@everfur/sdk 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/{Chat.d-D9n8tSDD.d.cts → Chat.d-Bl-_TsvQ.d.cts} +1 -1
  2. package/dist/{Chat.d-BXuEjJsg.d.ts → Chat.d-qQVN6VLp.d.ts} +1 -1
  3. package/dist/animations/index.cjs +1 -1
  4. package/dist/animations/index.js +1 -1
  5. package/dist/{attachments.d-Bsg6duaq.d.cts → attachments.d-DBlHzWYy.d.cts} +1 -1
  6. package/dist/{attachments.d-DjWUR-h9.d.ts → attachments.d-DOmkQ_8O.d.ts} +1 -1
  7. package/dist/{branding.d-Bzs4HJoN.d.cts → branding.d-CqDLKj1U.d.cts} +1 -1
  8. package/dist/{branding.d-CiC6xfGT.d.ts → branding.d-XrZYClN4.d.ts} +1 -1
  9. package/dist/chat/index.cjs +194 -194
  10. package/dist/chat/index.d.cts +7 -7
  11. package/dist/chat/index.d.ts +7 -7
  12. package/dist/chat/index.js +202 -202
  13. package/dist/chat/lite/index.cjs +205 -205
  14. package/dist/chat/lite/index.d.cts +7 -7
  15. package/dist/chat/lite/index.d.ts +7 -7
  16. package/dist/chat/lite/index.js +205 -205
  17. package/dist/{chatHandoffToken.d-sbumx0He.d.cts → chatHandoffToken.d-B4-iQ35P.d.cts} +3 -3
  18. package/dist/{chatHandoffToken.d-YJY6TZbj.d.ts → chatHandoffToken.d-Br3Gw3w-.d.ts} +3 -3
  19. package/dist/{checkin.d-DxpoRutq.d.cts → checkin.d-CAKQydg8.d.cts} +14 -2
  20. package/dist/{checkin.d-C6vh9KVr.d.ts → checkin.d-qvYXugN3.d.ts} +14 -2
  21. package/dist/{chunk-AJEELSFO.js → chunk-5OK2AF63.js} +14 -14
  22. package/dist/{chunk-II4QDD6F.js → chunk-6I4REU4U.js} +1 -1
  23. package/dist/{chunk-ZPIOCHKW.js → chunk-7MMJ7CYN.js} +1 -1
  24. package/dist/{chunk-FZ6DAQFH.js → chunk-PJHMKQ5C.js} +19 -19
  25. package/dist/client/index.cjs +2 -2
  26. package/dist/client/index.d.cts +7 -7
  27. package/dist/client/index.d.ts +7 -7
  28. package/dist/client/index.js +2 -2
  29. package/dist/consent/index.cjs +1 -1
  30. package/dist/consent/index.js +2 -2
  31. package/dist/{context.d-Cq2C4vdh.d.cts → context.d-DZfxKxNi.d.cts} +3 -3
  32. package/dist/{context.d-D1l56nFr.d.ts → context.d-FjU7dQP7.d.ts} +3 -3
  33. package/dist/core/index.cjs +21 -21
  34. package/dist/core/index.d.cts +10 -10
  35. package/dist/core/index.d.ts +10 -10
  36. package/dist/core/index.js +21 -21
  37. package/dist/{entitlementRepository.d-x2YFdgYD.d.ts → entitlementRepository.d-BltqS1W8.d.ts} +1 -1
  38. package/dist/{entitlementRepository.d-CEDU1gZE.d.cts → entitlementRepository.d-wfqpUIKN.d.cts} +1 -1
  39. package/dist/health-plan/index.cjs +1 -1
  40. package/dist/health-plan/index.d.cts +4 -4
  41. package/dist/health-plan/index.d.ts +4 -4
  42. package/dist/health-plan/index.js +1 -1
  43. package/dist/index.cjs +221 -221
  44. package/dist/index.d.cts +13 -13
  45. package/dist/index.d.ts +13 -13
  46. package/dist/index.js +221 -221
  47. package/dist/notifications/inbox/index.cjs +9 -9
  48. package/dist/notifications/inbox/index.js +9 -9
  49. package/dist/notifications/index.cjs +3 -3
  50. package/dist/notifications/index.d.cts +3 -3
  51. package/dist/notifications/index.d.ts +3 -3
  52. package/dist/notifications/index.js +6 -6
  53. package/dist/photo/index.cjs +1 -1
  54. package/dist/photo/index.js +23 -23
  55. package/dist/{presentation.d-CWGjwq8Z.d.cts → presentation.d-BkIvMtIl.d.cts} +3 -3
  56. package/dist/{presentation.d-CWGjwq8Z.d.ts → presentation.d-BkIvMtIl.d.ts} +3 -3
  57. package/dist/records/depth/index.cjs +1 -1
  58. package/dist/records/depth/index.js +1 -1
  59. package/dist/records/index.cjs +2 -2
  60. package/dist/records/index.d.cts +2 -2
  61. package/dist/records/index.d.ts +2 -2
  62. package/dist/records/index.js +71 -71
  63. package/dist/{route.d-IP_gkOWL.d.ts → route.d-B395-hNX.d.ts} +1 -1
  64. package/dist/{route.d-9wclfD-y.d.cts → route.d-DSSSpSB-.d.cts} +1 -1
  65. package/dist/{runtimeTypes.d-BdUe3tYs.d.ts → runtimeTypes.d-DAz0Tgw5.d.ts} +5 -5
  66. package/dist/{runtimeTypes.d-_UZ6rMUY.d.cts → runtimeTypes.d-DPh1Wh15.d.cts} +5 -5
  67. package/dist/server/events/index.cjs +3 -3
  68. package/dist/server/events/index.js +3 -3
  69. package/dist/server/index.cjs +8 -8
  70. package/dist/server/index.d.cts +15 -1
  71. package/dist/server/index.d.ts +15 -1
  72. package/dist/server/index.js +8 -8
  73. package/dist/slots/index.cjs +1 -1
  74. package/dist/slots/index.js +1 -1
  75. package/dist/tabs/index.cjs +2 -2
  76. package/dist/tabs/index.js +24 -24
  77. package/dist/televet/booking/index.cjs +51 -51
  78. package/dist/televet/booking/index.js +1 -1
  79. package/dist/televet/index.cjs +1 -1
  80. package/dist/televet/index.js +1 -1
  81. package/dist/testing/index.cjs +1 -1
  82. package/dist/testing/index.js +1 -1
  83. package/dist/testing/rn/index.cjs +8 -8
  84. package/dist/testing/rn/index.d.cts +5 -5
  85. package/dist/testing/rn/index.d.ts +5 -5
  86. package/dist/testing/rn/index.js +9 -9
  87. package/dist/testing/web/index.cjs +3 -3
  88. package/dist/testing/web/index.d.cts +5 -5
  89. package/dist/testing/web/index.d.ts +5 -5
  90. package/dist/testing/web/index.js +1 -1
  91. package/dist/texting/index.cjs +1 -1
  92. package/dist/texting/index.js +26 -26
  93. package/dist/{threadOptions.d-BW0rePcs.d.cts → threadOptions.d-DUQxxHyM.d.cts} +3 -3
  94. package/dist/{threadOptions.d-CrAb71J2.d.ts → threadOptions.d-DnM9UcMx.d.ts} +3 -3
  95. package/dist/{typeStyle.d-rzVzCfLz.d.ts → typeStyle.d-8mcLhtbH.d.ts} +1 -1
  96. package/dist/{typeStyle.d-B-YgiWcS.d.cts → typeStyle.d-CLrQZW-r.d.cts} +1 -1
  97. package/dist/{unreadStore.d-gCsleb6l.d.ts → unreadStore.d-CLnChKca.d.ts} +17 -9
  98. package/dist/{unreadStore.d-w5x6lEpR.d.cts → unreadStore.d-Donv4bcF.d.cts} +17 -9
  99. package/dist/{usePresentation.d-w5_oWKmh.d.ts → usePresentation.d-Buxz2Jkt.d.ts} +1 -1
  100. package/dist/{usePresentation.d-DefUwatV.d.cts → usePresentation.d-DUYzYXgA.d.cts} +1 -1
  101. package/dist/{useUnread.d-DeRDFtTb.d.cts → useUnread.d-7-cuCooM.d.cts} +3 -3
  102. package/dist/{useUnread.d-xDOpYyqx.d.ts → useUnread.d-B6Ehu0ao.d.ts} +3 -3
  103. package/dist/video/index.cjs +1 -1
  104. package/dist/video/index.js +1 -1
  105. package/dist/web/consent/index.cjs +3 -3
  106. package/dist/web/consent/index.js +5 -5
  107. package/dist/web/health-plan/index.cjs +2 -2
  108. package/dist/web/health-plan/index.d.cts +5 -5
  109. package/dist/web/health-plan/index.d.ts +5 -5
  110. package/dist/web/health-plan/index.js +1 -1
  111. package/dist/web/inbox/index.cjs +5 -5
  112. package/dist/web/inbox/index.js +5 -5
  113. package/dist/web/index.cjs +176 -176
  114. package/dist/web/index.d.cts +18 -18
  115. package/dist/web/index.d.ts +18 -18
  116. package/dist/web/index.js +181 -181
  117. package/dist/web/intro/index.cjs +10 -10
  118. package/dist/web/intro/index.js +6 -6
  119. package/dist/web/notifications/index.cjs +5 -5
  120. package/dist/web/notifications/index.d.cts +2 -2
  121. package/dist/web/notifications/index.d.ts +2 -2
  122. package/dist/web/notifications/index.js +1 -1
  123. package/dist/web/records/depth/index.cjs +1 -1
  124. package/dist/web/records/depth/index.js +1 -1
  125. package/dist/web/records/index.cjs +1 -1
  126. package/dist/web/records/index.js +1 -1
  127. package/dist/web/records-sheet/index.cjs +2 -2
  128. package/dist/web/records-sheet/index.js +2 -2
  129. package/dist/web/shop/index.cjs +1 -1
  130. package/dist/web/shop/index.js +15 -15
  131. package/dist/web/televet/booking/index.cjs +2 -2
  132. package/dist/web/televet/booking/index.js +64 -64
  133. package/dist/web/televet/call/index.cjs +1 -1
  134. package/dist/web/televet/call/index.js +1 -1
  135. package/dist/web/televet/index.cjs +6 -6
  136. package/dist/web/televet/index.js +1 -1
  137. package/dist/web/texting/index.cjs +1 -1
  138. package/dist/web/texting/index.js +1 -1
  139. package/dist/web/ui/index.cjs +1 -1
  140. package/dist/web/ui/index.js +33 -33
  141. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  /*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
2
- import{createContext,forwardRef as e,createElement as t,useRef as r,useMemo as n,useState as i,useCallback as l,useEffect as o,useReducer as a,useContext as s,useSyncExternalStore as d,Component as c}from"react";import{z as u}from"zod";import{TextInput as h,Platform as p,AccessibilityInfo as g,View as f,Pressable as m,ScrollView as b,ActivityIndicator as y,StyleSheet as v,PanResponder as w,KeyboardAvoidingView as k,Keyboard as x,Image as T,AppState as C,BackHandler as _,Text as R,Dimensions as S,Modal as z,RefreshControl as I,Linking as D,Animated as H,Share as L,Easing as P,useColorScheme as O,PixelRatio as $}from"react-native";import{jsx as B,jsxs as j,Fragment as A}from"react/jsx-runtime";import{useSafeAreaInsets as E}from"react-native-safe-area-context";var F=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],q=/* @__PURE__ */Object.freeze(F.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(q.map(e=>e.wireCode));var M=/* @__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",anonTokenInvalid:"authRejected",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",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound"}),N=/* @__PURE__ */Object.freeze(q.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:M[e.wireCode]}))),W=new Map(N.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),U=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(N.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...U]){let t=W.get(e+r);if(t)return t}}var G=/* @__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(e){return G[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";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"}}var V=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return V.has(e)}var K=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||K.has(e)}var Y=500,X=8e3,Q=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(Y*2**r,X);return Math.floor(t()*n)}var J="This feature isn't available on your account right now.",Z="Something in that request was not right. Check the details and try again.",ee=/* @__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:J,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:Z,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:J,runtimeDisposed:Z,unknown:"Something went wrong. Please try again."}),te="This session has ended. Please sign in again.",re="linked_account_read_only";function ne(e,t,r){return e==="conflict"&&r===re?J:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?te:userFacingError(e)}function userFacingError(e){return ee[e]}function ie(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var le=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===re,i={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:ne(e,t?.wireCode,n?re:null)};t?.httpStatus!==void 0&&(i.httpStatus=t.httpStatus),t?.requestId&&(i.requestId=t.requestId),typeof t?.reasonCode=="string"&&le.test(t.reasonCode)&&(i.reasonCode=t.reasonCode);let l=t?.retryAfterSeconds;if(typeof l=="number"&&Number.isFinite(l)&&l>=0&&(i.retryAfterSeconds=Math.round(l)),r);return t?.wireMessage&&ie(i,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&ie(i,"raw",t.raw),/* @__PURE__ */Object.freeze(i)}function ok(e,t){/* @__PURE__ */
2
+ import{createContext,forwardRef as e,createElement as t,useRef as r,useMemo as n,useState as i,useCallback as l,useEffect as o,useReducer as a,useContext as s,useSyncExternalStore as d,Component as c}from"react";import{z as u}from"zod";import{TextInput as h,Platform as p,AccessibilityInfo as g,View as f,Pressable as m,ScrollView as b,ActivityIndicator as y,StyleSheet as v,PanResponder as w,KeyboardAvoidingView as k,Keyboard as x,Image as T,AppState as _,BackHandler as C,Text as R,Dimensions as S,Modal as z,RefreshControl as I,Linking as D,Animated as H,Share as L,Easing as P,useColorScheme as O,PixelRatio as $}from"react-native";import{jsx as B,jsxs as j,Fragment as A}from"react/jsx-runtime";import{useSafeAreaInsets as E}from"react-native-safe-area-context";var F=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"timezone_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],q=/* @__PURE__ */Object.freeze(F.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(q.map(e=>e.wireCode));var M=/* @__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",anonTokenInvalid:"authRejected",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",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),N=/* @__PURE__ */Object.freeze(q.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:M[e.wireCode]}))),W=new Map(N.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),U=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(N.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...U]){let t=W.get(e+r);if(t)return t}}var G=/* @__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(e){return G[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";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"}}var V=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return V.has(e)}var K=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||K.has(e)}var Y=500,X=8e3,Q=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(Y*2**r,X);return Math.floor(t()*n)}var J="This feature isn't available on your account right now.",Z="Something in that request was not right. Check the details and try again.",ee=/* @__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:J,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:Z,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:J,runtimeDisposed:Z,unknown:"Something went wrong. Please try again."}),te="This session has ended. Please sign in again.",re="linked_account_read_only";function ne(e,t,r){return e==="conflict"&&r===re?J:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?te:userFacingError(e)}function userFacingError(e){return ee[e]}function ie(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var le=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===re,i={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:ne(e,t?.wireCode,n?re:null)};t?.httpStatus!==void 0&&(i.httpStatus=t.httpStatus),t?.requestId&&(i.requestId=t.requestId),typeof t?.reasonCode=="string"&&le.test(t.reasonCode)&&(i.reasonCode=t.reasonCode);let l=t?.retryAfterSeconds;if(typeof l=="number"&&Number.isFinite(l)&&l>=0&&(i.retryAfterSeconds=Math.round(l)),r);return t?.wireMessage&&ie(i,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&ie(i,"raw",t.raw),/* @__PURE__ */Object.freeze(i)}function ok(e,t){/* @__PURE__ */
3
3
  return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
4
- return Object.freeze({ok:false,error:e})}var oe=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var ae=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function se(e,t){let r=globalThis.URL;if(typeof r=="function"){let n;try{n=t===void 0?new r(e):new r(e,t)}catch{return null}try{if(n.protocol)return n}catch{}}return he(e,t)}var de=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,ce=/[\s\u0000-\u001f\u007f\\]/,ue={"http:":"80","https:":"443"};function he(e,t){let r=e.trim();if(t!==void 0&&!ae.test(r)){let e=he(t);if(e===null||!r.startsWith("/")||r.startsWith("//"))return null;r=e.origin+r}let n=ce.test(r)?null:de.exec(r);if(n===null)return null;let[,i="",l="",o="",a="",s="",d="",c="",u=""]=n,h=`${i.toLowerCase()}:`,p=Number(s);if(p>65535)return null;let g=s===""||String(p)===ue[h]?"":String(p),f=ue[h]!==void 0,m=a.toLowerCase()+(g&&`:${g}`),b=d||(f?"/":""),y=l||o?`${l}${o&&`:${o}`}@`:"";return{href:`${h}//${y}${m}${b}${c}${u}`,protocol:h,username:l,password:o,hostname:a.toLowerCase(),port:g,origin:f?`${h}//${m}`:"null",pathname:b,search:c==="?"?"":c,hash:u==="#"?"":u}}var pe=/* @__PURE__ */Object.freeze(["vet","groomer","boarding"]),ge=/* @__PURE__ */u.string().min(1).refine(e=>e.startsWith("https://")),fe=/* @__PURE__ */u.string().nullish(),me=/* @__PURE__ */u.unknown().optional(),be=/* @__PURE__ */u.object({share_id:/* @__PURE__ */u.string().min(1),share_url:/* @__PURE__ */u.string().min(1),expires_at:fe,audience:me}),ye=/* @__PURE__ */u.object({shares:/* @__PURE__ */u.array(/* @__PURE__ */u.object({share_id:/* @__PURE__ */u.string().min(1),expires_at:fe,created_at:fe,view_count:/* @__PURE__ */u.number().int().nonnegative().nullish(),last_viewed_at:fe,audience:me})).optional()}),ve=/* @__PURE__ */u.object({download_url:ge,expires_at:fe}),we=/* @__PURE__ */u.object({share_id:/* @__PURE__ */u.string().min(1),expires_at:fe,audience:me}),ke=/* @__PURE__ */u.object({audience:/* @__PURE__ */u.string().min(1),sections:/* @__PURE__ */u.array(/* @__PURE__ */u.string()),entity_types:/* @__PURE__ */u.array(/* @__PURE__ */u.string()).nullable()}),xe=254;function isShareRecipientEmail(e){let t=e.trim();return t.length>0&&t.length<=xe&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(t)}var Te=e=>typeof e=="string"&&pe.includes(e);function Ce(e){return Te(e)?e:null}function mapShareAudiences(e){let t=u.array(ke).safeParse(e);if(!t.success)/* @__PURE__ */return Object.freeze([]);let r=/* @__PURE__ */new Set,n=[];for(let e of t.data)!Te(e.audience)||r.has(e.audience)||(r.add(e.audience),n.push(/* @__PURE__ */Object.freeze({audience:e.audience,sections:/* @__PURE__ */Object.freeze([...e.sections]),entityTypes:e.entity_types===null?null:/* @__PURE__ */Object.freeze([...e.entity_types])}))/* @__PURE__ */);return Object.freeze(n)}function resolveShareUrl(e,t){let r=e.trim();if(r.length===0)return null;let n=/^[a-z][a-z0-9+.-]*:/i.test(r)?se(r):t!==void 0?se(r,t):null;return n===null||n.protocol!=="https:"?null:n.href}function mapRecordShareLink(e,t){let r=be.safeParse(e);if(!r.success)return null;let n=resolveShareUrl(r.data.share_url,t);return n===null?null:/* @__PURE__ */Object.freeze({shareId:r.data.share_id,shareUrl:n,expiresAt:r.data.expires_at??null,audience:Ce(r.data.audience)})}function mapRecordShareList(e){let t=ye.safeParse(e);return t.success?/* @__PURE__ */Object.freeze((t.data.shares??[]).map(e=>/* @__PURE__ */Object.freeze({shareId:e.share_id,expiresAt:e.expires_at??null,createdAt:e.created_at??null,viewCount:e.view_count??0,lastViewedAt:e.last_viewed_at??null,audience:Ce(e.audience)}))):null}function mapRecordShareEmailReceipt(e){let t=we.safeParse(e);return t.success?/* @__PURE__ */Object.freeze({shareId:t.data.share_id,expiresAt:t.data.expires_at??null,audience:Ce(t.data.audience)}):null}function mapRecordPdfLink(e){let t=ve.safeParse(e);return t.success?/* @__PURE__ */Object.freeze({downloadUrl:t.data.download_url,expiresAt:t.data.expires_at??null}):null}var _e="application/pdf",Re=/* @__PURE__ */Object.freeze(["image/jpeg","image/png","image/heic","image/heif"]),Se=e=>Re.includes(e);function ze(e,t){return e===_e||t!==void 0&&Se(e)&&t.includes(e)}var Ie=/* @__PURE__ */Object.freeze({features:/* @__PURE__ */Object.freeze({}),uploadContentTypes:/* @__PURE__ */Object.freeze([_e]),shareAudiences:/* @__PURE__ */Object.freeze([])}),De=/* @__PURE__ */u.object({features:/* @__PURE__ */u.record(/* @__PURE__ */u.boolean()),upload_content_types:/* @__PURE__ */u.array(/* @__PURE__ */u.string()).nullish(),share_audiences:/* @__PURE__ */u.unknown().optional()});function He(e){let t=De.safeParse(e);if(!t.success)return Ie;let r=t.data.upload_content_types??[],n=Re.filter(e=>r.includes(e));/* @__PURE__ */
5
- return Object.freeze({features:/* @__PURE__ */Object.freeze({...t.data.features}),uploadContentTypes:/* @__PURE__ */Object.freeze([_e,...n]),shareAudiences:mapShareAudiences(t.data.share_audiences)})}function acceptsPhotos(e){return e!==void 0&&e.some(Se)}function Le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Pe=/* @__PURE__ */new Set(["requested","awaiting_clinic","awaiting_upload","received","parsing","in_review","published","failed","revoked"]),Oe=/* @__PURE__ */Object.freeze({submitted:"requested",sent:"requested",dispatching:"requested",awaiting_response:"awaiting_clinic",clinic_responded_no_records:"awaiting_clinic",records_received:"received",parsing_failed:"in_review",review_email_failed:"in_review",clinic_declined:"failed"});function $e(e){let t=Object.prototype.hasOwnProperty.call(Oe,e)?Oe[e]:void 0;if(t!==void 0)return t;let r=e;return Pe.has(r)?r:"parsing"}function Be(e){return e==="owner_reported"||e==="clinic_document"?e:null}var je=/* @__PURE__ */u.object({request_id:/* @__PURE__ */u.string().min(1),pet_ref:/* @__PURE__ */u.string().min(1),status:/* @__PURE__ */u.string(),simple_status:/* @__PURE__ */u.string().nullish(),simple_status_detail:/* @__PURE__ */u.string().nullish(),status_label:/* @__PURE__ */u.string().optional(),dispatch_status:/* @__PURE__ */u.string().nullish(),can_retry_send:/* @__PURE__ */u.boolean().optional(),can_revoke:/* @__PURE__ */u.boolean().optional(),can_convert_to_upload:/* @__PURE__ */u.boolean().optional(),can_update_clinic_email:/* @__PURE__ */u.boolean().optional(),reminder_count:/* @__PURE__ */u.number().int().nonnegative().optional(),last_reminder_at:/* @__PURE__ */u.string().nullish(),waiting_expectation:/* @__PURE__ */u.string().nullish(),document_count:/* @__PURE__ */u.number().optional(),held_item_count:/* @__PURE__ */u.number().optional(),received_at:/* @__PURE__ */u.string().nullish(),parsing_started_at:/* @__PURE__ */u.string().nullish(),review_started_at:/* @__PURE__ */u.string().nullish(),created_at:/* @__PURE__ */u.string().optional(),updated_at:/* @__PURE__ */u.string().optional(),source:/* @__PURE__ */u.string().nullish().catch(null),action_needed_label:/* @__PURE__ */u.string().nullish().catch(null),failure_reason:/* @__PURE__ */u.string().nullish().catch(null),failure_code:/* @__PURE__ */u.string().nullish().catch(null),recovery_stage:/* @__PURE__ */u.string().nullish().catch(null),show_clinic_phone:/* @__PURE__ */u.boolean().optional().catch(void 0),clinic_name:/* @__PURE__ */u.string().nullish().catch(null),clinic_email:/* @__PURE__ */u.string().nullish().catch(null),clinic_phone:/* @__PURE__ */u.string().nullish().catch(null),converted_to_upload_at:/* @__PURE__ */u.string().nullish().catch(null),request_group_id:/* @__PURE__ */u.string().nullish().catch(null)}).passthrough();function Ae(e){let t=je.safeParse(e);if(!t.success)return null;let r=t.data,n=qe(r.simple_status),i=n==="requested"&&(r.status==="awaiting_upload"||r.simple_status_detail==="awaiting_owner_upload")?"awaiting_upload":n==="parsing"&&(r.simple_status_detail==="in_review"||r.simple_status_detail==="review_email_failed")?"in_review":n??$e(r.status);/* @__PURE__ */
4
+ return Object.freeze({ok:false,error:e})}var oe=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var ae=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function se(e,t){let r=globalThis.URL;if(typeof r=="function"){let n;try{n=t===void 0?new r(e):new r(e,t)}catch{return null}try{if(n.protocol)return n}catch{}}return he(e,t)}var de=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,ce=/[\s\u0000-\u001f\u007f\\]/,ue={"http:":"80","https:":"443"};function he(e,t){let r=e.trim();if(t!==void 0&&!ae.test(r)){let e=he(t);if(e===null||!r.startsWith("/")||r.startsWith("//"))return null;r=e.origin+r}let n=ce.test(r)?null:de.exec(r);if(n===null)return null;let[,i="",l="",o="",a="",s="",d="",c="",u=""]=n,h=`${i.toLowerCase()}:`,p=Number(s);if(p>65535)return null;let g=s===""||String(p)===ue[h]?"":String(p),f=ue[h]!==void 0,m=a.toLowerCase()+(g&&`:${g}`),b=d||(f?"/":""),y=l||o?`${l}${o&&`:${o}`}@`:"";return{href:`${h}//${y}${m}${b}${c}${u}`,protocol:h,username:l,password:o,hostname:a.toLowerCase(),port:g,origin:f?`${h}//${m}`:"null",pathname:b,search:c==="?"?"":c,hash:u==="#"?"":u}}var pe=/* @__PURE__ */Object.freeze(["vet","groomer","boarding"]),ge=/* @__PURE__ */u.string().min(1).refine(e=>e.startsWith("https://")),fe=/* @__PURE__ */u.string().nullish(),me=/* @__PURE__ */u.unknown().optional(),be=/* @__PURE__ */u.object({share_id:/* @__PURE__ */u.string().min(1),share_url:/* @__PURE__ */u.string().min(1),expires_at:fe,audience:me}),ye=/* @__PURE__ */u.object({shares:/* @__PURE__ */u.array(/* @__PURE__ */u.object({share_id:/* @__PURE__ */u.string().min(1),expires_at:fe,created_at:fe,view_count:/* @__PURE__ */u.number().int().nonnegative().nullish(),last_viewed_at:fe,audience:me})).optional()}),ve=/* @__PURE__ */u.object({download_url:ge,expires_at:fe}),we=/* @__PURE__ */u.object({share_id:/* @__PURE__ */u.string().min(1),expires_at:fe,audience:me}),ke=/* @__PURE__ */u.object({audience:/* @__PURE__ */u.string().min(1),sections:/* @__PURE__ */u.array(/* @__PURE__ */u.string()),entity_types:/* @__PURE__ */u.array(/* @__PURE__ */u.string()).nullable()}),xe=254;function isShareRecipientEmail(e){let t=e.trim();return t.length>0&&t.length<=xe&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(t)}var Te=e=>typeof e=="string"&&pe.includes(e);function _e(e){return Te(e)?e:null}function mapShareAudiences(e){let t=u.array(ke).safeParse(e);if(!t.success)/* @__PURE__ */return Object.freeze([]);let r=/* @__PURE__ */new Set,n=[];for(let e of t.data)!Te(e.audience)||r.has(e.audience)||(r.add(e.audience),n.push(/* @__PURE__ */Object.freeze({audience:e.audience,sections:/* @__PURE__ */Object.freeze([...e.sections]),entityTypes:e.entity_types===null?null:/* @__PURE__ */Object.freeze([...e.entity_types])}))/* @__PURE__ */);return Object.freeze(n)}function resolveShareUrl(e,t){let r=e.trim();if(r.length===0)return null;let n=/^[a-z][a-z0-9+.-]*:/i.test(r)?se(r):t!==void 0?se(r,t):null;return n===null||n.protocol!=="https:"?null:n.href}function mapRecordShareLink(e,t){let r=be.safeParse(e);if(!r.success)return null;let n=resolveShareUrl(r.data.share_url,t);return n===null?null:/* @__PURE__ */Object.freeze({shareId:r.data.share_id,shareUrl:n,expiresAt:r.data.expires_at??null,audience:_e(r.data.audience)})}function mapRecordShareList(e){let t=ye.safeParse(e);return t.success?/* @__PURE__ */Object.freeze((t.data.shares??[]).map(e=>/* @__PURE__ */Object.freeze({shareId:e.share_id,expiresAt:e.expires_at??null,createdAt:e.created_at??null,viewCount:e.view_count??0,lastViewedAt:e.last_viewed_at??null,audience:_e(e.audience)}))):null}function mapRecordShareEmailReceipt(e){let t=we.safeParse(e);return t.success?/* @__PURE__ */Object.freeze({shareId:t.data.share_id,expiresAt:t.data.expires_at??null,audience:_e(t.data.audience)}):null}function mapRecordPdfLink(e){let t=ve.safeParse(e);return t.success?/* @__PURE__ */Object.freeze({downloadUrl:t.data.download_url,expiresAt:t.data.expires_at??null}):null}var Ce="application/pdf",Re=/* @__PURE__ */Object.freeze(["image/jpeg","image/png","image/heic","image/heif"]),Se=e=>Re.includes(e);function ze(e,t){return e===Ce||t!==void 0&&Se(e)&&t.includes(e)}var Ie=/* @__PURE__ */Object.freeze({features:/* @__PURE__ */Object.freeze({}),uploadContentTypes:/* @__PURE__ */Object.freeze([Ce]),shareAudiences:/* @__PURE__ */Object.freeze([])}),De=/* @__PURE__ */u.object({features:/* @__PURE__ */u.record(/* @__PURE__ */u.boolean()),upload_content_types:/* @__PURE__ */u.array(/* @__PURE__ */u.string()).nullish(),share_audiences:/* @__PURE__ */u.unknown().optional()});function He(e){let t=De.safeParse(e);if(!t.success)return Ie;let r=t.data.upload_content_types??[],n=Re.filter(e=>r.includes(e));/* @__PURE__ */
5
+ return Object.freeze({features:/* @__PURE__ */Object.freeze({...t.data.features}),uploadContentTypes:/* @__PURE__ */Object.freeze([Ce,...n]),shareAudiences:mapShareAudiences(t.data.share_audiences)})}function acceptsPhotos(e){return e!==void 0&&e.some(Se)}function Le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Pe=/* @__PURE__ */new Set(["requested","awaiting_clinic","awaiting_upload","received","parsing","in_review","published","failed","revoked"]),Oe=/* @__PURE__ */Object.freeze({submitted:"requested",sent:"requested",dispatching:"requested",awaiting_response:"awaiting_clinic",clinic_responded_no_records:"awaiting_clinic",records_received:"received",parsing_failed:"in_review",review_email_failed:"in_review",clinic_declined:"failed"});function $e(e){let t=Object.prototype.hasOwnProperty.call(Oe,e)?Oe[e]:void 0;if(t!==void 0)return t;let r=e;return Pe.has(r)?r:"parsing"}function Be(e){return e==="owner_reported"||e==="clinic_document"?e:null}var je=/* @__PURE__ */u.object({request_id:/* @__PURE__ */u.string().min(1),pet_ref:/* @__PURE__ */u.string().min(1),status:/* @__PURE__ */u.string(),simple_status:/* @__PURE__ */u.string().nullish(),simple_status_detail:/* @__PURE__ */u.string().nullish(),status_label:/* @__PURE__ */u.string().optional(),dispatch_status:/* @__PURE__ */u.string().nullish(),can_retry_send:/* @__PURE__ */u.boolean().optional(),can_revoke:/* @__PURE__ */u.boolean().optional(),can_convert_to_upload:/* @__PURE__ */u.boolean().optional(),can_update_clinic_email:/* @__PURE__ */u.boolean().optional(),reminder_count:/* @__PURE__ */u.number().int().nonnegative().optional(),last_reminder_at:/* @__PURE__ */u.string().nullish(),waiting_expectation:/* @__PURE__ */u.string().nullish(),document_count:/* @__PURE__ */u.number().optional(),held_item_count:/* @__PURE__ */u.number().optional(),received_at:/* @__PURE__ */u.string().nullish(),parsing_started_at:/* @__PURE__ */u.string().nullish(),review_started_at:/* @__PURE__ */u.string().nullish(),created_at:/* @__PURE__ */u.string().optional(),updated_at:/* @__PURE__ */u.string().optional(),source:/* @__PURE__ */u.string().nullish().catch(null),action_needed_label:/* @__PURE__ */u.string().nullish().catch(null),failure_reason:/* @__PURE__ */u.string().nullish().catch(null),failure_code:/* @__PURE__ */u.string().nullish().catch(null),recovery_stage:/* @__PURE__ */u.string().nullish().catch(null),show_clinic_phone:/* @__PURE__ */u.boolean().optional().catch(void 0),clinic_name:/* @__PURE__ */u.string().nullish().catch(null),clinic_email:/* @__PURE__ */u.string().nullish().catch(null),clinic_phone:/* @__PURE__ */u.string().nullish().catch(null),converted_to_upload_at:/* @__PURE__ */u.string().nullish().catch(null),request_group_id:/* @__PURE__ */u.string().nullish().catch(null)}).passthrough();function Ae(e){let t=je.safeParse(e);if(!t.success)return null;let r=t.data,n=qe(r.simple_status),i=n==="requested"&&(r.status==="awaiting_upload"||r.simple_status_detail==="awaiting_owner_upload")?"awaiting_upload":n==="parsing"&&(r.simple_status_detail==="in_review"||r.simple_status_detail==="review_email_failed")?"in_review":n??$e(r.status);/* @__PURE__ */
6
6
  return Object.freeze({id:r.request_id,petRef:r.pet_ref,status:i,simpleStatus:n,simpleStatusDetail:r.simple_status_detail??null,statusLabel:r.status_label??"",dispatchStatus:r.dispatch_status??null,canRetrySend:r.can_retry_send===true,canRevoke:r.can_revoke===true,canConvertToUpload:r.can_convert_to_upload===true,canUpdateClinicEmail:r.can_update_clinic_email===true,reminderCount:r.reminder_count??0,lastReminderAt:r.last_reminder_at??null,waitingExpectation:r.waiting_expectation??null,documentCount:ot(r.document_count,0),heldItemCount:ot(r.held_item_count,0),receivedAt:r.received_at??null,parsingStartedAt:r.parsing_started_at??null,reviewStartedAt:r.review_started_at??null,createdAt:r.created_at??"",updatedAt:r.updated_at??"",wireStatus:r.status,source:r.source??null,actionNeededLabel:r.action_needed_label??null,failureReason:r.failure_reason??null,failureCode:r.failure_code??null,recoveryStage:r.recovery_stage??null,showClinicPhone:r.show_clinic_phone===true,clinicName:r.clinic_name??null,clinicEmail:r.clinic_email??null,clinicPhone:r.clinic_phone??null,convertedToUploadAt:r.converted_to_upload_at??null,requestGroupId:r.request_group_id??null})}var Ee=/* @__PURE__ */u.object({request_group_id:/* @__PURE__ */u.string().min(1),pet_ref:/* @__PURE__ */u.string().min(1),total:/* @__PURE__ */u.number().int().nonnegative(),responded:/* @__PURE__ */u.number().int().nonnegative(),pending:/* @__PURE__ */u.number().int().nonnegative(),members:/* @__PURE__ */u.array(/* @__PURE__ */u.unknown())});function Fe(e){let t=Ee.safeParse(e);if(!t.success)return null;let r=t.data,n=Me(r.members);return n.some(e=>e.petRef!==r.pet_ref)?null:/* @__PURE__ */Object.freeze({requestGroupId:r.request_group_id,petRef:r.pet_ref,total:r.total,responded:r.responded,pending:r.pending,members:n})}function qe(e){return!e||e==="awaiting_upload"||e==="in_review"?null:Pe.has(e)?e:null}function Me(e){let t=Array.isArray(e)?e:[],r=[];for(let e of t){let t=Ae(e);t!==null&&r.push(t)}/* @__PURE__ */
7
7
  return Object.freeze(r)}var Ne=/* @__PURE__ */u.object({source_doc_id:/* @__PURE__ */u.string().min(1),request_id:/* @__PURE__ */u.string().min(1)});function We(e){let t=Ne.safeParse(e);return t.success?/* @__PURE__ */Object.freeze({documentId:t.data.source_doc_id,requestId:t.data.request_id,status:"received"}):null}var Ue=/* @__PURE__ */u.object({label:/* @__PURE__ */u.string(),value:/* @__PURE__ */u.string()}),Ge=/* @__PURE__ */u.object({key:/* @__PURE__ */u.string(),category:/* @__PURE__ */u.string().optional(),label:/* @__PURE__ */u.string().optional(),value:/* @__PURE__ */u.string().nullish(),unit:/* @__PURE__ */u.string().nullish(),observed_at:/* @__PURE__ */u.string().nullish(),status:/* @__PURE__ */u.string().nullish(),origin:/* @__PURE__ */u.string().nullish(),canonical_key:/* @__PURE__ */u.string().nullish()}),Ve=/* @__PURE__ */u.object({at:/* @__PURE__ */u.string(),value:/* @__PURE__ */u.number().nullish(),display:/* @__PURE__ */u.string().nullish(),origin:/* @__PURE__ */u.string().nullish()}),Ke=/* @__PURE__ */u.object({key:/* @__PURE__ */u.string(),label:/* @__PURE__ */u.string().optional(),points:/* @__PURE__ */u.array(Ve).optional()}),Ye=/* @__PURE__ */u.object({title:/* @__PURE__ */u.string(),detail:/* @__PURE__ */u.string().nullish(),due_at:/* @__PURE__ */u.string().nullish(),care_item_key:/* @__PURE__ */u.string().nullish(),due_date_source:/* @__PURE__ */u.string().nullish()}),Xe=/* @__PURE__ */u.object({doc_id:/* @__PURE__ */u.string(),title:/* @__PURE__ */u.string().nullish(),document_class:/* @__PURE__ */u.string().nullish(),page_count:/* @__PURE__ */u.number().nullish(),received_at:/* @__PURE__ */u.string().nullish()});function Qe(e){/* @__PURE__ */
8
8
  return Object.freeze({key:e.key,category:e.category??"",label:e.label??e.key,value:e.value??null,unit:e.unit??null,observedAt:e.observed_at??null,status:e.status??null,origin:Be(e.origin),canonicalKey:e.canonical_key??null})}function Je(e){/* @__PURE__ */
@@ -11,15 +11,15 @@ return Object.freeze({petRef:i,schemaVersion:r,isEmpty:h,withheld:false,generate
11
11
  return Object.freeze({petRef:petRef,schemaVersion:e,isEmpty:false,withheld:true,generatedAt:null,identity:/* @__PURE__ */Object.freeze([]),entities:/* @__PURE__ */Object.freeze([]),entitySeries:/* @__PURE__ */Object.freeze([]),forwardLooking:/* @__PURE__ */Object.freeze([]),documents:/* @__PURE__ */Object.freeze({}),disclaimer:t})}var rt=/* @__PURE__ */u.object({pet_ref:/* @__PURE__ */u.string().optional(),granted:/* @__PURE__ */u.boolean().optional(),version:/* @__PURE__ */u.string().nullish(),granted_at:/* @__PURE__ */u.string().nullish()});function nt(petRef,e){let t=rt.safeParse(e),r=t.success?t.data:{};/* @__PURE__ */
12
12
  return Object.freeze({petRef:typeof r.pet_ref=="string"&&r.pet_ref.length>0?r.pet_ref:petRef,granted:r.granted===true,version:r.version??null,grantedAt:r.granted_at??null})}var it=/* @__PURE__ */u.object({granted:/* @__PURE__ */u.boolean().optional(),version:/* @__PURE__ */u.string().nullish(),granted_at:/* @__PURE__ */u.string().nullish(),pets:/* @__PURE__ */u.array(/* @__PURE__ */u.unknown()).optional()});function lt(e){let t=it.safeParse(e),r=t.success?t.data:{};/* @__PURE__ */
13
13
  return Object.freeze({scope:"all_pets",granted:r.granted===true,version:r.version??null,grantedAt:r.granted_at??null,pets:/* @__PURE__ */Object.freeze((r.pets??[]).map(e=>nt("",e)).filter(e=>e.petRef))})}function ot(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function at(e,t){return typeof e=="string"&&e.length>0?e:t}function st(e){return typeof e=="string"&&e.length>0?e:null}var dt=/* @__PURE__ */Object.freeze(["published","failed","revoked"]);function isTerminalStatus(e){return dt.includes(e)}function recordsDenialReasonOf(e){if(e===null)return null;let t=e.recordsReason;return t==="consent_required"||t==="session_required"||t==="entitlement"||t==="pet_not_found"?t:null}var ct="records_consent_required";function ut(e){let t=e.raw;if(t===null||typeof t!="object")return null;let r=t,n=typeof r.error=="object"&&r.error!==null?r.error.code:r.code;return typeof n=="string"&&n.length>0?n:null}function ht(e){return e===null||e.httpStatus!==409?false:ut(e)===ct}var pt=/* @__PURE__ */Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function gt(e){return e!==pt}var ft=/* @__PURE__ */Object.freeze({record(){}}),mt=25*1024*1024,bt=64,yt=128,vt=128;var wt=9e4;function kt(e,t){let r=!t[0]&&e.length>0&&e.every(e=>e.granted);/* @__PURE__ */
14
- return Object.freeze({scope:"all_pets",granted:r,version:r?e[0]?.version??null:null,grantedAt:null,pets:/* @__PURE__ */Object.freeze(e),...t[0]?{failed:/* @__PURE__ */Object.freeze(t)}:{}})}function xt(e){return new Tt(e)}var Tt=class{constructor(e){this.recordCache=/* @__PURE__ */new Map;this.consentEpoch=/* @__PURE__ */new Map;this.reportedGaps=/* @__PURE__ */new Set;this.features=Ie;this.repository=e.repository,this.uploads=e.uploads,this.telemetry=e.telemetry??ft,this.newIdempotencyKey=e.newIdempotencyKey??Dt(),this.timers=e.timers??zt,this.uploadDeadlineMs=e.uploadDeadlineMs??wt}async createUploadRequest(e){let t=await this.repository.createRequest({pet_ref:e.petRef,idempotency_key:e.idempotencyKey});if(!t.ok)return this.onRequestError(t.error);let r=Ae(t.value);return r===null?err(St()):(this.observeRequest(r),ok(r))}async getRequest(e){let t=await this.repository.getRequest(e);if(!t.ok)return this.onRequestError(t.error);let r=Ae(t.value);return r===null?err(St()):(this.observeRequest(r),ok(r))}async listRequests(){let e=await this.repository.listRequests();if(!e.ok)return this.onRequestError(e.error);let t=Me(e.value);for(let e of t)this.observeRequest(e);return ok(t)}async readFeatures(){let e=this.repository.getFeatures;if(e===void 0)return this.features=Ie;let t=Ie;try{let r=await e.call(this.repository);r.ok&&(t=He(r.value))}catch{}return this.features=t,t}async uploadDocument(e){let{requestId:t,file:r}=e,n=Ct(r,this.features.uploadContentTypes);if(n!==null)return this.telemetry.record("records.upload.rejected",{reason:n}),err(Rt(`upload rejected: ${n}`));let i=await this.repository.initiateUpload(t,{content_type:r.mimeType,file_size:r.sizeBytes});if(!i.ok)return this.onRequestError(i.error);let l=await this.postToS3(i.value,r,e);if(!l.ok)return this.telemetry.record("records.upload.failed",{reason:l.reason}),err(Rt(l.reason));let o=await this.repository.completeUpload(t,{upload_id:i.value.upload_id});if(!o.ok)return o.error.code==="mediaUploadFailed"&&this.telemetry.record("records.upload.rejected",{reason:_t(o.error)??"corrupt"}),this.onRequestError(o.error);let a=We(o.value);return a===null?err(St()):ok(a)}async postToS3(e,t,r){let n=new AbortController,i=It(n.signal,r.signal),l=this.timers.setTimeout(()=>n.abort(),this.uploadDeadlineMs);try{let n={signal:i};return r.onProgress&&(n.onProgress=r.onProgress),await this.uploads.postMultipart(e,t,n),{ok:!0}}catch{return{ok:false,reason:n.signal.aborted&&r.signal?.aborted!==true?"timeout":"upload_error"}}finally{this.timers.clearTimeout(l)}}async getRecord(e){let t=this.consentEpoch.get(e)??0,r=await this.repository.getRecord(e);if(t!==(this.consentEpoch.get(e)??0))return err(/* @__PURE__ */Object.freeze({...makeEverfurError("accessDenied",{retryable:false}),recordsReason:"consent_required"}));if(!r.ok){let t=recordsDenialReasonOf(r.error);return t==="consent_required"?(this.recordCache.delete(e),this.telemetry.record("records.consent.denied",{pet_ref:e})):t==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:e}),err(r.error)}let n=et(e,r.value);return n.petRef!==e?err(St()):n.withheld?(this.telemetry.record("records.redaction.withheld",{pet_ref:e}),this.recordCache.delete(e),ok(n)):(this.recordCache.set(e,n),ok(n))}peekCachedRecord(e){return this.recordCache.get(e)??null}async getConsent(e){let t=await this.repository.getConsent(e);return t.ok?ok(nt(e,t.value)):err(t.error)}async grantConsent(e){let t=await this.repository.putConsent(e.petRef,{consent_version:e.consentVersion,idempotency_key:e.idempotencyKey});return t.ok?ok(nt(e.petRef,t.value)):(recordsDenialReasonOf(t.error)==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:e.petRef}),err(t.error))}async revokeConsent(e){let t=await this.repository.deleteConsent(e);return t.ok?(this.consentEpoch.set(e,(this.consentEpoch.get(e)??0)+1),this.recordCache.delete(e),ok(nt(e,t.value))):err(t.error)}async getMemberConsent(){let e=await(this.repository.getMemberConsent?.());return e?e.ok?ok(lt(e.value)):e:err(makeEverfurError("resourceNotFound",{retryable:false,httpStatus:404}))}grantConsentAllPets(e){return this.allPets(e,true)}revokeConsentAllPets(e){return this.allPets(e,false)}async allPets(e,t){let{petRef:petRef,consentVersion:r,idempotencyKey:n}=e,i=await(t?this.repository.putMemberConsent?.({consent_version:r,idempotency_key:n}):this.repository.deleteMemberConsent?.());if(i?.ok){let r=lt(i.value);if(!t){let t=/* @__PURE__ */new Set([petRef,...this.recordCache.keys(),...r.pets.map(e=>e.petRef)]);for(let e of t)this.consentEpoch.set(e,(this.consentEpoch.get(e)??0)+1);this.recordCache.clear();for(let r of t)e.onRevoked?.(r)}return ok(r)}if(i&&i.error.httpStatus!==404&&i.error.httpStatus!==405)return t&&recordsDenialReasonOf(i.error)==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:petRef}),i;let l;try{l=e.listPetRefs?ok(await e.listPetRefs()):await(this.repository.listPetRefs?.())??err(makeEverfurError("notImplemented",{retryable:!1}))}catch{l=err(makeEverfurError("internalError"))}let o=[],a=[];for(let i of l.ok?/* @__PURE__ */new Set([petRef,...l.value]):[petRef]){let l=await(t?this.grantConsent({petRef:i,consentVersion:r,idempotencyKey:n}):this.revokeConsent(i));if(l.ok)t||e.onRevoked?.(i);else{if(t&&i===petRef)return l;a.push(/* @__PURE__ */Object.freeze({petRef:i,error:l.error}))}o.push(l.ok?l.value:nt(i,null))}let s=t?null:a[0]?.error??(l.ok?null:l.error);return s?err(s):ok(kt(o,a))}reportCapabilityDenied(e){this.telemetry.record("records.capability.denied",e?{pet_ref:e}:{})}observeRequest(e){e.reviewStartedAt!==null&&!this.reportedGaps.has(e.id)&&(this.reportedGaps.add(e.id),this.telemetry.record("records.parse.gap",{request_id:e.id}))}onRequestError(e){return recordsDenialReasonOf(e)==="entitlement"&&this.telemetry.record("records.capability.denied",{}),err(e)}};function Ct(e,t){if(!ze(e.mimeType,t))return"unsupported_format";let r=e.sizeBytes;return typeof r!="number"||!Number.isFinite(r)||r<=0||r>mt?"oversize":null}function _t(e){let t=e.wireMessage;return t==="unsupported_format"||t==="oversize"||t==="corrupt"?t:null}function Rt(e){return makeEverfurError("mediaUploadFailed",{retryable:false,wireMessage:e})}function St(){return makeEverfurError("internalError",{retryable:true})}var zt={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)};function It(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=()=>r.abort();return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}function Dt(){let e=0;return()=>`records-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
15
- return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var Ht="x-everfur-anon-token",Lt="anonTokenInvalid";async function Pt(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function Ot(e,t){let r=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...r?{wireMessage:r}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[Ht]=e.anonToken)),e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}function withAuthHeaders(e,t){return{...e,headers:{...$t(e.headers),...authHeaders(t)}}}function $t(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let e=r.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===Ht||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await Pt(t),n=await t.transport.request(withAuthHeaders(e,Bt(t,r)));if(n.ok||At(n.error.raw)!==Lt||t.anonIdentity===void 0||t.userRef!==null)return n;let i=await t.anonIdentity.token({forceRefresh:true});return i===null||i===r?n:t.transport.request(withAuthHeaders(e,Bt(t,i)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(Ot(e))}let n=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let i;try{i=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(Ot(e,{wireCode:At(n.error.raw),requestId:n.error.requestId}))}let l=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:i,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!l.ok&&l.error.httpStatus===401?(t.identity.reportRejected?.(),err(jt(l.error))):l}function Bt(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function jt(e){let t=e.raw,r=At(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...r?{wireCode:r}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function At(e){if(typeof e!="object"||e===null)return null;let t=e,r=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof r=="string"&&r.length>0?r:null}var Et="1.4.0";function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:Ft(e)})}function Ft(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var qt=3e4,Mt=X*2,Nt="idempotency-key",Wt=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),Ut=/* @__PURE__ */Object.freeze({onEvent(){}}),Gt=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Vt(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}function createRequestFunnel(e){let t=e.observer??Ut,r=e.timers??Gt,n=e.rng??Math.random,i=e.sleep??((e,t)=>dr(e,r,t)),l=e.maxAttempts??Q,o=e.unaryTimeoutMs??qt,a=e.newIdempotencyKey??Yt(),s=e=>{try{t.onEvent(e)}catch{}};async function d(t,d,c){let u=c?.maxAttempts,h=Math.max(1,u??l),p=c?.idempotent??Wt.has(d.method),g=c?.idempotencyKey===void 0?null:Vt(c.idempotencyKey),f=p?g??a():null,m=Kt(d,f),b=0;for(;;){let l=e=>/* @__PURE__ */Object.freeze({call:t,method:d.method,path:d.path,attempt:b,...f?{idempotencyKey:f}:{},...e});s(l({phase:"attempt"}));let a=ar(o,r),c=sr(a.signal,d.signal),p;try{p=await authedSend({...m,signal:c.signal},e.auth)}catch(e){p=err(networkError(e))}finally{c.dispose(),a.cancel()}if(p.ok)return s(l({phase:"settled",ok:true,reason:"ok"})),p;let g=p.error,y=Qt(g,b,{maxAttempts:h,rng:n,now:r.now(),aborted:d.signal?.aborted===true,...u!==void 0?{perCallMaxAttempts:u}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),v={ok:false,code:g.code,reason:y.reason,...g.httpStatus!==void 0?{httpStatus:g.httpStatus}:{},...g.requestId!==void 0?{requestId:g.requestId}:{}};if(!y.retry)return s(l({phase:"settled",...v})),err(g);if(s(l({phase:"retry",...v,delayMs:y.delayMs})),await i(y.delayMs,d.signal),d.signal?.aborted===true)return s(l({phase:"settled",...v,reason:"aborted"})),err(g);b+=1}}async function c(t){return withAuthHeaders(t,await or(e.auth))}async function*u(t,r,n){s(
14
+ return Object.freeze({scope:"all_pets",granted:r,version:r?e[0]?.version??null:null,grantedAt:null,pets:/* @__PURE__ */Object.freeze(e),...t[0]?{failed:/* @__PURE__ */Object.freeze(t)}:{}})}function xt(e){return new Tt(e)}var Tt=class{constructor(e){this.recordCache=/* @__PURE__ */new Map;this.consentEpoch=/* @__PURE__ */new Map;this.reportedGaps=/* @__PURE__ */new Set;this.features=Ie;this.repository=e.repository,this.uploads=e.uploads,this.telemetry=e.telemetry??ft,this.newIdempotencyKey=e.newIdempotencyKey??Dt(),this.timers=e.timers??zt,this.uploadDeadlineMs=e.uploadDeadlineMs??wt}async createUploadRequest(e){let t=await this.repository.createRequest({pet_ref:e.petRef,idempotency_key:e.idempotencyKey});if(!t.ok)return this.onRequestError(t.error);let r=Ae(t.value);return r===null?err(St()):(this.observeRequest(r),ok(r))}async getRequest(e){let t=await this.repository.getRequest(e);if(!t.ok)return this.onRequestError(t.error);let r=Ae(t.value);return r===null?err(St()):(this.observeRequest(r),ok(r))}async listRequests(){let e=await this.repository.listRequests();if(!e.ok)return this.onRequestError(e.error);let t=Me(e.value);for(let e of t)this.observeRequest(e);return ok(t)}async readFeatures(){let e=this.repository.getFeatures;if(e===void 0)return this.features=Ie;let t=Ie;try{let r=await e.call(this.repository);r.ok&&(t=He(r.value))}catch{}return this.features=t,t}async uploadDocument(e){let{requestId:t,file:r}=e,n=_t(r,this.features.uploadContentTypes);if(n!==null)return this.telemetry.record("records.upload.rejected",{reason:n}),err(Rt(`upload rejected: ${n}`));let i=await this.repository.initiateUpload(t,{content_type:r.mimeType,file_size:r.sizeBytes});if(!i.ok)return this.onRequestError(i.error);let l=await this.postToS3(i.value,r,e);if(!l.ok)return this.telemetry.record("records.upload.failed",{reason:l.reason}),err(Rt(l.reason));let o=await this.repository.completeUpload(t,{upload_id:i.value.upload_id});if(!o.ok)return o.error.code==="mediaUploadFailed"&&this.telemetry.record("records.upload.rejected",{reason:Ct(o.error)??"corrupt"}),this.onRequestError(o.error);let a=We(o.value);return a===null?err(St()):ok(a)}async postToS3(e,t,r){let n=new AbortController,i=It(n.signal,r.signal),l=this.timers.setTimeout(()=>n.abort(),this.uploadDeadlineMs);try{let n={signal:i};return r.onProgress&&(n.onProgress=r.onProgress),await this.uploads.postMultipart(e,t,n),{ok:!0}}catch{return{ok:false,reason:n.signal.aborted&&r.signal?.aborted!==true?"timeout":"upload_error"}}finally{this.timers.clearTimeout(l)}}async getRecord(e){let t=this.consentEpoch.get(e)??0,r=await this.repository.getRecord(e);if(t!==(this.consentEpoch.get(e)??0))return err(/* @__PURE__ */Object.freeze({...makeEverfurError("accessDenied",{retryable:false}),recordsReason:"consent_required"}));if(!r.ok){let t=recordsDenialReasonOf(r.error);return t==="consent_required"?(this.recordCache.delete(e),this.telemetry.record("records.consent.denied",{pet_ref:e})):t==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:e}),err(r.error)}let n=et(e,r.value);return n.petRef!==e?err(St()):n.withheld?(this.telemetry.record("records.redaction.withheld",{pet_ref:e}),this.recordCache.delete(e),ok(n)):(this.recordCache.set(e,n),ok(n))}peekCachedRecord(e){return this.recordCache.get(e)??null}async getConsent(e){let t=await this.repository.getConsent(e);return t.ok?ok(nt(e,t.value)):err(t.error)}async grantConsent(e){let t=await this.repository.putConsent(e.petRef,{consent_version:e.consentVersion,idempotency_key:e.idempotencyKey});return t.ok?ok(nt(e.petRef,t.value)):(recordsDenialReasonOf(t.error)==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:e.petRef}),err(t.error))}async revokeConsent(e){let t=await this.repository.deleteConsent(e);return t.ok?(this.consentEpoch.set(e,(this.consentEpoch.get(e)??0)+1),this.recordCache.delete(e),ok(nt(e,t.value))):err(t.error)}async getMemberConsent(){let e=await(this.repository.getMemberConsent?.());return e?e.ok?ok(lt(e.value)):e:err(makeEverfurError("resourceNotFound",{retryable:false,httpStatus:404}))}grantConsentAllPets(e){return this.allPets(e,true)}revokeConsentAllPets(e){return this.allPets(e,false)}async allPets(e,t){let{petRef:petRef,consentVersion:r,idempotencyKey:n}=e,i=await(t?this.repository.putMemberConsent?.({consent_version:r,idempotency_key:n}):this.repository.deleteMemberConsent?.());if(i?.ok){let r=lt(i.value);if(!t){let t=/* @__PURE__ */new Set([petRef,...this.recordCache.keys(),...r.pets.map(e=>e.petRef)]);for(let e of t)this.consentEpoch.set(e,(this.consentEpoch.get(e)??0)+1);this.recordCache.clear();for(let r of t)e.onRevoked?.(r)}return ok(r)}if(i&&i.error.httpStatus!==404&&i.error.httpStatus!==405)return t&&recordsDenialReasonOf(i.error)==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:petRef}),i;let l;try{l=e.listPetRefs?ok(await e.listPetRefs()):await(this.repository.listPetRefs?.())??err(makeEverfurError("notImplemented",{retryable:!1}))}catch{l=err(makeEverfurError("internalError"))}let o=[],a=[];for(let i of l.ok?/* @__PURE__ */new Set([petRef,...l.value]):[petRef]){let l=await(t?this.grantConsent({petRef:i,consentVersion:r,idempotencyKey:n}):this.revokeConsent(i));if(l.ok)t||e.onRevoked?.(i);else{if(t&&i===petRef)return l;a.push(/* @__PURE__ */Object.freeze({petRef:i,error:l.error}))}o.push(l.ok?l.value:nt(i,null))}let s=t?null:a[0]?.error??(l.ok?null:l.error);return s?err(s):ok(kt(o,a))}reportCapabilityDenied(e){this.telemetry.record("records.capability.denied",e?{pet_ref:e}:{})}observeRequest(e){e.reviewStartedAt!==null&&!this.reportedGaps.has(e.id)&&(this.reportedGaps.add(e.id),this.telemetry.record("records.parse.gap",{request_id:e.id}))}onRequestError(e){return recordsDenialReasonOf(e)==="entitlement"&&this.telemetry.record("records.capability.denied",{}),err(e)}};function _t(e,t){if(!ze(e.mimeType,t))return"unsupported_format";let r=e.sizeBytes;return typeof r!="number"||!Number.isFinite(r)||r<=0||r>mt?"oversize":null}function Ct(e){let t=e.wireMessage;return t==="unsupported_format"||t==="oversize"||t==="corrupt"?t:null}function Rt(e){return makeEverfurError("mediaUploadFailed",{retryable:false,wireMessage:e})}function St(){return makeEverfurError("internalError",{retryable:true})}var zt={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)};function It(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=()=>r.abort();return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}function Dt(){let e=0;return()=>`records-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
15
+ return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var Ht="x-everfur-anon-token",Lt="anonTokenInvalid";async function Pt(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function Ot(e,t){let r=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...r?{wireMessage:r}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[Ht]=e.anonToken)),e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}function withAuthHeaders(e,t){return{...e,headers:{...$t(e.headers),...authHeaders(t)}}}function $t(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let e=r.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===Ht||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await Pt(t),n=await t.transport.request(withAuthHeaders(e,Bt(t,r)));if(n.ok||At(n.error.raw)!==Lt||t.anonIdentity===void 0||t.userRef!==null)return n;let i=await t.anonIdentity.token({forceRefresh:true});return i===null||i===r?n:t.transport.request(withAuthHeaders(e,Bt(t,i)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(Ot(e))}let n=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let i;try{i=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(Ot(e,{wireCode:At(n.error.raw),requestId:n.error.requestId}))}let l=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:i,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!l.ok&&l.error.httpStatus===401?(t.identity.reportRejected?.(),err(jt(l.error))):l}function Bt(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function jt(e){let t=e.raw,r=At(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...r?{wireCode:r}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function At(e){if(typeof e!="object"||e===null)return null;let t=e,r=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof r=="string"&&r.length>0?r:null}var Et="1.4.1";function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:Ft(e)})}function Ft(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var qt=3e4,Mt=X*2,Nt="idempotency-key",Wt=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),Ut=/* @__PURE__ */Object.freeze({onEvent(){}}),Gt=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Vt(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}function createRequestFunnel(e){let t=e.observer??Ut,r=e.timers??Gt,n=e.rng??Math.random,i=e.sleep??((e,t)=>dr(e,r,t)),l=e.maxAttempts??Q,o=e.unaryTimeoutMs??qt,a=e.newIdempotencyKey??Yt(),s=e=>{try{t.onEvent(e)}catch{}};async function d(t,d,c){let u=c?.maxAttempts,h=Math.max(1,u??l),p=c?.idempotent??Wt.has(d.method),g=c?.idempotencyKey===void 0?null:Vt(c.idempotencyKey),f=p?g??a():null,m=Kt(d,f),b=0;for(;;){let l=e=>/* @__PURE__ */Object.freeze({call:t,method:d.method,path:d.path,attempt:b,...f?{idempotencyKey:f}:{},...e});s(l({phase:"attempt"}));let a=ar(o,r),c=sr(a.signal,d.signal),p;try{p=await authedSend({...m,signal:c.signal},e.auth)}catch(e){p=err(networkError(e))}finally{c.dispose(),a.cancel()}if(p.ok)return s(l({phase:"settled",ok:true,reason:"ok"})),p;let g=p.error,y=Qt(g,b,{maxAttempts:h,rng:n,now:r.now(),aborted:d.signal?.aborted===true,...u!==void 0?{perCallMaxAttempts:u}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),v={ok:false,code:g.code,reason:y.reason,...g.httpStatus!==void 0?{httpStatus:g.httpStatus}:{},...g.requestId!==void 0?{requestId:g.requestId}:{}};if(!y.retry)return s(l({phase:"settled",...v})),err(g);if(s(l({phase:"retry",...v,delayMs:y.delayMs})),await i(y.delayMs,d.signal),d.signal?.aborted===true)return s(l({phase:"settled",...v,reason:"aborted"})),err(g);b+=1}}async function c(t){return withAuthHeaders(t,await or(e.auth))}async function*u(t,r,n){s(
16
16
  /* @__PURE__ */Object.freeze({call:t,phase:"stream.open",method:r.method,path:r.path,attempt:0}));try{yield*e.auth.transport.stream(r,n)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}}/* @__PURE__ */
17
- return Object.freeze({send:d,authorize:c,stream:u})}function Kt(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==Nt&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function Yt(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var Xt=10;function Qt(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=Jt(e);if(n==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let i=n==="burst"?"burst-throttle":"retryable-code";if((()=>{if(r.policy===void 0)return false;try{return!r.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let l=()=>{if(r.policy===void 0)return null;let t;try{t=r.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min(Xt,Math.floor(t)))},o=r.perCallMaxAttempts??l()??r.maxAttempts;if(t+1>=o)return{retry:false,reason:"attempts-exhausted"};let a=Zt(e,r.now);return a!==null?a>Mt?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:i,delayMs:a}:{retry:true,reason:i,delayMs:backoffDelayMs(t,r.rng)}}function Jt(e){let t=e.code==="unknown"?fromWire(ir(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function Zt(e,t){let r=tr(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=er(e.raw);return n===null?null:Math.round(n*1e3)}function er(e){for(let t of rr(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function tr(e){for(let t of rr(e)){let e=t.resets_at,r=nr(e);if(r!==null)return r}return null}function rr(e){if(!lr(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];lr(n)&&t.push(n)}return t}function nr(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e11?Math.round(e*1e3):Math.round(e);if(typeof e=="string"&&e.trim().length>0){let t=Date.parse(e);return Number.isFinite(t)?t:null}return null}function ir(e){for(let t of rr(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function lr(e){return typeof e=="object"&&e!==null}async function or(e){if(e.mode==="anonymous"){let t=await Pt(e);return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}return{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}function ar(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function sr(e,t){let r=()=>{};if(!t)return{signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let i=()=>n.abort();return e.addEventListener("abort",i,{once:true}),t.addEventListener("abort",i,{once:true}),{signal:n.signal,dispose:()=>{e.removeEventListener("abort",i),t.removeEventListener("abort",i)}}}function dr(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let i=t.setTimeout(()=>{r?.removeEventListener("abort",l),n()},e),l=()=>{t.clearTimeout(i),n()};r?.addEventListener("abort",l,{once:true})})}function cr(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function ur(e){return[...e].length}function hr(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function pr(e){return e.code!=="conversationNotFound"?e:makeEverfurError("resourceNotFound",{retryable:false,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.requestId===void 0?{}:{requestId:e.requestId},...e.reasonCode===void 0?{}:{reasonCode:e.reasonCode},...e.wireMessage===void 0?{}:{wireMessage:e.wireMessage},...e.raw===void 0?{}:{raw:e.raw}})}function gr(e){return e.ok?e:err(pr(e.error))}function fr(e){return{send:async(...t)=>gr(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var mr="/widget/v1/records";function br(e){let{auth:t}=e,r=t.mode,n=e.funnel??createRequestFunnel({auth:t,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),i=async(e,t,i)=>{let l=await n.send(e,t);return l.ok?l:err(kr(pr(l.error),r,i))},l=(e,t)=>typeof t!="string"||t.length===0?makeEverfurError("validationFailed",{retryable:false,wireMessage:`${e} is required and must be a non-empty string`}):cr(t)?makeEverfurError("validationFailed",{retryable:false,wireMessage:`${e} contains an unpaired surrogate and cannot be encoded`}):null,o=(e,t,r)=>{let n=l(e,t);if(n!==null)return n;let i=[...t].length;return i>r?makeEverfurError("validationFailed",{retryable:false,wireMessage:`${e} is ${i} characters; the server accepts at most ${r}`}):null},a=(...e)=>e.find(e=>e!==null)??null,s=e=>a(o("consent_version",e.consent_version,bt),o("idempotency_key",e.idempotency_key,yt));return{createRequest:e=>{let t=a(o("idempotency_key",e.idempotency_key,yt),o("pet_ref",e.pet_ref,vt));return t?Promise.resolve(err(t)):i("records.createRequest",Tr(`${mr}/requests`,e),"request")},initiateUpload:(e,t)=>{let r=l("request_id",e);return r?Promise.resolve(err(r)):i("records.initiateUpload",Tr(`${mr}/requests/${encodeURIComponent(e)}/uploads/initiate`,t),"request")},completeUpload:(e,t)=>{let r=l("request_id",e);return r?Promise.resolve(err(r)):i("records.completeUpload",Tr(`${mr}/requests/${encodeURIComponent(e)}/uploads/complete`,t),"request")},getRequest:e=>{let t=l("request_id",e);return t?Promise.resolve(err(t)):i("records.getRequest",xr(`${mr}/requests/${encodeURIComponent(e)}`),"request")},listRequests:async()=>{let e=await i("records.listRequests",xr(`${mr}/requests`),"request");if(!e.ok)return e;let t=e.value;return{ok:true,value:Array.isArray(t)?t:t.items??[]}},listPetRefs:async()=>{let e=await i("records.listPetRefs",xr("/widget/v1/pets"),"request");if(!e.ok)return e;let t=e.value,r=Array.isArray(t)?t:t?.pets;return{ok:true,value:(Array.isArray(r)?r:[]).map(e=>e?.pet_ref).filter(e=>typeof e=="string"&&e.length>0)}},getRecord:petRef=>{let e=o("pet_ref",petRef,vt);return e?Promise.resolve(err(e)):i("records.getRecord",xr(`${mr}/pets/${encodeURIComponent(petRef)}/record`),"content")},getConsent:petRef=>{let e=o("pet_ref",petRef,vt);return e?Promise.resolve(err(e)):i("records.getConsent",xr(`${mr}/pets/${encodeURIComponent(petRef)}/consent`),"consent")},putConsent:(petRef,e)=>{let t=a(s(e),o("pet_ref",petRef,vt));return t?Promise.resolve(err(t)):i("records.putConsent",Cr(`${mr}/pets/${encodeURIComponent(petRef)}/consent`,e),"consent")},getMemberConsent:()=>i("records.getMemberConsent",xr(`${mr}/consent`),"consent"),putMemberConsent:e=>{let t=s(e);return t?Promise.resolve(err(t)):i("records.putMemberConsent",Cr(`${mr}/consent`,e),"consent")},deleteMemberConsent:()=>i("records.deleteMemberConsent",_r(`${mr}/consent`),"consent"),getFeatures:()=>i("records.getFeatures",xr(`${mr}/features`),"request"),deleteConsent:petRef=>{let e=o("pet_ref",petRef,vt);return e?Promise.resolve(err(e)):i("records.deleteConsent",_r(`${mr}/pets/${encodeURIComponent(petRef)}/consent`),"consent")}}}function yr(e,t){let r={...e,recordsReason:t};for(let t of["wireMessage","raw"]){let n=Object.getOwnPropertyDescriptor(e,t);n!==void 0&&Object.defineProperty(r,t,n)}/* @__PURE__ */
18
- return Object.freeze(r)}var vr="pet_not_registered";function wr(e){return e.httpStatus!==404?null:e.reasonCode===vr?"pet_not_found":"entitlement"}function kr(e,t,r){let n=wr(e);return n!==null?yr(e,n):e.code!=="accessDenied"?e:yr(e,t==="anonymous"?"session_required":r==="content"?"consent_required":"entitlement")}function xr(e){return{method:"GET",path:e}}function Tr(e,t){return{method:"POST",path:e,body:t}}function Cr(e,t){return{method:"PUT",path:e,body:t}}function _r(e){return{method:"DELETE",path:e}}var Rr=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Sr=globalThis,zr=Sr[Rr]??(Sr[Rr]=createContext(null));zr.displayName??="EverfurContext";function Ir(){let e=s(zr);if(e===null)throw new oe("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}var Dr=/* @__PURE__ */new Map,Hr=/* @__PURE__ */new Set;function Lr(petRef){Dr.set(petRef,(Dr.get(petRef)??0)+1);for(let e of[...Hr])e()}function Pr(petRef){return Dr.get(petRef)??0}function Or(e){return Hr.add(e),()=>{Hr.delete(e)}}function $r(petRef){let e=l(()=>Pr(petRef),[petRef]);return d(Or,e,e)}var Br={record:null,requests:[],consent:null,error:null,denialReason:null,withheld:false,loading:true,isUploading:false,uploadProgress:null,uploadQueue:[],uploadContentTypes:Ie.uploadContentTypes},jr=4e3,Ar=30;function useEverfurRecords(e){let{petRef:petRef}=e,t=r(e.uploadTransport);t.current=e.uploadTransport;let s=e.uploadTransport!==void 0,{runtime:d,userRef:userRef,scopeEpoch:c}=Ir(),u=n(()=>({}),[d,userRef,petRef,c,e.controller]),h=r(u),[p,g]=i({scope:u,controller:e.controller??null}),f=e.controller??(p.scope===u?p.controller:null),[m,b]=i({scope:u,value:Br}),y=m.scope===u?m.value:Br,v=l(e=>{b(t=>t.scope===u?{scope:u,value:e(t.value)}:t)},[u]),w=r(0);o(()=>(h.current=u,b({scope:u,value:Br}),()=>{h.current=null,w.current+=1}),[u]),o(()=>{if(e.controller)return;let{services:r}=d.registry,n={record:(e,t)=>r.telemetry.track(e,t)},i=d.registry.acquire("records",`${userRef??""}|${petRef}${s?"|own-upload":""}`,()=>xt({repository:br({auth:r.authFor(userRef),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),uploads:s?{postMultipart:(e,n,i)=>(t.current??r.uploadTransport).postMultipart(e,n,i)}:r.uploadTransport,telemetry:n}),()=>{});return g({scope:u,controller:i}),()=>{d.registry.release(i)}},[d,userRef,petRef,e.controller,c,u,s]);let k=l(e=>{v(t=>({...t,...e}))},[v]),x=l(async()=>{if(!f||h.current!==u)return;let e=w.current+=1;S.current=0,D(),k({loading:true,error:null,denialReason:null,withheld:false});let[t,r]=await Promise.all([f.getConsent(petRef),f.listRequests()]);if(e!==w.current)return;let n=t.ok?t.value:null,i=r.ok?r.value.filter(e=>e.petRef===petRef):[],l=r.ok?null:r.error;if(n&&n.granted){let t=await f.getRecord(petRef);if(e!==w.current)return;if(t.ok){k({consent:n,requests:i,record:t.value,withheld:t.value.withheld,error:t.value.withheld?Ur():l,denialReason:null,loading:false});return}k({consent:n,requests:i,record:null,error:t.error,denialReason:recordsDenialReasonOf(t.error),withheld:false,loading:false});return}k({consent:n,requests:i,record:null,error:t.ok?l:t.error,denialReason:n?"consent_required":Wr(t),withheld:false,loading:false})},[f,petRef,k,u]);o(()=>(x(),()=>{w.current+=1}),[x]);let T=e.readUploadFeatures===true;o(()=>{if(!T||!f?.readFeatures)return;let e=true;return f.readFeatures().then(t=>{e&&h.current===u&&k({uploadContentTypes:t.uploadContentTypes})}),()=>{e=false}},[f,T,k,u]);let C=n(()=>Mr(y.requests),[y.requests]),_=C?.id??null,R=C?.status??null,S=r(0),z=r(null),[I,D]=a(e=>e+1,0);o(()=>{if(!f||_===null||R===null||isTerminalStatus(R)||R==="in_review")return;z.current!==String(_)&&(z.current=String(_),S.current=0);let e=false,t=async()=>{if(e||S.current>=Ar)return;S.current+=1;let n=await f.getRequest(_);if(!e){if(n.ok&&n.value.petRef===petRef){if(v(e=>({...e,requests:Nr(e.requests,n.value)})),isTerminalStatus(n.value.status)){n.value.status==="published"&&x();return}if(n.value.status==="in_review")return}r=setTimeout(()=>{t()},jr)}},r=setTimeout(()=>{t()},jr);return()=>{e=true,clearTimeout(r)}},[f,_,R,x,I,petRef,v]);let H=l(async e=>{if(!f||h.current!==u)return Gr();let t=await f.createUploadRequest({petRef:petRef,idempotencyKey:e});return h.current===u&&t.ok&&t.value.petRef===petRef&&v(e=>({...e,requests:Nr(e.requests,t.value)})),t},[f,petRef,u,v]),L=l((e,t)=>{v(r=>({...r,uploadQueue:r.uploadQueue.map(r=>r.key===e?t(r):r)}))},[v]),P=l(async(e,t)=>{let r=Date.now().toString(36),n=t.map((e,t)=>{let n=Er(e,y.uploadContentTypes);return{key:`${r}-${t}`,name:e.name??null,status:n===null?"queued":"skipped",progress:0,skipReason:n,error:null}}),i=[...n];if(!f||h.current!==u)/* @__PURE__ */return Object.freeze(i);v(e=>({...e,uploadQueue:n,isUploading:true,uploadProgress:0}));for(let[r,l]of t.entries()){let t=n[r];if(t.status==="skipped")continue;if(h.current!==u)break;L(t.key,e=>({...e,status:"uploading",progress:0})),k({uploadProgress:0});let o=await f.uploadDocument({requestId:e,file:l,onProgress:e=>{if(h.current!==u)return;let r=Math.min(1,Math.max(0,e));L(t.key,e=>({...e,progress:Math.max(e.progress,r)})),k({uploadProgress:r})}});if(h.current!==u)break;let a=o.ok?{...t,status:"done",progress:1}:{...t,status:"failed",error:o.error};if(i[r]=a,L(t.key,()=>a),o.ok){let t=await f.getRequest(e);h.current===u&&t.ok&&t.value.petRef===petRef&&v(e=>({...e,requests:Nr(e.requests,t.value)}))}}return h.current===u&&k({isUploading:false,uploadProgress:null}),/* @__PURE__ */Object.freeze(i)},[f,k,L,petRef,u,v,y.uploadContentTypes]),O=l(async(e,t)=>{if(!f||h.current!==u)return Gr();let r=`${Date.now().toString(36)}-0`;v(e=>({...e,isUploading:true,uploadProgress:0,uploadQueue:[{key:r,name:t.name??null,status:"uploading",progress:0,skipReason:null,error:null}]}));let n=await f.uploadDocument({requestId:e,file:t,onProgress:e=>{h.current===u&&(k({uploadProgress:e}),L(r,t=>({...t,progress:Math.max(t.progress,Math.min(1,e))})))}});if(h.current!==u)return n;if(k({isUploading:false,uploadProgress:null}),L(r,e=>n.ok?{...e,status:"done",progress:1}:{...e,status:"failed",error:n.error}),n.ok){let t=await f.getRequest(e);h.current===u&&t.ok&&t.value.petRef===petRef&&v(e=>({...e,requests:Nr(e.requests,t.value)}))}return n},[f,k,L,petRef,u,v]),$=e.consentScope==="all_pets"&&f?.grantConsentAllPets&&f.revokeConsentAllPets?"all_pets":"pet",B=l(async(e,t)=>{if(!f||h.current!==u)return Gr();let r;if($==="all_pets"&&f.grantConsentAllPets){let n=await f.grantConsentAllPets({petRef:petRef,consentVersion:e,idempotencyKey:t}),i=n.ok?n.value.failed?.[0]:void 0;r=n.ok?i?err(i.error):ok(n.value.pets.find(e=>e.petRef===petRef)??nt(petRef,{granted:n.value.granted,version:n.value.version,granted_at:n.value.grantedAt})):n}else r=await f.grantConsent({petRef:petRef,consentVersion:e,idempotencyKey:t});return r.ok&&h.current===u&&x(),r},[f,petRef,x,u,$]),j=l(e=>{Lr(e),!(e!==petRef||h.current!==u)&&(w.current+=1,k({record:null,withheld:false,loading:false,denialReason:"consent_required",consent:nt(petRef,null)}))},[petRef,k,u]),A=l(async()=>{if(!f||h.current!==u)return Gr();if(!f.revokeConsentAllPets)return err(makeEverfurError("notImplemented",{retryable:false}));let e=false,t=await f.revokeConsentAllPets({petRef:petRef,onRevoked:t=>{e=true,j(t)}});if(t.ok&&!e)for(let e of[petRef,...t.value.pets.map(e=>e.petRef)])j(e);return t},[f,petRef,u,j]),E=l(async()=>{if(!f||h.current!==u)return Gr();if($==="all_pets"){let e=await A();return e.ok?ok(e.value.pets.find(e=>e.petRef===petRef)??nt(petRef,null)):e}let e=await f.revokeConsent(petRef);return e.ok&&j(petRef),e.ok&&h.current===u&&k({consent:e.value}),e},[f,petRef,k,u,$,A,j]),F=l(()=>x(),[x]),q=qr(y,f!==null);return n(()=>({status:q,record:y.record,requests:y.requests,activeRequest:C,consent:y.consent,consentScope:$,error:y.error,denialReason:y.denialReason,withheld:y.withheld,isUploading:y.isUploading,uploadProgress:y.uploadProgress,uploadQueue:y.uploadQueue,uploadContentTypes:y.uploadContentTypes,createRequest:H,uploadDocument:O,uploadDocuments:P,grantConsent:B,revokeConsent:E,revokeConsentAllPets:A,refresh:F}),[q,y,C,$,H,O,P,B,E,A,F])}function Er(e,t){if(!ze(e.mimeType,t))return"unsupported";let r=e.sizeBytes;return typeof r!="number"||!Number.isFinite(r)||r<=0||r>mt?"too_large":null}function Fr(e,t){let r=[],n=[];for(let i of e){let e=Er(i,t);e===null?r.push(i):n.push({name:i.name??null,reason:e})}return{uploadable:r,skipped:n}}function qr(e,t){return e.loading||!t?"loading":e.withheld||e.denialReason!==null||e.error!==null?"error":e.record!==null&&!e.record.isEmpty||e.requests.length>0?"populated":"empty"}function Mr(e){if(e.length===0)return null;let t=e[0];for(let r of e)r.updatedAt>t.updatedAt&&(t=r);return t}function Nr(e,t){let r=e.filter(e=>e.id!==t.id);return[t,...r]}function Wr(e){return e.ok?"consent_required":recordsDenialReasonOf(e.error)??"consent_required"}function Ur(){return makeEverfurError("internalError",{retryable:false})}function Gr(){return{ok:false,error:makeEverfurError("internalError",{retryable:true})}}function Vr(e){let t={};if(e==null)return t;for(let r of Object.keys(e))e[r]!==void 0&&(t[r]=e[r]);return t}function Kr(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function Yr(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function Xr(e,...t){if(typeof e=="function")try{let r=e(...t);return Yr(r)&&Promise.resolve(r).then(void 0,Kr),r}catch(e){Kr(e);return}}var Qr=/* @__PURE__ */new WeakMap;function Jr(e){if(typeof e!="function")return;let t=Qr.get(e);if(t!==void 0)return t;let r=(...t)=>{Xr(e,...t)};return Qr.set(e,r),r}function Zr(e,t){let r=null;for(let n of t){let t=e[n];typeof t=="function"&&(r??={...e},r[n]=Jr(t))}return r??e}function en(e,...t){let r;try{r=e(...t)}catch(e){return Kr(e),Promise.resolve({ok:false,error:e})}return Promise.resolve(r).then(e=>({ok:true,value:e}),e=>({ok:false,error:e}))}var tn=/* @__PURE__ */Object.freeze({name:"dashboard"});function initialRecordsNav(e=tn){/* @__PURE__ */
17
+ return Object.freeze({send:d,authorize:c,stream:u})}function Kt(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==Nt&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function Yt(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var Xt=10;function Qt(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=Jt(e);if(n==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let i=n==="burst"?"burst-throttle":"retryable-code";if((()=>{if(r.policy===void 0)return false;try{return!r.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let l=()=>{if(r.policy===void 0)return null;let t;try{t=r.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min(Xt,Math.floor(t)))},o=r.perCallMaxAttempts??l()??r.maxAttempts;if(t+1>=o)return{retry:false,reason:"attempts-exhausted"};let a=Zt(e,r.now);return a!==null?a>Mt?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:i,delayMs:a}:{retry:true,reason:i,delayMs:backoffDelayMs(t,r.rng)}}function Jt(e){let t=e.code==="unknown"?fromWire(ir(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function Zt(e,t){let r=tr(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=er(e.raw);return n===null?null:Math.round(n*1e3)}function er(e){for(let t of rr(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function tr(e){for(let t of rr(e)){let e=t.resets_at,r=nr(e);if(r!==null)return r}return null}function rr(e){if(!lr(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];lr(n)&&t.push(n)}return t}function nr(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e11?Math.round(e*1e3):Math.round(e);if(typeof e=="string"&&e.trim().length>0){let t=Date.parse(e);return Number.isFinite(t)?t:null}return null}function ir(e){for(let t of rr(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function lr(e){return typeof e=="object"&&e!==null}async function or(e){if(e.mode==="anonymous"){let t=await Pt(e);return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}return{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}function ar(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function sr(e,t){let r=()=>{};if(!t)return{signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let i=()=>n.abort();return e.addEventListener("abort",i,{once:true}),t.addEventListener("abort",i,{once:true}),{signal:n.signal,dispose:()=>{e.removeEventListener("abort",i),t.removeEventListener("abort",i)}}}function dr(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let i=t.setTimeout(()=>{r?.removeEventListener("abort",l),n()},e),l=()=>{t.clearTimeout(i),n()};r?.addEventListener("abort",l,{once:true})})}function cr(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function ur(e){return[...e].length}function hr(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function pr(e){return e.code!=="conversationNotFound"?e:makeEverfurError("resourceNotFound",{retryable:false,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.requestId===void 0?{}:{requestId:e.requestId},...e.reasonCode===void 0?{}:{reasonCode:e.reasonCode},...e.wireMessage===void 0?{}:{wireMessage:e.wireMessage},...e.raw===void 0?{}:{raw:e.raw}})}function gr(e){return e.ok?e:err(pr(e.error))}function fr(e){return{send:async(...t)=>gr(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var mr="/widget/v1/records";function br(e){let{auth:t}=e,r=t.mode,n=e.funnel??createRequestFunnel({auth:t,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),i=async(e,t,i)=>{let l=await n.send(e,t);return l.ok?l:err(kr(pr(l.error),r,i))},l=(e,t)=>typeof t!="string"||t.length===0?makeEverfurError("validationFailed",{retryable:false,wireMessage:`${e} is required and must be a non-empty string`}):cr(t)?makeEverfurError("validationFailed",{retryable:false,wireMessage:`${e} contains an unpaired surrogate and cannot be encoded`}):null,o=(e,t,r)=>{let n=l(e,t);if(n!==null)return n;let i=[...t].length;return i>r?makeEverfurError("validationFailed",{retryable:false,wireMessage:`${e} is ${i} characters; the server accepts at most ${r}`}):null},a=(...e)=>e.find(e=>e!==null)??null,s=e=>a(o("consent_version",e.consent_version,bt),o("idempotency_key",e.idempotency_key,yt));return{createRequest:e=>{let t=a(o("idempotency_key",e.idempotency_key,yt),o("pet_ref",e.pet_ref,vt));return t?Promise.resolve(err(t)):i("records.createRequest",Tr(`${mr}/requests`,e),"request")},initiateUpload:(e,t)=>{let r=l("request_id",e);return r?Promise.resolve(err(r)):i("records.initiateUpload",Tr(`${mr}/requests/${encodeURIComponent(e)}/uploads/initiate`,t),"request")},completeUpload:(e,t)=>{let r=l("request_id",e);return r?Promise.resolve(err(r)):i("records.completeUpload",Tr(`${mr}/requests/${encodeURIComponent(e)}/uploads/complete`,t),"request")},getRequest:e=>{let t=l("request_id",e);return t?Promise.resolve(err(t)):i("records.getRequest",xr(`${mr}/requests/${encodeURIComponent(e)}`),"request")},listRequests:async()=>{let e=await i("records.listRequests",xr(`${mr}/requests`),"request");if(!e.ok)return e;let t=e.value;return{ok:true,value:Array.isArray(t)?t:t.items??[]}},listPetRefs:async()=>{let e=await i("records.listPetRefs",xr("/widget/v1/pets"),"request");if(!e.ok)return e;let t=e.value,r=Array.isArray(t)?t:t?.pets;return{ok:true,value:(Array.isArray(r)?r:[]).map(e=>e?.pet_ref).filter(e=>typeof e=="string"&&e.length>0)}},getRecord:petRef=>{let e=o("pet_ref",petRef,vt);return e?Promise.resolve(err(e)):i("records.getRecord",xr(`${mr}/pets/${encodeURIComponent(petRef)}/record`),"content")},getConsent:petRef=>{let e=o("pet_ref",petRef,vt);return e?Promise.resolve(err(e)):i("records.getConsent",xr(`${mr}/pets/${encodeURIComponent(petRef)}/consent`),"consent")},putConsent:(petRef,e)=>{let t=a(s(e),o("pet_ref",petRef,vt));return t?Promise.resolve(err(t)):i("records.putConsent",_r(`${mr}/pets/${encodeURIComponent(petRef)}/consent`,e),"consent")},getMemberConsent:()=>i("records.getMemberConsent",xr(`${mr}/consent`),"consent"),putMemberConsent:e=>{let t=s(e);return t?Promise.resolve(err(t)):i("records.putMemberConsent",_r(`${mr}/consent`,e),"consent")},deleteMemberConsent:()=>i("records.deleteMemberConsent",Cr(`${mr}/consent`),"consent"),getFeatures:()=>i("records.getFeatures",xr(`${mr}/features`),"request"),deleteConsent:petRef=>{let e=o("pet_ref",petRef,vt);return e?Promise.resolve(err(e)):i("records.deleteConsent",Cr(`${mr}/pets/${encodeURIComponent(petRef)}/consent`),"consent")}}}function yr(e,t){let r={...e,recordsReason:t};for(let t of["wireMessage","raw"]){let n=Object.getOwnPropertyDescriptor(e,t);n!==void 0&&Object.defineProperty(r,t,n)}/* @__PURE__ */
18
+ return Object.freeze(r)}var vr="pet_not_registered";function wr(e){return e.httpStatus!==404?null:e.reasonCode===vr?"pet_not_found":"entitlement"}function kr(e,t,r){let n=wr(e);return n!==null?yr(e,n):e.code!=="accessDenied"?e:yr(e,t==="anonymous"?"session_required":r==="content"?"consent_required":"entitlement")}function xr(e){return{method:"GET",path:e}}function Tr(e,t){return{method:"POST",path:e,body:t}}function _r(e,t){return{method:"PUT",path:e,body:t}}function Cr(e){return{method:"DELETE",path:e}}var Rr=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Sr=globalThis,zr=Sr[Rr]??(Sr[Rr]=createContext(null));zr.displayName??="EverfurContext";function Ir(){let e=s(zr);if(e===null)throw new oe("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}var Dr=/* @__PURE__ */new Map,Hr=/* @__PURE__ */new Set;function Lr(petRef){Dr.set(petRef,(Dr.get(petRef)??0)+1);for(let e of[...Hr])e()}function Pr(petRef){return Dr.get(petRef)??0}function Or(e){return Hr.add(e),()=>{Hr.delete(e)}}function $r(petRef){let e=l(()=>Pr(petRef),[petRef]);return d(Or,e,e)}var Br={record:null,requests:[],consent:null,error:null,denialReason:null,withheld:false,loading:true,isUploading:false,uploadProgress:null,uploadQueue:[],uploadContentTypes:Ie.uploadContentTypes},jr=4e3,Ar=30;function useEverfurRecords(e){let{petRef:petRef}=e,t=r(e.uploadTransport);t.current=e.uploadTransport;let s=e.uploadTransport!==void 0,{runtime:d,userRef:userRef,scopeEpoch:c}=Ir(),u=n(()=>({}),[d,userRef,petRef,c,e.controller]),h=r(u),[p,g]=i({scope:u,controller:e.controller??null}),f=e.controller??(p.scope===u?p.controller:null),[m,b]=i({scope:u,value:Br}),y=m.scope===u?m.value:Br,v=l(e=>{b(t=>t.scope===u?{scope:u,value:e(t.value)}:t)},[u]),w=r(0);o(()=>(h.current=u,b({scope:u,value:Br}),()=>{h.current=null,w.current+=1}),[u]),o(()=>{if(e.controller)return;let{services:r}=d.registry,n={record:(e,t)=>r.telemetry.track(e,t)},i=d.registry.acquire("records",`${userRef??""}|${petRef}${s?"|own-upload":""}`,()=>xt({repository:br({auth:r.authFor(userRef),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),uploads:s?{postMultipart:(e,n,i)=>(t.current??r.uploadTransport).postMultipart(e,n,i)}:r.uploadTransport,telemetry:n}),()=>{});return g({scope:u,controller:i}),()=>{d.registry.release(i)}},[d,userRef,petRef,e.controller,c,u,s]);let k=l(e=>{v(t=>({...t,...e}))},[v]),x=l(async()=>{if(!f||h.current!==u)return;let e=w.current+=1;S.current=0,D(),k({loading:true,error:null,denialReason:null,withheld:false});let[t,r]=await Promise.all([f.getConsent(petRef),f.listRequests()]);if(e!==w.current)return;let n=t.ok?t.value:null,i=r.ok?r.value.filter(e=>e.petRef===petRef):[],l=r.ok?null:r.error;if(n&&n.granted){let t=await f.getRecord(petRef);if(e!==w.current)return;if(t.ok){k({consent:n,requests:i,record:t.value,withheld:t.value.withheld,error:t.value.withheld?Ur():l,denialReason:null,loading:false});return}k({consent:n,requests:i,record:null,error:t.error,denialReason:recordsDenialReasonOf(t.error),withheld:false,loading:false});return}k({consent:n,requests:i,record:null,error:t.ok?l:t.error,denialReason:n?"consent_required":Wr(t),withheld:false,loading:false})},[f,petRef,k,u]);o(()=>(x(),()=>{w.current+=1}),[x]);let T=e.readUploadFeatures===true;o(()=>{if(!T||!f?.readFeatures)return;let e=true;return f.readFeatures().then(t=>{e&&h.current===u&&k({uploadContentTypes:t.uploadContentTypes})}),()=>{e=false}},[f,T,k,u]);let _=n(()=>Mr(y.requests),[y.requests]),C=_?.id??null,R=_?.status??null,S=r(0),z=r(null),[I,D]=a(e=>e+1,0);o(()=>{if(!f||C===null||R===null||isTerminalStatus(R)||R==="in_review")return;z.current!==String(C)&&(z.current=String(C),S.current=0);let e=false,t=async()=>{if(e||S.current>=Ar)return;S.current+=1;let n=await f.getRequest(C);if(!e){if(n.ok&&n.value.petRef===petRef){if(v(e=>({...e,requests:Nr(e.requests,n.value)})),isTerminalStatus(n.value.status)){n.value.status==="published"&&x();return}if(n.value.status==="in_review")return}r=setTimeout(()=>{t()},jr)}},r=setTimeout(()=>{t()},jr);return()=>{e=true,clearTimeout(r)}},[f,C,R,x,I,petRef,v]);let H=l(async e=>{if(!f||h.current!==u)return Gr();let t=await f.createUploadRequest({petRef:petRef,idempotencyKey:e});return h.current===u&&t.ok&&t.value.petRef===petRef&&v(e=>({...e,requests:Nr(e.requests,t.value)})),t},[f,petRef,u,v]),L=l((e,t)=>{v(r=>({...r,uploadQueue:r.uploadQueue.map(r=>r.key===e?t(r):r)}))},[v]),P=l(async(e,t)=>{let r=Date.now().toString(36),n=t.map((e,t)=>{let n=Er(e,y.uploadContentTypes);return{key:`${r}-${t}`,name:e.name??null,status:n===null?"queued":"skipped",progress:0,skipReason:n,error:null}}),i=[...n];if(!f||h.current!==u)/* @__PURE__ */return Object.freeze(i);v(e=>({...e,uploadQueue:n,isUploading:true,uploadProgress:0}));for(let[r,l]of t.entries()){let t=n[r];if(t.status==="skipped")continue;if(h.current!==u)break;L(t.key,e=>({...e,status:"uploading",progress:0})),k({uploadProgress:0});let o=await f.uploadDocument({requestId:e,file:l,onProgress:e=>{if(h.current!==u)return;let r=Math.min(1,Math.max(0,e));L(t.key,e=>({...e,progress:Math.max(e.progress,r)})),k({uploadProgress:r})}});if(h.current!==u)break;let a=o.ok?{...t,status:"done",progress:1}:{...t,status:"failed",error:o.error};if(i[r]=a,L(t.key,()=>a),o.ok){let t=await f.getRequest(e);h.current===u&&t.ok&&t.value.petRef===petRef&&v(e=>({...e,requests:Nr(e.requests,t.value)}))}}return h.current===u&&k({isUploading:false,uploadProgress:null}),/* @__PURE__ */Object.freeze(i)},[f,k,L,petRef,u,v,y.uploadContentTypes]),O=l(async(e,t)=>{if(!f||h.current!==u)return Gr();let r=`${Date.now().toString(36)}-0`;v(e=>({...e,isUploading:true,uploadProgress:0,uploadQueue:[{key:r,name:t.name??null,status:"uploading",progress:0,skipReason:null,error:null}]}));let n=await f.uploadDocument({requestId:e,file:t,onProgress:e=>{h.current===u&&(k({uploadProgress:e}),L(r,t=>({...t,progress:Math.max(t.progress,Math.min(1,e))})))}});if(h.current!==u)return n;if(k({isUploading:false,uploadProgress:null}),L(r,e=>n.ok?{...e,status:"done",progress:1}:{...e,status:"failed",error:n.error}),n.ok){let t=await f.getRequest(e);h.current===u&&t.ok&&t.value.petRef===petRef&&v(e=>({...e,requests:Nr(e.requests,t.value)}))}return n},[f,k,L,petRef,u,v]),$=e.consentScope==="all_pets"&&f?.grantConsentAllPets&&f.revokeConsentAllPets?"all_pets":"pet",B=l(async(e,t)=>{if(!f||h.current!==u)return Gr();let r;if($==="all_pets"&&f.grantConsentAllPets){let n=await f.grantConsentAllPets({petRef:petRef,consentVersion:e,idempotencyKey:t}),i=n.ok?n.value.failed?.[0]:void 0;r=n.ok?i?err(i.error):ok(n.value.pets.find(e=>e.petRef===petRef)??nt(petRef,{granted:n.value.granted,version:n.value.version,granted_at:n.value.grantedAt})):n}else r=await f.grantConsent({petRef:petRef,consentVersion:e,idempotencyKey:t});return r.ok&&h.current===u&&x(),r},[f,petRef,x,u,$]),j=l(e=>{Lr(e),!(e!==petRef||h.current!==u)&&(w.current+=1,k({record:null,withheld:false,loading:false,denialReason:"consent_required",consent:nt(petRef,null)}))},[petRef,k,u]),A=l(async()=>{if(!f||h.current!==u)return Gr();if(!f.revokeConsentAllPets)return err(makeEverfurError("notImplemented",{retryable:false}));let e=false,t=await f.revokeConsentAllPets({petRef:petRef,onRevoked:t=>{e=true,j(t)}});if(t.ok&&!e)for(let e of[petRef,...t.value.pets.map(e=>e.petRef)])j(e);return t},[f,petRef,u,j]),E=l(async()=>{if(!f||h.current!==u)return Gr();if($==="all_pets"){let e=await A();return e.ok?ok(e.value.pets.find(e=>e.petRef===petRef)??nt(petRef,null)):e}let e=await f.revokeConsent(petRef);return e.ok&&j(petRef),e.ok&&h.current===u&&k({consent:e.value}),e},[f,petRef,k,u,$,A,j]),F=l(()=>x(),[x]),q=qr(y,f!==null);return n(()=>({status:q,record:y.record,requests:y.requests,activeRequest:_,consent:y.consent,consentScope:$,error:y.error,denialReason:y.denialReason,withheld:y.withheld,isUploading:y.isUploading,uploadProgress:y.uploadProgress,uploadQueue:y.uploadQueue,uploadContentTypes:y.uploadContentTypes,createRequest:H,uploadDocument:O,uploadDocuments:P,grantConsent:B,revokeConsent:E,revokeConsentAllPets:A,refresh:F}),[q,y,_,$,H,O,P,B,E,A,F])}function Er(e,t){if(!ze(e.mimeType,t))return"unsupported";let r=e.sizeBytes;return typeof r!="number"||!Number.isFinite(r)||r<=0||r>mt?"too_large":null}function Fr(e,t){let r=[],n=[];for(let i of e){let e=Er(i,t);e===null?r.push(i):n.push({name:i.name??null,reason:e})}return{uploadable:r,skipped:n}}function qr(e,t){return e.loading||!t?"loading":e.withheld||e.denialReason!==null||e.error!==null?"error":e.record!==null&&!e.record.isEmpty||e.requests.length>0?"populated":"empty"}function Mr(e){if(e.length===0)return null;let t=e[0];for(let r of e)r.updatedAt>t.updatedAt&&(t=r);return t}function Nr(e,t){let r=e.filter(e=>e.id!==t.id);return[t,...r]}function Wr(e){return e.ok?"consent_required":recordsDenialReasonOf(e.error)??"consent_required"}function Ur(){return makeEverfurError("internalError",{retryable:false})}function Gr(){return{ok:false,error:makeEverfurError("internalError",{retryable:true})}}function Vr(e){let t={};if(e==null)return t;for(let r of Object.keys(e))e[r]!==void 0&&(t[r]=e[r]);return t}function Kr(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function Yr(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function Xr(e,...t){if(typeof e=="function")try{let r=e(...t);return Yr(r)&&Promise.resolve(r).then(void 0,Kr),r}catch(e){Kr(e);return}}var Qr=/* @__PURE__ */new WeakMap;function Jr(e){if(typeof e!="function")return;let t=Qr.get(e);if(t!==void 0)return t;let r=(...t)=>{Xr(e,...t)};return Qr.set(e,r),r}function Zr(e,t){let r=null;for(let n of t){let t=e[n];typeof t=="function"&&(r??={...e},r[n]=Jr(t))}return r??e}function en(e,...t){let r;try{r=e(...t)}catch(e){return Kr(e),Promise.resolve({ok:false,error:e})}return Promise.resolve(r).then(e=>({ok:true,value:e}),e=>({ok:false,error:e}))}var tn=/* @__PURE__ */Object.freeze({name:"dashboard"});function initialRecordsNav(e=tn){/* @__PURE__ */
19
19
  return Object.freeze({stack:/* @__PURE__ */Object.freeze([e])})}function currentRecordsScreen(e){return e.stack[e.stack.length-1]??tn}function pushRecordsNav(e,t){/* @__PURE__ */
20
20
  return Object.freeze({stack:/* @__PURE__ */Object.freeze([...e.stack,t])})}function replaceRecordsNav(e,t){/* @__PURE__ */
21
- return Object.freeze({stack:/* @__PURE__ */Object.freeze([...e.stack.slice(0,-1),t])})}function resetRecordsNav(e){return initialRecordsNav(e)}function popRecordsNav(e){return e.stack.length<=1?{state:e,handled:false}:{state:/* @__PURE__ */Object.freeze({stack:/* @__PURE__ */Object.freeze(e.stack.slice(0,-1))}),handled:true}}function transitionRecordsNav(e,t){return t.name==="dashboard"?resetRecordsNav(t):currentRecordsScreen(e).name==="upload"&&t.name==="request"?replaceRecordsNav(e,t):pushRecordsNav(e,t)}function recordsNavReducer(e,t){switch(t.type){case"push":return pushRecordsNav(e,t.screen);case"pop":return popRecordsNav(e).state;case"replace":return replaceRecordsNav(e,t.screen);case"reset":return resetRecordsNav(t.screen);case"navigate":return transitionRecordsNav(e,t.screen);default:return e}}var rn=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[rn[t]]}}function headingFace(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type;if(r===null&&n===null)return face(e,t);if(r!==null)return{fontFamily:r,fontWeight:n??e.type.weight[rn[t]]};let i=face(e,t);return i.fontWeight===void 0||n===null?i:{fontFamily:i.fontFamily,fontWeight:n}}function nn(e){return e<=450?"regular":e<=650?"medium":"bold"}var ln={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=on.get(e);r===void 0&&(r=/* @__PURE__ */new Map,on.set(e,r));let n=r.get(t);if(n!==void 0)return n;let i=an(e,t);return r.set(t,i),i}var on=/* @__PURE__ */new WeakMap;function an(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,i=nn(Number(n)),l=r.face==="mono"?face(e,ln[i]):r.face==="heading"?headingFace(e,i):face(e,i),o=r.face==="heading"?e.type.headingWeight??n:n,a=l.fontWeight===void 0?l:{fontFamily:l.fontFamily,fontWeight:o},s=r.size,d={...a,fontSize:s,lineHeight:Math.round(s*r.lineHeight*100)/100};return r.letterSpacing!==0&&(d.letterSpacing=Math.round(s*r.letterSpacing*100)/100),r.uppercase&&(d.textTransform="uppercase"),/* @__PURE__ */Object.freeze(d)}var sn=/* @__PURE__ */Object.freeze({display:/* @__PURE__ */Object.freeze({size:29,lineHeight:1.06,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),title:/* @__PURE__ */Object.freeze({size:23,lineHeight:1.12,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),cardTitle:/* @__PURE__ */Object.freeze({size:19,lineHeight:1.22,weight:"800",face:"sans",letterSpacing:0,uppercase:false,tier:"heading"}),rowTitle:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.4,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),body:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),message:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),bodySmall:/* @__PURE__ */Object.freeze({size:14.5,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),caption:/* @__PURE__ */Object.freeze({size:13,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),label:/* @__PURE__ */Object.freeze({size:10.5,lineHeight:1.4,weight:"400",face:"mono",letterSpacing:.05,uppercase:true,tier:"compact"}),eyebrow:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"mono",letterSpacing:.07,uppercase:true,tier:"compact"}),chip:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.3,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),tab:/* @__PURE__ */Object.freeze({size:16,lineHeight:1.5,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),button:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"control"}),badge:/* @__PURE__ */Object.freeze({size:12,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"badge"})});var dn=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){dn(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var cn=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var un={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},hn={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},pn={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},gn={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},fn={regular:"400",medium:"500",bold:"700"},mn={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},bn=0,yn="System",vn="monospace",wn=["content","heading","control","compact","badge"];function kn(e){let t={};for(let r of wn)t[r]=e;return t}var xn=[];function Tn(){return{family:yn,mono:vn,fontUrl:null,families:{regular:yn,medium:yn,bold:yn,mono:vn,monoMedium:vn,monoBold:vn},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:pn,tierSizes:kn(pn),lineHeight:gn,weight:fn,letterSpacing:mn,scale:1,maxScale:bn,scaleCaps:cn,headingFamily:null,headingWeight:null,fontSources:xn,roles:sn,typeScale:1}}var Cn={},_n=/* @__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(e){return`cubic-bezier(${e.join(", ")})`}var Rn={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(_n.standard),emphasized:cssCubicBezier(_n.emphasized),exit:cssCubicBezier(_n.exit)},reducedMotion:false},Sn={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)"},zn=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Sn,space:un,radius:hn,type:Tn(),motion:Rn,slots:Cn}),In={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)"},Dn=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:In,space:un,radius:hn,type:Tn(),motion:Rn,slots:Cn});var Hn=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Ln=globalThis,Pn=Ln[Hn]??(Ln[Hn]=createContext(zn));Pn.displayName??="EverfurThemeContext";function useEverfurTheme(){return s(Pn)}function On(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:e,variant:r,...n}){let i=useEverfurTheme(),l=r===void 0?void 0:i.type.roles[r],o=On(i.type,e??l?.tier??"content"),a=r===void 0?n:{...n,style:[{...textRole(i,r),color:i.color.text.primary,flexShrink:1},n.style]};return t(R,o===void 0?a:{maxFontSizeMultiplier:o,...a})}var $n=e(function(e,r){return t(h,{...e,...r===null?{}:{ref:r}})});function Bn(e,t){if(e===void 0)return{};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}function jn(e){return e?.textColor===void 0?{}:{color:e.textColor}}function An(e){return e.recordCard??e.card}var En=/* @__PURE__ */Object.freeze({title:"Request records",clinic:"Clinic",search:"Search clinics by name or location",placeholder:"Clinic name, city, or ZIP",email:"Clinic email",emailPlaceholder:"records@clinic.com",ownerName:"Your full name",scopeHeading:"What you’re authorizing",send:"Send request",sending:"Sending…",cancel:"Cancel",sign:"Signature",draw:"Draw your signature",type:"Type your name to sign",toType:"Can’t draw? Type your name instead",toDraw:"Draw your signature instead",clear:"Clear",drawHint:"Draw your signature in the box above.",clearA11y:"Clear signature",typedSignatureA11y:e=>`Typed signature: ${e}`,missingSignature:"Please add your signature before submitting.",recentlyUsed:"Recently used",moreClinics:"Load more"});var Fn=/* @__PURE__ */Object.freeze({title:En.title,titleFor:e=>{let t=e?.trim()??"";return t.length>0?`Request ${t}’s records`:En.title},leadWeb:"Find the clinic that has them. We send a secure request and read every page they send back.",leadNative:"Find the clinic that has them.",searchLabelWeb:"Find the clinic",howItWorks:"How it works",howSteps:e=>[{title:"We send a secure request",body:"With your permission, straight to the clinic’s records team."},{title:"The clinic sends the file",body:"Most clinics respond within 3 to 5 business days. We follow up for you."},{title:"Everfur reads every page",body:`Visits, vaccines, labs and prescriptions land in ${e}’s records.`}],placeholder:En.placeholder,searchA11y:En.search,clearSearch:"Clear search",loading:"Loading clinics",uploadOwn:"I already have the records",uploadOwnStarting:"Setting up your upload…",noPet:"Add a pet first, then come back to request their records.",recentlyUsed:En.recentlyUsed,noMatch:e=>`No clinics match “${e}”. You can still request records using the option above.`,loadingMore:"Loading more…",loadMoreFailed:"Couldn’t load more. Tap to retry.",selectA11y:e=>`Request records from ${e}`,resultsCount:e=>e===1?"Showing 1 clinic":`Showing ${String(e)} clinics`,fallback:/* @__PURE__ */Object.freeze({title:"Can’t find your clinic?",subtitle:"Add it by email and we’ll request your records.",nameLabel:"Clinic name",namePlaceholder:"Your clinic’s name",emailLabel:"Clinic email",emailPlaceholder:"records@clinic.com",reviewNote:"We review every request by hand before reaching out to the clinic.",submit:"Continue"})});function qn(e){switch(e){case"verified":return{label:"Email on file",a11y:"verified email on file, we can request records directly",tone:"positive"};case"unverified":return{label:"Email unconfirmed",a11y:"email on file but unconfirmed, we will try and let you know",tone:"caution"};default:return{label:"We may need your help",a11y:"no email on file, we may ask you to confirm how to reach this clinic",tone:"neutral"}}}var Mn=1.609344;function Nn(e){return e===null||!Number.isFinite(e)?null:(e/Mn).toFixed(1)}function Wn(e){let t=Nn(e);return t===null?"":`${t} mi`}function Un(e){let t=Nn(e);return t===null?"":`${t} ${t==="1.0"?"mile":"miles"} away`}var Gn=300,Vn=2;var Kn=/* @__PURE__ */Object.freeze({loading:"Loading",empty:"No records yet",upload:"Upload records",consentRequired:"Consent required",allow:"Allow",allPetsConsent:"This covers all your pets. You can withdraw it at any time.",sessionRequired:"Sign in required",recordUnavailable:"Record unavailable",retry:"Try again",records:"Records",beingReviewed:"being reviewed"}),Yn="Everfur summarizes what your vet recorded. It is informational, not diagnostic.";var Xn="your pet";function Qn(e){let t=e?.trim()??"";return t.length>0?t:Xn}var Jn=/* @__PURE__ */Object.freeze({title:"Health records",titleWeb:e=>{let t=e?.trim()??"";return t.length>0?`${t}’s Records`:"Health records"},titleNative:e=>{let t=e?.trim()??"";return t.length>0?t:"Health records"},openTimeline:"Open timeline",loading:"Loading health records",lead:e=>`${Qn(e)}’s lab trends`,retryMarkers:"Retry loading lab trends",viewFullRecord:"View full medical record",viewTimeline:"View full timeline",important:e=>`Important: ${e}`}),Zn=/* @__PURE__ */Object.freeze({title:"At a glance",marker:"Marker",markers:"Markers",outOfRange:"out of range",inRange:"in range",noRange:"NO RANGE",subtitle:"Summary of your pet’s biomarkers",ask:"Ask about these markers",a11y:(e,t,r,n)=>`Marker summary: ${e} ${e===1?"marker":"markers"}, ${t} in range, ${r} out of range${n>0?`, ${n} without a range`:""}.`}),ei=/* @__PURE__ */Object.freeze({counter:(e,t)=>`${e+1} of ${t}`,a11y:(e,t,r)=>e!==null?`${e}, marker ${t+1} of ${r}. Swipe left or right to see more markers.`:`Marker ${t+1} of ${r}`}),ti=/* @__PURE__ */Object.freeze({tapHint:"Tap a point to see where it came from.",singleHint:"One reading so far: we’ll plot a trend as more come in.",empty:"No readings for this marker yet.",ask:"Ask about this marker",askNamed:e=>{let t=e?.trim()??"";return t.length>0?`Ask about ${t}`:"Ask about this marker"},status:e=>`Status: ${e}`,latestA11y:(e,t,r)=>`Latest reading ${e}, ${t}, collected ${r}`,readingsA11y:e=>`${e} readings, oldest to newest`}),ri=/* @__PURE__ */Object.freeze({title:"Where this comes from",close:"Close reading details",collected:"Collected",clinic:"Clinic",referenceRange:"Reference range",noRange:"Not on file for this reading",sourceDocument:"Source document",unverified:"Our team hasn’t verified this reading against the original document yet.",reviewed:"Reviewed by our team",ask:"Ask about this reading"}),ni=/* @__PURE__ */Object.freeze({title:e=>`${Qn(e)}’s records are on the way`,anotherClinic:"Another clinic",anotherClinicSub:"Seen more than one vet? We ask each one.",uploadDocumentPhotoSub:"A PDF, or a photo of a paper record.",body:e=>`We’re requesting ${Qn(e)}’s records from your vet. This usually takes a few days; we’ll show lab trends here as soon as they arrive.`,a11y:e=>`Records request in progress for ${Qn(e)}.`,ask:"Ask about this request"}),ii=/* @__PURE__ */Object.freeze({title:e=>`Add ${Qn(e)}’s records`,firstRecordTitle:e=>`Add ${Qn(e)}’s first record`,body:"Records can come from more than one clinic over a lifetime.",requestFromClinic:"Request from a clinic",requestFromClinicSub:"We send a secure request and read every page they send back.",uploadDocument:"Upload a document"});function li(e){return!isTerminalStatus(e.status)}function pickPetRecordsRequest(e,petRef){if(petRef===null)return null;let t=e.filter(e=>e.petRef===petRef);if(t.length===0)return null;let r=t.find(e=>e.status==="published");return r!==void 0?r:t.filter(li).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))[0]??null}function deriveRecordsDashboardState(e){if(e.hasMarkers)return"published";let t=pickPetRecordsRequest(e.requests,e.petRef);return t===null?"none":t.status==="published"||li(t)?"in_progress":"none"}function oi(e){return e.recordLoading?true:e.hasFullRecord?false:e.markersLoading||!e.hasMarkers&&e.requestsLoading}function selectDashboardView(e){return oi(e)?"loading":e.hasFullRecord?"record":e.markersError||e.recordError&&!e.hasMarkers?"error":e.dashboardState==="in_progress"&&e.drivingRequest!==null?"in_progress":e.dashboardState==="none"?"none":"labs_only"}function ai(e){return e?.httpStatus===429?"rate_limited":e?.httpStatus===502?"service_unavailable":"error"}var si=/* @__PURE__ */Object.freeze({loading:"Loading record request",sentTitle:"Request sent",sentLeadWeb:(e,t)=>`${e} has the request. We’ll let you know when ${t}’s file arrives.`,sentLeadNative:e=>`We’ll let you know when ${e}’s file arrives.`,whereItStands:"Where it stands",details:"Request details",detailsClinic:"Clinic",detailsSent:"Sent",timelineA11y:"Request timeline",awaitingNote:"Clinics usually reply within a week. We follow up automatically and will let you know if there’s no reply by day 14.",waitingBanner:e=>`It’s been ${e} ${e===1?"day":"days"}. Some clinics take a little longer; we’ve been following up automatically and are still on it. If there’s no reply by day 14, we’ll let you know.`,viewRecords:"View health records",nextStep:"You can try a different clinic or upload records you already have.",tryAnotherClinic:"Request from a different clinic",convert:"Upload my own records instead",converting:"Switching…",convertHint:"We’ll stop waiting on the clinic so you can add the records you already have. If the clinic does reply, we’ll still add their records too.",freshUpload:"Upload your own records",freshUploadStarting:"Starting…",cancel:"Cancel request",cancelling:"Cancelling…",resend:"Resend email",resending:"Resending…",errors:/* @__PURE__ */Object.freeze({cancel:"We couldn’t cancel this request. Please try again.",retry:"We couldn’t retry this request. Please try again.",email:"We couldn’t update the clinic email. Please try again.",convert:"We couldn’t switch this to an upload. Please try again.",start:"We couldn’t start that. Please try again.",invalidEmail:"Enter a valid clinic email."})});function di(e){if(e.wireStatus==="clinic_declined")return"The clinic declined to release the records.";if(e.wireStatus==="clinic_responded_no_records")return"The clinic replied but didn’t include your records.";switch(e.failureCode){case"no_response":return"The clinic didn’t reply after several reminders over 14 days.";case"parse_timeout":case"parse_error":return"We received the records but couldn’t read them. Uploading a clean copy usually fixes this.";case"hard_bounce":case"dispatch_failed":return"We couldn’t deliver the email to the clinic.";default:return"This request didn’t go through."}}function ci(e){let t=e.failureReason?.trim()??"";return t.length>0?t:di(e)}var ui=1440*60*1e3;function hi(e,t){if(!e.createdAt)return 0;let r=Date.parse(e.createdAt);if(Number.isNaN(r))return 0;let n=t-r;return n<=0?0:Math.floor(n/ui)}var pi=7;function gi(e,t){return e.wireStatus!=="awaiting_response"?false:hi(e,t)>=pi}function fi(e){return e.status==="failed"}function mi(e){return fi(e)||e.canUpdateClinicEmail===true||e.canRetrySend===true}function bi(e,t){let[a,s]=i(""),[d,c]=i(""),[u,h]=i([]),[p,g]=i(null),[f,m]=i([]),[b,y]=i(true),[v,w]=i(false),[k,x]=i(false),[T,C]=i(null),[_,R]=i(null),[S,z]=i(0),I=r(0),D=r(true),H=t?.latitude,L=t?.longitude,P=n(()=>H!==void 0&&L!==void 0?{latitude:H,longitude:L}:void 0,[H,L]);o(()=>(D.current=true,()=>{D.current=false,I.current+=1}),[e]),o(()=>{let t=true;return y(true),e.recentClinics({limit:5}).then(e=>{t&&(e.ok&&m(e.value.clinics),y(false))}).catch(()=>{t&&y(false)}),()=>{t=false}},[e]),o(()=>{let e=a.trim();if(e.length<Vn){c("");return}let t=setTimeout(()=>c(e),Gn);return()=>clearTimeout(t)},[a]);let O=d.length>=Vn;o(()=>{let t=I.current+=1;if(h([]),g(null),C(null),R(null),!O){w(false);return}w(true),e.searchClinics({query:d,limit:25,...P?{location:P}:{}}).then(e=>{!D.current||t!==I.current||(e.ok?(h(e.value.clinics),g(e.value.nextCursor)):C(e.error),w(false))}).catch(()=>{D.current&&t===I.current&&w(false)})},[e,d,O,P,S]);let $=l(()=>{if(!O||p===null||k)return;let t=I.current;x(true),R(null),e.searchClinics({query:d,limit:25,cursor:p,...P?{location:P}:{}}).then(e=>{!D.current||t!==I.current||(e.ok?(h(t=>[...t,...e.value.clinics]),g(e.value.nextCursor)):R(e.error),x(false))}).catch(()=>{D.current&&t===I.current&&x(false)})},[e,p,d,O,k,P]),B=l(e=>s(e),[]),j=l(()=>z(e=>e+1),[]);return n(()=>({query:a,debouncedQuery:d,isSearchActive:O,clinics:u,recent:f,recentLoading:b,initialLoading:v,loadingMore:k,hasNextPage:p!==null,error:T,pageError:_,setQuery:B,loadMore:$,retry:j}),[a,d,O,u,f,b,v,k,p,T,_,B,$,j])}function yi(e,t,r,n){/* @__PURE__ */
22
- return Object.freeze({key:e?.id??`free:${t??""}`,clinic:e,freeText:t,email:r,idempotencyKey:n})}var vi=10,wi=/* @__PURE__ */u.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),ki=(e,t=1)=>u.string().refine(r=>!cr(r)&&[...r].length>=t&&[...r].length<=e),xi=e=>[...e].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127),Ti=/* @__PURE__ */u.object({clinicId:/* @__PURE__ */wi.optional(),clinicFreeText:ki(200).refine(e=>e.trim().length>0).optional(),clinicEmail:ki(320,3).refine(e=>!xi(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())).optional(),signatureId:/* @__PURE__ */wi.optional(),signaturePngBase64:/* @__PURE__ */u.string().min(1).max(2*1024*1024).optional(),idempotencyKey:/* @__PURE__ */u.string().regex(/^[A-Za-z0-9._-]{8,128}$/)}).strict().refine(e=>e.clinicId===void 0!=(e.clinicFreeText===void 0)).refine(e=>e.signatureId===void 0!=(e.signaturePngBase64===void 0)),Ci=/* @__PURE__ */u.object({petRef:ki(128),ownerName:ki(200).refine(e=>e.trim().length>0&&!xi(e)),authorizationVersion:ki(64),clinics:/* @__PURE__ */u.array(Ti).min(1).max(vi)}).strict(),_i=/* @__PURE__ */u.object({request_group_id:wi,pet_ref:/* @__PURE__ */u.string(),created_count:/* @__PURE__ */u.number().int().nonnegative(),failed_count:/* @__PURE__ */u.number().int().nonnegative(),results:/* @__PURE__ */u.array(/* @__PURE__ */u.object({idempotency_key:/* @__PURE__ */u.string(),clinic_id:/* @__PURE__ */wi.nullable().optional(),clinic_free_text:/* @__PURE__ */u.string().nullable().optional(),created:/* @__PURE__ */u.boolean(),request:/* @__PURE__ */u.unknown().optional(),failure_code:/* @__PURE__ */u.string().nullable().optional(),failure_reason:/* @__PURE__ */u.string().nullable().optional()}))});function createRecordsClinicBatchClient(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}});return{async createClinicRequestBatch(e){if(!Ci.safeParse(e).success)return err(makeEverfurError("validationFailed",{retryable:false}));let r=await t.send("records.clinic.createBatch",{method:"POST",path:"/widget/v1/records/clinic-requests/batch",body:{pet_ref:e.petRef,owner_name:e.ownerName,authorization_version:e.authorizationVersion,clinics:e.clinics.map(e=>({...e.clinicId!==void 0?{clinic_id:e.clinicId}:{clinic_free_text:e.clinicFreeText},...e.clinicEmail!==void 0?{clinic_email:e.clinicEmail}:{},...e.signatureId!==void 0?{signature_id:e.signatureId}:{signature_png_base64:e.signaturePngBase64},idempotency_key:e.idempotencyKey}))}});if(!r.ok)return r;let n=_i.safeParse(r.value);if(!n.success||n.data.pet_ref!==e.petRef)return Ri();let i=[];for(let e of n.data.results){let t=e.request===void 0||e.request===null?null:Ae(e.request);if(e.created!==(t!==null))return Ri();i.push(/* @__PURE__ */Object.freeze({idempotencyKey:e.idempotency_key,clinicId:e.clinic_id??null,clinicFreeText:e.clinic_free_text??null,created:e.created,request:t,failureCode:e.failure_code??null,failureReason:e.failure_reason??null}))}return ok(/* @__PURE__ */Object.freeze({requestGroupId:n.data.request_group_id,petRef:n.data.pet_ref,results:/* @__PURE__ */Object.freeze(i),createdCount:n.data.created_count,failedCount:n.data.failed_count}))}}}function Ri(){return err(makeEverfurError("internalError",{retryable:false}))}var Si=/* @__PURE__ */u.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),zi=/* @__PURE__ */u.object({clinics:/* @__PURE__ */u.array(/* @__PURE__ */u.object({clinic_id:Si,name:/* @__PURE__ */u.string().min(1),address:/* @__PURE__ */u.string().nullable(),phone:/* @__PURE__ */u.string().nullable(),email_status:/* @__PURE__ */u.string(),distance_km:/* @__PURE__ */u.number().finite().nonnegative().nullable()})),next_cursor:/* @__PURE__ */u.string().nullable().optional()}),Ii=/* @__PURE__ */u.object({authorization_version:/* @__PURE__ */u.string().min(1),scope_template:/* @__PURE__ */u.string().min(1),authorization_template:/* @__PURE__ */u.string().min(1)}),Di=/* @__PURE__ */u.object({upload_id:/* @__PURE__ */u.string().min(1),upload_url:/* @__PURE__ */u.string().url().refine(e=>e.startsWith("https://")),upload_fields:/* @__PURE__ */u.record(/* @__PURE__ */u.string())});function Hi(e){let{repository:t}=e,r=async e=>{let t=await e;if(!t.ok)return t;let r=Ae(t.value);return r===null?Li():ok(r)},n=async e=>{let t=await e;if(!t.ok)return t;let r=zi.safeParse(t.value);return r.success?ok(/* @__PURE__ */Object.freeze({clinics:/* @__PURE__ */Object.freeze(r.data.clinics.map(e=>/* @__PURE__ */Object.freeze({id:e.clinic_id,name:e.name,address:e.address,phone:e.phone,emailStatus:e.email_status,distanceKm:e.distance_km}))),nextCursor:r.data.next_cursor??null})):Li()};return{searchClinics:(e={})=>n(t.searchClinics(e)),recentClinics:(e={})=>n(t.recentClinics(e)),async getRequestGroup(e){let r=await t.getRequestGroup(e);if(!r.ok)return r;let n=Fe(r.value);return n===null?Li():ok(n)},async getAuthorizationCopy(){let e=await t.getAuthorizationCopy();if(!e.ok)return e;let r=Ii.safeParse(e.value);return r.success?ok(/* @__PURE__ */Object.freeze({authorizationVersion:r.data.authorization_version,scopeTemplate:r.data.scope_template,authorizationTemplate:r.data.authorization_template})):Li()},async createClinicRequest(e){let n=await r(t.createClinicRequest(e));return n.ok&&n.value.petRef!==e.petRef?Li():n},retryRequest:e=>r(t.retryRequest(e)),revokeRequest:e=>r(t.revokeRequest(e)),updateClinicEmail:(e,n)=>r(t.updateClinicEmail(e,n)),convertToUpload:e=>r(t.convertToUpload(e)),async initiateSignatureUpload(e){let r=await t.initiateSignatureUpload(e);if(!r.ok)return r;let n=Di.safeParse(r.value);return n.success?ok(/* @__PURE__ */Object.freeze({uploadId:n.data.upload_id,uploadUrl:n.data.upload_url,uploadFields:/* @__PURE__ */Object.freeze(n.data.upload_fields)})):Li()},async completeSignatureUpload(e){let r=await t.completeSignatureUpload(e);if(!r.ok)return r;let n=u.object({signature_id:Si}).safeParse(r.value);return n.success?ok(n.data.signature_id):Li()}}}function Li(){return err(makeEverfurError("internalError",{retryable:false}))}var Pi="/widget/v1/records",Oi=/* @__PURE__ */u.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),$i=(e,t=1)=>u.string().refine(r=>!cr(r)&&[...r].length>=t&&[...r].length<=e),Bi=e=>[...e].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127),ji=$i(320,3).refine(e=>!Bi(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())),Ai=$i(64),Ei=/* @__PURE__ */u.object({limit:/* @__PURE__ */u.number().int().min(1).max(25).optional()}).strict(),Fi=/* @__PURE__ */u.object({query:$i(200,0).optional(),location:/* @__PURE__ */u.object({latitude:/* @__PURE__ */u.number().finite().min(-90).max(90),longitude:/* @__PURE__ */u.number().finite().min(-180).max(180)}).strict().optional(),limit:/* @__PURE__ */u.number().int().min(1).max(100).optional(),cursor:$i(512,0).optional()}).strict(),qi=/* @__PURE__ */u.object({petRef:$i(128),ownerName:$i(200).refine(e=>e.trim().length>0&&!Bi(e)),authorizationVersion:$i(64),clinicId:/* @__PURE__ */Oi.optional(),clinicFreeText:$i(200).refine(e=>e.trim().length>0).optional(),clinicEmail:ji.optional(),signatureId:/* @__PURE__ */Oi.optional(),signaturePngBase64:/* @__PURE__ */u.string().min(1).max(2*1024*1024).optional(),idempotencyKey:/* @__PURE__ */u.string().regex(/^[A-Za-z0-9._-]{8,128}$/)}).strict().refine(e=>e.clinicId===void 0!=(e.clinicFreeText===void 0)).refine(e=>e.signatureId===void 0!=(e.signaturePngBase64===void 0));function Mi(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=(e,r,n=false)=>t.send(`records.clinic.${e}`,r,r.method==="GET"||n?void 0:{idempotent:false,maxAttempts:1}),n=(e,t,n)=>Ai.safeParse(e).success?r(t,{method:"POST",path:`${Pi}/requests/${encodeURIComponent(e)}/${t}`,...n?{body:n}:{}}):Ni();return{searchClinics(e){return Fi.safeParse(e).success?r("search",{method:"GET",path:`${Pi}/clinics/search`,query:{q:e.query??"",lat:e.location?.latitude,lng:e.location?.longitude,limit:e.limit,cursor:e.cursor}}):Ni()},recentClinics(e){return Ei.safeParse(e).success?r("recent",{method:"GET",path:`${Pi}/clinics/recent`,query:{limit:e.limit}}):Ni()},getRequestGroup(e){return Ai.safeParse(e).success?r("requestGroup",{method:"GET",path:`${Pi}/request-groups/${encodeURIComponent(e)}`}):Ni()},getAuthorizationCopy:()=>r("authorizationCopy",{method:"GET",path:`${Pi}/authorization-copy`}),createClinicRequest(e){return qi.safeParse(e).success?r("create",{method:"POST",path:`${Pi}/clinic-requests`,body:{pet_ref:e.petRef,owner_name:e.ownerName,authorization_version:e.authorizationVersion,idempotency_key:e.idempotencyKey,...e.clinicId!==void 0?{clinic_id:e.clinicId}:{clinic_free_text:e.clinicFreeText},...e.clinicEmail!==void 0?{clinic_email:e.clinicEmail}:{},...e.signatureId!==void 0?{signature_id:e.signatureId}:{signature_png_base64:e.signaturePngBase64}}},true):Ni()},retryRequest:e=>n(e,"retry"),revokeRequest:e=>n(e,"revoke"),convertToUpload:e=>n(e,"convert-to-upload"),updateClinicEmail(e,t){return ji.safeParse(t).success?n(e,"clinic-email",{clinic_email:t}):Ni()},initiateSignatureUpload(e){return!Number.isInteger(e)||e<=0||e>2*1024*1024?Ni():r("signatureInitiate",{method:"POST",path:`${Pi}/signatures/initiate`,body:{content_type:"image/png",file_size:e}})},completeSignatureUpload(e){return/^sig-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?r("signatureComplete",{method:"POST",path:`${Pi}/signatures/complete`,body:{upload_id:e}}):Ni()}}}function Ni(){return Promise.resolve(err(makeEverfurError("validationFailed",{retryable:false})))}function useEverfurRecordsClinic(){let{runtime:e,userRef:userRef,scopeEpoch:t}=Ir(),i=n(()=>{let{services:t}=e.registry;return Hi({repository:Mi({auth:t.authFor(userRef),...t.errorPolicy?{errorPolicy:t.errorPolicy}:{}})})},[e,userRef,t]),l=r(i);return o(()=>(l.current=i,()=>{l.current=null}),[i]),n(()=>{let e=async e=>{if(userRef===null||l.current!==i)return err(makeEverfurError("accessDenied"));let t=await e();return l.current===i?t:err(makeEverfurError("accessDenied"))};return{searchClinics:t=>e(()=>i.searchClinics(t)),recentClinics:t=>e(()=>i.recentClinics(t)),getRequestGroup:t=>e(()=>i.getRequestGroup(t)),getAuthorizationCopy:()=>e(()=>i.getAuthorizationCopy()),createClinicRequest:t=>e(()=>i.createClinicRequest(t)),retryRequest:t=>e(()=>i.retryRequest(t)),revokeRequest:t=>e(()=>i.revokeRequest(t)),updateClinicEmail:(t,r)=>e(()=>i.updateClinicEmail(t,r)),convertToUpload:t=>e(()=>i.convertToUpload(t)),initiateSignatureUpload:t=>e(()=>i.initiateSignatureUpload(t)),completeSignatureUpload:t=>e(()=>i.completeSignatureUpload(t))}},[i,userRef])}function useEverfurRecordsClinicBatch(){let{runtime:e,userRef:userRef,scopeEpoch:t}=Ir(),i=n(()=>{let{services:t}=e.registry;return createRecordsClinicBatchClient({auth:t.authFor(userRef),...t.errorPolicy?{errorPolicy:t.errorPolicy}:{}})},[e,userRef,t]),l=r(i);return o(()=>(l.current=i,()=>{l.current=null}),[i]),n(()=>({async createClinicRequestBatch(e){if(userRef===null||l.current!==i)return err(makeEverfurError("accessDenied"));let t=await i.createClinicRequestBatch(e);return l.current===i?t:err(makeEverfurError("accessDenied"))}}),[i,userRef])}var Wi=class extends c{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(e,t){return Object.is(e.resetKey,t.key)?null:{failed:false,key:e.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:e}){return e()}function HostRender({render:e,fallback:r,resetKey:n}){return t(Wi,{fallback:r,resetKey:n,children:t(RenderHost,{render:e})})}var Ui=/* @__PURE__ */Object.freeze({chat:/* @__PURE__ */Object.freeze(["chat.message.create"]),records:/* @__PURE__ */Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:/* @__PURE__ */Object.freeze(["records.clinic.create"]),video:/* @__PURE__ */Object.freeze(["video.gait.execute"]),photo:/* @__PURE__ */Object.freeze(["photo.checkup.execute"]),animations:/* @__PURE__ */Object.freeze(["animations.state.read"]),televet:/* @__PURE__ */Object.freeze(["televet.visit.create"]),texting:/* @__PURE__ */Object.freeze(["sms.identity.read","sms.identity.update"]),healthPlan:/* @__PURE__ */Object.freeze(["shop.plan.read","shop.plan.update"])});function requires(e){return Ui[e]}function decideCapability(e,t,r){let n=requires(e),i=/* @__PURE__ */new Map;for(let e of t)i.set(e.resource,e);if(r?.isPending===true&&n.some(e=>!i.has(e)))return Ki({name:e,enabled:false,isPending:true,limits:{}});let l=Gi(n,i);return n.filter(e=>i.get(e)?.granted!==true).length===0?Ki({name:e,enabled:true,isPending:false,limits:l}):Ki({name:e,enabled:false,isPending:false,limits:l,disabled:Vi(n,i)})}function Gi(e,t){let r={};for(let n of e){let e=t.get(n)?.limits;if(e)for(let[t,n]of Object.entries(e)){let e=r[t];r[t]=e===void 0?n:Math.min(e,n)}}return r}function Vi(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
21
+ return Object.freeze({stack:/* @__PURE__ */Object.freeze([...e.stack.slice(0,-1),t])})}function resetRecordsNav(e){return initialRecordsNav(e)}function popRecordsNav(e){return e.stack.length<=1?{state:e,handled:false}:{state:/* @__PURE__ */Object.freeze({stack:/* @__PURE__ */Object.freeze(e.stack.slice(0,-1))}),handled:true}}function transitionRecordsNav(e,t){return t.name==="dashboard"?resetRecordsNav(t):currentRecordsScreen(e).name==="upload"&&t.name==="request"?replaceRecordsNav(e,t):pushRecordsNav(e,t)}function recordsNavReducer(e,t){switch(t.type){case"push":return pushRecordsNav(e,t.screen);case"pop":return popRecordsNav(e).state;case"replace":return replaceRecordsNav(e,t.screen);case"reset":return resetRecordsNav(t.screen);case"navigate":return transitionRecordsNav(e,t.screen);default:return e}}var rn=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[rn[t]]}}function headingFace(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type;if(r===null&&n===null)return face(e,t);if(r!==null)return{fontFamily:r,fontWeight:n??e.type.weight[rn[t]]};let i=face(e,t);return i.fontWeight===void 0||n===null?i:{fontFamily:i.fontFamily,fontWeight:n}}function nn(e){return e<=450?"regular":e<=650?"medium":"bold"}var ln={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=on.get(e);r===void 0&&(r=/* @__PURE__ */new Map,on.set(e,r));let n=r.get(t);if(n!==void 0)return n;let i=an(e,t);return r.set(t,i),i}var on=/* @__PURE__ */new WeakMap;function an(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,i=nn(Number(n)),l=r.face==="mono"?face(e,ln[i]):r.face==="heading"?headingFace(e,i):face(e,i),o=r.face==="heading"?e.type.headingWeight??n:n,a=l.fontWeight===void 0?l:{fontFamily:l.fontFamily,fontWeight:o},s=r.size,d={...a,fontSize:s,lineHeight:Math.round(s*r.lineHeight*100)/100};return r.letterSpacing!==0&&(d.letterSpacing=Math.round(s*r.letterSpacing*100)/100),r.uppercase&&(d.textTransform="uppercase"),/* @__PURE__ */Object.freeze(d)}var sn=/* @__PURE__ */Object.freeze({display:/* @__PURE__ */Object.freeze({size:29,lineHeight:1.06,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),title:/* @__PURE__ */Object.freeze({size:23,lineHeight:1.12,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),cardTitle:/* @__PURE__ */Object.freeze({size:19,lineHeight:1.22,weight:"800",face:"sans",letterSpacing:0,uppercase:false,tier:"heading"}),rowTitle:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.4,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),body:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),message:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),bodySmall:/* @__PURE__ */Object.freeze({size:14.5,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),caption:/* @__PURE__ */Object.freeze({size:13,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),label:/* @__PURE__ */Object.freeze({size:10.5,lineHeight:1.4,weight:"400",face:"mono",letterSpacing:.05,uppercase:true,tier:"compact"}),eyebrow:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"mono",letterSpacing:.07,uppercase:true,tier:"compact"}),chip:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.3,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),tab:/* @__PURE__ */Object.freeze({size:16,lineHeight:1.5,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),button:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"control"}),badge:/* @__PURE__ */Object.freeze({size:12,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"badge"})});var dn=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){dn(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var cn=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var un={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},hn={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},pn={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},gn={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},fn={regular:"400",medium:"500",bold:"700"},mn={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},bn=0,yn="System",vn="monospace",wn=["content","heading","control","compact","badge"];function kn(e){let t={};for(let r of wn)t[r]=e;return t}var xn=[];function Tn(){return{family:yn,mono:vn,fontUrl:null,families:{regular:yn,medium:yn,bold:yn,mono:vn,monoMedium:vn,monoBold:vn},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:pn,tierSizes:kn(pn),lineHeight:gn,weight:fn,letterSpacing:mn,scale:1,maxScale:bn,scaleCaps:cn,headingFamily:null,headingWeight:null,fontSources:xn,roles:sn,typeScale:1}}var _n={},Cn=/* @__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(e){return`cubic-bezier(${e.join(", ")})`}var Rn={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(Cn.standard),emphasized:cssCubicBezier(Cn.emphasized),exit:cssCubicBezier(Cn.exit)},reducedMotion:false},Sn={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)"},zn=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Sn,space:un,radius:hn,type:Tn(),motion:Rn,slots:_n}),In={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)"},Dn=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:In,space:un,radius:hn,type:Tn(),motion:Rn,slots:_n});var Hn=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Ln=globalThis,Pn=Ln[Hn]??(Ln[Hn]=createContext(zn));Pn.displayName??="EverfurThemeContext";function useEverfurTheme(){return s(Pn)}function On(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:e,variant:r,...n}){let i=useEverfurTheme(),l=r===void 0?void 0:i.type.roles[r],o=On(i.type,e??l?.tier??"content"),a=r===void 0?n:{...n,style:[{...textRole(i,r),color:i.color.text.primary,flexShrink:1},n.style]};return t(R,o===void 0?a:{maxFontSizeMultiplier:o,...a})}var $n=e(function(e,r){return t(h,{...e,...r===null?{}:{ref:r}})});function Bn(e,t){if(e===void 0)return{};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}function jn(e){return e?.textColor===void 0?{}:{color:e.textColor}}function An(e){return e.recordCard??e.card}var En=/* @__PURE__ */Object.freeze({title:"Request records",clinic:"Clinic",search:"Search clinics by name or location",placeholder:"Clinic name, city, or ZIP",email:"Clinic email",emailPlaceholder:"records@clinic.com",ownerName:"Your full name",scopeHeading:"What you’re authorizing",send:"Send request",sending:"Sending…",cancel:"Cancel",sign:"Signature",draw:"Draw your signature",type:"Type your name to sign",toType:"Can’t draw? Type your name instead",toDraw:"Draw your signature instead",clear:"Clear",drawHint:"Draw your signature in the box above.",clearA11y:"Clear signature",typedSignatureA11y:e=>`Typed signature: ${e}`,missingSignature:"Please add your signature before submitting.",recentlyUsed:"Recently used",moreClinics:"Load more"});var Fn=/* @__PURE__ */Object.freeze({title:En.title,titleFor:e=>{let t=e?.trim()??"";return t.length>0?`Request ${t}’s records`:En.title},leadWeb:"Find the clinic that has them. We send a secure request and read every page they send back.",leadNative:"Find the clinic that has them.",searchLabelWeb:"Find the clinic",howItWorks:"How it works",howSteps:e=>[{title:"We send a secure request",body:"With your permission, straight to the clinic’s records team."},{title:"The clinic sends the file",body:"Most clinics respond within 3 to 5 business days. We follow up for you."},{title:"Everfur reads every page",body:`Visits, vaccines, labs and prescriptions land in ${e}’s records.`}],placeholder:En.placeholder,searchA11y:En.search,clearSearch:"Clear search",loading:"Loading clinics",uploadOwn:"I already have the records",uploadOwnStarting:"Setting up your upload…",noPet:"Add a pet first, then come back to request their records.",recentlyUsed:En.recentlyUsed,noMatch:e=>`No clinics match “${e}”. You can still request records using the option above.`,loadingMore:"Loading more…",loadMoreFailed:"Couldn’t load more. Tap to retry.",selectA11y:e=>`Request records from ${e}`,resultsCount:e=>e===1?"Showing 1 clinic":`Showing ${String(e)} clinics`,fallback:/* @__PURE__ */Object.freeze({title:"Can’t find your clinic?",subtitle:"Add it by email and we’ll request your records.",nameLabel:"Clinic name",namePlaceholder:"Your clinic’s name",emailLabel:"Clinic email",emailPlaceholder:"records@clinic.com",reviewNote:"We review every request by hand before reaching out to the clinic.",submit:"Continue"})});function qn(e){switch(e){case"verified":return{label:"Email on file",a11y:"verified email on file, we can request records directly",tone:"positive"};case"unverified":return{label:"Email unconfirmed",a11y:"email on file but unconfirmed, we will try and let you know",tone:"caution"};default:return{label:"We may need your help",a11y:"no email on file, we may ask you to confirm how to reach this clinic",tone:"neutral"}}}var Mn=1.609344;function Nn(e){return e===null||!Number.isFinite(e)?null:(e/Mn).toFixed(1)}function Wn(e){let t=Nn(e);return t===null?"":`${t} mi`}function Un(e){let t=Nn(e);return t===null?"":`${t} ${t==="1.0"?"mile":"miles"} away`}var Gn=300,Vn=2;var Kn=/* @__PURE__ */Object.freeze({loading:"Loading",empty:"No records yet",upload:"Upload records",consentRequired:"Consent required",allow:"Allow",allPetsConsent:"This covers all your pets. You can withdraw it at any time.",sessionRequired:"Sign in required",recordUnavailable:"Record unavailable",retry:"Try again",records:"Records",beingReviewed:"being reviewed"}),Yn="Everfur summarizes what your vet recorded. It is informational, not diagnostic.";var Xn="your pet";function Qn(e){let t=e?.trim()??"";return t.length>0?t:Xn}var Jn=/* @__PURE__ */Object.freeze({title:"Health records",titleWeb:e=>{let t=e?.trim()??"";return t.length>0?`${t}’s Records`:"Health records"},titleNative:e=>{let t=e?.trim()??"";return t.length>0?t:"Health records"},openTimeline:"Open timeline",loading:"Loading health records",lead:e=>`${Qn(e)}’s lab trends`,retryMarkers:"Retry loading lab trends",viewFullRecord:"View full medical record",viewTimeline:"View full timeline",important:e=>`Important: ${e}`}),Zn=/* @__PURE__ */Object.freeze({title:"At a glance",marker:"Marker",markers:"Markers",outOfRange:"out of range",inRange:"in range",noRange:"NO RANGE",subtitle:"Summary of your pet’s biomarkers",ask:"Ask about these markers",a11y:(e,t,r,n)=>`Marker summary: ${e} ${e===1?"marker":"markers"}, ${t} in range, ${r} out of range${n>0?`, ${n} without a range`:""}.`}),ei=/* @__PURE__ */Object.freeze({counter:(e,t)=>`${e+1} of ${t}`,a11y:(e,t,r)=>e!==null?`${e}, marker ${t+1} of ${r}. Swipe left or right to see more markers.`:`Marker ${t+1} of ${r}`}),ti=/* @__PURE__ */Object.freeze({tapHint:"Tap a point to see where it came from.",singleHint:"One reading so far: we’ll plot a trend as more come in.",empty:"No readings for this marker yet.",ask:"Ask about this marker",askNamed:e=>{let t=e?.trim()??"";return t.length>0?`Ask about ${t}`:"Ask about this marker"},status:e=>`Status: ${e}`,latestA11y:(e,t,r)=>`Latest reading ${e}, ${t}, collected ${r}`,readingsA11y:e=>`${e} readings, oldest to newest`}),ri=/* @__PURE__ */Object.freeze({title:"Where this comes from",close:"Close reading details",collected:"Collected",clinic:"Clinic",referenceRange:"Reference range",noRange:"Not on file for this reading",sourceDocument:"Source document",unverified:"Our team hasn’t verified this reading against the original document yet.",reviewed:"Reviewed by our team",ask:"Ask about this reading"}),ni=/* @__PURE__ */Object.freeze({title:e=>`${Qn(e)}’s records are on the way`,anotherClinic:"Another clinic",anotherClinicSub:"Seen more than one vet? We ask each one.",uploadDocumentPhotoSub:"A PDF, or a photo of a paper record.",body:e=>`We’re requesting ${Qn(e)}’s records from your vet. This usually takes a few days; we’ll show lab trends here as soon as they arrive.`,a11y:e=>`Records request in progress for ${Qn(e)}.`,ask:"Ask about this request"}),ii=/* @__PURE__ */Object.freeze({title:e=>`Add ${Qn(e)}’s records`,firstRecordTitle:e=>`Add ${Qn(e)}’s first record`,body:"Records can come from more than one clinic over a lifetime.",requestFromClinic:"Request from a clinic",requestFromClinicSub:"We send a secure request and read every page they send back.",uploadDocument:"Upload a document"});function li(e){return!isTerminalStatus(e.status)}function pickPetRecordsRequest(e,petRef){if(petRef===null)return null;let t=e.filter(e=>e.petRef===petRef);if(t.length===0)return null;let r=t.find(e=>e.status==="published");return r!==void 0?r:t.filter(li).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))[0]??null}function deriveRecordsDashboardState(e){if(e.hasMarkers)return"published";let t=pickPetRecordsRequest(e.requests,e.petRef);return t===null?"none":t.status==="published"||li(t)?"in_progress":"none"}function oi(e){return e.recordLoading?true:e.hasFullRecord?false:e.markersLoading||!e.hasMarkers&&e.requestsLoading}function selectDashboardView(e){return oi(e)?"loading":e.hasFullRecord?"record":e.markersError||e.recordError&&!e.hasMarkers?"error":e.dashboardState==="in_progress"&&e.drivingRequest!==null?"in_progress":e.dashboardState==="none"?"none":"labs_only"}function ai(e){return e?.httpStatus===429?"rate_limited":e?.httpStatus===502?"service_unavailable":"error"}var si=/* @__PURE__ */Object.freeze({loading:"Loading record request",sentTitle:"Request sent",sentLeadWeb:(e,t)=>`${e} has the request. We’ll let you know when ${t}’s file arrives.`,sentLeadNative:e=>`We’ll let you know when ${e}’s file arrives.`,whereItStands:"Where it stands",details:"Request details",detailsClinic:"Clinic",detailsSent:"Sent",timelineA11y:"Request timeline",awaitingNote:"Clinics usually reply within a week. We follow up automatically and will let you know if there’s no reply by day 14.",waitingBanner:e=>`It’s been ${e} ${e===1?"day":"days"}. Some clinics take a little longer; we’ve been following up automatically and are still on it. If there’s no reply by day 14, we’ll let you know.`,viewRecords:"View health records",nextStep:"You can try a different clinic or upload records you already have.",tryAnotherClinic:"Request from a different clinic",convert:"Upload my own records instead",converting:"Switching…",convertHint:"We’ll stop waiting on the clinic so you can add the records you already have. If the clinic does reply, we’ll still add their records too.",freshUpload:"Upload your own records",freshUploadStarting:"Starting…",cancel:"Cancel request",cancelling:"Cancelling…",resend:"Resend email",resending:"Resending…",errors:/* @__PURE__ */Object.freeze({cancel:"We couldn’t cancel this request. Please try again.",retry:"We couldn’t retry this request. Please try again.",email:"We couldn’t update the clinic email. Please try again.",convert:"We couldn’t switch this to an upload. Please try again.",start:"We couldn’t start that. Please try again.",invalidEmail:"Enter a valid clinic email."})});function di(e){if(e.wireStatus==="clinic_declined")return"The clinic declined to release the records.";if(e.wireStatus==="clinic_responded_no_records")return"The clinic replied but didn’t include your records.";switch(e.failureCode){case"no_response":return"The clinic didn’t reply after several reminders over 14 days.";case"parse_timeout":case"parse_error":return"We received the records but couldn’t read them. Uploading a clean copy usually fixes this.";case"hard_bounce":case"dispatch_failed":return"We couldn’t deliver the email to the clinic.";default:return"This request didn’t go through."}}function ci(e){let t=e.failureReason?.trim()??"";return t.length>0?t:di(e)}var ui=1440*60*1e3;function hi(e,t){if(!e.createdAt)return 0;let r=Date.parse(e.createdAt);if(Number.isNaN(r))return 0;let n=t-r;return n<=0?0:Math.floor(n/ui)}var pi=7;function gi(e,t){return e.wireStatus!=="awaiting_response"?false:hi(e,t)>=pi}function fi(e){return e.status==="failed"}function mi(e){return fi(e)||e.canUpdateClinicEmail===true||e.canRetrySend===true}function bi(e,t){let[a,s]=i(""),[d,c]=i(""),[u,h]=i([]),[p,g]=i(null),[f,m]=i([]),[b,y]=i(true),[v,w]=i(false),[k,x]=i(false),[T,_]=i(null),[C,R]=i(null),[S,z]=i(0),I=r(0),D=r(true),H=t?.latitude,L=t?.longitude,P=n(()=>H!==void 0&&L!==void 0?{latitude:H,longitude:L}:void 0,[H,L]);o(()=>(D.current=true,()=>{D.current=false,I.current+=1}),[e]),o(()=>{let t=true;return y(true),e.recentClinics({limit:5}).then(e=>{t&&(e.ok&&m(e.value.clinics),y(false))}).catch(()=>{t&&y(false)}),()=>{t=false}},[e]),o(()=>{let e=a.trim();if(e.length<Vn){c("");return}let t=setTimeout(()=>c(e),Gn);return()=>clearTimeout(t)},[a]);let O=d.length>=Vn;o(()=>{let t=I.current+=1;if(h([]),g(null),_(null),R(null),!O){w(false);return}w(true),e.searchClinics({query:d,limit:25,...P?{location:P}:{}}).then(e=>{!D.current||t!==I.current||(e.ok?(h(e.value.clinics),g(e.value.nextCursor)):_(e.error),w(false))}).catch(()=>{D.current&&t===I.current&&w(false)})},[e,d,O,P,S]);let $=l(()=>{if(!O||p===null||k)return;let t=I.current;x(true),R(null),e.searchClinics({query:d,limit:25,cursor:p,...P?{location:P}:{}}).then(e=>{!D.current||t!==I.current||(e.ok?(h(t=>[...t,...e.value.clinics]),g(e.value.nextCursor)):R(e.error),x(false))}).catch(()=>{D.current&&t===I.current&&x(false)})},[e,p,d,O,k,P]),B=l(e=>s(e),[]),j=l(()=>z(e=>e+1),[]);return n(()=>({query:a,debouncedQuery:d,isSearchActive:O,clinics:u,recent:f,recentLoading:b,initialLoading:v,loadingMore:k,hasNextPage:p!==null,error:T,pageError:C,setQuery:B,loadMore:$,retry:j}),[a,d,O,u,f,b,v,k,p,T,C,B,$,j])}function yi(e,t,r,n){/* @__PURE__ */
22
+ return Object.freeze({key:e?.id??`free:${t??""}`,clinic:e,freeText:t,email:r,idempotencyKey:n})}var vi=10,wi=/* @__PURE__ */u.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),ki=(e,t=1)=>u.string().refine(r=>!cr(r)&&[...r].length>=t&&[...r].length<=e),xi=e=>[...e].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127),Ti=/* @__PURE__ */u.object({clinicId:/* @__PURE__ */wi.optional(),clinicFreeText:ki(200).refine(e=>e.trim().length>0).optional(),clinicEmail:ki(320,3).refine(e=>!xi(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())).optional(),signatureId:/* @__PURE__ */wi.optional(),signaturePngBase64:/* @__PURE__ */u.string().min(1).max(2*1024*1024).optional(),idempotencyKey:/* @__PURE__ */u.string().regex(/^[A-Za-z0-9._-]{8,128}$/)}).strict().refine(e=>e.clinicId===void 0!=(e.clinicFreeText===void 0)).refine(e=>e.signatureId===void 0!=(e.signaturePngBase64===void 0)),_i=/* @__PURE__ */u.object({petRef:ki(128),ownerName:ki(200).refine(e=>e.trim().length>0&&!xi(e)),authorizationVersion:ki(64),clinics:/* @__PURE__ */u.array(Ti).min(1).max(vi)}).strict(),Ci=/* @__PURE__ */u.object({request_group_id:wi,pet_ref:/* @__PURE__ */u.string(),created_count:/* @__PURE__ */u.number().int().nonnegative(),failed_count:/* @__PURE__ */u.number().int().nonnegative(),results:/* @__PURE__ */u.array(/* @__PURE__ */u.object({idempotency_key:/* @__PURE__ */u.string(),clinic_id:/* @__PURE__ */wi.nullable().optional(),clinic_free_text:/* @__PURE__ */u.string().nullable().optional(),created:/* @__PURE__ */u.boolean(),request:/* @__PURE__ */u.unknown().optional(),failure_code:/* @__PURE__ */u.string().nullable().optional(),failure_reason:/* @__PURE__ */u.string().nullable().optional()}))});function createRecordsClinicBatchClient(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}});return{async createClinicRequestBatch(e){if(!_i.safeParse(e).success)return err(makeEverfurError("validationFailed",{retryable:false}));let r=await t.send("records.clinic.createBatch",{method:"POST",path:"/widget/v1/records/clinic-requests/batch",body:{pet_ref:e.petRef,owner_name:e.ownerName,authorization_version:e.authorizationVersion,clinics:e.clinics.map(e=>({...e.clinicId!==void 0?{clinic_id:e.clinicId}:{clinic_free_text:e.clinicFreeText},...e.clinicEmail!==void 0?{clinic_email:e.clinicEmail}:{},...e.signatureId!==void 0?{signature_id:e.signatureId}:{signature_png_base64:e.signaturePngBase64},idempotency_key:e.idempotencyKey}))}});if(!r.ok)return r;let n=Ci.safeParse(r.value);if(!n.success||n.data.pet_ref!==e.petRef)return Ri();let i=[];for(let e of n.data.results){let t=e.request===void 0||e.request===null?null:Ae(e.request);if(e.created!==(t!==null))return Ri();i.push(/* @__PURE__ */Object.freeze({idempotencyKey:e.idempotency_key,clinicId:e.clinic_id??null,clinicFreeText:e.clinic_free_text??null,created:e.created,request:t,failureCode:e.failure_code??null,failureReason:e.failure_reason??null}))}return ok(/* @__PURE__ */Object.freeze({requestGroupId:n.data.request_group_id,petRef:n.data.pet_ref,results:/* @__PURE__ */Object.freeze(i),createdCount:n.data.created_count,failedCount:n.data.failed_count}))}}}function Ri(){return err(makeEverfurError("internalError",{retryable:false}))}var Si=/* @__PURE__ */u.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),zi=/* @__PURE__ */u.object({clinics:/* @__PURE__ */u.array(/* @__PURE__ */u.object({clinic_id:Si,name:/* @__PURE__ */u.string().min(1),address:/* @__PURE__ */u.string().nullable(),phone:/* @__PURE__ */u.string().nullable(),email_status:/* @__PURE__ */u.string(),distance_km:/* @__PURE__ */u.number().finite().nonnegative().nullable()})),next_cursor:/* @__PURE__ */u.string().nullable().optional()}),Ii=/* @__PURE__ */u.object({authorization_version:/* @__PURE__ */u.string().min(1),scope_template:/* @__PURE__ */u.string().min(1),authorization_template:/* @__PURE__ */u.string().min(1)}),Di=/* @__PURE__ */u.object({upload_id:/* @__PURE__ */u.string().min(1),upload_url:/* @__PURE__ */u.string().url().refine(e=>e.startsWith("https://")),upload_fields:/* @__PURE__ */u.record(/* @__PURE__ */u.string())});function Hi(e){let{repository:t}=e,r=async e=>{let t=await e;if(!t.ok)return t;let r=Ae(t.value);return r===null?Li():ok(r)},n=async e=>{let t=await e;if(!t.ok)return t;let r=zi.safeParse(t.value);return r.success?ok(/* @__PURE__ */Object.freeze({clinics:/* @__PURE__ */Object.freeze(r.data.clinics.map(e=>/* @__PURE__ */Object.freeze({id:e.clinic_id,name:e.name,address:e.address,phone:e.phone,emailStatus:e.email_status,distanceKm:e.distance_km}))),nextCursor:r.data.next_cursor??null})):Li()};return{searchClinics:(e={})=>n(t.searchClinics(e)),recentClinics:(e={})=>n(t.recentClinics(e)),async getRequestGroup(e){let r=await t.getRequestGroup(e);if(!r.ok)return r;let n=Fe(r.value);return n===null?Li():ok(n)},async getAuthorizationCopy(){let e=await t.getAuthorizationCopy();if(!e.ok)return e;let r=Ii.safeParse(e.value);return r.success?ok(/* @__PURE__ */Object.freeze({authorizationVersion:r.data.authorization_version,scopeTemplate:r.data.scope_template,authorizationTemplate:r.data.authorization_template})):Li()},async createClinicRequest(e){let n=await r(t.createClinicRequest(e));return n.ok&&n.value.petRef!==e.petRef?Li():n},retryRequest:e=>r(t.retryRequest(e)),revokeRequest:e=>r(t.revokeRequest(e)),updateClinicEmail:(e,n)=>r(t.updateClinicEmail(e,n)),convertToUpload:e=>r(t.convertToUpload(e)),async initiateSignatureUpload(e){let r=await t.initiateSignatureUpload(e);if(!r.ok)return r;let n=Di.safeParse(r.value);return n.success?ok(/* @__PURE__ */Object.freeze({uploadId:n.data.upload_id,uploadUrl:n.data.upload_url,uploadFields:/* @__PURE__ */Object.freeze(n.data.upload_fields)})):Li()},async completeSignatureUpload(e){let r=await t.completeSignatureUpload(e);if(!r.ok)return r;let n=u.object({signature_id:Si}).safeParse(r.value);return n.success?ok(n.data.signature_id):Li()}}}function Li(){return err(makeEverfurError("internalError",{retryable:false}))}var Pi="/widget/v1/records",Oi=/* @__PURE__ */u.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),$i=(e,t=1)=>u.string().refine(r=>!cr(r)&&[...r].length>=t&&[...r].length<=e),Bi=e=>[...e].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127),ji=$i(320,3).refine(e=>!Bi(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())),Ai=$i(64),Ei=/* @__PURE__ */u.object({limit:/* @__PURE__ */u.number().int().min(1).max(25).optional()}).strict(),Fi=/* @__PURE__ */u.object({query:$i(200,0).optional(),location:/* @__PURE__ */u.object({latitude:/* @__PURE__ */u.number().finite().min(-90).max(90),longitude:/* @__PURE__ */u.number().finite().min(-180).max(180)}).strict().optional(),limit:/* @__PURE__ */u.number().int().min(1).max(100).optional(),cursor:$i(512,0).optional()}).strict(),qi=/* @__PURE__ */u.object({petRef:$i(128),ownerName:$i(200).refine(e=>e.trim().length>0&&!Bi(e)),authorizationVersion:$i(64),clinicId:/* @__PURE__ */Oi.optional(),clinicFreeText:$i(200).refine(e=>e.trim().length>0).optional(),clinicEmail:ji.optional(),signatureId:/* @__PURE__ */Oi.optional(),signaturePngBase64:/* @__PURE__ */u.string().min(1).max(2*1024*1024).optional(),idempotencyKey:/* @__PURE__ */u.string().regex(/^[A-Za-z0-9._-]{8,128}$/)}).strict().refine(e=>e.clinicId===void 0!=(e.clinicFreeText===void 0)).refine(e=>e.signatureId===void 0!=(e.signaturePngBase64===void 0));function Mi(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=(e,r,n=false)=>t.send(`records.clinic.${e}`,r,r.method==="GET"||n?void 0:{idempotent:false,maxAttempts:1}),n=(e,t,n)=>Ai.safeParse(e).success?r(t,{method:"POST",path:`${Pi}/requests/${encodeURIComponent(e)}/${t}`,...n?{body:n}:{}}):Ni();return{searchClinics(e){return Fi.safeParse(e).success?r("search",{method:"GET",path:`${Pi}/clinics/search`,query:{q:e.query??"",lat:e.location?.latitude,lng:e.location?.longitude,limit:e.limit,cursor:e.cursor}}):Ni()},recentClinics(e){return Ei.safeParse(e).success?r("recent",{method:"GET",path:`${Pi}/clinics/recent`,query:{limit:e.limit}}):Ni()},getRequestGroup(e){return Ai.safeParse(e).success?r("requestGroup",{method:"GET",path:`${Pi}/request-groups/${encodeURIComponent(e)}`}):Ni()},getAuthorizationCopy:()=>r("authorizationCopy",{method:"GET",path:`${Pi}/authorization-copy`}),createClinicRequest(e){return qi.safeParse(e).success?r("create",{method:"POST",path:`${Pi}/clinic-requests`,body:{pet_ref:e.petRef,owner_name:e.ownerName,authorization_version:e.authorizationVersion,idempotency_key:e.idempotencyKey,...e.clinicId!==void 0?{clinic_id:e.clinicId}:{clinic_free_text:e.clinicFreeText},...e.clinicEmail!==void 0?{clinic_email:e.clinicEmail}:{},...e.signatureId!==void 0?{signature_id:e.signatureId}:{signature_png_base64:e.signaturePngBase64}}},true):Ni()},retryRequest:e=>n(e,"retry"),revokeRequest:e=>n(e,"revoke"),convertToUpload:e=>n(e,"convert-to-upload"),updateClinicEmail(e,t){return ji.safeParse(t).success?n(e,"clinic-email",{clinic_email:t}):Ni()},initiateSignatureUpload(e){return!Number.isInteger(e)||e<=0||e>2*1024*1024?Ni():r("signatureInitiate",{method:"POST",path:`${Pi}/signatures/initiate`,body:{content_type:"image/png",file_size:e}})},completeSignatureUpload(e){return/^sig-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?r("signatureComplete",{method:"POST",path:`${Pi}/signatures/complete`,body:{upload_id:e}}):Ni()}}}function Ni(){return Promise.resolve(err(makeEverfurError("validationFailed",{retryable:false})))}function useEverfurRecordsClinic(){let{runtime:e,userRef:userRef,scopeEpoch:t}=Ir(),i=n(()=>{let{services:t}=e.registry;return Hi({repository:Mi({auth:t.authFor(userRef),...t.errorPolicy?{errorPolicy:t.errorPolicy}:{}})})},[e,userRef,t]),l=r(i);return o(()=>(l.current=i,()=>{l.current=null}),[i]),n(()=>{let e=async e=>{if(userRef===null||l.current!==i)return err(makeEverfurError("accessDenied"));let t=await e();return l.current===i?t:err(makeEverfurError("accessDenied"))};return{searchClinics:t=>e(()=>i.searchClinics(t)),recentClinics:t=>e(()=>i.recentClinics(t)),getRequestGroup:t=>e(()=>i.getRequestGroup(t)),getAuthorizationCopy:()=>e(()=>i.getAuthorizationCopy()),createClinicRequest:t=>e(()=>i.createClinicRequest(t)),retryRequest:t=>e(()=>i.retryRequest(t)),revokeRequest:t=>e(()=>i.revokeRequest(t)),updateClinicEmail:(t,r)=>e(()=>i.updateClinicEmail(t,r)),convertToUpload:t=>e(()=>i.convertToUpload(t)),initiateSignatureUpload:t=>e(()=>i.initiateSignatureUpload(t)),completeSignatureUpload:t=>e(()=>i.completeSignatureUpload(t))}},[i,userRef])}function useEverfurRecordsClinicBatch(){let{runtime:e,userRef:userRef,scopeEpoch:t}=Ir(),i=n(()=>{let{services:t}=e.registry;return createRecordsClinicBatchClient({auth:t.authFor(userRef),...t.errorPolicy?{errorPolicy:t.errorPolicy}:{}})},[e,userRef,t]),l=r(i);return o(()=>(l.current=i,()=>{l.current=null}),[i]),n(()=>({async createClinicRequestBatch(e){if(userRef===null||l.current!==i)return err(makeEverfurError("accessDenied"));let t=await i.createClinicRequestBatch(e);return l.current===i?t:err(makeEverfurError("accessDenied"))}}),[i,userRef])}var Wi=class extends c{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(e,t){return Object.is(e.resetKey,t.key)?null:{failed:false,key:e.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:e}){return e()}function HostRender({render:e,fallback:r,resetKey:n}){return t(Wi,{fallback:r,resetKey:n,children:t(RenderHost,{render:e})})}var Ui=/* @__PURE__ */Object.freeze({chat:/* @__PURE__ */Object.freeze(["chat.message.create"]),records:/* @__PURE__ */Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:/* @__PURE__ */Object.freeze(["records.clinic.create"]),video:/* @__PURE__ */Object.freeze(["video.gait.execute"]),photo:/* @__PURE__ */Object.freeze(["photo.checkup.execute"]),animations:/* @__PURE__ */Object.freeze(["animations.state.read"]),televet:/* @__PURE__ */Object.freeze(["televet.visit.create"]),texting:/* @__PURE__ */Object.freeze(["sms.identity.read","sms.identity.update"]),healthPlan:/* @__PURE__ */Object.freeze(["shop.plan.read","shop.plan.update"])});function requires(e){return Ui[e]}function decideCapability(e,t,r){let n=requires(e),i=/* @__PURE__ */new Map;for(let e of t)i.set(e.resource,e);if(r?.isPending===true&&n.some(e=>!i.has(e)))return Ki({name:e,enabled:false,isPending:true,limits:{}});let l=Gi(n,i);return n.filter(e=>i.get(e)?.granted!==true).length===0?Ki({name:e,enabled:true,isPending:false,limits:l}):Ki({name:e,enabled:false,isPending:false,limits:l,disabled:Vi(n,i)})}function Gi(e,t){let r={};for(let n of e){let e=t.get(n)?.limits;if(e)for(let[t,n]of Object.entries(e)){let e=r[t];r[t]=e===void 0?n:Math.min(e,n)}}return r}function Vi(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
23
23
  return Object.freeze({reason:e.reason,level:e.level,recoverable:e.recoverable})}/* @__PURE__ */
24
24
  return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function Ki(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:/* @__PURE__ */Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),/* @__PURE__ */Object.freeze(t)}function useCapability(e){let{runtime:t}=Ir(),r=t.entitlements,i=d(r.subscribe,r.getSnapshot,r.getSnapshot);return n(()=>decideCapability(e,i.decisions,{isPending:i.isPending}),[e,i])}var Yi=48;function Xi(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(e){let{capability:t,children:r,renderDisabled:i,renderPending:l,style:o}=e,a=useCapability(t),s=n(()=>Xi(a),[a]);switch(s){case"enabled":return r;case"pending":return l?/* @__PURE__ */B(HostRender,{render:l,fallback:/* @__PURE__ */B(PendingSkeleton,{capability:t,style:o})}):/* @__PURE__ */B(PendingSkeleton,{capability:t,style:o});case"disabled":return i?/* @__PURE__ */B(HostRender,{render:()=>i(a),fallback:/* @__PURE__ */B(OffState,{decision:a,style:o}),resetKey:a}):/* @__PURE__ */B(OffState,{decision:a,style:o});default:return assertNever(s)}}function PendingSkeleton({capability:e,style:t}){let r=useEverfurTheme(),i=n(()=>Qi(r),[r]);/* @__PURE__ */
25
25
  return B(f,{style:[i.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:/* @__PURE__ */B(f,{style:i.skeletonBar})})}function OffState({decision:e,style:t}){let r=useEverfurTheme(),i=n(()=>Qi(r),[r]),l=e.disabled?.reason??"";/* @__PURE__ */
@@ -86,7 +86,7 @@ return B(WifiOffGlyph,{size:t,color:r});default:return null}}function RecordsEmp
86
86
  return j(f,{style:l.container,accessibilityRole:"summary",testID:n,children:[
87
87
  /* @__PURE__ */B(f,{style:l.glyph,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",testID:"records-empty-glyph",children:/* @__PURE__ */B(RecordsEmptyGlyph,{variant:e,size:hl,color:a.color.brandInk})}),
88
88
  /* @__PURE__ */B(Text,{style:l.title,children:s.title}),
89
- /* @__PURE__ */B(Text,{style:l.body,children:r??s.body}),h!==null&&t?/* @__PURE__ */B(m,{onPress:t,disabled:u,accessibilityRole:"button",accessibilityLabel:u?ol:h,accessibilityState:{disabled:u},style:[l.action,u?l.actionDisabled:null],testID:n?`${n}-action`:`records-empty-${e}-action`,children:/* @__PURE__ */B(Text,{style:l.actionLabel,children:h})}):null]})}function ul(){let e=useEverfurTheme();return n(()=>gl(e),[e])}var hl=22,pl=48;function gl(e){let{color:t,space:r,radius:n,type:i,slots:l}=e;return v.create({container:{paddingVertical:r.xxl,paddingHorizontal:r.xl,alignItems:"center",gap:r.sm+r.xs/2},glyph:{width:pl,height:pl,alignItems:"center",justifyContent:"center",marginBottom:r.xs},title:{...headingFace(e,"bold"),fontSize:i.size.subtitle,lineHeight:Math.round(i.size.subtitle*i.lineHeight.snug)-1,color:t.brandInk,textAlign:"center"},body:{...face(e,"regular"),fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*i.lineHeight.normal),color:t.text.muted,textAlign:"center",maxWidth:320},action:{marginTop:r.sm,minHeight:r.xxl+r.sm,borderRadius:n.pill,paddingHorizontal:r.lg+r.xs/2,backgroundColor:t.brand,alignItems:"center",justifyContent:"center",...Bn(l.primaryButton)},actionDisabled:{opacity:.5},actionLabel:{...face(e,"bold"),color:t.onPrimary,fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*i.lineHeight.snug)-1,...jn(l.primaryButton)}})}var fl=/* @__PURE__ */Object.freeze({note:"Test account: clinics are never contacted. Use records test mode to move a request forward.",clinicNotContacted:"Clinic not contacted",notEmailed:e=>`This is a test account, so no email went to ${e}.`,newClinicDirectSendNote:"This is a test account, so this clinic will not be emailed."});var NO_SUBSCRIPTION=()=>()=>{};function ml(e){return e?.livemode===false}function bl(){try{return Ir().runtime.entitlements??null}catch{return null}}function yl(){let e=bl(),t=l(t=>e===null?NO_SUBSCRIPTION():e.subscribe(t),[e]),r=l(()=>e===null?false:ml(e.getSnapshot()),[e]);return d(t,r,r)}function vl(e){let[t,r]=i(null);return{shown:e!==null&&t!==e,onError:()=>r(e)}}function BrandLogo({logoUrl:e,name:t,barStyle:r,logoStyle:n,testID:i}){let l=vl(e);return e===null||!l.shown?null:/* @__PURE__ */B(f,{style:r,...i===void 0?{}:{testID:i},children:/* @__PURE__ */B(T,{source:{uri:e},style:n,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:l.onError})})}function parseColor(e){let t=wl(e);return t===null?null:Sl(t)}function wl(e){if(typeof e=="number")return Tl(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return kl(t.slice(1));if(t.toLowerCase().startsWith("0x"))return kl(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return xl(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=kl(t);if(e!==null)return e}return/^\d+$/.test(t)?Tl(Number.parseInt(t,10)):null}function kl(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:_l(t[0]),g:_l(t[1]),b:_l(t[2]),a:1};if(t.length===6)return{r:Cl(t,0),g:Cl(t,2),b:Cl(t,4),a:1};if(t.length===8){let e=Cl(t,0);return{r:Cl(t,2),g:Cl(t,4),b:Cl(t,6),a:e/255}}return null}function xl(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(e=>e.trim());if(n.length<3)return null;let i=Rl(Number(n[0])),l=Rl(Number(n[1])),o=Rl(Number(n[2]));if(i===null||l===null||o===null)return null;let a=1;if(n.length>=4){let e=Number(n[3]);if(!Number.isFinite(e))return null;a=Math.min(1,Math.max(0,e))}return{r:i,g:l,b:o,a:a}}function Tl(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return{r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}function Cl(e,t){return Number.parseInt(e.slice(t,t+2),16)}function _l(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function Rl(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function Sl(e){if(e.a>=1)return zl(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return`rgba(${e.r},${e.g},${e.b},${t})`}function zl(e,t,r){return`#${Il(e)}${Il(t)}${Il(r)}`.toUpperCase()}function Il(e){return e.toString(16).padStart(2,"0")}var Dl="#111111",Hl="#FFFFFF",Ll="#000000";function readableOn(e){let t=wl(e);if(t===null)return Hl;let r=$l(t),n=$l({r:17,g:17,b:17}),i=$l({r:255,g:255,b:255});return jl(r,i)>=jl(r,n)?Hl:Dl}function Pl(e,t){let r=readableOn(e);return contrastRatio(r,e)>=t?r:contrastRatio(Hl,e)>=contrastRatio(Ll,e)?Hl:Ll}function Ol(e){let t=t=>e.reduce((e,r)=>Math.min(e,contrastRatio(t,r)),Number.POSITIVE_INFINITY);return t(Hl)>=t(Ll)?Hl:Ll}function $l(e){let t=Bl(e.r/255),r=Bl(e.g/255),n=Bl(e.b/255);return.2126*t+.7152*r+.0722*n}function Bl(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function jl(e,t){let r=Math.max(e,t),n=Math.min(e,t);return(r+.05)/(n+.05)}function contrastRatio(e,t){let r=wl(e),n=wl(t);if(r===null||n===null)return 1;let i=n.a>=1?n:{...n},l=r.a>=1?r:Al(r,i);return jl($l(l),$l(i))}function Al(e,t){let r=e.a,n=(e,t)=>Math.round(e*r+t*(1-r));return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}function El(e,t){let r=wl(e),n=wl(t);if(r===null||n===null)return null;let i=r.a>=1?r:Al(r,{...n});return zl(i.r,i.g,i.b)}function Fl(e,t){let r=wl(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return`rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}var ql=.05;function Ml(e,t,r,n){let i=t[0];if(i===void 0)return r;let l=e=>t.every(t=>contrastRatio(e,t)>=n);if(wl(e)===null)return r;if(l(e))return e;let o=El(e,i),a=o===null?null:wl(o),s=wl(r);if(a===null||s===null)return r;for(let e=1;e<1/ql;e+=1){let t=e*ql,r=(e,r)=>Math.round(e+(r-e)*t),n=zl(r(a.r,s.r),r(a.g,s.g),r(a.b,s.b));if(l(n))return n}return r}var Nl=/* @__PURE__ */Object.freeze({ink:"#262523",ink2:"#4A4845",ink3:"#6B6863",paper:"#F8F7F4",card:"#FFFFFF",line:"#E7E6E2",tile:"#F2F1EE",shadow:"rgba(38, 37, 35, .07)",riskBg:"#FFE3E1",riskInk:"#B0231B",riskDot:"#E5372B",clearBg:"#E6F4D3",clearInk:"#2F6A12",clearDot:"#5FA82B",watchDot:"#E5A000"}),Wl=/* @__PURE__ */new WeakMap;function Ul(e){let t=Wl.get(e);if(t!==void 0)return t;let r=e.color,n=e.brightness==="dark",i=n?{dark:n,ink:r.text.primary,ink2:r.text.secondary,ink3:r.text.muted,paper:r.background,card:r.surface,line:r.borderRingCream,tile:r.surfaceSubtle,shadow:r.shadow,riskBg:r.badgeBgCritical,riskInk:r.danger,riskDot:r.danger,clearBg:r.badgeBgPositive,clearInk:r.success,clearDot:r.success,watchDot:r.warningStrong}:{dark:n,...Nl},l=(e,t)=>Ml(e,t,Ol(t),Gl),o=(e,t)=>contrastRatio(e,t)>=Gl?e:Pl(t,Gl),a=[i.card,i.paper].map(e=>El(r.brandSoft,e)??e),s={primary:r.primary,onPrimary:o(r.onPrimary,r.primary),accent:r.accent,onAccent:o(r.onAccent,r.accent),link:l(r.linkInk,[i.card,i.paper,i.tile]),badge:r.brandSoft,onBadge:l(r.brandInk,a)},d=/* @__PURE__ */Object.freeze({...i,...s});return Wl.set(e,d),d}var Gl=4.5;function Vl(e,t){for(let r of t)if(contrastRatio(r,e)>=Gl)return r;return Pl(e,Gl)}var Kl=/* @__PURE__ */Object.freeze({ink:"#10462E",go:"#07C168",muted:"#6B6B6B",line:"#E4E4E4",alert:"#C03410",alertDeep:"#6D1D14",tintSage:"#E6ECE8",tintBlue:"#EAEEF6",tintYellow:"#FCF0D6",tintRed:"#FBF1EE",tintGo:"#DCF6EA",icoSage:"#819E90",efWhite:"#FFFFFF",efBlack:"#000000",efCharcoal:"#3D3D3D",efSkyBlue:"#4E98C9",embCyan1:"#E0FDFF",bgMist:"#F1F5F2",paper:"#F8F7F4",embB1:"#FFCE34",embB2:"#5CC8F2",embB3:"#FF6665",embB4:"#A55BD8",embRiskDot:"#E5372B",embRiskInk:"#B0231B",embClearDot:"#5FA82B",embInk2:"#4A4845",embInk3:"#6B6863",embTealInk:"#00707C",embYellow:"#FFCE34",watch:"#F9E6B9",barTrack:"#ECECEC",topCard:"#FFCE34",topKicker:"#4A4845",topInk:"#262523",plainEdge:"rgba(16, 70, 46, 0.2)"}),Yl=/* @__PURE__ */Object.freeze({".rec-note":/* @__PURE__ */Object.freeze({fontSize:12.5}),".efh":/* @__PURE__ */Object.freeze({gap:12,fontSize:15}),".efh-sheet":/* @__PURE__ */Object.freeze({marginTop:20,paddingTop:20,paddingBottom:28,paddingLeft:16,borderTopLeftRadius:28}),".efh-ico":/* @__PURE__ */Object.freeze({width:22}),".efh-label":/* @__PURE__ */Object.freeze({fontSize:12}),".efh-pill":/* @__PURE__ */Object.freeze({minHeight:24,paddingLeft:10,fontSize:12,letterSpacing:.72}),".efh-card":/* @__PURE__ */Object.freeze({paddingTop:16,borderRadius:20}),".efh-card__title":/* @__PURE__ */Object.freeze({fontSize:18}),".efh-btn":/* @__PURE__ */Object.freeze({minHeight:48,paddingLeft:20,fontSize:16}),".efh-btn--row":/* @__PURE__ */Object.freeze({minHeight:40,paddingLeft:16,fontSize:15}),".efh-head":/* @__PURE__ */Object.freeze({marginBottom:8}),".efh-name":/* @__PURE__ */Object.freeze({fontSize:22}),".efh-meta":/* @__PURE__ */Object.freeze({fontSize:13}),".efh-stage":/* @__PURE__ */Object.freeze({height:236,marginTop:4,marginLeft:-16}),".efh-stage__grass":/* @__PURE__ */Object.freeze({height:"44%"}),".efh-stage__pet":/* @__PURE__ */Object.freeze({left:"58%",bottom:22,height:"86%"}),".efh-stage .efh-vitals":/* @__PURE__ */Object.freeze({top:14,left:16,gap:12}),".efh-head__from":/* @__PURE__ */Object.freeze({marginTop:12}),".efh-due":/* @__PURE__ */Object.freeze({marginLeft:-12}),".efh-due li":/* @__PURE__ */Object.freeze({gap:12,paddingTop:12,paddingLeft:12,borderRadius:10}),".efh-due__title":/* @__PURE__ */Object.freeze({fontSize:17,lineHeight:22.1}),".efh-sec":/* @__PURE__ */Object.freeze({marginTop:8,marginBottom:12}),".efh-tiles":/* @__PURE__ */Object.freeze({gap:10}),".efh-tile":/* @__PURE__ */Object.freeze({gap:8,paddingTop:16,borderRadius:20}),".efh-tile__title":/* @__PURE__ */Object.freeze({fontSize:15,lineHeight:18.75,letterSpacing:-.15}),".efh-tile__foot":/* @__PURE__ */Object.freeze({gap:8,minHeight:28}),".efh-tile__foot .efh-pill":/* @__PURE__ */Object.freeze({minHeight:22,paddingLeft:7,fontSize:10.5,letterSpacing:.21}),".efh-tile__foot:has(.efh-pill + .efh-pill)":/* @__PURE__ */Object.freeze({gap:6}),".efh-tile__num":/* @__PURE__ */Object.freeze({fontSize:20,lineHeight:20,letterSpacing:-.4}),".efh-wt":/* @__PURE__ */Object.freeze({gap:8}),".efh-wt b":/* @__PURE__ */Object.freeze({fontSize:32,lineHeight:32,letterSpacing:-.64}),".efh-emb":/* @__PURE__ */Object.freeze({gap:8,marginTop:12,fontSize:15,lineHeight:19.5}),".efh-wchart":/* @__PURE__ */Object.freeze({marginTop:20}),".efh-wchart__plot":/* @__PURE__ */Object.freeze({height:148}),".efh-wkey":/* @__PURE__ */Object.freeze({rowGap:4,columnGap:16,marginTop:12,fontSize:13,lineHeight:18.2}),".efh-wkey span":/* @__PURE__ */Object.freeze({gap:6}),".efh-key":/* @__PURE__ */Object.freeze({rowGap:8,columnGap:16,fontSize:13,lineHeight:18.2}),".efh-key span":/* @__PURE__ */Object.freeze({gap:6}),".efh-key span::before":/* @__PURE__ */Object.freeze({width:10}),".efh-tl__dot":/* @__PURE__ */Object.freeze({width:16,marginTop:3}),".efh-tl__year":/* @__PURE__ */Object.freeze({marginTop:20,marginBottom:12,marginLeft:40}),".efh-tl .efh-tl__year":/* @__PURE__ */Object.freeze({marginTop:4}),".efh-tl__item":/* @__PURE__ */Object.freeze({gap:16,paddingBottom:24}),".efh-tl__item::before":/* @__PURE__ */Object.freeze({left:11,top:22,bottom:-2}),".efh-tl__date":/* @__PURE__ */Object.freeze({fontSize:12,lineHeight:16.8,letterSpacing:.48}),".efh-tl__title":/* @__PURE__ */Object.freeze({marginTop:2,fontSize:17,lineHeight:22.1}),".efh-tl__text":/* @__PURE__ */Object.freeze({marginTop:2,lineHeight:22.5}),".efh-add":/* @__PURE__ */Object.freeze({gap:12}),".efh-add > p":/* @__PURE__ */Object.freeze({fontSize:15,lineHeight:22.5}),".efh-sheet .rec-note":/* @__PURE__ */Object.freeze({marginTop:4}),".efh-lab":/* @__PURE__ */Object.freeze({paddingTop:8,paddingBottom:96,paddingLeft:16}),".efh-titles":/* @__PURE__ */Object.freeze({gap:2,paddingTop:4}),".efh-title":/* @__PURE__ */Object.freeze({fontSize:22}),".efh-smeta":/* @__PURE__ */Object.freeze({fontSize:13}),".efh-mk__name":/* @__PURE__ */Object.freeze({fontSize:17}),".efh-mk__line":/* @__PURE__ */Object.freeze({rowGap:0,columnGap:6,marginTop:1,fontSize:13,lineHeight:18.2}),".efh-mk__line b":/* @__PURE__ */Object.freeze({fontSize:17}),".efh-none":/* @__PURE__ */Object.freeze({paddingTop:0}),".efh-none__scene":/* @__PURE__ */Object.freeze({marginBottom:16,marginLeft:-16}),".efh-none__t":/* @__PURE__ */Object.freeze({fontSize:22,lineHeight:25.3,letterSpacing:-.44}),".efh-none__lead":/* @__PURE__ */Object.freeze({marginTop:8,fontSize:15,lineHeight:22.5}),".efh-ways":/* @__PURE__ */Object.freeze({gap:12,marginTop:16}),".efh-way":/* @__PURE__ */Object.freeze({columnGap:12,paddingTop:16,borderRadius:20}),".efh-way__w":/* @__PURE__ */Object.freeze({gap:2}),".efh-way__t":/* @__PURE__ */Object.freeze({fontSize:16,lineHeight:20.8}),".efh-way__x":/* @__PURE__ */Object.freeze({fontSize:15,lineHeight:21.75}),".efh-peek__labs .efh-card__title":/* @__PURE__ */Object.freeze({marginBottom:8}),".efh-peek__g":/* @__PURE__ */Object.freeze({fontSize:15,lineHeight:21.75,marginBottom:6}),".efh-peek__g b":/* @__PURE__ */Object.freeze({fontSize:16}),".dot":/* @__PURE__ */Object.freeze({width:9}),".rec-top":/* @__PURE__ */Object.freeze({gap:8,paddingTop:16,paddingRight:18,paddingBottom:18,paddingLeft:18,borderRadius:22}),".rec-top__k":/* @__PURE__ */Object.freeze({gap:7,fontSize:10.5,letterSpacing:.63}),".rec-top .emb-btn":/* @__PURE__ */Object.freeze({marginTop:4}),".mixbar":/* @__PURE__ */Object.freeze({gap:2,height:10}),".mixlegend":/* @__PURE__ */Object.freeze({rowGap:6,columnGap:14,marginTop:12,fontSize:13.5}),".mixlegend li":/* @__PURE__ */Object.freeze({gap:7}),".mixlegend i":/* @__PURE__ */Object.freeze({width:9}),".mixlegend b":/* @__PURE__ */Object.freeze({fontSize:12}),".askbar":/* @__PURE__ */Object.freeze({gap:6,height:52,paddingRight:6,paddingLeft:8,borderWidth:1.5}),".askbar input":/* @__PURE__ */Object.freeze({fontSize:16}),".askbar__add":/* @__PURE__ */Object.freeze({width:38}),".askbar__add svg":/* @__PURE__ */Object.freeze({width:22}),".askbar__send":/* @__PURE__ */Object.freeze({width:40}),".askbar__send svg":/* @__PURE__ */Object.freeze({width:20}),".ph-head":/* @__PURE__ */Object.freeze({height:58,paddingLeft:14}),".ph-back":/* @__PURE__ */Object.freeze({width:44,marginLeft:-6}),".ph-back svg":/* @__PURE__ */Object.freeze({width:26}),".ph-title":/* @__PURE__ */Object.freeze({fontSize:17}),".emb-card":/* @__PURE__ */Object.freeze({borderRadius:22}),".emb-tile":/* @__PURE__ */Object.freeze({width:46,height:46,borderRadius:13}),".ask-pill":/* @__PURE__ */Object.freeze({right:16,bottom:16,gap:8,minHeight:48,paddingRight:18,paddingLeft:14,fontSize:15.5}),".ask-pill svg":/* @__PURE__ */Object.freeze({width:22}),".ph-askbar":/* @__PURE__ */Object.freeze({paddingTop:10,paddingRight:14,paddingBottom:10,paddingLeft:14}),".rec":/* @__PURE__ */Object.freeze({paddingTop:18,paddingLeft:16}),".rec-dna":/* @__PURE__ */Object.freeze({paddingTop:16,marginTop:16}),".rec-dna__top":/* @__PURE__ */Object.freeze({gap:12,marginBottom:14}),".rec-dna__top h3":/* @__PURE__ */Object.freeze({fontSize:17}),".rec-dna__top p":/* @__PURE__ */Object.freeze({fontSize:10.5,letterSpacing:.53,marginTop:2}),".rec-dna__risk":/* @__PURE__ */Object.freeze({gap:10,marginTop:14,paddingTop:12,paddingRight:12,paddingBottom:12,paddingLeft:14,borderRadius:14}),".rec-dna__risk small":/* @__PURE__ */Object.freeze({fontSize:13}),".rec-dna__risk strong":/* @__PURE__ */Object.freeze({marginTop:1,fontSize:16,lineHeight:20}),".rec-dna__clear":/* @__PURE__ */Object.freeze({gap:7,minHeight:36,marginTop:4,paddingLeft:4,fontSize:14}),".rec-dna__clear .dot":/* @__PURE__ */Object.freeze({width:7})}),Xl=/* @__PURE__ */Object.freeze({viewBox:[0,0,240,64],path:{x0:12,y0:60,cx:120,cy:-4,x1:228,y1:60},width:210,headX:.34,headTop:0,gap:2,fontSize:22,fontWeight:"500",beats:4,keyframes:[{offset:0,opacity:0},{offset:.025,opacity:1},{offset:.052,opacity:1},{offset:.077,opacity:0},{offset:1,opacity:0}],durationMs:44e3,easing:"ease-in-out",delayMs:1200,staggerMs:3600}),Ql=/* @__PURE__ */Object.freeze({height:212,grassHeight:64,petHeight:150,petBottom:16,petAspect:.731,grassSize:[1520,479],petSize:[307,420]});var Jl=Yl;function Zl(e,t){let r=Jl[e]?.[t];return typeof r=="number"?r:Number.NaN}var eo=Zl;function to(e,t){let r=Jl[e]?.[t];return typeof r=="string"&&r.endsWith("%")?Number(r.slice(0,-1))/100:Number.NaN}var ro=/* @__PURE__ */Object.freeze({gap:eo(".efh","gap"),sheetPadTop:eo(".efh-sheet","paddingTop"),sheetPadX:eo(".efh-sheet","paddingLeft"),sheetPadBottom:eo(".efh-sheet","paddingBottom"),sheetRadius:eo(".efh-sheet","borderTopLeftRadius"),sheetGap:eo(".efh-sheet","marginTop"),cardPad:eo(".efh-card","paddingTop"),cardRadius:eo(".efh-card","borderRadius"),name:eo(".efh-name","fontSize"),cardTitle:eo(".efh-card__title","fontSize"),rowTitle:eo(".efh-mk__name","fontSize"),body:eo(".efh","fontSize"),small:eo(".efh-meta","fontSize"),mono:eo(".efh-label","fontSize"),tileNum:eo(".efh-tile__num","fontSize"),big:eo(".efh-wt b","fontSize"),button:eo(".efh-btn","minHeight"),rowButton:eo(".efh-btn--row","minHeight"),pill:eo(".efh-pill","minHeight"),plot:eo(".efh-wchart__plot","height"),rowRadius:eo(".efh-due li","borderRadius"),tileGap:eo(".efh-tiles","gap"),icon:eo(".efh-ico","width")});function no(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function io(e,t,r){let n=Fl(e,r);return(n!==null?El(n,t):null)??t}var lo=(e,t)=>parseColor(e)===parseColor(t);function oo(e){if(e.brightness!=="light")return false;let t=e.color,r=zn.color;return lo(t.primary,r.primary)&&lo(t.brandInk,r.brandInk)&&lo(t.onPrimary,r.onPrimary)&&lo(t.accent,r.accent)&&lo(t.accentEdge,r.accentEdge)}function ao(e){let t=e.color,r=Kl,n=Ul(e),i=e.brightness==="dark",l=oo(e),o=(i?Dn:zn).color,a=!lo(t.accent,o.accent),s=i?t.surface:r.efWhite,d=(e,t)=>io(e,s,i?.18:t),c=l?r.tintSage:d(n.primary,.105),u=l?r.topCard:a?n.accent:c;return{tintSage:c,chevron:l?r.icoSage:io(t.brandInk,s,.527),rowGround:l?r.bgMist:d(n.primary,.059),tintPartner:a?d(n.accent,.14):r.embCyan1,topFill:u,plainEdge:l?r.plainEdge:Fl(t.brandInk,.2)??t.structureEdge,topKicker:Vl(u,[a?n.onAccent:i?n.ink3:r.topKicker,r.topInk]),topInk:Vl(u,[a?n.onAccent:i?n.ink:r.topInk,r.topInk])}}function recordsSheetLook(e){let t=e.color,r=Kl,n=Ul(e),i=ao(e),l=oo(e)?r.go:no(t.accent,t.primary)?t.onPrimary:t.accent;return e.brightness==="dark"?/* @__PURE__ */Object.freeze({dark:true,paper:n.paper,ground:t.background,card:n.card,text:n.ink,muted:n.ink3,line:t.structureEdge,ink:t.brandInk,fill:n.primary,onFill:n.onPrimary,accentOnFill:l,accent:n.accent,go:t.success,goTint:t.badgeBgPositive,alert:n.riskInk,alertDeep:n.riskInk,alertTint:t.badgeBgCritical,watch:t.badgeBgCaution,wind:r.efSkyBlue,tintBlue:t.surfaceSubtle,tintYellow:t.surfaceSubtle,barTrack:t.structureEdge,...i}):/* @__PURE__ */Object.freeze({dark:false,paper:n.paper,ground:r.efWhite,card:r.efWhite,text:r.efBlack,muted:r.muted,line:r.line,ink:t.brandInk,fill:n.primary,onFill:n.onPrimary,accentOnFill:l,accent:n.accent,go:r.go,goTint:r.tintGo,alert:r.alert,alertDeep:r.alertDeep,alertTint:r.tintRed,watch:r.watch,wind:r.efSkyBlue,tintBlue:r.tintBlue,tintYellow:r.tintYellow,barTrack:r.barTrack,...i})}function so(e){return oo(e)}function co(e){let t=(e.brightness==="dark"?Dn:zn).color;return!lo(e.color.accent,t.accent)}function uo(e){if(e===void 0)return null;let t=e.split(",")[0]?.trim().replace(/^["']|["']$/g,"").trim()??"";return t.length>0?t:null}function ho(e,t,r){let n=uo(r?.font),i=uo(r?.mono),l=t==="everfur"||t==="raph";if(!l&&n===null&&i===null)return e;let o=e.type,a={...o.families,...n!==null?{regular:n,medium:n,bold:n}:{},...i!==null?{mono:i,monoMedium:i,monoBold:i}:{}},s={...o.namedFaces,...n!==null?{regular:false,medium:false,bold:false}:{},...i!==null?{mono:false,monoMedium:false,monoBold:false}:{}};return{...e,...l?{brightness:"light",highContrast:false,color:zn.color}:{},type:{...o,families:a,namedFaces:s,family:a.regular,mono:a.mono}}}var po=createContext("sheet"),go=po.Provider;function fo(){return s(po)}function mo(e,t={}){return{padding:e.cardPad,gap:12,...t,...e.card}}function bo(e,t){let r={...e};for(let n of Object.keys(t)){let i=t[n];i!==void 0&&(r[n]={...e[n],...i})}return r}var yo=/* @__PURE__ */new WeakMap;function vo(e){let t=yo.get(e);if(t!==void 0)return t;let r=recordsSheetLook(e),n=An(e.slots),i=face(e,"bold"),l={...i,fontSize:16,lineHeight:20},o=/* @__PURE__ */Object.freeze({look:r,ground:r.ground,card:{backgroundColor:r.card,borderRadius:e.radius.lg,borderWidth:r.dark?1:0,borderColor:r.line,shadowColor:"#000000",shadowOpacity:r.dark?0:.09,shadowRadius:3,shadowOffset:{width:0,height:1},elevation:r.dark?0:1,...Bn(n,1)},cardPad:ro.cardPad,cardTitle:{...i,fontSize:ro.cardTitle,lineHeight:Math.round(ro.cardTitle*1.25*100)/100,letterSpacing:-.36,color:r.ink,...jn(n)},body:{...face(e,"regular"),fontSize:15,lineHeight:21,color:r.ink,...jn(n)},title:{...face(e,"medium"),fontSize:ro.name,lineHeight:Math.round(ro.name*1.2*100)/100,letterSpacing:-.33,color:r.ink},button:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,minHeight:ro.button,paddingHorizontal:20,borderRadius:999},buttonInk:{backgroundColor:r.fill,borderWidth:0,...Bn(e.slots.primaryButton)},buttonInkLabel:{...l,color:r.onFill,...jn(e.slots.primaryButton)},buttonOutline:{backgroundColor:"transparent",borderWidth:1.5,borderColor:r.ink},buttonOutlineLabel:{...l,color:r.ink},askPill:{backgroundColor:Kl.embYellow,borderWidth:0,paddingLeft:Zl(".ask-pill","paddingLeft"),paddingRight:Zl(".ask-pill","paddingRight")},askPillLabel:{...i,fontSize:Zl(".ask-pill","fontSize"),lineHeight:Zl(".ask-pill","fontSize")*1.2,color:Kl.topInk}});return yo.set(e,o),o}var wo=/* @__PURE__ */Object.freeze({pressScale:.97,pressMs:160,riseWebPx:16,riseNativePx:14,fadeMs:320,moveMs:480,staggerMs:55,maxSteps:8});var ko=e=>e.replace(/\s+/gu," ").trim().replace(/\.$/u,"").toLowerCase(),xo=ko(Yn);function To(e){let t=ko(e);return t.length===0||t===xo}function Co(e){let t=(e.brightness==="dark"?Dn:zn).color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t);return{success:!n(r.success,t.success),warning:!n(r.warningStrong,t.warningStrong)||!n(r.cautionAccent,t.cautionAccent),info:!(n(r.info,r.brandInk)&&n(r.badgeBgInfo,r.brandSoft)&&n(r.infoEdge,r.structureEdge))}}var _o=4.5;function Ro(e){if(!Co(e).success)return null;let t=[e.color.surface];return Ml(e.color.success,t,Ol(t),_o)}var So=52,zo="rgba(0,0,0,0.4)";function Io(){let e=useEverfurTheme(),t=Do();return n(()=>Lo(e,t),[e,t])}function Do(){let e=useEverfurTheme();return fo()==="sheet"?vo(e):null}function DisclaimerBand({disclaimer:e,style:t}){let r=Io();return To(e)?null:/* @__PURE__ */j(f,{style:[r.band,t],accessible:true,accessibilityRole:"text",accessibilityLabel:Jn.important(e),testID:"records-disclaimer-band",children:[
89
+ /* @__PURE__ */B(Text,{style:l.body,children:r??s.body}),h!==null&&t?/* @__PURE__ */B(m,{onPress:t,disabled:u,accessibilityRole:"button",accessibilityLabel:u?ol:h,accessibilityState:{disabled:u},style:[l.action,u?l.actionDisabled:null],testID:n?`${n}-action`:`records-empty-${e}-action`,children:/* @__PURE__ */B(Text,{style:l.actionLabel,children:h})}):null]})}function ul(){let e=useEverfurTheme();return n(()=>gl(e),[e])}var hl=22,pl=48;function gl(e){let{color:t,space:r,radius:n,type:i,slots:l}=e;return v.create({container:{paddingVertical:r.xxl,paddingHorizontal:r.xl,alignItems:"center",gap:r.sm+r.xs/2},glyph:{width:pl,height:pl,alignItems:"center",justifyContent:"center",marginBottom:r.xs},title:{...headingFace(e,"bold"),fontSize:i.size.subtitle,lineHeight:Math.round(i.size.subtitle*i.lineHeight.snug)-1,color:t.brandInk,textAlign:"center"},body:{...face(e,"regular"),fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*i.lineHeight.normal),color:t.text.muted,textAlign:"center",maxWidth:320},action:{marginTop:r.sm,minHeight:r.xxl+r.sm,borderRadius:n.pill,paddingHorizontal:r.lg+r.xs/2,backgroundColor:t.brand,alignItems:"center",justifyContent:"center",...Bn(l.primaryButton)},actionDisabled:{opacity:.5},actionLabel:{...face(e,"bold"),color:t.onPrimary,fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*i.lineHeight.snug)-1,...jn(l.primaryButton)}})}var fl=/* @__PURE__ */Object.freeze({note:"Test account: clinics are never contacted. Use records test mode to move a request forward.",clinicNotContacted:"Clinic not contacted",notEmailed:e=>`This is a test account, so no email went to ${e}.`,newClinicDirectSendNote:"This is a test account, so this clinic will not be emailed."});var NO_SUBSCRIPTION=()=>()=>{};function ml(e){return e?.livemode===false}function bl(){try{return Ir().runtime.entitlements??null}catch{return null}}function yl(){let e=bl(),t=l(t=>e===null?NO_SUBSCRIPTION():e.subscribe(t),[e]),r=l(()=>e===null?false:ml(e.getSnapshot()),[e]);return d(t,r,r)}function vl(e){let[t,r]=i(null);return{shown:e!==null&&t!==e,onError:()=>r(e)}}function BrandLogo({logoUrl:e,name:t,barStyle:r,logoStyle:n,testID:i}){let l=vl(e);return e===null||!l.shown?null:/* @__PURE__ */B(f,{style:r,...i===void 0?{}:{testID:i},children:/* @__PURE__ */B(T,{source:{uri:e},style:n,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:l.onError})})}function parseColor(e){let t=wl(e);return t===null?null:Sl(t)}function wl(e){if(typeof e=="number")return Tl(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return kl(t.slice(1));if(t.toLowerCase().startsWith("0x"))return kl(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return xl(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=kl(t);if(e!==null)return e}return/^\d+$/.test(t)?Tl(Number.parseInt(t,10)):null}function kl(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:Cl(t[0]),g:Cl(t[1]),b:Cl(t[2]),a:1};if(t.length===6)return{r:_l(t,0),g:_l(t,2),b:_l(t,4),a:1};if(t.length===8){let e=_l(t,0);return{r:_l(t,2),g:_l(t,4),b:_l(t,6),a:e/255}}return null}function xl(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(e=>e.trim());if(n.length<3)return null;let i=Rl(Number(n[0])),l=Rl(Number(n[1])),o=Rl(Number(n[2]));if(i===null||l===null||o===null)return null;let a=1;if(n.length>=4){let e=Number(n[3]);if(!Number.isFinite(e))return null;a=Math.min(1,Math.max(0,e))}return{r:i,g:l,b:o,a:a}}function Tl(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return{r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}function _l(e,t){return Number.parseInt(e.slice(t,t+2),16)}function Cl(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function Rl(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function Sl(e){if(e.a>=1)return zl(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return`rgba(${e.r},${e.g},${e.b},${t})`}function zl(e,t,r){return`#${Il(e)}${Il(t)}${Il(r)}`.toUpperCase()}function Il(e){return e.toString(16).padStart(2,"0")}var Dl="#111111",Hl="#FFFFFF",Ll="#000000";function readableOn(e){let t=wl(e);if(t===null)return Hl;let r=$l(t),n=$l({r:17,g:17,b:17}),i=$l({r:255,g:255,b:255});return jl(r,i)>=jl(r,n)?Hl:Dl}function Pl(e,t){let r=readableOn(e);return contrastRatio(r,e)>=t?r:contrastRatio(Hl,e)>=contrastRatio(Ll,e)?Hl:Ll}function Ol(e){let t=t=>e.reduce((e,r)=>Math.min(e,contrastRatio(t,r)),Number.POSITIVE_INFINITY);return t(Hl)>=t(Ll)?Hl:Ll}function $l(e){let t=Bl(e.r/255),r=Bl(e.g/255),n=Bl(e.b/255);return.2126*t+.7152*r+.0722*n}function Bl(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function jl(e,t){let r=Math.max(e,t),n=Math.min(e,t);return(r+.05)/(n+.05)}function contrastRatio(e,t){let r=wl(e),n=wl(t);if(r===null||n===null)return 1;let i=n.a>=1?n:{...n},l=r.a>=1?r:Al(r,i);return jl($l(l),$l(i))}function Al(e,t){let r=e.a,n=(e,t)=>Math.round(e*r+t*(1-r));return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}function El(e,t){let r=wl(e),n=wl(t);if(r===null||n===null)return null;let i=r.a>=1?r:Al(r,{...n});return zl(i.r,i.g,i.b)}function Fl(e,t){let r=wl(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return`rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}var ql=.05;function Ml(e,t,r,n){let i=t[0];if(i===void 0)return r;let l=e=>t.every(t=>contrastRatio(e,t)>=n);if(wl(e)===null)return r;if(l(e))return e;let o=El(e,i),a=o===null?null:wl(o),s=wl(r);if(a===null||s===null)return r;for(let e=1;e<1/ql;e+=1){let t=e*ql,r=(e,r)=>Math.round(e+(r-e)*t),n=zl(r(a.r,s.r),r(a.g,s.g),r(a.b,s.b));if(l(n))return n}return r}var Nl=/* @__PURE__ */Object.freeze({ink:"#262523",ink2:"#4A4845",ink3:"#6B6863",paper:"#F8F7F4",card:"#FFFFFF",line:"#E7E6E2",tile:"#F2F1EE",shadow:"rgba(38, 37, 35, .07)",riskBg:"#FFE3E1",riskInk:"#B0231B",riskDot:"#E5372B",clearBg:"#E6F4D3",clearInk:"#2F6A12",clearDot:"#5FA82B",watchDot:"#E5A000"}),Wl=/* @__PURE__ */new WeakMap;function Ul(e){let t=Wl.get(e);if(t!==void 0)return t;let r=e.color,n=e.brightness==="dark",i=n?{dark:n,ink:r.text.primary,ink2:r.text.secondary,ink3:r.text.muted,paper:r.background,card:r.surface,line:r.borderRingCream,tile:r.surfaceSubtle,shadow:r.shadow,riskBg:r.badgeBgCritical,riskInk:r.danger,riskDot:r.danger,clearBg:r.badgeBgPositive,clearInk:r.success,clearDot:r.success,watchDot:r.warningStrong}:{dark:n,...Nl},l=(e,t)=>Ml(e,t,Ol(t),Gl),o=(e,t)=>contrastRatio(e,t)>=Gl?e:Pl(t,Gl),a=[i.card,i.paper].map(e=>El(r.brandSoft,e)??e),s={primary:r.primary,onPrimary:o(r.onPrimary,r.primary),accent:r.accent,onAccent:o(r.onAccent,r.accent),link:l(r.linkInk,[i.card,i.paper,i.tile]),badge:r.brandSoft,onBadge:l(r.brandInk,a)},d=/* @__PURE__ */Object.freeze({...i,...s});return Wl.set(e,d),d}var Gl=4.5;function Vl(e,t){for(let r of t)if(contrastRatio(r,e)>=Gl)return r;return Pl(e,Gl)}var Kl=/* @__PURE__ */Object.freeze({ink:"#10462E",go:"#07C168",muted:"#6B6B6B",line:"#E4E4E4",alert:"#C03410",alertDeep:"#6D1D14",tintSage:"#E6ECE8",tintBlue:"#EAEEF6",tintYellow:"#FCF0D6",tintRed:"#FBF1EE",tintGo:"#DCF6EA",icoSage:"#819E90",efWhite:"#FFFFFF",efBlack:"#000000",efCharcoal:"#3D3D3D",efSkyBlue:"#4E98C9",embCyan1:"#E0FDFF",bgMist:"#F1F5F2",paper:"#F8F7F4",embB1:"#FFCE34",embB2:"#5CC8F2",embB3:"#FF6665",embB4:"#A55BD8",embRiskDot:"#E5372B",embRiskInk:"#B0231B",embClearDot:"#5FA82B",embInk2:"#4A4845",embInk3:"#6B6863",embTealInk:"#00707C",embYellow:"#FFCE34",watch:"#F9E6B9",barTrack:"#ECECEC",topCard:"#FFCE34",topKicker:"#4A4845",topInk:"#262523",plainEdge:"rgba(16, 70, 46, 0.2)"}),Yl=/* @__PURE__ */Object.freeze({".rec-note":/* @__PURE__ */Object.freeze({fontSize:12.5}),".efh":/* @__PURE__ */Object.freeze({gap:12,fontSize:15}),".efh-sheet":/* @__PURE__ */Object.freeze({marginTop:20,paddingTop:20,paddingBottom:28,paddingLeft:16,borderTopLeftRadius:28}),".efh-ico":/* @__PURE__ */Object.freeze({width:22}),".efh-label":/* @__PURE__ */Object.freeze({fontSize:12}),".efh-pill":/* @__PURE__ */Object.freeze({minHeight:24,paddingLeft:10,fontSize:12,letterSpacing:.72}),".efh-card":/* @__PURE__ */Object.freeze({paddingTop:16,borderRadius:20}),".efh-card__title":/* @__PURE__ */Object.freeze({fontSize:18}),".efh-btn":/* @__PURE__ */Object.freeze({minHeight:48,paddingLeft:20,fontSize:16}),".efh-btn--row":/* @__PURE__ */Object.freeze({minHeight:40,paddingLeft:16,fontSize:15}),".efh-head":/* @__PURE__ */Object.freeze({marginBottom:8}),".efh-name":/* @__PURE__ */Object.freeze({fontSize:22}),".efh-meta":/* @__PURE__ */Object.freeze({fontSize:13}),".efh-stage":/* @__PURE__ */Object.freeze({height:236,marginTop:4,marginLeft:-16}),".efh-stage__grass":/* @__PURE__ */Object.freeze({height:"44%"}),".efh-stage__pet":/* @__PURE__ */Object.freeze({left:"58%",bottom:22,height:"86%"}),".efh-stage .efh-vitals":/* @__PURE__ */Object.freeze({top:14,left:16,gap:12}),".efh-head__from":/* @__PURE__ */Object.freeze({marginTop:12}),".efh-due":/* @__PURE__ */Object.freeze({marginLeft:-12}),".efh-due li":/* @__PURE__ */Object.freeze({gap:12,paddingTop:12,paddingLeft:12,borderRadius:10}),".efh-due__title":/* @__PURE__ */Object.freeze({fontSize:17,lineHeight:22.1}),".efh-sec":/* @__PURE__ */Object.freeze({marginTop:8,marginBottom:12}),".efh-tiles":/* @__PURE__ */Object.freeze({gap:10}),".efh-tile":/* @__PURE__ */Object.freeze({gap:8,paddingTop:16,borderRadius:20}),".efh-tile__title":/* @__PURE__ */Object.freeze({fontSize:15,lineHeight:18.75,letterSpacing:-.15}),".efh-tile__foot":/* @__PURE__ */Object.freeze({gap:8,minHeight:28}),".efh-tile__foot .efh-pill":/* @__PURE__ */Object.freeze({minHeight:22,paddingLeft:7,fontSize:10.5,letterSpacing:.21}),".efh-tile__foot:has(.efh-pill + .efh-pill)":/* @__PURE__ */Object.freeze({gap:6}),".efh-tile__num":/* @__PURE__ */Object.freeze({fontSize:20,lineHeight:20,letterSpacing:-.4}),".efh-wt":/* @__PURE__ */Object.freeze({gap:8}),".efh-wt b":/* @__PURE__ */Object.freeze({fontSize:32,lineHeight:32,letterSpacing:-.64}),".efh-emb":/* @__PURE__ */Object.freeze({gap:8,marginTop:12,fontSize:15,lineHeight:19.5}),".efh-wchart":/* @__PURE__ */Object.freeze({marginTop:20}),".efh-wchart__plot":/* @__PURE__ */Object.freeze({height:148}),".efh-wkey":/* @__PURE__ */Object.freeze({rowGap:4,columnGap:16,marginTop:12,fontSize:13,lineHeight:18.2}),".efh-wkey span":/* @__PURE__ */Object.freeze({gap:6}),".efh-key":/* @__PURE__ */Object.freeze({rowGap:8,columnGap:16,fontSize:13,lineHeight:18.2}),".efh-key span":/* @__PURE__ */Object.freeze({gap:6}),".efh-key span::before":/* @__PURE__ */Object.freeze({width:10}),".efh-tl__dot":/* @__PURE__ */Object.freeze({width:16,marginTop:3}),".efh-tl__year":/* @__PURE__ */Object.freeze({marginTop:20,marginBottom:12,marginLeft:40}),".efh-tl .efh-tl__year":/* @__PURE__ */Object.freeze({marginTop:4}),".efh-tl__item":/* @__PURE__ */Object.freeze({gap:16,paddingBottom:24}),".efh-tl__item::before":/* @__PURE__ */Object.freeze({left:11,top:22,bottom:-2}),".efh-tl__date":/* @__PURE__ */Object.freeze({fontSize:12,lineHeight:16.8,letterSpacing:.48}),".efh-tl__title":/* @__PURE__ */Object.freeze({marginTop:2,fontSize:17,lineHeight:22.1}),".efh-tl__text":/* @__PURE__ */Object.freeze({marginTop:2,lineHeight:22.5}),".efh-add":/* @__PURE__ */Object.freeze({gap:12}),".efh-add > p":/* @__PURE__ */Object.freeze({fontSize:15,lineHeight:22.5}),".efh-sheet .rec-note":/* @__PURE__ */Object.freeze({marginTop:4}),".efh-lab":/* @__PURE__ */Object.freeze({paddingTop:8,paddingBottom:96,paddingLeft:16}),".efh-titles":/* @__PURE__ */Object.freeze({gap:2,paddingTop:4}),".efh-title":/* @__PURE__ */Object.freeze({fontSize:22}),".efh-smeta":/* @__PURE__ */Object.freeze({fontSize:13}),".efh-mk__name":/* @__PURE__ */Object.freeze({fontSize:17}),".efh-mk__line":/* @__PURE__ */Object.freeze({rowGap:0,columnGap:6,marginTop:1,fontSize:13,lineHeight:18.2}),".efh-mk__line b":/* @__PURE__ */Object.freeze({fontSize:17}),".efh-none":/* @__PURE__ */Object.freeze({paddingTop:0}),".efh-none__scene":/* @__PURE__ */Object.freeze({marginBottom:16,marginLeft:-16}),".efh-none__t":/* @__PURE__ */Object.freeze({fontSize:22,lineHeight:25.3,letterSpacing:-.44}),".efh-none__lead":/* @__PURE__ */Object.freeze({marginTop:8,fontSize:15,lineHeight:22.5}),".efh-ways":/* @__PURE__ */Object.freeze({gap:12,marginTop:16}),".efh-way":/* @__PURE__ */Object.freeze({columnGap:12,paddingTop:16,borderRadius:20}),".efh-way__w":/* @__PURE__ */Object.freeze({gap:2}),".efh-way__t":/* @__PURE__ */Object.freeze({fontSize:16,lineHeight:20.8}),".efh-way__x":/* @__PURE__ */Object.freeze({fontSize:15,lineHeight:21.75}),".efh-peek__labs .efh-card__title":/* @__PURE__ */Object.freeze({marginBottom:8}),".efh-peek__g":/* @__PURE__ */Object.freeze({fontSize:15,lineHeight:21.75,marginBottom:6}),".efh-peek__g b":/* @__PURE__ */Object.freeze({fontSize:16}),".dot":/* @__PURE__ */Object.freeze({width:9}),".rec-top":/* @__PURE__ */Object.freeze({gap:8,paddingTop:16,paddingRight:18,paddingBottom:18,paddingLeft:18,borderRadius:22}),".rec-top__k":/* @__PURE__ */Object.freeze({gap:7,fontSize:10.5,letterSpacing:.63}),".rec-top .emb-btn":/* @__PURE__ */Object.freeze({marginTop:4}),".mixbar":/* @__PURE__ */Object.freeze({gap:2,height:10}),".mixlegend":/* @__PURE__ */Object.freeze({rowGap:6,columnGap:14,marginTop:12,fontSize:13.5}),".mixlegend li":/* @__PURE__ */Object.freeze({gap:7}),".mixlegend i":/* @__PURE__ */Object.freeze({width:9}),".mixlegend b":/* @__PURE__ */Object.freeze({fontSize:12}),".askbar":/* @__PURE__ */Object.freeze({gap:6,height:52,paddingRight:6,paddingLeft:8,borderWidth:1.5}),".askbar input":/* @__PURE__ */Object.freeze({fontSize:16}),".askbar__add":/* @__PURE__ */Object.freeze({width:38}),".askbar__add svg":/* @__PURE__ */Object.freeze({width:22}),".askbar__send":/* @__PURE__ */Object.freeze({width:40}),".askbar__send svg":/* @__PURE__ */Object.freeze({width:20}),".ph-head":/* @__PURE__ */Object.freeze({height:58,paddingLeft:14}),".ph-back":/* @__PURE__ */Object.freeze({width:44,marginLeft:-6}),".ph-back svg":/* @__PURE__ */Object.freeze({width:26}),".ph-title":/* @__PURE__ */Object.freeze({fontSize:17}),".emb-card":/* @__PURE__ */Object.freeze({borderRadius:22}),".emb-tile":/* @__PURE__ */Object.freeze({width:46,height:46,borderRadius:13}),".ask-pill":/* @__PURE__ */Object.freeze({right:16,bottom:16,gap:8,minHeight:48,paddingRight:18,paddingLeft:14,fontSize:15.5}),".ask-pill svg":/* @__PURE__ */Object.freeze({width:22}),".ph-askbar":/* @__PURE__ */Object.freeze({paddingTop:10,paddingRight:14,paddingBottom:10,paddingLeft:14}),".rec":/* @__PURE__ */Object.freeze({paddingTop:18,paddingLeft:16}),".rec-dna":/* @__PURE__ */Object.freeze({paddingTop:16,marginTop:16}),".rec-dna__top":/* @__PURE__ */Object.freeze({gap:12,marginBottom:14}),".rec-dna__top h3":/* @__PURE__ */Object.freeze({fontSize:17}),".rec-dna__top p":/* @__PURE__ */Object.freeze({fontSize:10.5,letterSpacing:.53,marginTop:2}),".rec-dna__risk":/* @__PURE__ */Object.freeze({gap:10,marginTop:14,paddingTop:12,paddingRight:12,paddingBottom:12,paddingLeft:14,borderRadius:14}),".rec-dna__risk small":/* @__PURE__ */Object.freeze({fontSize:13}),".rec-dna__risk strong":/* @__PURE__ */Object.freeze({marginTop:1,fontSize:16,lineHeight:20}),".rec-dna__clear":/* @__PURE__ */Object.freeze({gap:7,minHeight:36,marginTop:4,paddingLeft:4,fontSize:14}),".rec-dna__clear .dot":/* @__PURE__ */Object.freeze({width:7})}),Xl=/* @__PURE__ */Object.freeze({viewBox:[0,0,240,64],path:{x0:12,y0:60,cx:120,cy:-4,x1:228,y1:60},width:210,headX:.34,headTop:0,gap:2,fontSize:22,fontWeight:"500",beats:4,keyframes:[{offset:0,opacity:0},{offset:.025,opacity:1},{offset:.052,opacity:1},{offset:.077,opacity:0},{offset:1,opacity:0}],durationMs:44e3,easing:"ease-in-out",delayMs:1200,staggerMs:3600}),Ql=/* @__PURE__ */Object.freeze({height:212,grassHeight:64,petHeight:150,petBottom:16,petAspect:.731,grassSize:[1520,479],petSize:[307,420]});var Jl=Yl;function Zl(e,t){let r=Jl[e]?.[t];return typeof r=="number"?r:Number.NaN}var eo=Zl;function to(e,t){let r=Jl[e]?.[t];return typeof r=="string"&&r.endsWith("%")?Number(r.slice(0,-1))/100:Number.NaN}var ro=/* @__PURE__ */Object.freeze({gap:eo(".efh","gap"),sheetPadTop:eo(".efh-sheet","paddingTop"),sheetPadX:eo(".efh-sheet","paddingLeft"),sheetPadBottom:eo(".efh-sheet","paddingBottom"),sheetRadius:eo(".efh-sheet","borderTopLeftRadius"),sheetGap:eo(".efh-sheet","marginTop"),cardPad:eo(".efh-card","paddingTop"),cardRadius:eo(".efh-card","borderRadius"),name:eo(".efh-name","fontSize"),cardTitle:eo(".efh-card__title","fontSize"),rowTitle:eo(".efh-mk__name","fontSize"),body:eo(".efh","fontSize"),small:eo(".efh-meta","fontSize"),mono:eo(".efh-label","fontSize"),tileNum:eo(".efh-tile__num","fontSize"),big:eo(".efh-wt b","fontSize"),button:eo(".efh-btn","minHeight"),rowButton:eo(".efh-btn--row","minHeight"),pill:eo(".efh-pill","minHeight"),plot:eo(".efh-wchart__plot","height"),rowRadius:eo(".efh-due li","borderRadius"),tileGap:eo(".efh-tiles","gap"),icon:eo(".efh-ico","width")});function no(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function io(e,t,r){let n=Fl(e,r);return(n!==null?El(n,t):null)??t}var lo=(e,t)=>parseColor(e)===parseColor(t);function oo(e){if(e.brightness!=="light")return false;let t=e.color,r=zn.color;return lo(t.primary,r.primary)&&lo(t.brandInk,r.brandInk)&&lo(t.onPrimary,r.onPrimary)&&lo(t.accent,r.accent)&&lo(t.accentEdge,r.accentEdge)}function ao(e){let t=e.color,r=Kl,n=Ul(e),i=e.brightness==="dark",l=oo(e),o=(i?Dn:zn).color,a=!lo(t.accent,o.accent),s=i?t.surface:r.efWhite,d=(e,t)=>io(e,s,i?.18:t),c=l?r.tintSage:d(n.primary,.105),u=l?r.topCard:a?n.accent:c;return{tintSage:c,chevron:l?r.icoSage:io(t.brandInk,s,.527),rowGround:l?r.bgMist:d(n.primary,.059),tintPartner:a?d(n.accent,.14):r.embCyan1,topFill:u,plainEdge:l?r.plainEdge:Fl(t.brandInk,.2)??t.structureEdge,topKicker:Vl(u,[a?n.onAccent:i?n.ink3:r.topKicker,r.topInk]),topInk:Vl(u,[a?n.onAccent:i?n.ink:r.topInk,r.topInk])}}function recordsSheetLook(e){let t=e.color,r=Kl,n=Ul(e),i=ao(e),l=oo(e)?r.go:no(t.accent,t.primary)?t.onPrimary:t.accent;return e.brightness==="dark"?/* @__PURE__ */Object.freeze({dark:true,paper:n.paper,ground:t.background,card:n.card,text:n.ink,muted:n.ink3,line:t.structureEdge,ink:t.brandInk,fill:n.primary,onFill:n.onPrimary,accentOnFill:l,accent:n.accent,go:t.success,goTint:t.badgeBgPositive,alert:n.riskInk,alertDeep:n.riskInk,alertTint:t.badgeBgCritical,watch:t.badgeBgCaution,wind:r.efSkyBlue,tintBlue:t.surfaceSubtle,tintYellow:t.surfaceSubtle,barTrack:t.structureEdge,...i}):/* @__PURE__ */Object.freeze({dark:false,paper:n.paper,ground:r.efWhite,card:r.efWhite,text:r.efBlack,muted:r.muted,line:r.line,ink:t.brandInk,fill:n.primary,onFill:n.onPrimary,accentOnFill:l,accent:n.accent,go:r.go,goTint:r.tintGo,alert:r.alert,alertDeep:r.alertDeep,alertTint:r.tintRed,watch:r.watch,wind:r.efSkyBlue,tintBlue:r.tintBlue,tintYellow:r.tintYellow,barTrack:r.barTrack,...i})}function so(e){return oo(e)}function co(e){let t=(e.brightness==="dark"?Dn:zn).color;return!lo(e.color.accent,t.accent)}function uo(e){if(e===void 0)return null;let t=e.split(",")[0]?.trim().replace(/^["']|["']$/g,"").trim()??"";return t.length>0?t:null}function ho(e,t,r){let n=uo(r?.font),i=uo(r?.mono),l=t==="everfur"||t==="raph";if(!l&&n===null&&i===null)return e;let o=e.type,a={...o.families,...n!==null?{regular:n,medium:n,bold:n}:{},...i!==null?{mono:i,monoMedium:i,monoBold:i}:{}},s={...o.namedFaces,...n!==null?{regular:false,medium:false,bold:false}:{},...i!==null?{mono:false,monoMedium:false,monoBold:false}:{}};return{...e,...l?{brightness:"light",highContrast:false,color:zn.color}:{},type:{...o,families:a,namedFaces:s,family:a.regular,mono:a.mono}}}var po=createContext("sheet"),go=po.Provider;function fo(){return s(po)}function mo(e,t={}){return{padding:e.cardPad,gap:12,...t,...e.card}}function bo(e,t){let r={...e};for(let n of Object.keys(t)){let i=t[n];i!==void 0&&(r[n]={...e[n],...i})}return r}var yo=/* @__PURE__ */new WeakMap;function vo(e){let t=yo.get(e);if(t!==void 0)return t;let r=recordsSheetLook(e),n=An(e.slots),i=face(e,"bold"),l={...i,fontSize:16,lineHeight:20},o=/* @__PURE__ */Object.freeze({look:r,ground:r.ground,card:{backgroundColor:r.card,borderRadius:e.radius.lg,borderWidth:r.dark?1:0,borderColor:r.line,shadowColor:"#000000",shadowOpacity:r.dark?0:.09,shadowRadius:3,shadowOffset:{width:0,height:1},elevation:r.dark?0:1,...Bn(n,1)},cardPad:ro.cardPad,cardTitle:{...i,fontSize:ro.cardTitle,lineHeight:Math.round(ro.cardTitle*1.25*100)/100,letterSpacing:-.36,color:r.ink,...jn(n)},body:{...face(e,"regular"),fontSize:15,lineHeight:21,color:r.ink,...jn(n)},title:{...face(e,"medium"),fontSize:ro.name,lineHeight:Math.round(ro.name*1.2*100)/100,letterSpacing:-.33,color:r.ink},button:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,minHeight:ro.button,paddingHorizontal:20,borderRadius:999},buttonInk:{backgroundColor:r.fill,borderWidth:0,...Bn(e.slots.primaryButton)},buttonInkLabel:{...l,color:r.onFill,...jn(e.slots.primaryButton)},buttonOutline:{backgroundColor:"transparent",borderWidth:1.5,borderColor:r.ink},buttonOutlineLabel:{...l,color:r.ink},askPill:{backgroundColor:Kl.embYellow,borderWidth:0,paddingLeft:Zl(".ask-pill","paddingLeft"),paddingRight:Zl(".ask-pill","paddingRight")},askPillLabel:{...i,fontSize:Zl(".ask-pill","fontSize"),lineHeight:Zl(".ask-pill","fontSize")*1.2,color:Kl.topInk}});return yo.set(e,o),o}var wo=/* @__PURE__ */Object.freeze({pressScale:.97,pressMs:160,riseWebPx:16,riseNativePx:14,fadeMs:320,moveMs:480,staggerMs:55,maxSteps:8});var ko=e=>e.replace(/\s+/gu," ").trim().replace(/\.$/u,"").toLowerCase(),xo=ko(Yn);function To(e){let t=ko(e);return t.length===0||t===xo}function _o(e){let t=(e.brightness==="dark"?Dn:zn).color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t);return{success:!n(r.success,t.success),warning:!n(r.warningStrong,t.warningStrong)||!n(r.cautionAccent,t.cautionAccent),info:!(n(r.info,r.brandInk)&&n(r.badgeBgInfo,r.brandSoft)&&n(r.infoEdge,r.structureEdge))}}var Co=4.5;function Ro(e){if(!_o(e).success)return null;let t=[e.color.surface];return Ml(e.color.success,t,Ol(t),Co)}var So=52,zo="rgba(0,0,0,0.4)";function Io(){let e=useEverfurTheme(),t=Do();return n(()=>Lo(e,t),[e,t])}function Do(){let e=useEverfurTheme();return fo()==="sheet"?vo(e):null}function DisclaimerBand({disclaimer:e,style:t}){let r=Io();return To(e)?null:/* @__PURE__ */j(f,{style:[r.band,t],accessible:true,accessibilityRole:"text",accessibilityLabel:Jn.important(e),testID:"records-disclaimer-band",children:[
90
90
  /* @__PURE__ */B(f,{style:r.infoGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:/* @__PURE__ */B(Text,{style:r.infoGlyphText,children:"i"})}),
91
91
  /* @__PURE__ */B(Text,{style:r.bandText,children:e})]})}function Pill({label:e,onPress:t,kind:r="primary",disabled:n=false,busy:i=false,accessibilityLabel:l,accessibilityHint:o,testID:a,style:s}){let d=Io(),c=useEverfurTheme(),u=c.motion.reducedMotion,h=r==="primary"?d.pillPrimary:r==="outline"?d.pillOutline:r==="danger"?d.pillDanger:r==="ask"?d.pillAsk:d.pillLink,p=r==="primary"?d.pillPrimaryLabel:r==="danger"?d.pillDangerLabel:r==="ask"?d.pillAskLabel:r==="link"?d.pillLinkLabel:d.pillOutlineLabel;/* @__PURE__ */
92
92
  return j(m,{onPress:t,disabled:n||i,accessibilityRole:"button",accessibilityLabel:l??e,accessibilityHint:o,accessibilityState:{disabled:n||i,busy:i},style:({pressed:e})=>[d.pill,h,n?d.pillDisabled:null,e&&!u?d.pressed:null,s],testID:a,children:[i?/* @__PURE__ */B(y,{size:"small",color:r==="primary"?c.color.onPrimary:c.color.brandInk}):null,
@@ -118,7 +118,7 @@ return j(f,{style:e.downloadGlyph,accessibilityElementsHidden:true,importantForA
118
118
  /* @__PURE__ */B(f,{style:e.downloadHead}),
119
119
  /* @__PURE__ */B(f,{style:e.downloadTray})]})}function Fo(){let e=useEverfurTheme();return n(()=>qo(e),[e])}function qo(e){let{color:t,space:r,type:n}=e,i=e.slots.header,l=i?.textColor??t.brandInk,o={flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:r.lg,paddingTop:r.xs,paddingBottom:r.md,gap:r.sm},a=r.xxl+r.md,s=r.md,d=r.xs/2,c=r.lg+r.xs+r.xs/2;return v.create({row:{...o,...Bn(i)},rowUnderLogo:o,bar:{...Bn(i)},logoBar:{alignItems:"center",paddingTop:r.sm,paddingHorizontal:r.lg},logo:{height:$o,width:Bo},back:{width:a,height:a,alignItems:"center",justifyContent:"center"},chevron:{width:s,height:s,borderLeftWidth:d,borderBottomWidth:d,borderColor:l,transform:[{rotate:"45deg"}],marginLeft:r.xs},title:{flex:1,...headingFace(e,"bold"),fontSize:n.size.heading,lineHeight:Math.round(n.size.heading*n.lineHeight.tight)+1,color:l},spacer:{flex:1},sandboxNote:{marginHorizontal:r.lg,marginBottom:r.md},documentTitle:{flex:1,textAlign:"center",...headingFace(e,"bold"),fontSize:n.size.subtitle,lineHeight:Math.round(n.size.subtitle*n.lineHeight.snug),color:t.text.primary,...jn(i)},right:{flexDirection:"row",alignItems:"center",gap:r.sm+r.xs/2},listGlyph:{width:c,height:c,justifyContent:"space-evenly"},listBar:{height:d,borderRadius:d,backgroundColor:l},shareGlyph:{width:c-r.xs,height:c-r.xs},shareDot:{position:"absolute",width:r.xs+r.xs/2,height:r.xs+r.xs/2,borderRadius:r.xs,borderWidth:d,borderColor:l},shareDotTop:{right:0,top:0},shareDotLeft:{left:0,top:r.xs+r.xs/2},shareDotBottom:{right:0,bottom:0},shareStroke:{position:"absolute",left:r.xs,top:r.sm,width:r.sm+r.xs/2,height:d,backgroundColor:l},shareStrokeUp:{transform:[{rotate:"-30deg"}]},shareStrokeDown:{transform:[{rotate:"30deg"}]},sendGlyph:{width:c-r.xs,height:c-r.xs},downloadGlyph:{width:c-r.xs,height:c-r.xs,alignItems:"center"},downloadStem:{width:d,height:r.sm+r.xs/2,backgroundColor:l},downloadHead:{width:r.sm,height:r.sm,borderRightWidth:d,borderBottomWidth:d,borderColor:l,transform:[{rotate:"45deg"}],marginTop:-r.sm},downloadTray:{position:"absolute",bottom:0,left:0,right:0,height:r.xs+r.xs/2,borderLeftWidth:d,borderRightWidth:d,borderBottomWidth:d,borderColor:l}})}var Mo=120,No=44;function RecordsGateOffState({reason:e,onExit:t,exitLabel:r,style:n}){let{color:i,space:l,radius:o,type:a}=useEverfurTheme();/* @__PURE__ */
120
120
  return j(f,{testID:"records-gate-off",style:[{minHeight:Mo,justifyContent:"center",gap:l.md,padding:l.lg,borderRadius:o.md,borderWidth:1,borderColor:i.brandBorder,backgroundColor:i.surfaceCream},n],children:[e.length>0?/* @__PURE__ */B(Text,{style:{fontSize:a.size.bodyTight,color:i.text.muted},children:e}):null,
121
- /* @__PURE__ */B(m,{onPress:t,accessibilityRole:"button",accessibilityLabel:r,testID:"records-gate-off-exit",style:{minHeight:No,alignSelf:"flex-start",justifyContent:"center",paddingHorizontal:l.lg,borderRadius:o.pill,borderWidth:1.5,borderColor:i.brandInk},children:/* @__PURE__ */B(Text,{style:{fontSize:a.size.body,color:i.brandInk},children:r})})]})}function Wo(e,t){return e===void 0?{}:{renderDisabled:r=>/* @__PURE__ */B(RecordsGateOffState,{reason:r.disabled?.reason??"",onExit:e,exitLabel:t})}}function Uo(e,t){return e===null?"":t?`${e} ${t}`:e}function Go(e){if(e===null||e.length===0)return"";let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(t!==null){let e=t[1]??"",r=t[2]??"",n=t[3]??"";return`${Number(r)}/${Number(n)}/${e.slice(2)}`}let r=Date.parse(e);if(Number.isNaN(r))return e;let n=new Date(r);return`${n.getUTCMonth()+1}/${n.getUTCDate()}/${String(n.getUTCFullYear()).slice(2)}`}var Vo=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ko(e){if(!e)return"-";let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(t!==null)return Yo(Number(t[1]),Number(t[2])-1,Number(t[3]));let r=Date.parse(e);if(Number.isNaN(r))return"-";let n=new Date(r);return Yo(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate())}function Yo(e,t,r){let n=Vo[t];return n===void 0?"-":`${n} ${r}, ${e}`}function Xo(e){let t=e?/^([\d-]{10}T[\d:]+)(\.\d+)?(.*)$/.exec(e):null,r=t?Date.parse(`${t[1]}${(t[2]??"").slice(0,4)}${t[3]||"Z"}`):Number.NaN;if(Number.isNaN(r))return Ko(e);let n=new Date(r);return Yo(n.getFullYear(),n.getMonth(),n.getDate())}function Qo(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=Ko(e),r=Number(e.slice(8,10));return t==="-"||r<1||r>31?e:t}function Jo(e){let t=e=>{let t=e.receivedAt===null?Number.NaN:Date.parse(e.receivedAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t};return Object.values(e).map((e,r)=>({doc:e,index:r,ms:t(e)})).sort((e,t)=>t.ms===e.ms?e.index-t.index:t.ms>e.ms?1:-1).map(e=>e.doc)}var Zo=/* @__PURE__ */Object.freeze({timeline:"Timeline",loadingTimeline:"Loading timeline",labResults:"Blood & lab work",visits:"Visits",physicalExams:"Physical exams",visitNotes:"Visit notes",visit:"Visit",exam:"Exam",visitNote:"Visit note",notRecorded:"Not recorded",abnormal:"Abnormal",notExamined:"Not examined",normal:"Normal",measured:e=>`Measured ${e}`,uploadedDocument:"Uploaded document",kind:/* @__PURE__ */Object.freeze({visit:"Visit",vaccine:"Vaccine",weight:"Weight",medication:"Medication"}),clinicVisit:"Clinic visit",doctor:e=>`Dr. ${e}`,lot:e=>`Lot ${e}`,expires:e=>`Expires ${e}`});function ea(e){switch(e){case"above":return{label:"Above range",outOfRange:true};case"below":return{label:"Below range",outOfRange:true};case"in_range":return{label:"In range",outOfRange:false};default:return{label:"No range on file",outOfRange:false}}}function ta(e,t){return t<2?null:`${e==="flat"?"Holding steady":`Trending ${e==="down"?"down":e==="up"?"up":"steady"}`} over ${t} visits`}function ra(e){let t=e.replace(/_/g," ").trim();return t.length===0?e:t.charAt(0).toUpperCase()+t.slice(1)}var na=/* @__PURE__ */Object.freeze({general:"General / attitude",eent:"Eyes, ears, nose & throat",oral_dental:"Oral & dental",cardiovascular:"Cardiovascular",respiratory:"Respiratory",gastrointestinal:"GI / abdomen",urogenital:"Urogenital",musculoskeletal:"Musculoskeletal",neurologic:"Neurologic",integument:"Skin & coat",lymphatic:"Lymph nodes"});function ia(e){return Object.prototype.hasOwnProperty.call(na,e)?na[e]:ra(e)}var la=/* @__PURE__ */Object.freeze({reason_for_visit:"Reason for visit",subjective:"Subjective",objective:"Objective",assessment:"Assessment",plan:"Plan",discharge_instructions:"Discharge instructions",follow_up:"Follow-up",remarks:"Notes"});function oa(e){return Object.prototype.hasOwnProperty.call(la,e)?la[e]:ra(e)}function aa(e){return e===null||!Number.isFinite(e)?"-":`${e.toFixed(3).replace(/\.?0+$/,"")} kg`}function sa(e,t,r){if((e===null||!Number.isFinite(e))&&r)return r;if(e===null||!Number.isFinite(e))return"-";let n=e.toFixed(3).replace(/\.?0+$/,"");return t?`${n} ${t}`:n}function da(e,t,r){let n=ta(t,r);return e?`${Zo.measured(Ko(e))}${n?` · ${n}`:""}`:n}var ca=/* @__PURE__ */Object.freeze({lab_report:"Lab report",pims_export:"Practice export",vaccination_certificate:"Vaccination certificate",imaging_report:"Imaging report",discharge_summary:"Discharge summary",referral_letter:"Referral letter",clinician_note:"Clinician note",consent_form:"Consent form",invoice_estimate:"Invoice",prescription:"Prescription",genetic_report:"Genetic report"});function ua(e){let t=e.title?.trim()??"";if(t.length>0)return t;let r=e.documentClass;return(r&&Object.prototype.hasOwnProperty.call(ca,r)?ca[r]:void 0)??Zo.uploadedDocument}var ha=/* @__PURE__ */Object.freeze({title:"Visits & records",shareA11y:"Share medical record",requestClinicsA11y:"Request records from clinics",inReview:e=>`${e} ${e===1?"document":"documents"} from your vet ${e===1?"is":"are"} being reviewed. Your full record will appear here once review is complete.`,needsAttention:"Needs attention",conflictSub:"Two documents list different values. Your vet can confirm which is correct.",askConflict:"Ask Everfur about this",whatsOnFile:"What's on file",coverage:/* @__PURE__ */Object.freeze({labs:"Labs",vaccines:"Vaccines",weight:"Weight",vitals:"Vitals",exams:"Exams",procedures:"Procedures",genetics:"Genetics",parasite:"Parasite prevention",reproductive:"Reproductive"}),onFile:"on file",noneOnFile:"none on file",documentsOnFile:e=>`${e} ${e===1?"document":"documents"} on file`,inReviewChip:e=>`${e} in review`,beingVerified:e=>`${e} being verified`,beingVerifiedA11y:e=>`${e} ${e===1?"fact is":"facts are"} being verified`,pendingReview:"Pending review: ",dateRange:(e,t)=>`${Ko(e)} to ${Ko(t)}`,documents:"Sources on file",uploadedDocument:Zo.uploadedDocument,documentRowA11y:e=>`View what ${e} contributed to this record`,documentMeta:(e,t)=>{let r=t?Ko(t):null,n=[e!==null&&Number.isInteger(e)&&e>0?`${e} ${e===1?"page":"pages"}`:null,r].filter(e=>e!==null);return n.length>0?n.join(" · "):null},identity:"Identity",needsReview:"Needs review",upcomingCare:"Upcoming care",careTimeline:"Care timeline",careTimelineSub:"Related records grouped over time, newest first.",lastDone:e=>`Last done ${e}`,overdue:"Overdue",due:e=>`Due ${e}`,askUpcomingCare:"Ask Everfur about upcoming care",askEverfur:"Ask Everfur",askExam:"Ask Everfur about this exam",askVisit:"Ask Everfur about this visit",labResults:Zo.labResults,visits:Zo.visits,physicalExams:Zo.physicalExams,visitNotes:Zo.visitNotes,document:/* @__PURE__ */Object.freeze({title:"Health Record",titleFor:e=>{let t=e?.trim()??"";return t.length>0?`${t}’s health record`:"Health Record"},download:"Download PDF",empty:"This record is empty for now.",docTitle:"Medical Record",namelessPet:"Your pet",generated:e=>`Generated ${Ko(e)}`,identity:"Identity",labs:"Blood & Lab Work",ref:e=>`Ref ${e}`,noRange:"No reference range",upcomingCare:"Upcoming Care",physicalExams:"Physical Exams",clinicianNotes:"Clinician Notes"})}),pa=/* @__PURE__ */Object.freeze({vaccination:"Vaccinations",medication:"Medications",problem:"Problems & diagnoses",procedure:"Procedures & surgery",allergy:"Allergies",parasite_prevention:"Parasite prevention",reproductive:"Reproductive history",vital:"Vitals",body_weight:"Weight",lab_result:"Lab results",imaging:"Imaging & radiology",genetic_result:"Genetic testing",document_note:"Other notes"});function ga(e){return Object.prototype.hasOwnProperty.call(pa,e)?pa[e]:ra(e)}var fa=/* @__PURE__ */Object.freeze(["vaccination","medication","problem","procedure","allergy","parasite_prevention","reproductive","vital","body_weight"]);function ma(e){let t=fa.filter(t=>e.includes(t)),r=e.filter(e=>!fa.includes(e));return[...t,...r]}function ba(e){switch(e){case"identity_risk":return{label:"Identity mismatch",rank:0,tone:"critical"};case"benign":return{label:"Minor difference",rank:2,tone:"neutral"};default:return{label:"Needs review",rank:1,tone:"warning"}}}function ya(e,t){if(!e)return null;let r=Date.parse(e);if(Number.isNaN(r))return null;let n=r<t-1440*60*1e3;return{label:n?ha.overdue:ha.due(Ko(e)),overdue:n}}function va(e){return e===null?null:e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}`:e.refLow!==null?`≥ ${e.refLow}`:e.refHigh!==null?`≤ ${e.refHigh}`:null}var wa=/* @__PURE__ */Object.freeze({openA11y:"Share medical record",openA11yFor:e=>{let t=e?.trim()??"";return t.length>0?`Share ${t}’s record`:"Share medical record"},title:"Share medical record",titleFor:e=>{let t=e?.trim()??"";return t.length>0?`Send ${t}’s record`:"Share medical record"},helper:"Anyone with an active link can view this record until it expires. You can turn a link off anytime.",leadNative:"Pick who it’s for; we include the right pages.",leadWebFor:e=>{let t=e?.trim()??"";return t.length>0?`Share a snapshot of what ${t}’s vets recorded. Pick who it’s for and we include the right pages.`:"Pick who it’s for; we include the right pages."},audienceLabel:"Who it’s for",audiences:/* @__PURE__ */Object.freeze({vet:"Vet",groomer:"Groomer",boarding:"Boarding"}),included:"What’s included",sendTo:"Send to",sendToPlaceholder:"vet@example.com…",send:"Send",sending:"Sending…",addEmailFor:e=>{let t=e?.trim()??"";return t.length>0?`Add an email to send ${t}’s record.`:"Add an email to send the record."},emailInvalid:"That email doesn’t look right. Check it and try again.",emailFailed:"Could not send the email. Please try again.",close:"Close",closeSheetA11y:"Close share sheet",viewDocument:"View document",previewNative:"Preview what they get",createLink:"Create link and share",shareLinkNative:"Share link",linkTerms:"Sent as a secure link that works for 7 days. You can stop sharing it any time.",creatingLink:"Creating link...",downloadPdf:"Download PDF",preparingPdf:"Preparing PDF...",activeLinks:"Active links",loadingLinks:"Loading your share links",errorTitle:"Couldn’t load your links",errorBody:"Check your connection and try again. You can still create a new link above.",retry:"Try again",retrying:"Retrying...",emptyTitle:"No active links yet",emptyBody:"Create a link above to let your vet or a sitter view this record. It expires on its own, and you can turn it off anytime.",copyLink:"Copy link",turnOff:"Turn off",turnOffA11y:e=>`Turn off share link, ${e}`,turningOff:"Turning off...",keep:"Keep",confirmTurnOff:"Turn off this link? Anyone who has it will lose access.",shareMessage:e=>`View this medical record: ${e}`,consentOffTitle:"Records access is off",consentOffBody:"Allow records for this pet again to create a link or download the PDF. Any links that were live have been turned off. You can still turn off a link from this list.",toasts:/* @__PURE__ */Object.freeze({noAddress:"Link created, but no address came back. It is listed under Active links.",shareSheet:"Could not open the share sheet. The link is saved below.",pdfShareSheet:"Could not open the share sheet for this PDF.",copied:"Link copied.",copyFailed:"Could not copy the link.",copiedNative:"Link copied. It works for 7 days.",copyFailedNative:e=>`Couldn’t copy. The link is ${e}`,turnedOff:"Link turned off.",sentTo:e=>`Sent to ${e}. The link works for 7 days.`})}),ka=/* @__PURE__ */Object.freeze(["Vaccines, medications and allergies","Conditions and procedures, with dates"]),xa=/* @__PURE__ */Object.freeze([["encounters","encounters",Zo.visits],["lab_results","markers",Zo.labResults],["physical_exams","physical_exams",Zo.physicalExams]]);function Ta(e,t){let r=[];e.sections.includes("entities")&&(e.entityTypes===null?r.push(...ka):r.push(...ma(e.entityTypes).map(ga)));for(let[n,i,l]of xa)e.sections.includes(n)&&t[i]===true&&r.push(l);return e.sections.includes("forward_looking")&&r.push(ha.upcomingCare),/* @__PURE__ */Object.freeze(r)}function Ca(e,t){if(!e)return false;let r=Date.parse(e);return Number.isNaN(r)?false:r<=t}function _a(e,t){let r=Ko(e);return r==="-"?t?"Expired":"No expiry date":t?`Expired ${r}`:`Expires ${r}`}function Ra(e,t,r){let n=e.map(e=>{let n=Ca(e.expiresAt,r),i=_a(e.expiresAt,n),l=Ko(e.createdAt),o=n?"Expired":"Active",a=i.replace(/^Expires /,"expiring ").replace(/^Expired /,"expired ").replace(/^Expired$/,"expired").replace(/^No expiry date$/,"with no expiry date");return{shareId:e.shareId,shareUrl:t[e.shareId]??null,active:!n,statusLabel:o,expiryLabel:i,createdLabel:l==="-"?null:`Created ${l}`,a11yLabel:`Share link. ${o}. ${i}.`,actionContext:a}});/* @__PURE__ */
121
+ /* @__PURE__ */B(m,{onPress:t,accessibilityRole:"button",accessibilityLabel:r,testID:"records-gate-off-exit",style:{minHeight:No,alignSelf:"flex-start",justifyContent:"center",paddingHorizontal:l.lg,borderRadius:o.pill,borderWidth:1.5,borderColor:i.brandInk},children:/* @__PURE__ */B(Text,{style:{fontSize:a.size.body,color:i.brandInk},children:r})})]})}function Wo(e,t){return e===void 0?{}:{renderDisabled:r=>/* @__PURE__ */B(RecordsGateOffState,{reason:r.disabled?.reason??"",onExit:e,exitLabel:t})}}function Uo(e,t){return e===null?"":t?`${e} ${t}`:e}function Go(e){if(e===null||e.length===0)return"";let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(t!==null){let e=t[1]??"",r=t[2]??"",n=t[3]??"";return`${Number(r)}/${Number(n)}/${e.slice(2)}`}let r=Date.parse(e);if(Number.isNaN(r))return e;let n=new Date(r);return`${n.getUTCMonth()+1}/${n.getUTCDate()}/${String(n.getUTCFullYear()).slice(2)}`}var Vo=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ko(e){if(!e)return"-";let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(t!==null)return Yo(Number(t[1]),Number(t[2])-1,Number(t[3]));let r=Date.parse(e);if(Number.isNaN(r))return"-";let n=new Date(r);return Yo(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate())}function Yo(e,t,r){let n=Vo[t];return n===void 0?"-":`${n} ${r}, ${e}`}function Xo(e){let t=e?/^([\d-]{10}T[\d:]+)(\.\d+)?(.*)$/.exec(e):null,r=t?Date.parse(`${t[1]}${(t[2]??"").slice(0,4)}${t[3]||"Z"}`):Number.NaN;if(Number.isNaN(r))return Ko(e);let n=new Date(r);return Yo(n.getFullYear(),n.getMonth(),n.getDate())}function Qo(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=Ko(e),r=Number(e.slice(8,10));return t==="-"||r<1||r>31?e:t}function Jo(e){let t=e=>{let t=e.receivedAt===null?Number.NaN:Date.parse(e.receivedAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t};return Object.values(e).map((e,r)=>({doc:e,index:r,ms:t(e)})).sort((e,t)=>t.ms===e.ms?e.index-t.index:t.ms>e.ms?1:-1).map(e=>e.doc)}var Zo=/* @__PURE__ */Object.freeze({timeline:"Timeline",loadingTimeline:"Loading timeline",labResults:"Blood & lab work",visits:"Visits",physicalExams:"Physical exams",visitNotes:"Visit notes",visit:"Visit",exam:"Exam",visitNote:"Visit note",notRecorded:"Not recorded",abnormal:"Abnormal",notExamined:"Not examined",normal:"Normal",measured:e=>`Measured ${e}`,uploadedDocument:"Uploaded document",kind:/* @__PURE__ */Object.freeze({visit:"Visit",vaccine:"Vaccine",weight:"Weight",medication:"Medication"}),clinicVisit:"Clinic visit",doctor:e=>`Dr. ${e}`,lot:e=>`Lot ${e}`,expires:e=>`Expires ${e}`});function ea(e){switch(e){case"above":return{label:"Above range",outOfRange:true};case"below":return{label:"Below range",outOfRange:true};case"in_range":return{label:"In range",outOfRange:false};default:return{label:"No range on file",outOfRange:false}}}function ta(e,t){return t<2?null:`${e==="flat"?"Holding steady":`Trending ${e==="down"?"down":e==="up"?"up":"steady"}`} over ${t} visits`}function ra(e){let t=e.replace(/_/g," ").trim();return t.length===0?e:t.charAt(0).toUpperCase()+t.slice(1)}var na=/* @__PURE__ */Object.freeze({general:"General / attitude",eent:"Eyes, ears, nose & throat",oral_dental:"Oral & dental",cardiovascular:"Cardiovascular",respiratory:"Respiratory",gastrointestinal:"GI / abdomen",urogenital:"Urogenital",musculoskeletal:"Musculoskeletal",neurologic:"Neurologic",integument:"Skin & coat",lymphatic:"Lymph nodes"});function ia(e){return Object.prototype.hasOwnProperty.call(na,e)?na[e]:ra(e)}var la=/* @__PURE__ */Object.freeze({reason_for_visit:"Reason for visit",subjective:"Subjective",objective:"Objective",assessment:"Assessment",plan:"Plan",discharge_instructions:"Discharge instructions",follow_up:"Follow-up",remarks:"Notes"});function oa(e){return Object.prototype.hasOwnProperty.call(la,e)?la[e]:ra(e)}function aa(e){return e===null||!Number.isFinite(e)?"-":`${e.toFixed(3).replace(/\.?0+$/,"")} kg`}function sa(e,t,r){if((e===null||!Number.isFinite(e))&&r)return r;if(e===null||!Number.isFinite(e))return"-";let n=e.toFixed(3).replace(/\.?0+$/,"");return t?`${n} ${t}`:n}function da(e,t,r){let n=ta(t,r);return e?`${Zo.measured(Ko(e))}${n?` · ${n}`:""}`:n}var ca=/* @__PURE__ */Object.freeze({lab_report:"Lab report",pims_export:"Practice export",vaccination_certificate:"Vaccination certificate",imaging_report:"Imaging report",discharge_summary:"Discharge summary",referral_letter:"Referral letter",clinician_note:"Clinician note",consent_form:"Consent form",invoice_estimate:"Invoice",prescription:"Prescription",genetic_report:"Genetic report"});function ua(e){let t=e.title?.trim()??"";if(t.length>0)return t;let r=e.documentClass;return(r&&Object.prototype.hasOwnProperty.call(ca,r)?ca[r]:void 0)??Zo.uploadedDocument}var ha=/* @__PURE__ */Object.freeze({title:"Visits & records",shareA11y:"Share medical record",requestClinicsA11y:"Request records from clinics",inReview:e=>`${e} ${e===1?"document":"documents"} from your vet ${e===1?"is":"are"} being reviewed. Your full record will appear here once review is complete.`,needsAttention:"Needs attention",conflictSub:"Two documents list different values. Your vet can confirm which is correct.",askConflict:"Ask Everfur about this",whatsOnFile:"What's on file",coverage:/* @__PURE__ */Object.freeze({labs:"Labs",vaccines:"Vaccines",weight:"Weight",vitals:"Vitals",exams:"Exams",procedures:"Procedures",genetics:"Genetics",parasite:"Parasite prevention",reproductive:"Reproductive"}),onFile:"on file",noneOnFile:"none on file",documentsOnFile:e=>`${e} ${e===1?"document":"documents"} on file`,inReviewChip:e=>`${e} in review`,beingVerified:e=>`${e} being verified`,beingVerifiedA11y:e=>`${e} ${e===1?"fact is":"facts are"} being verified`,pendingReview:"Pending review: ",dateRange:(e,t)=>`${Ko(e)} to ${Ko(t)}`,documents:"Sources on file",uploadedDocument:Zo.uploadedDocument,documentRowA11y:e=>`View what ${e} contributed to this record`,documentMeta:(e,t)=>{let r=t?Ko(t):null,n=[e!==null&&Number.isInteger(e)&&e>0?`${e} ${e===1?"page":"pages"}`:null,r].filter(e=>e!==null);return n.length>0?n.join(" · "):null},identity:"Identity",needsReview:"Needs review",upcomingCare:"Upcoming care",careTimeline:"Care timeline",careTimelineSub:"Related records grouped over time, newest first.",lastDone:e=>`Last done ${e}`,overdue:"Overdue",due:e=>`Due ${e}`,askUpcomingCare:"Ask Everfur about upcoming care",askEverfur:"Ask Everfur",askExam:"Ask Everfur about this exam",askVisit:"Ask Everfur about this visit",labResults:Zo.labResults,visits:Zo.visits,physicalExams:Zo.physicalExams,visitNotes:Zo.visitNotes,document:/* @__PURE__ */Object.freeze({title:"Health Record",titleFor:e=>{let t=e?.trim()??"";return t.length>0?`${t}’s health record`:"Health Record"},download:"Download PDF",empty:"This record is empty for now.",docTitle:"Medical Record",namelessPet:"Your pet",generated:e=>`Generated ${Ko(e)}`,identity:"Identity",labs:"Blood & Lab Work",ref:e=>`Ref ${e}`,noRange:"No reference range",upcomingCare:"Upcoming Care",physicalExams:"Physical Exams",clinicianNotes:"Clinician Notes"})}),pa=/* @__PURE__ */Object.freeze({vaccination:"Vaccinations",medication:"Medications",problem:"Problems & diagnoses",procedure:"Procedures & surgery",allergy:"Allergies",parasite_prevention:"Parasite prevention",reproductive:"Reproductive history",vital:"Vitals",body_weight:"Weight",lab_result:"Lab results",imaging:"Imaging & radiology",genetic_result:"Genetic testing",document_note:"Other notes"});function ga(e){return Object.prototype.hasOwnProperty.call(pa,e)?pa[e]:ra(e)}var fa=/* @__PURE__ */Object.freeze(["vaccination","medication","problem","procedure","allergy","parasite_prevention","reproductive","vital","body_weight"]);function ma(e){let t=fa.filter(t=>e.includes(t)),r=e.filter(e=>!fa.includes(e));return[...t,...r]}function ba(e){switch(e){case"identity_risk":return{label:"Identity mismatch",rank:0,tone:"critical"};case"benign":return{label:"Minor difference",rank:2,tone:"neutral"};default:return{label:"Needs review",rank:1,tone:"warning"}}}function ya(e,t){if(!e)return null;let r=Date.parse(e);if(Number.isNaN(r))return null;let n=r<t-1440*60*1e3;return{label:n?ha.overdue:ha.due(Ko(e)),overdue:n}}function va(e){return e===null?null:e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}`:e.refLow!==null?`≥ ${e.refLow}`:e.refHigh!==null?`≤ ${e.refHigh}`:null}var wa=/* @__PURE__ */Object.freeze({openA11y:"Share medical record",openA11yFor:e=>{let t=e?.trim()??"";return t.length>0?`Share ${t}’s record`:"Share medical record"},title:"Share medical record",titleFor:e=>{let t=e?.trim()??"";return t.length>0?`Send ${t}’s record`:"Share medical record"},helper:"Anyone with an active link can view this record until it expires. You can turn a link off anytime.",leadNative:"Pick who it’s for; we include the right pages.",leadWebFor:e=>{let t=e?.trim()??"";return t.length>0?`Share a snapshot of what ${t}’s vets recorded. Pick who it’s for and we include the right pages.`:"Pick who it’s for; we include the right pages."},audienceLabel:"Who it’s for",audiences:/* @__PURE__ */Object.freeze({vet:"Vet",groomer:"Groomer",boarding:"Boarding"}),included:"What’s included",sendTo:"Send to",sendToPlaceholder:"vet@example.com…",send:"Send",sending:"Sending…",addEmailFor:e=>{let t=e?.trim()??"";return t.length>0?`Add an email to send ${t}’s record.`:"Add an email to send the record."},emailInvalid:"That email doesn’t look right. Check it and try again.",emailFailed:"Could not send the email. Please try again.",close:"Close",closeSheetA11y:"Close share sheet",viewDocument:"View document",previewNative:"Preview what they get",createLink:"Create link and share",shareLinkNative:"Share link",linkTerms:"Sent as a secure link that works for 7 days. You can stop sharing it any time.",creatingLink:"Creating link...",downloadPdf:"Download PDF",preparingPdf:"Preparing PDF...",activeLinks:"Active links",loadingLinks:"Loading your share links",errorTitle:"Couldn’t load your links",errorBody:"Check your connection and try again. You can still create a new link above.",retry:"Try again",retrying:"Retrying...",emptyTitle:"No active links yet",emptyBody:"Create a link above to let your vet or a sitter view this record. It expires on its own, and you can turn it off anytime.",copyLink:"Copy link",turnOff:"Turn off",turnOffA11y:e=>`Turn off share link, ${e}`,turningOff:"Turning off...",keep:"Keep",confirmTurnOff:"Turn off this link? Anyone who has it will lose access.",shareMessage:e=>`View this medical record: ${e}`,consentOffTitle:"Records access is off",consentOffBody:"Allow records for this pet again to create a link or download the PDF. Any links that were live have been turned off. You can still turn off a link from this list.",toasts:/* @__PURE__ */Object.freeze({noAddress:"Link created, but no address came back. It is listed under Active links.",shareSheet:"Could not open the share sheet. The link is saved below.",pdfShareSheet:"Could not open the share sheet for this PDF.",copied:"Link copied.",copyFailed:"Could not copy the link.",copiedNative:"Link copied. It works for 7 days.",copyFailedNative:e=>`Couldn’t copy. The link is ${e}`,turnedOff:"Link turned off.",sentTo:e=>`Sent to ${e}. The link works for 7 days.`})}),ka=/* @__PURE__ */Object.freeze(["Vaccines, medications and allergies","Conditions and procedures, with dates"]),xa=/* @__PURE__ */Object.freeze([["encounters","encounters",Zo.visits],["lab_results","markers",Zo.labResults],["physical_exams","physical_exams",Zo.physicalExams]]);function Ta(e,t){let r=[];e.sections.includes("entities")&&(e.entityTypes===null?r.push(...ka):r.push(...ma(e.entityTypes).map(ga)));for(let[n,i,l]of xa)e.sections.includes(n)&&t[i]===true&&r.push(l);return e.sections.includes("forward_looking")&&r.push(ha.upcomingCare),/* @__PURE__ */Object.freeze(r)}function _a(e,t){if(!e)return false;let r=Date.parse(e);return Number.isNaN(r)?false:r<=t}function Ca(e,t){let r=Ko(e);return r==="-"?t?"Expired":"No expiry date":t?`Expired ${r}`:`Expires ${r}`}function Ra(e,t,r){let n=e.map(e=>{let n=_a(e.expiresAt,r),i=Ca(e.expiresAt,n),l=Ko(e.createdAt),o=n?"Expired":"Active",a=i.replace(/^Expires /,"expiring ").replace(/^Expired /,"expired ").replace(/^Expired$/,"expired").replace(/^No expiry date$/,"with no expiry date");return{shareId:e.shareId,shareUrl:t[e.shareId]??null,active:!n,statusLabel:o,expiryLabel:i,createdLabel:l==="-"?null:`Created ${l}`,a11yLabel:`Share link. ${o}. ${i}.`,actionContext:a}});/* @__PURE__ */
122
122
  return Object.freeze([...n.filter(e=>e.active),...n.filter(e=>!e.active)])}function Sa(e,t){let r=e?.httpStatus;if(ht(e)){if(t==="create"||t==="email")return"Records access for this pet is off, so a new link cannot be created.";if(t==="download")return"Records access for this pet is off, so the PDF cannot be downloaded."}if(r===429)return"You are creating links a little too fast. Wait a moment, then try again.";if(t==="revoke"&&(r===404||r===409||r===410))return"That link was already turned off.";if(r===401||r===403)return"You need to be signed in as this pet's owner to do that.";if(t==="email"&&(r===400||r===422||e?.code==="validationFailed"))return wa.emailInvalid;switch(t){case"create":return"Could not create a share link. Please try again.";case"revoke":return"Could not turn off that link. Please try again.";case"email":return wa.emailFailed;default:return"Could not download the record PDF. Please try again."}}function SkeletonBlock({width:e,height:t,radius:r,style:n}){let{color:i,radius:l}=useEverfurTheme();/* @__PURE__ */
123
123
  return B(f,{style:[{width:e,height:t,borderRadius:r??l.xs,backgroundColor:i.skeleton},n],accessibilityElementsHidden:true,importantForAccessibility:"no"})}var za=180,Ia=70,Da=22,Ha=300,La=44,Pa=24,Oa=34,$a=6,Ba=5;function DashboardSkeleton({testID:e}){let t=Aa(),r=e=>/* @__PURE__ */j(f,{style:t.actionRow,children:[
124
124
  /* @__PURE__ */j(f,{style:t.actionLeft,children:[
@@ -183,13 +183,13 @@ return j(f,{style:t.document,accessible:true,accessibilityRole:"progressbar",acc
183
183
  /* @__PURE__ */B(f,{style:t.documentRule})]}),Array.from({length:e},(e,r)=>/* @__PURE__ */j(f,{style:[t.documentRow,r>0?t.recordDivider:null],children:[
184
184
  /* @__PURE__ */B(SkeletonBlock,{width:r%2===0?"46%":"38%",height:14,radius:7}),
185
185
  /* @__PURE__ */B(SkeletonBlock,{width:56,height:14,radius:7})]},r))]},r))]})}var ja=62;function Aa(){let e=useEverfurTheme();return n(()=>Ea(e),[e])}function Ea(e){let{color:t,space:r,radius:n}=e,i=v.hairlineWidth;return v.create({dashboard:{flex:1,paddingHorizontal:r.sm,paddingTop:r.xs,gap:r.lg,backgroundColor:t.background},inset:{paddingHorizontal:r.sm},summaryCard:{alignItems:"center",borderRadius:n.lg-r.xs,borderWidth:i,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.lg+r.xs,gap:r.md+r.xs/2},badges:{flexDirection:"row",gap:r.md},carouselCard:{borderRadius:n.lg-r.xs,borderWidth:i,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.lg},dots:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.xs+r.xs/2},centered:{alignSelf:"center"},actions:{gap:r.sm+r.xs/2},actionRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderRadius:n.md,borderWidth:i,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.lg},actionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:r.md},request:{paddingHorizontal:r.lg,paddingTop:r.xs,gap:r.lg+r.xs/2,backgroundColor:t.background},railRow:{flexDirection:"row",alignItems:"flex-start",gap:r.md},railColumn:{alignItems:"center",width:Pa},connector:{marginVertical:r.xs/2},railBody:{flex:1,paddingBottom:r.lg+r.xs/2,gap:r.xs+r.xs/2},statusCard:{borderRadius:n.md,backgroundColor:t.brandSoft,padding:r.md+r.xs/2,gap:r.sm},timeline:{flex:1,backgroundColor:t.background},timelineDisclaimer:{paddingHorizontal:r.lg,paddingTop:r.xs,paddingBottom:r.md},timelineRow:{flexDirection:"row",gap:r.md,paddingHorizontal:r.lg,paddingVertical:r.md+r.xs/2},timelineBody:{flex:1,gap:r.xs-1},timelineTop:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},timelineSeparator:{height:i,backgroundColor:t.brandBorder,marginLeft:ja},clinics:{gap:r.md},clinicRow:{borderRadius:n.lg-r.xs/2,borderWidth:i,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md+r.xs/2,gap:r.sm},shares:{gap:r.md,padding:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,borderWidth:i,borderColor:t.brandBorder},shareRow:{gap:r.xs+r.xs/2},record:{flex:1,paddingHorizontal:r.lg,paddingTop:r.xs,gap:r.lg+r.xs,backgroundColor:t.background},recordSection:{gap:r.sm+r.xs/2},recordHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},recordCard:{borderRadius:n.lg,borderWidth:i,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.xs},recordRow:{gap:r.xs+r.xs/2,paddingVertical:r.md},recordDivider:{borderTopWidth:i,borderTopColor:t.borderHairlineGreen},document:{flex:1,paddingHorizontal:r.lg+r.xs,paddingTop:r.md,gap:r.lg},letterhead:{alignItems:"center",gap:r.sm,paddingBottom:r.lg,borderBottomWidth:2,borderBottomColor:t.skeleton},documentSection:{gap:r.xs},documentHead:{flexDirection:"row",alignItems:"center",gap:r.sm+r.xs/2,marginBottom:r.xs},documentRule:{flex:1,height:i,backgroundColor:t.borderHairlineGreen},documentRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,paddingVertical:r.sm+1}})}var Fa=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function EverfurClinicPicker(e){let{userRef:userRef,scopeEpoch:t}=Ir();/* @__PURE__ */
186
- return B(CapabilityGate,{capability:"recordsClinic",style:e.style,...Wo(e.onBack,jo),children:userRef===null?/* @__PURE__ */B(Text,{accessibilityRole:"alert",children:Kn.sessionRequired}):/* @__PURE__ */B(PickerBody,{...Zr(e,["onNavigate","onBack"])},JSON.stringify([userRef,t,e.petRef]))})}function PickerBody({petRef:petRef,petName:e,controller:t,recordsController:n,location:a,onNavigate:s,onBack:d,style:c}){let u=Io(),h=qa(),v=useEverfurTheme(),w=useEverfurRecordsClinic(),k=bi(t??w,a),x=useEverfurRecords(n?{petRef:petRef,controller:n}:{petRef:petRef}),T=r(Yt()),[C,_]=i(false),[R,S]=i(null),[z,I]=i(false),[D,H]=i(""),[L,P]=i(false),[O,$]=i(""),[A,E]=i(false),F=l(e=>{s?.({name:"consent",clinic:yi(e,null,"",T.current())})},[s]),q=()=>{C||(_(true),S(null),x.createRequest(`records-upload-${Date.now().toString(36)}`).then(e=>{if(_(false),!e.ok){S(si.errors.start);return}s?.({name:"request",requestId:e.value.id})}))},M=L?D:k.query,N=Fa.test(O.trim()),W=M.trim().length>0&&N,U=e=>{let{layoutMeasurement:t,contentOffset:r,contentSize:n}=e.nativeEvent;t.height+r.y>=n.height-t.height*.6&&k.loadMore()},G=k.isSearchActive?k.clinics:k.recent,V=k.isSearchActive?k.error?ai(k.error):!k.initialLoading&&k.clinics.length===0?"idle":null:k.recent.length>0||k.recentLoading?null:"idle",K=k.isSearchActive&&!k.initialLoading&&!k.error&&k.clinics.length>0?Fn.resultsCount(k.clinics.length):"";return o(()=>{K.length>0&&g.announceForAccessibility?.(K)},[K]),/* @__PURE__ */j(f,{style:[u.root,c],children:[
186
+ return B(CapabilityGate,{capability:"recordsClinic",style:e.style,...Wo(e.onBack,jo),children:userRef===null?/* @__PURE__ */B(Text,{accessibilityRole:"alert",children:Kn.sessionRequired}):/* @__PURE__ */B(PickerBody,{...Zr(e,["onNavigate","onBack"])},JSON.stringify([userRef,t,e.petRef]))})}function PickerBody({petRef:petRef,petName:e,controller:t,recordsController:n,location:a,onNavigate:s,onBack:d,style:c}){let u=Io(),h=qa(),v=useEverfurTheme(),w=useEverfurRecordsClinic(),k=bi(t??w,a),x=useEverfurRecords(n?{petRef:petRef,controller:n}:{petRef:petRef}),T=r(Yt()),[_,C]=i(false),[R,S]=i(null),[z,I]=i(false),[D,H]=i(""),[L,P]=i(false),[O,$]=i(""),[A,E]=i(false),F=l(e=>{s?.({name:"consent",clinic:yi(e,null,"",T.current())})},[s]),q=()=>{_||(C(true),S(null),x.createRequest(`records-upload-${Date.now().toString(36)}`).then(e=>{if(C(false),!e.ok){S(si.errors.start);return}s?.({name:"request",requestId:e.value.id})}))},M=L?D:k.query,N=Fa.test(O.trim()),W=M.trim().length>0&&N,U=e=>{let{layoutMeasurement:t,contentOffset:r,contentSize:n}=e.nativeEvent;t.height+r.y>=n.height-t.height*.6&&k.loadMore()},G=k.isSearchActive?k.clinics:k.recent,V=k.isSearchActive?k.error?ai(k.error):!k.initialLoading&&k.clinics.length===0?"idle":null:k.recent.length>0||k.recentLoading?null:"idle",K=k.isSearchActive&&!k.initialLoading&&!k.error&&k.clinics.length>0?Fn.resultsCount(k.clinics.length):"";return o(()=>{K.length>0&&g.announceForAccessibility?.(K)},[K]),/* @__PURE__ */j(f,{style:[u.root,c],children:[
187
187
  /* @__PURE__ */B(ScreenHeader,{title:Fn.titleFor(e),onBack:d,testID:"records-clinic-header"}),
188
188
  /* @__PURE__ */B(Text,{style:h.lead,testID:"records-clinic-lead",children:Fn.leadNative}),
189
189
  /* @__PURE__ */j(f,{style:h.searchBar,children:[
190
190
  /* @__PURE__ */B(f,{testID:"records-clinic-search-glyph",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */B(SearchGlyph,{size:v.space.md,color:v.color.text.muted,strokeWidth:2})}),
191
191
  /* @__PURE__ */B($n,{value:k.query,onChangeText:k.setQuery,placeholder:Fn.placeholder,placeholderTextColor:v.color.text.muted,autoCorrect:false,autoCapitalize:"words",returnKeyType:"search",maxLength:200,accessibilityLabel:Fn.searchA11y,style:h.searchInput,testID:"records-clinic-search-input"}),k.query.length>0?/* @__PURE__ */B(m,{onPress:()=>k.setQuery(""),accessibilityRole:"button",accessibilityLabel:Fn.clearSearch,hitSlop:8,testID:"records-clinic-search-clear",children:/* @__PURE__ */B(Text,{style:h.clearGlyph,children:"×"})}):null]}),s?/* @__PURE__ */j(f,{style:h.uploadWrap,children:[R?/* @__PURE__ */B(f,{style:u.errorBanner,accessibilityRole:"alert",children:/* @__PURE__ */B(Text,{style:u.errorText,children:R})}):null,
192
- /* @__PURE__ */B(Pill,{label:C?Fn.uploadOwnStarting:Fn.uploadOwn,kind:"outline",busy:C,onPress:q,testID:"records-clinic-upload-own"})]}):null,
192
+ /* @__PURE__ */B(Pill,{label:_?Fn.uploadOwnStarting:Fn.uploadOwn,kind:"outline",busy:_,onPress:q,testID:"records-clinic-upload-own"})]}):null,
193
193
  /* @__PURE__ */B(Text,{accessibilityLiveRegion:"polite",style:h.srOnly,testID:"records-clinic-results-status",children:K}),
194
194
  /* @__PURE__ */j(b,{contentContainerStyle:h.list,keyboardShouldPersistTaps:"handled",keyboardDismissMode:p.OS==="ios"?"interactive":"on-drag",onScroll:k.isSearchActive?U:void 0,scrollEventThrottle:200,testID:"records-clinic-results",children:[k.isSearchActive?/* @__PURE__ */j(f,{style:h.fallbackCard,testID:"records-clinic-fallback-card",children:[
195
195
  /* @__PURE__ */j(m,{onPress:()=>I(e=>!e),accessibilityRole:"button",accessibilityLabel:Fn.fallback.title,accessibilityHint:Fn.fallback.subtitle,accessibilityState:{expanded:z},style:h.fallbackHeader,testID:"records-clinic-fallback",children:[
@@ -216,13 +216,13 @@ return B(CapabilityGate,{capability:"recordsClinic",style:e.style,...Wo(e.onBack
216
216
  return j(m,{onPress:()=>t(e),accessibilityRole:"button",accessibilityLabel:Fn.selectA11y(l),hitSlop:8,style:r.item,testID:`records-clinic-${e.id}`,children:[
217
217
  /* @__PURE__ */j(f,{style:r.itemHeader,children:[
218
218
  /* @__PURE__ */B(Text,{style:r.itemName,numberOfLines:1,children:e.name}),i?/* @__PURE__ */B(Text,{style:r.itemDistance,accessibilityElementsHidden:true,importantForAccessibility:"no",children:i}):null]}),e.address?/* @__PURE__ */B(Text,{style:r.itemAddress,numberOfLines:2,children:e.address}):null,e.phone?/* @__PURE__ */B(Text,{style:r.itemPhone,numberOfLines:1,accessibilityElementsHidden:true,importantForAccessibility:"no",children:e.phone}):null,
219
- /* @__PURE__ */B(f,{style:[r.badge,n.tone==="positive"?r.badgePositive:n.tone==="caution"?r.badgeCaution:r.badgeNeutral],accessibilityElementsHidden:true,importantForAccessibility:"no",children:/* @__PURE__ */B(Text,{style:[r.badgeLabel,n.tone==="positive"?r.badgePositiveText:n.tone==="caution"?r.badgeCautionText:r.badgeNeutralText],children:n.label})})]})}function qa(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?Na(e):bo(Na(e),Ma(t)),[e,t])}function Ma(e){return{howCard:mo(e,{marginTop:8}),howTitle:e.cardTitle,item:mo(e,{paddingHorizontal:e.cardPad,paddingVertical:12,gap:8}),fallbackCard:{...mo(e,{paddingHorizontal:e.cardPad,paddingVertical:12}),borderWidth:1,borderStyle:"dashed",borderColor:e.look.line}}}function Na(e){let{color:t,space:r,radius:n,type:i}=e,l=v.hairlineWidth,o=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n}),a=e.slots.card,s=jn(a);return v.create({srOnly:{position:"absolute",width:1,height:1,overflow:"hidden"},lead:{...o(i.size.body,i.lineHeight.normal,t.text.muted),paddingHorizontal:r.lg,paddingBottom:r.md},howCard:{borderRadius:n.lg,backgroundColor:t.surfaceSubtle,padding:r.lg,gap:r.md,marginTop:r.sm,...Bn(a)},howTitle:{...o(i.size.subtitle,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),letterSpacing:-.4,...s},howRow:{flexDirection:"row",gap:r.md},howNumber:{...face(e,"monoBold"),fontSize:i.size.caption,lineHeight:Math.round(i.size.body*i.lineHeight.snug),color:t.brandInk,minWidth:r.xl},howText:{flex:1,gap:r.xs/2},howStepTitle:{...o(i.size.body,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),...s},howStepBody:{...o(i.size.caption,i.lineHeight.normal,t.text.secondary),...s},searchBar:{flexDirection:"row",alignItems:"center",gap:r.sm,paddingHorizontal:r.md+r.xs/2,height:r.xxl+r.md,marginHorizontal:r.lg,marginBottom:r.sm,borderRadius:n.lg+r.xs/2,backgroundColor:t.surfaceSubtle,borderWidth:l,borderColor:t.borderHairlineGreen,...Bn(e.slots.input,l)},searchInput:{flex:1,...o(i.size.body,i.lineHeight.snug,t.text.primary),paddingVertical:0,...jn(e.slots.input)},clearGlyph:o(i.size.heading,i.lineHeight.tight,t.text.muted),uploadWrap:{paddingHorizontal:r.lg,paddingBottom:r.md,gap:r.sm},list:{paddingHorizontal:r.lg,paddingBottom:r.xxl,gap:r.md},sectionLabel:{...o(i.size.caption,i.lineHeight.normal,t.text.secondary,"bold"),textTransform:"uppercase",letterSpacing:i.letterSpacing.eyebrow/2},fallbackCard:{borderRadius:n.lg-r.xs/2,borderWidth:1,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.md,...Bn(a,1)},fallbackHeader:{flexDirection:"row",alignItems:"center",gap:r.md,minHeight:r.xxl+r.md},fallbackCopy:{flex:1,gap:r.xs/2},fallbackTitle:{...o(i.size.body,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),...s},fallbackSubtitle:{...o(i.size.caption,i.lineHeight.normal,t.text.muted),...s},fallbackForm:{gap:r.sm},item:{borderRadius:n.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm,...Bn(a,1)},itemHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},itemName:{flex:1,...o(i.size.body,i.lineHeight.snug,t.brandInk,"bold"),...headingFace(e,"bold"),...s},itemDistance:{...face(e,"mono"),fontSize:i.size.tiny,lineHeight:i.size.body,color:t.text.muted},itemAddress:{...o(i.size.caption,i.lineHeight.normal,t.text.primary),...s},itemPhone:{...o(i.size.caption,i.lineHeight.normal,t.text.muted),...s},badge:{alignSelf:"flex-start",borderRadius:n.pill,paddingHorizontal:r.sm+1,paddingVertical:r.xs},badgePositive:{backgroundColor:t.badgeBgPositive},badgeCaution:{backgroundColor:t.badgeBgCaution},badgeNeutral:{backgroundColor:t.badgeBgNeutral},badgeLabel:{...o(i.size.micro,i.lineHeight.snug,t.text.muted,"bold")},badgePositiveText:{color:t.success},badgeCautionText:{color:t.cautionAccent},badgeNeutralText:{color:t.text.muted},footer:{gap:r.sm,paddingTop:r.sm},footerLoading:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,minHeight:r.xxl+r.md},footerRetry:{minHeight:r.xxl+r.md,alignItems:"center",justifyContent:"center"},footerRetryLabel:{...o(i.size.bodyTight,i.lineHeight.snug,t.brandInk,"bold")}})}var Wa=/* @__PURE__ */Object.freeze({title:"Request records",resultTitle:"Request status",addClinic:"Add a clinic",atCap:`Up to ${vi} clinics`,send:e=>`Send ${e} ${e===1?"request":"requests"}`,sending:"Sending…",addToContinue:"Add a clinic to continue",tryAgain:"Try again",remove:e=>`Remove ${e}`,emailToAdd:"Email to add",perClinic:"Per-clinic result",sent:"Sent",notSent:"Not sent",allFailed:"We couldn’t send any of these requests. See the details below and try again.",partial:(e,t,r)=>`${e} of ${t} requests sent. ${r} couldn’t be sent.`,allSent:e=>`${e} ${e===1?"request":"requests"} sent.`,responded:(e,t)=>`${e} of ${t} ${t===1?"clinic":"clinics"} responded`});var Ua=25,Ga=5;function Va(e){let[t,r]=i({list:e,shown:Ga}),n=t.list===e?t.shown:Ga,o=l(()=>{r(t=>({list:e,shown:(t.list===e?t.shown:Ga)+Ga}))},[e]);return{visible:e.slice(0,n),hasMore:e.length>n,showMore:o}}var Ka=class extends Error{constructor(){super("Signature upload failed"),this.name="SignatureUploadLegError"}};function Ya(e){return e instanceof Ka}function Xa(e,t,r,n){let i={owner_name:t,pet_name:r,clinic_name:n},l=false,o=e.scopeTemplate.replace(/\{([^{}]+)\}/g,(e,t)=>Object.prototype.hasOwnProperty.call(i,t)?i[t]??"":(l=true,""));return l||/[{}]/.test(o)?null:o}function Qa(e){return e===null||e.emailStatus!=="verified"&&e.emailStatus!=="unverified"}function Ja(e,t,n){let[l,a]=i(e.ownerName),[s,d]=i(""),[c,u]=i(null),[h,p]=i(""),[g,f]=i([]),[m,b]=i([]),[y,v]=i(null),[w,k]=i(null),[x,T]=i(false),[C,_]=i(false),[R,S]=i(null),[z,I]=i(0),D=r(false),H=r(false),L=r(0),P=r(Yt()),O=r(null),$=r(null),B=r(0);o(()=>(D.current=true,H.current=false,T(false),()=>{D.current=false,B.current+=1,L.current+=1,O.current=null,$.current?.abort()}),[t]),o(()=>{let e=true;return v(null),O.current=null,t.getAuthorizationCopy().then(t=>{e&&(t.ok?(v(t.value),k(null)):k(t.error))}).catch(()=>{e&&k(makeEverfurError("internalError"))}),()=>{e=false}},[t,z]),o(()=>{let e=true;return b([]),t.recentClinics({limit:5}).then(t=>{e&&t.ok&&b(t.value.clinics)}).catch(()=>{}),()=>{e=false}},[t]);let j=()=>{O.current=null,k(null)},A=c?.name??s.trim(),E=y?Xa(y,l.trim(),e.petName,A):null,F=Qa(c),q=Va(g),M=!!(y&&E&&l.trim()&&e.petName.trim()&&A&&(!F||/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(h.trim()))&&n),N=async()=>{if(H.current)return;let e=++L.current;_(true);try{let r=await t.searchClinics({query:s.trim(),limit:Ua});if(!D.current||e!==L.current)return;r.ok?(f(r.value.clinics),k(null)):k(r.error)}catch{D.current&&e===L.current&&k(makeEverfurError("internalError"))}finally{D.current&&e===L.current&&_(false)}},W=async()=>{if(H.current||R||!M||!y||!E||!n)return;H.current=true;let r=B.current,i=()=>D.current&&B.current===r;T(true),k(null);try{if(!O.current){$.current=new AbortController;let t=await n({petRef:e.petRef,petName:e.petName,ownerName:l.trim(),clinicName:A,authorizationVersion:y.authorizationVersion,scopeText:E,signal:$.current.signal});if(!i()||t===null)return;let r=c&&(!F||c.emailStatus==="none")?{clinicId:c.id}:{clinicFreeText:A};O.current={petRef:e.petRef,ownerName:l.trim(),authorizationVersion:y.authorizationVersion,...r,...F?{clinicEmail:h.trim().toLowerCase()}:{},...t.signatureId!==void 0?{signatureId:t.signatureId}:{signaturePngBase64:t.signaturePngBase64},idempotencyKey:P.current()}}if(!i())return;let r=await t.createClinicRequest(O.current);if(!i())return;if(!r.ok){k(r.error);return}if(r.value.petRef!==e.petRef){k(makeEverfurError("internalError"));return}S(r.value),O.current=null,e.onCreated?.(r.value)}catch{i()&&k(makeEverfurError("internalError"))}finally{H.current=false,i()&&T(false)}};return{ownerName:l,query:s,clinic:c,email:h,clinics:g,copy:y,scope:E,error:w,busy:x,searching:C,created:R,ready:M,needsEmail:F,visibleClinics:q.visible,hasMoreClinics:q.hasMore,showMoreClinics:q.showMore,recent:g.length===0&&c===null?m:[],setOwnerName(e){H.current||(j(),a(e))},setQuery(e){H.current||(j(),L.current+=1,_(false),f([]),u(null),p(""),d(e))},setEmail(e){H.current||(j(),p(e))},selectClinic(e){H.current||(j(),L.current+=1,_(false),f([]),u(e),d(e.name),p(""))},invalidate:j,search:N,submit:W,retryCopy(){k(null),I(e=>e+1)}}}var Za=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function es(e){return e.clinic?.name??e.freeText??""}function ts(e){return Qa(e.clinic)}function rs(e,t,n,l,a){let[s,d]=i(e.ownerName),[c,u]=i(""),[h,p]=i([]),[g,f]=i([]),[m,b]=i([]),[y,v]=i(null),[w,k]=i(null),[x,T]=i(false),[C,_]=i(false),[R,S]=i(null),[z,I]=i(null),[D,H]=i(0),L=r(false),P=r(false),O=r(0),$=r(0),B=r(Yt()),j=r(null),A=r(null);o(()=>(L.current=true,P.current=false,T(false),()=>{L.current=false,$.current+=1,O.current+=1,j.current=null,A.current?.abort()}),[t,n]),o(()=>{let e=true;return v(null),j.current=null,t.getAuthorizationCopy().then(t=>{e&&(t.ok?(v(t.value),k(null)):k(t.error))}).catch(()=>{e&&k(makeEverfurError("internalError"))}),()=>{e=false}},[t,D]),o(()=>{let e=true;return f([]),t.recentClinics({limit:5}).then(t=>{e&&t.ok&&f(t.value.clinics)}).catch(()=>{}),()=>{e=false}},[t]);let E=Va(h),F=()=>{j.current=null,k(null)},q=m.map(es),M=Qn(e.petName),N=y?q.map(e=>Xa(y,s.trim(),M,e)):[],W=N.every(e=>e!==null)?N.join(`\n\n`):null,U=m.length>0&&m.every(e=>!ts(e)||Za.test(e.email.trim())),G=m.length>=vi,V=!!(y&&W&&s.trim()&&U&&l)&&R===null,K=async()=>{if(P.current)return;let e=++O.current;_(true);try{let r=await t.searchClinics({query:c.trim(),limit:Ua});if(!L.current||e!==O.current)return;r.ok?(p(r.value.clinics),k(null)):k(r.error)}catch{L.current&&e===O.current&&k(makeEverfurError("internalError"))}finally{L.current&&e===O.current&&_(false)}},Y=e=>{P.current||G||R!==null||e.clinic!==null&&m.some(t=>t.clinic?.id===e.clinic?.id)||(F(),b(t=>[...t,{...e,key:B.current(),idempotencyKey:B.current()}]),p([]),u(""))},X=async()=>{if(P.current||R!==null||!V||!y||!W||!l)return;P.current=true;let t=$.current,r=()=>L.current&&$.current===t;T(true),k(null);try{if(j.current===null){A.current=new AbortController;let t=await l({petRef:e.petRef,petName:M,ownerName:s.trim(),clinicName:q.join(", "),authorizationVersion:y.authorizationVersion,scopeText:W,signal:A.current.signal});if(!r()||t===null)return;if(j.current=t,t.signaturePngBase64!==void 0&&a!==void 0){let e=A.current;try{let n=await a(t.signaturePngBase64,e.signal);if(!r())return;j.current={signatureId:n.signatureId}}catch(t){if(!Ya(t)||e.signal.aborted)throw t;if(!r())return}}}let i=j.current,o=m.map(e=>({...e.clinic!==null&&(!ts(e)||e.clinic.emailStatus==="none")?{clinicId:e.clinic.id}:{clinicFreeText:es(e)},...ts(e)?{clinicEmail:e.email.trim().toLowerCase()}:{},...i.signatureId!==void 0?{signatureId:i.signatureId}:{signaturePngBase64:i.signaturePngBase64},idempotencyKey:e.idempotencyKey})),d=await n.createClinicRequestBatch({petRef:e.petRef,ownerName:s.trim(),authorizationVersion:y.authorizationVersion,clinics:o});if(!r())return;if(!d.ok){k(d.error);return}S(d.value),e.onCreated?.(d.value),Q(d.value.requestGroupId,t)}catch{r()&&k(makeEverfurError("internalError"))}finally{P.current=false,r()&&T(false)}},Q=async(r,n)=>{try{let i=await t.getRequestGroup(r);if(!L.current||$.current!==n)return;i.ok&&i.value.petRef===e.petRef&&I(i.value)}catch{}},J=async()=>{R===null||P.current||await Q(R.requestGroupId,$.current)};return{ownerName:s,query:c,clinics:h,copy:y,scopeText:W,error:w,busy:x,searching:C,drafts:m,outcome:R,group:z,ready:V,atCap:G,visibleClinics:E.visible,hasMoreClinics:E.hasMore,showMoreClinics:E.showMore,recent:h.length===0?g.filter(e=>!m.some(t=>t.clinic?.id===e.id)):[],setOwnerName(e){P.current||(F(),d(e))},setQuery(e){P.current||(O.current+=1,_(false),p([]),u(e))},search:K,addClinic(e){Y({clinic:e,freeText:null,email:""})},addFreeText(){let e=c.trim();e.length!==0&&Y({clinic:null,freeText:e,email:""})},setDraftEmail(e,t){P.current||(F(),b(r=>r.map(r=>r.key===e?{...r,email:t}:r)))},removeDraft(e){P.current||R!==null||(F(),b(t=>t.filter(t=>t.key!==e)))},submit:X,refreshGroup:J,retryCopy(){k(null),H(e=>e+1)}}}var ns=/* @__PURE__ */Object.freeze({}),is=100,ls=20;function os(e,t,r,n){return![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}function as(e,t){let a=typeof e=="number",s=r(null),[d,c]=i(null),u=r(null),h=r(null),p=r(true),g=l(()=>{h.current!==null&&clearTimeout(h.current),h.current=null},[]);o(()=>(p.current=true,()=>{p.current=false,g()}),[g]);let f=l(function e(t){s.current?.measureInWindow((r,n)=>{let i=u.current;if(!p.current||i===null)return;let l=os(n,i.y,i.height,S.get("window").height);if(l!==null){c(e=>e!==null&&e.chatTop===l.chatTop&&e.parentTop===l.parentTop?e:l);return}t>=ls||(h.current=setTimeout(()=>{h.current=null,e(t+1)},is))})},[]),m=l(e=>{let{y:t,height:r}=e.nativeEvent.layout;u.current={y:t,height:r},g(),f(0)},[f,g]);return n(()=>{if(!t)return{avoidingProps:ns,probeRef:null,topInWindow:null};let e=d?.parentTop??0;return{avoidingProps:e>0?{keyboardVerticalOffset:e,onLayout:m}:{onLayout:m},probeRef:s,topInWindow:d?.chatTop??null}},[t,a,e,d,m])}function KeyboardOffsetProbe({probeRef:e}){return e===null?null:/* @__PURE__ */B(f,{ref:e,collapsable:false,pointerEvents:"none",style:ss})}var ss=/* @__PURE__ */Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function ds(e){let t=se(e);if(t===null||t.protocol!=="https:"||t.username||t.password||t.port&&t.port!=="443")return false;let r=t.hostname.toLowerCase();return r==="s3.amazonaws.com"||r.endsWith(".s3.amazonaws.com")||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3[.-][a-z0-9-]+\.amazonaws\.com$/.test(r)||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3\.dualstack\.[a-z0-9-]+\.amazonaws\.com$/.test(r)||r==="s3-accelerate.amazonaws.com"||r.endsWith(".s3-accelerate.amazonaws.com")||r==="s3-accelerate.dualstack.amazonaws.com"||r.endsWith(".s3-accelerate.dualstack.amazonaws.com")}var cs="Signature upload failed",us=3e4;function hs(e){let t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}async function registerRnSignature(e,t,r,n){let i=()=>new Error(cs),l=hs(e);if(l<=0||r.aborted)throw i();let o=await t.initiateSignatureUpload(l);if(!o.ok||r.aborted||!ds(o.value.uploadUrl))throw i();let a=new FormData;for(let[e,t]of Object.entries(o.value.uploadFields))a.append(e,t);a.append("file",{uri:`data:image/png;base64,${e}`,name:"signature.png",type:"image/png"});let s=new AbortController,d=()=>s.abort();r.addEventListener("abort",d,{once:true});let c=setTimeout(d,us);try{if(!(await(n??fetch)(o.value.uploadUrl,{method:"POST",body:a,credentials:"omit",signal:s.signal})).ok||r.aborted)throw i()}catch{throw r.aborted?i():new Ka}finally{clearTimeout(c),r.removeEventListener("abort",d)}let u=await t.completeSignatureUpload(o.value.uploadId);if(!u.ok||r.aborted)throw i();return{signatureId:u.value}}var ps=/* @__PURE__ */Object.freeze({width:360,height:120});function gs(e,t){return{width:e,height:t,pixels:new Uint8Array(e*t)}}function fs(e,t,r,n){for(let i=-n;i<=n;i+=1)for(let l=-n;l<=n;l+=1){if(l*l+i*i>n*n+n)continue;let o=t+l,a=r+i;o<0||a<0||o>=e.width||a>=e.height||(e.pixels[a*e.width+o]=1)}}var ms=16384;function bs(e,t){let[r,n]=e;if(!Number.isFinite(r)||!Number.isFinite(n))return null;let i=Math.min(2*t.width,Math.max(-t.width,Math.round(r))),l=Math.min(2*t.height,Math.max(-t.height,Math.round(n)));return[i,l]}function ys(e,t,r,n,i){let[l,o]=t,[a,s]=r,d=Math.abs(a-l),c=-Math.abs(s-o),u=l<a?1:-1,h=o<s?1:-1,p=d+c,g=0;for(;g<i&&(fs(e,l,o,n),g+=1,!(l===a&&o===s));){let e=2*p;e>=c&&(p+=c,l+=u),e<=d&&(p+=d,o+=h)}return g}function rasterizeStrokes(e,t=1){let r=gs(ps.width,ps.height);for(let n of e){let e=[];for(let t of n){let n=bs(t,r);n!==null&&e.push(n)}if(e.length===0)continue;if(e.length===1){let[n,i]=e[0];fs(r,n,i,t);continue}let i=ms;for(let n=1;n<e.length&&i>0;n+=1)i-=ys(r,e[n-1],e[n],t,i)}return r}var vs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,'-",ws="ehhvhhhuhhuhhufgggggfuhhhhhuvgguggvvggugggfggnhhfhhhvhhhv44444v72222ichikokihggggggvhrllhhhhpljhhhehhhhheuhhugggehhhliduhhukihfgge11uv444444hhhhhhehhhhha4hhhllrhhha4ahhhha4444v1248gv00e1fhfgguhhhu00fgggf11fhhhf00ehvgf698s8880fhhf1egguhhhh40c444e20622icggikokic44444e00qllhh00uhhhh00ehhhe0uhhugg0fhhf1100mpggg00fge1u88s889600hhhjd00hhha400hhlla00ha4ah00hhf1e00v248vehjlphe4c4444eeh1248vv2421he26aiv22vgu11he68guhhev124888ehhehheehhf12c00000cc0000c48c480000000v000",ks="0123456789abcdefghijklmnopqrstuv",xs=5,Ts=7,Cs=xs+1;function _s(e,t){let r=vs.indexOf(e);return r<0?0:ks.indexOf(ws.charAt(r*Ts+t))}function rasterizeTypedName(e){let t=gs(ps.width,ps.height),r=e.trim();if(r.length===0)return t;let n=[...r],i=4;for(;i>1&&(n.length*Cs-1)*i>t.width-8;)i-=1;let l=(n.length*Cs-1)*i,o=Math.max(0,Math.floor((t.width-l)/2)),a=Math.floor((t.height-Ts*i)/2);return n.forEach((e,r)=>{let n=o+r*Cs*i;for(let r=0;r<Ts;r+=1){let l=_s(e,r);for(let e=0;e<xs;e+=1)if((l>>xs-1-e&1)!==0)for(let l=0;l<i;l+=1)for(let o=0;o<i;o+=1){let s=n+e*i+o,d=a+r*i+l;s<t.width&&d<t.height&&(t.pixels[d*t.width+s]=1)}}}),t}var Rs=class{constructor(){this.bytes=[];this.acc=0;this.count=0}writeBits(e,t){for(this.acc|=e<<this.count,this.count+=t;this.count>=8;)this.bytes.push(this.acc&255),this.acc>>>=8,this.count-=8}writeCode(e,t){let r=0;for(let n=0;n<t;n+=1)r=r<<1|e>>n&1;this.writeBits(r,t)}finish(){return this.count>0&&this.bytes.push(this.acc&255),Uint8Array.from(this.bytes)}};function Ss(e,t){t<144?e.writeCode(48+t,8):t<256?e.writeCode(400+(t-144),9):t<280?e.writeCode(t-256,7):e.writeCode(192+(t-280),8)}var zs=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],Is=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Ds=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Hs=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];function Ls(e,t,r){let n=zs.length-1;for(;zs[n]>t;)n-=1;Ss(e,257+n),Is[n]>0&&e.writeBits(t-zs[n],Is[n]);let i=Ds.length-1;for(;Ds[i]>r;)i-=1;e.writeCode(i,5),Hs[i]>0&&e.writeBits(r-Ds[i],Hs[i])}var Ps=32768,Os=3,$s=258,Bs=15,js=64;function As(e){let t=new Rs;t.writeBits(1,1),t.writeBits(1,2);let r=new Int32Array(1<<Bs).fill(-1),n=new Int32Array(e.length).fill(-1),i=t=>(e[t]<<10^e[t+1]<<5^e[t+2])&(1<<Bs)-1,l=t=>{if(t+Os>e.length)return;let l=i(t);n[t]=r[l],r[l]=t},o=0;for(;o<e.length;){let a=0,s=0;if(o+Os<=e.length){let t=r[i(o)],l=0,d=Math.min($s,e.length-o);for(;t>=0&&l<js&&o-t<=Ps;){let r=0;for(;r<d&&e[t+r]===e[o+r];)r+=1;if(r>a&&(a=r,s=o-t,r===d))break;t=n[t],l+=1}}if(a>=Os){Ls(t,a,s);for(let e=0;e<a;e+=1)l(o+e);o+=a}else Ss(t,e[o]),l(o),o+=1}return Ss(t,256),t.finish()}function Es(e){let t=1,r=0;for(let n of e)t=(t+n)%65521,r=(r+t)%65521;return(r<<16|t)>>>0}var Fs=null;function qs(e){if(Fs===null){Fs=new Uint32Array(256);for(let e=0;e<256;e+=1){let t=e;for(let e=0;e<8;e+=1)t=t&1?3988292384^t>>>1:t>>>1;Fs[e]=t>>>0}}let t=4294967295;for(let r of e)t=Fs[(t^r)&255]^t>>>8;return(t^4294967295)>>>0}function Ms(e){return[e>>>24&255,e>>>16&255,e>>>8&255,e&255]}function Ns(e,t){let r=Uint8Array.from([...e].map(e=>e.charCodeAt(0))),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),[...Ms(t.length),...n,...Ms(qs(n))]}var Ws="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Us(e){let t="";for(let r=0;r<e.length;r+=3){let n=e[r],i=r+1<e.length?e[r+1]:0,l=r+2<e.length?e[r+2]:0,o=n<<16|i<<8|l;t+=Ws.charAt(o>>18&63)+Ws.charAt(o>>12&63),t+=r+1<e.length?Ws.charAt(o>>6&63):"=",t+=r+2<e.length?Ws.charAt(o&63):"="}return t}function encodeSignaturePng(e){let{width:t,height:r,pixels:n}=e,i=Math.ceil(t/8)+1,l=new Uint8Array(i*r);for(let e=0;e<r;e+=1){let r=e*i;l[r]=0,l.fill(255,r+1,r+i);for(let i=0;i<t;i+=1)if(n[e*t+i]===1){let e=r+1+(i>>3);l[e]=l[e]&~(128>>(i&7))}}let o=As(l),a=new Uint8Array(2+o.length+4);a[0]=120,a[1]=1,a.set(o,2),a.set(Ms(Es(l)),2+o.length);let s=Uint8Array.from([...Ms(t),...Ms(r),1,0,0,0,0]),d=Uint8Array.from([137,80,78,71,13,10,26,10,...Ns("IHDR",s),...Ns("IDAT",a),...Ns("IEND",new Uint8Array(0))]);return Us(d)}var Gs=2.6,Vs="#111111";function Ks(e,t){let r=[];return e.forEach((e,n)=>{let i=r=>{let n=e[r];return[n[0]/t,n[1]/t]};if(e.length===1){let[e,t]=i(0);r.push({key:`${n}-0`,cx:e,cy:t,length:0,angle:0});return}for(let t=1;t<e.length;t+=1){let[e,l]=i(t-1),[o,a]=i(t);r.push({key:`${n}-${t}`,cx:(e+o)/2,cy:(l+a)/2,length:Math.hypot(o-e,a-l),angle:Math.atan2(a-l,o-e)})}}),r}var Ys=8,Xs=2;function SignaturePad({onChange:e,disabled:t=false,mode:a}){let s=Qs(),[d,c]=i("draw"),u=a!==void 0,h=a??d,[p,g]=i(""),[b,y]=i([]),[v,k]=i(0),x=r([]),T=r(null),C=v>0?ps.width/v:1,_=r(C);_.current=C;let R=r(t);R.current=t,o(()=>{if(h==="type"){Xr(e,p.trim().length>0?encodeSignaturePng(rasterizeTypedName(p)):null);return}let t=b.reduce((e,t)=>e+t.length,0);Xr(e,t>=Ys?encodeSignaturePng(rasterizeStrokes(b)):null)},[h,p,b,e]);let S=e=>{let{locationX:t,locationY:r}=e.nativeEvent;return[t*_.current,r*_.current]},z=()=>{let e=x.current,t=T.current;x.current=[],T.current=null,y(r=>[...r.filter(e=>e!==t),e])},I=n(()=>w.create({onStartShouldSetPanResponder:()=>!R.current,onMoveShouldSetPanResponder:()=>!R.current,onPanResponderTerminationRequest:()=>false,onPanResponderGrant:e=>{x.current=[S(e)]},onPanResponderMove:e=>{let t=S(e),r=x.current[x.current.length-1];if(r!==void 0&&Math.abs(r[0]-t[0])<Xs&&Math.abs(r[1]-t[1])<Xs)return;x.current=[...x.current,t];let n=T.current,i=x.current;T.current=i,y(e=>[...e.filter(e=>e!==n),i])},onPanResponderRelease:()=>z(),onPanResponderTerminate:()=>z()}),[]),D=l(()=>{R.current||(x.current=[],T.current=null,y([]),g(""))},[]),H=l(()=>{D(),c(e=>e==="draw"?"type":"draw")},[D]),L=r(h);o(()=>{L.current!==h&&(L.current=h,x.current=[],T.current=null,y([]),g(""))},[h]);let P=e=>k(e.nativeEvent.layout.width),O=b.reduce((e,t)=>e+t.length,0);/* @__PURE__ */
219
+ /* @__PURE__ */B(f,{style:[r.badge,n.tone==="positive"?r.badgePositive:n.tone==="caution"?r.badgeCaution:r.badgeNeutral],accessibilityElementsHidden:true,importantForAccessibility:"no",children:/* @__PURE__ */B(Text,{style:[r.badgeLabel,n.tone==="positive"?r.badgePositiveText:n.tone==="caution"?r.badgeCautionText:r.badgeNeutralText],children:n.label})})]})}function qa(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?Na(e):bo(Na(e),Ma(t)),[e,t])}function Ma(e){return{howCard:mo(e,{marginTop:8}),howTitle:e.cardTitle,item:mo(e,{paddingHorizontal:e.cardPad,paddingVertical:12,gap:8}),fallbackCard:{...mo(e,{paddingHorizontal:e.cardPad,paddingVertical:12}),borderWidth:1,borderStyle:"dashed",borderColor:e.look.line}}}function Na(e){let{color:t,space:r,radius:n,type:i}=e,l=v.hairlineWidth,o=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n}),a=e.slots.card,s=jn(a);return v.create({srOnly:{position:"absolute",width:1,height:1,overflow:"hidden"},lead:{...o(i.size.body,i.lineHeight.normal,t.text.muted),paddingHorizontal:r.lg,paddingBottom:r.md},howCard:{borderRadius:n.lg,backgroundColor:t.surfaceSubtle,padding:r.lg,gap:r.md,marginTop:r.sm,...Bn(a)},howTitle:{...o(i.size.subtitle,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),letterSpacing:-.4,...s},howRow:{flexDirection:"row",gap:r.md},howNumber:{...face(e,"monoBold"),fontSize:i.size.caption,lineHeight:Math.round(i.size.body*i.lineHeight.snug),color:t.brandInk,minWidth:r.xl},howText:{flex:1,gap:r.xs/2},howStepTitle:{...o(i.size.body,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),...s},howStepBody:{...o(i.size.caption,i.lineHeight.normal,t.text.secondary),...s},searchBar:{flexDirection:"row",alignItems:"center",gap:r.sm,paddingHorizontal:r.md+r.xs/2,height:r.xxl+r.md,marginHorizontal:r.lg,marginBottom:r.sm,borderRadius:n.lg+r.xs/2,backgroundColor:t.surfaceSubtle,borderWidth:l,borderColor:t.borderHairlineGreen,...Bn(e.slots.input,l)},searchInput:{flex:1,...o(i.size.body,i.lineHeight.snug,t.text.primary),paddingVertical:0,...jn(e.slots.input)},clearGlyph:o(i.size.heading,i.lineHeight.tight,t.text.muted),uploadWrap:{paddingHorizontal:r.lg,paddingBottom:r.md,gap:r.sm},list:{paddingHorizontal:r.lg,paddingBottom:r.xxl,gap:r.md},sectionLabel:{...o(i.size.caption,i.lineHeight.normal,t.text.secondary,"bold"),textTransform:"uppercase",letterSpacing:i.letterSpacing.eyebrow/2},fallbackCard:{borderRadius:n.lg-r.xs/2,borderWidth:1,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.md,...Bn(a,1)},fallbackHeader:{flexDirection:"row",alignItems:"center",gap:r.md,minHeight:r.xxl+r.md},fallbackCopy:{flex:1,gap:r.xs/2},fallbackTitle:{...o(i.size.body,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),...s},fallbackSubtitle:{...o(i.size.caption,i.lineHeight.normal,t.text.muted),...s},fallbackForm:{gap:r.sm},item:{borderRadius:n.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm,...Bn(a,1)},itemHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},itemName:{flex:1,...o(i.size.body,i.lineHeight.snug,t.brandInk,"bold"),...headingFace(e,"bold"),...s},itemDistance:{...face(e,"mono"),fontSize:i.size.tiny,lineHeight:i.size.body,color:t.text.muted},itemAddress:{...o(i.size.caption,i.lineHeight.normal,t.text.primary),...s},itemPhone:{...o(i.size.caption,i.lineHeight.normal,t.text.muted),...s},badge:{alignSelf:"flex-start",borderRadius:n.pill,paddingHorizontal:r.sm+1,paddingVertical:r.xs},badgePositive:{backgroundColor:t.badgeBgPositive},badgeCaution:{backgroundColor:t.badgeBgCaution},badgeNeutral:{backgroundColor:t.badgeBgNeutral},badgeLabel:{...o(i.size.micro,i.lineHeight.snug,t.text.muted,"bold")},badgePositiveText:{color:t.success},badgeCautionText:{color:t.cautionAccent},badgeNeutralText:{color:t.text.muted},footer:{gap:r.sm,paddingTop:r.sm},footerLoading:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,minHeight:r.xxl+r.md},footerRetry:{minHeight:r.xxl+r.md,alignItems:"center",justifyContent:"center"},footerRetryLabel:{...o(i.size.bodyTight,i.lineHeight.snug,t.brandInk,"bold")}})}var Wa=/* @__PURE__ */Object.freeze({title:"Request records",resultTitle:"Request status",addClinic:"Add a clinic",atCap:`Up to ${vi} clinics`,send:e=>`Send ${e} ${e===1?"request":"requests"}`,sending:"Sending…",addToContinue:"Add a clinic to continue",tryAgain:"Try again",remove:e=>`Remove ${e}`,emailToAdd:"Email to add",perClinic:"Per-clinic result",sent:"Sent",notSent:"Not sent",allFailed:"We couldn’t send any of these requests. See the details below and try again.",partial:(e,t,r)=>`${e} of ${t} requests sent. ${r} couldn’t be sent.`,allSent:e=>`${e} ${e===1?"request":"requests"} sent.`,responded:(e,t)=>`${e} of ${t} ${t===1?"clinic":"clinics"} responded`});var Ua=25,Ga=5;function Va(e){let[t,r]=i({list:e,shown:Ga}),n=t.list===e?t.shown:Ga,o=l(()=>{r(t=>({list:e,shown:(t.list===e?t.shown:Ga)+Ga}))},[e]);return{visible:e.slice(0,n),hasMore:e.length>n,showMore:o}}var Ka=class extends Error{constructor(){super("Signature upload failed"),this.name="SignatureUploadLegError"}};function Ya(e){return e instanceof Ka}function Xa(e,t,r,n){let i={owner_name:t,pet_name:r,clinic_name:n},l=false,o=e.scopeTemplate.replace(/\{([^{}]+)\}/g,(e,t)=>Object.prototype.hasOwnProperty.call(i,t)?i[t]??"":(l=true,""));return l||/[{}]/.test(o)?null:o}function Qa(e){return e===null||e.emailStatus!=="verified"&&e.emailStatus!=="unverified"}function Ja(e,t,n){let[l,a]=i(e.ownerName),[s,d]=i(""),[c,u]=i(null),[h,p]=i(""),[g,f]=i([]),[m,b]=i([]),[y,v]=i(null),[w,k]=i(null),[x,T]=i(false),[_,C]=i(false),[R,S]=i(null),[z,I]=i(0),D=r(false),H=r(false),L=r(0),P=r(Yt()),O=r(null),$=r(null),B=r(0);o(()=>(D.current=true,H.current=false,T(false),()=>{D.current=false,B.current+=1,L.current+=1,O.current=null,$.current?.abort()}),[t]),o(()=>{let e=true;return v(null),O.current=null,t.getAuthorizationCopy().then(t=>{e&&(t.ok?(v(t.value),k(null)):k(t.error))}).catch(()=>{e&&k(makeEverfurError("internalError"))}),()=>{e=false}},[t,z]),o(()=>{let e=true;return b([]),t.recentClinics({limit:5}).then(t=>{e&&t.ok&&b(t.value.clinics)}).catch(()=>{}),()=>{e=false}},[t]);let j=()=>{O.current=null,k(null)},A=c?.name??s.trim(),E=y?Xa(y,l.trim(),e.petName,A):null,F=Qa(c),q=Va(g),M=!!(y&&E&&l.trim()&&e.petName.trim()&&A&&(!F||/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(h.trim()))&&n),N=async()=>{if(H.current)return;let e=++L.current;C(true);try{let r=await t.searchClinics({query:s.trim(),limit:Ua});if(!D.current||e!==L.current)return;r.ok?(f(r.value.clinics),k(null)):k(r.error)}catch{D.current&&e===L.current&&k(makeEverfurError("internalError"))}finally{D.current&&e===L.current&&C(false)}},W=async()=>{if(H.current||R||!M||!y||!E||!n)return;H.current=true;let r=B.current,i=()=>D.current&&B.current===r;T(true),k(null);try{if(!O.current){$.current=new AbortController;let t=await n({petRef:e.petRef,petName:e.petName,ownerName:l.trim(),clinicName:A,authorizationVersion:y.authorizationVersion,scopeText:E,signal:$.current.signal});if(!i()||t===null)return;let r=c&&(!F||c.emailStatus==="none")?{clinicId:c.id}:{clinicFreeText:A};O.current={petRef:e.petRef,ownerName:l.trim(),authorizationVersion:y.authorizationVersion,...r,...F?{clinicEmail:h.trim().toLowerCase()}:{},...t.signatureId!==void 0?{signatureId:t.signatureId}:{signaturePngBase64:t.signaturePngBase64},idempotencyKey:P.current()}}if(!i())return;let r=await t.createClinicRequest(O.current);if(!i())return;if(!r.ok){k(r.error);return}if(r.value.petRef!==e.petRef){k(makeEverfurError("internalError"));return}S(r.value),O.current=null,e.onCreated?.(r.value)}catch{i()&&k(makeEverfurError("internalError"))}finally{H.current=false,i()&&T(false)}};return{ownerName:l,query:s,clinic:c,email:h,clinics:g,copy:y,scope:E,error:w,busy:x,searching:_,created:R,ready:M,needsEmail:F,visibleClinics:q.visible,hasMoreClinics:q.hasMore,showMoreClinics:q.showMore,recent:g.length===0&&c===null?m:[],setOwnerName(e){H.current||(j(),a(e))},setQuery(e){H.current||(j(),L.current+=1,C(false),f([]),u(null),p(""),d(e))},setEmail(e){H.current||(j(),p(e))},selectClinic(e){H.current||(j(),L.current+=1,C(false),f([]),u(e),d(e.name),p(""))},invalidate:j,search:N,submit:W,retryCopy(){k(null),I(e=>e+1)}}}var Za=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function es(e){return e.clinic?.name??e.freeText??""}function ts(e){return Qa(e.clinic)}function rs(e,t,n,l,a){let[s,d]=i(e.ownerName),[c,u]=i(""),[h,p]=i([]),[g,f]=i([]),[m,b]=i([]),[y,v]=i(null),[w,k]=i(null),[x,T]=i(false),[_,C]=i(false),[R,S]=i(null),[z,I]=i(null),[D,H]=i(0),L=r(false),P=r(false),O=r(0),$=r(0),B=r(Yt()),j=r(null),A=r(null);o(()=>(L.current=true,P.current=false,T(false),()=>{L.current=false,$.current+=1,O.current+=1,j.current=null,A.current?.abort()}),[t,n]),o(()=>{let e=true;return v(null),j.current=null,t.getAuthorizationCopy().then(t=>{e&&(t.ok?(v(t.value),k(null)):k(t.error))}).catch(()=>{e&&k(makeEverfurError("internalError"))}),()=>{e=false}},[t,D]),o(()=>{let e=true;return f([]),t.recentClinics({limit:5}).then(t=>{e&&t.ok&&f(t.value.clinics)}).catch(()=>{}),()=>{e=false}},[t]);let E=Va(h),F=()=>{j.current=null,k(null)},q=m.map(es),M=Qn(e.petName),N=y?q.map(e=>Xa(y,s.trim(),M,e)):[],W=N.every(e=>e!==null)?N.join(`\n\n`):null,U=m.length>0&&m.every(e=>!ts(e)||Za.test(e.email.trim())),G=m.length>=vi,V=!!(y&&W&&s.trim()&&U&&l)&&R===null,K=async()=>{if(P.current)return;let e=++O.current;C(true);try{let r=await t.searchClinics({query:c.trim(),limit:Ua});if(!L.current||e!==O.current)return;r.ok?(p(r.value.clinics),k(null)):k(r.error)}catch{L.current&&e===O.current&&k(makeEverfurError("internalError"))}finally{L.current&&e===O.current&&C(false)}},Y=e=>{P.current||G||R!==null||e.clinic!==null&&m.some(t=>t.clinic?.id===e.clinic?.id)||(F(),b(t=>[...t,{...e,key:B.current(),idempotencyKey:B.current()}]),p([]),u(""))},X=async()=>{if(P.current||R!==null||!V||!y||!W||!l)return;P.current=true;let t=$.current,r=()=>L.current&&$.current===t;T(true),k(null);try{if(j.current===null){A.current=new AbortController;let t=await l({petRef:e.petRef,petName:M,ownerName:s.trim(),clinicName:q.join(", "),authorizationVersion:y.authorizationVersion,scopeText:W,signal:A.current.signal});if(!r()||t===null)return;if(j.current=t,t.signaturePngBase64!==void 0&&a!==void 0){let e=A.current;try{let n=await a(t.signaturePngBase64,e.signal);if(!r())return;j.current={signatureId:n.signatureId}}catch(t){if(!Ya(t)||e.signal.aborted)throw t;if(!r())return}}}let i=j.current,o=m.map(e=>({...e.clinic!==null&&(!ts(e)||e.clinic.emailStatus==="none")?{clinicId:e.clinic.id}:{clinicFreeText:es(e)},...ts(e)?{clinicEmail:e.email.trim().toLowerCase()}:{},...i.signatureId!==void 0?{signatureId:i.signatureId}:{signaturePngBase64:i.signaturePngBase64},idempotencyKey:e.idempotencyKey})),d=await n.createClinicRequestBatch({petRef:e.petRef,ownerName:s.trim(),authorizationVersion:y.authorizationVersion,clinics:o});if(!r())return;if(!d.ok){k(d.error);return}S(d.value),e.onCreated?.(d.value),Q(d.value.requestGroupId,t)}catch{r()&&k(makeEverfurError("internalError"))}finally{P.current=false,r()&&T(false)}},Q=async(r,n)=>{try{let i=await t.getRequestGroup(r);if(!L.current||$.current!==n)return;i.ok&&i.value.petRef===e.petRef&&I(i.value)}catch{}},J=async()=>{R===null||P.current||await Q(R.requestGroupId,$.current)};return{ownerName:s,query:c,clinics:h,copy:y,scopeText:W,error:w,busy:x,searching:_,drafts:m,outcome:R,group:z,ready:V,atCap:G,visibleClinics:E.visible,hasMoreClinics:E.hasMore,showMoreClinics:E.showMore,recent:h.length===0?g.filter(e=>!m.some(t=>t.clinic?.id===e.id)):[],setOwnerName(e){P.current||(F(),d(e))},setQuery(e){P.current||(O.current+=1,C(false),p([]),u(e))},search:K,addClinic(e){Y({clinic:e,freeText:null,email:""})},addFreeText(){let e=c.trim();e.length!==0&&Y({clinic:null,freeText:e,email:""})},setDraftEmail(e,t){P.current||(F(),b(r=>r.map(r=>r.key===e?{...r,email:t}:r)))},removeDraft(e){P.current||R!==null||(F(),b(t=>t.filter(t=>t.key!==e)))},submit:X,refreshGroup:J,retryCopy(){k(null),H(e=>e+1)}}}var ns=/* @__PURE__ */Object.freeze({}),is=100,ls=20;function os(e,t,r,n){return![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}function as(e,t){let a=typeof e=="number",s=r(null),[d,c]=i(null),u=r(null),h=r(null),p=r(true),g=l(()=>{h.current!==null&&clearTimeout(h.current),h.current=null},[]);o(()=>(p.current=true,()=>{p.current=false,g()}),[g]);let f=l(function e(t){s.current?.measureInWindow((r,n)=>{let i=u.current;if(!p.current||i===null)return;let l=os(n,i.y,i.height,S.get("window").height);if(l!==null){c(e=>e!==null&&e.chatTop===l.chatTop&&e.parentTop===l.parentTop?e:l);return}t>=ls||(h.current=setTimeout(()=>{h.current=null,e(t+1)},is))})},[]),m=l(e=>{let{y:t,height:r}=e.nativeEvent.layout;u.current={y:t,height:r},g(),f(0)},[f,g]);return n(()=>{if(!t)return{avoidingProps:ns,probeRef:null,topInWindow:null};let e=d?.parentTop??0;return{avoidingProps:e>0?{keyboardVerticalOffset:e,onLayout:m}:{onLayout:m},probeRef:s,topInWindow:d?.chatTop??null}},[t,a,e,d,m])}function KeyboardOffsetProbe({probeRef:e}){return e===null?null:/* @__PURE__ */B(f,{ref:e,collapsable:false,pointerEvents:"none",style:ss})}var ss=/* @__PURE__ */Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function ds(e){let t=se(e);if(t===null||t.protocol!=="https:"||t.username||t.password||t.port&&t.port!=="443")return false;let r=t.hostname.toLowerCase();return r==="s3.amazonaws.com"||r.endsWith(".s3.amazonaws.com")||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3[.-][a-z0-9-]+\.amazonaws\.com$/.test(r)||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3\.dualstack\.[a-z0-9-]+\.amazonaws\.com$/.test(r)||r==="s3-accelerate.amazonaws.com"||r.endsWith(".s3-accelerate.amazonaws.com")||r==="s3-accelerate.dualstack.amazonaws.com"||r.endsWith(".s3-accelerate.dualstack.amazonaws.com")}var cs="Signature upload failed",us=3e4;function hs(e){let t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}async function registerRnSignature(e,t,r,n){let i=()=>new Error(cs),l=hs(e);if(l<=0||r.aborted)throw i();let o=await t.initiateSignatureUpload(l);if(!o.ok||r.aborted||!ds(o.value.uploadUrl))throw i();let a=new FormData;for(let[e,t]of Object.entries(o.value.uploadFields))a.append(e,t);a.append("file",{uri:`data:image/png;base64,${e}`,name:"signature.png",type:"image/png"});let s=new AbortController,d=()=>s.abort();r.addEventListener("abort",d,{once:true});let c=setTimeout(d,us);try{if(!(await(n??fetch)(o.value.uploadUrl,{method:"POST",body:a,credentials:"omit",signal:s.signal})).ok||r.aborted)throw i()}catch{throw r.aborted?i():new Ka}finally{clearTimeout(c),r.removeEventListener("abort",d)}let u=await t.completeSignatureUpload(o.value.uploadId);if(!u.ok||r.aborted)throw i();return{signatureId:u.value}}var ps=/* @__PURE__ */Object.freeze({width:360,height:120});function gs(e,t){return{width:e,height:t,pixels:new Uint8Array(e*t)}}function fs(e,t,r,n){for(let i=-n;i<=n;i+=1)for(let l=-n;l<=n;l+=1){if(l*l+i*i>n*n+n)continue;let o=t+l,a=r+i;o<0||a<0||o>=e.width||a>=e.height||(e.pixels[a*e.width+o]=1)}}var ms=16384;function bs(e,t){let[r,n]=e;if(!Number.isFinite(r)||!Number.isFinite(n))return null;let i=Math.min(2*t.width,Math.max(-t.width,Math.round(r))),l=Math.min(2*t.height,Math.max(-t.height,Math.round(n)));return[i,l]}function ys(e,t,r,n,i){let[l,o]=t,[a,s]=r,d=Math.abs(a-l),c=-Math.abs(s-o),u=l<a?1:-1,h=o<s?1:-1,p=d+c,g=0;for(;g<i&&(fs(e,l,o,n),g+=1,!(l===a&&o===s));){let e=2*p;e>=c&&(p+=c,l+=u),e<=d&&(p+=d,o+=h)}return g}function rasterizeStrokes(e,t=1){let r=gs(ps.width,ps.height);for(let n of e){let e=[];for(let t of n){let n=bs(t,r);n!==null&&e.push(n)}if(e.length===0)continue;if(e.length===1){let[n,i]=e[0];fs(r,n,i,t);continue}let i=ms;for(let n=1;n<e.length&&i>0;n+=1)i-=ys(r,e[n-1],e[n],t,i)}return r}var vs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,'-",ws="ehhvhhhuhhuhhufgggggfuhhhhhuvgguggvvggugggfggnhhfhhhvhhhv44444v72222ichikokihggggggvhrllhhhhpljhhhehhhhheuhhugggehhhliduhhukihfgge11uv444444hhhhhhehhhhha4hhhllrhhha4ahhhha4444v1248gv00e1fhfgguhhhu00fgggf11fhhhf00ehvgf698s8880fhhf1egguhhhh40c444e20622icggikokic44444e00qllhh00uhhhh00ehhhe0uhhugg0fhhf1100mpggg00fge1u88s889600hhhjd00hhha400hhlla00ha4ah00hhf1e00v248vehjlphe4c4444eeh1248vv2421he26aiv22vgu11he68guhhev124888ehhehheehhf12c00000cc0000c48c480000000v000",ks="0123456789abcdefghijklmnopqrstuv",xs=5,Ts=7,_s=xs+1;function Cs(e,t){let r=vs.indexOf(e);return r<0?0:ks.indexOf(ws.charAt(r*Ts+t))}function rasterizeTypedName(e){let t=gs(ps.width,ps.height),r=e.trim();if(r.length===0)return t;let n=[...r],i=4;for(;i>1&&(n.length*_s-1)*i>t.width-8;)i-=1;let l=(n.length*_s-1)*i,o=Math.max(0,Math.floor((t.width-l)/2)),a=Math.floor((t.height-Ts*i)/2);return n.forEach((e,r)=>{let n=o+r*_s*i;for(let r=0;r<Ts;r+=1){let l=Cs(e,r);for(let e=0;e<xs;e+=1)if((l>>xs-1-e&1)!==0)for(let l=0;l<i;l+=1)for(let o=0;o<i;o+=1){let s=n+e*i+o,d=a+r*i+l;s<t.width&&d<t.height&&(t.pixels[d*t.width+s]=1)}}}),t}var Rs=class{constructor(){this.bytes=[];this.acc=0;this.count=0}writeBits(e,t){for(this.acc|=e<<this.count,this.count+=t;this.count>=8;)this.bytes.push(this.acc&255),this.acc>>>=8,this.count-=8}writeCode(e,t){let r=0;for(let n=0;n<t;n+=1)r=r<<1|e>>n&1;this.writeBits(r,t)}finish(){return this.count>0&&this.bytes.push(this.acc&255),Uint8Array.from(this.bytes)}};function Ss(e,t){t<144?e.writeCode(48+t,8):t<256?e.writeCode(400+(t-144),9):t<280?e.writeCode(t-256,7):e.writeCode(192+(t-280),8)}var zs=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],Is=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Ds=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Hs=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];function Ls(e,t,r){let n=zs.length-1;for(;zs[n]>t;)n-=1;Ss(e,257+n),Is[n]>0&&e.writeBits(t-zs[n],Is[n]);let i=Ds.length-1;for(;Ds[i]>r;)i-=1;e.writeCode(i,5),Hs[i]>0&&e.writeBits(r-Ds[i],Hs[i])}var Ps=32768,Os=3,$s=258,Bs=15,js=64;function As(e){let t=new Rs;t.writeBits(1,1),t.writeBits(1,2);let r=new Int32Array(1<<Bs).fill(-1),n=new Int32Array(e.length).fill(-1),i=t=>(e[t]<<10^e[t+1]<<5^e[t+2])&(1<<Bs)-1,l=t=>{if(t+Os>e.length)return;let l=i(t);n[t]=r[l],r[l]=t},o=0;for(;o<e.length;){let a=0,s=0;if(o+Os<=e.length){let t=r[i(o)],l=0,d=Math.min($s,e.length-o);for(;t>=0&&l<js&&o-t<=Ps;){let r=0;for(;r<d&&e[t+r]===e[o+r];)r+=1;if(r>a&&(a=r,s=o-t,r===d))break;t=n[t],l+=1}}if(a>=Os){Ls(t,a,s);for(let e=0;e<a;e+=1)l(o+e);o+=a}else Ss(t,e[o]),l(o),o+=1}return Ss(t,256),t.finish()}function Es(e){let t=1,r=0;for(let n of e)t=(t+n)%65521,r=(r+t)%65521;return(r<<16|t)>>>0}var Fs=null;function qs(e){if(Fs===null){Fs=new Uint32Array(256);for(let e=0;e<256;e+=1){let t=e;for(let e=0;e<8;e+=1)t=t&1?3988292384^t>>>1:t>>>1;Fs[e]=t>>>0}}let t=4294967295;for(let r of e)t=Fs[(t^r)&255]^t>>>8;return(t^4294967295)>>>0}function Ms(e){return[e>>>24&255,e>>>16&255,e>>>8&255,e&255]}function Ns(e,t){let r=Uint8Array.from([...e].map(e=>e.charCodeAt(0))),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),[...Ms(t.length),...n,...Ms(qs(n))]}var Ws="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Us(e){let t="";for(let r=0;r<e.length;r+=3){let n=e[r],i=r+1<e.length?e[r+1]:0,l=r+2<e.length?e[r+2]:0,o=n<<16|i<<8|l;t+=Ws.charAt(o>>18&63)+Ws.charAt(o>>12&63),t+=r+1<e.length?Ws.charAt(o>>6&63):"=",t+=r+2<e.length?Ws.charAt(o&63):"="}return t}function encodeSignaturePng(e){let{width:t,height:r,pixels:n}=e,i=Math.ceil(t/8)+1,l=new Uint8Array(i*r);for(let e=0;e<r;e+=1){let r=e*i;l[r]=0,l.fill(255,r+1,r+i);for(let i=0;i<t;i+=1)if(n[e*t+i]===1){let e=r+1+(i>>3);l[e]=l[e]&~(128>>(i&7))}}let o=As(l),a=new Uint8Array(2+o.length+4);a[0]=120,a[1]=1,a.set(o,2),a.set(Ms(Es(l)),2+o.length);let s=Uint8Array.from([...Ms(t),...Ms(r),1,0,0,0,0]),d=Uint8Array.from([137,80,78,71,13,10,26,10,...Ns("IHDR",s),...Ns("IDAT",a),...Ns("IEND",new Uint8Array(0))]);return Us(d)}var Gs=2.6,Vs="#111111";function Ks(e,t){let r=[];return e.forEach((e,n)=>{let i=r=>{let n=e[r];return[n[0]/t,n[1]/t]};if(e.length===1){let[e,t]=i(0);r.push({key:`${n}-0`,cx:e,cy:t,length:0,angle:0});return}for(let t=1;t<e.length;t+=1){let[e,l]=i(t-1),[o,a]=i(t);r.push({key:`${n}-${t}`,cx:(e+o)/2,cy:(l+a)/2,length:Math.hypot(o-e,a-l),angle:Math.atan2(a-l,o-e)})}}),r}var Ys=8,Xs=2;function SignaturePad({onChange:e,disabled:t=false,mode:a}){let s=Qs(),[d,c]=i("draw"),u=a!==void 0,h=a??d,[p,g]=i(""),[b,y]=i([]),[v,k]=i(0),x=r([]),T=r(null),_=v>0?ps.width/v:1,C=r(_);C.current=_;let R=r(t);R.current=t,o(()=>{if(h==="type"){Xr(e,p.trim().length>0?encodeSignaturePng(rasterizeTypedName(p)):null);return}let t=b.reduce((e,t)=>e+t.length,0);Xr(e,t>=Ys?encodeSignaturePng(rasterizeStrokes(b)):null)},[h,p,b,e]);let S=e=>{let{locationX:t,locationY:r}=e.nativeEvent;return[t*C.current,r*C.current]},z=()=>{let e=x.current,t=T.current;x.current=[],T.current=null,y(r=>[...r.filter(e=>e!==t),e])},I=n(()=>w.create({onStartShouldSetPanResponder:()=>!R.current,onMoveShouldSetPanResponder:()=>!R.current,onPanResponderTerminationRequest:()=>false,onPanResponderGrant:e=>{x.current=[S(e)]},onPanResponderMove:e=>{let t=S(e),r=x.current[x.current.length-1];if(r!==void 0&&Math.abs(r[0]-t[0])<Xs&&Math.abs(r[1]-t[1])<Xs)return;x.current=[...x.current,t];let n=T.current,i=x.current;T.current=i,y(e=>[...e.filter(e=>e!==n),i])},onPanResponderRelease:()=>z(),onPanResponderTerminate:()=>z()}),[]),D=l(()=>{R.current||(x.current=[],T.current=null,y([]),g(""))},[]),H=l(()=>{D(),c(e=>e==="draw"?"type":"draw")},[D]),L=r(h);o(()=>{L.current!==h&&(L.current=h,x.current=[],T.current=null,y([]),g(""))},[h]);let P=e=>k(e.nativeEvent.layout.width),O=b.reduce((e,t)=>e+t.length,0);/* @__PURE__ */
220
220
  return j(f,{style:s.container,testID:"records-signature-pad",children:[u?null:/* @__PURE__ */B(Text,{style:s.label,children:h==="draw"?En.draw:En.type}),h==="type"?/* @__PURE__ */B($n,{accessibilityLabel:En.type,style:s.input,value:p,maxLength:100,editable:!t,autoComplete:"off",autoCorrect:false,onChangeText:e=>{R.current||g(e)}}):null,
221
- /* @__PURE__ */B(f,{onLayout:P,style:[s.canvas,{height:v>0?v/3:120}],accessible:true,accessibilityLabel:En.sign,accessibilityRole:"image",testID:"records-signature-canvas",...h==="draw"?I.panHandlers:{},children:h==="type"?/* @__PURE__ */B(Text,{style:s.typedPreview,numberOfLines:1,adjustsFontSizeToFit:true,children:p.trim()}):Ks(b,C).map(e=>{let t=e.length+Gs;/* @__PURE__ */
221
+ /* @__PURE__ */B(f,{onLayout:P,style:[s.canvas,{height:v>0?v/3:120}],accessible:true,accessibilityLabel:En.sign,accessibilityRole:"image",testID:"records-signature-canvas",...h==="draw"?I.panHandlers:{},children:h==="type"?/* @__PURE__ */B(Text,{style:s.typedPreview,numberOfLines:1,adjustsFontSizeToFit:true,children:p.trim()}):Ks(b,_).map(e=>{let t=e.length+Gs;/* @__PURE__ */
222
222
  return B(f,{pointerEvents:"none",style:[s.segment,{width:t,left:e.cx-t/2,top:e.cy-Gs/2,transform:[{rotate:`${e.angle}rad`}]}]},e.key)})}),
223
223
  /* @__PURE__ */B(Text,{style:s.hint,testID:"records-signature-hint",children:O>=Ys||h==="type"?" ":En.drawHint}),
224
224
  /* @__PURE__ */j(f,{style:s.actions,children:[h==="type"?null:/* @__PURE__ */B(m,{accessibilityRole:"button",accessibilityLabel:En.clearA11y,accessibilityState:{disabled:t},disabled:t,onPress:D,style:s.button,testID:"records-signature-clear",children:/* @__PURE__ */B(Text,{style:s.buttonLabel,children:En.clear})}),u?null:/* @__PURE__ */B(m,{accessibilityRole:"button",accessibilityLabel:h==="draw"?En.toType:En.toDraw,accessibilityState:{disabled:t},disabled:t,onPress:H,style:s.button,children:/* @__PURE__ */B(Text,{style:s.buttonLabel,children:h==="draw"?En.toType:En.toDraw})})]})]})}function Qs(){let e=useEverfurTheme();return n(()=>Js(e),[e])}function Js(e){let{color:t,space:r,radius:n,type:i}=e;return v.create({container:{gap:r.sm},label:{...face(e,"regular"),fontSize:i.size.body,color:t.text.primary},input:{minHeight:44,padding:r.sm,borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:n.sm,color:t.text.primary,backgroundColor:t.surface,...face(e,"regular"),fontSize:i.size.body,...Bn(e.slots.input,1),...jn(e.slots.input)},canvas:{width:"100%",backgroundColor:"#ffffff",borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:n.sm,overflow:"hidden",justifyContent:"center"},segment:{position:"absolute",height:Gs,borderRadius:Gs/2,backgroundColor:Vs},typedPreview:{textAlign:"center",fontSize:32,fontStyle:"italic",fontWeight:"700",color:Vs,paddingHorizontal:r.md},hint:{...face(e,"regular"),fontSize:i.size.tiny,color:t.text.muted},actions:{flexDirection:"row",flexWrap:"wrap",gap:r.sm},button:{minHeight:44,paddingHorizontal:r.md,justifyContent:"center",borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:n.sm,backgroundColor:t.surface},buttonLabel:{...face(e,"regular"),fontSize:i.size.body,color:t.text.primary}})}function EverfurClinicRequestBatch(e){let{userRef:userRef,scopeEpoch:t}=Ir();/* @__PURE__ */
225
- return B(CapabilityGate,{capability:"recordsClinic",...Wo(e.onClose,En.cancel),children:userRef===null?/* @__PURE__ */B(Text,{accessibilityRole:"alert",children:Kn.sessionRequired}):/* @__PURE__ */B(BatchBody,{...Zr(e,["onClose","onCreated"])},JSON.stringify([userRef,t,e.petRef,e.petName]))})}var Zs=p.OS==="ios";function ed(e){return[e.address,e.phone].filter(Boolean).join(", ")}function BatchBody(e){let t=useEverfurRecordsClinic(),r=useEverfurRecordsClinicBatch(),n=e.controller??t,[o,a]=i(null),s=l(async()=>o===null?null:{signaturePngBase64:o},[o]),d=l((e,t)=>registerRnSignature(e,n,t),[n]),c=rs(e,n,e.batchClient??r,e.onCaptureSignature??s,e.onCaptureSignature?void 0:d),u=e.onCaptureSignature!==void 0||o!==null,h=useEverfurTheme(),p=Io(),g=td(),y=E(),v=as(void 0,Zs),w=c.busy?Wa.sending:c.drafts.length===0?Wa.addToContinue:c.error?Wa.tryAgain:Wa.send(c.drafts.length),T=c.outcome?Wa.resultTitle:Wa.title,C=!c.busy&&!c.searching&&c.query.trim().length>=2,_=()=>{C&&(x.dismiss(),c.search())},R=(e,t)=>{let r=ed(t);/* @__PURE__ */
225
+ return B(CapabilityGate,{capability:"recordsClinic",...Wo(e.onClose,En.cancel),children:userRef===null?/* @__PURE__ */B(Text,{accessibilityRole:"alert",children:Kn.sessionRequired}):/* @__PURE__ */B(BatchBody,{...Zr(e,["onClose","onCreated"])},JSON.stringify([userRef,t,e.petRef,e.petName]))})}var Zs=p.OS==="ios";function ed(e){return[e.address,e.phone].filter(Boolean).join(", ")}function BatchBody(e){let t=useEverfurRecordsClinic(),r=useEverfurRecordsClinicBatch(),n=e.controller??t,[o,a]=i(null),s=l(async()=>o===null?null:{signaturePngBase64:o},[o]),d=l((e,t)=>registerRnSignature(e,n,t),[n]),c=rs(e,n,e.batchClient??r,e.onCaptureSignature??s,e.onCaptureSignature?void 0:d),u=e.onCaptureSignature!==void 0||o!==null,h=useEverfurTheme(),p=Io(),g=td(),y=E(),v=as(void 0,Zs),w=c.busy?Wa.sending:c.drafts.length===0?Wa.addToContinue:c.error?Wa.tryAgain:Wa.send(c.drafts.length),T=c.outcome?Wa.resultTitle:Wa.title,_=!c.busy&&!c.searching&&c.query.trim().length>=2,C=()=>{_&&(x.dismiss(),c.search())},R=(e,t)=>{let r=ed(t);/* @__PURE__ */
226
226
  return j(m,{accessibilityRole:"button",accessibilityLabel:[t.name,r].filter(Boolean).join(", "),accessibilityState:{disabled:c.busy},disabled:c.busy,onPress:()=>c.addClinic(t),style:[g.option,c.busy?p.pillDisabled:null],children:[
227
227
  /* @__PURE__ */B(Text,{style:g.optionName,children:t.name}),r?/* @__PURE__ */B(Text,{style:p.muted,children:r}):null]},e)};/* @__PURE__ */
228
228
  return j(f,{accessibilityLabel:T,style:[p.root,e.style],children:[
@@ -245,21 +245,21 @@ return j(f,{style:g.option,accessible:true,accessibilityRole:"text",accessibilit
245
245
  /* @__PURE__ */B(Pill,{label:Wa.remove(es(e)),kind:"link",disabled:c.busy,onPress:()=>c.removeDraft(e.key),style:g.remove})]},e.key)),
246
246
  /* @__PURE__ */j(f,{style:g.block,children:[
247
247
  /* @__PURE__ */B(Text,{accessibilityRole:"header",style:g.sectionTitle,children:c.atCap?Wa.atCap:Wa.addClinic}),!c.atCap&&/* @__PURE__ */j(A,{children:[
248
- /* @__PURE__ */B($n,{accessibilityLabel:En.clinic,style:p.field,value:c.query,placeholder:En.placeholder,placeholderTextColor:h.color.text.placeholder,maxLength:200,editable:!c.busy,autoCorrect:false,autoCapitalize:"words",returnKeyType:"search",onSubmitEditing:_,onChangeText:c.setQuery,testID:"records-batch-search-input"}),
249
- /* @__PURE__ */B(Pill,{label:En.search,kind:"outline",disabled:!C,onPress:_,testID:"records-batch-search"}),c.query.trim().length>0&&c.clinics.length===0&&!c.searching?/* @__PURE__ */B(Pill,{label:Wa.addClinic,kind:"link",disabled:c.busy,onPress:c.addFreeText,testID:"records-batch-add-typed"}):null,c.searching?/* @__PURE__ */B(Text,{accessibilityLiveRegion:"polite",style:p.muted,children:Kn.loading}):null,c.recent.length>0?/* @__PURE__ */B(Text,{accessibilityRole:"header",style:p.fieldLabel,children:En.recentlyUsed}):null,c.recent.map(e=>R(`recent-${e.id}`,e)),c.visibleClinics.map(e=>R(e.id,e)),c.hasMoreClinics?/* @__PURE__ */B(Pill,{label:En.moreClinics,kind:"link",disabled:c.busy,onPress:c.showMoreClinics,testID:"records-clinic-results-more"}):null]})]}),
248
+ /* @__PURE__ */B($n,{accessibilityLabel:En.clinic,style:p.field,value:c.query,placeholder:En.placeholder,placeholderTextColor:h.color.text.placeholder,maxLength:200,editable:!c.busy,autoCorrect:false,autoCapitalize:"words",returnKeyType:"search",onSubmitEditing:C,onChangeText:c.setQuery,testID:"records-batch-search-input"}),
249
+ /* @__PURE__ */B(Pill,{label:En.search,kind:"outline",disabled:!_,onPress:C,testID:"records-batch-search"}),c.query.trim().length>0&&c.clinics.length===0&&!c.searching?/* @__PURE__ */B(Pill,{label:Wa.addClinic,kind:"link",disabled:c.busy,onPress:c.addFreeText,testID:"records-batch-add-typed"}):null,c.searching?/* @__PURE__ */B(Text,{accessibilityLiveRegion:"polite",style:p.muted,children:Kn.loading}):null,c.recent.length>0?/* @__PURE__ */B(Text,{accessibilityRole:"header",style:p.fieldLabel,children:En.recentlyUsed}):null,c.recent.map(e=>R(`recent-${e.id}`,e)),c.visibleClinics.map(e=>R(e.id,e)),c.hasMoreClinics?/* @__PURE__ */B(Pill,{label:En.moreClinics,kind:"link",disabled:c.busy,onPress:c.showMoreClinics,testID:"records-clinic-results-more"}):null]})]}),
250
250
  /* @__PURE__ */j(f,{style:g.scopeCard,accessibilityRole:"summary",testID:"records-batch-scope",children:[
251
251
  /* @__PURE__ */B(Text,{accessibilityRole:"header",style:g.sectionTitle,children:En.scopeHeading}),c.copy?c.drafts.length>0&&c.ownerName.trim()?/* @__PURE__ */B(Text,{style:g.scopeText,testID:"records-batch-scope-text",children:c.scopeText??makeEverfurError("internalError").displayMessage}):null:!c.error&&/* @__PURE__ */B(Text,{accessibilityLiveRegion:"polite",style:p.muted,children:Kn.loading})]}),!e.onCaptureSignature&&/* @__PURE__ */B(SignaturePad,{onChange:a,disabled:c.busy}),!u&&c.ready&&/* @__PURE__ */B(Text,{accessibilityRole:"alert",style:p.bodyText,children:En.missingSignature}),c.error&&/* @__PURE__ */B(f,{style:p.errorBanner,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",children:/* @__PURE__ */B(Text,{style:p.errorText,children:c.error.displayMessage})}),!c.copy&&c.error&&/* @__PURE__ */B(Pill,{label:Kn.retry,kind:"outline",onPress:c.retryCopy})]}),
252
252
  /* @__PURE__ */B(RecordsFootnote,{})]}),c.outcome?null:/* @__PURE__ */B(f,{style:[g.footer,{paddingBottom:Math.max(y.bottom,h.space.md)}],testID:"records-batch-footer",children:/* @__PURE__ */B(Pill,{label:w,disabled:c.busy||!c.ready||!u,busy:c.busy,onPress:()=>{x.dismiss(),c.submit()},testID:"records-batch-send"})})]})]})}function td(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?nd(e):bo(nd(e),rd(t)),[e,t])}function rd(e){return{option:mo(e,{paddingHorizontal:e.cardPad,paddingVertical:12,gap:4}),draft:mo(e,{gap:8}),scopeCard:mo(e,{gap:8}),sectionTitle:e.cardTitle,footer:{backgroundColor:e.ground}}}function nd(e){let{color:t,space:r,radius:n,type:i}=e,l=v.hairlineWidth,o=r.xxl+r.md,a=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n});return v.create({header:{flexDirection:"row",alignItems:"center",gap:r.md,paddingHorizontal:r.lg,paddingTop:r.xs,paddingBottom:r.md,...Bn(e.slots.header)},title:{flex:1,...a(i.size.heading,i.lineHeight.snug,t.brandInk,"bold"),...headingFace(e,"bold"),...jn(e.slots.header)},close:{minHeight:o,minWidth:o,alignItems:"center",justifyContent:"center"},closeLabel:a(i.size.body,i.lineHeight.snug,t.linkInk,"bold"),content:{paddingHorizontal:r.lg,paddingBottom:r.xl,gap:r.lg},lead:a(i.size.body,i.lineHeight.normal,t.text.muted),block:{gap:r.sm},sectionTitle:{...a(i.size.subtitle,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold")},option:{minHeight:o,justifyContent:"center",gap:r.xs/2,borderRadius:n.md,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,paddingHorizontal:r.md,paddingVertical:r.sm+r.xs/2,...Bn(e.slots.card,1)},optionName:{...a(i.size.body,i.lineHeight.snug,t.text.primary,"bold"),...jn(e.slots.card)},draft:{gap:r.sm,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,...Bn(e.slots.card,1)},remove:{alignSelf:"flex-start",minHeight:o,paddingHorizontal:0},scopeCard:{borderRadius:n.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surfaceCream,padding:r.lg,gap:r.sm,...Bn(e.slots.card,1)},scopeText:{...a(i.size.bodyTight,i.lineHeight.relaxed,t.text.secondary),...jn(e.slots.card)},footer:{paddingHorizontal:r.lg,paddingTop:r.md,borderTopWidth:l,borderTopColor:t.borderHairlineGreen,backgroundColor:t.background}})}var id=/* @__PURE__ */Object.freeze({scopeHeading:"What we ask for",scopeBody:"You’re asking your pet’s clinic to release their medical records to Everfur, on your behalf, so we can organize them for you.",whatWeDo:/* @__PURE__ */Object.freeze(["We email the clinic a signed copy of this authorization.","When records arrive, our team reviews them before they appear in your app.","You can revoke this request at any time."]),retentionNote:"We keep the records you receive so you always have them. See our Privacy Policy for how records are stored and used.",authorizeLabel:e=>`I’m ${Qn(e)}’s owner. I authorize Everfur to request these records on my behalf.`,missingSignatureError:"Please add your signature before submitting.",missingDraftError:"Something went wrong with your selection. Please go back and pick the clinic again.",newClinicDirectSendNote:"We’ll email this clinic directly to request your pet’s medical records. Clinics usually reply within a week.",titleFreeText:"Check and send",titleDirectory:"Check and send",leadWeb:e=>`The clinic gets a secure request, with your permission to release ${Qn(e)}’s records to Everfur.`,leadNative:"The clinic gets a secure request, with your permission.",whatHappensNext:"What happens next",whatHappensNextBody:"Most clinics respond within 3 to 5 business days. We follow up automatically, and you can cancel any time before the records arrive.",noEmailNote:(e,t)=>`We don’t have an email on file for ${t}. Add it so we can request ${Qn(e)}’s records.`,emailLabel:"Clinic email for records",emailPlaceholder:"records@clinic.com",emailRequired:"Add the clinic’s records email to send the request.",emailInvalid:"That email doesn’t look right. Check it and try again.",reuseSignature:"Reuse a previous signature",reuseHint:"…or sign again below",reuseTileA11y:"Use this earlier signature",reuseTileSelectedA11y:"Earlier signature, selected",signType:"Type your name to sign",signDraw:"Sign with your finger",clear:"Clear",clearA11y:"Clear signature",fullName:"Your full name",fullNamePlaceholder:"Jane Doe",toType:"Can’t draw? Type your name instead",toDraw:"Draw your signature instead",signatureHint:e=>`Your signature is added to the authorization sent to ${e}.`,submit:"Send request",submitting:"Sending…"});var ld="value_text",od=64,ad=512;function isFactReviewerLocked(e){return e!==null&&e.httpStatus===409&&!ht(e)}var sd=/* @__PURE__ */Object.freeze({num:"value_num",date:"value_date",bool:"value_bool",text:ld}),dd=/^[+-]?(?:\d+\.?\d*|\.\d+)$/,cd=/^\d{4}-\d{2}-\d{2}$/;function inferFactValueKind(e){if(e==null)return"text";let t=e.trim();return dd.test(t)?"num":cd.test(t)&&!Number.isNaN(Date.parse(t))?"date":t==="true"||t==="false"?"bool":"text"}function factCorrectionFor(e,t){let r=t.trim(),n=inferFactValueKind(e);if(n==="num"&&dd.test(r)){let e=Number(r);if(Number.isFinite(e))/* @__PURE__ */return Object.freeze({[sd.num]:e})}return n==="date"&&cd.test(r)&&!Number.isNaN(Date.parse(r))?/* @__PURE__ */Object.freeze({[sd.date]:r}):/* @__PURE__ */Object.freeze(n==="bool"&&(r==="true"||r==="false")?{[sd.bool]:r==="true"}:{[sd.text]:r})}var ud=/* @__PURE__ */u.string().nullish(),hd=/* @__PURE__ */u.number().nullish(),pd=/* @__PURE__ */u.object({collected_at:ud,at:ud,value:hd,unit:ud,qualitative_result:ud,ref_low:hd,ref_high:hd,status:ud,source_clinic:ud,source_doc_id:ud,doc_id:ud,reviewed:/* @__PURE__ */u.boolean().nullish()}),gd=/* @__PURE__ */u.object({collected_at:ud,at:ud,value:hd,unit:ud,qualitative_result:ud,status:ud}),fd=/* @__PURE__ */u.object({marker_id:/* @__PURE__ */u.string().min(1),canonical_name:ud,name:ud,loinc_code:ud,canonical_unit:ud,unit:ud,panel_name:ud,panel:ud,meaning_text:ud,meaning:ud,latest:/* @__PURE__ */gd.nullish(),trajectory:ud,points:/* @__PURE__ */u.array(pd).optional()}),md=/* @__PURE__ */u.object({total_markers:/* @__PURE__ */u.number().int().nonnegative(),in_range_count:/* @__PURE__ */u.number().int().nonnegative(),out_of_range_count:/* @__PURE__ */u.number().int().nonnegative(),unknown_count:/* @__PURE__ */u.number().int().nonnegative()}),bd=/* @__PURE__ */u.object({markers:/* @__PURE__ */u.array(fd).optional(),summary:/* @__PURE__ */md.nullish(),disclaimer:/* @__PURE__ */u.string().optional(),featured_marker_id:ud});function yd(e){/* @__PURE__ */
253
253
  return Object.freeze({petRef:e,withheld:true,markers:/* @__PURE__ */Object.freeze([]),summary:null,disclaimer:"",featuredMarkerId:null})}function mapRecordMarkers(petRef,e){let t=Le(e)?e:{},r=typeof t.pet_ref=="string"&&t.pet_ref.length>0?t.pet_ref:petRef;if(t.withheld===true)return yd(r);let n=bd.safeParse(t);if(!n.success)return yd(r);let i=n.data,l=e=>/* @__PURE__ */Object.freeze({at:e.collected_at??e.at??null,value:e.value??null,unit:e.unit??null,qualitativeResult:e.qualitative_result??null,refLow:e.ref_low??null,refHigh:e.ref_high??null,status:e.status??null,sourceClinic:e.source_clinic??null,docId:e.source_doc_id??e.doc_id??null,reviewed:e.reviewed===true}),o=(i.markers??[]).map(e=>/* @__PURE__ */Object.freeze({markerId:e.marker_id,name:e.canonical_name??e.name??e.marker_id,loincCode:e.loinc_code??null,unit:e.canonical_unit??e.unit??null,panel:e.panel_name??e.panel??null,meaning:e.meaning_text??e.meaning??null,latest:e.latest?/* @__PURE__ */Object.freeze({at:e.latest.collected_at??e.latest.at??null,value:e.latest.value??null,unit:e.latest.unit??null,qualitativeResult:e.latest.qualitative_result??null,status:e.latest.status??null}):null,trajectory:e.trajectory??null,points:/* @__PURE__ */Object.freeze((e.points??[]).map(l))}));/* @__PURE__ */
254
254
  return Object.freeze({petRef:r,withheld:false,markers:/* @__PURE__ */Object.freeze(o),summary:i.summary?/* @__PURE__ */Object.freeze({totalMarkers:i.summary.total_markers,inRangeCount:i.summary.in_range_count,outOfRangeCount:i.summary.out_of_range_count,unknownCount:i.summary.unknown_count}):null,disclaimer:i.disclaimer??"",featuredMarkerId:i.featured_marker_id??null})}var vd=/* @__PURE__ */u.string().min(1).refine(e=>e.startsWith("https://")),wd=/* @__PURE__ */u.object({source_doc_id:/* @__PURE__ */u.string().min(1),file_name:/* @__PURE__ */u.string().nullish(),doc_format:/* @__PURE__ */u.string().nullish(),byte_size:/* @__PURE__ */u.number().int().nonnegative().nullish(),received_at:/* @__PURE__ */u.string().nullish(),download_url:vd,expires_in_seconds:/* @__PURE__ */u.number().int().nonnegative().nullish()}),kd=/* @__PURE__ */u.object({items:/* @__PURE__ */u.array(/* @__PURE__ */u.unknown()).optional()});function xd(e){let t=kd.safeParse(e);if(!t.success)return null;let r=[];for(let e of t.data.items??[]){let t=wd.safeParse(e);t.success&&r.push(
255
255
  /* @__PURE__ */Object.freeze({sourceDocId:t.data.source_doc_id,fileName:t.data.file_name??null,docFormat:t.data.doc_format??null,byteSize:t.data.byte_size??null,receivedAt:t.data.received_at??null,downloadUrl:t.data.download_url,expiresInSeconds:t.data.expires_in_seconds??0}))}/* @__PURE__ */
256
- return Object.freeze(r)}var Td=/* @__PURE__ */u.object({signatures:/* @__PURE__ */u.array(/* @__PURE__ */u.object({signature_id:/* @__PURE__ */u.string().min(1),preview_url:/* @__PURE__ */u.string().min(1).refine(e=>e.startsWith("https://")),created_at:/* @__PURE__ */u.string().nullish()})).optional()});function mapSignatureSuggestions(e){let t=Td.safeParse(e);return t.success?/* @__PURE__ */Object.freeze((t.data.signatures??[]).map(e=>/* @__PURE__ */Object.freeze({signatureId:e.signature_id,previewUrl:e.preview_url,createdAt:e.created_at??null}))):null}var Cd=/* @__PURE__ */u.string().nullish(),_d=/* @__PURE__ */u.number().nullish(),Rd=/* @__PURE__ */u.object({at:Cd,value:_d,unit:Cd,qualitative_result:Cd,ref_low:_d,ref_high:_d,status:Cd,doc_id:Cd}),Sd=/* @__PURE__ */u.object({marker_id:/* @__PURE__ */u.string(),name:/* @__PURE__ */u.string(),loinc_code:Cd,unit:Cd,panel:Cd,meaning:Cd,latest:/* @__PURE__ */u.object({at:Cd,value:_d,unit:Cd,qualitative_result:Cd,status:Cd}).nullish(),trajectory:Cd,points:/* @__PURE__ */u.array(Rd).optional()}),zd=/* @__PURE__ */u.object({encounter_id:/* @__PURE__ */u.string(),date:Cd,type:Cd,clinic_name:Cd,veterinarian:Cd,doc_id:Cd}),Id=/* @__PURE__ */u.object({note_id:/* @__PURE__ */u.string(),encounter_id:Cd,observed_on:Cd,sections:/* @__PURE__ */u.array(/* @__PURE__ */u.object({section:/* @__PURE__ */u.string(),text:/* @__PURE__ */u.string()})).optional()}),Dd=/* @__PURE__ */u.object({exam_id:/* @__PURE__ */u.string(),encounter_id:Cd,observed_on:Cd,doc_id:Cd,systems:/* @__PURE__ */u.record(/* @__PURE__ */u.object({finding_status:Cd,finding:Cd})).optional()}),Hd=/* @__PURE__ */u.object({has_lab_history:/* @__PURE__ */u.boolean().optional(),has_vaccination_history:/* @__PURE__ */u.boolean().optional(),has_weight_history:/* @__PURE__ */u.boolean().optional(),has_vitals_history:/* @__PURE__ */u.boolean().optional(),has_physical_exam_history:/* @__PURE__ */u.boolean().optional(),has_procedure_history:/* @__PURE__ */u.boolean().optional(),has_genetic_history:/* @__PURE__ */u.boolean().optional(),has_reproductive_history:/* @__PURE__ */u.boolean().optional(),has_parasite_prevention_history:/* @__PURE__ */u.boolean().optional(),earliest_record_at:Cd,latest_record_at:Cd,documents_ingested:/* @__PURE__ */u.number().int().nonnegative().optional(),documents_in_review:/* @__PURE__ */u.number().int().nonnegative().optional(),entities_pending_review:/* @__PURE__ */u.record(/* @__PURE__ */u.number().int().nonnegative()).optional(),held_total:/* @__PURE__ */u.number().int().nonnegative().optional()}),Ld=/* @__PURE__ */u.object({conflict_id:/* @__PURE__ */u.string(),entity_type:/* @__PURE__ */u.string(),field:Cd,severity:Cd,candidates:/* @__PURE__ */u.array(/* @__PURE__ */u.object({value:/* @__PURE__ */u.string(),source_doc_id:Cd,doc_id:Cd,collected_at:Cd})).optional()}),Pd=/* @__PURE__ */u.object({lab_results:/* @__PURE__ */u.array(Sd).optional(),encounters:/* @__PURE__ */u.array(zd).optional(),clinician_notes:/* @__PURE__ */u.array(Id).optional(),physical_exams:/* @__PURE__ */u.array(Dd).optional(),completeness:/* @__PURE__ */Hd.nullish(),conflicts:/* @__PURE__ */u.array(Ld).optional()}),Od=/* @__PURE__ */u.object({visits:/* @__PURE__ */u.array(/* @__PURE__ */u.object({visit_id:/* @__PURE__ */u.string(),visit_date:Cd,veterinarian:Cd,summary:Cd,doc_id:Cd})),vaccines:/* @__PURE__ */u.array(/* @__PURE__ */u.object({vaccine_id:/* @__PURE__ */u.string(),product:Cd,lot:Cd,administered_on:Cd,expires_on:Cd,doc_id:Cd})),weights:/* @__PURE__ */u.array(/* @__PURE__ */u.object({weight_id:/* @__PURE__ */u.string(),observed_on:Cd,weight_kg:_d,doc_id:Cd})),medications:/* @__PURE__ */u.array(/* @__PURE__ */u.object({medication_id:/* @__PURE__ */u.string(),drug_name:Cd,dose:Cd,route:Cd,frequency:Cd,sig:Cd,rx_number:Cd,started_on:Cd,stopped_on:Cd,doc_id:Cd})),disclaimer:/* @__PURE__ */u.string().optional()}),$d=/* @__PURE__ */u.object({document:Xe,contributions:/* @__PURE__ */u.array(Ge),contribution_count:/* @__PURE__ */u.number().int().nonnegative().optional()});function Bd(e,petRef){return typeof e.pet_ref=="string"&&e.pet_ref.length>0?e.pet_ref:petRef}function jd(e,t){/* @__PURE__ */
256
+ return Object.freeze(r)}var Td=/* @__PURE__ */u.object({signatures:/* @__PURE__ */u.array(/* @__PURE__ */u.object({signature_id:/* @__PURE__ */u.string().min(1),preview_url:/* @__PURE__ */u.string().min(1).refine(e=>e.startsWith("https://")),created_at:/* @__PURE__ */u.string().nullish()})).optional()});function mapSignatureSuggestions(e){let t=Td.safeParse(e);return t.success?/* @__PURE__ */Object.freeze((t.data.signatures??[]).map(e=>/* @__PURE__ */Object.freeze({signatureId:e.signature_id,previewUrl:e.preview_url,createdAt:e.created_at??null}))):null}var _d=/* @__PURE__ */u.string().nullish(),Cd=/* @__PURE__ */u.number().nullish(),Rd=/* @__PURE__ */u.object({at:_d,value:Cd,unit:_d,qualitative_result:_d,ref_low:Cd,ref_high:Cd,status:_d,doc_id:_d}),Sd=/* @__PURE__ */u.object({marker_id:/* @__PURE__ */u.string(),name:/* @__PURE__ */u.string(),loinc_code:_d,unit:_d,panel:_d,meaning:_d,latest:/* @__PURE__ */u.object({at:_d,value:Cd,unit:_d,qualitative_result:_d,status:_d}).nullish(),trajectory:_d,points:/* @__PURE__ */u.array(Rd).optional()}),zd=/* @__PURE__ */u.object({encounter_id:/* @__PURE__ */u.string(),date:_d,type:_d,clinic_name:_d,veterinarian:_d,doc_id:_d}),Id=/* @__PURE__ */u.object({note_id:/* @__PURE__ */u.string(),encounter_id:_d,observed_on:_d,sections:/* @__PURE__ */u.array(/* @__PURE__ */u.object({section:/* @__PURE__ */u.string(),text:/* @__PURE__ */u.string()})).optional()}),Dd=/* @__PURE__ */u.object({exam_id:/* @__PURE__ */u.string(),encounter_id:_d,observed_on:_d,doc_id:_d,systems:/* @__PURE__ */u.record(/* @__PURE__ */u.object({finding_status:_d,finding:_d})).optional()}),Hd=/* @__PURE__ */u.object({has_lab_history:/* @__PURE__ */u.boolean().optional(),has_vaccination_history:/* @__PURE__ */u.boolean().optional(),has_weight_history:/* @__PURE__ */u.boolean().optional(),has_vitals_history:/* @__PURE__ */u.boolean().optional(),has_physical_exam_history:/* @__PURE__ */u.boolean().optional(),has_procedure_history:/* @__PURE__ */u.boolean().optional(),has_genetic_history:/* @__PURE__ */u.boolean().optional(),has_reproductive_history:/* @__PURE__ */u.boolean().optional(),has_parasite_prevention_history:/* @__PURE__ */u.boolean().optional(),earliest_record_at:_d,latest_record_at:_d,documents_ingested:/* @__PURE__ */u.number().int().nonnegative().optional(),documents_in_review:/* @__PURE__ */u.number().int().nonnegative().optional(),entities_pending_review:/* @__PURE__ */u.record(/* @__PURE__ */u.number().int().nonnegative()).optional(),held_total:/* @__PURE__ */u.number().int().nonnegative().optional()}),Ld=/* @__PURE__ */u.object({conflict_id:/* @__PURE__ */u.string(),entity_type:/* @__PURE__ */u.string(),field:_d,severity:_d,candidates:/* @__PURE__ */u.array(/* @__PURE__ */u.object({value:/* @__PURE__ */u.string(),source_doc_id:_d,doc_id:_d,collected_at:_d})).optional()}),Pd=/* @__PURE__ */u.object({lab_results:/* @__PURE__ */u.array(Sd).optional(),encounters:/* @__PURE__ */u.array(zd).optional(),clinician_notes:/* @__PURE__ */u.array(Id).optional(),physical_exams:/* @__PURE__ */u.array(Dd).optional(),completeness:/* @__PURE__ */Hd.nullish(),conflicts:/* @__PURE__ */u.array(Ld).optional()}),Od=/* @__PURE__ */u.object({visits:/* @__PURE__ */u.array(/* @__PURE__ */u.object({visit_id:/* @__PURE__ */u.string(),visit_date:_d,veterinarian:_d,summary:_d,doc_id:_d})),vaccines:/* @__PURE__ */u.array(/* @__PURE__ */u.object({vaccine_id:/* @__PURE__ */u.string(),product:_d,lot:_d,administered_on:_d,expires_on:_d,doc_id:_d})),weights:/* @__PURE__ */u.array(/* @__PURE__ */u.object({weight_id:/* @__PURE__ */u.string(),observed_on:_d,weight_kg:Cd,doc_id:_d})),medications:/* @__PURE__ */u.array(/* @__PURE__ */u.object({medication_id:/* @__PURE__ */u.string(),drug_name:_d,dose:_d,route:_d,frequency:_d,sig:_d,rx_number:_d,started_on:_d,stopped_on:_d,doc_id:_d})),disclaimer:/* @__PURE__ */u.string().optional()}),$d=/* @__PURE__ */u.object({document:Xe,contributions:/* @__PURE__ */u.array(Ge),contribution_count:/* @__PURE__ */u.number().int().nonnegative().optional()});function Bd(e,petRef){return typeof e.pet_ref=="string"&&e.pet_ref.length>0?e.pet_ref:petRef}function jd(e,t){/* @__PURE__ */
257
257
  return Object.freeze({petRef:e,available:false,withheld:t,labResults:/* @__PURE__ */Object.freeze([]),encounters:/* @__PURE__ */Object.freeze([]),clinicianNotes:/* @__PURE__ */Object.freeze([]),physicalExams:/* @__PURE__ */Object.freeze([]),completeness:null,conflicts:/* @__PURE__ */Object.freeze([])})}function mapRecordDepth(petRef,e){let t=Le(e)?e:{},r=Bd(t,petRef);if(t.withheld===true)return jd(r,true);if(!["lab_results","encounters","clinician_notes","physical_exams","completeness","conflicts"].some(e=>e in t))return jd(r,false);let n=Pd.safeParse(t);if(!n.success)return jd(r,true);let i=n.data,l=e=>/* @__PURE__ */Object.freeze({at:e.at??null,value:e.value??null,unit:e.unit??null,qualitativeResult:e.qualitative_result??null,refLow:e.ref_low??null,refHigh:e.ref_high??null,status:e.status??null,docId:e.doc_id??null});/* @__PURE__ */
258
258
  return Object.freeze({petRef:r,available:true,withheld:false,labResults:/* @__PURE__ */Object.freeze((i.lab_results??[]).map(e=>/* @__PURE__ */Object.freeze({markerId:e.marker_id,name:e.name,loincCode:e.loinc_code??null,unit:e.unit??null,panel:e.panel??null,meaning:e.meaning??null,latest:/* @__PURE__ */Object.freeze({at:e.latest?.at??null,value:e.latest?.value??null,unit:e.latest?.unit??null,qualitativeResult:e.latest?.qualitative_result??null,status:e.latest?.status??null}),trajectory:e.trajectory??null,points:/* @__PURE__ */Object.freeze((e.points??[]).map(l))}))),encounters:/* @__PURE__ */Object.freeze((i.encounters??[]).map(e=>/* @__PURE__ */Object.freeze({encounterId:e.encounter_id,date:e.date??null,type:e.type??null,clinicName:e.clinic_name??null,veterinarian:e.veterinarian??null,docId:e.doc_id??null}))),clinicianNotes:/* @__PURE__ */Object.freeze((i.clinician_notes??[]).map(e=>/* @__PURE__ */Object.freeze({noteId:e.note_id,encounterId:e.encounter_id??null,observedOn:e.observed_on??null,sections:/* @__PURE__ */Object.freeze((e.sections??[]).map(e=>/* @__PURE__ */Object.freeze({section:e.section,text:e.text})))}))),physicalExams:/* @__PURE__ */Object.freeze((i.physical_exams??[]).map(e=>/* @__PURE__ */Object.freeze({examId:e.exam_id,encounterId:e.encounter_id??null,observedOn:e.observed_on??null,docId:e.doc_id??null,systems:/* @__PURE__ */Object.freeze(Object.entries(e.systems??{}).map(([e,t])=>/* @__PURE__ */Object.freeze({system:e,findingStatus:t.finding_status??null,finding:t.finding??null})))}))),completeness:i.completeness?/* @__PURE__ */Object.freeze({hasLabHistory:i.completeness.has_lab_history===true,hasVaccinationHistory:i.completeness.has_vaccination_history===true,hasWeightHistory:i.completeness.has_weight_history===true,hasVitalsHistory:i.completeness.has_vitals_history===true,hasPhysicalExamHistory:i.completeness.has_physical_exam_history===true,hasProcedureHistory:i.completeness.has_procedure_history===true,hasGeneticHistory:i.completeness.has_genetic_history===true,hasReproductiveHistory:i.completeness.has_reproductive_history===true,hasParasitePreventionHistory:i.completeness.has_parasite_prevention_history===true,earliestRecordAt:i.completeness.earliest_record_at??null,latestRecordAt:i.completeness.latest_record_at??null,documentsIngested:i.completeness.documents_ingested??0,documentsInReview:i.completeness.documents_in_review??0,entitiesPendingReview:/* @__PURE__ */Object.freeze({...i.completeness.entities_pending_review??{}}),heldTotal:i.completeness.held_total??0}):null,conflicts:/* @__PURE__ */Object.freeze((i.conflicts??[]).map(e=>/* @__PURE__ */Object.freeze({conflictId:e.conflict_id,entityType:e.entity_type,field:e.field??null,severity:e.severity??"needs_review",candidates:/* @__PURE__ */Object.freeze((e.candidates??[]).map(e=>/* @__PURE__ */Object.freeze({value:e.value,docId:e.source_doc_id??e.doc_id??null,collectedAt:e.collected_at??null})))})))})}function Ad(e){/* @__PURE__ */
259
259
  return Object.freeze({petRef:e,withheld:true,isEmpty:false,visits:/* @__PURE__ */Object.freeze([]),vaccines:/* @__PURE__ */Object.freeze([]),weights:/* @__PURE__ */Object.freeze([]),medications:/* @__PURE__ */Object.freeze([]),disclaimer:""})}function mapRecordsTimeline(petRef,e){let t=Le(e)?e:{},r=Bd(t,petRef);if(t.withheld===true)return Ad(r);let n=Od.safeParse(t);if(!n.success)return Ad(r);let i=n.data,l=i.visits.map(e=>/* @__PURE__ */Object.freeze({visitId:e.visit_id,visitDate:e.visit_date??null,veterinarian:e.veterinarian??null,summary:e.summary??null,docId:e.doc_id??null})),o=i.vaccines.map(e=>/* @__PURE__ */Object.freeze({vaccineId:e.vaccine_id,product:e.product??null,lot:e.lot??null,administeredOn:e.administered_on??null,expiresOn:e.expires_on??null,docId:e.doc_id??null})),a=i.weights.map(e=>/* @__PURE__ */Object.freeze({weightId:e.weight_id,observedOn:e.observed_on??null,weightKg:e.weight_kg??null,docId:e.doc_id??null})),s=i.medications.map(e=>/* @__PURE__ */Object.freeze({medicationId:e.medication_id,drugName:e.drug_name??null,dose:e.dose??null,route:e.route??null,frequency:e.frequency??null,sig:e.sig??null,rxNumber:e.rx_number??null,startedOn:e.started_on??null,stoppedOn:e.stopped_on??null,docId:e.doc_id??null}));/* @__PURE__ */
260
260
  return Object.freeze({petRef:r,withheld:false,isEmpty:l.length===0&&o.length===0&&a.length===0&&s.length===0,visits:/* @__PURE__ */Object.freeze(l),vaccines:/* @__PURE__ */Object.freeze(o),weights:/* @__PURE__ */Object.freeze(a),medications:/* @__PURE__ */Object.freeze(s),disclaimer:i.disclaimer??""})}function mapDocumentContributions(petRef,e){let t=Le(e)?e:{},r=Bd(t,petRef),n=()=>/* @__PURE__ */Object.freeze({petRef:r,withheld:true,document:null,contributions:/* @__PURE__ */Object.freeze([]),contributionCount:0});if(t.withheld===true)return n();let i=$d.safeParse(t);if(!i.success)return n();let l=/* @__PURE__ */Object.freeze(i.data.contributions.map(Qe));/* @__PURE__ */
261
- return Object.freeze({petRef:r,withheld:false,document:Je(i.data.document),contributions:l,contributionCount:i.data.contribution_count??l.length})}var Ed="/widget/v1/records/pets";function createRecordsDepthClient(e){let t=fr(e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})),r=(e,t)=>typeof e=="string"&&e.length>0&&!cr(e)&&[...e].length<=t,n=async(e,petRef,n,i)=>{if(!r(petRef,vt))return Fd();let l=await t.send(e,{method:"GET",path:n});if(!l.ok)return l;let o=i(l.value);return o.petRef===petRef?ok(o):err(makeEverfurError("internalError",{retryable:false}))},i=petRef=>`${Ed}/${encodeURIComponent(petRef)}`,l=petRef=>`${i(petRef)}/everfur_record`,o=async(e,r,n)=>{let i=await t.send(e,r,r.method==="POST"?{idempotent:false,maxAttempts:1}:void 0);if(!i.ok)return i;let l=n(i.value);return l===null?err(makeEverfurError("internalError",{retryable:false})):ok(l)},a=(e,t)=>!r(e.entityType,od)||!r(e.canonicalKey,ad)||e.idempotencyKey!==void 0&&!r(e.idempotencyKey,yt)||t!==void 0&&Object.keys(t).length===0?null:{entity_type:e.entityType,canonical_key:e.canonicalKey,...t!==void 0?{corrected_fields:t}:{},...e.idempotencyKey!==void 0?{idempotency_key:e.idempotencyKey}:{}};return{getRecordDepth:petRef=>n("records.depth.record",petRef,`${i(petRef)}/record`,e=>mapRecordDepth(petRef,e)),getTimeline:petRef=>n("records.depth.timeline",petRef,`${i(petRef)}/timeline`,e=>mapRecordsTimeline(petRef,e)),getDocumentContributions(petRef,e){return r(e,64)?n("records.depth.contributions",petRef,`${i(petRef)}/documents/${encodeURIComponent(e)}/contributions`,e=>mapDocumentContributions(petRef,e)):Fd()},getMarkers:petRef=>n("records.depth.markers",petRef,`${i(petRef)}/markers`,e=>mapRecordMarkers(petRef,e)),createShare(petRef,t){if(!r(petRef,vt))return Fd();let n=t?.audience;return n!==void 0&&!pe.includes(n)?Fd():o("records.share.create",{method:"POST",path:`${l(petRef)}/share`,...n!==void 0?{body:{audience:n}}:{}},t=>mapRecordShareLink(t,e.apiBaseUrl))},emailShare(petRef,e){let t=e.recipientKind,n=typeof e.recipientEmail=="string"?e.recipientEmail.trim():"",i=t==="other"||pe.includes(t);return!r(petRef,vt)||!i||!isShareRecipientEmail(n)||cr(n)?Fd():o("records.share.email",{method:"POST",path:`${l(petRef)}/share/email`,body:{recipient_email:n,recipient_kind:t}},mapRecordShareEmailReceipt)},async readFeatures(){try{let e=await t.send("records.getFeatures",{method:"GET",path:"/widget/v1/records/features"});return e.ok?He(e.value):Ie}catch{return Ie}},listShares(petRef){return r(petRef,vt)?o("records.share.list",{method:"GET",path:`${l(petRef)}/shares`},mapRecordShareList):Fd()},async revokeShare(petRef,e){if(!r(petRef,vt)||!r(e,64))return Fd();let n=await t.send("records.share.revoke",{method:"DELETE",path:`${l(petRef)}/shares/${encodeURIComponent(e)}`},{idempotent:false,maxAttempts:1});return n.ok?ok(void 0):n},getPdfLink(petRef){return r(petRef,vt)?o("records.pdf.link",{method:"GET",path:`${l(petRef)}/pdf-link`},mapRecordPdfLink):Fd()},async editFact(petRef,e){let n=r(petRef,vt)?a(e,e.correctedFields):null;if(n===null)return Fd();let i=await t.send("records.fact.edit",{method:"POST",path:`${l(petRef)}/facts/edit`,body:n},{idempotent:false,maxAttempts:1});return i.ok?ok(void 0):i},async removeFact(petRef,e){let n=r(petRef,vt)?a(e):null;if(n===null)return Fd();let i=await t.send("records.fact.remove",{method:"POST",path:`${l(petRef)}/facts/remove`,body:n},{idempotent:false,maxAttempts:1});return i.ok?ok(void 0):i},listRequestDocuments(e){return r(e,64)?o("records.request.documents",{method:"GET",path:`/widget/v1/records/requests/${encodeURIComponent(e)}/documents`},xd):Fd()},listAuthorizationSignatures:()=>o("records.signatures.list",{method:"GET",path:"/widget/v1/records/authorization-signatures"},mapSignatureSuggestions)}}function Fd(){return Promise.resolve(err(makeEverfurError("validationFailed",{retryable:false})))}function useEverfurRecordsDepthClient(){let{runtime:e,userRef:userRef,scopeEpoch:t}=Ir();return n(()=>{let{services:t}=e.registry;return createRecordsDepthClient({auth:t.authFor(userRef),...t.errorPolicy?{errorPolicy:t.errorPolicy}:{},...typeof t.apiBaseUrl=="string"?{apiBaseUrl:t.apiBaseUrl}:{}})},[e,userRef,t])}function useRecordsDepthRead(petRef,e,t,a=""){let s=useEverfurRecordsDepthClient(),{userRef:userRef}=Ir(),d=$r(petRef),c=n(()=>({}),[s,petRef,a,d]),[u,h]=i({scope:c,value:null,error:null,loading:true}),p=r(0),g=l(async()=>{let t=p.current+=1;if(h({scope:c,value:null,error:null,loading:true}),userRef===null){h({scope:c,value:null,error:null,loading:false});return}let r=await e(s,petRef);t===p.current&&(r.ok?h({scope:c,value:r.value,error:null,loading:false}):h({scope:c,value:null,error:r.error,loading:false}))},[s,petRef,e,c,userRef]);o(()=>(g(),()=>{p.current+=1}),[g]);let f=u.scope===c?u:{value:null,error:null,loading:true},m=l(()=>{g()},[g]),b=f.error===null||f.error.httpStatus!==404,y=b?f.error:null,v=f.loading?"loading":y!==null?"error":f.value===null?"empty":f.value.withheld?"populated":t(f.value)?"empty":"populated";return n(()=>({status:v,value:f.value,error:y,available:b,refresh:m}),[v,f.value,y,b,m])}function qd(e){return e!==null&&e.httpStatus===404}var Md=(e,petRef)=>e.getMarkers(petRef),Nd=e=>e.markers.length===0;function useRecordsMarkers(petRef){let e=useRecordsDepthRead(petRef,Md,Nd);return n(()=>{let t=e.available&&e.value!==null&&!e.value.withheld?e.value:null;return{status:e.status,markers:t,available:e.available,error:e.error,refresh:e.refresh}},[e])}var Wd=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function Ud(e){let{clinic:t,controller:n,depthClient:a,capture:s,onCreated:d}=e,c=t.clinic?.name??t.freeText??"",u=t.clinic===null,[h,p]=i(false),[g,f]=i(e.ownerName),[m,b]=i(t.email),[y,v]=i(false),[w,k]=i(null),[x,T]=i(null),[C,_]=i(0),[R,S]=i(null),[z,I]=i(false),[D,H]=i(null),[L,P]=i([]),[O,$]=i(null),[B,j]=i(false),A=r(false),E=r(true),F=r(Yt()),q=r(null);o(()=>(E.current=true,()=>{E.current=false,q.current=null}),[n]),o(()=>{let e=true;return k(null),q.current=null,n.getAuthorizationCopy().then(t=>{e&&(t.ok?(k(t.value),T(null)):T(t.error))}).catch(()=>{e&&T(makeEverfurError("internalError"))}),()=>{e=false}},[n,C]),o(()=>{if(a===void 0)return;let e=true;return a.listAuthorizationSignatures().then(t=>{e&&(t.ok?P(t.value):qd(t.error)||P([]))}).catch(()=>{}),()=>{e=false}},[a]);let M=Qa(t.clinic),N=m.trim().toLowerCase(),W=Wd.test(N),U=M&&(y||N.length>0)&&!W?N.length>0?id.emailInvalid:id.emailRequired:null,G=g.trim().length>0,V=w&&G?Xa(w,g.trim(),Qn(e.petName),c):null,K=e.hostCapture===true||B||O!==null,Y=!!(h&&w&&V&&G&&c&&(!M||W)),X=Y&&K,Q=l(async()=>{if(!(A.current||D!==null||!w||!V)){if(!c){S(id.missingDraftError);return}if(M&&!W){v(true),S(N.length>0?id.emailInvalid:id.emailRequired);return}if(!(!h||!g.trim())){A.current=true,I(true),S(null);try{if(q.current===null){let r=O!==null?{signatureId:O}:await s();if(!E.current)return;if(r===null){S(id.missingSignatureError);return}let n=t.clinic&&(!M||t.clinic.emailStatus==="none")?{clinicId:t.clinic.id}:{clinicFreeText:c};q.current={petRef:e.petRef,ownerName:g.trim(),authorizationVersion:w.authorizationVersion,...n,...M?{clinicEmail:N}:{},...r.signatureId!==void 0?{signatureId:r.signatureId}:{signaturePngBase64:r.signaturePngBase64},idempotencyKey:F.current()}}let r=await n.createClinicRequest(q.current);if(!E.current)return;if(!r.ok){S(r.error.displayMessage);return}if(r.value.petRef!==e.petRef){S(makeEverfurError("internalError").displayMessage);return}H(r.value),q.current=null,d?.(r.value)}catch{E.current&&S(makeEverfurError("internalError").displayMessage)}finally{A.current=false,E.current&&I(false)}}}},[h,s,t.clinic,c,n,w,D,e.petRef,M,N,d,g,O,V,W]),J=l(()=>{q.current=null,S(null)},[]);return{title:u?id.titleFreeText:id.titleDirectory,clinicName:c,isFreeText:u,authorized:h,ownerName:g,email:m,emailError:U,needsEmail:M,directoryClinicNoEmail:M&&t.clinic!==null,copy:w,copyError:x,scope:V,error:R,busy:z,created:D,ready:X,signatures:L,reuseSignatureId:O,hasSignature:K,scopeAwaitingName:w!==null&&!G,signatureLastMissing:Y&&!K,setAuthorized(e){A.current||(J(),p(e))},setOwnerName(e){A.current||(J(),f(e))},setEmail(e){A.current||(J(),v(false),b(e))},setSigned(e){A.current||(J(),j(e),e&&$(null))},pickReuseSignature(e){A.current||(J(),$(e))},retryCopy(){T(null),_(e=>e+1)},submit:Q}}function EverfurRecordsConsent(e){let{userRef:userRef,scopeEpoch:t}=Ir();/* @__PURE__ */
262
- return B(CapabilityGate,{capability:"recordsClinic",style:e.style,...Wo(e.onBack,jo),children:userRef===null?/* @__PURE__ */B(Text,{accessibilityRole:"alert",children:Kn.sessionRequired}):/* @__PURE__ */B(ConsentBody,{...Zr(e,["onCreated","onNavigate","onBack"])},JSON.stringify([userRef,t,e.petRef,e.clinic.key]))})}var Gd=p.OS==="ios";function ConsentBody({petRef:petRef,petName:e,clinic:t,ownerName:n,onCaptureSignature:o,onCreated:a,controller:s,onNavigate:d,onBack:c,style:u}){let h=Io(),p=Vd(),g=useEverfurTheme(),y=useEverfurRecordsClinic(),v=yl()?fl.newClinicDirectSendNote:id.newClinicDirectSendNote,w=useEverfurRecordsDepthClient(),[C,_]=i(null),[R,S]=i("draw"),z=l(async()=>C===null?null:{signaturePngBase64:C},[C]),I=Ud({petRef:petRef,petName:e,ownerName:n??"",clinic:t,controller:s??y,depthClient:w,capture:o?()=>o({petRef:petRef,petName:Qn(e),ownerName:I.ownerName,clinicName:I.clinicName,authorizationVersion:I.copy?.authorizationVersion??"",scopeText:I.scope??"",signal:(new AbortController).signal}):z,hostCapture:o!==void 0,onCreated:e=>{a?.(e),d?.({name:"dashboard"})}}),D=r(I);D.current=I;let H=l(e=>{_(e),D.current.setSigned(e!==null)},[]),L=I.busy,P=as(void 0,Gd);/* @__PURE__ */
261
+ return Object.freeze({petRef:r,withheld:false,document:Je(i.data.document),contributions:l,contributionCount:i.data.contribution_count??l.length})}var Ed="/widget/v1/records/pets";function createRecordsDepthClient(e){let t=fr(e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})),r=(e,t)=>typeof e=="string"&&e.length>0&&!cr(e)&&[...e].length<=t,n=async(e,petRef,n,i)=>{if(!r(petRef,vt))return Fd();let l=await t.send(e,{method:"GET",path:n});if(!l.ok)return l;let o=i(l.value);return o.petRef===petRef?ok(o):err(makeEverfurError("internalError",{retryable:false}))},i=petRef=>`${Ed}/${encodeURIComponent(petRef)}`,l=petRef=>`${i(petRef)}/everfur_record`,o=async(e,r,n)=>{let i=await t.send(e,r,r.method==="POST"?{idempotent:false,maxAttempts:1}:void 0);if(!i.ok)return i;let l=n(i.value);return l===null?err(makeEverfurError("internalError",{retryable:false})):ok(l)},a=(e,t)=>!r(e.entityType,od)||!r(e.canonicalKey,ad)||e.idempotencyKey!==void 0&&!r(e.idempotencyKey,yt)||t!==void 0&&Object.keys(t).length===0?null:{entity_type:e.entityType,canonical_key:e.canonicalKey,...t!==void 0?{corrected_fields:t}:{},...e.idempotencyKey!==void 0?{idempotency_key:e.idempotencyKey}:{}};return{getRecordDepth:petRef=>n("records.depth.record",petRef,`${i(petRef)}/record`,e=>mapRecordDepth(petRef,e)),getTimeline:petRef=>n("records.depth.timeline",petRef,`${i(petRef)}/timeline`,e=>mapRecordsTimeline(petRef,e)),getDocumentContributions(petRef,e){return r(e,64)?n("records.depth.contributions",petRef,`${i(petRef)}/documents/${encodeURIComponent(e)}/contributions`,e=>mapDocumentContributions(petRef,e)):Fd()},getMarkers:petRef=>n("records.depth.markers",petRef,`${i(petRef)}/markers`,e=>mapRecordMarkers(petRef,e)),createShare(petRef,t){if(!r(petRef,vt))return Fd();let n=t?.audience;return n!==void 0&&!pe.includes(n)?Fd():o("records.share.create",{method:"POST",path:`${l(petRef)}/share`,...n!==void 0?{body:{audience:n}}:{}},t=>mapRecordShareLink(t,e.apiBaseUrl))},emailShare(petRef,e){let t=e.recipientKind,n=typeof e.recipientEmail=="string"?e.recipientEmail.trim():"",i=t==="other"||pe.includes(t);return!r(petRef,vt)||!i||!isShareRecipientEmail(n)||cr(n)?Fd():o("records.share.email",{method:"POST",path:`${l(petRef)}/share/email`,body:{recipient_email:n,recipient_kind:t}},mapRecordShareEmailReceipt)},async readFeatures(){try{let e=await t.send("records.getFeatures",{method:"GET",path:"/widget/v1/records/features"});return e.ok?He(e.value):Ie}catch{return Ie}},listShares(petRef){return r(petRef,vt)?o("records.share.list",{method:"GET",path:`${l(petRef)}/shares`},mapRecordShareList):Fd()},async revokeShare(petRef,e){if(!r(petRef,vt)||!r(e,64))return Fd();let n=await t.send("records.share.revoke",{method:"DELETE",path:`${l(petRef)}/shares/${encodeURIComponent(e)}`},{idempotent:false,maxAttempts:1});return n.ok?ok(void 0):n},getPdfLink(petRef){return r(petRef,vt)?o("records.pdf.link",{method:"GET",path:`${l(petRef)}/pdf-link`},mapRecordPdfLink):Fd()},async editFact(petRef,e){let n=r(petRef,vt)?a(e,e.correctedFields):null;if(n===null)return Fd();let i=await t.send("records.fact.edit",{method:"POST",path:`${l(petRef)}/facts/edit`,body:n},{idempotent:false,maxAttempts:1});return i.ok?ok(void 0):i},async removeFact(petRef,e){let n=r(petRef,vt)?a(e):null;if(n===null)return Fd();let i=await t.send("records.fact.remove",{method:"POST",path:`${l(petRef)}/facts/remove`,body:n},{idempotent:false,maxAttempts:1});return i.ok?ok(void 0):i},listRequestDocuments(e){return r(e,64)?o("records.request.documents",{method:"GET",path:`/widget/v1/records/requests/${encodeURIComponent(e)}/documents`},xd):Fd()},listAuthorizationSignatures:()=>o("records.signatures.list",{method:"GET",path:"/widget/v1/records/authorization-signatures"},mapSignatureSuggestions)}}function Fd(){return Promise.resolve(err(makeEverfurError("validationFailed",{retryable:false})))}function useEverfurRecordsDepthClient(){let{runtime:e,userRef:userRef,scopeEpoch:t}=Ir();return n(()=>{let{services:t}=e.registry;return createRecordsDepthClient({auth:t.authFor(userRef),...t.errorPolicy?{errorPolicy:t.errorPolicy}:{},...typeof t.apiBaseUrl=="string"?{apiBaseUrl:t.apiBaseUrl}:{}})},[e,userRef,t])}function useRecordsDepthRead(petRef,e,t,a=""){let s=useEverfurRecordsDepthClient(),{userRef:userRef}=Ir(),d=$r(petRef),c=n(()=>({}),[s,petRef,a,d]),[u,h]=i({scope:c,value:null,error:null,loading:true}),p=r(0),g=l(async()=>{let t=p.current+=1;if(h({scope:c,value:null,error:null,loading:true}),userRef===null){h({scope:c,value:null,error:null,loading:false});return}let r=await e(s,petRef);t===p.current&&(r.ok?h({scope:c,value:r.value,error:null,loading:false}):h({scope:c,value:null,error:r.error,loading:false}))},[s,petRef,e,c,userRef]);o(()=>(g(),()=>{p.current+=1}),[g]);let f=u.scope===c?u:{value:null,error:null,loading:true},m=l(()=>{g()},[g]),b=f.error===null||f.error.httpStatus!==404,y=b?f.error:null,v=f.loading?"loading":y!==null?"error":f.value===null?"empty":f.value.withheld?"populated":t(f.value)?"empty":"populated";return n(()=>({status:v,value:f.value,error:y,available:b,refresh:m}),[v,f.value,y,b,m])}function qd(e){return e!==null&&e.httpStatus===404}var Md=(e,petRef)=>e.getMarkers(petRef),Nd=e=>e.markers.length===0;function useRecordsMarkers(petRef){let e=useRecordsDepthRead(petRef,Md,Nd);return n(()=>{let t=e.available&&e.value!==null&&!e.value.withheld?e.value:null;return{status:e.status,markers:t,available:e.available,error:e.error,refresh:e.refresh}},[e])}var Wd=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function Ud(e){let{clinic:t,controller:n,depthClient:a,capture:s,onCreated:d}=e,c=t.clinic?.name??t.freeText??"",u=t.clinic===null,[h,p]=i(false),[g,f]=i(e.ownerName),[m,b]=i(t.email),[y,v]=i(false),[w,k]=i(null),[x,T]=i(null),[_,C]=i(0),[R,S]=i(null),[z,I]=i(false),[D,H]=i(null),[L,P]=i([]),[O,$]=i(null),[B,j]=i(false),A=r(false),E=r(true),F=r(Yt()),q=r(null);o(()=>(E.current=true,()=>{E.current=false,q.current=null}),[n]),o(()=>{let e=true;return k(null),q.current=null,n.getAuthorizationCopy().then(t=>{e&&(t.ok?(k(t.value),T(null)):T(t.error))}).catch(()=>{e&&T(makeEverfurError("internalError"))}),()=>{e=false}},[n,_]),o(()=>{if(a===void 0)return;let e=true;return a.listAuthorizationSignatures().then(t=>{e&&(t.ok?P(t.value):qd(t.error)||P([]))}).catch(()=>{}),()=>{e=false}},[a]);let M=Qa(t.clinic),N=m.trim().toLowerCase(),W=Wd.test(N),U=M&&(y||N.length>0)&&!W?N.length>0?id.emailInvalid:id.emailRequired:null,G=g.trim().length>0,V=w&&G?Xa(w,g.trim(),Qn(e.petName),c):null,K=e.hostCapture===true||B||O!==null,Y=!!(h&&w&&V&&G&&c&&(!M||W)),X=Y&&K,Q=l(async()=>{if(!(A.current||D!==null||!w||!V)){if(!c){S(id.missingDraftError);return}if(M&&!W){v(true),S(N.length>0?id.emailInvalid:id.emailRequired);return}if(!(!h||!g.trim())){A.current=true,I(true),S(null);try{if(q.current===null){let r=O!==null?{signatureId:O}:await s();if(!E.current)return;if(r===null){S(id.missingSignatureError);return}let n=t.clinic&&(!M||t.clinic.emailStatus==="none")?{clinicId:t.clinic.id}:{clinicFreeText:c};q.current={petRef:e.petRef,ownerName:g.trim(),authorizationVersion:w.authorizationVersion,...n,...M?{clinicEmail:N}:{},...r.signatureId!==void 0?{signatureId:r.signatureId}:{signaturePngBase64:r.signaturePngBase64},idempotencyKey:F.current()}}let r=await n.createClinicRequest(q.current);if(!E.current)return;if(!r.ok){S(r.error.displayMessage);return}if(r.value.petRef!==e.petRef){S(makeEverfurError("internalError").displayMessage);return}H(r.value),q.current=null,d?.(r.value)}catch{E.current&&S(makeEverfurError("internalError").displayMessage)}finally{A.current=false,E.current&&I(false)}}}},[h,s,t.clinic,c,n,w,D,e.petRef,M,N,d,g,O,V,W]),J=l(()=>{q.current=null,S(null)},[]);return{title:u?id.titleFreeText:id.titleDirectory,clinicName:c,isFreeText:u,authorized:h,ownerName:g,email:m,emailError:U,needsEmail:M,directoryClinicNoEmail:M&&t.clinic!==null,copy:w,copyError:x,scope:V,error:R,busy:z,created:D,ready:X,signatures:L,reuseSignatureId:O,hasSignature:K,scopeAwaitingName:w!==null&&!G,signatureLastMissing:Y&&!K,setAuthorized(e){A.current||(J(),p(e))},setOwnerName(e){A.current||(J(),f(e))},setEmail(e){A.current||(J(),v(false),b(e))},setSigned(e){A.current||(J(),j(e),e&&$(null))},pickReuseSignature(e){A.current||(J(),$(e))},retryCopy(){T(null),C(e=>e+1)},submit:Q}}function EverfurRecordsConsent(e){let{userRef:userRef,scopeEpoch:t}=Ir();/* @__PURE__ */
262
+ return B(CapabilityGate,{capability:"recordsClinic",style:e.style,...Wo(e.onBack,jo),children:userRef===null?/* @__PURE__ */B(Text,{accessibilityRole:"alert",children:Kn.sessionRequired}):/* @__PURE__ */B(ConsentBody,{...Zr(e,["onCreated","onNavigate","onBack"])},JSON.stringify([userRef,t,e.petRef,e.clinic.key]))})}var Gd=p.OS==="ios";function ConsentBody({petRef:petRef,petName:e,clinic:t,ownerName:n,onCaptureSignature:o,onCreated:a,controller:s,onNavigate:d,onBack:c,style:u}){let h=Io(),p=Vd(),g=useEverfurTheme(),y=useEverfurRecordsClinic(),v=yl()?fl.newClinicDirectSendNote:id.newClinicDirectSendNote,w=useEverfurRecordsDepthClient(),[_,C]=i(null),[R,S]=i("draw"),z=l(async()=>_===null?null:{signaturePngBase64:_},[_]),I=Ud({petRef:petRef,petName:e,ownerName:n??"",clinic:t,controller:s??y,depthClient:w,capture:o?()=>o({petRef:petRef,petName:Qn(e),ownerName:I.ownerName,clinicName:I.clinicName,authorizationVersion:I.copy?.authorizationVersion??"",scopeText:I.scope??"",signal:(new AbortController).signal}):z,hostCapture:o!==void 0,onCreated:e=>{a?.(e),d?.({name:"dashboard"})}}),D=r(I);D.current=I;let H=l(e=>{C(e),D.current.setSigned(e!==null)},[]),L=I.busy,P=as(void 0,Gd);/* @__PURE__ */
263
263
  return j(f,{style:[h.root,u],children:[
264
264
  /* @__PURE__ */B(ScreenHeader,{title:I.title,onBack:c,testID:"records-consent-header"}),
265
265
  /* @__PURE__ */j(k,{behavior:Gd?"padding":void 0,style:h.body,...P.avoidingProps,children:[
@@ -299,7 +299,7 @@ return B(m,{onPress:()=>I.pickReuseSignature(t?null:e.signatureId),accessibility
299
299
  /* @__PURE__ */B(Pill,{label:L?id.submitting:id.submit,disabled:!I.ready,busy:L,onPress:()=>{x.dismiss(),I.submit()},style:p.submit,testID:"records-consent-submit"})]})]}),
300
300
  /* @__PURE__ */B(RecordsFootnote,{})]})}function Vd(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?Yd(e):bo(Yd(e),Kd(t)),[e,t])}function Kd(e){return{scopeCard:mo(e),nextCard:mo(e,{gap:8}),scopeHeading:e.cardTitle,footer:{backgroundColor:e.ground},submit:{minHeight:e.button.minHeight}}}function Yd(e){let{color:t,space:r,radius:n,type:i}=e,l=v.hairlineWidth,o=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n});return v.create({content:{paddingHorizontal:r.lg,paddingBottom:r.xl+r.xs,gap:r.lg+r.xs/2},lead:o(i.size.body,i.lineHeight.normal,t.text.muted),scopeCard:{borderRadius:n.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surfaceCream,padding:r.lg,gap:r.md,...Bn(e.slots.card,1)},nextCard:{borderRadius:n.lg,backgroundColor:t.surfaceSubtle,padding:r.lg,gap:r.sm,...Bn(e.slots.card)},scopeHeading:{...o(i.size.subtitle,i.lineHeight.snug,t.brandInk,"bold"),...headingFace(e,"bold"),letterSpacing:-.4,...jn(e.slots.card)},scopeBody:{...o(i.size.bodyTight,i.lineHeight.relaxed,t.text.primary),...jn(e.slots.card)},bullets:{gap:r.sm},bulletRow:{flexDirection:"row",alignItems:"flex-start",gap:r.sm},check:{...o(i.size.body,i.lineHeight.normal,t.brandInk,"bold")},bulletText:{flex:1,...o(i.size.bodyTight,i.lineHeight.normal,t.text.primary)},retentionRow:{paddingTop:r.xs,borderTopWidth:1,borderTopColor:t.borderHairlineGreen},retentionText:o(i.size.tiny,i.lineHeight.normal,t.text.muted),serverScope:{...o(i.size.bodyTight,i.lineHeight.relaxed,t.text.secondary),paddingTop:r.xs},toggle:{flexDirection:"row",alignItems:"flex-start",gap:r.md,borderRadius:n.lg-r.xs,borderWidth:l,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md+r.xs/2},toggleChecked:{borderColor:t.brandInk,backgroundColor:t.brandSoft},box:{width:r.xl,height:r.xl,borderRadius:n.xs+1,borderWidth:1.6,borderColor:t.brandInk,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},boxChecked:{backgroundColor:t.brandInk},boxCheck:{...o(i.size.body,i.lineHeight.tight,t.surface,"bold")},toggleLabel:{flex:1,...o(i.size.bodyTight,i.lineHeight.normal,t.text.primary,"bold")},block:{gap:r.sm},signatureBlock:{gap:r.sm},gallery:{gap:r.sm,paddingVertical:r.xs},tile:{width:r.xxl*3+r.lg,height:r.xxl+r.lg+r.sm,borderRadius:n.sm,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,overflow:"hidden"},tileSelected:{borderColor:t.brandInk,borderWidth:2},tileImage:{width:"100%",height:"100%"},signatureHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},modeToggle:{minHeight:r.xxl+r.md,alignItems:"center",justifyContent:"center"},modeToggleText:{...o(i.size.bodyTight,i.lineHeight.snug,t.linkInk,"bold"),textDecorationLine:"underline"},footer:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm,paddingHorizontal:r.lg,paddingTop:r.md,paddingBottom:r.xxl,borderTopWidth:l,borderTopColor:t.borderHairlineGreen,backgroundColor:t.background},cancel:{flexGrow:0,flexShrink:0},submit:{flexGrow:1,flexShrink:1,flexBasis:r.xxl*4,minWidth:0,minHeight:r.xxl+r.lg+r.xs+r.xs/2}})}function Xd(e){let t={uri:e.uri,mimeType:e.mimeType},r=Qd(e);return r!==null&&(t.sizeBytes=r),/* @__PURE__ */Object.freeze(t)}function Qd(e){let t=e.byteSize??e.sizeBytes;return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:null}function Jd(e,t){/* @__PURE__ */
301
301
  return Object.freeze({mode:e})}function Zd(e){return e!=null&&e.isAvailable===true}function ec(e){return e==="above"||e==="below"?"critical":e==="in_range"?"positive":"neutral"}function tc(e){switch(e){case"above":return"above the reference range";case"below":return"below the reference range";case"in_range":return"within range";default:return"no reference range on file"}}function rc(e){return e.refLow!==null&&e.refHigh!==null?`, reference range ${e.refLow} to ${e.refHigh}`:e.refLow!==null?`, reference range at least ${e.refLow}`:e.refHigh!==null?`, reference range up to ${e.refHigh}`:""}function nc(e,t){let r=t?` ${t}`:"";return e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}${r}`:e.refLow!==null?`≥ ${e.refLow}${r}`:e.refHigh!==null?`≤ ${e.refHigh}${r}`:"-"}function ic(e,t){let r=t.reviewed?", reviewed by our team":"",n=t.sourceClinic?`, from ${t.sourceClinic}`:"";return`${Ko(t.at)}: ${sa(t.value,e.unit,t.qualitativeResult)}, ${tc(t.status)}${rc(t)}${n}${r}`}function lc(e,t){if(!t)return e;let r=e.findIndex(e=>e.markerId===t);return r<=0?e:[e[r],...e.slice(0,r),...e.slice(r+1)]}var oc=7;function ac(e,t,r=oc){let n=Math.max(0,Math.min(t,r)),i=t<=r?0:Math.max(0,Math.min(e-Math.floor(r/2),t-r));return Array.from({length:n},(e,t)=>i+t)}function sc(e){return e?.trim()||"my pet"}function dc(e){let t=e.trim();return/[.!?]$/.test(t)?t:`${t}.`}function cc(e,t){let r=t.canonicalName.trim()||"a lab marker",n=[`I'm looking at ${sc(e)}'s ${r}`],i=[t.latestValueText?.trim(),t.statusText?.trim(),t.trajectoryText?.trim()].filter(Boolean).join(", ");return n[0]+=i?`: ${i}.`:".",t.meaningText?.trim()&&n.push(dc(t.meaningText)),n.push(`What does this trend tell me, and should I do anything differently for ${sc(e)}?`),{prompt:n.join(" "),entityRef:{type:"marker",id:t.markerId,payload:{marker:r,...t.statusText?.trim()?{status:t.statusText.trim()}:{}}}}}function uc(e,t,r){let{totalMarkers:n,inRangeCount:i,outOfRangeCount:l,unknownCount:o}=t;if(n===0)return{prompt:`I'm looking at ${sc(e)}'s lab markers, but there aren't any on file yet. What lab work is worth running for ${sc(e)}?`,entityRef:{type:"marker_summary",id:r,payload:{total:0}}};let a=o>0?`, ${o} without a reference range`:"";return{prompt:`I'm looking at ${sc(e)}'s lab markers: ${n} total, ${i} in range, ${l} out of range${a}. What should I focus on?`,entityRef:{type:"marker_summary",id:r,payload:{total:n,inRange:i,outOfRange:l,unknown:o}}}}function hc(e,t){let r=t.canonicalName.trim()||"a lab marker",n=[`${r}: ${t.valueText.trim()}`];t.collectedAt?.trim()&&n.push(`collected ${t.collectedAt.trim()}`),t.sourceClinic?.trim()&&n.push(`from ${t.sourceClinic.trim()}`),t.referenceText?.trim()&&n.push(`reference range ${t.referenceText.trim()}`),t.flagged&&n.push(`flagged ${t.flagged}`);let i={marker:r};return t.flagged&&(i.status=t.flagged),t.reviewed!==void 0&&(i.reviewed=t.reviewed),{prompt:`I'm looking at ${sc(e)}'s ${n.join(", ")}. What does this mean, and should I be concerned?`,entityRef:{type:"lab_reading",id:t.entityId,payload:i}}}function pc(e,t,r){let n=t.clinicName?.trim(),i=t.heldItemCount??0,l=i>0?`, ${i} fact${i===1?"":"s"} being verified`:"";return{prompt:`I'm looking at ${sc(e)}'s records request${n?` to ${n}`:""}, status: ${t.statusLabel.trim()}${l}. What does this status mean, and what happens next?`,entityRef:{type:"records_request",id:r,payload:{status:t.status,held:i,...n?{clinic:n}:{}}}}}var gc=/* @__PURE__ */Object.freeze({vaccination:"vaccine",medication:"medication",body_weight:"weight",vital:"weight"});function fc(e,t,r,n){let i=t.entityTypeLabel.trim()||"record",l=t.title.trim()||i,o=t.detail?.trim();return{prompt:`I'm looking at ${sc(e)}'s ${i.toLowerCase()}: ${l}${o?`, ${o}`:""}. What does this mean, and what should I keep on top of for ${sc(e)}?`,entityRef:{type:gc[r]??r,id:n,payload:{kind:i,title:l,...o?{detail:o}:{}}}}}function mc(e,t,r){let n=t.filter(e=>e.label.trim()),i={type:"upcoming_care",id:r};if(n.length===0)return{prompt:`I'm looking at ${sc(e)}'s upcoming care, but nothing is scheduled yet. What preventive care and checkups should ${sc(e)} be on?`,entityRef:i};let l=[...n].sort((e,t)=>(e.tone==="overdue"?0:1)-(t.tone==="overdue"?0:1)).slice(0,4).map(e=>e.relativeText.trim()?`${e.label.trim()} (${e.relativeText.trim().toLowerCase()})`:e.label.trim());return{prompt:`I'm looking at ${sc(e)}'s upcoming care: ${l.join(", ")}. What should I prioritize for ${sc(e)}, and how do I stay on top of these?`,entityRef:i}}function bc(e,t,r){let n=[`I'm looking at ${sc(e)}'s physical exam${t.observedOn?.trim()?` from ${t.observedOn.trim()}`:""}.`],i=t.abnormal.filter(e=>e.system.trim());return i.length>0?(n.push(`Abnormal: ${i.slice(0,6).map(e=>`${e.system.trim()}: ${e.finding.trim()}`).join("; ")}.`),n.push(`What do these findings mean, and what should I follow up on for ${sc(e)}?`)):n.push(`Everything examined came back normal. What does this tell me about ${sc(e)}'s health?`),{prompt:n.join(" "),entityRef:{type:"physical_exam",id:r}}}function yc(e,t,r){let n=[`I'm looking at ${sc(e)}'s visit notes${t.observedOn?.trim()?` from ${t.observedOn.trim()}`:""}.`];for(let e of t.sections.filter(e=>e.text.trim()).slice(0,3))n.push(`${e.label.trim()||"Note"}: ${dc(e.text)}`);return n.push(`Can you summarize what happened and what I should follow up on for ${sc(e)}?`),{prompt:n.join(" "),entityRef:{type:"visit",id:r}}}function vc(e,t,r){let n=t.scopeLabel.trim()||"a detail",i=t.candidates.filter(e=>e.value.trim()),l=i.slice(0,3).map(e=>`"${e.value.trim()}"${e.clinicName?.trim()?` (${e.clinicName.trim()})`:""}`).join(" vs ");return{prompt:`Two of ${sc(e)}'s documents disagree on ${n}: ${l}. Which is likely correct, and what should I ask my vet?`,entityRef:{type:"conflict",id:r,payload:{field:n,severity:t.severity,values:i.map(e=>e.value.trim()).join(" | ")}}}}var wc=/* @__PURE__ */Object.freeze({title:"Medical records",subtitle:e=>{let t=e?.trim()??"";return t.length>0?`${t}’s uploads and clinic requests`:"Every upload and clinic request"},requestRecords:"Request records",requestRecordsA11y:"Request records from a clinic",uploadOwn:"I already have the records",ownerUpload:"Records you uploaded",clinicRequest:"Clinic request",meta:(e,t)=>`${e?"Uploaded":"Requested"} ${Xo(t)}`,rowA11y:(e,t,r)=>`${e}, ${t}, status ${r}`,allRequests:"Your record requests"}),kc=/* @__PURE__ */Object.freeze({preparing:"Preparing",sent:"Sent",processing:"Processing",done:"Ready"});function xc(e){switch(e){case"awaiting_clinic":return kc.sent;case"received":case"parsing":case"in_review":return kc.processing;case"published":return kc.done;default:return kc.preparing}}function Tc(e){let t=e.source==="owner_provided",r=e.clinicName?.trim()||(t?wc.ownerUpload:wc.clinicRequest),n=e.statusLabel.trim()||xc(e.status),i=wc.meta(t,e.createdAt);/* @__PURE__ */
302
- return Object.freeze({source:r,meta:i,status:n,ownerUpload:t,a11yLabel:wc.rowA11y(r,i,n)})}var Cc=/* @__PURE__ */new Set(["records_received","parsing","parsing_failed","in_review","review_email_failed"]),_c=/* @__PURE__ */new Set(["received","parsing","in_review"]);function Rc(e){return e.wireStatus!==void 0?Cc.has(e.wireStatus):_c.has(e.status)}function Sc(e,t,r={}){let n=e.filter(e=>!isTerminalStatus(e.status));if(e.length===0||r.activeOnly===true&&n.length===0)return null;let i=e.filter(Rc).length,l=i>0?`${i} document${i===1?"":"s"} being read`:n.length>0?`${n.length} active record request${n.length===1?"":"s"}`:wc.allRequests,o=i>0?`We’ll add ${i===1?"it":"them"} to ${t}’s records once ready.`:n.length>0?"See each clinic’s status and what happens next.":"See the status of every upload and clinic request.";/* @__PURE__ */
302
+ return Object.freeze({source:r,meta:i,status:n,ownerUpload:t,a11yLabel:wc.rowA11y(r,i,n)})}var _c=/* @__PURE__ */new Set(["records_received","parsing","parsing_failed","in_review","review_email_failed"]),Cc=/* @__PURE__ */new Set(["received","parsing","in_review"]);function Rc(e){return e.wireStatus!==void 0?_c.has(e.wireStatus):Cc.has(e.status)}function Sc(e,t,r={}){let n=e.filter(e=>!isTerminalStatus(e.status));if(e.length===0||r.activeOnly===true&&n.length===0)return null;let i=e.filter(Rc).length,l=i>0?`${i} document${i===1?"":"s"} being read`:n.length>0?`${n.length} active record request${n.length===1?"":"s"}`:wc.allRequests,o=i>0?`We’ll add ${i===1?"it":"them"} to ${t}’s records once ready.`:n.length>0?"See each clinic’s status and what happens next.":"See the status of every upload and clinic request.";/* @__PURE__ */
303
303
  return Object.freeze({title:l,subtitle:o,processing:i>0,a11yLabel:`${l}. ${o}`})}function zc(e){return e!==void 0}function Ic(e,t){return e??t?.version??""}function Dc(e,t){return Ic(e,t).length>0}function Hc(e,t){return e.denialReason==="consent_required"?t?{kind:"consent_required"}:{kind:"consent_unavailable"}:e.denialReason==="pet_not_found"?{kind:"pet_not_found",error:makeEverfurError("petNotFound",{retryable:false})}:e.denialReason==="entitlement"?{kind:"error",error:makeEverfurError("accessDenied")}:e.denialReason==="session_required"?{kind:"session_required"}:e.withheld?{kind:"withheld"}:e.error===null?{kind:"withheld"}:{kind:"error",error:e.error}}function Lc(e){return e.kind==="consent_required"||e.kind==="consent_unavailable"}function selectRequestTitle(e){let t=e.clinicName?.trim()??"";return t.length>0?t:e.source==="owner_provided"?Pc.ownerUpload:Pc.clinicRequest}var Pc=/* @__PURE__ */Object.freeze({ownerUpload:"Records you uploaded",clinicRequest:"Record request"});function Oc(e,t){return t===null||t.status!=="awaiting_upload"?null:t}function $c(e){return`${e} ${Kn.beingReviewed}`}function selectRequestList(e){let t=[...e].sort((e,t)=>e.updatedAt!==t.updatedAt?e.updatedAt>t.updatedAt?-1:1:e.createdAt!==t.createdAt?e.createdAt>t.createdAt?-1:1:0);/* @__PURE__ */
304
304
  return Object.freeze(t)}function selectPrimaryLabel(e){let t=e.actionNeededLabel?.trim()??"";return t.length>0?t:e.statusLabel}function selectClinicCall(e){if(e.showClinicPhone!==true)return null;let t=e.clinicPhone?.trim()??"";return t.length===0?null:{phone:t,dial:`tel:${t.replace(/[^+\d]/g,"")}`,clinicName:e.clinicName?.trim()||null}}function Bc(e){switch(e.wireStatus??e.status){case"published":return"positive";case"failed":case"clinic_declined":return"critical";case"revoked":return"neutral";case"clinic_responded_no_records":case"awaiting_upload":case"records_received":case"parsing":case"parsing_failed":case"in_review":case"review_email_failed":return"warning";default:return"info"}}var jc=200,Ac=16;function Ec(e,t){let r=e.inRangeCount+e.outOfRangeCount+e.unknownCount;if(!Number.isFinite(r)||r<=0)return[];let n=[{key:"in_range",color:t.inRange,count:e.inRangeCount},{key:"out_of_range",color:t.outOfRange,count:e.outOfRangeCount},{key:"unknown",color:t.unknown,count:e.unknownCount}],i=0,l=[];for(let e of n){if(!(e.count>0))continue;let t=e.count/r*360;if(!Number.isFinite(t))return null;l.push({key:e.key,color:e.color,startDeg:i,sweepDeg:t}),i+=t}return l}function MarkerSummaryCard({summary:e,onAsk:t,testID:r}){let i=Fc(),l=useEverfurTheme(),{totalMarkers:o,inRangeCount:a,outOfRangeCount:s,unknownCount:d}=e,c=n(()=>Ec(e,{inRange:l.color.success,outOfRange:l.color.danger,unknown:l.color.text.muted}),[e,l]),u=c!==null&&c.length>0;/* @__PURE__ */
305
305
  return j(f,{style:i.card,accessibilityRole:"summary",testID:r,children:[
@@ -341,7 +341,7 @@ return j(z,{transparent:true,visible:true,animationType:"slide",onRequestClose:r
341
341
  /* @__PURE__ */j(f,{style:i.valueRow,children:[
342
342
  /* @__PURE__ */B(Text,{style:i.sheetName,children:e.name}),
343
343
  /* @__PURE__ */B(Text,{style:i.sheetValue,children:sa(t.value,e.unit,t.qualitativeResult)})]}),t.reviewed?/* @__PURE__ */B(f,{style:i.reviewed,accessibilityRole:"text",children:/* @__PURE__ */B(Text,{style:i.reviewedText,children:ri.reviewed})}):null,o(ri.collected,Ko(t.at)),t.sourceClinic?o(ri.clinic,t.sourceClinic):null,o(ri.referenceRange,t.refLow!==null||t.refHigh!==null?nc(t,e.unit):ri.noRange),t.docId?o(ri.sourceDocument,t.docId):null,t.reviewed?null:/* @__PURE__ */B(Text,{style:i.unverified,accessibilityRole:"text",children:ri.unverified}),n?/* @__PURE__ */B(m,{onPress:n,accessibilityRole:"button",accessibilityLabel:ri.ask,style:[l.pill,l.pillAsk],testID:"marker-provenance-ask",children:/* @__PURE__ */B(Text,{style:l.pillAskLabel,children:ri.ask})}):null]})]})]})}function Kc(){let e=useEverfurTheme();return n(()=>Yc(e),[e])}function Yc(e){let{color:t,space:r,radius:n,type:i,slots:l}=e,o=v.hairlineWidth,a=r.md,s=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n}),d=jn(An(l)),c=jn(l.dialog),u={...s(i.size.subtitle,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold")},h=s(i.size.verdict+r.xs,i.lineHeight.tight,t.text.primary,"bold");return v.create({page:{paddingHorizontal:r.sm},card:{borderRadius:n.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,padding:r.lg,gap:r.md,...Bn(An(l),1)},headerRow:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.sm+r.xs/2},nameColumn:{flex:1,gap:r.xs/2},markerName:{...u,...d},sheetName:{...u,...c},unit:{...face(e,"mono"),fontSize:i.size.tiny,lineHeight:i.size.body,color:t.text.muted,...d},latestRow:{flexDirection:"row",alignItems:"baseline",justifyContent:"space-between",gap:r.md},latestValue:{...h,...d},sheetValue:{...h,...c},latestValueDanger:{color:t.danger},latestDate:{...s(i.size.caption,i.lineHeight.normal,t.text.muted),...d},trajectory:{...s(i.size.bodyTight,i.lineHeight.normal,t.text.muted),...d},chartWrap:{gap:r.sm},plot:{height:Gc,borderRadius:n.sm,backgroundColor:t.surfaceCream,borderWidth:o,borderColor:t.borderHairlineGreen,overflow:"hidden"},band:{position:"absolute",left:0,right:0,backgroundColor:t.badgeBgPositive},point:{position:"absolute",width:a,height:a,borderRadius:a/2,marginLeft:-a/2,marginTop:-a/2,backgroundColor:t.brand,borderWidth:2,borderColor:t.surface},pointDanger:{backgroundColor:t.danger},a11yTable:{width:1,height:1,overflow:"hidden",position:"absolute"},tapHint:{...s(i.size.tiny,i.lineHeight.normal,t.text.placeholder),textAlign:"center",...d},singleHint:{...s(i.size.caption,i.lineHeight.normal,t.text.muted),textAlign:"center",...d},emptyBody:{alignItems:"center",justifyContent:"center",gap:r.sm,paddingVertical:r.xxl+r.xs},emptyText:{...s(i.size.bodyTight,i.lineHeight.normal,t.text.muted),textAlign:"center",...d},carousel:{height:Uc},footer:{alignItems:"center",gap:r.sm,paddingTop:r.md},dots:{flexDirection:"row",gap:r.xs+r.xs/2},dot:{width:r.xs+r.xs/2,height:r.xs+r.xs/2,borderRadius:r.xs-1,backgroundColor:t.borderHairlineGreen},dotActive:{width:r.lg+r.xs/2,backgroundColor:t.brand},counter:{...face(e,"mono"),fontSize:i.size.tiny,lineHeight:i.size.body,letterSpacing:i.letterSpacing.eyebrow/3,color:t.text.muted},backdrop:{flex:1,backgroundColor:zo},sheet:{backgroundColor:t.surfaceCream,borderTopLeftRadius:n.xl-r.xs,borderTopRightRadius:n.xl-r.xs,paddingHorizontal:r.lg+r.xs,paddingTop:r.sm,paddingBottom:r.xxl+r.xs,maxHeight:"80%",gap:r.md,...Wc(l.dialog)},handle:{alignSelf:"center",width:r.xxl+r.xs,height:r.xs,borderRadius:n.pill,backgroundColor:t.borderRingCream},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},sheetTitle:{flex:1,...s(i.size.subtitle,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),...c},closeButton:{width:r.xxl+r.md,height:r.xxl+r.md,alignItems:"center",justifyContent:"center"},closeGlyph:{...s(i.size.verdict,i.lineHeight.tight,t.text.primary),...c},sheetBody:{gap:r.md},valueRow:{flexDirection:"row",alignItems:"baseline",justifyContent:"space-between",gap:r.md},reviewed:{alignSelf:"flex-start",borderRadius:n.pill,paddingHorizontal:r.sm+r.xs/2,paddingVertical:r.xs,backgroundColor:t.badgeBgPositive},reviewedText:{...s(i.size.tiny,i.lineHeight.normal,t.success,"medium")},detailRow:{gap:r.xs/2},detailLabel:{...s(i.size.caption,i.lineHeight.normal,t.text.muted,"medium"),...c},detailValue:{...s(i.size.body,i.lineHeight.normal,t.text.primary),...c},unverified:{...s(i.size.caption,i.lineHeight.normal,t.text.muted),...c}})}var Xc=/* @__PURE__ */Object.freeze({vaccination:"Vaccination",medication:"Medication",problem:"Problem",body_weight:"Weight",allergy:"Allergy",vital:"Vital",lab_result:"Lab result",parasite_prevention:"Preventive"}),Qc="Given",Jc=/^\d{4}-\d{2}-\d{2}/,Zc=" · ";function eu(e){let t=e.filter(e=>e!==null&&e.trim().length>0);return t.length>0?t.join(Zc):null}function tu(e,t){let r=e.label.trim();if(r.length>0)return r;let n=Xc[e.category];return n!==void 0?n:t(e.category)}function ru(e,t){let r=tu(e,t.humanize),n=t.formatEntityValue(e.value,e.unit),i=n.trim().length>0?n:null,l=e.observedAt!==null&&e.observedAt.trim().length>0?t.formatRecordsDate(e.observedAt):null,o=l!==null&&l!=="-"?l:null;switch(e.category){case"vaccination":{let n=e.value!==null&&Jc.test(e.value.trim()),l=n?t.formatRecordsDate(e.value):o;return l!==null&&l!=="-"?{title:r,detail:eu([`${Qc} ${l}`,n?null:i])}:{title:r,detail:eu([i])}}case"medication":return{title:r,detail:eu([o])};case"problem":return{title:r,detail:eu([o])};case"body_weight":return{title:r,detail:eu([o])};case"allergy":return{title:r,detail:eu([o])};case"vital":return{title:r,detail:eu([i,o])};case"lab_result":return{title:r,detail:eu([i,o])};default:return{title:r,detail:eu([i,o])}}}var nu=/* @__PURE__ */Object.freeze({editA11y:e=>`Edit ${e}. Correct or remove this record detail.`,title:e=>`Edit ${e}`,helper:"Corrects your record. Your vet can still review it.",close:"Close",closeEditorA11y:"Close editor",save:"Save changes",saving:"Saving...",remove:"Remove this detail",confirmRemove:"Remove this detail from your record? This can't be undone.",removeConfirm:"Remove",removing:"Removing...",keep:"Keep",noChange:"Change a value before saving.",saved:"Saved.",removed:"Removed.",detail:"record detail"});function iu(e,t){return ht(e)?t==="remove"?"Records access for this pet is off, so this detail cannot be removed.":"Records access for this pet is off, so this detail cannot be changed.":isFactReviewerLocked(e)?t==="remove"?"A clinician already reviewed this detail, so it can't be removed here.":"A clinician already reviewed this detail, so it can't be changed here.":t==="remove"?"Couldn't remove that. Please check your connection and try again.":"Couldn't save that. Please check your connection and try again."}var lu=/* @__PURE__ */Object.freeze({edits:/* @__PURE__ */Object.freeze({}),removed:/* @__PURE__ */Object.freeze([])});function applyFactOverlay(e,t){if(Object.keys(t.edits).length===0&&t.removed.length===0)return e;let r=[];for(let n of e){let e=n.canonicalKey??null;if(e!==null&&t.removed.includes(e))continue;let i=e!==null?t.edits[e]:void 0;r.push(i===void 0?n:/* @__PURE__ */Object.freeze({...n,value:i}))}/* @__PURE__ */
344
- return Object.freeze(r)}function isFactEditable(e){return typeof e.canonicalKey=="string"&&e.canonicalKey.length>0}function ou(){return`records-fact-${Date.now().toString(36)}`}function useRecordFactEdit(petRef,e={}){let t=useEverfurRecordsDepthClient(),{userRef:userRef}=Ir(),[a,s]=i(lu),[d,c]=i(false),[u,h]=i(null),p=n(()=>({}),[t,petRef,userRef]),[g,f]=i(null),m=l(()=>f(p),[p]),[b,y]=i(null);o(()=>{if(userRef===null||t.readFeatures===void 0)return;let e=true;return t.readFeatures().then(t=>{e&&t.features.fact_edit===false&&y(p)},()=>{}),()=>{e=false}},[t,userRef,p]);let v=userRef!==null&&g!==p&&b!==p,w=r(false),k=r(e.newIdempotencyKey);k.current=e.newIdempotencyKey;let x=l(()=>(k.current??ou)(),[]),T=l((e,t,r)=>{if(c(false),!e.ok){if(t(),qd(e.error)){m();return}h(iu(e.error,r))}},[m]),C=l(async(e,r)=>{let n=e.canonicalKey??"",i=r.trim();if(w.current||n.length===0||i.length===0)return err(makeEverfurError("validationFailed",{retryable:false}));w.current=true,c(true),h(null);let l=a;s(e=>({...e,edits:{...e.edits,[n]:i}}));let o=await t.editFact(petRef,{entityType:e.category,canonicalKey:n,correctedFields:factCorrectionFor(e.value,i),idempotencyKey:x()});return w.current=false,T(o,()=>s(l),"edit"),o},[t,petRef,a,T,x]),_=l(async e=>{let r=e.canonicalKey??"";if(w.current||r.length===0)return err(makeEverfurError("validationFailed",{retryable:false}));w.current=true,c(true),h(null);let n=a;s(e=>({...e,removed:[...e.removed,r]}));let i=await t.removeFact(petRef,{entityType:e.category,canonicalKey:r,idempotencyKey:x()});return w.current=false,T(i,()=>s(n),"remove"),i},[t,petRef,a,T,x]),R=l(()=>h(null),[]);return n(()=>({overlay:a,busy:d,error:u,available:v,edit:C,remove:_,clearError:R}),[a,d,u,v,C,_,R])}var au=/* @__PURE__ */Object.freeze(["vaccination","parasite_prevention"]),su="Undated",du=/* @__PURE__ */Object.freeze({given:"Given",prevention:"Prevention",overdue:"Overdue",noDate:"No date"}),cu=/* @__PURE__ */Object.freeze({given:"positive",prevention:"neutral",overdue:"critical",noDate:"neutral"});function uu(e){if(!e)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function hu(e){let t=e.status?.toLowerCase()??"";return/overdue|lapsed|expired/.test(t)}function pu(e){return e.category==="parasite_prevention"?"prevention":uu(e.observedAt)===null?"noDate":hu(e)?"overdue":"given"}function gu(e){let t=uu(e);return t===null?su:String(new Date(t).getUTCFullYear())}function fu(e){let t=pu(e),r=[e.value!==null&&e.value.length>0?e.value:null,e.observedAt!==null?Ko(e.observedAt):null].filter(e=>e!==null&&e.length>0);return{key:e.key,name:e.label,detail:r.length>0?r.join(" · "):null,statusLabel:du[t],tone:t,entity:e}}function mu(e){let t=/* @__PURE__ */new Map;for(let r of e){if(!au.includes(r.category))continue;let e=gu(r.observedAt),n=t.get(e),i={row:fu(r),at:r.observedAt};n===void 0?t.set(e,[i]):n.push(i)}let r=[...t.keys()].sort((e,t)=>e===su?1:t===su?-1:Number(t)-Number(e));/* @__PURE__ */
344
+ return Object.freeze(r)}function isFactEditable(e){return typeof e.canonicalKey=="string"&&e.canonicalKey.length>0}function ou(){return`records-fact-${Date.now().toString(36)}`}function useRecordFactEdit(petRef,e={}){let t=useEverfurRecordsDepthClient(),{userRef:userRef}=Ir(),[a,s]=i(lu),[d,c]=i(false),[u,h]=i(null),p=n(()=>({}),[t,petRef,userRef]),[g,f]=i(null),m=l(()=>f(p),[p]),[b,y]=i(null);o(()=>{if(userRef===null||t.readFeatures===void 0)return;let e=true;return t.readFeatures().then(t=>{e&&t.features.fact_edit===false&&y(p)},()=>{}),()=>{e=false}},[t,userRef,p]);let v=userRef!==null&&g!==p&&b!==p,w=r(false),k=r(e.newIdempotencyKey);k.current=e.newIdempotencyKey;let x=l(()=>(k.current??ou)(),[]),T=l((e,t,r)=>{if(c(false),!e.ok){if(t(),qd(e.error)){m();return}h(iu(e.error,r))}},[m]),_=l(async(e,r)=>{let n=e.canonicalKey??"",i=r.trim();if(w.current||n.length===0||i.length===0)return err(makeEverfurError("validationFailed",{retryable:false}));w.current=true,c(true),h(null);let l=a;s(e=>({...e,edits:{...e.edits,[n]:i}}));let o=await t.editFact(petRef,{entityType:e.category,canonicalKey:n,correctedFields:factCorrectionFor(e.value,i),idempotencyKey:x()});return w.current=false,T(o,()=>s(l),"edit"),o},[t,petRef,a,T,x]),C=l(async e=>{let r=e.canonicalKey??"";if(w.current||r.length===0)return err(makeEverfurError("validationFailed",{retryable:false}));w.current=true,c(true),h(null);let n=a;s(e=>({...e,removed:[...e.removed,r]}));let i=await t.removeFact(petRef,{entityType:e.category,canonicalKey:r,idempotencyKey:x()});return w.current=false,T(i,()=>s(n),"remove"),i},[t,petRef,a,T,x]),R=l(()=>h(null),[]);return n(()=>({overlay:a,busy:d,error:u,available:v,edit:_,remove:C,clearError:R}),[a,d,u,v,_,C,R])}var au=/* @__PURE__ */Object.freeze(["vaccination","parasite_prevention"]),su="Undated",du=/* @__PURE__ */Object.freeze({given:"Given",prevention:"Prevention",overdue:"Overdue",noDate:"No date"}),cu=/* @__PURE__ */Object.freeze({given:"positive",prevention:"neutral",overdue:"critical",noDate:"neutral"});function uu(e){if(!e)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function hu(e){let t=e.status?.toLowerCase()??"";return/overdue|lapsed|expired/.test(t)}function pu(e){return e.category==="parasite_prevention"?"prevention":uu(e.observedAt)===null?"noDate":hu(e)?"overdue":"given"}function gu(e){let t=uu(e);return t===null?su:String(new Date(t).getUTCFullYear())}function fu(e){let t=pu(e),r=[e.value!==null&&e.value.length>0?e.value:null,e.observedAt!==null?Ko(e.observedAt):null].filter(e=>e!==null&&e.length>0);return{key:e.key,name:e.label,detail:r.length>0?r.join(" · "):null,statusLabel:du[t],tone:t,entity:e}}function mu(e){let t=/* @__PURE__ */new Map;for(let r of e){if(!au.includes(r.category))continue;let e=gu(r.observedAt),n=t.get(e),i={row:fu(r),at:r.observedAt};n===void 0?t.set(e,[i]):n.push(i)}let r=[...t.keys()].sort((e,t)=>e===su?1:t===su?-1:Number(t)-Number(e));/* @__PURE__ */
345
345
  return Object.freeze(r.map(e=>{let r=t.get(e)??[],n=e===su?r:[...r].sort((e,t)=>(uu(t.at)??0)-(uu(e.at)??0));/* @__PURE__ */
346
346
  return Object.freeze({year:e,items:/* @__PURE__ */Object.freeze(n.map(e=>e.row))})}))}var bu=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});function FactEditAffordance({entity:e,factEdit:t,children:r}){let n=yu(),[l,o]=i(false),a=e.label.trim()||nu.detail;/* @__PURE__ */
347
347
  return j(f,{style:n.row,children:[
@@ -363,8 +363,8 @@ return B(z,{transparent:true,visible:true,animationType:"slide",onRequestClose:n
363
363
  /* @__PURE__ */B(Pill,{label:v?nu.removing:nu.removeConfirm,kind:"danger",busy:v,onPress:x,style:l.confirmButton,testID:"fact-edit-remove-confirm"}),
364
364
  /* @__PURE__ */B(Pill,{label:nu.keep,kind:"outline",disabled:v,onPress:()=>g(false),style:l.confirmButton,testID:"fact-edit-remove-cancel"})]})]}):/* @__PURE__ */j(f,{style:l.actions,children:[
365
365
  /* @__PURE__ */B(Pill,{label:v?nu.saving:nu.save,busy:v,disabled:!b,onPress:w,testID:"fact-edit-save"}),
366
- /* @__PURE__ */B(m,{accessibilityRole:"button",accessibilityLabel:nu.remove,disabled:v,onPress:()=>{h(null),g(true)},style:[l.removeButton,v?l.removeDisabled:null],testID:"fact-edit-remove",children:/* @__PURE__ */B(Text,{style:l.removeText,children:nu.remove})})]})]})]})})}function yu(){let e=useEverfurTheme();return n(()=>vu(e),[e])}function vu(e){let{color:t,space:r,radius:n,type:i}=e,l=r.xxl+r.md,o=e.brightness==="dark"?t.errorRed:t.danger,a=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n});return v.create({row:{flexDirection:"row",alignItems:"center",gap:r.sm},main:{flex:1},editButton:{width:l,height:l,alignItems:"center",justifyContent:"center"},pencil:{width:r.md+r.xs/2,height:r.xs/2,backgroundColor:t.brandInk,borderRadius:n.pill,transform:[{rotate:"-45deg"}]},backdrop:{flex:1,justifyContent:"flex-end",backgroundColor:zo},sheet:{backgroundColor:t.surface,borderTopLeftRadius:n.xl-1,borderTopRightRadius:n.xl-1,paddingHorizontal:r.lg+r.xs+r.xs/2,paddingTop:r.md,paddingBottom:n.xl,maxHeight:"88%",gap:r.md,...Wc(e.slots.dialog)},handle:{alignSelf:"center",width:r.xxl+r.xs,height:r.xs,borderRadius:n.pill,backgroundColor:t.borderRingCream},header:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.sm},headerText:{flex:1,gap:r.xs},title:{...a(i.size.heading,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),...jn(e.slots.dialog)},helper:{...a(i.size.bodyTight,i.lineHeight.normal,t.text.muted),...jn(e.slots.dialog)},helperError:{color:o},closeButton:{width:l,height:l,alignItems:"center",justifyContent:"center"},closeGlyph:{...a(i.size.verdict,i.lineHeight.tight,t.text.primary),...jn(e.slots.dialog)},actions:{gap:r.sm},removeButton:{minHeight:l,alignItems:"center",justifyContent:"center"},removeDisabled:{opacity:.5},removeText:{...a(i.size.bodyTight,i.lineHeight.snug,t.danger,"bold")},confirmBlock:{gap:r.sm,padding:r.md,borderRadius:n.md,backgroundColor:t.badgeBgCritical},confirmText:a(i.size.bodyTight,i.lineHeight.normal,t.text.primary),confirmRow:{flexDirection:"row",gap:r.sm},confirmButton:{flex:1}})}function wu(e){return e.value!==null&&Number.isFinite(e.value)}function ku(e){return e.display!==null&&e.display.length>0?e.display:e.value!==null?String(e.value):""}function xu(e){let t=e.find(e=>e.points.some(wu));if(t===void 0)return null;let r=t.points.filter(wu),n=r[0];if(n===void 0)return null;let i=r.map(e=>e.value),l=Math.min(...i),o=Math.max(...i);l===o&&(l-=1,o+=1);let a=(o-l)*.18,s=l-a,d=o+a,c=d-s,u=6,h=r.length,p=r.map((e,t)=>({xPct:h<=1?50:u+t/(h-1)*(100-2*u),yPct:(d-e.value)/c*100})),g=(d-o)/c*100,f=(d-l)/c*100,m=r.reduce((e,t)=>t.value<e.value?t:e,n),b=r.reduce((e,t)=>t.value>e.value?t:e,n),y=r[r.length-1]??n,v=t.points[t.points.length-1]??y,w=ku(v),k=w.length>0?w:ku(y);return{label:t.label,heroDisplay:k,minDisplay:ku(m),maxDisplay:ku(b),firstDate:Go(t.points[0]?.at??null),lastDate:Go(v.at),points:p,bandTopPct:g,bandBottomPct:f}}function Tu(e){let t=e.indexOf(":");return t<=0?null:e.slice(0,t)}function Cu(e,t,r){let n=/* @__PURE__ */new Map,i=[];for(let t of e){let e=Tu(t.key)??"",r=n.get(e);r===void 0?(n.set(e,[t]),i.push(e)):r.push(t)}let l=t.filter(e=>n.has(e)),o=i.filter(e=>!l.includes(e));/* @__PURE__ */
367
- return Object.freeze([...l,...o].map(e=>/* @__PURE__ */Object.freeze({entityType:e.length>0?e:null,label:e.length>0?r(e):null,series:/* @__PURE__ */Object.freeze([...n.get(e)??[]])})))}function _u(e){return`${e}%`}function CareTimeline({series:e,testID:t}){let r=Ru(),i=n(()=>Cu(e,fa,ga),[e]);return i.length===0?null:/* @__PURE__ */j(f,{style:r.section,testID:t,children:[
366
+ /* @__PURE__ */B(m,{accessibilityRole:"button",accessibilityLabel:nu.remove,disabled:v,onPress:()=>{h(null),g(true)},style:[l.removeButton,v?l.removeDisabled:null],testID:"fact-edit-remove",children:/* @__PURE__ */B(Text,{style:l.removeText,children:nu.remove})})]})]})]})})}function yu(){let e=useEverfurTheme();return n(()=>vu(e),[e])}function vu(e){let{color:t,space:r,radius:n,type:i}=e,l=r.xxl+r.md,o=e.brightness==="dark"?t.errorRed:t.danger,a=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n});return v.create({row:{flexDirection:"row",alignItems:"center",gap:r.sm},main:{flex:1},editButton:{width:l,height:l,alignItems:"center",justifyContent:"center"},pencil:{width:r.md+r.xs/2,height:r.xs/2,backgroundColor:t.brandInk,borderRadius:n.pill,transform:[{rotate:"-45deg"}]},backdrop:{flex:1,justifyContent:"flex-end",backgroundColor:zo},sheet:{backgroundColor:t.surface,borderTopLeftRadius:n.xl-1,borderTopRightRadius:n.xl-1,paddingHorizontal:r.lg+r.xs+r.xs/2,paddingTop:r.md,paddingBottom:n.xl,maxHeight:"88%",gap:r.md,...Wc(e.slots.dialog)},handle:{alignSelf:"center",width:r.xxl+r.xs,height:r.xs,borderRadius:n.pill,backgroundColor:t.borderRingCream},header:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.sm},headerText:{flex:1,gap:r.xs},title:{...a(i.size.heading,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),...jn(e.slots.dialog)},helper:{...a(i.size.bodyTight,i.lineHeight.normal,t.text.muted),...jn(e.slots.dialog)},helperError:{color:o},closeButton:{width:l,height:l,alignItems:"center",justifyContent:"center"},closeGlyph:{...a(i.size.verdict,i.lineHeight.tight,t.text.primary),...jn(e.slots.dialog)},actions:{gap:r.sm},removeButton:{minHeight:l,alignItems:"center",justifyContent:"center"},removeDisabled:{opacity:.5},removeText:{...a(i.size.bodyTight,i.lineHeight.snug,t.danger,"bold")},confirmBlock:{gap:r.sm,padding:r.md,borderRadius:n.md,backgroundColor:t.badgeBgCritical},confirmText:a(i.size.bodyTight,i.lineHeight.normal,t.text.primary),confirmRow:{flexDirection:"row",gap:r.sm},confirmButton:{flex:1}})}function wu(e){return e.value!==null&&Number.isFinite(e.value)}function ku(e){return e.display!==null&&e.display.length>0?e.display:e.value!==null?String(e.value):""}function xu(e){let t=e.find(e=>e.points.some(wu));if(t===void 0)return null;let r=t.points.filter(wu),n=r[0];if(n===void 0)return null;let i=r.map(e=>e.value),l=Math.min(...i),o=Math.max(...i);l===o&&(l-=1,o+=1);let a=(o-l)*.18,s=l-a,d=o+a,c=d-s,u=6,h=r.length,p=r.map((e,t)=>({xPct:h<=1?50:u+t/(h-1)*(100-2*u),yPct:(d-e.value)/c*100})),g=(d-o)/c*100,f=(d-l)/c*100,m=r.reduce((e,t)=>t.value<e.value?t:e,n),b=r.reduce((e,t)=>t.value>e.value?t:e,n),y=r[r.length-1]??n,v=t.points[t.points.length-1]??y,w=ku(v),k=w.length>0?w:ku(y);return{label:t.label,heroDisplay:k,minDisplay:ku(m),maxDisplay:ku(b),firstDate:Go(t.points[0]?.at??null),lastDate:Go(v.at),points:p,bandTopPct:g,bandBottomPct:f}}function Tu(e){let t=e.indexOf(":");return t<=0?null:e.slice(0,t)}function _u(e,t,r){let n=/* @__PURE__ */new Map,i=[];for(let t of e){let e=Tu(t.key)??"",r=n.get(e);r===void 0?(n.set(e,[t]),i.push(e)):r.push(t)}let l=t.filter(e=>n.has(e)),o=i.filter(e=>!l.includes(e));/* @__PURE__ */
367
+ return Object.freeze([...l,...o].map(e=>/* @__PURE__ */Object.freeze({entityType:e.length>0?e:null,label:e.length>0?r(e):null,series:/* @__PURE__ */Object.freeze([...n.get(e)??[]])})))}function Cu(e){return`${e}%`}function CareTimeline({series:e,testID:t}){let r=Ru(),i=n(()=>_u(e,fa,ga),[e]);return i.length===0?null:/* @__PURE__ */j(f,{style:r.section,testID:t,children:[
368
368
  /* @__PURE__ */j(f,{children:[
369
369
  /* @__PURE__ */B(Text,{style:r.sectionTitle,accessibilityRole:"header",children:ha.careTimeline}),
370
370
  /* @__PURE__ */B(Text,{style:r.sectionSub,children:ha.careTimelineSub})]}),i.map(e=>/* @__PURE__ */j(f,{style:r.group,children:[e.label===null?null:/* @__PURE__ */B(Text,{style:r.groupLabel,numberOfLines:1,children:e.label}),e.series.map(e=>/* @__PURE__ */B(SeriesCard,{series:e,styles:r},e.key))]},e.entityType??"_"))]})}function SeriesCard({series:e,styles:t}){let r=n(()=>xu([e]),[e]);if(r!==null)/* @__PURE__ */return B(TrendChart,{model:r,styles:t});let i=e.points[e.points.length-1]?.display??null,l=i!==null&&i.length>0?`${e.label}, ${i}`:e.label;/* @__PURE__ */
@@ -373,9 +373,9 @@ return j(f,{style:t.card,accessible:true,accessibilityRole:"text",accessibilityL
373
373
  return j(f,{style:t.card,testID:r,children:[
374
374
  /* @__PURE__ */j(f,{accessible:true,accessibilityRole:"text",accessibilityLabel:n,children:[
375
375
  /* @__PURE__ */B(Text,{style:t.eyebrow,numberOfLines:1,children:e.label}),e.heroDisplay.length>0?/* @__PURE__ */B(Text,{style:t.hero,numberOfLines:1,children:e.heroDisplay}):null]}),
376
- /* @__PURE__ */j(f,{style:t.plot,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:[e.points.map((e,r)=>/* @__PURE__ */B(f,{style:[t.guide,{left:_u(e.xPct)}]},`g-${r}`)),
377
- /* @__PURE__ */B(f,{style:[t.band,{top:_u(e.bandTopPct),height:_u(i)}]}),e.points.map((r,n)=>{let i=n===e.points.length-1;/* @__PURE__ */
378
- return B(f,{style:[t.point,i?t.pointLatest:null,{left:_u(r.xPct),top:_u(r.yPct)}]},`pt-${n}`)}),e.maxDisplay.length>0?/* @__PURE__ */B(Text,{style:[t.edgeLabel,{top:_u(e.bandTopPct)}],numberOfLines:1,children:e.maxDisplay}):null,e.minDisplay.length>0?/* @__PURE__ */B(Text,{style:[t.edgeLabel,{top:_u(e.bandBottomPct)}],numberOfLines:1,children:e.minDisplay}):null]}),e.firstDate.length>0||e.lastDate.length>0?/* @__PURE__ */j(f,{style:t.dates,children:[
376
+ /* @__PURE__ */j(f,{style:t.plot,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:[e.points.map((e,r)=>/* @__PURE__ */B(f,{style:[t.guide,{left:Cu(e.xPct)}]},`g-${r}`)),
377
+ /* @__PURE__ */B(f,{style:[t.band,{top:Cu(e.bandTopPct),height:Cu(i)}]}),e.points.map((r,n)=>{let i=n===e.points.length-1;/* @__PURE__ */
378
+ return B(f,{style:[t.point,i?t.pointLatest:null,{left:Cu(r.xPct),top:Cu(r.yPct)}]},`pt-${n}`)}),e.maxDisplay.length>0?/* @__PURE__ */B(Text,{style:[t.edgeLabel,{top:Cu(e.bandTopPct)}],numberOfLines:1,children:e.maxDisplay}):null,e.minDisplay.length>0?/* @__PURE__ */B(Text,{style:[t.edgeLabel,{top:Cu(e.bandBottomPct)}],numberOfLines:1,children:e.minDisplay}):null]}),e.firstDate.length>0||e.lastDate.length>0?/* @__PURE__ */j(f,{style:t.dates,children:[
379
379
  /* @__PURE__ */B(Text,{style:t.dateLabel,children:e.firstDate}),
380
380
  /* @__PURE__ */B(Text,{style:t.dateLabel,children:e.lastDate})]}):null]})}function Ru(){let e=useEverfurTheme();return n(()=>Su(e),[e])}function Su(e){let{color:t,space:r,radius:n,type:i,slots:l}=e,{size:o,lineHeight:a,letterSpacing:s}=i,d=(e,t)=>Math.round(e*t),c=v.hairlineWidth,u=jn(An(l)),h=r.xxl*3,p=r.sm,g=-(p/2),f=r.xs,m={shadowColor:t.brand,shadowOffset:{width:0,height:r.xs},shadowRadius:r.sm,shadowOpacity:.08,elevation:r.xs};return v.create({section:{gap:r.lg},sectionTitle:{...headingFace(e,"bold"),fontSize:o.subtitle,lineHeight:d(o.subtitle,a.snug),letterSpacing:-.4,color:t.text.primary},sectionSub:{...face(e,"regular"),marginTop:r.xs,fontSize:o.caption,lineHeight:d(o.caption,a.normal),color:t.text.muted},group:{gap:r.sm},groupLabel:{...face(e,"regular"),fontSize:o.caption,lineHeight:d(o.caption,a.normal),color:t.text.muted,letterSpacing:s.eyebrow,textTransform:"uppercase"},card:{gap:r.sm,padding:r.lg,borderRadius:n.lg,backgroundColor:t.surfaceCream,borderWidth:c,borderColor:t.borderRingCream,...m,...Bn(An(l),c)},eyebrow:{...face(e,"regular"),fontSize:o.caption,lineHeight:d(o.caption,a.normal),color:t.text.muted,letterSpacing:s.eyebrow,textTransform:"uppercase",...u},hero:{...face(e,"bold"),fontSize:o.verdict,lineHeight:d(o.verdict,a.tight),color:t.text.primary,letterSpacing:s.tight,...u},plot:{position:"relative",height:h,marginTop:r.xs},guide:{position:"absolute",top:0,bottom:0,width:c,backgroundColor:t.borderHairlineGreen},band:{position:"absolute",left:f,right:r.xs,borderRadius:n.sm,backgroundColor:t.brandSoft},point:{position:"absolute",width:p,height:p,marginLeft:g,marginTop:g,borderRadius:n.pill,backgroundColor:t.brand,borderWidth:c,borderColor:t.surfaceCream},pointLatest:{backgroundColor:t.accent,borderColor:t.onAccent},edgeLabel:{position:"absolute",right:0,marginTop:-r.sm,...face(e,"medium"),fontSize:o.tiny,lineHeight:d(o.tiny,a.tight),color:t.text.muted,...u},dates:{flexDirection:"row",justifyContent:"space-between"},dateLabel:{...face(e,"regular"),fontSize:o.tiny,lineHeight:d(o.tiny,a.normal),color:t.text.muted,...u}})}function RecordSections({record:e,depth:t,petName:r,showLabs:i=true,onNavigate:l,onAsk:o,factEdit:a,nowMs:s}){let d=Io(),c=Iu(),u=s??Date.now(),h=n(()=>a?applyFactOverlay(e.entities,a.overlay):e.entities,[e.entities,a]),p=n(()=>{let e=[],t=/* @__PURE__ */new Map;for(let r of h){let n=r.category.trim();if(n.length===0||au.includes(n))continue;let i=t.get(n);i===void 0?(e.push(n),t.set(n,[r])):i.push(r)}return{order:ma(e),groups:t}},[h]),g=n(()=>mu(h),[h]),b=n(()=>Jo(e.documents),[e.documents]),y=(e,t,r)=>o?/* @__PURE__ */B(m,{onPress:()=>{let t=e();o(t.prompt,t.entityRef)},accessibilityRole:"button",accessibilityLabel:t,style:[d.pill,d.pillAsk,c.ask],testID:r,children:/* @__PURE__ */B(Text,{style:d.pillAskLabel,children:t})}):null,v=a!==void 0&&a.available;/* @__PURE__ */
381
381
  return j(A,{children:[
@@ -439,7 +439,7 @@ return j(f,{style:[d.row,t>0?d.rowDivider:null],children:[
439
439
  /* @__PURE__ */B(f,{style:d.card,children:t.encounters.map((e,t)=>{let r=[e.date?Ko(e.date):null,e.clinicName,e.veterinarian].filter(e=>e&&e!=="-").join(" · ");/* @__PURE__ */
440
440
  return B(f,{style:[d.row,t>0?d.rowDivider:null],children:/* @__PURE__ */j(f,{style:d.rowMain,children:[
441
441
  /* @__PURE__ */B(Text,{style:d.rowTitle,children:e.type?ra(e.type):Zo.visit}),r?/* @__PURE__ */B(Text,{style:d.rowDetail,children:r}):null]})},e.encounterId)})})]}):null]}),
442
- /* @__PURE__ */B(DisclaimerBand,{disclaimer:e.disclaimer})]})}function zu(e,t){return e>0?e:Object.values(t).reduce((e,t)=>e+t,0)}function Iu(){let e=useEverfurTheme();return n(()=>Du(e),[e])}function Du(e){let{color:t,space:r,radius:n,type:i}=e,l=v.hairlineWidth;return v.create({sections:{gap:r.lg+r.xs},vaccineGroup:{gap:r.xs+1,marginBottom:r.sm},vaccineYear:{...face(e,"monoMedium"),fontSize:i.size.micro,lineHeight:i.size.micro+r.xs,color:t.text.muted,letterSpacing:i.letterSpacing.eyebrow,textTransform:"uppercase",paddingTop:r.xs+2},ask:{marginTop:r.lg},conflictCard:{borderRadius:n.md,borderWidth:1,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm,...Bn(An(e.slots),1)},conflictHead:{flexDirection:"row",alignItems:"center",gap:r.sm},conflictTitle:{flex:1,...headingFace(e,"bold"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.snug),color:t.text.primary,...jn(An(e.slots))},candidate:{borderTopWidth:l,borderTopColor:t.borderHairlineGreen,paddingTop:r.sm},coverageRow:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,paddingVertical:r.md},coveragePill:{borderRadius:n.pill,paddingHorizontal:r.sm+r.xs/2,paddingVertical:r.xs+1},coverageText:{...face(e,"medium"),fontSize:i.size.caption,lineHeight:i.size.caption+r.xs-1},coverageRest:e.slots.chip?.borderRadius===void 0?{}:{borderRadius:e.slots.chip.borderRadius},coverageRestText:{},coverageOnFile:e.slots.chip?.borderRadius===void 0?{}:{borderRadius:e.slots.chip.borderRadius},metaRow:{flexDirection:"row",alignItems:"center",gap:r.sm,paddingBottom:r.md},metaText:{flex:1,...face(e,"regular"),fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*i.lineHeight.snug),color:t.text.secondary},pendingText:{...face(e,"regular"),fontSize:i.size.caption,lineHeight:Math.round(i.size.caption*i.lineHeight.normal),color:t.text.muted,paddingBottom:r.md},identityLabel:{...face(e,"medium"),fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*i.lineHeight.snug),color:t.text.secondary},identityValue:{flexShrink:1,textAlign:"right",...face(e,"medium"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.snug),color:t.text.primary},cardTitle:{paddingTop:r.sm},noteSection:{paddingVertical:r.md,gap:r.xs},noteLabel:{...face(e,"bold"),fontSize:i.size.bodyTight,color:t.text.secondary,textTransform:"uppercase",letterSpacing:i.letterSpacing.eyebrow/2},noteBody:{...face(e,"regular"),fontSize:i.size.body+1,lineHeight:Math.round((i.size.body+1)*i.lineHeight.relaxed),color:t.text.primary},noteBodyMuted:{...face(e,"regular"),fontSize:i.size.body+1,lineHeight:Math.round((i.size.body+1)*i.lineHeight.relaxed),color:t.text.muted,fontStyle:"italic"}})}var Hu=/* @__PURE__ */Object.freeze({heading:"A quick call can help",fallbackPrompt:"Reaching out to the clinic directly often speeds up a slow records request.",call:"Call the clinic",callAt:e=>`Call the clinic at ${e}`});function Lu(e){return typeof e=="string"&&e.trim().length>0?e:null}function Pu(e,t){return typeof e=="string"&&e.length>0&&Lu(t)===null}var Ou="[everfur] consentVersion was passed without consentText, so the records consent gate shows no consent text above Allow. Pass the consent text your member agrees to as consentText, next to its consentVersion.",$u=false;function Bu(e,t,r){if($u||!Pu(e,t))return;let n=false;try{n=r()===!0}catch{n=false}if(!n)return;$u=true;let i=globalThis.console;try{i?.warn?.(Ou)}catch{}}function ju(e,t,r){o(()=>{Bu(e,t,r)},[e,t,r])}function Au(){let e=O();return e==="dark"?"dark":e==="light"?"light":null}function Eu(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function Fu(){let[e,t]=i(false);return o(()=>{let e=true,r=g?.isReduceMotionEnabled;if(typeof r=="function"){let n=r.call(g);n!=null&&typeof n.then=="function"&&n.then(r=>{e&&t(r===true)},()=>{})}let n=g?.addEventListener?.("reduceMotionChanged",e=>t(e===true));return()=>{e=false,n?.remove?.()}},[]),e}function qu(){let e=$?.getFontScale;if(typeof e!="function")return 1;try{let t=e.call($);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}catch{return 1}}function Mu(e){let t=S?.addEventListener;if(typeof t!="function")return()=>{};let r=t.call(S,"change",e);return()=>r?.remove?.()}function Nu(){return d(Mu,qu,qu)}function Wu(){try{let e=p?.OS;return typeof e=="string"?e:null}catch{return null}}function Uu(){return Wu()==="android"?{query:"isHighTextContrastEnabled",event:"highTextContrastChanged"}:{query:"isDarkerSystemColorsEnabled",event:"darkerSystemColorsChanged"}}function Gu(){let[e,t]=i(false);return o(()=>{let e=true,{query:r,event:n}=Uu(),i=g?.[r];if(typeof i!="function")return()=>{};try{let r=i.call(g);Eu(r)&&Promise.resolve(r).then(r=>{e&&t(r===!0)},()=>{})}catch{}let l=g?.addEventListener,o=typeof l=="function"?l.call(g,n,e=>t(e===true)):void 0;return()=>{e=false,o?.remove?.()}},[]),e}function Vu(){return Wu()==="ios"?"Menlo":vn}function Ku(){return globalThis.__DEV__!==false}var Yu=/* @__PURE__ */new Set;function Xu(e){if(!Ku()||Yu.has(e))return;Yu.add(e);let t=globalThis.console;try{t?.warn?.(`[everfur] The theme names the font face "${e}", which this app has not registered; the SDK renders the platform font at that weight instead. Register the font file (expo-font or your native font assets) or name a registered face.`)}catch{}}function Qu(e){let t=globalThis.expo?.modules?.ExpoFontLoader,r=t?.getLoadedFonts;if(typeof r!="function")return null;let n;try{n=r.call(t)}catch{return null}if(!Array.isArray(n)||n.length===0)return null;let i=n.includes(e);return i||Xu(e),i}var Ju=/* @__PURE__ */new Set;function Zu(e){let t=[];return e.type.fontSources.length>0&&t.push("fontSources"),Object.values(e.type.fontUrls).some(e=>typeof e=="string"&&e.length>0)&&t.push("fontUrls"),t}var eh=/* @__PURE__ */Object.freeze({fontSources:"appearance.fonts (font_sources)",fontUrls:"font_urls"});function th(e){if(!Ku())return;let t=Zu(e).filter(e=>!Ju.has(e));if(t.length===0)return;for(let e of t)Ju.add(e);let r=globalThis.console;try{r?.warn?.(`[everfur] The theme sets ${t.map(e=>eh[e]).join(" and ")}, which only the web SDK loads. React Native does not download fonts: register the font file with expo-font (or your native font assets) and name the family. Until then the SDK renders the family as named, or the platform font when the app reports that family missing.`)}catch{}}function rh(e){o(()=>{try{th(e)}catch{}},[e])}var nh=/* @__PURE__ */Object.freeze({useColorScheme:Au,useReducedMotion:Fu,useTextScale:Nu,useHighContrast:Gu,scaleTypeSizes:false,typeProfile:"phone",platformMonoFamily:Vu,isFontRegistered:Qu,useResolvedTheme:rh,isDevelopment:Ku});var ih=()=>nh.isDevelopment?.()===true;function lh(e,t){ju(e,t,ih)}var oh=Math.round(mt/(1024*1024)),ah=/* @__PURE__ */Object.freeze({title:e=>`Upload ${Qn(e)}’s records`,screenTitle:"Upload a document",subtitle:e=>`Already have lab results, a vet summary, or test reports? Add them here and we’ll read them and pull out ${Qn(e)}’s health markers.`,noPet:"Select a pet first, then upload their records.",cardTitle:"Add records",cardSubtitle:`Upload PDF records you already have, up to ${oh} MB each. You can pick several at once. We’ll read them and add the results to your records.`,chooseFiles:"Choose a file",uploading:(e,t)=>`Uploading ${Math.min(e+1,t)} of ${t}…`,cancel:"Cancel",cancelA11y:"Cancel these uploads",received:e=>`${e===1?"Record received.":`${e} records received.`} We’ll read and review ${e===1?"it":"them"}, then add the results to your records, usually within 1-2 business days.`,retryFailed:e=>`Retry ${e} that didn’t upload`,haveMore:"Have more?",addMore:"Upload another document",addMoreA11y:"Upload another document",done:"Done",doneA11y:"Done, view records",errors:/* @__PURE__ */Object.freeze({start:"We couldn’t start that upload. Check your connection and try again.",startPlain:"We couldn’t start that upload. Please try again.",upload:"We couldn’t upload that record. Check your connection and try again."})}),sh=/* @__PURE__ */Object.freeze({note:"A PDF, or a photo of a paper record. Add them all; we sort them by date.",takePhoto:"Take a photo",takePhotoMeta:"of a paper record",choosePhotos:"Choose from photos",chooseFileMeta:"PDF",haveMoreLead:"PDFs and photos of paper records both work. Add them all; we sort them by date.",unreadable:"We can’t read this kind of file. Upload a PDF or a photo of the record."});function dh(e,t){return`${e} ${t}`}var ch=Math.round(mt/(1024*1024)),uh=/* @__PURE__ */Object.freeze({queued:"Queued",verifying:"Verifying…",done:"Done",failed:"Failed",uploading:(e,t)=>`Uploading ${Math.min(e+1,t)} of ${t} records`,uploaded:(e,t)=>`${e} of ${t} records uploaded`});function hh(e){let t=Math.round(e.progress*100);switch(e.status){case"done":return uh.done;case"failed":return uh.failed;case"uploading":return e.progress>=1?uh.verifying:`${t}%`;case"queued":return uh.queued;default:return null}}function ph(e,t=false){if(e.length===0)return null;let r=e=>{let t=e.map(e=>e.name??"");return t.length<=3?t.join(", "):`${t.slice(0,3).join(", ")} and ${t.length-3} more`},n=e.filter(e=>e.reason==="too_large"),i=e.filter(e=>e.reason==="unsupported");if(t){let e=[];return i.length>0&&e.push(sh.unreadable),n.length>0&&e.push(`Didn’t upload: ${r(n)} ${n.length>1?"are":"is"} over ${ch} MB.`),e.join(" ")}let l=[];return i.length>0&&l.push(`${r(i)} ${i.length>1?"are not PDFs":"is not a PDF"}`),n.length>0&&l.push(`${r(n)} ${n.length>1?"are":"is"} over ${ch} MB`),`Didn’t upload: ${l.join("; ")}. We can only read PDFs up to ${ch} MB right now.`}function gh(e){let t=[];for(let r of e)r.status==="skipped"&&r.skipReason!==null&&t.push({name:r.name,reason:r.skipReason});return t}var fh=/* @__PURE__ */Object.freeze({email:"Clinic email",emailPlaceholder:"records@clinic.com",emailError:"Enter a valid clinic email.",updateEmail:"Update email & resend",retry:"Retry sending",retryA11y:"Retry sending records request",retryHint:"Save the updated email first, then retry.",cancelRequest:"Cancel request",keepRequest:"Keep it",uploadInstead:"Upload instead",cancelQuestion:"Cancel this request?",cancelConsequence:"We’ll stop sending reminders to the clinic. If the clinic has already sent records, they may still arrive. You can start a new request or upload your own records anytime."});function mh({request:e,onRecovered:t,canUpload:n=false},l){let[a,s]=i(""),[d,c]=i(false),[u,h]=i(null),[p,g]=i(false),[f,m]=i(null),b=r(false),y=r(false),v=r(0);o(()=>(y.current=true,()=>{y.current=false,v.current+=1}),[l]);let w=f!==null&&f.before===e.updatedAt?{...f.value,canRetrySend:e.canRetrySend===true&&f.value.canRetrySend===true,canUpdateClinicEmail:e.canUpdateClinicEmail===true&&f.value.canUpdateClinicEmail===true,canRevoke:e.canRevoke===true&&f.value.canRevoke===true,canConvertToUpload:e.canConvertToUpload===true&&f.value.canConvertToUpload===true}:e,k=a.trim(),x=k.length<=320&&!Array.from(k).some(e=>e.charCodeAt(0)<=32||e.charCodeAt(0)===127)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(k),T=w.canUpdateClinicEmail===true&&k.length>0,C=w.canRetrySend===true&&!d&&!T,_=w.canUpdateClinicEmail===true&&!d&&x,R=w.canConvertToUpload===true&&n,S=async r=>{let n={retry:C,email:_,revoke:w.canRevoke===true&&p,convert:R};if(b.current||!y.current||!n[r])return;b.current=true,c(true),h(null);let i=v.current,o=()=>y.current&&i===v.current;try{let n=r==="retry"?await l.retryRequest(e.id):r==="email"?await l.updateClinicEmail(e.id,k):r==="revoke"?await l.revokeRequest(e.id):await l.convertToUpload(e.id);if(!o())return;if(!n.ok){h(n.error);return}if(n.value.id!==e.id||n.value.petRef!==e.petRef){h(makeEverfurError("internalError"));return}m({before:e.updatedAt,value:n.value}),s(""),g(!1),t()}catch{o()&&h(makeEverfurError("internalError"))}finally{b.current=false,o()&&c(false)}};return{request:w,email:a,busy:d,error:u,canRetry:C,canUpdateEmail:_,canConvert:R,hasEmailEdit:T,confirmingRevoke:p&&w.canRevoke===true,emailInvalid:k.length>0&&!x,setEmail(e){b.current||(s(e),h(null))},retry:()=>S("retry"),updateEmail:()=>S("email"),revoke:()=>S("revoke"),convert:()=>S("convert"),askRevoke(){!b.current&&w.canRevoke===true&&g(true)},keepRequest(){b.current||g(false)}}}var bh=["requested","sent_to_clinic","awaiting_clinic","records_received","processing","ready"],yh=["requested","awaiting_upload","records_received","processing","ready"],vh=["requested","sent_to_clinic","awaiting_clinic","awaiting_upload","records_received","processing","ready"],wh=/* @__PURE__ */Object.freeze({requested:"Request created",sent_to_clinic:"Sent to the clinic",awaiting_clinic:"Waiting on the clinic",awaiting_upload:"Add your records",records_received:"Records received",processing:"Preparing your records",parsing_failed:"Needs a closer look",manual_review:"Our team is reviewing it",ready:"Ready to view",delivery_failed:"Email could not be delivered",processing_failed:"Could not process the records",clinic_declined:"Clinic declined the request",clinic_no_records:"Clinic replied without your records",no_response:"No response from the clinic",revoked:"You cancelled this request"}),kh=/* @__PURE__ */Object.freeze({requested:"Request sent",sent_to_clinic:"Clinic notified",awaiting_clinic:"Waiting for records…"}),xh=/* @__PURE__ */Object.freeze({notified:e=>`A secure request went to ${e}.`,received:"Everfur reads every page: dates, vaccines, labs and prescriptions.",added:e=>`Added to ${e}’s records`}),Th=/* @__PURE__ */Object.freeze({delivered:"Email delivered to the clinic",emailing:"Emailing the clinic",bounced:"The clinic email did not go through",waiting:"Waiting for the clinic to send the records",upload:"Upload the records you already have",ownerAdded:"You added these records",clinicSent:"The clinic sent the records",preparing:"Getting your records ready to view",ready:"Your records are ready to view",parsingFailed:"We couldn’t read this one automatically",manualReview:"Checking these by hand so nothing’s missed",switchedTitle:"Stopped waiting on the clinic",switched:"You switched to uploading your own records"}),Ch=/* @__PURE__ */Object.freeze({delivery_failed:"The clinic email could not be delivered",processing_failed:"We could not read these records",clinic_declined:"The clinic declined to release records",clinic_no_records:"The clinic replied without records",no_response:"No reply after repeated reminders",revoked:"You cancelled this request"}),_h=/* @__PURE__ */Object.freeze({requested:"sent",awaiting_clinic:"awaiting_response",awaiting_upload:"awaiting_upload",received:"records_received",parsing:"parsing",in_review:"in_review",published:"published",failed:"failed",revoked:"revoked"});function Rh(e){return e.wireStatus??_h[e.status]??"sent"}function Sh(e,t){return e!=="awaiting_response"||t<=0?null:`${t} ${t===1?"reminder":"reminders"} sent`}function zh(e){switch(e){case"submitted":case"sent":return 1;case"awaiting_response":return 2;case"records_received":return 3;case"parsing":case"parsing_failed":case"in_review":case"review_email_failed":return 4;case"published":return 5;default:return-1}}function Ih(e){switch(e.dispatchStatus){case"sent":return Th.delivered;case"preparing":case"queued":case"sending":return Th.emailing;case"failed":return Th.bounced;default:return null}}function Dh(e,t){return Sh(t,e.reminderCount??0)??Th.waiting}function Hh(e){return e.source==="owner_provided"||!!e.convertedToUploadAt}function Lh(e,t,r){let n=Hh(t);switch(e){case"sent_to_clinic":return Ih(t);case"awaiting_clinic":return Dh(t,r);case"awaiting_upload":return Th.upload;case"records_received":return n?Th.ownerAdded:Th.clinicSent;case"processing":return Th.preparing;case"ready":return Th.ready;default:return null}}function Ph(e,t){return!!e.reviewStartedAt||t==="parsing_failed"||t==="review_email_failed"}function Oh(e,t,r){if(e.key!=="processing"||!Ph(t,r))return[e];let n=r==="parsing_failed",i=r==="published",l=i?"done":n?"current":"done",o=i?"done":n?"upcoming":"current";return[{key:"parsing_failed",title:wh.parsing_failed,detail:Th.parsingFailed,at:null,state:l},{key:"manual_review",title:wh.manual_review,detail:Th.manualReview,at:t.reviewStartedAt??null,state:o}]}function $h(e){switch(e){case"awaiting_upload":return 3;case"records_received":return 4;case"parsing":case"parsing_failed":case"in_review":case"review_email_failed":return 5;case"published":return 6;default:return 3}}function Bh(e){return{key:"awaiting_clinic",title:Th.switchedTitle,detail:Th.switched,at:e.convertedToUploadAt??null,state:"done"}}function jh(e){switch(e){case"submitted":case"sent":return 0;case"awaiting_upload":return 1;case"records_received":return 2;case"parsing":case"parsing_failed":case"in_review":case"review_email_failed":return 3;case"published":return 4;default:return-1}}function Ah(e,t,r){switch(e){case"requested":return t.createdAt||null;case"awaiting_clinic":return t.lastReminderAt??null;case"processing":return t.parsingStartedAt??t.reviewStartedAt??null;case"ready":return r==="published"&&t.updatedAt||null;default:return null}}function Eh(e,t,r,n){return{key:e,title:wh[e],detail:Lh(e,t,r),at:Ah(e,t,r),state:n}}function Fh(e,t){return{key:e,title:wh[e],detail:Ch[e]??null,at:t.updatedAt||null,state:"failed"}}function qh(e,t,r,n,i){return e.map((e,l)=>{let o=i?.(e)??null;if(o!==null)return o;let a=n==="published"||l<t?"done":l===t?"current":"upcoming";return Eh(e,r,n,a)}).flatMap(e=>Oh(e,r,n))}function buildRequestTimeline(e,t={}){return Nh(Wh(e),e,t.petName??null,t.sandbox===true)}function Mh(e){return Wh(e)}function Nh(e,t,r,n){let i=t.source!=="owner_provided"&&!e.some(e=>e.key==="delivery_failed"),l=t.clinicEmail?.trim()??"";return e.map(e=>{if(e.title!==wh[e.key])return e;if(e.key==="ready")return{...e,title:xh.added(Qn(r))};if(!i)return e;if(n&&e.key==="sent_to_clinic")return{...e,title:fl.clinicNotContacted,detail:l.length>0?fl.notEmailed(l):null};let o=kh[e.key]??e.title;return e.key==="sent_to_clinic"&&t.dispatchStatus==="sent"&&l.length>0?{...e,title:o,detail:xh.notified(l)}:e.key==="records_received"&&!Hh(t)?{...e,title:o,detail:xh.received}:{...e,title:o}})}function Wh(e){let t=Rh(e),r=r=>Eh(r,e,t,"done");if(t==="revoked")return[r("requested"),Fh("revoked",e)];if(e.convertedToUploadAt)return t==="failed"?[r("requested"),r("sent_to_clinic"),Bh(e),r("awaiting_upload"),r("records_received"),Fh("processing_failed",e)]:qh(vh,$h(t),e,t,t=>t==="awaiting_clinic"?Bh(e):null);if(e.source==="owner_provided"){if(t==="failed"||t==="clinic_declined")return[r("requested"),r("awaiting_upload"),r("records_received"),Fh("processing_failed",e)];let n=jh(t);return qh(yh,n<0?1:n,e,t)}if(t==="clinic_declined")return[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),Fh("clinic_declined",e)];if(t==="clinic_responded_no_records")return[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),Fh("clinic_no_records",e)];if(t==="failed"){let t=e.failureCode??null;return t==="no_response"?[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),Fh("no_response",e)]:t==="hard_bounce"||t==="dispatch_failed"?[r("requested"),Fh("delivery_failed",e)]:t==="parse_timeout"||t==="parse_error"||e.dispatchStatus==="sent"?[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),r("records_received"),Fh("processing_failed",e)]:[r("requested"),Fh("delivery_failed",e)]}let n=zh(t);return qh(bh,n<0?1:n,e,t)}var Uh=/* @__PURE__ */Object.freeze({done:"completed",current:"in progress",failed:"needs attention",upcoming:"not started"}),Gh=28,Vh="Now",Kh=10;function RequestTimeline({request:e,petName:t}){let r=Yh(),n=yl(),i=buildRequestTimeline(e,{petName:t??null,sandbox:n});/* @__PURE__ */
442
+ /* @__PURE__ */B(DisclaimerBand,{disclaimer:e.disclaimer})]})}function zu(e,t){return e>0?e:Object.values(t).reduce((e,t)=>e+t,0)}function Iu(){let e=useEverfurTheme();return n(()=>Du(e),[e])}function Du(e){let{color:t,space:r,radius:n,type:i}=e,l=v.hairlineWidth;return v.create({sections:{gap:r.lg+r.xs},vaccineGroup:{gap:r.xs+1,marginBottom:r.sm},vaccineYear:{...face(e,"monoMedium"),fontSize:i.size.micro,lineHeight:i.size.micro+r.xs,color:t.text.muted,letterSpacing:i.letterSpacing.eyebrow,textTransform:"uppercase",paddingTop:r.xs+2},ask:{marginTop:r.lg},conflictCard:{borderRadius:n.md,borderWidth:1,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm,...Bn(An(e.slots),1)},conflictHead:{flexDirection:"row",alignItems:"center",gap:r.sm},conflictTitle:{flex:1,...headingFace(e,"bold"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.snug),color:t.text.primary,...jn(An(e.slots))},candidate:{borderTopWidth:l,borderTopColor:t.borderHairlineGreen,paddingTop:r.sm},coverageRow:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,paddingVertical:r.md},coveragePill:{borderRadius:n.pill,paddingHorizontal:r.sm+r.xs/2,paddingVertical:r.xs+1},coverageText:{...face(e,"medium"),fontSize:i.size.caption,lineHeight:i.size.caption+r.xs-1},coverageRest:e.slots.chip?.borderRadius===void 0?{}:{borderRadius:e.slots.chip.borderRadius},coverageRestText:{},coverageOnFile:e.slots.chip?.borderRadius===void 0?{}:{borderRadius:e.slots.chip.borderRadius},metaRow:{flexDirection:"row",alignItems:"center",gap:r.sm,paddingBottom:r.md},metaText:{flex:1,...face(e,"regular"),fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*i.lineHeight.snug),color:t.text.secondary},pendingText:{...face(e,"regular"),fontSize:i.size.caption,lineHeight:Math.round(i.size.caption*i.lineHeight.normal),color:t.text.muted,paddingBottom:r.md},identityLabel:{...face(e,"medium"),fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*i.lineHeight.snug),color:t.text.secondary},identityValue:{flexShrink:1,textAlign:"right",...face(e,"medium"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.snug),color:t.text.primary},cardTitle:{paddingTop:r.sm},noteSection:{paddingVertical:r.md,gap:r.xs},noteLabel:{...face(e,"bold"),fontSize:i.size.bodyTight,color:t.text.secondary,textTransform:"uppercase",letterSpacing:i.letterSpacing.eyebrow/2},noteBody:{...face(e,"regular"),fontSize:i.size.body+1,lineHeight:Math.round((i.size.body+1)*i.lineHeight.relaxed),color:t.text.primary},noteBodyMuted:{...face(e,"regular"),fontSize:i.size.body+1,lineHeight:Math.round((i.size.body+1)*i.lineHeight.relaxed),color:t.text.muted,fontStyle:"italic"}})}var Hu=/* @__PURE__ */Object.freeze({heading:"A quick call can help",fallbackPrompt:"Reaching out to the clinic directly often speeds up a slow records request.",call:"Call the clinic",callAt:e=>`Call the clinic at ${e}`});function Lu(e){return typeof e=="string"&&e.trim().length>0?e:null}function Pu(e,t){return typeof e=="string"&&e.length>0&&Lu(t)===null}var Ou="[everfur] consentVersion was passed without consentText, so the records consent gate shows no consent text above Allow. Pass the consent text your member agrees to as consentText, next to its consentVersion.",$u=false;function Bu(e,t,r){if($u||!Pu(e,t))return;let n=false;try{n=r()===!0}catch{n=false}if(!n)return;$u=true;let i=globalThis.console;try{i?.warn?.(Ou)}catch{}}function ju(e,t,r){o(()=>{Bu(e,t,r)},[e,t,r])}function Au(){let e=O();return e==="dark"?"dark":e==="light"?"light":null}function Eu(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function Fu(){let[e,t]=i(false);return o(()=>{let e=true,r=g?.isReduceMotionEnabled;if(typeof r=="function"){let n=r.call(g);n!=null&&typeof n.then=="function"&&n.then(r=>{e&&t(r===true)},()=>{})}let n=g?.addEventListener?.("reduceMotionChanged",e=>t(e===true));return()=>{e=false,n?.remove?.()}},[]),e}function qu(){let e=$?.getFontScale;if(typeof e!="function")return 1;try{let t=e.call($);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}catch{return 1}}function Mu(e){let t=S?.addEventListener;if(typeof t!="function")return()=>{};let r=t.call(S,"change",e);return()=>r?.remove?.()}function Nu(){return d(Mu,qu,qu)}function Wu(){try{let e=p?.OS;return typeof e=="string"?e:null}catch{return null}}function Uu(){return Wu()==="android"?{query:"isHighTextContrastEnabled",event:"highTextContrastChanged"}:{query:"isDarkerSystemColorsEnabled",event:"darkerSystemColorsChanged"}}function Gu(){let[e,t]=i(false);return o(()=>{let e=true,{query:r,event:n}=Uu(),i=g?.[r];if(typeof i!="function")return()=>{};try{let r=i.call(g);Eu(r)&&Promise.resolve(r).then(r=>{e&&t(r===!0)},()=>{})}catch{}let l=g?.addEventListener,o=typeof l=="function"?l.call(g,n,e=>t(e===true)):void 0;return()=>{e=false,o?.remove?.()}},[]),e}function Vu(){return Wu()==="ios"?"Menlo":vn}function Ku(){return globalThis.__DEV__!==false}var Yu=/* @__PURE__ */new Set;function Xu(e){if(!Ku()||Yu.has(e))return;Yu.add(e);let t=globalThis.console;try{t?.warn?.(`[everfur] The theme names the font face "${e}", which this app has not registered; the SDK renders the platform font at that weight instead. Register the font file (expo-font or your native font assets) or name a registered face.`)}catch{}}function Qu(e){let t=globalThis.expo?.modules?.ExpoFontLoader,r=t?.getLoadedFonts;if(typeof r!="function")return null;let n;try{n=r.call(t)}catch{return null}if(!Array.isArray(n)||n.length===0)return null;let i=n.includes(e);return i||Xu(e),i}var Ju=/* @__PURE__ */new Set;function Zu(e){let t=[];return e.type.fontSources.length>0&&t.push("fontSources"),Object.values(e.type.fontUrls).some(e=>typeof e=="string"&&e.length>0)&&t.push("fontUrls"),t}var eh=/* @__PURE__ */Object.freeze({fontSources:"appearance.fonts (font_sources)",fontUrls:"font_urls"});function th(e){if(!Ku())return;let t=Zu(e).filter(e=>!Ju.has(e));if(t.length===0)return;for(let e of t)Ju.add(e);let r=globalThis.console;try{r?.warn?.(`[everfur] The theme sets ${t.map(e=>eh[e]).join(" and ")}, which only the web SDK loads. React Native does not download fonts: register the font file with expo-font (or your native font assets) and name the family. Until then the SDK renders the family as named, or the platform font when the app reports that family missing.`)}catch{}}function rh(e){o(()=>{try{th(e)}catch{}},[e])}var nh=/* @__PURE__ */Object.freeze({useColorScheme:Au,useReducedMotion:Fu,useTextScale:Nu,useHighContrast:Gu,scaleTypeSizes:false,typeProfile:"phone",platformMonoFamily:Vu,isFontRegistered:Qu,useResolvedTheme:rh,isDevelopment:Ku});var ih=()=>nh.isDevelopment?.()===true;function lh(e,t){ju(e,t,ih)}var oh=Math.round(mt/(1024*1024)),ah=/* @__PURE__ */Object.freeze({title:e=>`Upload ${Qn(e)}’s records`,screenTitle:"Upload a document",subtitle:e=>`Already have lab results, a vet summary, or test reports? Add them here and we’ll read them and pull out ${Qn(e)}’s health markers.`,noPet:"Select a pet first, then upload their records.",cardTitle:"Add records",cardSubtitle:`Upload PDF records you already have, up to ${oh} MB each. You can pick several at once. We’ll read them and add the results to your records.`,chooseFiles:"Choose a file",uploading:(e,t)=>`Uploading ${Math.min(e+1,t)} of ${t}…`,cancel:"Cancel",cancelA11y:"Cancel these uploads",received:e=>`${e===1?"Record received.":`${e} records received.`} We’ll read and review ${e===1?"it":"them"}, then add the results to your records, usually within 1-2 business days.`,retryFailed:e=>`Retry ${e} that didn’t upload`,haveMore:"Have more?",addMore:"Upload another document",addMoreA11y:"Upload another document",done:"Done",doneA11y:"Done, view records",errors:/* @__PURE__ */Object.freeze({start:"We couldn’t start that upload. Check your connection and try again.",startPlain:"We couldn’t start that upload. Please try again.",upload:"We couldn’t upload that record. Check your connection and try again."})}),sh=/* @__PURE__ */Object.freeze({note:"A PDF, or a photo of a paper record. Add them all; we sort them by date.",takePhoto:"Take a photo",takePhotoMeta:"of a paper record",choosePhotos:"Choose from photos",chooseFileMeta:"PDF",haveMoreLead:"PDFs and photos of paper records both work. Add them all; we sort them by date.",unreadable:"We can’t read this kind of file. Upload a PDF or a photo of the record."});function dh(e,t){return`${e} ${t}`}var ch=Math.round(mt/(1024*1024)),uh=/* @__PURE__ */Object.freeze({queued:"Queued",verifying:"Verifying…",done:"Done",failed:"Failed",uploading:(e,t)=>`Uploading ${Math.min(e+1,t)} of ${t} records`,uploaded:(e,t)=>`${e} of ${t} records uploaded`});function hh(e){let t=Math.round(e.progress*100);switch(e.status){case"done":return uh.done;case"failed":return uh.failed;case"uploading":return e.progress>=1?uh.verifying:`${t}%`;case"queued":return uh.queued;default:return null}}function ph(e,t=false){if(e.length===0)return null;let r=e=>{let t=e.map(e=>e.name??"");return t.length<=3?t.join(", "):`${t.slice(0,3).join(", ")} and ${t.length-3} more`},n=e.filter(e=>e.reason==="too_large"),i=e.filter(e=>e.reason==="unsupported");if(t){let e=[];return i.length>0&&e.push(sh.unreadable),n.length>0&&e.push(`Didn’t upload: ${r(n)} ${n.length>1?"are":"is"} over ${ch} MB.`),e.join(" ")}let l=[];return i.length>0&&l.push(`${r(i)} ${i.length>1?"are not PDFs":"is not a PDF"}`),n.length>0&&l.push(`${r(n)} ${n.length>1?"are":"is"} over ${ch} MB`),`Didn’t upload: ${l.join("; ")}. We can only read PDFs up to ${ch} MB right now.`}function gh(e){let t=[];for(let r of e)r.status==="skipped"&&r.skipReason!==null&&t.push({name:r.name,reason:r.skipReason});return t}var fh=/* @__PURE__ */Object.freeze({email:"Clinic email",emailPlaceholder:"records@clinic.com",emailError:"Enter a valid clinic email.",updateEmail:"Update email & resend",retry:"Retry sending",retryA11y:"Retry sending records request",retryHint:"Save the updated email first, then retry.",cancelRequest:"Cancel request",keepRequest:"Keep it",uploadInstead:"Upload instead",cancelQuestion:"Cancel this request?",cancelConsequence:"We’ll stop sending reminders to the clinic. If the clinic has already sent records, they may still arrive. You can start a new request or upload your own records anytime."});function mh({request:e,onRecovered:t,canUpload:n=false},l){let[a,s]=i(""),[d,c]=i(false),[u,h]=i(null),[p,g]=i(false),[f,m]=i(null),b=r(false),y=r(false),v=r(0);o(()=>(y.current=true,()=>{y.current=false,v.current+=1}),[l]);let w=f!==null&&f.before===e.updatedAt?{...f.value,canRetrySend:e.canRetrySend===true&&f.value.canRetrySend===true,canUpdateClinicEmail:e.canUpdateClinicEmail===true&&f.value.canUpdateClinicEmail===true,canRevoke:e.canRevoke===true&&f.value.canRevoke===true,canConvertToUpload:e.canConvertToUpload===true&&f.value.canConvertToUpload===true}:e,k=a.trim(),x=k.length<=320&&!Array.from(k).some(e=>e.charCodeAt(0)<=32||e.charCodeAt(0)===127)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(k),T=w.canUpdateClinicEmail===true&&k.length>0,_=w.canRetrySend===true&&!d&&!T,C=w.canUpdateClinicEmail===true&&!d&&x,R=w.canConvertToUpload===true&&n,S=async r=>{let n={retry:_,email:C,revoke:w.canRevoke===true&&p,convert:R};if(b.current||!y.current||!n[r])return;b.current=true,c(true),h(null);let i=v.current,o=()=>y.current&&i===v.current;try{let n=r==="retry"?await l.retryRequest(e.id):r==="email"?await l.updateClinicEmail(e.id,k):r==="revoke"?await l.revokeRequest(e.id):await l.convertToUpload(e.id);if(!o())return;if(!n.ok){h(n.error);return}if(n.value.id!==e.id||n.value.petRef!==e.petRef){h(makeEverfurError("internalError"));return}m({before:e.updatedAt,value:n.value}),s(""),g(!1),t()}catch{o()&&h(makeEverfurError("internalError"))}finally{b.current=false,o()&&c(false)}};return{request:w,email:a,busy:d,error:u,canRetry:_,canUpdateEmail:C,canConvert:R,hasEmailEdit:T,confirmingRevoke:p&&w.canRevoke===true,emailInvalid:k.length>0&&!x,setEmail(e){b.current||(s(e),h(null))},retry:()=>S("retry"),updateEmail:()=>S("email"),revoke:()=>S("revoke"),convert:()=>S("convert"),askRevoke(){!b.current&&w.canRevoke===true&&g(true)},keepRequest(){b.current||g(false)}}}var bh=["requested","sent_to_clinic","awaiting_clinic","records_received","processing","ready"],yh=["requested","awaiting_upload","records_received","processing","ready"],vh=["requested","sent_to_clinic","awaiting_clinic","awaiting_upload","records_received","processing","ready"],wh=/* @__PURE__ */Object.freeze({requested:"Request created",sent_to_clinic:"Sent to the clinic",awaiting_clinic:"Waiting on the clinic",awaiting_upload:"Add your records",records_received:"Records received",processing:"Preparing your records",parsing_failed:"Needs a closer look",manual_review:"Our team is reviewing it",ready:"Ready to view",delivery_failed:"Email could not be delivered",processing_failed:"Could not process the records",clinic_declined:"Clinic declined the request",clinic_no_records:"Clinic replied without your records",no_response:"No response from the clinic",revoked:"You cancelled this request"}),kh=/* @__PURE__ */Object.freeze({requested:"Request sent",sent_to_clinic:"Clinic notified",awaiting_clinic:"Waiting for records…"}),xh=/* @__PURE__ */Object.freeze({notified:e=>`A secure request went to ${e}.`,received:"Everfur reads every page: dates, vaccines, labs and prescriptions.",added:e=>`Added to ${e}’s records`}),Th=/* @__PURE__ */Object.freeze({delivered:"Email delivered to the clinic",emailing:"Emailing the clinic",bounced:"The clinic email did not go through",waiting:"Waiting for the clinic to send the records",upload:"Upload the records you already have",ownerAdded:"You added these records",clinicSent:"The clinic sent the records",preparing:"Getting your records ready to view",ready:"Your records are ready to view",parsingFailed:"We couldn’t read this one automatically",manualReview:"Checking these by hand so nothing’s missed",switchedTitle:"Stopped waiting on the clinic",switched:"You switched to uploading your own records"}),_h=/* @__PURE__ */Object.freeze({delivery_failed:"The clinic email could not be delivered",processing_failed:"We could not read these records",clinic_declined:"The clinic declined to release records",clinic_no_records:"The clinic replied without records",no_response:"No reply after repeated reminders",revoked:"You cancelled this request"}),Ch=/* @__PURE__ */Object.freeze({requested:"sent",awaiting_clinic:"awaiting_response",awaiting_upload:"awaiting_upload",received:"records_received",parsing:"parsing",in_review:"in_review",published:"published",failed:"failed",revoked:"revoked"});function Rh(e){return e.wireStatus??Ch[e.status]??"sent"}function Sh(e,t){return e!=="awaiting_response"||t<=0?null:`${t} ${t===1?"reminder":"reminders"} sent`}function zh(e){switch(e){case"submitted":case"sent":return 1;case"awaiting_response":return 2;case"records_received":return 3;case"parsing":case"parsing_failed":case"in_review":case"review_email_failed":return 4;case"published":return 5;default:return-1}}function Ih(e){switch(e.dispatchStatus){case"sent":return Th.delivered;case"preparing":case"queued":case"sending":return Th.emailing;case"failed":return Th.bounced;default:return null}}function Dh(e,t){return Sh(t,e.reminderCount??0)??Th.waiting}function Hh(e){return e.source==="owner_provided"||!!e.convertedToUploadAt}function Lh(e,t,r){let n=Hh(t);switch(e){case"sent_to_clinic":return Ih(t);case"awaiting_clinic":return Dh(t,r);case"awaiting_upload":return Th.upload;case"records_received":return n?Th.ownerAdded:Th.clinicSent;case"processing":return Th.preparing;case"ready":return Th.ready;default:return null}}function Ph(e,t){return!!e.reviewStartedAt||t==="parsing_failed"||t==="review_email_failed"}function Oh(e,t,r){if(e.key!=="processing"||!Ph(t,r))return[e];let n=r==="parsing_failed",i=r==="published",l=i?"done":n?"current":"done",o=i?"done":n?"upcoming":"current";return[{key:"parsing_failed",title:wh.parsing_failed,detail:Th.parsingFailed,at:null,state:l},{key:"manual_review",title:wh.manual_review,detail:Th.manualReview,at:t.reviewStartedAt??null,state:o}]}function $h(e){switch(e){case"awaiting_upload":return 3;case"records_received":return 4;case"parsing":case"parsing_failed":case"in_review":case"review_email_failed":return 5;case"published":return 6;default:return 3}}function Bh(e){return{key:"awaiting_clinic",title:Th.switchedTitle,detail:Th.switched,at:e.convertedToUploadAt??null,state:"done"}}function jh(e){switch(e){case"submitted":case"sent":return 0;case"awaiting_upload":return 1;case"records_received":return 2;case"parsing":case"parsing_failed":case"in_review":case"review_email_failed":return 3;case"published":return 4;default:return-1}}function Ah(e,t,r){switch(e){case"requested":return t.createdAt||null;case"awaiting_clinic":return t.lastReminderAt??null;case"processing":return t.parsingStartedAt??t.reviewStartedAt??null;case"ready":return r==="published"&&t.updatedAt||null;default:return null}}function Eh(e,t,r,n){return{key:e,title:wh[e],detail:Lh(e,t,r),at:Ah(e,t,r),state:n}}function Fh(e,t){return{key:e,title:wh[e],detail:_h[e]??null,at:t.updatedAt||null,state:"failed"}}function qh(e,t,r,n,i){return e.map((e,l)=>{let o=i?.(e)??null;if(o!==null)return o;let a=n==="published"||l<t?"done":l===t?"current":"upcoming";return Eh(e,r,n,a)}).flatMap(e=>Oh(e,r,n))}function buildRequestTimeline(e,t={}){return Nh(Wh(e),e,t.petName??null,t.sandbox===true)}function Mh(e){return Wh(e)}function Nh(e,t,r,n){let i=t.source!=="owner_provided"&&!e.some(e=>e.key==="delivery_failed"),l=t.clinicEmail?.trim()??"";return e.map(e=>{if(e.title!==wh[e.key])return e;if(e.key==="ready")return{...e,title:xh.added(Qn(r))};if(!i)return e;if(n&&e.key==="sent_to_clinic")return{...e,title:fl.clinicNotContacted,detail:l.length>0?fl.notEmailed(l):null};let o=kh[e.key]??e.title;return e.key==="sent_to_clinic"&&t.dispatchStatus==="sent"&&l.length>0?{...e,title:o,detail:xh.notified(l)}:e.key==="records_received"&&!Hh(t)?{...e,title:o,detail:xh.received}:{...e,title:o}})}function Wh(e){let t=Rh(e),r=r=>Eh(r,e,t,"done");if(t==="revoked")return[r("requested"),Fh("revoked",e)];if(e.convertedToUploadAt)return t==="failed"?[r("requested"),r("sent_to_clinic"),Bh(e),r("awaiting_upload"),r("records_received"),Fh("processing_failed",e)]:qh(vh,$h(t),e,t,t=>t==="awaiting_clinic"?Bh(e):null);if(e.source==="owner_provided"){if(t==="failed"||t==="clinic_declined")return[r("requested"),r("awaiting_upload"),r("records_received"),Fh("processing_failed",e)];let n=jh(t);return qh(yh,n<0?1:n,e,t)}if(t==="clinic_declined")return[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),Fh("clinic_declined",e)];if(t==="clinic_responded_no_records")return[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),Fh("clinic_no_records",e)];if(t==="failed"){let t=e.failureCode??null;return t==="no_response"?[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),Fh("no_response",e)]:t==="hard_bounce"||t==="dispatch_failed"?[r("requested"),Fh("delivery_failed",e)]:t==="parse_timeout"||t==="parse_error"||e.dispatchStatus==="sent"?[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),r("records_received"),Fh("processing_failed",e)]:[r("requested"),Fh("delivery_failed",e)]}let n=zh(t);return qh(bh,n<0?1:n,e,t)}var Uh=/* @__PURE__ */Object.freeze({done:"completed",current:"in progress",failed:"needs attention",upcoming:"not started"}),Gh=28,Vh="Now",Kh=10;function RequestTimeline({request:e,petName:t}){let r=Yh(),n=yl(),i=buildRequestTimeline(e,{petName:t??null,sandbox:n});/* @__PURE__ */
443
443
  return B(f,{style:r.container,accessibilityRole:"summary",children:i.map((e,t)=>/* @__PURE__ */B(TimelineRow,{event:e,isLast:t===i.length-1,styles:r},e.key))})}function TimelineRow({event:e,isLast:t,styles:r}){let n=e.at?Xo(e.at):null,i=[e.title,e.detail,n,Uh[e.state]].filter(Boolean);/* @__PURE__ */
444
444
  return j(f,{style:r.row,accessible:true,accessibilityRole:"text",accessibilityLabel:i.join(", "),testID:`records-timeline-${e.key}`,children:[
445
445
  /* @__PURE__ */j(f,{style:r.railColumn,children:[
@@ -499,12 +499,12 @@ return j(f,{style:l.row,testID:`records-request-row-${e.id}`,children:[t?/* @__P
499
499
  /* @__PURE__ */B(Text,{style:i.cardTitle,children:l.title}),
500
500
  /* @__PURE__ */B(Text,{style:i.cardSubtitle,children:l.subtitle})]}),
501
501
  /* @__PURE__ */B(Chevron,{})]})}function pp(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?fp(e):bo(fp(e),gp(t)),[e,t])}function gp(e){return{row:mo(e,{paddingHorizontal:e.cardPad,paddingVertical:12,gap:8}),card:mo(e,{flexDirection:"row",alignItems:"center",paddingHorizontal:e.cardPad,paddingVertical:12}),cardTitle:{...e.cardTitle,fontSize:16,lineHeight:20,letterSpacing:-.2},source:{color:e.look.ink}}}function fp(e){let{color:t,space:r,radius:n,type:i}=e,l=(e,t)=>Math.round(e*t),o=r.xxl+r.xs/2;return v.create({subtitle:{...face(e,"regular"),fontSize:i.size.caption,lineHeight:l(i.size.caption,i.lineHeight.normal),color:t.text.muted,paddingHorizontal:r.lg,paddingBottom:r.md},list:{paddingHorizontal:r.lg,paddingBottom:r.xl,gap:r.md},row:{borderRadius:n.lg,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm},rowInner:{flexDirection:"row",alignItems:"center",gap:r.md},bubble:{width:o,height:o,borderRadius:o/2},copy:{flex:1,gap:r.xs+1},source:{...face(e,"bold"),fontSize:i.size.body,lineHeight:l(i.size.body,i.lineHeight.snug),color:t.text.primary},meta:{...face(e,"regular"),fontSize:i.size.tiny,lineHeight:l(i.size.tiny,i.lineHeight.normal),color:t.text.muted},footer:{paddingHorizontal:r.lg,paddingTop:r.sm+r.xs/2,paddingBottom:r.lg,gap:r.sm+r.xs/2,borderTopWidth:1,borderTopColor:t.borderHairlineGreen},card:{flexDirection:"row",alignItems:"center",gap:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,paddingHorizontal:r.md+r.xs,paddingVertical:r.md,...Bn(An(e.slots),1)},cardBubble:{width:r.xl+r.xs/2,height:r.xl+r.xs/2,borderRadius:n.pill,borderWidth:2,borderColor:t.brandInk},cardBubbleProcessing:{borderColor:t.warningStrong,backgroundColor:t.badgeBgCaution},cardText:{flex:1,gap:2},cardTitle:{...headingFace(e,"bold"),fontSize:i.size.bodyTight,lineHeight:l(i.size.bodyTight,i.lineHeight.snug),color:t.brandInk,...jn(An(e.slots))},cardSubtitle:{...face(e,"regular"),fontSize:i.size.caption,lineHeight:l(i.size.caption,i.lineHeight.normal),color:t.text.muted,...jn(An(e.slots))}})}var mp=(e,petRef)=>e.getRecordDepth(petRef),bp=e=>!e.available;function EverfurRecordsDashboard(e){let{style:t,renderPending:r,...n}=Zr(e,["onNavigate","onBack","onAsk"]),{alwaysShowWays:i,...l}=n,{userRef:userRef}=Ir();/* @__PURE__ */
502
- return B(go,{value:"legacy",children:/* @__PURE__ */B(CapabilityGate,{capability:"records",style:t,...r?{renderPending:r}:{},...Wo(l.onBack,jo),children:userRef===null?/* @__PURE__ */B(SessionRequiredScreen,{style:t,testID:"dashboard-session-required"}):/* @__PURE__ */B(DashboardBody,{...l,style:t})})})}function DashboardBody({petRef:petRef,petName:e,controller:t,consentVersion:r,consentScope:o,consentText:a,onNavigate:s,onBack:d,onAsk:c,style:u}){let h=Io(),p=vp(),g=useEverfurRecords({petRef:petRef,readUploadFeatures:true,...t?{controller:t}:{},...o?{consentScope:o}:{}}),{runtime:y}=Ir(),v=acceptsPhotos(g.uploadContentTypes)&&Zd(y.registry.services.camera),w=useRecordsMarkers(petRef),k=useRecordsDepthRead(petRef,mp,bp),[x,T]=i(null),C=l((e,t)=>T({marker:e,point:t}),[]);lh(r,a);let _=n(()=>Dc(r,g.consent),[r,g.consent]),R=n(()=>ep(g,r),[g,r]),S=useCapability("recordsClinic"),z=S.enabled||S.isPending,I=w.markers?.markers??[],D=I.length>0,H=g.record!==null&&!g.record.isEmpty&&!g.record.withheld,L=pickPetRecordsRequest(g.requests,petRef),P=g.requests.filter(e=>e.petRef===petRef),O=s?()=>s({name:"requests"}):void 0,$=g.status==="error"?Hc(g,_):null,E=$!==null&&Lc($),F=deriveRecordsDashboardState({hasMarkers:D&&!E,requests:g.requests,petRef:petRef}),q=E?selectDashboardView({recordLoading:false,hasFullRecord:false,recordError:false,markersLoading:false,markersError:false,hasMarkers:false,requestsLoading:false,dashboardState:F,drivingRequest:L}):selectDashboardView({recordLoading:g.status==="loading",hasFullRecord:H,recordError:g.status==="error",markersLoading:w.status==="loading",markersError:w.status==="error",hasMarkers:D,requestsLoading:g.status==="loading",dashboardState:F,drivingRequest:L}),M=$?.kind==="consent_required"?/* @__PURE__ */B(f,{testID:"dashboard-consent",children:Zh(g,R,_,a)}):null,N=w.markers?.disclaimer??g.record?.disclaimer??"",W=()=>{g.refresh(),w.refresh(),k.refresh()},U=k.value!==null&&!k.value.withheld&&k.value.available?k.value:null,G=Qn(e),V=c&&w.markers?.summary?()=>{let t=uc(e,w.markers?.summary??{totalMarkers:0,inRangeCount:0,outOfRangeCount:0,unknownCount:0},petRef);c(t.prompt,t.entityRef)}:void 0,K=c?t=>{let r=cc(e,{canonicalName:t.name,markerId:t.markerId,latestValueText:t.latest?sa(t.latest.value,t.unit,t.latest.qualitativeResult):null,statusText:t.latest?ea(t.latest.status).label:null,trajectoryText:ta(t.trajectory,t.points.length),meaningText:t.meaning});c(r.prompt,r.entityRef)}:void 0,Y=c&&x?()=>{let{marker:t,point:r}=x,n=hc(e,{canonicalName:t.name,valueText:sa(r.value,t.unit,r.qualitativeResult),collectedAt:Ko(r.at),sourceClinic:r.sourceClinic,referenceText:r.refLow!==null||r.refHigh!==null?nc(r,t.unit):null,flagged:r.status==="above"?"above":r.status==="below"?"below":null,reviewed:r.reviewed,entityId:r.docId??t.markerId});T(null),c(n.prompt,n.entityRef)}:void 0,X=/* @__PURE__ */j(A,{children:[w.markers?.summary?/* @__PURE__ */B(f,{style:h.inset,children:/* @__PURE__ */B(MarkerSummaryCard,{summary:w.markers.summary,onAsk:V,testID:"dashboard-marker-summary"})}):null,
502
+ return B(go,{value:"legacy",children:/* @__PURE__ */B(CapabilityGate,{capability:"records",style:t,...r?{renderPending:r}:{},...Wo(l.onBack,jo),children:userRef===null?/* @__PURE__ */B(SessionRequiredScreen,{style:t,testID:"dashboard-session-required"}):/* @__PURE__ */B(DashboardBody,{...l,style:t})})})}function DashboardBody({petRef:petRef,petName:e,controller:t,consentVersion:r,consentScope:o,consentText:a,onNavigate:s,onBack:d,onAsk:c,style:u}){let h=Io(),p=vp(),g=useEverfurRecords({petRef:petRef,readUploadFeatures:true,...t?{controller:t}:{},...o?{consentScope:o}:{}}),{runtime:y}=Ir(),v=acceptsPhotos(g.uploadContentTypes)&&Zd(y.registry.services.camera),w=useRecordsMarkers(petRef),k=useRecordsDepthRead(petRef,mp,bp),[x,T]=i(null),_=l((e,t)=>T({marker:e,point:t}),[]);lh(r,a);let C=n(()=>Dc(r,g.consent),[r,g.consent]),R=n(()=>ep(g,r),[g,r]),S=useCapability("recordsClinic"),z=S.enabled||S.isPending,I=w.markers?.markers??[],D=I.length>0,H=g.record!==null&&!g.record.isEmpty&&!g.record.withheld,L=pickPetRecordsRequest(g.requests,petRef),P=g.requests.filter(e=>e.petRef===petRef),O=s?()=>s({name:"requests"}):void 0,$=g.status==="error"?Hc(g,C):null,E=$!==null&&Lc($),F=deriveRecordsDashboardState({hasMarkers:D&&!E,requests:g.requests,petRef:petRef}),q=E?selectDashboardView({recordLoading:false,hasFullRecord:false,recordError:false,markersLoading:false,markersError:false,hasMarkers:false,requestsLoading:false,dashboardState:F,drivingRequest:L}):selectDashboardView({recordLoading:g.status==="loading",hasFullRecord:H,recordError:g.status==="error",markersLoading:w.status==="loading",markersError:w.status==="error",hasMarkers:D,requestsLoading:g.status==="loading",dashboardState:F,drivingRequest:L}),M=$?.kind==="consent_required"?/* @__PURE__ */B(f,{testID:"dashboard-consent",children:Zh(g,R,C,a)}):null,N=w.markers?.disclaimer??g.record?.disclaimer??"",W=()=>{g.refresh(),w.refresh(),k.refresh()},U=k.value!==null&&!k.value.withheld&&k.value.available?k.value:null,G=Qn(e),V=c&&w.markers?.summary?()=>{let t=uc(e,w.markers?.summary??{totalMarkers:0,inRangeCount:0,outOfRangeCount:0,unknownCount:0},petRef);c(t.prompt,t.entityRef)}:void 0,K=c?t=>{let r=cc(e,{canonicalName:t.name,markerId:t.markerId,latestValueText:t.latest?sa(t.latest.value,t.unit,t.latest.qualitativeResult):null,statusText:t.latest?ea(t.latest.status).label:null,trajectoryText:ta(t.trajectory,t.points.length),meaningText:t.meaning});c(r.prompt,r.entityRef)}:void 0,Y=c&&x?()=>{let{marker:t,point:r}=x,n=hc(e,{canonicalName:t.name,valueText:sa(r.value,t.unit,r.qualitativeResult),collectedAt:Ko(r.at),sourceClinic:r.sourceClinic,referenceText:r.refLow!==null||r.refHigh!==null?nc(r,t.unit):null,flagged:r.status==="above"?"above":r.status==="below"?"below":null,reviewed:r.reviewed,entityId:r.docId??t.markerId});T(null),c(n.prompt,n.entityRef)}:void 0,X=/* @__PURE__ */j(A,{children:[w.markers?.summary?/* @__PURE__ */B(f,{style:h.inset,children:/* @__PURE__ */B(MarkerSummaryCard,{summary:w.markers.summary,onAsk:V,testID:"dashboard-marker-summary"})}):null,
503
503
  /* @__PURE__ */B(Text,{style:h.lead,children:Jn.lead(e)}),
504
- /* @__PURE__ */B(MarkerTrendCarousel,{markers:I,featuredMarkerId:w.markers?.featuredMarkerId??null,onPointPress:C,onAsk:K})]}),Q=e=>s?/* @__PURE__ */j(f,{style:[h.inset,p.actions],children:[e?/* @__PURE__ */B(ActionRow,{glyph:"record",label:Jn.viewFullRecord,onPress:()=>s({name:"record"}),testID:"dashboard-full-record-action"}):null,
504
+ /* @__PURE__ */B(MarkerTrendCarousel,{markers:I,featuredMarkerId:w.markers?.featuredMarkerId??null,onPointPress:_,onAsk:K})]}),Q=e=>s?/* @__PURE__ */j(f,{style:[h.inset,p.actions],children:[e?/* @__PURE__ */B(ActionRow,{glyph:"record",label:Jn.viewFullRecord,onPress:()=>s({name:"record"}),testID:"dashboard-full-record-action"}):null,
505
505
  /* @__PURE__ */B(ActionRow,{glyph:"timeline",label:Jn.viewTimeline,onPress:()=>s({name:"timeline"}),testID:"dashboard-timeline-action"}),
506
506
  /* @__PURE__ */B(ActionRow,{glyph:"requests",label:wc.allRequests,onPress:()=>s({name:"requests"}),testID:"dashboard-requests-action"})]}):null,J=e=>s?/* @__PURE__ */j(f,{style:[h.inset,p.addActions],testID:"dashboard-actions",children:[z?/* @__PURE__ */B(Pill,{label:ii.requestFromClinic,onPress:()=>s({name:"clinicPicker"}),style:p.addCta,testID:"dashboard-actions-clinic"}):null,
507
- /* @__PURE__ */B(Pill,{label:ii.uploadDocument,kind:"outline",onPress:()=>s({name:"upload"}),style:p.addCta,testID:"dashboard-actions-upload"})]}):null,Z;if($!==null&&!E)Z=$.kind==="error"||$.kind==="pet_not_found"?/* @__PURE__ */B(RecordsEmptyState,{variant:ai($.error),message:$.error.displayMessage,onAction:$.error.retryable?W:void 0,testID:"dashboard-error"}):Zh(g,R,_,a);else switch(q){case"loading":Z=/* @__PURE__ */B(DashboardSkeleton,{testID:"dashboard-loading"});break;case"record":Z=/* @__PURE__ */j(b,{contentContainerStyle:h.contentTight,testID:"dashboard-record",children:[D?X:w.status==="error"?/* @__PURE__ */B(f,{style:[h.inset,p.actions],children:/* @__PURE__ */B(ActionRow,{glyph:"retry",label:Jn.retryMarkers,onPress:W,testID:"dashboard-markers-retry"})}):null,
507
+ /* @__PURE__ */B(Pill,{label:ii.uploadDocument,kind:"outline",onPress:()=>s({name:"upload"}),style:p.addCta,testID:"dashboard-actions-upload"})]}):null,Z;if($!==null&&!E)Z=$.kind==="error"||$.kind==="pet_not_found"?/* @__PURE__ */B(RecordsEmptyState,{variant:ai($.error),message:$.error.displayMessage,onAction:$.error.retryable?W:void 0,testID:"dashboard-error"}):Zh(g,R,C,a);else switch(q){case"loading":Z=/* @__PURE__ */B(DashboardSkeleton,{testID:"dashboard-loading"});break;case"record":Z=/* @__PURE__ */j(b,{contentContainerStyle:h.contentTight,testID:"dashboard-record",children:[D?X:w.status==="error"?/* @__PURE__ */B(f,{style:[h.inset,p.actions],children:/* @__PURE__ */B(ActionRow,{glyph:"retry",label:Jn.retryMarkers,onPress:W,testID:"dashboard-markers-retry"})}):null,
508
508
  /* @__PURE__ */B(f,{style:h.inset,children:g.record?/* @__PURE__ */B(RecordSections,{record:g.record,depth:U,petName:e,showLabs:!D,onNavigate:s,onAsk:c}):null}),
509
509
  /* @__PURE__ */B(f,{style:h.inset,children:/* @__PURE__ */B(RecordsRequestsStatusCard,{requests:P,petName:e,activeOnly:true,onOpen:O})}),J(),Q(true)]});break;case"error":Z=/* @__PURE__ */B(RecordsEmptyState,{variant:ai(w.error??g.error),message:(w.error??g.error)?.displayMessage,onAction:(w.error??g.error)?.retryable?W:void 0,testID:"dashboard-error"});break;case"in_progress":Z=/* @__PURE__ */j(b,{contentContainerStyle:h.content,testID:"dashboard-in-progress",children:[L?/* @__PURE__ */B(InProgressCard,{request:L,petName:G,onOpen:s?()=>s({name:"request",requestId:L.id}):void 0,onAsk:c?()=>{let t=pc(e,{clinicName:L.clinicName??null,statusLabel:selectPrimaryLabel(L),status:L.status,heldItemCount:L.heldItemCount},L.id);c(t.prompt,t.entityRef)}:void 0}):null,
510
510
  /* @__PURE__ */B(RecordsRequestsStatusCard,{requests:P,petName:e,onOpen:O}),s?/* @__PURE__ */j(f,{style:p.ways,testID:"dashboard-ways",children:[z?/* @__PURE__ */B(WayCard,{title:ni.anotherClinic,sub:ni.anotherClinicSub,onPress:()=>s({name:"clinicPicker"}),testID:"dashboard-way-clinic"}):null,
@@ -540,7 +540,7 @@ return j(m,{onPress:i,accessibilityRole:"button",accessibilityLabel:r??(t?`${e}.
540
540
  /* @__PURE__ */j(f,{style:o.wayText,children:[
541
541
  /* @__PURE__ */B(Text,{style:o.wayTitle,children:e}),t?/* @__PURE__ */B(Text,{style:o.waySub,children:t}):null]}),
542
542
  /* @__PURE__ */B(Chevron,{})]})}function vp(){let e=useEverfurTheme();return n(()=>wp(e),[e])}function wp(e){let{color:t,space:r,radius:n,type:i}=e,l=v.hairlineWidth,o=r.xxl+r.md,a=e.slots.card,s=jn(a);return v.create({headerButton:{width:o,height:o,alignItems:"center",justifyContent:"center"},actions:{gap:r.sm+r.xs/2},actionRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderRadius:n.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.lg,...Bn(a,1)},actionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:r.md},actionIcon:{width:yp,height:yp,alignItems:"center",justifyContent:"center"},actionLabel:{flex:1,...face(e,"medium"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.snug),color:t.text.primary,...s},inProgressCard:{borderRadius:n.lg,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,padding:r.lg,gap:r.lg,...Bn(a,1)},inProgressHeadText:{flex:1,gap:r.xs/2},ways:{gap:r.sm},way:{flexDirection:"row",alignItems:"center",gap:r.md,borderRadius:n.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,padding:r.lg,...Bn(a,1)},wayDashed:{borderStyle:"dashed",borderColor:t.brandBorderStrong},wayText:{flex:1,gap:r.xs/2},wayTitle:{...headingFace(e,"bold"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.snug),color:t.text.primary,...s},waySub:{...face(e,"regular"),fontSize:i.size.caption,lineHeight:Math.round(i.size.caption*i.lineHeight.normal),color:t.text.muted,...s},inProgressInner:{gap:r.lg},inProgressHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},inProgressTitle:{...headingFace(e,"bold"),fontSize:i.size.subtitle,lineHeight:Math.round(i.size.subtitle*i.lineHeight.snug),letterSpacing:-.4,color:t.brandInk,...s},promptCard:{borderRadius:n.sm,backgroundColor:t.surfaceCream,borderWidth:l,borderColor:t.borderRingCream,paddingHorizontal:r.lg+r.xs,paddingVertical:r.lg+r.xs/2,...Bn(a,l)},promptHeader:{flexDirection:"row",alignItems:"center",gap:r.xs+1},promptGlyph:{width:r.xl+1,height:r.xl+1,borderRadius:n.xs,borderWidth:2,borderColor:t.warningStrong},promptTitle:{flex:1,...headingFace(e,"bold"),fontSize:i.size.subtitle,lineHeight:Math.round(i.size.subtitle*i.lineHeight.snug),letterSpacing:i.letterSpacing.headerBrand,color:t.brandInk,...s},promptBody:{marginTop:r.sm-1,...face(e,"regular"),fontSize:i.size.bodyTight,lineHeight:r.lg+r.xs,color:t.text.primary,...s},promptCta:{marginTop:r.sm-1,minHeight:r.xxl+r.sm},promptCtaSecondary:{marginTop:r.sm,minHeight:r.xxl+r.sm},addActions:{gap:r.sm},addCta:{minHeight:r.xxl+r.sm}})}var kp=/* @__PURE__ */Object.freeze({visit:0,vaccine:1,weight:2,medication:3});function xp(e){if(!e)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function buildTimelineRows(e){let t=[...e.visits.map((e,t)=>({key:`visit-${t}-${e.visitId}`,kind:"visit",kindLabel:Zo.kind.visit,at:e.visitDate,date:Ko(e.visitDate),title:e.summary??Zo.clinicVisit,detail:e.veterinarian?Zo.doctor(e.veterinarian):null,docId:e.docId})),...e.vaccines.map((e,t)=>{let r=[];return e.lot&&r.push(Zo.lot(e.lot)),e.expiresOn&&r.push(Zo.expires(Ko(e.expiresOn))),{key:`vaccine-${t}-${e.vaccineId}`,kind:"vaccine",kindLabel:Zo.kind.vaccine,at:e.administeredOn,date:Ko(e.administeredOn),title:e.product||Zo.kind.vaccine,detail:r.length?r.join(" · "):null,docId:e.docId}}),...e.weights.map((e,t)=>({key:`weight-${t}-${e.weightId}`,kind:"weight",kindLabel:Zo.kind.weight,at:e.observedOn,date:Ko(e.observedOn),title:aa(e.weightKg),detail:null,docId:e.docId})),...e.medications.map((e,t)=>{let r=[e.dose,e.route,e.frequency].filter(e=>!!e);return{key:`medication-${t}-${e.medicationId}`,kind:"medication",kindLabel:Zo.kind.medication,at:e.startedOn,date:Ko(e.startedOn),title:e.drugName||Zo.kind.medication,detail:r.length?r.join(" · "):null,docId:e.docId}})];/* @__PURE__ */
543
- return Object.freeze(t.sort((e,t)=>{let r=xp(e.at),n=xp(t.at);return r===null&&n===null?kp[e.kind]-kp[t.kind]:r===null?1:n===null?-1:n!==r?n-r:kp[e.kind]-kp[t.kind]}))}var Tp=300,Cp=(e,petRef)=>e.getTimeline(petRef),_p=e=>e.isEmpty;var Rp=e=>e.contributions.length===0;function EverfurRecordsTimeline({petRef:petRef,style:e,onBack:t}){let r=useRecordsDepthRead(petRef,Cp,_p);/* @__PURE__ */
543
+ return Object.freeze(t.sort((e,t)=>{let r=xp(e.at),n=xp(t.at);return r===null&&n===null?kp[e.kind]-kp[t.kind]:r===null?1:n===null?-1:n!==r?n-r:kp[e.kind]-kp[t.kind]}))}var Tp=300,_p=(e,petRef)=>e.getTimeline(petRef),Cp=e=>e.isEmpty;var Rp=e=>e.contributions.length===0;function EverfurRecordsTimeline({petRef:petRef,style:e,onBack:t}){let r=useRecordsDepthRead(petRef,_p,Cp);/* @__PURE__ */
544
544
  return B(DepthSurface,{state:r,style:e,onBack:t,header:/* @__PURE__ */B(ScreenHeader,{title:Zo.timeline,onBack:Jr(t),testID:"timeline-header"}),loading:/* @__PURE__ */B(TimelineSkeleton,{testID:"timeline-loading"}),empty:/* @__PURE__ */B(RecordsEmptyState,{variant:"no_records",testID:"timeline-empty"}),render:e=>/* @__PURE__ */B(TimelineBody,{timeline:e})})}function EverfurDocumentContributions({petRef:petRef,docId:e,style:t,onBack:r}){let n=l((t,r)=>t.getDocumentContributions(r,e),[e]),i=useRecordsDepthRead(petRef,n,Rp,e),o=i.value?.document??null,a=o!==null?ua(o):Zo.uploadedDocument;/* @__PURE__ */
545
545
  return B(DepthSurface,{state:i,style:t,onBack:r,header:/* @__PURE__ */B(ScreenHeader,{title:a,onBack:Jr(r),testID:"contributions-header"}),empty:/* @__PURE__ */B(RecordsEmptyState,{variant:"no_records",testID:"contributions-empty"}),render:e=>/* @__PURE__ */B(ContributionsBody,{view:e})})}function DepthSurface({state:e,style:t,header:r,loading:n,empty:i,render:l,onBack:o}){let a=zp();/* @__PURE__ */
546
546
  return B(CapabilityGate,{capability:"records",style:t,...Wo(Jr(o),jo),children:/* @__PURE__ */j(f,{style:[a.container,t],children:[r??null,
@@ -557,9 +557,9 @@ return j(b,{style:t.list,contentContainerStyle:t.timelineContent,accessibilityLa
557
557
  return j(b,{style:t.list,contentContainerStyle:t.listContent,accessibilityLabel:Kn.records,children:[e.document?.receivedAt?/* @__PURE__ */B(Text,{style:t.rowDetail,children:Xo(e.document.receivedAt)}):null,
558
558
  /* @__PURE__ */B(f,{style:t.card,children:e.contributions.map(e=>/* @__PURE__ */j(f,{style:t.row,accessible:true,accessibilityRole:"text",children:[
559
559
  /* @__PURE__ */B(Text,{style:t.rowTitle,children:e.label}),
560
- /* @__PURE__ */B(Text,{style:t.rowValue,children:Uo(e.value,e.unit)}),e.observedAt?/* @__PURE__ */B(Text,{style:t.rowDetail,children:Ko(e.observedAt)}):null]},e.key))})]})}function zp(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?Dp(e):bo(Dp(e),Ip(t)),[e,t])}function Ip(e){return{container:{backgroundColor:e.ground},card:mo(e,{padding:e.cardPad,gap:8}),heading:e.cardTitle,primaryButton:{...e.button,...e.buttonInk},primaryLabel:e.buttonInkLabel}}function Dp(e){let{color:t,space:r,radius:n,type:i,slots:l}=e,{size:o,lineHeight:a}=i,s=(e,t)=>Math.round(e*t),d=v.hairlineWidth,c=r.xxl*3+r.xl,u=r.xxl+r.md,h=e.brightness==="dark"?t.errorRed:t.danger,p=jn(An(l)),g=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:s(t,r),color:n}),f=(e,t,r,n="regular")=>({...g(e,t,r,n),...p});return v.create({container:{flex:1,minHeight:c,backgroundColor:t.background},body:{flex:1},centered:{minHeight:c,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl,gap:r.lg},emptyGlyph:{width:r.xxl+r.sm,height:r.xxl+r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:d,borderColor:t.brandBorder},errorText:{...g(o.subtitle,a.snug,h),textAlign:"center",marginBottom:r.md},primaryButton:{minHeight:u,minWidth:u,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.md,borderRadius:n.pill,backgroundColor:t.primary,...Bn(l.primaryButton)},primaryLabel:{...face(e,"bold"),color:t.onPrimary,fontSize:o.body,...jn(l.primaryButton)},list:{flex:1},listContent:{padding:r.lg,gap:r.md},section:{gap:r.sm},heading:{...g(o.heading,a.snug,t.text.primary,"bold"),...headingFace(e,"bold")},card:{gap:r.sm,padding:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,borderWidth:d,borderColor:t.brandBorder,...Bn(An(l),d)},row:{gap:r.xs,paddingVertical:r.xs,borderBottomWidth:d,borderBottomColor:t.borderHairlineGreen},topLine:{flexDirection:"row",justifyContent:"space-between",gap:r.md},kindLabel:{...f(o.caption,a.normal,t.text.muted,"medium")},date:f(o.caption,a.normal,t.text.muted),rowTitle:{...f(o.body,a.normal,t.text.primary,"bold"),...headingFace(e,"bold")},rowValue:{...f(o.body,a.normal,t.text.primary,"medium")},rowDetail:f(o.bodyTight,a.normal,t.text.muted),rowMuted:{...f(o.bodyTight,a.normal,t.text.muted),opacity:.7},chip:{...g(o.caption,a.normal,t.text.primary),alignSelf:"flex-start",paddingHorizontal:r.sm,paddingVertical:r.xs,borderRadius:n.pill},chipNeutral:{backgroundColor:t.badgeBgNeutral},chipCaution:{backgroundColor:t.badgeBgCaution},chipCritical:{backgroundColor:t.badgeBgCritical},disclaimer:{...g(o.caption,a.normal,t.text.muted),marginTop:r.md},timelineContent:{paddingBottom:r.xxl},timelineBand:{flexDirection:"row",gap:r.sm,borderRadius:n.md-r.xs/2,padding:r.md,backgroundColor:t.brandSoft,marginHorizontal:r.lg,marginTop:r.xs,marginBottom:r.md},timelineBandText:{flex:1,...g(o.caption,a.normal,t.text.secondary)},timelineSeparator:{height:d,backgroundColor:t.brandBorder,marginLeft:ja},timelineRow:{flexDirection:"row",gap:r.md,paddingHorizontal:r.lg,paddingVertical:r.md+r.xs/2},timelineBubble:{width:r.xxl+r.xs/2,height:r.xxl+r.xs/2,borderRadius:n.pill,backgroundColor:t.brandSoft,borderWidth:d,borderColor:t.brandBorder},timelineBody:{flex:1,gap:r.xs-1},timelineKind:{...face(e,"mono"),fontSize:o.micro,lineHeight:o.bodyTight,letterSpacing:i.letterSpacing.eyebrow/3,textTransform:"uppercase",color:t.text.secondary},timelineTitle:{...g(o.body,a.normal,t.text.primary,"medium")}})}function useRecordShares(petRef,e={}){let t=useEverfurRecordsDepthClient(),{userRef:userRef}=Ir(),a=e.now??Date.now,[s,d]=i(null),[c,u]=i(true),[h,p]=i(null),[g,f]=i(null),m=g===true,[b,y]=i({}),[v,w]=i(false),[k,x]=i(null),[T,C]=i(false),[_,R]=i(false),[S,z]=i(false),[I,D]=i(null),H=I!==null&&I.client===t?I.value:Ie,L=H.shareAudiences,P=$r(petRef),O=r(0),$=r(true),B=l(async()=>{let e=O.current+=1;if(u(true),p(null),userRef===null){d(null),u(false);return}let r=await t.listShares(petRef);e!==O.current||!$.current||(r.ok?(d(r.value),f(true)):qd(r.error)?(d(null),f(false)):(d(null),p(r.error),Hp(r)&&f(true)),u(false))},[t,petRef,userRef]);o(()=>($.current=true,B(),()=>{$.current=false,O.current+=1}),[B]),o(()=>{if(userRef===null||t.readFeatures===void 0)return;let e=true;return t.readFeatures().then(r=>{e&&D({client:t,value:r})},()=>{}),()=>{e=false}},[t,userRef]);let j=r(P);o(()=>{j.current!==P&&(j.current=P,y({}),R(true),B())},[P,B]);let A=l(async e=>{w(true);let r=await(e!==void 0&&L.some(t=>t.audience===e)?t.createShare(petRef,{audience:e}):t.createShare(petRef));return $.current&&(w(false),r.ok?(y(e=>({...e,[r.value.shareId]:r.value.shareUrl})),B()):qd(r.error)?f(false):ht(r.error)&&R(true)),r},[t,petRef,B,L]),E=l(async e=>{z(true);let r=await t.emailShare(petRef,e);return $.current&&(z(false),r.ok?B():qd(r.error)?f(false):ht(r.error)?R(true):r.error.httpStatus===502&&B()),r},[t,petRef,B]),F=l(async e=>{x(e);let r=await t.revokeShare(petRef,e);return $.current&&(x(null),B()),r},[t,petRef,B]),q=l(async()=>{C(true);let e=await t.getPdfLink(petRef);return $.current&&(C(false),!e.ok&&ht(e.error)&&R(true)),e},[t,petRef]),M=l(()=>{R(false),B()},[B]),N=n(()=>Ra(s??[],b,a()),[s,b,a]),W=c?"loading":h!==null?"error":N.length===0?"empty":"populated",U=H.features;return n(()=>({status:W,rows:N,available:m,consentRequired:_,error:h,creating:v,revokingId:k,preparingPdf:T,shareAudiences:L,features:U,sending:S,createLink:A,sendEmail:E,revoke:F,pdfLink:q,refresh:M}),[W,N,m,_,h,v,k,T,L,U,S,A,E,F,q,M])}function Hp(e){return e.ok||e.error.httpStatus!==void 0&&e.error.httpStatus!==404}function Lp(e){return e.available||e.status!=="empty"}function Pp(petRef){let e=useEverfurRecordsDepthClient(),{userRef:userRef}=Ir(),t=n(()=>({}),[e,petRef,userRef]),[r,l]=i({scope:t,lit:null});o(()=>{if(userRef===null)return;let r=true;return e.listShares(petRef).then(e=>{r&&(!e.ok&&qd(e.error)?l({scope:t,lit:false}):Hp(e)&&l({scope:t,lit:true}))},()=>{}),()=>{r=false}},[e,petRef,userRef,t]);let a=r.scope===t?r.lit:null;return n(()=>({lit:a}),[a])}function useRecordPdfLink(petRef){let e=useEverfurRecordsDepthClient(),t=Pp(petRef).lit===true,[a,s]=i(false),[d,c]=i(null),u=r(true);o(()=>(u.current=true,()=>{u.current=false}),[]);let h=l(async()=>{s(true),c(null);let t=await e.getPdfLink(petRef);return u.current&&(s(false),t.ok||c(t.error)),t},[e,petRef]);return n(()=>({preparing:a,available:t,error:d,pdfLink:h}),[a,t,d,h])}var Op=ha.document,$p=/* @__PURE__ */Object.freeze(["medication","vaccination","problem","allergy","procedure","body_weight","vital"]),Bp=(e,petRef)=>e.getRecordDepth(petRef),jp=e=>!e.available;function EverfurRecordDocument(e){let{style:t,renderPending:r,...n}=Zr(e,["onBack"]),{userRef:userRef}=Ir();/* @__PURE__ */
561
- return B(CapabilityGate,{capability:"records",style:t,...r?{renderPending:r}:{},...Wo(n.onBack,jo),children:userRef===null?/* @__PURE__ */B(SessionRequiredScreen,{style:t,testID:"records-document-session-required"}):/* @__PURE__ */B(DocumentBody,{...n,style:t})})}function Ap(e,t){return e.identity.length===0&&e.entities.length===0&&e.forwardLooking.length===0&&(t===null||t.labResults.length===0&&t.physicalExams.length===0&&t.clinicianNotes.length===0)}function DocumentBody({petRef:petRef,petName:e,controller:t,consentVersion:r,consentScope:l,consentText:o,onBack:a,onOpenUrl:s,style:d}){let c=Io(),u=Ep(),h=useEverfurTheme(),p=useEverfurRecords({petRef:petRef,...t?{controller:t}:{},...l?{consentScope:l}:{}}),g=useRecordsDepthRead(petRef,Bp,jp),b=useRecordPdfLink(petRef);lh(r,o);let v=n(()=>Dc(r,p.consent),[r,p.consent]),w=n(()=>ep(p,r),[p,r]),k=g.value!==null&&!g.value.withheld&&g.value.available?g.value:null,x=p.record,[T,C]=i(false),_=()=>{C(false),b.pdfLink().then(e=>{if(!e.ok)return;en(s??(e=>cp(e)),e.value.downloadUrl,"record_pdf").then(e=>{!e.ok&&!s&&C(true)})})},R,S=false;if(p.status==="loading"||g.status==="loading"&&x!==null)R=/* @__PURE__ */B(DocumentSkeleton,{testID:"record-document-loading"});else if(p.status==="error"){let e=Hc(p,v);R=e.kind==="error"||e.kind==="pet_not_found"?/* @__PURE__ */B(RecordsEmptyState,{variant:ai(e.error),message:e.error.displayMessage,onAction:e.error.retryable?()=>{p.refresh(),g.refresh()}:void 0,testID:"record-document-error"}):Zh(p,w,v,o)}else x===null||Ap(x,k)?R=/* @__PURE__ */B(f,{style:u.centered,testID:"record-document-empty",children:/* @__PURE__ */B(Text,{style:u.emptyText,children:Op.empty})}):(S=true,R=/* @__PURE__ */B(RecordDocument,{record:x,depth:k,petName:e,wordmark:h.meta.displayName})/* @__PURE__ */);return j(f,{style:[c.root,u.root,d],children:[
562
- /* @__PURE__ */B(ScreenHeader,{title:Op.titleFor(e),variant:"document",onBack:a,testID:"record-document-header",right:b.available&&S?/* @__PURE__ */B(m,{onPress:_,disabled:b.preparing,accessibilityRole:"button",accessibilityLabel:Op.download,accessibilityState:{disabled:b.preparing,busy:b.preparing},hitSlop:8,style:u.download,testID:"record-document-download",children:b.preparing?/* @__PURE__ */B(y,{size:"small",color:h.slots.header?.textColor??h.color.brandInk}):/* @__PURE__ */B(DownloadGlyph,{})}):void 0}),b.error?/* @__PURE__ */B(Text,{style:[c.errorText,u.inset],accessibilityRole:"alert",children:b.error.displayMessage}):T?/* @__PURE__ */B(Text,{style:[c.errorText,u.inset],accessibilityRole:"alert",testID:"record-document-share-failed",children:wa.toasts.pdfShareSheet}):null,
560
+ /* @__PURE__ */B(Text,{style:t.rowValue,children:Uo(e.value,e.unit)}),e.observedAt?/* @__PURE__ */B(Text,{style:t.rowDetail,children:Ko(e.observedAt)}):null]},e.key))})]})}function zp(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?Dp(e):bo(Dp(e),Ip(t)),[e,t])}function Ip(e){return{container:{backgroundColor:e.ground},card:mo(e,{padding:e.cardPad,gap:8}),heading:e.cardTitle,primaryButton:{...e.button,...e.buttonInk},primaryLabel:e.buttonInkLabel}}function Dp(e){let{color:t,space:r,radius:n,type:i,slots:l}=e,{size:o,lineHeight:a}=i,s=(e,t)=>Math.round(e*t),d=v.hairlineWidth,c=r.xxl*3+r.xl,u=r.xxl+r.md,h=e.brightness==="dark"?t.errorRed:t.danger,p=jn(An(l)),g=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:s(t,r),color:n}),f=(e,t,r,n="regular")=>({...g(e,t,r,n),...p});return v.create({container:{flex:1,minHeight:c,backgroundColor:t.background},body:{flex:1},centered:{minHeight:c,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl,gap:r.lg},emptyGlyph:{width:r.xxl+r.sm,height:r.xxl+r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:d,borderColor:t.brandBorder},errorText:{...g(o.subtitle,a.snug,h),textAlign:"center",marginBottom:r.md},primaryButton:{minHeight:u,minWidth:u,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.md,borderRadius:n.pill,backgroundColor:t.primary,...Bn(l.primaryButton)},primaryLabel:{...face(e,"bold"),color:t.onPrimary,fontSize:o.body,...jn(l.primaryButton)},list:{flex:1},listContent:{padding:r.lg,gap:r.md},section:{gap:r.sm},heading:{...g(o.heading,a.snug,t.text.primary,"bold"),...headingFace(e,"bold")},card:{gap:r.sm,padding:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,borderWidth:d,borderColor:t.brandBorder,...Bn(An(l),d)},row:{gap:r.xs,paddingVertical:r.xs,borderBottomWidth:d,borderBottomColor:t.borderHairlineGreen},topLine:{flexDirection:"row",justifyContent:"space-between",gap:r.md},kindLabel:{...f(o.caption,a.normal,t.text.muted,"medium")},date:f(o.caption,a.normal,t.text.muted),rowTitle:{...f(o.body,a.normal,t.text.primary,"bold"),...headingFace(e,"bold")},rowValue:{...f(o.body,a.normal,t.text.primary,"medium")},rowDetail:f(o.bodyTight,a.normal,t.text.muted),rowMuted:{...f(o.bodyTight,a.normal,t.text.muted),opacity:.7},chip:{...g(o.caption,a.normal,t.text.primary),alignSelf:"flex-start",paddingHorizontal:r.sm,paddingVertical:r.xs,borderRadius:n.pill},chipNeutral:{backgroundColor:t.badgeBgNeutral},chipCaution:{backgroundColor:t.badgeBgCaution},chipCritical:{backgroundColor:t.badgeBgCritical},disclaimer:{...g(o.caption,a.normal,t.text.muted),marginTop:r.md},timelineContent:{paddingBottom:r.xxl},timelineBand:{flexDirection:"row",gap:r.sm,borderRadius:n.md-r.xs/2,padding:r.md,backgroundColor:t.brandSoft,marginHorizontal:r.lg,marginTop:r.xs,marginBottom:r.md},timelineBandText:{flex:1,...g(o.caption,a.normal,t.text.secondary)},timelineSeparator:{height:d,backgroundColor:t.brandBorder,marginLeft:ja},timelineRow:{flexDirection:"row",gap:r.md,paddingHorizontal:r.lg,paddingVertical:r.md+r.xs/2},timelineBubble:{width:r.xxl+r.xs/2,height:r.xxl+r.xs/2,borderRadius:n.pill,backgroundColor:t.brandSoft,borderWidth:d,borderColor:t.brandBorder},timelineBody:{flex:1,gap:r.xs-1},timelineKind:{...face(e,"mono"),fontSize:o.micro,lineHeight:o.bodyTight,letterSpacing:i.letterSpacing.eyebrow/3,textTransform:"uppercase",color:t.text.secondary},timelineTitle:{...g(o.body,a.normal,t.text.primary,"medium")}})}function useRecordShares(petRef,e={}){let t=useEverfurRecordsDepthClient(),{userRef:userRef}=Ir(),a=e.now??Date.now,[s,d]=i(null),[c,u]=i(true),[h,p]=i(null),[g,f]=i(null),m=g===true,[b,y]=i({}),[v,w]=i(false),[k,x]=i(null),[T,_]=i(false),[C,R]=i(false),[S,z]=i(false),[I,D]=i(null),H=I!==null&&I.client===t?I.value:Ie,L=H.shareAudiences,P=$r(petRef),O=r(0),$=r(true),B=l(async()=>{let e=O.current+=1;if(u(true),p(null),userRef===null){d(null),u(false);return}let r=await t.listShares(petRef);e!==O.current||!$.current||(r.ok?(d(r.value),f(true)):qd(r.error)?(d(null),f(false)):(d(null),p(r.error),Hp(r)&&f(true)),u(false))},[t,petRef,userRef]);o(()=>($.current=true,B(),()=>{$.current=false,O.current+=1}),[B]),o(()=>{if(userRef===null||t.readFeatures===void 0)return;let e=true;return t.readFeatures().then(r=>{e&&D({client:t,value:r})},()=>{}),()=>{e=false}},[t,userRef]);let j=r(P);o(()=>{j.current!==P&&(j.current=P,y({}),R(true),B())},[P,B]);let A=l(async e=>{w(true);let r=await(e!==void 0&&L.some(t=>t.audience===e)?t.createShare(petRef,{audience:e}):t.createShare(petRef));return $.current&&(w(false),r.ok?(y(e=>({...e,[r.value.shareId]:r.value.shareUrl})),B()):qd(r.error)?f(false):ht(r.error)&&R(true)),r},[t,petRef,B,L]),E=l(async e=>{z(true);let r=await t.emailShare(petRef,e);return $.current&&(z(false),r.ok?B():qd(r.error)?f(false):ht(r.error)?R(true):r.error.httpStatus===502&&B()),r},[t,petRef,B]),F=l(async e=>{x(e);let r=await t.revokeShare(petRef,e);return $.current&&(x(null),B()),r},[t,petRef,B]),q=l(async()=>{_(true);let e=await t.getPdfLink(petRef);return $.current&&(_(false),!e.ok&&ht(e.error)&&R(true)),e},[t,petRef]),M=l(()=>{R(false),B()},[B]),N=n(()=>Ra(s??[],b,a()),[s,b,a]),W=c?"loading":h!==null?"error":N.length===0?"empty":"populated",U=H.features;return n(()=>({status:W,rows:N,available:m,consentRequired:C,error:h,creating:v,revokingId:k,preparingPdf:T,shareAudiences:L,features:U,sending:S,createLink:A,sendEmail:E,revoke:F,pdfLink:q,refresh:M}),[W,N,m,C,h,v,k,T,L,U,S,A,E,F,q,M])}function Hp(e){return e.ok||e.error.httpStatus!==void 0&&e.error.httpStatus!==404}function Lp(e){return e.available||e.status!=="empty"}function Pp(petRef){let e=useEverfurRecordsDepthClient(),{userRef:userRef}=Ir(),t=n(()=>({}),[e,petRef,userRef]),[r,l]=i({scope:t,lit:null});o(()=>{if(userRef===null)return;let r=true;return e.listShares(petRef).then(e=>{r&&(!e.ok&&qd(e.error)?l({scope:t,lit:false}):Hp(e)&&l({scope:t,lit:true}))},()=>{}),()=>{r=false}},[e,petRef,userRef,t]);let a=r.scope===t?r.lit:null;return n(()=>({lit:a}),[a])}function useRecordPdfLink(petRef){let e=useEverfurRecordsDepthClient(),t=Pp(petRef).lit===true,[a,s]=i(false),[d,c]=i(null),u=r(true);o(()=>(u.current=true,()=>{u.current=false}),[]);let h=l(async()=>{s(true),c(null);let t=await e.getPdfLink(petRef);return u.current&&(s(false),t.ok||c(t.error)),t},[e,petRef]);return n(()=>({preparing:a,available:t,error:d,pdfLink:h}),[a,t,d,h])}var Op=ha.document,$p=/* @__PURE__ */Object.freeze(["medication","vaccination","problem","allergy","procedure","body_weight","vital"]),Bp=(e,petRef)=>e.getRecordDepth(petRef),jp=e=>!e.available;function EverfurRecordDocument(e){let{style:t,renderPending:r,...n}=Zr(e,["onBack"]),{userRef:userRef}=Ir();/* @__PURE__ */
561
+ return B(CapabilityGate,{capability:"records",style:t,...r?{renderPending:r}:{},...Wo(n.onBack,jo),children:userRef===null?/* @__PURE__ */B(SessionRequiredScreen,{style:t,testID:"records-document-session-required"}):/* @__PURE__ */B(DocumentBody,{...n,style:t})})}function Ap(e,t){return e.identity.length===0&&e.entities.length===0&&e.forwardLooking.length===0&&(t===null||t.labResults.length===0&&t.physicalExams.length===0&&t.clinicianNotes.length===0)}function DocumentBody({petRef:petRef,petName:e,controller:t,consentVersion:r,consentScope:l,consentText:o,onBack:a,onOpenUrl:s,style:d}){let c=Io(),u=Ep(),h=useEverfurTheme(),p=useEverfurRecords({petRef:petRef,...t?{controller:t}:{},...l?{consentScope:l}:{}}),g=useRecordsDepthRead(petRef,Bp,jp),b=useRecordPdfLink(petRef);lh(r,o);let v=n(()=>Dc(r,p.consent),[r,p.consent]),w=n(()=>ep(p,r),[p,r]),k=g.value!==null&&!g.value.withheld&&g.value.available?g.value:null,x=p.record,[T,_]=i(false),C=()=>{_(false),b.pdfLink().then(e=>{if(!e.ok)return;en(s??(e=>cp(e)),e.value.downloadUrl,"record_pdf").then(e=>{!e.ok&&!s&&_(true)})})},R,S=false;if(p.status==="loading"||g.status==="loading"&&x!==null)R=/* @__PURE__ */B(DocumentSkeleton,{testID:"record-document-loading"});else if(p.status==="error"){let e=Hc(p,v);R=e.kind==="error"||e.kind==="pet_not_found"?/* @__PURE__ */B(RecordsEmptyState,{variant:ai(e.error),message:e.error.displayMessage,onAction:e.error.retryable?()=>{p.refresh(),g.refresh()}:void 0,testID:"record-document-error"}):Zh(p,w,v,o)}else x===null||Ap(x,k)?R=/* @__PURE__ */B(f,{style:u.centered,testID:"record-document-empty",children:/* @__PURE__ */B(Text,{style:u.emptyText,children:Op.empty})}):(S=true,R=/* @__PURE__ */B(RecordDocument,{record:x,depth:k,petName:e,wordmark:h.meta.displayName})/* @__PURE__ */);return j(f,{style:[c.root,u.root,d],children:[
562
+ /* @__PURE__ */B(ScreenHeader,{title:Op.titleFor(e),variant:"document",onBack:a,testID:"record-document-header",right:b.available&&S?/* @__PURE__ */B(m,{onPress:C,disabled:b.preparing,accessibilityRole:"button",accessibilityLabel:Op.download,accessibilityState:{disabled:b.preparing,busy:b.preparing},hitSlop:8,style:u.download,testID:"record-document-download",children:b.preparing?/* @__PURE__ */B(y,{size:"small",color:h.slots.header?.textColor??h.color.brandInk}):/* @__PURE__ */B(DownloadGlyph,{})}):void 0}),b.error?/* @__PURE__ */B(Text,{style:[c.errorText,u.inset],accessibilityRole:"alert",children:b.error.displayMessage}):T?/* @__PURE__ */B(Text,{style:[c.errorText,u.inset],accessibilityRole:"alert",testID:"record-document-share-failed",children:wa.toasts.pdfShareSheet}):null,
563
563
  /* @__PURE__ */B(f,{style:c.body,children:R}),
564
564
  /* @__PURE__ */B(RecordsFootnote,{})]})}function RecordDocument({record:e,depth:t,petName:r,wordmark:i}){let l=Ep(),o=n(()=>{let t=[],r=/* @__PURE__ */new Map;for(let n of e.entities){let e=n.category.trim();if(e.length===0)continue;let i=r.get(e);i===void 0?(t.push(e),r.set(e,[n])):i.push(n)}let n=$p.filter(e=>t.includes(e)),i=t.filter(e=>!$p.includes(e));return[...n,...i].map(e=>({type:e,rows:r.get(e)??[]}))},[e.entities]),a=Date.now(),s=(e,t,r)=>/* @__PURE__ */j(f,{style:l.section,testID:r,children:[
565
565
  /* @__PURE__ */j(f,{style:l.sectionHeader,children:[
@@ -588,7 +588,7 @@ return j(f,{style:[l.row,t>0?l.rowDivider:null],children:[
588
588
  /* @__PURE__ */B(Text,{style:l.fieldLabel,children:ia(e.system)}),
589
589
  /* @__PURE__ */B(Text,{style:l.fieldValue,children:e.finding})]},e.system))]},e.examId)),"record-document-exams"):null,t&&t.clinicianNotes.length>0?s(Op.clinicianNotes,t.clinicianNotes.map((e,t)=>/* @__PURE__ */j(f,{style:[l.block,t>0?l.rowDivider:null],children:[e.observedOn?/* @__PURE__ */B(Text,{style:l.blockDate,children:Ko(e.observedOn)}):null,e.sections.filter(e=>e.text).map((e,t)=>/* @__PURE__ */j(f,{style:l.noteSection,children:[
590
590
  /* @__PURE__ */B(Text,{style:l.noteLabel,children:oa(e.section)}),
591
- /* @__PURE__ */B(Text,{style:l.noteBody,children:e.text})]},`${e.section}-${t}`))]},e.noteId)),"record-document-notes"):null,To(e.disclaimer)?null:/* @__PURE__ */B(f,{style:l.disclaimer,children:/* @__PURE__ */B(Text,{style:l.disclaimerText,children:e.disclaimer})})]})}function Ep(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?qp(e):bo(qp(e),Fp(t)),[e,t])}function Fp(e){return{root:{backgroundColor:e.ground}}}function qp(e){let{color:t,space:r,radius:n,type:i}=e,l=v.hairlineWidth,o=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n}),a=(t,n)=>({...face(e,"mono"),fontSize:t,lineHeight:t+r.xs-1,color:n,letterSpacing:i.letterSpacing.eyebrow/2,textTransform:"uppercase"});return v.create({root:{backgroundColor:t.surface},inset:{paddingHorizontal:r.lg},download:{width:r.xxl+r.xs+r.xs/2,height:r.xxl+r.xs+r.xs/2,borderRadius:n.pill,alignItems:"center",justifyContent:"center"},centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xxl,minHeight:r.xxl*3+r.xl},emptyText:{...o(i.size.body,i.lineHeight.normal,t.text.muted,"medium"),textAlign:"center"},page:{paddingHorizontal:r.lg+r.xs,paddingBottom:r.xxl+r.lg},letterhead:{alignItems:"center",paddingTop:r.md,paddingBottom:r.lg+r.xs+r.xs/2,borderBottomWidth:2,borderBottomColor:t.brandInk,gap:r.xs+r.xs/2,marginBottom:r.sm},wordmark:{...o(i.size.heading,i.lineHeight.snug,t.brandInk,"bold"),letterSpacing:i.letterSpacing.headerBrand},docTitle:{...a(i.size.caption,t.brandInk),marginTop:r.sm+r.xs/2,letterSpacing:i.letterSpacing.eyebrow+.4},petName:o(i.size.verdict+r.xs/2,i.lineHeight.tight,t.text.primary),generated:{...a(i.size.tiny,t.text.muted),textTransform:"none"},section:{marginTop:r.lg+r.xs+r.xs/2},sectionHeader:{flexDirection:"row",alignItems:"center",gap:r.sm+r.xs/2,marginBottom:r.sm},sectionTitle:a(i.size.tiny,t.brandInk),rule:{flex:1,height:l,backgroundColor:t.borderHairlineGreen},row:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.md+r.xs/2,paddingVertical:r.sm+1},rowDivider:{borderTopWidth:l,borderTopColor:t.borderHairlineGreen},rowFlag:{backgroundColor:t.badgeBgCritical,marginHorizontal:-r.sm,paddingHorizontal:r.sm,borderRadius:n.xs},rowMain:{flexShrink:1},rowRight:{alignItems:"flex-end",gap:r.xs/2},rowLabel:{flexShrink:1,...o(i.size.body,i.lineHeight.normal,t.text.primary,"medium")},rowValue:{...o(i.size.body,i.lineHeight.normal,t.text.primary,"bold"),textAlign:"right"},rowValueAlert:{color:t.danger},rowMeta:{marginTop:r.xs/2,...face(e,"mono"),fontSize:i.size.tiny,lineHeight:i.size.body,color:t.text.muted},markerStatus:a(i.size.micro,t.text.muted),block:{paddingVertical:r.sm+r.xs/2},blockDate:{...a(i.size.tiny,t.text.muted),marginBottom:r.xs+r.xs/2},fieldRow:{flexDirection:"row",alignItems:"flex-start",gap:r.md+r.xs/2,paddingVertical:r.xs-1},fieldLabel:{width:120,...o(i.size.bodyTight,i.lineHeight.normal,t.text.muted,"medium")},fieldValue:{flex:1,...o(i.size.bodyTight,i.lineHeight.normal,t.text.primary,"medium")},noteSection:{marginTop:r.sm},noteLabel:{...a(i.size.tiny,t.brandInk),marginBottom:r.xs/2},noteBody:o(i.size.bodyTight,i.lineHeight.relaxed,t.text.primary),disclaimer:{marginTop:n.xl,paddingTop:r.md+r.xs/2,borderTopWidth:l,borderTopColor:t.borderHairlineGreen},disclaimerText:o(i.size.tiny,i.lineHeight.relaxed,t.text.muted)})}function ShareSheet({petRef:petRef,petName:e,onClose:t,onNavigate:r,onOpenUrl:n,onCopy:l}){let o=Mp(),a=Io(),s=useRecordShares(petRef),[d,c]=i(null),[u,p]=i(null),[g,y]=i("vet"),[v,w]=i(""),k=s.available&&!s.consentRequired,x=s.features.sharing!==false,T=k&&x,C=s.shareAudiences.length>0,_=s.shareAudiences.find(e=>e.audience===g)??null,R=_!==null?Ta(_,s.features):[],S=(e,t)=>{let r=n??((e,t)=>t==="share_link"?dp(e):cp(e)),i=t==="share_link"?wa.toasts.shareSheet:wa.toasts.pdfShareSheet;en(r,e,t).then(e=>{e.ok||c(i)})},I=()=>{c(null),s.createLink(C?g:void 0).then(e=>{e.ok?S(e.value.shareUrl,"share_link"):c(Sa(e.error,"create"))})},D=()=>{if(s.sending)return;c(null);let t=v.trim();if(t.length===0){c(wa.addEmailFor(e));return}if(!isShareRecipientEmail(t)){c(wa.emailInvalid);return}s.sendEmail({recipientEmail:t,recipientKind:g}).then(e=>{e.ok?(w(""),c(wa.toasts.sentTo(t))):c(Sa(e.error,"email"))})},H=()=>{c(null),s.pdfLink().then(e=>{e.ok?S(e.value.downloadUrl,"record_pdf"):c(Sa(e.error,"download"))})},L=e=>{if(!l||e.shareUrl===null)return;let t=e.shareUrl;en(l,t).then(e=>c(e.ok?wa.toasts.copiedNative:wa.toasts.copyFailedNative(t)))},P=e=>{s.revoke(e).then(e=>{p(null),c(e.ok?wa.toasts.turnedOff:Sa(e.error,"revoke"))})};/* @__PURE__ */
591
+ /* @__PURE__ */B(Text,{style:l.noteBody,children:e.text})]},`${e.section}-${t}`))]},e.noteId)),"record-document-notes"):null,To(e.disclaimer)?null:/* @__PURE__ */B(f,{style:l.disclaimer,children:/* @__PURE__ */B(Text,{style:l.disclaimerText,children:e.disclaimer})})]})}function Ep(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?qp(e):bo(qp(e),Fp(t)),[e,t])}function Fp(e){return{root:{backgroundColor:e.ground}}}function qp(e){let{color:t,space:r,radius:n,type:i}=e,l=v.hairlineWidth,o=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n}),a=(t,n)=>({...face(e,"mono"),fontSize:t,lineHeight:t+r.xs-1,color:n,letterSpacing:i.letterSpacing.eyebrow/2,textTransform:"uppercase"});return v.create({root:{backgroundColor:t.surface},inset:{paddingHorizontal:r.lg},download:{width:r.xxl+r.xs+r.xs/2,height:r.xxl+r.xs+r.xs/2,borderRadius:n.pill,alignItems:"center",justifyContent:"center"},centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xxl,minHeight:r.xxl*3+r.xl},emptyText:{...o(i.size.body,i.lineHeight.normal,t.text.muted,"medium"),textAlign:"center"},page:{paddingHorizontal:r.lg+r.xs,paddingBottom:r.xxl+r.lg},letterhead:{alignItems:"center",paddingTop:r.md,paddingBottom:r.lg+r.xs+r.xs/2,borderBottomWidth:2,borderBottomColor:t.brandInk,gap:r.xs+r.xs/2,marginBottom:r.sm},wordmark:{...o(i.size.heading,i.lineHeight.snug,t.brandInk,"bold"),letterSpacing:i.letterSpacing.headerBrand},docTitle:{...a(i.size.caption,t.brandInk),marginTop:r.sm+r.xs/2,letterSpacing:i.letterSpacing.eyebrow+.4},petName:o(i.size.verdict+r.xs/2,i.lineHeight.tight,t.text.primary),generated:{...a(i.size.tiny,t.text.muted),textTransform:"none"},section:{marginTop:r.lg+r.xs+r.xs/2},sectionHeader:{flexDirection:"row",alignItems:"center",gap:r.sm+r.xs/2,marginBottom:r.sm},sectionTitle:a(i.size.tiny,t.brandInk),rule:{flex:1,height:l,backgroundColor:t.borderHairlineGreen},row:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.md+r.xs/2,paddingVertical:r.sm+1},rowDivider:{borderTopWidth:l,borderTopColor:t.borderHairlineGreen},rowFlag:{backgroundColor:t.badgeBgCritical,marginHorizontal:-r.sm,paddingHorizontal:r.sm,borderRadius:n.xs},rowMain:{flexShrink:1},rowRight:{alignItems:"flex-end",gap:r.xs/2},rowLabel:{flexShrink:1,...o(i.size.body,i.lineHeight.normal,t.text.primary,"medium")},rowValue:{...o(i.size.body,i.lineHeight.normal,t.text.primary,"bold"),textAlign:"right"},rowValueAlert:{color:t.danger},rowMeta:{marginTop:r.xs/2,...face(e,"mono"),fontSize:i.size.tiny,lineHeight:i.size.body,color:t.text.muted},markerStatus:a(i.size.micro,t.text.muted),block:{paddingVertical:r.sm+r.xs/2},blockDate:{...a(i.size.tiny,t.text.muted),marginBottom:r.xs+r.xs/2},fieldRow:{flexDirection:"row",alignItems:"flex-start",gap:r.md+r.xs/2,paddingVertical:r.xs-1},fieldLabel:{width:120,...o(i.size.bodyTight,i.lineHeight.normal,t.text.muted,"medium")},fieldValue:{flex:1,...o(i.size.bodyTight,i.lineHeight.normal,t.text.primary,"medium")},noteSection:{marginTop:r.sm},noteLabel:{...a(i.size.tiny,t.brandInk),marginBottom:r.xs/2},noteBody:o(i.size.bodyTight,i.lineHeight.relaxed,t.text.primary),disclaimer:{marginTop:n.xl,paddingTop:r.md+r.xs/2,borderTopWidth:l,borderTopColor:t.borderHairlineGreen},disclaimerText:o(i.size.tiny,i.lineHeight.relaxed,t.text.muted)})}function ShareSheet({petRef:petRef,petName:e,onClose:t,onNavigate:r,onOpenUrl:n,onCopy:l}){let o=Mp(),a=Io(),s=useRecordShares(petRef),[d,c]=i(null),[u,p]=i(null),[g,y]=i("vet"),[v,w]=i(""),k=s.available&&!s.consentRequired,x=s.features.sharing!==false,T=k&&x,_=s.shareAudiences.length>0,C=s.shareAudiences.find(e=>e.audience===g)??null,R=C!==null?Ta(C,s.features):[],S=(e,t)=>{let r=n??((e,t)=>t==="share_link"?dp(e):cp(e)),i=t==="share_link"?wa.toasts.shareSheet:wa.toasts.pdfShareSheet;en(r,e,t).then(e=>{e.ok||c(i)})},I=()=>{c(null),s.createLink(_?g:void 0).then(e=>{e.ok?S(e.value.shareUrl,"share_link"):c(Sa(e.error,"create"))})},D=()=>{if(s.sending)return;c(null);let t=v.trim();if(t.length===0){c(wa.addEmailFor(e));return}if(!isShareRecipientEmail(t)){c(wa.emailInvalid);return}s.sendEmail({recipientEmail:t,recipientKind:g}).then(e=>{e.ok?(w(""),c(wa.toasts.sentTo(t))):c(Sa(e.error,"email"))})},H=()=>{c(null),s.pdfLink().then(e=>{e.ok?S(e.value.downloadUrl,"record_pdf"):c(Sa(e.error,"download"))})},L=e=>{if(!l||e.shareUrl===null)return;let t=e.shareUrl;en(l,t).then(e=>c(e.ok?wa.toasts.copiedNative:wa.toasts.copyFailedNative(t)))},P=e=>{s.revoke(e).then(e=>{p(null),c(e.ok?wa.toasts.turnedOff:Sa(e.error,"revoke"))})};/* @__PURE__ */
592
592
  return B(z,{transparent:true,visible:true,animationType:"slide",onRequestClose:t,children:/* @__PURE__ */j(f,{style:o.backdrop,children:[
593
593
  /* @__PURE__ */B(m,{style:bu,accessibilityRole:"button",accessibilityLabel:wa.closeSheetA11y,onPress:t}),
594
594
  /* @__PURE__ */j(f,{style:o.sheet,accessibilityViewIsModal:true,testID:"share-record-sheet",children:[
@@ -596,13 +596,13 @@ return B(z,{transparent:true,visible:true,animationType:"slide",onRequestClose:t
596
596
  /* @__PURE__ */j(f,{style:o.header,children:[
597
597
  /* @__PURE__ */j(f,{style:o.headerText,children:[
598
598
  /* @__PURE__ */B(Text,{style:o.title,accessibilityRole:"header",children:wa.titleFor(e)}),
599
- /* @__PURE__ */B(Text,{style:o.helper,children:C?wa.leadNative:wa.helper})]}),
599
+ /* @__PURE__ */B(Text,{style:o.helper,children:_?wa.leadNative:wa.helper})]}),
600
600
  /* @__PURE__ */B(m,{accessibilityRole:"button",accessibilityLabel:wa.close,onPress:t,hitSlop:12,style:o.closeButton,testID:"share-record-close",children:/* @__PURE__ */B(Text,{style:o.closeGlyph,children:"×"})})]}),
601
601
  /* @__PURE__ */j(b,{style:o.scroll,contentContainerStyle:o.body,showsVerticalScrollIndicator:false,children:[
602
602
  /* @__PURE__ */j(f,{style:o.actions,children:[T?/* @__PURE__ */j(f,{style:o.form,testID:"share-email-form",children:[
603
603
  /* @__PURE__ */B(Text,{style:o.fieldLabel,children:wa.audienceLabel}),
604
604
  /* @__PURE__ */B(f,{style:o.choices,accessibilityRole:"radiogroup",accessibilityLabel:wa.audienceLabel,children:pe.map(e=>{let t=g===e;/* @__PURE__ */
605
- return B(m,{onPress:()=>y(e),accessibilityRole:"radio",accessibilityLabel:wa.audiences[e],accessibilityState:{checked:t,selected:t},style:[o.choice,t?o.choiceOn:null],testID:`share-audience-${e}`,children:/* @__PURE__ */B(Text,{style:t?o.choiceTitleOn:o.choiceTitle,children:wa.audiences[e]})},e)})}),C&&R.length>0?/* @__PURE__ */j(f,{style:o.included,testID:"share-included",children:[
605
+ return B(m,{onPress:()=>y(e),accessibilityRole:"radio",accessibilityLabel:wa.audiences[e],accessibilityState:{checked:t,selected:t},style:[o.choice,t?o.choiceOn:null],testID:`share-audience-${e}`,children:/* @__PURE__ */B(Text,{style:t?o.choiceTitleOn:o.choiceTitle,children:wa.audiences[e]})},e)})}),_&&R.length>0?/* @__PURE__ */j(f,{style:o.included,testID:"share-included",children:[
606
606
  /* @__PURE__ */B(Text,{style:o.fieldLabel,children:wa.included}),R.map(e=>/* @__PURE__ */j(f,{style:o.includedRow,children:[
607
607
  /* @__PURE__ */B(Text,{style:o.includedLine,accessibilityElementsHidden:true,importantForAccessibility:"no",children:"•"}),
608
608
  /* @__PURE__ */B(Text,{style:[o.includedLine,o.includedText],testID:`share-included-line-${e}`,children:e})]},e))]}):null,r?/* @__PURE__ */B(Pill,{label:wa.previewNative,onPress:()=>{t(),r({name:"document"})},testID:"share-view-document"}):null,
@@ -628,7 +628,7 @@ return B(m,{onPress:()=>y(e),accessibilityRole:"radio",accessibilityLabel:wa.aud
628
628
  /* @__PURE__ */B(Pill,{label:s.revokingId===e.shareId?wa.turningOff:wa.turnOff,kind:"danger",busy:s.revokingId===e.shareId,onPress:()=>P(e.shareId),testID:`share-revoke-do-${e.shareId}`}),
629
629
  /* @__PURE__ */B(Pill,{label:wa.keep,kind:"outline",disabled:s.revokingId===e.shareId,onPress:()=>p(null),testID:`share-revoke-cancel-${e.shareId}`})]})]}):/* @__PURE__ */j(f,{style:o.rowActions,children:[l?/* @__PURE__ */B(Pill,{label:wa.copyLink,kind:"outline",disabled:e.shareUrl===null,accessibilityHint:e.a11yLabel,onPress:()=>L(e),testID:`share-copy-${e.shareId}`}):null,x?/* @__PURE__ */B(Pill,{label:wa.turnOff,kind:"danger",accessibilityLabel:wa.turnOffA11y(e.actionContext),onPress:()=>p(e.shareId),testID:`share-ask-revoke-${e.shareId}`}):null]})]},e.shareId))})]}):null]}),
630
630
  /* @__PURE__ */B(f,{style:a.inset})]})]})})}function Mp(){let e=useEverfurTheme();return n(()=>Np(e),[e])}function Np(e){let{color:t,space:r,radius:n,type:i}=e,l=r.xxl+r.md,o=v.hairlineWidth,a=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n}),{dialog:s,tab:d,input:c,card:u}=e.slots,h=jn(s);return v.create({active:{color:t.success},inactive:{color:t.text.muted},backdrop:{flex:1,justifyContent:"flex-end",backgroundColor:"rgba(0,0,0,0.4)"},sheet:{backgroundColor:t.surface,borderTopLeftRadius:n.xl-1,borderTopRightRadius:n.xl-1,paddingHorizontal:r.lg+r.xs+r.xs/2,paddingTop:r.md,paddingBottom:n.xl,maxHeight:"88%",gap:r.md,...Wc(s)},handle:{alignSelf:"center",width:r.xxl+r.xs,height:r.xs,borderRadius:n.pill,backgroundColor:t.borderRingCream},header:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.sm},headerText:{flex:1,gap:r.xs},title:{...a(i.size.heading,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),...h},helper:{...a(i.size.bodyTight,i.lineHeight.normal,t.text.muted),...h},terms:{...a(i.size.caption,i.lineHeight.normal,t.text.muted),textAlign:"center"},closeButton:{width:l,height:l,alignItems:"center",justifyContent:"center"},closeGlyph:{...a(i.size.verdict,i.lineHeight.tight,t.text.primary),...h},scroll:{flexGrow:0},body:{gap:r.lg,paddingBottom:r.sm},actions:{gap:r.sm},form:{gap:r.sm,paddingBottom:r.sm},fieldLabel:{...a(i.size.bodyTight,i.lineHeight.normal,t.text.secondary,"medium")},choices:{flexDirection:"row",gap:r.sm},choice:{flex:1,minHeight:l,alignItems:"center",justifyContent:"center",paddingHorizontal:r.sm,borderRadius:n.md,borderWidth:o,borderColor:t.borderHairlineGreen,backgroundColor:t.surface,...Bn(d,o)},choiceOn:{borderWidth:1.5,borderColor:t.brandInk,backgroundColor:t.brandSoft},choiceTitle:{...a(i.size.body,i.lineHeight.snug,t.text.primary,"medium"),...jn(d)},choiceTitleOn:{...a(i.size.body,i.lineHeight.snug,t.text.primary,"bold")},included:{gap:r.xs},includedRow:{flexDirection:"row",gap:r.sm},includedLine:a(i.size.bodyTight,i.lineHeight.normal,t.text.primary),includedText:{flex:1},field:{...a(i.size.body,i.lineHeight.normal,t.text.primary),minHeight:l,paddingHorizontal:r.md,borderRadius:n.sm,borderWidth:o,borderColor:t.borderHairlineGreen,backgroundColor:t.surface,...Bn(c,o),...jn(c)},placeholder:{color:t.text.placeholder},notice:{...a(i.size.bodyTight,i.lineHeight.normal,t.text.secondary),padding:r.md,borderRadius:n.md-r.xs/2,backgroundColor:t.brandSoft},section:{gap:r.sm},sectionLabel:{...a(i.size.bodyTight,i.lineHeight.snug,t.text.secondary,"bold"),textTransform:"uppercase",letterSpacing:i.letterSpacing.eyebrow/2},stateCard:{gap:r.sm,padding:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,borderWidth:o,borderColor:t.brandBorder,...Bn(u,o)},stateTitle:{...a(i.size.body,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold")},stateBody:a(i.size.bodyTight,i.lineHeight.normal,t.text.muted),list:{gap:r.md},row:{gap:r.sm,padding:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,borderWidth:o,borderColor:t.brandBorder,...Bn(u,o)},statusLine:{flexDirection:"row",alignItems:"center",gap:r.sm},statusDot:{width:r.sm,height:r.sm,borderRadius:r.xs},status:{...a(i.size.bodyTight,i.lineHeight.snug,t.text.primary,"bold")},expiry:{...a(i.size.caption,i.lineHeight.normal,t.text.muted)},created:a(i.size.tiny,i.lineHeight.normal,t.text.muted),url:{...a(i.size.caption,i.lineHeight.normal,t.text.secondary,"mono")},rowActions:{flexDirection:"row",flexWrap:"wrap",gap:r.sm},confirm:{gap:r.sm},confirmText:{...a(i.size.bodyTight,i.lineHeight.normal,t.text.primary,"medium")}})}var Wp=(e,petRef)=>e.getRecordDepth(petRef),Up=e=>!e.available;function EverfurRecordDetail(e){let{style:t,renderPending:r,...n}=Zr(e,["onNavigate","onBack","onAsk"]);/* @__PURE__ */
631
- return B(CapabilityGate,{capability:"records",style:t,...r?{renderPending:r}:{},...Wo(n.onBack,jo),children:/* @__PURE__ */B(RecordBody,{...n,style:t})})}function RecordBody({petRef:petRef,petName:e,controller:t,consentVersion:r,consentScope:l,consentText:o,onNavigate:a,onBack:s,onAsk:d,onOpenUrl:c,onCopy:u,style:h}){let p=Io(),g=Gp(),y=useEverfurRecords({petRef:petRef,...t?{controller:t}:{},...l?{consentScope:l}:{}}),v=useRecordsDepthRead(petRef,Wp,Up),w=useRecordFactEdit(petRef),k=Pp(petRef),[x,T]=i(false);lh(r,o);let C=n(()=>Dc(r,y.consent),[r,y.consent]),_=n(()=>ep(y,r),[y,r]),R=v.value!==null&&!v.value.withheld&&v.value.available?v.value:null,S=y.record,z=()=>{y.refresh(),v.refresh()},I=a!==void 0||k.lit===true,D=useCapability("recordsClinic"),H=a!==void 0&&(D.enabled||D.isPending),L;if(y.status==="loading"||v.status==="loading"&&S!==null&&!S.isEmpty)L=/* @__PURE__ */B(RecordSkeleton,{testID:"everfur-record-loading"});else if(y.status==="error"){let e=Hc(y,C);L=e.kind==="error"||e.kind==="pet_not_found"?/* @__PURE__ */B(RecordsEmptyState,{variant:ai(e.error),message:e.error.displayMessage,onAction:e.error.retryable?z:void 0,testID:"everfur-record-error"}):Zh(y,_,C,o)}else if(S===null||S.isEmpty){let e=R?.completeness?.documentsInReview??0;L=/* @__PURE__ */j(b,{contentContainerStyle:p.content,testID:"everfur-record-empty",children:[
631
+ return B(CapabilityGate,{capability:"records",style:t,...r?{renderPending:r}:{},...Wo(n.onBack,jo),children:/* @__PURE__ */B(RecordBody,{...n,style:t})})}function RecordBody({petRef:petRef,petName:e,controller:t,consentVersion:r,consentScope:l,consentText:o,onNavigate:a,onBack:s,onAsk:d,onOpenUrl:c,onCopy:u,style:h}){let p=Io(),g=Gp(),y=useEverfurRecords({petRef:petRef,...t?{controller:t}:{},...l?{consentScope:l}:{}}),v=useRecordsDepthRead(petRef,Wp,Up),w=useRecordFactEdit(petRef),k=Pp(petRef),[x,T]=i(false);lh(r,o);let _=n(()=>Dc(r,y.consent),[r,y.consent]),C=n(()=>ep(y,r),[y,r]),R=v.value!==null&&!v.value.withheld&&v.value.available?v.value:null,S=y.record,z=()=>{y.refresh(),v.refresh()},I=a!==void 0||k.lit===true,D=useCapability("recordsClinic"),H=a!==void 0&&(D.enabled||D.isPending),L;if(y.status==="loading"||v.status==="loading"&&S!==null&&!S.isEmpty)L=/* @__PURE__ */B(RecordSkeleton,{testID:"everfur-record-loading"});else if(y.status==="error"){let e=Hc(y,_);L=e.kind==="error"||e.kind==="pet_not_found"?/* @__PURE__ */B(RecordsEmptyState,{variant:ai(e.error),message:e.error.displayMessage,onAction:e.error.retryable?z:void 0,testID:"everfur-record-error"}):Zh(y,C,_,o)}else if(S===null||S.isEmpty){let e=R?.completeness?.documentsInReview??0;L=/* @__PURE__ */j(b,{contentContainerStyle:p.content,testID:"everfur-record-empty",children:[
632
632
  /* @__PURE__ */B(RecordsEmptyState,{variant:"no_records",message:e>0?ha.inReview(e):void 0}),
633
633
  /* @__PURE__ */B(DisclaimerBand,{disclaimer:S?.disclaimer??""})]})}else L=/* @__PURE__ */B(b,{contentContainerStyle:g.content,testID:"everfur-record",children:/* @__PURE__ */B(RecordSections,{record:S,depth:R,petName:e,onNavigate:a,onAsk:d,factEdit:w})});/* @__PURE__ */
634
634
  return j(f,{style:[p.root,h],children:[
@@ -714,11 +714,11 @@ return j(f,{style:[s.root,a],children:[
714
714
  /* @__PURE__ */B(Text,{style:d.title,accessibilityRole:"header",children:ah.screenTitle}),
715
715
  /* @__PURE__ */B(Text,{style:d.subtitle,children:ah.subtitle(e)})]}),
716
716
  /* @__PURE__ */B(UploadRecordCard,{records:h,requestId:null,onPickDocument:r,onPickPhotos:n,canUpload:p,onDone:l?e=>l({name:"request",requestId:e}):void 0})]}),
717
- /* @__PURE__ */B(RecordsFootnote,{})]})}function UploadRecordCard({records:e,requestId:t,onPickDocument:n,onPickPhotos:o,canUpload:a,onDone:s}){let d=Io(),c=ng(),{runtime:u}=Ir(),h=u.registry.services.camera,p=e.uploadContentTypes,g=acceptsPhotos(p),m=g&&Zd(h),b=g&&o!==void 0,y=m||b,[v,w]=i(null),[k,x]=i(0),T=r(t),C=r([]),_=e.uploadQueue.filter(e=>e.status!=="skipped"),R=_.filter(e=>e.status==="done").length,S=_.filter(e=>e.status==="failed").length,z=!e.isUploading&&k>0,I=l(async t=>{let{uploadable:r,skipped:n}=Fr(t,p),i=ph(n,y);if(r.length===0){i!==null&&w(i);return}w(i);let l=T.current;if(l===null){let t=await e.createRequest(`records-upload-${Date.now().toString(36)}`);if(!t.ok){w(ah.errors.start);return}l=t.value.id,T.current=l}x(e=>e+1);let o=await e.uploadDocuments(l,r);C.current=o.flatMap((e,t)=>e.status==="failed"&&r[t]!==void 0?[r[t]]:[])},[e,p,y]),D=l(e=>{!e||!a||en(e).then(e=>{if(!e.ok){w(ah.errors.startPlain);return}let t=e.value;t!==null&&I(Array.isArray(t)?t:[t])})},[a,I]),H=l(()=>{D(n)},[D,n]),L=l(()=>{D(o)},[D,o]),P=l(()=>{!m||!a||en(()=>h.capture(Jd("photo"))).then(e=>{if(!e.ok)return;let t=Xd(e.value);if(t.sizeBytes===void 0){w(ah.errors.startPlain);return}I([t])})},[h,m,a,I]),O=l(()=>{I(C.current)},[I]);/* @__PURE__ */
717
+ /* @__PURE__ */B(RecordsFootnote,{})]})}function UploadRecordCard({records:e,requestId:t,onPickDocument:n,onPickPhotos:o,canUpload:a,onDone:s}){let d=Io(),c=ng(),{runtime:u}=Ir(),h=u.registry.services.camera,p=e.uploadContentTypes,g=acceptsPhotos(p),m=g&&Zd(h),b=g&&o!==void 0,y=m||b,[v,w]=i(null),[k,x]=i(0),T=r(t),_=r([]),C=e.uploadQueue.filter(e=>e.status!=="skipped"),R=C.filter(e=>e.status==="done").length,S=C.filter(e=>e.status==="failed").length,z=!e.isUploading&&k>0,I=l(async t=>{let{uploadable:r,skipped:n}=Fr(t,p),i=ph(n,y);if(r.length===0){i!==null&&w(i);return}w(i);let l=T.current;if(l===null){let t=await e.createRequest(`records-upload-${Date.now().toString(36)}`);if(!t.ok){w(ah.errors.start);return}l=t.value.id,T.current=l}x(e=>e+1);let o=await e.uploadDocuments(l,r);_.current=o.flatMap((e,t)=>e.status==="failed"&&r[t]!==void 0?[r[t]]:[])},[e,p,y]),D=l(e=>{!e||!a||en(e).then(e=>{if(!e.ok){w(ah.errors.startPlain);return}let t=e.value;t!==null&&I(Array.isArray(t)?t:[t])})},[a,I]),H=l(()=>{D(n)},[D,n]),L=l(()=>{D(o)},[D,o]),P=l(()=>{!m||!a||en(()=>h.capture(Jd("photo"))).then(e=>{if(!e.ok)return;let t=Xd(e.value);if(t.sizeBytes===void 0){w(ah.errors.startPlain);return}I([t])})},[h,m,a,I]),O=l(()=>{I(_.current)},[I]);/* @__PURE__ */
718
718
  return j(f,{style:c.card,testID:"records-upload-card",children:[
719
719
  /* @__PURE__ */B(Text,{style:c.cardTitle,accessibilityRole:"header",children:ah.cardTitle}),
720
720
  /* @__PURE__ */B(Text,{style:c.cardSubtitle,children:y?sh.note:ah.cardSubtitle}),v?/* @__PURE__ */B(f,{style:d.errorBanner,accessibilityRole:"alert",children:/* @__PURE__ */B(Text,{style:d.errorText,children:v})}):null,
721
- /* @__PURE__ */B(UploadQueue,{records:e}),e.isUploading?/* @__PURE__ */B(f,{style:c.uploadingRow,children:/* @__PURE__ */B(Text,{style:c.progressText,children:ah.uploading(R,_.length)})}):z?/* @__PURE__ */j(f,{style:c.settled,children:[R>0?/* @__PURE__ */B(Text,{style:c.success,accessibilityRole:"alert",children:ah.received(R)}):null,S>0?/* @__PURE__ */B(Pill,{label:ah.retryFailed(S),kind:"link",onPress:O,testID:"records-upload-retry-failed"}):null,
721
+ /* @__PURE__ */B(UploadQueue,{records:e}),e.isUploading?/* @__PURE__ */B(f,{style:c.uploadingRow,children:/* @__PURE__ */B(Text,{style:c.progressText,children:ah.uploading(R,C.length)})}):z?/* @__PURE__ */j(f,{style:c.settled,children:[R>0?/* @__PURE__ */B(Text,{style:c.success,accessibilityRole:"alert",children:ah.received(R)}):null,S>0?/* @__PURE__ */B(Pill,{label:ah.retryFailed(S),kind:"link",onPress:O,testID:"records-upload-retry-failed"}):null,
722
722
  /* @__PURE__ */B(Text,{style:c.cardTitle,accessibilityRole:"header",children:ah.haveMore}),y?/* @__PURE__ */B(Text,{style:c.cardSubtitle,children:sh.haveMoreLead}):null,
723
723
  /* @__PURE__ */j(f,{style:c.settledActions,children:[
724
724
  /* @__PURE__ */B(Pill,{label:ah.addMore,kind:"link",accessibilityLabel:ah.addMoreA11y,disabled:!a,onPress:H,testID:"records-upload-another"}),s&&T.current!==null&&R>0?/* @__PURE__ */B(Pill,{label:ah.done,accessibilityLabel:ah.doneA11y,onPress:()=>s(T.current),testID:"records-upload-done"}):null]})]}):y?/* @__PURE__ */j(f,{style:c.actions,children:[m?/* @__PURE__ */j(f,{style:c.action,children:[
@@ -727,10 +727,10 @@ return j(f,{style:c.card,testID:"records-upload-card",children:[
727
727
  /* @__PURE__ */j(f,{style:c.action,children:[
728
728
  /* @__PURE__ */B(Pill,{label:ah.chooseFiles,disabled:!a,onPress:H,testID:"records-upload-choose"}),
729
729
  /* @__PURE__ */B(Text,{style:c.actionMeta,children:sh.chooseFileMeta})]})]}):/* @__PURE__ */B(Pill,{label:ah.chooseFiles,disabled:!a,onPress:H,testID:"records-upload-choose"})]})}function ng(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?og(e):bo(og(e),ig(t)),[e,t])}function ig(e){return{card:mo(e),cardTitle:e.cardTitle,title:{...e.title,textAlign:"center"}}}var lg=24;function og(e){let{color:t,space:r,radius:n,type:i}=e,l=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n});return v.create({content:{padding:r.lg+r.xs,gap:r.lg+r.xs},header:{gap:r.sm,alignItems:"center"},iconBubble:{width:r.xxl+r.lg+r.xs,height:r.xxl+r.lg+r.xs,borderRadius:n.pill,alignItems:"center",justifyContent:"center",marginBottom:r.xs},title:{...l(i.size.heading+r.xs/2,i.lineHeight.snug,t.brandInk,"bold"),...headingFace(e,"bold"),textAlign:"center"},subtitle:{...l(i.size.body,i.lineHeight.normal,t.text.muted),textAlign:"center",maxWidth:340},card:{borderRadius:n.lg,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,padding:r.lg,gap:r.md,...Bn(e.slots.card,1)},cardTitle:{...l(i.size.subtitle,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold"),...jn(e.slots.card)},cardSubtitle:{...l(i.size.bodyTight,i.lineHeight.normal,t.text.muted),...jn(e.slots.card)},uploadingRow:{flexDirection:"row",alignItems:"center",gap:r.sm},progressText:{flex:1,...l(i.size.bodyTight,i.lineHeight.normal,t.text.secondary)},settled:{gap:r.sm},success:l(i.size.bodyTight,i.lineHeight.normal,t.text.primary),settledActions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:r.sm},actions:{gap:r.md},action:{gap:r.xs},actionMeta:l(i.size.bodyTight,i.lineHeight.normal,t.text.muted)})}function EverfurRecordsRequest(e){let{style:t,renderPending:r,...n}=Zr(e,["onNavigate","onBack"]),{userRef:userRef}=Ir();/* @__PURE__ */
730
- return B(CapabilityGate,{capability:"records",style:t,...r?{renderPending:r}:{},...Wo(n.onBack,jo),children:userRef===null?/* @__PURE__ */B(SessionRequiredScreen,{style:t,testID:"records-request-session-required"}):/* @__PURE__ */B(RequestBody,{...n,style:t})})}function RequestBody({petRef:petRef,petName:e,requestId:t,controller:r,onPickDocument:n,onPickPhotos:i,uploadTransport:l,onNavigate:o,onBack:a,onOpenUrl:s,onAsk:d,style:c,nowMs:u}){let h=Io(),p=Do(),{runtime:g,userRef:userRef,scopeEpoch:m}=Ir(),b=useEverfurRecords(r?{petRef:petRef,controller:r,readUploadFeatures:true}:l?{petRef:petRef,uploadTransport:l,readUploadFeatures:true}:{petRef:petRef,readUploadFeatures:true}),y=b.requests.find(e=>e.id===t)??null,v=zc(n)&&(r!==void 0||l!==void 0||gt(g.registry.services.uploadTransport)),w=y?selectRequestTitle(y):"",x=Kp(b.refresh,"records-request-refresh"),T;b.status==="loading"&&y===null?T=/* @__PURE__ */B(RequestSkeleton,{testID:"records-request-loading"}):b.status==="error"&&b.error?T=/* @__PURE__ */B(RecordsEmptyState,{variant:ai(b.error),message:b.error.displayMessage,onAction:b.error.retryable?b.refresh:void 0,testID:"records-request-error"}):y===null&&(T=/* @__PURE__ */B(RecordsEmptyState,{variant:"no_requests",testID:"records-request-missing"}));let C=y!==null&&T===void 0,_=p!==null&&d!==void 0&&y!==null&&C?()=>{let t=pc(e,{clinicName:y.clinicName??null,statusLabel:selectPrimaryLabel(y),status:y.status,heldItemCount:y.heldItemCount},y.id);d(t.prompt,t.entityRef)}:null;return C&&(T=/* @__PURE__ */B(RequestDetail,{petName:e,request:y,records:b,canUpload:v,onPickDocument:n,onPickPhotos:i,onNavigate:o,onOpenUrl:s,nowMs:u,refreshControl:x,askRoom:_!==null},JSON.stringify([userRef,m,y.id]))),/* @__PURE__ */j(f,{style:[h.root,c],children:[
730
+ return B(CapabilityGate,{capability:"records",style:t,...r?{renderPending:r}:{},...Wo(n.onBack,jo),children:userRef===null?/* @__PURE__ */B(SessionRequiredScreen,{style:t,testID:"records-request-session-required"}):/* @__PURE__ */B(RequestBody,{...n,style:t})})}function RequestBody({petRef:petRef,petName:e,requestId:t,controller:r,onPickDocument:n,onPickPhotos:i,uploadTransport:l,onNavigate:o,onBack:a,onOpenUrl:s,onAsk:d,style:c,nowMs:u}){let h=Io(),p=Do(),{runtime:g,userRef:userRef,scopeEpoch:m}=Ir(),b=useEverfurRecords(r?{petRef:petRef,controller:r,readUploadFeatures:true}:l?{petRef:petRef,uploadTransport:l,readUploadFeatures:true}:{petRef:petRef,readUploadFeatures:true}),y=b.requests.find(e=>e.id===t)??null,v=zc(n)&&(r!==void 0||l!==void 0||gt(g.registry.services.uploadTransport)),w=y?selectRequestTitle(y):"",x=Kp(b.refresh,"records-request-refresh"),T;b.status==="loading"&&y===null?T=/* @__PURE__ */B(RequestSkeleton,{testID:"records-request-loading"}):b.status==="error"&&b.error?T=/* @__PURE__ */B(RecordsEmptyState,{variant:ai(b.error),message:b.error.displayMessage,onAction:b.error.retryable?b.refresh:void 0,testID:"records-request-error"}):y===null&&(T=/* @__PURE__ */B(RecordsEmptyState,{variant:"no_requests",testID:"records-request-missing"}));let _=y!==null&&T===void 0,C=p!==null&&d!==void 0&&y!==null&&_?()=>{let t=pc(e,{clinicName:y.clinicName??null,statusLabel:selectPrimaryLabel(y),status:y.status,heldItemCount:y.heldItemCount},y.id);d(t.prompt,t.entityRef)}:null;return _&&(T=/* @__PURE__ */B(RequestDetail,{petName:e,request:y,records:b,canUpload:v,onPickDocument:n,onPickPhotos:i,onNavigate:o,onOpenUrl:s,nowMs:u,refreshControl:x,askRoom:C!==null},JSON.stringify([userRef,m,y.id]))),/* @__PURE__ */j(f,{style:[h.root,c],children:[
731
731
  /* @__PURE__ */B(ScreenHeader,{title:w,onBack:a,testID:"records-request-header"}),
732
- /* @__PURE__ */j(k,{behavior:"padding",style:h.body,children:[T,_!==null?/* @__PURE__ */B(RecordsAskPill,{label:ni.ask,onPress:_,testID:"records-request-ask-pill"}):null]}),
733
- /* @__PURE__ */B(RecordsFootnote,{})]})}var ag=Zl(".ask-pill","minHeight")+Zl(".ask-pill","bottom")*2;function RequestDetail({petName:e,request:t,records:n,canUpload:l,onPickDocument:a,onPickPhotos:s,onNavigate:d,onOpenUrl:c,nowMs:u,refreshControl:h,askRoom:p=false}){let g=Io(),m=sg(),y=useEverfurTheme(),v=mh({request:t,onRecovered:n.refresh,canUpload:l},useEverfurRecordsClinic()),[w,k]=i(null),[x,T]=i(false),[C,_]=i(null),R=r(true);o(()=>(R.current=true,()=>{R.current=false}),[]);let S=v.request,z=u??Date.now(),I=S.status==="published",D=S.status==="published"||S.status==="failed"||S.status==="revoked",H=fi(S),L=S.wireStatus==="clinic_responded_no_records",P=gi(S,z),O=hi(S,z),$=D?null:S.waitingExpectation?.trim()||null,A=selectClinicCall(S),E=mi(S),F=v.canConvert,q=D&&!I,M=v.error!==null&&w!==null&&w!=="start"?w==="revoke"?si.errors.cancel:si.errors[w]:null,N=(e,t)=>{k(e),t()},W=()=>{x||(T(true),_(null),n.createRequest(`records-upload-${Date.now().toString(36)}`).then(e=>{if(R.current){if(T(false),!e.ok){_(si.errors.start);return}d?.({name:"request",requestId:e.value.id})}}))},U=S.clinicName?.trim()??"",G=!Hh(S)&&U.length>0,V=G&&(S.status==="requested"||S.status==="awaiting_clinic"),K=Xo(S.createdAt);/* @__PURE__ */
732
+ /* @__PURE__ */j(k,{behavior:"padding",style:h.body,children:[T,C!==null?/* @__PURE__ */B(RecordsAskPill,{label:ni.ask,onPress:C,testID:"records-request-ask-pill"}):null]}),
733
+ /* @__PURE__ */B(RecordsFootnote,{})]})}var ag=Zl(".ask-pill","minHeight")+Zl(".ask-pill","bottom")*2;function RequestDetail({petName:e,request:t,records:n,canUpload:l,onPickDocument:a,onPickPhotos:s,onNavigate:d,onOpenUrl:c,nowMs:u,refreshControl:h,askRoom:p=false}){let g=Io(),m=sg(),y=useEverfurTheme(),v=mh({request:t,onRecovered:n.refresh,canUpload:l},useEverfurRecordsClinic()),[w,k]=i(null),[x,T]=i(false),[_,C]=i(null),R=r(true);o(()=>(R.current=true,()=>{R.current=false}),[]);let S=v.request,z=u??Date.now(),I=S.status==="published",D=S.status==="published"||S.status==="failed"||S.status==="revoked",H=fi(S),L=S.wireStatus==="clinic_responded_no_records",P=gi(S,z),O=hi(S,z),$=D?null:S.waitingExpectation?.trim()||null,A=selectClinicCall(S),E=mi(S),F=v.canConvert,q=D&&!I,M=v.error!==null&&w!==null&&w!=="start"?w==="revoke"?si.errors.cancel:si.errors[w]:null,N=(e,t)=>{k(e),t()},W=()=>{x||(T(true),C(null),n.createRequest(`records-upload-${Date.now().toString(36)}`).then(e=>{if(R.current){if(T(false),!e.ok){C(si.errors.start);return}d?.({name:"request",requestId:e.value.id})}}))},U=S.clinicName?.trim()??"",G=!Hh(S)&&U.length>0,V=G&&(S.status==="requested"||S.status==="awaiting_clinic"),K=Xo(S.createdAt);/* @__PURE__ */
734
734
  return j(b,{contentContainerStyle:[m.content,p?{paddingBottom:ag}:null],keyboardShouldPersistTaps:"handled",refreshControl:h,testID:`records-request-${S.id}`,children:[V?/* @__PURE__ */j(f,{style:m.sent,testID:"records-request-sent",children:[
735
735
  /* @__PURE__ */B(Text,{style:m.cardTitle,accessibilityRole:"header",children:si.sentTitle}),
736
736
  /* @__PURE__ */B(Text,{style:g.bodyText,children:si.sentLeadWeb(U,Qn(e))})]}):null,
@@ -750,18 +750,18 @@ return j(b,{contentContainerStyle:[m.content,p?{paddingBottom:ag}:null],keyboard
750
750
  /* @__PURE__ */B(ClinicCallCard,{call:A,prompt:S.statusLabel}),S.canRetrySend===true?/* @__PURE__ */B(Pill,{label:v.busy&&w==="retry"?si.resending:si.resend,kind:"outline",disabled:!v.canRetry,onPress:()=>N("retry",v.retry),testID:"records-resend-authorization"}):null]}):null,F?/* @__PURE__ */j(f,{style:m.block,children:[
751
751
  /* @__PURE__ */B(Pill,{label:v.busy&&w==="convert"?si.converting:si.convert,busy:v.busy&&w==="convert",onPress:()=>N("convert",v.convert),testID:"records-convert-upload"}),
752
752
  /* @__PURE__ */B(Text,{style:g.muted,children:si.convertHint}),M&&w==="convert"?/* @__PURE__ */B(f,{style:g.errorBanner,accessibilityRole:"alert",children:/* @__PURE__ */B(Text,{style:g.errorText,children:M})}):null]}):null,q?/* @__PURE__ */j(f,{style:m.block,children:[
753
- /* @__PURE__ */B(Pill,{label:x?si.freshUploadStarting:si.freshUpload,kind:H||L?"outline":"primary",busy:x,onPress:W,testID:"records-upload-own-fresh"}),C?/* @__PURE__ */B(f,{style:g.errorBanner,accessibilityRole:"alert",children:/* @__PURE__ */B(Text,{style:g.errorText,children:C})}):null]}):null,M&&w==="revoke"?/* @__PURE__ */B(f,{style:g.errorBanner,accessibilityRole:"alert",children:/* @__PURE__ */B(Text,{style:g.errorText,children:M})}):null,S.canRevoke===true?v.confirmingRevoke?/* @__PURE__ */j(f,{style:m.block,testID:"records-revoke-confirm",children:[
753
+ /* @__PURE__ */B(Pill,{label:x?si.freshUploadStarting:si.freshUpload,kind:H||L?"outline":"primary",busy:x,onPress:W,testID:"records-upload-own-fresh"}),_?/* @__PURE__ */B(f,{style:g.errorBanner,accessibilityRole:"alert",children:/* @__PURE__ */B(Text,{style:g.errorText,children:_})}):null]}):null,M&&w==="revoke"?/* @__PURE__ */B(f,{style:g.errorBanner,accessibilityRole:"alert",children:/* @__PURE__ */B(Text,{style:g.errorText,children:M})}):null,S.canRevoke===true?v.confirmingRevoke?/* @__PURE__ */j(f,{style:m.block,testID:"records-revoke-confirm",children:[
754
754
  /* @__PURE__ */B(Text,{style:m.confirmTitle,accessibilityRole:"header",children:fh.cancelQuestion}),
755
755
  /* @__PURE__ */B(Text,{style:g.bodyText,children:fh.cancelConsequence}),
756
756
  /* @__PURE__ */B(Pill,{label:v.busy&&w==="revoke"?si.cancelling:si.cancel,kind:"danger",busy:v.busy&&w==="revoke",onPress:()=>N("revoke",v.revoke),testID:"records-revoke-do"}),
757
757
  /* @__PURE__ */B(Pill,{label:fh.keepRequest,kind:"outline",disabled:v.busy,onPress:v.keepRequest,testID:"records-revoke-keep"})]}):/* @__PURE__ */B(Pill,{label:si.cancel,kind:"danger",disabled:v.busy,onPress:v.askRevoke,testID:"records-revoke"}):null]})}function sg(){let e=useEverfurTheme(),t=Do();return n(()=>t===null?cg(e):bo(cg(e),dg(t)),[e,t])}function dg(e){return{card:mo(e),cardTitle:e.cardTitle,confirmTitle:e.cardTitle,readyCta:{minHeight:e.button.minHeight}}}function cg(e){let{color:t,space:r,radius:n,type:i}=e,l=(t,r,n,i="regular")=>({...face(e,i),fontSize:t,lineHeight:Math.round(t*r),color:n});return v.create({content:{paddingHorizontal:r.lg,paddingBottom:r.xxl,gap:r.lg+r.xs/2},readyCta:{minHeight:r.xxl+r.lg+r.xs/2},sent:{gap:r.xs},card:{borderRadius:n.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,padding:r.lg,gap:r.md,...Bn(An(e.slots),1)},cardTitle:{...l(i.size.subtitle,i.lineHeight.snug,t.brandInk,"bold"),...headingFace(e,"bold"),letterSpacing:-.4,...jn(An(e.slots))},detailRow:{flexDirection:"row",alignItems:"baseline",justifyContent:"space-between",gap:r.lg},detailValue:{flexShrink:1,textAlign:"right",...l(i.size.body,i.lineHeight.normal,t.text.primary)},failureCard:{borderRadius:n.lg-r.xs,borderWidth:1,padding:r.md+r.xs/2,gap:r.md},failureCritical:{borderColor:t.badgeBgCritical,backgroundColor:t.badgeBgCritical},failureCaution:{borderColor:t.badgeBgCaution,backgroundColor:t.badgeBgCaution},failureTitle:{...l(i.size.body,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold")},failureTitleCritical:{color:t.danger},failureTitleCaution:{color:t.warningStrong},emailBlock:{gap:r.sm},callBlock:{gap:r.sm},block:{gap:r.sm},statusRow:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm},confirmTitle:{...l(i.size.subtitle,i.lineHeight.snug,t.text.primary,"bold"),...headingFace(e,"bold")}})}var ug=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function hg(e){let t=ug(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}var pg=6;function gg(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=400?e:null}function fg(e,t,r){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let n=[];for(let i of e){if(n.length>=r)break;if(i===null||typeof i!="object"||Array.isArray(i))continue;let e=t(i);e!==null&&n.push(e)}/* @__PURE__ */
758
- return Object.freeze(n)}function mg(e){let t=ug(e.title,80),r=ug(e.body,600);return t===null||r===null?null:/* @__PURE__ */Object.freeze({title:t,body:r})}function bg(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,r=[];if(Array.isArray(t.gallery))for(let e of t.gallery){let t=hg(e);t!==null&&r.length<pg&&r.push(t)}let n=fg(t.doses,e=>{let t=ug(e.label,60),r=ug(e.amount,60);return t===null||r===null?null:/* @__PURE__ */Object.freeze({label:t,amount:r,minLb:gg(e.minLb??e.min_lb),maxLb:gg(e.maxLb??e.max_lb)})},pg),i=fg(t.details,mg,pg),l=t.fit,o=l!==null&&typeof l=="object"&&!Array.isArray(l)?mg(l):null,a=o!==null&&l.pet===true?/* @__PURE__ */Object.freeze({...o,pet:true}):o,s=/* @__PURE__ */Object.freeze({kicker:ug(t.kicker,80),gallery:/* @__PURE__ */Object.freeze(r),doses:n,details:i,fine:ug(t.fine,300),fit:a});return s.kicker===null&&r.length===0&&n.length===0&&i.length===0&&s.fine===null&&a===null?void 0:s}var yg=128;var vg=/* @__PURE__ */new Set(["shield","arrow","check","star","truck","refresh","card","alert","x","chat","repeat","calendar","flame","box","cart","minus","plus","chev","pulse","file","kit","dna","heart","bottle","harness","ramp"]),wg=/* @__PURE__ */new Set(["y","c","g","r"]),kg=/* @__PURE__ */new Set(["done","now","next"]),xg=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null,Tg=(e,t=1e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null,Cg=e=>typeof e=="string"&&/^[A-Za-z0-9_-]{1,40}$/.test(e)?e:null,_g=e=>typeof e=="string"&&vg.has(e)?e:null;function Rg(e){let t=Tg(e,2048);return t===null||/\s/.test(t)?null:/^https:\/\/[^/]/i.test(t)||/^\/(?![/\\])/.test(t)?t:null}var Sg=e=>typeof e=="number"&&Number.isInteger(e)?String(e):Tg(e,yg);function zg(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Ig(e){/* @__PURE__ */
759
- return Object.freeze(Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)))}function Dg(e,t,r=20){if(!Array.isArray(e))return null;let n=[];for(let i of e){if(n.length>=r)break;let e=t(i);e!==null&&n.push(e)}return n.length===0?null:/* @__PURE__ */Object.freeze(n)}var Hg=(e,t=12,r=300)=>Dg(e,e=>Tg(e,r),t);function Lg(e){let t=xg(e),r=Tg(t?.kicker,120),n=Tg(t?.title,300);if(t===null||r===null||n===null)return null;let i=xg(t.risk),l=xg(t.odds),o=xg(t.quote),a=xg(t.jump);return Ig({kicker:r,title:n,sources:Dg(t.sources,e=>{let t=Tg(xg(e)?.label,60);return t===null?null:Ig({label:t,kind:Cg(xg(e)?.kind)})},6),risk:Tg(i?.lead,300)===null?null:Ig({lead:Tg(i?.lead,300),body:Tg(i?.body),kind:Cg(i?.kind)}),odds:Tg(l?.label,120)===null||Tg(l?.from,20)===null||Tg(l?.to,20)===null?null:Ig({label:Tg(l?.label,120),tag:Tg(l?.tag,40),from:Tg(l?.from,20),to:Tg(l?.to,20),toLabel:Tg(l?.toLabel,120)}),quote:Tg(o?.text)===null?null:Ig({kicker:Tg(o?.kicker,120),tag:Tg(o?.tag,40),text:Tg(o?.text)}),jump:Tg(a?.title,300)===null||Tg(a?.go,60)===null?null:Ig({title:Tg(a?.title,300),go:Tg(a?.go,60)}),report:Pg(t.report)})}function Pg(e){let t=xg(e),r=Tg(t?.label,120),n=Tg(t?.text,1200);return r===null||n===null?null:Ig({label:r,text:n,actions:Hg(t?.actions,5,300)})}function Og(e){let t=xg(e),r=Tg(t?.title,300),n=Dg(t?.steps,e=>{let t=xg(e),r=Tg(t?.title,300),n=t?.tone;return r===null?null:Ig({title:r,body:Tg(t?.body),source:Tg(t?.source,200),tone:typeof n=="string"&&wg.has(n)?n:null,icon:_g(t?.icon),fromVet:t?.fromVet===true?true:null})});return r===null||n===null?null:Ig({title:r,label:Tg(t?.label,60),steps:n})}function $g(e){let t=xg(e),r=Tg(t?.title,300);if(t===null||r===null)return null;let n=xg(t.rating),i=xg(t.reviews),l=xg(t.why),o=xg(l?.score),a=xg(t.dose),s=xg(t.ingredients),d=Dg(i?.items,e=>{let t=xg(e),r=t?.stars,n=Tg(t?.text),i=Tg(t?.by,80);return typeof r!="number"||!Number.isFinite(r)||r<1||r>5||n===null||i===null?null:Ig({stars:Math.round(r),text:n,by:i})},5),c=Dg(l?.rows,e=>{let t=xg(e),r=Tg(t?.chip,40),n=Tg(t?.title,300);return r===null||n===null?null:Ig({chip:r,kind:Cg(t?.kind),title:n,body:Tg(t?.body)})}),u=Dg(a?.stats,e=>{let t=xg(e),r=Tg(t?.value,40),n=Tg(t?.label,120),i=t?.kind;return r===null||n===null?null:Ig({value:r,label:n,kind:i==="weight"||i==="dose"||i==="days"?i:null})},6),h=Hg(s?.items,12,80);return Ig({title:r,none:t.none===true?true:null,hidden:t.none===true&&t.hidden===true?true:null,productId:Sg(t.productId),partnerSku:Tg(t.partnerSku,200),rating:Tg(n?.value,20)===null?null:Ig({value:Tg(n?.value,20),label:Tg(n?.label,120)}),line:Tg(t.line),reviews:Tg(i?.label,200)===null||d===null?null:Ig({label:Tg(i?.label,200),items:d}),checkoutLine:Tg(t.checkoutLine,300),why:Tg(l?.title,200)===null||c===null?null:Ig({title:Tg(l?.title,200),rows:c,score:Tg(o?.text,200)===null||Tg(o?.value,20)===null?null:Ig({text:Tg(o?.text,200),value:Tg(o?.value,20)})}),dose:Tg(a?.title,200)===null||u===null?null:Ig({title:Tg(a?.title,200),stats:u,note:Tg(a?.note)}),doseLabel:Tg(t.doseLabel,120),ingredients:h===null?null:Ig({label:Tg(s?.label,200),items:h}),proof:Tg(t.proof,300),trust:Dg(t.trust,e=>{let t=xg(e),r=_g(t?.icon),n=Tg(t?.label,120);return r===null||n===null?null:Ig({icon:r,label:n})},6),more:Tg(t.more,120),fine:Tg(t.fine),checkin:Tg(t.checkin,200),detail:bg(t.detail)??null})}function Bg(e){let t=xg(e),r=Tg(t?.title,200),n=Dg(t?.items,e=>{let t=xg(e),r=Tg(t?.title,300),n=Tg(t?.body);return r===null||n===null?null:Ig({title:r,body:n,urgent:t?.urgent===true?true:null,callVet:t?.callVet===true?true:null})});return r===null||n===null?null:Ig({title:r,items:n})}function jg(e){let t=xg(e),r=Tg(t?.title,200),n=Hg(t?.questions,12,300),i=Tg(t?.add,80),l=Tg(t?.added,80);return r===null||n===null||i===null||l===null?null:Ig({title:r,questions:n,add:i,added:l})}function Ag(e){let t=xg(e),r=Tg(t?.title,200),n=Dg(t?.items,e=>{let t=xg(e),r=Tg(t?.key,yg),n=Tg(t?.title,300),i=Tg(t?.action,80),l=Sg(t?.productId),o=Tg(t?.added,80)??(l!==null?i:null);return r===null||n===null||i===null||o===null?null:Ig({key:r,productId:l,title:n,body:Tg(t?.body),price:Tg(t?.price,40),was:Tg(t?.was,40),tag:Tg(t?.tag,40),imageUrl:Rg(t?.imageUrl),icon:_g(t?.icon),kind:Cg(t?.kind),action:i,added:o,owned:t?.owned===true?true:null,detail:bg(t?.detail)??null})},6);return r===null||n===null?null:Ig({title:r,items:n})}function Eg(e){let t=xg(e),r=Tg(t?.kicker,120),n=Tg(t?.title,120);return t===null||r===null||n===null?null:Ig({kicker:r,title:n,icon:_g(t.icon),track:Dg(t.track,e=>{let t=xg(e),r=Tg(t?.title,120),n=t?.state;return r===null?null:Ig({title:r,detail:Tg(t?.detail,120),state:typeof n=="string"&&kg.has(n)?n:null,tag:Tg(t?.tag,40)})},6),heading:Tg(t.heading,200),rows:Dg(t.rows,e=>{let t=xg(e),r=_g(t?.icon),n=Tg(t?.label,120);if(r===null||n===null)return null;if(t?.fromVet===true)return Ig({icon:r,label:n,text:"",fromVet:true});let i=Tg(t?.text,300);return i===null?null:Ig({icon:r,label:n,text:i})},6),note:Tg(t.note,300),action:Tg(t.action,80)})}function healthPlanFocusDesignFromWire(e){let t=xg(e),r=Tg(t?.title,300),n=$g(t?.pick);if(t===null||r===null||n===null)return null;let i=xg(t.byline);return Ig({eyebrow:Tg(t.eyebrow,120),title:r,subtitle:Tg(t.subtitle,300),subtitleNoRecords:Tg(t.subtitleNoRecords,300),headImageUrl:Rg(t.headImageUrl),byline:Tg(i?.name,120)===null?null:Ig({name:Tg(i?.name,120),role:Tg(i?.role,120),imageUrl:Rg(i?.imageUrl),shortName:Tg(i?.shortName,60)}),focus:Lg(t.focus),routine:Og(t.routine),pick:n,signs:Bg(t.signs),checkup:jg(t.checkup),extras:Ag(t.extras),wait:Eg(t.wait),fine:Tg(t.fine),checkoutRows:Dg(t.checkoutRows,e=>{let t=xg(e),r=_g(t?.icon),n=Tg(t?.label,60),i=Tg(t?.value,200);return r===null||n===null||i===null?null:Ig({icon:r,label:n,value:i})},6)})}function healthPlanPageFromWire(e,petRef){let t=xg(e);if(t===null||!("page"in t))return null;let r=xg(t.pet),n=r?.sex;/* @__PURE__ */
760
- return Object.freeze({petRef:Tg(t.pet_ref,yg)??petRef,pet:/* @__PURE__ */Object.freeze({name:Tg(r?.name,120),species:Tg(r?.species,60),sex:n==="female"||n==="male"?n:null,breed:Tg(r?.breed,120),weightKg:zg(r?.weight_kg),weightLb:zg(r?.weight_lb)}),checkout:t.checkout==="everfur_stripe"?"everfur_stripe":"partner",page:healthPlanFocusDesignFromWire(t.page),vetReviewed:t.vet_reviewed===true,trackingTextsEnabled:t.tracking_texts_enabled===true})}function Fg(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function qg(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the expected shape`})}function Mg(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}var Ng=e=>typeof e=="string"&&e.length>0&&e.length<=yg;function Wg(petRef){return`/widget/v1/pets/${encodeURIComponent(petRef)}/plan`}async function Ug(e,petRef,t){if(!Ng(petRef))return err(Fg("petRef must be 1..128 characters"));let r=await e.send("healthPlan.page.read",{method:"GET",path:`${Wg(petRef)}/page`,...t?.signal?{signal:t.signal}:{}});if(!r.ok)return err(r.error);let n=healthPlanPageFromWire(r.value,petRef);return n===null?err(qg("healthPlan.page.read")):ok(n)}var Gg=/* @__PURE__ */new WeakMap;function Vg(e){let t=Gg.get(e);if(t!==void 0)return t;let r=Kg(e);return Gg.set(e,r),r}function Kg(e){return{getPage:(petRef,t)=>{if(e.isDisposed)return Promise.resolve(err(Mg("getPage")));let{services:r}=e.registry,n=fr(createRequestFunnel({auth:r.authFor(null),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}));return Ug(n,petRef,t)}}}var Yg=6e4;function Xg({lifecycle:e,refreshKey:t,readyAt:n,revalidate:i,refresh:l,now:a=Date.now}){let s=r({readyAt:n,revalidate:i,refresh:l??i,now:a});s.current={readyAt:n,revalidate:i,refresh:l??i,now:a},o(()=>{if(e==null)return;let t=Xr(()=>e.onForeground(()=>{let{readyAt:e,revalidate:t,now:r}=s.current;e!==null&&r()-e>=Yg&&t()}));return()=>{typeof t=="function"&&Xr(t)}},[e]);let d=r(t);o(()=>{Object.is(d.current,t)||(d.current=t,s.current.refresh())},[t])}var Qg=Yg,Jg=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanPageReads@v1");function Zg(){let e=globalThis,t=e[Jg];if(t instanceof WeakMap)return t;let r=/* @__PURE__ */new WeakMap;return e[Jg]=r,r}function ef(e,t,userRef,petRef,r){let n=Zg(),i=n.get(t);i===void 0&&(i=/* @__PURE__ */new Map,n.set(t,i));let l=i,o=`${userRef}\0${petRef}`,a=l.get(o);if(!r&&a!==void 0&&(a.at===null||Date.now()-a.at<Qg))return a.promise;let s={at:null,promise:e.getPage(petRef).then(e=>(l.get(o)===s&&(e.ok||hr(e.error)?s.at=Date.now():l.delete(o)),e))};return l.set(o,s),s.promise}function useHealthPlanPage(e){let{userRef:userRef,runtime:t}=Ir(),a=n(()=>Vg(t),[t]),s=e.repository,d=s??a,c=l((e,r)=>s!==void 0||userRef==null?d.getPage(e):ef(a,t,userRef,e,r),[s,d,a,t,userRef]),{petRef:petRef}=e,u=e.enabled!==false&&userRef!=null&&petRef!==null,[h,p]=i({phase:"idle",petRef:null,page:null,error:null}),g=r(0),f=r(0),m=l(async e=>{let t=++g.current;if(!u||petRef===null){p(e=>e.phase==="idle"&&e.petRef===null?e:{phase:"idle",petRef:null,page:null,error:null});return}p(e=>({phase:"loading",petRef:petRef,page:e.petRef===petRef?e.page:null,error:null}));let r=await c(petRef,e);t===g.current&&(r.ok?p({phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}):hr(r.error)?p({phase:"ready",petRef:petRef,page:null,error:null,missing:true,readyAt:Date.now()}):p({phase:"failed",petRef:petRef,page:null,error:r.error}))},[u,petRef,c]),b=l(()=>m(true),[m]),y=h.phase==="ready"&&h.petRef===petRef,v=l(async()=>{if(!u||petRef===null||!y)return;let e=g.current,t=++f.current,r=await c(petRef,true);e!==g.current||t!==f.current||!r.ok||p(e=>e.phase==="ready"&&e.petRef===petRef?{phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}:e)},[u,petRef,y,c]);Xg({lifecycle:e.lifecycle,refreshKey:e.refreshKey,readyAt:y?h.readyAt??null:null,revalidate:()=>{v()},refresh:()=>{y?v():b()}}),o(()=>(m(false),()=>{g.current+=1}),[m]);let w=u&&h.petRef!==petRef;return n(()=>({phase:w?"loading":h.phase,page:w?null:h.page,error:w?null:h.error,missing:!w&&h.missing===true,refresh:b}),[w,h,b])}var tf=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(tf,t)?tf[t]:null}var rf=50,nf=128,lf=120,of=120,af=2e3,sf=120,df=80,cf=/* @__PURE__ */new Set(["male","female","unknown"]),uf=/* @__PURE__ */new Set(["day","month","year"]),hf=/* @__PURE__ */new Set(["low","medium","high","athletic"]),pf=/* @__PURE__ */new Set(["indoor","outdoor","both"]),gf=/* @__PURE__ */new Set(["mild","moderate","severe"]),ff=/^(\d{4})-(\d{2})-(\d{2})$/,mf=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],bf=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...mf,...bf].map(([e])=>e));function yf(e){let t=ff.exec(e);if(t===null)return false;let[r,n,i]=[Number(t[1]),Number(t[2]),Number(t[3])],l=new Date(Date.UTC(r,n-1,i));return l.getUTCFullYear()===r&&l.getUTCMonth()===n-1&&l.getUTCDate()===i}var vf=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,wf=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,kf=(e,t)=>typeof t=="string"&&yf(t)?null:`${e} must be a real date written YYYY-MM-DD`,xf=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(cr(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let i=t.trimmed?n.trim():n;if(t.required&&i.length===0)return`${r} is required and must not be blank`;let l=ur(i);return l<=e?null:`${r} is ${l} characters; the server accepts at most ${e}`},Tf={sex:vf(cf),spayedNeutered:wf,birthDate:kf,birthDatePrecision:vf(uf),activityLevel:vf(hf),indoorOutdoor:vf(pf),foodBrand:xf(sf),foodType:xf(sf),microchipId:xf(df)},Cf=["ref","ref",false,xf(nf,{required:true,trimmed:true})],_f=["notes","notes",false,xf(af,{trimmed:true})],Rf=[Cf,["name","name",true,xf(lf,{required:true,trimmed:true})],["dose","dose",false,xf(of,{trimmed:true})],["frequency","frequency",false,xf(of,{trimmed:true})],["startDate","start_date",false,kf],["endDate","end_date",false,kf],_f],Sf={allergies:[Cf,["allergen","allergen",true,xf(lf,{required:true,trimmed:true})],["severity","severity",false,vf(gf)],_f],medications:Rf,supplements:Rf,conditions:[Cf,["conditionName","condition_name",true,xf(lf,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,kf],_f]};function zf(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let i=r,l={};for(let[t,r,o,a]of Sf[e]){let e=i[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(l[r]=null);continue}let s=a(`${n}.${t}`,e);if(s!==null)return{error:s};l[r]=e}let o=l.start_date,a=l.end_date;return typeof o=="string"&&typeof a=="string"&&a<o?{error:`${n}.endDate must not be before startDate`}:{item:l}}function If(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>rf)return{error:`${e} has ${t.length} items; the server accepts at most ${rf}`};let r=[],n=/* @__PURE__ */new Set;for(let i=0;i<t.length;i+=1){let l=zf(e,i,t[i]);if("error"in l)return l;let o=l.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(l.item)}return{items:r}}function Df(e,t){let r=e,n={};for(let[e,t]of mf){let i=r[e];if(i!==void 0){if(i!==null){let t=Tf[e](e,i);if(t!==null)return{error:t}}n[t]=i}}let i=r.birthDate!==void 0,l=r.birthDatePrecision!==void 0;if(i!==l||i&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of bf){let i=r[e];if(i===void 0)continue;let l=If(e,i);if("error"in l)return l;n[t]=l.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}var Hf=e=>typeof e=="string"?e:null,Lf=(e,t)=>typeof t=="string"&&e.has(t)?t:null,Pf=e=>typeof e=="boolean"?e:null;function Of(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function $f(e){let t=Hf(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Hf(e.ref),name:t,dose:Hf(e.dose),frequency:Hf(e.frequency),startDate:Hf(e.start_date),endDate:Hf(e.end_date),notes:Hf(e.notes)})}function Bf(e){let t=e.profile_version;/* @__PURE__ */
758
+ return Object.freeze(n)}function mg(e){let t=ug(e.title,80),r=ug(e.body,600);return t===null||r===null?null:/* @__PURE__ */Object.freeze({title:t,body:r})}function bg(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,r=[];if(Array.isArray(t.gallery))for(let e of t.gallery){let t=hg(e);t!==null&&r.length<pg&&r.push(t)}let n=fg(t.doses,e=>{let t=ug(e.label,60),r=ug(e.amount,60);return t===null||r===null?null:/* @__PURE__ */Object.freeze({label:t,amount:r,minLb:gg(e.minLb??e.min_lb),maxLb:gg(e.maxLb??e.max_lb)})},pg),i=fg(t.details,mg,pg),l=t.fit,o=l!==null&&typeof l=="object"&&!Array.isArray(l)?mg(l):null,a=o!==null&&l.pet===true?/* @__PURE__ */Object.freeze({...o,pet:true}):o,s=/* @__PURE__ */Object.freeze({kicker:ug(t.kicker,80),gallery:/* @__PURE__ */Object.freeze(r),doses:n,details:i,fine:ug(t.fine,300),fit:a});return s.kicker===null&&r.length===0&&n.length===0&&i.length===0&&s.fine===null&&a===null?void 0:s}var yg=128;var vg=/* @__PURE__ */new Set(["shield","arrow","check","star","truck","refresh","card","alert","x","chat","repeat","calendar","flame","box","cart","minus","plus","chev","pulse","file","kit","dna","heart","bottle","harness","ramp"]),wg=/* @__PURE__ */new Set(["y","c","g","r"]),kg=/* @__PURE__ */new Set(["done","now","next"]),xg=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null,Tg=(e,t=1e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null,_g=e=>typeof e=="string"&&/^[A-Za-z0-9_-]{1,40}$/.test(e)?e:null,Cg=e=>typeof e=="string"&&vg.has(e)?e:null;function Rg(e){let t=Tg(e,2048);return t===null||/\s/.test(t)?null:/^https:\/\/[^/]/i.test(t)||/^\/(?![/\\])/.test(t)?t:null}var Sg=e=>typeof e=="number"&&Number.isInteger(e)?String(e):Tg(e,yg);function zg(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Ig(e){/* @__PURE__ */
759
+ return Object.freeze(Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)))}function Dg(e,t,r=20){if(!Array.isArray(e))return null;let n=[];for(let i of e){if(n.length>=r)break;let e=t(i);e!==null&&n.push(e)}return n.length===0?null:/* @__PURE__ */Object.freeze(n)}var Hg=(e,t=12,r=300)=>Dg(e,e=>Tg(e,r),t);function Lg(e){let t=xg(e),r=Tg(t?.kicker,120),n=Tg(t?.title,300);if(t===null||r===null||n===null)return null;let i=xg(t.risk),l=xg(t.odds),o=xg(t.quote),a=xg(t.jump);return Ig({kicker:r,title:n,sources:Dg(t.sources,e=>{let t=Tg(xg(e)?.label,60);return t===null?null:Ig({label:t,kind:_g(xg(e)?.kind)})},6),risk:Tg(i?.lead,300)===null?null:Ig({lead:Tg(i?.lead,300),body:Tg(i?.body),kind:_g(i?.kind)}),odds:Tg(l?.label,120)===null||Tg(l?.from,20)===null||Tg(l?.to,20)===null?null:Ig({label:Tg(l?.label,120),tag:Tg(l?.tag,40),from:Tg(l?.from,20),to:Tg(l?.to,20),toLabel:Tg(l?.toLabel,120)}),quote:Tg(o?.text)===null?null:Ig({kicker:Tg(o?.kicker,120),tag:Tg(o?.tag,40),text:Tg(o?.text)}),jump:Tg(a?.title,300)===null||Tg(a?.go,60)===null?null:Ig({title:Tg(a?.title,300),go:Tg(a?.go,60)}),report:Pg(t.report)})}function Pg(e){let t=xg(e),r=Tg(t?.label,120),n=Tg(t?.text,1200);return r===null||n===null?null:Ig({label:r,text:n,actions:Hg(t?.actions,5,300)})}function Og(e){let t=xg(e),r=Tg(t?.title,300),n=Dg(t?.steps,e=>{let t=xg(e),r=Tg(t?.title,300),n=t?.tone;return r===null?null:Ig({title:r,body:Tg(t?.body),source:Tg(t?.source,200),tone:typeof n=="string"&&wg.has(n)?n:null,icon:Cg(t?.icon),fromVet:t?.fromVet===true?true:null})});return r===null||n===null?null:Ig({title:r,label:Tg(t?.label,60),steps:n})}function $g(e){let t=xg(e),r=Tg(t?.title,300);if(t===null||r===null)return null;let n=xg(t.rating),i=xg(t.reviews),l=xg(t.why),o=xg(l?.score),a=xg(t.dose),s=xg(t.ingredients),d=Dg(i?.items,e=>{let t=xg(e),r=t?.stars,n=Tg(t?.text),i=Tg(t?.by,80);return typeof r!="number"||!Number.isFinite(r)||r<1||r>5||n===null||i===null?null:Ig({stars:Math.round(r),text:n,by:i})},5),c=Dg(l?.rows,e=>{let t=xg(e),r=Tg(t?.chip,40),n=Tg(t?.title,300);return r===null||n===null?null:Ig({chip:r,kind:_g(t?.kind),title:n,body:Tg(t?.body)})}),u=Dg(a?.stats,e=>{let t=xg(e),r=Tg(t?.value,40),n=Tg(t?.label,120),i=t?.kind;return r===null||n===null?null:Ig({value:r,label:n,kind:i==="weight"||i==="dose"||i==="days"?i:null})},6),h=Hg(s?.items,12,80);return Ig({title:r,none:t.none===true?true:null,hidden:t.none===true&&t.hidden===true?true:null,productId:Sg(t.productId),partnerSku:Tg(t.partnerSku,200),rating:Tg(n?.value,20)===null?null:Ig({value:Tg(n?.value,20),label:Tg(n?.label,120)}),line:Tg(t.line),reviews:Tg(i?.label,200)===null||d===null?null:Ig({label:Tg(i?.label,200),items:d}),checkoutLine:Tg(t.checkoutLine,300),why:Tg(l?.title,200)===null||c===null?null:Ig({title:Tg(l?.title,200),rows:c,score:Tg(o?.text,200)===null||Tg(o?.value,20)===null?null:Ig({text:Tg(o?.text,200),value:Tg(o?.value,20)})}),dose:Tg(a?.title,200)===null||u===null?null:Ig({title:Tg(a?.title,200),stats:u,note:Tg(a?.note)}),doseLabel:Tg(t.doseLabel,120),ingredients:h===null?null:Ig({label:Tg(s?.label,200),items:h}),proof:Tg(t.proof,300),trust:Dg(t.trust,e=>{let t=xg(e),r=Cg(t?.icon),n=Tg(t?.label,120);return r===null||n===null?null:Ig({icon:r,label:n})},6),more:Tg(t.more,120),fine:Tg(t.fine),checkin:Tg(t.checkin,200),detail:bg(t.detail)??null})}function Bg(e){let t=xg(e),r=Tg(t?.title,200),n=Dg(t?.items,e=>{let t=xg(e),r=Tg(t?.title,300),n=Tg(t?.body);return r===null||n===null?null:Ig({title:r,body:n,urgent:t?.urgent===true?true:null,callVet:t?.callVet===true?true:null})});return r===null||n===null?null:Ig({title:r,items:n})}function jg(e){let t=xg(e),r=Tg(t?.title,200),n=Hg(t?.questions,12,300),i=Tg(t?.add,80),l=Tg(t?.added,80);return r===null||n===null||i===null||l===null?null:Ig({title:r,questions:n,add:i,added:l})}function Ag(e){let t=xg(e),r=Tg(t?.title,200),n=Dg(t?.items,e=>{let t=xg(e),r=Tg(t?.key,yg),n=Tg(t?.title,300),i=Tg(t?.action,80),l=Sg(t?.productId),o=Tg(t?.added,80)??(l!==null?i:null);return r===null||n===null||i===null||o===null?null:Ig({key:r,productId:l,title:n,body:Tg(t?.body),price:Tg(t?.price,40),was:Tg(t?.was,40),tag:Tg(t?.tag,40),imageUrl:Rg(t?.imageUrl),icon:Cg(t?.icon),kind:_g(t?.kind),action:i,added:o,owned:t?.owned===true?true:null,detail:bg(t?.detail)??null})},6);return r===null||n===null?null:Ig({title:r,items:n})}function Eg(e){let t=xg(e),r=Tg(t?.kicker,120),n=Tg(t?.title,120);return t===null||r===null||n===null?null:Ig({kicker:r,title:n,icon:Cg(t.icon),track:Dg(t.track,e=>{let t=xg(e),r=Tg(t?.title,120),n=t?.state;return r===null?null:Ig({title:r,detail:Tg(t?.detail,120),state:typeof n=="string"&&kg.has(n)?n:null,tag:Tg(t?.tag,40)})},6),heading:Tg(t.heading,200),rows:Dg(t.rows,e=>{let t=xg(e),r=Cg(t?.icon),n=Tg(t?.label,120);if(r===null||n===null)return null;if(t?.fromVet===true)return Ig({icon:r,label:n,text:"",fromVet:true});let i=Tg(t?.text,300);return i===null?null:Ig({icon:r,label:n,text:i})},6),note:Tg(t.note,300),action:Tg(t.action,80)})}function healthPlanFocusDesignFromWire(e){let t=xg(e),r=Tg(t?.title,300),n=$g(t?.pick);if(t===null||r===null||n===null)return null;let i=xg(t.byline);return Ig({eyebrow:Tg(t.eyebrow,120),title:r,subtitle:Tg(t.subtitle,300),subtitleNoRecords:Tg(t.subtitleNoRecords,300),headImageUrl:Rg(t.headImageUrl),byline:Tg(i?.name,120)===null?null:Ig({name:Tg(i?.name,120),role:Tg(i?.role,120),imageUrl:Rg(i?.imageUrl),shortName:Tg(i?.shortName,60)}),focus:Lg(t.focus),routine:Og(t.routine),pick:n,signs:Bg(t.signs),checkup:jg(t.checkup),extras:Ag(t.extras),wait:Eg(t.wait),fine:Tg(t.fine),checkoutRows:Dg(t.checkoutRows,e=>{let t=xg(e),r=Cg(t?.icon),n=Tg(t?.label,60),i=Tg(t?.value,200);return r===null||n===null||i===null?null:Ig({icon:r,label:n,value:i})},6)})}function healthPlanPageFromWire(e,petRef){let t=xg(e);if(t===null||!("page"in t))return null;let r=xg(t.pet),n=r?.sex;/* @__PURE__ */
760
+ return Object.freeze({petRef:Tg(t.pet_ref,yg)??petRef,pet:/* @__PURE__ */Object.freeze({name:Tg(r?.name,120),species:Tg(r?.species,60),sex:n==="female"||n==="male"?n:null,breed:Tg(r?.breed,120),weightKg:zg(r?.weight_kg),weightLb:zg(r?.weight_lb)}),checkout:t.checkout==="everfur_stripe"?"everfur_stripe":"partner",page:healthPlanFocusDesignFromWire(t.page),vetReviewed:t.vet_reviewed===true,trackingTextsEnabled:t.tracking_texts_enabled===true})}function Fg(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function qg(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the expected shape`})}function Mg(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}var Ng=e=>typeof e=="string"&&e.length>0&&e.length<=yg;function Wg(petRef){return`/widget/v1/pets/${encodeURIComponent(petRef)}/plan`}async function Ug(e,petRef,t){if(!Ng(petRef))return err(Fg("petRef must be 1..128 characters"));let r=await e.send("healthPlan.page.read",{method:"GET",path:`${Wg(petRef)}/page`,...t?.signal?{signal:t.signal}:{}});if(!r.ok)return err(r.error);let n=healthPlanPageFromWire(r.value,petRef);return n===null?err(qg("healthPlan.page.read")):ok(n)}var Gg=/* @__PURE__ */new WeakMap;function Vg(e){let t=Gg.get(e);if(t!==void 0)return t;let r=Kg(e);return Gg.set(e,r),r}function Kg(e){return{getPage:(petRef,t)=>{if(e.isDisposed)return Promise.resolve(err(Mg("getPage")));let{services:r}=e.registry,n=fr(createRequestFunnel({auth:r.authFor(null),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}));return Ug(n,petRef,t)}}}var Yg=6e4;function Xg({lifecycle:e,refreshKey:t,readyAt:n,revalidate:i,refresh:l,now:a=Date.now}){let s=r({readyAt:n,revalidate:i,refresh:l??i,now:a});s.current={readyAt:n,revalidate:i,refresh:l??i,now:a},o(()=>{if(e==null)return;let t=Xr(()=>e.onForeground(()=>{let{readyAt:e,revalidate:t,now:r}=s.current;e!==null&&r()-e>=Yg&&t()}));return()=>{typeof t=="function"&&Xr(t)}},[e]);let d=r(t);o(()=>{Object.is(d.current,t)||(d.current=t,s.current.refresh())},[t])}var Qg=Yg,Jg=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanPageReads@v1");function Zg(){let e=globalThis,t=e[Jg];if(t instanceof WeakMap)return t;let r=/* @__PURE__ */new WeakMap;return e[Jg]=r,r}function ef(e,t,userRef,petRef,r){let n=Zg(),i=n.get(t);i===void 0&&(i=/* @__PURE__ */new Map,n.set(t,i));let l=i,o=`${userRef}\0${petRef}`,a=l.get(o);if(!r&&a!==void 0&&(a.at===null||Date.now()-a.at<Qg))return a.promise;let s={at:null,promise:e.getPage(petRef).then(e=>(l.get(o)===s&&(e.ok||hr(e.error)?s.at=Date.now():l.delete(o)),e))};return l.set(o,s),s.promise}function useHealthPlanPage(e){let{userRef:userRef,runtime:t}=Ir(),a=n(()=>Vg(t),[t]),s=e.repository,d=s??a,c=l((e,r)=>s!==void 0||userRef==null?d.getPage(e):ef(a,t,userRef,e,r),[s,d,a,t,userRef]),{petRef:petRef}=e,u=e.enabled!==false&&userRef!=null&&petRef!==null,[h,p]=i({phase:"idle",petRef:null,page:null,error:null}),g=r(0),f=r(0),m=l(async e=>{let t=++g.current;if(!u||petRef===null){p(e=>e.phase==="idle"&&e.petRef===null?e:{phase:"idle",petRef:null,page:null,error:null});return}p(e=>({phase:"loading",petRef:petRef,page:e.petRef===petRef?e.page:null,error:null}));let r=await c(petRef,e);t===g.current&&(r.ok?p({phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}):hr(r.error)?p({phase:"ready",petRef:petRef,page:null,error:null,missing:true,readyAt:Date.now()}):p({phase:"failed",petRef:petRef,page:null,error:r.error}))},[u,petRef,c]),b=l(()=>m(true),[m]),y=h.phase==="ready"&&h.petRef===petRef,v=l(async()=>{if(!u||petRef===null||!y)return;let e=g.current,t=++f.current,r=await c(petRef,true);e!==g.current||t!==f.current||!r.ok||p(e=>e.phase==="ready"&&e.petRef===petRef?{phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}:e)},[u,petRef,y,c]);Xg({lifecycle:e.lifecycle,refreshKey:e.refreshKey,readyAt:y?h.readyAt??null:null,revalidate:()=>{v()},refresh:()=>{y?v():b()}}),o(()=>(m(false),()=>{g.current+=1}),[m]);let w=u&&h.petRef!==petRef;return n(()=>({phase:w?"loading":h.phase,page:w?null:h.page,error:w?null:h.error,missing:!w&&h.missing===true,refresh:b}),[w,h,b])}var tf=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(tf,t)?tf[t]:null}var rf=50,nf=128,lf=120,of=120,af=2e3,sf=120,df=80,cf=/* @__PURE__ */new Set(["male","female","unknown"]),uf=/* @__PURE__ */new Set(["day","month","year"]),hf=/* @__PURE__ */new Set(["low","medium","high","athletic"]),pf=/* @__PURE__ */new Set(["indoor","outdoor","both"]),gf=/* @__PURE__ */new Set(["mild","moderate","severe"]),ff=/^(\d{4})-(\d{2})-(\d{2})$/,mf=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],bf=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...mf,...bf].map(([e])=>e));function yf(e){let t=ff.exec(e);if(t===null)return false;let[r,n,i]=[Number(t[1]),Number(t[2]),Number(t[3])],l=new Date(Date.UTC(r,n-1,i));return l.getUTCFullYear()===r&&l.getUTCMonth()===n-1&&l.getUTCDate()===i}var vf=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,wf=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,kf=(e,t)=>typeof t=="string"&&yf(t)?null:`${e} must be a real date written YYYY-MM-DD`,xf=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(cr(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let i=t.trimmed?n.trim():n;if(t.required&&i.length===0)return`${r} is required and must not be blank`;let l=ur(i);return l<=e?null:`${r} is ${l} characters; the server accepts at most ${e}`},Tf={sex:vf(cf),spayedNeutered:wf,birthDate:kf,birthDatePrecision:vf(uf),activityLevel:vf(hf),indoorOutdoor:vf(pf),foodBrand:xf(sf),foodType:xf(sf),microchipId:xf(df)},_f=["ref","ref",false,xf(nf,{required:true,trimmed:true})],Cf=["notes","notes",false,xf(af,{trimmed:true})],Rf=[_f,["name","name",true,xf(lf,{required:true,trimmed:true})],["dose","dose",false,xf(of,{trimmed:true})],["frequency","frequency",false,xf(of,{trimmed:true})],["startDate","start_date",false,kf],["endDate","end_date",false,kf],Cf],Sf={allergies:[_f,["allergen","allergen",true,xf(lf,{required:true,trimmed:true})],["severity","severity",false,vf(gf)],Cf],medications:Rf,supplements:Rf,conditions:[_f,["conditionName","condition_name",true,xf(lf,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,kf],Cf]};function zf(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let i=r,l={};for(let[t,r,o,a]of Sf[e]){let e=i[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(l[r]=null);continue}let s=a(`${n}.${t}`,e);if(s!==null)return{error:s};l[r]=e}let o=l.start_date,a=l.end_date;return typeof o=="string"&&typeof a=="string"&&a<o?{error:`${n}.endDate must not be before startDate`}:{item:l}}function If(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>rf)return{error:`${e} has ${t.length} items; the server accepts at most ${rf}`};let r=[],n=/* @__PURE__ */new Set;for(let i=0;i<t.length;i+=1){let l=zf(e,i,t[i]);if("error"in l)return l;let o=l.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(l.item)}return{items:r}}function Df(e,t){let r=e,n={};for(let[e,t]of mf){let i=r[e];if(i!==void 0){if(i!==null){let t=Tf[e](e,i);if(t!==null)return{error:t}}n[t]=i}}let i=r.birthDate!==void 0,l=r.birthDatePrecision!==void 0;if(i!==l||i&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of bf){let i=r[e];if(i===void 0)continue;let l=If(e,i);if("error"in l)return l;n[t]=l.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}var Hf=e=>typeof e=="string"?e:null,Lf=(e,t)=>typeof t=="string"&&e.has(t)?t:null,Pf=e=>typeof e=="boolean"?e:null;function Of(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function $f(e){let t=Hf(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Hf(e.ref),name:t,dose:Hf(e.dose),frequency:Hf(e.frequency),startDate:Hf(e.start_date),endDate:Hf(e.end_date),notes:Hf(e.notes)})}function Bf(e){let t=e.profile_version;/* @__PURE__ */
761
761
  return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:Lf(cf,e.sex),spayedNeutered:Pf(e.spayed_neutered),birthDate:Hf(e.birth_date),birthDatePrecision:Lf(uf,e.birth_date_precision),activityLevel:Lf(hf,e.activity_level),indoorOutdoor:Lf(pf,e.indoor_outdoor),foodBrand:Hf(e.food_brand),foodType:Hf(e.food_type),microchipId:Hf(e.microchip_id),allergies:Of(e.allergies,e=>{let t=Hf(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Hf(e.ref),allergen:t,severity:Lf(gf,e.severity),notes:Hf(e.notes)})}),medications:Of(e.medications,$f),supplements:Of(e.supplements,$f),conditions:Of(e.conditions,e=>{let t=Hf(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Hf(e.ref),conditionName:t,diagnosedDate:Hf(e.diagnosed_date),notes:Hf(e.notes)})})})}var jf=100,Af=50,Ef=100,Ff=50,qf=500,Mf=128,Nf=6e4;function Wf(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Uf(e,t,r){if(typeof t!="string")return Wf(`${e} must be a string`);let n=ur(t);return n<=r?null:Wf(`${e} is ${n} characters; the server accepts at most ${r}`)}function Gf(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:Wf(`${e} must be a finite number between 0 and ${r}`)}function Vf(petRef,e){if(typeof petRef!="string")return Wf("pet_ref must be a string");if(petRef.trim().length===0)return Wf("pet_ref must not be blank");if(cr(petRef))return Wf("pet_ref contains an unpaired surrogate and cannot be encoded");if(e!=null&&typeof e!="object")return Wf("profile must be an object");let t=[Uf("pet_ref",petRef,Mf)];return e?.name!==void 0&&t.push(Uf("name",e.name,jf)),e?.species!==void 0&&t.push(Uf("species",e.species,Af)),e?.breed!==void 0&&t.push(Uf("breed",e.breed,Ef)),e?.ageYears!==void 0&&t.push(Gf("age_years",e.ageYears,Ff)),e?.weightKg!==void 0&&t.push(Gf("weight_kg",e.weightKg,qf)),t.find(e=>e!==null)??null}function Kf(e,t){let r=Df(e,t);return"error"in r?{error:Wf(r.error)}:r}function Yf(e){if(typeof e!="object"||e===null)return{error:Wf("patch must be an object")};let t=e,r=[["name","name",e=>Uf("name",e,jf)],["species","species",e=>Uf("species",e,Af)],["breed","breed",e=>Uf("breed",e,Ef)],["ageYears","age_years",e=>Gf("age_years",e,Ff)],["weightKg","weight_kg",e=>Gf("weight_kg",e,qf)]],n={};for(let[e,i,l]of r){let r=t[e];if(r!==void 0){if(r!==null){let e=l(r);if(e!==null)return{error:e}}n[i]=r}}let i=Kf(t,t.species);return"error"in i?i:(Object.assign(n,i.body),Object.keys(n).length===0?{error:Wf("patch must change at least one field")}:{body:n})}function Xf(e){if(e==null)return{body:{}};let t=Kf(e,e.species);return"error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}var Qf=e=>typeof e=="string"?e:null,Jf=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function Zf(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
762
762
  return Object.freeze({petRef:Qf(t.pet_ref)??petRef,name:Qf(t.name),species:Qf(t.species),breed:Qf(t.breed),ageYears:Jf(t.age_years),weightKg:Jf(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=Qf(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:Qf(t.pet_id),petRef:petRef,name:Qf(t.name),species:Qf(t.species),breed:Qf(t.breed),ageYears:Jf(t.age_years),weightKg:Jf(t.weight_kg),updatedAt:Qf(t.updated_at)})}function em(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...Bf(e)})}function tm(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];/* @__PURE__ */
763
763
  return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return rm(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:Nf}))}function rm(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>Vf(petRef,void 0)??`/widget/v1/pets/${encodeURIComponent(petRef)}`;return{async list(t){let n=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},t?.signal));return n.ok?ok(tm(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=Vf(petRef,t);if(n!==null)return err(n);let i=Xf(t);if("error"in i)return err(i.error);let l={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(petRef)}`,body:i.body},o=await e.send("pets.registerPet",r?.signal?{...l,signal:r.signal}:l);return o.ok?ok(Zf(o.value,petRef)):err(o.error)},async updatePet(petRef,t,i){let l=n(petRef);if(typeof l!="string")return err(l);let o=Yf(t);if("error"in o)return err(o.error);let a=await e.send("pets.updatePet",r({method:"PATCH",path:l,body:o.body},i?.signal));return a.ok?ok(Zf(a.value,petRef)):err(a.error)},async getPetProfile(petRef,t){let i=n(petRef);if(typeof i!="string")return err(i);let l=await e.send("pets.getPetProfile",r({method:"GET",path:`${i}/profile`},t?.signal));if(!l.ok)return err(l.error);let o=em(l.value);return o===null?err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):ok(o)},async deletePet(petRef,t){let i=n(petRef);if(typeof i!="string")return err(i);let l=await e.send("pets.deletePet",r({method:"DELETE",path:i},t?.signal));return l.ok?ok(void 0):err(l.error)},async eraseUserData(e){let n=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},e?.signal),{maxAttempts:1});return n.ok?ok(void 0):err(n.error)}}}var nm=/* @__PURE__ */new WeakMap;function im(e,t){let r=nm.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,nm.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:e,userRef:userRef,activePet:t,scopeEpoch:a}=Ir(),s=n(()=>createPetsRepository(e.registry.services.authFor(userRef)),[e,userRef,a]),[d,c]=i({repository:s,pets:[],loading:true,error:null}),u=d.repository===s?d:{pets:[],loading:true,error:null},h=r(0),p=l(async()=>{let e=++h.current;c(e=>({...e,repository:s,loading:true,error:null,pets:e.repository===s?e.pets:[]}));let t=await s.list();e===h.current&&c(t.ok?{repository:s,pets:t.value,loading:false,error:null}:e=>({repository:s,pets:e.repository===s?e.pets:[],loading:false,error:t.error}))},[s]);o(()=>(p(),()=>{h.current+=1}),[p]),o(()=>im(e,()=>{p()}),[e,p]);let g=n(()=>t===null?null:u.pets.find(e=>e.petRef===t)??null,[t,u.pets]);return n(()=>({pets:u.pets,activePet:g,loading:u.loading,error:u.error,refresh:p}),[u.pets,u.loading,u.error,g,p])}var lm=()=>()=>{},om=()=>null;function am(e,t){return d(t?.subscribe??lm,t?.get??om,t?.get??om)??e}var sm=/* @__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,serverSlots:false}),dm=/* @__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",serverSlots:"server_slots"}),cm=Object.keys(dm),um="presentation",hm="presentation.";var pm={chatAnswerStyle:["bubbles","cards"],chatHistoryStyle:["drawer","sheet"],chatTopCard:["none","focus"],safetyDisclaimerPlacement:["composer","answer_footer","none"],healthPlanLayout:["standard","focus_plan"],chatComposerStyle:["standard","compact"],chatComposerPlaceholder:["generic","pet_name"],chatHistoryBar:["pinned","scroll"],chatSendButton:["always_dark","dim_when_empty"]},gm=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner","chatTextingAsk","serverSlots"]);function fm(e,t){if(t==null)return;let r=pm[e];return r!==void 0?typeof t=="string"&&r.includes(t)?t:void 0:gm.has(e)?typeof t=="boolean"?t:void 0:typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=3?t:void 0}function parsePresentation(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let e of cm){let n=dm[e],i=Object.prototype.hasOwnProperty.call(t,n)?t[n]:t[e],l=fm(e,i);l!==void 0&&(r[e]=l)}return Object.keys(r).length===0?null:/* @__PURE__ */Object.freeze(r)}function isPresentationFieldLocked(e,t){if(t==null)return false;let r=`${hm}${dm[e]}`;for(let e of t)if(e===um||e===r)return true;return false}function resolvePresentation(e){let t=parsePresentation(e?.server??null)??{},{safetyDisclaimerPlacement:r,...n}=t,i=r==="none"||r===void 0?n:{...n,safetyDisclaimerPlacement:r},l=parsePresentation(e?.client??null)??{},o=e?.locked?[...e.locked]:null,a={};for(let e of cm){let t=i[e],r=isPresentationFieldLocked(e,o)?void 0:l[e];a[e]=r??t??sm[e]}/* @__PURE__ */
764
- return Object.freeze(a)}var mm=/* @__PURE__ */Object.freeze({branding:null}),bm=/* @__PURE__ */Object.freeze({subscribe:()=>()=>{},getSnapshot:()=>mm});function ym(e){return e?Object.keys(e).sort().map(t=>`${t}=${String(e[t])}`).join("&"):""}function useEverfurPresentation(e){return vm(e).presentation}function vm(e){let{runtime:t}=Ir(),r=t?.entitlements??bm,i=l(()=>r.getSnapshot()?.branding??null,[r]),o=am(d(r.subscribe,i,i),t?.sdkConfigHost?.branding),a=ym(e);return n(()=>{let t=o?.lockedFields??null;return{presentation:resolvePresentation({server:o?.presentation??null,locked:t,client:e??null}),isLocked:e=>isPresentationFieldLocked(e,t)}},[o,a])}var wm=3600*1e3;function km(e,t=true){let[n,l]=i(()=>e??Date.now()),a=r(true);return o(()=>{if(a.current){a.current=false;return}e===void 0&&t&&l(Date.now())},[e,t]),o(()=>{if(e!==void 0||!t)return;let r=setInterval(()=>l(Date.now()),wm),n=()=>{document.visibilityState==="visible"&&l(Date.now())},i=typeof document<"u"&&typeof document.addEventListener=="function"?document:null;return i?.addEventListener("visibilitychange",n),()=>{clearInterval(r),i?.removeEventListener("visibilitychange",n)}},[e,t]),e??n}var xm=e=>e.charAt(0).toUpperCase()+e.slice(1);function Tm(e,t){let r=e.trim(),n=r.length>0?r:Xn,i=xm(n);return t==="her"?{name:n,Name:i,poss:"her",Poss:"Her",subj:"she"}:t==="his"?{name:n,Name:i,poss:"his",Poss:"His",subj:"he"}:{name:n,Name:i,poss:`${n}'s`,Poss:`${i}'s`,subj:n}}var Cm=/* @__PURE__ */Object.freeze({vitalsFrom:(e,t,r)=>`Vitals from ${e.poss} ${t}, ${r}`,vitalsSource:e=>`Where ${e.name}'s vitals come from`,temperature:"Temperature",heartRate:"Heart rate",breathing:"Breathing",upcomingCare:"Upcoming care",overdueBy:e=>`Overdue · due by ${e}`,dueSoon:"Due soon",later:"Later",noDate:"No date",dueIn:(e,t)=>`Due ${e} · in ${t} ${t===1?"day":"days"}`,dueToday:e=>`Due ${e} · today`,overdueByDays:(e,t)=>`Overdue by ${t} ${t===1?"day":"days"} · due ${e}`,recordsHistory:"Records & history",labs:"Labs & bloodwork",results:"results",screenings:"Screenings",screeningsClear:"All clear",screeningsToReview:e=>`${e} to review`,noScreenings:"No screenings yet",visits:"Visits & records",timeline:"Timeline",events:e=>`${e} ${e===1?"event":"events"}`,weight:"Weight",vetVisits:e=>`${e} vet ${e===1?"visit":"visits"}`,history:"History",theirClinic:e=>`${e.Poss} clinic`,bloodPanel:"Blood panel",aboveRange:"above range",belowRange:"below range",othersInRange:"Other values in range.",addRecords:e=>`Add ${e.name}'s records`,moreThanOneClinic:"Records can come from more than one clinic over a lifetime.",visitsCount:e=>`${e} ${e===1?"visit":"visits"}`,panelsCount:e=>`${e} blood ${e===1?"panel":"panels"}`,requestFromClinic:"Request from a clinic",uploadDocument:"Upload a document",onFileNow:"On file now",firstRecord:e=>`Add ${e.name}'s first record`,firstLead:e=>`Records can come from more than one clinic over a lifetime. Start with the one ${e.subj} sees most, and this page fills in from there.`,requestFromTheirClinic:e=>`Request from ${e.poss} clinic`,requestDetail:"We send a secure request and read every page they send back.",uploadDetail:"A PDF, or a photo of a paper record.",findClinic:e=>`Find ${e.name}'s clinic`,chooseFile:"Choose a file",sayBeats:/* @__PURE__ */Object.freeze(["Hmmm","I wonder","what I may be","hiding"]),sayStill:"I wonder what I may be hiding",sample:"Sample",peekLead:e=>`A sneak peek at how ${e.name}'s records will read. Every number links back to the page it came from.`,sampleNote:e=>`Sample data until ${e.poss} records arrive.`,onTheWay:e=>`${e.Name}'s records are on the way`,clinicsTake:"Clinics usually take 2 to 5 days.",anotherClinic:"Another clinic",anotherClinicDetail:"Seen more than one vet? We ask each one.",noDueDate:"No due date on file",noLabs:e=>`No lab results on file for ${e.name} yet. They show up here when a record includes a blood or urine panel.`,noVisits:e=>`No visits in ${e.name}'s records yet. They show up here when a record includes one.`,oneReading:"One reading so far: we'll plot a trend as more come in.",takingNow:"Taking now",noCurrentMeds:"No current medications on file.",noVetTitle:e=>`When ${e.name} has a vet, start here.`,requestedFrom:e=>`Requested from ${e}. Clinics usually take 2 to 5 days.`,onTheWayFrom:(e,t)=>`${e.Name}'s records from ${t} are on the way.`,readingUpload:"We're reading the document you uploaded.",seeWhereItStands:"See where it stands",topRisk:e=>`${e.Poss} top risk`,seePlan:e=>`See ${e.poss} Health Plan`,panelOn:e=>`${e} blood panel`,latestReading:"Latest reading",rangeLine:(e,t,r)=>`range ${e} to ${t}${r?` ${r}`:""}`,noRange:"No range on the report",above:"Above",inRange:"In range",below:"Below",high:"High",belowRangePill:"Below range",changeUp:(e,t)=>`Up ${e}${t?` ${t}`:""}`,changeDown:(e,t)=>`Down ${e}${t?` ${t}`:""}`,changeSince:(e,t)=>` since ${e}, about ${t}%.`,whatIs:e=>`What ${e} is`,otherValues:e=>`Other ${e} values`,panelTitle:(e,t)=>`${e} · ${t}`,askAboutThis:"Ask about this"});var _m=864e5,Rm=30,Sm=2.20462,zm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Im(e){if(e==null||e.length===0)return null;let t=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:e);return Number.isNaN(t)?null:t}function Dm(e){let t=new Date(e);return`${zm[t.getUTCMonth()]??""} ${t.getUTCDate()}`}function Hm(e){return`${Dm(e)}, ${new Date(e).getUTCFullYear()}`}function Lm(e){let t=new Date(e);return`${t.getUTCMonth()+1}/${String(t.getUTCFullYear()%100).padStart(2,"0")}`}var Pm=e=>new Date(e).toISOString().slice(0,10);function Om(e){return String(Math.round(e*100)/100)}var $m=e=>Math.round(e*Sm*10)/10;function Bm(e){let t=e.trim();return t.length<2||t[1]===t[1]?.toUpperCase()?t:t.charAt(0).toLowerCase()+t.slice(1)}function jm(e){return/temp/i.test(e)?"temp":/heart|pulse/i.test(e)?"heart":/resp|breath/i.test(e)?"breath":null}var Am=["temp","heart","breath"],Em={temp:Cm.temperature,heart:Cm.heartRate,breath:Cm.breathing};function Fm(e){if(e===null||e.withheld)return{vitals:[],observedMs:null};let t=/* @__PURE__ */new Map;for(let r of e.entities){if(r.category!=="vital"||r.value===null||r.value.trim().length===0)continue;let e=jm(`${r.canonicalKey??""} ${r.key} ${r.label}`);if(e===null)continue;let n=Im(r.observedAt)??0,i=t.get(e);(i===void 0||n>i.ms)&&t.set(e,{value:r.value.trim(),unit:r.unit,ms:n})}let r=Am.flatMap(e=>{let r=t.get(e);return r===void 0?[]:[{kind:e,value:r.value,unit:r.unit,label:Em[e]}]}),n=[...t.values()].map(e=>e.ms).filter(e=>e>0);return{vitals:r,observedMs:n.length>0?Math.max(...n):null}}function qm(e,t){let r=Pm(t);return e.find(e=>{let t=Im(e.date);return t!==null&&Pm(t)===r})??null}function Mm(e){return/vaccin|rabies|dhpp|booster|bordetella|lepto|lyme|parvo|distemper/i.test(e)?"efi-shield":/\b(alt|alp|lab|labs|blood|panel|bloodwork|urinalysis|chemistry|cbc)\b/i.test(e)?"efi-flask-sm":"efi-calendar"}function Nm(e,t){return e.map(e=>{let r=Im(e.dueAt),n=Mm(e.title);if(r!==null&&r<t-_m+1)return{item:e,title:e.title,when:Cm.overdueBy(Dm(r)),tone:"alert",pill:null,icon:n};let i=e.detail??(r===null?Cm.noDueDate:Hm(r));if(r===null)return{item:e,title:e.title,when:i,tone:"none",pill:null,icon:n};let l=r-t<=Rm*_m;return{item:e,title:e.title,when:i,tone:l?"watch":"later",pill:l?Cm.dueSoon:Cm.later,icon:n}})}function Wm(e){return e==null?null:/above|high/i.test(e)?"above":/below|low/i.test(e)?"below":/in_range|normal|in range/i.test(e)?"in":null}var Um=e=>Math.round(e*10)/10;function Gm(e,t){let r=`${Om($m(e))} lb`,n=`${Om(Um(e))} kg`;return t==="kg"?{main:n,other:r}:{main:r,other:n}}function Vm(e,t){if(e===null||e.withheld)return null;let r=e.weights.flatMap(e=>{let t=Im(e.observedOn);return t===null||e.weightKg===null?[]:[{ms:t,kg:e.weightKg}]}).sort((e,t)=>e.ms-t.ms),n=r[r.length-1];if(n===void 0)return null;let i=r.map(e=>$m(e.kg)),l=Math.min(...i),o=Math.max(...i),a=r[0]?.ms??n.ms,s=n.ms-a,d=r.map((e,r)=>({x:s>0?Math.round((3.55+93.45*(e.ms-a)/s)*100)/100:50,y:o>l?Math.round((75-50*((i[r]??l)-l)/(o-l))*10)/10:50,lb:i[r]??0,value:t==="kg"?Um(e.kg):i[r]??0,ms:e.ms})),c=d.length<=4?d:[d[0],d[d.length-1]].filter(e=>e!==void 0),u=Gm(n.kg,t);return{latest:u.main,sub:`${u.other} · ${Dm(n.ms)}`,single:d.length===1,points:d,ticks:c.map(e=>({x:e.x,label:Lm(e.ms)})),vetCount:d.length}}function Km(e){let t=/* @__PURE__ */new Map;if(e===null||e.withheld)return t;for(let r of e.markers)for(let e of r.points){let n=Im(e.at);if(n===null)continue;let i=Pm(n),l=t.get(i)??{ms:n,flagged:[],total:0,inRange:0,clinics:/* @__PURE__ */new Set};l.total+=1;let o=Wm(e.status);o==="in"&&(l.inRange+=1),(o==="above"||o==="below")&&l.flagged.push({marker:r,point:e,ms:n,flag:o}),e.sourceClinic&&l.clinics.add(e.sourceClinic),t.set(i,l)}return t}function Ym(e,t){let r=[];for(let[e,n]of t)n.flagged.forEach((t,i)=>{let l=t.point.value===null?t.point.qualitativeResult??"":Om(t.point.value),o=t.point.unit??t.marker.unit,a=n.flagged.length===1&&n.inRange===n.total-1&&n.total>1;r.push({key:`lab-${e}-${t.marker.markerId}-${i}`,ms:n.ms,date:`${Dm(n.ms)} · ${Cm.bloodPanel}`,title:`${t.marker.name} ${l}${o?` ${o}`:""}, ${t.flag==="above"?Cm.aboveRange:Cm.belowRange}`,text:a?Cm.othersInRange:null,alert:true,markerId:t.marker.markerId,order:0})});let n=e.depth?.withheld===false?e.depth.encounters:[],i=e.timeline?.withheld===false?e.timeline.visits:[],l=/* @__PURE__ */new Set;n.forEach((e,t)=>{let n=Im(e.date);if(n===null)return;let o=i.find(t=>e.docId!==null&&t.docId===e.docId||Im(t.visitDate)!==null&&Pm(Im(t.visitDate)??0)===Pm(n))??null;o!==null&&l.add(o.visitId);let a=o?.summary?.trim()||null,s=e.type?.trim()||null,d=a??s;d!==null&&r.push({key:`enc-${e.encounterId}-${t}`,ms:n,date:a!==null&&s!==null?`${Dm(n)} · ${s}`:Dm(n),title:d,text:null,alert:false,markerId:null,order:1})});for(let e of i){let t=Im(e.visitDate),n=e.summary?.trim()||null;l.has(e.visitId)||t===null||n===null||r.push({key:`visit-${e.visitId}`,ms:t,date:Dm(t),title:n,text:null,alert:false,markerId:null,order:1})}r.sort((e,t)=>t.ms-e.ms||e.order-t.order);let o=[];for(let e of r){let t={key:e.key,ms:e.ms,date:e.date,title:e.title,text:e.text,alert:e.alert,markerId:e.markerId},r=String(new Date(t.ms).getUTCFullYear()),n=o[o.length-1];n!==void 0&&n.year===r?n.items.push(t):o.push({year:r,items:[t]})}return{years:o,count:r.length}}function Xm(e,t){let r=e.depth?.withheld===false?e.depth.encounters:[],n=t=>t?.trim()||Cm.theirClinic(e.words),i=/* @__PURE__ */new Map;for(let e of r)i.set(n(e.clinicName),(i.get(n(e.clinicName))??0)+1);let l=/* @__PURE__ */new Map,o=i.size===1?[...i.keys()][0]:void 0;for(let r of t.values()){let t=r.clinics.size>0?[...r.clinics].map(n):[o??Cm.theirClinic(e.words)];for(let e of t)l.set(e,(l.get(e)??0)+1)}return[.../* @__PURE__ */new Set([...i.keys(),...l.keys()])].map(e=>({label:e,detail:[(i.get(e)??0)>0?Cm.visitsCount(i.get(e)??0):null,(l.get(e)??0)>0?Cm.panelsCount(l.get(e)??0):null].filter(e=>e!==null).join(" · ")}))}var Qm={requested:15,awaiting_clinic:35,awaiting_upload:35,received:60,parsing:75,in_review:90};function Jm(e){let t=e.filter(e=>!isTerminalStatus(e.status)).sort((e,t)=>(Im(t.updatedAt)??0)-(Im(e.updatedAt)??0))[0];if(t===void 0)return null;let r=(t.waitingExpectation?.trim()||t.statusLabel).trim();return r.length===0?null:{step:r,pct:Qm[t.status]??15}}var Zm=e=>[...e].sort((e,t)=>(Im(t.updatedAt)??0)-(Im(e.updatedAt)??0)),eb=e=>/[.!?]$/.test(e)?e:`${e}.`;function tb(e,t){let r=Zm(t).filter(e=>!isTerminalStatus(e.status)),n=r.filter(e=>e.status==="awaiting_upload"),i=r.filter(e=>e.status!=="awaiting_upload"),l=[],o=/* @__PURE__ */new Map;for(let e of i){let t=e.clinicName?.trim()??"";e.source!=="clinic_request"||t===""||o.has(t)||o.set(t,e)}for(let[t,r]of o)l.push({key:`clinic-${t}`,text:Cm.onTheWayFrom(e,t),requestId:r.id});let a=i.find(e=>e.source==="owner_provided");a!==void 0&&l.push({key:"upload",text:Cm.readingUpload,requestId:a.id});let s=n[0],d=s?.statusLabel.trim()??"";return s!==void 0&&d!==""&&l.push({key:"awaiting-upload",text:eb(d),requestId:s.id}),l}function rb(e){return Zm(e).find(e=>!isTerminalStatus(e.status)&&e.status!=="awaiting_upload"&&e.source==="clinic_request"&&(e.clinicName?.trim()??"")!=="")?.clinicName?.trim()??null}function nb(e){if(e===null||e.withheld)return null;let t=e.medications.filter(e=>(e.drugName?.trim()??"")!=="");return t.length===0?null:{current:t.filter(e=>(e.stoppedOn?.trim()??"")==="").map(e=>{let t=[e.dose,e.frequency,e.route].map(e=>e?.trim()??"").filter(e=>e!==""),r=e.sig?.trim()||(t.length>0?t.join(" · "):null);return{key:e.medicationId,name:(e.drugName??"").trim(),detail:r}})}}function ib(e){if(e.some(e=>!isTerminalStatus(e.status)))return null;let t=[...e].sort((e,t)=>(Im(t.updatedAt)??0)-(Im(e.updatedAt)??0))[0];if(t===void 0||t.status!=="failed")return null;let r=t.statusLabel.trim();return r.length>0?r:null}function lb(e,t,r){return e!==null&&!e.withheld&&!e.isEmpty||t!==null&&!t.withheld&&t.markers.length>0?true:r!==null&&!r.withheld&&r.encounters.length>0}function ob(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return null;let t=Math.floor(e*12+1e-9),r=Math.floor(t/12),n=t%12;return r<=0?`${n}M`:n>0?`${r}Y ${n}M`:`${r}Y`}function ab(e){let{record:t,depth:r,markers:n,nowMs:i}=e,l=lb(t,n,r),o=Jm(e.requests),a=Km(n),{vitals:s,observedMs:d}=Fm(t),c=r?.withheld===false?r.encounters:[],u=d===null?null:qm(c,d),h=d!==null&&u?.type?Cm.vitalsFrom(e.words,Bm(u.type),Dm(d)):null,p=e.weightUnit??"lb",g=Vm(e.timeline,p),f=g!==null?null:e.petWeightKg,m=[e.breed?.trim()||null,ob(e.petAgeYears),g?.latest??(f!==null?Gm(f,p).main:null)].filter(e=>e!==null),b=e.timeline?.withheld===false?e.timeline.visits.length:0,y=Ym(e,a),v=c.map(e=>Im(e.date)).filter(e=>e!==null),w=n?.withheld===false?n.markers:[],k=n?.featuredMarkerId??w.find(e=>Wm(e.latest?.status)==="above"||Wm(e.latest?.status)==="below")?.markerId??w[0]?.markerId??null;return{state:l?"full":o!==null?"onTheWay":"none",meta:m.length>0?m.join(" · "):null,vitals:s,vitalsFrom:h,due:t!==null&&!t.withheld?Nm(t.forwardLooking,i):[],labsCount:n?.withheld===false?n.summary?.totalMarkers??n.markers.length:0,featuredMarkerId:k,latestVisit:v.length>0?Hm(Math.max(...v)):null,weight:g,history:y.years,historyCount:y.count,sources:Xm(e,a),pull:o,hasVisits:c.length>0||b>0,medications:nb(e.timeline),failedRequest:o===null?ib(e.requests):null,inFlight:tb(e.words,e.requests),requestedClinic:rb(e.requests)}}function sb(e){let t=e.points.filter(e=>e.value!==null);return t[t.length-1]??e.points[e.points.length-1]??null}function db(e){return e===null||e.refLow===null||e.refHigh===null||!Number.isFinite(e.refLow)||!Number.isFinite(e.refHigh)||e.refHigh<=e.refLow?null:{low:e.refLow,high:e.refHigh}}function cb(e,t=sb(e)){let r=db(t),n=t?.unit??e.unit,i=t?.value??null;return{markerId:e.markerId,name:e.name,value:i===null?t?.qualitativeResult??"":Om(i),unit:n,range:r===null?null:`${Om(r.low)} to ${Om(r.high)}${n?` ${n}`:""}`,at:r===null||i===null?null:Math.round(Math.min(100,Math.max(0,20+60*(i-r.low)/(r.high-r.low)))),flag:Wm(t?.status??e.latest?.status??null)}}function ub(e){return e==="above"?Cm.high:e==="below"?Cm.belowRangePill:e==="in"?Cm.inRange:null}var hb=e=>{let t=e.replace(/\s+panel$/i,"").trim()||e;return t.length>1&&t[1]===t[1]?.toUpperCase()?t:t.charAt(0).toLowerCase()+t.slice(1)};function pb(e,t){let r=e.markers.find(e=>e.markerId===t);if(r===void 0)return null;let n=sb(r),i=cb(r,n),l=Im(n?.at??r.latest?.at??null),o=db(n),a=[l===null?null:Dm(l),o===null?Cm.noRange:Cm.rangeLine(Om(o.low),Om(o.high),i.unit)].filter(e=>e!==null).join(" · "),s=r.points.flatMap(e=>{let t=Im(e.at);return e.value===null||t===null?[]:[{p:e,ms:t,v:e.value}]}),d=[];if(s.length>0){let e=s.map(e=>e.v),t=o?.low??Math.min(...e),r=o?.high??Math.max(...e);d=s.map((e,n)=>({x:s.length===1?50:Math.round((18+64*n/(s.length-1))*100)/100,y:r>t?Math.min(98,Math.max(2,Math.round((75-50*(e.v-t)/(r-t))*10)/10)):50,label:Om(e.v),out:Wm(e.p.status)==="above"||Wm(e.p.status)==="below",tick:Dm(e.ms)}))}let c=s[0],u=s[s.length-1],h=null;if(c!==void 0&&u!==void 0&&s.length>=2&&u.v!==c.v){let e=Math.abs(u.v-c.v),t=c.v!==0?Math.round(e/Math.abs(c.v)*100):null,r=u.v>c.v?Cm.changeUp(Om(e),i.unit):Cm.changeDown(Om(e),i.unit);h=t===null?null:{lead:r,rest:Cm.changeSince(Dm(c.ms),t)}}let p=[],g=l===null?null:Pm(l),f=e.markers.filter(e=>e.markerId!==r.markerId),m=f.filter(e=>e.panel!==null&&e.panel===r.panel);if(m.length>0&&r.panel!==null){let e=m.map(e=>cb(e));p.push({title:Cm.otherValues(hb(r.panel)),allInRange:e.every(e=>e.flag==="in"),rows:e})}if(g!==null&&l!==null){let e=/* @__PURE__ */new Map;for(let t of f){if(t.panel===null||t.panel===r.panel)continue;let n=[...t.points].reverse().find(e=>{let t=Im(e.at);return t!==null&&Pm(t)===g});n!==void 0&&e.set(t.panel,[...e.get(t.panel)??[],cb(t,n)])}for(let[t,r]of e)p.push({title:Cm.panelTitle(t,Dm(l)),allInRange:r.every(e=>e.flag==="in"),rows:r})}return{markerId:r.markerId,name:r.name,meta:l===null?null:Cm.panelOn(Hm(l)),pill:ub(i.flag),flagged:i.flag==="above"||i.flag==="below",latest:`${i.value}${i.unit?` ${i.unit}`:""}`,latestSub:a,hasRange:o!==null,chart:d,change:h,meaning:(r.meaning??"").split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e.length>0),groups:p}}var gb=/* @__PURE__ */Object.freeze({vitalsFromLabel:e=>`Where ${e}’s vitals come from`,vitalsFrom:(e,t)=>`From ${e}’s exam, ${t}. `,examNotes:"Exam notes",onTheWayFrom:(e,t)=>`${e}’s records from ${t} are on the way.`,readingUpload:"We’re reading the document you uploaded.",uploadFormatHint:"Upload PDF records you already have, up to 25 MB each. You can pick several at once. We'll read them and add the results to your records.",uploadLimitHint:"PDFs up to 25 MB each. You can pick several at once.",results:e=>e===1?"result":"results",noScreenings:"No screenings yet",screeningsToReview:e=>`${e} to review`,screeningsClear:"All clear",noVisits:"No visits yet",oneReading:"One reading so far: we’ll plot a trend as more come in.",uploadedDocument:"Uploaded document"}),fb=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function mb(e){let t=new Date(e);return`${fb[t.getUTCMonth()]??""} ${t.getUTCDate()}, ${t.getUTCFullYear()}`}function bb(e){let t=gb,r=e.filter(e=>(e.latest?.qualitativeResult??"").trim().length>0);if(r.length===0)return null;let n=r.filter(e=>yb(e.latest?.status??null,e.latest?.qualitativeResult??"")),i=n[0]??r[0];return n.length>0?{label:t.screeningsToReview(n.length),flagged:true,markerId:i.markerId}:{label:t.screeningsClear,flagged:false,markerId:i.markerId}}function yb(e,t){return e==="in_range"?false:e==="above"||e==="below"?true:/negative|not detected|clear|none/i.test(t)?false:/positive|detected|present|reactive/i.test(t)}function vb(e){let t=e.replace(/_/g," ").trim();return t.length>0?t.charAt(0).toUpperCase()+t.slice(1):e}function wb(e,t){if(e===null||e.withheld)return[];let r=/* @__PURE__ */new Map;if(t!==null&&!t.withheld)for(let e of t.encounters){let t=e.clinicName?.trim();e.docId!==null&&t&&r.set(e.docId,t)}return Object.values(e.documents).sort((e,t)=>(Im(t.receivedAt)??0)-(Im(e.receivedAt)??0)).slice(0,4).reverse().map(e=>{let t=Im(e.receivedAt);return{key:e.docId,name:r.get(e.docId)??gb.uploadedDocument,meta:[e.documentClass?vb(e.documentClass):null,t!==null?mb(t):null].filter(e=>e!==null).join(" · ")}})}var kb=["January","February","March","April","May","June","July","August","September","October","November","December"];function xb(e){let t=new Date(e);return`${kb[t.getUTCMonth()]??""} ${t.getUTCDate()}`}function Tb(e,t){if(t===null||e===null||e.withheld)return null;let r=new Date(t).toISOString().slice(0,10),n=e.encounters.find(e=>{let t=Im(e.date);return t!==null&&new Date(t).toISOString().slice(0,10)===r}),i=n?.veterinarian?.trim(),l=Im(n?.date);return i&&l!==null?{vet:i,date:xb(l)}:null}function Cb(e,t){let r=gb;return tb(Tm(e,null),t).map(t=>t.key==="upload"?{...t,text:r.readingUpload}:t.key.startsWith("clinic-")?{...t,text:r.onTheWayFrom(e,t.key.slice(7))}:t)}function _b(e){let t={url:e.url,kind:e.kind,expiresAt:e.expires_at};return typeof e.loop_duration_ms=="number"&&(t.loopDurationMs=e.loop_duration_ms),typeof e.cache_key=="string"&&e.cache_key.length>0&&(t.cacheKey=e.cache_key),/* @__PURE__ */Object.freeze(t)}function mapPetStateResponse(e){let t={};e.tiers.animation&&(t.animation=_b(e.tiers.animation)),e.tiers.image&&(t.image=_b(e.tiers.image));let r={};e.overlays.weather_alert&&(r.weatherAlert=_b(e.overlays.weather_alert));let n={category:e.category,tiers:/* @__PURE__ */Object.freeze(t),overlays:/* @__PURE__ */Object.freeze(r),idle:"bundled",ttlSeconds:e.ttl_seconds,degraded:e.degraded};return typeof e.cache_epoch=="number"&&(n.cacheEpoch=e.cache_epoch),/* @__PURE__ */Object.freeze(n)}var Rb=/* @__PURE__ */u.enum(["webp","video"]),Sb=/* @__PURE__ */u.enum(["health","attention","moment","activity","mood","idle"]),zb=/* @__PURE__ */u.object({url:/* @__PURE__ */u.string(),kind:/* @__PURE__ */Rb.default("webp"),loop_duration_ms:/* @__PURE__ */u.number().nullish(),expires_at:/* @__PURE__ */u.string(),cache_key:/* @__PURE__ */u.string().nullish()}),Ib=/* @__PURE__ */u.object({category:Sb,tiers:/* @__PURE__ */u.object({animation:/* @__PURE__ */zb.nullish(),image:/* @__PURE__ */zb.nullish()}).default({}),overlays:/* @__PURE__ */u.object({weather_alert:/* @__PURE__ */zb.nullish()}).default({}),idle:/* @__PURE__ */u.literal("bundled").default("bundled"),ttl_seconds:/* @__PURE__ */u.number(),degraded:/* @__PURE__ */u.boolean().default(false),cache_epoch:/* @__PURE__ */u.number().default(0)});function parsePetStateWire(e){let t=Ib.safeParse(e);return t.success?t.data:null}function createPetStateRepository(e){return Db(createRequestFunnel({auth:e}))}function Db(e){return{async getState(petRef,t){if(cr(petRef))return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}));let r=`/widget/v1/pets/${encodeURIComponent(petRef)}/state`,n=await e.send("animations.getState",t?.signal?{method:"GET",path:r,signal:t.signal}:{method:"GET",path:r},t?.maxAttempts!==void 0?{maxAttempts:t.maxAttempts}:void 0);if(n.ok){let e=parsePetStateWire(n.value);return e===null?err(makeEverfurError("internalError",{retryable:true})):ok(mapPetStateResponse(e))}return n.error.httpStatus===404?ok(null):err(n.error)}}}var Hb=/* @__PURE__ */Object.freeze({status:"loading"}),Lb=/* @__PURE__ */Object.freeze({status:"none"}),Pb=3e4,Ob=/* @__PURE__ */Object.freeze([2e3,6e3]),$b=/* @__PURE__ */Object.freeze({animation:false,image:false});function Bb(e,t,r){if(e.kind==="pending")return Hb;if(e.kind==="failed"||e.value===null)return Lb;let{animation:n,image:i}=e.value.tiers;return n!==void 0&&n.kind==="webp"&&!r&&!t.animation?{status:"art",url:n.url,key:n.cacheKey??n.url,animated:true}:i!==void 0&&i.kind==="webp"&&!t.image?{status:"art",url:i.url,key:i.cacheKey??i.url,animated:false}:Lb}function jb(petRef,e){let t=s(zr),a=t?.runtime??null,userRef=t?.userRef??null,d=a!==null&&userRef!==null&&petRef!==null?`${userRef}|${petRef}`:null,[c,u]=i({scope:d,read:{kind:"pending"}}),[h,p]=i({scope:d,failed:$b}),[g,f]=i({scope:d,at:0}),m=c.scope===d?c.read:{kind:"pending"},b=m.kind==="answer"&&m.value===null,y=r({scope:d,n:0});o(()=>{if(d===null||a===null||userRef===null||petRef===null||!e.isFocused||b)return;let t=g.scope===d?g.at:0,r=true,n=typeof AbortController=="function"?new AbortController:null,i=()=>{createPetStateRepository(a.registry.services.authFor(userRef)).getState(petRef,n?{signal:n.signal,maxAttempts:1}:{maxAttempts:1}).then(e=>{if(!r)return;if(e.ok){y.current={scope:d,n:0};let t=e.value;u(e=>t!==null&&t.degraded&&e.scope===d&&e.read.kind==="answer"&&e.read.value!==null?e:{scope:d,read:{kind:"answer",value:t}}),t!==null&&(t.degraded||p({scope:d,failed:$b}),f({scope:d,at:Date.now()+Math.max(30,t.ttlSeconds)*1e3}));return}if(e.error.httpStatus===403){u({scope:d,read:{kind:"answer",value:null}});return}let t=y.current.scope===d?y.current.n:0,n=Ob[t];y.current={scope:d,n:t+1},u(e=>e.scope===d&&e.read.kind==="answer"?e:n!==void 0?{scope:d,read:{kind:"pending"}}:{scope:d,read:{kind:"failed"}}),f({scope:d,at:Date.now()+(n??Pb)})})},l=Math.max(0,t-Date.now()),o=l===0?null:setTimeout(i,l);return o===null&&i(),()=>{r=false,o!==null&&clearTimeout(o),n?.abort()}},[d,a,userRef,petRef,e.isFocused,b,g]);let v=h.scope===d?h.failed:$b,w=n(()=>d===null?Lb:Bb(m,v,e.reducedMotion),[d,m,v,e.reducedMotion]),k=l(()=>{w.status==="art"&&p(e=>{let t=e.scope===d?e.failed:$b;return{scope:d,failed:w.animated?{...t,animation:true}:{...t,image:true}}})},[w,d]);return n(()=>({art:w,onError:k}),[w,k])}var Ab=/* @__PURE__ */Object.freeze({temperature:"Temperature",heartRate:"Heart rate",breathing:"Breathing",vitalsLabel:e=>`Vitals at ${e}’s last exam`,vitalLabel:(e,t,r,n=true)=>`${e}, ${t} ${r}.${n?" More about it":""}`,sayLine:"I wonder what I may be hiding",sayPhrases:["Hmmm","I wonder","what I may be","hiding"],upcomingCare:"Upcoming Care",viewAll:"View all →",dueSoon:"Due soon",later:"Later",nothingDue:e=>`Nothing due for ${e} right now.`,overdueBy:e=>`Overdue by ${e} ${e===1?"day":"days"}`,dueToday:"Due today",dueIn:e=>`Due in ${e} ${e===1?"day":"days"}`,noDueDate:"No due date on file",withDue:(e,t)=>`${e} · due ${t}`,dueOn:e=>`Due ${e}`,thisDay:(e,t)=>`${e} · this ${t}`,inWeeks:(e,t)=>`${e} · in ${t} ${t===1?"week":"weeks"}`,recordsHistory:"Records & History",labs:"Labs & bloodwork",labsA11y:(e,t)=>`Labs and bloodwork, ${e} ${t}`,labsA11yUnknown:"Labs and bloodwork",labsCountUnknown:"--",screenings:"Screenings",screeningsA11y:e=>`Screenings${e!==null?`, ${e}`:""}`,toReview:e=>`${e} to review`,allClear:"All clear",visits:"Visits & records",visitsA11y:e=>`Visits and records${e!==null?`, latest ${e}`:""}`,timeline:"Timeline",events:e=>`${e} events`,timelineA11y:e=>`Timeline${e>0?`, ${e} events`:""}`,weight:"Weight",estimatedRange:"Estimated Optimal Adult Range",noWeights:e=>`No weights on file yet. They show up here from ${e}’s vet visits.`,legendOver:["OVER","WEIGHT"],legendStable:["STABLE"],legendUnder:["UNDER","WEIGHT"],trendSummary:(e,t,r,n,i)=>`${e===1?"1 reading":`${e} readings`}, latest ${t}${e===1?"":`, trend ${r}`}.${n!==null&&i!==null?` Healthy range ${n} to ${i}.`:""}`,pointLabel:(e,t,r)=>e!==null?`${e}, ${t} ${r}`:`${t} ${r}`,addRecords:e=>`Add ${e}’s records`,moreThanOneClinic:"Records can come from more than one clinic over a lifetime.",onFileNow:"On file now",videoVisit:"Everfur video visit",requestFromClinic:"Request from a clinic",uploadDocument:"Upload a document",onTheWay:e=>`${e}’s records are on the way`,clinicsTake:"Clinics usually take 2 to 5 days.",requestSentTo:e=>e!==null?`Request sent to ${e}`:"Request sent",signedRelease:e=>`${e} · you signed the release`,waitingFor:e=>`Waiting for ${e} records`,inHealthTab:e=>`In ${e} Health tab`,everyPageRead:"Every page read: vaccines, labs, visits, meds",today:"Today",anotherClinic:"Another clinic",anotherClinicText:"Seen more than one vet? We ask each one.",uploadText:"A PDF, or a photo of a paper record.",requestTitle:e=>`${e}’s records request`,requestA11y:(e,t)=>`Records request for ${e}. ${t}`,sample:"Sample",peekLead:e=>`A sneak peek at how ${e}’s records will read. Every number links back to the page it came from.`,previousGroup:"Previous group",nextGroup:"Next group",markerGroups:"Marker groups",sampleNotTheirs:e=>`This is a sample, not ${e}’s result.`,sampleNote:e=>` Add ${e} records to see ${e} own numbers. Anything outside the range gets flagged like this, with what it measures and what to ask ${e} vet.`,columns:["Test","Result","Unit","Range"],slideOf:(e,t,r)=>`${e}, ${t} of ${r}`,high:"High",legal:Yn,noVetTitle:e=>`When ${e.name} has a vet, start here.`});function Eb(e){let t=Math.floor(e/12),r=e%12;return t<=0?`${r}m`:r>0?`${t}y ${r}m`:`${t}y`}var Fb={cap:"Read from the lab report, page 2",who:"Chemistry panel",page:"p. 2 of 12"},qb=/* @__PURE__ */Object.freeze([{key:"liver",chip:"Liver",lead:"What the liver makes and clears.",markers:[{name:"ALT",flag:"High",what:"An enzyme found mostly in liver cells.",at:92,value:"118",unit:"U/L"},{name:"ALP",what:"An enzyme from the liver and bones.",at:33,value:"64",unit:"U/L"},{name:"GGT",what:"An enzyme tied to the liver’s bile ducts.",at:36,value:"3",unit:"U/L"},{name:"Total bilirubin",what:"A yellow pigment the liver clears.",at:33,value:"0.2",unit:"mg/dL"}],from:{...Fb,rows:[{test:"ALB",result:"3.2",unit:"g/dL",range:"2.3-4.0"},{test:"ALP",result:"64",unit:"U/L",range:"23-212",lit:true},{test:"ALT",result:"118 H",unit:"U/L",range:"10-100",lit:true},{test:"BUN",result:"18",unit:"mg/dL",range:"7-27"},{test:"GGT",result:"3",unit:"U/L",range:"0-11",lit:true},{test:"T. BILI",result:"0.2",unit:"mg/dL",range:"0.0-0.9",lit:true}]}},{key:"kidney",chip:"Kidney",lead:"What the kidneys filter out and keep in balance.",markers:[{name:"BUN",what:"Protein waste the kidneys filter out.",at:53,value:"18",unit:"mg/dL"},{name:"Creatinine",what:"Muscle waste the kidneys filter out.",at:48,value:"1.1",unit:"mg/dL"},{name:"SDMA",what:"Another measure of kidney filtering.",at:59,value:"9",unit:"µg/dL"},{name:"Phosphorus",what:"A mineral the kidneys keep in balance.",at:42,value:"4.1",unit:"mg/dL"}],from:{...Fb,rows:[{test:"ALT",result:"45",unit:"U/L",range:"10-100"},{test:"BUN",result:"18",unit:"mg/dL",range:"7-27",lit:true},{test:"CA",result:"10.1",unit:"mg/dL",range:"7.9-12.0"},{test:"CREA",result:"1.1",unit:"mg/dL",range:"0.5-1.8",lit:true},{test:"PHOS",result:"4.1",unit:"mg/dL",range:"2.5-6.8",lit:true},{test:"SDMA",result:"9",unit:"µg/dL",range:"0-14",lit:true}]}},{key:"blood",chip:"Blood cells",lead:"The cells that carry oxygen, fight infection and help blood clot.",markers:[{name:"Red blood cells",what:"Cells that carry oxygen around the body.",at:43,value:"6.9",unit:"M/µL"},{name:"Hemoglobin",what:"The part of red cells that holds oxygen.",at:42,value:"15.8",unit:"g/dL"},{name:"White blood cells",what:"Cells that fight infection.",at:44,value:"9.8",unit:"K/µL"},{name:"Platelets",what:"Cell fragments that help blood clot.",at:41,value:"265",unit:"K/µL"}],from:{cap:"Read from the lab report, page 3",who:"Complete blood count",page:"p. 3 of 12",rows:[{test:"HCT",result:"46",unit:"%",range:"37.3-61.7"},{test:"HGB",result:"15.8",unit:"g/dL",range:"13.1-20.5",lit:true},{test:"NEUT",result:"6.1",unit:"K/µL",range:"2.95-11.64"},{test:"PLT",result:"265",unit:"K/µL",range:"148-484",lit:true},{test:"RBC",result:"6.9",unit:"M/µL",range:"5.65-8.87",lit:true},{test:"WBC",result:"9.8",unit:"K/µL",range:"5.05-16.76",lit:true}]}},{key:"sugar",chip:"Sugar and salts",lead:"Fuel, and the salts that keep fluids, nerves and muscles steady.",markers:[{name:"Glucose",what:"Blood sugar, the body’s main fuel.",at:41,value:"96",unit:"mg/dL"},{name:"Sodium",what:"A salt that keeps fluids in balance.",at:31,value:"147",unit:"mmol/L"},{name:"Potassium",what:"A salt that helps nerves and muscles work.",at:49,value:"4.6",unit:"mmol/L"},{name:"Calcium",what:"A mineral for bones, muscles and nerves.",at:52,value:"10.1",unit:"mg/dL"}],from:{...Fb,rows:[{test:"CA",result:"10.1",unit:"mg/dL",range:"7.9-12.0",lit:true},{test:"CL",result:"112",unit:"mmol/L",range:"109-122"},{test:"GLU",result:"96",unit:"mg/dL",range:"70-143",lit:true},{test:"K",result:"4.6",unit:"mmol/L",range:"3.5-5.8",lit:true},{test:"NA",result:"147",unit:"mmol/L",range:"144-160",lit:true},{test:"PHOS",result:"4.1",unit:"mg/dL",range:"2.5-6.8"}]}}]),Mb=/* @__PURE__ */Object.freeze([{key:"screenings",title:"Screenings",tint:"pink",lead:"Tests that look for common problems early, and what came back.",rows:[{title:"Heartworm test",pill:"Negative",tone:"clear"},{title:"Tick panel (4Dx)",pill:"Negative",tone:"clear"}]},{key:"visits",title:"Visits & records",tint:"blue",lead:"Every visit, with the vet’s notes and the pages they came from.",rows:[{title:"Wellness exam",text:"38 pages"},{title:"Everfur video visit",text:"3 pages"}]},{key:"timeline",title:"Timeline",tint:"yellow",lead:"Her whole history in order, with what’s due next.",rows:[{title:"Rabies vaccine",pill:"Due soon",tone:"soon"},{title:"Heartworm test",text:"Apr 18"}]}]);var Nb=/* @__PURE__ */Object.freeze({ink:"#10462E",go:"#07C168",muted:"#6B6B6B",line:"#E4E4E4",text:"#000000",bg:"#FFFFFF",white:"#FFFFFF",mist:"#F1F5F2",charcoal:"#3D3D3D",alert:"#C03410",alertDeep:"#6D1D14",pink:"#FFC3BC",yellow:"#F2C763",skyBlue:"#4E98C9",tintSage:"#E6ECE8",tintPink:"#FFEAE8",tintPinkSoft:"#FFF6F5",tintBlue:"#EAEEF6",tintYellow:"#FCF0D6",tintYellowEdge:"#F6D892",tintRed:"#FBF1EE",tintGo:"#DCF6EA",icoGrey:"#6B6B6B",icoSage:"#819E90",icoBlue:"#4E98C9",barTrack:"#ECECEC",pillPlainEdge:"rgba(16, 70, 46, 0.2)"}),Wb=/* @__PURE__ */Object.freeze({screenTitle:/* @__PURE__ */Object.freeze({size:22,lineHeight:26.4,face:"medium",color:"ink",letterSpacing:-.33}),cardTitle:/* @__PURE__ */Object.freeze({size:18,lineHeight:22.5,face:"bold",color:"ink",letterSpacing:-.36}),body:/* @__PURE__ */Object.freeze({size:17,lineHeight:26.35,face:"regular",color:"text",letterSpacing:0}),bodySm:/* @__PURE__ */Object.freeze({size:15,lineHeight:21.75,face:"regular",color:"text",letterSpacing:0}),bodySmBold:/* @__PURE__ */Object.freeze({size:15,lineHeight:21.75,face:"bold",color:"ink",letterSpacing:0}),fine:/* @__PURE__ */Object.freeze({size:13,lineHeight:18.2,face:"regular",color:"muted",letterSpacing:0}),labelMono:/* @__PURE__ */Object.freeze({size:12,lineHeight:16.8,face:"monoBold",color:"muted",letterSpacing:.72,upper:true}),pill:/* @__PURE__ */Object.freeze({size:12,lineHeight:14.4,face:"monoBold",color:"ink",letterSpacing:.72,upper:true}),button:/* @__PURE__ */Object.freeze({size:15,lineHeight:18,face:"bold",color:"ink",letterSpacing:0}),buttonRow:/* @__PURE__ */Object.freeze({size:14,lineHeight:16.8,face:"bold",color:"ink",letterSpacing:0}),chip:/* @__PURE__ */Object.freeze({size:14,lineHeight:16.8,face:"medium",color:"ink",letterSpacing:0}),hand:/* @__PURE__ */Object.freeze({size:22,lineHeight:26.4,face:"hand",color:"ink",letterSpacing:0})}),Ub=/* @__PURE__ */Object.freeze({surface:"#FFFFFF",textPrimary:"#111111",textMuted:"#6E6660",border:"#C8BEB4",brand:"#10462E",brandSoft:"rgba(16, 70, 46, 0.1)",danger:"#B91C1C"}),Gb=/* @__PURE__ */Object.freeze({dot:24,check:12,core:10,ring:2,rowGap:12,bodyBottom:18,bodyGap:2,titleGap:8,rail:2,railMin:22,railGap:2,titleSize:14,titleLineHeight:18,dateSize:12,dateLineHeight:16,detailSize:13,detailLineHeight:17,upcomingOpacity:.7});var Vb=/* @__PURE__ */Object.freeze({screen:{gap:12,padX:16,padBottom:24,legalTop:20},hero:{nameSize:22,nameLineHeight:26,nameTracking:-.44,metaTop:2,metaLineHeight:18,metaTracking:.26,stageHeight:280,stageTop:4,grassFraction:.46,petBottom:40,petBoxHeight:224,petTop:16,sayWidth:230,sayHeight:61,sayFontSize:22,sayArcPath:"M 12 60 Q 120 -4 228 60",sayViewBox:[240,64],vitalsTop:8,vitalsLeft:8,vitalMinHeight:40,vitalPadX:8,vitalGap:6,vitalIcon:22,vitalValueSize:17,vitalUnitSize:13,lawnOverlap:26,lawnRadius:28},card:{pad:16,radius:20,border:1,headGap:8,headBottom:12},button:{md:52,sm:46,row:36,padMd:24,padSm:16,padRow:14,iconMd:22,iconSm:20,iconRow:17,edge:1.5,gap:8,mdLabel:17,textGap:6,textMinHeight:24},pill:{minHeight:24,padX:10,edgeThin:1.25,edgeThick:1.5},upcoming:{listGap:4,bleed:8,rowPadY:10,rowPadX:8,rowGap:12,rowRadius:10,icon:20,maxRows:4},tiles:{top:8,titleBottom:12,gap:12,pad:16,radius:20,innerGap:8,icon:22,chevron:20,titleLineHeight:19,footMinHeight:28,numSize:20,numLineHeight:22,numTracking:-.4,countGap:8},weight:{headGap:4,headBottom:16,numSize:32,numLineHeight:34,numTracking:-.64,numGap:8},chart:{height:176,plotTop:24,axisBand:20,rightInset:14,indicatorWidth:8,plotLeft:62,dataLeft:76,dot:6,dotRing:1.5,lineWidth:2,labelGap:7,labelMax:12,labelMin:9,labelCharWidth:.62,edgePad:4,legendX:14,legendLine:14.4,legendSize:12,legendTracking:.24,monthY:172,monthSize:12,maxTicks:5,maxValues:8,bandFrom:.3,bandTo:.7,reach:.88,bandPct:.1,lineColor:"#111111",gridColor:"#EAEAEA",bandColor:"#D8F3E3"},add:{gap:12,headGap:8,icon:26,sourcesGap:6,sourcesTop:4,sourcePadY:10,sourcePadX:14,sourceRadius:10,sourceColumnGap:12,actsGap:12,actsTop:4},peek:{top:12,headGap:12,leadTop:8,labsTop:16,chipsTop:10,chipsGap:8,slideTop:16,slideGap:4,slideLeadTop:2,slideLeadBottom:8,markerPad:12,markerGap:8,markerRadius:10,markerTopGap:12,barHeight:8,barDot:12,barDotRing:2,valueGap:4,fromMinHeight:40,fromGap:6,fromIcon:16,fromChevron:18,moreGap:12,moreTop:16,morePad:16,moreInnerGap:12,moreRadius:20,moreIcon:22,moreHeadGap:8,rowsGap:6,rowMinHeight:44,rowPadY:8,rowPadX:14,rowRadius:10,roundButton:36,chipHeight:36,chipPadX:14},onTheWay:{dot:28,titleSize:22,titleLineHeight:25,titleTracking:-.44,wayIcon:26,wayPad:16,wayRadius:20},inProgress:{radius:18,pad:18,gap:16,titleSize:16,titleLineHeight:20,statusRadius:14,statusPad:14,statusSize:13,statusLineHeight:19}});var Kb=/* @__PURE__ */new WeakMap;function Yb(e){let t=Kb.get(e);if(t!==void 0)return t;let r=e.slots.primaryButton,n=/* @__PURE__ */Object.freeze({card:{borderRadius:e.radius.lg,...Bn(An(e.slots),1)},button:r===void 0?null:Bn(r),buttonInk:r?.textColor,radius:r?.borderRadius===void 0?null:{borderRadius:r.borderRadius}});return Kb.set(e,n),n}function Xb(){let e=useEverfurTheme();return n(()=>Yb(e),[e])}function Qb(e){let t=recordsSheetLook(e);if(t.dark)/* @__PURE__ */
764
+ return Object.freeze(a)}var mm=/* @__PURE__ */Object.freeze({branding:null}),bm=/* @__PURE__ */Object.freeze({subscribe:()=>()=>{},getSnapshot:()=>mm});function ym(e){return e?Object.keys(e).sort().map(t=>`${t}=${String(e[t])}`).join("&"):""}function useEverfurPresentation(e){return vm(e).presentation}function vm(e){let{runtime:t}=Ir(),r=t?.entitlements??bm,i=l(()=>r.getSnapshot()?.branding??null,[r]),o=am(d(r.subscribe,i,i),t?.sdkConfigHost?.branding),a=ym(e);return n(()=>{let t=o?.lockedFields??null;return{presentation:resolvePresentation({server:o?.presentation??null,locked:t,client:e??null}),isLocked:e=>isPresentationFieldLocked(e,t)}},[o,a])}var wm=3600*1e3;function km(e,t=true){let[n,l]=i(()=>e??Date.now()),a=r(true);return o(()=>{if(a.current){a.current=false;return}e===void 0&&t&&l(Date.now())},[e,t]),o(()=>{if(e!==void 0||!t)return;let r=setInterval(()=>l(Date.now()),wm),n=()=>{document.visibilityState==="visible"&&l(Date.now())},i=typeof document<"u"&&typeof document.addEventListener=="function"?document:null;return i?.addEventListener("visibilitychange",n),()=>{clearInterval(r),i?.removeEventListener("visibilitychange",n)}},[e,t]),e??n}var xm=e=>e.charAt(0).toUpperCase()+e.slice(1);function Tm(e,t){let r=e.trim(),n=r.length>0?r:Xn,i=xm(n);return t==="her"?{name:n,Name:i,poss:"her",Poss:"Her",subj:"she"}:t==="his"?{name:n,Name:i,poss:"his",Poss:"His",subj:"he"}:{name:n,Name:i,poss:`${n}'s`,Poss:`${i}'s`,subj:n}}var _m=/* @__PURE__ */Object.freeze({vitalsFrom:(e,t,r)=>`Vitals from ${e.poss} ${t}, ${r}`,vitalsSource:e=>`Where ${e.name}'s vitals come from`,temperature:"Temperature",heartRate:"Heart rate",breathing:"Breathing",upcomingCare:"Upcoming care",overdueBy:e=>`Overdue · due by ${e}`,dueSoon:"Due soon",later:"Later",noDate:"No date",dueIn:(e,t)=>`Due ${e} · in ${t} ${t===1?"day":"days"}`,dueToday:e=>`Due ${e} · today`,overdueByDays:(e,t)=>`Overdue by ${t} ${t===1?"day":"days"} · due ${e}`,recordsHistory:"Records & history",labs:"Labs & bloodwork",results:"results",screenings:"Screenings",screeningsClear:"All clear",screeningsToReview:e=>`${e} to review`,noScreenings:"No screenings yet",visits:"Visits & records",timeline:"Timeline",events:e=>`${e} ${e===1?"event":"events"}`,weight:"Weight",vetVisits:e=>`${e} vet ${e===1?"visit":"visits"}`,history:"History",theirClinic:e=>`${e.Poss} clinic`,bloodPanel:"Blood panel",aboveRange:"above range",belowRange:"below range",othersInRange:"Other values in range.",addRecords:e=>`Add ${e.name}'s records`,moreThanOneClinic:"Records can come from more than one clinic over a lifetime.",visitsCount:e=>`${e} ${e===1?"visit":"visits"}`,panelsCount:e=>`${e} blood ${e===1?"panel":"panels"}`,requestFromClinic:"Request from a clinic",uploadDocument:"Upload a document",onFileNow:"On file now",firstRecord:e=>`Add ${e.name}'s first record`,firstLead:e=>`Records can come from more than one clinic over a lifetime. Start with the one ${e.subj} sees most, and this page fills in from there.`,requestFromTheirClinic:e=>`Request from ${e.poss} clinic`,requestDetail:"We send a secure request and read every page they send back.",uploadDetail:"A PDF, or a photo of a paper record.",findClinic:e=>`Find ${e.name}'s clinic`,chooseFile:"Choose a file",sayBeats:/* @__PURE__ */Object.freeze(["Hmmm","I wonder","what I may be","hiding"]),sayStill:"I wonder what I may be hiding",sample:"Sample",peekLead:e=>`A sneak peek at how ${e.name}'s records will read. Every number links back to the page it came from.`,sampleNote:e=>`Sample data until ${e.poss} records arrive.`,onTheWay:e=>`${e.Name}'s records are on the way`,clinicsTake:"Clinics usually take 2 to 5 days.",anotherClinic:"Another clinic",anotherClinicDetail:"Seen more than one vet? We ask each one.",noDueDate:"No due date on file",noLabs:e=>`No lab results on file for ${e.name} yet. They show up here when a record includes a blood or urine panel.`,noVisits:e=>`No visits in ${e.name}'s records yet. They show up here when a record includes one.`,oneReading:"One reading so far: we'll plot a trend as more come in.",takingNow:"Taking now",noCurrentMeds:"No current medications on file.",noVetTitle:e=>`When ${e.name} has a vet, start here.`,requestedFrom:e=>`Requested from ${e}. Clinics usually take 2 to 5 days.`,onTheWayFrom:(e,t)=>`${e.Name}'s records from ${t} are on the way.`,readingUpload:"We're reading the document you uploaded.",seeWhereItStands:"See where it stands",topRisk:e=>`${e.Poss} top risk`,seePlan:e=>`See ${e.poss} Health Plan`,panelOn:e=>`${e} blood panel`,latestReading:"Latest reading",rangeLine:(e,t,r)=>`range ${e} to ${t}${r?` ${r}`:""}`,noRange:"No range on the report",above:"Above",inRange:"In range",below:"Below",high:"High",belowRangePill:"Below range",changeUp:(e,t)=>`Up ${e}${t?` ${t}`:""}`,changeDown:(e,t)=>`Down ${e}${t?` ${t}`:""}`,changeSince:(e,t)=>` since ${e}, about ${t}%.`,whatIs:e=>`What ${e} is`,otherValues:e=>`Other ${e} values`,panelTitle:(e,t)=>`${e} · ${t}`,askAboutThis:"Ask about this"});var Cm=864e5,Rm=30,Sm=2.20462,zm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Im(e){if(e==null||e.length===0)return null;let t=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:e);return Number.isNaN(t)?null:t}function Dm(e){let t=new Date(e);return`${zm[t.getUTCMonth()]??""} ${t.getUTCDate()}`}function Hm(e){return`${Dm(e)}, ${new Date(e).getUTCFullYear()}`}function Lm(e){let t=new Date(e);return`${t.getUTCMonth()+1}/${String(t.getUTCFullYear()%100).padStart(2,"0")}`}var Pm=e=>new Date(e).toISOString().slice(0,10);function Om(e){return String(Math.round(e*100)/100)}var $m=e=>Math.round(e*Sm*10)/10;function Bm(e){let t=e.trim();return t.length<2||t[1]===t[1]?.toUpperCase()?t:t.charAt(0).toLowerCase()+t.slice(1)}function jm(e){return/temp/i.test(e)?"temp":/heart|pulse/i.test(e)?"heart":/resp|breath/i.test(e)?"breath":null}var Am=["temp","heart","breath"],Em={temp:_m.temperature,heart:_m.heartRate,breath:_m.breathing};function Fm(e){if(e===null||e.withheld)return{vitals:[],observedMs:null};let t=/* @__PURE__ */new Map;for(let r of e.entities){if(r.category!=="vital"||r.value===null||r.value.trim().length===0)continue;let e=jm(`${r.canonicalKey??""} ${r.key} ${r.label}`);if(e===null)continue;let n=Im(r.observedAt)??0,i=t.get(e);(i===void 0||n>i.ms)&&t.set(e,{value:r.value.trim(),unit:r.unit,ms:n})}let r=Am.flatMap(e=>{let r=t.get(e);return r===void 0?[]:[{kind:e,value:r.value,unit:r.unit,label:Em[e]}]}),n=[...t.values()].map(e=>e.ms).filter(e=>e>0);return{vitals:r,observedMs:n.length>0?Math.max(...n):null}}function qm(e,t){let r=Pm(t);return e.find(e=>{let t=Im(e.date);return t!==null&&Pm(t)===r})??null}function Mm(e){return/vaccin|rabies|dhpp|booster|bordetella|lepto|lyme|parvo|distemper/i.test(e)?"efi-shield":/\b(alt|alp|lab|labs|blood|panel|bloodwork|urinalysis|chemistry|cbc)\b/i.test(e)?"efi-flask-sm":"efi-calendar"}function Nm(e,t){return e.map(e=>{let r=Im(e.dueAt),n=Mm(e.title);if(r!==null&&r<t-Cm+1)return{item:e,title:e.title,when:_m.overdueBy(Dm(r)),tone:"alert",pill:null,icon:n};let i=e.detail??(r===null?_m.noDueDate:Hm(r));if(r===null)return{item:e,title:e.title,when:i,tone:"none",pill:null,icon:n};let l=r-t<=Rm*Cm;return{item:e,title:e.title,when:i,tone:l?"watch":"later",pill:l?_m.dueSoon:_m.later,icon:n}})}function Wm(e){return e==null?null:/above|high/i.test(e)?"above":/below|low/i.test(e)?"below":/in_range|normal|in range/i.test(e)?"in":null}var Um=e=>Math.round(e*10)/10;function Gm(e,t){let r=`${Om($m(e))} lb`,n=`${Om(Um(e))} kg`;return t==="kg"?{main:n,other:r}:{main:r,other:n}}function Vm(e,t){if(e===null||e.withheld)return null;let r=e.weights.flatMap(e=>{let t=Im(e.observedOn);return t===null||e.weightKg===null?[]:[{ms:t,kg:e.weightKg}]}).sort((e,t)=>e.ms-t.ms),n=r[r.length-1];if(n===void 0)return null;let i=r.map(e=>$m(e.kg)),l=Math.min(...i),o=Math.max(...i),a=r[0]?.ms??n.ms,s=n.ms-a,d=r.map((e,r)=>({x:s>0?Math.round((3.55+93.45*(e.ms-a)/s)*100)/100:50,y:o>l?Math.round((75-50*((i[r]??l)-l)/(o-l))*10)/10:50,lb:i[r]??0,value:t==="kg"?Um(e.kg):i[r]??0,ms:e.ms})),c=d.length<=4?d:[d[0],d[d.length-1]].filter(e=>e!==void 0),u=Gm(n.kg,t);return{latest:u.main,sub:`${u.other} · ${Dm(n.ms)}`,single:d.length===1,points:d,ticks:c.map(e=>({x:e.x,label:Lm(e.ms)})),vetCount:d.length}}function Km(e){let t=/* @__PURE__ */new Map;if(e===null||e.withheld)return t;for(let r of e.markers)for(let e of r.points){let n=Im(e.at);if(n===null)continue;let i=Pm(n),l=t.get(i)??{ms:n,flagged:[],total:0,inRange:0,clinics:/* @__PURE__ */new Set};l.total+=1;let o=Wm(e.status);o==="in"&&(l.inRange+=1),(o==="above"||o==="below")&&l.flagged.push({marker:r,point:e,ms:n,flag:o}),e.sourceClinic&&l.clinics.add(e.sourceClinic),t.set(i,l)}return t}function Ym(e,t){let r=[];for(let[e,n]of t)n.flagged.forEach((t,i)=>{let l=t.point.value===null?t.point.qualitativeResult??"":Om(t.point.value),o=t.point.unit??t.marker.unit,a=n.flagged.length===1&&n.inRange===n.total-1&&n.total>1;r.push({key:`lab-${e}-${t.marker.markerId}-${i}`,ms:n.ms,date:`${Dm(n.ms)} · ${_m.bloodPanel}`,title:`${t.marker.name} ${l}${o?` ${o}`:""}, ${t.flag==="above"?_m.aboveRange:_m.belowRange}`,text:a?_m.othersInRange:null,alert:true,markerId:t.marker.markerId,order:0})});let n=e.depth?.withheld===false?e.depth.encounters:[],i=e.timeline?.withheld===false?e.timeline.visits:[],l=/* @__PURE__ */new Set;n.forEach((e,t)=>{let n=Im(e.date);if(n===null)return;let o=i.find(t=>e.docId!==null&&t.docId===e.docId||Im(t.visitDate)!==null&&Pm(Im(t.visitDate)??0)===Pm(n))??null;o!==null&&l.add(o.visitId);let a=o?.summary?.trim()||null,s=e.type?.trim()||null,d=a??s;d!==null&&r.push({key:`enc-${e.encounterId}-${t}`,ms:n,date:a!==null&&s!==null?`${Dm(n)} · ${s}`:Dm(n),title:d,text:null,alert:false,markerId:null,order:1})});for(let e of i){let t=Im(e.visitDate),n=e.summary?.trim()||null;l.has(e.visitId)||t===null||n===null||r.push({key:`visit-${e.visitId}`,ms:t,date:Dm(t),title:n,text:null,alert:false,markerId:null,order:1})}r.sort((e,t)=>t.ms-e.ms||e.order-t.order);let o=[];for(let e of r){let t={key:e.key,ms:e.ms,date:e.date,title:e.title,text:e.text,alert:e.alert,markerId:e.markerId},r=String(new Date(t.ms).getUTCFullYear()),n=o[o.length-1];n!==void 0&&n.year===r?n.items.push(t):o.push({year:r,items:[t]})}return{years:o,count:r.length}}function Xm(e,t){let r=e.depth?.withheld===false?e.depth.encounters:[],n=t=>t?.trim()||_m.theirClinic(e.words),i=/* @__PURE__ */new Map;for(let e of r)i.set(n(e.clinicName),(i.get(n(e.clinicName))??0)+1);let l=/* @__PURE__ */new Map,o=i.size===1?[...i.keys()][0]:void 0;for(let r of t.values()){let t=r.clinics.size>0?[...r.clinics].map(n):[o??_m.theirClinic(e.words)];for(let e of t)l.set(e,(l.get(e)??0)+1)}return[.../* @__PURE__ */new Set([...i.keys(),...l.keys()])].map(e=>({label:e,detail:[(i.get(e)??0)>0?_m.visitsCount(i.get(e)??0):null,(l.get(e)??0)>0?_m.panelsCount(l.get(e)??0):null].filter(e=>e!==null).join(" · ")}))}var Qm={requested:15,awaiting_clinic:35,awaiting_upload:35,received:60,parsing:75,in_review:90};function Jm(e){let t=e.filter(e=>!isTerminalStatus(e.status)).sort((e,t)=>(Im(t.updatedAt)??0)-(Im(e.updatedAt)??0))[0];if(t===void 0)return null;let r=(t.waitingExpectation?.trim()||t.statusLabel).trim();return r.length===0?null:{step:r,pct:Qm[t.status]??15}}var Zm=e=>[...e].sort((e,t)=>(Im(t.updatedAt)??0)-(Im(e.updatedAt)??0)),eb=e=>/[.!?]$/.test(e)?e:`${e}.`;function tb(e,t){let r=Zm(t).filter(e=>!isTerminalStatus(e.status)),n=r.filter(e=>e.status==="awaiting_upload"),i=r.filter(e=>e.status!=="awaiting_upload"),l=[],o=/* @__PURE__ */new Map;for(let e of i){let t=e.clinicName?.trim()??"";e.source!=="clinic_request"||t===""||o.has(t)||o.set(t,e)}for(let[t,r]of o)l.push({key:`clinic-${t}`,text:_m.onTheWayFrom(e,t),requestId:r.id});let a=i.find(e=>e.source==="owner_provided");a!==void 0&&l.push({key:"upload",text:_m.readingUpload,requestId:a.id});let s=n[0],d=s?.statusLabel.trim()??"";return s!==void 0&&d!==""&&l.push({key:"awaiting-upload",text:eb(d),requestId:s.id}),l}function rb(e){return Zm(e).find(e=>!isTerminalStatus(e.status)&&e.status!=="awaiting_upload"&&e.source==="clinic_request"&&(e.clinicName?.trim()??"")!=="")?.clinicName?.trim()??null}function nb(e){if(e===null||e.withheld)return null;let t=e.medications.filter(e=>(e.drugName?.trim()??"")!=="");return t.length===0?null:{current:t.filter(e=>(e.stoppedOn?.trim()??"")==="").map(e=>{let t=[e.dose,e.frequency,e.route].map(e=>e?.trim()??"").filter(e=>e!==""),r=e.sig?.trim()||(t.length>0?t.join(" · "):null);return{key:e.medicationId,name:(e.drugName??"").trim(),detail:r}})}}function ib(e){if(e.some(e=>!isTerminalStatus(e.status)))return null;let t=[...e].sort((e,t)=>(Im(t.updatedAt)??0)-(Im(e.updatedAt)??0))[0];if(t===void 0||t.status!=="failed")return null;let r=t.statusLabel.trim();return r.length>0?r:null}function lb(e,t,r){return e!==null&&!e.withheld&&!e.isEmpty||t!==null&&!t.withheld&&t.markers.length>0?true:r!==null&&!r.withheld&&r.encounters.length>0}function ob(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return null;let t=Math.floor(e*12+1e-9),r=Math.floor(t/12),n=t%12;return r<=0?`${n}M`:n>0?`${r}Y ${n}M`:`${r}Y`}function ab(e){let{record:t,depth:r,markers:n,nowMs:i}=e,l=lb(t,n,r),o=Jm(e.requests),a=Km(n),{vitals:s,observedMs:d}=Fm(t),c=r?.withheld===false?r.encounters:[],u=d===null?null:qm(c,d),h=d!==null&&u?.type?_m.vitalsFrom(e.words,Bm(u.type),Dm(d)):null,p=e.weightUnit??"lb",g=Vm(e.timeline,p),f=g!==null?null:e.petWeightKg,m=[e.breed?.trim()||null,ob(e.petAgeYears),g?.latest??(f!==null?Gm(f,p).main:null)].filter(e=>e!==null),b=e.timeline?.withheld===false?e.timeline.visits.length:0,y=Ym(e,a),v=c.map(e=>Im(e.date)).filter(e=>e!==null),w=n?.withheld===false?n.markers:[],k=n?.featuredMarkerId??w.find(e=>Wm(e.latest?.status)==="above"||Wm(e.latest?.status)==="below")?.markerId??w[0]?.markerId??null;return{state:l?"full":o!==null?"onTheWay":"none",meta:m.length>0?m.join(" · "):null,vitals:s,vitalsFrom:h,due:t!==null&&!t.withheld?Nm(t.forwardLooking,i):[],labsCount:n?.withheld===false?n.summary?.totalMarkers??n.markers.length:0,featuredMarkerId:k,latestVisit:v.length>0?Hm(Math.max(...v)):null,weight:g,history:y.years,historyCount:y.count,sources:Xm(e,a),pull:o,hasVisits:c.length>0||b>0,medications:nb(e.timeline),failedRequest:o===null?ib(e.requests):null,inFlight:tb(e.words,e.requests),requestedClinic:rb(e.requests)}}function sb(e){let t=e.points.filter(e=>e.value!==null);return t[t.length-1]??e.points[e.points.length-1]??null}function db(e){return e===null||e.refLow===null||e.refHigh===null||!Number.isFinite(e.refLow)||!Number.isFinite(e.refHigh)||e.refHigh<=e.refLow?null:{low:e.refLow,high:e.refHigh}}function cb(e,t=sb(e)){let r=db(t),n=t?.unit??e.unit,i=t?.value??null;return{markerId:e.markerId,name:e.name,value:i===null?t?.qualitativeResult??"":Om(i),unit:n,range:r===null?null:`${Om(r.low)} to ${Om(r.high)}${n?` ${n}`:""}`,at:r===null||i===null?null:Math.round(Math.min(100,Math.max(0,20+60*(i-r.low)/(r.high-r.low)))),flag:Wm(t?.status??e.latest?.status??null)}}function ub(e){return e==="above"?_m.high:e==="below"?_m.belowRangePill:e==="in"?_m.inRange:null}var hb=e=>{let t=e.replace(/\s+panel$/i,"").trim()||e;return t.length>1&&t[1]===t[1]?.toUpperCase()?t:t.charAt(0).toLowerCase()+t.slice(1)};function pb(e,t){let r=e.markers.find(e=>e.markerId===t);if(r===void 0)return null;let n=sb(r),i=cb(r,n),l=Im(n?.at??r.latest?.at??null),o=db(n),a=[l===null?null:Dm(l),o===null?_m.noRange:_m.rangeLine(Om(o.low),Om(o.high),i.unit)].filter(e=>e!==null).join(" · "),s=r.points.flatMap(e=>{let t=Im(e.at);return e.value===null||t===null?[]:[{p:e,ms:t,v:e.value}]}),d=[];if(s.length>0){let e=s.map(e=>e.v),t=o?.low??Math.min(...e),r=o?.high??Math.max(...e);d=s.map((e,n)=>({x:s.length===1?50:Math.round((18+64*n/(s.length-1))*100)/100,y:r>t?Math.min(98,Math.max(2,Math.round((75-50*(e.v-t)/(r-t))*10)/10)):50,label:Om(e.v),out:Wm(e.p.status)==="above"||Wm(e.p.status)==="below",tick:Dm(e.ms)}))}let c=s[0],u=s[s.length-1],h=null;if(c!==void 0&&u!==void 0&&s.length>=2&&u.v!==c.v){let e=Math.abs(u.v-c.v),t=c.v!==0?Math.round(e/Math.abs(c.v)*100):null,r=u.v>c.v?_m.changeUp(Om(e),i.unit):_m.changeDown(Om(e),i.unit);h=t===null?null:{lead:r,rest:_m.changeSince(Dm(c.ms),t)}}let p=[],g=l===null?null:Pm(l),f=e.markers.filter(e=>e.markerId!==r.markerId),m=f.filter(e=>e.panel!==null&&e.panel===r.panel);if(m.length>0&&r.panel!==null){let e=m.map(e=>cb(e));p.push({title:_m.otherValues(hb(r.panel)),allInRange:e.every(e=>e.flag==="in"),rows:e})}if(g!==null&&l!==null){let e=/* @__PURE__ */new Map;for(let t of f){if(t.panel===null||t.panel===r.panel)continue;let n=[...t.points].reverse().find(e=>{let t=Im(e.at);return t!==null&&Pm(t)===g});n!==void 0&&e.set(t.panel,[...e.get(t.panel)??[],cb(t,n)])}for(let[t,r]of e)p.push({title:_m.panelTitle(t,Dm(l)),allInRange:r.every(e=>e.flag==="in"),rows:r})}return{markerId:r.markerId,name:r.name,meta:l===null?null:_m.panelOn(Hm(l)),pill:ub(i.flag),flagged:i.flag==="above"||i.flag==="below",latest:`${i.value}${i.unit?` ${i.unit}`:""}`,latestSub:a,hasRange:o!==null,chart:d,change:h,meaning:(r.meaning??"").split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e.length>0),groups:p}}var gb=/* @__PURE__ */Object.freeze({vitalsFromLabel:e=>`Where ${e}’s vitals come from`,vitalsFrom:(e,t)=>`From ${e}’s exam, ${t}. `,examNotes:"Exam notes",onTheWayFrom:(e,t)=>`${e}’s records from ${t} are on the way.`,readingUpload:"We’re reading the document you uploaded.",uploadFormatHint:"Upload PDF records you already have, up to 25 MB each. You can pick several at once. We'll read them and add the results to your records.",uploadLimitHint:"PDFs up to 25 MB each. You can pick several at once.",results:e=>e===1?"result":"results",noScreenings:"No screenings yet",screeningsToReview:e=>`${e} to review`,screeningsClear:"All clear",noVisits:"No visits yet",oneReading:"One reading so far: we’ll plot a trend as more come in.",uploadedDocument:"Uploaded document"}),fb=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function mb(e){let t=new Date(e);return`${fb[t.getUTCMonth()]??""} ${t.getUTCDate()}, ${t.getUTCFullYear()}`}function bb(e){let t=gb,r=e.filter(e=>(e.latest?.qualitativeResult??"").trim().length>0);if(r.length===0)return null;let n=r.filter(e=>yb(e.latest?.status??null,e.latest?.qualitativeResult??"")),i=n[0]??r[0];return n.length>0?{label:t.screeningsToReview(n.length),flagged:true,markerId:i.markerId}:{label:t.screeningsClear,flagged:false,markerId:i.markerId}}function yb(e,t){return e==="in_range"?false:e==="above"||e==="below"?true:/negative|not detected|clear|none/i.test(t)?false:/positive|detected|present|reactive/i.test(t)}function vb(e){let t=e.replace(/_/g," ").trim();return t.length>0?t.charAt(0).toUpperCase()+t.slice(1):e}function wb(e,t){if(e===null||e.withheld)return[];let r=/* @__PURE__ */new Map;if(t!==null&&!t.withheld)for(let e of t.encounters){let t=e.clinicName?.trim();e.docId!==null&&t&&r.set(e.docId,t)}return Object.values(e.documents).sort((e,t)=>(Im(t.receivedAt)??0)-(Im(e.receivedAt)??0)).slice(0,4).reverse().map(e=>{let t=Im(e.receivedAt);return{key:e.docId,name:r.get(e.docId)??gb.uploadedDocument,meta:[e.documentClass?vb(e.documentClass):null,t!==null?mb(t):null].filter(e=>e!==null).join(" · ")}})}var kb=["January","February","March","April","May","June","July","August","September","October","November","December"];function xb(e){let t=new Date(e);return`${kb[t.getUTCMonth()]??""} ${t.getUTCDate()}`}function Tb(e,t){if(t===null||e===null||e.withheld)return null;let r=new Date(t).toISOString().slice(0,10),n=e.encounters.find(e=>{let t=Im(e.date);return t!==null&&new Date(t).toISOString().slice(0,10)===r}),i=n?.veterinarian?.trim(),l=Im(n?.date);return i&&l!==null?{vet:i,date:xb(l)}:null}function _b(e,t){let r=gb;return tb(Tm(e,null),t).map(t=>t.key==="upload"?{...t,text:r.readingUpload}:t.key.startsWith("clinic-")?{...t,text:r.onTheWayFrom(e,t.key.slice(7))}:t)}function Cb(e){let t={url:e.url,kind:e.kind,expiresAt:e.expires_at};return typeof e.loop_duration_ms=="number"&&(t.loopDurationMs=e.loop_duration_ms),typeof e.cache_key=="string"&&e.cache_key.length>0&&(t.cacheKey=e.cache_key),/* @__PURE__ */Object.freeze(t)}function mapPetStateResponse(e){let t={};e.tiers.animation&&(t.animation=Cb(e.tiers.animation)),e.tiers.image&&(t.image=Cb(e.tiers.image));let r={};e.overlays.weather_alert&&(r.weatherAlert=Cb(e.overlays.weather_alert));let n={category:e.category,tiers:/* @__PURE__ */Object.freeze(t),overlays:/* @__PURE__ */Object.freeze(r),idle:"bundled",ttlSeconds:e.ttl_seconds,degraded:e.degraded};return typeof e.cache_epoch=="number"&&(n.cacheEpoch=e.cache_epoch),/* @__PURE__ */Object.freeze(n)}var Rb=/* @__PURE__ */u.enum(["webp","video"]),Sb=/* @__PURE__ */u.enum(["health","attention","moment","activity","mood","idle"]),zb=/* @__PURE__ */u.object({url:/* @__PURE__ */u.string(),kind:/* @__PURE__ */Rb.default("webp"),loop_duration_ms:/* @__PURE__ */u.number().nullish(),expires_at:/* @__PURE__ */u.string(),cache_key:/* @__PURE__ */u.string().nullish()}),Ib=/* @__PURE__ */u.object({category:Sb,tiers:/* @__PURE__ */u.object({animation:/* @__PURE__ */zb.nullish(),image:/* @__PURE__ */zb.nullish()}).default({}),overlays:/* @__PURE__ */u.object({weather_alert:/* @__PURE__ */zb.nullish()}).default({}),idle:/* @__PURE__ */u.literal("bundled").default("bundled"),ttl_seconds:/* @__PURE__ */u.number(),degraded:/* @__PURE__ */u.boolean().default(false),cache_epoch:/* @__PURE__ */u.number().default(0)});function parsePetStateWire(e){let t=Ib.safeParse(e);return t.success?t.data:null}function createPetStateRepository(e){return Db(createRequestFunnel({auth:e}))}function Db(e){return{async getState(petRef,t){if(cr(petRef))return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}));let r=`/widget/v1/pets/${encodeURIComponent(petRef)}/state`,n=await e.send("animations.getState",t?.signal?{method:"GET",path:r,signal:t.signal}:{method:"GET",path:r},t?.maxAttempts!==void 0?{maxAttempts:t.maxAttempts}:void 0);if(n.ok){let e=parsePetStateWire(n.value);return e===null?err(makeEverfurError("internalError",{retryable:true})):ok(mapPetStateResponse(e))}return n.error.httpStatus===404?ok(null):err(n.error)}}}var Hb=/* @__PURE__ */Object.freeze({status:"loading"}),Lb=/* @__PURE__ */Object.freeze({status:"none"}),Pb=3e4,Ob=/* @__PURE__ */Object.freeze([2e3,6e3]),$b=/* @__PURE__ */Object.freeze({animation:false,image:false});function Bb(e,t,r){if(e.kind==="pending")return Hb;if(e.kind==="failed"||e.value===null)return Lb;let{animation:n,image:i}=e.value.tiers;return n!==void 0&&n.kind==="webp"&&!r&&!t.animation?{status:"art",url:n.url,key:n.cacheKey??n.url,animated:true}:i!==void 0&&i.kind==="webp"&&!t.image?{status:"art",url:i.url,key:i.cacheKey??i.url,animated:false}:Lb}function jb(petRef,e){let t=s(zr),a=t?.runtime??null,userRef=t?.userRef??null,d=a!==null&&userRef!==null&&petRef!==null?`${userRef}|${petRef}`:null,[c,u]=i({scope:d,read:{kind:"pending"}}),[h,p]=i({scope:d,failed:$b}),[g,f]=i({scope:d,at:0}),m=c.scope===d?c.read:{kind:"pending"},b=m.kind==="answer"&&m.value===null,y=r({scope:d,n:0});o(()=>{if(d===null||a===null||userRef===null||petRef===null||!e.isFocused||b)return;let t=g.scope===d?g.at:0,r=true,n=typeof AbortController=="function"?new AbortController:null,i=()=>{createPetStateRepository(a.registry.services.authFor(userRef)).getState(petRef,n?{signal:n.signal,maxAttempts:1}:{maxAttempts:1}).then(e=>{if(!r)return;if(e.ok){y.current={scope:d,n:0};let t=e.value;u(e=>t!==null&&t.degraded&&e.scope===d&&e.read.kind==="answer"&&e.read.value!==null?e:{scope:d,read:{kind:"answer",value:t}}),t!==null&&(t.degraded||p({scope:d,failed:$b}),f({scope:d,at:Date.now()+Math.max(30,t.ttlSeconds)*1e3}));return}if(e.error.httpStatus===403){u({scope:d,read:{kind:"answer",value:null}});return}let t=y.current.scope===d?y.current.n:0,n=Ob[t];y.current={scope:d,n:t+1},u(e=>e.scope===d&&e.read.kind==="answer"?e:n!==void 0?{scope:d,read:{kind:"pending"}}:{scope:d,read:{kind:"failed"}}),f({scope:d,at:Date.now()+(n??Pb)})})},l=Math.max(0,t-Date.now()),o=l===0?null:setTimeout(i,l);return o===null&&i(),()=>{r=false,o!==null&&clearTimeout(o),n?.abort()}},[d,a,userRef,petRef,e.isFocused,b,g]);let v=h.scope===d?h.failed:$b,w=n(()=>d===null?Lb:Bb(m,v,e.reducedMotion),[d,m,v,e.reducedMotion]),k=l(()=>{w.status==="art"&&p(e=>{let t=e.scope===d?e.failed:$b;return{scope:d,failed:w.animated?{...t,animation:true}:{...t,image:true}}})},[w,d]);return n(()=>({art:w,onError:k}),[w,k])}var Ab=/* @__PURE__ */Object.freeze({temperature:"Temperature",heartRate:"Heart rate",breathing:"Breathing",vitalsLabel:e=>`Vitals at ${e}’s last exam`,vitalLabel:(e,t,r,n=true)=>`${e}, ${t} ${r}.${n?" More about it":""}`,sayLine:"I wonder what I may be hiding",sayPhrases:["Hmmm","I wonder","what I may be","hiding"],upcomingCare:"Upcoming Care",viewAll:"View all →",dueSoon:"Due soon",later:"Later",nothingDue:e=>`Nothing due for ${e} right now.`,overdueBy:e=>`Overdue by ${e} ${e===1?"day":"days"}`,dueToday:"Due today",dueIn:e=>`Due in ${e} ${e===1?"day":"days"}`,noDueDate:"No due date on file",withDue:(e,t)=>`${e} · due ${t}`,dueOn:e=>`Due ${e}`,thisDay:(e,t)=>`${e} · this ${t}`,inWeeks:(e,t)=>`${e} · in ${t} ${t===1?"week":"weeks"}`,recordsHistory:"Records & History",labs:"Labs & bloodwork",labsA11y:(e,t)=>`Labs and bloodwork, ${e} ${t}`,labsA11yUnknown:"Labs and bloodwork",labsCountUnknown:"--",screenings:"Screenings",screeningsA11y:e=>`Screenings${e!==null?`, ${e}`:""}`,toReview:e=>`${e} to review`,allClear:"All clear",visits:"Visits & records",visitsA11y:e=>`Visits and records${e!==null?`, latest ${e}`:""}`,timeline:"Timeline",events:e=>`${e} events`,timelineA11y:e=>`Timeline${e>0?`, ${e} events`:""}`,weight:"Weight",estimatedRange:"Estimated Optimal Adult Range",noWeights:e=>`No weights on file yet. They show up here from ${e}’s vet visits.`,legendOver:["OVER","WEIGHT"],legendStable:["STABLE"],legendUnder:["UNDER","WEIGHT"],trendSummary:(e,t,r,n,i)=>`${e===1?"1 reading":`${e} readings`}, latest ${t}${e===1?"":`, trend ${r}`}.${n!==null&&i!==null?` Healthy range ${n} to ${i}.`:""}`,pointLabel:(e,t,r)=>e!==null?`${e}, ${t} ${r}`:`${t} ${r}`,addRecords:e=>`Add ${e}’s records`,moreThanOneClinic:"Records can come from more than one clinic over a lifetime.",onFileNow:"On file now",videoVisit:"Everfur video visit",requestFromClinic:"Request from a clinic",uploadDocument:"Upload a document",onTheWay:e=>`${e}’s records are on the way`,clinicsTake:"Clinics usually take 2 to 5 days.",requestSentTo:e=>e!==null?`Request sent to ${e}`:"Request sent",signedRelease:e=>`${e} · you signed the release`,waitingFor:e=>`Waiting for ${e} records`,inHealthTab:e=>`In ${e} Health tab`,everyPageRead:"Every page read: vaccines, labs, visits, meds",today:"Today",anotherClinic:"Another clinic",anotherClinicText:"Seen more than one vet? We ask each one.",uploadText:"A PDF, or a photo of a paper record.",requestTitle:e=>`${e}’s records request`,requestA11y:(e,t)=>`Records request for ${e}. ${t}`,sample:"Sample",peekLead:e=>`A sneak peek at how ${e}’s records will read. Every number links back to the page it came from.`,previousGroup:"Previous group",nextGroup:"Next group",markerGroups:"Marker groups",sampleNotTheirs:e=>`This is a sample, not ${e}’s result.`,sampleNote:e=>` Add ${e} records to see ${e} own numbers. Anything outside the range gets flagged like this, with what it measures and what to ask ${e} vet.`,columns:["Test","Result","Unit","Range"],slideOf:(e,t,r)=>`${e}, ${t} of ${r}`,high:"High",legal:Yn,noVetTitle:e=>`When ${e.name} has a vet, start here.`});function Eb(e){let t=Math.floor(e/12),r=e%12;return t<=0?`${r}m`:r>0?`${t}y ${r}m`:`${t}y`}var Fb={cap:"Read from the lab report, page 2",who:"Chemistry panel",page:"p. 2 of 12"},qb=/* @__PURE__ */Object.freeze([{key:"liver",chip:"Liver",lead:"What the liver makes and clears.",markers:[{name:"ALT",flag:"High",what:"An enzyme found mostly in liver cells.",at:92,value:"118",unit:"U/L"},{name:"ALP",what:"An enzyme from the liver and bones.",at:33,value:"64",unit:"U/L"},{name:"GGT",what:"An enzyme tied to the liver’s bile ducts.",at:36,value:"3",unit:"U/L"},{name:"Total bilirubin",what:"A yellow pigment the liver clears.",at:33,value:"0.2",unit:"mg/dL"}],from:{...Fb,rows:[{test:"ALB",result:"3.2",unit:"g/dL",range:"2.3-4.0"},{test:"ALP",result:"64",unit:"U/L",range:"23-212",lit:true},{test:"ALT",result:"118 H",unit:"U/L",range:"10-100",lit:true},{test:"BUN",result:"18",unit:"mg/dL",range:"7-27"},{test:"GGT",result:"3",unit:"U/L",range:"0-11",lit:true},{test:"T. BILI",result:"0.2",unit:"mg/dL",range:"0.0-0.9",lit:true}]}},{key:"kidney",chip:"Kidney",lead:"What the kidneys filter out and keep in balance.",markers:[{name:"BUN",what:"Protein waste the kidneys filter out.",at:53,value:"18",unit:"mg/dL"},{name:"Creatinine",what:"Muscle waste the kidneys filter out.",at:48,value:"1.1",unit:"mg/dL"},{name:"SDMA",what:"Another measure of kidney filtering.",at:59,value:"9",unit:"µg/dL"},{name:"Phosphorus",what:"A mineral the kidneys keep in balance.",at:42,value:"4.1",unit:"mg/dL"}],from:{...Fb,rows:[{test:"ALT",result:"45",unit:"U/L",range:"10-100"},{test:"BUN",result:"18",unit:"mg/dL",range:"7-27",lit:true},{test:"CA",result:"10.1",unit:"mg/dL",range:"7.9-12.0"},{test:"CREA",result:"1.1",unit:"mg/dL",range:"0.5-1.8",lit:true},{test:"PHOS",result:"4.1",unit:"mg/dL",range:"2.5-6.8",lit:true},{test:"SDMA",result:"9",unit:"µg/dL",range:"0-14",lit:true}]}},{key:"blood",chip:"Blood cells",lead:"The cells that carry oxygen, fight infection and help blood clot.",markers:[{name:"Red blood cells",what:"Cells that carry oxygen around the body.",at:43,value:"6.9",unit:"M/µL"},{name:"Hemoglobin",what:"The part of red cells that holds oxygen.",at:42,value:"15.8",unit:"g/dL"},{name:"White blood cells",what:"Cells that fight infection.",at:44,value:"9.8",unit:"K/µL"},{name:"Platelets",what:"Cell fragments that help blood clot.",at:41,value:"265",unit:"K/µL"}],from:{cap:"Read from the lab report, page 3",who:"Complete blood count",page:"p. 3 of 12",rows:[{test:"HCT",result:"46",unit:"%",range:"37.3-61.7"},{test:"HGB",result:"15.8",unit:"g/dL",range:"13.1-20.5",lit:true},{test:"NEUT",result:"6.1",unit:"K/µL",range:"2.95-11.64"},{test:"PLT",result:"265",unit:"K/µL",range:"148-484",lit:true},{test:"RBC",result:"6.9",unit:"M/µL",range:"5.65-8.87",lit:true},{test:"WBC",result:"9.8",unit:"K/µL",range:"5.05-16.76",lit:true}]}},{key:"sugar",chip:"Sugar and salts",lead:"Fuel, and the salts that keep fluids, nerves and muscles steady.",markers:[{name:"Glucose",what:"Blood sugar, the body’s main fuel.",at:41,value:"96",unit:"mg/dL"},{name:"Sodium",what:"A salt that keeps fluids in balance.",at:31,value:"147",unit:"mmol/L"},{name:"Potassium",what:"A salt that helps nerves and muscles work.",at:49,value:"4.6",unit:"mmol/L"},{name:"Calcium",what:"A mineral for bones, muscles and nerves.",at:52,value:"10.1",unit:"mg/dL"}],from:{...Fb,rows:[{test:"CA",result:"10.1",unit:"mg/dL",range:"7.9-12.0",lit:true},{test:"CL",result:"112",unit:"mmol/L",range:"109-122"},{test:"GLU",result:"96",unit:"mg/dL",range:"70-143",lit:true},{test:"K",result:"4.6",unit:"mmol/L",range:"3.5-5.8",lit:true},{test:"NA",result:"147",unit:"mmol/L",range:"144-160",lit:true},{test:"PHOS",result:"4.1",unit:"mg/dL",range:"2.5-6.8"}]}}]),Mb=/* @__PURE__ */Object.freeze([{key:"screenings",title:"Screenings",tint:"pink",lead:"Tests that look for common problems early, and what came back.",rows:[{title:"Heartworm test",pill:"Negative",tone:"clear"},{title:"Tick panel (4Dx)",pill:"Negative",tone:"clear"}]},{key:"visits",title:"Visits & records",tint:"blue",lead:"Every visit, with the vet’s notes and the pages they came from.",rows:[{title:"Wellness exam",text:"38 pages"},{title:"Everfur video visit",text:"3 pages"}]},{key:"timeline",title:"Timeline",tint:"yellow",lead:"Her whole history in order, with what’s due next.",rows:[{title:"Rabies vaccine",pill:"Due soon",tone:"soon"},{title:"Heartworm test",text:"Apr 18"}]}]);var Nb=/* @__PURE__ */Object.freeze({ink:"#10462E",go:"#07C168",muted:"#6B6B6B",line:"#E4E4E4",text:"#000000",bg:"#FFFFFF",white:"#FFFFFF",mist:"#F1F5F2",charcoal:"#3D3D3D",alert:"#C03410",alertDeep:"#6D1D14",pink:"#FFC3BC",yellow:"#F2C763",skyBlue:"#4E98C9",tintSage:"#E6ECE8",tintPink:"#FFEAE8",tintPinkSoft:"#FFF6F5",tintBlue:"#EAEEF6",tintYellow:"#FCF0D6",tintYellowEdge:"#F6D892",tintRed:"#FBF1EE",tintGo:"#DCF6EA",icoGrey:"#6B6B6B",icoSage:"#819E90",icoBlue:"#4E98C9",barTrack:"#ECECEC",pillPlainEdge:"rgba(16, 70, 46, 0.2)"}),Wb=/* @__PURE__ */Object.freeze({screenTitle:/* @__PURE__ */Object.freeze({size:22,lineHeight:26.4,face:"medium",color:"ink",letterSpacing:-.33}),cardTitle:/* @__PURE__ */Object.freeze({size:18,lineHeight:22.5,face:"bold",color:"ink",letterSpacing:-.36}),body:/* @__PURE__ */Object.freeze({size:17,lineHeight:26.35,face:"regular",color:"text",letterSpacing:0}),bodySm:/* @__PURE__ */Object.freeze({size:15,lineHeight:21.75,face:"regular",color:"text",letterSpacing:0}),bodySmBold:/* @__PURE__ */Object.freeze({size:15,lineHeight:21.75,face:"bold",color:"ink",letterSpacing:0}),fine:/* @__PURE__ */Object.freeze({size:13,lineHeight:18.2,face:"regular",color:"muted",letterSpacing:0}),labelMono:/* @__PURE__ */Object.freeze({size:12,lineHeight:16.8,face:"monoBold",color:"muted",letterSpacing:.72,upper:true}),pill:/* @__PURE__ */Object.freeze({size:12,lineHeight:14.4,face:"monoBold",color:"ink",letterSpacing:.72,upper:true}),button:/* @__PURE__ */Object.freeze({size:15,lineHeight:18,face:"bold",color:"ink",letterSpacing:0}),buttonRow:/* @__PURE__ */Object.freeze({size:14,lineHeight:16.8,face:"bold",color:"ink",letterSpacing:0}),chip:/* @__PURE__ */Object.freeze({size:14,lineHeight:16.8,face:"medium",color:"ink",letterSpacing:0}),hand:/* @__PURE__ */Object.freeze({size:22,lineHeight:26.4,face:"hand",color:"ink",letterSpacing:0})}),Ub=/* @__PURE__ */Object.freeze({surface:"#FFFFFF",textPrimary:"#111111",textMuted:"#6E6660",border:"#C8BEB4",brand:"#10462E",brandSoft:"rgba(16, 70, 46, 0.1)",danger:"#B91C1C"}),Gb=/* @__PURE__ */Object.freeze({dot:24,check:12,core:10,ring:2,rowGap:12,bodyBottom:18,bodyGap:2,titleGap:8,rail:2,railMin:22,railGap:2,titleSize:14,titleLineHeight:18,dateSize:12,dateLineHeight:16,detailSize:13,detailLineHeight:17,upcomingOpacity:.7});var Vb=/* @__PURE__ */Object.freeze({screen:{gap:12,padX:16,padBottom:24,legalTop:20},hero:{nameSize:22,nameLineHeight:26,nameTracking:-.44,metaTop:2,metaLineHeight:18,metaTracking:.26,stageHeight:280,stageTop:4,grassFraction:.46,petBottom:40,petBoxHeight:224,petTop:16,sayWidth:230,sayHeight:61,sayFontSize:22,sayArcPath:"M 12 60 Q 120 -4 228 60",sayViewBox:[240,64],vitalsTop:8,vitalsLeft:8,vitalMinHeight:40,vitalPadX:8,vitalGap:6,vitalIcon:22,vitalValueSize:17,vitalUnitSize:13,lawnOverlap:26,lawnRadius:28},card:{pad:16,radius:20,border:1,headGap:8,headBottom:12},button:{md:52,sm:46,row:36,padMd:24,padSm:16,padRow:14,iconMd:22,iconSm:20,iconRow:17,edge:1.5,gap:8,mdLabel:17,textGap:6,textMinHeight:24},pill:{minHeight:24,padX:10,edgeThin:1.25,edgeThick:1.5},upcoming:{listGap:4,bleed:8,rowPadY:10,rowPadX:8,rowGap:12,rowRadius:10,icon:20,maxRows:4},tiles:{top:8,titleBottom:12,gap:12,pad:16,radius:20,innerGap:8,icon:22,chevron:20,titleLineHeight:19,footMinHeight:28,numSize:20,numLineHeight:22,numTracking:-.4,countGap:8},weight:{headGap:4,headBottom:16,numSize:32,numLineHeight:34,numTracking:-.64,numGap:8},chart:{height:176,plotTop:24,axisBand:20,rightInset:14,indicatorWidth:8,plotLeft:62,dataLeft:76,dot:6,dotRing:1.5,lineWidth:2,labelGap:7,labelMax:12,labelMin:9,labelCharWidth:.62,edgePad:4,legendX:14,legendLine:14.4,legendSize:12,legendTracking:.24,monthY:172,monthSize:12,maxTicks:5,maxValues:8,bandFrom:.3,bandTo:.7,reach:.88,bandPct:.1,lineColor:"#111111",gridColor:"#EAEAEA",bandColor:"#D8F3E3"},add:{gap:12,headGap:8,icon:26,sourcesGap:6,sourcesTop:4,sourcePadY:10,sourcePadX:14,sourceRadius:10,sourceColumnGap:12,actsGap:12,actsTop:4},peek:{top:12,headGap:12,leadTop:8,labsTop:16,chipsTop:10,chipsGap:8,slideTop:16,slideGap:4,slideLeadTop:2,slideLeadBottom:8,markerPad:12,markerGap:8,markerRadius:10,markerTopGap:12,barHeight:8,barDot:12,barDotRing:2,valueGap:4,fromMinHeight:40,fromGap:6,fromIcon:16,fromChevron:18,moreGap:12,moreTop:16,morePad:16,moreInnerGap:12,moreRadius:20,moreIcon:22,moreHeadGap:8,rowsGap:6,rowMinHeight:44,rowPadY:8,rowPadX:14,rowRadius:10,roundButton:36,chipHeight:36,chipPadX:14},onTheWay:{dot:28,titleSize:22,titleLineHeight:25,titleTracking:-.44,wayIcon:26,wayPad:16,wayRadius:20},inProgress:{radius:18,pad:18,gap:16,titleSize:16,titleLineHeight:20,statusRadius:14,statusPad:14,statusSize:13,statusLineHeight:19}});var Kb=/* @__PURE__ */new WeakMap;function Yb(e){let t=Kb.get(e);if(t!==void 0)return t;let r=e.slots.primaryButton,n=/* @__PURE__ */Object.freeze({card:{borderRadius:e.radius.lg,...Bn(An(e.slots),1)},button:r===void 0?null:Bn(r),buttonInk:r?.textColor,radius:r?.borderRadius===void 0?null:{borderRadius:r.borderRadius}});return Kb.set(e,n),n}function Xb(){let e=useEverfurTheme();return n(()=>Yb(e),[e])}function Qb(e){let t=recordsSheetLook(e);if(t.dark)/* @__PURE__ */
765
765
  return Object.freeze({dark:true,bg:t.ground,white:t.card,text:t.text,muted:t.muted,line:t.line,charcoal:t.muted,ink:t.ink,fill:t.fill,onFill:t.onFill,accentOnFill:t.accentOnFill,go:t.go,alert:t.alert,alertDeep:t.alertDeep,yellow:t.watch,tintSage:t.tintSage,tintPink:t.tintPartner,tintPinkSoft:t.card,tintBlue:t.tintBlue,tintYellow:t.tintYellow,tintYellowEdge:t.watch,tintRed:t.alertTint,tintGo:t.goTint,icoGrey:t.muted,icoSage:t.chevron,icoBlue:t.wind,barTrack:t.barTrack,pillPlainEdge:t.plainEdge,chartLine:t.text,chartGrid:t.line,chartBand:t.goTint,legacyText:t.text,legacyMuted:t.muted,legacyBorder:t.line,brand:t.ink,brandSoft:Fl(t.ink,.1)??t.tintSage,watch:t.watch,tintPartner:t.tintPartner,mist:t.rowGround});let r=so(e),n=r?Nb.ink:t.ink;/* @__PURE__ */
766
766
  return Object.freeze({dark:false,bg:Nb.bg,white:Nb.white,text:Nb.text,muted:Nb.muted,line:Nb.line,charcoal:Nb.charcoal,ink:n,fill:r?Nb.ink:t.fill,onFill:r?Nb.white:t.onFill,accentOnFill:r?Nb.go:t.accentOnFill,go:Nb.go,alert:Nb.alert,alertDeep:Nb.alertDeep,yellow:Nb.yellow,tintSage:r?Nb.tintSage:t.tintSage,tintPink:r||!co(e)?Nb.tintPink:t.tintPartner,tintPinkSoft:Nb.tintPinkSoft,tintBlue:Nb.tintBlue,tintYellow:Nb.tintYellow,tintYellowEdge:Nb.tintYellowEdge,tintRed:Nb.tintRed,tintGo:Nb.tintGo,icoGrey:Nb.icoGrey,icoSage:r?Nb.icoSage:t.chevron,icoBlue:Nb.icoBlue,barTrack:Nb.barTrack,pillPlainEdge:r?Nb.pillPlainEdge:t.plainEdge,chartLine:Vb.chart.lineColor,chartGrid:Vb.chart.gridColor,chartBand:Vb.chart.bandColor,legacyText:Ub.textPrimary,legacyMuted:Ub.textMuted,legacyBorder:Ub.border,brand:r?Ub.brand:n,brandSoft:r?Ub.brandSoft:Fl(n,.1)??t.tintSage,watch:t.watch,tintPartner:t.tintPartner,mist:t.rowGround})}var Jb=createContext(null);function Zb(e,t){let r=Qb(e),n=r=>r==="hand"?t!==null?{fontFamily:t}:face(e,"regular"):face(e,r),i=/* @__PURE__ */new Map;return{theme:e,look:r,type:e=>{let t=i.get(e);if(t!==void 0)return t;let l=Wb[e],o={...n(l.face),fontSize:l.size,lineHeight:l.lineHeight,color:r[l.color],...l.letterSpacing!==0?{letterSpacing:l.letterSpacing}:{},...l.upper===true?{textTransform:"uppercase"}:{}};return i.set(e,o),o},face:n}}function HubKitProvider({handFamily:e,theme:t,children:r}){let i=useEverfurTheme(),l=t??i,o=n(()=>Zb(l,e),[l,e]);/* @__PURE__ */
767
767
  return B(Jb.Provider,{value:o,children:r})}function ey(){let e=useEverfurTheme(),t=n(()=>Zb(e,null),[e]);return s(Jb)??t}function HubText({variant:e="bodySm",color:t,style:r,children:n,tier:i,...l}){let{type:o}=ey();/* @__PURE__ */
@@ -773,7 +773,7 @@ return B(f,{testID:n,style:[{alignSelf:"flex-start",maxWidth:"100%",borderRadius
773
773
  return j(m,{onPress:t,disabled:t===void 0,accessibilityRole:"button",accessibilityLabel:s??e,...d!==void 0?{accessibilityHint:d}:{},hitSlop:n==="row"||g?4:void 0,style:[l?{alignSelf:"stretch"}:null,w,a],testID:c,children:[i!==void 0?/* @__PURE__ */B(HubIcon,{name:i,size:v,color:f}):null,
774
774
  /* @__PURE__ */B(HubText,{variant:n==="row"?"buttonRow":"button",color:f,numberOfLines:1,style:[n==="md"&&!g?{fontSize:Vb.button.mdLabel}:null,n==="row"?{fontSize:Zl(".efh-btn--row","fontSize"),lineHeight:Zl(".efh-btn--row","fontSize")*1.2}:null,n==="lg"?{fontSize:Zl(".efh-btn","fontSize"),lineHeight:Zl(".efh-btn","fontSize")*1.2}:null,r==="secondary"&&!o?h("regular"):null],children:e})]})}function HubChip({label:e,selected:t,onPress:r,testID:n}){let{look:i}=ey();/* @__PURE__ */
775
775
  return B(m,{onPress:r,hitSlop:4,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{selected:t},style:{flexDirection:"row",alignItems:"center",gap:6,borderRadius:999,minHeight:Vb.peek.chipHeight,paddingHorizontal:Vb.peek.chipPadX,borderWidth:1.5,borderColor:t?i.fill:i.line,backgroundColor:t?i.fill:i.white},testID:n,children:/* @__PURE__ */B(HubText,{variant:"chip",color:t?i.onFill:i.ink,numberOfLines:1,children:e})})}function HubRound({icon:e,rotate:t=0,label:r,disabled:n,onPress:i,testID:l}){let{look:o}=ey(),a=Vb.peek.roundButton;/* @__PURE__ */
776
- return B(m,{onPress:i,disabled:n,hitSlop:4,accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{disabled:n},style:{width:a,height:a,borderRadius:a/2,alignItems:"center",justifyContent:"center",borderWidth:1.5,borderColor:o.ink,backgroundColor:o.white},testID:l,children:/* @__PURE__ */B(HubIcon,{name:e,size:18,style:t!==0?{transform:[{rotate:`${t}deg`}]}:void 0})})}var ry=864e5,ny=30,iy=60,ly=2.20462,oy=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ay=["January","February","March","April","May","June","July","August","September","October","November","December"],sy=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function dy(e){if(e==null||e.trim()==="")return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function cy(e){let t=dy(e);if(t===null)return null;let r=new Date(t),n=r.getUTCFullYear(),i=r.getUTCMonth(),l=r.getUTCDate();return{y:n,m:i,d:l,ms:Date.UTC(n,i,l)}}function uy(e){let t=new Date(e);return{y:t.getFullYear(),ms:Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),weekday:t.getDay()}}function hy(e){let t=Math.round(e*10)/10;return Number.isInteger(t)?String(t):t.toFixed(1)}function py(e,t,r){let n=typeof t=="number"&&Number.isFinite(t)&&t>0?Eb(Math.floor(t*12+1e-9)):null,i=[e?.trim()||null,n,r?.primary??null].filter(e=>e!==null);return i.length>0?i.join(" · "):null}var gy=/* @__PURE__ */Object.freeze({dhpp:"DHPP",dhlpp:"DHLPP",dhppi:"DHPPi",dapp:"DAPP",dap:"DAP",fvrcp:"FVRCP",felv:"FeLV",fiv:"FIV",hw:"HW",bcs:"BCS","4dx":"4DX"});function fy(e){return e.split(/[_\s]+/).filter(Boolean).map(e=>gy[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function my(e){let t=e.toLowerCase();return t.includes("vacc")||t.includes("booster")||t.includes("rabies")||t.includes("dhpp")?"syringe":t.includes("test")||t.includes("screen")||t.includes("fecal")||t.includes("heartworm")||t.includes("worm")?"flask-sm":"calendar"}function by(e,t){let r=/* @__PURE__ */new Map;for(let t of e){let e=t.careItemKey?.trim()||t.title,n=r.get(e),i=dy(t.dueAt),l=n===void 0?null:dy(n.dueAt);(n===void 0||i!==null&&(l===null||i<l))&&r.set(e,t)}let n=uy(t);return[...r.entries()].map(([e,r])=>{let i=cy(r.dueAt),l=r.careItemKey?.trim()?fy(r.careItemKey.trim()):r.title;if(i===null)return{at:Number.POSITIVE_INFINITY,row:{key:e,label:l,when:Ab.noDueDate,tone:"upcoming",icon:my(e),pill:{label:Ab.later,tone:"later"}}};let o=Math.round((dy(r.dueAt)-t)/ry),a=o<0?"overdue":o<=ny?"dueSoon":"upcoming",s=o<0?Ab.overdueBy(-o):o===0?Ab.dueToday:Ab.dueIn(o),d=`${oy[i.m]} ${i.d}`,c=Math.round((i.ms-n.ms)/ry),u;a==="overdue"||c<0?u=Ab.withDue(s,d):c===0?u=s:c<=6?u=new Date(i.ms).getUTCDay()>n.weekday?Ab.thisDay(Ab.dueOn(d),sy[new Date(i.ms).getUTCDay()]):Ab.dueOn(d):c<iy?u=Ab.inWeeks(Ab.dueOn(d),Math.round(c/7)):u=Ab.dueOn(i.y===n.y?ay[i.m]:`${ay[i.m]} ${i.y}`);let h=a==="dueSoon"?{label:Ab.dueSoon,tone:"watch"}:a==="upcoming"?{label:Ab.later,tone:"later"}:null;return{at:i.ms,row:{key:e,label:l,when:u,tone:a,icon:my(e),pill:h}}}).sort((e,t)=>e.at-t.at).slice(0,Vb.upcoming.maxRows).map(e=>e.row)}function yy(e,t,r,n){let i=t!==null&&!t.withheld,l=i?t.summary?.totalMarkers??t.markers.length:0,o=gb.results(l),a=bb(i?t.markers:[]),s=a!==null?{label:a.label,tone:a.flagged?"high":"clear",markerId:a.markerId}:null,d=r!==null&&!r.withheld?r.encounters:[],c=n!==null&&!n.withheld?n.visits:[],u=[...d.map(e=>cy(e.date)),...d.length>0?[]:c.map(e=>cy(e.visitDate))].filter(e=>e!==null).sort((e,t)=>t.ms-e.ms)[0]??null,h=u===null?null:`${String(u.m+1).padStart(2,"0")}.${String(u.d).padStart(2,"0")}.${u.y}`,p=n!==null&&!n.withheld?n.visits.length+n.vaccines.length+n.weights.length+n.medications.length:0,g=e!==null&&!e.withheld?e.entitySeries.filter(e=>/^(medication|problem)[:|]/.test(e.key)&&e.points.length>0).length:0;return{labsTotal:l,labsNoun:o,screeningsPill:s,visitDate:h,timelineCount:p+g}}function vy(e,t,r){let n=t!==null&&!t.withheld?t.weights.filter(e=>e.weightKg!==null&&Number.isFinite(e.weightKg)).map(e=>({kg:e.weightKg,date:e.observedOn})):[],i=e!==null&&!e.withheld?e.entities.filter(e=>e.category==="body_weight"&&e.value!==null).map(e=>{let t=Number(e.value);return{kg:/lb/i.test(e.unit??"")?t/ly:t,date:e.observedAt}}).filter(e=>Number.isFinite(e.kg)&&e.kg>0):[],l=(n.length>0?n:i).slice().sort((e,t)=>(dy(e.date)??0)-(dy(t.date)??0));if(l.length===0)return null;let o=l.map(e=>e.kg),a=null;if(o.length>=2){let e=o.slice().sort((e,t)=>e-t),t=Math.floor(e.length/2),r=e.length%2===1?e[t]:(e[t-1]+e[t])/2;r>0&&(a={lowKg:r*(1-Vb.chart.bandPct),highKg:r*(1+Vb.chart.bandPct)})}let s=l.map(e=>({...e,status:a===null?null:e.kg>a.highKg?"over":e.kg<a.lowKg?"under":"in"})),d=o[o.length-1],c=`${hy(d*ly)} lb`,u=`${hy(d)} kg`,h=l.length===1?Im(l[0].date):null;return{primary:r==="kg"?u:c,secondary:r==="kg"?c:u,unit:r,points:s,band:a,date:h!==null?mb(h):null}}function wy(e){let t=dy(e);if(t===null)return null;let r=new Date(t);return`${r.getUTCMonth()+1}/${String(r.getUTCFullYear()%100).padStart(2,"0")}`}function ky(e){let t=dy(e);if(t===null)return null;let r=new Date(t);return`${r.getUTCMonth()+1}/${r.getUTCFullYear()}`}var xy=(e,t,r)=>Math.max(t,Math.min(r,e));function Ty(e,t,r,n,i){return r==="start"?xy(e,n,Math.max(n,i-t)):r==="end"?xy(e,Math.min(i,n+t),i):xy(e,n+t/2,Math.max(n+t/2,i-t/2))}function Cy(e,t){if(e<=0)return[];if(e<=t)return Array.from({length:e},(e,t)=>t);let r=/* @__PURE__ */new Set;for(let n=0;n<t;n+=1)r.add(Math.round(n*(e-1)/(t-1)));return[...r]}var _y=8,Ry=.82,Sy=2,zy=.6;function Iy(e,t){let r=Vb.chart,n=r.plotTop,i=r.height-r.axisBand,l=i-n,o=t=>e.unit==="kg"?t:t*ly,a=e.points.slice(-36),s=a.map(e=>e.kg),d,c=0,u=0,h=e.band,p=h!==null&&h.highKg>h.lowKg;if(p){let e=(h.highKg+h.lowKg)/2,t=(h.highKg-h.lowKg)/2,i=s.reduce((t,r)=>Math.max(t,Math.abs(r-e)),0),o=Math.max(t/(r.bandTo-r.bandFrom),i/r.reach),a=e+o;d=e=>n+(a-e)/(2*o)*l,c=d(h.highKg),u=d(h.lowKg)}else{let e=Math.min(...s),t=Math.max(...s);e===t&&(e-=1,t+=1);let r=(t-e)*.15;e-=r,t+=r,d=r=>i-(r-e)/(t-e)*l}let g=p?r.dataLeft:64,f=p?r.plotLeft:12,m=t-r.rightInset,b=a.length,y=e=>b<=1?(g+m)/2:g+e/(b-1)*(m-g),v=a.map(e=>hy(o(e.kg))),w=v.reduce((e,t)=>Math.max(e,t.length),1),k=b>1?(m-g)/(b-1):m-g,x=xy(Math.min(r.labelMax,(k-r.edgePad)/(w*r.labelCharWidth)),r.labelMin,r.labelMax),T=a.map((n,l)=>{let o=y(l),a=d(n.kg),s=v[l],c=l===0?"start":l===b-1?"end":"middle",u=x*Ry,h=i-2,p=a+r.dot+r.labelGap+u,g=n.status==="under"&&p<=h,f=xy(g?p:a-r.dot-r.labelGap,Sy+u,h),m=Ty(o,s.length*r.labelCharWidth*x,c,r.edgePad,t-r.edgePad);return{x:o,y:a,status:n.status,label:s,labelX:m,labelAnchor:c,labelBaseline:f,spoken:Ab.pointLabel(ky(n.date),s,e.unit)}}),C=Cy(b,r.maxTicks).flatMap(e=>{let n=p?wy(a[e].date):ky(a[e].date);if(n===null)return[];let i=e===0?"start":e===b-1?"end":"middle";return[{x:Ty(y(e),n.length*zy*r.monthSize,i,r.edgePad,t-r.edgePad),anchor:i,label:n}]}),_=r.legendLine,R=(e,t,n)=>{let l=e*_,o=xy((t+n)/2-l/2,0,Math.max(0,i-l));return Array.from({length:e},(e,t)=>o+t*_+_/2+r.legendSize*.35)},S=p?[{zone:"over",lines:Ab.legendOver,top:n,bottom:c},{zone:"in",lines:Ab.legendStable,top:c,bottom:u},{zone:"under",lines:Ab.legendUnder,top:u,bottom:i}].map(e=>({zone:e.zone,lines:e.lines,baselines:R(e.lines.length,e.top,e.bottom)})):[],z=s.map(o),I=z[z.length-1]??0,D=z[0]??0,H=I>D?"rising":I<D?"falling":"steady",L=Ab.trendSummary(z.length,hy(I),H,p?hy(o(h.lowKg)):null,p?hy(o(h.highKg)):null);return{width:t,hasBand:p,yBandTop:c,yBandBottom:u,plotTop:n,plotBottom:i,plotLeft:f,dataRight:m,cols:a.map((e,t)=>y(t)),dots:T,showValues:b<=_y,valueFont:x,months:C,legend:S,summary:L}}var Dy=3.55,Hy=97,Ly=3;function Py(e){let t=t=>e.unit==="kg"?t:t*ly,r=e.points.slice(-36),n=r.map(e=>e.kg),i=e.band,l=i!==null&&i.highKg>i.lowKg,o;if(l){let e=(i.highKg+i.lowKg)/2,t=(i.highKg-i.lowKg)/2;o=r=>50-(r-e)/(2*t)*50}else{let e=Math.min(...n),t=Math.max(...n);e===t&&(e-=1,t+=1),o=r=>90-(r-e)/(t-e)*80}let a=r.length,s=e=>a<=1?50:Dy+e/(a-1)*(Hy-Dy),d=e=>a<=1?null:e===0?"start":e===a-1?"end":null,c=r.map(e=>e.status==="over"||e.status==="under"||l&&(e.kg>i.highKg||e.kg<i.lowKg)),u=n.map(t),h=u[u.length-1]??0,p=u[0]??0,g=h>p?"rising":h<p?"falling":"steady";return{hasBand:l,points:r.map((e,r)=>({x:s(r),y:xy(o(e.kg),Ly,100-Ly),label:hy(t(e.kg)),out:c[r],edge:d(r)})),allValues:a<=_y,ticks:Cy(a,Vb.chart.maxTicks).flatMap(e=>{let t=wy(r[e].date);return t===null?[]:[{x:s(e),label:t,edge:d(e)}]}),legend:[Ab.legendOver.join(" "),Ab.legendStable.join(" "),Ab.legendUnder.join(" ")],summary:Ab.trendSummary(u.length,hy(h),g,l?hy(t(i.lowKg)):null,l?hy(t(i.highKg)):null)}}function Oy(e,t){return wb(e,t).map(e=>({key:e.key,name:e.name,meta:e.meta.length>0?e.meta:null}))}function $y(e){let t=dy(e);if(t===null)return null;let r=new Date(t);return`${oy[r.getMonth()]} ${r.getDate()}, ${r.getFullYear()}`}var By=typeof __EVERFUR_SDK_VERSION__=="string"&&__EVERFUR_SDK_VERSION__.length>0?__EVERFUR_SDK_VERSION__:Et,jy=typeof __EVERFUR_CDN_ORIGIN__=="string"&&__EVERFUR_CDN_ORIGIN__.length>0?__EVERFUR_CDN_ORIGIN__:"https://sdk.everfur.com",Ay=`${jy}/${By}/assets/grass.webp`;var Ey=/* @__PURE__ */Object.freeze({uri:Ay}),Fy=null,EASE_OUT=e=>(Fy??=P.bezier(.23,1,.32,1))(e);function qy(e,t){let n=t?1:0,i=r(new H.Value(n)).current,l=r(new H.Value(n)).current,a=r(new H.Value(n)).current,s=r(new H.Value(n)).current,d=r(t);o(()=>{if(t){for(let e of[i,l,a,s])e.setValue(1);return}if(d.current)return;d.current=true;let e=(e,t,r=0)=>H.timing(e,{toValue:1,duration:t,delay:r,easing:EASE_OUT,useNativeDriver:true}),r=H.parallel([e(i,400,60),e(l,700,60),e(a,820),e(s,360)]);return r.start(),()=>r.stop()},[t,i,l,a,s]);let c=r(null);if(c.current===null||c.current.pet.opacity!==i){let t=a.interpolate({inputRange:[0,1],outputRange:[.35,1]}),r=a.interpolate({inputRange:[0,1],outputRange:[e*.65/2,0]});c.current={pet:{opacity:i,transform:[{translateY:l.interpolate({inputRange:[0,1],outputRange:[16,0]})}]},grass:{opacity:s,transform:[{translateY:r},{scaleY:t}]}}}return c.current}function RiseIn({index:e,reduced:t,children:n}){let i=r(new H.Value(t?1:0)).current;return o(()=>{if(t){i.setValue(1);return}let r=H.timing(i,{toValue:1,duration:400,delay:e*60,easing:EASE_OUT,useNativeDriver:true});return r.start(),()=>r.stop()},[t,e,i]),/* @__PURE__ */B(H.View,{style:{opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[8,0]})}]},children:n})}function HubPetArt({art:e,onError:t,reduced:r}){return e.status!=="art"?null:/* @__PURE__ */B(PetImage,{url:e.url,onError:t,reduced:r},e.key)}function PetImage({url:e,onError:t,reduced:n}){let i=r(new H.Value(0)).current,l=()=>{if(n){i.setValue(1);return}H.timing(i,{toValue:1,duration:200,easing:EASE_OUT,useNativeDriver:true}).start()};/* @__PURE__ */
776
+ return B(m,{onPress:i,disabled:n,hitSlop:4,accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{disabled:n},style:{width:a,height:a,borderRadius:a/2,alignItems:"center",justifyContent:"center",borderWidth:1.5,borderColor:o.ink,backgroundColor:o.white},testID:l,children:/* @__PURE__ */B(HubIcon,{name:e,size:18,style:t!==0?{transform:[{rotate:`${t}deg`}]}:void 0})})}var ry=864e5,ny=30,iy=60,ly=2.20462,oy=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ay=["January","February","March","April","May","June","July","August","September","October","November","December"],sy=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function dy(e){if(e==null||e.trim()==="")return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function cy(e){let t=dy(e);if(t===null)return null;let r=new Date(t),n=r.getUTCFullYear(),i=r.getUTCMonth(),l=r.getUTCDate();return{y:n,m:i,d:l,ms:Date.UTC(n,i,l)}}function uy(e){let t=new Date(e);return{y:t.getFullYear(),ms:Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),weekday:t.getDay()}}function hy(e){let t=Math.round(e*10)/10;return Number.isInteger(t)?String(t):t.toFixed(1)}function py(e,t,r){let n=typeof t=="number"&&Number.isFinite(t)&&t>0?Eb(Math.floor(t*12+1e-9)):null,i=[e?.trim()||null,n,r?.primary??null].filter(e=>e!==null);return i.length>0?i.join(" · "):null}var gy=/* @__PURE__ */Object.freeze({dhpp:"DHPP",dhlpp:"DHLPP",dhppi:"DHPPi",dapp:"DAPP",dap:"DAP",fvrcp:"FVRCP",felv:"FeLV",fiv:"FIV",hw:"HW",bcs:"BCS","4dx":"4DX"});function fy(e){return e.split(/[_\s]+/).filter(Boolean).map(e=>gy[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function my(e){let t=e.toLowerCase();return t.includes("vacc")||t.includes("booster")||t.includes("rabies")||t.includes("dhpp")?"syringe":t.includes("test")||t.includes("screen")||t.includes("fecal")||t.includes("heartworm")||t.includes("worm")?"flask-sm":"calendar"}function by(e,t){let r=/* @__PURE__ */new Map;for(let t of e){let e=t.careItemKey?.trim()||t.title,n=r.get(e),i=dy(t.dueAt),l=n===void 0?null:dy(n.dueAt);(n===void 0||i!==null&&(l===null||i<l))&&r.set(e,t)}let n=uy(t);return[...r.entries()].map(([e,r])=>{let i=cy(r.dueAt),l=r.careItemKey?.trim()?fy(r.careItemKey.trim()):r.title;if(i===null)return{at:Number.POSITIVE_INFINITY,row:{key:e,label:l,when:Ab.noDueDate,tone:"upcoming",icon:my(e),pill:{label:Ab.later,tone:"later"}}};let o=Math.round((dy(r.dueAt)-t)/ry),a=o<0?"overdue":o<=ny?"dueSoon":"upcoming",s=o<0?Ab.overdueBy(-o):o===0?Ab.dueToday:Ab.dueIn(o),d=`${oy[i.m]} ${i.d}`,c=Math.round((i.ms-n.ms)/ry),u;a==="overdue"||c<0?u=Ab.withDue(s,d):c===0?u=s:c<=6?u=new Date(i.ms).getUTCDay()>n.weekday?Ab.thisDay(Ab.dueOn(d),sy[new Date(i.ms).getUTCDay()]):Ab.dueOn(d):c<iy?u=Ab.inWeeks(Ab.dueOn(d),Math.round(c/7)):u=Ab.dueOn(i.y===n.y?ay[i.m]:`${ay[i.m]} ${i.y}`);let h=a==="dueSoon"?{label:Ab.dueSoon,tone:"watch"}:a==="upcoming"?{label:Ab.later,tone:"later"}:null;return{at:i.ms,row:{key:e,label:l,when:u,tone:a,icon:my(e),pill:h}}}).sort((e,t)=>e.at-t.at).slice(0,Vb.upcoming.maxRows).map(e=>e.row)}function yy(e,t,r,n){let i=t!==null&&!t.withheld,l=i?t.summary?.totalMarkers??t.markers.length:0,o=gb.results(l),a=bb(i?t.markers:[]),s=a!==null?{label:a.label,tone:a.flagged?"high":"clear",markerId:a.markerId}:null,d=r!==null&&!r.withheld?r.encounters:[],c=n!==null&&!n.withheld?n.visits:[],u=[...d.map(e=>cy(e.date)),...d.length>0?[]:c.map(e=>cy(e.visitDate))].filter(e=>e!==null).sort((e,t)=>t.ms-e.ms)[0]??null,h=u===null?null:`${String(u.m+1).padStart(2,"0")}.${String(u.d).padStart(2,"0")}.${u.y}`,p=n!==null&&!n.withheld?n.visits.length+n.vaccines.length+n.weights.length+n.medications.length:0,g=e!==null&&!e.withheld?e.entitySeries.filter(e=>/^(medication|problem)[:|]/.test(e.key)&&e.points.length>0).length:0;return{labsTotal:l,labsNoun:o,screeningsPill:s,visitDate:h,timelineCount:p+g}}function vy(e,t,r){let n=t!==null&&!t.withheld?t.weights.filter(e=>e.weightKg!==null&&Number.isFinite(e.weightKg)).map(e=>({kg:e.weightKg,date:e.observedOn})):[],i=e!==null&&!e.withheld?e.entities.filter(e=>e.category==="body_weight"&&e.value!==null).map(e=>{let t=Number(e.value);return{kg:/lb/i.test(e.unit??"")?t/ly:t,date:e.observedAt}}).filter(e=>Number.isFinite(e.kg)&&e.kg>0):[],l=(n.length>0?n:i).slice().sort((e,t)=>(dy(e.date)??0)-(dy(t.date)??0));if(l.length===0)return null;let o=l.map(e=>e.kg),a=null;if(o.length>=2){let e=o.slice().sort((e,t)=>e-t),t=Math.floor(e.length/2),r=e.length%2===1?e[t]:(e[t-1]+e[t])/2;r>0&&(a={lowKg:r*(1-Vb.chart.bandPct),highKg:r*(1+Vb.chart.bandPct)})}let s=l.map(e=>({...e,status:a===null?null:e.kg>a.highKg?"over":e.kg<a.lowKg?"under":"in"})),d=o[o.length-1],c=`${hy(d*ly)} lb`,u=`${hy(d)} kg`,h=l.length===1?Im(l[0].date):null;return{primary:r==="kg"?u:c,secondary:r==="kg"?c:u,unit:r,points:s,band:a,date:h!==null?mb(h):null}}function wy(e){let t=dy(e);if(t===null)return null;let r=new Date(t);return`${r.getUTCMonth()+1}/${String(r.getUTCFullYear()%100).padStart(2,"0")}`}function ky(e){let t=dy(e);if(t===null)return null;let r=new Date(t);return`${r.getUTCMonth()+1}/${r.getUTCFullYear()}`}var xy=(e,t,r)=>Math.max(t,Math.min(r,e));function Ty(e,t,r,n,i){return r==="start"?xy(e,n,Math.max(n,i-t)):r==="end"?xy(e,Math.min(i,n+t),i):xy(e,n+t/2,Math.max(n+t/2,i-t/2))}function _y(e,t){if(e<=0)return[];if(e<=t)return Array.from({length:e},(e,t)=>t);let r=/* @__PURE__ */new Set;for(let n=0;n<t;n+=1)r.add(Math.round(n*(e-1)/(t-1)));return[...r]}var Cy=8,Ry=.82,Sy=2,zy=.6;function Iy(e,t){let r=Vb.chart,n=r.plotTop,i=r.height-r.axisBand,l=i-n,o=t=>e.unit==="kg"?t:t*ly,a=e.points.slice(-36),s=a.map(e=>e.kg),d,c=0,u=0,h=e.band,p=h!==null&&h.highKg>h.lowKg;if(p){let e=(h.highKg+h.lowKg)/2,t=(h.highKg-h.lowKg)/2,i=s.reduce((t,r)=>Math.max(t,Math.abs(r-e)),0),o=Math.max(t/(r.bandTo-r.bandFrom),i/r.reach),a=e+o;d=e=>n+(a-e)/(2*o)*l,c=d(h.highKg),u=d(h.lowKg)}else{let e=Math.min(...s),t=Math.max(...s);e===t&&(e-=1,t+=1);let r=(t-e)*.15;e-=r,t+=r,d=r=>i-(r-e)/(t-e)*l}let g=p?r.dataLeft:64,f=p?r.plotLeft:12,m=t-r.rightInset,b=a.length,y=e=>b<=1?(g+m)/2:g+e/(b-1)*(m-g),v=a.map(e=>hy(o(e.kg))),w=v.reduce((e,t)=>Math.max(e,t.length),1),k=b>1?(m-g)/(b-1):m-g,x=xy(Math.min(r.labelMax,(k-r.edgePad)/(w*r.labelCharWidth)),r.labelMin,r.labelMax),T=a.map((n,l)=>{let o=y(l),a=d(n.kg),s=v[l],c=l===0?"start":l===b-1?"end":"middle",u=x*Ry,h=i-2,p=a+r.dot+r.labelGap+u,g=n.status==="under"&&p<=h,f=xy(g?p:a-r.dot-r.labelGap,Sy+u,h),m=Ty(o,s.length*r.labelCharWidth*x,c,r.edgePad,t-r.edgePad);return{x:o,y:a,status:n.status,label:s,labelX:m,labelAnchor:c,labelBaseline:f,spoken:Ab.pointLabel(ky(n.date),s,e.unit)}}),_=_y(b,r.maxTicks).flatMap(e=>{let n=p?wy(a[e].date):ky(a[e].date);if(n===null)return[];let i=e===0?"start":e===b-1?"end":"middle";return[{x:Ty(y(e),n.length*zy*r.monthSize,i,r.edgePad,t-r.edgePad),anchor:i,label:n}]}),C=r.legendLine,R=(e,t,n)=>{let l=e*C,o=xy((t+n)/2-l/2,0,Math.max(0,i-l));return Array.from({length:e},(e,t)=>o+t*C+C/2+r.legendSize*.35)},S=p?[{zone:"over",lines:Ab.legendOver,top:n,bottom:c},{zone:"in",lines:Ab.legendStable,top:c,bottom:u},{zone:"under",lines:Ab.legendUnder,top:u,bottom:i}].map(e=>({zone:e.zone,lines:e.lines,baselines:R(e.lines.length,e.top,e.bottom)})):[],z=s.map(o),I=z[z.length-1]??0,D=z[0]??0,H=I>D?"rising":I<D?"falling":"steady",L=Ab.trendSummary(z.length,hy(I),H,p?hy(o(h.lowKg)):null,p?hy(o(h.highKg)):null);return{width:t,hasBand:p,yBandTop:c,yBandBottom:u,plotTop:n,plotBottom:i,plotLeft:f,dataRight:m,cols:a.map((e,t)=>y(t)),dots:T,showValues:b<=Cy,valueFont:x,months:_,legend:S,summary:L}}var Dy=3.55,Hy=97,Ly=3;function Py(e){let t=t=>e.unit==="kg"?t:t*ly,r=e.points.slice(-36),n=r.map(e=>e.kg),i=e.band,l=i!==null&&i.highKg>i.lowKg,o;if(l){let e=(i.highKg+i.lowKg)/2,t=(i.highKg-i.lowKg)/2;o=r=>50-(r-e)/(2*t)*50}else{let e=Math.min(...n),t=Math.max(...n);e===t&&(e-=1,t+=1),o=r=>90-(r-e)/(t-e)*80}let a=r.length,s=e=>a<=1?50:Dy+e/(a-1)*(Hy-Dy),d=e=>a<=1?null:e===0?"start":e===a-1?"end":null,c=r.map(e=>e.status==="over"||e.status==="under"||l&&(e.kg>i.highKg||e.kg<i.lowKg)),u=n.map(t),h=u[u.length-1]??0,p=u[0]??0,g=h>p?"rising":h<p?"falling":"steady";return{hasBand:l,points:r.map((e,r)=>({x:s(r),y:xy(o(e.kg),Ly,100-Ly),label:hy(t(e.kg)),out:c[r],edge:d(r)})),allValues:a<=Cy,ticks:_y(a,Vb.chart.maxTicks).flatMap(e=>{let t=wy(r[e].date);return t===null?[]:[{x:s(e),label:t,edge:d(e)}]}),legend:[Ab.legendOver.join(" "),Ab.legendStable.join(" "),Ab.legendUnder.join(" ")],summary:Ab.trendSummary(u.length,hy(h),g,l?hy(t(i.lowKg)):null,l?hy(t(i.highKg)):null)}}function Oy(e,t){return wb(e,t).map(e=>({key:e.key,name:e.name,meta:e.meta.length>0?e.meta:null}))}function $y(e){let t=dy(e);if(t===null)return null;let r=new Date(t);return`${oy[r.getMonth()]} ${r.getDate()}, ${r.getFullYear()}`}var By=typeof __EVERFUR_SDK_VERSION__=="string"&&__EVERFUR_SDK_VERSION__.length>0?__EVERFUR_SDK_VERSION__:Et,jy=typeof __EVERFUR_CDN_ORIGIN__=="string"&&__EVERFUR_CDN_ORIGIN__.length>0?__EVERFUR_CDN_ORIGIN__:"https://sdk.everfur.com",Ay=`${jy}/${By}/assets/grass.webp`;var Ey=/* @__PURE__ */Object.freeze({uri:Ay}),Fy=null,EASE_OUT=e=>(Fy??=P.bezier(.23,1,.32,1))(e);function qy(e,t){let n=t?1:0,i=r(new H.Value(n)).current,l=r(new H.Value(n)).current,a=r(new H.Value(n)).current,s=r(new H.Value(n)).current,d=r(t);o(()=>{if(t){for(let e of[i,l,a,s])e.setValue(1);return}if(d.current)return;d.current=true;let e=(e,t,r=0)=>H.timing(e,{toValue:1,duration:t,delay:r,easing:EASE_OUT,useNativeDriver:true}),r=H.parallel([e(i,400,60),e(l,700,60),e(a,820),e(s,360)]);return r.start(),()=>r.stop()},[t,i,l,a,s]);let c=r(null);if(c.current===null||c.current.pet.opacity!==i){let t=a.interpolate({inputRange:[0,1],outputRange:[.35,1]}),r=a.interpolate({inputRange:[0,1],outputRange:[e*.65/2,0]});c.current={pet:{opacity:i,transform:[{translateY:l.interpolate({inputRange:[0,1],outputRange:[16,0]})}]},grass:{opacity:s,transform:[{translateY:r},{scaleY:t}]}}}return c.current}function RiseIn({index:e,reduced:t,children:n}){let i=r(new H.Value(t?1:0)).current;return o(()=>{if(t){i.setValue(1);return}let r=H.timing(i,{toValue:1,duration:400,delay:e*60,easing:EASE_OUT,useNativeDriver:true});return r.start(),()=>r.stop()},[t,e,i]),/* @__PURE__ */B(H.View,{style:{opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[8,0]})}]},children:n})}function HubPetArt({art:e,onError:t,reduced:r}){return e.status!=="art"?null:/* @__PURE__ */B(PetImage,{url:e.url,onError:t,reduced:r},e.key)}function PetImage({url:e,onError:t,reduced:n}){let i=r(new H.Value(0)).current,l=()=>{if(n){i.setValue(1);return}H.timing(i,{toValue:1,duration:200,easing:EASE_OUT,useNativeDriver:true}).start()};/* @__PURE__ */
777
777
  return B(f,{style:{width:"100%",height:"100%"},testID:"everfur-records-sheet-pet-art",children:/* @__PURE__ */B(H.Image,{source:{uri:e},onLoad:l,onError:t,resizeMode:"contain",style:{width:"100%",height:"100%",opacity:i}})})}var My=/* @__PURE__ */Object.freeze({reveal:480,revealFade:320,revealStagger:60,revealMaxSteps:8,revealRiseBlock:14,rollDigits:900,rollDigitStagger:55,chartDraw:850,slideTravel:48,slideMs:320}),Ny=null,HUB_EASE_OUT=e=>(Ny??=P.bezier(.23,1,.32,1))(e);function Wy(e){return Math.min(Math.max(0,e),My.revealMaxSteps-1)*My.revealStagger}function HubReveal({index:e,reduced:t,style:n,testID:i,children:l}){let a=r(new H.Value(t?1:0)).current,s=r(new H.Value(t?1:0)).current,d=r(t);o(()=>{if(t){a.setValue(1),s.setValue(1);return}if(d.current)return;let r=Wy(e),n=H.parallel([H.timing(a,{toValue:1,duration:My.reveal,delay:r,easing:HUB_EASE_OUT,useNativeDriver:true}),H.timing(s,{toValue:1,duration:My.revealFade,delay:r,easing:HUB_EASE_OUT,useNativeDriver:true})]);return n.start(({finished:e})=>{e&&(d.current=true)}),()=>n.stop()},[t,e,a,s]);let c={opacity:s,transform:[{translateY:a.interpolate({inputRange:[0,1],outputRange:[My.revealRiseBlock,0]})}]};/* @__PURE__ */
778
778
  return B(H.View,{style:[n,c],testID:i,children:l})}function Uy(e,t){let n=r(new H.Value(t?1:0)).current,i=r(t);return o(()=>{if(t){n.setValue(1);return}if(!e||i.current)return;let r=H.timing(n,{toValue:1,duration:My.chartDraw,easing:HUB_EASE_OUT,useNativeDriver:true});return r.start(({finished:e})=>{e&&(i.current=true)}),()=>r.stop()},[e,t,n]),n}function Gy(e){let t=e.slice(1).map((t,r)=>Math.hypot(t.x-e[r].x,t.y-e[r].y)),r=t.reduce((e,t)=>e+t,0),n=0;return t.map(e=>{let t=r>0?n/r:0;return n+=e,[t,r>0?n/r:1]})}function Vy(e,t,r){let[n,i]=t,l=i>n?i:n+1e-4,o=e.interpolate({inputRange:[n,l],outputRange:[1e-4,1],extrapolate:"clamp"});return{translateX:e.interpolate({inputRange:[n,l],outputRange:[-r/2,0],extrapolate:"clamp"}),scaleX:o}}function Ky(e,t){return t<=0?0:e[t-1]?.[1]??1}function Yy(e,t){return e.interpolate({inputRange:[t-.0011,t-.001],outputRange:[0,1],extrapolate:"clamp"})}function Xy(e,t){let n=r(e),i=r(new H.Value(0)).current,l=r(new H.Value(1)).current;return o(()=>{let r=Math.sign(e-n.current);if(n.current=e,r===0||t)return;i.setValue(r*My.slideTravel),l.setValue(0);let o=H.parallel([H.timing(i,{toValue:0,duration:My.slideMs,easing:HUB_EASE_OUT,useNativeDriver:true}),H.timing(l,{toValue:1,duration:My.slideMs,easing:HUB_EASE_OUT,useNativeDriver:true})]);return o.start(),()=>o.stop()},[e,t,i,l]),r({opacity:l,transform:[{translateX:i}]}).current}function Qy(e){return Array.from(e,e=>({char:e,digit:/\d/.test(e)?Number(e):null}))}function Jy(e){let t=Math.min(1,Math.max(0,e));return 1-Math.pow(1-t,3)}function HubRollingDigits({text:e,reduced:t,renderText:n,testID:l}){let[a,s]=i(()=>!t&&/\d/.test(e)),d=r(e);return o(()=>{d.current!==e&&s(false)},[e]),o(()=>{t&&s(false)},[t]),a?/* @__PURE__ */j(f,{accessible:true,accessibilityRole:"text",accessibilityLabel:e,children:[
779
779
  /* @__PURE__ */B(f,{style:{opacity:0},importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:true,children:n(e,l!==void 0?{testID:l}:{})}),
@@ -795,7 +795,7 @@ return j(f,{style:a.mk,testID:o,children:[
795
795
  /* @__PURE__ */B(Text,{style:a.mkValue,children:t}),r?/* @__PURE__ */B(Text,{style:a.mkLineText,children:r}):null,n!==null?/* @__PURE__ */B(Text,{style:a.mkLineText,children:`· ${n}`}):null]})]}),i!==null?/* @__PURE__ */j(f,{style:a.mkBar,...lv,children:[
796
796
  /* @__PURE__ */B(f,{style:[a.mkBarIn,{backgroundColor:s.go}]}),
797
797
  /* @__PURE__ */B(f,{style:[a.mkBarDot,{left:`${i}%`,backgroundColor:s.ink,borderColor:s.card}]})]}):null]})}function ChartLine({points:e,color:t}){let[r,n]=i(null),l=e=>{let{width:t,height:i}=e.nativeEvent.layout;(r===null||r.w!==t||r.h!==i)&&n({w:t,h:i})},o=r===null?[]:e.slice(1).map((t,n)=>{let i=e[n]??t,l=i.x/100*r.w,o=i.y/100*r.h,a=t.x/100*r.w,s=t.y/100*r.h,d=Math.hypot(a-l,s-o),c=Math.atan2(s-o,a-l)*180/Math.PI;return{key:n,left:(l+a)/2-d/2,top:(o+s)/2-.75,length:d,angle:c}});/* @__PURE__ */
798
- return B(f,{style:bu,onLayout:l,...lv,children:o.map(e=>/* @__PURE__ */B(f,{style:{position:"absolute",left:e.left,top:e.top,width:e.length,height:1.5,backgroundColor:t,transform:[{rotate:`${e.angle}deg`}]}},e.key))})}function hv(e,t){let r=face(e,"regular"),n=face(e,"bold"),i=headingFace(e,"bold"),l=face(e,"mono"),o=face(e,"monoBold"),a=(e,t)=>fv(e*t);return v.create({scroll:{flexGrow:1},topSlot:{paddingHorizontal:ro.sheetPadX},sheet:{flexGrow:1,gap:ro.gap,paddingTop:ro.sheetPadTop,paddingHorizontal:ro.sheetPadX,paddingBottom:ro.sheetPadBottom,borderTopLeftRadius:ro.sheetRadius,borderTopRightRadius:ro.sheetRadius,backgroundColor:t.ground},sheetUnderSlot:{marginTop:ro.sheetGap},card:{padding:ro.cardPad,backgroundColor:t.card,borderRadius:ro.cardRadius,shadowColor:"#000000",shadowOpacity:t.dark?0:.09,shadowRadius:3,shadowOffset:{width:0,height:1},elevation:t.dark?0:1,borderWidth:t.dark?1:0,borderColor:t.line},cardHead:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:12},cardTitle:{...n,fontSize:ro.cardTitle,lineHeight:a(ro.cardTitle,1.25),letterSpacing:-.36,color:t.ink},cardTitleGap:{marginBottom:12},sec:{marginTop:8,marginBottom:12},head:{marginBottom:Zl(".efh-head","marginBottom")},name:{...i,fontSize:ro.name,lineHeight:a(ro.name,1.2),letterSpacing:-.44,color:t.ink,flexShrink:1},meta:{...r,marginTop:2,fontSize:ro.small,lineHeight:a(ro.small,1.4),letterSpacing:.26,textTransform:"uppercase",color:t.muted},label:{...o,marginTop:Zl(".efh-head__from","marginTop"),fontSize:ro.mono,lineHeight:a(ro.mono,1.4),letterSpacing:.72,textTransform:"uppercase",color:t.muted},vitals:{flexDirection:"row",gap:8,marginTop:8},stage:{position:"relative",height:Zl(".efh-stage","height"),marginTop:Zl(".efh-stage","marginTop"),marginHorizontal:Zl(".efh-stage","marginLeft"),overflow:"hidden"},stageGrass:{position:"absolute",left:0,right:0,bottom:0,height:`${to(".efh-stage__grass","height")*100}%`,overflow:"hidden"},stagePet:{position:"absolute",left:`${to(".efh-stage__pet","left")*100}%`,bottom:Zl(".efh-stage__pet","bottom"),height:ov},stageVitals:{position:"absolute",top:Zl(".efh-stage .efh-vitals","top"),left:Zl(".efh-stage .efh-vitals","left"),gap:Zl(".efh-stage .efh-vitals","gap")},vital:{flex:1,minWidth:0},vitalTop:{flexDirection:"row",alignItems:"center",gap:6},vitalValue:{...n,fontSize:17,lineHeight:a(17,1.2),color:t.ink},vitalUnit:{...r,fontSize:ro.small,color:t.muted},vitalLabel:{...r,marginTop:2,fontSize:ro.small,lineHeight:a(ro.small,1.4),color:t.muted},due:{gap:4,marginHorizontal:-12},dueRow:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:ro.rowRadius},dueText:{flex:1,minWidth:0,gap:2},duePill:{alignSelf:"center"},dueTitle:{...n,fontSize:ro.rowTitle,lineHeight:a(ro.rowTitle,1.3),color:t.ink},dueWhen:{...r,fontSize:ro.small,lineHeight:a(ro.small,1.4),color:t.muted},pill:{minHeight:ro.pill,paddingHorizontal:10,borderRadius:999,alignItems:"center",justifyContent:"center",alignSelf:"flex-start"},pillSmall:{minHeight:22,paddingHorizontal:7},pillText:{...o,fontSize:ro.mono,lineHeight:ro.mono+2,letterSpacing:.72,textTransform:"uppercase"},pillTextSmall:{fontSize:10.5,letterSpacing:.21},tiles:{flexDirection:"row",flexWrap:"wrap",gap:ro.tileGap},tile:{flexGrow:1,flexBasis:"45%",minWidth:0,gap:8,padding:16,borderRadius:ro.cardRadius},tileTop:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between"},tileTitle:{...n,fontSize:ro.body,lineHeight:a(ro.body,1.25),letterSpacing:-.15,color:t.ink},tileFoot:{flexDirection:"row",flexWrap:"wrap",alignItems:"baseline",gap:8,minHeight:28},tileNum:{...n,fontSize:ro.tileNum,lineHeight:ro.tileNum+2,letterSpacing:-.4,color:t.ink},tileUnit:{...r,fontSize:ro.small,color:t.muted},emptyLine:{...r,fontSize:ro.small,lineHeight:a(ro.small,1.5),color:t.muted},wt:{flexDirection:"row",flexWrap:"wrap",alignItems:"baseline",gap:8},wtValue:{...n,fontSize:ro.big,lineHeight:Zl(".efh-wt b","lineHeight"),letterSpacing:-.64,color:t.ink},wtSub:{...r,fontSize:ro.body,color:t.muted},chart:{marginTop:20},plot:{position:"relative",height:ro.plot},point:{position:"absolute",width:12,height:12,marginLeft:-6,marginTop:-6,borderRadius:6,borderWidth:1.5,borderColor:t.card},pointLabel:{...face(e,"medium"),position:"absolute",width:46,marginLeft:-23,textAlign:"center",fontSize:ro.mono,lineHeight:ro.mono+2,color:t.dark?t.text:pv},xAxis:{position:"relative",height:18,marginTop:8},xTick:{...l,position:"absolute",top:0,width:56,marginLeft:-28,textAlign:"center",fontSize:ro.mono,lineHeight:a(ro.mono,1.3),color:t.muted},key:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:6,marginTop:12},keyDot:{width:12,height:12,borderRadius:6,backgroundColor:t.ink},keyText:{...r,fontSize:ro.small,lineHeight:a(ro.small,1.4),color:t.muted},tlKey:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},tlKeyDot:{width:10,height:10,borderRadius:5,borderWidth:2.5,borderColor:t.ink,backgroundColor:t.card},tlYear:{...o,marginTop:20,marginBottom:12,marginLeft:40,fontSize:ro.mono,lineHeight:a(ro.mono,1.4),letterSpacing:.72,textTransform:"uppercase",color:t.muted},tlItem:{position:"relative",flexDirection:"row",gap:16,paddingBottom:24},tlItemLast:{paddingBottom:0},tlRail:{position:"absolute",left:11,top:22,bottom:-2,width:2,borderRadius:1,backgroundColor:t.line},tlRailEnd:{bottom:12},tlDot:{width:16,height:16,marginTop:3,marginHorizontal:4,borderRadius:8,borderWidth:3,borderColor:t.ink,backgroundColor:t.card},tlBody:{flex:1,minWidth:0},tlBtn:{marginTop:-8,marginHorizontal:-8,paddingVertical:8,paddingLeft:8,paddingRight:36,borderRadius:ro.rowRadius,backgroundColor:t.alertTint},tlChevron:{position:"absolute",right:8,top:"50%",marginTop:-10},tlDate:{...l,fontSize:ro.mono,lineHeight:a(ro.mono,1.4),letterSpacing:.48,textTransform:"uppercase",color:t.muted},tlTitle:{...n,marginTop:2,fontSize:ro.rowTitle,lineHeight:a(ro.rowTitle,1.3),color:t.ink},tlText:{...r,marginTop:2,fontSize:ro.body,lineHeight:a(ro.body,1.5),color:t.text},pull:{paddingTop:4,paddingBottom:24,paddingLeft:40},pullStep:{...n,fontSize:ro.body,lineHeight:a(ro.body,1.4),color:t.ink},pullBar:{height:6,marginTop:10,overflow:"hidden",borderRadius:999,backgroundColor:t.line},pullFill:{height:"100%",backgroundColor:t.accent},failed:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:ro.rowRadius,backgroundColor:t.alertTint},failedText:{...n,flex:1,fontSize:ro.body,lineHeight:a(ro.body,1.4),color:t.alertDeep},add:{gap:12},addHead:{flexDirection:"row",alignItems:"center",gap:8},addLead:{...r,fontSize:ro.body,lineHeight:a(ro.body,1.5),color:t.text},sources:{gap:6},source:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",columnGap:12,paddingVertical:10,paddingHorizontal:14,borderRadius:ro.rowRadius,backgroundColor:t.rowGround},sourceLabel:{...r,fontSize:ro.body,lineHeight:a(ro.body,1.4),color:t.text},sourceDetail:{...r,fontSize:ro.small,color:t.muted},addActs:{gap:12,paddingTop:4},button:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,minHeight:ro.button,paddingHorizontal:20,borderRadius:999},buttonRow:{minHeight:ro.rowButton,paddingHorizontal:16},buttonText:{...n,fontSize:16,lineHeight:20},buttonTextRow:{fontSize:ro.body},noneWithScene:{paddingTop:Zl(".efh-none","paddingTop")},scene:{position:"relative",height:Ql.height,marginHorizontal:Zl(".efh-none__scene","marginLeft"),marginBottom:Zl(".efh-none__scene","marginBottom"),overflow:"hidden",borderTopLeftRadius:ro.cardRadius,borderTopRightRadius:ro.cardRadius},sceneGrass:{position:"absolute",left:0,right:0,bottom:0,height:Ql.grassHeight,overflow:"hidden"},scenePet:{position:"absolute",left:"50%",bottom:Ql.petBottom,height:Ql.petHeight},noneTitle:{...i,fontSize:Zl(".efh-none__t","fontSize"),lineHeight:Zl(".efh-none__t","lineHeight"),letterSpacing:Zl(".efh-none__t","letterSpacing"),color:t.ink},noneLead:{...r,marginTop:Zl(".efh-none__lead","marginTop"),fontSize:Zl(".efh-none__lead","fontSize"),lineHeight:Zl(".efh-none__lead","lineHeight"),color:t.text},noneLine:{flexDirection:"row",flexWrap:"wrap",alignItems:"baseline",columnGap:4,marginTop:Zl(".efh-none__lead","marginTop")},noneLineText:{...r,fontSize:Zl(".efh-none__lead","fontSize"),lineHeight:Zl(".efh-none__lead","lineHeight"),color:t.text},noneLink:{...n,fontSize:Zl(".efh-none__lead","fontSize"),lineHeight:Zl(".efh-none__lead","lineHeight"),color:t.ink,textDecorationLine:"underline"},repeatLine:{...n,marginTop:Zl(".efh-ways","gap"),fontSize:Zl(".efh-none__lead","fontSize"),lineHeight:Zl(".efh-none__lead","lineHeight"),color:t.ink},ways:{gap:Zl(".efh-ways","gap"),marginTop:Zl(".efh-ways","marginTop")},way:{flexDirection:"row",alignItems:"center",gap:Zl(".efh-way","columnGap"),padding:Zl(".efh-way","paddingTop"),borderRadius:Zl(".efh-way","borderRadius")},wayText:{flex:1,minWidth:0,gap:Zl(".efh-way__w","gap")},wayTitle:{...n,fontSize:Zl(".efh-way__t","fontSize"),lineHeight:Zl(".efh-way__t","lineHeight")},wayDetail:{...r,fontSize:Zl(".efh-way__x","fontSize"),lineHeight:Zl(".efh-way__x","lineHeight")},tracker:{marginTop:16},step:{flexDirection:"row",gap:16,paddingBottom:20},stepLast:{paddingBottom:0},stepRail:{position:"absolute",left:gv/2-1,top:gv+2,bottom:2,width:2,borderRadius:1,backgroundColor:t.line},stepRailDone:{backgroundColor:t.ink},stepDot:{width:gv,height:gv,borderRadius:gv/2,borderWidth:2,borderColor:t.line,backgroundColor:t.card,alignItems:"center",justifyContent:"center"},stepDotOn:{borderColor:t.ink},stepDotDone:{backgroundColor:t.fill,borderColor:t.fill},stepNow:{width:10,height:10,borderRadius:5,backgroundColor:t.accent},stepText:{flex:1,minWidth:0,paddingTop:3,gap:2},stepTitle:{...n,fontSize:Zl(".efh-mk__name","fontSize"),lineHeight:22,color:t.ink},stepWhen:{...r,fontSize:Zl(".efh-mk__line","fontSize"),lineHeight:Zl(".efh-mk__line","lineHeight"),color:t.muted},peek:{gap:12,marginTop:12},peekHead:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:12},peekLead:{...r,marginTop:-4,fontSize:ro.body,lineHeight:a(ro.body,1.5),color:t.text},peekLabsTitle:{marginBottom:Zl(".efh-peek__labs .efh-card__title","marginBottom")},peekGroup:{marginBottom:Zl(".efh-peek__g","marginBottom")},peekGroupTitle:{...n,fontSize:Zl(".efh-peek__g b","fontSize"),lineHeight:fv(Zl(".efh-peek__g b","fontSize")*(Zl(".efh-peek__g","lineHeight")/Zl(".efh-peek__g","fontSize"))),color:t.ink},peekGroupLead:{...r,fontSize:Zl(".efh-peek__g","fontSize"),lineHeight:Zl(".efh-peek__g","lineHeight"),color:t.muted},more:{gap:10},moreCard:{gap:10,padding:16,borderRadius:ro.cardRadius},moreHead:{flexDirection:"row",alignItems:"center",gap:8},moreTitle:{...n,fontSize:16,lineHeight:a(16,1.3),color:t.ink},moreLead:{...r,fontSize:ro.body,lineHeight:a(ro.body,1.5),color:t.text},moreRows:{gap:6},moreRow:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:44,paddingVertical:8,paddingHorizontal:14,borderRadius:ro.rowRadius,backgroundColor:t.card},moreRowLabel:{...r,flexShrink:1,fontSize:ro.body,lineHeight:a(ro.body,1.4),color:t.text},moreWhen:{...l,fontSize:ro.mono,letterSpacing:.24,color:t.muted},note:{...r,marginTop:Zl(".efh-sheet .rec-note","marginTop"),fontSize:Zl(".rec-note","fontSize"),textAlign:"center",color:t.muted},mks:{gap:2,marginHorizontal:-8},mk:{flexDirection:"row",alignItems:"center",gap:12,paddingVertical:10,paddingHorizontal:8},mkText:{flex:1,minWidth:0},mkNameRow:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:8},mkName:{...n,fontSize:ro.rowTitle,lineHeight:a(ro.rowTitle,1.3),color:t.ink},mkLine:{flexDirection:"row",flexWrap:"wrap",alignItems:"baseline",rowGap:Zl(".efh-mk__line","rowGap"),columnGap:Zl(".efh-mk__line","columnGap"),marginTop:Zl(".efh-mk__line","marginTop")},mkLineText:{...r,fontSize:Zl(".efh-mk__line","fontSize"),lineHeight:Zl(".efh-mk__line","lineHeight"),color:t.muted,fontVariant:["tabular-nums"]},mkValue:{...n,fontSize:Zl(".efh-mk__line b","fontSize"),lineHeight:fv(Zl(".efh-mk__line b","fontSize")*(Zl(".efh-mk__line","lineHeight")/Zl(".efh-mk__line","fontSize"))),color:t.text,fontVariant:["tabular-nums"]},mkBar:{position:"relative",width:96,height:6,borderRadius:999,backgroundColor:t.barTrack},mkBarIn:{position:"absolute",top:0,bottom:0,left:"20%",right:"20%",borderRadius:999},mkBarDot:{position:"absolute",top:-2,width:10,height:10,marginLeft:-5,borderRadius:5,borderWidth:2},topRisk:{gap:Zl(".rec-top","gap"),paddingTop:Zl(".rec-top","paddingTop"),paddingRight:Zl(".rec-top","paddingRight"),paddingBottom:Zl(".rec-top","paddingBottom"),paddingLeft:Zl(".rec-top","paddingLeft"),backgroundColor:t.topFill,borderRadius:Zl(".rec-top","borderRadius"),borderWidth:0,shadowOpacity:0,elevation:0},topRiskKicker:{flexDirection:"row",alignItems:"center",gap:Zl(".rec-top__k","gap")},topRiskDot:{width:8,height:8,borderRadius:4,backgroundColor:t.alert},topRiskK:{...l,fontSize:Zl(".rec-top__k","fontSize"),lineHeight:Zl(".rec-top__k","fontSize")*1.5,letterSpacing:Zl(".rec-top__k","letterSpacing"),textTransform:"uppercase",color:t.topKicker},topRiskText:{...n,fontSize:ro.rowTitle,lineHeight:a(ro.rowTitle,1.35),color:t.topInk},disclaimer:{...r,fontSize:ro.small,lineHeight:a(ro.small,1.5),textAlign:"center",color:t.muted},lab:{gap:ro.gap,paddingTop:8,paddingHorizontal:16,paddingBottom:32,backgroundColor:t.ground},labTitle:{...face(e,"medium"),fontSize:ro.name,lineHeight:a(ro.name,1.2),letterSpacing:-.33,color:t.ink},labMeta:{...l,fontSize:ro.small,lineHeight:a(ro.small,1.45),color:t.muted},latest:{flexDirection:"row",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:4},latestSub:{...r,fontSize:ro.body,color:t.muted},change:{...r,marginTop:12,fontSize:ro.body,color:t.text},changeLead:{...n,color:t.ink},ctx:{gap:12},ctxText:{...r,fontSize:ro.rowTitle,lineHeight:a(ro.rowTitle,1.55),color:t.text},labBody:{flexDirection:"row",gap:8},rail:{width:8,height:ro.plot,overflow:"hidden",borderRadius:2},legend:{width:82,height:ro.plot,position:"relative"},range:{...o,position:"absolute",left:0,right:0,fontSize:ro.mono,lineHeight:a(ro.mono,1.2),letterSpacing:.24,textTransform:"uppercase",color:t.dark?t.text:pv},band:{position:"absolute",left:0,right:0,top:"25%",height:"50%",backgroundColor:t.goTint}})}var pv="#3D3D3D",gv=28,fv=e=>Math.round(e*100)/100;var mv={accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",pointerEvents:"none"},bv=iv(Vb.hero.sayWidth),yv=Zl(".efh-stage","height"),vv=yv*to(".efh-stage__grass","height");function wv(e){let t=Number(e);return e.trim()!==""&&Number.isFinite(t)?String(t):e}var kv=44e3,xv=1100,Tv=1188,Cv=1200,_v=3600;function SayPhrase({text:e,index:t,family:n}){let{look:i}=ey(),l=r(new H.Value(0)).current;return o(()=>{l.setValue(0);let e=P.inOut(P.ease),r=H.sequence([H.delay(Cv+t*_v),H.loop(H.sequence([H.timing(l,{toValue:1,duration:xv,easing:e,useNativeDriver:true}),H.delay(Tv),H.timing(l,{toValue:0,duration:xv,easing:e,useNativeDriver:true}),H.delay(kv-xv*2-Tv)]))]);return r.start(),()=>r.stop()},[t,l]),/* @__PURE__ */B(ArcLine,{line:e,geom:bv,opacity:l,text:{fontFamily:n,fontWeight:"500",fontSize:bv.font,lineHeight:bv.line,color:i.ink}})}function HubSay({family:e}){let{look:t}=ey();return useEverfurTheme().motion.reducedMotion?/* @__PURE__ */B(ArcLine,{line:Ab.sayLine,geom:bv,opacity:1,text:{fontFamily:e,fontWeight:"500",fontSize:bv.font,lineHeight:bv.line,color:t.ink}}):/* @__PURE__ */B(A,{children:Ab.sayPhrases.map((t,r)=>/* @__PURE__ */B(SayPhrase,{text:t,index:r,family:e},t))})}function HubHero({name:e,meta:t,stage:r,art:n,handFontFamily:l,say:o,vitals:a,vitalsName:s,renderStage:d,exam:c,onOpenExam:u,headPill:h,fromLine:p}){let{look:g,face:b}=ey(),y=useEverfurTheme().motion.reducedMotion,[v,w]=i(false),k=c!=null,x=r!==void 0||d===void 0,C=qy(vv,y),_=r?.grassSource??Ey,[R,S]=i(null),z=Dv(_),I=a.length>0?/* @__PURE__ */B(f,{style:x?{position:"absolute",top:Zl(".efh-stage .efh-vitals","top"),left:Zl(".efh-stage .efh-vitals","left"),gap:Zl(".efh-stage .efh-vitals","gap")}:{paddingHorizontal:Vb.screen.padX,marginTop:4,gap:Zl(".efh-stage .efh-vitals","gap")},accessibilityLabel:Ab.vitalsLabel(s),testID:"everfur-records-sheet-vitals",children:a.map((e,t)=>{let r=wv(e.value),n=e.kind==="temp"?Ab.temperature:e.kind==="heart"?Ab.heartRate:Ab.breathing,i=e.kind==="temp"?"thermo":e.kind==="heart"?"heart":"wind",l=e.kind==="temp"?g.ink:e.kind==="heart"?g.alert:g.icoBlue;/* @__PURE__ */
798
+ return B(f,{style:bu,onLayout:l,...lv,children:o.map(e=>/* @__PURE__ */B(f,{style:{position:"absolute",left:e.left,top:e.top,width:e.length,height:1.5,backgroundColor:t,transform:[{rotate:`${e.angle}deg`}]}},e.key))})}function hv(e,t){let r=face(e,"regular"),n=face(e,"bold"),i=headingFace(e,"bold"),l=face(e,"mono"),o=face(e,"monoBold"),a=(e,t)=>fv(e*t);return v.create({scroll:{flexGrow:1},topSlot:{paddingHorizontal:ro.sheetPadX},sheet:{flexGrow:1,gap:ro.gap,paddingTop:ro.sheetPadTop,paddingHorizontal:ro.sheetPadX,paddingBottom:ro.sheetPadBottom,borderTopLeftRadius:ro.sheetRadius,borderTopRightRadius:ro.sheetRadius,backgroundColor:t.ground},sheetUnderSlot:{marginTop:ro.sheetGap},card:{padding:ro.cardPad,backgroundColor:t.card,borderRadius:ro.cardRadius,shadowColor:"#000000",shadowOpacity:t.dark?0:.09,shadowRadius:3,shadowOffset:{width:0,height:1},elevation:t.dark?0:1,borderWidth:t.dark?1:0,borderColor:t.line},cardHead:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:12},cardTitle:{...n,fontSize:ro.cardTitle,lineHeight:a(ro.cardTitle,1.25),letterSpacing:-.36,color:t.ink},cardTitleGap:{marginBottom:12},sec:{marginTop:8,marginBottom:12},head:{marginBottom:Zl(".efh-head","marginBottom")},name:{...i,fontSize:ro.name,lineHeight:a(ro.name,1.2),letterSpacing:-.44,color:t.ink,flexShrink:1},meta:{...r,marginTop:2,fontSize:ro.small,lineHeight:a(ro.small,1.4),letterSpacing:.26,textTransform:"uppercase",color:t.muted},label:{...o,marginTop:Zl(".efh-head__from","marginTop"),fontSize:ro.mono,lineHeight:a(ro.mono,1.4),letterSpacing:.72,textTransform:"uppercase",color:t.muted},vitals:{flexDirection:"row",gap:8,marginTop:8},stage:{position:"relative",height:Zl(".efh-stage","height"),marginTop:Zl(".efh-stage","marginTop"),marginHorizontal:Zl(".efh-stage","marginLeft"),overflow:"hidden"},stageGrass:{position:"absolute",left:0,right:0,bottom:0,height:`${to(".efh-stage__grass","height")*100}%`,overflow:"hidden"},stagePet:{position:"absolute",left:`${to(".efh-stage__pet","left")*100}%`,bottom:Zl(".efh-stage__pet","bottom"),height:ov},stageVitals:{position:"absolute",top:Zl(".efh-stage .efh-vitals","top"),left:Zl(".efh-stage .efh-vitals","left"),gap:Zl(".efh-stage .efh-vitals","gap")},vital:{flex:1,minWidth:0},vitalTop:{flexDirection:"row",alignItems:"center",gap:6},vitalValue:{...n,fontSize:17,lineHeight:a(17,1.2),color:t.ink},vitalUnit:{...r,fontSize:ro.small,color:t.muted},vitalLabel:{...r,marginTop:2,fontSize:ro.small,lineHeight:a(ro.small,1.4),color:t.muted},due:{gap:4,marginHorizontal:-12},dueRow:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:ro.rowRadius},dueText:{flex:1,minWidth:0,gap:2},duePill:{alignSelf:"center"},dueTitle:{...n,fontSize:ro.rowTitle,lineHeight:a(ro.rowTitle,1.3),color:t.ink},dueWhen:{...r,fontSize:ro.small,lineHeight:a(ro.small,1.4),color:t.muted},pill:{minHeight:ro.pill,paddingHorizontal:10,borderRadius:999,alignItems:"center",justifyContent:"center",alignSelf:"flex-start"},pillSmall:{minHeight:22,paddingHorizontal:7},pillText:{...o,fontSize:ro.mono,lineHeight:ro.mono+2,letterSpacing:.72,textTransform:"uppercase"},pillTextSmall:{fontSize:10.5,letterSpacing:.21},tiles:{flexDirection:"row",flexWrap:"wrap",gap:ro.tileGap},tile:{flexGrow:1,flexBasis:"45%",minWidth:0,gap:8,padding:16,borderRadius:ro.cardRadius},tileTop:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between"},tileTitle:{...n,fontSize:ro.body,lineHeight:a(ro.body,1.25),letterSpacing:-.15,color:t.ink},tileFoot:{flexDirection:"row",flexWrap:"wrap",alignItems:"baseline",gap:8,minHeight:28},tileNum:{...n,fontSize:ro.tileNum,lineHeight:ro.tileNum+2,letterSpacing:-.4,color:t.ink},tileUnit:{...r,fontSize:ro.small,color:t.muted},emptyLine:{...r,fontSize:ro.small,lineHeight:a(ro.small,1.5),color:t.muted},wt:{flexDirection:"row",flexWrap:"wrap",alignItems:"baseline",gap:8},wtValue:{...n,fontSize:ro.big,lineHeight:Zl(".efh-wt b","lineHeight"),letterSpacing:-.64,color:t.ink},wtSub:{...r,fontSize:ro.body,color:t.muted},chart:{marginTop:20},plot:{position:"relative",height:ro.plot},point:{position:"absolute",width:12,height:12,marginLeft:-6,marginTop:-6,borderRadius:6,borderWidth:1.5,borderColor:t.card},pointLabel:{...face(e,"medium"),position:"absolute",width:46,marginLeft:-23,textAlign:"center",fontSize:ro.mono,lineHeight:ro.mono+2,color:t.dark?t.text:pv},xAxis:{position:"relative",height:18,marginTop:8},xTick:{...l,position:"absolute",top:0,width:56,marginLeft:-28,textAlign:"center",fontSize:ro.mono,lineHeight:a(ro.mono,1.3),color:t.muted},key:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:6,marginTop:12},keyDot:{width:12,height:12,borderRadius:6,backgroundColor:t.ink},keyText:{...r,fontSize:ro.small,lineHeight:a(ro.small,1.4),color:t.muted},tlKey:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},tlKeyDot:{width:10,height:10,borderRadius:5,borderWidth:2.5,borderColor:t.ink,backgroundColor:t.card},tlYear:{...o,marginTop:20,marginBottom:12,marginLeft:40,fontSize:ro.mono,lineHeight:a(ro.mono,1.4),letterSpacing:.72,textTransform:"uppercase",color:t.muted},tlItem:{position:"relative",flexDirection:"row",gap:16,paddingBottom:24},tlItemLast:{paddingBottom:0},tlRail:{position:"absolute",left:11,top:22,bottom:-2,width:2,borderRadius:1,backgroundColor:t.line},tlRailEnd:{bottom:12},tlDot:{width:16,height:16,marginTop:3,marginHorizontal:4,borderRadius:8,borderWidth:3,borderColor:t.ink,backgroundColor:t.card},tlBody:{flex:1,minWidth:0},tlBtn:{marginTop:-8,marginHorizontal:-8,paddingVertical:8,paddingLeft:8,paddingRight:36,borderRadius:ro.rowRadius,backgroundColor:t.alertTint},tlChevron:{position:"absolute",right:8,top:"50%",marginTop:-10},tlDate:{...l,fontSize:ro.mono,lineHeight:a(ro.mono,1.4),letterSpacing:.48,textTransform:"uppercase",color:t.muted},tlTitle:{...n,marginTop:2,fontSize:ro.rowTitle,lineHeight:a(ro.rowTitle,1.3),color:t.ink},tlText:{...r,marginTop:2,fontSize:ro.body,lineHeight:a(ro.body,1.5),color:t.text},pull:{paddingTop:4,paddingBottom:24,paddingLeft:40},pullStep:{...n,fontSize:ro.body,lineHeight:a(ro.body,1.4),color:t.ink},pullBar:{height:6,marginTop:10,overflow:"hidden",borderRadius:999,backgroundColor:t.line},pullFill:{height:"100%",backgroundColor:t.accent},failed:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:ro.rowRadius,backgroundColor:t.alertTint},failedText:{...n,flex:1,fontSize:ro.body,lineHeight:a(ro.body,1.4),color:t.alertDeep},add:{gap:12},addHead:{flexDirection:"row",alignItems:"center",gap:8},addLead:{...r,fontSize:ro.body,lineHeight:a(ro.body,1.5),color:t.text},sources:{gap:6},source:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",columnGap:12,paddingVertical:10,paddingHorizontal:14,borderRadius:ro.rowRadius,backgroundColor:t.rowGround},sourceLabel:{...r,fontSize:ro.body,lineHeight:a(ro.body,1.4),color:t.text},sourceDetail:{...r,fontSize:ro.small,color:t.muted},addActs:{gap:12,paddingTop:4},button:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,minHeight:ro.button,paddingHorizontal:20,borderRadius:999},buttonRow:{minHeight:ro.rowButton,paddingHorizontal:16},buttonText:{...n,fontSize:16,lineHeight:20},buttonTextRow:{fontSize:ro.body},noneWithScene:{paddingTop:Zl(".efh-none","paddingTop")},scene:{position:"relative",height:Ql.height,marginHorizontal:Zl(".efh-none__scene","marginLeft"),marginBottom:Zl(".efh-none__scene","marginBottom"),overflow:"hidden",borderTopLeftRadius:ro.cardRadius,borderTopRightRadius:ro.cardRadius},sceneGrass:{position:"absolute",left:0,right:0,bottom:0,height:Ql.grassHeight,overflow:"hidden"},scenePet:{position:"absolute",left:"50%",bottom:Ql.petBottom,height:Ql.petHeight},noneTitle:{...i,fontSize:Zl(".efh-none__t","fontSize"),lineHeight:Zl(".efh-none__t","lineHeight"),letterSpacing:Zl(".efh-none__t","letterSpacing"),color:t.ink},noneLead:{...r,marginTop:Zl(".efh-none__lead","marginTop"),fontSize:Zl(".efh-none__lead","fontSize"),lineHeight:Zl(".efh-none__lead","lineHeight"),color:t.text},noneLine:{flexDirection:"row",flexWrap:"wrap",alignItems:"baseline",columnGap:4,marginTop:Zl(".efh-none__lead","marginTop")},noneLineText:{...r,fontSize:Zl(".efh-none__lead","fontSize"),lineHeight:Zl(".efh-none__lead","lineHeight"),color:t.text},noneLink:{...n,fontSize:Zl(".efh-none__lead","fontSize"),lineHeight:Zl(".efh-none__lead","lineHeight"),color:t.ink,textDecorationLine:"underline"},repeatLine:{...n,marginTop:Zl(".efh-ways","gap"),fontSize:Zl(".efh-none__lead","fontSize"),lineHeight:Zl(".efh-none__lead","lineHeight"),color:t.ink},ways:{gap:Zl(".efh-ways","gap"),marginTop:Zl(".efh-ways","marginTop")},way:{flexDirection:"row",alignItems:"center",gap:Zl(".efh-way","columnGap"),padding:Zl(".efh-way","paddingTop"),borderRadius:Zl(".efh-way","borderRadius")},wayText:{flex:1,minWidth:0,gap:Zl(".efh-way__w","gap")},wayTitle:{...n,fontSize:Zl(".efh-way__t","fontSize"),lineHeight:Zl(".efh-way__t","lineHeight")},wayDetail:{...r,fontSize:Zl(".efh-way__x","fontSize"),lineHeight:Zl(".efh-way__x","lineHeight")},tracker:{marginTop:16},step:{flexDirection:"row",gap:16,paddingBottom:20},stepLast:{paddingBottom:0},stepRail:{position:"absolute",left:gv/2-1,top:gv+2,bottom:2,width:2,borderRadius:1,backgroundColor:t.line},stepRailDone:{backgroundColor:t.ink},stepDot:{width:gv,height:gv,borderRadius:gv/2,borderWidth:2,borderColor:t.line,backgroundColor:t.card,alignItems:"center",justifyContent:"center"},stepDotOn:{borderColor:t.ink},stepDotDone:{backgroundColor:t.fill,borderColor:t.fill},stepNow:{width:10,height:10,borderRadius:5,backgroundColor:t.accent},stepText:{flex:1,minWidth:0,paddingTop:3,gap:2},stepTitle:{...n,fontSize:Zl(".efh-mk__name","fontSize"),lineHeight:22,color:t.ink},stepWhen:{...r,fontSize:Zl(".efh-mk__line","fontSize"),lineHeight:Zl(".efh-mk__line","lineHeight"),color:t.muted},peek:{gap:12,marginTop:12},peekHead:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:12},peekLead:{...r,marginTop:-4,fontSize:ro.body,lineHeight:a(ro.body,1.5),color:t.text},peekLabsTitle:{marginBottom:Zl(".efh-peek__labs .efh-card__title","marginBottom")},peekGroup:{marginBottom:Zl(".efh-peek__g","marginBottom")},peekGroupTitle:{...n,fontSize:Zl(".efh-peek__g b","fontSize"),lineHeight:fv(Zl(".efh-peek__g b","fontSize")*(Zl(".efh-peek__g","lineHeight")/Zl(".efh-peek__g","fontSize"))),color:t.ink},peekGroupLead:{...r,fontSize:Zl(".efh-peek__g","fontSize"),lineHeight:Zl(".efh-peek__g","lineHeight"),color:t.muted},more:{gap:10},moreCard:{gap:10,padding:16,borderRadius:ro.cardRadius},moreHead:{flexDirection:"row",alignItems:"center",gap:8},moreTitle:{...n,fontSize:16,lineHeight:a(16,1.3),color:t.ink},moreLead:{...r,fontSize:ro.body,lineHeight:a(ro.body,1.5),color:t.text},moreRows:{gap:6},moreRow:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:44,paddingVertical:8,paddingHorizontal:14,borderRadius:ro.rowRadius,backgroundColor:t.card},moreRowLabel:{...r,flexShrink:1,fontSize:ro.body,lineHeight:a(ro.body,1.4),color:t.text},moreWhen:{...l,fontSize:ro.mono,letterSpacing:.24,color:t.muted},note:{...r,marginTop:Zl(".efh-sheet .rec-note","marginTop"),fontSize:Zl(".rec-note","fontSize"),textAlign:"center",color:t.muted},mks:{gap:2,marginHorizontal:-8},mk:{flexDirection:"row",alignItems:"center",gap:12,paddingVertical:10,paddingHorizontal:8},mkText:{flex:1,minWidth:0},mkNameRow:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:8},mkName:{...n,fontSize:ro.rowTitle,lineHeight:a(ro.rowTitle,1.3),color:t.ink},mkLine:{flexDirection:"row",flexWrap:"wrap",alignItems:"baseline",rowGap:Zl(".efh-mk__line","rowGap"),columnGap:Zl(".efh-mk__line","columnGap"),marginTop:Zl(".efh-mk__line","marginTop")},mkLineText:{...r,fontSize:Zl(".efh-mk__line","fontSize"),lineHeight:Zl(".efh-mk__line","lineHeight"),color:t.muted,fontVariant:["tabular-nums"]},mkValue:{...n,fontSize:Zl(".efh-mk__line b","fontSize"),lineHeight:fv(Zl(".efh-mk__line b","fontSize")*(Zl(".efh-mk__line","lineHeight")/Zl(".efh-mk__line","fontSize"))),color:t.text,fontVariant:["tabular-nums"]},mkBar:{position:"relative",width:96,height:6,borderRadius:999,backgroundColor:t.barTrack},mkBarIn:{position:"absolute",top:0,bottom:0,left:"20%",right:"20%",borderRadius:999},mkBarDot:{position:"absolute",top:-2,width:10,height:10,marginLeft:-5,borderRadius:5,borderWidth:2},topRisk:{gap:Zl(".rec-top","gap"),paddingTop:Zl(".rec-top","paddingTop"),paddingRight:Zl(".rec-top","paddingRight"),paddingBottom:Zl(".rec-top","paddingBottom"),paddingLeft:Zl(".rec-top","paddingLeft"),backgroundColor:t.topFill,borderRadius:Zl(".rec-top","borderRadius"),borderWidth:0,shadowOpacity:0,elevation:0},topRiskKicker:{flexDirection:"row",alignItems:"center",gap:Zl(".rec-top__k","gap")},topRiskDot:{width:8,height:8,borderRadius:4,backgroundColor:t.alert},topRiskK:{...l,fontSize:Zl(".rec-top__k","fontSize"),lineHeight:Zl(".rec-top__k","fontSize")*1.5,letterSpacing:Zl(".rec-top__k","letterSpacing"),textTransform:"uppercase",color:t.topKicker},topRiskText:{...n,fontSize:ro.rowTitle,lineHeight:a(ro.rowTitle,1.35),color:t.topInk},disclaimer:{...r,fontSize:ro.small,lineHeight:a(ro.small,1.5),textAlign:"center",color:t.muted},lab:{gap:ro.gap,paddingTop:8,paddingHorizontal:16,paddingBottom:32,backgroundColor:t.ground},labTitle:{...face(e,"medium"),fontSize:ro.name,lineHeight:a(ro.name,1.2),letterSpacing:-.33,color:t.ink},labMeta:{...l,fontSize:ro.small,lineHeight:a(ro.small,1.45),color:t.muted},latest:{flexDirection:"row",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:4},latestSub:{...r,fontSize:ro.body,color:t.muted},change:{...r,marginTop:12,fontSize:ro.body,color:t.text},changeLead:{...n,color:t.ink},ctx:{gap:12},ctxText:{...r,fontSize:ro.rowTitle,lineHeight:a(ro.rowTitle,1.55),color:t.text},labBody:{flexDirection:"row",gap:8},rail:{width:8,height:ro.plot,overflow:"hidden",borderRadius:2},legend:{width:82,height:ro.plot,position:"relative"},range:{...o,position:"absolute",left:0,right:0,fontSize:ro.mono,lineHeight:a(ro.mono,1.2),letterSpacing:.24,textTransform:"uppercase",color:t.dark?t.text:pv},band:{position:"absolute",left:0,right:0,top:"25%",height:"50%",backgroundColor:t.goTint}})}var pv="#3D3D3D",gv=28,fv=e=>Math.round(e*100)/100;var mv={accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",pointerEvents:"none"},bv=iv(Vb.hero.sayWidth),yv=Zl(".efh-stage","height"),vv=yv*to(".efh-stage__grass","height");function wv(e){let t=Number(e);return e.trim()!==""&&Number.isFinite(t)?String(t):e}var kv=44e3,xv=1100,Tv=1188,_v=1200,Cv=3600;function SayPhrase({text:e,index:t,family:n}){let{look:i}=ey(),l=r(new H.Value(0)).current;return o(()=>{l.setValue(0);let e=P.inOut(P.ease),r=H.sequence([H.delay(_v+t*Cv),H.loop(H.sequence([H.timing(l,{toValue:1,duration:xv,easing:e,useNativeDriver:true}),H.delay(Tv),H.timing(l,{toValue:0,duration:xv,easing:e,useNativeDriver:true}),H.delay(kv-xv*2-Tv)]))]);return r.start(),()=>r.stop()},[t,l]),/* @__PURE__ */B(ArcLine,{line:e,geom:bv,opacity:l,text:{fontFamily:n,fontWeight:"500",fontSize:bv.font,lineHeight:bv.line,color:i.ink}})}function HubSay({family:e}){let{look:t}=ey();return useEverfurTheme().motion.reducedMotion?/* @__PURE__ */B(ArcLine,{line:Ab.sayLine,geom:bv,opacity:1,text:{fontFamily:e,fontWeight:"500",fontSize:bv.font,lineHeight:bv.line,color:t.ink}}):/* @__PURE__ */B(A,{children:Ab.sayPhrases.map((t,r)=>/* @__PURE__ */B(SayPhrase,{text:t,index:r,family:e},t))})}function HubHero({name:e,meta:t,stage:r,art:n,handFontFamily:l,say:o,vitals:a,vitalsName:s,renderStage:d,exam:c,onOpenExam:u,headPill:h,fromLine:p}){let{look:g,face:b}=ey(),y=useEverfurTheme().motion.reducedMotion,[v,w]=i(false),k=c!=null,x=r!==void 0||d===void 0,_=qy(vv,y),C=r?.grassSource??Ey,[R,S]=i(null),z=Dv(C),I=a.length>0?/* @__PURE__ */B(f,{style:x?{position:"absolute",top:Zl(".efh-stage .efh-vitals","top"),left:Zl(".efh-stage .efh-vitals","left"),gap:Zl(".efh-stage .efh-vitals","gap")}:{paddingHorizontal:Vb.screen.padX,marginTop:4,gap:Zl(".efh-stage .efh-vitals","gap")},accessibilityLabel:Ab.vitalsLabel(s),testID:"everfur-records-sheet-vitals",children:a.map((e,t)=>{let r=wv(e.value),n=e.kind==="temp"?Ab.temperature:e.kind==="heart"?Ab.heartRate:Ab.breathing,i=e.kind==="temp"?"thermo":e.kind==="heart"?"heart":"wind",l=e.kind==="temp"?g.ink:e.kind==="heart"?g.alert:g.icoBlue;/* @__PURE__ */
799
799
  return B(RiseIn,{index:t,reduced:y,children:/* @__PURE__ */j(m,{disabled:!k,onPress:()=>w(e=>!e),accessible:true,...k?{accessibilityRole:"button",accessibilityState:{expanded:v}}:{},accessibilityLabel:Ab.vitalLabel(n,r,e.unit??"",k),hitSlop:6,style:{flexDirection:"row",alignItems:"center",gap:Vb.hero.vitalGap},testID:`everfur-records-sheet-vital-${e.kind}`,children:[
800
800
  /* @__PURE__ */B(HubIcon,{name:i,size:Vb.hero.vitalIcon,color:l}),
801
801
  /* @__PURE__ */B(HubText,{variant:"bodySmBold",tier:"compact",color:g.ink,style:{fontSize:Vb.hero.vitalValueSize,lineHeight:Vb.hero.vitalValueSize*1.2},children:r}),e.unit?/* @__PURE__ */B(HubText,{variant:"fine",tier:"compact",style:{fontSize:Vb.hero.vitalUnitSize},children:e.unit}):null]})},e.kind)})}):null,D=k&&v?/* @__PURE__ */j(f,{accessibilityLiveRegion:"polite",style:{marginTop:8,marginHorizontal:Vb.screen.padX,padding:Vb.card.pad,borderRadius:Vb.card.radius,backgroundColor:g.white,borderWidth:1,borderColor:g.line},testID:"everfur-records-sheet-vitals-from",children:[
@@ -804,8 +804,8 @@ return B(RiseIn,{index:t,reduced:y,children:/* @__PURE__ */j(m,{disabled:!k,onPr
804
804
  return j(f,{style:{marginTop:4,marginHorizontal:-Vb.screen.padX},testID:"everfur-records-hub-hero",children:[
805
805
  /* @__PURE__ */j(f,{style:[{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:Vb.screen.padX},o?null:{minHeight:Vb.peek.roundButton}],testID:"everfur-records-sheet-head",children:[
806
806
  /* @__PURE__ */B(HubText,{variant:"screenTitle",accessibilityRole:"header",numberOfLines:1,testID:"everfur-records-sheet-name",style:[b("bold"),{flexShrink:1,fontSize:Vb.hero.nameSize,lineHeight:Vb.hero.nameSize*1.2,letterSpacing:Vb.hero.nameTracking}],children:e}),h!=null?/* @__PURE__ */B(HubPill,{label:h.label,tone:h.tone,testID:"everfur-records-sheet-head-pill"}):null]}),t!==null?/* @__PURE__ */B(HubText,{variant:"fine",testID:"everfur-records-sheet-meta",style:{marginTop:Vb.hero.metaTop,paddingHorizontal:Vb.screen.padX,lineHeight:Vb.hero.metaLineHeight,textTransform:"uppercase",letterSpacing:Vb.hero.metaTracking},children:t}):null,x?/* @__PURE__ */j(f,{style:{height:yv,marginTop:Zl(".efh-stage","marginTop"),overflow:"hidden"},testID:"everfur-records-sheet-stage",children:[
807
- /* @__PURE__ */B(H.View,{style:[{position:"absolute",left:0,right:0,bottom:0,height:vv,overflow:"hidden"},C.grass],...mv,children:R===z?null:/* @__PURE__ */B(T,{source:_,onError:()=>S(z),style:{position:"absolute",top:0,left:0,right:0,height:"100%"},resizeMode:"cover",testID:"everfur-records-sheet-grass"})}),
808
- /* @__PURE__ */B(H.View,{style:[{position:"absolute",left:`${(2*to(".efh-stage__pet","left")-1)*100}%`,right:0,bottom:Zl(".efh-stage__pet","bottom"),alignItems:"center"},o?{top:Vb.hero.sayHeight-4}:{height:`${to(".efh-stage__pet","height")*100}%`},C.pet],...mv,children:r!==void 0?/* @__PURE__ */B(T,{source:r.petSource,style:{width:"100%",height:"100%"},resizeMode:"contain"}):/* @__PURE__ */B(HubPetArt,{art:n.art,onError:n.onError,reduced:y})}),o&&L!==null?/* @__PURE__ */B(f,{style:{position:"absolute",top:0,left:"50%",width:Vb.hero.sayWidth,height:Vb.hero.sayHeight,marginLeft:-Vb.hero.sayWidth/2},testID:"everfur-records-sheet-say",...mv,children:/* @__PURE__ */B(HubSay,{family:L})}):null,I]}):/* @__PURE__ */j(A,{children:[d!==void 0?/* @__PURE__ */B(HostRender,{render:d,fallback:null,resetKey:e}):null,I]}),p!=null&&p.trim().length>0&&a.length>0?/* @__PURE__ */B(HubText,{variant:"labelMono",testID:"everfur-records-sheet-vitals-line",style:{marginTop:Zl(".efh-head__from","marginTop"),paddingHorizontal:Vb.screen.padX},children:p}):null,D]})}function HubPrompt({title:e,canAct:t,canRequest:r,onRequest:n,onUpload:i,note:l}){let o=useEverfurTheme().motion.reducedMotion;/* @__PURE__ */
807
+ /* @__PURE__ */B(H.View,{style:[{position:"absolute",left:0,right:0,bottom:0,height:vv,overflow:"hidden"},_.grass],...mv,children:R===z?null:/* @__PURE__ */B(T,{source:C,onError:()=>S(z),style:{position:"absolute",top:0,left:0,right:0,height:"100%"},resizeMode:"cover",testID:"everfur-records-sheet-grass"})}),
808
+ /* @__PURE__ */B(H.View,{style:[{position:"absolute",left:`${(2*to(".efh-stage__pet","left")-1)*100}%`,right:0,bottom:Zl(".efh-stage__pet","bottom"),alignItems:"center"},o?{top:Vb.hero.sayHeight-4}:{height:`${to(".efh-stage__pet","height")*100}%`},_.pet],...mv,children:r!==void 0?/* @__PURE__ */B(T,{source:r.petSource,style:{width:"100%",height:"100%"},resizeMode:"contain"}):/* @__PURE__ */B(HubPetArt,{art:n.art,onError:n.onError,reduced:y})}),o&&L!==null?/* @__PURE__ */B(f,{style:{position:"absolute",top:0,left:"50%",width:Vb.hero.sayWidth,height:Vb.hero.sayHeight,marginLeft:-Vb.hero.sayWidth/2},testID:"everfur-records-sheet-say",...mv,children:/* @__PURE__ */B(HubSay,{family:L})}):null,I]}):/* @__PURE__ */j(A,{children:[d!==void 0?/* @__PURE__ */B(HostRender,{render:d,fallback:null,resetKey:e}):null,I]}),p!=null&&p.trim().length>0&&a.length>0?/* @__PURE__ */B(HubText,{variant:"labelMono",testID:"everfur-records-sheet-vitals-line",style:{marginTop:Zl(".efh-head__from","marginTop"),paddingHorizontal:Vb.screen.padX},children:p}):null,D]})}function HubPrompt({title:e,canAct:t,canRequest:r,onRequest:n,onUpload:i,note:l}){let o=useEverfurTheme().motion.reducedMotion;/* @__PURE__ */
809
809
  return B(HubReveal,{index:1,reduced:o,children:/* @__PURE__ */j(HubCard,{title:e,testID:"everfur-records-records-prompt",children:[
810
810
  /* @__PURE__ */B(HubText,{variant:"bodySm",children:Ab.moreThanOneClinic}),t&&r?/* @__PURE__ */B(HubButton,{label:Ab.requestFromClinic,icon:"download",block:true,onPress:n,style:{marginTop:12},testID:"everfur-records-sheet-none-request"}):null,t&&r&&l?/* @__PURE__ */B(f,{style:{marginTop:12},children:l}):null,t?/* @__PURE__ */B(HubButton,{label:Ab.uploadDocument,icon:"upload",variant:"secondary",block:true,onPress:i,style:{marginTop:12},testID:"everfur-records-sheet-none-upload"}):null]})})}function HubUpcoming({rows:e,items:t,onViewAll:r,renderAction:n,actionLabel:i,onAction:l}){let{look:o}=ey(),a=Vb.upcoming,s=useEverfurTheme().motion.reducedMotion;/* @__PURE__ */
811
811
  return B(HubCard,{title:Ab.upcomingCare,titleEnd:r!==void 0?/* @__PURE__ */B(HubButton,{label:Ab.viewAll,variant:"text",onPress:r,testID:"everfur-records-sheet-upcoming-all"}):void 0,testID:"everfur-records-hub-upcoming",children:/* @__PURE__ */B(f,{style:{gap:a.listGap,marginHorizontal:Zl(".efh-due","marginLeft")},children:e.map((e,r)=>{let d=e.tone==="overdue",c=t.get(e.key);/* @__PURE__ */
@@ -857,7 +857,7 @@ return j(f,{style:{flexDirection:"row",alignItems:"center",gap:Zl(".efh-wkey spa
857
857
  /* @__PURE__ */B(HubText,{variant:"fine",style:{fontSize:Zl(".efh-wkey","fontSize"),lineHeight:Zl(".efh-wkey","lineHeight")},children:e.label})]},e.label)})}):e.band!==null?/* @__PURE__ */B(HubText,{variant:"fine",children:Ab.estimatedRange}):null]}):e.points.length===1?
858
858
  /* @__PURE__ */j(f,{style:{gap:8,marginTop:l.headBottom},children:[e.date!==null?/* @__PURE__ */B(HubText,{variant:"fine",style:Sv,testID:"everfur-records-sheet-weight-date",children:e.date}):null,
859
859
  /* @__PURE__ */B(HubText,{variant:"fine",style:Sv,testID:"everfur-records-sheet-weight-single",children:gb.oneReading})]}):null]})})}function SeeWhereItStands({onPress:e,testID:t="everfur-records-sheet-on-the-way-go"}){/* @__PURE__ */
860
- return B(HubButton,{label:Cm.seeWhereItStands,variant:"secondary",size:"sm",icon:"chevron",onPress:e,style:{alignSelf:"flex-start"},testID:t})}function HubInFlight({lines:e,onOpenRequest:t}){return e.length===0?null:/* @__PURE__ */B(f,{style:{gap:12},testID:"everfur-records-sheet-in-flight",children:e.map(e=>/* @__PURE__ */j(f,{style:{gap:8,alignItems:"flex-start"},testID:"everfur-records-sheet-on-the-way",children:[
860
+ return B(HubButton,{label:_m.seeWhereItStands,variant:"secondary",size:"sm",icon:"chevron",onPress:e,style:{alignSelf:"flex-start"},testID:t})}function HubInFlight({lines:e,onOpenRequest:t}){return e.length===0?null:/* @__PURE__ */B(f,{style:{gap:12},testID:"everfur-records-sheet-in-flight",children:e.map(e=>/* @__PURE__ */j(f,{style:{gap:8,alignItems:"flex-start"},testID:"everfur-records-sheet-on-the-way",children:[
861
861
  /* @__PURE__ */B(HubText,{variant:"bodySm",children:e.text}),t!==void 0?/* @__PURE__ */B(SeeWhereItStands,{onPress:()=>t(e.requestId)}):null]},e.key))})}function HubAddRecords({words:e,sources:t,canRequest:r,onRequest:n,onUpload:i,note:l,inFlight:o=[],onOpenRequest:a,uploadHint:s}){let{look:d}=ey(),c=Vb.add,u=useEverfurTheme().motion.reducedMotion;/* @__PURE__ */
862
862
  return B(HubReveal,{index:4,reduced:u,children:/* @__PURE__ */B(HubCard,{testID:"everfur-records-hub-add-records",children:/* @__PURE__ */j(f,{style:{gap:Zl(".efh-add","gap")},children:[
863
863
  /* @__PURE__ */j(f,{style:{flexDirection:"row",alignItems:"center",gap:c.headGap},children:[
@@ -896,9 +896,9 @@ return j(f,{style:{flexDirection:"row",alignItems:"flex-start",gap:Gb.rowGap},ac
896
896
  /* @__PURE__ */B(RailDot,{state:e.state}),t<o.length-1?/* @__PURE__ */B(f,{style:{width:Gb.rail,flex:1,minHeight:Gb.railMin,marginVertical:Gb.railGap,backgroundColor:e.state==="done"?n.brand:n.legacyBorder},...mv}):null]}),
897
897
  /* @__PURE__ */j(f,{style:{flex:1,paddingBottom:Gb.bodyBottom,gap:Gb.bodyGap},children:[
898
898
  /* @__PURE__ */j(f,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:Gb.titleGap},children:[
899
- /* @__PURE__ */B(Text,{style:[i(a?"regular":"bold"),{flex:1,fontSize:Gb.titleSize,lineHeight:Gb.titleLineHeight,color:e.state==="current"?n.brand:e.state==="failed"?n.alert:a?n.legacyMuted:n.legacyText}],children:e.title}),r!==null?/* @__PURE__ */B(Text,{style:[i("regular"),{fontSize:Gb.dateSize,lineHeight:Gb.dateLineHeight,color:n.legacyMuted}],children:r}):null]}),e.detail!==null?/* @__PURE__ */B(Text,{style:[i("regular"),{fontSize:Gb.detailSize,lineHeight:Gb.detailLineHeight,color:n.legacyMuted},a?{opacity:Gb.upcomingOpacity}:null],children:e.detail}):null]})]},e.key)})}),s.length>0?/* @__PURE__ */B(f,{style:{borderRadius:l.statusRadius,backgroundColor:n.brandSoft,padding:l.statusPad},children:/* @__PURE__ */B(Text,{style:[i("regular"),{fontSize:l.statusSize,lineHeight:l.statusLineHeight,color:n.legacyText}],children:s})}):null,r!==void 0?/* @__PURE__ */B(SeeWhereItStands,{onPress:r}):null]})})}function HubMedications({medications:e}){let{look:t}=ey(),r=useEverfurTheme().motion.reducedMotion;return e===null?null:/* @__PURE__ */B(HubReveal,{index:5,reduced:r,children:/* @__PURE__ */B(HubCard,{title:Cm.takingNow,testID:"everfur-records-sheet-meds",children:e.current.length===0?/* @__PURE__ */B(HubText,{variant:"bodySm",children:Cm.noCurrentMeds}):/* @__PURE__ */B(f,{accessibilityRole:"list",style:{gap:Vb.upcoming.listGap},children:e.current.map((e,r)=>/* @__PURE__ */j(f,{style:[{paddingVertical:Vb.upcoming.rowPadY},r===0?null:{borderTopWidth:1,borderTopColor:t.line}],testID:`everfur-records-sheet-med-${e.key}`,children:[
900
- /* @__PURE__ */B(HubText,{variant:"bodySmBold",style:{fontSize:17,lineHeight:22},children:e.name}),e.detail!==null?/* @__PURE__ */B(HubText,{variant:"fine",children:e.detail}):null]},e.key))})})})}function zv(e,t){let r=[...e.flatMap(e=>e.items.map(e=>({...e,source:"clinic"}))),...t.map(e=>({key:`host-${e.key}`,ms:e.ms,date:e.date,title:e.title,text:e.text??null,alert:false,markerId:null,source:e.source,...e.onPress!==void 0?{onPress:e.onPress}:{}}))].sort((e,t)=>t.ms-e.ms),n=[];for(let e of r){let t=String(new Date(e.ms).getUTCFullYear()),r=n[n.length-1];r!==void 0&&r.year===t?r.items.push(e):n.push({year:t,items:[e]})}return n}function HubHistory({words:e,history:t,onOpenMarker:r,sourceKey:n,extra:i=[]}){let{look:l,face:o}=ey(),a=useEverfurTheme().motion.reducedMotion,s=zv(t,i);if(s.length===0)return null;let d=e=>e==="everfur"?l.go:e==="partner"?Kl.embTealInk:l.ink,c=[["clinic",n?.clinic??Cm.theirClinic(e)],...["everfur","partner"].flatMap(e=>n?.[e]!==void 0?[[e,n[e]]]:[])],u={...o("mono"),fontSize:Zl(".efh-tl__date","fontSize"),lineHeight:Zl(".efh-tl__date","lineHeight"),letterSpacing:Zl(".efh-tl__date","letterSpacing"),textTransform:"uppercase",color:l.muted};/* @__PURE__ */
901
- return B(HubReveal,{index:6,reduced:a,children:/* @__PURE__ */j(HubCard,{title:Cm.history,testID:"everfur-records-sheet-history",children:[
899
+ /* @__PURE__ */B(Text,{style:[i(a?"regular":"bold"),{flex:1,fontSize:Gb.titleSize,lineHeight:Gb.titleLineHeight,color:e.state==="current"?n.brand:e.state==="failed"?n.alert:a?n.legacyMuted:n.legacyText}],children:e.title}),r!==null?/* @__PURE__ */B(Text,{style:[i("regular"),{fontSize:Gb.dateSize,lineHeight:Gb.dateLineHeight,color:n.legacyMuted}],children:r}):null]}),e.detail!==null?/* @__PURE__ */B(Text,{style:[i("regular"),{fontSize:Gb.detailSize,lineHeight:Gb.detailLineHeight,color:n.legacyMuted},a?{opacity:Gb.upcomingOpacity}:null],children:e.detail}):null]})]},e.key)})}),s.length>0?/* @__PURE__ */B(f,{style:{borderRadius:l.statusRadius,backgroundColor:n.brandSoft,padding:l.statusPad},children:/* @__PURE__ */B(Text,{style:[i("regular"),{fontSize:l.statusSize,lineHeight:l.statusLineHeight,color:n.legacyText}],children:s})}):null,r!==void 0?/* @__PURE__ */B(SeeWhereItStands,{onPress:r}):null]})})}function HubMedications({medications:e}){let{look:t}=ey(),r=useEverfurTheme().motion.reducedMotion;return e===null?null:/* @__PURE__ */B(HubReveal,{index:5,reduced:r,children:/* @__PURE__ */B(HubCard,{title:_m.takingNow,testID:"everfur-records-sheet-meds",children:e.current.length===0?/* @__PURE__ */B(HubText,{variant:"bodySm",children:_m.noCurrentMeds}):/* @__PURE__ */B(f,{accessibilityRole:"list",style:{gap:Vb.upcoming.listGap},children:e.current.map((e,r)=>/* @__PURE__ */j(f,{style:[{paddingVertical:Vb.upcoming.rowPadY},r===0?null:{borderTopWidth:1,borderTopColor:t.line}],testID:`everfur-records-sheet-med-${e.key}`,children:[
900
+ /* @__PURE__ */B(HubText,{variant:"bodySmBold",style:{fontSize:17,lineHeight:22},children:e.name}),e.detail!==null?/* @__PURE__ */B(HubText,{variant:"fine",children:e.detail}):null]},e.key))})})})}function zv(e,t){let r=[...e.flatMap(e=>e.items.map(e=>({...e,source:"clinic"}))),...t.map(e=>({key:`host-${e.key}`,ms:e.ms,date:e.date,title:e.title,text:e.text??null,alert:false,markerId:null,source:e.source,...e.onPress!==void 0?{onPress:e.onPress}:{}}))].sort((e,t)=>t.ms-e.ms),n=[];for(let e of r){let t=String(new Date(e.ms).getUTCFullYear()),r=n[n.length-1];r!==void 0&&r.year===t?r.items.push(e):n.push({year:t,items:[e]})}return n}function HubHistory({words:e,history:t,onOpenMarker:r,sourceKey:n,extra:i=[]}){let{look:l,face:o}=ey(),a=useEverfurTheme().motion.reducedMotion,s=zv(t,i);if(s.length===0)return null;let d=e=>e==="everfur"?l.go:e==="partner"?Kl.embTealInk:l.ink,c=[["clinic",n?.clinic??_m.theirClinic(e)],...["everfur","partner"].flatMap(e=>n?.[e]!==void 0?[[e,n[e]]]:[])],u={...o("mono"),fontSize:Zl(".efh-tl__date","fontSize"),lineHeight:Zl(".efh-tl__date","lineHeight"),letterSpacing:Zl(".efh-tl__date","letterSpacing"),textTransform:"uppercase",color:l.muted};/* @__PURE__ */
901
+ return B(HubReveal,{index:6,reduced:a,children:/* @__PURE__ */j(HubCard,{title:_m.history,testID:"everfur-records-sheet-history",children:[
902
902
  /* @__PURE__ */B(f,{style:{flexDirection:"row",flexWrap:"wrap",rowGap:Zl(".efh-key","rowGap"),columnGap:Zl(".efh-key","columnGap"),marginBottom:16},testID:"everfur-records-sheet-history-key",children:c.map(([e,t])=>/* @__PURE__ */j(f,{style:{flexDirection:"row",alignItems:"center",gap:Zl(".efh-key span","gap")},children:[
903
903
  /* @__PURE__ */B(f,{style:{width:Zl(".efh-key span::before","width"),height:Zl(".efh-key span::before","width"),borderRadius:999,borderWidth:2.5,borderColor:d(e),backgroundColor:l.white}}),
904
904
  /* @__PURE__ */B(HubText,{variant:"fine",style:{fontSize:Zl(".efh-key","fontSize"),lineHeight:Zl(".efh-key","lineHeight")},children:t})]},e))}),s.map((e,t)=>/* @__PURE__ */j(f,{children:[
@@ -984,17 +984,17 @@ return j(f,{style:{flex:1},children:[
984
984
  /* @__PURE__ */B(Text,{style:a.labTitle,accessibilityRole:"header",children:e.name}),e.meta!==null?/* @__PURE__ */B(Text,{style:a.labMeta,children:e.meta}):null]}),
985
985
  /* @__PURE__ */j(SheetCard,{children:[
986
986
  /* @__PURE__ */j(f,{style:a.cardHead,children:[
987
- /* @__PURE__ */B(Text,{style:a.cardTitle,accessibilityRole:"header",children:Cm.latestReading}),e.pill!==null?/* @__PURE__ */B(SheetPill,{label:e.pill,tone:e.flagged?"high":"clear"}):null]}),
987
+ /* @__PURE__ */B(Text,{style:a.cardTitle,accessibilityRole:"header",children:_m.latestReading}),e.pill!==null?/* @__PURE__ */B(SheetPill,{label:e.pill,tone:e.flagged?"high":"clear"}):null]}),
988
988
  /* @__PURE__ */j(f,{style:a.latest,children:[
989
989
  /* @__PURE__ */B(Text,{style:[a.wtValue,{color:e.flagged?s.alert:s.ink}],children:e.latest}),
990
990
  /* @__PURE__ */B(Text,{style:a.latestSub,children:e.latestSub})]}),
991
991
  /* @__PURE__ */B(LabChart,{model:e}),e.change!==null?/* @__PURE__ */j(Text,{style:a.change,children:[
992
992
  /* @__PURE__ */B(Text,{style:a.changeLead,children:e.change.lead}),e.change.rest]}):null]}),t!==void 0?/* @__PURE__ */B(HostRender,{render:()=>t(e.markerId),fallback:null,resetKey:e.markerId}):null,r!==void 0?/* @__PURE__ */B(HostRender,{render:()=>r(e.markerId),fallback:null,resetKey:`${e.markerId}-note`}):null,e.meaning.length>0?/* @__PURE__ */j(SheetCard,{children:[
993
- /* @__PURE__ */B(Text,{style:[a.cardTitle,a.cardTitleGap],accessibilityRole:"header",children:Cm.whatIs(e.name)}),
993
+ /* @__PURE__ */B(Text,{style:[a.cardTitle,a.cardTitleGap],accessibilityRole:"header",children:_m.whatIs(e.name)}),
994
994
  /* @__PURE__ */B(f,{style:a.ctx,children:e.meaning.map((e,t)=>/* @__PURE__ */B(Text,{style:a.ctxText,children:e},t))})]}):null,e.groups.map((e,t)=>/* @__PURE__ */j(SheetCard,{children:[
995
995
  /* @__PURE__ */j(f,{style:a.cardHead,children:[
996
- /* @__PURE__ */B(Text,{style:a.cardTitle,accessibilityRole:"header",children:e.title}),e.allInRange?/* @__PURE__ */B(SheetPill,{label:Cm.inRange,tone:"clear"}):null]}),
997
- /* @__PURE__ */B(f,{style:a.mks,children:e.rows.map(e=>/* @__PURE__ */B(SheetMarkerRow,{name:e.name,value:e.value,unit:e.unit,range:e.range,at:e.at,pill:e.flag==="above"?Cm.high:e.flag==="below"?Cm.belowRangePill:null},e.markerId))})]},`${e.title}-${t}`)),i!==void 0&&l!==void 0?/* @__PURE__ */B(HostRender,{render:()=>l(i,Cm.askAboutThis),fallback:null,resetKey:e.markerId}):null]}),d?/* @__PURE__ */B(RecordsAskPill,{label:Cm.askAboutThis,onPress:i,...n!==void 0?{icon:n}:{},testID:"everfur-records-lab-ask"}):null]})}function LabChart({model:e}){let{s:t,look:r}=uv();if(e.chart.length===0)return null;let n=e.hasRange;/* @__PURE__ */
996
+ /* @__PURE__ */B(Text,{style:a.cardTitle,accessibilityRole:"header",children:e.title}),e.allInRange?/* @__PURE__ */B(SheetPill,{label:_m.inRange,tone:"clear"}):null]}),
997
+ /* @__PURE__ */B(f,{style:a.mks,children:e.rows.map(e=>/* @__PURE__ */B(SheetMarkerRow,{name:e.name,value:e.value,unit:e.unit,range:e.range,at:e.at,pill:e.flag==="above"?_m.high:e.flag==="below"?_m.belowRangePill:null},e.markerId))})]},`${e.title}-${t}`)),i!==void 0&&l!==void 0?/* @__PURE__ */B(HostRender,{render:()=>l(i,_m.askAboutThis),fallback:null,resetKey:e.markerId}):null]}),d?/* @__PURE__ */B(RecordsAskPill,{label:_m.askAboutThis,onPress:i,...n!==void 0?{icon:n}:{},testID:"everfur-records-lab-ask"}):null]})}function LabChart({model:e}){let{s:t,look:r}=uv();if(e.chart.length===0)return null;let n=e.hasRange;/* @__PURE__ */
998
998
  return j(f,{style:t.chart,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:[
999
999
  /* @__PURE__ */j(f,{style:t.labBody,children:[n?/* @__PURE__ */j(A,{children:[
1000
1000
  /* @__PURE__ */j(f,{style:t.rail,children:[
@@ -1002,9 +1002,9 @@ return j(f,{style:t.chart,accessibilityElementsHidden:true,importantForAccessibi
1002
1002
  /* @__PURE__ */B(f,{style:{flex:2,backgroundColor:r.go}}),
1003
1003
  /* @__PURE__ */B(f,{style:{flex:1,backgroundColor:r.line}})]}),
1004
1004
  /* @__PURE__ */j(f,{style:t.legend,children:[
1005
- /* @__PURE__ */B(Text,{style:[t.range,{top:"6%"}],children:Cm.above}),
1006
- /* @__PURE__ */B(Text,{style:[t.range,{top:"44%"}],children:Cm.inRange}),
1007
- /* @__PURE__ */B(Text,{style:[t.range,{top:"82%"}],children:Cm.below})]})]}):null,
1005
+ /* @__PURE__ */B(Text,{style:[t.range,{top:"6%"}],children:_m.above}),
1006
+ /* @__PURE__ */B(Text,{style:[t.range,{top:"44%"}],children:_m.inRange}),
1007
+ /* @__PURE__ */B(Text,{style:[t.range,{top:"82%"}],children:_m.below})]})]}):null,
1008
1008
  /* @__PURE__ */j(f,{style:[t.plot,{flex:1}],children:[n?/* @__PURE__ */B(f,{style:t.band}):null,e.chart.length>1?/* @__PURE__ */B(ChartLine,{points:e.chart,color:r.ink}):null,e.chart.map((e,i)=>/* @__PURE__ */B(f,{style:[t.point,{left:`${e.x}%`,top:`${e.y}%`,backgroundColor:e.out?r.alert:n?r.go:r.ink}]},i)),e.chart.map((e,n)=>/* @__PURE__ */B(Text,{style:[t.pointLabel,{left:`${e.x}%`,top:`${e.y}%`,marginTop:-(10+(t.pointLabel.lineHeight??14))},e.out?{color:r.alert}:null],children:e.label},`v${n}`))]})]}),
1009
1009
  /* @__PURE__ */B(f,{style:[t.xAxis,n?{marginLeft:106}:null],children:e.chart.map((r,n)=>{let i=e.chart.length>1&&n===e.chart.length-1?"end":e.chart.length>1&&n===0?"start":null;/* @__PURE__ */
1010
1010
  return B(Text,{style:[t.xTick,i==="end"?{right:`${100-r.x}%`,marginLeft:0,marginRight:-4,textAlign:"right"}:i==="start"?{left:`${r.x}%`,marginLeft:-4,textAlign:"left"}:{left:`${r.x}%`}],children:r.tick},n)})})]})}function Pv(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function Ov(e){return e==="female"?"her":e==="male"?"his":null}function $v(e,t){let r=e?.trim()??"",n=r.length>0?r:Xn,i=Tm(n,t);/* @__PURE__ */
@@ -1012,25 +1012,25 @@ return Object.freeze({...i,Poss:Pv(i.Poss)})}function Bv(e){let t=e?.trim()??"";
1012
1012
  return B(CapabilityGate,{capability:"records",style:t,...r?{renderPending:r}:{},...Wo(n.onBack,jo),children:/* @__PURE__ */B(cv,{value:l,children:/* @__PURE__ */B(HubKitProvider,{handFamily:rw(n.options),theme:i,children:userRef===null?
1013
1013
  /* @__PURE__ */j(f,{style:[{flex:1},t],testID:"everfur-records-sheet-session-required",children:[
1014
1014
  /* @__PURE__ */B(SessionRequiredState,{}),
1015
- /* @__PURE__ */B(RecordsFootnote,{})]}):/* @__PURE__ */B(SheetScreen,{...n,style:t})})})})}function SheetScreen({petRef:petRef,petName:e,controller:t,consentVersion:l,consentScope:a,consentText:s,onNavigate:d,onBack:c,onAsk:u,options:h=tw,style:p}){let{s:g,look:m}=uv(),y=ey(),v=useEverfurRecords({petRef:petRef,readUploadFeatures:true,...t?{controller:t}:{},...a?{consentScope:a}:{}}),w=useRecordsMarkers(petRef),k=useRecordsDepthRead(petRef,Qv,Jv),x=useRecordsDepthRead(petRef,Zv,ew),{pets:T}=useEverfurPets(),R=T.find(e=>e.petRef===petRef)??null,S=n(()=>h.topRiskLine===void 0?h.presentation??null:{...h.presentation,recordsTopRiskLine:h.topRiskLine},[h.presentation,h.topRiskLine]),z=useEverfurPresentation(S),I=n(()=>tv(h.stage),[h.stage]);lh(l,s);let D=n(()=>Dc(l,v.consent),[l,v.consent]),H=n(()=>ep(v,l),[v,l]),L=useCapability("recordsClinic"),P=L.enabled||L.isPending,[O,$]=i(null),A=h.active??true,[E,F]=i(()=>C.currentState!=="background");o(()=>{let e=C.addEventListener("change",e=>F(e==="active"));return()=>e.remove()},[]);let q=km(h.nowMs,A&&E),M=useEverfurTheme().motion.reducedMotion,N=jb(I===void 0&&h.renderStage===void 0?petRef:null,{reducedMotion:M,isFocused:A&&E}),W=h.pronoun??Ov(h.sex)??Ov(Kv(v.record))??null,U=W===null&&v.status!=="loading",G=useCapability("healthPlan"),V=useHealthPlanPage({petRef:petRef,enabled:G.enabled&&(z.recordsTopRiskLine||U)}),K=V.page?.pet??null,Y=W??Ov(Vv(K)),X=e?.trim()||R?.name?.trim()||K?.name?.trim()||"",Q=h.species??R?.species??K?.species??null,J=h.weightUnit??"lb",Z=$v(X,Y),ee=R?.breed??K?.breed??null,te=n(()=>ab({words:Z,record:v.record,depth:k.value,markers:w.markers,timeline:x.value,requests:v.requests,breed:ee,petWeightKg:R?.weightKg??K?.weightKg??null,nowMs:q}),[X,Y,v.record,v.requests,k.value,w.markers,x.value,R,K,q]),re=n(()=>vy(v.record,x.value,J),[v.record,x.value,J]),ne=r(null),ie=r(0),le=r(0),oe=py(ee,R?.ageYears??null,re),ae=Uv(v.requests,petRef),se=z.recordsTopRiskLine?Gv(V.page?.page?.focus):null,de=[w.markers?.disclaimer,v.record?.disclaimer,x.value?.disclaimer].map(e=>e?.trim()??"").find(e=>e.length>0)??"";o(()=>{if(O===null||!A)return;let e=_.addEventListener("hardwareBackPress",()=>($(null),true));return()=>{e.remove()}},[O,A]);let ce=e=>{h.onOpenMarker!==void 0?h.onOpenMarker(e):$(e)},ue=Av(v.requests,petRef),he=d!==void 0,pe={request:()=>{if(h.onRequestFromClinic!==void 0){let e=h.onRequestFromClinic({petRef:petRef});e!==void 0&&typeof e.then=="function"&&e.then(()=>v.refresh(),()=>v.refresh()).then(void 0,()=>{})}else d?.({name:"clinicPicker"})},upload:()=>d?.({name:"upload"}),record:()=>d?.({name:"record"})},ge=te.history.length>0?()=>ne.current?.scrollTo({y:Math.max(0,ie.current+le.current),animated:!M}):he?pe.record:void 0,fe=he?e=>d?.({name:"request",requestId:e}):void 0,me=()=>Promise.all([v.refresh(),w.refresh(),k.refresh(),x.refresh()].map(e=>Promise.resolve(e).then(void 0,()=>{}))).then(()=>{}),be=Kp(me,"everfur-records-sheet-refresh"),ye=n(()=>v.requests.filter(e=>e.petRef===petRef),[v.requests,petRef]),ve=n(()=>Cb(X,ye),[X,ye]),we=acceptsPhotos(v.uploadContentTypes)?Cm.uploadDetail:gb.uploadFormatHint,ke=Tb(k.value,v.record!==null?Fm(v.record).observedMs:null),xe=iw(),Te=Ev(v.requests,petRef)?.clinicName?.trim()||null,Ce=Te!==null?xe.show:pe.request,_e=Te!==null&&xe.on?/* @__PURE__ */B(RequestedNote,{clinic:Te},xe.shown):null;if(O!==null)/* @__PURE__ */
1015
+ /* @__PURE__ */B(RecordsFootnote,{})]}):/* @__PURE__ */B(SheetScreen,{...n,style:t})})})})}function SheetScreen({petRef:petRef,petName:e,controller:t,consentVersion:l,consentScope:a,consentText:s,onNavigate:d,onBack:c,onAsk:u,options:h=tw,style:p}){let{s:g,look:m}=uv(),y=ey(),v=useEverfurRecords({petRef:petRef,readUploadFeatures:true,...t?{controller:t}:{},...a?{consentScope:a}:{}}),w=useRecordsMarkers(petRef),k=useRecordsDepthRead(petRef,Qv,Jv),x=useRecordsDepthRead(petRef,Zv,ew),{pets:T}=useEverfurPets(),R=T.find(e=>e.petRef===petRef)??null,S=n(()=>h.topRiskLine===void 0?h.presentation??null:{...h.presentation,recordsTopRiskLine:h.topRiskLine},[h.presentation,h.topRiskLine]),z=useEverfurPresentation(S),I=n(()=>tv(h.stage),[h.stage]);lh(l,s);let D=n(()=>Dc(l,v.consent),[l,v.consent]),H=n(()=>ep(v,l),[v,l]),L=useCapability("recordsClinic"),P=L.enabled||L.isPending,[O,$]=i(null),A=h.active??true,[E,F]=i(()=>_.currentState!=="background");o(()=>{let e=_.addEventListener("change",e=>F(e==="active"));return()=>e.remove()},[]);let q=km(h.nowMs,A&&E),M=useEverfurTheme().motion.reducedMotion,N=jb(I===void 0&&h.renderStage===void 0?petRef:null,{reducedMotion:M,isFocused:A&&E}),W=h.pronoun??Ov(h.sex)??Ov(Kv(v.record))??null,U=W===null&&v.status!=="loading",G=useCapability("healthPlan"),V=useHealthPlanPage({petRef:petRef,enabled:G.enabled&&(z.recordsTopRiskLine||U)}),K=V.page?.pet??null,Y=W??Ov(Vv(K)),X=e?.trim()||R?.name?.trim()||K?.name?.trim()||"",Q=h.species??R?.species??K?.species??null,J=h.weightUnit??"lb",Z=$v(X,Y),ee=R?.breed??K?.breed??null,te=n(()=>ab({words:Z,record:v.record,depth:k.value,markers:w.markers,timeline:x.value,requests:v.requests,breed:ee,petWeightKg:R?.weightKg??K?.weightKg??null,nowMs:q}),[X,Y,v.record,v.requests,k.value,w.markers,x.value,R,K,q]),re=n(()=>vy(v.record,x.value,J),[v.record,x.value,J]),ne=r(null),ie=r(0),le=r(0),oe=py(ee,R?.ageYears??null,re),ae=Uv(v.requests,petRef),se=z.recordsTopRiskLine?Gv(V.page?.page?.focus):null,de=[w.markers?.disclaimer,v.record?.disclaimer,x.value?.disclaimer].map(e=>e?.trim()??"").find(e=>e.length>0)??"";o(()=>{if(O===null||!A)return;let e=C.addEventListener("hardwareBackPress",()=>($(null),true));return()=>{e.remove()}},[O,A]);let ce=e=>{h.onOpenMarker!==void 0?h.onOpenMarker(e):$(e)},ue=Av(v.requests,petRef),he=d!==void 0,pe={request:()=>{if(h.onRequestFromClinic!==void 0){let e=h.onRequestFromClinic({petRef:petRef});e!==void 0&&typeof e.then=="function"&&e.then(()=>v.refresh(),()=>v.refresh()).then(void 0,()=>{})}else d?.({name:"clinicPicker"})},upload:()=>d?.({name:"upload"}),record:()=>d?.({name:"record"})},ge=te.history.length>0?()=>ne.current?.scrollTo({y:Math.max(0,ie.current+le.current),animated:!M}):he?pe.record:void 0,fe=he?e=>d?.({name:"request",requestId:e}):void 0,me=()=>Promise.all([v.refresh(),w.refresh(),k.refresh(),x.refresh()].map(e=>Promise.resolve(e).then(void 0,()=>{}))).then(()=>{}),be=Kp(me,"everfur-records-sheet-refresh"),ye=n(()=>v.requests.filter(e=>e.petRef===petRef),[v.requests,petRef]),ve=n(()=>_b(X,ye),[X,ye]),we=acceptsPhotos(v.uploadContentTypes)?_m.uploadDetail:gb.uploadFormatHint,ke=Tb(k.value,v.record!==null?Fm(v.record).observedMs:null),xe=iw(),Te=Ev(v.requests,petRef)?.clinicName?.trim()||null,_e=Te!==null?xe.show:pe.request,Ce=Te!==null&&xe.on?/* @__PURE__ */B(RequestedNote,{clinic:Te},xe.shown):null;if(O!==null)/* @__PURE__ */
1016
1016
  return j(f,{style:[{flex:1,backgroundColor:m.ground},p],children:[
1017
1017
  /* @__PURE__ */B(RecordsPushHeader,{title:jv.labsTitle(Z),onBack:()=>$(null),look:m,testID:"everfur-records-lab-header"}),
1018
1018
  /* @__PURE__ */B(EverfurRecordsLabDetail,{petRef:petRef,markerId:O,...X.length>0?{petName:X}:{},...u?{onAsk:u}:{}}),
1019
1019
  /* @__PURE__ */B(RecordsFootnote,{})]});let Re,Se="full",ze=true,Ie=ae!==null?/* @__PURE__ */B(FailedLine,{label:ae.label,onPress:he?()=>d?.({name:"request",requestId:ae.id}):void 0}):null,De=h.renderTopSlot!==void 0?/* @__PURE__ */B(f,{testID:"everfur-records-sheet-top-slot",children:/* @__PURE__ */B(HostRender,{render:()=>h.renderTopSlot?.({clearResultsFilter:z.recordsClearResultsFilter})??null,fallback:null,resetKey:petRef})}):null,He=se!==null?/* @__PURE__ */B(TopRisk,{words:Z,text:se,onOpenPlan:h.onOpenPlan,start:h.topRiskPlanAction==="start"}):null,Le=(...e)=>{let t=e.filter(e=>e!=null&&e!==false);return t.length===0?null:/* @__PURE__ */B(f,{style:{paddingTop:Zl(".rec","paddingTop"),paddingHorizontal:Zl(".rec","paddingLeft"),gap:Zl(".rec-dna","marginTop")},testID:"everfur-records-sheet-paper",children:t})},Pe=e=>[g.sheet,{backgroundColor:y.look.bg,gap:Vb.screen.gap},e?{marginTop:Zl(".efh-sheet","marginTop")}:{borderTopLeftRadius:0,borderTopRightRadius:0}],Oe=u,$e=Oe!==void 0&&h.askBar!==false?/* @__PURE__ */B(RecordsAskBar,{placeholder:jv.askRecords(Z),label:jv.askField(Z),sendLabel:jv.askSend,addLabel:jv.askAdd,...he?{onAdd:pe.upload}:{},onSend:e=>Oe(e,{type:"records",id:petRef}),ground:m.paper,ink:m.dark?m.text:Kl.topInk,muted:m.dark?m.muted:Kl.embInk3,field:m.card}):null,Be=h.renderUpcomingCareAction===void 0?h.onSpeakToVet:void 0,je=de.length>0&&!To(de)?/* @__PURE__ */B(HubDisclaimer,{text:de}):null,Ae=h.vitalsLine!==void 0?h.vitalsLine?.trim()||null:ke!==null?gb.vitalsFrom(ke.vet,ke.date).trim():null,Ee=e=>/* @__PURE__ */B(HubHero,{headPill:e?null:Xv(h.headPill),fromLine:e?null:Ae,name:X.length>0?Z.Name:Bv(X),meta:oe,stage:I,art:N,handFontFamily:rw(h),say:e,vitals:e?[]:te.vitals,vitalsName:Z.name,renderStage:h.renderStage,exam:e?null:ke,onOpenExam:he?pe.record:void 0});if(v.status==="loading"&&v.record===null)Re=/* @__PURE__ */B(HubSkeleton,{}),Se="loading",ze=false;else if(v.status==="error"){let e=Hc(v,D);Lc(e)?(Se="consent",Re=/* @__PURE__ */j(b,{contentContainerStyle:{flexGrow:1},refreshControl:be,children:[Le(He,De),
1020
- /* @__PURE__ */j(f,{style:Pe(He!==null||De!==null),testID:"everfur-records-sheet-content",children:[Zh(v,H,D,s,true),he?/* @__PURE__ */B(HubAddRecords,{words:Z,sources:[],canRequest:P,onRequest:Ce,onUpload:pe.upload,note:_e,uploadHint:we}):null,
1020
+ /* @__PURE__ */j(f,{style:Pe(He!==null||De!==null),testID:"everfur-records-sheet-content",children:[Zh(v,H,D,s,true),he?/* @__PURE__ */B(HubAddRecords,{words:Z,sources:[],canRequest:P,onRequest:_e,onUpload:pe.upload,note:Ce,uploadHint:we}):null,
1021
1021
  /* @__PURE__ */B(HubLegal,{})]})]})):e.kind==="error"||e.kind==="pet_not_found"?(Se="error",ze=false,Re=/* @__PURE__ */B(RecordsEmptyState,{variant:ai(e.error),message:e.error.displayMessage,onAction:e.error.retryable?me:void 0,testID:"everfur-records-sheet-error"})):(Se=e.kind,ze=false,Re=Zh(v,H,D,s))}else if(te.state!=="full")Se=ue===null?"none":Fv(ue)?"processing":"onTheWay",Re=/* @__PURE__ */B(b,{contentContainerStyle:{flexGrow:1},refreshControl:be,children:/* @__PURE__ */j(f,{testID:"everfur-records-sheet-content",style:[{flexGrow:1},h.style],children:[Le(He,De,Ie),
1022
- /* @__PURE__ */j(f,{style:Pe(He!==null||De!==null||Ie!==null),children:[Ee(true),Se==="onTheWay"&&ue!==null?/* @__PURE__ */B(HubOnTheWay,{words:Z,request:ue,steps:qv(ue.status),sentWhen:Nv(ue.createdAt,q),canAct:he,canRequest:P,onAnotherClinic:pe.request,onUpload:pe.upload,onOpenRequest:fe!==void 0?()=>fe(ue.id):void 0}):Se==="processing"&&ue!==null?/* @__PURE__ */B(HubInProgress,{words:Z,request:ue,onOpenRequest:fe!==void 0?()=>fe(ue.id):void 0}):/* @__PURE__ */B(HubPrompt,{title:h.noVet===true?Ab.noVetTitle(Z):Ab.addRecords(Z.name),canAct:he,canRequest:P,onRequest:Ce,onUpload:pe.upload,note:_e}),re!==null?/* @__PURE__ */B(HubWeightCard,{weight:re,name:Z.name,chart:h.weightChart??"phone"}):null,
1022
+ /* @__PURE__ */j(f,{style:Pe(He!==null||De!==null||Ie!==null),children:[Ee(true),Se==="onTheWay"&&ue!==null?/* @__PURE__ */B(HubOnTheWay,{words:Z,request:ue,steps:qv(ue.status),sentWhen:Nv(ue.createdAt,q),canAct:he,canRequest:P,onAnotherClinic:pe.request,onUpload:pe.upload,onOpenRequest:fe!==void 0?()=>fe(ue.id):void 0}):Se==="processing"&&ue!==null?/* @__PURE__ */B(HubInProgress,{words:Z,request:ue,onOpenRequest:fe!==void 0?()=>fe(ue.id):void 0}):/* @__PURE__ */B(HubPrompt,{title:h.noVet===true?Ab.noVetTitle(Z):Ab.addRecords(Z.name),canAct:he,canRequest:P,onRequest:_e,onUpload:pe.upload,note:Ce}),re!==null?/* @__PURE__ */B(HubWeightCard,{weight:re,name:Z.name,chart:h.weightChart??"phone"}):null,
1023
1023
  /* @__PURE__ */B(HubSamplePeek,{name:Z.name,poss:Z.poss,species:Q}),je,
1024
1024
  /* @__PURE__ */B(HubLegal,{})]})]})});else{let e=by(v.record?.forwardLooking??[],q),t=new Map((v.record?.forwardLooking??[]).map(e=>[e.careItemKey?.trim()||e.title,e])),r=yy(v.record,w.markers,k.value,x.value),n=te.featuredMarkerId,i=r.screeningsPill?.markerId??null,l=w.status==="error"||x.status==="error",o=(w.status==="error"?w.error:null)??(x.status==="error"?x.error:null);Re=/* @__PURE__ */B(b,{ref:ne,contentContainerStyle:{flexGrow:1},refreshControl:be,children:/* @__PURE__ */j(f,{testID:"everfur-records-sheet-content",style:[{flexGrow:1},h.style],children:[Le(He,De,Ie),
1025
1025
  /* @__PURE__ */j(f,{style:Pe(He!==null||De!==null||Ie!==null),onLayout:e=>{ie.current=e.nativeEvent.layout.y},children:[Ee(false),l?
1026
1026
  /* @__PURE__ */B(RecordsEmptyState,{variant:ai(o),onAction:me,testID:"everfur-records-sheet-partial-error"}):null,e.length>0?/* @__PURE__ */B(HubUpcoming,{rows:e,items:t,onViewAll:ge,renderAction:h.renderUpcomingCareAction,...Be!==void 0?{actionLabel:jv.speakToVet,onAction:Be}:{}}):/* @__PURE__ */B(HubUpcomingEmpty,{name:Z.name}),
1027
1027
  /* @__PURE__ */B(HubTilesSection,{tiles:r,labsUnknown:w.status==="loading"||w.status==="error",onOpenLabs:n!==null?()=>ce(n):he?pe.record:void 0,onOpenScreenings:h.onOpenScreenings??(i!==null?()=>ce(i):he?pe.record:void 0),onOpenVisits:he?pe.record:void 0,onOpenTimeline:ge,...h.screeningsPills!==void 0?{screeningsPills:h.screeningsPills.map(Xv).filter(e=>e!==null)}:{}}),
1028
1028
  /* @__PURE__ */B(HubWeightCard,{weight:re,name:Z.name,chart:h.weightChart??"phone",extras:{status:Xv(h.weightStatus),prediction:h.weightPrediction??null,...h.weightKey!==void 0?{key:h.weightKey}:{}}}),
1029
- /* @__PURE__ */B(HubMedications,{medications:te.medications}),te.history.length>0||(h.historyItems?.length??0)>0?/* @__PURE__ */B(f,{onLayout:e=>{le.current=e.nativeEvent.layout.y},testID:"everfur-records-sheet-history-anchor",children:/* @__PURE__ */B(HubHistory,{words:Z,history:te.history,onOpenMarker:ce,...h.historySources!==void 0?{sourceKey:h.historySources}:{},...h.historyItems!==void 0?{extra:h.historyItems}:{}})}):null,he?/* @__PURE__ */B(HubAddRecords,{words:Z,sources:Yv(h.onFileRows)??Oy(v.record,k.value),canRequest:P,onRequest:Ce,onUpload:pe.upload,note:_e,inFlight:ve,onOpenRequest:fe,uploadHint:we}):null,je,
1029
+ /* @__PURE__ */B(HubMedications,{medications:te.medications}),te.history.length>0||(h.historyItems?.length??0)>0?/* @__PURE__ */B(f,{onLayout:e=>{le.current=e.nativeEvent.layout.y},testID:"everfur-records-sheet-history-anchor",children:/* @__PURE__ */B(HubHistory,{words:Z,history:te.history,onOpenMarker:ce,...h.historySources!==void 0?{sourceKey:h.historySources}:{},...h.historyItems!==void 0?{extra:h.historyItems}:{}})}):null,he?/* @__PURE__ */B(HubAddRecords,{words:Z,sources:Yv(h.onFileRows)??Oy(v.record,k.value),canRequest:P,onRequest:_e,onUpload:pe.upload,note:Ce,inFlight:ve,onOpenRequest:fe,uploadHint:we}):null,je,
1030
1030
  /* @__PURE__ */B(HubLegal,{})]})]})})}/* @__PURE__ */
1031
1031
  return j(f,{style:[{flex:1,backgroundColor:ze?m.paper:m.ground},p],testID:"everfur-records-sheet",children:[c!==void 0?/* @__PURE__ */B(go,{value:"legacy",children:/* @__PURE__ */B(ScreenHeader,{title:Jn.titleNative(e),onBack:c,testID:"everfur-records-sheet-header"})}):null,
1032
1032
  /* @__PURE__ */B(f,{style:{flex:1},testID:`everfur-records-sheet-state-${Se}`,children:Re}),ze?$e:/* @__PURE__ */B(RecordsFootnote,{})]})}var nw=2600;function iw(){let[e,t]=i(false),[n,a]=i(0),s=r(null);o(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]);let d=l(()=>{s.current!==null&&clearTimeout(s.current),t(true),a(e=>e+1),s.current=setTimeout(()=>{s.current=null,t(false)},nw)},[]);return{on:e,shown:n,show:d}}function RequestedNote({clinic:e}){let{look:t}=ey();/* @__PURE__ */
1033
- return B(f,{accessibilityLiveRegion:"polite",style:{paddingVertical:Vb.upcoming.rowPadY,paddingHorizontal:Vb.card.pad,borderRadius:Vb.card.radius,backgroundColor:t.fill},testID:"everfur-records-sheet-requested-note",children:/* @__PURE__ */B(HubText,{variant:"bodySm",color:t.onFill,children:Cm.requestedFrom(e)})})}function HubDisclaimer({text:e}){let{type:t}=ey();/* @__PURE__ */
1033
+ return B(f,{accessibilityLiveRegion:"polite",style:{paddingVertical:Vb.upcoming.rowPadY,paddingHorizontal:Vb.card.pad,borderRadius:Vb.card.radius,backgroundColor:t.fill},testID:"everfur-records-sheet-requested-note",children:/* @__PURE__ */B(HubText,{variant:"bodySm",color:t.onFill,children:_m.requestedFrom(e)})})}function HubDisclaimer({text:e}){let{type:t}=ey();/* @__PURE__ */
1034
1034
  return B(Text,{style:[t("fine"),{textAlign:"center",marginTop:Vb.screen.legalTop}],testID:"everfur-records-sheet-disclaimer",children:e})}function TopRisk({words:e,text:t,onOpenPlan:r,start:n}){let{s:i,look:l}=uv(),o=n?jv.startPlan(e):jv.seePlan(e);/* @__PURE__ */
1035
1035
  return j(SheetCard,{style:i.topRisk,testID:"everfur-records-sheet-top-risk",children:[
1036
1036
  /* @__PURE__ */j(f,{style:i.topRiskKicker,children:[
@@ -1038,7 +1038,7 @@ return j(SheetCard,{style:i.topRisk,testID:"everfur-records-sheet-top-risk",chil
1038
1038
  /* @__PURE__ */B(Text,{style:i.topRiskK,children:jv.topRiskKicker(e)})]}),
1039
1039
  /* @__PURE__ */B(Text,{style:i.topRiskText,children:t}),r!==void 0?
1040
1040
  /* @__PURE__ */B(m,{onPress:r,accessibilityRole:"button",accessibilityLabel:o,style:({pressed:e})=>[i.button,i.buttonRow,{alignSelf:"flex-start",marginTop:Zl(".rec-top .emb-btn","marginTop"),backgroundColor:l.topInk},e?{transform:[{scale:.97}]}:null],testID:"everfur-records-sheet-top-risk-plan",children:/* @__PURE__ */B(Text,{tier:"control",style:[i.buttonText,i.buttonTextRow,{color:Vl(l.topInk,[Kl.efWhite,Kl.topInk])}],children:o})}):null]})}function FailedLine({label:e,onPress:t}){let{s:r,look:n}=uv(),i=/* @__PURE__ */j(A,{children:[
1041
- /* @__PURE__ */B(Text,{style:r.failedText,children:e}),t!==void 0?/* @__PURE__ */B(SheetIcon,{kind:"chevron",size:20,color:n.alertDeep}):null]});return t!==void 0?/* @__PURE__ */B(m,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:r.failed,testID:"everfur-records-sheet-failed",children:i}):/* @__PURE__ */B(f,{style:r.failed,testID:"everfur-records-sheet-failed",children:i})}function EverfurRecordsFlow(e){let{petRef:petRef,petName:t,controller:r,clinicController:i,onPickDocument:s,onPickPhotos:d,uploadTransport:c,consentVersion:u,consentScope:h,consentText:p,ownerName:g,onCaptureSignature:f,initialScreen:m,onExit:b,style:y,renderPending:v,onOpenUrl:w,onCopy:k,onAsk:x,location:T,sheet:C=true,onNavigate:R,alwaysShowWays:S,renderUpcomingCareAction:z,noVet:I,weightUnit:D,onOpenPlan:H,onSpeakToVet:L,onOpenScreenings:P,onRequestFromClinic:O}=Zr(e,["onExit","onNavigate"]),$=n(()=>C===false?null:{...Vr({renderUpcomingCareAction:z,noVet:I,weightUnit:D,onOpenPlan:H,onSpeakToVet:L,onOpenScreenings:P,onRequestFromClinic:O}),...typeof C=="object"?Vr(C):{}},[C,z,I,D,H,L,P,O]),[j,A]=a(recordsNavReducer,m,initialRecordsNav),E=currentRecordsScreen(j),F=j.stack.length;o(()=>{let e=()=>F<=1?false:(A({type:"pop"}),true),t=_.addEventListener("hardwareBackPress",e);return()=>{t.remove()}},[F]);let q=l(e=>{R?R(e):A({type:"navigate",screen:e})},[R]),M=n(()=>popRecordsNav(j).handled?()=>A({type:"pop"}):b,[j,b]),N={onNavigate:q,...M?{onBack:M}:{},...t!==void 0?{petName:t}:{},...w?{onOpenUrl:w}:{},...k?{onCopy:k}:{},...x?{onAsk:x}:{},...T?{location:T}:{}},W={...r?{controller:r}:{},...u!==void 0?{consentVersion:u}:{},...h!==void 0?{consentScope:h}:{},...p!==void 0?{consentText:p}:{}},U={...s?{onPickDocument:s}:{},...d?{onPickPhotos:d}:{},...c?{uploadTransport:c}:{}},G=v?{renderPending:v}:{};/* @__PURE__ */
1041
+ /* @__PURE__ */B(Text,{style:r.failedText,children:e}),t!==void 0?/* @__PURE__ */B(SheetIcon,{kind:"chevron",size:20,color:n.alertDeep}):null]});return t!==void 0?/* @__PURE__ */B(m,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:r.failed,testID:"everfur-records-sheet-failed",children:i}):/* @__PURE__ */B(f,{style:r.failed,testID:"everfur-records-sheet-failed",children:i})}function EverfurRecordsFlow(e){let{petRef:petRef,petName:t,controller:r,clinicController:i,onPickDocument:s,onPickPhotos:d,uploadTransport:c,consentVersion:u,consentScope:h,consentText:p,ownerName:g,onCaptureSignature:f,initialScreen:m,onExit:b,style:y,renderPending:v,onOpenUrl:w,onCopy:k,onAsk:x,location:T,sheet:_=true,onNavigate:R,alwaysShowWays:S,renderUpcomingCareAction:z,noVet:I,weightUnit:D,onOpenPlan:H,onSpeakToVet:L,onOpenScreenings:P,onRequestFromClinic:O}=Zr(e,["onExit","onNavigate"]),$=n(()=>_===false?null:{...Vr({renderUpcomingCareAction:z,noVet:I,weightUnit:D,onOpenPlan:H,onSpeakToVet:L,onOpenScreenings:P,onRequestFromClinic:O}),...typeof _=="object"?Vr(_):{}},[_,z,I,D,H,L,P,O]),[j,A]=a(recordsNavReducer,m,initialRecordsNav),E=currentRecordsScreen(j),F=j.stack.length;o(()=>{let e=()=>F<=1?false:(A({type:"pop"}),true),t=C.addEventListener("hardwareBackPress",e);return()=>{t.remove()}},[F]);let q=l(e=>{R?R(e):A({type:"navigate",screen:e})},[R]),M=n(()=>popRecordsNav(j).handled?()=>A({type:"pop"}):b,[j,b]),N={onNavigate:q,...M?{onBack:M}:{},...t!==void 0?{petName:t}:{},...w?{onOpenUrl:w}:{},...k?{onCopy:k}:{},...x?{onAsk:x}:{},...T?{location:T}:{}},W={...r?{controller:r}:{},...u!==void 0?{consentVersion:u}:{},...h!==void 0?{consentScope:h}:{},...p!==void 0?{consentText:p}:{}},U={...s?{onPickDocument:s}:{},...d?{onPickPhotos:d}:{},...c?{uploadTransport:c}:{}},G=v?{renderPending:v}:{};/* @__PURE__ */
1042
1042
  return B(go,{value:$===null?"legacy":"sheet",children:V()});function V(){switch(E.name){case"dashboard":return $!==null?/* @__PURE__ */B(EverfurRecordsSheet,{petRef:petRef,...N,...W,...G,options:$,style:y}):/* @__PURE__ */B(EverfurRecordsDashboard,{petRef:petRef,...N,...W,...G,...S===true?{alwaysShowWays:S}:{},style:y});case"request":/* @__PURE__ */
1043
1043
  return B(EverfurRecordsRequest,{petRef:petRef,requestId:E.requestId,...N,...W,...U,...G,style:y});case"timeline":/* @__PURE__ */
1044
1044
  return B(EverfurRecordsTimeline,{petRef:petRef,...N,style:y});case"record":/* @__PURE__ */