@everfur/sdk 0.5.9 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +279 -0
- package/dist/{BookedScreen-BJPbXLCG.d.ts → BookedScreen-DFJcgf1e.d.ts} +12 -2
- package/dist/{BookedScreen-Cnld-jB_.d.cts → BookedScreen-R5X_Zrlh.d.cts} +12 -2
- package/dist/{Chat-C9dVhnyt.d.ts → Chat-DZpYH8Uh.d.ts} +4 -4
- package/dist/{Chat-WmdRwC3b.d.cts → Chat-bATY4atj.d.cts} +4 -4
- package/dist/{DepthViews-CBoI9EYy.d.ts → DepthViews-BpHUbjSY.d.cts} +1 -1
- package/dist/{DepthViews-CmxhM8iP.d.ts → DepthViews-C4DC4Kom.d.cts} +1 -1
- package/dist/{DepthViews-NPFtO5Kz.d.cts → DepthViews-dLTizxjr.d.ts} +1 -1
- package/dist/{DepthViews-DoODlUnQ.d.cts → DepthViews-qBIoA48w.d.ts} +1 -1
- package/dist/animations/index.cjs +1 -1
- package/dist/animations/index.d.cts +3 -3
- package/dist/animations/index.d.ts +3 -3
- package/dist/animations/index.js +1 -1
- package/dist/{attachments-R2oajKPT.d.ts → attachments-CPRFfoHT.d.ts} +2 -2
- package/dist/{attachments-c4mJcIWU.d.cts → attachments-CUOGILir.d.cts} +5 -5
- package/dist/{attachments-CuFT1o5q.d.ts → attachments-CXAnZcEg.d.ts} +5 -5
- package/dist/{attachments-OaW36D0H.d.cts → attachments-Ce06TWqe.d.cts} +2 -2
- package/dist/{bookingCopy-DGQPrisa.d.cts → bookingCopy-BwVopcoV.d.cts} +451 -50
- package/dist/{bookingCopy-EtPJ4nME.d.ts → bookingCopy-DFTv9w6J.d.ts} +451 -50
- package/dist/{bookingTypes-DCs8mmBb.d.cts → bookingTypes-D4pD3tHs.d.cts} +13 -1
- package/dist/{bookingTypes-DCs8mmBb.d.ts → bookingTypes-D4pD3tHs.d.ts} +13 -1
- package/dist/{branding-Ry0em51L.d.ts → branding-Bio5MM6g.d.cts} +135 -3
- package/dist/{branding-DiaCIJZL.d.cts → branding-ytH4jJq1.d.ts} +135 -3
- package/dist/{callCopy-CPe9mbwG.d.cts → callCopy-DHjem0R-.d.cts} +12 -1
- package/dist/{callCopy-CPe9mbwG.d.ts → callCopy-DHjem0R-.d.ts} +12 -1
- package/dist/{casesRepository-DB5c8AAo.d.cts → casesRepository-CJchNp3x.d.cts} +1 -1
- package/dist/{casesRepository-Cu8h8gQK.d.ts → casesRepository-DAVcY3jC.d.ts} +1 -1
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.d.cts +9 -9
- package/dist/chat/index.d.ts +9 -9
- package/dist/chat/index.js +1 -1
- package/dist/client/index.cjs +6 -6
- package/dist/client/index.d.cts +10 -10
- package/dist/client/index.d.ts +10 -10
- package/dist/client/index.js +6 -6
- package/dist/{config-DlR_I-0S.d.ts → config-ZxwCylac.d.ts} +1 -1
- package/dist/{config-DQFMkaTU.d.cts → config-h5h6TsHL.d.cts} +1 -1
- package/dist/consent/index.cjs +1 -1
- package/dist/consent/index.d.cts +5 -5
- package/dist/consent/index.d.ts +5 -5
- package/dist/consent/index.js +1 -1
- package/dist/{context-DZEieVJ5.d.cts → context-CtsAgJnc.d.cts} +7 -7
- package/dist/{context-CLuquPRB.d.ts → context-DtPIshVA.d.ts} +7 -7
- package/dist/{copy-B2DOzSSy.d.cts → copy-CaWaplQc.d.cts} +2 -2
- package/dist/{copy-ptTCT5-J.d.ts → copy-Cg89Qoal.d.ts} +2 -2
- package/dist/core/index.cjs +9 -9
- package/dist/core/index.d.cts +21 -21
- package/dist/core/index.d.ts +21 -21
- package/dist/core/index.js +9 -9
- package/dist/{depth-CtyC7HOF.d.ts → depth-Bo4bAwcn.d.ts} +132 -38
- package/dist/{depth-DuOyvthD.d.cts → depth-EXZYEO70.d.cts} +132 -38
- package/dist/{entitlementRepository-DlGwxZ1k.d.cts → entitlementRepository-BYtVb1oU.d.cts} +3 -3
- package/dist/{entitlementRepository-CAtyh8Xt.d.ts → entitlementRepository-DcbIx8yV.d.ts} +3 -3
- package/dist/{identity-D_NR9ucT.d.ts → identity-EC5-apbY.d.ts} +1 -1
- package/dist/{identity-BC9AF3y4.d.cts → identity-b5Vp32Vp.d.cts} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +17 -17
- package/dist/index.d.ts +17 -17
- package/dist/index.js +6 -6
- package/dist/notifications/index.d.cts +2 -2
- package/dist/notifications/index.d.ts +2 -2
- package/dist/{pets-DuuNvKTK.d.ts → pets-B_27_agU.d.ts} +1 -1
- package/dist/{pets-D7UjvR1A.d.cts → pets-DM8QvKLo.d.cts} +1 -1
- package/dist/{petsRepository-llMvpMkp.d.cts → petsRepository-BJsJ4cju.d.cts} +1 -1
- package/dist/{petsRepository-C28NKFwy.d.ts → petsRepository-CuYZZaI5.d.ts} +1 -1
- package/dist/photo/index.cjs +1 -1
- package/dist/photo/index.js +1 -1
- package/dist/{ports-Dbw2h_M1.d.cts → ports-ZmJYgd5I.d.cts} +10 -9
- package/dist/{ports-s45HNNyc.d.ts → ports-nXHf50_X.d.ts} +10 -9
- package/dist/records/depth/index.cjs +2 -2
- package/dist/records/depth/index.d.cts +7 -7
- package/dist/records/depth/index.d.ts +7 -7
- package/dist/records/depth/index.js +2 -2
- package/dist/records/index.cjs +3 -3
- package/dist/records/index.d.cts +19 -10
- package/dist/records/index.d.ts +19 -10
- package/dist/records/index.js +3 -3
- package/dist/{requestFunnel-D_o7se38.d.cts → requestFunnel-C_cZXhIA.d.cts} +2 -2
- package/dist/{requestFunnel-CqwOiZNJ.d.ts → requestFunnel-Ve9BshTB.d.ts} +2 -2
- package/dist/{runtimeTypes-DS0RLoKN.d.ts → runtimeTypes-ByKsp8hm.d.ts} +5 -5
- package/dist/{runtimeTypes-BNBENMkz.d.cts → runtimeTypes-D155OlBW.d.cts} +5 -5
- package/dist/server/events/index.cjs +1 -1
- package/dist/server/events/index.d.cts +2 -2
- package/dist/server/events/index.d.ts +2 -2
- package/dist/server/events/index.js +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +1 -1
- package/dist/televet/booking/index.cjs +4 -1
- package/dist/televet/booking/index.d.cts +116 -29
- package/dist/televet/booking/index.d.ts +116 -29
- package/dist/televet/booking/index.js +4 -1
- package/dist/televet/call/index.cjs +1 -1
- package/dist/televet/call/index.d.cts +1 -1
- package/dist/televet/call/index.d.ts +1 -1
- package/dist/televet/call/index.js +1 -1
- package/dist/televet/index.cjs +1 -1
- package/dist/televet/index.js +1 -1
- package/dist/testing/index.cjs +3 -3
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +3 -3
- package/dist/testing/rn/index.cjs +1 -1
- package/dist/testing/rn/index.d.cts +14 -12
- package/dist/testing/rn/index.d.ts +14 -12
- package/dist/testing/rn/index.js +1 -1
- package/dist/testing/web/index.d.cts +9 -9
- package/dist/testing/web/index.d.ts +9 -9
- package/dist/{timelineRows-B6nCq30k.d.cts → timelineRows-BNF43SXK.d.cts} +1 -1
- package/dist/{timelineRows-DacfDpDU.d.ts → timelineRows-DXpjECfA.d.ts} +1 -1
- package/dist/{tokens-DOTIxrws.d.cts → tokens-BYtbKwFh.d.cts} +12 -4
- package/dist/{tokens-DOTIxrws.d.ts → tokens-BYtbKwFh.d.ts} +12 -4
- package/dist/{typeStyle-achxqQ-h.d.cts → typeStyle-BqfwxZH4.d.cts} +2 -2
- package/dist/{typeStyle-DROhJNkh.d.ts → typeStyle-DKz02DGU.d.ts} +2 -2
- package/dist/{uploadTransport-C1p8FuG8.d.cts → uploadTransport-BM_pnEWj.d.cts} +5 -0
- package/dist/{uploadTransport-bZIKBTyK.d.ts → uploadTransport-C6kGP1Kd.d.ts} +5 -0
- package/dist/{useRecordsDepth-BLK8W646.d.cts → useRecordsDepth-CARTuHKh.d.cts} +1 -1
- package/dist/{useRecordsDepth-C7guUoLc.d.ts → useRecordsDepth-fPSv-GXU.d.ts} +1 -1
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.js +1 -1
- package/dist/{view-BF9oW2GJ.d.cts → view-DGPaVno8.d.cts} +47 -5
- package/dist/{view-B6JsD22K.d.ts → view-Dc-JlFkf.d.ts} +47 -5
- package/dist/web/consent/index.cjs +1 -1
- package/dist/web/consent/index.d.cts +5 -5
- package/dist/web/consent/index.d.ts +5 -5
- package/dist/web/consent/index.js +1 -1
- package/dist/web/index.cjs +7 -7
- package/dist/web/index.d.cts +23 -22
- package/dist/web/index.d.ts +23 -22
- package/dist/web/index.js +7 -7
- package/dist/web/notifications/index.d.cts +3 -3
- package/dist/web/notifications/index.d.ts +3 -3
- package/dist/web/records/depth/index.cjs +2 -2
- package/dist/web/records/depth/index.d.cts +7 -7
- package/dist/web/records/depth/index.d.ts +7 -7
- package/dist/web/records/depth/index.js +2 -2
- package/dist/web/records/index.cjs +3 -3
- package/dist/web/records/index.d.cts +28 -17
- package/dist/web/records/index.d.ts +28 -17
- package/dist/web/records/index.js +3 -3
- package/dist/web/televet/booking/index.cjs +4 -2
- package/dist/web/televet/booking/index.d.cts +228 -90
- package/dist/web/televet/booking/index.d.ts +228 -90
- package/dist/web/televet/booking/index.js +4 -2
- package/dist/web/televet/call/index.cjs +1 -1
- package/dist/web/televet/call/index.d.cts +1 -1
- package/dist/web/televet/call/index.d.ts +1 -1
- package/dist/web/televet/call/index.js +1 -1
- package/dist/web/televet/index.cjs +2 -2
- package/dist/web/televet/index.d.cts +2 -2
- package/dist/web/televet/index.d.ts +2 -2
- package/dist/web/televet/index.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
'use strict';var react=require('react'),reactNativeSafeAreaContext=require('react-native-safe-area-context'),zod=require('zod'),Ah=require('react-native-sse'),reactNative=require('react-native'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ah__default=/*#__PURE__*/_interopDefault(Ah);var Tf=Object.defineProperty;var i=(e,t)=>Tf(e,"name",{value:t,configurable:true});function be(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(be,"hasLoneSurrogate");function at(e){return [...e].length}i(at,"serverLength");function L(e,t){return Object.freeze(t===void 0?{ok:true,value:e}:{ok:true,value:e,warning:t})}i(L,"ok");function C(e){return Object.freeze({ok:false,error:e})}i(C,"err");function Pf(e){return e.ok}i(Pf,"isOk");function kf(e){return !e.ok}i(kf,"isErr");var Dr=class Dr extends Error{constructor(t){super(`${t.code}: ${t.displayMessage}`),this.name="EverfurThrownError",this.error=t,this.code=t.code,this.category=t.category,Object.setPrototypeOf(this,Dr.prototype);}};i(Dr,"EverfurThrownError");var Lr=Dr;function xf(e){if(e.ok)return e.value;throw new Lr(e.error)}i(xf,"unwrap");var Nr=class Nr extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,Nr.prototype);}};i(Nr,"EverfurConfigError");var Q=Nr;var gs=128,hs=128,bs=/[\u0000-\u001F\u007F]/,_f=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function wf(e){let t=e,r=at(t);if(r===0||r>hs)throw new Q("invalid-argument",`petRef must be 1..${hs} characters`);if(bs.test(t))throw new Q("invalid-argument","petRef must be printable (no control characters)");return t}i(wf,"petRef");function If(e){let t=e,r=at(t);if(r===0||r>gs)throw new Q("invalid-argument",`userRef must be 1..${gs} characters`);if(t.includes("@"))throw new Q("invalid-argument","userRef must not contain '@'");if(bs.test(t))throw new Q("invalid-argument","userRef must be printable (no control characters)");return t}i(If,"userRef");function Af(e){if(!_f.test(e))throw new Q("invalid-argument","conversationId must be a UUID");return e}i(Af,"conversationId");var Kn=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(Kn.map(e=>e.wireCode));var Of=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"}),Cs=Object.freeze(Kn.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:Of[e.wireCode]}))),Ff=new Map(Cs.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),Mf=Object.freeze(["http_envelope",...[...new Set(Cs.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function Ur(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let n of [t??"http_envelope",...Mf]){let o=Ff.get(n+r);if(o)return o}}i(Ur,"contractErrorFor");function Lf(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(Lf,"contractDocUrl");function Es(e){return null}i(Es,"publishedDocUrl");var Df=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 Df[e]}i(qn,"categoryFor");function Oe(e){let t=Ur(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return "authRejected";if(r.startsWith("AUTH"))return "authExpired";switch(n){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":case "TELEVETRATELIMITED":return "rateLimited";case "IDEMPOTENCYKEYCONFLICT":case "IDEMPOTENCYCONFLICT":return "idempotencyConflict";case "ACCESSDENIED":case "FORBIDDEN":return "accessDenied";case "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(Oe,"fromWire");function Rs(e){return e===401?"authExpired":e===403?"accessDenied":e===404?"conversationNotFound":e===409?"idempotencyConflict":e===421?"unknown":e===429?"rateLimited":e===400||e===422?"unknown":e>=500?"internalError":"unknown"}i(Rs,"fromHttpStatus");var Nf=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function Be(e){return Nf.has(e)}i(Be,"isAutoRetryable");var Uf=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function $n(e){return Be(e)||Uf.has(e)}i($n,"isRetryableCode");function Vr(e,t=false){return t||Be(e)}i(Vr,"shouldRetry");var Vf=500,Yn=8e3,Jt=4;function Hr(e,t=Math.random){let r=Math.max(0,e),n=Math.min(Vf*2**r,Yn);return Math.floor(t()*n)}i(Hr,"backoffDelayMs");function Ss(e){return e==="conversationNotFound"}i(Ss,"canRecreateOnNotFound");var Hf=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 Ot(e){return Hf[e]}i(Ot,"userFacingError");function Ts(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(Ts,"defineHidden");var Bf=/^[a-z][a-z0-9_]{0,63}$/;function D(e,t){let r=Ur(t?.wireCode,t?.wireEnvelope),n={code:e,category:qn(e),retryable:t?.retryable??$n(e),displayMessage:Ot(e)};if(t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&Bf.test(t.reasonCode)&&(n.reasonCode=t.reasonCode),r);return t?.wireMessage&&Ts(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Ts(n,"raw",t.raw),Object.freeze(n)}i(D,"makeEverfurError");var zf="file",Xn="multipart upload failed";function Br(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(zf,e.file);}catch{return Promise.reject(new Error(Xn))}return e.fetch!==void 0?Gf(e.fetch,e.url,t,e.signal):Wf(e.url,t,e.signal)}i(Br,"postRnMultipart");function jf(e){return e>=200&&e<300}i(jf,"stored");function Wf(e,t,r){return new Promise((n,o)=>{let s=globalThis.XMLHttpRequest;if(typeof s!="function"||r?.aborted===true){o(new Error(Xn));return}let a=null,l=i(()=>{a!==null&&r?.removeEventListener("abort",a);},"release"),u=i(()=>{l(),o(new Error(Xn));},"fail");try{let d=new s;d.open("POST",e),d.withCredentials=!1,d.onload=()=>{l(),n(jf(d.status));},d.onerror=u,d.ontimeout=u,d.onabort=u,r!==void 0&&(a=i(()=>{try{d.abort();}finally{u();}},"onAbort"),r.addEventListener("abort",a,{once:!0})),d.send(t);}catch{u();}})}i(Wf,"postWithXhr");function Gf(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(o=>o.ok)}i(Gf,"postWithFetch");var Kf="document.pdf",qf="records upload: the file handle has no uri",$f="records upload failed";function Yf(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(qf));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error($f)),"failed");return o?.aborted===true?a():Br({url:t.upload_url,fields:t.upload_fields,file:{uri:r.uri,name:Kf,type:"application/pdf"},signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(Yf,"createRnRecordsUploadTransport");var zr=Object.freeze({track(){},trackExpectedFailure(){}});var Ps=Object.freeze({shouldRetry(e,t){return Be(e)&&t<Jt},maxAttempts(){return Jt}});var ks=Object.freeze({isAvailable:false,async capture(){return Promise.reject(new Error("CameraPort is unavailable; check isAvailable before calling capture"))}});function Ze(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(Ze,"assertNever");function xs(e,t,r=null){return Object.freeze({kind:"accepted",streamId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(xs,"acceptedFrame");function _s(e,t=null){return Object.freeze({kind:"heartbeat",lastEventId:e,serverRequestId:t,terminal:false})}i(_s,"heartbeatFrame");function ws(e,t,r=null){return Object.freeze({kind:"delta",delta:e,lastEventId:t,serverRequestId:r,terminal:false})}i(ws,"deltaFrame");function Is(e,t=null){return Object.freeze({kind:"done",terminal:true,conversationId:e.conversationId,messageId:e.messageId,title:e.title,followUpQuestions:Object.freeze([...e.followUpQuestions]),citations:Object.freeze([...e.citations]),citationStatus:e.citationStatus,urgencyLevel:e.urgencyLevel,urgencyReason:e.urgencyReason,urgencyProvided:e.urgencyProvided??e.urgencyLevel!==null,resultId:e.resultId,lastEventId:e.lastEventId,serverRequestId:t})}i(Is,"doneFrame");function ce(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(ce,"errorFrame");function As(e,t,r=null){return Object.freeze({kind:"analysisStarted",requestId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(As,"analysisStartedFrame");function Os(e,t=null){return Object.freeze({kind:"analysisComplete",terminal:false,resultId:e.resultId,analysisType:e.analysisType,modelVersion:e.modelVersion,confidence:e.confidence,detections:Object.freeze([...e.detections]),interpretation:e.interpretation,lastEventId:e.lastEventId,serverRequestId:t})}i(Os,"analysisCompleteFrame");function Fs(e,t,r=null){return Object.freeze({kind:"unknown",raw:{...e},lastEventId:t,serverRequestId:r,terminal:false})}i(Fs,"unknownFrame");function Ms(e,t,r){let n=null,o=null,s=false,a=i(()=>o||(o=(async()=>{try{let l=await t(),u=typeof l=="string"?l:l?.token;if(typeof u!="string"||u.length===0)throw new Q("invalid-argument","TokenProvider returned an empty token");return n=u,r?.(typeof l=="string"?null:Zf(l.expiresAt)),u}finally{o=null;}})(),o),"load");return {userRef:e,async currentToken(l){if(s)throw new Q("not-initialized","This identity was cleared (sign-out); mint a new one.");return l?.forceRefresh&&(n=null),n!==null?n:a()},hasToken(){return !s&&n!==null},clear(){s=true,n=null;}}}i(Ms,"createIdentityProvider");function Zf(e){if(e===void 0)return null;let t=typeof e=="number"?e<1e11?e*1e3:e:new Date(e).getTime();return Number.isFinite(t)?t:null}i(Zf,"expiryMs");function Zn(){let e=new Uint8Array(16),t=globalThis.crypto;if(typeof t?.getRandomValues=="function")t.getRandomValues(e);else for(let n=0;n<e.length;n+=1)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let r=[];for(let n=0;n<e.length;n+=1)r.push(e[n].toString(16).padStart(2,"0"));return r.slice(0,4).join("")+"-"+r.slice(4,6).join("")+"-"+r.slice(6,8).join("")+"-"+r.slice(8,10).join("")+"-"+r.slice(10,16).join("")}i(Zn,"newSessionId");function Jf(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(Jf,"authHeaders");function er(e,t){return {...e,headers:{...em(e.headers),...Jf(t)}}}i(er,"withAuthHeaders");function em(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(em,"stripAuthHeaders");async function Ls(e,t){if(t.mode==="anonymous")return t.transport.request(er(e,{mode:"anonymous",publishableKey:t.publishableKey,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));let r;try{r=await t.identity.currentToken();}catch{return C(Qn())}let n=await t.transport.request(er(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 C(Qn())}let s=await t.transport.request(er(e,{mode:"personalized",token:o,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !s.ok&&s.error.httpStatus===401?C(Qn(s.error.httpStatus)):s}i(Ls,"authedSend");function Qn(e){return D("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(Qn,"authRejectedError");var Ds=`
|
|
1
|
+
'use strict';var zod=require('zod'),react=require('react'),reactNativeSafeAreaContext=require('react-native-safe-area-context'),fb=require('react-native-sse'),reactNative=require('react-native'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var fb__default=/*#__PURE__*/_interopDefault(fb);var Xf=Object.defineProperty;var i=(e,t)=>Xf(e,"name",{value:t,configurable:true});function Ce(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(Ce,"hasLoneSurrogate");function gt(e){return [...e].length}i(gt,"serverLength");function L(e,t){return Object.freeze(t===void 0?{ok:true,value:e}:{ok:true,value:e,warning:t})}i(L,"ok");function v(e){return Object.freeze({ok:false,error:e})}i(v,"err");function Qf(e){return e.ok}i(Qf,"isOk");function Zf(e){return !e.ok}i(Zf,"isErr");var Wr=class Wr extends Error{constructor(t){super(`${t.code}: ${t.displayMessage}`),this.name="EverfurThrownError",this.error=t,this.code=t.code,this.category=t.category,Object.setPrototypeOf(this,Wr.prototype);}};i(Wr,"EverfurThrownError");var jr=Wr;function Jf(e){if(e.ok)return e.value;throw new jr(e.error)}i(Jf,"unwrap");var Gr=class Gr extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,Gr.prototype);}};i(Gr,"EverfurConfigError");var re=Gr;var As=128,Os=128,Fs=/[\u0000-\u001F\u007F]/,em=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function tm(e){let t=e,r=gt(t);if(r===0||r>Os)throw new re("invalid-argument",`petRef must be 1..${Os} characters`);if(Fs.test(t))throw new re("invalid-argument","petRef must be printable (no control characters)");return t}i(tm,"petRef");function rm(e){let t=e,r=gt(t);if(r===0||r>As)throw new re("invalid-argument",`userRef must be 1..${As} characters`);if(t.includes("@"))throw new re("invalid-argument","userRef must not contain '@'");if(Fs.test(t))throw new re("invalid-argument","userRef must be printable (no control characters)");return t}i(rm,"userRef");function nm(e){if(!em.test(e))throw new re("invalid-argument","conversationId must be a UUID");return e}i(nm,"conversationId");var ao=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(ao.map(e=>e.wireCode));var om=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"}),Ls=Object.freeze(ao.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:om[e.wireCode]}))),im=new Map(Ls.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),sm=Object.freeze(["http_envelope",...[...new Set(Ls.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function Kr(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let n of [t??"http_envelope",...sm]){let o=im.get(n+r);if(o)return o}}i(Kr,"contractErrorFor");function am(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(am,"contractDocUrl");function Ns(e){return null}i(Ns,"publishedDocUrl");var lm=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 lo(e){return lm[e]}i(lo,"categoryFor");function Fe(e){let t=Kr(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return "authRejected";if(r.startsWith("AUTH"))return "authExpired";switch(n){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":case "TELEVETRATELIMITED":return "rateLimited";case "IDEMPOTENCYKEYCONFLICT":case "IDEMPOTENCYCONFLICT":return "idempotencyConflict";case "ACCESSDENIED":case "FORBIDDEN":return "accessDenied";case "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(Fe,"fromWire");function Ds(e){return e===401?"authExpired":e===403?"accessDenied":e===404?"conversationNotFound":e===409?"idempotencyConflict":e===421?"unknown":e===429?"rateLimited":e===400||e===422?"unknown":e>=500?"internalError":"unknown"}i(Ds,"fromHttpStatus");var um=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function Ge(e){return um.has(e)}i(Ge,"isAutoRetryable");var dm=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function uo(e){return Ge(e)||dm.has(e)}i(uo,"isRetryableCode");function qr(e,t=false){return t||Ge(e)}i(qr,"shouldRetry");var cm=500,co=8e3,rr=4;function $r(e,t=Math.random){let r=Math.max(0,e),n=Math.min(cm*2**r,co);return Math.floor(t()*n)}i($r,"backoffDelayMs");function Us(e){return e==="conversationNotFound"}i(Us,"canRecreateOnNotFound");var pm=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 Dt(e){return pm[e]}i(Dt,"userFacingError");function Vs(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(Vs,"defineHidden");var fm=/^[a-z][a-z0-9_]{0,63}$/;function D(e,t){let r=Kr(t?.wireCode,t?.wireEnvelope),n={code:e,category:lo(e),retryable:t?.retryable??uo(e),displayMessage:Dt(e)};if(t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&fm.test(t.reasonCode)&&(n.reasonCode=t.reasonCode),r);return t?.wireMessage&&Vs(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Vs(n,"raw",t.raw),Object.freeze(n)}i(D,"makeEverfurError");var Hs="application/pdf",Yr=Object.freeze(["image/jpeg","image/png","image/heic","image/heif"]);zod.z.object({features:zod.z.record(zod.z.boolean()),upload_content_types:zod.z.array(zod.z.string()).nullish(),share_audiences:zod.z.unknown().optional()});var mm=i(e=>Yr.includes(e),"isPhotoType");function po(e,t){return e===Hs||t!==void 0&&mm(e)&&t.includes(e)}i(po,"isAcceptedUploadType");var Bs=Object.freeze({"application/pdf":"document.pdf","image/jpeg":"document.jpg","image/png":"document.png","image/heic":"document.heic","image/heif":"document.heif"});function zs(e){return po(e,Yr)?Bs[e]:Bs["application/pdf"]}i(zs,"recordsUploadFilename");var ym="file",fo="multipart upload failed";function Xr(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(ym,e.file);}catch{return Promise.reject(new Error(fo))}return e.fetch!==void 0?bm(e.fetch,e.url,t,e.signal):hm(e.url,t,e.signal)}i(Xr,"postRnMultipart");function gm(e){return e>=200&&e<300}i(gm,"stored");function hm(e,t,r){return new Promise((n,o)=>{let s=globalThis.XMLHttpRequest;if(typeof s!="function"||r?.aborted===true){o(new Error(fo));return}let a=null,l=i(()=>{a!==null&&r?.removeEventListener("abort",a);},"release"),u=i(()=>{l(),o(new Error(fo));},"fail");try{let d=new s;d.open("POST",e),d.withCredentials=!1,d.onload=()=>{l(),n(gm(d.status));},d.onerror=u,d.ontimeout=u,d.onabort=u,r!==void 0&&(a=i(()=>{try{d.abort();}finally{u();}},"onAbort"),r.addEventListener("abort",a,{once:!0})),d.send(t);}catch{u();}})}i(hm,"postWithXhr");function bm(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(o=>o.ok)}i(bm,"postWithFetch");var vm="records upload: the file handle has no uri",Em="records upload failed";function Cm(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(vm));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(Em)),"failed");return o?.aborted===true?a():Xr({url:t.upload_url,fields:t.upload_fields,file:{uri:r.uri,name:zs(r.mimeType),type:Rm(r.mimeType)},signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(Cm,"createRnRecordsUploadTransport");function Rm(e){return po(e,Yr)?e:"application/pdf"}i(Rm,"partType");var Qr=Object.freeze({track(){},trackExpectedFailure(){}});var js=Object.freeze({shouldRetry(e,t){return Ge(e)&&t<rr},maxAttempts(){return rr}});var Ws=Object.freeze({isAvailable:false,async capture(){return Promise.reject(new Error("CameraPort is unavailable; check isAvailable before calling capture"))}});function at(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(at,"assertNever");function Gs(e,t,r=null){return Object.freeze({kind:"accepted",streamId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(Gs,"acceptedFrame");function Ks(e,t=null){return Object.freeze({kind:"heartbeat",lastEventId:e,serverRequestId:t,terminal:false})}i(Ks,"heartbeatFrame");function qs(e,t,r=null){return Object.freeze({kind:"delta",delta:e,lastEventId:t,serverRequestId:r,terminal:false})}i(qs,"deltaFrame");function $s(e,t=null){return Object.freeze({kind:"done",terminal:true,conversationId:e.conversationId,messageId:e.messageId,title:e.title,followUpQuestions:Object.freeze([...e.followUpQuestions]),citations:Object.freeze([...e.citations]),citationStatus:e.citationStatus,urgencyLevel:e.urgencyLevel,urgencyReason:e.urgencyReason,urgencyProvided:e.urgencyProvided??e.urgencyLevel!==null,resultId:e.resultId,lastEventId:e.lastEventId,serverRequestId:t})}i($s,"doneFrame");function ye(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(ye,"errorFrame");function Ys(e,t,r=null){return Object.freeze({kind:"analysisStarted",requestId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(Ys,"analysisStartedFrame");function Xs(e,t=null){return Object.freeze({kind:"analysisComplete",terminal:false,resultId:e.resultId,analysisType:e.analysisType,modelVersion:e.modelVersion,confidence:e.confidence,detections:Object.freeze([...e.detections]),interpretation:e.interpretation,lastEventId:e.lastEventId,serverRequestId:t})}i(Xs,"analysisCompleteFrame");function Qs(e,t,r=null){return Object.freeze({kind:"unknown",raw:{...e},lastEventId:t,serverRequestId:r,terminal:false})}i(Qs,"unknownFrame");function Zs(e,t,r){let n=null,o=null,s=false,a=i(()=>o||(o=(async()=>{try{let l=await t(),u=typeof l=="string"?l:l?.token;if(typeof u!="string"||u.length===0)throw new re("invalid-argument","TokenProvider returned an empty token");return n=u,r?.(typeof l=="string"?null:Pm(l.expiresAt)),u}finally{o=null;}})(),o),"load");return {userRef:e,async currentToken(l){if(s)throw new re("not-initialized","This identity was cleared (sign-out); mint a new one.");return l?.forceRefresh&&(n=null),n!==null?n:a()},hasToken(){return !s&&n!==null},clear(){s=true,n=null;}}}i(Zs,"createIdentityProvider");function Pm(e){if(e===void 0)return null;let t=typeof e=="number"?e<1e11?e*1e3:e:new Date(e).getTime();return Number.isFinite(t)?t:null}i(Pm,"expiryMs");function yo(){let e=new Uint8Array(16),t=globalThis.crypto;if(typeof t?.getRandomValues=="function")t.getRandomValues(e);else for(let n=0;n<e.length;n+=1)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let r=[];for(let n=0;n<e.length;n+=1)r.push(e[n].toString(16).padStart(2,"0"));return r.slice(0,4).join("")+"-"+r.slice(4,6).join("")+"-"+r.slice(6,8).join("")+"-"+r.slice(8,10).join("")+"-"+r.slice(10,16).join("")}i(yo,"newSessionId");function km(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(km,"authHeaders");function nr(e,t){return {...e,headers:{...xm(e.headers),...km(t)}}}i(nr,"withAuthHeaders");function xm(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(xm,"stripAuthHeaders");async function Js(e,t){if(t.mode==="anonymous")return t.transport.request(nr(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(mo())}let n=await t.transport.request(nr(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(mo())}let s=await t.transport.request(nr(e,{mode:"personalized",token:o,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !s.ok&&s.error.httpStatus===401?v(mo(s.error.httpStatus)):s}i(Js,"authedSend");function mo(e){return D("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(mo,"authRejectedError");var ea=`
|
|
2
2
|
|
|
3
|
-
`,
|
|
3
|
+
`,_m=1048576,wm=zod.z.record(zod.z.string(),zod.z.unknown()),Im=["emergency","schedule_soon","home_care"];async function*Zr(e,t=null){let r=null,n=i(()=>(r!==null||(r=typeof t=="function"?t():t),r),"requestIdNow"),o=new TextDecoder("utf-8"),s="",a=0,l=false;for await(let u of e){for(s+=o.decode(u,{stream:true});;){let d=s.indexOf(ea,a);if(d===-1)break;let c=s.slice(0,d);s=s.slice(d+ea.length),a=0;let p=ta(c,n());if(p!==null&&(p.kind==="delta"&&(l=true),yield p,p.terminal))return}if(a=s.length>0?s.length-1:0,s.length>_m){yield ye({code:l?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});return}}if(s+=o.decode(),s.trim().length>0){let u=ta(s,n());if(u!==null&&(u.kind==="delta"&&(l=true),yield u,u.terminal))return}yield ye({code:l?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});}i(Zr,"parseSse");function ta(e,t){let r=null,n=[];for(let a of e.split(`
|
|
4
4
|
`)){let l=a.replace(/\s+$/,"");l.length===0||l.startsWith(":")||(l.startsWith("id:")?r=l.slice(3).trim():l.startsWith("data:")&&n.push(l.slice(5).replace(/^ /,"")));}if(n.length===0)return null;let o;try{o=JSON.parse(n.join(`
|
|
5
|
-
`));}catch{return null}if(typeof o!="object"||o===null||Array.isArray(o))return null;let s=
|
|
5
|
+
`));}catch{return null}if(typeof o!="object"||o===null||Array.isArray(o))return null;let s=wm.safeParse(o);return s.success?Am(s.data,r,t):null}i(ta,"parseBlock");function Am(e,t,r){let n=e.type,o=e.event;if(n==="error"||"error"in e)return ye({code:pe(e.code)??"unknown",retryable:e.retryable===true,wireMessage:pe(e.error),synthesized:false,lastEventId:t,serverRequestId:r});if(n==="done"||e.done===true)return $s({conversationId:pe(e.conversation_id)??"",messageId:pe(e.message_id),title:pe(e.title),followUpQuestions:Mm(e.follow_up_questions),citations:ra(e.citations),citationStatus:pe(e.citation_status),urgencyLevel:na(e.urgency_level),urgencyReason:pe(e.urgency_reason),urgencyProvided:Fm(e),resultId:pe(e.result_id),lastEventId:t},r);if(n==="accepted"||e.status==="reasoning")return Gs(pe(e.stream_id),t,r);if(n==="heartbeat"||e.heartbeat===true)return Ks(t,r);if(n==="text.delta"||"delta"in e||"token"in e){let s=pe(e.delta)??pe(e.token)??"";return qs(s,t,r)}return o==="analysis_started"?Ys(pe(e.request_id),t,r):o==="analysis_complete"?Xs({resultId:pe(e.result_id),analysisType:pe(e.analysis_type),modelVersion:pe(e.model_version),confidence:Om(e.confidence),detections:ra(e.detections),interpretation:pe(e.interpretation),lastEventId:t},r):Qs(e,t,r)}i(Am,"frameFromWire");function pe(e){return typeof e=="string"?e:null}i(pe,"asString");function Om(e){return typeof e=="number"&&Number.isFinite(e)?e:null}i(Om,"asNumber");function na(e){return typeof e=="string"&&Im.includes(e)?e:null}i(na,"asUrgency");function Fm(e){if(!Object.prototype.hasOwnProperty.call(e,"urgency_level"))return false;let t=e.urgency_level;return t===null||na(t)!==null}i(Fm,"urgencySlotProvided");function Mm(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t:String(t)):[]}i(Mm,"asStringList");function Lm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Lm,"isPlainObject");function ra(e){return Array.isArray(e)?e.filter(Lm):[]}i(ra,"asMapList");var Nm="0.7.0",ho="react-native",Dm="2026-09-19",Jr="EVERFUR_API_BASE_URL";function or(e,t){return Object.freeze({ok:false,failure:Object.freeze({reason:e,message:t})})}i(or,"configFailure");function bo(e){let t=typeof e=="string"?e.trim():"";return t.length===0?{reason:"missing-publishable-key",message:"publishableKey is required"}:/^sk[_-]/i.test(t)?{reason:"secret-key-as-publishable-key",message:"publishableKey looks like a SECRET key (sk_...). A device must never hold a partner secret key: use the pk_ publishable key here, and keep the secret key on your server."}:null}i(bo,"checkPublishableKey");function oa(e,t){let r=bo(e?.publishableKey);if(r!==null)return Object.freeze({ok:false,failure:r});let n=e.publishableKey.trim(),o=Um(e.apiBaseUrl);if(!o.ok)return o;let s=e.contractVersion?.trim()||Dm;return Object.freeze({ok:true,config:Object.freeze({publishableKey:n,apiBaseUrl:o.value,contractVersion:s,sdkVersion:Nm,platform:t?.platform??ho,debug:e.debug===true})})}i(oa,"tryResolveClientConfig");function Um(e){let t=e?.trim(),r=t&&t.length>0?t:Km(Jr);return r?Wm(r):or("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${Jr}. The SDK never ships a hardcoded host.`)}i(Um,"tryResolveApiBaseUrl");function ia(e){return {"X-Everfur-SDK-Version":e.sdkVersion,"X-Everfur-SDK-Platform":e.platform,"X-Everfur-Contract":e.contractVersion}}i(ia,"buildBaseHeaders");var Vm=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function Bm(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}i(Bm,"hostOf");function Hm(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}i(Hm,"isPrintableHost");function zm(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:Hm(t)}i(zm,"canEchoOrigin");function jm(e,t){return `${e}://${t}`}i(jm,"safeOrigin");function Wm(e){let t=e.trim(),r=Vm.exec(t);if(r===null||r[2]===void 0||r[2].length===0)return or("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let n=(r[1]??"").toLowerCase(),o=Bm(r[2]);if(o.length===0)return or("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let s=zm(t,o)?`: ${jm(n,o)}`:"";if(n!=="https"){if(!(n==="http"&&Gm(o)))return n==="http"?or("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${s}`):or("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${s}`)}let a=t.endsWith("/")?t.slice(0,-1):t;return Object.freeze({ok:true,value:a})}i(Wm,"normalizeBaseUrl");function Gm(e){let t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t==="::1"}i(Gm,"isLoopbackHost");function Km(e){let r=globalThis.process?.env?.[e];return typeof r=="string"&&r.trim().length>0?r.trim():void 0}i(Km,"readEnv");var qm=3e4,ua="x-request-id";async function*sa(e){if(!e)return;let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;n&&n.length>0&&(yield n);}}finally{await t.cancel?.();}}i(sa,"fetchByteSource");function $m(e){let t=new TextEncoder,r=Xm(),n=false,o=i(u=>{let d="";u.lastEventId&&(d+=`id: ${u.lastEventId}
|
|
6
6
|
`);let c=u.data??"";for(let p of c.split(`
|
|
7
7
|
`))d+=`data: ${p}
|
|
8
8
|
`;d+=`
|
|
9
|
-
`,r.push(t.encode(d));},"onMessage"),s=i(()=>{l(),r.end();},"onDone"),a=i(u=>{let d=typeof u.xhrStatus=="number"?u.xhrStatus:0;if(d>=400){let c
|
|
9
|
+
`,r.push(t.encode(d));},"onMessage"),s=i(()=>{l(),r.end();},"onDone"),a=i(u=>{let d=typeof u.xhrStatus=="number"?u.xhrStatus:0;if(d>=400){let c=pa(d),p=Ge(Fe(c));r.push(t.encode(`data: ${JSON.stringify({type:"error",code:c,retryable:p})}
|
|
10
10
|
|
|
11
|
-
`));}l(),r.end();},"onError");e.addEventListener("message",o),e.addEventListener("done",s),e.addEventListener("error",a);function l(){if(!n){n=true,e.removeEventListener("message",o),e.removeEventListener("done",s),e.removeEventListener("error",a);try{e.close();}catch{}}}return i(l,"cleanup"),Rm(r.source,l)}i(Em,"eventSourceByteSource");async function*Rm(e,t){try{yield*e;}finally{t();}}i(Rm,"sourceWithCleanup");function Sm(){let e=[],t=false,r=null,n=i(()=>{if(r){let s=r;r=null,s();}},"signal");async function*o(){for(;;){let s=e.shift();if(s!==void 0){yield s;continue}if(t)return;await new Promise(a=>{r=a;});}}return i(o,"gen"),{source:o(),push:i(s=>{e.push(s),n();},"push"),end:i(()=>{t=true,n();},"end")}}i(Sm,"createByteQueue");async function Tm(e,t){let r=t.fetchImpl??Ys(),n=Xs(t.config.apiBaseUrl,e.path,e.query),o=Qs(t.config,e.headers,"application/json",e.body!==void 0&&e.multipart===void 0),s=Im(Cm),a=Am(s.signal,e.signal),l;try{l=await r(n,Zs({...e,signal:a},o));}catch(d){return C(ro(d))}finally{s.cancel();}let u=await Js(l);return l.ok?L(u):C(xm(l.status,u,qs(l)))}i(Tm,"requestJson");function Ks(e){return {request:i(t=>Tm(t,e),"request"),stream:i((t,r)=>Pm(wm(t,r),e),"stream")}}i(Ks,"createHttpTransport");async function*Pm(e,t){let r=Xs(t.config.apiBaseUrl,e.path,e.query),n=Qs(t.config,e.headers,"text/event-stream",e.body!==void 0&&e.multipart===void 0);if(t.eventSourceFactory){let l=t.eventSourceFactory(r,km(e,n));yield*jr(Em(l),()=>_m(l));return}let o=t.fetchImpl??Ys(),s;try{s=await o(r,Zs(e,n));}catch(l){yield js("",true,na(l));return}let a=qs(s);if(!s.ok){let l=await Js(s),u=ea(l)??$s(s.status),d=ra(l)||Be(Oe(u));yield js(u,d,ta(l),a);return}if(s.body){yield*jr(zs(s.body),a);return}yield*jr(zs(null),a);}i(Pm,"streamFrames");function km(e,t){return {method:e.method,headers:t,pollingInterval:0,...e.body!==void 0?{body:JSON.stringify(e.body)}:{}}}i(km,"buildEventSourceInit");function xm(e,t,r){let n=ea(t),o=n?Oe(n):Rs(e),s=ta(t);return D(o,{httpStatus:e,...ra(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...Ws(t)?{reasonCode:Ws(t)}:{},...s?{wireMessage:s}:{},...t!=null?{raw:t}:{}})}i(xm,"errorFromResponse");function ro(e){return D("internalError",{retryable:true,wireMessage:na(e)})}i(ro,"networkError");function qs(e){let t=e.headers.get(Gs);return typeof t=="string"&&t.length>0?t:null}i(qs,"requestIdOf");function _m(e){if(typeof e.getResponseHeader!="function")return null;let t;try{t=e.getResponseHeader(Gs);}catch{return null}return typeof t=="string"&&t.length>0?t:null}i(_m,"eventSourceRequestId");function $s(e){return e===401?"AUTH_EXPIRED":e===403?"ACCESS_DENIED":e===404?"NOT_FOUND":e===409?"IDEMPOTENCY_CONFLICT":e===421?"MISDIRECTED_REQUEST":e===429?"RATE_LIMITED":e===400||e===422?"INVALID_REQUEST":e===503||e>=500?"INTERNAL_ERROR":""}i($s,"statusToWireCode");function js(e,t,r,n=null){return ce({code:e,retryable:t,wireMessage:r,synthesized:true,lastEventId:null,serverRequestId:n})}i(js,"syntheticErrorFrame");function Ys(){let e=globalThis.fetch;if(typeof e!="function")throw new Q("missing-peer-dependency","global fetch is unavailable; provide config.transport or an injected fetch implementation");return e}i(Ys,"getGlobalFetch");function Xs(e,t,r){let n=t.startsWith("/")?t:`/${t}`,o=`${e}${n}`;if(r){let s=Object.entries(r).filter(a=>a[1]!==void 0).map(([a,l])=>`${encodeURIComponent(a)}=${encodeURIComponent(String(l))}`).join("&");s&&(o+=`?${s}`);}return o}i(Xs,"buildUrl");function Qs(e,t,r,n){let o={...Bs(e),accept:r};return n&&(o["content-type"]="application/json"),t&&Object.assign(o,t),o}i(Qs,"mergeHeaders");function Zs(e,t){let r={method:e.method,headers:t};return e.multipart!==void 0?r.body=e.multipart:e.body!==void 0&&(r.body=JSON.stringify(e.body)),e.signal&&(r.signal=e.signal),r}i(Zs,"buildInit");function wm(e,t){return e.signal?e:{...e,signal:t}}i(wm,"withSignal");function Im(e){let t=new AbortController,r=setTimeout(()=>t.abort(),e);return {signal:t.signal,cancel:i(()=>clearTimeout(r),"cancel")}}i(Im,"timeoutSignal");function Am(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(Am,"mergeAbortSignals");async function Js(e){try{return await e.json()}catch{return null}}i(Js,"safeJson");function Ws(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}i(Ws,"extractReasonCode");function ea(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?r:null}i(ea,"extractWireCode");function ta(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}i(ta,"extractWireMessage");function ra(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}i(ra,"extractRetryable");function na(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(na,"describeCause");var Om=3e4,Fm=Yn*2,Mm="idempotency-key",Lm=new Set(["POST","PUT","PATCH","DELETE"]),Dm=Object.freeze({onEvent(){}}),Nm=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function Um(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}i(Um,"seededIdempotencyKey");function _e(e){let t=e.observer??Dm,r=e.timers??Nm,n=e.rng??Math.random,o=e.sleep??((f,m)=>Zm(f,r,m)),s=e.maxAttempts??Jt,a=e.unaryTimeoutMs??Om,l=e.newIdempotencyKey??Hm(),u=i(f=>{try{t.onEvent(f);}catch{}},"emit");async function d(f,m,y){let k=y?.maxAttempts,b=Math.max(1,k??s),E=y?.idempotent??Lm.has(m.method),w=y?.idempotencyKey===void 0?null:Um(y.idempotencyKey),T=E?w??l():null,x=Vm(m,T),g=0;for(;;){let _=i(j=>Object.freeze({call:f,method:m.method,path:m.path,attempt:g,...T?{idempotencyKey:T}:{},...j}),"stamp");u(_({phase:"attempt"}));let O=Xm(a,r),M=Qm(O.signal,m.signal),I;try{I=await Ls({...x,signal:M.signal},e.auth);}catch(j){I=C(ro(j));}finally{M.dispose(),O.cancel();}if(I.ok)return u(_({phase:"settled",ok:true,reason:"ok"})),I;let v=I.error,P=zm(v,g,{maxAttempts:b,rng:n,now:r.now(),aborted:m.signal?.aborted===true,...k!==void 0?{perCallMaxAttempts:k}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),V={ok:false,code:v.code,reason:P.reason,...v.httpStatus!==void 0?{httpStatus:v.httpStatus}:{},...v.requestId!==void 0?{requestId:v.requestId}:{}};if(!P.retry)return u(_({phase:"settled",...V})),C(v);if(u(_({phase:"retry",...V,delayMs:P.delayMs})),await o(P.delayMs,m.signal),m.signal?.aborted===true)return u(_({phase:"settled",...V,reason:"aborted"})),C(v);g+=1;}}i(d,"send");async function c(f){return er(f,await Ym(e.auth))}i(c,"authorize");async function*p(f,m,y){u(Object.freeze({call:f,phase:"stream.open",method:m.method,path:m.path,attempt:0}));try{yield*e.auth.transport.stream(m,y);}catch{yield ce({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(p,"stream"),Object.freeze({send:d,authorize:c,stream:p})}i(_e,"createRequestFunnel");function Vm(e,t){let r={};for(let[n,o]of Object.entries(e.headers??{}))n.toLowerCase()!==Mm&&(r[n]=o);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(Vm,"assembleHeaders");function Hm(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(Hm,"defaultIdempotencyKeyFactory");var Bm=10;function zm(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let n=jm(e);if(n==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!Be(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 a=i(()=>{if(r.policy===void 0)return null;let d;try{d=r.policy.maxAttempts(e.code);}catch{return null}return typeof d!="number"||!Number.isFinite(d)?null:Math.max(1,Math.min(Bm,Math.floor(d)))},"policyCeiling"),l=r.perCallMaxAttempts??a()??r.maxAttempts;if(t+1>=l)return {retry:false,reason:"attempts-exhausted"};let u=Wm(e,r.now);return u!==null?u>Fm?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:o,delayMs:u}:{retry:true,reason:o,delayMs:Hr(t,r.rng)}}i(zm,"decideRetry");function jm(e){let t=e.code==="unknown"?Oe($m(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(jm,"throttleKind");function Wm(e,t){let r=Km(e.raw);if(r!==null){let o=r-t;return o>0?o:0}let n=Gm(e.raw);return n===null?null:Math.round(n*1e3)}i(Wm,"retryOverrideMs");function Gm(e){for(let t of no(e)){let r=t.retry_after_seconds;if(typeof r=="number"&&Number.isFinite(r)&&r>=0)return r}return null}i(Gm,"findRetryAfterSeconds");function Km(e){for(let t of no(e)){let r=t.resets_at,n=qm(r);if(n!==null)return n}return null}i(Km,"findResetsAt");function no(e){if(!oa(e))return [];let t=[e];for(let r of ["error","detail"]){let n=e[r];oa(n)&&t.push(n);}return t}i(no,"candidateScopes");function qm(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(qm,"parseInstantMs");function $m(e){for(let t of no(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i($m,"rawWireCode");function oa(e){return typeof e=="object"&&e!==null}i(oa,"isRecord");async function Ym(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(Ym,"resolveDeviceAuth");function Xm(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(n),"cancel")}}i(Xm,"boundedSignal");function Qm(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(Qm,"mergeSignals");function Zm(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let o=t.setTimeout(()=>{r?.removeEventListener("abort",s),n();},e),s=i(()=>{t.clearTimeout(o),n();},"onAbort");r?.addEventListener("abort",s,{once:true});})}i(Zm,"delayAbortable");var Gr=Object.freeze(["better","same","worse"]),io=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ia(e){return C(D("validationFailed",{retryable:false,wireMessage:e}))}i(ia,"invalid");function oo(){return C(D("internalError",{retryable:false}))}i(oo,"malformed");function sa(e){return typeof e!="string"||e.trim().length===0?D("validationFailed",{retryable:false,wireMessage:"pet_ref must not be blank"}):be(e)?D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}):`/widget/v1/pets/${encodeURIComponent(e)}/cases`}i(sa,"petPath");var ze=i(e=>typeof e=="string"?e:null,"str"),aa=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"count");function la(e){if(typeof e!="object"||e===null)return null;let t=e,r=ze(t.case_id),n=ze(t.status);if(r===null||n===null)return null;let o=ze(t.last_response);return Object.freeze({caseId:r,status:n,bodyLocation:ze(t.body_location),lastResponse:o!==null&&Gr.includes(o)?o:null,checkInDueAt:ze(t.check_in_due_at),openedAt:ze(t.opened_at),resolvedAt:ze(t.resolved_at),resolutionText:ze(t.resolution_text),checkinAskCount:aa(t.checkin_ask_count),checkinAnswerCount:aa(t.checkin_answer_count)})}i(la,"caseFromWire");function ua(e){return {async list(t,r){let n=sa(t);if(typeof n!="string")return C(n);let o=await e.send("cases.list",{method:"GET",path:n,...r?.signal?{signal:r.signal}:{}});if(!o.ok)return C(o.error);let s=typeof o.value=="object"&&o.value!==null?o.value.cases:null;if(!Array.isArray(s))return oo();let a=s.map(la);return a.every(l=>l!==null)?L(Object.freeze(a)):oo()},async checkin(t,r,n,o){let s=sa(t);if(typeof s!="string")return C(s);if(typeof r!="string"||!io.test(r))return ia("case_id must be a UUID");if(!Gr.includes(n))return ia("response must be one of better, same, worse");let a=await e.send("cases.checkin",{method:"POST",path:`${s}/${r}/checkin`,body:{response:n},...o?.signal?{signal:o.signal}:{}});if(!a.ok)return C(a.error);let l=typeof a.value=="object"&&a.value!==null?a.value:{},u=la(l.case);return u===null?oo():L(Object.freeze({case:u,ctaDeepLink:ze(l.cta_deep_link)}))}}}i(ua,"createCasesRepositoryOver");var da=Object.freeze({async presignedPut(){return Promise.reject(new Error("UploadPort is unavailable; no presigned-upload adapter was injected"))}});var ca=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function qr(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let o={handle:void 0},s=i(()=>{r.clearTimeout(o.handle),t.removeEventListener("abort",s),n();},"done");o.handle=r.setTimeout(s,e),t.addEventListener("abort",s,{once:true});})}i(qr,"delayAbortable");function $r(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i($r,"mergeSignals");var so=class so{constructor(t){this.listeners=new Set;this.epoch=0;this.inFlight=null;this.snapshot=Object.freeze({...t});}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t);}}getSnapshot(){return this.snapshot}patch(t){this.snapshot=Object.freeze({...this.snapshot,...t});for(let r of this.listeners)r();}beginOperation(t){this.inFlight?.abort();let r=new AbortController;this.inFlight=r;let n=this.epoch;return {signal:t?$r(r.signal,t):r.signal,epoch:n,settle:i(()=>{this.inFlight===r&&(this.inFlight=null);},"settle")}}alive(t){return t===this.epoch}rescope(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null;}dispose(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null,this.listeners.clear();}};i(so,"MediaStore");var Kr=so;function lo(e,t,r){return Object.freeze({id:e,role:"user",text:t,createdAt:r,pending:true})}i(lo,"makeUser");function uo(e,t,r){return Object.freeze({id:e,role:"assistant",text:t,createdAt:r})}i(uo,"makeAssistant");function nr(e){return Object.freeze({id:e.id,role:e.role,text:e.text,createdAt:e.createdAt})}i(nr,"stripPending");function pa(e,t){let r={id:e.id,role:e.role,text:e.text+t,createdAt:e.createdAt};return e.citations&&(r.citations=e.citations),e.responseId&&(r.responseId=e.responseId),Object.freeze(r)}i(pa,"appendText");function co(e,t){let r={id:t.messageId?t.messageId:e.id,role:"assistant",text:e.text,createdAt:e.createdAt};return t.citations.length>0&&(r.citations=t.citations),t.messageId&&(r.responseId=t.messageId),r.urgencyLevel=t.urgencyLevel,r.urgencyReason=t.urgencyReason,r.urgencyProvided=t.urgencyProvided,Object.freeze(r)}i(co,"finalizeAssistant");function fa(e){return Object.freeze({status:e.status,messages:Object.freeze([...e.messages]),conversationId:e.conversationId,error:e.error,isStreaming:e.isStreaming,isBootstrapping:e.isBootstrapping,suggestedPrompts:Object.freeze([...e.suggestedPrompts]),unreadCount:e.unreadCount})}i(fa,"freezeSnapshot");function U(e,t,r){return D(e,{retryable:t,...r?{wireMessage:r}:{}})}i(U,"makeError");function po(e){let t=Oe(e.code);return D(t,{retryable:e.retryable||Vr(t),wireCode:e.code,wireEnvelope:"sse_frame",...e.serverRequestId?{requestId:e.serverRequestId}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},raw:e})}i(po,"errorFromFrame");function Fe(e){return ce({code:Jm(e.code),retryable:e.retryable,wireMessage:e.wireMessage??null,synthesized:true,lastEventId:null,serverRequestId:e.requestId??null})}i(Fe,"synthErrorFrame");function Jm(e){switch(e){case "authExpired":return "AUTH_EXPIRED";case "authRejected":return "AuthorizationException";case "sessionRequired":return "session_required";case "accessDenied":return "ACCESS_DENIED";case "paymentRequired":return "TIER_UPGRADE_REQUIRED";case "quotaExceeded":return "QUOTA_EXCEEDED";case "rateLimited":return "RATE_LIMITED";case "validationFailed":return "ValidationException";case "sdkUpdateRequired":return "invalidRequest";case "conflict":return "ConflictException";case "idempotencyConflict":return "IDEMPOTENCY_CONFLICT";case "idempotencyInFlight":return "IDEMPOTENCY_KEY_IN_FLIGHT";case "conversationNotFound":return "CONVERSATION_NOT_FOUND";case "petNotFound":return "PET_NOT_FOUND";case "resourceNotFound":return "ResourceNotFoundException";case "streamTimeout":return "STREAM_TIMEOUT";case "mediaUploadFailed":return "MEDIA_UPLOAD_FAILED";case "moderationBlocked":return "MODERATION_BLOCKED";case "upstreamLlmTimeout":return "UPSTREAM_LLM_TIMEOUT";case "internalError":return "INTERNAL_ERROR";case "notImplemented":return "NotImplementedException";case "serviceUnavailable":return "ServiceUnavailableException";case "streamIncomplete":return "STREAM_INCOMPLETE";case "unknown":return "UNKNOWN";default:return Ze(e)}}i(Jm,"canonicalWireCode");function ma(e){let t=Array.isArray(e)?e:ao(e)&&Array.isArray(e.categories)?e.categories:[],r=[];for(let n of t){if(!ao(n))continue;let o=rr(n.category)??rr(n.title)??"",s=ey(n.prompts??n.questions);o.length===0&&s.length===0||r.push(Object.freeze({category:o,prompts:Object.freeze(s)}));}return Object.freeze(r)}i(ma,"parsePromptCategories");function fo(e){let t=new Set,r=[];for(let n of e)for(let o of n.prompts){let s=o.trim();s.length===0||t.has(s)||(t.add(s),r.push(s));}return r}i(fo,"flattenPrompts");function ao(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(ao,"isPlainObject");function rr(e){return typeof e=="string"?e:null}i(rr,"asStr");function ey(e){if(!Array.isArray(e))return [];let t=[];for(let r of e)if(typeof r=="string")t.push(r);else if(ao(r)){let n=rr(r.text)??rr(r.prompt)??rr(r.title);n!==null&&t.push(n);}return t}i(ey,"asPromptTextList");function ya(){let e=0;return ()=>`m-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,8)}`}i(ya,"defaultIdFactory");function ga(){let e=0;return ()=>`chat-send-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(ga,"defaultIdempotencyFactory");var ba={setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")};async function*va(e,t,r,n){let o=e[Symbol.asyncIterator](),s=ha(t.overallMs,n),a=ha(t.idleMs,n),l=ny(r);try{for(;;){if(r.aborted)return;let u=o.next().then(p=>({tag:"next",value:p}),()=>({tag:"streamError"})),d=await Promise.race([u,a.promise.then(()=>({tag:"idle"})),s.promise.then(()=>({tag:"overall"})),l.then(()=>({tag:"abort"}))]);if(d.tag==="abort")return;if(d.tag==="streamError"){if(r.aborted)return;yield ry();return}if(d.tag==="idle"||d.tag==="overall"){yield ty();return}let c=d.value;if(c.done||(a.reset(t.idleMs),yield c.value,c.value.terminal))return}}finally{a.cancel(),s.cancel(),Promise.resolve(o.return?.(void 0)).catch(()=>{});}}i(va,"withWatchdog");function ty(){return ce({code:"STREAM_TIMEOUT",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(ty,"synthTimeoutFrame");function ry(){return ce({code:"STREAM_INCOMPLETE",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(ry,"synthStreamErrorFrame");function ha(e,t){let r=i(()=>{},"resolveFn"),n=new Promise(s=>{r=s;}),o=t.setTimeout(()=>r(),e);return {promise:n,reset(s){t.clearTimeout(o),o=t.setTimeout(()=>r(),s);},cancel(){t.clearTimeout(o);}}}i(ha,"deadline");function ny(e){return new Promise(t=>{if(e.aborted){t();return}e.addEventListener("abort",()=>t(),{once:true});})}i(ny,"abortPromise");var oy="checkin",iy=/^\d{4}-\d{2}-\d{2}$/,Yr="watching";function Ca(e){return e.status!=null&&e.status!==Yr}i(Ca,"isCheckinSettled");function Ea(e){let{askCount:t,answerCount:r}=e;return typeof t!="number"||!Number.isFinite(t)||typeof r!="number"||!Number.isFinite(r)||t<=0?true:r>=t}i(Ea,"isLiveAskAnswered");function mo(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,o]=t;return r!==oy||n===void 0||o===void 0||!io.test(n)||!iy.test(o)?null:{caseId:n,dueDay:o}}i(mo,"parseCheckinOrigin");function Ra(e){return mo(e)?.caseId??null}i(Ra,"parseCheckinOriginRef");function go(e,t){if(e?.limit!==void 0&&(!Number.isInteger(e.limit)||e.limit<1||e.limit>t))return C(D("validationFailed"));let r=[];for(let[n,o]of [["cursor",e?.cursor],["pet_ref",e?.petRef]])if(o!==void 0){if(typeof o!="string"||o.length===0||be(o))return C(D("validationFailed"));r.push(`${n}=${encodeURIComponent(o)}`);}return e?.limit!==void 0&&r.push(`limit=${e.limit}`),L(r.length?`?${r.join("&")}`:"")}i(go,"historyQuery");function ir(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}i(ir,"validConversationId");function Ft(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}i(Ft,"object");function Sa(e){return e==null||typeof e=="string"&&e.length>0&&!be(e)}i(Sa,"cursor");function or(){return C(D("internalError",{retryable:false}))}i(or,"malformed");function Ta(e){let t=Ft(e);if(!t||!Array.isArray(t.conversations)||!Sa(t.next_cursor))return or();let r=[];for(let n of t.conversations){let o=Ft(n);if(!o||typeof o.conversation_id!="string"||!ir(o.conversation_id)||!(o.title==null||typeof o.title=="string")||typeof o.created_at!="string"||typeof o.updated_at!="string")return or();let s=o.unread_message_count;if(!(s==null||Number.isInteger(s)&&s>=0))return or();r.push(Object.freeze({id:o.conversation_id,title:o.title??null,createdAt:o.created_at,updatedAt:o.updated_at,unreadCount:s??null}));}return L(Object.freeze({conversations:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(Ta,"mapConversationPage");function Pa(e){let t=Ft(e);if(!t||!Array.isArray(t.messages)||!Sa(t.next_cursor))return or();let r=[],n=new Set;for(let o of t.messages){let s=Ft(o);if(!s||typeof s.message_id!="string"||!ir(s.message_id)||typeof s.role!="string"||typeof s.content!="string"||typeof s.created_at!="string")return or();if(s.role!=="user"&&s.role!=="assistant"&&s.role!=="vet"||n.has(s.message_id))continue;if(n.add(s.message_id),s.role==="vet"){r.push(sy(s,s.message_id,s.content,s.created_at));continue}let a=typeof s.proactive_origin_ref=="string"?s.proactive_origin_ref:null,l=s.role==="assistant"?Ra(a):null;r.push(Object.freeze({id:s.message_id,role:s.role,text:s.content,createdAt:s.created_at,...s.role==="assistant"?{responseId:s.message_id}:{},...s.urgency_level!==void 0?{urgencyLevel:ay(s.urgency_level)}:{},...Array.isArray(s.citations)?{citations:ly(s.citations)}:{},...a!==null?{proactiveOriginRef:a}:{},...l!==null?{checkin:Object.freeze({caseId:l,answer:null,resolutionText:null,status:null})}:{}}));}return L(Object.freeze({messages:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(Pa,"mapMessagePage");function sy(e,t,r,n){let o=Ft(e.sender),s=yo(o?.display_name)??yo(e.sender_display_name),a=yo(o?.specialty);return Object.freeze({id:t,role:"vet",text:r,createdAt:n,sender:Object.freeze({displayName:s,specialty:a})})}i(sy,"vetMessage");function yo(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&!be(t)?t:null}i(yo,"trimmedText");function ay(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(ay,"normalizeUrgency");function ly(e){let t=["source_name","source_abbrev","section","authority_tier","doi","url","title","year","study_type","journal","excerpt","monograph_chunk_id"];return Object.freeze(e.flatMap(r=>{let n=Ft(r);if(!n||typeof n.source_name!="string"||typeof n.authority_tier!="string")return [];let o={};for(let s of t){let a=n[s];(typeof a=="string"||a===null)&&(o[s]=a);}return [Object.freeze(o)]}))}i(ly,"historyCitations");var ho=Object.freeze(["helpful","neutral","not_helpful","wrong","outdated","dangerous","unclear"]),Mt=4e3;var Lt=4e3;function ka(e){return e===void 0?null:!Array.isArray(e)||e.length>5?{reason:"too_many_images",error:U("validationFailed",false,`image_s3_keys accepts at most ${5} keys`)}:e.some(t=>typeof t!="string"||t.trim().length===0)?{reason:"bad_image_key",error:U("validationFailed",false,"image_s3_keys must be non-empty strings")}:null}i(ka,"validateImageKeys");function vo(e){let t=typeof e=="string"?e:"";if(t.trim().length===0)return {reason:"empty",error:U("validationFailed",false,"message is empty or whitespace-only")};let r=[...t].length;return r>Lt?{reason:"too_long",error:U("validationFailed",false,`message is ${r} characters; the server accepts at most ${Lt}`)}:null}i(vo,"validateMessageText");function xa(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(xa,"urgencyTier");async function*sr(e){yield e;}i(sr,"singleFrameStream");async function*_a(){}i(_a,"emptyStream");var uy=6e4,dy=18e4,cy=24,py=512,fy=false;function wa(e){return new Co(e)}i(wa,"createChatController");var Eo=class Eo extends Kr{constructor(r){super(fa({status:"idle",messages:[],conversationId:r.initialConversationId??null,error:null,isStreaming:false,isBootstrapping:false,suggestedPrompts:[],unreadCount:null}));this.handlerTeardowns=new Set;this.lastTurn=null;this.unadoptedCreate=null;this.lastResponseIdValue=null;this.historyGeneration=0;this.disposed=false;this.bootstrapPrompts=[];this.scopePrompts=[];this.replyPrompts=null;this.unreadByConversation=new Map;this.classifiedMessageIds=new Set;this.pendingDelta="";this.flushHandle=null;this.auth=r.auth,this.funnel=r.funnel??_e({auth:r.auth,...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),this.petRef=r.petRef??null,this.cases=ua(this.funnel),this.telemetry=r.telemetry??zr,this.errorPolicy=r.errorPolicy??Ps,this.timers=r.timers??ba,this.rng=r.rng??Math.random,this.newId=r.newId??ya(),this.makeIdempotencyKey=r.makeIdempotencyKey??ga(),this.budget={idleMs:r.budget?.idleMs??uy,overallMs:r.budget?.overallMs??dy};}patch(r){if(r.messages!==void 0){let n=Object.freeze([...r.messages]);super.patch({...r,messages:n});return}super.patch(r);}send(r,n,o){let s=n??{};if(this.disposed||this.snapshot.isBootstrapping){let u=U(this.disposed?"accessDenied":"internalError",!this.disposed);return o?(o.onError(u),()=>{}):sr(Fe(u))}let a=vo(r)??ka(s.imageS3Keys);if(a!==null)return this.telemetry.track("chat.send.rejected",{reason:a.reason}),this.patch({status:"error",isStreaming:false,error:a.error}),o?(o.onError(a.error),()=>{}):sr(Fe(a.error));if(o)return this.driveWithHandlers(r,s,o);let l=this.beginTurn(r,s);return this.runTurn(l,s.signal)}askEverfur(r,n){if(this.disposed)return sr(Fe(U("accessDenied",false)));let o=vo(r);return o!==null?(this.telemetry.track("chat.send.rejected",{reason:o.reason}),sr(Fe(o.error))):(this.resetThread(),this.send(r,n??{}))}retryLast(){let r=this.lastTurn;if(r===null){let s=this.snapshot.conversationId;return s!==null&&this.snapshot.status==="error"?this.retryHistory(s):_a()}r.assistantMessageId=null,r.sawDelta=false,r.conversationIdOverride=null,this.discardPendingDelta();let o=this.snapshot.messages.some(s=>s.id===r.userMessageId)?this.snapshot.messages:[...this.snapshot.messages,lo(r.userMessageId,r.text,this.stamp())];return this.patch({error:null,stopped:false,messages:o}),this.runTurn(r,void 0)}stop(){this.inFlight?.abort(),this.inFlight=null,this.discardPendingDelta(),this.telemetry.track("chat.cancel",{});let r=this.snapshot.messages.some(o=>o.role==="user"&&o.pending===true),n=r?this.snapshot.messages.map(o=>o.pending===true?nr(o):o):this.snapshot.messages;(this.snapshot.status==="streaming"||r)&&this.patch({status:"idle",isStreaming:false,reconnecting:false,...r?{messages:n,stopped:true}:{}});}rescope(){this.resetThread(),this.scopePrompts=[],this.unreadByConversation.clear(),this.classifiedMessageIds.clear(),this.reflectUnreadDot();}resetThread(r=[]){super.rescope(),this.historyGeneration+=1,this.unadoptedCreate=null,this.lastTurn=null,this.lastResponseIdValue=null,this.bootstrapPrompts=r,this.replyPrompts=null,this.discardPendingDelta(),this.patch({status:"idle",isStreaming:false,messages:[],conversationId:null,error:null,suggestedPrompts:r,historyCursor:null,isLoadingHistory:false,isBootstrapping:false,unreadCount:null,stopped:false,reconnecting:false});}newConversation(){this.disposed||this.resetThread(this.scopePrompts);}dispose(){this.rescope(),this.disposed=true,this.unadoptedCreate=null,this.discardPendingDelta();for(let r of this.handlerTeardowns)r();this.handlerTeardowns.clear(),super.dispose();}adoptConversation(r){this.disposed||(this.unadoptedCreate=null,this.snapshot.conversationId!==r&&this.patch({conversationId:r}));}adoptPrompts(r){if(this.disposed)return;let n=Object.freeze(fo(r));this.bootstrapPrompts=n,this.scopePrompts=n,this.replyPrompts===null&&(n.length===0&&this.snapshot.suggestedPrompts.length===0||this.patch({suggestedPrompts:n}));}async listConversations(r){return this.listConversationsWith(r)}async listConversationsWith(r,n){let o=go(r,100);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return C(U("accessDenied",false));let a=await this.authedUnary("chat.listConversations",{method:"GET",path:`/widget/v1/conversations${o.value}`},r?.signal,n);if(!this.alive(s)||this.disposed)return C(U("accessDenied",false));if(!a.ok)return a;let l=Ta(a.value);if(l.ok){for(let c of l.value.conversations)c.unreadCount!==null&&this.unreadByConversation.set(c.id,c.unreadCount);let u=this.snapshot.conversationId,d=u===null?void 0:this.unreadByConversation.get(u);d!==void 0&&d!==this.snapshot.unreadCount&&this.patch({unreadCount:d}),this.reflectUnreadDot();}return l}reflectUnreadDot(){let r=false;for(let n of this.unreadByConversation.values())if(n>0){r=true;break}r!==(this.snapshot.hasUnreadThreads??false)&&this.patch({hasUnreadThreads:r});}async openCheckin(r){if(this.disposed)return C(U("accessDenied",false));let n=r?.conversationId??null;if(n!==null){let u=await this.resumeConversation(n);return u.ok?L(n):C(u.error)}let o=r?.petRef??this.petRef,s=await this.listConversations({...o===null?{}:{petRef:o},limit:1});if(!s.ok)return C(s.error);let a=s.value.conversations[0];if(a===void 0)return L(null);let l=await this.resumeConversation(a.id);return l.ok?L(a.id):C(l.error)}async markRead(r){if(this.disposed)return C(U("accessDenied",false));let n=this.snapshot.conversationId;if(n===null)return L(void 0);let o=this.epoch,s=await this.authedUnary("chat.markRead",{method:"POST",path:`/widget/v1/conversations/${n}/read`},r?.signal);return !this.alive(o)||this.disposed?C(U("accessDenied",false)):s.ok?(this.unreadByConversation.set(n,0),this.snapshot.conversationId===n&&this.snapshot.unreadCount!==0&&this.patch({unreadCount:0}),this.reflectUnreadDot(),L(void 0)):C(s.error)}async submitFeedback(r,n,o,s){if(this.disposed)return C(U("accessDenied",false));if(typeof r!="string"||r.trim().length===0||be(r))return C(U("validationFailed",false,"feedback needs the server message id of an assistant reply"));if(!ho.includes(n))return C(U("validationFailed",false,`feedback_type must be one of ${ho.join(", ")}`));let a=typeof o=="string"?o.trim():"";if([...a].length>Mt)return C(U("validationFailed",false,`notes is over ${Mt} characters`));let l={feedback_type:n};a.length>0&&(l.notes=a);let u=this.epoch,d=await this.authedUnary("chat.submitFeedback",{method:"POST",path:`/widget/v1/messages/${encodeURIComponent(r)}/feedback`,body:l},s?.signal);if(!this.alive(u)||this.disposed)return C(U("accessDenied",false));if(!d.ok)return C(d.error);let c=d.value?.feedback_id;return L(Object.freeze({feedbackId:typeof c=="string"?c:""}))}async answerCheckin(r,n,o){if(this.disposed)return C(U("accessDenied",false));let s=o?.petRef??this.petRef;if(s===null)return C(U("validationFailed",false,"a check-in needs the pet the case belongs to"));let a=this.epoch,l=await this.cases.checkin(s,r,n,o?.signal?{signal:o.signal}:{});if(!this.alive(a)||this.disposed)return C(U("accessDenied",false));if(!l.ok)return l;let u=l.value.case.openedAt,d=Object.freeze({caseId:r,answer:n,resolutionText:l.value.case.resolutionText,status:l.value.case.status??null,...u!==null?{openedAt:u}:{}}),c=i(p=>p.checkin?.caseId===r,"carries");return this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,checkin:d}):p)}),l}async getMessages(r,n){if(!ir(r))return C(U("validationFailed",false));let o=go(n,200);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return C(U("accessDenied",false));let a=await this.authedUnary("chat.getMessages",{method:"GET",path:`/widget/v1/conversations/${r}/messages${o.value}`},n?.signal);return !this.alive(s)||this.disposed?C(U("accessDenied",false)):a.ok?Pa(a.value):a}async resumeConversation(r){if(this.disposed)return C(U("accessDenied",false));if(!ir(r))return C(U("validationFailed",false));this.resetThread();let n=this.historyGeneration;this.patch({conversationId:r,isBootstrapping:true,isLoadingHistory:true});let o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return C(U("accessDenied",false));if(!o.ok)return this.patch({status:"error",error:o.error,isBootstrapping:false,isLoadingHistory:false}),o;let s=this.unreadByConversation.get(r)??null;return this.patch({messages:o.value.messages,historyCursor:o.value.nextCursor,isBootstrapping:false,isLoadingHistory:false,unreadCount:s}),this.stampCheckinStatuses(n),s!==null&&s>0&&this.markRead(),L(void 0)}async stampCheckinStatuses(r){let n=this.petRef;if(n===null||!this.snapshot.messages.some(d=>d.checkin!==void 0&&d.checkin.status===null))return;let o=await this.cases.list(n);if(!o.ok||r!==this.historyGeneration||this.disposed)return;let s=new Set(o.value.filter(d=>d.status===Yr).map(d=>d.caseId)),a=new Map(o.value.map(d=>[d.caseId,d])),l=false,u=this.snapshot.messages.map(d=>{let c=d.checkin;if(c===void 0||c.status!==null)return d;l=true;let p=a.get(c.caseId),f=c.openedAt??p?.openedAt??null,m=s.has(c.caseId),y=p!==void 0&&(!m||Ea({askCount:p.checkinAskCount,answerCount:p.checkinAnswerCount}))?p.lastResponse:null;return Object.freeze({...d,checkin:Object.freeze({...c,status:m?Yr:p?.status??"resolved",answer:c.answer??y,resolutionText:c.resolutionText??p?.resolutionText??null,...f!==null?{openedAt:f}:{}})})});l&&this.patch({messages:u});}async refreshActiveThread(){if(this.disposed)return C(U("accessDenied",false));let r=this.snapshot.conversationId;if(r===null||this.snapshot.isStreaming)return L(void 0);let n=this.historyGeneration,o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return C(U("accessDenied",false));if(!o.ok)return C(o.error);let s=new Set(this.snapshot.messages.map(l=>l.id)),a=o.value.messages.filter(l=>!s.has(l.id));return a.length>0&&this.patch({messages:[...this.snapshot.messages,...a]}),await this.listConversationsWith({...this.petRef===null?{}:{petRef:this.petRef},limit:1},{maxAttempts:1}),L(void 0)}async loadOlderMessages(){if(this.disposed)return C(U("accessDenied",false));let r=this.snapshot.conversationId,n=this.snapshot.historyCursor;if(!r||!n||this.snapshot.isLoadingHistory)return L(void 0);let o=this.historyGeneration;this.patch({isLoadingHistory:true});let s=await this.getMessages(r,{cursor:n});if(o!==this.historyGeneration||this.disposed)return C(U("accessDenied",false));if(this.patch({isLoadingHistory:false}),!s.ok)return s;let a=new Set(this.snapshot.messages.map(u=>u.id)),l=s.value.messages.filter(u=>!a.has(u.id));return this.patch({messages:[...l,...this.snapshot.messages],historyCursor:s.value.nextCursor===n?null:s.value.nextCursor}),L(void 0)}async*retryHistory(r){let n=await this.resumeConversation(r);n.ok||(yield Fe(n.error));}async primeConversation(r){if(this.disposed)return C(U("accessDenied",false));let n=r?.petRef??null,o={petRef:n,settled:this.primeBounded(n)};this.unadoptedCreate=o;let s=await o.settled;return this.disposed?C(U("accessDenied",false)):(!s.ok&&this.unadoptedCreate===o&&(this.unadoptedCreate=null),s)}async primeBounded(r){let n=await this.headThreadWithUnread(r);if(n!==null&&!this.snapshot.isStreaming&&this.snapshot.conversationId===null&&(await this.resumeConversation(n)).ok)return L(n);let o=this.snapshot.conversationId;return o!==null?L(o):this.createConversationBounded(r)}async headThreadWithUnread(r){let n=await this.listConversationsWith({...r===null?{}:{petRef:r},limit:1},{maxAttempts:1});if(!n.ok)return null;let o=n.value.conversations[0];return o===void 0||o.unreadCount===null||o.unreadCount<=0?null:o.id}async createConversation(r){let n=this.epoch;if(this.disposed)return C(U("accessDenied",false));let o=r?.petRef??null,s={petRef:o,settled:this.createConversationBounded(o)};this.unadoptedCreate=s;let a=await s.settled;return !this.alive(n)||this.disposed?C(U("accessDenied",false)):(!a.ok&&this.unadoptedCreate===s&&(this.unadoptedCreate=null),a)}async createConversationBounded(r,n){let o={method:"POST",path:"/widget/v1/conversations",body:r?{pet_ref:r}:{}},s=await this.authedUnary("chat.createConversation",o,n,{maxAttempts:1});if(!s.ok)return C(s.error);let a=s.value?.conversation_id??s.value?.id;return typeof a!="string"||a.length===0?C(U("internalError",true)):L(a)}async getPrompts(r){let n=this.epoch;if(this.disposed)return C(U("accessDenied",false));let o=r?.petRef??null;if(o!==null&&be(o))return C(D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}));let s=o!==null?`?pet_ref=${encodeURIComponent(o)}`:"",a=await this.authedUnary("chat.getPrompts",{method:"GET",path:`/widget/v1/suggested-prompts${s}`});return !this.alive(n)||this.disposed?C(U("accessDenied",false)):a.ok?L(ma(a.value)):C(a.error)}async authedUnary(r,n,o,s){return this.funnel.send(r,o?{...n,signal:o}:n,s)}driveWithHandlers(r,n,o){let s=new AbortController,a=$r(s.signal,n.signal),l=this.beginTurn(r,n),u=this.runTurn(l,a),d=false,c=i(()=>{d||(d=true,s.abort(),this.handlerTeardowns.delete(c));},"teardown");return this.handlerTeardowns.add(c),(async()=>{for await(let p of u){if(d)break;o.onFrame(p),p.kind==="done"&&o.onDone(this.lastResponseIdValue);}!d&&this.snapshot.status==="error"&&this.snapshot.error!==null&&o.onError(this.snapshot.error),this.handlerTeardowns.delete(c);})(),c}beginTurn(r,n){let o={epoch:this.epoch,text:r,petRef:n.petRef??null,imageS3Keys:Object.freeze([...n.imageS3Keys??[]]),idempotencyKey:n.idempotencyKey??this.makeIdempotencyKey(),userMessageId:this.newId(),assistantMessageId:null,sawDelta:false,conversationIdOverride:n.conversationId??null};return this.patch({error:null,stopped:false,reconnecting:false,messages:[...this.snapshot.messages,lo(o.userMessageId,r,this.stamp())]}),o}async*runTurn(r,n){let o=this.beginOperation(n);r.epoch=o.epoch,this.patch({status:"streaming",isStreaming:true,error:null}),this.lastTurn=r;let s=0,a=false,l=false;try{for(;;){if(o.signal.aborted||!this.alive(o.epoch))return;let u=r.conversationIdOverride===null&&this.snapshot.conversationId===null,d=u?this.unadoptedCreate:null;if(d!==null&&(r.petRef===null||r.petRef===d.petRef)){let b=await d.settled;if(o.signal.aborted||!this.alive(o.epoch))return;b.ok&&this.snapshot.conversationId===null&&this.adoptConversation(b.value);}if(u&&this.snapshot.conversationId===null){let b=await this.createConversationBounded(r.petRef,o.signal);if(o.signal.aborted||!this.alive(o.epoch))return;if(!b.ok){yield*this.emitTerminal(r,b.error,Fe(b.error));return}this.adoptConversation(b.value);}let c=r.conversationIdOverride??this.snapshot.conversationId;if(c===null){let b=U("internalError",!0);yield*this.emitTerminal(r,b,Fe(b));return}this.clearAssistantInProgress(r);let p=new AbortController,f=$r(o.signal,p.signal),m=null;try{let b;try{b=await this.funnel.authorize(this.buildSendRequest(r,c));}catch{let w=this.authRejected();yield*this.emitTerminal(r,w,Fe(w));return}if(o.signal.aborted||!this.alive(o.epoch))return;let E=this.funnel.stream("chat.send",b,f);for await(let w of va(E,this.budget,f,this.timers)){if(!this.alive(o.epoch))return;if(w.kind==="error"&&w.terminal){m=w;break}if(this.applyFrame(w,r),yield w,w.terminal){o.settle();return}}}finally{p.abort();}if(o.signal.aborted||!this.alive(o.epoch))return;if(m===null){if(this.snapshot.status==="complete")return;let b=U("streamIncomplete",!0);yield*this.emitTerminal(r,b,Fe(b));return}let y=Oe(m.code);if(y==="authExpired"&&this.auth.mode==="personalized"&&!l){l=!0,this.telemetry.track("chat.auth.refresh",{});let b=await this.tryForceRefresh();if(o.signal.aborted||!this.alive(o.epoch))return;if(!b){let E=this.authRejected();yield*this.emitTerminal(r,E,m);return}this.patch({reconnecting:!0});continue}if(y==="authExpired"){this.telemetry.track("chat.auth.rejected",{});let b=this.authRejected();yield*this.emitTerminal(r,b,m);return}if(y==="accessDenied"){this.telemetry.track("chat.access_denied",{}),yield*this.emitTerminal(r,po(m),m);return}if(Ss(y)&&!a){a=!0,this.telemetry.track("chat.conv.recreate",{}),this.adoptConversation(null),r.conversationIdOverride=null,this.patch({reconnecting:!0});continue}let k=m.retryable&&Vr(y,!0);if(fy&&k&&s+1<this.errorPolicy.maxAttempts(y));yield*this.emitTerminal(r,po(m),m);return}}finally{o.settle();}}*emitTerminal(r,n,o){this.applyError(r,n),yield o;}applyFrame(r,n){switch(r.kind){case "accepted":this.snapshot.isStreaming||this.patch({status:"streaming",isStreaming:true});return;case "heartbeat":return;case "delta":this.applyDelta(r.delta,n);return;case "done":this.applyDone(r,n);return;case "analysisStarted":case "analysisComplete":return;case "unknown":this.telemetry.track("chat.frame.unknown",{});return;case "error":return;default:return Ze(r)}}stamp(){return new Date(this.timers.now()).toISOString()}applyDelta(r,n){if(n.assistantMessageId===null){let o=this.newId();n.assistantMessageId=o,n.sawDelta=true;let s=this.snapshot.messages.map(a=>a.id===n.userMessageId&&a.pending===true?nr(a):a);this.patch({status:"streaming",isStreaming:true,messages:[...s,uo(o,r,this.stamp())]});return}if(this.pendingDelta+=r,this.pendingDelta.length>=py){this.flushPendingDelta(n);return}this.scheduleDeltaFlush(n);}scheduleDeltaFlush(r){if(this.flushHandle!==null)return;let n=this.epoch;this.flushHandle=this.timers.setTimeout(()=>{if(this.flushHandle=null,!this.alive(n)){this.pendingDelta="";return}this.flushPendingDelta(r);},cy);}flushPendingDelta(r){if(this.clearFlushTimer(),this.pendingDelta.length===0)return;let n=this.pendingDelta;this.pendingDelta="";let o=r.assistantMessageId;if(o===null)return;let s=this.snapshot.messages.map(a=>a.id===o?pa(a,n):a);this.patch({messages:s});}discardPendingDelta(){this.clearFlushTimer(),this.pendingDelta="";}clearFlushTimer(){this.flushHandle!==null&&(this.timers.clearTimeout(this.flushHandle),this.flushHandle=null);}applyDone(r,n){this.flushPendingDelta(n),this.lastResponseIdValue=r.messageId?r.messageId:null;let o=r.conversationId?r.conversationId:this.snapshot.conversationId,s;if(n.assistantMessageId!==null)s=this.snapshot.messages.map(l=>l.id===n.assistantMessageId?co(l,r):l);else {let l=this.newId();n.assistantMessageId=l,n.sawDelta=true,s=[...this.snapshot.messages.map(d=>d.id===n.userMessageId&&d.pending===true?nr(d):d),co(uo(l,"",this.stamp()),r)];}let a=fo([{category:"",prompts:r.followUpQuestions}]);this.replyPrompts=a.length>0?Object.freeze(a):null,this.patch({status:"complete",isStreaming:false,error:null,conversationId:o,messages:s,suggestedPrompts:this.replyPrompts??this.bootstrapPrompts,reconnecting:false}),!r.urgencyProvided&&o!==null&&this.classifyTurn(o,this.lastResponseIdValue);}async classifyTurn(r,n){if(n===null||this.disposed)return;let o=String(n);if(this.classifiedMessageIds.has(o))return;this.classifiedMessageIds.add(o);let s=this.epoch,a=this.historyGeneration,l=await this.authedUnary("chat.classifyUrgency",{method:"POST",path:`/widget/v1/conversations/${r}/classify`});if(!l.ok||!this.alive(s)||this.disposed||a!==this.historyGeneration||this.snapshot.conversationId!==r)return;let u=xa(l.value?.urgency),d=typeof l.value?.reason=="string"?l.value.reason:null,c=i(p=>p.responseId===n,"carries");this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,urgencyLevel:u,urgencyReason:d,urgencyProvided:true}):p)});}applyError(r,n){this.flushPendingDelta(r);let o=this.snapshot.messages.map(s=>s.id===r.userMessageId&&s.pending===true?nr(s):s);this.patch({status:"error",isStreaming:false,error:n,messages:o,reconnecting:false});try{this.errorPolicy.onExpectedFailure?.(n);}catch{}}clearAssistantInProgress(r){if(this.discardPendingDelta(),r.assistantMessageId===null)return;let n=r.assistantMessageId;r.assistantMessageId=null,r.sawDelta=false;let o=this.snapshot.messages.filter(s=>s.id!==n);o.length!==this.snapshot.messages.length&&this.patch({messages:o});}buildSendRequest(r,n){let o={message:r.text};return r.imageS3Keys.length>0&&(o.image_s3_keys=r.imageS3Keys),{method:"POST",path:`/widget/v1/conversations/${n}/messages`,body:o,headers:{"Idempotency-Key":r.idempotencyKey}}}async tryForceRefresh(){if(this.auth.mode!=="personalized")return false;try{return await this.auth.identity.currentToken({forceRefresh:!0}),!0}catch{return false}}authRejected(){return U("authRejected",false)}};i(Eo,"ChatControllerImpl");var Co=Eo;async function Oa(e,t){let{controller:r}=t,n=e.petRef??null,o=e.resumeConversationId??null,s=[],a=false,l=false,u=false,d=null,c=null,p=o?r.resumeConversation(o).then(x=>x.ok?L(o):x):r.primeConversation(n?{petRef:n}:void 0),f=r.getPrompts(n!==null?{petRef:n}:void 0),[m,y]=await Promise.all([p,f]),k=null;if(m.ok)k=m.value,s.push(m.value),r.getSnapshot().conversationId===null&&r.adoptConversation(m.value);else {let x=m.error;c=x,Ia(x)?(l=true,d=x):(Aa(x)&&(a=true),u=true);}let b=[];y.ok?b=y.value:E(y.error);function E(x){Ia(x)?(l=true,d===null&&(d=x)):Aa(x)&&(a=true);}i(E,"recordAuthSignals");let w=d!==null?d.displayMessage:null;return Object.freeze({conversationId:k,petRef:n,suggestedPrompts:b,error:w,warning:w===null&&k===null&&u?my:null,cause:d??c,diagnostics:Object.freeze({candidateConversationIds:Object.freeze([...s]),sawForbidden:a,sawUnauthorized:l,sawConversationInitFailure:u})})}i(Oa,"bootstrapChat");var my="Chat is ready. Your first message will start the conversation.";function Ia(e){return e.httpStatus===401||e.code==="authExpired"||e.code==="authRejected"}i(Ia,"isUnauthorized");function Aa(e){return e.httpStatus===403||e.code==="accessDenied"}i(Aa,"isForbidden");var Ro=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Fa(e){return e!==Ro}i(Fa,"isUploadTransportAvailable");var yy=Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var Xr=10*1024*1024,Qr=5,ar=120,gy="/widget/v1/uploads/initiate";function hy(e){return typeof e=="string"&&yy.includes(e.trim().toLowerCase())}i(hy,"isAttachmentMime");function So(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<=ar)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,ar);let n=t.slice(r);return n.length>=ar?t.slice(0,ar):`${t.slice(0,r).slice(0,ar-n.length)}${n}`}i(So,"sanitizeFilename");function To(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i(To,"formatBytes");var lr=i(e=>Object.freeze({ok:true,value:e}),"ok"),we=i(e=>Object.freeze({ok:false,error:e}),"err");function oe(e,t,r,n){return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}i(oe,"failure");function by(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(by,"attachmentSize");function vy(e){let t=So(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!hy(r))return we(oe("unsupported_type",false,t));let n=by(e);return n===null?we(oe("unknown",false,t)):n>Xr?we(oe("too_large",false,t,{sizeBytes:n})):lr(Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}i(vy,"validateAttachment");function Cy(e){if(typeof e!="object"||e===null)return null;let t=e,r=i(d=>typeof d=="string"&&d.length>0?d:null,"str"),n=i(d=>typeof d=="number"&&Number.isFinite(d)?d:null,"num"),o=r(t.upload_id),s=r(t.upload_url),a=r(t.s3_key);if(o===null||s===null||a===null)return null;let l={},u=t.upload_fields;if(typeof u=="object"&&u!==null)for(let[d,c]of Object.entries(u))typeof c=="string"&&(l[d]=c);return Object.freeze({upload_id:o,upload_url:s,upload_fields:Object.freeze(l),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??Xr,s3_key:a,purpose:r(t.purpose)})}i(Cy,"parsePolicy");function Ey(e,t){let r=e.httpStatus;switch(e.code){case "quotaExceeded":return oe("quota_exceeded",false,t,{cause:e});case "rateLimited":return oe("rate_limited",true,t,{cause:e});case "idempotencyConflict":case "idempotencyInFlight":return oe("idempotency_conflict",true,t,{cause:e});case "validationFailed":return oe("unsupported_type",false,t,{cause:e});case "serviceUnavailable":case "streamTimeout":return oe("network",true,t,{cause:e});default:return r===429?oe("rate_limited",true,t,{cause:e}):r===503?oe("network",true,t,{cause:e}):r===void 0?oe("network",true,t,{cause:e}):oe("server",e.retryable,t,{httpStatus:r,cause:e})}}i(Ey,"initiateFailure");async function Ry(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:gy,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return we(Ey(n.error,t.filename));let o=Cy(n.value);return o===null?we(oe("server",false,t.filename)):lr(o)}i(Ry,"initiateAttachmentUpload");async function Sy(e,t,r,n){let o=i(()=>n?.signal?.aborted===true,"cancelled");if(o())return we(oe("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),lr(void 0)}catch{return o()?we(oe("cancelled",true,r.filename)):we(oe("server",true,r.filename))}}i(Sy,"uploadAttachmentBytes");var Ty=2,Py=3,ky=Object.freeze([1e3,2e3,4e3]),Ma=0;function xy(){return Ma+=1,`attachment-${Ma}`}i(xy,"defaultNewId");function La(e){let t=Math.max(1,e.concurrency??Ty),r=Math.max(1,e.maxAttempts??Py),n=e.backoffMs??ky,o=Math.max(1,e.maxPerMessage??Qr),s=e.timers??ca,a=e.newId??xy,l=Fa(e.transport),u=new Map,d=[],c=[],p=new Set,f=new Set,m=Object.freeze({attachments:Object.freeze([])}),y=false,k=i(()=>{m=Object.freeze({attachments:Object.freeze(d.flatMap(g=>{let _=u.get(g);return _===void 0?[]:[_.state]}))});for(let g of f)g();},"publish"),b=i((g,_)=>{g.state=Object.freeze({...g.state,..._}),k();},"patch"),E=i(()=>{for(;!y&&p.size<t&&c.length>0;){let g=c.shift(),_=u.get(g);_!==void 0&&(p.add(g),w(_).finally(()=>{p.delete(g),E();}));}},"pump"),w=i(async g=>{let{attachment:_}=g;for(;g.attempts<r;){if(y||g.controller.signal.aborted)return;g.attempts+=1;let O=g.controller.signal;b(g,{status:"uploading",error:null,progress:0});let M=await Ry(e.funnel,_,{signal:O});if(y||O.aborted)return;let I;if(!M.ok)I=we(M.error);else {let j=await Sy(e.transport,M.value,_,{signal:O,onProgress:i(W=>{!O.aborted&&g.state.status==="uploading"&&b(g,{progress:_y(W)});},"onProgress")});if(y||O.aborted)return;I=j.ok?lr(M.value.s3_key):we(j.error);}if(I.ok){b(g,{status:"uploaded",s3Key:I.value,error:null,progress:1});return}let v=I.error,P=v.retryable&&g.attempts<r;if(b(g,{status:P?"uploading":"failed",error:v,progress:0}),!P)return;let V=n[Math.min(g.attempts-1,n.length-1)]??0;await qr(V,O,s);}},"run"),T=i(g=>{c.push(g.state.id),E();},"enqueue"),x={available:l,subscribe(g){return f.add(g),()=>{f.delete(g);}},getSnapshot:i(()=>m,"getSnapshot"),get uploading(){return m.attachments.some(g=>g.status==="uploading")},get s3Keys(){return m.attachments.flatMap(g=>g.status==="uploaded"&&g.s3Key!==null?[g.s3Key]:[])},add(g){let _=vy(g);if(!_.ok)return _;if(y||d.length>=o)return we(oe("too_many",false,_.value.filename));let O=a(),M={attachment:_.value,controller:new AbortController,attempts:0,state:Object.freeze({id:O,filename:_.value.filename,previewUri:g.uri,contentType:_.value.contentType,sizeBytes:_.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return u.set(O,M),d.push(O),k(),T(M),lr(M.state)},retry(g){let _=u.get(g);_===void 0||y||_.state.status!=="failed"||(_.controller=new AbortController,_.attempts=0,b(_,{status:"uploading",error:null,progress:0,s3Key:null}),T(_));},remove(g){let _=u.get(g);if(_===void 0)return;_.controller.abort(),u.delete(g);let O=d.indexOf(g);O>=0&&d.splice(O,1);let M=c.indexOf(g);M>=0&&c.splice(M,1),k();},clear(){for(let g of [...d])x.remove(g);},dispose(){y=true;for(let g of u.values())g.controller.abort();u.clear(),d.length=0,c.length=0,f.clear(),m=Object.freeze({attachments:Object.freeze([])});}};return x}i(La,"createAttachmentQueue");function _y(e){return Number.isNaN(e)||e<0?0:e>1?1:e}i(_y,"clamp");var Da=Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function ur(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(Da,t)?Da[t]:null}i(ur,"canonicalPetSpecies");var Na=50,wy=128,Po=120,Ua=120,Iy=2e3,Va=120,Ay=80,za=new Set(["male","female","unknown"]),ja=new Set(["day","month","year"]),Wa=new Set(["low","medium","high","athletic"]),Ga=new Set(["indoor","outdoor","both"]),Ka=new Set(["mild","moderate","severe"]),Oy=/^(\d{4})-(\d{2})-(\d{2})$/,qa=[["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"]],$a=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];Object.freeze([...qa,...$a].map(([e])=>e));function Fy(e){let t=Oy.exec(e);if(t===null)return false;let[r,n,o]=[Number(t[1]),Number(t[2]),Number(t[3])],s=new Date(Date.UTC(r,n-1,o));return s.getUTCFullYear()===r&&s.getUTCMonth()===n-1&&s.getUTCDate()===o}i(Fy,"isRealDate");var cr=i(e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,"oneOf"),My=i((e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,"boolean"),Jr=i((e,t)=>typeof t=="string"&&Fy(t)?null:`${e} must be a real date written YYYY-MM-DD`,"date"),Me=i((e,t={})=>(r,n)=>{if(typeof n!="string")return `${r} must be a string`;if(be(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 s=at(o);return s<=e?null:`${r} is ${s} characters; the server accepts at most ${e}`},"text"),Ly={sex:cr(za),spayedNeutered:My,birthDate:Jr,birthDatePrecision:cr(ja),activityLevel:cr(Wa),indoorOutdoor:cr(Ga),foodBrand:Me(Va),foodType:Me(Va),microchipId:Me(Ay)},ko=["ref","ref",false,Me(wy,{required:true,trimmed:true})],xo=["notes","notes",false,Me(Iy,{trimmed:true})],Ha=[ko,["name","name",true,Me(Po,{required:true,trimmed:true})],["dose","dose",false,Me(Ua,{trimmed:true})],["frequency","frequency",false,Me(Ua,{trimmed:true})],["startDate","start_date",false,Jr],["endDate","end_date",false,Jr],xo],Dy={allergies:[ko,["allergen","allergen",true,Me(Po,{required:true,trimmed:true})],["severity","severity",false,cr(Ka)],xo],medications:Ha,supplements:Ha,conditions:[ko,["conditionName","condition_name",true,Me(Po,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Jr],xo]};function Ny(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,s={};for(let[u,d,c,p]of Dy[e]){let f=o[u];if(f==null){if(c)return {error:`${n}.${u} is required`};f===null&&(s[d]=null);continue}let m=p(`${n}.${u}`,f);if(m!==null)return {error:m};s[d]=f;}let a=s.start_date,l=s.end_date;return typeof a=="string"&&typeof l=="string"&&l<a?{error:`${n}.endDate must not be before startDate`}:{item:s}}i(Ny,"itemToWire");function Uy(e,t){if(!Array.isArray(t))return {error:`${e} must be an array (send [] to clear it)`};if(t.length>Na)return {error:`${e} has ${t.length} items; the server accepts at most ${Na}`};let r=[],n=new Set;for(let o=0;o<t.length;o+=1){let s=Ny(e,o,t[o]);if("error"in s)return s;let a=s.item.ref;if(typeof a=="string"){let l=a.trim();if(n.has(l))return {error:`${e}: ref ${JSON.stringify(l)} is used twice; a ref names one item`};n.add(l);}r.push(s.item);}return {items:r}}i(Uy,"listToWire");function Ya(e,t){let r=e,n={};for(let[a,l]of qa){let u=r[a];if(u!==void 0){if(u!==null){let d=Ly[a](a,u);if(d!==null)return {error:d}}n[l]=u;}}let o=r.birthDate!==void 0,s=r.birthDatePrecision!==void 0;if(o!==s||o&&r.birthDate===null!=(r.birthDatePrecision===null))return {error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[a,l]of $a){let u=r[a];if(u===void 0)continue;let d=Uy(a,u);if("error"in d)return d;n[l]=d.items;}return Object.keys(n).length>0&&t!==void 0&&ur(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(Ya,"petHealthToWire");var ee=i(e=>typeof e=="string"?e:null,"str"),dr=i((e,t)=>typeof t=="string"&&e.has(t)?t:null,"pick"),Vy=i(e=>typeof e=="boolean"?e:null,"bool");function Zr(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(Zr,"itemsFromWire");function Ba(e){let t=ee(e.name);return t===null||t.length===0?null:Object.freeze({ref:ee(e.ref),name:t,dose:ee(e.dose),frequency:ee(e.frequency),startDate:ee(e.start_date),endDate:ee(e.end_date),notes:ee(e.notes)})}i(Ba,"medicationFromWire");function Xa(e){let t=e.profile_version;return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:dr(za,e.sex),spayedNeutered:Vy(e.spayed_neutered),birthDate:ee(e.birth_date),birthDatePrecision:dr(ja,e.birth_date_precision),activityLevel:dr(Wa,e.activity_level),indoorOutdoor:dr(Ga,e.indoor_outdoor),foodBrand:ee(e.food_brand),foodType:ee(e.food_type),microchipId:ee(e.microchip_id),allergies:Zr(e.allergies,r=>{let n=ee(r.allergen);return n===null||n.length===0?null:Object.freeze({ref:ee(r.ref),allergen:n,severity:dr(Ka,r.severity),notes:ee(r.notes)})}),medications:Zr(e.medications,Ba),supplements:Zr(e.supplements,Ba),conditions:Zr(e.conditions,r=>{let n=ee(r.condition_name);return n===null||n.length===0?null:Object.freeze({ref:ee(r.ref),conditionName:n,diagnosedDate:ee(r.diagnosed_date),notes:ee(r.notes)})})})}i(Xa,"petHealthFromWire");var Ja=100,el=50,tl=100,rl=50,nl=500,Hy=128,By=6e4;function De(e){return D("validationFailed",{retryable:false,wireMessage:e})}i(De,"invalid");function lt(e,t,r){if(typeof t!="string")return De(`${e} must be a string`);let n=at(t);return n<=r?null:De(`${e} is ${n} characters; the server accepts at most ${r}`)}i(lt,"checkString");function en(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:De(`${e} must be a finite number between 0 and ${r}`)}i(en,"outOfRange");function Qa(e,t){if(typeof e!="string")return De("pet_ref must be a string");if(e.trim().length===0)return De("pet_ref must not be blank");if(be(e))return De("pet_ref contains an unpaired surrogate and cannot be encoded");if(t!=null&&typeof t!="object")return De("profile must be an object");let r=[lt("pet_ref",e,Hy)];return t?.name!==void 0&&r.push(lt("name",t.name,Ja)),t?.species!==void 0&&r.push(lt("species",t.species,el)),t?.breed!==void 0&&r.push(lt("breed",t.breed,tl)),t?.ageYears!==void 0&&r.push(en("age_years",t.ageYears,rl)),t?.weightKg!==void 0&&r.push(en("weight_kg",t.weightKg,nl)),r.find(n=>n!==null)??null}i(Qa,"validate");function ol(e,t){let r=Ya(e,t);return "error"in r?{error:De(r.error)}:r}i(ol,"healthToWire");function zy(e){if(typeof e!="object"||e===null)return {error:De("patch must be an object")};let t=e,r=[["name","name",s=>lt("name",s,Ja)],["species","species",s=>lt("species",s,el)],["breed","breed",s=>lt("breed",s,tl)],["ageYears","age_years",s=>en("age_years",s,rl)],["weightKg","weight_kg",s=>en("weight_kg",s,nl)]],n={};for(let[s,a,l]of r){let u=t[s];if(u!==void 0){if(u!==null){let d=l(u);if(d!==null)return {error:d}}n[a]=u;}}let o=ol(t,t.species);return "error"in o?o:(Object.assign(n,o.body),Object.keys(n).length===0?{error:De("patch must change at least one field")}:{body:n})}i(zy,"patchToWire");function jy(e){if(e==null)return {body:{}};let t=ol(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(jy,"toWire");var Le=i(e=>typeof e=="string"?e:null,"str"),tn=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"num");function Za(e,t){let r=typeof e=="object"&&e!==null?e:{};return Object.freeze({petRef:Le(r.pet_ref)??t,name:Le(r.name),species:Le(r.species),breed:Le(r.breed),ageYears:tn(r.age_years),weightKg:tn(r.weight_kg)})}i(Za,"fromWire");function il(e){if(typeof e!="object"||e===null)return null;let t=e,r=Le(t.pet_ref);return r===null||r.length===0?null:Object.freeze({petId:Le(t.pet_id),petRef:r,name:Le(t.name),species:Le(t.species),breed:Le(t.breed),ageYears:tn(t.age_years),weightKg:tn(t.weight_kg),updatedAt:Le(t.updated_at)})}i(il,"widgetPetFromWire");function Wy(e){let t=il(e);return t===null?null:Object.freeze({...t,...Xa(e)})}i(Wy,"widgetPetProfileFromWire");function Gy(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=il(r);return n===null?[]:[n]}))}i(Gy,"petListFromWire");function Je(e){return Ky(_e({auth:e}),_e({auth:e,unaryTimeoutMs:By}))}i(Je,"createPetsRepository");function Ky(e,t=e){let r=i((o,s)=>s?{...o,signal:s}:o,"withSignal"),n=i(o=>Qa(o,void 0)??`/widget/v1/pets/${encodeURIComponent(o)}`,"petPath");return {async list(o){let s=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},o?.signal));return s.ok?L(Gy(s.value)):C(s.error)},async registerPet(o,s,a){let l=Qa(o,s);if(l!==null)return C(l);let u=jy(s);if("error"in u)return C(u.error);let c={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(o)}`,body:u.body},p=await e.send("pets.registerPet",a?.signal?{...c,signal:a.signal}:c);return p.ok?L(Za(p.value,o)):C(p.error)},async updatePet(o,s,a){let l=n(o);if(typeof l!="string")return C(l);let u=zy(s);if("error"in u)return C(u.error);let d=await e.send("pets.updatePet",r({method:"PATCH",path:l,body:u.body},a?.signal));return d.ok?L(Za(d.value,o)):C(d.error)},async getPetProfile(o,s){let a=n(o);if(typeof a!="string")return C(a);let l=await e.send("pets.getPetProfile",r({method:"GET",path:`${a}/profile`},s?.signal));if(!l.ok)return C(l.error);let u=Wy(l.value);return u===null?C(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):L(u)},async deletePet(o,s){let a=n(o);if(typeof a!="string")return C(a);let l=await e.send("pets.deletePet",r({method:"DELETE",path:a},s?.signal));return l.ok?L(void 0):C(l.error)},async eraseUserData(o){let s=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},o?.signal),{maxAttempts:1});return s.ok?L(void 0):C(s.error)}}}i(Ky,"createPetsRepositoryOver");var wo=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 qy(e){return wo[e]}i(qy,"requires");function sl(e,t){let r=Object.freeze({reason:t,level:e,recoverable:false}),n=[],o=new Set;for(let s of Object.keys(wo))for(let a of wo[s])o.has(a)||(o.add(a),n.push(Object.freeze({resource:a,granted:false,disabled:r})));return Object.freeze(n)}i(sl,"deniedDecisionsFor");function al(e,t,r){let n=qy(e),o=new Map;for(let l of t)o.set(l.resource,l);if(r?.isPending===true&&n.some(l=>!o.has(l)))return _o({name:e,enabled:false,isPending:true,limits:{}});let s=$y(n,o);return n.filter(l=>o.get(l)?.granted!==true).length===0?_o({name:e,enabled:true,isPending:false,limits:s}):_o({name:e,enabled:false,isPending:false,limits:s,disabled:Yy(n,o)})}i(al,"decideCapability");function $y(e,t){let r={};for(let n of e){let o=t.get(n)?.limits;if(o)for(let[s,a]of Object.entries(o)){let l=r[s];r[s]=l===void 0?a:Math.min(l,a);}}return r}i($y,"mergeLimits");function Yy(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:Ot("accessDenied"),level:"user_entitlement",recoverable:false})}i(Yy,"disabledFor");function _o(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(_o,"freezeDecision");function me(e){let t=ie(e);return t===null?null:Qy(t)}i(me,"parseColor");function ie(e){if(typeof e=="number")return ll(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return Io(t.slice(1));if(t.toLowerCase().startsWith("0x"))return Io(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Xy(t);if(/^[0-9a-fA-F]+$/.test(t)){let r=Io(t);if(r!==null)return r}return /^\d+$/.test(t)?ll(Number.parseInt(t,10)):null}i(ie,"toRgba");function Io(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return {r:Ao(t[0]),g:Ao(t[1]),b:Ao(t[2]),a:1};if(t.length===6)return {r:ut(t,0),g:ut(t,2),b:ut(t,4),a:1};if(t.length===8){let r=ut(t,0);return {r:ut(t,2),g:ut(t,4),b:ut(t,6),a:r/255}}return null}i(Io,"fromHex");function Xy(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(u=>u.trim());if(n.length<3)return null;let o=Oo(Number(n[0])),s=Oo(Number(n[1])),a=Oo(Number(n[2]));if(o===null||s===null||a===null)return null;let l=1;if(n.length>=4){let u=Number(n[3]);if(!Number.isFinite(u))return null;l=Math.min(1,Math.max(0,u));}return {r:o,g:s,b:a,a:l}}i(Xy,"fromRgbFunc");function ll(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return {r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}i(ll,"argbIntToRgba");function ut(e,t){return Number.parseInt(e.slice(t,t+2),16)}i(ut,"byte");function Ao(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}i(Ao,"dup");function Oo(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}i(Oo,"clampByte");function Qy(e){if(e.a>=1)return ct(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return `rgba(${e.r},${e.g},${e.b},${t})`}i(Qy,"normalizeRgba");function ct(e,t,r){return `#${Fo(e)}${Fo(t)}${Fo(r)}`.toUpperCase()}i(ct,"rgbToHex");function Fo(e){return e.toString(16).padStart(2,"0")}i(Fo,"hex2");var Zy="#111111",Dt="#FFFFFF",rn="#000000";function dl(e){let t=ie(e);if(t===null)return Dt;let r=dt(t),n=dt({r:17,g:17,b:17}),o=dt({r:255,g:255,b:255});return Do(r,o)>=Do(r,n)?Dt:Zy}i(dl,"readableOn");function pr(e,t){let r=dl(e);return ue(r,e)>=t?r:ue(Dt,e)>=ue(rn,e)?Dt:rn}i(pr,"legibleOn");function fr(e){let t=i(r=>e.reduce((n,o)=>Math.min(n,ue(r,o)),Number.POSITIVE_INFINITY),"worst");return t(Dt)>=t(rn)?Dt:rn}i(fr,"poleForGrounds");function dt(e){let t=Mo(e.r/255),r=Mo(e.g/255),n=Mo(e.b/255);return .2126*t+.7152*r+.0722*n}i(dt,"relativeLuminance");function Mo(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}i(Mo,"linearize");function Do(e,t){let r=Math.max(e,t),n=Math.min(e,t);return (r+.05)/(n+.05)}i(Do,"luminanceContrast");function ue(e,t){let r=ie(e),n=ie(t);if(r===null||n===null)return 1;let o=n.a>=1?n:{...n},s=r.a>=1?r:cl(r,o);return Do(dt(s),dt(o))}i(ue,"contrastRatio");function cl(e,t){let r=e.a,n=i((o,s)=>Math.round(o*r+s*(1-r)),"mix");return {r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}i(cl,"composite");function pt(e,t){let r=ie(e),n=ie(t);if(r===null||n===null)return null;let o=r.a>=1?r:cl(r,{...n});return ct(o.r,o.g,o.b)}i(pt,"flattenOnto");function pl(e,t){let r=ie(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return `rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}i(pl,"withAlpha");var ul=.05;function et(e,t,r,n){let o=t[0];if(o===void 0)return r;let s=i(d=>t.every(c=>ue(d,c)>=n),"reads");if(ie(e)===null)return r;if(s(e))return e;let a=pt(e,o),l=a===null?null:ie(a),u=ie(r);if(l===null||u===null)return r;for(let d=1;d<1/ul;d+=1){let c=d*ul,p=i((m,y)=>Math.round(m+(y-m)*c),"mix"),f=ct(p(l.r,u.r),p(l.g,u.g),p(l.b,u.b));if(s(f))return f}return r}i(et,"pushToContrast");function fl(e,t,r){let n=e/255,o=t/255,s=r/255,a=Math.max(n,o,s),l=Math.min(n,o,s),u=(a+l)/2;if(a===l)return {h:0,s:0,l:u};let d=a-l,c=d/(1-Math.abs(2*u-1)),p;return a===n?(p=(o-s)/d*60,p<0&&(p=p+360)):a===o?p=((s-n)/d+2)*60:p=((n-o)/d+4)*60,{h:p,s:c,l:u}}i(fl,"rgbToHsl");function No(e){let{h:t,s:r,l:n}=e,o=(1-Math.abs(2*n-1))*r,s=t/60,a=o*(1-Math.abs(s%2-1)),l=n-o/2,u=Math.floor(s)%6,d=[[o,a,0],[a,o,0],[0,o,a],[0,a,o],[a,0,o],[o,0,a]],[c,p,f]=d[u];return {r:Lo(c+l),g:Lo(p+l),b:Lo(f+l)}}i(No,"hslToRgb");function Lo(e){return Math.min(255,Math.max(0,Math.floor(e*255+.5)))}i(Lo,"channel");function je(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.keys(e))je(e[t]);}return e}i(je,"deepFreeze");var on=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),yl={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},gl={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},ml={nano:8,small:9,micro:10,tiny:11,caption:12,bodyTight:13,body:14,subtitle:16,heading:18,verdict:24},Jy={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},eg={regular:"400",medium:"500",bold:"700"},tg={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},Uo=0,ft="System",Ne="monospace",rg=["content","heading","control","compact","badge"];function ng(e){let t={};for(let r of rg)t[r]=e;return t}i(ng,"authoredTierSizes");function hl(){return {family:ft,mono:Ne,fontUrl:null,families:{regular:ft,medium:ft,bold:ft,mono:Ne,monoMedium:Ne,monoBold:Ne},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:ml,tierSizes:ng(ml),lineHeight:Jy,weight:eg,letterSpacing:tg,scale:1,maxScale:Uo,scaleCaps:on}}i(hl,"baseType");var bl={},mt=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function nn(e){return `cubic-bezier(${e.join(", ")})`}i(nn,"cssCubicBezier");var vl={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:nn(mt.standard),emphasized:nn(mt.emphasized),exit:nn(mt.exit)},reducedMotion:false},og={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",bubbleVet:"#FFC3BC",onBubbleVet:"#111111",skeleton:"#EFE9E3",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},yt=je({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:og,space:yl,radius:gl,type:hl(),motion:vl,slots:bl}),ig={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",bubbleVet:"#FFC3BC",onBubbleVet:"#111111",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"},sn=je({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:ig,space:yl,radius:gl,type:hl(),motion:vl,slots:bl});var sg="#23272C",Cl=4.5,ag=.6,Vo=.9,lg=.02,ug="#FFFFFF",dg="#111111";function cg(e){return ue(e,sg)>=Cl&&Math.max(ue(e,ug),ue(e,dg))>=Cl}i(cg,"readsOnDark");function Sl(e){let t=ie(e);if(t===null)return null;let{h:r,s:n,l:o}=fl(t.r,t.g,t.b),s=Math.min(Math.max(o,ag),Vo);for(let l=0;;l+=1){let u=s+l*lg;if(u>Vo)break;let d=No({h:r,s:n,l:u}),c=ct(d.r,d.g,d.b);if(cg(c))return c}let a=No({h:r,s:n,l:Vo});return ct(a.r,a.g,a.b)}i(Sl,"deriveDarkVariant");var pg=7,El=.05,fg="#000000",mg="#FFFFFF";function yg(e,t,r,n){let o=pt(e,t);if(o===null)return r;if(ue(o,t)>=n)return o;let s=ie(o),a=ie(r);if(s===null||a===null)return r;for(let l=1;l<1/El;l+=1){let u=l*El,d=i((p,f)=>Math.round(p+(f-p)*u),"mix"),c=ct(d(s.r,a.r),d(s.g,a.g),d(s.b,a.b));if(ue(c,t)>=n)return c}return r}i(yg,"pushContrast");function gg(e,t){let r=[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill],n=r[0],o=Rl(n);for(let s of r){let a=Rl(s);(t?a>o:a<o)&&(n=s,o=a);}return n}i(gg,"hardestGround");function Rl(e){let t=ie(e);return t===null?0:dt(t)}i(Rl,"luminanceOf");function tt(e,t){return pt(e,t)??me(e)??t}i(tt,"solid");function Tl(e){let t=e.color,r=e.brightness==="dark",n=r?mg:fg,o=gg(t,r),s=i(l=>yg(l,o,n,pg),"text"),a={...t,brandSoft:tt(t.brandSoft,t.surface),brandSofter:tt(t.brandSofter,t.surface),brandBorder:s(t.brandBorder),borderHairlineGreen:s(t.borderHairlineGreen),brandBorderStrong:s(t.brandBorderStrong),brandInk:s(t.brandInk),linkInk:s(t.linkInk),borderRingCream:s(t.borderRingCream),composerBorder:s(t.composerBorder),text:{primary:s(t.text.primary),secondary:s(t.text.secondary),muted:s(t.text.muted),placeholder:s(t.text.placeholder),onBrand:t.text.onBrand,metaCool:s(t.text.metaCool),timestamp:s(t.text.timestamp)},badgeBgPositive:tt(t.badgeBgPositive,t.surface),badgeBgCaution:tt(t.badgeBgCaution,t.surface),badgeBgCritical:tt(t.badgeBgCritical,t.surface),badgeBgNeutral:tt(t.badgeBgNeutral,t.surface),checkupCardLowRiskBg:tt(t.checkupCardLowRiskBg,t.surface),checkupCardConcernBg:tt(t.checkupCardConcernBg,t.surface)};return je({...e,highContrast:true,color:a})}i(Tl,"deriveHighContrast");var gt=Object.freeze(["composerInput","sendButton","userBubble","assistantBubble","vetBubble","recordCard","vetVisitButton","primaryButton","link"]),hg=Object.freeze(["backgroundColor","borderColor","borderRadius","textColor"]),Ie=4.5,bg=Object.freeze({});function vg(e){return gt.includes(e)}i(vg,"isSlotName");function Cg(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)?Math.max(0,t):null}i(Cg,"parseRadius");function Pl(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t={},r=false;for(let[n,o]of Object.entries(e)){if(!vg(n)||o===null||typeof o!="object")continue;let s=Eg(o);s!==null&&(t[n]=s,r=true);}return r?Object.freeze(t):null}i(Pl,"parseThemeSlots");function an(e,t,r){return e[t]!==void 0?e[t]:e[r]}i(an,"pick");function Eg(e){let t={},r=me(an(e,"background_color","backgroundColor"));r!==null&&(t.backgroundColor=r);let n=me(an(e,"border_color","borderColor"));n!==null&&(t.borderColor=n);let o=Cg(an(e,"border_radius","borderRadius"));o!==null&&(t.borderRadius=o);let s=me(an(e,"text_color","textColor"));return s!==null&&(t.textColor=s),Object.keys(t).length===0?null:Object.freeze(t)}i(Eg,"parseSlot");function kl(e,t){return t===null||Object.keys(t).length===0?e??bg:e===null||Object.keys(e).length===0?t:Object.freeze({...e,...t})}i(kl,"mergeThemeSlots");var Ho=3;function Rg(e,t){return e===void 0?t:t.length===0?[e]:t.map(r=>pt(e,r)??r)}i(Rg,"seatsOf");function Sg(e,t){let r=fr(e);return e.every(n=>ue(r,n)>=t)}i(Sg,"someInkReads");function Tg(e,t){let r=t[0];return r===void 0?null:pt(e,r)}i(Tg,"collapseUnsatisfiableFill");function Pg(e){let t=pr(e[0],Ie);return e.every(r=>ue(t,r)>=Ie)?t:fr(e)}i(Pg,"inkFor");function xl(e,t){let r=false,n={};for(let o of gt){let s=e[o];if(s===void 0)continue;let a=s.backgroundColor,l=t?.[o]??[],u=Rg(a,l),d={...s},c=false;if(a!==void 0&&u.length>1&&!Sg(u,Ie)){let p=Tg(a,l);p!==null&&(d.backgroundColor=p,u=[p],c=true);}if(u.length>0){let p=s.textColor;if(a!==void 0)(p===void 0||u.some(f=>ue(p,f)<Ie))&&(d.textColor=Pg(u),c=true);else if(p!==void 0){let f=et(p,u,fr(u),Ie);f!==p&&(d.textColor=f,c=true);}if(s.borderColor!==void 0){let f=et(s.borderColor,u,fr(u),Ho);f!==s.borderColor&&(d.borderColor=f,c=true);}}n[o]=c?Object.freeze(d):s,r=r||c;}return r?Object.freeze(n):e}i(xl,"guardSlotContrast");var Il=Object.freeze(["display_name","logo_url","logo_url_dark","primary_color","accent_color","primary_color_dark","accent_color_dark","brightness","color_scheme","font_family","font_url","fonts","font_urls","chat_placeholder","surface_style","radius_scale","accessibility_max_font_scale","slots"]),mr="slots.",Al=Object.freeze([1,2]);function ln(e){return Object.keys(e).every(t=>t==="schemaVersion"||(e[t]??null)===null)}i(ln,"isEmptyBranding");function Ol(e){let t=e?.schemaVersion??null;return t===null||Al.includes(t)}i(Ol,"isKnownBrandingSchema");function Fl(e){return new Set(["hide_powered_by",...e?.lockedFields??[]])}i(Fl,"lockedFieldsOf");function kg(e){return e==="hide_powered_by"||Il.includes(e)?true:e.startsWith(mr)&>.includes(e.slice(mr.length))}i(kg,"isThemeLockName");function We(e){if(e===null||typeof e!="object")return null;let t=e,r={displayName:ht($(t,"display_name","displayName")),logoUrl:ht($(t,"logo_url","logoUrl")),primaryColor:me($(t,"primary_color","primaryColor")),accentColor:me($(t,"accent_color","accentColor")),brightness:Ig($(t,"brightness","color_scheme","colorScheme")),fontFamily:ht($(t,"font_family","fontFamily")),fontUrl:ht($(t,"font_url","fontUrl")),fonts:_l($(t,"fonts")),fontUrls:_l($(t,"font_urls","fontUrls")),placeholder:ht($(t,"chat_placeholder","placeholder","chatPlaceholder")),hidePoweredBy:xg($(t,"hide_powered_by","hidePoweredBy")),primaryColorDark:me($(t,"primary_color_dark","primaryColorDark")),accentColorDark:me($(t,"accent_color_dark","accentColorDark")),surfaceStyle:wl($(t,"surface_style","surfaceStyle"),_g),radiusScale:wl($(t,"radius_scale","radiusScale"),wg),logoUrlDark:ht($(t,"logo_url_dark","logoUrlDark")),slots:Pl($(t,"slots")),accessibilityMaxFontScale:Og($(t,"accessibility_max_font_scale","accessibilityMaxFontScale")),lockedFields:Mg($(t,"locked_fields","lockedFields")),schemaVersion:Fg($(t,"schema_version","schemaVersion"))};return ln(r)?null:Object.freeze(r)}i(We,"parseClientBranding");function xg(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true")return true;if(t==="false")return false}return null}i(xg,"parseBool");function $(e,...t){for(let r of t)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];if(n!==void 0)return n}}i($,"pick");function ht(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(ht,"parseNonEmptyString");var yr=["regular","medium","bold","mono","monoMedium","monoBold"];function _l(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let n of yr){let o=ht($(t,n));o!==null&&(r[n]=o);}return Object.keys(r).length===0?null:Object.freeze(r)}i(_l,"parseFaceMap");var _g=["white","cream","subtle"],wg=["sharp","default","round"];function wl(e,t){if(typeof e!="string")return null;let r=e.trim().toLowerCase();return t.includes(r)?r:null}i(wl,"parseEnum");function Ig(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="light"||t==="dark"||t==="auto"?t:null}i(Ig,"parseBrightness");function Ml(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)&&(typeof e!="string"||e.trim().length>0)?t:null}i(Ml,"parseNumber");var Ag=1,Ll=3.1;function Og(e){let t=Ml(e);return t===null?null:t<=0?0:Math.min(Ll,Math.max(Ag,t))}i(Og,"parseMaxFontScale");function Fg(e){if(e==null)return null;let t=Ml(e);return t!==null&&Number.isInteger(t)&&t>=1?t:0}i(Fg,"parseSchemaVersion");function Bo(e){let t=e.trim();return t.startsWith(mr)?t:t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}i(Bo,"toWireName");function Mg(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="string")continue;let n=Bo(r);kg(n)&&!t.includes(n)&&t.push(n);}return t.length===0?null:Object.freeze(t)}i(Mg,"parseLockedFields");function zo(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}i(zo,"hardenHttpsUrl");function Dl(e,t){if(t===null||ln(t))return e;let r=(t.brightness==="light"||t.brightness==="dark")&&t.brightness!==e.brightness?t.brightness==="dark"?sn:yt:e,n=r.brightness==="dark"?sn:yt,o=r.brightness==="dark",s=o?t.primaryColorDark??Nl(t.primaryColor):t.primaryColor,a=o?t.accentColorDark??Nl(t.accentColor):t.accentColor,l=s??r.color.primary,u=a??r.color.accent,d=s!==null&&Vg(t,l,n,o),c=d?n.color.primary:l,p=s!==null&&!d?ie(c):null,f=i(k=>Math.round(k+(255-k)*.4),"lift"),m=p!==null?{brand:c,bubbleUser:c,brandInk:c,text:{...r.color.text,secondary:c},brandSoft:`rgba(${p.r}, ${p.g}, ${p.b}, 0.10)`,brandSofter:`rgba(${p.r}, ${p.g}, ${p.b}, 0.15)`,brandBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.20)`,borderHairlineGreen:`rgba(${p.r}, ${p.g}, ${p.b}, 0.28)`,brandBorderStrong:`rgba(${p.r}, ${p.g}, ${p.b}, 0.55)`,composerBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.75)`,accentEdge:`rgb(${f(p.r)}, ${f(p.g)}, ${f(p.b)})`}:d?Hg(n,r.color.text):{},y={brightness:r.brightness,highContrast:r.highContrast,meta:{displayName:t.displayName??r.meta.displayName,logoUrl:(o?t.logoUrlDark??t.logoUrl:t.logoUrl)??r.meta.logoUrl,placeholder:t.placeholder??r.meta.placeholder,hidePoweredBy:t.hidePoweredBy??r.meta.hidePoweredBy},color:{...r.color,...m,...Ug(t.surfaceStyle??null,n),primary:c,accent:u,onPrimary:r.color.onPrimary,onAccent:r.color.onAccent},space:r.space,radius:zg(t.radiusScale??null,r.radius,n),type:{...r.type,...Ng(r.type,t),maxScale:t.accessibilityMaxFontScale??r.type.maxScale},motion:r.motion,slots:kl(r.slots,t.slots??null)};return je(y)}i(Dl,"withServerBranding");var Lg={regular:["regular"],medium:["medium","regular"],bold:["bold","medium","regular"],mono:["mono"],monoMedium:["monoMedium","mono"],monoBold:["monoBold","monoMedium","mono"]},Dg=[["regular","medium","bold"],["mono","monoMedium","monoBold"]];function jo(e){return e==="mono"||e==="monoMedium"||e==="monoBold"}i(jo,"isMonoFace");function Ng(e,t){let r=t.fonts??{},n=t.fontUrls??{},o={...e.families},s={...e.namedFaces},a={...e.fontUrls};for(let l of yr){let u=Lg[l].map(p=>r[p]).find(p=>p!==void 0),d=jo(l)?null:t.fontFamily;u!==void 0?(o[l]=u,s[l]=true):d!==null&&(o[l]=d,s[l]=false);let c=n[l]??(l==="regular"?t.fontUrl:null)??null;c!==null?a[l]=c:u!==void 0&&delete a[l];}for(let l of Dg)for(let u of l)s[u]&&l.some(d=>d!==u&&o[d]===o[u])&&(s[u]=false);return {family:o.regular,mono:o.mono,fontUrl:a.regular??null,families:o,namedFaces:s,fontUrls:a}}i(Ng,"mergeFaces");function Nl(e){return e===null?null:Sl(e)}i(Nl,"darkVariantOf");function Ug(e,t){if(e===null)return {};let r=t.color;return {chatGround:e==="white"?r.surface:e==="subtle"?r.surfaceSubtle:r.surfaceCream}}i(Ug,"surfaceOf");function Ul(e,t){return e==null?false:me(e)===me(t)}i(Ul,"sameColor");function Vg(e,t,r,n){return Ul(t,r.color.primary)?true:n&&(e.primaryColorDark??null)===null&&Ul(e.primaryColor,yt.color.primary)}i(Vg,"isCompiledPrimary");function Hg(e,t){let r=e.color;return {text:{...t,secondary:r.text.secondary},brand:r.brand,bubbleUser:r.bubbleUser,brandInk:r.brandInk,brandSoft:r.brandSoft,brandSofter:r.brandSofter,brandBorder:r.brandBorder,borderHairlineGreen:r.borderHairlineGreen,brandBorderStrong:r.brandBorderStrong,composerBorder:r.composerBorder,accentEdge:r.accentEdge}}i(Hg,"compiledBrandFamily");var Bg={sharp:.5,default:1,round:1.5};function zg(e,t,r){if(e===null)return t;let n=Bg[e],o=r.radius,s=i(a=>Math.round(a*n),"s");return {tile:s(o.tile),xs:s(o.xs),sm:s(o.sm),md:s(o.md),lg:s(o.lg),xl:s(o.xl),pill:o.pill}}i(zg,"radiusOf");var jg="Everfur",Wg=.5;function Wo(e){let t=e?.branding??null,r=Ol(t)?t:null,n=Yg(e?.clientOverride??null,Fl(r)),o=e?.colorScheme==="dark"?"dark":"light",s=n?.brightness??r?.brightness??"light",u=Dl((s==="auto"?o:s)==="dark"?sn:yt,Vl(r)),d=Dl(u,Vl(n));return ah(d,e)}i(Wo,"resolveTheme");function Gg(e,t,r){return Wo({...r,branding:We(t),clientOverride:We(e)})}i(Gg,"previewTheme");function Kg(e){return e==="placeholder"?"chat_placeholder":Bo(e)}i(Kg,"wireNameOf");var qg={brightness:["color_scheme"],fontUrl:["font_family"],fonts:["font_family"],fontUrls:["font_url","font_family"],primaryColorDark:["primary_color"],accentColorDark:["accent_color"],logoUrlDark:["logo_url"]};function $g(e,t){return t.has(Kg(e))?true:(qg[e]??[]).some(r=>t.has(r))}i($g,"isLocked");function Yg(e,t){if(e===null)return null;let r=false,n={...e};for(let a of Object.keys(e))(e[a]??null)!==null&&($g(a,t)||a==="lockedFields")&&(n[a]=null,r=true);let o=n.slots??null;if(o!==null){let a={},l=false;for(let u of gt){let d=o[u];d!==void 0&&(t.has(`${mr}${u}`)?l=true:a[u]=d);}l&&(n.slots=Object.keys(a).length===0?null:Object.freeze(a),r=true);}if(!r)return e;let s=Object.freeze(n);return ln(s)?null:s}i(Yg,"withoutFields");function Vl(e){return e===null||e.brightness===null?e:Object.freeze({...e,brightness:null})}i(Vl,"withoutBrightness");function Xg(e,t){if(t===1)return e;let r={};for(let[n,o]of Object.entries(e))r[n]=Math.round(o*t*10)/10;return r}i(Xg,"scaledSizes");function Qg(e){return e===void 0||!Number.isFinite(e)?1:Math.max(Wg,e)}i(Qg,"effectiveScale");var Hl=["content","heading","control","compact","badge"];function Zg(e){if(!(e>0))return on;let t={};for(let r of Hl){let n=on[r];t[r]=n===0?0:Math.min(n,e);}return t}i(Zg,"tierCaps");function Jg(e,t){return t>0?Math.min(e,t):e}i(Jg,"capped");function eh(e,t,r,n){let o={};for(let s of Hl)o[s]=n?Xg(e,Jg(t,r[s])):e;return o}i(eh,"sizesByTier");function th(e){return e==="dark"?"#FFFFFF":"#000000"}i(th,"inkPole");function rh(e){return [e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}i(rh,"textGrounds");function nh(e){return [e.surface,e.surfaceCream,e.background,e.chatGround,e.composerFill]}i(nh,"controlGrounds");function Bl(e){return [e.chatGround,e.surface,e.surfaceCream]}i(Bl,"linkGrounds");function oh(e){return {composerInput:[e.composerFill],sendButton:[e.composerFill],userBubble:[e.bubbleUser],assistantBubble:[e.chatGround,e.surfaceCream],vetBubble:[e.bubbleVet],recordCard:[e.surface],vetVisitButton:[e.primary],primaryButton:[e.brand],link:Bl(e)}}i(oh,"slotGrounds");function ih(e,t){try{let r=e(t);return r===!0||r===!1?r:null}catch{return null}}i(ih,"registration");function sh(e,t){let r=t?.isFontRegistered,n=t?.platformMonoFamily?.trim()||null;if(r===void 0&&n===null)return {family:e.family,mono:e.mono,families:e.families,namedFaces:e.namedFaces};let o={...e.families},s={...e.namedFaces};for(let a of yr)!(o[a]===ft||o[a]===Ne)&&r!==void 0&&ih(r,o[a])===false&&(o[a]=jo(a)?Ne:ft,s[a]=false),n!==null&&jo(a)&&o[a]===Ne&&(o[a]=n);return {family:o.regular,mono:o.mono,families:o,namedFaces:s}}i(sh,"platformFaces");function ah(e,t){let r=e.color.primary,n=e.color.accent,o=e.meta.displayName.trim().length===0?jg:e.meta.displayName,s=zo(e.meta.logoUrl),a={};for(let T of yr){let x=e.type.fontUrls[T];x!==void 0&&(a[T]=zo(x));}let l=a.regular??null,d=t?.reducedMotion===true?{duration:{instant:0,fast:0,normal:0,slow:0},spring:{gentle:{damping:100,stiffness:1e3}},easing:e.motion.easing,reducedMotion:true}:e.motion,c=Number.isFinite(e.type.maxScale)?e.type.maxScale:Uo,p=Qg(t?.textScale),f=Zg(c),m=eh(e.type.size,p,f,t?.scaleTypeSizes===true),y=e.color,k=th(e.brightness),b=rh(y),E={...y,primary:r,accent:n,onPrimary:pr(r,Ie),onAccent:pr(n,Ie),brandInk:et(y.brandInk,b,k,Ie),linkInk:et(e.slots.link?.textColor??n,Bl(y),k,Ie),text:{...y.text,secondary:et(y.text.secondary,b,k,Ie)},brandBorderStrong:et(y.brandBorderStrong,nh(y),k,Ho)},w={brightness:e.brightness,highContrast:false,meta:{displayName:o,logoUrl:s,placeholder:e.meta.placeholder,hidePoweredBy:e.meta.hidePoweredBy},color:E,space:e.space,radius:e.radius,type:{...e.type,...sh(e.type,t),fontUrl:l,fontUrls:a,size:m.content,tierSizes:m,scale:p,maxScale:c,scaleCaps:f},motion:d,slots:xl(e.slots,oh(E))};return t?.highContrast===true?Tl(je(w)):je(w)}i(ah,"finalize");var zl="/widget/v1/entitlements",lh=304,uh=Object.freeze({kind:"notModified"});async function Wl(e,t={},r=_e({auth:e})){let n=await r.send("entitlements.fetch",ch(t));return n.ok?ph(n.value):n.error.httpStatus===lh?uh:{kind:"failed",error:n.error}}i(Wl,"fetchEntitlements");var dh=64;function ch(e){let t={};return Go(e.cachedRevision)&&(t["if-none-match"]=`"${e.cachedRevision}"`),e.region&&e.region.length<=dh?{method:"GET",path:zl,headers:t,query:{region:e.region}}:{method:"GET",path:zl,headers:t}}i(ch,"buildRequest");function ph(e){if(e===null||typeof e!="object"||!Go(e.revision))return jl();let t=typeof e.region=="string"?e.region:"",r=Go(e.ttl_seconds)?e.ttl_seconds:0;return Object.freeze({kind:"updated",revision:e.revision,region:t,ttlSeconds:r,decisions:mh(e.capabilities),branding:fh(e),livemode:e.livemode!==false})}i(ph,"parseUpdated");function fh(e){let t=We(e.branding);if(t!==null)return t;let r=e.render_hints;if(r!==null&&typeof r=="object"){let n=We(r.branding);return n!==null?n:We(r)}return null}i(fh,"parseBranding");function mh(e){if(e===null||typeof e!="object")return Object.freeze([]);let t=[];for(let[r,n]of Object.entries(e))yh(n)&&t.push(Object.freeze({resource:r,granted:true}));return Object.freeze(t)}i(mh,"mapCapabilities");function yh(e){return typeof e=="object"&&e!==null&&e.enabled===true}i(yh,"isEnabled");function jl(){return {kind:"failed",error:D("internalError",{retryable:true,wireMessage:"malformed entitlements response"})}}i(jl,"malformed");function Go(e){return typeof e=="number"&&Number.isFinite(e)}i(Go,"isFiniteNumber");var gh=30;function Gl(e){let t=e.scheduler??hh,r=e.resolve??Wl,n=Math.max(1,e.floorSeconds??gh),o=e.rng??Math.random,s=i(()=>n+o()*n,"jitteredFloorSeconds"),a=false,l=false,u=null,d=null,c=n,p=0,f=i(()=>{u!==null&&(t.clear(u),u=null);},"clearTimer"),m=i(E=>{l||!a||(c=Math.max(n,E),u=t.set(()=>{u=null,b();},c*1e3));},"schedule"),y=null,k=i(async()=>{if(l)return null;let E=p;e.onFetch?.();let w=e.region?{cachedRevision:d,region:e.region}:{cachedRevision:d},T;try{T=await r(e.authFor(),w);}catch(x){return e.telemetry?.track("sdk.entitlements.poll_error",{reason:bh(x)}),!l&&E===p&&(e.onSettled?.(),m(s())),null}if(l||E!==p)return null;switch(T.kind){case "updated":d=T.revision,e.update(T.decisions,T.branding??null,T.livemode!==false),m(T.ttlSeconds);break;case "notModified":m(c);break;case "failed":e.telemetry?.track("sdk.entitlements.poll_failed",{code:T.error.code}),m(s());break;default:m(s());}return e.onSettled?.(),T},"tick"),b=i(()=>{let E=k().finally(()=>{y===E&&(y=null);});return y=E,E},"run");return {start(){a||l||(a=true,b());},prime(){return l?Promise.resolve(null):y??b()},stop(){l||(l=true,p++,f());},refresh(){l||!a||(p++,d=null,f(),b());}}}i(Gl,"createEntitlementPoller");var hh={set(e,t){let r=setTimeout(e,t);return r.unref?.(),r},clear(e){clearTimeout(e);}};function bh(e){return e instanceof Error?e.message:"poll failed"}i(bh,"describe");var Kl="everfur.notifications.device";var vh=3e3,ql=Object.freeze([Kl]);function $l(e){let{leaving:t,identity:r,hooks:n,telemetry:o}=e;if(t===null||r===null||n.size===0)return null;let s=Object.freeze({userRef:t.userRef,auth:e.graceAuth()}),a=[...n].map(d=>{try{return Promise.resolve(d(s))}catch(c){return Promise.reject(c)}}),l=i((d,c)=>{try{o.track("sdk.logout.hookFailed",{reason:d,count:c,totalCount:a.length});}catch{}},"report"),u=Promise.allSettled(a).then(d=>{let c=d.filter(p=>p.status==="rejected").length;c>0&&l("failed",c);});return new Promise(d=>{let c=false,p=i(()=>{c||(c=true,clearTimeout(f),d());},"finish"),f=setTimeout(()=>{c||l("timeout",a.length),p();},vh);u.then(p,p);})}i($l,"startBeforeLogoutHooks");function Yl(e){let{leaving:t,identity:r,transport:n,sessionId:o}=e,s=r.currentToken();s.catch(()=>{});let a={userRef:t.userRef,currentToken:i(()=>s,"currentToken"),hasToken:i(()=>true,"hasToken"),clear:i(()=>{},"clear")};return {mode:"personalized",transport:n,identity:a,userRef:t.userRef,sessionId:o}}i(Yl,"graceAuth");async function Xl(e,t){if(ql.length===0)return;let r=await Promise.allSettled(ql.map(o=>e.removeItem(o))),n=r.filter(o=>o.status==="rejected").length;n>0&&t.track("sdk.logout.sweepPartialFailure",{failedCount:n,totalCount:r.length});}i(Xl,"sweepPerUserKv");function Ch(){return Object.freeze([Object.freeze({resource:"chat.message.create",granted:true})])}i(Ch,"compiledDefaultDecisions");function Ko(e=Ch){let t=new Set,r=Object.freeze({decisions:e(),isPending:false,branding:null}),n=i(()=>{for(let o of t)o();},"emit");return {subscribe(o){return t.add(o),()=>{t.delete(o);}},getSnapshot(){return r},set(o){r=Object.freeze({decisions:Object.freeze([...o.decisions]),isPending:o.isPending,branding:o.branding??null,...o.livemode===false?{livemode:false}:{}}),n();},reset(){r=Object.freeze({decisions:e(),isPending:false,branding:null}),n();},setPending(o){r.isPending!==o&&(r=Object.freeze({...r,isPending:o}),n());}}}i(Ko,"createEntitlementStore");function qo(e){return D("validationFailed",{retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`})}i(qo,"notConfiguredError");function Ql(e,t){let r={publishableKey:e.publishableKey,...e.apiBaseUrl!==void 0?{apiBaseUrl:e.apiBaseUrl}:{},...e.contractVersion!==void 0?{contractVersion:e.contractVersion}:{},...e.debug!==void 0?{debug:e.debug}:{}};return Hs(r,t===void 0?void 0:{platform:t})}i(Ql,"tryResolveClient");function Zl(e){return Object.freeze({track(t,r){try{e.track(t,r);}catch{}},trackExpectedFailure(t,r){try{e.trackExpectedFailure(t,r);}catch{}}})}i(Zl,"guardTelemetry");var Eh=Object.freeze({"react-native":"If the value is set in your environment, note that babel-preset-expo inlines only EXPO_PUBLIC_* variables into a release bundle.",web:`If the value is set in your environment, note that a browser bundle does not expose ${Wr} to the SDK at run time (bundlers inline only the variables your own code names), so pass apiBaseUrl in config.`});function Jl(e,t,r=eo){try{t.trackExpectedFailure("sdk.config.invalid",{reason:e.reason});}catch{}globalThis.console?.error?.(`[everfur] SDK disabled: ${e.message}
|
|
12
|
-
[everfur] Every Everfur capability will render its off-state until this is fixed. `+Eh[r]);}i(Jl,"reportConfigFailure");function $o(e){return Object.freeze({request(){return Promise.resolve(C(qo(e)))},stream(t,r){let n=ce({code:"sdk_not_configured",retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`,synthesized:true,lastEventId:null});return {async*[Symbol.asyncIterator](){r.aborted||(yield n);}}}})}i($o,"refusingTransport");function eu(){let e=new Map;return {async getItem(t){return e.get(t)??null},async setItem(t,r){e.set(t,r);},async removeItem(t){e.delete(t);},async keys(t){return [...e.keys()].filter(r=>r.startsWith(t))}}}i(eu,"createInMemoryKv");var tu=Object.freeze({clearMemoryCache(){},clearDiskCache(){}});function ou(e,t){return new Xo(e,t)}i(ou,"createEverfurRuntime");var Rh=6e4,Qo=class Qo{constructor(t,r){this.sessionId=Zn();this.entries=new Map;this.destroyers=new Map;this.epoch=0;this.disposed=false;this.verdictSettled=false;this.refreshTimer=null;this.bootstraps=new WeakMap;this.prepared=null;this.beforeLogoutHooks=new Set;this.pendingBeforeLogout=null;this.leavingSessionId=null;let n=t.config;if(n.secureStore!==void 0&&n.secureStore.isAvailable===true)throw new Q("invalid-argument","config.secureStore is not yet consumable: SDK token persistence is unimplemented. Omit secureStore to keep memory-only tokens (SPEC-10 \xA75.3).");this.telemetry=n.telemetry?Zl(n.telemetry):zr;let o=typeof n?.publishableKey=="string"?n.publishableKey.trim():"",s=to(n?.publishableKey),a=n.transport!==void 0,l,u=typeof n.apiBaseUrl=="string"&&n.apiBaseUrl.trim().length>0?n.apiBaseUrl.trim():null;if(s!==null)l=$o(s);else if(n.transport!==void 0)l=n.transport;else {let c=Ql(n,r?.platform);c.ok?(u=c.config.apiBaseUrl,l=Ks({config:c.config,...r?.eventSourceFactory?{eventSourceFactory:r.eventSourceFactory}:{}})):(s=c.failure,l=$o(c.failure));}this.configFailure=s,this.publishableKey=s===null?o:"",this.transport=l,s!==null&&Jl(s,this.telemetry,r?.platform),this.errorPolicy=n.errorPolicy,this.camera=n.camera??ks,this.upload=n.upload??da,this.uploadTransport=n.uploadTransport??Ro,this.imageCache=n.imageCache??tu,this.kv=n.storage??eu(),this.currentUser=t.user??null,this.identity=this.buildIdentity(t.user??null),this.activePet=t.activePet,this.store=s===null?Ko():Ko(()=>sl("sdk_config",Ot("accessDenied"))),this.services={authFor:i(c=>this.buildAuth(c),"authFor"),telemetry:this.telemetry,errorPolicy:this.errorPolicy,camera:this.camera,upload:this.upload,uploadTransport:this.uploadTransport,imageCache:this.imageCache,kv:this.kv,apiBaseUrl:u},this.registry={services:this.services,acquireChat:i(c=>this.acquireInternal("chat",Yo(c),()=>this.buildChatController(c),ru),"acquireChat"),releaseChat:i(c=>this.releaseInternal(c),"releaseChat"),peekChat:i(c=>this.entries.get(`${this.epoch}|chat|${Yo(c)}`)?.controller??null,"peekChat"),acquire:i((c,p,f,m)=>this.acquireInternal(c,p,f,m),"acquire"),release:i(c=>this.releaseInternal(c),"release")},this.entitlements=this.store;let d=s===null&&(r?.startEntitlementPolling??!a);this.poller=s===null?this.buildPoller(r?.pollScheduler):null,d&&this.poller?.start();}get isDisposed(){return this.disposed}get scopeEpoch(){return this.epoch}buildIdentity(t){if(t===null)return null;let r=Ms(t.userRef,t.getToken,n=>this.armTokenRefresh(r,n));return r}armTokenRefresh(t,r){if(this.clearTokenRefresh(),r===null||this.disposed||t!==this.identity)return;let n=r-Date.now();if(n<=0)return;let o=Math.max(n-Rh,n/2);this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,!(this.disposed||t!==this.identity)&&t.currentToken({forceRefresh:true}).catch(()=>{});},o),this.refreshTimer.unref?.();}clearTokenRefresh(){this.refreshTimer!==null&&clearTimeout(this.refreshTimer),this.refreshTimer=null;}buildPoller(t){return Gl({authFor:i(()=>this.buildAuth(this.currentUser?.userRef??null),"authFor"),update:i((r,n,o)=>this.updateEntitlements({decisions:r,isPending:false,branding:n,...o===false?{livemode:o}:{}}),"update"),onFetch:i(()=>{this.verdictSettled||this.store.setPending(true);},"onFetch"),onSettled:i(()=>{this.verdictSettled=true,this.store.setPending(false);},"onSettled"),telemetry:this.telemetry,...t?{scheduler:t}:{}})}acquireInternal(t,r,n,o,s=false){let a=`${this.epoch}|${t}|${r}`,l=this.entries.get(a);if(l)return s||(l.warm?l.warm=false:l.refCount+=1),l.controller;let u=n();return this.entries.set(a,{controller:u,refCount:1,warm:s}),this.destroyers.set(u,o),u}releaseInternal(t){for(let[r,n]of this.entries)if(n.controller===t){n.refCount-=1,n.refCount<=0&&(this.runDestroyer(t),this.entries.delete(r));return}}runDestroyer(t){let r=this.destroyers.get(t);this.destroyers.delete(t),r&&r(t);}buildChatController(t){let r=wa({auth:this.buildAuth(t.userRef),telemetry:this.telemetry,...this.errorPolicy?{errorPolicy:this.errorPolicy}:{},initialConversationId:t.conversationId,petRef:t.petRef});return this.runBootstrap(r,t),r}runBootstrap(t,r){let n={};r.petRef!==null&&(n.petRef=r.petRef),r.conversationId!==null&&(n.resumeConversationId=r.conversationId);let o=Oa(n,{controller:t});return o.then(s=>t.adoptPrompts(s.suggestedPrompts)).catch(()=>{}),this.bootstraps.set(t,o),o}buildAuth(t){return this.identity!==null&&this.currentUser!==null?{mode:"personalized",transport:this.transport,identity:this.identity,userRef:this.currentUser.userRef,sessionId:this.sessionId}:{mode:"anonymous",transport:this.transport,publishableKey:this.publishableKey,userRef:this.currentUser===null?null:t,sessionId:this.sessionId}}setUser(t){if(this.disposed)return;let r=t?.userRef??null,n=this.currentUser?.userRef??null;if(r===n){this.currentUser=t,t&&this.identity===null&&(this.identity=this.buildIdentity(t));return}this.pendingBeforeLogout=this.beforeLogoutSettlement(),this.identity?.clear(),this.clearTokenRefresh(),this.currentUser=t,this.identity=this.buildIdentity(t),this.rescopeAll();}async logout(){if(this.disposed)return;let t=this.currentUser===null;this.leavingSessionId=this.sessionId,this.sessionId=Zn(),this.setUser(null),this.leavingSessionId=null,t&&this.rescopeAll();let r=this.pendingBeforeLogout;this.pendingBeforeLogout=null,r!==null&&await r,await Xl(this.kv,this.telemetry);}onBeforeLogout(t){return this.disposed?()=>{}:(this.beforeLogoutHooks.add(t),()=>{this.beforeLogoutHooks.delete(t);})}beforeLogoutSettlement(){let t=this.currentUser,r=this.identity;return $l({leaving:t,identity:r,hooks:this.beforeLogoutHooks,telemetry:this.telemetry,graceAuth:i(()=>Yl({leaving:t,identity:r,transport:this.transport,sessionId:this.leavingSessionId??this.sessionId}),"graceAuth")})}async registerPet(t,r){return this.withPets("registerPet",n=>r===void 0?n.registerPet(t):n.registerPet(t,r))}updatePet(t,r){return this.withPets("updatePet",n=>n.updatePet(t,r))}deletePet(t){return this.withPets("deletePet",r=>r.deletePet(t))}eraseUserData(){return this.withPets("eraseUserData",t=>t.eraseUserData())}async withPets(t,r){return this.disposed?C(nu(t)):r(Je(this.buildAuth(this.currentUser?.userRef??null)))}prepare(t){let r=t?.petRef??null,n=`${this.epoch}|${this.currentUser?.userRef??""}|${r??""}`,o=this.prepared;if(o!==null&&o.key===n&&(o.result===null||o.result.status==="ready"))return o.promise;let s={key:n,result:null,promise:this.runPrepare(r).then(a=>(s.result=a,a))};return this.prepared=s,s.promise}async runPrepare(t){let r=Date.now(),n=this.configFailure,o=this.disposed?nu("prepare"):n===null?null:qo(n),s=this.identity,[a,l,u]=await Promise.all([o?C(o):s===null?L(void 0):s.currentToken().then(()=>L(void 0),()=>C(D("authRejected",{retryable:false}))),o?C(o):this.primeEntitlements(),t===null?void 0:o?C(o):this.primeChat(t)]),d=a.ok?l.ok&&(u?.ok??true)?"ready":"partial":"failed",c=Date.now()-r;try{this.telemetry.track("sdk.prepare.timing",{durationMs:c,status:d});}catch{}return Object.freeze({status:d,durationMs:c,session:a,entitlements:l,...u?{chat:u}:{}})}async primeEntitlements(){let t=await this.poller?.prime();return t?t.kind==="failed"?C(t.error):L(void 0):C(D("internalError",{retryable:true}))}async primeChat(t){let r={userRef:this.currentUser?.userRef??null,petRef:t,conversationId:null},n=this.acquireInternal("chat",Yo(r),()=>this.buildChatController(r),ru,true),o=await this.bootstraps.get(n);return o?.cause&&n.getSnapshot().conversationId===null&&(o=await this.runBootstrap(n,r)),o?.cause?C(o.cause):L(void 0)}setActivePet(t){if(this.disposed)return;let r=t??null;r!==this.activePet&&(this.activePet=r,this.rescopeAll());}updateEntitlements(t){this.disposed||this.configFailure===null&&this.store.set(t);}open(t){this.telemetry.track("sdk.open",{capability:t});}dispose(){this.disposed||(this.disposed=true,this.epoch+=1,this.poller?.stop(),this.identity?.clear(),this.clearTokenRefresh(),this.disposeAllControllers());}rescopeAll(){this.epoch+=1,this.disposeAllControllers(),this.store.reset(),this.verdictSettled=false,this.poller?.refresh();}disposeAllControllers(){for(let t of this.entries.values())this.runDestroyer(t.controller);this.entries.clear(),this.destroyers.clear();}};i(Qo,"EverfurRuntimeImpl");var Xo=Qo;function Yo(e){return `${e.userRef??""}|${e.petRef??""}|${e.conversationId??""}`}i(Yo,"chatScopeKey");function ru(e){e.dispose();}i(ru,"disposeChat");function nu(e){return D("validationFailed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}i(nu,"disposedError");var iu=Symbol.for("@everfur/sdk#EverfurContext@v1"),su=globalThis,un=su[iu]??(su[iu]=react.createContext(null));un.displayName??="EverfurContext";function Y(){let e=react.useContext(un);if(e===null)throw new Q("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(Y,"useEverfurContext");function au(){return Y().handle}i(au,"useEverfur");var lu=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),uu=globalThis,gr=uu[lu]??(uu[lu]=react.createContext(yt));gr.displayName??="EverfurThemeContext";function F(){return react.useContext(gr)}i(F,"useEverfurTheme");function dn(e){let{runtime:t}=Y(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot),o=e.seams.useColorScheme(),s=e.seams.useReducedMotion(),a=e.seams.useTextScale(),l=e.seams.useHighContrast(),u=e.seams.scaleTypeSizes,d=e.seams.platformMonoFamily?.(),c=e.seams.isFontRegistered,p=e.clientTheme?wh(e.clientTheme):"",f=react.useMemo(()=>e.clientTheme?We(e.clientTheme):null,[p]),m=n.branding??null,y=react.useMemo(()=>Wo({branding:m,clientOverride:f,colorScheme:o,reducedMotion:s,textScale:a,scaleTypeSizes:u,highContrast:l,...d===void 0?{}:{platformMonoFamily:d},...c===void 0?{}:{isFontRegistered:c}}),[m,f,o,s,a,u,l,d,c]);return e.seams.useResolvedTheme?.(y),react.createElement(gr.Provider,{value:y},e.children)}i(dn,"EverfurThemeProviderCore");function wh(e){try{return JSON.stringify(e)}catch{return Object.keys(e).join("&")}}i(wh,"stableKey");function mu(e){let{config:t,user:r,activePet:n,theme:o,warmUp:s,children:a,seams:l}=e,u=`${t?.publishableKey??""}|${t?.apiBaseUrl??""}|${t?.contractVersion??""}`,d=react.useRef(null),c=react.useRef(null),[p,f]=react.useReducer(P=>P+1,0),m=react.useRef(null),y=react.useRef(void 0),k=r?.userRef??null;y.current!==k&&(y.current!==void 0&&(m.current=null),y.current=k);let b=m.current!==null?m.current.user:r??null,E=react.useRef(null),w=react.useRef(void 0),T=n??null;w.current!==T&&(w.current!==void 0&&(E.current=null),w.current=T);let x=E.current!==null?E.current.pet:n??null;(d.current===null||d.current.key!==u||d.current.runtime.isDisposed)&&(d.current!==null&&!d.current.runtime.isDisposed&&(c.current=d.current.runtime),d.current={key:u,runtime:ou({config:l.withDefaults?l.withDefaults(t):t,user:b,activePet:x,theme:o??null},{platform:l.platform,...l.eventSourceFactory?{eventSourceFactory:l.eventSourceFactory}:{}})});let g=d.current.runtime,_=react.useRef(null);react.useEffect(()=>{let P=d.current?.runtime;P===void 0||!P.isDisposed||_.current!==P&&(_.current=P,f());}),react.useEffect(()=>{let P=c.current;P!==null&&(c.current=null,P.dispose());});let O=b?.userRef??null;react.useLayoutEffect(()=>{g.setUser(b);},[g,O]),react.useLayoutEffect(()=>{g.setActivePet(x);},[g,x]),react.useEffect(()=>()=>g.dispose(),[g]),react.useEffect(()=>{s==="onMount"&&g.prepare(x===null?{}:{petRef:x});},[g,s,O,x]);let M=react.useMemo(()=>({setUser:i(P=>{m.current={user:P},g.setUser(P),f();},"setUser"),setActivePet:i(P=>{E.current={pet:P},g.setActivePet(P),f();},"setActivePet"),open:i(P=>g.open(P),"open"),prepare:i(P=>g.prepare(P),"prepare"),registerPet:i((P,V)=>g.registerPet(P,V),"registerPet"),updatePet:i((P,V)=>g.updatePet(P,V),"updatePet"),deletePet:i(P=>g.deletePet(P),"deletePet"),eraseUserData:i(()=>g.eraseUserData(),"eraseUserData"),logout:i(()=>{m.current={user:null};let P=g.logout();return f(),P},"logout")}),[g,f]),I=react.useMemo(()=>({runtime:g,handle:M,userRef:O,activePet:x,scopeEpoch:g.scopeEpoch}),[g,M,O,x,p]),v=react.createElement(dn,{clientTheme:o??null,seams:l.theme,children:a});return react.createElement(un.Provider,{value:I},l.wrap?l.wrap(v):v)}i(mu,"EverfurProviderCore");var Oh=2;function Fh(e,t){let r=e?._xhr;if(!r||typeof r.getResponseHeader!="function"||typeof r.readyState=="number"&&r.readyState<Oh)return null;let n;try{n=r.getResponseHeader(t);}catch{return null}return typeof n=="string"&&n.length>0?n:null}i(Fh,"readEventSourceResponseHeader");function yu(){let e=Ah__default.default;return (t,r)=>{let n=new e(t,{method:r.method,headers:r.headers,pollingInterval:r.pollingInterval??0,...r.body!==void 0?{body:r.body}:{}});return Object.assign(n,{getResponseHeader:i(o=>Fh(n,o),"getResponseHeader")})}}i(yu,"createRnEventSourceFactory");function Nh(){let e=reactNative.useColorScheme();return e==="dark"?"dark":e==="light"?"light":null}i(Nh,"useRnColorScheme");function Uh(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(Uh,"isThenable");function Vh(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,n=reactNative.AccessibilityInfo?.isReduceMotionEnabled;if(typeof n=="function"){let s=n.call(reactNative.AccessibilityInfo);s!=null&&typeof s.then=="function"&&s.then(a=>{r&&t(a===true);},()=>{});}let o=reactNative.AccessibilityInfo?.addEventListener?.("reduceMotionChanged",s=>t(s===true));return ()=>{r=false,o?.remove?.();}},[]),e}i(Vh,"useRnReducedMotion");function bu(){let e=reactNative.PixelRatio?.getFontScale;if(typeof e!="function")return 1;try{let t=e.call(reactNative.PixelRatio);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}catch{return 1}}i(bu,"readFontScale");function Hh(e){let t=reactNative.Dimensions?.addEventListener;if(typeof t!="function")return ()=>{};let r=t.call(reactNative.Dimensions,"change",e);return ()=>r?.remove?.()}i(Hh,"subscribeFontScale");function Bh(){return react.useSyncExternalStore(Hh,bu,bu)}i(Bh,"useRnTextScale");function Ru(){try{let e=reactNative.Platform?.OS;return typeof e=="string"?e:null}catch{return null}}i(Ru,"platformOS");function zh(){return Ru()==="android"?{query:"isHighTextContrastEnabled",event:"highTextContrastChanged"}:{query:"isDarkerSystemColorsEnabled",event:"darkerSystemColorsChanged"}}i(zh,"contrastSignal");function jh(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,{query:n,event:o}=zh(),a=reactNative.AccessibilityInfo?.[n];if(typeof a!="function")return ()=>{};try{let d=a.call(reactNative.AccessibilityInfo);Uh(d)&&Promise.resolve(d).then(c=>{r&&t(c===!0);},()=>{});}catch{}let l=reactNative.AccessibilityInfo?.addEventListener,u=typeof l=="function"?l.call(reactNative.AccessibilityInfo,o,d=>t(d===true)):void 0;return ()=>{r=false,u?.remove?.();}},[]),e}i(jh,"useRnHighContrast");function Wh(){return Ru()==="ios"?"Menlo":Ne}i(Wh,"rnPlatformMonoFamily");function Gh(){return globalThis.__DEV__!==false}i(Gh,"isDevelopment");var vu=new Set;function Kh(e){if(!Gh()||vu.has(e))return;vu.add(e);let t=globalThis.console;try{t?.warn?.(`[everfur] The theme names the font face "${e}", which this app has not registered; the SDK renders the platform font at that weight instead. Register the font file (expo-font or your native font assets) or name a registered face.`);}catch{}}i(Kh,"warnUnregisteredFace");function qh(e){let t=globalThis.expo?.modules?.ExpoFontLoader,r=t?.getLoadedFonts;if(typeof r!="function")return null;let n;try{n=r.call(t);}catch{return null}if(!Array.isArray(n)||n.length===0)return null;let o=n.includes(e);return o||Kh(e),o}i(qh,"rnIsFontRegistered");var pn=Object.freeze({useColorScheme:Nh,useReducedMotion:Vh,useTextScale:Bh,useHighContrast:jh,scaleTypeSizes:false,platformMonoFamily:Wh,isFontRegistered:qh});function Yh(e){return react.createElement(reactNativeSafeAreaContext.SafeAreaProvider,null,e)}i(Yh,"wrapInSafeArea");var Xh=Object.freeze({platform:"react-native",eventSourceFactory:yu(),wrap:Yh,theme:pn});function Qh(e){return react.createElement(mu,{...e,seams:Xh})}i(Qh,"EverfurProvider");function Nt(e){let{runtime:t}=Y(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return react.useMemo(()=>al(e,n.decisions,{isPending:n.isPending}),[e,n])}i(Nt,"useCapability");function nb(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(nb,"tierMultiplier");function R({tier:e="content",...t}){let{type:r}=F(),n=nb(r,e);return react.createElement(reactNative.Text,n===void 0?t:{maxFontSizeMultiplier:n,...t})}i(R,"Text");var Ut=react.forwardRef(i(function(t,r){return react.createElement(reactNative.TextInput,{...t,...r===null?{}:{ref:r}})},"TextInput"));var ob=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function S(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[ob[t]]}}i(S,"face");var Jo=class Jo 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(Jo,"HostRenderBoundary");var Zo=Jo;function sb({render:e}){return e()}i(sb,"RenderHost");function Ct({render:e,fallback:t,resetKey:r}){return react.createElement(Zo,{fallback:t,resetKey:r,children:react.createElement(sb,{render:e})})}i(Ct,"HostRender");var ab=48;function lb(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(lb,"selectView");function ri(e){let{capability:t,children:r,renderDisabled:n,renderPending:o,style:s}=e,a=Nt(t),l=react.useMemo(()=>lb(a),[a]);switch(l){case "enabled":return r;case "pending":return o?jsxRuntime.jsx(Ct,{render:o,fallback:jsxRuntime.jsx(xu,{capability:t,style:s})}):jsxRuntime.jsx(xu,{capability:t,style:s});case "disabled":return n?jsxRuntime.jsx(Ct,{render:()=>n(a),fallback:jsxRuntime.jsx(_u,{decision:a,style:s}),resetKey:a}):jsxRuntime.jsx(_u,{decision:a,style:s});default:return Ze(l)}}i(ri,"CapabilityGate");function xu({capability:e,style:t}){let r=F(),n=react.useMemo(()=>wu(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(xu,"PendingSkeleton");function _u({decision:e,style:t}){let r=F(),n=react.useMemo(()=>wu(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(R,{style:n.offstateText,children:o}):null})}i(_u,"OffState");function wu(e){let{color:t,space:r,radius:n,type:o}=e;return reactNative.StyleSheet.create({offstate:{minHeight:ab,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...S(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(wu,"makeStyles");var h=Object.freeze({placeholder:"Ask me anything!",send:"Send",stop:"Stop",retry:"Try again",followUps:"Helpful follow-ups",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",senderVet:"Your vet",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 K(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let o=t[n];return o===void 0?r:String(o)})}i(K,"fillCopy");var ni=Object.freeze([Object.freeze({key:"inaccurate",label:h.feedbackReasonInaccurate,feedbackType:"wrong"}),Object.freeze({key:"outdated",label:h.feedbackReasonOutdated,feedbackType:"outdated"}),Object.freeze({key:"unsafe",label:h.feedbackReasonUnsafe,feedbackType:"dangerous"}),Object.freeze({key:"unclear",label:h.feedbackReasonUnclear,feedbackType:"unclear"}),Object.freeze({key:"other",label:h.feedbackReasonOther,feedbackType:"not_helpful"})]),Iu=Object.freeze([Object.freeze({sentiment:"up",label:h.feedbackHelpful}),Object.freeze({sentiment:"neutral",label:h.feedbackNeutral}),Object.freeze({sentiment:"down",label:h.feedbackNotHelpful})]);function ub(e){switch(e){case "up":return "helpful";case "neutral":return "neutral";case "down":return "not_helpful"}}i(ub,"sentimentToFeedbackType");function Au(e,t){if(e==="down"&&t!==null){let r=ni.find(n=>n.key===t);if(r!==void 0)return r.feedbackType}return ub(e)}i(Au,"feedbackTypeFor");var fb=Object.freeze({status:"idle",messages:Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:Object.freeze([]),unreadCount:null});function hr(e){let{runtime:t,userRef:r,activePet:n,scopeEpoch:o}=Y(),s=e?.petRef??n??null,a=e?.conversationId??null,l=react.useMemo(()=>({runtime:t,userRef:r,petRef:s,conversationId:a,scopeEpoch:o}),[t,r,s,a,o]),[u,d]=react.useState(null),c=u?.scope===l?u.controller:t.registry.peekChat({userRef:r,petRef:s,conversationId:a}),p=react.useRef(null);react.useEffect(()=>{let I=t.registry.acquireChat({userRef:r,petRef:s,conversationId:a});return p.current=I,d({scope:l,controller:I}),()=>{p.current=null,d(v=>v?.controller===I?null:v),t.registry.releaseChat(I);}},[t,r,s,a,o,l]);let f=react.useCallback(I=>c?c.subscribe(I):mb,[c]),m=react.useCallback(()=>c?c.getSnapshot():fb,[c]),y=react.useSyncExternalStore(f,m,m),k=react.useCallback((I,v)=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?ii(c,c.send(I,v?.imageS3Keys===void 0?{}:{imageS3Keys:v.imageS3Keys}),()=>p.current===c):Promise.resolve(si()),[c]),b=react.useCallback(I=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?ii(c,c.askEverfur(I),()=>p.current===c):Promise.resolve(si()),[c]),E=react.useCallback(()=>c&&p.current===c?ii(c,c.retryLast(),()=>p.current===c):Promise.resolve(si()),[c]),w=react.useCallback(()=>{c&&p.current===c&&c.stop();},[c]),T=react.useCallback(()=>{c&&p.current===c&&c.newConversation();},[c]),[x,g]=react.useState({controller:null,byMessage:{}}),_=x.controller===c?x.byMessage:yb,O=react.useCallback(async(I,v,P,V)=>{if(!c||p.current!==c)return C(D("accessDenied"));let j=String(I),W=x.controller===c?x.byMessage[j]:void 0;if(W===v&&P==null)return g(he=>{let xe={...he.controller===c?he.byMessage:{}};return delete xe[j],{controller:c,byMessage:xe}}),L(Object.freeze({feedbackId:""}));g(he=>({controller:c,byMessage:{...he.controller===c?he.byMessage:{},[j]:v}}));let ne=await c.submitFeedback(I,Au(v,P??null),V??null);return p.current!==c?C(D("accessDenied")):(ne.ok||g(he=>{let xe={...he.controller===c?he.byMessage:{}};return W===void 0?delete xe[j]:xe[j]=W,{controller:c,byMessage:xe}}),ne)},[c,x]),M=react.useMemo(()=>{let I=i(async v=>{if(!c||p.current!==c)return C(D("accessDenied"));let P=await v(c);return p.current===c?P:C(D("accessDenied"))},"run");return {listConversations:i(v=>I(P=>P.listConversations({...s?{petRef:s}:{},...v})),"listConversations"),getMessages:i((v,P)=>I(V=>V.getMessages(v,P)),"getMessages"),resumeConversation:i(v=>I(P=>P.resumeConversation(v)),"resumeConversation"),loadOlderMessages:i(()=>I(v=>v.loadOlderMessages()),"loadOlderMessages"),markRead:i(()=>I(v=>v.markRead()),"markRead"),refreshActiveThread:i(()=>I(v=>v.refreshActiveThread()),"refreshActiveThread"),answerCheckin:i((v,P)=>I(V=>V.answerCheckin(v,P)),"answerCheckin"),openCheckin:i(v=>I(P=>P.openCheckin(v)),"openCheckin")}},[c,s]);return react.useMemo(()=>({status:y.status,messages:y.messages,conversationId:y.conversationId,petRef:s,error:y.error,isStreaming:y.isStreaming,isBootstrapping:y.isBootstrapping,historyCursor:y.historyCursor??null,isLoadingHistory:y.isLoadingHistory??false,stopped:y.stopped??false,reconnecting:y.reconnecting??false,...M,suggestedPrompts:y.suggestedPrompts,unreadCount:y.unreadCount,hasUnreadThreads:y.hasUnreadThreads??false,newConversation:T,sentimentByMessage:_,feedback:O,send:k,askEverfur:b,retryLast:E,stop:w}),[y,s,k,b,E,w,M,T,_,O])}i(hr,"useEverfurChat");var mb=i(()=>{},"NOOP_UNSUBSCRIBE"),yb=Object.freeze({});async function ii(e,t,r){for await(let o of t);if(!r())return C(D("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?C(n.error):L(gb(n.messages))}i(ii,"driveToResult");function gb(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(gb,"lastAssistantResponseId");function si(){return C(D("internalError",{retryable:true}))}i(si,"notReadyError");function Lu(e){switch(e.code){case "too_large":return K(h.attachmentTooLarge,{max:To(Xr),filename:e.filename,size:To(e.sizeBytes??0)});case "too_many":return K(h.attachmentTooMany,{max:Qr});case "unsupported_type":return K(h.attachmentUnsupported,{filename:e.filename});case "network":return h.attachmentNetwork;case "server":return K(h.attachmentServer,{status:e.httpStatus?` (${e.httpStatus})`:""});case "cancelled":return h.attachmentCancelled;case "rate_limited":return h.attachmentRateLimited;case "quota_exceeded":return h.attachmentQuota;case "idempotency_conflict":return h.attachmentConflict;case "unknown":return h.attachmentUnknown}}i(Lu,"attachmentErrorMessage");function Du(e,t){return K(e>=t?h.attachmentsFull:h.addAttachment,{used:e,total:t})}i(Du,"attachControlLabel");var Cb=Object.freeze({attachments:Object.freeze([])});function fn(e={}){let{runtime:t,userRef:r,scopeEpoch:n}=Y(),o=e.maxPerMessage??Qr,s=react.useCallback(()=>{let{services:g}=t.registry;return La({funnel:_e({auth:g.authFor(r),...g.errorPolicy?{errorPolicy:g.errorPolicy}:{}}),transport:e.transport??g.uploadTransport,maxPerMessage:o})},[t,r,n,o,e.transport]),a=react.useMemo(()=>e.queue??s(),[e.queue,s]),l=react.useRef(new WeakSet),[u,d]=react.useState(null),c=u!==null&&u.of===a?u.queue:a;react.useEffect(()=>{if(c!==e.queue){if(l.current.has(c)){d({of:a,queue:s()});return}return ()=>{c.dispose(),l.current.add(c);}}},[c,a,s,e.queue]);let p=react.useSyncExternalStore(c.subscribe,c.getSnapshot,()=>Cb),[f,m]=react.useState(null),y=react.useCallback(g=>{let O=(Array.isArray(g)?g:[g]).map(I=>c.add(I)),M=O.find(I=>!I.ok);return M!==void 0&&!M.ok&&m(M.error),O},[c,m]),k=react.useCallback(g=>c.retry(g),[c]),b=react.useCallback(g=>c.remove(g),[c]),E=react.useCallback(()=>c.clear(),[c]),w=react.useCallback(()=>m(null),[m]),T=p.attachments.some(g=>g.status==="uploading"),x=p.attachments.some(g=>g.status==="failed");return react.useMemo(()=>({available:c.available,attachments:p.attachments,maxPerMessage:o,uploading:T,failed:x,blocked:T||x,s3Keys:p.attachments.flatMap(g=>g.status==="uploaded"&&g.s3Key!==null?[g.s3Key]:[]),rejected:f,add:y,retry:k,remove:b,clear:E,dismissRejected:w}),[c.available,p,o,T,x,f,y,k,b,E,w])}i(fn,"useChatAttachments");var Sb="pet_not_registered";function Vu(e){return e!=null&&e.reasonCode===Sb}i(Vu,"isPetNotRegistered");var Tb=Object.freeze({status:"idle",error:null,registered:null,retry:i(()=>{},"retry")});function Hu(e,t,r){let{runtime:n,userRef:o,scopeEpoch:s}=Y(),a=react.useCallback(()=>Je(n.registry.services.authFor(o)),[n,o,s]),l=react.useMemo(()=>t===void 0?null:li(t),[t]),[u,d]=react.useState({key:null,status:"idle",error:null,registered:null}),c=react.useRef(0),p=react.useRef(r);p.current=r;let f=e===null||l===null?null:`${String(o)}|${s}|${e}|${l}`,m=react.useCallback(()=>{if(e===null||t===void 0||f===null)return;let k=++c.current;d({key:f,status:"registering",error:null,registered:null}),a().registerPet(e,t).then(b=>{k===c.current&&(b.ok?(d({key:f,status:"registered",error:null,registered:b.value}),p.current?.()):d({key:f,status:"failed",error:b.error,registered:null}));});},[a,e,f]);react.useEffect(()=>{if(f===null){c.current+=1;return}return m(),()=>{c.current+=1;}},[f,m]);let y=react.useCallback(()=>{u.status==="failed"&&m();},[u.status,m]);return react.useMemo(()=>f===null?Tb:u.key!==f?{status:"registering",error:null,registered:null,retry:y}:{status:u.status,error:u.error,registered:u.registered,retry:y},[f,u,y])}i(Hu,"useChatPetRegistration");function li(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(li).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)}:${li(n)}`).join(",")}}`}i(li,"stableKey");var ui=Object.freeze({});function zu(e){let[t,r]=react.useState(ui),n=react.useRef(null),o=react.useRef([]);o.current=e.map(a=>a.id),react.useEffect(()=>{if(e.length===0){n.current=null,r(u=>u===ui?u:ui);return}let a=n.current;if(a===null)return;let l=e.find(u=>u.role==="user"&&!a.known.has(u.id));l!==void 0&&(n.current=null,r(u=>({...u,[l.id]:a.images})));},[e]);let s=react.useCallback(a=>{n.current=a.length===0?null:{images:a,known:new Set(o.current)};},[]);return react.useMemo(()=>({byMessage:t,stage:s}),[t,s])}i(zu,"useSentImages");var Ib=500;function di(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,Ib):null}i(di,"sanitizeSeedPrompt");function Wu(e,t,r){let n=di(r),o=react.useRef(e);o.current=e;let s=react.useRef(null);react.useEffect(()=>{if(n===null||t||s.current===n)return;let a=o.current;a!==void 0&&(s.current=n,Promise.resolve(a(n)).catch(()=>{}));},[n,t]);}i(Wu,"useInitialAsk");function Ab(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(Ab,"isCoalesced");function Gu(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"}:Ab(e,r,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:r}}i(Gu,"decideChatRefresh");function ci(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(ci,"reportHostFailure");function Ob(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(Ob,"isThenable");function q(e,...t){if(typeof e=="function")try{let r=e(...t);return Ob(r)&&Promise.resolve(r).then(void 0,ci),r}catch(r){ci(r);return}}i(q,"callHost");var Ku=new WeakMap;function qu(e){if(typeof e!="function")return;let t=Ku.get(e);if(t!==void 0)return t;let r=i((...n)=>{q(e,...n);},"guarded");return Ku.set(e,r),r}i(qu,"guardHost");function Ht(e,...t){let r;try{r=e(...t);}catch(n){return ci(n),Promise.resolve({ok:false,error:n})}return Promise.resolve(r).then(n=>({ok:true,value:n}),n=>({ok:false,error:n}))}i(Ht,"callHostAsync");function Yu(e,t){let r=react.useRef(t);r.current=t;let n=react.useRef(null),o=react.useRef(null),s=e?.isOffline===void 0?false:q(()=>e.isOffline?.()===!0)===true,a=react.useRef(()=>{});a.current=l=>{let{conversationId:u,isTurnInFlight:d,refresh:c}=r.current,p=Gu(l,{activeConversationId:u,isTurnInFlight:d,isOffline:s,lastRefresh:n.current,now:Date.now()});if(p.action!=="skip"){if(p.action==="defer"){o.current!=="announced"&&(o.current=l);return}o.current=null,n.current={conversationId:p.conversationId,at:Date.now()},c!==void 0&&Promise.resolve(c()).catch(()=>{});}},react.useEffect(()=>{if(t.isTurnInFlight||s)return;let l=o.current;l!==null&&a.current(l);},[t.isTurnInFlight,s]),react.useEffect(()=>{if(e===void 0)return;let l=[],u=i((d,c)=>{if(d===void 0)return;let p=q(()=>d(()=>{a.current(c);}));typeof p=="function"&&l.push(p);},"subscribe");return u(e.onForeground?.bind(e),"foreground"),u(e.onOnline?.bind(e),"foreground"),u(e.onAnnounced?.bind(e),"announced"),()=>{for(let d of l)q(d);}},[e]);}i(Yu,"useChatLifecycle");function Mb(e){if(e===void 0)return null;let t=e.conversationId??"",r=e.petRef??"";return t===""&&r===""?null:`${String(t)}|${String(r)}`}i(Mb,"targetKey");function Qu(e,t){let r=Mb(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:s,target:a}=n.current;s===void 0||a===void 0||Promise.resolve(s(a)).catch(()=>{});},[r]);}i(Qu,"useCheckinTarget");function ed(e,t,r){let[n,o]=react.useState({send:e,conversationId:t,text:r??"",seeded:r??null}),s=n.send===e&&(n.conversationId===null||n.conversationId===t);react.useEffect(()=>{o(l=>{let u=l.send===e&&(l.conversationId===null||l.conversationId===t),d=u?l.text:"",c=u?l.seeded:null,p=r!=null&&r!==c&&d.length===0;return {send:e,conversationId:t,text:p?r:d,seeded:p?r:c}});},[e,t,r]);let a=react.useCallback(l=>o(u=>({send:e,conversationId:t,text:l,seeded:u.seeded})),[e,t]);return [s?n.text:"",a]}i(ed,"useChatDraft");function td(e,t,r,n){let o=react.useRef({draft:r,setDraft:n});o.current={draft:r,setDraft:n};let s=react.useRef(null),[a,l]=react.useState(null);react.useEffect(()=>{if(e===void 0)return;let u=`${t??""}`;if(s.current===u)return;s.current=u;let d=true;return (async()=>{let c=await Ht(()=>e.read(t));if(!d)return;let p=c.ok&&typeof c.value=="string"?c.value:"";p.length>0&&o.current.draft.length===0&&o.current.setDraft(p),l(u);})(),()=>{d=false;}},[e,t]),react.useEffect(()=>{e===void 0||a!==`${t??""}`||q(()=>e.write(t,r));},[e,t,r,a]);}i(td,"usePersistedDraft");var Z=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",newChat:"New chat",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 yn(e){let t=e?.replace(/\s+/g," ").trim();return t||Z.untitled}i(yn,"conversationTitle");function nd(e){return `${e.unreadCount!==null&&e.unreadCount>0?Z.unreadPrefix:""}${Z.openConversation} ${yn(e.title)}`}i(nd,"openConversationLabel");function rd(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}i(rd,"normalizeForSearch");function Hb(e,t){let r=rd(t);if(r.length===0)return e;let n=[[],[],[]];for(let o of e){let s=rd(yn(o.title)),a=s.indexOf(r);if(a<0)continue;let l=a===0?0:s.charAt(a-1)===" "?1:2;n[l]?.push(o);}return n.flat()}i(Hb,"filterConversations");function mi(e){return {scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}i(mi,"fresh");function od(e){let[t,r]=react.useState(false),[n,o]=react.useState(""),s=e.listConversations,a=react.useRef(0),[l,u]=react.useState(()=>mi(s)),d=l.scope===s?l:mi(s);react.useEffect(()=>(a.current+=1,r(false),o(""),u(mi(s)),()=>{a.current+=1;}),[s]);let c=react.useCallback(async T=>{let x=++a.current,g=T!==void 0;u(O=>({...O,scope:s,loading:!g,loadingMore:g,error:null}));let _=await e.listConversations(T?{cursor:T}:void 0);if(x===a.current){if(!_.ok){u(O=>({...O,loading:false,loadingMore:false,error:_.error.displayMessage}));return}u(O=>{let M=T&&O.scope===s?O.rows:[],I=new Set(M.map(v=>v.id));return {scope:s,loading:false,loadingMore:false,error:null,rows:[...M,..._.value.conversations.filter(v=>!I.has(v.id))],cursor:_.value.nextCursor===T?null:_.value.nextCursor}});}},[e.listConversations,s]),p=i(()=>{r(true),o(""),c();},"show"),f=i(()=>{a.current+=1,r(false);},"close"),m=i(async T=>{let x=++a.current;u(_=>({..._,loading:true,error:null}));let g=await e.resumeConversation(T);x===a.current&&(u(_=>({..._,loading:false,error:g.ok?null:g.error.displayMessage})),g.ok&&r(false));},"resume"),y=i(async()=>{let T=a.current,x=await e.loadOlderMessages();T===a.current&&!x.ok&&u(g=>({...g,error:x.error.displayMessage}));},"earlier"),k=i(()=>{e.newConversation(),a.current+=1,r(false);},"newConversation"),b=i(()=>{d.cursor===null||d.loading||d.loadingMore||n.trim().length>0||c(d.cursor);},"loadMore"),E=react.useMemo(()=>Hb(d.rows,n),[d.rows,n]),w=n.trim().length>0;return {...d,open:t,show:p,close:f,load:c,resume:m,earlier:y,newConversation:k,loadMore:b,query:n,setQuery:o,searching:w,filtered:E,emptyKind:d.rows.length===0?"empty":"noMatch"}}i(od,"useHistoryPanel");var gn="#111111",hn="#FFFFFF",jb=Object.freeze({emergency:Object.freeze({level:"emergency",label:"Vet care now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:gn,pillColor:hn,showsVetAction:true}),schedule_soon:Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:gn,pillColor:hn,showsVetAction:true}),home_care:Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:gn,pillColor:hn,showsVetAction:false}),general:Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:gn,pillColor:hn,showsVetAction:false})});function Wb(e){return `${e.messageId}:${e.level}:${e.reason??""}`}i(Wb,"urgencySignature");function Gb(e){return K(h.urgencyGeneralReason,{petName:e?.trim()||h.emptyTitlePetFallback})}i(Gb,"generalUrgencyReason");function ad(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:Kb(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:Gb(t)}:null}return null}i(ad,"latestUrgencySource");function Kb(e){return typeof e=="string"&&e.trim().length>0?e:null}i(Kb,"shownReason");function ld(e){let t=e===null?null:Wb(e),[r,n]=react.useState(null),[o,s]=react.useState(false);react.useEffect(()=>s(false),[t]);let l=e!==null&&(o||!(r!==null&&r===t)),u=e===null?null:jb[e.level],d=e!==null&&!l&&e.level!=="general",c=react.useCallback(()=>{t!==null&&n(t),s(false);},[t]),p=react.useCallback(()=>s(true),[]);return react.useMemo(()=>({source:e,tier:u,signature:t,showBanner:l,showCompactIcon:d,showVetAction:l&&u!==null&&u.showsVetAction,dismissLabel:u===null?null:K(h.dismissBanner,{label:u.label}),dismiss:c,expand:p}),[e,u,t,l,d,c,p])}i(ld,"useUrgencySurface");function ud(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}i(ud,"selectView");function qb(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}i(qb,"needsNewConversation");function dd(e){if(e.messages.length===0)return null;let t=e.status==="error"?e.error:null;if(t!==null){let r=qb(t);return {tone:"error",title:r?h.turnUnreachableTitle:h.turnFailedTitle,body:t.displayMessage,actionLabel:r?h.turnStartNewChat:h.turnRetry,action:r?"startNew":"retry"}}return e.stopped===true?{tone:"neutral",title:h.turnStoppedTitle,body:h.turnStoppedBody,actionLabel:h.turnRetry,action:"retry"}:null}i(dd,"turnNotice");function cd(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}i(cd,"awaitingAssistant");var $b=3,Yb=Object.freeze([]);function pd(e){let t=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||t===void 0||t.role!=="assistant")return Yb;let r=new Set,n=[];for(let o of e.suggestedPrompts){let s=o.trim(),a=s.replace(/\s+/g," ").toLowerCase();if(!(a.length===0||r.has(a))&&(r.add(a),n.push(s),n.length===$b))break}return Object.freeze(n)}i(pd,"visibleFollowUps");function fd(e){return e.sender?.displayName??h.senderVet}i(fd,"vetSenderLabel");function md(e,t){let r={};return e!==void 0&&(r.petRef=e),t!==void 0&&(r.conversationId=t),r}i(md,"buildChatOpts");var br=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 hd(e){let t=F(),r=react.useMemo(()=>Zb(t),[t]);return jsxRuntime.jsxs(reactNative.View,{style:[r.container,e.style],accessible:true,accessibilityRole:"text",accessibilityLabel:`${br.title}. ${br.body}`,children:[jsxRuntime.jsx(R,{style:r.title,children:br.title}),jsxRuntime.jsx(R,{style:r.body,children:br.body})]})}i(hd,"ClinicalDisclaimer");function Zb(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:{...S(e,"bold"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.secondary,letterSpacing:n.letterSpacing.eyebrow},body:{...S(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.muted}})}i(Zb,"makeStyles");var se={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function te(e){return {width:e,height:e,alignItems:"center",justifyContent:"center"}}i(te,"box");function pe(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}i(pe,"stroke");function bd({size:e,color:t,strokeWidth:r}){let n=pe(e,r),o={width:e*.82,height:n,borderRadius:n,backgroundColor:t};return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{gap:e*.22}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o})]})}i(bd,"MenuGlyph");function vd({size:e,color:t,strokeWidth:r,rotate:n}){let o=pe(e,r),s=e*.78;return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{transform:[{rotate:n}]}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:s,height:o,borderRadius:o,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:o,height:s,borderRadius:o,backgroundColor:t}})]})}i(vd,"Cross");function Cd(e){return jsxRuntime.jsx(vd,{...e,rotate:"0deg"})}i(Cd,"PlusGlyph");function Et(e){return jsxRuntime.jsx(vd,{...e,rotate:"45deg"})}i(Et,"CloseGlyph");function nt({size:e,color:t,strokeWidth:r}){let n=pe(e,r);return jsxRuntime.jsx(reactNative.View,{style:te(e),...se,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(nt,"CheckGlyph");var tv={down:{rotate:"45deg",marginTop:-0.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-0.4}};function bn({size:e,color:t,strokeWidth:r,direction:n}){let o=pe(e,r),s=e*.46,a=tv[n];return jsxRuntime.jsx(reactNative.View,{style:te(e),...se,children:jsxRuntime.jsx(reactNative.View,{style:{width:s,height:s,borderRightWidth:o,borderBottomWidth:o,borderColor:t,marginTop:s*a.marginTop,marginLeft:s*a.marginLeft,transform:[{rotate:a.rotate}]}})})}i(bn,"ChevronGlyph");function Ed({size:e,color:t,strokeWidth:r}){let n=pe(e,r),o={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{flexDirection:"row",gap:1}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopLeftRadius:e*.2}]}),jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}i(Ed,"BookGlyph");function Rd({size:e,color:t,strokeWidth:r}){let n=pe(e,r),o=e*.5;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,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(Rd,"ArrowUpRightGlyph");function Sd({size:e,color:t,strokeWidth:r}){let n=pe(e,r),o=e*.6,s={position:"absolute",width:o,height:o,borderWidth:n,borderColor:t,borderRadius:e*.14};return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:[s,{top:0,left:0}]}),jsxRuntime.jsx(reactNative.View,{style:[s,{bottom:0,right:0}]})]})}i(Sd,"CopyGlyph");function vn({size:e,color:t,strokeWidth:r,active:n,rotate:o}){let s=pe(e,r),a=n?t:"transparent";return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{transform:[{rotate:o}]}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,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:s,borderColor:t,backgroundColor:a,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:s,borderColor:t,backgroundColor:a,borderRadius:e*.05}})]})}i(vn,"ThumbGlyph");function Td({size:e,color:t,strokeWidth:r}){let n=pe(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...se,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(Td,"InfoGlyph");function Pd({size:e,color:t,strokeWidth:r}){let n=pe(e,r),o=e*.34;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,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(Pd,"UploadGlyph");function kd({size:e,color:t,strokeWidth:r}){let n=pe(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...se,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(kd,"PhotoGlyph");function xd({size:e,color:t,strokeWidth:r}){let n=pe(e,r);return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,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(xd,"CameraGlyph");function _d({size:e,color:t,strokeWidth:r}){let n=pe(e,r),o=e*.66;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,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(_d,"SearchGlyph");function wd({size:e,color:t,strokeWidth:r}){let n=pe(e,r);return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,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(wd,"EditGlyph");function Id({size:e,color:t,strokeWidth:r}){let n=pe(e,r),o=e*.62;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,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(Id,"MapPinGlyph");function Ad({size:e,color:t,testID:r}){let n=e*.36;return jsxRuntime.jsx(reactNative.View,{style:te(e),testID:r,...se,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(Ad,"SendGlyph");function Od({size:e,color:t,testID:r}){return jsxRuntime.jsx(reactNative.View,{style:te(e),testID:r,...se,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}i(Od,"StopGlyph");function Cn({size:e,strokeWidth:t,color:r,children:n}){return jsxRuntime.jsx(reactNative.View,{style:[te(e),{borderRadius:e/2,borderWidth:t??reactNative.StyleSheet.hairlineWidth,borderColor:r}],children:n})}i(Cn,"Ring");var vr=Object.freeze({standard:mt.standard,emphasized:mt.emphasized,exit:mt.exit,outQuad:Object.freeze([.25,.46,.45,.94])});var Fd=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}),rv=Object.freeze({...Fd,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 Md(e){return e.motion.reducedMotion?rv:Fd}i(Md,"chatMotion");function En(e,t){return Math.max(0,t)*e.followUpStaggerMs}i(En,"followUpDelayMs");function Ld(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(Ld,"nextRevealLength");function X(){let e=F();return Md(e)}i(X,"useChatMotion");var lv=8;function Nd(e,t,r){return ((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}i(Nd,"bezierComponent");function uv(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}i(uv,"bezierSlope");function Rn(e){let[t,r,n,o]=e;return s=>{if(s<=0)return 0;if(s>=1)return 1;let a=s;for(let l=0;l<lv;l+=1){let u=uv(a,t,n);if(u===0)break;a-=(Nd(a,t,n)-s)/u;}return Nd(Math.min(1,Math.max(0,a)),r,o)}}i(Rn,"bezierEasing");var yi=Rn(vr.standard),dv=Rn(vr.outQuad);function vi(e){let t=react.useRef(null);return t.current===null&&(t.current=new reactNative.Animated.Value(e)),t.current}i(vi,"useAnimatedValue");function Rt(e,t={}){let r=t.risePx??0,n=t.delayMs??0,o=vi(e>0?0:1);return react.useEffect(()=>{if(e<=0)return;let s=reactNative.Animated.timing(o,{toValue:1,duration:e,easing:dv,useNativeDriver:true}),a=n>0?reactNative.Animated.sequence([reactNative.Animated.delay(n),s]):s;return a.start(),()=>a.stop()},[o,e,n]),react.useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[o,r])}i(Rt,"useFadeIn");function Ci({visible:e,inMs:t,outMs:r,style:n,children:o}){let[s,a]=react.useState(e),l=vi(e&&t<=0?1:0);return react.useEffect(()=>{if(e){a(true);let d=reactNative.Animated.timing(l,{toValue:1,duration:Math.max(0,t),easing:yi,useNativeDriver:true});return d.start(),()=>d.stop()}if(!s)return;if(r<=0){a(false);return}let u=reactNative.Animated.timing(l,{toValue:0,duration:r,easing:yi,useNativeDriver:true});return u.start(({finished:d})=>{d&&a(false);}),()=>u.stop()},[e,s,t,r,l]),!s&&!e?null:jsxRuntime.jsx(reactNative.Animated.View,{style:[n,{opacity:l}],children:o})}i(Ci,"FadePresence");var cv=12;function B({style:e,containerStyle:t,children:r,onPressIn:n,onPressOut:o,hitSlop:s,...a}){let l=X(),u=vi(1),d=react.useCallback(c=>{l.pressMs<=0||l.pressScale===1||reactNative.Animated.timing(u,{toValue:c,duration:l.pressMs,easing:yi,useNativeDriver:true}).start();},[u,l.pressMs,l.pressScale]);return jsxRuntime.jsx(reactNative.Pressable,{...a,hitSlop:s??cv,style:t,onPressIn:c=>{d(l.pressScale),n?.(c);},onPressOut:c=>{d(1),o?.(c);},children:jsxRuntime.jsx(reactNative.Animated.View,{style:[e,{transform:[{scale:u}]}],children:r})})}i(B,"PressScale");function Hd(e,t,r){let n=t&&r.revealTickMs>0,[o,s]=react.useState(0),a=react.useRef(e);return a.current=e,react.useEffect(()=>{if(!n)return;let l=setInterval(()=>{s(u=>Ld(r,u,a.current.length));},r.revealTickMs);return ()=>clearInterval(l)},[n,r]),n?e.slice(0,Math.min(o,e.length)):e}i(Hd,"useRevealedText");var Ud=false;function pv(e){e.layoutMs<=0||(Ud||(Ud=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(pv,"animateLayout");function Cr(e,t){let r=react.useRef(e);r.current!==e&&(r.current=e,pv(t));}i(Cr,"useAnimateLayoutOn");var Ei=36,vv=22,Cv=12,Ev=12,Rv=16,Sv="#000",Tv="rgba(0,0,0,0.45)";function Bd({uri:e,label:t,onClose:r}){let n=F(),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:h.closePreview,style:Sn.backdrop,onPress:r,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:Sn.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),jsxRuntime.jsx(reactNative.View,{pointerEvents:"box-none",style:[Sn.closeWrap,{top:o.top+Ev}],children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.closePreview,hitSlop:Cv,style:Sn.closeButton,onPress:r,children:jsxRuntime.jsx(Et,{size:vv,color:n.color.surface,strokeWidth:2})})})]})}i(Bd,"AttachmentImageLightbox");var Sn=reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:Sv,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:Rv},closeButton:{width:Ei,height:Ei,borderRadius:Ei/2,backgroundColor:Tv,alignItems:"center",justifyContent:"center"}});var Tn=12,wv=80,Ri=44,zd=22,Iv=.14,Av=18,Ov=8,jd=Object.freeze({photo:h.attachmentPhoto,camera:h.attachmentCamera});function Wd({sources:e,full:t,onPick:r,onClose:n}){let o=F(),s=react.useMemo(()=>Fv(o),[o]);return jsxRuntime.jsxs(reactNative.View,{style:s.anchor,pointerEvents:"box-none",children:[jsxRuntime.jsx(reactNative.Pressable,{style:s.dismissLayer,accessibilityRole:"button",accessibilityLabel:h.closeAttachmentPicker,onPress:n}),jsxRuntime.jsxs(reactNative.View,{style:s.bubble,children:[jsxRuntime.jsx(reactNative.View,{style:s.tilesRow,children:e.map(a=>jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:jd[a],accessibilityState:{disabled:t},disabled:t,containerStyle:s.tile,style:s.tileInner,onPress:()=>r(a),children:[jsxRuntime.jsx(reactNative.View,{style:s.tileIconWrap,children:a==="photo"?jsxRuntime.jsx(kd,{size:zd,color:o.color.brandInk,strokeWidth:1.5}):jsxRuntime.jsx(xd,{size:zd,color:o.color.brandInk,strokeWidth:1.5})}),jsxRuntime.jsx(R,{tier:"control",style:s.tileLabel,children:jd[a]})]},a))}),jsxRuntime.jsx(reactNative.View,{style:s.tail}),jsxRuntime.jsx(reactNative.View,{style:s.tailFill})]})]})}i(Wd,"AttachmentPickerPopover");function Fv(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:Iv,shadowRadius:Av,shadowOffset:{width:0,height:Ov},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:wv,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:Ri,height:Ri,borderRadius:Ri/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...S(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-Tn/2,width:Tn,height:Tn,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:Tn+4,height:2,backgroundColor:t.surfaceCream}})}i(Fv,"makeStyles");var Te=Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var Kd=56,qd=12,Dv=14,Nv=10,Uv=.45,Vv="rgba(7,193,104,0.55)",Hv="rgba(185,28,28,0.55)",Bv=200,zv=300,tc=20,Ti=22,jv=12,Wv="rgba(0,0,0,0.78)",$d=220,Yd=100,Xd="rgba(255,255,255,0.15)";function rc({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:o,onPreview:s}){let a=F(),l=react.useMemo(()=>oc(a),[a]);return e.length===0&&t===null?null:jsxRuntime.jsxs(reactNative.View,{style:l.strip,children:[e.length>0?jsxRuntime.jsx(reactNative.View,{style:l.cards,children:e.map(u=>jsxRuntime.jsx(Gv,{row:u,styles:l,onRetry:n,onRemove:o,onPreview:s},u.id))}):null,r?jsxRuntime.jsx(R,{style:l.rejected,accessibilityRole:"alert",children:h.attachmentsFailedBlocked}):null,t!==null?jsxRuntime.jsx(R,{style:l.rejected,accessibilityRole:"alert",children:Lu(t)}):null]})}i(rc,"AttachmentStrip");function Gv({row:e,styles:t,onRetry:r,onRemove:n,onPreview:o}){let s=F(),a=e.status==="uploading",l=e.status==="failed",u=e.status==="uploaded",d=react.useRef(e.status),[c,p]=react.useState(false);return react.useEffect(()=>{let f=d.current;d.current=e.status,e.status==="uploaded"&&f==="uploading"&&p(true);},[e.status]),jsxRuntime.jsxs(reactNative.View,{style:t.card,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:u?"button":"image",accessibilityLabel:u?K(h.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:a,disabled:!u},disabled:!u,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}),a?jsxRuntime.jsx(reactNative.View,{style:t.uploadingOverlay,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:s.color.surface})}):null,c?jsxRuntime.jsx(Kv,{styles:t,onDone:()=>p(false)}):null]})}),l?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K(h.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:jsxRuntime.jsx(reactNative.View,{style:t.failedInner,children:jsxRuntime.jsx(Et,{size:tc,color:s.color.surface,strokeWidth:2})})}):null,jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:K(h.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:jsxRuntime.jsx(Et,{size:jv,color:s.color.surface,strokeWidth:1.5})})]})}i(Gv,"PreviewCard");function Kv({styles:e,onDone:t}){let r=F(),n=X(),o=react.useRef(null);o.current===null&&(o.current=new reactNative.Animated.Value(0));let s=o.current;return react.useEffect(()=>{let a=reactNative.Animated.sequence([reactNative.Animated.timing(s,{toValue:1,duration:Bv,useNativeDriver:true}),reactNative.Animated.delay(n.uploadFlashMs),reactNative.Animated.timing(s,{toValue:0,duration:zv,useNativeDriver:true})]);return a.start(({finished:l})=>{l&&t();}),()=>a.stop()},[s,n.uploadFlashMs,t]),jsxRuntime.jsx(reactNative.Animated.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:s}],children:jsxRuntime.jsx(nt,{size:tc,color:r.color.surface,strokeWidth:2})})}i(Kv,"SuccessFlash");function nc({images:e,onPreview:t}){let r=F(),n=react.useMemo(()=>oc(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((s,a)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K(h.attachedImage,{filename:s.filename}),onPress:()=>t(s),children:jsxRuntime.jsx(reactNative.Image,{source:{uri:s.uri},style:o?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${s.uri}-${a}`))})}i(nc,"SentImages");function oc(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:Kd,height:Kd,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:qd,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...Te,alignItems:"center",justifyContent:"center",backgroundColor:pl(e.color.brandInk,Uv)??e.color.brandSofter},successOverlay:{...Te,alignItems:"center",justifyContent:"center",backgroundColor:Vv},failedOverlay:{...Te,borderRadius:qd,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:Hv},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:Ti,height:Ti,borderRadius:Ti/2,backgroundColor:Wv,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...S(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:$d,height:$d,borderRadius:Dv,backgroundColor:Xd},gridImage:{width:Yd,height:Yd,borderRadius:Nv,backgroundColor:Xd}})}i(oc,"makeStyles");var qv="chat attachment upload: the file handle has no uri",$v="chat attachment upload failed";function Yv(e){return {uri:e.uri,name:So(e.name),type:e.mimeType}}i(Yv,"filePartOf");function ic(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(qv));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error($v)),"failed");return o?.aborted===true?a():Br({url:t.upload_url,fields:t.upload_fields,file:Yv(r),signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(ic,"createRnChatAttachmentTransport");function Pn(){let{runtime:e,userRef:t,activePet:r,scopeEpoch:n}=Y(),o=react.useMemo(()=>Je(e.registry.services.authFor(t)),[e,t,n]),[s,a]=react.useState({repository:o,pets:[],loading:true,error:null}),l=s.repository===o?s:{pets:[],loading:true,error:null},u=react.useRef(0),d=react.useCallback(async()=>{let p=++u.current;a(m=>({...m,repository:o,loading:true,error:null,pets:m.repository===o?m.pets:[]}));let f=await o.list();p===u.current&&a(f.ok?{repository:o,pets:f.value,loading:false,error:null}:m=>({repository:o,pets:m.repository===o?m.pets:[],loading:false,error:f.error}));},[o]);react.useEffect(()=>(d(),()=>{u.current+=1;}),[d]);let c=react.useMemo(()=>r===null?null:l.pets.find(p=>p.petRef===r)??null,[r,l.pets]);return react.useMemo(()=>({pets:l.pets,activePet:c,loading:l.loading,error:l.error,refresh:d}),[l.pets,l.loading,l.error,c,d])}i(Pn,"useEverfurPets");function sc(e,t){if(t!==null){let r=e.find(n=>n.petRef===t);if(r!==void 0)return r}return e[0]??null}i(sc,"headerPetOf");function de(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(de,"slotBox");function _i(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}i(_i,"ownGroundSlot");function Ce(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(Ce,"slotText");var ac=Object.freeze({visitButton:"Talk to a vet"});var lc=Symbol.for("@everfur/sdk/televet");function Ke(){let e=globalThis,t=e[lc];if(t!==void 0)return t;let r={presenter:null,snapshot:Object.freeze({request:null,serial:0,activeHost:null}),hosts:[],nextHost:1,listeners:new Set,dailyRegistered:false};return e[lc]=r,r}i(Ke,"televetGlobal");function kn(e){let t=Ke();t.snapshot=Object.freeze({...t.snapshot,...e});for(let r of [...t.listeners])try{r();}catch{}}i(kn,"publish");function uc(e){let t=Ke().presenter;if(t===null)return "absent";try{return t(e)===!1?"declined":"presented"}catch(r){return console.warn("[everfur] Your registerEverfurTelevetFlow presenter threw; the in-app visit opened instead.",r),"threw"}}i(uc,"callTelevetPresenter");function dc(e){let t=Ke();return t.listeners.add(e),()=>{t.listeners.delete(e);}}i(dc,"subscribeTelevetExperience");function wi(){return Ke().snapshot}i(wi,"televetExperienceSnapshot");function eC(){return Ke().hosts.length>0}i(eC,"hasTelevetHost");function cc(e){if(!eC())return false;let t=Object.freeze({...e});return kn({request:t,serial:Ke().snapshot.serial+1}),true}i(cc,"presentTelevetExperience");function Ii(){Ke().snapshot.request!==null&&kn({request:null});}i(Ii,"dismissTelevetExperience");function pc(){let e=Ke(),t=e.nextHost;return e.nextHost+=1,e.hosts=[...e.hosts,t],kn({activeHost:e.hosts[0]??null}),t}i(pc,"claimTelevetHost");function fc(e){let t=Ke();t.hosts=t.hosts.filter(n=>n!==e);let r=t.hosts[0]??null;kn(r===null?{activeHost:r,request:null}:{activeHost:r});}i(fc,"releaseTelevetHost");var mc=false;function xn(e,t){return t!==void 0?(q(t,e),"onStartInApp"):uc(e)==="presented"?"presenter":cc(e)?"experience":(mc||(mc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}i(xn,"openVetVisitInApp");function hc(e){let t=null;return ()=>{if(t!==null)return t;let r=e();return t=r,r.then(void 0,()=>{t===r&&(t=null);}),r}}i(hc,"memoizeTelevetLoader");function bc(e){let[t,r]=react.useState(null);react.useEffect(()=>{let d=pc();return r(d),()=>{fc(d);}},[]);let n=react.useSyncExternalStore(dc,wi,wi),s=t!==null&&n.activeHost===t?n.request:null,[a,l]=react.useState(null),u=s!==null&&a===null;return react.useEffect(()=>{if(!u)return;let d=true;return e().then(c=>{d&&l(()=>c);},c=>{d&&(console.warn("[everfur] The in-app vet visit could not load its screens.",c),Ii());}),()=>{d=false;}},[u,e]),s===null||a===null?null:{module:a,request:s,serial:n.serial,dismiss:Ii}}i(bc,"useTelevetExperienceHost");var rC=hc(()=>import('@everfur/sdk/televet/booking'));function Rr(){let e=bc(rC);if(e===null)return null;let{EverfurTelevetModal:t}=e.module;return jsxRuntime.jsx(t,{request:e.request,onClose:e.dismiss},e.serial)}i(Rr,"EverfurTelevetHost");var Ai=Object.freeze(["visit","join","summary","messages"]);function Oi(e){return typeof e=="string"&&Ai.includes(e)}i(Oi,"isVetVisitIntent");var oC="/widget/v1/televet/handoffs",iC="/widget/v1/televet/availability",sC="/widget/v1/televet/chat-entry",aC=/^[a-z0-9][a-z0-9_-]{0,39}$/,lC=/^[A-Za-z0-9_-]{22}$/;var vc=32,Cc=128,Ec=64;function Mi(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(Mi,"vetVisitErrorReasonOf");function Rc(e){return C(D("validationFailed",{retryable:false,wireMessage:e}))}i(Rc,"invalid");function Fi(e){return C(D("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}i(Fi,"unusable");function uC(e,t){let r={};e!==void 0&&(r.pet_ref=e);let n=t?.returnTo;if(n!=null){if(typeof n!="string"||!aC.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 s=t?.visitRef,a=t?.intent,l=s!=null;if(l){let u=typeof s=="string"?s.trim():"";if(u.length<1||[...u].length>Ec)return {ok:false,message:`visitRef must be 1..${Ec} characters`};r.visit_ref=u;}if(a!=null){if(!l)return {ok:false,message:"intent needs the visitRef it opens"};if(!Oi(a))return {ok:false,message:`intent must be one of ${Ai.join(", ")}`};r.intent=a;}return {ok:true,body:r}}i(uC,"handoffBody");function dC(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!Oi(r)?null:Object.freeze({visitRef:t,intent:r})}i(dC,"parseVisitEcho");function Tc(e){let t=e.funnel??_e({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=i(o=>(Sc(r,"televet.visit.handoff_failed",{reason:Mi(o)}),C(o)),"failed");return {async createHandoff(o,s){let a;if(o!=null){let b=typeof o=="string"?[...o].length:0;if(b<1||b>Cc)return n(D("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${Cc} characters`}));a=o;}let l=uC(a,s);if(!l.ok){let b=Rc(l.message);return b.ok?b:n(b.error)}let u=l.body,d=await t.send("televet.visit.handoff",{method:"POST",path:oC,body:u},{idempotent:false,maxAttempts:1});if(!d.ok)return n(d.error);let c=cC(d.value),p=u.return_to!==void 0,f=p?d.value?.flow_id:void 0;if(p&&(typeof f!="string"||!lC.test(f))){let b=Fi("the handoff response carried no usable return flow id");return b.ok?b:n(b.error)}let m=u.visit_ref!==void 0,y=m?dC(d.value?.visit):null;if(m&&y===null){let b=Fi("the handoff response did not confirm the visit it opens");return b.ok?b:n(b.error)}let k=c===null?null:Object.freeze({...c,...p?{flowId:f}:{},...y!==null?{visit:y}:{}});return k===null?n(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Sc(r,"televet.visit.handoff_created",{pet_scoped:u.pet_ref!==void 0}),L(k))},async checkAvailability(o){if(typeof o!="string"||o.length>vc)return Rc(`state must be at most ${vc} characters`);let s=await t.send("televet.visit.availability",{method:"POST",path:iC,body:{state:o}},{idempotent:false,maxAttempts:1});if(!s.ok)return C(s.error);let a=s.value?.available;return typeof a!="boolean"?Fi("the availability response carried no usable answer"):L(Object.freeze({available:a}))},async chatEntryOpen(){try{let o=await t.send("televet.visit.chat_entry",{method:"GET",path:sC},{maxAttempts:1});return o.ok&&o.value?.open===!0}catch{return false}}}}i(Tc,"createVetVisitController");function cC(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||!yC(t)?null:Object.freeze({url:t,expiresAt:r})}i(cC,"parseHandoff");var pC=new Set(["localhost","127.0.0.1","[::1]"]),fC=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,mC=/[\s\u0000-\u001f\u007f]/;function yC(e){if(mC.test(e))return false;let t=fC.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(),s=r==="https",a=r==="http"&&pC.has(o);if(!s&&!a)return false;let l=e.indexOf("#");if(l<0)return false;let u=e.slice(l);return u.startsWith("#h=")&&u.length>3}i(yC,"isOpenableVisitUrl");function Sc(e,t,r){if(e)try{e.track(t,r);}catch{}}i(Sc,"safeTrack");var Li=Object.freeze({status:"idle",error:null,errorReason:null});function hC(e,t,r){let{usState:n,chat:o,scope:s}=r,a=t&&(n!==null||o),l=`${n??""}|${o?"chat":""}`,[u,d]=react.useState(null);if(react.useEffect(()=>{if(!a)return;let p=true,f=e.current;return d(null),i(async()=>{try{if(o&&!(f.chatEntryOpen&&await f.chatEntryOpen()))return !1;if(n===null)return !0;if(!f.checkAvailability)return !1;let y=await f.checkAvailability(n);return y.ok&&y.value.available}catch{return false}},"ask")().then(y=>{p&&d({key:l,open:y});}),()=>{p=false;}},[a,l,n,o,s,e]),!a)return null;let c=u!==null&&u.key===l;return {open:c&&u.open,pending:!c}}i(hC,"usePreflight");var bC=Object.freeze({status:"opening",error:null,errorReason:null});function xc(e,t={}){let{runtime:r,userRef:n,scopeEpoch:o}=Y(),s=Nt("televet"),a=s.enabled&&n!==null,l=t.usState??null,u=t.entry==="chat",d=t.petRef??null,c=t.prefer==="redirect",p=react.useMemo(()=>{if(t.controller)return t.controller;let{services:P}=r.registry;return Tc({auth:P.authFor(n),telemetry:P.telemetry,...P.errorPolicy?{errorPolicy:P.errorPolicy}:{}})},[r,n,o,t.controller]),f=react.useRef(p);f.current=p;let m=react.useMemo(()=>({runtime:r,userRef:n,scopeEpoch:o}),[r,n,o]),y=hC(f,a,{usState:l,chat:u,scope:m}),k=a&&(y===null||y.open)&&(!u||d!==null),b=t.returnTo??null,[E,w]=react.useState(Li),T=react.useRef(null),x=react.useRef({runtime:r,userRef:n,scopeEpoch:o});x.current={runtime:r,userRef:n,scopeEpoch:o};let g=react.useRef(p);g.current=p;let _=react.useRef(k);_.current=k;let O=react.useCallback((P,V)=>{if(T.current)return T.current;let j=i((fe,Qe)=>(w({status:fe==="cancelled"?"idle":"error",error:Qe,errorReason:fe==="cancelled"?null:fe}),Object.freeze({opened:false,reason:fe,error:Qe})),"fail");if(!_.current)return Promise.resolve(j("unavailable",null));let W=e.prepare();if(!W.ok)return Promise.resolve(j(W.reason,null));let ne=x.current,he=g.current;w(bC);let st=(async()=>{let fe,Qe={...b!==null?{returnTo:b}:{},...u?{entry:"chat"}:{},...V!==null?{visitRef:V.visitRef}:{},...V!==null&&V.intent!==null&&V.intent!==void 0?{intent:V.intent}:{}},Ar=Object.keys(Qe).length===0?void 0:Qe,Or=P===void 0?d:P;try{fe=await(Ar===void 0?he.createHandoff(Or):he.createHandoff(Or,Ar));}catch{return e.abandon(W.value),j("unknown",null)}let It=x.current;if(It.runtime!==ne.runtime||It.userRef!==ne.userRef||It.scopeEpoch!==ne.scopeEpoch)return e.abandon(W.value),j("cancelled",null);if(!fe.ok)return e.abandon(W.value),j(Mi(fe.error),fe.error);let Xt=await e.finish(W.value,fe.value);return Xt!==null?j(Xt,null):(w(Li),Object.freeze(fe.value.flowId===void 0?{opened:true}:{opened:true,flowId:fe.value.flowId}))})().finally(()=>{T.current===st&&(T.current=null);});return T.current=st,st},[e,d,b,u]),M=react.useCallback((P,V)=>{if(!_.current)return w({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}));let j=P===void 0?d:P,W={...j!==null?{petRef:j}:{},...l!==null?{usState:l}:{},...V!==null?{visitRef:V.visitRef,intent:V.intent}:{}};return xn(W)===null?(w({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}))):(w(Li),Promise.resolve(Object.freeze({opened:true})))},[d,l]),I=react.useCallback(P=>c?O(P,null):M(P,null),[c,O,M]),v=react.useCallback((P,V)=>c?O(void 0,{visitRef:P,intent:V??null}):M(void 0,{visitRef:P,intent:V??null}),[c,O,M]);return {available:k,isPending:s.isPending||(y?.pending??false),status:E.status,error:E.error,errorReason:E.errorReason,open:I,openVisit:v}}i(xc,"useVetVisitWith");var EC=i(e=>reactNative.Linking.openURL(e),"defaultOpenUrl");function wn(e={}){let{openUrl:t,...r}=e,n=react.useMemo(()=>{let o=t??EC;return {prepare:i(()=>({ok:true,value:null}),"prepare"),async finish(s,a){try{return await o(a.url),null}catch{return "openFailed"}},abandon:i(()=>{},"abandon")}},[t]);return xc(n,r)}i(wn,"useVetVisit");var _c=44,kC=.6;function jt(e){let{petRef:t,label:r,openUrl:n,onOpened:o,onError:s,style:a,labelStyle:l,controller:u,returnTo:d,usState:c,entry:p,visitRef:f,intent:m,onStartInApp:y,prefer:k}=e,b=k==="redirect",E=wn({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...t!==void 0?{petRef:t}:{},...n!==void 0?{openUrl:n}:{},...u!==void 0?{controller:u}:{},prefer:b?"redirect":"in-app"}),w=F(),T=react.useMemo(()=>xC(w),[w]),x=react.useRef(false);if(!E.available)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[null,jsxRuntime.jsx(Rr,{})]});let g=E.status==="opening",_=r??ac.visitButton;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.Pressable,{onPress:i(()=>{if(!(g||x.current)){if(!b){let M={...t!==void 0?{petRef:t}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:m??null}:{}};xn(M,y)===null&&q(s,"unavailable",null);return}x.current=true,(f==null?E.open():E.openVisit(f,m??null)).then(M=>{M.opened?q(o,M.flowId??null):M.reason!=="cancelled"&&q(s,M.reason,M.error);}).finally(()=>{x.current=false;});}},"onPress"),accessibilityRole:"button",accessibilityLabel:_,accessibilityState:{busy:g,disabled:g},style:[T.button,g?T.busy:null,a],children:jsxRuntime.jsx(R,{style:[T.label,l],children:_})}),jsxRuntime.jsx(Rr,{})]})}i(jt,"VetVisitButton");function xC(e){let{color:t,space:r,radius:n,type:o,slots:s}=e;return reactNative.StyleSheet.create({button:{minHeight:_c,minWidth:_c,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...de(s.vetVisitButton)},busy:{opacity:kC},label:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug,...Ce(s.vetVisitButton)}})}i(xC,"makeStyles");function Di(e){return ur(e)==="cat"?"cat":"dog"}i(Di,"speciesOf");function Ni(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}i(Ni,"petAgeYears");function Oc(e){let t=Ni(e.ageYears),r=Di(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return `${r} \xB7 ${n}`}i(Oc,"formatPetMeta");var Ac=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 _C(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return Ac[t%Ac.length]}i(_C,"pickInitialsPalette");function Ui(e){let t=(e??"").trim();return (Array.from(t)[0]??"?").toUpperCase()}i(Ui,"getInitial");function Fc(e){return {..._C(e.petRef),initial:Ui(e.name)}}i(Fc,"petInitials");function OC(e){return Math.max(12,Math.round(e*.42))}i(OC,"letterSize");function Tr({pet:e,size:t,ringStroke:r}){let n=F(),o=react.useMemo(()=>FC(n),[n]),s=t-r*2,a=e===null?null:Fc(e),l=OC(s);return jsxRuntime.jsx(Cn,{size:t,strokeWidth:r,color:n.color.success,children:jsxRuntime.jsx(reactNative.View,{style:[o.disc,{width:s,height:s,borderRadius:s/2},a===null?o.discEmpty:{backgroundColor:a.background}],children:jsxRuntime.jsx(R,{tier:"badge",style:[o.letter,{fontSize:l,lineHeight:Math.round(l*1.2),color:a===null?n.color.text.muted:a.foreground}],children:a===null?Ui(null):a.initial})})})}i(Tr,"PetDisc");function FC(e){return reactNative.StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...S(e,"bold"),textAlign:"center",includeFontPadding:false}})}i(FC,"makeStyles");var Hi=48,Dc=2,VC=320,HC="80%",BC="rgba(17,17,17,0.45)",zC=18,Mc=22,jC=12,Lc=.4,WC=44;function Bi(e){return e?.name?.trim()||h.yourPet}i(Bi,"petDisplayName");function Nc({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:o=null,onClose:s}){let a=F(),l=react.useMemo(()=>GC(a),[a]);return e?jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:s,children:jsxRuntime.jsxs(reactNative.View,{style:l.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:Te,onPress:s,accessibilityRole:"button",accessibilityLabel:h.close,children:jsxRuntime.jsx(reactNative.View,{style:l.backdrop})}),jsxRuntime.jsxs(reactNative.View,{style:l.panel,accessibilityViewIsModal:true,children:[jsxRuntime.jsx(R,{tier:"heading",style:l.title,accessibilityRole:"header",children:h.yourPets}),jsxRuntime.jsx(reactNative.ScrollView,{style:l.list,contentContainerStyle:l.listContent,showsVerticalScrollIndicator:true,children:t.map(u=>{let d=u.petRef===r,c=Bi(u),p=Oc(u);return jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:K(d?h.petCurrentlyActive:h.switchToPet,{name:c}),accessibilityState:{selected:d},style:[l.row,d?l.rowActive:null],onPress:()=>n(u.petRef),children:[jsxRuntime.jsx(Tr,{pet:u,size:Hi,ringStroke:Dc}),jsxRuntime.jsxs(reactNative.View,{style:l.copy,children:[jsxRuntime.jsx(R,{style:l.name,numberOfLines:1,children:c}),jsxRuntime.jsx(R,{tier:"compact",style:l.meta,numberOfLines:1,children:d?`${h.activePrefix}${p}`:p})]}),d?jsxRuntime.jsx(nt,{size:zC,color:a.color.brandInk}):null]},u.petRef)})}),o!==null?jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:h.addAnotherPet,style:l.addRow,onPress:o,children:[jsxRuntime.jsx(reactNative.View,{style:l.addDisc,children:jsxRuntime.jsx(R,{tier:"control",style:l.addPlus,children:"+"})}),jsxRuntime.jsx(R,{style:l.addLabel,children:h.addAnotherPet})]}):null,jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.close,containerStyle:l.closeSlot,style:l.closeButton,onPress:s,children:jsxRuntime.jsx(R,{tier:"control",style:l.closeText,children:h.close})})]})]})}):null}i(Nc,"PetSwitcherSheet");function GC(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:BC},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:Mc,borderTopRightRadius:Mc,gap:14,maxHeight:HC},title:{...S(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk},list:{maxHeight:VC,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:WC,paddingHorizontal:8},addDisc:{width:Hi,height:Hi,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:Dc,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...S(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...S(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:{...S(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...S(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:Lc},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:jC,backgroundColor:t.brandSoft},closeText:{...S(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:Lc}})}i(GC,"makeStyles");var $C=44,An=36,YC=22,zi=9,XC=1.5,Vc=6,Tt=35,On=1.75,ji=12.4,QC=.5,ZC=8,JC=28,eE=160;function Gi(e,t){return sc(e,t)}i(Gi,"headerPet");function Bc({pets:e,petRef:t,historyUnread:r,onOpenHistory:n,onPetChange:o,onAddPet:s,vet:a}){let l=F(),u=react.useMemo(()=>rE(l),[l]),[d,c]=react.useState(false),p=Gi(e.pets,t),f=e.pets.length>=2,m=t??p?.petRef??null,y=Bi(p),k=i(E=>{c(false),e.setActivePet(E),q(o,E);},"select"),b=s===void 0?null:()=>{c(false),q(s);};return jsxRuntime.jsxs(reactNative.View,{style:u.row,children:[jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:r?h.openMenuUnread:h.openMenu,containerStyle:u.iconSlot,style:u.iconButton,onPress:n,children:[jsxRuntime.jsx(bd,{size:YC,color:l.color.text.primary,strokeWidth:2}),r?jsxRuntime.jsx(reactNative.View,{style:u.unreadDot,pointerEvents:"none"}):null]}),jsxRuntime.jsx(reactNative.View,{style:u.center,pointerEvents:"box-none",children:jsxRuntime.jsx(tE,{logoUrl:l.meta.logoUrl,name:l.meta.displayName,styles:u})}),m===null?null:jsxRuntime.jsx(jt,{entry:"chat",petRef:m,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:u.vetEntry,labelStyle:u.vetEntryLabel}),jsxRuntime.jsx(reactNative.View,{style:u.right,children:f?jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:K(h.switchActivePet,{name:y}),containerStyle:u.avatarSlot,style:u.avatarWrap,onPress:()=>c(true),children:[jsxRuntime.jsx(Tr,{pet:p,size:Tt,ringStroke:On}),jsxRuntime.jsx(reactNative.View,{style:u.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:jsxRuntime.jsx(Cd,{size:ZC,color:l.color.brandInk,strokeWidth:2})})]}):e.loading&&p===null?jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityLabel:h.yourPet,children:jsxRuntime.jsx(Cn,{size:Tt,strokeWidth:On,color:l.color.success,children:jsxRuntime.jsx(reactNative.View,{style:u.placeholderDisc})})}):jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:p===null?h.yourPet:y,children:jsxRuntime.jsx(Tr,{pet:p,size:Tt,ringStroke:On})})}),jsxRuntime.jsx(Nc,{visible:d,pets:e.pets,activePetRef:p?.petRef??null,onSelect:k,onAddPet:b,onClose:()=>c(false)})]})}i(Bc,"ChatHeader");function tE({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(tE,"BrandLogo");function rE(e){let t=e.color,r=Tt-On*2;return reactNative.StyleSheet.create({vetEntry:{minHeight:$C,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},vetEntryLabel:{...S(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:An/2},iconButton:{width:An,height:An,borderRadius:An/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:Vc,right:Vc,width:zi,height:zi,borderRadius:zi,backgroundColor:t.danger,borderWidth:XC,borderColor:t.surface},center:{...Te,alignItems:"center",justifyContent:"center"},logoBar:{alignItems:"center",paddingHorizontal:e.space.lg},logo:{height:JC,width:eE},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:Tt/2},avatarWrap:{width:Tt,height:Tt,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:ji,height:ji,borderRadius:ji/2,borderWidth:QC,borderColor:t.success,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}i(rE,"makeStyles");var Wc=44,aE="rgba(17,17,17,0.55)",Gc=26,lE=36,Kc=4,Ki=20,qi=38,uE=18,dE=12;function qc({visible:e,onSubmit:t,onSkip:r}){let n=F(),o=react.useMemo(()=>cE(n),[n]),[s,a]=react.useState(null),[l,u]=react.useState(""),[d,c]=react.useState(false),[p,f]=react.useState(false),m=i(()=>{a(null),u(""),c(false),f(false);},"reset"),y=i(()=>{d||(m(),r());},"skip"),k=i(async()=>{if(d)return;c(true),f(false);let E=l.trim();await t(s,E.length>0?E:null)?m():(c(false),f(true));},"submit");if(!e)return null;let b=[...l].length>Mt;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:n.motion.reducedMotion?"none":"slide",onRequestClose:y,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:y,accessibilityRole:"button",accessibilityLabel:h.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(vn,{size:uE,color:n.color.brandInk,active:false,rotate:"180deg"})}),jsxRuntime.jsxs(reactNative.View,{style:o.headerText,children:[jsxRuntime.jsx(R,{tier:"heading",style:o.title,accessibilityRole:"header",children:h.feedbackTitle}),jsxRuntime.jsx(R,{style:o.subtitle,children:h.feedbackSubtitle})]})]}),jsxRuntime.jsx(reactNative.View,{style:o.options,children:ni.map(E=>{let w=s===E.key;return jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:E.label,accessibilityState:{selected:w},style:[o.option,w?o.optionSelected:null],onPress:()=>a(T=>T===E.key?null:E.key),children:[jsxRuntime.jsx(R,{style:[o.optionLabel,w?o.optionLabelSelected:null],children:E.label}),jsxRuntime.jsx(reactNative.View,{style:[o.radio,w?o.radioSelected:null],children:w?jsxRuntime.jsx(nt,{size:dE,color:n.color.surface,strokeWidth:2}):null})]},E.key)})}),jsxRuntime.jsxs(reactNative.View,{style:o.inputWrap,children:[jsxRuntime.jsx(Ut,{style:o.input,placeholder:h.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:h.feedbackNotesPlaceholder,value:l,onChangeText:u,multiline:true,editable:!d}),l.length>0?jsxRuntime.jsx(R,{tier:"compact",style:[o.counter,b?o.counterOver:null],children:`${[...l].length}/${Mt}`}):null]}),p?jsxRuntime.jsx(R,{style:o.failed,accessibilityRole:"alert",children:h.feedbackFailed}):null,jsxRuntime.jsxs(reactNative.View,{style:o.actions,children:[jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.feedbackSubmit,accessibilityState:{busy:d,disabled:d||b},disabled:d||b,style:[o.submit,d||b?o.submitDisabled:null],onPress:()=>{k();},children:jsxRuntime.jsx(R,{tier:"control",style:o.submitLabel,children:h.feedbackSubmit})}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:h.feedbackSkipA11y,hitSlop:8,onPress:y,style:o.skip,children:jsxRuntime.jsx(R,{tier:"control",style:o.skipLabel,children:h.feedbackSkip})})]})]})]})})}i(qc,"FeedbackReasons");function cE(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:{...Te,backgroundColor:aE},sheet:{backgroundColor:t.surface,borderTopLeftRadius:Gc,borderTopRightRadius:Gc,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14},handle:{alignSelf:"center",width:lE,height:Kc,borderRadius:Kc/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:qi,height:qi,borderRadius:qi/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...S(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight},subtitle:{...S(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:{...S(e,"medium"),fontSize:r.size.body,color:t.text.primary},optionLabelSelected:{color:t.brandInk},radio:{width:Ki,height:Ki,borderRadius:Ki/2,borderWidth:2,borderColor:t.brandBorderStrong,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...S(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top"},counter:{...S(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...S(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:Wc,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...de(o.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...S(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...Ce(o.primaryButton)},skip:{minHeight:Wc,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...S(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}i(cE,"makeStyles");var kE=.88,xE=420,_E=58,wE="rgba(17,17,17,0.28)",IE=.08,AE=.1,OE=.08,FE=.18,ME=.78,LE=.7,$i=36,DE=10,NE=14,UE=12,VE=16,HE=14,Yi=8,BE=1.5,zE=.5,jE=Rn(vr.standard);function WE(e){return Math.min(Math.round(e*kE),xE)}i(WE,"drawerPanelWidth");function $c({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(GE,{chat:e,history:t,onHidden:o}):null}i($c,"HistoryDrawer");function GE({chat:e,history:t,onHidden:r}){let n=F(),o=react.useMemo(()=>qE(n),[n]),s=X(),a=reactNativeSafeAreaContext.useSafeAreaInsets(),{width:l}=reactNative.useWindowDimensions(),u=WE(l),d=t.open,c=react.useRef(null);c.current===null&&(c.current=new reactNative.Animated.Value(s.drawerMs<=0&&d?1:0));let p=c.current;react.useEffect(()=>{if(!d&&s.drawerMs<=0){r();return}let E=reactNative.Animated.timing(p,{toValue:d?1:0,duration:s.drawerMs,easing:jE,useNativeDriver:true});return E.start(({finished:w})=>{w&&!d&&r();}),()=>E.stop()},[d,p,s.drawerMs,r]);let f=p.interpolate({inputRange:[0,1],outputRange:[-u,0]}),m=t.filtered,y=t.rows.length===0,k=y&&t.loading?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,accessibilityLabel:Z.loading,accessibilityState:{busy:true},children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{color:n.color.onPrimary}),jsxRuntime.jsx(R,{style:o.emptyBody,children:Z.loading})]}):y&&t.error!==null?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(R,{style:o.emptyTitle,accessibilityRole:"alert",children:Z.loadFailed}),jsxRuntime.jsx(R,{style:o.emptyBody,children:t.error}),jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:Z.retryA11y,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load();},children:jsxRuntime.jsx(R,{tier:"control",style:o.retryText,children:Z.retry})})]}):jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(R,{style:o.emptyTitle,children:t.emptyKind==="empty"?Z.empty:Z.noMatch}),jsxRuntime.jsx(R,{style:o.emptyBody,children:t.emptyKind==="empty"?Z.emptyBody:Z.noMatchBody})]}),b=!t.searching&&t.loadingMore?jsxRuntime.jsx(reactNative.View,{style:o.loadMoreFooter,children:jsxRuntime.jsx(R,{style:o.loadMoreLabel,children:Z.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:Te,onPress:t.close,accessibilityRole:"button",accessibilityLabel:Z.closeA11y,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[o.backdrop,{opacity:p}]})}),jsxRuntime.jsx(reactNative.Animated.View,{style:[o.panel,{width:u,paddingTop:Math.max(_E,a.top+n.space.md),transform:[{translateX:f}]}],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(_d,{size:HE,color:n.color.text.muted,strokeWidth:1.5}),jsxRuntime.jsx(Ut,{value:t.query,onChangeText:E=>t.setQuery(E.replace(/^\s+/,"")),style:o.searchInput,placeholder:Z.search,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:Z.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:Z.newConversation,style:o.newButton,onPress:t.newConversation,children:jsxRuntime.jsx(wd,{size:VE,color:n.color.text.primary,strokeWidth:1.5})})]}),jsxRuntime.jsx(R,{tier:"heading",style:o.heading,accessibilityRole:"header",children:Z.heading}),t.error!==null&&!y?jsxRuntime.jsx(reactNative.View,{style:o.errorCard,children:jsxRuntime.jsx(R,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,jsxRuntime.jsx(reactNative.FlatList,{data:m,keyExtractor:E=>E.id,renderItem:({item:E})=>jsxRuntime.jsx(KE,{row:E,active:E.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(E.id);}}),contentContainerStyle:m.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:k,ListFooterComponent:b,onEndReached:t.loadMore,onEndReachedThreshold:zE})]})})]})})}i(GE,"DrawerModal");function KE({row:e,active:t,disabled:r,styles:n,onPress:o}){let s=e.unreadCount!==null&&e.unreadCount>0;return jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:nd(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(R,{style:[n.itemTitle,s?n.itemTitleUnread:null],numberOfLines:1,children:yn(e.title)}),s?jsxRuntime.jsx(reactNative.View,{style:n.unreadDot}):null]})})}i(KE,"Row");function Ln(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(Ln,"inkWash");function qE(e){let t=e.color,r=e.slots,n=t.onPrimary;return reactNative.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:wE},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:Ln(n,AE)},searchInput:{...S(e,"regular"),flex:1,fontSize:13,lineHeight:16,color:t.text.primary,padding:0},newButton:{width:$i,height:$i,borderRadius:$i/2,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},heading:{...S(e,"bold"),fontSize:14,lineHeight:17,color:n,marginTop:4},list:{gap:10,paddingBottom:28},listEmpty:{flexGrow:1},item:{paddingVertical:12,paddingHorizontal:4,borderRadius:DE},itemActive:{backgroundColor:Ln(n,IE)},itemRow:{flexDirection:"row",alignItems:"center",gap:8},itemTitle:{...S(e,"regular"),flex:1,fontSize:14,lineHeight:18,color:n},itemTitleUnread:S(e,"bold"),unreadDot:{width:Yi,height:Yi,borderRadius:Yi/2,backgroundColor:t.danger,borderWidth:BE,borderColor:n},errorCard:{borderRadius:UE,borderWidth:.5,borderColor:t.danger,backgroundColor:t.surface,padding:12},errorText:{...S(e,"regular"),fontSize:11,lineHeight:16,color:t.danger},emptyCard:{borderRadius:NE,padding:14,gap:6,backgroundColor:Ln(n,OE),borderWidth:.5,borderColor:Ln(n,FE)},emptyTitle:{...S(e,"bold"),fontSize:12,lineHeight:15,color:n},emptyBody:{...S(e,"regular"),fontSize:11,lineHeight:17,color:n,opacity:ME},retrySlot:{marginTop:8,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:7,borderWidth:1,borderColor:n,...de(r.primaryButton)},retryText:{...S(e,"bold"),fontSize:12,lineHeight:15,color:n,...Ce(r.primaryButton)},loadMoreFooter:{paddingVertical:14,alignItems:"center"},loadMoreLabel:{...S(e,"regular"),fontSize:11,lineHeight:14,color:n,opacity:LE}})}i(qE,"makeStyles");var JE=Object.freeze({}),eR=100,tR=20;function rR(e,t,r,n){return ![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}i(rR,"readWindowTops");function Yc(e,t){let r=typeof e=="number"&&Number.isFinite(e),n=react.useRef(null),[o,s]=react.useState(null),a=react.useRef(null),l=react.useRef(null),u=react.useRef(true),d=react.useCallback(()=>{l.current!==null&&clearTimeout(l.current),l.current=null;},[]);react.useEffect(()=>(u.current=true,()=>{u.current=false,d();}),[d]);let c=react.useCallback(i(function f(m){n.current?.measureInWindow((y,k)=>{let b=a.current;if(!u.current||b===null)return;let E=rR(k,b.y,b.height,reactNative.Dimensions.get("window").height);if(E!==null){s(w=>w!==null&&w.chatTop===E.chatTop&&w.parentTop===E.parentTop?w:E);return}m>=tR||(l.current=setTimeout(()=>{l.current=null,f(m+1);},eR));});},"measureAt"),[]),p=react.useCallback(f=>{let{y:m,height:y}=f.nativeEvent.layout;a.current={y:m,height:y},d(),c(0);},[c,d]);return react.useMemo(()=>{if(!t)return {avoidingProps:r?{keyboardVerticalOffset:e}:JE,probeRef:null,topInWindow:null};let f=o?.parentTop??0;return {avoidingProps:r?{keyboardVerticalOffset:e,onLayout:p}:f>0?{keyboardVerticalOffset:f,onLayout:p}:{onLayout:p},probeRef:n,topInWindow:o?.chatTop??null}},[t,r,e,o,p])}i(Yc,"useChatKeyboardOffset");function Xc({probeRef:e}){return e===null?null:jsxRuntime.jsx(reactNative.View,{ref:e,collapsable:false,pointerEvents:"none",style:nR})}i(Xc,"KeyboardOffsetProbe");var nR=Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function Qc(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),t?.prefer!==void 0&&(r.prefer=t.prefer),r}i(Qc,"chatVetVisitOptions");var lR=16,uR=.75,Qi=12,Zc=15,dR=18,Nn=22,cR=14,pR=8,fR=20,mR=10,yR=13;function ep({surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o}){let s=F(),a=react.useMemo(()=>gR(s),[s]),l=X(),u=e.tier,d=e.source;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ci,{visible:e.showBanner&&u!==null,inMs:l.bannerInMs,outMs:l.bannerOutMs,style:a.pinned,children:u!==null&&d!==null?jsxRuntime.jsxs(reactNative.View,{accessibilityRole:"alert",style:[a.card,{borderColor:u.borderColor,backgroundColor:u.backgroundColor}],children:[jsxRuntime.jsx(R,{tier:"compact",style:[a.label,{color:u.textColor}],children:u.label}),d.reason!==null?jsxRuntime.jsx(R,{style:[a.reason,{color:u.reasonColor}],children:d.reason}):null,e.showVetAction?r!==void 0?jsxRuntime.jsx(Ct,{render:()=>r(u.level),fallback:jsxRuntime.jsx(Jc,{tier:u,petRef:t,onFindVet:n,vet:o,styles:a}),resetKey:u.level}):jsxRuntime.jsx(Jc,{tier:u,petRef:t,onFindVet:n,vet:o,styles:a}):null,e.dismissLabel!==null?jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:e.dismissLabel,hitSlop:pR,containerStyle:a.closeSlot,style:a.closeButton,onPress:e.dismiss,children:jsxRuntime.jsx(Et,{size:cR,color:u.textColor,strokeWidth:1.5})}):null]}):null}),jsxRuntime.jsx(Ci,{visible:e.showCompactIcon,inMs:l.iconInMs,outMs:l.iconOutMs,style:a.indicatorRow,children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.showLatestVetAlert,hitSlop:mR,onPress:e.expand,children:jsxRuntime.jsx(Td,{size:fR,color:s.color.text.muted,strokeWidth:2})})})]})}i(ep,"UrgencyBanner");function Jc({tier:e,petRef:t,onFindVet:r,vet:n,styles:o}){let s=F(),a=wn(Qc(t,n)),l=a.status==="opening",u=a.available?()=>{a.open();}:r!==void 0?()=>{q(r,e.level);}:null;if(u===null)return null;let d=_i(s.slots.vetVisitButton)?.textColor??e.textColor;return jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:h.findVetA11y,accessibilityState:{busy:l},containerStyle:o.findVetSlot,style:[o.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},o.findVetSlotBox,l?o.findVetBusy:null],onPress:u,children:[jsxRuntime.jsx(Id,{size:yR,color:d,strokeWidth:1.5}),jsxRuntime.jsx(R,{tier:"control",style:[o.findVetLabel,{color:d}],children:h.findVet})]})}i(Jc,"VetAction");function gR(e){let t=_i(e.slots.vetVisitButton);return reactNative.StyleSheet.create({pinned:{marginTop:0,marginBottom:4,paddingHorizontal:e.space.lg},card:{borderRadius:lR,borderWidth:uR,paddingHorizontal:14,paddingVertical:8,gap:2},label:{...S(e,"monoBold"),fontSize:Qi,lineHeight:Zc},reason:{...S(e,"regular"),fontSize:Qi,lineHeight:dR,paddingRight:Nn},findVetSlot:{alignSelf:"flex-start",marginTop:6},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...de(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...S(e,"monoBold"),fontSize:Qi,lineHeight:Zc},closeSlot:{position:"absolute",top:6,right:6},closeButton:{width:Nn,height:Nn,borderRadius:Nn/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:16,paddingTop:2,paddingBottom:4}})}i(gR,"makeStyles");function tp(){let e=Pn(),{handle:t}=Y(),r=react.useCallback(n=>t.setActivePet(n),[t]);return react.useMemo(()=>({...e,setActivePet:r}),[e,r])}i(tp,"useChatPets");var ap=300,lp=3e3,np=120,Gt=44,ER=120,RR="86%",Ji=15,es=22,xr=.5,SR=.04,TR=8,PR=2,kR=1,xR=.6,_R=22,wR=48,op=1.25,IR=14,AR=18,OR=6,FR=14,MR=.04,LR=12,DR=2,NR=2,ip=36,UR=20,Wt=36,Kt=(Gt-Wt)/2,up=24,dp=22,VR=.4,Un=30,cp=20,HR=.4,BR=480,zR=8,sp=14,jR=10,WR=14,GR=12,KR=13,qR=18,$R="12%";function Re(){let e=F(),t=react.useMemo(()=>YR(e),[e]);return {theme:e,styles:t}}i(Re,"useChatTheme");function YR(e){let t=e.color,r=e.space,n=e.radius,o=e.type,s=e.slots;return reactNative.StyleSheet.create({container:{flex:1,minHeight:np,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:np,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},emptyContent:{flexGrow:1,alignItems:"center",justifyContent:"flex-start",paddingTop:$R,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:BR,gap:18},errorText:{...S(e,"regular"),fontSize:o.size.subtitle,lineHeight:o.size.subtitle*o.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:Gt,minWidth:Gt,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...de(s.primaryButton)},retryLabel:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,...Ce(s.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...S(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:{...S(e,"bold"),color:t.text.primary,fontSize:o.size.body},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...S(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal},turnNoticeAction:{minHeight:Gt,justifyContent:"center"},turnNoticeActionLabel:{...S(e,"medium"),color:t.brandInk,fontSize:o.size.body},setupNoticeAction:{...S(e,"medium"),color:t.brandInk,fontSize:o.size.caption},reconnectingCaption:{...S(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:RR},bubbleUser:{padding:Ji,backgroundColor:t.bubbleUser,borderRadius:n.xl,borderBottomRightRadius:n.sm,borderWidth:xr,borderColor:t.accentEdge,shadowColor:t.brand,shadowOpacity:SR,shadowRadius:TR,shadowOffset:{width:0,height:PR},elevation:kR,...de(s.userBubble,xr)},bubbleAssistant:s.assistantBubble?.backgroundColor===void 0?{...de(s.assistantBubble,xr)}:{padding:Ji,borderRadius:n.xl,...de(s.assistantBubble,xr)},bubbleVet:{padding:Ji,backgroundColor:t.bubbleVet,borderRadius:n.xl,borderBottomLeftRadius:n.sm,...de(s.vetBubble,xr)},bubblePending:{opacity:xR},bubbleTextUser:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:es,...Ce(s.userBubble)},bubbleTextAssistant:{...S(e,"medium"),color:t.text.primary,fontSize:o.size.body,lineHeight:es,...Ce(s.assistantBubble)},bubbleTextVet:{...S(e,"medium"),color:t.onBubbleVet,fontSize:o.size.body,lineHeight:es,...Ce(s.vetBubble)},vetSender:{...S(e,"bold"),color:t.onBubbleVet,fontSize:o.size.caption,lineHeight:Math.round(o.size.caption*o.lineHeight.normal),marginBottom:r.xs,...Ce(s.vetBubble)},bubbleBold:S(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:S(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.sm,gap:zR},followUpSlot:{alignSelf:"stretch",borderRadius:sp},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:GR,paddingVertical:jR,paddingHorizontal:WR,borderRadius:sp,backgroundColor:t.brandSoft},followUpText:{...S(e,"medium"),flex:1,color:t.text.primary,fontSize:KR,lineHeight:qR},composerOuter:{position:"relative"},composer:{marginHorizontal:r.md,marginTop:r.xs,marginBottom:r.sm,minHeight:wR,justifyContent:"center",paddingLeft:IR,paddingRight:AR,paddingVertical:OR,backgroundColor:t.composerFill,borderWidth:op,borderColor:t.composerBorder,borderRadius:_R,shadowColor:t.shadow,shadowOpacity:MR,shadowRadius:LR,shadowOffset:{width:0,height:DR},elevation:NR,...de(s.composerInput,op)},composerRow:{flexDirection:"row",alignItems:"center",gap:FR,minHeight:ip},attachControl:{width:Un,height:Un,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:HR},input:{flex:1,minHeight:ip,maxHeight:ER,paddingHorizontal:0,paddingVertical:0,...S(e,"regular"),fontSize:o.size.body,lineHeight:UR,color:t.text.primary,...Ce(s.composerInput)},sendControl:{minHeight:Wt,minWidth:Wt,alignItems:"center",justifyContent:"center"},sendDisc:{width:Wt,height:Wt,borderRadius:Wt/2,alignItems:"center",justifyContent:"center",...de(s.sendButton)},sendControlDisabled:{opacity:VR},poweredBy:{...S(e,"regular"),color:t.text.muted,fontSize:o.size.micro,textAlign:"center",paddingBottom:r.xs}})}i(YR,"makeStyles");var XR=Object.freeze({kind:"live"}),QR=Object.freeze({kind:"folded"});function ts(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=mo(e.proactiveOriginRef);return {caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}i(ts,"askOf");function fp(e){let t=new Map,r=new Map;for(let o of e){let s=ts(o);if(s===null)continue;let a=r.get(s.caseId);(a===void 0||s.dueDay>=a.dueDay)&&r.set(s.caseId,{messageId:o.id,dueDay:s.dueDay});}if(r.size===0)return t;let n=null;for(let o of e){let s=ts(o);if(s===null){n=null;continue}if(r.get(s.caseId)?.messageId===o.id){t.set(o.id,XR),n=null;continue}if(n!==null&&n.caseId===s.caseId){n.days.push(s.dueDay),t.set(o.id,QR);continue}let a=[s.dueDay];n={id:o.id,caseId:s.caseId,days:a},t.set(o.id,{kind:"past",runDueDays:a});}return t}i(fp,"placeCheckins");var pp=864e5,ZR=365;function Vn(e,t){if(typeof e!="string"||typeof t!="string")return null;let r=Date.parse(e),n=Date.parse(t);if(Number.isNaN(r)||Number.isNaN(n))return null;let o=Math.floor(n/pp)-Math.floor(r/pp);return o<1||o>ZR?null:o}i(Vn,"checkinDayNumber");function mp(e){return ts(e)?.dueDay||null}i(mp,"checkinDueDay");var Pe=Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" \xB7 ",answers:Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),yp=Object.freeze(Gr.map(e=>Object.freeze({answer:e,label:Pe.answers[e]})));function gp(e,t){let[r,n]=react.useState(null),[o,s]=react.useState(null),[a,l]=react.useState(null),u=react.useCallback(c=>{t!==null&&(n(c),s(null),t(e.caseId,c).then(p=>{n(null),p.ok?l(c):s(p.error);}));},[t,e.caseId]),d=a??e.answer;return {answer:d,answerable:!Ca(e),escalated:d==="worse",pending:r,error:o,choose:u}}i(gp,"useCheckinCard");var vp=44,tS=.6;function Ep({message:e,checkin:t,onAnswer:r,petRef:n,onFindVet:o,vet:s,onLayout:a}){let l=F(),u=react.useMemo(()=>rS(l),[l]),d=gp(t,r),c=d.answer!==null||d.pending!==null,p=r!==null&&d.answerable,f=Vn(t.openedAt,mp(e));return jsxRuntime.jsxs(reactNative.View,{style:u.card,accessibilityLabel:Pe.eyebrow,onLayout:a,children:[jsxRuntime.jsxs(reactNative.View,{style:u.head,children:[jsxRuntime.jsx(R,{tier:"compact",style:u.eyebrow,children:Pe.eyebrow}),f!==null?jsxRuntime.jsx(R,{tier:"compact",style:u.headDay,children:K(Pe.day,{day:f})}):null]}),jsxRuntime.jsx(R,{style:u.question,accessibilityRole:"text",children:e.text}),p?jsxRuntime.jsx(reactNative.View,{style:[u.row,d.pending?u.rowPending:null],children:yp.map(({answer:m,label:y})=>{let k=(d.pending??d.answer)===m;return jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>d.choose(m),disabled:c,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{selected:k,disabled:c,busy:d.pending===m},style:[u.pill,k?u.pillSelected:null],children:jsxRuntime.jsx(R,{tier:"control",style:[u.pillLabel,k?u.pillLabelSelected:null],children:y})},m)})}):null,d.answer!==null?jsxRuntime.jsx(R,{style:u.logged,children:Pe.logged}):null,d.escalated?o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:Pe.findVet,style:u.findVet,children:jsxRuntime.jsx(R,{tier:"control",style:u.findVetLabel,children:Pe.findVet})}):n?jsxRuntime.jsx(jt,{entry:"chat",petRef:n,label:Pe.findVet,...s?.returnTo!==void 0?{returnTo:s.returnTo}:{},...s?.usState!==void 0?{usState:s.usState}:{},...s?.prefer!==void 0?{prefer:s.prefer}:{},style:u.findVet,labelStyle:u.findVetLabel}):null:null,t.resolutionText?jsxRuntime.jsx(R,{style:u.resolution,children:t.resolutionText}):null,d.error?jsxRuntime.jsx(R,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}i(Ep,"CheckinCard");function rS(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.brandSoft,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...S(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},headDay:{...S(e,"bold"),color:t.text.primary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},question:{...S(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:tS},pill:{flex:1,minHeight:vp,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brand},pillLabel:{...S(e,"regular"),color:t.text.primary,fontSize:o.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...S(e,"regular"),color:t.text.secondary,fontSize:o.size.caption},resolution:{...S(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},error:{...S(e,"regular"),color:t.danger,fontSize:o.size.caption},findVet:{alignSelf:"stretch",minHeight:vp,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.brandBorder,backgroundColor:t.surface},findVetLabel:{...S(e,"bold"),color:t.brandInk,fontSize:o.size.body}})}i(rS,"makeStyles");var iS=1.5,sS=3;function Sp({text:e,runDueDays:t,openedAt:r,onLayout:n}){let o=F(),s=react.useMemo(()=>aS(o),[o]),a=t.map(u=>Vn(r,u)).filter(u=>u!==null),l=t.length>1;return l&&a.length===0?null:jsxRuntime.jsxs(reactNative.View,{style:s.row,onLayout:n,children:[jsxRuntime.jsx(reactNative.View,{style:s.rule,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}),jsxRuntime.jsxs(reactNative.View,{style:s.body,children:[a.length>0?jsxRuntime.jsx(R,{tier:"compact",style:s.days,children:a.map(u=>K(Pe.day,{day:u})).join(Pe.daySeparator)}):null,l?null:jsxRuntime.jsx(R,{style:s.question,accessibilityRole:"text",children:e})]})]})}i(Sp,"CheckinPastAsk");function aS(e){let t=e.color,r=e.space,n=e.type;return reactNative.StyleSheet.create({row:{flexDirection:"row",paddingVertical:r.xs},rule:{width:iS,borderRadius:1,backgroundColor:t.borderHairlineGreen,marginRight:r.md},body:{flex:1,gap:sS},days:{...S(e,"monoMedium"),fontSize:n.size.nano,letterSpacing:n.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},question:{...S(e,"regular"),fontSize:n.size.bodyTight,lineHeight:n.size.bodyTight*n.lineHeight.normal,color:t.text.muted}})}i(aS,"makeStyles");var lS=Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),Tp="#C8BEB4";function uS(e){return e?lS[e.toUpperCase()]??Tp:Tp}i(uS,"tierColor");function dS(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}i(dS,"tierLabel");function He(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(He,"text");function cS(e){let t=He(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}i(cS,"httpsUrl");function pS(e,t){let r=He(e.source_name)??He(e.sourceName),n=He(e.section),o=He(e.authority_tier)??He(e.authorityTier),s=dS(o),a=r??He(e.title)??`Source ${t+1}`,l=He(e.monograph_chunk_id)??He(e.chunkId),u=[n,s].filter(d=>d!==null).join(" \xB7 ");return Object.freeze({title:a,sourceName:r,section:n,authorityTier:o,tierLabel:s,meta:u.length===0?null:u,url:cS(e.url),excerpt:He(e.excerpt),tierColor:uS(o),key:`${a}-${l??"none"}-${t}`})}i(pS,"toCitationCard");function Pp(e){return e===void 0||e.length===0?fS:Object.freeze(e.map((t,r)=>pS(t,r)))}i(Pp,"toCitationCards");var fS=Object.freeze([]);function ss(e){return e===1?`1 ${h.sourceSingular}`:`${e} ${h.sourcePlural}`}i(ss,"sourcesLabel");function kp(e,t){return `${t?h.hideSources:h.showSources} ${ss(e)}`}i(kp,"sourcesToggleLabel");function xp(e){return [e.url!==null?`${h.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(t=>t!==null&&t.length>0).join(". ")}i(xp,"citationA11yLabel");var bS=244,wp=8,Ip=13,vS=14,CS=.3,ES=-0.24,RS=22,SS=10,TS=15;function Ap({citations:e,onOpenUrl:t}){let r=F(),n=react.useMemo(()=>xS(r),[r]),o=react.useMemo(()=>Pp(e),[e]),[s,a]=react.useState(false);if(o.length===0)return null;let l=o.length;return jsxRuntime.jsxs(reactNative.View,{style:n.block,children:[jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:kp(l,s),accessibilityState:{expanded:s},containerStyle:n.toggleSlot,style:n.togglePill,onPress:()=>a(u=>!u),children:[jsxRuntime.jsx(Ed,{size:Ip,color:r.color.brandInk,strokeWidth:1.5}),jsxRuntime.jsx(R,{tier:"compact",style:n.toggleLabel,children:ss(l)}),jsxRuntime.jsx(bn,{size:Ip,color:r.color.brandInk,strokeWidth:1.5,direction:s?"up":"down"})]}),s?jsxRuntime.jsx(PS,{cards:o,styles:n,open:t}):null]})}i(Ap,"CitationCards");function PS({cards:e,styles:t,open:r}){let n=X(),o=Rt(n.citationsInMs,{risePx:n.citationsRisePx});return jsxRuntime.jsx(reactNative.Animated.View,{style:o,children:jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(s=>jsxRuntime.jsx(kS,{card:s,styles:t,open:r},s.key))})})}i(PS,"Deck");function kS({card:e,styles:t,open:r}){let n=F(),o=e.url!==null&&r!==void 0,s=xp(o?e:{...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(R,{style:[t.cardTitle,o?t.cardTitleLink:null],numberOfLines:2,children:e.title}),o?jsxRuntime.jsx(Rd,{size:vS,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?jsxRuntime.jsx(R,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?jsxRuntime.jsx(R,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let l=e.url;return jsxRuntime.jsx(B,{accessibilityRole:"link",accessibilityLabel:s,style:t.card,onPress:()=>r(l),children:a})}return jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:s,style:t.card,children:a})}i(kS,"Card");function xS(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:{...S(e,"monoBold"),fontSize:o.micro,lineHeight:o.micro,letterSpacing:CS,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:bS,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:wp,height:wp,borderRadius:n.pill},cardTitle:{...S(e,"bold"),flex:1,fontSize:o.bodyTight,lineHeight:RS,color:t.text.primary,letterSpacing:ES},cardTitleLink:{color:t.linkInk},cardMeta:{...S(e,"monoMedium"),fontSize:o.nano,lineHeight:SS,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},cardExcerpt:{...S(e,"regular"),fontSize:o.tiny,lineHeight:TS,color:t.text.muted}})}i(xS,"makeStyles");function Op(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}i(Op,"formatMessageTime");var _r=15,FS=15,MS=6,LS=Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function Np({message:e,onCopy:t,sentiment:r=null,onSentiment:n,thanks:o=false}){let s=F(),a=react.useMemo(()=>DS(s),[s]),l=X(),u=e.role==="user",d=react.useMemo(()=>Op(e.createdAt),[e.createdAt]),c=t!==void 0&&e.role!=="vet"&&e.text.length>0,p=e.role==="assistant"&&n!==void 0&&e.responseId!==void 0,[f,m]=react.useState(false),y=react.useRef(null);react.useEffect(()=>()=>{y.current&&clearTimeout(y.current);},[]);let k=i(()=>{t!==void 0&&(Ht(t,e.text),m(true),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{m(false),y.current=null;},l.copiedMs));},"copy");return d===null&&!c&&!p?null:jsxRuntime.jsxs(reactNative.View,{style:a.wrap,children:[jsxRuntime.jsxs(reactNative.View,{style:[a.row,u?a.rowUser:a.rowAssistant],children:[d!==null?jsxRuntime.jsx(R,{tier:"compact",style:a.timestamp,children:d}):null,c?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:f?h.copied:u?h.copyUserMessage:h.copyAssistantMessage,hitSlop:FS,onPress:k,style:a.iconHit,children:f?jsxRuntime.jsx(nt,{size:_r,color:s.color.success,strokeWidth:2}):jsxRuntime.jsx(Sd,{size:_r,color:s.color.text.timestamp,strokeWidth:1.5})}):null,p?Iu.map(({sentiment:b,label:E})=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:E,accessibilityState:{selected:r===b},hitSlop:MS,onPress:()=>n?.(b),style:a.iconHit,children:jsxRuntime.jsx(vn,{size:_r,color:s.color.sentiment[b],active:r===b,rotate:LS[b],strokeWidth:1.5})},b)):null]}),o?jsxRuntime.jsx(R,{style:a.thanks,accessibilityLiveRegion:"polite",children:h.feedbackThanks}):null]})}i(Np,"MessageFooter");function DS(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:{...S(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:_r,height:_r,alignItems:"center",justifyContent:"center"},thanks:{...S(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary}})}i(DS,"makeStyles");var Up="#10462E",Vp="#000000",NS="#83E0B4",US=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:NS,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:Up,brandEdge:true,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})]),VS=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function HS(e){return e==null?e:e.replace(VS,"").trim()}i(HS,"formatBreedForPrompt");var BS=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 zS(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return BS.has(t)}i(zS,"isUninformativeBreed");function jS(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}i(jS,"unspecifiedBreedLabel");function WS(e,t){return zS(e)?jS(t):String(e).replace(/\s+/gu," ").trim()}i(WS,"resolveBreedLabel");function Hp(e){let t=e?.name?.trim()||h.emptyTitlePetFallback;return K(h.emptyTitle,{petName:t})}i(Hp,"emptyStateTitle");function Bp(e,t=Up){let r=Di(e?.species),n=r==="cat"?"my cat":"my dog",o=e?.name?.trim()||null,s=o||n,a=WS(HS(e?.breed),r)||null,l=Ni(e?.ageYears),u=l===null?null:String(l);return Object.freeze(US.map(d=>{let c=d.label.includes("{breed}"),p=d.label.includes("{ageYears}"),m=d.fallbackLabel!==void 0&&(c&&!a||p&&!u)&&d.fallbackLabel?d.fallbackLabel:d.label,y=K(m,{petName:s,breed:a??n,species:r,ageYears:u??""}),k=!o&&m.startsWith("{petName}")?y.charAt(0).toUpperCase()+y.slice(1):y;return Object.freeze({id:d.id,intent:d.intent,label:k,background:d.background,borderColor:d.brandEdge===true?t:d.borderColor,borderWidth:d.borderWidth})}))}i(Bp,"resolveQuickPrompts");var KS=36,Wp=4,qS=340;function Gp({pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o}){let s=F(),a=react.useMemo(()=>YS(s),[s]),l=react.useMemo(()=>Bp(e,s.color.brandInk),[e,s.color.brandInk]),u=Hp(e);return jsxRuntime.jsxs(reactNative.View,{style:a.block,children:[jsxRuntime.jsx(R,{tier:"heading",style:a.title,accessibilityRole:"header",children:u}),jsxRuntime.jsx(reactNative.View,{style:a.list,children:l.map((d,c)=>jsxRuntime.jsx($S,{prompt:d,index:c,petRef:t,onSend:r,onVetPrep:n,vet:o,pet:e,styles:a},d.id))})]})}i(Gp,"QuickPrompts");function $S({prompt:e,index:t,pet:r,petRef:n,onSend:o,onVetPrep:s,vet:a,styles:l}){let u=X(),d=Rt(u.followUpInMs,{delayMs:En(u,t)}),c={backgroundColor:e.background,borderColor:e.borderColor,borderWidth:e.borderWidth};return e.intent==="vet_report"?s!==void 0?jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Wp,style:[l.chip,c],onPress:()=>{q(s,r);},children:jsxRuntime.jsx(R,{tier:"compact",style:l.chipLabel,children:e.label})})}):n===null?null:jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(jt,{entry:"chat",petRef:n,label:e.label,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:[l.chip,c],labelStyle:l.chipLabel})}):jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Wp,style:[l.chip,c],onPress:()=>o(e.label),children:jsxRuntime.jsx(R,{tier:"compact",style:l.chipLabel,children:e.label})})})}i($S,"Chip");function YS(e){let t=e.color;return reactNative.StyleSheet.create({block:{gap:18,alignItems:"center",width:"100%"},title:{...S(e,"bold"),fontSize:28,lineHeight:34,color:t.text.primary,letterSpacing:-0.8,textAlign:"center",maxWidth:qS},list:{width:"100%",gap:12,alignItems:"center"},chip:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:9,minHeight:KS,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipLabel:{...S(e,"bold"),fontSize:12,lineHeight:14,color:Vp,textAlign:"center"}})}i(YS,"makeStyles");var ls=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;function Kp(e){return e.includes("*")||e.includes("`")}i(Kp,"hasInlineMarkup");function qp(e){let t=[],r=0;ls.lastIndex=0;for(let n=ls.exec(e);n!==null;n=ls.exec(e)){n.index>r&&t.push({kind:"text",text:e.slice(r,n.index)});let o=n[1],s=n[2],a=n[3];o!==void 0?t.push({kind:"bold",text:o}):s!==void 0?t.push({kind:"italic",text:s}):a!==void 0&&t.push({kind:"code",text:a}),r=n.index+n[0].length;}return r<e.length&&t.push({kind:"text",text:e.slice(r)}),t}i(qp,"tokenizeInlineMarkdown");function $p(e,t){return Kp(e)?qp(e).map((r,n)=>{switch(r.kind){case "bold":return jsxRuntime.jsx(R,{style:t.bold,children:r.text},n);case "italic":return t.italic?jsxRuntime.jsx(R,{style:t.italic,children:r.text},n):r.text;case "code":return t.code?jsxRuntime.jsx(R,{style:t.code,children:r.text},n):r.text;default:return r.text}}):e}i($p,"renderInlineMarkdown");var Qp=6,ef=520,tT=Math.round(ef*.18),Zp=.44,rT=.5,Jp=[0,.5,1],nT=[0,1,2];function tf(){let e=F(),t=react.useMemo(()=>iT(e),[e]),r=!e.motion.reducedMotion;return jsxRuntime.jsx(reactNative.View,{style:t.card,accessible:true,accessibilityRole:"text",accessibilityLabel:h.typing,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:nT.map(n=>r?jsxRuntime.jsx(oT,{index:n,style:t.dot},n):jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotStatic]},n))})}i(tf,"TypingIndicator");function oT({index:e,style:t}){let r=react.useRef(new reactNative.Animated.Value(0)).current;react.useEffect(()=>{let s=reactNative.Animated.sequence([reactNative.Animated.delay(e*tT),reactNative.Animated.loop(reactNative.Animated.timing(r,{toValue:1,duration:ef,useNativeDriver:true}))]);return s.start(),()=>s.stop()},[r,e]);let n=r.interpolate({inputRange:Jp,outputRange:[Zp,1,Zp]}),o=r.interpolate({inputRange:Jp,outputRange:[0,-3.5,0]});return jsxRuntime.jsx(reactNative.Animated.View,{style:[t,{opacity:n,transform:[{translateY:o}]}]})}i(oT,"AnimatedDot");function iT(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:Qp,height:Qp,borderRadius:n.pill,backgroundColor:t.brand},dotStatic:{opacity:rT}})}i(iT,"makeStyles");function rf(e,t,r){let n=e-r,o=t!=null?Math.min(n,t):n;return Math.max(0,o)}i(rf,"resolveTurnScrollTarget");function nf(e){let t=e.length-1,r=e[t];if(r===void 0||r.role!=="assistant")return null;let n=e[t-1];return {assistantIndex:t,userIndex:n!==void 0&&n.role==="user"?t-1:null}}i(nf,"latestTurn");function of(e,t,r){let n=Math.max(0,r),o=e===null?n:Math.min(Math.max(0,e),n);return o>t+1?o:null}i(of,"nextFollowOffset");function sf(e,t){let r=react.useRef(null),n=react.useRef(true),o=react.useRef(t),s=react.useRef(0),a=react.useRef(0),l=react.useRef(0),u=react.useRef(new Map),d=nf(e),c=d===null?null:e[d.assistantIndex]?.id??null,p=d===null||d.userIndex===null?null:e[d.userIndex]?.id??null,f=react.useCallback(()=>{let T=r.current;if(T===null||!n.current||a.current===0)return;let x=null;if(c!==null){let _=u.current.get(c);if(_===void 0)return;let O=p===null?null:u.current.get(p)??null;x=rf(_,O,96);}let g=of(x,s.current,l.current-a.current);g!==null&&(s.current=g,T.scrollTo({y:g,animated:false}));},[c,p]);react.useEffect(()=>{t&&!o.current&&(n.current=true),o.current=t,f();},[e,t,f]);let m=react.useCallback(T=>{a.current=T.nativeEvent.layout.height,f();},[f]),y=react.useCallback((T,x)=>{l.current=x,a.current>0&&(s.current=Math.min(s.current,Math.max(0,x-a.current))),f();},[f]),k=react.useCallback(T=>{s.current=T.nativeEvent.contentOffset.y;},[]),b=react.useCallback(()=>{n.current=false;},[]),E=react.useCallback(T=>{let{contentOffset:x,contentSize:g,layoutMeasurement:_}=T.nativeEvent;s.current=x.y,n.current=g.height-x.y-_.height<=24;},[]),w=react.useCallback(T=>x=>{u.current.set(T,x.nativeEvent.layout.y),(T===c||T===p)&&f();},[c,p,f]);return {ref:r,onLayout:m,onContentSizeChange:y,onScroll:k,onScrollBeginDrag:b,onScrollEnd:E,rowLayout:w}}i(sf,"useThreadFollow");function cf(e,t,r){switch(e){case "loading":return r.renderPending?jsxRuntime.jsx(Ct,{render:r.renderPending,fallback:jsxRuntime.jsx(lf,{})}):jsxRuntime.jsx(lf,{});case "empty":return jsxRuntime.jsx(fT,{pet:r.shownPet,petRef:t.petRef,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet});case "error":return jsxRuntime.jsx(gT,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case "populated":return jsxRuntime.jsx(hT,{messages:t.messages,prompts:pd(t),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,onOpenUrl:r.onOpenUrl});default:return Ze(e)}}i(cf,"renderView");function lf(){let{theme:e,styles:t}=Re(),[r,n]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>n(true),ap);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx(reactNative.View,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:h.loading,children:r?jsxRuntime.jsx(reactNative.ActivityIndicator,{color:e.color.brandInk}):null})}i(lf,"LoadingState");function fT({pet:e,petRef:t,onSelectPrompt:r,onVetPrep:n,vet:o}){let{styles:s}=Re();return jsxRuntime.jsx(reactNative.ScrollView,{contentContainerStyle:s.emptyContent,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,accessibilityLabel:h.empty,children:jsxRuntime.jsx(Gp,{pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o})})}i(fT,"EmptyState");function mT({prompts:e,onSelectPrompt:t}){let{styles:r}=Re();return e.length===0?null:jsxRuntime.jsx(reactNative.View,{style:r.followUps,children:e.map((n,o)=>jsxRuntime.jsx(yT,{prompt:n,index:o,onSelectPrompt:t},n))})}i(mT,"FollowUps");function yT({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:o}=Re(),s=X(),a=Rt(s.followUpInMs,{delayMs:En(s,t)});return jsxRuntime.jsx(reactNative.Animated.View,{style:a,children:jsxRuntime.jsxs(B,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:o.followUpSlot,style:o.followUpRow,children:[jsxRuntime.jsx(R,{style:o.followUpText,children:e}),jsxRuntime.jsx(bn,{size:ET,color:n.color.brandInk,direction:"right"})]})})}i(yT,"FollowUpRow");function gT({error:e,onRetry:t,onAddPet:r}){let{styles:n}=Re(),o=Vu(e)?qu(r):void 0;return jsxRuntime.jsxs(reactNative.View,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(R,{style:n.errorText,children:e.displayMessage}),o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:h.addPet,style:n.retryButton,children:jsxRuntime.jsx(R,{tier:"control",style:n.retryLabel,children:h.addPet})}):null,e.retryable?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:h.retry,style:n.retryButton,children:jsxRuntime.jsx(R,{tier:"control",style:n.retryLabel,children:h.retry})}):null]})}i(gT,"ErrorState");function hT({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:o,onCopy:s,sentimentByMessage:a,onSentiment:l,thanksFor:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:f,onRetry:m,onStartNew:y,petRef:k,onFindVet:b,vet:E,onOpenUrl:w}){let{styles:T}=Re(),x=X();Cr(e.length,x);let g=react.useMemo(()=>fp(e),[e]),_=cd(e,n),O=e[e.length-1],M=react.useMemo(()=>e.filter(v=>!(v.checkin&&g.get(v.id)?.kind==="folded")),[e,g]),I=sf(M,n);return jsxRuntime.jsxs(reactNative.ScrollView,{ref:I.ref,style:T.list,contentContainerStyle:T.listContent,accessibilityLabel:h.transcript,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,onLayout:I.onLayout,onContentSizeChange:I.onContentSizeChange,onScroll:I.onScroll,scrollEventThrottle:CT,onScrollBeginDrag:I.onScrollBeginDrag,onScrollEndDrag:I.onScrollEnd,onMomentumScrollEnd:I.onScrollEnd,children:[e.map(v=>{let P=v.checkin?g.get(v.id):void 0;return P?.kind==="folded"?null:P?.kind==="past"?jsxRuntime.jsx(Sp,{text:v.text,runDueDays:P.runDueDays,openedAt:v.checkin?.openedAt,onLayout:I.rowLayout(v.id)},v.id):v.checkin&&P!==void 0?jsxRuntime.jsx(Ep,{message:v,checkin:v.checkin,onAnswer:o,petRef:k,onFindVet:b,vet:E,onLayout:I.rowLayout(v.id)},v.id):jsxRuntime.jsx(RT,{onLayout:I.rowLayout(v.id),message:v,revealing:n&&v===O&&v.role==="assistant",onCopy:s,sentiment:v.responseId===void 0?null:a[String(v.responseId)]??null,onSentiment:l,thanks:u!==null&&v.responseId!==void 0&&String(v.responseId)===u,images:d[v.id]??vT,onPreview:c,onOpenUrl:w},v.id)}),f?jsxRuntime.jsx(R,{tier:"compact",style:T.reconnectingCaption,accessibilityRole:"text",children:h.reconnecting}):null,_?jsxRuntime.jsx(tf,{}):null,p!==null?jsxRuntime.jsx(bT,{notice:p,onRetry:m,onStartNew:y}):null,jsxRuntime.jsx(mT,{prompts:t,onSelectPrompt:r})]})}i(hT,"PopulatedState");function bT({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=Re(),o=e.tone==="error";return jsxRuntime.jsxs(reactNative.View,{style:[n.turnNotice,o?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(R,{tier:"control",style:[n.turnNoticeTitle,o?n.turnNoticeTitleError:null],children:e.title}),jsxRuntime.jsx(R,{tier:"compact",style:n.turnNoticeBody,children:e.body}),jsxRuntime.jsx(reactNative.Pressable,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:Kt,style:n.turnNoticeAction,children:jsxRuntime.jsx(R,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}i(bT,"TurnNoticeCard");var vT=Object.freeze([]),CT=16,ET=14;function RT({message:e,revealing:t,onCopy:r,sentiment:n,onSentiment:o,thanks:s,images:a,onPreview:l,onOpenUrl:u,onLayout:d}){let{styles:c}=Re(),p=X(),f=Rt(p.messageInMs),m=Hd(e.text,t,p),y=e.role==="user",k=e.role==="vet",b=y?h.senderUser:k?fd(e):h.senderAssistant,E=react.useCallback(T=>o(e,T),[o,e]),w=e.pending!==true;return jsxRuntime.jsxs(reactNative.Animated.View,{style:[c.rowBlock,y?c.rowBlockUser:c.rowBlockAssistant,f],onLayout:d,children:[jsxRuntime.jsx(reactNative.View,{style:[c.row,y?c.rowUser:c.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${b}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:jsxRuntime.jsxs(reactNative.View,{style:[c.bubble,y?c.bubbleUser:k?c.bubbleVet:c.bubbleAssistant,e.pending?c.bubblePending:null],children:[y&&a.length>0?jsxRuntime.jsx(nc,{images:a,onPreview:T=>l({uri:T.uri,label:T.filename})}):null,k?jsxRuntime.jsx(R,{style:c.vetSender,children:b}):null,jsxRuntime.jsx(R,{style:y?c.bubbleTextUser:k?c.bubbleTextVet:c.bubbleTextAssistant,children:e.role==="assistant"?$p(m,{bold:c.bubbleBold,italic:c.bubbleItalic,code:c.bubbleCode}):e.text})]})}),e.role==="assistant"&&!t?jsxRuntime.jsx(Ap,{citations:e.citations,onOpenUrl:u}):null,w?jsxRuntime.jsx(Np,{message:e,onCopy:r,sentiment:n,onSentiment:e.responseId===void 0?void 0:E,thanks:s}):null]})}i(RT,"MessageRow");var xT=Object.freeze(["photo"]),_T=1;function ff(e){let{style:t,renderPending:r}=e;return jsxRuntime.jsx(ri,{capability:"chat",style:t,...r?{renderPending:r}:{},children:jsxRuntime.jsx(wT,{...e})})}i(ff,"EverfurChat");function wT({petRef:e,conversationId:t,style:r,renderPending:n,onCopy:o,onPetChange:s,onVetPrep:a,onFindVet:l,renderVetAction:u,attachments:d,pet:c,onAddPet:p,checkinTarget:f,initialAsk:m,composerSeed:y,lifecycle:k,draftStore:b,vetReturnTo:E,vetUsState:w,vetPrefer:T,onOpenUrl:x,keyboardVerticalOffset:g}){let{theme:_,styles:O}=Re(),M=X(),I=react.useMemo(()=>md(e,t),[e,t]),v=hr(I),P=ud(v),V=tp(),j=od(v),W=reactNativeSafeAreaContext.useSafeAreaInsets(),ne=dd(v),he=react.useMemo(()=>l===void 0?void 0:()=>{q(l,"emergency");},[l]),xe=react.useMemo(()=>E===void 0&&w===void 0&&T===void 0?void 0:{returnTo:E,usState:w,prefer:T},[E,w,T]),st=Gi(V.pets,v.petRef),fe=react.useMemo(()=>ad(v.messages,st?.name??null),[v.messages,st?.name]),Qe=ld(fe);Cr(Qe.showBanner,M),Qu(v.openCheckin,f),Wu(v.askEverfur,v.isBootstrapping,m);let Ar=react.useMemo(()=>di(y),[y]);Yu(k,{conversationId:v.conversationId===null?null:String(v.conversationId),isTurnInFlight:v.isStreaming,refresh:v.refreshActiveThread});let Or=(v.hasUnreadThreads??false)||j.rows.some(Se=>Se.unreadCount!==null&&Se.unreadCount>0)||(v.unreadCount??0)>0,It=zu(v.messages),[Xt,Wn]=react.useState(null),yf=react.useCallback(()=>Wn(null),[]),[Qt,Gn]=react.useState(null),[gf,ps]=react.useState(null),At=react.useRef(null);react.useEffect(()=>()=>{At.current&&clearTimeout(At.current);},[]);let fs=react.useCallback(Se=>{ps(String(Se)),At.current&&clearTimeout(At.current),At.current=setTimeout(()=>{ps(null),At.current=null;},lp);},[]),hf=react.useCallback((Se,Mr)=>{let Zt=Se.responseId;if(Zt===void 0)return;let Sf=v.sentimentByMessage[String(Zt)];v.feedback(Zt,Mr),Mr==="down"&&Sf!=="down"&&Gn(Zt);},[v]),bf=react.useCallback(async(Se,Mr)=>Qt===null||!(await v.feedback(Qt,"down",Se??"other",Mr)).ok?false:(Gn(null),fs(Qt),true),[v,Qt,fs]),vf=react.useCallback(()=>Gn(null),[]),Cf=react.useCallback(Se=>{v.send(Se);},[v.send]),Ef=react.useMemo(()=>x===void 0?void 0:Se=>{q(x,Se,"citation");},[x]),ms=reactNative.Platform.OS==="ios"?"padding":void 0,Fr=Yc(g,ms!==void 0),Rf=Fr.topInWindow===null?W.top:Math.max(0,W.top-Fr.topInWindow),ys={send:v.send,stop:v.stop,isStreaming:v.isStreaming,conversationId:v.conversationId,seed:Ar,draftStore:b,onStage:It.stage,onPreview:Wn};return jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:[O.container,{paddingTop:Rf},r],behavior:ms,...Fr.avoidingProps,children:[jsxRuntime.jsx(Xc,{probeRef:Fr.probeRef}),jsxRuntime.jsx(Bc,{pets:V,petRef:v.petRef,historyUnread:Or,onOpenHistory:j.show,onPetChange:s,onAddPet:p,vet:xe}),c!==void 0?jsxRuntime.jsx(IT,{petRef:e??null,pet:c,onRegistered:V.refresh}):null,jsxRuntime.jsx(ep,{surface:Qe,petRef:v.petRef,renderVetAction:u,onFindVet:l,vet:xe}),jsxRuntime.jsx(reactNative.View,{style:O.body,children:cf(P,v,{notice:ne,vet:xe,onCheckinFindVet:he,onSelectPrompt:Cf,renderPending:n,shownPet:st,onVetPrep:a,onCopy:o,onSentiment:hf,thanksFor:gf,imagesByMessage:It.byMessage,onPreview:Wn,onAddPet:p,onOpenUrl:Ef})}),d!==void 0?jsxRuntime.jsx(AT,{...ys,attachments:d}):jsxRuntime.jsx(mf,{...ys,attachments:null}),jsxRuntime.jsx(hd,{}),_.meta.hidePoweredBy?null:jsxRuntime.jsx(R,{tier:"compact",style:O.poweredBy,accessibilityRole:"text",accessibilityLabel:h.poweredBy,children:h.poweredBy}),jsxRuntime.jsx($c,{chat:v,history:j}),jsxRuntime.jsx(qc,{visible:Qt!==null,onSubmit:bf,onSkip:vf}),jsxRuntime.jsx(Bd,{uri:Xt?.uri??null,label:Xt?.label??"",onClose:yf}),jsxRuntime.jsx(Rr,{})]})}i(wT,"ChatBody");function IT({petRef:e,pet:t,onRegistered:r}){let{styles:n}=Re(),o=Hu(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(R,{tier:"compact",style:n.setupNoticeText,children:o.error.displayMessage}),jsxRuntime.jsx(reactNative.Pressable,{onPress:o.retry,accessibilityRole:"button",accessibilityLabel:h.retry,hitSlop:Kt,children:jsxRuntime.jsx(R,{tier:"control",style:n.setupNoticeAction,children:h.retry})})]})}i(IT,"PetSetupNotice");function AT({attachments:e,...t}){let r=react.useMemo(()=>ic(),[]),n=fn({maxPerMessage:e.maxPerMessage??_T,transport:r}),o=react.useMemo(()=>({state:n,sources:e.sources??xT,pick:e.pick}),[n,e.sources,e.pick]);return jsxRuntime.jsx(mf,{...t,attachments:o})}i(AT,"ComposerWithAttachments");function mf({send:e,stop:t,isStreaming:r,conversationId:n,attachments:o,seed:s,draftStore:a,onStage:l,onPreview:u}){let{theme:d,styles:c}=Re(),p=X(),[f,m]=ed(e,n,s);td(a,n===null?null:String(n),f,m);let[y,k]=react.useState(false),[b,E]=react.useState(false);react.useEffect(()=>{E(false);},[n]);let w=d.meta.placeholder??h.placeholder,T=o?.state.uploading??false,x=o?.state.failed??false,g=T||x,_=o?.state.attachments??OT;Cr(_.length,p);let O=react.useCallback(()=>{if(f.trim().length===0||g||[...f].length>Lt)return;let W=o?.state.s3Keys??FT;o!==null&&W.length>0?(l(o.state.attachments.filter(ne=>ne.status==="uploaded").map(ne=>({uri:ne.previewUri,filename:ne.filename}))),e(f,{imageS3Keys:W}),o.state.clear()):e(f),m(""),E(false);},[f,e,g,o,l]),M=react.useCallback(()=>{t();},[t]),I=react.useCallback(W=>{k(false),o!==null&&(E(false),o.state.dismissRejected(),Ht(o.pick,W).then(ne=>{if(!ne.ok){E(true);return}ne.value!==null&&o.state.add(ne.value);}));},[o]),P=react.useMemo(()=>[...f].length>Lt,[f])||g,V=o!==null&&_.length>=o.state.maxPerMessage,j=d.slots.sendButton?.textColor??d.color.brandInk;return jsxRuntime.jsxs(reactNative.View,{style:c.composerOuter,children:[o!==null&&y?jsxRuntime.jsx(Wd,{sources:o.sources,full:V,onPick:I,onClose:()=>k(false)}):null,jsxRuntime.jsxs(reactNative.View,{style:c.composer,children:[o!==null?jsxRuntime.jsx(rc,{attachments:_,rejected:b?MT:o.state.rejected,uploadFailed:x,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:W=>u({uri:W.previewUri,label:W.filename})}):null,jsxRuntime.jsxs(reactNative.View,{style:c.composerRow,children:[o!==null?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:Du(_.length,o.state.maxPerMessage),accessibilityState:{disabled:V,expanded:y},disabled:V,hitSlop:(Gt-Un)/2,style:[c.attachControl,V?c.attachControlDisabled:null],onPress:()=>k(W=>!W),children:jsxRuntime.jsx(Pd,{size:cp,color:V?d.color.text.muted:d.color.brandInk,strokeWidth:1.75})}):null,jsxRuntime.jsx(Ut,{style:c.input,value:f,onChangeText:m,placeholder:w,placeholderTextColor:d.slots.composerInput?.textColor??d.color.text.placeholder,onSubmitEditing:O,returnKeyType:"send",blurOnSubmit:false,multiline:true,editable:true}),r?jsxRuntime.jsx(reactNative.Pressable,{onPress:M,accessibilityRole:"button",accessibilityLabel:h.stop,hitSlop:Kt,style:c.sendControl,children:jsxRuntime.jsx(reactNative.View,{style:c.sendDisc,testID:"everfur-stop-disc",children:jsxRuntime.jsx(Od,{size:dp,color:j,testID:"everfur-stop-glyph"})})}):jsxRuntime.jsx(reactNative.Pressable,{onPress:O,disabled:P,accessibilityRole:"button",accessibilityLabel:h.send,accessibilityState:{disabled:P,busy:T},hitSlop:Kt,style:[c.sendControl,P?c.sendControlDisabled:null],children:jsxRuntime.jsx(reactNative.View,{style:c.sendDisc,testID:"everfur-send-disc",children:jsxRuntime.jsx(Ad,{size:up,color:j,testID:"everfur-send-glyph"})})})]})]})]})}i(mf,"Composer");var OT=Object.freeze([]),FT=Object.freeze([]),MT=Object.freeze({code:"unknown",retryable:true,filename:""});function VT(e){let{runtime:t,userRef:r,scopeEpoch:n}=Y(),o=react.useMemo(()=>Je(t.registry.services.authFor(r)),[t,r,n]),s=react.useMemo(()=>({repository:o,petRef:e}),[o,e]),[a,l]=react.useState({key:s,profile:null,loading:e!==null,error:null}),u=a.key===s?a:{profile:null,loading:e!==null,error:null},d=react.useRef(0),c=react.useCallback(async()=>{let p=++d.current;if(s.petRef===null){l({key:s,profile:null,loading:false,error:null});return}l(m=>({key:s,profile:m.key===s?m.profile:null,loading:true,error:null}));let f=await s.repository.getPetProfile(s.petRef);p===d.current&&l(f.ok?{key:s,profile:f.value,loading:false,error:null}:{key:s,profile:null,loading:false,error:f.error});},[s]);return react.useEffect(()=>(c(),()=>{d.current+=1;}),[c]),react.useMemo(()=>({profile:u.profile,loading:u.loading,error:u.error,refresh:c}),[u.profile,u.loading,u.error,c])}i(VT,"useEverfurPetProfile");function BT(e){return react.createElement(dn,{clientTheme:e.clientTheme??null,seams:pn,children:e.children})}i(BT,"EverfurThemeProvider");exports.CapabilityGate=ri;exports.EverfurChat=ff;exports.EverfurConfigError=Q;exports.EverfurProvider=Qh;exports.EverfurThemeProvider=BT;exports.EverfurThrownError=Lr;exports.THEME_SLOT_KEYS=hg;exports.THEME_SLOT_NAMES=gt;exports.canonicalPetSpecies=ur;exports.categoryFor=qn;exports.conversationId=Af;exports.createRnRecordsUploadTransport=Yf;exports.face=S;exports.isErr=kf;exports.isOk=Pf;exports.isRetryableCode=$n;exports.petRef=wf;exports.previewTheme=Gg;exports.unwrap=xf;exports.useCapability=Nt;exports.useChatAttachments=fn;exports.useEverfur=au;exports.useEverfurChat=hr;exports.useEverfurPetProfile=VT;exports.useEverfurPets=Pn;exports.useEverfurTheme=F;exports.userFacingError=Ot;exports.userRef=If;
|
|
11
|
+
`));}l(),r.end();},"onError");e.addEventListener("message",o),e.addEventListener("done",s),e.addEventListener("error",a);function l(){if(!n){n=true,e.removeEventListener("message",o),e.removeEventListener("done",s),e.removeEventListener("error",a);try{e.close();}catch{}}}return i(l,"cleanup"),Ym(r.source,l)}i($m,"eventSourceByteSource");async function*Ym(e,t){try{yield*e;}finally{t();}}i(Ym,"sourceWithCleanup");function Xm(){let e=[],t=false,r=null,n=i(()=>{if(r){let s=r;r=null,s();}},"signal");async function*o(){for(;;){let s=e.shift();if(s!==void 0){yield s;continue}if(t)return;await new Promise(a=>{r=a;});}}return i(o,"gen"),{source:o(),push:i(s=>{e.push(s),n();},"push"),end:i(()=>{t=true,n();},"end")}}i(Xm,"createByteQueue");async function Qm(e,t){let r=t.fetchImpl??fa(),n=ma(t.config.apiBaseUrl,e.path,e.query),o=ya(t.config,e.headers,"application/json",e.body!==void 0&&e.multipart===void 0),s=ny(qm),a=oy(s.signal,e.signal),l;try{l=await r(n,ga({...e,signal:a},o));}catch(d){return v(vo(d))}finally{s.cancel();}let u=await ha(l);return l.ok?L(u):v(ey(l.status,u,ca(l)))}i(Qm,"requestJson");function da(e){return {request:i(t=>Qm(t,e),"request"),stream:i((t,r)=>Zm(ry(t,r),e),"stream")}}i(da,"createHttpTransport");async function*Zm(e,t){let r=ma(t.config.apiBaseUrl,e.path,e.query),n=ya(t.config,e.headers,"text/event-stream",e.body!==void 0&&e.multipart===void 0);if(t.eventSourceFactory){let l=t.eventSourceFactory(r,Jm(e,n));yield*Zr($m(l),()=>ty(l));return}let o=t.fetchImpl??fa(),s;try{s=await o(r,ga(e,n));}catch(l){yield aa("",true,Ca(l));return}let a=ca(s);if(!s.ok){let l=await ha(s),u=ba(l)??pa(s.status),d=Ea(l)||Ge(Fe(u));yield aa(u,d,va(l),a);return}if(s.body){yield*Zr(sa(s.body),a);return}yield*Zr(sa(null),a);}i(Zm,"streamFrames");function Jm(e,t){return {method:e.method,headers:t,pollingInterval:0,...e.body!==void 0?{body:JSON.stringify(e.body)}:{}}}i(Jm,"buildEventSourceInit");function ey(e,t,r){let n=ba(t),o=n?Fe(n):Ds(e),s=va(t);return D(o,{httpStatus:e,...Ea(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...la(t)?{reasonCode:la(t)}:{},...s?{wireMessage:s}:{},...t!=null?{raw:t}:{}})}i(ey,"errorFromResponse");function vo(e){return D("internalError",{retryable:true,wireMessage:Ca(e)})}i(vo,"networkError");function ca(e){let t=e.headers.get(ua);return typeof t=="string"&&t.length>0?t:null}i(ca,"requestIdOf");function ty(e){if(typeof e.getResponseHeader!="function")return null;let t;try{t=e.getResponseHeader(ua);}catch{return null}return typeof t=="string"&&t.length>0?t:null}i(ty,"eventSourceRequestId");function pa(e){return e===401?"AUTH_EXPIRED":e===403?"ACCESS_DENIED":e===404?"NOT_FOUND":e===409?"IDEMPOTENCY_CONFLICT":e===421?"MISDIRECTED_REQUEST":e===429?"RATE_LIMITED":e===400||e===422?"INVALID_REQUEST":e===503||e>=500?"INTERNAL_ERROR":""}i(pa,"statusToWireCode");function aa(e,t,r,n=null){return ye({code:e,retryable:t,wireMessage:r,synthesized:true,lastEventId:null,serverRequestId:n})}i(aa,"syntheticErrorFrame");function fa(){let e=globalThis.fetch;if(typeof e!="function")throw new re("missing-peer-dependency","global fetch is unavailable; provide config.transport or an injected fetch implementation");return e}i(fa,"getGlobalFetch");function ma(e,t,r){let n=t.startsWith("/")?t:`/${t}`,o=`${e}${n}`;if(r){let s=Object.entries(r).filter(a=>a[1]!==void 0).map(([a,l])=>`${encodeURIComponent(a)}=${encodeURIComponent(String(l))}`).join("&");s&&(o+=`?${s}`);}return o}i(ma,"buildUrl");function ya(e,t,r,n){let o={...ia(e),accept:r};return n&&(o["content-type"]="application/json"),t&&Object.assign(o,t),o}i(ya,"mergeHeaders");function ga(e,t){let r={method:e.method,headers:t};return e.multipart!==void 0?r.body=e.multipart:e.body!==void 0&&(r.body=JSON.stringify(e.body)),e.signal&&(r.signal=e.signal),r}i(ga,"buildInit");function ry(e,t){return e.signal?e:{...e,signal:t}}i(ry,"withSignal");function ny(e){let t=new AbortController,r=setTimeout(()=>t.abort(),e);return {signal:t.signal,cancel:i(()=>clearTimeout(r),"cancel")}}i(ny,"timeoutSignal");function oy(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(oy,"mergeAbortSignals");async function ha(e){try{return await e.json()}catch{return null}}i(ha,"safeJson");function la(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}i(la,"extractReasonCode");function ba(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?r:null}i(ba,"extractWireCode");function va(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}i(va,"extractWireMessage");function Ea(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}i(Ea,"extractRetryable");function Ca(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(Ca,"describeCause");var iy=3e4,sy=co*2,ay="idempotency-key",ly=new Set(["POST","PUT","PATCH","DELETE"]),uy=Object.freeze({onEvent(){}}),dy=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function cy(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}i(cy,"seededIdempotencyKey");function Ie(e){let t=e.observer??uy,r=e.timers??dy,n=e.rng??Math.random,o=e.sleep??((f,m)=>Py(f,r,m)),s=e.maxAttempts??rr,a=e.unaryTimeoutMs??iy,l=e.newIdempotencyKey??fy(),u=i(f=>{try{t.onEvent(f);}catch{}},"emit");async function d(f,m,h){let T=h?.maxAttempts,b=Math.max(1,T??s),S=h?.idempotent??ly.has(m.method),P=h?.idempotencyKey===void 0?null:cy(h.idempotencyKey),k=S?P??l():null,x=py(m,k),y=0;for(;;){let _=i(H=>Object.freeze({call:f,method:m.method,path:m.path,attempt:y,...k?{idempotencyKey:k}:{},...H}),"stamp");u(_({phase:"attempt"}));let A=Sy(a,r),O=Ty(A.signal,m.signal),F;try{F=await Js({...x,signal:O.signal},e.auth);}catch(H){F=v(vo(H));}finally{O.dispose(),A.cancel();}if(F.ok)return u(_({phase:"settled",ok:true,reason:"ok"})),F;let C=F.error,w=yy(C,y,{maxAttempts:b,rng:n,now:r.now(),aborted:m.signal?.aborted===true,...T!==void 0?{perCallMaxAttempts:T}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),I={ok:false,code:C.code,reason:w.reason,...C.httpStatus!==void 0?{httpStatus:C.httpStatus}:{},...C.requestId!==void 0?{requestId:C.requestId}:{}};if(!w.retry)return u(_({phase:"settled",...I})),v(C);if(u(_({phase:"retry",...I,delayMs:w.delayMs})),await o(w.delayMs,m.signal),m.signal?.aborted===true)return u(_({phase:"settled",...I,reason:"aborted"})),v(C);y+=1;}}i(d,"send");async function c(f){return nr(f,await Ry(e.auth))}i(c,"authorize");async function*p(f,m,h){u(Object.freeze({call:f,phase:"stream.open",method:m.method,path:m.path,attempt:0}));try{yield*e.auth.transport.stream(m,h);}catch{yield ye({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(p,"stream"),Object.freeze({send:d,authorize:c,stream:p})}i(Ie,"createRequestFunnel");function py(e,t){let r={};for(let[n,o]of Object.entries(e.headers??{}))n.toLowerCase()!==ay&&(r[n]=o);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(py,"assembleHeaders");function fy(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(fy,"defaultIdempotencyKeyFactory");var my=10;function yy(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let n=gy(e);if(n==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!Ge(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 a=i(()=>{if(r.policy===void 0)return null;let d;try{d=r.policy.maxAttempts(e.code);}catch{return null}return typeof d!="number"||!Number.isFinite(d)?null:Math.max(1,Math.min(my,Math.floor(d)))},"policyCeiling"),l=r.perCallMaxAttempts??a()??r.maxAttempts;if(t+1>=l)return {retry:false,reason:"attempts-exhausted"};let u=hy(e,r.now);return u!==null?u>sy?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:o,delayMs:u}:{retry:true,reason:o,delayMs:$r(t,r.rng)}}i(yy,"decideRetry");function gy(e){let t=e.code==="unknown"?Fe(Cy(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(gy,"throttleKind");function hy(e,t){let r=vy(e.raw);if(r!==null){let o=r-t;return o>0?o:0}let n=by(e.raw);return n===null?null:Math.round(n*1e3)}i(hy,"retryOverrideMs");function by(e){for(let t of Eo(e)){let r=t.retry_after_seconds;if(typeof r=="number"&&Number.isFinite(r)&&r>=0)return r}return null}i(by,"findRetryAfterSeconds");function vy(e){for(let t of Eo(e)){let r=t.resets_at,n=Ey(r);if(n!==null)return n}return null}i(vy,"findResetsAt");function Eo(e){if(!Ra(e))return [];let t=[e];for(let r of ["error","detail"]){let n=e[r];Ra(n)&&t.push(n);}return t}i(Eo,"candidateScopes");function Ey(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(Ey,"parseInstantMs");function Cy(e){for(let t of Eo(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i(Cy,"rawWireCode");function Ra(e){return typeof e=="object"&&e!==null}i(Ra,"isRecord");async function Ry(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(Ry,"resolveDeviceAuth");function Sy(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(n),"cancel")}}i(Sy,"boundedSignal");function Ty(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(Ty,"mergeSignals");function Py(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let o=t.setTimeout(()=>{r?.removeEventListener("abort",s),n();},e),s=i(()=>{t.clearTimeout(o),n();},"onAbort");r?.addEventListener("abort",s,{once:true});})}i(Py,"delayAbortable");var en=Object.freeze(["better","same","worse"]),Ro=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Sa(e){return v(D("validationFailed",{retryable:false,wireMessage:e}))}i(Sa,"invalid");function Co(){return v(D("internalError",{retryable:false}))}i(Co,"malformed");function Ta(e){return typeof e!="string"||e.trim().length===0?D("validationFailed",{retryable:false,wireMessage:"pet_ref must not be blank"}):Ce(e)?D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}):`/widget/v1/pets/${encodeURIComponent(e)}/cases`}i(Ta,"petPath");var Ke=i(e=>typeof e=="string"?e:null,"str"),Pa=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"count");function ka(e){if(typeof e!="object"||e===null)return null;let t=e,r=Ke(t.case_id),n=Ke(t.status);if(r===null||n===null)return null;let o=Ke(t.last_response);return Object.freeze({caseId:r,status:n,bodyLocation:Ke(t.body_location),lastResponse:o!==null&&en.includes(o)?o:null,checkInDueAt:Ke(t.check_in_due_at),openedAt:Ke(t.opened_at),resolvedAt:Ke(t.resolved_at),resolutionText:Ke(t.resolution_text),checkinAskCount:Pa(t.checkin_ask_count),checkinAnswerCount:Pa(t.checkin_answer_count)})}i(ka,"caseFromWire");function xa(e){return {async list(t,r){let n=Ta(t);if(typeof n!="string")return v(n);let o=await e.send("cases.list",{method:"GET",path:n,...r?.signal?{signal:r.signal}:{}});if(!o.ok)return v(o.error);let s=typeof o.value=="object"&&o.value!==null?o.value.cases:null;if(!Array.isArray(s))return Co();let a=s.map(ka);return a.every(l=>l!==null)?L(Object.freeze(a)):Co()},async checkin(t,r,n,o){let s=Ta(t);if(typeof s!="string")return v(s);if(typeof r!="string"||!Ro.test(r))return Sa("case_id must be a UUID");if(!en.includes(n))return Sa("response must be one of better, same, worse");let a=await e.send("cases.checkin",{method:"POST",path:`${s}/${r}/checkin`,body:{response:n},...o?.signal?{signal:o.signal}:{}});if(!a.ok)return v(a.error);let l=typeof a.value=="object"&&a.value!==null?a.value:{},u=ka(l.case);return u===null?Co():L(Object.freeze({case:u,ctaDeepLink:Ke(l.cta_deep_link)}))}}}i(xa,"createCasesRepositoryOver");var _a=Object.freeze({async presignedPut(){return Promise.reject(new Error("UploadPort is unavailable; no presigned-upload adapter was injected"))}});var wa=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function rn(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let o={handle:void 0},s=i(()=>{r.clearTimeout(o.handle),t.removeEventListener("abort",s),n();},"done");o.handle=r.setTimeout(s,e),t.addEventListener("abort",s,{once:true});})}i(rn,"delayAbortable");function nn(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(nn,"mergeSignals");var So=class So{constructor(t){this.listeners=new Set;this.epoch=0;this.inFlight=null;this.snapshot=Object.freeze({...t});}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t);}}getSnapshot(){return this.snapshot}patch(t){this.snapshot=Object.freeze({...this.snapshot,...t});for(let r of this.listeners)r();}beginOperation(t){this.inFlight?.abort();let r=new AbortController;this.inFlight=r;let n=this.epoch;return {signal:t?nn(r.signal,t):r.signal,epoch:n,settle:i(()=>{this.inFlight===r&&(this.inFlight=null);},"settle")}}alive(t){return t===this.epoch}rescope(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null;}dispose(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null,this.listeners.clear();}};i(So,"MediaStore");var tn=So;function Po(e,t,r){return Object.freeze({id:e,role:"user",text:t,createdAt:r,pending:true})}i(Po,"makeUser");function ko(e,t,r){return Object.freeze({id:e,role:"assistant",text:t,createdAt:r})}i(ko,"makeAssistant");function sr(e){return Object.freeze({id:e.id,role:e.role,text:e.text,createdAt:e.createdAt})}i(sr,"stripPending");function Ia(e,t){let r={id:e.id,role:e.role,text:e.text+t,createdAt:e.createdAt};return e.citations&&(r.citations=e.citations),e.responseId&&(r.responseId=e.responseId),Object.freeze(r)}i(Ia,"appendText");function xo(e,t){let r={id:t.messageId?t.messageId:e.id,role:"assistant",text:e.text,createdAt:e.createdAt};return t.citations.length>0&&(r.citations=t.citations),t.messageId&&(r.responseId=t.messageId),r.urgencyLevel=t.urgencyLevel,r.urgencyReason=t.urgencyReason,r.urgencyProvided=t.urgencyProvided,Object.freeze(r)}i(xo,"finalizeAssistant");function Aa(e){return Object.freeze({status:e.status,messages:Object.freeze([...e.messages]),conversationId:e.conversationId,error:e.error,isStreaming:e.isStreaming,isBootstrapping:e.isBootstrapping,suggestedPrompts:Object.freeze([...e.suggestedPrompts]),unreadCount:e.unreadCount})}i(Aa,"freezeSnapshot");function U(e,t,r){return D(e,{retryable:t,...r?{wireMessage:r}:{}})}i(U,"makeError");function _o(e){let t=Fe(e.code);return D(t,{retryable:e.retryable||qr(t),wireCode:e.code,wireEnvelope:"sse_frame",...e.serverRequestId?{requestId:e.serverRequestId}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},raw:e})}i(_o,"errorFromFrame");function Me(e){return ye({code:ky(e.code),retryable:e.retryable,wireMessage:e.wireMessage??null,synthesized:true,lastEventId:null,serverRequestId:e.requestId??null})}i(Me,"synthErrorFrame");function ky(e){switch(e){case "authExpired":return "AUTH_EXPIRED";case "authRejected":return "AuthorizationException";case "sessionRequired":return "session_required";case "accessDenied":return "ACCESS_DENIED";case "paymentRequired":return "TIER_UPGRADE_REQUIRED";case "quotaExceeded":return "QUOTA_EXCEEDED";case "rateLimited":return "RATE_LIMITED";case "validationFailed":return "ValidationException";case "sdkUpdateRequired":return "invalidRequest";case "conflict":return "ConflictException";case "idempotencyConflict":return "IDEMPOTENCY_CONFLICT";case "idempotencyInFlight":return "IDEMPOTENCY_KEY_IN_FLIGHT";case "conversationNotFound":return "CONVERSATION_NOT_FOUND";case "petNotFound":return "PET_NOT_FOUND";case "resourceNotFound":return "ResourceNotFoundException";case "streamTimeout":return "STREAM_TIMEOUT";case "mediaUploadFailed":return "MEDIA_UPLOAD_FAILED";case "moderationBlocked":return "MODERATION_BLOCKED";case "upstreamLlmTimeout":return "UPSTREAM_LLM_TIMEOUT";case "internalError":return "INTERNAL_ERROR";case "notImplemented":return "NotImplementedException";case "serviceUnavailable":return "ServiceUnavailableException";case "streamIncomplete":return "STREAM_INCOMPLETE";case "unknown":return "UNKNOWN";default:return at(e)}}i(ky,"canonicalWireCode");function Oa(e){let t=Array.isArray(e)?e:To(e)&&Array.isArray(e.categories)?e.categories:[],r=[];for(let n of t){if(!To(n))continue;let o=ir(n.category)??ir(n.title)??"",s=xy(n.prompts??n.questions);o.length===0&&s.length===0||r.push(Object.freeze({category:o,prompts:Object.freeze(s)}));}return Object.freeze(r)}i(Oa,"parsePromptCategories");function wo(e){let t=new Set,r=[];for(let n of e)for(let o of n.prompts){let s=o.trim();s.length===0||t.has(s)||(t.add(s),r.push(s));}return r}i(wo,"flattenPrompts");function To(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(To,"isPlainObject");function ir(e){return typeof e=="string"?e:null}i(ir,"asStr");function xy(e){if(!Array.isArray(e))return [];let t=[];for(let r of e)if(typeof r=="string")t.push(r);else if(To(r)){let n=ir(r.text)??ir(r.prompt)??ir(r.title);n!==null&&t.push(n);}return t}i(xy,"asPromptTextList");function Fa(){let e=0;return ()=>`m-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,8)}`}i(Fa,"defaultIdFactory");function Ma(){let e=0;return ()=>`chat-send-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(Ma,"defaultIdempotencyFactory");var Na={setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")};async function*Da(e,t,r,n){let o=e[Symbol.asyncIterator](),s=La(t.overallMs,n),a=La(t.idleMs,n),l=Iy(r);try{for(;;){if(r.aborted)return;let u=o.next().then(p=>({tag:"next",value:p}),()=>({tag:"streamError"})),d=await Promise.race([u,a.promise.then(()=>({tag:"idle"})),s.promise.then(()=>({tag:"overall"})),l.then(()=>({tag:"abort"}))]);if(d.tag==="abort")return;if(d.tag==="streamError"){if(r.aborted)return;yield wy();return}if(d.tag==="idle"||d.tag==="overall"){yield _y();return}let c=d.value;if(c.done||(a.reset(t.idleMs),yield c.value,c.value.terminal))return}}finally{a.cancel(),s.cancel(),Promise.resolve(o.return?.(void 0)).catch(()=>{});}}i(Da,"withWatchdog");function _y(){return ye({code:"STREAM_TIMEOUT",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(_y,"synthTimeoutFrame");function wy(){return ye({code:"STREAM_INCOMPLETE",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(wy,"synthStreamErrorFrame");function La(e,t){let r=i(()=>{},"resolveFn"),n=new Promise(s=>{r=s;}),o=t.setTimeout(()=>r(),e);return {promise:n,reset(s){t.clearTimeout(o),o=t.setTimeout(()=>r(),s);},cancel(){t.clearTimeout(o);}}}i(La,"deadline");function Iy(e){return new Promise(t=>{if(e.aborted){t();return}e.addEventListener("abort",()=>t(),{once:true});})}i(Iy,"abortPromise");var Ay="checkin",Oy=/^\d{4}-\d{2}-\d{2}$/,on="watching";function Ua(e){return e.status!=null&&e.status!==on}i(Ua,"isCheckinSettled");function Va(e){let{askCount:t,answerCount:r}=e;return typeof t!="number"||!Number.isFinite(t)||typeof r!="number"||!Number.isFinite(r)||t<=0?true:r>=t}i(Va,"isLiveAskAnswered");function Io(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,o]=t;return r!==Ay||n===void 0||o===void 0||!Ro.test(n)||!Oy.test(o)?null:{caseId:n,dueDay:o}}i(Io,"parseCheckinOrigin");function Ba(e){return Io(e)?.caseId??null}i(Ba,"parseCheckinOriginRef");function Oo(e,t){if(e?.limit!==void 0&&(!Number.isInteger(e.limit)||e.limit<1||e.limit>t))return v(D("validationFailed"));let r=[];for(let[n,o]of [["cursor",e?.cursor],["pet_ref",e?.petRef]])if(o!==void 0){if(typeof o!="string"||o.length===0||Ce(o))return v(D("validationFailed"));r.push(`${n}=${encodeURIComponent(o)}`);}return e?.limit!==void 0&&r.push(`limit=${e.limit}`),L(r.length?`?${r.join("&")}`:"")}i(Oo,"historyQuery");function lr(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}i(lr,"validConversationId");function Vt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}i(Vt,"object");function Ha(e){return e==null||typeof e=="string"&&e.length>0&&!Ce(e)}i(Ha,"cursor");function ar(){return v(D("internalError",{retryable:false}))}i(ar,"malformed");function za(e){let t=Vt(e);if(!t||!Array.isArray(t.conversations)||!Ha(t.next_cursor))return ar();let r=[];for(let n of t.conversations){let o=Vt(n);if(!o||typeof o.conversation_id!="string"||!lr(o.conversation_id)||!(o.title==null||typeof o.title=="string")||typeof o.created_at!="string"||typeof o.updated_at!="string")return ar();let s=o.unread_message_count;if(!(s==null||Number.isInteger(s)&&s>=0))return ar();r.push(Object.freeze({id:o.conversation_id,title:o.title??null,createdAt:o.created_at,updatedAt:o.updated_at,unreadCount:s??null}));}return L(Object.freeze({conversations:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(za,"mapConversationPage");function ja(e){let t=Vt(e);if(!t||!Array.isArray(t.messages)||!Ha(t.next_cursor))return ar();let r=[],n=new Set;for(let o of t.messages){let s=Vt(o);if(!s||typeof s.message_id!="string"||!lr(s.message_id)||typeof s.role!="string"||typeof s.content!="string"||typeof s.created_at!="string")return ar();if(s.role!=="user"&&s.role!=="assistant"&&s.role!=="vet"||n.has(s.message_id))continue;if(n.add(s.message_id),s.role==="vet"){r.push(Fy(s,s.message_id,s.content,s.created_at));continue}let a=typeof s.proactive_origin_ref=="string"?s.proactive_origin_ref:null,l=s.role==="assistant"?Ba(a):null;r.push(Object.freeze({id:s.message_id,role:s.role,text:s.content,createdAt:s.created_at,...s.role==="assistant"?{responseId:s.message_id}:{},...s.urgency_level!==void 0?{urgencyLevel:My(s.urgency_level)}:{},...Array.isArray(s.citations)?{citations:Ly(s.citations)}:{},...a!==null?{proactiveOriginRef:a}:{},...l!==null?{checkin:Object.freeze({caseId:l,answer:null,resolutionText:null,status:null})}:{}}));}return L(Object.freeze({messages:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(ja,"mapMessagePage");function Fy(e,t,r,n){let o=Vt(e.sender),s=Ao(o?.display_name)??Ao(e.sender_display_name),a=Ao(o?.specialty);return Object.freeze({id:t,role:"vet",text:r,createdAt:n,sender:Object.freeze({displayName:s,specialty:a})})}i(Fy,"vetMessage");function Ao(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&!Ce(t)?t:null}i(Ao,"trimmedText");function My(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(My,"normalizeUrgency");function Ly(e){let t=["source_name","source_abbrev","section","authority_tier","doi","url","title","year","study_type","journal","excerpt","monograph_chunk_id"];return Object.freeze(e.flatMap(r=>{let n=Vt(r);if(!n||typeof n.source_name!="string"||typeof n.authority_tier!="string")return [];let o={};for(let s of t){let a=n[s];(typeof a=="string"||a===null)&&(o[s]=a);}return [Object.freeze(o)]}))}i(Ly,"historyCitations");var Fo=Object.freeze(["helpful","neutral","not_helpful","wrong","outdated","dangerous","unclear"]),Bt=4e3;var Ht=4e3;function Wa(e){return e===void 0?null:!Array.isArray(e)||e.length>5?{reason:"too_many_images",error:U("validationFailed",false,`image_s3_keys accepts at most ${5} keys`)}:e.some(t=>typeof t!="string"||t.trim().length===0)?{reason:"bad_image_key",error:U("validationFailed",false,"image_s3_keys must be non-empty strings")}:null}i(Wa,"validateImageKeys");function Lo(e){let t=typeof e=="string"?e:"";if(t.trim().length===0)return {reason:"empty",error:U("validationFailed",false,"message is empty or whitespace-only")};let r=[...t].length;return r>Ht?{reason:"too_long",error:U("validationFailed",false,`message is ${r} characters; the server accepts at most ${Ht}`)}:null}i(Lo,"validateMessageText");function Ga(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(Ga,"urgencyTier");async function*ur(e){yield e;}i(ur,"singleFrameStream");async function*Ka(){}i(Ka,"emptyStream");var Ny=6e4,Dy=18e4,Uy=24,Vy=512,By=false;function qa(e){return new No(e)}i(qa,"createChatController");var Do=class Do extends tn{constructor(r){super(Aa({status:"idle",messages:[],conversationId:r.initialConversationId??null,error:null,isStreaming:false,isBootstrapping:false,suggestedPrompts:[],unreadCount:null}));this.handlerTeardowns=new Set;this.lastTurn=null;this.unadoptedCreate=null;this.lastResponseIdValue=null;this.historyGeneration=0;this.disposed=false;this.bootstrapPrompts=[];this.scopePrompts=[];this.replyPrompts=null;this.unreadByConversation=new Map;this.classifiedMessageIds=new Set;this.pendingDelta="";this.flushHandle=null;this.auth=r.auth,this.funnel=r.funnel??Ie({auth:r.auth,...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),this.petRef=r.petRef??null,this.cases=xa(this.funnel),this.telemetry=r.telemetry??Qr,this.errorPolicy=r.errorPolicy??js,this.timers=r.timers??Na,this.rng=r.rng??Math.random,this.newId=r.newId??Fa(),this.makeIdempotencyKey=r.makeIdempotencyKey??Ma(),this.budget={idleMs:r.budget?.idleMs??Ny,overallMs:r.budget?.overallMs??Dy};}patch(r){if(r.messages!==void 0){let n=Object.freeze([...r.messages]);super.patch({...r,messages:n});return}super.patch(r);}send(r,n,o){let s=n??{};if(this.disposed||this.snapshot.isBootstrapping){let u=U(this.disposed?"accessDenied":"internalError",!this.disposed);return o?(o.onError(u),()=>{}):ur(Me(u))}let a=Lo(r)??Wa(s.imageS3Keys);if(a!==null)return this.telemetry.track("chat.send.rejected",{reason:a.reason}),this.patch({status:"error",isStreaming:false,error:a.error}),o?(o.onError(a.error),()=>{}):ur(Me(a.error));if(o)return this.driveWithHandlers(r,s,o);let l=this.beginTurn(r,s);return this.runTurn(l,s.signal)}askEverfur(r,n){if(this.disposed)return ur(Me(U("accessDenied",false)));let o=Lo(r);return o!==null?(this.telemetry.track("chat.send.rejected",{reason:o.reason}),ur(Me(o.error))):(this.resetThread(),this.send(r,n??{}))}retryLast(){let r=this.lastTurn;if(r===null){let s=this.snapshot.conversationId;return s!==null&&this.snapshot.status==="error"?this.retryHistory(s):Ka()}r.assistantMessageId=null,r.sawDelta=false,r.conversationIdOverride=null,this.discardPendingDelta();let o=this.snapshot.messages.some(s=>s.id===r.userMessageId)?this.snapshot.messages:[...this.snapshot.messages,Po(r.userMessageId,r.text,this.stamp())];return this.patch({error:null,stopped:false,messages:o}),this.runTurn(r,void 0)}stop(){this.inFlight?.abort(),this.inFlight=null,this.discardPendingDelta(),this.telemetry.track("chat.cancel",{});let r=this.snapshot.messages.some(o=>o.role==="user"&&o.pending===true),n=r?this.snapshot.messages.map(o=>o.pending===true?sr(o):o):this.snapshot.messages;(this.snapshot.status==="streaming"||r)&&this.patch({status:"idle",isStreaming:false,reconnecting:false,...r?{messages:n,stopped:true}:{}});}rescope(){this.resetThread(),this.scopePrompts=[],this.unreadByConversation.clear(),this.classifiedMessageIds.clear(),this.reflectUnreadDot();}resetThread(r=[]){super.rescope(),this.historyGeneration+=1,this.unadoptedCreate=null,this.lastTurn=null,this.lastResponseIdValue=null,this.bootstrapPrompts=r,this.replyPrompts=null,this.discardPendingDelta(),this.patch({status:"idle",isStreaming:false,messages:[],conversationId:null,error:null,suggestedPrompts:r,historyCursor:null,isLoadingHistory:false,isBootstrapping:false,unreadCount:null,stopped:false,reconnecting:false});}newConversation(){this.disposed||this.resetThread(this.scopePrompts);}dispose(){this.rescope(),this.disposed=true,this.unadoptedCreate=null,this.discardPendingDelta();for(let r of this.handlerTeardowns)r();this.handlerTeardowns.clear(),super.dispose();}adoptConversation(r){this.disposed||(this.unadoptedCreate=null,this.snapshot.conversationId!==r&&this.patch({conversationId:r}));}adoptPrompts(r){if(this.disposed)return;let n=Object.freeze(wo(r));this.bootstrapPrompts=n,this.scopePrompts=n,this.replyPrompts===null&&(n.length===0&&this.snapshot.suggestedPrompts.length===0||this.patch({suggestedPrompts:n}));}async listConversations(r){return this.listConversationsWith(r)}async listConversationsWith(r,n){let o=Oo(r,100);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return v(U("accessDenied",false));let a=await this.authedUnary("chat.listConversations",{method:"GET",path:`/widget/v1/conversations${o.value}`},r?.signal,n);if(!this.alive(s)||this.disposed)return v(U("accessDenied",false));if(!a.ok)return a;let l=za(a.value);if(l.ok){for(let c of l.value.conversations)c.unreadCount!==null&&this.unreadByConversation.set(c.id,c.unreadCount);let u=this.snapshot.conversationId,d=u===null?void 0:this.unreadByConversation.get(u);d!==void 0&&d!==this.snapshot.unreadCount&&this.patch({unreadCount:d}),this.reflectUnreadDot();}return l}reflectUnreadDot(){let r=false;for(let n of this.unreadByConversation.values())if(n>0){r=true;break}r!==(this.snapshot.hasUnreadThreads??false)&&this.patch({hasUnreadThreads:r});}async openCheckin(r){if(this.disposed)return v(U("accessDenied",false));let n=r?.conversationId??null;if(n!==null){let u=await this.resumeConversation(n);return u.ok?L(n):v(u.error)}let o=r?.petRef??this.petRef,s=await this.listConversations({...o===null?{}:{petRef:o},limit:1});if(!s.ok)return v(s.error);let a=s.value.conversations[0];if(a===void 0)return L(null);let l=await this.resumeConversation(a.id);return l.ok?L(a.id):v(l.error)}async markRead(r){if(this.disposed)return v(U("accessDenied",false));let n=this.snapshot.conversationId;if(n===null)return L(void 0);let o=this.epoch,s=await this.authedUnary("chat.markRead",{method:"POST",path:`/widget/v1/conversations/${n}/read`},r?.signal);return !this.alive(o)||this.disposed?v(U("accessDenied",false)):s.ok?(this.unreadByConversation.set(n,0),this.snapshot.conversationId===n&&this.snapshot.unreadCount!==0&&this.patch({unreadCount:0}),this.reflectUnreadDot(),L(void 0)):v(s.error)}async submitFeedback(r,n,o,s){if(this.disposed)return v(U("accessDenied",false));if(typeof r!="string"||r.trim().length===0||Ce(r))return v(U("validationFailed",false,"feedback needs the server message id of an assistant reply"));if(!Fo.includes(n))return v(U("validationFailed",false,`feedback_type must be one of ${Fo.join(", ")}`));let a=typeof o=="string"?o.trim():"";if([...a].length>Bt)return v(U("validationFailed",false,`notes is over ${Bt} characters`));let l={feedback_type:n};a.length>0&&(l.notes=a);let u=this.epoch,d=await this.authedUnary("chat.submitFeedback",{method:"POST",path:`/widget/v1/messages/${encodeURIComponent(r)}/feedback`,body:l},s?.signal);if(!this.alive(u)||this.disposed)return v(U("accessDenied",false));if(!d.ok)return v(d.error);let c=d.value?.feedback_id;return L(Object.freeze({feedbackId:typeof c=="string"?c:""}))}async answerCheckin(r,n,o){if(this.disposed)return v(U("accessDenied",false));let s=o?.petRef??this.petRef;if(s===null)return v(U("validationFailed",false,"a check-in needs the pet the case belongs to"));let a=this.epoch,l=await this.cases.checkin(s,r,n,o?.signal?{signal:o.signal}:{});if(!this.alive(a)||this.disposed)return v(U("accessDenied",false));if(!l.ok)return l;let u=l.value.case.openedAt,d=Object.freeze({caseId:r,answer:n,resolutionText:l.value.case.resolutionText,status:l.value.case.status??null,...u!==null?{openedAt:u}:{}}),c=i(p=>p.checkin?.caseId===r,"carries");return this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,checkin:d}):p)}),l}async getMessages(r,n){if(!lr(r))return v(U("validationFailed",false));let o=Oo(n,200);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return v(U("accessDenied",false));let a=await this.authedUnary("chat.getMessages",{method:"GET",path:`/widget/v1/conversations/${r}/messages${o.value}`},n?.signal);return !this.alive(s)||this.disposed?v(U("accessDenied",false)):a.ok?ja(a.value):a}async resumeConversation(r){if(this.disposed)return v(U("accessDenied",false));if(!lr(r))return v(U("validationFailed",false));this.resetThread();let n=this.historyGeneration;this.patch({conversationId:r,isBootstrapping:true,isLoadingHistory:true});let o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return v(U("accessDenied",false));if(!o.ok)return this.patch({status:"error",error:o.error,isBootstrapping:false,isLoadingHistory:false}),o;let s=this.unreadByConversation.get(r)??null;return this.patch({messages:o.value.messages,historyCursor:o.value.nextCursor,isBootstrapping:false,isLoadingHistory:false,unreadCount:s}),this.stampCheckinStatuses(n),s!==null&&s>0&&this.markRead(),L(void 0)}async stampCheckinStatuses(r){let n=this.petRef;if(n===null||!this.snapshot.messages.some(d=>d.checkin!==void 0&&d.checkin.status===null))return;let o=await this.cases.list(n);if(!o.ok||r!==this.historyGeneration||this.disposed)return;let s=new Set(o.value.filter(d=>d.status===on).map(d=>d.caseId)),a=new Map(o.value.map(d=>[d.caseId,d])),l=false,u=this.snapshot.messages.map(d=>{let c=d.checkin;if(c===void 0||c.status!==null)return d;l=true;let p=a.get(c.caseId),f=c.openedAt??p?.openedAt??null,m=s.has(c.caseId),h=p!==void 0&&(!m||Va({askCount:p.checkinAskCount,answerCount:p.checkinAnswerCount}))?p.lastResponse:null;return Object.freeze({...d,checkin:Object.freeze({...c,status:m?on:p?.status??"resolved",answer:c.answer??h,resolutionText:c.resolutionText??p?.resolutionText??null,...f!==null?{openedAt:f}:{}})})});l&&this.patch({messages:u});}async refreshActiveThread(){if(this.disposed)return v(U("accessDenied",false));let r=this.snapshot.conversationId;if(r===null||this.snapshot.isStreaming)return L(void 0);let n=this.historyGeneration,o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return v(U("accessDenied",false));if(!o.ok)return v(o.error);let s=new Set(this.snapshot.messages.map(l=>l.id)),a=o.value.messages.filter(l=>!s.has(l.id));return a.length>0&&this.patch({messages:[...this.snapshot.messages,...a]}),await this.listConversationsWith({...this.petRef===null?{}:{petRef:this.petRef},limit:1},{maxAttempts:1}),L(void 0)}async loadOlderMessages(){if(this.disposed)return v(U("accessDenied",false));let r=this.snapshot.conversationId,n=this.snapshot.historyCursor;if(!r||!n||this.snapshot.isLoadingHistory)return L(void 0);let o=this.historyGeneration;this.patch({isLoadingHistory:true});let s=await this.getMessages(r,{cursor:n});if(o!==this.historyGeneration||this.disposed)return v(U("accessDenied",false));if(this.patch({isLoadingHistory:false}),!s.ok)return s;let a=new Set(this.snapshot.messages.map(u=>u.id)),l=s.value.messages.filter(u=>!a.has(u.id));return this.patch({messages:[...l,...this.snapshot.messages],historyCursor:s.value.nextCursor===n?null:s.value.nextCursor}),L(void 0)}async*retryHistory(r){let n=await this.resumeConversation(r);n.ok||(yield Me(n.error));}async primeConversation(r){if(this.disposed)return v(U("accessDenied",false));let n=r?.petRef??null,o={petRef:n,settled:this.primeBounded(n)};this.unadoptedCreate=o;let s=await o.settled;return this.disposed?v(U("accessDenied",false)):(!s.ok&&this.unadoptedCreate===o&&(this.unadoptedCreate=null),s)}async primeBounded(r){let n=await this.headThreadWithUnread(r);return n.ok?n.value!==null&&!this.snapshot.isStreaming&&this.snapshot.conversationId===null&&(await this.resumeConversation(n.value)).ok?L(n.value):L(this.snapshot.conversationId):n.error.code==="accessDenied"||n.error.httpStatus===403?L(null):v(n.error)}async headThreadWithUnread(r){let n=await this.listConversationsWith({...r===null?{}:{petRef:r},limit:1},{maxAttempts:1});if(!n.ok)return v(n.error);let o=n.value.conversations[0];return o===void 0||o.unreadCount===null||o.unreadCount<=0?L(null):L(o.id)}async createConversation(r){let n=this.epoch;if(this.disposed)return v(U("accessDenied",false));let o=r?.petRef??null,s={petRef:o,settled:this.createConversationBounded(o)};this.unadoptedCreate=s;let a=await s.settled;return !this.alive(n)||this.disposed?v(U("accessDenied",false)):(!a.ok&&this.unadoptedCreate===s&&(this.unadoptedCreate=null),a)}async createConversationBounded(r,n){let o={method:"POST",path:"/widget/v1/conversations",body:r?{pet_ref:r}:{}},s=await this.authedUnary("chat.createConversation",o,n,{maxAttempts:1});if(!s.ok)return v(s.error);let a=s.value?.conversation_id??s.value?.id;return typeof a!="string"||a.length===0?v(U("internalError",true)):L(a)}async getPrompts(r){let n=this.epoch;if(this.disposed)return v(U("accessDenied",false));let o=r?.petRef??null;if(o!==null&&Ce(o))return v(D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}));let s=o!==null?`?pet_ref=${encodeURIComponent(o)}`:"",a=await this.authedUnary("chat.getPrompts",{method:"GET",path:`/widget/v1/suggested-prompts${s}`});return !this.alive(n)||this.disposed?v(U("accessDenied",false)):a.ok?L(Oa(a.value)):v(a.error)}async authedUnary(r,n,o,s){return this.funnel.send(r,o?{...n,signal:o}:n,s)}driveWithHandlers(r,n,o){let s=new AbortController,a=nn(s.signal,n.signal),l=this.beginTurn(r,n),u=this.runTurn(l,a),d=false,c=i(()=>{d||(d=true,s.abort(),this.handlerTeardowns.delete(c));},"teardown");return this.handlerTeardowns.add(c),(async()=>{for await(let p of u){if(d)break;o.onFrame(p),p.kind==="done"&&o.onDone(this.lastResponseIdValue);}!d&&this.snapshot.status==="error"&&this.snapshot.error!==null&&o.onError(this.snapshot.error),this.handlerTeardowns.delete(c);})(),c}beginTurn(r,n){let o={epoch:this.epoch,text:r,petRef:n.petRef??null,imageS3Keys:Object.freeze([...n.imageS3Keys??[]]),idempotencyKey:n.idempotencyKey??this.makeIdempotencyKey(),userMessageId:this.newId(),assistantMessageId:null,sawDelta:false,conversationIdOverride:n.conversationId??null};return this.patch({error:null,stopped:false,reconnecting:false,messages:[...this.snapshot.messages,Po(o.userMessageId,r,this.stamp())]}),o}async*runTurn(r,n){let o=this.beginOperation(n);r.epoch=o.epoch,this.patch({status:"streaming",isStreaming:true,error:null}),this.lastTurn=r;let s=0,a=false,l=false;try{for(;;){if(o.signal.aborted||!this.alive(o.epoch))return;let u=r.conversationIdOverride===null&&this.snapshot.conversationId===null,d=u?this.unadoptedCreate:null;if(d!==null&&(r.petRef===null||r.petRef===d.petRef)){let b=await d.settled;if(o.signal.aborted||!this.alive(o.epoch))return;b.ok&&b.value!==null&&this.snapshot.conversationId===null&&this.adoptConversation(b.value);}if(u&&this.snapshot.conversationId===null){let b=await this.createConversationBounded(r.petRef,o.signal);if(o.signal.aborted||!this.alive(o.epoch))return;if(!b.ok){yield*this.emitTerminal(r,b.error,Me(b.error));return}this.adoptConversation(b.value);}let c=r.conversationIdOverride??this.snapshot.conversationId;if(c===null){let b=U("internalError",!0);yield*this.emitTerminal(r,b,Me(b));return}this.clearAssistantInProgress(r);let p=new AbortController,f=nn(o.signal,p.signal),m=null;try{let b;try{b=await this.funnel.authorize(this.buildSendRequest(r,c));}catch{let P=this.authRejected();yield*this.emitTerminal(r,P,Me(P));return}if(o.signal.aborted||!this.alive(o.epoch))return;let S=this.funnel.stream("chat.send",b,f);for await(let P of Da(S,this.budget,f,this.timers)){if(!this.alive(o.epoch))return;if(P.kind==="error"&&P.terminal){m=P;break}if(this.applyFrame(P,r),yield P,P.terminal){o.settle();return}}}finally{p.abort();}if(o.signal.aborted||!this.alive(o.epoch))return;if(m===null){if(this.snapshot.status==="complete")return;let b=U("streamIncomplete",!0);yield*this.emitTerminal(r,b,Me(b));return}let h=Fe(m.code);if(h==="authExpired"&&this.auth.mode==="personalized"&&!l){l=!0,this.telemetry.track("chat.auth.refresh",{});let b=await this.tryForceRefresh();if(o.signal.aborted||!this.alive(o.epoch))return;if(!b){let S=this.authRejected();yield*this.emitTerminal(r,S,m);return}this.patch({reconnecting:!0});continue}if(h==="authExpired"){this.telemetry.track("chat.auth.rejected",{});let b=this.authRejected();yield*this.emitTerminal(r,b,m);return}if(h==="accessDenied"){this.telemetry.track("chat.access_denied",{}),yield*this.emitTerminal(r,_o(m),m);return}if(Us(h)&&!a){a=!0,this.telemetry.track("chat.conv.recreate",{}),this.adoptConversation(null),r.conversationIdOverride=null,this.patch({reconnecting:!0});continue}let T=m.retryable&&qr(h,!0);if(By&&T&&s+1<this.errorPolicy.maxAttempts(h));yield*this.emitTerminal(r,_o(m),m);return}}finally{o.settle();}}*emitTerminal(r,n,o){this.applyError(r,n),yield o;}applyFrame(r,n){switch(r.kind){case "accepted":this.snapshot.isStreaming||this.patch({status:"streaming",isStreaming:true});return;case "heartbeat":return;case "delta":this.applyDelta(r.delta,n);return;case "done":this.applyDone(r,n);return;case "analysisStarted":case "analysisComplete":return;case "unknown":this.telemetry.track("chat.frame.unknown",{});return;case "error":return;default:return at(r)}}stamp(){return new Date(this.timers.now()).toISOString()}applyDelta(r,n){if(n.assistantMessageId===null){let o=this.newId();n.assistantMessageId=o,n.sawDelta=true;let s=this.snapshot.messages.map(a=>a.id===n.userMessageId&&a.pending===true?sr(a):a);this.patch({status:"streaming",isStreaming:true,messages:[...s,ko(o,r,this.stamp())]});return}if(this.pendingDelta+=r,this.pendingDelta.length>=Vy){this.flushPendingDelta(n);return}this.scheduleDeltaFlush(n);}scheduleDeltaFlush(r){if(this.flushHandle!==null)return;let n=this.epoch;this.flushHandle=this.timers.setTimeout(()=>{if(this.flushHandle=null,!this.alive(n)){this.pendingDelta="";return}this.flushPendingDelta(r);},Uy);}flushPendingDelta(r){if(this.clearFlushTimer(),this.pendingDelta.length===0)return;let n=this.pendingDelta;this.pendingDelta="";let o=r.assistantMessageId;if(o===null)return;let s=this.snapshot.messages.map(a=>a.id===o?Ia(a,n):a);this.patch({messages:s});}discardPendingDelta(){this.clearFlushTimer(),this.pendingDelta="";}clearFlushTimer(){this.flushHandle!==null&&(this.timers.clearTimeout(this.flushHandle),this.flushHandle=null);}applyDone(r,n){this.flushPendingDelta(n),this.lastResponseIdValue=r.messageId?r.messageId:null;let o=r.conversationId?r.conversationId:this.snapshot.conversationId,s;if(n.assistantMessageId!==null)s=this.snapshot.messages.map(l=>l.id===n.assistantMessageId?xo(l,r):l);else {let l=this.newId();n.assistantMessageId=l,n.sawDelta=true,s=[...this.snapshot.messages.map(d=>d.id===n.userMessageId&&d.pending===true?sr(d):d),xo(ko(l,"",this.stamp()),r)];}let a=wo([{category:"",prompts:r.followUpQuestions}]);this.replyPrompts=a.length>0?Object.freeze(a):null,this.patch({status:"complete",isStreaming:false,error:null,conversationId:o,messages:s,suggestedPrompts:this.replyPrompts??this.bootstrapPrompts,reconnecting:false}),!r.urgencyProvided&&o!==null&&this.classifyTurn(o,this.lastResponseIdValue);}async classifyTurn(r,n){if(n===null||this.disposed)return;let o=String(n);if(this.classifiedMessageIds.has(o))return;this.classifiedMessageIds.add(o);let s=this.epoch,a=this.historyGeneration,l=await this.authedUnary("chat.classifyUrgency",{method:"POST",path:`/widget/v1/conversations/${r}/classify`});if(!l.ok||!this.alive(s)||this.disposed||a!==this.historyGeneration||this.snapshot.conversationId!==r)return;let u=Ga(l.value?.urgency),d=typeof l.value?.reason=="string"?l.value.reason:null,c=i(p=>p.responseId===n,"carries");this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,urgencyLevel:u,urgencyReason:d,urgencyProvided:true}):p)});}applyError(r,n){this.flushPendingDelta(r);let o=this.snapshot.messages.map(s=>s.id===r.userMessageId&&s.pending===true?sr(s):s);this.patch({status:"error",isStreaming:false,error:n,messages:o,reconnecting:false});try{this.errorPolicy.onExpectedFailure?.(n);}catch{}}clearAssistantInProgress(r){if(this.discardPendingDelta(),r.assistantMessageId===null)return;let n=r.assistantMessageId;r.assistantMessageId=null,r.sawDelta=false;let o=this.snapshot.messages.filter(s=>s.id!==n);o.length!==this.snapshot.messages.length&&this.patch({messages:o});}buildSendRequest(r,n){let o={message:r.text};return r.imageS3Keys.length>0&&(o.image_s3_keys=r.imageS3Keys),{method:"POST",path:`/widget/v1/conversations/${n}/messages`,body:o,headers:{"Idempotency-Key":r.idempotencyKey}}}async tryForceRefresh(){if(this.auth.mode!=="personalized")return false;try{return await this.auth.identity.currentToken({forceRefresh:!0}),!0}catch{return false}}authRejected(){return U("authRejected",false)}};i(Do,"ChatControllerImpl");var No=Do;async function Xa(e,t){let{controller:r}=t,n=e.petRef??null,o=e.resumeConversationId??null,s=[],a=false,l=false,u=false,d=null,c=null,p=o?r.resumeConversation(o).then(x=>x.ok?L(o):v(x.error)):r.primeConversation(n?{petRef:n}:void 0),f=r.getPrompts(n!==null?{petRef:n}:void 0),[m,h]=await Promise.all([p,f]),T=null;if(m.ok)T=m.value,m.value!==null&&s.push(m.value),m.value!==null&&r.getSnapshot().conversationId===null&&r.adoptConversation(m.value);else {let x=m.error;c=x,$a(x)?(l=true,d=x):(Ya(x)&&(a=true),u=true);}let b=[];h.ok?b=h.value:S(h.error);function S(x){$a(x)?(l=true,d===null&&(d=x)):Ya(x)&&(a=true);}i(S,"recordAuthSignals");let P=d!==null?d.displayMessage:null;return Object.freeze({conversationId:T,petRef:n,suggestedPrompts:b,error:P,warning:P===null&&T===null&&u?Hy:null,cause:d??c,diagnostics:Object.freeze({candidateConversationIds:Object.freeze([...s]),sawForbidden:a,sawUnauthorized:l,sawConversationInitFailure:u})})}i(Xa,"bootstrapChat");var Hy="Chat is ready. Your first message will start the conversation.";function $a(e){return e.httpStatus===401||e.code==="authExpired"||e.code==="authRejected"}i($a,"isUnauthorized");function Ya(e){return e.httpStatus===403||e.code==="accessDenied"}i(Ya,"isForbidden");var Uo=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Qa(e){return e!==Uo}i(Qa,"isUploadTransportAvailable");var zy=Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var sn=10*1024*1024,an=5,dr=120,jy="/widget/v1/uploads/initiate";function Wy(e){return typeof e=="string"&&zy.includes(e.trim().toLowerCase())}i(Wy,"isAttachmentMime");function Vo(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<=dr)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,dr);let n=t.slice(r);return n.length>=dr?t.slice(0,dr):`${t.slice(0,r).slice(0,dr-n.length)}${n}`}i(Vo,"sanitizeFilename");function Bo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i(Bo,"formatBytes");var cr=i(e=>Object.freeze({ok:true,value:e}),"ok"),Ae=i(e=>Object.freeze({ok:false,error:e}),"err");function ue(e,t,r,n){return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}i(ue,"failure");function Gy(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(Gy,"attachmentSize");function Ky(e){let t=Vo(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!Wy(r))return Ae(ue("unsupported_type",false,t));let n=Gy(e);return n===null?Ae(ue("unknown",false,t)):n>sn?Ae(ue("too_large",false,t,{sizeBytes:n})):cr(Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}i(Ky,"validateAttachment");function qy(e){if(typeof e!="object"||e===null)return null;let t=e,r=i(d=>typeof d=="string"&&d.length>0?d:null,"str"),n=i(d=>typeof d=="number"&&Number.isFinite(d)?d:null,"num"),o=r(t.upload_id),s=r(t.upload_url),a=r(t.s3_key);if(o===null||s===null||a===null)return null;let l={},u=t.upload_fields;if(typeof u=="object"&&u!==null)for(let[d,c]of Object.entries(u))typeof c=="string"&&(l[d]=c);return Object.freeze({upload_id:o,upload_url:s,upload_fields:Object.freeze(l),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??sn,s3_key:a,purpose:r(t.purpose)})}i(qy,"parsePolicy");function $y(e,t){let r=e.httpStatus;switch(e.code){case "quotaExceeded":return ue("quota_exceeded",false,t,{cause:e});case "rateLimited":return ue("rate_limited",true,t,{cause:e});case "idempotencyConflict":case "idempotencyInFlight":return ue("idempotency_conflict",true,t,{cause:e});case "validationFailed":return ue("unsupported_type",false,t,{cause:e});case "serviceUnavailable":case "streamTimeout":return ue("network",true,t,{cause:e});default:return r===429?ue("rate_limited",true,t,{cause:e}):r===503?ue("network",true,t,{cause:e}):r===void 0?ue("network",true,t,{cause:e}):ue("server",e.retryable,t,{httpStatus:r,cause:e})}}i($y,"initiateFailure");async function Yy(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:jy,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return Ae($y(n.error,t.filename));let o=qy(n.value);return o===null?Ae(ue("server",false,t.filename)):cr(o)}i(Yy,"initiateAttachmentUpload");async function Xy(e,t,r,n){let o=i(()=>n?.signal?.aborted===true,"cancelled");if(o())return Ae(ue("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),cr(void 0)}catch{return o()?Ae(ue("cancelled",true,r.filename)):Ae(ue("server",true,r.filename))}}i(Xy,"uploadAttachmentBytes");var Qy=2,Zy=3,Jy=Object.freeze([1e3,2e3,4e3]),Za=0;function eg(){return Za+=1,`attachment-${Za}`}i(eg,"defaultNewId");function Ja(e){let t=Math.max(1,e.concurrency??Qy),r=Math.max(1,e.maxAttempts??Zy),n=e.backoffMs??Jy,o=Math.max(1,e.maxPerMessage??an),s=e.timers??wa,a=e.newId??eg,l=Qa(e.transport),u=new Map,d=[],c=[],p=new Set,f=new Set,m=Object.freeze({attachments:Object.freeze([])}),h=false,T=i(()=>{m=Object.freeze({attachments:Object.freeze(d.flatMap(y=>{let _=u.get(y);return _===void 0?[]:[_.state]}))});for(let y of f)y();},"publish"),b=i((y,_)=>{y.state=Object.freeze({...y.state,..._}),T();},"patch"),S=i(()=>{for(;!h&&p.size<t&&c.length>0;){let y=c.shift(),_=u.get(y);_!==void 0&&(p.add(y),P(_).finally(()=>{p.delete(y),S();}));}},"pump"),P=i(async y=>{let{attachment:_}=y;for(;y.attempts<r;){if(h||y.controller.signal.aborted)return;y.attempts+=1;let A=y.controller.signal;b(y,{status:"uploading",error:null,progress:0});let O=await Yy(e.funnel,_,{signal:A});if(h||A.aborted)return;let F;if(!O.ok)F=Ae(O.error);else {let H=await Xy(e.transport,O.value,_,{signal:A,onProgress:i(Q=>{!A.aborted&&y.state.status==="uploading"&&b(y,{progress:tg(Q)});},"onProgress")});if(h||A.aborted)return;F=H.ok?cr(O.value.s3_key):Ae(H.error);}if(F.ok){b(y,{status:"uploaded",s3Key:F.value,error:null,progress:1});return}let C=F.error,w=C.retryable&&y.attempts<r;if(b(y,{status:w?"uploading":"failed",error:C,progress:0}),!w)return;let I=n[Math.min(y.attempts-1,n.length-1)]??0;await rn(I,A,s);}},"run"),k=i(y=>{c.push(y.state.id),S();},"enqueue"),x={available:l,subscribe(y){return f.add(y),()=>{f.delete(y);}},getSnapshot:i(()=>m,"getSnapshot"),get uploading(){return m.attachments.some(y=>y.status==="uploading")},get s3Keys(){return m.attachments.flatMap(y=>y.status==="uploaded"&&y.s3Key!==null?[y.s3Key]:[])},add(y){let _=Ky(y);if(!_.ok)return _;if(h||d.length>=o)return Ae(ue("too_many",false,_.value.filename));let A=a(),O={attachment:_.value,controller:new AbortController,attempts:0,state:Object.freeze({id:A,filename:_.value.filename,previewUri:y.uri,contentType:_.value.contentType,sizeBytes:_.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return u.set(A,O),d.push(A),T(),k(O),cr(O.state)},retry(y){let _=u.get(y);_===void 0||h||_.state.status!=="failed"||(_.controller=new AbortController,_.attempts=0,b(_,{status:"uploading",error:null,progress:0,s3Key:null}),k(_));},remove(y){let _=u.get(y);if(_===void 0)return;_.controller.abort(),u.delete(y);let A=d.indexOf(y);A>=0&&d.splice(A,1);let O=c.indexOf(y);O>=0&&c.splice(O,1),T();},clear(){for(let y of [...d])x.remove(y);},dispose(){h=true;for(let y of u.values())y.controller.abort();u.clear(),d.length=0,c.length=0,f.clear(),m=Object.freeze({attachments:Object.freeze([])});}};return x}i(Ja,"createAttachmentQueue");function tg(e){return Number.isNaN(e)||e<0?0:e>1?1:e}i(tg,"clamp");var el=Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function pr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(el,t)?el[t]:null}i(pr,"canonicalPetSpecies");var tl=50,rg=128,Ho=120,rl=120,ng=2e3,nl=120,og=80,sl=new Set(["male","female","unknown"]),al=new Set(["day","month","year"]),ll=new Set(["low","medium","high","athletic"]),ul=new Set(["indoor","outdoor","both"]),dl=new Set(["mild","moderate","severe"]),ig=/^(\d{4})-(\d{2})-(\d{2})$/,cl=[["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"]],pl=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];Object.freeze([...cl,...pl].map(([e])=>e));function sg(e){let t=ig.exec(e);if(t===null)return false;let[r,n,o]=[Number(t[1]),Number(t[2]),Number(t[3])],s=new Date(Date.UTC(r,n-1,o));return s.getUTCFullYear()===r&&s.getUTCMonth()===n-1&&s.getUTCDate()===o}i(sg,"isRealDate");var mr=i(e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,"oneOf"),ag=i((e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,"boolean"),un=i((e,t)=>typeof t=="string"&&sg(t)?null:`${e} must be a real date written YYYY-MM-DD`,"date"),Le=i((e,t={})=>(r,n)=>{if(typeof n!="string")return `${r} must be a string`;if(Ce(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 s=gt(o);return s<=e?null:`${r} is ${s} characters; the server accepts at most ${e}`},"text"),lg={sex:mr(sl),spayedNeutered:ag,birthDate:un,birthDatePrecision:mr(al),activityLevel:mr(ll),indoorOutdoor:mr(ul),foodBrand:Le(nl),foodType:Le(nl),microchipId:Le(og)},zo=["ref","ref",false,Le(rg,{required:true,trimmed:true})],jo=["notes","notes",false,Le(ng,{trimmed:true})],ol=[zo,["name","name",true,Le(Ho,{required:true,trimmed:true})],["dose","dose",false,Le(rl,{trimmed:true})],["frequency","frequency",false,Le(rl,{trimmed:true})],["startDate","start_date",false,un],["endDate","end_date",false,un],jo],ug={allergies:[zo,["allergen","allergen",true,Le(Ho,{required:true,trimmed:true})],["severity","severity",false,mr(dl)],jo],medications:ol,supplements:ol,conditions:[zo,["conditionName","condition_name",true,Le(Ho,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,un],jo]};function dg(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,s={};for(let[u,d,c,p]of ug[e]){let f=o[u];if(f==null){if(c)return {error:`${n}.${u} is required`};f===null&&(s[d]=null);continue}let m=p(`${n}.${u}`,f);if(m!==null)return {error:m};s[d]=f;}let a=s.start_date,l=s.end_date;return typeof a=="string"&&typeof l=="string"&&l<a?{error:`${n}.endDate must not be before startDate`}:{item:s}}i(dg,"itemToWire");function cg(e,t){if(!Array.isArray(t))return {error:`${e} must be an array (send [] to clear it)`};if(t.length>tl)return {error:`${e} has ${t.length} items; the server accepts at most ${tl}`};let r=[],n=new Set;for(let o=0;o<t.length;o+=1){let s=dg(e,o,t[o]);if("error"in s)return s;let a=s.item.ref;if(typeof a=="string"){let l=a.trim();if(n.has(l))return {error:`${e}: ref ${JSON.stringify(l)} is used twice; a ref names one item`};n.add(l);}r.push(s.item);}return {items:r}}i(cg,"listToWire");function fl(e,t){let r=e,n={};for(let[a,l]of cl){let u=r[a];if(u!==void 0){if(u!==null){let d=lg[a](a,u);if(d!==null)return {error:d}}n[l]=u;}}let o=r.birthDate!==void 0,s=r.birthDatePrecision!==void 0;if(o!==s||o&&r.birthDate===null!=(r.birthDatePrecision===null))return {error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[a,l]of pl){let u=r[a];if(u===void 0)continue;let d=cg(a,u);if("error"in d)return d;n[l]=d.items;}return Object.keys(n).length>0&&t!==void 0&&pr(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(fl,"petHealthToWire");var ie=i(e=>typeof e=="string"?e:null,"str"),fr=i((e,t)=>typeof t=="string"&&e.has(t)?t:null,"pick"),pg=i(e=>typeof e=="boolean"?e:null,"bool");function ln(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(ln,"itemsFromWire");function il(e){let t=ie(e.name);return t===null||t.length===0?null:Object.freeze({ref:ie(e.ref),name:t,dose:ie(e.dose),frequency:ie(e.frequency),startDate:ie(e.start_date),endDate:ie(e.end_date),notes:ie(e.notes)})}i(il,"medicationFromWire");function ml(e){let t=e.profile_version;return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:fr(sl,e.sex),spayedNeutered:pg(e.spayed_neutered),birthDate:ie(e.birth_date),birthDatePrecision:fr(al,e.birth_date_precision),activityLevel:fr(ll,e.activity_level),indoorOutdoor:fr(ul,e.indoor_outdoor),foodBrand:ie(e.food_brand),foodType:ie(e.food_type),microchipId:ie(e.microchip_id),allergies:ln(e.allergies,r=>{let n=ie(r.allergen);return n===null||n.length===0?null:Object.freeze({ref:ie(r.ref),allergen:n,severity:fr(dl,r.severity),notes:ie(r.notes)})}),medications:ln(e.medications,il),supplements:ln(e.supplements,il),conditions:ln(e.conditions,r=>{let n=ie(r.condition_name);return n===null||n.length===0?null:Object.freeze({ref:ie(r.ref),conditionName:n,diagnosedDate:ie(r.diagnosed_date),notes:ie(r.notes)})})})}i(ml,"petHealthFromWire");var hl=100,bl=50,vl=100,El=50,Cl=500,fg=128,mg=6e4;function De(e){return D("validationFailed",{retryable:false,wireMessage:e})}i(De,"invalid");function ht(e,t,r){if(typeof t!="string")return De(`${e} must be a string`);let n=gt(t);return n<=r?null:De(`${e} is ${n} characters; the server accepts at most ${r}`)}i(ht,"checkString");function dn(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:De(`${e} must be a finite number between 0 and ${r}`)}i(dn,"outOfRange");function yl(e,t){if(typeof e!="string")return De("pet_ref must be a string");if(e.trim().length===0)return De("pet_ref must not be blank");if(Ce(e))return De("pet_ref contains an unpaired surrogate and cannot be encoded");if(t!=null&&typeof t!="object")return De("profile must be an object");let r=[ht("pet_ref",e,fg)];return t?.name!==void 0&&r.push(ht("name",t.name,hl)),t?.species!==void 0&&r.push(ht("species",t.species,bl)),t?.breed!==void 0&&r.push(ht("breed",t.breed,vl)),t?.ageYears!==void 0&&r.push(dn("age_years",t.ageYears,El)),t?.weightKg!==void 0&&r.push(dn("weight_kg",t.weightKg,Cl)),r.find(n=>n!==null)??null}i(yl,"validate");function Rl(e,t){let r=fl(e,t);return "error"in r?{error:De(r.error)}:r}i(Rl,"healthToWire");function yg(e){if(typeof e!="object"||e===null)return {error:De("patch must be an object")};let t=e,r=[["name","name",s=>ht("name",s,hl)],["species","species",s=>ht("species",s,bl)],["breed","breed",s=>ht("breed",s,vl)],["ageYears","age_years",s=>dn("age_years",s,El)],["weightKg","weight_kg",s=>dn("weight_kg",s,Cl)]],n={};for(let[s,a,l]of r){let u=t[s];if(u!==void 0){if(u!==null){let d=l(u);if(d!==null)return {error:d}}n[a]=u;}}let o=Rl(t,t.species);return "error"in o?o:(Object.assign(n,o.body),Object.keys(n).length===0?{error:De("patch must change at least one field")}:{body:n})}i(yg,"patchToWire");function gg(e){if(e==null)return {body:{}};let t=Rl(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(gg,"toWire");var Ne=i(e=>typeof e=="string"?e:null,"str"),cn=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"num");function gl(e,t){let r=typeof e=="object"&&e!==null?e:{};return Object.freeze({petRef:Ne(r.pet_ref)??t,name:Ne(r.name),species:Ne(r.species),breed:Ne(r.breed),ageYears:cn(r.age_years),weightKg:cn(r.weight_kg)})}i(gl,"fromWire");function Sl(e){if(typeof e!="object"||e===null)return null;let t=e,r=Ne(t.pet_ref);return r===null||r.length===0?null:Object.freeze({petId:Ne(t.pet_id),petRef:r,name:Ne(t.name),species:Ne(t.species),breed:Ne(t.breed),ageYears:cn(t.age_years),weightKg:cn(t.weight_kg),updatedAt:Ne(t.updated_at)})}i(Sl,"widgetPetFromWire");function hg(e){let t=Sl(e);return t===null?null:Object.freeze({...t,...ml(e)})}i(hg,"widgetPetProfileFromWire");function bg(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=Sl(r);return n===null?[]:[n]}))}i(bg,"petListFromWire");function lt(e){return vg(Ie({auth:e}),Ie({auth:e,unaryTimeoutMs:mg}))}i(lt,"createPetsRepository");function vg(e,t=e){let r=i((o,s)=>s?{...o,signal:s}:o,"withSignal"),n=i(o=>yl(o,void 0)??`/widget/v1/pets/${encodeURIComponent(o)}`,"petPath");return {async list(o){let s=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},o?.signal));return s.ok?L(bg(s.value)):v(s.error)},async registerPet(o,s,a){let l=yl(o,s);if(l!==null)return v(l);let u=gg(s);if("error"in u)return v(u.error);let c={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(o)}`,body:u.body},p=await e.send("pets.registerPet",a?.signal?{...c,signal:a.signal}:c);return p.ok?L(gl(p.value,o)):v(p.error)},async updatePet(o,s,a){let l=n(o);if(typeof l!="string")return v(l);let u=yg(s);if("error"in u)return v(u.error);let d=await e.send("pets.updatePet",r({method:"PATCH",path:l,body:u.body},a?.signal));return d.ok?L(gl(d.value,o)):v(d.error)},async getPetProfile(o,s){let a=n(o);if(typeof a!="string")return v(a);let l=await e.send("pets.getPetProfile",r({method:"GET",path:`${a}/profile`},s?.signal));if(!l.ok)return v(l.error);let u=hg(l.value);return u===null?v(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):L(u)},async deletePet(o,s){let a=n(o);if(typeof a!="string")return v(a);let l=await e.send("pets.deletePet",r({method:"DELETE",path:a},s?.signal));return l.ok?L(void 0):v(l.error)},async eraseUserData(o){let s=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},o?.signal),{maxAttempts:1});return s.ok?L(void 0):v(s.error)}}}i(vg,"createPetsRepositoryOver");var Go=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 Eg(e){return Go[e]}i(Eg,"requires");function Tl(e,t){let r=Object.freeze({reason:t,level:e,recoverable:false}),n=[],o=new Set;for(let s of Object.keys(Go))for(let a of Go[s])o.has(a)||(o.add(a),n.push(Object.freeze({resource:a,granted:false,disabled:r})));return Object.freeze(n)}i(Tl,"deniedDecisionsFor");function Pl(e,t,r){let n=Eg(e),o=new Map;for(let l of t)o.set(l.resource,l);if(r?.isPending===true&&n.some(l=>!o.has(l)))return Wo({name:e,enabled:false,isPending:true,limits:{}});let s=Cg(n,o);return n.filter(l=>o.get(l)?.granted!==true).length===0?Wo({name:e,enabled:true,isPending:false,limits:s}):Wo({name:e,enabled:false,isPending:false,limits:s,disabled:Rg(n,o)})}i(Pl,"decideCapability");function Cg(e,t){let r={};for(let n of e){let o=t.get(n)?.limits;if(o)for(let[s,a]of Object.entries(o)){let l=r[s];r[s]=l===void 0?a:Math.min(l,a);}}return r}i(Cg,"mergeLimits");function Rg(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:Dt("accessDenied"),level:"user_entitlement",recoverable:false})}i(Rg,"disabledFor");function Wo(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(Wo,"freezeDecision");function Z(e){let t=X(e);return t===null?null:Tg(t)}i(Z,"parseColor");function X(e){if(typeof e=="number")return kl(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return Ko(t.slice(1));if(t.toLowerCase().startsWith("0x"))return Ko(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Sg(t);if(/^[0-9a-fA-F]+$/.test(t)){let r=Ko(t);if(r!==null)return r}return /^\d+$/.test(t)?kl(Number.parseInt(t,10)):null}i(X,"toRgba");function Ko(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return {r:qo(t[0]),g:qo(t[1]),b:qo(t[2]),a:1};if(t.length===6)return {r:bt(t,0),g:bt(t,2),b:bt(t,4),a:1};if(t.length===8){let r=bt(t,0);return {r:bt(t,2),g:bt(t,4),b:bt(t,6),a:r/255}}return null}i(Ko,"fromHex");function Sg(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(u=>u.trim());if(n.length<3)return null;let o=$o(Number(n[0])),s=$o(Number(n[1])),a=$o(Number(n[2]));if(o===null||s===null||a===null)return null;let l=1;if(n.length>=4){let u=Number(n[3]);if(!Number.isFinite(u))return null;l=Math.min(1,Math.max(0,u));}return {r:o,g:s,b:a,a:l}}i(Sg,"fromRgbFunc");function kl(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return {r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}i(kl,"argbIntToRgba");function bt(e,t){return Number.parseInt(e.slice(t,t+2),16)}i(bt,"byte");function qo(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}i(qo,"dup");function $o(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}i($o,"clampByte");function Tg(e){if(e.a>=1)return qe(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return `rgba(${e.r},${e.g},${e.b},${t})`}i(Tg,"normalizeRgba");function qe(e,t,r){return `#${Yo(e)}${Yo(t)}${Yo(r)}`.toUpperCase()}i(qe,"rgbToHex");function Yo(e){return e.toString(16).padStart(2,"0")}i(Yo,"hex2");var Pg="#111111",zt="#FFFFFF",pn="#000000";function _l(e){let t=X(e);if(t===null)return zt;let r=vt(t),n=vt({r:17,g:17,b:17}),o=vt({r:255,g:255,b:255});return Zo(r,o)>=Zo(r,n)?zt:Pg}i(_l,"readableOn");function jt(e,t){let r=_l(e);return se(r,e)>=t?r:se(zt,e)>=se(pn,e)?zt:pn}i(jt,"legibleOn");function Re(e){let t=i(r=>e.reduce((n,o)=>Math.min(n,se(r,o)),Number.POSITIVE_INFINITY),"worst");return t(zt)>=t(pn)?zt:pn}i(Re,"poleForGrounds");function vt(e){let t=Xo(e.r/255),r=Xo(e.g/255),n=Xo(e.b/255);return .2126*t+.7152*r+.0722*n}i(vt,"relativeLuminance");function Xo(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}i(Xo,"linearize");function Zo(e,t){let r=Math.max(e,t),n=Math.min(e,t);return (r+.05)/(n+.05)}i(Zo,"luminanceContrast");function se(e,t){let r=X(e),n=X(t);if(r===null||n===null)return 1;let o=n.a>=1?n:{...n},s=r.a>=1?r:wl(r,o);return Zo(vt(s),vt(o))}i(se,"contrastRatio");function wl(e,t){let r=e.a,n=i((o,s)=>Math.round(o*r+s*(1-r)),"mix");return {r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}i(wl,"composite");function Ue(e,t){let r=X(e),n=X(t);if(r===null||n===null)return null;let o=r.a>=1?r:wl(r,{...n});return qe(o.r,o.g,o.b)}i(Ue,"flattenOnto");function ut(e,t){let r=X(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return `rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}i(ut,"withAlpha");var xl=.05;function yr(e,t,r,n){let o=t[0];if(o===void 0)return r;let s=i(d=>t.every(c=>se(d,c)>=n),"reads");if(X(e)===null)return r;if(s(e))return e;let a=Ue(e,o),l=a===null?null:X(a),u=X(r);if(l===null||u===null)return r;for(let d=1;d<1/xl;d+=1){let c=d*xl,p=i((m,h)=>Math.round(m+(h-m)*c),"mix"),f=qe(p(l.r,u.r),p(l.g,u.g),p(l.b,u.b));if(s(f))return f}return r}i(yr,"pushToContrast");function Il(e,t,r){let n=e/255,o=t/255,s=r/255,a=Math.max(n,o,s),l=Math.min(n,o,s),u=(a+l)/2;if(a===l)return {h:0,s:0,l:u};let d=a-l,c=d/(1-Math.abs(2*u-1)),p;return a===n?(p=(o-s)/d*60,p<0&&(p=p+360)):a===o?p=((s-n)/d+2)*60:p=((n-o)/d+4)*60,{h:p,s:c,l:u}}i(Il,"rgbToHsl");function Jo(e){let{h:t,s:r,l:n}=e,o=(1-Math.abs(2*n-1))*r,s=t/60,a=o*(1-Math.abs(s%2-1)),l=n-o/2,u=Math.floor(s)%6,d=[[o,a,0],[a,o,0],[0,o,a],[0,a,o],[a,0,o],[o,0,a]],[c,p,f]=d[u];return {r:Qo(c+l),g:Qo(p+l),b:Qo(f+l)}}i(Jo,"hslToRgb");function Qo(e){return Math.min(255,Math.max(0,Math.floor(e*255+.5)))}i(Qo,"channel");var $e=Object.freeze(["composerInput","sendButton","userBubble","assistantBubble","vetBubble","recordCard","vetVisitButton","primaryButton","link"]),kg=Object.freeze(["backgroundColor","borderColor","borderRadius","textColor"]),J=4.5,xg=Object.freeze({});function _g(e){return $e.includes(e)}i(_g,"isSlotName");function wg(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)?Math.max(0,t):null}i(wg,"parseRadius");function Al(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t={},r=false;for(let[n,o]of Object.entries(e)){if(!_g(n)||o===null||typeof o!="object")continue;let s=Ig(o);s!==null&&(t[n]=s,r=true);}return r?Object.freeze(t):null}i(Al,"parseThemeSlots");function fn(e,t,r){return e[t]!==void 0?e[t]:e[r]}i(fn,"pick");function Ig(e){let t={},r=Z(fn(e,"background_color","backgroundColor"));r!==null&&(t.backgroundColor=r);let n=Z(fn(e,"border_color","borderColor"));n!==null&&(t.borderColor=n);let o=wg(fn(e,"border_radius","borderRadius"));o!==null&&(t.borderRadius=o);let s=Z(fn(e,"text_color","textColor"));return s!==null&&(t.textColor=s),Object.keys(t).length===0?null:Object.freeze(t)}i(Ig,"parseSlot");function mn(e,t){return t===null||Object.keys(t).length===0?e??xg:e===null||Object.keys(e).length===0?t:Object.freeze({...e,...t})}i(mn,"mergeThemeSlots");var gr=3;function Ag(e,t){return e===void 0?t:t.length===0?[e]:t.map(r=>Ue(e,r)??r)}i(Ag,"seatsOf");function Og(e,t){let r=Re(e);return e.every(n=>se(r,n)>=t)}i(Og,"someInkReads");function Fg(e,t){let r=t[0];return r===void 0?null:Ue(e,r)}i(Fg,"collapseUnsatisfiableFill");function Mg(e){let t=jt(e[0],J);return e.every(r=>se(t,r)>=J)?t:Re(e)}i(Mg,"inkFor");function Ol(e,t){let r=false,n={};for(let o of $e){let s=e[o];if(s===void 0)continue;let a=s.backgroundColor,l=t?.[o]??[],u=Ag(a,l),d={...s},c=false;if(a!==void 0&&u.length>1&&!Og(u,J)){let p=Fg(a,l);p!==null&&(d.backgroundColor=p,u=[p],c=true);}if(u.length>0){let p=s.textColor;if(a!==void 0)(p===void 0||u.some(f=>se(p,f)<J))&&(d.textColor=Mg(u),c=true);else if(p!==void 0){let f=yr(p,u,Re(u),J);f!==p&&(d.textColor=f,c=true);}if(s.borderColor!==void 0){let f=yr(s.borderColor,u,Re(u),gr);f!==s.borderColor&&(d.borderColor=f,c=true);}}n[o]=c?Object.freeze(d):s,r=r||c;}return r?Object.freeze(n):e}i(Ol,"guardSlotContrast");function Ye(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.keys(e))Ye(e[t]);}return e}i(Ye,"deepFreeze");var gn=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),Ml={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},Ll={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},Fl={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},Lg={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Ng={regular:"400",medium:"500",bold:"700"},Dg={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},ei=0,Et="System",Ve="monospace",Ug=["content","heading","control","compact","badge"];function Vg(e){let t={};for(let r of Ug)t[r]=e;return t}i(Vg,"authoredTierSizes");function Nl(){return {family:Et,mono:Ve,fontUrl:null,families:{regular:Et,medium:Et,bold:Et,mono:Ve,monoMedium:Ve,monoBold:Ve},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:Fl,tierSizes:Vg(Fl),lineHeight:Lg,weight:Ng,letterSpacing:Dg,scale:1,maxScale:ei,scaleCaps:gn}}i(Nl,"baseType");var Dl={},Ct=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function yn(e){return `cubic-bezier(${e.join(", ")})`}i(yn,"cssCubicBezier");var Ul={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:yn(Ct.standard),emphasized:yn(Ct.emphasized),exit:yn(Ct.exit)},reducedMotion:false},Bg={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},Be=Ye({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Bg,space:Ml,radius:Ll,type:Nl(),motion:Ul,slots:Dl}),Hg={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"},Rt=Ye({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Hg,space:Ml,radius:Ll,type:Nl(),motion:Ul,slots:Dl});function St(e){return [e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}i(St,"textGrounds");function Vl(e){return [e.surface,e.surfaceCream,e.background,e.chatGround,e.composerFill]}i(Vl,"controlGrounds");function ti(e){return [e.chatGround,e.surface,e.surfaceCream]}i(ti,"linkGrounds");function Bl(e,t){return [e.surface,e.surfaceCream,e.background,e.chatGround,e.composerFill,...Hl(e,t)]}i(Bl,"statusGrounds");function Hl(e,t){return [Ue(t,e.surface)??e.surface,Ue(t,e.surfaceCream)??e.surfaceCream]}i(Hl,"washGrounds");function zg(e){return [e.composerFill,e.chatGround]}i(zg,"composerGrounds");var jg=new Set(["text.timestamp","text.placeholder","errorRed","warningStrong","composerBorder"]);function Wg(e,t){let r=new Set(St(t));return St(e).every(n=>r.has(n))}i(Wg,"onCompiledGrounds");function zl(e){let t=e.color,r=(e.brightness==="dark"?Rt:Be).color,n=(e.brightness==="dark"?Be:Rt).color,o=St(t),s=Re(o)!==Re(St(r)),a=Wg(t,r),l=t.danger===r.danger&&t.badgeBgCritical===r.badgeBgCritical,u=i((T,b,S,P,k,x)=>{let y=b===S&&(T!=="errorRed"||l);return y&&a&&jg.has(T)?b:yr(y&&s?P:b,k,Re(k),x)},"ink"),d=i((T,b,S)=>u(`text.${T}`,t.text[T],r.text[T],n.text[T],b,S),"text"),c=i((T,b,S,P)=>u(T,b,r[T],n[T],S,P),"token"),p=i(T=>s&&t[T]===r[T]?n[T]:t[T],"tint"),f=t.primary,m=jt(f,J),h=c("danger",t.danger,[...o,...Hl(t,t.badgeBgCritical)],J);return {...t,onPrimary:m,onAccent:jt(t.accent,J),onDanger:se(m,h)>=J?m:jt(h,J),brandSoft:p("brandSoft"),brandSofter:p("brandSofter"),brandBorder:p("brandBorder"),borderHairlineGreen:p("borderHairlineGreen"),brandInk:c("brandInk",t.brandInk,o,J),linkInk:c("linkInk",e.slots.link?.textColor??t.accent,ti(t),J),text:{...t.text,primary:d("primary",o,J),secondary:d("secondary",o,J),muted:d("muted",o,J),metaCool:d("metaCool",o,J),timestamp:d("timestamp",o,J),placeholder:d("placeholder",Vl(t),gr)},danger:h,errorRed:c("errorRed",t.errorRed,Bl(t,t.badgeBgCritical),J),warningStrong:c("warningStrong",t.warningStrong,Bl(t,t.badgeBgCaution),J),composerBorder:c("composerBorder",t.composerBorder,zg(t),gr),brandBorderStrong:c("brandBorderStrong",t.brandBorderStrong,Vl(t),gr)}}i(zl,"guardInks");var Gg="#23272C",jl=4.5,Kg=.6,ri=.9,qg=.02,$g="#FFFFFF",Yg="#111111";function Xg(e){return se(e,Gg)>=jl&&Math.max(se(e,$g),se(e,Yg))>=jl}i(Xg,"readsOnDark");function ql(e){let t=X(e);if(t===null)return null;let{h:r,s:n,l:o}=Il(t.r,t.g,t.b),s=Math.min(Math.max(o,Kg),ri);for(let l=0;;l+=1){let u=s+l*qg;if(u>ri)break;let d=Jo({h:r,s:n,l:u}),c=qe(d.r,d.g,d.b);if(Xg(c))return c}let a=Jo({h:r,s:n,l:ri});return qe(a.r,a.g,a.b)}i(ql,"deriveDarkVariant");var Qg=7,Wl=.05,Zg="#000000",Gl="#FFFFFF";function Jg(e,t,r,n){let o=Ue(e,t);if(o===null)return r;if(se(o,t)>=n)return o;let s=X(o),a=X(r);if(s===null||a===null)return r;for(let l=1;l<1/Wl;l+=1){let u=l*Wl,d=i((p,f)=>Math.round(p+(f-p)*u),"mix"),c=qe(d(s.r,a.r),d(s.g,a.g),d(s.b,a.b));if(se(c,t)>=n)return c}return r}i(Jg,"pushContrast");function eh(e,t){let r=St(e),n=r[0],o=Kl(n);for(let s of r){let a=Kl(s);(t?a>o:a<o)&&(n=s,o=a);}return n}i(eh,"hardestGround");function Kl(e){let t=X(e);return t===null?0:vt(t)}i(Kl,"luminanceOf");function dt(e,t){return Ue(e,t)??Z(e)??t}i(dt,"solid");function $l(e){let t=e.color,r=Re(St(t))===Gl,n=r?Gl:Zg,o=eh(t,r),s=i(l=>Jg(l,o,n,Qg),"text"),a={...t,brandSoft:dt(t.brandSoft,t.surface),brandSofter:dt(t.brandSofter,t.surface),brandBorder:s(t.brandBorder),borderHairlineGreen:s(t.borderHairlineGreen),brandBorderStrong:s(t.brandBorderStrong),brandInk:s(t.brandInk),linkInk:s(t.linkInk),borderRingCream:s(t.borderRingCream),composerBorder:s(t.composerBorder),text:{primary:s(t.text.primary),secondary:s(t.text.secondary),muted:s(t.text.muted),placeholder:s(t.text.placeholder),onBrand:t.text.onBrand,metaCool:s(t.text.metaCool),timestamp:s(t.text.timestamp)},badgeBgPositive:dt(t.badgeBgPositive,t.surface),badgeBgCaution:dt(t.badgeBgCaution,t.surface),badgeBgCritical:dt(t.badgeBgCritical,t.surface),badgeBgNeutral:dt(t.badgeBgNeutral,t.surface),checkupCardLowRiskBg:dt(t.checkupCardLowRiskBg,t.surface),checkupCardConcernBg:dt(t.checkupCardConcernBg,t.surface)};return Ye({...e,highContrast:true,color:a})}i($l,"deriveHighContrast");var oi=Object.freeze({cream:.03,subtle:.07,ring:.16}),th=oi.cream,rh=oi.subtle,nh=oi.ring,oh=10;function ni(e,t,r){let n=X(e),o=X(t);if(n===null||o===null)return null;let s=i((a,l)=>Math.round(a+(l-a)*r),"at");return qe(s(n.r,o.r),s(n.g,o.g),s(n.b,o.b))}i(ni,"mix");function Yl(e){if(e===null)return {};let t=Re([e]),r=ni(e,t,th),n=ni(e,t,rh),o=ni(e,t,nh);return r===null||n===null||o===null?{}:{surface:e,background:e,chatGround:e,bubbleAssistant:e,surfaceCream:r,composerFill:r,surfaceSubtle:n,skeleton:n,borderRingCream:o}}i(Yl,"surfaceFamily");function Xl(e){if(e===null)return {};let t=X(e);return t===null?{}:{danger:e,errorRed:e,badgeBgCritical:`rgba(${t.r},${t.g},${t.b},0.12)`}}i(Xl,"dangerFamily");function Ql(e,t,r){if(e===null)return t;let n=e/r.type.size.body;if(n===1)return r.type.size;let o={};for(let[s,a]of Object.entries(r.type.size))o[s]=Math.max(oh,Math.round(a*n*10)/10);return o}i(Ql,"typeSizesFor");function Zl(e,t,r){if(e===null)return t;let n=e/r.space.xs,o=i(a=>Math.round(a*n),"s"),s=r.space;return {xs:o(s.xs),sm:o(s.sm),md:o(s.md),lg:o(s.lg),xl:o(s.xl),xxl:o(s.xxl)}}i(Zl,"spaceFor");function Jl(e,t){let r=e/t.radius.md,n=i(s=>Math.round(s*r),"s"),o=t.radius;return {tile:n(o.tile),xs:n(o.xs),sm:n(o.sm),md:n(o.md),lg:n(o.lg),xl:n(o.xl),pill:o.pill}}i(Jl,"radiiFor");var eu=Object.freeze(["everfur","minimal","night"]),tu=Object.freeze({everfur:Object.freeze({}),minimal:Object.freeze({colorPrimary:"#111111",colorAccent:"#111111",borderRadius:6}),night:Object.freeze({colorScheme:"dark"})}),br=Object.freeze({fontSizeBase:Object.freeze({min:12,max:20,default:14}),borderRadius:Object.freeze({min:0,max:32,default:14}),spacingUnit:Object.freeze({min:3,max:6,default:4})});function hn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(hn,"isRecord");function ih(e){return typeof e=="string"&&eu.includes(e.trim().toLowerCase())}i(ih,"isPreset");function hr(e,t){let r=e[t];return r??void 0}i(hr,"present");var sh=16;function ah(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.length>sh)return;let t=/^(-?\d+(?:\.\d+)?)(?: ?px)?$/i.exec(e.trim());return t===null?void 0:Number(t[1])}i(ah,"parsePx");var lh=[["colorPrimary","primary_color"],["colorAccent","accent_color"],["colorBackground","background_color"],["colorText","text_color"]],uh=[["fontSizeBase","font_size_base"],["borderRadius","border_radius"],["spacingUnit","spacing_unit"]];function ii(e){if(!hn(e))return null;let t=ih(e.theme)?tu[e.theme.trim().toLowerCase()]:{},r=hn(e.variables)?e.variables:{},n={...t};for(let[p,f]of Object.entries(r))f!=null&&(n[p]=f);let o={},s=hr(n,"colorScheme"),a=typeof s=="string"?s.trim().toLowerCase():null;(a==="light"||a==="dark"||a==="auto")&&(o.color_scheme=a);let l=a==="dark"?"_dark":"";for(let[p,f]of lh){let m=hr(n,p);m!==void 0&&(o[`${f}${l}`]=m);}let u=hr(n,"colorDanger");u!==void 0&&(o[`danger_color${l}`]=u);let d=hr(n,"fontFamily");typeof d=="string"&&d.trim().length>0&&(o.font_family=d.trim());for(let[p,f]of uh){let m=ah(hr(n,p));m!==void 0&&(o[f]=m);}let c=e.rules;if(hn(c)){let p={};for(let f of $e){let m=c[f];hn(m)&&(p[f]=m);}Object.keys(p).length>0&&(o.slots=p);}return Object.keys(o).length===0?null:Object.freeze(o)}i(ii,"expandAppearance");var iu=Object.freeze(["display_name","logo_url","logo_url_dark","primary_color","accent_color","primary_color_dark","accent_color_dark","brightness","color_scheme","font_family","font_url","fonts","font_urls","chat_placeholder","surface_style","radius_scale","accessibility_max_font_scale","slots","background_color","background_color_dark","text_color","text_color_dark","danger_color","danger_color_dark","font_size_base","border_radius","spacing_unit"]),vr="slots.",su=Object.freeze([1,2]);function vn(e){return Object.keys(e).every(t=>t==="schemaVersion"||(e[t]??null)===null)}i(vn,"isEmptyBranding");function au(e){let t=e?.schemaVersion??null;return t===null||su.includes(t)}i(au,"isKnownBrandingSchema");function lu(e){return new Set(["hide_powered_by",...e?.lockedFields??[]])}i(lu,"lockedFieldsOf");function dh(e){return e==="hide_powered_by"||iu.includes(e)?true:e.startsWith(vr)&&$e.includes(e.slice(vr.length))}i(dh,"isThemeLockName");function Xe(e){if(e===null||typeof e!="object")return null;let t=e,r=ru(t),n=ii(j(t,"appearance")),o=n===null?r:ch(ru(n),r);return vn(o)?null:Object.freeze(o)}i(Xe,"parseClientBranding");function ch(e,t){let r={...e};for(let[o,s]of Object.entries(t))s!=null&&(r[o]=s);let n=mn(e.slots??null,t.slots??null);return r.slots=Object.keys(n).length===0?null:n,r}i(ch,"overlayFlat");function ru(e){return {displayName:Tt(j(e,"display_name","displayName")),logoUrl:Tt(j(e,"logo_url","logoUrl")),primaryColor:Z(j(e,"primary_color","primaryColor")),accentColor:Z(j(e,"accent_color","accentColor")),brightness:yh(j(e,"brightness","color_scheme","colorScheme")),fontFamily:Tt(j(e,"font_family","fontFamily")),fontUrl:Tt(j(e,"font_url","fontUrl")),fonts:nu(j(e,"fonts")),fontUrls:nu(j(e,"font_urls","fontUrls")),placeholder:Tt(j(e,"chat_placeholder","placeholder","chatPlaceholder")),hidePoweredBy:ph(j(e,"hide_powered_by","hidePoweredBy")),primaryColorDark:Z(j(e,"primary_color_dark","primaryColorDark")),accentColorDark:Z(j(e,"accent_color_dark","accentColorDark")),surfaceStyle:ou(j(e,"surface_style","surfaceStyle"),fh),radiusScale:ou(j(e,"radius_scale","radiusScale"),mh),logoUrlDark:Tt(j(e,"logo_url_dark","logoUrlDark")),slots:Al(j(e,"slots")),accessibilityMaxFontScale:hh(j(e,"accessibility_max_font_scale","accessibilityMaxFontScale")),lockedFields:vh(j(e,"locked_fields","lockedFields")),schemaVersion:bh(j(e,"schema_version","schemaVersion")),backgroundColor:Z(j(e,"background_color","backgroundColor")),backgroundColorDark:Z(j(e,"background_color_dark","backgroundColorDark")),textColor:Z(j(e,"text_color","textColor")),textColorDark:Z(j(e,"text_color_dark","textColorDark")),dangerColor:Z(j(e,"danger_color","dangerColor")),dangerColorDark:Z(j(e,"danger_color_dark","dangerColorDark")),fontSizeBase:si(j(e,"font_size_base","fontSizeBase"),br.fontSizeBase),borderRadius:si(j(e,"border_radius","borderRadius"),br.borderRadius),spacingUnit:si(j(e,"spacing_unit","spacingUnit"),br.spacingUnit)}}i(ru,"parseFlat");function si(e,t){let r=bn(typeof e=="string"?e.trim().replace(/px$/i,""):e);return r===null?null:Math.min(t.max,Math.max(t.min,r))}i(si,"parseClamped");function ph(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true")return true;if(t==="false")return false}return null}i(ph,"parseBool");function j(e,...t){for(let r of t)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];if(n!==void 0)return n}}i(j,"pick");function Tt(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(Tt,"parseNonEmptyString");var Er=["regular","medium","bold","mono","monoMedium","monoBold"];function nu(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let n of Er){let o=Tt(j(t,n));o!==null&&(r[n]=o);}return Object.keys(r).length===0?null:Object.freeze(r)}i(nu,"parseFaceMap");var fh=["white","cream","subtle"],mh=["sharp","default","round"];function ou(e,t){if(typeof e!="string")return null;let r=e.trim().toLowerCase();return t.includes(r)?r:null}i(ou,"parseEnum");function yh(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="light"||t==="dark"||t==="auto"?t:null}i(yh,"parseBrightness");function bn(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)&&(typeof e!="string"||e.trim().length>0)?t:null}i(bn,"parseNumber");var gh=1,uu=3.1;function hh(e){let t=bn(e);return t===null?null:t<=0?0:Math.min(uu,Math.max(gh,t))}i(hh,"parseMaxFontScale");function bh(e){if(e==null)return null;let t=bn(e);return t!==null&&Number.isInteger(t)&&t>=1?t:0}i(bh,"parseSchemaVersion");function ai(e){let t=e.trim();return t.startsWith(vr)?t:t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}i(ai,"toWireName");function vh(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="string")continue;let n=ai(r);dh(n)&&!t.includes(n)&&t.push(n);}return t.length===0?null:Object.freeze(t)}i(vh,"parseLockedFields");function li(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}i(li,"hardenHttpsUrl");function du(e,t){if(t===null||vn(t))return e;let r=(t.brightness==="light"||t.brightness==="dark")&&t.brightness!==e.brightness?t.brightness==="dark"?Rt:Be:e,n=r.brightness==="dark"?Rt:Be,o=r.brightness==="dark",s=o?t.primaryColorDark??ui(t.primaryColor):t.primaryColor,a=o?t.accentColorDark??ui(t.accentColor):t.accentColor,l=s??r.color.primary,u=a??r.color.accent,d=s!==null&&Th(t,l,n,o),c=d?n.color.primary:l,p=s!==null&&!d?X(c):null,f=i(k=>Math.round(k+(255-k)*.4),"lift"),m=p!==null?{brand:c,bubbleUser:c,brandInk:c,text:{...r.color.text,secondary:c},brandSoft:`rgba(${p.r}, ${p.g}, ${p.b}, 0.10)`,brandSofter:`rgba(${p.r}, ${p.g}, ${p.b}, 0.15)`,brandBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.20)`,borderHairlineGreen:`rgba(${p.r}, ${p.g}, ${p.b}, 0.28)`,brandBorderStrong:`rgba(${p.r}, ${p.g}, ${p.b}, 0.55)`,composerBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.75)`,accentEdge:`rgb(${f(p.r)}, ${f(p.g)}, ${f(p.b)})`}:d?Ph(n,r.color.text):{},h=(o?t.backgroundColorDark:t.backgroundColor)??null,T=Yl(h),b={...r.color,...T},S=(o?t.textColorDark:t.textColor)??null,P={brightness:r.brightness,highContrast:r.highContrast,meta:{displayName:t.displayName??r.meta.displayName,logoUrl:(o?t.logoUrlDark??t.logoUrl:t.logoUrl)??r.meta.logoUrl,placeholder:t.placeholder??r.meta.placeholder,hidePoweredBy:t.hidePoweredBy??r.meta.hidePoweredBy},color:{...r.color,...m,...T,...Xl((o?t.dangerColorDark??ui(t.dangerColor??null):t.dangerColor)??null),...S!==null?{text:{...m.text??r.color.text,primary:S}}:{},...Sh(t.surfaceStyle??null,b),primary:c,accent:u,onPrimary:r.color.onPrimary,onAccent:r.color.onAccent},space:Zl(t.spacingUnit??null,r.space,n),radius:t.borderRadius!=null?Jl(t.borderRadius,n):xh(t.radiusScale??null,r.radius,n),type:{...r.type,...Rh(r.type,t),size:Ql(t.fontSizeBase??null,r.type.size,n),maxScale:t.accessibilityMaxFontScale??r.type.maxScale},motion:r.motion,slots:mn(r.slots,t.slots??null)};return Ye(P)}i(du,"withServerBranding");var Eh={regular:["regular"],medium:["medium","regular"],bold:["bold","medium","regular"],mono:["mono"],monoMedium:["monoMedium","mono"],monoBold:["monoBold","monoMedium","mono"]},Ch=[["regular","medium","bold"],["mono","monoMedium","monoBold"]];function di(e){return e==="mono"||e==="monoMedium"||e==="monoBold"}i(di,"isMonoFace");function Rh(e,t){let r=t.fonts??{},n=t.fontUrls??{},o={...e.families},s={...e.namedFaces},a={...e.fontUrls};for(let l of Er){let u=Eh[l].map(p=>r[p]).find(p=>p!==void 0),d=di(l)?null:t.fontFamily;u!==void 0?(o[l]=u,s[l]=true):d!==null&&(o[l]=d,s[l]=false);let c=n[l]??(l==="regular"?t.fontUrl:null)??null;c!==null?a[l]=c:u!==void 0&&delete a[l];}for(let l of Ch)for(let u of l)s[u]&&l.some(d=>d!==u&&o[d]===o[u])&&(s[u]=false);return {family:o.regular,mono:o.mono,fontUrl:a.regular??null,families:o,namedFaces:s,fontUrls:a}}i(Rh,"mergeFaces");function ui(e){return e===null?null:ql(e)}i(ui,"darkVariantOf");function Sh(e,t){if(e===null)return {};let r=t;return {chatGround:e==="white"?r.surface:e==="subtle"?r.surfaceSubtle:r.surfaceCream}}i(Sh,"surfaceOf");function cu(e,t){return e==null?false:Z(e)===Z(t)}i(cu,"sameColor");function Th(e,t,r,n){return cu(t,r.color.primary)?true:n&&(e.primaryColorDark??null)===null&&cu(e.primaryColor,Be.color.primary)}i(Th,"isCompiledPrimary");function Ph(e,t){let r=e.color;return {text:{...t,secondary:r.text.secondary},brand:r.brand,bubbleUser:r.bubbleUser,brandInk:r.brandInk,brandSoft:r.brandSoft,brandSofter:r.brandSofter,brandBorder:r.brandBorder,borderHairlineGreen:r.borderHairlineGreen,brandBorderStrong:r.brandBorderStrong,composerBorder:r.composerBorder,accentEdge:r.accentEdge}}i(Ph,"compiledBrandFamily");var kh={sharp:.5,default:1,round:1.5};function xh(e,t,r){if(e===null)return t;let n=kh[e],o=r.radius,s=i(a=>Math.round(a*n),"s");return {tile:s(o.tile),xs:s(o.xs),sm:s(o.sm),md:s(o.md),lg:s(o.lg),xl:s(o.xl),pill:o.pill}}i(xh,"radiusOf");var _h="Everfur",wh=.5;function ci(e){let t=e?.branding??null,r=au(t)?t:null,n=Mh(e?.clientOverride??null,lu(r)),o=e?.colorScheme==="dark"?"dark":"light",s=n?.brightness??r?.brightness??"light",u=du((s==="auto"?o:s)==="dark"?Rt:Be,pu(r)),d=du(u,pu(n));return jh(d,e)}i(ci,"resolveTheme");function Ih(e,t,r){return ci({...r,branding:Xe(t),clientOverride:Xe(e)})}i(Ih,"previewTheme");function Ah(e){return e==="placeholder"?"chat_placeholder":ai(e)}i(Ah,"wireNameOf");var Oh={brightness:["color_scheme"],fontUrl:["font_family"],fonts:["font_family"],fontUrls:["font_url","font_family","fonts"],primaryColorDark:["primary_color"],accentColorDark:["accent_color"],logoUrlDark:["logo_url"],backgroundColorDark:["background_color"],textColorDark:["text_color"],dangerColorDark:["danger_color"],borderRadius:["radius_scale"],radiusScale:["border_radius"]};function Fh(e,t){return t.has(Ah(e))?true:(Oh[e]??[]).some(r=>t.has(r))}i(Fh,"isLocked");function Mh(e,t){if(e===null)return null;let r=false,n={...e};for(let a of Object.keys(e))(e[a]??null)!==null&&(Fh(a,t)||a==="lockedFields")&&(n[a]=null,r=true);let o=n.slots??null;if(o!==null){let a={},l=false;for(let u of $e){let d=o[u];d!==void 0&&(t.has(`${vr}${u}`)?l=true:a[u]=d);}l&&(n.slots=Object.keys(a).length===0?null:Object.freeze(a),r=true);}if(!r)return e;let s=Object.freeze(n);return vn(s)?null:s}i(Mh,"withoutFields");function pu(e){return e===null||e.brightness===null?e:Object.freeze({...e,brightness:null})}i(pu,"withoutBrightness");function Lh(e,t){if(t===1)return e;let r={};for(let[n,o]of Object.entries(e))r[n]=Math.round(o*t*10)/10;return r}i(Lh,"scaledSizes");function Nh(e){return e===void 0||!Number.isFinite(e)?1:Math.max(wh,e)}i(Nh,"effectiveScale");var fu=["content","heading","control","compact","badge"];function Dh(e){if(!(e>0))return gn;let t={};for(let r of fu){let n=gn[r];t[r]=n===0?0:Math.min(n,e);}return t}i(Dh,"tierCaps");function Uh(e,t){return t>0?Math.min(e,t):e}i(Uh,"capped");function Vh(e,t,r,n){let o={};for(let s of fu)o[s]=n?Lh(e,Uh(t,r[s])):e;return o}i(Vh,"sizesByTier");function Bh(e){return {composerInput:[e.composerFill],sendButton:[e.composerFill],userBubble:[e.bubbleUser],assistantBubble:[e.chatGround,e.surfaceCream],vetBubble:[e.bubbleVet],recordCard:[e.surface],vetVisitButton:[e.primary],primaryButton:[e.brand],link:ti(e)}}i(Bh,"slotGrounds");function Hh(e,t){try{let r=e(t);return r===!0||r===!1?r:null}catch{return null}}i(Hh,"registration");function zh(e,t){let r=t?.isFontRegistered,n=t?.platformMonoFamily?.trim()||null;if(r===void 0&&n===null)return {family:e.family,mono:e.mono,families:e.families,namedFaces:e.namedFaces};let o={...e.families},s={...e.namedFaces};for(let a of Er)!(o[a]===Et||o[a]===Ve)&&r!==void 0&&Hh(r,o[a])===false&&(o[a]=di(a)?Ve:Et,s[a]=false),n!==null&&di(a)&&o[a]===Ve&&(o[a]=n);return {family:o.regular,mono:o.mono,families:o,namedFaces:s}}i(zh,"platformFaces");function jh(e,t){let r=e.meta.displayName.trim().length===0?_h:e.meta.displayName,n=li(e.meta.logoUrl),o={};for(let h of Er){let T=e.type.fontUrls[h];T!==void 0&&(o[h]=li(T));}let s=o.regular??null,l=t?.reducedMotion===true?{duration:{instant:0,fast:0,normal:0,slow:0},spring:{gentle:{damping:100,stiffness:1e3}},easing:e.motion.easing,reducedMotion:true}:e.motion,u=Number.isFinite(e.type.maxScale)?e.type.maxScale:ei,d=Nh(t?.textScale),c=Dh(u),p=Vh(e.type.size,d,c,t?.scaleTypeSizes===true),f=zl(e),m={brightness:e.brightness,highContrast:false,meta:{displayName:r,logoUrl:n,placeholder:e.meta.placeholder,hidePoweredBy:e.meta.hidePoweredBy},color:f,space:e.space,radius:e.radius,type:{...e.type,...zh(e.type,t),fontUrl:s,fontUrls:o,size:p.content,tierSizes:p,scale:d,maxScale:u,scaleCaps:c},motion:l,slots:Ol(e.slots,Bh(f))};return t?.highContrast===true?$l(Ye(m)):Ye(m)}i(jh,"finalize");var mu="/widget/v1/entitlements",Wh=304,Gh=Object.freeze({kind:"notModified"});async function gu(e,t={},r=Ie({auth:e})){let n=await r.send("entitlements.fetch",qh(t));return n.ok?$h(n.value):n.error.httpStatus===Wh?Gh:{kind:"failed",error:n.error}}i(gu,"fetchEntitlements");var Kh=64;function qh(e){let t={};return pi(e.cachedRevision)&&(t["if-none-match"]=`"${e.cachedRevision}"`),e.region&&e.region.length<=Kh?{method:"GET",path:mu,headers:t,query:{region:e.region}}:{method:"GET",path:mu,headers:t}}i(qh,"buildRequest");function $h(e){if(e===null||typeof e!="object"||!pi(e.revision))return yu();let t=typeof e.region=="string"?e.region:"",r=pi(e.ttl_seconds)?e.ttl_seconds:0;return Object.freeze({kind:"updated",revision:e.revision,region:t,ttlSeconds:r,decisions:Xh(e.capabilities),branding:Yh(e),livemode:e.livemode!==false})}i($h,"parseUpdated");function Yh(e){let t=Xe(e.branding);if(t!==null)return t;let r=e.render_hints;if(r!==null&&typeof r=="object"){let n=Xe(r.branding);return n!==null?n:Xe(r)}return null}i(Yh,"parseBranding");function Xh(e){if(e===null||typeof e!="object")return Object.freeze([]);let t=[];for(let[r,n]of Object.entries(e))Qh(n)&&t.push(Object.freeze({resource:r,granted:true}));return Object.freeze(t)}i(Xh,"mapCapabilities");function Qh(e){return typeof e=="object"&&e!==null&&e.enabled===true}i(Qh,"isEnabled");function yu(){return {kind:"failed",error:D("internalError",{retryable:true,wireMessage:"malformed entitlements response"})}}i(yu,"malformed");function pi(e){return typeof e=="number"&&Number.isFinite(e)}i(pi,"isFiniteNumber");var Zh=30;function hu(e){let t=e.scheduler??Jh,r=e.resolve??gu,n=Math.max(1,e.floorSeconds??Zh),o=e.rng??Math.random,s=i(()=>n+o()*n,"jitteredFloorSeconds"),a=false,l=false,u=null,d=null,c=n,p=0,f=i(()=>{u!==null&&(t.clear(u),u=null);},"clearTimer"),m=i(S=>{l||!a||(c=Math.max(n,S),u=t.set(()=>{u=null,b();},c*1e3));},"schedule"),h=null,T=i(async()=>{if(l)return null;let S=p;e.onFetch?.();let P=e.region?{cachedRevision:d,region:e.region}:{cachedRevision:d},k;try{k=await r(e.authFor(),P);}catch(x){return e.telemetry?.track("sdk.entitlements.poll_error",{reason:eb(x)}),!l&&S===p&&(e.onSettled?.(),m(s())),null}if(l||S!==p)return null;switch(k.kind){case "updated":d=k.revision,e.update(k.decisions,k.branding??null,k.livemode!==false),m(k.ttlSeconds);break;case "notModified":m(c);break;case "failed":e.telemetry?.track("sdk.entitlements.poll_failed",{code:k.error.code}),m(s());break;default:m(s());}return e.onSettled?.(),k},"tick"),b=i(()=>{let S=T().finally(()=>{h===S&&(h=null);});return h=S,S},"run");return {start(){a||l||(a=true,b());},prime(){return l?Promise.resolve(null):h??b()},stop(){l||(l=true,p++,f());},refresh(){l||!a||(p++,d=null,f(),b());}}}i(hu,"createEntitlementPoller");var Jh={set(e,t){let r=setTimeout(e,t);return r.unref?.(),r},clear(e){clearTimeout(e);}};function eb(e){return e instanceof Error?e.message:"poll failed"}i(eb,"describe");var bu="everfur.notifications.device";var tb=3e3,vu=Object.freeze([bu]);function Eu(e){let{leaving:t,identity:r,hooks:n,telemetry:o}=e;if(t===null||r===null||n.size===0)return null;let s=Object.freeze({userRef:t.userRef,auth:e.graceAuth()}),a=[...n].map(d=>{try{return Promise.resolve(d(s))}catch(c){return Promise.reject(c)}}),l=i((d,c)=>{try{o.track("sdk.logout.hookFailed",{reason:d,count:c,totalCount:a.length});}catch{}},"report"),u=Promise.allSettled(a).then(d=>{let c=d.filter(p=>p.status==="rejected").length;c>0&&l("failed",c);});return new Promise(d=>{let c=false,p=i(()=>{c||(c=true,clearTimeout(f),d());},"finish"),f=setTimeout(()=>{c||l("timeout",a.length),p();},tb);u.then(p,p);})}i(Eu,"startBeforeLogoutHooks");function Cu(e){let{leaving:t,identity:r,transport:n,sessionId:o}=e,s=r.currentToken();s.catch(()=>{});let a={userRef:t.userRef,currentToken:i(()=>s,"currentToken"),hasToken:i(()=>true,"hasToken"),clear:i(()=>{},"clear")};return {mode:"personalized",transport:n,identity:a,userRef:t.userRef,sessionId:o}}i(Cu,"graceAuth");async function Ru(e,t){if(vu.length===0)return;let r=await Promise.allSettled(vu.map(o=>e.removeItem(o))),n=r.filter(o=>o.status==="rejected").length;n>0&&t.track("sdk.logout.sweepPartialFailure",{failedCount:n,totalCount:r.length});}i(Ru,"sweepPerUserKv");function rb(){return Object.freeze([Object.freeze({resource:"chat.message.create",granted:true})])}i(rb,"compiledDefaultDecisions");function fi(e=rb){let t=new Set,r=Object.freeze({decisions:e(),isPending:false,branding:null}),n=i(()=>{for(let o of t)o();},"emit");return {subscribe(o){return t.add(o),()=>{t.delete(o);}},getSnapshot(){return r},set(o){r=Object.freeze({decisions:Object.freeze([...o.decisions]),isPending:o.isPending,branding:o.branding??null,...o.livemode===false?{livemode:false}:{}}),n();},reset(){r=Object.freeze({decisions:e(),isPending:false,branding:null}),n();},setPending(o){r.isPending!==o&&(r=Object.freeze({...r,isPending:o}),n());}}}i(fi,"createEntitlementStore");function mi(e){return D("validationFailed",{retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`})}i(mi,"notConfiguredError");function Su(e,t){let r={publishableKey:e.publishableKey,...e.apiBaseUrl!==void 0?{apiBaseUrl:e.apiBaseUrl}:{},...e.contractVersion!==void 0?{contractVersion:e.contractVersion}:{},...e.debug!==void 0?{debug:e.debug}:{}};return oa(r,t===void 0?void 0:{platform:t})}i(Su,"tryResolveClient");function Tu(e){return Object.freeze({track(t,r){try{e.track(t,r);}catch{}},trackExpectedFailure(t,r){try{e.trackExpectedFailure(t,r);}catch{}}})}i(Tu,"guardTelemetry");var nb=Object.freeze({"react-native":"If the value is set in your environment, note that babel-preset-expo inlines only EXPO_PUBLIC_* variables into a release bundle.",web:`If the value is set in your environment, note that a browser bundle does not expose ${Jr} to the SDK at run time (bundlers inline only the variables your own code names), so pass apiBaseUrl in config.`});function Pu(e,t,r=ho){try{t.trackExpectedFailure("sdk.config.invalid",{reason:e.reason});}catch{}globalThis.console?.error?.(`[everfur] SDK disabled: ${e.message}
|
|
12
|
+
[everfur] Every Everfur capability will render its off-state until this is fixed. `+nb[r]);}i(Pu,"reportConfigFailure");function yi(e){return Object.freeze({request(){return Promise.resolve(v(mi(e)))},stream(t,r){let n=ye({code:"sdk_not_configured",retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`,synthesized:true,lastEventId:null});return {async*[Symbol.asyncIterator](){r.aborted||(yield n);}}}})}i(yi,"refusingTransport");function ku(){let e=new Map;return {async getItem(t){return e.get(t)??null},async setItem(t,r){e.set(t,r);},async removeItem(t){e.delete(t);},async keys(t){return [...e.keys()].filter(r=>r.startsWith(t))}}}i(ku,"createInMemoryKv");var xu=Object.freeze({clearMemoryCache(){},clearDiskCache(){}});function Iu(e,t){return new hi(e,t)}i(Iu,"createEverfurRuntime");var ob=6e4,bi=class bi{constructor(t,r){this.sessionId=yo();this.entries=new Map;this.destroyers=new Map;this.epoch=0;this.disposed=false;this.verdictSettled=false;this.refreshTimer=null;this.bootstraps=new WeakMap;this.prepared=null;this.beforeLogoutHooks=new Set;this.pendingBeforeLogout=null;this.leavingSessionId=null;let n=t.config;if(n.secureStore!==void 0&&n.secureStore.isAvailable===true)throw new re("invalid-argument","config.secureStore is not yet consumable: SDK token persistence is unimplemented. Omit secureStore to keep memory-only tokens (SPEC-10 \xA75.3).");this.telemetry=n.telemetry?Tu(n.telemetry):Qr;let o=typeof n?.publishableKey=="string"?n.publishableKey.trim():"",s=bo(n?.publishableKey),a=n.transport!==void 0,l,u=typeof n.apiBaseUrl=="string"&&n.apiBaseUrl.trim().length>0?n.apiBaseUrl.trim():null;if(s!==null)l=yi(s);else if(n.transport!==void 0)l=n.transport;else {let c=Su(n,r?.platform);c.ok?(u=c.config.apiBaseUrl,l=da({config:c.config,...r?.eventSourceFactory?{eventSourceFactory:r.eventSourceFactory}:{}})):(s=c.failure,l=yi(c.failure));}this.configFailure=s,this.publishableKey=s===null?o:"",this.transport=l,s!==null&&Pu(s,this.telemetry,r?.platform),this.errorPolicy=n.errorPolicy,this.camera=n.camera??Ws,this.upload=n.upload??_a,this.uploadTransport=n.uploadTransport??Uo,this.imageCache=n.imageCache??xu,this.kv=n.storage??ku(),this.currentUser=t.user??null,this.identity=this.buildIdentity(t.user??null),this.activePet=t.activePet,this.store=s===null?fi():fi(()=>Tl("sdk_config",Dt("accessDenied"))),this.services={authFor:i(c=>this.buildAuth(c),"authFor"),telemetry:this.telemetry,errorPolicy:this.errorPolicy,camera:this.camera,upload:this.upload,uploadTransport:this.uploadTransport,imageCache:this.imageCache,kv:this.kv,apiBaseUrl:u},this.registry={services:this.services,acquireChat:i(c=>this.acquireInternal("chat",gi(c),()=>this.buildChatController(c),_u),"acquireChat"),releaseChat:i(c=>this.releaseInternal(c),"releaseChat"),peekChat:i(c=>this.entries.get(`${this.epoch}|chat|${gi(c)}`)?.controller??null,"peekChat"),acquire:i((c,p,f,m)=>this.acquireInternal(c,p,f,m),"acquire"),release:i(c=>this.releaseInternal(c),"release")},this.entitlements=this.store;let d=s===null&&(r?.startEntitlementPolling??!a);this.poller=s===null?this.buildPoller(r?.pollScheduler):null,d&&this.poller?.start();}get isDisposed(){return this.disposed}get scopeEpoch(){return this.epoch}buildIdentity(t){if(t===null)return null;let r=Zs(t.userRef,t.getToken,n=>this.armTokenRefresh(r,n));return r}armTokenRefresh(t,r){if(this.clearTokenRefresh(),r===null||this.disposed||t!==this.identity)return;let n=r-Date.now();if(n<=0)return;let o=Math.max(n-ob,n/2);this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,!(this.disposed||t!==this.identity)&&t.currentToken({forceRefresh:true}).catch(()=>{});},o),this.refreshTimer.unref?.();}clearTokenRefresh(){this.refreshTimer!==null&&clearTimeout(this.refreshTimer),this.refreshTimer=null;}buildPoller(t){return hu({authFor:i(()=>this.buildAuth(this.currentUser?.userRef??null),"authFor"),update:i((r,n,o)=>this.updateEntitlements({decisions:r,isPending:false,branding:n,...o===false?{livemode:o}:{}}),"update"),onFetch:i(()=>{this.verdictSettled||this.store.setPending(true);},"onFetch"),onSettled:i(()=>{this.verdictSettled=true,this.store.setPending(false);},"onSettled"),telemetry:this.telemetry,...t?{scheduler:t}:{}})}acquireInternal(t,r,n,o,s=false){let a=`${this.epoch}|${t}|${r}`,l=this.entries.get(a);if(l)return s||(l.warm?l.warm=false:l.refCount+=1),l.controller;let u=n();return this.entries.set(a,{controller:u,refCount:1,warm:s}),this.destroyers.set(u,o),u}releaseInternal(t){for(let[r,n]of this.entries)if(n.controller===t){n.refCount-=1,n.refCount<=0&&(this.runDestroyer(t),this.entries.delete(r));return}}runDestroyer(t){let r=this.destroyers.get(t);this.destroyers.delete(t),r&&r(t);}buildChatController(t){let r=qa({auth:this.buildAuth(t.userRef),telemetry:this.telemetry,...this.errorPolicy?{errorPolicy:this.errorPolicy}:{},initialConversationId:t.conversationId,petRef:t.petRef});return this.runBootstrap(r,t),r}runBootstrap(t,r){let n={};r.petRef!==null&&(n.petRef=r.petRef),r.conversationId!==null&&(n.resumeConversationId=r.conversationId);let o=Xa(n,{controller:t});return o.then(s=>t.adoptPrompts(s.suggestedPrompts)).catch(()=>{}),this.bootstraps.set(t,o),o}buildAuth(t){return this.identity!==null&&this.currentUser!==null?{mode:"personalized",transport:this.transport,identity:this.identity,userRef:this.currentUser.userRef,sessionId:this.sessionId}:{mode:"anonymous",transport:this.transport,publishableKey:this.publishableKey,userRef:this.currentUser===null?null:t,sessionId:this.sessionId}}setUser(t){if(this.disposed)return;let r=t?.userRef??null,n=this.currentUser?.userRef??null;if(r===n){this.currentUser=t,t&&this.identity===null&&(this.identity=this.buildIdentity(t));return}this.pendingBeforeLogout=this.beforeLogoutSettlement(),this.identity?.clear(),this.clearTokenRefresh(),this.currentUser=t,this.identity=this.buildIdentity(t),this.rescopeAll();}async logout(){if(this.disposed)return;let t=this.currentUser===null;this.leavingSessionId=this.sessionId,this.sessionId=yo(),this.setUser(null),this.leavingSessionId=null,t&&this.rescopeAll();let r=this.pendingBeforeLogout;this.pendingBeforeLogout=null,r!==null&&await r,await Ru(this.kv,this.telemetry);}onBeforeLogout(t){return this.disposed?()=>{}:(this.beforeLogoutHooks.add(t),()=>{this.beforeLogoutHooks.delete(t);})}beforeLogoutSettlement(){let t=this.currentUser,r=this.identity;return Eu({leaving:t,identity:r,hooks:this.beforeLogoutHooks,telemetry:this.telemetry,graceAuth:i(()=>Cu({leaving:t,identity:r,transport:this.transport,sessionId:this.leavingSessionId??this.sessionId}),"graceAuth")})}async registerPet(t,r){return this.withPets("registerPet",n=>r===void 0?n.registerPet(t):n.registerPet(t,r))}updatePet(t,r){return this.withPets("updatePet",n=>n.updatePet(t,r))}deletePet(t){return this.withPets("deletePet",r=>r.deletePet(t))}eraseUserData(){return this.withPets("eraseUserData",t=>t.eraseUserData())}async withPets(t,r){return this.disposed?v(wu(t)):r(lt(this.buildAuth(this.currentUser?.userRef??null)))}prepare(t){let r=t?.petRef??null,n=`${this.epoch}|${this.currentUser?.userRef??""}|${r??""}`,o=this.prepared;if(o!==null&&o.key===n&&(o.result===null||o.result.status==="ready"))return o.promise;let s={key:n,result:null,promise:this.runPrepare(r).then(a=>(s.result=a,a))};return this.prepared=s,s.promise}async runPrepare(t){let r=Date.now(),n=this.configFailure,o=this.disposed?wu("prepare"):n===null?null:mi(n),s=this.identity,[a,l,u]=await Promise.all([o?v(o):s===null?L(void 0):s.currentToken().then(()=>L(void 0),()=>v(D("authRejected",{retryable:false}))),o?v(o):this.primeEntitlements(),t===null?void 0:o?v(o):this.primeChat(t)]),d=a.ok?l.ok&&(u?.ok??true)?"ready":"partial":"failed",c=Date.now()-r;try{this.telemetry.track("sdk.prepare.timing",{durationMs:c,status:d});}catch{}return Object.freeze({status:d,durationMs:c,session:a,entitlements:l,...u?{chat:u}:{}})}async primeEntitlements(){let t=await this.poller?.prime();return t?t.kind==="failed"?v(t.error):L(void 0):v(D("internalError",{retryable:true}))}async primeChat(t){let r={userRef:this.currentUser?.userRef??null,petRef:t,conversationId:null},n=this.acquireInternal("chat",gi(r),()=>this.buildChatController(r),_u,true),o=await this.bootstraps.get(n);return o?.cause&&n.getSnapshot().conversationId===null&&(o=await this.runBootstrap(n,r)),o?.cause?v(o.cause):L(void 0)}setActivePet(t){if(this.disposed)return;let r=t??null;r!==this.activePet&&(this.activePet=r,this.rescopeAll());}updateEntitlements(t){this.disposed||this.configFailure===null&&this.store.set(t);}open(t){this.telemetry.track("sdk.open",{capability:t});}dispose(){this.disposed||(this.disposed=true,this.epoch+=1,this.poller?.stop(),this.identity?.clear(),this.clearTokenRefresh(),this.disposeAllControllers());}rescopeAll(){this.epoch+=1,this.disposeAllControllers(),this.store.reset(),this.verdictSettled=false,this.poller?.refresh();}disposeAllControllers(){for(let t of this.entries.values())this.runDestroyer(t.controller);this.entries.clear(),this.destroyers.clear();}};i(bi,"EverfurRuntimeImpl");var hi=bi;function gi(e){return `${e.userRef??""}|${e.petRef??""}|${e.conversationId??""}`}i(gi,"chatScopeKey");function _u(e){e.dispose();}i(_u,"disposeChat");function wu(e){return D("validationFailed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}i(wu,"disposedError");var Au=Symbol.for("@everfur/sdk#EverfurContext@v1"),Ou=globalThis,En=Ou[Au]??(Ou[Au]=react.createContext(null));En.displayName??="EverfurContext";function ee(){let e=react.useContext(En);if(e===null)throw new re("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(ee,"useEverfurContext");function Fu(){return ee().handle}i(Fu,"useEverfur");var Mu=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Lu=globalThis,Cr=Lu[Mu]??(Lu[Mu]=react.createContext(Be));Cr.displayName??="EverfurThemeContext";function N(){return react.useContext(Cr)}i(N,"useEverfurTheme");function Cn(e){let{runtime:t}=ee(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot),o=e.seams.useColorScheme(),s=e.seams.useReducedMotion(),a=e.seams.useTextScale(),l=e.seams.useHighContrast(),u=e.seams.scaleTypeSizes,d=e.seams.platformMonoFamily?.(),c=e.seams.isFontRegistered,p=e.clientTheme?cb(e.clientTheme):"",f=react.useMemo(()=>e.clientTheme?Xe(e.clientTheme):null,[p]),m=n.branding??null,h=react.useMemo(()=>ci({branding:m,clientOverride:f,colorScheme:o,reducedMotion:s,textScale:a,scaleTypeSizes:u,highContrast:l,...d===void 0?{}:{platformMonoFamily:d},...c===void 0?{}:{isFontRegistered:c}}),[m,f,o,s,a,u,l,d,c]);return e.seams.useResolvedTheme?.(h),react.createElement(Cr.Provider,{value:h},e.children)}i(Cn,"EverfurThemeProviderCore");function cb(e){try{return JSON.stringify(e)}catch{return Object.keys(e).join("&")}}i(cb,"stableKey");function Bu(e){let{config:t,user:r,activePet:n,theme:o,warmUp:s,children:a,seams:l}=e,u=`${t?.publishableKey??""}|${t?.apiBaseUrl??""}|${t?.contractVersion??""}`,d=react.useRef(null),c=react.useRef(null),[p,f]=react.useReducer(w=>w+1,0),m=react.useRef(null),h=react.useRef(void 0),T=r?.userRef??null;h.current!==T&&(h.current!==void 0&&(m.current=null),h.current=T);let b=m.current!==null?m.current.user:r??null,S=react.useRef(null),P=react.useRef(void 0),k=n??null;P.current!==k&&(P.current!==void 0&&(S.current=null),P.current=k);let x=S.current!==null?S.current.pet:n??null;(d.current===null||d.current.key!==u||d.current.runtime.isDisposed)&&(d.current!==null&&!d.current.runtime.isDisposed&&(c.current=d.current.runtime),d.current={key:u,runtime:Iu({config:l.withDefaults?l.withDefaults(t):t,user:b,activePet:x,theme:o??null},{platform:l.platform,...l.eventSourceFactory?{eventSourceFactory:l.eventSourceFactory}:{}})});let y=d.current.runtime,_=react.useRef(null);react.useEffect(()=>{let w=d.current?.runtime;w===void 0||!w.isDisposed||_.current!==w&&(_.current=w,f());}),react.useEffect(()=>{let w=c.current;w!==null&&(c.current=null,w.dispose());});let A=b?.userRef??null;react.useLayoutEffect(()=>{y.setUser(b);},[y,A]),react.useLayoutEffect(()=>{y.setActivePet(x);},[y,x]),react.useEffect(()=>()=>y.dispose(),[y]),react.useEffect(()=>{s==="onMount"&&y.prepare(x===null?{}:{petRef:x});},[y,s,A,x]);let O=react.useMemo(()=>({setUser:i(w=>{m.current={user:w},y.setUser(w),f();},"setUser"),setActivePet:i(w=>{S.current={pet:w},y.setActivePet(w),f();},"setActivePet"),open:i(w=>y.open(w),"open"),prepare:i(w=>y.prepare(w),"prepare"),registerPet:i((w,I)=>y.registerPet(w,I),"registerPet"),updatePet:i((w,I)=>y.updatePet(w,I),"updatePet"),deletePet:i(w=>y.deletePet(w),"deletePet"),eraseUserData:i(()=>y.eraseUserData(),"eraseUserData"),logout:i(()=>{m.current={user:null};let w=y.logout();return f(),w},"logout")}),[y,f]),F=react.useMemo(()=>({runtime:y,handle:O,userRef:A,activePet:x,scopeEpoch:y.scopeEpoch}),[y,O,A,x,p]),C=react.createElement(Cn,{clientTheme:o??null,seams:l.theme,children:a});return react.createElement(En.Provider,{value:F},l.wrap?l.wrap(C):C)}i(Bu,"EverfurProviderCore");var mb=2;function yb(e,t){let r=e?._xhr;if(!r||typeof r.getResponseHeader!="function"||typeof r.readyState=="number"&&r.readyState<mb)return null;let n;try{n=r.getResponseHeader(t);}catch{return null}return typeof n=="string"&&n.length>0?n:null}i(yb,"readEventSourceResponseHeader");function Hu(){let e=fb__default.default;return (t,r)=>{let n=new e(t,{method:r.method,headers:r.headers,pollingInterval:r.pollingInterval??0,...r.body!==void 0?{body:r.body}:{}});return Object.assign(n,{getResponseHeader:i(o=>yb(n,o),"getResponseHeader")})}}i(Hu,"createRnEventSourceFactory");function vb(){let e=reactNative.useColorScheme();return e==="dark"?"dark":e==="light"?"light":null}i(vb,"useRnColorScheme");function Eb(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(Eb,"isThenable");function Cb(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,n=reactNative.AccessibilityInfo?.isReduceMotionEnabled;if(typeof n=="function"){let s=n.call(reactNative.AccessibilityInfo);s!=null&&typeof s.then=="function"&&s.then(a=>{r&&t(a===true);},()=>{});}let o=reactNative.AccessibilityInfo?.addEventListener?.("reduceMotionChanged",s=>t(s===true));return ()=>{r=false,o?.remove?.();}},[]),e}i(Cb,"useRnReducedMotion");function Wu(){let e=reactNative.PixelRatio?.getFontScale;if(typeof e!="function")return 1;try{let t=e.call(reactNative.PixelRatio);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}catch{return 1}}i(Wu,"readFontScale");function Rb(e){let t=reactNative.Dimensions?.addEventListener;if(typeof t!="function")return ()=>{};let r=t.call(reactNative.Dimensions,"change",e);return ()=>r?.remove?.()}i(Rb,"subscribeFontScale");function Sb(){return react.useSyncExternalStore(Rb,Wu,Wu)}i(Sb,"useRnTextScale");function $u(){try{let e=reactNative.Platform?.OS;return typeof e=="string"?e:null}catch{return null}}i($u,"platformOS");function Tb(){return $u()==="android"?{query:"isHighTextContrastEnabled",event:"highTextContrastChanged"}:{query:"isDarkerSystemColorsEnabled",event:"darkerSystemColorsChanged"}}i(Tb,"contrastSignal");function Pb(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,{query:n,event:o}=Tb(),a=reactNative.AccessibilityInfo?.[n];if(typeof a!="function")return ()=>{};try{let d=a.call(reactNative.AccessibilityInfo);Eb(d)&&Promise.resolve(d).then(c=>{r&&t(c===!0);},()=>{});}catch{}let l=reactNative.AccessibilityInfo?.addEventListener,u=typeof l=="function"?l.call(reactNative.AccessibilityInfo,o,d=>t(d===true)):void 0;return ()=>{r=false,u?.remove?.();}},[]),e}i(Pb,"useRnHighContrast");function kb(){return $u()==="ios"?"Menlo":Ve}i(kb,"rnPlatformMonoFamily");function xb(){return globalThis.__DEV__!==false}i(xb,"isDevelopment");var Gu=new Set;function _b(e){if(!xb()||Gu.has(e))return;Gu.add(e);let t=globalThis.console;try{t?.warn?.(`[everfur] The theme names the font face "${e}", which this app has not registered; the SDK renders the platform font at that weight instead. Register the font file (expo-font or your native font assets) or name a registered face.`);}catch{}}i(_b,"warnUnregisteredFace");function wb(e){let t=globalThis.expo?.modules?.ExpoFontLoader,r=t?.getLoadedFonts;if(typeof r!="function")return null;let n;try{n=r.call(t);}catch{return null}if(!Array.isArray(n)||n.length===0)return null;let o=n.includes(e);return o||_b(e),o}i(wb,"rnIsFontRegistered");var Sn=Object.freeze({useColorScheme:vb,useReducedMotion:Cb,useTextScale:Sb,useHighContrast:Pb,scaleTypeSizes:false,platformMonoFamily:kb,isFontRegistered:wb});function Ab(e){return react.createElement(reactNativeSafeAreaContext.SafeAreaProvider,null,e)}i(Ab,"wrapInSafeArea");var Ob=Object.freeze({platform:"react-native",eventSourceFactory:Hu(),wrap:Ab,theme:Sn});function Fb(e){return react.createElement(Bu,{...e,seams:Ob})}i(Fb,"EverfurProvider");function Wt(e){let{runtime:t}=ee(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return react.useMemo(()=>Pl(e,n.decisions,{isPending:n.isPending}),[e,n])}i(Wt,"useCapability");function Vb(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(Vb,"tierMultiplier");function E({tier:e="content",...t}){let{type:r}=N(),n=Vb(r,e);return react.createElement(reactNative.Text,n===void 0?t:{maxFontSizeMultiplier:n,...t})}i(E,"Text");var Gt=react.forwardRef(i(function(t,r){return react.createElement(reactNative.TextInput,{...t,...r===null?{}:{ref:r}})},"TextInput"));var Bb=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function R(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[Bb[t]]}}i(R,"face");var Ei=class Ei 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(Ei,"HostRenderBoundary");var vi=Ei;function zb({render:e}){return e()}i(zb,"RenderHost");function xt({render:e,fallback:t,resetKey:r}){return react.createElement(vi,{fallback:t,resetKey:r,children:react.createElement(zb,{render:e})})}i(xt,"HostRender");var jb=48;function Wb(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(Wb,"selectView");function Si(e){let{capability:t,children:r,renderDisabled:n,renderPending:o,style:s}=e,a=Wt(t),l=react.useMemo(()=>Wb(a),[a]);switch(l){case "enabled":return r;case "pending":return o?jsxRuntime.jsx(xt,{render:o,fallback:jsxRuntime.jsx(Ju,{capability:t,style:s})}):jsxRuntime.jsx(Ju,{capability:t,style:s});case "disabled":return n?jsxRuntime.jsx(xt,{render:()=>n(a),fallback:jsxRuntime.jsx(ed,{decision:a,style:s}),resetKey:a}):jsxRuntime.jsx(ed,{decision:a,style:s});default:return at(l)}}i(Si,"CapabilityGate");function Ju({capability:e,style:t}){let r=N(),n=react.useMemo(()=>td(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(Ju,"PendingSkeleton");function ed({decision:e,style:t}){let r=N(),n=react.useMemo(()=>td(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(E,{style:n.offstateText,children:o}):null})}i(ed,"OffState");function td(e){let{color:t,space:r,radius:n,type:o}=e;return reactNative.StyleSheet.create({offstate:{minHeight:jb,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...R(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(td,"makeStyles");var g=Object.freeze({placeholder:"Ask anything about {petName}\u2026",placeholderFollowUpWeb:"Ask a follow-up\u2026",placeholderUrgentWeb:"Tell us what\u2019s happening\u2026",composerLabel:"Message",attachPhotoOrFileNative:"Add a photo or file",footnoteNative:"Educational, not a diagnosis. Emergency? Call a vet.",footnoteWeb:"Everfur\u2019s assistant isn\u2019t a vet and doesn\u2019t diagnose. Your vet makes the calls. Not for emergencies: if {petName} is in distress, go to the nearest emergency animal hospital now.",suggestions:"Suggestions",reading:"Reading {petName}\u2019s records\u2026",answered:"Everfur answered.",assistantName:"Everfur",followUpsHeadingNative:"Follow-up questions",turnFailedTitleWeb:"Everfur couldn\u2019t answer that just now.",send:"Send",stop:"Stop",retry:"Try again",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",senderVet:"Your vet",loading:"Loading",empty:"No messages yet",transcript:"Chat with Everfur",emptyTitle:"What can we help {petName} with today?",emptyTitlePetFallback:"your pet",copied:"Copied",copyUserMessage:"Copy your message",copyAssistantMessage:"Copy assistant message",feedbackHelpful:"Helpful",feedbackNeutral:"Neutral",feedbackNotHelpful:"Not helpful",feedbackTitle:"What went wrong?",feedbackSubtitle:"Your feedback helps make answers more reliable.",feedbackReasonInaccurate:"Inaccurate",feedbackReasonOutdated:"Out of date",feedbackReasonUnsafe:"Unsafe advice",feedbackReasonUnclear:"Confusing or unclear",feedbackReasonOther:"Something else",feedbackNotesPlaceholder:"Add details (optional)",feedbackSubmit:"Submit feedback",feedbackSkip:"Skip",feedbackSkipA11y:"Skip feedback",feedbackThanks:"Thanks for the feedback",feedbackFailed:"Couldn't send feedback. Please try again.",turnFailedTitle:"Message failed",turnRetry:"Retry",turnUnreachableTitle:"Couldn't reach this chat",turnStartNewChat:"Start a new chat",reconnecting:"Reconnecting\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",nearestEmergencyVet:"Nearest emergency vet",poisonControlWeb:"ASPCA Poison Control",poisonControlNative:"ASPCA Animal Poison Control, (888) 426-4435",showLatestVetAlert:"Show latest vet alert",dismissBanner:"Dismiss {label} banner",openHistoryNative:"Chats and vet messages",openHistoryWeb:"Chats",showChatsWeb:"Show chats",hideChatsWeb:"Hide chats",newReplySuffix:", a new reply",yourPets:"Your pets",yourPet:"Your pet",switchActivePet:"{name}. Switch pet",petCurrentlyActive:"{name}, currently active",switchToPet:"Switch to {name}",activePrefix:"Active \xB7 ",close:"Close",addAnotherPet:"Add a 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 K(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let o=t[n];return o===void 0?r:String(o)})}i(K,"fillCopy");function Gb(e){return e?.trim()||g.emptyTitlePetFallback}i(Gb,"petNameSlot");function Tn(e,t){return K(e,{petName:Gb(t)})}i(Tn,"forPet");var rd="tel:+18884264435";var Ti=Object.freeze([Object.freeze({key:"inaccurate",label:g.feedbackReasonInaccurate,feedbackType:"wrong"}),Object.freeze({key:"outdated",label:g.feedbackReasonOutdated,feedbackType:"outdated"}),Object.freeze({key:"unsafe",label:g.feedbackReasonUnsafe,feedbackType:"dangerous"}),Object.freeze({key:"unclear",label:g.feedbackReasonUnclear,feedbackType:"unclear"}),Object.freeze({key:"other",label:g.feedbackReasonOther,feedbackType:"not_helpful"})]),nd=Object.freeze([Object.freeze({sentiment:"up",label:g.feedbackHelpful}),Object.freeze({sentiment:"neutral",label:g.feedbackNeutral}),Object.freeze({sentiment:"down",label:g.feedbackNotHelpful})]);function Kb(e){switch(e){case "up":return "helpful";case "neutral":return "neutral";case "down":return "not_helpful"}}i(Kb,"sentimentToFeedbackType");function od(e,t){if(e==="down"&&t!==null){let r=Ti.find(n=>n.key===t);if(r!==void 0)return r.feedbackType}return Kb(e)}i(od,"feedbackTypeFor");var Xb=Object.freeze({status:"idle",messages:Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:Object.freeze([]),unreadCount:null});function Rr(e){let{runtime:t,userRef:r,activePet:n,scopeEpoch:o}=ee(),s=e?.petRef??n??null,a=e?.conversationId??null,l=react.useMemo(()=>({runtime:t,userRef:r,petRef:s,conversationId:a,scopeEpoch:o}),[t,r,s,a,o]),[u,d]=react.useState(null),c=u?.scope===l?u.controller:t.registry.peekChat({userRef:r,petRef:s,conversationId:a}),p=react.useRef(null);react.useEffect(()=>{let F=t.registry.acquireChat({userRef:r,petRef:s,conversationId:a});return p.current=F,d({scope:l,controller:F}),()=>{p.current=null,d(C=>C?.controller===F?null:C),t.registry.releaseChat(F);}},[t,r,s,a,o,l]);let f=react.useCallback(F=>c?c.subscribe(F):Qb,[c]),m=react.useCallback(()=>c?c.getSnapshot():Xb,[c]),h=react.useSyncExternalStore(f,m,m),T=react.useCallback((F,C)=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?ki(c,c.send(F,C?.imageS3Keys===void 0?{}:{imageS3Keys:C.imageS3Keys}),()=>p.current===c):Promise.resolve(xi()),[c]),b=react.useCallback(F=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?ki(c,c.askEverfur(F),()=>p.current===c):Promise.resolve(xi()),[c]),S=react.useCallback(()=>c&&p.current===c?ki(c,c.retryLast(),()=>p.current===c):Promise.resolve(xi()),[c]),P=react.useCallback(()=>{c&&p.current===c&&c.stop();},[c]),k=react.useCallback(()=>{c&&p.current===c&&c.newConversation();},[c]),[x,y]=react.useState({controller:null,byMessage:{}}),_=x.controller===c?x.byMessage:Zb,A=react.useCallback(async(F,C,w,I)=>{if(!c||p.current!==c)return v(D("accessDenied"));let H=String(F),Q=x.controller===c?x.byMessage[H]:void 0;if(Q===C&&w==null)return y(Y=>{let we={...Y.controller===c?Y.byMessage:{}};return delete we[H],{controller:c,byMessage:we}}),L(Object.freeze({feedbackId:""}));y(Y=>({controller:c,byMessage:{...Y.controller===c?Y.byMessage:{},[H]:C}}));let oe=await c.submitFeedback(F,od(C,w??null),I??null);return p.current!==c?v(D("accessDenied")):(oe.ok||y(Y=>{let we={...Y.controller===c?Y.byMessage:{}};return Q===void 0?delete we[H]:we[H]=Q,{controller:c,byMessage:we}}),oe)},[c,x]),O=react.useMemo(()=>{let F=i(async C=>{if(!c||p.current!==c)return v(D("accessDenied"));let w=await C(c);return p.current===c?w:v(D("accessDenied"))},"run");return {listConversations:i(C=>F(w=>w.listConversations({...s?{petRef:s}:{},...C})),"listConversations"),getMessages:i((C,w)=>F(I=>I.getMessages(C,w)),"getMessages"),resumeConversation:i(C=>F(w=>w.resumeConversation(C)),"resumeConversation"),loadOlderMessages:i(()=>F(C=>C.loadOlderMessages()),"loadOlderMessages"),markRead:i(()=>F(C=>C.markRead()),"markRead"),refreshActiveThread:i(()=>F(C=>C.refreshActiveThread()),"refreshActiveThread"),answerCheckin:i((C,w)=>F(I=>I.answerCheckin(C,w)),"answerCheckin"),openCheckin:i(C=>F(w=>w.openCheckin(C)),"openCheckin")}},[c,s]);return react.useMemo(()=>({status:h.status,messages:h.messages,conversationId:h.conversationId,petRef:s,error:h.error,isStreaming:h.isStreaming,isBootstrapping:h.isBootstrapping,historyCursor:h.historyCursor??null,isLoadingHistory:h.isLoadingHistory??false,stopped:h.stopped??false,reconnecting:h.reconnecting??false,...O,suggestedPrompts:h.suggestedPrompts,unreadCount:h.unreadCount,hasUnreadThreads:h.hasUnreadThreads??false,newConversation:k,sentimentByMessage:_,feedback:A,send:T,askEverfur:b,retryLast:S,stop:P}),[h,s,T,b,S,P,O,k,_,A])}i(Rr,"useEverfurChat");var Qb=i(()=>{},"NOOP_UNSUBSCRIBE"),Zb=Object.freeze({});async function ki(e,t,r){for await(let o of t);if(!r())return v(D("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?v(n.error):L(Jb(n.messages))}i(ki,"driveToResult");function Jb(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(Jb,"lastAssistantResponseId");function xi(){return v(D("internalError",{retryable:true}))}i(xi,"notReadyError");function ld(e){switch(e.code){case "too_large":return K(g.attachmentTooLarge,{max:Bo(sn),filename:e.filename,size:Bo(e.sizeBytes??0)});case "too_many":return K(g.attachmentTooMany,{max:an});case "unsupported_type":return K(g.attachmentUnsupported,{filename:e.filename});case "network":return g.attachmentNetwork;case "server":return K(g.attachmentServer,{status:e.httpStatus?` (${e.httpStatus})`:""});case "cancelled":return g.attachmentCancelled;case "rate_limited":return g.attachmentRateLimited;case "quota_exceeded":return g.attachmentQuota;case "idempotency_conflict":return g.attachmentConflict;case "unknown":return g.attachmentUnknown}}i(ld,"attachmentErrorMessage");function ud(e,t){return K(e>=t?g.attachmentsFull:g.addAttachment,{used:e,total:t})}i(ud,"attachControlLabel");var nv=Object.freeze({attachments:Object.freeze([])});function Pn(e={}){let{runtime:t,userRef:r,scopeEpoch:n}=ee(),o=e.maxPerMessage??an,s=react.useCallback(()=>{let{services:y}=t.registry;return Ja({funnel:Ie({auth:y.authFor(r),...y.errorPolicy?{errorPolicy:y.errorPolicy}:{}}),transport:e.transport??y.uploadTransport,maxPerMessage:o})},[t,r,n,o,e.transport]),a=react.useMemo(()=>e.queue??s(),[e.queue,s]),l=react.useRef(new WeakSet),[u,d]=react.useState(null),c=u!==null&&u.of===a?u.queue:a;react.useEffect(()=>{if(c!==e.queue){if(l.current.has(c)){d({of:a,queue:s()});return}return ()=>{c.dispose(),l.current.add(c);}}},[c,a,s,e.queue]);let p=react.useSyncExternalStore(c.subscribe,c.getSnapshot,()=>nv),[f,m]=react.useState(null),h=react.useCallback(y=>{let A=(Array.isArray(y)?y:[y]).map(F=>c.add(F)),O=A.find(F=>!F.ok);return O!==void 0&&!O.ok&&m(O.error),A},[c,m]),T=react.useCallback(y=>c.retry(y),[c]),b=react.useCallback(y=>c.remove(y),[c]),S=react.useCallback(()=>c.clear(),[c]),P=react.useCallback(()=>m(null),[m]),k=p.attachments.some(y=>y.status==="uploading"),x=p.attachments.some(y=>y.status==="failed");return react.useMemo(()=>({available:c.available,attachments:p.attachments,maxPerMessage:o,uploading:k,failed:x,blocked:k||x,s3Keys:p.attachments.flatMap(y=>y.status==="uploaded"&&y.s3Key!==null?[y.s3Key]:[]),rejected:f,add:h,retry:T,remove:b,clear:S,dismissRejected:P}),[c.available,p,o,k,x,f,h,T,b,S,P])}i(Pn,"useChatAttachments");var sv="pet_not_registered";function pd(e){return e!=null&&e.reasonCode===sv}i(pd,"isPetNotRegistered");var av=Object.freeze({status:"idle",error:null,registered:null,retry:i(()=>{},"retry")});function fd(e,t,r){let{runtime:n,userRef:o,scopeEpoch:s}=ee(),a=react.useCallback(()=>lt(n.registry.services.authFor(o)),[n,o,s]),l=react.useMemo(()=>t===void 0?null:wi(t),[t]),[u,d]=react.useState({key:null,status:"idle",error:null,registered:null}),c=react.useRef(0),p=react.useRef(r);p.current=r;let f=e===null||l===null?null:`${String(o)}|${s}|${e}|${l}`,m=react.useCallback(()=>{if(e===null||t===void 0||f===null)return;let T=++c.current;d({key:f,status:"registering",error:null,registered:null}),a().registerPet(e,t).then(b=>{T===c.current&&(b.ok?(d({key:f,status:"registered",error:null,registered:b.value}),p.current?.()):d({key:f,status:"failed",error:b.error,registered:null}));});},[a,e,f]);react.useEffect(()=>{if(f===null){c.current+=1;return}return m(),()=>{c.current+=1;}},[f,m]);let h=react.useCallback(()=>{u.status==="failed"&&m();},[u.status,m]);return react.useMemo(()=>f===null?av:u.key!==f?{status:"registering",error:null,registered:null,retry:h}:{status:u.status,error:u.error,registered:u.registered,retry:h},[f,u,h])}i(fd,"useChatPetRegistration");function wi(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(wi).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)}:${wi(n)}`).join(",")}}`}i(wi,"stableKey");var Ii=Object.freeze({});function yd(e){let[t,r]=react.useState(Ii),n=react.useRef(null),o=react.useRef([]);o.current=e.map(a=>a.id),react.useEffect(()=>{if(e.length===0){n.current=null,r(u=>u===Ii?u:Ii);return}let a=n.current;if(a===null)return;let l=e.find(u=>u.role==="user"&&!a.known.has(u.id));l!==void 0&&(n.current=null,r(u=>({...u,[l.id]:a.images})));},[e]);let s=react.useCallback(a=>{n.current=a.length===0?null:{images:a,known:new Set(o.current)};},[]);return react.useMemo(()=>({byMessage:t,stage:s}),[t,s])}i(yd,"useSentImages");var fv=500;function Ai(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,fv):null}i(Ai,"sanitizeSeedPrompt");function hd(e,t,r){let n=Ai(r),o=react.useRef(e);o.current=e;let s=react.useRef(null);react.useEffect(()=>{if(n===null||t||s.current===n)return;let a=o.current;a!==void 0&&(s.current=n,Promise.resolve(a(n)).catch(()=>{}));},[n,t]);}i(hd,"useInitialAsk");function mv(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(mv,"isCoalesced");function bd(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"}:mv(e,r,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:r}}i(bd,"decideChatRefresh");function Oi(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(Oi,"reportHostFailure");function yv(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(yv,"isThenable");function $(e,...t){if(typeof e=="function")try{let r=e(...t);return yv(r)&&Promise.resolve(r).then(void 0,Oi),r}catch(r){Oi(r);return}}i($,"callHost");var vd=new WeakMap;function Ed(e){if(typeof e!="function")return;let t=vd.get(e);if(t!==void 0)return t;let r=i((...n)=>{$(e,...n);},"guarded");return vd.set(e,r),r}i(Ed,"guardHost");function qt(e,...t){let r;try{r=e(...t);}catch(n){return Oi(n),Promise.resolve({ok:false,error:n})}return Promise.resolve(r).then(n=>({ok:true,value:n}),n=>({ok:false,error:n}))}i(qt,"callHostAsync");function Rd(e,t){let r=react.useRef(t);r.current=t;let n=react.useRef(null),o=react.useRef(null),s=e?.isOffline===void 0?false:$(()=>e.isOffline?.()===!0)===true,a=react.useRef(()=>{});a.current=l=>{let{conversationId:u,isTurnInFlight:d,refresh:c}=r.current,p=bd(l,{activeConversationId:u,isTurnInFlight:d,isOffline:s,lastRefresh:n.current,now:Date.now()});if(p.action!=="skip"){if(p.action==="defer"){o.current!=="announced"&&(o.current=l);return}o.current=null,n.current={conversationId:p.conversationId,at:Date.now()},c!==void 0&&Promise.resolve(c()).catch(()=>{});}},react.useEffect(()=>{if(t.isTurnInFlight||s)return;let l=o.current;l!==null&&a.current(l);},[t.isTurnInFlight,s]),react.useEffect(()=>{if(e===void 0)return;let l=[],u=i((d,c)=>{if(d===void 0)return;let p=$(()=>d(()=>{a.current(c);}));typeof p=="function"&&l.push(p);},"subscribe");return u(e.onForeground?.bind(e),"foreground"),u(e.onOnline?.bind(e),"foreground"),u(e.onAnnounced?.bind(e),"announced"),()=>{for(let d of l)$(d);}},[e]);}i(Rd,"useChatLifecycle");function hv(e){if(e===void 0)return null;let t=e.conversationId??"",r=e.petRef??"";return t===""&&r===""?null:`${String(t)}|${String(r)}`}i(hv,"targetKey");function Td(e,t){let r=hv(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:s,target:a}=n.current;s===void 0||a===void 0||Promise.resolve(s(a)).catch(()=>{});},[r]);}i(Td,"useCheckinTarget");function xd(e,t,r){let[n,o]=react.useState({send:e,conversationId:t,text:r??"",seeded:r??null}),s=n.send===e&&(n.conversationId===null||n.conversationId===t);react.useEffect(()=>{o(l=>{let u=l.send===e&&(l.conversationId===null||l.conversationId===t),d=u?l.text:"",c=u?l.seeded:null,p=r!=null&&r!==c&&d.length===0;return {send:e,conversationId:t,text:p?r:d,seeded:p?r:c}});},[e,t,r]);let a=react.useCallback(l=>o(u=>({send:e,conversationId:t,text:l,seeded:u.seeded})),[e,t]);return [s?n.text:"",a]}i(xd,"useChatDraft");function _d(e,t,r,n){let o=react.useRef({draft:r,setDraft:n});o.current={draft:r,setDraft:n};let s=react.useRef(null),[a,l]=react.useState(null);react.useEffect(()=>{if(e===void 0)return;let u=`${t??""}`;if(s.current===u)return;s.current=u;let d=true;return (async()=>{let c=await qt(()=>e.read(t));if(!d)return;let p=c.ok&&typeof c.value=="string"?c.value:"";p.length>0&&o.current.draft.length===0&&o.current.setDraft(p),l(u);})(),()=>{d=false;}},[e,t]),react.useEffect(()=>{e===void 0||a!==`${t??""}`||$(()=>e.write(t,r));},[e,t,r,a]);}i(_d,"usePersistedDraft");var q=Object.freeze({heading:"Chats",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No chats match that.",loading:"Loading your chats\u2026",loadFailed:"Couldn\u2019t load your chats",loadingMore:"Loading more\u2026",untitled:"New conversation",newChat:"New chat",searchPlaceholder:"Search chats\u2026",search:"Search chats",countLabel:"Chats and vet messages",countSeparator:" \xB7 ",newReply:"New reply \xB7 {date}",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 xn(e){let t=e?.replace(/\s+/g," ").trim();return t||q.untitled}i(xn,"conversationTitle");function Sv(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}i(Sv,"conversationDate");function Id(e){let t=Sv(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?q.newReply.replace("{date}",t):t}i(Id,"conversationMeta");function Ad(e,t){return t?`${q.countLabel}${q.countSeparator}${e}`:q.countLabel}i(Ad,"historyCountLabel");function Od(e){return `${e.unreadCount!==null&&e.unreadCount>0?q.unreadPrefix:""}${q.openConversation} ${xn(e.title)}`}i(Od,"openConversationLabel");function wd(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}i(wd,"normalizeForSearch");function Tv(e,t){let r=wd(t);if(r.length===0)return e;let n=[[],[],[]];for(let o of e){let s=wd(xn(o.title)),a=s.indexOf(r);if(a<0)continue;let l=a===0?0:s.charAt(a-1)===" "?1:2;n[l]?.push(o);}return n.flat()}i(Tv,"filterConversations");function Li(e){return {scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}i(Li,"fresh");function Fd(e){let[t,r]=react.useState(false),[n,o]=react.useState(""),s=e.listConversations,a=react.useRef(0),[l,u]=react.useState(()=>Li(s)),d=l.scope===s?l:Li(s);react.useEffect(()=>(a.current+=1,r(false),o(""),u(Li(s)),()=>{a.current+=1;}),[s]);let c=react.useCallback(async k=>{let x=++a.current,y=k!==void 0;u(A=>({...A,scope:s,loading:!y,loadingMore:y,error:null}));let _=await e.listConversations(k?{cursor:k}:void 0);if(x===a.current){if(!_.ok){u(A=>({...A,loading:false,loadingMore:false,error:_.error.displayMessage}));return}u(A=>{let O=k&&A.scope===s?A.rows:[],F=new Set(O.map(C=>C.id));return {scope:s,loading:false,loadingMore:false,error:null,rows:[...O,..._.value.conversations.filter(C=>!F.has(C.id))],cursor:_.value.nextCursor===k?null:_.value.nextCursor}});}},[e.listConversations,s]),p=i(()=>{r(true),o(""),c();},"show"),f=i(()=>{a.current+=1,r(false);},"close"),m=i(async k=>{let x=++a.current;u(_=>({..._,loading:true,error:null}));let y=await e.resumeConversation(k);x===a.current&&(u(_=>({..._,loading:false,error:y.ok?null:y.error.displayMessage})),y.ok&&r(false));},"resume"),h=i(async()=>{let k=a.current,x=await e.loadOlderMessages();k===a.current&&!x.ok&&u(y=>({...y,error:x.error.displayMessage}));},"earlier"),T=i(()=>{e.newConversation(),a.current+=1,r(false);},"newConversation"),b=i(()=>{d.cursor===null||d.loading||d.loadingMore||n.trim().length>0||c(d.cursor);},"loadMore"),S=react.useMemo(()=>Tv(d.rows,n),[d.rows,n]),P=n.trim().length>0;return {...d,open:t,show:p,close:f,load:c,resume:m,earlier:h,newConversation:T,loadMore:b,query:n,setQuery:o,searching:P,filtered:S,emptyKind:d.rows.length===0?"empty":"noMatch"}}i(Fd,"useHistoryPanel");var _n="#111111",wn="#FFFFFF",xv=Object.freeze({emergency:Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:_n,pillColor:wn,showsVetAction:true}),schedule_soon:Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:_n,pillColor:wn,showsVetAction:true}),home_care:Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:_n,pillColor:wn,showsVetAction:false}),general:Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:_n,pillColor:wn,showsVetAction:false})});function _v(e){return `${e.messageId}:${e.level}:${e.reason??""}`}i(_v,"urgencySignature");function wv(e){return K(g.urgencyGeneralReason,{petName:e?.trim()||g.emptyTitlePetFallback})}i(wv,"generalUrgencyReason");function Nd(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:Iv(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:wv(t)}:null}return null}i(Nd,"latestUrgencySource");function Iv(e){return typeof e=="string"&&e.trim().length>0?e:null}i(Iv,"shownReason");function Dd(e){let t=e===null?null:_v(e),[r,n]=react.useState(null),[o,s]=react.useState(false);react.useEffect(()=>s(false),[t]);let l=e!==null&&(o||!(r!==null&&r===t)),u=e===null?null:xv[e.level],d=e!==null&&!l&&e.level!=="general",c=react.useCallback(()=>{t!==null&&n(t),s(false);},[t]),p=react.useCallback(()=>s(true),[]);return react.useMemo(()=>({source:e,tier:u,signature:t,showBanner:l,showCompactIcon:d,showVetAction:l&&u!==null&&u.showsVetAction,dismissLabel:u===null?null:K(g.dismissBanner,{label:u.label}),dismiss:c,expand:p}),[e,u,t,l,d,c,p])}i(Dd,"useUrgencySurface");function Ud(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}i(Ud,"selectView");function Av(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}i(Av,"needsNewConversation");function Vd(e,t="native"){if(e.messages.length===0)return null;let r=e.status==="error"?e.error:null;if(r!==null){let n=Av(r),o=t==="web";return {tone:"error",title:n?g.turnUnreachableTitle:o?g.turnFailedTitleWeb:g.turnFailedTitle,body:r.displayMessage,actionLabel:n?g.turnStartNewChat:o?g.retry:g.turnRetry,action:n?"startNew":"retry"}}return e.stopped===true?{tone:"neutral",title:g.turnStoppedTitle,body:g.turnStoppedBody,actionLabel:g.turnRetry,action:"retry"}:null}i(Vd,"turnNotice");function Bd(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}i(Bd,"awaitingAssistant");var Ov=3,Fv=Object.freeze([]);function Hd(e){let t=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||t===void 0||t.role!=="assistant")return Fv;let r=new Set,n=[];for(let o of e.suggestedPrompts){let s=o.trim(),a=s.replace(/\s+/g," ").toLowerCase();if(!(a.length===0||r.has(a))&&(r.add(a),n.push(s),n.length===Ov))break}return Object.freeze(n)}i(Hd,"visibleFollowUps");function zd(e){return e.sender?.displayName??g.senderVet}i(zd,"vetSenderLabel");function jd(e,t){let r={};return e!==void 0&&(r.petRef=e),t!==void 0&&(r.conversationId=t),r}i(jd,"buildChatOpts");var fe={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function de(e){return {width:e,height:e,alignItems:"center",justifyContent:"center"}}i(de,"box");function be(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}i(be,"stroke");function Wd({size:e,color:t,strokeWidth:r}){let n=be(e,r),o={width:e*.82,height:n,borderRadius:n,backgroundColor:t};return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{gap:e*.22}],...fe,children:[jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o})]})}i(Wd,"MenuGlyph");function Gd({size:e,color:t,strokeWidth:r,rotate:n}){let o=be(e,r),s=e*.78;return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{transform:[{rotate:n}]}],...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:s,height:o,borderRadius:o,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:o,height:s,borderRadius:o,backgroundColor:t}})]})}i(Gd,"Cross");function In(e){return jsxRuntime.jsx(Gd,{...e,rotate:"0deg"})}i(In,"PlusGlyph");function Qe(e){return jsxRuntime.jsx(Gd,{...e,rotate:"45deg"})}i(Qe,"CloseGlyph");function pt({size:e,color:t,strokeWidth:r}){let n=be(e,r);return jsxRuntime.jsx(reactNative.View,{style:de(e),...fe,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(pt,"CheckGlyph");var Lv={down:{rotate:"45deg",marginTop:-0.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-0.4}};function Kd({size:e,color:t,strokeWidth:r,direction:n}){let o=be(e,r),s=e*.46,a=Lv[n];return jsxRuntime.jsx(reactNative.View,{style:de(e),...fe,children:jsxRuntime.jsx(reactNative.View,{style:{width:s,height:s,borderRightWidth:o,borderBottomWidth:o,borderColor:t,marginTop:s*a.marginTop,marginLeft:s*a.marginLeft,transform:[{rotate:a.rotate}]}})})}i(Kd,"ChevronGlyph");function qd({size:e,color:t,strokeWidth:r}){let n=be(e,r),o={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{flexDirection:"row",gap:1}],...fe,children:[jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopLeftRadius:e*.2}]}),jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}i(qd,"BookGlyph");function $d({size:e,color:t,strokeWidth:r}){let n=be(e,r),o=e*.5;return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,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($d,"ArrowUpRightGlyph");function Yd({size:e,color:t,strokeWidth:r}){let n=be(e,r),o=e*.6,s={position:"absolute",width:o,height:o,borderWidth:n,borderColor:t,borderRadius:e*.14};return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,children:[jsxRuntime.jsx(reactNative.View,{style:[s,{top:0,left:0}]}),jsxRuntime.jsx(reactNative.View,{style:[s,{bottom:0,right:0}]})]})}i(Yd,"CopyGlyph");function An({size:e,color:t,strokeWidth:r,active:n,rotate:o}){let s=be(e,r),a=n?t:"transparent";return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{transform:[{rotate:o}]}],...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,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:s,borderColor:t,backgroundColor:a,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:s,borderColor:t,backgroundColor:a,borderRadius:e*.05}})]})}i(An,"ThumbGlyph");function Xd({size:e,color:t,strokeWidth:r}){let n=be(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...fe,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(Xd,"InfoGlyph");function Qd({size:e,color:t,strokeWidth:r}){let n=be(e,r),o=e*.34;return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,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(Qd,"UploadGlyph");function Zd({size:e,color:t,strokeWidth:r}){let n=be(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...fe,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(Zd,"PhotoGlyph");function Jd({size:e,color:t,strokeWidth:r}){let n=be(e,r);return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,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(Jd,"CameraGlyph");function ec({size:e,color:t,strokeWidth:r}){let n=be(e,r),o=e*.66;return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,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(ec,"SearchGlyph");function Ni({size:e,color:t,strokeWidth:r}){let n=be(e,r),o=e*.62;return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,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(Ni,"MapPinGlyph");function tc({size:e,color:t,testID:r}){let n=e*.36;return jsxRuntime.jsx(reactNative.View,{style:de(e),testID:r,...fe,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(tc,"SendGlyph");function rc({size:e,color:t,testID:r}){return jsxRuntime.jsx(reactNative.View,{style:de(e),testID:r,...fe,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}i(rc,"StopGlyph");function On({size:e,strokeWidth:t,color:r,children:n}){return jsxRuntime.jsx(reactNative.View,{style:[de(e),{borderRadius:e/2,borderWidth:t??reactNative.StyleSheet.hairlineWidth,borderColor:r}],children:n})}i(On,"Ring");var $t=Object.freeze({standard:Ct.standard,emphasized:Ct.emphasized,exit:Ct.exit,outQuad:Object.freeze([.25,.46,.45,.94]),out:Object.freeze([.23,1,.32,1])});var nc=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,bubbleInMs:280,bubbleFromScale:.94,bubbleRisePx:6,promptRisePx:8,reduced:false}),Nv=Object.freeze({...nc,layoutMs:0,messageInMs:0,bannerInMs:0,bannerOutMs:0,iconInMs:0,iconOutMs:0,followUpInMs:0,followUpStaggerMs:0,citationsInMs:0,citationsRisePx:0,drawerMs:0,pressScale:1,pressMs:0,revealTickMs:0,dotsCycleMs:0,dotsMinOpacity:1,dotsLiftPx:0,bubbleInMs:0,bubbleFromScale:1,bubbleRisePx:0,promptRisePx:0,reduced:true});function oc(e){return e.motion.reducedMotion?Nv:nc}i(oc,"chatMotion");function Fn(e,t){return Math.max(0,t)*e.followUpStaggerMs}i(Fn,"followUpDelayMs");function ic(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(ic,"nextRevealLength");function te(){let e=N();return oc(e)}i(te,"useChatMotion");var Bv=8;function ac(e,t,r){return ((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}i(ac,"bezierComponent");function Hv(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}i(Hv,"bezierSlope");function Tr(e){let[t,r,n,o]=e;return s=>{if(s<=0)return 0;if(s>=1)return 1;let a=s;for(let l=0;l<Bv;l+=1){let u=Hv(a,t,n);if(u===0)break;a-=(ac(a,t,n)-s)/u;}return ac(Math.min(1,Math.max(0,a)),r,o)}}i(Tr,"bezierEasing");var Di=Tr($t.standard),zv=Tr($t.outQuad),jv=Tr($t.out);function Ln(e){let t=react.useRef(null);return t.current===null&&(t.current=new reactNative.Animated.Value(e)),t.current}i(Ln,"useAnimatedValue");function Yt(e,t={}){let r=t.risePx??0,n=t.delayMs??0,o=Ln(e>0?0:1);return react.useEffect(()=>{if(e<=0)return;let s=reactNative.Animated.timing(o,{toValue:1,duration:e,easing:zv,useNativeDriver:true}),a=n>0?reactNative.Animated.sequence([reactNative.Animated.delay(n),s]):s;return a.start(),()=>a.stop()},[o,e,n]),react.useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[o,r])}i(Yt,"useFadeIn");function Bi({visible:e,inMs:t,outMs:r,style:n,children:o}){let[s,a]=react.useState(e),l=Ln(e&&t<=0?1:0);return react.useEffect(()=>{if(e){a(true);let d=reactNative.Animated.timing(l,{toValue:1,duration:Math.max(0,t),easing:Di,useNativeDriver:true});return d.start(),()=>d.stop()}if(!s)return;if(r<=0){a(false);return}let u=reactNative.Animated.timing(l,{toValue:0,duration:r,easing:Di,useNativeDriver:true});return u.start(({finished:d})=>{d&&a(false);}),()=>u.stop()},[e,s,t,r,l]),!s&&!e?null:jsxRuntime.jsx(reactNative.Animated.View,{style:[n,{opacity:l}],children:o})}i(Bi,"FadePresence");var Wv=Object.freeze({opacity:1,transform:Object.freeze([{translateY:0},{scale:1}])});function cc(e,t){let[r]=react.useState(()=>e?t.bubbleInMs:0),n=r>0,o=Ln(n?0:1);react.useEffect(()=>{if(r<=0)return;let l=reactNative.Animated.timing(o,{toValue:1,duration:r,easing:jv,useNativeDriver:true});return l.start(),()=>l.stop()},[r,o]);let s=t.bubbleFromScale,a=t.bubbleRisePx;return react.useMemo(()=>n?{opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[a,0]})},{scale:o.interpolate({inputRange:[0,1],outputRange:[s,1]})}]}:Wv,[n,o,a,s])}i(cc,"useBubbleEnter");function pc(e){let t=react.useRef(null),r=react.useRef(null),n=e[0]?.id??null;if(t.current===null||r.current!==n){let s=t.current===null;t.current=new Map(e.map(a=>[a.id,s&&a.pending===true])),r.current=n;}let o=t.current;for(let s of e)o.has(s.id)||o.set(s.id,true);return react.useCallback(s=>o.get(s)===true,[o])}i(pc,"useEnteringRows");var Gv=12;function z({style:e,containerStyle:t,children:r,onPressIn:n,onPressOut:o,hitSlop:s,...a}){let l=te(),u=Ln(1),d=react.useCallback(c=>{l.pressMs<=0||l.pressScale===1||reactNative.Animated.timing(u,{toValue:c,duration:l.pressMs,easing:Di,useNativeDriver:true}).start();},[u,l.pressMs,l.pressScale]);return jsxRuntime.jsx(reactNative.Pressable,{...a,hitSlop:s??Gv,style:t,onPressIn:c=>{d(l.pressScale),n?.(c);},onPressOut:c=>{d(1),o?.(c);},children:jsxRuntime.jsx(reactNative.Animated.View,{style:[e,{transform:[{scale:u}]}],children:r})})}i(z,"PressScale");function fc(e,t,r){let n=t&&r.revealTickMs>0,[o,s]=react.useState(0),a=react.useRef(e);return a.current=e,react.useEffect(()=>{if(!n)return;let l=setInterval(()=>{s(u=>ic(r,u,a.current.length));},r.revealTickMs);return ()=>clearInterval(l)},[n,r]),n?e.slice(0,Math.min(o,e.length)):e}i(fc,"useRevealedText");var lc=false;function Kv(e){e.layoutMs<=0||(lc||(lc=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(Kv,"animateLayout");function Pr(e,t){let r=react.useRef(e);r.current!==e&&(r.current=e,Kv(t));}i(Pr,"useAnimateLayoutOn");var Hi=36,Jv=22,eE=12,tE=12,rE=16,nE="#000",oE="rgba(0,0,0,0.45)";function mc({uri:e,label:t,onClose:r}){let n=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:g.closePreview,style:Nn.backdrop,onPress:r,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:Nn.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),jsxRuntime.jsx(reactNative.View,{pointerEvents:"box-none",style:[Nn.closeWrap,{top:o.top+tE}],children:jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:g.closePreview,hitSlop:eE,style:Nn.closeButton,onPress:r,children:jsxRuntime.jsx(Qe,{size:Jv,color:n.color.surface,strokeWidth:2})})})]})}i(mc,"AttachmentImageLightbox");var Nn=reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:nE,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:rE},closeButton:{width:Hi,height:Hi,borderRadius:Hi/2,backgroundColor:oE,alignItems:"center",justifyContent:"center"}});var Dn=12,uE=80,zi=44,yc=22,dE=.14,cE=18,pE=8,gc=Object.freeze({photo:g.attachmentPhoto,camera:g.attachmentCamera});function hc({sources:e,full:t,onPick:r,onClose:n}){let o=N(),s=react.useMemo(()=>fE(o),[o]);return jsxRuntime.jsxs(reactNative.View,{style:s.anchor,pointerEvents:"box-none",children:[jsxRuntime.jsx(reactNative.Pressable,{style:s.dismissLayer,accessibilityRole:"button",accessibilityLabel:g.closeAttachmentPicker,onPress:n}),jsxRuntime.jsxs(reactNative.View,{style:s.bubble,children:[jsxRuntime.jsx(reactNative.View,{style:s.tilesRow,children:e.map(a=>jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:gc[a],accessibilityState:{disabled:t},disabled:t,containerStyle:s.tile,style:s.tileInner,onPress:()=>r(a),children:[jsxRuntime.jsx(reactNative.View,{style:s.tileIconWrap,children:a==="photo"?jsxRuntime.jsx(Zd,{size:yc,color:o.color.brandInk,strokeWidth:1.5}):jsxRuntime.jsx(Jd,{size:yc,color:o.color.brandInk,strokeWidth:1.5})}),jsxRuntime.jsx(E,{tier:"control",style:s.tileLabel,children:gc[a]})]},a))}),jsxRuntime.jsx(reactNative.View,{style:s.tail}),jsxRuntime.jsx(reactNative.View,{style:s.tailFill})]})]})}i(hc,"AttachmentPickerPopover");function fE(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:dE,shadowRadius:cE,shadowOffset:{width:0,height:pE},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:uE,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:zi,height:zi,borderRadius:zi/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...R(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-Dn/2,width:Dn,height:Dn,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:Dn+4,height:2,backgroundColor:t.surfaceCream}})}i(fE,"makeStyles");var Pe=Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var vc=56,Ec=12,gE=14,hE=10,bE=.45,vE="rgba(7,193,104,0.55)",EE="rgba(185,28,28,0.55)",CE=200,RE=300,_c=20,Wi=22,SE=12,TE="rgba(0,0,0,0.78)",Cc=220,Rc=100,Sc="rgba(255,255,255,0.15)";function wc({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:o,onPreview:s}){let a=N(),l=react.useMemo(()=>Ac(a),[a]);return e.length===0&&t===null?null:jsxRuntime.jsxs(reactNative.View,{style:l.strip,children:[e.length>0?jsxRuntime.jsx(reactNative.View,{style:l.cards,children:e.map(u=>jsxRuntime.jsx(PE,{row:u,styles:l,onRetry:n,onRemove:o,onPreview:s},u.id))}):null,r?jsxRuntime.jsx(E,{style:l.rejected,accessibilityRole:"alert",children:g.attachmentsFailedBlocked}):null,t!==null?jsxRuntime.jsx(E,{style:l.rejected,accessibilityRole:"alert",children:ld(t)}):null]})}i(wc,"AttachmentStrip");function PE({row:e,styles:t,onRetry:r,onRemove:n,onPreview:o}){let s=N(),a=e.status==="uploading",l=e.status==="failed",u=e.status==="uploaded",d=react.useRef(e.status),[c,p]=react.useState(false);return react.useEffect(()=>{let f=d.current;d.current=e.status,e.status==="uploaded"&&f==="uploading"&&p(true);},[e.status]),jsxRuntime.jsxs(reactNative.View,{style:t.card,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:u?"button":"image",accessibilityLabel:u?K(g.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:a,disabled:!u},disabled:!u,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}),a?jsxRuntime.jsx(reactNative.View,{style:t.uploadingOverlay,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:s.color.surface})}):null,c?jsxRuntime.jsx(kE,{styles:t,onDone:()=>p(false)}):null]})}),l?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K(g.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:jsxRuntime.jsx(reactNative.View,{style:t.failedInner,children:jsxRuntime.jsx(Qe,{size:_c,color:s.color.surface,strokeWidth:2})})}):null,jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:K(g.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:jsxRuntime.jsx(Qe,{size:SE,color:s.color.surface,strokeWidth:1.5})})]})}i(PE,"PreviewCard");function kE({styles:e,onDone:t}){let r=N(),n=te(),o=react.useRef(null);o.current===null&&(o.current=new reactNative.Animated.Value(0));let s=o.current;return react.useEffect(()=>{let a=reactNative.Animated.sequence([reactNative.Animated.timing(s,{toValue:1,duration:CE,useNativeDriver:true}),reactNative.Animated.delay(n.uploadFlashMs),reactNative.Animated.timing(s,{toValue:0,duration:RE,useNativeDriver:true})]);return a.start(({finished:l})=>{l&&t();}),()=>a.stop()},[s,n.uploadFlashMs,t]),jsxRuntime.jsx(reactNative.Animated.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:s}],children:jsxRuntime.jsx(pt,{size:_c,color:r.color.surface,strokeWidth:2})})}i(kE,"SuccessFlash");function Ic({images:e,onPreview:t}){let r=N(),n=react.useMemo(()=>Ac(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((s,a)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K(g.attachedImage,{filename:s.filename}),onPress:()=>t(s),children:jsxRuntime.jsx(reactNative.Image,{source:{uri:s.uri},style:o?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${s.uri}-${a}`))})}i(Ic,"SentImages");function Ac(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:vc,height:vc,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:Ec,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...Pe,alignItems:"center",justifyContent:"center",backgroundColor:ut(e.color.brandInk,bE)??e.color.brandSofter},successOverlay:{...Pe,alignItems:"center",justifyContent:"center",backgroundColor:vE},failedOverlay:{...Pe,borderRadius:Ec,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:EE},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:Wi,height:Wi,borderRadius:Wi/2,backgroundColor:TE,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...R(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:Cc,height:Cc,borderRadius:gE,backgroundColor:Sc},gridImage:{width:Rc,height:Rc,borderRadius:hE,backgroundColor:Sc}})}i(Ac,"makeStyles");var xE="chat attachment upload: the file handle has no uri",_E="chat attachment upload failed";function wE(e){return {uri:e.uri,name:Vo(e.name),type:e.mimeType}}i(wE,"filePartOf");function Oc(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(xE));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(_E)),"failed");return o?.aborted===true?a():Xr({url:t.upload_url,fields:t.upload_fields,file:wE(r),signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(Oc,"createRnChatAttachmentTransport");function Un(){let{runtime:e,userRef:t,activePet:r,scopeEpoch:n}=ee(),o=react.useMemo(()=>lt(e.registry.services.authFor(t)),[e,t,n]),[s,a]=react.useState({repository:o,pets:[],loading:true,error:null}),l=s.repository===o?s:{pets:[],loading:true,error:null},u=react.useRef(0),d=react.useCallback(async()=>{let p=++u.current;a(m=>({...m,repository:o,loading:true,error:null,pets:m.repository===o?m.pets:[]}));let f=await o.list();p===u.current&&a(f.ok?{repository:o,pets:f.value,loading:false,error:null}:m=>({repository:o,pets:m.repository===o?m.pets:[],loading:false,error:f.error}));},[o]);react.useEffect(()=>(d(),()=>{u.current+=1;}),[d]);let c=react.useMemo(()=>r===null?null:l.pets.find(p=>p.petRef===r)??null,[r,l.pets]);return react.useMemo(()=>({pets:l.pets,activePet:c,loading:l.loading,error:l.error,refresh:d}),[l.pets,l.loading,l.error,c,d])}i(Un,"useEverfurPets");function Fc(e,t){if(t!==null){let r=e.find(n=>n.petRef===t);if(r!==void 0)return r}return e[0]??null}i(Fc,"headerPetOf");function me(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(me,"slotBox");function Vn(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}i(Vn,"ownGroundSlot");function ke(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(ke,"slotText");var Mc=Object.freeze({visitButton:"Vet"});var Lc=Symbol.for("@everfur/sdk/televet");function Ze(){let e=globalThis,t=e[Lc];if(t!==void 0)return t;let r={presenter:null,snapshot:Object.freeze({request:null,serial:0,activeHost:null}),hosts:[],nextHost:1,listeners:new Set,dailyRegistered:false};return e[Lc]=r,r}i(Ze,"televetGlobal");function Bn(e){let t=Ze();t.snapshot=Object.freeze({...t.snapshot,...e});for(let r of [...t.listeners])try{r();}catch{}}i(Bn,"publish");function Nc(e){let t=Ze().presenter;if(t===null)return "absent";try{return t(e)===!1?"declined":"presented"}catch(r){return console.warn("[everfur] Your registerEverfurTelevetFlow presenter threw; the in-app visit opened instead.",r),"threw"}}i(Nc,"callTelevetPresenter");function Dc(e){let t=Ze();return t.listeners.add(e),()=>{t.listeners.delete(e);}}i(Dc,"subscribeTelevetExperience");function $i(){return Ze().snapshot}i($i,"televetExperienceSnapshot");function ME(){return Ze().hosts.length>0}i(ME,"hasTelevetHost");function Uc(e){if(!ME())return false;let t=Object.freeze({...e});return Bn({request:t,serial:Ze().snapshot.serial+1}),true}i(Uc,"presentTelevetExperience");function Yi(){Ze().snapshot.request!==null&&Bn({request:null});}i(Yi,"dismissTelevetExperience");function Vc(){let e=Ze(),t=e.nextHost;return e.nextHost+=1,e.hosts=[...e.hosts,t],Bn({activeHost:e.hosts[0]??null}),t}i(Vc,"claimTelevetHost");function Bc(e){let t=Ze();t.hosts=t.hosts.filter(n=>n!==e);let r=t.hosts[0]??null;Bn(r===null?{activeHost:r,request:null}:{activeHost:r});}i(Bc,"releaseTelevetHost");var Hc=false;function Hn(e,t){return t!==void 0?($(t,e),"onStartInApp"):Nc(e)==="presented"?"presenter":Uc(e)?"experience":(Hc||(Hc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}i(Hn,"openVetVisitInApp");function Wc(e){let t=null;return ()=>{if(t!==null)return t;let r=e();return t=r,r.then(void 0,()=>{t===r&&(t=null);}),r}}i(Wc,"memoizeTelevetLoader");function Gc(e){let[t,r]=react.useState(null);react.useEffect(()=>{let d=Vc();return r(d),()=>{Bc(d);}},[]);let n=react.useSyncExternalStore(Dc,$i,$i),s=t!==null&&n.activeHost===t?n.request:null,[a,l]=react.useState(null),u=s!==null&&a===null;return react.useEffect(()=>{if(!u)return;let d=true;return e().then(c=>{d&&l(()=>c);},c=>{d&&(console.warn("[everfur] The in-app vet visit could not load its screens.",c),Yi());}),()=>{d=false;}},[u,e]),s===null||a===null?null:{module:a,request:s,serial:n.serial,dismiss:Yi}}i(Gc,"useTelevetExperienceHost");var NE=Wc(()=>import('@everfur/sdk/televet/booking'));function xr(){let e=Gc(NE);if(e===null)return null;let{EverfurTelevetModal:t}=e.module;return jsxRuntime.jsx(t,{request:e.request,onClose:e.dismiss},e.serial)}i(xr,"EverfurTelevetHost");var Xi=Object.freeze(["visit","join","summary","messages"]);function Qi(e){return typeof e=="string"&&Xi.includes(e)}i(Qi,"isVetVisitIntent");var UE="/widget/v1/televet/handoffs",VE="/widget/v1/televet/availability",BE="/widget/v1/televet/chat-entry",HE=/^[a-z0-9][a-z0-9_-]{0,39}$/,zE=/^[A-Za-z0-9_-]{22}$/;var Kc=32,qc=128,$c=64;function Ji(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(Ji,"vetVisitErrorReasonOf");function Yc(e){return v(D("validationFailed",{retryable:false,wireMessage:e}))}i(Yc,"invalid");function Zi(e){return v(D("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}i(Zi,"unusable");function jE(e,t){let r={};e!==void 0&&(r.pet_ref=e);let n=t?.returnTo;if(n!=null){if(typeof n!="string"||!HE.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 s=t?.visitRef,a=t?.intent,l=s!=null;if(l){let u=typeof s=="string"?s.trim():"";if(u.length<1||[...u].length>$c)return {ok:false,message:`visitRef must be 1..${$c} characters`};r.visit_ref=u;}if(a!=null){if(!l)return {ok:false,message:"intent needs the visitRef it opens"};if(!Qi(a))return {ok:false,message:`intent must be one of ${Xi.join(", ")}`};r.intent=a;}return {ok:true,body:r}}i(jE,"handoffBody");function WE(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!Qi(r)?null:Object.freeze({visitRef:t,intent:r})}i(WE,"parseVisitEcho");function Qc(e){let t=e.funnel??Ie({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=i(o=>(Xc(r,"televet.visit.handoff_failed",{reason:Ji(o)}),v(o)),"failed");return {async createHandoff(o,s){let a;if(o!=null){let b=typeof o=="string"?[...o].length:0;if(b<1||b>qc)return n(D("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${qc} characters`}));a=o;}let l=jE(a,s);if(!l.ok){let b=Yc(l.message);return b.ok?b:n(b.error)}let u=l.body,d=await t.send("televet.visit.handoff",{method:"POST",path:UE,body:u},{idempotent:false,maxAttempts:1});if(!d.ok)return n(d.error);let c=GE(d.value),p=u.return_to!==void 0,f=p?d.value?.flow_id:void 0;if(p&&(typeof f!="string"||!zE.test(f))){let b=Zi("the handoff response carried no usable return flow id");return b.ok?b:n(b.error)}let m=u.visit_ref!==void 0,h=m?WE(d.value?.visit):null;if(m&&h===null){let b=Zi("the handoff response did not confirm the visit it opens");return b.ok?b:n(b.error)}let T=c===null?null:Object.freeze({...c,...p?{flowId:f}:{},...h!==null?{visit:h}:{}});return T===null?n(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Xc(r,"televet.visit.handoff_created",{pet_scoped:u.pet_ref!==void 0}),L(T))},async checkAvailability(o){if(typeof o!="string"||o.length>Kc)return Yc(`state must be at most ${Kc} characters`);let s=await t.send("televet.visit.availability",{method:"POST",path:VE,body:{state:o}},{idempotent:false,maxAttempts:1});if(!s.ok)return v(s.error);let a=s.value?.available;return typeof a!="boolean"?Zi("the availability response carried no usable answer"):L(Object.freeze({available:a}))},async chatEntryOpen(){try{let o=await t.send("televet.visit.chat_entry",{method:"GET",path:BE},{maxAttempts:1});return o.ok&&o.value?.open===!0}catch{return false}}}}i(Qc,"createVetVisitController");function GE(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||!YE(t)?null:Object.freeze({url:t,expiresAt:r})}i(GE,"parseHandoff");var KE=new Set(["localhost","127.0.0.1","[::1]"]),qE=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,$E=/[\s\u0000-\u001f\u007f]/;function YE(e){if($E.test(e))return false;let t=qE.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(),s=r==="https",a=r==="http"&&KE.has(o);if(!s&&!a)return false;let l=e.indexOf("#");if(l<0)return false;let u=e.slice(l);return u.startsWith("#h=")&&u.length>3}i(YE,"isOpenableVisitUrl");function Xc(e,t,r){if(e)try{e.track(t,r);}catch{}}i(Xc,"safeTrack");var es=Object.freeze({status:"idle",error:null,errorReason:null});function QE(e,t,r){let{usState:n,chat:o,scope:s}=r,a=t&&(n!==null||o),l=`${n??""}|${o?"chat":""}`,[u,d]=react.useState(null);if(react.useEffect(()=>{if(!a)return;let p=true,f=e.current;return d(null),i(async()=>{try{if(o&&!(f.chatEntryOpen&&await f.chatEntryOpen()))return !1;if(n===null)return !0;if(!f.checkAvailability)return !1;let h=await f.checkAvailability(n);return h.ok&&h.value.available}catch{return false}},"ask")().then(h=>{p&&d({key:l,open:h});}),()=>{p=false;}},[a,l,n,o,s,e]),!a)return null;let c=u!==null&&u.key===l;return {open:c&&u.open,pending:!c}}i(QE,"usePreflight");var ZE=Object.freeze({status:"opening",error:null,errorReason:null});function ep(e,t={}){let{runtime:r,userRef:n,scopeEpoch:o}=ee(),s=Wt("televet"),a=s.enabled&&n!==null,l=t.usState??null,u=t.entry==="chat",d=t.petRef??null,c=t.prefer==="redirect",p=react.useMemo(()=>{if(t.controller)return t.controller;let{services:w}=r.registry;return Qc({auth:w.authFor(n),telemetry:w.telemetry,...w.errorPolicy?{errorPolicy:w.errorPolicy}:{}})},[r,n,o,t.controller]),f=react.useRef(p);f.current=p;let m=react.useMemo(()=>({runtime:r,userRef:n,scopeEpoch:o}),[r,n,o]),h=QE(f,a,{usState:l,chat:u,scope:m}),T=a&&(h===null||h.open)&&(!u||d!==null),b=t.returnTo??null,[S,P]=react.useState(es),k=react.useRef(null),x=react.useRef({runtime:r,userRef:n,scopeEpoch:o});x.current={runtime:r,userRef:n,scopeEpoch:o};let y=react.useRef(p);y.current=p;let _=react.useRef(T);_.current=T;let A=react.useCallback((w,I)=>{if(k.current)return k.current;let H=i((he,st)=>(P({status:he==="cancelled"?"idle":"error",error:st,errorReason:he==="cancelled"?null:he}),Object.freeze({opened:false,reason:he,error:st})),"fail");if(!_.current)return Promise.resolve(H("unavailable",null));let Q=e.prepare();if(!Q.ok)return Promise.resolve(H(Q.reason,null));let oe=x.current,Y=y.current;P(ZE);let it=(async()=>{let he,st={...b!==null?{returnTo:b}:{},...u?{entry:"chat"}:{},...I!==null?{visitRef:I.visitRef}:{},...I!==null&&I.intent!==null&&I.intent!==void 0?{intent:I.intent}:{}},Vr=Object.keys(st).length===0?void 0:st,Br=w===void 0?d:w;try{he=await(Vr===void 0?Y.createHandoff(Br):Y.createHandoff(Br,Vr));}catch{return e.abandon(Q.value),H("unknown",null)}let Lt=x.current;if(Lt.runtime!==oe.runtime||Lt.userRef!==oe.userRef||Lt.scopeEpoch!==oe.scopeEpoch)return e.abandon(Q.value),H("cancelled",null);if(!he.ok)return e.abandon(Q.value),H(Ji(he.error),he.error);let Jt=await e.finish(Q.value,he.value);return Jt!==null?H(Jt,null):(P(es),Object.freeze(he.value.flowId===void 0?{opened:true}:{opened:true,flowId:he.value.flowId}))})().finally(()=>{k.current===it&&(k.current=null);});return k.current=it,it},[e,d,b,u]),O=react.useCallback((w,I)=>{if(!_.current)return P({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}));let H=w===void 0?d:w,Q={...H!==null?{petRef:H}:{},...l!==null?{usState:l}:{},...I!==null?{visitRef:I.visitRef,intent:I.intent}:{}};return Hn(Q)===null?(P({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}))):(P(es),Promise.resolve(Object.freeze({opened:true})))},[d,l]),F=react.useCallback(w=>c?A(w,null):O(w,null),[c,A,O]),C=react.useCallback((w,I)=>c?A(void 0,{visitRef:w,intent:I??null}):O(void 0,{visitRef:w,intent:I??null}),[c,A,O]);return {available:T,isPending:s.isPending||(h?.pending??false),status:S.status,error:S.error,errorReason:S.errorReason,open:F,openVisit:C}}i(ep,"useVetVisitWith");var tC=i(e=>reactNative.Linking.openURL(e),"defaultOpenUrl");function jn(e={}){let{openUrl:t,...r}=e,n=react.useMemo(()=>{let o=t??tC;return {prepare:i(()=>({ok:true,value:null}),"prepare"),async finish(s,a){try{return await o(a.url),null}catch{return "openFailed"}},abandon:i(()=>{},"abandon")}},[t]);return ep(n,r)}i(jn,"useVetVisit");var tp=44,sC=.6;function Zt(e){let{petRef:t,label:r,openUrl:n,onOpened:o,onError:s,style:a,labelStyle:l,controller:u,returnTo:d,usState:c,entry:p,visitRef:f,intent:m,onStartInApp:h,prefer:T}=e,b=T==="redirect",S=jn({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...t!==void 0?{petRef:t}:{},...n!==void 0?{openUrl:n}:{},...u!==void 0?{controller:u}:{},prefer:b?"redirect":"in-app"}),P=N(),k=react.useMemo(()=>aC(P),[P]),x=react.useRef(false);if(!S.available)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[null,jsxRuntime.jsx(xr,{})]});let y=S.status==="opening",_=r??Mc.visitButton;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.Pressable,{onPress:i(()=>{if(!(y||x.current)){if(!b){let O={...t!==void 0?{petRef:t}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:m??null}:{}};Hn(O,h)===null&&$(s,"unavailable",null);return}x.current=true,(f==null?S.open():S.openVisit(f,m??null)).then(O=>{O.opened?$(o,O.flowId??null):O.reason!=="cancelled"&&$(s,O.reason,O.error);}).finally(()=>{x.current=false;});}},"onPress"),accessibilityRole:"button",accessibilityLabel:_,accessibilityState:{busy:y,disabled:y},style:[k.button,y?k.busy:null,a],children:jsxRuntime.jsx(E,{style:[k.label,l],children:_})}),jsxRuntime.jsx(xr,{})]})}i(Zt,"VetVisitButton");function aC(e){let{color:t,space:r,radius:n,type:o,slots:s}=e;return reactNative.StyleSheet.create({button:{minHeight:tp,minWidth:tp,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...me(s.vetVisitButton)},busy:{opacity:sC},label:{...R(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug,...ke(s.vetVisitButton)}})}i(aC,"makeStyles");function ts(e){return pr(e)==="cat"?"cat":"dog"}i(ts,"speciesOf");function rs(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}i(rs,"petAgeYears");function ip(e){let t=rs(e.ageYears),r=ts(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return `${r} \xB7 ${n}`}i(ip,"formatPetMeta");var op=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 lC(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return op[t%op.length]}i(lC,"pickInitialsPalette");function ns(e){let t=(e??"").trim();return (Array.from(t)[0]??"?").toUpperCase()}i(ns,"getInitial");function sp(e){return {...lC(e.petRef),initial:ns(e.name)}}i(sp,"petInitials");function pC(e){return Math.max(12,Math.round(e*.42))}i(pC,"letterSize");function wr({pet:e,size:t,ringStroke:r}){let n=N(),o=react.useMemo(()=>fC(n),[n]),s=t-r*2,a=e===null?null:sp(e),l=pC(s);return jsxRuntime.jsx(On,{size:t,strokeWidth:r,color:n.color.success,children:jsxRuntime.jsx(reactNative.View,{style:[o.disc,{width:s,height:s,borderRadius:s/2},a===null?o.discEmpty:{backgroundColor:a.background}],children:jsxRuntime.jsx(E,{tier:"badge",style:[o.letter,{fontSize:l,lineHeight:Math.round(l*1.2),color:a===null?n.color.text.muted:a.foreground}],children:a===null?ns(null):a.initial})})})}i(wr,"PetDisc");function fC(e){return reactNative.StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...R(e,"bold"),textAlign:"center",includeFontPadding:false}})}i(fC,"makeStyles");var is=48,up=2,vC=320,EC="80%",CC="rgba(17,17,17,0.45)",RC=18,ap=22,SC=12,lp=.4,TC=44;function ss(e){return e?.name?.trim()||g.yourPet}i(ss,"petDisplayName");function dp({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:o=null,onClose:s}){let a=N(),l=react.useMemo(()=>PC(a),[a]);return e?jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:s,children:jsxRuntime.jsxs(reactNative.View,{style:l.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:Pe,onPress:s,accessibilityRole:"button",accessibilityLabel:g.close,children:jsxRuntime.jsx(reactNative.View,{style:l.backdrop})}),jsxRuntime.jsxs(reactNative.View,{style:l.panel,accessibilityViewIsModal:true,children:[jsxRuntime.jsx(E,{tier:"heading",style:l.title,accessibilityRole:"header",children:g.yourPets}),jsxRuntime.jsx(reactNative.ScrollView,{style:l.list,contentContainerStyle:l.listContent,showsVerticalScrollIndicator:true,children:t.map(u=>{let d=u.petRef===r,c=ss(u),p=ip(u);return jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:K(d?g.petCurrentlyActive:g.switchToPet,{name:c}),accessibilityState:{selected:d},style:[l.row,d?l.rowActive:null],onPress:()=>n(u.petRef),children:[jsxRuntime.jsx(wr,{pet:u,size:is,ringStroke:up}),jsxRuntime.jsxs(reactNative.View,{style:l.copy,children:[jsxRuntime.jsx(E,{style:l.name,numberOfLines:1,children:c}),jsxRuntime.jsx(E,{tier:"compact",style:l.meta,numberOfLines:1,children:d?`${g.activePrefix}${p}`:p})]}),d?jsxRuntime.jsx(pt,{size:RC,color:a.color.brandInk}):null]},u.petRef)})}),o!==null?jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:g.addAnotherPet,style:l.addRow,onPress:o,children:[jsxRuntime.jsx(reactNative.View,{style:l.addDisc,children:jsxRuntime.jsx(E,{tier:"control",style:l.addPlus,children:"+"})}),jsxRuntime.jsx(E,{style:l.addLabel,children:g.addAnotherPet})]}):null,jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:g.close,containerStyle:l.closeSlot,style:l.closeButton,onPress:s,children:jsxRuntime.jsx(E,{tier:"control",style:l.closeText,children:g.close})})]})]})}):null}i(dp,"PetSwitcherSheet");function PC(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:CC},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:ap,borderTopRightRadius:ap,gap:14,maxHeight:EC},title:{...R(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk},list:{maxHeight:vC,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:TC,paddingHorizontal:8},addDisc:{width:is,height:is,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:up,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...R(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...R(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:{...R(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...R(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:lp},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:SC,backgroundColor:t.brandSoft},closeText:{...R(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:lp}})}i(PC,"makeStyles");var _C=44,Gn=36,wC=22,as=9,IC=1.5,pp=6,wt=35,Kn=1.75,ls=12.4,AC=.5,OC=8,FC=28,MC=160;function ds(e,t){return Fc(e,t)}i(ds,"headerPet");function mp({pets:e,petRef:t,historyUnread:r,onOpenHistory:n,onPetChange:o,onAddPet:s,vet:a}){let l=N(),u=react.useMemo(()=>NC(l),[l]),[d,c]=react.useState(false),p=ds(e.pets,t),f=e.pets.length>=2,m=t??p?.petRef??null,h=ss(p),T=i(S=>{c(false),e.setActivePet(S),$(o,S);},"select"),b=s===void 0?null:()=>{c(false),$(s);};return jsxRuntime.jsxs(reactNative.View,{style:u.row,children:[jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:r?`${g.openHistoryNative}${g.newReplySuffix}`:g.openHistoryNative,containerStyle:u.iconSlot,style:u.iconButton,onPress:n,children:[jsxRuntime.jsx(Wd,{size:wC,color:l.color.text.primary,strokeWidth:2}),r?jsxRuntime.jsx(reactNative.View,{style:u.unreadDot,pointerEvents:"none"}):null]}),jsxRuntime.jsx(reactNative.View,{style:u.center,pointerEvents:"box-none",children:jsxRuntime.jsx(LC,{logoUrl:l.meta.logoUrl,name:l.meta.displayName,styles:u})}),m===null?null:jsxRuntime.jsx(Zt,{entry:"chat",petRef:m,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:u.vetEntry,labelStyle:u.vetEntryLabel}),jsxRuntime.jsx(reactNative.View,{style:u.right,children:f?jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:K(g.switchActivePet,{name:h}),containerStyle:u.avatarSlot,style:u.avatarWrap,onPress:()=>c(true),children:[jsxRuntime.jsx(wr,{pet:p,size:wt,ringStroke:Kn}),jsxRuntime.jsx(reactNative.View,{style:u.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:jsxRuntime.jsx(In,{size:OC,color:l.color.brandInk,strokeWidth:2})})]}):e.loading&&p===null?jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityLabel:g.yourPet,children:jsxRuntime.jsx(On,{size:wt,strokeWidth:Kn,color:l.color.success,children:jsxRuntime.jsx(reactNative.View,{style:u.placeholderDisc})})}):jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:p===null?g.yourPet:h,children:jsxRuntime.jsx(wr,{pet:p,size:wt,ringStroke:Kn})})}),jsxRuntime.jsx(dp,{visible:d,pets:e.pets,activePetRef:p?.petRef??null,onSelect:T,onAddPet:b,onClose:()=>c(false)})]})}i(mp,"ChatHeader");function LC({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(LC,"BrandLogo");function NC(e){let t=e.color,r=wt-Kn*2;return reactNative.StyleSheet.create({vetEntry:{minHeight:_C,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},vetEntryLabel:{...R(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:Gn/2},iconButton:{width:Gn,height:Gn,borderRadius:Gn/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:pp,right:pp,width:as,height:as,borderRadius:as,backgroundColor:t.danger,borderWidth:IC,borderColor:t.surface},center:{...Pe,alignItems:"center",justifyContent:"center"},logoBar:{alignItems:"center",paddingHorizontal:e.space.lg},logo:{height:FC,width:MC},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:wt/2},avatarWrap:{width:wt,height:wt,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:ls,height:ls,borderRadius:ls/2,borderWidth:AC,borderColor:t.success,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}i(NC,"makeStyles");var hp=44,HC="rgba(17,17,17,0.55)",bp=26,zC=36,vp=4,cs=20,ps=38,jC=18,WC=12;function Ep({visible:e,onSubmit:t,onSkip:r}){let n=N(),o=react.useMemo(()=>GC(n),[n]),[s,a]=react.useState(null),[l,u]=react.useState(""),[d,c]=react.useState(false),[p,f]=react.useState(false),m=i(()=>{a(null),u(""),c(false),f(false);},"reset"),h=i(()=>{d||(m(),r());},"skip"),T=i(async()=>{if(d)return;c(true),f(false);let S=l.trim();await t(s,S.length>0?S:null)?m():(c(false),f(true));},"submit");if(!e)return null;let b=[...l].length>Bt;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:n.motion.reducedMotion?"none":"slide",onRequestClose:h,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:h,accessibilityRole:"button",accessibilityLabel:g.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(An,{size:jC,color:n.color.brandInk,active:false,rotate:"180deg"})}),jsxRuntime.jsxs(reactNative.View,{style:o.headerText,children:[jsxRuntime.jsx(E,{tier:"heading",style:o.title,accessibilityRole:"header",children:g.feedbackTitle}),jsxRuntime.jsx(E,{style:o.subtitle,children:g.feedbackSubtitle})]})]}),jsxRuntime.jsx(reactNative.View,{style:o.options,children:Ti.map(S=>{let P=s===S.key;return jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:S.label,accessibilityState:{selected:P},style:[o.option,P?o.optionSelected:null],onPress:()=>a(k=>k===S.key?null:S.key),children:[jsxRuntime.jsx(E,{style:[o.optionLabel,P?o.optionLabelSelected:null],children:S.label}),jsxRuntime.jsx(reactNative.View,{style:[o.radio,P?o.radioSelected:null],children:P?jsxRuntime.jsx(pt,{size:WC,color:n.color.surface,strokeWidth:2}):null})]},S.key)})}),jsxRuntime.jsxs(reactNative.View,{style:o.inputWrap,children:[jsxRuntime.jsx(Gt,{style:o.input,placeholder:g.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:g.feedbackNotesPlaceholder,value:l,onChangeText:u,multiline:true,editable:!d}),l.length>0?jsxRuntime.jsx(E,{tier:"compact",style:[o.counter,b?o.counterOver:null],children:`${[...l].length}/${Bt}`}):null]}),p?jsxRuntime.jsx(E,{style:o.failed,accessibilityRole:"alert",children:g.feedbackFailed}):null,jsxRuntime.jsxs(reactNative.View,{style:o.actions,children:[jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:g.feedbackSubmit,accessibilityState:{busy:d,disabled:d||b},disabled:d||b,style:[o.submit,d||b?o.submitDisabled:null],onPress:()=>{T();},children:jsxRuntime.jsx(E,{tier:"control",style:o.submitLabel,children:g.feedbackSubmit})}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:g.feedbackSkipA11y,hitSlop:8,onPress:h,style:o.skip,children:jsxRuntime.jsx(E,{tier:"control",style:o.skipLabel,children:g.feedbackSkip})})]})]})]})})}i(Ep,"FeedbackReasons");function GC(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:{...Pe,backgroundColor:HC},sheet:{backgroundColor:t.surface,borderTopLeftRadius:bp,borderTopRightRadius:bp,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14},handle:{alignSelf:"center",width:zC,height:vp,borderRadius:vp/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:ps,height:ps,borderRadius:ps/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...R(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight},subtitle:{...R(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:{...R(e,"medium"),fontSize:r.size.body,color:t.text.primary},optionLabelSelected:{color:t.brandInk},radio:{width:cs,height:cs,borderRadius:cs/2,borderWidth:2,borderColor:t.brandBorderStrong,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...R(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top"},counter:{...R(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...R(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:hp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...me(o.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...R(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...ke(o.primaryButton)},skip:{minHeight:hp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...R(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}i(GC,"makeStyles");var oR=.88,iR=420,sR=58,aR="rgba(17,17,17,0.28)",lR=.15,uR=14,dR=12,fs=44,cR=16,pR=14,fR=12,mR=14,ms=8,mt=2,yR=.5,gR=Tr($t.standard);function hR(e){return Math.min(Math.round(e*oR),iR)}i(hR,"drawerPanelWidth");function Rp({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(bR,{chat:e,history:t,onHidden:o}):null}i(Rp,"HistoryDrawer");function bR({chat:e,history:t,onHidden:r}){let n=N(),o=react.useMemo(()=>ER(n),[n]),s=te(),a=reactNativeSafeAreaContext.useSafeAreaInsets(),{width:l}=reactNative.useWindowDimensions(),u=hR(l),d=t.open,c=react.useRef(null);c.current===null&&(c.current=new reactNative.Animated.Value(s.drawerMs<=0&&d?1:0));let p=c.current;react.useEffect(()=>{if(!d&&s.drawerMs<=0){r();return}let P=reactNative.Animated.timing(p,{toValue:d?1:0,duration:s.drawerMs,easing:gR,useNativeDriver:true});return P.start(({finished:k})=>{k&&!d&&r();}),()=>P.stop()},[d,p,s.drawerMs,r]);let f=p.interpolate({inputRange:[0,1],outputRange:[-u,0]}),m=t.filtered,h=t.rows.length===0,T=t.cursor===null&&!t.loading&&t.error===null,b=h&&t.loading?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,accessibilityLabel:q.loading,accessibilityState:{busy:true},children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{color:o.emptyTitle.color}),jsxRuntime.jsx(E,{style:o.emptyBody,children:q.loading})]}):h&&t.error!==null?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(E,{style:o.emptyTitle,accessibilityRole:"alert",children:q.loadFailed}),jsxRuntime.jsx(E,{style:o.emptyBody,children:t.error}),jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:q.retryA11y,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load();},children:jsxRuntime.jsx(E,{tier:"control",style:o.retryText,children:q.retry})})]}):t.emptyKind==="empty"?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(E,{style:o.emptyTitle,children:q.empty}),jsxRuntime.jsx(E,{style:o.emptyBody,children:q.emptyBody})]}):jsxRuntime.jsx(E,{style:o.noMatch,children:q.noMatch}),S=!t.searching&&t.loadingMore?jsxRuntime.jsx(reactNative.View,{style:o.loadMoreFooter,children:jsxRuntime.jsx(E,{style:o.loadMoreLabel,children:q.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:Pe,onPress:t.close,accessibilityRole:"button",accessibilityLabel:q.closeA11y,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[o.backdrop,{opacity:p}]})}),jsxRuntime.jsx(reactNative.Animated.View,{style:[o.panel,{width:u,paddingTop:Math.max(sR,a.top+n.space.md),transform:[{translateX:f}]}],accessibilityViewIsModal:true,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:o.keyboardAvoider,behavior:reactNative.Platform.OS==="ios"?"padding":"height",children:[jsxRuntime.jsxs(reactNative.View,{style:o.header,children:[jsxRuntime.jsx(E,{tier:"heading",style:o.heading,accessibilityRole:"header",children:q.heading}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:q.newChat,style:o.newChat,onPress:t.newConversation,children:jsxRuntime.jsx(E,{tier:"control",style:o.newChatLabel,children:q.newChat})}),jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:q.close,hitSlop:0,style:o.closeButton,onPress:t.close,children:jsxRuntime.jsx(Qe,{size:cR,color:n.color.text.muted,strokeWidth:1.75})})]}),jsxRuntime.jsxs(reactNative.View,{style:o.searchPill,children:[jsxRuntime.jsx(ec,{size:mR,color:n.color.text.muted,strokeWidth:1.5}),jsxRuntime.jsx(Gt,{value:t.query,onChangeText:P=>t.setQuery(P.replace(/^\s+/,"")),style:o.searchInput,placeholder:q.searchPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:q.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),jsxRuntime.jsx(E,{tier:"compact",style:o.countLabel,children:Ad(t.rows.length,T)}),t.error!==null&&!h?jsxRuntime.jsx(reactNative.View,{style:o.errorCard,children:jsxRuntime.jsx(E,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,jsxRuntime.jsx(reactNative.FlatList,{data:m,keyExtractor:P=>P.id,renderItem:({item:P})=>jsxRuntime.jsx(vR,{row:P,active:P.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(P.id);}}),contentContainerStyle:m.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:b,ListFooterComponent:S,onEndReached:t.loadMore,onEndReachedThreshold:yR})]})})]})})}i(bR,"DrawerModal");function vR({row:e,active:t,disabled:r,styles:n,onPress:o}){let s=e.unreadCount!==null&&e.unreadCount>0,a=Id(e);return jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:Od(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(E,{tier:"control",style:n.itemTitle,numberOfLines:1,children:xn(e.title)}),s?jsxRuntime.jsx(reactNative.View,{style:n.unreadDot}):null]}),a!==null?jsxRuntime.jsx(E,{tier:"compact",style:n.itemMeta,numberOfLines:1,children:a}):null]})}i(vR,"Row");function ER(e){let t=e.color,r=e.space,n=e.type,o=e.slots,s=t.text.primary;return reactNative.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:aR},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.surface,paddingHorizontal:r.lg,borderRightWidth:reactNative.StyleSheet.hairlineWidth,borderRightColor:t.borderRingCream,gap:r.md},keyboardAvoider:{flex:1,gap:r.md},header:{flexDirection:"row",alignItems:"center",gap:r.sm},heading:{...R(e,"bold"),flex:1,fontSize:n.size.subtitle,color:s},newChat:{minHeight:fs,justifyContent:"center",paddingHorizontal:r.xs},newChatLabel:{...R(e,"bold"),fontSize:uR,color:t.brandInk},closeButton:{width:fs,height:fs,alignItems:"center",justifyContent:"center"},searchPill:{flexDirection:"row",alignItems:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,paddingHorizontal:r.md+mt,paddingVertical:r.sm+mt,borderWidth:1,borderColor:t.borderRingCream},searchInput:{...R(e,"regular"),flex:1,fontSize:n.size.bodyTight,color:t.text.primary,padding:0},countLabel:{...R(e,"mono"),fontSize:dR,color:t.text.muted},list:{gap:r.xs,paddingBottom:r.xl},listEmpty:{flexGrow:1},item:{paddingVertical:r.sm+mt,paddingHorizontal:r.sm,borderRadius:e.radius.md,gap:mt},itemActive:{backgroundColor:ut(t.scanButtonPink,lR)??t.surfaceSubtle},itemRow:{flexDirection:"row",alignItems:"center",gap:r.sm},itemTitle:{...R(e,"bold"),flex:1,fontSize:n.size.bodyTight,color:s},itemMeta:{...R(e,"regular"),fontSize:n.size.caption,color:t.text.muted},unreadDot:{width:ms,height:ms,borderRadius:ms/2,backgroundColor:t.danger},errorCard:{borderRadius:fR,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.danger,backgroundColor:t.surface,padding:r.md},errorText:{...R(e,"regular"),fontSize:n.size.caption,color:t.danger},emptyCard:{borderRadius:pR,padding:r.md+mt,gap:r.xs+mt,backgroundColor:t.surfaceSubtle,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.borderRingCream},emptyTitle:{...R(e,"bold"),fontSize:n.size.bodyTight,color:s},emptyBody:{...R(e,"regular"),fontSize:n.size.caption,color:t.text.secondary},noMatch:{...R(e,"regular"),fontSize:n.size.bodyTight,color:t.text.muted,paddingVertical:r.sm},retrySlot:{marginTop:r.sm,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:r.md+mt,paddingVertical:r.sm,borderWidth:1,borderColor:t.brandInk,...me(o.primaryButton)},retryText:{...R(e,"bold"),fontSize:n.size.caption,color:t.brandInk,...ke(o.primaryButton)},loadMoreFooter:{paddingVertical:r.md+mt,alignItems:"center"},loadMoreLabel:{...R(e,"regular"),fontSize:n.size.caption,color:t.text.muted}})}i(ER,"makeStyles");var kR=Object.freeze({}),xR=100,_R=20;function wR(e,t,r,n){return ![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}i(wR,"readWindowTops");function Sp(e,t){let r=typeof e=="number"&&Number.isFinite(e),n=react.useRef(null),[o,s]=react.useState(null),a=react.useRef(null),l=react.useRef(null),u=react.useRef(true),d=react.useCallback(()=>{l.current!==null&&clearTimeout(l.current),l.current=null;},[]);react.useEffect(()=>(u.current=true,()=>{u.current=false,d();}),[d]);let c=react.useCallback(i(function f(m){n.current?.measureInWindow((h,T)=>{let b=a.current;if(!u.current||b===null)return;let S=wR(T,b.y,b.height,reactNative.Dimensions.get("window").height);if(S!==null){s(P=>P!==null&&P.chatTop===S.chatTop&&P.parentTop===S.parentTop?P:S);return}m>=_R||(l.current=setTimeout(()=>{l.current=null,f(m+1);},xR));});},"measureAt"),[]),p=react.useCallback(f=>{let{y:m,height:h}=f.nativeEvent.layout;a.current={y:m,height:h},d(),c(0);},[c,d]);return react.useMemo(()=>{if(!t)return {avoidingProps:r?{keyboardVerticalOffset:e}:kR,probeRef:null,topInWindow:null};let f=o?.parentTop??0;return {avoidingProps:r?{keyboardVerticalOffset:e,onLayout:p}:f>0?{keyboardVerticalOffset:f,onLayout:p}:{onLayout:p},probeRef:n,topInWindow:o?.chatTop??null}},[t,r,e,o,p])}i(Sp,"useChatKeyboardOffset");function Tp({probeRef:e}){return e===null?null:jsxRuntime.jsx(reactNative.View,{ref:e,collapsable:false,pointerEvents:"none",style:IR})}i(Tp,"KeyboardOffsetProbe");var IR=Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function Pp(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),t?.prefer!==void 0&&(r.prefer=t.prefer),r}i(Pp,"chatVetVisitOptions");var LR=.75,NR=1.5,DR=.4,UR=4,VR=1.5,Or=22,BR=14,HR=8,zR=20,jR=10,xp=13,WR=12,GR=15,KR=44,qR=14,$R=1.25,YR=14,XR=6;function QR(e,t){let r=e.color;return t.level==="emergency"?{card:{backgroundColor:r.badgeBgCritical,borderColor:ut(r.danger,DR)??r.danger,borderWidth:NR},label:r.danger,reason:r.text.primary,close:r.danger,action:{fill:r.surface,edge:r.danger,ink:r.danger}}:{card:{backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:LR},label:t.textColor,reason:t.reasonColor,close:t.textColor,action:null}}i(QR,"tierPaint");function _p({surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o}){let s=N(),a=react.useMemo(()=>tS(s),[s]),l=te(),u=e.tier,d=e.source;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bi,{visible:e.showBanner&&u!==null,inMs:l.bannerInMs,outMs:l.bannerOutMs,style:a.pinned,children:u!==null&&d!==null?jsxRuntime.jsx(ZR,{tier:u,reason:d.reason,surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o,styles:a}):null}),jsxRuntime.jsx(Bi,{visible:e.showCompactIcon,inMs:l.iconInMs,outMs:l.iconOutMs,style:a.indicatorRow,children:jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:g.showLatestVetAlert,hitSlop:jR,onPress:e.expand,children:jsxRuntime.jsx(Xd,{size:zR,color:s.color.text.muted,strokeWidth:2})})})]})}i(_p,"UrgencyBanner");function ZR({tier:e,reason:t,surface:r,petRef:n,renderVetAction:o,onFindVet:s,vet:a,styles:l}){let u=N(),d=QR(u,e),c=jsxRuntime.jsx(eS,{tier:e,paint:d,petRef:n,onFindVet:s,vet:a,styles:l}),p=r.showVetAction?o!==void 0?jsxRuntime.jsx(xt,{render:()=>o(e.level),fallback:c,resetKey:e.level}):c:null,f=d.action!==null?jsxRuntime.jsx(JR,{paint:d.action,styles:l}):null;return jsxRuntime.jsxs(reactNative.View,{accessibilityRole:"alert",style:[l.card,d.card],children:[jsxRuntime.jsx(E,{tier:"control",style:[l.label,{color:d.label}],children:e.label}),t!==null?jsxRuntime.jsx(E,{style:[l.reason,{color:d.reason}],children:t}):null,p!==null||f!==null?jsxRuntime.jsxs(reactNative.View,{style:l.actions,children:[p,f]}):null,r.dismissLabel!==null?jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:r.dismissLabel,hitSlop:HR,containerStyle:l.closeSlot,style:l.closeButton,onPress:r.dismiss,children:jsxRuntime.jsx(Qe,{size:BR,color:d.close,strokeWidth:1.5})}):null]})}i(ZR,"BannerCard");function JR({paint:e,styles:t}){let r=i(()=>{try{reactNative.Linking.openURL(rd).catch(()=>{});}catch{}},"call");return jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:g.poisonControlNative,hitSlop:0,style:[t.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:r,children:jsxRuntime.jsx(E,{tier:"control",style:[t.actionLabel,{color:e.ink}],children:g.poisonControlNative})})}i(JR,"PoisonControl");function eS({tier:e,paint:t,petRef:r,onFindVet:n,vet:o,styles:s}){let a=N(),l=jn(Pp(r,o)),u=l.status==="opening",d=!l.available&&n!==void 0,c=l.available?()=>{l.open();}:n!==void 0?()=>{$(n,e.level);}:null;if(c===null)return null;let p=t.action;if(p!==null){let m=d?g.nearestEmergencyVet:g.findVet,h=Vn(a.slots.vetVisitButton)?.textColor??p.ink;return jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:d?g.nearestEmergencyVet:g.findVetA11y,accessibilityState:{busy:u},hitSlop:0,style:[s.action,{backgroundColor:p.fill,borderColor:p.edge},s.findVetSlotBox,u?s.findVetBusy:null],onPress:c,children:[jsxRuntime.jsx(Ni,{size:xp,color:h,strokeWidth:1.5}),jsxRuntime.jsx(E,{tier:"control",style:[s.actionLabel,{color:h}],children:m})]})}let f=Vn(a.slots.vetVisitButton)?.textColor??e.textColor;return jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:g.findVetA11y,accessibilityState:{busy:u},style:[s.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},s.findVetSlotBox,u?s.findVetBusy:null],onPress:c,children:[jsxRuntime.jsx(Ni,{size:xp,color:f,strokeWidth:1.5}),jsxRuntime.jsx(E,{tier:"control",style:[s.findVetLabel,{color:f}],children:g.findVet})]})}i(eS,"VetAction");function tS(e){let t=Vn(e.slots.vetVisitButton),r=e.space,n=e.type;return reactNative.StyleSheet.create({pinned:{marginTop:0,marginBottom:r.xs,paddingHorizontal:r.lg},card:{borderRadius:e.radius.lg,paddingHorizontal:r.lg+UR,paddingVertical:r.lg,gap:r.sm},label:{...R(e,"bold"),fontSize:n.size.body,paddingRight:Or},reason:{...R(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*VR),paddingRight:Or},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm},action:{flexDirection:"row",alignItems:"center",gap:XR,minHeight:KR,paddingHorizontal:qR,borderRadius:e.radius.pill,borderWidth:$R},actionLabel:{...R(e,"bold"),fontSize:YR},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...me(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...R(e,"monoBold"),fontSize:WR,lineHeight:GR},closeSlot:{position:"absolute",top:r.md,right:r.md},closeButton:{width:Or,height:Or,borderRadius:Or/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:r.lg,paddingTop:2,paddingBottom:r.xs}})}i(tS,"makeStyles");function wp(){let e=Un(),{handle:t}=ee(),r=react.useCallback(n=>t.setActivePet(n),[t]);return react.useMemo(()=>({...e,setActivePet:r}),[e,r])}i(wp,"useChatPets");function sS(){try{let e=reactNative.AccessibilityInfo?.announceForAccessibility;typeof e=="function"&&e.call(reactNative.AccessibilityInfo,g.answered);}catch{}}i(sS,"announceAnswered");function Op(e){let t=react.useRef(false),r=react.useRef({send:e.send,id:e.conversationId});react.useEffect(()=>{let n=r.current;if((n.send!==e.send||n.id!==null&&n.id!==e.conversationId)&&(t.current=false),r.current={send:e.send,id:e.conversationId},t.current&&!e.isStreaming){let o=e.messages[e.messages.length-1];o!==void 0&&o.role==="assistant"&&sS();}t.current=e.isStreaming;},[e.isStreaming,e.messages,e.send,e.conversationId]);}i(Op,"useSettleAnnouncement");var Bp=300,Hp=3e3,Mp=120,Lr=44,lS=120,uS="88%",Lp=520,Qn=2,Zn=.5,dS=1.5,cS=1.6,pS=.6,fS=56,Np=1.5,mS=5,yS=5,Dp=36,gS=20,hS=14,Mr=Lr,Jn=4,zp=24,jp=22,bS=.4,Up=Lr,Wp=20,vS=.4,ES=480,CS=12,RS=.72,SS=48,Vp=1,TS=12,PS=18,kS="12%";function ge(){let e=N(),t=react.useMemo(()=>xS(e),[e]);return {theme:e,styles:t}}i(ge,"useChatTheme");function xS(e){let t=e.color,r=e.space,n=e.radius,o=e.type,s=Math.round(o.size.body*dS),a=Math.round(o.size.body*cS),l=Math.round(gS*o.size.body/hS),u=t.borderRingCream,d=e.slots;return reactNative.StyleSheet.create({container:{flex:1,minHeight:Mp,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:Mp,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},emptyContent:{flexGrow:1,alignItems:"stretch",justifyContent:"flex-start",paddingTop:kS,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:ES,gap:r.lg},errorText:{...R(e,"regular"),fontSize:o.size.subtitle,lineHeight:o.size.subtitle*o.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:Lr,minWidth:Lr,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...me(d.primaryButton)},retryLabel:{...R(e,"medium"),color:t.onPrimary,fontSize:o.size.body,...ke(d.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...R(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:{...R(e,"bold"),color:t.text.primary,fontSize:o.size.body},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...R(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal},turnNoticeAction:{minHeight:Lr,justifyContent:"center"},turnNoticeActionLabel:{...R(e,"medium"),color:t.brandInk,fontSize:o.size.body},setupNoticeAction:{...R(e,"medium"),color:t.brandInk,fontSize:o.size.caption},reconnectingCaption:{...R(e,"medium"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},readingLine:{...R(e,"regular"),color:t.text.muted,fontSize:o.size.bodyTight,lineHeight:Math.round(o.size.bodyTight*o.lineHeight.relaxed)},list:{flex:1},listContent:{padding:r.lg,gap:r.xl},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:uS,alignItems:"flex-start"},bubbleSideUser:{alignItems:"flex-end"},bubbleUser:{maxWidth:Lp,paddingVertical:r.md,paddingHorizontal:r.lg+Qn,backgroundColor:t.bubbleUser,borderRadius:n.lg,borderBottomRightRadius:n.xs,...me(d.userBubble,Zn)},bubbleAssistant:d.assistantBubble?.backgroundColor===void 0?{...me(d.assistantBubble,Zn)}:{paddingVertical:r.md,paddingHorizontal:r.lg+Qn,borderRadius:n.lg,...me(d.assistantBubble,Zn)},bubbleVet:{maxWidth:Lp,paddingVertical:r.md,paddingHorizontal:r.lg+Qn,backgroundColor:t.bubbleVet,borderRadius:n.lg,borderTopLeftRadius:n.xs,...me(d.vetBubble,Zn)},bubblePending:{opacity:pS},bubbleTextUser:{...R(e,"regular"),color:t.onPrimary,fontSize:o.size.body,lineHeight:s,...ke(d.userBubble)},bubbleTextAssistant:{...R(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:a,...ke(d.assistantBubble)},bubbleTextVet:{...R(e,"regular"),color:t.onBubbleVet,fontSize:o.size.body,lineHeight:s,...ke(d.vetBubble)},assistantName:{...R(e,"bold"),color:t.brandInk,fontSize:o.size.bodyTight,marginBottom:r.xs},vetHeader:{flexDirection:"row",alignItems:"baseline",gap:r.sm,marginBottom:r.xs},vetSender:{...R(e,"bold"),color:t.text.primary,fontSize:o.size.bodyTight},vetTime:{...R(e,"regular"),color:t.text.muted,fontSize:o.size.caption},bubbleBold:R(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:R(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.md},followUpsHeading:{...R(e,"monoBold"),color:t.text.muted,fontSize:CS,textTransform:"uppercase",letterSpacing:RS,paddingBottom:r.sm,borderBottomWidth:Vp,borderBottomColor:u},followUpSlot:{alignSelf:"stretch"},followUpSlotRuled:{borderTopWidth:Vp,borderTopColor:u},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,minHeight:SS,paddingVertical:r.sm+Qn},followUpText:{...R(e,"bold"),flex:1,color:t.brandInk,fontSize:o.size.bodyTight},composerOuter:{position:"relative"},composer:{marginHorizontal:r.md,marginTop:r.xs,minHeight:fS,justifyContent:"center",paddingLeft:r.sm,paddingRight:mS,paddingVertical:yS,backgroundColor:t.composerFill,borderWidth:Np,borderColor:t.composerBorder,borderRadius:n.pill,...me(d.composerInput,Np)},composerRow:{flexDirection:"row",alignItems:"center",gap:r.xs,minHeight:Dp},attachControl:{width:Up,height:Up,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:vS},input:{flex:1,minHeight:Dp,maxHeight:lS,paddingHorizontal:0,paddingVertical:0,...R(e,"regular"),fontSize:o.size.body,lineHeight:l,color:t.text.primary,...ke(d.composerInput)},sendControl:{minHeight:Mr,minWidth:Mr,alignItems:"center",justifyContent:"center"},sendDisc:{width:Mr,height:Mr,borderRadius:Mr/2,alignItems:"center",justifyContent:"center",...me(d.sendButton)},sendControlDisabled:{opacity:bS},footnote:{...R(e,"regular"),color:t.text.muted,fontSize:TS,lineHeight:PS,textAlign:"center",marginTop:r.sm,marginBottom:r.xs,paddingHorizontal:r.lg},poweredBy:{...R(e,"regular"),color:t.text.muted,fontSize:o.size.micro,textAlign:"center",paddingBottom:r.xs}})}i(xS,"makeStyles");var _S=Object.freeze({kind:"live"}),wS=Object.freeze({kind:"folded"});function gs(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=Io(e.proactiveOriginRef);return {caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}i(gs,"askOf");function Kp(e){let t=new Map,r=new Map;for(let o of e){let s=gs(o);if(s===null)continue;let a=r.get(s.caseId);(a===void 0||s.dueDay>=a.dueDay)&&r.set(s.caseId,{messageId:o.id,dueDay:s.dueDay});}if(r.size===0)return t;let n=null;for(let o of e){let s=gs(o);if(s===null){n=null;continue}if(r.get(s.caseId)?.messageId===o.id){t.set(o.id,_S),n=null;continue}if(n!==null&&n.caseId===s.caseId){n.days.push(s.dueDay),t.set(o.id,wS);continue}let a=[s.dueDay];n={id:o.id,caseId:s.caseId,days:a},t.set(o.id,{kind:"past",runDueDays:a});}return t}i(Kp,"placeCheckins");var Gp=864e5,IS=365;function eo(e,t){if(typeof e!="string"||typeof t!="string")return null;let r=Date.parse(e),n=Date.parse(t);if(Number.isNaN(r)||Number.isNaN(n))return null;let o=Math.floor(n/Gp)-Math.floor(r/Gp);return o<1||o>IS?null:o}i(eo,"checkinDayNumber");function qp(e){return gs(e)?.dueDay||null}i(qp,"checkinDueDay");function to(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}i(to,"formatMessageTime");var xe=Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" \xB7 ",answers:Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),$p=Object.freeze(en.map(e=>Object.freeze({answer:e,label:xe.answers[e]})));function Yp(e,t){let[r,n]=react.useState(null),[o,s]=react.useState(null),[a,l]=react.useState(null),u=react.useCallback(c=>{t!==null&&(n(c),s(null),t(e.caseId,c).then(p=>{n(null),p.ok?l(c):s(p.error);}));},[t,e.caseId]),d=a??e.answer;return {answer:d,answerable:!Ua(e),escalated:d==="worse",pending:r,error:o,choose:u}}i(Yp,"useCheckinCard");var Zp=44,FS=.6;function ef({message:e,checkin:t,onAnswer:r,petRef:n,onFindVet:o,vet:s,onLayout:a}){let l=N(),u=react.useMemo(()=>MS(l),[l]),d=Yp(t,r),c=d.answer!==null||d.pending!==null,p=r!==null&&d.answerable,f=eo(t.openedAt,qp(e));return jsxRuntime.jsxs(reactNative.View,{style:u.card,accessibilityLabel:xe.eyebrow,onLayout:a,children:[jsxRuntime.jsxs(reactNative.View,{style:u.head,children:[jsxRuntime.jsx(E,{tier:"compact",style:u.eyebrow,children:xe.eyebrow}),f!==null?jsxRuntime.jsx(E,{tier:"compact",style:u.headDay,children:K(xe.day,{day:f})}):null]}),jsxRuntime.jsx(E,{style:u.question,accessibilityRole:"text",children:e.text}),p?jsxRuntime.jsx(reactNative.View,{style:[u.row,d.pending?u.rowPending:null],children:$p.map(({answer:m,label:h})=>{let T=(d.pending??d.answer)===m;return jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>d.choose(m),disabled:c,accessibilityRole:"button",accessibilityLabel:h,accessibilityState:{selected:T,disabled:c,busy:d.pending===m},style:[u.pill,T?u.pillSelected:null],children:jsxRuntime.jsx(E,{tier:"control",style:[u.pillLabel,T?u.pillLabelSelected:null],children:h})},m)})}):null,d.answer!==null?jsxRuntime.jsx(E,{style:u.logged,children:xe.logged}):null,d.escalated?o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:xe.findVet,style:u.findVet,children:jsxRuntime.jsx(E,{tier:"control",style:u.findVetLabel,children:xe.findVet})}):n?jsxRuntime.jsx(Zt,{entry:"chat",petRef:n,label:xe.findVet,...s?.returnTo!==void 0?{returnTo:s.returnTo}:{},...s?.usState!==void 0?{usState:s.usState}:{},...s?.prefer!==void 0?{prefer:s.prefer}:{},style:u.findVet,labelStyle:u.findVetLabel}):null:null,t.resolutionText?jsxRuntime.jsx(E,{style:u.resolution,children:t.resolutionText}):null,d.error?jsxRuntime.jsx(E,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}i(ef,"CheckinCard");function MS(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.brandSoft,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...R(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},headDay:{...R(e,"bold"),color:t.text.primary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},question:{...R(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:FS},pill:{flex:1,minHeight:Zp,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brandInk},pillLabel:{...R(e,"regular"),color:t.text.primary,fontSize:o.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...R(e,"regular"),color:t.text.secondary,fontSize:o.size.caption},resolution:{...R(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},error:{...R(e,"regular"),color:t.danger,fontSize:o.size.caption},findVet:{alignSelf:"stretch",minHeight:Zp,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.brandBorder,backgroundColor:t.surface},findVetLabel:{...R(e,"bold"),color:t.brandInk,fontSize:o.size.body}})}i(MS,"makeStyles");var DS=1.5,US=3;function rf({text:e,runDueDays:t,openedAt:r,onLayout:n}){let o=N(),s=react.useMemo(()=>VS(o),[o]),a=t.map(u=>eo(r,u)).filter(u=>u!==null),l=t.length>1;return l&&a.length===0?null:jsxRuntime.jsxs(reactNative.View,{style:s.row,onLayout:n,children:[jsxRuntime.jsx(reactNative.View,{style:s.rule,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}),jsxRuntime.jsxs(reactNative.View,{style:s.body,children:[a.length>0?jsxRuntime.jsx(E,{tier:"compact",style:s.days,children:a.map(u=>K(xe.day,{day:u})).join(xe.daySeparator)}):null,l?null:jsxRuntime.jsx(E,{style:s.question,accessibilityRole:"text",children:e})]})]})}i(rf,"CheckinPastAsk");function VS(e){let t=e.color,r=e.space,n=e.type;return reactNative.StyleSheet.create({row:{flexDirection:"row",paddingVertical:r.xs},rule:{width:DS,borderRadius:1,backgroundColor:t.borderHairlineGreen,marginRight:r.md},body:{flex:1,gap:US},days:{...R(e,"monoMedium"),fontSize:n.size.nano,letterSpacing:n.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},question:{...R(e,"regular"),fontSize:n.size.bodyTight,lineHeight:n.size.bodyTight*n.lineHeight.normal,color:t.text.muted}})}i(VS,"makeStyles");var BS=Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),nf="#C8BEB4";function HS(e){return e?BS[e.toUpperCase()]??nf:nf}i(HS,"tierColor");function zS(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}i(zS,"tierLabel");function We(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(We,"text");function jS(e){let t=We(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}i(jS,"httpsUrl");function WS(e,t){let r=We(e.source_name)??We(e.sourceName),n=We(e.section),o=We(e.authority_tier)??We(e.authorityTier),s=zS(o),a=r??We(e.title)??`Source ${t+1}`,l=We(e.monograph_chunk_id)??We(e.chunkId),u=[n,s].filter(d=>d!==null).join(" \xB7 ");return Object.freeze({title:a,sourceName:r,section:n,authorityTier:o,tierLabel:s,meta:u.length===0?null:u,url:jS(e.url),excerpt:We(e.excerpt),tierColor:HS(o),key:`${a}-${l??"none"}-${t}`})}i(WS,"toCitationCard");function of(e){return e===void 0||e.length===0?GS:Object.freeze(e.map((t,r)=>WS(t,r)))}i(of,"toCitationCards");var GS=Object.freeze([]);function Cs(e){return e===1?`1 ${g.sourceSingular}`:`${e} ${g.sourcePlural}`}i(Cs,"sourcesLabel");function sf(e,t){return `${t?g.hideSources:g.showSources} ${Cs(e)}`}i(sf,"sourcesToggleLabel");function af(e){return [e.url!==null?`${g.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(t=>t!==null&&t.length>0).join(". ")}i(af,"citationA11yLabel");var XS=244,uf=8,df=13,QS=14,ZS=.3,JS=-0.24,eT=22,tT=10,rT=15;function cf({citations:e,onOpenUrl:t}){let r=N(),n=react.useMemo(()=>iT(r),[r]),o=react.useMemo(()=>of(e),[e]),[s,a]=react.useState(false);if(o.length===0)return null;let l=o.length;return jsxRuntime.jsxs(reactNative.View,{style:n.block,children:[jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:sf(l,s),accessibilityState:{expanded:s},containerStyle:n.toggleSlot,style:n.togglePill,onPress:()=>a(u=>!u),children:[jsxRuntime.jsx(qd,{size:df,color:r.color.brandInk,strokeWidth:1.5}),jsxRuntime.jsx(E,{tier:"compact",style:n.toggleLabel,children:Cs(l)}),jsxRuntime.jsx(Kd,{size:df,color:r.color.brandInk,strokeWidth:1.5,direction:s?"up":"down"})]}),s?jsxRuntime.jsx(nT,{cards:o,styles:n,open:t}):null]})}i(cf,"CitationCards");function nT({cards:e,styles:t,open:r}){let n=te(),o=Yt(n.citationsInMs,{risePx:n.citationsRisePx});return jsxRuntime.jsx(reactNative.Animated.View,{style:o,children:jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(s=>jsxRuntime.jsx(oT,{card:s,styles:t,open:r},s.key))})})}i(nT,"Deck");function oT({card:e,styles:t,open:r}){let n=N(),o=e.url!==null&&r!==void 0,s=af(o?e:{...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(E,{style:[t.cardTitle,o?t.cardTitleLink:null],numberOfLines:2,children:e.title}),o?jsxRuntime.jsx($d,{size:QS,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?jsxRuntime.jsx(E,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?jsxRuntime.jsx(E,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let l=e.url;return jsxRuntime.jsx(z,{accessibilityRole:"link",accessibilityLabel:s,style:t.card,onPress:()=>r(l),children:a})}return jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:s,style:t.card,children:a})}i(oT,"Card");function iT(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:{...R(e,"monoBold"),fontSize:o.micro,lineHeight:o.micro,letterSpacing:ZS,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:XS,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:uf,height:uf,borderRadius:n.pill},cardTitle:{...R(e,"bold"),flex:1,fontSize:o.bodyTight,lineHeight:eT,color:t.text.primary,letterSpacing:JS},cardTitleLink:{color:t.linkInk},cardMeta:{...R(e,"monoMedium"),fontSize:o.nano,lineHeight:tT,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},cardExcerpt:{...R(e,"regular"),fontSize:o.tiny,lineHeight:rT,color:t.text.muted}})}i(iT,"makeStyles");var Nr=15,cT=15,pT=6,fT=Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function gf({message:e,onCopy:t,sentiment:r=null,onSentiment:n,thanks:o=false}){let s=N(),a=react.useMemo(()=>mT(s),[s]),l=te(),u=e.role==="user",d=react.useMemo(()=>to(e.createdAt),[e.createdAt]),c=t!==void 0&&e.role!=="vet"&&e.text.length>0,p=e.role==="assistant"&&n!==void 0&&e.responseId!==void 0,[f,m]=react.useState(false),h=react.useRef(null);react.useEffect(()=>()=>{h.current&&clearTimeout(h.current);},[]);let T=i(()=>{t!==void 0&&(qt(t,e.text),m(true),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{m(false),h.current=null;},l.copiedMs));},"copy");return d===null&&!c&&!p?null:jsxRuntime.jsxs(reactNative.View,{style:a.wrap,children:[jsxRuntime.jsxs(reactNative.View,{style:[a.row,u?a.rowUser:a.rowAssistant],children:[d!==null?jsxRuntime.jsx(E,{tier:"compact",style:a.timestamp,children:d}):null,c?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:f?g.copied:u?g.copyUserMessage:g.copyAssistantMessage,hitSlop:cT,onPress:T,style:a.iconHit,children:f?jsxRuntime.jsx(pt,{size:Nr,color:s.color.success,strokeWidth:2}):jsxRuntime.jsx(Yd,{size:Nr,color:s.color.text.timestamp,strokeWidth:1.5})}):null,p?nd.map(({sentiment:b,label:S})=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:S,accessibilityState:{selected:r===b},hitSlop:pT,onPress:()=>n?.(b),style:a.iconHit,children:jsxRuntime.jsx(An,{size:Nr,color:s.color.sentiment[b],active:r===b,rotate:fT[b],strokeWidth:1.5})},b)):null]}),o?jsxRuntime.jsx(E,{style:a.thanks,accessibilityLiveRegion:"polite",children:g.feedbackThanks}):null]})}i(gf,"MessageFooter");function mT(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:{...R(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:Nr,height:Nr,alignItems:"center",justifyContent:"center"},thanks:{...R(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary}})}i(mT,"makeStyles");var hf="#10462E";var bf="#000000",yT="#83E0B4",gT=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:yT,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:hf,brandEdge:true,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})]),hT=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function bT(e){return e==null?e:e.replace(hT,"").trim()}i(bT,"formatBreedForPrompt");var vT=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 ET(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return vT.has(t)}i(ET,"isUninformativeBreed");function CT(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}i(CT,"unspecifiedBreedLabel");function RT(e,t){return ET(e)?CT(t):String(e).replace(/\s+/gu," ").trim()}i(RT,"resolveBreedLabel");function vf(e){let t=e?.name?.trim()||g.emptyTitlePetFallback;return K(g.emptyTitle,{petName:t})}i(vf,"emptyStateTitle");function Ef(e,t=hf){let r=ts(e?.species),n=r==="cat"?"my cat":"my dog",o=e?.name?.trim()||null,s=o||n,a=RT(bT(e?.breed),r)||null,l=rs(e?.ageYears),u=l===null?null:String(l);return Object.freeze(gT.map(d=>{let c=d.label.includes("{breed}"),p=d.label.includes("{ageYears}"),m=d.fallbackLabel!==void 0&&(c&&!a||p&&!u)&&d.fallbackLabel?d.fallbackLabel:d.label,h=K(m,{petName:s,breed:a??n,species:r,ageYears:u??""}),T=!o&&m.startsWith("{petName}")?h.charAt(0).toUpperCase()+h.slice(1):h;return Object.freeze({id:d.id,intent:d.intent,label:T,background:d.background,borderColor:d.brandEdge===true?t:d.borderColor,borderWidth:d.borderWidth})}))}i(Ef,"resolveQuickPrompts");var TT=44,Sf=0,PT=1,kT=.28,xT=2,_T=2,wT=1.3,IT=-0.015;function Tf({pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o}){let s=N(),a=react.useMemo(()=>OT(s),[s]),l=react.useMemo(()=>Ef(e,s.color.brandInk),[e,s.color.brandInk]),u=vf(e);return jsxRuntime.jsxs(reactNative.View,{style:a.block,children:[jsxRuntime.jsx(E,{tier:"heading",style:a.title,accessibilityRole:"header",children:u}),jsxRuntime.jsx(reactNative.View,{style:a.list,accessibilityLabel:g.suggestions,children:l.map((d,c)=>jsxRuntime.jsx(AT,{prompt:d,index:c,petRef:t,onSend:r,onVetPrep:n,vet:o,pet:e,styles:a},d.id))})]})}i(Tf,"QuickPrompts");function AT({prompt:e,index:t,pet:r,petRef:n,onSend:o,onVetPrep:s,vet:a,styles:l}){let u=te(),d=Yt(u.followUpInMs,{delayMs:Fn(u,t),risePx:u.promptRisePx}),c={backgroundColor:e.background};return e.intent==="vet_report"?s!==void 0?jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Sf,style:[l.chip,l.chipEdge,c],onPress:()=>{$(s,r);},children:jsxRuntime.jsx(E,{tier:"compact",style:l.chipLabel,children:e.label})})}):n===null?null:jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(Zt,{entry:"chat",petRef:n,label:e.label,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:[l.chip,l.chipEdge,c],labelStyle:l.chipLabel})}):jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Sf,style:[l.chip,l.chipEdge,c],onPress:()=>o(e.label),children:jsxRuntime.jsx(E,{tier:"compact",style:l.chipLabel,children:e.label})})})}i(AT,"Chip");function OT(e){let t=e.color,r=e.space,n=e.type;return reactNative.StyleSheet.create({block:{gap:r.lg,alignItems:"stretch",width:"100%"},title:{...R(e,"medium"),fontSize:n.size.heading,lineHeight:Math.round(n.size.heading*n.lineHeight.snug),color:t.brandInk,letterSpacing:n.size.heading*IT,textAlign:"left"},list:{width:"100%",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",gap:r.sm+xT},chip:{borderRadius:e.radius.pill,paddingHorizontal:r.lg+_T,paddingVertical:r.sm,minHeight:TT,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipEdge:{borderWidth:PT,borderColor:ut(t.brandInk,kT)??t.borderRingCream},chipLabel:{...R(e,"bold"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*wT),color:bf,textAlign:"left"}})}i(OT,"makeStyles");var Ss=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;function Pf(e){return e.includes("*")||e.includes("`")}i(Pf,"hasInlineMarkup");function kf(e){let t=[],r=0;Ss.lastIndex=0;for(let n=Ss.exec(e);n!==null;n=Ss.exec(e)){n.index>r&&t.push({kind:"text",text:e.slice(r,n.index)});let o=n[1],s=n[2],a=n[3];o!==void 0?t.push({kind:"bold",text:o}):s!==void 0?t.push({kind:"italic",text:s}):a!==void 0&&t.push({kind:"code",text:a}),r=n.index+n[0].length;}return r<e.length&&t.push({kind:"text",text:e.slice(r)}),t}i(kf,"tokenizeInlineMarkdown");function xf(e,t){return Pf(e)?kf(e).map((r,n)=>{switch(r.kind){case "bold":return jsxRuntime.jsx(E,{style:t.bold,children:r.text},n);case "italic":return t.italic?jsxRuntime.jsx(E,{style:t.italic,children:r.text},n):r.text;case "code":return t.code?jsxRuntime.jsx(E,{style:t.code,children:r.text},n):r.text;default:return r.text}}):e}i(xf,"renderInlineMarkdown");function _f({petName:e=null}){let{styles:t}=ge(),r=Tn(g.reading,e);return jsxRuntime.jsx(E,{tier:"compact",style:t.readingLine,accessibilityRole:"text",accessibilityLabel:r,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:r})}i(_f,"TypingIndicator");function wf(e,t,r){let n=e-r,o=t!=null?Math.min(n,t):n;return Math.max(0,o)}i(wf,"resolveTurnScrollTarget");function If(e){let t=e.length-1,r=e[t];if(r===void 0||r.role!=="assistant")return null;let n=e[t-1];return {assistantIndex:t,userIndex:n!==void 0&&n.role==="user"?t-1:null}}i(If,"latestTurn");function Af(e,t,r){let n=Math.max(0,r),o=e===null?n:Math.min(Math.max(0,e),n);return o>t+1?o:null}i(Af,"nextFollowOffset");function Of(e,t){let r=react.useRef(null),n=react.useRef(true),o=react.useRef(t),s=react.useRef(0),a=react.useRef(0),l=react.useRef(0),u=react.useRef(new Map),d=If(e),c=d===null?null:e[d.assistantIndex]?.id??null,p=d===null||d.userIndex===null?null:e[d.userIndex]?.id??null,f=react.useCallback(()=>{let k=r.current;if(k===null||!n.current||a.current===0)return;let x=null;if(c!==null){let _=u.current.get(c);if(_===void 0)return;let A=p===null?null:u.current.get(p)??null;x=wf(_,A,96);}let y=Af(x,s.current,l.current-a.current);y!==null&&(s.current=y,k.scrollTo({y,animated:false}));},[c,p]);react.useEffect(()=>{t&&!o.current&&(n.current=true),o.current=t,f();},[e,t,f]);let m=react.useCallback(k=>{a.current=k.nativeEvent.layout.height,f();},[f]),h=react.useCallback((k,x)=>{l.current=x,a.current>0&&(s.current=Math.min(s.current,Math.max(0,x-a.current))),f();},[f]),T=react.useCallback(k=>{s.current=k.nativeEvent.contentOffset.y;},[]),b=react.useCallback(()=>{n.current=false;},[]),S=react.useCallback(k=>{let{contentOffset:x,contentSize:y,layoutMeasurement:_}=k.nativeEvent;s.current=x.y,n.current=y.height-x.y-_.height<=24;},[]),P=react.useCallback(k=>x=>{u.current.set(k,x.nativeEvent.layout.y),(k===c||k===p)&&f();},[c,p,f]);return {ref:r,onLayout:m,onContentSizeChange:h,onScroll:T,onScrollBeginDrag:b,onScrollEnd:S,rowLayout:P}}i(Of,"useThreadFollow");function Df(e,t,r){switch(e){case "loading":return r.renderPending?jsxRuntime.jsx(xt,{render:r.renderPending,fallback:jsxRuntime.jsx(Mf,{})}):jsxRuntime.jsx(Mf,{});case "empty":return jsxRuntime.jsx(zT,{pet:r.shownPet,petRef:t.petRef,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet});case "error":return jsxRuntime.jsx(GT,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case "populated":return jsxRuntime.jsx(KT,{messages:t.messages,prompts:Hd(t),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,onOpenUrl:r.onOpenUrl,petName:r.shownPet?.name??null});default:return at(e)}}i(Df,"renderView");function Mf(){let{theme:e,styles:t}=ge(),[r,n]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>n(true),Bp);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx(reactNative.View,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:g.loading,children:r?jsxRuntime.jsx(reactNative.ActivityIndicator,{color:e.color.brandInk}):null})}i(Mf,"LoadingState");function zT({pet:e,petRef:t,onSelectPrompt:r,onVetPrep:n,vet:o}){let{styles:s}=ge();return jsxRuntime.jsx(reactNative.ScrollView,{contentContainerStyle:s.emptyContent,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,accessibilityLabel:g.empty,children:jsxRuntime.jsx(Tf,{pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o})})}i(zT,"EmptyState");function jT({prompts:e,onSelectPrompt:t}){let{styles:r}=ge();return e.length===0?null:jsxRuntime.jsxs(reactNative.View,{style:r.followUps,children:[jsxRuntime.jsx(E,{tier:"compact",style:r.followUpsHeading,accessibilityRole:"header",children:g.followUpsHeadingNative}),e.map((n,o)=>jsxRuntime.jsx(WT,{prompt:n,index:o,onSelectPrompt:t},n))]})}i(jT,"FollowUps");function WT({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:o}=ge(),s=te(),a=Yt(s.followUpInMs,{delayMs:Fn(s,t)});return jsxRuntime.jsx(reactNative.Animated.View,{style:a,children:jsxRuntime.jsxs(z,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:[o.followUpSlot,t>0?o.followUpSlotRuled:null],style:o.followUpRow,children:[jsxRuntime.jsx(E,{tier:"control",style:o.followUpText,children:e}),jsxRuntime.jsx(In,{size:XT,color:n.color.text.muted,strokeWidth:1.75})]})})}i(WT,"FollowUpRow");function GT({error:e,onRetry:t,onAddPet:r}){let{styles:n}=ge(),o=pd(e)?Ed(r):void 0;return jsxRuntime.jsxs(reactNative.View,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(E,{style:n.errorText,children:e.displayMessage}),o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:g.addPet,style:n.retryButton,children:jsxRuntime.jsx(E,{tier:"control",style:n.retryLabel,children:g.addPet})}):null,e.retryable?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:g.retry,style:n.retryButton,children:jsxRuntime.jsx(E,{tier:"control",style:n.retryLabel,children:g.retry})}):null]})}i(GT,"ErrorState");function KT({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:o,onCopy:s,sentimentByMessage:a,onSentiment:l,thanksFor:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:f,onRetry:m,onStartNew:h,petRef:T,onFindVet:b,vet:S,onOpenUrl:P,petName:k}){let{styles:x}=ge(),y=te();Pr(e.length,y);let _=react.useMemo(()=>Kp(e),[e]),A=Bd(e,n),O=e[e.length-1],F=react.useMemo(()=>e.filter(I=>!(I.checkin&&_.get(I.id)?.kind==="folded")),[e,_]),C=Of(F,n),w=pc(F);return jsxRuntime.jsxs(reactNative.ScrollView,{ref:C.ref,style:x.list,contentContainerStyle:x.listContent,accessibilityLabel:g.transcript,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,onLayout:C.onLayout,onContentSizeChange:C.onContentSizeChange,onScroll:C.onScroll,scrollEventThrottle:YT,onScrollBeginDrag:C.onScrollBeginDrag,onScrollEndDrag:C.onScrollEnd,onMomentumScrollEnd:C.onScrollEnd,children:[e.map(I=>{let H=I.checkin?_.get(I.id):void 0;return H?.kind==="folded"?null:H?.kind==="past"?jsxRuntime.jsx(rf,{text:I.text,runDueDays:H.runDueDays,openedAt:I.checkin?.openedAt,onLayout:C.rowLayout(I.id)},I.id):I.checkin&&H!==void 0?jsxRuntime.jsx(ef,{message:I,checkin:I.checkin,onAnswer:o,petRef:T,onFindVet:b,vet:S,onLayout:C.rowLayout(I.id)},I.id):jsxRuntime.jsx(QT,{onLayout:C.rowLayout(I.id),message:I,revealing:n&&I===O&&I.role==="assistant",onCopy:s,sentiment:I.responseId===void 0?null:a[String(I.responseId)]??null,onSentiment:l,thanks:u!==null&&I.responseId!==void 0&&String(I.responseId)===u,images:d[I.id]??$T,onPreview:c,onOpenUrl:P,entering:w(I.id)},I.id)}),f?jsxRuntime.jsx(E,{tier:"compact",style:x.reconnectingCaption,accessibilityRole:"text",children:g.reconnecting}):null,A?jsxRuntime.jsx(_f,{petName:k}):null,p!==null?jsxRuntime.jsx(qT,{notice:p,onRetry:m,onStartNew:h}):null,jsxRuntime.jsx(jT,{prompts:t,onSelectPrompt:r})]})}i(KT,"PopulatedState");function qT({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=ge(),o=e.tone==="error";return jsxRuntime.jsxs(reactNative.View,{style:[n.turnNotice,o?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(E,{tier:"control",style:[n.turnNoticeTitle,o?n.turnNoticeTitleError:null],children:e.title}),jsxRuntime.jsx(E,{tier:"compact",style:n.turnNoticeBody,children:e.body}),jsxRuntime.jsx(reactNative.Pressable,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:Jn,style:n.turnNoticeAction,children:jsxRuntime.jsx(E,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}i(qT,"TurnNoticeCard");var $T=Object.freeze([]),YT=16,XT=18;function QT({message:e,revealing:t,onCopy:r,sentiment:n,onSentiment:o,thanks:s,images:a,onPreview:l,onOpenUrl:u,onLayout:d,entering:c}){let{theme:p,styles:f}=ge(),m=te(),h=cc(c,m),T=fc(e.text,t,m),b=e.role==="user",S=e.role==="vet",P=e.role==="assistant",k=P&&!p.meta.hidePoweredBy,x=b?g.senderUser:S?zd(e):k?g.assistantName:g.senderAssistant,y=S?to(e.createdAt):null,_=react.useCallback(O=>o(e,O),[o,e]),A=e.pending!==true;return jsxRuntime.jsxs(reactNative.View,{style:[f.rowBlock,b?f.rowBlockUser:f.rowBlockAssistant],onLayout:d,children:[jsxRuntime.jsx(reactNative.View,{style:[f.row,b?f.rowUser:f.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${x}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:jsxRuntime.jsxs(reactNative.Animated.View,{style:[f.bubble,b?f.bubbleSideUser:null,h],children:[k?jsxRuntime.jsx(E,{tier:"control",style:f.assistantName,children:g.assistantName}):null,S?jsxRuntime.jsxs(reactNative.View,{style:f.vetHeader,children:[jsxRuntime.jsx(E,{tier:"control",style:f.vetSender,children:x}),y!==null?jsxRuntime.jsx(E,{tier:"compact",style:f.vetTime,children:y}):null]}):null,jsxRuntime.jsxs(reactNative.View,{style:[b?f.bubbleUser:S?f.bubbleVet:f.bubbleAssistant,e.pending?f.bubblePending:null],children:[b&&a.length>0?jsxRuntime.jsx(Ic,{images:a,onPreview:O=>l({uri:O.uri,label:O.filename})}):null,jsxRuntime.jsx(E,{style:b?f.bubbleTextUser:S?f.bubbleTextVet:f.bubbleTextAssistant,children:P?xf(T,{bold:f.bubbleBold,italic:f.bubbleItalic,code:f.bubbleCode}):e.text})]})]})}),P&&!t?jsxRuntime.jsx(cf,{citations:e.citations,onOpenUrl:u}):null,A?jsxRuntime.jsx(gf,{message:e,onCopy:r,sentiment:n,onSentiment:e.responseId===void 0?void 0:_,thanks:s}):null]})}i(QT,"MessageRow");var rP=Object.freeze(["photo"]),nP=1;function Vf(e){let{style:t,renderPending:r}=e;return jsxRuntime.jsx(Si,{capability:"chat",style:t,...r?{renderPending:r}:{},children:jsxRuntime.jsx(oP,{...e})})}i(Vf,"EverfurChat");function oP({petRef:e,conversationId:t,style:r,renderPending:n,onCopy:o,onPetChange:s,onVetPrep:a,onFindVet:l,renderVetAction:u,attachments:d,pet:c,onAddPet:p,checkinTarget:f,initialAsk:m,composerSeed:h,lifecycle:T,draftStore:b,vetReturnTo:S,vetUsState:P,vetPrefer:k,onOpenUrl:x,keyboardVerticalOffset:y}){let{theme:_,styles:A}=ge(),O=te(),F=react.useMemo(()=>jd(e,t),[e,t]),C=Rr(F),w=Ud(C),I=wp(),H=Fd(C),Q=reactNativeSafeAreaContext.useSafeAreaInsets(),oe=Vd(C),Y=react.useMemo(()=>l===void 0?void 0:()=>{$(l,"emergency");},[l]),we=react.useMemo(()=>S===void 0&&P===void 0&&k===void 0?void 0:{returnTo:S,usState:P,prefer:k},[S,P,k]),it=ds(I.pets,C.petRef),he=react.useMemo(()=>Nd(C.messages,it?.name??null),[C.messages,it?.name]),st=Dd(he);Op(C),Pr(st.showBanner,O),Td(C.openCheckin,f),hd(C.askEverfur,C.isBootstrapping,m);let Vr=react.useMemo(()=>Ai(h),[h]);Rd(T,{conversationId:C.conversationId===null?null:String(C.conversationId),isTurnInFlight:C.isStreaming,refresh:C.refreshActiveThread});let Br=(C.hasUnreadThreads??false)||H.rows.some(Se=>Se.unreadCount!==null&&Se.unreadCount>0)||(C.unreadCount??0)>0,Lt=yd(C.messages),[Jt,io]=react.useState(null),Hf=react.useCallback(()=>io(null),[]),[er,so]=react.useState(null),[zf,xs]=react.useState(null),Nt=react.useRef(null);react.useEffect(()=>()=>{Nt.current&&clearTimeout(Nt.current);},[]);let _s=react.useCallback(Se=>{xs(String(Se)),Nt.current&&clearTimeout(Nt.current),Nt.current=setTimeout(()=>{xs(null),Nt.current=null;},Hp);},[]),jf=react.useCallback((Se,zr)=>{let tr=Se.responseId;if(tr===void 0)return;let Yf=C.sentimentByMessage[String(tr)];C.feedback(tr,zr),zr==="down"&&Yf!=="down"&&so(tr);},[C]),Wf=react.useCallback(async(Se,zr)=>er===null||!(await C.feedback(er,"down",Se??"other",zr)).ok?false:(so(null),_s(er),true),[C,er,_s]),Gf=react.useCallback(()=>so(null),[]),Kf=react.useCallback(Se=>{C.send(Se);},[C.send]),qf=react.useMemo(()=>x===void 0?void 0:Se=>{$(x,Se,"citation");},[x]),ws=reactNative.Platform.OS==="ios"?"padding":void 0,Hr=Sp(y,ws!==void 0),$f=Hr.topInWindow===null?Q.top:Math.max(0,Q.top-Hr.topInWindow),Is={send:C.send,stop:C.stop,isStreaming:C.isStreaming,conversationId:C.conversationId,seed:Vr,draftStore:b,onStage:Lt.stage,onPreview:io,petName:it?.name??null};return jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:[A.container,{paddingTop:$f},r],behavior:ws,...Hr.avoidingProps,children:[jsxRuntime.jsx(Tp,{probeRef:Hr.probeRef}),jsxRuntime.jsx(mp,{pets:I,petRef:C.petRef,historyUnread:Br,onOpenHistory:H.show,onPetChange:s,onAddPet:p,vet:we}),c!==void 0?jsxRuntime.jsx(iP,{petRef:e??null,pet:c,onRegistered:I.refresh}):null,jsxRuntime.jsx(_p,{surface:st,petRef:C.petRef,renderVetAction:u,onFindVet:l,vet:we}),jsxRuntime.jsx(reactNative.View,{style:A.body,children:Df(w,C,{notice:oe,vet:we,onCheckinFindVet:Y,onSelectPrompt:Kf,renderPending:n,shownPet:it,onVetPrep:a,onCopy:o,onSentiment:jf,thanksFor:zf,imagesByMessage:Lt.byMessage,onPreview:io,onAddPet:p,onOpenUrl:qf})}),d!==void 0?jsxRuntime.jsx(sP,{...Is,attachments:d}):jsxRuntime.jsx(Bf,{...Is,attachments:null}),jsxRuntime.jsx(E,{tier:"compact",style:A.footnote,accessibilityRole:"text",children:g.footnoteNative}),_.meta.hidePoweredBy?null:jsxRuntime.jsx(E,{tier:"compact",style:A.poweredBy,accessibilityRole:"text",accessibilityLabel:g.poweredBy,children:g.poweredBy}),jsxRuntime.jsx(Rp,{chat:C,history:H}),jsxRuntime.jsx(Ep,{visible:er!==null,onSubmit:Wf,onSkip:Gf}),jsxRuntime.jsx(mc,{uri:Jt?.uri??null,label:Jt?.label??"",onClose:Hf}),jsxRuntime.jsx(xr,{})]})}i(oP,"ChatBody");function iP({petRef:e,pet:t,onRegistered:r}){let{styles:n}=ge(),o=fd(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(E,{tier:"compact",style:n.setupNoticeText,children:o.error.displayMessage}),jsxRuntime.jsx(reactNative.Pressable,{onPress:o.retry,accessibilityRole:"button",accessibilityLabel:g.retry,hitSlop:Jn,children:jsxRuntime.jsx(E,{tier:"control",style:n.setupNoticeAction,children:g.retry})})]})}i(iP,"PetSetupNotice");function sP({attachments:e,...t}){let r=react.useMemo(()=>Oc(),[]),n=Pn({maxPerMessage:e.maxPerMessage??nP,transport:r}),o=react.useMemo(()=>({state:n,sources:e.sources??rP,pick:e.pick}),[n,e.sources,e.pick]);return jsxRuntime.jsx(Bf,{...t,attachments:o})}i(sP,"ComposerWithAttachments");function Bf({send:e,stop:t,isStreaming:r,conversationId:n,attachments:o,seed:s,draftStore:a,onStage:l,onPreview:u,petName:d}){let{theme:c,styles:p}=ge(),f=te(),[m,h]=xd(e,n,s);_d(a,n===null?null:String(n),m,h);let[T,b]=react.useState(false),[S,P]=react.useState(false);react.useEffect(()=>{P(false);},[n]);let k=c.meta.placeholder??Tn(g.placeholder,d),x=o?.state.uploading??false,y=o?.state.failed??false,_=x||y,A=o?.state.attachments??aP;Pr(A.length,f);let O=react.useCallback(()=>{if(m.trim().length===0||_||[...m].length>Ht)return;let oe=o?.state.s3Keys??lP;o!==null&&oe.length>0?(l(o.state.attachments.filter(Y=>Y.status==="uploaded").map(Y=>({uri:Y.previewUri,filename:Y.filename}))),e(m,{imageS3Keys:oe}),o.state.clear()):e(m),h(""),P(false);},[m,e,_,o,l]),F=react.useCallback(()=>{t();},[t]),C=react.useCallback(oe=>{b(false),o!==null&&(P(false),o.state.dismissRejected(),qt(o.pick,oe).then(Y=>{if(!Y.ok){P(true);return}Y.value!==null&&o.state.add(Y.value);}));},[o]),I=react.useMemo(()=>[...m].length>Ht,[m])||_,H=o!==null&&A.length>=o.state.maxPerMessage,Q=c.slots.sendButton?.textColor??c.color.brandInk;return jsxRuntime.jsxs(reactNative.View,{style:p.composerOuter,children:[o!==null&&T?jsxRuntime.jsx(hc,{sources:o.sources,full:H,onPick:C,onClose:()=>b(false)}):null,jsxRuntime.jsxs(reactNative.View,{style:p.composer,children:[o!==null?jsxRuntime.jsx(wc,{attachments:A,rejected:S?uP:o.state.rejected,uploadFailed:y,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:oe=>u({uri:oe.previewUri,label:oe.filename})}):null,jsxRuntime.jsxs(reactNative.View,{style:p.composerRow,children:[o!==null?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:H?ud(A.length,o.state.maxPerMessage):g.attachPhotoOrFileNative,accessibilityState:{disabled:H,expanded:T},disabled:H,style:[p.attachControl,H?p.attachControlDisabled:null],onPress:()=>b(oe=>!oe),children:jsxRuntime.jsx(Qd,{size:Wp,color:H?c.color.text.muted:c.color.brandInk,strokeWidth:1.75})}):null,jsxRuntime.jsx(Gt,{style:p.input,value:m,onChangeText:h,placeholder:k,placeholderTextColor:c.slots.composerInput?.textColor??c.color.text.placeholder,accessibilityLabel:g.composerLabel,onSubmitEditing:O,returnKeyType:"send",blurOnSubmit:false,multiline:true,editable:true}),r?jsxRuntime.jsx(reactNative.Pressable,{onPress:F,accessibilityRole:"button",accessibilityLabel:g.stop,style:p.sendControl,children:jsxRuntime.jsx(reactNative.View,{style:p.sendDisc,testID:"everfur-stop-disc",children:jsxRuntime.jsx(rc,{size:jp,color:Q,testID:"everfur-stop-glyph"})})}):jsxRuntime.jsx(reactNative.Pressable,{onPress:O,disabled:I,accessibilityRole:"button",accessibilityLabel:g.send,accessibilityState:{disabled:I,busy:x},style:[p.sendControl,I?p.sendControlDisabled:null],children:jsxRuntime.jsx(reactNative.View,{style:p.sendDisc,testID:"everfur-send-disc",children:jsxRuntime.jsx(tc,{size:zp,color:Q,testID:"everfur-send-glyph"})})})]})]})]})}i(Bf,"Composer");var aP=Object.freeze([]),lP=Object.freeze([]),uP=Object.freeze({code:"unknown",retryable:true,filename:""});function mP(e){let{runtime:t,userRef:r,scopeEpoch:n}=ee(),o=react.useMemo(()=>lt(t.registry.services.authFor(r)),[t,r,n]),s=react.useMemo(()=>({repository:o,petRef:e}),[o,e]),[a,l]=react.useState({key:s,profile:null,loading:e!==null,error:null}),u=a.key===s?a:{profile:null,loading:e!==null,error:null},d=react.useRef(0),c=react.useCallback(async()=>{let p=++d.current;if(s.petRef===null){l({key:s,profile:null,loading:false,error:null});return}l(m=>({key:s,profile:m.key===s?m.profile:null,loading:true,error:null}));let f=await s.repository.getPetProfile(s.petRef);p===d.current&&l(f.ok?{key:s,profile:f.value,loading:false,error:null}:{key:s,profile:null,loading:false,error:f.error});},[s]);return react.useEffect(()=>(c(),()=>{d.current+=1;}),[c]),react.useMemo(()=>({profile:u.profile,loading:u.loading,error:u.error,refresh:c}),[u.profile,u.loading,u.error,c])}i(mP,"useEverfurPetProfile");function gP(e){return react.createElement(Cn,{clientTheme:e.clientTheme??null,seams:Sn,children:e.children})}i(gP,"EverfurThemeProvider");exports.APPEARANCE_PRESETS=tu;exports.APPEARANCE_PRESET_NAMES=eu;exports.APPEARANCE_SIZE_RANGES=br;exports.CapabilityGate=Si;exports.EverfurChat=Vf;exports.EverfurConfigError=re;exports.EverfurProvider=Fb;exports.EverfurThemeProvider=gP;exports.EverfurThrownError=jr;exports.THEME_SLOT_KEYS=kg;exports.THEME_SLOT_NAMES=$e;exports.canonicalPetSpecies=pr;exports.categoryFor=lo;exports.conversationId=nm;exports.createRnRecordsUploadTransport=Cm;exports.expandAppearance=ii;exports.face=R;exports.isErr=Zf;exports.isOk=Qf;exports.isRetryableCode=uo;exports.petRef=tm;exports.previewTheme=Ih;exports.unwrap=Jf;exports.useCapability=Wt;exports.useChatAttachments=Pn;exports.useEverfur=Fu;exports.useEverfurChat=Rr;exports.useEverfurPetProfile=mP;exports.useEverfurPets=Un;exports.useEverfurTheme=N;exports.userFacingError=Dt;exports.userRef=rm;
|