@everfur/sdk 0.1.1 → 0.3.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.
- package/CHANGELOG.md +634 -0
- package/README.md +58 -23
- package/consent/package.json +8 -0
- package/dist/Chat-DPUD6dnc.d.cts +128 -0
- package/dist/Chat-DwAC2vhB.d.ts +128 -0
- package/dist/DepthViews-DNEM96Se.d.ts +16 -0
- package/dist/DepthViews-DP0R-DhB.d.cts +19 -0
- package/dist/DepthViews-D_3hl4xk.d.ts +19 -0
- package/dist/DepthViews-DbFhR4Du.d.cts +16 -0
- package/dist/ErrorPolicyPort-CNf4uQZP.d.cts +22 -0
- package/dist/ErrorPolicyPort-CwbfmxzJ.d.ts +22 -0
- package/dist/{EverfurResult-D92-uL82.d.cts → EverfurResult-DN9pL2Ab.d.cts} +11 -10
- package/dist/{EverfurResult-D92-uL82.d.ts → EverfurResult-DN9pL2Ab.d.ts} +11 -10
- package/dist/{PhotoController-BItt5M7u.d.cts → PhotoController-3l7MT9jA.d.cts} +1 -1
- package/dist/{PhotoController-D8zMTdcW.d.ts → PhotoController-vzY5bfY_.d.ts} +1 -1
- package/dist/animations/index.cjs +1 -1997
- package/dist/animations/index.d.cts +35 -35
- package/dist/animations/index.d.ts +35 -35
- package/dist/animations/index.js +1 -1972
- package/dist/attachments-5NeobOCd.d.ts +256 -0
- package/dist/attachments-Bw3iMQgu.d.ts +146 -0
- package/dist/attachments-CQgFrEQ7.d.cts +146 -0
- package/dist/attachments-D8T5re7e.d.cts +256 -0
- package/dist/casesRepository-ClLv6qMl.d.ts +188 -0
- package/dist/casesRepository-DHwtGRYY.d.cts +188 -0
- package/dist/chat/index.cjs +1 -1170
- package/dist/chat/index.d.cts +31 -53
- package/dist/chat/index.d.ts +31 -53
- package/dist/chat/index.js +1 -1167
- package/dist/client/index.cjs +9 -2315
- package/dist/client/index.d.cts +77 -15
- package/dist/client/index.d.ts +77 -15
- package/dist/client/index.js +9 -2215
- package/dist/{config-CiJ0PVBB.d.ts → config-CzTZGlfF.d.cts} +63 -25
- package/dist/{config-BSjBdxrZ.d.cts → config-DW60uRb9.d.ts} +63 -25
- package/dist/consent/index.cjs +1 -0
- package/dist/consent/index.d.cts +33 -0
- package/dist/consent/index.d.ts +33 -0
- package/dist/consent/index.js +1 -0
- package/dist/context-DXhqHlPU.d.ts +159 -0
- package/dist/context-XvTzq1tE.d.cts +159 -0
- package/dist/copy-Mjoo91aS.d.ts +198 -0
- package/dist/copy-bKDNigLb.d.cts +198 -0
- package/dist/core/index.cjs +13 -3178
- package/dist/core/index.d.cts +58 -12
- package/dist/core/index.d.ts +58 -12
- package/dist/core/index.js +13 -3166
- package/dist/depth-CErXCU8J.d.cts +502 -0
- package/dist/depth-DjDcJ6kH.d.ts +502 -0
- package/dist/entitlementRepository-DKdXFgTo.d.cts +698 -0
- package/dist/entitlementRepository-DSbzuyAW.d.ts +698 -0
- package/dist/{identity-DK9zORrG.d.ts → identity-BMx2SUOM.d.ts} +19 -6
- package/dist/{identity-Brl-lDd6.d.cts → identity-DI4eVx9S.d.cts} +19 -6
- package/dist/{ids-CJ1S6adf.d.cts → ids-B2GAAifq.d.cts} +1 -1
- package/dist/{ids-CJ1S6adf.d.ts → ids-B2GAAifq.d.ts} +1 -1
- package/dist/index.cjs +12 -4494
- package/dist/index.d.cts +29 -121
- package/dist/index.d.ts +29 -121
- package/dist/index.js +12 -4470
- package/dist/models-B-Uh2LTf.d.ts +214 -0
- package/dist/models-D2EUxPZY.d.cts +214 -0
- package/dist/notifications/index.cjs +2 -0
- package/dist/notifications/index.d.cts +17 -0
- package/dist/notifications/index.d.ts +17 -0
- package/dist/notifications/index.js +2 -0
- package/dist/pets-CtQdRpWo.d.ts +92 -0
- package/dist/pets-aB8q0JyX.d.cts +92 -0
- package/dist/photo/index.cjs +1 -2189
- package/dist/photo/index.d.cts +6 -6
- package/dist/photo/index.d.ts +6 -6
- package/dist/photo/index.js +1 -2186
- package/dist/ports-BN6RHF9W.d.cts +48 -0
- package/dist/ports-BN6RHF9W.d.ts +48 -0
- package/dist/ports-DEBzEhbp.d.cts +386 -0
- package/dist/ports-DMolTRzU.d.ts +386 -0
- package/dist/profile-CSs1wlXT.d.cts +93 -0
- package/dist/profile-CSs1wlXT.d.ts +93 -0
- package/dist/records/depth/index.cjs +2 -0
- package/dist/records/depth/index.d.cts +13 -0
- package/dist/records/depth/index.d.ts +13 -0
- package/dist/records/depth/index.js +2 -0
- package/dist/records/index.cjs +3 -2839
- package/dist/records/index.d.cts +137 -203
- package/dist/records/index.d.ts +137 -203
- package/dist/records/index.js +3 -2833
- package/dist/requestFunnel-CjW7uDuA.d.ts +87 -0
- package/dist/requestFunnel-L-BQfi0z.d.cts +87 -0
- package/dist/{resolve-Dq_4_agU.d.ts → resolve-D4Ywz5OS.d.cts} +10 -4
- package/dist/{resolve-Dq_4_agU.d.cts → resolve-D4Ywz5OS.d.ts} +10 -4
- package/dist/{runtime-Bvr8yqXm.d.cts → runtime-B8s-_hv8.d.cts} +121 -59
- package/dist/{runtime-BIYzf9cK.d.ts → runtime-BR9ysG0J.d.ts} +121 -59
- package/dist/server/events/index.cjs +2 -0
- package/dist/server/events/index.d.cts +550 -0
- package/dist/server/events/index.d.ts +550 -0
- package/dist/server/events/index.js +2 -0
- package/dist/server/index.cjs +2 -533
- package/dist/server/index.d.cts +73 -18
- package/dist/server/index.d.ts +73 -18
- package/dist/server/index.js +2 -530
- package/dist/species-BXAIMh7I.d.cts +9 -0
- package/dist/species-BXAIMh7I.d.ts +9 -0
- package/dist/televet/index.cjs +1 -0
- package/dist/televet/index.d.cts +60 -0
- package/dist/televet/index.d.ts +60 -0
- package/dist/televet/index.js +1 -0
- package/dist/testing/index.cjs +5 -823
- package/dist/testing/index.d.cts +17 -3
- package/dist/testing/index.d.ts +17 -3
- package/dist/testing/index.js +5 -820
- package/dist/testing/rn/index.cjs +1 -449
- package/dist/testing/rn/index.d.cts +17 -29
- package/dist/testing/rn/index.d.ts +17 -29
- package/dist/testing/rn/index.js +1 -444
- package/dist/testing/web/index.cjs +1 -0
- package/dist/testing/web/index.d.cts +131 -0
- package/dist/testing/web/index.d.ts +131 -0
- package/dist/testing/web/index.js +1 -0
- package/dist/timelineRows-CaohZzXS.d.cts +19 -0
- package/dist/timelineRows-DZed6dAM.d.ts +19 -0
- package/dist/typeStyle-0TydiZ1w.d.cts +19 -0
- package/dist/typeStyle-CWMsoe6b.d.ts +19 -0
- package/dist/uploadTransport-D0M0T4hN.d.ts +38 -0
- package/dist/uploadTransport-DKJHs3Yj.d.cts +38 -0
- package/dist/useRecordsDepth-BHBzJ76R.d.cts +237 -0
- package/dist/useRecordsDepth-BU-OhzH6.d.ts +237 -0
- package/dist/useVetVisit-Bc84hWUU.d.cts +187 -0
- package/dist/useVetVisit-CjmMa896.d.ts +187 -0
- package/dist/video/index.cjs +1 -1941
- package/dist/video/index.d.cts +4 -4
- package/dist/video/index.d.ts +4 -4
- package/dist/video/index.js +1 -1938
- package/dist/view-C3qPIXGX.d.cts +310 -0
- package/dist/view-DtSPYpKa.d.ts +310 -0
- package/dist/visitIntent-D7_yVp1I.d.cts +8 -0
- package/dist/visitIntent-D7_yVp1I.d.ts +8 -0
- package/dist/web/consent/index.cjs +1 -0
- package/dist/web/consent/index.d.cts +34 -0
- package/dist/web/consent/index.d.ts +34 -0
- package/dist/web/consent/index.js +1 -0
- package/dist/web/index.cjs +14 -0
- package/dist/web/index.d.cts +217 -0
- package/dist/web/index.d.ts +217 -0
- package/dist/web/index.js +14 -0
- package/dist/web/notifications/index.cjs +2 -0
- package/dist/web/notifications/index.d.cts +213 -0
- package/dist/web/notifications/index.d.ts +213 -0
- package/dist/web/notifications/index.js +2 -0
- package/dist/web/records/depth/index.cjs +2 -0
- package/dist/web/records/depth/index.d.cts +12 -0
- package/dist/web/records/depth/index.d.ts +12 -0
- package/dist/web/records/depth/index.js +2 -0
- package/dist/web/records/index.cjs +4 -0
- package/dist/web/records/index.d.cts +194 -0
- package/dist/web/records/index.d.ts +194 -0
- package/dist/web/records/index.js +4 -0
- package/dist/web/televet/index.cjs +1 -0
- package/dist/web/televet/index.d.cts +50 -0
- package/dist/web/televet/index.d.ts +50 -0
- package/dist/web/televet/index.js +1 -0
- package/notifications/package.json +8 -0
- package/package.json +197 -9
- package/records/depth/package.json +8 -0
- package/server/events/device-blocked.cjs +15 -0
- package/server/events/package.json +9 -0
- package/televet/package.json +8 -0
- package/testing/web/native-blocked.cjs +12 -0
- package/testing/web/package.json +8 -0
- package/web/consent/native-blocked.cjs +12 -0
- package/web/consent/package.json +8 -0
- package/web/native-blocked.cjs +12 -0
- package/web/notifications/native-blocked.cjs +12 -0
- package/web/notifications/package.json +8 -0
- package/web/package.json +8 -0
- package/web/records/depth/native-blocked.cjs +12 -0
- package/web/records/depth/package.json +8 -0
- package/web/records/native-blocked.cjs +12 -0
- package/web/records/package.json +8 -0
- package/web/televet/native-blocked.cjs +12 -0
- package/web/televet/package.json +8 -0
- package/dist/ChatController-CKdBvPj2.d.ts +0 -146
- package/dist/ChatController-CpUMvvZf.d.cts +0 -146
- package/dist/FilePort-BabWrv7I.d.cts +0 -22
- package/dist/FilePort-BabWrv7I.d.ts +0 -22
- package/dist/petsRepository-BEGb97M9.d.cts +0 -326
- package/dist/petsRepository-Bu18r2kK.d.ts +0 -326
- package/dist/requestFunnel-DuUH-kAe.d.cts +0 -28
- package/dist/requestFunnel-dio5OmR9.d.ts +0 -28
package/dist/chat/index.cjs
CHANGED
|
@@ -1,1170 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
var reactNativeSafeAreaContext = require('react-native-safe-area-context');
|
|
5
|
-
var reactNative = require('react-native');
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
|
|
8
|
-
// src/rn/chat/useChat.ts
|
|
9
|
-
var CONTRACT_RETRYABILITY = Object.freeze([
|
|
10
|
-
Object.freeze({ wireCode: "AccessDeniedException", envelope: "http_envelope", httpStatus: 403, retryable: false }),
|
|
11
|
-
Object.freeze({ wireCode: "AuthorizationException", envelope: "http_envelope", httpStatus: 401, retryable: false }),
|
|
12
|
-
Object.freeze({ wireCode: "ConflictException", envelope: "http_envelope", httpStatus: 409, retryable: true }),
|
|
13
|
-
Object.freeze({ wireCode: "DAILY_QUOTA_EXCEEDED", envelope: "http_envelope", httpStatus: 429, retryable: true }),
|
|
14
|
-
Object.freeze({ wireCode: "IDEMPOTENCY_KEY_IN_FLIGHT", envelope: "http_envelope", httpStatus: 409, retryable: true }),
|
|
15
|
-
Object.freeze({ wireCode: "IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST", envelope: "http_envelope", httpStatus: 409, retryable: false }),
|
|
16
|
-
Object.freeze({ wireCode: "InternalFailureException", envelope: "http_envelope", httpStatus: 500, retryable: true }),
|
|
17
|
-
Object.freeze({ wireCode: "NotImplementedException", envelope: "http_envelope", httpStatus: 501, retryable: false }),
|
|
18
|
-
Object.freeze({ wireCode: "PaymentRequiredException", envelope: "http_envelope", httpStatus: 402, retryable: false }),
|
|
19
|
-
Object.freeze({ wireCode: "ResourceNotFoundException", envelope: "http_envelope", httpStatus: 404, retryable: false }),
|
|
20
|
-
Object.freeze({ wireCode: "ServiceUnavailableException", envelope: "http_envelope", httpStatus: 503, retryable: true }),
|
|
21
|
-
Object.freeze({ wireCode: "TIER_UPGRADE_REQUIRED", envelope: "http_envelope", httpStatus: 402, retryable: false }),
|
|
22
|
-
Object.freeze({ wireCode: "ThrottlingException", envelope: "http_envelope", httpStatus: 429, retryable: true }),
|
|
23
|
-
Object.freeze({ wireCode: "ValidationException", envelope: "http_envelope", httpStatus: 400, retryable: false }),
|
|
24
|
-
Object.freeze({ wireCode: "accessDenied", envelope: "http_envelope", httpStatus: 403, retryable: false }),
|
|
25
|
-
Object.freeze({ wireCode: "authExpired", envelope: "http_envelope", httpStatus: 401, retryable: true }),
|
|
26
|
-
Object.freeze({ wireCode: "internal_error", envelope: "sse_frame", httpStatus: 200, retryable: false }),
|
|
27
|
-
Object.freeze({ wireCode: "invalidRequest", envelope: "http_envelope", httpStatus: 400, retryable: false }),
|
|
28
|
-
Object.freeze({ wireCode: "not_found", envelope: "sse_frame", httpStatus: 200, retryable: false }),
|
|
29
|
-
Object.freeze({ wireCode: "session_required", envelope: "http_envelope", httpStatus: 403, retryable: false }),
|
|
30
|
-
Object.freeze({ wireCode: "timeout", envelope: "sse_frame", httpStatus: 200, retryable: true }),
|
|
31
|
-
Object.freeze({ wireCode: "unavailable", envelope: "http_envelope", httpStatus: 503, retryable: true })
|
|
32
|
-
]);
|
|
33
|
-
Object.freeze(
|
|
34
|
-
CONTRACT_RETRYABILITY.map((row) => row.wireCode)
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
// src/client/errors/contract.ts
|
|
38
|
-
var NORMALIZED_FOLD = Object.freeze({
|
|
39
|
-
// the default status-mapped envelope
|
|
40
|
-
ValidationException: "validationFailed",
|
|
41
|
-
AuthorizationException: "authRejected",
|
|
42
|
-
PaymentRequiredException: "paymentRequired",
|
|
43
|
-
AccessDeniedException: "accessDenied",
|
|
44
|
-
ResourceNotFoundException: "resourceNotFound",
|
|
45
|
-
ConflictException: "conflict",
|
|
46
|
-
ThrottlingException: "rateLimited",
|
|
47
|
-
InternalFailureException: "internalError",
|
|
48
|
-
NotImplementedException: "notImplemented",
|
|
49
|
-
ServiceUnavailableException: "serviceUnavailable",
|
|
50
|
-
// dict-detail codes on the widget surface
|
|
51
|
-
authExpired: "authExpired",
|
|
52
|
-
unavailable: "serviceUnavailable",
|
|
53
|
-
session_required: "sessionRequired",
|
|
54
|
-
accessDenied: "accessDenied",
|
|
55
|
-
invalidRequest: "sdkUpdateRequired",
|
|
56
|
-
// typed codes
|
|
57
|
-
IDEMPOTENCY_KEY_IN_FLIGHT: "idempotencyInFlight",
|
|
58
|
-
IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST: "idempotencyConflict",
|
|
59
|
-
DAILY_QUOTA_EXCEEDED: "quotaExceeded",
|
|
60
|
-
TIER_UPGRADE_REQUIRED: "paymentRequired",
|
|
61
|
-
// SSE error frames
|
|
62
|
-
not_found: "conversationNotFound",
|
|
63
|
-
timeout: "streamTimeout",
|
|
64
|
-
internal_error: "internalError"
|
|
65
|
-
});
|
|
66
|
-
var CONTRACT_ERROR_ROWS = Object.freeze(
|
|
67
|
-
CONTRACT_RETRYABILITY.map(
|
|
68
|
-
(generated) => Object.freeze({
|
|
69
|
-
wireCode: generated.wireCode,
|
|
70
|
-
envelope: generated.envelope,
|
|
71
|
-
retryable: generated.retryable,
|
|
72
|
-
normalized: NORMALIZED_FOLD[generated.wireCode]
|
|
73
|
-
})
|
|
74
|
-
)
|
|
75
|
-
);
|
|
76
|
-
var BY_UPPER = new Map(
|
|
77
|
-
CONTRACT_ERROR_ROWS.map((r) => [r.wireCode.toUpperCase(), r])
|
|
78
|
-
);
|
|
79
|
-
function contractErrorFor(wireCode) {
|
|
80
|
-
if (typeof wireCode !== "string") return void 0;
|
|
81
|
-
const key = wireCode.trim().toUpperCase();
|
|
82
|
-
return key.length > 0 ? BY_UPPER.get(key) : void 0;
|
|
83
|
-
}
|
|
84
|
-
var CATEGORY_OF = Object.freeze({
|
|
85
|
-
// the caller's sign-in state is wrong and a credential change is the remedy
|
|
86
|
-
authExpired: "authentication",
|
|
87
|
-
authRejected: "authentication",
|
|
88
|
-
sessionRequired: "authentication",
|
|
89
|
-
// signed in, correctly identified, and still not allowed
|
|
90
|
-
accessDenied: "authorization",
|
|
91
|
-
// a plan gate, not a permission failure: the remedy is commercial
|
|
92
|
-
paymentRequired: "entitlement",
|
|
93
|
-
// slow down / come back later
|
|
94
|
-
quotaExceeded: "rateLimit",
|
|
95
|
-
rateLimited: "rateLimit",
|
|
96
|
-
// the request itself was wrong; retrying it unchanged can never succeed
|
|
97
|
-
validationFailed: "invalidRequest",
|
|
98
|
-
sdkUpdateRequired: "invalidRequest",
|
|
99
|
-
// the target is gone, hidden, or was never visible to this caller
|
|
100
|
-
conversationNotFound: "notFound",
|
|
101
|
-
petNotFound: "notFound",
|
|
102
|
-
resourceNotFound: "notFound",
|
|
103
|
-
// something else already holds the thing
|
|
104
|
-
conflict: "conflict",
|
|
105
|
-
idempotencyConflict: "conflict",
|
|
106
|
-
idempotencyInFlight: "conflict",
|
|
107
|
-
// the pipe, not the request: timeouts, drops, a briefly unreachable dependency
|
|
108
|
-
streamTimeout: "connection",
|
|
109
|
-
streamIncomplete: "connection",
|
|
110
|
-
upstreamLlmTimeout: "connection",
|
|
111
|
-
serviceUnavailable: "connection",
|
|
112
|
-
// the server admits fault
|
|
113
|
-
internalError: "server",
|
|
114
|
-
notImplemented: "server",
|
|
115
|
-
mediaUploadFailed: "media",
|
|
116
|
-
moderationBlocked: "policy",
|
|
117
|
-
unknown: "unknown"
|
|
118
|
-
});
|
|
119
|
-
function categoryFor(code) {
|
|
120
|
-
return CATEGORY_OF[code];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// src/client/errors/EverfurError.ts
|
|
124
|
-
var USER_FACING_COPY = Object.freeze({
|
|
125
|
-
authExpired: "Please sign in again to continue.",
|
|
126
|
-
authRejected: "Please sign in again to continue.",
|
|
127
|
-
sessionRequired: "This app needs to be updated to keep using Everfur.",
|
|
128
|
-
accessDenied: "This feature isn't available on your account right now.",
|
|
129
|
-
paymentRequired: "This is part of a paid plan.",
|
|
130
|
-
quotaExceeded: "You have used today's messages. This resets tomorrow.",
|
|
131
|
-
rateLimited: "You are sending messages quickly. Try again in a few seconds.",
|
|
132
|
-
validationFailed: "Something in that request was not right. Check the details and try again.",
|
|
133
|
-
sdkUpdateRequired: "This app needs to be updated to keep using Everfur.",
|
|
134
|
-
conflict: "That is already running. Wait for it to finish, then try again.",
|
|
135
|
-
idempotencyConflict: "That message was already delivered.",
|
|
136
|
-
idempotencyInFlight: "That is still processing. Give it a moment.",
|
|
137
|
-
conversationNotFound: "This conversation is no longer available.",
|
|
138
|
-
petNotFound: "We could not find that pet. Please pick a pet and try again.",
|
|
139
|
-
resourceNotFound: "We could not find that.",
|
|
140
|
-
streamTimeout: "The response timed out. Tap retry to try again.",
|
|
141
|
-
mediaUploadFailed: "We could not upload that photo. Please attach it again.",
|
|
142
|
-
moderationBlocked: "This request cannot be answered here.",
|
|
143
|
-
upstreamLlmTimeout: "The response timed out. Tap retry to try again.",
|
|
144
|
-
internalError: "We hit a snag on our end. Please try again.",
|
|
145
|
-
notImplemented: "That is not available yet.",
|
|
146
|
-
serviceUnavailable: "That service is briefly unavailable. Try again shortly.",
|
|
147
|
-
streamIncomplete: "The connection dropped mid-answer. Tap retry to continue.",
|
|
148
|
-
unknown: "Something went wrong. Please try again."
|
|
149
|
-
});
|
|
150
|
-
function userFacingError(code) {
|
|
151
|
-
return USER_FACING_COPY[code];
|
|
152
|
-
}
|
|
153
|
-
function defineHidden(target, key, value) {
|
|
154
|
-
Object.defineProperty(target, key, {
|
|
155
|
-
value,
|
|
156
|
-
enumerable: false,
|
|
157
|
-
writable: false,
|
|
158
|
-
configurable: false
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
function makeEverfurError(code, opts) {
|
|
162
|
-
contractErrorFor(opts?.wireCode);
|
|
163
|
-
const error = {
|
|
164
|
-
code,
|
|
165
|
-
category: categoryFor(code),
|
|
166
|
-
retryable: opts?.retryable,
|
|
167
|
-
displayMessage: userFacingError(code)
|
|
168
|
-
};
|
|
169
|
-
if (opts?.httpStatus !== void 0) error.httpStatus = opts.httpStatus;
|
|
170
|
-
if (opts?.requestId) error.requestId = opts.requestId;
|
|
171
|
-
if (opts?.wireMessage) defineHidden(error, "wireMessage", opts.wireMessage);
|
|
172
|
-
if (opts?.raw !== void 0 && opts.raw !== null) defineHidden(error, "raw", opts.raw);
|
|
173
|
-
return Object.freeze(error);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// src/client/errors/EverfurResult.ts
|
|
177
|
-
function ok(value, warning) {
|
|
178
|
-
return Object.freeze(
|
|
179
|
-
{ ok: true, value }
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
function err(error) {
|
|
183
|
-
return Object.freeze({ ok: false, error });
|
|
184
|
-
}
|
|
185
|
-
var EverfurConfigError = class _EverfurConfigError extends Error {
|
|
186
|
-
constructor(kind, message) {
|
|
187
|
-
super(message);
|
|
188
|
-
this.name = "EverfurConfigError";
|
|
189
|
-
this.kind = kind;
|
|
190
|
-
Object.setPrototypeOf(this, _EverfurConfigError.prototype);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
// src/client/protocol/frames.ts
|
|
195
|
-
function assertNever(x) {
|
|
196
|
-
throw new Error(
|
|
197
|
-
`assertNever: unhandled discriminated-union member ${JSON.stringify(x)}`
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// src/core/chat/ChatController.ts
|
|
202
|
-
var MESSAGE_MAX_CHARS = 4e3;
|
|
203
|
-
|
|
204
|
-
// src/client/entitlements/resolve.ts
|
|
205
|
-
var REQUIRES = Object.freeze({
|
|
206
|
-
chat: Object.freeze(["chat.message.create"]),
|
|
207
|
-
records: Object.freeze(["records.upload.create", "records.record.read"]),
|
|
208
|
-
video: Object.freeze(["video.gait.execute"]),
|
|
209
|
-
photo: Object.freeze(["photo.checkup.execute"]),
|
|
210
|
-
animations: Object.freeze(["animations.state.read"])
|
|
211
|
-
});
|
|
212
|
-
function requires(name) {
|
|
213
|
-
return REQUIRES[name];
|
|
214
|
-
}
|
|
215
|
-
function decideCapability(name, decisions, opts) {
|
|
216
|
-
if (opts?.isPending === true) {
|
|
217
|
-
return freezeDecision({ name, enabled: false, isPending: true, limits: {} });
|
|
218
|
-
}
|
|
219
|
-
const keys = requires(name);
|
|
220
|
-
const byResource = /* @__PURE__ */ new Map();
|
|
221
|
-
for (const decision of decisions) byResource.set(decision.resource, decision);
|
|
222
|
-
const limits = mergeLimits(keys, byResource);
|
|
223
|
-
const missing = keys.filter((key) => byResource.get(key)?.granted !== true);
|
|
224
|
-
if (missing.length === 0) {
|
|
225
|
-
return freezeDecision({ name, enabled: true, isPending: false, limits });
|
|
226
|
-
}
|
|
227
|
-
return freezeDecision({
|
|
228
|
-
name,
|
|
229
|
-
enabled: false,
|
|
230
|
-
isPending: false,
|
|
231
|
-
limits,
|
|
232
|
-
disabled: disabledFor(keys, byResource)
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
function mergeLimits(keys, byResource) {
|
|
236
|
-
const out = {};
|
|
237
|
-
for (const key of keys) {
|
|
238
|
-
const decisionLimits = byResource.get(key)?.limits;
|
|
239
|
-
if (!decisionLimits) continue;
|
|
240
|
-
for (const [limitKey, limitValue] of Object.entries(decisionLimits)) {
|
|
241
|
-
const existing = out[limitKey];
|
|
242
|
-
out[limitKey] = existing === void 0 ? limitValue : Math.min(existing, limitValue);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
return out;
|
|
246
|
-
}
|
|
247
|
-
function disabledFor(keys, byResource) {
|
|
248
|
-
for (const key of keys) {
|
|
249
|
-
const explicit = byResource.get(key)?.disabled;
|
|
250
|
-
if (explicit) {
|
|
251
|
-
return Object.freeze({
|
|
252
|
-
reason: explicit.reason,
|
|
253
|
-
level: explicit.level,
|
|
254
|
-
recoverable: explicit.recoverable
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return Object.freeze({
|
|
259
|
-
reason: userFacingError("accessDenied"),
|
|
260
|
-
level: "user_entitlement",
|
|
261
|
-
recoverable: false
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
function freezeDecision(d) {
|
|
265
|
-
const base = {
|
|
266
|
-
name: d.name,
|
|
267
|
-
enabled: d.enabled,
|
|
268
|
-
isPending: d.isPending,
|
|
269
|
-
limits: Object.freeze({ ...d.limits })
|
|
270
|
-
};
|
|
271
|
-
if (d.disabled !== void 0) base.disabled = d.disabled;
|
|
272
|
-
return Object.freeze(base);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// src/client/theme/tokens.ts
|
|
276
|
-
function deepFreeze(value) {
|
|
277
|
-
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
278
|
-
Object.freeze(value);
|
|
279
|
-
for (const key of Object.keys(value)) {
|
|
280
|
-
deepFreeze(value[key]);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return value;
|
|
284
|
-
}
|
|
285
|
-
var SPACE = { xs: 4, sm: 8, md: 12, lg: 16, xl: 24, xxl: 32 };
|
|
286
|
-
var RADIUS = { tile: 5, xs: 6, sm: 10, md: 14, lg: 20, xl: 28, pill: 500 };
|
|
287
|
-
var TYPE_SIZE = {
|
|
288
|
-
nano: 8,
|
|
289
|
-
small: 9,
|
|
290
|
-
micro: 10,
|
|
291
|
-
tiny: 11,
|
|
292
|
-
caption: 12,
|
|
293
|
-
bodyTight: 13,
|
|
294
|
-
body: 14,
|
|
295
|
-
subtitle: 16,
|
|
296
|
-
heading: 18,
|
|
297
|
-
verdict: 24
|
|
298
|
-
};
|
|
299
|
-
var LINE_HEIGHT = { tight: 1.15, snug: 1.3, normal: 1.4, relaxed: 1.55 };
|
|
300
|
-
var WEIGHT = { regular: "400", medium: "500", bold: "700" };
|
|
301
|
-
var LETTER_SPACING = {
|
|
302
|
-
eyebrow: 1,
|
|
303
|
-
monoWide: 0.9,
|
|
304
|
-
headerBrand: -0.42,
|
|
305
|
-
tight: -0.35
|
|
306
|
-
};
|
|
307
|
-
function baseType() {
|
|
308
|
-
return {
|
|
309
|
-
family: "System",
|
|
310
|
-
mono: "monospace",
|
|
311
|
-
fontUrl: null,
|
|
312
|
-
size: TYPE_SIZE,
|
|
313
|
-
lineHeight: LINE_HEIGHT,
|
|
314
|
-
weight: WEIGHT,
|
|
315
|
-
letterSpacing: LETTER_SPACING
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
var MOTION = {
|
|
319
|
-
duration: { instant: 80, fast: 140, normal: 220, slow: 320 },
|
|
320
|
-
spring: { gentle: { damping: 18, stiffness: 200 } },
|
|
321
|
-
easing: { standard: "cubic-bezier(0.4, 0, 0.2, 1)" },
|
|
322
|
-
reducedMotion: false
|
|
323
|
-
};
|
|
324
|
-
var LIGHT_COLOR = {
|
|
325
|
-
brand: "#10462E",
|
|
326
|
-
brandSoft: "rgba(16,70,46,0.10)",
|
|
327
|
-
brandSofter: "rgba(16,70,46,0.15)",
|
|
328
|
-
brandBorder: "rgba(16,70,46,0.18)",
|
|
329
|
-
borderHairlineGreen: "rgba(16,70,46,0.25)",
|
|
330
|
-
surface: "#FFFFFF",
|
|
331
|
-
surfaceCream: "#FDFBF8",
|
|
332
|
-
surfaceSubtle: "#EFE9E3",
|
|
333
|
-
background: "#FFFFFF",
|
|
334
|
-
borderRingCream: "#D8D2C8",
|
|
335
|
-
text: {
|
|
336
|
-
primary: "#111111",
|
|
337
|
-
secondary: "#0E462E",
|
|
338
|
-
muted: "#6E6660",
|
|
339
|
-
placeholder: "rgba(0,0,0,0.30)",
|
|
340
|
-
onBrand: "#FFFFFF",
|
|
341
|
-
metaCool: "#3D3D3D"
|
|
342
|
-
},
|
|
343
|
-
primary: "#10462E",
|
|
344
|
-
onPrimary: "#FFFFFF",
|
|
345
|
-
accent: "#10462E",
|
|
346
|
-
onAccent: "#FFFFFF",
|
|
347
|
-
accentEdge: "#07C168",
|
|
348
|
-
success: "#07C168",
|
|
349
|
-
danger: "#B91C1C",
|
|
350
|
-
errorRed: "#FF1B00",
|
|
351
|
-
warningStrong: "#A45610",
|
|
352
|
-
cautionAccent: "#D9821D",
|
|
353
|
-
riskConcern: "#EFA700",
|
|
354
|
-
badgeBgPositive: "rgba(7,193,104,0.12)",
|
|
355
|
-
badgeBgCaution: "rgba(217,130,29,0.14)",
|
|
356
|
-
badgeBgCritical: "rgba(185,28,28,0.12)",
|
|
357
|
-
badgeBgNeutral: "rgba(110,102,96,0.12)",
|
|
358
|
-
bubbleUser: "#10462E",
|
|
359
|
-
bubbleAssistant: "#FFFFFF",
|
|
360
|
-
skeleton: "#EFE9E3",
|
|
361
|
-
scanButtonPink: "#FFC3BC",
|
|
362
|
-
checkupCardLowRiskBg: "rgba(7,193,104,0.10)",
|
|
363
|
-
checkupCardConcernBg: "rgba(239,167,0,0.10)"
|
|
364
|
-
};
|
|
365
|
-
var EVERFUR_LIGHT = deepFreeze({
|
|
366
|
-
brightness: "light",
|
|
367
|
-
meta: { displayName: "Everfur", logoUrl: null, placeholder: null, hidePoweredBy: false },
|
|
368
|
-
color: LIGHT_COLOR,
|
|
369
|
-
space: SPACE,
|
|
370
|
-
radius: RADIUS,
|
|
371
|
-
type: baseType(),
|
|
372
|
-
motion: MOTION
|
|
373
|
-
});
|
|
374
|
-
var DARK_COLOR = {
|
|
375
|
-
brand: "#6BD39A",
|
|
376
|
-
brandSoft: "rgba(107,211,154,0.12)",
|
|
377
|
-
brandSofter: "rgba(107,211,154,0.18)",
|
|
378
|
-
brandBorder: "rgba(107,211,154,0.22)",
|
|
379
|
-
borderHairlineGreen: "rgba(107,211,154,0.28)",
|
|
380
|
-
surface: "#1C1F23",
|
|
381
|
-
surfaceCream: "#23272C",
|
|
382
|
-
surfaceSubtle: "#23272C",
|
|
383
|
-
background: "#15171A",
|
|
384
|
-
borderRingCream: "#3A3F45",
|
|
385
|
-
text: {
|
|
386
|
-
primary: "#F5F3F0",
|
|
387
|
-
secondary: "#A9E4C4",
|
|
388
|
-
muted: "#9A938C",
|
|
389
|
-
placeholder: "rgba(255,255,255,0.35)",
|
|
390
|
-
onBrand: "#0E1F17",
|
|
391
|
-
metaCool: "#C9C9C9"
|
|
392
|
-
},
|
|
393
|
-
primary: "#6BD39A",
|
|
394
|
-
onPrimary: "#0E1F17",
|
|
395
|
-
accent: "#6BD39A",
|
|
396
|
-
onAccent: "#0E1F17",
|
|
397
|
-
accentEdge: "#34D888",
|
|
398
|
-
success: "#07C168",
|
|
399
|
-
danger: "#B91C1C",
|
|
400
|
-
errorRed: "#FF1B00",
|
|
401
|
-
warningStrong: "#A45610",
|
|
402
|
-
cautionAccent: "#D9821D",
|
|
403
|
-
riskConcern: "#EFA700",
|
|
404
|
-
badgeBgPositive: "rgba(7,193,104,0.18)",
|
|
405
|
-
badgeBgCaution: "rgba(217,130,29,0.20)",
|
|
406
|
-
badgeBgCritical: "rgba(185,28,28,0.22)",
|
|
407
|
-
badgeBgNeutral: "rgba(255,255,255,0.10)",
|
|
408
|
-
bubbleUser: "#6BD39A",
|
|
409
|
-
bubbleAssistant: "#1C1F23",
|
|
410
|
-
skeleton: "#23272C",
|
|
411
|
-
scanButtonPink: "#FFC3BC",
|
|
412
|
-
checkupCardLowRiskBg: "rgba(7,193,104,0.16)",
|
|
413
|
-
checkupCardConcernBg: "rgba(239,167,0,0.16)"
|
|
414
|
-
};
|
|
415
|
-
deepFreeze({
|
|
416
|
-
brightness: "dark",
|
|
417
|
-
meta: { displayName: "Everfur", logoUrl: null, placeholder: null, hidePoweredBy: false },
|
|
418
|
-
color: DARK_COLOR,
|
|
419
|
-
space: SPACE,
|
|
420
|
-
radius: RADIUS,
|
|
421
|
-
type: baseType(),
|
|
422
|
-
motion: MOTION
|
|
423
|
-
});
|
|
424
|
-
var EVERFUR_THEME_CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("@everfur/sdk#EverfurThemeContext@v1");
|
|
425
|
-
var globalThemeHost = globalThis;
|
|
426
|
-
var EverfurThemeContext = globalThemeHost[EVERFUR_THEME_CONTEXT_SYMBOL] ?? (globalThemeHost[EVERFUR_THEME_CONTEXT_SYMBOL] = react.createContext(EVERFUR_LIGHT));
|
|
427
|
-
EverfurThemeContext.displayName ??= "EverfurThemeContext";
|
|
428
|
-
function useEverfurTheme() {
|
|
429
|
-
return react.useContext(EverfurThemeContext);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// src/rn/facade.ts
|
|
433
|
-
var EVERFUR_CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("@everfur/sdk#EverfurContext@v1");
|
|
434
|
-
var globalContextHost = globalThis;
|
|
435
|
-
var EverfurContext = globalContextHost[EVERFUR_CONTEXT_SYMBOL] ?? (globalContextHost[EVERFUR_CONTEXT_SYMBOL] = react.createContext(null));
|
|
436
|
-
EverfurContext.displayName ??= "EverfurContext";
|
|
437
|
-
function useEverfurContext() {
|
|
438
|
-
const ctx = react.useContext(EverfurContext);
|
|
439
|
-
if (ctx === null) {
|
|
440
|
-
throw new EverfurConfigError(
|
|
441
|
-
"not-initialized",
|
|
442
|
-
"Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high."
|
|
443
|
-
);
|
|
444
|
-
}
|
|
445
|
-
return ctx;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
// src/rn/chat/useChat.ts
|
|
449
|
-
var BOOTSTRAP_SNAPSHOT = Object.freeze({
|
|
450
|
-
status: "idle",
|
|
451
|
-
messages: Object.freeze([]),
|
|
452
|
-
conversationId: null,
|
|
453
|
-
error: null,
|
|
454
|
-
isStreaming: false,
|
|
455
|
-
isBootstrapping: true,
|
|
456
|
-
suggestedPrompts: Object.freeze([])
|
|
457
|
-
});
|
|
458
|
-
function useEverfurChat(opts) {
|
|
459
|
-
const { runtime, userRef, activePet, scopeEpoch } = useEverfurContext();
|
|
460
|
-
const petRef = opts?.petRef ?? activePet ?? null;
|
|
461
|
-
const conversationId = opts?.conversationId ?? null;
|
|
462
|
-
const [controller, setController] = react.useState(null);
|
|
463
|
-
react.useEffect(() => {
|
|
464
|
-
const acquired = runtime.registry.acquireChat({ userRef, petRef, conversationId });
|
|
465
|
-
setController(acquired);
|
|
466
|
-
return () => {
|
|
467
|
-
setController((current) => current === acquired ? null : current);
|
|
468
|
-
runtime.registry.releaseChat(acquired);
|
|
469
|
-
};
|
|
470
|
-
}, [runtime, userRef, petRef, conversationId, scopeEpoch]);
|
|
471
|
-
const subscribe = react.useCallback(
|
|
472
|
-
(onChange) => controller ? controller.subscribe(onChange) : NOOP_UNSUBSCRIBE,
|
|
473
|
-
[controller]
|
|
474
|
-
);
|
|
475
|
-
const getSnapshot = react.useCallback(
|
|
476
|
-
() => controller ? controller.getSnapshot() : BOOTSTRAP_SNAPSHOT,
|
|
477
|
-
[controller]
|
|
478
|
-
);
|
|
479
|
-
const snapshot = react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
480
|
-
const send = react.useCallback(
|
|
481
|
-
(text) => controller ? driveToResult(controller, controller.send(text)) : Promise.resolve(notReadyError()),
|
|
482
|
-
[controller]
|
|
483
|
-
);
|
|
484
|
-
const retryLast = react.useCallback(
|
|
485
|
-
() => controller ? driveToResult(controller, controller.retryLast()) : Promise.resolve(notReadyError()),
|
|
486
|
-
[controller]
|
|
487
|
-
);
|
|
488
|
-
const stop = react.useCallback(() => {
|
|
489
|
-
controller?.stop();
|
|
490
|
-
}, [controller]);
|
|
491
|
-
return react.useMemo(
|
|
492
|
-
() => ({
|
|
493
|
-
status: snapshot.status,
|
|
494
|
-
messages: snapshot.messages,
|
|
495
|
-
conversationId: snapshot.conversationId,
|
|
496
|
-
error: snapshot.error,
|
|
497
|
-
isStreaming: snapshot.isStreaming,
|
|
498
|
-
isBootstrapping: snapshot.isBootstrapping,
|
|
499
|
-
suggestedPrompts: snapshot.suggestedPrompts,
|
|
500
|
-
send,
|
|
501
|
-
retryLast,
|
|
502
|
-
stop
|
|
503
|
-
}),
|
|
504
|
-
[snapshot, send, retryLast, stop]
|
|
505
|
-
);
|
|
506
|
-
}
|
|
507
|
-
var NOOP_UNSUBSCRIBE = () => {
|
|
508
|
-
};
|
|
509
|
-
async function driveToResult(controller, iterable) {
|
|
510
|
-
for await (const _frame of iterable) {
|
|
511
|
-
}
|
|
512
|
-
const snapshot = controller.getSnapshot();
|
|
513
|
-
if (snapshot.status === "error" && snapshot.error !== null) return err(snapshot.error);
|
|
514
|
-
return ok(lastAssistantResponseId(snapshot.messages));
|
|
515
|
-
}
|
|
516
|
-
function lastAssistantResponseId(messages) {
|
|
517
|
-
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
518
|
-
const message = messages[i];
|
|
519
|
-
if (message && message.role === "assistant" && message.responseId !== void 0) {
|
|
520
|
-
return message.responseId;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
return null;
|
|
524
|
-
}
|
|
525
|
-
function notReadyError() {
|
|
526
|
-
return err(
|
|
527
|
-
makeEverfurError("internalError", { retryable: true })
|
|
528
|
-
);
|
|
529
|
-
}
|
|
530
|
-
function useCapability(name) {
|
|
531
|
-
const { runtime } = useEverfurContext();
|
|
532
|
-
const store = runtime.entitlements;
|
|
533
|
-
const snapshot = react.useSyncExternalStore(
|
|
534
|
-
store.subscribe,
|
|
535
|
-
store.getSnapshot,
|
|
536
|
-
store.getSnapshot
|
|
537
|
-
);
|
|
538
|
-
return react.useMemo(
|
|
539
|
-
() => decideCapability(name, snapshot.decisions, { isPending: snapshot.isPending }),
|
|
540
|
-
[name, snapshot]
|
|
541
|
-
);
|
|
542
|
-
}
|
|
543
|
-
var MIN_OFFSTATE_HEIGHT = 48;
|
|
544
|
-
function selectView(decision) {
|
|
545
|
-
if (decision.isPending) return "pending";
|
|
546
|
-
return decision.enabled ? "enabled" : "disabled";
|
|
547
|
-
}
|
|
548
|
-
function CapabilityGate(props) {
|
|
549
|
-
const { capability, children, renderDisabled, renderPending, style } = props;
|
|
550
|
-
const decision = useCapability(capability);
|
|
551
|
-
const view = react.useMemo(() => selectView(decision), [decision]);
|
|
552
|
-
switch (view) {
|
|
553
|
-
case "enabled":
|
|
554
|
-
return children;
|
|
555
|
-
case "pending":
|
|
556
|
-
return renderPending ? renderPending() : /* @__PURE__ */ jsxRuntime.jsx(PendingSkeleton, { capability, style });
|
|
557
|
-
case "disabled":
|
|
558
|
-
return renderDisabled ? renderDisabled(decision) : /* @__PURE__ */ jsxRuntime.jsx(OffState, { decision, style });
|
|
559
|
-
default:
|
|
560
|
-
return assertNever(view);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
function PendingSkeleton({
|
|
564
|
-
capability,
|
|
565
|
-
style
|
|
566
|
-
}) {
|
|
567
|
-
const theme = useEverfurTheme();
|
|
568
|
-
const styles = react.useMemo(() => makeStyles(theme), [theme]);
|
|
569
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
-
reactNative.View,
|
|
571
|
-
{
|
|
572
|
-
style: [styles.offstate, style],
|
|
573
|
-
accessible: true,
|
|
574
|
-
accessibilityState: { busy: true },
|
|
575
|
-
accessibilityLabel: `Loading ${capability}`,
|
|
576
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles.skeletonBar })
|
|
577
|
-
}
|
|
578
|
-
);
|
|
579
|
-
}
|
|
580
|
-
function OffState({
|
|
581
|
-
decision,
|
|
582
|
-
style
|
|
583
|
-
}) {
|
|
584
|
-
const theme = useEverfurTheme();
|
|
585
|
-
const styles = react.useMemo(() => makeStyles(theme), [theme]);
|
|
586
|
-
const message = decision.disabled?.reason ?? "";
|
|
587
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
588
|
-
reactNative.View,
|
|
589
|
-
{
|
|
590
|
-
style: [styles.offstate, style],
|
|
591
|
-
accessible: true,
|
|
592
|
-
accessibilityRole: "text",
|
|
593
|
-
accessibilityLabel: message,
|
|
594
|
-
children: message.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.offstateText, children: message }) : null
|
|
595
|
-
}
|
|
596
|
-
);
|
|
597
|
-
}
|
|
598
|
-
function makeStyles(theme) {
|
|
599
|
-
const { color, space, radius, type } = theme;
|
|
600
|
-
return reactNative.StyleSheet.create({
|
|
601
|
-
// A deliberate cream card with a soft brand hairline, never a bare grey slab.
|
|
602
|
-
offstate: {
|
|
603
|
-
minHeight: MIN_OFFSTATE_HEIGHT,
|
|
604
|
-
justifyContent: "center",
|
|
605
|
-
paddingHorizontal: space.lg,
|
|
606
|
-
paddingVertical: space.md,
|
|
607
|
-
backgroundColor: color.surfaceCream,
|
|
608
|
-
borderRadius: radius.md,
|
|
609
|
-
borderWidth: reactNative.StyleSheet.hairlineWidth,
|
|
610
|
-
borderColor: color.brandBorder
|
|
611
|
-
},
|
|
612
|
-
offstateText: {
|
|
613
|
-
fontFamily: type.family,
|
|
614
|
-
fontSize: type.size.body,
|
|
615
|
-
lineHeight: Math.round(type.size.body * type.lineHeight.normal),
|
|
616
|
-
color: color.text.muted
|
|
617
|
-
},
|
|
618
|
-
// A soft green shimmer bar (brand wash) that stays legible on the cream card in both light and dark,
|
|
619
|
-
// where the neutral `skeleton` token would collide with the dark cream surface.
|
|
620
|
-
skeletonBar: {
|
|
621
|
-
height: space.md,
|
|
622
|
-
borderRadius: radius.xs,
|
|
623
|
-
backgroundColor: color.brandSofter
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
var CLINICAL_DISCLAIMER = Object.freeze({
|
|
628
|
-
title: "For educational use only",
|
|
629
|
-
body: "Everfur is for educational purposes only. It helps you track visible changes through AI checkups. It does not diagnose, treat, prescribe, or replace veterinary care. For urgent symptoms or emergencies, contact a veterinarian immediately."
|
|
630
|
-
});
|
|
631
|
-
function ClinicalDisclaimer(props) {
|
|
632
|
-
const theme = useEverfurTheme();
|
|
633
|
-
const styles = react.useMemo(() => makeStyles2(theme), [theme]);
|
|
634
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
635
|
-
reactNative.View,
|
|
636
|
-
{
|
|
637
|
-
style: [styles.container, props.style],
|
|
638
|
-
accessible: true,
|
|
639
|
-
accessibilityRole: "text",
|
|
640
|
-
accessibilityLabel: `${CLINICAL_DISCLAIMER.title}. ${CLINICAL_DISCLAIMER.body}`,
|
|
641
|
-
children: [
|
|
642
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.title, children: CLINICAL_DISCLAIMER.title }),
|
|
643
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.body, children: CLINICAL_DISCLAIMER.body })
|
|
644
|
-
]
|
|
645
|
-
}
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
function makeStyles2(theme) {
|
|
649
|
-
const { color, space, type } = theme;
|
|
650
|
-
return reactNative.StyleSheet.create({
|
|
651
|
-
container: {
|
|
652
|
-
paddingHorizontal: space.lg,
|
|
653
|
-
paddingVertical: space.md,
|
|
654
|
-
borderTopWidth: reactNative.StyleSheet.hairlineWidth,
|
|
655
|
-
borderTopColor: color.borderHairlineGreen,
|
|
656
|
-
backgroundColor: color.surfaceCream,
|
|
657
|
-
gap: space.xs
|
|
658
|
-
},
|
|
659
|
-
title: {
|
|
660
|
-
fontFamily: type.family,
|
|
661
|
-
fontSize: type.size.caption,
|
|
662
|
-
lineHeight: Math.round(type.size.caption * type.lineHeight.snug),
|
|
663
|
-
color: color.text.secondary,
|
|
664
|
-
fontWeight: type.weight.bold,
|
|
665
|
-
letterSpacing: type.letterSpacing.eyebrow
|
|
666
|
-
},
|
|
667
|
-
body: {
|
|
668
|
-
fontFamily: type.family,
|
|
669
|
-
fontSize: type.size.caption,
|
|
670
|
-
lineHeight: Math.round(type.size.caption * type.lineHeight.snug),
|
|
671
|
-
color: color.text.muted,
|
|
672
|
-
fontWeight: type.weight.regular
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
var INLINE_TOKEN = /\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;
|
|
677
|
-
function renderInlineMarkdown(text, styles) {
|
|
678
|
-
if (!text.includes("*") && !text.includes("`")) return text;
|
|
679
|
-
const nodes = [];
|
|
680
|
-
let cursor = 0;
|
|
681
|
-
let key = 0;
|
|
682
|
-
INLINE_TOKEN.lastIndex = 0;
|
|
683
|
-
for (let match = INLINE_TOKEN.exec(text); match !== null; match = INLINE_TOKEN.exec(text)) {
|
|
684
|
-
if (match.index > cursor) nodes.push(text.slice(cursor, match.index));
|
|
685
|
-
const bold = match[1];
|
|
686
|
-
const italic = match[2];
|
|
687
|
-
const code = match[3];
|
|
688
|
-
if (bold !== void 0) {
|
|
689
|
-
nodes.push(/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.bold, children: bold }, key++));
|
|
690
|
-
} else if (italic !== void 0) {
|
|
691
|
-
nodes.push(styles.italic ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.italic, children: italic }, key++) : italic);
|
|
692
|
-
} else if (code !== void 0) {
|
|
693
|
-
nodes.push(styles.code ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.code, children: code }, key++) : code);
|
|
694
|
-
}
|
|
695
|
-
cursor = match.index + match[0].length;
|
|
696
|
-
}
|
|
697
|
-
if (cursor < text.length) nodes.push(text.slice(cursor));
|
|
698
|
-
return nodes;
|
|
699
|
-
}
|
|
700
|
-
var DOT_SIZE = 6;
|
|
701
|
-
var LOOP_MS = 520;
|
|
702
|
-
var STAGGER_MS = Math.round(LOOP_MS * 0.18);
|
|
703
|
-
var OPACITY_REST = 0.44;
|
|
704
|
-
var OPACITY_STATIC = 0.5;
|
|
705
|
-
var TRI_IN = [0, 0.5, 1];
|
|
706
|
-
var DOT_INDICES = [0, 1, 2];
|
|
707
|
-
function TypingIndicator() {
|
|
708
|
-
const theme = useEverfurTheme();
|
|
709
|
-
const styles = react.useMemo(() => makeStyles3(theme), [theme]);
|
|
710
|
-
const animate = !theme.motion.reducedMotion;
|
|
711
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
712
|
-
reactNative.View,
|
|
713
|
-
{
|
|
714
|
-
style: styles.card,
|
|
715
|
-
accessible: true,
|
|
716
|
-
accessibilityRole: "text",
|
|
717
|
-
accessibilityLabel: "Assistant is typing",
|
|
718
|
-
accessibilityLiveRegion: "polite",
|
|
719
|
-
accessibilityState: { busy: true },
|
|
720
|
-
children: DOT_INDICES.map(
|
|
721
|
-
(index) => animate ? /* @__PURE__ */ jsxRuntime.jsx(AnimatedDot, { index, style: styles.dot }, index) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles.dot, styles.dotStatic] }, index)
|
|
722
|
-
)
|
|
723
|
-
}
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
function AnimatedDot({ index, style }) {
|
|
727
|
-
const t = react.useRef(new reactNative.Animated.Value(0)).current;
|
|
728
|
-
react.useEffect(() => {
|
|
729
|
-
const anim = reactNative.Animated.sequence([
|
|
730
|
-
reactNative.Animated.delay(index * STAGGER_MS),
|
|
731
|
-
reactNative.Animated.loop(reactNative.Animated.timing(t, { toValue: 1, duration: LOOP_MS, useNativeDriver: true }))
|
|
732
|
-
]);
|
|
733
|
-
anim.start();
|
|
734
|
-
return () => anim.stop();
|
|
735
|
-
}, [t, index]);
|
|
736
|
-
const opacity = t.interpolate({ inputRange: TRI_IN, outputRange: [OPACITY_REST, 1, OPACITY_REST] });
|
|
737
|
-
const translateY = t.interpolate({ inputRange: TRI_IN, outputRange: [0, -3.5, 0] });
|
|
738
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [style, { opacity, transform: [{ translateY }] }] });
|
|
739
|
-
}
|
|
740
|
-
function makeStyles3(theme) {
|
|
741
|
-
const c = theme.color;
|
|
742
|
-
const s = theme.space;
|
|
743
|
-
const r = theme.radius;
|
|
744
|
-
return reactNative.StyleSheet.create({
|
|
745
|
-
card: {
|
|
746
|
-
alignSelf: "flex-start",
|
|
747
|
-
flexDirection: "row",
|
|
748
|
-
alignItems: "center",
|
|
749
|
-
gap: s.xs,
|
|
750
|
-
paddingHorizontal: s.md,
|
|
751
|
-
paddingVertical: s.sm,
|
|
752
|
-
backgroundColor: c.surfaceCream,
|
|
753
|
-
borderRadius: r.md,
|
|
754
|
-
borderWidth: reactNative.StyleSheet.hairlineWidth,
|
|
755
|
-
borderColor: c.brandBorder
|
|
756
|
-
},
|
|
757
|
-
dot: { width: DOT_SIZE, height: DOT_SIZE, borderRadius: r.pill, backgroundColor: c.brand },
|
|
758
|
-
dotStatic: { opacity: OPACITY_STATIC }
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
var SPINNER_DELAY_MS = 300;
|
|
762
|
-
var DEFAULT_PLACEHOLDER = "Message";
|
|
763
|
-
var DEFAULT_SEND_LABEL = "Send";
|
|
764
|
-
var DEFAULT_STOP_LABEL = "Stop";
|
|
765
|
-
var FOLLOW_UPS_LABEL = "Follow up questions";
|
|
766
|
-
var POWERED_BY_LABEL = "powered by everfur";
|
|
767
|
-
var MIN_SURFACE_HEIGHT = 120;
|
|
768
|
-
var MIN_TOUCH_TARGET = 44;
|
|
769
|
-
var INPUT_MAX_HEIGHT = 120;
|
|
770
|
-
var EMPTY_GLYPH_SIZE = 40;
|
|
771
|
-
var BUBBLE_MAX_WIDTH = "82%";
|
|
772
|
-
var COMPOSER_BORDER_WIDTH = 1.25;
|
|
773
|
-
var BUBBLE_EDGE_WIDTH = 0.5;
|
|
774
|
-
var PENDING_OPACITY = 0.6;
|
|
775
|
-
var COMPOSER_SHADOW_OPACITY = 0.1;
|
|
776
|
-
var COMPOSER_SHADOW_OFFSET_Y = 2;
|
|
777
|
-
var COMPOSER_SHADOW_ELEVATION = 2;
|
|
778
|
-
function EverfurChat(props) {
|
|
779
|
-
const { petRef, conversationId, style } = props;
|
|
780
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CapabilityGate, { capability: "chat", style, children: /* @__PURE__ */ jsxRuntime.jsx(ChatBody, { petRef, conversationId, style }) });
|
|
781
|
-
}
|
|
782
|
-
function selectView2(state) {
|
|
783
|
-
if (state.isBootstrapping) return "loading";
|
|
784
|
-
if (state.status === "error" && state.error) return "error";
|
|
785
|
-
if (state.messages.length === 0) return "empty";
|
|
786
|
-
return "populated";
|
|
787
|
-
}
|
|
788
|
-
function ChatBody({
|
|
789
|
-
petRef,
|
|
790
|
-
conversationId,
|
|
791
|
-
style
|
|
792
|
-
}) {
|
|
793
|
-
const { theme, styles } = useChatTheme();
|
|
794
|
-
const chatOpts = react.useMemo(
|
|
795
|
-
() => buildChatOpts(petRef, conversationId),
|
|
796
|
-
[petRef, conversationId]
|
|
797
|
-
);
|
|
798
|
-
const chat = useEverfurChat(chatOpts);
|
|
799
|
-
const view = selectView2(chat);
|
|
800
|
-
const insets = reactNativeSafeAreaContext.useSafeAreaInsets();
|
|
801
|
-
const onSelectPrompt = react.useCallback(
|
|
802
|
-
(prompt) => {
|
|
803
|
-
void chat.send(prompt);
|
|
804
|
-
},
|
|
805
|
-
[chat.send]
|
|
806
|
-
);
|
|
807
|
-
return (
|
|
808
|
-
// KeyboardAvoidingView so the composer + disclaimer lift above the software keyboard while the user types.
|
|
809
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
810
|
-
reactNative.KeyboardAvoidingView,
|
|
811
|
-
{
|
|
812
|
-
style: [styles.container, { paddingTop: insets.top }, style],
|
|
813
|
-
behavior: reactNative.Platform.OS === "ios" ? "padding" : void 0,
|
|
814
|
-
children: [
|
|
815
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles.body, children: renderView(view, chat, onSelectPrompt) }),
|
|
816
|
-
/* @__PURE__ */ jsxRuntime.jsx(Composer, { send: chat.send, stop: chat.stop, isStreaming: chat.isStreaming }),
|
|
817
|
-
/* @__PURE__ */ jsxRuntime.jsx(ClinicalDisclaimer, {}),
|
|
818
|
-
theme.meta.hidePoweredBy ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.poweredBy, accessibilityRole: "text", accessibilityLabel: POWERED_BY_LABEL, children: POWERED_BY_LABEL })
|
|
819
|
-
]
|
|
820
|
-
}
|
|
821
|
-
)
|
|
822
|
-
);
|
|
823
|
-
}
|
|
824
|
-
function Composer({
|
|
825
|
-
send,
|
|
826
|
-
stop,
|
|
827
|
-
isStreaming
|
|
828
|
-
}) {
|
|
829
|
-
const { theme, styles } = useChatTheme();
|
|
830
|
-
const [draft, setDraft] = react.useState("");
|
|
831
|
-
const placeholder = theme.meta.placeholder ?? DEFAULT_PLACEHOLDER;
|
|
832
|
-
const onSend = react.useCallback(() => {
|
|
833
|
-
if (draft.trim().length === 0) return;
|
|
834
|
-
if ([...draft].length > MESSAGE_MAX_CHARS) return;
|
|
835
|
-
void send(draft);
|
|
836
|
-
setDraft("");
|
|
837
|
-
}, [draft, send]);
|
|
838
|
-
const onStop = react.useCallback(() => {
|
|
839
|
-
stop();
|
|
840
|
-
}, [stop]);
|
|
841
|
-
const isOverLimit = react.useMemo(() => [...draft].length > MESSAGE_MAX_CHARS, [draft]);
|
|
842
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles.composer, children: [
|
|
843
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
844
|
-
reactNative.TextInput,
|
|
845
|
-
{
|
|
846
|
-
style: styles.input,
|
|
847
|
-
value: draft,
|
|
848
|
-
onChangeText: setDraft,
|
|
849
|
-
placeholder,
|
|
850
|
-
placeholderTextColor: theme.color.text.placeholder,
|
|
851
|
-
accessibilityLabel: placeholder,
|
|
852
|
-
onSubmitEditing: onSend,
|
|
853
|
-
returnKeyType: "send",
|
|
854
|
-
blurOnSubmit: false,
|
|
855
|
-
multiline: true,
|
|
856
|
-
editable: true
|
|
857
|
-
}
|
|
858
|
-
),
|
|
859
|
-
isStreaming ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
860
|
-
reactNative.Pressable,
|
|
861
|
-
{
|
|
862
|
-
onPress: onStop,
|
|
863
|
-
accessibilityRole: "button",
|
|
864
|
-
accessibilityLabel: DEFAULT_STOP_LABEL,
|
|
865
|
-
style: styles.actionButton,
|
|
866
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.actionLabel, children: DEFAULT_STOP_LABEL })
|
|
867
|
-
}
|
|
868
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
869
|
-
reactNative.Pressable,
|
|
870
|
-
{
|
|
871
|
-
onPress: onSend,
|
|
872
|
-
disabled: isOverLimit,
|
|
873
|
-
accessibilityRole: "button",
|
|
874
|
-
accessibilityLabel: DEFAULT_SEND_LABEL,
|
|
875
|
-
accessibilityState: { disabled: isOverLimit },
|
|
876
|
-
style: [styles.actionButton, isOverLimit ? styles.actionButtonDisabled : null],
|
|
877
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles.actionLabel, isOverLimit ? styles.actionLabelDisabled : null], children: DEFAULT_SEND_LABEL })
|
|
878
|
-
}
|
|
879
|
-
)
|
|
880
|
-
] });
|
|
881
|
-
}
|
|
882
|
-
function renderView(view, chat, onSelectPrompt) {
|
|
883
|
-
switch (view) {
|
|
884
|
-
case "loading":
|
|
885
|
-
return /* @__PURE__ */ jsxRuntime.jsx(LoadingState, {});
|
|
886
|
-
case "empty":
|
|
887
|
-
return /* @__PURE__ */ jsxRuntime.jsx(EmptyState, { prompts: chat.suggestedPrompts, onSelectPrompt });
|
|
888
|
-
case "error":
|
|
889
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ErrorState, { error: chat.error, onRetry: chat.retryLast });
|
|
890
|
-
case "populated":
|
|
891
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
892
|
-
PopulatedState,
|
|
893
|
-
{
|
|
894
|
-
messages: chat.messages,
|
|
895
|
-
prompts: chat.suggestedPrompts,
|
|
896
|
-
onSelectPrompt,
|
|
897
|
-
isStreaming: chat.isStreaming
|
|
898
|
-
}
|
|
899
|
-
);
|
|
900
|
-
default:
|
|
901
|
-
return assertNever(view);
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
function buildChatOpts(petRef, conversationId) {
|
|
905
|
-
const opts = {};
|
|
906
|
-
if (petRef !== void 0) opts.petRef = petRef;
|
|
907
|
-
if (conversationId !== void 0) opts.conversationId = conversationId;
|
|
908
|
-
return opts;
|
|
909
|
-
}
|
|
910
|
-
function LoadingState() {
|
|
911
|
-
const { theme, styles } = useChatTheme();
|
|
912
|
-
const [visible, setVisible] = react.useState(false);
|
|
913
|
-
react.useEffect(() => {
|
|
914
|
-
const id = setTimeout(() => setVisible(true), SPINNER_DELAY_MS);
|
|
915
|
-
return () => clearTimeout(id);
|
|
916
|
-
}, []);
|
|
917
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles.centered, accessible: true, accessibilityState: { busy: true }, accessibilityLabel: "Loading", children: visible ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.ActivityIndicator, { color: theme.color.brand }) : null });
|
|
918
|
-
}
|
|
919
|
-
function EmptyState({
|
|
920
|
-
prompts,
|
|
921
|
-
onSelectPrompt
|
|
922
|
-
}) {
|
|
923
|
-
const { styles } = useChatTheme();
|
|
924
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.ScrollView, { contentContainerStyle: styles.emptyContent, keyboardShouldPersistTaps: "handled", children: [
|
|
925
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles.emptyGlyphWrap, accessible: true, accessibilityRole: "summary", accessibilityLabel: "No messages yet", children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles.emptyGlyph }) }),
|
|
926
|
-
/* @__PURE__ */ jsxRuntime.jsx(FollowUps, { prompts, onSelectPrompt })
|
|
927
|
-
] });
|
|
928
|
-
}
|
|
929
|
-
function FollowUps({
|
|
930
|
-
prompts,
|
|
931
|
-
onSelectPrompt
|
|
932
|
-
}) {
|
|
933
|
-
const { styles } = useChatTheme();
|
|
934
|
-
if (prompts.length === 0) return null;
|
|
935
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles.followUps, children: [
|
|
936
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.followUpsLabel, accessibilityRole: "header", children: FOLLOW_UPS_LABEL }),
|
|
937
|
-
prompts.map((prompt, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
938
|
-
reactNative.Pressable,
|
|
939
|
-
{
|
|
940
|
-
onPress: () => onSelectPrompt(prompt),
|
|
941
|
-
accessibilityRole: "button",
|
|
942
|
-
accessibilityLabel: prompt,
|
|
943
|
-
style: [styles.followUpRow, index > 0 ? styles.followUpDivider : null],
|
|
944
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.followUpText, children: prompt })
|
|
945
|
-
},
|
|
946
|
-
prompt
|
|
947
|
-
))
|
|
948
|
-
] });
|
|
949
|
-
}
|
|
950
|
-
function ErrorState({ error, onRetry }) {
|
|
951
|
-
const { styles } = useChatTheme();
|
|
952
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles.centered, accessible: true, accessibilityRole: "alert", children: [
|
|
953
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.errorText, children: error.displayMessage }),
|
|
954
|
-
error.retryable ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
955
|
-
reactNative.Pressable,
|
|
956
|
-
{
|
|
957
|
-
onPress: onRetry,
|
|
958
|
-
accessibilityRole: "button",
|
|
959
|
-
accessibilityLabel: "Try again",
|
|
960
|
-
style: styles.retryButton,
|
|
961
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.retryLabel, children: "Try again" })
|
|
962
|
-
}
|
|
963
|
-
) : null
|
|
964
|
-
] });
|
|
965
|
-
}
|
|
966
|
-
function PopulatedState({
|
|
967
|
-
messages,
|
|
968
|
-
prompts,
|
|
969
|
-
onSelectPrompt,
|
|
970
|
-
isStreaming
|
|
971
|
-
}) {
|
|
972
|
-
const { styles } = useChatTheme();
|
|
973
|
-
const lastMessage = messages[messages.length - 1];
|
|
974
|
-
const awaitingAssistant = isStreaming && (lastMessage === void 0 || lastMessage.role === "user");
|
|
975
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
976
|
-
reactNative.ScrollView,
|
|
977
|
-
{
|
|
978
|
-
style: styles.list,
|
|
979
|
-
contentContainerStyle: styles.listContent,
|
|
980
|
-
accessibilityLabel: "Conversation",
|
|
981
|
-
keyboardShouldPersistTaps: "handled",
|
|
982
|
-
children: [
|
|
983
|
-
messages.map((message) => /* @__PURE__ */ jsxRuntime.jsx(MessageRow, { message }, message.id)),
|
|
984
|
-
awaitingAssistant ? /* @__PURE__ */ jsxRuntime.jsx(TypingIndicator, {}) : null,
|
|
985
|
-
!isStreaming ? /* @__PURE__ */ jsxRuntime.jsx(FollowUps, { prompts, onSelectPrompt }) : null
|
|
986
|
-
]
|
|
987
|
-
}
|
|
988
|
-
);
|
|
989
|
-
}
|
|
990
|
-
function MessageRow({ message }) {
|
|
991
|
-
const { styles } = useChatTheme();
|
|
992
|
-
const isUser = message.role === "user";
|
|
993
|
-
const sender = isUser ? "You" : "Assistant";
|
|
994
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
995
|
-
reactNative.View,
|
|
996
|
-
{
|
|
997
|
-
style: [styles.row, isUser ? styles.rowUser : styles.rowAssistant],
|
|
998
|
-
accessible: true,
|
|
999
|
-
accessibilityRole: "text",
|
|
1000
|
-
accessibilityLabel: `${sender}: ${message.text}`,
|
|
1001
|
-
accessibilityState: message.pending === true ? { busy: true } : void 0,
|
|
1002
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles.bubble, isUser ? styles.bubbleUser : styles.bubbleAssistant, message.pending ? styles.bubblePending : null], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: isUser ? styles.bubbleTextUser : styles.bubbleTextAssistant, children: isUser ? message.text : renderInlineMarkdown(message.text, {
|
|
1003
|
-
bold: styles.bubbleBold,
|
|
1004
|
-
italic: styles.bubbleItalic,
|
|
1005
|
-
code: styles.bubbleCode
|
|
1006
|
-
}) }) })
|
|
1007
|
-
}
|
|
1008
|
-
);
|
|
1009
|
-
}
|
|
1010
|
-
function useChatTheme() {
|
|
1011
|
-
const theme = useEverfurTheme();
|
|
1012
|
-
const styles = react.useMemo(() => makeStyles4(theme), [theme]);
|
|
1013
|
-
return { theme, styles };
|
|
1014
|
-
}
|
|
1015
|
-
function makeStyles4(theme) {
|
|
1016
|
-
const c = theme.color;
|
|
1017
|
-
const s = theme.space;
|
|
1018
|
-
const r = theme.radius;
|
|
1019
|
-
const t = theme.type;
|
|
1020
|
-
const weightLabel = t.weight.medium;
|
|
1021
|
-
return reactNative.StyleSheet.create({
|
|
1022
|
-
// Cream ground so the branded bubbles / bare assistant text sit on an Everfur surface (host `style` still wins).
|
|
1023
|
-
container: { flex: 1, minHeight: MIN_SURFACE_HEIGHT, backgroundColor: c.surfaceCream },
|
|
1024
|
-
body: { flex: 1 },
|
|
1025
|
-
centered: { minHeight: MIN_SURFACE_HEIGHT, flexGrow: 1, alignItems: "center", justifyContent: "center", padding: s.xl },
|
|
1026
|
-
// Deliberate empty-state placeholder: a soft brand-wash disc (never a blank region).
|
|
1027
|
-
emptyGlyph: {
|
|
1028
|
-
width: EMPTY_GLYPH_SIZE,
|
|
1029
|
-
height: EMPTY_GLYPH_SIZE,
|
|
1030
|
-
borderRadius: r.pill,
|
|
1031
|
-
backgroundColor: c.brandSoft,
|
|
1032
|
-
borderWidth: reactNative.StyleSheet.hairlineWidth,
|
|
1033
|
-
borderColor: c.brandBorder
|
|
1034
|
-
},
|
|
1035
|
-
// Empty state scrolls (glyph centered, then the follow-up list) so nothing overflows a short surface.
|
|
1036
|
-
emptyContent: { flexGrow: 1, justifyContent: "center", padding: s.lg, gap: s.lg },
|
|
1037
|
-
emptyGlyphWrap: { alignItems: "center", justifyContent: "center", paddingVertical: s.xl },
|
|
1038
|
-
errorText: {
|
|
1039
|
-
fontFamily: t.family,
|
|
1040
|
-
fontSize: t.size.subtitle,
|
|
1041
|
-
lineHeight: t.size.subtitle * t.lineHeight.snug,
|
|
1042
|
-
color: c.danger,
|
|
1043
|
-
textAlign: "center",
|
|
1044
|
-
marginBottom: s.md
|
|
1045
|
-
},
|
|
1046
|
-
// Brand-green pill retry CTA with the WCAG-legible on-brand foreground.
|
|
1047
|
-
retryButton: {
|
|
1048
|
-
minHeight: MIN_TOUCH_TARGET,
|
|
1049
|
-
minWidth: MIN_TOUCH_TARGET,
|
|
1050
|
-
alignItems: "center",
|
|
1051
|
-
justifyContent: "center",
|
|
1052
|
-
paddingHorizontal: s.xl,
|
|
1053
|
-
paddingVertical: s.sm,
|
|
1054
|
-
borderRadius: r.pill,
|
|
1055
|
-
backgroundColor: c.brand
|
|
1056
|
-
},
|
|
1057
|
-
retryLabel: { fontFamily: t.family, color: c.onPrimary, fontSize: t.size.body, fontWeight: weightLabel },
|
|
1058
|
-
list: { flex: 1 },
|
|
1059
|
-
listContent: { padding: s.lg, gap: s.md },
|
|
1060
|
-
row: { flexDirection: "row" },
|
|
1061
|
-
rowUser: { justifyContent: "flex-end" },
|
|
1062
|
-
rowAssistant: { justifyContent: "flex-start" },
|
|
1063
|
-
bubble: { maxWidth: BUBBLE_MAX_WIDTH, paddingHorizontal: s.md, paddingVertical: s.sm, borderRadius: r.lg },
|
|
1064
|
-
// User = brand accent fill + 0.5px accent edge, tail corner tightened (the mobile asymmetry).
|
|
1065
|
-
bubbleUser: {
|
|
1066
|
-
backgroundColor: c.bubbleUser,
|
|
1067
|
-
borderBottomRightRadius: r.tile,
|
|
1068
|
-
borderWidth: BUBBLE_EDGE_WIDTH,
|
|
1069
|
-
borderColor: c.accentEdge
|
|
1070
|
-
},
|
|
1071
|
-
// Assistant = bare text block (no fill, flush-left) so the reply reads as plain, on-surface prose.
|
|
1072
|
-
bubbleAssistant: { paddingHorizontal: 0 },
|
|
1073
|
-
bubblePending: { opacity: PENDING_OPACITY },
|
|
1074
|
-
bubbleTextUser: {
|
|
1075
|
-
fontFamily: t.family,
|
|
1076
|
-
color: c.onAccent,
|
|
1077
|
-
fontSize: t.size.body,
|
|
1078
|
-
lineHeight: t.size.body * t.lineHeight.normal
|
|
1079
|
-
},
|
|
1080
|
-
bubbleTextAssistant: {
|
|
1081
|
-
fontFamily: t.family,
|
|
1082
|
-
color: c.text.primary,
|
|
1083
|
-
fontSize: t.size.body,
|
|
1084
|
-
lineHeight: t.size.body * t.lineHeight.normal
|
|
1085
|
-
},
|
|
1086
|
-
// Inline-markdown runs inside the assistant reply (nested <Text>): bold entities + optional italic / code.
|
|
1087
|
-
bubbleBold: { fontWeight: t.weight.bold },
|
|
1088
|
-
bubbleItalic: { fontStyle: "italic" },
|
|
1089
|
-
bubbleCode: { fontFamily: t.mono },
|
|
1090
|
-
// "Follow up questions": a labeled, list-with-dividers block of tappable, ready-to-send backend prompts.
|
|
1091
|
-
followUps: { marginTop: s.sm, borderRadius: r.md, backgroundColor: c.brandSoft, borderWidth: reactNative.StyleSheet.hairlineWidth, borderColor: c.brandBorder },
|
|
1092
|
-
followUpsLabel: {
|
|
1093
|
-
fontFamily: t.family,
|
|
1094
|
-
color: c.text.secondary,
|
|
1095
|
-
fontSize: t.size.caption,
|
|
1096
|
-
fontWeight: weightLabel,
|
|
1097
|
-
letterSpacing: t.letterSpacing.eyebrow,
|
|
1098
|
-
textTransform: "uppercase",
|
|
1099
|
-
paddingHorizontal: s.md,
|
|
1100
|
-
paddingTop: s.md,
|
|
1101
|
-
paddingBottom: s.sm
|
|
1102
|
-
},
|
|
1103
|
-
followUpRow: { minHeight: MIN_TOUCH_TARGET, justifyContent: "center", paddingHorizontal: s.md, paddingVertical: s.sm },
|
|
1104
|
-
followUpDivider: { borderTopWidth: reactNative.StyleSheet.hairlineWidth, borderTopColor: c.brandBorder },
|
|
1105
|
-
followUpText: {
|
|
1106
|
-
fontFamily: t.family,
|
|
1107
|
-
color: c.text.primary,
|
|
1108
|
-
fontSize: t.size.body,
|
|
1109
|
-
lineHeight: t.size.body * t.lineHeight.snug
|
|
1110
|
-
},
|
|
1111
|
-
// Composer = inset cream pill with a brand border and a soft brand-tinted lift.
|
|
1112
|
-
composer: {
|
|
1113
|
-
flexDirection: "row",
|
|
1114
|
-
alignItems: "flex-end",
|
|
1115
|
-
gap: s.sm,
|
|
1116
|
-
marginHorizontal: s.md,
|
|
1117
|
-
marginTop: s.xs,
|
|
1118
|
-
marginBottom: s.sm,
|
|
1119
|
-
paddingHorizontal: s.md,
|
|
1120
|
-
paddingVertical: s.sm,
|
|
1121
|
-
backgroundColor: c.surfaceCream,
|
|
1122
|
-
borderWidth: COMPOSER_BORDER_WIDTH,
|
|
1123
|
-
borderColor: c.brandBorder,
|
|
1124
|
-
borderRadius: r.pill,
|
|
1125
|
-
shadowColor: c.brand,
|
|
1126
|
-
shadowOpacity: COMPOSER_SHADOW_OPACITY,
|
|
1127
|
-
shadowRadius: s.sm,
|
|
1128
|
-
shadowOffset: { width: 0, height: COMPOSER_SHADOW_OFFSET_Y },
|
|
1129
|
-
elevation: COMPOSER_SHADOW_ELEVATION
|
|
1130
|
-
},
|
|
1131
|
-
// Bare input inside the pill (the composer owns the border / fill); placeholder color set on the element.
|
|
1132
|
-
input: {
|
|
1133
|
-
flex: 1,
|
|
1134
|
-
minHeight: MIN_TOUCH_TARGET,
|
|
1135
|
-
maxHeight: INPUT_MAX_HEIGHT,
|
|
1136
|
-
paddingHorizontal: s.md,
|
|
1137
|
-
paddingVertical: s.sm,
|
|
1138
|
-
fontFamily: t.family,
|
|
1139
|
-
fontSize: t.size.body,
|
|
1140
|
-
lineHeight: t.size.body * t.lineHeight.normal,
|
|
1141
|
-
color: c.text.primary
|
|
1142
|
-
},
|
|
1143
|
-
// Brand-green pill send / stop control.
|
|
1144
|
-
actionButton: {
|
|
1145
|
-
minHeight: MIN_TOUCH_TARGET,
|
|
1146
|
-
minWidth: MIN_TOUCH_TARGET,
|
|
1147
|
-
alignItems: "center",
|
|
1148
|
-
justifyContent: "center",
|
|
1149
|
-
paddingHorizontal: s.lg,
|
|
1150
|
-
borderRadius: r.pill,
|
|
1151
|
-
backgroundColor: c.brand
|
|
1152
|
-
},
|
|
1153
|
-
actionLabel: { fontFamily: t.family, color: c.onPrimary, fontSize: t.size.body, fontWeight: weightLabel },
|
|
1154
|
-
// The over-length state. Opacity alone would carry the meaning by appearance only, so the control also
|
|
1155
|
-
// sets `disabled` and `accessibilityState.disabled`, which is what a screen reader announces.
|
|
1156
|
-
actionButtonDisabled: { opacity: 0.45 },
|
|
1157
|
-
actionLabelDisabled: { color: c.onPrimary },
|
|
1158
|
-
// Everfur's own attribution: small, muted, centered under the disclaimer.
|
|
1159
|
-
poweredBy: {
|
|
1160
|
-
fontFamily: t.family,
|
|
1161
|
-
color: c.text.muted,
|
|
1162
|
-
fontSize: t.size.micro,
|
|
1163
|
-
textAlign: "center",
|
|
1164
|
-
paddingBottom: s.xs
|
|
1165
|
-
}
|
|
1166
|
-
});
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
exports.EverfurChat = EverfurChat;
|
|
1170
|
-
exports.useEverfurChat = useEverfurChat;
|
|
1
|
+
'use strict';var react=require('react'),reactNative=require('react-native'),reactNativeSafeAreaContext=require('react-native-safe-area-context'),jsxRuntime=require('react/jsx-runtime');var pl=Object.defineProperty;var i=(e,t)=>pl(e,"name",{value:t,configurable:true});var gr=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(gr.map(e=>e.wireCode));var fl=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"}),Wn=Object.freeze(gr.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:fl[e.wireCode]}))),yl=new Map(Wn.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),ml=Object.freeze(["http_envelope",...[...new Set(Wn.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function wt(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let n of [t??"http_envelope",...ml]){let o=yl.get(n+r);if(o)return o}}i(wt,"contractErrorFor");function gl(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(gl,"contractDocUrl");function Gn(e){return null}i(Gn,"publishedDocUrl");var hl=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 qn(e){return hl[e]}i(qn,"categoryFor");function Yn(e){let t=wt(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":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"}}i(Yn,"fromWire");var bl=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function hr(e){return bl.has(e)}i(hr,"isAutoRetryable");var vl=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function Kn(e){return hr(e)||vl.has(e)}i(Kn,"isRetryableCode");var Cl=500,br=8e3,$n=4;function Qn(e,t=Math.random){let r=Math.max(0,e),n=Math.min(Cl*2**r,br);return Math.floor(t()*n)}i(Qn,"backoffDelayMs");var El=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 vr(e){return El[e]}i(vr,"userFacingError");function Xn(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(Xn,"defineHidden");var Rl=/^[a-z][a-z0-9_]{0,63}$/;function j(e,t){let r=wt(t?.wireCode,t?.wireEnvelope),n={code:e,category:qn(e),retryable:t?.retryable??Kn(e),displayMessage:vr(e)};if(t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&Rl.test(t.reasonCode)&&(n.reasonCode=t.reasonCode),r);return t?.wireMessage&&Xn(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Xn(n,"raw",t.raw),Object.freeze(n)}i(j,"makeEverfurError");function le(e,t){return Object.freeze(t===void 0?{ok:true,value:e}:{ok:true,value:e,warning:t})}i(le,"ok");function V(e){return Object.freeze({ok:false,error:e})}i(V,"err");var _t=class _t extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,_t.prototype);}};i(_t,"EverfurConfigError");var lt=_t;var p=Object.freeze({placeholder:"Message",send:"Send",stop:"Stop",retry:"Try again",followUps:"Follow up questions",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",typing:"Assistant is typing",loading:"Loading",empty:"No messages yet",transcript:"Conversation",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\u2026",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",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",showLatestVetAlert:"Show latest vet alert",dismissBanner:"Dismiss {label} banner",openMenu:"Open menu",openMenuUnread:"Open menu, unread chats",yourPets:"Your Pets",yourPet:"Your pet",switchActivePet:"Switch active pet, {name}",petCurrentlyActive:"{name}, currently active",switchToPet:"Switch to {name}",activePrefix:"Active \xB7 ",close:"Close",addAnotherPet:"Add another pet",addPet:"Add a pet",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 B(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let o=t[n];return o===void 0?r:String(o)})}i(B,"fillCopy");var Cr=Object.freeze([Object.freeze({key:"inaccurate",label:p.feedbackReasonInaccurate,feedbackType:"wrong"}),Object.freeze({key:"outdated",label:p.feedbackReasonOutdated,feedbackType:"outdated"}),Object.freeze({key:"unsafe",label:p.feedbackReasonUnsafe,feedbackType:"dangerous"}),Object.freeze({key:"unclear",label:p.feedbackReasonUnclear,feedbackType:"unclear"}),Object.freeze({key:"other",label:p.feedbackReasonOther,feedbackType:"not_helpful"})]),Zn=Object.freeze([Object.freeze({sentiment:"up",label:p.feedbackHelpful}),Object.freeze({sentiment:"neutral",label:p.feedbackNeutral}),Object.freeze({sentiment:"down",label:p.feedbackNotHelpful})]);function Sl(e){switch(e){case "up":return "helpful";case "neutral":return "neutral";case "down":return "not_helpful"}}i(Sl,"sentimentToFeedbackType");function Jn(e,t){if(e==="down"&&t!==null){let r=Cr.find(n=>n.key===t);if(r!==void 0)return r.feedbackType}return Sl(e)}i(Jn,"feedbackTypeFor");var eo=Symbol.for("@everfur/sdk#EverfurContext@v1"),to=globalThis,ro=to[eo]??(to[eo]=react.createContext(null));ro.displayName??="EverfurContext";function ie(){let e=react.useContext(ro);if(e===null)throw new lt("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(ie,"useEverfurContext");var xl=Object.freeze({status:"idle",messages:Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:Object.freeze([]),unreadCount:null});function xt(e){let{runtime:t,userRef:r,activePet:n,scopeEpoch:o}=ie(),a=e?.petRef??n??null,s=e?.conversationId??null,d=react.useMemo(()=>({runtime:t,userRef:r,petRef:a,conversationId:s,scopeEpoch:o}),[t,r,a,s,o]),[l,c]=react.useState(null),u=l?.scope===d?l.controller:t.registry.peekChat({userRef:r,petRef:a,conversationId:s}),f=react.useRef(null);react.useEffect(()=>{let P=t.registry.acquireChat({userRef:r,petRef:a,conversationId:s});return f.current=P,c({scope:d,controller:P}),()=>{f.current=null,c(k=>k?.controller===P?null:k),t.registry.releaseChat(P);}},[t,r,a,s,o,d]);let y=react.useCallback(P=>u?u.subscribe(P):Il,[u]),b=react.useCallback(()=>u?u.getSnapshot():xl,[u]),g=react.useSyncExternalStore(y,b,b),x=react.useCallback((P,k)=>u&&f.current===u&&!u.getSnapshot().isBootstrapping?Rr(u,u.send(P,k?.imageS3Keys===void 0?{}:{imageS3Keys:k.imageS3Keys}),()=>f.current===u):Promise.resolve(Sr()),[u]),m=react.useCallback(P=>u&&f.current===u&&!u.getSnapshot().isBootstrapping?Rr(u,u.askEverfur(P),()=>f.current===u):Promise.resolve(Sr()),[u]),T=react.useCallback(()=>u&&f.current===u?Rr(u,u.retryLast(),()=>f.current===u):Promise.resolve(Sr()),[u]),I=react.useCallback(()=>{u&&f.current===u&&u.stop();},[u]),O=react.useCallback(()=>{u&&f.current===u&&u.adoptConversation(null);},[u]),[F,h]=react.useState({controller:null,byMessage:{}}),E=F.controller===u?F.byMessage:Al,R=react.useCallback(async(P,k,M,H)=>{if(!u||f.current!==u)return V(j("accessDenied"));let X=String(P),U=F.controller===u?F.byMessage[X]:void 0;if(U===k&&M==null)return h(oe=>{let z={...oe.controller===u?oe.byMessage:{}};return delete z[X],{controller:u,byMessage:z}}),le(Object.freeze({feedbackId:""}));h(oe=>({controller:u,byMessage:{...oe.controller===u?oe.byMessage:{},[X]:k}}));let te=await u.submitFeedback(P,Jn(k,M??null),H??null);return f.current!==u?V(j("accessDenied")):(te.ok||h(oe=>{let z={...oe.controller===u?oe.byMessage:{}};return U===void 0?delete z[X]:z[X]=U,{controller:u,byMessage:z}}),te)},[u,F]),L=react.useMemo(()=>{let P=i(async k=>{if(!u||f.current!==u)return V(j("accessDenied"));let M=await k(u);return f.current===u?M:V(j("accessDenied"))},"run");return {listConversations:i(k=>P(M=>M.listConversations({...a?{petRef:a}:{},...k})),"listConversations"),getMessages:i((k,M)=>P(H=>H.getMessages(k,M)),"getMessages"),resumeConversation:i(k=>P(M=>M.resumeConversation(k)),"resumeConversation"),loadOlderMessages:i(()=>P(k=>k.loadOlderMessages()),"loadOlderMessages"),markRead:i(()=>P(k=>k.markRead()),"markRead"),refreshActiveThread:i(()=>P(k=>k.refreshActiveThread()),"refreshActiveThread"),answerCheckin:i((k,M)=>P(H=>H.answerCheckin(k,M)),"answerCheckin"),openCheckin:i(k=>P(M=>M.openCheckin(k)),"openCheckin")}},[u,a]);return react.useMemo(()=>({status:g.status,messages:g.messages,conversationId:g.conversationId,petRef:a,error:g.error,isStreaming:g.isStreaming,isBootstrapping:g.isBootstrapping,historyCursor:g.historyCursor??null,isLoadingHistory:g.isLoadingHistory??false,stopped:g.stopped??false,reconnecting:g.reconnecting??false,...L,suggestedPrompts:g.suggestedPrompts,unreadCount:g.unreadCount,hasUnreadThreads:g.hasUnreadThreads??false,newConversation:O,sentimentByMessage:E,feedback:R,send:x,askEverfur:m,retryLast:T,stop:I}),[g,a,x,m,T,I,L,O,E,R])}i(xt,"useEverfurChat");var Il=i(()=>{},"NOOP_UNSUBSCRIBE"),Al=Object.freeze({});async function Rr(e,t,r){for await(let o of t);if(!r())return V(j("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?V(n.error):le(Ol(n.messages))}i(Rr,"driveToResult");function Ol(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}i(Ol,"lastAssistantResponseId");function Sr(){return V(j("internalError",{retryable:true}))}i(Sr,"notReadyError");function Pr(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.keys(e))Pr(e[t]);}return e}i(Pr,"deepFreeze");var Fl=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),io={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},ao={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},oo={nano:8,small:9,micro:10,tiny:11,caption:12,bodyTight:13,body:14,subtitle:16,heading:18,verdict:24},Ml={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Vl={regular:"400",medium:"500",bold:"700"},Dl={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},Ll=0,It="System",At="monospace",Nl=["content","heading","control","compact","badge"];function Hl(e){let t={};for(let r of Nl)t[r]=e;return t}i(Hl,"authoredTierSizes");function so(){return {family:It,mono:At,fontUrl:null,families:{regular:It,medium:It,bold:It,mono:At,monoMedium:At,monoBold:At},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:oo,tierSizes:Hl(oo),lineHeight:Ml,weight:Vl,letterSpacing:Dl,scale:1,maxScale:Ll,scaleCaps:Fl}}i(so,"baseType");var lo={},Le=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function Ot(e){return `cubic-bezier(${e.join(", ")})`}i(Ot,"cssCubicBezier");var co={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:Ot(Le.standard),emphasized:Ot(Le.emphasized),exit:Ot(Le.exit)},reducedMotion:false},Ul={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)"},uo=Pr({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Ul,space:io,radius:ao,type:so(),motion:co,slots:lo}),zl={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)"};Pr({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:zl,space:io,radius:ao,type:so(),motion:co,slots:lo});var po=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),fo=globalThis,Tr=fo[po]??(fo[po]=react.createContext(uo));Tr.displayName??="EverfurThemeContext";function _(){return react.useContext(Tr)}i(_,"useEverfurTheme");function Yl(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(Yl,"tierMultiplier");function v({tier:e="content",...t}){let{type:r}=_(),n=Yl(r,e);return react.createElement(reactNative.Text,n===void 0?t:{maxFontSizeMultiplier:n,...t})}i(v,"Text");var Qe=react.forwardRef(i(function(t,r){return react.createElement(reactNative.TextInput,{...t,...r===null?{}:{ref:r}})},"TextInput"));function Ft(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(Ft,"assertNever");function mo(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})}i(mo,"errorFrame");function re(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}i(re,"slotBox");function kr(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}i(kr,"ownGroundSlot");function fe(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(fe,"slotText");var Ql=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function C(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[Ql[t]]}}i(C,"face");function Xl(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:t["x-everfur-partner-key"]=e.publishableKey,e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}i(Xl,"authHeaders");function dt(e,t){return {...e,headers:{...Zl(e.headers),...Xl(t)}}}i(dt,"withAuthHeaders");function Zl(e){if(!e)return {};let t={};for(let[r,n]of Object.entries(e)){let o=r.toLowerCase();o==="authorization"||o==="x-everfur-partner-key"||(t[r]=n);}return t}i(Zl,"stripAuthHeaders");async function go(e,t){if(t.mode==="anonymous")return t.transport.request(dt(e,{mode:"anonymous",publishableKey:t.publishableKey,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));let r;try{r=await t.identity.currentToken();}catch{return V(wr())}let n=await t.transport.request(dt(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let o;try{o=await t.identity.currentToken({forceRefresh:!0});}catch{return V(wr())}let a=await t.transport.request(dt(e,{mode:"personalized",token:o,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !a.ok&&a.error.httpStatus===401?V(wr(a.error.httpStatus)):a}i(go,"authedSend");function wr(e){return j("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(wr,"authRejectedError");function ho(e){return j("internalError",{retryable:true,wireMessage:Jl(e)})}i(ho,"networkError");function Jl(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(Jl,"describeCause");var ed=3e4,td=br*2,rd="idempotency-key",nd=new Set(["POST","PUT","PATCH","DELETE"]),od=Object.freeze({onEvent(){}}),id=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function Ne(e){let t=e.observer??od,r=e.timers??id,n=e.rng??Math.random,o=e.sleep??((y,b)=>bd(y,r,b)),a=e.maxAttempts??$n,s=e.unaryTimeoutMs??ed,d=e.newIdempotencyKey??sd(),l=i(y=>{try{t.onEvent(y);}catch{}},"emit");async function c(y,b,g){let x=g?.maxAttempts,m=Math.max(1,x??a),I=g?.idempotent??nd.has(b.method)?d():null,O=ad(b,I),F=0;for(;;){let h=i(H=>Object.freeze({call:y,method:b.method,path:b.path,attempt:F,...I?{idempotencyKey:I}:{},...H}),"stamp");l(h({phase:"attempt"}));let E=gd(s,r),R=hd(E.signal,b.signal),L;try{L=await go({...O,signal:R.signal},e.auth);}catch(H){L=V(ho(H));}finally{R.dispose(),E.cancel();}if(L.ok)return l(h({phase:"settled",ok:true,reason:"ok"})),L;let P=L.error,k=dd(P,F,{maxAttempts:m,rng:n,now:r.now(),aborted:b.signal?.aborted===true,...x!==void 0?{perCallMaxAttempts:x}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),M={ok:false,code:P.code,reason:k.reason,...P.httpStatus!==void 0?{httpStatus:P.httpStatus}:{},...P.requestId!==void 0?{requestId:P.requestId}:{}};if(!k.retry)return l(h({phase:"settled",...M})),V(P);if(l(h({phase:"retry",...M,delayMs:k.delayMs})),await o(k.delayMs,b.signal),b.signal?.aborted===true)return l(h({phase:"settled",...M,reason:"aborted"})),V(P);F+=1;}}i(c,"send");async function u(y){return dt(y,await md(e.auth))}i(u,"authorize");async function*f(y,b,g){l(Object.freeze({call:y,phase:"stream.open",method:b.method,path:b.path,attempt:0}));try{yield*e.auth.transport.stream(b,g);}catch{yield mo({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(f,"stream"),Object.freeze({send:c,authorize:u,stream:f})}i(Ne,"createRequestFunnel");function ad(e,t){let r={};for(let[n,o]of Object.entries(e.headers??{}))n.toLowerCase()!==rd&&(r[n]=o);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(ad,"assembleHeaders");function sd(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(sd,"defaultIdempotencyKeyFactory");var ld=10;function dd(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let n=cd(e);if(n==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!hr(e.code))return {retry:false,reason:"terminal-code"};let o=n==="burst"?"burst-throttle":"retryable-code";if(i(()=>{if(r.policy===void 0)return false;try{return !r.policy.shouldRetry(e.code,t)}catch{return false}},"policyVetoedRetry")())return {retry:false,reason:"terminal-code"};let s=i(()=>{if(r.policy===void 0)return null;let c;try{c=r.policy.maxAttempts(e.code);}catch{return null}return typeof c!="number"||!Number.isFinite(c)?null:Math.max(1,Math.min(ld,Math.floor(c)))},"policyCeiling"),d=r.perCallMaxAttempts??s()??r.maxAttempts;if(t+1>=d)return {retry:false,reason:"attempts-exhausted"};let l=ud(e,r.now);return l!==null?l>td?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:o,delayMs:l}:{retry:true,reason:o,delayMs:Qn(t,r.rng)}}i(dd,"decideRetry");function cd(e){let t=e.code==="unknown"?Yn(yd(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(cd,"throttleKind");function ud(e,t){let r=pd(e.raw);if(r===null)return null;let n=r-t;return n>0?n:0}i(ud,"retryOverrideMs");function pd(e){for(let t of vo(e)){let r=t.resets_at,n=fd(r);if(n!==null)return n}return null}i(pd,"findResetsAt");function vo(e){if(!bo(e))return [];let t=[e];for(let r of ["error","detail"]){let n=e[r];bo(n)&&t.push(n);}return t}i(vo,"candidateScopes");function fd(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}i(fd,"parseInstantMs");function yd(e){for(let t of vo(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i(yd,"rawWireCode");function bo(e){return typeof e=="object"&&e!==null}i(bo,"isRecord");async function md(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}:{}}}i(md,"resolveDeviceAuth");function gd(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(n),"cancel")}}i(gd,"boundedSignal");function hd(e,t){let r=i(()=>{},"noop");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 o=i(()=>n.abort(),"onAbort");return e.addEventListener("abort",o,{once:true}),t.addEventListener("abort",o,{once:true}),{signal:n.signal,dispose:i(()=>{e.removeEventListener("abort",o),t.removeEventListener("abort",o);},"dispose")}}i(hd,"mergeSignals");function bd(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let o=t.setTimeout(()=>{r?.removeEventListener("abort",a),n();},e),a=i(()=>{t.clearTimeout(o),n();},"onAbort");r?.addEventListener("abort",a,{once:true});})}i(bd,"delayAbortable");function Mt(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let n=e.charCodeAt(t+1);if(!(n>=56320&&n<=57343))return true;t+=1;}else if(r>=56320&&r<=57343)return true}return false}i(Mt,"hasLoneSurrogate");function Vt(e){return [...e].length}i(Vt,"serverLength");var Co=Object.freeze(["better","same","worse"]);var Eo=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function Ro(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let o={handle:void 0},a=i(()=>{r.clearTimeout(o.handle),t.removeEventListener("abort",a),n();},"done");o.handle=r.setTimeout(a,e),t.addEventListener("abort",a,{once:true});})}i(Ro,"delayAbortable");var vd="watching";function So(e){return e.status!=null&&e.status!==vd}i(So,"isCheckinSettled");var Po=5,_r=4e3;var xr=4e3;var Cd=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function To(e){return e!==Cd}i(To,"isUploadTransportAvailable");var Ed=Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var Dt=10*1024*1024,Lt=Po,ct=120,Rd="/widget/v1/uploads/initiate";function Sd(e){return typeof e=="string"&&Ed.includes(e.trim().toLowerCase())}i(Sd,"isAttachmentMime");function Ir(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<=ct)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,ct);let n=t.slice(r);return n.length>=ct?t.slice(0,ct):`${t.slice(0,r).slice(0,ct-n.length)}${n}`}i(Ir,"sanitizeFilename");function Ar(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i(Ar,"formatBytes");var ut=i(e=>Object.freeze({ok:true,value:e}),"ok"),ye=i(e=>Object.freeze({ok:false,error:e}),"err");function Z(e,t,r,n){return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}i(Z,"failure");function Pd(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}i(Pd,"attachmentSize");function Td(e){let t=Ir(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!Sd(r))return ye(Z("unsupported_type",false,t));let n=Pd(e);return n===null?ye(Z("unknown",false,t)):n>Dt?ye(Z("too_large",false,t,{sizeBytes:n})):ut(Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}i(Td,"validateAttachment");function kd(e){if(typeof e!="object"||e===null)return null;let t=e,r=i(c=>typeof c=="string"&&c.length>0?c:null,"str"),n=i(c=>typeof c=="number"&&Number.isFinite(c)?c:null,"num"),o=r(t.upload_id),a=r(t.upload_url),s=r(t.s3_key);if(o===null||a===null||s===null)return null;let d={},l=t.upload_fields;if(typeof l=="object"&&l!==null)for(let[c,u]of Object.entries(l))typeof u=="string"&&(d[c]=u);return Object.freeze({upload_id:o,upload_url:a,upload_fields:Object.freeze(d),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??Dt,s3_key:s,purpose:r(t.purpose)})}i(kd,"parsePolicy");function wd(e,t){let r=e.httpStatus;switch(e.code){case "quotaExceeded":return Z("quota_exceeded",false,t,{cause:e});case "rateLimited":return Z("rate_limited",true,t,{cause:e});case "idempotencyConflict":case "idempotencyInFlight":return Z("idempotency_conflict",true,t,{cause:e});case "validationFailed":return Z("unsupported_type",false,t,{cause:e});case "serviceUnavailable":case "streamTimeout":return Z("network",true,t,{cause:e});default:return r===429?Z("rate_limited",true,t,{cause:e}):r===503?Z("network",true,t,{cause:e}):r===void 0?Z("network",true,t,{cause:e}):Z("server",e.retryable,t,{httpStatus:r,cause:e})}}i(wd,"initiateFailure");async function _d(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:Rd,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return ye(wd(n.error,t.filename));let o=kd(n.value);return o===null?ye(Z("server",false,t.filename)):ut(o)}i(_d,"initiateAttachmentUpload");async function xd(e,t,r,n){let o=i(()=>n?.signal?.aborted===true,"cancelled");if(o())return ye(Z("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),ut(void 0)}catch{return o()?ye(Z("cancelled",true,r.filename)):ye(Z("server",true,r.filename))}}i(xd,"uploadAttachmentBytes");var Id=2,Ad=3,Od=Object.freeze([1e3,2e3,4e3]),ko=0;function Fd(){return ko+=1,`attachment-${ko}`}i(Fd,"defaultNewId");function wo(e){let t=Math.max(1,e.concurrency??Id),r=Math.max(1,e.maxAttempts??Ad),n=e.backoffMs??Od,o=Math.max(1,e.maxPerMessage??Lt),a=e.timers??Eo,s=e.newId??Fd,d=To(e.transport),l=new Map,c=[],u=[],f=new Set,y=new Set,b=Object.freeze({attachments:Object.freeze([])}),g=false,x=i(()=>{b=Object.freeze({attachments:Object.freeze(c.flatMap(h=>{let E=l.get(h);return E===void 0?[]:[E.state]}))});for(let h of y)h();},"publish"),m=i((h,E)=>{h.state=Object.freeze({...h.state,...E}),x();},"patch"),T=i(()=>{for(;!g&&f.size<t&&u.length>0;){let h=u.shift(),E=l.get(h);E!==void 0&&(f.add(h),I(E).finally(()=>{f.delete(h),T();}));}},"pump"),I=i(async h=>{let{attachment:E}=h;for(;h.attempts<r;){if(g||h.controller.signal.aborted)return;h.attempts+=1;let R=h.controller.signal;m(h,{status:"uploading",error:null,progress:0});let L=await _d(e.funnel,E,{signal:R});if(g||R.aborted)return;let P;if(!L.ok)P=ye(L.error);else {let X=await xd(e.transport,L.value,E,{signal:R,onProgress:i(U=>{!R.aborted&&h.state.status==="uploading"&&m(h,{progress:Md(U)});},"onProgress")});if(g||R.aborted)return;P=X.ok?ut(L.value.s3_key):ye(X.error);}if(P.ok){m(h,{status:"uploaded",s3Key:P.value,error:null,progress:1});return}let k=P.error,M=k.retryable&&h.attempts<r;if(m(h,{status:M?"uploading":"failed",error:k,progress:0}),!M)return;let H=n[Math.min(h.attempts-1,n.length-1)]??0;await Ro(H,R,a);}},"run"),O=i(h=>{u.push(h.state.id),T();},"enqueue"),F={available:d,subscribe(h){return y.add(h),()=>{y.delete(h);}},getSnapshot:i(()=>b,"getSnapshot"),get uploading(){return b.attachments.some(h=>h.status==="uploading")},get s3Keys(){return b.attachments.flatMap(h=>h.status==="uploaded"&&h.s3Key!==null?[h.s3Key]:[])},add(h){let E=Td(h);if(!E.ok)return E;if(g||c.length>=o)return ye(Z("too_many",false,E.value.filename));let R=s(),L={attachment:E.value,controller:new AbortController,attempts:0,state:Object.freeze({id:R,filename:E.value.filename,previewUri:h.uri,contentType:E.value.contentType,sizeBytes:E.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return l.set(R,L),c.push(R),x(),O(L),ut(L.state)},retry(h){let E=l.get(h);E===void 0||g||E.state.status!=="failed"||(E.controller=new AbortController,E.attempts=0,m(E,{status:"uploading",error:null,progress:0,s3Key:null}),O(E));},remove(h){let E=l.get(h);if(E===void 0)return;E.controller.abort(),l.delete(h);let R=c.indexOf(h);R>=0&&c.splice(R,1);let L=u.indexOf(h);L>=0&&u.splice(L,1),x();},clear(){for(let h of [...c])F.remove(h);},dispose(){g=true;for(let h of l.values())h.controller.abort();l.clear(),c.length=0,u.length=0,y.clear(),b=Object.freeze({attachments:Object.freeze([])});}};return F}i(wo,"createAttachmentQueue");function Md(e){return Number.isNaN(e)||e<0?0:e>1?1:e}i(Md,"clamp");function xo(e){switch(e.code){case "too_large":return B(p.attachmentTooLarge,{max:Ar(Dt),filename:e.filename,size:Ar(e.sizeBytes??0)});case "too_many":return B(p.attachmentTooMany,{max:Lt});case "unsupported_type":return B(p.attachmentUnsupported,{filename:e.filename});case "network":return p.attachmentNetwork;case "server":return B(p.attachmentServer,{status:e.httpStatus?` (${e.httpStatus})`:""});case "cancelled":return p.attachmentCancelled;case "rate_limited":return p.attachmentRateLimited;case "quota_exceeded":return p.attachmentQuota;case "idempotency_conflict":return p.attachmentConflict;case "unknown":return p.attachmentUnknown}}i(xo,"attachmentErrorMessage");function Io(e,t){return B(e>=t?p.attachmentsFull:p.addAttachment,{used:e,total:t})}i(Io,"attachControlLabel");var Nd=Object.freeze({attachments:Object.freeze([])});function Or(e={}){let{runtime:t,userRef:r,scopeEpoch:n}=ie(),o=e.maxPerMessage??Lt,a=react.useMemo(()=>{if(e.queue)return e.queue;let{services:m}=t.registry;return wo({funnel:Ne({auth:m.authFor(r),...m.errorPolicy?{errorPolicy:m.errorPolicy}:{}}),transport:e.transport??m.uploadTransport,maxPerMessage:o})},[t,r,n,o,e.queue,e.transport]);react.useEffect(()=>()=>{a!==e.queue&&a.dispose();},[a,e.queue]);let s=react.useSyncExternalStore(a.subscribe,a.getSnapshot,()=>Nd),[d,l]=react.useState(null),c=react.useCallback(m=>{let I=(Array.isArray(m)?m:[m]).map(F=>a.add(F)),O=I.find(F=>!F.ok);return O!==void 0&&!O.ok&&l(O.error),I},[a,l]),u=react.useCallback(m=>a.retry(m),[a]),f=react.useCallback(m=>a.remove(m),[a]),y=react.useCallback(()=>a.clear(),[a]),b=react.useCallback(()=>l(null),[l]),g=s.attachments.some(m=>m.status==="uploading"),x=s.attachments.some(m=>m.status==="failed");return react.useMemo(()=>({available:a.available,attachments:s.attachments,maxPerMessage:o,uploading:g,failed:x,blocked:g||x,s3Keys:s.attachments.flatMap(m=>m.status==="uploaded"&&m.s3Key!==null?[m.s3Key]:[]),rejected:d,add:c,retry:u,remove:f,clear:y,dismissRejected:b}),[a.available,s,o,g,x,d,c,u,f,y,b])}i(Or,"useChatAttachments");var Ao=Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function Nt(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(Ao,t)?Ao[t]:null}i(Nt,"canonicalPetSpecies");var Oo=50,Hd=128,Fr=120,Fo=120,Ud=2e3,Mo=120,zd=80,Lo=new Set(["male","female","unknown"]),No=new Set(["day","month","year"]),Ho=new Set(["low","medium","high","athletic"]),Uo=new Set(["indoor","outdoor","both"]),zo=new Set(["mild","moderate","severe"]),Bd=/^(\d{4})-(\d{2})-(\d{2})$/,Bo=[["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"]],jo=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];Object.freeze([...Bo,...jo].map(([e])=>e));function jd(e){let t=Bd.exec(e);if(t===null)return false;let[r,n,o]=[Number(t[1]),Number(t[2]),Number(t[3])],a=new Date(Date.UTC(r,n-1,o));return a.getUTCFullYear()===r&&a.getUTCMonth()===n-1&&a.getUTCDate()===o}i(jd,"isRealDate");var yt=i(e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,"oneOf"),Wd=i((e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,"boolean"),Ut=i((e,t)=>typeof t=="string"&&jd(t)?null:`${e} must be a real date written YYYY-MM-DD`,"date"),ve=i((e,t={})=>(r,n)=>{if(typeof n!="string")return `${r} must be a string`;if(Mt(n))return `${r} contains an unpaired surrogate and cannot be encoded`;let o=t.trimmed?n.trim():n;if(t.required&&o.length===0)return `${r} is required and must not be blank`;let a=Vt(o);return a<=e?null:`${r} is ${a} characters; the server accepts at most ${e}`},"text"),Gd={sex:yt(Lo),spayedNeutered:Wd,birthDate:Ut,birthDatePrecision:yt(No),activityLevel:yt(Ho),indoorOutdoor:yt(Uo),foodBrand:ve(Mo),foodType:ve(Mo),microchipId:ve(zd)},Mr=["ref","ref",false,ve(Hd,{required:true,trimmed:true})],Vr=["notes","notes",false,ve(Ud,{trimmed:true})],Vo=[Mr,["name","name",true,ve(Fr,{required:true,trimmed:true})],["dose","dose",false,ve(Fo,{trimmed:true})],["frequency","frequency",false,ve(Fo,{trimmed:true})],["startDate","start_date",false,Ut],["endDate","end_date",false,Ut],Vr],qd={allergies:[Mr,["allergen","allergen",true,ve(Fr,{required:true,trimmed:true})],["severity","severity",false,yt(zo)],Vr],medications:Vo,supplements:Vo,conditions:[Mr,["conditionName","condition_name",true,ve(Fr,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Ut],Vr]};function Yd(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return {error:`${n} must be an object`};let o=r,a={};for(let[l,c,u,f]of qd[e]){let y=o[l];if(y==null){if(u)return {error:`${n}.${l} is required`};y===null&&(a[c]=null);continue}let b=f(`${n}.${l}`,y);if(b!==null)return {error:b};a[c]=y;}let s=a.start_date,d=a.end_date;return typeof s=="string"&&typeof d=="string"&&d<s?{error:`${n}.endDate must not be before startDate`}:{item:a}}i(Yd,"itemToWire");function Kd(e,t){if(!Array.isArray(t))return {error:`${e} must be an array (send [] to clear it)`};if(t.length>Oo)return {error:`${e} has ${t.length} items; the server accepts at most ${Oo}`};let r=[],n=new Set;for(let o=0;o<t.length;o+=1){let a=Yd(e,o,t[o]);if("error"in a)return a;let s=a.item.ref;if(typeof s=="string"){let d=s.trim();if(n.has(d))return {error:`${e}: ref ${JSON.stringify(d)} is used twice; a ref names one item`};n.add(d);}r.push(a.item);}return {items:r}}i(Kd,"listToWire");function Wo(e,t){let r=e,n={};for(let[s,d]of Bo){let l=r[s];if(l!==void 0){if(l!==null){let c=Gd[s](s,l);if(c!==null)return {error:c}}n[d]=l;}}let o=r.birthDate!==void 0,a=r.birthDatePrecision!==void 0;if(o!==a||o&&r.birthDate===null!=(r.birthDatePrecision===null))return {error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[s,d]of jo){let l=r[s];if(l===void 0)continue;let c=Kd(s,l);if("error"in c)return c;n[d]=c.items;}return Object.keys(n).length>0&&t!==void 0&&Nt(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}}i(Wo,"petHealthToWire");var K=i(e=>typeof e=="string"?e:null,"str"),ft=i((e,t)=>typeof t=="string"&&e.has(t)?t:null,"pick"),$d=i(e=>typeof e=="boolean"?e:null,"bool");function Ht(e,t){return Array.isArray(e)?Object.freeze(e.flatMap(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return [];let n=t(r);return n===null?[]:[n]})):Object.freeze([])}i(Ht,"itemsFromWire");function Do(e){let t=K(e.name);return t===null||t.length===0?null:Object.freeze({ref:K(e.ref),name:t,dose:K(e.dose),frequency:K(e.frequency),startDate:K(e.start_date),endDate:K(e.end_date),notes:K(e.notes)})}i(Do,"medicationFromWire");function Go(e){let t=e.profile_version;return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:ft(Lo,e.sex),spayedNeutered:$d(e.spayed_neutered),birthDate:K(e.birth_date),birthDatePrecision:ft(No,e.birth_date_precision),activityLevel:ft(Ho,e.activity_level),indoorOutdoor:ft(Uo,e.indoor_outdoor),foodBrand:K(e.food_brand),foodType:K(e.food_type),microchipId:K(e.microchip_id),allergies:Ht(e.allergies,r=>{let n=K(r.allergen);return n===null||n.length===0?null:Object.freeze({ref:K(r.ref),allergen:n,severity:ft(zo,r.severity),notes:K(r.notes)})}),medications:Ht(e.medications,Do),supplements:Ht(e.supplements,Do),conditions:Ht(e.conditions,r=>{let n=K(r.condition_name);return n===null||n.length===0?null:Object.freeze({ref:K(r.ref),conditionName:n,diagnosedDate:K(r.diagnosed_date),notes:K(r.notes)})})})}i(Go,"petHealthFromWire");var Ko=100,$o=50,Qo=100,Xo=50,Zo=500,Qd=128,Xd=6e4;function Ee(e){return j("validationFailed",{retryable:false,wireMessage:e})}i(Ee,"invalid");function He(e,t,r){if(typeof t!="string")return Ee(`${e} must be a string`);let n=Vt(t);return n<=r?null:Ee(`${e} is ${n} characters; the server accepts at most ${r}`)}i(He,"checkString");function zt(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:Ee(`${e} must be a finite number between 0 and ${r}`)}i(zt,"outOfRange");function qo(e,t){if(typeof e!="string")return Ee("pet_ref must be a string");if(e.trim().length===0)return Ee("pet_ref must not be blank");if(Mt(e))return Ee("pet_ref contains an unpaired surrogate and cannot be encoded");if(t!=null&&typeof t!="object")return Ee("profile must be an object");let r=[He("pet_ref",e,Qd)];return t?.name!==void 0&&r.push(He("name",t.name,Ko)),t?.species!==void 0&&r.push(He("species",t.species,$o)),t?.breed!==void 0&&r.push(He("breed",t.breed,Qo)),t?.ageYears!==void 0&&r.push(zt("age_years",t.ageYears,Xo)),t?.weightKg!==void 0&&r.push(zt("weight_kg",t.weightKg,Zo)),r.find(n=>n!==null)??null}i(qo,"validate");function Jo(e,t){let r=Wo(e,t);return "error"in r?{error:Ee(r.error)}:r}i(Jo,"healthToWire");function Zd(e){if(typeof e!="object"||e===null)return {error:Ee("patch must be an object")};let t=e,r=[["name","name",a=>He("name",a,Ko)],["species","species",a=>He("species",a,$o)],["breed","breed",a=>He("breed",a,Qo)],["ageYears","age_years",a=>zt("age_years",a,Xo)],["weightKg","weight_kg",a=>zt("weight_kg",a,Zo)]],n={};for(let[a,s,d]of r){let l=t[a];if(l!==void 0){if(l!==null){let c=d(l);if(c!==null)return {error:c}}n[s]=l;}}let o=Jo(t,t.species);return "error"in o?o:(Object.assign(n,o.body),Object.keys(n).length===0?{error:Ee("patch must change at least one field")}:{body:n})}i(Zd,"patchToWire");function Jd(e){if(e==null)return {body:{}};let t=Jo(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}}}i(Jd,"toWire");var Ce=i(e=>typeof e=="string"?e:null,"str"),Bt=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"num");function Yo(e,t){let r=typeof e=="object"&&e!==null?e:{};return Object.freeze({petRef:Ce(r.pet_ref)??t,name:Ce(r.name),species:Ce(r.species),breed:Ce(r.breed),ageYears:Bt(r.age_years),weightKg:Bt(r.weight_kg)})}i(Yo,"fromWire");function ei(e){if(typeof e!="object"||e===null)return null;let t=e,r=Ce(t.pet_ref);return r===null||r.length===0?null:Object.freeze({petId:Ce(t.pet_id),petRef:r,name:Ce(t.name),species:Ce(t.species),breed:Ce(t.breed),ageYears:Bt(t.age_years),weightKg:Bt(t.weight_kg),updatedAt:Ce(t.updated_at)})}i(ei,"widgetPetFromWire");function ec(e){let t=ei(e);return t===null?null:Object.freeze({...t,...Go(e)})}i(ec,"widgetPetProfileFromWire");function tc(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];return Object.freeze(t.flatMap(r=>{let n=ei(r);return n===null?[]:[n]}))}i(tc,"petListFromWire");function jt(e){return rc(Ne({auth:e}),Ne({auth:e,unaryTimeoutMs:Xd}))}i(jt,"createPetsRepository");function rc(e,t=e){let r=i((o,a)=>a?{...o,signal:a}:o,"withSignal"),n=i(o=>qo(o,void 0)??`/widget/v1/pets/${encodeURIComponent(o)}`,"petPath");return {async list(o){let a=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},o?.signal));return a.ok?le(tc(a.value)):V(a.error)},async registerPet(o,a,s){let d=qo(o,a);if(d!==null)return V(d);let l=Jd(a);if("error"in l)return V(l.error);let u={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(o)}`,body:l.body},f=await e.send("pets.registerPet",s?.signal?{...u,signal:s.signal}:u);return f.ok?le(Yo(f.value,o)):V(f.error)},async updatePet(o,a,s){let d=n(o);if(typeof d!="string")return V(d);let l=Zd(a);if("error"in l)return V(l.error);let c=await e.send("pets.updatePet",r({method:"PATCH",path:d,body:l.body},s?.signal));return c.ok?le(Yo(c.value,o)):V(c.error)},async getPetProfile(o,a){let s=n(o);if(typeof s!="string")return V(s);let d=await e.send("pets.getPetProfile",r({method:"GET",path:`${s}/profile`},a?.signal));if(!d.ok)return V(d.error);let l=ec(d.value);return l===null?V(j("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):le(l)},async deletePet(o,a){let s=n(o);if(typeof s!="string")return V(s);let d=await e.send("pets.deletePet",r({method:"DELETE",path:s},a?.signal));return d.ok?le(void 0):V(d.error)},async eraseUserData(o){let a=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},o?.signal),{maxAttempts:1});return a.ok?le(void 0):V(a.error)}}}i(rc,"createPetsRepositoryOver");var ic="pet_not_registered";function ni(e){return e!=null&&e.reasonCode===ic}i(ni,"isPetNotRegistered");var ac=Object.freeze({status:"idle",error:null,registered:null,retry:i(()=>{},"retry")});function oi(e,t,r){let{runtime:n,userRef:o,scopeEpoch:a}=ie(),s=react.useCallback(()=>jt(n.registry.services.authFor(o)),[n,o,a]),d=react.useMemo(()=>t===void 0?null:Lr(t),[t]),[l,c]=react.useState({key:null,status:"idle",error:null,registered:null}),u=react.useRef(0),f=react.useRef(r);f.current=r;let y=e===null||d===null?null:`${String(o)}|${a}|${e}|${d}`,b=react.useCallback(()=>{if(e===null||t===void 0||y===null)return;let x=++u.current;c({key:y,status:"registering",error:null,registered:null}),s().registerPet(e,t).then(m=>{x===u.current&&(m.ok?(c({key:y,status:"registered",error:null,registered:m.value}),f.current?.()):c({key:y,status:"failed",error:m.error,registered:null}));});},[s,e,y]);react.useEffect(()=>{if(y===null){u.current+=1;return}return b(),()=>{u.current+=1;}},[y,b]);let g=react.useCallback(()=>{l.status==="failed"&&b();},[l.status,b]);return react.useMemo(()=>y===null?ac:l.key!==y?{status:"registering",error:null,registered:null,retry:g}:{status:l.status,error:l.error,registered:l.registered,retry:g},[y,l,g])}i(oi,"useChatPetRegistration");function Lr(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(Lr).join(",")}]`:`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>`${JSON.stringify(r)}:${Lr(n)}`).join(",")}}`}i(Lr,"stableKey");var mt=Object.freeze({standard:Le.standard,emphasized:Le.emphasized,exit:Le.exit,outQuad:Object.freeze([.25,.46,.45,.94])});var ii=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:Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,reduced:false}),sc=Object.freeze({...ii,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,reduced:true});function ai(e){return e.motion.reducedMotion?sc:ii}i(ai,"chatMotion");function Wt(e,t){return Math.max(0,t)*e.followUpStaggerMs}i(Wt,"followUpDelayMs");function si(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)}i(si,"nextRevealLength");var Nr=Object.freeze({});function di(e){let[t,r]=react.useState(Nr),n=react.useRef(null),o=react.useRef([]);o.current=e.map(s=>s.id),react.useEffect(()=>{if(e.length===0){n.current=null,r(l=>l===Nr?l:Nr);return}let s=n.current;if(s===null)return;let d=e.find(l=>l.role==="user"&&!s.known.has(l.id));d!==void 0&&(n.current=null,r(l=>({...l,[d.id]:s.images})));},[e]);let a=react.useCallback(s=>{n.current=s.length===0?null:{images:s,known:new Set(o.current)};},[]);return react.useMemo(()=>({byMessage:t,stage:a}),[t,a])}i(di,"useSentImages");var fc=500;function Hr(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,fc):null}i(Hr,"sanitizeSeedPrompt");function ui(e,t,r){let n=Hr(r),o=react.useRef(e);o.current=e;let a=react.useRef(null);react.useEffect(()=>{if(n===null||t||a.current===n)return;let s=o.current;s!==void 0&&(a.current=n,Promise.resolve(s(n)).catch(()=>{}));},[n,t]);}i(ui,"useInitialAsk");function yc(e,t,r){if(e==="announced")return false;let n=r.lastRefresh;return n===null||n.conversationId!==t?false:r.now-n.at<15e3}i(yc,"isCoalesced");function pi(e,t){let r=t.activeConversationId;return r===null||r.length===0?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:yc(e,r,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:r}}i(pi,"decideChatRefresh");function Ur(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(Ur,"reportHostFailure");function mc(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(mc,"isThenable");function W(e,...t){if(typeof e=="function")try{let r=e(...t);return mc(r)&&Promise.resolve(r).then(void 0,Ur),r}catch(r){Ur(r);return}}i(W,"callHost");var fi=new WeakMap;function yi(e){if(typeof e!="function")return;let t=fi.get(e);if(t!==void 0)return t;let r=i((...n)=>{W(e,...n);},"guarded");return fi.set(e,r),r}i(yi,"guardHost");function Xe(e,...t){let r;try{r=e(...t);}catch(n){return Ur(n),Promise.resolve({ok:false,error:n})}return Promise.resolve(r).then(n=>({ok:true,value:n}),n=>({ok:false,error:n}))}i(Xe,"callHostAsync");function gi(e,t){let r=react.useRef(t);r.current=t;let n=react.useRef(null),o=react.useRef(null),a=e?.isOffline===void 0?false:W(()=>e.isOffline?.()===!0)===true,s=react.useRef(()=>{});s.current=d=>{let{conversationId:l,isTurnInFlight:c,refresh:u}=r.current,f=pi(d,{activeConversationId:l,isTurnInFlight:c,isOffline:a,lastRefresh:n.current,now:Date.now()});if(f.action!=="skip"){if(f.action==="defer"){o.current!=="announced"&&(o.current=d);return}o.current=null,n.current={conversationId:f.conversationId,at:Date.now()},u!==void 0&&Promise.resolve(u()).catch(()=>{});}},react.useEffect(()=>{if(t.isTurnInFlight||a)return;let d=o.current;d!==null&&s.current(d);},[t.isTurnInFlight,a]),react.useEffect(()=>{if(e===void 0)return;let d=[],l=i((c,u)=>{if(c===void 0)return;let f=W(()=>c(()=>{s.current(u);}));typeof f=="function"&&d.push(f);},"subscribe");return l(e.onForeground?.bind(e),"foreground"),l(e.onOnline?.bind(e),"foreground"),l(e.onAnnounced?.bind(e),"announced"),()=>{for(let c of d)W(c);}},[e]);}i(gi,"useChatLifecycle");function hc(e){if(e===void 0)return null;let t=e.conversationId??"",r=e.petRef??"";return t===""&&r===""?null:`${String(t)}|${String(r)}`}i(hc,"targetKey");function bi(e,t){let r=hc(t),n=react.useRef({openCheckin:e,target:t});n.current={openCheckin:e,target:t};let o=react.useRef(null);react.useEffect(()=>{if(r===null||o.current===r)return;o.current=r;let{openCheckin:a,target:s}=n.current;a===void 0||s===void 0||Promise.resolve(a(s)).catch(()=>{});},[r]);}i(bi,"useCheckinTarget");function Ei(e,t,r){let[n,o]=react.useState({send:e,conversationId:t,text:r??"",seeded:r??null}),a=n.send===e&&(n.conversationId===null||n.conversationId===t);react.useEffect(()=>{o(d=>{let l=d.send===e&&(d.conversationId===null||d.conversationId===t),c=l?d.text:"",u=l?d.seeded:null,f=r!=null&&r!==u&&c.length===0;return {send:e,conversationId:t,text:f?r:c,seeded:f?r:u}});},[e,t,r]);let s=react.useCallback(d=>o(l=>({send:e,conversationId:t,text:d,seeded:l.seeded})),[e,t]);return [a?n.text:"",s]}i(Ei,"useChatDraft");function Ri(e,t,r,n){let o=react.useRef({draft:r,setDraft:n});o.current={draft:r,setDraft:n};let a=react.useRef(null),[s,d]=react.useState(null);react.useEffect(()=>{if(e===void 0)return;let l=`${t??""}`;if(a.current===l)return;a.current=l;let c=true;return (async()=>{let u=await Xe(()=>e.read(t));if(!c)return;let f=u.ok&&typeof u.value=="string"?u.value:"";f.length>0&&o.current.draft.length===0&&o.current.setDraft(f),d(l);})(),()=>{c=false;}},[e,t]),react.useEffect(()=>{e===void 0||s!==`${t??""}`||W(()=>e.write(t,r));},[e,t,r,s]);}i(Ri,"usePersistedDraft");var G=Object.freeze({heading:"Chat History",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No matching chats",noMatchBody:"Try a different title or start a new conversation.",loading:"Loading your chats\u2026",loadFailed:"Couldn\u2019t load your chats",loadingMore:"Loading more\u2026",untitled:"New conversation",newConversation:"New conversation",search:"Search",retry:"Try again",retryA11y:"Retry loading chats",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages\u2026",openConversation:"Open conversation",unreadPrefix:"Unread. "});function qt(e){let t=e?.replace(/\s+/g," ").trim();return t||G.untitled}i(qt,"conversationTitle");function Pi(e){return `${e.unreadCount!==null&&e.unreadCount>0?G.unreadPrefix:""}${G.openConversation} ${qt(e.title)}`}i(Pi,"openConversationLabel");function Si(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}i(Si,"normalizeForSearch");function Sc(e,t){let r=Si(t);if(r.length===0)return e;let n=[[],[],[]];for(let o of e){let a=Si(qt(o.title)),s=a.indexOf(r);if(s<0)continue;let d=s===0?0:a.charAt(s-1)===" "?1:2;n[d]?.push(o);}return n.flat()}i(Sc,"filterConversations");function jr(e){return {scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}i(jr,"fresh");function Ti(e){let[t,r]=react.useState(false),[n,o]=react.useState(""),a=e.listConversations,s=react.useRef(0),[d,l]=react.useState(()=>jr(a)),c=d.scope===a?d:jr(a);react.useEffect(()=>(s.current+=1,r(false),o(""),l(jr(a)),()=>{s.current+=1;}),[a]);let u=react.useCallback(async O=>{let F=++s.current,h=O!==void 0;l(R=>({...R,scope:a,loading:!h,loadingMore:h,error:null}));let E=await e.listConversations(O?{cursor:O}:void 0);if(F===s.current){if(!E.ok){l(R=>({...R,loading:false,loadingMore:false,error:E.error.displayMessage}));return}l(R=>{let L=O&&R.scope===a?R.rows:[],P=new Set(L.map(k=>k.id));return {scope:a,loading:false,loadingMore:false,error:null,rows:[...L,...E.value.conversations.filter(k=>!P.has(k.id))],cursor:E.value.nextCursor===O?null:E.value.nextCursor}});}},[e.listConversations,a]),f=i(()=>{r(true),o(""),u();},"show"),y=i(()=>{s.current+=1,r(false);},"close"),b=i(async O=>{let F=++s.current;l(E=>({...E,loading:true,error:null}));let h=await e.resumeConversation(O);F===s.current&&(l(E=>({...E,loading:false,error:h.ok?null:h.error.displayMessage})),h.ok&&r(false));},"resume"),g=i(async()=>{let O=s.current,F=await e.loadOlderMessages();O===s.current&&!F.ok&&l(h=>({...h,error:F.error.displayMessage}));},"earlier"),x=i(()=>{e.newConversation(),s.current+=1,r(false);},"newConversation"),m=i(()=>{c.cursor===null||c.loading||c.loadingMore||n.trim().length>0||u(c.cursor);},"loadMore"),T=react.useMemo(()=>Sc(c.rows,n),[c.rows,n]),I=n.trim().length>0;return {...c,open:t,show:f,close:y,load:u,resume:b,earlier:g,newConversation:x,loadMore:m,query:n,setQuery:o,searching:I,filtered:T,emptyKind:c.rows.length===0?"empty":"noMatch"}}i(Ti,"useHistoryPanel");var Yt="#111111",Kt="#FFFFFF",kc=Object.freeze({emergency:Object.freeze({level:"emergency",label:"Vet care now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:Yt,pillColor:Kt,showsVetAction:true}),schedule_soon:Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:Yt,pillColor:Kt,showsVetAction:true}),home_care:Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Yt,pillColor:Kt,showsVetAction:false}),general:Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Yt,pillColor:Kt,showsVetAction:false})});function wc(e){return `${e.messageId}:${e.level}:${e.reason??""}`}i(wc,"urgencySignature");function _c(e){return B(p.urgencyGeneralReason,{petName:e?.trim()||p.emptyTitlePetFallback})}i(_c,"generalUrgencyReason");function _i(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 o=n.urgencyLevel;return o?{messageId:n.id,level:o,reason:n.urgencyReason??null}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:_c(t)}:null}return null}i(_i,"latestUrgencySource");function xi(e){let t=e===null?null:wc(e),[r,n]=react.useState(null),[o,a]=react.useState(false);react.useEffect(()=>a(false),[t]);let d=e!==null&&(o||!(r!==null&&r===t)),l=e===null?null:kc[e.level],c=e!==null&&!d&&e.level!=="general",u=react.useCallback(()=>{t!==null&&n(t),a(false);},[t]),f=react.useCallback(()=>a(true),[]);return react.useMemo(()=>({source:e,tier:l,signature:t,showBanner:d,showCompactIcon:c,showVetAction:d&&l!==null&&l.showsVetAction,dismissLabel:l===null?null:B(p.dismissBanner,{label:l.label}),dismiss:u,expand:f}),[e,l,t,d,c,u,f])}i(xi,"useUrgencySurface");function Ii(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}i(Ii,"selectView");function xc(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}i(xc,"needsNewConversation");function Ai(e){if(e.messages.length===0)return null;let t=e.status==="error"?e.error:null;if(t!==null){let r=xc(t);return {tone:"error",title:r?p.turnUnreachableTitle:p.turnFailedTitle,body:t.displayMessage,actionLabel:r?p.turnStartNewChat:p.turnRetry,action:r?"startNew":"retry"}}return e.stopped===true?{tone:"neutral",title:p.turnStoppedTitle,body:p.turnStoppedBody,actionLabel:p.turnRetry,action:"retry"}:null}i(Ai,"turnNotice");function Oi(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}i(Oi,"awaitingAssistant");function Fi(e,t){let r={};return e!==void 0&&(r.petRef=e),t!==void 0&&(r.conversationId=t),r}i(Fi,"buildChatOpts");var Gr=class Gr extends react.Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(r,n){return Object.is(r.resetKey,n.key)?null:{failed:false,key:r.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};i(Gr,"HostRenderBoundary");var Wr=Gr;function Ac({render:e}){return e()}i(Ac,"RenderHost");function Ue({render:e,fallback:t,resetKey:r}){return react.createElement(Wr,{fallback:t,resetKey:r,children:react.createElement(Ac,{render:e})})}i(Ue,"HostRender");var Oc=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 Fc(e){return Oc[e]}i(Fc,"requires");function Vi(e,t,r){let n=Fc(e),o=new Map;for(let d of t)o.set(d.resource,d);if(r?.isPending===true&&n.some(d=>!o.has(d)))return qr({name:e,enabled:false,isPending:true,limits:{}});let a=Mc(n,o);return n.filter(d=>o.get(d)?.granted!==true).length===0?qr({name:e,enabled:true,isPending:false,limits:a}):qr({name:e,enabled:false,isPending:false,limits:a,disabled:Vc(n,o)})}i(Vi,"decideCapability");function Mc(e,t){let r={};for(let n of e){let o=t.get(n)?.limits;if(o)for(let[a,s]of Object.entries(o)){let d=r[a];r[a]=d===void 0?s:Math.min(d,s);}}return r}i(Mc,"mergeLimits");function Vc(e,t){for(let r of e){let n=t.get(r)?.disabled;if(n)return Object.freeze({reason:n.reason,level:n.level,recoverable:n.recoverable})}return Object.freeze({reason:vr("accessDenied"),level:"user_entitlement",recoverable:false})}i(Vc,"disabledFor");function qr(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),Object.freeze(t)}i(qr,"freezeDecision");function gt(e){let{runtime:t}=ie(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return react.useMemo(()=>Vi(e,n.decisions,{isPending:n.isPending}),[e,n])}i(gt,"useCapability");var Nc=48;function Hc(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(Hc,"selectView");function Hi(e){let{capability:t,children:r,renderDisabled:n,renderPending:o,style:a}=e,s=gt(t),d=react.useMemo(()=>Hc(s),[s]);switch(d){case "enabled":return r;case "pending":return o?jsxRuntime.jsx(Ue,{render:o,fallback:jsxRuntime.jsx(Li,{capability:t,style:a})}):jsxRuntime.jsx(Li,{capability:t,style:a});case "disabled":return n?jsxRuntime.jsx(Ue,{render:()=>n(s),fallback:jsxRuntime.jsx(Ni,{decision:s,style:a}),resetKey:s}):jsxRuntime.jsx(Ni,{decision:s,style:a});default:return Ft(d)}}i(Hi,"CapabilityGate");function Li({capability:e,style:t}){let r=_(),n=react.useMemo(()=>Ui(r),[r]);return jsxRuntime.jsx(reactNative.View,{style:[n.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:jsxRuntime.jsx(reactNative.View,{style:n.skeletonBar})})}i(Li,"PendingSkeleton");function Ni({decision:e,style:t}){let r=_(),n=react.useMemo(()=>Ui(r),[r]),o=e.disabled?.reason??"";return jsxRuntime.jsx(reactNative.View,{style:[n.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:o,children:o.length>0?jsxRuntime.jsx(v,{style:n.offstateText,children:o}):null})}i(Ni,"OffState");function Ui(e){let{color:t,space:r,radius:n,type:o}=e;return reactNative.StyleSheet.create({offstate:{minHeight:Nc,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...C(e,"regular"),fontSize:o.size.body,lineHeight:Math.round(o.size.body*o.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}i(Ui,"makeStyles");var ht=Object.freeze({title:"For educational use only",body:"Everfur is for educational purposes only. It helps you track visible changes through AI checkups. It does not diagnose, treat, prescribe, or replace veterinary care. For urgent symptoms or emergencies, contact a veterinarian immediately."});function ji(e){let t=_(),r=react.useMemo(()=>Bc(t),[t]);return jsxRuntime.jsxs(reactNative.View,{style:[r.container,e.style],accessible:true,accessibilityRole:"text",accessibilityLabel:`${ht.title}. ${ht.body}`,children:[jsxRuntime.jsx(v,{style:r.title,children:ht.title}),jsxRuntime.jsx(v,{style:r.body,children:ht.body})]})}i(ji,"ClinicalDisclaimer");function Bc(e){let{color:t,space:r,type:n}=e;return reactNative.StyleSheet.create({container:{paddingHorizontal:r.lg,paddingVertical:r.md,borderTopWidth:reactNative.StyleSheet.hairlineWidth,borderTopColor:t.borderHairlineGreen,backgroundColor:t.surfaceCream,gap:r.xs},title:{...C(e,"bold"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.secondary,letterSpacing:n.letterSpacing.eyebrow},body:{...C(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.muted}})}i(Bc,"makeStyles");var J={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function $(e){return {width:e,height:e,alignItems:"center",justifyContent:"center"}}i($,"box");function ne(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}i(ne,"stroke");function Wi({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o={width:e*.82,height:n,borderRadius:n,backgroundColor:t};return jsxRuntime.jsxs(reactNative.View,{style:[$(e),{gap:e*.22}],...J,children:[jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o})]})}i(Wi,"MenuGlyph");function Gi({size:e,color:t,strokeWidth:r,rotate:n}){let o=ne(e,r),a=e*.78;return jsxRuntime.jsxs(reactNative.View,{style:[$(e),{transform:[{rotate:n}]}],...J,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:a,height:o,borderRadius:o,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:o,height:a,borderRadius:o,backgroundColor:t}})]})}i(Gi,"Cross");function qi(e){return jsxRuntime.jsx(Gi,{...e,rotate:"0deg"})}i(qi,"PlusGlyph");function ze(e){return jsxRuntime.jsx(Gi,{...e,rotate:"45deg"})}i(ze,"CloseGlyph");function Ae({size:e,color:t,strokeWidth:r}){let n=ne(e,r);return jsxRuntime.jsx(reactNative.View,{style:$(e),...J,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}i(Ae,"CheckGlyph");function Yi({size:e,color:t,strokeWidth:r,direction:n}){let o=ne(e,r),a=e*.46;return jsxRuntime.jsx(reactNative.View,{style:$(e),...J,children:jsxRuntime.jsx(reactNative.View,{style:{width:a,height:a,borderRightWidth:o,borderBottomWidth:o,borderColor:t,marginTop:n==="down"?-a*.4:a*.4,transform:[{rotate:n==="down"?"45deg":"225deg"}]}})})}i(Yi,"ChevronGlyph");function Ki({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};return jsxRuntime.jsxs(reactNative.View,{style:[$(e),{flexDirection:"row",gap:1}],...J,children:[jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopLeftRadius:e*.2}]}),jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}i(Ki,"BookGlyph");function $i({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o=e*.5;return jsxRuntime.jsxs(reactNative.View,{style:$(e),...J,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:e*.78,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.16,right:e*.16,width:o,height:o,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}i($i,"ArrowUpRightGlyph");function Qi({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o=e*.6,a={position:"absolute",width:o,height:o,borderWidth:n,borderColor:t,borderRadius:e*.14};return jsxRuntime.jsxs(reactNative.View,{style:$(e),...J,children:[jsxRuntime.jsx(reactNative.View,{style:[a,{top:0,left:0}]}),jsxRuntime.jsx(reactNative.View,{style:[a,{bottom:0,right:0}]})]})}i(Qi,"CopyGlyph");function $t({size:e,color:t,strokeWidth:r,active:n,rotate:o}){let a=ne(e,r),s=n?t:"transparent";return jsxRuntime.jsxs(reactNative.View,{style:[$(e),{transform:[{rotate:o}]}],...J,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:a,borderColor:t,backgroundColor:s,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:a,borderColor:t,backgroundColor:s,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:a,borderColor:t,backgroundColor:s,borderRadius:e*.05}})]})}i($t,"ThumbGlyph");function Xi({size:e,color:t,strokeWidth:r}){let n=ne(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[$(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...J,children:[jsxRuntime.jsx(reactNative.View,{style:{width:n,height:n,borderRadius:n,backgroundColor:t,marginBottom:e*.1}}),jsxRuntime.jsx(reactNative.View,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}i(Xi,"InfoGlyph");function Zi({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o=e*.34;return jsxRuntime.jsxs(reactNative.View,{style:$(e),...J,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.06,width:o,height:o,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.1,width:n,height:e*.56,borderRadius:n,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}i(Zi,"UploadGlyph");function Ji({size:e,color:t,strokeWidth:r}){let n=ne(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[$(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...J,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(Ji,"PhotoGlyph");function ea({size:e,color:t,strokeWidth:r}){let n=ne(e,r);return jsxRuntime.jsxs(reactNative.View,{style:$(e),...J,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderTopLeftRadius:n,borderTopRightRadius:n}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}i(ea,"CameraGlyph");function ta({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o=e*.66;return jsxRuntime.jsxs(reactNative.View,{style:$(e),...J,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:0,left:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.02,right:e*.02,width:n,height:e*.4,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}})]})}i(ta,"SearchGlyph");function ra({size:e,color:t,strokeWidth:r}){let n=ne(e,r);return jsxRuntime.jsxs(reactNative.View,{style:$(e),...J,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:n,borderColor:t,borderRadius:n,transform:[{rotate:"45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:n,borderRadius:n,backgroundColor:t}})]})}i(ra,"EditGlyph");function na({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o=e*.62;return jsxRuntime.jsxs(reactNative.View,{style:$(e),...J,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t,alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(reactNative.View,{style:{width:n*1.4,height:n*1.4,borderRadius:n,backgroundColor:t}})}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.04,width:o*.5,height:o*.5,borderRightWidth:n,borderBottomWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(na,"MapPinGlyph");function oa({size:e,color:t,testID:r}){let n=e*.36;return jsxRuntime.jsx(reactNative.View,{style:$(e),testID:r,...J,children:jsxRuntime.jsx(reactNative.View,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}i(oa,"SendGlyph");function ia({size:e,color:t,testID:r}){return jsxRuntime.jsx(reactNative.View,{style:$(e),testID:r,...J,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}i(ia,"StopGlyph");function Qt({size:e,strokeWidth:t,color:r,children:n}){return jsxRuntime.jsx(reactNative.View,{style:[$(e),{borderRadius:e/2,borderWidth:t??reactNative.StyleSheet.hairlineWidth,borderColor:r}],children:n})}i(Qt,"Ring");function q(){let e=_();return ai(e)}i(q,"useChatMotion");var Qc=8;function sa(e,t,r){return ((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}i(sa,"bezierComponent");function Xc(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}i(Xc,"bezierSlope");function Xt(e){let[t,r,n,o]=e;return a=>{if(a<=0)return 0;if(a>=1)return 1;let s=a;for(let d=0;d<Qc;d+=1){let l=Xc(s,t,n);if(l===0)break;s-=(sa(s,t,n)-a)/l;}return sa(Math.min(1,Math.max(0,s)),r,o)}}i(Xt,"bezierEasing");var $r=Xt(mt.standard),Zc=Xt(mt.outQuad);function Jr(e){let t=react.useRef(null);return t.current===null&&(t.current=new reactNative.Animated.Value(e)),t.current}i(Jr,"useAnimatedValue");function Be(e,t={}){let r=t.risePx??0,n=t.delayMs??0,o=Jr(e>0?0:1);return react.useEffect(()=>{if(e<=0)return;let a=reactNative.Animated.timing(o,{toValue:1,duration:e,easing:Zc,useNativeDriver:true}),s=n>0?reactNative.Animated.sequence([reactNative.Animated.delay(n),a]):a;return s.start(),()=>s.stop()},[o,e,n]),react.useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[o,r])}i(Be,"useFadeIn");function en({visible:e,inMs:t,outMs:r,style:n,children:o}){let[a,s]=react.useState(e),d=Jr(e&&t<=0?1:0);return react.useEffect(()=>{if(e){s(true);let c=reactNative.Animated.timing(d,{toValue:1,duration:Math.max(0,t),easing:$r,useNativeDriver:true});return c.start(),()=>c.stop()}if(!a)return;if(r<=0){s(false);return}let l=reactNative.Animated.timing(d,{toValue:0,duration:r,easing:$r,useNativeDriver:true});return l.start(({finished:c})=>{c&&s(false);}),()=>l.stop()},[e,a,t,r,d]),!a&&!e?null:jsxRuntime.jsx(reactNative.Animated.View,{style:[n,{opacity:d}],children:o})}i(en,"FadePresence");function D({style:e,containerStyle:t,children:r,onPressIn:n,onPressOut:o,...a}){let s=q(),d=Jr(1),l=react.useCallback(c=>{s.pressMs<=0||s.pressScale===1||reactNative.Animated.timing(d,{toValue:c,duration:s.pressMs,easing:$r,useNativeDriver:true}).start();},[d,s.pressMs,s.pressScale]);return jsxRuntime.jsx(reactNative.Pressable,{...a,style:t,onPressIn:c=>{l(s.pressScale),n?.(c);},onPressOut:c=>{l(1),o?.(c);},children:jsxRuntime.jsx(reactNative.Animated.View,{style:[e,{transform:[{scale:d}]}],children:r})})}i(D,"PressScale");function ca(e,t,r){let n=t&&r.revealTickMs>0,[o,a]=react.useState(0),s=react.useRef(e);return s.current=e,react.useEffect(()=>{if(!n)return;let d=setInterval(()=>{a(l=>si(r,l,s.current.length));},r.revealTickMs);return ()=>clearInterval(d)},[n,r]),n?e.slice(0,Math.min(o,e.length)):e}i(ca,"useRevealedText");var la=false;function Jc(e){e.layoutMs<=0||(la||(la=true,reactNative.Platform.OS==="android"&&typeof reactNative.UIManager.setLayoutAnimationEnabledExperimental=="function"&&reactNative.UIManager.setLayoutAnimationEnabledExperimental(true)),reactNative.LayoutAnimation.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}));}i(Jc,"animateLayout");function Zt(e,t){let r=react.useRef(e);r.current!==e&&(r.current=e,Jc(t));}i(Zt,"useAnimateLayoutOn");var tn=36,au=22,su=12,lu=12,du=16,cu="#000",uu="rgba(0,0,0,0.45)";function ua({uri:e,label:t,onClose:r}){let n=_(),o=reactNativeSafeAreaContext.useSafeAreaInsets();return e===null?null:jsxRuntime.jsxs(reactNative.Modal,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:p.closePreview,style:Jt.backdrop,onPress:r,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:Jt.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),jsxRuntime.jsx(reactNative.View,{pointerEvents:"box-none",style:[Jt.closeWrap,{top:o.top+lu}],children:jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:p.closePreview,hitSlop:su,style:Jt.closeButton,onPress:r,children:jsxRuntime.jsx(ze,{size:au,color:n.color.surface,strokeWidth:2})})})]})}i(ua,"AttachmentImageLightbox");var Jt=reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:cu,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:du},closeButton:{width:tn,height:tn,borderRadius:tn/2,backgroundColor:uu,alignItems:"center",justifyContent:"center"}});var er=12,gu=80,rn=44,pa=22,hu=.14,bu=18,vu=8,fa=Object.freeze({photo:p.attachmentPhoto,camera:p.attachmentCamera});function ya({sources:e,full:t,onPick:r,onClose:n}){let o=_(),a=react.useMemo(()=>Cu(o),[o]);return jsxRuntime.jsxs(reactNative.View,{style:a.anchor,pointerEvents:"box-none",children:[jsxRuntime.jsx(reactNative.Pressable,{style:a.dismissLayer,accessibilityRole:"button",accessibilityLabel:p.closeAttachmentPicker,onPress:n}),jsxRuntime.jsxs(reactNative.View,{style:a.bubble,children:[jsxRuntime.jsx(reactNative.View,{style:a.tilesRow,children:e.map(s=>jsxRuntime.jsxs(D,{accessibilityRole:"button",accessibilityLabel:fa[s],accessibilityState:{disabled:t},disabled:t,containerStyle:a.tile,style:a.tileInner,onPress:()=>r(s),children:[jsxRuntime.jsx(reactNative.View,{style:a.tileIconWrap,children:s==="photo"?jsxRuntime.jsx(Ji,{size:pa,color:o.color.brandInk,strokeWidth:1.5}):jsxRuntime.jsx(ea,{size:pa,color:o.color.brandInk,strokeWidth:1.5})}),jsxRuntime.jsx(v,{tier:"control",style:a.tileLabel,children:fa[s]})]},s))}),jsxRuntime.jsx(reactNative.View,{style:a.tail}),jsxRuntime.jsx(reactNative.View,{style:a.tailFill})]})]})}i(ya,"AttachmentPickerPopover");function Cu(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({anchor:{position:"absolute",left:0,right:0,bottom:"100%",paddingHorizontal:8,paddingBottom:10,alignItems:"flex-start"},dismissLayer:{position:"absolute",left:-1e3,right:-1e3,top:-2e3,bottom:0},bubble:{backgroundColor:t.surfaceCream,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:6,paddingVertical:8,shadowColor:t.shadow,shadowOpacity:hu,shadowRadius:bu,shadowOffset:{width:0,height:vu},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:gu,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:rn,height:rn,borderRadius:rn/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...C(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-er/2,width:er,height:er,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:er+4,height:2,backgroundColor:t.surfaceCream}})}i(Cu,"makeStyles");var ma=56,ga=12,Su=14,Pu=10,Tu="rgba(16,70,46,0.45)",ku="rgba(7,193,104,0.55)",wu="rgba(185,28,28,0.55)",_u=200,xu=300,Pa=20,on=22,Iu=12,Au="rgba(0,0,0,0.78)",ha=220,ba=100,va="rgba(255,255,255,0.15)";function Ta({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:o,onPreview:a}){let s=_(),d=react.useMemo(()=>wa(s),[s]);return e.length===0&&t===null?null:jsxRuntime.jsxs(reactNative.View,{style:d.strip,children:[e.length>0?jsxRuntime.jsx(reactNative.View,{style:d.cards,children:e.map(l=>jsxRuntime.jsx(Ou,{row:l,styles:d,onRetry:n,onRemove:o,onPreview:a},l.id))}):null,r?jsxRuntime.jsx(v,{style:d.rejected,accessibilityRole:"alert",children:p.attachmentsFailedBlocked}):null,t!==null?jsxRuntime.jsx(v,{style:d.rejected,accessibilityRole:"alert",children:xo(t)}):null]})}i(Ta,"AttachmentStrip");function Ou({row:e,styles:t,onRetry:r,onRemove:n,onPreview:o}){let a=_(),s=e.status==="uploading",d=e.status==="failed",l=e.status==="uploaded",c=react.useRef(e.status),[u,f]=react.useState(false);return react.useEffect(()=>{let y=c.current;c.current=e.status,e.status==="uploaded"&&y==="uploading"&&f(true);},[e.status]),jsxRuntime.jsxs(reactNative.View,{style:t.card,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:l?"button":"image",accessibilityLabel:l?B(p.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:s,disabled:!l},disabled:!l,style:t.thumbHit,onPress:()=>o(e),children:jsxRuntime.jsxs(reactNative.View,{style:t.thumb,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),s?jsxRuntime.jsx(reactNative.View,{style:t.uploadingOverlay,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:a.color.surface})}):null,u?jsxRuntime.jsx(Fu,{styles:t,onDone:()=>f(false)}):null]})}),d?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:B(p.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:jsxRuntime.jsx(reactNative.View,{style:t.failedInner,children:jsxRuntime.jsx(ze,{size:Pa,color:a.color.surface,strokeWidth:2})})}):null,jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:B(p.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:jsxRuntime.jsx(ze,{size:Iu,color:a.color.surface,strokeWidth:1.5})})]})}i(Ou,"PreviewCard");function Fu({styles:e,onDone:t}){let r=_(),n=q(),o=react.useRef(null);o.current===null&&(o.current=new reactNative.Animated.Value(0));let a=o.current;return react.useEffect(()=>{let s=reactNative.Animated.sequence([reactNative.Animated.timing(a,{toValue:1,duration:_u,useNativeDriver:true}),reactNative.Animated.delay(n.uploadFlashMs),reactNative.Animated.timing(a,{toValue:0,duration:xu,useNativeDriver:true})]);return s.start(({finished:d})=>{d&&t();}),()=>s.stop()},[a,n.uploadFlashMs,t]),jsxRuntime.jsx(reactNative.Animated.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:a}],children:jsxRuntime.jsx(Ae,{size:Pa,color:r.color.surface,strokeWidth:2})})}i(Fu,"SuccessFlash");function ka({images:e,onPreview:t}){let r=_(),n=react.useMemo(()=>wa(r),[r]);if(e.length===0)return null;let o=e.length===1;return jsxRuntime.jsx(reactNative.View,{style:o?n.sentSingle:n.sentGrid,children:e.map((a,s)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:B(p.attachedImage,{filename:a.filename}),onPress:()=>t(a),children:jsxRuntime.jsx(reactNative.Image,{source:{uri:a.uri},style:o?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${a.uri}-${s}`))})}i(ka,"SentImages");function wa(e){let t=e.color,r=e.type;return reactNative.StyleSheet.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:ma,height:ma,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:ga,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...reactNative.StyleSheet.absoluteFillObject,alignItems:"center",justifyContent:"center",backgroundColor:Tu},successOverlay:{...reactNative.StyleSheet.absoluteFillObject,alignItems:"center",justifyContent:"center",backgroundColor:ku},failedOverlay:{...reactNative.StyleSheet.absoluteFillObject,borderRadius:ga,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:wu},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:on,height:on,borderRadius:on/2,backgroundColor:Au,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...C(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:ha,height:ha,borderRadius:Su,backgroundColor:va},gridImage:{width:ba,height:ba,borderRadius:Pu,backgroundColor:va}})}i(wa,"makeStyles");var Mu="file",Vu="chat attachment upload: the file handle has no uri",Du="chat attachment upload failed";function Lu(e){return {uri:e.uri,name:Ir(e.name),type:e.mimeType}}i(Lu,"filePartOf");function ln(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(Vu));let{signal:o,onProgress:a}=n,s=i(()=>Promise.reject(new Error(Du)),"failed");if(o?.aborted===true)return s();let d=new FormData;for(let[c,u]of Object.entries(t.upload_fields))d.append(c,u);d.append(Mu,Lu(r));let l=e.fetch??fetch;return Promise.resolve().then(()=>l(t.upload_url,{method:"POST",body:d,credentials:"omit",...o?{signal:o}:{}})).then(c=>{if(!c.ok)return s();a?.(1);},s)}})}i(ln,"createRnChatAttachmentTransport");function cn(){let{runtime:e,userRef:t,activePet:r,scopeEpoch:n}=ie(),o=react.useMemo(()=>jt(e.registry.services.authFor(t)),[e,t,n]),[a,s]=react.useState({repository:o,pets:[],loading:true,error:null}),d=a.repository===o?a:{pets:[],loading:true,error:null},l=react.useRef(0),c=react.useCallback(async()=>{let f=++l.current;s(b=>({...b,repository:o,loading:true,error:null,pets:b.repository===o?b.pets:[]}));let y=await o.list();f===l.current&&s(y.ok?{repository:o,pets:y.value,loading:false,error:null}:b=>({repository:o,pets:b.repository===o?b.pets:[],loading:false,error:y.error}));},[o]);react.useEffect(()=>(c(),()=>{l.current+=1;}),[c]);let u=react.useMemo(()=>r===null?null:d.pets.find(f=>f.petRef===r)??null,[r,d.pets]);return react.useMemo(()=>({pets:d.pets,activePet:u,loading:d.loading,error:d.error,refresh:c}),[d.pets,d.loading,d.error,u,c])}i(cn,"useEverfurPets");function _a(e,t){if(t!==null){let r=e.find(n=>n.petRef===t);if(r!==void 0)return r}return e[0]??null}i(_a,"headerPetOf");var xa=Object.freeze({visitButton:"Talk to a vet"});var un=Object.freeze(["visit","join","summary","messages"]);function pn(e){return typeof e=="string"&&un.includes(e)}i(pn,"isVetVisitIntent");var Bu="/widget/v1/televet/handoffs",ju="/widget/v1/televet/availability",Wu="/widget/v1/televet/chat-entry",Gu=/^[a-z0-9][a-z0-9_-]{0,39}$/,qu=/^[A-Za-z0-9_-]{22}$/;var Ia=32,Aa=128,Oa=64;function yn(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"}i(yn,"vetVisitErrorReasonOf");function Fa(e){return V(j("validationFailed",{retryable:false,wireMessage:e}))}i(Fa,"invalid");function fn(e){return V(j("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}i(fn,"unusable");function Yu(e,t){let r={};e!==void 0&&(r.pet_ref=e);let n=t?.returnTo;if(n!=null){if(typeof n!="string"||!Gu.test(n))return {ok:false,message:"returnTo must be a registered return destination key"};r.return_to=n;}let o=t?.entry;if(o!=null){if(o!=="chat"||e===void 0)return {ok:false,message:"entry 'chat' needs the pet the chat is about"};r.entry=o;}let a=t?.visitRef,s=t?.intent,d=a!=null;if(d){let l=typeof a=="string"?a.trim():"";if(l.length<1||[...l].length>Oa)return {ok:false,message:`visitRef must be 1..${Oa} characters`};r.visit_ref=l;}if(s!=null){if(!d)return {ok:false,message:"intent needs the visitRef it opens"};if(!pn(s))return {ok:false,message:`intent must be one of ${un.join(", ")}`};r.intent=s;}return {ok:true,body:r}}i(Yu,"handoffBody");function Ku(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!pn(r)?null:Object.freeze({visitRef:t,intent:r})}i(Ku,"parseVisitEcho");function Va(e){let t=e.funnel??Ne({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=i(o=>(Ma(r,"televet.visit.handoff_failed",{reason:yn(o)}),V(o)),"failed");return {async createHandoff(o,a){let s;if(o!=null){let m=typeof o=="string"?[...o].length:0;if(m<1||m>Aa)return n(j("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${Aa} characters`}));s=o;}let d=Yu(s,a);if(!d.ok){let m=Fa(d.message);return m.ok?m:n(m.error)}let l=d.body,c=await t.send("televet.visit.handoff",{method:"POST",path:Bu,body:l},{idempotent:false,maxAttempts:1});if(!c.ok)return n(c.error);let u=$u(c.value),f=l.return_to!==void 0,y=f?c.value?.flow_id:void 0;if(f&&(typeof y!="string"||!qu.test(y))){let m=fn("the handoff response carried no usable return flow id");return m.ok?m:n(m.error)}let b=l.visit_ref!==void 0,g=b?Ku(c.value?.visit):null;if(b&&g===null){let m=fn("the handoff response did not confirm the visit it opens");return m.ok?m:n(m.error)}let x=u===null?null:Object.freeze({...u,...f?{flowId:y}:{},...g!==null?{visit:g}:{}});return x===null?n(j("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Ma(r,"televet.visit.handoff_created",{pet_scoped:l.pet_ref!==void 0}),le(x))},async checkAvailability(o){if(typeof o!="string"||o.length>Ia)return Fa(`state must be at most ${Ia} characters`);let a=await t.send("televet.visit.availability",{method:"POST",path:ju,body:{state:o}},{idempotent:false,maxAttempts:1});if(!a.ok)return V(a.error);let s=a.value?.available;return typeof s!="boolean"?fn("the availability response carried no usable answer"):le(Object.freeze({available:s}))},async chatEntryOpen(){try{let o=await t.send("televet.visit.chat_entry",{method:"GET",path:Wu},{maxAttempts:1});return o.ok&&o.value?.open===!0}catch{return false}}}}i(Va,"createVetVisitController");function $u(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||!Ju(t)?null:Object.freeze({url:t,expiresAt:r})}i($u,"parseHandoff");var Qu=new Set(["localhost","127.0.0.1","[::1]"]),Xu=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,Zu=/[\s\u0000-\u001f\u007f]/;function Ju(e){if(Zu.test(e))return false;let t=Xu.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let o=n.replace(/:\d+$/,"").toLowerCase(),a=r==="https",s=r==="http"&&Qu.has(o);if(!a&&!s)return false;let d=e.indexOf("#");if(d<0)return false;let l=e.slice(d);return l.startsWith("#h=")&&l.length>3}i(Ju,"isOpenableVisitUrl");function Ma(e,t,r){if(e)try{e.track(t,r);}catch{}}i(Ma,"safeTrack");var La=Object.freeze({status:"idle",error:null,errorReason:null});function tp(e,t,r){let{usState:n,chat:o,scope:a}=r,s=t&&(n!==null||o),d=`${n??""}|${o?"chat":""}`,[l,c]=react.useState(null);if(react.useEffect(()=>{if(!s)return;let f=true,y=e.current;return c(null),i(async()=>{try{if(o&&!(y.chatEntryOpen&&await y.chatEntryOpen()))return !1;if(n===null)return !0;if(!y.checkAvailability)return !1;let g=await y.checkAvailability(n);return g.ok&&g.value.available}catch{return false}},"ask")().then(g=>{f&&c({key:d,open:g});}),()=>{f=false;}},[s,d,n,o,a,e]),!s)return null;let u=l!==null&&l.key===d;return {open:u&&l.open,pending:!u}}i(tp,"usePreflight");var rp=Object.freeze({status:"opening",error:null,errorReason:null});function Ha(e,t={}){let{runtime:r,userRef:n,scopeEpoch:o}=ie(),a=gt("televet"),s=a.enabled&&n!==null,d=t.usState??null,l=t.entry==="chat",c=t.petRef??null,u=react.useMemo(()=>{if(t.controller)return t.controller;let{services:P}=r.registry;return Va({auth:P.authFor(n),telemetry:P.telemetry,...P.errorPolicy?{errorPolicy:P.errorPolicy}:{}})},[r,n,o,t.controller]),f=react.useRef(u);f.current=u;let y=react.useMemo(()=>({runtime:r,userRef:n,scopeEpoch:o}),[r,n,o]),b=tp(f,s,{usState:d,chat:l,scope:y}),g=s&&(b===null||b.open)&&(!l||c!==null),x=t.returnTo??null,[m,T]=react.useState(La),I=react.useRef(null),O=react.useRef({runtime:r,userRef:n,scopeEpoch:o});O.current={runtime:r,userRef:n,scopeEpoch:o};let F=react.useRef(u);F.current=u;let h=react.useRef(g);h.current=g;let E=react.useCallback((P,k)=>{if(I.current)return I.current;let M=i((z,De)=>(T({status:z==="cancelled"?"idle":"error",error:De,errorReason:z==="cancelled"?null:z}),Object.freeze({opened:false,reason:z,error:De})),"fail");if(!h.current)return Promise.resolve(M("unavailable",null));let H=e.prepare();if(!H.ok)return Promise.resolve(M(H.reason,null));let X=O.current,U=F.current;T(rp);let oe=(async()=>{let z,De={...x!==null?{returnTo:x}:{},...l?{entry:"chat"}:{},...k!==null?{visitRef:k.visitRef}:{},...k!==null&&k.intent!==null&&k.intent!==void 0?{intent:k.intent}:{}},Tt=Object.keys(De).length===0?void 0:De,it=P===void 0?c:P;try{z=await(Tt===void 0?U.createHandoff(it):U.createHandoff(it,Tt));}catch{return e.abandon(H.value),M("unknown",null)}let Ye=O.current;if(Ye.runtime!==X.runtime||Ye.userRef!==X.userRef||Ye.scopeEpoch!==X.scopeEpoch)return e.abandon(H.value),M("cancelled",null);if(!z.ok)return e.abandon(H.value),M(yn(z.error),z.error);let Ke=await e.finish(H.value,z.value);return Ke!==null?M(Ke,null):(T(La),Object.freeze(z.value.flowId===void 0?{opened:true}:{opened:true,flowId:z.value.flowId}))})().finally(()=>{I.current===oe&&(I.current=null);});return I.current=oe,oe},[e,c,x,l]),R=react.useCallback(P=>E(P,null),[E]),L=react.useCallback((P,k)=>E(void 0,{visitRef:P,intent:k??null}),[E]);return {available:g,isPending:a.isPending||(b?.pending??false),status:m.status,error:m.error,errorReason:m.errorReason,open:R,openVisit:L}}i(Ha,"useVetVisitWith");var ip=i(e=>reactNative.Linking.openURL(e),"defaultOpenUrl");function tr(e={}){let{openUrl:t,...r}=e,n=react.useMemo(()=>{let o=t??ip;return {prepare:i(()=>({ok:true,value:null}),"prepare"),async finish(a,s){try{return await o(s.url),null}catch{return "openFailed"}},abandon:i(()=>{},"abandon")}},[t]);return Ha(n,r)}i(tr,"useVetVisit");var Ua=44,cp=.6;function et(e){let{petRef:t,label:r,openUrl:n,onOpened:o,onError:a,style:s,labelStyle:d,controller:l,returnTo:c,usState:u,entry:f,visitRef:y,intent:b}=e,g=tr({...c!==void 0?{returnTo:c}:{},...u!==void 0?{usState:u}:{},...f!==void 0?{entry:f}:{},...t!==void 0?{petRef:t}:{},...n!==void 0?{openUrl:n}:{},...l!==void 0?{controller:l}:{}}),x=_(),m=react.useMemo(()=>up(x),[x]),T=react.useRef(false);if(!g.available)return null;let I=g.status==="opening",O=r??xa.visitButton;return jsxRuntime.jsx(reactNative.Pressable,{onPress:i(()=>{I||T.current||(T.current=true,(y==null?g.open():g.openVisit(y,b??null)).then(h=>{h.opened?W(o,h.flowId??null):h.reason!=="cancelled"&&W(a,h.reason,h.error);}).finally(()=>{T.current=false;}));},"onPress"),accessibilityRole:"button",accessibilityLabel:O,accessibilityState:{busy:I,disabled:I},style:[m.button,I?m.busy:null,s],children:jsxRuntime.jsx(v,{style:[m.label,d],children:O})})}i(et,"VetVisitButton");function up(e){let{color:t,space:r,radius:n,type:o,slots:a}=e;return reactNative.StyleSheet.create({button:{minHeight:Ua,minWidth:Ua,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...re(a.vetVisitButton)},busy:{opacity:cp},label:{...C(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug,...fe(a.vetVisitButton)}})}i(up,"makeStyles");function gn(e){return Nt(e)==="cat"?"cat":"dog"}i(gn,"speciesOf");function hn(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}i(hn,"petAgeYears");function ja(e){let t=hn(e.ageYears),r=gn(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return `${r} \xB7 ${n}`}i(ja,"formatPetMeta");var Ba=Object.freeze([Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),Object.freeze({background:"#fbc558",foreground:"#10462e"}),Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function pp(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return Ba[t%Ba.length]}i(pp,"pickInitialsPalette");function bn(e){let t=(e??"").trim();return (Array.from(t)[0]??"?").toUpperCase()}i(bn,"getInitial");function Wa(e){return {...pp(e.petRef),initial:bn(e.name)}}i(Wa,"petInitials");function gp(e){return Math.max(12,Math.round(e*.42))}i(gp,"letterSize");function Et({pet:e,size:t,ringStroke:r}){let n=_(),o=react.useMemo(()=>hp(n),[n]),a=t-r*2,s=e===null?null:Wa(e),d=gp(a);return jsxRuntime.jsx(Qt,{size:t,strokeWidth:r,color:n.color.success,children:jsxRuntime.jsx(reactNative.View,{style:[o.disc,{width:a,height:a,borderRadius:a/2},s===null?o.discEmpty:{backgroundColor:s.background}],children:jsxRuntime.jsx(v,{tier:"badge",style:[o.letter,{fontSize:d,lineHeight:Math.round(d*1.2),color:s===null?n.color.text.muted:s.foreground}],children:s===null?bn(null):s.initial})})})}i(Et,"PetDisc");function hp(e){return reactNative.StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...C(e,"bold"),textAlign:"center",includeFontPadding:false}})}i(hp,"makeStyles");var Cn=48,Ka=2,Rp=320,Sp="80%",Pp="rgba(17,17,17,0.45)",Tp=18,Ga=22,kp=12,qa=.4,wp=44;function En(e){return e?.name?.trim()||p.yourPet}i(En,"petDisplayName");function $a({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:o=null,onClose:a}){let s=_(),d=react.useMemo(()=>_p(s),[s]);return e?jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:s.motion.reducedMotion?"none":"fade",onRequestClose:a,children:jsxRuntime.jsxs(reactNative.View,{style:d.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:reactNative.StyleSheet.absoluteFill,onPress:a,accessibilityRole:"button",accessibilityLabel:p.close,children:jsxRuntime.jsx(reactNative.View,{style:d.backdrop})}),jsxRuntime.jsxs(reactNative.View,{style:d.panel,accessibilityViewIsModal:true,children:[jsxRuntime.jsx(v,{tier:"heading",style:d.title,accessibilityRole:"header",children:p.yourPets}),jsxRuntime.jsx(reactNative.ScrollView,{style:d.list,contentContainerStyle:d.listContent,showsVerticalScrollIndicator:true,children:t.map(l=>{let c=l.petRef===r,u=En(l),f=ja(l);return jsxRuntime.jsxs(D,{accessibilityRole:"button",accessibilityLabel:B(c?p.petCurrentlyActive:p.switchToPet,{name:u}),accessibilityState:{selected:c},style:[d.row,c?d.rowActive:null],onPress:()=>n(l.petRef),children:[jsxRuntime.jsx(Et,{pet:l,size:Cn,ringStroke:Ka}),jsxRuntime.jsxs(reactNative.View,{style:d.copy,children:[jsxRuntime.jsx(v,{style:d.name,numberOfLines:1,children:u}),jsxRuntime.jsx(v,{tier:"compact",style:d.meta,numberOfLines:1,children:c?`${p.activePrefix}${f}`:f})]}),c?jsxRuntime.jsx(Ae,{size:Tp,color:s.color.brandInk}):null]},l.petRef)})}),o!==null?jsxRuntime.jsxs(D,{accessibilityRole:"button",accessibilityLabel:p.addAnotherPet,style:d.addRow,onPress:o,children:[jsxRuntime.jsx(reactNative.View,{style:d.addDisc,children:jsxRuntime.jsx(v,{tier:"control",style:d.addPlus,children:"+"})}),jsxRuntime.jsx(v,{style:d.addLabel,children:p.addAnotherPet})]}):null,jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:p.close,containerStyle:d.closeSlot,style:d.closeButton,onPress:a,children:jsxRuntime.jsx(v,{tier:"control",style:d.closeText,children:p.close})})]})]})}):null}i($a,"PetSwitcherSheet");function _p(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:Pp},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:Ga,borderTopRightRadius:Ga,gap:14,maxHeight:Sp},title:{...C(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk},list:{maxHeight:Rp,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:wp,paddingHorizontal:8},addDisc:{width:Cn,height:Cn,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:Ka,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...C(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...C(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary},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:{...C(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...C(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:qa},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:kp,backgroundColor:t.brandSoft},closeText:{...C(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:qa}})}i(_p,"makeStyles");var Ap=44,rr=36,Op=22,Sn=9,Fp=1.5,Qa=6,We=35,nr=1.75,Pn=12.4,Mp=.5,Vp=8,Dp=28,Lp=160;function kn(e,t){return _a(e,t)}i(kn,"headerPet");function Za({pets:e,petRef:t,historyUnread:r,onOpenHistory:n,onPetChange:o,onAddPet:a,vet:s}){let d=_(),l=react.useMemo(()=>Hp(d),[d]),[c,u]=react.useState(false),f=kn(e.pets,t),y=e.pets.length>=2,b=t??f?.petRef??null,g=En(f),x=i(T=>{u(false),e.setActivePet(T),W(o,T);},"select"),m=a===void 0?null:()=>{u(false),W(a);};return jsxRuntime.jsxs(reactNative.View,{style:l.row,children:[jsxRuntime.jsxs(D,{accessibilityRole:"button",accessibilityLabel:r?p.openMenuUnread:p.openMenu,containerStyle:l.iconSlot,style:l.iconButton,onPress:n,children:[jsxRuntime.jsx(Wi,{size:Op,color:d.color.text.primary,strokeWidth:2}),r?jsxRuntime.jsx(reactNative.View,{style:l.unreadDot,pointerEvents:"none"}):null]}),jsxRuntime.jsx(reactNative.View,{style:l.center,pointerEvents:"box-none",children:jsxRuntime.jsx(Np,{logoUrl:d.meta.logoUrl,name:d.meta.displayName,styles:l})}),b===null?null:jsxRuntime.jsx(et,{entry:"chat",petRef:b,...s?.returnTo!==void 0?{returnTo:s.returnTo}:{},...s?.usState!==void 0?{usState:s.usState}:{},style:l.vetEntry,labelStyle:l.vetEntryLabel}),jsxRuntime.jsx(reactNative.View,{style:l.right,children:y?jsxRuntime.jsxs(D,{accessibilityRole:"button",accessibilityLabel:B(p.switchActivePet,{name:g}),containerStyle:l.avatarSlot,style:l.avatarWrap,onPress:()=>u(true),children:[jsxRuntime.jsx(Et,{pet:f,size:We,ringStroke:nr}),jsxRuntime.jsx(reactNative.View,{style:l.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:jsxRuntime.jsx(qi,{size:Vp,color:d.color.brandInk,strokeWidth:2})})]}):e.loading&&f===null?jsxRuntime.jsx(reactNative.View,{style:l.avatarWrap,accessible:true,accessibilityLabel:p.yourPet,children:jsxRuntime.jsx(Qt,{size:We,strokeWidth:nr,color:d.color.success,children:jsxRuntime.jsx(reactNative.View,{style:l.placeholderDisc})})}):jsxRuntime.jsx(reactNative.View,{style:l.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:f===null?p.yourPet:g,children:jsxRuntime.jsx(Et,{pet:f,size:We,ringStroke:nr})})}),jsxRuntime.jsx($a,{visible:c,pets:e.pets,activePetRef:f?.petRef??null,onSelect:x,onAddPet:m,onClose:()=>u(false)})]})}i(Za,"ChatHeader");function Np({logoUrl:e,name:t,styles:r}){let[n,o]=react.useState(null);return e===null||n===e?null:jsxRuntime.jsx(reactNative.View,{style:r.logoBar,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:r.logo,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:()=>o(e)})})}i(Np,"BrandLogo");function Hp(e){let t=e.color,r=We-nr*2;return reactNative.StyleSheet.create({vetEntry:{minHeight:Ap,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},vetEntryLabel:{...C(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingVertical:10,backgroundColor:t.surface},iconSlot:{borderRadius:rr/2},iconButton:{width:rr,height:rr,borderRadius:rr/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:Qa,right:Qa,width:Sn,height:Sn,borderRadius:Sn,backgroundColor:t.danger,borderWidth:Fp,borderColor:t.surface},center:{...reactNative.StyleSheet.absoluteFillObject,alignItems:"center",justifyContent:"center"},logoBar:{alignItems:"center",paddingHorizontal:e.space.lg},logo:{height:Dp,width:Lp},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:We/2},avatarWrap:{width:We,height:We,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:Pn,height:Pn,borderRadius:Pn/2,borderWidth:Mp,borderColor:t.success,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}i(Hp,"makeStyles");var Fe=Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",answers:Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),Ja=Object.freeze(Co.map(e=>Object.freeze({answer:e,label:Fe.answers[e]})));function es(e,t){let[r,n]=react.useState(null),[o,a]=react.useState(null),[s,d]=react.useState(null),l=react.useCallback(u=>{t!==null&&(n(u),a(null),t(e.caseId,u).then(f=>{n(null),f.ok?d(u):a(f.error);}));},[t,e.caseId]),c=s??e.answer;return {answer:c,answerable:!So(e),escalated:c==="worse",pending:r,error:o,choose:l}}i(es,"useCheckinCard");var os=44,Bp=.6;function is({message:e,checkin:t,onAnswer:r,petRef:n,onFindVet:o,vet:a}){let s=_(),d=react.useMemo(()=>jp(s),[s]),l=es(t,r),c=l.answer!==null||l.pending!==null,u=r!==null&&l.answerable;return jsxRuntime.jsxs(reactNative.View,{style:d.card,accessibilityLabel:Fe.eyebrow,children:[jsxRuntime.jsx(v,{tier:"compact",style:d.eyebrow,children:Fe.eyebrow}),jsxRuntime.jsx(v,{style:d.question,accessibilityRole:"text",children:e.text}),u?jsxRuntime.jsx(reactNative.View,{style:[d.row,l.pending?d.rowPending:null],children:Ja.map(({answer:f,label:y})=>{let b=(l.pending??l.answer)===f;return jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>l.choose(f),disabled:c,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{selected:b,disabled:c,busy:l.pending===f},style:[d.pill,b?d.pillSelected:null],children:jsxRuntime.jsx(v,{tier:"control",style:[d.pillLabel,b?d.pillLabelSelected:null],children:y})},f)})}):null,l.answer!==null?jsxRuntime.jsx(v,{style:d.logged,children:Fe.logged}):null,l.escalated?o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:Fe.findVet,style:d.findVet,children:jsxRuntime.jsx(v,{tier:"control",style:d.findVetLabel,children:Fe.findVet})}):n?jsxRuntime.jsx(et,{entry:"chat",petRef:n,label:Fe.findVet,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},style:d.findVet,labelStyle:d.findVetLabel}):null:null,t.resolutionText?jsxRuntime.jsx(v,{style:d.resolution,children:t.resolutionText}):null,l.error?jsxRuntime.jsx(v,{style:d.error,accessibilityRole:"alert",children:l.error.displayMessage}):null]})}i(is,"CheckinCard");function jp(e){let t=e.color,r=e.space,n=e.radius,o=e.type;return reactNative.StyleSheet.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.surface,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},eyebrow:{...C(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},question:{...C(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:Bp},pill:{flex:1,minHeight:os,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surfaceCream},pillSelected:{backgroundColor:t.brand,borderColor:t.brand},pillLabel:{...C(e,"regular"),color:t.text.primary,fontSize:o.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...C(e,"regular"),color:t.text.secondary,fontSize:o.size.caption},resolution:{...C(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},error:{...C(e,"regular"),color:t.danger,fontSize:o.size.caption},findVet:{alignSelf:"stretch",minHeight:os,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.brandBorder,backgroundColor:t.surface},findVetLabel:{...C(e,"bold"),color:t.brandInk,fontSize:o.size.body}})}i(jp,"makeStyles");var Gp=Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),as="#C8BEB4";function qp(e){return e?Gp[e.toUpperCase()]??as:as}i(qp,"tierColor");function Yp(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}i(Yp,"tierLabel");function Se(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(Se,"text");function Kp(e){let t=Se(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}i(Kp,"httpsUrl");function $p(e,t){let r=Se(e.source_name)??Se(e.sourceName),n=Se(e.section),o=Se(e.authority_tier)??Se(e.authorityTier),a=Yp(o),s=r??Se(e.title)??`Source ${t+1}`,d=Se(e.monograph_chunk_id)??Se(e.chunkId),l=[n,a].filter(c=>c!==null).join(" \xB7 ");return Object.freeze({title:s,sourceName:r,section:n,authorityTier:o,tierLabel:a,meta:l.length===0?null:l,url:Kp(e.url),excerpt:Se(e.excerpt),tierColor:qp(o),key:`${s}-${d??"none"}-${t}`})}i($p,"toCitationCard");function ss(e){return e===void 0||e.length===0?Qp:Object.freeze(e.map((t,r)=>$p(t,r)))}i(ss,"toCitationCards");var Qp=Object.freeze([]);function _n(e){return e===1?`1 ${p.sourceSingular}`:`${e} ${p.sourcePlural}`}i(_n,"sourcesLabel");function ls(e,t){return `${t?p.hideSources:p.showSources} ${_n(e)}`}i(ls,"sourcesToggleLabel");function ds(e){return [e.url!==null?`${p.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(t=>t!==null&&t.length>0).join(". ")}i(ds,"citationA11yLabel");var rf=244,us=8,ps=13,nf=14,of=.3,af=-0.24,sf=22,lf=10,df=15;function fs({citations:e}){let t=_(),r=react.useMemo(()=>pf(t),[t]),n=react.useMemo(()=>ss(e),[e]),[o,a]=react.useState(false);if(n.length===0)return null;let s=n.length;return jsxRuntime.jsxs(reactNative.View,{style:r.block,children:[jsxRuntime.jsxs(D,{accessibilityRole:"button",accessibilityLabel:ls(s,o),accessibilityState:{expanded:o},containerStyle:r.toggleSlot,style:r.togglePill,onPress:()=>a(d=>!d),children:[jsxRuntime.jsx(Ki,{size:ps,color:t.color.brandInk,strokeWidth:1.5}),jsxRuntime.jsx(v,{tier:"compact",style:r.toggleLabel,children:_n(s)}),jsxRuntime.jsx(Yi,{size:ps,color:t.color.brandInk,strokeWidth:1.5,direction:o?"up":"down"})]}),o?jsxRuntime.jsx(cf,{cards:n,styles:r}):null]})}i(fs,"CitationCards");function cf({cards:e,styles:t}){let r=q(),n=Be(r.citationsInMs,{risePx:r.citationsRisePx});return jsxRuntime.jsx(reactNative.Animated.View,{style:n,children:jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(o=>jsxRuntime.jsx(uf,{card:o,styles:t},o.key))})})}i(cf,"Deck");function uf({card:e,styles:t}){let r=_(),n=ds(e),o=e.url!==null,a=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:t.cardHeader,children:[jsxRuntime.jsx(reactNative.View,{style:[t.tierDot,{backgroundColor:e.tierColor}]}),jsxRuntime.jsx(v,{style:[t.cardTitle,o?t.cardTitleLink:null],numberOfLines:2,children:e.title}),o?jsxRuntime.jsx($i,{size:nf,color:r.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?jsxRuntime.jsx(v,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?jsxRuntime.jsx(v,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null){let s=e.url;return jsxRuntime.jsx(D,{accessibilityRole:"link",accessibilityLabel:n,style:t.card,onPress:()=>{reactNative.Linking.openURL(s);},children:a})}return jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:n,style:t.card,children:a})}i(uf,"Card");function pf(e){let t=e.color,r=e.space,n=e.radius,o=e.type.size;return reactNative.StyleSheet.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:{...C(e,"monoBold"),fontSize:o.micro,lineHeight:o.micro,letterSpacing:of,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:rf,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:us,height:us,borderRadius:n.pill},cardTitle:{...C(e,"bold"),flex:1,fontSize:o.bodyTight,lineHeight:sf,color:t.text.primary,letterSpacing:af},cardTitleLink:{color:t.linkInk},cardMeta:{...C(e,"monoMedium"),fontSize:o.nano,lineHeight:lf,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},cardExcerpt:{...C(e,"regular"),fontSize:o.tiny,lineHeight:df,color:t.text.muted}})}i(pf,"makeStyles");var ms=44,bf="rgba(17,17,17,0.55)",gs=26,vf=36,hs=4,xn=20,In=38,Cf=18,Ef=12;function bs({visible:e,onSubmit:t,onSkip:r}){let n=_(),o=react.useMemo(()=>Rf(n),[n]),[a,s]=react.useState(null),[d,l]=react.useState(""),[c,u]=react.useState(false),[f,y]=react.useState(false),b=i(()=>{s(null),l(""),u(false),y(false);},"reset"),g=i(()=>{c||(b(),r());},"skip"),x=i(async()=>{if(c)return;u(true),y(false);let T=d.trim();await t(a,T.length>0?T:null)?b():(u(false),y(true));},"submit");if(!e)return null;let m=[...d].length>_r;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:n.motion.reducedMotion?"none":"slide",onRequestClose:g,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:reactNative.Platform.OS==="ios"?"padding":void 0,style:o.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:o.scrim,onPress:g,accessibilityRole:"button",accessibilityLabel:p.feedbackSkipA11y}),jsxRuntime.jsxs(reactNative.View,{style:o.sheet,accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[jsxRuntime.jsx(reactNative.View,{style:o.handle}),jsxRuntime.jsxs(reactNative.View,{style:o.header,children:[jsxRuntime.jsx(reactNative.View,{style:o.iconBadge,children:jsxRuntime.jsx($t,{size:Cf,color:n.color.brandInk,active:false,rotate:"180deg"})}),jsxRuntime.jsxs(reactNative.View,{style:o.headerText,children:[jsxRuntime.jsx(v,{tier:"heading",style:o.title,accessibilityRole:"header",children:p.feedbackTitle}),jsxRuntime.jsx(v,{style:o.subtitle,children:p.feedbackSubtitle})]})]}),jsxRuntime.jsx(reactNative.View,{style:o.options,children:Cr.map(T=>{let I=a===T.key;return jsxRuntime.jsxs(D,{accessibilityRole:"button",accessibilityLabel:T.label,accessibilityState:{selected:I},style:[o.option,I?o.optionSelected:null],onPress:()=>s(O=>O===T.key?null:T.key),children:[jsxRuntime.jsx(v,{style:[o.optionLabel,I?o.optionLabelSelected:null],children:T.label}),jsxRuntime.jsx(reactNative.View,{style:[o.radio,I?o.radioSelected:null],children:I?jsxRuntime.jsx(Ae,{size:Ef,color:n.color.surface,strokeWidth:2}):null})]},T.key)})}),jsxRuntime.jsxs(reactNative.View,{style:o.inputWrap,children:[jsxRuntime.jsx(Qe,{style:o.input,placeholder:p.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:p.feedbackNotesPlaceholder,value:d,onChangeText:l,multiline:true,editable:!c}),d.length>0?jsxRuntime.jsx(v,{tier:"compact",style:[o.counter,m?o.counterOver:null],children:`${[...d].length}/${_r}`}):null]}),f?jsxRuntime.jsx(v,{style:o.failed,accessibilityRole:"alert",children:p.feedbackFailed}):null,jsxRuntime.jsxs(reactNative.View,{style:o.actions,children:[jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:p.feedbackSubmit,accessibilityState:{busy:c,disabled:c||m},disabled:c||m,style:[o.submit,c||m?o.submitDisabled:null],onPress:()=>{x();},children:jsxRuntime.jsx(v,{tier:"control",style:o.submitLabel,children:p.feedbackSubmit})}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:p.feedbackSkipA11y,hitSlop:8,onPress:g,style:o.skip,children:jsxRuntime.jsx(v,{tier:"control",style:o.skipLabel,children:p.feedbackSkip})})]})]})]})})}i(bs,"FeedbackReasons");function Rf(e){let t=e.color,r=e.type,n=e.radius,o=e.slots;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...reactNative.StyleSheet.absoluteFillObject,backgroundColor:bf},sheet:{backgroundColor:t.surface,borderTopLeftRadius:gs,borderTopRightRadius:gs,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14},handle:{alignSelf:"center",width:vf,height:hs,borderRadius:hs/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:In,height:In,borderRadius:In/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...C(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight},subtitle:{...C(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,backgroundColor:t.surface},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...C(e,"medium"),fontSize:r.size.body,color:t.text.primary},optionLabelSelected:{color:t.brandInk},radio:{width:xn,height:xn,borderRadius:xn/2,borderWidth:2,borderColor:t.brandBorder,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...C(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top"},counter:{...C(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...C(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:ms,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...re(o.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...C(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...fe(o.primaryButton)},skip:{minHeight:ms,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...C(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}i(Rf,"makeStyles");var Df=.88,Lf=420,Nf=58,Hf="rgba(17,17,17,0.28)",Uf=.08,zf=.1,Bf=.08,jf=.18,Wf=.78,Gf=.7,An=36,qf=10,Yf=14,Kf=12,$f=16,Qf=14,On=8,Xf=1.5,Zf=.5,Jf=Xt(mt.standard);function ey(e){return Math.min(Math.round(e*Df),Lf)}i(ey,"drawerPanelWidth");function Cs({chat:e,history:t}){let[r,n]=react.useState(t.open),o=react.useCallback(()=>n(false),[]);return t.open&&!r&&n(true),r?jsxRuntime.jsx(ty,{chat:e,history:t,onHidden:o}):null}i(Cs,"HistoryDrawer");function ty({chat:e,history:t,onHidden:r}){let n=_(),o=react.useMemo(()=>ny(n),[n]),a=q(),s=reactNativeSafeAreaContext.useSafeAreaInsets(),{width:d}=reactNative.useWindowDimensions(),l=ey(d),c=t.open,u=react.useRef(null);u.current===null&&(u.current=new reactNative.Animated.Value(a.drawerMs<=0&&c?1:0));let f=u.current;react.useEffect(()=>{if(!c&&a.drawerMs<=0){r();return}let T=reactNative.Animated.timing(f,{toValue:c?1:0,duration:a.drawerMs,easing:Jf,useNativeDriver:true});return T.start(({finished:I})=>{I&&!c&&r();}),()=>T.stop()},[c,f,a.drawerMs,r]);let y=f.interpolate({inputRange:[0,1],outputRange:[-l,0]}),b=t.filtered,g=t.rows.length===0,x=g&&t.loading?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,accessibilityLabel:G.loading,accessibilityState:{busy:true},children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{color:n.color.onPrimary}),jsxRuntime.jsx(v,{style:o.emptyBody,children:G.loading})]}):g&&t.error!==null?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(v,{style:o.emptyTitle,accessibilityRole:"alert",children:G.loadFailed}),jsxRuntime.jsx(v,{style:o.emptyBody,children:t.error}),jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:G.retryA11y,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load();},children:jsxRuntime.jsx(v,{tier:"control",style:o.retryText,children:G.retry})})]}):jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(v,{style:o.emptyTitle,children:t.emptyKind==="empty"?G.empty:G.noMatch}),jsxRuntime.jsx(v,{style:o.emptyBody,children:t.emptyKind==="empty"?G.emptyBody:G.noMatchBody})]}),m=!t.searching&&t.loadingMore?jsxRuntime.jsx(reactNative.View,{style:o.loadMoreFooter,children:jsxRuntime.jsx(v,{style:o.loadMoreLabel,children:G.loadingMore})}):null;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:"none",onRequestClose:t.close,children:jsxRuntime.jsxs(reactNative.View,{style:o.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:reactNative.StyleSheet.absoluteFill,onPress:t.close,accessibilityRole:"button",accessibilityLabel:G.closeA11y,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[o.backdrop,{opacity:f}]})}),jsxRuntime.jsx(reactNative.Animated.View,{style:[o.panel,{width:l,paddingTop:Math.max(Nf,s.top+n.space.md),transform:[{translateX:y}]}],accessibilityViewIsModal:true,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:o.keyboardAvoider,behavior:reactNative.Platform.OS==="ios"?"padding":"height",children:[jsxRuntime.jsxs(reactNative.View,{style:o.searchRow,children:[jsxRuntime.jsxs(reactNative.View,{style:o.searchPill,children:[jsxRuntime.jsx(ta,{size:Qf,color:n.color.text.muted,strokeWidth:1.5}),jsxRuntime.jsx(Qe,{value:t.query,onChangeText:T=>t.setQuery(T.replace(/^\s+/,"")),style:o.searchInput,placeholder:G.search,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:G.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:G.newConversation,style:o.newButton,onPress:t.newConversation,children:jsxRuntime.jsx(ra,{size:$f,color:n.color.text.primary,strokeWidth:1.5})})]}),jsxRuntime.jsx(v,{tier:"heading",style:o.heading,accessibilityRole:"header",children:G.heading}),t.error!==null&&!g?jsxRuntime.jsx(reactNative.View,{style:o.errorCard,children:jsxRuntime.jsx(v,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,jsxRuntime.jsx(reactNative.FlatList,{data:b,keyExtractor:T=>T.id,renderItem:({item:T})=>jsxRuntime.jsx(ry,{row:T,active:T.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(T.id);}}),contentContainerStyle:b.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:x,ListFooterComponent:m,onEndReached:t.loadMore,onEndReachedThreshold:Zf})]})})]})})}i(ty,"DrawerModal");function ry({row:e,active:t,disabled:r,styles:n,onPress:o}){let a=e.unreadCount!==null&&e.unreadCount>0;return jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:Pi(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:o,children:jsxRuntime.jsxs(reactNative.View,{style:n.itemRow,children:[jsxRuntime.jsx(v,{style:[n.itemTitle,a?n.itemTitleUnread:null],numberOfLines:1,children:qt(e.title)}),a?jsxRuntime.jsx(reactNative.View,{style:n.unreadDot}):null]})})}i(ry,"Row");function dr(e,t){if(!/^#[0-9a-f]{6}$/i.test(e))return "transparent";let r=Math.round(Math.min(1,Math.max(0,t))*255);return `${e}${r.toString(16).padStart(2,"0").toUpperCase()}`}i(dr,"inkWash");function ny(e){let t=e.color,r=e.slots,n=t.onPrimary;return reactNative.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:Hf},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.brand,paddingHorizontal:16,borderRightWidth:.5,borderRightColor:t.brandBorder,gap:12},keyboardAvoider:{flex:1,gap:12},searchRow:{flexDirection:"row",alignItems:"center",gap:10},searchPill:{flex:1,flexDirection:"row",alignItems:"center",gap:8,borderRadius:e.radius.pill,backgroundColor:t.surface,paddingHorizontal:14,paddingVertical:10,borderWidth:1,borderColor:dr(n,zf)},searchInput:{...C(e,"regular"),flex:1,fontSize:13,lineHeight:16,color:t.text.primary,padding:0},newButton:{width:An,height:An,borderRadius:An/2,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},heading:{...C(e,"bold"),fontSize:14,lineHeight:17,color:n,marginTop:4},list:{gap:10,paddingBottom:28},listEmpty:{flexGrow:1},item:{paddingVertical:12,paddingHorizontal:4,borderRadius:qf},itemActive:{backgroundColor:dr(n,Uf)},itemRow:{flexDirection:"row",alignItems:"center",gap:8},itemTitle:{...C(e,"regular"),flex:1,fontSize:14,lineHeight:18,color:n},itemTitleUnread:C(e,"bold"),unreadDot:{width:On,height:On,borderRadius:On/2,backgroundColor:t.danger,borderWidth:Xf,borderColor:n},errorCard:{borderRadius:Kf,borderWidth:.5,borderColor:t.danger,backgroundColor:t.surface,padding:12},errorText:{...C(e,"regular"),fontSize:11,lineHeight:16,color:t.danger},emptyCard:{borderRadius:Yf,padding:14,gap:6,backgroundColor:dr(n,Bf),borderWidth:.5,borderColor:dr(n,jf)},emptyTitle:{...C(e,"bold"),fontSize:12,lineHeight:15,color:n},emptyBody:{...C(e,"regular"),fontSize:11,lineHeight:17,color:n,opacity:Wf},retrySlot:{marginTop:8,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:7,borderWidth:1,borderColor:n,...re(r.primaryButton)},retryText:{...C(e,"bold"),fontSize:12,lineHeight:15,color:n,...fe(r.primaryButton)},loadMoreFooter:{paddingVertical:14,alignItems:"center"},loadMoreLabel:{...C(e,"regular"),fontSize:11,lineHeight:14,color:n,opacity:Gf}})}i(ny,"makeStyles");function Es(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}i(Es,"formatMessageTime");var Pt=15,ly=15,dy=6,cy=Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function ks({message:e,onCopy:t,sentiment:r=null,onSentiment:n,thanks:o=false}){let a=_(),s=react.useMemo(()=>uy(a),[a]),d=q(),l=e.role==="user",c=react.useMemo(()=>Es(e.createdAt),[e.createdAt]),u=t!==void 0&&e.text.length>0,f=!l&&n!==void 0&&e.responseId!==void 0,[y,b]=react.useState(false),g=react.useRef(null);react.useEffect(()=>()=>{g.current&&clearTimeout(g.current);},[]);let x=i(()=>{t!==void 0&&(Xe(t,e.text),b(true),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{b(false),g.current=null;},d.copiedMs));},"copy");return c===null&&!u&&!f?null:jsxRuntime.jsxs(reactNative.View,{style:s.wrap,children:[jsxRuntime.jsxs(reactNative.View,{style:[s.row,l?s.rowUser:s.rowAssistant],children:[c!==null?jsxRuntime.jsx(v,{tier:"compact",style:s.timestamp,children:c}):null,u?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:y?p.copied:l?p.copyUserMessage:p.copyAssistantMessage,hitSlop:ly,onPress:x,style:s.iconHit,children:y?jsxRuntime.jsx(Ae,{size:Pt,color:a.color.success,strokeWidth:2}):jsxRuntime.jsx(Qi,{size:Pt,color:a.color.text.timestamp,strokeWidth:1.5})}):null,f?Zn.map(({sentiment:m,label:T})=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:T,accessibilityState:{selected:r===m},hitSlop:dy,onPress:()=>n?.(m),style:s.iconHit,children:jsxRuntime.jsx($t,{size:Pt,color:a.color.sentiment[m],active:r===m,rotate:cy[m],strokeWidth:1.5})},m)):null]}),o?jsxRuntime.jsx(v,{style:s.thanks,accessibilityLiveRegion:"polite",children:p.feedbackThanks}):null]})}i(ks,"MessageFooter");function uy(e){let t=e.type;return reactNative.StyleSheet.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...C(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:Pt,height:Pt,alignItems:"center",justifyContent:"center"},thanks:{...C(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary}})}i(uy,"makeStyles");var ws="#000000",py="#83E0B4",fy=Object.freeze([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}),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:py,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:"#10462E",borderWidth:1}),Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}\u2019s vet visit.",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]),yy=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function my(e){return e==null?e:e.replace(yy,"").trim()}i(my,"formatBreedForPrompt");var gy=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 hy(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return gy.has(t)}i(hy,"isUninformativeBreed");function by(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}i(by,"unspecifiedBreedLabel");function vy(e,t){return hy(e)?by(t):String(e).replace(/\s+/gu," ").trim()}i(vy,"resolveBreedLabel");function _s(e){let t=e?.name?.trim()||p.emptyTitlePetFallback;return B(p.emptyTitle,{petName:t})}i(_s,"emptyStateTitle");function xs(e){let t=gn(e?.species),r=t==="cat"?"my cat":"my dog",n=e?.name?.trim()||null,o=n||r,a=vy(my(e?.breed),t)||null,s=hn(e?.ageYears),d=s===null?null:String(s);return Object.freeze(fy.map(l=>{let c=l.label.includes("{breed}"),u=l.label.includes("{ageYears}"),y=l.fallbackLabel!==void 0&&(c&&!a||u&&!d)&&l.fallbackLabel?l.fallbackLabel:l.label,b=B(y,{petName:o,breed:a??r,species:t,ageYears:d??""}),g=!n&&y.startsWith("{petName}")?b.charAt(0).toUpperCase()+b.slice(1):b;return Object.freeze({id:l.id,intent:l.intent,label:g,background:l.background,borderColor:l.borderColor,borderWidth:l.borderWidth})}))}i(xs,"resolveQuickPrompts");var Ey=36,Os=4,Ry=340;function Fs({pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o}){let a=_(),s=react.useMemo(()=>Py(a),[a]),d=react.useMemo(()=>xs(e),[e]),l=_s(e);return jsxRuntime.jsxs(reactNative.View,{style:s.block,children:[jsxRuntime.jsx(v,{tier:"heading",style:s.title,accessibilityRole:"header",children:l}),jsxRuntime.jsx(reactNative.View,{style:s.list,children:d.map((c,u)=>jsxRuntime.jsx(Sy,{prompt:c,index:u,petRef:t,onSend:r,onVetPrep:n,vet:o,pet:e,styles:s},c.id))})]})}i(Fs,"QuickPrompts");function Sy({prompt:e,index:t,pet:r,petRef:n,onSend:o,onVetPrep:a,vet:s,styles:d}){let l=q(),c=Be(l.followUpInMs,{delayMs:Wt(l,t)}),u={backgroundColor:e.background,borderColor:e.borderColor,borderWidth:e.borderWidth};return e.intent==="vet_report"?a!==void 0?jsxRuntime.jsx(reactNative.Animated.View,{style:c,children:jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Os,style:[d.chip,u],onPress:()=>{W(a,r);},children:jsxRuntime.jsx(v,{tier:"compact",style:d.chipLabel,children:e.label})})}):n===null?null:jsxRuntime.jsx(reactNative.Animated.View,{style:c,children:jsxRuntime.jsx(et,{entry:"chat",petRef:n,label:e.label,...s?.returnTo!==void 0?{returnTo:s.returnTo}:{},...s?.usState!==void 0?{usState:s.usState}:{},style:[d.chip,u],labelStyle:d.chipLabel})}):jsxRuntime.jsx(reactNative.Animated.View,{style:c,children:jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Os,style:[d.chip,u],onPress:()=>o(e.label),children:jsxRuntime.jsx(v,{tier:"compact",style:d.chipLabel,children:e.label})})})}i(Sy,"Chip");function Py(e){let t=e.color;return reactNative.StyleSheet.create({block:{gap:18,alignItems:"center",width:"100%"},title:{...C(e,"bold"),fontSize:28,lineHeight:34,color:t.text.primary,letterSpacing:-0.8,textAlign:"center",maxWidth:Ry},list:{width:"100%",gap:12,alignItems:"center"},chip:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:9,minHeight:Ey,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipLabel:{...C(e,"bold"),fontSize:12,lineHeight:14,color:ws,textAlign:"center"}})}i(Py,"makeStyles");var Mn=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;function Ms(e){return e.includes("*")||e.includes("`")}i(Ms,"hasInlineMarkup");function Vs(e){let t=[],r=0;Mn.lastIndex=0;for(let n=Mn.exec(e);n!==null;n=Mn.exec(e)){n.index>r&&t.push({kind:"text",text:e.slice(r,n.index)});let o=n[1],a=n[2],s=n[3];o!==void 0?t.push({kind:"bold",text:o}):a!==void 0?t.push({kind:"italic",text:a}):s!==void 0&&t.push({kind:"code",text:s}),r=n.index+n[0].length;}return r<e.length&&t.push({kind:"text",text:e.slice(r)}),t}i(Vs,"tokenizeInlineMarkdown");function Ds(e,t){return Ms(e)?Vs(e).map((r,n)=>{switch(r.kind){case "bold":return jsxRuntime.jsx(v,{style:t.bold,children:r.text},n);case "italic":return t.italic?jsxRuntime.jsx(v,{style:t.italic,children:r.text},n):r.text;case "code":return t.code?jsxRuntime.jsx(v,{style:t.code,children:r.text},n):r.text;default:return r.text}}):e}i(Ds,"renderInlineMarkdown");var Hs=6,Bs=520,Iy=Math.round(Bs*.18),Us=.44,Ay=.5,zs=[0,.5,1],Oy=[0,1,2];function js(){let e=_(),t=react.useMemo(()=>My(e),[e]),r=!e.motion.reducedMotion;return jsxRuntime.jsx(reactNative.View,{style:t.card,accessible:true,accessibilityRole:"text",accessibilityLabel:p.typing,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:Oy.map(n=>r?jsxRuntime.jsx(Fy,{index:n,style:t.dot},n):jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotStatic]},n))})}i(js,"TypingIndicator");function Fy({index:e,style:t}){let r=react.useRef(new reactNative.Animated.Value(0)).current;react.useEffect(()=>{let a=reactNative.Animated.sequence([reactNative.Animated.delay(e*Iy),reactNative.Animated.loop(reactNative.Animated.timing(r,{toValue:1,duration:Bs,useNativeDriver:true}))]);return a.start(),()=>a.stop()},[r,e]);let n=r.interpolate({inputRange:zs,outputRange:[Us,1,Us]}),o=r.interpolate({inputRange:zs,outputRange:[0,-3.5,0]});return jsxRuntime.jsx(reactNative.Animated.View,{style:[t,{opacity:n,transform:[{translateY:o}]}]})}i(Fy,"AnimatedDot");function My(e){let t=e.color,r=e.space,n=e.radius;return reactNative.StyleSheet.create({card:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:r.xs,paddingHorizontal:r.md,paddingVertical:r.sm,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},dot:{width:Hs,height:Hs,borderRadius:n.pill,backgroundColor:t.brand},dotStatic:{opacity:Ay}})}i(My,"makeStyles");function Ws(e,t){let r={entry:"chat",petRef:e};return t?.returnTo!==void 0&&(r.returnTo=t.returnTo),t?.usState!==void 0&&(r.usState=t.usState),r}i(Ws,"chatVetVisitOptions");var Ny=16,Hy=.75,Dn=12,Gs=15,Uy=18,ur=22,zy=14,By=8,jy=20,Wy=10,Gy=13;function Ys({surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o}){let a=_(),s=react.useMemo(()=>qy(a),[a]),d=q(),l=e.tier,c=e.source;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(en,{visible:e.showBanner&&l!==null,inMs:d.bannerInMs,outMs:d.bannerOutMs,style:s.pinned,children:l!==null&&c!==null?jsxRuntime.jsxs(reactNative.View,{accessibilityRole:"alert",style:[s.card,{borderColor:l.borderColor,backgroundColor:l.backgroundColor}],children:[jsxRuntime.jsx(v,{tier:"compact",style:[s.label,{color:l.textColor}],children:l.label}),c.reason!==null?jsxRuntime.jsx(v,{style:[s.reason,{color:l.reasonColor}],children:c.reason}):null,e.showVetAction?r!==void 0?jsxRuntime.jsx(Ue,{render:()=>r(l.level),fallback:jsxRuntime.jsx(qs,{tier:l,petRef:t,onFindVet:n,vet:o,styles:s}),resetKey:l.level}):jsxRuntime.jsx(qs,{tier:l,petRef:t,onFindVet:n,vet:o,styles:s}):null,e.dismissLabel!==null?jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:e.dismissLabel,hitSlop:By,containerStyle:s.closeSlot,style:s.closeButton,onPress:e.dismiss,children:jsxRuntime.jsx(ze,{size:zy,color:l.textColor,strokeWidth:1.5})}):null]}):null}),jsxRuntime.jsx(en,{visible:e.showCompactIcon,inMs:d.iconInMs,outMs:d.iconOutMs,style:s.indicatorRow,children:jsxRuntime.jsx(D,{accessibilityRole:"button",accessibilityLabel:p.showLatestVetAlert,hitSlop:Wy,onPress:e.expand,children:jsxRuntime.jsx(Xi,{size:jy,color:a.color.text.muted,strokeWidth:2})})})]})}i(Ys,"UrgencyBanner");function qs({tier:e,petRef:t,onFindVet:r,vet:n,styles:o}){let a=_(),s=tr(Ws(t,n)),d=s.status==="opening",l=s.available?()=>{s.open();}:r!==void 0?()=>{W(r,e.level);}:null;if(l===null)return null;let c=kr(a.slots.vetVisitButton)?.textColor??e.textColor;return jsxRuntime.jsxs(D,{accessibilityRole:"button",accessibilityLabel:p.findVetA11y,accessibilityState:{busy:d},containerStyle:o.findVetSlot,style:[o.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},o.findVetSlotBox,d?o.findVetBusy:null],onPress:l,children:[jsxRuntime.jsx(na,{size:Gy,color:c,strokeWidth:1.5}),jsxRuntime.jsx(v,{tier:"control",style:[o.findVetLabel,{color:c}],children:p.findVet})]})}i(qs,"VetAction");function qy(e){let t=kr(e.slots.vetVisitButton);return reactNative.StyleSheet.create({pinned:{marginTop:0,marginBottom:4,paddingHorizontal:e.space.lg},card:{borderRadius:Ny,borderWidth:Hy,paddingHorizontal:14,paddingVertical:8,gap:2},label:{...C(e,"monoBold"),fontSize:Dn,lineHeight:Gs},reason:{...C(e,"regular"),fontSize:Dn,lineHeight:Uy,paddingRight:ur},findVetSlot:{alignSelf:"flex-start",marginTop:6},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...re(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...C(e,"monoBold"),fontSize:Dn,lineHeight:Gs},closeSlot:{position:"absolute",top:6,right:6},closeButton:{width:ur,height:ur,borderRadius:ur/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:16,paddingTop:2,paddingBottom:4}})}i(qy,"makeStyles");function Ks(){let e=cn(),{handle:t}=ie(),r=react.useCallback(n=>t.setActivePet(n),[t]);return react.useMemo(()=>({...e,setActivePet:r}),[e,r])}i(Ks,"useChatPets");var tm=300,rm=3e3,$s=120,nt=44,nm=120,om="86%",Qs=15,Xs=22,fr=.5,im=.04,am=8,sm=2,lm=1,dm=.6,cm=22,um=48,Zs=1.25,pm=14,fm=18,ym=6,mm=14,gm=.04,hm=12,bm=2,vm=2,Js=36,Cm=20,rt=36,yr=(nt-rt)/2,Em=24,Rm=22,Sm=.4,Nn=30,Pm=20,Tm=.4,km=480,wm="12%",_m=Object.freeze(["photo"]),xm=1;function Im(e){let{style:t,renderPending:r}=e;return jsxRuntime.jsx(Hi,{capability:"chat",style:t,...r?{renderPending:r}:{},children:jsxRuntime.jsx(Am,{...e})})}i(Im,"EverfurChat");function Am({petRef:e,conversationId:t,style:r,renderPending:n,onCopy:o,onPetChange:a,onVetPrep:s,onFindVet:d,renderVetAction:l,attachments:c,pet:u,onAddPet:f,checkinTarget:y,initialAsk:b,composerSeed:g,lifecycle:x,draftStore:m,vetReturnTo:T,vetUsState:I}){let{theme:O,styles:F}=he(),h=q(),E=react.useMemo(()=>Fi(e,t),[e,t]),R=xt(E),L=Ii(R),P=Ks(),k=Ti(R),M=reactNativeSafeAreaContext.useSafeAreaInsets(),H=Ai(R),X=react.useMemo(()=>d===void 0?void 0:()=>{W(d,"emergency");},[d]),U=react.useMemo(()=>T===void 0&&I===void 0?void 0:{returnTo:T,usState:I},[T,I]),te=kn(P.pets,R.petRef),oe=react.useMemo(()=>_i(R.messages,te?.name??null),[R.messages,te?.name]),z=xi(oe);Zt(z.showBanner,h),bi(R.openCheckin,y),ui(R.askEverfur,R.isBootstrapping,b);let De=react.useMemo(()=>Hr(g),[g]);gi(x,{conversationId:R.conversationId===null?null:String(R.conversationId),isTurnInFlight:R.isStreaming,refresh:R.refreshActiveThread});let Tt=(R.hasUnreadThreads??false)||k.rows.some(be=>be.unreadCount!==null&&be.unreadCount>0)||(R.unreadCount??0)>0,it=di(R.messages),[Ye,Ke]=react.useState(null),il=react.useCallback(()=>Ke(null),[]),[at,mr]=react.useState(null),[al,Un]=react.useState(null),$e=react.useRef(null);react.useEffect(()=>()=>{$e.current&&clearTimeout($e.current);},[]);let zn=react.useCallback(be=>{Un(String(be)),$e.current&&clearTimeout($e.current),$e.current=setTimeout(()=>{Un(null),$e.current=null;},rm);},[]),sl=react.useCallback((be,kt)=>{let st=be.responseId;if(st===void 0)return;let ul=R.sentimentByMessage[String(st)];R.feedback(st,kt),kt==="down"&&ul!=="down"&&mr(st);},[R]),ll=react.useCallback(async(be,kt)=>at===null||!(await R.feedback(at,"down",be??"other",kt)).ok?false:(mr(null),zn(at),true),[R,at,zn]),dl=react.useCallback(()=>mr(null),[]),cl=react.useCallback(be=>{R.send(be);},[R.send]),Bn={send:R.send,stop:R.stop,isStreaming:R.isStreaming,conversationId:R.conversationId,seed:De,draftStore:m,onStage:it.stage,onPreview:Ke};return jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:[F.container,{paddingTop:M.top},r],behavior:reactNative.Platform.OS==="ios"?"padding":void 0,children:[jsxRuntime.jsx(Za,{pets:P,petRef:R.petRef,historyUnread:Tt,onOpenHistory:k.show,onPetChange:a,onAddPet:f,vet:U}),u!==void 0?jsxRuntime.jsx(Om,{petRef:e??null,pet:u,onRegistered:P.refresh}):null,jsxRuntime.jsx(Ys,{surface:z,petRef:R.petRef,renderVetAction:l,onFindVet:d,vet:U}),jsxRuntime.jsx(reactNative.View,{style:F.body,children:Lm(L,R,{notice:H,vet:U,onCheckinFindVet:X,onSelectPrompt:cl,renderPending:n,shownPet:te,onVetPrep:s,onCopy:o,onSentiment:sl,thanksFor:al,imagesByMessage:it.byMessage,onPreview:Ke,onAddPet:f})}),c!==void 0?jsxRuntime.jsx(Fm,{...Bn,attachments:c}):jsxRuntime.jsx(nl,{...Bn,attachments:null}),jsxRuntime.jsx(ji,{}),O.meta.hidePoweredBy?null:jsxRuntime.jsx(v,{tier:"compact",style:F.poweredBy,accessibilityRole:"text",accessibilityLabel:p.poweredBy,children:p.poweredBy}),jsxRuntime.jsx(Cs,{chat:R,history:k}),jsxRuntime.jsx(bs,{visible:at!==null,onSubmit:ll,onSkip:dl}),jsxRuntime.jsx(ua,{uri:Ye?.uri??null,label:Ye?.label??"",onClose:il})]})}i(Am,"ChatBody");function Om({petRef:e,pet:t,onRegistered:r}){let{styles:n}=he(),o=oi(e,t,r);return o.status!=="failed"||o.error===null?null:jsxRuntime.jsxs(reactNative.View,{style:n.setupNotice,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(v,{tier:"compact",style:n.setupNoticeText,children:o.error.displayMessage}),jsxRuntime.jsx(reactNative.Pressable,{onPress:o.retry,accessibilityRole:"button",accessibilityLabel:p.retry,hitSlop:yr,children:jsxRuntime.jsx(v,{tier:"control",style:n.setupNoticeAction,children:p.retry})})]})}i(Om,"PetSetupNotice");function Fm({attachments:e,...t}){let r=react.useMemo(()=>ln(),[]),n=Or({maxPerMessage:e.maxPerMessage??xm,transport:r}),o=react.useMemo(()=>({state:n,sources:e.sources??_m,pick:e.pick}),[n,e.sources,e.pick]);return jsxRuntime.jsx(nl,{...t,attachments:o})}i(Fm,"ComposerWithAttachments");function nl({send:e,stop:t,isStreaming:r,conversationId:n,attachments:o,seed:a,draftStore:s,onStage:d,onPreview:l}){let{theme:c,styles:u}=he(),f=q(),[y,b]=Ei(e,n,a);Ri(s,n===null?null:String(n),y,b);let[g,x]=react.useState(false),[m,T]=react.useState(false);react.useEffect(()=>{T(false);},[n]);let I=c.meta.placeholder??p.placeholder,O=o?.state.uploading??false,F=o?.state.failed??false,h=O||F,E=o?.state.attachments??Mm;Zt(E.length,f);let R=react.useCallback(()=>{if(y.trim().length===0||h||[...y].length>xr)return;let U=o?.state.s3Keys??Vm;o!==null&&U.length>0?(d(o.state.attachments.filter(te=>te.status==="uploaded").map(te=>({uri:te.previewUri,filename:te.filename}))),e(y,{imageS3Keys:U}),o.state.clear()):e(y),b(""),T(false);},[y,e,h,o,d]),L=react.useCallback(()=>{t();},[t]),P=react.useCallback(U=>{x(false),o!==null&&(T(false),o.state.dismissRejected(),Xe(o.pick,U).then(te=>{if(!te.ok){T(true);return}te.value!==null&&o.state.add(te.value);}));},[o]),M=react.useMemo(()=>[...y].length>xr,[y])||h,H=o!==null&&E.length>=o.state.maxPerMessage,X=c.slots.sendButton?.textColor??c.color.brandInk;return jsxRuntime.jsxs(reactNative.View,{style:u.composerOuter,children:[o!==null&&g?jsxRuntime.jsx(ya,{sources:o.sources,full:H,onPick:P,onClose:()=>x(false)}):null,jsxRuntime.jsxs(reactNative.View,{style:u.composer,children:[o!==null?jsxRuntime.jsx(Ta,{attachments:E,rejected:m?Dm:o.state.rejected,uploadFailed:F,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:U=>l({uri:U.previewUri,label:U.filename})}):null,jsxRuntime.jsxs(reactNative.View,{style:u.composerRow,children:[o!==null?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:Io(E.length,o.state.maxPerMessage),accessibilityState:{disabled:H,expanded:g},disabled:H,hitSlop:(nt-Nn)/2,style:[u.attachControl,H?u.attachControlDisabled:null],onPress:()=>x(U=>!U),children:jsxRuntime.jsx(Zi,{size:Pm,color:H?c.color.text.muted:c.color.brandInk,strokeWidth:1.75})}):null,jsxRuntime.jsx(Qe,{style:u.input,value:y,onChangeText:b,placeholder:I,placeholderTextColor:c.slots.composerInput?.textColor??c.color.text.placeholder,accessibilityLabel:I,onSubmitEditing:R,returnKeyType:"send",blurOnSubmit:false,multiline:true,editable:true}),r?jsxRuntime.jsx(reactNative.Pressable,{onPress:L,accessibilityRole:"button",accessibilityLabel:p.stop,hitSlop:yr,style:u.sendControl,children:jsxRuntime.jsx(reactNative.View,{style:u.sendDisc,testID:"everfur-stop-disc",children:jsxRuntime.jsx(ia,{size:Rm,color:X,testID:"everfur-stop-glyph"})})}):jsxRuntime.jsx(reactNative.Pressable,{onPress:R,disabled:M,accessibilityRole:"button",accessibilityLabel:p.send,accessibilityState:{disabled:M,busy:O},hitSlop:yr,style:[u.sendControl,M?u.sendControlDisabled:null],children:jsxRuntime.jsx(reactNative.View,{style:u.sendDisc,testID:"everfur-send-disc",children:jsxRuntime.jsx(oa,{size:Em,color:X,testID:"everfur-send-glyph"})})})]})]})]})}i(nl,"Composer");var Mm=Object.freeze([]),Vm=Object.freeze([]),Dm=Object.freeze({code:"unknown",retryable:true,filename:""});function Lm(e,t,r){switch(e){case "loading":return r.renderPending?jsxRuntime.jsx(Ue,{render:r.renderPending,fallback:jsxRuntime.jsx(el,{})}):jsxRuntime.jsx(el,{});case "empty":return jsxRuntime.jsx(Nm,{pet:r.shownPet,petRef:t.petRef,prompts:t.suggestedPrompts,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet});case "error":return jsxRuntime.jsx(Um,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case "populated":return jsxRuntime.jsx(zm,{messages:t.messages,prompts:t.suggestedPrompts,onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,thanksFor:r.thanksFor,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});default:return Ft(e)}}i(Lm,"renderView");function el(){let{theme:e,styles:t}=he(),[r,n]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>n(true),tm);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx(reactNative.View,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:p.loading,children:r?jsxRuntime.jsx(reactNative.ActivityIndicator,{color:e.color.brandInk}):null})}i(el,"LoadingState");function Nm({pet:e,petRef:t,prompts:r,onSelectPrompt:n,onVetPrep:o,vet:a}){let{styles:s}=he();return jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.emptyContent,keyboardShouldPersistTaps:"handled",accessibilityLabel:p.empty,children:[jsxRuntime.jsx(Fs,{pet:e,petRef:t,onSend:n,onVetPrep:o,vet:a}),jsxRuntime.jsx(ol,{prompts:r,onSelectPrompt:n})]})}i(Nm,"EmptyState");function ol({prompts:e,onSelectPrompt:t}){let{styles:r}=he();return e.length===0?null:jsxRuntime.jsxs(reactNative.View,{style:r.followUps,children:[jsxRuntime.jsx(v,{tier:"compact",style:r.followUpsLabel,accessibilityRole:"header",children:p.followUps}),e.map((n,o)=>jsxRuntime.jsx(Hm,{prompt:n,index:o,onSelectPrompt:t},n))]})}i(ol,"FollowUps");function Hm({prompt:e,index:t,onSelectPrompt:r}){let{styles:n}=he(),o=q(),a=Be(o.followUpInMs,{delayMs:Wt(o,t)});return jsxRuntime.jsx(reactNative.Animated.View,{style:a,children:jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,style:[n.followUpRow,t>0?n.followUpDivider:null],children:jsxRuntime.jsx(v,{style:n.followUpText,children:e})})})}i(Hm,"FollowUpRow");function Um({error:e,onRetry:t,onAddPet:r}){let{styles:n}=he(),o=ni(e)?yi(r):void 0;return jsxRuntime.jsxs(reactNative.View,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(v,{style:n.errorText,children:e.displayMessage}),o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:p.addPet,style:n.retryButton,children:jsxRuntime.jsx(v,{tier:"control",style:n.retryLabel,children:p.addPet})}):null,e.retryable?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:p.retry,style:n.retryButton,children:jsxRuntime.jsx(v,{tier:"control",style:n.retryLabel,children:p.retry})}):null]})}i(Um,"ErrorState");function zm({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:o,onCopy:a,sentimentByMessage:s,onSentiment:d,thanksFor:l,imagesByMessage:c,onPreview:u,notice:f,reconnecting:y,onRetry:b,onStartNew:g,petRef:x,onFindVet:m,vet:T}){let{styles:I}=he(),O=q();Zt(e.length,O);let F=Oi(e,n),h=e[e.length-1];return jsxRuntime.jsxs(reactNative.ScrollView,{style:I.list,contentContainerStyle:I.listContent,accessibilityLabel:p.transcript,keyboardShouldPersistTaps:"handled",children:[e.map(E=>E.checkin?jsxRuntime.jsx(is,{message:E,checkin:E.checkin,onAnswer:o,petRef:x,onFindVet:m,vet:T},E.id):jsxRuntime.jsx(Wm,{message:E,revealing:n&&E===h&&E.role==="assistant",onCopy:a,sentiment:E.responseId===void 0?null:s[String(E.responseId)]??null,onSentiment:d,thanks:l!==null&&E.responseId!==void 0&&String(E.responseId)===l,images:c[E.id]??jm,onPreview:u},E.id)),y?jsxRuntime.jsx(v,{tier:"compact",style:I.reconnectingCaption,accessibilityRole:"text",children:p.reconnecting}):null,F?jsxRuntime.jsx(js,{}):null,f!==null?jsxRuntime.jsx(Bm,{notice:f,onRetry:b,onStartNew:g}):null,n?null:jsxRuntime.jsx(ol,{prompts:t,onSelectPrompt:r})]})}i(zm,"PopulatedState");function Bm({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=he(),o=e.tone==="error";return jsxRuntime.jsxs(reactNative.View,{style:[n.turnNotice,o?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(v,{tier:"control",style:[n.turnNoticeTitle,o?n.turnNoticeTitleError:null],children:e.title}),jsxRuntime.jsx(v,{tier:"compact",style:n.turnNoticeBody,children:e.body}),jsxRuntime.jsx(reactNative.Pressable,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:yr,style:n.turnNoticeAction,children:jsxRuntime.jsx(v,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}i(Bm,"TurnNoticeCard");var jm=Object.freeze([]);function Wm({message:e,revealing:t,onCopy:r,sentiment:n,onSentiment:o,thanks:a,images:s,onPreview:d}){let{styles:l}=he(),c=q(),u=Be(c.messageInMs),f=ca(e.text,t,c),y=e.role==="user",b=y?p.senderUser:p.senderAssistant,g=react.useCallback(m=>o(e,m),[o,e]),x=e.pending!==true;return jsxRuntime.jsxs(reactNative.Animated.View,{style:[l.rowBlock,y?l.rowBlockUser:l.rowBlockAssistant,u],children:[jsxRuntime.jsx(reactNative.View,{style:[l.row,y?l.rowUser:l.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${b}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:jsxRuntime.jsxs(reactNative.View,{style:[l.bubble,y?l.bubbleUser:l.bubbleAssistant,e.pending?l.bubblePending:null],children:[y&&s.length>0?jsxRuntime.jsx(ka,{images:s,onPreview:m=>d({uri:m.uri,label:m.filename})}):null,jsxRuntime.jsx(v,{style:y?l.bubbleTextUser:l.bubbleTextAssistant,children:y?e.text:Ds(f,{bold:l.bubbleBold,italic:l.bubbleItalic,code:l.bubbleCode})})]})}),!y&&!t?jsxRuntime.jsx(fs,{citations:e.citations}):null,x?jsxRuntime.jsx(ks,{message:e,onCopy:r,sentiment:n,onSentiment:e.responseId===void 0?void 0:g,thanks:a}):null]})}i(Wm,"MessageRow");function he(){let e=_(),t=react.useMemo(()=>Gm(e),[e]);return {theme:e,styles:t}}i(he,"useChatTheme");function Gm(e){let t=e.color,r=e.space,n=e.radius,o=e.type,a=e.slots;return reactNative.StyleSheet.create({container:{flex:1,minHeight:$s,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:$s,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},emptyContent:{flexGrow:1,alignItems:"center",justifyContent:"flex-start",paddingTop:wm,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:km,gap:18},errorText:{...C(e,"regular"),fontSize:o.size.subtitle,lineHeight:o.size.subtitle*o.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:nt,minWidth:nt,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...re(a.primaryButton)},retryLabel:{...C(e,"medium"),color:t.onPrimary,fontSize:o.size.body,...fe(a.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...C(e,"regular"),color:t.danger,fontSize:o.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.lg,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...C(e,"bold"),color:t.text.primary,fontSize:o.size.body},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...C(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal},turnNoticeAction:{minHeight:nt,justifyContent:"center"},turnNoticeActionLabel:{...C(e,"medium"),color:t.brandInk,fontSize:o.size.body},setupNoticeAction:{...C(e,"medium"),color:t.brandInk,fontSize:o.size.caption},reconnectingCaption:{...C(e,"medium"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},list:{flex:1},listContent:{padding:r.lg,gap:r.md},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:om},bubbleUser:{padding:Qs,backgroundColor:t.bubbleUser,borderRadius:n.xl,borderBottomRightRadius:n.sm,borderWidth:fr,borderColor:t.accentEdge,shadowColor:t.brand,shadowOpacity:im,shadowRadius:am,shadowOffset:{width:0,height:sm},elevation:lm,...re(a.userBubble,fr)},bubbleAssistant:a.assistantBubble?.backgroundColor===void 0?{...re(a.assistantBubble,fr)}:{padding:Qs,borderRadius:n.xl,...re(a.assistantBubble,fr)},bubblePending:{opacity:dm},bubbleTextUser:{...C(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:Xs,...fe(a.userBubble)},bubbleTextAssistant:{...C(e,"medium"),color:t.text.primary,fontSize:o.size.body,lineHeight:Xs,...fe(a.assistantBubble)},bubbleBold:C(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:C(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.sm,borderRadius:n.md,backgroundColor:t.brandSoft,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},followUpsLabel:{...C(e,"medium"),color:t.text.secondary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase",paddingHorizontal:r.md,paddingTop:r.md,paddingBottom:r.sm},followUpRow:{minHeight:nt,justifyContent:"center",paddingHorizontal:r.md,paddingVertical:r.sm},followUpDivider:{borderTopWidth:reactNative.StyleSheet.hairlineWidth,borderTopColor:t.brandBorder},followUpText:{...C(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug},composerOuter:{position:"relative"},composer:{marginHorizontal:r.md,marginTop:r.xs,marginBottom:r.sm,minHeight:um,justifyContent:"center",paddingLeft:pm,paddingRight:fm,paddingVertical:ym,backgroundColor:t.composerFill,borderWidth:Zs,borderColor:t.composerBorder,borderRadius:cm,shadowColor:t.shadow,shadowOpacity:gm,shadowRadius:hm,shadowOffset:{width:0,height:bm},elevation:vm,...re(a.composerInput,Zs)},composerRow:{flexDirection:"row",alignItems:"center",gap:mm,minHeight:Js},attachControl:{width:Nn,height:Nn,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:Tm},input:{flex:1,minHeight:Js,maxHeight:nm,paddingHorizontal:0,paddingVertical:0,...C(e,"regular"),fontSize:o.size.body,lineHeight:Cm,color:t.text.primary,...fe(a.composerInput)},sendControl:{minHeight:rt,minWidth:rt,alignItems:"center",justifyContent:"center"},sendDisc:{width:rt,height:rt,borderRadius:rt/2,alignItems:"center",justifyContent:"center",...re(a.sendButton)},sendControlDisabled:{opacity:Sm},poweredBy:{...C(e,"regular"),color:t.text.muted,fontSize:o.size.micro,textAlign:"center",paddingBottom:r.xs}})}i(Gm,"makeStyles");exports.EverfurChat=Im;exports.createRnChatAttachmentTransport=ln;exports.useChatAttachments=Or;exports.useEverfurChat=xt;exports.useEverfurPets=cn;
|