@everfur/sdk 0.5.7 → 0.5.9
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 +37 -0
- package/dist/{Chat-C8OR_AI2.d.ts → Chat-C9dVhnyt.d.ts} +3 -3
- package/dist/{Chat-GrVxqwYw.d.cts → Chat-WmdRwC3b.d.cts} +3 -3
- package/dist/{DepthViews-CUjaiKlo.d.ts → DepthViews-CBoI9EYy.d.ts} +1 -1
- package/dist/{DepthViews-CKO66Myd.d.ts → DepthViews-CmxhM8iP.d.ts} +1 -1
- package/dist/{DepthViews-DGH2wGj_.d.cts → DepthViews-DoODlUnQ.d.cts} +1 -1
- package/dist/{DepthViews-D37_RviC.d.cts → DepthViews-NPFtO5Kz.d.cts} +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-BB1UJWnE.d.ts → attachments-CuFT1o5q.d.ts} +5 -5
- package/dist/{attachments-whGKD6W3.d.cts → attachments-OaW36D0H.d.cts} +2 -2
- package/dist/{attachments-CGwqUqKv.d.ts → attachments-R2oajKPT.d.ts} +2 -2
- package/dist/{attachments-BoAvTNhc.d.cts → attachments-c4mJcIWU.d.cts} +5 -5
- package/dist/{bookingCopy-CR1OG51t.d.cts → bookingCopy-DGQPrisa.d.cts} +2 -2
- package/dist/{bookingCopy-fV30DkIz.d.ts → bookingCopy-EtPJ4nME.d.ts} +2 -2
- package/dist/{branding-xpQ056sM.d.ts → branding-DiaCIJZL.d.cts} +2 -2
- package/dist/{branding-Xb_wL8N1.d.cts → branding-Ry0em51L.d.ts} +2 -2
- package/dist/{casesRepository-C8Lbu2hu.d.ts → casesRepository-Cu8h8gQK.d.ts} +1 -1
- package/dist/{casesRepository-DQd1BzeU.d.cts → casesRepository-DB5c8AAo.d.cts} +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 +4 -4
- package/dist/client/index.d.cts +10 -10
- package/dist/client/index.d.ts +10 -10
- package/dist/client/index.js +4 -4
- package/dist/{config-1sjsfSqw.d.cts → config-DQFMkaTU.d.cts} +1 -1
- package/dist/{config-CRqlaRdm.d.ts → config-DlR_I-0S.d.ts} +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-CptFbEl3.d.ts → context-CLuquPRB.d.ts} +7 -7
- package/dist/{context-6TkTwYWz.d.cts → context-DZEieVJ5.d.cts} +7 -7
- package/dist/{copy-Cbh62Ahp.d.cts → copy-B2DOzSSy.d.cts} +2 -2
- package/dist/{copy-fyJWwXLB.d.ts → copy-ptTCT5-J.d.ts} +2 -2
- package/dist/core/index.cjs +7 -7
- package/dist/core/index.d.cts +15 -15
- package/dist/core/index.d.ts +15 -15
- package/dist/core/index.js +7 -7
- package/dist/{depth-CFvkrm5i.d.ts → depth-CtyC7HOF.d.ts} +2 -2
- package/dist/{depth-A0lzfsHw.d.cts → depth-DuOyvthD.d.cts} +2 -2
- package/dist/{entitlementRepository-B9Nrivmd.d.ts → entitlementRepository-CAtyh8Xt.d.ts} +3 -3
- package/dist/{entitlementRepository-CCY6wtld.d.cts → entitlementRepository-DlGwxZ1k.d.cts} +3 -3
- package/dist/{identity-CQ_S12DE.d.cts → identity-BC9AF3y4.d.cts} +1 -1
- package/dist/{identity-sKp5WoCR.d.ts → identity-D_NR9ucT.d.ts} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +16 -16
- package/dist/index.d.ts +16 -16
- 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-CO8D9-_Q.d.cts → pets-D7UjvR1A.d.cts} +1 -1
- package/dist/{pets-u62Gt8RO.d.ts → pets-DuuNvKTK.d.ts} +1 -1
- package/dist/{petsRepository-3anNlfb7.d.ts → petsRepository-C28NKFwy.d.ts} +1 -1
- package/dist/{petsRepository-BXOEFjRd.d.cts → petsRepository-llMvpMkp.d.cts} +1 -1
- package/dist/photo/index.cjs +1 -1
- package/dist/photo/index.js +1 -1
- package/dist/{ports-DoJgREyr.d.cts → ports-Dbw2h_M1.d.cts} +25 -6
- package/dist/{ports-BlKQDOwZ.d.ts → ports-s45HNNyc.d.ts} +25 -6
- package/dist/records/depth/index.cjs +1 -1
- package/dist/records/depth/index.d.cts +7 -7
- package/dist/records/depth/index.d.ts +7 -7
- package/dist/records/depth/index.js +1 -1
- package/dist/records/index.cjs +3 -3
- package/dist/records/index.d.cts +9 -9
- package/dist/records/index.d.ts +9 -9
- package/dist/records/index.js +3 -3
- package/dist/{requestFunnel-Cz3zOMJo.d.ts → requestFunnel-CqwOiZNJ.d.ts} +2 -2
- package/dist/{requestFunnel-iJJcNuWp.d.cts → requestFunnel-D_o7se38.d.cts} +2 -2
- package/dist/{runtimeTypes-CrAbk27V.d.cts → runtimeTypes-BNBENMkz.d.cts} +5 -5
- package/dist/{runtimeTypes-L-KYBPq-.d.ts → runtimeTypes-DS0RLoKN.d.ts} +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 +1 -1
- package/dist/televet/booking/index.d.cts +6 -6
- package/dist/televet/booking/index.d.ts +6 -6
- package/dist/televet/booking/index.js +1 -1
- package/dist/televet/call/index.cjs +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.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/rn/index.cjs +1 -1
- package/dist/testing/rn/index.d.cts +9 -9
- package/dist/testing/rn/index.d.ts +9 -9
- 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-CtCZFBTj.d.cts → timelineRows-B6nCq30k.d.cts} +1 -1
- package/dist/{timelineRows-BORU0Ybg.d.ts → timelineRows-DacfDpDU.d.ts} +1 -1
- package/dist/{tokens-CIngRkvt.d.cts → tokens-DOTIxrws.d.cts} +8 -1
- package/dist/{tokens-CIngRkvt.d.ts → tokens-DOTIxrws.d.ts} +8 -1
- package/dist/{typeStyle-YPS_MXeI.d.ts → typeStyle-DROhJNkh.d.ts} +2 -2
- package/dist/{typeStyle-DHJzDaUo.d.cts → typeStyle-achxqQ-h.d.cts} +2 -2
- package/dist/{useRecordsDepth-C9jITKwj.d.cts → useRecordsDepth-BLK8W646.d.cts} +1 -1
- package/dist/{useRecordsDepth-CLtpeQHl.d.ts → useRecordsDepth-C7guUoLc.d.ts} +1 -1
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.js +1 -1
- package/dist/{view-BDSk7WW0.d.ts → view-B6JsD22K.d.ts} +2 -2
- package/dist/{view-B7Mz1TyH.d.cts → view-BF9oW2GJ.d.cts} +2 -2
- 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 +19 -19
- package/dist/web/index.d.ts +19 -19
- 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 +1 -1
- 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 +1 -1
- package/dist/web/records/index.cjs +1 -1
- package/dist/web/records/index.d.cts +9 -9
- package/dist/web/records/index.d.ts +9 -9
- package/dist/web/records/index.js +1 -1
- package/dist/web/televet/booking/index.cjs +1 -1
- package/dist/web/televet/booking/index.d.cts +7 -7
- package/dist/web/televet/booking/index.d.ts +7 -7
- package/dist/web/televet/booking/index.js +1 -1
- package/dist/web/televet/call/index.cjs +1 -1
- package/dist/web/televet/call/index.js +1 -1
- package/dist/web/televet/index.cjs +1 -1
- package/dist/web/televet/index.js +1 -1
- 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'),_h=require('react-native-sse'),reactNative=require('react-native'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var _h__default=/*#__PURE__*/_interopDefault(_h);var Rf=Object.defineProperty;var i=(e,t)=>Rf(e,"name",{value:t,configurable:true});function Re(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(Re,"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 E(e){return Object.freeze({ok:false,error:e})}i(E,"err");function Sf(e){return e.ok}i(Sf,"isOk");function Tf(e){return !e.ok}i(Tf,"isErr");var Lr=class Lr 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,Lr.prototype);}};i(Lr,"EverfurThrownError");var Mr=Lr;function Pf(e){if(e.ok)return e.value;throw new Mr(e.error)}i(Pf,"unwrap");var Dr=class Dr extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,Dr.prototype);}};i(Dr,"EverfurConfigError");var Q=Dr;var fs=128,ms=128,ys=/[\u0000-\u001F\u007F]/,kf=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function xf(e){let t=e,r=at(t);if(r===0||r>ms)throw new Q("invalid-argument",`petRef must be 1..${ms} characters`);if(ys.test(t))throw new Q("invalid-argument","petRef must be printable (no control characters)");return t}i(xf,"petRef");function _f(e){let t=e,r=at(t);if(r===0||r>fs)throw new Q("invalid-argument",`userRef must be 1..${fs} characters`);if(t.includes("@"))throw new Q("invalid-argument","userRef must not contain '@'");if(ys.test(t))throw new Q("invalid-argument","userRef must be printable (no control characters)");return t}i(_f,"userRef");function wf(e){if(!kf.test(e))throw new Q("invalid-argument","conversationId must be a UUID");return e}i(wf,"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 If=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"}),hs=Object.freeze(Kn.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:If[e.wireCode]}))),Af=new Map(hs.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),Of=Object.freeze(["http_envelope",...[...new Set(hs.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function Nr(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let n of [t??"http_envelope",...Of]){let o=Af.get(n+r);if(o)return o}}i(Nr,"contractErrorFor");function Ff(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(Ff,"contractDocUrl");function bs(e){return null}i(bs,"publishedDocUrl");var Mf=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 Mf[e]}i(qn,"categoryFor");function Oe(e){let t=Nr(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 vs(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(vs,"fromHttpStatus");var Lf=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function Be(e){return Lf.has(e)}i(Be,"isAutoRetryable");var Df=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function $n(e){return Be(e)||Df.has(e)}i($n,"isRetryableCode");function Ur(e,t=false){return t||Be(e)}i(Ur,"shouldRetry");var Nf=500,Yn=8e3,Zt=4;function Vr(e,t=Math.random){let r=Math.max(0,e),n=Math.min(Nf*2**r,Yn);return Math.floor(t()*n)}i(Vr,"backoffDelayMs");function Es(e){return e==="conversationNotFound"}i(Es,"canRecreateOnNotFound");var Uf=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 Ft(e){return Uf[e]}i(Ft,"userFacingError");function Cs(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(Cs,"defineHidden");var Vf=/^[a-z][a-z0-9_]{0,63}$/;function D(e,t){let r=Nr(t?.wireCode,t?.wireEnvelope),n={code:e,category:qn(e),retryable:t?.retryable??$n(e),displayMessage:Ft(e)};if(t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&Vf.test(t.reasonCode)&&(n.reasonCode=t.reasonCode),r);return t?.wireMessage&&Cs(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Cs(n,"raw",t.raw),Object.freeze(n)}i(D,"makeEverfurError");var Hf="file",Xn="multipart upload failed";function Hr(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(Hf,e.file);}catch{return Promise.reject(new Error(Xn))}return e.fetch!==void 0?jf(e.fetch,e.url,t,e.signal):zf(e.url,t,e.signal)}i(Hr,"postRnMultipart");function Bf(e){return e>=200&&e<300}i(Bf,"stored");function zf(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(Bf(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(zf,"postWithXhr");function jf(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(o=>o.ok)}i(jf,"postWithFetch");var Wf="document.pdf",Gf="records upload: the file handle has no uri",Kf="records upload failed";function qf(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(Gf));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(Kf)),"failed");return o?.aborted===true?a():Hr({url:t.upload_url,fields:t.upload_fields,file:{uri:r.uri,name:Wf,type:"application/pdf"},signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(qf,"createRnRecordsUploadTransport");var Br=Object.freeze({track(){},trackExpectedFailure(){}});var Rs=Object.freeze({shouldRetry(e,t){return Be(e)&&t<Zt},maxAttempts(){return Zt}});var Ss=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 Ts(e,t,r=null){return Object.freeze({kind:"accepted",streamId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(Ts,"acceptedFrame");function Ps(e,t=null){return Object.freeze({kind:"heartbeat",lastEventId:e,serverRequestId:t,terminal:false})}i(Ps,"heartbeatFrame");function ks(e,t,r=null){return Object.freeze({kind:"delta",delta:e,lastEventId:t,serverRequestId:r,terminal:false})}i(ks,"deltaFrame");function xs(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(xs,"doneFrame");function de(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(de,"errorFrame");function _s(e,t,r=null){return Object.freeze({kind:"analysisStarted",requestId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(_s,"analysisStartedFrame");function ws(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(ws,"analysisCompleteFrame");function Is(e,t,r=null){return Object.freeze({kind:"unknown",raw:{...e},lastEventId:t,serverRequestId:r,terminal:false})}i(Is,"unknownFrame");function As(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:Xf(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(As,"createIdentityProvider");function Xf(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(Xf,"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 Qf(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(Qf,"authHeaders");function Jt(e,t){return {...e,headers:{...Zf(e.headers),...Qf(t)}}}i(Jt,"withAuthHeaders");function Zf(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(Zf,"stripAuthHeaders");async function Os(e,t){if(t.mode==="anonymous")return t.transport.request(Jt(e,{mode:"anonymous",publishableKey:t.publishableKey,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));let r;try{r=await t.identity.currentToken();}catch{return E(Qn())}let n=await t.transport.request(Jt(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 E(Qn())}let s=await t.transport.request(Jt(e,{mode:"personalized",token:o,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !s.ok&&s.error.httpStatus===401?E(Qn(s.error.httpStatus)):s}i(Os,"authedSend");function Qn(e){return D("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(Qn,"authRejectedError");var Fs=`
|
|
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=`
|
|
2
2
|
|
|
3
|
-
`,
|
|
3
|
+
`,tm=1048576,rm=zod.z.record(zod.z.string(),zod.z.unknown()),nm=["emergency","schedule_soon","home_care"];async function*jr(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(Ds,a);if(d===-1)break;let c=s.slice(0,d);s=s.slice(d+Ds.length),a=0;let p=Ns(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>tm){yield ce({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=Ns(s,n());if(u!==null&&(u.kind==="delta"&&(l=true),yield u,u.terminal))return}yield ce({code:l?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});}i(jr,"parseSse");function Ns(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=rm.safeParse(o);return s.success?om(s.data,r,t):null}i(Ns,"parseBlock");function om(e,t,r){let n=e.type,o=e.event;if(n==="error"||"error"in e)return ce({code:le(e.code)??"unknown",retryable:e.retryable===true,wireMessage:le(e.error),synthesized:false,lastEventId:t,serverRequestId:r});if(n==="done"||e.done===true)return Is({conversationId:le(e.conversation_id)??"",messageId:le(e.message_id),title:le(e.title),followUpQuestions:am(e.follow_up_questions),citations:Us(e.citations),citationStatus:le(e.citation_status),urgencyLevel:Vs(e.urgency_level),urgencyReason:le(e.urgency_reason),urgencyProvided:sm(e),resultId:le(e.result_id),lastEventId:t},r);if(n==="accepted"||e.status==="reasoning")return xs(le(e.stream_id),t,r);if(n==="heartbeat"||e.heartbeat===true)return _s(t,r);if(n==="text.delta"||"delta"in e||"token"in e){let s=le(e.delta)??le(e.token)??"";return ws(s,t,r)}return o==="analysis_started"?As(le(e.request_id),t,r):o==="analysis_complete"?Os({resultId:le(e.result_id),analysisType:le(e.analysis_type),modelVersion:le(e.model_version),confidence:im(e.confidence),detections:Us(e.detections),interpretation:le(e.interpretation),lastEventId:t},r):Fs(e,t,r)}i(om,"frameFromWire");function le(e){return typeof e=="string"?e:null}i(le,"asString");function im(e){return typeof e=="number"&&Number.isFinite(e)?e:null}i(im,"asNumber");function Vs(e){return typeof e=="string"&&nm.includes(e)?e:null}i(Vs,"asUrgency");function sm(e){if(!Object.prototype.hasOwnProperty.call(e,"urgency_level"))return false;let t=e.urgency_level;return t===null||Vs(t)!==null}i(sm,"urgencySlotProvided");function am(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t:String(t)):[]}i(am,"asStringList");function lm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(lm,"isPlainObject");function Us(e){return Array.isArray(e)?e.filter(lm):[]}i(Us,"asMapList");var um="0.5.9",eo="react-native",dm="2026-09-19",Wr="EVERFUR_API_BASE_URL";function tr(e,t){return Object.freeze({ok:false,failure:Object.freeze({reason:e,message:t})})}i(tr,"configFailure");function to(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(to,"checkPublishableKey");function Hs(e,t){let r=to(e?.publishableKey);if(r!==null)return Object.freeze({ok:false,failure:r});let n=e.publishableKey.trim(),o=cm(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:um,platform:t?.platform??eo,debug:e.debug===true})})}i(Hs,"tryResolveClientConfig");function cm(e){let t=e?.trim(),r=t&&t.length>0?t:vm(Wr);return r?hm(r):tr("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${Wr}. The SDK never ships a hardcoded host.`)}i(cm,"tryResolveApiBaseUrl");function Bs(e){return {"X-Everfur-SDK-Version":e.sdkVersion,"X-Everfur-SDK-Platform":e.platform,"X-Everfur-Contract":e.contractVersion}}i(Bs,"buildBaseHeaders");var pm=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function fm(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}i(fm,"hostOf");function mm(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}i(mm,"isPrintableHost");function ym(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:mm(t)}i(ym,"canEchoOrigin");function gm(e,t){return `${e}://${t}`}i(gm,"safeOrigin");function hm(e){let t=e.trim(),r=pm.exec(t);if(r===null||r[2]===void 0||r[2].length===0)return tr("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let n=(r[1]??"").toLowerCase(),o=fm(r[2]);if(o.length===0)return tr("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let s=ym(t,o)?`: ${gm(n,o)}`:"";if(n!=="https"){if(!(n==="http"&&bm(o)))return n==="http"?tr("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${s}`):tr("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(hm,"normalizeBaseUrl");function bm(e){let t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t==="::1"}i(bm,"isLoopbackHost");function vm(e){let r=globalThis.process?.env?.[e];return typeof r=="string"&&r.trim().length>0?r.trim():void 0}i(vm,"readEnv");var Cm=3e4,Gs="x-request-id";async function*zs(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(zs,"fetchByteSource");function Em(e){let t=new TextEncoder,r=Sm(),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=$s(d),p=Be(Oe(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"),Em(r.source,l)}i(vm,"eventSourceByteSource");async function*Em(e,t){try{yield*e;}finally{t();}}i(Em,"sourceWithCleanup");function Cm(){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(Cm,"createByteQueue");async function Rm(e,t){let r=t.fetchImpl??Ks(),n=qs(t.config.apiBaseUrl,e.path,e.query),o=$s(t.config,e.headers,"application/json",e.body!==void 0&&e.multipart===void 0),s=_m(bm),a=wm(s.signal,e.signal),l;try{l=await r(n,Ys({...e,signal:a},o));}catch(d){return E(ro(d))}finally{s.cancel();}let u=await Xs(l);return l.ok?L(u):E(Pm(l.status,u,Ws(l)))}i(Rm,"requestJson");function js(e){return {request:i(t=>Rm(t,e),"request"),stream:i((t,r)=>Sm(xm(t,r),e),"stream")}}i(js,"createHttpTransport");async function*Sm(e,t){let r=qs(t.config.apiBaseUrl,e.path,e.query),n=$s(t.config,e.headers,"text/event-stream",e.body!==void 0&&e.multipart===void 0);if(t.eventSourceFactory){let l=t.eventSourceFactory(r,Tm(e,n));yield*zr(vm(l),()=>km(l));return}let o=t.fetchImpl??Ks(),s;try{s=await o(r,Ys(e,n));}catch(l){yield Hs("",true,ea(l));return}let a=Ws(s);if(!s.ok){let l=await Xs(s),u=Qs(l)??Gs(s.status),d=Js(l)||Be(Oe(u));yield Hs(u,d,Zs(l),a);return}if(s.body){yield*zr(Vs(s.body),a);return}yield*zr(Vs(null),a);}i(Sm,"streamFrames");function Tm(e,t){return {method:e.method,headers:t,pollingInterval:0,...e.body!==void 0?{body:JSON.stringify(e.body)}:{}}}i(Tm,"buildEventSourceInit");function Pm(e,t,r){let n=Qs(t),o=n?Oe(n):vs(e),s=Zs(t);return D(o,{httpStatus:e,...Js(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...Bs(t)?{reasonCode:Bs(t)}:{},...s?{wireMessage:s}:{},...t!=null?{raw:t}:{}})}i(Pm,"errorFromResponse");function ro(e){return D("internalError",{retryable:true,wireMessage:ea(e)})}i(ro,"networkError");function Ws(e){let t=e.headers.get(zs);return typeof t=="string"&&t.length>0?t:null}i(Ws,"requestIdOf");function km(e){if(typeof e.getResponseHeader!="function")return null;let t;try{t=e.getResponseHeader(zs);}catch{return null}return typeof t=="string"&&t.length>0?t:null}i(km,"eventSourceRequestId");function Gs(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(Gs,"statusToWireCode");function Hs(e,t,r,n=null){return de({code:e,retryable:t,wireMessage:r,synthesized:true,lastEventId:null,serverRequestId:n})}i(Hs,"syntheticErrorFrame");function Ks(){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(Ks,"getGlobalFetch");function qs(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(qs,"buildUrl");function $s(e,t,r,n){let o={...Us(e),accept:r};return n&&(o["content-type"]="application/json"),t&&Object.assign(o,t),o}i($s,"mergeHeaders");function Ys(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(Ys,"buildInit");function xm(e,t){return e.signal?e:{...e,signal:t}}i(xm,"withSignal");function _m(e){let t=new AbortController,r=setTimeout(()=>t.abort(),e);return {signal:t.signal,cancel:i(()=>clearTimeout(r),"cancel")}}i(_m,"timeoutSignal");function wm(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(wm,"mergeAbortSignals");async function Xs(e){try{return await e.json()}catch{return null}}i(Xs,"safeJson");function Bs(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}i(Bs,"extractReasonCode");function Qs(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?r:null}i(Qs,"extractWireCode");function Zs(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}i(Zs,"extractWireMessage");function Js(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}i(Js,"extractRetryable");function ea(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(ea,"describeCause");var Im=3e4,Am=Yn*2,Om="idempotency-key",Fm=new Set(["POST","PUT","PATCH","DELETE"]),Mm=Object.freeze({onEvent(){}}),Lm=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function Dm(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}i(Dm,"seededIdempotencyKey");function xe(e){let t=e.observer??Mm,r=e.timers??Lm,n=e.rng??Math.random,o=e.sleep??((f,m)=>Xm(f,r,m)),s=e.maxAttempts??Zt,a=e.unaryTimeoutMs??Im,l=e.newIdempotencyKey??Um(),u=i(f=>{try{t.onEvent(f);}catch{}},"emit");async function d(f,m,y){let x=y?.maxAttempts,b=Math.max(1,x??s),C=y?.idempotent??Fm.has(m.method),_=y?.idempotencyKey===void 0?null:Dm(y.idempotencyKey),P=C?_??l():null,k=Nm(m,P),g=0;for(;;){let w=i(j=>Object.freeze({call:f,method:m.method,path:m.path,attempt:g,...P?{idempotencyKey:P}:{},...j}),"stamp");u(w({phase:"attempt"}));let O=$m(a,r),M=Ym(O.signal,m.signal),I;try{I=await Os({...k,signal:M.signal},e.auth);}catch(j){I=E(ro(j));}finally{M.dispose(),O.cancel();}if(I.ok)return u(w({phase:"settled",ok:true,reason:"ok"})),I;let v=I.error,T=Hm(v,g,{maxAttempts:b,rng:n,now:r.now(),aborted:m.signal?.aborted===true,...x!==void 0?{perCallMaxAttempts:x}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),V={ok:false,code:v.code,reason:T.reason,...v.httpStatus!==void 0?{httpStatus:v.httpStatus}:{},...v.requestId!==void 0?{requestId:v.requestId}:{}};if(!T.retry)return u(w({phase:"settled",...V})),E(v);if(u(w({phase:"retry",...V,delayMs:T.delayMs})),await o(T.delayMs,m.signal),m.signal?.aborted===true)return u(w({phase:"settled",...V,reason:"aborted"})),E(v);g+=1;}}i(d,"send");async function c(f){return Jt(f,await qm(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 de({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(xe,"createRequestFunnel");function Nm(e,t){let r={};for(let[n,o]of Object.entries(e.headers??{}))n.toLowerCase()!==Om&&(r[n]=o);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(Nm,"assembleHeaders");function Um(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(Um,"defaultIdempotencyKeyFactory");var Vm=10;function Hm(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let n=Bm(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(Vm,Math.floor(d)))},"policyCeiling"),l=r.perCallMaxAttempts??a()??r.maxAttempts;if(t+1>=l)return {retry:false,reason:"attempts-exhausted"};let u=zm(e,r.now);return u!==null?u>Am?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:o,delayMs:u}:{retry:true,reason:o,delayMs:Vr(t,r.rng)}}i(Hm,"decideRetry");function Bm(e){let t=e.code==="unknown"?Oe(Km(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(Bm,"throttleKind");function zm(e,t){let r=Wm(e.raw);if(r!==null){let o=r-t;return o>0?o:0}let n=jm(e.raw);return n===null?null:Math.round(n*1e3)}i(zm,"retryOverrideMs");function jm(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(jm,"findRetryAfterSeconds");function Wm(e){for(let t of no(e)){let r=t.resets_at,n=Gm(r);if(n!==null)return n}return null}i(Wm,"findResetsAt");function no(e){if(!ta(e))return [];let t=[e];for(let r of ["error","detail"]){let n=e[r];ta(n)&&t.push(n);}return t}i(no,"candidateScopes");function Gm(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(Gm,"parseInstantMs");function Km(e){for(let t of no(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i(Km,"rawWireCode");function ta(e){return typeof e=="object"&&e!==null}i(ta,"isRecord");async function qm(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(qm,"resolveDeviceAuth");function $m(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(n),"cancel")}}i($m,"boundedSignal");function Ym(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(Ym,"mergeSignals");function Xm(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(Xm,"delayAbortable");var Wr=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 ra(e){return E(D("validationFailed",{retryable:false,wireMessage:e}))}i(ra,"invalid");function oo(){return E(D("internalError",{retryable:false}))}i(oo,"malformed");function na(e){return typeof e!="string"||e.trim().length===0?D("validationFailed",{retryable:false,wireMessage:"pet_ref must not be blank"}):Re(e)?D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}):`/widget/v1/pets/${encodeURIComponent(e)}/cases`}i(na,"petPath");var ze=i(e=>typeof e=="string"?e:null,"str"),oa=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"count");function ia(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&&Wr.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:oa(t.checkin_ask_count),checkinAnswerCount:oa(t.checkin_answer_count)})}i(ia,"caseFromWire");function sa(e){return {async list(t,r){let n=na(t);if(typeof n!="string")return E(n);let o=await e.send("cases.list",{method:"GET",path:n,...r?.signal?{signal:r.signal}:{}});if(!o.ok)return E(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(ia);return a.every(l=>l!==null)?L(Object.freeze(a)):oo()},async checkin(t,r,n,o){let s=na(t);if(typeof s!="string")return E(s);if(typeof r!="string"||!io.test(r))return ra("case_id must be a UUID");if(!Wr.includes(n))return ra("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 E(a.error);let l=typeof a.value=="object"&&a.value!==null?a.value:{},u=ia(l.case);return u===null?oo():L(Object.freeze({case:u,ctaDeepLink:ze(l.cta_deep_link)}))}}}i(sa,"createCasesRepositoryOver");var aa=Object.freeze({async presignedPut(){return Promise.reject(new Error("UploadPort is unavailable; no presigned-upload adapter was injected"))}});var la=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function Kr(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(Kr,"delayAbortable");function qr(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(qr,"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?qr(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 Gr=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 rr(e){return Object.freeze({id:e.id,role:e.role,text:e.text,createdAt:e.createdAt})}i(rr,"stripPending");function ua(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(ua,"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 da(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(da,"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||Ur(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 de({code:Qm(e.code),retryable:e.retryable,wireMessage:e.wireMessage??null,synthesized:true,lastEventId:null,serverRequestId:e.requestId??null})}i(Fe,"synthErrorFrame");function Qm(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(Qm,"canonicalWireCode");function ca(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=tr(n.category)??tr(n.title)??"",s=Zm(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(ca,"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 tr(e){return typeof e=="string"?e:null}i(tr,"asStr");function Zm(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=tr(r.text)??tr(r.prompt)??tr(r.title);n!==null&&t.push(n);}return t}i(Zm,"asPromptTextList");function pa(){let e=0;return ()=>`m-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,8)}`}i(pa,"defaultIdFactory");function fa(){let e=0;return ()=>`chat-send-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(fa,"defaultIdempotencyFactory");var ya={setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")};async function*ga(e,t,r,n){let o=e[Symbol.asyncIterator](),s=ma(t.overallMs,n),a=ma(t.idleMs,n),l=ty(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 ey();return}if(d.tag==="idle"||d.tag==="overall"){yield Jm();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(ga,"withWatchdog");function Jm(){return de({code:"STREAM_TIMEOUT",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(Jm,"synthTimeoutFrame");function ey(){return de({code:"STREAM_INCOMPLETE",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(ey,"synthStreamErrorFrame");function ma(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(ma,"deadline");function ty(e){return new Promise(t=>{if(e.aborted){t();return}e.addEventListener("abort",()=>t(),{once:true});})}i(ty,"abortPromise");var ry="checkin",ny=/^\d{4}-\d{2}-\d{2}$/,$r="watching";function ha(e){return e.status!=null&&e.status!==$r}i(ha,"isCheckinSettled");function ba(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(ba,"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!==ry||n===void 0||o===void 0||!io.test(n)||!ny.test(o)?null:{caseId:n,dueDay:o}}i(mo,"parseCheckinOrigin");function va(e){return mo(e)?.caseId??null}i(va,"parseCheckinOriginRef");function yo(e,t){if(e?.limit!==void 0&&(!Number.isInteger(e.limit)||e.limit<1||e.limit>t))return E(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||Re(o))return E(D("validationFailed"));r.push(`${n}=${encodeURIComponent(o)}`);}return e?.limit!==void 0&&r.push(`limit=${e.limit}`),L(r.length?`?${r.join("&")}`:"")}i(yo,"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 or(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}i(or,"object");function Ea(e){return e==null||typeof e=="string"&&e.length>0&&!Re(e)}i(Ea,"cursor");function nr(){return E(D("internalError",{retryable:false}))}i(nr,"malformed");function Ca(e){let t=or(e);if(!t||!Array.isArray(t.conversations)||!Ea(t.next_cursor))return nr();let r=[];for(let n of t.conversations){let o=or(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 nr();let s=o.unread_message_count;if(!(s==null||Number.isInteger(s)&&s>=0))return nr();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(Ca,"mapConversationPage");function Ra(e){let t=or(e);if(!t||!Array.isArray(t.messages)||!Ea(t.next_cursor))return nr();let r=[],n=new Set;for(let o of t.messages){let s=or(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 nr();if(s.role!=="user"&&s.role!=="assistant"||n.has(s.message_id))continue;n.add(s.message_id);let a=typeof s.proactive_origin_ref=="string"?s.proactive_origin_ref:null,l=s.role==="assistant"?va(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:oy(s.urgency_level)}:{},...Array.isArray(s.citations)?{citations:iy(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(Ra,"mapMessagePage");function oy(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(oy,"normalizeUrgency");function iy(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=or(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(iy,"historyCitations");var go=Object.freeze(["helpful","neutral","not_helpful","wrong","outdated","dangerous","unclear"]),Mt=4e3;var Lt=4e3;function Sa(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(Sa,"validateImageKeys");function bo(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(bo,"validateMessageText");function Ta(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(Ta,"urgencyTier");async function*sr(e){yield e;}i(sr,"singleFrameStream");async function*Pa(){}i(Pa,"emptyStream");var sy=6e4,ay=18e4,ly=24,uy=512,dy=false;function ka(e){return new vo(e)}i(ka,"createChatController");var Eo=class Eo extends Gr{constructor(r){super(da({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??xe({auth:r.auth,...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),this.petRef=r.petRef??null,this.cases=sa(this.funnel),this.telemetry=r.telemetry??Br,this.errorPolicy=r.errorPolicy??Rs,this.timers=r.timers??ya,this.rng=r.rng??Math.random,this.newId=r.newId??pa(),this.makeIdempotencyKey=r.makeIdempotencyKey??fa(),this.budget={idleMs:r.budget?.idleMs??sy,overallMs:r.budget?.overallMs??ay};}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=bo(r)??Sa(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=bo(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):Pa()}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?rr(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=yo(r,100);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return E(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 E(U("accessDenied",false));if(!a.ok)return a;let l=Ca(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 E(U("accessDenied",false));let n=r?.conversationId??null;if(n!==null){let u=await this.resumeConversation(n);return u.ok?L(n):E(u.error)}let o=r?.petRef??this.petRef,s=await this.listConversations({...o===null?{}:{petRef:o},limit:1});if(!s.ok)return E(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):E(l.error)}async markRead(r){if(this.disposed)return E(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?E(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)):E(s.error)}async submitFeedback(r,n,o,s){if(this.disposed)return E(U("accessDenied",false));if(typeof r!="string"||r.trim().length===0||Re(r))return E(U("validationFailed",false,"feedback needs the server message id of an assistant reply"));if(!go.includes(n))return E(U("validationFailed",false,`feedback_type must be one of ${go.join(", ")}`));let a=typeof o=="string"?o.trim():"";if([...a].length>Mt)return E(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 E(U("accessDenied",false));if(!d.ok)return E(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 E(U("accessDenied",false));let s=o?.petRef??this.petRef;if(s===null)return E(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 E(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 E(U("validationFailed",false));let o=yo(n,200);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return E(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?E(U("accessDenied",false)):a.ok?Ra(a.value):a}async resumeConversation(r){if(this.disposed)return E(U("accessDenied",false));if(!ir(r))return E(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 E(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===$r).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||ba({askCount:p.checkinAskCount,answerCount:p.checkinAnswerCount}))?p.lastResponse:null;return Object.freeze({...d,checkin:Object.freeze({...c,status:m?$r: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 E(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 E(U("accessDenied",false));if(!o.ok)return E(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 E(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 E(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 E(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?E(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 E(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?E(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 E(s.error);let a=s.value?.conversation_id??s.value?.id;return typeof a!="string"||a.length===0?E(U("internalError",true)):L(a)}async getPrompts(r){let n=this.epoch;if(this.disposed)return E(U("accessDenied",false));let o=r?.petRef??null;if(o!==null&&Re(o))return E(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?E(U("accessDenied",false)):a.ok?L(ca(a.value)):E(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=qr(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=qr(o.signal,p.signal),m=null;try{let b;try{b=await this.funnel.authorize(this.buildSendRequest(r,c));}catch{let _=this.authRejected();yield*this.emitTerminal(r,_,Fe(_));return}if(o.signal.aborted||!this.alive(o.epoch))return;let C=this.funnel.stream("chat.send",b,f);for await(let _ of ga(C,this.budget,f,this.timers)){if(!this.alive(o.epoch))return;if(_.kind==="error"&&_.terminal){m=_;break}if(this.applyFrame(_,r),yield _,_.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 C=this.authRejected();yield*this.emitTerminal(r,C,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(Es(y)&&!a){a=!0,this.telemetry.track("chat.conv.recreate",{}),this.adoptConversation(null),r.conversationIdOverride=null,this.patch({reconnecting:!0});continue}let x=m.retryable&&Ur(y,!0);if(dy&&x&&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?rr(a):a);this.patch({status:"streaming",isStreaming:true,messages:[...s,uo(o,r,this.stamp())]});return}if(this.pendingDelta+=r,this.pendingDelta.length>=uy){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);},ly);}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?ua(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?rr(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=Ta(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?rr(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 vo=Eo;async function wa(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(k=>k.ok?L(o):k):r.primeConversation(n?{petRef:n}:void 0),f=r.getPrompts(n!==null?{petRef:n}:void 0),[m,y]=await Promise.all([p,f]),x=null;if(m.ok)x=m.value,s.push(m.value),r.getSnapshot().conversationId===null&&r.adoptConversation(m.value);else {let k=m.error;c=k,xa(k)?(l=true,d=k):(_a(k)&&(a=true),u=true);}let b=[];y.ok?b=y.value:C(y.error);function C(k){xa(k)?(l=true,d===null&&(d=k)):_a(k)&&(a=true);}i(C,"recordAuthSignals");let _=d!==null?d.displayMessage:null;return Object.freeze({conversationId:x,petRef:n,suggestedPrompts:b,error:_,warning:_===null&&x===null&&u?cy:null,cause:d??c,diagnostics:Object.freeze({candidateConversationIds:Object.freeze([...s]),sawForbidden:a,sawUnauthorized:l,sawConversationInitFailure:u})})}i(wa,"bootstrapChat");var cy="Chat is ready. Your first message will start the conversation.";function xa(e){return e.httpStatus===401||e.code==="authExpired"||e.code==="authRejected"}i(xa,"isUnauthorized");function _a(e){return e.httpStatus===403||e.code==="accessDenied"}i(_a,"isForbidden");var Co=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Ia(e){return e!==Co}i(Ia,"isUploadTransportAvailable");var py=Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var Yr=10*1024*1024,Xr=5,ar=120,fy="/widget/v1/uploads/initiate";function my(e){return typeof e=="string"&&py.includes(e.trim().toLowerCase())}i(my,"isAttachmentMime");function Ro(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(Ro,"sanitizeFilename");function So(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i(So,"formatBytes");var lr=i(e=>Object.freeze({ok:true,value:e}),"ok"),_e=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 yy(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(yy,"attachmentSize");function gy(e){let t=Ro(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!my(r))return _e(oe("unsupported_type",false,t));let n=yy(e);return n===null?_e(oe("unknown",false,t)):n>Yr?_e(oe("too_large",false,t,{sizeBytes:n})):lr(Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}i(gy,"validateAttachment");function hy(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)??Yr,s3_key:a,purpose:r(t.purpose)})}i(hy,"parsePolicy");function by(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(by,"initiateFailure");async function vy(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:fy,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return _e(by(n.error,t.filename));let o=hy(n.value);return o===null?_e(oe("server",false,t.filename)):lr(o)}i(vy,"initiateAttachmentUpload");async function Ey(e,t,r,n){let o=i(()=>n?.signal?.aborted===true,"cancelled");if(o())return _e(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()?_e(oe("cancelled",true,r.filename)):_e(oe("server",true,r.filename))}}i(Ey,"uploadAttachmentBytes");var Cy=2,Ry=3,Sy=Object.freeze([1e3,2e3,4e3]),Aa=0;function Ty(){return Aa+=1,`attachment-${Aa}`}i(Ty,"defaultNewId");function Oa(e){let t=Math.max(1,e.concurrency??Cy),r=Math.max(1,e.maxAttempts??Ry),n=e.backoffMs??Sy,o=Math.max(1,e.maxPerMessage??Xr),s=e.timers??la,a=e.newId??Ty,l=Ia(e.transport),u=new Map,d=[],c=[],p=new Set,f=new Set,m=Object.freeze({attachments:Object.freeze([])}),y=false,x=i(()=>{m=Object.freeze({attachments:Object.freeze(d.flatMap(g=>{let w=u.get(g);return w===void 0?[]:[w.state]}))});for(let g of f)g();},"publish"),b=i((g,w)=>{g.state=Object.freeze({...g.state,...w}),x();},"patch"),C=i(()=>{for(;!y&&p.size<t&&c.length>0;){let g=c.shift(),w=u.get(g);w!==void 0&&(p.add(g),_(w).finally(()=>{p.delete(g),C();}));}},"pump"),_=i(async g=>{let{attachment:w}=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 vy(e.funnel,w,{signal:O});if(y||O.aborted)return;let I;if(!M.ok)I=_e(M.error);else {let j=await Ey(e.transport,M.value,w,{signal:O,onProgress:i(W=>{!O.aborted&&g.state.status==="uploading"&&b(g,{progress:Py(W)});},"onProgress")});if(y||O.aborted)return;I=j.ok?lr(M.value.s3_key):_e(j.error);}if(I.ok){b(g,{status:"uploaded",s3Key:I.value,error:null,progress:1});return}let v=I.error,T=v.retryable&&g.attempts<r;if(b(g,{status:T?"uploading":"failed",error:v,progress:0}),!T)return;let V=n[Math.min(g.attempts-1,n.length-1)]??0;await Kr(V,O,s);}},"run"),P=i(g=>{c.push(g.state.id),C();},"enqueue"),k={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 w=gy(g);if(!w.ok)return w;if(y||d.length>=o)return _e(oe("too_many",false,w.value.filename));let O=a(),M={attachment:w.value,controller:new AbortController,attempts:0,state:Object.freeze({id:O,filename:w.value.filename,previewUri:g.uri,contentType:w.value.contentType,sizeBytes:w.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return u.set(O,M),d.push(O),x(),P(M),lr(M.state)},retry(g){let w=u.get(g);w===void 0||y||w.state.status!=="failed"||(w.controller=new AbortController,w.attempts=0,b(w,{status:"uploading",error:null,progress:0,s3Key:null}),P(w));},remove(g){let w=u.get(g);if(w===void 0)return;w.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),x();},clear(){for(let g of [...d])k.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 k}i(Oa,"createAttachmentQueue");function Py(e){return Number.isNaN(e)||e<0?0:e>1?1:e}i(Py,"clamp");var Fa=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(Fa,t)?Fa[t]:null}i(ur,"canonicalPetSpecies");var Ma=50,ky=128,To=120,La=120,xy=2e3,Da=120,_y=80,Va=new Set(["male","female","unknown"]),Ha=new Set(["day","month","year"]),Ba=new Set(["low","medium","high","athletic"]),za=new Set(["indoor","outdoor","both"]),ja=new Set(["mild","moderate","severe"]),wy=/^(\d{4})-(\d{2})-(\d{2})$/,Wa=[["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"]],Ga=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];Object.freeze([...Wa,...Ga].map(([e])=>e));function Iy(e){let t=wy.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(Iy,"isRealDate");var cr=i(e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,"oneOf"),Ay=i((e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,"boolean"),Zr=i((e,t)=>typeof t=="string"&&Iy(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(Re(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"),Oy={sex:cr(Va),spayedNeutered:Ay,birthDate:Zr,birthDatePrecision:cr(Ha),activityLevel:cr(Ba),indoorOutdoor:cr(za),foodBrand:Me(Da),foodType:Me(Da),microchipId:Me(_y)},Po=["ref","ref",false,Me(ky,{required:true,trimmed:true})],ko=["notes","notes",false,Me(xy,{trimmed:true})],Na=[Po,["name","name",true,Me(To,{required:true,trimmed:true})],["dose","dose",false,Me(La,{trimmed:true})],["frequency","frequency",false,Me(La,{trimmed:true})],["startDate","start_date",false,Zr],["endDate","end_date",false,Zr],ko],Fy={allergies:[Po,["allergen","allergen",true,Me(To,{required:true,trimmed:true})],["severity","severity",false,cr(ja)],ko],medications:Na,supplements:Na,conditions:[Po,["conditionName","condition_name",true,Me(To,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Zr],ko]};function My(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 Fy[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(My,"itemToWire");function Ly(e,t){if(!Array.isArray(t))return {error:`${e} must be an array (send [] to clear it)`};if(t.length>Ma)return {error:`${e} has ${t.length} items; the server accepts at most ${Ma}`};let r=[],n=new Set;for(let o=0;o<t.length;o+=1){let s=My(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(Ly,"listToWire");function Ka(e,t){let r=e,n={};for(let[a,l]of Wa){let u=r[a];if(u!==void 0){if(u!==null){let d=Oy[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 Ga){let u=r[a];if(u===void 0)continue;let d=Ly(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(Ka,"petHealthToWire");var ee=i(e=>typeof e=="string"?e:null,"str"),dr=i((e,t)=>typeof t=="string"&&e.has(t)?t:null,"pick"),Dy=i(e=>typeof e=="boolean"?e:null,"bool");function Qr(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(Qr,"itemsFromWire");function Ua(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(Ua,"medicationFromWire");function qa(e){let t=e.profile_version;return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:dr(Va,e.sex),spayedNeutered:Dy(e.spayed_neutered),birthDate:ee(e.birth_date),birthDatePrecision:dr(Ha,e.birth_date_precision),activityLevel:dr(Ba,e.activity_level),indoorOutdoor:dr(za,e.indoor_outdoor),foodBrand:ee(e.food_brand),foodType:ee(e.food_type),microchipId:ee(e.microchip_id),allergies:Qr(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(ja,r.severity),notes:ee(r.notes)})}),medications:Qr(e.medications,Ua),supplements:Qr(e.supplements,Ua),conditions:Qr(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(qa,"petHealthFromWire");var Xa=100,Qa=50,Za=100,Ja=50,el=500,Ny=128,Uy=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 Jr(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(Jr,"outOfRange");function $a(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(Re(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,Ny)];return t?.name!==void 0&&r.push(lt("name",t.name,Xa)),t?.species!==void 0&&r.push(lt("species",t.species,Qa)),t?.breed!==void 0&&r.push(lt("breed",t.breed,Za)),t?.ageYears!==void 0&&r.push(Jr("age_years",t.ageYears,Ja)),t?.weightKg!==void 0&&r.push(Jr("weight_kg",t.weightKg,el)),r.find(n=>n!==null)??null}i($a,"validate");function tl(e,t){let r=Ka(e,t);return "error"in r?{error:De(r.error)}:r}i(tl,"healthToWire");function Vy(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,Xa)],["species","species",s=>lt("species",s,Qa)],["breed","breed",s=>lt("breed",s,Za)],["ageYears","age_years",s=>Jr("age_years",s,Ja)],["weightKg","weight_kg",s=>Jr("weight_kg",s,el)]],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=tl(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(Vy,"patchToWire");function Hy(e){if(e==null)return {body:{}};let t=tl(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(Hy,"toWire");var Le=i(e=>typeof e=="string"?e:null,"str"),en=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"num");function Ya(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:en(r.age_years),weightKg:en(r.weight_kg)})}i(Ya,"fromWire");function rl(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:en(t.age_years),weightKg:en(t.weight_kg),updatedAt:Le(t.updated_at)})}i(rl,"widgetPetFromWire");function By(e){let t=rl(e);return t===null?null:Object.freeze({...t,...qa(e)})}i(By,"widgetPetProfileFromWire");function zy(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=rl(r);return n===null?[]:[n]}))}i(zy,"petListFromWire");function Je(e){return jy(xe({auth:e}),xe({auth:e,unaryTimeoutMs:Uy}))}i(Je,"createPetsRepository");function jy(e,t=e){let r=i((o,s)=>s?{...o,signal:s}:o,"withSignal"),n=i(o=>$a(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(zy(s.value)):E(s.error)},async registerPet(o,s,a){let l=$a(o,s);if(l!==null)return E(l);let u=Hy(s);if("error"in u)return E(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(Ya(p.value,o)):E(p.error)},async updatePet(o,s,a){let l=n(o);if(typeof l!="string")return E(l);let u=Vy(s);if("error"in u)return E(u.error);let d=await e.send("pets.updatePet",r({method:"PATCH",path:l,body:u.body},a?.signal));return d.ok?L(Ya(d.value,o)):E(d.error)},async getPetProfile(o,s){let a=n(o);if(typeof a!="string")return E(a);let l=await e.send("pets.getPetProfile",r({method:"GET",path:`${a}/profile`},s?.signal));if(!l.ok)return E(l.error);let u=By(l.value);return u===null?E(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 E(a);let l=await e.send("pets.deletePet",r({method:"DELETE",path:a},s?.signal));return l.ok?L(void 0):E(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):E(s.error)}}}i(jy,"createPetsRepositoryOver");var _o=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 Wy(e){return _o[e]}i(Wy,"requires");function nl(e,t){let r=Object.freeze({reason:t,level:e,recoverable:false}),n=[],o=new Set;for(let s of Object.keys(_o))for(let a of _o[s])o.has(a)||(o.add(a),n.push(Object.freeze({resource:a,granted:false,disabled:r})));return Object.freeze(n)}i(nl,"deniedDecisionsFor");function ol(e,t,r){let n=Wy(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 xo({name:e,enabled:false,isPending:true,limits:{}});let s=Gy(n,o);return n.filter(l=>o.get(l)?.granted!==true).length===0?xo({name:e,enabled:true,isPending:false,limits:s}):xo({name:e,enabled:false,isPending:false,limits:s,disabled:Ky(n,o)})}i(ol,"decideCapability");function Gy(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(Gy,"mergeLimits");function Ky(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:Ft("accessDenied"),level:"user_entitlement",recoverable:false})}i(Ky,"disabledFor");function xo(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(xo,"freezeDecision");function me(e){let t=ie(e);return t===null?null:$y(t)}i(me,"parseColor");function ie(e){if(typeof e=="number")return il(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return wo(t.slice(1));if(t.toLowerCase().startsWith("0x"))return wo(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return qy(t);if(/^[0-9a-fA-F]+$/.test(t)){let r=wo(t);if(r!==null)return r}return /^\d+$/.test(t)?il(Number.parseInt(t,10)):null}i(ie,"toRgba");function wo(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return {r:Io(t[0]),g:Io(t[1]),b:Io(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(wo,"fromHex");function qy(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=Ao(Number(n[0])),s=Ao(Number(n[1])),a=Ao(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(qy,"fromRgbFunc");function il(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(il,"argbIntToRgba");function ut(e,t){return Number.parseInt(e.slice(t,t+2),16)}i(ut,"byte");function Io(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}i(Io,"dup");function Ao(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}i(Ao,"clampByte");function $y(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($y,"normalizeRgba");function ct(e,t,r){return `#${Oo(e)}${Oo(t)}${Oo(r)}`.toUpperCase()}i(ct,"rgbToHex");function Oo(e){return e.toString(16).padStart(2,"0")}i(Oo,"hex2");var Yy="#111111",Dt="#FFFFFF",tn="#000000";function al(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 Lo(r,o)>=Lo(r,n)?Dt:Yy}i(al,"readableOn");function pr(e,t){let r=al(e);return ue(r,e)>=t?r:ue(Dt,e)>=ue(tn,e)?Dt:tn}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(tn)?Dt:tn}i(fr,"poleForGrounds");function dt(e){let t=Fo(e.r/255),r=Fo(e.g/255),n=Fo(e.b/255);return .2126*t+.7152*r+.0722*n}i(dt,"relativeLuminance");function Fo(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}i(Fo,"linearize");function Lo(e,t){let r=Math.max(e,t),n=Math.min(e,t);return (r+.05)/(n+.05)}i(Lo,"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:ll(r,o);return Lo(dt(s),dt(o))}i(ue,"contrastRatio");function ll(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(ll,"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:ll(r,{...n});return ct(o.r,o.g,o.b)}i(pt,"flattenOnto");function ul(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(ul,"withAlpha");var sl=.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/sl;d+=1){let c=d*sl,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 dl(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(dl,"rgbToHsl");function Do(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:Mo(c+l),g:Mo(p+l),b:Mo(f+l)}}i(Do,"hslToRgb");function Mo(e){return Math.min(255,Math.max(0,Math.floor(e*255+.5)))}i(Mo,"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 nn=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),pl={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},fl={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},cl={nano:8,small:9,micro:10,tiny:11,caption:12,bodyTight:13,body:14,subtitle:16,heading:18,verdict:24},Xy={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Qy={regular:"400",medium:"500",bold:"700"},Zy={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},No=0,ft="System",Ne="monospace",Jy=["content","heading","control","compact","badge"];function eg(e){let t={};for(let r of Jy)t[r]=e;return t}i(eg,"authoredTierSizes");function ml(){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:cl,tierSizes:eg(cl),lineHeight:Xy,weight:Qy,letterSpacing:Zy,scale:1,maxScale:No,scaleCaps:nn}}i(ml,"baseType");var yl={},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 rn(e){return `cubic-bezier(${e.join(", ")})`}i(rn,"cssCubicBezier");var gl={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:rn(mt.standard),emphasized:rn(mt.emphasized),exit:rn(mt.exit)},reducedMotion:false},tg={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FDFBF8",surfaceSubtle:"#EFE9E3",background:"#FFFFFF",borderRingCream:"#D8D2C8",chatGround:"#FFFFFF",composerFill:"#FDFBF8",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#111111",secondary:"#0E462E",muted:"#6E6660",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#B91C1C",errorRed:"#FF1B00",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(185,28,28,0.12)",badgeBgNeutral:"rgba(110,102,96,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",skeleton:"#EFE9E3",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},yt=je({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:tg,space:pl,radius:fl,type:ml(),motion:gl,slots:yl}),rg={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A938C",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"},on=je({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:rg,space:pl,radius:fl,type:ml(),motion:gl,slots:yl});var ng="#23272C",hl=4.5,og=.6,Uo=.9,ig=.02,sg="#FFFFFF",ag="#111111";function lg(e){return ue(e,ng)>=hl&&Math.max(ue(e,sg),ue(e,ag))>=hl}i(lg,"readsOnDark");function El(e){let t=ie(e);if(t===null)return null;let{h:r,s:n,l:o}=dl(t.r,t.g,t.b),s=Math.min(Math.max(o,og),Uo);for(let l=0;;l+=1){let u=s+l*ig;if(u>Uo)break;let d=Do({h:r,s:n,l:u}),c=ct(d.r,d.g,d.b);if(lg(c))return c}let a=Do({h:r,s:n,l:Uo});return ct(a.r,a.g,a.b)}i(El,"deriveDarkVariant");var ug=7,bl=.05,dg="#000000",cg="#FFFFFF";function pg(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/bl;l+=1){let u=l*bl,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(pg,"pushContrast");function fg(e,t){let r=[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill],n=r[0],o=vl(n);for(let s of r){let a=vl(s);(t?a>o:a<o)&&(n=s,o=a);}return n}i(fg,"hardestGround");function vl(e){let t=ie(e);return t===null?0:dt(t)}i(vl,"luminanceOf");function tt(e,t){return pt(e,t)??me(e)??t}i(tt,"solid");function Cl(e){let t=e.color,r=e.brightness==="dark",n=r?cg:dg,o=fg(t,r),s=i(l=>pg(l,o,n,ug),"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(Cl,"deriveHighContrast");var gt=Object.freeze(["composerInput","sendButton","userBubble","assistantBubble","recordCard","vetVisitButton","primaryButton","link"]),mg=Object.freeze(["backgroundColor","borderColor","borderRadius","textColor"]),we=4.5,yg=Object.freeze({});function gg(e){return gt.includes(e)}i(gg,"isSlotName");function hg(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(hg,"parseRadius");function Rl(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(!gg(n)||o===null||typeof o!="object")continue;let s=bg(o);s!==null&&(t[n]=s,r=true);}return r?Object.freeze(t):null}i(Rl,"parseThemeSlots");function sn(e,t,r){return e[t]!==void 0?e[t]:e[r]}i(sn,"pick");function bg(e){let t={},r=me(sn(e,"background_color","backgroundColor"));r!==null&&(t.backgroundColor=r);let n=me(sn(e,"border_color","borderColor"));n!==null&&(t.borderColor=n);let o=hg(sn(e,"border_radius","borderRadius"));o!==null&&(t.borderRadius=o);let s=me(sn(e,"text_color","textColor"));return s!==null&&(t.textColor=s),Object.keys(t).length===0?null:Object.freeze(t)}i(bg,"parseSlot");function Sl(e,t){return t===null||Object.keys(t).length===0?e??yg:e===null||Object.keys(e).length===0?t:Object.freeze({...e,...t})}i(Sl,"mergeThemeSlots");var Vo=3;function vg(e,t){return e===void 0?t:t.length===0?[e]:t.map(r=>pt(e,r)??r)}i(vg,"seatsOf");function Eg(e,t){let r=fr(e);return e.every(n=>ue(r,n)>=t)}i(Eg,"someInkReads");function Cg(e,t){let r=t[0];return r===void 0?null:pt(e,r)}i(Cg,"collapseUnsatisfiableFill");function Rg(e){let t=pr(e[0],we);return e.every(r=>ue(t,r)>=we)?t:fr(e)}i(Rg,"inkFor");function Tl(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=vg(a,l),d={...s},c=false;if(a!==void 0&&u.length>1&&!Eg(u,we)){let p=Cg(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)<we))&&(d.textColor=Rg(u),c=true);else if(p!==void 0){let f=et(p,u,fr(u),we);f!==p&&(d.textColor=f,c=true);}if(s.borderColor!==void 0){let f=et(s.borderColor,u,fr(u),Vo);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(Tl,"guardSlotContrast");var xl=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.",_l=Object.freeze([1,2]);function an(e){return Object.keys(e).every(t=>t==="schemaVersion"||(e[t]??null)===null)}i(an,"isEmptyBranding");function wl(e){let t=e?.schemaVersion??null;return t===null||_l.includes(t)}i(wl,"isKnownBrandingSchema");function Il(e){return new Set(["hide_powered_by",...e?.lockedFields??[]])}i(Il,"lockedFieldsOf");function Sg(e){return e==="hide_powered_by"||xl.includes(e)?true:e.startsWith(mr)&>.includes(e.slice(mr.length))}i(Sg,"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:xg($(t,"brightness","color_scheme","colorScheme")),fontFamily:ht($(t,"font_family","fontFamily")),fontUrl:ht($(t,"font_url","fontUrl")),fonts:Pl($(t,"fonts")),fontUrls:Pl($(t,"font_urls","fontUrls")),placeholder:ht($(t,"chat_placeholder","placeholder","chatPlaceholder")),hidePoweredBy:Tg($(t,"hide_powered_by","hidePoweredBy")),primaryColorDark:me($(t,"primary_color_dark","primaryColorDark")),accentColorDark:me($(t,"accent_color_dark","accentColorDark")),surfaceStyle:kl($(t,"surface_style","surfaceStyle"),Pg),radiusScale:kl($(t,"radius_scale","radiusScale"),kg),logoUrlDark:ht($(t,"logo_url_dark","logoUrlDark")),slots:Rl($(t,"slots")),accessibilityMaxFontScale:wg($(t,"accessibility_max_font_scale","accessibilityMaxFontScale")),lockedFields:Ag($(t,"locked_fields","lockedFields")),schemaVersion:Ig($(t,"schema_version","schemaVersion"))};return an(r)?null:Object.freeze(r)}i(We,"parseClientBranding");function Tg(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(Tg,"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 Pl(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(Pl,"parseFaceMap");var Pg=["white","cream","subtle"],kg=["sharp","default","round"];function kl(e,t){if(typeof e!="string")return null;let r=e.trim().toLowerCase();return t.includes(r)?r:null}i(kl,"parseEnum");function xg(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="light"||t==="dark"||t==="auto"?t:null}i(xg,"parseBrightness");function Al(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(Al,"parseNumber");var _g=1,Ol=3.1;function wg(e){let t=Al(e);return t===null?null:t<=0?0:Math.min(Ol,Math.max(_g,t))}i(wg,"parseMaxFontScale");function Ig(e){if(e==null)return null;let t=Al(e);return t!==null&&Number.isInteger(t)&&t>=1?t:0}i(Ig,"parseSchemaVersion");function Ho(e){let t=e.trim();return t.startsWith(mr)?t:t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}i(Ho,"toWireName");function Ag(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="string")continue;let n=Ho(r);Sg(n)&&!t.includes(n)&&t.push(n);}return t.length===0?null:Object.freeze(t)}i(Ag,"parseLockedFields");function Bo(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}i(Bo,"hardenHttpsUrl");function Fl(e,t){if(t===null||an(t))return e;let r=(t.brightness==="light"||t.brightness==="dark")&&t.brightness!==e.brightness?t.brightness==="dark"?on:yt:e,n=r.brightness==="dark"?on:yt,o=r.brightness==="dark",s=o?t.primaryColorDark??Ml(t.primaryColor):t.primaryColor,a=o?t.accentColorDark??Ml(t.accentColor):t.accentColor,l=s??r.color.primary,u=a??r.color.accent,d=s!==null&&Dg(t,l,n,o),c=d?n.color.primary:l,p=s!==null&&!d?ie(c):null,f=i(x=>Math.round(x+(255-x)*.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?Ng(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,...Lg(t.surfaceStyle??null,n),primary:c,accent:u,onPrimary:r.color.onPrimary,onAccent:r.color.onAccent},space:r.space,radius:Vg(t.radiusScale??null,r.radius,n),type:{...r.type,...Mg(r.type,t),maxScale:t.accessibilityMaxFontScale??r.type.maxScale},motion:r.motion,slots:Sl(r.slots,t.slots??null)};return je(y)}i(Fl,"withServerBranding");var Og={regular:["regular"],medium:["medium","regular"],bold:["bold","medium","regular"],mono:["mono"],monoMedium:["monoMedium","mono"],monoBold:["monoBold","monoMedium","mono"]},Fg=[["regular","medium","bold"],["mono","monoMedium","monoBold"]];function zo(e){return e==="mono"||e==="monoMedium"||e==="monoBold"}i(zo,"isMonoFace");function Mg(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=Og[l].map(p=>r[p]).find(p=>p!==void 0),d=zo(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 Fg)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(Mg,"mergeFaces");function Ml(e){return e===null?null:El(e)}i(Ml,"darkVariantOf");function Lg(e,t){if(e===null)return {};let r=t.color;return {chatGround:e==="white"?r.surface:e==="subtle"?r.surfaceSubtle:r.surfaceCream}}i(Lg,"surfaceOf");function Ll(e,t){return e==null?false:me(e)===me(t)}i(Ll,"sameColor");function Dg(e,t,r,n){return Ll(t,r.color.primary)?true:n&&(e.primaryColorDark??null)===null&&Ll(e.primaryColor,yt.color.primary)}i(Dg,"isCompiledPrimary");function Ng(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(Ng,"compiledBrandFamily");var Ug={sharp:.5,default:1,round:1.5};function Vg(e,t,r){if(e===null)return t;let n=Ug[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(Vg,"radiusOf");var Hg="Everfur",Bg=.5;function jo(e){let t=e?.branding??null,r=wl(t)?t:null,n=Kg(e?.clientOverride??null,Il(r)),o=e?.colorScheme==="dark"?"dark":"light",s=n?.brightness??r?.brightness??"light",u=Fl((s==="auto"?o:s)==="dark"?on:yt,Dl(r)),d=Fl(u,Dl(n));return oh(d,e)}i(jo,"resolveTheme");function zg(e,t,r){return jo({...r,branding:We(t),clientOverride:We(e)})}i(zg,"previewTheme");function jg(e){return e==="placeholder"?"chat_placeholder":Ho(e)}i(jg,"wireNameOf");var Wg={brightness:["color_scheme"],fontUrl:["font_family"],fonts:["font_family"],fontUrls:["font_url","font_family"],primaryColorDark:["primary_color"],accentColorDark:["accent_color"],logoUrlDark:["logo_url"]};function Gg(e,t){return t.has(jg(e))?true:(Wg[e]??[]).some(r=>t.has(r))}i(Gg,"isLocked");function Kg(e,t){if(e===null)return null;let r=false,n={...e};for(let a of Object.keys(e))(e[a]??null)!==null&&(Gg(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 an(s)?null:s}i(Kg,"withoutFields");function Dl(e){return e===null||e.brightness===null?e:Object.freeze({...e,brightness:null})}i(Dl,"withoutBrightness");function qg(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(qg,"scaledSizes");function $g(e){return e===void 0||!Number.isFinite(e)?1:Math.max(Bg,e)}i($g,"effectiveScale");var Nl=["content","heading","control","compact","badge"];function Yg(e){if(!(e>0))return nn;let t={};for(let r of Nl){let n=nn[r];t[r]=n===0?0:Math.min(n,e);}return t}i(Yg,"tierCaps");function Xg(e,t){return t>0?Math.min(e,t):e}i(Xg,"capped");function Qg(e,t,r,n){let o={};for(let s of Nl)o[s]=n?qg(e,Xg(t,r[s])):e;return o}i(Qg,"sizesByTier");function Zg(e){return e==="dark"?"#FFFFFF":"#000000"}i(Zg,"inkPole");function Jg(e){return [e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}i(Jg,"textGrounds");function eh(e){return [e.surface,e.surfaceCream,e.background,e.chatGround,e.composerFill]}i(eh,"controlGrounds");function Ul(e){return [e.chatGround,e.surface,e.surfaceCream]}i(Ul,"linkGrounds");function th(e){return {composerInput:[e.composerFill],sendButton:[e.composerFill],userBubble:[e.bubbleUser],assistantBubble:[e.chatGround,e.surfaceCream],recordCard:[e.surface],vetVisitButton:[e.primary],primaryButton:[e.brand],link:Ul(e)}}i(th,"slotGrounds");function rh(e,t){try{let r=e(t);return r===!0||r===!1?r:null}catch{return null}}i(rh,"registration");function nh(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&&rh(r,o[a])===false&&(o[a]=zo(a)?Ne:ft,s[a]=false),n!==null&&zo(a)&&o[a]===Ne&&(o[a]=n);return {family:o.regular,mono:o.mono,families:o,namedFaces:s}}i(nh,"platformFaces");function oh(e,t){let r=e.color.primary,n=e.color.accent,o=e.meta.displayName.trim().length===0?Hg:e.meta.displayName,s=Bo(e.meta.logoUrl),a={};for(let P of yr){let k=e.type.fontUrls[P];k!==void 0&&(a[P]=Bo(k));}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:No,p=$g(t?.textScale),f=Yg(c),m=Qg(e.type.size,p,f,t?.scaleTypeSizes===true),y=e.color,x=Zg(e.brightness),b=Jg(y),C={...y,primary:r,accent:n,onPrimary:pr(r,we),onAccent:pr(n,we),brandInk:et(y.brandInk,b,x,we),linkInk:et(e.slots.link?.textColor??n,Ul(y),x,we),text:{...y.text,secondary:et(y.text.secondary,b,x,we)},brandBorderStrong:et(y.brandBorderStrong,eh(y),x,Vo)},_={brightness:e.brightness,highContrast:false,meta:{displayName:o,logoUrl:s,placeholder:e.meta.placeholder,hidePoweredBy:e.meta.hidePoweredBy},color:C,space:e.space,radius:e.radius,type:{...e.type,...nh(e.type,t),fontUrl:l,fontUrls:a,size:m.content,tierSizes:m,scale:p,maxScale:c,scaleCaps:f},motion:d,slots:Tl(e.slots,th(C))};return t?.highContrast===true?Cl(je(_)):je(_)}i(oh,"finalize");var Vl="/widget/v1/entitlements",ih=304,sh=Object.freeze({kind:"notModified"});async function Bl(e,t={},r=xe({auth:e})){let n=await r.send("entitlements.fetch",lh(t));return n.ok?uh(n.value):n.error.httpStatus===ih?sh:{kind:"failed",error:n.error}}i(Bl,"fetchEntitlements");var ah=64;function lh(e){let t={};return Wo(e.cachedRevision)&&(t["if-none-match"]=`"${e.cachedRevision}"`),e.region&&e.region.length<=ah?{method:"GET",path:Vl,headers:t,query:{region:e.region}}:{method:"GET",path:Vl,headers:t}}i(lh,"buildRequest");function uh(e){if(e===null||typeof e!="object"||!Wo(e.revision))return Hl();let t=typeof e.region=="string"?e.region:"",r=Wo(e.ttl_seconds)?e.ttl_seconds:0;return Object.freeze({kind:"updated",revision:e.revision,region:t,ttlSeconds:r,decisions:ch(e.capabilities),branding:dh(e),livemode:e.livemode!==false})}i(uh,"parseUpdated");function dh(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(dh,"parseBranding");function ch(e){if(e===null||typeof e!="object")return Object.freeze([]);let t=[];for(let[r,n]of Object.entries(e))ph(n)&&t.push(Object.freeze({resource:r,granted:true}));return Object.freeze(t)}i(ch,"mapCapabilities");function ph(e){return typeof e=="object"&&e!==null&&e.enabled===true}i(ph,"isEnabled");function Hl(){return {kind:"failed",error:D("internalError",{retryable:true,wireMessage:"malformed entitlements response"})}}i(Hl,"malformed");function Wo(e){return typeof e=="number"&&Number.isFinite(e)}i(Wo,"isFiniteNumber");var fh=30;function zl(e){let t=e.scheduler??mh,r=e.resolve??Bl,n=Math.max(1,e.floorSeconds??fh),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(C=>{l||!a||(c=Math.max(n,C),u=t.set(()=>{u=null,b();},c*1e3));},"schedule"),y=null,x=i(async()=>{if(l)return null;let C=p;e.onFetch?.();let _=e.region?{cachedRevision:d,region:e.region}:{cachedRevision:d},P;try{P=await r(e.authFor(),_);}catch(k){return e.telemetry?.track("sdk.entitlements.poll_error",{reason:yh(k)}),!l&&C===p&&(e.onSettled?.(),m(s())),null}if(l||C!==p)return null;switch(P.kind){case "updated":d=P.revision,e.update(P.decisions,P.branding??null,P.livemode!==false),m(P.ttlSeconds);break;case "notModified":m(c);break;case "failed":e.telemetry?.track("sdk.entitlements.poll_failed",{code:P.error.code}),m(s());break;default:m(s());}return e.onSettled?.(),P},"tick"),b=i(()=>{let C=x().finally(()=>{y===C&&(y=null);});return y=C,C},"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(zl,"createEntitlementPoller");var mh={set(e,t){let r=setTimeout(e,t);return r.unref?.(),r},clear(e){clearTimeout(e);}};function yh(e){return e instanceof Error?e.message:"poll failed"}i(yh,"describe");var jl="everfur.notifications.device";var gh=3e3,Wl=Object.freeze([jl]);function Gl(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();},gh);u.then(p,p);})}i(Gl,"startBeforeLogoutHooks");function Kl(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(Kl,"graceAuth");async function ql(e,t){if(Wl.length===0)return;let r=await Promise.allSettled(Wl.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(ql,"sweepPerUserKv");function hh(){return Object.freeze([Object.freeze({resource:"chat.message.create",granted:true})])}i(hh,"compiledDefaultDecisions");function Go(e=hh){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(Go,"createEntitlementStore");function Ko(e){return D("validationFailed",{retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`})}i(Ko,"notConfiguredError");function $l(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 Ns(r,t===void 0?void 0:{platform:t})}i($l,"tryResolveClient");function Yl(e){return Object.freeze({track(t,r){try{e.track(t,r);}catch{}},trackExpectedFailure(t,r){try{e.trackExpectedFailure(t,r);}catch{}}})}i(Yl,"guardTelemetry");var bh=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 Xl(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. `+bh[r]);}i(Xl,"reportConfigFailure");function qo(e){return Object.freeze({request(){return Promise.resolve(E(Ko(e)))},stream(t,r){let n=de({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(qo,"refusingTransport");function Ql(){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(Ql,"createInMemoryKv");var Zl=Object.freeze({clearMemoryCache(){},clearDiskCache(){}});function tu(e,t){return new Yo(e,t)}i(tu,"createEverfurRuntime");var vh=6e4,Xo=class Xo{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?Yl(n.telemetry):Br;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=qo(s);else if(n.transport!==void 0)l=n.transport;else {let c=$l(n,r?.platform);c.ok?(u=c.config.apiBaseUrl,l=js({config:c.config,...r?.eventSourceFactory?{eventSourceFactory:r.eventSourceFactory}:{}})):(s=c.failure,l=qo(c.failure));}this.configFailure=s,this.publishableKey=s===null?o:"",this.transport=l,s!==null&&Xl(s,this.telemetry,r?.platform),this.errorPolicy=n.errorPolicy,this.camera=n.camera??Ss,this.upload=n.upload??aa,this.uploadTransport=n.uploadTransport??Co,this.imageCache=n.imageCache??Zl,this.kv=n.storage??Ql(),this.currentUser=t.user??null,this.identity=this.buildIdentity(t.user??null),this.activePet=t.activePet,this.store=s===null?Go():Go(()=>nl("sdk_config",Ft("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",$o(c),()=>this.buildChatController(c),Jl),"acquireChat"),releaseChat:i(c=>this.releaseInternal(c),"releaseChat"),peekChat:i(c=>this.entries.get(`${this.epoch}|chat|${$o(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=As(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-vh,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 zl({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=ka({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=wa(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 ql(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 Gl({leaving:t,identity:r,hooks:this.beforeLogoutHooks,telemetry:this.telemetry,graceAuth:i(()=>Kl({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?E(eu(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?eu("prepare"):n===null?null:Ko(n),s=this.identity,[a,l,u]=await Promise.all([o?E(o):s===null?L(void 0):s.currentToken().then(()=>L(void 0),()=>E(D("authRejected",{retryable:false}))),o?E(o):this.primeEntitlements(),t===null?void 0:o?E(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"?E(t.error):L(void 0):E(D("internalError",{retryable:true}))}async primeChat(t){let r={userRef:this.currentUser?.userRef??null,petRef:t,conversationId:null},n=this.acquireInternal("chat",$o(r),()=>this.buildChatController(r),Jl,true),o=await this.bootstraps.get(n);return o?.cause&&n.getSnapshot().conversationId===null&&(o=await this.runBootstrap(n,r)),o?.cause?E(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(Xo,"EverfurRuntimeImpl");var Yo=Xo;function $o(e){return `${e.userRef??""}|${e.petRef??""}|${e.conversationId??""}`}i($o,"chatScopeKey");function Jl(e){e.dispose();}i(Jl,"disposeChat");function eu(e){return D("validationFailed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}i(eu,"disposedError");var ru=Symbol.for("@everfur/sdk#EverfurContext@v1"),nu=globalThis,ln=nu[ru]??(nu[ru]=react.createContext(null));ln.displayName??="EverfurContext";function Y(){let e=react.useContext(ln);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 ou(){return Y().handle}i(ou,"useEverfur");var iu=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),su=globalThis,gr=su[iu]??(su[iu]=react.createContext(yt));gr.displayName??="EverfurThemeContext";function F(){return react.useContext(gr)}i(F,"useEverfurTheme");function un(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?kh(e.clientTheme):"",f=react.useMemo(()=>e.clientTheme?We(e.clientTheme):null,[p]),m=n.branding??null,y=react.useMemo(()=>jo({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(un,"EverfurThemeProviderCore");function kh(e){try{return JSON.stringify(e)}catch{return Object.keys(e).join("&")}}i(kh,"stableKey");function cu(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(T=>T+1,0),m=react.useRef(null),y=react.useRef(void 0),x=r?.userRef??null;y.current!==x&&(y.current!==void 0&&(m.current=null),y.current=x);let b=m.current!==null?m.current.user:r??null,C=react.useRef(null),_=react.useRef(void 0),P=n??null;_.current!==P&&(_.current!==void 0&&(C.current=null),_.current=P);let k=C.current!==null?C.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:tu({config:l.withDefaults?l.withDefaults(t):t,user:b,activePet:k,theme:o??null},{platform:l.platform,...l.eventSourceFactory?{eventSourceFactory:l.eventSourceFactory}:{}})});let g=d.current.runtime,w=react.useRef(null);react.useEffect(()=>{let T=d.current?.runtime;T===void 0||!T.isDisposed||w.current!==T&&(w.current=T,f());}),react.useEffect(()=>{let T=c.current;T!==null&&(c.current=null,T.dispose());});let O=b?.userRef??null;react.useLayoutEffect(()=>{g.setUser(b);},[g,O]),react.useLayoutEffect(()=>{g.setActivePet(k);},[g,k]),react.useEffect(()=>()=>g.dispose(),[g]),react.useEffect(()=>{s==="onMount"&&g.prepare(k===null?{}:{petRef:k});},[g,s,O,k]);let M=react.useMemo(()=>({setUser:i(T=>{m.current={user:T},g.setUser(T),f();},"setUser"),setActivePet:i(T=>{C.current={pet:T},g.setActivePet(T),f();},"setActivePet"),open:i(T=>g.open(T),"open"),prepare:i(T=>g.prepare(T),"prepare"),registerPet:i((T,V)=>g.registerPet(T,V),"registerPet"),updatePet:i((T,V)=>g.updatePet(T,V),"updatePet"),deletePet:i(T=>g.deletePet(T),"deletePet"),eraseUserData:i(()=>g.eraseUserData(),"eraseUserData"),logout:i(()=>{m.current={user:null};let T=g.logout();return f(),T},"logout")}),[g,f]),I=react.useMemo(()=>({runtime:g,handle:M,userRef:O,activePet:k,scopeEpoch:g.scopeEpoch}),[g,M,O,k,p]),v=react.createElement(un,{clientTheme:o??null,seams:l.theme,children:a});return react.createElement(ln.Provider,{value:I},l.wrap?l.wrap(v):v)}i(cu,"EverfurProviderCore");var wh=2;function Ih(e,t){let r=e?._xhr;if(!r||typeof r.getResponseHeader!="function"||typeof r.readyState=="number"&&r.readyState<wh)return null;let n;try{n=r.getResponseHeader(t);}catch{return null}return typeof n=="string"&&n.length>0?n:null}i(Ih,"readEventSourceResponseHeader");function pu(){let e=_h__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=>Ih(n,o),"getResponseHeader")})}}i(pu,"createRnEventSourceFactory");function Mh(){let e=reactNative.useColorScheme();return e==="dark"?"dark":e==="light"?"light":null}i(Mh,"useRnColorScheme");function Lh(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(Lh,"isThenable");function Dh(){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(Dh,"useRnReducedMotion");function yu(){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(yu,"readFontScale");function Nh(e){let t=reactNative.Dimensions?.addEventListener;if(typeof t!="function")return ()=>{};let r=t.call(reactNative.Dimensions,"change",e);return ()=>r?.remove?.()}i(Nh,"subscribeFontScale");function Uh(){return react.useSyncExternalStore(Nh,yu,yu)}i(Uh,"useRnTextScale");function vu(){try{let e=reactNative.Platform?.OS;return typeof e=="string"?e:null}catch{return null}}i(vu,"platformOS");function Vh(){return vu()==="android"?{query:"isHighTextContrastEnabled",event:"highTextContrastChanged"}:{query:"isDarkerSystemColorsEnabled",event:"darkerSystemColorsChanged"}}i(Vh,"contrastSignal");function Hh(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,{query:n,event:o}=Vh(),a=reactNative.AccessibilityInfo?.[n];if(typeof a!="function")return ()=>{};try{let d=a.call(reactNative.AccessibilityInfo);Lh(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(Hh,"useRnHighContrast");function Bh(){return vu()==="ios"?"Menlo":Ne}i(Bh,"rnPlatformMonoFamily");function zh(){return globalThis.__DEV__!==false}i(zh,"isDevelopment");var gu=new Set;function jh(e){if(!zh()||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(jh,"warnUnregisteredFace");function Wh(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||jh(e),o}i(Wh,"rnIsFontRegistered");var cn=Object.freeze({useColorScheme:Mh,useReducedMotion:Dh,useTextScale:Uh,useHighContrast:Hh,scaleTypeSizes:false,platformMonoFamily:Bh,isFontRegistered:Wh});function Kh(e){return react.createElement(reactNativeSafeAreaContext.SafeAreaProvider,null,e)}i(Kh,"wrapInSafeArea");var qh=Object.freeze({platform:"react-native",eventSourceFactory:pu(),wrap:Kh,theme:cn});function $h(e){return react.createElement(cu,{...e,seams:qh})}i($h,"EverfurProvider");function Nt(e){let{runtime:t}=Y(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return react.useMemo(()=>ol(e,n.decisions,{isPending:n.isPending}),[e,n])}i(Nt,"useCapability");function eb(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(eb,"tierMultiplier");function R({tier:e="content",...t}){let{type:r}=F(),n=eb(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 tb=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[tb[t]]}}i(S,"face");var Zo=class Zo 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(Zo,"HostRenderBoundary");var Qo=Zo;function nb({render:e}){return e()}i(nb,"RenderHost");function Et({render:e,fallback:t,resetKey:r}){return react.createElement(Qo,{fallback:t,resetKey:r,children:react.createElement(nb,{render:e})})}i(Et,"HostRender");var ob=48;function ib(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(ib,"selectView");function ti(e){let{capability:t,children:r,renderDisabled:n,renderPending:o,style:s}=e,a=Nt(t),l=react.useMemo(()=>ib(a),[a]);switch(l){case "enabled":return r;case "pending":return o?jsxRuntime.jsx(Et,{render:o,fallback:jsxRuntime.jsx(Tu,{capability:t,style:s})}):jsxRuntime.jsx(Tu,{capability:t,style:s});case "disabled":return n?jsxRuntime.jsx(Et,{render:()=>n(a),fallback:jsxRuntime.jsx(Pu,{decision:a,style:s}),resetKey:a}):jsxRuntime.jsx(Pu,{decision:a,style:s});default:return Ze(l)}}i(ti,"CapabilityGate");function Tu({capability:e,style:t}){let r=F(),n=react.useMemo(()=>ku(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(Tu,"PendingSkeleton");function Pu({decision:e,style:t}){let r=F(),n=react.useMemo(()=>ku(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(Pu,"OffState");function ku(e){let{color:t,space:r,radius:n,type:o}=e;return reactNative.StyleSheet.create({offstate:{minHeight:ob,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(ku,"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",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 ri=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"})]),xu=Object.freeze([Object.freeze({sentiment:"up",label:h.feedbackHelpful}),Object.freeze({sentiment:"neutral",label:h.feedbackNeutral}),Object.freeze({sentiment:"down",label:h.feedbackNotHelpful})]);function sb(e){switch(e){case "up":return "helpful";case "neutral":return "neutral";case "down":return "not_helpful"}}i(sb,"sentimentToFeedbackType");function _u(e,t){if(e==="down"&&t!==null){let r=ri.find(n=>n.key===t);if(r!==void 0)return r.feedbackType}return sb(e)}i(_u,"feedbackTypeFor");var db=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):cb,[c]),m=react.useCallback(()=>c?c.getSnapshot():db,[c]),y=react.useSyncExternalStore(f,m,m),x=react.useCallback((I,v)=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?oi(c,c.send(I,v?.imageS3Keys===void 0?{}:{imageS3Keys:v.imageS3Keys}),()=>p.current===c):Promise.resolve(ii()),[c]),b=react.useCallback(I=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?oi(c,c.askEverfur(I),()=>p.current===c):Promise.resolve(ii()),[c]),C=react.useCallback(()=>c&&p.current===c?oi(c,c.retryLast(),()=>p.current===c):Promise.resolve(ii()),[c]),_=react.useCallback(()=>{c&&p.current===c&&c.stop();},[c]),P=react.useCallback(()=>{c&&p.current===c&&c.newConversation();},[c]),[k,g]=react.useState({controller:null,byMessage:{}}),w=k.controller===c?k.byMessage:pb,O=react.useCallback(async(I,v,T,V)=>{if(!c||p.current!==c)return E(D("accessDenied"));let j=String(I),W=k.controller===c?k.byMessage[j]:void 0;if(W===v&&T==null)return g(he=>{let ke={...he.controller===c?he.byMessage:{}};return delete ke[j],{controller:c,byMessage:ke}}),L(Object.freeze({feedbackId:""}));g(he=>({controller:c,byMessage:{...he.controller===c?he.byMessage:{},[j]:v}}));let ne=await c.submitFeedback(I,_u(v,T??null),V??null);return p.current!==c?E(D("accessDenied")):(ne.ok||g(he=>{let ke={...he.controller===c?he.byMessage:{}};return W===void 0?delete ke[j]:ke[j]=W,{controller:c,byMessage:ke}}),ne)},[c,k]),M=react.useMemo(()=>{let I=i(async v=>{if(!c||p.current!==c)return E(D("accessDenied"));let T=await v(c);return p.current===c?T:E(D("accessDenied"))},"run");return {listConversations:i(v=>I(T=>T.listConversations({...s?{petRef:s}:{},...v})),"listConversations"),getMessages:i((v,T)=>I(V=>V.getMessages(v,T)),"getMessages"),resumeConversation:i(v=>I(T=>T.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,T)=>I(V=>V.answerCheckin(v,T)),"answerCheckin"),openCheckin:i(v=>I(T=>T.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:P,sentimentByMessage:w,feedback:O,send:x,askEverfur:b,retryLast:C,stop:_}),[y,s,x,b,C,_,M,P,w,O])}i(hr,"useEverfurChat");var cb=i(()=>{},"NOOP_UNSUBSCRIBE"),pb=Object.freeze({});async function oi(e,t,r){for await(let o of t);if(!r())return E(D("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?E(n.error):L(fb(n.messages))}i(oi,"driveToResult");function fb(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(fb,"lastAssistantResponseId");function ii(){return E(D("internalError",{retryable:true}))}i(ii,"notReadyError");function Ou(e){switch(e.code){case "too_large":return K(h.attachmentTooLarge,{max:So(Yr),filename:e.filename,size:So(e.sizeBytes??0)});case "too_many":return K(h.attachmentTooMany,{max:Xr});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(Ou,"attachmentErrorMessage");function Fu(e,t){return K(e>=t?h.attachmentsFull:h.addAttachment,{used:e,total:t})}i(Fu,"attachControlLabel");var hb=Object.freeze({attachments:Object.freeze([])});function pn(e={}){let{runtime:t,userRef:r,scopeEpoch:n}=Y(),o=e.maxPerMessage??Xr,s=react.useCallback(()=>{let{services:g}=t.registry;return Oa({funnel:xe({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,()=>hb),[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]),x=react.useCallback(g=>c.retry(g),[c]),b=react.useCallback(g=>c.remove(g),[c]),C=react.useCallback(()=>c.clear(),[c]),_=react.useCallback(()=>m(null),[m]),P=p.attachments.some(g=>g.status==="uploading"),k=p.attachments.some(g=>g.status==="failed");return react.useMemo(()=>({available:c.available,attachments:p.attachments,maxPerMessage:o,uploading:P,failed:k,blocked:P||k,s3Keys:p.attachments.flatMap(g=>g.status==="uploaded"&&g.s3Key!==null?[g.s3Key]:[]),rejected:f,add:y,retry:x,remove:b,clear:C,dismissRejected:_}),[c.available,p,o,P,k,f,y,x,b,C,_])}i(pn,"useChatAttachments");var Eb="pet_not_registered";function Du(e){return e!=null&&e.reasonCode===Eb}i(Du,"isPetNotRegistered");var Cb=Object.freeze({status:"idle",error:null,registered:null,retry:i(()=>{},"retry")});function Nu(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:ai(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 x=++c.current;d({key:f,status:"registering",error:null,registered:null}),a().registerPet(e,t).then(b=>{x===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?Cb: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(Nu,"useChatPetRegistration");function ai(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(ai).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)}:${ai(n)}`).join(",")}}`}i(ai,"stableKey");var li=Object.freeze({});function Vu(e){let[t,r]=react.useState(li),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===li?u:li);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(Vu,"useSentImages");var xb=500;function ui(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,xb):null}i(ui,"sanitizeSeedPrompt");function Bu(e,t,r){let n=ui(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(Bu,"useInitialAsk");function _b(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(_b,"isCoalesced");function zu(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"}:_b(e,r,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:r}}i(zu,"decideChatRefresh");function di(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(di,"reportHostFailure");function wb(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(wb,"isThenable");function q(e,...t){if(typeof e=="function")try{let r=e(...t);return wb(r)&&Promise.resolve(r).then(void 0,di),r}catch(r){di(r);return}}i(q,"callHost");var ju=new WeakMap;function Wu(e){if(typeof e!="function")return;let t=ju.get(e);if(t!==void 0)return t;let r=i((...n)=>{q(e,...n);},"guarded");return ju.set(e,r),r}i(Wu,"guardHost");function Ht(e,...t){let r;try{r=e(...t);}catch(n){return di(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 Ku(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=zu(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(Ku,"useChatLifecycle");function Ab(e){if(e===void 0)return null;let t=e.conversationId??"",r=e.petRef??"";return t===""&&r===""?null:`${String(t)}|${String(r)}`}i(Ab,"targetKey");function $u(e,t){let r=Ab(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($u,"useCheckinTarget");function Qu(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(Qu,"useChatDraft");function Zu(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(Zu,"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 mn(e){let t=e?.replace(/\s+/g," ").trim();return t||Z.untitled}i(mn,"conversationTitle");function ed(e){return `${e.unreadCount!==null&&e.unreadCount>0?Z.unreadPrefix:""}${Z.openConversation} ${mn(e.title)}`}i(ed,"openConversationLabel");function Ju(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}i(Ju,"normalizeForSearch");function Nb(e,t){let r=Ju(t);if(r.length===0)return e;let n=[[],[],[]];for(let o of e){let s=Ju(mn(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(Nb,"filterConversations");function fi(e){return {scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}i(fi,"fresh");function td(e){let[t,r]=react.useState(false),[n,o]=react.useState(""),s=e.listConversations,a=react.useRef(0),[l,u]=react.useState(()=>fi(s)),d=l.scope===s?l:fi(s);react.useEffect(()=>(a.current+=1,r(false),o(""),u(fi(s)),()=>{a.current+=1;}),[s]);let c=react.useCallback(async P=>{let k=++a.current,g=P!==void 0;u(O=>({...O,scope:s,loading:!g,loadingMore:g,error:null}));let w=await e.listConversations(P?{cursor:P}:void 0);if(k===a.current){if(!w.ok){u(O=>({...O,loading:false,loadingMore:false,error:w.error.displayMessage}));return}u(O=>{let M=P&&O.scope===s?O.rows:[],I=new Set(M.map(v=>v.id));return {scope:s,loading:false,loadingMore:false,error:null,rows:[...M,...w.value.conversations.filter(v=>!I.has(v.id))],cursor:w.value.nextCursor===P?null:w.value.nextCursor}});}},[e.listConversations,s]),p=i(()=>{r(true),o(""),c();},"show"),f=i(()=>{a.current+=1,r(false);},"close"),m=i(async P=>{let k=++a.current;u(w=>({...w,loading:true,error:null}));let g=await e.resumeConversation(P);k===a.current&&(u(w=>({...w,loading:false,error:g.ok?null:g.error.displayMessage})),g.ok&&r(false));},"resume"),y=i(async()=>{let P=a.current,k=await e.loadOlderMessages();P===a.current&&!k.ok&&u(g=>({...g,error:k.error.displayMessage}));},"earlier"),x=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"),C=react.useMemo(()=>Nb(d.rows,n),[d.rows,n]),_=n.trim().length>0;return {...d,open:t,show:p,close:f,load:c,resume:m,earlier:y,newConversation:x,loadMore:b,query:n,setQuery:o,searching:_,filtered:C,emptyKind:d.rows.length===0?"empty":"noMatch"}}i(td,"useHistoryPanel");var yn="#111111",gn="#FFFFFF",Hb=Object.freeze({emergency:Object.freeze({level:"emergency",label:"Vet care now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:yn,pillColor:gn,showsVetAction:true}),schedule_soon:Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:yn,pillColor:gn,showsVetAction:true}),home_care:Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:yn,pillColor:gn,showsVetAction:false}),general:Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:yn,pillColor:gn,showsVetAction:false})});function Bb(e){return `${e.messageId}:${e.level}:${e.reason??""}`}i(Bb,"urgencySignature");function zb(e){return K(h.urgencyGeneralReason,{petName:e?.trim()||h.emptyTitlePetFallback})}i(zb,"generalUrgencyReason");function od(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:jb(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:zb(t)}:null}return null}i(od,"latestUrgencySource");function jb(e){return typeof e=="string"&&e.trim().length>0?e:null}i(jb,"shownReason");function id(e){let t=e===null?null:Bb(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:Hb[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(id,"useUrgencySurface");function sd(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}i(sd,"selectView");function Wb(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}i(Wb,"needsNewConversation");function ad(e){if(e.messages.length===0)return null;let t=e.status==="error"?e.error:null;if(t!==null){let r=Wb(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(ad,"turnNotice");function ld(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}i(ld,"awaitingAssistant");function ud(e,t){let r={};return e!==void 0&&(r.petRef=e),t!==void 0&&(r.conversationId=t),r}i(ud,"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 pd(e){let t=F(),r=react.useMemo(()=>qb(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(pd,"ClinicalDisclaimer");function qb(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(qb,"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 ce(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}i(ce,"stroke");function fd({size:e,color:t,strokeWidth:r}){let n=ce(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(fd,"MenuGlyph");function md({size:e,color:t,strokeWidth:r,rotate:n}){let o=ce(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(md,"Cross");function yd(e){return jsxRuntime.jsx(md,{...e,rotate:"0deg"})}i(yd,"PlusGlyph");function Ct(e){return jsxRuntime.jsx(md,{...e,rotate:"45deg"})}i(Ct,"CloseGlyph");function nt({size:e,color:t,strokeWidth:r}){let n=ce(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 Xb={down:{rotate:"45deg",marginTop:-0.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-0.4}};function hn({size:e,color:t,strokeWidth:r,direction:n}){let o=ce(e,r),s=e*.46,a=Xb[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(hn,"ChevronGlyph");function gd({size:e,color:t,strokeWidth:r}){let n=ce(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(gd,"BookGlyph");function hd({size:e,color:t,strokeWidth:r}){let n=ce(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(hd,"ArrowUpRightGlyph");function bd({size:e,color:t,strokeWidth:r}){let n=ce(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(bd,"CopyGlyph");function bn({size:e,color:t,strokeWidth:r,active:n,rotate:o}){let s=ce(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(bn,"ThumbGlyph");function vd({size:e,color:t,strokeWidth:r}){let n=ce(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(vd,"InfoGlyph");function Ed({size:e,color:t,strokeWidth:r}){let n=ce(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(Ed,"UploadGlyph");function Cd({size:e,color:t,strokeWidth:r}){let n=ce(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(Cd,"PhotoGlyph");function Rd({size:e,color:t,strokeWidth:r}){let n=ce(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(Rd,"CameraGlyph");function Sd({size:e,color:t,strokeWidth:r}){let n=ce(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(Sd,"SearchGlyph");function Td({size:e,color:t,strokeWidth:r}){let n=ce(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(Td,"EditGlyph");function Pd({size:e,color:t,strokeWidth:r}){let n=ce(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(Pd,"MapPinGlyph");function kd({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(kd,"SendGlyph");function xd({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(xd,"StopGlyph");function vn({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(vn,"Ring");var vr=Object.freeze({standard:mt.standard,emphasized:mt.emphasized,exit:mt.exit,outQuad:Object.freeze([.25,.46,.45,.94])});var _d=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}),Qb=Object.freeze({..._d,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 wd(e){return e.motion.reducedMotion?Qb:_d}i(wd,"chatMotion");function En(e,t){return Math.max(0,t)*e.followUpStaggerMs}i(En,"followUpDelayMs");function Id(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(Id,"nextRevealLength");function X(){let e=F();return wd(e)}i(X,"useChatMotion");var nv=8;function Od(e,t,r){return ((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}i(Od,"bezierComponent");function ov(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}i(ov,"bezierSlope");function Cn(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<nv;l+=1){let u=ov(a,t,n);if(u===0)break;a-=(Od(a,t,n)-s)/u;}return Od(Math.min(1,Math.max(0,a)),r,o)}}i(Cn,"bezierEasing");var mi=Cn(vr.standard),iv=Cn(vr.outQuad);function bi(e){let t=react.useRef(null);return t.current===null&&(t.current=new reactNative.Animated.Value(e)),t.current}i(bi,"useAnimatedValue");function Rt(e,t={}){let r=t.risePx??0,n=t.delayMs??0,o=bi(e>0?0:1);return react.useEffect(()=>{if(e<=0)return;let s=reactNative.Animated.timing(o,{toValue:1,duration:e,easing:iv,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 vi({visible:e,inMs:t,outMs:r,style:n,children:o}){let[s,a]=react.useState(e),l=bi(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:mi,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:mi,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(vi,"FadePresence");var sv=12;function B({style:e,containerStyle:t,children:r,onPressIn:n,onPressOut:o,hitSlop:s,...a}){let l=X(),u=bi(1),d=react.useCallback(c=>{l.pressMs<=0||l.pressScale===1||reactNative.Animated.timing(u,{toValue:c,duration:l.pressMs,easing:mi,useNativeDriver:true}).start();},[u,l.pressMs,l.pressScale]);return jsxRuntime.jsx(reactNative.Pressable,{...a,hitSlop:s??sv,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 Ld(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=>Id(r,u,a.current.length));},r.revealTickMs);return ()=>clearInterval(l)},[n,r]),n?e.slice(0,Math.min(o,e.length)):e}i(Ld,"useRevealedText");var Fd=false;function av(e){e.layoutMs<=0||(Fd||(Fd=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(av,"animateLayout");function Er(e,t){let r=react.useRef(e);r.current!==e&&(r.current=e,av(t));}i(Er,"useAnimateLayoutOn");var Ei=36,mv=22,yv=12,gv=12,hv=16,bv="#000",vv="rgba(0,0,0,0.45)";function Dd({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:Rn.backdrop,onPress:r,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:Rn.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),jsxRuntime.jsx(reactNative.View,{pointerEvents:"box-none",style:[Rn.closeWrap,{top:o.top+gv}],children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.closePreview,hitSlop:yv,style:Rn.closeButton,onPress:r,children:jsxRuntime.jsx(Ct,{size:mv,color:n.color.surface,strokeWidth:2})})})]})}i(Dd,"AttachmentImageLightbox");var Rn=reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:bv,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:hv},closeButton:{width:Ei,height:Ei,borderRadius:Ei/2,backgroundColor:vv,alignItems:"center",justifyContent:"center"}});var Sn=12,Tv=80,Ci=44,Nd=22,Pv=.14,kv=18,xv=8,Ud=Object.freeze({photo:h.attachmentPhoto,camera:h.attachmentCamera});function Vd({sources:e,full:t,onPick:r,onClose:n}){let o=F(),s=react.useMemo(()=>_v(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:Ud[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(Cd,{size:Nd,color:o.color.brandInk,strokeWidth:1.5}):jsxRuntime.jsx(Rd,{size:Nd,color:o.color.brandInk,strokeWidth:1.5})}),jsxRuntime.jsx(R,{tier:"control",style:s.tileLabel,children:Ud[a]})]},a))}),jsxRuntime.jsx(reactNative.View,{style:s.tail}),jsxRuntime.jsx(reactNative.View,{style:s.tailFill})]})]})}i(Vd,"AttachmentPickerPopover");function _v(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:Pv,shadowRadius:kv,shadowOffset:{width:0,height:xv},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:Tv,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:Ci,height:Ci,borderRadius:Ci/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:-Sn/2,width:Sn,height:Sn,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:Sn+4,height:2,backgroundColor:t.surfaceCream}})}i(_v,"makeStyles");var Se=Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var Bd=56,zd=12,Av=14,Ov=10,Fv=.45,Mv="rgba(7,193,104,0.55)",Lv="rgba(185,28,28,0.55)",Dv=200,Nv=300,Xd=20,Si=22,Uv=12,Vv="rgba(0,0,0,0.78)",jd=220,Wd=100,Gd="rgba(255,255,255,0.15)";function Qd({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:o,onPreview:s}){let a=F(),l=react.useMemo(()=>Jd(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(Hv,{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:Ou(t)}):null]})}i(Qd,"AttachmentStrip");function Hv({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(Bv,{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(Ct,{size:Xd,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(Ct,{size:Uv,color:s.color.surface,strokeWidth:1.5})})]})}i(Hv,"PreviewCard");function Bv({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:Dv,useNativeDriver:true}),reactNative.Animated.delay(n.uploadFlashMs),reactNative.Animated.timing(s,{toValue:0,duration:Nv,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:Xd,color:r.color.surface,strokeWidth:2})})}i(Bv,"SuccessFlash");function Zd({images:e,onPreview:t}){let r=F(),n=react.useMemo(()=>Jd(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(Zd,"SentImages");function Jd(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:Bd,height:Bd,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:zd,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...Se,alignItems:"center",justifyContent:"center",backgroundColor:ul(e.color.brandInk,Fv)??e.color.brandSofter},successOverlay:{...Se,alignItems:"center",justifyContent:"center",backgroundColor:Mv},failedOverlay:{...Se,borderRadius:zd,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:Lv},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:Si,height:Si,borderRadius:Si/2,backgroundColor:Vv,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:jd,height:jd,borderRadius:Av,backgroundColor:Gd},gridImage:{width:Wd,height:Wd,borderRadius:Ov,backgroundColor:Gd}})}i(Jd,"makeStyles");var zv="chat attachment upload: the file handle has no uri",jv="chat attachment upload failed";function Wv(e){return {uri:e.uri,name:Ro(e.name),type:e.mimeType}}i(Wv,"filePartOf");function ec(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(zv));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(jv)),"failed");return o?.aborted===true?a():Hr({url:t.upload_url,fields:t.upload_fields,file:Wv(r),signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(ec,"createRnChatAttachmentTransport");function Tn(){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(Tn,"useEverfurPets");function tc(e,t){if(t!==null){let r=e.find(n=>n.petRef===t);if(r!==void 0)return r}return e[0]??null}i(tc,"headerPetOf");function pe(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(pe,"slotBox");function xi(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}i(xi,"ownGroundSlot");function Ie(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(Ie,"slotText");var rc=Object.freeze({visitButton:"Talk to a vet"});var nc=Symbol.for("@everfur/sdk/televet");function Ke(){let e=globalThis,t=e[nc];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[nc]=r,r}i(Ke,"televetGlobal");function Pn(e){let t=Ke();t.snapshot=Object.freeze({...t.snapshot,...e});for(let r of [...t.listeners])try{r();}catch{}}i(Pn,"publish");function oc(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(oc,"callTelevetPresenter");function ic(e){let t=Ke();return t.listeners.add(e),()=>{t.listeners.delete(e);}}i(ic,"subscribeTelevetExperience");function _i(){return Ke().snapshot}i(_i,"televetExperienceSnapshot");function Yv(){return Ke().hosts.length>0}i(Yv,"hasTelevetHost");function sc(e){if(!Yv())return false;let t=Object.freeze({...e});return Pn({request:t,serial:Ke().snapshot.serial+1}),true}i(sc,"presentTelevetExperience");function wi(){Ke().snapshot.request!==null&&Pn({request:null});}i(wi,"dismissTelevetExperience");function ac(){let e=Ke(),t=e.nextHost;return e.nextHost+=1,e.hosts=[...e.hosts,t],Pn({activeHost:e.hosts[0]??null}),t}i(ac,"claimTelevetHost");function lc(e){let t=Ke();t.hosts=t.hosts.filter(n=>n!==e);let r=t.hosts[0]??null;Pn(r===null?{activeHost:r,request:null}:{activeHost:r});}i(lc,"releaseTelevetHost");var uc=false;function kn(e,t){return t!==void 0?(q(t,e),"onStartInApp"):oc(e)==="presented"?"presenter":sc(e)?"experience":(uc||(uc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}i(kn,"openVetVisitInApp");function pc(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(pc,"memoizeTelevetLoader");function fc(e){let[t,r]=react.useState(null);react.useEffect(()=>{let d=ac();return r(d),()=>{lc(d);}},[]);let n=react.useSyncExternalStore(ic,_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),wi());}),()=>{d=false;}},[u,e]),s===null||a===null?null:{module:a,request:s,serial:n.serial,dismiss:wi}}i(fc,"useTelevetExperienceHost");var Qv=pc(()=>import('@everfur/sdk/televet/booking'));function Rr(){let e=fc(Qv);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 Ii=Object.freeze(["visit","join","summary","messages"]);function Ai(e){return typeof e=="string"&&Ii.includes(e)}i(Ai,"isVetVisitIntent");var Jv="/widget/v1/televet/handoffs",eE="/widget/v1/televet/availability",tE="/widget/v1/televet/chat-entry",rE=/^[a-z0-9][a-z0-9_-]{0,39}$/,nE=/^[A-Za-z0-9_-]{22}$/;var mc=32,yc=128,gc=64;function Fi(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(Fi,"vetVisitErrorReasonOf");function hc(e){return E(D("validationFailed",{retryable:false,wireMessage:e}))}i(hc,"invalid");function Oi(e){return E(D("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}i(Oi,"unusable");function oE(e,t){let r={};e!==void 0&&(r.pet_ref=e);let n=t?.returnTo;if(n!=null){if(typeof n!="string"||!rE.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>gc)return {ok:false,message:`visitRef must be 1..${gc} characters`};r.visit_ref=u;}if(a!=null){if(!l)return {ok:false,message:"intent needs the visitRef it opens"};if(!Ai(a))return {ok:false,message:`intent must be one of ${Ii.join(", ")}`};r.intent=a;}return {ok:true,body:r}}i(oE,"handoffBody");function iE(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!Ai(r)?null:Object.freeze({visitRef:t,intent:r})}i(iE,"parseVisitEcho");function vc(e){let t=e.funnel??xe({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=i(o=>(bc(r,"televet.visit.handoff_failed",{reason:Fi(o)}),E(o)),"failed");return {async createHandoff(o,s){let a;if(o!=null){let b=typeof o=="string"?[...o].length:0;if(b<1||b>yc)return n(D("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${yc} characters`}));a=o;}let l=oE(a,s);if(!l.ok){let b=hc(l.message);return b.ok?b:n(b.error)}let u=l.body,d=await t.send("televet.visit.handoff",{method:"POST",path:Jv,body:u},{idempotent:false,maxAttempts:1});if(!d.ok)return n(d.error);let c=sE(d.value),p=u.return_to!==void 0,f=p?d.value?.flow_id:void 0;if(p&&(typeof f!="string"||!nE.test(f))){let b=Oi("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?iE(d.value?.visit):null;if(m&&y===null){let b=Oi("the handoff response did not confirm the visit it opens");return b.ok?b:n(b.error)}let x=c===null?null:Object.freeze({...c,...p?{flowId:f}:{},...y!==null?{visit:y}:{}});return x===null?n(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(bc(r,"televet.visit.handoff_created",{pet_scoped:u.pet_ref!==void 0}),L(x))},async checkAvailability(o){if(typeof o!="string"||o.length>mc)return hc(`state must be at most ${mc} characters`);let s=await t.send("televet.visit.availability",{method:"POST",path:eE,body:{state:o}},{idempotent:false,maxAttempts:1});if(!s.ok)return E(s.error);let a=s.value?.available;return typeof a!="boolean"?Oi("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:tE},{maxAttempts:1});return o.ok&&o.value?.open===!0}catch{return false}}}}i(vc,"createVetVisitController");function sE(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||!dE(t)?null:Object.freeze({url:t,expiresAt:r})}i(sE,"parseHandoff");var aE=new Set(["localhost","127.0.0.1","[::1]"]),lE=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,uE=/[\s\u0000-\u001f\u007f]/;function dE(e){if(uE.test(e))return false;let t=lE.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"&&aE.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(dE,"isOpenableVisitUrl");function bc(e,t,r){if(e)try{e.track(t,r);}catch{}}i(bc,"safeTrack");var Mi=Object.freeze({status:"idle",error:null,errorReason:null});function pE(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(pE,"usePreflight");var fE=Object.freeze({status:"opening",error:null,errorReason:null});function Rc(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:T}=r.registry;return vc({auth:T.authFor(n),telemetry:T.telemetry,...T.errorPolicy?{errorPolicy:T.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=pE(f,a,{usState:l,chat:u,scope:m}),x=a&&(y===null||y.open)&&(!u||d!==null),b=t.returnTo??null,[C,_]=react.useState(Mi),P=react.useRef(null),k=react.useRef({runtime:r,userRef:n,scopeEpoch:o});k.current={runtime:r,userRef:n,scopeEpoch:o};let g=react.useRef(p);g.current=p;let w=react.useRef(x);w.current=x;let O=react.useCallback((T,V)=>{if(P.current)return P.current;let j=i((fe,Qe)=>(_({status:fe==="cancelled"?"idle":"error",error:Qe,errorReason:fe==="cancelled"?null:fe}),Object.freeze({opened:false,reason:fe,error:Qe})),"fail");if(!w.current)return Promise.resolve(j("unavailable",null));let W=e.prepare();if(!W.ok)return Promise.resolve(j(W.reason,null));let ne=k.current,he=g.current;_(fE);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}:{}},Ir=Object.keys(Qe).length===0?void 0:Qe,Ar=T===void 0?d:T;try{fe=await(Ir===void 0?he.createHandoff(Ar):he.createHandoff(Ar,Ir));}catch{return e.abandon(W.value),j("unknown",null)}let At=k.current;if(At.runtime!==ne.runtime||At.userRef!==ne.userRef||At.scopeEpoch!==ne.scopeEpoch)return e.abandon(W.value),j("cancelled",null);if(!fe.ok)return e.abandon(W.value),j(Fi(fe.error),fe.error);let Yt=await e.finish(W.value,fe.value);return Yt!==null?j(Yt,null):(_(Mi),Object.freeze(fe.value.flowId===void 0?{opened:true}:{opened:true,flowId:fe.value.flowId}))})().finally(()=>{P.current===st&&(P.current=null);});return P.current=st,st},[e,d,b,u]),M=react.useCallback((T,V)=>{if(!w.current)return _({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}));let j=T===void 0?d:T,W={...j!==null?{petRef:j}:{},...l!==null?{usState:l}:{},...V!==null?{visitRef:V.visitRef,intent:V.intent}:{}};return kn(W)===null?(_({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}))):(_(Mi),Promise.resolve(Object.freeze({opened:true})))},[d,l]),I=react.useCallback(T=>c?O(T,null):M(T,null),[c,O,M]),v=react.useCallback((T,V)=>c?O(void 0,{visitRef:T,intent:V??null}):M(void 0,{visitRef:T,intent:V??null}),[c,O,M]);return {available:x,isPending:s.isPending||(y?.pending??false),status:C.status,error:C.error,errorReason:C.errorReason,open:I,openVisit:v}}i(Rc,"useVetVisitWith");var gE=i(e=>reactNative.Linking.openURL(e),"defaultOpenUrl");function _n(e={}){let{openUrl:t,...r}=e,n=react.useMemo(()=>{let o=t??gE;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 Rc(n,r)}i(_n,"useVetVisit");var Sc=44,CE=.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:x}=e,b=x==="redirect",C=_n({...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"}),_=F(),P=react.useMemo(()=>RE(_),[_]),k=react.useRef(false);if(!C.available)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[null,jsxRuntime.jsx(Rr,{})]});let g=C.status==="opening",w=r??rc.visitButton;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.Pressable,{onPress:i(()=>{if(!(g||k.current)){if(!b){let M={...t!==void 0?{petRef:t}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:m??null}:{}};kn(M,y)===null&&q(s,"unavailable",null);return}k.current=true,(f==null?C.open():C.openVisit(f,m??null)).then(M=>{M.opened?q(o,M.flowId??null):M.reason!=="cancelled"&&q(s,M.reason,M.error);}).finally(()=>{k.current=false;});}},"onPress"),accessibilityRole:"button",accessibilityLabel:w,accessibilityState:{busy:g,disabled:g},style:[P.button,g?P.busy:null,a],children:jsxRuntime.jsx(R,{style:[P.label,l],children:w})}),jsxRuntime.jsx(Rr,{})]})}i(jt,"VetVisitButton");function RE(e){let{color:t,space:r,radius:n,type:o,slots:s}=e;return reactNative.StyleSheet.create({button:{minHeight:Sc,minWidth:Sc,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...pe(s.vetVisitButton)},busy:{opacity:CE},label:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug,...Ie(s.vetVisitButton)}})}i(RE,"makeStyles");function Li(e){return ur(e)==="cat"?"cat":"dog"}i(Li,"speciesOf");function Di(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}i(Di,"petAgeYears");function xc(e){let t=Di(e.ageYears),r=Li(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return `${r} \xB7 ${n}`}i(xc,"formatPetMeta");var kc=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 SE(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return kc[t%kc.length]}i(SE,"pickInitialsPalette");function Ni(e){let t=(e??"").trim();return (Array.from(t)[0]??"?").toUpperCase()}i(Ni,"getInitial");function _c(e){return {...SE(e.petRef),initial:Ni(e.name)}}i(_c,"petInitials");function xE(e){return Math.max(12,Math.round(e*.42))}i(xE,"letterSize");function Tr({pet:e,size:t,ringStroke:r}){let n=F(),o=react.useMemo(()=>_E(n),[n]),s=t-r*2,a=e===null?null:_c(e),l=xE(s);return jsxRuntime.jsx(vn,{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?Ni(null):a.initial})})})}i(Tr,"PetDisc");function _E(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(_E,"makeStyles");var Vi=48,Ac=2,ME=320,LE="80%",DE="rgba(17,17,17,0.45)",NE=18,wc=22,UE=12,Ic=.4,VE=44;function Hi(e){return e?.name?.trim()||h.yourPet}i(Hi,"petDisplayName");function Oc({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:o=null,onClose:s}){let a=F(),l=react.useMemo(()=>HE(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:Se,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=Hi(u),p=xc(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:Vi,ringStroke:Ac}),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:NE,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(Oc,"PetSwitcherSheet");function HE(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:DE},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:wc,borderTopRightRadius:wc,gap:14,maxHeight:LE},title:{...S(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk},list:{maxHeight:ME,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:VE,paddingHorizontal:8},addDisc:{width:Vi,height:Vi,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:Ac,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:Ic},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:UE,backgroundColor:t.brandSoft},closeText:{...S(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:Ic}})}i(HE,"makeStyles");var jE=44,In=36,WE=22,Bi=9,GE=1.5,Mc=6,Tt=35,An=1.75,zi=12.4,KE=.5,qE=8,$E=28,YE=160;function Wi(e,t){return tc(e,t)}i(Wi,"headerPet");function Dc({pets:e,petRef:t,historyUnread:r,onOpenHistory:n,onPetChange:o,onAddPet:s,vet:a}){let l=F(),u=react.useMemo(()=>QE(l),[l]),[d,c]=react.useState(false),p=Wi(e.pets,t),f=e.pets.length>=2,m=t??p?.petRef??null,y=Hi(p),x=i(C=>{c(false),e.setActivePet(C),q(o,C);},"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(fd,{size:WE,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(XE,{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:An}),jsxRuntime.jsx(reactNative.View,{style:u.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:jsxRuntime.jsx(yd,{size:qE,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(vn,{size:Tt,strokeWidth:An,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:An})})}),jsxRuntime.jsx(Oc,{visible:d,pets:e.pets,activePetRef:p?.petRef??null,onSelect:x,onAddPet:b,onClose:()=>c(false)})]})}i(Dc,"ChatHeader");function XE({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(XE,"BrandLogo");function QE(e){let t=e.color,r=Tt-An*2;return reactNative.StyleSheet.create({vetEntry:{minHeight:jE,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:In/2},iconButton:{width:In,height:In,borderRadius:In/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:Mc,right:Mc,width:Bi,height:Bi,borderRadius:Bi,backgroundColor:t.danger,borderWidth:GE,borderColor:t.surface},center:{...Se,alignItems:"center",justifyContent:"center"},logoBar:{alignItems:"center",paddingHorizontal:e.space.lg},logo:{height:$E,width:YE},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:zi,height:zi,borderRadius:zi/2,borderWidth:KE,borderColor:t.success,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}i(QE,"makeStyles");var Vc=44,rC="rgba(17,17,17,0.55)",Hc=26,nC=36,Bc=4,Gi=20,Ki=38,oC=18,iC=12;function zc({visible:e,onSubmit:t,onSkip:r}){let n=F(),o=react.useMemo(()=>sC(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"),x=i(async()=>{if(d)return;c(true),f(false);let C=l.trim();await t(s,C.length>0?C: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(bn,{size:oC,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:ri.map(C=>{let _=s===C.key;return jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:C.label,accessibilityState:{selected:_},style:[o.option,_?o.optionSelected:null],onPress:()=>a(P=>P===C.key?null:C.key),children:[jsxRuntime.jsx(R,{style:[o.optionLabel,_?o.optionLabelSelected:null],children:C.label}),jsxRuntime.jsx(reactNative.View,{style:[o.radio,_?o.radioSelected:null],children:_?jsxRuntime.jsx(nt,{size:iC,color:n.color.surface,strokeWidth:2}):null})]},C.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:()=>{x();},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(zc,"FeedbackReasons");function sC(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:{...Se,backgroundColor:rC},sheet:{backgroundColor:t.surface,borderTopLeftRadius:Hc,borderTopRightRadius:Hc,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14},handle:{alignSelf:"center",width:nC,height:Bc,borderRadius:Bc/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:Ki,height:Ki,borderRadius:Ki/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:Gi,height:Gi,borderRadius:Gi/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:Vc,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...pe(o.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...S(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...Ie(o.primaryButton)},skip:{minHeight:Vc,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...S(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}i(sC,"makeStyles");var CC=.88,RC=420,SC=58,TC="rgba(17,17,17,0.28)",PC=.08,kC=.1,xC=.08,_C=.18,wC=.78,IC=.7,qi=36,AC=10,OC=14,FC=12,MC=16,LC=14,$i=8,DC=1.5,NC=.5,UC=Cn(vr.standard);function VC(e){return Math.min(Math.round(e*CC),RC)}i(VC,"drawerPanelWidth");function jc({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(HC,{chat:e,history:t,onHidden:o}):null}i(jc,"HistoryDrawer");function HC({chat:e,history:t,onHidden:r}){let n=F(),o=react.useMemo(()=>zC(n),[n]),s=X(),a=reactNativeSafeAreaContext.useSafeAreaInsets(),{width:l}=reactNative.useWindowDimensions(),u=VC(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 C=reactNative.Animated.timing(p,{toValue:d?1:0,duration:s.drawerMs,easing:UC,useNativeDriver:true});return C.start(({finished:_})=>{_&&!d&&r();}),()=>C.stop()},[d,p,s.drawerMs,r]);let f=p.interpolate({inputRange:[0,1],outputRange:[-u,0]}),m=t.filtered,y=t.rows.length===0,x=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:Se,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(SC,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(Sd,{size:LC,color:n.color.text.muted,strokeWidth:1.5}),jsxRuntime.jsx(Ut,{value:t.query,onChangeText:C=>t.setQuery(C.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(Td,{size:MC,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:C=>C.id,renderItem:({item:C})=>jsxRuntime.jsx(BC,{row:C,active:C.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(C.id);}}),contentContainerStyle:m.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:x,ListFooterComponent:b,onEndReached:t.loadMore,onEndReachedThreshold:NC})]})})]})})}i(HC,"DrawerModal");function BC({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:ed(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:mn(e.title)}),s?jsxRuntime.jsx(reactNative.View,{style:n.unreadDot}):null]})})}i(BC,"Row");function Mn(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(Mn,"inkWash");function zC(e){let t=e.color,r=e.slots,n=t.onPrimary;return reactNative.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:TC},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:Mn(n,kC)},searchInput:{...S(e,"regular"),flex:1,fontSize:13,lineHeight:16,color:t.text.primary,padding:0},newButton:{width:qi,height:qi,borderRadius:qi/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:AC},itemActive:{backgroundColor:Mn(n,PC)},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:$i,height:$i,borderRadius:$i/2,backgroundColor:t.danger,borderWidth:DC,borderColor:n},errorCard:{borderRadius:FC,borderWidth:.5,borderColor:t.danger,backgroundColor:t.surface,padding:12},errorText:{...S(e,"regular"),fontSize:11,lineHeight:16,color:t.danger},emptyCard:{borderRadius:OC,padding:14,gap:6,backgroundColor:Mn(n,xC),borderWidth:.5,borderColor:Mn(n,_C)},emptyTitle:{...S(e,"bold"),fontSize:12,lineHeight:15,color:n},emptyBody:{...S(e,"regular"),fontSize:11,lineHeight:17,color:n,opacity:wC},retrySlot:{marginTop:8,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:7,borderWidth:1,borderColor:n,...pe(r.primaryButton)},retryText:{...S(e,"bold"),fontSize:12,lineHeight:15,color:n,...Ie(r.primaryButton)},loadMoreFooter:{paddingVertical:14,alignItems:"center"},loadMoreLabel:{...S(e,"regular"),fontSize:11,lineHeight:14,color:n,opacity:IC}})}i(zC,"makeStyles");var $C=Object.freeze({}),YC=100,XC=20;function QC(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(QC,"readWindowTops");function Wc(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,x)=>{let b=a.current;if(!u.current||b===null)return;let C=QC(x,b.y,b.height,reactNative.Dimensions.get("window").height);if(C!==null){s(_=>_!==null&&_.chatTop===C.chatTop&&_.parentTop===C.parentTop?_:C);return}m>=XC||(l.current=setTimeout(()=>{l.current=null,f(m+1);},YC));});},"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}:$C,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(Wc,"useChatKeyboardOffset");function Gc({probeRef:e}){return e===null?null:jsxRuntime.jsx(reactNative.View,{ref:e,collapsable:false,pointerEvents:"none",style:ZC})}i(Gc,"KeyboardOffsetProbe");var ZC=Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function Kc(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(Kc,"chatVetVisitOptions");var nR=16,oR=.75,Xi=12,qc=15,iR=18,Dn=22,sR=14,aR=8,lR=20,uR=10,dR=13;function Yc({surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o}){let s=F(),a=react.useMemo(()=>cR(s),[s]),l=X(),u=e.tier,d=e.source;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(vi,{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(Et,{render:()=>r(u.level),fallback:jsxRuntime.jsx($c,{tier:u,petRef:t,onFindVet:n,vet:o,styles:a}),resetKey:u.level}):jsxRuntime.jsx($c,{tier:u,petRef:t,onFindVet:n,vet:o,styles:a}):null,e.dismissLabel!==null?jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:e.dismissLabel,hitSlop:aR,containerStyle:a.closeSlot,style:a.closeButton,onPress:e.dismiss,children:jsxRuntime.jsx(Ct,{size:sR,color:u.textColor,strokeWidth:1.5})}):null]}):null}),jsxRuntime.jsx(vi,{visible:e.showCompactIcon,inMs:l.iconInMs,outMs:l.iconOutMs,style:a.indicatorRow,children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.showLatestVetAlert,hitSlop:uR,onPress:e.expand,children:jsxRuntime.jsx(vd,{size:lR,color:s.color.text.muted,strokeWidth:2})})})]})}i(Yc,"UrgencyBanner");function $c({tier:e,petRef:t,onFindVet:r,vet:n,styles:o}){let s=F(),a=_n(Kc(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=xi(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(Pd,{size:dR,color:d,strokeWidth:1.5}),jsxRuntime.jsx(R,{tier:"control",style:[o.findVetLabel,{color:d}],children:h.findVet})]})}i($c,"VetAction");function cR(e){let t=xi(e.slots.vetVisitButton);return reactNative.StyleSheet.create({pinned:{marginTop:0,marginBottom:4,paddingHorizontal:e.space.lg},card:{borderRadius:nR,borderWidth:oR,paddingHorizontal:14,paddingVertical:8,gap:2},label:{...S(e,"monoBold"),fontSize:Xi,lineHeight:qc},reason:{...S(e,"regular"),fontSize:Xi,lineHeight:iR,paddingRight:Dn},findVetSlot:{alignSelf:"flex-start",marginTop:6},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...pe(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...S(e,"monoBold"),fontSize:Xi,lineHeight:qc},closeSlot:{position:"absolute",top:6,right:6},closeButton:{width:Dn,height:Dn,borderRadius:Dn/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:16,paddingTop:2,paddingBottom:4}})}i(cR,"makeStyles");function Xc(){let e=Tn(),{handle:t}=Y(),r=react.useCallback(n=>t.setActivePet(n),[t]);return react.useMemo(()=>({...e,setActivePet:r}),[e,r])}i(Xc,"useChatPets");var op=300,ip=3e3,Zc=120,Gt=44,gR=120,hR="86%",Jc=15,ep=22,Nn=.5,bR=.04,vR=8,ER=2,CR=1,RR=.6,SR=22,TR=48,tp=1.25,PR=14,kR=18,xR=6,_R=14,wR=.04,IR=12,AR=2,OR=2,rp=36,FR=20,Wt=36,Kt=(Gt-Wt)/2,sp=24,ap=22,MR=.4,Un=30,lp=20,LR=.4,DR=480,NR=8,np=14,UR=10,VR=14,HR=12,BR=13,zR=18,jR="12%";function Ee(){let e=F(),t=react.useMemo(()=>WR(e),[e]);return {theme:e,styles:t}}i(Ee,"useChatTheme");function WR(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:Zc,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:Zc,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},emptyContent:{flexGrow:1,alignItems:"center",justifyContent:"flex-start",paddingTop:jR,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:DR,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,...pe(s.primaryButton)},retryLabel:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,...Ie(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:hR},bubbleUser:{padding:Jc,backgroundColor:t.bubbleUser,borderRadius:n.xl,borderBottomRightRadius:n.sm,borderWidth:Nn,borderColor:t.accentEdge,shadowColor:t.brand,shadowOpacity:bR,shadowRadius:vR,shadowOffset:{width:0,height:ER},elevation:CR,...pe(s.userBubble,Nn)},bubbleAssistant:s.assistantBubble?.backgroundColor===void 0?{...pe(s.assistantBubble,Nn)}:{padding:Jc,borderRadius:n.xl,...pe(s.assistantBubble,Nn)},bubblePending:{opacity:RR},bubbleTextUser:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:ep,...Ie(s.userBubble)},bubbleTextAssistant:{...S(e,"medium"),color:t.text.primary,fontSize:o.size.body,lineHeight:ep,...Ie(s.assistantBubble)},bubbleBold:S(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:S(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.sm,gap:NR},followUpSlot:{alignSelf:"stretch",borderRadius:np},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:HR,paddingVertical:UR,paddingHorizontal:VR,borderRadius:np,backgroundColor:t.brandSoft},followUpText:{...S(e,"medium"),flex:1,color:t.text.primary,fontSize:BR,lineHeight:zR},composerOuter:{position:"relative"},composer:{marginHorizontal:r.md,marginTop:r.xs,marginBottom:r.sm,minHeight:TR,justifyContent:"center",paddingLeft:PR,paddingRight:kR,paddingVertical:xR,backgroundColor:t.composerFill,borderWidth:tp,borderColor:t.composerBorder,borderRadius:SR,shadowColor:t.shadow,shadowOpacity:wR,shadowRadius:IR,shadowOffset:{width:0,height:AR},elevation:OR,...pe(s.composerInput,tp)},composerRow:{flexDirection:"row",alignItems:"center",gap:_R,minHeight:rp},attachControl:{width:Un,height:Un,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:LR},input:{flex:1,minHeight:rp,maxHeight:gR,paddingHorizontal:0,paddingVertical:0,...S(e,"regular"),fontSize:o.size.body,lineHeight:FR,color:t.text.primary,...Ie(s.composerInput)},sendControl:{minHeight:Wt,minWidth:Wt,alignItems:"center",justifyContent:"center"},sendDisc:{width:Wt,height:Wt,borderRadius:Wt/2,alignItems:"center",justifyContent:"center",...pe(s.sendButton)},sendControlDisabled:{opacity:MR},poweredBy:{...S(e,"regular"),color:t.text.muted,fontSize:o.size.micro,textAlign:"center",paddingBottom:r.xs}})}i(WR,"makeStyles");var GR=Object.freeze({kind:"live"}),KR=Object.freeze({kind:"folded"});function Zi(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(Zi,"askOf");function dp(e){let t=new Map,r=new Map;for(let o of e){let s=Zi(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=Zi(o);if(s===null){n=null;continue}if(r.get(s.caseId)?.messageId===o.id){t.set(o.id,GR),n=null;continue}if(n!==null&&n.caseId===s.caseId){n.days.push(s.dueDay),t.set(o.id,KR);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(dp,"placeCheckins");var up=864e5,qR=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/up)-Math.floor(r/up);return o<1||o>qR?null:o}i(Vn,"checkinDayNumber");function cp(e){return Zi(e)?.dueDay||null}i(cp,"checkinDueDay");var Te=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"})}),pp=Object.freeze(Wr.map(e=>Object.freeze({answer:e,label:Te.answers[e]})));function fp(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:!ha(e),escalated:d==="worse",pending:r,error:o,choose:u}}i(fp,"useCheckinCard");var gp=44,XR=.6;function bp({message:e,checkin:t,onAnswer:r,petRef:n,onFindVet:o,vet:s,onLayout:a}){let l=F(),u=react.useMemo(()=>QR(l),[l]),d=fp(t,r),c=d.answer!==null||d.pending!==null,p=r!==null&&d.answerable,f=Vn(t.openedAt,cp(e));return jsxRuntime.jsxs(reactNative.View,{style:u.card,accessibilityLabel:Te.eyebrow,onLayout:a,children:[jsxRuntime.jsxs(reactNative.View,{style:u.head,children:[jsxRuntime.jsx(R,{tier:"compact",style:u.eyebrow,children:Te.eyebrow}),f!==null?jsxRuntime.jsx(R,{tier:"compact",style:u.headDay,children:K(Te.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:pp.map(({answer:m,label:y})=>{let x=(d.pending??d.answer)===m;return jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>d.choose(m),disabled:c,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{selected:x,disabled:c,busy:d.pending===m},style:[u.pill,x?u.pillSelected:null],children:jsxRuntime.jsx(R,{tier:"control",style:[u.pillLabel,x?u.pillLabelSelected:null],children:y})},m)})}):null,d.answer!==null?jsxRuntime.jsx(R,{style:u.logged,children:Te.logged}):null,d.escalated?o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:Te.findVet,style:u.findVet,children:jsxRuntime.jsx(R,{tier:"control",style:u.findVetLabel,children:Te.findVet})}):n?jsxRuntime.jsx(jt,{entry:"chat",petRef:n,label:Te.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(bp,"CheckinCard");function QR(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:XR},pill:{flex:1,minHeight:gp,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:gp,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(QR,"makeStyles");var eS=1.5,tS=3;function Ep({text:e,runDueDays:t,openedAt:r,onLayout:n}){let o=F(),s=react.useMemo(()=>rS(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(Te.day,{day:u})).join(Te.daySeparator)}):null,l?null:jsxRuntime.jsx(R,{style:s.question,accessibilityRole:"text",children:e})]})]})}i(Ep,"CheckinPastAsk");function rS(e){let t=e.color,r=e.space,n=e.type;return reactNative.StyleSheet.create({row:{flexDirection:"row",paddingVertical:r.xs},rule:{width:eS,borderRadius:1,backgroundColor:t.borderHairlineGreen,marginRight:r.md},body:{flex:1,gap:tS},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(rS,"makeStyles");var nS=Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),Cp="#C8BEB4";function oS(e){return e?nS[e.toUpperCase()]??Cp:Cp}i(oS,"tierColor");function iS(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}i(iS,"tierLabel");function He(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(He,"text");function sS(e){let t=He(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}i(sS,"httpsUrl");function aS(e,t){let r=He(e.source_name)??He(e.sourceName),n=He(e.section),o=He(e.authority_tier)??He(e.authorityTier),s=iS(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:sS(e.url),excerpt:He(e.excerpt),tierColor:oS(o),key:`${a}-${l??"none"}-${t}`})}i(aS,"toCitationCard");function Rp(e){return e===void 0||e.length===0?lS:Object.freeze(e.map((t,r)=>aS(t,r)))}i(Rp,"toCitationCards");var lS=Object.freeze([]);function ns(e){return e===1?`1 ${h.sourceSingular}`:`${e} ${h.sourcePlural}`}i(ns,"sourcesLabel");function Sp(e,t){return `${t?h.hideSources:h.showSources} ${ns(e)}`}i(Sp,"sourcesToggleLabel");function Tp(e){return [e.url!==null?`${h.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(t=>t!==null&&t.length>0).join(". ")}i(Tp,"citationA11yLabel");var fS=244,kp=8,xp=13,mS=14,yS=.3,gS=-0.24,hS=22,bS=10,vS=15;function _p({citations:e,onOpenUrl:t}){let r=F(),n=react.useMemo(()=>RS(r),[r]),o=react.useMemo(()=>Rp(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:Sp(l,s),accessibilityState:{expanded:s},containerStyle:n.toggleSlot,style:n.togglePill,onPress:()=>a(u=>!u),children:[jsxRuntime.jsx(gd,{size:xp,color:r.color.brandInk,strokeWidth:1.5}),jsxRuntime.jsx(R,{tier:"compact",style:n.toggleLabel,children:ns(l)}),jsxRuntime.jsx(hn,{size:xp,color:r.color.brandInk,strokeWidth:1.5,direction:s?"up":"down"})]}),s?jsxRuntime.jsx(ES,{cards:o,styles:n,open:t}):null]})}i(_p,"CitationCards");function ES({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(CS,{card:s,styles:t,open:r},s.key))})})}i(ES,"Deck");function CS({card:e,styles:t,open:r}){let n=F(),o=e.url!==null&&r!==void 0,s=Tp(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(hd,{size:mS,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(CS,"Card");function RS(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:yS,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:fS,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:kp,height:kp,borderRadius:n.pill},cardTitle:{...S(e,"bold"),flex:1,fontSize:o.bodyTight,lineHeight:hS,color:t.text.primary,letterSpacing:gS},cardTitleLink:{color:t.linkInk},cardMeta:{...S(e,"monoMedium"),fontSize:o.nano,lineHeight:bS,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},cardExcerpt:{...S(e,"regular"),fontSize:o.tiny,lineHeight:vS,color:t.text.muted}})}i(RS,"makeStyles");function wp(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}i(wp,"formatMessageTime");var xr=15,_S=15,wS=6,IS=Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function Mp({message:e,onCopy:t,sentiment:r=null,onSentiment:n,thanks:o=false}){let s=F(),a=react.useMemo(()=>AS(s),[s]),l=X(),u=e.role==="user",d=react.useMemo(()=>wp(e.createdAt),[e.createdAt]),c=t!==void 0&&e.text.length>0,p=!u&&n!==void 0&&e.responseId!==void 0,[f,m]=react.useState(false),y=react.useRef(null);react.useEffect(()=>()=>{y.current&&clearTimeout(y.current);},[]);let x=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:_S,onPress:x,style:a.iconHit,children:f?jsxRuntime.jsx(nt,{size:xr,color:s.color.success,strokeWidth:2}):jsxRuntime.jsx(bd,{size:xr,color:s.color.text.timestamp,strokeWidth:1.5})}):null,p?xu.map(({sentiment:b,label:C})=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:C,accessibilityState:{selected:r===b},hitSlop:wS,onPress:()=>n?.(b),style:a.iconHit,children:jsxRuntime.jsx(bn,{size:xr,color:s.color.sentiment[b],active:r===b,rotate:IS[b],strokeWidth:1.5})},b)):null]}),o?jsxRuntime.jsx(R,{style:a.thanks,accessibilityLiveRegion:"polite",children:h.feedbackThanks}):null]})}i(Mp,"MessageFooter");function AS(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:xr,height:xr,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(AS,"makeStyles");var Lp="#10462E",Dp="#000000",OS="#83E0B4",FS=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:OS,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:Lp,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})]),MS=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function LS(e){return e==null?e:e.replace(MS,"").trim()}i(LS,"formatBreedForPrompt");var DS=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 NS(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return DS.has(t)}i(NS,"isUninformativeBreed");function US(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}i(US,"unspecifiedBreedLabel");function VS(e,t){return NS(e)?US(t):String(e).replace(/\s+/gu," ").trim()}i(VS,"resolveBreedLabel");function Np(e){let t=e?.name?.trim()||h.emptyTitlePetFallback;return K(h.emptyTitle,{petName:t})}i(Np,"emptyStateTitle");function Up(e,t=Lp){let r=Li(e?.species),n=r==="cat"?"my cat":"my dog",o=e?.name?.trim()||null,s=o||n,a=VS(LS(e?.breed),r)||null,l=Di(e?.ageYears),u=l===null?null:String(l);return Object.freeze(FS.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??""}),x=!o&&m.startsWith("{petName}")?y.charAt(0).toUpperCase()+y.slice(1):y;return Object.freeze({id:d.id,intent:d.intent,label:x,background:d.background,borderColor:d.brandEdge===true?t:d.borderColor,borderWidth:d.borderWidth})}))}i(Up,"resolveQuickPrompts");var BS=36,Bp=4,zS=340;function zp({pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o}){let s=F(),a=react.useMemo(()=>WS(s),[s]),l=react.useMemo(()=>Up(e,s.color.brandInk),[e,s.color.brandInk]),u=Np(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(jS,{prompt:d,index:c,petRef:t,onSend:r,onVetPrep:n,vet:o,pet:e,styles:a},d.id))})]})}i(zp,"QuickPrompts");function jS({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:Bp,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:Bp,style:[l.chip,c],onPress:()=>o(e.label),children:jsxRuntime.jsx(R,{tier:"compact",style:l.chipLabel,children:e.label})})})}i(jS,"Chip");function WS(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:zS},list:{width:"100%",gap:12,alignItems:"center"},chip:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:9,minHeight:BS,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipLabel:{...S(e,"bold"),fontSize:12,lineHeight:14,color:Dp,textAlign:"center"}})}i(WS,"makeStyles");var is=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;function jp(e){return e.includes("*")||e.includes("`")}i(jp,"hasInlineMarkup");function Wp(e){let t=[],r=0;is.lastIndex=0;for(let n=is.exec(e);n!==null;n=is.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(Wp,"tokenizeInlineMarkdown");function Gp(e,t){return jp(e)?Wp(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(Gp,"renderInlineMarkdown");var $p=6,Qp=520,XS=Math.round(Qp*.18),Yp=.44,QS=.5,Xp=[0,.5,1],ZS=[0,1,2];function Zp(){let e=F(),t=react.useMemo(()=>eT(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:ZS.map(n=>r?jsxRuntime.jsx(JS,{index:n,style:t.dot},n):jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotStatic]},n))})}i(Zp,"TypingIndicator");function JS({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*XS),reactNative.Animated.loop(reactNative.Animated.timing(r,{toValue:1,duration:Qp,useNativeDriver:true}))]);return s.start(),()=>s.stop()},[r,e]);let n=r.interpolate({inputRange:Xp,outputRange:[Yp,1,Yp]}),o=r.interpolate({inputRange:Xp,outputRange:[0,-3.5,0]});return jsxRuntime.jsx(reactNative.Animated.View,{style:[t,{opacity:n,transform:[{translateY:o}]}]})}i(JS,"AnimatedDot");function eT(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:$p,height:$p,borderRadius:n.pill,backgroundColor:t.brand},dotStatic:{opacity:QS}})}i(eT,"makeStyles");function Jp(e,t,r){let n=e-r,o=t!=null?Math.min(n,t):n;return Math.max(0,o)}i(Jp,"resolveTurnScrollTarget");function ef(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(ef,"latestTurn");function tf(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(tf,"nextFollowOffset");function rf(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=ef(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 P=r.current;if(P===null||!n.current||a.current===0)return;let k=null;if(c!==null){let w=u.current.get(c);if(w===void 0)return;let O=p===null?null:u.current.get(p)??null;k=Jp(w,O,96);}let g=tf(k,s.current,l.current-a.current);g!==null&&(s.current=g,P.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(P=>{a.current=P.nativeEvent.layout.height,f();},[f]),y=react.useCallback((P,k)=>{l.current=k,a.current>0&&(s.current=Math.min(s.current,Math.max(0,k-a.current))),f();},[f]),x=react.useCallback(P=>{s.current=P.nativeEvent.contentOffset.y;},[]),b=react.useCallback(()=>{n.current=false;},[]),C=react.useCallback(P=>{let{contentOffset:k,contentSize:g,layoutMeasurement:w}=P.nativeEvent;s.current=k.y,n.current=g.height-k.y-w.height<=24;},[]),_=react.useCallback(P=>k=>{u.current.set(P,k.nativeEvent.layout.y),(P===c||P===p)&&f();},[c,p,f]);return {ref:r,onLayout:m,onContentSizeChange:y,onScroll:x,onScrollBeginDrag:b,onScrollEnd:C,rowLayout:_}}i(rf,"useThreadFollow");function lf(e,t,r){switch(e){case "loading":return r.renderPending?jsxRuntime.jsx(Et,{render:r.renderPending,fallback:jsxRuntime.jsx(of,{})}):jsxRuntime.jsx(of,{});case "empty":return jsxRuntime.jsx(lT,{pet:r.shownPet,petRef:t.petRef,prompts:t.suggestedPrompts,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet});case "error":return jsxRuntime.jsx(dT,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case "populated":return jsxRuntime.jsx(cT,{messages:t.messages,prompts:t.suggestedPrompts,onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,thanksFor:r.thanksFor,imagesByMessage:r.imagesByMessage,onPreview:r.onPreview,notice:r.notice,reconnecting:t.reconnecting===true,onRetry:t.retryLast,onStartNew:t.newConversation,petRef:t.petRef,onFindVet:r.onCheckinFindVet,vet:r.vet,onOpenUrl:r.onOpenUrl});default:return Ze(e)}}i(lf,"renderView");function of(){let{theme:e,styles:t}=Ee(),[r,n]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>n(true),op);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(of,"LoadingState");function lT({pet:e,petRef:t,prompts:r,onSelectPrompt:n,onVetPrep:o,vet:s}){let{styles:a}=Ee();return jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:a.emptyContent,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,accessibilityLabel:h.empty,children:[jsxRuntime.jsx(zp,{pet:e,petRef:t,onSend:n,onVetPrep:o,vet:s}),jsxRuntime.jsx(uf,{prompts:r,onSelectPrompt:n})]})}i(lT,"EmptyState");function uf({prompts:e,onSelectPrompt:t}){let{styles:r}=Ee();return e.length===0?null:jsxRuntime.jsx(reactNative.View,{style:r.followUps,children:e.map((n,o)=>jsxRuntime.jsx(uT,{prompt:n,index:o,onSelectPrompt:t},n))})}i(uf,"FollowUps");function uT({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:o}=Ee(),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(hn,{size:yT,color:n.color.brandInk,direction:"right"})]})})}i(uT,"FollowUpRow");function dT({error:e,onRetry:t,onAddPet:r}){let{styles:n}=Ee(),o=Du(e)?Wu(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(dT,"ErrorState");function cT({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:x,onFindVet:b,vet:C,onOpenUrl:_}){let{styles:P}=Ee(),k=X();Er(e.length,k);let g=react.useMemo(()=>dp(e),[e]),w=ld(e,n),O=e[e.length-1],M=react.useMemo(()=>e.filter(v=>!(v.checkin&&g.get(v.id)?.kind==="folded")),[e,g]),I=rf(M,n);return jsxRuntime.jsxs(reactNative.ScrollView,{ref:I.ref,style:P.list,contentContainerStyle:P.listContent,accessibilityLabel:h.transcript,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,onLayout:I.onLayout,onContentSizeChange:I.onContentSizeChange,onScroll:I.onScroll,scrollEventThrottle:mT,onScrollBeginDrag:I.onScrollBeginDrag,onScrollEndDrag:I.onScrollEnd,onMomentumScrollEnd:I.onScrollEnd,children:[e.map(v=>{let T=v.checkin?g.get(v.id):void 0;return T?.kind==="folded"?null:T?.kind==="past"?jsxRuntime.jsx(Ep,{text:v.text,runDueDays:T.runDueDays,openedAt:v.checkin?.openedAt,onLayout:I.rowLayout(v.id)},v.id):v.checkin&&T!==void 0?jsxRuntime.jsx(bp,{message:v,checkin:v.checkin,onAnswer:o,petRef:x,onFindVet:b,vet:C,onLayout:I.rowLayout(v.id)},v.id):jsxRuntime.jsx(gT,{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]??fT,onPreview:c,onOpenUrl:_},v.id)}),f?jsxRuntime.jsx(R,{tier:"compact",style:P.reconnectingCaption,accessibilityRole:"text",children:h.reconnecting}):null,w?jsxRuntime.jsx(Zp,{}):null,p!==null?jsxRuntime.jsx(pT,{notice:p,onRetry:m,onStartNew:y}):null,n?null:jsxRuntime.jsx(uf,{prompts:t,onSelectPrompt:r})]})}i(cT,"PopulatedState");function pT({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=Ee(),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(pT,"TurnNoticeCard");var fT=Object.freeze([]),mT=16,yT=14;function gT({message:e,revealing:t,onCopy:r,sentiment:n,onSentiment:o,thanks:s,images:a,onPreview:l,onOpenUrl:u,onLayout:d}){let{styles:c}=Ee(),p=X(),f=Rt(p.messageInMs),m=Ld(e.text,t,p),y=e.role==="user",x=y?h.senderUser:h.senderAssistant,b=react.useCallback(_=>o(e,_),[o,e]),C=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:`${x}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:jsxRuntime.jsxs(reactNative.View,{style:[c.bubble,y?c.bubbleUser:c.bubbleAssistant,e.pending?c.bubblePending:null],children:[y&&a.length>0?jsxRuntime.jsx(Zd,{images:a,onPreview:_=>l({uri:_.uri,label:_.filename})}):null,jsxRuntime.jsx(R,{style:y?c.bubbleTextUser:c.bubbleTextAssistant,children:y?e.text:Gp(m,{bold:c.bubbleBold,italic:c.bubbleItalic,code:c.bubbleCode})})]})}),!y&&!t?jsxRuntime.jsx(_p,{citations:e.citations,onOpenUrl:u}):null,C?jsxRuntime.jsx(Mp,{message:e,onCopy:r,sentiment:n,onSentiment:e.responseId===void 0?void 0:b,thanks:s}):null]})}i(gT,"MessageRow");var CT=Object.freeze(["photo"]),RT=1;function cf(e){let{style:t,renderPending:r}=e;return jsxRuntime.jsx(ti,{capability:"chat",style:t,...r?{renderPending:r}:{},children:jsxRuntime.jsx(ST,{...e})})}i(cf,"EverfurChat");function ST({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:x,draftStore:b,vetReturnTo:C,vetUsState:_,vetPrefer:P,onOpenUrl:k,keyboardVerticalOffset:g}){let{theme:w,styles:O}=Ee(),M=X(),I=react.useMemo(()=>ud(e,t),[e,t]),v=hr(I),T=sd(v),V=Xc(),j=td(v),W=reactNativeSafeAreaContext.useSafeAreaInsets(),ne=ad(v),he=react.useMemo(()=>l===void 0?void 0:()=>{q(l,"emergency");},[l]),ke=react.useMemo(()=>C===void 0&&_===void 0&&P===void 0?void 0:{returnTo:C,usState:_,prefer:P},[C,_,P]),st=Wi(V.pets,v.petRef),fe=react.useMemo(()=>od(v.messages,st?.name??null),[v.messages,st?.name]),Qe=id(fe);Er(Qe.showBanner,M),$u(v.openCheckin,f),Bu(v.askEverfur,v.isBootstrapping,m);let Ir=react.useMemo(()=>ui(y),[y]);Ku(x,{conversationId:v.conversationId===null?null:String(v.conversationId),isTurnInFlight:v.isStreaming,refresh:v.refreshActiveThread});let Ar=(v.hasUnreadThreads??false)||j.rows.some(Ce=>Ce.unreadCount!==null&&Ce.unreadCount>0)||(v.unreadCount??0)>0,At=Vu(v.messages),[Yt,Wn]=react.useState(null),ff=react.useCallback(()=>Wn(null),[]),[Xt,Gn]=react.useState(null),[mf,us]=react.useState(null),Ot=react.useRef(null);react.useEffect(()=>()=>{Ot.current&&clearTimeout(Ot.current);},[]);let ds=react.useCallback(Ce=>{us(String(Ce)),Ot.current&&clearTimeout(Ot.current),Ot.current=setTimeout(()=>{us(null),Ot.current=null;},ip);},[]),yf=react.useCallback((Ce,Fr)=>{let Qt=Ce.responseId;if(Qt===void 0)return;let Cf=v.sentimentByMessage[String(Qt)];v.feedback(Qt,Fr),Fr==="down"&&Cf!=="down"&&Gn(Qt);},[v]),gf=react.useCallback(async(Ce,Fr)=>Xt===null||!(await v.feedback(Xt,"down",Ce??"other",Fr)).ok?false:(Gn(null),ds(Xt),true),[v,Xt,ds]),hf=react.useCallback(()=>Gn(null),[]),bf=react.useCallback(Ce=>{v.send(Ce);},[v.send]),vf=react.useMemo(()=>k===void 0?void 0:Ce=>{q(k,Ce,"citation");},[k]),cs=reactNative.Platform.OS==="ios"?"padding":void 0,Or=Wc(g,cs!==void 0),Ef=Or.topInWindow===null?W.top:Math.max(0,W.top-Or.topInWindow),ps={send:v.send,stop:v.stop,isStreaming:v.isStreaming,conversationId:v.conversationId,seed:Ir,draftStore:b,onStage:At.stage,onPreview:Wn};return jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:[O.container,{paddingTop:Ef},r],behavior:cs,...Or.avoidingProps,children:[jsxRuntime.jsx(Gc,{probeRef:Or.probeRef}),jsxRuntime.jsx(Dc,{pets:V,petRef:v.petRef,historyUnread:Ar,onOpenHistory:j.show,onPetChange:s,onAddPet:p,vet:ke}),c!==void 0?jsxRuntime.jsx(TT,{petRef:e??null,pet:c,onRegistered:V.refresh}):null,jsxRuntime.jsx(Yc,{surface:Qe,petRef:v.petRef,renderVetAction:u,onFindVet:l,vet:ke}),jsxRuntime.jsx(reactNative.View,{style:O.body,children:lf(T,v,{notice:ne,vet:ke,onCheckinFindVet:he,onSelectPrompt:bf,renderPending:n,shownPet:st,onVetPrep:a,onCopy:o,onSentiment:yf,thanksFor:mf,imagesByMessage:At.byMessage,onPreview:Wn,onAddPet:p,onOpenUrl:vf})}),d!==void 0?jsxRuntime.jsx(PT,{...ps,attachments:d}):jsxRuntime.jsx(pf,{...ps,attachments:null}),jsxRuntime.jsx(pd,{}),w.meta.hidePoweredBy?null:jsxRuntime.jsx(R,{tier:"compact",style:O.poweredBy,accessibilityRole:"text",accessibilityLabel:h.poweredBy,children:h.poweredBy}),jsxRuntime.jsx(jc,{chat:v,history:j}),jsxRuntime.jsx(zc,{visible:Xt!==null,onSubmit:gf,onSkip:hf}),jsxRuntime.jsx(Dd,{uri:Yt?.uri??null,label:Yt?.label??"",onClose:ff}),jsxRuntime.jsx(Rr,{})]})}i(ST,"ChatBody");function TT({petRef:e,pet:t,onRegistered:r}){let{styles:n}=Ee(),o=Nu(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(TT,"PetSetupNotice");function PT({attachments:e,...t}){let r=react.useMemo(()=>ec(),[]),n=pn({maxPerMessage:e.maxPerMessage??RT,transport:r}),o=react.useMemo(()=>({state:n,sources:e.sources??CT,pick:e.pick}),[n,e.sources,e.pick]);return jsxRuntime.jsx(pf,{...t,attachments:o})}i(PT,"ComposerWithAttachments");function pf({send:e,stop:t,isStreaming:r,conversationId:n,attachments:o,seed:s,draftStore:a,onStage:l,onPreview:u}){let{theme:d,styles:c}=Ee(),p=X(),[f,m]=Qu(e,n,s);Zu(a,n===null?null:String(n),f,m);let[y,x]=react.useState(false),[b,C]=react.useState(false);react.useEffect(()=>{C(false);},[n]);let _=d.meta.placeholder??h.placeholder,P=o?.state.uploading??false,k=o?.state.failed??false,g=P||k,w=o?.state.attachments??kT;Er(w.length,p);let O=react.useCallback(()=>{if(f.trim().length===0||g||[...f].length>Lt)return;let W=o?.state.s3Keys??xT;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(""),C(false);},[f,e,g,o,l]),M=react.useCallback(()=>{t();},[t]),I=react.useCallback(W=>{x(false),o!==null&&(C(false),o.state.dismissRejected(),Ht(o.pick,W).then(ne=>{if(!ne.ok){C(true);return}ne.value!==null&&o.state.add(ne.value);}));},[o]),T=react.useMemo(()=>[...f].length>Lt,[f])||g,V=o!==null&&w.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(Vd,{sources:o.sources,full:V,onPick:I,onClose:()=>x(false)}):null,jsxRuntime.jsxs(reactNative.View,{style:c.composer,children:[o!==null?jsxRuntime.jsx(Qd,{attachments:w,rejected:b?_T:o.state.rejected,uploadFailed:k,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:Fu(w.length,o.state.maxPerMessage),accessibilityState:{disabled:V,expanded:y},disabled:V,hitSlop:(Gt-Un)/2,style:[c.attachControl,V?c.attachControlDisabled:null],onPress:()=>x(W=>!W),children:jsxRuntime.jsx(Ed,{size:lp,color:V?d.color.text.muted:d.color.brandInk,strokeWidth:1.75})}):null,jsxRuntime.jsx(Ut,{style:c.input,value:f,onChangeText:m,placeholder:_,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(xd,{size:ap,color:j,testID:"everfur-stop-glyph"})})}):jsxRuntime.jsx(reactNative.Pressable,{onPress:O,disabled:T,accessibilityRole:"button",accessibilityLabel:h.send,accessibilityState:{disabled:T,busy:P},hitSlop:Kt,style:[c.sendControl,T?c.sendControlDisabled:null],children:jsxRuntime.jsx(reactNative.View,{style:c.sendDisc,testID:"everfur-send-disc",children:jsxRuntime.jsx(kd,{size:sp,color:j,testID:"everfur-send-glyph"})})})]})]})]})}i(pf,"Composer");var kT=Object.freeze([]),xT=Object.freeze([]),_T=Object.freeze({code:"unknown",retryable:true,filename:""});function FT(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(FT,"useEverfurPetProfile");function LT(e){return react.createElement(un,{clientTheme:e.clientTheme??null,seams:cn,children:e.children})}i(LT,"EverfurThemeProvider");exports.CapabilityGate=ti;exports.EverfurChat=cf;exports.EverfurConfigError=Q;exports.EverfurProvider=$h;exports.EverfurThemeProvider=LT;exports.EverfurThrownError=Mr;exports.THEME_SLOT_KEYS=mg;exports.THEME_SLOT_NAMES=gt;exports.canonicalPetSpecies=ur;exports.categoryFor=qn;exports.conversationId=wf;exports.createRnRecordsUploadTransport=qf;exports.face=S;exports.isErr=Tf;exports.isOk=Sf;exports.isRetryableCode=$n;exports.petRef=xf;exports.previewTheme=zg;exports.unwrap=Pf;exports.useCapability=Nt;exports.useChatAttachments=pn;exports.useEverfur=ou;exports.useEverfurChat=hr;exports.useEverfurPetProfile=FT;exports.useEverfurPets=Tn;exports.useEverfurTheme=F;exports.userFacingError=Ft;exports.userRef=_f;
|
|
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;
|