@everfur/sdk 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +206 -0
- package/README.md +11 -10
- package/dist/{Chat.d-Dts8u_1a.d.cts → Chat.d-CtfANk3A.d.cts} +12 -4
- package/dist/{Chat.d-DUNTfzqC.d.ts → Chat.d-a7Ksz7NZ.d.ts} +12 -4
- package/dist/{DepthViews.d-CubkMPbU.d.ts → DepthViews.d-BqMnWSMu.d.cts} +1 -1
- package/dist/{DepthViews.d-BMU2jFPw.d.cts → DepthViews.d-CuBElgEc.d.ts} +1 -1
- package/dist/{DepthViews.d-Ce2Zhnrb.d.ts → DepthViews.d-DbJejGm3.d.ts} +1 -1
- package/dist/{DepthViews.d-BIp599lz.d.cts → DepthViews.d-dXWL6ToG.d.cts} +1 -1
- package/dist/RecordsPage.d-DKrZ9rHX.d.ts +93 -0
- package/dist/RecordsPage.d-DRPdUAo4.d.cts +93 -0
- package/dist/animations/index.cjs +1 -1
- package/dist/animations/index.d.cts +7 -5
- package/dist/animations/index.d.ts +7 -5
- package/dist/animations/index.js +1 -1
- package/dist/{attachments.d-Djy9z_0Z.d.ts → attachments.d-BGn2_knv.d.ts} +6 -24
- package/dist/{attachments.d-D1yhJjcZ.d.ts → attachments.d-CoQhXrP9.d.ts} +2 -2
- package/dist/{attachments.d-Bp2qbHxn.d.cts → attachments.d-CpaOfi2g.d.cts} +6 -24
- package/dist/{attachments.d-DisnvB9R.d.cts → attachments.d-CqHMGoER.d.cts} +2 -2
- package/dist/{bookingCopy.d-BlBmhAJc.d.cts → bookingCopy.d-Bnq2zk0F.d.cts} +2 -2
- package/dist/{bookingCopy.d-BJF6gd1A.d.ts → bookingCopy.d-BwCOCZUj.d.ts} +2 -2
- package/dist/{branding.d-DI8S400y.d.cts → branding.d-Bbc6p1XY.d.cts} +2 -2
- package/dist/{branding.d-OIGLbQeM.d.ts → branding.d-y6c0UwhE.d.ts} +2 -2
- package/dist/{casesRepository.d-CT2LTicS.d.cts → casesRepository.d-CsUJ2Oyb.d.cts} +1 -1
- package/dist/{casesRepository.d-UsWOz9bv.d.ts → casesRepository.d-DG83Ggbq.d.ts} +1 -1
- package/dist/chat/index.cjs +45 -43
- package/dist/chat/index.d.cts +26 -13
- package/dist/chat/index.d.ts +26 -13
- package/dist/chat/index.js +45 -43
- package/dist/client/index.cjs +3 -3
- package/dist/client/index.d.cts +12 -12
- package/dist/client/index.d.ts +12 -12
- package/dist/client/index.js +3 -3
- package/dist/clinicBatch.d-BLpbpS51.d.cts +71 -0
- package/dist/clinicBatch.d-Byjx4y_W.d.ts +71 -0
- package/dist/clinicModels.d-BXgKZqDb.d.cts +68 -0
- package/dist/clinicModels.d-CaS64-P-.d.ts +68 -0
- package/dist/clinicRequestProps.d-1dCtouGA.d.cts +65 -0
- package/dist/clinicRequestProps.d-CjsMg_OD.d.ts +65 -0
- package/dist/{config.d-BR3DT9ho.d.cts → config.d-C0WgjutL.d.cts} +1 -1
- package/dist/{config.d-Dy6igYlH.d.ts → config.d-zd2eTb2L.d.ts} +1 -1
- package/dist/consent/index.d.cts +5 -5
- package/dist/consent/index.d.ts +5 -5
- package/dist/{context.d-QcCgguzA.d.ts → context.d-BBjmV0rz.d.ts} +8 -8
- package/dist/{context.d-Cwks0p3C.d.cts → context.d-Du_UPxa1.d.cts} +8 -8
- package/dist/{copy.d-CiMn2IIt.d.ts → copy.d-D_VVj01o.d.ts} +2 -2
- package/dist/{copy.d-DLJTyRfT.d.cts → copy.d-Da_PP2K3.d.cts} +2 -2
- package/dist/core/index.cjs +3 -3
- package/dist/core/index.d.cts +21 -19
- package/dist/core/index.d.ts +21 -19
- package/dist/core/index.js +3 -3
- package/dist/{depth.d-OSALbYM7.d.ts → depth.d-BEedifOR.d.ts} +6 -133
- package/dist/{depth.d-CjPGVPDL.d.cts → depth.d-RTV61QNf.d.cts} +6 -133
- package/dist/{entitlementRepository.d-Cf3LbTwD.d.ts → entitlementRepository.d-BwThmh3V.d.ts} +4 -4
- package/dist/{entitlementRepository.d-CVQa1DA1.d.cts → entitlementRepository.d-C-stdRyA.d.cts} +4 -4
- package/dist/{features.d-fNsGcg0R.d.ts → features.d-DrQxTw3-.d.cts} +1 -1
- package/dist/{features.d-fNsGcg0R.d.cts → features.d-DrQxTw3-.d.ts} +1 -1
- package/dist/{focus.d-DMg2ngHI.d.ts → focus.d-CtotIyEt.d.ts} +127 -350
- package/dist/{focus.d-az9cqUz3.d.cts → focus.d-Dsm39DjO.d.cts} +127 -350
- package/dist/health-plan/index.cjs +182 -163
- package/dist/health-plan/index.d.cts +53 -11
- package/dist/health-plan/index.d.ts +53 -11
- package/dist/health-plan/index.js +185 -166
- package/dist/{idempotency.d-WpXx9zQo.d.ts → idempotency.d-Bfm7oIxS.d.cts} +158 -6
- package/dist/{idempotency.d-D461_DPD.d.cts → idempotency.d-Cv-B7SfC.d.ts} +158 -6
- package/dist/{identity.d-DzTijonw.d.ts → identity.d-BksOEa6m.d.ts} +1 -1
- package/dist/{identity.d-60LeJt_s.d.cts → identity.d-CioQhZrq.d.cts} +1 -1
- package/dist/index.cjs +48 -46
- package/dist/index.d.cts +20 -19
- package/dist/index.d.ts +20 -19
- package/dist/index.js +48 -46
- package/dist/introEvents.d-dS3fJCH1.d.cts +5 -0
- package/dist/introEvents.d-dS3fJCH1.d.ts +5 -0
- package/dist/introEvents.d-fAZitxMA.d.cts +175 -0
- package/dist/introEvents.d-tOi4o3F4.d.ts +175 -0
- package/dist/{models.d-BnLm3VAA.d.cts → models.d-BSqvbTE1.d.cts} +8 -1
- package/dist/{models.d-BagXhafD.d.ts → models.d-DOwnr8fi.d.ts} +8 -1
- package/dist/notifications/index.d.cts +4 -4
- package/dist/notifications/index.d.ts +4 -4
- package/dist/{optInView.d-acKpV8V2.d.ts → optInView.d-B8zTORO2.d.ts} +119 -3
- package/dist/{optInView.d-CEyHR6PK.d.cts → optInView.d-BkNSv4Gk.d.cts} +119 -3
- package/dist/{parse.d-C8CXyS58.d.ts → parse.d-B5JHS6Pr.d.ts} +1 -1
- package/dist/{parse.d-tEzufgJX.d.cts → parse.d-BgjO82mY.d.cts} +1 -1
- package/dist/{pets.d-NbJvP_kh.d.cts → pets.d-B_LoizOv.d.cts} +1 -1
- package/dist/{pets.d-C_53_fzo.d.ts → pets.d-OWxskXCP.d.ts} +1 -1
- package/dist/{petsRepository.d-lp1BHRqM.d.cts → petsRepository.d-B5DWzU7C.d.cts} +1 -1
- package/dist/{petsRepository.d-BuGHymNx.d.ts → petsRepository.d-Ba3xhJcj.d.ts} +1 -1
- package/dist/planSignals.d-Cl6n5QpS.d.cts +126 -0
- package/dist/planSignals.d-DtxZoWGM.d.ts +126 -0
- package/dist/{ports.d-COIyN624.d.ts → ports.d-BDtwHxmW.d.ts} +4 -4
- package/dist/{ports.d-CEROoqnA.d.cts → ports.d-gZNTn8Qf.d.cts} +4 -4
- package/dist/{presentation.d-DMbdad7G.d.cts → presentation.d-vy8kTGfR.d.cts} +6 -0
- package/dist/{presentation.d-DMbdad7G.d.ts → presentation.d-vy8kTGfR.d.ts} +6 -0
- package/dist/quickPrompts.d-NM_81Jc1.d.cts +19 -0
- package/dist/quickPrompts.d-NM_81Jc1.d.ts +19 -0
- package/dist/records/depth/index.d.cts +13 -9
- package/dist/records/depth/index.d.ts +13 -9
- package/dist/records/index.cjs +264 -140
- package/dist/records/index.d.cts +95 -24
- package/dist/records/index.d.ts +95 -24
- package/dist/records/index.js +265 -141
- package/dist/{requestFunnel.d-DWQQpjFR.d.cts → requestFunnel.d-CR4akGCY.d.cts} +2 -2
- package/dist/{requestFunnel.d-CXUMPw1K.d.ts → requestFunnel.d-DFf9C__p.d.ts} +2 -2
- package/dist/{resolve.d-jI8FmBj3.d.cts → resolve.d-CoQWUy1Y.d.cts} +1 -1
- package/dist/{resolve.d-jI8FmBj3.d.ts → resolve.d-CoQWUy1Y.d.ts} +1 -1
- package/dist/{runtimeTypes.d-4yFNNuYR.d.ts → runtimeTypes.d-BqBOrZxa.d.ts} +6 -6
- package/dist/{runtimeTypes.d-D6N_fhxx.d.cts → runtimeTypes.d-CHdH-y2c.d.cts} +6 -6
- package/dist/{useRecordsDepth.d-sAq2Qkhr.d.cts → screenProps.d-B1dIANI0.d.cts} +5 -91
- package/dist/{useRecordsDepth.d-DFcCfiXm.d.ts → screenProps.d-CVqFJw-J.d.ts} +5 -91
- 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/{sheetSeam.d-Cviqk89n.d.ts → sheetSeam.d-B09jf4YC.d.ts} +8 -4
- package/dist/{sheetSeam.d-DCS3LW8g.d.cts → sheetSeam.d-BBuEIVsa.d.cts} +8 -4
- package/dist/shop/index.cjs +227 -60
- package/dist/shop/index.d.cts +35 -5
- package/dist/shop/index.d.ts +35 -5
- package/dist/shop/index.js +228 -61
- package/dist/tabs/index.cjs +195 -0
- package/dist/tabs/index.d.cts +175 -0
- package/dist/tabs/index.d.ts +175 -0
- package/dist/tabs/index.js +195 -0
- package/dist/tabsModel.d-BfIQg6yS.d.cts +31 -0
- package/dist/tabsModel.d-BfIQg6yS.d.ts +31 -0
- package/dist/televet/booking/index.d.cts +6 -6
- package/dist/televet/booking/index.d.ts +6 -6
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/rn/index.cjs +1 -1
- package/dist/testing/rn/index.d.cts +12 -12
- package/dist/testing/rn/index.d.ts +12 -12
- package/dist/testing/rn/index.js +1 -1
- package/dist/testing/web/index.d.cts +13 -13
- package/dist/testing/web/index.d.ts +13 -13
- package/dist/texting/index.cjs +40 -5
- package/dist/texting/index.d.cts +40 -7
- package/dist/texting/index.d.ts +40 -7
- package/dist/texting/index.js +40 -5
- package/dist/threadOptions.d-CnSfFVMr.d.cts +458 -0
- package/dist/threadOptions.d-DZ0AoQGk.d.ts +458 -0
- package/dist/{timelineRows.d-BNxgzYRW.d.cts → timelineRows.d-CF1KvLcQ.d.cts} +1 -1
- package/dist/{timelineRows.d-CU5GvvLk.d.ts → timelineRows.d-CtL0y7y1.d.ts} +1 -1
- package/dist/{tokens.d-DarDaV39.d.cts → tokens.d-BUVqme2D.d.cts} +1 -1
- package/dist/{tokens.d-DarDaV39.d.ts → tokens.d-BUVqme2D.d.ts} +1 -1
- package/dist/{typeStyle.d-C1HBRAI3.d.ts → typeStyle.d-B3Kdtjie.d.ts} +2 -2
- package/dist/{typeStyle.d-Bl8pzbBy.d.cts → typeStyle.d-DmlwyJq-.d.cts} +2 -2
- package/dist/useIntroSeen.d-CTWFUthO.d.cts +35 -0
- package/dist/useIntroSeen.d-CTWFUthO.d.ts +35 -0
- package/dist/usePresentation.d-BsR08Wxt.d.ts +285 -0
- package/dist/usePresentation.d-CZS0qlLI.d.cts +285 -0
- package/dist/{useRecords.d-Cb-36SF5.d.cts → useRecords.d-BYNX01El.d.cts} +2 -2
- package/dist/{useRecords.d-aQTzQZoV.d.ts → useRecords.d-DWk61a4c.d.ts} +2 -2
- package/dist/useRecordsDepth.d-DTAxFf5s.d.ts +32 -0
- package/dist/useRecordsDepth.d-k-zYIHTe.d.cts +32 -0
- package/dist/{view.d-C-SNpDJX.d.ts → view.d-BE7VOlsB.d.ts} +6 -4
- package/dist/{view.d-Dps5C8-s.d.cts → view.d-CAWQjcY_.d.cts} +6 -4
- package/dist/web/consent/index.d.cts +5 -5
- package/dist/web/consent/index.d.ts +5 -5
- package/dist/web/health-plan/index.cjs +65 -53
- package/dist/web/health-plan/index.d.cts +46 -192
- package/dist/web/health-plan/index.d.ts +46 -192
- package/dist/web/health-plan/index.js +79 -67
- package/dist/web/index.cjs +62 -46
- package/dist/web/index.d.cts +168 -27
- package/dist/web/index.d.ts +168 -27
- package/dist/web/index.js +63 -47
- package/dist/web/intro/index.cjs +167 -0
- package/dist/web/intro/index.d.cts +79 -0
- package/dist/web/intro/index.d.ts +79 -0
- package/dist/web/intro/index.js +167 -0
- package/dist/web/notifications/index.d.cts +3 -3
- package/dist/web/notifications/index.d.ts +3 -3
- package/dist/web/records/depth/index.d.cts +13 -9
- package/dist/web/records/depth/index.d.ts +13 -9
- package/dist/web/records/index.cjs +7 -7
- package/dist/web/records/index.d.cts +21 -82
- package/dist/web/records/index.d.ts +21 -82
- package/dist/web/records/index.js +7 -7
- package/dist/web/records-sheet/index.cjs +207 -128
- package/dist/web/records-sheet/index.d.cts +25 -16
- package/dist/web/records-sheet/index.d.ts +25 -16
- package/dist/web/records-sheet/index.js +207 -128
- package/dist/web/shop/index.cjs +194 -78
- package/dist/web/shop/index.d.cts +21 -4
- package/dist/web/shop/index.d.ts +21 -4
- package/dist/web/shop/index.js +194 -78
- package/dist/web/televet/booking/index.d.cts +7 -7
- package/dist/web/televet/booking/index.d.ts +7 -7
- package/dist/web/texting/index.cjs +36 -5
- package/dist/web/texting/index.d.cts +40 -7
- package/dist/web/texting/index.d.ts +40 -7
- package/dist/web/texting/index.js +36 -5
- package/package.json +36 -4
- package/tabs/package.json +8 -0
- package/web/intro/native-blocked.cjs +12 -0
- package/web/intro/package.json +8 -0
- package/dist/threadOptions.d-B1pTMmDF.d.cts +0 -260
- package/dist/threadOptions.d-B1pTMmDF.d.ts +0 -260
- package/dist/usePresentation.d-D6qsFzBz.d.cts +0 -9
- package/dist/usePresentation.d-DuGQe_Do.d.ts +0 -9
package/dist/client/index.js
CHANGED
|
@@ -93,7 +93,7 @@ import{z}from"zod";var CONTRACT_RETRYABILITY=/* @__PURE__ */Object.freeze([
|
|
|
93
93
|
/* @__PURE__ */Object.freeze({wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
94
94
|
/* @__PURE__ */Object.freeze({wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false})]);/* @__PURE__ */Object.freeze(CONTRACT_RETRYABILITY.map(row=>row.wireCode));var NORMALIZED_FOLD=/* @__PURE__ */Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",session_revoked:"authExpired",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict"}),CONTRACT_ERROR_ROWS=/* @__PURE__ */Object.freeze(CONTRACT_RETRYABILITY.map(generated=>/* @__PURE__ */Object.freeze({wireCode:generated.wireCode,envelope:generated.envelope,retryable:generated.retryable,normalized:NORMALIZED_FOLD[generated.wireCode]}))),BY_KEY=new Map(CONTRACT_ERROR_ROWS.map(r=>[r.envelope+r.wireCode.toUpperCase(),r])),ENVELOPE_LOOKUP_ORDER=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(CONTRACT_ERROR_ROWS.map(r=>r.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(wireCode,envelope){if(typeof wireCode!="string")return;let key=wireCode.trim().toUpperCase();if(key.length!==0)for(let candidate of[envelope??"http_envelope",...ENVELOPE_LOOKUP_ORDER]){let row=BY_KEY.get(candidate+key);if(row)return row}}function contractDocUrl(entry){return entry.envelope==="sse_frame"?`/errors#sse-${entry.wireCode}`:entry.envelope==="oauth_error"?`/errors#oauth-${entry.wireCode}`:`/errors#${entry.wireCode}`}var DOC_SITE_ORIGIN=null;function publishedDocUrl(entry){return null}var EVERFUR_ERROR_CODES=/* @__PURE__ */Object.freeze(["authExpired","authRejected","sessionRequired","accessDenied","paymentRequired","quotaExceeded","rateLimited","validationFailed","sdkUpdateRequired","conflict","idempotencyConflict","idempotencyInFlight","conversationNotFound","petNotFound","resourceNotFound","streamTimeout","mediaUploadFailed","moderationBlocked","upstreamLlmTimeout","internalError","notImplemented","serviceUnavailable","streamIncomplete","identitySignatureRequired","runtimeDisposed","unknown"]),EVERFUR_ERROR_CATEGORIES=/* @__PURE__ */Object.freeze(["authentication","authorization","entitlement","rateLimit","invalidRequest","notFound","conflict","connection","server","media","policy","unknown"]),CATEGORY_OF=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function categoryFor(code){return CATEGORY_OF[code]}function fromWire(wire){let contractRow=contractErrorFor(wire);if(contractRow)return contractRow.normalized;let upper=(wire??"").trim().toUpperCase(),canonical=upper.replace(/[^A-Z0-9]/g,"");if(canonical==="AUTHREJECTED")return"authRejected";if(upper.startsWith("AUTH"))return"authExpired";switch(canonical){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}function fromHttpStatus(status){return status===401?"authExpired":status===403?"accessDenied":status===404?"conversationNotFound":status===409?"idempotencyConflict":status===421?"unknown":status===429?"rateLimited":status===400||status===422?"unknown":status>=500?"internalError":"unknown"}var AUTO_RETRYABLE_CODES=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(code){return AUTO_RETRYABLE_CODES.has(code)}var RETRYABLE_CONTRACT_CODES=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(code){return isAutoRetryable(code)||RETRYABLE_CONTRACT_CODES.has(code)}function shouldRetry(code,frameRetryable=false){return frameRetryable||isAutoRetryable(code)}var BACKOFF_BASE_MS=500,BACKOFF_CAP_MS=8e3,MAX_RETRY_ATTEMPTS=4;function backoffDelayMs(attempt,rng=Math.random){let bounded=Math.max(0,attempt),ceiling=Math.min(BACKOFF_BASE_MS*2**bounded,BACKOFF_CAP_MS);return Math.floor(rng()*ceiling)}function canRecreateOnNotFound(code){return code==="conversationNotFound"}var ACCESS_DENIED_COPY="This feature isn't available on your account right now.",VALIDATION_FAILED_COPY="Something in that request was not right. Check the details and try again.",USER_FACING_COPY=/* @__PURE__ */Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:ACCESS_DENIED_COPY,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:VALIDATION_FAILED_COPY,sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",identitySignatureRequired:ACCESS_DENIED_COPY,runtimeDisposed:VALIDATION_FAILED_COPY,unknown:"Something went wrong. Please try again."}),SESSION_REVOKED_COPY="This session has ended. Please sign in again.",LINKED_ACCOUNT_READ_ONLY="linked_account_read_only";function isLinkedAccountReadOnly(error){return error!=null&&error.code==="conflict"&&error.reasonCode===LINKED_ACCOUNT_READ_ONLY}function displayFor(code,wireCode,reasonCode){return code==="conflict"&&reasonCode===LINKED_ACCOUNT_READ_ONLY?ACCESS_DENIED_COPY:(code==="authRejected"||code==="authExpired")&&typeof wireCode=="string"&&wireCode.trim().toLowerCase()==="session_revoked"?SESSION_REVOKED_COPY:userFacingError(code)}function userFacingError(code){return USER_FACING_COPY[code]}function defineHidden(target,key,value){Object.defineProperty(target,key,{value:value,enumerable:false,writable:false,configurable:false})}var REASON_CODE_SHAPE=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(code,opts){let row=contractErrorFor(opts?.wireCode,opts?.wireEnvelope),linkedReadOnly=code==="conflict"&&opts?.reasonCode===LINKED_ACCOUNT_READ_ONLY,error={code:code,category:categoryFor(code),retryable:opts?.retryable??(linkedReadOnly?false:isRetryableCode(code)),displayMessage:displayFor(code,opts?.wireCode,linkedReadOnly?LINKED_ACCOUNT_READ_ONLY:null)};opts?.httpStatus!==void 0&&(error.httpStatus=opts.httpStatus),opts?.requestId&&(error.requestId=opts.requestId),typeof opts?.reasonCode=="string"&&REASON_CODE_SHAPE.test(opts.reasonCode)&&(error.reasonCode=opts.reasonCode);let wait=opts?.retryAfterSeconds;if(typeof wait=="number"&&Number.isFinite(wait)&&wait>=0&&(error.retryAfterSeconds=Math.round(wait)),row);return opts?.wireMessage&&defineHidden(error,"wireMessage",opts.wireMessage),opts?.raw!==void 0&&opts.raw!==null&&defineHidden(error,"raw",opts.raw),/* @__PURE__ */Object.freeze(error)}function ok(value,warning){/* @__PURE__ */
|
|
95
95
|
return Object.freeze(warning===void 0?{ok:true,value:value}:{ok:true,value:value,warning:warning})}function err(error){/* @__PURE__ */
|
|
96
|
-
return Object.freeze({ok:false,error:error})}function isOk(r){return r.ok}function isErr(r){return!r.ok}var EverfurThrownError=class _EverfurThrownError extends Error{constructor(error){super(`${error.code}: ${error.displayMessage}`),this.name="EverfurThrownError",this.error=error,this.code=error.code,this.category=error.category,Object.setPrototypeOf(this,_EverfurThrownError.prototype)}};function unwrap(r){if(r.ok)return r.value;throw new EverfurThrownError(r.error)}var EverfurConfigError=class _EverfurConfigError extends Error{constructor(kind,message){super(message),this.name="EverfurConfigError",this.kind=kind,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var SDK_VERSION="0.
|
|
96
|
+
return Object.freeze({ok:false,error:error})}function isOk(r){return r.ok}function isErr(r){return!r.ok}var EverfurThrownError=class _EverfurThrownError extends Error{constructor(error){super(`${error.code}: ${error.displayMessage}`),this.name="EverfurThrownError",this.error=error,this.code=error.code,this.category=error.category,Object.setPrototypeOf(this,_EverfurThrownError.prototype)}};function unwrap(r){if(r.ok)return r.value;throw new EverfurThrownError(r.error)}var EverfurConfigError=class _EverfurConfigError extends Error{constructor(kind,message){super(message),this.name="EverfurConfigError",this.kind=kind,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var SDK_VERSION="0.15.0",SDK_PLATFORM="react-native",DEFAULT_CONTRACT_VERSION="2026-09-19",ENV_API_BASE_URL="EVERFUR_API_BASE_URL";function configFailure(reason,message){/* @__PURE__ */
|
|
97
97
|
return Object.freeze({ok:false,failure:/* @__PURE__ */Object.freeze({reason:reason,message:message})})}function checkPublishableKey(raw){let publishableKey=typeof raw=="string"?raw.trim():"";return publishableKey.length===0?{reason:"missing-publishable-key",message:"publishableKey is required"}:/^sk[_-]/i.test(publishableKey)?{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}function tryResolveClientConfig(config,options){let keyFailure=checkPublishableKey(config?.publishableKey);if(keyFailure!==null)/* @__PURE__ */
|
|
98
98
|
return Object.freeze({ok:false,failure:keyFailure});let publishableKey=config.publishableKey.trim(),baseUrl=tryResolveApiBaseUrl(config.apiBaseUrl);if(!baseUrl.ok)return baseUrl;let contractVersion=config.contractVersion?.trim()||DEFAULT_CONTRACT_VERSION;/* @__PURE__ */
|
|
99
99
|
return Object.freeze({ok:true,config:/* @__PURE__ */Object.freeze({publishableKey:publishableKey,apiBaseUrl:baseUrl.value,contractVersion:contractVersion,sdkVersion:SDK_VERSION,platform:options?.platform??SDK_PLATFORM,debug:config.debug===true})})}function resolveClientConfig(config,options){let outcome=tryResolveClientConfig(config,options);if(!outcome.ok)throw new EverfurConfigError("invalid-argument",outcome.failure.message);return outcome.config}function tryResolveApiBaseUrl(apiBaseUrl){let explicit=apiBaseUrl?.trim(),candidate=explicit&&explicit.length>0?explicit:readEnv(ENV_API_BASE_URL);return candidate?normalizeBaseUrl(candidate):configFailure("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${ENV_API_BASE_URL}. The SDK never ships a hardcoded host.`)}function resolveApiBaseUrl(apiBaseUrl){let outcome=tryResolveApiBaseUrl(apiBaseUrl);if(!outcome.ok)throw new EverfurConfigError("invalid-argument",outcome.failure.message);return outcome.value}function buildBaseHeaders(cfg){return{"X-Everfur-SDK-Version":cfg.sdkVersion,"X-Everfur-SDK-Platform":cfg.platform,"X-Everfur-Contract":cfg.contractVersion}}var ABSOLUTE_URL=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function hostOf(authority){return authority.slice(authority.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}function isPrintableHost(host){return host.length===0||host.includes("@")?false:host.startsWith("[")&&host.endsWith("]")?true:!host.includes(":")}function canEchoOrigin(rawTrimmed,host){let schemeEnd=rawTrimmed.indexOf("://");return schemeEnd<0||rawTrimmed.slice(schemeEnd+3).includes("@")?false:isPrintableHost(host)}function safeOrigin(scheme,host){return`${scheme}://${host}`}function normalizeBaseUrl(raw){let trimmed=raw.trim(),match=ABSOLUTE_URL.exec(trimmed);if(match===null||match[2]===void 0||match[2].length===0)return configFailure("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let scheme=(match[1]??"").toLowerCase(),host=hostOf(match[2]);if(host.length===0)return configFailure("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let shown=canEchoOrigin(trimmed,host)?`: ${safeOrigin(scheme,host)}`:"";if(scheme!=="https"){if(!(scheme==="http"&&isLoopbackHost(host)))return scheme==="http"?configFailure("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${shown}`):configFailure("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${shown}`)}let value=trimmed.endsWith("/")?trimmed.slice(0,-1):trimmed;/* @__PURE__ */
|
|
@@ -110,8 +110,8 @@ return Object.freeze({granted:/* @__PURE__ */Object.freeze([...r.granted]),asGra
|
|
|
110
110
|
return Object.freeze({reason:explicit.reason,level:explicit.level,recoverable:explicit.recoverable})}/* @__PURE__ */
|
|
111
111
|
return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function freezeDecision(d){let base={name:d.name,enabled:d.enabled,isPending:d.isPending,limits:/* @__PURE__ */Object.freeze({...d.limits})};return d.disabled!==void 0&&(base.disabled=d.disabled),/* @__PURE__ */Object.freeze(base)}var FUNNEL_UNARY_TIMEOUT_MS=3e4,RETRY_OVERRIDE_MAX_MS=BACKOFF_CAP_MS*2,IDEMPOTENCY_HEADER="idempotency-key",MUTATING_METHODS=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),NOOP_OBSERVER=/* @__PURE__ */Object.freeze({onEvent(){}}),defaultFunnelTimers=/* @__PURE__ */Object.freeze({setTimeout:(handler,ms)=>setTimeout(handler,ms),clearTimeout:handle=>clearTimeout(handle),now:()=>Date.now()});function seededIdempotencyKey(seed){let safe=seed.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return safe.length===0?null:`efs_${safe}`.slice(0,128)}function createRequestFunnel(deps){let observer=deps.observer??NOOP_OBSERVER,timers=deps.timers??defaultFunnelTimers,rng=deps.rng??Math.random,sleep=deps.sleep??((ms,signal)=>delayAbortable(ms,timers,signal)),ceiling=deps.maxAttempts??MAX_RETRY_ATTEMPTS,timeoutMs=deps.unaryTimeoutMs??FUNNEL_UNARY_TIMEOUT_MS,mintKey=deps.newIdempotencyKey??defaultIdempotencyKeyFactory(),emit=event=>{try{observer.onEvent(event)}catch{}};async function send(call,req,opts){let perCallMaxAttempts=opts?.maxAttempts,maxAttempts=Math.max(1,perCallMaxAttempts??ceiling),idempotent=opts?.idempotent??MUTATING_METHODS.has(req.method),seeded=opts?.idempotencyKey===void 0?null:seededIdempotencyKey(opts.idempotencyKey),idempotencyKey=idempotent?seeded??mintKey():null,base=assembleHeaders(req,idempotencyKey),attempt=0;for(;;){let stamp=extra=>/* @__PURE__ */Object.freeze({call:call,method:req.method,path:req.path,attempt:attempt,...idempotencyKey?{idempotencyKey:idempotencyKey}:{},...extra});emit(stamp({phase:"attempt"}));let deadline=boundedSignal(timeoutMs,timers),merged=mergeSignals(deadline.signal,req.signal),settled;try{settled=await authedSend({...base,signal:merged.signal},deps.auth)}catch(cause){settled=err(networkError(cause))}finally{merged.dispose(),deadline.cancel()}if(settled.ok)return emit(stamp({phase:"settled",ok:true,reason:"ok"})),settled;let error=settled.error,decision=decideRetry(error,attempt,{maxAttempts:maxAttempts,rng:rng,now:timers.now(),aborted:req.signal?.aborted===true,...perCallMaxAttempts!==void 0?{perCallMaxAttempts:perCallMaxAttempts}:{},...deps.errorPolicy!==void 0?{policy:deps.errorPolicy}:{}}),settledEvent={ok:false,code:error.code,reason:decision.reason,...error.httpStatus!==void 0?{httpStatus:error.httpStatus}:{},...error.requestId!==void 0?{requestId:error.requestId}:{}};if(!decision.retry)return emit(stamp({phase:"settled",...settledEvent})),err(error);if(emit(stamp({phase:"retry",...settledEvent,delayMs:decision.delayMs})),await sleep(decision.delayMs,req.signal),req.signal?.aborted===true)return emit(stamp({phase:"settled",...settledEvent,reason:"aborted"})),err(error);attempt+=1}}async function authorize(req){return withAuthHeaders(req,await resolveDeviceAuth(deps.auth))}async function*stream(call,req,signal){emit(
|
|
112
112
|
/* @__PURE__ */Object.freeze({call:call,phase:"stream.open",method:req.method,path:req.path,attempt:0}));try{yield*deps.auth.transport.stream(req,signal)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null})}}/* @__PURE__ */
|
|
113
|
-
return Object.freeze({send:send,authorize:authorize,stream:stream})}function assembleHeaders(req,idempotencyKey){let headers={};for(let[key,value]of Object.entries(req.headers??{}))key.toLowerCase()!==IDEMPOTENCY_HEADER&&(headers[key]=value);return idempotencyKey!==null&&(headers["Idempotency-Key"]=idempotencyKey),{...req,headers:headers}}function defaultIdempotencyKeyFactory(){let counter=0;return()=>`efk_${Date.now().toString(36)}_${(counter++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var POLICY_MAX_ATTEMPTS_CAP=10;function decideRetry(error,attempt,ctx){if(ctx.aborted)return{retry:false,reason:"aborted"};let throttle=throttleKind(error);if(throttle==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(throttle!=="burst"&&!isAutoRetryable(error.code))return{retry:false,reason:"terminal-code"};let reason=throttle==="burst"?"burst-throttle":"retryable-code";if((()=>{if(ctx.policy===void 0)return false;try{return!ctx.policy.shouldRetry(error.code,attempt)}catch{return false}})())return{retry:false,reason:"terminal-code"};let policyCeiling=()=>{if(ctx.policy===void 0)return null;let raw;try{raw=ctx.policy.maxAttempts(error.code)}catch{return null}return typeof raw!="number"||!Number.isFinite(raw)?null:Math.max(1,Math.min(POLICY_MAX_ATTEMPTS_CAP,Math.floor(raw)))},ceiling=ctx.perCallMaxAttempts??policyCeiling()??ctx.maxAttempts;if(attempt+1>=ceiling)return{retry:false,reason:"attempts-exhausted"};let override=retryOverrideMs(error,ctx.now);return override!==null?override>RETRY_OVERRIDE_MAX_MS?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:reason,delayMs:override}:{retry:true,reason:reason,delayMs:backoffDelayMs(attempt,ctx.rng)}}function throttleKind(error){let code=error.code==="unknown"?fromWire(rawWireCode(error.raw)):error.code;return code==="quotaExceeded"?"quota":code==="rateLimited"||error.httpStatus===429?"burst":null}function retryOverrideMs(error,now){let at=findResetsAt(error.raw);if(at!==null){let delta=at-now;return delta>0?delta:0}let wait=findRetryAfterSeconds(error.raw);return wait===null?null:Math.round(wait*1e3)}function findRetryAfterSeconds(raw){for(let scope of candidateScopes(raw)){let value=scope.retry_after_seconds;if(typeof value=="number"&&Number.isFinite(value)&&value>=0)return value}return null}function findResetsAt(raw){for(let scope of candidateScopes(raw)){let value=scope.resets_at,parsed=parseInstantMs(value);if(parsed!==null)return parsed}return null}function candidateScopes(raw){if(!isRecord(raw))return[];let out=[raw];for(let nested of["error","detail"]){let value=raw[nested];isRecord(value)&&out.push(value)}return out}function parseInstantMs(value){if(typeof value=="number"&&Number.isFinite(value))return value<1e11?Math.round(value*1e3):Math.round(value);if(typeof value=="string"&&value.trim().length>0){let parsed=Date.parse(value);return Number.isFinite(parsed)?parsed:null}return null}function rawWireCode(raw){for(let scope of candidateScopes(raw)){let code=scope.code;if(typeof code=="string"&&code.length>0)return code}return null}function isRecord(value){return typeof value=="object"&&value!==null}async function resolveDeviceAuth(auth){return auth.mode==="anonymous"?{mode:"anonymous",publishableKey:auth.publishableKey,userRef:auth.userRef,...auth.sessionId?{sessionId:auth.sessionId}:{}}:{mode:"personalized",token:await auth.identity.currentToken(),userRef:auth.userRef,...auth.sessionId?{sessionId:auth.sessionId}:{}}}function boundedSignal(ms,timers){let ctrl=new AbortController,handle=timers.setTimeout(()=>ctrl.abort(),ms);return{signal:ctrl.signal,cancel:()=>timers.clearTimeout(handle)}}function mergeSignals(deadline,caller){let noop=()=>{};if(!caller)return{signal:deadline,dispose:noop};let ctrl=new AbortController;if(deadline.aborted||caller.aborted)return ctrl.abort(),{signal:ctrl.signal,dispose:noop};let onAbort=()=>ctrl.abort();return deadline.addEventListener("abort",onAbort,{once:true}),caller.addEventListener("abort",onAbort,{once:true}),{signal:ctrl.signal,dispose:()=>{deadline.removeEventListener("abort",onAbort),caller.removeEventListener("abort",onAbort)}}}function delayAbortable(ms,timers,signal){return ms<=0||signal?.aborted===true?Promise.resolve():new Promise(resolve=>{let handle=timers.setTimeout(()=>{signal?.removeEventListener("abort",onAbort),resolve()},ms),onAbort=()=>{timers.clearTimeout(handle),resolve()};signal?.addEventListener("abort",onAbort,{once:true})})}function parseColor(value){let rgba=toRgba(value);return rgba===null?null:normalizeRgba(rgba)}function toRgba(value){if(typeof value=="number")return argbIntToRgba(value);if(typeof value!="string")return null;let s=value.trim();if(s.length===0)return null;if(s.startsWith("#"))return fromHex(s.slice(1));if(s.toLowerCase().startsWith("0x"))return fromHex(s.slice(2));if(s.toLowerCase().startsWith("rgb"))return fromRgbFunc(s);if(/^[0-9a-fA-F]+$/.test(s)){let hex=fromHex(s);if(hex!==null)return hex}return/^\d+$/.test(s)?argbIntToRgba(Number.parseInt(s,10)):null}function fromHex(hex){let h=hex.trim();if(!/^[0-9a-fA-F]+$/.test(h))return null;if(h.length===3)return{r:dup(h[0]),g:dup(h[1]),b:dup(h[2]),a:1};if(h.length===6)return{r:byte(h,0),g:byte(h,2),b:byte(h,4),a:1};if(h.length===8){let a=byte(h,0);return{r:byte(h,2),g:byte(h,4),b:byte(h,6),a:a/255}}return null}function fromRgbFunc(input){let open=input.indexOf("("),close=input.indexOf(")");if(open<0||close<0||close<open)return null;let parts=input.slice(open+1,close).split(",").map(p=>p.trim());if(parts.length<3)return null;let r=clampByte(Number(parts[0])),g=clampByte(Number(parts[1])),b=clampByte(Number(parts[2]));if(r===null||g===null||b===null)return null;let a=1;if(parts.length>=4){let alpha=Number(parts[3]);if(!Number.isFinite(alpha))return null;a=Math.min(1,Math.max(0,alpha))}return{r:r,g:g,b:b,a:a}}function argbIntToRgba(n){if(!Number.isFinite(n))return null;let int=Math.trunc(n)>>>0,a=int>>>24&255;return{r:int>>>16&255,g:int>>>8&255,b:int&255,a:a===0?1:a/255}}function byte(hex,at){return Number.parseInt(hex.slice(at,at+2),16)}function dup(nibble){return Number.parseInt(`${nibble??"0"}${nibble??"0"}`,16)}function clampByte(n){return Number.isFinite(n)?Math.min(255,Math.max(0,Math.round(n))):null}function normalizeRgba(rgba){if(rgba.a>=1)return rgbToHex(rgba.r,rgba.g,rgba.b);let a=Math.round(rgba.a*1e3)/1e3;return`rgba(${rgba.r},${rgba.g},${rgba.b},${a})`}function rgbToHex(r,g,b){return`#${hex2(r)}${hex2(g)}${hex2(b)}`.toUpperCase()}function hex2(n){return n.toString(16).padStart(2,"0")}var NEAR_BLACK="#111111",WHITE="#FFFFFF",BLACK="#000000";function readableOn(background){let rgba=toRgba(background);if(rgba===null)return WHITE;let bg=relativeLuminance(rgba),black=relativeLuminance({r:17,g:17,b:17}),white=relativeLuminance({r:255,g:255,b:255});return luminanceContrast(bg,white)>=luminanceContrast(bg,black)?WHITE:NEAR_BLACK}function legibleOn(background,target){let first=readableOn(background);return contrastRatio(first,background)>=target?first:contrastRatio(WHITE,background)>=contrastRatio(BLACK,background)?WHITE:BLACK}function poleForGrounds(grounds){let worst=ink=>grounds.reduce((low,ground)=>Math.min(low,contrastRatio(ink,ground)),Number.POSITIVE_INFINITY);return worst(WHITE)>=worst(BLACK)?WHITE:BLACK}function relativeLuminance(rgba){let r=linearize(rgba.r/255),g=linearize(rgba.g/255),b=linearize(rgba.b/255);return.2126*r+.7152*g+.0722*b}function linearize(channel2){return channel2<=.03928?channel2/12.92:Math.pow((channel2+.055)/1.055,2.4)}function luminanceContrast(l1,l2){let lighter=Math.max(l1,l2),darker=Math.min(l1,l2);return(lighter+.05)/(darker+.05)}function contrastRatio(a,b){let fg=toRgba(a),bg=toRgba(b);if(fg===null||bg===null)return 1;let ground=bg.a>=1?bg:{...bg},fore=fg.a>=1?fg:composite(fg,ground);return luminanceContrast(relativeLuminance(fore),relativeLuminance(ground))}function composite(fg,bg){let a=fg.a,mix2=(f,g)=>Math.round(f*a+g*(1-a));return{r:mix2(fg.r,bg.r),g:mix2(fg.g,bg.g),b:mix2(fg.b,bg.b),a:1}}function flattenOnto(color,background){let fg=toRgba(color),bg=toRgba(background);if(fg===null||bg===null)return null;let out=fg.a>=1?fg:composite(fg,{...bg});return rgbToHex(out.r,out.g,out.b)}function withAlpha(color,alpha){let rgba=toRgba(color);if(rgba===null)return null;let a=Math.min(1,Math.max(0,alpha));return`rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${a})`}var PUSH_STEP=.05;function pushToContrast(color,grounds,pole,target){let first=grounds[0];if(first===void 0)return pole;let reads=candidate=>grounds.every(ground=>contrastRatio(candidate,ground)>=target);if(toRgba(color)===null)return pole;if(reads(color))return color;let flat=flattenOnto(color,first),from=flat===null?null:toRgba(flat),to=toRgba(pole);if(from===null||to===null)return pole;for(let step=1;step<1/PUSH_STEP;step+=1){let t=step*PUSH_STEP,mix2=(a,b)=>Math.round(a+(b-a)*t),candidate=rgbToHex(mix2(from.r,to.r),mix2(from.g,to.g),mix2(from.b,to.b));if(reads(candidate))return candidate}return pole}function rgbToHsl(r,g,b){let rn=r/255,gn=g/255,bn=b/255,mx=Math.max(rn,gn,bn),mn=Math.min(rn,gn,bn),l=(mx+mn)/2;if(mx===mn)return{h:0,s:0,l:l};let d=mx-mn,s=d/(1-Math.abs(2*l-1)),h;return mx===rn?(h=(gn-bn)/d*60,h<0&&(h=h+360)):mx===gn?h=((bn-rn)/d+2)*60:h=((rn-gn)/d+4)*60,{h:h,s:s,l:l}}function hslToRgb(hsl){let{h:h,s:s,l:l}=hsl,c=(1-Math.abs(2*l-1))*s,hp=h/60,x=c*(1-Math.abs(hp%2-1)),m=l-c/2,sector=Math.floor(hp)%6,rgb1=[[c,x,0],[x,c,0],[0,c,x],[0,x,c],[x,0,c],[c,0,x]],[r1,g1,b1]=rgb1[sector];return{r:channel(r1+m),g:channel(g1+m),b:channel(b1+m)}}function channel(v){return Math.min(255,Math.max(0,Math.floor(v*255+.5)))}var THEME_SLOT_NAMES=/* @__PURE__ */Object.freeze(["composerInput","sendButton","userBubble","assistantBubble","vetBubble","recordCard","vetVisitButton","primaryButton","link","header","banner","chip","card","input","tab","bookingStep","dialog","cartBar","planCard","planReasonLabel"]),THEME_SLOT_KEYS=/* @__PURE__ */Object.freeze(["backgroundColor","borderColor","borderRadius","textColor"]),THEME_SLOT_KEYS_BY_SLOT=/* @__PURE__ */Object.freeze({planReasonLabel:/* @__PURE__ */Object.freeze(["textColor"])});function themeSlotKeysFor(name){return THEME_SLOT_KEYS_BY_SLOT[name]??THEME_SLOT_KEYS}var SLOT_MIN_CONTRAST=4.5,EMPTY=/* @__PURE__ */Object.freeze({});function isSlotName(value){return THEME_SLOT_NAMES.includes(value)}function parseRadius(value){let text2=typeof value=="string"&&value.length<=16?value.trim().replace(/ ?px$/i,""):null,n=typeof value=="number"?value:text2!==null&&text2.length>0?Number(text2):Number.NaN;return Number.isFinite(n)?Math.max(0,n):null}function parseThemeSlots(json){if(json===null||typeof json!="object"||Array.isArray(json))return null;let out={},any=false;for(let[name,raw]of Object.entries(json)){if(!isSlotName(name)||raw===null||typeof raw!="object")continue;let parsed=parseSlot(raw);if(parsed===null)continue;let slot=restrictSlotKeys(name,parsed);slot!==null&&(out[name]=slot,any=true)}return any?/* @__PURE__ */Object.freeze(out):null}function restrictSlotKeys(name,slot){let allowed=THEME_SLOT_KEYS_BY_SLOT[name];if(allowed===void 0)return slot;let out={};for(let key of allowed)slot[key]!==void 0&&(out[key]=slot[key]);return Object.keys(out).length===0?null:/* @__PURE__ */Object.freeze(out)}function pick(raw,snake,camel){return raw[snake]!==void 0?raw[snake]:raw[camel]}function parseSlot(raw){let slot={},backgroundColor=parseColor(pick(raw,"background_color","backgroundColor"));backgroundColor!==null&&(slot.backgroundColor=backgroundColor);let borderColor=parseColor(pick(raw,"border_color","borderColor"));borderColor!==null&&(slot.borderColor=borderColor);let borderRadius=parseRadius(pick(raw,"border_radius","borderRadius"));borderRadius!==null&&(slot.borderRadius=borderRadius);let textColor=parseColor(pick(raw,"text_color","textColor"));return textColor!==null&&(slot.textColor=textColor),Object.keys(slot).length===0?null:/* @__PURE__ */Object.freeze(slot)}function mergeThemeSlots(base,over){return over===null||Object.keys(over).length===0?base??EMPTY:base===null||Object.keys(base).length===0?over:/* @__PURE__ */Object.freeze({...base,...over})}function isOpaque(color){let rgba=toRgba(color);return rgba!==null&&rgba.a>=1}var SLOT_MIN_BORDER_CONTRAST=3,DECORATIVE_EDGE_SLOTS=/* @__PURE__ */new Set(["card","recordCard","banner","header","dialog","bookingStep","cartBar","planCard"]);function sameColor(a,b){let left=parseColor(a);return left!==null&&left===parseColor(b)}function boundaryFor(fill,surrounds,seats=[]){if(surrounds.length===0)return null;let shown=surrounds.map(ground=>flattenOnto(fill,ground)??fill);if(surrounds.every((ground,index)=>contrastRatio(shown[index],ground)>=SLOT_MIN_BORDER_CONTRAST))return null;let against=[...surrounds,...shown,...seats];return pushToContrast(shown[0],against,poleForGrounds(against),SLOT_MIN_BORDER_CONTRAST)}function seatsOf(background,defaults){return background===void 0?defaults:defaults.length===0?[background]:defaults.map(ground=>flattenOnto(background,ground)??ground)}function someInkReads(seats,target){let pole=poleForGrounds(seats);return seats.every(seat=>contrastRatio(pole,seat)>=target)}function collapseUnsatisfiableFill(background,defaults){let ground=defaults[0];return ground===void 0?null:flattenOnto(background,ground)}function inkFor(seats){let pick5=legibleOn(seats[0],SLOT_MIN_CONTRAST);return seats.every(seat=>contrastRatio(pick5,seat)>=SLOT_MIN_CONTRAST)?pick5:poleForGrounds(seats)}function edgeShowsTheControl(name,edge,fill,around,melts){return DECORATIVE_EDGE_SLOTS.has(name)?false:melts?true:fill!==void 0&&sameColor(edge,fill)?false:!(around!==void 0&&fill!==void 0&&isOpaque(fill))}function guardSlotContrast(slots,grounds,surrounds){let changed=false,out={};for(let name of THEME_SLOT_NAMES){let slot=slots[name];if(slot===void 0)continue;let bg=slot.backgroundColor,defaults=grounds?.[name]??[],seats=seatsOf(bg,defaults),next={...slot},fixed=false;if(bg!==void 0&&seats.length>1&&!someInkReads(seats,SLOT_MIN_CONTRAST)){let opaque=collapseUnsatisfiableFill(bg,defaults);opaque!==null&&(next.backgroundColor=opaque,seats=[opaque],fixed=true)}let around=surrounds?.[name],fill=next.backgroundColor,melts=around!==void 0&&fill!==void 0&&isOpaque(fill)&&boundaryFor(fill,around,seats)!==null;if(seats.length>0){let ink=slot.textColor;if(bg!==void 0)(ink===void 0||seats.some(seat=>contrastRatio(ink,seat)<SLOT_MIN_CONTRAST))&&(next.textColor=inkFor(seats),fixed=true);else if(ink!==void 0){let legible=pushToContrast(ink,seats,poleForGrounds(seats),SLOT_MIN_CONTRAST);legible!==ink&&(next.textColor=legible,fixed=true)}if(slot.borderColor!==void 0&&edgeShowsTheControl(name,slot.borderColor,fill,around,melts)){let against=melts?[...seats,...around??[]]:seats,edge=pushToContrast(slot.borderColor,against,poleForGrounds(against),SLOT_MIN_BORDER_CONTRAST);edge!==slot.borderColor&&(next.borderColor=edge,fixed=true)}}if(melts&&fill!==void 0&&around!==void 0&&next.borderColor===void 0){let edge=boundaryFor(fill,around,seats);edge!==null&&(next.borderColor=edge,fixed=true)}out[name]=fixed?/* @__PURE__ */Object.freeze(next):slot,changed=changed||fixed}return changed?/* @__PURE__ */Object.freeze(out):slots}var freezeInPlace=Object.freeze;function deepFreeze(value){if(value!==null&&typeof value=="object"&&!Object.isFrozen(value)){freezeInPlace(value);for(let key of Object.keys(value))deepFreeze(value[key])}return value}var TEXT_SCALE_TIER_CAPS=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),SPACE={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},RADIUS={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},TYPE_SIZE={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},LINE_HEIGHT={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},WEIGHT={regular:"400",medium:"500",bold:"700"},LETTER_SPACING={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},DEFAULT_MAX_FONT_SCALE=0,SYSTEM_FONT_FAMILY="System",SYSTEM_MONO_FAMILY="monospace",TIERS=["content","heading","control","compact","badge"];function authoredTierSizes(size){let out={};for(let tier of TIERS)out[tier]=size;return out}var NO_FONT_SOURCES=[];function baseType(){return{family:SYSTEM_FONT_FAMILY,mono:SYSTEM_MONO_FAMILY,fontUrl:null,families:{regular:SYSTEM_FONT_FAMILY,medium:SYSTEM_FONT_FAMILY,bold:SYSTEM_FONT_FAMILY,mono:SYSTEM_MONO_FAMILY,monoMedium:SYSTEM_MONO_FAMILY,monoBold:SYSTEM_MONO_FAMILY},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:TYPE_SIZE,tierSizes:authoredTierSizes(TYPE_SIZE),lineHeight:LINE_HEIGHT,weight:WEIGHT,letterSpacing:LETTER_SPACING,scale:1,maxScale:DEFAULT_MAX_FONT_SCALE,scaleCaps:TEXT_SCALE_TIER_CAPS,headingFamily:null,headingWeight:null,fontSources:NO_FONT_SOURCES}}var NO_SLOTS={},EASING_CURVES=/* @__PURE__ */Object.freeze({standard:/* @__PURE__ */Object.freeze([.2,0,0,1]),emphasized:/* @__PURE__ */Object.freeze([.2,.8,.2,1]),exit:/* @__PURE__ */Object.freeze([.4,0,1,1])});function cssCubicBezier(curve){return`cubic-bezier(${curve.join(", ")})`}var MOTION={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(EASING_CURVES.standard),emphasized:cssCubicBezier(EASING_CURVES.emphasized),exit:cssCubicBezier(EASING_CURVES.exit)},reducedMotion:false},LIGHT_COLOR={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",highlight:"#FFC3BC",onHighlight:"#000000",mark:"#07C168",controlEdge:"rgba(16,70,46,0.18)",structureEdge:"rgba(16,70,46,0.25)",primaryEdge:"#10462E",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)",info:"#10462E",badgeBgInfo:"rgba(16,70,46,0.10)",infoEdge:"rgba(16,70,46,0.25)"},EVERFUR_LIGHT=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:LIGHT_COLOR,space:SPACE,radius:RADIUS,type:baseType(),motion:MOTION,slots:NO_SLOTS}),DARK_COLOR={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",highlight:"#605051",onHighlight:"#F5F3F0",mark:"#07C168",controlEdge:"rgba(107,211,154,0.22)",structureEdge:"rgba(107,211,154,0.28)",primaryEdge:"#6BD39A",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)",info:"#6BD39A",badgeBgInfo:"rgba(107,211,154,0.12)",infoEdge:"rgba(107,211,154,0.28)"},EVERFUR_DARK=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:DARK_COLOR,space:SPACE,radius:RADIUS,type:baseType(),motion:MOTION,slots:NO_SLOTS});function textGrounds(c){return[c.surface,c.surfaceCream,c.surfaceSubtle,c.background,c.chatGround,c.composerFill]}function controlGrounds(c){return[c.surface,c.surfaceCream,c.background,c.chatGround,c.composerFill]}function brandReadsOnControls(c){return controlGrounds(c).every(ground=>contrastRatio(c.brand,ground)>=SLOT_MIN_BORDER_CONTRAST)}function linkGrounds(c){return[c.chatGround,c.surface,c.surfaceCream]}function statusGrounds(c,wash2){return[c.surface,c.surfaceCream,c.background,c.chatGround,c.composerFill,...washGrounds(c,wash2)]}function washGrounds(c,wash2){return[flattenOnto(wash2,c.surface)??c.surface,flattenOnto(wash2,c.surfaceCream)??c.surfaceCream]}function composerGrounds(c){return[c.composerFill,c.chatGround]}var AUTHORED_AS_IS=/* @__PURE__ */new Set(["text.timestamp","text.placeholder","errorRed","warningStrong","composerBorder"]);function onCompiledGrounds(c,compiled){let own=new Set(textGrounds(compiled));return textGrounds(c).every(ground=>own.has(ground))}function guardInks(theme){let c=theme.color,compiled=(theme.brightness==="dark"?EVERFUR_DARK:EVERFUR_LIGHT).color,other=(theme.brightness==="dark"?EVERFUR_LIGHT:EVERFUR_DARK).color,grounds=textGrounds(c),flipped=poleForGrounds(grounds)!==poleForGrounds(textGrounds(compiled)),keepCompiled=onCompiledGrounds(c,compiled),dangerIsCompiled=c.danger===compiled.danger&&c.badgeBgCritical===compiled.badgeBgCritical,ink=(name,value,authored,twin,on,target)=>{let untouched=value===authored&&(name!=="errorRed"||dangerIsCompiled);return untouched&&keepCompiled&&AUTHORED_AS_IS.has(name)?value:pushToContrast(untouched&&flipped?twin:value,on,poleForGrounds(on),target)},text2=(key,on,target)=>ink(`text.${key}`,c.text[key],compiled.text[key],other.text[key],on,target),token=(key,value,on,target)=>ink(key,value,compiled[key],other[key],on,target),tint=key=>flipped&&c[key]===compiled[key]?other[key]:c[key],primary=c.primary,onPrimary=legibleOn(primary,SLOT_MIN_CONTRAST),danger=token("danger",c.danger,[...grounds,...washGrounds(c,c.badgeBgCritical)],SLOT_MIN_CONTRAST),guarded={...c,onPrimary:onPrimary,onAccent:legibleOn(c.accent,SLOT_MIN_CONTRAST),onDanger:contrastRatio(onPrimary,danger)>=SLOT_MIN_CONTRAST?onPrimary:legibleOn(danger,SLOT_MIN_CONTRAST),brandSoft:tint("brandSoft"),brandSofter:tint("brandSofter"),brandBorder:tint("brandBorder"),borderHairlineGreen:tint("borderHairlineGreen"),brandInk:token("brandInk",c.brandInk,grounds,SLOT_MIN_CONTRAST),linkInk:token("linkInk",theme.slots.link?.textColor??c.accent,linkGrounds(c),SLOT_MIN_CONTRAST),text:{...c.text,primary:text2("primary",grounds,SLOT_MIN_CONTRAST),secondary:text2("secondary",grounds,SLOT_MIN_CONTRAST),muted:text2("muted",grounds,SLOT_MIN_CONTRAST),metaCool:text2("metaCool",grounds,SLOT_MIN_CONTRAST),timestamp:text2("timestamp",grounds,SLOT_MIN_CONTRAST),placeholder:text2("placeholder",controlGrounds(c),SLOT_MIN_BORDER_CONTRAST)},danger:danger,errorRed:token("errorRed",c.errorRed,statusGrounds(c,c.badgeBgCritical),SLOT_MIN_CONTRAST),warningStrong:token("warningStrong",c.warningStrong,statusGrounds(c,c.badgeBgCaution),SLOT_MIN_CONTRAST),composerBorder:token("composerBorder",c.composerBorder,composerGrounds(c),SLOT_MIN_BORDER_CONTRAST),brandBorderStrong:token("brandBorderStrong",c.brandBorderStrong,controlGrounds(c),SLOT_MIN_BORDER_CONTRAST)},accented={...guarded,...accentFamily(guarded,compiled,keepCompiled)};return{...accented,...statusInks(c,accented,compiled)}}function statusInks(merged,g,compiled){let out={},push=(value,on,target)=>pushToContrast(value,on,poleForGrounds(on),target);if((!same(merged.success,compiled.success)||!same(merged.badgeBgPositive,compiled.badgeBgPositive))&&(out.success=push(merged.success,statusGrounds(g,merged.badgeBgPositive),SLOT_MIN_CONTRAST)),(!same(merged.cautionAccent,compiled.cautionAccent)||!same(merged.badgeBgCaution,compiled.badgeBgCaution))&&(out.cautionAccent=push(merged.cautionAccent,statusGrounds(g,merged.badgeBgCaution),SLOT_MIN_CONTRAST)),isPartnerInfo(merged,compiled)){out.info=push(merged.info,statusGrounds(g,merged.badgeBgInfo),SLOT_MIN_CONTRAST);let edgeGrounds=[g.surface,g.chatGround,...washGrounds(g,merged.badgeBgInfo)];out.infoEdge=push(merged.infoEdge,edgeGrounds,SLOT_MIN_BORDER_CONTRAST)}else out.info=g.brandInk,out.badgeBgInfo=g.brandSoft,out.infoEdge=g.structureEdge;return out}function isPartnerInfo(c,compiled){return!same(c.info,compiled.info)||!same(c.badgeBgInfo,compiled.badgeBgInfo)}var HIGHLIGHT_LIGHT_TINT=.24,HIGHLIGHT_DARK_TINT=.3;function same(a,b){return parseColor(a)===parseColor(b)}function partnerHue(c,compiled){return same(c.accent,compiled.accent)?same(c.brand,compiled.brand)?null:c.brand:c.accent}function tintOver(hue,surface,tint){let wash2=withAlpha(hue,tint);return(wash2===null?null:flattenOnto(wash2,surface))??surface}function accentFamily(c,compiled,keepCompiled){let hue=partnerHue(c,compiled),controls=controlGrounds(c),controlPole=poleForGrounds(controls),darkGround=poleForGrounds([c.surface])===WHITE,everfurMarks=hue===null&&keepCompiled,highlight;everfurMarks?highlight=compiled.highlight:hue===null?highlight=darkGround?tintOver(EVERFUR_LIGHT.color.highlight,c.surface,HIGHLIGHT_DARK_TINT):EVERFUR_LIGHT.color.highlight:highlight=tintOver(hue,c.surface,darkGround?HIGHLIGHT_DARK_TINT:HIGHLIGHT_LIGHT_TINT);let onHighlight=everfurMarks?compiled.onHighlight:pushToContrast(c.text.primary,[highlight],poleForGrounds([highlight]),SLOT_MIN_CONTRAST),mark=hue===null?compiled.mark:pushToContrast(hue,controls,controlPole,SLOT_MIN_BORDER_CONTRAST),toward=brandReadsOnControls(c)?c.brand:controlPole,edge=(value,authored,compiledEdge)=>keepCompiled&&same(value,authored)?compiledEdge:pushToContrast(value,controls,toward,SLOT_MIN_BORDER_CONTRAST),primaryGrounds=[c.chatGround,c.composerFill,c.surface,c.surfaceCream],primaryEdge=primaryGrounds.every(ground=>contrastRatio(c.primary,ground)>=SLOT_MIN_BORDER_CONTRAST)?c.primary:pushToContrast(c.primary,primaryGrounds,poleForGrounds(primaryGrounds),SLOT_MIN_BORDER_CONTRAST);return{highlight:highlight,onHighlight:onHighlight,mark:mark,controlEdge:edge(c.brandBorder,compiled.brandBorder,compiled.controlEdge),structureEdge:edge(c.borderHairlineGreen,compiled.borderHairlineGreen,compiled.structureEdge),primaryEdge:primaryEdge}}var same2=(a,b)=>a!==void 0&&b!==void 0&&parseColor(a)===parseColor(b);function diffThemeAdjustments(merged,resolved){let compiled=(merged.brightness==="dark"?EVERFUR_DARK:EVERFUR_LIGHT).color,m=merged.color,r=resolved.color,out=[],add=(field,role,requested,painted)=>{out.push(/* @__PURE__ */Object.freeze({field:field,role:role,requested:requested,painted:painted}))},own=(value,compiledValue)=>!same2(value,compiledValue);own(m.text.primary,compiled.text.primary)&&!same2(r.text.primary,m.text.primary)&&add("text_color","body text",m.text.primary,r.text.primary),own(m.brand,compiled.brand)&&(same2(r.brandInk,m.brand)||add("primary_color","brand text and icons",m.brand,r.brandInk),same2(r.primaryEdge,m.primary)||add("primary_color","edge of a filled control",m.primary,r.primaryEdge),!same2(r.controlEdge,m.brandBorder)&&!brandReadsOnControls({...r,brand:m.brand})&&add("primary_color","control outline",m.brand,r.controlEdge)),own(m.accent,compiled.accent)&&merged.slots.link?.textColor===void 0&&!same2(r.linkInk,m.accent)&&add("accent_color","link text",m.accent,r.linkInk),own(m.danger,compiled.danger)&&!same2(r.danger,m.danger)&&add("danger_color","error text",m.danger,r.danger),own(m.success,compiled.success)&&!same2(r.success,m.success)&&add("success_color","positive status",m.success,r.success),own(m.warningStrong,compiled.warningStrong)&&!same2(r.warningStrong,m.warningStrong)&&add("warning_color","caution text",m.warningStrong,r.warningStrong),own(m.cautionAccent,compiled.cautionAccent)&&!same2(r.cautionAccent,m.cautionAccent)&&add("warning_color","caution accent",m.cautionAccent,r.cautionAccent),(own(m.info,compiled.info)||own(m.badgeBgInfo,compiled.badgeBgInfo))&&(same2(r.info,m.info)||add("info_color","information text",m.info,r.info),same2(r.infoEdge,m.infoEdge)||add("info_color","information outline",m.infoEdge,r.infoEdge));for(let name of THEME_SLOT_NAMES){let before=merged.slots[name],after=resolved.slots[name];before===void 0||after===void 0||before===after||(after.backgroundColor!==void 0&&!same2(after.backgroundColor,before.backgroundColor)&&add(`slots.${name}.background_color`,"fill",before.backgroundColor??null,after.backgroundColor),before.textColor!==void 0&&after.textColor!==void 0&&!same2(after.textColor,before.textColor)&&add(`slots.${name}.text_color`,"text",before.textColor??null,after.textColor),after.borderColor!==void 0&&!same2(after.borderColor,before.borderColor)&&add(`slots.${name}.border_color`,"outline",before.borderColor??null,after.borderColor))}/* @__PURE__ */
|
|
114
|
-
return Object.freeze(out)}var DARK_VARIANT_GROUND="#23272C",DARK_VARIANT_TARGET_RATIO=4.5,DARK_VARIANT_LIGHTNESS_FLOOR=.6,DARK_VARIANT_LIGHTNESS_CEILING=.9,DARK_VARIANT_LIGHTNESS_STEP=.02,WHITE_INK="#FFFFFF",NEAR_BLACK_INK="#111111";function readsOnDark(candidate){return contrastRatio(candidate,DARK_VARIANT_GROUND)>=DARK_VARIANT_TARGET_RATIO&&Math.max(contrastRatio(candidate,WHITE_INK),contrastRatio(candidate,NEAR_BLACK_INK))>=DARK_VARIANT_TARGET_RATIO}function deriveDarkVariant(color){let rgba=toRgba(color);if(rgba===null)return null;let{h:h,s:s,l:l}=rgbToHsl(rgba.r,rgba.g,rgba.b),lDark=Math.min(Math.max(l,DARK_VARIANT_LIGHTNESS_FLOOR),DARK_VARIANT_LIGHTNESS_CEILING);for(let i=0;;i+=1){let li=lDark+i*DARK_VARIANT_LIGHTNESS_STEP;if(li>DARK_VARIANT_LIGHTNESS_CEILING)break;let rgb=hslToRgb({h:h,s:s,l:li}),candidate=rgbToHex(rgb.r,rgb.g,rgb.b);if(readsOnDark(candidate))return candidate}let ceiling=hslToRgb({h:h,s:s,l:DARK_VARIANT_LIGHTNESS_CEILING});return rgbToHex(ceiling.r,ceiling.g,ceiling.b)}var HIGH_CONTRAST_TARGET_RATIO=7,PUSH_STEP2=.05,BLACK2="#000000",WHITE2="#FFFFFF";function pushContrast(color,ground,pole,target){let flat=flattenOnto(color,ground);if(flat===null)return pole;if(contrastRatio(flat,ground)>=target)return flat;let from=toRgba(flat),to=toRgba(pole);if(from===null||to===null)return pole;for(let step=1;step<1/PUSH_STEP2;step+=1){let t=step*PUSH_STEP2,mix2=(a,b)=>Math.round(a+(b-a)*t),candidate=rgbToHex(mix2(from.r,to.r),mix2(from.g,to.g),mix2(from.b,to.b));if(contrastRatio(candidate,ground)>=target)return candidate}return pole}function hardestGround(color,dark){let grounds=textGrounds(color),pick5=grounds[0],pickLum=luminanceOf(pick5);for(let ground of grounds){let lum=luminanceOf(ground);(dark?lum>pickLum:lum<pickLum)&&(pick5=ground,pickLum=lum)}return pick5}function luminanceOf(color){let rgba=toRgba(color);return rgba===null?0:relativeLuminance(rgba)}function solid(wash2,surface){return flattenOnto(wash2,surface)??parseColor(wash2)??surface}function deriveHighContrast(theme){let c=theme.color,lightInk=poleForGrounds(textGrounds(c))===WHITE2,pole=lightInk?WHITE2:BLACK2,ground=hardestGround(c,lightInk),text2=color2=>pushContrast(color2,ground,pole,HIGH_CONTRAST_TARGET_RATIO),color={...c,brandSoft:solid(c.brandSoft,c.surface),brandSofter:solid(c.brandSofter,c.surface),brandBorder:text2(c.brandBorder),borderHairlineGreen:text2(c.borderHairlineGreen),brandBorderStrong:text2(c.brandBorderStrong),controlEdge:text2(c.controlEdge),structureEdge:text2(c.structureEdge),brandInk:text2(c.brandInk),linkInk:text2(c.linkInk),borderRingCream:text2(c.borderRingCream),composerBorder:text2(c.composerBorder),text:{primary:text2(c.text.primary),secondary:text2(c.text.secondary),muted:text2(c.text.muted),placeholder:text2(c.text.placeholder),onBrand:c.text.onBrand,metaCool:text2(c.text.metaCool),timestamp:text2(c.text.timestamp)},badgeBgPositive:solid(c.badgeBgPositive,c.surface),badgeBgCaution:solid(c.badgeBgCaution,c.surface),badgeBgCritical:solid(c.badgeBgCritical,c.surface),badgeBgNeutral:solid(c.badgeBgNeutral,c.surface),checkupCardLowRiskBg:solid(c.checkupCardLowRiskBg,c.surface),checkupCardConcernBg:solid(c.checkupCardConcernBg,c.surface),info:text2(c.info),infoEdge:text2(c.infoEdge),badgeBgInfo:solid(c.badgeBgInfo,c.surface)};return deepFreeze({...theme,highContrast:true,color:color})}var BACKGROUND_STEPS=/* @__PURE__ */Object.freeze({cream:.03,subtle:.07,ring:.16}),CREAM_STEP=BACKGROUND_STEPS.cream,SUBTLE_STEP=BACKGROUND_STEPS.subtle,RING_STEP=BACKGROUND_STEPS.ring,MIN_DERIVED_TYPE_SIZE=10;function mix(color,toward,t){let from=toRgba(color),to=toRgba(toward);if(from===null||to===null)return null;let at=(a,b)=>Math.round(a+(b-a)*t);return rgbToHex(at(from.r,to.r),at(from.g,to.g),at(from.b,to.b))}function surfaceFamily(background){if(background===null)return{};let pole=poleForGrounds([background]),cream=mix(background,pole,CREAM_STEP),subtle=mix(background,pole,SUBTLE_STEP),ring=mix(background,pole,RING_STEP);return cream===null||subtle===null||ring===null?{}:{surface:background,background:background,chatGround:background,bubbleAssistant:background,surfaceCream:cream,composerFill:cream,surfaceSubtle:subtle,skeleton:subtle,borderRingCream:ring}}function dangerFamily(danger){if(danger===null)return{};let rgba=toRgba(danger);return rgba===null?{}:{danger:danger,errorRed:danger,badgeBgCritical:`rgba(${rgba.r},${rgba.g},${rgba.b},0.12)`}}function typeSizesFor(base,current,compiled){if(base===null)return current;let factor=base/compiled.type.size.body;if(factor===1)return compiled.type.size;let out={};for(let[key,value]of Object.entries(compiled.type.size))out[key]=Math.max(MIN_DERIVED_TYPE_SIZE,Math.round(value*factor*10)/10);return out}function spaceFor(unit,current,compiled){if(unit===null)return current;let factor=unit/compiled.space.xs,s=n=>Math.round(n*factor),c=compiled.space;return{xs:s(c.xs),sm:s(c.sm),md:s(c.md),lg:s(c.lg),xl:s(c.xl),xxl:s(c.xxl)}}function radiiFor(base,compiled){let factor=base/compiled.radius.md,s=n=>Math.round(n*factor),r=compiled.radius;return{tile:s(r.tile),xs:s(r.xs),sm:s(r.sm),md:s(r.md),lg:s(r.lg),xl:s(r.xl),pill:r.pill}}var STATUS_WASH=/* @__PURE__ */Object.freeze({success:/* @__PURE__ */Object.freeze({light:.12,dark:.18}),successCard:/* @__PURE__ */Object.freeze({light:.1,dark:.16}),warning:/* @__PURE__ */Object.freeze({light:.14,dark:.2}),info:/* @__PURE__ */Object.freeze({light:.1,dark:.12})});function wash(color,alpha){let rgba=toRgba(color);return rgba===null?null:`rgba(${rgba.r},${rgba.g},${rgba.b},${alpha})`}function successFamily(color,dark){if(color===null)return{};let badge=wash(color,dark?STATUS_WASH.success.dark:STATUS_WASH.success.light),card=wash(color,dark?STATUS_WASH.successCard.dark:STATUS_WASH.successCard.light);return badge===null||card===null?{}:{success:color,badgeBgPositive:badge,checkupCardLowRiskBg:card}}function warningFamily(color,dark){if(color===null)return{};let badge=wash(color,dark?STATUS_WASH.warning.dark:STATUS_WASH.warning.light);return badge===null?{}:{warningStrong:color,cautionAccent:color,badgeBgCaution:badge}}function infoFamily(color,dark){if(color===null)return{};let badge=wash(color,dark?STATUS_WASH.info.dark:STATUS_WASH.info.light);return badge===null?{}:{info:color,infoEdge:color,badgeBgInfo:badge}}function lineHeightsFor(lineHeight,current,compiled){if(lineHeight===null)return current;let c=compiled.type.lineHeight,factor=lineHeight/c.normal;if(factor===1)return c;let s=n=>Math.round(n*factor*100)/100;return{tight:s(c.tight),snug:s(c.snug),normal:s(c.normal),relaxed:s(c.relaxed)}}function slotGrounds(c){return{composerInput:[c.composerFill],sendButton:[c.composerFill],userBubble:[c.bubbleUser],assistantBubble:[c.chatGround,c.surfaceCream],vetBubble:[c.bubbleVet],recordCard:[c.surface],vetVisitButton:[c.primary],primaryButton:[c.brand],link:linkGrounds(c),header:[c.surface,c.background,c.chatGround],banner:[flattenOnto(c.badgeBgInfo,c.surface)??c.surface,flattenOnto(c.badgeBgCaution,c.surface)??c.surface,c.surface],chip:[c.chatGround,c.surface,c.background,c.surfaceCream],card:[c.surface],input:[c.surface,c.composerFill,c.surfaceCream,c.surfaceSubtle],tab:[c.surface,c.background],bookingStep:[c.surface,c.background],dialog:[c.surface],cartBar:[c.brand],planCard:[c.surface],planReasonLabel:[c.surface]}}function slotSurrounds(c){return{userBubble:[c.chatGround],assistantBubble:[c.chatGround],vetBubble:[c.chatGround],sendButton:[c.composerFill],vetVisitButton:[c.surfaceCream,c.surface,c.chatGround],primaryButton:[c.surface,c.surfaceCream]}}var APPEARANCE_PRESET_NAMES=/* @__PURE__ */Object.freeze(["everfur","minimal","night"]),APPEARANCE_PRESETS=/* @__PURE__ */Object.freeze({everfur:/* @__PURE__ */Object.freeze({}),minimal:/* @__PURE__ */Object.freeze({colorPrimary:"#111111",colorAccent:"#111111",borderRadius:6}),night:/* @__PURE__ */Object.freeze({colorScheme:"dark"})}),APPEARANCE_SIZE_RANGES=/* @__PURE__ */Object.freeze({fontSizeBase:/* @__PURE__ */Object.freeze({min:12,max:20,default:14}),borderRadius:/* @__PURE__ */Object.freeze({min:0,max:32,default:14}),spacingUnit:/* @__PURE__ */Object.freeze({min:3,max:6,default:4})});function isRecord2(value){return value!==null&&typeof value=="object"&&!Array.isArray(value)}function isPreset(value){return typeof value=="string"&&APPEARANCE_PRESET_NAMES.includes(value.trim().toLowerCase())}function present(vars,key){let value=vars[key];return value??void 0}var PX_MAX_LENGTH=16;function parsePx(value){if(typeof value=="number")return Number.isFinite(value)?value:void 0;if(typeof value!="string"||value.length>PX_MAX_LENGTH)return;let match=/^(-?\d+(?:\.\d+)?)(?: ?px)?$/i.exec(value.trim());return match===null?void 0:Number(match[1])}var COLOR_VARIABLES=[["colorPrimary","primary_color"],["colorAccent","accent_color"],["colorBackground","background_color"],["colorText","text_color"]],STATUS_VARIABLES=[["colorDanger","danger_color"],["colorSuccess","success_color"],["colorWarning","warning_color"],["colorInfo","info_color"]],PASSTHROUGH_VARIABLES=[["fontWeightBody","font_weight_body"],["fontWeightHeading","font_weight_heading"],["lineHeight","line_height"]],STRING_VARIABLES=[["fontFamily","font_family"],["fontFamilyHeading","heading_font_family"],["logoUrl","logo_url"],["assistantAvatarUrl","assistant_avatar_url"]],SIZE_VARIABLES=[["fontSizeBase","font_size_base"],["borderRadius","border_radius"],["spacingUnit","spacing_unit"]];function expandAppearance(appearance){if(!isRecord2(appearance))return null;let preset=isPreset(appearance.theme)?APPEARANCE_PRESETS[appearance.theme.trim().toLowerCase()]:{},own=isRecord2(appearance.variables)?appearance.variables:{},vars={...preset};for(let[key,value]of Object.entries(own))value!=null&&(vars[key]=value);let out={},scheme=present(vars,"colorScheme"),schemeName=typeof scheme=="string"?scheme.trim().toLowerCase():null;(schemeName==="light"||schemeName==="dark"||schemeName==="auto")&&(out.color_scheme=schemeName);let suffix=schemeName==="dark"?"_dark":"";for(let[variable,field]of COLOR_VARIABLES){let value=present(vars,variable);value!==void 0&&(out[`${field}${suffix}`]=value)}for(let[variable,field]of STATUS_VARIABLES){let value=present(vars,variable);value!==void 0&&(out[`${field}${suffix}`]=value)}for(let[variable,field]of STRING_VARIABLES){let value=present(vars,variable);typeof value=="string"&&value.trim().length>0&&(out[field]=value.trim())}for(let[variable,field]of SIZE_VARIABLES){let px=parsePx(present(vars,variable));px!==void 0&&(out[field]=px)}for(let[variable,field]of PASSTHROUGH_VARIABLES){let value=present(vars,variable);(typeof value=="number"||typeof value=="string")&&(out[field]=value)}let fonts=appearance.fonts;Array.isArray(fonts)&&fonts.length>0&&(out.font_sources=fonts);let rules=appearance.rules;if(isRecord2(rules)){let slots={};for(let name of THEME_SLOT_NAMES){let paint=rules[name];isRecord2(paint)&&(slots[name]=paint)}Object.keys(slots).length>0&&(out.slots=slots)}return Object.keys(out).length===0?null:/* @__PURE__ */Object.freeze(out)}var DEFAULT_PRESENTATION=/* @__PURE__ */Object.freeze({chatAnswerStyle:"cards",chatHistoryStyle:"sheet",chatTopCard:"focus",chatFollowUpCount:3,chatFollowUpsExcludeTelevet:false,chatComposerMic:true,chatComposerUpload:true,safetyDisclaimerPlacement:"composer",healthPlanLayout:"focus_plan",recordsTopRiskLine:true,recordsClearResultsFilter:true,chatComposerStyle:"compact",chatComposerPlaceholder:"pet_name",chatHistoryBar:"scroll",chatGeneralBanner:true,chatSendButton:"always_dark"}),PRESENTATION_WIRE_NAMES=/* @__PURE__ */Object.freeze({chatAnswerStyle:"chat_answer_style",chatHistoryStyle:"chat_history_style",chatTopCard:"chat_top_card",chatFollowUpCount:"chat_follow_up_count",chatFollowUpsExcludeTelevet:"chat_follow_ups_exclude_televet",chatComposerMic:"chat_composer_mic",chatComposerUpload:"chat_composer_upload",safetyDisclaimerPlacement:"safety_disclaimer_placement",healthPlanLayout:"health_plan_layout",recordsTopRiskLine:"records_top_risk_line",recordsClearResultsFilter:"records_clear_results_filter",chatComposerStyle:"chat_composer_style",chatComposerPlaceholder:"chat_composer_placeholder",chatHistoryBar:"chat_history_bar",chatGeneralBanner:"chat_general_banner",chatSendButton:"chat_send_button"}),FIELDS=Object.keys(PRESENTATION_WIRE_NAMES),PRESENTATION_LOCK="presentation",PRESENTATION_LOCK_PREFIX="presentation.";function isPresentationLockName(name){if(name===PRESENTATION_LOCK)return true;if(!name.startsWith(PRESENTATION_LOCK_PREFIX))return false;let field=name.slice(PRESENTATION_LOCK_PREFIX.length);return Object.values(PRESENTATION_WIRE_NAMES).includes(field)}var ENUMS={chatAnswerStyle:["bubbles","cards"],chatHistoryStyle:["drawer","sheet"],chatTopCard:["none","focus"],safetyDisclaimerPlacement:["composer","answer_footer"],healthPlanLayout:["standard","focus_plan"],chatComposerStyle:["standard","compact"],chatComposerPlaceholder:["generic","pet_name"],chatHistoryBar:["pinned","scroll"],chatSendButton:["always_dark","dim_when_empty"]},BOOLS=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner"]);function parseField(field,value){if(value==null)return;let allowed=ENUMS[field];return allowed!==void 0?typeof value=="string"&&allowed.includes(value)?value:void 0:BOOLS.has(field)?typeof value=="boolean"?value:void 0:typeof value=="number"&&Number.isInteger(value)&&value>=0&&value<=3?value:void 0}function parsePresentation(raw){if(raw===null||typeof raw!="object"||Array.isArray(raw))return null;let source=raw,out={};for(let field of FIELDS){let wire=PRESENTATION_WIRE_NAMES[field],value=Object.prototype.hasOwnProperty.call(source,wire)?source[wire]:source[field],parsed=parseField(field,value);parsed!==void 0&&(out[field]=parsed)}return Object.keys(out).length===0?null:/* @__PURE__ */Object.freeze(out)}function isPresentationFieldLocked(field,locked){if(locked==null)return false;let one=`${PRESENTATION_LOCK_PREFIX}${PRESENTATION_WIRE_NAMES[field]}`;for(let name of locked)if(name===PRESENTATION_LOCK||name===one)return true;return false}function resolvePresentation(input){let server=parsePresentation(input?.server??null)??{},client=parsePresentation(input?.client??null)??{},locked=input?.locked?[...input.locked]:null,out={};for(let field of FIELDS){let fromServer=server[field],fromClient=isPresentationFieldLocked(field,locked)?void 0:client[field];out[field]=fromClient??fromServer??DEFAULT_PRESENTATION[field]}/* @__PURE__ */
|
|
113
|
+
return Object.freeze({send:send,authorize:authorize,stream:stream})}function assembleHeaders(req,idempotencyKey){let headers={};for(let[key,value]of Object.entries(req.headers??{}))key.toLowerCase()!==IDEMPOTENCY_HEADER&&(headers[key]=value);return idempotencyKey!==null&&(headers["Idempotency-Key"]=idempotencyKey),{...req,headers:headers}}function defaultIdempotencyKeyFactory(){let counter=0;return()=>`efk_${Date.now().toString(36)}_${(counter++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var POLICY_MAX_ATTEMPTS_CAP=10;function decideRetry(error,attempt,ctx){if(ctx.aborted)return{retry:false,reason:"aborted"};let throttle=throttleKind(error);if(throttle==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(throttle!=="burst"&&!isAutoRetryable(error.code))return{retry:false,reason:"terminal-code"};let reason=throttle==="burst"?"burst-throttle":"retryable-code";if((()=>{if(ctx.policy===void 0)return false;try{return!ctx.policy.shouldRetry(error.code,attempt)}catch{return false}})())return{retry:false,reason:"terminal-code"};let policyCeiling=()=>{if(ctx.policy===void 0)return null;let raw;try{raw=ctx.policy.maxAttempts(error.code)}catch{return null}return typeof raw!="number"||!Number.isFinite(raw)?null:Math.max(1,Math.min(POLICY_MAX_ATTEMPTS_CAP,Math.floor(raw)))},ceiling=ctx.perCallMaxAttempts??policyCeiling()??ctx.maxAttempts;if(attempt+1>=ceiling)return{retry:false,reason:"attempts-exhausted"};let override=retryOverrideMs(error,ctx.now);return override!==null?override>RETRY_OVERRIDE_MAX_MS?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:reason,delayMs:override}:{retry:true,reason:reason,delayMs:backoffDelayMs(attempt,ctx.rng)}}function throttleKind(error){let code=error.code==="unknown"?fromWire(rawWireCode(error.raw)):error.code;return code==="quotaExceeded"?"quota":code==="rateLimited"||error.httpStatus===429?"burst":null}function retryOverrideMs(error,now){let at=findResetsAt(error.raw);if(at!==null){let delta=at-now;return delta>0?delta:0}let wait=findRetryAfterSeconds(error.raw);return wait===null?null:Math.round(wait*1e3)}function findRetryAfterSeconds(raw){for(let scope of candidateScopes(raw)){let value=scope.retry_after_seconds;if(typeof value=="number"&&Number.isFinite(value)&&value>=0)return value}return null}function findResetsAt(raw){for(let scope of candidateScopes(raw)){let value=scope.resets_at,parsed=parseInstantMs(value);if(parsed!==null)return parsed}return null}function candidateScopes(raw){if(!isRecord(raw))return[];let out=[raw];for(let nested of["error","detail"]){let value=raw[nested];isRecord(value)&&out.push(value)}return out}function parseInstantMs(value){if(typeof value=="number"&&Number.isFinite(value))return value<1e11?Math.round(value*1e3):Math.round(value);if(typeof value=="string"&&value.trim().length>0){let parsed=Date.parse(value);return Number.isFinite(parsed)?parsed:null}return null}function rawWireCode(raw){for(let scope of candidateScopes(raw)){let code=scope.code;if(typeof code=="string"&&code.length>0)return code}return null}function isRecord(value){return typeof value=="object"&&value!==null}async function resolveDeviceAuth(auth){return auth.mode==="anonymous"?{mode:"anonymous",publishableKey:auth.publishableKey,userRef:auth.userRef,...auth.sessionId?{sessionId:auth.sessionId}:{}}:{mode:"personalized",token:await auth.identity.currentToken(),userRef:auth.userRef,...auth.sessionId?{sessionId:auth.sessionId}:{}}}function boundedSignal(ms,timers){let ctrl=new AbortController,handle=timers.setTimeout(()=>ctrl.abort(),ms);return{signal:ctrl.signal,cancel:()=>timers.clearTimeout(handle)}}function mergeSignals(deadline,caller){let noop=()=>{};if(!caller)return{signal:deadline,dispose:noop};let ctrl=new AbortController;if(deadline.aborted||caller.aborted)return ctrl.abort(),{signal:ctrl.signal,dispose:noop};let onAbort=()=>ctrl.abort();return deadline.addEventListener("abort",onAbort,{once:true}),caller.addEventListener("abort",onAbort,{once:true}),{signal:ctrl.signal,dispose:()=>{deadline.removeEventListener("abort",onAbort),caller.removeEventListener("abort",onAbort)}}}function delayAbortable(ms,timers,signal){return ms<=0||signal?.aborted===true?Promise.resolve():new Promise(resolve=>{let handle=timers.setTimeout(()=>{signal?.removeEventListener("abort",onAbort),resolve()},ms),onAbort=()=>{timers.clearTimeout(handle),resolve()};signal?.addEventListener("abort",onAbort,{once:true})})}function parseColor(value){let rgba=toRgba(value);return rgba===null?null:normalizeRgba(rgba)}function toRgba(value){if(typeof value=="number")return argbIntToRgba(value);if(typeof value!="string")return null;let s=value.trim();if(s.length===0)return null;if(s.startsWith("#"))return fromHex(s.slice(1));if(s.toLowerCase().startsWith("0x"))return fromHex(s.slice(2));if(s.toLowerCase().startsWith("rgb"))return fromRgbFunc(s);if(/^[0-9a-fA-F]+$/.test(s)){let hex=fromHex(s);if(hex!==null)return hex}return/^\d+$/.test(s)?argbIntToRgba(Number.parseInt(s,10)):null}function fromHex(hex){let h=hex.trim();if(!/^[0-9a-fA-F]+$/.test(h))return null;if(h.length===3)return{r:dup(h[0]),g:dup(h[1]),b:dup(h[2]),a:1};if(h.length===6)return{r:byte(h,0),g:byte(h,2),b:byte(h,4),a:1};if(h.length===8){let a=byte(h,0);return{r:byte(h,2),g:byte(h,4),b:byte(h,6),a:a/255}}return null}function fromRgbFunc(input){let open=input.indexOf("("),close=input.indexOf(")");if(open<0||close<0||close<open)return null;let parts=input.slice(open+1,close).split(",").map(p=>p.trim());if(parts.length<3)return null;let r=clampByte(Number(parts[0])),g=clampByte(Number(parts[1])),b=clampByte(Number(parts[2]));if(r===null||g===null||b===null)return null;let a=1;if(parts.length>=4){let alpha=Number(parts[3]);if(!Number.isFinite(alpha))return null;a=Math.min(1,Math.max(0,alpha))}return{r:r,g:g,b:b,a:a}}function argbIntToRgba(n){if(!Number.isFinite(n))return null;let int=Math.trunc(n)>>>0,a=int>>>24&255;return{r:int>>>16&255,g:int>>>8&255,b:int&255,a:a===0?1:a/255}}function byte(hex,at){return Number.parseInt(hex.slice(at,at+2),16)}function dup(nibble){return Number.parseInt(`${nibble??"0"}${nibble??"0"}`,16)}function clampByte(n){return Number.isFinite(n)?Math.min(255,Math.max(0,Math.round(n))):null}function normalizeRgba(rgba){if(rgba.a>=1)return rgbToHex(rgba.r,rgba.g,rgba.b);let a=Math.round(rgba.a*1e3)/1e3;return`rgba(${rgba.r},${rgba.g},${rgba.b},${a})`}function rgbToHex(r,g,b){return`#${hex2(r)}${hex2(g)}${hex2(b)}`.toUpperCase()}function hex2(n){return n.toString(16).padStart(2,"0")}var NEAR_BLACK="#111111",WHITE="#FFFFFF",BLACK="#000000";function readableOn(background){let rgba=toRgba(background);if(rgba===null)return WHITE;let bg=relativeLuminance(rgba),black=relativeLuminance({r:17,g:17,b:17}),white=relativeLuminance({r:255,g:255,b:255});return luminanceContrast(bg,white)>=luminanceContrast(bg,black)?WHITE:NEAR_BLACK}function legibleOn(background,target){let first=readableOn(background);return contrastRatio(first,background)>=target?first:contrastRatio(WHITE,background)>=contrastRatio(BLACK,background)?WHITE:BLACK}function poleForGrounds(grounds){let worst=ink=>grounds.reduce((low,ground)=>Math.min(low,contrastRatio(ink,ground)),Number.POSITIVE_INFINITY);return worst(WHITE)>=worst(BLACK)?WHITE:BLACK}function relativeLuminance(rgba){let r=linearize(rgba.r/255),g=linearize(rgba.g/255),b=linearize(rgba.b/255);return.2126*r+.7152*g+.0722*b}function linearize(channel2){return channel2<=.03928?channel2/12.92:Math.pow((channel2+.055)/1.055,2.4)}function luminanceContrast(l1,l2){let lighter=Math.max(l1,l2),darker=Math.min(l1,l2);return(lighter+.05)/(darker+.05)}function contrastRatio(a,b){let fg=toRgba(a),bg=toRgba(b);if(fg===null||bg===null)return 1;let ground=bg.a>=1?bg:{...bg},fore=fg.a>=1?fg:composite(fg,ground);return luminanceContrast(relativeLuminance(fore),relativeLuminance(ground))}function composite(fg,bg){let a=fg.a,mix2=(f,g)=>Math.round(f*a+g*(1-a));return{r:mix2(fg.r,bg.r),g:mix2(fg.g,bg.g),b:mix2(fg.b,bg.b),a:1}}function flattenOnto(color,background){let fg=toRgba(color),bg=toRgba(background);if(fg===null||bg===null)return null;let out=fg.a>=1?fg:composite(fg,{...bg});return rgbToHex(out.r,out.g,out.b)}function withAlpha(color,alpha){let rgba=toRgba(color);if(rgba===null)return null;let a=Math.min(1,Math.max(0,alpha));return`rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${a})`}var PUSH_STEP=.05;function pushToContrast(color,grounds,pole,target){let first=grounds[0];if(first===void 0)return pole;let reads=candidate=>grounds.every(ground=>contrastRatio(candidate,ground)>=target);if(toRgba(color)===null)return pole;if(reads(color))return color;let flat=flattenOnto(color,first),from=flat===null?null:toRgba(flat),to=toRgba(pole);if(from===null||to===null)return pole;for(let step=1;step<1/PUSH_STEP;step+=1){let t=step*PUSH_STEP,mix2=(a,b)=>Math.round(a+(b-a)*t),candidate=rgbToHex(mix2(from.r,to.r),mix2(from.g,to.g),mix2(from.b,to.b));if(reads(candidate))return candidate}return pole}function rgbToHsl(r,g,b){let rn=r/255,gn=g/255,bn=b/255,mx=Math.max(rn,gn,bn),mn=Math.min(rn,gn,bn),l=(mx+mn)/2;if(mx===mn)return{h:0,s:0,l:l};let d=mx-mn,s=d/(1-Math.abs(2*l-1)),h;return mx===rn?(h=(gn-bn)/d*60,h<0&&(h=h+360)):mx===gn?h=((bn-rn)/d+2)*60:h=((rn-gn)/d+4)*60,{h:h,s:s,l:l}}function hslToRgb(hsl){let{h:h,s:s,l:l}=hsl,c=(1-Math.abs(2*l-1))*s,hp=h/60,x=c*(1-Math.abs(hp%2-1)),m=l-c/2,sector=Math.floor(hp)%6,rgb1=[[c,x,0],[x,c,0],[0,c,x],[0,x,c],[x,0,c],[c,0,x]],[r1,g1,b1]=rgb1[sector];return{r:channel(r1+m),g:channel(g1+m),b:channel(b1+m)}}function channel(v){return Math.min(255,Math.max(0,Math.floor(v*255+.5)))}var THEME_SLOT_NAMES=/* @__PURE__ */Object.freeze(["composerInput","sendButton","userBubble","assistantBubble","vetBubble","recordCard","vetVisitButton","primaryButton","link","header","banner","chip","card","input","tab","bookingStep","dialog","cartBar","planCard","planReasonLabel","planWash","planChip"]),THEME_SLOT_KEYS=/* @__PURE__ */Object.freeze(["backgroundColor","borderColor","borderRadius","textColor"]),THEME_SLOT_KEYS_BY_SLOT=/* @__PURE__ */Object.freeze({planReasonLabel:/* @__PURE__ */Object.freeze(["textColor"]),planWash:/* @__PURE__ */Object.freeze(["backgroundColor"]),planChip:/* @__PURE__ */Object.freeze(["backgroundColor"])});function themeSlotKeysFor(name){return THEME_SLOT_KEYS_BY_SLOT[name]??THEME_SLOT_KEYS}var SLOT_MIN_CONTRAST=4.5,EMPTY=/* @__PURE__ */Object.freeze({});function isSlotName(value){return THEME_SLOT_NAMES.includes(value)}function parseRadius(value){let text2=typeof value=="string"&&value.length<=16?value.trim().replace(/ ?px$/i,""):null,n=typeof value=="number"?value:text2!==null&&text2.length>0?Number(text2):Number.NaN;return Number.isFinite(n)?Math.max(0,n):null}function parseThemeSlots(json){if(json===null||typeof json!="object"||Array.isArray(json))return null;let out={},any=false;for(let[name,raw]of Object.entries(json)){if(!isSlotName(name)||raw===null||typeof raw!="object")continue;let parsed=parseSlot(raw);if(parsed===null)continue;let slot=restrictSlotKeys(name,parsed);slot!==null&&(out[name]=slot,any=true)}return any?/* @__PURE__ */Object.freeze(out):null}function restrictSlotKeys(name,slot){let allowed=THEME_SLOT_KEYS_BY_SLOT[name];if(allowed===void 0)return slot;let out={};for(let key of allowed)slot[key]!==void 0&&(out[key]=slot[key]);return Object.keys(out).length===0?null:/* @__PURE__ */Object.freeze(out)}function pick(raw,snake,camel){return raw[snake]!==void 0?raw[snake]:raw[camel]}function parseSlot(raw){let slot={},backgroundColor=parseColor(pick(raw,"background_color","backgroundColor"));backgroundColor!==null&&(slot.backgroundColor=backgroundColor);let borderColor=parseColor(pick(raw,"border_color","borderColor"));borderColor!==null&&(slot.borderColor=borderColor);let borderRadius=parseRadius(pick(raw,"border_radius","borderRadius"));borderRadius!==null&&(slot.borderRadius=borderRadius);let textColor=parseColor(pick(raw,"text_color","textColor"));return textColor!==null&&(slot.textColor=textColor),Object.keys(slot).length===0?null:/* @__PURE__ */Object.freeze(slot)}function mergeThemeSlots(base,over){return over===null||Object.keys(over).length===0?base??EMPTY:base===null||Object.keys(base).length===0?over:/* @__PURE__ */Object.freeze({...base,...over})}function isOpaque(color){let rgba=toRgba(color);return rgba!==null&&rgba.a>=1}var SLOT_MIN_BORDER_CONTRAST=3,DECORATIVE_EDGE_SLOTS=/* @__PURE__ */new Set(["card","recordCard","banner","header","dialog","bookingStep","cartBar","planCard"]);function sameColor(a,b){let left=parseColor(a);return left!==null&&left===parseColor(b)}function boundaryFor(fill,surrounds,seats=[]){if(surrounds.length===0)return null;let shown=surrounds.map(ground=>flattenOnto(fill,ground)??fill);if(surrounds.every((ground,index)=>contrastRatio(shown[index],ground)>=SLOT_MIN_BORDER_CONTRAST))return null;let against=[...surrounds,...shown,...seats];return pushToContrast(shown[0],against,poleForGrounds(against),SLOT_MIN_BORDER_CONTRAST)}function seatsOf(background,defaults){return background===void 0?defaults:defaults.length===0?[background]:defaults.map(ground=>flattenOnto(background,ground)??ground)}function someInkReads(seats,target){let pole=poleForGrounds(seats);return seats.every(seat=>contrastRatio(pole,seat)>=target)}function collapseUnsatisfiableFill(background,defaults){let ground=defaults[0];return ground===void 0?null:flattenOnto(background,ground)}function inkFor(seats){let pick5=legibleOn(seats[0],SLOT_MIN_CONTRAST);return seats.every(seat=>contrastRatio(pick5,seat)>=SLOT_MIN_CONTRAST)?pick5:poleForGrounds(seats)}function edgeShowsTheControl(name,edge,fill,around,melts){return DECORATIVE_EDGE_SLOTS.has(name)?false:melts?true:fill!==void 0&&sameColor(edge,fill)?false:!(around!==void 0&&fill!==void 0&&isOpaque(fill))}function guardSlotContrast(slots,grounds,surrounds){let changed=false,out={};for(let name of THEME_SLOT_NAMES){let slot=slots[name];if(slot===void 0)continue;let bg=slot.backgroundColor,defaults=grounds?.[name]??[],seats=seatsOf(bg,defaults),next={...slot},fixed=false;if(bg!==void 0&&seats.length>1&&!someInkReads(seats,SLOT_MIN_CONTRAST)){let opaque=collapseUnsatisfiableFill(bg,defaults);opaque!==null&&(next.backgroundColor=opaque,seats=[opaque],fixed=true)}let around=surrounds?.[name],fill=next.backgroundColor,melts=around!==void 0&&fill!==void 0&&isOpaque(fill)&&boundaryFor(fill,around,seats)!==null;if(seats.length>0){let ink=slot.textColor;if(bg!==void 0)(ink===void 0||seats.some(seat=>contrastRatio(ink,seat)<SLOT_MIN_CONTRAST))&&(next.textColor=inkFor(seats),fixed=true);else if(ink!==void 0){let legible=pushToContrast(ink,seats,poleForGrounds(seats),SLOT_MIN_CONTRAST);legible!==ink&&(next.textColor=legible,fixed=true)}if(slot.borderColor!==void 0&&edgeShowsTheControl(name,slot.borderColor,fill,around,melts)){let against=melts?[...seats,...around??[]]:seats,edge=pushToContrast(slot.borderColor,against,poleForGrounds(against),SLOT_MIN_BORDER_CONTRAST);edge!==slot.borderColor&&(next.borderColor=edge,fixed=true)}}if(melts&&fill!==void 0&&around!==void 0&&next.borderColor===void 0){let edge=boundaryFor(fill,around,seats);edge!==null&&(next.borderColor=edge,fixed=true)}out[name]=fixed?/* @__PURE__ */Object.freeze(next):slot,changed=changed||fixed}return changed?/* @__PURE__ */Object.freeze(out):slots}var freezeInPlace=Object.freeze;function deepFreeze(value){if(value!==null&&typeof value=="object"&&!Object.isFrozen(value)){freezeInPlace(value);for(let key of Object.keys(value))deepFreeze(value[key])}return value}var TEXT_SCALE_TIER_CAPS=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),SPACE={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},RADIUS={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},TYPE_SIZE={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},LINE_HEIGHT={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},WEIGHT={regular:"400",medium:"500",bold:"700"},LETTER_SPACING={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},DEFAULT_MAX_FONT_SCALE=0,SYSTEM_FONT_FAMILY="System",SYSTEM_MONO_FAMILY="monospace",TIERS=["content","heading","control","compact","badge"];function authoredTierSizes(size){let out={};for(let tier of TIERS)out[tier]=size;return out}var NO_FONT_SOURCES=[];function baseType(){return{family:SYSTEM_FONT_FAMILY,mono:SYSTEM_MONO_FAMILY,fontUrl:null,families:{regular:SYSTEM_FONT_FAMILY,medium:SYSTEM_FONT_FAMILY,bold:SYSTEM_FONT_FAMILY,mono:SYSTEM_MONO_FAMILY,monoMedium:SYSTEM_MONO_FAMILY,monoBold:SYSTEM_MONO_FAMILY},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:TYPE_SIZE,tierSizes:authoredTierSizes(TYPE_SIZE),lineHeight:LINE_HEIGHT,weight:WEIGHT,letterSpacing:LETTER_SPACING,scale:1,maxScale:DEFAULT_MAX_FONT_SCALE,scaleCaps:TEXT_SCALE_TIER_CAPS,headingFamily:null,headingWeight:null,fontSources:NO_FONT_SOURCES}}var NO_SLOTS={},EASING_CURVES=/* @__PURE__ */Object.freeze({standard:/* @__PURE__ */Object.freeze([.2,0,0,1]),emphasized:/* @__PURE__ */Object.freeze([.2,.8,.2,1]),exit:/* @__PURE__ */Object.freeze([.4,0,1,1])});function cssCubicBezier(curve){return`cubic-bezier(${curve.join(", ")})`}var MOTION={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(EASING_CURVES.standard),emphasized:cssCubicBezier(EASING_CURVES.emphasized),exit:cssCubicBezier(EASING_CURVES.exit)},reducedMotion:false},LIGHT_COLOR={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",highlight:"#FFC3BC",onHighlight:"#000000",mark:"#07C168",controlEdge:"rgba(16,70,46,0.18)",structureEdge:"rgba(16,70,46,0.25)",primaryEdge:"#10462E",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)",info:"#10462E",badgeBgInfo:"rgba(16,70,46,0.10)",infoEdge:"rgba(16,70,46,0.25)"},EVERFUR_LIGHT=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:LIGHT_COLOR,space:SPACE,radius:RADIUS,type:baseType(),motion:MOTION,slots:NO_SLOTS}),DARK_COLOR={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",highlight:"#605051",onHighlight:"#F5F3F0",mark:"#07C168",controlEdge:"rgba(107,211,154,0.22)",structureEdge:"rgba(107,211,154,0.28)",primaryEdge:"#6BD39A",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)",info:"#6BD39A",badgeBgInfo:"rgba(107,211,154,0.12)",infoEdge:"rgba(107,211,154,0.28)"},EVERFUR_DARK=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:DARK_COLOR,space:SPACE,radius:RADIUS,type:baseType(),motion:MOTION,slots:NO_SLOTS});function textGrounds(c){return[c.surface,c.surfaceCream,c.surfaceSubtle,c.background,c.chatGround,c.composerFill]}function controlGrounds(c){return[c.surface,c.surfaceCream,c.background,c.chatGround,c.composerFill]}function brandReadsOnControls(c){return controlGrounds(c).every(ground=>contrastRatio(c.brand,ground)>=SLOT_MIN_BORDER_CONTRAST)}function linkGrounds(c){return[c.chatGround,c.surface,c.surfaceCream]}function statusGrounds(c,wash2){return[c.surface,c.surfaceCream,c.background,c.chatGround,c.composerFill,...washGrounds(c,wash2)]}function washGrounds(c,wash2){return[flattenOnto(wash2,c.surface)??c.surface,flattenOnto(wash2,c.surfaceCream)??c.surfaceCream]}function composerGrounds(c){return[c.composerFill,c.chatGround]}var AUTHORED_AS_IS=/* @__PURE__ */new Set(["text.timestamp","text.placeholder","errorRed","warningStrong","composerBorder"]);function onCompiledGrounds(c,compiled){let own=new Set(textGrounds(compiled));return textGrounds(c).every(ground=>own.has(ground))}function guardInks(theme){let c=theme.color,compiled=(theme.brightness==="dark"?EVERFUR_DARK:EVERFUR_LIGHT).color,other=(theme.brightness==="dark"?EVERFUR_LIGHT:EVERFUR_DARK).color,grounds=textGrounds(c),flipped=poleForGrounds(grounds)!==poleForGrounds(textGrounds(compiled)),keepCompiled=onCompiledGrounds(c,compiled),dangerIsCompiled=c.danger===compiled.danger&&c.badgeBgCritical===compiled.badgeBgCritical,ink=(name,value,authored,twin,on,target)=>{let untouched=value===authored&&(name!=="errorRed"||dangerIsCompiled);return untouched&&keepCompiled&&AUTHORED_AS_IS.has(name)?value:pushToContrast(untouched&&flipped?twin:value,on,poleForGrounds(on),target)},text2=(key,on,target)=>ink(`text.${key}`,c.text[key],compiled.text[key],other.text[key],on,target),token=(key,value,on,target)=>ink(key,value,compiled[key],other[key],on,target),tint=key=>flipped&&c[key]===compiled[key]?other[key]:c[key],primary=c.primary,onPrimary=legibleOn(primary,SLOT_MIN_CONTRAST),danger=token("danger",c.danger,[...grounds,...washGrounds(c,c.badgeBgCritical)],SLOT_MIN_CONTRAST),guarded={...c,onPrimary:onPrimary,onAccent:legibleOn(c.accent,SLOT_MIN_CONTRAST),onDanger:contrastRatio(onPrimary,danger)>=SLOT_MIN_CONTRAST?onPrimary:legibleOn(danger,SLOT_MIN_CONTRAST),brandSoft:tint("brandSoft"),brandSofter:tint("brandSofter"),brandBorder:tint("brandBorder"),borderHairlineGreen:tint("borderHairlineGreen"),brandInk:token("brandInk",c.brandInk,grounds,SLOT_MIN_CONTRAST),linkInk:token("linkInk",theme.slots.link?.textColor??c.accent,linkGrounds(c),SLOT_MIN_CONTRAST),text:{...c.text,primary:text2("primary",grounds,SLOT_MIN_CONTRAST),secondary:text2("secondary",grounds,SLOT_MIN_CONTRAST),muted:text2("muted",grounds,SLOT_MIN_CONTRAST),metaCool:text2("metaCool",grounds,SLOT_MIN_CONTRAST),timestamp:text2("timestamp",grounds,SLOT_MIN_CONTRAST),placeholder:text2("placeholder",controlGrounds(c),SLOT_MIN_BORDER_CONTRAST)},danger:danger,errorRed:token("errorRed",c.errorRed,statusGrounds(c,c.badgeBgCritical),SLOT_MIN_CONTRAST),warningStrong:token("warningStrong",c.warningStrong,statusGrounds(c,c.badgeBgCaution),SLOT_MIN_CONTRAST),composerBorder:token("composerBorder",c.composerBorder,composerGrounds(c),SLOT_MIN_BORDER_CONTRAST),brandBorderStrong:token("brandBorderStrong",c.brandBorderStrong,controlGrounds(c),SLOT_MIN_BORDER_CONTRAST)},accented={...guarded,...accentFamily(guarded,compiled,keepCompiled)};return{...accented,...statusInks(c,accented,compiled)}}function statusInks(merged,g,compiled){let out={},push=(value,on,target)=>pushToContrast(value,on,poleForGrounds(on),target);if((!same(merged.success,compiled.success)||!same(merged.badgeBgPositive,compiled.badgeBgPositive))&&(out.success=push(merged.success,statusGrounds(g,merged.badgeBgPositive),SLOT_MIN_CONTRAST)),(!same(merged.cautionAccent,compiled.cautionAccent)||!same(merged.badgeBgCaution,compiled.badgeBgCaution))&&(out.cautionAccent=push(merged.cautionAccent,statusGrounds(g,merged.badgeBgCaution),SLOT_MIN_CONTRAST)),isPartnerInfo(merged,compiled)){out.info=push(merged.info,statusGrounds(g,merged.badgeBgInfo),SLOT_MIN_CONTRAST);let edgeGrounds=[g.surface,g.chatGround,...washGrounds(g,merged.badgeBgInfo)];out.infoEdge=push(merged.infoEdge,edgeGrounds,SLOT_MIN_BORDER_CONTRAST)}else out.info=g.brandInk,out.badgeBgInfo=g.brandSoft,out.infoEdge=g.structureEdge;return out}function isPartnerInfo(c,compiled){return!same(c.info,compiled.info)||!same(c.badgeBgInfo,compiled.badgeBgInfo)}var HIGHLIGHT_LIGHT_TINT=.24,HIGHLIGHT_DARK_TINT=.3;function same(a,b){return parseColor(a)===parseColor(b)}function partnerHue(c,compiled){return same(c.accent,compiled.accent)?same(c.brand,compiled.brand)?null:c.brand:c.accent}function tintOver(hue,surface,tint){let wash2=withAlpha(hue,tint);return(wash2===null?null:flattenOnto(wash2,surface))??surface}function accentFamily(c,compiled,keepCompiled){let hue=partnerHue(c,compiled),controls=controlGrounds(c),controlPole=poleForGrounds(controls),darkGround=poleForGrounds([c.surface])===WHITE,everfurMarks=hue===null&&keepCompiled,highlight;everfurMarks?highlight=compiled.highlight:hue===null?highlight=darkGround?tintOver(EVERFUR_LIGHT.color.highlight,c.surface,HIGHLIGHT_DARK_TINT):EVERFUR_LIGHT.color.highlight:highlight=tintOver(hue,c.surface,darkGround?HIGHLIGHT_DARK_TINT:HIGHLIGHT_LIGHT_TINT);let onHighlight=everfurMarks?compiled.onHighlight:pushToContrast(c.text.primary,[highlight],poleForGrounds([highlight]),SLOT_MIN_CONTRAST),mark=hue===null?compiled.mark:pushToContrast(hue,controls,controlPole,SLOT_MIN_BORDER_CONTRAST),toward=brandReadsOnControls(c)?c.brand:controlPole,edge=(value,authored,compiledEdge)=>keepCompiled&&same(value,authored)?compiledEdge:pushToContrast(value,controls,toward,SLOT_MIN_BORDER_CONTRAST),primaryGrounds=[c.chatGround,c.composerFill,c.surface,c.surfaceCream],primaryEdge=primaryGrounds.every(ground=>contrastRatio(c.primary,ground)>=SLOT_MIN_BORDER_CONTRAST)?c.primary:pushToContrast(c.primary,primaryGrounds,poleForGrounds(primaryGrounds),SLOT_MIN_BORDER_CONTRAST);return{highlight:highlight,onHighlight:onHighlight,mark:mark,controlEdge:edge(c.brandBorder,compiled.brandBorder,compiled.controlEdge),structureEdge:edge(c.borderHairlineGreen,compiled.borderHairlineGreen,compiled.structureEdge),primaryEdge:primaryEdge}}var same2=(a,b)=>a!==void 0&&b!==void 0&&parseColor(a)===parseColor(b);function diffThemeAdjustments(merged,resolved){let compiled=(merged.brightness==="dark"?EVERFUR_DARK:EVERFUR_LIGHT).color,m=merged.color,r=resolved.color,out=[],add=(field,role,requested,painted)=>{out.push(/* @__PURE__ */Object.freeze({field:field,role:role,requested:requested,painted:painted}))},own=(value,compiledValue)=>!same2(value,compiledValue);own(m.text.primary,compiled.text.primary)&&!same2(r.text.primary,m.text.primary)&&add("text_color","body text",m.text.primary,r.text.primary),own(m.brand,compiled.brand)&&(same2(r.brandInk,m.brand)||add("primary_color","brand text and icons",m.brand,r.brandInk),same2(r.primaryEdge,m.primary)||add("primary_color","edge of a filled control",m.primary,r.primaryEdge),!same2(r.controlEdge,m.brandBorder)&&!brandReadsOnControls({...r,brand:m.brand})&&add("primary_color","control outline",m.brand,r.controlEdge)),own(m.accent,compiled.accent)&&merged.slots.link?.textColor===void 0&&!same2(r.linkInk,m.accent)&&add("accent_color","link text",m.accent,r.linkInk),own(m.danger,compiled.danger)&&!same2(r.danger,m.danger)&&add("danger_color","error text",m.danger,r.danger),own(m.success,compiled.success)&&!same2(r.success,m.success)&&add("success_color","positive status",m.success,r.success),own(m.warningStrong,compiled.warningStrong)&&!same2(r.warningStrong,m.warningStrong)&&add("warning_color","caution text",m.warningStrong,r.warningStrong),own(m.cautionAccent,compiled.cautionAccent)&&!same2(r.cautionAccent,m.cautionAccent)&&add("warning_color","caution accent",m.cautionAccent,r.cautionAccent),(own(m.info,compiled.info)||own(m.badgeBgInfo,compiled.badgeBgInfo))&&(same2(r.info,m.info)||add("info_color","information text",m.info,r.info),same2(r.infoEdge,m.infoEdge)||add("info_color","information outline",m.infoEdge,r.infoEdge));for(let name of THEME_SLOT_NAMES){let before=merged.slots[name],after=resolved.slots[name];before===void 0||after===void 0||before===after||(after.backgroundColor!==void 0&&!same2(after.backgroundColor,before.backgroundColor)&&add(`slots.${name}.background_color`,"fill",before.backgroundColor??null,after.backgroundColor),before.textColor!==void 0&&after.textColor!==void 0&&!same2(after.textColor,before.textColor)&&add(`slots.${name}.text_color`,"text",before.textColor??null,after.textColor),after.borderColor!==void 0&&!same2(after.borderColor,before.borderColor)&&add(`slots.${name}.border_color`,"outline",before.borderColor??null,after.borderColor))}/* @__PURE__ */
|
|
114
|
+
return Object.freeze(out)}var DARK_VARIANT_GROUND="#23272C",DARK_VARIANT_TARGET_RATIO=4.5,DARK_VARIANT_LIGHTNESS_FLOOR=.6,DARK_VARIANT_LIGHTNESS_CEILING=.9,DARK_VARIANT_LIGHTNESS_STEP=.02,WHITE_INK="#FFFFFF",NEAR_BLACK_INK="#111111";function readsOnDark(candidate){return contrastRatio(candidate,DARK_VARIANT_GROUND)>=DARK_VARIANT_TARGET_RATIO&&Math.max(contrastRatio(candidate,WHITE_INK),contrastRatio(candidate,NEAR_BLACK_INK))>=DARK_VARIANT_TARGET_RATIO}function deriveDarkVariant(color){let rgba=toRgba(color);if(rgba===null)return null;let{h:h,s:s,l:l}=rgbToHsl(rgba.r,rgba.g,rgba.b),lDark=Math.min(Math.max(l,DARK_VARIANT_LIGHTNESS_FLOOR),DARK_VARIANT_LIGHTNESS_CEILING);for(let i=0;;i+=1){let li=lDark+i*DARK_VARIANT_LIGHTNESS_STEP;if(li>DARK_VARIANT_LIGHTNESS_CEILING)break;let rgb=hslToRgb({h:h,s:s,l:li}),candidate=rgbToHex(rgb.r,rgb.g,rgb.b);if(readsOnDark(candidate))return candidate}let ceiling=hslToRgb({h:h,s:s,l:DARK_VARIANT_LIGHTNESS_CEILING});return rgbToHex(ceiling.r,ceiling.g,ceiling.b)}var HIGH_CONTRAST_TARGET_RATIO=7,PUSH_STEP2=.05,BLACK2="#000000",WHITE2="#FFFFFF";function pushContrast(color,ground,pole,target){let flat=flattenOnto(color,ground);if(flat===null)return pole;if(contrastRatio(flat,ground)>=target)return flat;let from=toRgba(flat),to=toRgba(pole);if(from===null||to===null)return pole;for(let step=1;step<1/PUSH_STEP2;step+=1){let t=step*PUSH_STEP2,mix2=(a,b)=>Math.round(a+(b-a)*t),candidate=rgbToHex(mix2(from.r,to.r),mix2(from.g,to.g),mix2(from.b,to.b));if(contrastRatio(candidate,ground)>=target)return candidate}return pole}function hardestGround(color,dark){let grounds=textGrounds(color),pick5=grounds[0],pickLum=luminanceOf(pick5);for(let ground of grounds){let lum=luminanceOf(ground);(dark?lum>pickLum:lum<pickLum)&&(pick5=ground,pickLum=lum)}return pick5}function luminanceOf(color){let rgba=toRgba(color);return rgba===null?0:relativeLuminance(rgba)}function solid(wash2,surface){return flattenOnto(wash2,surface)??parseColor(wash2)??surface}function deriveHighContrast(theme){let c=theme.color,lightInk=poleForGrounds(textGrounds(c))===WHITE2,pole=lightInk?WHITE2:BLACK2,ground=hardestGround(c,lightInk),text2=color2=>pushContrast(color2,ground,pole,HIGH_CONTRAST_TARGET_RATIO),color={...c,brandSoft:solid(c.brandSoft,c.surface),brandSofter:solid(c.brandSofter,c.surface),brandBorder:text2(c.brandBorder),borderHairlineGreen:text2(c.borderHairlineGreen),brandBorderStrong:text2(c.brandBorderStrong),controlEdge:text2(c.controlEdge),structureEdge:text2(c.structureEdge),brandInk:text2(c.brandInk),linkInk:text2(c.linkInk),borderRingCream:text2(c.borderRingCream),composerBorder:text2(c.composerBorder),text:{primary:text2(c.text.primary),secondary:text2(c.text.secondary),muted:text2(c.text.muted),placeholder:text2(c.text.placeholder),onBrand:c.text.onBrand,metaCool:text2(c.text.metaCool),timestamp:text2(c.text.timestamp)},badgeBgPositive:solid(c.badgeBgPositive,c.surface),badgeBgCaution:solid(c.badgeBgCaution,c.surface),badgeBgCritical:solid(c.badgeBgCritical,c.surface),badgeBgNeutral:solid(c.badgeBgNeutral,c.surface),checkupCardLowRiskBg:solid(c.checkupCardLowRiskBg,c.surface),checkupCardConcernBg:solid(c.checkupCardConcernBg,c.surface),info:text2(c.info),infoEdge:text2(c.infoEdge),badgeBgInfo:solid(c.badgeBgInfo,c.surface)};return deepFreeze({...theme,highContrast:true,color:color})}var BACKGROUND_STEPS=/* @__PURE__ */Object.freeze({cream:.03,subtle:.07,ring:.16}),CREAM_STEP=BACKGROUND_STEPS.cream,SUBTLE_STEP=BACKGROUND_STEPS.subtle,RING_STEP=BACKGROUND_STEPS.ring,MIN_DERIVED_TYPE_SIZE=10;function mix(color,toward,t){let from=toRgba(color),to=toRgba(toward);if(from===null||to===null)return null;let at=(a,b)=>Math.round(a+(b-a)*t);return rgbToHex(at(from.r,to.r),at(from.g,to.g),at(from.b,to.b))}function surfaceFamily(background){if(background===null)return{};let pole=poleForGrounds([background]),cream=mix(background,pole,CREAM_STEP),subtle=mix(background,pole,SUBTLE_STEP),ring=mix(background,pole,RING_STEP);return cream===null||subtle===null||ring===null?{}:{surface:background,background:background,chatGround:background,bubbleAssistant:background,surfaceCream:cream,composerFill:cream,surfaceSubtle:subtle,skeleton:subtle,borderRingCream:ring}}function dangerFamily(danger){if(danger===null)return{};let rgba=toRgba(danger);return rgba===null?{}:{danger:danger,errorRed:danger,badgeBgCritical:`rgba(${rgba.r},${rgba.g},${rgba.b},0.12)`}}function typeSizesFor(base,current,compiled){if(base===null)return current;let factor=base/compiled.type.size.body;if(factor===1)return compiled.type.size;let out={};for(let[key,value]of Object.entries(compiled.type.size))out[key]=Math.max(MIN_DERIVED_TYPE_SIZE,Math.round(value*factor*10)/10);return out}function spaceFor(unit,current,compiled){if(unit===null)return current;let factor=unit/compiled.space.xs,s=n=>Math.round(n*factor),c=compiled.space;return{xs:s(c.xs),sm:s(c.sm),md:s(c.md),lg:s(c.lg),xl:s(c.xl),xxl:s(c.xxl)}}function radiiFor(base,compiled){let factor=base/compiled.radius.md,s=n=>Math.round(n*factor),r=compiled.radius;return{tile:s(r.tile),xs:s(r.xs),sm:s(r.sm),md:s(r.md),lg:s(r.lg),xl:s(r.xl),pill:r.pill}}var STATUS_WASH=/* @__PURE__ */Object.freeze({success:/* @__PURE__ */Object.freeze({light:.12,dark:.18}),successCard:/* @__PURE__ */Object.freeze({light:.1,dark:.16}),warning:/* @__PURE__ */Object.freeze({light:.14,dark:.2}),info:/* @__PURE__ */Object.freeze({light:.1,dark:.12})});function wash(color,alpha){let rgba=toRgba(color);return rgba===null?null:`rgba(${rgba.r},${rgba.g},${rgba.b},${alpha})`}function successFamily(color,dark){if(color===null)return{};let badge=wash(color,dark?STATUS_WASH.success.dark:STATUS_WASH.success.light),card=wash(color,dark?STATUS_WASH.successCard.dark:STATUS_WASH.successCard.light);return badge===null||card===null?{}:{success:color,badgeBgPositive:badge,checkupCardLowRiskBg:card}}function warningFamily(color,dark){if(color===null)return{};let badge=wash(color,dark?STATUS_WASH.warning.dark:STATUS_WASH.warning.light);return badge===null?{}:{warningStrong:color,cautionAccent:color,badgeBgCaution:badge}}function infoFamily(color,dark){if(color===null)return{};let badge=wash(color,dark?STATUS_WASH.info.dark:STATUS_WASH.info.light);return badge===null?{}:{info:color,infoEdge:color,badgeBgInfo:badge}}function lineHeightsFor(lineHeight,current,compiled){if(lineHeight===null)return current;let c=compiled.type.lineHeight,factor=lineHeight/c.normal;if(factor===1)return c;let s=n=>Math.round(n*factor*100)/100;return{tight:s(c.tight),snug:s(c.snug),normal:s(c.normal),relaxed:s(c.relaxed)}}function slotGrounds(c){return{composerInput:[c.composerFill],sendButton:[c.composerFill],userBubble:[c.bubbleUser],assistantBubble:[c.chatGround,c.surfaceCream],vetBubble:[c.bubbleVet],recordCard:[c.surface],vetVisitButton:[c.primary],primaryButton:[c.brand],link:linkGrounds(c),header:[c.surface,c.background,c.chatGround],banner:[flattenOnto(c.badgeBgInfo,c.surface)??c.surface,flattenOnto(c.badgeBgCaution,c.surface)??c.surface,c.surface],chip:[c.chatGround,c.surface,c.background,c.surfaceCream],card:[c.surface],input:[c.surface,c.composerFill,c.surfaceCream,c.surfaceSubtle],tab:[c.surface,c.background],bookingStep:[c.surface,c.background],dialog:[c.surface],cartBar:[c.brand],planCard:[c.surface],planReasonLabel:[c.surface],planWash:[c.surface],planChip:[c.surface]}}function slotSurrounds(c){return{userBubble:[c.chatGround],assistantBubble:[c.chatGround],vetBubble:[c.chatGround],sendButton:[c.composerFill],vetVisitButton:[c.surfaceCream,c.surface,c.chatGround],primaryButton:[c.surface,c.surfaceCream]}}var APPEARANCE_PRESET_NAMES=/* @__PURE__ */Object.freeze(["everfur","minimal","night"]),APPEARANCE_PRESETS=/* @__PURE__ */Object.freeze({everfur:/* @__PURE__ */Object.freeze({}),minimal:/* @__PURE__ */Object.freeze({colorPrimary:"#111111",colorAccent:"#111111",borderRadius:6}),night:/* @__PURE__ */Object.freeze({colorScheme:"dark"})}),APPEARANCE_SIZE_RANGES=/* @__PURE__ */Object.freeze({fontSizeBase:/* @__PURE__ */Object.freeze({min:12,max:20,default:14}),borderRadius:/* @__PURE__ */Object.freeze({min:0,max:32,default:14}),spacingUnit:/* @__PURE__ */Object.freeze({min:3,max:6,default:4})});function isRecord2(value){return value!==null&&typeof value=="object"&&!Array.isArray(value)}function isPreset(value){return typeof value=="string"&&APPEARANCE_PRESET_NAMES.includes(value.trim().toLowerCase())}function present(vars,key){let value=vars[key];return value??void 0}var PX_MAX_LENGTH=16;function parsePx(value){if(typeof value=="number")return Number.isFinite(value)?value:void 0;if(typeof value!="string"||value.length>PX_MAX_LENGTH)return;let match=/^(-?\d+(?:\.\d+)?)(?: ?px)?$/i.exec(value.trim());return match===null?void 0:Number(match[1])}var COLOR_VARIABLES=[["colorPrimary","primary_color"],["colorAccent","accent_color"],["colorBackground","background_color"],["colorText","text_color"]],STATUS_VARIABLES=[["colorDanger","danger_color"],["colorSuccess","success_color"],["colorWarning","warning_color"],["colorInfo","info_color"]],PASSTHROUGH_VARIABLES=[["fontWeightBody","font_weight_body"],["fontWeightHeading","font_weight_heading"],["lineHeight","line_height"]],STRING_VARIABLES=[["fontFamily","font_family"],["fontFamilyHeading","heading_font_family"],["logoUrl","logo_url"],["assistantAvatarUrl","assistant_avatar_url"]],SIZE_VARIABLES=[["fontSizeBase","font_size_base"],["borderRadius","border_radius"],["spacingUnit","spacing_unit"]];function expandAppearance(appearance){if(!isRecord2(appearance))return null;let preset=isPreset(appearance.theme)?APPEARANCE_PRESETS[appearance.theme.trim().toLowerCase()]:{},own=isRecord2(appearance.variables)?appearance.variables:{},vars={...preset};for(let[key,value]of Object.entries(own))value!=null&&(vars[key]=value);let out={},scheme=present(vars,"colorScheme"),schemeName=typeof scheme=="string"?scheme.trim().toLowerCase():null;(schemeName==="light"||schemeName==="dark"||schemeName==="auto")&&(out.color_scheme=schemeName);let suffix=schemeName==="dark"?"_dark":"";for(let[variable,field]of COLOR_VARIABLES){let value=present(vars,variable);value!==void 0&&(out[`${field}${suffix}`]=value)}for(let[variable,field]of STATUS_VARIABLES){let value=present(vars,variable);value!==void 0&&(out[`${field}${suffix}`]=value)}for(let[variable,field]of STRING_VARIABLES){let value=present(vars,variable);typeof value=="string"&&value.trim().length>0&&(out[field]=value.trim())}for(let[variable,field]of SIZE_VARIABLES){let px=parsePx(present(vars,variable));px!==void 0&&(out[field]=px)}for(let[variable,field]of PASSTHROUGH_VARIABLES){let value=present(vars,variable);(typeof value=="number"||typeof value=="string")&&(out[field]=value)}let fonts=appearance.fonts;Array.isArray(fonts)&&fonts.length>0&&(out.font_sources=fonts);let rules=appearance.rules;if(isRecord2(rules)){let slots={};for(let name of THEME_SLOT_NAMES){let paint=rules[name];isRecord2(paint)&&(slots[name]=paint)}Object.keys(slots).length>0&&(out.slots=slots)}return Object.keys(out).length===0?null:/* @__PURE__ */Object.freeze(out)}var DEFAULT_PRESENTATION=/* @__PURE__ */Object.freeze({chatAnswerStyle:"cards",chatHistoryStyle:"sheet",chatTopCard:"focus",chatFollowUpCount:3,chatFollowUpsExcludeTelevet:false,chatComposerMic:true,chatComposerUpload:true,safetyDisclaimerPlacement:"composer",healthPlanLayout:"focus_plan",recordsTopRiskLine:true,recordsClearResultsFilter:true,chatComposerStyle:"compact",chatComposerPlaceholder:"pet_name",chatHistoryBar:"scroll",chatGeneralBanner:true,chatSendButton:"always_dark",chatTextingAsk:true}),PRESENTATION_WIRE_NAMES=/* @__PURE__ */Object.freeze({chatAnswerStyle:"chat_answer_style",chatHistoryStyle:"chat_history_style",chatTopCard:"chat_top_card",chatFollowUpCount:"chat_follow_up_count",chatFollowUpsExcludeTelevet:"chat_follow_ups_exclude_televet",chatComposerMic:"chat_composer_mic",chatComposerUpload:"chat_composer_upload",safetyDisclaimerPlacement:"safety_disclaimer_placement",healthPlanLayout:"health_plan_layout",recordsTopRiskLine:"records_top_risk_line",recordsClearResultsFilter:"records_clear_results_filter",chatComposerStyle:"chat_composer_style",chatComposerPlaceholder:"chat_composer_placeholder",chatHistoryBar:"chat_history_bar",chatGeneralBanner:"chat_general_banner",chatSendButton:"chat_send_button",chatTextingAsk:"chat_texting_ask"}),FIELDS=Object.keys(PRESENTATION_WIRE_NAMES),PRESENTATION_LOCK="presentation",PRESENTATION_LOCK_PREFIX="presentation.";function isPresentationLockName(name){if(name===PRESENTATION_LOCK)return true;if(!name.startsWith(PRESENTATION_LOCK_PREFIX))return false;let field=name.slice(PRESENTATION_LOCK_PREFIX.length);return Object.values(PRESENTATION_WIRE_NAMES).includes(field)}var ENUMS={chatAnswerStyle:["bubbles","cards"],chatHistoryStyle:["drawer","sheet"],chatTopCard:["none","focus"],safetyDisclaimerPlacement:["composer","answer_footer"],healthPlanLayout:["standard","focus_plan"],chatComposerStyle:["standard","compact"],chatComposerPlaceholder:["generic","pet_name"],chatHistoryBar:["pinned","scroll"],chatSendButton:["always_dark","dim_when_empty"]},BOOLS=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner","chatTextingAsk"]);function parseField(field,value){if(value==null)return;let allowed=ENUMS[field];return allowed!==void 0?typeof value=="string"&&allowed.includes(value)?value:void 0:BOOLS.has(field)?typeof value=="boolean"?value:void 0:typeof value=="number"&&Number.isInteger(value)&&value>=0&&value<=3?value:void 0}function parsePresentation(raw){if(raw===null||typeof raw!="object"||Array.isArray(raw))return null;let source=raw,out={};for(let field of FIELDS){let wire=PRESENTATION_WIRE_NAMES[field],value=Object.prototype.hasOwnProperty.call(source,wire)?source[wire]:source[field],parsed=parseField(field,value);parsed!==void 0&&(out[field]=parsed)}return Object.keys(out).length===0?null:/* @__PURE__ */Object.freeze(out)}function isPresentationFieldLocked(field,locked){if(locked==null)return false;let one=`${PRESENTATION_LOCK_PREFIX}${PRESENTATION_WIRE_NAMES[field]}`;for(let name of locked)if(name===PRESENTATION_LOCK||name===one)return true;return false}function resolvePresentation(input){let server=parsePresentation(input?.server??null)??{},client=parsePresentation(input?.client??null)??{},locked=input?.locked?[...input.locked]:null,out={};for(let field of FIELDS){let fromServer=server[field],fromClient=isPresentationFieldLocked(field,locked)?void 0:client[field];out[field]=fromClient??fromServer??DEFAULT_PRESENTATION[field]}/* @__PURE__ */
|
|
115
115
|
return Object.freeze(out)}var LINE_HEIGHT_RANGE=/* @__PURE__ */Object.freeze({min:1,max:2}),FAMILY_MAX_LENGTH=100,URL_MAX_LENGTH=2048,WEIGHTS=["100","200","300","400","500","600","700","800","900"];function finiteNumber(value){if(typeof value=="number")return Number.isFinite(value)?value:null;if(typeof value!="string"||value.trim().length===0||value.length>16)return null;let n=Number(value.trim());return Number.isFinite(n)?n:null}function parseFontWeight(value){let n=finiteNumber(value);if(n===null)return null;let name=String(n);return WEIGHTS.includes(name)?name:null}function parseLineHeight(value){let n=finiteNumber(value);return n===null?null:Math.min(LINE_HEIGHT_RANGE.max,Math.max(LINE_HEIGHT_RANGE.min,n))}function fontSourceUrl(value){if(typeof value!="string")return null;let trimmed=value.trim();return trimmed.length===0||trimmed.length>URL_MAX_LENGTH?null:/^https:\/\/[^\s"'()\\<>]+$/i.test(trimmed)?trimmed:null}function familyName(value){if(typeof value!="string")return null;let trimmed=value.trim();return trimmed.length===0||trimmed.length>FAMILY_MAX_LENGTH||/[\u0000-\u001F\u007F]/.test(trimmed)?null:trimmed}function isRecord3(value){return value!==null&&typeof value=="object"&&!Array.isArray(value)}function pick2(raw,...keys){for(let key of keys)if(raw[key]!==void 0&&raw[key]!==null)return raw[key]}function parseFontSource(raw){if(!isRecord3(raw))return null;let family=familyName(raw.family);if(family===null)return null;let srcRaw=pick2(raw,"src"),cssRaw=pick2(raw,"cssSrc","css_src");if(srcRaw===void 0==(cssRaw===void 0))return null;if(cssRaw!==void 0){let cssSrc=fontSourceUrl(cssRaw);return cssSrc===null?null:/* @__PURE__ */Object.freeze({family:family,cssSrc:cssSrc})}let src=fontSourceUrl(srcRaw);if(src===null)return null;let out={family:family,src:src},weight=parseFontWeight(raw.weight);weight!==null&&(out.weight=weight);let style=typeof raw.style=="string"?raw.style.trim().toLowerCase():null;return(style==="normal"||style==="italic")&&(out.style=style),/* @__PURE__ */Object.freeze(out)}function parseFontSources(value){if(!Array.isArray(value))return null;let out=[];for(let entry of value){if(out.length>=4)break;let source=parseFontSource(entry);source!==null&&out.push(source)}return out.length===0?null:/* @__PURE__ */Object.freeze(out)}var LOCKABLE_THEME_FIELDS=/* @__PURE__ */Object.freeze(["display_name","logo_url","logo_url_dark","primary_color","accent_color","primary_color_dark","accent_color_dark","brightness","color_scheme","font_family","font_url","fonts","font_urls","chat_placeholder","surface_style","radius_scale","accessibility_max_font_scale","slots","background_color","background_color_dark","text_color","text_color_dark","danger_color","danger_color_dark","font_size_base","border_radius","spacing_unit","success_color","success_color_dark","warning_color","warning_color_dark","info_color","info_color_dark","heading_font_family","font_weight_body","font_weight_heading","line_height","assistant_avatar_url","font_sources"]),SLOT_LOCK_PREFIX="slots.",THEME_SCHEMA_VERSIONS=/* @__PURE__ */Object.freeze([1,2]);function isEmptyBranding(b){return Object.keys(b).every(key=>key==="schemaVersion"||(b[key]??null)===null)}function isKnownBrandingSchema(b){let version=b?.schemaVersion??null;return version===null||THEME_SCHEMA_VERSIONS.includes(version)}function lockedFieldsOf(b){/* @__PURE__ */
|
|
116
116
|
return new Set(["hide_powered_by",...b?.lockedFields??[]])}function isThemeLockName(name){return name==="hide_powered_by"||LOCKABLE_THEME_FIELDS.includes(name)||isPresentationLockName(name)?true:name.startsWith(SLOT_LOCK_PREFIX)&&THEME_SLOT_NAMES.includes(name.slice(SLOT_LOCK_PREFIX.length))}function parseClientBranding(json){if(json===null||typeof json!="object")return null;let raw=json,flat=parseFlat(raw),expanded=expandAppearance(pick3(raw,"appearance")),branding=expanded===null?flat:overlayFlat(parseFlat(expanded),flat);return isEmptyBranding(branding)?null:/* @__PURE__ */Object.freeze(branding)}function overlayFlat(base,over){let out={...base};for(let[key,value]of Object.entries(over))value!=null&&(out[key]=value);let slots=mergeThemeSlots(base.slots??null,over.slots??null);return out.slots=Object.keys(slots).length===0?null:slots,out}function parseFlat(raw){return{displayName:parseNonEmptyString(pick3(raw,"display_name","displayName")),logoUrl:parseNonEmptyString(pick3(raw,"logo_url","logoUrl")),primaryColor:parseColor(pick3(raw,"primary_color","primaryColor")),accentColor:parseColor(pick3(raw,"accent_color","accentColor")),brightness:parseBrightness(pick3(raw,"brightness","color_scheme","colorScheme")),fontFamily:parseNonEmptyString(pick3(raw,"font_family","fontFamily")),fontUrl:parseNonEmptyString(pick3(raw,"font_url","fontUrl")),fonts:parseFaceMap(pick3(raw,"fonts")),fontUrls:parseFaceMap(pick3(raw,"font_urls","fontUrls")),placeholder:parseNonEmptyString(pick3(raw,"chat_placeholder","placeholder","chatPlaceholder")),hidePoweredBy:parseBool(pick3(raw,"hide_powered_by","hidePoweredBy")),primaryColorDark:parseColor(pick3(raw,"primary_color_dark","primaryColorDark")),accentColorDark:parseColor(pick3(raw,"accent_color_dark","accentColorDark")),surfaceStyle:parseEnum(pick3(raw,"surface_style","surfaceStyle"),SURFACE_STYLES),radiusScale:parseEnum(pick3(raw,"radius_scale","radiusScale"),RADIUS_SCALES),logoUrlDark:parseNonEmptyString(pick3(raw,"logo_url_dark","logoUrlDark")),slots:parseThemeSlots(pick3(raw,"slots")),accessibilityMaxFontScale:parseMaxFontScale(pick3(raw,"accessibility_max_font_scale","accessibilityMaxFontScale")),lockedFields:parseLockedFields(pick3(raw,"locked_fields","lockedFields")),presentation:parsePresentation(pick3(raw,"presentation")),schemaVersion:parseSchemaVersion(pick3(raw,"schema_version","schemaVersion")),backgroundColor:parseColor(pick3(raw,"background_color","backgroundColor")),backgroundColorDark:parseColor(pick3(raw,"background_color_dark","backgroundColorDark")),textColor:parseColor(pick3(raw,"text_color","textColor")),textColorDark:parseColor(pick3(raw,"text_color_dark","textColorDark")),dangerColor:parseColor(pick3(raw,"danger_color","dangerColor")),dangerColorDark:parseColor(pick3(raw,"danger_color_dark","dangerColorDark")),fontSizeBase:parseClamped(pick3(raw,"font_size_base","fontSizeBase"),APPEARANCE_SIZE_RANGES.fontSizeBase),borderRadius:parseClamped(pick3(raw,"border_radius","borderRadius"),APPEARANCE_SIZE_RANGES.borderRadius),spacingUnit:parseClamped(pick3(raw,"spacing_unit","spacingUnit"),APPEARANCE_SIZE_RANGES.spacingUnit),successColor:parseColor(pick3(raw,"success_color","successColor")),successColorDark:parseColor(pick3(raw,"success_color_dark","successColorDark")),warningColor:parseColor(pick3(raw,"warning_color","warningColor")),warningColorDark:parseColor(pick3(raw,"warning_color_dark","warningColorDark")),infoColor:parseColor(pick3(raw,"info_color","infoColor")),infoColorDark:parseColor(pick3(raw,"info_color_dark","infoColorDark")),headingFontFamily:parseNonEmptyString(pick3(raw,"heading_font_family","headingFontFamily")),fontWeightBody:parseFontWeight(pick3(raw,"font_weight_body","fontWeightBody")),fontWeightHeading:parseFontWeight(pick3(raw,"font_weight_heading","fontWeightHeading")),lineHeight:parseLineHeight(pick3(raw,"line_height","lineHeight")),fontSources:parseFontSources(pick3(raw,"font_sources","fontSources")),assistantAvatarUrl:parseNonEmptyString(pick3(raw,"assistant_avatar_url","assistantAvatarUrl"))}}function parseClamped(value,range){let n=parseNumber(typeof value=="string"?value.trim().replace(/px$/i,""):value);return n===null?null:Math.min(range.max,Math.max(range.min,n))}function parseBool(value){if(typeof value=="boolean")return value;if(typeof value=="string"){let lower=value.trim().toLowerCase();if(lower==="true")return true;if(lower==="false")return false}return null}function pick3(raw,...keys){for(let key of keys)if(Object.prototype.hasOwnProperty.call(raw,key)){let value=raw[key];if(value!==void 0)return value}}function parseNonEmptyString(value){if(typeof value!="string")return null;let trimmed=value.trim();return trimmed.length===0?null:trimmed}var FONT_FACE_KEYS=["regular","medium","bold","mono","monoMedium","monoBold"];function parseFaceMap(value){if(value===null||typeof value!="object"||Array.isArray(value))return null;let raw=value,out={};for(let key of FONT_FACE_KEYS){let entry=parseNonEmptyString(pick3(raw,key));entry!==null&&(out[key]=entry)}return Object.keys(out).length===0?null:/* @__PURE__ */Object.freeze(out)}var SURFACE_STYLES=["white","cream","subtle"],RADIUS_SCALES=["sharp","default","round"];function parseEnum(value,allowed){if(typeof value!="string")return null;let lower=value.trim().toLowerCase();return allowed.includes(lower)?lower:null}function parseBrightness(value){if(typeof value!="string")return null;let lower=value.trim().toLowerCase();return lower==="light"||lower==="dark"||lower==="auto"?lower:null}function parseNumber(value){let n=typeof value=="number"?value:typeof value=="string"?Number(value.trim()):Number.NaN;return Number.isFinite(n)&&(typeof value!="string"||value.trim().length>0)?n:null}var MAX_FONT_SCALE_FLOOR=1,MAX_FONT_SCALE_CEILING=3.1;function parseMaxFontScale(value){let n=parseNumber(value);return n===null?null:n<=0?0:Math.min(MAX_FONT_SCALE_CEILING,Math.max(MAX_FONT_SCALE_FLOOR,n))}function parseSchemaVersion(value){if(value==null)return null;let n=parseNumber(value);return n!==null&&Number.isInteger(n)&&n>=1?n:0}function toWireName(name){let trimmed=name.trim();return trimmed.startsWith(SLOT_LOCK_PREFIX)?trimmed:trimmed.startsWith(PRESENTATION_LOCK_PREFIX)?PRESENTATION_LOCK_PREFIX+trimmed.slice(PRESENTATION_LOCK_PREFIX.length).replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase():trimmed.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}function parseLockedFields(value){if(!Array.isArray(value))return null;let out=[];for(let entry of value){if(typeof entry!="string")continue;let name=toWireName(entry);isThemeLockName(name)&&!out.includes(name)&&out.push(name)}return out.length===0?null:/* @__PURE__ */Object.freeze(out)}function hardenHttpsUrl(url){if(url===null)return null;let trimmed=url.trim();return trimmed.length===0?null:/^https:\/\/\S+$/i.test(trimmed)?trimmed:null}var BRAND_ASSET_URL=/^https:\/\/sdk(-staging)?\.everfur\.com\/brand\/[0-9a-f]{16}\.(png|jpg|webp)$/;function hardenBrandAssetUrl(url){let https=hardenHttpsUrl(url);return https!==null&&BRAND_ASSET_URL.test(https)?https:null}function withServerBranding(base,b){if(b===null||isEmptyBranding(b))return base;let palette=(b.brightness==="light"||b.brightness==="dark")&&b.brightness!==base.brightness?b.brightness==="dark"?EVERFUR_DARK:EVERFUR_LIGHT:base,compiled=palette.brightness==="dark"?EVERFUR_DARK:EVERFUR_LIGHT,dark=palette.brightness==="dark",primaryIn=dark?b.primaryColorDark??darkVariantOf(b.primaryColor):b.primaryColor,accentIn=dark?b.accentColorDark??darkVariantOf(b.accentColor):b.accentColor,primaryRaw=primaryIn??palette.color.primary,accent=accentIn??palette.color.accent,keepsCompiled=primaryIn!==null&&isCompiledPrimary(b,primaryRaw,compiled,dark),primary=keepsCompiled?compiled.color.primary:primaryRaw,pr=primaryIn!==null&&!keepsCompiled?toRgba(primary):null,lift=c=>Math.round(c+(255-c)*.4),brandFamily=pr!==null?{brand:primary,bubbleUser:primary,brandInk:primary,text:{...palette.color.text,secondary:primary},brandSoft:`rgba(${pr.r}, ${pr.g}, ${pr.b}, 0.10)`,brandSofter:`rgba(${pr.r}, ${pr.g}, ${pr.b}, 0.15)`,brandBorder:`rgba(${pr.r}, ${pr.g}, ${pr.b}, 0.20)`,borderHairlineGreen:`rgba(${pr.r}, ${pr.g}, ${pr.b}, 0.28)`,brandBorderStrong:`rgba(${pr.r}, ${pr.g}, ${pr.b}, 0.55)`,composerBorder:`rgba(${pr.r}, ${pr.g}, ${pr.b}, 0.75)`,accentEdge:`rgb(${lift(pr.r)}, ${lift(pr.g)}, ${lift(pr.b)})`}:keepsCompiled?compiledBrandFamily(compiled,palette.color.text):{},background=(dark?b.backgroundColorDark:b.backgroundColor)??null,grounds=surfaceFamily(background),groundFamily={...palette.color,...grounds},bodyInk=(dark?b.textColorDark:b.textColor)??null,status=(light,darkTwin)=>(dark?darkTwin??darkVariantOf(light??null):light)??null,next={brightness:palette.brightness,highContrast:palette.highContrast,meta:{displayName:b.displayName??palette.meta.displayName,logoUrl:(dark?b.logoUrlDark??b.logoUrl:b.logoUrl)??palette.meta.logoUrl,placeholder:b.placeholder??palette.meta.placeholder,hidePoweredBy:b.hidePoweredBy??palette.meta.hidePoweredBy,assistantAvatarUrl:b.assistantAvatarUrl??palette.meta.assistantAvatarUrl},color:{...palette.color,...brandFamily,...grounds,...dangerFamily(status(b.dangerColor,b.dangerColorDark)),...successFamily(status(b.successColor,b.successColorDark),dark),...warningFamily(status(b.warningColor,b.warningColorDark),dark),...infoFamily(status(b.infoColor,b.infoColorDark),dark),...bodyInk!==null?{text:{...brandFamily.text??palette.color.text,primary:bodyInk}}:{},...surfaceOf(b.surfaceStyle??null,groundFamily),primary:primary,accent:accent,onPrimary:palette.color.onPrimary,onAccent:palette.color.onAccent},space:spaceFor(b.spacingUnit??null,palette.space,compiled),radius:b.borderRadius!=null?radiiFor(b.borderRadius,compiled):radiusOf(b.radiusScale??null,palette.radius,compiled),type:{...palette.type,...mergeFaces(palette.type,b),size:typeSizesFor(b.fontSizeBase??null,palette.type.size,compiled),maxScale:b.accessibilityMaxFontScale??palette.type.maxScale,lineHeight:lineHeightsFor(b.lineHeight??null,palette.type.lineHeight,compiled),weight:b.fontWeightBody==null?palette.type.weight:{...palette.type.weight,regular:b.fontWeightBody},headingFamily:b.headingFontFamily??palette.type.headingFamily,headingWeight:b.fontWeightHeading??palette.type.headingWeight,fontSources:b.fontSources??palette.type.fontSources},motion:palette.motion,slots:mergeThemeSlots(palette.slots,b.slots??null)};return deepFreeze(next)}var FACE_CHAIN={regular:["regular"],medium:["medium","regular"],bold:["bold","medium","regular"],mono:["mono"],monoMedium:["monoMedium","mono"],monoBold:["monoBold","monoMedium","mono"]},FACE_GROUPS=[["regular","medium","bold"],["mono","monoMedium","monoBold"]];function isMonoFace(face2){return face2==="mono"||face2==="monoMedium"||face2==="monoBold"}function mergeFaces(base,b){let fonts=b.fonts??{},urls=b.fontUrls??{},families={...base.families},namedFaces={...base.namedFaces},fontUrls={...base.fontUrls};for(let face2 of FONT_FACE_KEYS){let named=FACE_CHAIN[face2].map(key=>fonts[key]).find(name=>name!==void 0),legacy=isMonoFace(face2)?null:b.fontFamily;named!==void 0?(families[face2]=named,namedFaces[face2]=true):legacy!==null&&(families[face2]=legacy,namedFaces[face2]=false);let url=urls[face2]??(face2==="regular"?b.fontUrl:null)??null;url!==null?fontUrls[face2]=url:named!==void 0&&delete fontUrls[face2]}for(let group of FACE_GROUPS)for(let face2 of group)namedFaces[face2]&&group.some(other=>other!==face2&&families[other]===families[face2])&&(namedFaces[face2]=false);return{family:families.regular,mono:families.mono,fontUrl:fontUrls.regular??null,families:families,namedFaces:namedFaces,fontUrls:fontUrls}}function darkVariantOf(color){return color===null?null:deriveDarkVariant(color)}function surfaceOf(style,family){if(style===null)return{};let c=family;return{chatGround:style==="white"?c.surface:style==="subtle"?c.surfaceSubtle:c.surfaceCream}}function sameColor2(a,b){return a==null?false:parseColor(a)===parseColor(b)}function isCompiledPrimary(b,primary,compiled,dark){return sameColor2(primary,compiled.color.primary)?true:dark&&(b.primaryColorDark??null)===null&&sameColor2(b.primaryColor,EVERFUR_LIGHT.color.primary)}function compiledBrandFamily(compiled,text2){let c=compiled.color;return{text:{...text2,secondary:c.text.secondary},brand:c.brand,bubbleUser:c.bubbleUser,brandInk:c.brandInk,brandSoft:c.brandSoft,brandSofter:c.brandSofter,brandBorder:c.brandBorder,borderHairlineGreen:c.borderHairlineGreen,brandBorderStrong:c.brandBorderStrong,composerBorder:c.composerBorder,accentEdge:c.accentEdge}}var RADIUS_FACTOR={sharp:.5,default:1,round:1.5};function radiusOf(scale,base,compiled){if(scale===null)return base;let f=RADIUS_FACTOR[scale],r=compiled.radius,s=n=>Math.round(n*f);return{tile:s(r.tile),xs:s(r.xs),sm:s(r.sm),md:s(r.md),lg:s(r.lg),xl:s(r.xl),pill:r.pill}}var DEFAULT_DISPLAY_NAME="Everfur",TEXT_SCALE_FLOOR=.5;function resolveTheme(input){return finalize(mergeLayers(input),input)}function themeAdjustments(input){let merged=mergeLayers(input);return diffThemeAdjustments(merged,finalize(merged,{...input,highContrast:false}))}function mergeLayers(input){let candidate=input?.branding??null,server=isKnownBrandingSchema(candidate)?candidate:null,client=withoutFields(input?.clientOverride??null,lockedFieldsOf(server)),device=input?.colorScheme==="dark"?"dark":"light",chosen=client?.brightness??server?.brightness??"light",withServer=withServerBranding((chosen==="auto"?device:chosen)==="dark"?EVERFUR_DARK:EVERFUR_LIGHT,withoutBrightness(server));return withServerBranding(withServer,withoutBrightness(client))}function previewTheme(input,hints,options){return resolveTheme({...options,branding:parseClientBranding(hints),clientOverride:parseClientBranding(input)})}function wireNameOf(key){return key==="placeholder"?"chat_placeholder":toWireName(key)}var LOCK_ALIASES={brightness:["color_scheme"],fontUrl:["font_family"],fonts:["font_family"],fontUrls:["font_url","font_family","fonts"],fontSources:["font_family","heading_font_family"],primaryColorDark:["primary_color"],accentColorDark:["accent_color"],logoUrlDark:["logo_url"],backgroundColorDark:["background_color"],textColorDark:["text_color"],dangerColorDark:["danger_color"],successColorDark:["success_color"],warningColorDark:["warning_color"],infoColorDark:["info_color"],borderRadius:["radius_scale"],radiusScale:["border_radius"]};function isLocked(key,locked){return locked.has(wireNameOf(key))?true:(LOCK_ALIASES[key]??[]).some(name=>locked.has(name))}function withoutFields(b,locked){if(b===null)return null;let changed=false,out={...b};for(let key of Object.keys(b))(b[key]??null)!==null&&(isLocked(key,locked)||key==="lockedFields")&&(out[key]=null,changed=true);let slots=out.slots??null;if(slots!==null){let kept={},dropped=false;for(let name of THEME_SLOT_NAMES){let slot=slots[name];slot!==void 0&&(locked.has(`${SLOT_LOCK_PREFIX}${name}`)?dropped=true:kept[name]=slot)}dropped&&(out.slots=Object.keys(kept).length===0?null:/* @__PURE__ */Object.freeze(kept),changed=true)}if(!changed)return b;let stripped=/* @__PURE__ */Object.freeze(out);return isEmptyBranding(stripped)?null:stripped}function withoutBrightness(b){return b===null||b.brightness===null?b:/* @__PURE__ */Object.freeze({...b,brightness:null})}function scaledSizes(size,scale){if(scale===1)return size;let out={};for(let[key,value]of Object.entries(size))out[key]=Math.round(value*scale*10)/10;return out}function effectiveScale(textScale){return textScale===void 0||!Number.isFinite(textScale)?1:Math.max(TEXT_SCALE_FLOOR,textScale)}var SCALE_TIERS=["content","heading","control","compact","badge"];function tierCaps(maxScale){if(!(maxScale>0))return TEXT_SCALE_TIER_CAPS;let out={};for(let tier of SCALE_TIERS){let cap=TEXT_SCALE_TIER_CAPS[tier];out[tier]=cap===0?0:Math.min(cap,maxScale)}return out}function capped(scale,cap){return cap>0?Math.min(scale,cap):scale}function sizesByTier(size,scale,caps,scaleSizes){let out={};for(let tier of SCALE_TIERS)out[tier]=scaleSizes?scaledSizes(size,capped(scale,caps[tier])):size;return out}function registration(isFontRegistered,family){try{let answer=isFontRegistered(family);return answer===!0||answer===!1?answer:null}catch{return null}}function platformFaces(type,input){let isFontRegistered=input?.isFontRegistered,platformMono=input?.platformMonoFamily?.trim()||null;if(isFontRegistered===void 0&&platformMono===null)return{family:type.family,mono:type.mono,families:type.families,namedFaces:type.namedFaces,headingFamily:type.headingFamily};let headingFamily=type.headingFamily!==null&&isFontRegistered!==void 0&®istration(isFontRegistered,type.headingFamily)===false?null:type.headingFamily,families={...type.families},namedFaces={...type.namedFaces};for(let key of FONT_FACE_KEYS)!(families[key]===SYSTEM_FONT_FAMILY||families[key]===SYSTEM_MONO_FAMILY)&&isFontRegistered!==void 0&®istration(isFontRegistered,families[key])===false&&(families[key]=isMonoFace(key)?SYSTEM_MONO_FAMILY:SYSTEM_FONT_FAMILY,namedFaces[key]=false),platformMono!==null&&isMonoFace(key)&&families[key]===SYSTEM_MONO_FAMILY&&(families[key]=platformMono);return{family:families.regular,mono:families.mono,families:families,namedFaces:namedFaces,headingFamily:headingFamily}}function finalize(theme,input){let displayName=theme.meta.displayName.trim().length===0?DEFAULT_DISPLAY_NAME:theme.meta.displayName,logoUrl=hardenBrandAssetUrl(theme.meta.logoUrl),fontUrls={};for(let face2 of FONT_FACE_KEYS){let url=theme.type.fontUrls[face2];url!==void 0&&(fontUrls[face2]=hardenHttpsUrl(url))}let fontUrl=fontUrls.regular??null,motion=input?.reducedMotion===true?{duration:{instant:0,fast:0,normal:0,slow:0},spring:{gentle:{damping:100,stiffness:1e3}},easing:theme.motion.easing,reducedMotion:true}:theme.motion,maxScale=Number.isFinite(theme.type.maxScale)?theme.type.maxScale:DEFAULT_MAX_FONT_SCALE,scale=effectiveScale(input?.textScale),scaleCaps=tierCaps(maxScale),tierSizes=sizesByTier(theme.type.size,scale,scaleCaps,input?.scaleTypeSizes===true),color=guardInks(theme),finalized={brightness:theme.brightness,highContrast:false,meta:{displayName:displayName,logoUrl:logoUrl,placeholder:theme.meta.placeholder,hidePoweredBy:theme.meta.hidePoweredBy,assistantAvatarUrl:hardenBrandAssetUrl(theme.meta.assistantAvatarUrl)},color:color,space:theme.space,radius:theme.radius,type:{...theme.type,...platformFaces(theme.type,input),fontUrl:fontUrl,fontUrls:fontUrls,size:tierSizes.content,tierSizes:tierSizes,scale:scale,maxScale:maxScale,scaleCaps:scaleCaps},motion:motion,slots:guardSlotContrast(theme.slots,slotGrounds(color),slotSurrounds(color))};return input?.highContrast===true?deriveHighContrast(deepFreeze(finalized)):deepFreeze(finalized)}var ENTITLEMENTS_PATH="/widget/v1/entitlements",HTTP_NOT_MODIFIED=304,NOT_MODIFIED=/* @__PURE__ */Object.freeze({kind:"notModified"});async function fetchEntitlements(auth,args={},funnel=createRequestFunnel({auth:auth})){let result=await funnel.send("entitlements.fetch",buildRequest(args));return result.ok?parseUpdated(result.value):result.error.httpStatus===HTTP_NOT_MODIFIED?NOT_MODIFIED:{kind:"failed",error:result.error}}var REGION_MAX=64;function buildRequest(args){let headers={};return isFiniteNumber(args.cachedRevision)&&(headers["if-none-match"]=`"${args.cachedRevision}"`),args.region&&args.region.length<=REGION_MAX?{method:"GET",path:ENTITLEMENTS_PATH,headers:headers,query:{region:args.region}}:{method:"GET",path:ENTITLEMENTS_PATH,headers:headers}}function parseUpdated(body){if(body===null||typeof body!="object"||!isFiniteNumber(body.revision))return malformed();let region=typeof body.region=="string"?body.region:"",ttlSeconds=isFiniteNumber(body.ttl_seconds)?body.ttl_seconds:0;/* @__PURE__ */
|
|
117
117
|
return Object.freeze({kind:"updated",revision:body.revision,region:region,ttlSeconds:ttlSeconds,decisions:mapCapabilities(body.capabilities),branding:parseBranding(body),livemode:body.livemode!==false,...smsProfileOf(body)})}function smsProfileOf(body){let hints=body.render_hints,raw=body.sms_profile_public??(hints!==null&&typeof hints=="object"?hints.sms_profile_public:void 0);return raw!==null&&typeof raw=="object"?{smsProfilePublic:raw}:{}}function parseBranding(body){let direct=parseClientBranding(body.branding);if(direct!==null)return direct;let hints=body.render_hints;if(hints!==null&&typeof hints=="object"){let nested=parseClientBranding(hints.branding);return nested!==null?nested:parseClientBranding(hints)}return null}function mapCapabilities(capabilities){if(capabilities===null||typeof capabilities!="object")/* @__PURE__ */return Object.freeze([]);let out=[];for(let[resource,value]of Object.entries(capabilities))isEnabled(value)&&out.push(/* @__PURE__ */Object.freeze({resource:resource,granted:true}));/* @__PURE__ */
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { E as EverfurResult } from './EverfurResult.d-BFH-3s6E.cjs';
|
|
2
|
+
import { P as PetRef } from './ids.d-B2GAAifq.cjs';
|
|
3
|
+
import { a as RecordsClinicTarget, b as RecordsAuthorizationSignature } from './clinicModels.d-BXgKZqDb.cjs';
|
|
4
|
+
import { R as RequestFunnel } from './requestFunnel.d-CR4akGCY.cjs';
|
|
5
|
+
import { A as AuthContext } from './identity.d-CioQhZrq.cjs';
|
|
6
|
+
import { E as ErrorPolicyPort } from './ErrorPolicyPort.d-DirW9hgO.cjs';
|
|
7
|
+
import { d as RecordsRequestView } from './models.d-BSqvbTE1.cjs';
|
|
8
|
+
|
|
9
|
+
interface HttpRecordsClinicRepositoryDeps {
|
|
10
|
+
readonly auth: AuthContext;
|
|
11
|
+
readonly funnel?: RequestFunnel;
|
|
12
|
+
readonly errorPolicy?: ErrorPolicyPort;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The most clinics one batch may name (the server's `_MAX_BATCH_CLINICS`). */
|
|
16
|
+
declare const RECORDS_CLINIC_BATCH_MAX = 10;
|
|
17
|
+
/** One clinic of a batch: exactly one clinic target, exactly one signature, and its own idempotency key. */
|
|
18
|
+
type RecordsClinicBatchItem = RecordsClinicTarget & RecordsAuthorizationSignature & {
|
|
19
|
+
/** Owner-supplied contact only; server anti-relay checks prevent redirecting an addressable clinic. */
|
|
20
|
+
readonly clinicEmail?: string;
|
|
21
|
+
/** Stable for retries of this clinic's authorization, distinct for a new one. */
|
|
22
|
+
readonly idempotencyKey: string;
|
|
23
|
+
};
|
|
24
|
+
interface CreateClinicRequestBatchInput {
|
|
25
|
+
/** The registered pet the records are requested for. */
|
|
26
|
+
readonly petRef: PetRef;
|
|
27
|
+
/** The signer's name, confirmed by the owner before signing. */
|
|
28
|
+
readonly ownerName: string;
|
|
29
|
+
/** The version of the backend-authored authorization copy the owner signed. */
|
|
30
|
+
readonly authorizationVersion: string;
|
|
31
|
+
/** 1..RECORDS_CLINIC_BATCH_MAX clinics. */
|
|
32
|
+
readonly clinics: readonly RecordsClinicBatchItem[];
|
|
33
|
+
}
|
|
34
|
+
/** One clinic's outcome: `request` when created, `failureCode` and `failureReason` when not. */
|
|
35
|
+
interface RecordsClinicBatchResult {
|
|
36
|
+
/** The idempotency key this clinic was sent with. */
|
|
37
|
+
readonly idempotencyKey: string;
|
|
38
|
+
/** The directory clinic, when the clinic was chosen from the directory. */
|
|
39
|
+
readonly clinicId: string | null;
|
|
40
|
+
/** The owner-entered clinic, when it was not. */
|
|
41
|
+
readonly clinicFreeText: string | null;
|
|
42
|
+
/** True when this clinic has a request in the response; false with failureCode otherwise. */
|
|
43
|
+
readonly created: boolean;
|
|
44
|
+
/** The created request, mapped like every other records request. */
|
|
45
|
+
readonly request: RecordsRequestView | null;
|
|
46
|
+
/** Machine-readable reason this clinic was not created. */
|
|
47
|
+
readonly failureCode: string | null;
|
|
48
|
+
/** Server-authored; safe to log, but render your own copy from `failureCode`. */
|
|
49
|
+
readonly failureReason: string | null;
|
|
50
|
+
}
|
|
51
|
+
interface RecordsClinicBatch {
|
|
52
|
+
/** The group every request of this batch belongs to. */
|
|
53
|
+
readonly requestGroupId: string;
|
|
54
|
+
/** The pet the batch was for; always the input's petRef. */
|
|
55
|
+
readonly petRef: string;
|
|
56
|
+
/** One result per clinic, in the order sent. */
|
|
57
|
+
readonly results: readonly RecordsClinicBatchResult[];
|
|
58
|
+
/** How many clinics have a request. */
|
|
59
|
+
readonly createdCount: number;
|
|
60
|
+
/** How many clinics failed. */
|
|
61
|
+
readonly failedCount: number;
|
|
62
|
+
}
|
|
63
|
+
/** The multi-clinic records request client. */
|
|
64
|
+
interface RecordsClinicBatchClient {
|
|
65
|
+
/** Run it only from the owner's own signed action: it gives consent and contacts clinics in the owner's name. */
|
|
66
|
+
createClinicRequestBatch(input: CreateClinicRequestBatchInput): Promise<EverfurResult<RecordsClinicBatch>>;
|
|
67
|
+
}
|
|
68
|
+
/** The batch client, over the same auth, funnel and error policy as the clinic repository. */
|
|
69
|
+
declare function createRecordsClinicBatchClient(deps: HttpRecordsClinicRepositoryDeps): RecordsClinicBatchClient;
|
|
70
|
+
|
|
71
|
+
export { type CreateClinicRequestBatchInput as C, type HttpRecordsClinicRepositoryDeps as H, type RecordsClinicBatch as R, type RecordsClinicBatchClient as a, RECORDS_CLINIC_BATCH_MAX as b, type RecordsClinicBatchItem as c, type RecordsClinicBatchResult as d, createRecordsClinicBatchClient as e };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { E as EverfurResult } from './EverfurResult.d-D_-254ZY.js';
|
|
2
|
+
import { P as PetRef } from './ids.d-B2GAAifq.js';
|
|
3
|
+
import { a as RecordsClinicTarget, b as RecordsAuthorizationSignature } from './clinicModels.d-CaS64-P-.js';
|
|
4
|
+
import { R as RequestFunnel } from './requestFunnel.d-DFf9C__p.js';
|
|
5
|
+
import { A as AuthContext } from './identity.d-BksOEa6m.js';
|
|
6
|
+
import { E as ErrorPolicyPort } from './ErrorPolicyPort.d-68yrE3BE.js';
|
|
7
|
+
import { d as RecordsRequestView } from './models.d-DOwnr8fi.js';
|
|
8
|
+
|
|
9
|
+
interface HttpRecordsClinicRepositoryDeps {
|
|
10
|
+
readonly auth: AuthContext;
|
|
11
|
+
readonly funnel?: RequestFunnel;
|
|
12
|
+
readonly errorPolicy?: ErrorPolicyPort;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The most clinics one batch may name (the server's `_MAX_BATCH_CLINICS`). */
|
|
16
|
+
declare const RECORDS_CLINIC_BATCH_MAX = 10;
|
|
17
|
+
/** One clinic of a batch: exactly one clinic target, exactly one signature, and its own idempotency key. */
|
|
18
|
+
type RecordsClinicBatchItem = RecordsClinicTarget & RecordsAuthorizationSignature & {
|
|
19
|
+
/** Owner-supplied contact only; server anti-relay checks prevent redirecting an addressable clinic. */
|
|
20
|
+
readonly clinicEmail?: string;
|
|
21
|
+
/** Stable for retries of this clinic's authorization, distinct for a new one. */
|
|
22
|
+
readonly idempotencyKey: string;
|
|
23
|
+
};
|
|
24
|
+
interface CreateClinicRequestBatchInput {
|
|
25
|
+
/** The registered pet the records are requested for. */
|
|
26
|
+
readonly petRef: PetRef;
|
|
27
|
+
/** The signer's name, confirmed by the owner before signing. */
|
|
28
|
+
readonly ownerName: string;
|
|
29
|
+
/** The version of the backend-authored authorization copy the owner signed. */
|
|
30
|
+
readonly authorizationVersion: string;
|
|
31
|
+
/** 1..RECORDS_CLINIC_BATCH_MAX clinics. */
|
|
32
|
+
readonly clinics: readonly RecordsClinicBatchItem[];
|
|
33
|
+
}
|
|
34
|
+
/** One clinic's outcome: `request` when created, `failureCode` and `failureReason` when not. */
|
|
35
|
+
interface RecordsClinicBatchResult {
|
|
36
|
+
/** The idempotency key this clinic was sent with. */
|
|
37
|
+
readonly idempotencyKey: string;
|
|
38
|
+
/** The directory clinic, when the clinic was chosen from the directory. */
|
|
39
|
+
readonly clinicId: string | null;
|
|
40
|
+
/** The owner-entered clinic, when it was not. */
|
|
41
|
+
readonly clinicFreeText: string | null;
|
|
42
|
+
/** True when this clinic has a request in the response; false with failureCode otherwise. */
|
|
43
|
+
readonly created: boolean;
|
|
44
|
+
/** The created request, mapped like every other records request. */
|
|
45
|
+
readonly request: RecordsRequestView | null;
|
|
46
|
+
/** Machine-readable reason this clinic was not created. */
|
|
47
|
+
readonly failureCode: string | null;
|
|
48
|
+
/** Server-authored; safe to log, but render your own copy from `failureCode`. */
|
|
49
|
+
readonly failureReason: string | null;
|
|
50
|
+
}
|
|
51
|
+
interface RecordsClinicBatch {
|
|
52
|
+
/** The group every request of this batch belongs to. */
|
|
53
|
+
readonly requestGroupId: string;
|
|
54
|
+
/** The pet the batch was for; always the input's petRef. */
|
|
55
|
+
readonly petRef: string;
|
|
56
|
+
/** One result per clinic, in the order sent. */
|
|
57
|
+
readonly results: readonly RecordsClinicBatchResult[];
|
|
58
|
+
/** How many clinics have a request. */
|
|
59
|
+
readonly createdCount: number;
|
|
60
|
+
/** How many clinics failed. */
|
|
61
|
+
readonly failedCount: number;
|
|
62
|
+
}
|
|
63
|
+
/** The multi-clinic records request client. */
|
|
64
|
+
interface RecordsClinicBatchClient {
|
|
65
|
+
/** Run it only from the owner's own signed action: it gives consent and contacts clinics in the owner's name. */
|
|
66
|
+
createClinicRequestBatch(input: CreateClinicRequestBatchInput): Promise<EverfurResult<RecordsClinicBatch>>;
|
|
67
|
+
}
|
|
68
|
+
/** The batch client, over the same auth, funnel and error policy as the clinic repository. */
|
|
69
|
+
declare function createRecordsClinicBatchClient(deps: HttpRecordsClinicRepositoryDeps): RecordsClinicBatchClient;
|
|
70
|
+
|
|
71
|
+
export { type CreateClinicRequestBatchInput as C, type HttpRecordsClinicRepositoryDeps as H, type RecordsClinicBatch as R, type RecordsClinicBatchClient as a, RECORDS_CLINIC_BATCH_MAX as b, type RecordsClinicBatchItem as c, type RecordsClinicBatchResult as d, createRecordsClinicBatchClient as e };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { P as PetRef } from './ids.d-B2GAAifq.cjs';
|
|
2
|
+
|
|
3
|
+
/** Directory contact details only. The server intentionally does not expose clinic email addresses. */
|
|
4
|
+
interface RecordsClinic {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly address: string | null;
|
|
8
|
+
readonly phone: string | null;
|
|
9
|
+
readonly emailStatus: string;
|
|
10
|
+
readonly distanceKm: number | null;
|
|
11
|
+
}
|
|
12
|
+
interface RecordsClinicSearchInput {
|
|
13
|
+
readonly query?: string;
|
|
14
|
+
readonly location?: {
|
|
15
|
+
readonly latitude: number;
|
|
16
|
+
readonly longitude: number;
|
|
17
|
+
};
|
|
18
|
+
readonly limit?: number;
|
|
19
|
+
/** Use with the same query/location that produced it. Opaque; never decode it. */
|
|
20
|
+
readonly cursor?: string;
|
|
21
|
+
}
|
|
22
|
+
interface RecordsClinicSearchPage {
|
|
23
|
+
readonly clinics: readonly RecordsClinic[];
|
|
24
|
+
readonly nextCursor: string | null;
|
|
25
|
+
}
|
|
26
|
+
/** `GET /widget/v1/records/clinics/recent`: the directory clinics THIS member sent a request to before. */
|
|
27
|
+
interface RecordsRecentClinicsInput {
|
|
28
|
+
/** 1 to 25 (the route's bound); the server default when omitted. */
|
|
29
|
+
readonly limit?: number;
|
|
30
|
+
}
|
|
31
|
+
/** Backend-authored templates. Present them before signing; never substitute SDK-authored legal copy. */
|
|
32
|
+
interface RecordsAuthorizationCopy {
|
|
33
|
+
readonly authorizationVersion: string;
|
|
34
|
+
readonly scopeTemplate: string;
|
|
35
|
+
readonly authorizationTemplate: string;
|
|
36
|
+
}
|
|
37
|
+
type RecordsClinicTarget = {
|
|
38
|
+
readonly clinicId: string;
|
|
39
|
+
readonly clinicFreeText?: never;
|
|
40
|
+
} | {
|
|
41
|
+
readonly clinicId?: never;
|
|
42
|
+
readonly clinicFreeText: string;
|
|
43
|
+
};
|
|
44
|
+
/** Exactly one explicit authorization signature; never inferred from the partner's virtual user. */
|
|
45
|
+
type RecordsAuthorizationSignature = {
|
|
46
|
+
readonly signatureId: string;
|
|
47
|
+
readonly signaturePngBase64?: never;
|
|
48
|
+
} | {
|
|
49
|
+
readonly signatureId?: never;
|
|
50
|
+
readonly signaturePngBase64: string;
|
|
51
|
+
};
|
|
52
|
+
type CreateClinicRequestInput = RecordsClinicTarget & RecordsAuthorizationSignature & {
|
|
53
|
+
readonly petRef: PetRef;
|
|
54
|
+
readonly ownerName: string;
|
|
55
|
+
readonly authorizationVersion: string;
|
|
56
|
+
/** Owner-supplied contact only; server anti-relay checks prevent redirecting an addressable clinic. */
|
|
57
|
+
readonly clinicEmail?: string;
|
|
58
|
+
/** Stable for retries of this authorization, distinct for a new authorization. */
|
|
59
|
+
readonly idempotencyKey: string;
|
|
60
|
+
};
|
|
61
|
+
/** Multipart signature upload policy. Do not log or persist this short-lived credential. */
|
|
62
|
+
interface RecordsSignatureUploadPolicy {
|
|
63
|
+
readonly uploadId: string;
|
|
64
|
+
readonly uploadUrl: string;
|
|
65
|
+
readonly uploadFields: Readonly<Record<string, string>>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type { CreateClinicRequestInput as C, RecordsClinic as R, RecordsClinicTarget as a, RecordsAuthorizationSignature as b, RecordsClinicSearchInput as c, RecordsClinicSearchPage as d, RecordsRecentClinicsInput as e, RecordsAuthorizationCopy as f, RecordsSignatureUploadPolicy as g };
|