@everfur/sdk 0.1.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/CHANGELOG.md +703 -4
  2. package/README.md +63 -23
  3. package/consent/package.json +8 -0
  4. package/dist/Chat-BZZ-Py5l.d.ts +128 -0
  5. package/dist/Chat-Dq4fffIO.d.cts +128 -0
  6. package/dist/DepthViews-BG3E25MD.d.ts +16 -0
  7. package/dist/DepthViews-B_hIypI6.d.cts +19 -0
  8. package/dist/DepthViews-CL75jyRA.d.cts +16 -0
  9. package/dist/DepthViews-CkYri51q.d.ts +19 -0
  10. package/dist/ErrorPolicyPort-CNf4uQZP.d.cts +22 -0
  11. package/dist/ErrorPolicyPort-CwbfmxzJ.d.ts +22 -0
  12. package/dist/{EverfurResult-D92-uL82.d.cts → EverfurResult-DN9pL2Ab.d.cts} +11 -10
  13. package/dist/{EverfurResult-D92-uL82.d.ts → EverfurResult-DN9pL2Ab.d.ts} +11 -10
  14. package/dist/{PhotoController-BItt5M7u.d.cts → PhotoController-3l7MT9jA.d.cts} +1 -1
  15. package/dist/{PhotoController-D8zMTdcW.d.ts → PhotoController-vzY5bfY_.d.ts} +1 -1
  16. package/dist/animations/index.cjs +1 -1997
  17. package/dist/animations/index.d.cts +35 -35
  18. package/dist/animations/index.d.ts +35 -35
  19. package/dist/animations/index.js +1 -1972
  20. package/dist/attachments-BorG422I.d.cts +146 -0
  21. package/dist/attachments-BrUWQYNK.d.ts +257 -0
  22. package/dist/attachments-D_SECjr1.d.cts +257 -0
  23. package/dist/attachments-DpldrvIW.d.ts +146 -0
  24. package/dist/bookingCopy-CqtDYvCR.d.ts +732 -0
  25. package/dist/bookingCopy-SREvkG19.d.cts +732 -0
  26. package/dist/branding-CsRdeNwK.d.cts +566 -0
  27. package/dist/branding-CsRdeNwK.d.ts +566 -0
  28. package/dist/callCopy-DoQKG3-L.d.cts +40 -0
  29. package/dist/callCopy-DoQKG3-L.d.ts +40 -0
  30. package/dist/casesRepository-DwtZVsbj.d.cts +51 -0
  31. package/dist/casesRepository-v6QczS9N.d.ts +51 -0
  32. package/dist/chat/index.cjs +1 -1170
  33. package/dist/chat/index.d.cts +32 -53
  34. package/dist/chat/index.d.ts +32 -53
  35. package/dist/chat/index.js +1 -1167
  36. package/dist/client/index.cjs +9 -2315
  37. package/dist/client/index.d.cts +80 -16
  38. package/dist/client/index.d.ts +80 -16
  39. package/dist/client/index.js +9 -2215
  40. package/dist/{config-CiJ0PVBB.d.ts → config--Wu1Umhd.d.cts} +64 -26
  41. package/dist/{config-BSjBdxrZ.d.cts → config-C7eb_IMD.d.ts} +64 -26
  42. package/dist/consent/index.cjs +1 -0
  43. package/dist/consent/index.d.cts +33 -0
  44. package/dist/consent/index.d.ts +33 -0
  45. package/dist/consent/index.js +1 -0
  46. package/dist/context-CL3lyuy1.d.cts +159 -0
  47. package/dist/context-CahAEha8.d.ts +159 -0
  48. package/dist/copy-DdVFDL01.d.ts +198 -0
  49. package/dist/copy-UeUJVk8X.d.cts +198 -0
  50. package/dist/core/index.cjs +13 -3178
  51. package/dist/core/index.d.cts +164 -29
  52. package/dist/core/index.d.ts +164 -29
  53. package/dist/core/index.js +13 -3166
  54. package/dist/depth-D5HwcvKC.d.cts +533 -0
  55. package/dist/depth-DvPwPuT_.d.ts +533 -0
  56. package/dist/entitlementRepository-B7egEdW6.d.ts +43 -0
  57. package/dist/entitlementRepository-BpJ7tiwl.d.cts +43 -0
  58. package/dist/{identity-Brl-lDd6.d.cts → identity-C2-08BZW.d.cts} +20 -7
  59. package/dist/{identity-DK9zORrG.d.ts → identity-CEi9GRFZ.d.ts} +20 -7
  60. package/dist/{ids-CJ1S6adf.d.cts → ids-B2GAAifq.d.cts} +1 -1
  61. package/dist/{ids-CJ1S6adf.d.ts → ids-B2GAAifq.d.ts} +1 -1
  62. package/dist/index.cjs +12 -4494
  63. package/dist/index.d.cts +30 -121
  64. package/dist/index.d.ts +30 -121
  65. package/dist/index.js +12 -4470
  66. package/dist/models-B-Uh2LTf.d.ts +214 -0
  67. package/dist/models-D2EUxPZY.d.cts +214 -0
  68. package/dist/notifications/index.cjs +2 -0
  69. package/dist/notifications/index.d.cts +17 -0
  70. package/dist/notifications/index.d.ts +17 -0
  71. package/dist/notifications/index.js +2 -0
  72. package/dist/optionalModule-DbJmsq5f.d.cts +21 -0
  73. package/dist/optionalModule-DbJmsq5f.d.ts +21 -0
  74. package/dist/pets-DJv2sj2H.d.ts +92 -0
  75. package/dist/pets-JVCXgRgR.d.cts +92 -0
  76. package/dist/petsRepository-B_gKbAzJ.d.cts +142 -0
  77. package/dist/petsRepository-Bk6GDwLs.d.ts +142 -0
  78. package/dist/photo/index.cjs +1 -2189
  79. package/dist/photo/index.d.cts +6 -6
  80. package/dist/photo/index.d.ts +6 -6
  81. package/dist/photo/index.js +1 -2186
  82. package/dist/ports-BN6RHF9W.d.cts +48 -0
  83. package/dist/ports-BN6RHF9W.d.ts +48 -0
  84. package/dist/ports-BY2ph0_y.d.cts +376 -0
  85. package/dist/ports-D7YW8qz9.d.ts +376 -0
  86. package/dist/profile-CSs1wlXT.d.cts +93 -0
  87. package/dist/profile-CSs1wlXT.d.ts +93 -0
  88. package/dist/records/depth/index.cjs +2 -0
  89. package/dist/records/depth/index.d.cts +13 -0
  90. package/dist/records/depth/index.d.ts +13 -0
  91. package/dist/records/depth/index.js +2 -0
  92. package/dist/records/index.cjs +3 -2839
  93. package/dist/records/index.d.cts +137 -203
  94. package/dist/records/index.d.ts +137 -203
  95. package/dist/records/index.js +3 -2833
  96. package/dist/requestFunnel-BjDpqqvm.d.cts +110 -0
  97. package/dist/requestFunnel-DFMGcluw.d.ts +110 -0
  98. package/dist/{resolve-Dq_4_agU.d.ts → resolve-D4Ywz5OS.d.cts} +10 -4
  99. package/dist/{resolve-Dq_4_agU.d.cts → resolve-D4Ywz5OS.d.ts} +10 -4
  100. package/dist/{runtime-Bvr8yqXm.d.cts → runtimeTypes-gZEJu-da.d.cts} +104 -132
  101. package/dist/{runtime-BIYzf9cK.d.ts → runtimeTypes-w5KqBMcs.d.ts} +104 -132
  102. package/dist/server/events/index.cjs +2 -0
  103. package/dist/server/events/index.d.cts +550 -0
  104. package/dist/server/events/index.d.ts +550 -0
  105. package/dist/server/events/index.js +2 -0
  106. package/dist/server/index.cjs +2 -533
  107. package/dist/server/index.d.cts +73 -18
  108. package/dist/server/index.d.ts +73 -18
  109. package/dist/server/index.js +2 -530
  110. package/dist/species-BXAIMh7I.d.cts +9 -0
  111. package/dist/species-BXAIMh7I.d.ts +9 -0
  112. package/dist/televet/booking/index.cjs +1 -0
  113. package/dist/televet/booking/index.d.cts +294 -0
  114. package/dist/televet/booking/index.d.ts +294 -0
  115. package/dist/televet/booking/index.js +1 -0
  116. package/dist/televet/call/index.cjs +1 -0
  117. package/dist/televet/call/index.d.cts +141 -0
  118. package/dist/televet/call/index.d.ts +141 -0
  119. package/dist/televet/call/index.js +1 -0
  120. package/dist/televet/index.cjs +1 -0
  121. package/dist/televet/index.d.cts +142 -0
  122. package/dist/televet/index.d.ts +142 -0
  123. package/dist/televet/index.js +1 -0
  124. package/dist/testing/index.cjs +5 -823
  125. package/dist/testing/index.d.cts +18 -4
  126. package/dist/testing/index.d.ts +18 -4
  127. package/dist/testing/index.js +5 -820
  128. package/dist/testing/rn/index.cjs +1 -449
  129. package/dist/testing/rn/index.d.cts +18 -29
  130. package/dist/testing/rn/index.d.ts +18 -29
  131. package/dist/testing/rn/index.js +1 -444
  132. package/dist/testing/web/index.cjs +1 -0
  133. package/dist/testing/web/index.d.cts +132 -0
  134. package/dist/testing/web/index.d.ts +132 -0
  135. package/dist/testing/web/index.js +1 -0
  136. package/dist/timelineRows-C15jxFFH.d.ts +19 -0
  137. package/dist/timelineRows-odO8g9r2.d.cts +19 -0
  138. package/dist/typeStyle-CKqVYD6L.d.cts +111 -0
  139. package/dist/typeStyle-DmoyacDG.d.ts +111 -0
  140. package/dist/uploadTransport-D0M0T4hN.d.ts +38 -0
  141. package/dist/uploadTransport-DKJHs3Yj.d.cts +38 -0
  142. package/dist/useRecordsDepth-C6rjEaLn.d.cts +237 -0
  143. package/dist/useRecordsDepth-crhBllQK.d.ts +237 -0
  144. package/dist/useVetVisit-Bc84hWUU.d.cts +187 -0
  145. package/dist/useVetVisit-CjmMa896.d.ts +187 -0
  146. package/dist/video/index.cjs +1 -1941
  147. package/dist/video/index.d.cts +4 -4
  148. package/dist/video/index.d.ts +4 -4
  149. package/dist/video/index.js +1 -1938
  150. package/dist/view-Bxwxp4xD.d.ts +310 -0
  151. package/dist/view-DyitEO0m.d.cts +310 -0
  152. package/dist/visitIntent-D7_yVp1I.d.cts +8 -0
  153. package/dist/visitIntent-D7_yVp1I.d.ts +8 -0
  154. package/dist/web/consent/index.cjs +1 -0
  155. package/dist/web/consent/index.d.cts +34 -0
  156. package/dist/web/consent/index.d.ts +34 -0
  157. package/dist/web/consent/index.js +1 -0
  158. package/dist/web/index.cjs +14 -0
  159. package/dist/web/index.d.cts +218 -0
  160. package/dist/web/index.d.ts +218 -0
  161. package/dist/web/index.js +14 -0
  162. package/dist/web/notifications/index.cjs +2 -0
  163. package/dist/web/notifications/index.d.cts +213 -0
  164. package/dist/web/notifications/index.d.ts +213 -0
  165. package/dist/web/notifications/index.js +2 -0
  166. package/dist/web/records/depth/index.cjs +2 -0
  167. package/dist/web/records/depth/index.d.cts +12 -0
  168. package/dist/web/records/depth/index.d.ts +12 -0
  169. package/dist/web/records/depth/index.js +2 -0
  170. package/dist/web/records/index.cjs +4 -0
  171. package/dist/web/records/index.d.cts +285 -0
  172. package/dist/web/records/index.d.ts +285 -0
  173. package/dist/web/records/index.js +4 -0
  174. package/dist/web/televet/booking/index.cjs +1 -0
  175. package/dist/web/televet/booking/index.d.cts +349 -0
  176. package/dist/web/televet/booking/index.d.ts +349 -0
  177. package/dist/web/televet/booking/index.js +1 -0
  178. package/dist/web/televet/call/index.cjs +1 -0
  179. package/dist/web/televet/call/index.d.cts +142 -0
  180. package/dist/web/televet/call/index.d.ts +142 -0
  181. package/dist/web/televet/call/index.js +1 -0
  182. package/dist/web/televet/index.cjs +1 -0
  183. package/dist/web/televet/index.d.cts +136 -0
  184. package/dist/web/televet/index.d.ts +136 -0
  185. package/dist/web/televet/index.js +1 -0
  186. package/notifications/package.json +8 -0
  187. package/package.json +266 -10
  188. package/records/depth/package.json +8 -0
  189. package/server/events/device-blocked.cjs +15 -0
  190. package/server/events/package.json +9 -0
  191. package/televet/booking/package.json +8 -0
  192. package/televet/call/package.json +8 -0
  193. package/televet/package.json +8 -0
  194. package/testing/web/native-blocked.cjs +12 -0
  195. package/testing/web/package.json +8 -0
  196. package/web/consent/native-blocked.cjs +12 -0
  197. package/web/consent/package.json +8 -0
  198. package/web/native-blocked.cjs +12 -0
  199. package/web/notifications/native-blocked.cjs +12 -0
  200. package/web/notifications/package.json +8 -0
  201. package/web/package.json +8 -0
  202. package/web/records/depth/native-blocked.cjs +12 -0
  203. package/web/records/depth/package.json +8 -0
  204. package/web/records/native-blocked.cjs +12 -0
  205. package/web/records/package.json +8 -0
  206. package/web/televet/booking/native-blocked.cjs +12 -0
  207. package/web/televet/booking/package.json +8 -0
  208. package/web/televet/call/native-blocked.cjs +12 -0
  209. package/web/televet/call/package.json +8 -0
  210. package/web/televet/native-blocked.cjs +12 -0
  211. package/web/televet/package.json +8 -0
  212. package/dist/ChatController-CKdBvPj2.d.ts +0 -146
  213. package/dist/ChatController-CpUMvvZf.d.cts +0 -146
  214. package/dist/FilePort-BabWrv7I.d.cts +0 -22
  215. package/dist/FilePort-BabWrv7I.d.ts +0 -22
  216. package/dist/petsRepository-BEGb97M9.d.cts +0 -326
  217. package/dist/petsRepository-Bu18r2kK.d.ts +0 -326
  218. package/dist/requestFunnel-DuUH-kAe.d.cts +0 -28
  219. package/dist/requestFunnel-dio5OmR9.d.ts +0 -28
@@ -0,0 +1,142 @@
1
+ import { P as PetRef } from '../ids-B2GAAifq.cjs';
2
+ export { B as Brand, _ as __brand } from '../ids-B2GAAifq.cjs';
3
+ import { U as UseVetVisitOptions, a as UseVetVisitState, V as VetVisitEntry, b as VetVisitErrorReason, c as VetVisitController } from '../useVetVisit-Bc84hWUU.cjs';
4
+ export { d as VetVisitAvailability, e as VetVisitHandoff, f as VetVisitHandoffOptions, g as VetVisitHandoffVisit, h as VetVisitOpenResult, i as VetVisitReturn, j as VetVisitStatus, p as parseVetVisitReturn, v as vetVisitErrorReasonOf } from '../useVetVisit-Bc84hWUU.cjs';
5
+ import { ReactNode } from 'react';
6
+ import { StyleProp, ViewStyle, TextStyle } from 'react-native';
7
+ import { E as EverfurError } from '../EverfurResult-DN9pL2Ab.cjs';
8
+ export { a as EverfurErrorCategory, b as EverfurErrorCode, c as EverfurResult } from '../EverfurResult-DN9pL2Ab.cjs';
9
+ import { V as VetVisitIntent } from '../visitIntent-D7_yVp1I.cjs';
10
+ export { a as VET_VISIT_INTENTS, i as isVetVisitIntent } from '../visitIntent-D7_yVp1I.cjs';
11
+
12
+ /**
13
+ * What the button hands the host when it opens the in-app visit.
14
+ *
15
+ * Deliberately the scoping the BUTTON was given and nothing more. The host already holds the session, the
16
+ * theme and the navigator; what it cannot know is which pet and which state this particular button was
17
+ * placed for, so that, and only that, travels.
18
+ */
19
+ interface EverfurTelevetFlowRequest {
20
+ /** The pet this button was scoped to, when it was scoped to one. */
21
+ readonly petRef?: PetRef | null | undefined;
22
+ /** The member's US state, when the host gave one. The booking screens preflight availability with it. */
23
+ readonly usState?: string | null | undefined;
24
+ }
25
+ /**
26
+ * The host's presenter: show the Everfur booking flow. Called on press, and expected to navigate or present.
27
+ *
28
+ * It returns nothing. The button is not waiting on it and has nothing to do with the result: presenting a
29
+ * screen is the host's business, and a presenter that throws is contained (see `presentEverfurTelevetFlow`)
30
+ * rather than allowed to break the press.
31
+ */
32
+ type EverfurTelevetFlowPresenter = (request: EverfurTelevetFlowRequest) => void;
33
+ /**
34
+ * Register how this app presents the in-app vet visit. Call it ONCE, in your app entry:
35
+ *
36
+ * ```ts
37
+ * import { registerEverfurTelevetFlow } from '@everfur/sdk/televet';
38
+ * registerEverfurTelevetFlow(() => navigationRef.navigate('EverfurBooking'));
39
+ * ```
40
+ *
41
+ * From that line on, every `VetVisitButton` in the app opens your screen instead of the system browser, with
42
+ * no other change at any call site. Passing `null` unregisters it, which is what a test does between cases
43
+ * and what a partner does to go back to the hosted visit everywhere at once.
44
+ */
45
+ declare function registerEverfurTelevetFlow(next: EverfurTelevetFlowPresenter | null): void;
46
+ /** Is an in-app flow registered? The button asks this to choose its destination before it mints anything. */
47
+ declare function hasEverfurTelevetFlow(): boolean;
48
+ /**
49
+ * Present the registered flow. Answers whether the visit was HANDED OVER, which is what lets the caller fall
50
+ * through to the hosted handoff rather than leave the member on a screen that never opened.
51
+ *
52
+ * A THROWING PRESENTER IS NOT A DEAD BUTTON. A host navigator can throw (an unmounted ref, a route that was
53
+ * renamed), and the member pressing the button has no idea any of that happened. So a throw is caught and
54
+ * reported as "not handed over", and the caller then mints and opens the hosted visit: the member reaches a
55
+ * vet either way, which is the floor this whole file is built around. The throw is not swallowed silently -
56
+ * it is re-surfaced to the partner's engineer through the console, because a navigator that throws on every
57
+ * press is a defect in their app that they need to see.
58
+ */
59
+ declare function presentEverfurTelevetFlow(request: EverfurTelevetFlowRequest): boolean;
60
+
61
+ interface UseNativeVetVisitOptions extends UseVetVisitOptions {
62
+ /**
63
+ * Opens the minted visit URL. Defaults to `Linking.openURL`. Receives a single-use URL: open it once, now,
64
+ * and never log, store or share it.
65
+ */
66
+ readonly openUrl?: ((url: string) => Promise<unknown>) | undefined;
67
+ }
68
+ /**
69
+ * The vet visit hook for a React Native app. `available` is false (render nothing) unless Everfur grants vet
70
+ * visits to this signed-in user. Requires a signed session: pass `user` with a `getToken` backed by your
71
+ * server's session mint.
72
+ */
73
+ declare function useVetVisit(opts?: UseNativeVetVisitOptions): UseVetVisitState;
74
+
75
+ interface VetVisitButtonProps {
76
+ /** The partner's pet reference to scope the visit to. Optional. */
77
+ readonly petRef?: PetRef | null | undefined;
78
+ /** The button label. Defaults to Everfur's label. */
79
+ readonly label?: string | undefined;
80
+ /**
81
+ * Opens the minted URL when the press REDIRECTS. Defaults to `Linking.openURL` (the system browser).
82
+ *
83
+ * This is the redirect path's opener, not the button's destination. Which destination a press takes is
84
+ * `prefer` plus what the app registered; see the note on `prefer`.
85
+ */
86
+ readonly openUrl?: ((url: string) => Promise<unknown>) | undefined;
87
+ /** Called after the URL was handed to the browser, with the return flow id when `returnTo` was given. */
88
+ readonly onOpened?: ((flowId: string | null) => void) | undefined;
89
+ /** The KEY of a return destination your tenant registered with Everfur; `onOpened` then receives the flow id. */
90
+ readonly returnTo?: string | null | undefined;
91
+ /** The user's US state. When set, the button renders only once Everfur confirms a visit is available there. */
92
+ readonly usState?: string | null | undefined;
93
+ /** `'chat'` for the entry inside Chat: renders only while Everfur has it switched on, and needs `petRef`. */
94
+ readonly entry?: VetVisitEntry | null | undefined;
95
+ /**
96
+ * TV-01. A visit this member already has. The button then OPENS that visit rather than starting a booking:
97
+ * put the `visitRef` a tapped push carries here. Without it the button books, exactly as before.
98
+ */
99
+ readonly visitRef?: string | null | undefined;
100
+ /** What to open for `visitRef`: `visit` (the default), `join`, `summary` or `messages`. */
101
+ readonly intent?: VetVisitIntent | null | undefined;
102
+ /** Called when the visit could not be opened. `error` is null for a device-side failure. */
103
+ readonly onError?: ((reason: VetVisitErrorReason, error: EverfurError | null) => void) | undefined;
104
+ /**
105
+ * Open the IN-APP booking flow (`EverfurTelevet`) instead of handing off to the hosted visit.
106
+ *
107
+ * ADDITIVE, AND THE DEFAULT IS UNCHANGED. A 0.3.0 integration that does not pass this keeps the handoff it
108
+ * already ships, byte for byte: nothing about an existing button moves. The flow is a component the host
109
+ * mounts, and the SDK owns no navigator, so the host is the only thing that can say where it lives - which
110
+ * is why this is a callback and not a `mode` flag the button could not honour.
111
+ *
112
+ * `visitRef` still wins over it: a tapped push that names an existing visit opens THAT visit, and there is
113
+ * no in-app surface for one yet. Sending an owner into a fresh booking funnel because they tapped a reminder
114
+ * for the visit they already have is the wrong screen, loudly.
115
+ */
116
+ readonly onStartInApp?: (() => void) | undefined;
117
+ /**
118
+ * Which destination a press takes. Defaults to `'in-app'`.
119
+ *
120
+ * THE DEFAULT CHANGED IN 0.4.0, AND ONLY FOR AN APP THAT REGISTERED A FLOW. `'in-app'` opens the flow this
121
+ * app registered with `registerEverfurTelevetFlow`; with nothing registered there is no flow to open, so
122
+ * the press mints and opens the hosted visit exactly as 0.3.0 did. That is the floor: an app that upgrades
123
+ * and changes nothing keeps a working button, and the member always reaches a vet.
124
+ *
125
+ * `'redirect'` is the explicit opt-in back to the browser handoff. It ignores the registry entirely, which
126
+ * is what a partner wants for a surface they deliberately keep hosted.
127
+ *
128
+ * `visitRef` still wins over both: a tapped push that names an existing visit opens THAT visit, and there
129
+ * is no in-app surface for one yet.
130
+ */
131
+ readonly prefer?: 'in-app' | 'redirect' | undefined;
132
+ /** Merged over the button's own style. */
133
+ readonly style?: StyleProp<ViewStyle>;
134
+ /** Merged over the label's own style. */
135
+ readonly labelStyle?: StyleProp<TextStyle>;
136
+ /** Host/test seam: inject a controller instead of building one from the provider's session. */
137
+ readonly controller?: VetVisitController | undefined;
138
+ }
139
+ /** Opens the Everfur vet visit, in-app by default. Renders nothing unless vet visits are granted. */
140
+ declare function VetVisitButton(props: VetVisitButtonProps): ReactNode;
141
+
142
+ export { EverfurError, type EverfurTelevetFlowPresenter, type EverfurTelevetFlowRequest, PetRef, type UseNativeVetVisitOptions, UseVetVisitOptions, UseVetVisitState, VetVisitButton, type VetVisitButtonProps, VetVisitController, VetVisitEntry, VetVisitErrorReason, VetVisitIntent, hasEverfurTelevetFlow, presentEverfurTelevetFlow, registerEverfurTelevetFlow, useVetVisit };
@@ -0,0 +1,142 @@
1
+ import { P as PetRef } from '../ids-B2GAAifq.js';
2
+ export { B as Brand, _ as __brand } from '../ids-B2GAAifq.js';
3
+ import { U as UseVetVisitOptions, a as UseVetVisitState, V as VetVisitEntry, b as VetVisitErrorReason, c as VetVisitController } from '../useVetVisit-CjmMa896.js';
4
+ export { d as VetVisitAvailability, e as VetVisitHandoff, f as VetVisitHandoffOptions, g as VetVisitHandoffVisit, h as VetVisitOpenResult, i as VetVisitReturn, j as VetVisitStatus, p as parseVetVisitReturn, v as vetVisitErrorReasonOf } from '../useVetVisit-CjmMa896.js';
5
+ import { ReactNode } from 'react';
6
+ import { StyleProp, ViewStyle, TextStyle } from 'react-native';
7
+ import { E as EverfurError } from '../EverfurResult-DN9pL2Ab.js';
8
+ export { a as EverfurErrorCategory, b as EverfurErrorCode, c as EverfurResult } from '../EverfurResult-DN9pL2Ab.js';
9
+ import { V as VetVisitIntent } from '../visitIntent-D7_yVp1I.js';
10
+ export { a as VET_VISIT_INTENTS, i as isVetVisitIntent } from '../visitIntent-D7_yVp1I.js';
11
+
12
+ /**
13
+ * What the button hands the host when it opens the in-app visit.
14
+ *
15
+ * Deliberately the scoping the BUTTON was given and nothing more. The host already holds the session, the
16
+ * theme and the navigator; what it cannot know is which pet and which state this particular button was
17
+ * placed for, so that, and only that, travels.
18
+ */
19
+ interface EverfurTelevetFlowRequest {
20
+ /** The pet this button was scoped to, when it was scoped to one. */
21
+ readonly petRef?: PetRef | null | undefined;
22
+ /** The member's US state, when the host gave one. The booking screens preflight availability with it. */
23
+ readonly usState?: string | null | undefined;
24
+ }
25
+ /**
26
+ * The host's presenter: show the Everfur booking flow. Called on press, and expected to navigate or present.
27
+ *
28
+ * It returns nothing. The button is not waiting on it and has nothing to do with the result: presenting a
29
+ * screen is the host's business, and a presenter that throws is contained (see `presentEverfurTelevetFlow`)
30
+ * rather than allowed to break the press.
31
+ */
32
+ type EverfurTelevetFlowPresenter = (request: EverfurTelevetFlowRequest) => void;
33
+ /**
34
+ * Register how this app presents the in-app vet visit. Call it ONCE, in your app entry:
35
+ *
36
+ * ```ts
37
+ * import { registerEverfurTelevetFlow } from '@everfur/sdk/televet';
38
+ * registerEverfurTelevetFlow(() => navigationRef.navigate('EverfurBooking'));
39
+ * ```
40
+ *
41
+ * From that line on, every `VetVisitButton` in the app opens your screen instead of the system browser, with
42
+ * no other change at any call site. Passing `null` unregisters it, which is what a test does between cases
43
+ * and what a partner does to go back to the hosted visit everywhere at once.
44
+ */
45
+ declare function registerEverfurTelevetFlow(next: EverfurTelevetFlowPresenter | null): void;
46
+ /** Is an in-app flow registered? The button asks this to choose its destination before it mints anything. */
47
+ declare function hasEverfurTelevetFlow(): boolean;
48
+ /**
49
+ * Present the registered flow. Answers whether the visit was HANDED OVER, which is what lets the caller fall
50
+ * through to the hosted handoff rather than leave the member on a screen that never opened.
51
+ *
52
+ * A THROWING PRESENTER IS NOT A DEAD BUTTON. A host navigator can throw (an unmounted ref, a route that was
53
+ * renamed), and the member pressing the button has no idea any of that happened. So a throw is caught and
54
+ * reported as "not handed over", and the caller then mints and opens the hosted visit: the member reaches a
55
+ * vet either way, which is the floor this whole file is built around. The throw is not swallowed silently -
56
+ * it is re-surfaced to the partner's engineer through the console, because a navigator that throws on every
57
+ * press is a defect in their app that they need to see.
58
+ */
59
+ declare function presentEverfurTelevetFlow(request: EverfurTelevetFlowRequest): boolean;
60
+
61
+ interface UseNativeVetVisitOptions extends UseVetVisitOptions {
62
+ /**
63
+ * Opens the minted visit URL. Defaults to `Linking.openURL`. Receives a single-use URL: open it once, now,
64
+ * and never log, store or share it.
65
+ */
66
+ readonly openUrl?: ((url: string) => Promise<unknown>) | undefined;
67
+ }
68
+ /**
69
+ * The vet visit hook for a React Native app. `available` is false (render nothing) unless Everfur grants vet
70
+ * visits to this signed-in user. Requires a signed session: pass `user` with a `getToken` backed by your
71
+ * server's session mint.
72
+ */
73
+ declare function useVetVisit(opts?: UseNativeVetVisitOptions): UseVetVisitState;
74
+
75
+ interface VetVisitButtonProps {
76
+ /** The partner's pet reference to scope the visit to. Optional. */
77
+ readonly petRef?: PetRef | null | undefined;
78
+ /** The button label. Defaults to Everfur's label. */
79
+ readonly label?: string | undefined;
80
+ /**
81
+ * Opens the minted URL when the press REDIRECTS. Defaults to `Linking.openURL` (the system browser).
82
+ *
83
+ * This is the redirect path's opener, not the button's destination. Which destination a press takes is
84
+ * `prefer` plus what the app registered; see the note on `prefer`.
85
+ */
86
+ readonly openUrl?: ((url: string) => Promise<unknown>) | undefined;
87
+ /** Called after the URL was handed to the browser, with the return flow id when `returnTo` was given. */
88
+ readonly onOpened?: ((flowId: string | null) => void) | undefined;
89
+ /** The KEY of a return destination your tenant registered with Everfur; `onOpened` then receives the flow id. */
90
+ readonly returnTo?: string | null | undefined;
91
+ /** The user's US state. When set, the button renders only once Everfur confirms a visit is available there. */
92
+ readonly usState?: string | null | undefined;
93
+ /** `'chat'` for the entry inside Chat: renders only while Everfur has it switched on, and needs `petRef`. */
94
+ readonly entry?: VetVisitEntry | null | undefined;
95
+ /**
96
+ * TV-01. A visit this member already has. The button then OPENS that visit rather than starting a booking:
97
+ * put the `visitRef` a tapped push carries here. Without it the button books, exactly as before.
98
+ */
99
+ readonly visitRef?: string | null | undefined;
100
+ /** What to open for `visitRef`: `visit` (the default), `join`, `summary` or `messages`. */
101
+ readonly intent?: VetVisitIntent | null | undefined;
102
+ /** Called when the visit could not be opened. `error` is null for a device-side failure. */
103
+ readonly onError?: ((reason: VetVisitErrorReason, error: EverfurError | null) => void) | undefined;
104
+ /**
105
+ * Open the IN-APP booking flow (`EverfurTelevet`) instead of handing off to the hosted visit.
106
+ *
107
+ * ADDITIVE, AND THE DEFAULT IS UNCHANGED. A 0.3.0 integration that does not pass this keeps the handoff it
108
+ * already ships, byte for byte: nothing about an existing button moves. The flow is a component the host
109
+ * mounts, and the SDK owns no navigator, so the host is the only thing that can say where it lives - which
110
+ * is why this is a callback and not a `mode` flag the button could not honour.
111
+ *
112
+ * `visitRef` still wins over it: a tapped push that names an existing visit opens THAT visit, and there is
113
+ * no in-app surface for one yet. Sending an owner into a fresh booking funnel because they tapped a reminder
114
+ * for the visit they already have is the wrong screen, loudly.
115
+ */
116
+ readonly onStartInApp?: (() => void) | undefined;
117
+ /**
118
+ * Which destination a press takes. Defaults to `'in-app'`.
119
+ *
120
+ * THE DEFAULT CHANGED IN 0.4.0, AND ONLY FOR AN APP THAT REGISTERED A FLOW. `'in-app'` opens the flow this
121
+ * app registered with `registerEverfurTelevetFlow`; with nothing registered there is no flow to open, so
122
+ * the press mints and opens the hosted visit exactly as 0.3.0 did. That is the floor: an app that upgrades
123
+ * and changes nothing keeps a working button, and the member always reaches a vet.
124
+ *
125
+ * `'redirect'` is the explicit opt-in back to the browser handoff. It ignores the registry entirely, which
126
+ * is what a partner wants for a surface they deliberately keep hosted.
127
+ *
128
+ * `visitRef` still wins over both: a tapped push that names an existing visit opens THAT visit, and there
129
+ * is no in-app surface for one yet.
130
+ */
131
+ readonly prefer?: 'in-app' | 'redirect' | undefined;
132
+ /** Merged over the button's own style. */
133
+ readonly style?: StyleProp<ViewStyle>;
134
+ /** Merged over the label's own style. */
135
+ readonly labelStyle?: StyleProp<TextStyle>;
136
+ /** Host/test seam: inject a controller instead of building one from the provider's session. */
137
+ readonly controller?: VetVisitController | undefined;
138
+ }
139
+ /** Opens the Everfur vet visit, in-app by default. Renders nothing unless vet visits are granted. */
140
+ declare function VetVisitButton(props: VetVisitButtonProps): ReactNode;
141
+
142
+ export { EverfurError, type EverfurTelevetFlowPresenter, type EverfurTelevetFlowRequest, PetRef, type UseNativeVetVisitOptions, UseVetVisitOptions, UseVetVisitState, VetVisitButton, type VetVisitButtonProps, VetVisitController, VetVisitEntry, VetVisitErrorReason, VetVisitIntent, hasEverfurTelevetFlow, presentEverfurTelevetFlow, registerEverfurTelevetFlow, useVetVisit };
@@ -0,0 +1 @@
1
+ import {createContext,forwardRef,useMemo,createElement,useRef,useContext,useSyncExternalStore,useState,useEffect,useCallback}from'react';import {Linking,TextInput,Pressable,StyleSheet,Text}from'react-native';import {jsx}from'react/jsx-runtime';var pr=Object.defineProperty;var n=(e,r)=>pr(e,"name",{value:r,configurable:true});var Q=null;function yr(e){Q=e;}n(yr,"registerEverfurTelevetFlow");function X(){return Q!==null}n(X,"hasEverfurTelevetFlow");function Z(e){let r=Q;if(r===null)return false;try{return r(e),!0}catch(t){return console.warn("[everfur] The in-app vet visit presenter registered with registerEverfurTelevetFlow threw, so this press fell back to the hosted visit in the browser. The member reached a vet, but your navigation did not run - check the destination you registered.",t),false}}n(Z,"presentEverfurTelevetFlow");var J=Object.freeze([Object.freeze({wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false}),Object.freeze({wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true}),Object.freeze({wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true}),Object.freeze({wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true}),Object.freeze({wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false}),Object.freeze({wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false}),Object.freeze({wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false}),Object.freeze({wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false}),Object.freeze({wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false}),Object.freeze({wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true}),Object.freeze({wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false}),Object.freeze({wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false}),Object.freeze({wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false}),Object.freeze({wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false}),Object.freeze({wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false}),Object.freeze({wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false}),Object.freeze({wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false}),Object.freeze({wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true}),Object.freeze({wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true}),Object.freeze({wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true}),Object.freeze({wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false}),Object.freeze({wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false})]);Object.freeze(J.map(e=>e.wireCode));var mr=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",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",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"}),Ee=Object.freeze(J.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:mr[e.wireCode]}))),vr=new Map(Ee.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),br=Object.freeze(["http_envelope",...[...new Set(Ee.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function L(e,r){if(typeof e!="string")return;let t=e.trim().toUpperCase();if(t.length!==0)for(let o of [r??"http_envelope",...br]){let i=vr.get(o+t);if(i)return i}}n(L,"contractErrorFor");function Er(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}n(Er,"contractDocUrl");function ge(e){return null}n(ge,"publishedDocUrl");var gr=Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"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 he(e){return gr[e]}n(he,"categoryFor");function _e(e){let r=L(e);if(r)return r.normalized;let t=(e??"").trim().toUpperCase(),o=t.replace(/[^A-Z0-9]/g,"");if(o==="AUTHREJECTED")return "authRejected";if(t.startsWith("AUTH"))return "authExpired";switch(o){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":return "rateLimited";case "IDEMPOTENCYKEYCONFLICT":case "IDEMPOTENCYCONFLICT":return "idempotencyConflict";case "ACCESSDENIED":case "FORBIDDEN":return "accessDenied";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"}}n(_e,"fromWire");var hr=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function ee(e){return hr.has(e)}n(ee,"isAutoRetryable");var _r=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function Re(e){return ee(e)||_r.has(e)}n(Re,"isRetryableCode");var Rr=500,re=8e3,Te=4;function Ce(e,r=Math.random){let t=Math.max(0,e),o=Math.min(Rr*2**t,re);return Math.floor(r()*o)}n(Ce,"backoffDelayMs");var Tr=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:"This feature isn't available on your account right now.",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:"Something in that request was not right. Check the details and try again.",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.",unknown:"Something went wrong. Please try again."});function te(e){return Tr[e]}n(te,"userFacingError");function we(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:false,writable:false,configurable:false});}n(we,"defineHidden");var Cr=/^[a-z][a-z0-9_]{0,63}$/;function F(e,r){let t=L(r?.wireCode,r?.wireEnvelope),o={code:e,category:he(e),retryable:r?.retryable??Re(e),displayMessage:te(e)};if(r?.httpStatus!==void 0&&(o.httpStatus=r.httpStatus),r?.requestId&&(o.requestId=r.requestId),typeof r?.reasonCode=="string"&&Cr.test(r.reasonCode)&&(o.reasonCode=r.reasonCode),t);return r?.wireMessage&&we(o,"wireMessage",r.wireMessage),r?.raw!==void 0&&r.raw!==null&&we(o,"raw",r.raw),Object.freeze(o)}n(F,"makeEverfurError");function ne(e,r){return Object.freeze(r===void 0?{ok:true,value:e}:{ok:true,value:e,warning:r})}n(ne,"ok");function h(e){return Object.freeze({ok:false,error:e})}n(h,"err");var U=class U extends Error{constructor(r,t){super(t),this.name="EverfurConfigError",this.kind=r,Object.setPrototypeOf(this,U.prototype);}};n(U,"EverfurConfigError");var z=U;function xe(e){return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:e.serverRequestId??null})}n(xe,"errorFrame");function Sr(e){let r={};return e.mode==="personalized"?r.authorization=`Bearer ${e.token}`:r["x-everfur-partner-key"]=e.publishableKey,e.userRef&&(r["x-everfur-user-ref"]=e.userRef),e.sessionId&&(r["x-everfur-session-id"]=e.sessionId),r}n(Sr,"authHeaders");function j(e,r){return {...e,headers:{...kr(e.headers),...Sr(r)}}}n(j,"withAuthHeaders");function kr(e){if(!e)return {};let r={};for(let[t,o]of Object.entries(e)){let i=t.toLowerCase();i==="authorization"||i==="x-everfur-partner-key"||(r[t]=o);}return r}n(kr,"stripAuthHeaders");async function Se(e,r){if(r.mode==="anonymous")return r.transport.request(j(e,{mode:"anonymous",publishableKey:r.publishableKey,userRef:r.userRef,...r.sessionId?{sessionId:r.sessionId}:{}}));let t;try{t=await r.identity.currentToken();}catch{return h(oe())}let o=await r.transport.request(j(e,{mode:"personalized",token:t,userRef:r.userRef,...r.sessionId?{sessionId:r.sessionId}:{}}));if(o.ok||o.error.httpStatus!==401)return o;let i;try{i=await r.identity.currentToken({forceRefresh:!0});}catch{return h(oe())}let a=await r.transport.request(j(e,{mode:"personalized",token:i,userRef:r.userRef,...r.sessionId?{sessionId:r.sessionId}:{}}));return !a.ok&&a.error.httpStatus===401?h(oe(a.error.httpStatus)):a}n(Se,"authedSend");function oe(e){return F("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}n(oe,"authRejectedError");function ke(e){return F("internalError",{retryable:true,wireMessage:Fr(e)})}n(ke,"networkError");function Fr(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}n(Fr,"describeCause");var Or=3e4,Vr=re*2,Ir="idempotency-key",Ar=new Set(["POST","PUT","PATCH","DELETE"]),Pr=Object.freeze({onEvent(){}}),zr=Object.freeze({setTimeout:n((e,r)=>setTimeout(e,r),"setTimeout"),clearTimeout:n(e=>clearTimeout(e),"clearTimeout"),now:n(()=>Date.now(),"now")});function jr(e){let r=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return r.length===0?null:`efs_${r}`.slice(0,128)}n(jr,"seededIdempotencyKey");function Oe(e){let r=e.observer??Pr,t=e.timers??zr,o=e.rng??Math.random,i=e.sleep??((d,f)=>$r(d,t,f)),a=e.maxAttempts??Te,l=e.unaryTimeoutMs??Or,u=e.newIdempotencyKey??Nr(),s=n(d=>{try{r.onEvent(d);}catch{}},"emit");async function p(d,f,y){let _=y?.maxAttempts,c=Math.max(1,_??a),O=y?.idempotent??Ar.has(f.method),C=y?.idempotencyKey===void 0?null:jr(y.idempotencyKey),w=O?C??u():null,S=Dr(f,w),k=0;for(;;){let R=n(A=>Object.freeze({call:d,method:f.method,path:f.path,attempt:k,...w?{idempotencyKey:w}:{},...A}),"stamp");s(R({phase:"attempt"}));let V=Kr(l,t),I=Gr(V.signal,f.signal),m;try{m=await Se({...S,signal:I.signal},e.auth);}catch(A){m=h(ke(A));}finally{I.dispose(),V.cancel();}if(m.ok)return s(R({phase:"settled",ok:true,reason:"ok"})),m;let v=m.error,b=Ur(v,k,{maxAttempts:c,rng:o,now:t.now(),aborted:f.signal?.aborted===true,..._!==void 0?{perCallMaxAttempts:_}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),x={ok:false,code:v.code,reason:b.reason,...v.httpStatus!==void 0?{httpStatus:v.httpStatus}:{},...v.requestId!==void 0?{requestId:v.requestId}:{}};if(!b.retry)return s(R({phase:"settled",...x})),h(v);if(s(R({phase:"retry",...x,delayMs:b.delayMs})),await i(b.delayMs,f.signal),f.signal?.aborted===true)return s(R({phase:"settled",...x,reason:"aborted"})),h(v);k+=1;}}n(p,"send");async function E(d){return j(d,await Wr(e.auth))}n(E,"authorize");async function*g(d,f,y){s(Object.freeze({call:d,phase:"stream.open",method:f.method,path:f.path,attempt:0}));try{yield*e.auth.transport.stream(f,y);}catch{yield xe({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return n(g,"stream"),Object.freeze({send:p,authorize:E,stream:g})}n(Oe,"createRequestFunnel");function Dr(e,r){let t={};for(let[o,i]of Object.entries(e.headers??{}))o.toLowerCase()!==Ir&&(t[o]=i);return r!==null&&(t["Idempotency-Key"]=r),{...e,headers:t}}n(Dr,"assembleHeaders");function Nr(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}n(Nr,"defaultIdempotencyKeyFactory");var Lr=10;function Ur(e,r,t){if(t.aborted)return {retry:false,reason:"aborted"};let o=Mr(e);if(o==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(o!=="burst"&&!ee(e.code))return {retry:false,reason:"terminal-code"};let i=o==="burst"?"burst-throttle":"retryable-code";if(n(()=>{if(t.policy===void 0)return false;try{return !t.policy.shouldRetry(e.code,r)}catch{return false}},"policyVetoedRetry")())return {retry:false,reason:"terminal-code"};let l=n(()=>{if(t.policy===void 0)return null;let p;try{p=t.policy.maxAttempts(e.code);}catch{return null}return typeof p!="number"||!Number.isFinite(p)?null:Math.max(1,Math.min(Lr,Math.floor(p)))},"policyCeiling"),u=t.perCallMaxAttempts??l()??t.maxAttempts;if(r+1>=u)return {retry:false,reason:"attempts-exhausted"};let s=Br(e,t.now);return s!==null?s>Vr?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:i,delayMs:s}:{retry:true,reason:i,delayMs:Ce(r,t.rng)}}n(Ur,"decideRetry");function Mr(e){let r=e.code==="unknown"?_e(Yr(e.raw)):e.code;return r==="quotaExceeded"?"quota":r==="rateLimited"||e.httpStatus===429?"burst":null}n(Mr,"throttleKind");function Br(e,r){let t=qr(e.raw);if(t===null)return null;let o=t-r;return o>0?o:0}n(Br,"retryOverrideMs");function qr(e){for(let r of Ve(e)){let t=r.resets_at,o=Hr(t);if(o!==null)return o}return null}n(qr,"findResetsAt");function Ve(e){if(!Fe(e))return [];let r=[e];for(let t of ["error","detail"]){let o=e[t];Fe(o)&&r.push(o);}return r}n(Ve,"candidateScopes");function Hr(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 r=Date.parse(e);return Number.isFinite(r)?r:null}return null}n(Hr,"parseInstantMs");function Yr(e){for(let r of Ve(e)){let t=r.code;if(typeof t=="string"&&t.length>0)return t}return null}n(Yr,"rawWireCode");function Fe(e){return typeof e=="object"&&e!==null}n(Fe,"isRecord");async function Wr(e){return e.mode==="anonymous"?{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}:{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}n(Wr,"resolveDeviceAuth");function Kr(e,r){let t=new AbortController,o=r.setTimeout(()=>t.abort(),e);return {signal:t.signal,cancel:n(()=>r.clearTimeout(o),"cancel")}}n(Kr,"boundedSignal");function Gr(e,r){let t=n(()=>{},"noop");if(!r)return {signal:e,dispose:t};let o=new AbortController;if(e.aborted||r.aborted)return o.abort(),{signal:o.signal,dispose:t};let i=n(()=>o.abort(),"onAbort");return e.addEventListener("abort",i,{once:true}),r.addEventListener("abort",i,{once:true}),{signal:o.signal,dispose:n(()=>{e.removeEventListener("abort",i),r.removeEventListener("abort",i);},"dispose")}}n(Gr,"mergeSignals");function $r(e,r,t){return e<=0||t?.aborted===true?Promise.resolve():new Promise(o=>{let i=r.setTimeout(()=>{t?.removeEventListener("abort",a),o();},e),a=n(()=>{r.clearTimeout(i),o();},"onAbort");t?.addEventListener("abort",a,{once:true});})}n($r,"delayAbortable");var M=Object.freeze(["visit","join","summary","messages"]);function B(e){return typeof e=="string"&&M.includes(e)}n(B,"isVetVisitIntent");var Qr="/widget/v1/televet/handoffs",Xr="/widget/v1/televet/availability",Zr="/widget/v1/televet/chat-entry",Jr=/^[a-z0-9][a-z0-9_-]{0,39}$/,Ne=/^[A-Za-z0-9_-]{22}$/,Ie="everfur_flow",Ae=32,Pe=128,ze=64;function q(e){let r=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 r===void 0?e.code==="internalError"?"network":"unknown":r===429?"rateLimited":r===404?"unavailable":r===403?"accessDenied":r===401?"authRejected":r===400||r===422?"invalidRequest":r>=500?"serverError":"unknown"}n(q,"vetVisitErrorReasonOf");function je(e){return h(F("validationFailed",{retryable:false,wireMessage:e}))}n(je,"invalid");function ie(e){return h(F("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}n(ie,"unusable");function et(e,r){let t={};e!==void 0&&(t.pet_ref=e);let o=r?.returnTo;if(o!=null){if(typeof o!="string"||!Jr.test(o))return {ok:false,message:"returnTo must be a registered return destination key"};t.return_to=o;}let i=r?.entry;if(i!=null){if(i!=="chat"||e===void 0)return {ok:false,message:"entry 'chat' needs the pet the chat is about"};t.entry=i;}let a=r?.visitRef,l=r?.intent,u=a!=null;if(u){let s=typeof a=="string"?a.trim():"";if(s.length<1||[...s].length>ze)return {ok:false,message:`visitRef must be 1..${ze} characters`};t.visit_ref=s;}if(l!=null){if(!u)return {ok:false,message:"intent needs the visitRef it opens"};if(!B(l))return {ok:false,message:`intent must be one of ${M.join(", ")}`};t.intent=l;}return {ok:true,body:t}}n(et,"handoffBody");function rt(e){if(typeof e!="object"||e===null)return null;let{visit_ref:r,intent:t}=e;return typeof r!="string"||r.length===0||!B(t)?null:Object.freeze({visitRef:r,intent:t})}n(rt,"parseVisitEcho");function Le(e){let r=e.funnel??Oe({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),t=e.telemetry,o=n(i=>(De(t,"televet.visit.handoff_failed",{reason:q(i)}),h(i)),"failed");return {async createHandoff(i,a){let l;if(i!=null){let c=typeof i=="string"?[...i].length:0;if(c<1||c>Pe)return o(F("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${Pe} characters`}));l=i;}let u=et(l,a);if(!u.ok){let c=je(u.message);return c.ok?c:o(c.error)}let s=u.body,p=await r.send("televet.visit.handoff",{method:"POST",path:Qr,body:s},{idempotent:false,maxAttempts:1});if(!p.ok)return o(p.error);let E=nt(p.value),g=s.return_to!==void 0,d=g?p.value?.flow_id:void 0;if(g&&(typeof d!="string"||!Ne.test(d))){let c=ie("the handoff response carried no usable return flow id");return c.ok?c:o(c.error)}let f=s.visit_ref!==void 0,y=f?rt(p.value?.visit):null;if(f&&y===null){let c=ie("the handoff response did not confirm the visit it opens");return c.ok?c:o(c.error)}let _=E===null?null:Object.freeze({...E,...g?{flowId:d}:{},...y!==null?{visit:y}:{}});return _===null?o(F("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(De(t,"televet.visit.handoff_created",{pet_scoped:s.pet_ref!==void 0}),ne(_))},async checkAvailability(i){if(typeof i!="string"||i.length>Ae)return je(`state must be at most ${Ae} characters`);let a=await r.send("televet.visit.availability",{method:"POST",path:Xr,body:{state:i}},{idempotent:false,maxAttempts:1});if(!a.ok)return h(a.error);let l=a.value?.available;return typeof l!="boolean"?ie("the availability response carried no usable answer"):ne(Object.freeze({available:l}))},async chatEntryOpen(){try{let i=await r.send("televet.visit.chat_entry",{method:"GET",path:Zr},{maxAttempts:1});return i.ok&&i.value?.open===!0}catch{return false}}}}n(Le,"createVetVisitController");function tt(e){if(typeof e!="string")return null;let r=e.indexOf("#"),t=r<0?e:e.slice(0,r),o=t.indexOf("?");if(o<0)return null;let i=t.slice(o+1).split("&").filter(a=>a.startsWith(`${Ie}=`)).map(a=>a.slice(Ie.length+1));return i.length!==1||!Ne.test(i[0]??"")?null:Object.freeze({flowId:i[0]})}n(tt,"parseVetVisitReturn");function nt(e){if(typeof e!="object"||e===null)return null;let{url:r,expires_at:t}=e;return typeof r!="string"||typeof t!="string"||t.length===0||!st(r)?null:Object.freeze({url:r,expiresAt:t})}n(nt,"parseHandoff");var ot=new Set(["localhost","127.0.0.1","[::1]"]),it=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,at=/[\s\u0000-\u001f\u007f]/;function st(e){if(at.test(e))return false;let r=it.exec(e);if(r===null)return false;let t=(r[1]??"").toLowerCase(),o=r[2]??"";if(o.length===0||o.includes("@"))return false;let i=o.replace(/:\d+$/,"").toLowerCase(),a=t==="https",l=t==="http"&&ot.has(i);if(!a&&!l)return false;let u=e.indexOf("#");if(u<0)return false;let s=e.slice(u);return s.startsWith("#h=")&&s.length>3}n(st,"isOpenableVisitUrl");function De(e,r,t){if(e)try{e.track(r,t);}catch{}}n(De,"safeTrack");var Ue=Symbol.for("@everfur/sdk#EverfurContext@v1"),Me=globalThis,Be=Me[Ue]??(Me[Ue]=createContext(null));Be.displayName??="EverfurContext";function H(){let e=useContext(Be);if(e===null)throw new z("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}n(H,"useEverfurContext");var dt=Object.freeze({chat:Object.freeze(["chat.message.create"]),records:Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:Object.freeze(["records.clinic.create"]),video:Object.freeze(["video.gait.execute"]),photo:Object.freeze(["photo.checkup.execute"]),animations:Object.freeze(["animations.state.read"]),televet:Object.freeze(["televet.visit.create"])});function ct(e){return dt[e]}n(ct,"requires");function qe(e,r,t){let o=ct(e),i=new Map;for(let u of r)i.set(u.resource,u);if(t?.isPending===true&&o.some(u=>!i.has(u)))return ae({name:e,enabled:false,isPending:true,limits:{}});let a=ft(o,i);return o.filter(u=>i.get(u)?.granted!==true).length===0?ae({name:e,enabled:true,isPending:false,limits:a}):ae({name:e,enabled:false,isPending:false,limits:a,disabled:pt(o,i)})}n(qe,"decideCapability");function ft(e,r){let t={};for(let o of e){let i=r.get(o)?.limits;if(i)for(let[a,l]of Object.entries(i)){let u=t[a];t[a]=u===void 0?l:Math.min(u,l);}}return t}n(ft,"mergeLimits");function pt(e,r){for(let t of e){let o=r.get(t)?.disabled;if(o)return Object.freeze({reason:o.reason,level:o.level,recoverable:o.recoverable})}return Object.freeze({reason:te("accessDenied"),level:"user_entitlement",recoverable:false})}n(pt,"disabledFor");function ae(e){let r={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:Object.freeze({...e.limits})};return e.disabled!==void 0&&(r.disabled=e.disabled),Object.freeze(r)}n(ae,"freezeDecision");function He(e){let{runtime:r}=H(),t=r.entitlements,o=useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot);return useMemo(()=>qe(e,o.decisions,{isPending:o.isPending}),[e,o])}n(He,"useCapability");var We=Object.freeze({status:"idle",error:null,errorReason:null});function bt(e,r,t){let{usState:o,chat:i,scope:a}=t,l=r&&(o!==null||i),u=`${o??""}|${i?"chat":""}`,[s,p]=useState(null);if(useEffect(()=>{if(!l)return;let g=true,d=e.current;return p(null),n(async()=>{try{if(i&&!(d.chatEntryOpen&&await d.chatEntryOpen()))return !1;if(o===null)return !0;if(!d.checkAvailability)return !1;let y=await d.checkAvailability(o);return y.ok&&y.value.available}catch{return false}},"ask")().then(y=>{g&&p({key:u,open:y});}),()=>{g=false;}},[l,u,o,i,a,e]),!l)return null;let E=s!==null&&s.key===u;return {open:E&&s.open,pending:!E}}n(bt,"usePreflight");var Et=Object.freeze({status:"opening",error:null,errorReason:null});function Ge(e,r={}){let{runtime:t,userRef:o,scopeEpoch:i}=H(),a=He("televet"),l=a.enabled&&o!==null,u=r.usState??null,s=r.entry==="chat",p=r.petRef??null,E=useMemo(()=>{if(r.controller)return r.controller;let{services:m}=t.registry;return Le({auth:m.authFor(o),telemetry:m.telemetry,...m.errorPolicy?{errorPolicy:m.errorPolicy}:{}})},[t,o,i,r.controller]),g=useRef(E);g.current=E;let d=useMemo(()=>({runtime:t,userRef:o,scopeEpoch:i}),[t,o,i]),f=bt(g,l,{usState:u,chat:s,scope:d}),y=l&&(f===null||f.open)&&(!s||p!==null),_=r.returnTo??null,[c,O]=useState(We),C=useRef(null),w=useRef({runtime:t,userRef:o,scopeEpoch:i});w.current={runtime:t,userRef:o,scopeEpoch:i};let S=useRef(E);S.current=E;let k=useRef(y);k.current=y;let R=useCallback((m,v)=>{if(C.current)return C.current;let b=n((T,P)=>(O({status:T==="cancelled"?"idle":"error",error:P,errorReason:T==="cancelled"?null:T}),Object.freeze({opened:false,reason:T,error:P})),"fail");if(!k.current)return Promise.resolve(b("unavailable",null));let x=e.prepare();if(!x.ok)return Promise.resolve(b(x.reason,null));let A=w.current,pe=S.current;O(Et);let G=(async()=>{let T,P={..._!==null?{returnTo:_}:{},...s?{entry:"chat"}:{},...v!==null?{visitRef:v.visitRef}:{},...v!==null&&v.intent!==null&&v.intent!==void 0?{intent:v.intent}:{}},ye=Object.keys(P).length===0?void 0:P,me=m===void 0?p:m;try{T=await(ye===void 0?pe.createHandoff(me):pe.createHandoff(me,ye));}catch{return e.abandon(x.value),b("unknown",null)}let $=w.current;if($.runtime!==A.runtime||$.userRef!==A.userRef||$.scopeEpoch!==A.scopeEpoch)return e.abandon(x.value),b("cancelled",null);if(!T.ok)return e.abandon(x.value),b(q(T.error),T.error);let ve=await e.finish(x.value,T.value);return ve!==null?b(ve,null):(O(We),Object.freeze(T.value.flowId===void 0?{opened:true}:{opened:true,flowId:T.value.flowId}))})().finally(()=>{C.current===G&&(C.current=null);});return C.current=G,G},[e,p,_,s]),V=useCallback(m=>R(m,null),[R]),I=useCallback((m,v)=>R(void 0,{visitRef:m,intent:v??null}),[R]);return {available:y,isPending:a.isPending||(f?.pending??false),status:c.status,error:c.error,errorReason:c.errorReason,open:V,openVisit:I}}n(Ge,"useVetVisitWith");var _t=n(e=>Linking.openURL(e),"defaultOpenUrl");function le(e={}){let{openUrl:r,...t}=e,o=useMemo(()=>{let i=r??_t;return {prepare:n(()=>({ok:true,value:null}),"prepare"),async finish(a,l){try{return await i(l.url),null}catch{return "openFailed"}},abandon:n(()=>{},"abandon")}},[r]);return Ge(o,t)}n(le,"useVetVisit");function ce(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let r of Object.keys(e))ce(e[r]);}return e}n(ce,"deepFreeze");var Rt=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),Qe={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},Xe={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},$e={nano:8,small:9,micro:10,tiny:11,caption:12,bodyTight:13,body:14,subtitle:16,heading:18,verdict:24},Tt={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Ct={regular:"400",medium:"500",bold:"700"},wt={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},xt=0,Y="System",W="monospace",St=["content","heading","control","compact","badge"];function kt(e){let r={};for(let t of St)r[t]=e;return r}n(kt,"authoredTierSizes");function Ze(){return {family:Y,mono:W,fontUrl:null,families:{regular:Y,medium:Y,bold:Y,mono:W,monoMedium:W,monoBold:W},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:$e,tierSizes:kt($e),lineHeight:Tt,weight:Ct,letterSpacing:wt,scale:1,maxScale:xt,scaleCaps:Rt}}n(Ze,"baseType");var Je={},ue=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function de(e){return `cubic-bezier(${e.join(", ")})`}n(de,"cssCubicBezier");var er={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:de(ue.standard),emphasized:de(ue.emphasized),exit:de(ue.exit)},reducedMotion:false},Ft={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:"#FDFBF8",surfaceSubtle:"#EFE9E3",background:"#FFFFFF",borderRingCream:"#D8D2C8",chatGround:"#FFFFFF",composerFill:"#FDFBF8",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#111111",secondary:"#0E462E",muted:"#6E6660",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:"#B91C1C",errorRed:"#FF1B00",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(185,28,28,0.12)",badgeBgNeutral:"rgba(110,102,96,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",skeleton:"#EFE9E3",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},rr=ce({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Ft,space:Qe,radius:Xe,type:Ze(),motion:er,slots:Je}),Ot={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:"#9A938C",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",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",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"};ce({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Ot,space:Qe,radius:Xe,type:Ze(),motion:er,slots:Je});var tr=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),nr=globalThis,fe=nr[tr]??(nr[tr]=createContext(rr));fe.displayName??="EverfurThemeContext";function N(){return useContext(fe)}n(N,"useEverfurTheme");function jt(e,r){let t=e.scaleCaps[r];return t>0?t:void 0}n(jt,"tierMultiplier");function ir({tier:e="content",...r}){let{type:t}=N(),o=jt(t,e);return createElement(Text,o===void 0?r:{maxFontSizeMultiplier:o,...r})}n(ir,"Text");forwardRef(n(function(r,t){return createElement(TextInput,{...r,...t===null?{}:{ref:t}})},"TextInput"));function ar(e,r){if(e===void 0)return {};let t={};return e.backgroundColor!==void 0&&(t.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(t.borderColor=e.borderColor,t.borderWidth=r??1),e.borderRadius!==void 0&&(t.borderRadius=e.borderRadius),t}n(ar,"slotBox");function sr(e){return e?.textColor===void 0?{}:{color:e.textColor}}n(sr,"slotText");var Dt=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function lr(e,r){let t=e.type,o=t.families[r];return r==="mono"||t.namedFaces[r]?{fontFamily:o}:{fontFamily:o,fontWeight:t.weight[Dt[r]]}}n(lr,"face");function ur(e){let r=globalThis.console;try{r?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}n(ur,"reportHostFailure");function Nt(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}n(Nt,"isThenable");function K(e,...r){if(typeof e=="function")try{let t=e(...r);return Nt(t)&&Promise.resolve(t).then(void 0,ur),t}catch(t){ur(t);return}}n(K,"callHost");var dr=Object.freeze({visitButton:"Talk to a vet"});var cr=44,qt=.6;function Ht(e){let{petRef:r,label:t,openUrl:o,onOpened:i,onError:a,style:l,labelStyle:u,controller:s,returnTo:p,usState:E,entry:g,visitRef:d,intent:f,onStartInApp:y,prefer:_}=e,c=le({...p!==void 0?{returnTo:p}:{},...E!==void 0?{usState:E}:{},...g!==void 0?{entry:g}:{},...r!==void 0?{petRef:r}:{},...o!==void 0?{openUrl:o}:{},...s!==void 0?{controller:s}:{}}),O=N(),C=useMemo(()=>Yt(O),[O]),w=useRef(false);if(!c.available)return null;let S=c.status==="opening",k=t??dr.visitButton,R=d!=null,V=_==="redirect"||R,I=!V&&y!==void 0,m=!V&&!I&&X();return jsx(Pressable,{onPress:n(()=>{if(!(S||w.current)){if(I){K(y);return}m&&Z({...r!==void 0?{petRef:r}:{},...E!==void 0?{usState:E}:{}})||(w.current=true,(d==null?c.open():c.openVisit(d,f??null)).then(b=>{b.opened?K(i,b.flowId??null):b.reason!=="cancelled"&&K(a,b.reason,b.error);}).finally(()=>{w.current=false;}));}},"onPress"),accessibilityRole:"button",accessibilityLabel:k,accessibilityState:{busy:S,disabled:S},style:[C.button,S?C.busy:null,l],children:jsx(ir,{style:[C.label,u],children:k})})}n(Ht,"VetVisitButton");function Yt(e){let{color:r,space:t,radius:o,type:i,slots:a}=e;return StyleSheet.create({button:{minHeight:cr,minWidth:cr,alignItems:"center",justifyContent:"center",paddingHorizontal:t.xl,paddingVertical:t.sm,borderRadius:o.pill,backgroundColor:r.primary,...ar(a.vetVisitButton)},busy:{opacity:qt},label:{...lr(e,"medium"),color:r.onPrimary,fontSize:i.size.body,lineHeight:i.size.body*i.lineHeight.snug,...sr(a.vetVisitButton)}})}n(Yt,"makeStyles");export{M as VET_VISIT_INTENTS,Ht as VetVisitButton,X as hasEverfurTelevetFlow,B as isVetVisitIntent,tt as parseVetVisitReturn,Z as presentEverfurTelevetFlow,yr as registerEverfurTelevetFlow,le as useVetVisit,q as vetVisitErrorReasonOf};