@everfur/sdk 1.6.1 → 1.7.1

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-RF4N4WUN.js → chunk-25LX7XTO.js} +18 -18
  36. package/dist/{chunk-CQUKIPRU.js → chunk-7DLCYODF.js} +1 -1
  37. package/dist/{chunk-ZSCVH4UW.js → chunk-BFCVAT43.js} +16 -16
  38. package/dist/{chunk-DBQYQLJT.js → chunk-KR75CVE4.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,354 +1,355 @@
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
- import{createContext,forwardRef as e,createElement as t,lazy as r,useCallback as n,useMemo as l,useRef as i,useState as o,useEffect as a,useSyncExternalStore as s,useContext as u,Component as d,Fragment as c,Suspense as p}from"react";import*as f from"react-native";import{TextInput as h,StyleSheet as g,Platform as b,AppState as y,Text as m,View as v,Linking as w,KeyboardAvoidingView as k,Pressable as C,Dimensions as S,Keyboard as x,Modal as R,ScrollView as T,ActivityIndicator as _,Image as z,AccessibilityInfo as I,UIManager as P,LayoutAnimation as F,Animated as L,useWindowDimensions as E,FlatList as O}from"react-native";import{jsx as A,jsxs as j,Fragment as D}from"react/jsx-runtime";import{useSafeAreaInsets as M}from"react-native-safe-area-context";import*as B from"@everfur/sdk/texting";var H=/* @__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[H[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[H[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function W(e){return e<=450?"regular":e<=650?"medium":"bold"}var N={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=U.get(e);r===void 0&&(r=/* @__PURE__ */new Map,U.set(e,r));let n=r.get(t);if(n!==void 0)return n;let l=$(e,t);return r.set(t,l),l}var U=/* @__PURE__ */new WeakMap;function $(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,l=W(Number(n)),i=r.face==="mono"?face(e,N[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 V=/* @__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 q=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){q(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var G=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var K={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},Y={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},Q={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},Z={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},J={regular:"400",medium:"500",bold:"700"},X={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},ee=0,te="System",re="monospace",ne=["content","heading","control","compact","badge"];function le(e){let t={};for(let r of ne)t[r]=e;return t}var ie=[];function oe(){return{family:te,mono:re,fontUrl:null,families:{regular:te,medium:te,bold:te,mono:re,monoMedium:re,monoBold:re},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:Q,tierSizes:le(Q),lineHeight:Z,weight:J,letterSpacing:X,scale:1,maxScale:ee,scaleCaps:G,headingFamily:null,headingWeight:null,fontSources:ie,roles:V,typeScale:1}}var ae={},se=/* @__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 ue={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(se.standard),emphasized:cssCubicBezier(se.emphasized),exit:cssCubicBezier(se.exit)},reducedMotion:false},de={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)"},ce=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:de,space:K,radius:Y,type:oe(),motion:ue,slots:ae}),pe={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)"},fe=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:pe,space:K,radius:Y,type:oe(),motion:ue,slots:ae});var he=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),ge=globalThis,be=ge[he]??(ge[he]=createContext(ce));be.displayName??="EverfurThemeContext";function useEverfurTheme(){return u(be)}function ye(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:e,variant:r,...n}){let l=useEverfurTheme(),i=r===void 0?void 0:l.type.roles[r],o=ye(l.type,e??i?.tier??"content"),a=r===void 0?n:{...n,style:[{...textRole(l,r),color:l.color.text.primary,flexShrink:1},n.style]};return t(m,o===void 0?a:{maxFontSizeMultiplier:o,...a})}var me=e(function(e,r){return t(h,{...e,...r===null?{}:{ref:r}})});var ve=640,we=600,ke=/* @__PURE__ */Object.freeze({width:0,height:0}),Ce="useWindowDimensions"in f&&typeof f.useWindowDimensions=="function"?f.useWindowDimensions:()=>ke,Se=/* @__PURE__ */Object.freeze({width:"100%",maxWidth:ve,alignSelf:"center"});/* @__PURE__ */Object.freeze({...Se,flex:1});var xe=/* @__PURE__ */Object.freeze({...Se,flexGrow:1,flexShrink:1});function Re(){return Ce().width>=we}function Te(e="flow"){let{width:t}=Ce();if(t<we)return null;if(e==="flow")return Se;let r=Math.max(0,Math.round((t-ve)/2));return{left:r,right:r}}function _e(e,t){return t===null?e:[e,t]}var ze=/* @__PURE__ */Symbol.for("@everfur/sdk#InSdkColumn@v1"),Ie=globalThis,Pe=Ie[ze]??(Ie[ze]=createContext(false));Pe.displayName??="EverfurInSdkColumn";function SdkTabletColumn({children:e,style:t,testID:r}){let n=Re(),l=u(Pe);return!n||l?e:/* @__PURE__ */A(v,{style:t===void 0?xe:[xe,t],testID:r??"everfur-tablet-column",children:/* @__PURE__ */A(Pe.Provider,{value:true,children:e})})}var Fe=/* @__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}),Le=/* @__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"}),Ee=Object.keys(Le),Oe="presentation",Ae="presentation.";var je={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"]},De=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner","chatTextingAsk","serverSlots"]);function Me(e,t){if(t==null)return;let r=je[e];return r!==void 0?typeof t=="string"&&r.includes(t)?t:void 0:De.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 Ee){let n=Le[e],l=Object.prototype.hasOwnProperty.call(t,n)?t[n]:t[e],i=Me(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=`${Ae}${Le[e]}`;for(let e of t)if(e===Oe||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 Ee){let t=l[e],r=isPresentationFieldLocked(e,o)?void 0:i[e];a[e]=r??t??Fe[e]}/* @__PURE__ */
3
- return Object.freeze(a)}var Be="Go to the nearest emergency vet now.";var He=/* @__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:Be,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 We(e,t){return e.replace(/\{(\w+)\}/g,(e,r)=>{let n=t[r];return n===void 0?e:String(n)})}function Ne(e){return e?.trim()||He.emptyTitlePetFallback}function Ue(e,t){return We(e,{petName:Ne(t)})}var $e="tel:+18884264435";function ok(e,t){/* @__PURE__ */
2
+ import{createContext,forwardRef as e,createElement as t,lazy as r,useCallback as n,useMemo as l,useRef as i,useState as o,useEffect as a,useSyncExternalStore as s,useContext as u,Component as d,Fragment as c,Suspense as p}from"react";import*as f from"react-native";import{TextInput as h,StyleSheet as g,Platform as b,AppState as y,Text as m,View as v,Linking as w,KeyboardAvoidingView as k,Pressable as C,Dimensions as S,Keyboard as x,Modal as R,ScrollView as T,ActivityIndicator as _,Image as z,AccessibilityInfo as I,UIManager as P,LayoutAnimation as F,Animated as L,useWindowDimensions as E,FlatList as O}from"react-native";import{jsx as A,jsxs as j,Fragment as D}from"react/jsx-runtime";import{useSafeAreaInsets as M}from"react-native-safe-area-context";import*as B from"@everfur/sdk/texting";var H=/* @__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[H[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[H[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function W(e){return e<=450?"regular":e<=650?"medium":"bold"}var N={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=U.get(e);r===void 0&&(r=/* @__PURE__ */new Map,U.set(e,r));let n=r.get(t);if(n!==void 0)return n;let l=$(e,t);return r.set(t,l),l}var U=/* @__PURE__ */new WeakMap;function $(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,l=W(Number(n)),i=r.face==="mono"?face(e,N[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 V=/* @__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 q=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){q(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var G=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var K={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},Y={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},Q={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},Z={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},J={regular:"400",medium:"500",bold:"700"},X={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},ee=0,te="System",re="monospace",ne=["content","heading","control","compact","badge"];function le(e){let t={};for(let r of ne)t[r]=e;return t}var ie=[];function oe(){return{family:te,mono:re,fontUrl:null,families:{regular:te,medium:te,bold:te,mono:re,monoMedium:re,monoBold:re},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:Q,tierSizes:le(Q),lineHeight:Z,weight:J,letterSpacing:X,scale:1,maxScale:ee,scaleCaps:G,headingFamily:null,headingWeight:null,fontSources:ie,roles:V,typeScale:1}}var ae={},se=/* @__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 ue={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(se.standard),emphasized:cssCubicBezier(se.emphasized),exit:cssCubicBezier(se.exit)},reducedMotion:false},de={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)"},ce=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:de,space:K,radius:Y,type:oe(),motion:ue,slots:ae}),pe={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)"},fe=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:pe,space:K,radius:Y,type:oe(),motion:ue,slots:ae});var he=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),ge=globalThis,be=ge[he]??(ge[he]=createContext(ce));be.displayName??="EverfurThemeContext";function useEverfurTheme(){return u(be)}function ye(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:e,variant:r,...n}){let l=useEverfurTheme(),i=r===void 0?void 0:l.type.roles[r],o=ye(l.type,e??i?.tier??"content"),a=r===void 0?n:{...n,style:[{...textRole(l,r),color:l.color.text.primary,flexShrink:1},n.style]};return t(m,o===void 0?a:{maxFontSizeMultiplier:o,...a})}var me=e(function(e,r){return t(h,{...e,...r===null?{}:{ref:r}})});var ve=640,we=600,ke=/* @__PURE__ */Object.freeze({width:0,height:0}),Ce="useWindowDimensions"in f&&typeof f.useWindowDimensions=="function"?f.useWindowDimensions:()=>ke,Se=/* @__PURE__ */Object.freeze({width:"100%",maxWidth:ve,alignSelf:"center"});/* @__PURE__ */Object.freeze({...Se,flex:1});var xe=/* @__PURE__ */Object.freeze({...Se,flexGrow:1,flexShrink:1});function Re(){return Ce().width>=we}function Te(e="flow"){let{width:t}=Ce();if(t<we)return null;if(e==="flow")return Se;let r=Math.max(0,Math.round((t-ve)/2));return{left:r,right:r}}function _e(e,t){return t===null?e:[e,t]}var ze=/* @__PURE__ */Symbol.for("@everfur/sdk#InSdkColumn@v1"),Ie=globalThis,Pe=Ie[ze]??(Ie[ze]=createContext(false));Pe.displayName??="EverfurInSdkColumn";function SdkTabletColumn({children:e,style:t,testID:r}){let n=Re(),l=u(Pe);return!n||l?e:/* @__PURE__ */A(v,{style:t===void 0?xe:[xe,t],testID:r??"everfur-tablet-column",children:/* @__PURE__ */A(Pe.Provider,{value:true,children:e})})}var Fe=/* @__PURE__ */Object.freeze(["ask","vet","plan","records"]),Le=/* @__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"}),Ee=/* @__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"}),Oe=Object.keys(Ee),Ae="presentation",je="presentation.";var De={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 Me(e){if(!Array.isArray(e)||e.length===0)return;let t=/* @__PURE__ */new Set;for(let r of e){if(typeof r!="string"||!Fe.includes(r)||t.has(r))return;t.add(r)}/* @__PURE__ */
3
+ return Object.freeze([...e])}var Be=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner","chatTextingAsk","serverSlots"]);function He(e,t){if(t==null)return;if(e==="shellTabs")return Me(t);let r=De[e];return r!==void 0?typeof t=="string"&&r.includes(t)?t:void 0:Be.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 Oe){let n=Ee[e],l=Object.prototype.hasOwnProperty.call(t,n)?t[n]:t[e],i=He(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=`${je}${Ee[e]}`;for(let e of t)if(e===Ae||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 Oe){let t=l[e],r=isPresentationFieldLocked(e,o)?void 0:i[e];a[e]=r??t??Le[e]}/* @__PURE__ */
4
+ return Object.freeze(a)}var We="Go to the nearest emergency vet now.";var Ne=/* @__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:We,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 Ue(e,t){return e.replace(/\{(\w+)\}/g,(e,r)=>{let n=t[r];return n===void 0?e:String(n)})}function $e(e){return e?.trim()||Ne.emptyTitlePetFallback}function Ve(e,t){return Ue(e,{petName:$e(t)})}var qe="tel:+18884264435";function ok(e,t){/* @__PURE__ */
4
5
  return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
5
- return Object.freeze({ok:false,error:e})}var Ve=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var qe=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Ge=globalThis,Ke=Ge[qe]??(Ge[qe]=createContext(null));Ke.displayName??="EverfurContext";function Ye(){let e=u(Ke);if(e===null)throw new Ve("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}var Qe=[{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}],Ze=/* @__PURE__ */Object.freeze(Qe.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(Ze.map(e=>e.wireCode));var Je=/* @__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"}),Xe=/* @__PURE__ */Object.freeze(Ze.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:Je[e.wireCode]}))),et=new Map(Xe.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),tt=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(Xe.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",...tt]){let t=et.get(e+r);if(t)return t}}var rt=/* @__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 rt[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 nt=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return nt.has(e)}var lt=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||lt.has(e)}var it=500,ot=8e3,at=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(it*2**r,ot);return Math.floor(t()*n)}var st="This feature isn't available on your account right now.",ut="Something in that request was not right. Check the details and try again.",dt=/* @__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:st,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:ut,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:st,runtimeDisposed:ut,unknown:"Something went wrong. Please try again."}),ct="This session has ended. Please sign in again.",pt="linked_account_read_only";function ft(e,t,r){return e==="conflict"&&r===pt?st:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?ct:userFacingError(e)}function userFacingError(e){return dt[e]}function ht(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var gt=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===pt,l={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:ft(e,t?.wireCode,n?pt:null)};t?.httpStatus!==void 0&&(l.httpStatus=t.httpStatus),t?.requestId&&(l.requestId=t.requestId),typeof t?.reasonCode=="string"&&gt.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&&ht(l,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&ht(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__ */
6
- 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 bt="x-everfur-anon-token",yt="anonTokenInvalid";async function mt(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function vt(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[bt]=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:{...wt(e.headers),...authHeaders(t)}}}function wt(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===bt||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await mt(t),n=await t.transport.request(withAuthHeaders(e,kt(t,r)));if(n.ok||St(n.error.raw)!==yt||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,kt(t,l)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(vt(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(vt(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(Ct(i.error))):i}function kt(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function Ct(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 xt="free_cap_reached";function Rt(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Tt(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!==xt&&n.code!==xt)return null;let l=Rt(n.limit),i=Rt(n.used);if(l===null||i===null)return null;let o=n.resets_at,a=n.emergency_guidance;/* @__PURE__ */
7
- 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 _t(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:Tt(t)}function zt(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 Lt(e)}var It=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,Pt=/[\s\u0000-\u001f\u007f\\]/,Ft={"http:":"80","https:":"443"};function Lt(e,t){let r=e.trim();let n=Pt.test(r)?null:It.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",d="",c=""]=n,p=`${l.toLowerCase()}:`,f=Number(s);if(f>65535)return null;let h=s===""||String(f)===Ft[p]?"":String(f),g=Ft[p]!==void 0,b=a.toLowerCase()+(h&&`:${h}`),y=u||(g?"/":""),m=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${p}//${m}${b}${y}${d}${c}`,protocol:p,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:g?`${p}//${b}`:"null",pathname:y,search:d==="?"?"":d,hash:c==="#"?"":c}}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:Et(e)})}function Et(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var Ot=3e4,At=ot*2,jt="idempotency-key",Dt=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),Mt=/* @__PURE__ */Object.freeze({onEvent(){}}),Bt=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Ht(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??Mt,r=e.timers??Bt,n=e.rng??Math.random,l=e.sleep??((e,t)=>rr(e,r,t)),i=e.maxAttempts??at,o=e.unaryTimeoutMs??Ot,a=e.newIdempotencyKey??Nt(),s=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,d){let c=d?.maxAttempts,p=Math.max(1,c??i),f=d?.idempotent??Dt.has(u.method),h=d?.idempotencyKey===void 0?null:Ht(d.idempotencyKey),g=f?h??a():null,b=Wt(u,g),y=0;for(;;){let i=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:y,...g?{idempotencyKey:g}:{},...e});s(i({phase:"attempt"}));let a=er(o,r),d=tr(a.signal,u.signal),f;try{f=await authedSend({...b,signal:d.signal},e.auth)}catch(e){f=err(networkError(e))}finally{d.dispose(),a.cancel()}if(f.ok)return s(i({phase:"settled",ok:true,reason:"ok"})),f;let h=f.error,m=$t(h,y,{maxAttempts:p,rng:n,now:r.now(),aborted:u.signal?.aborted===true,...c!==void 0?{perCallMaxAttempts:c}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),v={ok:false,code:h.code,reason:m.reason,...h.httpStatus!==void 0?{httpStatus:h.httpStatus}:{},...h.requestId!==void 0?{requestId:h.requestId}:{}};if(!m.retry)return s(i({phase:"settled",...v})),err(h);if(s(i({phase:"retry",...v,delayMs:m.delayMs})),await l(m.delayMs,u.signal),u.signal?.aborted===true)return s(i({phase:"settled",...v,reason:"aborted"})),err(h);y+=1}}async function d(t){return withAuthHeaders(t,await Xt(e.auth))}async function*c(t,r,n){s(
6
+ return Object.freeze({ok:false,error:e})}var Ge=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var Ke=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Ye=globalThis,Qe=Ye[Ke]??(Ye[Ke]=createContext(null));Qe.displayName??="EverfurContext";function Ze(){let e=u(Qe);if(e===null)throw new Ge("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}var Je=[{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}],Xe=/* @__PURE__ */Object.freeze(Je.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(Xe.map(e=>e.wireCode));var et=/* @__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"}),tt=/* @__PURE__ */Object.freeze(Xe.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:et[e.wireCode]}))),rt=new Map(tt.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),nt=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(tt.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",...nt]){let t=rt.get(e+r);if(t)return t}}var lt=/* @__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 lt[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 it=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return it.has(e)}var ot=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||ot.has(e)}var at=500,st=8e3,ut=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(at*2**r,st);return Math.floor(t()*n)}var dt="This feature isn't available on your account right now.",ct="Something in that request was not right. Check the details and try again.",pt=/* @__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:dt,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:ct,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:dt,runtimeDisposed:ct,unknown:"Something went wrong. Please try again."}),ft="This session has ended. Please sign in again.",ht="linked_account_read_only";function gt(e,t,r){return e==="conflict"&&r===ht?dt:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?ft:userFacingError(e)}function userFacingError(e){return pt[e]}function bt(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var yt=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===ht,l={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:gt(e,t?.wireCode,n?ht:null)};t?.httpStatus!==void 0&&(l.httpStatus=t.httpStatus),t?.requestId&&(l.requestId=t.requestId),typeof t?.reasonCode=="string"&&yt.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&&bt(l,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&bt(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 mt="x-everfur-anon-token",vt="anonTokenInvalid";async function wt(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function kt(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[mt]=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:{...Ct(e.headers),...authHeaders(t)}}}function Ct(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===mt||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await wt(t),n=await t.transport.request(withAuthHeaders(e,St(t,r)));if(n.ok||Rt(n.error.raw)!==vt||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(kt(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(kt(e,{wireCode:Rt(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(xt(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 xt(e){let t=e.raw,r=Rt(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 Rt(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 Tt="free_cap_reached";function _t(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function zt(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!==Tt&&n.code!==Tt)return null;let l=_t(n.limit),i=_t(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 It(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:zt(t)}function Pt(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 Ot(e)}var Ft=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,Lt=/[\s\u0000-\u001f\u007f\\]/,Et={"http:":"80","https:":"443"};function Ot(e,t){let r=e.trim();let n=Lt.test(r)?null:Ft.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",d="",c=""]=n,p=`${l.toLowerCase()}:`,f=Number(s);if(f>65535)return null;let h=s===""||String(f)===Et[p]?"":String(f),g=Et[p]!==void 0,b=a.toLowerCase()+(h&&`:${h}`),y=u||(g?"/":""),m=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${p}//${m}${b}${y}${d}${c}`,protocol:p,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:g?`${p}//${b}`:"null",pathname:y,search:d==="?"?"":d,hash:c==="#"?"":c}}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:At(e)})}function At(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var jt=3e4,Dt=st*2,Mt="idempotency-key",Bt=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),Ht=/* @__PURE__ */Object.freeze({onEvent(){}}),Wt=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Nt(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??Ht,r=e.timers??Wt,n=e.rng??Math.random,l=e.sleep??((e,t)=>lr(e,r,t)),i=e.maxAttempts??ut,o=e.unaryTimeoutMs??jt,a=e.newIdempotencyKey??$t(),s=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,d){let c=d?.maxAttempts,p=Math.max(1,c??i),f=d?.idempotent??Bt.has(u.method),h=d?.idempotencyKey===void 0?null:Nt(d.idempotencyKey),g=f?h??a():null,b=Ut(u,g),y=0;for(;;){let i=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:y,...g?{idempotencyKey:g}:{},...e});s(i({phase:"attempt"}));let a=rr(o,r),d=nr(a.signal,u.signal),f;try{f=await authedSend({...b,signal:d.signal},e.auth)}catch(e){f=err(networkError(e))}finally{d.dispose(),a.cancel()}if(f.ok)return s(i({phase:"settled",ok:true,reason:"ok"})),f;let h=f.error,m=qt(h,y,{maxAttempts:p,rng:n,now:r.now(),aborted:u.signal?.aborted===true,...c!==void 0?{perCallMaxAttempts:c}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),v={ok:false,code:h.code,reason:m.reason,...h.httpStatus!==void 0?{httpStatus:h.httpStatus}:{},...h.requestId!==void 0?{requestId:h.requestId}:{}};if(!m.retry)return s(i({phase:"settled",...v})),err(h);if(s(i({phase:"retry",...v,delayMs:m.delayMs})),await l(m.delayMs,u.signal),u.signal?.aborted===true)return s(i({phase:"settled",...v,reason:"aborted"})),err(h);y+=1}}async function d(t){return withAuthHeaders(t,await tr(e.auth))}async function*c(t,r,n){s(
8
9
  /* @__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__ */
9
- return Object.freeze({send:u,authorize:d,stream:c})}function Wt(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==jt&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function Nt(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var Ut=10;function $t(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=Vt(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(Ut,Math.floor(t)))},o=r.perCallMaxAttempts??i()??r.maxAttempts;if(t+1>=o)return{retry:false,reason:"attempts-exhausted"};let a=qt(e,r.now);return a!==null?a>At?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:l,delayMs:a}:{retry:true,reason:l,delayMs:backoffDelayMs(t,r.rng)}}function Vt(e){let t=e.code==="unknown"?fromWire(Zt(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function qt(e,t){let r=Kt(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=Gt(e.raw);return n===null?null:Math.round(n*1e3)}function Gt(e){for(let t of Yt(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function Kt(e){for(let t of Yt(e)){let e=t.resets_at,r=Qt(e);if(r!==null)return r}return null}function Yt(e){if(!Jt(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];Jt(n)&&t.push(n)}return t}function Qt(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 Zt(e){for(let t of Yt(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function Jt(e){return typeof e=="object"&&e!==null}async function Xt(e){if(e.mode==="anonymous"){let t=await mt(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 er(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function tr(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 rr(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 nr(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function lr(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 ir(e){return e.ok?e:err(lr(e.error))}function or(e){return{send:async(...t)=>ir(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var ar=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function sr(e){let t=ar(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}var ur=6;function dr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=400?e:null}function cr(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__ */
10
- return Object.freeze(n)}function pr(e){let t=ar(e.title,80),r=ar(e.body,600);return t===null||r===null?null:/* @__PURE__ */Object.freeze({title:t,body:r})}function fr(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=sr(e);t!==null&&r.length<ur&&r.push(t)}let n=cr(t.doses,e=>{let t=ar(e.label,60),r=ar(e.amount,60);return t===null||r===null?null:/* @__PURE__ */Object.freeze({label:t,amount:r,minLb:dr(e.minLb??e.min_lb),maxLb:dr(e.maxLb??e.max_lb)})},ur),l=cr(t.details,pr,ur),i=t.fit,o=i!==null&&typeof i=="object"&&!Array.isArray(i)?pr(i):null,a=o!==null&&i.pet===true?/* @__PURE__ */Object.freeze({...o,pet:true}):o,s=/* @__PURE__ */Object.freeze({kicker:ar(t.kicker,80),gallery:/* @__PURE__ */Object.freeze(r),doses:n,details:l,fine:ar(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 hr=128;var gr=/* @__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"]),br=/* @__PURE__ */new Set(["y","c","g","r"]),yr=/* @__PURE__ */new Set(["done","now","next"]),mr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null,vr=(e,t=1e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null,wr=e=>typeof e=="string"&&/^[A-Za-z0-9_-]{1,40}$/.test(e)?e:null,kr=e=>typeof e=="string"&&gr.has(e)?e:null;function Cr(e){let t=vr(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):vr(e,hr);function xr(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Rr(e){/* @__PURE__ */
11
- return Object.freeze(Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)))}function Tr(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 _r=(e,t=12,r=300)=>Tr(e,e=>vr(e,r),t);function zr(e){let t=mr(e),r=vr(t?.kicker,120),n=vr(t?.title,300);if(t===null||r===null||n===null)return null;let l=mr(t.risk),i=mr(t.odds),o=mr(t.quote),a=mr(t.jump);return Rr({kicker:r,title:n,sources:Tr(t.sources,e=>{let t=vr(mr(e)?.label,60);return t===null?null:Rr({label:t,kind:wr(mr(e)?.kind)})},6),risk:vr(l?.lead,300)===null?null:Rr({lead:vr(l?.lead,300),body:vr(l?.body),kind:wr(l?.kind)}),odds:vr(i?.label,120)===null||vr(i?.from,20)===null||vr(i?.to,20)===null?null:Rr({label:vr(i?.label,120),tag:vr(i?.tag,40),from:vr(i?.from,20),to:vr(i?.to,20),toLabel:vr(i?.toLabel,120)}),quote:vr(o?.text)===null?null:Rr({kicker:vr(o?.kicker,120),tag:vr(o?.tag,40),text:vr(o?.text)}),jump:vr(a?.title,300)===null||vr(a?.go,60)===null?null:Rr({title:vr(a?.title,300),go:vr(a?.go,60)}),report:Ir(t.report)})}function Ir(e){let t=mr(e),r=vr(t?.label,120),n=vr(t?.text,1200);return r===null||n===null?null:Rr({label:r,text:n,actions:_r(t?.actions,5,300)})}function Pr(e){let t=mr(e),r=vr(t?.title,300),n=Tr(t?.steps,e=>{let t=mr(e),r=vr(t?.title,300),n=t?.tone;return r===null?null:Rr({title:r,body:vr(t?.body),source:vr(t?.source,200),tone:typeof n=="string"&&br.has(n)?n:null,icon:kr(t?.icon),fromVet:t?.fromVet===true?true:null})});return r===null||n===null?null:Rr({title:r,label:vr(t?.label,60),steps:n})}function Fr(e){let t=mr(e),r=vr(t?.title,300);if(t===null||r===null)return null;let n=mr(t.rating),l=mr(t.reviews),i=mr(t.why),o=mr(i?.score),a=mr(t.dose),s=mr(t.ingredients),u=Tr(l?.items,e=>{let t=mr(e),r=t?.stars,n=vr(t?.text),l=vr(t?.by,80);return typeof r!="number"||!Number.isFinite(r)||r<1||r>5||n===null||l===null?null:Rr({stars:Math.round(r),text:n,by:l})},5),d=Tr(i?.rows,e=>{let t=mr(e),r=vr(t?.chip,40),n=vr(t?.title,300);return r===null||n===null?null:Rr({chip:r,kind:wr(t?.kind),title:n,body:vr(t?.body)})}),c=Tr(a?.stats,e=>{let t=mr(e),r=vr(t?.value,40),n=vr(t?.label,120),l=t?.kind;return r===null||n===null?null:Rr({value:r,label:n,kind:l==="weight"||l==="dose"||l==="days"?l:null})},6),p=_r(s?.items,12,80);return Rr({title:r,none:t.none===true?true:null,hidden:t.none===true&&t.hidden===true?true:null,productId:Sr(t.productId),partnerSku:vr(t.partnerSku,200),rating:vr(n?.value,20)===null?null:Rr({value:vr(n?.value,20),label:vr(n?.label,120)}),line:vr(t.line),reviews:vr(l?.label,200)===null||u===null?null:Rr({label:vr(l?.label,200),items:u}),checkoutLine:vr(t.checkoutLine,300),why:vr(i?.title,200)===null||d===null?null:Rr({title:vr(i?.title,200),rows:d,score:vr(o?.text,200)===null||vr(o?.value,20)===null?null:Rr({text:vr(o?.text,200),value:vr(o?.value,20)})}),dose:vr(a?.title,200)===null||c===null?null:Rr({title:vr(a?.title,200),stats:c,note:vr(a?.note)}),doseLabel:vr(t.doseLabel,120),ingredients:p===null?null:Rr({label:vr(s?.label,200),items:p}),proof:vr(t.proof,300),trust:Tr(t.trust,e=>{let t=mr(e),r=kr(t?.icon),n=vr(t?.label,120);return r===null||n===null?null:Rr({icon:r,label:n})},6),more:vr(t.more,120),fine:vr(t.fine),checkin:vr(t.checkin,200),detail:fr(t.detail)??null})}function Lr(e){let t=mr(e),r=vr(t?.title,200),n=Tr(t?.items,e=>{let t=mr(e),r=vr(t?.title,300),n=vr(t?.body);return r===null||n===null?null:Rr({title:r,body:n,urgent:t?.urgent===true?true:null,callVet:t?.callVet===true?true:null})});return r===null||n===null?null:Rr({title:r,items:n})}function Er(e){let t=mr(e),r=vr(t?.title,200),n=_r(t?.questions,12,300),l=vr(t?.add,80),i=vr(t?.added,80);return r===null||n===null||l===null||i===null?null:Rr({title:r,questions:n,add:l,added:i})}function Or(e){let t=mr(e),r=vr(t?.title,200),n=Tr(t?.items,e=>{let t=mr(e),r=vr(t?.key,hr),n=vr(t?.title,300),l=vr(t?.action,80),i=Sr(t?.productId),o=vr(t?.added,80)??(i!==null?l:null);return r===null||n===null||l===null||o===null?null:Rr({key:r,productId:i,title:n,body:vr(t?.body),price:vr(t?.price,40),was:vr(t?.was,40),tag:vr(t?.tag,40),imageUrl:Cr(t?.imageUrl),icon:kr(t?.icon),kind:wr(t?.kind),action:l,added:o,owned:t?.owned===true?true:null,detail:fr(t?.detail)??null})},6);return r===null||n===null?null:Rr({title:r,items:n})}function Ar(e){let t=mr(e),r=vr(t?.kicker,120),n=vr(t?.title,120);return t===null||r===null||n===null?null:Rr({kicker:r,title:n,icon:kr(t.icon),track:Tr(t.track,e=>{let t=mr(e),r=vr(t?.title,120),n=t?.state;return r===null?null:Rr({title:r,detail:vr(t?.detail,120),state:typeof n=="string"&&yr.has(n)?n:null,tag:vr(t?.tag,40)})},6),heading:vr(t.heading,200),rows:Tr(t.rows,e=>{let t=mr(e),r=kr(t?.icon),n=vr(t?.label,120);if(r===null||n===null)return null;if(t?.fromVet===true)return Rr({icon:r,label:n,text:"",fromVet:true});let l=vr(t?.text,300);return l===null?null:Rr({icon:r,label:n,text:l})},6),note:vr(t.note,300),action:vr(t.action,80)})}function healthPlanFocusDesignFromWire(e){let t=mr(e),r=vr(t?.title,300),n=Fr(t?.pick);if(t===null||r===null||n===null)return null;let l=mr(t.byline);return Rr({eyebrow:vr(t.eyebrow,120),title:r,subtitle:vr(t.subtitle,300),subtitleNoRecords:vr(t.subtitleNoRecords,300),headImageUrl:Cr(t.headImageUrl),byline:vr(l?.name,120)===null?null:Rr({name:vr(l?.name,120),role:vr(l?.role,120),imageUrl:Cr(l?.imageUrl),shortName:vr(l?.shortName,60)}),focus:zr(t.focus),routine:Pr(t.routine),pick:n,signs:Lr(t.signs),checkup:Er(t.checkup),extras:Or(t.extras),wait:Ar(t.wait),fine:vr(t.fine),checkoutRows:Tr(t.checkoutRows,e=>{let t=mr(e),r=kr(t?.icon),n=vr(t?.label,60),l=vr(t?.value,200);return r===null||n===null||l===null?null:Rr({icon:r,label:n,value:l})},6)})}function healthPlanPageFromWire(e,petRef){let t=mr(e);if(t===null||!("page"in t))return null;let r=mr(t.pet),n=r?.sex;/* @__PURE__ */
12
- return Object.freeze({petRef:vr(t.pet_ref,hr)??petRef,pet:/* @__PURE__ */Object.freeze({name:vr(r?.name,120),species:vr(r?.species,60),sex:n==="female"||n==="male"?n:null,breed:vr(r?.breed,120),weightKg:xr(r?.weight_kg),weightLb:xr(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 jr(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Dr(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the expected shape`})}function Mr(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}var Br=e=>typeof e=="string"&&e.length>0&&e.length<=hr;function Hr(petRef){return`/widget/v1/pets/${encodeURIComponent(petRef)}/plan`}async function Wr(e,petRef,t){if(!Br(petRef))return err(jr("petRef must be 1..128 characters"));let r=await e.send("healthPlan.page.read",{method:"GET",path:`${Hr(petRef)}/page`,...t?.signal?{signal:t.signal}:{}});if(!r.ok)return err(r.error);let n=healthPlanPageFromWire(r.value,petRef);return n===null?err(Dr("healthPlan.page.read")):ok(n)}var Nr=/* @__PURE__ */new WeakMap;function Ur(e){let t=Nr.get(e);if(t!==void 0)return t;let r=$r(e);return Nr.set(e,r),r}function $r(e){return{getPage:(petRef,t)=>{if(e.isDisposed)return Promise.resolve(err(Mr("getPage")));let{services:r}=e.registry,n=or(createRequestFunnel({auth:r.authFor(null),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}));return Wr(n,petRef,t)}}}function Vr(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function qr(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function Gr(e,...t){if(typeof e=="function")try{let r=e(...t);return qr(r)&&Promise.resolve(r).then(void 0,Vr),r}catch(e){Vr(e);return}}var Kr=/* @__PURE__ */new WeakMap;function Yr(e){if(typeof e!="function")return;let t=Kr.get(e);if(t!==void 0)return t;let r=(...t)=>{Gr(e,...t)};return Kr.set(e,r),r}function Qr(e,...t){let r;try{r=e(...t)}catch(e){return Vr(e),Promise.resolve({ok:false,error:e})}return Promise.resolve(r).then(e=>({ok:true,value:e}),e=>({ok:false,error:e}))}var Zr=6e4;function Jr({lifecycle:e,refreshKey:t,readyAt:r,revalidate:n,refresh:l,now:o=Date.now}){let s=i({readyAt:r,revalidate:n,refresh:l??n,now:o});s.current={readyAt:r,revalidate:n,refresh:l??n,now:o},a(()=>{if(e==null)return;let t=Gr(()=>e.onForeground(()=>{let{readyAt:e,revalidate:t,now:r}=s.current;e!==null&&r()-e>=Zr&&t()}));return()=>{typeof t=="function"&&Gr(t)}},[e]);let u=i(t);a(()=>{Object.is(u.current,t)||(u.current=t,s.current.refresh())},[t])}var Xr=Zr,en=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanPageReads@v1");function tn(){let e=globalThis,t=e[en];if(t instanceof WeakMap)return t;let r=/* @__PURE__ */new WeakMap;return e[en]=r,r}function rn(e,t,userRef,petRef,r){let n=tn(),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<Xr))return a.promise;let s={at:null,promise:e.getPage(petRef).then(e=>(i.get(o)===s&&(e.ok||nr(e.error)?s.at=Date.now():i.delete(o)),e))};return i.set(o,s),s.promise}function useHealthPlanPage(e){let{userRef:userRef,runtime:t}=Ye(),r=l(()=>Ur(t),[t]),s=e.repository,u=s??r,d=n((e,n)=>s!==void 0||userRef==null?u.getPage(e):rn(r,t,userRef,e,n),[s,u,r,t,userRef]),{petRef:petRef}=e,c=e.enabled!==false&&userRef!=null&&petRef!==null,[p,f]=o({phase:"idle",petRef:null,page:null,error:null}),h=i(0),g=i(0),b=n(async e=>{let t=++h.current;if(!c||petRef===null){f(e=>e.phase==="idle"&&e.petRef===null?e:{phase:"idle",petRef:null,page:null,error:null});return}f(e=>({phase:"loading",petRef:petRef,page:e.petRef===petRef?e.page:null,error:null}));let r=await d(petRef,e);t===h.current&&(r.ok?f({phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}):nr(r.error)?f({phase:"ready",petRef:petRef,page:null,error:null,missing:true,readyAt:Date.now()}):f({phase:"failed",petRef:petRef,page:null,error:r.error}))},[c,petRef,d]),y=n(()=>b(true),[b]),m=p.phase==="ready"&&p.petRef===petRef,v=n(async()=>{if(!c||petRef===null||!m)return;let e=h.current,t=++g.current,r=await d(petRef,true);e!==h.current||t!==g.current||!r.ok||f(e=>e.phase==="ready"&&e.petRef===petRef?{phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}:e)},[c,petRef,m,d]);Jr({lifecycle:e.lifecycle,refreshKey:e.refreshKey,readyAt:m?p.readyAt??null:null,revalidate:()=>{v()},refresh:()=>{m?v():y()}}),a(()=>(b(false),()=>{h.current+=1}),[b]);let w=c&&p.petRef!==petRef;return l(()=>({phase:w?"loading":p.phase,page:w?null:p.page,error:w?null:p.error,missing:!w&&p.missing===true,refresh:y}),[w,p,y])}var nn=/* @__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 nn[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 an({name:e,enabled:false,isPending:true,limits:{}});let i=ln(n,l);return n.filter(e=>l.get(e)?.granted!==true).length===0?an({name:e,enabled:true,isPending:false,limits:i}):an({name:e,enabled:false,isPending:false,limits:i,disabled:on(n,l)})}function ln(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 on(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
10
+ return Object.freeze({send:u,authorize:d,stream:c})}function Ut(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==Mt&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function $t(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var Vt=10;function qt(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=Gt(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(Vt,Math.floor(t)))},o=r.perCallMaxAttempts??i()??r.maxAttempts;if(t+1>=o)return{retry:false,reason:"attempts-exhausted"};let a=Kt(e,r.now);return a!==null?a>Dt?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:l,delayMs:a}:{retry:true,reason:l,delayMs:backoffDelayMs(t,r.rng)}}function Gt(e){let t=e.code==="unknown"?fromWire(Xt(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function Kt(e,t){let r=Qt(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=Yt(e.raw);return n===null?null:Math.round(n*1e3)}function Yt(e){for(let t of Zt(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function Qt(e){for(let t of Zt(e)){let e=t.resets_at,r=Jt(e);if(r!==null)return r}return null}function Zt(e){if(!er(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];er(n)&&t.push(n)}return t}function Jt(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 Xt(e){for(let t of Zt(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function er(e){return typeof e=="object"&&e!==null}async function tr(e){if(e.mode==="anonymous"){let t=await wt(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 rr(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function nr(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 lr(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 ir(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function or(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 ar(e){return e.ok?e:err(or(e.error))}function sr(e){return{send:async(...t)=>ar(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var ur=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function dr(e){let t=ur(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}var cr=6;function pr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=400?e:null}function fr(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 hr(e){let t=ur(e.title,80),r=ur(e.body,600);return t===null||r===null?null:/* @__PURE__ */Object.freeze({title:t,body:r})}function gr(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=dr(e);t!==null&&r.length<cr&&r.push(t)}let n=fr(t.doses,e=>{let t=ur(e.label,60),r=ur(e.amount,60);return t===null||r===null?null:/* @__PURE__ */Object.freeze({label:t,amount:r,minLb:pr(e.minLb??e.min_lb),maxLb:pr(e.maxLb??e.max_lb)})},cr),l=fr(t.details,hr,cr),i=t.fit,o=i!==null&&typeof i=="object"&&!Array.isArray(i)?hr(i):null,a=o!==null&&i.pet===true?/* @__PURE__ */Object.freeze({...o,pet:true}):o,s=/* @__PURE__ */Object.freeze({kicker:ur(t.kicker,80),gallery:/* @__PURE__ */Object.freeze(r),doses:n,details:l,fine:ur(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 br=128;var yr=/* @__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"]),mr=/* @__PURE__ */new Set(["y","c","g","r"]),vr=/* @__PURE__ */new Set(["done","now","next"]),wr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null,kr=(e,t=1e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null,Cr=e=>typeof e=="string"&&/^[A-Za-z0-9_-]{1,40}$/.test(e)?e:null,Sr=e=>typeof e=="string"&&yr.has(e)?e:null;function xr(e){let t=kr(e,2048);return t===null||/\s/.test(t)?null:/^https:\/\/[^/]/i.test(t)||/^\/(?![/\\])/.test(t)?t:null}var Rr=e=>typeof e=="number"&&Number.isInteger(e)?String(e):kr(e,br);function Tr(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function _r(e){/* @__PURE__ */
12
+ return Object.freeze(Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)))}function zr(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 Ir=(e,t=12,r=300)=>zr(e,e=>kr(e,r),t);function Pr(e){let t=wr(e),r=kr(t?.kicker,120),n=kr(t?.title,300);if(t===null||r===null||n===null)return null;let l=wr(t.risk),i=wr(t.odds),o=wr(t.quote),a=wr(t.jump);return _r({kicker:r,title:n,sources:zr(t.sources,e=>{let t=kr(wr(e)?.label,60);return t===null?null:_r({label:t,kind:Cr(wr(e)?.kind)})},6),risk:kr(l?.lead,300)===null?null:_r({lead:kr(l?.lead,300),body:kr(l?.body),kind:Cr(l?.kind)}),odds:kr(i?.label,120)===null||kr(i?.from,20)===null||kr(i?.to,20)===null?null:_r({label:kr(i?.label,120),tag:kr(i?.tag,40),from:kr(i?.from,20),to:kr(i?.to,20),toLabel:kr(i?.toLabel,120)}),quote:kr(o?.text)===null?null:_r({kicker:kr(o?.kicker,120),tag:kr(o?.tag,40),text:kr(o?.text)}),jump:kr(a?.title,300)===null||kr(a?.go,60)===null?null:_r({title:kr(a?.title,300),go:kr(a?.go,60)}),report:Fr(t.report)})}function Fr(e){let t=wr(e),r=kr(t?.label,120),n=kr(t?.text,1200);return r===null||n===null?null:_r({label:r,text:n,actions:Ir(t?.actions,5,300)})}function Lr(e){let t=wr(e),r=kr(t?.title,300),n=zr(t?.steps,e=>{let t=wr(e),r=kr(t?.title,300),n=t?.tone;return r===null?null:_r({title:r,body:kr(t?.body),source:kr(t?.source,200),tone:typeof n=="string"&&mr.has(n)?n:null,icon:Sr(t?.icon),fromVet:t?.fromVet===true?true:null})});return r===null||n===null?null:_r({title:r,label:kr(t?.label,60),steps:n})}function Er(e){let t=wr(e),r=kr(t?.title,300);if(t===null||r===null)return null;let n=wr(t.rating),l=wr(t.reviews),i=wr(t.why),o=wr(i?.score),a=wr(t.dose),s=wr(t.ingredients),u=zr(l?.items,e=>{let t=wr(e),r=t?.stars,n=kr(t?.text),l=kr(t?.by,80);return typeof r!="number"||!Number.isFinite(r)||r<1||r>5||n===null||l===null?null:_r({stars:Math.round(r),text:n,by:l})},5),d=zr(i?.rows,e=>{let t=wr(e),r=kr(t?.chip,40),n=kr(t?.title,300);return r===null||n===null?null:_r({chip:r,kind:Cr(t?.kind),title:n,body:kr(t?.body)})}),c=zr(a?.stats,e=>{let t=wr(e),r=kr(t?.value,40),n=kr(t?.label,120),l=t?.kind;return r===null||n===null?null:_r({value:r,label:n,kind:l==="weight"||l==="dose"||l==="days"?l:null})},6),p=Ir(s?.items,12,80);return _r({title:r,none:t.none===true?true:null,hidden:t.none===true&&t.hidden===true?true:null,productId:Rr(t.productId),partnerSku:kr(t.partnerSku,200),rating:kr(n?.value,20)===null?null:_r({value:kr(n?.value,20),label:kr(n?.label,120)}),line:kr(t.line),reviews:kr(l?.label,200)===null||u===null?null:_r({label:kr(l?.label,200),items:u}),checkoutLine:kr(t.checkoutLine,300),why:kr(i?.title,200)===null||d===null?null:_r({title:kr(i?.title,200),rows:d,score:kr(o?.text,200)===null||kr(o?.value,20)===null?null:_r({text:kr(o?.text,200),value:kr(o?.value,20)})}),dose:kr(a?.title,200)===null||c===null?null:_r({title:kr(a?.title,200),stats:c,note:kr(a?.note)}),doseLabel:kr(t.doseLabel,120),ingredients:p===null?null:_r({label:kr(s?.label,200),items:p}),proof:kr(t.proof,300),trust:zr(t.trust,e=>{let t=wr(e),r=Sr(t?.icon),n=kr(t?.label,120);return r===null||n===null?null:_r({icon:r,label:n})},6),more:kr(t.more,120),fine:kr(t.fine),checkin:kr(t.checkin,200),detail:gr(t.detail)??null})}function Or(e){let t=wr(e),r=kr(t?.title,200),n=zr(t?.items,e=>{let t=wr(e),r=kr(t?.title,300),n=kr(t?.body);return r===null||n===null?null:_r({title:r,body:n,urgent:t?.urgent===true?true:null,callVet:t?.callVet===true?true:null})});return r===null||n===null?null:_r({title:r,items:n})}function Ar(e){let t=wr(e),r=kr(t?.title,200),n=Ir(t?.questions,12,300),l=kr(t?.add,80),i=kr(t?.added,80);return r===null||n===null||l===null||i===null?null:_r({title:r,questions:n,add:l,added:i})}function jr(e){let t=wr(e),r=kr(t?.title,200),n=zr(t?.items,e=>{let t=wr(e),r=kr(t?.key,br),n=kr(t?.title,300),l=kr(t?.action,80),i=Rr(t?.productId),o=kr(t?.added,80)??(i!==null?l:null);return r===null||n===null||l===null||o===null?null:_r({key:r,productId:i,title:n,body:kr(t?.body),price:kr(t?.price,40),was:kr(t?.was,40),tag:kr(t?.tag,40),imageUrl:xr(t?.imageUrl),icon:Sr(t?.icon),kind:Cr(t?.kind),action:l,added:o,owned:t?.owned===true?true:null,detail:gr(t?.detail)??null})},6);return r===null||n===null?null:_r({title:r,items:n})}function Dr(e){let t=wr(e),r=kr(t?.kicker,120),n=kr(t?.title,120);return t===null||r===null||n===null?null:_r({kicker:r,title:n,icon:Sr(t.icon),track:zr(t.track,e=>{let t=wr(e),r=kr(t?.title,120),n=t?.state;return r===null?null:_r({title:r,detail:kr(t?.detail,120),state:typeof n=="string"&&vr.has(n)?n:null,tag:kr(t?.tag,40)})},6),heading:kr(t.heading,200),rows:zr(t.rows,e=>{let t=wr(e),r=Sr(t?.icon),n=kr(t?.label,120);if(r===null||n===null)return null;if(t?.fromVet===true)return _r({icon:r,label:n,text:"",fromVet:true});let l=kr(t?.text,300);return l===null?null:_r({icon:r,label:n,text:l})},6),note:kr(t.note,300),action:kr(t.action,80)})}function healthPlanFocusDesignFromWire(e){let t=wr(e),r=kr(t?.title,300),n=Er(t?.pick);if(t===null||r===null||n===null)return null;let l=wr(t.byline);return _r({eyebrow:kr(t.eyebrow,120),title:r,subtitle:kr(t.subtitle,300),subtitleNoRecords:kr(t.subtitleNoRecords,300),headImageUrl:xr(t.headImageUrl),byline:kr(l?.name,120)===null?null:_r({name:kr(l?.name,120),role:kr(l?.role,120),imageUrl:xr(l?.imageUrl),shortName:kr(l?.shortName,60)}),focus:Pr(t.focus),routine:Lr(t.routine),pick:n,signs:Or(t.signs),checkup:Ar(t.checkup),extras:jr(t.extras),wait:Dr(t.wait),fine:kr(t.fine),checkoutRows:zr(t.checkoutRows,e=>{let t=wr(e),r=Sr(t?.icon),n=kr(t?.label,60),l=kr(t?.value,200);return r===null||n===null||l===null?null:_r({icon:r,label:n,value:l})},6)})}function healthPlanPageFromWire(e,petRef){let t=wr(e);if(t===null||!("page"in t))return null;let r=wr(t.pet),n=r?.sex;/* @__PURE__ */
13
+ return Object.freeze({petRef:kr(t.pet_ref,br)??petRef,pet:/* @__PURE__ */Object.freeze({name:kr(r?.name,120),species:kr(r?.species,60),sex:n==="female"||n==="male"?n:null,breed:kr(r?.breed,120),weightKg:Tr(r?.weight_kg),weightLb:Tr(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 Mr(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Br(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the expected shape`})}function Hr(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}var Wr=e=>typeof e=="string"&&e.length>0&&e.length<=br;function Nr(petRef){return`/widget/v1/pets/${encodeURIComponent(petRef)}/plan`}async function Ur(e,petRef,t){if(!Wr(petRef))return err(Mr("petRef must be 1..128 characters"));let r=await e.send("healthPlan.page.read",{method:"GET",path:`${Nr(petRef)}/page`,...t?.signal?{signal:t.signal}:{}});if(!r.ok)return err(r.error);let n=healthPlanPageFromWire(r.value,petRef);return n===null?err(Br("healthPlan.page.read")):ok(n)}var $r=/* @__PURE__ */new WeakMap;function Vr(e){let t=$r.get(e);if(t!==void 0)return t;let r=qr(e);return $r.set(e,r),r}function qr(e){return{getPage:(petRef,t)=>{if(e.isDisposed)return Promise.resolve(err(Hr("getPage")));let{services:r}=e.registry,n=sr(createRequestFunnel({auth:r.authFor(null),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}));return Ur(n,petRef,t)}}}function Gr(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function Kr(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function Yr(e,...t){if(typeof e=="function")try{let r=e(...t);return Kr(r)&&Promise.resolve(r).then(void 0,Gr),r}catch(e){Gr(e);return}}var Qr=/* @__PURE__ */new WeakMap;function Zr(e){if(typeof e!="function")return;let t=Qr.get(e);if(t!==void 0)return t;let r=(...t)=>{Yr(e,...t)};return Qr.set(e,r),r}function Jr(e,...t){let r;try{r=e(...t)}catch(e){return Gr(e),Promise.resolve({ok:false,error:e})}return Promise.resolve(r).then(e=>({ok:true,value:e}),e=>({ok:false,error:e}))}var Xr=6e4;function en({lifecycle:e,refreshKey:t,readyAt:r,revalidate:n,refresh:l,now:o=Date.now}){let s=i({readyAt:r,revalidate:n,refresh:l??n,now:o});s.current={readyAt:r,revalidate:n,refresh:l??n,now:o},a(()=>{if(e==null)return;let t=Yr(()=>e.onForeground(()=>{let{readyAt:e,revalidate:t,now:r}=s.current;e!==null&&r()-e>=Xr&&t()}));return()=>{typeof t=="function"&&Yr(t)}},[e]);let u=i(t);a(()=>{Object.is(u.current,t)||(u.current=t,s.current.refresh())},[t])}var tn=Xr,rn=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanPageReads@v1");function nn(){let e=globalThis,t=e[rn];if(t instanceof WeakMap)return t;let r=/* @__PURE__ */new WeakMap;return e[rn]=r,r}function ln(e,t,userRef,petRef,r){let n=nn(),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<tn))return a.promise;let s={at:null,promise:e.getPage(petRef).then(e=>(i.get(o)===s&&(e.ok||ir(e.error)?s.at=Date.now():i.delete(o)),e))};return i.set(o,s),s.promise}function useHealthPlanPage(e){let{userRef:userRef,runtime:t}=Ze(),r=l(()=>Vr(t),[t]),s=e.repository,u=s??r,d=n((e,n)=>s!==void 0||userRef==null?u.getPage(e):ln(r,t,userRef,e,n),[s,u,r,t,userRef]),{petRef:petRef}=e,c=e.enabled!==false&&userRef!=null&&petRef!==null,[p,f]=o({phase:"idle",petRef:null,page:null,error:null}),h=i(0),g=i(0),b=n(async e=>{let t=++h.current;if(!c||petRef===null){f(e=>e.phase==="idle"&&e.petRef===null?e:{phase:"idle",petRef:null,page:null,error:null});return}f(e=>({phase:"loading",petRef:petRef,page:e.petRef===petRef?e.page:null,error:null}));let r=await d(petRef,e);t===h.current&&(r.ok?f({phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}):ir(r.error)?f({phase:"ready",petRef:petRef,page:null,error:null,missing:true,readyAt:Date.now()}):f({phase:"failed",petRef:petRef,page:null,error:r.error}))},[c,petRef,d]),y=n(()=>b(true),[b]),m=p.phase==="ready"&&p.petRef===petRef,v=n(async()=>{if(!c||petRef===null||!m)return;let e=h.current,t=++g.current,r=await d(petRef,true);e!==h.current||t!==g.current||!r.ok||f(e=>e.phase==="ready"&&e.petRef===petRef?{phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}:e)},[c,petRef,m,d]);en({lifecycle:e.lifecycle,refreshKey:e.refreshKey,readyAt:m?p.readyAt??null:null,revalidate:()=>{v()},refresh:()=>{m?v():y()}}),a(()=>(b(false),()=>{h.current+=1}),[b]);let w=c&&p.petRef!==petRef;return l(()=>({phase:w?"loading":p.phase,page:w?null:p.page,error:w?null:p.error,missing:!w&&p.missing===true,refresh:y}),[w,p,y])}var on=/* @__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 on[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 un({name:e,enabled:false,isPending:true,limits:{}});let i=an(n,l);return n.filter(e=>l.get(e)?.granted!==true).length===0?un({name:e,enabled:true,isPending:false,limits:i}):un({name:e,enabled:false,isPending:false,limits:i,disabled:sn(n,l)})}function an(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 sn(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
13
14
  return Object.freeze({reason:e.reason,level:e.level,recoverable:e.recoverable})}/* @__PURE__ */
14
- return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function an(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(e){let{runtime:t}=Ye(),r=t.entitlements,n=s(r.subscribe,r.getSnapshot,r.getSnapshot);return l(()=>decideCapability(e,n.decisions,{isPending:n.isPending}),[e,n])}function sn(e){let{runtime:t}=Ye(),r=t.entitlements,l=n(e=>r===void 0?()=>{}:r.subscribe(e),[r]),i=n(()=>{if(r===void 0)return false;let t=r.getSnapshot();return decideCapability(e,t.decisions,{isPending:t.isPending}).enabled},[r,e]);return s(l,i,i)}var un=()=>()=>{},dn=()=>null;function cn(e,t){return s(t?.subscribe??un,t?.get??dn,t?.get??dn)??e}var pn=/* @__PURE__ */Object.freeze({branding:null}),fn=/* @__PURE__ */Object.freeze({subscribe:()=>()=>{},getSnapshot:()=>pn});function hn(e){return e?Object.keys(e).sort().map(t=>`${t}=${String(e[t])}`).join("&"):""}function gn(e){let{runtime:t}=Ye(),r=t?.entitlements??fn,i=n(()=>r.getSnapshot()?.branding??null,[r]),o=cn(s(r.subscribe,i,i),t?.sdkConfigHost?.branding),a=hn(e);return l(()=>{let t=o?.lockedFields??null;return{presentation:resolvePresentation({server:o?.presentation??null,locked:t,client:e??null}),isLocked:e=>isPresentationFieldLocked(e,t)}},[o,a])}function bn(e){let t={};for(let[r,n]of Object.entries(e))n!==void 0&&(t[r]=n);return t}function yn(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}function mn(e){let t=_t(e);return t===null?null:{reached:He.capReached.replace("{cap}",String(t.limit)),guidance:t.emergencyGuidance??null}}function vn(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}function wn(e,t="native"){if(e.messages.length===0)return null;let r=e.status==="error"?e.error:null;if(r!==null){let e=vn(r),n=t==="web",l=mn(r);return{tone:"error",title:l!==null?l.reached:e?He.turnUnreachableTitle:n?He.turnFailedTitleWeb:He.turnFailedTitle,body:r.displayMessage,actionLabel:e?He.turnStartNewChat:n?He.retry:He.turnRetry,action:e?"startNew":"retry",...l!==null&&l.guidance!==null?{guidance:l.guidance}:{}}}return e.stopped===true?{tone:"neutral",title:He.turnStoppedTitle,body:He.turnStoppedBody,actionLabel:He.turnRetry,action:"retry"}:null}function kn(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}var Cn=3,Sn=/* @__PURE__ */Object.freeze([]);function xn(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===Cn))break}/* @__PURE__ */
15
- return Object.freeze(n)}var Rn=5;function Tn(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 _n(e,t){if(t===void 0)return xn(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(Rn,Math.floor(t.count??Cn))),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)||Tn(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__ */
16
- return Object.freeze(a)}function zn(e){return e.sender?.displayName??He.senderVet}function In(petRef,conversationId){let e={};return petRef!==void 0&&(e.petRef=petRef),conversationId!==void 0&&(e.conversationId=conversationId),e}var Pn=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 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 Ln(e,t,r){let n=t.chatFollowUpsExcludeTelevet,l=e?.count!==void 0&&!r?e.count:t.chatFollowUpCount;if(e===void 0&&l===Cn&&!n)return;if(l<=0)return{...e??{},count:1,exclude:NONE,fill:[]};let i=e?.exclude,o=n?e=>Pn.test(e)||Fn(i,e):i;return{...e??{},count:l,...o!==void 0?{exclude:o}:{}}}function En(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 On(e){return[...e].length}var An=/* @__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(An,t)?An[t]:null}var jn=50,Dn=128,Mn=120,Bn=120,Hn=2e3,Wn=120,Nn=80,Un=/* @__PURE__ */new Set(["male","female","unknown"]),$n=/* @__PURE__ */new Set(["day","month","year"]),Vn=/* @__PURE__ */new Set(["low","medium","high","athletic"]),qn=/* @__PURE__ */new Set(["indoor","outdoor","both"]),Gn=/* @__PURE__ */new Set(["mild","moderate","severe"]),Kn=/^(\d{4})-(\d{2})-(\d{2})$/,Yn=[["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"]],Qn=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...Yn,...Qn].map(([e])=>e));function Zn(e){let t=Kn.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 Jn=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,Xn=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,el=(e,t)=>typeof t=="string"&&Zn(t)?null:`${e} must be a real date written YYYY-MM-DD`,tl=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(En(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=On(l);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},rl={sex:Jn(Un),spayedNeutered:Xn,birthDate:el,birthDatePrecision:Jn($n),activityLevel:Jn(Vn),indoorOutdoor:Jn(qn),foodBrand:tl(Wn),foodType:tl(Wn),microchipId:tl(Nn)},nl=["ref","ref",false,tl(Dn,{required:true,trimmed:true})],ll=["notes","notes",false,tl(Hn,{trimmed:true})],il=[nl,["name","name",true,tl(Mn,{required:true,trimmed:true})],["dose","dose",false,tl(Bn,{trimmed:true})],["frequency","frequency",false,tl(Bn,{trimmed:true})],["startDate","start_date",false,el],["endDate","end_date",false,el],ll],ol={allergies:[nl,["allergen","allergen",true,tl(Mn,{required:true,trimmed:true})],["severity","severity",false,Jn(Gn)],ll],medications:il,supplements:il,conditions:[nl,["conditionName","condition_name",true,tl(Mn,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,el],ll]};function al(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 ol[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 sl(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>jn)return{error:`${e} has ${t.length} items; the server accepts at most ${jn}`};let r=[],n=/* @__PURE__ */new Set;for(let l=0;l<t.length;l+=1){let i=al(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 ul(e,t){let r=e,n={};for(let[e,t]of Yn){let l=r[e];if(l!==void 0){if(l!==null){let t=rl[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 Qn){let l=r[e];if(l===void 0)continue;let i=sl(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 dl=e=>typeof e=="string"?e:null,cl=(e,t)=>typeof t=="string"&&e.has(t)?t:null,pl=e=>typeof e=="boolean"?e:null;function fl(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 hl(e){let t=dl(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:dl(e.ref),name:t,dose:dl(e.dose),frequency:dl(e.frequency),startDate:dl(e.start_date),endDate:dl(e.end_date),notes:dl(e.notes)})}function gl(e){let t=e.profile_version;/* @__PURE__ */
17
- return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:cl(Un,e.sex),spayedNeutered:pl(e.spayed_neutered),birthDate:dl(e.birth_date),birthDatePrecision:cl($n,e.birth_date_precision),activityLevel:cl(Vn,e.activity_level),indoorOutdoor:cl(qn,e.indoor_outdoor),foodBrand:dl(e.food_brand),foodType:dl(e.food_type),microchipId:dl(e.microchip_id),allergies:fl(e.allergies,e=>{let t=dl(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:dl(e.ref),allergen:t,severity:cl(Gn,e.severity),notes:dl(e.notes)})}),medications:fl(e.medications,hl),supplements:fl(e.supplements,hl),conditions:fl(e.conditions,e=>{let t=dl(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:dl(e.ref),conditionName:t,diagnosedDate:dl(e.diagnosed_date),notes:dl(e.notes)})})})}var bl=100,yl=50,ml=100,vl=50,wl=500,kl=128,Cl=6e4;function Sl(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function xl(e,t,r){if(typeof t!="string")return Sl(`${e} must be a string`);let n=On(t);return n<=r?null:Sl(`${e} is ${n} characters; the server accepts at most ${r}`)}function Rl(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 Tl(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(En(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=[xl("pet_ref",petRef,kl)];return e?.name!==void 0&&t.push(xl("name",e.name,bl)),e?.species!==void 0&&t.push(xl("species",e.species,yl)),e?.breed!==void 0&&t.push(xl("breed",e.breed,ml)),e?.ageYears!==void 0&&t.push(Rl("age_years",e.ageYears,vl)),e?.weightKg!==void 0&&t.push(Rl("weight_kg",e.weightKg,wl)),t.find(e=>e!==null)??null}function _l(e,t){let r=ul(e,t);return"error"in r?{error:Sl(r.error)}:r}function zl(e){if(typeof e!="object"||e===null)return{error:Sl("patch must be an object")};let t=e,r=[["name","name",e=>xl("name",e,bl)],["species","species",e=>xl("species",e,yl)],["breed","breed",e=>xl("breed",e,ml)],["ageYears","age_years",e=>Rl("age_years",e,vl)],["weightKg","weight_kg",e=>Rl("weight_kg",e,wl)]],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=_l(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 Il(e){if(e==null)return{body:{}};let t=_l(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 Pl=e=>typeof e=="string"?e:null,Fl=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function Ll(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
18
- return Object.freeze({petRef:Pl(t.pet_ref)??petRef,name:Pl(t.name),species:Pl(t.species),breed:Pl(t.breed),ageYears:Fl(t.age_years),weightKg:Fl(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=Pl(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:Pl(t.pet_id),petRef:petRef,name:Pl(t.name),species:Pl(t.species),breed:Pl(t.breed),ageYears:Fl(t.age_years),weightKg:Fl(t.weight_kg),updatedAt:Pl(t.updated_at)})}function El(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...gl(e)})}function Ol(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];/* @__PURE__ */
19
- return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return Al(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:Cl}))}function Al(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>Tl(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(Ol(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=Tl(petRef,t);if(n!==null)return err(n);let l=Il(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(Ll(o.value,petRef)):err(o.error)},async updatePet(petRef,t,l){let i=n(petRef);if(typeof i!="string")return err(i);let o=zl(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(Ll(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=El(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 jl=/* @__PURE__ */new WeakMap,Dl=/* @__PURE__ */new Map;function Ml(e,t,petRef,r){let n=jl.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}|${Hl(r)}`}function Bl(e,t){if(e===null)return t();let r=Dl.get(e);if(r!==void 0)return r;let n=t().finally(()=>{Dl.get(e)===n&&Dl.delete(e)});return Dl.set(e,n),n}function Hl(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(Hl).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)}:${Hl(t)}`).join(",")}}`}var Wl="pet_not_registered";function Nl(e){return e!=null&&e.reasonCode===Wl}var Ul=/* @__PURE__ */Object.freeze({status:"idle",error:null,registered:null,retry:()=>{}});function $l(petRef,e,t){let{runtime:r,userRef:userRef,scopeEpoch:s}=Ye(),u=n((e,t)=>{let n=r.registry.services.authFor(userRef);return Bl(Ml(r,n,e,t),()=>createPetsRepository(n).registerPet(e,t))},[r,userRef,s]),d=l(()=>e===void 0?null:Hl(e),[e]),[c,p]=o({key:null,status:"idle",error:null,registered:null}),f=i(0),h=i(t);h.current=t;let g=petRef===null||d===null?null:`${String(userRef)}|${s}|${petRef}|${d}`,b=n(()=>{if(petRef===null||e===void 0||g===null)return;let t=++f.current;p({key:g,status:"registering",error:null,registered:null}),u(petRef,e).then(e=>{t===f.current&&(e.ok?(p({key:g,status:"registered",error:null,registered:e.value}),h.current?.()):p({key:g,status:"failed",error:e.error,registered:null}))})},[u,petRef,g]);a(()=>{if(g===null){f.current+=1;return}return b(),()=>{f.current+=1}},[g,b]);let y=n(()=>{c.status==="failed"&&b()},[c.status,b]);return l(()=>g===null?Ul:c.key!==g?{status:"registering",error:null,registered:null,retry:y}:{status:c.status,error:c.error,registered:c.registered,retry:y},[g,c,y])}var Vl=/* @__PURE__ */Object.freeze({});function ql(e){let[t,r]=o(Vl),s=i(null),u=i([]);u.current=e.map(e=>e.id),a(()=>{if(e.length===0){s.current=null,r(e=>e===Vl?e:Vl);return}let t=s.current;if(t===null)return;let n=e.find(e=>e.role==="user"&&!t.known.has(e.id));n!==void 0&&(s.current=null,r(e=>({...e,[n.id]:t.images})))},[e]);let d=n(e=>{s.current=e.length===0?null:{images:e,known:new Set(u.current)}},[]);return l(()=>({byMessage:t,stage:d}),[t,d])}var Gl=/* @__PURE__ */new WeakSet;function Kl(){let e=makeEverfurError("internalError",{retryable:true});return Gl.add(e),err(e)}function Yl(e){if(typeof e!="object"||e===null||e.ok!==false)return false;let t=e.error;return typeof t=="object"&&t!==null&&Gl.has(t)}var Ql=500;function Zl(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,Ql):null}function Jl(e,t,r,n){let l=Zl(r),o=l===null?null:n!==void 0?`key:${String(n)}`:`prompt:${l}`,s=i(e);s.current=e;let u=i(null),d=i(null),c=i(o);c.current=o,a(()=>{if(l===null||o===null||t||u.current===o||d.current===o)return;let e=s.current;if(e===void 0)return;d.current=o;let r=e=>{d.current===o&&(d.current=null),!Yl(e)&&c.current===o&&(u.current=o)};Promise.resolve(e(l)).then(r,()=>r(void 0))},[l,o,t,e])}var Xl=/* @__PURE__ */Object.freeze({openUnreadHead:true,reportLoadFailures:true}),ei=/* @__PURE__ */Object.freeze({reportLoadFailures:true}),ti=/* @__PURE__ */Object.freeze({...Xl,markRead:true}),ri=/* @__PURE__ */Object.freeze({...ei,markRead:true});function ni(e,t){return e?t?ti:Xl:t?ri:ei}function li(e,t){let r=e?.isVisible===void 0?t:e.isVisible.bind(e);return r===void 0?true:Gr(()=>r()!==!1)===true}function ii(e,t){let r=i({target:e,isVisible:t});r.current={target:e,isVisible:t};let n=i(e.isStreaming);a(()=>{let t=n.current;if(n.current=e.isStreaming,!t||e.isStreaming)return;let{target:l,isVisible:i}=r.current;l.status!=="complete"||l.conversationId===null||l.unreadCount===null||!i()||l.markRead()},[e.isStreaming])}function oi(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 ai(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"}:oi(e,conversationId,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:conversationId}}var si=3e5;function ui(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 di(e,t,r){let n=i(t);n.current=t;let l=i(null),o=i(null),s=i(false),u=i(0),d=i(0),c=i(3e4),p=()=>e?.isOffline===void 0?false:Gr(()=>e.isOffline?.()===!0)===true,f=p(),h=i(()=>{});h.current=e=>{let{conversationId:conversationId,isTurnInFlight:t,refresh:r,refreshesBlankThread:i}=n.current,a=ai(e,{activeConversationId:conversationId,isTurnInFlight:t,refreshesBlankThread:i===true,isOffline:p(),lastRefresh:l.current,now:Date.now()});if(a.action==="skip")return;if(a.action==="defer"){o.current!=="announced"&&(o.current=e);return}if(s.current){if(e==="poll")return;o.current!=="announced"&&(o.current=e);return}if(o.current=null,l.current={conversationId:a.conversationId,at:Date.now()},r===void 0)return;s.current=true;let f=e=>{s.current=false,ui(e)?(u.current=Math.min(u.current===0?c.current*2:u.current*2,si),d.current=Date.now()+u.current):(u.current=0,d.current=0);let t=o.current;t!==null&&h.current(t)};Promise.resolve(r()).then(f,()=>f({ok:false,error:{category:"server"}}))},a(()=>{if(t.isTurnInFlight||f)return;let e=o.current;e!==null&&h.current(e)},[t.isTurnInFlight,f]),a(()=>{if(e===void 0)return;let t=[],r=(e,r)=>{if(e===void 0)return;let n=Gr(()=>e(()=>{h.current(r)}));typeof n=="function"&&t.push(n)};return r(e.onForeground?.bind(e),"foreground"),r(e.onOnline?.bind(e),"foreground"),r(e.onAnnounced?.bind(e),"announced"),()=>{for(let e of t)Gr(e)}},[e]);let g=r?.intervalMs??null,b=r?.isVisibleFallback;a(()=>{if(e===void 0||g===null||!Number.isFinite(g)||g<=0)return;c.current=g;let t=setInterval(()=>{Date.now()<d.current||li(e,b)&&h.current("poll")},g);return()=>clearInterval(t)},[e,g,b])}var ci=/^efch_[A-Za-z0-9_-]{43}$/,pi="efch";function fi(e){return typeof e=="string"&&ci.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(`${pi}=`))continue;let e=r.slice(pi.length+1);return fi(e)?e:null}return null}var hi=/* @__PURE__ */Object.freeze(["better","same","worse"]),gi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var bi="checkin",yi=/^\d{4}-\d{2}-\d{2}$/,mi="watching";function isCheckinSettled(e){return e.status!=null&&e.status!==mi}function vi(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,l]=t;return r!==bi||n===void 0||l===void 0||!gi.test(n)||!yi.test(l)?null:{caseId:n,dueDay:l}}function wi(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 ki(e,t,r){return makeEverfurError(e,{retryable:t,...{}})}var Ci=128,Si=/[\u0000-\u001f\u007f]/;function xi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Ri(e){return typeof e!="string"||e.length===0||e.length>Ci||Si.test(e)||e.includes("://")?null:e}function Ti(e){if(e===null)return null;let conversationId=e.conversation_id,petRef=Ri(e.pet_ref);return typeof conversationId!="string"||!wi(conversationId)||petRef===null?null:{conversationId:conversationId,petRef:petRef}}function _i(e,t,r){return fi(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(Ti(xi(e.value))):e.error.httpStatus===404?ok(null):err(e.error),()=>err(ki("internalError",false))):Promise.resolve(ok(null))}function zi(e,t){let r=t?.runtime??null,userRef=t?.userRef??null,n=fi(e)?e:null,l=n===null||userRef===null?null:`${String(userRef)}|${n}`,[i,s]=o(null);return a(()=>{if(l===null||n===null||userRef===null||r===null)return;let e=true,t=r.registry.services;return _i(t.authFor(userRef),n,t.errorPolicy).then(t=>{!e||!t.ok||t.value===null||s({key:l,target:/* @__PURE__ */Object.freeze({kind:"chat",conversationId:t.value.conversationId,petRef:t.value.petRef})})}),()=>{e=false}},[l,r,n,userRef]),i!==null&&i.key===l?i.target:void 0}function Ii(e){if(e===void 0)return null;let conversationId=e.conversationId??"",petRef=e.petRef??"";return conversationId===""&&petRef===""?null:`${String(conversationId)}|${String(petRef)}`}function Pi(e,t,r){let n=Ii(t),l=t?.kind==="chat",o=t?.petRef??null,s=l&&!r.pinned&&o!==null&&r.petRef!==null&&o!==r.petRef,u=i({openCheckin:e,target:t,selectPet:r.selectPet});u.current={openCheckin:e,target:t,selectPet:r.selectPet};let d=i(null),c=i(null),petRef=r.petRef;a(()=>{if(n===null||d.current===n)return;let{openCheckin:e,target:t,selectPet:i}=u.current;if(s&&o!==null){if(c.current?.key!==n){c.current={key:n,from:petRef},i(o);return}petRef!==c.current.from&&(d.current=n);return}l&&!r.ready||(d.current=n,!(e===void 0||t===void 0)&&Promise.resolve(e(t)).catch(()=>{}))},[n,l,s,o,petRef,r.ready])}var Fi=/* @__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 Li(e){let t=e?.replace(/\s+/g," ").trim();return t||Fi.untitled}function Ei(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}function Oi(e){let t=Ei(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?Fi.newReply.replace("{date}",t):t}function Ai(e,t){return t?`${Fi.countLabel}${Fi.countSeparator}${e}`:Fi.countLabel}function ji(e){return`${e.unreadCount!==null&&e.unreadCount>0?Fi.unreadPrefix:""}${Fi.openConversation} ${Li(e.title)}`}function Di(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}function Mi(e,t){let r=Di(t);if(r.length===0)return e;let n=[[],[],[]];for(let t of e){let e=Di(Li(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 Bi(e){return{scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}function Hi(e){let[t,r]=o(false),[s,u]=o(""),d=e.listConversations,c=i(0),[p,f]=o(()=>Bi(d)),h=p.scope===d?p:Bi(d);a(()=>(c.current+=1,r(false),u(""),f(Bi(d)),()=>{c.current+=1}),[d]);let g=n(async t=>{let r=++c.current,n=t!==void 0;f(e=>({...e,scope:d,loading:!n,loadingMore:n,error:null}));let l=await e.listConversations(t?{cursor:t}:void 0);if(r===c.current){if(!l.ok){f(e=>({...e,loading:false,loadingMore:false,error:l.error.displayMessage}));return}f(e=>{let r=t&&e.scope===d?e.rows:[],n=new Set(r.map(e=>e.id));return{scope:d,loading:false,loadingMore:false,error:null,rows:[...r,...l.value.conversations.filter(e=>!n.has(e.id))],cursor:l.value.nextCursor===t?null:l.value.nextCursor}})}},[e.listConversations,d]),b=()=>{r(true),u(""),g()},y=()=>{c.current+=1,r(false)},m=async t=>{let n=++c.current;f(e=>({...e,loading:true,error:null}));let l=await e.resumeConversation(t);n===c.current&&(f(e=>({...e,loading:false,error:l.ok?null:l.error.displayMessage})),l.ok&&r(false))},v=async()=>{let t=c.current,r=await e.loadOlderMessages();t===c.current&&!r.ok&&f(e=>({...e,error:r.error.displayMessage}))},w=()=>{e.newConversation(),c.current+=1,r(false)},k=()=>{h.cursor===null||h.loading||h.loadingMore||s.trim().length>0||g(h.cursor)},C=l(()=>Mi(h.rows,s),[h.rows,s]),S=s.trim().length>0;return{...h,open:t,show:b,close:y,load:g,resume:m,earlier:v,newConversation:w,loadMore:k,query:s,setQuery:u,searching:S,filtered:C,emptyKind:h.rows.length===0?"empty":"noMatch"}}var Wi="#111111",Ni="#FFFFFF",Ui=/* @__PURE__ */Object.freeze({emergency:/* @__PURE__ */Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:Wi,pillColor:Ni,showsVetAction:true}),schedule_soon:/* @__PURE__ */Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:Wi,pillColor:Ni,showsVetAction:true}),home_care:/* @__PURE__ */Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Wi,pillColor:Ni,showsVetAction:false}),general:/* @__PURE__ */Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Wi,pillColor:Ni,showsVetAction:false})});function $i(e){return`${e.messageId}:${e.level}:${e.reason??""}`}function Vi(e){return We(He.urgencyGeneralReason,{petName:e?.trim()||He.emptyTitlePetFallback})}function qi(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:Gi(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:Vi(t)}:null}return null}function Gi(e){return typeof e=="string"&&e.trim().length>0?e:null}function Ki(e){let t=e===null?null:$i(e),[r,i]=o(null),[s,u]=o(false);a(()=>u(false),[t]);let d=e!==null&&(s||!(r!==null&&r===t)),c=e===null?null:Ui[e.level],p=e!==null&&!d&&e.level!=="general",f=n(()=>{t!==null&&i(t),u(false)},[t]),h=n(()=>u(true),[]);return l(()=>({source:e,tier:c,signature:t,showBanner:d,showCompactIcon:p,showVetAction:d&&c!==null&&c.showsVetAction,dismissLabel:c===null?null:We(He.dismissBanner,{label:c.label}),dismiss:f,expand:h}),[e,c,t,d,p,f,h])}var Yi=()=>globalThis[/* @__PURE__ */Symbol.for("everfur.sdk.chatCards.v1")]??={loader:null,lazy:null};var Qi=Yi;function registerEverfurChatCards(e){let t=Qi();t.loader=e;let n=e&&Promise.resolve().then(e).then(e=>typeof e.ServerCards=="function"?e.ServerCards:NONE3,()=>NONE3);t.lazy=n&&r(async()=>({default:await n}))}var NONE3=()=>null,Zi=createContext(null);function ServerCardsSlot({message:e}){let r=u(Zi),n=Qi(),l=e.a2ui??n.frames?.get(e.responseId),i=n.lazy;return l===void 0||r===null||i===null?null:t(p,{fallback:null},t(i,{message:e,a2ui:l,host:r}))}var Ji=class extends d{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:e,fallback:r,resetKey:n}){return t(Ji,{fallback:r,resetKey:n,children:t(RenderHost,{render:e})})}var Xi=48;function eo(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(e){let{capability:t,children:r,renderDisabled:n,renderPending:i,style:o}=e,a=useCapability(t),s=l(()=>eo(a),[a]);switch(s){case"enabled":return r;case"pending":return i?/* @__PURE__ */A(HostRender,{render:i,fallback:/* @__PURE__ */A(PendingSkeleton,{capability:t,style:o})}):/* @__PURE__ */A(PendingSkeleton,{capability:t,style:o});case"disabled":return n?/* @__PURE__ */A(HostRender,{render:()=>n(a),fallback:/* @__PURE__ */A(OffState,{decision:a,style:o}),resetKey:a}):/* @__PURE__ */A(OffState,{decision:a,style:o});default:return assertNever(s)}}function PendingSkeleton({capability:e,style:t}){let r=useEverfurTheme(),n=l(()=>to(r),[r]);/* @__PURE__ */
20
- return A(v,{style:[n.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:/* @__PURE__ */A(v,{style:n.skeletonBar})})}function OffState({decision:e,style:t}){let r=useEverfurTheme(),n=l(()=>to(r),[r]),i=e.disabled?.reason??"";/* @__PURE__ */
21
- return A(v,{style:[n.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:i,children:i.length>0?/* @__PURE__ */A(Text,{style:n.offstateText,children:i}):null})}function to(e){let{color:t,space:r,radius:n,type:l}=e;return g.create({offstate:{minHeight:Xi,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:g.hairlineWidth,borderColor:t.brandBorder},offstateText:{...face(e,"regular"),fontSize:l.size.body,lineHeight:Math.round(l.size.body*l.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}var ro="everfur.com",no=2048,lo=/^(\*\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function io(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&&lo.test(e)&&t.add(e)}/* @__PURE__ */
22
- return Object.freeze([...t])}function oo(e,t){if(e===ro||e.endsWith(`.${ro}`))return true;for(let r of t)if(r.startsWith("*.")?e.endsWith(r.slice(1)):e===r)return true;return false}function ao(e,t){if(typeof e!="string"||e.length===0||e.length>no||!/^https:\/\//i.test(e))return null;let r=zt(e);return r===null||r.protocol!=="https:"||r.username!==""||r.password!==""||r.port!==""?null:oo(r.hostname,t)?r.href:null}function so(e){try{Promise.resolve(w.openURL(e)).catch(()=>{})}catch{}}var uo=createContext(null);function co(){return u(uo)??void 0}function MessageLinksScope({linkHosts:e,onOpenUrl:r,children:n}){let i=e===false?null:Array.isArray(e)?e.join(`\n`):"",o=l(()=>{if(i===null)return null;let e=io(i===""?[]:i.split(`\n`));/* @__PURE__ */
23
- return Object.freeze({hosts:e,open:r!==void 0?e=>{Gr(r,e,"message")}:so})},[i,r]);return t(uo.Provider,{value:o},n)}var po={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function fo(e){return{width:e,height:e,alignItems:"center",justifyContent:"center"}}function ho(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}function MenuGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r),l={width:e*.82,height:n,borderRadius:n,backgroundColor:t};/* @__PURE__ */
24
- return j(v,{style:[fo(e),{gap:e*.22}],...po,children:[
15
+ return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function un(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(e){let{runtime:t}=Ze(),r=t.entitlements,n=s(r.subscribe,r.getSnapshot,r.getSnapshot);return l(()=>decideCapability(e,n.decisions,{isPending:n.isPending}),[e,n])}function dn(e){let{runtime:t}=Ze(),r=t.entitlements,l=n(e=>r===void 0?()=>{}:r.subscribe(e),[r]),i=n(()=>{if(r===void 0)return false;let t=r.getSnapshot();return decideCapability(e,t.decisions,{isPending:t.isPending}).enabled},[r,e]);return s(l,i,i)}var cn=()=>()=>{},pn=()=>null;function fn(e,t){return s(t?.subscribe??cn,t?.get??pn,t?.get??pn)??e}var hn=/* @__PURE__ */Object.freeze({branding:null}),gn=/* @__PURE__ */Object.freeze({subscribe:()=>()=>{},getSnapshot:()=>hn});function bn(e){return e?Object.keys(e).sort().map(t=>`${t}=${String(e[t])}`).join("&"):""}function yn(e){let{runtime:t}=Ze(),r=t?.entitlements??gn,i=n(()=>r.getSnapshot()?.branding??null,[r]),o=fn(s(r.subscribe,i,i),t?.sdkConfigHost?.branding),a=bn(e);return l(()=>{let t=o?.lockedFields??null;return{presentation:resolvePresentation({server:o?.presentation??null,locked:t,client:e??null}),isLocked:e=>isPresentationFieldLocked(e,t)}},[o,a])}function mn(e){let t={};for(let[r,n]of Object.entries(e))n!==void 0&&(t[r]=n);return t}function vn(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}function wn(e){let t=It(e);return t===null?null:{reached:Ne.capReached.replace("{cap}",String(t.limit)),guidance:t.emergencyGuidance??null}}function kn(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}function Cn(e,t="native"){if(e.messages.length===0)return null;let r=e.status==="error"?e.error:null;if(r!==null){let e=kn(r),n=t==="web",l=wn(r);return{tone:"error",title:l!==null?l.reached:e?Ne.turnUnreachableTitle:n?Ne.turnFailedTitleWeb:Ne.turnFailedTitle,body:r.displayMessage,actionLabel:e?Ne.turnStartNewChat:n?Ne.retry:Ne.turnRetry,action:e?"startNew":"retry",...l!==null&&l.guidance!==null?{guidance:l.guidance}:{}}}return e.stopped===true?{tone:"neutral",title:Ne.turnStoppedTitle,body:Ne.turnStoppedBody,actionLabel:Ne.turnRetry,action:"retry"}:null}function Sn(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}var xn=3,Rn=/* @__PURE__ */Object.freeze([]);function Tn(e){let t=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||t===void 0||t.role!=="assistant")return Rn;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===xn))break}/* @__PURE__ */
16
+ return Object.freeze(n)}var _n=5;function zn(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 In(e,t){if(t===void 0)return Tn(e);let r=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||r===void 0||r.role!=="assistant")return Rn;let n=Math.max(1,Math.min(_n,Math.floor(t.count??xn))),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)||zn(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 Pn(e){return e.sender?.displayName??Ne.senderVet}function Fn(petRef,conversationId){let e={};return petRef!==void 0&&(e.petRef=petRef),conversationId!==void 0&&(e.conversationId=conversationId),e}var Ln=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 En(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 On(e,t,r){let n=t.chatFollowUpsExcludeTelevet,l=e?.count!==void 0&&!r?e.count:t.chatFollowUpCount;if(e===void 0&&l===xn&&!n)return;if(l<=0)return{...e??{},count:1,exclude:NONE,fill:[]};let i=e?.exclude,o=n?e=>Ln.test(e)||En(i,e):i;return{...e??{},count:l,...o!==void 0?{exclude:o}:{}}}function An(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 jn(e){return[...e].length}var Dn=/* @__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(Dn,t)?Dn[t]:null}var Mn=50,Bn=128,Hn=120,Wn=120,Nn=2e3,Un=120,$n=80,Vn=/* @__PURE__ */new Set(["male","female","unknown"]),qn=/* @__PURE__ */new Set(["day","month","year"]),Gn=/* @__PURE__ */new Set(["low","medium","high","athletic"]),Kn=/* @__PURE__ */new Set(["indoor","outdoor","both"]),Yn=/* @__PURE__ */new Set(["mild","moderate","severe"]),Qn=/^(\d{4})-(\d{2})-(\d{2})$/,Zn=[["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"]],Jn=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...Zn,...Jn].map(([e])=>e));function Xn(e){let t=Qn.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 el=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,tl=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,rl=(e,t)=>typeof t=="string"&&Xn(t)?null:`${e} must be a real date written YYYY-MM-DD`,nl=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(An(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=jn(l);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},ll={sex:el(Vn),spayedNeutered:tl,birthDate:rl,birthDatePrecision:el(qn),activityLevel:el(Gn),indoorOutdoor:el(Kn),foodBrand:nl(Un),foodType:nl(Un),microchipId:nl($n)},il=["ref","ref",false,nl(Bn,{required:true,trimmed:true})],ol=["notes","notes",false,nl(Nn,{trimmed:true})],al=[il,["name","name",true,nl(Hn,{required:true,trimmed:true})],["dose","dose",false,nl(Wn,{trimmed:true})],["frequency","frequency",false,nl(Wn,{trimmed:true})],["startDate","start_date",false,rl],["endDate","end_date",false,rl],ol],sl={allergies:[il,["allergen","allergen",true,nl(Hn,{required:true,trimmed:true})],["severity","severity",false,el(Yn)],ol],medications:al,supplements:al,conditions:[il,["conditionName","condition_name",true,nl(Hn,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,rl],ol]};function ul(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 sl[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 dl(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>Mn)return{error:`${e} has ${t.length} items; the server accepts at most ${Mn}`};let r=[],n=/* @__PURE__ */new Set;for(let l=0;l<t.length;l+=1){let i=ul(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 cl(e,t){let r=e,n={};for(let[e,t]of Zn){let l=r[e];if(l!==void 0){if(l!==null){let t=ll[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 Jn){let l=r[e];if(l===void 0)continue;let i=dl(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 pl=e=>typeof e=="string"?e:null,fl=(e,t)=>typeof t=="string"&&e.has(t)?t:null,hl=e=>typeof e=="boolean"?e:null;function gl(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 bl(e){let t=pl(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:pl(e.ref),name:t,dose:pl(e.dose),frequency:pl(e.frequency),startDate:pl(e.start_date),endDate:pl(e.end_date),notes:pl(e.notes)})}function yl(e){let t=e.profile_version;/* @__PURE__ */
18
+ return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:fl(Vn,e.sex),spayedNeutered:hl(e.spayed_neutered),birthDate:pl(e.birth_date),birthDatePrecision:fl(qn,e.birth_date_precision),activityLevel:fl(Gn,e.activity_level),indoorOutdoor:fl(Kn,e.indoor_outdoor),foodBrand:pl(e.food_brand),foodType:pl(e.food_type),microchipId:pl(e.microchip_id),allergies:gl(e.allergies,e=>{let t=pl(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:pl(e.ref),allergen:t,severity:fl(Yn,e.severity),notes:pl(e.notes)})}),medications:gl(e.medications,bl),supplements:gl(e.supplements,bl),conditions:gl(e.conditions,e=>{let t=pl(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:pl(e.ref),conditionName:t,diagnosedDate:pl(e.diagnosed_date),notes:pl(e.notes)})})})}var ml=100,vl=50,wl=100,kl=50,Cl=500,Sl=128,xl=6e4;function Rl(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Tl(e,t,r){if(typeof t!="string")return Rl(`${e} must be a string`);let n=jn(t);return n<=r?null:Rl(`${e} is ${n} characters; the server accepts at most ${r}`)}function _l(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:Rl(`${e} must be a finite number between 0 and ${r}`)}function zl(petRef,e){if(typeof petRef!="string")return Rl("pet_ref must be a string");if(petRef.trim().length===0)return Rl("pet_ref must not be blank");if(An(petRef))return Rl("pet_ref contains an unpaired surrogate and cannot be encoded");if(e!=null&&typeof e!="object")return Rl("profile must be an object");let t=[Tl("pet_ref",petRef,Sl)];return e?.name!==void 0&&t.push(Tl("name",e.name,ml)),e?.species!==void 0&&t.push(Tl("species",e.species,vl)),e?.breed!==void 0&&t.push(Tl("breed",e.breed,wl)),e?.ageYears!==void 0&&t.push(_l("age_years",e.ageYears,kl)),e?.weightKg!==void 0&&t.push(_l("weight_kg",e.weightKg,Cl)),t.find(e=>e!==null)??null}function Il(e,t){let r=cl(e,t);return"error"in r?{error:Rl(r.error)}:r}function Pl(e){if(typeof e!="object"||e===null)return{error:Rl("patch must be an object")};let t=e,r=[["name","name",e=>Tl("name",e,ml)],["species","species",e=>Tl("species",e,vl)],["breed","breed",e=>Tl("breed",e,wl)],["ageYears","age_years",e=>_l("age_years",e,kl)],["weightKg","weight_kg",e=>_l("weight_kg",e,Cl)]],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=Il(t,t.species);return"error"in l?l:(Object.assign(n,l.body),Object.keys(n).length===0?{error:Rl("patch must change at least one field")}:{body:n})}function Fl(e){if(e==null)return{body:{}};let t=Il(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 Ll=e=>typeof e=="string"?e:null,El=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function Ol(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
19
+ return Object.freeze({petRef:Ll(t.pet_ref)??petRef,name:Ll(t.name),species:Ll(t.species),breed:Ll(t.breed),ageYears:El(t.age_years),weightKg:El(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=Ll(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:Ll(t.pet_id),petRef:petRef,name:Ll(t.name),species:Ll(t.species),breed:Ll(t.breed),ageYears:El(t.age_years),weightKg:El(t.weight_kg),updatedAt:Ll(t.updated_at)})}function Al(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...yl(e)})}function jl(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 Dl(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:xl}))}function Dl(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>zl(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(jl(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=zl(petRef,t);if(n!==null)return err(n);let l=Fl(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(Ol(o.value,petRef)):err(o.error)},async updatePet(petRef,t,l){let i=n(petRef);if(typeof i!="string")return err(i);let o=Pl(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(Ol(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=Al(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 Ml=/* @__PURE__ */new WeakMap,Bl=/* @__PURE__ */new Map;function Hl(e,t,petRef,r){let n=Ml.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}|${Nl(r)}`}function Wl(e,t){if(e===null)return t();let r=Bl.get(e);if(r!==void 0)return r;let n=t().finally(()=>{Bl.get(e)===n&&Bl.delete(e)});return Bl.set(e,n),n}function Nl(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(Nl).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)}:${Nl(t)}`).join(",")}}`}var Ul="pet_not_registered";function $l(e){return e!=null&&e.reasonCode===Ul}var Vl=/* @__PURE__ */Object.freeze({status:"idle",error:null,registered:null,retry:()=>{}});function ql(petRef,e,t){let{runtime:r,userRef:userRef,scopeEpoch:s}=Ze(),u=n((e,t)=>{let n=r.registry.services.authFor(userRef);return Wl(Hl(r,n,e,t),()=>createPetsRepository(n).registerPet(e,t))},[r,userRef,s]),d=l(()=>e===void 0?null:Nl(e),[e]),[c,p]=o({key:null,status:"idle",error:null,registered:null}),f=i(0),h=i(t);h.current=t;let g=petRef===null||d===null?null:`${String(userRef)}|${s}|${petRef}|${d}`,b=n(()=>{if(petRef===null||e===void 0||g===null)return;let t=++f.current;p({key:g,status:"registering",error:null,registered:null}),u(petRef,e).then(e=>{t===f.current&&(e.ok?(p({key:g,status:"registered",error:null,registered:e.value}),h.current?.()):p({key:g,status:"failed",error:e.error,registered:null}))})},[u,petRef,g]);a(()=>{if(g===null){f.current+=1;return}return b(),()=>{f.current+=1}},[g,b]);let y=n(()=>{c.status==="failed"&&b()},[c.status,b]);return l(()=>g===null?Vl:c.key!==g?{status:"registering",error:null,registered:null,retry:y}:{status:c.status,error:c.error,registered:c.registered,retry:y},[g,c,y])}var Gl=/* @__PURE__ */Object.freeze({});function Kl(e){let[t,r]=o(Gl),s=i(null),u=i([]);u.current=e.map(e=>e.id),a(()=>{if(e.length===0){s.current=null,r(e=>e===Gl?e:Gl);return}let t=s.current;if(t===null)return;let n=e.find(e=>e.role==="user"&&!t.known.has(e.id));n!==void 0&&(s.current=null,r(e=>({...e,[n.id]:t.images})))},[e]);let d=n(e=>{s.current=e.length===0?null:{images:e,known:new Set(u.current)}},[]);return l(()=>({byMessage:t,stage:d}),[t,d])}var Yl=/* @__PURE__ */new WeakSet;function Ql(){let e=makeEverfurError("internalError",{retryable:true});return Yl.add(e),err(e)}function Zl(e){if(typeof e!="object"||e===null||e.ok!==false)return false;let t=e.error;return typeof t=="object"&&t!==null&&Yl.has(t)}var Jl=500;function Xl(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,Jl):null}function ei(e,t,r,n){let l=Xl(r),o=l===null?null:n!==void 0?`key:${String(n)}`:`prompt:${l}`,s=i(e);s.current=e;let u=i(null),d=i(null),c=i(o);c.current=o,a(()=>{if(l===null||o===null||t||u.current===o||d.current===o)return;let e=s.current;if(e===void 0)return;d.current=o;let r=e=>{d.current===o&&(d.current=null),!Zl(e)&&c.current===o&&(u.current=o)};Promise.resolve(e(l)).then(r,()=>r(void 0))},[l,o,t,e])}var ti=/* @__PURE__ */Object.freeze({openUnreadHead:true,reportLoadFailures:true}),ri=/* @__PURE__ */Object.freeze({reportLoadFailures:true}),ni=/* @__PURE__ */Object.freeze({...ti,markRead:true}),li=/* @__PURE__ */Object.freeze({...ri,markRead:true});function ii(e,t){return e?t?ni:ti:t?li:ri}function oi(e,t){let r=e?.isVisible===void 0?t:e.isVisible.bind(e);return r===void 0?true:Yr(()=>r()!==!1)===true}function ai(e,t){let r=i({target:e,isVisible:t});r.current={target:e,isVisible:t};let n=i(e.isStreaming);a(()=>{let t=n.current;if(n.current=e.isStreaming,!t||e.isStreaming)return;let{target:l,isVisible:i}=r.current;l.status!=="complete"||l.conversationId===null||l.unreadCount===null||!i()||l.markRead()},[e.isStreaming])}function si(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 ui(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"}:si(e,conversationId,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:conversationId}}var di=3e5;function ci(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 pi(e,t,r){let n=i(t);n.current=t;let l=i(null),o=i(null),s=i(false),u=i(0),d=i(0),c=i(3e4),p=()=>e?.isOffline===void 0?false:Yr(()=>e.isOffline?.()===!0)===true,f=p(),h=i(()=>{});h.current=e=>{let{conversationId:conversationId,isTurnInFlight:t,refresh:r,refreshesBlankThread:i}=n.current,a=ui(e,{activeConversationId:conversationId,isTurnInFlight:t,refreshesBlankThread:i===true,isOffline:p(),lastRefresh:l.current,now:Date.now()});if(a.action==="skip")return;if(a.action==="defer"){o.current!=="announced"&&(o.current=e);return}if(s.current){if(e==="poll")return;o.current!=="announced"&&(o.current=e);return}if(o.current=null,l.current={conversationId:a.conversationId,at:Date.now()},r===void 0)return;s.current=true;let f=e=>{s.current=false,ci(e)?(u.current=Math.min(u.current===0?c.current*2:u.current*2,di),d.current=Date.now()+u.current):(u.current=0,d.current=0);let t=o.current;t!==null&&h.current(t)};Promise.resolve(r()).then(f,()=>f({ok:false,error:{category:"server"}}))},a(()=>{if(t.isTurnInFlight||f)return;let e=o.current;e!==null&&h.current(e)},[t.isTurnInFlight,f]),a(()=>{if(e===void 0)return;let t=[],r=(e,r)=>{if(e===void 0)return;let n=Yr(()=>e(()=>{h.current(r)}));typeof n=="function"&&t.push(n)};return r(e.onForeground?.bind(e),"foreground"),r(e.onOnline?.bind(e),"foreground"),r(e.onAnnounced?.bind(e),"announced"),()=>{for(let e of t)Yr(e)}},[e]);let g=r?.intervalMs??null,b=r?.isVisibleFallback;a(()=>{if(e===void 0||g===null||!Number.isFinite(g)||g<=0)return;c.current=g;let t=setInterval(()=>{Date.now()<d.current||oi(e,b)&&h.current("poll")},g);return()=>clearInterval(t)},[e,g,b])}var fi=/^efch_[A-Za-z0-9_-]{43}$/,hi="efch";function gi(e){return typeof e=="string"&&fi.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(`${hi}=`))continue;let e=r.slice(hi.length+1);return gi(e)?e:null}return null}var bi=/* @__PURE__ */Object.freeze(["better","same","worse"]),yi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var mi="checkin",vi=/^\d{4}-\d{2}-\d{2}$/,wi="watching";function isCheckinSettled(e){return e.status!=null&&e.status!==wi}function ki(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,l]=t;return r!==mi||n===void 0||l===void 0||!yi.test(n)||!vi.test(l)?null:{caseId:n,dueDay:l}}function Ci(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 xi=128,Ri=/[\u0000-\u001f\u007f]/;function Ti(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function _i(e){return typeof e!="string"||e.length===0||e.length>xi||Ri.test(e)||e.includes("://")?null:e}function zi(e){if(e===null)return null;let conversationId=e.conversation_id,petRef=_i(e.pet_ref);return typeof conversationId!="string"||!Ci(conversationId)||petRef===null?null:{conversationId:conversationId,petRef:petRef}}function Ii(e,t,r){return gi(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(zi(Ti(e.value))):e.error.httpStatus===404?ok(null):err(e.error),()=>err(Si("internalError",false))):Promise.resolve(ok(null))}function Pi(e,t){let r=t?.runtime??null,userRef=t?.userRef??null,n=gi(e)?e:null,l=n===null||userRef===null?null:`${String(userRef)}|${n}`,[i,s]=o(null);return a(()=>{if(l===null||n===null||userRef===null||r===null)return;let e=true,t=r.registry.services;return Ii(t.authFor(userRef),n,t.errorPolicy).then(t=>{!e||!t.ok||t.value===null||s({key:l,target:/* @__PURE__ */Object.freeze({kind:"chat",conversationId:t.value.conversationId,petRef:t.value.petRef})})}),()=>{e=false}},[l,r,n,userRef]),i!==null&&i.key===l?i.target:void 0}function Fi(e){if(e===void 0)return null;let conversationId=e.conversationId??"",petRef=e.petRef??"";return conversationId===""&&petRef===""?null:`${String(conversationId)}|${String(petRef)}`}function Li(e,t,r){let n=Fi(t),l=t?.kind==="chat",o=t?.petRef??null,s=l&&!r.pinned&&o!==null&&r.petRef!==null&&o!==r.petRef,u=i({openCheckin:e,target:t,selectPet:r.selectPet});u.current={openCheckin:e,target:t,selectPet:r.selectPet};let d=i(null),c=i(null),petRef=r.petRef;a(()=>{if(n===null||d.current===n)return;let{openCheckin:e,target:t,selectPet:i}=u.current;if(s&&o!==null){if(c.current?.key!==n){c.current={key:n,from:petRef},i(o);return}petRef!==c.current.from&&(d.current=n);return}l&&!r.ready||(d.current=n,!(e===void 0||t===void 0)&&Promise.resolve(e(t)).catch(()=>{}))},[n,l,s,o,petRef,r.ready])}var Ei=/* @__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 Oi(e){let t=e?.replace(/\s+/g," ").trim();return t||Ei.untitled}function Ai(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}function ji(e){let t=Ai(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?Ei.newReply.replace("{date}",t):t}function Di(e,t){return t?`${Ei.countLabel}${Ei.countSeparator}${e}`:Ei.countLabel}function Mi(e){return`${e.unreadCount!==null&&e.unreadCount>0?Ei.unreadPrefix:""}${Ei.openConversation} ${Oi(e.title)}`}function Bi(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}function Hi(e,t){let r=Bi(t);if(r.length===0)return e;let n=[[],[],[]];for(let t of e){let e=Bi(Oi(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 Wi(e){return{scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}function Ni(e){let[t,r]=o(false),[s,u]=o(""),d=e.listConversations,c=i(0),[p,f]=o(()=>Wi(d)),h=p.scope===d?p:Wi(d);a(()=>(c.current+=1,r(false),u(""),f(Wi(d)),()=>{c.current+=1}),[d]);let g=n(async t=>{let r=++c.current,n=t!==void 0;f(e=>({...e,scope:d,loading:!n,loadingMore:n,error:null}));let l=await e.listConversations(t?{cursor:t}:void 0);if(r===c.current){if(!l.ok){f(e=>({...e,loading:false,loadingMore:false,error:l.error.displayMessage}));return}f(e=>{let r=t&&e.scope===d?e.rows:[],n=new Set(r.map(e=>e.id));return{scope:d,loading:false,loadingMore:false,error:null,rows:[...r,...l.value.conversations.filter(e=>!n.has(e.id))],cursor:l.value.nextCursor===t?null:l.value.nextCursor}})}},[e.listConversations,d]),b=()=>{r(true),u(""),g()},y=()=>{c.current+=1,r(false)},m=async t=>{let n=++c.current;f(e=>({...e,loading:true,error:null}));let l=await e.resumeConversation(t);n===c.current&&(f(e=>({...e,loading:false,error:l.ok?null:l.error.displayMessage})),l.ok&&r(false))},v=async()=>{let t=c.current,r=await e.loadOlderMessages();t===c.current&&!r.ok&&f(e=>({...e,error:r.error.displayMessage}))},w=()=>{e.newConversation(),c.current+=1,r(false)},k=()=>{h.cursor===null||h.loading||h.loadingMore||s.trim().length>0||g(h.cursor)},C=l(()=>Hi(h.rows,s),[h.rows,s]),S=s.trim().length>0;return{...h,open:t,show:b,close:y,load:g,resume:m,earlier:v,newConversation:w,loadMore:k,query:s,setQuery:u,searching:S,filtered:C,emptyKind:h.rows.length===0?"empty":"noMatch"}}var Ui="#111111",$i="#FFFFFF",Vi=/* @__PURE__ */Object.freeze({emergency:/* @__PURE__ */Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:Ui,pillColor:$i,showsVetAction:true}),schedule_soon:/* @__PURE__ */Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:Ui,pillColor:$i,showsVetAction:true}),home_care:/* @__PURE__ */Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Ui,pillColor:$i,showsVetAction:false}),general:/* @__PURE__ */Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Ui,pillColor:$i,showsVetAction:false})});function qi(e){return`${e.messageId}:${e.level}:${e.reason??""}`}function Gi(e){return Ue(Ne.urgencyGeneralReason,{petName:e?.trim()||Ne.emptyTitlePetFallback})}function Ki(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:Yi(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:Gi(t)}:null}return null}function Yi(e){return typeof e=="string"&&e.trim().length>0?e:null}function Qi(e){let t=e===null?null:qi(e),[r,i]=o(null),[s,u]=o(false);a(()=>u(false),[t]);let d=e!==null&&(s||!(r!==null&&r===t)),c=e===null?null:Vi[e.level],p=e!==null&&!d&&e.level!=="general",f=n(()=>{t!==null&&i(t),u(false)},[t]),h=n(()=>u(true),[]);return l(()=>({source:e,tier:c,signature:t,showBanner:d,showCompactIcon:p,showVetAction:d&&c!==null&&c.showsVetAction,dismissLabel:c===null?null:Ue(Ne.dismissBanner,{label:c.label}),dismiss:f,expand:h}),[e,c,t,d,p,f,h])}var Zi=()=>globalThis[/* @__PURE__ */Symbol.for("everfur.sdk.chatCards.v1")]??={loader:null,lazy:null};var Ji=Zi;function registerEverfurChatCards(e){let t=Ji();t.loader=e;let n=e&&Promise.resolve().then(e).then(e=>typeof e.ServerCards=="function"?e.ServerCards:NONE3,()=>NONE3);t.lazy=n&&r(async()=>({default:await n}))}var NONE3=()=>null,Xi=createContext(null);function ServerCardsSlot({message:e}){let r=u(Xi),n=Ji(),l=e.a2ui??n.frames?.get(e.responseId),i=n.lazy;return l===void 0||r===null||i===null?null:t(p,{fallback:null},t(i,{message:e,a2ui:l,host:r}))}var eo=class extends d{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:e,fallback:r,resetKey:n}){return t(eo,{fallback:r,resetKey:n,children:t(RenderHost,{render:e})})}var to=48;function ro(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(e){let{capability:t,children:r,renderDisabled:n,renderPending:i,style:o}=e,a=useCapability(t),s=l(()=>ro(a),[a]);switch(s){case"enabled":return r;case"pending":return i?/* @__PURE__ */A(HostRender,{render:i,fallback:/* @__PURE__ */A(PendingSkeleton,{capability:t,style:o})}):/* @__PURE__ */A(PendingSkeleton,{capability:t,style:o});case"disabled":return n?/* @__PURE__ */A(HostRender,{render:()=>n(a),fallback:/* @__PURE__ */A(OffState,{decision:a,style:o}),resetKey:a}):/* @__PURE__ */A(OffState,{decision:a,style:o});default:return assertNever(s)}}function PendingSkeleton({capability:e,style:t}){let r=useEverfurTheme(),n=l(()=>no(r),[r]);/* @__PURE__ */
21
+ return A(v,{style:[n.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:/* @__PURE__ */A(v,{style:n.skeletonBar})})}function OffState({decision:e,style:t}){let r=useEverfurTheme(),n=l(()=>no(r),[r]),i=e.disabled?.reason??"";/* @__PURE__ */
22
+ return A(v,{style:[n.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:i,children:i.length>0?/* @__PURE__ */A(Text,{style:n.offstateText,children:i}):null})}function no(e){let{color:t,space:r,radius:n,type:l}=e;return g.create({offstate:{minHeight:to,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:g.hairlineWidth,borderColor:t.brandBorder},offstateText:{...face(e,"regular"),fontSize:l.size.body,lineHeight:Math.round(l.size.body*l.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}var lo="everfur.com",io=2048,oo=/^(\*\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function ao(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&&oo.test(e)&&t.add(e)}/* @__PURE__ */
23
+ return Object.freeze([...t])}function so(e,t){if(e===lo||e.endsWith(`.${lo}`))return true;for(let r of t)if(r.startsWith("*.")?e.endsWith(r.slice(1)):e===r)return true;return false}function uo(e,t){if(typeof e!="string"||e.length===0||e.length>io||!/^https:\/\//i.test(e))return null;let r=Pt(e);return r===null||r.protocol!=="https:"||r.username!==""||r.password!==""||r.port!==""?null:so(r.hostname,t)?r.href:null}function co(e){try{Promise.resolve(w.openURL(e)).catch(()=>{})}catch{}}var po=createContext(null);function fo(){return u(po)??void 0}function MessageLinksScope({linkHosts:e,onOpenUrl:r,children:n}){let i=e===false?null:Array.isArray(e)?e.join(`\n`):"",o=l(()=>{if(i===null)return null;let e=ao(i===""?[]:i.split(`\n`));/* @__PURE__ */
24
+ return Object.freeze({hosts:e,open:r!==void 0?e=>{Yr(r,e,"message")}:co})},[i,r]);return t(po.Provider,{value:o},n)}var ho={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function go(e){return{width:e,height:e,alignItems:"center",justifyContent:"center"}}function bo(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}function MenuGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r),l={width:e*.82,height:n,borderRadius:n,backgroundColor:t};/* @__PURE__ */
25
+ return j(v,{style:[go(e),{gap:e*.22}],...ho,children:[
25
26
  /* @__PURE__ */A(v,{style:l}),
26
27
  /* @__PURE__ */A(v,{style:l}),
27
- /* @__PURE__ */A(v,{style:l})]})}function Cross({size:e,color:t,strokeWidth:r,rotate:n}){let l=ho(e,r),i=e*.78;/* @__PURE__ */
28
- return j(v,{style:[fo(e),{transform:[{rotate:n}]}],...po,children:[
28
+ /* @__PURE__ */A(v,{style:l})]})}function Cross({size:e,color:t,strokeWidth:r,rotate:n}){let l=bo(e,r),i=e*.78;/* @__PURE__ */
29
+ return j(v,{style:[go(e),{transform:[{rotate:n}]}],...ho,children:[
29
30
  /* @__PURE__ */A(v,{style:{position:"absolute",width:i,height:l,borderRadius:l,backgroundColor:t}}),
30
31
  /* @__PURE__ */A(v,{style:{position:"absolute",width:l,height:i,borderRadius:l,backgroundColor:t}})]})}function PlusGlyph(e){/* @__PURE__ */
31
32
  return A(Cross,{...e,rotate:"0deg"})}function CloseGlyph(e){/* @__PURE__ */
32
- return A(Cross,{...e,rotate:"45deg"})}function CheckGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r);/* @__PURE__ */
33
- return A(v,{style:fo(e),...po,children:/* @__PURE__ */A(v,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}var go={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:t,strokeWidth:r,direction:n}){let l=ho(e,r),i=e*.46,o=go[n];/* @__PURE__ */
34
- return A(v,{style:fo(e),...po,children:/* @__PURE__ */A(v,{style:{width:i,height:i,borderRightWidth:l,borderBottomWidth:l,borderColor:t,marginTop:i*o.marginTop,marginLeft:i*o.marginLeft,transform:[{rotate:o.rotate}]}})})}function BookGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r),l={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};/* @__PURE__ */
35
- return j(v,{style:[fo(e),{flexDirection:"row",gap:1}],...po,children:[
33
+ return A(Cross,{...e,rotate:"45deg"})}function CheckGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r);/* @__PURE__ */
34
+ return A(v,{style:go(e),...ho,children:/* @__PURE__ */A(v,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}var yo={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:t,strokeWidth:r,direction:n}){let l=bo(e,r),i=e*.46,o=yo[n];/* @__PURE__ */
35
+ return A(v,{style:go(e),...ho,children:/* @__PURE__ */A(v,{style:{width:i,height:i,borderRightWidth:l,borderBottomWidth:l,borderColor:t,marginTop:i*o.marginTop,marginLeft:i*o.marginLeft,transform:[{rotate:o.rotate}]}})})}function BookGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r),l={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};/* @__PURE__ */
36
+ return j(v,{style:[go(e),{flexDirection:"row",gap:1}],...ho,children:[
36
37
  /* @__PURE__ */A(v,{style:[l,{borderTopLeftRadius:e*.2}]}),
37
- /* @__PURE__ */A(v,{style:[l,{borderTopRightRadius:e*.2}]})]})}function ArrowUpRightGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r),l=e*.5;/* @__PURE__ */
38
- return j(v,{style:fo(e),...po,children:[
38
+ /* @__PURE__ */A(v,{style:[l,{borderTopRightRadius:e*.2}]})]})}function ArrowUpRightGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r),l=e*.5;/* @__PURE__ */
39
+ return j(v,{style:go(e),...ho,children:[
39
40
  /* @__PURE__ */A(v,{style:{position:"absolute",width:e*.78,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}}),
40
- /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.16,right:e*.16,width:l,height:l,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}function CopyGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r),l=e*.6,i={position:"absolute",width:l,height:l,borderWidth:n,borderColor:t,borderRadius:e*.14};/* @__PURE__ */
41
- return j(v,{style:fo(e),...po,children:[
41
+ /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.16,right:e*.16,width:l,height:l,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}function CopyGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r),l=e*.6,i={position:"absolute",width:l,height:l,borderWidth:n,borderColor:t,borderRadius:e*.14};/* @__PURE__ */
42
+ return j(v,{style:go(e),...ho,children:[
42
43
  /* @__PURE__ */A(v,{style:[i,{top:0,left:0}]}),
43
- /* @__PURE__ */A(v,{style:[i,{bottom:0,right:0}]})]})}function ThumbGlyph({size:e,color:t,strokeWidth:r,active:n,rotate:l}){let i=ho(e,r),o=n?t:"transparent";/* @__PURE__ */
44
- return j(v,{style:[fo(e),{transform:[{rotate:l}]}],...po,children:[
44
+ /* @__PURE__ */A(v,{style:[i,{bottom:0,right:0}]})]})}function ThumbGlyph({size:e,color:t,strokeWidth:r,active:n,rotate:l}){let i=bo(e,r),o=n?t:"transparent";/* @__PURE__ */
45
+ return j(v,{style:[go(e),{transform:[{rotate:l}]}],...ho,children:[
45
46
  /* @__PURE__ */A(v,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),
46
47
  /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),
47
- /* @__PURE__ */A(v,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.05}})]})}function InfoGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r);/* @__PURE__ */
48
- return j(v,{style:[fo(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...po,children:[
48
+ /* @__PURE__ */A(v,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.05}})]})}function InfoGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r);/* @__PURE__ */
49
+ return j(v,{style:[go(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...ho,children:[
49
50
  /* @__PURE__ */A(v,{style:{width:n,height:n,borderRadius:n,backgroundColor:t,marginBottom:e*.1}}),
50
- /* @__PURE__ */A(v,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}function UploadGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r),l=e*.34;/* @__PURE__ */
51
- return j(v,{style:fo(e),...po,children:[
51
+ /* @__PURE__ */A(v,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}function UploadGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r),l=e*.34;/* @__PURE__ */
52
+ return j(v,{style:go(e),...ho,children:[
52
53
  /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.06,width:l,height:l,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}}),
53
54
  /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.1,width:n,height:e*.56,borderRadius:n,backgroundColor:t}}),
54
- /* @__PURE__ */A(v,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}function PhotoGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r);/* @__PURE__ */
55
- return j(v,{style:[fo(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...po,children:[
55
+ /* @__PURE__ */A(v,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}function PhotoGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r);/* @__PURE__ */
56
+ return j(v,{style:[go(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...ho,children:[
56
57
  /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:t}}),
57
- /* @__PURE__ */A(v,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function CameraGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r);/* @__PURE__ */
58
- return j(v,{style:fo(e),...po,children:[
58
+ /* @__PURE__ */A(v,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function CameraGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r);/* @__PURE__ */
59
+ return j(v,{style:go(e),...ho,children:[
59
60
  /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderTopLeftRadius:n,borderTopRightRadius:n}}),
60
- /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */A(v,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}function SearchGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r),l=e/24,i=16*l+n,o=11*l-i/2,a=11+8/Math.SQRT2,s=(21-a)*Math.SQRT2*l,u=(a+21)/2*l;/* @__PURE__ */
61
- return j(v,{style:fo(e),...po,children:[
61
+ /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */A(v,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}function SearchGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r),l=e/24,i=16*l+n,o=11*l-i/2,a=11+8/Math.SQRT2,s=(21-a)*Math.SQRT2*l,u=(a+21)/2*l;/* @__PURE__ */
62
+ return j(v,{style:go(e),...ho,children:[
62
63
  /* @__PURE__ */A(v,{style:{position:"absolute",top:o,left:o,width:i,height:i,borderRadius:i,borderWidth:n,borderColor:t}}),
63
- /* @__PURE__ */A(v,{style:{position:"absolute",top:u-n/2,left:u-(s+n)/2,width:s+n,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"45deg"}]}})]})}function EditGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r);/* @__PURE__ */
64
- return j(v,{style:fo(e),...po,children:[
64
+ /* @__PURE__ */A(v,{style:{position:"absolute",top:u-n/2,left:u-(s+n)/2,width:s+n,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"45deg"}]}})]})}function EditGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r);/* @__PURE__ */
65
+ return j(v,{style:go(e),...ho,children:[
65
66
  /* @__PURE__ */A(v,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:n,borderColor:t,borderRadius:n,transform:[{rotate:"45deg"}]}}),
66
- /* @__PURE__ */A(v,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:n,borderRadius:n,backgroundColor:t}})]})}function MapPinGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r),l=e*.62;/* @__PURE__ */
67
- return j(v,{style:fo(e),...po,children:[
67
+ /* @__PURE__ */A(v,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:n,borderRadius:n,backgroundColor:t}})]})}function MapPinGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r),l=e*.62;/* @__PURE__ */
68
+ return j(v,{style:go(e),...ho,children:[
68
69
  /* @__PURE__ */A(v,{style:{position:"absolute",top:0,width:l,height:l,borderRadius:l,borderWidth:n,borderColor:t,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */A(v,{style:{width:n*1.4,height:n*1.4,borderRadius:n,backgroundColor:t}})}),
69
70
  /* @__PURE__ */A(v,{style:{position:"absolute",bottom:e*.04,width:l*.5,height:l*.5,borderRightWidth:n,borderBottomWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function SendGlyph({size:e,color:t,testID:r}){let n=e*.36;/* @__PURE__ */
70
- return A(v,{style:fo(e),testID:r,...po,children:/* @__PURE__ */A(v,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}function StopGlyph({size:e,color:t,testID:r}){/* @__PURE__ */
71
- return A(v,{style:fo(e),testID:r,...po,children:/* @__PURE__ */A(v,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}function MicGlyph({size:e,color:t,strokeWidth:r,testID:n}){let l=ho(e,r);/* @__PURE__ */
72
- return j(v,{style:fo(e),testID:n,...po,children:[
71
+ return A(v,{style:go(e),testID:r,...ho,children:/* @__PURE__ */A(v,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}function StopGlyph({size:e,color:t,testID:r}){/* @__PURE__ */
72
+ return A(v,{style:go(e),testID:r,...ho,children:/* @__PURE__ */A(v,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}function MicGlyph({size:e,color:t,strokeWidth:r,testID:n}){let l=bo(e,r);/* @__PURE__ */
73
+ return j(v,{style:go(e),testID:n,...ho,children:[
73
74
  /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.08,width:e*.26,height:e*.48,borderWidth:l,borderColor:t,borderRadius:e*.13}}),
74
75
  /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.38,width:e*.56,height:e*.36,borderBottomWidth:l,borderLeftWidth:l,borderRightWidth:l,borderColor:t,borderBottomLeftRadius:e*.28,borderBottomRightRadius:e*.28}}),
75
76
  /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.74,width:l,height:e*.18,backgroundColor:t}})]})}function Ring({size:e,strokeWidth:t,color:r,children:n}){/* @__PURE__ */
76
- return A(v,{style:[fo(e),{borderRadius:e/2,borderWidth:t??g.hairlineWidth,borderColor:r}],children:n})}function ArrowUpGlyph({size:e,color:t,strokeWidth:r,testID:n}){let l=ho(e,r),i=e*.46;/* @__PURE__ */
77
- return j(v,{style:fo(e),testID:n,...po,children:[
77
+ return A(v,{style:[go(e),{borderRadius:e/2,borderWidth:t??g.hairlineWidth,borderColor:r}],children:n})}function ArrowUpGlyph({size:e,color:t,strokeWidth:r,testID:n}){let l=bo(e,r),i=e*.46;/* @__PURE__ */
78
+ return j(v,{style:go(e),testID:n,...ho,children:[
78
79
  /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.16,bottom:e*.12,width:l,borderRadius:l,backgroundColor:t}}),
79
- /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.16+l/2,width:i,height:i,borderLeftWidth:l,borderTopWidth:l,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function ChatBubbleGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r);/* @__PURE__ */
80
- return j(v,{style:fo(e),...po,children:[
80
+ /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.16+l/2,width:i,height:i,borderLeftWidth:l,borderTopWidth:l,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function ChatBubbleGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r);/* @__PURE__ */
81
+ return j(v,{style:go(e),...ho,children:[
81
82
  /* @__PURE__ */A(v,{style:{width:e*.8,height:e*.6,marginTop:-e*.12,borderWidth:n,borderColor:t,borderRadius:e*.14}}),
82
- /* @__PURE__ */A(v,{style:{position:"absolute",bottom:e*.1,left:e*.22,width:e*.2,height:e*.2,borderLeftWidth:n,borderBottomWidth:n,borderColor:t}})]})}function HistoryGlyph({size:e,color:t,strokeWidth:r}){let n=ho(e,r),l=e*.72,i=e/2;/* @__PURE__ */
83
- return j(v,{style:fo(e),...po,children:[
83
+ /* @__PURE__ */A(v,{style:{position:"absolute",bottom:e*.1,left:e*.22,width:e*.2,height:e*.2,borderLeftWidth:n,borderBottomWidth:n,borderColor:t}})]})}function HistoryGlyph({size:e,color:t,strokeWidth:r}){let n=bo(e,r),l=e*.72,i=e/2;/* @__PURE__ */
84
+ return j(v,{style:go(e),...ho,children:[
84
85
  /* @__PURE__ */A(v,{style:{width:l,height:l,borderRadius:l/2,borderWidth:n,borderColor:t,borderLeftColor:"transparent",transform:[{rotate:"45deg"}]}}),
85
86
  /* @__PURE__ */A(v,{style:{position:"absolute",top:e*.16,left:e*.12,width:e*.2,height:e*.2,borderLeftWidth:n,borderBottomWidth:n,borderColor:t}}),
86
87
  /* @__PURE__ */A(v,{style:{position:"absolute",top:i-e*.2,left:i-n/2,width:n,height:e*.2+n/2,borderRadius:n,backgroundColor:t}}),
87
- /* @__PURE__ */A(v,{style:{position:"absolute",top:i-n/2,left:i-n/2,width:e*.15+n/2,height:n,borderRadius:n,backgroundColor:t}})]})}var bo=/* @__PURE__ */Object.freeze({standard:se.standard,emphasized:se.emphasized,exit:se.exit,outQuad:/* @__PURE__ */Object.freeze([.25,.46,.45,.94]),out:/* @__PURE__ */Object.freeze([.23,1,.32,1])});var yo=/* @__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}),mo=/* @__PURE__ */Object.freeze({...yo,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 vo(e){return e.motion.reducedMotion?mo:yo}function wo(e,t){return Math.max(0,t)*e.followUpStaggerMs}function ko(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 Co(){let e=useEverfurTheme();return vo(e)}var So=8;function xo(e,t,r){return((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}function Ro(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}function To(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<So;r+=1){let r=Ro(i,t,n);if(r===0)break;i-=(xo(i,t,n)-e)/r}return xo(Math.min(1,Math.max(0,i)),r,l)}}var _o=To(bo.standard),zo=To(bo.outQuad),Io=To(bo.out);function Po(e){let t=i(null);return t.current===null&&(t.current=new L.Value(e)),t.current}function Fo(e,t={}){let r=t.risePx??0,n=t.delayMs??0,i=Po(e>0?0:1);return a(()=>{if(e<=0){i.setValue(1);return}let t=L.timing(i,{toValue:1,duration:e,easing:zo,useNativeDriver:true}),r=n>0?L.sequence([L.delay(n),t]):t;return r.start(),()=>r.stop()},[i,e,n]),l(()=>({opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[i,r])}function FadePresence({visible:e,inMs:t,outMs:r,style:n,children:l}){let[i,s]=o(e),u=Po(e&&t<=0?1:0);return a(()=>{if(e){s(true);let e=L.timing(u,{toValue:1,duration:Math.max(0,t),easing:_o,useNativeDriver:true});return e.start(),()=>e.stop()}if(!i)return;if(r<=0){s(false);return}let n=L.timing(u,{toValue:0,duration:r,easing:_o,useNativeDriver:true});return n.start(({finished:e})=>{e&&s(false)}),()=>n.stop()},[e,i,t,r,u]),!i&&!e?null:/* @__PURE__ */A(L.View,{style:[n,{opacity:u}],children:l})}var Lo=/* @__PURE__ */Object.freeze({opacity:1,transform:/* @__PURE__ */Object.freeze([{translateY:0},{scale:1}])});function Eo(e,t){let[r]=o(()=>e?t.bubbleInMs:0),n=r>0,i=Po(n?0:1);a(()=>{if(r<=0)return;let e=L.timing(i,{toValue:1,duration:r,easing:Io,useNativeDriver:true});return e.start(),()=>e.stop()},[r,i]);let s=t.bubbleFromScale,u=t.bubbleRisePx;return l(()=>n?{opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[u,0]})},{scale:i.interpolate({inputRange:[0,1],outputRange:[s,1]})}]}:Lo,[n,i,u,s])}function Oo(e){let t=i(null),r=i(null),l=e[0]?.id??null;if(t.current===null||r.current!==l){let n=t.current===null;t.current=new Map(e.map(e=>[e.id,n&&e.pending===true])),r.current=l}let o=t.current;for(let t of e)o.has(t.id)||o.set(t.id,true);return n(e=>o.get(e)===true,[o])}var Ao=12;function PressScale({style:e,containerStyle:t,children:r,onPressIn:l,onPressOut:i,hitSlop:o,...a}){let s=Co(),u=Po(1),d=n(e=>{s.pressMs<=0||s.pressScale===1||L.timing(u,{toValue:e,duration:s.pressMs,easing:_o,useNativeDriver:true}).start()},[u,s.pressMs,s.pressScale]);/* @__PURE__ */
88
- return A(C,{...a,hitSlop:o??Ao,style:t,onPressIn:e=>{d(s.pressScale),l?.(e)},onPressOut:e=>{d(1),i?.(e)},children:/* @__PURE__ */A(L.View,{style:[e,{transform:[{scale:u}]}],children:r})})}function jo(e,t,r){let n=t&&r.revealTickMs>0,[l,s]=o(0),u=i(e);return u.current=e,a(()=>{if(!n)return;let e=setInterval(()=>{s(e=>ko(r,e,u.current.length))},r.revealTickMs);return()=>clearInterval(e)},[n,r]),n?e.slice(0,Math.min(l,e.length)):e}var Do=false;function Mo(e){e.layoutMs<=0||(Do||(Do=true,b.OS==="android"&&typeof P.setLayoutAnimationEnabledExperimental=="function"&&P.setLayoutAnimationEnabledExperimental(true)),F.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}))}function Bo(e,t){let r=i(e);r.current!==e&&(r.current=e,Mo(t))}var Ho=36,Wo=22,No=12,Uo=12,$o=16,Vo="#000",qo="rgba(0,0,0,0.45)";function AttachmentImageLightbox({uri:e,label:t,onClose:r}){let n=useEverfurTheme(),l=M();return e===null?null:/* @__PURE__ */j(R,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[
89
- /* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:He.closePreview,style:Go.backdrop,onPress:r,children:/* @__PURE__ */A(z,{source:{uri:e},style:Go.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),
90
- /* @__PURE__ */A(v,{pointerEvents:"box-none",style:[Go.closeWrap,{top:l.top+Uo}],children:/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:He.closePreview,hitSlop:No,style:Go.closeButton,onPress:r,children:/* @__PURE__ */A(CloseGlyph,{size:Wo,color:n.color.surface,strokeWidth:2})})})]})}var Go=g.create({backdrop:{flex:1,backgroundColor:Vo,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:$o},closeButton:{width:Ho,height:Ho,borderRadius:Ho/2,backgroundColor:qo,alignItems:"center",justifyContent:"center"}});var Ko=()=>{};function Yo(){try{return y.currentState==="active"}catch{return false}}function createAppStateLifecycle(){return{onForeground(e){let t;try{let r=y.currentState==="background";t=y.addEventListener("change",t=>{t==="background"?r=!0:t==="active"&&r&&(r=!1,e())})}catch{return Ko}return()=>t.remove()},isVisible:Yo}}function Qo(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 Zo(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}function Jo(e){return e?.textColor===void 0?{}:{color:e.textColor}}var Xo=/* @__PURE__ */Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function ea(e){return e!==Xo}var ta=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function ra(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 na=4e3;var la=4e3;var ia=/* @__PURE__ */Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var oa=10*1024*1024,aa=5,sa=120,ua="/widget/v1/uploads/initiate";function isAttachmentMime(e){return typeof e=="string"&&ia.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<=sa)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,sa);let n=t.slice(r);return n.length>=sa?t.slice(0,sa):`${t.slice(0,r).slice(0,sa-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 da=e=>/* @__PURE__ */Object.freeze({ok:true,value:e}),ca=e=>/* @__PURE__ */Object.freeze({ok:false,error:e});function pa(e,t,r,n){/* @__PURE__ */
91
- 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 ca(pa("unsupported_type",false,t));let n=attachmentSize(e);return n===null?ca(pa("unknown",false,t)):n>oa?ca(pa("too_large",false,t,{sizeBytes:n})):da(/* @__PURE__ */Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}function fa(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__ */
92
- 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)??oa,s3_key:o,purpose:r(t.purpose)})}function ha(e,t){let r=e.httpStatus;switch(e.code){case"quotaExceeded":return pa("quota_exceeded",false,t,{cause:e});case"rateLimited":return pa("rate_limited",true,t,{cause:e});case"idempotencyConflict":case"idempotencyInFlight":return pa("idempotency_conflict",true,t,{cause:e});case"validationFailed":return pa("unsupported_type",false,t,{cause:e});case"serviceUnavailable":case"streamTimeout":return pa("network",true,t,{cause:e});default:return r===429?pa("rate_limited",true,t,{cause:e}):r===503?pa("network",true,t,{cause:e}):r===void 0?pa("network",true,t,{cause:e}):pa("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:ua,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return ca(ha(n.error,t.filename));let l=fa(n.value);return l===null?ca(pa("server",false,t.filename)):da(l)}async function uploadAttachmentBytes(e,t,r,n){let l=()=>n?.signal?.aborted===true;if(l())return ca(pa("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),da(void 0)}catch{return l()?ca(pa("cancelled",true,r.filename)):ca(pa("server",true,r.filename))}}var ga=2,ba=3,ya=/* @__PURE__ */Object.freeze([1e3,2e3,4e3]),ma=0;function va(){return ma+=1,`attachment-${ma}`}function createAttachmentQueue(e){let t=Math.max(1,e.concurrency??ga),r=Math.max(1,e.maxAttempts??ba),n=e.backoffMs??ya,l=Math.max(1,e.maxPerMessage??aa),i=e.timers??ta,o=e.newId??va,a=ea(e.transport),s=/* @__PURE__ */new Map,u=[],d=[],c=/* @__PURE__ */new Set,p=/* @__PURE__ */new Set,f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])}),h=false,g=()=>{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()},b=(e,t)=>{e.state=/* @__PURE__ */Object.freeze({...e.state,...t}),g()},y=()=>{for(;!h&&c.size<t&&d.length>0;){let e=d.shift(),t=s.get(e);t!==void 0&&(c.add(e),m(t).finally(()=>{c.delete(e),y()}))}},m=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;b(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=ca(a.error);else{let r=await uploadAttachmentBytes(e.transport,a.value,l,{signal:o,onProgress:e=>{!o.aborted&&t.state.status==="uploading"&&b(t,{progress:wa(e)})}});if(h||o.aborted)return;s=r.ok?da(a.value.s3_key):ca(r.error)}if(s.ok){b(t,{status:"uploaded",s3Key:s.value,error:null,progress:1});return}let u=s.error,d=u.retryable&&t.attempts<r;if(b(t,{status:d?"uploading":"failed",error:u,progress:0}),!d)return;let c=n[Math.min(t.attempts-1,n.length-1)]??0;await ra(c,o,i)}},v=e=>{d.push(e.state.id),y()},w={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 ca(pa("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),g(),v(n),da(n.state)},retry(e){let t=s.get(e);t===void 0||h||t.state.status!=="failed"||(t.controller=new AbortController,t.attempts=0,b(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=d.indexOf(e);n>=0&&d.splice(n,1),g()},clear(){for(let e of[...u])w.remove(e)},dispose(){h=true;for(let e of s.values())e.controller.abort();s.clear(),u.length=0,d.length=0,p.clear(),f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])})}};return w}function wa(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function ka(e){switch(e.code){case"too_large":return We(He.attachmentTooLarge,{max:formatBytes(oa),filename:e.filename,size:formatBytes(e.sizeBytes??0)});case"too_many":return We(He.attachmentTooMany,{max:aa});case"unsupported_type":return We(He.attachmentUnsupported,{filename:e.filename});case"network":return He.attachmentNetwork;case"server":return We(He.attachmentServer,{status:""});case"cancelled":return He.attachmentCancelled;case"rate_limited":return He.attachmentRateLimited;case"quota_exceeded":return He.attachmentQuota;case"idempotency_conflict":return He.attachmentConflict;case"unknown":return He.attachmentUnknown}}function Ca(e,t){return We(e>=t?He.attachmentsFull:He.addAttachment,{used:e,total:t})}var Sa=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])});function useChatAttachments(e={}){let{runtime:t,userRef:userRef,scopeEpoch:r}=Ye(),u=e.maxPerMessage??aa,d=n(()=>{let{services:r}=t.registry;return createAttachmentQueue({funnel:createRequestFunnel({auth:r.authFor(userRef),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),transport:e.transport??r.uploadTransport,maxPerMessage:u})},[t,userRef,r,u,e.transport]),c=l(()=>e.queue??d(),[e.queue,d]),p=i(/* @__PURE__ */new WeakSet),[f,h]=o(null),g=f!==null&&f.of===c?f.queue:c;a(()=>{if(g!==e.queue){if(p.current.has(g)){h({of:c,queue:d()});return}return()=>{g.dispose(),p.current.add(g)}}},[g,c,d,e.queue]);let b=s(g.subscribe,g.getSnapshot,()=>Sa),[y,m]=o(null),v=n(e=>{let t=(Array.isArray(e)?e:[e]).map(e=>g.add(e)),r=t.find(e=>!e.ok);return r!==void 0&&!r.ok&&m(r.error),t},[g,m]),w=n(e=>g.retry(e),[g]),k=n(e=>g.remove(e),[g]),C=n(()=>g.clear(),[g]),S=n(()=>m(null),[m]),x=b.attachments.some(e=>e.status==="uploading"),R=b.attachments.some(e=>e.status==="failed");return l(()=>({available:g.available,attachments:b.attachments,maxPerMessage:u,uploading:x,failed:R,blocked:x||R,s3Keys:b.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[]),rejected:y,add:v,retry:w,remove:k,clear:C,dismissRejected:S}),[g.available,b,u,x,R,y,v,w,k,C,S])}var xa=6e3;function Ra(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 Ta(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 _a(e){switch(e){case"permissionDenied":return He.micBlocked;case"noSpeech":return He.noSpeech;case"unavailable":return He.dictationUnavailable}}function za(e,t,r){if(e)try{e.track(t,{...r})}catch{}}var Ia=["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 Pa(e={}){let t=/* @__PURE__ */new Set,r=[];for(let n of[e.name,e.breed,...Ia]){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 Fa(e,conversationId,t){let[r,l]=o({send:e,conversationId:conversationId,text:t??"",seeded:t??null}),i=r.send===e&&(r.conversationId===null||r.conversationId===conversationId);a(()=>{l(r=>{let n=r.send===e&&(r.conversationId===null||r.conversationId===conversationId),l=n?r.text:"",i=n?r.seeded:null,o=t!=null&&t!==i&&l.length===0;return{send:e,conversationId:conversationId,text:o?t:l,seeded:o?t:i}})},[e,conversationId,t]);let s=n(t=>l(r=>({send:e,conversationId:conversationId,text:t,seeded:r.seeded})),[e,conversationId]);return[i?r.text:"",s]}function La(e,conversationId,t,r,n=false){let l=i({draft:t,setDraft:r});l.current={draft:t,setDraft:r};let s=i(null),[u,d]=o(null);a(()=>{if(e===void 0)return;let t=`${conversationId??""}`;if(s.current===t)return;s.current=t;let r=true;return(async()=>{let n=await Qr(()=>e.read(conversationId));if(!r)return;let i=n.ok&&typeof n.value=="string"?n.value:"";i.length>0&&l.current.draft.length===0&&l.current.setDraft(i),d(t)})(),()=>{r=false}},[e,conversationId]),a(()=>{e===void 0||n||u!==`${conversationId??""}`||Gr(()=>e.write(conversationId,t))},[e,conversationId,t,u,n])}function Ea(e){if(!(b.OS!=="ios"||e===""))try{let t=I?.announceForAccessibility;typeof t=="function"&&t.call(I,e)}catch{}}function AnnounceLine({line:e}){return a(()=>{Ea(e)},[e]),null}var Oa=12,Aa=80,ja=44,Da=22,Ma=.14,Ba=18,Ha=8,Wa=/* @__PURE__ */Object.freeze({photo:He.attachmentPhoto,camera:He.attachmentCamera});function AttachmentPickerPopover({sources:e,full:t,onPick:r,onClose:n}){let i=useEverfurTheme(),o=l(()=>Na(i),[i]);/* @__PURE__ */
88
+ /* @__PURE__ */A(v,{style:{position:"absolute",top:i-n/2,left:i-n/2,width:e*.15+n/2,height:n,borderRadius:n,backgroundColor:t}})]})}var mo=/* @__PURE__ */Object.freeze({standard:se.standard,emphasized:se.emphasized,exit:se.exit,outQuad:/* @__PURE__ */Object.freeze([.25,.46,.45,.94]),out:/* @__PURE__ */Object.freeze([.23,1,.32,1])});var vo=/* @__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}),wo=/* @__PURE__ */Object.freeze({...vo,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 ko(e){return e.motion.reducedMotion?wo:vo}function Co(e,t){return Math.max(0,t)*e.followUpStaggerMs}function So(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 xo(){let e=useEverfurTheme();return ko(e)}var Ro=8;function To(e,t,r){return((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}function _o(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}function zo(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<Ro;r+=1){let r=_o(i,t,n);if(r===0)break;i-=(To(i,t,n)-e)/r}return To(Math.min(1,Math.max(0,i)),r,l)}}var Io=zo(mo.standard),Po=zo(mo.outQuad),Fo=zo(mo.out);function Lo(e){let t=i(null);return t.current===null&&(t.current=new L.Value(e)),t.current}function Eo(e,t={}){let r=t.risePx??0,n=t.delayMs??0,i=Lo(e>0?0:1);return a(()=>{if(e<=0){i.setValue(1);return}let t=L.timing(i,{toValue:1,duration:e,easing:Po,useNativeDriver:true}),r=n>0?L.sequence([L.delay(n),t]):t;return r.start(),()=>r.stop()},[i,e,n]),l(()=>({opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[i,r])}function FadePresence({visible:e,inMs:t,outMs:r,style:n,children:l}){let[i,s]=o(e),u=Lo(e&&t<=0?1:0);return a(()=>{if(e){s(true);let e=L.timing(u,{toValue:1,duration:Math.max(0,t),easing:Io,useNativeDriver:true});return e.start(),()=>e.stop()}if(!i)return;if(r<=0){s(false);return}let n=L.timing(u,{toValue:0,duration:r,easing:Io,useNativeDriver:true});return n.start(({finished:e})=>{e&&s(false)}),()=>n.stop()},[e,i,t,r,u]),!i&&!e?null:/* @__PURE__ */A(L.View,{style:[n,{opacity:u}],children:l})}var Oo=/* @__PURE__ */Object.freeze({opacity:1,transform:/* @__PURE__ */Object.freeze([{translateY:0},{scale:1}])});function Ao(e,t){let[r]=o(()=>e?t.bubbleInMs:0),n=r>0,i=Lo(n?0:1);a(()=>{if(r<=0)return;let e=L.timing(i,{toValue:1,duration:r,easing:Fo,useNativeDriver:true});return e.start(),()=>e.stop()},[r,i]);let s=t.bubbleFromScale,u=t.bubbleRisePx;return l(()=>n?{opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[u,0]})},{scale:i.interpolate({inputRange:[0,1],outputRange:[s,1]})}]}:Oo,[n,i,u,s])}function jo(e){let t=i(null),r=i(null),l=e[0]?.id??null;if(t.current===null||r.current!==l){let n=t.current===null;t.current=new Map(e.map(e=>[e.id,n&&e.pending===true])),r.current=l}let o=t.current;for(let t of e)o.has(t.id)||o.set(t.id,true);return n(e=>o.get(e)===true,[o])}var Do=12;function PressScale({style:e,containerStyle:t,children:r,onPressIn:l,onPressOut:i,hitSlop:o,...a}){let s=xo(),u=Lo(1),d=n(e=>{s.pressMs<=0||s.pressScale===1||L.timing(u,{toValue:e,duration:s.pressMs,easing:Io,useNativeDriver:true}).start()},[u,s.pressMs,s.pressScale]);/* @__PURE__ */
89
+ return A(C,{...a,hitSlop:o??Do,style:t,onPressIn:e=>{d(s.pressScale),l?.(e)},onPressOut:e=>{d(1),i?.(e)},children:/* @__PURE__ */A(L.View,{style:[e,{transform:[{scale:u}]}],children:r})})}function Mo(e,t,r){let n=t&&r.revealTickMs>0,[l,s]=o(0),u=i(e);return u.current=e,a(()=>{if(!n)return;let e=setInterval(()=>{s(e=>So(r,e,u.current.length))},r.revealTickMs);return()=>clearInterval(e)},[n,r]),n?e.slice(0,Math.min(l,e.length)):e}var Bo=false;function Ho(e){e.layoutMs<=0||(Bo||(Bo=true,b.OS==="android"&&typeof P.setLayoutAnimationEnabledExperimental=="function"&&P.setLayoutAnimationEnabledExperimental(true)),F.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}))}function Wo(e,t){let r=i(e);r.current!==e&&(r.current=e,Ho(t))}var No=36,Uo=22,$o=12,Vo=12,qo=16,Go="#000",Ko="rgba(0,0,0,0.45)";function AttachmentImageLightbox({uri:e,label:t,onClose:r}){let n=useEverfurTheme(),l=M();return e===null?null:/* @__PURE__ */j(R,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[
90
+ /* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Ne.closePreview,style:Yo.backdrop,onPress:r,children:/* @__PURE__ */A(z,{source:{uri:e},style:Yo.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),
91
+ /* @__PURE__ */A(v,{pointerEvents:"box-none",style:[Yo.closeWrap,{top:l.top+Vo}],children:/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Ne.closePreview,hitSlop:$o,style:Yo.closeButton,onPress:r,children:/* @__PURE__ */A(CloseGlyph,{size:Uo,color:n.color.surface,strokeWidth:2})})})]})}var Yo=g.create({backdrop:{flex:1,backgroundColor:Go,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:qo},closeButton:{width:No,height:No,borderRadius:No/2,backgroundColor:Ko,alignItems:"center",justifyContent:"center"}});var Qo=()=>{};function Zo(){try{return y.currentState==="active"}catch{return false}}function createAppStateLifecycle(){return{onForeground(e){let t;try{let r=y.currentState==="background";t=y.addEventListener("change",t=>{t==="background"?r=!0:t==="active"&&r&&(r=!1,e())})}catch{return Qo}return()=>t.remove()},isVisible:Zo}}function Jo(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 Xo(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}function ea(e){return e?.textColor===void 0?{}:{color:e.textColor}}var ta=/* @__PURE__ */Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function ra(e){return e!==ta}var na=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function la(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 ia=4e3;var oa=4e3;var aa=/* @__PURE__ */Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var sa=10*1024*1024,ua=5,da=120,ca="/widget/v1/uploads/initiate";function isAttachmentMime(e){return typeof e=="string"&&aa.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<=da)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,da);let n=t.slice(r);return n.length>=da?t.slice(0,da):`${t.slice(0,r).slice(0,da-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 pa=e=>/* @__PURE__ */Object.freeze({ok:true,value:e}),fa=e=>/* @__PURE__ */Object.freeze({ok:false,error:e});function ha(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 fa(ha("unsupported_type",false,t));let n=attachmentSize(e);return n===null?fa(ha("unknown",false,t)):n>sa?fa(ha("too_large",false,t,{sizeBytes:n})):pa(/* @__PURE__ */Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}function ga(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)??sa,s3_key:o,purpose:r(t.purpose)})}function ba(e,t){let r=e.httpStatus;switch(e.code){case"quotaExceeded":return ha("quota_exceeded",false,t,{cause:e});case"rateLimited":return ha("rate_limited",true,t,{cause:e});case"idempotencyConflict":case"idempotencyInFlight":return ha("idempotency_conflict",true,t,{cause:e});case"validationFailed":return ha("unsupported_type",false,t,{cause:e});case"serviceUnavailable":case"streamTimeout":return ha("network",true,t,{cause:e});default:return r===429?ha("rate_limited",true,t,{cause:e}):r===503?ha("network",true,t,{cause:e}):r===void 0?ha("network",true,t,{cause:e}):ha("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:ca,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return fa(ba(n.error,t.filename));let l=ga(n.value);return l===null?fa(ha("server",false,t.filename)):pa(l)}async function uploadAttachmentBytes(e,t,r,n){let l=()=>n?.signal?.aborted===true;if(l())return fa(ha("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),pa(void 0)}catch{return l()?fa(ha("cancelled",true,r.filename)):fa(ha("server",true,r.filename))}}var ya=2,ma=3,va=/* @__PURE__ */Object.freeze([1e3,2e3,4e3]),wa=0;function ka(){return wa+=1,`attachment-${wa}`}function createAttachmentQueue(e){let t=Math.max(1,e.concurrency??ya),r=Math.max(1,e.maxAttempts??ma),n=e.backoffMs??va,l=Math.max(1,e.maxPerMessage??ua),i=e.timers??na,o=e.newId??ka,a=ra(e.transport),s=/* @__PURE__ */new Map,u=[],d=[],c=/* @__PURE__ */new Set,p=/* @__PURE__ */new Set,f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])}),h=false,g=()=>{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()},b=(e,t)=>{e.state=/* @__PURE__ */Object.freeze({...e.state,...t}),g()},y=()=>{for(;!h&&c.size<t&&d.length>0;){let e=d.shift(),t=s.get(e);t!==void 0&&(c.add(e),m(t).finally(()=>{c.delete(e),y()}))}},m=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;b(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=fa(a.error);else{let r=await uploadAttachmentBytes(e.transport,a.value,l,{signal:o,onProgress:e=>{!o.aborted&&t.state.status==="uploading"&&b(t,{progress:Ca(e)})}});if(h||o.aborted)return;s=r.ok?pa(a.value.s3_key):fa(r.error)}if(s.ok){b(t,{status:"uploaded",s3Key:s.value,error:null,progress:1});return}let u=s.error,d=u.retryable&&t.attempts<r;if(b(t,{status:d?"uploading":"failed",error:u,progress:0}),!d)return;let c=n[Math.min(t.attempts-1,n.length-1)]??0;await la(c,o,i)}},v=e=>{d.push(e.state.id),y()},w={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 fa(ha("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),g(),v(n),pa(n.state)},retry(e){let t=s.get(e);t===void 0||h||t.state.status!=="failed"||(t.controller=new AbortController,t.attempts=0,b(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=d.indexOf(e);n>=0&&d.splice(n,1),g()},clear(){for(let e of[...u])w.remove(e)},dispose(){h=true;for(let e of s.values())e.controller.abort();s.clear(),u.length=0,d.length=0,p.clear(),f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])})}};return w}function Ca(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function Sa(e){switch(e.code){case"too_large":return Ue(Ne.attachmentTooLarge,{max:formatBytes(sa),filename:e.filename,size:formatBytes(e.sizeBytes??0)});case"too_many":return Ue(Ne.attachmentTooMany,{max:ua});case"unsupported_type":return Ue(Ne.attachmentUnsupported,{filename:e.filename});case"network":return Ne.attachmentNetwork;case"server":return Ue(Ne.attachmentServer,{status:""});case"cancelled":return Ne.attachmentCancelled;case"rate_limited":return Ne.attachmentRateLimited;case"quota_exceeded":return Ne.attachmentQuota;case"idempotency_conflict":return Ne.attachmentConflict;case"unknown":return Ne.attachmentUnknown}}function xa(e,t){return Ue(e>=t?Ne.attachmentsFull:Ne.addAttachment,{used:e,total:t})}var Ra=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])});function useChatAttachments(e={}){let{runtime:t,userRef:userRef,scopeEpoch:r}=Ze(),u=e.maxPerMessage??ua,d=n(()=>{let{services:r}=t.registry;return createAttachmentQueue({funnel:createRequestFunnel({auth:r.authFor(userRef),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),transport:e.transport??r.uploadTransport,maxPerMessage:u})},[t,userRef,r,u,e.transport]),c=l(()=>e.queue??d(),[e.queue,d]),p=i(/* @__PURE__ */new WeakSet),[f,h]=o(null),g=f!==null&&f.of===c?f.queue:c;a(()=>{if(g!==e.queue){if(p.current.has(g)){h({of:c,queue:d()});return}return()=>{g.dispose(),p.current.add(g)}}},[g,c,d,e.queue]);let b=s(g.subscribe,g.getSnapshot,()=>Ra),[y,m]=o(null),v=n(e=>{let t=(Array.isArray(e)?e:[e]).map(e=>g.add(e)),r=t.find(e=>!e.ok);return r!==void 0&&!r.ok&&m(r.error),t},[g,m]),w=n(e=>g.retry(e),[g]),k=n(e=>g.remove(e),[g]),C=n(()=>g.clear(),[g]),S=n(()=>m(null),[m]),x=b.attachments.some(e=>e.status==="uploading"),R=b.attachments.some(e=>e.status==="failed");return l(()=>({available:g.available,attachments:b.attachments,maxPerMessage:u,uploading:x,failed:R,blocked:x||R,s3Keys:b.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[]),rejected:y,add:v,retry:w,remove:k,clear:C,dismissRejected:S}),[g.available,b,u,x,R,y,v,w,k,C,S])}var Ta=6e3;function _a(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 za(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 Ia(e){switch(e){case"permissionDenied":return Ne.micBlocked;case"noSpeech":return Ne.noSpeech;case"unavailable":return Ne.dictationUnavailable}}function Pa(e,t,r){if(e)try{e.track(t,{...r})}catch{}}var Fa=["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 La(e={}){let t=/* @__PURE__ */new Set,r=[];for(let n of[e.name,e.breed,...Fa]){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 Ea(e,conversationId,t){let[r,l]=o({send:e,conversationId:conversationId,text:t??"",seeded:t??null}),i=r.send===e&&(r.conversationId===null||r.conversationId===conversationId);a(()=>{l(r=>{let n=r.send===e&&(r.conversationId===null||r.conversationId===conversationId),l=n?r.text:"",i=n?r.seeded:null,o=t!=null&&t!==i&&l.length===0;return{send:e,conversationId:conversationId,text:o?t:l,seeded:o?t:i}})},[e,conversationId,t]);let s=n(t=>l(r=>({send:e,conversationId:conversationId,text:t,seeded:r.seeded})),[e,conversationId]);return[i?r.text:"",s]}function Oa(e,conversationId,t,r,n=false){let l=i({draft:t,setDraft:r});l.current={draft:t,setDraft:r};let s=i(null),[u,d]=o(null);a(()=>{if(e===void 0)return;let t=`${conversationId??""}`;if(s.current===t)return;s.current=t;let r=true;return(async()=>{let n=await Jr(()=>e.read(conversationId));if(!r)return;let i=n.ok&&typeof n.value=="string"?n.value:"";i.length>0&&l.current.draft.length===0&&l.current.setDraft(i),d(t)})(),()=>{r=false}},[e,conversationId]),a(()=>{e===void 0||n||u!==`${conversationId??""}`||Yr(()=>e.write(conversationId,t))},[e,conversationId,t,u,n])}function Aa(e){if(!(b.OS!=="ios"||e===""))try{let t=I?.announceForAccessibility;typeof t=="function"&&t.call(I,e)}catch{}}function AnnounceLine({line:e}){return a(()=>{Aa(e)},[e]),null}var ja=12,Da=80,Ma=44,Ba=22,Ha=.14,Wa=18,Na=8,Ua=/* @__PURE__ */Object.freeze({photo:Ne.attachmentPhoto,camera:Ne.attachmentCamera});function AttachmentPickerPopover({sources:e,full:t,onPick:r,onClose:n}){let i=useEverfurTheme(),o=l(()=>$a(i),[i]);/* @__PURE__ */
93
94
  return j(v,{style:o.anchor,pointerEvents:"box-none",children:[
94
- /* @__PURE__ */A(C,{style:o.dismissLayer,accessibilityRole:"button",accessibilityLabel:He.closeAttachmentPicker,onPress:n}),
95
+ /* @__PURE__ */A(C,{style:o.dismissLayer,accessibilityRole:"button",accessibilityLabel:Ne.closeAttachmentPicker,onPress:n}),
95
96
  /* @__PURE__ */j(v,{style:o.bubble,children:[
96
- /* @__PURE__ */A(v,{style:o.tilesRow,children:e.map(e=>/* @__PURE__ */j(PressScale,{accessibilityRole:"button",accessibilityLabel:Wa[e],accessibilityState:{disabled:t},disabled:t,containerStyle:o.tile,style:o.tileInner,onPress:()=>r(e),children:[
97
- /* @__PURE__ */A(v,{style:o.tileIconWrap,children:e==="photo"?/* @__PURE__ */A(PhotoGlyph,{size:Da,color:i.color.brandInk,strokeWidth:1.5}):/* @__PURE__ */A(CameraGlyph,{size:Da,color:i.color.brandInk,strokeWidth:1.5})}),
98
- /* @__PURE__ */A(Text,{tier:"control",style:o.tileLabel,children:Wa[e]})]},e))}),
97
+ /* @__PURE__ */A(v,{style:o.tilesRow,children:e.map(e=>/* @__PURE__ */j(PressScale,{accessibilityRole:"button",accessibilityLabel:Ua[e],accessibilityState:{disabled:t},disabled:t,containerStyle:o.tile,style:o.tileInner,onPress:()=>r(e),children:[
98
+ /* @__PURE__ */A(v,{style:o.tileIconWrap,children:e==="photo"?/* @__PURE__ */A(PhotoGlyph,{size:Ba,color:i.color.brandInk,strokeWidth:1.5}):/* @__PURE__ */A(CameraGlyph,{size:Ba,color:i.color.brandInk,strokeWidth:1.5})}),
99
+ /* @__PURE__ */A(Text,{tier:"control",style:o.tileLabel,children:Ua[e]})]},e))}),
99
100
  /* @__PURE__ */A(v,{style:o.tail}),
100
- /* @__PURE__ */A(v,{style:o.tailFill})]})]})}function Na(e){let t=e.color,r=e.radius;return g.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:Ma,shadowRadius:Ba,shadowOffset:{width:0,height:Ha},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:Aa,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:ja,height:ja,borderRadius:ja/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:-Oa/2,width:Oa,height:Oa,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:Oa+4,height:2,backgroundColor:t.surfaceCream}})}function parseColor(e){let t=Ua(e);return t===null?null:Qa(t)}function Ua(e){if(typeof e=="number")return qa(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return $a(t.slice(1));if(t.toLowerCase().startsWith("0x"))return $a(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Va(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=$a(t);if(e!==null)return e}return/^\d+$/.test(t)?qa(Number.parseInt(t,10)):null}function $a(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:Ka(t[0]),g:Ka(t[1]),b:Ka(t[2]),a:1};if(t.length===6)return{r:Ga(t,0),g:Ga(t,2),b:Ga(t,4),a:1};if(t.length===8){let e=Ga(t,0);return{r:Ga(t,2),g:Ga(t,4),b:Ga(t,6),a:e/255}}return null}function Va(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=Ya(Number(n[0])),i=Ya(Number(n[1])),o=Ya(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 qa(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 Ga(e,t){return Number.parseInt(e.slice(t,t+2),16)}function Ka(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function Ya(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function Qa(e){if(e.a>=1)return Za(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return`rgba(${e.r},${e.g},${e.b},${t})`}function Za(e,t,r){return`#${Ja(e)}${Ja(t)}${Ja(r)}`.toUpperCase()}function Ja(e){return e.toString(16).padStart(2,"0")}var Xa="#111111",es="#FFFFFF",ts="#000000";function readableOn(e){let t=Ua(e);if(t===null)return es;let r=ls(t),n=ls({r:17,g:17,b:17}),l=ls({r:255,g:255,b:255});return os(r,l)>=os(r,n)?es:Xa}function rs(e,t){let r=readableOn(e);return contrastRatio(r,e)>=t?r:contrastRatio(es,e)>=contrastRatio(ts,e)?es:ts}function ns(e){let t=t=>e.reduce((e,r)=>Math.min(e,contrastRatio(t,r)),Number.POSITIVE_INFINITY);return t(es)>=t(ts)?es:ts}function ls(e){let t=is(e.r/255),r=is(e.g/255),n=is(e.b/255);return.2126*t+.7152*r+.0722*n}function is(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function os(e,t){let r=Math.max(e,t),n=Math.min(e,t);return(r+.05)/(n+.05)}function contrastRatio(e,t){let r=Ua(e),n=Ua(t);if(r===null||n===null)return 1;let l=n.a>=1?n:{...n},i=r.a>=1?r:as(r,l);return os(ls(i),ls(l))}function as(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 ss(e,t){let r=Ua(e),n=Ua(t);if(r===null||n===null)return null;let l=r.a>=1?r:as(r,{...n});return Za(l.r,l.g,l.b)}function us(e,t){let r=Ua(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 ds=.05;function cs(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(Ua(e)===null)return r;if(i(e))return e;let o=ss(e,l),a=o===null?null:Ua(o),s=Ua(r);if(a===null||s===null)return r;for(let e=1;e<1/ds;e+=1){let t=e*ds,r=(e,r)=>Math.round(e+(r-e)*t),n=Za(r(a.r,s.r),r(a.g,s.g),r(a.b,s.b));if(i(n))return n}return r}var ps=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var fs=56,hs=12,gs=14,bs=10,ys=.45,ms="rgba(7,193,104,0.55)",vs="rgba(185,28,28,0.55)",ws=200,ks=300,Cs=20,Ss=22,xs=12,Rs="rgba(0,0,0,0.78)",Ts=220,_s=100,zs="rgba(255,255,255,0.15)";function AttachmentStrip({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:i,onPreview:o,style:a}){let s=useEverfurTheme(),u=l(()=>Is(s),[s]);return e.length===0&&t===null?null:/* @__PURE__ */j(v,{style:[u.strip,a],children:[e.length>0?/* @__PURE__ */A(v,{style:u.cards,children:e.map(e=>/* @__PURE__ */A(PreviewCard,{row:e,styles:u,onRetry:n,onRemove:i,onPreview:o},e.id))}):null,r?/* @__PURE__ */A(Text,{style:u.rejected,accessibilityRole:"alert",children:He.attachmentsFailedBlocked}):null,t!==null?/* @__PURE__ */A(Text,{style:u.rejected,accessibilityRole:"alert",children:ka(t)}):null]})}function PreviewCard({row:e,styles:t,onRetry:r,onRemove:n,onPreview:l}){let s=useEverfurTheme(),u=e.status==="uploading",d=e.status==="failed",c=e.status==="uploaded",p=i(e.status),[f,h]=o(false);return a(()=>{let t=p.current;p.current=e.status,e.status==="uploaded"&&t==="uploading"&&h(true)},[e.status]),/* @__PURE__ */j(v,{style:t.card,children:[
101
- /* @__PURE__ */A(C,{accessibilityRole:c?"button":"image",accessibilityLabel:c?We(He.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:u,disabled:!c},disabled:!c,style:t.thumbHit,onPress:()=>l(e),children:/* @__PURE__ */j(v,{style:t.thumb,children:[
102
- /* @__PURE__ */A(z,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),u?/* @__PURE__ */A(v,{style:t.uploadingOverlay,children:/* @__PURE__ */A(_,{size:"small",color:s.color.surface})}):null,f?/* @__PURE__ */A(SuccessFlash,{styles:t,onDone:()=>h(false)}):null]})}),d?/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:We(He.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:/* @__PURE__ */A(v,{style:t.failedInner,children:/* @__PURE__ */A(CloseGlyph,{size:Cs,color:s.color.surface,strokeWidth:2})})}):null,
103
- /* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:We(He.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:/* @__PURE__ */A(CloseGlyph,{size:xs,color:s.color.surface,strokeWidth:1.5})})]})}function SuccessFlash({styles:e,onDone:t}){let r=useEverfurTheme(),n=Co(),l=i(null);l.current===null&&(l.current=new L.Value(0));let o=l.current;return a(()=>{let e=L.sequence([L.timing(o,{toValue:1,duration:ws,useNativeDriver:true}),L.delay(n.uploadFlashMs),L.timing(o,{toValue:0,duration:ks,useNativeDriver:true})]);return e.start(({finished:e})=>{e&&t()}),()=>e.stop()},[o,n.uploadFlashMs,t]),/* @__PURE__ */A(L.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:o}],children:/* @__PURE__ */A(CheckGlyph,{size:Cs,color:r.color.surface,strokeWidth:2})})}function SentImages({images:e,onPreview:t}){let r=useEverfurTheme(),n=l(()=>Is(r),[r]);if(e.length===0)return null;let i=e.length===1;/* @__PURE__ */
104
- return A(v,{style:i?n.sentSingle:n.sentGrid,children:e.map((e,r)=>/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:We(He.attachedImage,{filename:e.filename}),onPress:()=>t(e),children:/* @__PURE__ */A(z,{source:{uri:e.uri},style:i?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${e.uri}-${r}`))})}function Is(e){let t=e.color,r=e.type;return g.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:fs,height:fs,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:hs,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:g.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...ps,alignItems:"center",justifyContent:"center",backgroundColor:us(e.color.brandInk,ys)??e.color.brandSofter},successOverlay:{...ps,alignItems:"center",justifyContent:"center",backgroundColor:ms},failedOverlay:{...ps,borderRadius:hs,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:vs},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:Ss,height:Ss,borderRadius:Ss/2,backgroundColor:Rs,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:Ts,height:Ts,borderRadius:gs,backgroundColor:zs},gridImage:{width:_s,height:_s,borderRadius:bs,backgroundColor:zs}})}var Ps="file",Fs="multipart upload failed";function Ls(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(Ps,e.file)}catch{return Promise.reject(new Error(Fs))}return e.fetch!==void 0?As(e.fetch,e.url,t,e.signal):Os(e.url,t,e.signal)}function Es(e){return e>=200&&e<300}function Os(e,t,r){return new Promise((n,l)=>{let i=globalThis.XMLHttpRequest;if(typeof i!="function"||r?.aborted===true){l(new Error(Fs));return}let o=null,a=()=>{o!==null&&r?.removeEventListener("abort",o)},s=()=>{a(),l(new Error(Fs))};try{let l=new i;l.open("POST",e),l.withCredentials=!1,l.onload=()=>{a(),n(Es(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 As(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(e=>e.ok)}var js="chat attachment upload: the file handle has no uri",Ds="chat attachment upload failed";function Ms(e){return{uri:e.uri,name:sanitizeFilename(e.name),type:e.mimeType}}function createRnChatAttachmentTransport(e={}){/* @__PURE__ */
105
- return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(js));let{signal:l,onProgress:i}=n,o=()=>Promise.reject(new Error(Ds));return l?.aborted===true?o():Ls({url:t.upload_url,fields:t.upload_fields,file:Ms(r),signal:l,fetch:e.fetch}).then(e=>{if(!e)return o();i?.(1)},o)}})}var Bs=300,Hs=3e3,Ws=120,Ns=44,Us=120,$s="88%",Vs=520,qs=2,Gs=.5,Ks=1.5,Ys=1.6,Qs=.6,Zs=56,Js=1.5,Xs=5,eu=5,tu=36,ru=20,nu=14,lu=Ns,iu=4,ou=24,au=22,su=.4,uu=Ns,du=20,cu=.4,pu=480,fu=12,hu=.72,gu=48,bu=1.5,yu=1.3,mu=1,vu=1,wu="12%",ku=14,Cu=16,Su=28,xu=18,Ru="84%",Tu=10,_u=15,zu=1.42,Iu=4,Pu=3,Fu=14,Lu=20;function Eu(){let e=useEverfurTheme(),t=l(()=>Ou(e),[e]);return{theme:e,styles:t}}function Ou(e){let t=e.color,r=e.space,n=e.radius,l=e.type,i=Math.round(l.size.body*Ks),o=Math.round(l.size.body*Ys),a=Math.round(ru*l.size.body/nu),s=t.borderRingCream,u=e.slots;return g.create({container:{flex:1,minHeight:Ws,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:Ws,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},homeEmpty:{flexGrow:1},emptyContent:{flexGrow:1,alignItems:"stretch",justifyContent:"flex-start",paddingTop:wu,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:pu,gap:r.lg},errorText:{...face(e,"regular"),fontSize:l.size.subtitle,lineHeight:l.size.subtitle*l.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:Ns,minWidth:Ns,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...Qo(u.primaryButton)},retryLabel:{...face(e,"medium"),color:t.onPrimary,fontSize:l.size.body,...Jo(u.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:l.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,borderWidth:vu,borderColor:t.borderRingCream,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.bodyTight},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal},turnNoticeAction:{minHeight:Ns,justifyContent:"center"},turnNoticeActionLabel:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight},setupNoticeAction:{...face(e,"medium"),color:t.brandInk,fontSize:l.size.caption},reconnectingCaption:{...face(e,"medium"),color:t.text.secondary,fontSize:l.size.caption,lineHeight:l.size.caption*l.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:n.md},readingDot:{width:6,height:6,borderRadius:n.pill,backgroundColor:t.brandInk},readingInline:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:Pu,minHeight:Fu},readingDotInline:{width:Iu,height:Iu,borderRadius:n.pill,backgroundColor:t.text.muted},list:{flex:1},earlierButton:{alignSelf:"center",minHeight:Ns,justifyContent:"center",paddingHorizontal:r.md+r.xs/2},earlierLabel:{...face(e,"monoBold"),color:t.linkInk,fontSize:l.size.caption},listContent:{padding:r.lg,gap:r.xl},listContentCards:{paddingTop:ku,paddingHorizontal:Cu,paddingBottom:Su,gap:xu},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:$s,alignItems:"flex-start"},bubbleSideUser:{alignItems:"flex-end"},bubbleUser:{maxWidth:Vs,paddingVertical:r.md,paddingHorizontal:r.lg+qs,backgroundColor:t.bubbleUser,...t.primaryEdge!==t.primary&&t.bubbleUser===t.primary?{borderWidth:Gs,borderColor:t.primaryEdge}:{},borderRadius:n.lg,borderBottomRightRadius:n.xs,...Qo(u.userBubble,Gs)},bubbleAssistant:u.assistantBubble?.backgroundColor===void 0?{...Qo(u.assistantBubble,Gs)}:{paddingVertical:r.md,paddingHorizontal:r.lg+qs,borderRadius:n.lg,...Qo(u.assistantBubble,Gs)},bubbleVet:{maxWidth:Vs,paddingVertical:r.md,paddingHorizontal:r.lg+qs,backgroundColor:t.bubbleVet,borderRadius:n.lg,borderTopLeftRadius:n.xs,...Qo(u.vetBubble,Gs)},bubbleCards:{maxWidth:Ru},bubbleUserCards:{paddingVertical:Tu,paddingHorizontal:_u},bubbleTextUserCards:{fontSize:textRole(e,"message").fontSize,lineHeight:Math.round(textRole(e,"message").fontSize*zu)},bubblePending:{opacity:Qs},bubbleTextUser:{...face(e,"regular"),color:t.onPrimary,fontSize:l.size.body,lineHeight:i,...Jo(u.userBubble)},bubbleTextAssistant:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:o,...Jo(u.assistantBubble)},bubbleTextVet:{...face(e,"regular"),color:t.onBubbleVet,fontSize:l.size.body,lineHeight:i,...Jo(u.vetBubble)},assistantName:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight,marginBottom:r.xs},assistantSender:{flexDirection:"row",alignItems:"center",gap:r.sm,marginBottom:r.xs},assistantAvatar:{width:Lu,height:Lu,borderRadius:Lu/2},assistantNameInRow:{marginBottom:0},vetHeader:{flexDirection:"row",alignItems:"baseline",gap:r.sm,marginBottom:r.xs},vetSender:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.bodyTight},vetTime:{...face(e,"regular"),color:t.text.muted,fontSize:l.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:fu,textTransform:"uppercase",letterSpacing:hu,paddingBottom:r.sm,borderBottomWidth:mu,borderBottomColor:s},followUpSlot:{alignSelf:"stretch"},followUpSlotRuled:{borderTopWidth:mu,borderTopColor:s},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,minHeight:gu,paddingVertical:r.sm+qs,...u.chip?.backgroundColor!==void 0||u.chip?.borderColor!==void 0?{paddingHorizontal:r.md}:{},...Qo(u.chip)},followUpText:{...face(e,"bold"),flex:1,color:t.brandInk,fontSize:l.size.bodyTight,...Jo(u.chip)},askChips:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,marginTop:r.md},askChip:{minHeight:Ns,maxWidth:"100%",justifyContent:"center",paddingVertical:r.sm,paddingHorizontal:r.lg,borderRadius:n.pill,borderWidth:bu,borderColor:t.brandInk,backgroundColor:t.chatGround,...Qo(u.chip,bu)},askChipText:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*yu),...Jo(u.chip)},composerOuter:{position:"relative"},askEntry:{marginHorizontal:r.md,marginTop:r.xs},composer:{marginHorizontal:r.md,marginTop:r.xs,minHeight:Zs,justifyContent:"center",paddingLeft:r.sm,paddingRight:Xs,paddingVertical:eu,backgroundColor:t.composerFill,borderWidth:Js,borderColor:t.composerBorder,borderRadius:n.pill,...Qo(u.composerInput,Js)},composerRow:{flexDirection:"row",alignItems:"center",gap:r.xs,minHeight:tu},dictationError:{...face(e,"regular"),fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal,color:t.danger,paddingHorizontal:r.xs},attachControl:{width:uu,height:uu,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:cu},input:{flex:1,minHeight:tu,maxHeight:Us,paddingHorizontal:0,paddingVertical:0,...face(e,"regular"),fontSize:l.size.body,lineHeight:a,color:t.text.primary,...Jo(u.composerInput)},sendControl:{minHeight:lu,minWidth:lu,alignItems:"center",justifyContent:"center"},sendDisc:{width:lu,height:lu,borderRadius:lu/2,alignItems:"center",justifyContent:"center",...Qo(u.sendButton)},sendControlDisabled:{opacity:su},poweredBy:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.micro,textAlign:"center",paddingBottom:r.xs}})}var Au=18,ju=28,Du=6,Mu=1200,Bu=.4,Hu=.4;function DictationButton({active:e,listening:t,elapsedMs:r,disabled:n=false,onToggle:i}){let o=useEverfurTheme(),s=l(()=>Wu(o),[o]);return a(()=>{if(t)try{I.announceForAccessibility(He.listening)}catch{}},[t]),/* @__PURE__ */j(v,{style:s.wrap,children:[t?/* @__PURE__ */A(Text,{style:s.timer,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",testID:"everfur-dictation-timer",children:Ta(r)}):null,
106
- /* @__PURE__ */A(C,{onPress:()=>i(),disabled:n,accessibilityRole:"button",accessibilityLabel:e?He.stopDictation:He.dictate,accessibilityState:{selected:e,disabled:n},style:[s.button,n?s.buttonDisabled:null],testID:"everfur-dictation-button",children:e?/* @__PURE__ */j(D,{children:[
101
+ /* @__PURE__ */A(v,{style:o.tailFill})]})]})}function $a(e){let t=e.color,r=e.radius;return g.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:Ha,shadowRadius:Wa,shadowOffset:{width:0,height:Na},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:Da,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:Ma,height:Ma,borderRadius:Ma/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:-ja/2,width:ja,height:ja,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:ja+4,height:2,backgroundColor:t.surfaceCream}})}function parseColor(e){let t=Va(e);return t===null?null:Ja(t)}function Va(e){if(typeof e=="number")return Ka(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return qa(t.slice(1));if(t.toLowerCase().startsWith("0x"))return qa(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Ga(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=qa(t);if(e!==null)return e}return/^\d+$/.test(t)?Ka(Number.parseInt(t,10)):null}function qa(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:Qa(t[0]),g:Qa(t[1]),b:Qa(t[2]),a:1};if(t.length===6)return{r:Ya(t,0),g:Ya(t,2),b:Ya(t,4),a:1};if(t.length===8){let e=Ya(t,0);return{r:Ya(t,2),g:Ya(t,4),b:Ya(t,6),a:e/255}}return null}function Ga(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=Za(Number(n[0])),i=Za(Number(n[1])),o=Za(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 Ka(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 Ya(e,t){return Number.parseInt(e.slice(t,t+2),16)}function Qa(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function Za(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function Ja(e){if(e.a>=1)return Xa(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return`rgba(${e.r},${e.g},${e.b},${t})`}function Xa(e,t,r){return`#${es(e)}${es(t)}${es(r)}`.toUpperCase()}function es(e){return e.toString(16).padStart(2,"0")}var ts="#111111",rs="#FFFFFF",ns="#000000";function readableOn(e){let t=Va(e);if(t===null)return rs;let r=os(t),n=os({r:17,g:17,b:17}),l=os({r:255,g:255,b:255});return ss(r,l)>=ss(r,n)?rs:ts}function ls(e,t){let r=readableOn(e);return contrastRatio(r,e)>=t?r:contrastRatio(rs,e)>=contrastRatio(ns,e)?rs:ns}function is(e){let t=t=>e.reduce((e,r)=>Math.min(e,contrastRatio(t,r)),Number.POSITIVE_INFINITY);return t(rs)>=t(ns)?rs:ns}function os(e){let t=as(e.r/255),r=as(e.g/255),n=as(e.b/255);return.2126*t+.7152*r+.0722*n}function as(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function ss(e,t){let r=Math.max(e,t),n=Math.min(e,t);return(r+.05)/(n+.05)}function contrastRatio(e,t){let r=Va(e),n=Va(t);if(r===null||n===null)return 1;let l=n.a>=1?n:{...n},i=r.a>=1?r:us(r,l);return ss(os(i),os(l))}function us(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 ds(e,t){let r=Va(e),n=Va(t);if(r===null||n===null)return null;let l=r.a>=1?r:us(r,{...n});return Xa(l.r,l.g,l.b)}function cs(e,t){let r=Va(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 ps=.05;function fs(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(Va(e)===null)return r;if(i(e))return e;let o=ds(e,l),a=o===null?null:Va(o),s=Va(r);if(a===null||s===null)return r;for(let e=1;e<1/ps;e+=1){let t=e*ps,r=(e,r)=>Math.round(e+(r-e)*t),n=Xa(r(a.r,s.r),r(a.g,s.g),r(a.b,s.b));if(i(n))return n}return r}var hs=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var gs=56,bs=12,ys=14,ms=10,vs=.45,ws="rgba(7,193,104,0.55)",ks="rgba(185,28,28,0.55)",Cs=200,Ss=300,xs=20,Rs=22,Ts=12,_s="rgba(0,0,0,0.78)",zs=220,Is=100,Ps="rgba(255,255,255,0.15)";function AttachmentStrip({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:i,onPreview:o,style:a}){let s=useEverfurTheme(),u=l(()=>Fs(s),[s]);return e.length===0&&t===null?null:/* @__PURE__ */j(v,{style:[u.strip,a],children:[e.length>0?/* @__PURE__ */A(v,{style:u.cards,children:e.map(e=>/* @__PURE__ */A(PreviewCard,{row:e,styles:u,onRetry:n,onRemove:i,onPreview:o},e.id))}):null,r?/* @__PURE__ */A(Text,{style:u.rejected,accessibilityRole:"alert",children:Ne.attachmentsFailedBlocked}):null,t!==null?/* @__PURE__ */A(Text,{style:u.rejected,accessibilityRole:"alert",children:Sa(t)}):null]})}function PreviewCard({row:e,styles:t,onRetry:r,onRemove:n,onPreview:l}){let s=useEverfurTheme(),u=e.status==="uploading",d=e.status==="failed",c=e.status==="uploaded",p=i(e.status),[f,h]=o(false);return a(()=>{let t=p.current;p.current=e.status,e.status==="uploaded"&&t==="uploading"&&h(true)},[e.status]),/* @__PURE__ */j(v,{style:t.card,children:[
102
+ /* @__PURE__ */A(C,{accessibilityRole:c?"button":"image",accessibilityLabel:c?Ue(Ne.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:u,disabled:!c},disabled:!c,style:t.thumbHit,onPress:()=>l(e),children:/* @__PURE__ */j(v,{style:t.thumb,children:[
103
+ /* @__PURE__ */A(z,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),u?/* @__PURE__ */A(v,{style:t.uploadingOverlay,children:/* @__PURE__ */A(_,{size:"small",color:s.color.surface})}):null,f?/* @__PURE__ */A(SuccessFlash,{styles:t,onDone:()=>h(false)}):null]})}),d?/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Ue(Ne.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:/* @__PURE__ */A(v,{style:t.failedInner,children:/* @__PURE__ */A(CloseGlyph,{size:xs,color:s.color.surface,strokeWidth:2})})}):null,
104
+ /* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Ue(Ne.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:/* @__PURE__ */A(CloseGlyph,{size:Ts,color:s.color.surface,strokeWidth:1.5})})]})}function SuccessFlash({styles:e,onDone:t}){let r=useEverfurTheme(),n=xo(),l=i(null);l.current===null&&(l.current=new L.Value(0));let o=l.current;return a(()=>{let e=L.sequence([L.timing(o,{toValue:1,duration:Cs,useNativeDriver:true}),L.delay(n.uploadFlashMs),L.timing(o,{toValue:0,duration:Ss,useNativeDriver:true})]);return e.start(({finished:e})=>{e&&t()}),()=>e.stop()},[o,n.uploadFlashMs,t]),/* @__PURE__ */A(L.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:o}],children:/* @__PURE__ */A(CheckGlyph,{size:xs,color:r.color.surface,strokeWidth:2})})}function SentImages({images:e,onPreview:t}){let r=useEverfurTheme(),n=l(()=>Fs(r),[r]);if(e.length===0)return null;let i=e.length===1;/* @__PURE__ */
105
+ return A(v,{style:i?n.sentSingle:n.sentGrid,children:e.map((e,r)=>/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Ue(Ne.attachedImage,{filename:e.filename}),onPress:()=>t(e),children:/* @__PURE__ */A(z,{source:{uri:e.uri},style:i?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${e.uri}-${r}`))})}function Fs(e){let t=e.color,r=e.type;return g.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:gs,height:gs,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:bs,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:g.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...hs,alignItems:"center",justifyContent:"center",backgroundColor:cs(e.color.brandInk,vs)??e.color.brandSofter},successOverlay:{...hs,alignItems:"center",justifyContent:"center",backgroundColor:ws},failedOverlay:{...hs,borderRadius:bs,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:ks},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:Rs,height:Rs,borderRadius:Rs/2,backgroundColor:_s,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:zs,height:zs,borderRadius:ys,backgroundColor:Ps},gridImage:{width:Is,height:Is,borderRadius:ms,backgroundColor:Ps}})}var Ls="file",Es="multipart upload failed";function Os(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(Ls,e.file)}catch{return Promise.reject(new Error(Es))}return e.fetch!==void 0?Ds(e.fetch,e.url,t,e.signal):js(e.url,t,e.signal)}function As(e){return e>=200&&e<300}function js(e,t,r){return new Promise((n,l)=>{let i=globalThis.XMLHttpRequest;if(typeof i!="function"||r?.aborted===true){l(new Error(Es));return}let o=null,a=()=>{o!==null&&r?.removeEventListener("abort",o)},s=()=>{a(),l(new Error(Es))};try{let l=new i;l.open("POST",e),l.withCredentials=!1,l.onload=()=>{a(),n(As(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 Ds(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(e=>e.ok)}var Ms="chat attachment upload: the file handle has no uri",Bs="chat attachment upload failed";function Hs(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(Ms));let{signal:l,onProgress:i}=n,o=()=>Promise.reject(new Error(Bs));return l?.aborted===true?o():Os({url:t.upload_url,fields:t.upload_fields,file:Hs(r),signal:l,fetch:e.fetch}).then(e=>{if(!e)return o();i?.(1)},o)}})}var Ws=300,Ns=3e3,Us=120,$s=44,Vs=120,qs="88%",Gs=520,Ks=2,Ys=.5,Qs=1.5,Zs=1.6,Js=.6,Xs=56,eu=1.5,tu=5,ru=5,nu=36,lu=20,iu=14,ou=$s,au=4,su=24,uu=22,du=.4,cu=$s,pu=20,fu=.4,hu=480,gu=12,bu=.72,yu=48,mu=1.5,vu=1.3,wu=1,ku=1,Cu="12%",Su=14,xu=16,Ru=28,Tu=18,_u="84%",zu=10,Iu=15,Pu=1.42,Fu=4,Lu=3,Eu=14,Ou=20;function Au(){let e=useEverfurTheme(),t=l(()=>ju(e),[e]);return{theme:e,styles:t}}function ju(e){let t=e.color,r=e.space,n=e.radius,l=e.type,i=Math.round(l.size.body*Qs),o=Math.round(l.size.body*Zs),a=Math.round(lu*l.size.body/iu),s=t.borderRingCream,u=e.slots;return g.create({container:{flex:1,minHeight:Us,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:Us,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},homeEmpty:{flexGrow:1},emptyContent:{flexGrow:1,alignItems:"stretch",justifyContent:"flex-start",paddingTop:Cu,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:hu,gap:r.lg},errorText:{...face(e,"regular"),fontSize:l.size.subtitle,lineHeight:l.size.subtitle*l.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:$s,minWidth:$s,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...Jo(u.primaryButton)},retryLabel:{...face(e,"medium"),color:t.onPrimary,fontSize:l.size.body,...ea(u.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:l.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,borderWidth:ku,borderColor:t.borderRingCream,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.bodyTight},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal},turnNoticeAction:{minHeight:$s,justifyContent:"center"},turnNoticeActionLabel:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight},setupNoticeAction:{...face(e,"medium"),color:t.brandInk,fontSize:l.size.caption},reconnectingCaption:{...face(e,"medium"),color:t.text.secondary,fontSize:l.size.caption,lineHeight:l.size.caption*l.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:n.md},readingDot:{width:6,height:6,borderRadius:n.pill,backgroundColor:t.brandInk},readingInline:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:Lu,minHeight:Eu},readingDotInline:{width:Fu,height:Fu,borderRadius:n.pill,backgroundColor:t.text.muted},list:{flex:1},earlierButton:{alignSelf:"center",minHeight:$s,justifyContent:"center",paddingHorizontal:r.md+r.xs/2},earlierLabel:{...face(e,"monoBold"),color:t.linkInk,fontSize:l.size.caption},listContent:{padding:r.lg,gap:r.xl},listContentCards:{paddingTop:Su,paddingHorizontal:xu,paddingBottom:Ru,gap:Tu},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:qs,alignItems:"flex-start"},bubbleSideUser:{alignItems:"flex-end"},bubbleUser:{maxWidth:Gs,paddingVertical:r.md,paddingHorizontal:r.lg+Ks,backgroundColor:t.bubbleUser,...t.primaryEdge!==t.primary&&t.bubbleUser===t.primary?{borderWidth:Ys,borderColor:t.primaryEdge}:{},borderRadius:n.lg,borderBottomRightRadius:n.xs,...Jo(u.userBubble,Ys)},bubbleAssistant:u.assistantBubble?.backgroundColor===void 0?{...Jo(u.assistantBubble,Ys)}:{paddingVertical:r.md,paddingHorizontal:r.lg+Ks,borderRadius:n.lg,...Jo(u.assistantBubble,Ys)},bubbleVet:{maxWidth:Gs,paddingVertical:r.md,paddingHorizontal:r.lg+Ks,backgroundColor:t.bubbleVet,borderRadius:n.lg,borderTopLeftRadius:n.xs,...Jo(u.vetBubble,Ys)},bubbleCards:{maxWidth:_u},bubbleUserCards:{paddingVertical:zu,paddingHorizontal:Iu},bubbleTextUserCards:{fontSize:textRole(e,"message").fontSize,lineHeight:Math.round(textRole(e,"message").fontSize*Pu)},bubblePending:{opacity:Js},bubbleTextUser:{...face(e,"regular"),color:t.onPrimary,fontSize:l.size.body,lineHeight:i,...ea(u.userBubble)},bubbleTextAssistant:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:o,...ea(u.assistantBubble)},bubbleTextVet:{...face(e,"regular"),color:t.onBubbleVet,fontSize:l.size.body,lineHeight:i,...ea(u.vetBubble)},assistantName:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight,marginBottom:r.xs},assistantSender:{flexDirection:"row",alignItems:"center",gap:r.sm,marginBottom:r.xs},assistantAvatar:{width:Ou,height:Ou,borderRadius:Ou/2},assistantNameInRow:{marginBottom:0},vetHeader:{flexDirection:"row",alignItems:"baseline",gap:r.sm,marginBottom:r.xs},vetSender:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.bodyTight},vetTime:{...face(e,"regular"),color:t.text.muted,fontSize:l.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:gu,textTransform:"uppercase",letterSpacing:bu,paddingBottom:r.sm,borderBottomWidth:wu,borderBottomColor:s},followUpSlot:{alignSelf:"stretch"},followUpSlotRuled:{borderTopWidth:wu,borderTopColor:s},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,minHeight:yu,paddingVertical:r.sm+Ks,...u.chip?.backgroundColor!==void 0||u.chip?.borderColor!==void 0?{paddingHorizontal:r.md}:{},...Jo(u.chip)},followUpText:{...face(e,"bold"),flex:1,color:t.brandInk,fontSize:l.size.bodyTight,...ea(u.chip)},askChips:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,marginTop:r.md},askChip:{minHeight:$s,maxWidth:"100%",justifyContent:"center",paddingVertical:r.sm,paddingHorizontal:r.lg,borderRadius:n.pill,borderWidth:mu,borderColor:t.brandInk,backgroundColor:t.chatGround,...Jo(u.chip,mu)},askChipText:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*vu),...ea(u.chip)},composerOuter:{position:"relative"},askEntry:{marginHorizontal:r.md,marginTop:r.xs},composer:{marginHorizontal:r.md,marginTop:r.xs,minHeight:Xs,justifyContent:"center",paddingLeft:r.sm,paddingRight:tu,paddingVertical:ru,backgroundColor:t.composerFill,borderWidth:eu,borderColor:t.composerBorder,borderRadius:n.pill,...Jo(u.composerInput,eu)},composerRow:{flexDirection:"row",alignItems:"center",gap:r.xs,minHeight:nu},dictationError:{...face(e,"regular"),fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal,color:t.danger,paddingHorizontal:r.xs},attachControl:{width:cu,height:cu,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:fu},input:{flex:1,minHeight:nu,maxHeight:Vs,paddingHorizontal:0,paddingVertical:0,...face(e,"regular"),fontSize:l.size.body,lineHeight:a,color:t.text.primary,...ea(u.composerInput)},sendControl:{minHeight:ou,minWidth:ou,alignItems:"center",justifyContent:"center"},sendDisc:{width:ou,height:ou,borderRadius:ou/2,alignItems:"center",justifyContent:"center",...Jo(u.sendButton)},sendControlDisabled:{opacity:du},poweredBy:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.micro,textAlign:"center",paddingBottom:r.xs}})}var Du=18,Mu=28,Bu=6,Hu=1200,Wu=.4,Nu=.4;function DictationButton({active:e,listening:t,elapsedMs:r,disabled:n=false,onToggle:i}){let o=useEverfurTheme(),s=l(()=>Uu(o),[o]);return a(()=>{if(t)try{I.announceForAccessibility(Ne.listening)}catch{}},[t]),/* @__PURE__ */j(v,{style:s.wrap,children:[t?/* @__PURE__ */A(Text,{style:s.timer,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",testID:"everfur-dictation-timer",children:za(r)}):null,
107
+ /* @__PURE__ */A(C,{onPress:()=>i(),disabled:n,accessibilityRole:"button",accessibilityLabel:e?Ne.stopDictation:Ne.dictate,accessibilityState:{selected:e,disabled:n},style:[s.button,n?s.buttonDisabled:null],testID:"everfur-dictation-button",children:e?/* @__PURE__ */j(D,{children:[
107
108
  /* @__PURE__ */A(Pulse,{style:s.pulse,reduced:o.motion.reducedMotion}),
108
- /* @__PURE__ */A(StopGlyph,{size:ju,color:o.color.brandInk,testID:"everfur-dictation-stop"})]}):/* @__PURE__ */A(MicGlyph,{size:Au,color:o.color.brandInk,testID:"everfur-dictation-mic"})})]})}function Pulse({style:e,reduced:t}){let r=i(new L.Value(1)).current;return a(()=>{if(t)return;let e=L.loop(L.sequence([L.timing(r,{toValue:Bu,duration:Mu/2,useNativeDriver:true}),L.timing(r,{toValue:1,duration:Mu/2,useNativeDriver:true})]));return e.start(),()=>e.stop()},[r,t]),/* @__PURE__ */A(L.View,{style:[e,{opacity:r}],accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"})}function Wu(e){let t=e.color,r=e.type.tierSizes.compact.micro;return g.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:Ns,height:Ns,borderRadius:e.radius.pill,alignItems:"center",justifyContent:"center"},buttonDisabled:{opacity:Hu},pulse:{position:"absolute",top:Du,right:Du,bottom:Du,left:Du,borderRadius:e.radius.pill,backgroundColor:t.brandSofter}})}function optionalModule(e,t,r){let n;try{n=t()}catch(t){return Uu(`optional peer '${e}' is not installed: ${$u(t)}`)}let l=Nu(n);return l==null?Uu(`optional peer '${e}' resolved to no module`):r&&!r(l)?Uu(`optional peer '${e}' is present but failed its shape check`):/* @__PURE__ */Object.freeze({available:true,module:l})}function Nu(e){return typeof e=="object"&&e!==null&&"default"in e&&Object.keys(e).length<=2?e.default:e}function Uu(e){/* @__PURE__ */
109
- return Object.freeze({available:false,module:null,reason:e})}function $u(e){return e instanceof Error?e.message:typeof e=="string"?e:"unknown load error"}var Vu=/* @__PURE__ */Symbol.for("@everfur/sdk/rn-dictation");function qu(){let e=globalThis,t=e[Vu];if(t!==void 0)return t;let r={loader:null,memo:void 0};return e[Vu]=r,r}function registerEverfurDictation(e){let t=qu();t.loader=e,t.memo=void 0,t.version=(t.version??0)+1;for(let e of[...t.listeners??[]])try{e()}catch{}}function Gu(){return qu().version??0}function Ku(e){let t=qu(),r=t.listeners??/* @__PURE__ */new Set;t.listeners=r;let n=()=>e();return r.add(n),()=>{r.delete(n)}}function Yu(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 Qu(e){return typeof e!="object"||e===null?null:e.ExpoSpeechRecognitionModule??e}function Zu(){let e=qu();if(e.memo!==void 0)return e.memo;e.memo=null;let t=e.loader;if(t===null||b.OS!=="ios"&&b.OS!=="android")return e.memo;let r=optionalModule("expo-speech-recognition",()=>({box:Qu(t())}),e=>typeof e=="object"&&e!==null&&Yu(e.box));return r.available&&(e.memo=r.module.box),e.memo}function Ju(e){if(e===null)return false;try{return e.isRecognitionAvailable()===!0}catch{return false}}function Xu(){try{return Intl.DateTimeFormat().resolvedOptions().locale||td}catch{return td}}function ed(e){return e.replace(/_/g,"-").toLowerCase()}var td="en-US";function rd(e=Xu()){let[t=""]=e.replace(/_/g,"-").split("-u-"),r=t.split("-");if(r[0]?.toLowerCase()!=="en")return td;let n=r.slice(1).find(e=>/^[A-Za-z]{2}$/.test(e));return n?`en-${n.toUpperCase()}`:td}function nd(e,t){if(t.length===0)return null;let r=e=>t.find(t=>ed(t)===ed(e));return r(e)??r(td)??t.find(e=>ed(e).startsWith("en-"))??null}async function ld(e,t){if(b.OS!=="ios")return t;try{let{locales:r}=await e.getSupportedLocales({});return nd(t,r??[])??t}catch{return t}}async function id(e,t){let r=false;try{r=e.supportsOnDeviceRecognition()===!0}catch{r=false}if(!r)return"network";if(b.OS!=="android")return"on_device";try{let{installedLocales:r}=await e.getSupportedLocales({}),n=ed(t);return(r??[]).some(e=>ed(e)===n)?"on_device":"network"}catch{return"network"}}function od(){return b.OS!=="android"?true:Number(b.Version)>=ad}var ad=33;function sd(e,t,r){return{lang:t,interimResults:true,continuous:od(),maxAlternatives:1,addsPunctuation:true,requiresOnDeviceRecognition:e==="on_device",contextualStrings:r.slice(0,100),iosTaskHint:"dictation"}}var ud=/* @__PURE__ */new Set(["not-allowed","no-speech","speech-timeout","aborted","interrupted"]),dd=/* @__PURE__ */new Set(["busy","client","network","audio-capture","too-many-requests","unknown"]);function cd(e){return dd.has(e)}var pd=600,fd=3;function hd(e,t,r){if(ud.has(r))return null;let n=cd(r)?pd:0;return r==="language-not-supported"&&ed(t)!==ed(td)?{mode:"network",lang:td,delayMs:n}:e==="on_device"?{mode:"network",lang:t,delayMs:n}:n>0?{mode:"network",lang:t,delayMs:n}:null}function gd(e){return e==="not-allowed"?"permissionDenied":e==="no-speech"||e==="speech-timeout"?"noSpeech":"unavailable"}async function bd(e){try{if((await e.getPermissionsAsync()).granted)return"granted"}catch{}try{return(await e.requestPermissionsAsync()).granted?"granted":"denied"}catch{return"error"}}var yd=55e3,md=3e3,vd=1e3;function wd(e){return kd.has(e)||cd(e)}var kd=/* @__PURE__ */new Set(["no-speech","speech-timeout","aborted","interrupted"]),Cd=/* @__PURE__ */Object.freeze({committed:/* @__PURE__ */Object.freeze([]),interim:""});function Sd(e){return e.replace(/\s+/g," ").trim()}function xd(e,t,r){let n=Sd(t);return r?n?{committed:[...e.committed,n],interim:""}:{committed:e.committed,interim:""}:{committed:e.committed,interim:n}}function Rd(e){return Sd([...e.committed,e.interim].join(" "))}function Td(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 d(e){return!e.sawStart&&e.errorCode===null&&e.pendingRetry===null&&Rd(e.transcript)===""&&e.launchedAt-o<vd}function c(e){return e.mode??"none"}function p(e,t){za(r(),"chat_dictation_completed",{mode:c(e),duration_ms:e.startedAt===null?0:Math.max(0,n()-e.startedAt),char_count:t.length})}function f(e,n){za(r(),"chat_dictation_failed",{mode:c(e),error:n}),t.onStatus("idle"),t.onError(n)}function h(e){if(a(e.token)===null)return;u(e);let r=Rd(e.transcript),n=e.errorCode;if(n!==null&&!(r&&wd(n))){f(e,gd(n));return}if(!r){f(e,"noSpeech");return}p(e,r),t.onStatus("idle")}function g(l){l.subscriptions=[e.addListener("start",()=>{a(l.token)!==null&&(l.sawStart=true,l.startedAt===null&&(l.startedAt=n()),za(r(),"chat_dictation_started",{mode:c(l)}),t.onStatus("listening"))}),e.addListener("result",e=>{if(a(l.token)===null)return;let r=e?.results?.[0]?.transcript??"";l.transcript=xd(l.transcript,r,e?.isFinal===true),t.onText(Rd(l.transcript))}),e.addListener("error",e=>{if(a(l.token)===null)return;let t=e?.error??"unknown";if(l.userStopped&&(t==="aborted"||cd(t)))return;let r=Rd(l.transcript)==="",n=l.mode!==null&&!l.userStopped&&r&&l.retries<fd?hd(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&&!d(l)){if(l.pendingRetry!==null){let e=l.pendingRetry;if(l.pendingRetry=null,l.retries+=1,l.lang=e.lang,e.delayMs<=0){b(l,e.mode);return}s(l),l.retryTimer=setTimeout(()=>{l.retryTimer=null,!(a(l.token)===null||l.userStopped)&&b(l,e.mode)},e.delayMs);return}h(l)}})]}function b(t,r){s(t),t.mode=r,t.sawStart=false,t.launchedAt=n(),t.transcript=Cd,t.errorCode=null,g(t);try{e.start(sd(r,t.lang,t.phrases))}catch{t.errorCode="unknown",h(t)}}async function y(t){let r=await bd(e);if(a(t.token)===null)return;if(r!=="granted"){u(t),f(t,r==="denied"?"permissionDenied":"unavailable");return}if(t.lang=await ld(e,t.lang),a(t.token)===null)return;let n=await id(e,t.lang);a(t.token)!==null&&(t.autoStopTimer=setTimeout(()=>m(t),yd),b(t,n))}function m(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),md);try{e.stop()}catch{h(r)}}}return{start(e){if(i!==null)return;let r={token:++l,phrases:e,lang:rd(),mode:null,retries:0,pendingRetry:null,userStopped:false,transcript:Cd,errorCode:null,startedAt:null,sawStart:false,launchedAt:0,subscriptions:[],autoStopTimer:null,graceTimer:null,retryTimer:null};i=r,t.onStatus("starting"),y(r)},stop(){i!==null&&m(i)},cancel(){let r=i;if(r===null)return;let l=r.mode!==null&&r.retryTimer===null,a=Rd(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 _d({enabled:e,input:t,setInput:r,phrases:u,maxLength:d,telemetry:c}){let p=s(Ku,Gu,Gu),f=l(()=>e?Zu():null,[e,p]),h=l(()=>Ju(f),[f]),[g,b]=o("idle"),[m,v]=o(null),[w,k]=o(0),C=i(t);C.current=t;let S=i(r);S.current=r;let x=i(c);x.current=c;let R=i(""),T=i(d);T.current=d;let _=i(null);f!==null&&_.current?.mod!==f&&(_.current?.controller.cancel(),_.current={mod:f,controller:Td(f,{onStatus:e=>{b(t=>e==="idle"&&t==="error"?t:e)},onText:e=>S.current(Ra(R.current,e,T.current)),onError:e=>{v(e),b("error")}},()=>x.current)});let z=f===null?null:_.current?.controller??null,I=n(()=>{z?.cancel()},[z]),P=n(()=>{if(z!==null){if(z.isActive()){z.stop();return}v(null),k(0),R.current=C.current,z.start(u)}},[z,u]);a(()=>{if(g!=="listening")return;let e=Date.now();k(0);let t=setInterval(()=>k(Date.now()-e),1e3);return()=>clearInterval(t)},[g]),a(()=>{if(g!=="error")return;let e=setTimeout(()=>{v(null),b("idle")},xa);return()=>clearTimeout(e)},[g]),a(()=>{if(z===null)return;let e=null;try{e=y.addEventListener("change",e=>{e==="background"&&!z.isPreparing()&&z.cancel()})}catch{}return()=>{e?.remove(),z.cancel()}},[z]);let F=e&&h;return a(()=>{F||z?.cancel()},[F,z]),{supported:F,status:g,active:g==="starting"||g==="listening",error:m,elapsedMs:w,toggle:P,cancel:I}}var zd=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatPaneShown");function Id(){let e=globalThis,t=e[zd];if(t!==void 0)return t;let r=createContext(true);return e[zd]=r,r}var Pd=Id();function Fd(){return u(Pd)}var Ld=/* @__PURE__ */Object.freeze(["photo"]),Ed=52,Od=1.5,Ad=10,jd=14,Dd=10,Md=40,Bd=20,Hd=.3,Wd=2.5,Nd=1,Ud=1.5,$d=38,Vd=22,qd=3;function Gd(e,t,r,n="ask",l=false){let i=typeof t=="string"&&t.trim()!=="";return r&&i&&n!=="urgent"?Ue(He.placeholder,t):e!==null?!l||!e.includes("{pet}")?e:i?e.split("{pet}").join(t.trim()):Ue(He.placeholder,t):n==="urgent"?He.placeholderUrgentWeb:n==="followUp"?He.placeholderFollowUpWeb:Ue(He.placeholder,t)}function ComposerWithAttachments({attachments:e,...t}){let r=l(()=>createRnChatAttachmentTransport(),[]),n=useChatAttachments({maxPerMessage:e.maxPerMessage??aa,transport:r}),i=l(()=>({state:n,sources:e.sources??Ld,pick:e.pick}),[n,e.sources,e.pick]);/* @__PURE__ */
110
- return A(Composer,{...t,attachments:i})}function Composer({send:e,stop:t,isStreaming:r,conversationId:conversationId,attachments:s,seed:u,draftStore:d,onStage:c,onPreview:p,petName:f,petBreed:h=null,mood:g="ask",dictation:b=false,telemetry:y=null,compact:m=false,petPlaceholder:w=false,dimEmptySend:k=false}){let{theme:S,styles:x}=Eu(),R=l(()=>Xd(S),[S]),T=l(()=>ec(S),[S]),_=Co(),[z,I]=Fa(e,conversationId,u),[P,F]=o(false),[L,E]=o(false),O=n(()=>E(true),[]),M=n(()=>E(false),[]),[B,H]=o(false);a(()=>{H(false)},[conversationId]);let W=Gd(S.meta.placeholder,f,w,g,S.meta.placeholderFillsPet===true),N=l(()=>Pa({name:f,breed:h}),[f,h]),U=_d({enabled:b,input:z,setInput:I,phrases:N,maxLength:la,telemetry:y}),$=U.cancel,V=U.active;La(d,conversationId===null?null:String(conversationId),z,I,V);let q=i(conversationId);a(()=>{q.current!==conversationId&&(q.current=conversationId,$())},[conversationId,$]);let G=Fd();a(()=>{G||$()},[G,$]);let K=s?.state.uploading??false,Y=s?.state.failed??false,Q=K||Y,Z=s?.state.attachments??Kd;Bo(Z.length,_);let J=n(()=>{let t=z.trim();if(t.length===0||Q||[...t].length>la)return;V&&$();let r=s?.state.s3Keys??Yd;s!==null&&r.length>0?(c(s.state.attachments.filter(e=>e.status==="uploaded").map(e=>({uri:e.previewUri,filename:e.filename}))),e(t,{imageS3Keys:r}),s.state.clear()):e(t),I(""),H(false)},[z,e,Q,V,$,s,c]),X=n(e=>{V&&$(),I(e)},[V,$,I]),ee=n(()=>{t()},[t]),te=n(e=>{F(false),s!==null&&(H(false),s.state.dismissRejected(),Qr(s.pick,e).then(e=>{if(!e.ok){H(true);return}e.value!==null&&s.state.add(e.value)}))},[s]),re=l(()=>[...z.trim()].length>la,[z]),ne=re||Q||z.trim().length===0,le=re||Q||k&&z.trim().length===0,ie=s!==null&&Z.length>=s.state.maxPerMessage,oe=S.slots.sendButton?.textColor??S.color.brandInk,ae=S.slots.sendButton?.textColor??S.color.surface;/* @__PURE__ */
111
- return j(v,{style:x.composerOuter,children:[s!==null&&P?/* @__PURE__ */A(AttachmentPickerPopover,{sources:s.sources,full:ie,onPick:te,onClose:()=>F(false)}):null,s!==null?/* @__PURE__ */A(AttachmentStrip,{attachments:Z,rejected:B?Jd:s.state.rejected,uploadFailed:Y,onRetry:s.state.retry,onRemove:s.state.remove,onPreview:e=>p({uri:e.previewUri,label:e.filename}),style:m?R.tray:T.tray}):null,
112
- /* @__PURE__ */j(v,{style:m?[x.composer,R.bar,L?R.barFocused:null]:x.composer,children:[U.supported&&U.error!==null?/* @__PURE__ */j(D,{children:[
113
- /* @__PURE__ */A(Text,{style:x.dictationError,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:_a(U.error)}),
114
- /* @__PURE__ */A(AnnounceLine,{line:_a(U.error)})]}):null,
115
- /* @__PURE__ */j(v,{style:x.composerRow,children:[s!==null?/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:ie?Ca(Z.length,s.state.maxPerMessage):He.attachPhotoOrFileNative,accessibilityState:{disabled:ie,expanded:P},disabled:ie,style:[x.attachControl,m?R.add:null,ie?x.attachControlDisabled:null],hitSlop:m?qd:void 0,onPress:()=>F(e=>!e),children:/* @__PURE__ */A(UploadGlyph,{size:m?Vd:du,color:ie?S.color.text.muted:m?S.color.text.primary:S.color.brandInk,strokeWidth:1.75})}):null,
116
- /* @__PURE__ */A(me,{style:m?[x.input,R.input]:x.input,onFocus:O,onBlur:M,value:z,onChangeText:X,placeholder:W,placeholderTextColor:S.slots.composerInput?.textColor??S.color.text.placeholder,accessibilityLabel:He.composerLabel,onSubmitEditing:J,returnKeyType:"send",...Qd,...m?Zd:null,blurOnSubmit:false,multiline:true,editable:true}),U.supported?/* @__PURE__ */A(DictationButton,{active:U.active,listening:U.status==="listening",elapsedMs:U.elapsedMs,onToggle:U.toggle}):null,r?/* @__PURE__ */A(C,{onPress:ee,accessibilityRole:"button",accessibilityLabel:He.stop,style:x.sendControl,children:/* @__PURE__ */A(v,{style:m?R.disc:x.sendDisc,testID:"everfur-stop-disc",children:/* @__PURE__ */A(StopGlyph,{size:m?Bd:au,color:m?ae:oe,testID:"everfur-stop-glyph"})})}):/* @__PURE__ */A(C,{onPress:J,disabled:ne,accessibilityRole:"button",accessibilityLabel:He.send,accessibilityState:{disabled:ne,busy:K},style:[x.sendControl,le?m?R.dimmed:x.sendControlDisabled:null],children:m?/* @__PURE__ */A(v,{style:R.disc,testID:"everfur-send-disc",children:/* @__PURE__ */A(ArrowUpGlyph,{size:Bd,color:ae,strokeWidth:2.25,testID:"everfur-send-arrow"})}):/* @__PURE__ */A(v,{style:x.sendDisc,testID:"everfur-send-disc",children:/* @__PURE__ */A(SendGlyph,{size:ou,color:oe,testID:"everfur-send-glyph"})})})]})]})]})}var Kd=/* @__PURE__ */Object.freeze([]),Yd=/* @__PURE__ */Object.freeze([]),Qd=/* @__PURE__ */Object.freeze({submitBehavior:"submit"}),Zd=/* @__PURE__ */Object.freeze(b.OS==="web"?{rows:1}:{}),Jd=/* @__PURE__ */Object.freeze({code:"unknown",retryable:true,filename:""});function Xd(e){let t=e.color,r=e.slots.sendButton,n=textRole(e,"body").fontSize+Nd;return g.create({bar:{marginTop:Ad,marginHorizontal:jd,marginBottom:Dd,minHeight:Ed,paddingLeft:8,paddingRight:6,paddingVertical:0,borderWidth:Od,borderColor:e.slots.composerInput?.borderColor??t.text.primary},barFocused:{borderWidth:Wd,paddingLeft:8-(Wd-Od),paddingRight:6-(Wd-Od)},input:{fontSize:n,lineHeight:Math.round(n*Ud),minHeight:Math.round(n*Ud),...b.OS==="web"?{outlineStyle:"none"}:null},add:{width:$d,height:$d,borderRadius:$d/2},disc:{width:Md,height:Md,borderRadius:Md/2,alignItems:"center",justifyContent:"center",backgroundColor:r?.backgroundColor??t.text.primary,...Qo(r)},dimmed:{opacity:Hd},tray:{marginHorizontal:jd,marginTop:Ad,paddingBottom:0}})}function ec(e){return g.create({tray:{marginHorizontal:e.space.md,marginTop:e.space.xs,paddingBottom:0}})}var tc=/* @__PURE__ */new WeakMap;function rc(e,t){let r=tc.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,tc.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:e,userRef:userRef,activePet:t,scopeEpoch:r}=Ye(),s=l(()=>createPetsRepository(e.registry.services.authFor(userRef)),[e,userRef,r]),[u,d]=o({repository:s,pets:[],loading:true,error:null}),c=u.repository===s?u:{pets:[],loading:true,error:null},p=i(0),f=n(async()=>{let e=++p.current;d(e=>({...e,repository:s,loading:true,error:null,pets:e.repository===s?e.pets:[]}));let t=await s.list();e===p.current&&d(t.ok?{repository:s,pets:t.value,loading:false,error:null}:e=>({repository:s,pets:e.repository===s?e.pets:[],loading:false,error:t.error}))},[s]);a(()=>(f(),()=>{p.current+=1}),[f]),a(()=>rc(e,()=>{f()}),[e,f]);let h=l(()=>t===null?null:c.pets.find(e=>e.petRef===t)??null,[t,c.pets]);return l(()=>({pets:c.pets,activePet:h,loading:c.loading,error:c.error,refresh:f}),[c.pets,c.loading,c.error,h,f])}function nc(e,t){if(t!==null){let r=e.find(e=>e.petRef===t);if(r!==void 0)return r}return e[0]??null}var lc=/* @__PURE__ */Object.freeze({visitButton:"Vet"});var ic=/* @__PURE__ */Symbol.for("@everfur/sdk/televet");function oc(){let e=globalThis,t=e[ic];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[ic]=r,r}function ac(e){let t=oc();t.snapshot=/* @__PURE__ */Object.freeze({...t.snapshot,...e});for(let e of[...t.listeners])try{e()}catch{}}function sc(e){let t=oc().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 uc(){return oc().hosts.length>0}function dc(e){if(!uc())return false;let t=/* @__PURE__ */Object.freeze({...e});return ac({request:t,serial:oc().snapshot.serial+1}),true}var cc=false;function pc(e,t){return t!==void 0?(Gr(t,e),"onStartInApp"):sc(e)==="presented"?"presenter":dc(e)?"experience":(cc||(cc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}var fc=createContext(null);function TelevetHostOutlet(){let e=u(fc);return e===null?null:/* @__PURE__ */A(e,{})}var hc=/* @__PURE__ */Object.freeze(["visit","join","summary","messages"]);function isVetVisitIntent(e){return typeof e=="string"&&hc.includes(e)}var gc="/widget/v1/televet/handoffs",bc="/widget/v1/televet/availability",yc="/widget/v1/televet/chat-entry",mc=/^[a-z0-9][a-z0-9_-]{0,39}$/,vc=/^[A-Za-z0-9_-]{22}$/;var wc=32,kc=128,Cc=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 Sc(e){return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:e}))}function xc(e){return err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}function Rc(petRef,e){let t={};petRef!==void 0&&(t.pet_ref=petRef);let r=e?.returnTo;if(r!=null){if(typeof r!="string"||!mc.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>Cc)return{ok:false,message:`visitRef must be 1..${Cc} 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 ${hc.join(", ")}`};t.intent=i}return{ok:true,body:t}}function Tc(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 _c(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=e=>(Ec(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>kc)return n(makeEverfurError("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${kc} characters`}));l=petRef}let i=Rc(l,e);if(!i.ok){let e=Sc(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=zc(a.value),u=o.return_to!==void 0,d=u?a.value?.flow_id:void 0;if(u&&(typeof d!="string"||!vc.test(d))){let e=xc("the handoff response carried no usable return flow id");return e.ok?e:n(e.error)}let c=o.visit_ref!==void 0,p=c?Tc(a.value?.visit):null;if(c&&p===null){let e=xc("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:d}:{},...p!==null?{visit:p}:{}});return f===null?n(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Ec(r,"televet.visit.handoff_created",{pet_scoped:o.pet_ref!==void 0}),ok(f))},async checkAvailability(e){if(typeof e!="string"||e.length>wc)return Sc(`state must be at most ${wc} characters`);let r=await t.send("televet.visit.availability",{method:"POST",path:bc,body:{state:e}},{idempotent:false,maxAttempts:1});if(!r.ok)return err(r.error);let n=r.value?.available;return typeof n!="boolean"?xc("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 zc(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||!Lc(t)?null:/* @__PURE__ */Object.freeze({url:t,expiresAt:r})}var Ic=/* @__PURE__ */new Set(["localhost","127.0.0.1","[::1]"]),Pc=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,Fc=/[\s\u0000-\u001f\u007f]/;function Lc(e){if(Fc.test(e))return false;let t=Pc.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"&&Ic.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 Ec(e,t,r){if(e)try{e.track(t,r)}catch{}}var Oc=/* @__PURE__ */Object.freeze({status:"idle",error:null,errorReason:null});function Ac(e,t,r){let{usState:n,chat:l,scope:i}=r,s=t&&(n!==null||l),u=`${n??""}|${l?"chat":""}`,[d,c]=o(null);if(a(()=>{if(!s)return;let t=true,r=e.current;return c(null),(async()=>{try{if(l&&!(r.chatEntryOpen&&await r.chatEntryOpen()))return!1;if(n===null)return!0;if(!r.checkAvailability)return!1;let e=await r.checkAvailability(n);return e.ok&&e.value.available}catch{return false}})().then(e=>{t&&c({key:u,open:e})}),()=>{t=false}},[s,u,n,l,i,e]),!s)return null;let p=d!==null&&d.key===u;return{open:p&&d.open,pending:!p}}var jc=/* @__PURE__ */Object.freeze({status:"opening",error:null,errorReason:null});function Dc(e,t={}){let{runtime:r,userRef:userRef,scopeEpoch:a}=Ye(),s=useCapability("televet"),u=s.enabled&&userRef!==null,d=t.usState??null,c=t.entry==="chat",p=t.petRef??null,f=t.prefer==="redirect",h=l(()=>{if(t.controller)return t.controller;let{services:e}=r.registry;return _c({auth:e.authFor(userRef),telemetry:e.telemetry,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})},[r,userRef,a,t.controller]),g=i(h);g.current=h;let b=l(()=>({runtime:r,userRef:userRef,scopeEpoch:a}),[r,userRef,a]),y=Ac(g,u,{usState:d,chat:c,scope:b}),m=u&&(y===null||y.open)&&(!c||p!==null),v=t.returnTo??null,[w,k]=o(Oc),C=i(null),S=i({runtime:r,userRef:userRef,scopeEpoch:a});S.current={runtime:r,userRef:userRef,scopeEpoch:a};let x=i(h);x.current=h;let R=i(m);R.current=m;let T=n((petRef,t)=>{if(C.current)return C.current;let r=(e,t)=>(k({status:e==="cancelled"?"idle":"error",error:t,errorReason:e==="cancelled"?null:e}),/* @__PURE__ */Object.freeze({opened:false,reason:e,error:t}));if(!R.current)return Promise.resolve(r("unavailable",null));let n=e.prepare();if(!n.ok)return Promise.resolve(r(n.reason,null));let l=S.current,i=x.current;k(jc);let o=(async()=>{let o,a={...v!==null?{returnTo:v}:{},...c?{entry:"chat"}:{},...t!==null?{visitRef:t.visitRef}:{},...t!==null&&t.intent!==null&&t.intent!==void 0?{intent:t.intent}:{}},s=Object.keys(a).length===0?void 0:a,u=petRef===void 0?p:petRef;try{o=await(s===void 0?i.createHandoff(u):i.createHandoff(u,s))}catch{return e.abandon(n.value),r("unknown",null)}let d=S.current;if(d.runtime!==l.runtime||d.userRef!==l.userRef||d.scopeEpoch!==l.scopeEpoch)return e.abandon(n.value),r("cancelled",null);if(!o.ok)return e.abandon(n.value),r(vetVisitErrorReasonOf(o.error),o.error);let f=await e.finish(n.value,o.value);return f!==null?r(f,null):(k(Oc),/* @__PURE__ */Object.freeze(o.value.flowId===void 0?{opened:true}:{opened:true,flowId:o.value.flowId}))})().finally(()=>{C.current===o&&(C.current=null)});return C.current=o,o},[e,p,v,c]),_=n((petRef,e)=>{if(!R.current)return k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}));let t=petRef===void 0?p:petRef,r={...t!==null?{petRef:t}:{},...d!==null?{usState:d}:{},...e!==null&&"consultId"in e?{consultId:e.consultId}:{},...e!==null&&"visitRef"in e?{visitRef:e.visitRef,intent:e.intent}:{}};return pc(r)===null?(k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}))):(k(Oc),Promise.resolve(/* @__PURE__ */Object.freeze({opened:true})))},[p,d]),z=n(petRef=>f?T(petRef,null):_(petRef,null),[f,T,_]),I=n((e,t)=>f?T(void 0,{visitRef:e,intent:t??null}):_(void 0,{visitRef:e,intent:t??null}),[f,T,_]),P=n(e=>f?T(void 0,null):_(void 0,{consultId:e.trim()}),[f,T,_]);return{available:m,isPending:s.isPending||(y?.pending??false),status:w.status,error:w.error,errorReason:w.errorReason,open:z,openVisit:I,joinVisit:P}}var Mc=e=>w.openURL(e);function useVetVisit(e={}){let{openUrl:t,...r}=e,n=l(()=>{let e=t??Mc;return{prepare:()=>({ok:true,value:null}),async finish(t,r){try{return await e(r.url),null}catch{return"openFailed"}},abandon:()=>{}}},[t]);return Dc(n,r)}var Bc=44,Hc=.6;function VetVisitButtonCore(e){let{petRef:petRef,label:t,openUrl:r,onOpened:n,onError:o,style:a,labelStyle:s,controller:u,returnTo:d,usState:c,entry:p,visitRef:f,intent:h,onStartInApp:g,prefer:b}=e,y=b==="redirect",m=useVetVisit({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...petRef!==void 0?{petRef:petRef}:{},...r!==void 0?{openUrl:r}:{},...u!==void 0?{controller:u}:{},prefer:y?"redirect":"in-app"}),v=useEverfurTheme(),w=l(()=>Wc(v),[v]),k=i(false);if(!m.available)/* @__PURE__ */
109
+ /* @__PURE__ */A(StopGlyph,{size:Mu,color:o.color.brandInk,testID:"everfur-dictation-stop"})]}):/* @__PURE__ */A(MicGlyph,{size:Du,color:o.color.brandInk,testID:"everfur-dictation-mic"})})]})}function Pulse({style:e,reduced:t}){let r=i(new L.Value(1)).current;return a(()=>{if(t)return;let e=L.loop(L.sequence([L.timing(r,{toValue:Wu,duration:Hu/2,useNativeDriver:true}),L.timing(r,{toValue:1,duration:Hu/2,useNativeDriver:true})]));return e.start(),()=>e.stop()},[r,t]),/* @__PURE__ */A(L.View,{style:[e,{opacity:r}],accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"})}function Uu(e){let t=e.color,r=e.type.tierSizes.compact.micro;return g.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:$s,height:$s,borderRadius:e.radius.pill,alignItems:"center",justifyContent:"center"},buttonDisabled:{opacity:Nu},pulse:{position:"absolute",top:Bu,right:Bu,bottom:Bu,left:Bu,borderRadius:e.radius.pill,backgroundColor:t.brandSofter}})}function optionalModule(e,t,r){let n;try{n=t()}catch(t){return Vu(`optional peer '${e}' is not installed: ${qu(t)}`)}let l=$u(n);return l==null?Vu(`optional peer '${e}' resolved to no module`):r&&!r(l)?Vu(`optional peer '${e}' is present but failed its shape check`):/* @__PURE__ */Object.freeze({available:true,module:l})}function $u(e){return typeof e=="object"&&e!==null&&"default"in e&&Object.keys(e).length<=2?e.default:e}function Vu(e){/* @__PURE__ */
110
+ return Object.freeze({available:false,module:null,reason:e})}function qu(e){return e instanceof Error?e.message:typeof e=="string"?e:"unknown load error"}var Gu=/* @__PURE__ */Symbol.for("@everfur/sdk/rn-dictation");function Ku(){let e=globalThis,t=e[Gu];if(t!==void 0)return t;let r={loader:null,memo:void 0};return e[Gu]=r,r}function registerEverfurDictation(e){let t=Ku();t.loader=e,t.memo=void 0,t.version=(t.version??0)+1;for(let e of[...t.listeners??[]])try{e()}catch{}}function Yu(){return Ku().version??0}function Qu(e){let t=Ku(),r=t.listeners??/* @__PURE__ */new Set;t.listeners=r;let n=()=>e();return r.add(n),()=>{r.delete(n)}}function Zu(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 Ju(e){return typeof e!="object"||e===null?null:e.ExpoSpeechRecognitionModule??e}function Xu(){let e=Ku();if(e.memo!==void 0)return e.memo;e.memo=null;let t=e.loader;if(t===null||b.OS!=="ios"&&b.OS!=="android")return e.memo;let r=optionalModule("expo-speech-recognition",()=>({box:Ju(t())}),e=>typeof e=="object"&&e!==null&&Zu(e.box));return r.available&&(e.memo=r.module.box),e.memo}function ed(e){if(e===null)return false;try{return e.isRecognitionAvailable()===!0}catch{return false}}function td(){try{return Intl.DateTimeFormat().resolvedOptions().locale||nd}catch{return nd}}function rd(e){return e.replace(/_/g,"-").toLowerCase()}var nd="en-US";function ld(e=td()){let[t=""]=e.replace(/_/g,"-").split("-u-"),r=t.split("-");if(r[0]?.toLowerCase()!=="en")return nd;let n=r.slice(1).find(e=>/^[A-Za-z]{2}$/.test(e));return n?`en-${n.toUpperCase()}`:nd}function id(e,t){if(t.length===0)return null;let r=e=>t.find(t=>rd(t)===rd(e));return r(e)??r(nd)??t.find(e=>rd(e).startsWith("en-"))??null}async function od(e,t){if(b.OS!=="ios")return t;try{let{locales:r}=await e.getSupportedLocales({});return id(t,r??[])??t}catch{return t}}async function ad(e,t){let r=false;try{r=e.supportsOnDeviceRecognition()===!0}catch{r=false}if(!r)return"network";if(b.OS!=="android")return"on_device";try{let{installedLocales:r}=await e.getSupportedLocales({}),n=rd(t);return(r??[]).some(e=>rd(e)===n)?"on_device":"network"}catch{return"network"}}function sd(){return b.OS!=="android"?true:Number(b.Version)>=ud}var ud=33;function dd(e,t,r){return{lang:t,interimResults:true,continuous:sd(),maxAlternatives:1,addsPunctuation:true,requiresOnDeviceRecognition:e==="on_device",contextualStrings:r.slice(0,100),iosTaskHint:"dictation"}}var cd=/* @__PURE__ */new Set(["not-allowed","no-speech","speech-timeout","aborted","interrupted"]),pd=/* @__PURE__ */new Set(["busy","client","network","audio-capture","too-many-requests","unknown"]);function fd(e){return pd.has(e)}var hd=600,gd=3;function bd(e,t,r){if(cd.has(r))return null;let n=fd(r)?hd:0;return r==="language-not-supported"&&rd(t)!==rd(nd)?{mode:"network",lang:nd,delayMs:n}:e==="on_device"?{mode:"network",lang:t,delayMs:n}:n>0?{mode:"network",lang:t,delayMs:n}:null}function yd(e){return e==="not-allowed"?"permissionDenied":e==="no-speech"||e==="speech-timeout"?"noSpeech":"unavailable"}async function md(e){try{if((await e.getPermissionsAsync()).granted)return"granted"}catch{}try{return(await e.requestPermissionsAsync()).granted?"granted":"denied"}catch{return"error"}}var vd=55e3,wd=3e3,kd=1e3;function Cd(e){return Sd.has(e)||fd(e)}var Sd=/* @__PURE__ */new Set(["no-speech","speech-timeout","aborted","interrupted"]),xd=/* @__PURE__ */Object.freeze({committed:/* @__PURE__ */Object.freeze([]),interim:""});function Rd(e){return e.replace(/\s+/g," ").trim()}function Td(e,t,r){let n=Rd(t);return r?n?{committed:[...e.committed,n],interim:""}:{committed:e.committed,interim:""}:{committed:e.committed,interim:n}}function _d(e){return Rd([...e.committed,e.interim].join(" "))}function zd(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 d(e){return!e.sawStart&&e.errorCode===null&&e.pendingRetry===null&&_d(e.transcript)===""&&e.launchedAt-o<kd}function c(e){return e.mode??"none"}function p(e,t){Pa(r(),"chat_dictation_completed",{mode:c(e),duration_ms:e.startedAt===null?0:Math.max(0,n()-e.startedAt),char_count:t.length})}function f(e,n){Pa(r(),"chat_dictation_failed",{mode:c(e),error:n}),t.onStatus("idle"),t.onError(n)}function h(e){if(a(e.token)===null)return;u(e);let r=_d(e.transcript),n=e.errorCode;if(n!==null&&!(r&&Cd(n))){f(e,yd(n));return}if(!r){f(e,"noSpeech");return}p(e,r),t.onStatus("idle")}function g(l){l.subscriptions=[e.addListener("start",()=>{a(l.token)!==null&&(l.sawStart=true,l.startedAt===null&&(l.startedAt=n()),Pa(r(),"chat_dictation_started",{mode:c(l)}),t.onStatus("listening"))}),e.addListener("result",e=>{if(a(l.token)===null)return;let r=e?.results?.[0]?.transcript??"";l.transcript=Td(l.transcript,r,e?.isFinal===true),t.onText(_d(l.transcript))}),e.addListener("error",e=>{if(a(l.token)===null)return;let t=e?.error??"unknown";if(l.userStopped&&(t==="aborted"||fd(t)))return;let r=_d(l.transcript)==="",n=l.mode!==null&&!l.userStopped&&r&&l.retries<gd?bd(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&&!d(l)){if(l.pendingRetry!==null){let e=l.pendingRetry;if(l.pendingRetry=null,l.retries+=1,l.lang=e.lang,e.delayMs<=0){b(l,e.mode);return}s(l),l.retryTimer=setTimeout(()=>{l.retryTimer=null,!(a(l.token)===null||l.userStopped)&&b(l,e.mode)},e.delayMs);return}h(l)}})]}function b(t,r){s(t),t.mode=r,t.sawStart=false,t.launchedAt=n(),t.transcript=xd,t.errorCode=null,g(t);try{e.start(dd(r,t.lang,t.phrases))}catch{t.errorCode="unknown",h(t)}}async function y(t){let r=await md(e);if(a(t.token)===null)return;if(r!=="granted"){u(t),f(t,r==="denied"?"permissionDenied":"unavailable");return}if(t.lang=await od(e,t.lang),a(t.token)===null)return;let n=await ad(e,t.lang);a(t.token)!==null&&(t.autoStopTimer=setTimeout(()=>m(t),vd),b(t,n))}function m(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),wd);try{e.stop()}catch{h(r)}}}return{start(e){if(i!==null)return;let r={token:++l,phrases:e,lang:ld(),mode:null,retries:0,pendingRetry:null,userStopped:false,transcript:xd,errorCode:null,startedAt:null,sawStart:false,launchedAt:0,subscriptions:[],autoStopTimer:null,graceTimer:null,retryTimer:null};i=r,t.onStatus("starting"),y(r)},stop(){i!==null&&m(i)},cancel(){let r=i;if(r===null)return;let l=r.mode!==null&&r.retryTimer===null,a=_d(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 Id({enabled:e,input:t,setInput:r,phrases:u,maxLength:d,telemetry:c}){let p=s(Qu,Yu,Yu),f=l(()=>e?Xu():null,[e,p]),h=l(()=>ed(f),[f]),[g,b]=o("idle"),[m,v]=o(null),[w,k]=o(0),C=i(t);C.current=t;let S=i(r);S.current=r;let x=i(c);x.current=c;let R=i(""),T=i(d);T.current=d;let _=i(null);f!==null&&_.current?.mod!==f&&(_.current?.controller.cancel(),_.current={mod:f,controller:zd(f,{onStatus:e=>{b(t=>e==="idle"&&t==="error"?t:e)},onText:e=>S.current(_a(R.current,e,T.current)),onError:e=>{v(e),b("error")}},()=>x.current)});let z=f===null?null:_.current?.controller??null,I=n(()=>{z?.cancel()},[z]),P=n(()=>{if(z!==null){if(z.isActive()){z.stop();return}v(null),k(0),R.current=C.current,z.start(u)}},[z,u]);a(()=>{if(g!=="listening")return;let e=Date.now();k(0);let t=setInterval(()=>k(Date.now()-e),1e3);return()=>clearInterval(t)},[g]),a(()=>{if(g!=="error")return;let e=setTimeout(()=>{v(null),b("idle")},Ta);return()=>clearTimeout(e)},[g]),a(()=>{if(z===null)return;let e=null;try{e=y.addEventListener("change",e=>{e==="background"&&!z.isPreparing()&&z.cancel()})}catch{}return()=>{e?.remove(),z.cancel()}},[z]);let F=e&&h;return a(()=>{F||z?.cancel()},[F,z]),{supported:F,status:g,active:g==="starting"||g==="listening",error:m,elapsedMs:w,toggle:P,cancel:I}}var Pd=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatTabsAsk.v1");function Fd(){let e=globalThis;return e[Pd]??=createContext(null)}var Ld=Fd();function Ed(){return u(Ld)}var Od=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatPaneShown");function Ad(){let e=globalThis,t=e[Od];if(t!==void 0)return t;let r=createContext(true);return e[Od]=r,r}var jd=Ad();function Dd(){return u(jd)}var Md=/* @__PURE__ */Object.freeze(["photo"]),Bd=52,Hd=1.5,Wd=10,Nd=14,Ud=10,$d=40,Vd=20,qd=.3,Gd=2.5,Kd=1,Yd=1.5,Qd=38,Zd=22,Jd=3;function Xd(e,t,r,n="ask",l=false){let i=typeof t=="string"&&t.trim()!=="";return r&&i&&n!=="urgent"?Ve(Ne.placeholder,t):e!==null?!l||!e.includes("{pet}")?e:i?e.split("{pet}").join(t.trim()):Ve(Ne.placeholder,t):n==="urgent"?Ne.placeholderUrgentWeb:n==="followUp"?Ne.placeholderFollowUpWeb:Ve(Ne.placeholder,t)}function ComposerWithAttachments({attachments:e,...t}){let r=l(()=>createRnChatAttachmentTransport(),[]),n=useChatAttachments({maxPerMessage:e.maxPerMessage??ua,transport:r}),i=l(()=>({state:n,sources:e.sources??Md,pick:e.pick}),[n,e.sources,e.pick]);/* @__PURE__ */
111
+ return A(Composer,{...t,attachments:i})}function Composer({send:e,stop:t,isStreaming:r,conversationId:conversationId,attachments:s,seed:u,draftStore:d,onStage:c,onPreview:p,petName:f,petBreed:h=null,mood:g="ask",dictation:b=false,telemetry:y=null,compact:m=false,petPlaceholder:w=false,dimEmptySend:k=false}){let{theme:S,styles:x}=Au(),R=Ed(),T=m||R!==null,_=l(()=>ic(S),[S]),z=R?.paint.composer??null,I=l(()=>sc(S),[S]),P=xo(),[F,L]=Ea(e,conversationId,u),[E,O]=o(false),[M,B]=o(false),H=n(()=>B(true),[]),W=n(()=>B(false),[]),[N,U]=o(false);a(()=>{U(false)},[conversationId]);let $=Xd(S.meta.placeholder,f,w,g,S.meta.placeholderFillsPet===true),V=R?.paint.placeholder($,g!=="ask")??$,q=l(()=>La({name:f,breed:h}),[f,h]),G=Id({enabled:b,input:F,setInput:L,phrases:q,maxLength:oa,telemetry:y}),K=G.cancel,Y=G.active;Oa(d,conversationId===null?null:String(conversationId),F,L,Y);let Q=i(conversationId);a(()=>{Q.current!==conversationId&&(Q.current=conversationId,K())},[conversationId,K]);let Z=Dd();a(()=>{Z||K()},[Z,K]);let J=s?.state.uploading??false,X=s?.state.failed??false,ee=J||X,te=s?.state.attachments??ec;Wo(te.length,P);let re=n(()=>{let t=F.trim();if(t.length===0||ee||[...t].length>oa)return;Y&&K();let r=s?.state.s3Keys??tc;s!==null&&r.length>0?(c(s.state.attachments.filter(e=>e.status==="uploaded").map(e=>({uri:e.previewUri,filename:e.filename}))),e(t,{imageS3Keys:r}),s.state.clear()):e(t),L(""),U(false)},[F,e,ee,Y,K,s,c]),ne=n(e=>{Y&&K(),L(e)},[Y,K,L]),le=n(()=>{t()},[t]),ie=n(e=>{O(false),s!==null&&(U(false),s.state.dismissRejected(),Jr(s.pick,e).then(e=>{if(!e.ok){U(true);return}e.value!==null&&s.state.add(e.value)}))},[s]),oe=l(()=>[...F.trim()].length>oa,[F]),ae=oe||ee||F.trim().length===0,se=oe||ee||k&&F.trim().length===0,ue=s!==null&&te.length>=s.state.maxPerMessage,de=S.slots.sendButton?.textColor??S.color.brandInk,ce=S.slots.sendButton?.textColor??S.color.surface;/* @__PURE__ */
112
+ return j(v,{style:x.composerOuter,children:[s!==null&&E?/* @__PURE__ */A(AttachmentPickerPopover,{sources:s.sources,full:ue,onPick:ie,onClose:()=>O(false)}):null,s!==null?/* @__PURE__ */A(AttachmentStrip,{attachments:te,rejected:N?lc:s.state.rejected,uploadFailed:X,onRetry:s.state.retry,onRemove:s.state.remove,onPreview:e=>p({uri:e.previewUri,label:e.filename}),style:T?_.tray:I.tray}):null,
113
+ /* @__PURE__ */j(v,{style:T?[x.composer,_.bar,M?_.barFocused:null,z?.bar]:x.composer,children:[G.supported&&G.error!==null?/* @__PURE__ */j(D,{children:[
114
+ /* @__PURE__ */A(Text,{style:x.dictationError,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:Ia(G.error)}),
115
+ /* @__PURE__ */A(AnnounceLine,{line:Ia(G.error)})]}):null,
116
+ /* @__PURE__ */j(v,{style:x.composerRow,children:[s!==null?/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:ue?xa(te.length,s.state.maxPerMessage):Ne.attachPhotoOrFileNative,accessibilityState:{disabled:ue,expanded:E},disabled:ue,style:[x.attachControl,T?_.add:null,ue?x.attachControlDisabled:null],hitSlop:T?Jd:void 0,onPress:()=>O(e=>!e),children:R!==null?/* @__PURE__ */A(R.paint.Icon,{name:"upload",size:oc,color:ue?S.color.text.muted:R.paint.accent}):/* @__PURE__ */A(UploadGlyph,{size:T?Zd:pu,color:ue?S.color.text.muted:T?S.color.text.primary:S.color.brandInk,strokeWidth:1.75})}):null,
117
+ /* @__PURE__ */A(me,{style:T?[x.input,_.input,z?.input]:x.input,onFocus:H,onBlur:W,value:F,onChangeText:ne,placeholder:V,placeholderTextColor:R?.paint.muted??S.slots.composerInput?.textColor??S.color.text.placeholder,accessibilityLabel:Ne.composerLabel,onSubmitEditing:re,returnKeyType:"send",...rc,...T?nc:null,blurOnSubmit:false,multiline:true,editable:true}),G.supported?/* @__PURE__ */A(DictationButton,{active:G.active,listening:G.status==="listening",elapsedMs:G.elapsedMs,onToggle:G.toggle}):null,r?/* @__PURE__ */A(C,{onPress:le,accessibilityRole:"button",accessibilityLabel:Ne.stop,style:x.sendControl,children:/* @__PURE__ */A(v,{style:T?[_.disc,z?.stopDisc]:x.sendDisc,testID:"everfur-stop-disc",children:/* @__PURE__ */A(StopGlyph,{size:T?Vd:uu,color:T?ce:de,testID:"everfur-stop-glyph"})})}):/* @__PURE__ */A(C,{onPress:re,disabled:ae,accessibilityRole:"button",accessibilityLabel:Ne.send,accessibilityState:{disabled:ae,busy:J},style:[x.sendControl,se?T?_.dimmed:x.sendControlDisabled:null],children:R!==null&&z!==null?/* @__PURE__ */A(v,{style:z.send,testID:"everfur-send-disc",children:/* @__PURE__ */A(R.paint.Icon,{name:"send",size:ac,color:R.paint.accent})}):T?/* @__PURE__ */A(v,{style:_.disc,testID:"everfur-send-disc",children:/* @__PURE__ */A(ArrowUpGlyph,{size:Vd,color:ce,strokeWidth:2.25,testID:"everfur-send-arrow"})}):/* @__PURE__ */A(v,{style:x.sendDisc,testID:"everfur-send-disc",children:/* @__PURE__ */A(SendGlyph,{size:su,color:de,testID:"everfur-send-glyph"})})})]})]})]})}var ec=/* @__PURE__ */Object.freeze([]),tc=/* @__PURE__ */Object.freeze([]),rc=/* @__PURE__ */Object.freeze({submitBehavior:"submit"}),nc=/* @__PURE__ */Object.freeze(b.OS==="web"?{rows:1}:{}),lc=/* @__PURE__ */Object.freeze({code:"unknown",retryable:true,filename:""});function ic(e){let t=e.color,r=e.slots.sendButton,n=textRole(e,"body").fontSize+Kd;return g.create({bar:{marginTop:Wd,marginHorizontal:Nd,marginBottom:Ud,minHeight:Bd,paddingLeft:8,paddingRight:6,paddingVertical:0,borderWidth:Hd,borderColor:e.slots.composerInput?.borderColor??t.text.primary},barFocused:{borderWidth:Gd,paddingLeft:8-(Gd-Hd),paddingRight:6-(Gd-Hd)},input:{fontSize:n,lineHeight:Math.round(n*Yd),minHeight:Math.round(n*Yd),...b.OS==="web"?{outlineStyle:"none"}:null},add:{width:Qd,height:Qd,borderRadius:Qd/2},disc:{width:$d,height:$d,borderRadius:$d/2,alignItems:"center",justifyContent:"center",backgroundColor:r?.backgroundColor??t.text.primary,...Jo(r)},dimmed:{opacity:qd},tray:{marginHorizontal:Nd,marginTop:Wd,paddingBottom:0}})}var oc=20,ac=22;function sc(e){return g.create({tray:{marginHorizontal:e.space.md,marginTop:e.space.xs,paddingBottom:0}})}var uc=/* @__PURE__ */new WeakMap;function dc(e,t){let r=uc.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,uc.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:e,userRef:userRef,activePet:t,scopeEpoch:r}=Ze(),s=l(()=>createPetsRepository(e.registry.services.authFor(userRef)),[e,userRef,r]),[u,d]=o({repository:s,pets:[],loading:true,error:null}),c=u.repository===s?u:{pets:[],loading:true,error:null},p=i(0),f=n(async()=>{let e=++p.current;d(e=>({...e,repository:s,loading:true,error:null,pets:e.repository===s?e.pets:[]}));let t=await s.list();e===p.current&&d(t.ok?{repository:s,pets:t.value,loading:false,error:null}:e=>({repository:s,pets:e.repository===s?e.pets:[],loading:false,error:t.error}))},[s]);a(()=>(f(),()=>{p.current+=1}),[f]),a(()=>dc(e,()=>{f()}),[e,f]);let h=l(()=>t===null?null:c.pets.find(e=>e.petRef===t)??null,[t,c.pets]);return l(()=>({pets:c.pets,activePet:h,loading:c.loading,error:c.error,refresh:f}),[c.pets,c.loading,c.error,h,f])}function cc(e,t){if(t!==null){let r=e.find(e=>e.petRef===t);if(r!==void 0)return r}return e[0]??null}var pc=/* @__PURE__ */Object.freeze({visitButton:"Vet"});var fc=/* @__PURE__ */Symbol.for("@everfur/sdk/televet");function hc(){let e=globalThis,t=e[fc];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[fc]=r,r}function gc(e){let t=hc();t.snapshot=/* @__PURE__ */Object.freeze({...t.snapshot,...e});for(let e of[...t.listeners])try{e()}catch{}}function bc(e){let t=hc().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 yc(){return hc().hosts.length>0}function mc(e){if(!yc())return false;let t=/* @__PURE__ */Object.freeze({...e});return gc({request:t,serial:hc().snapshot.serial+1}),true}var vc=false;function wc(e,t){return t!==void 0?(Yr(t,e),"onStartInApp"):bc(e)==="presented"?"presenter":mc(e)?"experience":(vc||(vc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}var kc=createContext(null);function TelevetHostOutlet(){let e=u(kc);return e===null?null:/* @__PURE__ */A(e,{})}var Cc=/* @__PURE__ */Object.freeze(["visit","join","summary","messages"]);function isVetVisitIntent(e){return typeof e=="string"&&Cc.includes(e)}var Sc="/widget/v1/televet/handoffs",xc="/widget/v1/televet/availability",Rc="/widget/v1/televet/chat-entry",Tc=/^[a-z0-9][a-z0-9_-]{0,39}$/,_c=/^[A-Za-z0-9_-]{22}$/;var zc=32,Ic=128,Pc=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 Fc(e){return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:e}))}function Lc(e){return err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}function Ec(petRef,e){let t={};petRef!==void 0&&(t.pet_ref=petRef);let r=e?.returnTo;if(r!=null){if(typeof r!="string"||!Tc.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>Pc)return{ok:false,message:`visitRef must be 1..${Pc} 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 ${Cc.join(", ")}`};t.intent=i}return{ok:true,body:t}}function Oc(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 Ac(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=e=>(Wc(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>Ic)return n(makeEverfurError("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${Ic} characters`}));l=petRef}let i=Ec(l,e);if(!i.ok){let e=Fc(i.message);return e.ok?e:n(e.error)}let o=i.body,a=await t.send("televet.visit.handoff",{method:"POST",path:Sc,body:o},{idempotent:false,maxAttempts:1});if(!a.ok)return n(a.error);let s=jc(a.value),u=o.return_to!==void 0,d=u?a.value?.flow_id:void 0;if(u&&(typeof d!="string"||!_c.test(d))){let e=Lc("the handoff response carried no usable return flow id");return e.ok?e:n(e.error)}let c=o.visit_ref!==void 0,p=c?Oc(a.value?.visit):null;if(c&&p===null){let e=Lc("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:d}:{},...p!==null?{visit:p}:{}});return f===null?n(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Wc(r,"televet.visit.handoff_created",{pet_scoped:o.pet_ref!==void 0}),ok(f))},async checkAvailability(e){if(typeof e!="string"||e.length>zc)return Fc(`state must be at most ${zc} characters`);let r=await t.send("televet.visit.availability",{method:"POST",path:xc,body:{state:e}},{idempotent:false,maxAttempts:1});if(!r.ok)return err(r.error);let n=r.value?.available;return typeof n!="boolean"?Lc("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:Rc},{maxAttempts:1});return e.ok&&e.value?.open===!0}catch{return false}}}}function jc(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||!Hc(t)?null:/* @__PURE__ */Object.freeze({url:t,expiresAt:r})}var Dc=/* @__PURE__ */new Set(["localhost","127.0.0.1","[::1]"]),Mc=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,Bc=/[\s\u0000-\u001f\u007f]/;function Hc(e){if(Bc.test(e))return false;let t=Mc.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"&&Dc.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 Wc(e,t,r){if(e)try{e.track(t,r)}catch{}}var Nc=/* @__PURE__ */Object.freeze({status:"idle",error:null,errorReason:null});function Uc(e,t,r){let{usState:n,chat:l,scope:i}=r,s=t&&(n!==null||l),u=`${n??""}|${l?"chat":""}`,[d,c]=o(null);if(a(()=>{if(!s)return;let t=true,r=e.current;return c(null),(async()=>{try{if(l&&!(r.chatEntryOpen&&await r.chatEntryOpen()))return!1;if(n===null)return!0;if(!r.checkAvailability)return!1;let e=await r.checkAvailability(n);return e.ok&&e.value.available}catch{return false}})().then(e=>{t&&c({key:u,open:e})}),()=>{t=false}},[s,u,n,l,i,e]),!s)return null;let p=d!==null&&d.key===u;return{open:p&&d.open,pending:!p}}var $c=/* @__PURE__ */Object.freeze({status:"opening",error:null,errorReason:null});function Vc(e,t={}){let{runtime:r,userRef:userRef,scopeEpoch:a}=Ze(),s=useCapability("televet"),u=s.enabled&&userRef!==null,d=t.usState??null,c=t.entry==="chat",p=t.petRef??null,f=t.prefer==="redirect",h=l(()=>{if(t.controller)return t.controller;let{services:e}=r.registry;return Ac({auth:e.authFor(userRef),telemetry:e.telemetry,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})},[r,userRef,a,t.controller]),g=i(h);g.current=h;let b=l(()=>({runtime:r,userRef:userRef,scopeEpoch:a}),[r,userRef,a]),y=Uc(g,u,{usState:d,chat:c,scope:b}),m=u&&(y===null||y.open)&&(!c||p!==null),v=t.returnTo??null,[w,k]=o(Nc),C=i(null),S=i({runtime:r,userRef:userRef,scopeEpoch:a});S.current={runtime:r,userRef:userRef,scopeEpoch:a};let x=i(h);x.current=h;let R=i(m);R.current=m;let T=n((petRef,t)=>{if(C.current)return C.current;let r=(e,t)=>(k({status:e==="cancelled"?"idle":"error",error:t,errorReason:e==="cancelled"?null:e}),/* @__PURE__ */Object.freeze({opened:false,reason:e,error:t}));if(!R.current)return Promise.resolve(r("unavailable",null));let n=e.prepare();if(!n.ok)return Promise.resolve(r(n.reason,null));let l=S.current,i=x.current;k($c);let o=(async()=>{let o,a={...v!==null?{returnTo:v}:{},...c?{entry:"chat"}:{},...t!==null?{visitRef:t.visitRef}:{},...t!==null&&t.intent!==null&&t.intent!==void 0?{intent:t.intent}:{}},s=Object.keys(a).length===0?void 0:a,u=petRef===void 0?p:petRef;try{o=await(s===void 0?i.createHandoff(u):i.createHandoff(u,s))}catch{return e.abandon(n.value),r("unknown",null)}let d=S.current;if(d.runtime!==l.runtime||d.userRef!==l.userRef||d.scopeEpoch!==l.scopeEpoch)return e.abandon(n.value),r("cancelled",null);if(!o.ok)return e.abandon(n.value),r(vetVisitErrorReasonOf(o.error),o.error);let f=await e.finish(n.value,o.value);return f!==null?r(f,null):(k(Nc),/* @__PURE__ */Object.freeze(o.value.flowId===void 0?{opened:true}:{opened:true,flowId:o.value.flowId}))})().finally(()=>{C.current===o&&(C.current=null)});return C.current=o,o},[e,p,v,c]),_=n((petRef,e)=>{if(!R.current)return k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}));let t=petRef===void 0?p:petRef,r={...t!==null?{petRef:t}:{},...d!==null?{usState:d}:{},...e!==null&&"consultId"in e?{consultId:e.consultId}:{},...e!==null&&"visitRef"in e?{visitRef:e.visitRef,intent:e.intent}:{}};return wc(r)===null?(k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}))):(k(Nc),Promise.resolve(/* @__PURE__ */Object.freeze({opened:true})))},[p,d]),z=n(petRef=>f?T(petRef,null):_(petRef,null),[f,T,_]),I=n((e,t)=>f?T(void 0,{visitRef:e,intent:t??null}):_(void 0,{visitRef:e,intent:t??null}),[f,T,_]),P=n(e=>f?T(void 0,null):_(void 0,{consultId:e.trim()}),[f,T,_]);return{available:m,isPending:s.isPending||(y?.pending??false),status:w.status,error:w.error,errorReason:w.errorReason,open:z,openVisit:I,joinVisit:P}}var qc=e=>w.openURL(e);function useVetVisit(e={}){let{openUrl:t,...r}=e,n=l(()=>{let e=t??qc;return{prepare:()=>({ok:true,value:null}),async finish(t,r){try{return await e(r.url),null}catch{return"openFailed"}},abandon:()=>{}}},[t]);return Vc(n,r)}var Gc=44,Kc=.6;function VetVisitButtonCore(e){let{petRef:petRef,label:t,openUrl:r,onOpened:n,onError:o,style:a,labelStyle:s,controller:u,returnTo:d,usState:c,entry:p,visitRef:f,intent:h,onStartInApp:g,prefer:b}=e,y=b==="redirect",m=useVetVisit({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...petRef!==void 0?{petRef:petRef}:{},...r!==void 0?{openUrl:r}:{},...u!==void 0?{controller:u}:{},prefer:y?"redirect":"in-app"}),v=useEverfurTheme(),w=l(()=>Yc(v),[v]),k=i(false);if(!m.available)/* @__PURE__ */
117
118
  return j(D,{children:[null,
118
- /* @__PURE__ */A(TelevetHostOutlet,{})]});let S=m.status==="opening",x=t??lc.visitButton;/* @__PURE__ */
119
+ /* @__PURE__ */A(TelevetHostOutlet,{})]});let S=m.status==="opening",x=t??pc.visitButton;/* @__PURE__ */
119
120
  return j(D,{children:[
120
- /* @__PURE__ */A(C,{onPress:()=>{if(!(S||k.current)){if(!y){let e={...petRef!==void 0?{petRef:petRef}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:h??null}:{}};pc(e,g)===null&&Gr(o,"unavailable",null);return}k.current=true,(f==null?m.open():m.openVisit(f,h??null)).then(e=>{e.opened?Gr(n,e.flowId??null):e.reason!=="cancelled"&&Gr(o,e.reason,e.error)}).finally(()=>{k.current=false})}},accessibilityRole:"button",accessibilityLabel:x,accessibilityState:{busy:S,disabled:S},style:[w.button,S?w.busy:null,a],children:/* @__PURE__ */A(Text,{style:[w.label,s],children:x})}),
121
- /* @__PURE__ */A(TelevetHostOutlet,{})]})}function Wc(e){let{color:t,space:r,radius:n,type:l,slots:i}=e;return g.create({button:{minHeight:Bc,minWidth:Bc,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...Qo(i.vetVisitButton)},busy:{opacity:Hc},label:{...face(e,"medium"),color:t.onPrimary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.snug,...Jo(i.vetVisitButton)}})}function Nc(e){let[t,r]=o(null);return{shown:e!==null&&t!==e,onError:()=>r(e)}}function BrandImage({uri:e,label:t,decorative:r=false,style:n,resizeMode:l="contain",fallback:i=null,onError:o,testID:a}){let s=Nc(e);if(e===null||!s.shown)return i;let u=r?{accessible:false,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}:{accessible:true,accessibilityRole:"image",...t===void 0?{}:{accessibilityLabel:t}};/* @__PURE__ */
122
- return A(z,{source:{uri:e},style:n,resizeMode:l,...u,onError:()=>{s.onError(),o?.()},...a===void 0?{}:{testID:a}})}function BrandLogo({logoUrl:e,name:t,barStyle:r,logoStyle:n,testID:l}){let i=Nc(e);return e===null||!i.shown?null:/* @__PURE__ */A(v,{style:r,...l===void 0?{}:{testID:l},children:/* @__PURE__ */A(z,{source:{uri:e},style:n,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:i.onError})})}var Uc=/* @__PURE__ */Object.freeze({row:null,leading:null,trailing:null}),$c=/* @__PURE__ */Object.freeze({leading:void 0,trailing:void 0});function Vc(e,t,r){if(e.row===null||e.leading===null||e.trailing===null)return $c;let n=Math.abs(e.leading-e.trailing);if(n<.5)return $c;let l=e.row-t-e.leading-e.trailing,i=Math.min(n,Math.max(0,l-r));return i<.5?$c:e.leading<e.trailing?{leading:e.leading+i,trailing:void 0}:{leading:void 0,trailing:e.trailing+i}}function qc(e,t,r){let n=e[t];return n!==null&&Math.abs(n-r)<.5?e:{...e,[t]:r}}function Gc(e){return[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}function Kc(e){if(e.brightness!=="light")return false;let t=ce.color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t),l=new Set(Gc(t));return n(r.brand,t.brand)&&n(r.accent,t.accent)&&Gc(r).every(e=>l.has(e))}function Yc(e){let t=(e.brightness==="dark"?fe:ce).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 Qc(e){return canonicalPetSpecies(e)==="cat"?"cat":"dog"}function Zc(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}function Jc(e){let t=Zc(e.ageYears),r=Qc(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return`${r} · ${n}`}var Xc=/* @__PURE__ */Object.freeze([
121
+ /* @__PURE__ */A(C,{onPress:()=>{if(!(S||k.current)){if(!y){let e={...petRef!==void 0?{petRef:petRef}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:h??null}:{}};wc(e,g)===null&&Yr(o,"unavailable",null);return}k.current=true,(f==null?m.open():m.openVisit(f,h??null)).then(e=>{e.opened?Yr(n,e.flowId??null):e.reason!=="cancelled"&&Yr(o,e.reason,e.error)}).finally(()=>{k.current=false})}},accessibilityRole:"button",accessibilityLabel:x,accessibilityState:{busy:S,disabled:S},style:[w.button,S?w.busy:null,a],children:/* @__PURE__ */A(Text,{style:[w.label,s],children:x})}),
122
+ /* @__PURE__ */A(TelevetHostOutlet,{})]})}function Yc(e){let{color:t,space:r,radius:n,type:l,slots:i}=e;return g.create({button:{minHeight:Gc,minWidth:Gc,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...Jo(i.vetVisitButton)},busy:{opacity:Kc},label:{...face(e,"medium"),color:t.onPrimary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.snug,...ea(i.vetVisitButton)}})}function Qc(e){let[t,r]=o(null);return{shown:e!==null&&t!==e,onError:()=>r(e)}}function BrandImage({uri:e,label:t,decorative:r=false,style:n,resizeMode:l="contain",fallback:i=null,onError:o,testID:a}){let s=Qc(e);if(e===null||!s.shown)return i;let u=r?{accessible:false,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}:{accessible:true,accessibilityRole:"image",...t===void 0?{}:{accessibilityLabel:t}};/* @__PURE__ */
123
+ return A(z,{source:{uri:e},style:n,resizeMode:l,...u,onError:()=>{s.onError(),o?.()},...a===void 0?{}:{testID:a}})}function BrandLogo({logoUrl:e,name:t,barStyle:r,logoStyle:n,testID:l}){let i=Qc(e);return e===null||!i.shown?null:/* @__PURE__ */A(v,{style:r,...l===void 0?{}:{testID:l},children:/* @__PURE__ */A(z,{source:{uri:e},style:n,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:i.onError})})}var Zc=/* @__PURE__ */Object.freeze({row:null,leading:null,trailing:null}),Jc=/* @__PURE__ */Object.freeze({leading:void 0,trailing:void 0});function Xc(e,t,r){if(e.row===null||e.leading===null||e.trailing===null)return Jc;let n=Math.abs(e.leading-e.trailing);if(n<.5)return Jc;let l=e.row-t-e.leading-e.trailing,i=Math.min(n,Math.max(0,l-r));return i<.5?Jc:e.leading<e.trailing?{leading:e.leading+i,trailing:void 0}:{leading:void 0,trailing:e.trailing+i}}function ep(e,t,r){let n=e[t];return n!==null&&Math.abs(n-r)<.5?e:{...e,[t]:r}}function tp(e){return[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}function rp(e){if(e.brightness!=="light")return false;let t=ce.color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t),l=new Set(tp(t));return n(r.brand,t.brand)&&n(r.accent,t.accent)&&tp(r).every(e=>l.has(e))}function np(e){let t=(e.brightness==="dark"?fe:ce).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 lp(e){return canonicalPetSpecies(e)==="cat"?"cat":"dog"}function ip(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}function op(e){let t=ip(e.ageYears),r=lp(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return`${r} · ${n}`}var ap=/* @__PURE__ */Object.freeze([
123
124
  /* @__PURE__ */Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),
124
125
  /* @__PURE__ */Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),
125
126
  /* @__PURE__ */Object.freeze({background:"#fbc558",foreground:"#10462e"}),
126
127
  /* @__PURE__ */Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),
127
128
  /* @__PURE__ */Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),
128
- /* @__PURE__ */Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function ep(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return Xc[t%Xc.length]}function tp(e){let t=(e??"").trim();return(Array.from(t)[0]??"?").toUpperCase()}function rp(e){return{...ep(e.petRef),initial:tp(e.name)}}function np(e,t,r){let n=rp(e);return t?n:{background:r.fill,foreground:r.ink,initial:n.initial}}function lp(e){return Math.max(12,Math.round(e*.42))}function PetDisc({pet:e,size:t,ringStroke:r}){let n=useEverfurTheme(),i=l(()=>ip(n),[n]),o=t-r*2,a=e===null?null:np(e,Kc(n),{fill:n.color.highlight,ink:n.color.onHighlight}),s=lp(o);/* @__PURE__ */
129
- return A(Ring,{size:t,strokeWidth:r,color:n.color.mark,children:/* @__PURE__ */A(v,{style:[i.disc,{width:o,height:o,borderRadius:o/2},a===null?i.discEmpty:{backgroundColor:a.background}],children:/* @__PURE__ */A(Text,{tier:"badge",style:[i.letter,{fontSize:s,lineHeight:Math.round(s*1.2),color:a===null?n.color.text.muted:a.foreground}],children:a===null?tp(null):a.initial})})})}function ip(e){return g.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...face(e,"bold"),textAlign:"center",includeFontPadding:false}})}function op(e,t){let{borderRadius:r,...n}=Qo(e,t);return r===void 0?n:{...n,borderTopLeftRadius:r,borderTopRightRadius:r}}function ap(e,t){let{backgroundColor:r,borderColor:n,borderWidth:l,borderRadius:i}=Qo(e,t);return{...r===void 0?{}:{backgroundColor:r},...n===void 0?{}:{borderRightColor:n,borderRightWidth:l??1},...i===void 0?{}:{borderTopRightRadius:i,borderBottomRightRadius:i}}}var sp=48,up=2,dp=320,cp="80%",pp="rgba(17,17,17,0.45)",fp=18,hp=22,gp=12,bp=.4,yp=44;function mp(e){return e?.name?.trim()||He.yourPet}function PetSwitcherSheet({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:i=null,onClose:o}){let a=useEverfurTheme(),s=l(()=>vp(a),[a]),u=Te();return e?/* @__PURE__ */A(R,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:o,children:/* @__PURE__ */j(v,{style:s.root,children:[
130
- /* @__PURE__ */A(C,{style:ps,onPress:o,accessibilityRole:"button",accessibilityLabel:He.close,children:/* @__PURE__ */A(v,{style:s.backdrop})}),
129
+ /* @__PURE__ */Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function sp(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return ap[t%ap.length]}function up(e){let t=(e??"").trim();return(Array.from(t)[0]??"?").toUpperCase()}function dp(e){return{...sp(e.petRef),initial:up(e.name)}}function cp(e,t,r){let n=dp(e);return t?n:{background:r.fill,foreground:r.ink,initial:n.initial}}function pp(e){return Math.max(12,Math.round(e*.42))}function PetDisc({pet:e,size:t,ringStroke:r}){let n=useEverfurTheme(),i=l(()=>fp(n),[n]),o=t-r*2,a=e===null?null:cp(e,rp(n),{fill:n.color.highlight,ink:n.color.onHighlight}),s=pp(o);/* @__PURE__ */
130
+ return A(Ring,{size:t,strokeWidth:r,color:n.color.mark,children:/* @__PURE__ */A(v,{style:[i.disc,{width:o,height:o,borderRadius:o/2},a===null?i.discEmpty:{backgroundColor:a.background}],children:/* @__PURE__ */A(Text,{tier:"badge",style:[i.letter,{fontSize:s,lineHeight:Math.round(s*1.2),color:a===null?n.color.text.muted:a.foreground}],children:a===null?up(null):a.initial})})})}function fp(e){return g.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...face(e,"bold"),textAlign:"center",includeFontPadding:false}})}function hp(e,t){let{borderRadius:r,...n}=Jo(e,t);return r===void 0?n:{...n,borderTopLeftRadius:r,borderTopRightRadius:r}}function gp(e,t){let{backgroundColor:r,borderColor:n,borderWidth:l,borderRadius:i}=Jo(e,t);return{...r===void 0?{}:{backgroundColor:r},...n===void 0?{}:{borderRightColor:n,borderRightWidth:l??1},...i===void 0?{}:{borderTopRightRadius:i,borderBottomRightRadius:i}}}var bp=48,yp=2,mp=320,vp="80%",wp="rgba(17,17,17,0.45)",kp=18,Cp=22,Sp=12,xp=.4,Rp=44;function Tp(e){return e?.name?.trim()||Ne.yourPet}function PetSwitcherSheet({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:i=null,onClose:o}){let a=useEverfurTheme(),s=l(()=>_p(a),[a]),u=Te();return e?/* @__PURE__ */A(R,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:o,children:/* @__PURE__ */j(v,{style:s.root,children:[
131
+ /* @__PURE__ */A(C,{style:hs,onPress:o,accessibilityRole:"button",accessibilityLabel:Ne.close,children:/* @__PURE__ */A(v,{style:s.backdrop})}),
131
132
  /* @__PURE__ */j(v,{style:_e(s.panel,u),accessibilityViewIsModal:true,children:[
132
- /* @__PURE__ */A(Text,{tier:"heading",style:s.title,accessibilityRole:"header",children:He.yourPets}),
133
- /* @__PURE__ */A(T,{style:s.list,contentContainerStyle:s.listContent,showsVerticalScrollIndicator:true,children:t.map(e=>{let t=e.petRef===r,l=mp(e),i=Jc(e);/* @__PURE__ */
134
- return j(PressScale,{accessibilityRole:"button",accessibilityLabel:We(t?He.petCurrentlyActive:He.switchToPet,{name:l}),accessibilityState:{selected:t},style:[s.row,t?s.rowActive:null],onPress:()=>n(e.petRef),children:[
135
- /* @__PURE__ */A(PetDisc,{pet:e,size:sp,ringStroke:up}),
133
+ /* @__PURE__ */A(Text,{tier:"heading",style:s.title,accessibilityRole:"header",children:Ne.yourPets}),
134
+ /* @__PURE__ */A(T,{style:s.list,contentContainerStyle:s.listContent,showsVerticalScrollIndicator:true,children:t.map(e=>{let t=e.petRef===r,l=Tp(e),i=op(e);/* @__PURE__ */
135
+ return j(PressScale,{accessibilityRole:"button",accessibilityLabel:Ue(t?Ne.petCurrentlyActive:Ne.switchToPet,{name:l}),accessibilityState:{selected:t},style:[s.row,t?s.rowActive:null],onPress:()=>n(e.petRef),children:[
136
+ /* @__PURE__ */A(PetDisc,{pet:e,size:bp,ringStroke:yp}),
136
137
  /* @__PURE__ */j(v,{style:s.copy,children:[
137
138
  /* @__PURE__ */A(Text,{style:s.name,numberOfLines:1,children:l}),
138
- /* @__PURE__ */A(Text,{tier:"compact",style:s.meta,numberOfLines:1,children:t?`${He.activePrefix}${i}`:i})]}),t?/* @__PURE__ */A(CheckGlyph,{size:fp,color:a.color.brandInk}):null]},e.petRef)})}),i!==null?/* @__PURE__ */j(PressScale,{accessibilityRole:"button",accessibilityLabel:He.addAnotherPet,style:s.addRow,onPress:i,children:[
139
+ /* @__PURE__ */A(Text,{tier:"compact",style:s.meta,numberOfLines:1,children:t?`${Ne.activePrefix}${i}`:i})]}),t?/* @__PURE__ */A(CheckGlyph,{size:kp,color:a.color.brandInk}):null]},e.petRef)})}),i!==null?/* @__PURE__ */j(PressScale,{accessibilityRole:"button",accessibilityLabel:Ne.addAnotherPet,style:s.addRow,onPress:i,children:[
139
140
  /* @__PURE__ */A(v,{style:s.addDisc,children:/* @__PURE__ */A(Text,{tier:"control",style:s.addPlus,children:"+"})}),
140
- /* @__PURE__ */A(Text,{style:s.addLabel,children:He.addAnotherPet})]}):null,
141
- /* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:He.close,containerStyle:s.closeSlot,style:s.closeButton,onPress:o,children:/* @__PURE__ */A(Text,{tier:"control",style:s.closeText,children:He.close})})]})]})}):null}function vp(e){let t=e.color,r=e.radius,n=Jo(e.slots.dialog);return g.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:pp},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:hp,borderTopRightRadius:hp,gap:14,maxHeight:cp,...op(e.slots.dialog)},title:{...headingFace(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk,...n},list:{maxHeight:dp,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:yp,paddingHorizontal:8},addDisc:{width:sp,height:sp,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:up,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,...n},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:bp},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:gp,backgroundColor:t.brandSoft},closeText:{...face(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:bp}})}var wp=44,kp=36,Cp=22,Sp=20,xp=9,Rp=1.5,Tp=6,_p=35,zp=1.75,Ip=12.4,Pp=.5,Fp=8,Lp=28,Ep=160,Op=16,Ap=8;function jp(e,petRef){return nc(e,petRef)}function ChatHeader({pets:e,petRef:petRef,historyUnread:t,onOpenHistory:r,onNewChat:i,onPetChange:a,onAddPet:s,vet:u,textingEntry:d=null}){let c=useEverfurTheme(),p=l(()=>Dp(c),[c]),[f,h]=o(false),g=jp(e.pets,petRef),b=g!==null&&(e.pets.length>=2||s!==void 0),y=petRef??g?.petRef??null,m=mp(g),[w,k]=o(Uc),C=n(e=>t=>{let r=t.nativeEvent.layout.width;k(t=>qc(t,e,r))},[]),S=l(()=>C("row"),[C]),x=l(()=>C("leading"),[C]),R=l(()=>C("trailing"),[C]),T=2*Op+2*(c.slots.header?.borderColor!==void 0?1:0)+2*Ap,_=Vc(w,T,Ep),z=t=>{h(false),e.setActivePet(t),Gr(a,t)},I=s===void 0?null:()=>{h(false),Gr(s)};/* @__PURE__ */
141
+ /* @__PURE__ */A(Text,{style:s.addLabel,children:Ne.addAnotherPet})]}):null,
142
+ /* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Ne.close,containerStyle:s.closeSlot,style:s.closeButton,onPress:o,children:/* @__PURE__ */A(Text,{tier:"control",style:s.closeText,children:Ne.close})})]})]})}):null}function _p(e){let t=e.color,r=e.radius,n=ea(e.slots.dialog);return g.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:wp},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:Cp,borderTopRightRadius:Cp,gap:14,maxHeight:vp,...hp(e.slots.dialog)},title:{...headingFace(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk,...n},list:{maxHeight:mp,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:Rp,paddingHorizontal:8},addDisc:{width:bp,height:bp,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:yp,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,...n},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:xp},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:Sp,backgroundColor:t.brandSoft},closeText:{...face(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:xp}})}var zp=44,Ip=36,Pp=22,Fp=20,Lp=9,Ep=1.5,Op=6,Ap=35,jp=1.75,Dp=12.4,Mp=.5,Bp=8,Hp=28,Wp=160,Np=16,Up=8;function $p(e,petRef){return cc(e,petRef)}function ChatHeader({pets:e,petRef:petRef,historyUnread:t,onOpenHistory:r,onNewChat:i,onPetChange:a,onAddPet:s,vet:u,textingEntry:d=null}){let c=useEverfurTheme(),p=l(()=>Vp(c),[c]),[f,h]=o(false),g=$p(e.pets,petRef),b=g!==null&&(e.pets.length>=2||s!==void 0),y=petRef??g?.petRef??null,m=Tp(g),[w,k]=o(Zc),C=n(e=>t=>{let r=t.nativeEvent.layout.width;k(t=>ep(t,e,r))},[]),S=l(()=>C("row"),[C]),x=l(()=>C("leading"),[C]),R=l(()=>C("trailing"),[C]),T=2*Np+2*(c.slots.header?.borderColor!==void 0?1:0)+2*Up,_=Xc(w,T,Wp),z=t=>{h(false),e.setActivePet(t),Yr(a,t)},I=s===void 0?null:()=>{h(false),Yr(s)};/* @__PURE__ */
142
143
  return j(D,{children:[
143
144
  /* @__PURE__ */j(v,{style:p.row,onLayout:S,children:[
144
- /* @__PURE__ */A(v,{style:[p.leading,_.leading===void 0?null:{minWidth:_.leading}],children:/* @__PURE__ */j(v,{style:p.sideContent,onLayout:x,children:[i!==void 0?/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Fi.newChat,containerStyle:p.iconSlot,style:p.iconButton,onPress:i,children:/* @__PURE__ */A(EditGlyph,{size:Sp,color:c.slots.header?.textColor??c.color.text.primary,strokeWidth:2})}):null,
145
- /* @__PURE__ */j(PressScale,{accessibilityRole:"button",accessibilityLabel:t?`${He.openHistoryNative}${He.newReplySuffix}`:He.openHistoryNative,containerStyle:p.iconSlot,style:p.iconButton,onPress:r,children:[
146
- /* @__PURE__ */A(MenuGlyph,{size:Cp,color:c.slots.header?.textColor??c.color.text.primary,strokeWidth:2}),t?/* @__PURE__ */A(v,{style:p.unreadDot,pointerEvents:"none"}):null]})]})}),
145
+ /* @__PURE__ */A(v,{style:[p.leading,_.leading===void 0?null:{minWidth:_.leading}],children:/* @__PURE__ */j(v,{style:p.sideContent,onLayout:x,children:[i!==void 0?/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Ei.newChat,containerStyle:p.iconSlot,style:p.iconButton,onPress:i,children:/* @__PURE__ */A(EditGlyph,{size:Fp,color:c.slots.header?.textColor??c.color.text.primary,strokeWidth:2})}):null,
146
+ /* @__PURE__ */j(PressScale,{accessibilityRole:"button",accessibilityLabel:t?`${Ne.openHistoryNative}${Ne.newReplySuffix}`:Ne.openHistoryNative,containerStyle:p.iconSlot,style:p.iconButton,onPress:r,children:[
147
+ /* @__PURE__ */A(MenuGlyph,{size:Pp,color:c.slots.header?.textColor??c.color.text.primary,strokeWidth:2}),t?/* @__PURE__ */A(v,{style:p.unreadDot,pointerEvents:"none"}):null]})]})}),
147
148
  /* @__PURE__ */A(v,{style:p.centre,pointerEvents:"box-none",children:/* @__PURE__ */A(BrandLogo,{logoUrl:c.meta.logoUrl,name:c.meta.displayName,barStyle:p.logoBar,logoStyle:p.logo})}),
148
149
  /* @__PURE__ */A(v,{style:[p.trailing,_.trailing===void 0?null:{minWidth:_.trailing}],children:/* @__PURE__ */j(v,{style:p.trailingContent,onLayout:R,children:[y===null?null:/* @__PURE__ */A(VetVisitButtonCore,{entry:"chat",petRef:y,...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}),
149
- /* @__PURE__ */A(v,{style:p.right,children:b?/* @__PURE__ */j(PressScale,{accessibilityRole:"button",accessibilityLabel:We(He.switchActivePet,{name:m}),containerStyle:p.avatarSlot,style:p.avatarWrap,onPress:()=>h(true),children:[
150
- /* @__PURE__ */A(PetDisc,{pet:g,size:_p,ringStroke:zp}),
151
- /* @__PURE__ */A(v,{style:p.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */A(PlusGlyph,{size:Fp,color:c.color.brandInk,strokeWidth:2})})]}):e.loading&&g===null?
152
- /* @__PURE__ */A(v,{style:p.avatarWrap,accessible:true,accessibilityLabel:He.yourPet,children:/* @__PURE__ */A(Ring,{size:_p,strokeWidth:zp,color:c.color.mark,children:/* @__PURE__ */A(v,{style:p.placeholderDisc})})}):/* @__PURE__ */A(v,{style:p.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:g===null?He.yourPet:m,children:/* @__PURE__ */A(PetDisc,{pet:g,size:_p,ringStroke:zp})})})]})}),
153
- /* @__PURE__ */A(PetSwitcherSheet,{visible:f,pets:e.pets,activePetRef:g?.petRef??null,onSelect:z,onAddPet:I,onClose:()=>h(false)})]}),d===null?null:/* @__PURE__ */A(TextingEntryRow,{entry:d,place:"header"})]})}function TextingEntryRow({entry:e,place:t}){let r=useEverfurTheme(),n=l(()=>Dp(r),[r]);/* @__PURE__ */
154
- return A(v,{style:t==="header"?n.textingEntryRowHeader:n.textingEntryRowThread,children:/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,containerStyle:n.textingEntrySlot,style:n.vetEntry,onPress:e.onOpen,testID:"everfur-texting-entry",children:/* @__PURE__ */A(Text,{tier:"control",style:n.vetEntryLabel,numberOfLines:1,children:e.label})})})}function Dp(e){let t=e.color,r=_p-zp*2,n=e.slots.header;return g.create({vetEntry:{minHeight:wp,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:g.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:Op,paddingBottom:10,backgroundColor:n?.backgroundColor??t.surface},textingEntryRowThread:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:Op,paddingTop:e.space.md,paddingBottom:e.space.xs},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:Op,paddingVertical:10,backgroundColor:t.surface,...Qo(n)},iconSlot:{borderRadius:kp/2},iconButton:{width:kp,height:kp,borderRadius:kp/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:Tp,right:Tp,width:xp,height:xp,borderRadius:xp,backgroundColor:t.danger,borderWidth:Rp,borderColor:n?.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:Ap,alignItems:"center",justifyContent:"center"},logoBar:{alignSelf:"stretch",alignItems:"center"},logo:{height:Lp,width:Ep,maxWidth:"100%"},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:_p/2},avatarWrap:{width:_p,height:_p,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:Ip,height:Ip,borderRadius:Ip/2,borderWidth:Pp,borderColor:t.mark,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}var Mp=/* @__PURE__ */Object.freeze([
155
- /* @__PURE__ */Object.freeze({key:"inaccurate",label:He.feedbackReasonInaccurate,feedbackType:"wrong"}),
156
- /* @__PURE__ */Object.freeze({key:"outdated",label:He.feedbackReasonOutdated,feedbackType:"outdated"}),
157
- /* @__PURE__ */Object.freeze({key:"unsafe",label:He.feedbackReasonUnsafe,feedbackType:"dangerous"}),
158
- /* @__PURE__ */Object.freeze({key:"unclear",label:He.feedbackReasonUnclear,feedbackType:"unclear"}),
159
- /* @__PURE__ */Object.freeze({key:"other",label:He.feedbackReasonOther,feedbackType:"not_helpful"})]),Bp=/* @__PURE__ */Object.freeze([
160
- /* @__PURE__ */Object.freeze({sentiment:"up",label:He.feedbackHelpful}),
161
- /* @__PURE__ */Object.freeze({sentiment:"down",label:He.feedbackNotHelpful})]);function Hp(e){switch(e){case"up":return"helpful";case"neutral":return"neutral";case"down":return"not_helpful"}}function Wp(e,t){if(e==="down"&&t!==null){let e=Mp.find(e=>e.key===t);if(e!==void 0)return e.feedbackType}return Hp(e)}var Np=44,Up="rgba(17,17,17,0.55)",$p=26,Vp=36,qp=4,Gp=20,Kp=38,Yp=18,Qp=12;function FeedbackReasons({visible:e,onSubmit:t,onSkip:r}){let n=useEverfurTheme(),i=l(()=>Zp(n),[n]),a=Te(),[s,u]=o(null),[d,c]=o(""),[p,f]=o(false),[h,g]=o(false),y=()=>{u(null),c(""),f(false),g(false)},m=()=>{p||(y(),r())},w=async()=>{if(p)return;f(true),g(false);let e=d.trim();await t(s,e.length>0?e:null)?y():(f(false),g(true))};if(!e)return null;let S=[...d].length>na;/* @__PURE__ */
150
+ /* @__PURE__ */A(v,{style:p.right,children:b?/* @__PURE__ */j(PressScale,{accessibilityRole:"button",accessibilityLabel:Ue(Ne.switchActivePet,{name:m}),containerStyle:p.avatarSlot,style:p.avatarWrap,onPress:()=>h(true),children:[
151
+ /* @__PURE__ */A(PetDisc,{pet:g,size:Ap,ringStroke:jp}),
152
+ /* @__PURE__ */A(v,{style:p.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */A(PlusGlyph,{size:Bp,color:c.color.brandInk,strokeWidth:2})})]}):e.loading&&g===null?
153
+ /* @__PURE__ */A(v,{style:p.avatarWrap,accessible:true,accessibilityLabel:Ne.yourPet,children:/* @__PURE__ */A(Ring,{size:Ap,strokeWidth:jp,color:c.color.mark,children:/* @__PURE__ */A(v,{style:p.placeholderDisc})})}):/* @__PURE__ */A(v,{style:p.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:g===null?Ne.yourPet:m,children:/* @__PURE__ */A(PetDisc,{pet:g,size:Ap,ringStroke:jp})})})]})}),
154
+ /* @__PURE__ */A(PetSwitcherSheet,{visible:f,pets:e.pets,activePetRef:g?.petRef??null,onSelect:z,onAddPet:I,onClose:()=>h(false)})]}),d===null?null:/* @__PURE__ */A(TextingEntryRow,{entry:d,place:"header"})]})}function TextingEntryRow({entry:e,place:t}){let r=useEverfurTheme(),n=l(()=>Vp(r),[r]);/* @__PURE__ */
155
+ return A(v,{style:t==="header"?n.textingEntryRowHeader:n.textingEntryRowThread,children:/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,containerStyle:n.textingEntrySlot,style:n.vetEntry,onPress:e.onOpen,testID:"everfur-texting-entry",children:/* @__PURE__ */A(Text,{tier:"control",style:n.vetEntryLabel,numberOfLines:1,children:e.label})})})}function Vp(e){let t=e.color,r=Ap-jp*2,n=e.slots.header;return g.create({vetEntry:{minHeight:zp,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:g.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:Np,paddingBottom:10,backgroundColor:n?.backgroundColor??t.surface},textingEntryRowThread:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:Np,paddingTop:e.space.md,paddingBottom:e.space.xs},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:Np,paddingVertical:10,backgroundColor:t.surface,...Jo(n)},iconSlot:{borderRadius:Ip/2},iconButton:{width:Ip,height:Ip,borderRadius:Ip/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:Op,right:Op,width:Lp,height:Lp,borderRadius:Lp,backgroundColor:t.danger,borderWidth:Ep,borderColor:n?.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:Up,alignItems:"center",justifyContent:"center"},logoBar:{alignSelf:"stretch",alignItems:"center"},logo:{height:Hp,width:Wp,maxWidth:"100%"},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:Ap/2},avatarWrap:{width:Ap,height:Ap,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:Dp,height:Dp,borderRadius:Dp/2,borderWidth:Mp,borderColor:t.mark,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}var qp=/* @__PURE__ */Object.freeze([
156
+ /* @__PURE__ */Object.freeze({key:"inaccurate",label:Ne.feedbackReasonInaccurate,feedbackType:"wrong"}),
157
+ /* @__PURE__ */Object.freeze({key:"outdated",label:Ne.feedbackReasonOutdated,feedbackType:"outdated"}),
158
+ /* @__PURE__ */Object.freeze({key:"unsafe",label:Ne.feedbackReasonUnsafe,feedbackType:"dangerous"}),
159
+ /* @__PURE__ */Object.freeze({key:"unclear",label:Ne.feedbackReasonUnclear,feedbackType:"unclear"}),
160
+ /* @__PURE__ */Object.freeze({key:"other",label:Ne.feedbackReasonOther,feedbackType:"not_helpful"})]),Gp=/* @__PURE__ */Object.freeze([
161
+ /* @__PURE__ */Object.freeze({sentiment:"up",label:Ne.feedbackHelpful}),
162
+ /* @__PURE__ */Object.freeze({sentiment:"down",label:Ne.feedbackNotHelpful})]);function Kp(e){switch(e){case"up":return"helpful";case"neutral":return"neutral";case"down":return"not_helpful"}}function Yp(e,t){if(e==="down"&&t!==null){let e=qp.find(e=>e.key===t);if(e!==void 0)return e.feedbackType}return Kp(e)}var Qp=44,Zp="rgba(17,17,17,0.55)",Jp=26,Xp=36,ef=4,tf=20,rf=38,nf=18,lf=12;function FeedbackReasons({visible:e,onSubmit:t,onSkip:r}){let n=useEverfurTheme(),i=l(()=>of(n),[n]),a=Te(),[s,u]=o(null),[d,c]=o(""),[p,f]=o(false),[h,g]=o(false),y=()=>{u(null),c(""),f(false),g(false)},m=()=>{p||(y(),r())},w=async()=>{if(p)return;f(true),g(false);let e=d.trim();await t(s,e.length>0?e:null)?y():(f(false),g(true))};if(!e)return null;let S=[...d].length>ia;/* @__PURE__ */
162
163
  return A(R,{visible:true,transparent:true,animationType:n.motion.reducedMotion?"none":"slide",onRequestClose:m,children:/* @__PURE__ */j(k,{behavior:b.OS==="ios"?"padding":void 0,style:i.root,children:[
163
- /* @__PURE__ */A(C,{style:i.scrim,onPress:m,accessibilityRole:"button",accessibilityLabel:He.feedbackSkipA11y}),
164
+ /* @__PURE__ */A(C,{style:i.scrim,onPress:m,accessibilityRole:"button",accessibilityLabel:Ne.feedbackSkipA11y}),
164
165
  /* @__PURE__ */j(v,{style:_e(i.sheet,a),accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[
165
166
  /* @__PURE__ */A(v,{style:i.handle}),
166
167
  /* @__PURE__ */j(v,{style:i.header,children:[
167
- /* @__PURE__ */A(v,{style:i.iconBadge,children:/* @__PURE__ */A(ThumbGlyph,{size:Yp,color:n.color.brandInk,active:false,rotate:"180deg"})}),
168
+ /* @__PURE__ */A(v,{style:i.iconBadge,children:/* @__PURE__ */A(ThumbGlyph,{size:nf,color:n.color.brandInk,active:false,rotate:"180deg"})}),
168
169
  /* @__PURE__ */j(v,{style:i.headerText,children:[
169
- /* @__PURE__ */A(Text,{tier:"heading",style:i.title,accessibilityRole:"header",children:He.feedbackTitle}),
170
- /* @__PURE__ */A(Text,{style:i.subtitle,children:He.feedbackSubtitle})]})]}),
171
- /* @__PURE__ */A(v,{style:i.options,children:Mp.map(e=>{let t=s===e.key;/* @__PURE__ */
170
+ /* @__PURE__ */A(Text,{tier:"heading",style:i.title,accessibilityRole:"header",children:Ne.feedbackTitle}),
171
+ /* @__PURE__ */A(Text,{style:i.subtitle,children:Ne.feedbackSubtitle})]})]}),
172
+ /* @__PURE__ */A(v,{style:i.options,children:qp.map(e=>{let t=s===e.key;/* @__PURE__ */
172
173
  return j(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,accessibilityState:{selected:t},style:[i.option,t?i.optionSelected:null],onPress:()=>u(t=>t===e.key?null:e.key),children:[
173
174
  /* @__PURE__ */A(Text,{style:[i.optionLabel,t?i.optionLabelSelected:null],children:e.label}),
174
- /* @__PURE__ */A(v,{style:[i.radio,t?i.radioSelected:null],children:t?/* @__PURE__ */A(CheckGlyph,{size:Qp,color:n.color.surface,strokeWidth:2}):null})]},e.key)})}),
175
+ /* @__PURE__ */A(v,{style:[i.radio,t?i.radioSelected:null],children:t?/* @__PURE__ */A(CheckGlyph,{size:lf,color:n.color.surface,strokeWidth:2}):null})]},e.key)})}),
175
176
  /* @__PURE__ */j(v,{style:i.inputWrap,children:[
176
- /* @__PURE__ */A(me,{style:i.input,placeholder:He.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:He.feedbackNotesPlaceholder,value:d,onChangeText:c,multiline:true,editable:!p}),d.length>0?/* @__PURE__ */A(Text,{tier:"compact",style:[i.counter,S?i.counterOver:null],children:`${[...d].length}/${na}`}):null]}),h?/* @__PURE__ */A(Text,{style:i.failed,accessibilityRole:"alert",children:He.feedbackFailed}):null,
177
+ /* @__PURE__ */A(me,{style:i.input,placeholder:Ne.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:Ne.feedbackNotesPlaceholder,value:d,onChangeText:c,multiline:true,editable:!p}),d.length>0?/* @__PURE__ */A(Text,{tier:"compact",style:[i.counter,S?i.counterOver:null],children:`${[...d].length}/${ia}`}):null]}),h?/* @__PURE__ */A(Text,{style:i.failed,accessibilityRole:"alert",children:Ne.feedbackFailed}):null,
177
178
  /* @__PURE__ */j(v,{style:i.actions,children:[
178
- /* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:He.feedbackSubmit,accessibilityState:{busy:p,disabled:p||S},disabled:p||S,style:[i.submit,p||S?i.submitDisabled:null],onPress:()=>{w()},children:/* @__PURE__ */A(Text,{tier:"control",style:i.submitLabel,children:He.feedbackSubmit})}),
179
- /* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:He.feedbackSkipA11y,hitSlop:8,onPress:m,style:i.skip,children:/* @__PURE__ */A(Text,{tier:"control",style:i.skipLabel,children:He.feedbackSkip})})]})]})]})})}function Zp(e){let t=e.color,r=e.type,n=e.radius,l=e.slots,i=Jo(l.dialog);return g.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...ps,backgroundColor:Up},sheet:{backgroundColor:t.surface,borderTopLeftRadius:$p,borderTopRightRadius:$p,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14,...op(l.dialog)},handle:{alignSelf:"center",width:Vp,height:qp,borderRadius:qp/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:Kp,height:Kp,borderRadius:Kp/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,...i},subtitle:{...face(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted,...i},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:g.hairlineWidth,borderColor:t.controlEdge,backgroundColor:t.surface,...Qo(l.chip,g.hairlineWidth)},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.primary,...Jo(l.chip)},optionLabelSelected:{color:t.brandInk},radio:{width:Gp,height:Gp,borderRadius:Gp/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:n.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",...Qo(l.input,1),...Jo(l.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:Np,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...Qo(l.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...Jo(l.primaryButton)},skip:{minHeight:Np,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}var Jp=/* @__PURE__ */Symbol.for("everfur.sdk.rn.askHome");function Xp(){let e=globalThis,t=e[Jp];if(t!==void 0)return t;let r={factory:createContext(null),home:createContext(null)};return e[Jp]=r,r}var ef=Xp().factory,tf=Xp().home;function rf(){return u(ef)}function nf(){return u(tf)?.kit??null}function lf(){return u(tf)}var of=15,af=8;function HistoryBar({bar:e,history:t,empty:r,unread:n,extra:i}){let o=useEverfurTheme(),a=nf(),s=l(()=>a!==null?df(o,a):cf(o),[o,a]),u=t.cursor===null?t.rows.length:0,d=t=>{let r=e.renderIcon;if(r!==void 0)/* @__PURE__ */return A(HostRender,{render:()=>r(t),fallback:null});if(a===null)return null;let n=String(g.flatten(s.label).color??o.color.linkInk);return t==="history"?/* @__PURE__ */A(HistoryGlyph,{size:uf,color:n,strokeWidth:1.8}):/* @__PURE__ */A(EditGlyph,{size:uf,color:n,strokeWidth:1.8})};/* @__PURE__ */
180
- return j(v,{style:s.bar,testID:"everfur-history-bar",children:[
181
- /* @__PURE__ */j(C,{accessibilityRole:"button",accessibilityLabel:u>0?`${e.chats} ${u}`:e.chats,accessibilityState:{expanded:t.open},onPress:t.open?t.close:t.show,style:s.control,hitSlop:a!==null?sf:void 0,children:[d("history"),
182
- /* @__PURE__ */A(Text,{tier:"control",style:s.label,children:e.chats}),u>0?/* @__PURE__ */A(v,{style:s.count,children:/* @__PURE__ */A(Text,{tier:"badge",style:s.countText,children:String(u)})}):null,n?/* @__PURE__ */A(v,{style:s.dot,testID:"everfur-chat-history-bar-unread"}):null]}),e.extra??null,i??null,
183
- /* @__PURE__ */A(v,{style:s.spacer}),r?null:/* @__PURE__ */j(C,{accessibilityRole:"button",accessibilityLabel:e.newChat,onPress:t.newConversation,style:s.control,hitSlop:a!==null?sf:void 0,children:[d("edit"),
184
- /* @__PURE__ */A(Text,{tier:"control",style:s.label,children:e.newChat})]})]})}var sf=4,uf=18;function df(e,t){return{...cf(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 cf(e){let t=e.color,r=e.space;return g.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:Ns},label:{...face(e,"bold"),fontSize:of,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:af,height:af,borderRadius:af/2,backgroundColor:t.danger},spacer:{flexGrow:1}})}var pf=.88,ff=420,hf=58,gf="rgba(17,17,17,0.28)",bf=.15,yf=14,mf=12,vf=44,wf=16,kf=14,Cf=12,Sf=14,xf=8,Rf=2,Tf=.5,_f=To(bo.standard);function zf(e){return Math.min(Math.round(e*pf),ff)}function HistoryDrawer({chat:e,history:t}){let[r,l]=o(t.open),i=n(()=>l(false),[]);return t.open&&!r&&l(true),r?/* @__PURE__ */A(DrawerModal,{chat:e,history:t,onHidden:i}):null}function DrawerModal({chat:e,history:t,onHidden:r}){let n=useEverfurTheme(),o=l(()=>If(n),[n]),s=Co(),u=M(),{width:d}=E(),c=zf(d),p=t.open,f=i(null);f.current===null&&(f.current=new L.Value(s.drawerMs<=0&&p?1:0));let h=f.current;a(()=>{if(!p&&s.drawerMs<=0){r();return}let e=L.timing(h,{toValue:p?1:0,duration:s.drawerMs,easing:_f,useNativeDriver:true});return e.start(({finished:e})=>{e&&!p&&r()}),()=>e.stop()},[p,h,s.drawerMs,r]);let g=h.interpolate({inputRange:[0,1],outputRange:[-c,0]}),y=t.filtered,m=t.rows.length===0,w=t.cursor===null&&!t.loading&&t.error===null,S=m&&t.loading?/* @__PURE__ */j(v,{style:o.emptyCard,accessibilityLabel:Fi.loading,accessibilityState:{busy:true},children:[
179
+ /* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Ne.feedbackSubmit,accessibilityState:{busy:p,disabled:p||S},disabled:p||S,style:[i.submit,p||S?i.submitDisabled:null],onPress:()=>{w()},children:/* @__PURE__ */A(Text,{tier:"control",style:i.submitLabel,children:Ne.feedbackSubmit})}),
180
+ /* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Ne.feedbackSkipA11y,hitSlop:8,onPress:m,style:i.skip,children:/* @__PURE__ */A(Text,{tier:"control",style:i.skipLabel,children:Ne.feedbackSkip})})]})]})]})})}function of(e){let t=e.color,r=e.type,n=e.radius,l=e.slots,i=ea(l.dialog);return g.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...hs,backgroundColor:Zp},sheet:{backgroundColor:t.surface,borderTopLeftRadius:Jp,borderTopRightRadius:Jp,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14,...hp(l.dialog)},handle:{alignSelf:"center",width:Xp,height:ef,borderRadius:ef/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:rf,height:rf,borderRadius:rf/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,...i},subtitle:{...face(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted,...i},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:g.hairlineWidth,borderColor:t.controlEdge,backgroundColor:t.surface,...Jo(l.chip,g.hairlineWidth)},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.primary,...ea(l.chip)},optionLabelSelected:{color:t.brandInk},radio:{width:tf,height:tf,borderRadius:tf/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:n.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",...Jo(l.input,1),...ea(l.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:Qp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...Jo(l.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...ea(l.primaryButton)},skip:{minHeight:Qp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}var af=/* @__PURE__ */Symbol.for("everfur.sdk.rn.askHome");function sf(){let e=globalThis,t=e[af];if(t!==void 0)return t;let r={factory:createContext(null),home:createContext(null)};return e[af]=r,r}var uf=sf().factory,df=sf().home;function cf(){return u(uf)}function pf(){return u(df)?.kit??null}function ff(){return u(df)}var hf=15,gf=8;function HistoryBar({bar:e,history:t,empty:r,unread:n,extra:i}){let o=useEverfurTheme(),a=pf(),s=Ed(),u=l(()=>s!==null?{...vf(o),...s.paint.history}:a!==null?mf(o,a):vf(o),[o,a,s]),d=s===null&&t.cursor===null?t.rows.length:0,c=s!==null||a!==null,p=t=>{let r=e.renderIcon;if(r!==void 0)/* @__PURE__ */return A(HostRender,{render:()=>r(t),fallback:null});if(!c)return null;let n=String(g.flatten(u.label).color??o.color.linkInk);return s!==null?/* @__PURE__ */A(s.paint.Icon,{name:t==="history"?"clock":"pen",size:20,color:n}):t==="history"?/* @__PURE__ */A(HistoryGlyph,{size:yf,color:n,strokeWidth:1.8}):/* @__PURE__ */A(EditGlyph,{size:yf,color:n,strokeWidth:1.8})};/* @__PURE__ */
181
+ return j(v,{style:u.bar,testID:"everfur-history-bar",children:[
182
+ /* @__PURE__ */j(C,{accessibilityRole:"button",accessibilityLabel:d>0?`${e.chats} ${d}`:e.chats,accessibilityState:{expanded:t.open},onPress:t.open?t.close:t.show,style:u.control,hitSlop:c?bf:void 0,children:[p("history"),
183
+ /* @__PURE__ */A(Text,{tier:"control",style:u.label,children:e.chats}),d>0?/* @__PURE__ */A(v,{style:u.count,children:/* @__PURE__ */A(Text,{tier:"badge",style:u.countText,children:String(d)})}):null,n?/* @__PURE__ */A(v,{style:u.dot,testID:"everfur-chat-history-bar-unread"}):null]}),e.extra??null,i??null,
184
+ /* @__PURE__ */A(v,{style:u.spacer}),r?null:/* @__PURE__ */j(C,{accessibilityRole:"button",accessibilityLabel:e.newChat,onPress:t.newConversation,style:u.control,hitSlop:c?bf:void 0,children:[p("edit"),
185
+ /* @__PURE__ */A(Text,{tier:"control",style:u.label,children:e.newChat})]})]})}var bf=4,yf=18;function mf(e,t){return{...vf(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 vf(e){let t=e.color,r=e.space;return g.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:$s},label:{...face(e,"bold"),fontSize:hf,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:gf,height:gf,borderRadius:gf/2,backgroundColor:t.danger},spacer:{flexGrow:1}})}var wf=.88,kf=420,Cf=58,Sf="rgba(17,17,17,0.28)",xf=.15,Rf=14,Tf=12,_f=44,zf=16,If=14,Pf=12,Ff=14,Lf=8,Ef=2,Of=.5,Af=zo(mo.standard);function jf(e){return Math.min(Math.round(e*wf),kf)}function HistoryDrawer({chat:e,history:t}){let[r,l]=o(t.open),i=n(()=>l(false),[]);return t.open&&!r&&l(true),r?/* @__PURE__ */A(DrawerModal,{chat:e,history:t,onHidden:i}):null}function DrawerModal({chat:e,history:t,onHidden:r}){let n=useEverfurTheme(),o=l(()=>Df(n),[n]),s=xo(),u=M(),{width:d}=E(),c=jf(d),p=t.open,f=i(null);f.current===null&&(f.current=new L.Value(s.drawerMs<=0&&p?1:0));let h=f.current;a(()=>{if(!p&&s.drawerMs<=0){r();return}let e=L.timing(h,{toValue:p?1:0,duration:s.drawerMs,easing:Af,useNativeDriver:true});return e.start(({finished:e})=>{e&&!p&&r()}),()=>e.stop()},[p,h,s.drawerMs,r]);let g=h.interpolate({inputRange:[0,1],outputRange:[-c,0]}),y=t.filtered,m=t.rows.length===0,w=t.cursor===null&&!t.loading&&t.error===null,S=m&&t.loading?/* @__PURE__ */j(v,{style:o.emptyCard,accessibilityLabel:Ei.loading,accessibilityState:{busy:true},children:[
185
186
  /* @__PURE__ */A(_,{color:o.emptyTitle.color}),
186
- /* @__PURE__ */A(Text,{style:o.emptyBody,children:Fi.loading})]}):m&&t.error!==null?/* @__PURE__ */j(v,{style:o.emptyCard,children:[
187
- /* @__PURE__ */A(Text,{style:o.emptyTitle,accessibilityRole:"alert",children:Fi.loadFailed}),
187
+ /* @__PURE__ */A(Text,{style:o.emptyBody,children:Ei.loading})]}):m&&t.error!==null?/* @__PURE__ */j(v,{style:o.emptyCard,children:[
188
+ /* @__PURE__ */A(Text,{style:o.emptyTitle,accessibilityRole:"alert",children:Ei.loadFailed}),
188
189
  /* @__PURE__ */A(Text,{style:o.emptyBody,children:t.error}),
189
- /* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Fi.retry,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load()},children:/* @__PURE__ */A(Text,{tier:"control",style:o.retryText,children:Fi.retry})})]}):t.emptyKind==="empty"?/* @__PURE__ */j(v,{style:o.emptyCard,children:[
190
- /* @__PURE__ */A(Text,{style:o.emptyTitle,children:Fi.empty}),
191
- /* @__PURE__ */A(Text,{style:o.emptyBody,children:Fi.emptyBody})]}):
192
- /* @__PURE__ */A(Text,{style:o.noMatch,children:Fi.noMatch}),x=!t.searching&&t.loadingMore?/* @__PURE__ */A(v,{style:o.loadMoreFooter,children:/* @__PURE__ */A(Text,{style:o.loadMoreLabel,children:Fi.loadingMore})}):null;/* @__PURE__ */
190
+ /* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Ei.retry,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load()},children:/* @__PURE__ */A(Text,{tier:"control",style:o.retryText,children:Ei.retry})})]}):t.emptyKind==="empty"?/* @__PURE__ */j(v,{style:o.emptyCard,children:[
191
+ /* @__PURE__ */A(Text,{style:o.emptyTitle,children:Ei.empty}),
192
+ /* @__PURE__ */A(Text,{style:o.emptyBody,children:Ei.emptyBody})]}):
193
+ /* @__PURE__ */A(Text,{style:o.noMatch,children:Ei.noMatch}),x=!t.searching&&t.loadingMore?/* @__PURE__ */A(v,{style:o.loadMoreFooter,children:/* @__PURE__ */A(Text,{style:o.loadMoreLabel,children:Ei.loadingMore})}):null;/* @__PURE__ */
193
194
  return A(R,{visible:true,transparent:true,animationType:"none",onRequestClose:t.close,children:/* @__PURE__ */j(v,{style:o.root,children:[
194
- /* @__PURE__ */A(C,{style:ps,onPress:t.close,accessibilityRole:"button",accessibilityLabel:Fi.closeA11y,children:/* @__PURE__ */A(L.View,{style:[o.backdrop,{opacity:h}]})}),
195
- /* @__PURE__ */A(L.View,{style:[o.panel,{width:c,paddingTop:Math.max(hf,u.top+n.space.md),transform:[{translateX:g}]}],accessibilityViewIsModal:true,children:/* @__PURE__ */j(k,{style:o.keyboardAvoider,behavior:b.OS==="ios"?"padding":"height",children:[
195
+ /* @__PURE__ */A(C,{style:hs,onPress:t.close,accessibilityRole:"button",accessibilityLabel:Ei.closeA11y,children:/* @__PURE__ */A(L.View,{style:[o.backdrop,{opacity:h}]})}),
196
+ /* @__PURE__ */A(L.View,{style:[o.panel,{width:c,paddingTop:Math.max(Cf,u.top+n.space.md),transform:[{translateX:g}]}],accessibilityViewIsModal:true,children:/* @__PURE__ */j(k,{style:o.keyboardAvoider,behavior:b.OS==="ios"?"padding":"height",children:[
196
197
  /* @__PURE__ */j(v,{style:o.header,children:[
197
- /* @__PURE__ */A(Text,{tier:"heading",style:o.heading,accessibilityRole:"header",children:Fi.heading}),
198
- /* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Fi.newChat,style:o.newChat,onPress:t.newConversation,children:/* @__PURE__ */A(Text,{tier:"control",style:o.newChatLabel,children:Fi.newChat})}),
199
- /* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Fi.close,hitSlop:0,style:o.closeButton,onPress:t.close,children:/* @__PURE__ */A(CloseGlyph,{size:wf,color:n.color.text.muted,strokeWidth:1.75})})]}),
198
+ /* @__PURE__ */A(Text,{tier:"heading",style:o.heading,accessibilityRole:"header",children:Ei.heading}),
199
+ /* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Ei.newChat,style:o.newChat,onPress:t.newConversation,children:/* @__PURE__ */A(Text,{tier:"control",style:o.newChatLabel,children:Ei.newChat})}),
200
+ /* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Ei.close,hitSlop:0,style:o.closeButton,onPress:t.close,children:/* @__PURE__ */A(CloseGlyph,{size:zf,color:n.color.text.muted,strokeWidth:1.75})})]}),
200
201
  /* @__PURE__ */j(v,{style:o.searchPill,children:[
201
- /* @__PURE__ */A(SearchGlyph,{size:Sf,color:n.color.text.muted,strokeWidth:1.5}),
202
- /* @__PURE__ */A(me,{value:t.query,onChangeText:e=>t.setQuery(e.replace(/^\s+/,"")),style:o.searchInput,placeholder:Fi.searchPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:Fi.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),
203
- /* @__PURE__ */A(Text,{tier:"compact",style:o.countLabel,children:Ai(t.rows.length,w)}),t.error!==null&&!m?/* @__PURE__ */A(v,{style:o.errorCard,children:/* @__PURE__ */A(Text,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,
204
- /* @__PURE__ */A(O,{data:y,keyExtractor:e=>e.id,renderItem:({item:r})=>/* @__PURE__ */A(Row,{row:r,active:r.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(r.id)}}),contentContainerStyle:y.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:S,ListFooterComponent:x,onEndReached:t.loadMore,onEndReachedThreshold:Tf})]})})]})})}function Row({row:e,active:t,disabled:r,styles:n,onPress:l}){let i=e.unreadCount!==null&&e.unreadCount>0,o=Oi(e);/* @__PURE__ */
205
- return j(PressScale,{accessibilityRole:"button",accessibilityLabel:ji(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:l,children:[
202
+ /* @__PURE__ */A(SearchGlyph,{size:Ff,color:n.color.text.muted,strokeWidth:1.5}),
203
+ /* @__PURE__ */A(me,{value:t.query,onChangeText:e=>t.setQuery(e.replace(/^\s+/,"")),style:o.searchInput,placeholder:Ei.searchPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:Ei.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),
204
+ /* @__PURE__ */A(Text,{tier:"compact",style:o.countLabel,children:Di(t.rows.length,w)}),t.error!==null&&!m?/* @__PURE__ */A(v,{style:o.errorCard,children:/* @__PURE__ */A(Text,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,
205
+ /* @__PURE__ */A(O,{data:y,keyExtractor:e=>e.id,renderItem:({item:r})=>/* @__PURE__ */A(Row,{row:r,active:r.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(r.id)}}),contentContainerStyle:y.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:S,ListFooterComponent:x,onEndReached:t.loadMore,onEndReachedThreshold:Of})]})})]})})}function Row({row:e,active:t,disabled:r,styles:n,onPress:l}){let i=e.unreadCount!==null&&e.unreadCount>0,o=ji(e);/* @__PURE__ */
206
+ return j(PressScale,{accessibilityRole:"button",accessibilityLabel:Mi(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:l,children:[
206
207
  /* @__PURE__ */j(v,{style:n.itemRow,children:[
207
- /* @__PURE__ */A(Text,{tier:"control",style:n.itemTitle,numberOfLines:1,children:Li(e.title)}),i?/* @__PURE__ */A(v,{style:n.unreadDot}):null]}),o!==null?/* @__PURE__ */A(Text,{tier:"compact",style:n.itemMeta,numberOfLines:1,children:o}):null]})}function If(e){let t=e.color,r=e.space,n=e.type,l=e.slots,i=t.text.primary,o=Jo(l.card);return g.create({root:{flex:1},backdrop:{flex:1,backgroundColor:gf},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.surface,paddingHorizontal:r.lg,borderRightWidth:g.hairlineWidth,borderRightColor:t.borderRingCream,gap:r.md,...ap(l.dialog,g.hairlineWidth)},keyboardAvoider:{flex:1,gap:r.md},header:{flexDirection:"row",alignItems:"center",gap:r.sm},heading:{...headingFace(e,"bold"),flex:1,fontSize:n.size.subtitle,color:i,...Jo(l.dialog)},newChat:{minHeight:vf,justifyContent:"center",paddingHorizontal:r.xs},newChatLabel:{...face(e,"bold"),fontSize:yf,color:t.brandInk},closeButton:{width:vf,height:vf,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,...Qo(l.input,1)},searchInput:{...face(e,"regular"),flex:1,fontSize:n.size.bodyTight,color:t.text.primary,padding:0,...Jo(l.input)},countLabel:{...face(e,"mono"),fontSize:mf,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:us(t.highlight,bf)??t.surfaceSubtle},itemRow:{flexDirection:"row",alignItems:"center",gap:r.sm},itemTitle:{...face(e,"bold"),flex:1,fontSize:n.size.bodyTight,color:i},itemMeta:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.muted},unreadDot:{width:xf,height:xf,borderRadius:xf/2,backgroundColor:t.danger},errorCard:{borderRadius:Cf,borderWidth:g.hairlineWidth,borderColor:t.danger,backgroundColor:t.surface,padding:r.md},errorText:{...face(e,"regular"),fontSize:n.size.caption,color:t.danger},emptyCard:{borderRadius:kf,padding:r.md+Rf,gap:r.xs+Rf,backgroundColor:t.surfaceSubtle,borderWidth:g.hairlineWidth,borderColor:t.borderRingCream,...Qo(l.card,g.hairlineWidth)},emptyTitle:{...headingFace(e,"bold"),fontSize:n.size.bodyTight,color:i,...o},emptyBody:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.secondary,...o},noMatch:{...face(e,"regular"),fontSize:n.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,...Qo(l.primaryButton)},retryText:{...face(e,"bold"),fontSize:n.size.caption,color:t.brandInk,...Jo(l.primaryButton)},loadMoreFooter:{paddingVertical:r.md+Rf,alignItems:"center"},loadMoreLabel:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.muted}})}function Pf(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 Ff(e,t){let r=new Date(e);return Number.isNaN(r.getTime())?null:r.toLocaleTimeString(t,{hour:"numeric",minute:"2-digit"})}function Lf(e,t=/* @__PURE__ */new Date){let r=[];for(let n of e){let e=Pf(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 Ef="rgba(38,37,35,0.38)",Of=28,Af=40,jf=5,Df=11,Mf=10.5,Bf=36,Hf=11,Wf=14,Nf=15,Uf=13.5,$f=48,Vf=2,qf=1.3,Gf=.12,Kf=16,Yf=8,Qf="80%";function Zf(e,t,r){let n=e?.renderIcon;return n===void 0?r:/* @__PURE__ */A(HostRender,{render:()=>n(t),fallback:r})}function HistorySheet({chat:e,history:t,sheet:r}){let n=useEverfurTheme(),i=l(()=>Jf(n),[n]),o=M(),a=l(()=>Lf(t.rows),[t.rows]),s=Te();if(!t.open)return null;let u=n.color,d=r?.title?.trim(),p=d!==void 0&&d!==""?d:Fi.heading;/* @__PURE__ */
208
+ /* @__PURE__ */A(Text,{tier:"control",style:n.itemTitle,numberOfLines:1,children:Oi(e.title)}),i?/* @__PURE__ */A(v,{style:n.unreadDot}):null]}),o!==null?/* @__PURE__ */A(Text,{tier:"compact",style:n.itemMeta,numberOfLines:1,children:o}):null]})}function Df(e){let t=e.color,r=e.space,n=e.type,l=e.slots,i=t.text.primary,o=ea(l.card);return g.create({root:{flex:1},backdrop:{flex:1,backgroundColor:Sf},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.surface,paddingHorizontal:r.lg,borderRightWidth:g.hairlineWidth,borderRightColor:t.borderRingCream,gap:r.md,...gp(l.dialog,g.hairlineWidth)},keyboardAvoider:{flex:1,gap:r.md},header:{flexDirection:"row",alignItems:"center",gap:r.sm},heading:{...headingFace(e,"bold"),flex:1,fontSize:n.size.subtitle,color:i,...ea(l.dialog)},newChat:{minHeight:_f,justifyContent:"center",paddingHorizontal:r.xs},newChatLabel:{...face(e,"bold"),fontSize:Rf,color:t.brandInk},closeButton:{width:_f,height:_f,alignItems:"center",justifyContent:"center"},searchPill:{flexDirection:"row",alignItems:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,paddingHorizontal:r.md+Ef,paddingVertical:r.sm+Ef,borderWidth:1,borderColor:t.borderRingCream,...Jo(l.input,1)},searchInput:{...face(e,"regular"),flex:1,fontSize:n.size.bodyTight,color:t.text.primary,padding:0,...ea(l.input)},countLabel:{...face(e,"mono"),fontSize:Tf,color:t.text.muted},list:{gap:r.xs,paddingBottom:r.xl},listEmpty:{flexGrow:1},item:{paddingVertical:r.sm+Ef,paddingHorizontal:r.sm,borderRadius:e.radius.md,gap:Ef},itemActive:{backgroundColor:cs(t.highlight,xf)??t.surfaceSubtle},itemRow:{flexDirection:"row",alignItems:"center",gap:r.sm},itemTitle:{...face(e,"bold"),flex:1,fontSize:n.size.bodyTight,color:i},itemMeta:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.muted},unreadDot:{width:Lf,height:Lf,borderRadius:Lf/2,backgroundColor:t.danger},errorCard:{borderRadius:Pf,borderWidth:g.hairlineWidth,borderColor:t.danger,backgroundColor:t.surface,padding:r.md},errorText:{...face(e,"regular"),fontSize:n.size.caption,color:t.danger},emptyCard:{borderRadius:If,padding:r.md+Ef,gap:r.xs+Ef,backgroundColor:t.surfaceSubtle,borderWidth:g.hairlineWidth,borderColor:t.borderRingCream,...Jo(l.card,g.hairlineWidth)},emptyTitle:{...headingFace(e,"bold"),fontSize:n.size.bodyTight,color:i,...o},emptyBody:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.secondary,...o},noMatch:{...face(e,"regular"),fontSize:n.size.bodyTight,color:t.text.muted,paddingVertical:r.sm},retrySlot:{marginTop:r.sm,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:r.md+Ef,paddingVertical:r.sm,borderWidth:1,borderColor:t.brandInk,...Jo(l.primaryButton)},retryText:{...face(e,"bold"),fontSize:n.size.caption,color:t.brandInk,...ea(l.primaryButton)},loadMoreFooter:{paddingVertical:r.md+Ef,alignItems:"center"},loadMoreLabel:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.muted}})}function Mf(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 Bf(e,t){let r=new Date(e);return Number.isNaN(r.getTime())?null:r.toLocaleTimeString(t,{hour:"numeric",minute:"2-digit"})}function Hf(e,t=/* @__PURE__ */new Date){let r=[];for(let n of e){let e=Mf(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 Wf="rgba(38,37,35,0.38)",Nf=28,Uf=40,$f=5,Vf=11,qf=10.5,Gf=36,Kf=11,Yf=14,Qf=15,Zf=13.5,Jf=48,Xf=2,eh=1.3,th=.12,rh=16,nh=8,lh="80%";function ih(e,t,r){let n=e?.renderIcon;return n===void 0?r:/* @__PURE__ */A(HostRender,{render:()=>n(t),fallback:r})}function HistorySheet({chat:e,history:t,sheet:r}){let n=useEverfurTheme(),i=l(()=>oh(n),[n]),o=M(),a=l(()=>Hf(t.rows),[t.rows]),s=Te();if(!t.open)return null;let u=n.color,d=r?.title?.trim(),p=d!==void 0&&d!==""?d:Ei.heading;/* @__PURE__ */
208
209
  return A(R,{visible:true,transparent:true,animationType:"slide",onRequestClose:t.close,children:/* @__PURE__ */j(v,{style:i.root,children:[
209
- /* @__PURE__ */A(C,{style:[ps,i.scrim],onPress:t.close,accessibilityRole:"button",accessibilityLabel:Fi.closeA11y}),
210
+ /* @__PURE__ */A(C,{style:[hs,i.scrim],onPress:t.close,accessibilityRole:"button",accessibilityLabel:Ei.closeA11y}),
210
211
  /* @__PURE__ */j(v,{style:_e([i.sheet,{paddingBottom:Math.max(40,o.bottom+n.space.lg)}],s),accessibilityViewIsModal:true,testID:"everfur-history-sheet",children:[
211
212
  /* @__PURE__ */A(v,{style:i.grab}),
212
213
  /* @__PURE__ */j(v,{style:i.top,children:[
213
214
  /* @__PURE__ */A(Text,{tier:"compact",style:i.kicker,accessibilityRole:"header",children:p}),
214
- /* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Fi.closeA11y,onPress:t.close,style:i.close,children:Zf(r,"close",/* @__PURE__ */A(CloseGlyph,{size:22,color:u.text.primary,strokeWidth:2}))})]}),
215
- /* @__PURE__ */j(T,{style:i.scroll,contentContainerStyle:i.scrollContent,keyboardShouldPersistTaps:"handled",children:[t.loading&&t.rows.length===0?/* @__PURE__ */j(v,{style:i.state,accessibilityLabel:Fi.loading,accessibilityState:{busy:true},children:[
215
+ /* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Ei.closeA11y,onPress:t.close,style:i.close,children:ih(r,"close",/* @__PURE__ */A(CloseGlyph,{size:22,color:u.text.primary,strokeWidth:2}))})]}),
216
+ /* @__PURE__ */j(T,{style:i.scroll,contentContainerStyle:i.scrollContent,keyboardShouldPersistTaps:"handled",children:[t.loading&&t.rows.length===0?/* @__PURE__ */j(v,{style:i.state,accessibilityLabel:Ei.loading,accessibilityState:{busy:true},children:[
216
217
  /* @__PURE__ */A(_,{color:u.brandInk}),
217
- /* @__PURE__ */A(Text,{tier:"compact",style:i.mono,children:Fi.loading})]}):null,t.error!==null?/* @__PURE__ */j(v,{style:i.state,children:[
218
- /* @__PURE__ */A(Text,{style:i.stateText,accessibilityRole:"alert",children:Fi.loadFailed}),
219
- /* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Fi.retry,onPress:()=>{t.load()},style:i.link,children:/* @__PURE__ */A(Text,{tier:"control",style:i.linkText,children:Fi.retry})})]}):null,!t.loading&&t.error===null&&t.rows.length===0?/* @__PURE__ */A(Text,{style:[i.stateText,i.state],children:Fi.empty}):null,a.map((n,l)=>/* @__PURE__ */j(c,{children:[n.day?/* @__PURE__ */A(Text,{tier:"compact",style:[i.mono,i.day,l===0?i.dayFirst:null],children:n.day}):null,n.rows.map(n=>{let l=n.id===e.conversationId,o=n.unreadCount!==null&&n.unreadCount>0,a=Ff(n.updatedAt);/* @__PURE__ */
220
- return j(C,{accessibilityRole:"button",accessibilityLabel:ji(n),accessibilityState:{selected:l},onPress:()=>{t.resume(n.id)},style:[i.row,l?i.rowCurrent:null],children:[
221
- /* @__PURE__ */A(v,{style:i.icon,children:Zf(r,"chat",/* @__PURE__ */A(ChatBubbleGlyph,{size:19,color:u.linkInk,strokeWidth:1.75}))}),
218
+ /* @__PURE__ */A(Text,{tier:"compact",style:i.mono,children:Ei.loading})]}):null,t.error!==null?/* @__PURE__ */j(v,{style:i.state,children:[
219
+ /* @__PURE__ */A(Text,{style:i.stateText,accessibilityRole:"alert",children:Ei.loadFailed}),
220
+ /* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Ei.retry,onPress:()=>{t.load()},style:i.link,children:/* @__PURE__ */A(Text,{tier:"control",style:i.linkText,children:Ei.retry})})]}):null,!t.loading&&t.error===null&&t.rows.length===0?/* @__PURE__ */A(Text,{style:[i.stateText,i.state],children:Ei.empty}):null,a.map((n,l)=>/* @__PURE__ */j(c,{children:[n.day?/* @__PURE__ */A(Text,{tier:"compact",style:[i.mono,i.day,l===0?i.dayFirst:null],children:n.day}):null,n.rows.map(n=>{let l=n.id===e.conversationId,o=n.unreadCount!==null&&n.unreadCount>0,a=Bf(n.updatedAt);/* @__PURE__ */
221
+ return j(C,{accessibilityRole:"button",accessibilityLabel:Mi(n),accessibilityState:{selected:l},onPress:()=>{t.resume(n.id)},style:[i.row,l?i.rowCurrent:null],children:[
222
+ /* @__PURE__ */A(v,{style:i.icon,children:ih(r,"chat",/* @__PURE__ */A(ChatBubbleGlyph,{size:19,color:u.linkInk,strokeWidth:1.75}))}),
222
223
  /* @__PURE__ */j(v,{style:i.rowWords,children:[
223
- /* @__PURE__ */A(Text,{tier:"control",style:i.rowTitle,numberOfLines:1,children:Li(n.title)}),n.preview!==void 0?/* @__PURE__ */A(Text,{tier:"compact",style:i.preview,numberOfLines:1,children:n.preview}):null]}),
224
- /* @__PURE__ */j(v,{style:i.rowEnd,children:[a!==null?/* @__PURE__ */A(Text,{tier:"compact",style:[i.mono,i.time,o?i.timeUnread:null],children:a}):null,o?/* @__PURE__ */A(v,{style:i.unreadDot,testID:`everfur-history-sheet-unread-${String(n.id)}`}):null]})]},String(n.id))})]},n.day)),t.cursor!==null&&!t.loadingMore?/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Fi.more,onPress:t.loadMore,style:i.link,children:/* @__PURE__ */A(Text,{tier:"control",style:i.linkText,children:Fi.more})}):null]}),
225
- /* @__PURE__ */j(C,{accessibilityRole:"button",accessibilityLabel:Fi.newChat,onPress:t.newConversation,style:i.newChat,children:[Zf(r,"edit",/* @__PURE__ */A(EditGlyph,{size:18,color:n.slots.primaryButton?.textColor??u.onPrimary,strokeWidth:1.75})),
226
- /* @__PURE__ */A(Text,{tier:"control",style:i.newChatText,children:Fi.newChat})]})]})]})})}function Jf(e){let t=e.color,r=e.space,n={...face(e,"mono"),fontSize:Mf,letterSpacing:Mf*.06,textTransform:"uppercase",color:t.text.muted};return g.create({root:{flex:1,justifyContent:"flex-end"},scrim:{backgroundColor:Ef},sheet:{maxHeight:Qf,backgroundColor:t.surface,borderTopLeftRadius:Of,borderTopRightRadius:Of,paddingTop:10,paddingHorizontal:20},grab:{width:Af,height:jf,borderRadius:3,backgroundColor:t.borderRingCream,alignSelf:"center",marginBottom:10},top:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},kicker:{...n,fontSize:Df,letterSpacing:Df*.08,flexShrink:1},close:{width:Ns,height:Ns,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:Ns/2},scroll:{flexGrow:0},scrollContent:{paddingBottom:r.xs},mono:n,day:{marginTop:r.lg,marginBottom:r.xs},dayFirst:{marginTop:Vf},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:Ns,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:Wf,minHeight:Ns},rowCurrent:{backgroundColor:t.surfaceSubtle},icon:{width:Bf,height:Bf,borderRadius:Hf,backgroundColor:us(t.linkInk,Gf)??t.surfaceSubtle,alignItems:"center",justifyContent:"center"},rowWords:{flex:1,minWidth:0},rowTitle:{...face(e,"bold"),fontSize:Nf,lineHeight:Nf*qf,color:t.text.primary},preview:{...face(e,"regular"),fontSize:Uf,color:t.text.muted,marginTop:2},rowEnd:{alignSelf:"flex-start",alignItems:"flex-end",gap:6},time:{marginTop:3,letterSpacing:Mf*.04,textTransform:"none"},timeUnread:{...face(e,"monoBold"),color:t.text.primary},unreadDot:{width:Yf,height:Yf,borderRadius:Yf/2,backgroundColor:t.danger},newChat:{marginTop:r.lg,minHeight:$f,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.primary,...Qo(e.slots.primaryButton)},newChatText:{...face(e,"bold"),fontSize:Kf,color:t.onPrimary,...Jo(e.slots.primaryButton)}})}var Xf="Close",eh=/* @__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:`${th(e.possessive)} results`,resultsClose:e=>e.possessive===null?null:`Close ${e.possessive} results`,resultsTopRisk:"Top risk"});function th(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={...eh,...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(),d=t.results!==void 0&&r.report!==void 0?t.results:void 0;if(d!==void 0){let e=n.resultsKicker(l)?.trim()||r.kicker,s=n.resultsClose(l),c=d.onTopRisk??o,p={key:"top-risk",label:n.resultsTopRisk,title:r.title,...r.risk?.lead?{line:r.risk.lead}:{},tone:"risk",...c===void 0?{}:{onPress:c}};return{kicker:e,...i===void 0?{}:{badge:i},title:r.title,results:[p,...d.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()===""?Xf: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()===""?Xf:s,pill:r.kicker,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}function rh(e){let t=face(e,"medium");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"600"}}function nh(e){let t=face(e,"bold");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"800"}}var lh=20,ih=14,oh=16,ah=18,sh=22,uh=15,dh=12,ch=24,ph=15,fh=14.5,hh=21,gh=14.5,bh=18,yh=9,mh=36,vh=14,wh=15,kh=8,Ch=40;function TopCard({card:e,open:t,onOpenChange:r,ask:n}){let i=useEverfurTheme(),o=nf(),a=l(()=>o!==null?xh(o):Rh(i),[i,o]),s=l(()=>Qo(i.slots.card),[i.slots.card]);if(!t)return null;let u=e.closeLabel===void 0?null:e.closeLabel.trim()!==""?e.closeLabel:He.close,d=e.action,c=e.ask,p=/* @__PURE__ */A(CloseGlyph,{size:o!==null?HOME_CLOSE_GLYPH(o):bh,color:o!==null?String(o.text(".ask-focus__x").color):i.color.text.primary,strokeWidth:2});/* @__PURE__ */
224
+ /* @__PURE__ */A(Text,{tier:"control",style:i.rowTitle,numberOfLines:1,children:Oi(n.title)}),n.preview!==void 0?/* @__PURE__ */A(Text,{tier:"compact",style:i.preview,numberOfLines:1,children:n.preview}):null]}),
225
+ /* @__PURE__ */j(v,{style:i.rowEnd,children:[a!==null?/* @__PURE__ */A(Text,{tier:"compact",style:[i.mono,i.time,o?i.timeUnread:null],children:a}):null,o?/* @__PURE__ */A(v,{style:i.unreadDot,testID:`everfur-history-sheet-unread-${String(n.id)}`}):null]})]},String(n.id))})]},n.day)),t.cursor!==null&&!t.loadingMore?/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:Ei.more,onPress:t.loadMore,style:i.link,children:/* @__PURE__ */A(Text,{tier:"control",style:i.linkText,children:Ei.more})}):null]}),
226
+ /* @__PURE__ */j(C,{accessibilityRole:"button",accessibilityLabel:Ei.newChat,onPress:t.newConversation,style:i.newChat,children:[ih(r,"edit",/* @__PURE__ */A(EditGlyph,{size:18,color:n.slots.primaryButton?.textColor??u.onPrimary,strokeWidth:1.75})),
227
+ /* @__PURE__ */A(Text,{tier:"control",style:i.newChatText,children:Ei.newChat})]})]})]})})}function oh(e){let t=e.color,r=e.space,n={...face(e,"mono"),fontSize:qf,letterSpacing:qf*.06,textTransform:"uppercase",color:t.text.muted};return g.create({root:{flex:1,justifyContent:"flex-end"},scrim:{backgroundColor:Wf},sheet:{maxHeight:lh,backgroundColor:t.surface,borderTopLeftRadius:Nf,borderTopRightRadius:Nf,paddingTop:10,paddingHorizontal:20},grab:{width:Uf,height:$f,borderRadius:3,backgroundColor:t.borderRingCream,alignSelf:"center",marginBottom:10},top:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},kicker:{...n,fontSize:Vf,letterSpacing:Vf*.08,flexShrink:1},close:{width:$s,height:$s,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:$s/2},scroll:{flexGrow:0},scrollContent:{paddingBottom:r.xs},mono:n,day:{marginTop:r.lg,marginBottom:r.xs},dayFirst:{marginTop:Xf},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:$s,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:Yf,minHeight:$s},rowCurrent:{backgroundColor:t.surfaceSubtle},icon:{width:Gf,height:Gf,borderRadius:Kf,backgroundColor:cs(t.linkInk,th)??t.surfaceSubtle,alignItems:"center",justifyContent:"center"},rowWords:{flex:1,minWidth:0},rowTitle:{...face(e,"bold"),fontSize:Qf,lineHeight:Qf*eh,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:qf*.04,textTransform:"none"},timeUnread:{...face(e,"monoBold"),color:t.text.primary},unreadDot:{width:nh,height:nh,borderRadius:nh/2,backgroundColor:t.danger},newChat:{marginTop:r.lg,minHeight:Jf,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.primary,...Jo(e.slots.primaryButton)},newChatText:{...face(e,"bold"),fontSize:rh,color:t.onPrimary,...ea(e.slots.primaryButton)}})}var ah="Close",sh=/* @__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:`${uh(e.possessive)} results`,resultsClose:e=>e.possessive===null?null:`Close ${e.possessive} results`,resultsTopRisk:"Top risk"});function uh(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={...sh,...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(),d=t.results!==void 0&&r.report!==void 0?t.results:void 0;if(d!==void 0){let e=n.resultsKicker(l)?.trim()||r.kicker,s=n.resultsClose(l),c=d.onTopRisk??o,p={key:"top-risk",label:n.resultsTopRisk,title:r.title,...r.risk?.lead?{line:r.risk.lead}:{},tone:"risk",...c===void 0?{}:{onPress:c}};return{kicker:e,...i===void 0?{}:{badge:i},title:r.title,results:[p,...d.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()===""?ah: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()===""?ah:s,pill:r.kicker,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}function dh(e){let t=face(e,"medium");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"600"}}function ch(e){let t=face(e,"bold");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"800"}}var ph=20,fh=14,hh=16,gh=18,bh=22,yh=15,mh=12,vh=24,wh=15,kh=14.5,Ch=21,Sh=14.5,xh=18,Rh=9,Th=36,_h=14,zh=15,Ih=8,Ph=40;function TopCard({card:e,open:t,onOpenChange:r,ask:n}){let i=useEverfurTheme(),o=pf(),a=l(()=>o!==null?Lh(o):Eh(i),[i,o]),s=l(()=>Jo(i.slots.card),[i.slots.card]);if(!t)return null;let u=e.closeLabel===void 0?null:e.closeLabel.trim()!==""?e.closeLabel:Ne.close,d=e.action,c=e.ask,p=/* @__PURE__ */A(CloseGlyph,{size:o!==null?HOME_CLOSE_GLYPH(o):xh,color:o!==null?String(o.text(".ask-focus__x").color):i.color.text.primary,strokeWidth:2});/* @__PURE__ */
227
228
  return j(v,{style:[a.card,s],testID:"everfur-top-card",children:[
228
229
  /* @__PURE__ */j(v,{style:a.kickerRow,children:[
229
- /* @__PURE__ */A(Text,{tier:"control",style:a.kicker,children:e.kicker}),e.badge!==void 0?/* @__PURE__ */A(v,{style:a.badge,children:/* @__PURE__ */A(Text,{tier:"compact",style:a.badgeText,numberOfLines:1,children:e.badge})}):null,u!==null?/* @__PURE__ */A(C,{onPress:()=>r(false),accessibilityRole:"button",accessibilityLabel:u,style:a.close,hitSlop:o!==null?Sh:void 0,testID:"everfur-top-card-close",children:e.renderIcon!==void 0?/* @__PURE__ */A(HostRender,{render:()=>e.renderIcon?.("close"),fallback:p}):p}):null]}),
230
+ /* @__PURE__ */A(Text,{tier:"control",style:a.kicker,children:e.kicker}),e.badge!==void 0?/* @__PURE__ */A(v,{style:a.badge,children:/* @__PURE__ */A(Text,{tier:"compact",style:a.badgeText,numberOfLines:1,children:e.badge})}):null,u!==null?/* @__PURE__ */A(C,{onPress:()=>r(false),accessibilityRole:"button",accessibilityLabel:u,style:a.close,hitSlop:o!==null?Fh:void 0,testID:"everfur-top-card-close",children:e.renderIcon!==void 0?/* @__PURE__ */A(HostRender,{render:()=>e.renderIcon?.("close"),fallback:p}):p}):null]}),
230
231
  /* @__PURE__ */A(Text,{tier:"heading",style:a.title,accessibilityRole:"header",children:e.title}),e.lead!==void 0||e.body!==void 0?/* @__PURE__ */j(v,{style:a.finding,children:[
231
232
  /* @__PURE__ */A(v,{style:a.dot}),
232
- /* @__PURE__ */j(Text,{style:a.findingText,children:[e.lead!==void 0?/* @__PURE__ */A(Text,{style:a.lead,children:e.lead}):null,e.lead!==void 0&&e.body!==void 0?" ":null,e.body??null]})]}):null,d!==void 0||c!==void 0?/* @__PURE__ */j(v,{style:a.actions,children:[d!==void 0?/* @__PURE__ */A(C,{onPress:()=>{Gr(d.onPress)},accessibilityRole:"button",accessibilityLabel:d.label,style:a.action,hitSlop:o!==null?Sh:void 0,children:/* @__PURE__ */A(Text,{tier:"control",style:a.actionText,children:d.label})}):null,c!==void 0?/* @__PURE__ */A(C,{onPress:()=>n(c.prompt),accessibilityRole:"button",accessibilityLabel:c.label,style:a.ask,hitSlop:o!==null?Sh:void 0,children:/* @__PURE__ */A(Text,{tier:"control",style:a.askText,children:c.label})}):null]}):null]})}function TopCardPill({card:e,open:t,onOpenChange:r}){let n=useEverfurTheme(),i=nf(),o=l(()=>i!==null?xh(i):Rh(n),[n,i]);if(t||e.closeLabel===void 0)return null;let a=e.pill??e.kicker;/* @__PURE__ */
233
- return j(C,{onPress:()=>r(true),accessibilityRole:"button",accessibilityLabel:a,accessibilityState:{expanded:false},style:o.pill,hitSlop:i!==null?Sh:void 0,testID:"everfur-top-card-pill",children:[
233
+ /* @__PURE__ */j(Text,{style:a.findingText,children:[e.lead!==void 0?/* @__PURE__ */A(Text,{style:a.lead,children:e.lead}):null,e.lead!==void 0&&e.body!==void 0?" ":null,e.body??null]})]}):null,d!==void 0||c!==void 0?/* @__PURE__ */j(v,{style:a.actions,children:[d!==void 0?/* @__PURE__ */A(C,{onPress:()=>{Yr(d.onPress)},accessibilityRole:"button",accessibilityLabel:d.label,style:a.action,hitSlop:o!==null?Fh:void 0,children:/* @__PURE__ */A(Text,{tier:"control",style:a.actionText,children:d.label})}):null,c!==void 0?/* @__PURE__ */A(C,{onPress:()=>n(c.prompt),accessibilityRole:"button",accessibilityLabel:c.label,style:a.ask,hitSlop:o!==null?Fh:void 0,children:/* @__PURE__ */A(Text,{tier:"control",style:a.askText,children:c.label})}):null]}):null]})}function TopCardPill({card:e,open:t,onOpenChange:r}){let n=useEverfurTheme(),i=pf(),o=l(()=>i!==null?Lh(i):Eh(n),[n,i]);if(t||e.closeLabel===void 0)return null;let a=e.pill??e.kicker;/* @__PURE__ */
234
+ return j(C,{onPress:()=>r(true),accessibilityRole:"button",accessibilityLabel:a,accessibilityState:{expanded:false},style:o.pill,hitSlop:i!==null?Fh:void 0,testID:"everfur-top-card-pill",children:[
234
235
  /* @__PURE__ */A(v,{style:o.pillDot}),
235
- /* @__PURE__ */A(Text,{tier:"control",style:o.pillText,numberOfLines:1,children:a})]})}var Sh=4,HOME_CLOSE_GLYPH=e=>{let t=e.icon(".ask-focus__x svg").width;return typeof t=="number"?t:bh};function xh(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:yh;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 Rh(e){let t=e.color,r=e.space;return g.create({card:{paddingTop:ih,paddingHorizontal:oh,paddingBottom:oh,borderRadius:lh,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,alignSelf:"stretch"},kickerRow:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Ns-8},kicker:{...nh(e),fontSize:uh,color:t.text.primary,flexShrink:1},badge:{marginLeft:"auto",minHeight:ch,justifyContent:"center",paddingHorizontal:9,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,flexShrink:1},badgeText:{...face(e,"bold"),fontSize:dh,color:t.text.secondary},close:{width:Ns,height:Ns,marginVertical:-4,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:Ns/2},title:{...nh(e),fontSize:ah,lineHeight:sh,color:t.text.primary,marginTop:r.xs},finding:{flexDirection:"row",gap:r.sm,marginTop:r.xs+2},dot:{width:yh,height:yh,borderRadius:yh/2,marginTop:7,backgroundColor:t.danger},findingText:{...face(e,"regular"),flex:1,fontSize:fh,lineHeight:hh,color:t.text.primary},lead:face(e,"bold"),actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.lg,marginTop:14},action:{minHeight:Math.max(Ch,Ns),paddingHorizontal:r.lg,borderRadius:e.radius.pill,backgroundColor:t.primary,alignItems:"center",justifyContent:"center",maxWidth:"100%"},actionText:{...face(e,"bold"),fontSize:ph,color:t.onPrimary},ask:{minHeight:Ns,justifyContent:"center",maxWidth:"100%"},askText:{...face(e,"bold"),fontSize:gh,color:t.brandInk,textDecorationLine:"underline"},pill:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Math.max(mh,Ns),paddingHorizontal:vh,borderRadius:e.radius.pill,backgroundColor:t.badgeBgCritical,alignSelf:"flex-start",maxWidth:"100%"},pillDot:{width:kh,height:kh,borderRadius:kh/2,backgroundColor:t.danger},pillText:{...face(e,"bold"),fontSize:wh,color:t.danger,flexShrink:1}})}var Th=/* @__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"}),_h=/* @__PURE__ */new WeakMap;function zh(e){let t=_h.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,...Th},i=(e,t)=>cs(e,t,ns(t),Ih),o=(e,t)=>contrastRatio(e,t)>=Ih?e:rs(t,Ih),a=[l.card,l.paper].map(e=>ss(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 _h.set(e,u),u}var Ih=4.5;function Ph(e,t){for(let r of t)if(contrastRatio(r,e)>=Ih)return r;return rs(e,Ih)}function Fh(e,t,r){let n=us(e,t);return(n===null?null:ss(n,r))??r}function Lh(e){let t=zh(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:Ph(t.accent,[t.ink,t.onAccent]),accent2:Fh(t.accent,.75,n),accent4:Fh(t.accent,.17,n),accentChip:Fh(t.accent,.47,n),link:t.link,linkChip:Fh(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 Eh=/* @__PURE__ */new Set(["color","fontSize","fontWeight","fontStyle","lh","ls","family","textAlign","textTransform","textDecorationLine"]),Oh=/* @__PURE__ */new Set(["dur","delay","stagger","ease","tint","k","cols","nowrap"]),Ah=["paddingTop","paddingRight","paddingBottom","paddingLeft"],jh=17,Dh=1.5,Mh=400,Bh=700;function Hh(e){return e<=450?"regular":e<=650?"medium":"bold"}function Wh(e){let t=Math.min(900,Math.max(100,Math.round(e/100)*100));return String(t)}function Nh(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:Wh(r)}}let n=t==="$serif"?headingFace(e,Hh(r)):face(e,Hh(r));return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:Wh(r)}}function Uh(e,t,r={}){let n=Lh(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={},d=e=>{if(e!==void 0)for(let[t,r]of Object.entries(e))u[t]=o(r)};for(let e of n)d(t[e]),i&&d(r[e]);let c=/* @__PURE__ */Object.freeze(u);return a.set(l,c),c},u=/* @__PURE__ */new Map,d=(...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))Eh.has(e)||Oh.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 Ah){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 d=/* @__PURE__ */Object.freeze(l);return u.set(t,d),d},c=/* @__PURE__ */new Map,p=(t,r)=>{let l=`${t}|${r.filter(Boolean).join("|")}`,i=c.get(l);if(i!==void 0)return i;let o=s(r),a=typeof o.fontSize=="number"?o.fontSize:jh,u=typeof o.lh=="number"?o.lh:Dh,d=typeof o.fontWeight=="string"?Number(o.fontWeight):t,p=typeof o.family=="string"?o.family:"$sans",f={...Nh(e,p,d),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 c.set(l,h),h};return{reduced:i,colors:n,view:d,text:(...e)=>p(Mh,e),strong:(...e)=>p(Bh,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 $h={".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"]}},Vh=16;var qh=4e3,Gh=.5;function Kh(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 Yh(e,t,r){if(e.length===0)return r;let n=Kh(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=Gh*e.length+1;for(let o of l)if(Kh(e,t,o)<=n)return Math.min(r,o+i);return r}function BalancedTitle({text:e,style:t,measureCh:r}){let n=l(()=>e.split(/\s+/).filter(e=>e!==""),[e]),a=g.flatten(t),s=[e,a.fontFamily,a.fontSize,a.fontWeight,a.letterSpacing].join("|"),u=i({key:"",ch:null,line:null,words:[]});u.current.key!==s&&(u.current={key:s,ch:null,line:null,words:n.map(()=>null)});let[d,c]=o(null),p=d!==null&&d.key===s?d.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,n=t.reduce((e,t)=>e+t,0),l=t.length>1?Math.max(0,(e.line-n)/(t.length-1)):0,i=Yh(t,l,(e.ch+Gh)*r);c(t=>t!==null&&t.key===e.key&&t.value===i?t:{key:e.key,value:i})},h=e=>t=>{u.current.key===s&&(e(u.current,t.nativeEvent.layout.width),f())};/* @__PURE__ */
236
- return j(v,{style:Qh.wrap,children:[
236
+ /* @__PURE__ */A(Text,{tier:"control",style:o.pillText,numberOfLines:1,children:a})]})}var Fh=4,HOME_CLOSE_GLYPH=e=>{let t=e.icon(".ask-focus__x svg").width;return typeof t=="number"?t:xh};function Lh(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:Rh;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 Eh(e){let t=e.color,r=e.space;return g.create({card:{paddingTop:fh,paddingHorizontal:hh,paddingBottom:hh,borderRadius:ph,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,alignSelf:"stretch"},kickerRow:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:$s-8},kicker:{...ch(e),fontSize:yh,color:t.text.primary,flexShrink:1},badge:{marginLeft:"auto",minHeight:vh,justifyContent:"center",paddingHorizontal:9,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,flexShrink:1},badgeText:{...face(e,"bold"),fontSize:mh,color:t.text.secondary},close:{width:$s,height:$s,marginVertical:-4,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:$s/2},title:{...ch(e),fontSize:gh,lineHeight:bh,color:t.text.primary,marginTop:r.xs},finding:{flexDirection:"row",gap:r.sm,marginTop:r.xs+2},dot:{width:Rh,height:Rh,borderRadius:Rh/2,marginTop:7,backgroundColor:t.danger},findingText:{...face(e,"regular"),flex:1,fontSize:kh,lineHeight:Ch,color:t.text.primary},lead:face(e,"bold"),actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.lg,marginTop:14},action:{minHeight:Math.max(Ph,$s),paddingHorizontal:r.lg,borderRadius:e.radius.pill,backgroundColor:t.primary,alignItems:"center",justifyContent:"center",maxWidth:"100%"},actionText:{...face(e,"bold"),fontSize:wh,color:t.onPrimary},ask:{minHeight:$s,justifyContent:"center",maxWidth:"100%"},askText:{...face(e,"bold"),fontSize:Sh,color:t.brandInk,textDecorationLine:"underline"},pill:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Math.max(Th,$s),paddingHorizontal:_h,borderRadius:e.radius.pill,backgroundColor:t.badgeBgCritical,alignSelf:"flex-start",maxWidth:"100%"},pillDot:{width:Ih,height:Ih,borderRadius:Ih/2,backgroundColor:t.danger},pillText:{...face(e,"bold"),fontSize:zh,color:t.danger,flexShrink:1}})}var Oh=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatShellTabsBar");function Ah(){let e=globalThis,t=e[Oh];if(t!==void 0)return t;let r=createContext(false);return e[Oh]=r,r}var jh=Ah();function Dh(){return u(jh)}var Mh=/* @__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"}),Bh=/* @__PURE__ */new WeakMap;function Hh(e){let t=Bh.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,...Mh},i=(e,t)=>fs(e,t,is(t),Wh),o=(e,t)=>contrastRatio(e,t)>=Wh?e:ls(t,Wh),a=[l.card,l.paper].map(e=>ds(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 Bh.set(e,u),u}var Wh=4.5;function Nh(e,t){for(let r of t)if(contrastRatio(r,e)>=Wh)return r;return ls(e,Wh)}function Uh(e,t,r){let n=cs(e,t);return(n===null?null:ds(n,r))??r}function $h(e){let t=Hh(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:Nh(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 Vh=/* @__PURE__ */new Set(["color","fontSize","fontWeight","fontStyle","lh","ls","family","textAlign","textTransform","textDecorationLine"]),qh=/* @__PURE__ */new Set(["dur","delay","stagger","ease","tint","k","cols","nowrap"]),Gh=["paddingTop","paddingRight","paddingBottom","paddingLeft"],Kh=17,Yh=1.5,Qh=400,Zh=700;function Jh(e){return e<=450?"regular":e<=650?"medium":"bold"}function Xh(e){let t=Math.min(900,Math.max(100,Math.round(e/100)*100));return String(t)}function eg(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:Xh(r)}}let n=t==="$serif"?headingFace(e,Jh(r)):face(e,Jh(r));return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:Xh(r)}}function tg(e,t,r={}){let n=$h(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={},d=e=>{if(e!==void 0)for(let[t,r]of Object.entries(e))u[t]=o(r)};for(let e of n)d(t[e]),i&&d(r[e]);let c=/* @__PURE__ */Object.freeze(u);return a.set(l,c),c},u=/* @__PURE__ */new Map,d=(...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))Vh.has(e)||qh.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 Gh){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 d=/* @__PURE__ */Object.freeze(l);return u.set(t,d),d},c=/* @__PURE__ */new Map,p=(t,r)=>{let l=`${t}|${r.filter(Boolean).join("|")}`,i=c.get(l);if(i!==void 0)return i;let o=s(r),a=typeof o.fontSize=="number"?o.fontSize:Kh,u=typeof o.lh=="number"?o.lh:Yh,d=typeof o.fontWeight=="string"?Number(o.fontWeight):t,p=typeof o.family=="string"?o.family:"$sans",f={...eg(e,p,d),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 c.set(l,h),h};return{reduced:i,colors:n,view:d,text:(...e)=>p(Qh,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 rg={".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"]}},ng=16;var lg=4e3,ig=.5;function og(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 ag(e,t,r){if(e.length===0)return r;let n=og(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=ig*e.length+1;for(let o of l)if(og(e,t,o)<=n)return Math.min(r,o+i);return r}function BalancedTitle({text:e,style:t,measureCh:r}){let n=l(()=>e.split(/\s+/).filter(e=>e!==""),[e]),a=g.flatten(t),s=[e,a.fontFamily,a.fontSize,a.fontWeight,a.letterSpacing].join("|"),u=i({key:"",ch:null,line:null,words:[]});u.current.key!==s&&(u.current={key:s,ch:null,line:null,words:n.map(()=>null)});let[d,c]=o(null),p=d!==null&&d.key===s?d.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,n=t.reduce((e,t)=>e+t,0),l=t.length>1?Math.max(0,(e.line-n)/(t.length-1)):0,i=ag(t,l,(e.ch+ig)*r);c(t=>t!==null&&t.key===e.key&&t.value===i?t:{key:e.key,value:i})},h=e=>t=>{u.current.key===s&&(e(u.current,t.nativeEvent.layout.width),f())};/* @__PURE__ */
237
+ return j(v,{style:sg.wrap,children:[
237
238
  /* @__PURE__ */A(Text,{tier:"heading",style:p===null?t:[t,{maxWidth:p}],accessibilityRole:"header",children:e}),
238
- /* @__PURE__ */A(v,{style:Qh.probeClip,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */j(v,{style:Qh.probeRow,children:[
239
+ /* @__PURE__ */A(v,{style:sg.probeClip,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */j(v,{style:sg.probeRow,children:[
239
240
  /* @__PURE__ */A(Text,{tier:"heading",style:t,onLayout:h((e,t)=>{e.ch=t}),children:"0"}),
240
- /* @__PURE__ */A(Text,{tier:"heading",style:t,onLayout:h((e,t)=>{e.line=t}),children:n.join(" ")}),n.map((e,r)=>/* @__PURE__ */A(Text,{tier:"heading",style:t,onLayout:h((e,t)=>{e.words[r]=t}),children:e},`${r}:${e}`))]})})]})}var Qh=g.create({wrap:{alignSelf:"stretch",alignItems:"center"},probeClip:{position:"absolute",left:0,top:0,width:0,height:0,overflow:"hidden",opacity:0},probeRow:{width:qh,flexDirection:"row",alignItems:"flex-start"}});function Zh(e){return{kit:Uh(e,$h),Title:BalancedTitle,titleCh:Vh}}var Jh=/* @__PURE__ */Symbol.for("everfur.sdk.rn.poweredBy");function Xh(){let e=globalThis,t=e[Jh];if(t!==void 0)return t;let r={count:0,listeners:/* @__PURE__ */new Set};return e[Jh]=r,r}var eg=e=>{let t=Xh();return t.listeners.add(e),()=>t.listeners.delete(e)},tg=()=>Xh().count>0;function useHostPoweredBy(){return s(eg,tg,tg)}function EverfurPoweredBy({children:e,style:t}){let r=useEverfurTheme().meta.hidePoweredBy;return a(()=>{if(r)return;let e=Xh();return e.count+=1,e.listeners.forEach(e=>e()),()=>{e.count-=1,e.listeners.forEach(e=>e())}},[r]),r?null:e??/* @__PURE__ */A(Text,{tier:"compact",style:t,accessibilityRole:"text",children:He.poweredBy})}var rg=/* @__PURE__ */Object.freeze({}),ng=100,lg=20;function ig(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 og(e,t){let r=typeof e=="number"&&Number.isFinite(e),s=i(null),[u,d]=o(null),c=i(null),p=i(null),f=i(true),h=n(()=>{p.current!==null&&clearTimeout(p.current),p.current=null},[]);a(()=>(f.current=true,()=>{f.current=false,h()}),[h]);let g=n(function e(t){s.current?.measureInWindow((r,n)=>{let l=c.current;if(!f.current||l===null)return;let i=ig(n,l.y,l.height,S.get("window").height);if(i!==null){d(e=>e!==null&&e.chatTop===i.chatTop&&e.parentTop===i.parentTop?e:i);return}t>=lg||(p.current=setTimeout(()=>{p.current=null,e(t+1)},ng))})},[]),b=n(e=>{let{y:t,height:r}=e.nativeEvent.layout;c.current={y:t,height:r},h(),g(0)},[g,h]);return l(()=>{if(!t)return{avoidingProps:r?{keyboardVerticalOffset:e}:rg,probeRef:null,topInWindow:null};let n=u?.parentTop??0;return{avoidingProps:r?{keyboardVerticalOffset:e,onLayout:b}:n>0?{keyboardVerticalOffset:n,onLayout:b}:{onLayout:b},probeRef:s,topInWindow:u?.chatTop??null}},[t,r,e,u,b])}function KeyboardOffsetProbe({probeRef:e}){return e===null?null:/* @__PURE__ */A(v,{ref:e,collapsable:false,pointerEvents:"none",style:ag})}var ag=/* @__PURE__ */Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function sg(){let[e,t]=o(false);return a(()=>{let e=x;if(typeof e?.addListener!="function")return;let r=b.OS==="ios",n=e.addListener(r?"keyboardWillShow":"keyboardDidShow",()=>t(true)),l=e.addListener(r?"keyboardWillHide":"keyboardDidHide",()=>t(false));return()=>{n.remove(),l.remove()}},[]),e}var ug=4.5;var dg=3;function cg(e,t,r){return cs(e,t,ns(t),r)}function pg(e,t){if(e.level==="emergency")return e;let r=e.level==="schedule_soon",n=Yc(t),l=r?n.warning:n.info,i=Kc(t)&&!l?e:fg(e,t,r);return hg(i,t.slots.banner)}function fg(e,t,r){let n=t.color,l=ss(r?n.badgeBgCaution:n.badgeBgInfo,n.surface)??n.surface,i=r?n.cautionAccent:n.infoEdge,o=cg(ss(i,n.surface)??i,[n.surface,n.chatGround],dg),a=cg(r?n.warningStrong:n.info,[l,n.surface],ug);/* @__PURE__ */
241
- return Object.freeze({...e,borderColor:o,backgroundColor:l,textColor:a,reasonColor:cg(n.text.primary,[l],ug),pillColor:n.surface})}function hg(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 gg(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 bg=.75,yg=1.5,mg=.4,vg=4,wg=1.5,kg=22,Cg=14,Sg=8,xg=20,Rg=10,Tg=13,_g=12,zg=15,Ig=44,Pg=14,Fg=1.25,Lg=14,Eg=6,Og=2;function Ag(e,t){let r=e.color;if(t.level==="emergency")return{card:{backgroundColor:r.badgeBgCritical,borderColor:us(r.danger,mg)??r.danger,borderWidth:yg},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:bg,...n===void 0?{}:{borderRadius:n}},label:t.textColor,reason:t.reasonColor,close:t.textColor,action:null}}function UrgencyBanner({surface:e,petRef:petRef,renderVetAction:t,onFindVet:r,vet:n,compact:i=false}){let o=useEverfurTheme(),a=l(()=>jg(o),[o]),s=Co(),u=e.tier===null?null:pg(e.tier,o),d=e.source;/* @__PURE__ */
241
+ /* @__PURE__ */A(Text,{tier:"heading",style:t,onLayout:h((e,t)=>{e.line=t}),children:n.join(" ")}),n.map((e,r)=>/* @__PURE__ */A(Text,{tier:"heading",style:t,onLayout:h((e,t)=>{e.words[r]=t}),children:e},`${r}:${e}`))]})})]})}var sg=g.create({wrap:{alignSelf:"stretch",alignItems:"center"},probeClip:{position:"absolute",left:0,top:0,width:0,height:0,overflow:"hidden",opacity:0},probeRow:{width:lg,flexDirection:"row",alignItems:"flex-start"}});function ug(e){return{kit:tg(e,rg),Title:BalancedTitle,titleCh:ng}}var dg=/* @__PURE__ */Symbol.for("everfur.sdk.rn.poweredBy");function cg(){let e=globalThis,t=e[dg];if(t!==void 0)return t;let r={count:0,listeners:/* @__PURE__ */new Set};return e[dg]=r,r}var pg=e=>{let t=cg();return t.listeners.add(e),()=>t.listeners.delete(e)},fg=()=>cg().count>0;function useHostPoweredBy(){return s(pg,fg,fg)}function EverfurPoweredBy({children:e,style:t}){let r=useEverfurTheme().meta.hidePoweredBy;return a(()=>{if(r)return;let e=cg();return e.count+=1,e.listeners.forEach(e=>e()),()=>{e.count-=1,e.listeners.forEach(e=>e())}},[r]),r?null:e??/* @__PURE__ */A(Text,{tier:"compact",style:t,accessibilityRole:"text",children:Ne.poweredBy})}var hg=/* @__PURE__ */Object.freeze({}),gg=100,bg=20;function yg(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 mg(e,t){let r=typeof e=="number"&&Number.isFinite(e),s=i(null),[u,d]=o(null),c=i(null),p=i(null),f=i(true),h=n(()=>{p.current!==null&&clearTimeout(p.current),p.current=null},[]);a(()=>(f.current=true,()=>{f.current=false,h()}),[h]);let g=n(function e(t){s.current?.measureInWindow((r,n)=>{let l=c.current;if(!f.current||l===null)return;let i=yg(n,l.y,l.height,S.get("window").height);if(i!==null){d(e=>e!==null&&e.chatTop===i.chatTop&&e.parentTop===i.parentTop?e:i);return}t>=bg||(p.current=setTimeout(()=>{p.current=null,e(t+1)},gg))})},[]),b=n(e=>{let{y:t,height:r}=e.nativeEvent.layout;c.current={y:t,height:r},h(),g(0)},[g,h]);return l(()=>{if(!t)return{avoidingProps:r?{keyboardVerticalOffset:e}:hg,probeRef:null,topInWindow:null};let n=u?.parentTop??0;return{avoidingProps:r?{keyboardVerticalOffset:e,onLayout:b}:n>0?{keyboardVerticalOffset:n,onLayout:b}:{onLayout:b},probeRef:s,topInWindow:u?.chatTop??null}},[t,r,e,u,b])}function KeyboardOffsetProbe({probeRef:e}){return e===null?null:/* @__PURE__ */A(v,{ref:e,collapsable:false,pointerEvents:"none",style:vg})}var vg=/* @__PURE__ */Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function wg(){let[e,t]=o(false);return a(()=>{let e=x;if(typeof e?.addListener!="function")return;let r=b.OS==="ios",n=e.addListener(r?"keyboardWillShow":"keyboardDidShow",()=>t(true)),l=e.addListener(r?"keyboardWillHide":"keyboardDidHide",()=>t(false));return()=>{n.remove(),l.remove()}},[]),e}var kg=4.5;var Cg=3;function Sg(e,t,r){return fs(e,t,is(t),r)}function xg(e,t){if(e.level==="emergency")return e;let r=e.level==="schedule_soon",n=np(t),l=r?n.warning:n.info,i=rp(t)&&!l?e:Rg(e,t,r);return Tg(i,t.slots.banner)}function Rg(e,t,r){let n=t.color,l=ds(r?n.badgeBgCaution:n.badgeBgInfo,n.surface)??n.surface,i=r?n.cautionAccent:n.infoEdge,o=Sg(ds(i,n.surface)??i,[n.surface,n.chatGround],Cg),a=Sg(r?n.warningStrong:n.info,[l,n.surface],kg);/* @__PURE__ */
242
+ return Object.freeze({...e,borderColor:o,backgroundColor:l,textColor:a,reasonColor:Sg(n.text.primary,[l],kg),pillColor:n.surface})}function Tg(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 _g(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 zg=.75,Ig=1.5,Pg=.4,Fg=4,Lg=1.5,Eg=22,Og=14,Ag=8,jg=20,Dg=10,Mg=13,Bg=12,Hg=15,Wg=44,Ng=14,Ug=1.25,$g=14,Vg=6,qg=2;function Gg(e,t){let r=e.color;if(t.level==="emergency")return{card:{backgroundColor:r.badgeBgCritical,borderColor:cs(r.danger,Pg)??r.danger,borderWidth:Ig},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:zg,...n===void 0?{}:{borderRadius:n}},label:t.textColor,reason:t.reasonColor,close:t.textColor,action:null}}function UrgencyBanner({surface:e,petRef:petRef,renderVetAction:t,onFindVet:r,vet:n,compact:i=false}){let o=useEverfurTheme(),a=l(()=>Kg(o),[o]),s=xo(),u=e.tier===null?null:xg(e.tier,o),d=e.source;/* @__PURE__ */
242
243
  return j(D,{children:[
243
244
  /* @__PURE__ */A(FadePresence,{visible:e.showBanner&&u!==null,inMs:s.bannerInMs,outMs:s.bannerOutMs,style:a.pinned,children:u!==null&&d!==null?/* @__PURE__ */A(BannerCard,{tier:u,reason:d.reason,surface:e,petRef:petRef,renderVetAction:t,onFindVet:r,vet:n,styles:a,compact:i}):null}),
244
- /* @__PURE__ */A(FadePresence,{visible:e.showCompactIcon,inMs:s.iconInMs,outMs:s.iconOutMs,style:a.indicatorRow,children:/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:He.showLatestVetAlert,hitSlop:Rg,onPress:e.expand,children:/* @__PURE__ */A(InfoGlyph,{size:xg,color:o.color.text.muted,strokeWidth:2})})})]})}function BannerCard({tier:e,reason:t,surface:r,petRef:petRef,renderVetAction:n,onFindVet:l,vet:i,styles:o,compact:a}){let s=useEverfurTheme(),u=Ag(s,e),d=/* @__PURE__ */A(VetAction,{tier:e,paint:u,petRef:petRef,onFindVet:l,vet:i,styles:o}),c=r.showVetAction?n!==void 0?/* @__PURE__ */A(HostRender,{render:()=>n(e.level),fallback:d,resetKey:e.level}):d:null,p=u.action!==null?/* @__PURE__ */A(PoisonControl,{paint:u.action,styles:o}):null,f=e.level==="emergency"&&l===void 0,h=e.level==="emergency"||e.level==="schedule_soon";/* @__PURE__ */
245
+ /* @__PURE__ */A(FadePresence,{visible:e.showCompactIcon,inMs:s.iconInMs,outMs:s.iconOutMs,style:a.indicatorRow,children:/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:Ne.showLatestVetAlert,hitSlop:Dg,onPress:e.expand,children:/* @__PURE__ */A(InfoGlyph,{size:jg,color:o.color.text.muted,strokeWidth:2})})})]})}function BannerCard({tier:e,reason:t,surface:r,petRef:petRef,renderVetAction:n,onFindVet:l,vet:i,styles:o,compact:a}){let s=useEverfurTheme(),u=Gg(s,e),d=/* @__PURE__ */A(VetAction,{tier:e,paint:u,petRef:petRef,onFindVet:l,vet:i,styles:o}),c=r.showVetAction?n!==void 0?/* @__PURE__ */A(HostRender,{render:()=>n(e.level),fallback:d,resetKey:e.level}):d:null,p=u.action!==null?/* @__PURE__ */A(PoisonControl,{paint:u.action,styles:o}):null,f=e.level==="emergency"&&l===void 0,h=e.level==="emergency"||e.level==="schedule_soon";/* @__PURE__ */
245
246
  return j(v,{...h?{accessibilityRole:"alert"}:{accessibilityLiveRegion:"polite"},style:[o.card,u.card,a?o.cardCompact:null],testID:a?"chat-urgency-compact":void 0,children:[
246
- /* @__PURE__ */A(Text,{tier:"control",style:[o.label,{color:u.label}],children:e.label}),t!==null?/* @__PURE__ */A(Text,{style:[o.reason,{color:u.reason}],numberOfLines:a?Og:void 0,accessibilityLabel:a?t:void 0,children:t}):null,f?/* @__PURE__ */A(Text,{style:[o.reason,o.erLine,{color:u.reason}],children:He.goToNearestEmergencyVet}):null,c!==null||p!==null?/* @__PURE__ */j(v,{style:o.actions,children:[c,p]}):null,r.dismissLabel!==null?/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:r.dismissLabel,hitSlop:Sg,containerStyle:o.closeSlot,style:o.closeButton,onPress:r.dismiss,children:/* @__PURE__ */A(CloseGlyph,{size:Cg,color:u.close,strokeWidth:1.5})}):null]})}function PoisonControl({paint:e,styles:t}){let r=()=>{try{w.openURL($e).catch(()=>{})}catch{}};/* @__PURE__ */
247
- return A(PressScale,{accessibilityRole:"button",accessibilityLabel:He.poisonControlNative,hitSlop:0,style:[t.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:r,children:/* @__PURE__ */A(Text,{tier:"control",style:[t.actionLabel,{color:e.ink}],children:He.poisonControlNative})})}function VetAction({tier:e,paint:t,petRef:petRef,onFindVet:r,vet:n,styles:l}){let i=useEverfurTheme(),o=useVetVisit(gg(petRef,n)),a=o.status==="opening",s=!o.available&&r!==void 0,u=o.available?()=>{o.open()}:r!==void 0?()=>{Gr(r,e.level)}:null;if(u===null)return null;let d=t.action;if(d!==null){let e=s?He.nearestEmergencyVet:He.findVet,t=Zo(i.slots.vetVisitButton)?.textColor??d.ink;/* @__PURE__ */
248
- return j(PressScale,{accessibilityRole:"button",accessibilityLabel:s?He.nearestEmergencyVet:He.findVetA11y,accessibilityState:{busy:a},hitSlop:0,style:[l.action,{backgroundColor:d.fill,borderColor:d.edge},l.findVetSlotBox,a?l.findVetBusy:null],onPress:u,children:[
249
- /* @__PURE__ */A(MapPinGlyph,{size:Tg,color:t,strokeWidth:1.5}),
250
- /* @__PURE__ */A(Text,{tier:"control",style:[l.actionLabel,{color:t}],children:e})]})}let c=Zo(i.slots.vetVisitButton)?.textColor??e.textColor;/* @__PURE__ */
251
- return j(PressScale,{accessibilityRole:"button",accessibilityLabel:He.findVetA11y,accessibilityState:{busy:a},style:[l.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},l.findVetSlotBox,a?l.findVetBusy:null],onPress:u,children:[
252
- /* @__PURE__ */A(MapPinGlyph,{size:Tg,color:c,strokeWidth:1.5}),
253
- /* @__PURE__ */A(Text,{tier:"control",style:[l.findVetLabel,{color:c}],children:He.findVet})]})}function jg(e){let t=Zo(e.slots.vetVisitButton),r=e.space,n=e.type;return g.create({pinned:{marginTop:0,marginBottom:r.xs,paddingHorizontal:r.lg},card:{borderRadius:e.radius.lg,paddingHorizontal:r.lg+vg,paddingVertical:r.lg,gap:r.sm},cardCompact:{paddingVertical:r.md,gap:r.xs},label:{...face(e,"bold"),fontSize:n.size.body,paddingRight:kg},reason:{...face(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*wg),paddingRight:kg},erLine:{...face(e,"bold")},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm},action:{flexDirection:"row",alignItems:"center",gap:Eg,minHeight:Ig,paddingHorizontal:Pg,borderRadius:e.radius.pill,borderWidth:Fg},actionLabel:{...face(e,"bold"),fontSize:Lg},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...Qo(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...face(e,"monoBold"),fontSize:_g,lineHeight:zg},closeSlot:{position:"absolute",top:r.md,right:r.md},closeButton:{width:kg,height:kg,borderRadius:kg/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:r.lg,paddingTop:2,paddingBottom:r.xs}})}function Dg(e,userRef,petRef,t){let[r,n]=o({pet:petRef,user:userRef}),l=r.pet!==petRef||r.user===null&&userRef!==null;l&&n({pet:petRef,user:userRef});let i=l?{user:userRef}:r,s=petRef!==null&&i.user!==null&&i.user!==userRef;return a(()=>{if(!s||userRef===null||petRef===null)return;let t=true,r=createPetsRepository(e.registry.services.authFor(userRef)),l=async()=>{let e=await r.list();t&&e.ok&&e.value.some(e=>e.petRef===petRef)&&n({pet:petRef,user:userRef})};l();let i=rc(e,()=>{l()});return()=>{t=false,i()}},[s,e,userRef,petRef,t]),s}var Mg=/* @__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(e){let{runtime:t,userRef:userRef,activePet:r,scopeEpoch:u}=Ye(),petRef=e?.petRef??r??null,conversationId=e?.conversationId??null,d=Dg(t,userRef,petRef,u),c=l(()=>({runtime:t,userRef:userRef,petRef:petRef,conversationId:conversationId,scopeEpoch:u,held:d}),[t,userRef,petRef,conversationId,u,d]),[p,f]=o(null),h=d?null:p?.scope===c?p.controller:t.registry.peekChat({userRef:userRef,petRef:petRef,conversationId:conversationId}),g=i(null);a(()=>{if(d)return;let e=t.registry.acquireChat({userRef:userRef,petRef:petRef,conversationId:conversationId});return g.current=e,f({scope:c,controller:e}),()=>{g.current=null,f(t=>t?.controller===e?null:t),t.registry.releaseChat(e)}},[t,userRef,petRef,conversationId,u,d,c]);let b=n(e=>h?h.subscribe(e):NOOP_UNSUBSCRIBE,[h]),y=n(()=>h?h.getSnapshot():Mg,[h]),m=s(b,y,y),v=n((e,t)=>h&&g.current===h&&!h.getSnapshot().isBootstrapping?Hg(h,h.send(e,t?.imageS3Keys===void 0?{}:{imageS3Keys:t.imageS3Keys}),()=>g.current===h):Promise.resolve(Ng()),[h]),w=n(e=>h&&g.current===h&&!h.getSnapshot().isBootstrapping?Hg(h,h.askEverfur(e),()=>g.current===h):Promise.resolve(Ng()),[h]),k=n(()=>h&&g.current===h?Hg(h,h.retryLast(),()=>g.current===h):Promise.resolve(Ng()),[h]),C=n(()=>{h&&g.current===h&&h.stop()},[h]),S=n(()=>{h&&g.current===h&&h.newConversation()},[h]),[x,R]=o({controller:null,byMessage:{}}),T=x.controller===h?x.byMessage:Bg,_=n(async(e,t,r,n)=>{if(!h||g.current!==h)return err(makeEverfurError("accessDenied"));let l=String(e),i=x.controller===h?x.byMessage[l]:void 0;if(i===t&&r==null)return R(e=>{let t={...e.controller===h?e.byMessage:{}};return delete t[l],{controller:h,byMessage:t}}),ok(/* @__PURE__ */Object.freeze({feedbackId:""}));R(e=>({controller:h,byMessage:{...e.controller===h?e.byMessage:{},[l]:t}}));let o=await h.submitFeedback(e,Wp(t,r??null),n??null);return g.current!==h?err(makeEverfurError("accessDenied")):(o.ok||R(e=>{let t={...e.controller===h?e.byMessage:{}};return i===void 0?delete t[l]:t[l]=i,{controller:h,byMessage:t}}),o)},[h,x]),z=l(()=>{let e=async e=>{if(!h||g.current!==h)return err(makeEverfurError("accessDenied"));let t=await e(h);return g.current===h?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))}},[h,petRef]);return l(()=>({status:m.status,messages:m.messages,conversationId:m.conversationId,petRef:petRef,error:m.error,isStreaming:m.isStreaming,isBootstrapping:m.isBootstrapping,historyCursor:m.historyCursor??null,isLoadingHistory:m.isLoadingHistory??false,stopped:m.stopped??false,reconnecting:m.reconnecting??false,...z,suggestedPrompts:m.suggestedPrompts,unreadCount:m.unreadCount,hasUnreadThreads:m.hasUnreadThreads??false,pendingCheckin:m.pendingCheckin??null,newConversation:S,sentimentByMessage:T,feedback:_,send:v,askEverfur:w,retryLast:k,stop:C}),[m,petRef,v,w,k,C,z,S,T,_])}var NOOP_UNSUBSCRIBE=()=>{},Bg=/* @__PURE__ */Object.freeze({});async function Hg(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(Wg(n.messages))}function Wg(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 Ng(){return Kl()}function Ug(){let e=useEverfurPets(),{handle:t}=Ye(),r=n(petRef=>t.setActivePet(petRef),[t]);return l(()=>({...e,setActivePet:r}),[e,r])}function $g(){try{let e=I?.announceForAccessibility;typeof e=="function"&&e.call(I,He.answered)}catch{}}function Vg(e){let t=i(false),r=i({send:e.send,id:e.conversationId});a(()=>{let n=r.current;if((n.send!==e.send||n.id!==null&&n.id!==e.conversationId)&&(t.current=false),r.current={send:e.send,id:e.conversationId},t.current&&!e.isStreaming){let t=e.messages[e.messages.length-1];t!==void 0&&t.role==="assistant"&&$g()}t.current=e.isStreaming},[e.isStreaming,e.messages,e.send,e.conversationId])}var qg=/* @__PURE__ */Object.freeze({kind:"live"}),Gg=/* @__PURE__ */Object.freeze({kind:"folded"});function Kg(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=vi(e.proactiveOriginRef);return{caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}function Yg(e){let t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(let t of e){let e=Kg(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=Kg(l);if(e===null){n=null;continue}if(r.get(e.caseId)?.messageId===l.id){t.set(l.id,qg),n=null;continue}if(n!==null&&n.caseId===e.caseId){n.days.push(e.dueDay),t.set(l.id,Gg);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 Qg(e){let t=/* @__PURE__ */new Set;for(let[r,n]of e)n.kind==="live"&&t.add(r);return t}var Zg=864e5,Jg=365;function Xg(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/Zg)-Math.floor(r/Zg);return l<1||l>Jg?null:l}function eb(e){return Kg(e)?.dueDay||null}function tb(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:t,styles:r}){let n=Nc(e);return n.shown?/* @__PURE__ */j(v,{style:r.assistantSender,testID:"everfur-assistant-sender",children:[
254
- /* @__PURE__ */A(BrandImage,{uri:e,decorative:true,style:r.assistantAvatar,resizeMode:"cover",onError:n.onError,testID:"everfur-assistant-avatar"}),t?/* @__PURE__ */A(Text,{tier:"control",style:[r.assistantName,r.assistantNameInRow],children:He.assistantName}):null]}):t?/* @__PURE__ */A(Text,{tier:"control",style:r.assistantName,children:He.assistantName}):null}var rb=/* @__PURE__ */Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),nb="#C8BEB4";function lb(e){return e?rb[e.toUpperCase()]??nb:nb}function ib(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}function ob(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}function ab(e){let t=ob(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}function sb(e,t){let r=ob(e.source_name)??ob(e.sourceName),n=ob(e.section),l=ob(e.authority_tier)??ob(e.authorityTier),i=ib(l),o=r??ob(e.title)??`Source ${t+1}`,a=ob(e.monograph_chunk_id)??ob(e.chunkId),s=[n,i].filter(e=>e!==null).join(" · ");/* @__PURE__ */
255
- return Object.freeze({title:o,sourceName:r,section:n,authorityTier:l,tierLabel:i,meta:s.length===0?null:s,url:ab(e.url),excerpt:ob(e.excerpt),tierColor:lb(l),key:`${o}-${a??"none"}-${t}`})}function ub(e){return e===void 0||e.length===0?db:/* @__PURE__ */Object.freeze(e.map((e,t)=>sb(e,t)))}var db=/* @__PURE__ */Object.freeze([]);function cb(e){return e===1?`1 ${He.sourceSingular}`:`${e} ${He.sourcePlural}`}function pb(e,t){return`${t?He.hideSources:He.showSources} ${cb(e)}`}function fb(e){return[e.url!==null?`${He.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(e=>e!==null&&e.length>0).join(". ")}var hb="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__):hb;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 bb(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.*)$/,mb=/^\s*(\d{1,3})[.)]\s+(\S.*)$/;function vb(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?mb.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 wb(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 kb(e,t){if(e===void 0)return[];try{let r=e(t);return Array.isArray(r)?r:[]}catch{return[]}}function Cb(e){return hardenHttpsUrl(e.trim())}function Sb(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?[]:kb(t.followUpActions,{answer:r.text,question:wb(e.messages,r.id),messageId:r.id})}var xb=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g,Rb=new RegExp(`\\[([^\\]\\n]{1,300})\\]\\((https:\\/\\/[^\\s()<>]{1,${no}})\\)|(https:\\/\\/[^\\s<>"'\`*\\[\\]]{1,${no}})`,"gi"),Tb=/https:\/\//i,_b=`.,;:!?'"`;function zb(e,t){return e.includes("*")||e.includes("`")||t!==void 0&&Tb.test(e)}function Ib(e,t){let r=[],n=e=>{t===void 0?r.push({kind:"text",text:e}):Lb(r,e,t)},l=0;xb.lastIndex=0;for(let t=xb.exec(e);t!==null;t=xb.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 Pb(e){let t=e.length;for(;;){let r=e[t-1];if(r===void 0)break;if(_b.includes(r))t-=1;else if(r===")"&&Fb(e,"(",t)<Fb(e,")",t))t-=1;else break}return e.slice(0,t)}function Fb(e,t,r){let n=0;for(let l=0;l<r;l+=1)e[l]===t&&(n+=1);return n}function Lb(e,t,r){if(!Tb.test(t)){e.push({kind:"text",text:t});return}let n=0;Rb.lastIndex=0;for(let l=Rb.exec(t);l!==null;l=Rb.exec(t)){let i=l[1],o=l[2],a=l[3],s,u,d;if(i!==void 0&&o!==void 0)s=i.trim(),u=s.length>0?ao(o,r):null,d=l[0].length;else if(a!==void 0)s=Pb(a),u=ao(s,r),d=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+d,Rb.lastIndex=n)}n<t.length&&e.push({kind:"text",text:t.slice(n)})}var Eb=/* @__PURE__ */Object.freeze({textDecorationLine:"underline"});function Ob(e,t){return t===void 0||!zb(e,t.hosts)?false:Ib(e,t.hosts).some(e=>e.kind==="link")}function Ab(e,t,r){let n=r?.hosts;return zb(e,n)?Ib(e,n).map((e,n)=>{switch(e.kind){case"bold":/* @__PURE__ */
247
+ /* @__PURE__ */A(Text,{tier:"control",style:[o.label,{color:u.label}],children:e.label}),t!==null?/* @__PURE__ */A(Text,{style:[o.reason,{color:u.reason}],numberOfLines:a?qg:void 0,accessibilityLabel:a?t:void 0,children:t}):null,f?/* @__PURE__ */A(Text,{style:[o.reason,o.erLine,{color:u.reason}],children:Ne.goToNearestEmergencyVet}):null,c!==null||p!==null?/* @__PURE__ */j(v,{style:o.actions,children:[c,p]}):null,r.dismissLabel!==null?/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:r.dismissLabel,hitSlop:Ag,containerStyle:o.closeSlot,style:o.closeButton,onPress:r.dismiss,children:/* @__PURE__ */A(CloseGlyph,{size:Og,color:u.close,strokeWidth:1.5})}):null]})}function PoisonControl({paint:e,styles:t}){let r=()=>{try{w.openURL(qe).catch(()=>{})}catch{}};/* @__PURE__ */
248
+ return A(PressScale,{accessibilityRole:"button",accessibilityLabel:Ne.poisonControlNative,hitSlop:0,style:[t.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:r,children:/* @__PURE__ */A(Text,{tier:"control",style:[t.actionLabel,{color:e.ink}],children:Ne.poisonControlNative})})}function VetAction({tier:e,paint:t,petRef:petRef,onFindVet:r,vet:n,styles:l}){let i=useEverfurTheme(),o=useVetVisit(_g(petRef,n)),a=o.status==="opening",s=!o.available&&r!==void 0,u=o.available?()=>{o.open()}:r!==void 0?()=>{Yr(r,e.level)}:null;if(u===null)return null;let d=t.action;if(d!==null){let e=s?Ne.nearestEmergencyVet:Ne.findVet,t=Xo(i.slots.vetVisitButton)?.textColor??d.ink;/* @__PURE__ */
249
+ return j(PressScale,{accessibilityRole:"button",accessibilityLabel:s?Ne.nearestEmergencyVet:Ne.findVetA11y,accessibilityState:{busy:a},hitSlop:0,style:[l.action,{backgroundColor:d.fill,borderColor:d.edge},l.findVetSlotBox,a?l.findVetBusy:null],onPress:u,children:[
250
+ /* @__PURE__ */A(MapPinGlyph,{size:Mg,color:t,strokeWidth:1.5}),
251
+ /* @__PURE__ */A(Text,{tier:"control",style:[l.actionLabel,{color:t}],children:e})]})}let c=Xo(i.slots.vetVisitButton)?.textColor??e.textColor;/* @__PURE__ */
252
+ return j(PressScale,{accessibilityRole:"button",accessibilityLabel:Ne.findVetA11y,accessibilityState:{busy:a},style:[l.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},l.findVetSlotBox,a?l.findVetBusy:null],onPress:u,children:[
253
+ /* @__PURE__ */A(MapPinGlyph,{size:Mg,color:c,strokeWidth:1.5}),
254
+ /* @__PURE__ */A(Text,{tier:"control",style:[l.findVetLabel,{color:c}],children:Ne.findVet})]})}function Kg(e){let t=Xo(e.slots.vetVisitButton),r=e.space,n=e.type;return g.create({pinned:{marginTop:0,marginBottom:r.xs,paddingHorizontal:r.lg},card:{borderRadius:e.radius.lg,paddingHorizontal:r.lg+Fg,paddingVertical:r.lg,gap:r.sm},cardCompact:{paddingVertical:r.md,gap:r.xs},label:{...face(e,"bold"),fontSize:n.size.body,paddingRight:Eg},reason:{...face(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*Lg),paddingRight:Eg},erLine:{...face(e,"bold")},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm},action:{flexDirection:"row",alignItems:"center",gap:Vg,minHeight:Wg,paddingHorizontal:Ng,borderRadius:e.radius.pill,borderWidth:Ug},actionLabel:{...face(e,"bold"),fontSize:$g},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...Jo(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...face(e,"monoBold"),fontSize:Bg,lineHeight:Hg},closeSlot:{position:"absolute",top:r.md,right:r.md},closeButton:{width:Eg,height:Eg,borderRadius:Eg/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:r.lg,paddingTop:2,paddingBottom:r.xs}})}var Yg=/* @__PURE__ */Symbol.for("everfur.sdk.tabsBar.v1");function Qg(){return globalThis[Yg]??null}function Zg(e){return e==="tabs_bar"&&Qg()!==null}function SeverityCard(e){let t=Qg()?.ask.SeverityCard;return t===void 0?null:/* @__PURE__ */A(t,{...e})}function AnswerRecordCards(e){let t=Qg()?.ask.AnswerRecordCards;return t===void 0?null:/* @__PURE__ */A(t,{...e})}function PrivacyLine(e){let t=Qg()?.ask.PrivacyLine;return t===void 0?null:/* @__PURE__ */A(t,{...e})}function AskBarDisclaimer(){let e=Qg()?.ask.AskBarDisclaimer;return e===void 0?null:/* @__PURE__ */A(e,{})}function Jg(e,userRef,petRef,t){let[r,n]=o({pet:petRef,user:userRef}),l=r.pet!==petRef||r.user===null&&userRef!==null;l&&n({pet:petRef,user:userRef});let i=l?{user:userRef}:r,s=petRef!==null&&i.user!==null&&i.user!==userRef;return a(()=>{if(!s||userRef===null||petRef===null)return;let t=true,r=createPetsRepository(e.registry.services.authFor(userRef)),l=async()=>{let e=await r.list();t&&e.ok&&e.value.some(e=>e.petRef===petRef)&&n({pet:petRef,user:userRef})};l();let i=dc(e,()=>{l()});return()=>{t=false,i()}},[s,e,userRef,petRef,t]),s}var Xg=/* @__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(e){let{runtime:t,userRef:userRef,activePet:r,scopeEpoch:u}=Ze(),petRef=e?.petRef??r??null,conversationId=e?.conversationId??null,d=Jg(t,userRef,petRef,u),c=l(()=>({runtime:t,userRef:userRef,petRef:petRef,conversationId:conversationId,scopeEpoch:u,held:d}),[t,userRef,petRef,conversationId,u,d]),[p,f]=o(null),h=d?null:p?.scope===c?p.controller:t.registry.peekChat({userRef:userRef,petRef:petRef,conversationId:conversationId}),g=i(null);a(()=>{if(d)return;let e=t.registry.acquireChat({userRef:userRef,petRef:petRef,conversationId:conversationId});return g.current=e,f({scope:c,controller:e}),()=>{g.current=null,f(t=>t?.controller===e?null:t),t.registry.releaseChat(e)}},[t,userRef,petRef,conversationId,u,d,c]);let b=n(e=>h?h.subscribe(e):NOOP_UNSUBSCRIBE,[h]),y=n(()=>h?h.getSnapshot():Xg,[h]),m=s(b,y,y),v=n((e,t)=>h&&g.current===h&&!h.getSnapshot().isBootstrapping?tb(h,h.send(e,t?.imageS3Keys===void 0?{}:{imageS3Keys:t.imageS3Keys}),()=>g.current===h):Promise.resolve(nb()),[h]),w=n(e=>h&&g.current===h&&!h.getSnapshot().isBootstrapping?tb(h,h.askEverfur(e),()=>g.current===h):Promise.resolve(nb()),[h]),k=n(()=>h&&g.current===h?tb(h,h.retryLast(),()=>g.current===h):Promise.resolve(nb()),[h]),C=n(()=>{h&&g.current===h&&h.stop()},[h]),S=n(()=>{h&&g.current===h&&h.newConversation()},[h]),[x,R]=o({controller:null,byMessage:{}}),T=x.controller===h?x.byMessage:eb,_=n(async(e,t,r,n)=>{if(!h||g.current!==h)return err(makeEverfurError("accessDenied"));let l=String(e),i=x.controller===h?x.byMessage[l]:void 0;if(i===t&&r==null)return R(e=>{let t={...e.controller===h?e.byMessage:{}};return delete t[l],{controller:h,byMessage:t}}),ok(/* @__PURE__ */Object.freeze({feedbackId:""}));R(e=>({controller:h,byMessage:{...e.controller===h?e.byMessage:{},[l]:t}}));let o=await h.submitFeedback(e,Yp(t,r??null),n??null);return g.current!==h?err(makeEverfurError("accessDenied")):(o.ok||R(e=>{let t={...e.controller===h?e.byMessage:{}};return i===void 0?delete t[l]:t[l]=i,{controller:h,byMessage:t}}),o)},[h,x]),z=l(()=>{let e=async e=>{if(!h||g.current!==h)return err(makeEverfurError("accessDenied"));let t=await e(h);return g.current===h?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))}},[h,petRef]);return l(()=>({status:m.status,messages:m.messages,conversationId:m.conversationId,petRef:petRef,error:m.error,isStreaming:m.isStreaming,isBootstrapping:m.isBootstrapping,historyCursor:m.historyCursor??null,isLoadingHistory:m.isLoadingHistory??false,stopped:m.stopped??false,reconnecting:m.reconnecting??false,...z,suggestedPrompts:m.suggestedPrompts,unreadCount:m.unreadCount,hasUnreadThreads:m.hasUnreadThreads??false,pendingCheckin:m.pendingCheckin??null,newConversation:S,sentimentByMessage:T,feedback:_,send:v,askEverfur:w,retryLast:k,stop:C}),[m,petRef,v,w,k,C,z,S,T,_])}var NOOP_UNSUBSCRIBE=()=>{},eb=/* @__PURE__ */Object.freeze({});async function tb(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(rb(n.messages))}function rb(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 nb(){return Ql()}function lb(){let e=useEverfurPets(),{handle:t}=Ze(),r=n(petRef=>t.setActivePet(petRef),[t]);return l(()=>({...e,setActivePet:r}),[e,r])}function ib(){try{let e=I?.announceForAccessibility;typeof e=="function"&&e.call(I,Ne.answered)}catch{}}function ob(e){let t=i(false),r=i({send:e.send,id:e.conversationId});a(()=>{let n=r.current;if((n.send!==e.send||n.id!==null&&n.id!==e.conversationId)&&(t.current=false),r.current={send:e.send,id:e.conversationId},t.current&&!e.isStreaming){let t=e.messages[e.messages.length-1];t!==void 0&&t.role==="assistant"&&ib()}t.current=e.isStreaming},[e.isStreaming,e.messages,e.send,e.conversationId])}var ab=/* @__PURE__ */Object.freeze({kind:"live"}),sb=/* @__PURE__ */Object.freeze({kind:"folded"});function ub(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=ki(e.proactiveOriginRef);return{caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}function db(e){let t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(let t of e){let e=ub(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=ub(l);if(e===null){n=null;continue}if(r.get(e.caseId)?.messageId===l.id){t.set(l.id,ab),n=null;continue}if(n!==null&&n.caseId===e.caseId){n.days.push(e.dueDay),t.set(l.id,sb);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 cb(e){let t=/* @__PURE__ */new Set;for(let[r,n]of e)n.kind==="live"&&t.add(r);return t}var pb=864e5,fb=365;function hb(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/pb)-Math.floor(r/pb);return l<1||l>fb?null:l}function gb(e){return ub(e)?.dueDay||null}function bb(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:t,styles:r}){let n=Qc(e);return n.shown?/* @__PURE__ */j(v,{style:r.assistantSender,testID:"everfur-assistant-sender",children:[
255
+ /* @__PURE__ */A(BrandImage,{uri:e,decorative:true,style:r.assistantAvatar,resizeMode:"cover",onError:n.onError,testID:"everfur-assistant-avatar"}),t?/* @__PURE__ */A(Text,{tier:"control",style:[r.assistantName,r.assistantNameInRow],children:Ne.assistantName}):null]}):t?/* @__PURE__ */A(Text,{tier:"control",style:r.assistantName,children:Ne.assistantName}):null}var yb=/* @__PURE__ */Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),mb="#C8BEB4";function vb(e){return e?yb[e.toUpperCase()]??mb:mb}function wb(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}function kb(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}function Cb(e){let t=kb(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}function Sb(e,t){let r=kb(e.source_name)??kb(e.sourceName),n=kb(e.section),l=kb(e.authority_tier)??kb(e.authorityTier),i=wb(l),o=r??kb(e.title)??`Source ${t+1}`,a=kb(e.monograph_chunk_id)??kb(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:Cb(e.url),excerpt:kb(e.excerpt),tierColor:vb(l),key:`${o}-${a??"none"}-${t}`})}function xb(e){return e===void 0||e.length===0?Rb:/* @__PURE__ */Object.freeze(e.map((e,t)=>Sb(e,t)))}var Rb=/* @__PURE__ */Object.freeze([]);function Tb(e){return e===1?`1 ${Ne.sourceSingular}`:`${e} ${Ne.sourcePlural}`}function _b(e,t){return`${t?Ne.hideSources:Ne.showSources} ${Tb(e)}`}function zb(e){return[e.url!==null?`${Ne.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(e=>e!==null&&e.length>0).join(". ")}var Ib="https:\\/\\/sdk(?:-[a-z]+)?\\.everfur\\.com";function Pb(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}typeof __EVERFUR_BRAND_CDN_ORIGIN__=="string"&&__EVERFUR_BRAND_CDN_ORIGIN__.length>0?Pb(__EVERFUR_BRAND_CDN_ORIGIN__):Ib;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 Fb(e){let t=e.split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:[e]}var Lb=/^\s*[-*]\s+(\S.*)$/,Eb=/^\s*(\d{1,3})[.)]\s+(\S.*)$/;function Ob(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=Lb.exec(t),o=e===null?Eb.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 Ab(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 jb(e,t){if(e===void 0)return[];try{let r=e(t);return Array.isArray(r)?r:[]}catch{return[]}}function Db(e){return hardenHttpsUrl(e.trim())}function Mb(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?[]:jb(t.followUpActions,{answer:r.text,question:Ab(e.messages,r.id),messageId:r.id})}var Bb=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g,Hb=new RegExp(`\\[([^\\]\\n]{1,300})\\]\\((https:\\/\\/[^\\s()<>]{1,${io}})\\)|(https:\\/\\/[^\\s<>"'\`*\\[\\]]{1,${io}})`,"gi"),Wb=/https:\/\//i,Nb=`.,;:!?'"`;function Ub(e,t){return e.includes("*")||e.includes("`")||t!==void 0&&Wb.test(e)}function $b(e,t){let r=[],n=e=>{t===void 0?r.push({kind:"text",text:e}):Gb(r,e,t)},l=0;Bb.lastIndex=0;for(let t=Bb.exec(e);t!==null;t=Bb.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 Vb(e){let t=e.length;for(;;){let r=e[t-1];if(r===void 0)break;if(Nb.includes(r))t-=1;else if(r===")"&&qb(e,"(",t)<qb(e,")",t))t-=1;else break}return e.slice(0,t)}function qb(e,t,r){let n=0;for(let l=0;l<r;l+=1)e[l]===t&&(n+=1);return n}function Gb(e,t,r){if(!Wb.test(t)){e.push({kind:"text",text:t});return}let n=0;Hb.lastIndex=0;for(let l=Hb.exec(t);l!==null;l=Hb.exec(t)){let i=l[1],o=l[2],a=l[3],s,u,d;if(i!==void 0&&o!==void 0)s=i.trim(),u=s.length>0?uo(o,r):null,d=l[0].length;else if(a!==void 0)s=Vb(a),u=uo(s,r),d=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+d,Hb.lastIndex=n)}n<t.length&&e.push({kind:"text",text:t.slice(n)})}var Kb=/* @__PURE__ */Object.freeze({textDecorationLine:"underline"});function Yb(e,t){return t===void 0||!Ub(e,t.hosts)?false:$b(e,t.hosts).some(e=>e.kind==="link")}function Qb(e,t,r){let n=r?.hosts;return Ub(e,n)?$b(e,n).map((e,n)=>{switch(e.kind){case"bold":/* @__PURE__ */
256
257
  return A(Text,{style:t.bold,children:e.text},n);case"italic":return t.italic?/* @__PURE__ */A(Text,{style:t.italic,children:e.text},n):e.text;case"code":return t.code?/* @__PURE__ */A(Text,{style:t.code,children:e.text},n):e.text;case"link":{if(r===void 0)return e.text;let{href:t}=e;/* @__PURE__ */
257
- return A(Text,{style:Eb,accessibilityRole:"link",accessibilityLabel:e.text,onPress:()=>r.open(t),children:e.text},n)}default:return e.text}}):e}var jb=10.5,Db=16,Mb=12,Bb=38,Hb=11,Wb=15,Nb=22,Ub=32,$b=13.5,Vb=14,qb=15,Gb=16,Kb=13,Yb=13,Qb=26,Zb=21,Jb=42,Xb=1,ey=.06,ty=.07,ry=.12,ny="45%";function ly(){let e=useEverfurTheme(),t=l(()=>iy(e),[e]);return{theme:e,styles:t}}function Chevron({options:e,color:t}){let r=/* @__PURE__ */A(ChevronGlyph,{size:Gb,color:t,strokeWidth:2,direction:"right"}),n=e?.renderIcon;return n===void 0?r:/* @__PURE__ */A(HostRender,{render:()=>n("chevron"),fallback:r})}function AnswerCard({card:e,options:t}){let{theme:r,styles:n}=ly();if(e.render!==void 0){let r=e.render;/* @__PURE__ */
258
- return A(v,{style:[n.card,e.variant!==void 0?t?.styles?.cardVariant?.[e.variant]:null],accessible:false,accessibilityLabel:e.title,testID:"everfur-answer-host-card",children:/* @__PURE__ */A(HostRender,{render:r,fallback:null})})}let l=e.value!==void 0,i=t?.styles,o=[n.card,l?i?.cardStat:null,e.variant!==void 0?i?.cardVariant?.[e.variant]:null],a=e.tile?.tone,s=e.pill?.tone,u=e.tile?.imageUrl!==void 0?Cb(e.tile.imageUrl):null,d=/* @__PURE__ */j(D,{children:[l?null:/* @__PURE__ */A(v,{style:[n.tile,a!==void 0?i?.tileTone?.[a]:null],children:u!==null?/* @__PURE__ */A(z,{source:{uri:u},style:n.tileImage,accessibilityIgnoresInvertColors:true}):e.tile?.icon??null}),
258
+ return A(Text,{style:Kb,accessibilityRole:"link",accessibilityLabel:e.text,onPress:()=>r.open(t),children:e.text},n)}default:return e.text}}):e}var Zb=10.5,Jb=16,Xb=12,ey=38,ty=11,ry=15,ny=22,ly=32,iy=13.5,oy=14,ay=15,sy=16,uy=13,dy=13,cy=26,py=21,fy=42,hy=1,gy=.06,by=.07,yy=.12,my="45%";function vy(){let e=useEverfurTheme(),t=l(()=>wy(e),[e]);return{theme:e,styles:t}}function Chevron({options:e,color:t}){let r=/* @__PURE__ */A(ChevronGlyph,{size:sy,color:t,strokeWidth:2,direction:"right"}),n=e?.renderIcon;return n===void 0?r:/* @__PURE__ */A(HostRender,{render:()=>n("chevron"),fallback:r})}function AnswerCard({card:e,options:t}){let{theme:r,styles:n}=vy();if(e.render!==void 0){let r=e.render;/* @__PURE__ */
259
+ return A(v,{style:[n.card,e.variant!==void 0?t?.styles?.cardVariant?.[e.variant]:null],accessible:false,accessibilityLabel:e.title,testID:"everfur-answer-host-card",children:/* @__PURE__ */A(HostRender,{render:r,fallback:null})})}let l=e.value!==void 0,i=t?.styles,o=[n.card,l?i?.cardStat:null,e.variant!==void 0?i?.cardVariant?.[e.variant]:null],a=e.tile?.tone,s=e.pill?.tone,u=e.tile?.imageUrl!==void 0?Db(e.tile.imageUrl):null,d=/* @__PURE__ */j(D,{children:[l?null:/* @__PURE__ */A(v,{style:[n.tile,a!==void 0?i?.tileTone?.[a]:null],children:u!==null?/* @__PURE__ */A(z,{source:{uri:u},style:n.tileImage,accessibilityIgnoresInvertColors:true}):e.tile?.icon??null}),
259
260
  /* @__PURE__ */j(v,{style:n.cardWords,children:[
260
261
  /* @__PURE__ */A(Text,{tier:"control",style:n.cardTitle,children:e.title}),e.meta!==void 0?/* @__PURE__ */A(Text,{tier:"compact",style:n.cardMeta,children:e.meta}):null]}),l?/* @__PURE__ */j(Text,{tier:"control",style:n.stat,children:[e.value?.amount,e.value?.unit!==void 0?/* @__PURE__ */A(Text,{style:n.statUnit,children:e.value.unit}):null]}):/* @__PURE__ */j(D,{children:[e.pill!==void 0?/* @__PURE__ */A(v,{style:[n.pill,s!==void 0?i?.pillTone?.[s]:null],children:/* @__PURE__ */A(Text,{tier:"badge",style:[n.pillText,s!==void 0?i?.pillToneText?.[s]:null],numberOfLines:1,ellipsizeMode:"tail",children:e.pill.label})}):null,e.onPress!==void 0?/* @__PURE__ */A(Chevron,{options:t,color:r.color.text.muted}):null]})]});if(e.onPress!==void 0){let t=e.onPress;/* @__PURE__ */
261
- return A(C,{onPress:()=>{Gr(t)},accessibilityRole:"button",accessibilityLabel:e.title,style:o,children:d})}/* @__PURE__ */
262
- return A(v,{style:o,children:d})}function CardsAnswer({message:e,text:t,streaming:r,messages:n,options:i,sentiment:o,onSentiment:a,sender:s,footer:u,onOpenUrl:d}){let{styles:c}=ly(),p=l(()=>({answer:e.text,question:wb(n,e.id),messageId:e.id}),[e.text,e.id,n]),f=!r&&e.pending!==true,h=f?kb(i?.cards,p):[],g=l(()=>f?ub(e.citations):[],[f,e.citations]),b=i?.byline,y=i?.feedback!==void 0&&e.responseId!==void 0&&a!==void 0?i.feedback:null,m={bold:c.bold,italic:c.italic,code:c.code},w=co(),k=f?w:void 0;/* @__PURE__ */
262
+ return A(C,{onPress:()=>{Yr(t)},accessibilityRole:"button",accessibilityLabel:e.title,style:o,children:d})}/* @__PURE__ */
263
+ return A(v,{style:o,children:d})}function CardsAnswer({message:e,text:t,streaming:r,messages:n,options:i,sentiment:o,onSentiment:a,sender:s,footer:u,onOpenUrl:d}){let{styles:c}=vy(),p=l(()=>({answer:e.text,question:Ab(n,e.id),messageId:e.id}),[e.text,e.id,n]),f=!r&&e.pending!==true,h=f?jb(i?.cards,p):[],g=l(()=>f?xb(e.citations):[],[f,e.citations]),b=i?.byline,y=i?.feedback!==void 0&&e.responseId!==void 0&&a!==void 0?i.feedback:null,m={bold:c.bold,italic:c.italic,code:c.code},w=fo(),k=f?w:void 0;/* @__PURE__ */
263
264
  return j(v,{style:c.answer,testID:"everfur-answer-cards",children:[b!==void 0?/* @__PURE__ */j(v,{style:c.byline,children:[b.icon??null,
264
- /* @__PURE__ */A(Text,{tier:"compact",style:c.bylineText,children:b.label})]}):s,
265
- /* @__PURE__ */A(v,{style:c.body,children:bb(t).flatMap((e,t)=>vb(e).map((e,r)=>{let n=`${t}-${r}`;return e.kind==="text"?/* @__PURE__ */A(Text,{style:c.paragraph,children:Ab(e.text,m,k)},n):/* @__PURE__ */A(v,{style:c.list,children:e.items.map((t,r)=>/* @__PURE__ */j(v,{style:c.listItem,children:[
265
+ /* @__PURE__ */A(Text,{tier:"compact",style:c.bylineText,children:b.label})]}):s,f?/* @__PURE__ */A(SeverityCard,{message:e}):null,
266
+ /* @__PURE__ */A(v,{style:c.body,children:Fb(t).flatMap((e,t)=>Ob(e).map((e,r)=>{let n=`${t}-${r}`;return e.kind==="text"?/* @__PURE__ */A(Text,{style:c.paragraph,children:Qb(e.text,m,k)},n):/* @__PURE__ */A(v,{style:c.list,children:e.items.map((t,r)=>/* @__PURE__ */j(v,{style:c.listItem,children:[
266
267
  /* @__PURE__ */A(Text,{style:c.paragraph,children:e.ordered?`${e.start+r}.`:"•"}),
267
- /* @__PURE__ */A(Text,{style:[c.paragraph,c.listText],children:Ab(t,m,k)})]},r))},n)}))}),h.length>0?/* @__PURE__ */A(v,{style:c.cards,children:h.map(e=>/* @__PURE__ */A(AnswerCard,{card:e,options:i},e.key))}):null,f?/* @__PURE__ */A(ServerCardsSlot,{message:e}):null,g.length>0?/* @__PURE__ */j(v,{style:c.cards,accessibilityLabel:cb(g.length),children:[
268
- /* @__PURE__ */A(Text,{tier:"compact",style:c.label,children:He.sourcesHeading}),g.map(e=>{let t=e.url;/* @__PURE__ */
268
+ /* @__PURE__ */A(Text,{style:[c.paragraph,c.listText],children:Qb(t,m,k)})]},r))},n)}))}),h.length>0?/* @__PURE__ */A(v,{style:c.cards,children:h.map(e=>/* @__PURE__ */A(AnswerCard,{card:e,options:i},e.key))}):null,f?/* @__PURE__ */A(AnswerRecordCards,{message:e}):null,f?/* @__PURE__ */A(ServerCardsSlot,{message:e}):null,g.length>0?/* @__PURE__ */j(v,{style:c.cards,accessibilityLabel:Tb(g.length),children:[
269
+ /* @__PURE__ */A(Text,{tier:"compact",style:c.label,children:Ne.sourcesHeading}),g.map(e=>{let t=e.url;/* @__PURE__ */
269
270
  return A(AnswerCard,{card:{key:e.key,title:e.title,...e.meta!==null?{meta:e.meta}:{},tile:{icon:/* @__PURE__ */A(SourceTileGlyph,{})},...d!==void 0&&t!==null?{onPress:()=>d(t)}:{}},options:i},e.key)})]}):null,f&&y!==null&&a!==void 0?/* @__PURE__ */j(v,{style:[c.feedback,i?.styles?.feedback],children:[
270
271
  /* @__PURE__ */A(FeedbackChip,{label:y.helpful,on:o==="up",onPress:()=>a("up"),styles:c,host:i?.styles}),
271
272
  /* @__PURE__ */A(FeedbackChip,{label:y.notHelpful,on:o==="down",onPress:()=>a("down"),styles:c,host:i?.styles})]}):null,f?u(y===null):null]})}function SourceTileGlyph(){let e=useEverfurTheme();/* @__PURE__ */
272
- return A(BookGlyph,{size:Zb,color:e.color.linkInk,strokeWidth:1.5})}function FeedbackChip({label:e,on:t,onPress:r,styles:n,host:l}){/* @__PURE__ */
273
- return A(C,{onPress:r,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{selected:t},style:[n.chip,l?.feedbackChip,t?n.chipOn:null],hitSlop:(Ns-Ub)/2,children:/* @__PURE__ */A(Text,{tier:"control",style:[n.chipText,l?.feedbackChipText],children:e})})}function CardsFollowUps({prompts:e,onSelectPrompt:t,label:r,actions:n,options:l}){let{theme:i,styles:o}=ly();if(e.length===0&&n.length===0)return null;let a=l?.styles,s=r??He.followUpsHeadingNative;/* @__PURE__ */
274
- return j(v,{style:[o.followUps,a?.followUps],accessibilityLabel:s,testID:"everfur-cards-follow-ups",children:[
275
- /* @__PURE__ */A(Text,{tier:"compact",style:[o.label,a?.followUpsLabel],accessibilityRole:"header",children:s}),n.map(e=>/* @__PURE__ */j(C,{onPress:()=>{Gr(e.onPress)},accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Xb,style:[o.row,o.rowAction,a?.followUp,a?.followUpAction],children:[e.icon??null,
276
- /* @__PURE__ */A(Text,{tier:"control",style:[o.rowText,o.rowTextAction,a?.followUpText,a?.followUpActionText],children:e.label}),
277
- /* @__PURE__ */A(Chevron,{options:l,color:i.color.text.primary})]},`action:${e.key}`)),e.map(e=>/* @__PURE__ */j(C,{onPress:()=>t(e),accessibilityRole:"button",accessibilityLabel:e,hitSlop:Xb,style:[o.row,a?.followUp],children:[
278
- /* @__PURE__ */A(Text,{tier:"control",style:[o.rowText,a?.followUpText],children:e}),
279
- /* @__PURE__ */A(Chevron,{options:l,color:i.color.linkInk})]},e))]})}function CardsByline({label:e}){let{styles:t}=ly();/* @__PURE__ */
280
- return A(v,{style:t.byline,children:/* @__PURE__ */A(Text,{tier:"compact",style:t.bylineText,children:e})})}function iy(e){let t=e.color,r=e.space,n={...face(e,"mono"),fontSize:jb,textTransform:"uppercase",color:t.text.muted},l={borderWidth:1,borderColor:t.borderRingCream},i={borderWidth:1,borderColor:us(t.text.primary,ey)??t.borderRingCream},o={shadowColor:t.text.primary,shadowOffset:{width:0,height:1},shadowOpacity:ty,shadowRadius:2,elevation:1},a=textRole(e,"message"),chipInk=Jo(e.slots.chip);return g.create({answer:{gap:r.md,alignSelf:"stretch"},byline:{flexDirection:"row",alignItems:"center",gap:10,minHeight:14},bylineText:{...n,letterSpacing:jb*.06,flexShrink:1},body:{gap:10},paragraph:{...face(e,"regular"),fontSize:a.fontSize,lineHeight:Math.round(a.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:Mb,borderRadius:Db,backgroundColor:t.surface,...i,...o,minHeight:Ns,...Qo(e.slots.card)},tile:{width:Bb,height:Bb,borderRadius:Hb,backgroundColor:us(t.linkInk,ry)??t.surfaceSubtle,alignItems:"center",justifyContent:"center",overflow:"hidden"},tileImage:{width:Bb,height:Bb},cardWords:{flex:1,minWidth:0},cardTitle:{...face(e,"bold"),fontSize:Wb,lineHeight:Math.round(Wb*1.25),color:t.text.primary,...Jo(e.slots.card)},cardMeta:{...n,letterSpacing:jb*.04,marginTop:3},stat:{...face(e,"mono"),fontSize:Nb,color:t.text.primary},statUnit:{...face(e,"mono"),fontSize:jb+2,color:t.text.muted},pill:{minHeight:Qb,paddingHorizontal:10,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,justifyContent:"center",flexShrink:1,maxWidth:ny},pillText:{...face(e,"bold"),fontSize:Yb,color:t.text.primary},feedback:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,alignItems:"center"},chip:{minHeight:Ub,paddingHorizontal:12,borderRadius:e.radius.pill,...l,justifyContent:"center"},chipOn:{backgroundColor:t.surfaceSubtle},chipText:{...rh(e),fontSize:$b,color:t.text.primary,...chipInk},followUps:{gap:r.sm,alignSelf:"stretch",marginTop:r.xs},label:{...face(e,"bold"),fontSize:Kb,lineHeight:Math.round(Kb*1.5),color:t.text.muted,marginTop:2},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:Jb,paddingTop:11,paddingBottom:11,paddingRight:12,paddingLeft:14,borderRadius:Vb,backgroundColor:t.surface,...i},rowAction:{},rowText:{...rh(e),flex:1,fontSize:qb,lineHeight:Math.round(qb*1.3),color:t.linkInk},rowTextAction:{color:t.text.primary}})}var oy=/* @__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"})}),ay=/* @__PURE__ */Object.freeze(hi.map(e=>/* @__PURE__ */Object.freeze({answer:e,label:oy.answers[e]})));function sy(e,t){let[r,l]=o(null),[i,a]=o(null),[s,u]=o(null),d=n(r=>{t!==null&&(l(r),a(null),t(e.caseId,r).then(e=>{l(null),e.ok?u(r):a(e.error)}))},[t,e.caseId]),c=s??e.answer;return{answer:c,answerable:!isCheckinSettled(e),escalated:c==="worse",pending:r,error:i,choose:d}}var uy=44,dy=.6,cy=/* @__PURE__ */Object.freeze({caseId:"",answer:null,resolutionText:null,status:null});function CheckinCard({message:e,checkin:t,onAnswer:r,petRef:petRef,onFindVet:n,vet:i,onLayout:o,onOpen:a}){let s=useEverfurTheme(),u=l(()=>py(s),[s]),d=sy(t??cy,t===null?null:r),c=d.answer!==null||d.pending!==null,p=t!==null&&r!==null&&d.answerable,f=t===null?null:Xg(t.openedAt,eb(e));/* @__PURE__ */
281
- return j(v,{style:u.card,accessibilityLabel:oy.eyebrow,onLayout:o,children:[
273
+ return A(BookGlyph,{size:py,color:e.color.linkInk,strokeWidth:1.5})}function FeedbackChip({label:e,on:t,onPress:r,styles:n,host:l}){/* @__PURE__ */
274
+ return A(C,{onPress:r,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{selected:t},style:[n.chip,l?.feedbackChip,t?n.chipOn:null],hitSlop:($s-ly)/2,children:/* @__PURE__ */A(Text,{tier:"control",style:[n.chipText,l?.feedbackChipText],children:e})})}function CardsFollowUps({prompts:e,onSelectPrompt:t,label:r,actions:n,options:i}){let{theme:o,styles:a}=vy(),s=Ed(),u=l(()=>s===null?null:Qg()?.ask.followUpStyles(s.paint)??null,[s]);if(e.length===0&&n.length===0)return null;let d=i?.styles,c=r??Ne.followUpsHeadingNative;/* @__PURE__ */
275
+ return j(v,{style:[a.followUps,u?.followUps,d?.followUps],accessibilityLabel:c,testID:"everfur-cards-follow-ups",children:[
276
+ /* @__PURE__ */A(Text,{tier:"compact",style:[a.label,u?.label,d?.followUpsLabel],accessibilityRole:"header",children:c}),n.map(e=>/* @__PURE__ */j(C,{onPress:()=>{Yr(e.onPress)},accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:hy,style:[a.row,a.rowAction,u?.row,d?.followUp,d?.followUpAction],children:[e.icon??null,
277
+ /* @__PURE__ */A(Text,{tier:"control",style:[a.rowText,a.rowTextAction,u?.rowText,d?.followUpText,d?.followUpActionText],children:e.label}),
278
+ /* @__PURE__ */A(Chevron,{options:i,color:s?.paint.accent??o.color.text.primary})]},`action:${e.key}`)),e.map(e=>/* @__PURE__ */j(C,{onPress:()=>t(e),accessibilityRole:"button",accessibilityLabel:e,hitSlop:hy,style:[a.row,u?.row,d?.followUp],children:[
279
+ /* @__PURE__ */A(Text,{tier:"control",style:[a.rowText,u?.rowText,d?.followUpText],children:e}),
280
+ /* @__PURE__ */A(Chevron,{options:i,color:s?.paint.accent??o.color.linkInk})]},e))]})}function CardsByline({label:e}){let{styles:t}=vy();/* @__PURE__ */
281
+ return A(v,{style:t.byline,children:/* @__PURE__ */A(Text,{tier:"compact",style:t.bylineText,children:e})})}function wy(e){let t=e.color,r=e.space,n={...face(e,"mono"),fontSize:Zb,textTransform:"uppercase",color:t.text.muted},l={borderWidth:1,borderColor:t.borderRingCream},i={borderWidth:1,borderColor:cs(t.text.primary,gy)??t.borderRingCream},o={shadowColor:t.text.primary,shadowOffset:{width:0,height:1},shadowOpacity:by,shadowRadius:2,elevation:1},a=textRole(e,"message"),chipInk=ea(e.slots.chip);return g.create({answer:{gap:r.md,alignSelf:"stretch"},byline:{flexDirection:"row",alignItems:"center",gap:10,minHeight:14},bylineText:{...n,letterSpacing:Zb*.06,flexShrink:1},body:{gap:10},paragraph:{...face(e,"regular"),fontSize:a.fontSize,lineHeight:Math.round(a.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:Xb,borderRadius:Jb,backgroundColor:t.surface,...i,...o,minHeight:$s,...Jo(e.slots.card)},tile:{width:ey,height:ey,borderRadius:ty,backgroundColor:cs(t.linkInk,yy)??t.surfaceSubtle,alignItems:"center",justifyContent:"center",overflow:"hidden"},tileImage:{width:ey,height:ey},cardWords:{flex:1,minWidth:0},cardTitle:{...face(e,"bold"),fontSize:ry,lineHeight:Math.round(ry*1.25),color:t.text.primary,...ea(e.slots.card)},cardMeta:{...n,letterSpacing:Zb*.04,marginTop:3},stat:{...face(e,"mono"),fontSize:ny,color:t.text.primary},statUnit:{...face(e,"mono"),fontSize:Zb+2,color:t.text.muted},pill:{minHeight:cy,paddingHorizontal:10,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,justifyContent:"center",flexShrink:1,maxWidth:my},pillText:{...face(e,"bold"),fontSize:dy,color:t.text.primary},feedback:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,alignItems:"center"},chip:{minHeight:ly,paddingHorizontal:12,borderRadius:e.radius.pill,...l,justifyContent:"center"},chipOn:{backgroundColor:t.surfaceSubtle},chipText:{...dh(e),fontSize:iy,color:t.text.primary,...chipInk},followUps:{gap:r.sm,alignSelf:"stretch",marginTop:r.xs},label:{...face(e,"bold"),fontSize:uy,lineHeight:Math.round(uy*1.5),color:t.text.muted,marginTop:2},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:fy,paddingTop:11,paddingBottom:11,paddingRight:12,paddingLeft:14,borderRadius:oy,backgroundColor:t.surface,...i},rowAction:{},rowText:{...dh(e),flex:1,fontSize:ay,lineHeight:Math.round(ay*1.3),color:t.linkInk},rowTextAction:{color:t.text.primary}})}var ky=/* @__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"})}),Cy=/* @__PURE__ */Object.freeze(bi.map(e=>/* @__PURE__ */Object.freeze({answer:e,label:ky.answers[e]})));function Sy(e,t){let[r,l]=o(null),[i,a]=o(null),[s,u]=o(null),d=n(r=>{t!==null&&(l(r),a(null),t(e.caseId,r).then(e=>{l(null),e.ok?u(r):a(e.error)}))},[t,e.caseId]),c=s??e.answer;return{answer:c,answerable:!isCheckinSettled(e),escalated:c==="worse",pending:r,error:i,choose:d}}var xy=44,Ry=.6,Ty=/* @__PURE__ */Object.freeze({caseId:"",answer:null,resolutionText:null,status:null});function CheckinCard({message:e,checkin:t,onAnswer:r,petRef:petRef,onFindVet:n,vet:i,onLayout:o,onOpen:a}){let s=useEverfurTheme(),u=l(()=>_y(s),[s]),d=Sy(t??Ty,t===null?null:r),c=d.answer!==null||d.pending!==null,p=t!==null&&r!==null&&d.answerable,f=t===null?null:hb(t.openedAt,gb(e));/* @__PURE__ */
282
+ return j(v,{style:u.card,accessibilityLabel:ky.eyebrow,onLayout:o,children:[
282
283
  /* @__PURE__ */j(v,{style:u.head,children:[
283
- /* @__PURE__ */A(Text,{tier:"compact",style:u.eyebrow,children:oy.eyebrow}),f!==null?/* @__PURE__ */A(Text,{tier:"compact",style:u.headDay,children:We(oy.day,{day:f})}):null]}),a?/* @__PURE__ */A(C,{onPress:a,accessibilityRole:"button",accessibilityLabel:e.text,style:u.open,children:/* @__PURE__ */A(Text,{style:[u.question,u.openText],children:e.text})}):/* @__PURE__ */A(Text,{style:u.question,accessibilityRole:"text",children:e.text}),p?/* @__PURE__ */A(v,{style:[u.row,d.pending?u.rowPending:null],children:ay.map(({answer:e,label:t})=>{let r=(d.pending??d.answer)===e;/* @__PURE__ */
284
- return A(C,{onPress:()=>d.choose(e),disabled:c,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{selected:r,disabled:c,busy:d.pending===e},style:[u.pill,r?u.pillSelected:null],children:/* @__PURE__ */A(Text,{tier:"control",style:[u.pillLabel,r?u.pillLabelSelected:null],children:t})},e)})}):null,d.answer!==null?/* @__PURE__ */A(Text,{style:u.logged,children:oy.logged}):null,d.escalated?/* @__PURE__ */A(CheckinFindVet,{petRef:petRef??null,onFindVet:n,vet:i,styles:u}):null,t?.resolutionText?/* @__PURE__ */A(Text,{style:u.resolution,children:t.resolutionText}):null,d.error?/* @__PURE__ */A(Text,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}function CheckinFindVet({petRef:petRef,onFindVet:e,vet:t,styles:r}){return useVetVisit(gg(petRef,t)).available&&petRef!==null?/* @__PURE__ */A(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:oy.findVet,...t?.returnTo!==void 0?{returnTo:t.returnTo}:{},...t?.usState!==void 0?{usState:t.usState}:{},...t?.prefer!==void 0?{prefer:t.prefer}:{},style:r.findVet,labelStyle:r.findVetLabel}):e===void 0?null:/* @__PURE__ */A(C,{onPress:e,accessibilityRole:"button",accessibilityLabel:oy.findVet,style:r.findVet,children:/* @__PURE__ */A(Text,{tier:"control",style:r.findVetLabel,children:oy.findVet})})}function py(e){let t=e.color,r=e.space,n=e.radius,l=e.type,i=Zo(e.slots.card),o=Jo(i);return g.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:g.hairlineWidth,borderColor:t.brandBorder,...Qo(i,g.hairlineWidth)},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...face(e,"regular"),color:t.text.secondary,fontSize:l.size.caption,letterSpacing:l.letterSpacing.eyebrow,textTransform:"uppercase",...o},headDay:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.caption,letterSpacing:l.letterSpacing.eyebrow,textTransform:"uppercase",...o},question:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.normal,...o},open:{minHeight:uy,justifyContent:"center"},openText:{textDecorationLine:"underline"},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:dy},pill:{flex:1,minHeight:uy,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.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:l.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...face(e,"regular"),color:t.text.secondary,fontSize:l.size.caption,...o},resolution:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.normal,...o},error:{...face(e,"regular"),color:t.danger,fontSize:l.size.caption},findVet:{alignSelf:"stretch",minHeight:uy,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.controlEdge,backgroundColor:t.surface},findVetLabel:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.body}})}var fy=244,hy=8,gy=13,by=14,yy=.3,my=-.24,vy=22,wy=10,ky=15;function CitationCards({citations:e,onOpenUrl:t}){let r=useEverfurTheme(),n=l(()=>Cy(r),[r]),i=l(()=>ub(e),[e]),[a,s]=o(false);if(i.length===0)return null;let u=i.length;/* @__PURE__ */
284
+ /* @__PURE__ */A(Text,{tier:"compact",style:u.eyebrow,children:ky.eyebrow}),f!==null?/* @__PURE__ */A(Text,{tier:"compact",style:u.headDay,children:Ue(ky.day,{day:f})}):null]}),a?/* @__PURE__ */A(C,{onPress:a,accessibilityRole:"button",accessibilityLabel:e.text,style:u.open,children:/* @__PURE__ */A(Text,{style:[u.question,u.openText],children:e.text})}):/* @__PURE__ */A(Text,{style:u.question,accessibilityRole:"text",children:e.text}),p?/* @__PURE__ */A(v,{style:[u.row,d.pending?u.rowPending:null],children:Cy.map(({answer:e,label:t})=>{let r=(d.pending??d.answer)===e;/* @__PURE__ */
285
+ return A(C,{onPress:()=>d.choose(e),disabled:c,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{selected:r,disabled:c,busy:d.pending===e},style:[u.pill,r?u.pillSelected:null],children:/* @__PURE__ */A(Text,{tier:"control",style:[u.pillLabel,r?u.pillLabelSelected:null],children:t})},e)})}):null,d.answer!==null?/* @__PURE__ */A(Text,{style:u.logged,children:ky.logged}):null,d.escalated?/* @__PURE__ */A(CheckinFindVet,{petRef:petRef??null,onFindVet:n,vet:i,styles:u}):null,t?.resolutionText?/* @__PURE__ */A(Text,{style:u.resolution,children:t.resolutionText}):null,d.error?/* @__PURE__ */A(Text,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}function CheckinFindVet({petRef:petRef,onFindVet:e,vet:t,styles:r}){return useVetVisit(_g(petRef,t)).available&&petRef!==null?/* @__PURE__ */A(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:ky.findVet,...t?.returnTo!==void 0?{returnTo:t.returnTo}:{},...t?.usState!==void 0?{usState:t.usState}:{},...t?.prefer!==void 0?{prefer:t.prefer}:{},style:r.findVet,labelStyle:r.findVetLabel}):e===void 0?null:/* @__PURE__ */A(C,{onPress:e,accessibilityRole:"button",accessibilityLabel:ky.findVet,style:r.findVet,children:/* @__PURE__ */A(Text,{tier:"control",style:r.findVetLabel,children:ky.findVet})})}function _y(e){let t=e.color,r=e.space,n=e.radius,l=e.type,i=Xo(e.slots.card),o=ea(i);return g.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:g.hairlineWidth,borderColor:t.brandBorder,...Jo(i,g.hairlineWidth)},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...face(e,"regular"),color:t.text.secondary,fontSize:l.size.caption,letterSpacing:l.letterSpacing.eyebrow,textTransform:"uppercase",...o},headDay:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.caption,letterSpacing:l.letterSpacing.eyebrow,textTransform:"uppercase",...o},question:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.normal,...o},open:{minHeight:xy,justifyContent:"center"},openText:{textDecorationLine:"underline"},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:Ry},pill:{flex:1,minHeight:xy,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.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:l.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...face(e,"regular"),color:t.text.secondary,fontSize:l.size.caption,...o},resolution:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.normal,...o},error:{...face(e,"regular"),color:t.danger,fontSize:l.size.caption},findVet:{alignSelf:"stretch",minHeight:xy,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.controlEdge,backgroundColor:t.surface},findVetLabel:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.body}})}var zy=244,Iy=8,Py=13,Fy=14,Ly=.3,Ey=-.24,Oy=22,Ay=10,jy=15;function CitationCards({citations:e,onOpenUrl:t}){let r=useEverfurTheme(),n=l(()=>Dy(r),[r]),i=l(()=>xb(e),[e]),[a,s]=o(false);if(i.length===0)return null;let u=i.length;/* @__PURE__ */
285
286
  return j(v,{style:n.block,children:[
286
- /* @__PURE__ */j(PressScale,{accessibilityRole:"button",accessibilityLabel:pb(u,a),accessibilityState:{expanded:a},containerStyle:n.toggleSlot,style:n.togglePill,onPress:()=>s(e=>!e),children:[
287
- /* @__PURE__ */A(BookGlyph,{size:gy,color:r.color.brandInk,strokeWidth:1.5}),
288
- /* @__PURE__ */A(Text,{tier:"compact",style:n.toggleLabel,children:cb(u)}),
289
- /* @__PURE__ */A(ChevronGlyph,{size:gy,color:r.color.brandInk,strokeWidth:1.5,direction:a?"up":"down"})]}),a?/* @__PURE__ */A(Deck,{cards:i,styles:n,open:t}):null]})}function Deck({cards:e,styles:t,open:r}){let n=Co(),l=Fo(n.citationsInMs,{risePx:n.citationsRisePx});/* @__PURE__ */
290
- return A(L.View,{style:l,children:/* @__PURE__ */A(T,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(e=>/* @__PURE__ */A(Card,{card:e,styles:t,open:r},e.key))})})}function Card({card:e,styles:t,open:r}){let n=useEverfurTheme(),l=e.url!==null&&r!==void 0,i=fb(l?e:{...e,url:null}),o=/* @__PURE__ */j(D,{children:[
287
+ /* @__PURE__ */j(PressScale,{accessibilityRole:"button",accessibilityLabel:_b(u,a),accessibilityState:{expanded:a},containerStyle:n.toggleSlot,style:n.togglePill,onPress:()=>s(e=>!e),children:[
288
+ /* @__PURE__ */A(BookGlyph,{size:Py,color:r.color.brandInk,strokeWidth:1.5}),
289
+ /* @__PURE__ */A(Text,{tier:"compact",style:n.toggleLabel,children:Tb(u)}),
290
+ /* @__PURE__ */A(ChevronGlyph,{size:Py,color:r.color.brandInk,strokeWidth:1.5,direction:a?"up":"down"})]}),a?/* @__PURE__ */A(Deck,{cards:i,styles:n,open:t}):null]})}function Deck({cards:e,styles:t,open:r}){let n=xo(),l=Eo(n.citationsInMs,{risePx:n.citationsRisePx});/* @__PURE__ */
291
+ return A(L.View,{style:l,children:/* @__PURE__ */A(T,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(e=>/* @__PURE__ */A(Card,{card:e,styles:t,open:r},e.key))})})}function Card({card:e,styles:t,open:r}){let n=useEverfurTheme(),l=e.url!==null&&r!==void 0,i=zb(l?e:{...e,url:null}),o=/* @__PURE__ */j(D,{children:[
291
292
  /* @__PURE__ */j(v,{style:t.cardHeader,children:[
292
293
  /* @__PURE__ */A(v,{style:[t.tierDot,{backgroundColor:e.tierColor}]}),
293
- /* @__PURE__ */A(Text,{style:[t.cardTitle,l?t.cardTitleLink:null],numberOfLines:2,children:e.title}),l?/* @__PURE__ */A(ArrowUpRightGlyph,{size:by,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?/* @__PURE__ */A(Text,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?/* @__PURE__ */A(Text,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let n=e.url;/* @__PURE__ */
294
+ /* @__PURE__ */A(Text,{style:[t.cardTitle,l?t.cardTitleLink:null],numberOfLines:2,children:e.title}),l?/* @__PURE__ */A(ArrowUpRightGlyph,{size:Fy,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?/* @__PURE__ */A(Text,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?/* @__PURE__ */A(Text,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let n=e.url;/* @__PURE__ */
294
295
  return A(PressScale,{accessibilityRole:"link",accessibilityLabel:i,style:t.card,onPress:()=>r(n),children:o})}/* @__PURE__ */
295
- return A(v,{accessible:true,accessibilityRole:"text",accessibilityLabel:i,style:t.card,children:o})}function Cy(e){let t=e.color,r=e.space,n=e.radius,l=e.type.size,i=Jo(e.slots.card);return g.create({block:{gap:r.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:n.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:r.xs+2,paddingHorizontal:r.md,paddingVertical:r.xs+2,borderRadius:n.pill,backgroundColor:t.brandSoft},toggleLabel:{...face(e,"monoBold"),fontSize:l.micro,lineHeight:l.micro,letterSpacing:yy,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:fy,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2,...Qo(e.slots.card,1)},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:hy,height:hy,borderRadius:n.pill},cardTitle:{...headingFace(e,"bold"),flex:1,fontSize:l.bodyTight,lineHeight:vy,color:t.text.primary,letterSpacing:my,...i},cardTitleLink:{color:t.linkInk},cardMeta:{...face(e,"monoMedium"),fontSize:l.nano,lineHeight:wy,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase",...i},cardExcerpt:{...face(e,"regular"),fontSize:l.tiny,lineHeight:ky,color:t.text.muted,...i}})}var Sy=15,xy=44,Ry=16,Ty=/* @__PURE__ */Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function MessageFooter({message:e,onCopy:t,sentiment:r=null,onSentiment:n,note:s=null}){let u=useEverfurTheme(),d=l(()=>_y(u),[u]),c=Co(),p=e.role==="user",f=l(()=>tb(e.createdAt),[e.createdAt]),h=t!==void 0&&e.role!=="vet"&&e.text.length>0,g=e.role==="assistant"&&n!==void 0&&e.responseId!==void 0,[b,y]=o(false),m=i(null);a(()=>()=>{m.current&&clearTimeout(m.current)},[]);let w=()=>{t!==void 0&&(Qr(t,e.text),y(true),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{y(false),m.current=null},c.copiedMs))};return f===null&&!h&&!g?null:/* @__PURE__ */j(v,{style:d.wrap,children:[
296
- /* @__PURE__ */j(v,{style:[d.row,p?d.rowUser:d.rowAssistant],children:[f!==null?/* @__PURE__ */A(Text,{tier:"compact",style:d.timestamp,children:f}):null,h?/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:b?He.copied:p?He.copyUserMessage:He.copyAssistantMessage,onPress:w,style:d.iconHit,children:b?/* @__PURE__ */A(CheckGlyph,{size:Sy,color:u.color.success,strokeWidth:2}):/* @__PURE__ */A(CopyGlyph,{size:Sy,color:u.color.text.timestamp,strokeWidth:1.5})}):null,g?Bp.map(({sentiment:e,label:t})=>/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{selected:r===e},onPress:()=>n?.(e),style:d.iconHit,children:/* @__PURE__ */A(ThumbGlyph,{size:Sy,color:r===e?u.color.sentiment[e]:u.color.text.timestamp,active:r===e,rotate:Ty[e],strokeWidth:1.5})},e)):null]}),s==="thanks"?/* @__PURE__ */A(Text,{style:d.thanks,accessibilityLiveRegion:"polite",children:He.feedbackThanks}):null,s==="failed"?/* @__PURE__ */j(D,{children:[
297
- /* @__PURE__ */A(Text,{style:d.failed,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:He.feedbackFailed}),
298
- /* @__PURE__ */A(AnnounceLine,{line:He.feedbackFailed})]}):null]})}function _y(e){let t=e.type;return g.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:Ry,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:xy,height:xy,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 zy=16,Iy=10,Py=12,Fy=10,Ly=2,Ey=.06,Oy=34,Ay=9,jy=10.5,Dy=.06,My=15,By=19.5,Hy=14,Wy=19.6;function OpeningCard({card:e,onLayout:t}){let r=useEverfurTheme(),n=l(()=>Ny(r),[r]),i=e.styles;/* @__PURE__ */
296
+ return A(v,{accessible:true,accessibilityRole:"text",accessibilityLabel:i,style:t.card,children:o})}function Dy(e){let t=e.color,r=e.space,n=e.radius,l=e.type.size,i=ea(e.slots.card);return g.create({block:{gap:r.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:n.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:r.xs+2,paddingHorizontal:r.md,paddingVertical:r.xs+2,borderRadius:n.pill,backgroundColor:t.brandSoft},toggleLabel:{...face(e,"monoBold"),fontSize:l.micro,lineHeight:l.micro,letterSpacing:Ly,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:zy,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2,...Jo(e.slots.card,1)},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:Iy,height:Iy,borderRadius:n.pill},cardTitle:{...headingFace(e,"bold"),flex:1,fontSize:l.bodyTight,lineHeight:Oy,color:t.text.primary,letterSpacing:Ey,...i},cardTitleLink:{color:t.linkInk},cardMeta:{...face(e,"monoMedium"),fontSize:l.nano,lineHeight:Ay,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase",...i},cardExcerpt:{...face(e,"regular"),fontSize:l.tiny,lineHeight:jy,color:t.text.muted,...i}})}var My=15,By=44,Hy=16,Wy=/* @__PURE__ */Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function MessageFooter({message:e,onCopy:t,sentiment:r=null,onSentiment:n,note:s=null}){let u=useEverfurTheme(),d=l(()=>Ny(u),[u]),c=xo(),p=e.role==="user",f=Ed(),h=l(()=>f?null:bb(e.createdAt),[f,e.createdAt]),g=t!==void 0&&e.role!=="vet"&&e.text.length>0,b=e.role==="assistant"&&n!==void 0&&e.responseId!==void 0,[y,m]=o(false),w=i(null);a(()=>()=>{w.current&&clearTimeout(w.current)},[]);let k=()=>{t!==void 0&&(Jr(t,e.text),m(true),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{m(false),w.current=null},c.copiedMs))};return h===null&&!g&&!b?null:/* @__PURE__ */j(v,{style:d.wrap,children:[
297
+ /* @__PURE__ */j(v,{style:[d.row,p?d.rowUser:d.rowAssistant],children:[h!==null?/* @__PURE__ */A(Text,{tier:"compact",style:d.timestamp,children:h}):null,g?/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:y?Ne.copied:p?Ne.copyUserMessage:Ne.copyAssistantMessage,onPress:k,style:d.iconHit,children:y?/* @__PURE__ */A(CheckGlyph,{size:My,color:u.color.success,strokeWidth:2}):/* @__PURE__ */A(CopyGlyph,{size:My,color:u.color.text.timestamp,strokeWidth:1.5})}):null,b?Gp.map(({sentiment:e,label:t})=>/* @__PURE__ */A(C,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{selected:r===e},onPress:()=>n?.(e),style:d.iconHit,children:/* @__PURE__ */A(ThumbGlyph,{size:My,color:r===e?u.color.sentiment[e]:u.color.text.timestamp,active:r===e,rotate:Wy[e],strokeWidth:1.5})},e)):null]}),s==="thanks"?/* @__PURE__ */A(Text,{style:d.thanks,accessibilityLiveRegion:"polite",children:Ne.feedbackThanks}):null,s==="failed"?/* @__PURE__ */j(D,{children:[
298
+ /* @__PURE__ */A(Text,{style:d.failed,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:Ne.feedbackFailed}),
299
+ /* @__PURE__ */A(AnnounceLine,{line:Ne.feedbackFailed})]}):null]})}function Ny(e){let t=e.type;return g.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:Hy,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:By,height:By,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 Uy=16,$y=10,Vy=12,qy=10,Gy=2,Ky=.06,Yy=34,Qy=9,Zy=10.5,Jy=.06,Xy=15,em=19.5,tm=14,rm=19.6;function OpeningCard({card:e,onLayout:t}){let r=useEverfurTheme(),n=l(()=>nm(r),[r]),i=e.styles;/* @__PURE__ */
299
300
  return j(v,{testID:"everfur-opening-card",onLayout:t,accessible:true,accessibilityLabel:[e.kicker,e.title,e.body].filter(e=>e!==void 0).join(", "),style:[n.card,i?.card],children:[e.icon!==void 0?/* @__PURE__ */A(v,{style:[n.icon,i?.icon],children:e.icon}):null,
300
301
  /* @__PURE__ */j(v,{style:n.words,children:[
301
302
  /* @__PURE__ */A(Text,{tier:"compact",style:[n.kicker,i?.kicker],children:e.kicker}),
302
- /* @__PURE__ */A(Text,{tier:"control",style:[n.title,i?.title],children:e.title}),e.body!==void 0?/* @__PURE__ */A(Text,{style:[n.body,i?.body],children:e.body}):null]})]})}function Ny(e){let t=e.color;return g.create({card:{flexDirection:"row",alignItems:"flex-start",gap:Fy,paddingVertical:Iy,paddingHorizontal:Py,alignSelf:"stretch",borderRadius:zy,backgroundColor:t.surface,borderWidth:1,borderColor:us(t.text.primary,Ey)??t.borderRingCream},icon:{flexShrink:0,width:Oy,height:Oy,borderRadius:Ay,backgroundColor:t.highlight,alignItems:"center",justifyContent:"center",overflow:"hidden"},words:{flex:1,minWidth:0,gap:Ly},kicker:{...face(e,"mono"),fontSize:jy,letterSpacing:jy*Dy,textTransform:"uppercase",color:t.text.muted},title:{...face(e,"bold"),fontSize:My,lineHeight:By,color:t.text.primary},body:{...face(e,"regular"),fontSize:Hy,lineHeight:Wy,color:t.text.secondary}})}var Uy="#10462E",$y="Book a video visit",Vy="#000000",qy="#83E0B4",Gy=/* @__PURE__ */Object.freeze([
303
+ /* @__PURE__ */A(Text,{tier:"control",style:[n.title,i?.title],children:e.title}),e.body!==void 0?/* @__PURE__ */A(Text,{style:[n.body,i?.body],children:e.body}):null]})]})}function nm(e){let t=e.color;return g.create({card:{flexDirection:"row",alignItems:"flex-start",gap:qy,paddingVertical:$y,paddingHorizontal:Vy,alignSelf:"stretch",borderRadius:Uy,backgroundColor:t.surface,borderWidth:1,borderColor:cs(t.text.primary,Ky)??t.borderRingCream},icon:{flexShrink:0,width:Yy,height:Yy,borderRadius:Qy,backgroundColor:t.highlight,alignItems:"center",justifyContent:"center",overflow:"hidden"},words:{flex:1,minWidth:0,gap:Gy},kicker:{...face(e,"mono"),fontSize:Zy,letterSpacing:Zy*Jy,textTransform:"uppercase",color:t.text.muted},title:{...face(e,"bold"),fontSize:Xy,lineHeight:em,color:t.text.primary},body:{...face(e,"regular"),fontSize:tm,lineHeight:rm,color:t.text.secondary}})}var lm="#10462E",im="Book a video visit",om="#000000",am="#83E0B4",sm=/* @__PURE__ */Object.freeze([
303
304
  /* @__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}),
304
- /* @__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:qy,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),
305
- /* @__PURE__ */Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:Uy,brandEdge:true,borderWidth:1}),
306
- /* @__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 Ky(e,t){return e?null:{fill:t.fill,ink:t.ink}}var Yy=8;function Qy(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&t.length<=64&&!/[;{}<>]/u.test(t)?t:null}function Zy(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(t.length>=Yy)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=Qy(r.tint);t.push(/* @__PURE__ */Object.freeze({id:`starter-${t.length}`,label:e,prompt:n,tint:l,ink:l===null?null:Qy(r.ink)}))}return t.length>0?/* @__PURE__ */Object.freeze(t):null}var Jy=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function Xy(e){return e==null?e:e.replace(Jy,"").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 tm(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return em.has(t)}function rm(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}function nm(e,t){let r=e?.trim();if(r===void 0||r==="")return lm(t);let n=t?.name?.trim()||He.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()||He.emptyTitlePetFallback;return We(He.emptyTitle,{petName:t})}function im(e){let t=e.toLowerCase();return t===rm("dog").toLowerCase()||t===rm("cat").toLowerCase()}function om(e){let t=Xy(e);if(tm(t))return null;let r=String(t).replace(/\s+/gu," ").trim();return im(r)?null:r}function am(e,t=Uy,r){let n=canonicalPetSpecies(e?.species),l=e?.name?.trim()||null,i=om(e?.breed),o=Zc(e?.ageYears),a=o===null?null:String(o),s=r?.vetPrepLabel?.trim()||null;/* @__PURE__ */
307
- return Object.freeze(Gy.flatMap(e=>{let r=e.intent==="vet_report"&&s!==null?s:e.label,o=r.includes("{breed}"),u=r.includes("{ageYears}"),d=e.fallbackLabel!==void 0&&(o&&!i||u&&!a)&&e.fallbackLabel?e.fallbackLabel:r;if(d.includes("{breed}")&&i===null||d.includes("{ageYears}")&&a===null||n===null&&(d.includes("{species}")||d.includes("{petName}")&&l===null))return[];let c=We(d,{petName:l??(n==="cat"?"my cat":"my dog"),breed:i??"",species:n??"",ageYears:a??""}),p=!l&&d.startsWith("{petName}")?c.charAt(0).toUpperCase()+c.slice(1):c;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 sm=44,um=0,dm={top:3,bottom:3},cm=1,pm=.28,fm=2,hm=2,gm=1.3,bm=-.015,ym=/* @__PURE__ */Object.freeze([
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:am,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:lm,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 um(e,t){return e?null:{fill:t.fill,ink:t.ink}}var dm=8;function cm(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&t.length<=64&&!/[;{}<>]/u.test(t)?t:null}function pm(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(t.length>=dm)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=cm(r.tint);t.push(/* @__PURE__ */Object.freeze({id:`starter-${t.length}`,label:e,prompt:n,tint:l,ink:l===null?null:cm(r.ink)}))}return t.length>0?/* @__PURE__ */Object.freeze(t):null}var fm=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function hm(e){return e==null?e:e.replace(fm,"").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 bm(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 mm(e,t){let r=e?.trim();if(r===void 0||r==="")return vm(t);let n=t?.name?.trim()||Ne.emptyTitlePetFallback,l=n.charAt(0).toUpperCase()+n.slice(1);return r.replace(/\{(pet|petName)\}/g,(e,t,r)=>r===0?l:n)}function vm(e){let t=e?.name?.trim()||Ne.emptyTitlePetFallback;return Ue(Ne.emptyTitle,{petName:t})}function wm(e){let t=e.toLowerCase();return t===ym("dog").toLowerCase()||t===ym("cat").toLowerCase()}function km(e){let t=hm(e);if(bm(t))return null;let r=String(t).replace(/\s+/gu," ").trim();return wm(r)?null:r}function Cm(e,t=lm,r){let n=canonicalPetSpecies(e?.species),l=e?.name?.trim()||null,i=km(e?.breed),o=ip(e?.ageYears),a=o===null?null:String(o),s=r?.vetPrepLabel?.trim()||null;/* @__PURE__ */
308
+ return Object.freeze(sm.flatMap(e=>{let r=e.intent==="vet_report"&&s!==null?s:e.label,o=r.includes("{breed}"),u=r.includes("{ageYears}"),d=e.fallbackLabel!==void 0&&(o&&!i||u&&!a)&&e.fallbackLabel?e.fallbackLabel:r;if(d.includes("{breed}")&&i===null||d.includes("{ageYears}")&&a===null||n===null&&(d.includes("{species}")||d.includes("{petName}")&&l===null))return[];let c=Ue(d,{petName:l??(n==="cat"?"my cat":"my dog"),breed:i??"",species:n??"",ageYears:a??""}),p=!l&&d.startsWith("{petName}")?c.charAt(0).toUpperCase()+c.slice(1):c;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 Sm=44,xm=0,Rm={top:3,bottom:3},Tm=1,_m=.28,zm=2,Im=2,Pm=1.3,Fm=-.015,Lm=/* @__PURE__ */Object.freeze([
308
309
  /* @__PURE__ */Object.freeze({tint:"#FFE7A1",ink:"#262523"}),
309
310
  /* @__PURE__ */Object.freeze({tint:"#C8F4F8",ink:"#262523"}),
310
311
  /* @__PURE__ */Object.freeze({tint:"#DDEFC4",ink:"#262523"}),
311
- /* @__PURE__ */Object.freeze({tint:"#FFD8D6",ink:"#262523"})]);function QuickPrompts({pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:i,emptyState:o,centered:a=false}){let s=useEverfurTheme(),u=l(()=>mm(s),[s]),d=l(()=>Zy(i),[i]),c=l(()=>d!==null?d.map(e=>({prompt:{id:e.id,intent:"send",label:e.label,background:e.tint??s.color.highlight,borderColor:"transparent",borderWidth:1},send:e.prompt,paint:e.tint===null?null:{fill:e.tint,ink:e.ink??s.color.text.primary}})):am(e,s.color.brandInk,{vetPrepLabel:$y}).map(e=>({prompt:e,send:e.label,paint:null})),[d,e,s.color.brandInk,s.color.highlight,s.color.text.primary]),p=o?.chipTints!==void 0,f=l(()=>(o?.chipTints??(s.brightness==="light"?ym:[])).filter(e=>typeof e.tint=="string"&&e.tint.trim()!==""),[o?.chipTints,s.brightness]),h=l(()=>f.length===0?c:c.map((e,t)=>{if(e.paint!==null)return e;let r=f[t%f.length];return{...e,paint:{fill:r.tint,ink:r.ink??s.color.text.primary},...p?{}:{cycleDefault:true}}}),[c,f,p,s.color.text.primary]),g=l(()=>Ky(Kc(s),{fill:s.color.highlight,ink:s.color.onHighlight}),[s]),b=l(()=>({fill:s.color.highlight,ink:s.color.onHighlight}),[s.color.highlight,s.color.onHighlight]),y=nm(o?.title,e),m=nf(),w=lf(),k=m!==null&&w!==null?/* @__PURE__ */A(w.Title,{text:y,style:[u.title,m.text(".serif",".ask-empty h2"),u.centerText],measureCh:w.titleCh}):/* @__PURE__ */A(Text,{tier:"heading",style:a?[u.title,u.centerText]:u.title,accessibilityRole:"header",children:y});/* @__PURE__ */
312
- return j(v,{style:m!==null?u.homeBlock:u.block,children:[k,
313
- /* @__PURE__ */A(v,{style:m!==null?[u.list,u.listCentered,m.view(".ask-chips",".ask-empty .ask-chips")]:a?[u.list,u.listCentered]:u.list,accessibilityLabel:He.suggestions,children:h.map(({prompt:l,send:i,paint:o,cycleDefault:s},c)=>/* @__PURE__ */A(Chip,{prompt:l,send:i,themed:o??(d!==null?b:g),index:c,petRef:petRef,onSend:t,onVetPrep:r,vet:n,pet:e,styles:u,tinted:o!==null&&s!==true,soft:o!==null,centered:a},l.id))})]})}function Chip({prompt:e,send:t,themed:r,index:n,pet:l,petRef:petRef,onSend:i,onVetPrep:o,vet:a,styles:s,tinted:u,soft:d,centered:c}){let p=Co(),f=Fo(p.followUpInMs,{delayMs:wo(p,n),risePx:p.promptRisePx}),h=nf(),g=h!==null?[s.chipHome,h.view(".chip")]:c&&d?s.chipNoEdge:s.chipEdge,b={backgroundColor:r?.fill??e.background},y=s.chipSlot===null?b:u?{...s.chipSlot,...b}:{...b,...s.chipSlot},m=h!==null?[s.chipLabel,h.text(".chip")]:c?[s.chipLabel,s.centerText]:[s.chipLabel],v=h!==null?dm:um,w=r===null?s.chipSlotLabel===null?m:[...m,s.chipSlotLabel]:u?[...m,...s.chipSlotLabel===null?[]:[s.chipSlotLabel],{color:r.ink}]:[...m,{color:r.ink},...s.chipSlotLabel===null?[]:[s.chipSlotLabel]];return e.intent==="vet_report"?o!==void 0?/* @__PURE__ */A(L.View,{style:f,children:/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:v,style:[s.chip,g,y],onPress:()=>{Gr(o,l)},children:/* @__PURE__ */A(Text,{tier:"compact",style:w,children:e.label})})}):petRef===null?null:/* @__PURE__ */A(L.View,{style:f,children:/* @__PURE__ */A(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:e.label,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:[s.chip,g,y],labelStyle:w})}):/* @__PURE__ */A(L.View,{style:f,children:/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:v,style:[s.chip,g,y],onPress:()=>i(t),children:/* @__PURE__ */A(Text,{tier:"compact",style:w,children:e.label})})})}function mm(e){let t=Zo(e.slots.chip),r=Jo(t);return{chipSlot:t===void 0?null:Qo(t,cm),chipSlotLabel:r.color===void 0?null:r,...vm(e)}}function vm(e){let t=e.color,r=e.space,n=e.type;return g.create({block:{gap:r.lg,alignItems:"stretch",width:"100%"},homeBlock:{alignItems:"stretch",width:"100%"},chipHome:{borderWidth:0,minHeight:0},title:{...headingFace(e,"medium"),fontSize:n.size.heading,lineHeight:Math.round(n.size.heading*n.lineHeight.snug),color:t.brandInk,letterSpacing:n.size.heading*bm,textAlign:"left"},list:{width:"100%",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",gap:r.sm+fm},listCentered:{flexDirection:"column",flexWrap:"nowrap",alignItems:"stretch"},centerText:{textAlign:"center"},chipNoEdge:{borderWidth:cm,borderColor:"transparent"},chip:{borderRadius:e.radius.pill,paddingHorizontal:r.lg+hm,paddingVertical:r.sm,minHeight:sm,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipEdge:{borderWidth:cm,borderColor:us(t.brandInk,pm)??t.borderRingCream},chipLabel:{...face(e,"bold"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*gm),color:Vy,textAlign:"left"}})}var wm=1e3,km=150,Cm=.25,Sm=.5,xm=3;function TypingIndicator({petName:e=null,inline:t=false}){let{theme:r,styles:n}=Eu(),l=r.motion.reducedMotion,o=Ue(He.reading,e),s=i(Array.from({length:xm},()=>new L.Value(0))).current;return a(()=>{if(l)return;let e=s.map((e,t)=>L.loop(L.sequence([L.delay(t*km),L.timing(e,{toValue:1,duration:wm*.4,useNativeDriver:true}),L.timing(e,{toValue:0,duration:wm*.6,useNativeDriver:true}),L.delay((xm-t-1)*km)])));for(let t of e)t.start();return()=>{for(let t of e)t.stop()}},[l,s]),/* @__PURE__ */A(v,{style:t?n.readingInline:n.readingBox,accessible:true,accessibilityRole:"text",accessibilityLabel:o,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:s.map((e,r)=>/* @__PURE__ */A(L.View,{accessibilityElementsHidden:true,importantForAccessibility:"no",style:[t?n.readingDotInline:n.readingDot,l?{opacity:Sm}:{opacity:e.interpolate({inputRange:[0,1],outputRange:[Cm,1]}),transform:[{translateY:e.interpolate({inputRange:[0,1],outputRange:[0,-3]})}]}]},r))})}function Rm(e,t,r){let n=e-r,l=t!=null?Math.min(n,t):n;return Math.max(0,l)}function Tm(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 _m(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 zm=16;function Im(e,t,r=null){let l=i(null),o=i(true),s=i(t),u=i(0),d=i(0),c=i(0),p=i(/* @__PURE__ */new Map),f=i(null),h=i(false),g=e[0]?.id??null,b=i(g),y=i(null);a(()=>{let t=b.current;if(b.current=g,t===null||t===g||(y.current=null,o.current||!e.some(e=>e.id===t)))return;let r=p.current.get(t);r!==void 0&&(y.current={id:t,top:r,offset:u.current})},[g,e]);let m=Tm(e),v=m===null?null:e[m.assistantIndex]?.id??null,w=m===null||m.userIndex===null?null:e[m.userIndex]?.id??null,k=n(()=>{let e=l.current;if(e===null||!o.current||d.current===0)return;let t=null;if(v!==null){let e=p.current.get(v);if(e===void 0)return;let r=w===null?null:p.current.get(w)??null;t=Rm(e,r,96)}let r=_m(t,u.current,c.current-d.current);if(r!==null&&(u.current=r,e.scrollTo({y:r,animated:false})),!h.current||f.current===null)return;let n=_m(f.current+zm-d.current,u.current,c.current-d.current);n!==null&&(u.current=n,e.scrollTo({y:n,animated:false}))},[v,w]);a(()=>{h.current=r!==null,r===null&&(f.current=null),k()},[r,k]),a(()=>{t&&!s.current&&(o.current=true,h.current=false),s.current=t,k()},[e,t,k]);let C=n(e=>{d.current=e.nativeEvent.layout.height,k()},[k]),S=n((e,t)=>{c.current=t,d.current>0&&(u.current=Math.min(u.current,Math.max(0,t-d.current))),k()},[k]),x=n(e=>{u.current=e.nativeEvent.contentOffset.y},[]),R=n(()=>{o.current=false,h.current=false},[]),T=n(e=>{let{contentOffset:t,contentSize:r,layoutMeasurement:n}=e.nativeEvent;u.current=t.y,o.current=r.height-t.y-n.height<=24},[]),_=n(e=>t=>{let r=t.nativeEvent.layout.y;p.current.set(e,r);let n=y.current;if(n!==null&&n.id===e&&r!==n.top){y.current=null;let e=Math.max(0,n.offset+r-n.top);u.current=e,l.current?.scrollTo({y:e,animated:false})}(e===v||e===w)&&k()},[v,w,k]),z=n(e=>{let{y:t,height:r}=e.nativeEvent.layout;f.current=t+r,k()},[k]);return{ref:l,onLayout:C,onContentSizeChange:S,onScroll:x,onScrollBeginDrag:R,onScrollEnd:T,rowLayout:_,asideLayout:z}}function Pm(e,t,r){switch(e){case"loading":return r.renderPending?/* @__PURE__ */A(HostRender,{render:r.renderPending,fallback:/* @__PURE__ */A(LoadingState,{})}):/* @__PURE__ */A(LoadingState,{});case"empty":/* @__PURE__ */
312
+ /* @__PURE__ */Object.freeze({tint:"#FFD8D6",ink:"#262523"})]);function QuickPrompts({pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:i,emptyState:o,centered:a=false}){let s=useEverfurTheme(),u=l(()=>Em(s),[s]),d=l(()=>pm(i),[i]),c=l(()=>d!==null?d.map(e=>({prompt:{id:e.id,intent:"send",label:e.label,background:e.tint??s.color.highlight,borderColor:"transparent",borderWidth:1},send:e.prompt,paint:e.tint===null?null:{fill:e.tint,ink:e.ink??s.color.text.primary}})):Cm(e,s.color.brandInk,{vetPrepLabel:im}).map(e=>({prompt:e,send:e.label,paint:null})),[d,e,s.color.brandInk,s.color.highlight,s.color.text.primary]),p=Ed(),f=o?.chipTints!==void 0,h=l(()=>p===null?null:p.paint.pastels.map(e=>({tint:e,ink:p.paint.ink})),[p]),g=l(()=>(o?.chipTints??h??(s.brightness==="light"?Lm:[])).filter(e=>typeof e.tint=="string"&&e.tint.trim()!==""),[o?.chipTints,h,s.brightness]),b=l(()=>g.length===0?c:c.map((e,t)=>{if(e.paint!==null)return e;let r=g[t%g.length];return{...e,paint:{fill:r.tint,ink:r.ink??s.color.text.primary},...f||h!==null?{}:{cycleDefault:true}}}),[c,g,f,h,s.color.text.primary]),y=l(()=>um(rp(s),{fill:s.color.highlight,ink:s.color.onHighlight}),[s]),m=l(()=>({fill:s.color.highlight,ink:s.color.onHighlight}),[s.color.highlight,s.color.onHighlight]),w=mm(o?.title,e),k=pf(),C=p!==null?null:k,S=ff(),x=p!==null?/* @__PURE__ */A(Text,{tier:"heading",style:[u.title,u.tabsTitle,{color:p.paint.ink}],accessibilityRole:"header",children:w}):C!==null&&S!==null?/* @__PURE__ */A(S.Title,{text:w,style:[u.title,C.text(".serif",".ask-empty h2"),u.centerText],measureCh:S.titleCh}):/* @__PURE__ */A(Text,{tier:"heading",style:a?[u.title,u.centerText]:u.title,accessibilityRole:"header",children:w});/* @__PURE__ */
313
+ return j(v,{style:C!==null?u.homeBlock:u.block,children:[x,
314
+ /* @__PURE__ */A(v,{style:p!==null?[u.list,u.tabsList]:C!==null?[u.list,u.listCentered,C.view(".ask-chips",".ask-empty .ask-chips")]:a?[u.list,u.listCentered]:u.list,accessibilityLabel:Ne.suggestions,children:b.map(({prompt:l,send:i,paint:o,cycleDefault:s},c)=>/* @__PURE__ */A(Chip,{prompt:l,send:i,themed:o??(d!==null?m:y),index:c,petRef:petRef,onSend:t,onVetPrep:r,vet:n,pet:e,styles:u,tinted:o!==null&&s!==true,soft:o!==null,centered:a,tabs:p!==null},l.id))})]})}function Chip({prompt:e,send:t,themed:r,index:n,pet:l,petRef:petRef,onSend:i,onVetPrep:o,vet:a,styles:s,tinted:u,soft:d,centered:c,tabs:p}){let f=xo(),h=Eo(f.followUpInMs,{delayMs:Co(f,n),risePx:f.promptRisePx}),g=pf(),b=p?null:g,y=p?[s.chipNoEdge,s.tabsChip]:b!==null?[s.chipHome,b.view(".chip")]:c&&d?s.chipNoEdge:s.chipEdge,m={backgroundColor:r?.fill??e.background},v=s.chipSlot===null?m:u?{...s.chipSlot,...m}:{...m,...s.chipSlot},w=p?[s.chipLabel,s.tabsChipLabel]:b!==null?[s.chipLabel,b.text(".chip")]:c?[s.chipLabel,s.centerText]:[s.chipLabel],k=b!==null?Rm:xm,C=r===null?s.chipSlotLabel===null?w:[...w,s.chipSlotLabel]:u?[...w,...s.chipSlotLabel===null?[]:[s.chipSlotLabel],{color:r.ink}]:[...w,{color:r.ink},...s.chipSlotLabel===null?[]:[s.chipSlotLabel]];return e.intent==="vet_report"?o!==void 0?/* @__PURE__ */A(L.View,{style:h,children:/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:k,style:[s.chip,y,v],onPress:()=>{Yr(o,l)},children:/* @__PURE__ */A(Text,{tier:"compact",style:C,children:e.label})})}):petRef===null?null:/* @__PURE__ */A(L.View,{style:h,children:/* @__PURE__ */A(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:e.label,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:[s.chip,y,v],labelStyle:C})}):/* @__PURE__ */A(L.View,{style:h,children:/* @__PURE__ */A(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:k,style:[s.chip,y,v],onPress:()=>i(t),children:/* @__PURE__ */A(Text,{tier:"compact",style:C,children:e.label})})})}function Em(e){let t=Xo(e.slots.chip),r=ea(t);return{chipSlot:t===void 0?null:Jo(t,Tm),chipSlotLabel:r.color===void 0?null:r,...Om(e)}}function Om(e){let t=e.color,r=e.space,n=e.type;return g.create({block:{gap:r.lg,alignItems:"stretch",width:"100%"},homeBlock:{alignItems:"stretch",width:"100%"},chipHome:{borderWidth:0,minHeight:0},title:{...headingFace(e,"medium"),fontSize:n.size.heading,lineHeight:Math.round(n.size.heading*n.lineHeight.snug),color:t.brandInk,letterSpacing:n.size.heading*Fm,textAlign:"left"},list:{width:"100%",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",gap:r.sm+zm},listCentered:{flexDirection:"column",flexWrap:"nowrap",alignItems:"stretch"},centerText:{textAlign:"center"},chipNoEdge:{borderWidth:Tm,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+Im,paddingVertical:r.sm,minHeight:Sm,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipEdge:{borderWidth:Tm,borderColor:cs(t.brandInk,_m)??t.borderRingCream},chipLabel:{...face(e,"bold"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*Pm),color:om,textAlign:"left"}})}var Am=1e3,jm=150,Dm=.25,Mm=.5,Bm=3;function TypingIndicator({petName:e=null,inline:t=false}){let{theme:r,styles:n}=Au(),l=r.motion.reducedMotion,o=Ve(Ne.reading,e),s=i(Array.from({length:Bm},()=>new L.Value(0))).current;return a(()=>{if(l)return;let e=s.map((e,t)=>L.loop(L.sequence([L.delay(t*jm),L.timing(e,{toValue:1,duration:Am*.4,useNativeDriver:true}),L.timing(e,{toValue:0,duration:Am*.6,useNativeDriver:true}),L.delay((Bm-t-1)*jm)])));for(let t of e)t.start();return()=>{for(let t of e)t.stop()}},[l,s]),/* @__PURE__ */A(v,{style:t?n.readingInline:n.readingBox,accessible:true,accessibilityRole:"text",accessibilityLabel:o,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:s.map((e,r)=>/* @__PURE__ */A(L.View,{accessibilityElementsHidden:true,importantForAccessibility:"no",style:[t?n.readingDotInline:n.readingDot,l?{opacity:Mm}:{opacity:e.interpolate({inputRange:[0,1],outputRange:[Dm,1]}),transform:[{translateY:e.interpolate({inputRange:[0,1],outputRange:[0,-3]})}]}]},r))})}function Hm(e,t,r){let n=e-r,l=t!=null?Math.min(n,t):n;return Math.max(0,l)}function Wm(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 Nm(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 Um=16;function $m(e,t,r=null){let l=i(null),o=i(true),s=i(t),u=i(0),d=i(0),c=i(0),p=i(/* @__PURE__ */new Map),f=i(null),h=i(false),g=e[0]?.id??null,b=i(g),y=i(null);a(()=>{let t=b.current;if(b.current=g,t===null||t===g||(y.current=null,o.current||!e.some(e=>e.id===t)))return;let r=p.current.get(t);r!==void 0&&(y.current={id:t,top:r,offset:u.current})},[g,e]);let m=Wm(e),v=m===null?null:e[m.assistantIndex]?.id??null,w=m===null||m.userIndex===null?null:e[m.userIndex]?.id??null,k=n(()=>{let e=l.current;if(e===null||!o.current||d.current===0)return;let t=null;if(v!==null){let e=p.current.get(v);if(e===void 0)return;let r=w===null?null:p.current.get(w)??null;t=Hm(e,r,96)}let r=Nm(t,u.current,c.current-d.current);if(r!==null&&(u.current=r,e.scrollTo({y:r,animated:false})),!h.current||f.current===null)return;let n=Nm(f.current+Um-d.current,u.current,c.current-d.current);n!==null&&(u.current=n,e.scrollTo({y:n,animated:false}))},[v,w]);a(()=>{h.current=r!==null,r===null&&(f.current=null),k()},[r,k]),a(()=>{t&&!s.current&&(o.current=true,h.current=false),s.current=t,k()},[e,t,k]);let C=n(e=>{d.current=e.nativeEvent.layout.height,k()},[k]),S=n((e,t)=>{c.current=t,d.current>0&&(u.current=Math.min(u.current,Math.max(0,t-d.current))),k()},[k]),x=n(e=>{u.current=e.nativeEvent.contentOffset.y},[]),R=n(()=>{o.current=false,h.current=false},[]),T=n(e=>{let{contentOffset:t,contentSize:r,layoutMeasurement:n}=e.nativeEvent;u.current=t.y,o.current=r.height-t.y-n.height<=24},[]),_=n(e=>t=>{let r=t.nativeEvent.layout.y;p.current.set(e,r);let n=y.current;if(n!==null&&n.id===e&&r!==n.top){y.current=null;let e=Math.max(0,n.offset+r-n.top);u.current=e,l.current?.scrollTo({y:e,animated:false})}(e===v||e===w)&&k()},[v,w,k]),z=n(e=>{let{y:t,height:r}=e.nativeEvent.layout;f.current=t+r,k()},[k]);return{ref:l,onLayout:C,onContentSizeChange:S,onScroll:x,onScrollBeginDrag:R,onScrollEnd:T,rowLayout:_,asideLayout:z}}function Vm(e,t,r){switch(e){case"loading":return r.renderPending?/* @__PURE__ */A(HostRender,{render:r.renderPending,fallback:/* @__PURE__ */A(LoadingState,{})}):/* @__PURE__ */A(LoadingState,{});case"empty":/* @__PURE__ */
314
315
  return A(EmptyState,{pet:r.shownPet,petRef:t.petRef,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet,top:r.threadTop,pendingCheckin:r.pendingCheckin??null,topCard:r.topCard,starterPrompts:r.starterPrompts,emptyState:r.emptyState,centered:r.emptyCentered===true,renderEmptyHeader:r.renderEmptyHeader});case"error":/* @__PURE__ */
315
316
  return A(ErrorState,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case"populated":/* @__PURE__ */
316
- return A(PopulatedState,{messages:t.messages,prompts:_n(t,r.followUpPolicy),actions:r.answerCards?Sb(t,r.answerCards):Lm,answerCards:r.answerCards??null,threadTop:r.threadTop,pendingCheckin:r.pendingCheckin??null,threadAside:r.threadAside,threadAsideKey:r.threadAsideKey??null,onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,feedbackNote:r.feedbackNote,imagesByMessage:r.imagesByMessage,onPreview:r.onPreview,notice:r.notice,reconnecting:t.reconnecting===true,onRetry:t.retryLast,onStartNew:t.newConversation,petRef:t.petRef,onFindVet:r.onCheckinFindVet,vet:r.vet,onOpenUrl:r.onOpenUrl,petName:r.shownPet?.name??null,followUpLabel:r.followUpPolicy?.label,openingCard:r.openingCard,earlier:t.historyCursor?{loading:t.isLoadingHistory,load:t.loadOlderMessages}:null});default:return assertNever(e)}}function LoadingState(){let{theme:e,styles:t}=Eu(),[r,n]=o(false);return a(()=>{let e=setTimeout(()=>n(true),Bs);return()=>clearTimeout(e)},[]),/* @__PURE__ */A(v,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:He.loading,children:r?/* @__PURE__ */A(_,{color:e.color.brandInk}):null})}function EmptyState({pet:e,petRef:petRef,onSelectPrompt:t,onVetPrep:r,vet:n,top:l,topCard:i,pendingCheckin:o,starterPrompts:a,emptyState:s,centered:u,renderEmptyHeader:d}){let{styles:c}=Eu(),p=nf(),f=d===void 0?null:/* @__PURE__ */A(v,{testID:"everfur-empty-header",children:/* @__PURE__ */A(HostRender,{render:()=>d({ask:t}),fallback:null})});if(p!==null){let{minHeight:u,...d}=p.view(".ask-empty");/* @__PURE__ */
317
- return j(T,{contentContainerStyle:[d,c.homeEmpty],keyboardShouldPersistTaps:"handled",keyboardDismissMode:Om,nestedScrollEnabled:true,accessibilityLabel:He.empty,children:[l!=null?/* @__PURE__ */A(v,{style:p.view(".ask-top"),children:l}):null,o,i??null,f,
317
+ return A(PopulatedState,{messages:t.messages,prompts:In(t,r.followUpPolicy),actions:r.answerCards?Mb(t,r.answerCards):Gm,answerCards:r.answerCards??null,threadTop:r.threadTop,pendingCheckin:r.pendingCheckin??null,threadAside:r.threadAside,threadAsideKey:r.threadAsideKey??null,onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,feedbackNote:r.feedbackNote,imagesByMessage:r.imagesByMessage,onPreview:r.onPreview,notice:r.notice,reconnecting:t.reconnecting===true,onRetry:t.retryLast,onStartNew:t.newConversation,petRef:t.petRef,onFindVet:r.onCheckinFindVet,vet:r.vet,onOpenUrl:r.onOpenUrl,petName:r.shownPet?.name??null,followUpLabel:r.followUpPolicy?.label,openingCard:r.openingCard,earlier:t.historyCursor?{loading:t.isLoadingHistory,load:t.loadOlderMessages}:null});default:return assertNever(e)}}function LoadingState(){let{theme:e,styles:t}=Au(),[r,n]=o(false);return a(()=>{let e=setTimeout(()=>n(true),Ws);return()=>clearTimeout(e)},[]),/* @__PURE__ */A(v,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:Ne.loading,children:r?/* @__PURE__ */A(_,{color:e.color.brandInk}):null})}function EmptyState({pet:e,petRef:petRef,onSelectPrompt:t,onVetPrep:r,vet:n,top:l,topCard:i,pendingCheckin:o,starterPrompts:a,emptyState:s,centered:u,renderEmptyHeader:d}){let{styles:c}=Au(),p=pf(),f=d===void 0?null:/* @__PURE__ */A(v,{testID:"everfur-empty-header",children:/* @__PURE__ */A(HostRender,{render:()=>d({ask:t}),fallback:null})});if(p!==null){let{minHeight:u,...d}=p.view(".ask-empty");/* @__PURE__ */
318
+ return j(T,{contentContainerStyle:[d,c.homeEmpty],keyboardShouldPersistTaps:"handled",keyboardDismissMode:Ym,nestedScrollEnabled:true,accessibilityLabel:Ne.empty,children:[l!=null?/* @__PURE__ */A(v,{style:p.view(".ask-top"),children:l}):null,o,i??null,f,
318
319
  /* @__PURE__ */A(v,{style:p.view(".ask-start"),children:/* @__PURE__ */A(QuickPrompts,{pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:a,emptyState:s,centered:true})})]})}
319
320
  /* @__PURE__ */
320
- return j(T,{contentContainerStyle:c.emptyContent,keyboardShouldPersistTaps:"handled",keyboardDismissMode:Om,nestedScrollEnabled:true,accessibilityLabel:He.empty,children:[l??null,o,i??null,f,
321
- /* @__PURE__ */A(QuickPrompts,{pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:a,emptyState:s,centered:u})]})}function FollowUps({prompts:e,onSelectPrompt:t,label:r}){let{styles:n}=Eu();return e.length===0?null:/* @__PURE__ */j(v,{style:n.followUps,children:[
322
- /* @__PURE__ */A(Text,{tier:"compact",style:n.followUpsHeading,accessibilityRole:"header",children:r??He.followUpsHeadingNative}),e.map((e,r)=>/* @__PURE__ */A(FollowUpRow,{prompt:e,index:r,onSelectPrompt:t},e))]})}function FollowUpRow({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:l}=Eu(),i=Co(),o=Fo(i.followUpInMs,{delayMs:wo(i,t)});/* @__PURE__ */
321
+ return j(T,{contentContainerStyle:c.emptyContent,keyboardShouldPersistTaps:"handled",keyboardDismissMode:Ym,nestedScrollEnabled:true,accessibilityLabel:Ne.empty,children:[l??null,o,i??null,f,
322
+ /* @__PURE__ */A(QuickPrompts,{pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:a,emptyState:s,centered:u})]})}function FollowUps({prompts:e,onSelectPrompt:t,label:r}){let{styles:n}=Au();return e.length===0?null:/* @__PURE__ */j(v,{style:n.followUps,children:[
323
+ /* @__PURE__ */A(Text,{tier:"compact",style:n.followUpsHeading,accessibilityRole:"header",children:r??Ne.followUpsHeadingNative}),e.map((e,r)=>/* @__PURE__ */A(FollowUpRow,{prompt:e,index:r,onSelectPrompt:t},e))]})}function FollowUpRow({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:l}=Au(),i=xo(),o=Eo(i.followUpInMs,{delayMs:Co(i,t)});/* @__PURE__ */
323
324
  return A(L.View,{style:o,children:/* @__PURE__ */j(PressScale,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:[l.followUpSlot,t>0?l.followUpSlotRuled:null],style:l.followUpRow,children:[
324
325
  /* @__PURE__ */A(Text,{tier:"control",style:l.followUpText,children:e}),
325
- /* @__PURE__ */A(PlusGlyph,{size:Am,color:n.slots.chip?.textColor??n.color.text.muted,strokeWidth:1.75})]})})}function ErrorState({error:e,onRetry:t,onAddPet:r}){let{styles:n}=Eu(),l=Nl(e)?Yr(r):void 0,i=mn(e);/* @__PURE__ */
326
+ /* @__PURE__ */A(PlusGlyph,{size:Qm,color:n.slots.chip?.textColor??n.color.text.muted,strokeWidth:1.75})]})})}function ErrorState({error:e,onRetry:t,onAddPet:r}){let{styles:n}=Au(),l=$l(e)?Zr(r):void 0,i=wn(e);/* @__PURE__ */
326
327
  return j(v,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[i!==null?/* @__PURE__ */A(Text,{style:n.errorText,testID:"everfur-chat-cap-reached",children:i.reached}):null,
327
- /* @__PURE__ */A(Text,{style:n.errorText,children:e.displayMessage}),i!==null&&i.guidance!==null?/* @__PURE__ */A(Text,{style:n.errorText,testID:"everfur-chat-cap-guidance",children:i.guidance}):null,l!==void 0?/* @__PURE__ */A(C,{onPress:l,accessibilityRole:"button",accessibilityLabel:He.addPet,style:n.retryButton,children:/* @__PURE__ */A(Text,{tier:"control",style:n.retryLabel,children:He.addPet})}):null,e.retryable?/* @__PURE__ */A(C,{onPress:t,accessibilityRole:"button",accessibilityLabel:He.retry,style:n.retryButton,children:/* @__PURE__ */A(Text,{tier:"control",style:n.retryLabel,children:He.retry})}):null]})}function PopulatedState({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:i,onCopy:o,sentimentByMessage:a,onSentiment:s,feedbackNote:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:f,onRetry:h,onStartNew:g,petRef:petRef,onFindVet:b,vet:y,onOpenUrl:m,petName:w,actions:k,answerCards:S,threadTop:x,pendingCheckin:R,threadAside:_,threadAsideKey:z,followUpLabel:I,openingCard:P,earlier:F}){let{styles:L}=Eu(),E=Co();Bo(e.length,E);let O=l(()=>Qg(Yg(e)),[e]),D=kn(e,n),M=e[e.length-1],B=_??null,H=Im(e,n,B===null?null:z??"shown"),W=Oo(e),N=e[0],U=P!==void 0&&N!==void 0&&N.role==="user"&&N.text.trim()===P.prompt?N.id:null;/* @__PURE__ */
328
- return j(T,{ref:H.ref,style:L.list,contentContainerStyle:S!==null?L.listContentCards:L.listContent,accessibilityLabel:He.transcript,keyboardShouldPersistTaps:"handled",keyboardDismissMode:Om,nestedScrollEnabled:true,onLayout:H.onLayout,onContentSizeChange:H.onContentSizeChange,onScroll:H.onScroll,scrollEventThrottle:Em,onScrollBeginDrag:H.onScrollBeginDrag,onScrollEndDrag:H.onScrollEnd,onMomentumScrollEnd:H.onScrollEnd,children:[x??null,R,F!==null?/* @__PURE__ */A(C,{onPress:()=>{F.load()},disabled:F.loading,accessibilityRole:"button",accessibilityLabel:F.loading?Fi.loadingEarlier:Fi.earlier,accessibilityState:{disabled:F.loading,busy:F.loading},hitSlop:iu,style:L.earlierButton,children:/* @__PURE__ */A(Text,{tier:"compact",style:L.earlierLabel,children:F.loading?Fi.loadingEarlier:Fi.earlier})}):null,e.map(t=>t.id===U&&P!==void 0?/* @__PURE__ */A(OpeningCard,{card:P.card,onLayout:H.rowLayout(t.id)},t.id):t.checkin&&O.has(t.id)?/* @__PURE__ */A(CheckinCard,{message:t,checkin:t.checkin,onAnswer:i,petRef:petRef,onFindVet:b,vet:y,onLayout:H.rowLayout(t.id)},t.id):/* @__PURE__ */A(MessageRow,{onLayout:H.rowLayout(t.id),message:t,revealing:n&&t===M&&t.role==="assistant",onCopy:o,sentiment:t.responseId===void 0?null:a[String(t.responseId)]??null,onSentiment:s,note:t.responseId!==void 0&&u?.responseId===String(t.responseId)?u.kind:null,images:d[t.id]??Fm,onPreview:c,onOpenUrl:m,entering:W(t.id),answerCards:S,messages:e},t.id)),f?/* @__PURE__ */A(Text,{tier:"compact",style:L.reconnectingCaption,accessibilityRole:"text",children:He.reconnecting}):null,D?/* @__PURE__ */A(TypingIndicator,{petName:w,inline:S!==null}):null,p!==null?/* @__PURE__ */A(TurnNoticeCard,{notice:p,onRetry:h,onStartNew:g}):null,S!==null?/* @__PURE__ */A(CardsFollowUps,{prompts:t,onSelectPrompt:r,label:I,actions:k,options:S}):/* @__PURE__ */A(FollowUps,{prompts:t,onSelectPrompt:r,label:I}),B!==null?/* @__PURE__ */A(v,{onLayout:H.asideLayout,children:B}):null]})}function TurnNoticeCard({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=Eu(),l=e.tone==="error";/* @__PURE__ */
328
+ /* @__PURE__ */A(Text,{style:n.errorText,children:e.displayMessage}),i!==null&&i.guidance!==null?/* @__PURE__ */A(Text,{style:n.errorText,testID:"everfur-chat-cap-guidance",children:i.guidance}):null,l!==void 0?/* @__PURE__ */A(C,{onPress:l,accessibilityRole:"button",accessibilityLabel:Ne.addPet,style:n.retryButton,children:/* @__PURE__ */A(Text,{tier:"control",style:n.retryLabel,children:Ne.addPet})}):null,e.retryable?/* @__PURE__ */A(C,{onPress:t,accessibilityRole:"button",accessibilityLabel:Ne.retry,style:n.retryButton,children:/* @__PURE__ */A(Text,{tier:"control",style:n.retryLabel,children:Ne.retry})}):null]})}function PopulatedState({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:i,onCopy:o,sentimentByMessage:a,onSentiment:s,feedbackNote:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:f,onRetry:h,onStartNew:g,petRef:petRef,onFindVet:b,vet:y,onOpenUrl:m,petName:w,actions:k,answerCards:S,threadTop:x,pendingCheckin:R,threadAside:_,threadAsideKey:z,followUpLabel:I,openingCard:P,earlier:F}){let L=Ed(),{styles:E}=Au(),O=xo();Wo(e.length,O);let D=l(()=>cb(db(e)),[e]),M=Sn(e,n),B=e[e.length-1],H=_??null,W=$m(e,n,H===null?null:z??"shown"),N=jo(e),U=e[0],$=P!==void 0&&U!==void 0&&U.role==="user"&&U.text.trim()===P.prompt?U.id:null;/* @__PURE__ */
329
+ return j(T,{ref:W.ref,style:E.list,contentContainerStyle:S!==null?E.listContentCards:E.listContent,accessibilityLabel:Ne.transcript,keyboardShouldPersistTaps:"handled",keyboardDismissMode:Ym,nestedScrollEnabled:true,onLayout:W.onLayout,onContentSizeChange:W.onContentSizeChange,onScroll:W.onScroll,scrollEventThrottle:Km,onScrollBeginDrag:W.onScrollBeginDrag,onScrollEndDrag:W.onScrollEnd,onMomentumScrollEnd:W.onScrollEnd,children:[x??null,R,F!==null?/* @__PURE__ */A(C,{onPress:()=>{F.load()},disabled:F.loading,accessibilityRole:"button",accessibilityLabel:F.loading?Ei.loadingEarlier:Ei.earlier,accessibilityState:{disabled:F.loading,busy:F.loading},hitSlop:au,style:E.earlierButton,children:/* @__PURE__ */A(Text,{tier:"compact",style:E.earlierLabel,children:F.loading?Ei.loadingEarlier:Ei.earlier})}):null,e.map(t=>t.id===$&&P!==void 0?/* @__PURE__ */A(OpeningCard,{card:P.card,onLayout:W.rowLayout(t.id)},t.id):t.checkin&&D.has(t.id)?/* @__PURE__ */A(CheckinCard,{message:t,checkin:t.checkin,onAnswer:i,petRef:petRef,onFindVet:b,vet:y,onLayout:W.rowLayout(t.id)},t.id):/* @__PURE__ */A(MessageRow,{onLayout:W.rowLayout(t.id),message:t,revealing:n&&t===B&&t.role==="assistant",onCopy:o,sentiment:t.responseId===void 0?null:a[String(t.responseId)]??null,onSentiment:s,note:t.responseId!==void 0&&u?.responseId===String(t.responseId)?u.kind:null,images:d[t.id]??qm,onPreview:c,onOpenUrl:m,entering:N(t.id),answerCards:S,messages:e},t.id)),f?/* @__PURE__ */A(Text,{tier:"compact",style:E.reconnectingCaption,accessibilityRole:"text",children:Ne.reconnecting}):null,M?/* @__PURE__ */A(TypingIndicator,{petName:w,inline:S!==null}):null,p!==null?/* @__PURE__ */A(TurnNoticeCard,{notice:p,onRetry:h,onStartNew:g}):null,S!==null||L!==null?/* @__PURE__ */A(CardsFollowUps,{prompts:t,onSelectPrompt:r,label:I,actions:k,options:S??void 0}):/* @__PURE__ */A(FollowUps,{prompts:t,onSelectPrompt:r,label:I}),H!==null?/* @__PURE__ */A(v,{onLayout:W.asideLayout,children:H}):null]})}function TurnNoticeCard({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=Au(),l=e.tone==="error";/* @__PURE__ */
329
330
  return j(v,{style:[n.turnNotice,l?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[
330
331
  /* @__PURE__ */A(Text,{tier:"control",style:[n.turnNoticeTitle,l?n.turnNoticeTitleError:null],children:e.title}),
331
332
  /* @__PURE__ */A(Text,{tier:"compact",style:n.turnNoticeBody,children:e.body}),e.guidance!==void 0?/* @__PURE__ */A(Text,{tier:"compact",style:n.turnNoticeBody,testID:"everfur-chat-cap-guidance",children:e.guidance}):null,
332
- /* @__PURE__ */A(C,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:iu,style:n.turnNoticeAction,children:/* @__PURE__ */A(Text,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}var Fm=/* @__PURE__ */Object.freeze([]),Lm=/* @__PURE__ */Object.freeze([]),Em=16,Om=b.OS==="ios"?"interactive":"on-drag",Am=18;function MessageRow({message:e,revealing:t,onCopy:r,sentiment:l,onSentiment:i,note:o,images:a,onPreview:s,onOpenUrl:u,onLayout:d,entering:c,answerCards:p,messages:f}){let{theme:h,styles:g}=Eu(),b=Co(),y=Eo(c,b),m=jo(e.text,t,b),w=e.role==="user",k=e.role==="vet",C=e.role==="assistant",S=co(),x=C&&!t?S:void 0,R=x!==void 0&&Ob(e.text,x),T=C&&!h.meta.hidePoweredBy,_=w?He.senderUser:k?zn(e):T?He.assistantName:He.senderAssistant,z=k?tb(e.createdAt):null,I=n(t=>i(e,t),[i,e]),P=e.pending!==true,F=C&&h.meta.assistantAvatarUrl!==null?/* @__PURE__ */A(AssistantSender,{avatarUrl:h.meta.assistantAvatarUrl,named:T,styles:g}):T?p!==null?/* @__PURE__ */A(CardsByline,{label:He.assistantName}):/* @__PURE__ */A(Text,{tier:"control",style:g.assistantName,children:He.assistantName}):null,E=p!==null;return C&&p!==null?/* @__PURE__ */A(L.View,{style:[g.rowBlock,y],onLayout:d,accessibilityLabel:`${_}: ${e.text}`,children:/* @__PURE__ */A(CardsAnswer,{message:e,text:m,streaming:t,messages:f,options:p,sentiment:l,onSentiment:e.responseId===void 0?void 0:I,sender:F,onOpenUrl:u,footer:t=>/* @__PURE__ */A(MessageFooter,{message:e,onCopy:r,sentiment:l,onSentiment:t&&e.responseId!==void 0?I:void 0,note:o})})}):/* @__PURE__ */j(v,{style:[g.rowBlock,w?g.rowBlockUser:g.rowBlockAssistant],onLayout:d,children:[
333
- /* @__PURE__ */A(v,{style:[g.row,w?g.rowUser:g.rowAssistant],accessible:!R,accessibilityRole:R?void 0:"text",accessibilityLabel:R?void 0:`${_}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:/* @__PURE__ */j(L.View,{style:[g.bubble,E?g.bubbleCards:null,w?g.bubbleSideUser:null,y],children:[F,k?/* @__PURE__ */j(v,{style:g.vetHeader,children:[
334
- /* @__PURE__ */A(Text,{tier:"control",style:g.vetSender,children:_}),z!==null?/* @__PURE__ */A(Text,{tier:"compact",style:g.vetTime,children:z}):null]}):null,
335
- /* @__PURE__ */j(v,{style:[w?g.bubbleUser:k?g.bubbleVet:g.bubbleAssistant,w&&E?g.bubbleUserCards:null,e.pending?g.bubblePending:null],children:[w&&a.length>0?/* @__PURE__ */A(SentImages,{images:a,onPreview:e=>s({uri:e.uri,label:e.filename})}):null,
336
- /* @__PURE__ */A(Text,{style:w?E?[g.bubbleTextUser,g.bubbleTextUserCards]:g.bubbleTextUser:k?g.bubbleTextVet:g.bubbleTextAssistant,children:C?Ab(m,{bold:g.bubbleBold,italic:g.bubbleItalic,code:g.bubbleCode},x):e.text})]})]})}),C&&!t?/* @__PURE__ */A(ServerCardsSlot,{message:e}):null,C&&!t?/* @__PURE__ */A(CitationCards,{citations:e.citations,onOpenUrl:u}):null,P&&!(w&&p!==null)?/* @__PURE__ */A(MessageFooter,{message:e,onCopy:r,sentiment:l,onSentiment:e.responseId===void 0?void 0:I,note:o}):null]})}var jm=/* @__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"&&jm.has(t.urgencyLevel))}var NO_SNAPSHOT2=()=>null;function Dm(){let{runtime:e}=Ye(),t=e.entitlements??null,r=n(e=>t===null?()=>{}:t.subscribe(e),[t]),i=t===null?NO_SNAPSHOT2:t.getSnapshot,o=s(r,i,i);return l(()=>o!==null&&decideCapability("texting",o.decisions,{isPending:o.isPending}).enabled,[o])}var Mm=/* @__PURE__ */Object.freeze({runner:null,line:null,entry:null,stage:null,headerEntry:null});function Bm(e,t,r=false){let[n,l]=o(null);if(!e)return Mm;let i=/* @__PURE__ */A(AskRunner,{ready:textingAskThreadReady(t),onAsk:l,entry:r}),a=r&&n!==null&&n.canOpen?{label:B.textingAskLines(n).accept,onOpen:n.open}:null;if(n===null||n.stage==="hidden"||n.stage==="dismissed")return{runner:i,line:null,entry:null,stage:null,headerEntry:a};let s=B.textingAskLines(n),u=/* @__PURE__ */A(AskLine,{stage:n.stage,text:n.stage==="verified"?s.verified:s.line,accept:s.accept,dismiss:s.dismiss,onAccept:n.accept,onDismiss:n.dismiss}),d=n.stage==="enrolling"?/* @__PURE__ */A(B.ChatTextingAskComposer,{ask:n}):null;return{runner:i,line:u,entry:d,stage:n.stage,headerEntry:a}}function AskRunner({ready:e,onAsk:t,entry:r}){let{userRef:userRef}=Ye(),n=Dm(),l=userRef!==null&&n;return a(()=>{l||t(null)},[l,t]),l?/* @__PURE__ */A(B.ChatTextingAskController,{enabled:true,ready:e,onAsk:t,entry:r}):null}function AskLine({stage:e,text:t,accept:r,dismiss:n,onAccept:l,onDismiss:i}){let{theme:o,styles:a}=Eu(),s=!o.meta.hidePoweredBy,u=s?He.assistantName:He.senderAssistant,d=o.meta.assistantAvatarUrl!==null?/* @__PURE__ */A(AssistantSender,{avatarUrl:o.meta.assistantAvatarUrl,named:s,styles:a}):s?/* @__PURE__ */A(Text,{tier:"control",style:a.assistantName,children:He.assistantName}):null;/* @__PURE__ */
333
+ /* @__PURE__ */A(C,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:au,style:n.turnNoticeAction,children:/* @__PURE__ */A(Text,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}var qm=/* @__PURE__ */Object.freeze([]),Gm=/* @__PURE__ */Object.freeze([]),Km=16,Ym=b.OS==="ios"?"interactive":"on-drag",Qm=18;function MessageRow({message:e,revealing:t,onCopy:r,sentiment:l,onSentiment:i,note:o,images:a,onPreview:s,onOpenUrl:u,onLayout:d,entering:c,answerCards:p,messages:f}){let{theme:h,styles:g}=Au(),b=Ed()?.paint,y=xo(),m=Ao(c,y),w=Mo(e.text,t,y),k=e.role==="user",C=e.role==="vet",S=e.role==="assistant",x=fo(),R=S&&!t?x:void 0,T=R!==void 0&&Yb(e.text,R),_=S&&!h.meta.hidePoweredBy,z=k?Ne.senderUser:C?Pn(e):_?Ne.assistantName:Ne.senderAssistant,I=C?bb(e.createdAt):null,P=n(t=>i(e,t),[i,e]),F=e.pending!==true,E=_&&b!==void 0?/* @__PURE__ */A(b.Byline,{}):S&&h.meta.assistantAvatarUrl!==null?/* @__PURE__ */A(AssistantSender,{avatarUrl:h.meta.assistantAvatarUrl,named:_,styles:g}):_?p!==null?/* @__PURE__ */A(CardsByline,{label:Ne.assistantName}):/* @__PURE__ */A(Text,{tier:"control",style:g.assistantName,children:Ne.assistantName}):null,O=p!==null;return S&&p!==null?/* @__PURE__ */A(L.View,{style:[g.rowBlock,m],onLayout:d,accessibilityLabel:`${z}: ${e.text}`,children:/* @__PURE__ */A(CardsAnswer,{message:e,text:w,streaming:t,messages:f,options:p,sentiment:l,onSentiment:e.responseId===void 0?void 0:P,sender:E,onOpenUrl:u,footer:t=>/* @__PURE__ */A(MessageFooter,{message:e,onCopy:r,sentiment:l,onSentiment:t&&e.responseId!==void 0?P:void 0,note:o})})}):/* @__PURE__ */j(v,{style:[g.rowBlock,k?g.rowBlockUser:g.rowBlockAssistant],onLayout:d,children:[
334
+ /* @__PURE__ */A(v,{style:[g.row,k?g.rowUser:g.rowAssistant],accessible:!T,accessibilityRole:T?void 0:"text",accessibilityLabel:T?void 0:`${z}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:/* @__PURE__ */j(L.View,{style:[g.bubble,O?g.bubbleCards:null,k?g.bubbleSideUser:null,m],children:[E,S&&F&&!t?/* @__PURE__ */A(SeverityCard,{message:e,spaced:true}):null,C?/* @__PURE__ */j(v,{style:g.vetHeader,children:[
335
+ /* @__PURE__ */A(Text,{tier:"control",style:g.vetSender,children:z}),I!==null?/* @__PURE__ */A(Text,{tier:"compact",style:g.vetTime,children:I}):null]}):null,
336
+ /* @__PURE__ */j(v,{style:[k?[g.bubbleUser,b?.userBubble]:C?g.bubbleVet:g.bubbleAssistant,k&&O?g.bubbleUserCards:null,e.pending?g.bubblePending:null],children:[k&&a.length>0?/* @__PURE__ */A(SentImages,{images:a,onPreview:e=>s({uri:e.uri,label:e.filename})}):null,
337
+ /* @__PURE__ */A(Text,{style:k?[g.bubbleTextUser,O?g.bubbleTextUserCards:null,b?.userText]:C?g.bubbleTextVet:g.bubbleTextAssistant,children:S?Qb(w,{bold:g.bubbleBold,italic:g.bubbleItalic,code:g.bubbleCode},R):e.text})]})]})}),S&&!t?/* @__PURE__ */A(ServerCardsSlot,{message:e}):null,S&&!t?/* @__PURE__ */A(CitationCards,{citations:e.citations,onOpenUrl:u}):null,S&&!t?/* @__PURE__ */A(AnswerRecordCards,{message:e,spaced:true}):null,F&&!(k&&p!==null)?/* @__PURE__ */A(MessageFooter,{message:e,onCopy:r,sentiment:l,onSentiment:e.responseId===void 0?void 0:P,note:o}):null]})}var Zm=/* @__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"&&Zm.has(t.urgencyLevel))}var NO_SNAPSHOT2=()=>null;function Jm(){let{runtime:e}=Ze(),t=e.entitlements??null,r=n(e=>t===null?()=>{}:t.subscribe(e),[t]),i=t===null?NO_SNAPSHOT2:t.getSnapshot,o=s(r,i,i);return l(()=>o!==null&&decideCapability("texting",o.decisions,{isPending:o.isPending}).enabled,[o])}var Xm=/* @__PURE__ */Object.freeze({runner:null,line:null,entry:null,stage:null,headerEntry:null});function ev(e,t,r=false){let[n,l]=o(null);if(!e)return Xm;let i=/* @__PURE__ */A(AskRunner,{ready:textingAskThreadReady(t),onAsk:l,entry:r}),a=r&&n!==null&&n.canOpen?{label:B.textingAskLines(n).accept,onOpen:n.open}:null;if(n===null||n.stage==="hidden"||n.stage==="dismissed")return{runner:i,line:null,entry:null,stage:null,headerEntry:a};let s=B.textingAskLines(n),u=/* @__PURE__ */A(AskLine,{stage:n.stage,text:n.stage==="verified"?s.verified:s.line,accept:s.accept,dismiss:s.dismiss,onAccept:n.accept,onDismiss:n.dismiss}),d=n.stage==="enrolling"?/* @__PURE__ */A(B.ChatTextingAskComposer,{ask:n}):null;return{runner:i,line:u,entry:d,stage:n.stage,headerEntry:a}}function AskRunner({ready:e,onAsk:t,entry:r}){let{userRef:userRef}=Ze(),n=Jm(),l=userRef!==null&&n;return a(()=>{l||t(null)},[l,t]),l?/* @__PURE__ */A(B.ChatTextingAskController,{enabled:true,ready:e,onAsk:t,entry:r}):null}function AskLine({stage:e,text:t,accept:r,dismiss:n,onAccept:l,onDismiss:i}){let{theme:o,styles:a}=Au(),s=!o.meta.hidePoweredBy,u=s?Ne.assistantName:Ne.senderAssistant,d=o.meta.assistantAvatarUrl!==null?/* @__PURE__ */A(AssistantSender,{avatarUrl:o.meta.assistantAvatarUrl,named:s,styles:a}):s?/* @__PURE__ */A(Text,{tier:"control",style:a.assistantName,children:Ne.assistantName}):null;/* @__PURE__ */
337
338
  return j(v,{style:[a.rowBlock,a.rowBlockAssistant],testID:`everfur-texting-ask-${e}`,children:[
338
339
  /* @__PURE__ */A(v,{style:[a.row,a.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${u}: ${t}`,children:/* @__PURE__ */j(v,{style:a.bubble,children:[d,
339
- /* @__PURE__ */A(v,{style:a.bubbleAssistant,children:/* @__PURE__ */A(Text,{style:a.bubbleTextAssistant,children:t})})]})}),e==="offered"?/* @__PURE__ */A(v,{style:a.askChips,children:[{label:r,onPress:l,testID:"everfur-texting-ask-accept"},{label:n,onPress:i,testID:"everfur-texting-ask-dismiss"}].map(e=>/* @__PURE__ */A(PressScale,{onPress:e.onPress,accessibilityRole:"button",accessibilityLabel:e.label,style:a.askChip,testID:e.testID,children:/* @__PURE__ */A(Text,{tier:"control",style:a.askChipText,children:e.label})},e.testID))}):null]})}function Hm(){let e=/* @__PURE__ */Symbol.for("@everfur/sdk#SdkSurfaceHooks@v1"),t=globalThis;return t[e]??(t[e]=createContext(null))}var Wm=/* @__PURE__ */Hm();function Nm(e){return typeof e=="object"&&e!==null&&e.ok===true}function Um(e){if(typeof e!="object"||e===null)return null;let t=e;return t.ok!==false||typeof t.error!="object"||t.error===null?null:_t(t.error)}function $m(e){let t=u(Wm),r=t?.onMessageSent,l=t?.onFreeCapReached,i=n((...t)=>{let n=e(...t);return Promise.resolve(n).then(e=>{try{if(Nm(e)){r?.();return}let t=l===void 0?null:Um(e);t!==null&&l?.(t)}catch{}},()=>{}),n},[e,r,l]);return r===void 0&&l===void 0?e:i}function EverfurChatCore(e){let{style:t,renderPending:r}=e;/* @__PURE__ */
340
- return A(CapabilityGate,{capability:"chat",style:t,...r?{renderPending:r}:{},children:/* @__PURE__ */A(MessageLinksScope,{linkHosts:e.linkHosts,onOpenUrl:e.onOpenUrl,children:/* @__PURE__ */A(ChatBody,{...e})})})}function Vm(){try{return Ye()}catch{return null}}function qm(e){return bn({...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 t=Vm();return t===null?/* @__PURE__ */A(ChatBodyAlone,{...e}):/* @__PURE__ */A(ChatBodyInProvider,{...e,activePet:t.activePet,telemetry:t.runtime.registry?.services?.telemetry??null})}function ChatBodyAlone(e){let t=qm(e),r=JSON.stringify(t),n=e.petRef??null,i=l(()=>({presentation:resolvePresentation({server:null,locked:null,client:t}),isLocked:()=>false,planPage:null,planPetRef:n,inProvider:false,telemetry:null}),[r,n]);/* @__PURE__ */
341
- return A(ChatSurface,{...e,settings:i})}function ChatBodyInProvider({activePet:e,telemetry:t,...r}){let{presentation:n,isLocked:isLocked}=gn(qm(r)),i=sn("healthPlan"),o=n.chatTopCard==="focus"&&r.topCard===void 0&&i,a=r.petRef??e??null,s=useHealthPlanPage({petRef:a,enabled:o}),u=o&&s.phase==="ready"?s.page:null,d=l(()=>({presentation:n,isLocked:isLocked,planPage:u,planPetRef:a,inProvider:true,telemetry:t}),[n,isLocked,u,a,t]);/* @__PURE__ */
342
- return A(ChatSurface,{...r,settings:d})}function ChatSurface({settings:e,petRef:petRef,conversationId:conversationId,style:t,renderPending:r,onCopy:s,onPetChange:u,onVetPrep:d,onFindVet:c,renderVetAction:p,attachments:f,pet:h,onAddPet:g,checkinTarget:y,handoffToken:m,initialAsk:w,initialAskKey:C,composerSeed:S,lifecycle:x,refreshIntervalMs:R,refreshesBlankThread:T,openUnreadOnRefresh:_,draftStore:z,vetReturnTo:I,vetUsState:P,vetPrefer:F,onOpenUrl:L,keyboardVerticalOffset:E,topCard:O,onOpenHealthPlan:B,answerCards:H,historySheet:W,historyBar:N,starterPrompts:U,emptyState:$,header:V=true,textingEntry:q=true,renderEmptyHeader:G,followUpPolicy:K,initialAskCard:Y}){let{presentation:Q,isLocked:isLocked,planPage:Z,planPetRef:J}=e,{theme:X,styles:ee}=Eu(),te=rf()??(Q.chatAnswerStyle==="cards"?Zh:null),re=l(()=>te===null?null:te(X),[te,X]),ne=useHostPoweredBy(),le=Co(),ie=l(()=>In(petRef,conversationId),[petRef,conversationId]),oe=useEverfurChat(ie),ae=$m(oe.send),se=l(()=>ae===oe.send?oe:{...oe,send:ae},[oe,ae]),ue=yn(se),de=Ug(),ce=Hi(se),pe=M(),fe=wn(se,"web"),he=l(()=>c===void 0?void 0:()=>{Gr(c,"emergency")},[c]),ge=l(()=>I===void 0&&P===void 0&&F===void 0?void 0:{returnTo:I,usState:P,prefer:F},[I,P,F]),be=jp(de.pets,se.petRef),[ye,me]=o(null),ve=l(()=>{let e=qi(se.messages,be?.name??null);return e?.level==="schedule_soon"&&e.messageId===ye?null:e},[se.messages,be?.name,ye]),we=Ki(ve);Vg(se),Bo(we.showBanner,le);let ke=Vm(),Ce=zi(m,ke);Pi(se.openCheckin,y??Ce,{petRef:se.petRef,pinned:petRef!==void 0,ready:!se.isBootstrapping,selectPet:e=>{de.setActivePet(e),Gr(u,e)}}),Jl(se.askEverfur,se.isBootstrapping,w,C);let Se=l(()=>Zl(S),[S]),xe=l(()=>Zl(w),[w]),Re=l(()=>Y!==void 0&&xe!==null?{card:Y,prompt:xe}:void 0,[Y,xe]),Te=l(()=>x===void 0?createAppStateLifecycle():x??void 0,[x]);di(Te,{conversationId:se.conversationId===null?null:String(se.conversationId),isTurnInFlight:se.isStreaming,refreshesBlankThread:T===true||_===true,refresh:se.refreshActiveThread===void 0?void 0:()=>se.refreshActiveThread?.(ni(_===true,li(Te,Yo)))??Promise.resolve()},{intervalMs:R===void 0?3e4:R,isVisibleFallback:Yo}),ii({isStreaming:se.isStreaming,status:se.status,conversationId:se.conversationId===null?null:String(se.conversationId),unreadCount:se.unreadCount,markRead:se.markRead},()=>li(Te,Yo));let _e=se.pendingCheckin??null,ze=_e===null?null:/* @__PURE__ */A(v,{testID:"everfur-pending-checkin",accessibilityLiveRegion:"polite",children:/* @__PURE__ */A(CheckinCard,{message:_e.message,checkin:_e.checkin,onAnswer:se.petRef?se.answerCheckin:null,petRef:se.petRef,onFindVet:he,vet:ge,onOpen:()=>{se.resumeConversation(_e.conversationId)}})}),Ie=(se.hasUnreadThreads??false)||ce.rows.some(e=>e.unreadCount!==null&&e.unreadCount>0)||(se.unreadCount??0)>0,Pe=ql(se.messages),[Fe,Le]=o(null),Ee=n(()=>Le(null),[]),[Oe,Ae]=o(null),[je,De]=o(null),Me=i(null);a(()=>()=>{Me.current&&clearTimeout(Me.current)},[]);let Be=n((e,t)=>{De({responseId:String(e),kind:t}),Me.current&&clearTimeout(Me.current),Me.current=t==="thanks"?setTimeout(()=>{De(null),Me.current=null},Hs):null},[]),We=n((e,t)=>{let r=e.responseId;if(r===void 0)return;let n=se.sentimentByMessage[String(r)];De(e=>e?.responseId===String(r)?null:e),se.feedback(r,t).then(e=>{e.ok||Be(r,"failed")}),t==="down"&&n!=="down"&&Ae(r)},[se,Be]),Ne=n(async(e,t)=>Oe===null||!(e==null&&t===null?{ok:true}:await se.feedback(Oe,"down",e??"other",t)).ok?false:(Ae(null),Be(Oe,"thanks"),true),[se,Oe,Be]),Ue=n(()=>Ae(null),[]),$e=n(e=>{se.send(e)},[se.send]),Ve=l(()=>L===void 0?void 0:e=>{Gr(L,e,"citation")},[L]),qe=b.OS==="ios"?"padding":void 0,Ge=og(E,qe!==void 0),Ke=Ge.topInWindow===null?pe.top:Math.max(0,pe.top-Ge.topInWindow),Ye=sg(),Qe=l(()=>B===void 0?void 0:()=>{Gr(B,J)},[B,J]),Ze=l(()=>({petRef:se.petRef,vet:ge,cover:me}),[se.petRef,ge]),Je=l(()=>O===void 0?healthPlanTopCard(Z,{onOpenPlan:Qe}):void 0,[O,Z,Qe]),Xe=Q.chatTopCard==="focus"?O??Je:void 0,[et,tt]=o(true),rt=n(e=>{se.send(e)},[se.send]),nt=l(()=>Ln(K,Q,isLocked("chatFollowUpCount")),[K,Q,isLocked]),lt=Q.chatAnswerStyle==="cards",it=l(()=>lt&&se.messages.length===0?Ym(se.suggestedPrompts):void 0,[lt,se.messages.length,se.suggestedPrompts]),ot=Q.chatHistoryStyle==="sheet",at=se.messages.length===0,st=Xe!==void 0?/* @__PURE__ */A(TopCardPill,{card:Xe,open:et,onOpenChange:tt}):null,ut=N??(V?void 0:Qm),dt=ut!==void 0?/* @__PURE__ */A(HistoryBar,{bar:ut,history:ce,empty:at,unread:Ie,extra:st}):null,ct=Q.chatHistoryBar==="scroll"&&(ue==="empty"||ue==="populated"),pt=Xe===void 0?null:/* @__PURE__ */j(D,{children:[
343
- /* @__PURE__ */A(TopCard,{card:Xe,open:et,onOpenChange:tt,ask:rt}),ut===void 0?st:null]}),ft=ut!==void 0,ht=ce.load,gt=ce.open;a(()=>{ft&&!gt&&ht()},[ft,gt,se.conversationId,ht]);let bt={send:se.send,stop:se.stop,isStreaming:se.isStreaming,conversationId:se.conversationId,seed:Se,draftStore:z,onStage:Pe.stage,onPreview:Le,petName:be?.name??null,petBreed:be?.breed??null,compact:Q.chatComposerStyle==="compact",petPlaceholder:Q.chatComposerPlaceholder==="pet_name",dimEmptySend:Q.chatSendButton==="dim_when_empty",mood:Zm(ue,we.source?.level??null),dictation:Q.chatComposerMic,telemetry:e.telemetry},yt=Bm(Q.chatTextingAsk&&e.inProvider,se,q),mt=f!==void 0&&Q.chatComposerUpload,vt=!Q.chatGeneralBanner&&we.source?.level==="general";
340
+ /* @__PURE__ */A(v,{style:a.bubbleAssistant,children:/* @__PURE__ */A(Text,{style:a.bubbleTextAssistant,children:t})})]})}),e==="offered"?/* @__PURE__ */A(v,{style:a.askChips,children:[{label:r,onPress:l,testID:"everfur-texting-ask-accept"},{label:n,onPress:i,testID:"everfur-texting-ask-dismiss"}].map(e=>/* @__PURE__ */A(PressScale,{onPress:e.onPress,accessibilityRole:"button",accessibilityLabel:e.label,style:a.askChip,testID:e.testID,children:/* @__PURE__ */A(Text,{tier:"control",style:a.askChipText,children:e.label})},e.testID))}):null]})}function tv(){let e=/* @__PURE__ */Symbol.for("@everfur/sdk#SdkSurfaceHooks@v1"),t=globalThis;return t[e]??(t[e]=createContext(null))}var rv=/* @__PURE__ */tv();function nv(e){return typeof e=="object"&&e!==null&&e.ok===true}function lv(e){if(typeof e!="object"||e===null)return null;let t=e;return t.ok!==false||typeof t.error!="object"||t.error===null?null:It(t.error)}function iv(e){let t=u(rv),r=t?.onMessageSent,l=t?.onFreeCapReached,i=n((...t)=>{let n=e(...t);return Promise.resolve(n).then(e=>{try{if(nv(e)){r?.();return}let t=l===void 0?null:lv(e);t!==null&&l?.(t)}catch{}},()=>{}),n},[e,r,l]);return r===void 0&&l===void 0?e:i}function EverfurChatCore(e){let{style:t,renderPending:r}=e;/* @__PURE__ */
341
+ return A(CapabilityGate,{capability:"chat",style:t,...r?{renderPending:r}:{},children:/* @__PURE__ */A(MessageLinksScope,{linkHosts:e.linkHosts,onOpenUrl:e.onOpenUrl,children:/* @__PURE__ */A(ChatBody,{...e})})})}function ov(){try{return Ze()}catch{return null}}function av(e){return mn({...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 sv(e,t){let r=Zg(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 t=ov();return t===null?/* @__PURE__ */A(ChatBodyAlone,{...e}):/* @__PURE__ */A(ChatBodyInProvider,{...e,activePet:t.activePet,telemetry:t.runtime.registry?.services?.telemetry??null})}function ChatBodyAlone(e){let t=av(e),r=JSON.stringify(t),n=e.petRef??null,i=l(()=>({presentation:sv(resolvePresentation({server:null,locked:null,client:t}),false),isLocked:()=>false,planPage:null,planPetRef:n,inProvider:false,telemetry:null}),[r,n]);/* @__PURE__ */
342
+ return A(ChatSurface,{...e,settings:i})}function ChatBodyInProvider({activePet:e,telemetry:t,...r}){let{presentation:n,isLocked:isLocked}=yn(av(r)),i=Dh(),o=l(()=>sv(n,i),[i,n]),a=dn("healthPlan"),s=o.chatTopCard==="focus"&&o.shellHeader!=="tabs_bar"&&r.topCard===void 0&&a,u=r.petRef??e??null,d=useHealthPlanPage({petRef:u,enabled:s}),c=s&&d.phase==="ready"?d.page:null,p=l(()=>({presentation:o,isLocked:isLocked,planPage:c,planPetRef:u,inProvider:true,telemetry:t}),[o,isLocked,c,u,t]);/* @__PURE__ */
343
+ return A(ChatSurface,{...r,settings:p})}function ChatSurface({settings:e,petRef:petRef,conversationId:conversationId,style:t,renderPending:r,onCopy:s,onPetChange:u,onVetPrep:d,onFindVet:c,renderVetAction:p,attachments:f,pet:h,onAddPet:g,checkinTarget:y,handoffToken:m,initialAsk:w,initialAskKey:C,composerSeed:S,lifecycle:x,refreshIntervalMs:R,refreshesBlankThread:T,openUnreadOnRefresh:_,draftStore:z,vetReturnTo:I,vetUsState:P,vetPrefer:F,onOpenUrl:L,keyboardVerticalOffset:E,topCard:O,onOpenHealthPlan:B,onOpenRecord:H,answerCards:W,historySheet:N,historyBar:U,starterPrompts:$,emptyState:V,header:q=true,textingEntry:G=true,renderEmptyHeader:K,followUpPolicy:Y,initialAskCard:Q}){let{presentation:Z,isLocked:isLocked,planPage:J,planPetRef:X}=e,{theme:ee,styles:te}=Au(),re=cf()??(Z.chatAnswerStyle==="cards"?ug:null),ne=l(()=>re===null?null:re(ee),[re,ee]),le=useHostPoweredBy(),ie=xo(),oe=l(()=>Fn(petRef,conversationId),[petRef,conversationId]),ae=useEverfurChat(oe),se=iv(ae.send),ue=l(()=>se===ae.send?ae:{...ae,send:se},[ae,se]),de=vn(ue),ce=lb(),pe=Ni(ue),fe=M(),he=Cn(ue,"web"),ge=l(()=>c===void 0?void 0:()=>{Yr(c,"emergency")},[c]),be=l(()=>I===void 0&&P===void 0&&F===void 0?void 0:{returnTo:I,usState:P,prefer:F},[I,P,F]),ye=$p(ce.pets,ue.petRef),[me,ve]=o(null),we=l(()=>{let e=Ki(ue.messages,ye?.name??null);return e?.level==="schedule_soon"&&e.messageId===me?null:e},[ue.messages,ye?.name,me]),ke=Qi(we);ob(ue),Wo(ke.showBanner,ie);let Ce=ov(),Se=Pi(m,Ce);Li(ue.openCheckin,y??Se,{petRef:ue.petRef,pinned:petRef!==void 0,ready:!ue.isBootstrapping,selectPet:e=>{ce.setActivePet(e),Yr(u,e)}}),ei(ue.askEverfur,ue.isBootstrapping,w,C);let xe=l(()=>Xl(S),[S]),Re=l(()=>Xl(w),[w]),Te=l(()=>Q!==void 0&&Re!==null?{card:Q,prompt:Re}:void 0,[Q,Re]),_e=l(()=>x===void 0?createAppStateLifecycle():x??void 0,[x]);pi(_e,{conversationId:ue.conversationId===null?null:String(ue.conversationId),isTurnInFlight:ue.isStreaming,refreshesBlankThread:T===true||_===true,refresh:ue.refreshActiveThread===void 0?void 0:()=>ue.refreshActiveThread?.(ii(_===true,oi(_e,Zo)))??Promise.resolve()},{intervalMs:R===void 0?3e4:R,isVisibleFallback:Zo}),ai({isStreaming:ue.isStreaming,status:ue.status,conversationId:ue.conversationId===null?null:String(ue.conversationId),unreadCount:ue.unreadCount,markRead:ue.markRead},()=>oi(_e,Zo));let ze=ue.pendingCheckin??null,Ie=ze===null?null:/* @__PURE__ */A(v,{testID:"everfur-pending-checkin",accessibilityLiveRegion:"polite",children:/* @__PURE__ */A(CheckinCard,{message:ze.message,checkin:ze.checkin,onAnswer:ue.petRef?ue.answerCheckin:null,petRef:ue.petRef,onFindVet:ge,vet:be,onOpen:()=>{ue.resumeConversation(ze.conversationId)}})}),Pe=(ue.hasUnreadThreads??false)||pe.rows.some(e=>e.unreadCount!==null&&e.unreadCount>0)||(ue.unreadCount??0)>0,Fe=Kl(ue.messages),[Le,Ee]=o(null),Oe=n(()=>Ee(null),[]),[Ae,je]=o(null),[De,Me]=o(null),Be=i(null);a(()=>()=>{Be.current&&clearTimeout(Be.current)},[]);let He=n((e,t)=>{Me({responseId:String(e),kind:t}),Be.current&&clearTimeout(Be.current),Be.current=t==="thanks"?setTimeout(()=>{Me(null),Be.current=null},Ns):null},[]),We=n((e,t)=>{let r=e.responseId;if(r===void 0)return;let n=ue.sentimentByMessage[String(r)];Me(e=>e?.responseId===String(r)?null:e),ue.feedback(r,t).then(e=>{e.ok||He(r,"failed")}),t==="down"&&n!=="down"&&je(r)},[ue,He]),Ue=n(async(e,t)=>Ae===null||!(e==null&&t===null?{ok:true}:await ue.feedback(Ae,"down",e??"other",t)).ok?false:(je(null),He(Ae,"thanks"),true),[ue,Ae,He]),$e=n(()=>je(null),[]),Ve=n(e=>{ue.send(e)},[ue.send]),qe=l(()=>L===void 0?void 0:e=>{Yr(L,e,"citation")},[L]),Ge=b.OS==="ios"?"padding":void 0,Ke=mg(E,Ge!==void 0),Ye=Ke.topInWindow===null?fe.top:Math.max(0,fe.top-Ke.topInWindow),Qe=wg(),Ze=l(()=>B===void 0?void 0:()=>{Yr(B,X)},[B,X]),Je=l(()=>({petRef:ue.petRef,vet:be,cover:ve}),[ue.petRef,be]),Xe=l(()=>O===void 0?healthPlanTopCard(J,{onOpenPlan:Ze}):void 0,[O,J,Ze]),et=Z.chatTopCard==="focus"?O??(Z.shellHeader==="tabs_bar"?void 0:Xe):void 0,[tt,rt]=o(true),nt=n(e=>{ue.send(e)},[ue.send]),lt=l(()=>On(Y,Z,isLocked("chatFollowUpCount")),[Y,Z,isLocked]),it=Z.chatAnswerStyle==="cards",ot=Z.shellHeader==="tabs_bar",at=l(()=>it&&ue.messages.length===0?dv(ue.suggestedPrompts,ot?4:3):void 0,[it,ue.messages.length,ue.suggestedPrompts,ot]),st=Z.chatHistoryStyle==="sheet",ut=ue.messages.length===0,dt=et!==void 0?/* @__PURE__ */A(TopCardPill,{card:et,open:tt,onOpenChange:rt}):null,ct=U??(q?void 0:cv),pt=ct!==void 0?/* @__PURE__ */A(HistoryBar,{bar:ct,history:pe,empty:ut,unread:Pe,extra:dt}):null,ft=Z.chatHistoryBar==="scroll"&&!ot&&(de==="empty"||de==="populated"),ht=et===void 0?null:/* @__PURE__ */j(D,{children:[
344
+ /* @__PURE__ */A(TopCard,{card:et,open:tt,onOpenChange:rt,ask:nt}),ct===void 0?dt:null]}),gt=ct!==void 0,bt=pe.load,yt=pe.open;a(()=>{gt&&!yt&&bt()},[gt,yt,ue.conversationId,bt]);let mt={send:ue.send,stop:ue.stop,isStreaming:ue.isStreaming,conversationId:ue.conversationId,seed:xe,draftStore:z,onStage:Fe.stage,onPreview:Ee,petName:ye?.name??null,petBreed:ye?.breed??null,compact:Z.chatComposerStyle==="compact",petPlaceholder:Z.chatComposerPlaceholder==="pet_name",dimEmptySend:Z.chatSendButton==="dim_when_empty",mood:pv(de,ke.source?.level??null),dictation:Z.chatComposerMic,telemetry:e.telemetry},vt=ev(Z.chatTextingAsk&&e.inProvider,ue,G),wt=f!==void 0&&Z.chatComposerUpload,kt=!Z.chatGeneralBanner&&ke.source?.level==="general",Ct=ot?Qg()?.ask??null:null,St=l(()=>Ct!==null?{paint:Ct.paint(ee),petRef:ue.petRef??null,vet:be,onFindVet:c,renderVetAction:p,onOpenRecord:H}:null,[Ct,ee,ue.petRef,be,c,p,H]),xt=St!==null&&St.paint.partner!==null,Rt=xt&&de!=="empty"?/* @__PURE__ */A(PrivacyLine,{}):null,Tt=xt&&de==="empty"?/* @__PURE__ */A(PrivacyLine,{empty:true}):null,_t=ft?Rt===null?pt:/* @__PURE__ */j(D,{children:[pt,Rt]}):null;
344
345
  /* @__PURE__ */
345
- return A(tf.Provider,{value:re,children:/* @__PURE__ */j(k,{style:[ee.container,{paddingTop:Ke},t],behavior:qe,...Ge.avoidingProps,children:[
346
- /* @__PURE__ */A(KeyboardOffsetProbe,{probeRef:Ge.probeRef}),
347
- /* @__PURE__ */j(SdkTabletColumn,{children:[V?/* @__PURE__ */A(ChatHeader,{pets:de,petRef:se.petRef,historyUnread:Ie,onOpenHistory:ce.show,onNewChat:ce.newConversation,onPetChange:u,onAddPet:g,vet:ge,textingEntry:yt.headerEntry}):null,h!==void 0?/* @__PURE__ */A(PetSetupNotice,{petRef:petRef??null,pet:h,onRegistered:de.refresh}):null,!V&&yt.headerEntry!==null?/* @__PURE__ */A(TextingEntryRow,{entry:yt.headerEntry,place:"thread"}):null,ct?null:dt,vt?null:/* @__PURE__ */A(UrgencyBanner,{surface:we,petRef:se.petRef,renderVetAction:p,onFindVet:c,vet:ge,compact:Ye}),
348
- /* @__PURE__ */A(v,{style:ee.body,children:/* @__PURE__ */A(Zi.Provider,{value:Ze,children:Pm(ue,se,{notice:fe,vet:ge,onCheckinFindVet:he,onSelectPrompt:$e,renderPending:r,shownPet:be,onVetPrep:d,onCopy:s,onSentiment:We,feedbackNote:je,imagesByMessage:Pe.byMessage,onPreview:Le,onAddPet:g,onOpenUrl:Ve,threadTop:ct?dt:null,pendingCheckin:ze,topCard:pt,starterPrompts:U??it,emptyState:$,emptyCentered:Q.chatAnswerStyle==="cards",followUpPolicy:nt,answerCards:Q.chatAnswerStyle==="cards"?H??Gm:null,threadAside:yt.line,threadAsideKey:yt.stage,renderEmptyHeader:G,openingCard:Re})})}),yt.runner,yt.entry!==null?/* @__PURE__ */A(v,{style:ee.composerOuter,children:/* @__PURE__ */A(v,{style:ee.askEntry,children:yt.entry})}):mt&&f!==void 0?/* @__PURE__ */A(ComposerWithAttachments,{...bt,attachments:f}):/* @__PURE__ */A(Composer,{...bt,attachments:null}),X.meta.hidePoweredBy||ne?null:/* @__PURE__ */A(Text,{tier:"compact",style:ee.poweredBy,accessibilityRole:"text",accessibilityLabel:He.poweredBy,children:He.poweredBy})]}),ot?/* @__PURE__ */A(HistorySheet,{chat:se,history:ce,sheet:W}):/* @__PURE__ */A(HistoryDrawer,{chat:se,history:ce}),
349
- /* @__PURE__ */A(FeedbackReasons,{visible:Oe!==null,onSubmit:Ne,onSkip:Ue}),
350
- /* @__PURE__ */A(AttachmentImageLightbox,{uri:Fe?.uri??null,label:Fe?.label??"",onClose:Ee}),
351
- /* @__PURE__ */A(TelevetHostOutlet,{})]})})}function PetSetupNotice({petRef:petRef,pet:e,onRegistered:t}){let{styles:r}=Eu(),n=$l(petRef,e,t);return n.status!=="failed"||n.error===null?null:/* @__PURE__ */j(v,{style:r.setupNotice,accessible:true,accessibilityRole:"alert",children:[
346
+ return A(df.Provider,{value:ne,children:/* @__PURE__ */A(Ld.Provider,{value:St,children:/* @__PURE__ */j(k,{style:[te.container,{paddingTop:Ye},t],behavior:Ge,...Ke.avoidingProps,children:[
347
+ /* @__PURE__ */A(KeyboardOffsetProbe,{probeRef:Ke.probeRef}),
348
+ /* @__PURE__ */j(SdkTabletColumn,{children:[q?/* @__PURE__ */A(ChatHeader,{pets:ce,petRef:ue.petRef,historyUnread:Pe,onOpenHistory:pe.show,onNewChat:pe.newConversation,onPetChange:u,onAddPet:g,vet:be,textingEntry:vt.headerEntry}):null,h!==void 0?/* @__PURE__ */A(PetSetupNotice,{petRef:petRef??null,pet:h,onRegistered:ce.refresh}):null,!q&&vt.headerEntry!==null?/* @__PURE__ */A(TextingEntryRow,{entry:vt.headerEntry,place:"thread"}):null,ft?null:pt,ft?null:Rt,kt||St!==null?null:/* @__PURE__ */A(UrgencyBanner,{surface:ke,petRef:ue.petRef,renderVetAction:p,onFindVet:c,vet:be,compact:Qe}),
349
+ /* @__PURE__ */A(v,{style:te.body,children:/* @__PURE__ */A(Xi.Provider,{value:Je,children:Vm(de,ue,{notice:he,vet:be,onCheckinFindVet:ge,onSelectPrompt:Ve,renderPending:r,shownPet:ye,onVetPrep:d,onCopy:s,onSentiment:We,feedbackNote:De,imagesByMessage:Fe.byMessage,onPreview:Ee,onAddPet:g,onOpenUrl:qe,threadTop:_t,pendingCheckin:Ie,topCard:ht,starterPrompts:$??at,emptyState:V,emptyCentered:Z.chatAnswerStyle==="cards",followUpPolicy:lt,answerCards:Z.chatAnswerStyle==="cards"?W??uv:null,threadAside:vt.line,threadAsideKey:vt.stage,renderEmptyHeader:K,openingCard:Te})})}),vt.runner,Tt,vt.entry!==null?/* @__PURE__ */A(v,{style:te.composerOuter,children:/* @__PURE__ */A(v,{style:te.askEntry,children:vt.entry})}):wt&&f!==void 0?/* @__PURE__ */A(ComposerWithAttachments,{...mt,attachments:f}):/* @__PURE__ */A(Composer,{...mt,attachments:null}),St!==null?/* @__PURE__ */A(AskBarDisclaimer,{}):ee.meta.hidePoweredBy||le?null:/* @__PURE__ */A(Text,{tier:"compact",style:te.poweredBy,accessibilityRole:"text",accessibilityLabel:Ne.poweredBy,children:Ne.poweredBy})]}),st?/* @__PURE__ */A(HistorySheet,{chat:ue,history:pe,sheet:N}):/* @__PURE__ */A(HistoryDrawer,{chat:ue,history:pe}),
350
+ /* @__PURE__ */A(FeedbackReasons,{visible:Ae!==null,onSubmit:Ue,onSkip:$e}),
351
+ /* @__PURE__ */A(AttachmentImageLightbox,{uri:Le?.uri??null,label:Le?.label??"",onClose:Oe}),
352
+ /* @__PURE__ */A(TelevetHostOutlet,{})]})})})}function PetSetupNotice({petRef:petRef,pet:e,onRegistered:t}){let{styles:r}=Au(),n=ql(petRef,e,t);return n.status!=="failed"||n.error===null?null:/* @__PURE__ */j(v,{style:r.setupNotice,accessible:true,accessibilityRole:"alert",children:[
352
353
  /* @__PURE__ */A(Text,{tier:"compact",style:r.setupNoticeText,children:n.error.displayMessage}),
353
- /* @__PURE__ */A(C,{onPress:n.retry,accessibilityRole:"button",accessibilityLabel:He.retry,hitSlop:iu,children:/* @__PURE__ */A(Text,{tier:"control",style:r.setupNoticeAction,children:He.retry})})]})}var Gm=/* @__PURE__ */Object.freeze({}),Km=3;function Ym(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===Km)break}return t.length>0?/* @__PURE__ */Object.freeze(t):void 0}var Qm=/* @__PURE__ */Object.freeze({chats:Fi.heading,newChat:Fi.newChat});function Zm(e,t){return t==="emergency"?"urgent":e==="populated"?"followUp":"ask"}function EverfurChat(e){/* @__PURE__ */
354
- return A(EverfurChatCore,{...e})}var Jm=/* @__PURE__ */Object.freeze({hasUnread:null,unreadCount:null,conversationId:null,petRef:null}),NO_SUBSCRIPTION=()=>()=>{};function Xm(e,t){let{runtime:r,userRef:userRef,activePet:i,scopeEpoch:o}=Ye(),u=r.unread??null,petRef=e===void 0?i:e,d=n(e=>u===null?NO_SUBSCRIPTION():u.subscribe(e),[u]),c=n(()=>u===null||userRef===null?Jm:u.get(petRef),[u,userRef,petRef]),p=s(d,c,c),f=n(()=>u===null||userRef===null?Promise.resolve():u.refresh(petRef),[u,userRef,petRef]);return a(()=>{f()},[f,o]),di(t,{conversationId:null,isTurnInFlight:false,refreshesBlankThread:true,refresh:f}),l(()=>({...p,refresh:f}),[p,f])}function useEverfurUnread(e={}){let{lifecycle:t}=e,r=l(()=>t===void 0?createAppStateLifecycle():t??void 0,[t]);return Xm(e.petRef,r)}export{EverfurChat,EverfurPoweredBy,chatHandoffTokenFromUrl,createAppStateLifecycle,createRnChatAttachmentTransport,registerEverfurChatCards,registerEverfurDictation,useChatAttachments,useEverfurChat,useEverfurPets,useEverfurUnread,useHostPoweredBy};
354
+ /* @__PURE__ */A(C,{onPress:n.retry,accessibilityRole:"button",accessibilityLabel:Ne.retry,hitSlop:au,children:/* @__PURE__ */A(Text,{tier:"control",style:r.setupNoticeAction,children:Ne.retry})})]})}var uv=/* @__PURE__ */Object.freeze({});function dv(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 cv=/* @__PURE__ */Object.freeze({chats:Ei.heading,newChat:Ei.newChat});function pv(e,t){return t==="emergency"?"urgent":e==="populated"?"followUp":"ask"}function EverfurChat(e){/* @__PURE__ */
355
+ return A(EverfurChatCore,{...e})}var fv=/* @__PURE__ */Object.freeze({hasUnread:null,unreadCount:null,conversationId:null,petRef:null}),NO_SUBSCRIPTION=()=>()=>{};function hv(e,t){let{runtime:r,userRef:userRef,activePet:i,scopeEpoch:o}=Ze(),u=r.unread??null,petRef=e===void 0?i:e,d=n(e=>u===null?NO_SUBSCRIPTION():u.subscribe(e),[u]),c=n(()=>u===null||userRef===null?fv:u.get(petRef),[u,userRef,petRef]),p=s(d,c,c),f=n(()=>u===null||userRef===null?Promise.resolve():u.refresh(petRef),[u,userRef,petRef]);return a(()=>{f()},[f,o]),pi(t,{conversationId:null,isTurnInFlight:false,refreshesBlankThread:true,refresh:f}),l(()=>({...p,refresh:f}),[p,f])}function useEverfurUnread(e={}){let{lifecycle:t}=e,r=l(()=>t===void 0?createAppStateLifecycle():t??void 0,[t]);return hv(e.petRef,r)}export{EverfurChat,EverfurPoweredBy,chatHandoffTokenFromUrl,createAppStateLifecycle,createRnChatAttachmentTransport,registerEverfurChatCards,registerEverfurDictation,useChatAttachments,useEverfurChat,useEverfurPets,useEverfurUnread,useHostPoweredBy};