@everfur/sdk 0.5.9 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/CHANGELOG.md +279 -0
  2. package/dist/{BookedScreen-BJPbXLCG.d.ts → BookedScreen-DFJcgf1e.d.ts} +12 -2
  3. package/dist/{BookedScreen-Cnld-jB_.d.cts → BookedScreen-R5X_Zrlh.d.cts} +12 -2
  4. package/dist/{Chat-C9dVhnyt.d.ts → Chat-DZpYH8Uh.d.ts} +4 -4
  5. package/dist/{Chat-WmdRwC3b.d.cts → Chat-bATY4atj.d.cts} +4 -4
  6. package/dist/{DepthViews-CBoI9EYy.d.ts → DepthViews-BpHUbjSY.d.cts} +1 -1
  7. package/dist/{DepthViews-CmxhM8iP.d.ts → DepthViews-C4DC4Kom.d.cts} +1 -1
  8. package/dist/{DepthViews-NPFtO5Kz.d.cts → DepthViews-dLTizxjr.d.ts} +1 -1
  9. package/dist/{DepthViews-DoODlUnQ.d.cts → DepthViews-qBIoA48w.d.ts} +1 -1
  10. package/dist/animations/index.cjs +1 -1
  11. package/dist/animations/index.d.cts +3 -3
  12. package/dist/animations/index.d.ts +3 -3
  13. package/dist/animations/index.js +1 -1
  14. package/dist/{attachments-R2oajKPT.d.ts → attachments-CPRFfoHT.d.ts} +2 -2
  15. package/dist/{attachments-c4mJcIWU.d.cts → attachments-CUOGILir.d.cts} +5 -5
  16. package/dist/{attachments-CuFT1o5q.d.ts → attachments-CXAnZcEg.d.ts} +5 -5
  17. package/dist/{attachments-OaW36D0H.d.cts → attachments-Ce06TWqe.d.cts} +2 -2
  18. package/dist/{bookingCopy-DGQPrisa.d.cts → bookingCopy-BwVopcoV.d.cts} +451 -50
  19. package/dist/{bookingCopy-EtPJ4nME.d.ts → bookingCopy-DFTv9w6J.d.ts} +451 -50
  20. package/dist/{bookingTypes-DCs8mmBb.d.cts → bookingTypes-D4pD3tHs.d.cts} +13 -1
  21. package/dist/{bookingTypes-DCs8mmBb.d.ts → bookingTypes-D4pD3tHs.d.ts} +13 -1
  22. package/dist/{branding-Ry0em51L.d.ts → branding-Bio5MM6g.d.cts} +135 -3
  23. package/dist/{branding-DiaCIJZL.d.cts → branding-ytH4jJq1.d.ts} +135 -3
  24. package/dist/{callCopy-CPe9mbwG.d.cts → callCopy-DHjem0R-.d.cts} +12 -1
  25. package/dist/{callCopy-CPe9mbwG.d.ts → callCopy-DHjem0R-.d.ts} +12 -1
  26. package/dist/{casesRepository-DB5c8AAo.d.cts → casesRepository-CJchNp3x.d.cts} +1 -1
  27. package/dist/{casesRepository-Cu8h8gQK.d.ts → casesRepository-DAVcY3jC.d.ts} +1 -1
  28. package/dist/chat/index.cjs +1 -1
  29. package/dist/chat/index.d.cts +9 -9
  30. package/dist/chat/index.d.ts +9 -9
  31. package/dist/chat/index.js +1 -1
  32. package/dist/client/index.cjs +6 -6
  33. package/dist/client/index.d.cts +10 -10
  34. package/dist/client/index.d.ts +10 -10
  35. package/dist/client/index.js +6 -6
  36. package/dist/{config-DlR_I-0S.d.ts → config-ZxwCylac.d.ts} +1 -1
  37. package/dist/{config-DQFMkaTU.d.cts → config-h5h6TsHL.d.cts} +1 -1
  38. package/dist/consent/index.cjs +1 -1
  39. package/dist/consent/index.d.cts +5 -5
  40. package/dist/consent/index.d.ts +5 -5
  41. package/dist/consent/index.js +1 -1
  42. package/dist/{context-DZEieVJ5.d.cts → context-CtsAgJnc.d.cts} +7 -7
  43. package/dist/{context-CLuquPRB.d.ts → context-DtPIshVA.d.ts} +7 -7
  44. package/dist/{copy-B2DOzSSy.d.cts → copy-CaWaplQc.d.cts} +2 -2
  45. package/dist/{copy-ptTCT5-J.d.ts → copy-Cg89Qoal.d.ts} +2 -2
  46. package/dist/core/index.cjs +9 -9
  47. package/dist/core/index.d.cts +21 -21
  48. package/dist/core/index.d.ts +21 -21
  49. package/dist/core/index.js +9 -9
  50. package/dist/{depth-CtyC7HOF.d.ts → depth-Bo4bAwcn.d.ts} +132 -38
  51. package/dist/{depth-DuOyvthD.d.cts → depth-EXZYEO70.d.cts} +132 -38
  52. package/dist/{entitlementRepository-DlGwxZ1k.d.cts → entitlementRepository-BYtVb1oU.d.cts} +3 -3
  53. package/dist/{entitlementRepository-CAtyh8Xt.d.ts → entitlementRepository-DcbIx8yV.d.ts} +3 -3
  54. package/dist/{identity-D_NR9ucT.d.ts → identity-EC5-apbY.d.ts} +1 -1
  55. package/dist/{identity-BC9AF3y4.d.cts → identity-b5Vp32Vp.d.cts} +1 -1
  56. package/dist/index.cjs +6 -6
  57. package/dist/index.d.cts +17 -17
  58. package/dist/index.d.ts +17 -17
  59. package/dist/index.js +6 -6
  60. package/dist/notifications/index.d.cts +2 -2
  61. package/dist/notifications/index.d.ts +2 -2
  62. package/dist/{pets-DuuNvKTK.d.ts → pets-B_27_agU.d.ts} +1 -1
  63. package/dist/{pets-D7UjvR1A.d.cts → pets-DM8QvKLo.d.cts} +1 -1
  64. package/dist/{petsRepository-llMvpMkp.d.cts → petsRepository-BJsJ4cju.d.cts} +1 -1
  65. package/dist/{petsRepository-C28NKFwy.d.ts → petsRepository-CuYZZaI5.d.ts} +1 -1
  66. package/dist/photo/index.cjs +1 -1
  67. package/dist/photo/index.js +1 -1
  68. package/dist/{ports-Dbw2h_M1.d.cts → ports-ZmJYgd5I.d.cts} +10 -9
  69. package/dist/{ports-s45HNNyc.d.ts → ports-nXHf50_X.d.ts} +10 -9
  70. package/dist/records/depth/index.cjs +2 -2
  71. package/dist/records/depth/index.d.cts +7 -7
  72. package/dist/records/depth/index.d.ts +7 -7
  73. package/dist/records/depth/index.js +2 -2
  74. package/dist/records/index.cjs +3 -3
  75. package/dist/records/index.d.cts +19 -10
  76. package/dist/records/index.d.ts +19 -10
  77. package/dist/records/index.js +3 -3
  78. package/dist/{requestFunnel-D_o7se38.d.cts → requestFunnel-C_cZXhIA.d.cts} +2 -2
  79. package/dist/{requestFunnel-CqwOiZNJ.d.ts → requestFunnel-Ve9BshTB.d.ts} +2 -2
  80. package/dist/{runtimeTypes-DS0RLoKN.d.ts → runtimeTypes-ByKsp8hm.d.ts} +5 -5
  81. package/dist/{runtimeTypes-BNBENMkz.d.cts → runtimeTypes-D155OlBW.d.cts} +5 -5
  82. package/dist/server/events/index.cjs +1 -1
  83. package/dist/server/events/index.d.cts +2 -2
  84. package/dist/server/events/index.d.ts +2 -2
  85. package/dist/server/events/index.js +1 -1
  86. package/dist/server/index.cjs +1 -1
  87. package/dist/server/index.d.cts +3 -3
  88. package/dist/server/index.d.ts +3 -3
  89. package/dist/server/index.js +1 -1
  90. package/dist/televet/booking/index.cjs +4 -1
  91. package/dist/televet/booking/index.d.cts +116 -29
  92. package/dist/televet/booking/index.d.ts +116 -29
  93. package/dist/televet/booking/index.js +4 -1
  94. package/dist/televet/call/index.cjs +1 -1
  95. package/dist/televet/call/index.d.cts +1 -1
  96. package/dist/televet/call/index.d.ts +1 -1
  97. package/dist/televet/call/index.js +1 -1
  98. package/dist/televet/index.cjs +1 -1
  99. package/dist/televet/index.js +1 -1
  100. package/dist/testing/index.cjs +3 -3
  101. package/dist/testing/index.d.cts +1 -1
  102. package/dist/testing/index.d.ts +1 -1
  103. package/dist/testing/index.js +3 -3
  104. package/dist/testing/rn/index.cjs +1 -1
  105. package/dist/testing/rn/index.d.cts +14 -12
  106. package/dist/testing/rn/index.d.ts +14 -12
  107. package/dist/testing/rn/index.js +1 -1
  108. package/dist/testing/web/index.d.cts +9 -9
  109. package/dist/testing/web/index.d.ts +9 -9
  110. package/dist/{timelineRows-B6nCq30k.d.cts → timelineRows-BNF43SXK.d.cts} +1 -1
  111. package/dist/{timelineRows-DacfDpDU.d.ts → timelineRows-DXpjECfA.d.ts} +1 -1
  112. package/dist/{tokens-DOTIxrws.d.cts → tokens-BYtbKwFh.d.cts} +12 -4
  113. package/dist/{tokens-DOTIxrws.d.ts → tokens-BYtbKwFh.d.ts} +12 -4
  114. package/dist/{typeStyle-achxqQ-h.d.cts → typeStyle-BqfwxZH4.d.cts} +2 -2
  115. package/dist/{typeStyle-DROhJNkh.d.ts → typeStyle-DKz02DGU.d.ts} +2 -2
  116. package/dist/{uploadTransport-C1p8FuG8.d.cts → uploadTransport-BM_pnEWj.d.cts} +5 -0
  117. package/dist/{uploadTransport-bZIKBTyK.d.ts → uploadTransport-C6kGP1Kd.d.ts} +5 -0
  118. package/dist/{useRecordsDepth-BLK8W646.d.cts → useRecordsDepth-CARTuHKh.d.cts} +1 -1
  119. package/dist/{useRecordsDepth-C7guUoLc.d.ts → useRecordsDepth-fPSv-GXU.d.ts} +1 -1
  120. package/dist/video/index.cjs +1 -1
  121. package/dist/video/index.js +1 -1
  122. package/dist/{view-BF9oW2GJ.d.cts → view-DGPaVno8.d.cts} +47 -5
  123. package/dist/{view-B6JsD22K.d.ts → view-Dc-JlFkf.d.ts} +47 -5
  124. package/dist/web/consent/index.cjs +1 -1
  125. package/dist/web/consent/index.d.cts +5 -5
  126. package/dist/web/consent/index.d.ts +5 -5
  127. package/dist/web/consent/index.js +1 -1
  128. package/dist/web/index.cjs +7 -7
  129. package/dist/web/index.d.cts +23 -22
  130. package/dist/web/index.d.ts +23 -22
  131. package/dist/web/index.js +7 -7
  132. package/dist/web/notifications/index.d.cts +3 -3
  133. package/dist/web/notifications/index.d.ts +3 -3
  134. package/dist/web/records/depth/index.cjs +2 -2
  135. package/dist/web/records/depth/index.d.cts +7 -7
  136. package/dist/web/records/depth/index.d.ts +7 -7
  137. package/dist/web/records/depth/index.js +2 -2
  138. package/dist/web/records/index.cjs +3 -3
  139. package/dist/web/records/index.d.cts +28 -17
  140. package/dist/web/records/index.d.ts +28 -17
  141. package/dist/web/records/index.js +3 -3
  142. package/dist/web/televet/booking/index.cjs +4 -2
  143. package/dist/web/televet/booking/index.d.cts +228 -90
  144. package/dist/web/televet/booking/index.d.ts +228 -90
  145. package/dist/web/televet/booking/index.js +4 -2
  146. package/dist/web/televet/call/index.cjs +1 -1
  147. package/dist/web/televet/call/index.d.cts +1 -1
  148. package/dist/web/televet/call/index.d.ts +1 -1
  149. package/dist/web/televet/call/index.js +1 -1
  150. package/dist/web/televet/index.cjs +2 -2
  151. package/dist/web/televet/index.d.cts +2 -2
  152. package/dist/web/televet/index.d.ts +2 -2
  153. package/dist/web/televet/index.js +2 -2
  154. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- 'use strict';var react=require('react'),zod=require('zod'),jsxRuntime=require('react/jsx-runtime');var Sc=Object.defineProperty;var i=(e,r)=>Sc(e,"name",{value:r,configurable:true});var Wo=Object.freeze([Object.freeze({wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false}),Object.freeze({wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true}),Object.freeze({wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true}),Object.freeze({wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true}),Object.freeze({wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false}),Object.freeze({wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false}),Object.freeze({wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false}),Object.freeze({wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false}),Object.freeze({wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false}),Object.freeze({wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true}),Object.freeze({wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false}),Object.freeze({wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false}),Object.freeze({wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false}),Object.freeze({wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false}),Object.freeze({wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false}),Object.freeze({wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false}),Object.freeze({wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false}),Object.freeze({wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true}),Object.freeze({wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true}),Object.freeze({wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true}),Object.freeze({wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false}),Object.freeze({wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false})]);Object.freeze(Wo.map(e=>e.wireCode));var wc=Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict"}),Na=Object.freeze(Wo.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:wc[e.wireCode]}))),kc=new Map(Na.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),_c=Object.freeze(["http_envelope",...[...new Set(Na.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function Hn(e,r){if(typeof e!="string")return;let t=e.trim().toUpperCase();if(t.length!==0)for(let o of [r??"http_envelope",..._c]){let n=kc.get(o+t);if(n)return n}}i(Hn,"contractErrorFor");function Pc(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(Pc,"contractDocUrl");function La(e){return null}i(La,"publishedDocUrl");var Tc=Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function Fa(e){return Tc[e]}i(Fa,"categoryFor");function za(e){let r=Hn(e);if(r)return r.normalized;let t=(e??"").trim().toUpperCase(),o=t.replace(/[^A-Z0-9]/g,"");if(o==="AUTHREJECTED")return "authRejected";if(t.startsWith("AUTH"))return "authExpired";switch(o){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":case "TELEVETRATELIMITED":return "rateLimited";case "IDEMPOTENCYKEYCONFLICT":case "IDEMPOTENCYCONFLICT":return "idempotencyConflict";case "ACCESSDENIED":case "FORBIDDEN":return "accessDenied";case "NOTFOUND":case "CONVERSATIONNOTFOUND":return "conversationNotFound";case "PETNOTFOUND":return "petNotFound";case "TIMEOUT":case "STREAMTIMEOUT":return "streamTimeout";case "MEDIAUPLOADFAILED":case "UNRECOGNIZEDVIDEOFORMAT":case "FILETOOSMALL":return "mediaUploadFailed";case "MODERATIONBLOCKED":return "moderationBlocked";case "UPSTREAMLLMTIMEOUT":return "upstreamLlmTimeout";case "INTERNALERROR":case "INTERNALSERVERERROR":return "internalError";case "STREAMINCOMPLETE":case "CHATSTREAMINCOMPLETE":return "streamIncomplete";case "INVALIDANALYSISTYPE":case "INVALIDUPLOADPURPOSE":return "unknown";default:return "unknown"}}i(za,"fromWire");var Dc=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function Go(e){return Dc.has(e)}i(Go,"isAutoRetryable");var Oc=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function Ma(e){return Go(e)||Oc.has(e)}i(Ma,"isRetryableCode");var Ic=500,Yo=8e3,$a=4;function Ua(e,r=Math.random){let t=Math.max(0,e),o=Math.min(Ic*2**t,Yo);return Math.floor(r()*o)}i(Ua,"backoffDelayMs");var Ac=Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:"This feature isn't available on your account right now.",paymentRequired:"This is part of a paid plan.",quotaExceeded:"You have used today's messages. This resets tomorrow.",rateLimited:"You are sending messages quickly. Try again in a few seconds.",validationFailed:"Something in that request was not right. Check the details and try again.",sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",unknown:"Something went wrong. Please try again."});function Ko(e){return Ac[e]}i(Ko,"userFacingError");function Ba(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:false,writable:false,configurable:false});}i(Ba,"defineHidden");var qc=/^[a-z][a-z0-9_]{0,63}$/;function z(e,r){let t=Hn(r?.wireCode,r?.wireEnvelope),o={code:e,category:Fa(e),retryable:r?.retryable??Ma(e),displayMessage:Ko(e)};if(r?.httpStatus!==void 0&&(o.httpStatus=r.httpStatus),r?.requestId&&(o.requestId=r.requestId),typeof r?.reasonCode=="string"&&qc.test(r.reasonCode)&&(o.reasonCode=r.reasonCode),t);return r?.wireMessage&&Ba(o,"wireMessage",r.wireMessage),r?.raw!==void 0&&r.raw!==null&&Ba(o,"raw",r.raw),Object.freeze(o)}i(z,"makeEverfurError");function we(e,r){return Object.freeze(r===void 0?{ok:true,value:e}:{ok:true,value:e,warning:r})}i(we,"ok");function Y(e){return Object.freeze({ok:false,error:e})}i(Y,"err");var Vn=class Vn extends Error{constructor(r,t){super(t),this.name="EverfurConfigError",this.kind=r,Object.setPrototypeOf(this,Vn.prototype);}};i(Vn,"EverfurConfigError");var un=Vn;var Ga=new Set(["requested","awaiting_clinic","awaiting_upload","received","parsing","in_review","published","failed","revoked"]),ja=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 Nc(e){let r=Object.prototype.hasOwnProperty.call(ja,e)?ja[e]:void 0;if(r!==void 0)return r;let t=e;return Ga.has(t)?t:"parsing"}i(Nc,"normalizeStatus");function Ya(e){return e==="owner_reported"||e==="clinic_document"?e:null}i(Ya,"normalizeOrigin");var Lc=zod.z.object({request_id:zod.z.string().min(1),pet_ref:zod.z.string().min(1),status:zod.z.string(),simple_status:zod.z.string().nullish(),simple_status_detail:zod.z.string().nullish(),status_label:zod.z.string().optional(),dispatch_status:zod.z.string().nullish(),can_retry_send:zod.z.boolean().optional(),can_revoke:zod.z.boolean().optional(),can_convert_to_upload:zod.z.boolean().optional(),can_update_clinic_email:zod.z.boolean().optional(),reminder_count:zod.z.number().int().nonnegative().optional(),last_reminder_at:zod.z.string().nullish(),waiting_expectation:zod.z.string().nullish(),document_count:zod.z.number().optional(),held_item_count:zod.z.number().optional(),received_at:zod.z.string().nullish(),parsing_started_at:zod.z.string().nullish(),review_started_at:zod.z.string().nullish(),created_at:zod.z.string().optional(),updated_at:zod.z.string().optional(),source:zod.z.string().nullish().catch(null),action_needed_label:zod.z.string().nullish().catch(null),failure_reason:zod.z.string().nullish().catch(null),failure_code:zod.z.string().nullish().catch(null),recovery_stage:zod.z.string().nullish().catch(null),show_clinic_phone:zod.z.boolean().optional().catch(void 0),clinic_name:zod.z.string().nullish().catch(null),clinic_email:zod.z.string().nullish().catch(null),clinic_phone:zod.z.string().nullish().catch(null),converted_to_upload_at:zod.z.string().nullish().catch(null),request_group_id:zod.z.string().nullish().catch(null)}).passthrough();function lt(e){let r=Lc.safeParse(e);if(!r.success)return null;let t=r.data,o=zc(t.simple_status),n=o==="requested"&&(t.status==="awaiting_upload"||t.simple_status_detail==="awaiting_owner_upload")?"awaiting_upload":o==="parsing"&&(t.simple_status_detail==="in_review"||t.simple_status_detail==="review_email_failed")?"in_review":o??Nc(t.status);return Object.freeze({id:t.request_id,petRef:t.pet_ref,status:n,simpleStatus:o,simpleStatusDetail:t.simple_status_detail??null,statusLabel:t.status_label??"",dispatchStatus:t.dispatch_status??null,canRetrySend:t.can_retry_send===true,canRevoke:t.can_revoke===true,canConvertToUpload:t.can_convert_to_upload===true,canUpdateClinicEmail:t.can_update_clinic_email===true,reminderCount:t.reminder_count??0,lastReminderAt:t.last_reminder_at??null,waitingExpectation:t.waiting_expectation??null,documentCount:Va(t.document_count,0),heldItemCount:Va(t.held_item_count,0),receivedAt:t.received_at??null,parsingStartedAt:t.parsing_started_at??null,reviewStartedAt:t.review_started_at??null,createdAt:t.created_at??"",updatedAt:t.updated_at??"",wireStatus:t.status,source:t.source??null,actionNeededLabel:t.action_needed_label??null,failureReason:t.failure_reason??null,failureCode:t.failure_code??null,recoveryStage:t.recovery_stage??null,showClinicPhone:t.show_clinic_phone===true,clinicName:t.clinic_name??null,clinicEmail:t.clinic_email??null,clinicPhone:t.clinic_phone??null,convertedToUploadAt:t.converted_to_upload_at??null,requestGroupId:t.request_group_id??null})}i(lt,"mapRequestView");var Fc=zod.z.object({request_group_id:zod.z.string().min(1),pet_ref:zod.z.string().min(1),total:zod.z.number().int().nonnegative(),responded:zod.z.number().int().nonnegative(),pending:zod.z.number().int().nonnegative(),members:zod.z.array(zod.z.unknown())});function Ka(e){let r=Fc.safeParse(e);if(!r.success)return null;let t=r.data,o=Qo(t.members);return o.some(n=>n.petRef!==t.pet_ref)?null:Object.freeze({requestGroupId:t.request_group_id,petRef:t.pet_ref,total:t.total,responded:t.responded,pending:t.pending,members:o})}i(Ka,"mapRequestGroup");function zc(e){return !e||e==="awaiting_upload"||e==="in_review"?null:Ga.has(e)?e:null}i(zc,"normalizeSimpleStatus");function Qo(e){let r=Array.isArray(e)?e:[],t=[];for(let o of r){let n=lt(o);n!==null&&t.push(n);}return Object.freeze(t)}i(Qo,"mapRequestList");var Mc=zod.z.object({source_doc_id:zod.z.string().min(1),request_id:zod.z.string().min(1)});function Qa(e){let r=Mc.safeParse(e);return r.success?Object.freeze({documentId:r.data.source_doc_id,requestId:r.data.request_id,status:"received"}):null}i(Qa,"mapUploadedDocument");var $c=zod.z.object({label:zod.z.string(),value:zod.z.string()}),Xo=zod.z.object({key:zod.z.string(),category:zod.z.string().optional(),label:zod.z.string().optional(),value:zod.z.string().nullish(),unit:zod.z.string().nullish(),observed_at:zod.z.string().nullish(),status:zod.z.string().nullish(),origin:zod.z.string().nullish(),canonical_key:zod.z.string().nullish()}),Uc=zod.z.object({at:zod.z.string(),value:zod.z.number().nullish(),display:zod.z.string().nullish(),origin:zod.z.string().nullish()}),Bc=zod.z.object({key:zod.z.string(),label:zod.z.string().optional(),points:zod.z.array(Uc).optional()}),jc=zod.z.object({title:zod.z.string(),detail:zod.z.string().nullish(),due_at:zod.z.string().nullish()}),Jo=zod.z.object({doc_id:zod.z.string(),title:zod.z.string().nullish(),page_count:zod.z.number().nullish(),received_at:zod.z.string().nullish()});function Zo(e){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:Ya(e.origin),canonicalKey:e.canonical_key??null})}i(Zo,"mapEntityRow");function ei(e){return Object.freeze({docId:e.doc_id,title:e.title??null,pageCount:e.page_count??null,receivedAt:e.received_at??null})}i(ei,"mapDocumentRow");var Hc=zod.z.object({identity:zod.z.array($c).optional(),entities:zod.z.array(Xo).optional(),entity_series:zod.z.array(Bc).optional(),forward_looking:zod.z.array(jc).optional(),documents:zod.z.array(Jo).optional()});function Xa(e,r){let t=Wc(r)?r:{},o=Wa(t.schema_version,"epdf/1.0"),n=Wa(t.disclaimer,""),l=typeof t.pet_ref=="string"&&t.pet_ref.length>0?t.pet_ref:e;if(t.withheld===true)return Ha(l,o,n);let a=Hc.safeParse(t);if(!a.success)return Ha(l,o,n);let c=a.data,s=(c.identity??[]).map(g=>Object.freeze({label:g.label,value:g.value})),d=(c.entities??[]).map(Zo),u=(c.entity_series??[]).map(g=>Object.freeze({key:g.key,label:g.label??g.key,points:Object.freeze((g.points??[]).map(f=>Object.freeze({at:f.at,value:f.value??null,display:f.display??null,origin:Ya(f.origin)})))})),p=(c.forward_looking??[]).map(g=>Object.freeze({title:g.title,detail:g.detail??null,dueAt:g.due_at??null})),m={};for(let g of c.documents??[])m[g.doc_id]=ei(g);let y=t.is_empty===true||s.length===0&&d.length===0&&u.length===0&&p.length===0&&Object.keys(m).length===0;return Object.freeze({petRef:l,schemaVersion:o,isEmpty:y,withheld:false,generatedAt:Gc(t.generated_at),identity:Object.freeze(s),entities:Object.freeze(d),entitySeries:Object.freeze(u),forwardLooking:Object.freeze(p),documents:Object.freeze(m),disclaimer:n})}i(Xa,"mapRecordView");function Ha(e,r,t){return Object.freeze({petRef:e,schemaVersion:r,isEmpty:false,withheld:true,generatedAt:null,identity:Object.freeze([]),entities:Object.freeze([]),entitySeries:Object.freeze([]),forwardLooking:Object.freeze([]),documents:Object.freeze({}),disclaimer:t})}i(Ha,"withheldView");var Vc=zod.z.object({pet_ref:zod.z.string().optional(),granted:zod.z.boolean().optional(),version:zod.z.string().nullish(),granted_at:zod.z.string().nullish()});function Wn(e,r){let t=Vc.safeParse(r),o=t.success?t.data:{};return Object.freeze({petRef:typeof o.pet_ref=="string"&&o.pet_ref.length>0?o.pet_ref:e,granted:o.granted===true,version:o.version??null,grantedAt:o.granted_at??null})}i(Wn,"mapConsent");function Wc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Wc,"isObject");function Va(e,r){return typeof e=="number"&&Number.isFinite(e)?e:r}i(Va,"numberOr");function Wa(e,r){return typeof e=="string"&&e.length>0?e:r}i(Wa,"strOr");function Gc(e){return typeof e=="string"&&e.length>0?e:null}i(Gc,"strOrNull");var Ja=Object.freeze(["published","failed","revoked"]);function Mt(e){return Ja.includes(e)}i(Mt,"isTerminalStatus");function dt(e){if(e===null)return null;let r=e.recordsReason;return r==="consent_required"||r==="session_required"||r==="entitlement"||r==="pet_not_found"?r:null}i(dt,"recordsDenialReasonOf");var Yc="records_consent_required";function Kc(e){let r=e.raw;if(r===null||typeof r!="object")return null;let t=r,o=typeof t.error=="object"&&t.error!==null?t.error.code:t.code;return typeof o=="string"&&o.length>0?o:null}i(Kc,"recordsWireCodeOf");function Jr(e){return e===null||e.httpStatus!==409?false:Kc(e)===Yc}i(Jr,"isRecordsConsentRequired");var Qc=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Gn(e){return e!==Qc}i(Gn,"isUploadTransportAvailable");var Za=Object.freeze({record(){}}),jr=25*1024*1024,es=64,pn=128,or=128,ct="application/pdf",rs=9e4;function ns(e){return new ri(e)}i(ns,"createRecordsController");var ti=class ti{constructor(r){this.recordCache=new Map;this.consentEpoch=new Map;this.reportedGaps=new Set;this.repository=r.repository,this.uploads=r.uploads,this.telemetry=r.telemetry??Za,this.newIdempotencyKey=r.newIdempotencyKey??ru(),this.timers=r.timers??Zc,this.uploadDeadlineMs=r.uploadDeadlineMs??rs;}async createUploadRequest(r){let t=await this.repository.createRequest({pet_ref:r.petRef,idempotency_key:r.idempotencyKey});if(!t.ok)return this.onRequestError(t.error);let o=lt(t.value);return o===null?Y(Yn()):(this.observeRequest(o),we(o))}async getRequest(r){let t=await this.repository.getRequest(r);if(!t.ok)return this.onRequestError(t.error);let o=lt(t.value);return o===null?Y(Yn()):(this.observeRequest(o),we(o))}async listRequests(){let r=await this.repository.listRequests();if(!r.ok)return this.onRequestError(r.error);let t=Qo(r.value);for(let o of t)this.observeRequest(o);return we(t)}async uploadDocument(r){let{requestId:t,file:o}=r,n=Xc(o);if(n!==null)return this.telemetry.record("records.upload.rejected",{reason:n}),Y(ts(`upload rejected: ${n}`));let l=await this.repository.initiateUpload(t,{content_type:ct,file_size:o.sizeBytes});if(!l.ok)return this.onRequestError(l.error);let a=await this.postToS3(l.value,o,r);if(!a.ok)return this.telemetry.record("records.upload.failed",{reason:a.reason}),Y(ts(a.reason));let c=await this.repository.completeUpload(t,{upload_id:l.value.upload_id});if(!c.ok)return c.error.code==="mediaUploadFailed"&&this.telemetry.record("records.upload.rejected",{reason:Jc(c.error)??"corrupt"}),this.onRequestError(c.error);let s=Qa(c.value);return s===null?Y(Yn()):we(s)}async postToS3(r,t,o){let n=new AbortController,l=eu(n.signal,o.signal),a=this.timers.setTimeout(()=>n.abort(),this.uploadDeadlineMs);try{let c={signal:l};return o.onProgress&&(c.onProgress=o.onProgress),await this.uploads.postMultipart(r,t,c),{ok:!0}}catch{return {ok:false,reason:n.signal.aborted&&o.signal?.aborted!==true?"timeout":"upload_error"}}finally{this.timers.clearTimeout(a);}}async getRecord(r){let t=this.consentEpoch.get(r)??0,o=await this.repository.getRecord(r);if(t!==(this.consentEpoch.get(r)??0))return Y(Object.freeze({...z("accessDenied",{retryable:false}),recordsReason:"consent_required"}));if(!o.ok){let l=dt(o.error);return l==="consent_required"?(this.recordCache.delete(r),this.telemetry.record("records.consent.denied",{pet_ref:r})):l==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:r}),Y(o.error)}let n=Xa(r,o.value);return n.petRef!==r?Y(Yn()):n.withheld?(this.telemetry.record("records.redaction.withheld",{pet_ref:r}),this.recordCache.delete(r),we(n)):(this.recordCache.set(r,n),we(n))}peekCachedRecord(r){return this.recordCache.get(r)??null}async getConsent(r){let t=await this.repository.getConsent(r);return t.ok?we(Wn(r,t.value)):Y(t.error)}async grantConsent(r){let t=await this.repository.putConsent(r.petRef,{consent_version:r.consentVersion,idempotency_key:r.idempotencyKey});return t.ok?we(Wn(r.petRef,t.value)):(dt(t.error)==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:r.petRef}),Y(t.error))}async revokeConsent(r){let t=await this.repository.deleteConsent(r);return t.ok?(this.consentEpoch.set(r,(this.consentEpoch.get(r)??0)+1),this.recordCache.delete(r),we(Wn(r,t.value))):Y(t.error)}reportCapabilityDenied(r){this.telemetry.record("records.capability.denied",r?{pet_ref:r}:{});}observeRequest(r){r.reviewStartedAt!==null&&!this.reportedGaps.has(r.id)&&(this.reportedGaps.add(r.id),this.telemetry.record("records.parse.gap",{request_id:r.id}));}onRequestError(r){return dt(r)==="entitlement"&&this.telemetry.record("records.capability.denied",{}),Y(r)}};i(ti,"RecordsControllerImpl");var ri=ti;function Xc(e){if(e.mimeType!==ct)return "unsupported_format";let r=e.sizeBytes;return typeof r!="number"||!Number.isFinite(r)||r<=0||r>jr?"oversize":null}i(Xc,"validateFile");function Jc(e){let r=e.wireMessage;return r==="unsupported_format"||r==="oversize"||r==="corrupt"?r:null}i(Jc,"reasonFromWire");function ts(e){return z("mediaUploadFailed",{retryable:false,wireMessage:e})}i(ts,"uploadFailed");function Yn(){return z("internalError",{retryable:true})}i(Yn,"internal");var Zc={setTimeout:i((e,r)=>setTimeout(e,r),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout")};function eu(e,r){if(!r)return e;let t=new AbortController;if(e.aborted||r.aborted)return t.abort(),t.signal;let o=i(()=>t.abort(),"onAbort");return e.addEventListener("abort",o,{once:true}),r.addEventListener("abort",o,{once:true}),t.signal}i(eu,"mergeSignals");function ru(){let e=0;return ()=>`records-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(ru,"defaultIdempotencyFactory");function Dr(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(Dr,"assertNever");function os(e){return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:e.serverRequestId??null})}i(os,"errorFrame");function ou(e){let r={};return e.mode==="personalized"?r.authorization=`Bearer ${e.token}`:r["x-everfur-partner-key"]=e.publishableKey,e.userRef&&(r["x-everfur-user-ref"]=e.userRef),e.sessionId&&(r["x-everfur-session-id"]=e.sessionId),r}i(ou,"authHeaders");function mn(e,r){return {...e,headers:{...iu(e.headers),...ou(r)}}}i(mn,"withAuthHeaders");function iu(e){if(!e)return {};let r={};for(let[t,o]of Object.entries(e)){let n=t.toLowerCase();n==="authorization"||n==="x-everfur-partner-key"||(r[t]=o);}return r}i(iu,"stripAuthHeaders");async function is(e,r){if(r.mode==="anonymous")return r.transport.request(mn(e,{mode:"anonymous",publishableKey:r.publishableKey,userRef:r.userRef,...r.sessionId?{sessionId:r.sessionId}:{}}));let t;try{t=await r.identity.currentToken();}catch{return Y(ni())}let o=await r.transport.request(mn(e,{mode:"personalized",token:t,userRef:r.userRef,...r.sessionId?{sessionId:r.sessionId}:{}}));if(o.ok||o.error.httpStatus!==401)return o;let n;try{n=await r.identity.currentToken({forceRefresh:!0});}catch{return Y(ni())}let l=await r.transport.request(mn(e,{mode:"personalized",token:n,userRef:r.userRef,...r.sessionId?{sessionId:r.sessionId}:{}}));return !l.ok&&l.error.httpStatus===401?Y(ni(l.error.httpStatus)):l}i(is,"authedSend");function ni(e){return z("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(ni,"authRejectedError");function as(e){return z("internalError",{retryable:true,wireMessage:au(e)})}i(as,"networkError");function au(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(au,"describeCause");var su=3e4,lu=Yo*2,du="idempotency-key",cu=new Set(["POST","PUT","PATCH","DELETE"]),uu=Object.freeze({onEvent(){}}),pu=Object.freeze({setTimeout:i((e,r)=>setTimeout(e,r),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function mu(e){let r=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return r.length===0?null:`efs_${r}`.slice(0,128)}i(mu,"seededIdempotencyKey");function ut(e){let r=e.observer??uu,t=e.timers??pu,o=e.rng??Math.random,n=e.sleep??((m,y)=>ku(m,t,y)),l=e.maxAttempts??$a,a=e.unaryTimeoutMs??su,c=e.newIdempotencyKey??Zr(),s=i(m=>{try{r.onEvent(m);}catch{}},"emit");async function d(m,y,g){let f=g?.maxAttempts,R=Math.max(1,f??l),b=g?.idempotent??cu.has(y.method),E=g?.idempotencyKey===void 0?null:mu(g.idempotencyKey),h=b?E??c():null,v=fu(y,h),S=0;for(;;){let C=i(M=>Object.freeze({call:m,method:y.method,path:y.path,attempt:S,...h?{idempotencyKey:h}:{},...M}),"stamp");s(C({phase:"attempt"}));let k=Su(a,t),_=wu(k.signal,y.signal),T;try{T=await is({...v,signal:_.signal},e.auth);}catch(M){T=Y(as(M));}finally{_.dispose(),k.cancel();}if(T.ok)return s(C({phase:"settled",ok:true,reason:"ok"})),T;let I=T.error,F=gu(I,S,{maxAttempts:R,rng:o,now:t.now(),aborted:y.signal?.aborted===true,...f!==void 0?{perCallMaxAttempts:f}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),q={ok:false,code:I.code,reason:F.reason,...I.httpStatus!==void 0?{httpStatus:I.httpStatus}:{},...I.requestId!==void 0?{requestId:I.requestId}:{}};if(!F.retry)return s(C({phase:"settled",...q})),Y(I);if(s(C({phase:"retry",...q,delayMs:F.delayMs})),await n(F.delayMs,y.signal),y.signal?.aborted===true)return s(C({phase:"settled",...q,reason:"aborted"})),Y(I);S+=1;}}i(d,"send");async function u(m){return mn(m,await xu(e.auth))}i(u,"authorize");async function*p(m,y,g){s(Object.freeze({call:m,phase:"stream.open",method:y.method,path:y.path,attempt:0}));try{yield*e.auth.transport.stream(y,g);}catch{yield os({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(p,"stream"),Object.freeze({send:d,authorize:u,stream:p})}i(ut,"createRequestFunnel");function fu(e,r){let t={};for(let[o,n]of Object.entries(e.headers??{}))o.toLowerCase()!==du&&(t[o]=n);return r!==null&&(t["Idempotency-Key"]=r),{...e,headers:t}}i(fu,"assembleHeaders");function Zr(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(Zr,"defaultIdempotencyKeyFactory");var yu=10;function gu(e,r,t){if(t.aborted)return {retry:false,reason:"aborted"};let o=bu(e);if(o==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(o!=="burst"&&!Go(e.code))return {retry:false,reason:"terminal-code"};let n=o==="burst"?"burst-throttle":"retryable-code";if(i(()=>{if(t.policy===void 0)return false;try{return !t.policy.shouldRetry(e.code,r)}catch{return false}},"policyVetoedRetry")())return {retry:false,reason:"terminal-code"};let a=i(()=>{if(t.policy===void 0)return null;let d;try{d=t.policy.maxAttempts(e.code);}catch{return null}return typeof d!="number"||!Number.isFinite(d)?null:Math.max(1,Math.min(yu,Math.floor(d)))},"policyCeiling"),c=t.perCallMaxAttempts??a()??t.maxAttempts;if(r+1>=c)return {retry:false,reason:"attempts-exhausted"};let s=Ru(e,t.now);return s!==null?s>lu?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:n,delayMs:s}:{retry:true,reason:n,delayMs:Ua(r,t.rng)}}i(gu,"decideRetry");function bu(e){let r=e.code==="unknown"?za(Eu(e.raw)):e.code;return r==="quotaExceeded"?"quota":r==="rateLimited"||e.httpStatus===429?"burst":null}i(bu,"throttleKind");function Ru(e,r){let t=vu(e.raw);if(t!==null){let n=t-r;return n>0?n:0}let o=hu(e.raw);return o===null?null:Math.round(o*1e3)}i(Ru,"retryOverrideMs");function hu(e){for(let r of oi(e)){let t=r.retry_after_seconds;if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t}return null}i(hu,"findRetryAfterSeconds");function vu(e){for(let r of oi(e)){let t=r.resets_at,o=Cu(t);if(o!==null)return o}return null}i(vu,"findResetsAt");function oi(e){if(!ss(e))return [];let r=[e];for(let t of ["error","detail"]){let o=e[t];ss(o)&&r.push(o);}return r}i(oi,"candidateScopes");function Cu(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 r=Date.parse(e);return Number.isFinite(r)?r:null}return null}i(Cu,"parseInstantMs");function Eu(e){for(let r of oi(e)){let t=r.code;if(typeof t=="string"&&t.length>0)return t}return null}i(Eu,"rawWireCode");function ss(e){return typeof e=="object"&&e!==null}i(ss,"isRecord");async function xu(e){return e.mode==="anonymous"?{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}:{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}i(xu,"resolveDeviceAuth");function Su(e,r){let t=new AbortController,o=r.setTimeout(()=>t.abort(),e);return {signal:t.signal,cancel:i(()=>r.clearTimeout(o),"cancel")}}i(Su,"boundedSignal");function wu(e,r){let t=i(()=>{},"noop");if(!r)return {signal:e,dispose:t};let o=new AbortController;if(e.aborted||r.aborted)return o.abort(),{signal:o.signal,dispose:t};let n=i(()=>o.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),r.addEventListener("abort",n,{once:true}),{signal:o.signal,dispose:i(()=>{e.removeEventListener("abort",n),r.removeEventListener("abort",n);},"dispose")}}i(wu,"mergeSignals");function ku(e,r,t){return e<=0||t?.aborted===true?Promise.resolve():new Promise(o=>{let n=r.setTimeout(()=>{t?.removeEventListener("abort",l),o();},e),l=i(()=>{r.clearTimeout(n),o();},"onAbort");t?.addEventListener("abort",l,{once:true});})}i(ku,"delayAbortable");function pt(e){for(let r=0;r<e.length;r+=1){let t=e.charCodeAt(r);if(t>=55296&&t<=56319){let o=e.charCodeAt(r+1);if(!(o>=56320&&o<=57343))return true;r+=1;}else if(t>=56320&&t<=57343)return true}return false}i(pt,"hasLoneSurrogate");var et="/widget/v1/records";function ds(e){let{auth:r}=e,t=r.mode,o=e.funnel??ut({auth:r,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),n=i(async(s,d,u)=>{let p=await o.send(s,d);return p.ok?p:Y(Tu(p.error,t,u))},"send"),l=i((s,d)=>typeof d!="string"||d.length===0?z("validationFailed",{retryable:false,wireMessage:`${s} is required and must be a non-empty string`}):pt(d)?z("validationFailed",{retryable:false,wireMessage:`${s} contains an unpaired surrogate and cannot be encoded`}):null,"segmentError"),a=i((s,d,u)=>{let p=l(s,d);if(p!==null)return p;let y=[...d].length;return y>u?z("validationFailed",{retryable:false,wireMessage:`${s} is ${y} characters; the server accepts at most ${u}`}):null},"boundsError"),c=i((...s)=>s.find(d=>d!==null)??null,"firstError");return {createRequest:i(s=>{let d=c(a("idempotency_key",s.idempotency_key,pn),a("pet_ref",s.pet_ref,or));return d?Promise.resolve(Y(d)):n("records.createRequest",ii(`${et}/requests`,s),"request")},"createRequest"),initiateUpload:i((s,d)=>{let u=l("request_id",s);return u?Promise.resolve(Y(u)):n("records.initiateUpload",ii(`${et}/requests/${encodeURIComponent(s)}/uploads/initiate`,d),"request")},"initiateUpload"),completeUpload:i((s,d)=>{let u=l("request_id",s);return u?Promise.resolve(Y(u)):n("records.completeUpload",ii(`${et}/requests/${encodeURIComponent(s)}/uploads/complete`,d),"request")},"completeUpload"),getRequest:i(s=>{let d=l("request_id",s);return d?Promise.resolve(Y(d)):n("records.getRequest",Kn(`${et}/requests/${encodeURIComponent(s)}`),"request")},"getRequest"),listRequests:i(async()=>{let s=await n("records.listRequests",Kn(`${et}/requests`),"request");if(!s.ok)return s;let d=s.value;return {ok:true,value:Array.isArray(d)?d:d.items??[]}},"listRequests"),getRecord:i(s=>{let d=a("pet_ref",s,or);return d?Promise.resolve(Y(d)):n("records.getRecord",Kn(`${et}/pets/${encodeURIComponent(s)}/record`),"content")},"getRecord"),getConsent:i(s=>{let d=a("pet_ref",s,or);return d?Promise.resolve(Y(d)):n("records.getConsent",Kn(`${et}/pets/${encodeURIComponent(s)}/consent`),"consent")},"getConsent"),putConsent:i((s,d)=>{let u=c(a("consent_version",d.consent_version,es),a("idempotency_key",d.idempotency_key,pn),a("pet_ref",s,or));return u?Promise.resolve(Y(u)):n("records.putConsent",Du(`${et}/pets/${encodeURIComponent(s)}/consent`,d),"consent")},"putConsent"),deleteConsent:i(s=>{let d=a("pet_ref",s,or);return d?Promise.resolve(Y(d)):n("records.deleteConsent",Ou(`${et}/pets/${encodeURIComponent(s)}/consent`),"consent")},"deleteConsent")}}i(ds,"createHttpRecordsRepository");function ls(e,r){let t={...e,recordsReason:r};for(let o of ["wireMessage","raw"]){let n=Object.getOwnPropertyDescriptor(e,o);n!==void 0&&Object.defineProperty(t,o,n);}return Object.freeze(t)}i(ls,"withReason");var _u="pet_not_registered";function Pu(e){return e.httpStatus!==404?null:e.reasonCode===_u?"pet_not_found":"entitlement"}i(Pu,"recordsErrorReasonFor");function Tu(e,r,t){let o=Pu(e);return o!==null?ls(e,o):e.code!=="accessDenied"?e:ls(e,r==="anonymous"?"session_required":t==="content"?"consent_required":"entitlement")}i(Tu,"tagReason");function Kn(e){return {method:"GET",path:e}}i(Kn,"get");function ii(e,r){return {method:"POST",path:e,body:r}}i(ii,"post");function Du(e,r){return {method:"PUT",path:e,body:r}}i(Du,"put");function Ou(e){return {method:"DELETE",path:e}}i(Ou,"del");var cs=Symbol.for("@everfur/sdk#EverfurContext@v1"),us=globalThis,ps=us[cs]??(us[cs]=react.createContext(null));ps.displayName??="EverfurContext";function ee(){let e=react.useContext(ps);if(e===null)throw new un("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(ee,"useEverfurContext");var ai=new Map,si=new Set;function ms(e){ai.set(e,(ai.get(e)??0)+1);for(let r of [...si])r();}i(ms,"notifyRecordsConsentWithdrawn");function Lu(e){return ai.get(e)??0}i(Lu,"recordsConsentEpochOf");function Fu(e){return si.add(e),()=>{si.delete(e);}}i(Fu,"subscribe");function Qn(e){let r=react.useCallback(()=>Lu(e),[e]);return react.useSyncExternalStore(Fu,r,r)}i(Qn,"useRecordsConsentEpoch");var di={record:null,requests:[],consent:null,error:null,denialReason:null,withheld:false,loading:true,isUploading:false,uploadProgress:null,uploadQueue:[]},ys=4e3,Mu=30;function We(e){let{petRef:r}=e,t=react.useRef(e.uploadTransport);t.current=e.uploadTransport;let o=e.uploadTransport!==void 0,{runtime:n,userRef:l,scopeEpoch:a}=ee(),c=react.useMemo(()=>({}),[n,l,r,a,e.controller]),s=react.useRef(c),[d,u]=react.useState({scope:c,controller:e.controller??null}),p=e.controller??(d.scope===c?d.controller:null),[m,y]=react.useState({scope:c,value:di}),g=m.scope===c?m.value:di,f=react.useCallback(w=>{y(x=>x.scope===c?{scope:c,value:w(x.value)}:x);},[c]),R=react.useRef(0);react.useEffect(()=>(s.current=c,y({scope:c,value:di}),()=>{s.current=null,R.current+=1;}),[c]),react.useEffect(()=>{if(e.controller)return;let{services:w}=n.registry,x={record:i((D,W)=>w.telemetry.track(D,W),"record")},A=n.registry.acquire("records",`${l??""}|${r}${o?"|own-upload":""}`,()=>ns({repository:ds({auth:w.authFor(l),...w.errorPolicy?{errorPolicy:w.errorPolicy}:{}}),uploads:o?{postMultipart:i((D,W,de)=>(t.current??w.uploadTransport).postMultipart(D,W,de),"postMultipart")}:w.uploadTransport,telemetry:x}),()=>{});return u({scope:c,controller:A}),()=>{n.registry.release(A);}},[n,l,r,e.controller,a,c,o]);let b=react.useCallback(w=>{f(x=>({...x,...w}));},[f]),E=react.useCallback(async()=>{if(!p||s.current!==c)return;let w=R.current+=1;C.current=0,T(),b({loading:true,error:null,denialReason:null,withheld:false});let[x,A]=await Promise.all([p.getConsent(r),p.listRequests()]);if(w!==R.current)return;let D=x.ok?x.value:null,W=A.ok?A.value.filter(Ae=>Ae.petRef===r):[],de=A.ok?null:A.error;if(D&&D.granted){let Ae=await p.getRecord(r);if(w!==R.current)return;if(Ae.ok){b({consent:D,requests:W,record:Ae.value,withheld:Ae.value.withheld,error:Ae.value.withheld?ju():de,denialReason:null,loading:false});return}b({consent:D,requests:W,record:null,error:Ae.error,denialReason:dt(Ae.error),withheld:false,loading:false});return}b({consent:D,requests:W,record:null,error:x.ok?de:x.error,denialReason:D?"consent_required":Bu(x),withheld:false,loading:false});},[p,r,b,c]);react.useEffect(()=>(E(),()=>{R.current+=1;}),[E]);let h=react.useMemo(()=>Uu(g.requests),[g.requests]),v=h?.id??null,S=h?.status??null,C=react.useRef(0),k=react.useRef(null),[_,T]=react.useReducer(w=>w+1,0);react.useEffect(()=>{if(!p||v===null||S===null||Mt(S)||S==="in_review")return;k.current!==String(v)&&(k.current=String(v),C.current=0);let w=false,x=i(async()=>{if(w||C.current>=Mu)return;C.current+=1;let D=await p.getRequest(v);if(!w){if(D.ok&&D.value.petRef===r){if(f(W=>({...W,requests:Jn(W.requests,D.value)})),Mt(D.value.status)){D.value.status==="published"&&E();return}if(D.value.status==="in_review")return}A=setTimeout(()=>{x();},ys);}},"tick"),A=setTimeout(()=>{x();},ys);return ()=>{w=true,clearTimeout(A);}},[p,v,S,E,_,r,f]);let I=react.useCallback(async w=>{if(!p||s.current!==c)return Zn();let x=await p.createUploadRequest({petRef:r,idempotencyKey:w});return s.current===c&&x.ok&&x.value.petRef===r&&f(A=>({...A,requests:Jn(A.requests,x.value)})),x},[p,r,c,f]),F=react.useCallback((w,x)=>{f(A=>({...A,uploadQueue:A.uploadQueue.map(D=>D.key===w?x(D):D)}));},[f]),q=react.useCallback(async(w,x)=>{let A=Date.now().toString(36),D=x.map((de,Ae)=>{let oe=gs(de);return {key:`${A}-${Ae}`,name:de.name??null,status:oe===null?"queued":"skipped",progress:0,skipReason:oe,error:null}}),W=[...D];if(!p||s.current!==c)return Object.freeze(W);f(de=>({...de,uploadQueue:D,isUploading:true,uploadProgress:0}));for(let[de,Ae]of x.entries()){let oe=D[de];if(oe.status==="skipped")continue;if(s.current!==c)break;F(oe.key,Qe=>({...Qe,status:"uploading",progress:0})),b({uploadProgress:0});let ve=await p.uploadDocument({requestId:w,file:Ae,onProgress:i(Qe=>{if(s.current!==c)return;let _r=Math.min(1,Math.max(0,Qe));F(oe.key,Pr=>({...Pr,progress:Math.max(Pr.progress,_r)})),b({uploadProgress:_r});},"onProgress")});if(s.current!==c)break;let ar=ve.ok?{...oe,status:"done",progress:1}:{...oe,status:"failed",error:ve.error};if(W[de]=ar,F(oe.key,()=>ar),ve.ok){let Qe=await p.getRequest(w);s.current===c&&Qe.ok&&Qe.value.petRef===r&&f(_r=>({..._r,requests:Jn(_r.requests,Qe.value)}));}}return s.current===c&&b({isUploading:false,uploadProgress:null}),Object.freeze(W)},[p,b,F,r,c,f]),M=react.useCallback(async(w,x)=>{if(!p||s.current!==c)return Zn();let A=`${Date.now().toString(36)}-0`;f(W=>({...W,isUploading:true,uploadProgress:0,uploadQueue:[{key:A,name:x.name??null,status:"uploading",progress:0,skipReason:null,error:null}]}));let D=await p.uploadDocument({requestId:w,file:x,onProgress:i(W=>{s.current===c&&(b({uploadProgress:W}),F(A,de=>({...de,progress:Math.max(de.progress,Math.min(1,W))})));},"onProgress")});if(s.current!==c)return D;if(b({isUploading:false,uploadProgress:null}),F(A,W=>D.ok?{...W,status:"done",progress:1}:{...W,status:"failed",error:D.error}),D.ok){let W=await p.getRequest(w);s.current===c&&W.ok&&W.value.petRef===r&&f(de=>({...de,requests:Jn(de.requests,W.value)}));}return D},[p,b,F,r,c,f]),$=react.useCallback(async(w,x)=>{if(!p||s.current!==c)return Zn();let A=await p.grantConsent({petRef:r,consentVersion:w,idempotencyKey:x});return A.ok&&s.current===c&&E(),A},[p,r,E,c]),V=react.useCallback(async()=>{if(!p||s.current!==c)return Zn();let w=await p.revokeConsent(r);return w.ok&&ms(r),w.ok&&s.current===c&&(R.current+=1,b({record:null,withheld:false,loading:false,denialReason:"consent_required",consent:w.value})),w},[p,r,b,c]),re=react.useCallback(()=>E(),[E]),Q=$u(g,p!==null);return react.useMemo(()=>({status:Q,record:g.record,requests:g.requests,activeRequest:h,consent:g.consent,error:g.error,denialReason:g.denialReason,withheld:g.withheld,isUploading:g.isUploading,uploadProgress:g.uploadProgress,uploadQueue:g.uploadQueue,createRequest:I,uploadDocument:M,uploadDocuments:q,grantConsent:$,revokeConsent:V,refresh:re}),[Q,g,h,I,M,q,$,V,re])}i(We,"useEverfurRecords");function gs(e){if(e.mimeType!==ct)return "unsupported";let r=e.sizeBytes;return typeof r!="number"||!Number.isFinite(r)||r<=0||r>jr?"too_large":null}i(gs,"skipReasonFor");function bs(e){let r=[],t=[];for(let o of e){let n=gs(o);n===null?r.push(o):t.push({name:o.name??null,reason:n});}return {uploadable:r,skipped:t}}i(bs,"classifyPick");function $u(e,r){return e.loading||!r?"loading":e.withheld||e.denialReason!==null||e.error!==null?"error":e.record!==null&&!e.record.isEmpty||e.requests.length>0?"populated":"empty"}i($u,"selectStatus");function Uu(e){if(e.length===0)return null;let r=e[0];for(let t of e)t.updatedAt>r.updatedAt&&(r=t);return r}i(Uu,"newestRequest");function Jn(e,r){let t=e.filter(o=>o.id!==r.id);return [r,...t]}i(Jn,"replaceRequest");function Bu(e){return e.ok?"consent_required":dt(e.error)??"consent_required"}i(Bu,"consentDenial");function ju(){return z("internalError",{retryable:false})}i(ju,"withheldSentinel");function Zn(){return {ok:false,error:z("internalError",{retryable:true})}}i(Zn,"notReady");function ci(e){let r=globalThis.console;try{r?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(ci,"reportHostFailure");function Hu(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(Hu,"isThenable");function Vu(e,...r){if(typeof e=="function")try{let t=e(...r);return Hu(t)&&Promise.resolve(t).then(void 0,ci),t}catch(t){ci(t);return}}i(Vu,"callHost");var Rs=new WeakMap;function yn(e){if(typeof e!="function")return;let r=Rs.get(e);if(r!==void 0)return r;let t=i((...o)=>{Vu(e,...o);},"guarded");return Rs.set(e,t),t}i(yn,"guardHost");function _e(e,r){let t=null;for(let o of r){let n=e[o];typeof n=="function"&&(t??={...e},t[o]=yn(n));}return t??e}i(_e,"guardHostProps");function Et(e,...r){let t;try{t=e(...r);}catch(o){return ci(o),Promise.resolve({ok:false,error:o})}return Promise.resolve(t).then(o=>({ok:true,value:o}),o=>({ok:false,error:o}))}i(Et,"callHostAsync");var Wu="your pet";function Pe(e){let r=e?.trim()??"";return r.length>0?r:Wu}i(Pe,"petNameOr");var lr=Object.freeze({title:"Health records",openTimeline:"Open timeline",loading:"Loading health records",lead:i(e=>`${Pe(e)}\u2019s lab trends`,"lead"),retryMarkers:"Retry loading lab trends",viewFullRecord:"View full medical record",viewTimeline:"View full timeline",important:i(e=>`Important: ${e}`,"important")}),hr=Object.freeze({title:"Marker Summary",marker:"Marker",markers:"Markers",outOfRange:"OUT OF RANGE",inRange:"IN RANGE",noRange:"NO RANGE",subtitle:"Summary of your pet\u2019s biomarkers",ask:"Ask about these markers",askA11y:"Ask Everfur about these markers",a11y:i((e,r,t,o)=>`Marker summary: ${e} ${e===1?"marker":"markers"}, ${r} in range, ${t} out of range${o>0?`, ${o} without a range`:""}.`,"a11y")}),ui=Object.freeze({counter:i((e,r)=>`${e+1} of ${r}`,"counter"),a11y:i((e,r,t)=>e!==null?`${e}, marker ${r+1} of ${t}. Swipe left or right to see more markers.`:`Marker ${r+1} of ${t}`,"a11y")}),rt=Object.freeze({tapHint:"Tap a point to see where it came from.",singleHint:"One reading so far: we\u2019ll plot a trend as more come in.",empty:"No readings for this marker yet.",ask:"Ask about this marker",askA11y:i(e=>`Ask Everfur about ${e}`,"askA11y"),status:i(e=>`Status: ${e}`,"status"),latestA11y:i((e,r,t)=>`Latest reading ${e}, ${r}, collected ${t}`,"latestA11y"),readingsA11y:i(e=>`${e} readings, oldest to newest`,"readingsA11y")}),dr=Object.freeze({title:"Where this reading came 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\u2019t verified this reading against the original document yet.",reviewed:"Reviewed by our team",ask:"Ask about this reading",askA11y:"Ask Everfur about this reading"}),$t=Object.freeze({title:i(e=>`${Pe(e)}\u2019s records request`,"title"),body:i(e=>`We\u2019re requesting ${Pe(e)}\u2019s records from your vet. This usually takes a few days; we\u2019ll show lab trends here as soon as they arrive.`,"body"),a11y:i(e=>`Records request in progress for ${Pe(e)}.`,"a11y"),openA11y:i((e,r)=>`Open ${Pe(e)}\u2019s records request. ${r}`,"openA11y"),ask:"Ask about this request",askA11y:"Ask Everfur about this records request"}),xt=Object.freeze({title:i(e=>`Add ${Pe(e)}\u2019s records`,"title"),body:"Records can come from more than one clinic over a lifetime.",requestFromClinic:"Request from a clinic",requestFromClinicA11y:i(e=>`Request ${Pe(e)}\u2019s records from a clinic`,"requestFromClinicA11y"),uploadDocument:"Upload a document",uploadDocumentA11y:i(e=>`Upload one of ${Pe(e)}\u2019s records`,"uploadDocumentA11y")});var Se=Object.freeze({title:"Medical records",lead:"Follow your records requests and add records you already have.",viewRecord:"Visits & records",viewTimeline:"Timeline",viewLabs:"Labs & bloodwork",viewScreenings:"Screenings",requestsFor:i(e=>`Requests for ${Pe(e)}`,"requestsFor"),uploadPromptTitle:i(e=>`Do you already have ${Pe(e)}'s records?`,"uploadPromptTitle"),uploadPromptBody:"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.",uploadAction:"Upload records I already have",uploadStarting:"Starting upload\u2026",noPet:"Add your pet in Chat before starting a records request.",requestRecords:"Request records",requestTimeline:"Request timeline",requestTimelineA11y:i(e=>`Request timeline, ${e}`,"requestTimelineA11y"),ownerProvided:"Records you provided",askA11y:i(e=>`Ask Everfur about ${Pe(e)}'s medical records`,"askA11y")});function hs(e){return `I'm looking at ${e?.trim()||"my pet"}'s medical records. What do these records tell me about their health and what should I keep on top of?`}i(hs,"buildRecordsPageAskPrompt");function eo(e){if(e.convertedToUploadAt)return Se.ownerProvided;let r=e.clinicName?.trim()??"";return r.length>0?r:Se.ownerProvided}i(eo,"consumerRequestSource");var G=Object.freeze({loading:"Loading",empty:"No records yet",upload:"Upload records",consentRequired:"Consent required",allow:"Allow",sessionRequired:"Sign in required",recordUnavailable:"Record unavailable",retry:"Try again",records:"Records",beingReviewed:"being reviewed"});function vs(e){return !Mt(e.status)}i(vs,"isRecordsInProgress");function ro(e,r){if(r===null)return null;let t=e.filter(l=>l.petRef===r);if(t.length===0)return null;let o=t.find(l=>l.status==="published");return o!==void 0?o:t.filter(vs).sort((l,a)=>a.updatedAt.localeCompare(l.updatedAt))[0]??null}i(ro,"pickPetRecordsRequest");function pi(e){if(e.hasMarkers)return "published";let r=ro(e.requests,e.petRef);return r===null?"none":r.status==="published"||vs(r)?"in_progress":"none"}i(pi,"deriveRecordsDashboardState");function Gu(e){return e.recordLoading?true:e.hasFullRecord?false:e.markersLoading||!e.hasMarkers&&e.requestsLoading}i(Gu,"selectDashboardLoading");function mi(e){return Gu(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"}i(mi,"selectDashboardView");function Xe(e){return e?.httpStatus===429?"rate_limited":e?.httpStatus===502?"service_unavailable":"error"}i(Xe,"recordsEmptyVariantForError");var Cs=Object.freeze({name:"dashboard"});function Ut(e=Cs){return Object.freeze({stack:Object.freeze([e])})}i(Ut,"initialRecordsNav");function to(e){return e.stack[e.stack.length-1]??Cs}i(to,"currentRecordsScreen");function fi(e,r){return Object.freeze({stack:Object.freeze([...e.stack,r])})}i(fi,"pushRecordsNav");function yi(e,r){return Object.freeze({stack:Object.freeze([...e.stack.slice(0,-1),r])})}i(yi,"replaceRecordsNav");function gi(e){return Ut(e)}i(gi,"resetRecordsNav");function no(e){return e.stack.length<=1?{state:e,handled:false}:{state:Object.freeze({stack:Object.freeze(e.stack.slice(0,-1))}),handled:true}}i(no,"popRecordsNav");function Es(e,r){return r.name==="dashboard"?gi(r):to(e).name==="upload"&&r.name==="request"?yi(e,r):fi(e,r)}i(Es,"transitionRecordsNav");function gn(e,r){switch(r.type){case "push":return fi(e,r.screen);case "pop":return no(e).state;case "replace":return yi(e,r.screen);case "reset":return gi(r.screen);case "navigate":return Es(e,r.screen);default:return e}}i(gn,"recordsNavReducer");function Vr(e,r){return e??r?.version??""}i(Vr,"resolveConsentVersion");function tt(e,r){return Vr(e,r).length>0}i(tt,"canGrantConsent");function Wr(e,r){return e.denialReason==="consent_required"?r?{kind:"consent_required"}:{kind:"consent_unavailable"}:e.denialReason==="pet_not_found"?{kind:"pet_not_found",error:z("petNotFound",{retryable:false})}:e.denialReason==="entitlement"?{kind:"error",error:z("accessDenied")}:e.denialReason==="session_required"?{kind:"session_required"}:e.withheld?{kind:"withheld"}:e.error===null?{kind:"withheld"}:{kind:"error",error:e.error}}i(Wr,"selectErrorView");function oo(e){let r=e.clinicName?.trim()??"";return r.length>0?r:e.source==="owner_provided"?xs.ownerUpload:xs.clinicRequest}i(oo,"selectRequestTitle");var xs=Object.freeze({ownerUpload:"Records you uploaded",clinicRequest:"Record request"});function bi(e,r){return r===null||r.status!=="awaiting_upload"?null:r}i(bi,"selectResumableUploadRequest");function Ri(e){return `${e} ${G.beingReviewed}`}i(Ri,"heldItemsLabel");function hi(e){let r=[...e].sort((t,o)=>t.updatedAt!==o.updatedAt?t.updatedAt>o.updatedAt?-1:1:t.createdAt!==o.createdAt?t.createdAt>o.createdAt?-1:1:0);return Object.freeze(r)}i(hi,"selectRequestList");function bn(e){let r=e.actionNeededLabel?.trim()??"";return r.length>0?r:e.statusLabel}i(bn,"selectPrimaryLabel");function io(e){if(e.showClinicPhone!==true)return null;let r=e.clinicPhone?.trim()??"";return r.length===0?null:{phone:r,dial:`tel:${r.replace(/[^+\d]/g,"")}`,clinicName:e.clinicName?.trim()||null}}i(io,"selectClinicCall");function Ss(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"}}i(Ss,"selectRequestStatusTone");var Ei=class Ei extends react.Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(t,o){return Object.is(t.resetKey,o.key)?null:{failed:false,key:t.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};i(Ei,"HostRenderBoundary");var vi=Ei;function Ku({render:e}){return e()}i(Ku,"RenderHost");function Ci({render:e,fallback:r,resetKey:t}){return react.createElement(vi,{fallback:r,resetKey:t,children:react.createElement(Ku,{render:e})})}i(Ci,"HostRender");function wi(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let r of Object.keys(e))wi(e[r]);}return e}i(wi,"deepFreeze");var Qu=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),_s={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},Ps={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},ks={nano:8,small:9,micro:10,tiny:11,caption:12,bodyTight:13,body:14,subtitle:16,heading:18,verdict:24},Xu={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Ju={regular:"400",medium:"500",bold:"700"},Zu={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},ep=0,ao="System",so="monospace",rp=["content","heading","control","compact","badge"];function tp(e){let r={};for(let t of rp)r[t]=e;return r}i(tp,"authoredTierSizes");function Ts(){return {family:ao,mono:so,fontUrl:null,families:{regular:ao,medium:ao,bold:ao,mono:so,monoMedium:so,monoBold:so},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:ks,tierSizes:tp(ks),lineHeight:Xu,weight:Ju,letterSpacing:Zu,scale:1,maxScale:ep,scaleCaps:Qu}}i(Ts,"baseType");var Ds={},xi=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function Si(e){return `cubic-bezier(${e.join(", ")})`}i(Si,"cssCubicBezier");var Os={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:Si(xi.standard),emphasized:Si(xi.emphasized),exit:Si(xi.exit)},reducedMotion:false},np={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FDFBF8",surfaceSubtle:"#EFE9E3",background:"#FFFFFF",borderRingCream:"#D8D2C8",chatGround:"#FFFFFF",composerFill:"#FDFBF8",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#111111",secondary:"#0E462E",muted:"#6E6660",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#B91C1C",errorRed:"#FF1B00",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(185,28,28,0.12)",badgeBgNeutral:"rgba(110,102,96,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#111111",skeleton:"#EFE9E3",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},Is=wi({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:np,space:_s,radius:Ps,type:Ts(),motion:Os,slots:Ds}),op={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A938C",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#111111",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"};wi({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:op,space:_s,radius:Ps,type:Ts(),motion:Os,slots:Ds});var As=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),qs=globalThis,ki=qs[As]??(qs[As]=react.createContext(Is));ki.displayName??="EverfurThemeContext";function ce(){return react.useContext(ki)}i(ce,"useEverfurTheme");var Ns=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});var Ls='system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',sp="System";function lp(e){let r=e.trim();return r.length===0||r===sp?Ls:`${Fs(r)}, ${Ls}`}i(lp,"cssFontFamily");function dp(e){let r=e.trim();return r.length===0||r==="monospace"?"ui-monospace, Menlo, Consolas, monospace":`${Fs(r)}, ui-monospace, Menlo, Consolas, monospace`}i(dp,"cssMonoFamily");function Fs(e){return `"${e.replace(/[\\"]/g,"\\$&")}"`}i(Fs,"quote");function O(e,r){let t=e.type,o=t.families[r];return {fontFamily:r==="mono"||r==="monoMedium"||r==="monoBold"?dp(o):lp(o),fontWeight:t.namedFaces[r]?t.weight.regular:t.weight[Ns[r]]}}i(O,"faceCss");var mt=Object.freeze({textAlign:"start"});var cp=Object.freeze({chat:Object.freeze(["chat.message.create"]),records:Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:Object.freeze(["records.clinic.create"]),video:Object.freeze(["video.gait.execute"]),photo:Object.freeze(["photo.checkup.execute"]),animations:Object.freeze(["animations.state.read"]),televet:Object.freeze(["televet.visit.create"])});function up(e){return cp[e]}i(up,"requires");function zs(e,r,t){let o=up(e),n=new Map;for(let c of r)n.set(c.resource,c);if(t?.isPending===true&&o.some(c=>!n.has(c)))return _i({name:e,enabled:false,isPending:true,limits:{}});let l=pp(o,n);return o.filter(c=>n.get(c)?.granted!==true).length===0?_i({name:e,enabled:true,isPending:false,limits:l}):_i({name:e,enabled:false,isPending:false,limits:l,disabled:mp(o,n)})}i(zs,"decideCapability");function pp(e,r){let t={};for(let o of e){let n=r.get(o)?.limits;if(n)for(let[l,a]of Object.entries(n)){let c=t[l];t[l]=c===void 0?a:Math.min(c,a);}}return t}i(pp,"mergeLimits");function mp(e,r){for(let t of e){let o=r.get(t)?.disabled;if(o)return Object.freeze({reason:o.reason,level:o.level,recoverable:o.recoverable})}return Object.freeze({reason:Ko("accessDenied"),level:"user_entitlement",recoverable:false})}i(mp,"disabledFor");function _i(e){let r={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:Object.freeze({...e.limits})};return e.disabled!==void 0&&(r.disabled=e.disabled),Object.freeze(r)}i(_i,"freezeDecision");function St(e){let{runtime:r}=ee(),t=r.entitlements,o=react.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot);return react.useMemo(()=>zs(e,o.decisions,{isPending:o.isPending}),[e,o])}i(St,"useCapability");var gp=48;function bp(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(bp,"selectView");function Te(e){let{capability:r,children:t,renderDisabled:o,renderPending:n,style:l,className:a}=e,c=St(r),s=react.useMemo(()=>bp(c),[c]);switch(s){case "enabled":return t;case "pending":return n?jsxRuntime.jsx(Ci,{render:n,fallback:jsxRuntime.jsx(Ms,{capability:r,style:l,className:a})}):jsxRuntime.jsx(Ms,{capability:r,style:l,className:a});case "disabled":return o?jsxRuntime.jsx(Ci,{render:()=>o(c),fallback:jsxRuntime.jsx($s,{decision:c,style:l,className:a}),resetKey:c}):jsxRuntime.jsx($s,{decision:c,style:l,className:a});default:return Dr(s)}}i(Te,"CapabilityGate");function Ms({capability:e,style:r,className:t}){let o=ce(),n=react.useMemo(()=>Us(o),[o]);return jsxRuntime.jsx("div",{role:"status","aria-busy":"true","aria-label":`Loading ${e}`,className:t,style:{...n.offstate,...r},children:jsxRuntime.jsx("div",{style:n.skeletonBar})})}i(Ms,"PendingSkeleton");function $s({decision:e,style:r,className:t}){let o=ce(),n=react.useMemo(()=>Us(o),[o]),l=e.disabled?.reason??"";return jsxRuntime.jsx("div",{className:t,style:{...n.offstate,...r},children:l.length>0?jsxRuntime.jsx("p",{style:n.offstateText,children:l}):null})}i($s,"OffState");function Us(e){let{color:r,space:t,radius:o,type:n}=e;return {offstate:{...mt,boxSizing:"border-box",minHeight:gp,display:"flex",flexDirection:"column",justifyContent:"center",padding:`${t.md}px ${t.lg}px`,backgroundColor:r.surfaceCream,borderRadius:o.md,border:`1px solid ${r.brandBorder}`},offstateText:{margin:0,...O(e,"regular"),fontSize:n.size.body,lineHeight:`${Math.round(n.size.body*n.lineHeight.normal)}px`,color:r.text.muted},skeletonBar:{height:t.md,borderRadius:o.xs,backgroundColor:r.brandSofter}}}i(Us,"makeStyles");var lo=2;function Bs(e){return typeof e!="number"||!Number.isInteger(e)?lo:e<1?1:e>6?6:e}i(Bs,"headingLevel");function Ti(e){return e>=6?6:e+1}i(Ti,"nextHeadingLevel");function co(e){return `h${String(e)}`}i(co,"headingTag");var hp=Ti(lo);react.createContext(hp);var Di=Object.freeze({title:"For educational use only",body:"Everfur is for educational purposes only. It helps you track visible changes through AI checkups. It does not diagnose, treat, prescribe, or replace veterinary care. For urgent symptoms or emergencies, contact a veterinarian immediately."});function De(e){let r=ce(),t=react.useMemo(()=>Cp(r),[r]);return jsxRuntime.jsxs("div",{role:"note",className:e.className,style:{...t.container,...e.style},children:[jsxRuntime.jsx("p",{style:t.title,children:Di.title}),jsxRuntime.jsx("p",{style:t.body,children:Di.body})]})}i(De,"ClinicalDisclaimer");function Cp(e){let{color:r,space:t,type:o}=e,n=`${Math.round(o.size.caption*o.lineHeight.snug)}px`;return {container:{...mt,boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.xs,padding:`${t.md}px ${t.lg}px`,borderTop:`1px solid ${r.borderHairlineGreen}`,backgroundColor:r.surfaceCream},title:{margin:0,...O(e,"bold"),fontSize:o.size.caption,lineHeight:n,color:r.text.secondary,letterSpacing:o.letterSpacing.eyebrow},body:{margin:0,...O(e,"regular"),fontSize:o.size.caption,lineHeight:n,color:r.text.muted}}}i(Cp,"makeStyles");var X=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\u2019re authorizing",send:"Send request",sending:"Sending\u2026",cancel:"Cancel",sign:"Signature",draw:"Draw your signature",type:"Type your name to sign",toType:"Can\u2019t draw? Type your name instead",toDraw:"Draw your signature instead",clear:"Clear",drawHint:"Draw your signature in the box above.",clearA11y:"Clear signature",typedSignatureA11y:i(e=>`Typed signature: ${e}`,"typedSignatureA11y"),missingSignature:"Please add your signature before submitting.",recentlyUsed:"Recently used"}),Hs=100;var xe=Object.freeze({title:X.title,placeholder:X.placeholder,searchA11y:X.search,clearSearch:"Clear search",loading:"Loading clinics",uploadOwn:"I already have the records",uploadOwnStarting:"Setting up your upload\u2026",uploadOwnA11y:"Upload records you already have",noPet:"Add a pet first, then come back to request their records.",recentlyUsed:X.recentlyUsed,noMatch:i(e=>`No clinics match \u201C${e}\u201D. You can still request records using the option above.`,"noMatch"),loadingMore:"Loading more\u2026",loadMoreFailed:"Couldn\u2019t load more. Tap to retry.",loadMoreRetryA11y:"Retry loading more clinics",selectA11y:i(e=>`Request records from ${e}`,"selectA11y"),fallback:Object.freeze({title:"Can\u2019t find your clinic?",subtitle:"Add it by email and we\u2019ll request your records.",expandA11y:"Can't find your clinic? Add it by email to request records.",collapseA11y:"Hide the request-by-email form",nameLabel:"Clinic name",namePlaceholder:"Your clinic\u2019s name",emailLabel:"Clinic email",emailPlaceholder:"records@clinic.com",reviewNote:"We review every request by hand before reaching out to the clinic.",submit:"Continue",submitA11y:"Request records by email"})});function Vs(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"}}}i(Vs,"clinicEmailStatusBadge");function Ws(e){return e===null||!Number.isFinite(e)?"":`${e.toFixed(1)} km`}i(Ws,"formatClinicDistanceLabel");function Gs(e){return e===null||!Number.isFinite(e)?"":`${e.toFixed(1)} ${e===1?"kilometer":"kilometers"} away`}i(Gs,"formatClinicDistanceForA11y");var Ys=300,Oi=2;var ue=Object.freeze({loading:"Loading record request",timelineA11y:"Request timeline",awaitingNote:"Clinics usually reply within a week. We follow up automatically and will let you know if there\u2019s no reply by day 14.",waitingBanner:i(e=>`It\u2019s been ${e} ${e===1?"day":"days"}. Some clinics take a little longer; we\u2019ve been following up automatically and are still on it. If there\u2019s no reply by day 14, we\u2019ll let you know.`,"waitingBanner"),viewRecords:"View health records",nextStep:"You can try a different clinic or upload records you already have.",tryAnotherClinic:"Request from a different clinic",tryAnotherClinicA11y:"Request records from a different clinic",convert:"Upload my own records instead",converting:"Switching\u2026",convertHint:"We\u2019ll stop waiting on the clinic so you can add the records you already have. If the clinic does reply, we\u2019ll still add their records too.",freshUpload:"Upload your own records",freshUploadStarting:"Starting\u2026",cancel:"Cancel request",cancelling:"Cancelling\u2026",cancelA11y:"Cancel this records request",cancellingA11y:"Cancelling, please wait",resend:"Resend email",resending:"Resending\u2026",resendA11y:"Resend the authorization email to the clinic",resendingA11y:"Resending the email, please wait",errors:Object.freeze({cancel:"We couldn\u2019t cancel this request. Please try again.",retry:"We couldn\u2019t retry this request. Please try again.",email:"We couldn\u2019t update the clinic email. Please try again.",convert:"We couldn\u2019t switch this to an upload. Please try again.",start:"We couldn\u2019t start that. Please try again.",invalidEmail:"Enter a valid clinic email."})});function xp(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\u2019t include your records.";switch(e.failureCode){case "no_response":return "The clinic didn\u2019t reply after several reminders over 14 days.";case "parse_timeout":case "parse_error":return "We received the records but couldn\u2019t read them. Uploading a clean copy usually fixes this.";case "hard_bounce":case "dispatch_failed":return "We couldn\u2019t deliver the email to the clinic.";default:return "This request didn\u2019t go through."}}i(xp,"fallbackFailureTitle");function Ks(e){let r=e.failureReason?.trim()??"";return r.length>0?r:xp(e)}i(Ks,"failureTitle");var Sp=1440*60*1e3;function Ii(e,r){if(!e.createdAt)return 0;let t=Date.parse(e.createdAt);if(Number.isNaN(t))return 0;let o=r-t;return o<=0?0:Math.floor(o/Sp)}i(Ii,"requestElapsedDays");var wp=7;function Qs(e,r){return e.wireStatus!=="awaiting_response"?false:Ii(e,r)>=wp}i(Qs,"requestWaitingTooLong");function Ai(e){return e.status==="failed"}i(Ai,"isTerminalFailure");function Xs(e){return Ai(e)||e.canUpdateClinicEmail===true||e.canRetrySend===true}i(Xs,"shouldOfferRecovery");function el(e,r){let[t,o]=react.useState(""),[n,l]=react.useState(""),[a,c]=react.useState([]),[s,d]=react.useState(null),[u,p]=react.useState([]),[m,y]=react.useState(true),[g,f]=react.useState(false),[R,b]=react.useState(false),[E,h]=react.useState(null),[v,S]=react.useState(null),[C,k]=react.useState(0),_=react.useRef(0),T=react.useRef(true),I=r?.latitude,F=r?.longitude,q=react.useMemo(()=>I!==void 0&&F!==void 0?{latitude:I,longitude:F}:void 0,[I,F]);react.useEffect(()=>(T.current=true,()=>{T.current=false,_.current+=1;}),[e]),react.useEffect(()=>{let Q=true;return y(true),e.recentClinics({limit:5}).then(w=>{Q&&(w.ok&&p(w.value.clinics),y(false));}).catch(()=>{Q&&y(false);}),()=>{Q=false;}},[e]),react.useEffect(()=>{let Q=t.trim();if(Q.length<Oi){l("");return}let w=setTimeout(()=>l(Q),Ys);return ()=>clearTimeout(w)},[t]);let M=n.length>=Oi;react.useEffect(()=>{let Q=_.current+=1;if(c([]),d(null),h(null),S(null),!M){f(false);return}f(true),e.searchClinics({query:n,limit:25,...q?{location:q}:{}}).then(w=>{!T.current||Q!==_.current||(w.ok?(c(w.value.clinics),d(w.value.nextCursor)):h(w.error),f(false));}).catch(()=>{T.current&&Q===_.current&&f(false);});},[e,n,M,q,C]);let $=react.useCallback(()=>{if(!M||s===null||R)return;let Q=_.current;b(true),S(null),e.searchClinics({query:n,limit:25,cursor:s,...q?{location:q}:{}}).then(w=>{!T.current||Q!==_.current||(w.ok?(c(x=>[...x,...w.value.clinics]),d(w.value.nextCursor)):S(w.error),b(false));}).catch(()=>{T.current&&Q===_.current&&b(false);});},[e,s,n,M,R,q]),V=react.useCallback(Q=>o(Q),[]),re=react.useCallback(()=>k(Q=>Q+1),[]);return react.useMemo(()=>({query:t,debouncedQuery:n,isSearchActive:M,clinics:a,recent:u,recentLoading:m,initialLoading:g,loadingMore:R,hasNextPage:s!==null,error:E,pageError:v,setQuery:V,loadMore:$,retry:re}),[t,n,M,a,u,m,g,R,s,E,v,V,$,re])}i(el,"useClinicPicker");function Ni(e,r,t,o){return Object.freeze({key:e?.id??`free:${r??""}`,clinic:e,freeText:r,email:t,idempotencyKey:o})}i(Ni,"clinicDraftFor");var Bt=10,po=zod.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),Rn=i((e,r=1)=>zod.z.string().refine(t=>!pt(t)&&[...t].length>=r&&[...t].length<=e),"text"),tl=i(e=>[...e].some(r=>r.charCodeAt(0)<32||r.charCodeAt(0)===127),"hasControl"),kp=zod.z.object({clinicId:po.optional(),clinicFreeText:Rn(200).refine(e=>e.trim().length>0).optional(),clinicEmail:Rn(320,3).refine(e=>!tl(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())).optional(),signatureId:po.optional(),signaturePngBase64:zod.z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:zod.z.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)),_p=zod.z.object({petRef:Rn(128),ownerName:Rn(200).refine(e=>e.trim().length>0&&!tl(e)),authorizationVersion:Rn(64),clinics:zod.z.array(kp).min(1).max(Bt)}).strict(),Pp=zod.z.object({request_group_id:po,pet_ref:zod.z.string(),created_count:zod.z.number().int().nonnegative(),failed_count:zod.z.number().int().nonnegative(),results:zod.z.array(zod.z.object({idempotency_key:zod.z.string(),clinic_id:po.nullable().optional(),clinic_free_text:zod.z.string().nullable().optional(),created:zod.z.boolean(),request:zod.z.unknown().optional(),failure_code:zod.z.string().nullable().optional(),failure_reason:zod.z.string().nullable().optional()}))});function nl(e){let r=e.funnel??ut({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}});return {async createClinicRequestBatch(t){if(!_p.safeParse(t).success)return Y(z("validationFailed",{retryable:false}));let o=await r.send("records.clinic.createBatch",{method:"POST",path:"/widget/v1/records/clinic-requests/batch",body:{pet_ref:t.petRef,owner_name:t.ownerName,authorization_version:t.authorizationVersion,clinics:t.clinics.map(a=>({...a.clinicId!==void 0?{clinic_id:a.clinicId}:{clinic_free_text:a.clinicFreeText},...a.clinicEmail!==void 0?{clinic_email:a.clinicEmail}:{},...a.signatureId!==void 0?{signature_id:a.signatureId}:{signature_png_base64:a.signaturePngBase64},idempotency_key:a.idempotencyKey}))}});if(!o.ok)return o;let n=Pp.safeParse(o.value);if(!n.success||n.data.pet_ref!==t.petRef)return rl();let l=[];for(let a of n.data.results){let c=a.request===void 0||a.request===null?null:lt(a.request);if(a.created!==(c!==null))return rl();l.push(Object.freeze({idempotencyKey:a.idempotency_key,clinicId:a.clinic_id??null,clinicFreeText:a.clinic_free_text??null,created:a.created,request:c,failureCode:a.failure_code??null,failureReason:a.failure_reason??null}));}return we(Object.freeze({requestGroupId:n.data.request_group_id,petRef:n.data.pet_ref,results:Object.freeze(l),createdCount:n.data.created_count,failedCount:n.data.failed_count}))}}}i(nl,"createRecordsClinicBatchClient");function rl(){return Y(z("internalError",{retryable:false}))}i(rl,"malformed");var ol=zod.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),Tp=zod.z.object({clinics:zod.z.array(zod.z.object({clinic_id:ol,name:zod.z.string().min(1),address:zod.z.string().nullable(),phone:zod.z.string().nullable(),email_status:zod.z.string(),distance_km:zod.z.number().finite().nonnegative().nullable()})),next_cursor:zod.z.string().nullable().optional()}),Dp=zod.z.object({authorization_version:zod.z.string().min(1),scope_template:zod.z.string().min(1),authorization_template:zod.z.string().min(1)}),Op=zod.z.object({upload_id:zod.z.string().min(1),upload_url:zod.z.string().url().refine(e=>e.startsWith("https://")),upload_fields:zod.z.record(zod.z.string())});function il(e){let{repository:r}=e,t=i(async n=>{let l=await n;if(!l.ok)return l;let a=lt(l.value);return a===null?wt():we(a)},"request"),o=i(async n=>{let l=await n;if(!l.ok)return l;let a=Tp.safeParse(l.value);return a.success?we(Object.freeze({clinics:Object.freeze(a.data.clinics.map(c=>Object.freeze({id:c.clinic_id,name:c.name,address:c.address,phone:c.phone,emailStatus:c.email_status,distanceKm:c.distance_km}))),nextCursor:a.data.next_cursor??null})):wt()},"page");return {searchClinics:i((n={})=>o(r.searchClinics(n)),"searchClinics"),recentClinics:i((n={})=>o(r.recentClinics(n)),"recentClinics"),async getRequestGroup(n){let l=await r.getRequestGroup(n);if(!l.ok)return l;let a=Ka(l.value);return a===null?wt():we(a)},async getAuthorizationCopy(){let n=await r.getAuthorizationCopy();if(!n.ok)return n;let l=Dp.safeParse(n.value);return l.success?we(Object.freeze({authorizationVersion:l.data.authorization_version,scopeTemplate:l.data.scope_template,authorizationTemplate:l.data.authorization_template})):wt()},async createClinicRequest(n){let l=await t(r.createClinicRequest(n));return l.ok&&l.value.petRef!==n.petRef?wt():l},retryRequest:i(n=>t(r.retryRequest(n)),"retryRequest"),revokeRequest:i(n=>t(r.revokeRequest(n)),"revokeRequest"),updateClinicEmail:i((n,l)=>t(r.updateClinicEmail(n,l)),"updateClinicEmail"),convertToUpload:i(n=>t(r.convertToUpload(n)),"convertToUpload"),async initiateSignatureUpload(n){let l=await r.initiateSignatureUpload(n);if(!l.ok)return l;let a=Op.safeParse(l.value);return a.success?we(Object.freeze({uploadId:a.data.upload_id,uploadUrl:a.data.upload_url,uploadFields:Object.freeze(a.data.upload_fields)})):wt()},async completeSignatureUpload(n){let l=await r.completeSignatureUpload(n);if(!l.ok)return l;let a=zod.z.object({signature_id:ol}).safeParse(l.value);return a.success?we(a.data.signature_id):wt()}}}i(il,"createRecordsClinicController");function wt(){return Y(z("internalError",{retryable:false}))}i(wt,"malformed");var ft="/widget/v1/records",al=zod.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),gt=i((e,r=1)=>zod.z.string().refine(t=>!pt(t)&&[...t].length>=r&&[...t].length<=e),"text"),ll=i(e=>[...e].some(r=>r.charCodeAt(0)<32||r.charCodeAt(0)===127),"hasControl"),dl=gt(320,3).refine(e=>!ll(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())),sl=gt(64),Ip=zod.z.object({limit:zod.z.number().int().min(1).max(25).optional()}).strict(),Ap=zod.z.object({query:gt(200,0).optional(),location:zod.z.object({latitude:zod.z.number().finite().min(-90).max(90),longitude:zod.z.number().finite().min(-180).max(180)}).strict().optional(),limit:zod.z.number().int().min(1).max(100).optional(),cursor:gt(512,0).optional()}).strict(),qp=zod.z.object({petRef:gt(128),ownerName:gt(200).refine(e=>e.trim().length>0&&!ll(e)),authorizationVersion:gt(64),clinicId:al.optional(),clinicFreeText:gt(200).refine(e=>e.trim().length>0).optional(),clinicEmail:dl.optional(),signatureId:al.optional(),signaturePngBase64:zod.z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:zod.z.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 cl(e){let r=e.funnel??ut({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),t=i((n,l,a=false)=>r.send(`records.clinic.${n}`,l,l.method==="GET"||a?void 0:{idempotent:false,maxAttempts:1}),"send"),o=i((n,l,a)=>sl.safeParse(n).success?t(l,{method:"POST",path:`${ft}/requests/${encodeURIComponent(n)}/${l}`,...a?{body:a}:{}}):yt(),"recover");return {searchClinics(n){return Ap.safeParse(n).success?t("search",{method:"GET",path:`${ft}/clinics/search`,query:{q:n.query??"",lat:n.location?.latitude,lng:n.location?.longitude,limit:n.limit,cursor:n.cursor}}):yt()},recentClinics(n){return Ip.safeParse(n).success?t("recent",{method:"GET",path:`${ft}/clinics/recent`,query:{limit:n.limit}}):yt()},getRequestGroup(n){return sl.safeParse(n).success?t("requestGroup",{method:"GET",path:`${ft}/request-groups/${encodeURIComponent(n)}`}):yt()},getAuthorizationCopy:i(()=>t("authorizationCopy",{method:"GET",path:`${ft}/authorization-copy`}),"getAuthorizationCopy"),createClinicRequest(n){return qp.safeParse(n).success?t("create",{method:"POST",path:`${ft}/clinic-requests`,body:{pet_ref:n.petRef,owner_name:n.ownerName,authorization_version:n.authorizationVersion,idempotency_key:n.idempotencyKey,...n.clinicId!==void 0?{clinic_id:n.clinicId}:{clinic_free_text:n.clinicFreeText},...n.clinicEmail!==void 0?{clinic_email:n.clinicEmail}:{},...n.signatureId!==void 0?{signature_id:n.signatureId}:{signature_png_base64:n.signaturePngBase64}}},true):yt()},retryRequest:i(n=>o(n,"retry"),"retryRequest"),revokeRequest:i(n=>o(n,"revoke"),"revokeRequest"),convertToUpload:i(n=>o(n,"convert-to-upload"),"convertToUpload"),updateClinicEmail(n,l){return dl.safeParse(l).success?o(n,"clinic-email",{clinic_email:l}):yt()},initiateSignatureUpload(n){return !Number.isInteger(n)||n<=0||n>2*1024*1024?yt():t("signatureInitiate",{method:"POST",path:`${ft}/signatures/initiate`,body:{content_type:"image/png",file_size:n}})},completeSignatureUpload(n){return /^sig-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)?t("signatureComplete",{method:"POST",path:`${ft}/signatures/complete`,body:{upload_id:n}}):yt()}}}i(cl,"createHttpRecordsClinicRepository");function yt(){return Promise.resolve(Y(z("validationFailed",{retryable:false})))}i(yt,"invalid");function Ir(){let{runtime:e,userRef:r,scopeEpoch:t}=ee(),o=react.useMemo(()=>{let{services:l}=e.registry;return il({repository:cl({auth:l.authFor(r),...l.errorPolicy?{errorPolicy:l.errorPolicy}:{}})})},[e,r,t]),n=react.useRef(o);return react.useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),react.useMemo(()=>{let l=i(async a=>{if(r===null||n.current!==o)return Y(z("accessDenied"));let c=await a();return n.current===o?c:Y(z("accessDenied"))},"run");return {searchClinics:i(a=>l(()=>o.searchClinics(a)),"searchClinics"),recentClinics:i(a=>l(()=>o.recentClinics(a)),"recentClinics"),getRequestGroup:i(a=>l(()=>o.getRequestGroup(a)),"getRequestGroup"),getAuthorizationCopy:i(()=>l(()=>o.getAuthorizationCopy()),"getAuthorizationCopy"),createClinicRequest:i(a=>l(()=>o.createClinicRequest(a)),"createClinicRequest"),retryRequest:i(a=>l(()=>o.retryRequest(a)),"retryRequest"),revokeRequest:i(a=>l(()=>o.revokeRequest(a)),"revokeRequest"),updateClinicEmail:i((a,c)=>l(()=>o.updateClinicEmail(a,c)),"updateClinicEmail"),convertToUpload:i(a=>l(()=>o.convertToUpload(a)),"convertToUpload"),initiateSignatureUpload:i(a=>l(()=>o.initiateSignatureUpload(a)),"initiateSignatureUpload"),completeSignatureUpload:i(a=>l(()=>o.completeSignatureUpload(a)),"completeSignatureUpload")}},[o,r])}i(Ir,"useEverfurRecordsClinic");function Li(){let{runtime:e,userRef:r,scopeEpoch:t}=ee(),o=react.useMemo(()=>{let{services:l}=e.registry;return nl({auth:l.authFor(r),...l.errorPolicy?{errorPolicy:l.errorPolicy}:{}})},[e,r,t]),n=react.useRef(o);return react.useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),react.useMemo(()=>({async createClinicRequestBatch(l){if(r===null||n.current!==o)return Y(z("accessDenied"));let a=await o.createClinicRequestBatch(l);return n.current===o?a:Y(z("accessDenied"))}}),[o,r])}i(Li,"useEverfurRecordsClinicBatch");var Np=120,Lp=44;function Fp({reason:e,onExit:r,exitLabel:t,style:o,className:n}){let{color:l,space:a,radius:c,type:s}=ce();return jsxRuntime.jsxs("div",{className:n,"data-testid":"records-gate-off",style:{boxSizing:"border-box",minHeight:Np,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-start",gap:a.md,padding:a.lg,borderRadius:c.md,border:`1px solid ${l.brandBorder}`,backgroundColor:l.surfaceCream,color:l.text.primary,...o},children:[e.length>0?jsxRuntime.jsx("p",{style:{margin:0,fontSize:s.size.bodyTight,color:l.text.muted},children:e}):null,jsxRuntime.jsx("button",{type:"button",onClick:r,"data-testid":"records-gate-off-exit",style:{minHeight:Lp,padding:`0 ${a.lg}px`,borderRadius:c.pill,border:`1.5px solid ${l.brand}`,backgroundColor:"transparent",color:l.brand,font:"inherit",fontSize:s.size.body,cursor:"pointer"},children:t})]})}i(Fp,"RecordsGateOffState");function Oe(e,r){return e===void 0?{}:{renderDisabled:i(t=>jsxRuntime.jsx(Fp,{reason:t.disabled?.reason??"",onExit:e,exitLabel:r}),"renderDisabled")}}i(Oe,"recordsGateExit");function Mp(e,r){if(e===void 0)return {};let t={};return e.backgroundColor!==void 0&&(t.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(t.borderColor=e.borderColor,t.borderWidth=r??1),e.borderRadius!==void 0&&(t.borderRadius=e.borderRadius),t}i(Mp,"slotBox");function Yr(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(Yr,"slotText");function Ar(e,r){let t=Mp(e,r),o={};return t.backgroundColor!==void 0&&(o.backgroundColor=t.backgroundColor),t.borderColor!==void 0&&(o.border=`${t.borderWidth??1}px solid ${t.borderColor}`),t.borderRadius!==void 0&&(o.borderRadius=t.borderRadius),o}i(Ar,"slotBoxCss");var hn="data-ef-screen-heading";function fl(e){return e.focus(),document.activeElement===e}i(fl,"focusTook");function Up(e){let r=e.querySelector(`[${hn}]`);if(r!==null&&(r.textContent??"").trim().length>0&&fl(r)||fl(e))return;let t=e.firstElementChild;t instanceof HTMLElement&&(t.hasAttribute("tabindex")||(t.setAttribute("tabindex","-1"),t.style.outline="none"),t.focus());}i(Up,"focusScreen");function jt(e){let r=react.useRef(null),t=react.useRef(e);return react.useEffect(()=>{if(Object.is(t.current,e))return;t.current=e;let o=r.current;o!==null&&Up(o);},[e]),r}i(jt,"useFocusScreenOnChange");var jp=120,vn=44,Le="Back";function j(){let e=ce(),r=react.useMemo(()=>Hp(e),[e]);return {theme:e,styles:r}}i(j,"useScreenStyles");function He({title:e,onBack:r,right:t,testID:o,variant:n="brand"}){let{styles:l}=j();return jsxRuntime.jsxs("header",{style:l.headerRow,"data-testid":o,children:[r?jsxRuntime.jsx("button",{type:"button",onClick:r,"aria-label":Le,style:l.iconButton,"data-testid":o?`${o}-back`:void 0,children:jsxRuntime.jsx("span",{"aria-hidden":"true",style:l.backChevron})}):jsxRuntime.jsx("span",{style:l.iconButton}),jsxRuntime.jsx("h2",{tabIndex:-1,[hn]:"",style:n==="document"?l.documentTitle:l.headerTitle,children:e}),jsxRuntime.jsx("div",{style:l.headerRight,children:t??jsxRuntime.jsx("span",{style:l.iconButton})})]})}i(He,"ScreenHeader");function bt({disclaimer:e,style:r}){let{styles:t}=j();return e.trim().length===0?null:jsxRuntime.jsxs("p",{role:"note","aria-label":lr.important(e),style:{...t.band,...r},"data-testid":"records-disclaimer-band",children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:t.infoGlyph,children:"i"}),jsxRuntime.jsx("span",{style:t.bandText,children:e})]})}i(bt,"DisclaimerBand");function B({label:e,onClick:r,kind:t="primary",disabled:o=false,busy:n=false,ariaLabel:l,ariaDescribedBy:a,testID:c,style:s}){let{styles:d}=j(),u=t==="primary"?d.pillPrimary:t==="outline"?d.pillOutline:t==="danger"?d.pillDanger:t==="ask"?d.pillAsk:d.pillLink;return jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:o||n,"aria-busy":n,"aria-label":l,"aria-describedby":a,style:{...d.pill,...u,...o?d.pillDisabled:{},...s},"data-testid":c,children:e})}i(B,"Pill");function cr({label:e,tone:r="neutral",testID:t}){let{styles:o}=j();return jsxRuntime.jsx("span",{style:{...o.chip,...o.chipTones[r]},"data-testid":t,children:e})}i(cr,"Chip");function qr({title:e,count:r}){let{styles:t}=j();return jsxRuntime.jsxs("div",{style:t.sectionHeader,children:[jsxRuntime.jsx("h3",{style:t.sectionTitle,children:e}),r!==void 0?jsxRuntime.jsx("span",{style:t.sectionCount,children:r}):null]})}i(qr,"SectionHeader");function zi({name:e,color:r}){return jsxRuntime.jsx("svg",{"aria-hidden":"true",focusable:"false",width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block",flexShrink:0},"data-glyph":e,children:e==="send"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),jsxRuntime.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:"18",cy:"5",r:"3"}),jsxRuntime.jsx("circle",{cx:"6",cy:"12",r:"3"}),jsxRuntime.jsx("circle",{cx:"18",cy:"19",r:"3"}),jsxRuntime.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),jsxRuntime.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})})}i(zi,"HeaderGlyph");function kt({direction:e="right"}){let{styles:r}=j(),t=e==="right"?"45deg":e==="down"?"135deg":"-45deg";return jsxRuntime.jsx("span",{"aria-hidden":"true",style:{...r.chevron,transform:`rotate(${t})`}})}i(kt,"Chevron");function Hp(e){let{color:r,space:t,radius:o,type:n,slots:l}=e,a=i((y,g)=>`${Math.round(y*g)}px`,"lh"),c=i((y,g,f,R="regular")=>({margin:0,...O(e,R),fontSize:y,lineHeight:a(y,g),color:f}),"text"),s=Yr(l.recordCard),d=`1px solid ${r.brandBorder}`,u=e.brightness==="dark"?r.errorRed:r.danger,p=i((y,g)=>({backgroundColor:y,color:g}),"tone"),m={boxSizing:"border-box",minHeight:vn,minWidth:vn,padding:`${t.md}px ${t.lg+t.xs/2}px`,borderRadius:o.pill,...O(e,"bold"),fontSize:n.size.body,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:t.sm,textDecoration:"none"};return {chipTones:{neutral:p(r.badgeBgNeutral,r.text.secondary),info:p(r.brandSoft,r.brand),warning:p(r.badgeBgCaution,r.warningStrong),critical:p(r.badgeBgCritical,r.danger),positive:p(r.badgeBgPositive,r.success)},root:{...mt,boxSizing:"border-box",display:"flex",flexDirection:"column",minHeight:jp,height:"100%",backgroundColor:r.background,color:r.text.primary,...O(e,"regular")},body:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",overflowY:"auto"},content:{display:"flex",flexDirection:"column",gap:t.lg,padding:`0 ${t.lg}px ${t.xxl}px`},contentTight:{display:"flex",flexDirection:"column",gap:t.lg,padding:`0 ${t.sm}px ${t.xxl}px`},inset:{padding:`0 ${t.sm}px`},headerRow:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:t.sm,padding:`${t.xs}px ${t.lg}px ${t.md}px`},iconButton:{boxSizing:"border-box",width:vn,height:vn,display:"inline-flex",alignItems:"center",justifyContent:"center",border:0,background:"transparent",cursor:"pointer",padding:0,color:r.brand,flexShrink:0},backChevron:{display:"block",width:t.md,height:t.md,borderLeft:`2px solid ${r.brand}`,borderBottom:`2px solid ${r.brand}`,transform:"rotate(45deg)",marginLeft:t.xs},headerTitle:{...c(n.size.heading,n.lineHeight.tight,r.brand,"bold"),flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},documentTitle:{...c(n.size.subtitle,n.lineHeight.snug,r.text.primary,"bold"),flex:1,textAlign:"center"},headerRight:{display:"flex",alignItems:"center",gap:t.sm+t.xs/2},section:{display:"flex",flexDirection:"column",gap:t.sm+t.xs/2},sectionHeader:{display:"flex",alignItems:"center",gap:t.sm,padding:`0 ${t.xs}px`},sectionTitle:{...c(n.size.body+1,n.lineHeight.snug,r.text.primary,"bold")},sectionCount:{...c(n.size.bodyTight,n.lineHeight.snug,r.text.muted,"medium")},card:{boxSizing:"border-box",borderRadius:o.lg-t.xs,border:d,backgroundColor:r.surface,padding:`${t.xs}px ${t.lg}px`,margin:0,listStyle:"none",...Ar(l.recordCard,1)},creamCard:{boxSizing:"border-box",borderRadius:o.lg-t.xs/2,border:d,backgroundColor:r.surfaceCream,padding:t.lg,display:"flex",flexDirection:"column",gap:t.md,...Ar(l.recordCard,1)},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:t.md,padding:`${t.md}px 0`},rowDivider:{borderTop:`1px solid ${r.borderHairlineGreen}`},rowMain:{flex:1,minWidth:0},rowRight:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:t.xs+t.xs/2},rowTitle:{...c(n.size.body,n.lineHeight.snug,r.text.primary,"medium"),...s},rowDetail:{...c(n.size.caption,n.lineHeight.normal,r.text.secondary),marginTop:t.xs/2,...s},rowValue:{...c(n.size.body+1,n.lineHeight.snug,r.text.primary,"bold"),marginTop:t.xs/2,...s},rowMuted:{...c(n.size.caption,n.lineHeight.normal,r.text.muted),...s},chip:{display:"inline-block",borderRadius:o.pill,padding:`${t.xs-1}px ${t.sm}px`,...O(e,"medium"),fontSize:n.size.tiny,lineHeight:a(n.size.tiny,n.lineHeight.snug),whiteSpace:"nowrap"},pill:m,pillPrimary:{border:0,backgroundColor:r.brand,color:r.onPrimary,...Ar(l.primaryButton),...Yr(l.primaryButton)},pillOutline:{border:`1.5px solid ${r.brand}`,backgroundColor:"transparent",color:r.brand},pillDanger:{border:`1.4px solid ${r.danger}`,backgroundColor:r.surface,color:r.danger,fontSize:n.size.bodyTight},pillAsk:{border:`1px solid ${r.borderRingCream}`,backgroundColor:r.surface,color:r.text.primary},pillLink:{border:0,backgroundColor:"transparent",color:r.linkInk,padding:`${t.sm}px`},pillDisabled:{opacity:.5,cursor:"default"},infoNote:{display:"flex",gap:t.sm,borderRadius:o.md-t.xs/2,backgroundColor:r.brandSoft,padding:`${t.sm+t.xs/2}px ${t.md}px`,...c(n.size.bodyTight,n.lineHeight.normal,r.text.primary)},cautionNote:{display:"flex",gap:t.sm,borderRadius:o.md-t.xs/2,backgroundColor:r.badgeBgCaution,padding:`${t.sm+t.xs/2}px ${t.md}px`,...c(n.size.bodyTight,n.lineHeight.normal,r.warningStrong)},statusCard:{borderRadius:o.md,backgroundColor:r.brandSoft,padding:t.md+t.xs/2,...c(n.size.bodyTight,n.lineHeight.relaxed,r.text.primary)},errorBanner:{display:"flex",gap:t.sm,borderRadius:o.md-t.xs/2,backgroundColor:r.badgeBgCritical,padding:t.md,...c(n.size.bodyTight,n.lineHeight.normal,u)},errorText:c(n.size.bodyTight,n.lineHeight.normal,u),band:{display:"flex",alignItems:"flex-start",gap:t.sm,borderRadius:o.md-t.xs/2,padding:t.md,backgroundColor:r.brandSoft,margin:0},bandText:{flex:1,...c(n.size.caption,n.lineHeight.normal,r.text.secondary)},infoGlyph:{boxSizing:"border-box",flexShrink:0,width:t.md+t.xs/2,height:t.md+t.xs/2,borderRadius:o.pill,border:`1px solid ${r.text.secondary}`,display:"inline-flex",alignItems:"center",justifyContent:"center",...O(e,"bold"),fontSize:n.size.small,color:r.text.secondary},chevron:{display:"inline-block",width:t.sm,height:t.sm,borderTop:`2px solid ${r.text.muted}`,borderRight:`2px solid ${r.text.muted}`,flexShrink:0},lead:{...c(n.size.body+1,n.lineHeight.snug,r.text.primary,"bold"),padding:`0 ${t.sm}px`},field:{boxSizing:"border-box",display:"block",width:"100%",minHeight:vn,padding:`${t.sm}px ${t.md}px`,border:`1px solid ${r.borderHairlineGreen}`,borderRadius:o.sm,color:r.text.primary,backgroundColor:r.surface,...O(e,"regular"),fontSize:n.size.body},fieldLabel:{...c(n.size.bodyTight,n.lineHeight.normal,r.text.secondary,"medium"),display:"block",marginBottom:t.xs},muted:c(n.size.caption,n.lineHeight.normal,r.text.muted),bodyText:c(n.size.body,n.lineHeight.normal,r.text.primary),mono:O(e,"mono"),plainList:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column"},dialogFrame:{boxSizing:"border-box",position:"fixed",top:0,right:0,bottom:0,left:0,width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0,padding:0,border:0,backgroundColor:"transparent",overflow:"hidden"},dialogScrim:{boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:t.lg,backgroundColor:"rgba(0,0,0,0.4)"},dialogScrimSide:{boxSizing:"border-box",display:"flex",alignItems:"stretch",justifyContent:"flex-end",width:"100%",height:"100%",backgroundColor:"rgba(0,0,0,0.4)"},dialogPanel:{boxSizing:"border-box",width:"100%",maxWidth:560,maxHeight:"100%",overflowY:"auto",backgroundColor:r.surface,borderRadius:o.xl-1,padding:`${t.lg}px ${t.lg+t.xs+t.xs/2}px`,display:"flex",flexDirection:"column",gap:t.md,...O(e,"regular"),color:r.text.primary},dialogPanelSide:{boxSizing:"border-box",width:"min(100vw, 480px)",height:"100%",maxHeight:"100%",overflowY:"auto",backgroundColor:r.surface,padding:`${t.lg}px ${t.lg+t.xs+t.xs/2}px`,display:"flex",flexDirection:"column",gap:t.md,...O(e,"regular"),color:r.text.primary},sheetHeader:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:t.sm},sheetTitle:{...c(n.size.heading,n.lineHeight.snug,r.text.primary,"bold")},sheetHelper:c(n.size.bodyTight,n.lineHeight.normal,r.text.muted),closeGlyph:{fontSize:n.size.verdict,lineHeight:1,color:r.text.primary}}}i(Hp,"makeScreenStyles");function Ht(e,r){return e===null?"":r?`${e} ${r}`:e}i(Ht,"formatEntityValue");function Mi(e){if(e===null||e.length===0)return "";let r=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(r!==null){let n=r[1]??"",l=r[2]??"",a=r[3]??"";return `${Number(l)}/${Number(a)}/${n.slice(2)}`}let t=Date.parse(e);if(Number.isNaN(t))return e;let o=new Date(t);return `${o.getUTCMonth()+1}/${o.getUTCDate()}/${String(o.getUTCFullYear()).slice(2)}`}i(Mi,"formatShortDate");var gl=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function J(e){if(!e)return "-";let r=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(r!==null){let n=gl[Number(r[2])-1];return n===void 0?"-":`${n} ${Number(r[3])}, ${r[1]}`}let t=Date.parse(e);if(Number.isNaN(t))return "-";let o=new Date(t);return `${gl[o.getUTCMonth()]} ${o.getUTCDate()}, ${o.getUTCFullYear()}`}i(J,"formatRecordsDate");var me=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:i(e=>`Measured ${e}`,"measured"),uploadedDocument:"Uploaded document",kind:Object.freeze({visit:"Visit",vaccine:"Vaccine",weight:"Weight",medication:"Medication"}),clinicVisit:"Clinic visit",doctor:i(e=>`Dr. ${e}`,"doctor"),lot:i(e=>`Lot ${e}`,"lot"),expires:i(e=>`Expires ${e}`,"expires")});function Kr(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}}}i(Kr,"markerStatusLabel");function Vt(e,r){return r<2?null:`${e==="flat"?"Holding steady":`Trending ${e==="down"?"down":e==="up"?"up":"steady"}`} over ${r} visits`}i(Vt,"trajectoryLabel");function Qr(e){let r=e.replace(/_/g," ").trim();return r.length===0?e:r.charAt(0).toUpperCase()+r.slice(1)}i(Qr,"humanize");var bl=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 Wt(e){return Object.prototype.hasOwnProperty.call(bl,e)?bl[e]:Qr(e)}i(Wt,"bodySystemLabel");var Rl=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 Gt(e){return Object.prototype.hasOwnProperty.call(Rl,e)?Rl[e]:Qr(e)}i(Gt,"soapSectionLabel");function hl(e){return e===null||!Number.isFinite(e)?"-":`${e.toFixed(3).replace(/\.?0+$/,"")} kg`}i(hl,"formatWeightKg");function ur(e,r,t){if((e===null||!Number.isFinite(e))&&t)return t;if(e===null||!Number.isFinite(e))return "-";let o=e.toFixed(3).replace(/\.?0+$/,"");return r?`${o} ${r}`:o}i(ur,"formatMarkerReading");function $i(e,r,t){let o=Vt(r,t);return e?`${me.measured(J(e))}${o?` \xB7 ${o}`:""}`:o}i($i,"labDetailLine");var fo=Object.freeze({idle:Object.freeze({title:"Find your pet\u2019s clinic",body:"Search for the clinic that holds your pet\u2019s records. We\u2019ll request them on your behalf once you sign the authorization.",action:null}),no_requests:Object.freeze({title:"No record requests yet",body:"When you request records from a clinic, you\u2019ll be able to track every step here.",action:null}),no_records:Object.freeze({title:"Nothing to show just yet",body:"Once your pet\u2019s records arrive and our team reviews them, lab trends and visits will appear here.",action:null}),rate_limited:Object.freeze({title:"Slow down a moment",body:"You\u2019ve made a lot of requests just now. You can try again shortly.",action:"Try again"}),service_unavailable:Object.freeze({title:"Records search is temporarily down",body:"We\u2019re working on it. Please try again in a few minutes.",action:"Try again"}),error:Object.freeze({title:"Couldn\u2019t reach Everfur",body:"Check your connection and try again.",action:"Try again"})}),Ui=60;function vl(e){return `Try again in ${e}s`}i(vl,"coolingActionLabel");var Cl="Try again, available shortly";var se=Object.freeze({openA11y:"Share medical record",title:"Share medical record",helper:"Anyone with an active link can view this record until it expires. You can turn a link off anytime.",close:"Close",closeSheetA11y:"Close share sheet",viewDocument:"View document",createLink:"Create link and share",creatingLink:"Creating link...",downloadPdf:"Download PDF",preparingPdf:"Preparing PDF...",activeLinks:"Active links",loadingLinks:"Loading your share links",errorTitle:"Couldn\u2019t 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",copyLinkA11y:i(e=>`Copy share link, ${e}`,"copyLinkA11y"),turnOff:"Turn off",turnOffA11y:i(e=>`Turn off share link, ${e}`,"turnOffA11y"),turningOff:"Turning off...",keep:"Keep",confirmTurnOff:"Turn off this link? Anyone who has it will lose access.",shareMessage:i(e=>`View this medical record: ${e}`,"shareMessage"),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: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.",turnedOff:"Link turned off."})});function Vp(e,r){if(!e)return false;let t=Date.parse(e);return Number.isNaN(t)?false:t<=r}i(Vp,"isShareExpired");function Wp(e,r){let t=J(e);return t==="-"?r?"Expired":"No expiry date":r?`Expired ${t}`:`Expires ${t}`}i(Wp,"formatShareExpiry");function El(e,r,t){let o=e.map(n=>{let l=Vp(n.expiresAt,t),a=Wp(n.expiresAt,l),c=J(n.createdAt),s=l?"Expired":"Active",d=a.replace(/^Expires /,"expiring ").replace(/^Expired /,"expired ").replace(/^Expired$/,"expired").replace(/^No expiry date$/,"with no expiry date");return {shareId:n.shareId,shareUrl:r[n.shareId]??null,active:!l,statusLabel:s,expiryLabel:a,createdLabel:c==="-"?null:`Created ${c}`,a11yLabel:`Share link. ${s}. ${a}.`,actionContext:d}});return Object.freeze([...o.filter(n=>n.active),...o.filter(n=>!n.active)])}i(El,"buildShareRows");function _t(e,r){let t=e?.httpStatus;if(Jr(e)){if(r==="create")return "Records access for this pet is off, so a new link cannot be created.";if(r==="download")return "Records access for this pet is off, so the PDF cannot be downloaded."}if(t===429)return "You are creating links a little too fast. Wait a moment, then try again.";if(r==="revoke"&&(t===404||t===409||t===410))return "That link was already turned off.";if(t===401||t===403)return "You need to be signed in as this pet's owner to do that.";switch(r){case "create":return "Could not create a share link. Please try again.";case "revoke":return "Could not turn off that link. Please try again.";default:return "Could not download the record PDF. Please try again."}}i(_t,"shareErrorMessage");function fe({width:e,height:r,radius:t,style:o}){let{color:n,radius:l}=ce();return jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"block",width:e,height:r,borderRadius:t??l.xs,backgroundColor:n.skeleton,flexShrink:0,...o}})}i(fe,"SkeletonBlock");var Bi=180,Sl=44,ji=62;function Yt({testID:e}){let r=Kt(),t=i(o=>jsxRuntime.jsxs("div",{style:r.actionRow,children:[jsxRuntime.jsxs("div",{style:r.actionLeft,children:[jsxRuntime.jsx(fe,{width:18,height:18,radius:9}),jsxRuntime.jsx(fe,{width:"55%",height:14,radius:7})]}),jsxRuntime.jsx(fe,{width:18,height:18,radius:9})]},o),"action");return jsxRuntime.jsxs("div",{role:"progressbar","aria-label":lr.loading,"aria-busy":"true",style:r.dashboard,"data-testid":e,children:[jsxRuntime.jsx("div",{style:r.inset,children:jsxRuntime.jsxs("div",{style:r.summaryCard,children:[jsxRuntime.jsx(fe,{width:Bi,height:Bi,radius:Bi/2}),jsxRuntime.jsxs("div",{style:r.badges,children:[jsxRuntime.jsx(fe,{width:70,height:22,radius:11}),jsxRuntime.jsx(fe,{width:70,height:22,radius:11})]})]})}),jsxRuntime.jsx("div",{style:r.inset,children:jsxRuntime.jsx(fe,{width:150,height:16,radius:8})}),jsxRuntime.jsx("div",{style:r.carouselCard,children:jsxRuntime.jsx(fe,{width:"100%",height:300,radius:14})}),jsxRuntime.jsxs("div",{style:r.dots,children:[jsxRuntime.jsx(fe,{width:6,height:6,radius:3}),jsxRuntime.jsx(fe,{width:18,height:6,radius:3}),jsxRuntime.jsx(fe,{width:6,height:6,radius:3})]}),jsxRuntime.jsx("div",{style:r.centered,children:jsxRuntime.jsx(fe,{width:46,height:12,radius:6})}),jsxRuntime.jsx("div",{style:r.inset,children:jsxRuntime.jsx(fe,{width:"100%",height:Sl,radius:12})}),jsxRuntime.jsxs("div",{style:{...r.inset,...r.actions},children:[t("a"),t("b")]})]})}i(Yt,"DashboardSkeleton");function yo({testID:e}){let r=Kt();return jsxRuntime.jsxs("div",{role:"progressbar","aria-label":ue.loading,"aria-busy":"true",style:r.request,"data-testid":e,children:[jsxRuntime.jsx("div",{children:[0,1,2,3].map(t=>jsxRuntime.jsxs("div",{style:r.railRow,children:[jsxRuntime.jsxs("div",{style:r.railColumn,children:[jsxRuntime.jsx(fe,{width:24,height:24,radius:12}),t<3?jsxRuntime.jsx(fe,{width:2,height:20,radius:1}):null]}),jsxRuntime.jsxs("div",{style:r.railBody,children:[jsxRuntime.jsx(fe,{width:"55%",height:14,radius:7}),jsxRuntime.jsx(fe,{width:"75%",height:11,radius:6})]})]},t))}),jsxRuntime.jsxs("div",{style:r.statusCard,children:[jsxRuntime.jsx(fe,{width:"90%",height:13,radius:6}),jsxRuntime.jsx(fe,{width:"60%",height:13,radius:6})]}),jsxRuntime.jsx(fe,{width:"100%",height:50,radius:25})]})}i(yo,"RequestSkeleton");function wl({testID:e}){let r=Kt();return jsxRuntime.jsxs("div",{role:"progressbar","aria-label":me.loadingTimeline,"aria-busy":"true",style:r.timeline,"data-testid":e,children:[jsxRuntime.jsx("div",{style:r.timelineDisclaimer,children:jsxRuntime.jsx(fe,{width:"100%",height:Sl,radius:12})}),Array.from({length:6},(t,o)=>jsxRuntime.jsxs("div",{children:[o>0?jsxRuntime.jsx("div",{style:r.timelineSeparator}):null,jsxRuntime.jsxs("div",{style:r.timelineRow,children:[jsxRuntime.jsx(fe,{width:34,height:34,radius:17}),jsxRuntime.jsxs("div",{style:r.timelineBody,children:[jsxRuntime.jsxs("div",{style:r.timelineTop,children:[jsxRuntime.jsx(fe,{width:44,height:10,radius:5}),jsxRuntime.jsx(fe,{width:56,height:12,radius:6})]}),jsxRuntime.jsx(fe,{width:"70%",height:14,radius:7}),o%2===0?jsxRuntime.jsx(fe,{width:"45%",height:12,radius:6}):null]})]})]},o))]})}i(wl,"TimelineSkeleton");function kl({testID:e}){let r=Kt();return jsxRuntime.jsx("div",{role:"progressbar","aria-label":xe.loading,"aria-busy":"true",style:r.clinics,"data-testid":e,children:Array.from({length:5},(t,o)=>jsxRuntime.jsxs("div",{style:r.clinicRow,children:[jsxRuntime.jsx(fe,{width:"65%",height:14,radius:7}),jsxRuntime.jsx(fe,{width:"40%",height:11,radius:6})]},o))})}i(kl,"ClinicsSkeleton");function _l({testID:e}){let r=Kt();return jsxRuntime.jsx("div",{role:"progressbar","aria-label":se.loadingLinks,"aria-busy":"true",style:r.shares,"data-testid":e,children:[0,1].map(t=>jsxRuntime.jsxs("div",{style:r.shareRow,children:[jsxRuntime.jsx(fe,{width:"55%",height:13}),jsxRuntime.jsx(fe,{width:"40%",height:11})]},t))})}i(_l,"SharesSkeleton");function Fe({variant:e,onAction:r,message:t,testID:o}){let n=Kt(),l=fo[e],[a,c]=react.useState(e==="rate_limited"?Ui:0);react.useEffect(()=>{e==="rate_limited"&&c(Ui);},[e]),react.useEffect(()=>{if(a<=0)return;let u=setTimeout(()=>c(p=>Math.max(0,p-1)),1e3);return ()=>clearTimeout(u)},[a]);let s=e==="rate_limited"&&a>0,d=s?vl(a):l.action;return jsxRuntime.jsxs("section",{role:"status",style:n.empty,"data-testid":o,children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:n.emptyGlyph}),jsxRuntime.jsx("h3",{style:n.emptyTitle,children:l.title}),jsxRuntime.jsx("p",{style:n.emptyBody,children:t??l.body}),d!==null&&r?jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:s,"aria-label":s?Cl:d,style:{...n.emptyAction,...s?n.emptyActionDisabled:{}},"data-testid":o?`${o}-action`:`records-empty-${e}-action`,children:d}):null]})}i(Fe,"RecordsEmptyState");function Kt(){let e=ce();return react.useMemo(()=>Kp(e),[e])}i(Kt,"useStyles");function Kp(e){let{color:r,space:t,radius:o,type:n}=e,l=`1px solid ${r.brandBorder}`;return {dashboard:{display:"flex",flexDirection:"column",gap:t.lg,padding:`${t.xs}px ${t.sm}px 0`,backgroundColor:r.background},inset:{padding:`0 ${t.sm}px`},summaryCard:{display:"flex",flexDirection:"column",alignItems:"center",gap:t.md+t.xs/2,borderRadius:o.lg-t.xs,border:l,backgroundColor:r.surface,padding:`${t.lg+t.xs}px ${t.lg}px`},badges:{display:"flex",gap:t.md},carouselCard:{borderRadius:o.lg-t.xs,border:l,backgroundColor:r.surface,padding:t.lg},dots:{display:"flex",alignItems:"center",justifyContent:"center",gap:t.xs+t.xs/2},centered:{display:"flex",justifyContent:"center"},actions:{display:"flex",flexDirection:"column",gap:t.sm+t.xs/2},actionRow:{display:"flex",alignItems:"center",justifyContent:"space-between",borderRadius:o.md,border:l,backgroundColor:r.surface,padding:t.lg},actionLeft:{flex:1,display:"flex",alignItems:"center",gap:t.md},request:{display:"flex",flexDirection:"column",gap:t.lg+t.xs/2,padding:`${t.xs}px ${t.lg}px 0`},railRow:{display:"flex",alignItems:"flex-start",gap:t.md},railColumn:{display:"flex",flexDirection:"column",alignItems:"center",gap:t.xs/2,width:24},railBody:{flex:1,display:"flex",flexDirection:"column",gap:t.xs+t.xs/2,paddingBottom:t.lg+t.xs/2},statusCard:{display:"flex",flexDirection:"column",gap:t.sm,borderRadius:o.md,backgroundColor:r.brandSoft,padding:t.md+t.xs/2},timeline:{backgroundColor:r.background},timelineDisclaimer:{padding:`${t.xs}px ${t.lg}px ${t.md}px`},timelineRow:{display:"flex",gap:t.md,padding:`${t.md+t.xs/2}px ${t.lg}px`},timelineBody:{flex:1,display:"flex",flexDirection:"column",gap:t.xs-1},timelineTop:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:t.sm},timelineSeparator:{height:1,backgroundColor:r.brandBorder,marginLeft:ji},clinics:{display:"flex",flexDirection:"column",gap:t.md},clinicRow:{display:"flex",flexDirection:"column",gap:t.sm,borderRadius:o.lg-t.xs/2,border:l,backgroundColor:r.surface,padding:`${t.md+t.xs/2}px`},shares:{display:"flex",flexDirection:"column",gap:t.md,padding:t.md,borderRadius:o.md,backgroundColor:r.surfaceCream,border:l},shareRow:{display:"flex",flexDirection:"column",gap:t.xs+t.xs/2},empty:{display:"flex",flexDirection:"column",alignItems:"center",gap:t.sm+t.xs/2,padding:`${t.xxl}px ${t.xl}px`,textAlign:"center"},emptyGlyph:{boxSizing:"border-box",width:22,height:22,borderRadius:11,backgroundColor:r.brandSoft,border:l,marginBottom:t.xs},emptyTitle:{margin:0,...O(e,"bold"),fontSize:n.size.subtitle,lineHeight:`${Math.round(n.size.subtitle*n.lineHeight.snug)-1}px`,color:r.brand},emptyBody:{margin:0,...O(e,"regular"),fontSize:n.size.bodyTight,lineHeight:`${Math.round(n.size.bodyTight*n.lineHeight.normal)}px`,color:r.text.muted,maxWidth:320},emptyAction:{boxSizing:"border-box",marginTop:t.sm,minHeight:40,borderRadius:o.pill,padding:`0 ${t.lg+t.xs/2}px`,backgroundColor:r.brand,color:r.onPrimary,border:0,cursor:"pointer",...O(e,"bold"),fontSize:n.size.bodyTight},emptyActionDisabled:{opacity:.5,cursor:"default"}}}i(Kp,"makeStyles");var Jp=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function En(e){let{userRef:r,scopeEpoch:t}=ee();return jsxRuntime.jsx(Te,{capability:"recordsClinic",style:e.style,className:e.className,...Oe(e.onBack,Le),children:r===null?jsxRuntime.jsx("p",{role:"alert",children:G.sessionRequired}):jsxRuntime.jsx(Zp,{..._e(e,["onNavigate","onBack"])},JSON.stringify([r,t,e.petRef]))})}i(En,"EverfurClinicPicker");function Zp({petRef:e,controller:r,recordsController:t,location:o,onNavigate:n,onBack:l,style:a,className:c}){let{theme:s,styles:d}=j(),u=Ir(),p=el(r??u,o),m=We(t?{petRef:e,controller:t}:{petRef:e}),y=react.useRef(Zr()),[g,f]=react.useState(false),[R,b]=react.useState(null),[E,h]=react.useState(false),[v,S]=react.useState(""),[C,k]=react.useState(false),[_,T]=react.useState(""),[I,F]=react.useState(false),q=react.useCallback(D=>{n?.({name:"consent",clinic:Ni(D,null,"",y.current())});},[n]),M=i(()=>{g||(f(true),b(null),m.createRequest(`records-upload-${Date.now().toString(36)}`).then(D=>{if(f(false),!D.ok){b(ue.errors.start);return}n?.({name:"request",requestId:D.value.id});}));},"startUpload"),$=C?v:p.query,V=Jp.test(_.trim()),re=$.trim().length>0&&V,Q=p.isSearchActive?p.clinics:p.recent,w=p.isSearchActive?p.error?Xe(p.error):!p.initialLoading&&p.clinics.length===0?"idle":null:p.recent.length>0||p.recentLoading?null:"idle",x={display:"flex",flexDirection:"column",gap:s.space.sm},A=i(D=>{let W=D.currentTarget;W.scrollTop+W.clientHeight>=W.scrollHeight-W.clientHeight*.6&&p.loadMore();},"onScroll");return jsxRuntime.jsxs("div",{className:c,style:{...d.root,...a},"data-testid":"records-clinic-picker",children:[jsxRuntime.jsx(He,{title:xe.title,onBack:l,testID:"records-clinic-header"}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:s.space.sm,margin:`0 ${s.space.lg}px ${s.space.sm}px`,padding:`0 ${s.space.md+s.space.xs/2}px`,height:44,borderRadius:22,backgroundColor:s.color.surfaceSubtle,border:`1px solid ${s.color.borderHairlineGreen}`},children:[jsxRuntime.jsx("input",{type:"search",value:p.query,onChange:D=>p.setQuery(D.target.value),placeholder:xe.placeholder,maxLength:200,"aria-label":xe.searchA11y,autoComplete:"off",style:{flex:1,border:0,background:"transparent",font:"inherit",fontSize:s.type.size.body,color:s.color.text.primary,outline:"none"},"data-testid":"records-clinic-search-input"}),p.query.length>0?jsxRuntime.jsx("button",{type:"button",onClick:()=>p.setQuery(""),"aria-label":xe.clearSearch,style:{...d.iconButton,width:32,height:32},"data-testid":"records-clinic-search-clear",children:jsxRuntime.jsx("span",{"aria-hidden":"true",style:d.closeGlyph,children:"\xD7"})}):null]}),n?jsxRuntime.jsxs("div",{style:{...x,padding:`0 ${s.space.lg}px ${s.space.md}px`},children:[R?jsxRuntime.jsx("p",{role:"alert",style:d.errorBanner,children:R}):null,jsxRuntime.jsx(B,{label:g?xe.uploadOwnStarting:xe.uploadOwn,kind:"outline",ariaLabel:xe.uploadOwnA11y,busy:g,onClick:M,testID:"records-clinic-upload-own"})]}):null,jsxRuntime.jsxs("div",{style:{...d.body,...d.content,gap:s.space.md},onScroll:p.isSearchActive?A:void 0,"data-testid":"records-clinic-results",children:[p.isSearchActive?jsxRuntime.jsxs("section",{style:{...d.creamCard,borderStyle:"dashed",padding:`${s.space.md}px ${s.space.md+s.space.xs/2}px`},"data-testid":"records-clinic-fallback-card",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>h(D=>!D),"aria-expanded":E,"aria-label":E?xe.fallback.collapseA11y:xe.fallback.expandA11y,style:{display:"flex",alignItems:"center",gap:s.space.md,width:"100%",minHeight:44,background:"transparent",border:0,padding:0,cursor:"pointer",textAlign:"left",font:"inherit",color:"inherit"},"data-testid":"records-clinic-fallback",children:[jsxRuntime.jsxs("span",{style:{flex:1,display:"flex",flexDirection:"column",gap:s.space.xs/2},children:[jsxRuntime.jsx("span",{style:{...d.rowTitle,...O(s,"bold")},children:xe.fallback.title}),jsxRuntime.jsx("span",{style:d.muted,children:xe.fallback.subtitle})]}),jsxRuntime.jsx(kt,{direction:E?"up":"down"})]}),E?jsxRuntime.jsxs("div",{style:x,children:[jsxRuntime.jsx("label",{htmlFor:"records-clinic-fallback-name",style:d.fieldLabel,children:xe.fallback.nameLabel}),jsxRuntime.jsx("input",{id:"records-clinic-fallback-name",style:d.field,value:$,onChange:D=>{S(D.target.value),k(true);},placeholder:xe.fallback.namePlaceholder,maxLength:200,autoComplete:"off","data-testid":"records-clinic-fallback-name"}),jsxRuntime.jsx("label",{htmlFor:"records-clinic-fallback-email",style:d.fieldLabel,children:xe.fallback.emailLabel}),jsxRuntime.jsx("input",{id:"records-clinic-fallback-email",type:"email",style:d.field,value:_,onChange:D=>{T(D.target.value),F(false);},onBlur:()=>F(true),placeholder:xe.fallback.emailPlaceholder,maxLength:320,autoComplete:"off","data-testid":"records-clinic-fallback-email"}),I&&_.trim().length>0&&!V?jsxRuntime.jsx("p",{role:"alert",style:d.errorText,children:ue.errors.invalidEmail}):null,jsxRuntime.jsx("p",{style:d.muted,children:xe.fallback.reviewNote}),jsxRuntime.jsx(B,{label:xe.fallback.submit,ariaLabel:xe.fallback.submitA11y,disabled:!re||!n,onClick:()=>n?.({name:"consent",clinic:Ni(null,$.trim(),_.trim().toLowerCase(),y.current())}),testID:"records-clinic-fallback-submit"})]}):null]}):p.recent.length>0?jsxRuntime.jsx("h3",{style:{...d.fieldLabel,...O(s,"bold"),textTransform:"uppercase",marginBottom:0},"data-testid":"records-clinic-recent-label",children:xe.recentlyUsed}):null,p.isSearchActive&&p.initialLoading?jsxRuntime.jsx(kl,{testID:"records-clinic-page-loading"}):null,jsxRuntime.jsx("ul",{style:{...d.plainList,gap:s.space.md},children:Q.map(D=>{let W=Vs(D.emailStatus),de=Ws(D.distanceKm),Ae=[D.name,D.address,D.phone?`phone ${D.phone}`:null,de?Gs(D.distanceKm):null,W.a11y].filter(Boolean).join(", "),oe=W.tone==="positive"?{backgroundColor:s.color.badgeBgPositive,color:s.color.success}:W.tone==="caution"?{backgroundColor:s.color.badgeBgCaution,color:s.color.cautionAccent}:{backgroundColor:s.color.badgeBgNeutral,color:s.color.text.muted};return jsxRuntime.jsx("li",{children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>q(D),"aria-label":xe.selectA11y(Ae),style:{...d.creamCard,backgroundColor:s.color.surface,width:"100%",textAlign:"left",cursor:"pointer",gap:s.space.sm,padding:`${s.space.md}px ${s.space.md+s.space.xs/2}px`,font:"inherit",color:"inherit"},"data-testid":`records-clinic-${D.id}`,children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:s.space.sm},children:[jsxRuntime.jsx("span",{style:{...d.rowTitle,...O(s,"bold"),color:s.color.brand},children:D.name}),de?jsxRuntime.jsx("span",{"aria-hidden":"true",style:{...d.muted,...d.mono},children:de}):null]}),D.address?jsxRuntime.jsx("span",{style:d.rowDetail,children:D.address}):null,D.phone?jsxRuntime.jsx("span",{"aria-hidden":"true",style:d.rowMuted,children:D.phone}):null,jsxRuntime.jsx("span",{"aria-hidden":"true",style:{...d.chip,...oe,...O(s,"bold"),fontSize:s.type.size.micro,alignSelf:"flex-start"},children:W.label})]})},D.id)})}),w&&!p.initialLoading?jsxRuntime.jsx(Fe,{variant:w,message:p.isSearchActive&&w==="idle"?xe.noMatch(p.debouncedQuery):p.error?.displayMessage,onAction:p.error?.retryable===true?p.retry:void 0,testID:"records-clinic-empty"}):null,jsxRuntime.jsxs("div",{style:x,children:[p.loadingMore?jsxRuntime.jsx("p",{role:"status",style:{...d.muted,textAlign:"center"},"data-testid":"records-clinic-loading-more",children:xe.loadingMore}):null,p.pageError?jsxRuntime.jsx("button",{type:"button",onClick:p.loadMore,"aria-label":xe.loadMoreRetryA11y,style:{...d.pill,...d.pillLink},"data-testid":"records-clinic-page-error-retry",children:xe.loadMoreFailed}):null]})]}),jsxRuntime.jsx(De,{})]})}i(Zp,"PickerBody");var ze=Object.freeze({title:"Request records",resultTitle:"Request status",addClinic:"Add a clinic",atCap:`Up to ${Bt} clinics`,sendA11y:i(e=>e===1?"Send 1 records request":`Send ${e} records requests`,"sendA11y"),send:i(e=>`Send ${e} ${e===1?"request":"requests"}`,"send"),sending:"Sending\u2026",addToContinue:"Add a clinic to continue",tryAgain:"Try again",remove:i(e=>`Remove ${e}`,"remove"),emailToAdd:"Email to add",perClinic:"Per-clinic result",sent:"Sent",notSent:"Not sent",allFailed:"We couldn\u2019t send any of these requests. See the details below and try again.",partial:i((e,r,t)=>`${e} of ${r} requests sent. ${t} couldn\u2019t be sent.`,"partial"),allSent:i(e=>`${e} ${e===1?"request":"requests"} sent.`,"allSent"),responded:i((e,r)=>`${e} of ${r} ${r===1?"clinic":"clinics"} responded`,"responded")});function xn(e,r,t,o){let n={owner_name:r,pet_name:t,clinic_name:o},l=false,a=e.scopeTemplate.replace(/\{([^{}]+)\}/g,(c,s)=>Object.prototype.hasOwnProperty.call(n,s)?n[s]??"":(l=true,""));return l||/[{}]/.test(a)?null:a}i(xn,"renderClinicScope");function Sn(e){return e===null||e.emailStatus!=="verified"&&e.emailStatus!=="unverified"}i(Sn,"clinicNeedsEmail");function Pl(e,r,t){let[o,n]=react.useState(e.ownerName),[l,a]=react.useState(""),[c,s]=react.useState(null),[d,u]=react.useState(""),[p,m]=react.useState([]),[y,g]=react.useState([]),[f,R]=react.useState(null),[b,E]=react.useState(null),[h,v]=react.useState(false),[S,C]=react.useState(false),[k,_]=react.useState(null),[T,I]=react.useState(0),F=react.useRef(false),q=react.useRef(false),M=react.useRef(0),$=react.useRef(Zr()),V=react.useRef(null),re=react.useRef(null),Q=react.useRef(0);react.useEffect(()=>(F.current=true,q.current=false,v(false),()=>{F.current=false,Q.current+=1,M.current+=1,V.current=null,re.current?.abort();}),[r]),react.useEffect(()=>{let oe=true;return R(null),V.current=null,r.getAuthorizationCopy().then(ve=>{oe&&(ve.ok?(R(ve.value),E(null)):E(ve.error));}).catch(()=>{oe&&E(z("internalError"));}),()=>{oe=false;}},[r,T]),react.useEffect(()=>{let oe=true;return g([]),r.recentClinics({limit:5}).then(ve=>{oe&&ve.ok&&g(ve.value.clinics);}).catch(()=>{}),()=>{oe=false;}},[r]);let w=i(()=>{V.current=null,E(null);},"invalidate"),x=c?.name??l.trim(),A=f?xn(f,o.trim(),e.petName,x):null,D=Sn(c),W=!!(f&&A&&o.trim()&&e.petName.trim()&&x&&(!D||/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(d.trim()))&&t),de=i(async()=>{if(q.current)return;let oe=++M.current;C(true);try{let ve=await r.searchClinics({query:l.trim(),limit:100});if(!F.current||oe!==M.current)return;ve.ok?(m(ve.value.clinics),E(null)):E(ve.error);}catch{F.current&&oe===M.current&&E(z("internalError"));}finally{F.current&&oe===M.current&&C(false);}},"search"),Ae=i(async()=>{if(q.current||k||!W||!f||!A||!t)return;q.current=true;let oe=Q.current,ve=i(()=>F.current&&Q.current===oe,"current");v(true),E(null);try{if(!V.current){re.current=new AbortController;let Qe=await t({petRef:e.petRef,petName:e.petName,ownerName:o.trim(),clinicName:x,authorizationVersion:f.authorizationVersion,scopeText:A,signal:re.current.signal});if(!ve()||Qe===null)return;let _r=c&&(!D||c.emailStatus==="none")?{clinicId:c.id}:{clinicFreeText:x};V.current={petRef:e.petRef,ownerName:o.trim(),authorizationVersion:f.authorizationVersion,..._r,...D?{clinicEmail:d.trim().toLowerCase()}:{},...Qe.signatureId!==void 0?{signatureId:Qe.signatureId}:{signaturePngBase64:Qe.signaturePngBase64},idempotencyKey:$.current()};}if(!ve())return;let ar=await r.createClinicRequest(V.current);if(!ve())return;if(!ar.ok){E(ar.error);return}if(ar.value.petRef!==e.petRef){E(z("internalError"));return}_(ar.value),V.current=null,e.onCreated?.(ar.value);}catch{ve()&&E(z("internalError"));}finally{q.current=false,ve()&&v(false);}},"submit");return {ownerName:o,query:l,clinic:c,email:d,clinics:p,copy:f,scope:A,error:b,busy:h,searching:S,created:k,ready:W,needsEmail:D,recent:p.length===0&&c===null?y:[],setOwnerName(oe){q.current||(w(),n(oe));},setQuery(oe){q.current||(w(),M.current+=1,C(false),m([]),s(null),u(""),a(oe));},setEmail(oe){q.current||(w(),u(oe));},selectClinic(oe){q.current||(w(),M.current+=1,C(false),m([]),s(oe),a(oe.name),u(""));},invalidate:w,search:de,submit:Ae,retryCopy(){E(null),I(oe=>oe+1);}}}i(Pl,"useClinicRequestForm");var em=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function Xt(e){return e.clinic?.name??e.freeText??""}i(Xt,"draftName");function Qt(e){return Sn(e.clinic)}i(Qt,"draftNeedsEmail");function Tl(e,r,t,o,n){let[l,a]=react.useState(e.ownerName),[c,s]=react.useState(""),[d,u]=react.useState([]),[p,m]=react.useState([]),[y,g]=react.useState([]),[f,R]=react.useState(null),[b,E]=react.useState(null),[h,v]=react.useState(false),[S,C]=react.useState(false),[k,_]=react.useState(null),[T,I]=react.useState(null),[F,q]=react.useState(0),M=react.useRef(false),$=react.useRef(false),V=react.useRef(0),re=react.useRef(0),Q=react.useRef(Zr()),w=react.useRef(null),x=react.useRef(null);react.useEffect(()=>(M.current=true,$.current=false,v(false),()=>{M.current=false,re.current+=1,V.current+=1,w.current=null,x.current?.abort();}),[r,t]),react.useEffect(()=>{let U=true;return R(null),w.current=null,r.getAuthorizationCopy().then(Re=>{U&&(Re.ok?(R(Re.value),E(null)):E(Re.error));}).catch(()=>{U&&E(z("internalError"));}),()=>{U=false;}},[r,F]),react.useEffect(()=>{let U=true;return m([]),r.recentClinics({limit:5}).then(Re=>{U&&Re.ok&&m(Re.value.clinics);}).catch(()=>{}),()=>{U=false;}},[r]);let A=i(()=>{w.current=null,E(null);},"invalidate"),D=y.map(Xt),W=f?D.map(U=>xn(f,l.trim(),e.petName,U)):[],de=W.every(U=>U!==null)?W.join(`
1
+ 'use strict';var react=require('react'),zod=require('zod'),jsxRuntime=require('react/jsx-runtime');var du=Object.defineProperty;var i=(e,r)=>du(e,"name",{value:r,configurable:true});var di=Object.freeze([Object.freeze({wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false}),Object.freeze({wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true}),Object.freeze({wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true}),Object.freeze({wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true}),Object.freeze({wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false}),Object.freeze({wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false}),Object.freeze({wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false}),Object.freeze({wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false}),Object.freeze({wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false}),Object.freeze({wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true}),Object.freeze({wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false}),Object.freeze({wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false}),Object.freeze({wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false}),Object.freeze({wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false}),Object.freeze({wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false}),Object.freeze({wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false}),Object.freeze({wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false}),Object.freeze({wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true}),Object.freeze({wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true}),Object.freeze({wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true}),Object.freeze({wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false}),Object.freeze({wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false})]);Object.freeze(di.map(e=>e.wireCode));var cu=Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict"}),is=Object.freeze(di.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:cu[e.wireCode]}))),uu=new Map(is.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),pu=Object.freeze(["http_envelope",...[...new Set(is.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function oo(e,r){if(typeof e!="string")return;let t=e.trim().toUpperCase();if(t.length!==0)for(let o of [r??"http_envelope",...pu]){let n=uu.get(o+t);if(n)return n}}i(oo,"contractErrorFor");function mu(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(mu,"contractDocUrl");function as(e){return null}i(as,"publishedDocUrl");var fu=Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function ss(e){return fu[e]}i(ss,"categoryFor");function ls(e){let r=oo(e);if(r)return r.normalized;let t=(e??"").trim().toUpperCase(),o=t.replace(/[^A-Z0-9]/g,"");if(o==="AUTHREJECTED")return "authRejected";if(t.startsWith("AUTH"))return "authExpired";switch(o){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":case "TELEVETRATELIMITED":return "rateLimited";case "IDEMPOTENCYKEYCONFLICT":case "IDEMPOTENCYCONFLICT":return "idempotencyConflict";case "ACCESSDENIED":case "FORBIDDEN":return "accessDenied";case "NOTFOUND":case "CONVERSATIONNOTFOUND":return "conversationNotFound";case "PETNOTFOUND":return "petNotFound";case "TIMEOUT":case "STREAMTIMEOUT":return "streamTimeout";case "MEDIAUPLOADFAILED":case "UNRECOGNIZEDVIDEOFORMAT":case "FILETOOSMALL":return "mediaUploadFailed";case "MODERATIONBLOCKED":return "moderationBlocked";case "UPSTREAMLLMTIMEOUT":return "upstreamLlmTimeout";case "INTERNALERROR":case "INTERNALSERVERERROR":return "internalError";case "STREAMINCOMPLETE":case "CHATSTREAMINCOMPLETE":return "streamIncomplete";case "INVALIDANALYSISTYPE":case "INVALIDUPLOADPURPOSE":return "unknown";default:return "unknown"}}i(ls,"fromWire");var yu=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function ci(e){return yu.has(e)}i(ci,"isAutoRetryable");var gu=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function ds(e){return ci(e)||gu.has(e)}i(ds,"isRetryableCode");var bu=500,ui=8e3,cs=4;function us(e,r=Math.random){let t=Math.max(0,e),o=Math.min(bu*2**t,ui);return Math.floor(r()*o)}i(us,"backoffDelayMs");var hu=Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:"This feature isn't available on your account right now.",paymentRequired:"This is part of a paid plan.",quotaExceeded:"You have used today's messages. This resets tomorrow.",rateLimited:"You are sending messages quickly. Try again in a few seconds.",validationFailed:"Something in that request was not right. Check the details and try again.",sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",unknown:"Something went wrong. Please try again."});function pi(e){return hu[e]}i(pi,"userFacingError");function ps(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:false,writable:false,configurable:false});}i(ps,"defineHidden");var Ru=/^[a-z][a-z0-9_]{0,63}$/;function H(e,r){let t=oo(r?.wireCode,r?.wireEnvelope),o={code:e,category:ss(e),retryable:r?.retryable??ds(e),displayMessage:pi(e)};if(r?.httpStatus!==void 0&&(o.httpStatus=r.httpStatus),r?.requestId&&(o.requestId=r.requestId),typeof r?.reasonCode=="string"&&Ru.test(r.reasonCode)&&(o.reasonCode=r.reasonCode),t);return r?.wireMessage&&ps(o,"wireMessage",r.wireMessage),r?.raw!==void 0&&r.raw!==null&&ps(o,"raw",r.raw),Object.freeze(o)}i(H,"makeEverfurError");function Te(e,r){return Object.freeze(r===void 0?{ok:true,value:e}:{ok:true,value:e,warning:r})}i(Te,"ok");function J(e){return Object.freeze({ok:false,error:e})}i(J,"err");var io=class io extends Error{constructor(r,t){super(t),this.name="EverfurConfigError",this.kind=r,Object.setPrototypeOf(this,io.prototype);}};i(io,"EverfurConfigError");var Sn=io;var Kt=Object.freeze(["vet","groomer","boarding"]),vu=zod.z.string().min(1).refine(e=>e.startsWith("https://")),Yt=zod.z.string().nullish(),mi=zod.z.unknown().optional(),Cu=zod.z.object({share_id:zod.z.string().min(1),share_url:zod.z.string().min(1),expires_at:Yt,audience:mi}),Eu=zod.z.object({shares:zod.z.array(zod.z.object({share_id:zod.z.string().min(1),expires_at:Yt,created_at:Yt,view_count:zod.z.number().int().nonnegative().nullish(),last_viewed_at:Yt,audience:mi})).optional()}),Su=zod.z.object({download_url:vu,expires_at:Yt}),xu=zod.z.object({share_id:zod.z.string().min(1),expires_at:Yt,audience:mi}),wu=zod.z.object({audience:zod.z.string().min(1),sections:zod.z.array(zod.z.string()),entity_types:zod.z.array(zod.z.string()).nullable()}),fi=254;function ao(e){let r=e.trim();return r.length>0&&r.length<=fi&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(r)}i(ao,"isShareRecipientEmail");var ms=i(e=>typeof e=="string"&&Kt.includes(e),"isAudience");function yi(e){return ms(e)?e:null}i(yi,"audienceOf");function fs(e){let r=zod.z.array(wu).safeParse(e);if(!r.success)return Object.freeze([]);let t=new Set,o=[];for(let n of r.data)!ms(n.audience)||t.has(n.audience)||(t.add(n.audience),o.push(Object.freeze({audience:n.audience,sections:Object.freeze([...n.sections]),entityTypes:n.entity_types===null?null:Object.freeze([...n.entity_types])})));return Object.freeze(o)}i(fs,"mapShareAudiences");function ku(e,r){let t=e.trim();if(t.length===0)return null;try{let o=/^[a-z][a-z0-9+.-]*:/i.test(t)?new URL(t):r!==void 0?new URL(t,r):null;return o===null||o.protocol!=="https:"?null:o.toString()}catch{return null}}i(ku,"resolveShareUrl");function ys(e,r){let t=Cu.safeParse(e);if(!t.success)return null;let o=ku(t.data.share_url,r);return o===null?null:Object.freeze({shareId:t.data.share_id,shareUrl:o,expiresAt:t.data.expires_at??null,audience:yi(t.data.audience)})}i(ys,"mapRecordShareLink");function gs(e){let r=Eu.safeParse(e);return r.success?Object.freeze((r.data.shares??[]).map(t=>Object.freeze({shareId:t.share_id,expiresAt:t.expires_at??null,createdAt:t.created_at??null,viewCount:t.view_count??0,lastViewedAt:t.last_viewed_at??null,audience:yi(t.audience)}))):null}i(gs,"mapRecordShareList");function bs(e){let r=xu.safeParse(e);return r.success?Object.freeze({shareId:r.data.share_id,expiresAt:r.data.expires_at??null,audience:yi(r.data.audience)}):null}i(bs,"mapRecordShareEmailReceipt");function hs(e){let r=Su.safeParse(e);return r.success?Object.freeze({downloadUrl:r.data.download_url,expiresAt:r.data.expires_at??null}):null}i(hs,"mapRecordPdfLink");var gi="application/pdf",Xt=Object.freeze(["image/jpeg","image/png","image/heic","image/heif"]),kr=Object.freeze({features:Object.freeze({}),uploadContentTypes:Object.freeze([gi]),shareAudiences:Object.freeze([])}),_u=zod.z.object({features:zod.z.record(zod.z.boolean()),upload_content_types:zod.z.array(zod.z.string()).nullish(),share_audiences:zod.z.unknown().optional()}),vs=i(e=>Xt.includes(e),"isPhotoType");function so(e){let r=_u.safeParse(e);if(!r.success)return kr;let t=r.data.upload_content_types??[],o=Xt.filter(n=>t.includes(n));return Object.freeze({features:Object.freeze({...r.data.features}),uploadContentTypes:Object.freeze([gi,...o]),shareAudiences:fs(r.data.share_audiences)})}i(so,"mapRecordsFeatures");function xn(e){return e!==void 0&&e.some(vs)}i(xn,"acceptsPhotos");function Gr(e,r){return e===gi||r!==void 0&&vs(e)&&r.includes(e)}i(Gr,"isAcceptedUploadType");var Rs=Object.freeze({"application/pdf":"document.pdf","image/jpeg":"document.jpg","image/png":"document.png","image/heic":"document.heic","image/heif":"document.heif"});function Cs(e){return Gr(e,Xt)?Rs[e]:Rs["application/pdf"]}i(Cs,"recordsUploadFilename");var ks=new Set(["requested","awaiting_clinic","awaiting_upload","received","parsing","in_review","published","failed","revoked"]),Es=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 Pu(e){let r=Object.prototype.hasOwnProperty.call(Es,e)?Es[e]:void 0;if(r!==void 0)return r;let t=e;return ks.has(t)?t:"parsing"}i(Pu,"normalizeStatus");function _s(e){return e==="owner_reported"||e==="clinic_document"?e:null}i(_s,"normalizeOrigin");var Tu=zod.z.object({request_id:zod.z.string().min(1),pet_ref:zod.z.string().min(1),status:zod.z.string(),simple_status:zod.z.string().nullish(),simple_status_detail:zod.z.string().nullish(),status_label:zod.z.string().optional(),dispatch_status:zod.z.string().nullish(),can_retry_send:zod.z.boolean().optional(),can_revoke:zod.z.boolean().optional(),can_convert_to_upload:zod.z.boolean().optional(),can_update_clinic_email:zod.z.boolean().optional(),reminder_count:zod.z.number().int().nonnegative().optional(),last_reminder_at:zod.z.string().nullish(),waiting_expectation:zod.z.string().nullish(),document_count:zod.z.number().optional(),held_item_count:zod.z.number().optional(),received_at:zod.z.string().nullish(),parsing_started_at:zod.z.string().nullish(),review_started_at:zod.z.string().nullish(),created_at:zod.z.string().optional(),updated_at:zod.z.string().optional(),source:zod.z.string().nullish().catch(null),action_needed_label:zod.z.string().nullish().catch(null),failure_reason:zod.z.string().nullish().catch(null),failure_code:zod.z.string().nullish().catch(null),recovery_stage:zod.z.string().nullish().catch(null),show_clinic_phone:zod.z.boolean().optional().catch(void 0),clinic_name:zod.z.string().nullish().catch(null),clinic_email:zod.z.string().nullish().catch(null),clinic_phone:zod.z.string().nullish().catch(null),converted_to_upload_at:zod.z.string().nullish().catch(null),request_group_id:zod.z.string().nullish().catch(null)}).passthrough();function gt(e){let r=Tu.safeParse(e);if(!r.success)return null;let t=r.data,o=Iu(t.simple_status),n=o==="requested"&&(t.status==="awaiting_upload"||t.simple_status_detail==="awaiting_owner_upload")?"awaiting_upload":o==="parsing"&&(t.simple_status_detail==="in_review"||t.simple_status_detail==="review_email_failed")?"in_review":o??Pu(t.status);return Object.freeze({id:t.request_id,petRef:t.pet_ref,status:n,simpleStatus:o,simpleStatusDetail:t.simple_status_detail??null,statusLabel:t.status_label??"",dispatchStatus:t.dispatch_status??null,canRetrySend:t.can_retry_send===true,canRevoke:t.can_revoke===true,canConvertToUpload:t.can_convert_to_upload===true,canUpdateClinicEmail:t.can_update_clinic_email===true,reminderCount:t.reminder_count??0,lastReminderAt:t.last_reminder_at??null,waitingExpectation:t.waiting_expectation??null,documentCount:xs(t.document_count,0),heldItemCount:xs(t.held_item_count,0),receivedAt:t.received_at??null,parsingStartedAt:t.parsing_started_at??null,reviewStartedAt:t.review_started_at??null,createdAt:t.created_at??"",updatedAt:t.updated_at??"",wireStatus:t.status,source:t.source??null,actionNeededLabel:t.action_needed_label??null,failureReason:t.failure_reason??null,failureCode:t.failure_code??null,recoveryStage:t.recovery_stage??null,showClinicPhone:t.show_clinic_phone===true,clinicName:t.clinic_name??null,clinicEmail:t.clinic_email??null,clinicPhone:t.clinic_phone??null,convertedToUploadAt:t.converted_to_upload_at??null,requestGroupId:t.request_group_id??null})}i(gt,"mapRequestView");var Du=zod.z.object({request_group_id:zod.z.string().min(1),pet_ref:zod.z.string().min(1),total:zod.z.number().int().nonnegative(),responded:zod.z.number().int().nonnegative(),pending:zod.z.number().int().nonnegative(),members:zod.z.array(zod.z.unknown())});function Ps(e){let r=Du.safeParse(e);if(!r.success)return null;let t=r.data,o=bi(t.members);return o.some(n=>n.petRef!==t.pet_ref)?null:Object.freeze({requestGroupId:t.request_group_id,petRef:t.pet_ref,total:t.total,responded:t.responded,pending:t.pending,members:o})}i(Ps,"mapRequestGroup");function Iu(e){return !e||e==="awaiting_upload"||e==="in_review"?null:ks.has(e)?e:null}i(Iu,"normalizeSimpleStatus");function bi(e){let r=Array.isArray(e)?e:[],t=[];for(let o of r){let n=gt(o);n!==null&&t.push(n);}return Object.freeze(t)}i(bi,"mapRequestList");var Ou=zod.z.object({source_doc_id:zod.z.string().min(1),request_id:zod.z.string().min(1)});function Ts(e){let r=Ou.safeParse(e);return r.success?Object.freeze({documentId:r.data.source_doc_id,requestId:r.data.request_id,status:"received"}):null}i(Ts,"mapUploadedDocument");var Au=zod.z.object({label:zod.z.string(),value:zod.z.string()}),hi=zod.z.object({key:zod.z.string(),category:zod.z.string().optional(),label:zod.z.string().optional(),value:zod.z.string().nullish(),unit:zod.z.string().nullish(),observed_at:zod.z.string().nullish(),status:zod.z.string().nullish(),origin:zod.z.string().nullish(),canonical_key:zod.z.string().nullish()}),Fu=zod.z.object({at:zod.z.string(),value:zod.z.number().nullish(),display:zod.z.string().nullish(),origin:zod.z.string().nullish()}),qu=zod.z.object({key:zod.z.string(),label:zod.z.string().optional(),points:zod.z.array(Fu).optional()}),Nu=zod.z.object({title:zod.z.string(),detail:zod.z.string().nullish(),due_at:zod.z.string().nullish()}),Ri=zod.z.object({doc_id:zod.z.string(),title:zod.z.string().nullish(),page_count:zod.z.number().nullish(),received_at:zod.z.string().nullish()});function vi(e){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:_s(e.origin),canonicalKey:e.canonical_key??null})}i(vi,"mapEntityRow");function Ci(e){return Object.freeze({docId:e.doc_id,title:e.title??null,pageCount:e.page_count??null,receivedAt:e.received_at??null})}i(Ci,"mapDocumentRow");var Lu=zod.z.object({identity:zod.z.array(Au).optional(),entities:zod.z.array(hi).optional(),entity_series:zod.z.array(qu).optional(),forward_looking:zod.z.array(Nu).optional(),documents:zod.z.array(Ri).optional()});function Ds(e,r){let t=Mu(r)?r:{},o=ws(t.schema_version,"epdf/1.0"),n=ws(t.disclaimer,""),s=typeof t.pet_ref=="string"&&t.pet_ref.length>0?t.pet_ref:e;if(t.withheld===true)return Ss(s,o,n);let a=Lu.safeParse(t);if(!a.success)return Ss(s,o,n);let c=a.data,l=(c.identity??[]).map(g=>Object.freeze({label:g.label,value:g.value})),d=(c.entities??[]).map(vi),u=(c.entity_series??[]).map(g=>Object.freeze({key:g.key,label:g.label??g.key,points:Object.freeze((g.points??[]).map(f=>Object.freeze({at:f.at,value:f.value??null,display:f.display??null,origin:_s(f.origin)})))})),p=(c.forward_looking??[]).map(g=>Object.freeze({title:g.title,detail:g.detail??null,dueAt:g.due_at??null})),m={};for(let g of c.documents??[])m[g.doc_id]=Ci(g);let y=t.is_empty===true||l.length===0&&d.length===0&&u.length===0&&p.length===0&&Object.keys(m).length===0;return Object.freeze({petRef:s,schemaVersion:o,isEmpty:y,withheld:false,generatedAt:$u(t.generated_at),identity:Object.freeze(l),entities:Object.freeze(d),entitySeries:Object.freeze(u),forwardLooking:Object.freeze(p),documents:Object.freeze(m),disclaimer:n})}i(Ds,"mapRecordView");function Ss(e,r,t){return Object.freeze({petRef:e,schemaVersion:r,isEmpty:false,withheld:true,generatedAt:null,identity:Object.freeze([]),entities:Object.freeze([]),entitySeries:Object.freeze([]),forwardLooking:Object.freeze([]),documents:Object.freeze({}),disclaimer:t})}i(Ss,"withheldView");var zu=zod.z.object({pet_ref:zod.z.string().optional(),granted:zod.z.boolean().optional(),version:zod.z.string().nullish(),granted_at:zod.z.string().nullish()});function lo(e,r){let t=zu.safeParse(r),o=t.success?t.data:{};return Object.freeze({petRef:typeof o.pet_ref=="string"&&o.pet_ref.length>0?o.pet_ref:e,granted:o.granted===true,version:o.version??null,grantedAt:o.granted_at??null})}i(lo,"mapConsent");function Mu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Mu,"isObject");function xs(e,r){return typeof e=="number"&&Number.isFinite(e)?e:r}i(xs,"numberOr");function ws(e,r){return typeof e=="string"&&e.length>0?e:r}i(ws,"strOr");function $u(e){return typeof e=="string"&&e.length>0?e:null}i($u,"strOrNull");var Is=Object.freeze(["published","failed","revoked"]);function Jt(e){return Is.includes(e)}i(Jt,"isTerminalStatus");function bt(e){if(e===null)return null;let r=e.recordsReason;return r==="consent_required"||r==="session_required"||r==="entitlement"||r==="pet_not_found"?r:null}i(bt,"recordsDenialReasonOf");var Uu="records_consent_required";function Bu(e){let r=e.raw;if(r===null||typeof r!="object")return null;let t=r,o=typeof t.error=="object"&&t.error!==null?t.error.code:t.code;return typeof o=="string"&&o.length>0?o:null}i(Bu,"recordsWireCodeOf");function Yr(e){return e===null||e.httpStatus!==409?false:Bu(e)===Uu}i(Yr,"isRecordsConsentRequired");var Hu=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function co(e){return e!==Hu}i(co,"isUploadTransportAvailable");var Os=Object.freeze({record(){}}),Kr=25*1024*1024,As=64,wn=128,lr=128,Fs="application/pdf",qs=9e4;function Ls(e){return new Ei(e)}i(Ls,"createRecordsController");var Si=class Si{constructor(r){this.recordCache=new Map;this.consentEpoch=new Map;this.reportedGaps=new Set;this.features=kr;this.repository=r.repository,this.uploads=r.uploads,this.telemetry=r.telemetry??Os,this.newIdempotencyKey=r.newIdempotencyKey??Yu(),this.timers=r.timers??Wu,this.uploadDeadlineMs=r.uploadDeadlineMs??qs;}async createUploadRequest(r){let t=await this.repository.createRequest({pet_ref:r.petRef,idempotency_key:r.idempotencyKey});if(!t.ok)return this.onRequestError(t.error);let o=gt(t.value);return o===null?J(uo()):(this.observeRequest(o),Te(o))}async getRequest(r){let t=await this.repository.getRequest(r);if(!t.ok)return this.onRequestError(t.error);let o=gt(t.value);return o===null?J(uo()):(this.observeRequest(o),Te(o))}async listRequests(){let r=await this.repository.listRequests();if(!r.ok)return this.onRequestError(r.error);let t=bi(r.value);for(let o of t)this.observeRequest(o);return Te(t)}async readFeatures(){let r=this.repository.getFeatures;if(r===void 0)return this.features=kr;let t=kr;try{let o=await r.call(this.repository);o.ok&&(t=so(o.value));}catch{}return this.features=t,t}async uploadDocument(r){let{requestId:t,file:o}=r,n=ju(o,this.features.uploadContentTypes);if(n!==null)return this.telemetry.record("records.upload.rejected",{reason:n}),J(Ns(`upload rejected: ${n}`));let s=await this.repository.initiateUpload(t,{content_type:o.mimeType,file_size:o.sizeBytes});if(!s.ok)return this.onRequestError(s.error);let a=await this.postToS3(s.value,o,r);if(!a.ok)return this.telemetry.record("records.upload.failed",{reason:a.reason}),J(Ns(a.reason));let c=await this.repository.completeUpload(t,{upload_id:s.value.upload_id});if(!c.ok)return c.error.code==="mediaUploadFailed"&&this.telemetry.record("records.upload.rejected",{reason:Vu(c.error)??"corrupt"}),this.onRequestError(c.error);let l=Ts(c.value);return l===null?J(uo()):Te(l)}async postToS3(r,t,o){let n=new AbortController,s=Gu(n.signal,o.signal),a=this.timers.setTimeout(()=>n.abort(),this.uploadDeadlineMs);try{let c={signal:s};return o.onProgress&&(c.onProgress=o.onProgress),await this.uploads.postMultipart(r,t,c),{ok:!0}}catch{return {ok:false,reason:n.signal.aborted&&o.signal?.aborted!==true?"timeout":"upload_error"}}finally{this.timers.clearTimeout(a);}}async getRecord(r){let t=this.consentEpoch.get(r)??0,o=await this.repository.getRecord(r);if(t!==(this.consentEpoch.get(r)??0))return J(Object.freeze({...H("accessDenied",{retryable:false}),recordsReason:"consent_required"}));if(!o.ok){let s=bt(o.error);return s==="consent_required"?(this.recordCache.delete(r),this.telemetry.record("records.consent.denied",{pet_ref:r})):s==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:r}),J(o.error)}let n=Ds(r,o.value);return n.petRef!==r?J(uo()):n.withheld?(this.telemetry.record("records.redaction.withheld",{pet_ref:r}),this.recordCache.delete(r),Te(n)):(this.recordCache.set(r,n),Te(n))}peekCachedRecord(r){return this.recordCache.get(r)??null}async getConsent(r){let t=await this.repository.getConsent(r);return t.ok?Te(lo(r,t.value)):J(t.error)}async grantConsent(r){let t=await this.repository.putConsent(r.petRef,{consent_version:r.consentVersion,idempotency_key:r.idempotencyKey});return t.ok?Te(lo(r.petRef,t.value)):(bt(t.error)==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:r.petRef}),J(t.error))}async revokeConsent(r){let t=await this.repository.deleteConsent(r);return t.ok?(this.consentEpoch.set(r,(this.consentEpoch.get(r)??0)+1),this.recordCache.delete(r),Te(lo(r,t.value))):J(t.error)}reportCapabilityDenied(r){this.telemetry.record("records.capability.denied",r?{pet_ref:r}:{});}observeRequest(r){r.reviewStartedAt!==null&&!this.reportedGaps.has(r.id)&&(this.reportedGaps.add(r.id),this.telemetry.record("records.parse.gap",{request_id:r.id}));}onRequestError(r){return bt(r)==="entitlement"&&this.telemetry.record("records.capability.denied",{}),J(r)}};i(Si,"RecordsControllerImpl");var Ei=Si;function ju(e,r){if(!Gr(e.mimeType,r))return "unsupported_format";let t=e.sizeBytes;return typeof t!="number"||!Number.isFinite(t)||t<=0||t>Kr?"oversize":null}i(ju,"validateFile");function Vu(e){let r=e.wireMessage;return r==="unsupported_format"||r==="oversize"||r==="corrupt"?r:null}i(Vu,"reasonFromWire");function Ns(e){return H("mediaUploadFailed",{retryable:false,wireMessage:e})}i(Ns,"uploadFailed");function uo(){return H("internalError",{retryable:true})}i(uo,"internal");var Wu={setTimeout:i((e,r)=>setTimeout(e,r),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout")};function Gu(e,r){if(!r)return e;let t=new AbortController;if(e.aborted||r.aborted)return t.abort(),t.signal;let o=i(()=>t.abort(),"onAbort");return e.addEventListener("abort",o,{once:true}),r.addEventListener("abort",o,{once:true}),t.signal}i(Gu,"mergeSignals");function Yu(){let e=0;return ()=>`records-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(Yu,"defaultIdempotencyFactory");function Nr(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(Nr,"assertNever");function zs(e){return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:e.serverRequestId??null})}i(zs,"errorFrame");function Xu(e){let r={};return e.mode==="personalized"?r.authorization=`Bearer ${e.token}`:r["x-everfur-partner-key"]=e.publishableKey,e.userRef&&(r["x-everfur-user-ref"]=e.userRef),e.sessionId&&(r["x-everfur-session-id"]=e.sessionId),r}i(Xu,"authHeaders");function kn(e,r){return {...e,headers:{...Ju(e.headers),...Xu(r)}}}i(kn,"withAuthHeaders");function Ju(e){if(!e)return {};let r={};for(let[t,o]of Object.entries(e)){let n=t.toLowerCase();n==="authorization"||n==="x-everfur-partner-key"||(r[t]=o);}return r}i(Ju,"stripAuthHeaders");async function Ms(e,r){if(r.mode==="anonymous")return r.transport.request(kn(e,{mode:"anonymous",publishableKey:r.publishableKey,userRef:r.userRef,...r.sessionId?{sessionId:r.sessionId}:{}}));let t;try{t=await r.identity.currentToken();}catch{return J(xi())}let o=await r.transport.request(kn(e,{mode:"personalized",token:t,userRef:r.userRef,...r.sessionId?{sessionId:r.sessionId}:{}}));if(o.ok||o.error.httpStatus!==401)return o;let n;try{n=await r.identity.currentToken({forceRefresh:!0});}catch{return J(xi())}let s=await r.transport.request(kn(e,{mode:"personalized",token:n,userRef:r.userRef,...r.sessionId?{sessionId:r.sessionId}:{}}));return !s.ok&&s.error.httpStatus===401?J(xi(s.error.httpStatus)):s}i(Ms,"authedSend");function xi(e){return H("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(xi,"authRejectedError");function $s(e){return H("internalError",{retryable:true,wireMessage:Zu(e)})}i($s,"networkError");function Zu(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(Zu,"describeCause");var ep=3e4,rp=ui*2,tp="idempotency-key",np=new Set(["POST","PUT","PATCH","DELETE"]),op=Object.freeze({onEvent(){}}),ip=Object.freeze({setTimeout:i((e,r)=>setTimeout(e,r),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function ap(e){let r=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return r.length===0?null:`efs_${r}`.slice(0,128)}i(ap,"seededIdempotencyKey");function ht(e){let r=e.observer??op,t=e.timers??ip,o=e.rng??Math.random,n=e.sleep??((m,y)=>Rp(m,t,y)),s=e.maxAttempts??cs,a=e.unaryTimeoutMs??ep,c=e.newIdempotencyKey??it(),l=i(m=>{try{r.onEvent(m);}catch{}},"emit");async function d(m,y,g){let f=g?.maxAttempts,v=Math.max(1,f??s),b=g?.idempotent??np.has(y.method),R=g?.idempotencyKey===void 0?null:ap(g.idempotencyKey),h=b?R??c():null,E=sp(y,h),S=0;for(;;){let C=i(N=>Object.freeze({call:m,method:y.method,path:y.path,attempt:S,...h?{idempotencyKey:h}:{},...N}),"stamp");l(C({phase:"attempt"}));let k=bp(a,t),M=hp(k.signal,y.signal),T;try{T=await Ms({...E,signal:M.signal},e.auth);}catch(N){T=J($s(N));}finally{M.dispose(),k.cancel();}if(T.ok)return l(C({phase:"settled",ok:true,reason:"ok"})),T;let O=T.error,z=dp(O,S,{maxAttempts:v,rng:o,now:t.now(),aborted:y.signal?.aborted===true,...f!==void 0?{perCallMaxAttempts:f}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),q={ok:false,code:O.code,reason:z.reason,...O.httpStatus!==void 0?{httpStatus:O.httpStatus}:{},...O.requestId!==void 0?{requestId:O.requestId}:{}};if(!z.retry)return l(C({phase:"settled",...q})),J(O);if(l(C({phase:"retry",...q,delayMs:z.delayMs})),await n(z.delayMs,y.signal),y.signal?.aborted===true)return l(C({phase:"settled",...q,reason:"aborted"})),J(O);S+=1;}}i(d,"send");async function u(m){return kn(m,await gp(e.auth))}i(u,"authorize");async function*p(m,y,g){l(Object.freeze({call:m,phase:"stream.open",method:y.method,path:y.path,attempt:0}));try{yield*e.auth.transport.stream(y,g);}catch{yield zs({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(p,"stream"),Object.freeze({send:d,authorize:u,stream:p})}i(ht,"createRequestFunnel");function sp(e,r){let t={};for(let[o,n]of Object.entries(e.headers??{}))o.toLowerCase()!==tp&&(t[o]=n);return r!==null&&(t["Idempotency-Key"]=r),{...e,headers:t}}i(sp,"assembleHeaders");function it(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(it,"defaultIdempotencyKeyFactory");var lp=10;function dp(e,r,t){if(t.aborted)return {retry:false,reason:"aborted"};let o=cp(e);if(o==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(o!=="burst"&&!ci(e.code))return {retry:false,reason:"terminal-code"};let n=o==="burst"?"burst-throttle":"retryable-code";if(i(()=>{if(t.policy===void 0)return false;try{return !t.policy.shouldRetry(e.code,r)}catch{return false}},"policyVetoedRetry")())return {retry:false,reason:"terminal-code"};let a=i(()=>{if(t.policy===void 0)return null;let d;try{d=t.policy.maxAttempts(e.code);}catch{return null}return typeof d!="number"||!Number.isFinite(d)?null:Math.max(1,Math.min(lp,Math.floor(d)))},"policyCeiling"),c=t.perCallMaxAttempts??a()??t.maxAttempts;if(r+1>=c)return {retry:false,reason:"attempts-exhausted"};let l=up(e,t.now);return l!==null?l>rp?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:n,delayMs:l}:{retry:true,reason:n,delayMs:us(r,t.rng)}}i(dp,"decideRetry");function cp(e){let r=e.code==="unknown"?ls(yp(e.raw)):e.code;return r==="quotaExceeded"?"quota":r==="rateLimited"||e.httpStatus===429?"burst":null}i(cp,"throttleKind");function up(e,r){let t=mp(e.raw);if(t!==null){let n=t-r;return n>0?n:0}let o=pp(e.raw);return o===null?null:Math.round(o*1e3)}i(up,"retryOverrideMs");function pp(e){for(let r of wi(e)){let t=r.retry_after_seconds;if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t}return null}i(pp,"findRetryAfterSeconds");function mp(e){for(let r of wi(e)){let t=r.resets_at,o=fp(t);if(o!==null)return o}return null}i(mp,"findResetsAt");function wi(e){if(!Us(e))return [];let r=[e];for(let t of ["error","detail"]){let o=e[t];Us(o)&&r.push(o);}return r}i(wi,"candidateScopes");function fp(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 r=Date.parse(e);return Number.isFinite(r)?r:null}return null}i(fp,"parseInstantMs");function yp(e){for(let r of wi(e)){let t=r.code;if(typeof t=="string"&&t.length>0)return t}return null}i(yp,"rawWireCode");function Us(e){return typeof e=="object"&&e!==null}i(Us,"isRecord");async function gp(e){return e.mode==="anonymous"?{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}:{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}i(gp,"resolveDeviceAuth");function bp(e,r){let t=new AbortController,o=r.setTimeout(()=>t.abort(),e);return {signal:t.signal,cancel:i(()=>r.clearTimeout(o),"cancel")}}i(bp,"boundedSignal");function hp(e,r){let t=i(()=>{},"noop");if(!r)return {signal:e,dispose:t};let o=new AbortController;if(e.aborted||r.aborted)return o.abort(),{signal:o.signal,dispose:t};let n=i(()=>o.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),r.addEventListener("abort",n,{once:true}),{signal:o.signal,dispose:i(()=>{e.removeEventListener("abort",n),r.removeEventListener("abort",n);},"dispose")}}i(hp,"mergeSignals");function Rp(e,r,t){return e<=0||t?.aborted===true?Promise.resolve():new Promise(o=>{let n=r.setTimeout(()=>{t?.removeEventListener("abort",s),o();},e),s=i(()=>{r.clearTimeout(n),o();},"onAbort");t?.addEventListener("abort",s,{once:true});})}i(Rp,"delayAbortable");function at(e){for(let r=0;r<e.length;r+=1){let t=e.charCodeAt(r);if(t>=55296&&t<=56319){let o=e.charCodeAt(r+1);if(!(o>=56320&&o<=57343))return true;r+=1;}else if(t>=56320&&t<=57343)return true}return false}i(at,"hasLoneSurrogate");var Qr="/widget/v1/records";function Hs(e){let{auth:r}=e,t=r.mode,o=e.funnel??ht({auth:r,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),n=i(async(l,d,u)=>{let p=await o.send(l,d);return p.ok?p:J(Ep(p.error,t,u))},"send"),s=i((l,d)=>typeof d!="string"||d.length===0?H("validationFailed",{retryable:false,wireMessage:`${l} is required and must be a non-empty string`}):at(d)?H("validationFailed",{retryable:false,wireMessage:`${l} contains an unpaired surrogate and cannot be encoded`}):null,"segmentError"),a=i((l,d,u)=>{let p=s(l,d);if(p!==null)return p;let y=[...d].length;return y>u?H("validationFailed",{retryable:false,wireMessage:`${l} is ${y} characters; the server accepts at most ${u}`}):null},"boundsError"),c=i((...l)=>l.find(d=>d!==null)??null,"firstError");return {createRequest:i(l=>{let d=c(a("idempotency_key",l.idempotency_key,wn),a("pet_ref",l.pet_ref,lr));return d?Promise.resolve(J(d)):n("records.createRequest",ki(`${Qr}/requests`,l),"request")},"createRequest"),initiateUpload:i((l,d)=>{let u=s("request_id",l);return u?Promise.resolve(J(u)):n("records.initiateUpload",ki(`${Qr}/requests/${encodeURIComponent(l)}/uploads/initiate`,d),"request")},"initiateUpload"),completeUpload:i((l,d)=>{let u=s("request_id",l);return u?Promise.resolve(J(u)):n("records.completeUpload",ki(`${Qr}/requests/${encodeURIComponent(l)}/uploads/complete`,d),"request")},"completeUpload"),getRequest:i(l=>{let d=s("request_id",l);return d?Promise.resolve(J(d)):n("records.getRequest",_n(`${Qr}/requests/${encodeURIComponent(l)}`),"request")},"getRequest"),listRequests:i(async()=>{let l=await n("records.listRequests",_n(`${Qr}/requests`),"request");if(!l.ok)return l;let d=l.value;return {ok:true,value:Array.isArray(d)?d:d.items??[]}},"listRequests"),getRecord:i(l=>{let d=a("pet_ref",l,lr);return d?Promise.resolve(J(d)):n("records.getRecord",_n(`${Qr}/pets/${encodeURIComponent(l)}/record`),"content")},"getRecord"),getConsent:i(l=>{let d=a("pet_ref",l,lr);return d?Promise.resolve(J(d)):n("records.getConsent",_n(`${Qr}/pets/${encodeURIComponent(l)}/consent`),"consent")},"getConsent"),putConsent:i((l,d)=>{let u=c(a("consent_version",d.consent_version,As),a("idempotency_key",d.idempotency_key,wn),a("pet_ref",l,lr));return u?Promise.resolve(J(u)):n("records.putConsent",Sp(`${Qr}/pets/${encodeURIComponent(l)}/consent`,d),"consent")},"putConsent"),getFeatures:i(()=>n("records.getFeatures",_n(`${Qr}/features`),"request"),"getFeatures"),deleteConsent:i(l=>{let d=a("pet_ref",l,lr);return d?Promise.resolve(J(d)):n("records.deleteConsent",xp(`${Qr}/pets/${encodeURIComponent(l)}/consent`),"consent")},"deleteConsent")}}i(Hs,"createHttpRecordsRepository");function Bs(e,r){let t={...e,recordsReason:r};for(let o of ["wireMessage","raw"]){let n=Object.getOwnPropertyDescriptor(e,o);n!==void 0&&Object.defineProperty(t,o,n);}return Object.freeze(t)}i(Bs,"withReason");var vp="pet_not_registered";function Cp(e){return e.httpStatus!==404?null:e.reasonCode===vp?"pet_not_found":"entitlement"}i(Cp,"recordsErrorReasonFor");function Ep(e,r,t){let o=Cp(e);return o!==null?Bs(e,o):e.code!=="accessDenied"?e:Bs(e,r==="anonymous"?"session_required":t==="content"?"consent_required":"entitlement")}i(Ep,"tagReason");function _n(e){return {method:"GET",path:e}}i(_n,"get");function ki(e,r){return {method:"POST",path:e,body:r}}i(ki,"post");function Sp(e,r){return {method:"PUT",path:e,body:r}}i(Sp,"put");function xp(e){return {method:"DELETE",path:e}}i(xp,"del");var js=Symbol.for("@everfur/sdk#EverfurContext@v1"),Vs=globalThis,Ws=Vs[js]??(Vs[js]=react.createContext(null));Ws.displayName??="EverfurContext";function se(){let e=react.useContext(Ws);if(e===null)throw new Sn("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(se,"useEverfurContext");var _i=new Map,Pi=new Set;function Gs(e){_i.set(e,(_i.get(e)??0)+1);for(let r of [...Pi])r();}i(Gs,"notifyRecordsConsentWithdrawn");function Tp(e){return _i.get(e)??0}i(Tp,"recordsConsentEpochOf");function Dp(e){return Pi.add(e),()=>{Pi.delete(e);}}i(Dp,"subscribe");function po(e){let r=react.useCallback(()=>Tp(e),[e]);return react.useSyncExternalStore(Dp,r,r)}i(po,"useRecordsConsentEpoch");var Di={record:null,requests:[],consent:null,error:null,denialReason:null,withheld:false,loading:true,isUploading:false,uploadProgress:null,uploadQueue:[],uploadContentTypes:kr.uploadContentTypes},Ks=4e3,Op=30;function er(e){let{petRef:r}=e,t=react.useRef(e.uploadTransport);t.current=e.uploadTransport;let o=e.uploadTransport!==void 0,{runtime:n,userRef:s,scopeEpoch:a}=se(),c=react.useMemo(()=>({}),[n,s,r,a,e.controller]),l=react.useRef(c),[d,u]=react.useState({scope:c,controller:e.controller??null}),p=e.controller??(d.scope===c?d.controller:null),[m,y]=react.useState({scope:c,value:Di}),g=m.scope===c?m.value:Di,f=react.useCallback(I=>{y(w=>w.scope===c?{scope:c,value:I(w.value)}:w);},[c]),v=react.useRef(0);react.useEffect(()=>(l.current=c,y({scope:c,value:Di}),()=>{l.current=null,v.current+=1;}),[c]),react.useEffect(()=>{if(e.controller)return;let{services:I}=n.registry,w={record:i((_,Y)=>I.telemetry.track(_,Y),"record")},A=n.registry.acquire("records",`${s??""}|${r}${o?"|own-upload":""}`,()=>Ls({repository:Hs({auth:I.authFor(s),...I.errorPolicy?{errorPolicy:I.errorPolicy}:{}}),uploads:o?{postMultipart:i((_,Y,me)=>(t.current??I.uploadTransport).postMultipart(_,Y,me),"postMultipart")}:I.uploadTransport,telemetry:w}),()=>{});return u({scope:c,controller:A}),()=>{n.registry.release(A);}},[n,s,r,e.controller,a,c,o]);let b=react.useCallback(I=>{f(w=>({...w,...I}));},[f]),R=react.useCallback(async()=>{if(!p||l.current!==c)return;let I=v.current+=1;k.current=0,O(),b({loading:true,error:null,denialReason:null,withheld:false});let[w,A]=await Promise.all([p.getConsent(r),p.listRequests()]);if(I!==v.current)return;let _=w.ok?w.value:null,Y=A.ok?A.value.filter(Ne=>Ne.petRef===r):[],me=A.ok?null:A.error;if(_&&_.granted){let Ne=await p.getRecord(r);if(I!==v.current)return;if(Ne.ok){b({consent:_,requests:Y,record:Ne.value,withheld:Ne.value.withheld,error:Ne.value.withheld?Np():me,denialReason:null,loading:false});return}b({consent:_,requests:Y,record:null,error:Ne.error,denialReason:bt(Ne.error),withheld:false,loading:false});return}b({consent:_,requests:Y,record:null,error:w.ok?me:w.error,denialReason:_?"consent_required":qp(w),withheld:false,loading:false});},[p,r,b,c]);react.useEffect(()=>(R(),()=>{v.current+=1;}),[R]);let h=e.readUploadFeatures===true;react.useEffect(()=>{if(!h||!p?.readFeatures)return;let I=true;return p.readFeatures().then(w=>{I&&l.current===c&&b({uploadContentTypes:w.uploadContentTypes});}),()=>{I=false;}},[p,h,b,c]);let E=react.useMemo(()=>Fp(g.requests),[g.requests]),S=E?.id??null,C=E?.status??null,k=react.useRef(0),M=react.useRef(null),[T,O]=react.useReducer(I=>I+1,0);react.useEffect(()=>{if(!p||S===null||C===null||Jt(C)||C==="in_review")return;M.current!==String(S)&&(M.current=String(S),k.current=0);let I=false,w=i(async()=>{if(I||k.current>=Op)return;k.current+=1;let _=await p.getRequest(S);if(!I){if(_.ok&&_.value.petRef===r){if(f(Y=>({...Y,requests:mo(Y.requests,_.value)})),Jt(_.value.status)){_.value.status==="published"&&R();return}if(_.value.status==="in_review")return}A=setTimeout(()=>{w();},Ks);}},"tick"),A=setTimeout(()=>{w();},Ks);return ()=>{I=true,clearTimeout(A);}},[p,S,C,R,T,r,f]);let z=react.useCallback(async I=>{if(!p||l.current!==c)return fo();let w=await p.createUploadRequest({petRef:r,idempotencyKey:I});return l.current===c&&w.ok&&w.value.petRef===r&&f(A=>({...A,requests:mo(A.requests,w.value)})),w},[p,r,c,f]),q=react.useCallback((I,w)=>{f(A=>({...A,uploadQueue:A.uploadQueue.map(_=>_.key===I?w(_):_)}));},[f]),N=react.useCallback(async(I,w)=>{let A=Date.now().toString(36),_=w.map((me,Ne)=>{let re=Qs(me,g.uploadContentTypes);return {key:`${A}-${Ne}`,name:me.name??null,status:re===null?"queued":"skipped",progress:0,skipReason:re,error:null}}),Y=[..._];if(!p||l.current!==c)return Object.freeze(Y);f(me=>({...me,uploadQueue:_,isUploading:true,uploadProgress:0}));for(let[me,Ne]of w.entries()){let re=_[me];if(re.status==="skipped")continue;if(l.current!==c)break;q(re.key,Pe=>({...Pe,status:"uploading",progress:0})),b({uploadProgress:0});let oe=await p.uploadDocument({requestId:I,file:Ne,onProgress:i(Pe=>{if(l.current!==c)return;let Ge=Math.min(1,Math.max(0,Pe));q(re.key,xe=>({...xe,progress:Math.max(xe.progress,Ge)})),b({uploadProgress:Ge});},"onProgress")});if(l.current!==c)break;let Se=oe.ok?{...re,status:"done",progress:1}:{...re,status:"failed",error:oe.error};if(Y[me]=Se,q(re.key,()=>Se),oe.ok){let Pe=await p.getRequest(I);l.current===c&&Pe.ok&&Pe.value.petRef===r&&f(Ge=>({...Ge,requests:mo(Ge.requests,Pe.value)}));}}return l.current===c&&b({isUploading:false,uploadProgress:null}),Object.freeze(Y)},[p,b,q,r,c,f,g.uploadContentTypes]),B=react.useCallback(async(I,w)=>{if(!p||l.current!==c)return fo();let A=`${Date.now().toString(36)}-0`;f(Y=>({...Y,isUploading:true,uploadProgress:0,uploadQueue:[{key:A,name:w.name??null,status:"uploading",progress:0,skipReason:null,error:null}]}));let _=await p.uploadDocument({requestId:I,file:w,onProgress:i(Y=>{l.current===c&&(b({uploadProgress:Y}),q(A,me=>({...me,progress:Math.max(me.progress,Math.min(1,Y))})));},"onProgress")});if(l.current!==c)return _;if(b({isUploading:false,uploadProgress:null}),q(A,Y=>_.ok?{...Y,status:"done",progress:1}:{...Y,status:"failed",error:_.error}),_.ok){let Y=await p.getRequest(I);l.current===c&&Y.ok&&Y.value.petRef===r&&f(me=>({...me,requests:mo(me.requests,Y.value)}));}return _},[p,b,q,r,c,f]),x=react.useCallback(async(I,w)=>{if(!p||l.current!==c)return fo();let A=await p.grantConsent({petRef:r,consentVersion:I,idempotencyKey:w});return A.ok&&l.current===c&&R(),A},[p,r,R,c]),L=react.useCallback(async()=>{if(!p||l.current!==c)return fo();let I=await p.revokeConsent(r);return I.ok&&Gs(r),I.ok&&l.current===c&&(v.current+=1,b({record:null,withheld:false,loading:false,denialReason:"consent_required",consent:I.value})),I},[p,r,b,c]),F=react.useCallback(()=>R(),[R]),W=Ap(g,p!==null);return react.useMemo(()=>({status:W,record:g.record,requests:g.requests,activeRequest:E,consent:g.consent,error:g.error,denialReason:g.denialReason,withheld:g.withheld,isUploading:g.isUploading,uploadProgress:g.uploadProgress,uploadQueue:g.uploadQueue,uploadContentTypes:g.uploadContentTypes,createRequest:z,uploadDocument:B,uploadDocuments:N,grantConsent:x,revokeConsent:L,refresh:F}),[W,g,E,z,B,N,x,L,F])}i(er,"useEverfurRecords");function Qs(e,r){if(!Gr(e.mimeType,r))return "unsupported";let t=e.sizeBytes;return typeof t!="number"||!Number.isFinite(t)||t<=0||t>Kr?"too_large":null}i(Qs,"skipReasonFor");function Xs(e,r){let t=[],o=[];for(let n of e){let s=Qs(n,r);s===null?t.push(n):o.push({name:n.name??null,reason:s});}return {uploadable:t,skipped:o}}i(Xs,"classifyPick");function Ap(e,r){return e.loading||!r?"loading":e.withheld||e.denialReason!==null||e.error!==null?"error":e.record!==null&&!e.record.isEmpty||e.requests.length>0?"populated":"empty"}i(Ap,"selectStatus");function Fp(e){if(e.length===0)return null;let r=e[0];for(let t of e)t.updatedAt>r.updatedAt&&(r=t);return r}i(Fp,"newestRequest");function mo(e,r){let t=e.filter(o=>o.id!==r.id);return [r,...t]}i(mo,"replaceRequest");function qp(e){return e.ok?"consent_required":bt(e.error)??"consent_required"}i(qp,"consentDenial");function Np(){return H("internalError",{retryable:false})}i(Np,"withheldSentinel");function fo(){return {ok:false,error:H("internalError",{retryable:true})}}i(fo,"notReady");function Ii(e){let r=globalThis.console;try{r?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(Ii,"reportHostFailure");function Lp(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(Lp,"isThenable");function zp(e,...r){if(typeof e=="function")try{let t=e(...r);return Lp(t)&&Promise.resolve(t).then(void 0,Ii),t}catch(t){Ii(t);return}}i(zp,"callHost");var Js=new WeakMap;function Dn(e){if(typeof e!="function")return;let r=Js.get(e);if(r!==void 0)return r;let t=i((...o)=>{zp(e,...o);},"guarded");return Js.set(e,t),t}i(Dn,"guardHost");function Ie(e,r){let t=null;for(let o of r){let n=e[o];typeof n=="function"&&(t??={...e},t[o]=Dn(n));}return t??e}i(Ie,"guardHostProps");function It(e,...r){let t;try{t=e(...r);}catch(o){return Ii(o),Promise.resolve({ok:false,error:o})}return Promise.resolve(t).then(o=>({ok:true,value:o}),o=>({ok:false,error:o}))}i(It,"callHostAsync");var Mp="your pet";function Re(e){let r=e?.trim()??"";return r.length>0?r:Mp}i(Re,"petNameOr");var yr=Object.freeze({title:"Health records",titleWeb:i(e=>{let r=e?.trim()??"";return r.length>0?`${r}\u2019s Records`:"Health records"},"titleWeb"),titleNative:i(e=>{let r=e?.trim()??"";return r.length>0?r:"Health records"},"titleNative"),openTimeline:"Open timeline",loading:"Loading health records",lead:i(e=>`${Re(e)}\u2019s lab trends`,"lead"),retryMarkers:"Retry loading lab trends",viewFullRecord:"View full medical record",viewTimeline:"View full timeline",important:i(e=>`Important: ${e}`,"important")}),_r=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\u2019s biomarkers",ask:"Ask about these markers",askA11y:"Ask Everfur about these markers",a11y:i((e,r,t,o)=>`Marker summary: ${e} ${e===1?"marker":"markers"}, ${r} in range, ${t} out of range${o>0?`, ${o} without a range`:""}.`,"a11y")}),Oi=Object.freeze({counter:i((e,r)=>`${e+1} of ${r}`,"counter"),a11y:i((e,r,t)=>e!==null?`${e}, marker ${r+1} of ${t}. Swipe left or right to see more markers.`:`Marker ${r+1} of ${t}`,"a11y")}),st=Object.freeze({tapHint:"Tap a point to see where it came from.",singleHint:"One reading so far: we\u2019ll plot a trend as more come in.",empty:"No readings for this marker yet.",ask:"Ask about this marker",askNamed:i(e=>{let r=e?.trim()??"";return r.length>0?`Ask about ${r}`:"Ask about this marker"},"askNamed"),askA11y:i(e=>`Ask Everfur about ${e}`,"askA11y"),status:i(e=>`Status: ${e}`,"status"),latestA11y:i((e,r,t)=>`Latest reading ${e}, ${r}, collected ${t}`,"latestA11y"),readingsA11y:i(e=>`${e} readings, oldest to newest`,"readingsA11y")}),gr=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\u2019t verified this reading against the original document yet.",reviewed:"Reviewed by our team",ask:"Ask about this reading",askA11y:"Ask Everfur about this reading"}),lt=Object.freeze({title:i(e=>`${Re(e)}\u2019s records are on the way`,"title"),anotherClinic:"Another clinic",anotherClinicSub:"Seen more than one vet? We ask each one.",uploadDocumentPhotoSub:"A PDF, or a photo of a paper record.",body:i(e=>`We\u2019re requesting ${Re(e)}\u2019s records from your vet. This usually takes a few days; we\u2019ll show lab trends here as soon as they arrive.`,"body"),a11y:i(e=>`Records request in progress for ${Re(e)}.`,"a11y"),openA11y:i((e,r)=>`Open ${Re(e)}\u2019s records request. ${r}`,"openA11y"),ask:"Ask about this request",askA11y:"Ask Everfur about this records request"}),Jr=Object.freeze({title:i(e=>`Add ${Re(e)}\u2019s records`,"title"),firstRecordTitle:i(e=>`Add ${Re(e)}\u2019s first record`,"firstRecordTitle"),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.",requestFromClinicA11y:i(e=>`Request ${Re(e)}\u2019s records from a clinic`,"requestFromClinicA11y"),uploadDocument:"Upload a document",uploadDocumentA11y:i(e=>`Upload one of ${Re(e)}\u2019s records`,"uploadDocumentA11y")});var _e=Object.freeze({title:"Medical records",titleFor:i(e=>{let r=e?.trim()??"";return r.length>0?`${r}\u2019s Records`:"Medical records"},"titleFor"),lead:"Follow your records requests and add records you already have.",viewRecord:"Visits & records",viewTimeline:"Timeline",viewLabs:"Labs & bloodwork",viewScreenings:"Screenings",requestsFor:i(e=>`Requests for ${Re(e)}`,"requestsFor"),uploadPromptTitle:i(e=>`Do you already have ${Re(e)}'s records?`,"uploadPromptTitle"),uploadPromptBody:"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.",uploadAction:"Upload records I already have",uploadStarting:"Starting upload\u2026",noPet:"Add your pet in Chat before starting a records request.",requestRecords:"Request records",requestTimeline:"Request timeline",requestTimelineA11y:i(e=>`Request timeline, ${e}`,"requestTimelineA11y"),ownerProvided:"Records you provided",askA11y:i(e=>`Ask Everfur about ${Re(e)}'s medical records`,"askA11y")});function Zs(e){return `I'm looking at ${e?.trim()||"my pet"}'s medical records. What do these records tell me about their health and what should I keep on top of?`}i(Zs,"buildRecordsPageAskPrompt");function yo(e){if(e.convertedToUploadAt)return _e.ownerProvided;let r=e.clinicName?.trim()??"";return r.length>0?r:_e.ownerProvided}i(yo,"consumerRequestSource");var X=Object.freeze({loading:"Loading",empty:"No records yet",upload:"Upload records",consentRequired:"Consent required",allow:"Allow",sessionRequired:"Sign in required",recordUnavailable:"Record unavailable",retry:"Try again",records:"Records",beingReviewed:"being reviewed"}),el="Everfur summarizes what your vet recorded. It is informational, not diagnostic.";function rl(e){return !Jt(e.status)}i(rl,"isRecordsInProgress");function go(e,r){if(r===null)return null;let t=e.filter(s=>s.petRef===r);if(t.length===0)return null;let o=t.find(s=>s.status==="published");return o!==void 0?o:t.filter(rl).sort((s,a)=>a.updatedAt.localeCompare(s.updatedAt))[0]??null}i(go,"pickPetRecordsRequest");function Ai(e){if(e.hasMarkers)return "published";let r=go(e.requests,e.petRef);return r===null?"none":r.status==="published"||rl(r)?"in_progress":"none"}i(Ai,"deriveRecordsDashboardState");function $p(e){return e.recordLoading?true:e.hasFullRecord?false:e.markersLoading||!e.hasMarkers&&e.requestsLoading}i($p,"selectDashboardLoading");function Fi(e){return $p(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"}i(Fi,"selectDashboardView");function nr(e){return e?.httpStatus===429?"rate_limited":e?.httpStatus===502?"service_unavailable":"error"}i(nr,"recordsEmptyVariantForError");var tl=Object.freeze({name:"dashboard"});function Zt(e=tl){return Object.freeze({stack:Object.freeze([e])})}i(Zt,"initialRecordsNav");function bo(e){return e.stack[e.stack.length-1]??tl}i(bo,"currentRecordsScreen");function qi(e,r){return Object.freeze({stack:Object.freeze([...e.stack,r])})}i(qi,"pushRecordsNav");function Ni(e,r){return Object.freeze({stack:Object.freeze([...e.stack.slice(0,-1),r])})}i(Ni,"replaceRecordsNav");function Li(e){return Zt(e)}i(Li,"resetRecordsNav");function ho(e){return e.stack.length<=1?{state:e,handled:false}:{state:Object.freeze({stack:Object.freeze(e.stack.slice(0,-1))}),handled:true}}i(ho,"popRecordsNav");function nl(e,r){return r.name==="dashboard"?Li(r):bo(e).name==="upload"&&r.name==="request"?Ni(e,r):qi(e,r)}i(nl,"transitionRecordsNav");function In(e,r){switch(r.type){case "push":return qi(e,r.screen);case "pop":return ho(e).state;case "replace":return Ni(e,r.screen);case "reset":return Li(r.screen);case "navigate":return nl(e,r.screen);default:return e}}i(In,"recordsNavReducer");function Zr(e,r){return e??r?.version??""}i(Zr,"resolveConsentVersion");function dt(e,r){return Zr(e,r).length>0}i(dt,"canGrantConsent");function et(e,r){return e.denialReason==="consent_required"?r?{kind:"consent_required"}:{kind:"consent_unavailable"}:e.denialReason==="pet_not_found"?{kind:"pet_not_found",error:H("petNotFound",{retryable:false})}:e.denialReason==="entitlement"?{kind:"error",error:H("accessDenied")}:e.denialReason==="session_required"?{kind:"session_required"}:e.withheld?{kind:"withheld"}:e.error===null?{kind:"withheld"}:{kind:"error",error:e.error}}i(et,"selectErrorView");function Ro(e){let r=e.clinicName?.trim()??"";return r.length>0?r:e.source==="owner_provided"?ol.ownerUpload:ol.clinicRequest}i(Ro,"selectRequestTitle");var ol=Object.freeze({ownerUpload:"Records you uploaded",clinicRequest:"Record request"});function zi(e,r){return r===null||r.status!=="awaiting_upload"?null:r}i(zi,"selectResumableUploadRequest");function Mi(e){return `${e} ${X.beingReviewed}`}i(Mi,"heldItemsLabel");function $i(e){let r=[...e].sort((t,o)=>t.updatedAt!==o.updatedAt?t.updatedAt>o.updatedAt?-1:1:t.createdAt!==o.createdAt?t.createdAt>o.createdAt?-1:1:0);return Object.freeze(r)}i($i,"selectRequestList");function On(e){let r=e.actionNeededLabel?.trim()??"";return r.length>0?r:e.statusLabel}i(On,"selectPrimaryLabel");function vo(e){if(e.showClinicPhone!==true)return null;let r=e.clinicPhone?.trim()??"";return r.length===0?null:{phone:r,dial:`tel:${r.replace(/[^+\d]/g,"")}`,clinicName:e.clinicName?.trim()||null}}i(vo,"selectClinicCall");function il(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"}}i(il,"selectRequestStatusTone");var Hi=class Hi extends react.Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(t,o){return Object.is(t.resetKey,o.key)?null:{failed:false,key:t.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};i(Hi,"HostRenderBoundary");var Ui=Hi;function Bp({render:e}){return e()}i(Bp,"RenderHost");function Bi({render:e,fallback:r,resetKey:t}){return react.createElement(Ui,{fallback:r,resetKey:t,children:react.createElement(Bp,{render:e})})}i(Bi,"HostRender");function Vi(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let r of Object.keys(e))Vi(e[r]);}return e}i(Vi,"deepFreeze");var Hp=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),ll={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},dl={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},sl={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},jp={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Vp={regular:"400",medium:"500",bold:"700"},Wp={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},Gp=0,Co="System",Eo="monospace",Yp=["content","heading","control","compact","badge"];function Kp(e){let r={};for(let t of Yp)r[t]=e;return r}i(Kp,"authoredTierSizes");function cl(){return {family:Co,mono:Eo,fontUrl:null,families:{regular:Co,medium:Co,bold:Co,mono:Eo,monoMedium:Eo,monoBold:Eo},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:sl,tierSizes:Kp(sl),lineHeight:jp,weight:Vp,letterSpacing:Wp,scale:1,maxScale:Gp,scaleCaps:Hp}}i(cl,"baseType");var ul={},ji=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function An(e){return `cubic-bezier(${e.join(", ")})`}i(An,"cssCubicBezier");var pl={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:An(ji.standard),emphasized:An(ji.emphasized),exit:An(ji.exit)},reducedMotion:false},Qp={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},ml=Vi({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Qp,space:ll,radius:dl,type:cl(),motion:pl,slots:ul}),Xp={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"};Vi({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Xp,space:ll,radius:dl,type:cl(),motion:pl,slots:ul});var fl=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),yl=globalThis,Wi=yl[fl]??(yl[fl]=react.createContext(ml));Wi.displayName??="EverfurThemeContext";function ye(){return react.useContext(Wi)}i(ye,"useEverfurTheme");var gl=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});var bl='system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',em="System";function rm(e){let r=e.trim();return r.length===0||r===em?bl:`${hl(r)}, ${bl}`}i(rm,"cssFontFamily");function tm(e){let r=e.trim();return r.length===0||r==="monospace"?"ui-monospace, Menlo, Consolas, monospace":`${hl(r)}, ui-monospace, Menlo, Consolas, monospace`}i(tm,"cssMonoFamily");function hl(e){return `"${e.replace(/[\\"]/g,"\\$&")}"`}i(hl,"quote");function D(e,r){let t=e.type,o=t.families[r];return {fontFamily:r==="mono"||r==="monoMedium"||r==="monoBold"?tm(o):rm(o),fontWeight:t.namedFaces[r]?t.weight.regular:t.weight[gl[r]]}}i(D,"faceCss");var Rt=Object.freeze({textAlign:"start"});var nm=Object.freeze({chat:Object.freeze(["chat.message.create"]),records:Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:Object.freeze(["records.clinic.create"]),video:Object.freeze(["video.gait.execute"]),photo:Object.freeze(["photo.checkup.execute"]),animations:Object.freeze(["animations.state.read"]),televet:Object.freeze(["televet.visit.create"])});function om(e){return nm[e]}i(om,"requires");function Rl(e,r,t){let o=om(e),n=new Map;for(let c of r)n.set(c.resource,c);if(t?.isPending===true&&o.some(c=>!n.has(c)))return Gi({name:e,enabled:false,isPending:true,limits:{}});let s=im(o,n);return o.filter(c=>n.get(c)?.granted!==true).length===0?Gi({name:e,enabled:true,isPending:false,limits:s}):Gi({name:e,enabled:false,isPending:false,limits:s,disabled:am(o,n)})}i(Rl,"decideCapability");function im(e,r){let t={};for(let o of e){let n=r.get(o)?.limits;if(n)for(let[s,a]of Object.entries(n)){let c=t[s];t[s]=c===void 0?a:Math.min(c,a);}}return t}i(im,"mergeLimits");function am(e,r){for(let t of e){let o=r.get(t)?.disabled;if(o)return Object.freeze({reason:o.reason,level:o.level,recoverable:o.recoverable})}return Object.freeze({reason:pi("accessDenied"),level:"user_entitlement",recoverable:false})}i(am,"disabledFor");function Gi(e){let r={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:Object.freeze({...e.limits})};return e.disabled!==void 0&&(r.disabled=e.disabled),Object.freeze(r)}i(Gi,"freezeDecision");function Ot(e){let{runtime:r}=se(),t=r.entitlements,o=react.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot);return react.useMemo(()=>Rl(e,o.decisions,{isPending:o.isPending}),[e,o])}i(Ot,"useCapability");var dm=48;function cm(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(cm,"selectView");function Oe(e){let{capability:r,children:t,renderDisabled:o,renderPending:n,style:s,className:a}=e,c=Ot(r),l=react.useMemo(()=>cm(c),[c]);switch(l){case "enabled":return t;case "pending":return n?jsxRuntime.jsx(Bi,{render:n,fallback:jsxRuntime.jsx(vl,{capability:r,style:s,className:a})}):jsxRuntime.jsx(vl,{capability:r,style:s,className:a});case "disabled":return o?jsxRuntime.jsx(Bi,{render:()=>o(c),fallback:jsxRuntime.jsx(Cl,{decision:c,style:s,className:a}),resetKey:c}):jsxRuntime.jsx(Cl,{decision:c,style:s,className:a});default:return Nr(l)}}i(Oe,"CapabilityGate");function vl({capability:e,style:r,className:t}){let o=ye(),n=react.useMemo(()=>El(o),[o]);return jsxRuntime.jsx("div",{role:"status","aria-busy":"true","aria-label":`Loading ${e}`,className:t,style:{...n.offstate,...r},children:jsxRuntime.jsx("div",{style:n.skeletonBar})})}i(vl,"PendingSkeleton");function Cl({decision:e,style:r,className:t}){let o=ye(),n=react.useMemo(()=>El(o),[o]),s=e.disabled?.reason??"";return jsxRuntime.jsx("div",{className:t,style:{...n.offstate,...r},children:s.length>0?jsxRuntime.jsx("p",{style:n.offstateText,children:s}):null})}i(Cl,"OffState");function El(e){let{color:r,space:t,radius:o,type:n}=e;return {offstate:{...Rt,boxSizing:"border-box",minHeight:dm,display:"flex",flexDirection:"column",justifyContent:"center",padding:`${t.md}px ${t.lg}px`,backgroundColor:r.surfaceCream,borderRadius:o.md,border:`1px solid ${r.brandBorder}`},offstateText:{margin:0,...D(e,"regular"),fontSize:n.size.body,lineHeight:`${Math.round(n.size.body*n.lineHeight.normal)}px`,color:r.text.muted},skeletonBar:{height:t.md,borderRadius:o.xs,backgroundColor:r.brandSofter}}}i(El,"makeStyles");var So=2;function Sl(e){return typeof e!="number"||!Number.isInteger(e)?So:e<1?1:e>6?6:e}i(Sl,"headingLevel");function Ki(e){return e>=6?6:e+1}i(Ki,"nextHeadingLevel");function xo(e){return `h${String(e)}`}i(xo,"headingTag");var pm=Ki(So);react.createContext(pm);function Ae(e){let r=ye(),t=react.useMemo(()=>fm(r),[r]);return jsxRuntime.jsx("p",{role:"note",className:e.className,style:{...t,...e.style},"data-testid":"records-footnote",children:el})}i(Ae,"RecordsFootnote");function fm(e){let{color:r,space:t,type:o}=e;return {...Rt,boxSizing:"border-box",margin:0,padding:`${t.md}px ${t.lg}px ${t.lg}px`,textAlign:"center",...D(e,"regular"),fontSize:o.size.caption,lineHeight:`${Math.round(o.size.caption*o.lineHeight.normal)}px`,color:r.text.muted,backgroundColor:r.background}}i(fm,"footnoteStyle");var te=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\u2019re authorizing",send:"Send request",sending:"Sending\u2026",cancel:"Cancel",sign:"Signature",draw:"Draw your signature",type:"Type your name to sign",toType:"Can\u2019t draw? Type your name instead",toDraw:"Draw your signature instead",clear:"Clear",drawHint:"Draw your signature in the box above.",clearA11y:"Clear signature",typedSignatureA11y:i(e=>`Typed signature: ${e}`,"typedSignatureA11y"),missingSignature:"Please add your signature before submitting.",recentlyUsed:"Recently used",moreClinics:"Load more"}),xl=100;var we=Object.freeze({title:te.title,titleFor:i(e=>{let r=e?.trim()??"";return r.length>0?`Request ${r}\u2019s records`:te.title},"titleFor"),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:i(e=>[{title:"We send a secure request",body:"With your permission, straight to the clinic\u2019s 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}\u2019s records.`}],"howSteps"),placeholder:te.placeholder,searchA11y:te.search,clearSearch:"Clear search",loading:"Loading clinics",uploadOwn:"I already have the records",uploadOwnStarting:"Setting up your upload\u2026",uploadOwnA11y:"Upload records you already have",noPet:"Add a pet first, then come back to request their records.",recentlyUsed:te.recentlyUsed,noMatch:i(e=>`No clinics match \u201C${e}\u201D. You can still request records using the option above.`,"noMatch"),loadingMore:"Loading more\u2026",loadMoreFailed:"Couldn\u2019t load more. Tap to retry.",loadMoreRetryA11y:"Retry loading more clinics",selectA11y:i(e=>`Request records from ${e}`,"selectA11y"),fallback:Object.freeze({title:"Can\u2019t find your clinic?",subtitle:"Add it by email and we\u2019ll request your records.",expandA11y:"Can't find your clinic? Add it by email to request records.",collapseA11y:"Hide the request-by-email form",nameLabel:"Clinic name",namePlaceholder:"Your clinic\u2019s name",emailLabel:"Clinic email",emailPlaceholder:"records@clinic.com",reviewNote:"We review every request by hand before reaching out to the clinic.",submit:"Continue",submitA11y:"Request records by email"})});function wl(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"}}}i(wl,"clinicEmailStatusBadge");var gm=1.609344;function kl(e){return e===null||!Number.isFinite(e)?null:(e/gm).toFixed(1)}i(kl,"milesLabel");function _l(e){let r=kl(e);return r===null?"":`${r} mi`}i(_l,"formatClinicDistanceLabel");function Pl(e){let r=kl(e);return r===null?"":`${r} ${r==="1.0"?"mile":"miles"} away`}i(Pl,"formatClinicDistanceForA11y");var Tl=300,Qi=2;var le=Object.freeze({loading:"Loading record request",sentTitle:"Request sent",sentLeadWeb:i((e,r)=>`${e} has the request. We\u2019ll let you know when ${r}\u2019s file arrives.`,"sentLeadWeb"),sentLeadNative:i(e=>`We\u2019ll let you know when ${e}\u2019s file arrives.`,"sentLeadNative"),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\u2019s no reply by day 14.",waitingBanner:i(e=>`It\u2019s been ${e} ${e===1?"day":"days"}. Some clinics take a little longer; we\u2019ve been following up automatically and are still on it. If there\u2019s no reply by day 14, we\u2019ll let you know.`,"waitingBanner"),viewRecords:"View health records",nextStep:"You can try a different clinic or upload records you already have.",tryAnotherClinic:"Request from a different clinic",tryAnotherClinicA11y:"Request records from a different clinic",convert:"Upload my own records instead",converting:"Switching\u2026",convertHint:"We\u2019ll stop waiting on the clinic so you can add the records you already have. If the clinic does reply, we\u2019ll still add their records too.",freshUpload:"Upload your own records",freshUploadStarting:"Starting\u2026",cancel:"Cancel request",cancelling:"Cancelling\u2026",cancelA11y:"Cancel this records request",cancellingA11y:"Cancelling, please wait",resend:"Resend email",resending:"Resending\u2026",resendA11y:"Resend the authorization email to the clinic",resendingA11y:"Resending the email, please wait",errors:Object.freeze({cancel:"We couldn\u2019t cancel this request. Please try again.",retry:"We couldn\u2019t retry this request. Please try again.",email:"We couldn\u2019t update the clinic email. Please try again.",convert:"We couldn\u2019t switch this to an upload. Please try again.",start:"We couldn\u2019t start that. Please try again.",invalidEmail:"Enter a valid clinic email."})});function bm(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\u2019t include your records.";switch(e.failureCode){case "no_response":return "The clinic didn\u2019t reply after several reminders over 14 days.";case "parse_timeout":case "parse_error":return "We received the records but couldn\u2019t read them. Uploading a clean copy usually fixes this.";case "hard_bounce":case "dispatch_failed":return "We couldn\u2019t deliver the email to the clinic.";default:return "This request didn\u2019t go through."}}i(bm,"fallbackFailureTitle");function Dl(e){let r=e.failureReason?.trim()??"";return r.length>0?r:bm(e)}i(Dl,"failureTitle");var hm=1440*60*1e3;function Xi(e,r){if(!e.createdAt)return 0;let t=Date.parse(e.createdAt);if(Number.isNaN(t))return 0;let o=r-t;return o<=0?0:Math.floor(o/hm)}i(Xi,"requestElapsedDays");var Rm=7;function Il(e,r){return e.wireStatus!=="awaiting_response"?false:Xi(e,r)>=Rm}i(Il,"requestWaitingTooLong");function Ji(e){return e.status==="failed"}i(Ji,"isTerminalFailure");function Ol(e){return Ji(e)||e.canUpdateClinicEmail===true||e.canRetrySend===true}i(Ol,"shouldOfferRecovery");function ql(e,r){let[t,o]=react.useState(""),[n,s]=react.useState(""),[a,c]=react.useState([]),[l,d]=react.useState(null),[u,p]=react.useState([]),[m,y]=react.useState(true),[g,f]=react.useState(false),[v,b]=react.useState(false),[R,h]=react.useState(null),[E,S]=react.useState(null),[C,k]=react.useState(0),M=react.useRef(0),T=react.useRef(true),O=r?.latitude,z=r?.longitude,q=react.useMemo(()=>O!==void 0&&z!==void 0?{latitude:O,longitude:z}:void 0,[O,z]);react.useEffect(()=>(T.current=true,()=>{T.current=false,M.current+=1;}),[e]),react.useEffect(()=>{let F=true;return y(true),e.recentClinics({limit:5}).then(W=>{F&&(W.ok&&p(W.value.clinics),y(false));}).catch(()=>{F&&y(false);}),()=>{F=false;}},[e]),react.useEffect(()=>{let F=t.trim();if(F.length<Qi){s("");return}let W=setTimeout(()=>s(F),Tl);return ()=>clearTimeout(W)},[t]);let N=n.length>=Qi;react.useEffect(()=>{let F=M.current+=1;if(c([]),d(null),h(null),S(null),!N){f(false);return}f(true),e.searchClinics({query:n,limit:25,...q?{location:q}:{}}).then(W=>{!T.current||F!==M.current||(W.ok?(c(W.value.clinics),d(W.value.nextCursor)):h(W.error),f(false));}).catch(()=>{T.current&&F===M.current&&f(false);});},[e,n,N,q,C]);let B=react.useCallback(()=>{if(!N||l===null||v)return;let F=M.current;b(true),S(null),e.searchClinics({query:n,limit:25,cursor:l,...q?{location:q}:{}}).then(W=>{!T.current||F!==M.current||(W.ok?(c(I=>[...I,...W.value.clinics]),d(W.value.nextCursor)):S(W.error),b(false));}).catch(()=>{T.current&&F===M.current&&b(false);});},[e,l,n,N,v,q]),x=react.useCallback(F=>o(F),[]),L=react.useCallback(()=>k(F=>F+1),[]);return react.useMemo(()=>({query:t,debouncedQuery:n,isSearchActive:N,clinics:a,recent:u,recentLoading:m,initialLoading:g,loadingMore:v,hasNextPage:l!==null,error:R,pageError:E,setQuery:x,loadMore:B,retry:L}),[t,n,N,a,u,m,g,v,l,R,E,x,B,L])}i(ql,"useClinicPicker");function ea(e,r,t,o){return Object.freeze({key:e?.id??`free:${r??""}`,clinic:e,freeText:r,email:t,idempotencyKey:o})}i(ea,"clinicDraftFor");var en=10,ko=zod.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),Fn=i((e,r=1)=>zod.z.string().refine(t=>!at(t)&&[...t].length>=r&&[...t].length<=e),"text"),Ll=i(e=>[...e].some(r=>r.charCodeAt(0)<32||r.charCodeAt(0)===127),"hasControl"),vm=zod.z.object({clinicId:ko.optional(),clinicFreeText:Fn(200).refine(e=>e.trim().length>0).optional(),clinicEmail:Fn(320,3).refine(e=>!Ll(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())).optional(),signatureId:ko.optional(),signaturePngBase64:zod.z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:zod.z.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)),Cm=zod.z.object({petRef:Fn(128),ownerName:Fn(200).refine(e=>e.trim().length>0&&!Ll(e)),authorizationVersion:Fn(64),clinics:zod.z.array(vm).min(1).max(en)}).strict(),Em=zod.z.object({request_group_id:ko,pet_ref:zod.z.string(),created_count:zod.z.number().int().nonnegative(),failed_count:zod.z.number().int().nonnegative(),results:zod.z.array(zod.z.object({idempotency_key:zod.z.string(),clinic_id:ko.nullable().optional(),clinic_free_text:zod.z.string().nullable().optional(),created:zod.z.boolean(),request:zod.z.unknown().optional(),failure_code:zod.z.string().nullable().optional(),failure_reason:zod.z.string().nullable().optional()}))});function zl(e){let r=e.funnel??ht({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}});return {async createClinicRequestBatch(t){if(!Cm.safeParse(t).success)return J(H("validationFailed",{retryable:false}));let o=await r.send("records.clinic.createBatch",{method:"POST",path:"/widget/v1/records/clinic-requests/batch",body:{pet_ref:t.petRef,owner_name:t.ownerName,authorization_version:t.authorizationVersion,clinics:t.clinics.map(a=>({...a.clinicId!==void 0?{clinic_id:a.clinicId}:{clinic_free_text:a.clinicFreeText},...a.clinicEmail!==void 0?{clinic_email:a.clinicEmail}:{},...a.signatureId!==void 0?{signature_id:a.signatureId}:{signature_png_base64:a.signaturePngBase64},idempotency_key:a.idempotencyKey}))}});if(!o.ok)return o;let n=Em.safeParse(o.value);if(!n.success||n.data.pet_ref!==t.petRef)return Nl();let s=[];for(let a of n.data.results){let c=a.request===void 0||a.request===null?null:gt(a.request);if(a.created!==(c!==null))return Nl();s.push(Object.freeze({idempotencyKey:a.idempotency_key,clinicId:a.clinic_id??null,clinicFreeText:a.clinic_free_text??null,created:a.created,request:c,failureCode:a.failure_code??null,failureReason:a.failure_reason??null}));}return Te(Object.freeze({requestGroupId:n.data.request_group_id,petRef:n.data.pet_ref,results:Object.freeze(s),createdCount:n.data.created_count,failedCount:n.data.failed_count}))}}}i(zl,"createRecordsClinicBatchClient");function Nl(){return J(H("internalError",{retryable:false}))}i(Nl,"malformed");var Ml=zod.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),Sm=zod.z.object({clinics:zod.z.array(zod.z.object({clinic_id:Ml,name:zod.z.string().min(1),address:zod.z.string().nullable(),phone:zod.z.string().nullable(),email_status:zod.z.string(),distance_km:zod.z.number().finite().nonnegative().nullable()})),next_cursor:zod.z.string().nullable().optional()}),xm=zod.z.object({authorization_version:zod.z.string().min(1),scope_template:zod.z.string().min(1),authorization_template:zod.z.string().min(1)}),wm=zod.z.object({upload_id:zod.z.string().min(1),upload_url:zod.z.string().url().refine(e=>e.startsWith("https://")),upload_fields:zod.z.record(zod.z.string())});function $l(e){let{repository:r}=e,t=i(async n=>{let s=await n;if(!s.ok)return s;let a=gt(s.value);return a===null?At():Te(a)},"request"),o=i(async n=>{let s=await n;if(!s.ok)return s;let a=Sm.safeParse(s.value);return a.success?Te(Object.freeze({clinics:Object.freeze(a.data.clinics.map(c=>Object.freeze({id:c.clinic_id,name:c.name,address:c.address,phone:c.phone,emailStatus:c.email_status,distanceKm:c.distance_km}))),nextCursor:a.data.next_cursor??null})):At()},"page");return {searchClinics:i((n={})=>o(r.searchClinics(n)),"searchClinics"),recentClinics:i((n={})=>o(r.recentClinics(n)),"recentClinics"),async getRequestGroup(n){let s=await r.getRequestGroup(n);if(!s.ok)return s;let a=Ps(s.value);return a===null?At():Te(a)},async getAuthorizationCopy(){let n=await r.getAuthorizationCopy();if(!n.ok)return n;let s=xm.safeParse(n.value);return s.success?Te(Object.freeze({authorizationVersion:s.data.authorization_version,scopeTemplate:s.data.scope_template,authorizationTemplate:s.data.authorization_template})):At()},async createClinicRequest(n){let s=await t(r.createClinicRequest(n));return s.ok&&s.value.petRef!==n.petRef?At():s},retryRequest:i(n=>t(r.retryRequest(n)),"retryRequest"),revokeRequest:i(n=>t(r.revokeRequest(n)),"revokeRequest"),updateClinicEmail:i((n,s)=>t(r.updateClinicEmail(n,s)),"updateClinicEmail"),convertToUpload:i(n=>t(r.convertToUpload(n)),"convertToUpload"),async initiateSignatureUpload(n){let s=await r.initiateSignatureUpload(n);if(!s.ok)return s;let a=wm.safeParse(s.value);return a.success?Te(Object.freeze({uploadId:a.data.upload_id,uploadUrl:a.data.upload_url,uploadFields:Object.freeze(a.data.upload_fields)})):At()},async completeSignatureUpload(n){let s=await r.completeSignatureUpload(n);if(!s.ok)return s;let a=zod.z.object({signature_id:Ml}).safeParse(s.value);return a.success?Te(a.data.signature_id):At()}}}i($l,"createRecordsClinicController");function At(){return J(H("internalError",{retryable:false}))}i(At,"malformed");var vt="/widget/v1/records",Ul=zod.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),Et=i((e,r=1)=>zod.z.string().refine(t=>!at(t)&&[...t].length>=r&&[...t].length<=e),"text"),Hl=i(e=>[...e].some(r=>r.charCodeAt(0)<32||r.charCodeAt(0)===127),"hasControl"),jl=Et(320,3).refine(e=>!Hl(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())),Bl=Et(64),km=zod.z.object({limit:zod.z.number().int().min(1).max(25).optional()}).strict(),_m=zod.z.object({query:Et(200,0).optional(),location:zod.z.object({latitude:zod.z.number().finite().min(-90).max(90),longitude:zod.z.number().finite().min(-180).max(180)}).strict().optional(),limit:zod.z.number().int().min(1).max(100).optional(),cursor:Et(512,0).optional()}).strict(),Pm=zod.z.object({petRef:Et(128),ownerName:Et(200).refine(e=>e.trim().length>0&&!Hl(e)),authorizationVersion:Et(64),clinicId:Ul.optional(),clinicFreeText:Et(200).refine(e=>e.trim().length>0).optional(),clinicEmail:jl.optional(),signatureId:Ul.optional(),signaturePngBase64:zod.z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:zod.z.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 Vl(e){let r=e.funnel??ht({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),t=i((n,s,a=false)=>r.send(`records.clinic.${n}`,s,s.method==="GET"||a?void 0:{idempotent:false,maxAttempts:1}),"send"),o=i((n,s,a)=>Bl.safeParse(n).success?t(s,{method:"POST",path:`${vt}/requests/${encodeURIComponent(n)}/${s}`,...a?{body:a}:{}}):Ct(),"recover");return {searchClinics(n){return _m.safeParse(n).success?t("search",{method:"GET",path:`${vt}/clinics/search`,query:{q:n.query??"",lat:n.location?.latitude,lng:n.location?.longitude,limit:n.limit,cursor:n.cursor}}):Ct()},recentClinics(n){return km.safeParse(n).success?t("recent",{method:"GET",path:`${vt}/clinics/recent`,query:{limit:n.limit}}):Ct()},getRequestGroup(n){return Bl.safeParse(n).success?t("requestGroup",{method:"GET",path:`${vt}/request-groups/${encodeURIComponent(n)}`}):Ct()},getAuthorizationCopy:i(()=>t("authorizationCopy",{method:"GET",path:`${vt}/authorization-copy`}),"getAuthorizationCopy"),createClinicRequest(n){return Pm.safeParse(n).success?t("create",{method:"POST",path:`${vt}/clinic-requests`,body:{pet_ref:n.petRef,owner_name:n.ownerName,authorization_version:n.authorizationVersion,idempotency_key:n.idempotencyKey,...n.clinicId!==void 0?{clinic_id:n.clinicId}:{clinic_free_text:n.clinicFreeText},...n.clinicEmail!==void 0?{clinic_email:n.clinicEmail}:{},...n.signatureId!==void 0?{signature_id:n.signatureId}:{signature_png_base64:n.signaturePngBase64}}},true):Ct()},retryRequest:i(n=>o(n,"retry"),"retryRequest"),revokeRequest:i(n=>o(n,"revoke"),"revokeRequest"),convertToUpload:i(n=>o(n,"convert-to-upload"),"convertToUpload"),updateClinicEmail(n,s){return jl.safeParse(s).success?o(n,"clinic-email",{clinic_email:s}):Ct()},initiateSignatureUpload(n){return !Number.isInteger(n)||n<=0||n>2*1024*1024?Ct():t("signatureInitiate",{method:"POST",path:`${vt}/signatures/initiate`,body:{content_type:"image/png",file_size:n}})},completeSignatureUpload(n){return /^sig-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)?t("signatureComplete",{method:"POST",path:`${vt}/signatures/complete`,body:{upload_id:n}}):Ct()}}}i(Vl,"createHttpRecordsClinicRepository");function Ct(){return Promise.resolve(J(H("validationFailed",{retryable:false})))}i(Ct,"invalid");function zr(){let{runtime:e,userRef:r,scopeEpoch:t}=se(),o=react.useMemo(()=>{let{services:s}=e.registry;return $l({repository:Vl({auth:s.authFor(r),...s.errorPolicy?{errorPolicy:s.errorPolicy}:{}})})},[e,r,t]),n=react.useRef(o);return react.useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),react.useMemo(()=>{let s=i(async a=>{if(r===null||n.current!==o)return J(H("accessDenied"));let c=await a();return n.current===o?c:J(H("accessDenied"))},"run");return {searchClinics:i(a=>s(()=>o.searchClinics(a)),"searchClinics"),recentClinics:i(a=>s(()=>o.recentClinics(a)),"recentClinics"),getRequestGroup:i(a=>s(()=>o.getRequestGroup(a)),"getRequestGroup"),getAuthorizationCopy:i(()=>s(()=>o.getAuthorizationCopy()),"getAuthorizationCopy"),createClinicRequest:i(a=>s(()=>o.createClinicRequest(a)),"createClinicRequest"),retryRequest:i(a=>s(()=>o.retryRequest(a)),"retryRequest"),revokeRequest:i(a=>s(()=>o.revokeRequest(a)),"revokeRequest"),updateClinicEmail:i((a,c)=>s(()=>o.updateClinicEmail(a,c)),"updateClinicEmail"),convertToUpload:i(a=>s(()=>o.convertToUpload(a)),"convertToUpload"),initiateSignatureUpload:i(a=>s(()=>o.initiateSignatureUpload(a)),"initiateSignatureUpload"),completeSignatureUpload:i(a=>s(()=>o.completeSignatureUpload(a)),"completeSignatureUpload")}},[o,r])}i(zr,"useEverfurRecordsClinic");function ra(){let{runtime:e,userRef:r,scopeEpoch:t}=se(),o=react.useMemo(()=>{let{services:s}=e.registry;return zl({auth:s.authFor(r),...s.errorPolicy?{errorPolicy:s.errorPolicy}:{}})},[e,r,t]),n=react.useRef(o);return react.useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),react.useMemo(()=>({async createClinicRequestBatch(s){if(r===null||n.current!==o)return J(H("accessDenied"));let a=await o.createClinicRequestBatch(s);return n.current===o?a:J(H("accessDenied"))}}),[o,r])}i(ra,"useEverfurRecordsClinicBatch");var Tm=120,Dm=44;function Im({reason:e,onExit:r,exitLabel:t,style:o,className:n}){let{color:s,space:a,radius:c,type:l}=ye();return jsxRuntime.jsxs("div",{className:n,"data-testid":"records-gate-off",style:{boxSizing:"border-box",minHeight:Tm,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-start",gap:a.md,padding:a.lg,borderRadius:c.md,border:`1px solid ${s.brandBorder}`,backgroundColor:s.surfaceCream,color:s.text.primary,...o},children:[e.length>0?jsxRuntime.jsx("p",{style:{margin:0,fontSize:l.size.bodyTight,color:s.text.muted},children:e}):null,jsxRuntime.jsx("button",{type:"button",onClick:r,"data-testid":"records-gate-off-exit",style:{minHeight:Dm,padding:`0 ${a.lg}px`,borderRadius:c.pill,border:`1.5px solid ${s.brandInk}`,backgroundColor:"transparent",color:s.brandInk,font:"inherit",fontSize:l.size.body,cursor:"pointer"},children:t})]})}i(Im,"RecordsGateOffState");function Fe(e,r){return e===void 0?{}:{renderDisabled:i(t=>jsxRuntime.jsx(Im,{reason:t.disabled?.reason??"",onExit:e,exitLabel:r}),"renderDisabled")}}i(Fe,"recordsGateExit");function Am(e,r){if(e===void 0)return {};let t={};return e.backgroundColor!==void 0&&(t.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(t.borderColor=e.borderColor,t.borderWidth=r??1),e.borderRadius!==void 0&&(t.borderRadius=e.borderRadius),t}i(Am,"slotBox");function tt(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(tt,"slotText");function Mr(e,r){let t=Am(e,r),o={};return t.backgroundColor!==void 0&&(o.backgroundColor=t.backgroundColor),t.borderColor!==void 0&&(o.border=`${t.borderWidth??1}px solid ${t.borderColor}`),t.borderRadius!==void 0&&(o.borderRadius=t.borderRadius),o}i(Mr,"slotBoxCss");var Yl=Object.freeze([.23,1,.32,1]),St=Object.freeze({pressScale:.97,pressMs:160,riseWebPx:16,riseNativePx:14,fadeMs:320,moveMs:480,staggerMs:55,maxSteps:8});var oa=An(Yl);function Ql(e=false){let r=ye(),[t,o]=react.useState(false),n=r.motion.reducedMotion||e,s=react.useCallback(()=>o(true),[]),a=react.useCallback(()=>o(false),[]);return {style:n?{}:{transform:t?`scale(${St.pressScale})`:"none",transition:`transform ${St.pressMs}ms ${oa}`},handlers:{onPointerDown:s,onPointerUp:a,onPointerLeave:a,onPointerCancel:a}}}i(Ql,"usePressScale");function xt(){let r=ye().motion.reducedMotion,t=react.useRef(false),o=react.useRef([]);return react.useEffect(()=>()=>{for(let n of o.current)n.cancel();},[]),react.useCallback(n=>{n===null||t.current||r||(t.current=true,Array.from(n.children).forEach((s,a)=>{if(typeof s.animate!="function")return;let c=Math.min(a,St.maxSteps-1)*St.staggerMs;try{o.current.push(s.animate([{transform:`translateY(${St.riseWebPx}px)`},{transform:"none"}],{duration:St.moveMs,delay:c,easing:oa,fill:"backwards"}),s.animate([{opacity:0},{opacity:1}],{duration:St.fadeMs,delay:c,easing:oa,fill:"backwards"}));}catch{}}));},[r])}i(xt,"useSectionRise");var Ft="data-ef-screen-heading";function Jl(e){return e.focus(),document.activeElement===e}i(Jl,"focusTook");function Lm(e){let r=e.querySelector(`[${Ft}]`);if(r!==null&&(r.textContent??"").trim().length>0&&Jl(r)||Jl(e))return;let t=e.firstElementChild;t instanceof HTMLElement&&(t.hasAttribute("tabindex")||(t.setAttribute("tabindex","-1"),t.style.outline="none"),t.focus());}i(Lm,"focusScreen");function rn(e){let r=react.useRef(null),t=react.useRef(e);return react.useEffect(()=>{if(Object.is(t.current,e))return;t.current=e;let o=r.current;o!==null&&Lm(o);},[e]),r}i(rn,"useFocusScreenOnChange");var Mm=120,qt=44,$m=52,Me="Back";function V(){let e=ye(),r=react.useMemo(()=>Bm(e),[e]);return {theme:e,styles:r}}i(V,"useScreenStyles");function Ke({title:e,onBack:r,right:t,testID:o,variant:n="brand"}){let{styles:s}=V();return jsxRuntime.jsxs("header",{style:s.headerRow,"data-testid":o,children:[r?jsxRuntime.jsx("button",{type:"button",onClick:r,"aria-label":Me,style:s.iconButton,"data-testid":o?`${o}-back`:void 0,children:jsxRuntime.jsx("span",{"aria-hidden":"true",style:s.backChevron})}):jsxRuntime.jsx("span",{style:s.iconButton}),e.trim().length>0?jsxRuntime.jsx("h2",{tabIndex:-1,[Ft]:"",style:n==="document"?s.documentTitle:s.headerTitle,children:e}):jsxRuntime.jsx("span",{"aria-hidden":"true",style:s.headerTitle,"data-testid":o?`${o}-spacer`:void 0}),jsxRuntime.jsx("div",{style:s.headerRight,children:t??jsxRuntime.jsx("span",{style:s.iconButton})})]})}i(Ke,"ScreenHeader");function wt({disclaimer:e,style:r}){let{styles:t}=V();return e.trim().length===0?null:jsxRuntime.jsxs("p",{role:"note","aria-label":yr.important(e),style:{...t.band,...r},"data-testid":"records-disclaimer-band",children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:t.infoGlyph,children:"i"}),jsxRuntime.jsx("span",{style:t.bandText,children:e})]})}i(wt,"DisclaimerBand");function j({label:e,onClick:r,kind:t="primary",disabled:o=false,busy:n=false,ariaLabel:s,ariaDescribedBy:a,testID:c,style:l}){let{styles:d}=V(),u=Ql(o||n),p=t==="primary"?d.pillPrimary:t==="outline"?d.pillOutline:t==="danger"?d.pillDanger:t==="ask"?d.pillAsk:d.pillLink;return jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:o||n,"aria-busy":n,"aria-label":s,"aria-describedby":a,...u.handlers,style:{...d.pill,...p,...o?d.pillDisabled:{},...u.style,...l},"data-testid":c,children:e})}i(j,"Pill");function br({label:e,tone:r="neutral",testID:t}){let{styles:o}=V(),n=e.length>Um;return jsxRuntime.jsx("span",{style:{...o.chip,...n?o.chipSentence:{},...o.chipTones[r]},"data-testid":t,children:e})}i(br,"Chip");var Um=24;function $r({title:e,count:r}){let{styles:t}=V();return jsxRuntime.jsxs("div",{style:t.sectionHeader,children:[jsxRuntime.jsx("h3",{style:t.sectionTitle,children:e}),r!==void 0?jsxRuntime.jsx("span",{style:t.sectionCount,children:r}):null]})}i($r,"SectionHeader");function ia({name:e,color:r}){return jsxRuntime.jsx("svg",{"aria-hidden":"true",focusable:"false",width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block",flexShrink:0},"data-glyph":e,children:e==="send"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),jsxRuntime.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:"18",cy:"5",r:"3"}),jsxRuntime.jsx("circle",{cx:"6",cy:"12",r:"3"}),jsxRuntime.jsx("circle",{cx:"18",cy:"19",r:"3"}),jsxRuntime.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),jsxRuntime.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})})}i(ia,"HeaderGlyph");function kt({direction:e="right"}){let{styles:r}=V(),t=e==="right"?"45deg":e==="down"?"135deg":"-45deg";return jsxRuntime.jsx("span",{"aria-hidden":"true",style:{...r.chevron,transform:`rotate(${t})`}})}i(kt,"Chevron");function Bm(e){let{color:r,space:t,radius:o,type:n,slots:s}=e,a=i((g,f)=>`${Math.round(g*f)}px`,"lh"),c=i((g,f,v,b="regular")=>({margin:0,...D(e,b),fontSize:g,lineHeight:a(g,f),color:v}),"text"),l=tt(s.recordCard),d=e.brightness==="dark"?r.errorRed:r.danger,u=i((g,f)=>({backgroundColor:g,color:f,border:"1.5px solid transparent"}),"tone"),p=i((g,f)=>({backgroundColor:r.surface,color:f,border:`1.5px solid ${g}`}),"edge"),m=`1px solid ${r.borderRingCream}`,y={boxSizing:"border-box",minHeight:$m,minWidth:qt,padding:`${t.md}px ${t.lg+t.xs/2}px`,borderRadius:o.pill,...D(e,"bold"),fontSize:n.size.body,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:t.sm,textDecoration:"none"};return {chipTones:{neutral:p(r.brandBorderStrong,r.text.primary),info:u(r.brandSoft,r.brandInk),warning:p(r.cautionAccent,r.text.primary),critical:p(r.danger,r.danger),positive:p(r.success,r.brandInk)},root:{...Rt,boxSizing:"border-box",display:"flex",flexDirection:"column",minHeight:Mm,height:"100%",backgroundColor:r.background,color:r.text.primary,...D(e,"regular")},body:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",overflowY:"auto"},content:{display:"flex",flexDirection:"column",gap:t.lg,padding:`0 ${t.lg}px ${t.xxl}px`},contentTight:{display:"flex",flexDirection:"column",gap:t.lg,padding:`0 ${t.sm}px ${t.xxl}px`},inset:{padding:`0 ${t.sm}px`},headerRow:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:t.sm,padding:`${t.xs}px ${t.lg}px ${t.md}px`},iconButton:{boxSizing:"border-box",width:qt,height:qt,display:"inline-flex",alignItems:"center",justifyContent:"center",border:0,background:"transparent",cursor:"pointer",padding:0,color:r.brandInk,flexShrink:0},backChevron:{display:"block",width:t.md,height:t.md,borderLeft:`2px solid ${r.brandInk}`,borderBottom:`2px solid ${r.brandInk}`,transform:"rotate(45deg)",marginLeft:t.xs},headerTitle:{...c(n.size.heading,n.lineHeight.tight,r.brandInk,"bold"),flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},documentTitle:{...c(n.size.subtitle,n.lineHeight.snug,r.text.primary,"bold"),flex:1,textAlign:"center"},headerRight:{display:"flex",alignItems:"center",gap:t.sm+t.xs/2},section:{display:"flex",flexDirection:"column",gap:t.sm+t.xs/2},sectionHeader:{display:"flex",alignItems:"center",gap:t.sm,padding:`0 ${t.xs}px`},sectionTitle:{...c(n.size.subtitle,n.lineHeight.snug,r.text.primary,"bold"),letterSpacing:"-0.02em"},sectionCount:{...c(n.size.bodyTight,n.lineHeight.snug,r.text.muted,"medium")},card:{boxSizing:"border-box",borderRadius:o.lg,border:m,backgroundColor:r.surface,padding:`${t.xs}px ${t.lg}px`,margin:0,listStyle:"none",...Mr(s.recordCard,1)},creamCard:{boxSizing:"border-box",borderRadius:o.lg,border:m,backgroundColor:r.surfaceCream,padding:t.lg,display:"flex",flexDirection:"column",gap:t.md,...Mr(s.recordCard,1)},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:t.md,padding:`${t.md}px 0`},rowDivider:{borderTop:`1px solid ${r.borderHairlineGreen}`},rowMain:{flex:1,minWidth:0},rowRight:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:t.xs+t.xs/2},rowTitle:{...c(n.size.body,n.lineHeight.snug,r.text.primary,"medium"),...l},rowDetail:{...c(n.size.caption,n.lineHeight.normal,r.text.secondary),marginTop:t.xs/2,...l},rowValue:{...c(n.size.body+1,n.lineHeight.snug,r.text.primary,"bold"),marginTop:t.xs/2,...l},rowMuted:{...c(n.size.caption,n.lineHeight.normal,r.text.muted),...l},chip:{boxSizing:"border-box",display:"inline-flex",alignItems:"center",minHeight:24,borderRadius:o.pill,padding:`0 ${t.sm+t.xs/2}px`,...D(e,"monoBold"),fontSize:n.size.tiny+1,lineHeight:a(n.size.tiny+1,n.lineHeight.snug),letterSpacing:"0.06em",textTransform:"uppercase",whiteSpace:"nowrap"},pill:y,pillPrimary:{border:0,backgroundColor:r.brand,color:r.onPrimary,...Mr(s.primaryButton),...tt(s.primaryButton)},pillOutline:{border:`1.5px solid ${r.brandInk}`,backgroundColor:"transparent",color:r.brandInk},pillDanger:{border:`1.4px solid ${r.danger}`,backgroundColor:r.surface,color:r.danger,fontSize:n.size.bodyTight},pillAsk:{border:`1px solid ${r.borderRingCream}`,backgroundColor:r.surface,color:r.text.primary},pillLink:{minHeight:qt,border:0,backgroundColor:"transparent",color:r.linkInk,padding:`${t.sm}px`},pillDisabled:{opacity:.5,cursor:"default"},infoNote:{display:"flex",gap:t.sm,borderRadius:o.md-t.xs/2,backgroundColor:r.brandSoft,padding:`${t.sm+t.xs/2}px ${t.md}px`,...c(n.size.bodyTight,n.lineHeight.normal,r.text.primary)},cautionNote:{display:"flex",gap:t.sm,borderRadius:o.md-t.xs/2,backgroundColor:r.badgeBgCaution,padding:`${t.sm+t.xs/2}px ${t.md}px`,...c(n.size.bodyTight,n.lineHeight.normal,r.warningStrong)},statusCard:{borderRadius:o.md,backgroundColor:r.brandSoft,padding:t.md+t.xs/2,...c(n.size.bodyTight,n.lineHeight.relaxed,r.text.primary)},errorBanner:{display:"flex",gap:t.sm,borderRadius:o.md-t.xs/2,backgroundColor:r.badgeBgCritical,padding:t.md,...c(n.size.bodyTight,n.lineHeight.normal,d)},errorText:c(n.size.bodyTight,n.lineHeight.normal,d),band:{display:"flex",alignItems:"flex-start",gap:t.sm,borderRadius:o.md-t.xs/2,padding:t.md,backgroundColor:r.brandSoft,margin:0},bandText:{flex:1,...c(n.size.caption,n.lineHeight.normal,r.text.secondary)},infoGlyph:{boxSizing:"border-box",flexShrink:0,width:t.md+t.xs/2,height:t.md+t.xs/2,borderRadius:o.pill,border:`1px solid ${r.text.secondary}`,display:"inline-flex",alignItems:"center",justifyContent:"center",...D(e,"bold"),fontSize:n.size.small,color:r.text.secondary},chevron:{display:"inline-block",width:t.sm,height:t.sm,borderTop:`2px solid ${r.text.muted}`,borderRight:`2px solid ${r.text.muted}`,flexShrink:0},chipSentence:{...D(e,"medium"),fontSize:n.size.caption,lineHeight:a(n.size.caption,n.lineHeight.normal),letterSpacing:"normal",textTransform:"none",whiteSpace:"normal",borderRadius:o.md,padding:`${t.xs}px ${t.sm+t.xs/2}px`},lead:{...c(n.size.body+1,n.lineHeight.snug,r.text.primary,"bold"),padding:`0 ${t.sm}px`},subLead:{...c(n.size.body,n.lineHeight.normal,r.text.muted),padding:`0 ${t.lg}px ${t.md}px`},field:{boxSizing:"border-box",display:"block",width:"100%",minHeight:qt,padding:`${t.sm}px ${t.md}px`,border:`1px solid ${r.borderHairlineGreen}`,borderRadius:o.sm,color:r.text.primary,backgroundColor:r.surface,...D(e,"regular"),fontSize:n.size.body},fieldLabel:{...c(n.size.bodyTight,n.lineHeight.normal,r.text.secondary,"medium"),display:"block",marginBottom:t.xs},muted:c(n.size.caption,n.lineHeight.normal,r.text.muted),bodyText:c(n.size.body,n.lineHeight.normal,r.text.primary),mono:D(e,"mono"),plainList:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column"},dialogFrame:{boxSizing:"border-box",position:"fixed",top:0,right:0,bottom:0,left:0,width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0,padding:0,border:0,backgroundColor:"transparent",overflow:"hidden"},dialogScrim:{boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:t.lg,backgroundColor:"rgba(0,0,0,0.4)"},dialogScrimSide:{boxSizing:"border-box",display:"flex",alignItems:"stretch",justifyContent:"flex-end",width:"100%",height:"100%",backgroundColor:"rgba(0,0,0,0.4)"},dialogPanel:{boxSizing:"border-box",width:"100%",maxWidth:560,maxHeight:"100%",overflowY:"auto",backgroundColor:r.surface,borderRadius:o.xl-1,padding:`${t.lg}px ${t.lg+t.xs+t.xs/2}px`,display:"flex",flexDirection:"column",gap:t.md,...D(e,"regular"),color:r.text.primary},dialogPanelSide:{boxSizing:"border-box",width:"min(100vw, 480px)",height:"100%",maxHeight:"100%",overflowY:"auto",backgroundColor:r.surface,padding:`${t.lg}px ${t.lg+t.xs+t.xs/2}px`,display:"flex",flexDirection:"column",gap:t.md,...D(e,"regular"),color:r.text.primary},sheetHeader:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:t.sm},sheetTitle:{...c(n.size.heading,n.lineHeight.snug,r.text.primary,"bold")},sheetHelper:c(n.size.bodyTight,n.lineHeight.normal,r.text.muted),closeGlyph:{fontSize:n.size.verdict,lineHeight:1,color:r.text.primary}}}i(Bm,"makeScreenStyles");function tn(e,r){return e===null?"":r?`${e} ${r}`:e}i(tn,"formatEntityValue");function aa(e){if(e===null||e.length===0)return "";let r=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(r!==null){let n=r[1]??"",s=r[2]??"",a=r[3]??"";return `${Number(s)}/${Number(a)}/${n.slice(2)}`}let t=Date.parse(e);if(Number.isNaN(t))return e;let o=new Date(t);return `${o.getUTCMonth()+1}/${o.getUTCDate()}/${String(o.getUTCFullYear()).slice(2)}`}i(aa,"formatShortDate");var ed=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ee(e){if(!e)return "-";let r=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(r!==null){let n=ed[Number(r[2])-1];return n===void 0?"-":`${n} ${Number(r[3])}, ${r[1]}`}let t=Date.parse(e);if(Number.isNaN(t))return "-";let o=new Date(t);return `${ed[o.getUTCMonth()]} ${o.getUTCDate()}, ${o.getUTCFullYear()}`}i(ee,"formatRecordsDate");function rd(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let r=ee(e),t=Number(e.slice(8,10));return r==="-"||t<1||t>31?e:r}i(rd,"formatIdentityValue");var ge=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:i(e=>`Measured ${e}`,"measured"),uploadedDocument:"Uploaded document",kind:Object.freeze({visit:"Visit",vaccine:"Vaccine",weight:"Weight",medication:"Medication"}),clinicVisit:"Clinic visit",doctor:i(e=>`Dr. ${e}`,"doctor"),lot:i(e=>`Lot ${e}`,"lot"),expires:i(e=>`Expires ${e}`,"expires")});function nt(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}}}i(nt,"markerStatusLabel");function nn(e,r){return r<2?null:`${e==="flat"?"Holding steady":`Trending ${e==="down"?"down":e==="up"?"up":"steady"}`} over ${r} visits`}i(nn,"trajectoryLabel");function ot(e){let r=e.replace(/_/g," ").trim();return r.length===0?e:r.charAt(0).toUpperCase()+r.slice(1)}i(ot,"humanize");var td=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 on(e){return Object.prototype.hasOwnProperty.call(td,e)?td[e]:ot(e)}i(on,"bodySystemLabel");var nd=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 an(e){return Object.prototype.hasOwnProperty.call(nd,e)?nd[e]:ot(e)}i(an,"soapSectionLabel");function od(e){return e===null||!Number.isFinite(e)?"-":`${e.toFixed(3).replace(/\.?0+$/,"")} kg`}i(od,"formatWeightKg");function hr(e,r,t){if((e===null||!Number.isFinite(e))&&t)return t;if(e===null||!Number.isFinite(e))return "-";let o=e.toFixed(3).replace(/\.?0+$/,"");return r?`${o} ${r}`:o}i(hr,"formatMarkerReading");function sa(e,r,t){let o=nn(r,t);return e?`${ge.measured(ee(e))}${o?` \xB7 ${o}`:""}`:o}i(sa,"labDetailLine");var Po=Object.freeze({idle:Object.freeze({title:"Find your pet\u2019s clinic",body:"Search for the clinic that holds your pet\u2019s records. We\u2019ll request them on your behalf once you sign the authorization.",action:null}),no_requests:Object.freeze({title:"No record requests yet",body:"When you request records from a clinic, you\u2019ll be able to track every step here.",action:null}),no_records:Object.freeze({title:"Nothing to show just yet",body:"Once your pet\u2019s records arrive and our team reviews them, lab trends and visits will appear here.",action:null}),rate_limited:Object.freeze({title:"Slow down a moment",body:"You\u2019ve made a lot of requests just now. You can try again shortly.",action:"Try again"}),service_unavailable:Object.freeze({title:"Records search is temporarily down",body:"We\u2019re working on it. Please try again in a few minutes.",action:"Try again"}),error:Object.freeze({title:"Couldn\u2019t reach Everfur",body:"Check your connection and try again.",action:"Try again"})}),la=60;function id(e){return `Try again in ${e}s`}i(id,"coolingActionLabel");var ad="Try again, available shortly";var K=Object.freeze({title:"Visits & records",shareA11y:"Share medical record",requestClinicsA11y:"Request records from clinics",inReview:i(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.`,"inReview"),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: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:i(e=>`${e} ${e===1?"document":"documents"} on file`,"documentsOnFile"),inReviewChip:i(e=>`${e} in review`,"inReviewChip"),beingVerified:i(e=>`${e} being verified`,"beingVerified"),beingVerifiedA11y:i(e=>`${e} ${e===1?"fact is":"facts are"} being verified`,"beingVerifiedA11y"),pendingReview:"Pending review: ",dateRange:i((e,r)=>`${ee(e)} to ${ee(r)}`,"dateRange"),documents:"Sources on file",uploadedDocument:ge.uploadedDocument,documentRowA11y:i(e=>`View what ${e} contributed to this record`,"documentRowA11y"),documentMeta:i((e,r)=>{let t=r?ee(r):null,n=[e!==null&&Number.isInteger(e)&&e>0?`${e} ${e===1?"page":"pages"}`:null,t].filter(s=>s!==null);return n.length>0?n.join(" \xB7 "):null},"documentMeta"),identity:"Identity",needsReview:"Needs review",upcomingCare:"Upcoming care",careTimeline:"Care timeline",careTimelineSub:"Related records grouped over time, newest first.",lastDone:i(e=>`Last done ${e}`,"lastDone"),overdue:"Overdue",due:i(e=>`Due ${e}`,"due"),askUpcomingCare:"Ask Everfur about upcoming care",askEverfur:"Ask Everfur",askExam:"Ask Everfur about this exam",askVisit:"Ask Everfur about this visit",labResults:ge.labResults,visits:ge.visits,physicalExams:ge.physicalExams,visitNotes:ge.visitNotes,document:Object.freeze({title:"Health Record",titleFor:i(e=>{let r=e?.trim()??"";return r.length>0?`${r}\u2019s health record`:"Health Record"},"titleFor"),download:"Download PDF",empty:"This record is empty for now.",docTitle:"Medical Record",namelessPet:"Your pet",generated:i(e=>`Generated ${ee(e)}`,"generated"),identity:"Identity",labs:"Blood & Lab Work",ref:i(e=>`Ref ${e}`,"ref"),noRange:"No reference range",upcomingCare:"Upcoming Care",physicalExams:"Physical Exams",clinicianNotes:"Clinician Notes"})}),sd=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 ct(e){return Object.prototype.hasOwnProperty.call(sd,e)?sd[e]:ot(e)}i(ct,"entityTypeLabel");var To=Object.freeze(["vaccination","medication","problem","procedure","allergy","parasite_prevention","reproductive","vital","body_weight"]);function Do(e){let r=To.filter(o=>e.includes(o)),t=e.filter(o=>!To.includes(o));return [...r,...t]}i(Do,"orderEntityTypes");function Io(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"}}}i(Io,"conflictSeverityMeta");function Nn(e,r){if(!e)return null;let t=Date.parse(e);if(Number.isNaN(t))return null;let o=t<r-1440*60*1e3;return {label:o?K.overdue:K.due(ee(e)),overdue:o}}i(Nn,"dueBadge");function ld(e){return e===null?null:e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}`:e.refLow!==null?`\u2265 ${e.refLow}`:e.refHigh!==null?`\u2264 ${e.refHigh}`:null}i(ld,"formatReferenceBand");var Q=Object.freeze({openA11y:"Share medical record",openA11yFor:i(e=>{let r=e?.trim()??"";return r.length>0?`Share ${r}\u2019s record`:"Share medical record"},"openA11yFor"),title:"Share medical record",titleFor:i(e=>{let r=e?.trim()??"";return r.length>0?`Send ${r}\u2019s record`:"Share medical record"},"titleFor"),helper:"Anyone with an active link can view this record until it expires. You can turn a link off anytime.",leadNative:"Pick who it\u2019s for; we include the right pages.",leadWebFor:i(e=>{let r=e?.trim()??"";return r.length>0?`Share a snapshot of what ${r}\u2019s vets recorded. Pick who it\u2019s for and we include the right pages.`:"Pick who it\u2019s for; we include the right pages."},"leadWebFor"),audienceLabel:"Who it\u2019s for",audiences:Object.freeze({vet:"Vet",groomer:"Groomer",boarding:"Boarding"}),included:"What\u2019s included",sendTo:"Send to",sendToPlaceholder:"vet@example.com\u2026",send:"Send",sending:"Sending\u2026",addEmailFor:i(e=>{let r=e?.trim()??"";return r.length>0?`Add an email to send ${r}\u2019s record.`:"Add an email to send the record."},"addEmailFor"),emailInvalid:"That email doesn\u2019t 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\u2019t 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",copyLinkA11y:i(e=>`Copy share link, ${e}`,"copyLinkA11y"),turnOff:"Turn off",turnOffA11y:i(e=>`Turn off share link, ${e}`,"turnOffA11y"),turningOff:"Turning off...",keep:"Keep",confirmTurnOff:"Turn off this link? Anyone who has it will lose access.",shareMessage:i(e=>`View this medical record: ${e}`,"shareMessage"),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: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:i(e=>`Couldn\u2019t copy. The link is ${e}`,"copyFailedNative"),turnedOff:"Link turned off.",sentTo:i(e=>`Sent to ${e}. The link works for 7 days.`,"sentTo")})}),Hm=Object.freeze(["Vaccines, medications and allergies","Conditions and procedures, with dates"]),jm=Object.freeze([["encounters","encounters",ge.visits],["lab_results","markers",ge.labResults],["physical_exams","physical_exams",ge.physicalExams]]);function dd(e,r){let t=[];e.sections.includes("entities")&&(e.entityTypes===null?t.push(...Hm):t.push(...Do(e.entityTypes).map(ct)));for(let[o,n,s]of jm)e.sections.includes(o)&&r[n]===true&&t.push(s);return e.sections.includes("forward_looking")&&t.push(K.upcomingCare),Object.freeze(t)}i(dd,"shareIncludedLines");function Vm(e,r){if(!e)return false;let t=Date.parse(e);return Number.isNaN(t)?false:t<=r}i(Vm,"isShareExpired");function Wm(e,r){let t=ee(e);return t==="-"?r?"Expired":"No expiry date":r?`Expired ${t}`:`Expires ${t}`}i(Wm,"formatShareExpiry");function cd(e,r,t){let o=e.map(n=>{let s=Vm(n.expiresAt,t),a=Wm(n.expiresAt,s),c=ee(n.createdAt),l=s?"Expired":"Active",d=a.replace(/^Expires /,"expiring ").replace(/^Expired /,"expired ").replace(/^Expired$/,"expired").replace(/^No expiry date$/,"with no expiry date");return {shareId:n.shareId,shareUrl:r[n.shareId]??null,active:!s,statusLabel:l,expiryLabel:a,createdLabel:c==="-"?null:`Created ${c}`,a11yLabel:`Share link. ${l}. ${a}.`,actionContext:d}});return Object.freeze([...o.filter(n=>n.active),...o.filter(n=>!n.active)])}i(cd,"buildShareRows");function _t(e,r){let t=e?.httpStatus;if(Yr(e)){if(r==="create"||r==="email")return "Records access for this pet is off, so a new link cannot be created.";if(r==="download")return "Records access for this pet is off, so the PDF cannot be downloaded."}if(t===429)return "You are creating links a little too fast. Wait a moment, then try again.";if(r==="revoke"&&(t===404||t===409||t===410))return "That link was already turned off.";if(t===401||t===403)return "You need to be signed in as this pet's owner to do that.";if(r==="email"&&(t===400||t===422||e?.code==="validationFailed"))return Q.emailInvalid;switch(r){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 Q.emailFailed;default:return "Could not download the record PDF. Please try again."}}i(_t,"shareErrorMessage");function ve({width:e,height:r,radius:t,style:o}){let{color:n,radius:s}=ye();return jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"block",width:e,height:r,borderRadius:t??s.xs,backgroundColor:n.skeleton,flexShrink:0,...o}})}i(ve,"SkeletonBlock");var da=180,pd=44,ca=62;function sn({testID:e}){let r=ln(),t=i(o=>jsxRuntime.jsxs("div",{style:r.actionRow,children:[jsxRuntime.jsxs("div",{style:r.actionLeft,children:[jsxRuntime.jsx(ve,{width:18,height:18,radius:9}),jsxRuntime.jsx(ve,{width:"55%",height:14,radius:7})]}),jsxRuntime.jsx(ve,{width:18,height:18,radius:9})]},o),"action");return jsxRuntime.jsxs("div",{role:"progressbar","aria-label":yr.loading,"aria-busy":"true",style:r.dashboard,"data-testid":e,children:[jsxRuntime.jsx("div",{style:r.inset,children:jsxRuntime.jsxs("div",{style:r.summaryCard,children:[jsxRuntime.jsx(ve,{width:da,height:da,radius:da/2}),jsxRuntime.jsxs("div",{style:r.badges,children:[jsxRuntime.jsx(ve,{width:70,height:22,radius:11}),jsxRuntime.jsx(ve,{width:70,height:22,radius:11})]})]})}),jsxRuntime.jsx("div",{style:r.inset,children:jsxRuntime.jsx(ve,{width:150,height:16,radius:8})}),jsxRuntime.jsx("div",{style:r.carouselCard,children:jsxRuntime.jsx(ve,{width:"100%",height:300,radius:14})}),jsxRuntime.jsxs("div",{style:r.dots,children:[jsxRuntime.jsx(ve,{width:6,height:6,radius:3}),jsxRuntime.jsx(ve,{width:18,height:6,radius:3}),jsxRuntime.jsx(ve,{width:6,height:6,radius:3})]}),jsxRuntime.jsx("div",{style:r.centered,children:jsxRuntime.jsx(ve,{width:46,height:12,radius:6})}),jsxRuntime.jsx("div",{style:r.inset,children:jsxRuntime.jsx(ve,{width:"100%",height:pd,radius:12})}),jsxRuntime.jsxs("div",{style:{...r.inset,...r.actions},children:[t("a"),t("b")]})]})}i(sn,"DashboardSkeleton");function Oo({testID:e}){let r=ln();return jsxRuntime.jsxs("div",{role:"progressbar","aria-label":le.loading,"aria-busy":"true",style:r.request,"data-testid":e,children:[jsxRuntime.jsx("div",{children:[0,1,2,3].map(t=>jsxRuntime.jsxs("div",{style:r.railRow,children:[jsxRuntime.jsxs("div",{style:r.railColumn,children:[jsxRuntime.jsx(ve,{width:24,height:24,radius:12}),t<3?jsxRuntime.jsx(ve,{width:2,height:20,radius:1}):null]}),jsxRuntime.jsxs("div",{style:r.railBody,children:[jsxRuntime.jsx(ve,{width:"55%",height:14,radius:7}),jsxRuntime.jsx(ve,{width:"75%",height:11,radius:6})]})]},t))}),jsxRuntime.jsxs("div",{style:r.statusCard,children:[jsxRuntime.jsx(ve,{width:"90%",height:13,radius:6}),jsxRuntime.jsx(ve,{width:"60%",height:13,radius:6})]}),jsxRuntime.jsx(ve,{width:"100%",height:50,radius:25})]})}i(Oo,"RequestSkeleton");function md({testID:e}){let r=ln();return jsxRuntime.jsxs("div",{role:"progressbar","aria-label":ge.loadingTimeline,"aria-busy":"true",style:r.timeline,"data-testid":e,children:[jsxRuntime.jsx("div",{style:r.timelineDisclaimer,children:jsxRuntime.jsx(ve,{width:"100%",height:pd,radius:12})}),Array.from({length:6},(t,o)=>jsxRuntime.jsxs("div",{children:[o>0?jsxRuntime.jsx("div",{style:r.timelineSeparator}):null,jsxRuntime.jsxs("div",{style:r.timelineRow,children:[jsxRuntime.jsx(ve,{width:34,height:34,radius:17}),jsxRuntime.jsxs("div",{style:r.timelineBody,children:[jsxRuntime.jsxs("div",{style:r.timelineTop,children:[jsxRuntime.jsx(ve,{width:44,height:10,radius:5}),jsxRuntime.jsx(ve,{width:56,height:12,radius:6})]}),jsxRuntime.jsx(ve,{width:"70%",height:14,radius:7}),o%2===0?jsxRuntime.jsx(ve,{width:"45%",height:12,radius:6}):null]})]})]},o))]})}i(md,"TimelineSkeleton");function fd({testID:e}){let r=ln();return jsxRuntime.jsx("div",{role:"progressbar","aria-label":we.loading,"aria-busy":"true",style:r.clinics,"data-testid":e,children:Array.from({length:5},(t,o)=>jsxRuntime.jsxs("div",{style:r.clinicRow,children:[jsxRuntime.jsx(ve,{width:"65%",height:14,radius:7}),jsxRuntime.jsx(ve,{width:"40%",height:11,radius:6})]},o))})}i(fd,"ClinicsSkeleton");function yd({testID:e}){let r=ln();return jsxRuntime.jsx("div",{role:"progressbar","aria-label":Q.loadingLinks,"aria-busy":"true",style:r.shares,"data-testid":e,children:[0,1].map(t=>jsxRuntime.jsxs("div",{style:r.shareRow,children:[jsxRuntime.jsx(ve,{width:"55%",height:13}),jsxRuntime.jsx(ve,{width:"40%",height:11})]},t))})}i(yd,"SharesSkeleton");function He({variant:e,onAction:r,message:t,testID:o}){let n=ln(),s=Po[e],[a,c]=react.useState(e==="rate_limited"?la:0);react.useEffect(()=>{e==="rate_limited"&&c(la);},[e]),react.useEffect(()=>{if(a<=0)return;let u=setTimeout(()=>c(p=>Math.max(0,p-1)),1e3);return ()=>clearTimeout(u)},[a]);let l=e==="rate_limited"&&a>0,d=l?id(a):s.action;return jsxRuntime.jsxs("section",{role:"status",style:n.empty,"data-testid":o,children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:n.emptyGlyph}),jsxRuntime.jsx("h3",{style:n.emptyTitle,children:s.title}),jsxRuntime.jsx("p",{style:n.emptyBody,children:t??s.body}),d!==null&&r?jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:l,"aria-label":l?ad:d,style:{...n.emptyAction,...l?n.emptyActionDisabled:{}},"data-testid":o?`${o}-action`:`records-empty-${e}-action`,children:d}):null]})}i(He,"RecordsEmptyState");function ln(){let e=ye();return react.useMemo(()=>Km(e),[e])}i(ln,"useStyles");function Km(e){let{color:r,space:t,radius:o,type:n}=e,s=`1px solid ${r.brandBorder}`;return {dashboard:{display:"flex",flexDirection:"column",gap:t.lg,padding:`${t.xs}px ${t.sm}px 0`,backgroundColor:r.background},inset:{padding:`0 ${t.sm}px`},summaryCard:{display:"flex",flexDirection:"column",alignItems:"center",gap:t.md+t.xs/2,borderRadius:o.lg-t.xs,border:s,backgroundColor:r.surface,padding:`${t.lg+t.xs}px ${t.lg}px`},badges:{display:"flex",gap:t.md},carouselCard:{borderRadius:o.lg-t.xs,border:s,backgroundColor:r.surface,padding:t.lg},dots:{display:"flex",alignItems:"center",justifyContent:"center",gap:t.xs+t.xs/2},centered:{display:"flex",justifyContent:"center"},actions:{display:"flex",flexDirection:"column",gap:t.sm+t.xs/2},actionRow:{display:"flex",alignItems:"center",justifyContent:"space-between",borderRadius:o.md,border:s,backgroundColor:r.surface,padding:t.lg},actionLeft:{flex:1,display:"flex",alignItems:"center",gap:t.md},request:{display:"flex",flexDirection:"column",gap:t.lg+t.xs/2,padding:`${t.xs}px ${t.lg}px 0`},railRow:{display:"flex",alignItems:"flex-start",gap:t.md},railColumn:{display:"flex",flexDirection:"column",alignItems:"center",gap:t.xs/2,width:24},railBody:{flex:1,display:"flex",flexDirection:"column",gap:t.xs+t.xs/2,paddingBottom:t.lg+t.xs/2},statusCard:{display:"flex",flexDirection:"column",gap:t.sm,borderRadius:o.md,backgroundColor:r.brandSoft,padding:t.md+t.xs/2},timeline:{backgroundColor:r.background},timelineDisclaimer:{padding:`${t.xs}px ${t.lg}px ${t.md}px`},timelineRow:{display:"flex",gap:t.md,padding:`${t.md+t.xs/2}px ${t.lg}px`},timelineBody:{flex:1,display:"flex",flexDirection:"column",gap:t.xs-1},timelineTop:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:t.sm},timelineSeparator:{height:1,backgroundColor:r.brandBorder,marginLeft:ca},clinics:{display:"flex",flexDirection:"column",gap:t.md},clinicRow:{display:"flex",flexDirection:"column",gap:t.sm,borderRadius:o.lg-t.xs/2,border:s,backgroundColor:r.surface,padding:`${t.md+t.xs/2}px`},shares:{display:"flex",flexDirection:"column",gap:t.md,padding:t.md,borderRadius:o.md,backgroundColor:r.surfaceCream,border:s},shareRow:{display:"flex",flexDirection:"column",gap:t.xs+t.xs/2},empty:{display:"flex",flexDirection:"column",alignItems:"center",gap:t.sm+t.xs/2,padding:`${t.xxl}px ${t.xl}px`,textAlign:"center"},emptyGlyph:{boxSizing:"border-box",width:22,height:22,borderRadius:11,backgroundColor:r.brandSoft,border:s,marginBottom:t.xs},emptyTitle:{margin:0,...D(e,"bold"),fontSize:n.size.subtitle,lineHeight:`${Math.round(n.size.subtitle*n.lineHeight.snug)-1}px`,color:r.brandInk},emptyBody:{margin:0,...D(e,"regular"),fontSize:n.size.bodyTight,lineHeight:`${Math.round(n.size.bodyTight*n.lineHeight.normal)}px`,color:r.text.muted,maxWidth:320},emptyAction:{boxSizing:"border-box",marginTop:t.sm,minHeight:40,borderRadius:o.pill,padding:`0 ${t.lg+t.xs/2}px`,backgroundColor:r.brand,color:r.onPrimary,border:0,cursor:"pointer",...D(e,"bold"),fontSize:n.size.bodyTight},emptyActionDisabled:{opacity:.5,cursor:"default"}}}i(Km,"makeStyles");var Jm=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function Ln(e){let{userRef:r,scopeEpoch:t}=se();return jsxRuntime.jsx(Oe,{capability:"recordsClinic",style:e.style,className:e.className,...Fe(e.onBack,Me),children:r===null?jsxRuntime.jsx("p",{role:"alert",children:X.sessionRequired}):jsxRuntime.jsx(Zm,{...Ie(e,["onNavigate","onBack"])},JSON.stringify([r,t,e.petRef]))})}i(Ln,"EverfurClinicPicker");function Zm({petRef:e,petName:r,controller:t,recordsController:o,location:n,onNavigate:s,onBack:a,style:c,className:l}){let{theme:d,styles:u}=V(),p=zr(),m=ql(t??p,n),y=er(o?{petRef:e,controller:o}:{petRef:e}),g=react.useRef(it()),[f,v]=react.useState(false),[b,R]=react.useState(null),[h,E]=react.useState(false),[S,C]=react.useState(""),[k,M]=react.useState(false),[T,O]=react.useState(""),[z,q]=react.useState(false),N=react.useCallback(_=>{s?.({name:"consent",clinic:ea(_,null,"",g.current())});},[s]),B=i(()=>{f||(v(true),R(null),y.createRequest(`records-upload-${Date.now().toString(36)}`).then(_=>{if(v(false),!_.ok){R(le.errors.start);return}s?.({name:"request",requestId:_.value.id});}));},"startUpload"),x=k?S:m.query,L=Jm.test(T.trim()),F=x.trim().length>0&&L,W=m.isSearchActive?m.clinics:m.recent,I=m.isSearchActive?m.error?nr(m.error):!m.initialLoading&&m.clinics.length===0?"idle":null:m.recent.length>0||m.recentLoading?null:"idle",w={display:"flex",flexDirection:"column",gap:d.space.sm},A=i(_=>{let Y=_.currentTarget;Y.scrollTop+Y.clientHeight>=Y.scrollHeight-Y.clientHeight*.6&&m.loadMore();},"onScroll");return jsxRuntime.jsxs("div",{className:l,style:{...u.root,...c},"data-testid":"records-clinic-picker",children:[jsxRuntime.jsx(Ke,{title:we.titleFor(r),onBack:a,testID:"records-clinic-header"}),jsxRuntime.jsx("p",{style:u.subLead,"data-testid":"records-clinic-lead",children:we.leadWeb}),jsxRuntime.jsx("label",{htmlFor:"records-clinic-search",style:{...u.fieldLabel,padding:`0 ${d.space.lg}px`},children:we.searchLabelWeb}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:d.space.sm,margin:`0 ${d.space.lg}px ${d.space.sm}px`,padding:`0 ${d.space.md+d.space.xs/2}px`,height:44,borderRadius:22,backgroundColor:d.color.surfaceSubtle,border:`1px solid ${d.color.borderHairlineGreen}`},children:[jsxRuntime.jsx("input",{id:"records-clinic-search",type:"search",value:m.query,onChange:_=>m.setQuery(_.target.value),placeholder:we.placeholder,maxLength:200,autoComplete:"off",style:{flex:1,border:0,background:"transparent",font:"inherit",fontSize:d.type.size.body,color:d.color.text.primary,outline:"none"},"data-testid":"records-clinic-search-input"}),m.query.length>0?jsxRuntime.jsx("button",{type:"button",onClick:()=>m.setQuery(""),"aria-label":we.clearSearch,style:{...u.iconButton,width:32,height:32},"data-testid":"records-clinic-search-clear",children:jsxRuntime.jsx("span",{"aria-hidden":"true",style:u.closeGlyph,children:"\xD7"})}):null]}),s?jsxRuntime.jsxs("div",{style:{...w,padding:`0 ${d.space.lg}px ${d.space.md}px`},children:[b?jsxRuntime.jsx("p",{role:"alert",style:u.errorBanner,children:b}):null,jsxRuntime.jsx(j,{label:f?we.uploadOwnStarting:we.uploadOwn,kind:"outline",ariaLabel:we.uploadOwnA11y,busy:f,onClick:B,testID:"records-clinic-upload-own"})]}):null,jsxRuntime.jsxs("div",{style:{...u.body,...u.content,gap:d.space.md},onScroll:m.isSearchActive?A:void 0,"data-testid":"records-clinic-results",children:[m.isSearchActive?jsxRuntime.jsxs("section",{style:{...u.creamCard,borderStyle:"dashed",padding:`${d.space.md}px ${d.space.md+d.space.xs/2}px`},"data-testid":"records-clinic-fallback-card",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>E(_=>!_),"aria-expanded":h,"aria-label":h?we.fallback.collapseA11y:we.fallback.expandA11y,style:{display:"flex",alignItems:"center",gap:d.space.md,width:"100%",minHeight:44,background:"transparent",border:0,padding:0,cursor:"pointer",textAlign:"left",font:"inherit",color:"inherit"},"data-testid":"records-clinic-fallback",children:[jsxRuntime.jsxs("span",{style:{flex:1,display:"flex",flexDirection:"column",gap:d.space.xs/2},children:[jsxRuntime.jsx("span",{style:{...u.rowTitle,...D(d,"bold")},children:we.fallback.title}),jsxRuntime.jsx("span",{style:u.muted,children:we.fallback.subtitle})]}),jsxRuntime.jsx(kt,{direction:h?"up":"down"})]}),h?jsxRuntime.jsxs("div",{style:w,children:[jsxRuntime.jsx("label",{htmlFor:"records-clinic-fallback-name",style:u.fieldLabel,children:we.fallback.nameLabel}),jsxRuntime.jsx("input",{id:"records-clinic-fallback-name",style:u.field,value:x,onChange:_=>{C(_.target.value),M(true);},placeholder:we.fallback.namePlaceholder,maxLength:200,autoComplete:"off","data-testid":"records-clinic-fallback-name"}),jsxRuntime.jsx("label",{htmlFor:"records-clinic-fallback-email",style:u.fieldLabel,children:we.fallback.emailLabel}),jsxRuntime.jsx("input",{id:"records-clinic-fallback-email",type:"email",style:u.field,value:T,onChange:_=>{O(_.target.value),q(false);},onBlur:()=>q(true),placeholder:we.fallback.emailPlaceholder,maxLength:320,autoComplete:"off","data-testid":"records-clinic-fallback-email"}),z&&T.trim().length>0&&!L?jsxRuntime.jsx("p",{role:"alert",style:u.errorText,children:le.errors.invalidEmail}):null,jsxRuntime.jsx("p",{style:u.muted,children:we.fallback.reviewNote}),jsxRuntime.jsx(j,{label:we.fallback.submit,ariaLabel:we.fallback.submitA11y,disabled:!F||!s,onClick:()=>s?.({name:"consent",clinic:ea(null,x.trim(),T.trim().toLowerCase(),g.current())}),testID:"records-clinic-fallback-submit"})]}):null]}):m.recent.length>0?jsxRuntime.jsx("h3",{style:{...u.fieldLabel,...D(d,"bold"),textTransform:"uppercase",marginBottom:0},"data-testid":"records-clinic-recent-label",children:we.recentlyUsed}):null,m.isSearchActive&&m.initialLoading?jsxRuntime.jsx(fd,{testID:"records-clinic-page-loading"}):null,jsxRuntime.jsx("ul",{style:{...u.plainList,gap:d.space.md},children:W.map(_=>{let Y=wl(_.emailStatus),me=_l(_.distanceKm),Ne=[_.name,_.address,_.phone?`phone ${_.phone}`:null,me?Pl(_.distanceKm):null,Y.a11y].filter(Boolean).join(", "),re=Y.tone==="positive"?{backgroundColor:d.color.badgeBgPositive,color:d.color.success}:Y.tone==="caution"?{backgroundColor:d.color.badgeBgCaution,color:d.color.cautionAccent}:{backgroundColor:d.color.badgeBgNeutral,color:d.color.text.muted};return jsxRuntime.jsx("li",{children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>N(_),"aria-label":we.selectA11y(Ne),style:{...u.creamCard,backgroundColor:d.color.surface,width:"100%",textAlign:"left",cursor:"pointer",gap:d.space.sm,padding:`${d.space.md}px ${d.space.md+d.space.xs/2}px`,font:"inherit",color:"inherit"},"data-testid":`records-clinic-${_.id}`,children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:d.space.sm},children:[jsxRuntime.jsx("span",{style:{...u.rowTitle,...D(d,"bold"),color:d.color.brandInk},children:_.name}),me?jsxRuntime.jsx("span",{"aria-hidden":"true",style:{...u.muted,...u.mono},children:me}):null]}),_.address?jsxRuntime.jsx("span",{style:u.rowDetail,children:_.address}):null,_.phone?jsxRuntime.jsx("span",{"aria-hidden":"true",style:u.rowMuted,children:_.phone}):null,jsxRuntime.jsx("span",{"aria-hidden":"true",style:{...u.chip,...re,...D(d,"bold"),fontSize:d.type.size.micro,alignSelf:"flex-start"},children:Y.label})]})},_.id)})}),I&&!m.initialLoading?jsxRuntime.jsx(He,{variant:I,message:m.isSearchActive&&I==="idle"?we.noMatch(m.debouncedQuery):m.error?.displayMessage,onAction:m.error?.retryable===true?m.retry:void 0,testID:"records-clinic-empty"}):null,jsxRuntime.jsxs("div",{style:w,children:[m.loadingMore?jsxRuntime.jsx("p",{role:"status",style:{...u.muted,textAlign:"center"},"data-testid":"records-clinic-loading-more",children:we.loadingMore}):null,m.pageError?jsxRuntime.jsx("button",{type:"button",onClick:m.loadMore,"aria-label":we.loadMoreRetryA11y,style:{...u.pill,...u.pillLink},"data-testid":"records-clinic-page-error-retry",children:we.loadMoreFailed}):null]}),jsxRuntime.jsx(ef,{petName:r})]}),jsxRuntime.jsx(Ae,{})]})}i(Zm,"PickerBody");function ef({petName:e}){let{theme:r,styles:t}=V();return jsxRuntime.jsxs("section",{style:{...t.creamCard,backgroundColor:r.color.surfaceSubtle,border:0},"aria-label":we.howItWorks,"data-testid":"records-clinic-how",children:[jsxRuntime.jsx("h3",{style:t.sectionTitle,children:we.howItWorks}),jsxRuntime.jsx("ol",{style:{...t.plainList,gap:r.space.md},children:we.howSteps(Re(e)).map((o,n)=>jsxRuntime.jsxs("li",{style:{display:"flex",gap:r.space.md},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{...t.mono,...D(r,"monoBold"),fontSize:r.type.size.caption,color:r.color.brandInk,minWidth:r.space.xl},children:String(n+1).padStart(2,"0")}),jsxRuntime.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:r.space.xs/2},children:[jsxRuntime.jsx("span",{style:{...t.rowTitle,...D(r,"bold")},children:o.title}),jsxRuntime.jsx("span",{style:t.rowDetail,children:o.body})]})]},o.title))})]})}i(ef,"HowItWorks");var je=Object.freeze({title:"Request records",resultTitle:"Request status",addClinic:"Add a clinic",atCap:`Up to ${en} clinics`,sendA11y:i(e=>e===1?"Send 1 records request":`Send ${e} records requests`,"sendA11y"),send:i(e=>`Send ${e} ${e===1?"request":"requests"}`,"send"),sending:"Sending\u2026",addToContinue:"Add a clinic to continue",tryAgain:"Try again",remove:i(e=>`Remove ${e}`,"remove"),emailToAdd:"Email to add",perClinic:"Per-clinic result",sent:"Sent",notSent:"Not sent",allFailed:"We couldn\u2019t send any of these requests. See the details below and try again.",partial:i((e,r,t)=>`${e} of ${r} requests sent. ${t} couldn\u2019t be sent.`,"partial"),allSent:i(e=>`${e} ${e===1?"request":"requests"} sent.`,"allSent"),responded:i((e,r)=>`${e} of ${r} ${r===1?"clinic":"clinics"} responded`,"responded")});var Fo=25,Ao=5;function qo(e){let[r,t]=react.useState({list:e,shown:Ao}),o=r.list===e?r.shown:Ao,n=react.useCallback(()=>{t(s=>({list:e,shown:(s.list===e?s.shown:Ao)+Ao}));},[e]);return {visible:e.slice(0,o),hasMore:e.length>o,showMore:n}}i(qo,"useVisibleClinics");function zn(e,r,t,o){let n={owner_name:r,pet_name:t,clinic_name:o},s=false,a=e.scopeTemplate.replace(/\{([^{}]+)\}/g,(c,l)=>Object.prototype.hasOwnProperty.call(n,l)?n[l]??"":(s=true,""));return s||/[{}]/.test(a)?null:a}i(zn,"renderClinicScope");function Mn(e){return e===null||e.emailStatus!=="verified"&&e.emailStatus!=="unverified"}i(Mn,"clinicNeedsEmail");function gd(e,r,t){let[o,n]=react.useState(e.ownerName),[s,a]=react.useState(""),[c,l]=react.useState(null),[d,u]=react.useState(""),[p,m]=react.useState([]),[y,g]=react.useState([]),[f,v]=react.useState(null),[b,R]=react.useState(null),[h,E]=react.useState(false),[S,C]=react.useState(false),[k,M]=react.useState(null),[T,O]=react.useState(0),z=react.useRef(false),q=react.useRef(false),N=react.useRef(0),B=react.useRef(it()),x=react.useRef(null),L=react.useRef(null),F=react.useRef(0);react.useEffect(()=>(z.current=true,q.current=false,E(false),()=>{z.current=false,F.current+=1,N.current+=1,x.current=null,L.current?.abort();}),[r]),react.useEffect(()=>{let re=true;return v(null),x.current=null,r.getAuthorizationCopy().then(oe=>{re&&(oe.ok?(v(oe.value),R(null)):R(oe.error));}).catch(()=>{re&&R(H("internalError"));}),()=>{re=false;}},[r,T]),react.useEffect(()=>{let re=true;return g([]),r.recentClinics({limit:5}).then(oe=>{re&&oe.ok&&g(oe.value.clinics);}).catch(()=>{}),()=>{re=false;}},[r]);let W=i(()=>{x.current=null,R(null);},"invalidate"),I=c?.name??s.trim(),w=f?zn(f,o.trim(),e.petName,I):null,A=Mn(c),_=qo(p),Y=!!(f&&w&&o.trim()&&e.petName.trim()&&I&&(!A||/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(d.trim()))&&t),me=i(async()=>{if(q.current)return;let re=++N.current;C(true);try{let oe=await r.searchClinics({query:s.trim(),limit:Fo});if(!z.current||re!==N.current)return;oe.ok?(m(oe.value.clinics),R(null)):R(oe.error);}catch{z.current&&re===N.current&&R(H("internalError"));}finally{z.current&&re===N.current&&C(false);}},"search"),Ne=i(async()=>{if(q.current||k||!Y||!f||!w||!t)return;q.current=true;let re=F.current,oe=i(()=>z.current&&F.current===re,"current");E(true),R(null);try{if(!x.current){L.current=new AbortController;let Pe=await t({petRef:e.petRef,petName:e.petName,ownerName:o.trim(),clinicName:I,authorizationVersion:f.authorizationVersion,scopeText:w,signal:L.current.signal});if(!oe()||Pe===null)return;let Ge=c&&(!A||c.emailStatus==="none")?{clinicId:c.id}:{clinicFreeText:I};x.current={petRef:e.petRef,ownerName:o.trim(),authorizationVersion:f.authorizationVersion,...Ge,...A?{clinicEmail:d.trim().toLowerCase()}:{},...Pe.signatureId!==void 0?{signatureId:Pe.signatureId}:{signaturePngBase64:Pe.signaturePngBase64},idempotencyKey:B.current()};}if(!oe())return;let Se=await r.createClinicRequest(x.current);if(!oe())return;if(!Se.ok){R(Se.error);return}if(Se.value.petRef!==e.petRef){R(H("internalError"));return}M(Se.value),x.current=null,e.onCreated?.(Se.value);}catch{oe()&&R(H("internalError"));}finally{q.current=false,oe()&&E(false);}},"submit");return {ownerName:o,query:s,clinic:c,email:d,clinics:p,copy:f,scope:w,error:b,busy:h,searching:S,created:k,ready:Y,needsEmail:A,visibleClinics:_.visible,hasMoreClinics:_.hasMore,showMoreClinics:_.showMore,recent:p.length===0&&c===null?y:[],setOwnerName(re){q.current||(W(),n(re));},setQuery(re){q.current||(W(),N.current+=1,C(false),m([]),l(null),u(""),a(re));},setEmail(re){q.current||(W(),u(re));},selectClinic(re){q.current||(W(),N.current+=1,C(false),m([]),l(re),a(re.name),u(""));},invalidate:W,search:me,submit:Ne,retryCopy(){R(null),O(re=>re+1);}}}i(gd,"useClinicRequestForm");var nf=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function cn(e){return e.clinic?.name??e.freeText??""}i(cn,"draftName");function dn(e){return Mn(e.clinic)}i(dn,"draftNeedsEmail");function bd(e,r,t,o,n){let[s,a]=react.useState(e.ownerName),[c,l]=react.useState(""),[d,u]=react.useState([]),[p,m]=react.useState([]),[y,g]=react.useState([]),[f,v]=react.useState(null),[b,R]=react.useState(null),[h,E]=react.useState(false),[S,C]=react.useState(false),[k,M]=react.useState(null),[T,O]=react.useState(null),[z,q]=react.useState(0),N=react.useRef(false),B=react.useRef(false),x=react.useRef(0),L=react.useRef(0),F=react.useRef(it()),W=react.useRef(null),I=react.useRef(null);react.useEffect(()=>(N.current=true,B.current=false,E(false),()=>{N.current=false,L.current+=1,x.current+=1,W.current=null,I.current?.abort();}),[r,t]),react.useEffect(()=>{let ie=true;return v(null),W.current=null,r.getAuthorizationCopy().then(ke=>{ie&&(ke.ok?(v(ke.value),R(null)):R(ke.error));}).catch(()=>{ie&&R(H("internalError"));}),()=>{ie=false;}},[r,z]),react.useEffect(()=>{let ie=true;return m([]),r.recentClinics({limit:5}).then(ke=>{ie&&ke.ok&&m(ke.value.clinics);}).catch(()=>{}),()=>{ie=false;}},[r]);let w=qo(d),A=i(()=>{W.current=null,R(null);},"invalidate"),_=y.map(cn),Y=f?_.map(ie=>zn(f,s.trim(),e.petName,ie)):[],me=Y.every(ie=>ie!==null)?Y.join(`
2
2
 
3
- `):null,Ae=y.length>0&&y.every(U=>!Qt(U)||em.test(U.email.trim())),oe=y.length>=Bt,ve=!!(f&&de&&l.trim()&&e.petName.trim()&&Ae&&o)&&k===null,ar=i(async()=>{if($.current)return;let U=++V.current;C(true);try{let Re=await r.searchClinics({query:c.trim(),limit:100});if(!M.current||U!==V.current)return;Re.ok?(u(Re.value.clinics),E(null)):E(Re.error);}catch{M.current&&U===V.current&&E(z("internalError"));}finally{M.current&&U===V.current&&C(false);}},"search"),Qe=i(U=>{$.current||oe||k!==null||U.clinic!==null&&y.some(Re=>Re.clinic?.id===U.clinic?.id)||(A(),g(Re=>[...Re,{...U,key:Q.current(),idempotencyKey:Q.current()}]),u([]),s(""));},"add"),_r=i(async()=>{if($.current||k!==null||!ve||!f||!de||!o)return;$.current=true;let U=re.current,Re=i(()=>M.current&&re.current===U,"current");v(true),E(null);try{if(w.current===null){x.current=new AbortController;let sr=await o({petRef:e.petRef,petName:e.petName,ownerName:l.trim(),clinicName:D.join(", "),authorizationVersion:f.authorizationVersion,scopeText:de,signal:x.current.signal});if(!Re()||sr===null)return;if(w.current=sr,sr.signaturePngBase64!==void 0&&n!==void 0){let xc=await n(sr.signaturePngBase64,x.current.signal);if(!Re())return;w.current={signatureId:xc.signatureId};}}let Tr=w.current,dn=y.map(sr=>({...sr.clinic!==null&&(!Qt(sr)||sr.clinic.emailStatus==="none")?{clinicId:sr.clinic.id}:{clinicFreeText:Xt(sr)},...Qt(sr)?{clinicEmail:sr.email.trim().toLowerCase()}:{},...Tr.signatureId!==void 0?{signatureId:Tr.signatureId}:{signaturePngBase64:Tr.signaturePngBase64},idempotencyKey:sr.idempotencyKey})),cn=await t.createClinicRequestBatch({petRef:e.petRef,ownerName:l.trim(),authorizationVersion:f.authorizationVersion,clinics:dn});if(!Re())return;if(!cn.ok){E(cn.error);return}_(cn.value),e.onCreated?.(cn.value),Pr(cn.value.requestGroupId,U);}catch{Re()&&E(z("internalError"));}finally{$.current=false,Re()&&v(false);}},"submit"),Pr=i(async(U,Re)=>{try{let Tr=await r.getRequestGroup(U);if(!M.current||re.current!==Re)return;Tr.ok&&Tr.value.petRef===e.petRef&&I(Tr.value);}catch{}},"loadGroup"),Ee=i(async()=>{k===null||$.current||await Pr(k.requestGroupId,re.current);},"refreshGroup");return {ownerName:l,query:c,clinics:d,copy:f,scopeText:de,error:b,busy:h,searching:S,drafts:y,outcome:k,group:T,ready:ve,atCap:oe,recent:d.length===0?p.filter(U=>!y.some(Re=>Re.clinic?.id===U.id)):[],setOwnerName(U){$.current||(A(),a(U));},setQuery(U){$.current||(V.current+=1,C(false),u([]),s(U));},search:ar,addClinic(U){Qe({clinic:U,freeText:null,email:""});},addFreeText(){let U=c.trim();U.length!==0&&Qe({clinic:null,freeText:U,email:""});},setDraftEmail(U,Re){$.current||(A(),g(Tr=>Tr.map(dn=>dn.key===U?{...dn,email:Re}:dn)));},removeDraft(U){$.current||k!==null||(A(),g(Re=>Re.filter(Tr=>Tr.key!==U)));},submit:_r,refreshGroup:Ee,retryCopy(){E(null),q(U=>U+1);}}}i(Tl,"useClinicBatchForm");function Dl(e){try{let r=new URL(e);if(r.protocol!=="https:"||r.username||r.password||r.port&&r.port!=="443")return !1;let t=r.hostname.toLowerCase();return t==="s3.amazonaws.com"||t.endsWith(".s3.amazonaws.com")||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3[.-][a-z0-9-]+\.amazonaws\.com$/.test(t)||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3\.dualstack\.[a-z0-9-]+\.amazonaws\.com$/.test(t)||t==="s3-accelerate.amazonaws.com"||t.endsWith(".s3-accelerate.amazonaws.com")||t==="s3-accelerate.dualstack.amazonaws.com"||t.endsWith(".s3-accelerate.dualstack.amazonaws.com")}catch{return false}}i(Dl,"trustedSignatureUploadUrl");function Ol(e,r,t,o){e.clearRect(0,0,t,o);let n=r.trim();if(!n)return;let l=Math.max(1,t-32),a=Math.min(44,Math.max(16,Math.round(o*.34))),c=i(()=>{e.font=`italic 700 ${a}px Georgia, "Times New Roman", serif`;},"font");for(c();a>12&&e.measureText(n).width>l;)a-=2,c();e.textAlign="center",e.textBaseline="middle",e.fillText(n,t/2,o/2,l);}i(Ol,"paintClinicTypedSignature");function Il(e,r,t,o){e.clearRect(0,0,t,o);for(let n of r){let l=n[0];if(l!==void 0){e.beginPath(),e.moveTo(l[0],l[1]),n.length===1&&e.lineTo(l[0],l[1]);for(let a=1;a<n.length;a+=1){let c=n[a];c!==void 0&&e.lineTo(c[0],c[1]);}e.stroke();}}}i(Il,"paintSignatureStrokes");async function Al(e,r,t,o=fetch){let n=i(()=>new Error("Signature upload failed"),"fail"),l=await new Promise(m=>e.toBlob(m,"image/png"));if(!l||!l.size||l.size>2*1024*1024||t.aborted)throw n();let a=await r.initiateSignatureUpload(l.size);if(!a.ok||t.aborted||!Dl(a.value.uploadUrl))throw n();let c=new FormData;for(let[m,y]of Object.entries(a.value.uploadFields))c.append(m,y);c.append("file",l,"signature.png");let s=new AbortController,d=i(()=>s.abort(),"onAbort");t.addEventListener("abort",d,{once:true});let u=setTimeout(d,9e4);try{if(!(await o(a.value.uploadUrl,{method:"POST",body:c,credentials:"omit",redirect:"error",referrerPolicy:"no-referrer",signal:s.signal})).ok||t.aborted)throw n()}catch{throw n()}finally{clearTimeout(u),t.removeEventListener("abort",d);}let p=await r.completeSignatureUpload(a.value.uploadId);if(!p.ok||t.aborted)throw n();return {signatureId:p.value}}i(Al,"registerClinicSignature");var tm=8,nm=480,om=160;function Ot(e){let r=react.useRef(null),t=react.useRef(false),o=react.useRef([]),[n,l]=react.useState("draw"),[a,c]=react.useState(""),[s,d]=react.useState(false),u=react.useRef(a);u.current=a;let p=react.useCallback(()=>{let f=r.current,R=f?.getContext("2d");if(!f||!R)return;let b=typeof window<"u"&&window.devicePixelRatio||1;R.setTransform(b,0,0,b,0,0);let E=f.width/b,h=f.height/b;if(u.current.trim().length>0){R.fillStyle="#111",Ol(R,u.current,E,h);return}R.lineWidth=2,R.lineCap="round",R.lineJoin="round",R.strokeStyle="#111",Il(R,o.current,E,h);},[]);react.useEffect(()=>{let f=r.current;if(!f)return;let R=i(()=>{let E=f.getBoundingClientRect(),h=typeof window<"u"&&window.devicePixelRatio||1,v=Math.max(1,Math.round((E.width||f.clientWidth||nm)*h)),S=Math.max(1,Math.round((E.height||f.clientHeight||om)*h));f.width!==v&&(f.width=v),f.height!==S&&(f.height=S),p();},"resize");if(R(),typeof ResizeObserver>"u")return;let b=new ResizeObserver(R);return b.observe(f),()=>b.disconnect()},[p]);let m=react.useCallback(()=>{e?.(),o.current=[],d(false),c(""),u.current="",p();},[e,p]),y=i(f=>{let R=f.currentTarget.getBoundingClientRect();return [f.clientX-R.left,f.clientY-R.top]},"point"),g=i(()=>o.current.reduce((f,R)=>f+R.length,0),"countPoints");return {canvas:r,mode:n,typed:a,signed:s,clear:m,setTyped(f){e?.(),c(f),u.current=f,d(!!f.trim()),p();},toggle(){m(),l(f=>f==="draw"?"type":"draw");},onPointerDown(f){n==="draw"&&(e?.(),t.current=true,f.currentTarget.setPointerCapture(f.pointerId),o.current=[...o.current,[y(f)]],p());},onPointerMove(f){if(!t.current||n!=="draw")return;let R=o.current[o.current.length-1];R!==void 0&&(o.current=[...o.current.slice(0,-1),[...R,y(f)]],p(),d(g()>=tm));},onPointerUp(){t.current=false;},register(f,R){return !r.current||!s?Promise.reject(new Error("Signature upload failed")):Al(r.current,f,R)}}}i(Ot,"useSignatureCanvas");function It({pad:e,disabled:r}){let t=ce(),o=e.mode==="type"?e.typed.trim():"",n={minHeight:44,padding:t.space.sm,border:`1px solid ${t.color.borderHairlineGreen}`,borderRadius:t.radius.sm,background:t.color.surface,color:t.color.text.primary,font:"inherit"},l={...n,cursor:"pointer"};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{style:{margin:`0 0 ${t.space.sm}px`},children:e.mode==="draw"?X.draw:X.type}),jsxRuntime.jsx("button",{type:"button",style:{...l,alignSelf:"flex-start",marginBottom:t.space.sm,textDecoration:"underline"},disabled:r,onClick:e.toggle,"data-testid":"records-consent-sign-mode-toggle",children:e.mode==="draw"?X.toType:X.toDraw}),e.mode==="type"&&jsxRuntime.jsx("input",{"aria-label":X.type,style:{...n,display:"block",width:"100%",boxSizing:"border-box"},maxLength:Hs,value:e.typed,disabled:r,autoComplete:"off",onChange:a=>e.setTyped(a.target.value)}),jsxRuntime.jsx("canvas",{ref:e.canvas,role:"img","aria-label":o.length>0?X.typedSignatureA11y(o):X.sign,style:{display:"block",width:"100%",height:160,maxWidth:"100%",boxSizing:"border-box",touchAction:"none",background:"#fff",border:`1px solid ${t.color.borderHairlineGreen}`,...r?{opacity:.6,pointerEvents:"none"}:{},...e.mode==="type"?{pointerEvents:"none"}:{}},onPointerDown:a=>{r||e.onPointerDown(a);},onPointerMove:a=>{r||e.onPointerMove(a);},onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerUp}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:t.space.sm,marginTop:t.space.sm},children:[jsxRuntime.jsx("p",{style:{margin:0,fontSize:t.type.size.tiny,color:t.color.text.muted},"data-testid":"records-signature-hint",children:e.signed?"\xA0":X.drawHint}),e.mode==="type"?null:jsxRuntime.jsx("button",{type:"button",style:l,disabled:r,onClick:e.clear,"aria-label":X.clearA11y,"data-testid":"records-signature-clear",children:X.clear})]})]})}i(It,"SignatureCanvas");function wn(e){let{userRef:r,scopeEpoch:t}=ee();return jsxRuntime.jsx(Te,{capability:"recordsClinic",...Oe(e.onClose,X.cancel),children:r===null?jsxRuntime.jsx("p",{role:"alert",children:G.sessionRequired}):jsxRuntime.jsx(im,{..._e(e,["onClose","onCreated"])},JSON.stringify([r,t,e.petRef,e.petName]))})}i(wn,"EverfurClinicRequestBatch");function im(e){let r=Ir(),t=Li(),o=e.controller??r,n=ce(),l=Ot(),a=Tl(e,o,e.batchClient??t,e.onCaptureSignature??(async f=>l.signed?l.register(o,f.signal):null)),c=e.onCaptureSignature!==void 0||l.signed,s={minHeight:44,padding:n.space.sm,border:`1px solid ${n.color.borderHairlineGreen}`,borderRadius:n.radius.sm,background:n.color.surface,color:n.color.text.primary,font:"inherit"},d={...s,display:"block",width:"100%",boxSizing:"border-box"},u={...s,cursor:"pointer"},p={margin:0,color:n.color.text.muted,fontSize:n.type.size.bodyTight},m=i(f=>[f.name,f.address,f.phone].filter(Boolean).join(", "),"clinicLabel"),y=a.busy?ze.sending:a.drafts.length===0?ze.addToContinue:a.error?ze.tryAgain:ze.send(a.drafts.length),g=a.outcome?ze.resultTitle:ze.title;return jsxRuntime.jsxs("section",{className:e.className,"aria-label":g,style:{...mt,background:n.color.surface,color:n.color.text.primary,padding:n.space.lg,borderRadius:n.radius.lg,minHeight:120,minWidth:0,overflowWrap:"anywhere",...e.style},children:[jsxRuntime.jsx("h2",{style:{margin:0,fontSize:n.type.size.heading},children:g}),jsxRuntime.jsx("p",{style:{margin:`${n.space.sm}px 0 ${n.space.lg}px`},children:e.petName}),a.outcome?jsxRuntime.jsxs("div",{style:{display:"grid",gap:n.space.sm},"data-testid":"records-batch-result",children:[jsxRuntime.jsx("p",{role:"status",style:{margin:0},children:a.outcome.createdCount===0?ze.allFailed:a.outcome.failedCount>0?ze.partial(a.outcome.createdCount,a.outcome.results.length,a.outcome.failedCount):ze.allSent(a.outcome.createdCount)}),jsxRuntime.jsx("h3",{style:{margin:0,fontSize:n.type.size.subtitle},children:ze.perClinic}),jsxRuntime.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:n.space.sm},children:a.outcome.results.map((f,R)=>{let b=f.request?.clinicName??a.drafts[R]?.clinic?.name??f.clinicFreeText??"";return jsxRuntime.jsxs("li",{"data-testid":`records-batch-row-${f.created?"created":"failed"}`,children:[jsxRuntime.jsx("span",{children:b})," ",jsxRuntime.jsx("span",{style:p,children:f.created?ze.sent:ze.notSent}),f.created&&f.request?.statusLabel?jsxRuntime.jsx("p",{style:p,children:f.request.statusLabel}):null,!f.created&&f.failureReason?jsxRuntime.jsx("p",{style:p,children:f.failureReason}):null]},f.idempotencyKey)})}),a.group?jsxRuntime.jsx("p",{"aria-live":"polite",style:{margin:0},children:ze.responded(a.group.responded,a.group.total)}):null,a.group?.members.map(f=>f.statusLabel?jsxRuntime.jsx("p",{style:p,children:[f.clinicName,f.statusLabel].filter(Boolean).join(": ")},f.id):null)]}):jsxRuntime.jsxs("div",{style:{display:"grid",gap:n.space.md},children:[jsxRuntime.jsxs("label",{children:[X.ownerName,jsxRuntime.jsx("input",{style:d,maxLength:200,value:a.ownerName,disabled:a.busy,autoComplete:"name",onChange:f=>{l.clear(),a.setOwnerName(f.target.value);}})]}),a.drafts.length>0&&jsxRuntime.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:n.space.sm},children:a.drafts.map(f=>jsxRuntime.jsxs("li",{"data-testid":`records-batch-draft-${f.key}`,style:{display:"grid",gap:n.space.xs},children:[jsxRuntime.jsx("span",{children:Xt(f)}),Qt(f)?jsxRuntime.jsxs("label",{children:[X.email,jsxRuntime.jsx("input",{style:d,type:"email",placeholder:X.emailPlaceholder,maxLength:320,autoComplete:"off",value:f.email,disabled:a.busy,onChange:R=>{l.clear(),a.setDraftEmail(f.key,R.target.value);}})]}):null,Qt(f)&&!f.email.trim()?jsxRuntime.jsx("p",{style:p,children:ze.emailToAdd}):null,jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,"aria-label":ze.remove(Xt(f)),onClick:()=>{l.clear(),a.removeDraft(f.key);},children:ze.remove(Xt(f))})]},f.key))}),jsxRuntime.jsx("p",{style:{margin:0},children:a.atCap?ze.atCap:ze.addClinic}),!a.atCap&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("label",{children:[X.clinic,jsxRuntime.jsx("input",{style:d,placeholder:X.placeholder,maxLength:200,value:a.query,disabled:a.busy,autoComplete:"off",onChange:f=>a.setQuery(f.target.value)})]}),jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy||a.searching||a.query.trim().length<2,onClick:()=>{a.search();},children:X.search}),a.query.trim().length>0&&a.clinics.length===0&&!a.searching&&jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,onClick:()=>{l.clear(),a.addFreeText();},children:ze.addClinic}),a.searching&&jsxRuntime.jsx("p",{role:"status",children:G.loading}),a.recent.length>0&&jsxRuntime.jsx("h3",{style:{margin:0,fontSize:n.type.size.subtitle},children:X.recentlyUsed}),a.recent.map(f=>jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,onClick:()=>{l.clear(),a.addClinic(f);},children:m(f)},`recent-${f.id}`)),a.clinics.map(f=>jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,onClick:()=>{l.clear(),a.addClinic(f);},children:m(f)},f.id))]}),jsxRuntime.jsx("h3",{style:{margin:`${n.space.sm}px 0 0`,fontSize:n.type.size.subtitle},children:X.scopeHeading}),a.copy?jsxRuntime.jsx("p",{style:{whiteSpace:"pre-wrap",margin:0},children:a.drafts.length>0&&a.ownerName.trim()?a.scopeText??z("internalError").displayMessage:G.consentRequired}):!a.error&&jsxRuntime.jsx("p",{role:"status",children:G.loading}),!e.onCaptureSignature&&jsxRuntime.jsx(It,{pad:l,disabled:a.busy}),!c&&jsxRuntime.jsx("p",{role:"alert",children:X.missingSignature}),a.error&&jsxRuntime.jsx("p",{role:"alert",children:a.error.displayMessage}),!a.copy&&a.error&&jsxRuntime.jsx("button",{type:"button",style:u,onClick:a.retryCopy,children:G.retry}),jsxRuntime.jsx("button",{type:"button","aria-label":ze.sendA11y(a.drafts.length),style:{...u,background:n.color.primary,color:n.color.onPrimary,opacity:a.busy||!a.ready||!c?.5:1},disabled:a.busy||!a.ready||!c,onClick:()=>{a.submit();},children:y})]}),e.onClose&&jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,onClick:e.onClose,children:X.cancel}),jsxRuntime.jsx(De,{})]})}i(im,"BatchBody");var he=Object.freeze({scopeHeading:"What you\u2019re authorizing",scopeBody:"You\u2019re asking your pet\u2019s clinic to release their medical records to Everfur, on your behalf, so we can organize them for you.",whatWeDo: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:i((e,r)=>`I authorize ${r} to release ${Pe(e)}\u2019s records to Everfur.`,"authorizeLabel"),missingSignatureError:"Please add your signature before submitting.",missingDraftError:"Something went wrong with your selection. Please go back and pick the clinic again.",newClinicDirectSendNote:"We\u2019ll email this clinic directly to request your pet\u2019s medical records. Clinics usually reply within a week.",titleFreeText:"Confirm your request",titleDirectory:"Authorize records release",noEmailNote:i((e,r)=>`We don\u2019t have an email on file for ${r}. Add it so we can request ${Pe(e)}\u2019s records.`,"noEmailNote"),emailLabel:"Clinic email",emailPlaceholder:"records@clinic.com",emailRequired:"Enter the clinic email before sending the request.",reuseSignature:"Reuse a previous signature",reuseHint:"\u2026or 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\u2019t draw? Type your name instead",toTypeA11y:"Can\u2019t draw? Type your name to sign instead",toDraw:"Draw your signature instead",signatureHint:i(e=>`Your signature is added to the authorization sent to ${e}.`,"signatureHint"),submit:"Authorize & send request",submitting:"Submitting\u2026",submitA11y:"Submit authorization"});var sm="value_text",Ll=64,Fl=512;function zl(e){return e!==null&&e.httpStatus===409&&!Jr(e)}i(zl,"isFactReviewerLocked");var kn=Object.freeze({num:"value_num",date:"value_date",bool:"value_bool",text:sm}),Ml=/^[+-]?(?:\d+\.?\d*|\.\d+)$/,$l=/^\d{4}-\d{2}-\d{2}$/;function Ul(e){if(e==null)return "text";let r=e.trim();return Ml.test(r)?"num":$l.test(r)&&!Number.isNaN(Date.parse(r))?"date":r==="true"||r==="false"?"bool":"text"}i(Ul,"inferFactValueKind");function Gi(e,r){let t=r.trim(),o=Ul(e);if(o==="num"&&Ml.test(t)){let n=Number(t);if(Number.isFinite(n))return Object.freeze({[kn.num]:n})}return o==="date"&&$l.test(t)&&!Number.isNaN(Date.parse(t))?Object.freeze({[kn.date]:t}):Object.freeze(o==="bool"&&(t==="true"||t==="false")?{[kn.bool]:t==="true"}:{[kn.text]:t})}i(Gi,"factCorrectionFor");var Ie=zod.z.string().nullish(),bo=zod.z.number().nullish(),lm=zod.z.object({collected_at:Ie,at:Ie,value:bo,unit:Ie,qualitative_result:Ie,ref_low:bo,ref_high:bo,status:Ie,source_clinic:Ie,source_doc_id:Ie,doc_id:Ie,reviewed:zod.z.boolean().nullish()}),dm=zod.z.object({collected_at:Ie,at:Ie,value:bo,unit:Ie,qualitative_result:Ie,status:Ie}),cm=zod.z.object({marker_id:zod.z.string().min(1),canonical_name:Ie,name:Ie,loinc_code:Ie,canonical_unit:Ie,unit:Ie,panel_name:Ie,panel:Ie,meaning_text:Ie,meaning:Ie,latest:dm.nullish(),trajectory:Ie,points:zod.z.array(lm).optional()}),um=zod.z.object({total_markers:zod.z.number().int().nonnegative(),in_range_count:zod.z.number().int().nonnegative(),out_of_range_count:zod.z.number().int().nonnegative(),unknown_count:zod.z.number().int().nonnegative()}),pm=zod.z.object({markers:zod.z.array(cm).optional(),summary:um.nullish(),disclaimer:zod.z.string().optional(),featured_marker_id:Ie});function mm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(mm,"isObject");function Bl(e){return Object.freeze({petRef:e,withheld:true,markers:Object.freeze([]),summary:null,disclaimer:"",featuredMarkerId:null})}i(Bl,"withheldMarkers");function jl(e,r){let t=mm(r)?r:{},o=typeof t.pet_ref=="string"&&t.pet_ref.length>0?t.pet_ref:e;if(t.withheld===true)return Bl(o);let n=pm.safeParse(t);if(!n.success)return Bl(o);let l=n.data,a=i(s=>Object.freeze({at:s.collected_at??s.at??null,value:s.value??null,unit:s.unit??null,qualitativeResult:s.qualitative_result??null,refLow:s.ref_low??null,refHigh:s.ref_high??null,status:s.status??null,sourceClinic:s.source_clinic??null,docId:s.source_doc_id??s.doc_id??null,reviewed:s.reviewed===true}),"point"),c=(l.markers??[]).map(s=>Object.freeze({markerId:s.marker_id,name:s.canonical_name??s.name??s.marker_id,loincCode:s.loinc_code??null,unit:s.canonical_unit??s.unit??null,panel:s.panel_name??s.panel??null,meaning:s.meaning_text??s.meaning??null,latest:s.latest?Object.freeze({at:s.latest.collected_at??s.latest.at??null,value:s.latest.value??null,unit:s.latest.unit??null,qualitativeResult:s.latest.qualitative_result??null,status:s.latest.status??null}):null,trajectory:s.trajectory??null,points:Object.freeze((s.points??[]).map(a))}));return Object.freeze({petRef:o,withheld:false,markers:Object.freeze(c),summary:l.summary?Object.freeze({totalMarkers:l.summary.total_markers,inRangeCount:l.summary.in_range_count,outOfRangeCount:l.summary.out_of_range_count,unknownCount:l.summary.unknown_count}):null,disclaimer:l.disclaimer??"",featuredMarkerId:l.featured_marker_id??null})}i(jl,"mapRecordMarkers");var fm=zod.z.string().min(1).refine(e=>e.startsWith("https://")),ym=zod.z.object({source_doc_id:zod.z.string().min(1),file_name:zod.z.string().nullish(),doc_format:zod.z.string().nullish(),byte_size:zod.z.number().int().nonnegative().nullish(),received_at:zod.z.string().nullish(),download_url:fm,expires_in_seconds:zod.z.number().int().nonnegative().nullish()}),gm=zod.z.object({items:zod.z.array(zod.z.unknown()).optional()});function Hl(e){let r=gm.safeParse(e);if(!r.success)return null;let t=[];for(let o of r.data.items??[]){let n=ym.safeParse(o);n.success&&t.push(Object.freeze({sourceDocId:n.data.source_doc_id,fileName:n.data.file_name??null,docFormat:n.data.doc_format??null,byteSize:n.data.byte_size??null,receivedAt:n.data.received_at??null,downloadUrl:n.data.download_url,expiresInSeconds:n.data.expires_in_seconds??0}));}return Object.freeze(t)}i(Hl,"mapRequestDocuments");var bm=zod.z.string().min(1).refine(e=>e.startsWith("https://")),_n=zod.z.string().nullish(),Rm=zod.z.object({share_id:zod.z.string().min(1),share_url:zod.z.string().min(1),expires_at:_n}),hm=zod.z.object({shares:zod.z.array(zod.z.object({share_id:zod.z.string().min(1),expires_at:_n,created_at:_n,view_count:zod.z.number().int().nonnegative().nullish(),last_viewed_at:_n})).optional()}),vm=zod.z.object({download_url:bm,expires_at:_n});function Cm(e,r){let t=e.trim();if(t.length===0)return null;try{let o=/^[a-z][a-z0-9+.-]*:/i.test(t)?new URL(t):r!==void 0?new URL(t,r):null;return o===null||o.protocol!=="https:"?null:o.toString()}catch{return null}}i(Cm,"resolveShareUrl");function Vl(e,r){let t=Rm.safeParse(e);if(!t.success)return null;let o=Cm(t.data.share_url,r);return o===null?null:Object.freeze({shareId:t.data.share_id,shareUrl:o,expiresAt:t.data.expires_at??null})}i(Vl,"mapRecordShareLink");function Wl(e){let r=hm.safeParse(e);return r.success?Object.freeze((r.data.shares??[]).map(t=>Object.freeze({shareId:t.share_id,expiresAt:t.expires_at??null,createdAt:t.created_at??null,viewCount:t.view_count??0,lastViewedAt:t.last_viewed_at??null}))):null}i(Wl,"mapRecordShareList");function Gl(e){let r=vm.safeParse(e);return r.success?Object.freeze({downloadUrl:r.data.download_url,expiresAt:r.data.expires_at??null}):null}i(Gl,"mapRecordPdfLink");var Em=zod.z.object({signatures:zod.z.array(zod.z.object({signature_id:zod.z.string().min(1),preview_url:zod.z.string().min(1).refine(e=>e.startsWith("https://")),created_at:zod.z.string().nullish()})).optional()});function Yl(e){let r=Em.safeParse(e);return r.success?Object.freeze((r.data.signatures??[]).map(t=>Object.freeze({signatureId:t.signature_id,previewUrl:t.preview_url,createdAt:t.created_at??null}))):null}i(Yl,"mapSignatureSuggestions");var H=zod.z.string().nullish(),Pn=zod.z.number().nullish(),xm=zod.z.object({at:H,value:Pn,unit:H,qualitative_result:H,ref_low:Pn,ref_high:Pn,status:H,doc_id:H}),Sm=zod.z.object({marker_id:zod.z.string(),name:zod.z.string(),loinc_code:H,unit:H,panel:H,meaning:H,latest:zod.z.object({at:H,value:Pn,unit:H,qualitative_result:H,status:H}).nullish(),trajectory:H,points:zod.z.array(xm).optional()}),wm=zod.z.object({encounter_id:zod.z.string(),date:H,type:H,clinic_name:H,veterinarian:H,doc_id:H}),km=zod.z.object({note_id:zod.z.string(),encounter_id:H,observed_on:H,sections:zod.z.array(zod.z.object({section:zod.z.string(),text:zod.z.string()})).optional()}),_m=zod.z.object({exam_id:zod.z.string(),encounter_id:H,observed_on:H,doc_id:H,systems:zod.z.record(zod.z.object({finding_status:H,finding:H})).optional()}),Pm=zod.z.object({has_lab_history:zod.z.boolean().optional(),has_vaccination_history:zod.z.boolean().optional(),has_weight_history:zod.z.boolean().optional(),has_vitals_history:zod.z.boolean().optional(),has_physical_exam_history:zod.z.boolean().optional(),has_procedure_history:zod.z.boolean().optional(),has_genetic_history:zod.z.boolean().optional(),has_reproductive_history:zod.z.boolean().optional(),has_parasite_prevention_history:zod.z.boolean().optional(),earliest_record_at:H,latest_record_at:H,documents_ingested:zod.z.number().int().nonnegative().optional(),documents_in_review:zod.z.number().int().nonnegative().optional(),entities_pending_review:zod.z.record(zod.z.number().int().nonnegative()).optional(),held_total:zod.z.number().int().nonnegative().optional()}),Tm=zod.z.object({conflict_id:zod.z.string(),entity_type:zod.z.string(),field:H,severity:H,candidates:zod.z.array(zod.z.object({value:zod.z.string(),source_doc_id:H,doc_id:H,collected_at:H})).optional()}),Dm=zod.z.object({lab_results:zod.z.array(Sm).optional(),encounters:zod.z.array(wm).optional(),clinician_notes:zod.z.array(km).optional(),physical_exams:zod.z.array(_m).optional(),completeness:Pm.nullish(),conflicts:zod.z.array(Tm).optional()}),Om=zod.z.object({visits:zod.z.array(zod.z.object({visit_id:zod.z.string(),visit_date:H,veterinarian:H,summary:H,doc_id:H})),vaccines:zod.z.array(zod.z.object({vaccine_id:zod.z.string(),product:H,lot:H,administered_on:H,expires_on:H,doc_id:H})),weights:zod.z.array(zod.z.object({weight_id:zod.z.string(),observed_on:H,weight_kg:Pn,doc_id:H})),medications:zod.z.array(zod.z.object({medication_id:zod.z.string(),drug_name:H,dose:H,route:H,frequency:H,sig:H,rx_number:H,started_on:H,stopped_on:H,doc_id:H})),disclaimer:zod.z.string().optional()}),Im=zod.z.object({document:Jo,contributions:zod.z.array(Xo),contribution_count:zod.z.number().int().nonnegative().optional()});function Ki(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Ki,"isObject");function Qi(e,r){return typeof e.pet_ref=="string"&&e.pet_ref.length>0?e.pet_ref:r}i(Qi,"petOf");function Yi(e,r){return Object.freeze({petRef:e,available:false,withheld:r,labResults:Object.freeze([]),encounters:Object.freeze([]),clinicianNotes:Object.freeze([]),physicalExams:Object.freeze([]),completeness:null,conflicts:Object.freeze([])})}i(Yi,"emptyDepth");function Am(e,r){let t=Ki(r)?r:{},o=Qi(t,e);if(t.withheld===true)return Yi(o,true);if(!["lab_results","encounters","clinician_notes","physical_exams","completeness","conflicts"].some(s=>s in t))return Yi(o,false);let l=Dm.safeParse(t);if(!l.success)return Yi(o,true);let a=l.data,c=i(s=>Object.freeze({at:s.at??null,value:s.value??null,unit:s.unit??null,qualitativeResult:s.qualitative_result??null,refLow:s.ref_low??null,refHigh:s.ref_high??null,status:s.status??null,docId:s.doc_id??null}),"point");return Object.freeze({petRef:o,available:true,withheld:false,labResults:Object.freeze((a.lab_results??[]).map(s=>Object.freeze({markerId:s.marker_id,name:s.name,loincCode:s.loinc_code??null,unit:s.unit??null,panel:s.panel??null,meaning:s.meaning??null,latest:Object.freeze({at:s.latest?.at??null,value:s.latest?.value??null,unit:s.latest?.unit??null,qualitativeResult:s.latest?.qualitative_result??null,status:s.latest?.status??null}),trajectory:s.trajectory??null,points:Object.freeze((s.points??[]).map(c))}))),encounters:Object.freeze((a.encounters??[]).map(s=>Object.freeze({encounterId:s.encounter_id,date:s.date??null,type:s.type??null,clinicName:s.clinic_name??null,veterinarian:s.veterinarian??null,docId:s.doc_id??null}))),clinicianNotes:Object.freeze((a.clinician_notes??[]).map(s=>Object.freeze({noteId:s.note_id,encounterId:s.encounter_id??null,observedOn:s.observed_on??null,sections:Object.freeze((s.sections??[]).map(d=>Object.freeze({section:d.section,text:d.text})))}))),physicalExams:Object.freeze((a.physical_exams??[]).map(s=>Object.freeze({examId:s.exam_id,encounterId:s.encounter_id??null,observedOn:s.observed_on??null,docId:s.doc_id??null,systems:Object.freeze(Object.entries(s.systems??{}).map(([d,u])=>Object.freeze({system:d,findingStatus:u.finding_status??null,finding:u.finding??null})))}))),completeness:a.completeness?Object.freeze({hasLabHistory:a.completeness.has_lab_history===true,hasVaccinationHistory:a.completeness.has_vaccination_history===true,hasWeightHistory:a.completeness.has_weight_history===true,hasVitalsHistory:a.completeness.has_vitals_history===true,hasPhysicalExamHistory:a.completeness.has_physical_exam_history===true,hasProcedureHistory:a.completeness.has_procedure_history===true,hasGeneticHistory:a.completeness.has_genetic_history===true,hasReproductiveHistory:a.completeness.has_reproductive_history===true,hasParasitePreventionHistory:a.completeness.has_parasite_prevention_history===true,earliestRecordAt:a.completeness.earliest_record_at??null,latestRecordAt:a.completeness.latest_record_at??null,documentsIngested:a.completeness.documents_ingested??0,documentsInReview:a.completeness.documents_in_review??0,entitiesPendingReview:Object.freeze({...a.completeness.entities_pending_review??{}}),heldTotal:a.completeness.held_total??0}):null,conflicts:Object.freeze((a.conflicts??[]).map(s=>Object.freeze({conflictId:s.conflict_id,entityType:s.entity_type,field:s.field??null,severity:s.severity??"needs_review",candidates:Object.freeze((s.candidates??[]).map(d=>Object.freeze({value:d.value,docId:d.source_doc_id??d.doc_id??null,collectedAt:d.collected_at??null})))})))})}i(Am,"mapRecordDepth");function Kl(e){return Object.freeze({petRef:e,withheld:true,isEmpty:false,visits:Object.freeze([]),vaccines:Object.freeze([]),weights:Object.freeze([]),medications:Object.freeze([]),disclaimer:""})}i(Kl,"withheldTimeline");function qm(e,r){let t=Ki(r)?r:{},o=Qi(t,e);if(t.withheld===true)return Kl(o);let n=Om.safeParse(t);if(!n.success)return Kl(o);let l=n.data,a=l.visits.map(u=>Object.freeze({visitId:u.visit_id,visitDate:u.visit_date??null,veterinarian:u.veterinarian??null,summary:u.summary??null,docId:u.doc_id??null})),c=l.vaccines.map(u=>Object.freeze({vaccineId:u.vaccine_id,product:u.product??null,lot:u.lot??null,administeredOn:u.administered_on??null,expiresOn:u.expires_on??null,docId:u.doc_id??null})),s=l.weights.map(u=>Object.freeze({weightId:u.weight_id,observedOn:u.observed_on??null,weightKg:u.weight_kg??null,docId:u.doc_id??null})),d=l.medications.map(u=>Object.freeze({medicationId:u.medication_id,drugName:u.drug_name??null,dose:u.dose??null,route:u.route??null,frequency:u.frequency??null,sig:u.sig??null,rxNumber:u.rx_number??null,startedOn:u.started_on??null,stoppedOn:u.stopped_on??null,docId:u.doc_id??null}));return Object.freeze({petRef:o,withheld:false,isEmpty:a.length===0&&c.length===0&&s.length===0&&d.length===0,visits:Object.freeze(a),vaccines:Object.freeze(c),weights:Object.freeze(s),medications:Object.freeze(d),disclaimer:l.disclaimer??""})}i(qm,"mapRecordsTimeline");function Nm(e,r){let t=Ki(r)?r:{},o=Qi(t,e),n=i(()=>Object.freeze({petRef:o,withheld:true,document:null,contributions:Object.freeze([]),contributionCount:0}),"withheld");if(t.withheld===true)return n();let l=Im.safeParse(t);if(!l.success)return n();let a=Object.freeze(l.data.contributions.map(Zo));return Object.freeze({petRef:o,withheld:false,document:ei(l.data.document),contributions:a,contributionCount:l.data.contribution_count??a.length})}i(Nm,"mapDocumentContributions");var Lm="/widget/v1/records/pets";function Ql(e){let r=e.funnel??ut({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),t=i((s,d)=>typeof s=="string"&&s.length>0&&!pt(s)&&[...s].length<=d,"segment"),o=i(async(s,d,u,p)=>{if(!t(d,or))return ot();let m=await r.send(s,{method:"GET",path:u});if(!m.ok)return m;let y=p(m.value);return y.petRef===d?we(y):Y(z("internalError",{retryable:false}))},"read"),n=i(s=>`${Lm}/${encodeURIComponent(s)}`,"pet"),l=i(s=>`${n(s)}/everfur_record`,"record"),a=i(async(s,d,u)=>{let p=await r.send(s,d,d.method==="POST"?{idempotent:false,maxAttempts:1}:void 0);if(!p.ok)return p;let m=u(p.value);return m===null?Y(z("internalError",{retryable:false})):we(m)},"parsed"),c=i((s,d)=>!t(s.entityType,Ll)||!t(s.canonicalKey,Fl)||s.idempotencyKey!==void 0&&!t(s.idempotencyKey,pn)||d!==void 0&&Object.keys(d).length===0?null:{entity_type:s.entityType,canonical_key:s.canonicalKey,...d!==void 0?{corrected_fields:d}:{},...s.idempotencyKey!==void 0?{idempotency_key:s.idempotencyKey}:{}},"factBody");return {getRecordDepth:i(s=>o("records.depth.record",s,`${n(s)}/record`,d=>Am(s,d)),"getRecordDepth"),getTimeline:i(s=>o("records.depth.timeline",s,`${n(s)}/timeline`,d=>qm(s,d)),"getTimeline"),getDocumentContributions(s,d){return t(d,64)?o("records.depth.contributions",s,`${n(s)}/documents/${encodeURIComponent(d)}/contributions`,u=>Nm(s,u)):ot()},getMarkers:i(s=>o("records.depth.markers",s,`${n(s)}/markers`,d=>jl(s,d)),"getMarkers"),createShare(s){return t(s,or)?a("records.share.create",{method:"POST",path:`${l(s)}/share`},d=>Vl(d,e.apiBaseUrl)):ot()},listShares(s){return t(s,or)?a("records.share.list",{method:"GET",path:`${l(s)}/shares`},Wl):ot()},async revokeShare(s,d){if(!t(s,or)||!t(d,64))return ot();let u=await r.send("records.share.revoke",{method:"DELETE",path:`${l(s)}/shares/${encodeURIComponent(d)}`},{idempotent:false,maxAttempts:1});return u.ok?we(void 0):u},getPdfLink(s){return t(s,or)?a("records.pdf.link",{method:"GET",path:`${l(s)}/pdf-link`},Gl):ot()},async editFact(s,d){let u=t(s,or)?c(d,d.correctedFields):null;if(u===null)return ot();let p=await r.send("records.fact.edit",{method:"POST",path:`${l(s)}/facts/edit`,body:u},{idempotent:false,maxAttempts:1});return p.ok?we(void 0):p},async removeFact(s,d){let u=t(s,or)?c(d):null;if(u===null)return ot();let p=await r.send("records.fact.remove",{method:"POST",path:`${l(s)}/facts/remove`,body:u},{idempotent:false,maxAttempts:1});return p.ok?we(void 0):p},listRequestDocuments(s){return t(s,64)?a("records.request.documents",{method:"GET",path:`/widget/v1/records/requests/${encodeURIComponent(s)}/documents`},Hl):ot()},listAuthorizationSignatures:i(()=>a("records.signatures.list",{method:"GET",path:"/widget/v1/records/authorization-signatures"},Yl),"listAuthorizationSignatures")}}i(Ql,"createRecordsDepthClient");function ot(){return Promise.resolve(Y(z("validationFailed",{retryable:false})))}i(ot,"invalid");function pr(){let{runtime:e,userRef:r,scopeEpoch:t}=ee();return react.useMemo(()=>{let{services:o}=e.registry;return Ql({auth:o.authFor(r),...o.errorPolicy?{errorPolicy:o.errorPolicy}:{},...typeof o.apiBaseUrl=="string"?{apiBaseUrl:o.apiBaseUrl}:{}})},[e,r,t])}i(pr,"useEverfurRecordsDepthClient");function zr(e,r,t,o=""){let n=pr(),{userRef:l}=ee(),a=Qn(e),c=react.useMemo(()=>({}),[n,e,o,a]),[s,d]=react.useState({scope:c,value:null,error:null,loading:true}),u=react.useRef(0),p=react.useCallback(async()=>{let b=u.current+=1;if(d({scope:c,value:null,error:null,loading:true}),l===null){d({scope:c,value:null,error:null,loading:false});return}let E=await r(n,e);b===u.current&&(E.ok?d({scope:c,value:E.value,error:null,loading:false}):d({scope:c,value:null,error:E.error,loading:false}));},[n,e,r,c,l]);react.useEffect(()=>(p(),()=>{u.current+=1;}),[p]);let m=s.scope===c?s:{value:null,error:null,loading:true},y=react.useCallback(()=>{p();},[p]),g=m.error===null||m.error.httpStatus!==404,f=g?m.error:null,R=m.loading?"loading":f!==null?"error":m.value===null?"empty":m.value.withheld?"populated":t(m.value)?"empty":"populated";return react.useMemo(()=>({status:R,value:m.value,error:f,available:g,refresh:y}),[R,m.value,f,g,y])}i(zr,"useRecordsDepthRead");function Rt(e){return e!==null&&e.httpStatus===404}i(Rt,"isDarkRouteError");var Um=i((e,r)=>e.getMarkers(r),"readMarkers"),Bm=i(e=>e.markers.length===0,"markersEmpty");function Ji(e){let r=zr(e,Um,Bm);return react.useMemo(()=>{let t=r.available&&r.value!==null&&!r.value.withheld?r.value:null;return {status:r.status,markers:t,available:r.available,error:r.error,refresh:r.refresh}},[r])}i(Ji,"useRecordsMarkers");var jm=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function Zl(e){let{clinic:r,controller:t,depthClient:o,capture:n,onCreated:l}=e,a=r.clinic?.name??r.freeText??"",c=r.clinic===null,[s,d]=react.useState(false),[u,p]=react.useState(e.ownerName),[m,y]=react.useState(r.email),[g,f]=react.useState(false),[R,b]=react.useState(null),[E,h]=react.useState(null),[v,S]=react.useState(0),[C,k]=react.useState(null),[_,T]=react.useState(false),[I,F]=react.useState(null),[q,M]=react.useState([]),[$,V]=react.useState(null),[re,Q]=react.useState(false),w=react.useRef(false),x=react.useRef(true),A=react.useRef(Zr()),D=react.useRef(null);react.useEffect(()=>(x.current=true,()=>{x.current=false,D.current=null;}),[t]),react.useEffect(()=>{let Ee=true;return b(null),D.current=null,t.getAuthorizationCopy().then(U=>{Ee&&(U.ok?(b(U.value),h(null)):h(U.error));}).catch(()=>{Ee&&h(z("internalError"));}),()=>{Ee=false;}},[t,v]),react.useEffect(()=>{if(o===void 0)return;let Ee=true;return o.listAuthorizationSignatures().then(U=>{Ee&&(U.ok?M(U.value):Rt(U.error)||M([]));}).catch(()=>{}),()=>{Ee=false;}},[o]);let W=Sn(r.clinic),de=m.trim().toLowerCase(),Ae=jm.test(de),oe=W&&(g||de.length>0)&&!Ae?he.emailRequired:null,ve=R?xn(R,u.trim(),Pe(e.petName),a):null,ar=e.hostCapture===true||re||$!==null,Qe=!!(s&&R&&ve&&u.trim()&&a&&ar&&(!W||Ae)),_r=react.useCallback(async()=>{if(!(w.current||I!==null||!R||!ve)){if(!a){k(he.missingDraftError);return}if(W&&!Ae){f(true),k(he.emailRequired);return}if(!(!s||!u.trim())){w.current=true,T(true),k(null);try{if(D.current===null){let U=$!==null?{signatureId:$}:await n();if(!x.current)return;if(U===null){k(he.missingSignatureError);return}let Re=r.clinic&&(!W||r.clinic.emailStatus==="none")?{clinicId:r.clinic.id}:{clinicFreeText:a};D.current={petRef:e.petRef,ownerName:u.trim(),authorizationVersion:R.authorizationVersion,...Re,...W?{clinicEmail:de}:{},...U.signatureId!==void 0?{signatureId:U.signatureId}:{signaturePngBase64:U.signaturePngBase64},idempotencyKey:A.current()};}let Ee=await t.createClinicRequest(D.current);if(!x.current)return;if(!Ee.ok){k(Ee.error.displayMessage);return}if(Ee.value.petRef!==e.petRef){k(z("internalError").displayMessage);return}F(Ee.value),D.current=null,l?.(Ee.value);}catch{x.current&&k(z("internalError").displayMessage);}finally{w.current=false,x.current&&T(false);}}}},[s,n,r.clinic,a,t,R,I,e.petRef,W,de,l,u,$,ve,Ae]),Pr=react.useCallback(()=>{D.current=null,k(null);},[]);return {title:c?he.titleFreeText:he.titleDirectory,clinicName:a,isFreeText:c,authorized:s,ownerName:u,email:m,emailError:oe,needsEmail:W,directoryClinicNoEmail:W&&r.clinic!==null,copy:R,copyError:E,scope:ve,error:C,busy:_,created:I,ready:Qe,signatures:q,reuseSignatureId:$,hasSignature:ar,setAuthorized(Ee){w.current||(Pr(),d(Ee));},setOwnerName(Ee){w.current||(Pr(),p(Ee));},setEmail(Ee){w.current||(Pr(),f(false),y(Ee));},setSigned(Ee){w.current||(Pr(),Q(Ee),Ee&&V(null));},pickReuseSignature(Ee){w.current||(Pr(),V(Ee));},retryCopy(){h(null),S(Ee=>Ee+1);},submit:_r}}i(Zl,"useRecordsConsentForm");function Tn(e){let{userRef:r,scopeEpoch:t}=ee();return jsxRuntime.jsx(Te,{capability:"recordsClinic",style:e.style,className:e.className,...Oe(e.onBack,Le),children:r===null?jsxRuntime.jsx("p",{role:"alert",children:G.sessionRequired}):jsxRuntime.jsx(Wm,{..._e(e,["onCreated","onNavigate","onBack"])},JSON.stringify([r,t,e.petRef,e.clinic.key]))})}i(Tn,"EverfurRecordsConsent");function Wm({petRef:e,petName:r,clinic:t,ownerName:o,onCaptureSignature:n,onCreated:l,controller:a,onNavigate:c,onBack:s,style:d,className:u}){let{theme:p,styles:m}=j(),y=Ir(),g=a??y,f=pr(),R=Ot(),b=Zl({petRef:e,petName:r,ownerName:o??"",clinic:t,controller:g,depthClient:f,capture:n?()=>n({petRef:e,petName:Pe(r),ownerName:b.ownerName,clinicName:b.clinicName,authorizationVersion:b.copy?.authorizationVersion??"",scopeText:b.scope??"",signal:new AbortController().signal}):async()=>R.signed?R.register(g,new AbortController().signal):null,hostCapture:n!==void 0,onCreated:i(_=>{l?.(_),c?.({name:"dashboard"});},"onCreated")}),E=R.signed,h=react.useRef(b);h.current=b,react.useEffect(()=>{h.current.setSigned(E);},[E]);let v=b.busy,S={display:"flex",flexDirection:"column",gap:p.space.sm},C="records-consent-owner-name",k="records-consent-clinic-email";return jsxRuntime.jsxs("div",{className:u,style:{...m.root,...d},"data-testid":"records-consent-screen",children:[jsxRuntime.jsx(He,{title:b.title,onBack:s,testID:"records-consent-header"}),jsxRuntime.jsxs("div",{style:{...m.body,...m.content,gap:p.space.lg+p.space.xs/2},"data-testid":"records-consent",children:[jsxRuntime.jsxs("section",{style:m.creamCard,"aria-label":he.scopeHeading,children:[jsxRuntime.jsx("h3",{style:{...m.sectionTitle,color:p.color.brand},children:he.scopeHeading}),jsxRuntime.jsx("p",{style:m.bodyText,children:he.scopeBody}),jsxRuntime.jsx("ul",{style:{...m.plainList,gap:p.space.sm},children:he.whatWeDo.map(_=>jsxRuntime.jsxs("li",{style:{...m.bodyText,display:"flex",gap:p.space.sm},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{color:p.color.brand,...O(p,"bold")},children:"\u2713"}),jsxRuntime.jsx("span",{children:_})]},_))}),jsxRuntime.jsx("p",{style:{...m.muted,paddingTop:p.space.xs,borderTop:`1px solid ${p.color.borderHairlineGreen}`},children:he.retentionNote}),b.copy&&b.scope?jsxRuntime.jsx("p",{style:{...m.rowDetail,whiteSpace:"pre-wrap"},"data-testid":"records-consent-scope",children:b.scope}):b.copyError?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{role:"alert",style:m.errorText,children:b.copyError.displayMessage}),jsxRuntime.jsx(B,{label:G.retry,kind:"outline",onClick:b.retryCopy,testID:"records-consent-copy-retry"})]}):jsxRuntime.jsx("p",{role:"status",style:m.muted,children:G.loading})]}),jsxRuntime.jsxs("button",{type:"button",role:"checkbox","aria-checked":b.authorized,onClick:()=>b.setAuthorized(!b.authorized),style:{display:"flex",alignItems:"flex-start",gap:p.space.md,textAlign:"left",font:"inherit",cursor:"pointer",borderRadius:p.radius.lg-p.space.xs,border:`1px solid ${b.authorized?p.color.brand:p.color.brandBorder}`,backgroundColor:b.authorized?p.color.brandSoft:p.color.surface,padding:p.space.md+p.space.xs/2,color:p.color.text.primary},"data-testid":"records-authorize-toggle",children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{boxSizing:"border-box",flexShrink:0,width:p.space.xl,height:p.space.xl,borderRadius:p.radius.xs+1,border:`1.6px solid ${p.color.brand}`,backgroundColor:b.authorized?p.color.brand:p.color.surface,color:p.color.onPrimary,display:"inline-flex",alignItems:"center",justifyContent:"center",...O(p,"bold")},children:b.authorized?"\u2713":""}),jsxRuntime.jsx("span",{style:{...m.rowTitle,...O(p,"bold"),fontSize:p.type.size.bodyTight},children:he.authorizeLabel(r,b.clinicName)})]}),jsxRuntime.jsxs("div",{style:S,children:[jsxRuntime.jsx("label",{htmlFor:C,style:m.fieldLabel,children:he.fullName}),jsxRuntime.jsx("input",{id:C,style:m.field,value:b.ownerName,placeholder:he.fullNamePlaceholder,maxLength:200,disabled:v,autoComplete:"name",onChange:_=>b.setOwnerName(_.target.value),"data-testid":"records-consent-owner-name"})]}),b.needsEmail?jsxRuntime.jsxs("div",{style:S,"data-testid":"records-consent-email-block",children:[b.directoryClinicNoEmail?jsxRuntime.jsx("p",{style:m.cautionNote,"data-testid":"records-consent-no-email-note",children:he.noEmailNote(r,b.clinicName)}):null,jsxRuntime.jsx("label",{htmlFor:k,style:m.fieldLabel,children:he.emailLabel}),jsxRuntime.jsx("input",{id:k,type:"email",style:m.field,value:b.email,placeholder:he.emailPlaceholder,maxLength:320,disabled:v,autoComplete:"off",onChange:_=>b.setEmail(_.target.value),"data-testid":"records-consent-clinic-email"}),b.emailError?jsxRuntime.jsx("p",{role:"alert",style:m.errorText,children:b.emailError}):null,jsxRuntime.jsx("p",{style:m.muted,"data-testid":"records-consent-review-note",children:he.newClinicDirectSendNote})]}):null,n?null:jsxRuntime.jsxs("div",{style:S,children:[b.signatures.length>0?jsxRuntime.jsxs("div",{style:S,children:[jsxRuntime.jsx("span",{style:m.fieldLabel,children:he.reuseSignature}),jsxRuntime.jsx("div",{style:{display:"flex",gap:p.space.sm,overflowX:"auto",padding:`${p.space.xs}px 0`},children:b.signatures.map(_=>{let T=b.reuseSignatureId===_.signatureId;return jsxRuntime.jsx("button",{type:"button",onClick:()=>b.pickReuseSignature(T?null:_.signatureId),"aria-label":T?he.reuseTileSelectedA11y:he.reuseTileA11y,"aria-pressed":T,style:{flexShrink:0,width:112,height:56,borderRadius:p.radius.sm,border:T?`2px solid ${p.color.brand}`:`1px solid ${p.color.brandBorder}`,backgroundColor:p.color.surface,padding:0,overflow:"hidden",cursor:"pointer"},"data-testid":`records-consent-reuse-${_.signatureId}`,children:jsxRuntime.jsx("img",{src:_.previewUrl,alt:"",style:{width:"100%",height:"100%",objectFit:"contain"}})},_.signatureId)})}),jsxRuntime.jsx("p",{style:m.muted,children:he.reuseHint})]}):null,jsxRuntime.jsx(It,{pad:R,disabled:v}),jsxRuntime.jsx("p",{style:m.muted,children:he.signatureHint(b.clinicName)}),!b.hasSignature&&b.clinicName.length>0?jsxRuntime.jsx("p",{style:m.muted,"data-testid":"records-consent-signature-required",children:he.missingSignatureError}):null]}),b.error?jsxRuntime.jsx("p",{role:"alert","aria-live":"assertive",style:m.errorBanner,children:b.error}):null,b.created?jsxRuntime.jsx("p",{role:"status",style:m.bodyText,children:b.created.statusLabel||G.records}):null]}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:p.space.sm,padding:`${p.space.md}px ${p.space.lg}px ${p.space.xxl}px`,borderTop:`1px solid ${p.color.borderHairlineGreen}`,backgroundColor:p.color.background},children:[s?jsxRuntime.jsx(B,{label:X.cancel,kind:"link",disabled:v,onClick:s,style:{flex:"0 0 auto"},testID:"records-consent-cancel"}):null,jsxRuntime.jsx(B,{label:v?he.submitting:he.submit,ariaLabel:he.submitA11y,disabled:!b.ready,busy:v,onClick:()=>{b.submit();},style:{flex:"1 1 12rem",minWidth:0,minHeight:54},testID:"records-consent-submit"})]}),jsxRuntime.jsx(De,{})]})}i(Wm,"ConsentBody");var ho=Object.freeze({visit:0,vaccine:1,weight:2,medication:3});function ed(e){if(!e)return null;let r=Date.parse(e);return Number.isNaN(r)?null:r}i(ed,"toMillis");function rd(e){let r=[...e.visits.map((t,o)=>({key:`visit-${o}-${t.visitId}`,kind:"visit",kindLabel:me.kind.visit,at:t.visitDate,date:J(t.visitDate),title:t.summary??me.clinicVisit,detail:t.veterinarian?me.doctor(t.veterinarian):null,docId:t.docId})),...e.vaccines.map((t,o)=>{let n=[];return t.lot&&n.push(me.lot(t.lot)),t.expiresOn&&n.push(me.expires(J(t.expiresOn))),{key:`vaccine-${o}-${t.vaccineId}`,kind:"vaccine",kindLabel:me.kind.vaccine,at:t.administeredOn,date:J(t.administeredOn),title:t.product||me.kind.vaccine,detail:n.length?n.join(" \xB7 "):null,docId:t.docId}}),...e.weights.map((t,o)=>({key:`weight-${o}-${t.weightId}`,kind:"weight",kindLabel:me.kind.weight,at:t.observedOn,date:J(t.observedOn),title:hl(t.weightKg),detail:null,docId:t.docId})),...e.medications.map((t,o)=>{let n=[t.dose,t.route,t.frequency].filter(l=>!!l);return {key:`medication-${o}-${t.medicationId}`,kind:"medication",kindLabel:me.kind.medication,at:t.startedOn,date:J(t.startedOn),title:t.drugName||me.kind.medication,detail:n.length?n.join(" \xB7 "):null,docId:t.docId}})];return Object.freeze(r.sort((t,o)=>{let n=ed(t.at),l=ed(o.at);return n===null&&l===null?ho[t.kind]-ho[o.kind]:n===null?1:l===null?-1:l!==n?l-n:ho[t.kind]-ho[o.kind]}))}i(rd,"buildTimelineRows");var Jm=300,td=120,nd=44,Zm=i((e,r)=>e.getTimeline(r),"readTimeline"),ef=i(e=>e.isEmpty,"timelineEmpty");var rf=i(e=>e.contributions.length===0,"contributionsEmpty");function vo({petRef:e,style:r,className:t,onBack:o}){let n=zr(e,Zm,ef);return jsxRuntime.jsx(od,{state:n,style:r,className:t,onBack:o,header:jsxRuntime.jsx(He,{title:me.timeline,onBack:yn(o),testID:"timeline-header"}),loading:jsxRuntime.jsx(wl,{testID:"timeline-loading"}),empty:jsxRuntime.jsx(Fe,{variant:"no_records",testID:"timeline-empty"}),render:l=>jsxRuntime.jsx(of,{timeline:l})})}i(vo,"EverfurRecordsTimeline");function Co({petRef:e,docId:r,style:t,className:o,onBack:n}){let l=react.useCallback((s,d)=>s.getDocumentContributions(d,r),[r]),a=zr(e,l,rf,r),c=a.value?.document?.title?.trim()||me.uploadedDocument;return jsxRuntime.jsx(od,{state:a,style:t,className:o,onBack:n,header:jsxRuntime.jsx(He,{title:c,onBack:yn(n),testID:"contributions-header"}),empty:jsxRuntime.jsx(Fe,{variant:"no_records",testID:"contributions-empty"}),render:s=>jsxRuntime.jsx(af,{view:s})})}i(Co,"EverfurDocumentContributions");function od({state:e,style:r,className:t,header:o,loading:n,empty:l,render:a,onBack:c}){let{styles:s}=ea(),{userRef:d}=ee();return jsxRuntime.jsx(Te,{capability:"records",style:r,className:t,...Oe(yn(c),Le),children:jsxRuntime.jsxs("div",{className:t,style:{...s.container,...r},children:[o??null,jsxRuntime.jsx("div",{style:s.body,children:d===null?jsxRuntime.jsx("p",{role:"alert",style:s.alertText,children:G.sessionRequired}):tf(e,a,s,n,l)}),jsxRuntime.jsx(De,{})]})})}i(od,"DepthSurface");function tf(e,r,t,o,n){switch(e.status){case "loading":return o??jsxRuntime.jsx(nf,{styles:t});case "empty":return n??jsxRuntime.jsx("div",{style:t.centered,children:jsxRuntime.jsx("div",{role:"img","aria-label":G.empty,style:t.emptyGlyph})});case "error":return e.error?jsxRuntime.jsx(Fe,{variant:Xe(e.error),message:e.error.displayMessage,onAction:e.error.retryable?e.refresh:void 0,testID:"depth-error"}):null;case "populated":return e.value===null||e.value.withheld?null:r(e.value);default:return null}}i(tf,"renderState");function nf({styles:e}){let[r,t]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>t(true),Jm);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx("div",{role:"status","aria-busy":"true","aria-label":G.loading,style:e.centered,children:r?jsxRuntime.jsx("div",{"aria-hidden":"true",style:e.spinner}):null})}i(nf,"LoadingState");function of({timeline:e}){let{styles:r}=ea(),t=rd(e);return jsxRuntime.jsxs("section",{"aria-label":me.timeline,style:r.timelineList,children:[e.disclaimer.length>0?jsxRuntime.jsx("p",{role:"note","aria-label":lr.important(e.disclaimer),style:r.timelineBand,children:e.disclaimer}):null,jsxRuntime.jsx("ul",{style:r.plainList,children:t.map((o,n)=>jsxRuntime.jsx("li",{style:n>0?r.timelineSeparated:void 0,"data-testid":`records-timeline-row-${o.kind}`,children:jsxRuntime.jsxs("div",{style:r.timelineRow,"aria-label":[o.kindLabel,o.date,o.title,o.detail].filter(Boolean).join(", "),children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:r.timelineBubble}),jsxRuntime.jsxs("div",{style:r.timelineBody,children:[jsxRuntime.jsxs("div",{style:r.topLine,children:[jsxRuntime.jsx("span",{style:r.timelineKind,children:o.kindLabel}),jsxRuntime.jsx("span",{style:r.date,children:o.date})]}),jsxRuntime.jsx("span",{style:r.timelineTitle,children:o.title}),o.detail?jsxRuntime.jsx("span",{style:r.rowDetail,children:o.detail}):null]})]})},o.key))})]})}i(of,"TimelineBody");function af({view:e}){let{styles:r}=ea();return jsxRuntime.jsxs("section",{"aria-label":G.records,style:r.list,children:[e.document?.receivedAt?jsxRuntime.jsx("p",{style:r.rowDetail,children:J(e.document.receivedAt)}):null,jsxRuntime.jsx("dl",{style:r.card,children:e.contributions.map(t=>jsxRuntime.jsxs("div",{style:r.row,children:[jsxRuntime.jsx("dt",{style:r.rowTitle,children:t.label}),jsxRuntime.jsx("dd",{style:r.rowValue,children:Ht(t.value,t.unit)}),t.observedAt?jsxRuntime.jsx("dd",{style:r.rowDetail,children:J(t.observedAt)}):null]},t.key))})]})}i(af,"ContributionsBody");function ea(){let e=ce(),r=react.useMemo(()=>sf(e),[e]);return {theme:e,styles:r}}i(ea,"useDepthTheme");function sf(e){let{color:r,space:t,radius:o,type:n,slots:l}=e,a=i((m,y)=>`${Math.round(m*y)}px`,"lh"),c=i((m,y,g,f="regular")=>({margin:0,...O(e,f),fontSize:m,lineHeight:a(m,y),color:g}),"text"),s=Yr(l.recordCard),d=i((m,y,g,f="regular")=>({...c(m,y,g,f),...s}),"inCard"),u=`1px solid ${r.brandBorder}`,p=e.brightness==="dark"?r.errorRed:r.danger;return {container:{boxSizing:"border-box",display:"flex",flexDirection:"column",minHeight:td,height:"100%",backgroundColor:r.background,color:r.text.primary,...O(e,"regular")},body:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",overflowY:"auto"},centered:{boxSizing:"border-box",flex:"1 1 auto",minHeight:td,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:t.lg,padding:t.xl,textAlign:"center"},spinner:{boxSizing:"border-box",width:24,height:24,borderRadius:o.pill,border:`3px solid ${r.brandSofter}`,borderTopColor:r.brand},emptyGlyph:{boxSizing:"border-box",width:40,height:40,borderRadius:o.lg,backgroundColor:r.brandSoft,border:u},alertText:c(n.size.subtitle,n.lineHeight.snug,r.text.secondary),errorText:c(n.size.subtitle,n.lineHeight.snug,p),primaryButton:{boxSizing:"border-box",minHeight:nd,minWidth:nd,padding:`${t.md}px ${t.xl}px`,borderRadius:o.pill,...O(e,"bold"),fontSize:n.size.body,border:0,cursor:"pointer",backgroundColor:r.primary,color:r.onPrimary,...Ar(l.primaryButton),...Yr(l.primaryButton)},list:{display:"flex",flexDirection:"column",gap:t.md,padding:t.lg},section:{display:"flex",flexDirection:"column",gap:t.sm},heading:{...c(n.size.heading,n.lineHeight.snug,r.text.primary,"bold")},card:{boxSizing:"border-box",listStyle:"none",display:"flex",flexDirection:"column",gap:t.sm,margin:0,padding:t.md,borderRadius:o.md,backgroundColor:r.surfaceCream,border:u,...Ar(l.recordCard,1)},plainList:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:t.sm},row:{display:"flex",flexDirection:"column",gap:t.xs,padding:`${t.xs}px 0`,borderBottom:`1px solid ${r.borderHairlineGreen}`},topLine:{display:"flex",justifyContent:"space-between",gap:t.md},kindLabel:{...d(n.size.caption,n.lineHeight.normal,r.text.muted,"medium")},date:d(n.size.caption,n.lineHeight.normal,r.text.muted),rowTitle:{...d(n.size.body,n.lineHeight.normal,r.text.primary,"bold")},rowValue:{...d(n.size.body,n.lineHeight.normal,r.text.primary,"medium")},rowDetail:d(n.size.bodyTight,n.lineHeight.normal,r.text.muted),rowMuted:{...d(n.size.bodyTight,n.lineHeight.normal,r.text.muted),opacity:.7},chip:{...c(n.size.caption,n.lineHeight.normal,r.text.primary),alignSelf:"flex-start",padding:`${t.xs}px ${t.sm}px`,borderRadius:o.pill},chipNeutral:{backgroundColor:r.badgeBgNeutral},chipCaution:{backgroundColor:r.badgeBgCaution},chipCritical:{backgroundColor:r.badgeBgCritical},disclaimer:c(n.size.caption,n.lineHeight.normal,r.text.muted),timelineList:{display:"flex",flexDirection:"column",paddingBottom:t.xxl},timelineBand:{...c(n.size.caption,n.lineHeight.normal,r.text.secondary),borderRadius:o.md-t.xs/2,padding:t.md,backgroundColor:r.brandSoft,margin:`${t.xs}px ${t.lg}px ${t.md}px`},timelineSeparated:{borderTop:`1px solid ${r.brandBorder}`,marginLeft:ji,paddingLeft:0},timelineRow:{display:"flex",gap:t.md,padding:`${t.md+t.xs/2}px ${t.lg}px`},timelineBubble:{boxSizing:"border-box",flexShrink:0,width:34,height:34,borderRadius:o.pill,backgroundColor:r.brandSoft,border:u},timelineBody:{flex:1,display:"flex",flexDirection:"column",gap:t.xs-1,minWidth:0},timelineKind:{...O(e,"mono"),fontSize:n.size.micro,lineHeight:`${n.size.bodyTight}px`,letterSpacing:n.letterSpacing.eyebrow/3,textTransform:"uppercase",color:r.text.secondary},timelineTitle:{...c(n.size.body,n.lineHeight.normal,r.text.primary,"medium")}}}i(sf,"makeStyles");var K=Object.freeze({title:"Full medical record",shareA11y:"Share medical record",requestClinicsA11y:"Request records from clinics",inReview:i(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.`,"inReview"),needsAttention:"Needs your 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: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:i(e=>`${e} ${e===1?"document":"documents"} on file`,"documentsOnFile"),inReviewChip:i(e=>`${e} in review`,"inReviewChip"),beingVerified:i(e=>`${e} being verified`,"beingVerified"),beingVerifiedA11y:i(e=>`${e} ${e===1?"fact is":"facts are"} being verified`,"beingVerifiedA11y"),pendingReview:"Pending review: ",dateRange:i((e,r)=>`${J(e)} to ${J(r)}`,"dateRange"),documents:"Documents",uploadedDocument:me.uploadedDocument,documentRowA11y:i(e=>`View what ${e} contributed to this record`,"documentRowA11y"),identity:"Identity",needsReview:"Needs review",upcomingCare:"Upcoming care",careTimeline:"Care timeline",careTimelineSub:"Related records grouped over time, newest first.",lastDone:i(e=>`Last done ${e}`,"lastDone"),overdue:"Overdue",due:i(e=>`Due ${e}`,"due"),askUpcomingCare:"Ask Everfur about upcoming care",askEverfur:"Ask Everfur",askExam:"Ask Everfur about this exam",askVisit:"Ask Everfur about this visit",labResults:me.labResults,visits:me.visits,physicalExams:me.physicalExams,visitNotes:me.visitNotes,document:Object.freeze({title:"Health Record",download:"Download record PDF",empty:"This record is empty for now.",docTitle:"Medical Record",namelessPet:"Your pet",generated:i(e=>`Generated ${J(e)}`,"generated"),identity:"Identity",labs:"Blood & Lab Work",ref:i(e=>`Ref ${e}`,"ref"),noRange:"No reference range",upcomingCare:"Upcoming Care",physicalExams:"Physical Exams",clinicianNotes:"Clinician Notes"})}),id=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 qt(e){return Object.prototype.hasOwnProperty.call(id,e)?id[e]:Qr(e)}i(qt,"entityTypeLabel");var Eo=Object.freeze(["vaccination","medication","problem","procedure","allergy","parasite_prevention","reproductive","vital","body_weight"]);function ad(e){let r=Eo.filter(o=>e.includes(o)),t=e.filter(o=>!Eo.includes(o));return [...r,...t]}i(ad,"orderEntityTypes");function xo(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"}}}i(xo,"conflictSeverityMeta");function Dn(e,r){if(!e)return null;let t=Date.parse(e);if(Number.isNaN(t))return null;let o=t<r-1440*60*1e3;return {label:o?K.overdue:K.due(J(e)),overdue:o}}i(Dn,"dueBadge");function sd(e){return e===null?null:e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}`:e.refLow!==null?`\u2265 ${e.refLow}`:e.refHigh!==null?`\u2264 ${e.refHigh}`:null}i(sd,"formatReferenceBand");function ra(e,r={}){let t=pr(),{userRef:o}=ee(),n=r.now??Date.now,[l,a]=react.useState(null),[c,s]=react.useState(true),[d,u]=react.useState(null),[p,m]=react.useState(null),y=p===true,[g,f]=react.useState({}),[R,b]=react.useState(false),[E,h]=react.useState(null),[v,S]=react.useState(false),[C,k]=react.useState(false),_=Qn(e),T=react.useRef(0),I=react.useRef(true),F=react.useCallback(async()=>{let x=T.current+=1;if(s(true),u(null),o===null){a(null),s(false);return}let A=await t.listShares(e);x!==T.current||!I.current||(A.ok?(a(A.value),m(true)):Rt(A.error)?(a(null),m(false)):(a(null),u(A.error),ld(A)&&m(true)),s(false));},[t,e,o]);react.useEffect(()=>(I.current=true,F(),()=>{I.current=false,T.current+=1;}),[F]);let q=react.useRef(_);react.useEffect(()=>{q.current!==_&&(q.current=_,f({}),k(true),F());},[_,F]);let M=react.useCallback(async()=>{b(true);let x=await t.createShare(e);return I.current&&(b(false),x.ok?(f(A=>({...A,[x.value.shareId]:x.value.shareUrl})),F()):Rt(x.error)?m(false):Jr(x.error)&&k(true)),x},[t,e,F]),$=react.useCallback(async x=>{h(x);let A=await t.revokeShare(e,x);return I.current&&(h(null),F()),A},[t,e,F]),V=react.useCallback(async()=>{S(true);let x=await t.getPdfLink(e);return I.current&&(S(false),!x.ok&&Jr(x.error)&&k(true)),x},[t,e]),re=react.useCallback(()=>{k(false),F();},[F]),Q=react.useMemo(()=>El(l??[],g,n()),[l,g,n]),w=c?"loading":d!==null?"error":Q.length===0?"empty":"populated";return react.useMemo(()=>({status:w,rows:Q,available:y,consentRequired:C,error:d,creating:R,revokingId:E,preparingPdf:v,createLink:M,revoke:$,pdfLink:V,refresh:re}),[w,Q,y,C,d,R,E,v,M,$,V,re])}i(ra,"useRecordShares");function ld(e){return e.ok||e.error.httpStatus!==void 0&&e.error.httpStatus!==404}i(ld,"answeredBehindGate");function dd(e){return e.available||e.status!=="empty"}i(dd,"sharesListShown");function ta(e){let r=pr(),{userRef:t}=ee(),o=react.useMemo(()=>({}),[r,e,t]),[n,l]=react.useState({scope:o,lit:null});react.useEffect(()=>{if(t===null)return;let c=true;return r.listShares(e).then(s=>{c&&(!s.ok&&Rt(s.error)?l({scope:o,lit:false}):ld(s)&&l({scope:o,lit:true}));},()=>{}),()=>{c=false;}},[r,e,t,o]);let a=n.scope===o?n.lit:null;return react.useMemo(()=>({lit:a}),[a])}i(ta,"useRecordsDepthProbe");function na(e){let r=pr(),o=ta(e).lit===true,[n,l]=react.useState(false),[a,c]=react.useState(null),s=react.useRef(true);react.useEffect(()=>(s.current=true,()=>{s.current=false;}),[]);let d=react.useCallback(async()=>{l(true),c(null);let u=await r.getPdfLink(e);return s.current&&(l(false),u.ok||c(u.error)),u},[r,e]);return react.useMemo(()=>({preparing:n,available:o,error:a,pdfLink:d}),[n,o,a,d])}i(na,"useRecordPdfLink");var In=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:i(e=>`Call the clinic at ${e}`,"callAt")});var cd=Math.round(jr/(1024*1024)),Nt=Object.freeze({queued:"Queued",verifying:"Verifying\u2026",done:"Done",failed:"Failed",uploading:i((e,r)=>`Uploading ${Math.min(e+1,r)} of ${r} records`,"uploading"),uploaded:i((e,r)=>`${e} of ${r} records uploaded`,"uploaded")});function ud(e){let r=Math.round(e.progress*100);switch(e.status){case "done":return Nt.done;case "failed":return Nt.failed;case "uploading":return e.progress>=1?Nt.verifying:`${r}%`;case "queued":return Nt.queued;default:return null}}i(ud,"uploadItemStatusLabel");function ko(e){if(e.length===0)return null;let r=i(l=>{let a=l.map(c=>c.name??"");return a.length<=3?a.join(", "):`${a.slice(0,3).join(", ")} and ${a.length-3} more`},"nameList"),t=e.filter(l=>l.reason==="too_large"),o=e.filter(l=>l.reason==="unsupported"),n=[];return o.length>0&&n.push(`${r(o)} ${o.length>1?"are not PDFs":"is not a PDF"}`),t.length>0&&n.push(`${r(t)} ${t.length>1?"are":"is"} over ${cd} MB`),`Didn\u2019t upload: ${n.join("; ")}. We can only read PDFs up to ${cd} MB right now.`}i(ko,"skippedFilesMessage");function pd(e){let r=[];for(let t of e)t.status==="skipped"&&t.skipReason!==null&&r.push({name:t.name,reason:t.skipReason});return r}i(pd,"skippedOf");var oa=[37,80,68,70,45],_o="application/pdf,.pdf",lf="application/octet-stream",df="file:web-document";async function cf(e,r){let t=e.slice(0,r);try{return typeof t.arrayBuffer=="function"?new Uint8Array(await t.arrayBuffer()):await new Promise(o=>{let n=new FileReader;n.onload=()=>{o(n.result instanceof ArrayBuffer?new Uint8Array(n.result):new Uint8Array);},n.onerror=()=>o(new Uint8Array),n.readAsArrayBuffer(t);})}catch{return new Uint8Array}}i(cf,"readHead");async function md(e){if(e.size<oa.length)return false;let r=await cf(e,oa.length);return oa.every((t,o)=>r[o]===t)}i(md,"isPdfBlob");async function Po(e){let r=await md(e),t=e.name,o=typeof t=="string"?t:void 0;return Object.freeze({uri:df,mimeType:r?ct:lf,sizeBytes:e.size,blob:e,...o!==void 0?{name:o}:{}})}i(Po,"fileToHandle");function uf(e){let r=e.sizeBytes;return e.mimeType===ct&&typeof r=="number"&&Number.isFinite(r)&&r>0&&r<=jr}i(uf,"isUploadableHandle");function pf(e=document){return new Promise(r=>{let t=e.createElement("input");t.type="file",t.accept=_o,t.hidden=true;let o=i(()=>{t.remove();},"done");t.addEventListener("change",()=>{let n=t.files?.[0];if(o(),n===void 0){r(null);return}Po(n).then(r);},{once:true}),t.addEventListener("cancel",()=>{o(),r(null);},{once:true}),e.body.appendChild(t),t.click();})}i(pf,"pickDocument");var $r=Object.freeze({email:"Clinic email",emailPlaceholder:"records@clinic.com",emailError:"Enter a valid clinic email.",updateEmail:"Update email & resend",updateEmailA11y:"Update clinic email and resend request",retry:"Retry sending",retryA11y:"Retry sending records request",retryHint:"Save the updated email first, then retry.",cancelRequest:"Cancel request",keepRequest:"Keep request",uploadInstead:"Upload instead",cancelQuestion:"Cancel this request?",cancelConsequence:"We\u2019ll 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 fd({request:e,onRecovered:r,canUpload:t=false},o){let[n,l]=react.useState(""),[a,c]=react.useState(false),[s,d]=react.useState(null),[u,p]=react.useState(false),[m,y]=react.useState(null),g=react.useRef(false),f=react.useRef(false),R=react.useRef(0);react.useEffect(()=>(f.current=true,()=>{f.current=false,R.current+=1;}),[o]);let b=m!==null&&m.before===e.updatedAt?{...m.value,canRetrySend:e.canRetrySend===true&&m.value.canRetrySend===true,canUpdateClinicEmail:e.canUpdateClinicEmail===true&&m.value.canUpdateClinicEmail===true,canRevoke:e.canRevoke===true&&m.value.canRevoke===true,canConvertToUpload:e.canConvertToUpload===true&&m.value.canConvertToUpload===true}:e,E=n.trim(),h=E.length<=320&&!Array.from(E).some(T=>T.charCodeAt(0)<=32||T.charCodeAt(0)===127)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(E),v=b.canUpdateClinicEmail===true&&E.length>0,S=b.canRetrySend===true&&!a&&!v,C=b.canUpdateClinicEmail===true&&!a&&h,k=b.canConvertToUpload===true&&t,_=i(async T=>{let I={retry:S,email:C,revoke:b.canRevoke===true&&u,convert:k};if(g.current||!f.current||!I[T])return;g.current=true,c(true),d(null);let F=R.current,q=i(()=>f.current&&F===R.current,"live");try{let M=T==="retry"?await o.retryRequest(e.id):T==="email"?await o.updateClinicEmail(e.id,E):T==="revoke"?await o.revokeRequest(e.id):await o.convertToUpload(e.id);if(!q())return;if(!M.ok){d(M.error);return}if(M.value.id!==e.id||M.value.petRef!==e.petRef){d(z("internalError"));return}y({before:e.updatedAt,value:M.value}),l(""),p(!1),r();}catch{q()&&d(z("internalError"));}finally{g.current=false,q()&&c(false);}},"run");return {request:b,email:n,busy:a,error:s,canRetry:S,canUpdateEmail:C,canConvert:k,hasEmailEdit:v,confirmingRevoke:u&&b.canRevoke===true,emailInvalid:E.length>0&&!h,setEmail(T){g.current||(l(T),d(null));},retry:i(()=>_("retry"),"retry"),updateEmail:i(()=>_("email"),"updateEmail"),revoke:i(()=>_("revoke"),"revoke"),convert:i(()=>_("convert"),"convert"),askRevoke(){!g.current&&b.canRevoke===true&&p(true);},keepRequest(){g.current||p(false);}}}i(fd,"useRecordsRecovery");var ff=["requested","sent_to_clinic","awaiting_clinic","records_received","processing","ready"],yf=["requested","awaiting_upload","records_received","processing","ready"],gf=["requested","sent_to_clinic","awaiting_clinic","awaiting_upload","records_received","processing","ready"],qn=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"}),fr=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\u2019t read this one automatically",manualReview:"Checking these by hand so nothing\u2019s missed",switchedTitle:"Stopped waiting on the clinic",switched:"You switched to uploading your own records"}),bf=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"}),Rf=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 hf(e){return e.wireStatus??Rf[e.status]??"sent"}i(hf,"wireStatusOf");function vf(e,r){return e!=="awaiting_response"||r<=0?null:`${r} ${r===1?"reminder":"reminders"} sent`}i(vf,"reminderProgressLabel");function Cf(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}}i(Cf,"reachedRailIndex");function Ef(e){switch(e.dispatchStatus){case "sent":return fr.delivered;case "preparing":case "queued":case "sending":return fr.emailing;case "failed":return fr.bounced;default:return null}}i(Ef,"deliveryDetail");function xf(e,r){return vf(r,e.reminderCount??0)??fr.waiting}i(xf,"awaitingDetail");function Nn(e){return e.source==="owner_provided"||!!e.convertedToUploadAt}i(Nn,"isOwnerSourcedRequest");function Sf(e,r,t){let o=Nn(r);switch(e){case "sent_to_clinic":return Ef(r);case "awaiting_clinic":return xf(r,t);case "awaiting_upload":return fr.upload;case "records_received":return o?fr.ownerAdded:fr.clinicSent;case "processing":return fr.preparing;case "ready":return fr.ready;default:return null}}i(Sf,"railDetail");function wf(e,r){return !!e.reviewStartedAt||r==="parsing_failed"||r==="review_email_failed"}i(wf,"tookReviewBranch");function kf(e,r,t){if(e.key!=="processing"||!wf(r,t))return [e];let o=t==="parsing_failed",n=t==="published",l=n?"done":o?"current":"done",a=n?"done":o?"upcoming":"current";return [{key:"parsing_failed",title:qn.parsing_failed,detail:fr.parsingFailed,at:null,state:l},{key:"manual_review",title:qn.manual_review,detail:fr.manualReview,at:r.reviewStartedAt??null,state:a}]}i(kf,"expandProcessingPhase");function _f(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}}i(_f,"convertedReachedIndex");function yd(e){return {key:"awaiting_clinic",title:fr.switchedTitle,detail:fr.switched,at:e.convertedToUploadAt??null,state:"done"}}i(yd,"convertedClinicSwitchEvent");function Pf(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}}i(Pf,"ownerReachedIndex");function Tf(e,r,t){switch(e){case "requested":return r.createdAt||null;case "awaiting_clinic":return r.lastReminderAt??null;case "processing":return r.parsingStartedAt??r.reviewStartedAt??null;case "ready":return t==="published"&&r.updatedAt||null;default:return null}}i(Tf,"railTimestamp");function gd(e,r,t,o){return {key:e,title:qn[e],detail:Sf(e,r,t),at:Tf(e,r,t),state:o}}i(gd,"railEvent");function it(e,r){return {key:e,title:qn[e],detail:bf[e]??null,at:r.updatedAt||null,state:"failed"}}i(it,"terminalEvent");function aa(e,r,t,o,n){return e.map((l,a)=>{let c=n?.(l)??null;if(c!==null)return c;let s=o==="published"||a<r?"done":a===r?"current":"upcoming";return gd(l,t,o,s)}).flatMap(l=>kf(l,t,o))}i(aa,"walkRail");function sa(e){let r=hf(e),t=i(n=>gd(n,e,r,"done"),"done");if(r==="revoked")return [t("requested"),it("revoked",e)];if(e.convertedToUploadAt)return r==="failed"?[t("requested"),t("sent_to_clinic"),yd(e),t("awaiting_upload"),t("records_received"),it("processing_failed",e)]:aa(gf,_f(r),e,r,n=>n==="awaiting_clinic"?yd(e):null);if(e.source==="owner_provided"){if(r==="failed"||r==="clinic_declined")return [t("requested"),t("awaiting_upload"),t("records_received"),it("processing_failed",e)];let n=Pf(r);return aa(yf,n<0?1:n,e,r)}if(r==="clinic_declined")return [t("requested"),t("sent_to_clinic"),t("awaiting_clinic"),it("clinic_declined",e)];if(r==="clinic_responded_no_records")return [t("requested"),t("sent_to_clinic"),t("awaiting_clinic"),it("clinic_no_records",e)];if(r==="failed"){let n=e.failureCode??null;return n==="no_response"?[t("requested"),t("sent_to_clinic"),t("awaiting_clinic"),it("no_response",e)]:n==="hard_bounce"||n==="dispatch_failed"?[t("requested"),it("delivery_failed",e)]:n==="parse_timeout"||n==="parse_error"||e.dispatchStatus==="sent"?[t("requested"),t("sent_to_clinic"),t("awaiting_clinic"),t("records_received"),it("processing_failed",e)]:[t("requested"),it("delivery_failed",e)]}let o=Cf(r);return aa(ff,o<0?1:o,e,r)}i(sa,"buildRequestTimeline");var Of=Object.freeze({done:"completed",current:"in progress",failed:"needs attention",upcoming:"not started"}),To=24;function rn({request:e}){let r=qf(),t=sa(e);return jsxRuntime.jsx("ol",{style:r.list,"aria-label":ue.timelineA11y,"data-testid":"records-timeline",children:t.map((o,n)=>jsxRuntime.jsx(If,{event:o,isLast:n===t.length-1,styles:r},o.key))})}i(rn,"RequestTimeline");function If({event:e,isLast:r,styles:t}){let o=e.at?J(e.at):null,n={...t.title,...e.state==="current"?t.titleCurrent:{},...e.state==="failed"?t.titleFailed:{},...e.state==="upcoming"?t.titleUpcoming:{}};return jsxRuntime.jsxs("li",{style:t.row,"data-testid":`records-timeline-${e.key}`,children:[jsxRuntime.jsxs("div",{style:t.railColumn,"aria-hidden":"true",children:[jsxRuntime.jsx(Af,{state:e.state,styles:t}),r?null:jsxRuntime.jsx("div",{style:{...t.connector,...e.state==="done"?t.connectorDone:{}}})]}),jsxRuntime.jsxs("div",{style:t.body,children:[jsxRuntime.jsxs("div",{style:t.titleRow,children:[jsxRuntime.jsx("span",{style:n,children:e.title}),o&&e.at?jsxRuntime.jsx("time",{dateTime:e.at,style:t.date,children:o}):null]}),e.detail?jsxRuntime.jsx("span",{style:{...t.detail,...e.state==="upcoming"?t.detailUpcoming:{}},children:e.detail}):null,jsxRuntime.jsx("span",{style:t.srOnly,children:Of[e.state]})]})]})}i(If,"TimelineRow");function Af({state:e,styles:r}){return e==="done"?jsxRuntime.jsx("div",{style:{...r.dot,...r.dotDone},children:"\u2713"}):e==="failed"?jsxRuntime.jsx("div",{style:{...r.dot,...r.dotFailed},children:"!"}):e==="current"?jsxRuntime.jsx("div",{style:{...r.dot,...r.dotCurrent},children:jsxRuntime.jsx("div",{style:r.dotCurrentCore})}):jsxRuntime.jsx("div",{style:{...r.dot,...r.dotUpcoming}})}i(Af,"Dot");function qf(){let e=ce();return react.useMemo(()=>Nf(e),[e])}i(qf,"useStyles");function Nf(e){let{color:r}=e,t={boxSizing:"border-box",width:To,height:To,borderRadius:To/2,display:"flex",alignItems:"center",justifyContent:"center",...O(e,"bold"),fontSize:12,lineHeight:"14px"};return {list:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column"},row:{display:"flex",alignItems:"flex-start",gap:12},railColumn:{display:"flex",flexDirection:"column",alignItems:"center",alignSelf:"stretch",width:To,flexShrink:0},body:{flex:1,minWidth:0,paddingBottom:18,display:"flex",flexDirection:"column",gap:2},titleRow:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},dot:t,dotDone:{backgroundColor:r.brand,color:r.surface},dotFailed:{backgroundColor:r.danger,color:r.surface},dotCurrent:{border:`2px solid ${r.brand}`,backgroundColor:r.surface},dotCurrentCore:{width:10,height:10,borderRadius:5,backgroundColor:r.brand},dotUpcoming:{border:`2px solid ${r.borderHairlineGreen}`,backgroundColor:r.surface},connector:{width:2,flex:1,minHeight:22,backgroundColor:r.borderHairlineGreen,margin:"2px 0"},connectorDone:{backgroundColor:r.brand},title:{flex:1,...O(e,"bold"),fontSize:14,lineHeight:"18px",color:r.text.primary},titleCurrent:{color:r.brand},titleFailed:{color:r.danger},titleUpcoming:{color:r.text.muted,...O(e,"regular")},date:{...O(e,"regular"),fontSize:12,lineHeight:"16px",color:r.text.muted},detail:{...O(e,"regular"),fontSize:13,lineHeight:"17px",color:r.text.muted},detailUpcoming:{opacity:.7},srOnly:{position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0}}}i(Nf,"makeStyles");function bd(e){return e.value!==null&&Number.isFinite(e.value)}i(bd,"isFinitePoint");function Oo(e){return e.display!==null&&e.display.length>0?e.display:e.value!==null?String(e.value):""}i(Oo,"pointDisplay");function Rd(e){let r=e.find(C=>C.points.some(bd));if(r===void 0)return null;let t=r.points.filter(bd),o=t[0];if(o===void 0)return null;let n=t.map(C=>C.value),l=Math.min(...n),a=Math.max(...n);l===a&&(l-=1,a+=1);let c=(a-l)*.18,s=l-c,d=a+c,u=d-s,p=6,m=t.length,y=t.map((C,k)=>({xPct:m<=1?50:p+k/(m-1)*(100-2*p),yPct:(d-C.value)/u*100})),g=(d-a)/u*100,f=(d-l)/u*100,R=t.reduce((C,k)=>k.value<C.value?k:C,o),b=t.reduce((C,k)=>k.value>C.value?k:C,o),E=t[t.length-1]??o,h=r.points[r.points.length-1]??E,v=Oo(h),S=v.length>0?v:Oo(E);return {label:r.label,heroDisplay:S,minDisplay:Oo(R),maxDisplay:Oo(b),firstDate:Mi(r.points[0]?.at??null),lastDate:Mi(h.at),points:y,bandTopPct:g,bandBottomPct:f}}i(Rd,"buildTrendModel");function Lf(e){let r=e.indexOf(":");return r<=0?null:e.slice(0,r)}i(Lf,"entityTypeOf");function hd(e,r,t){let o=new Map,n=[];for(let c of e){let s=Lf(c.key)??"",d=o.get(s);d===void 0?(o.set(s,[c]),n.push(s)):d.push(c);}let l=r.filter(c=>o.has(c)),a=n.filter(c=>!l.includes(c));return Object.freeze([...l,...a].map(c=>Object.freeze({entityType:c.length>0?c:null,label:c.length>0?t(c):null,series:Object.freeze([...o.get(c)??[]])})))}i(hd,"groupSeriesByEntityType");function vd({series:e}){let r=ce(),t=react.useMemo(()=>Mf(r),[r]),o=react.useMemo(()=>hd(e,Eo,qt),[e]);return o.length===0?null:jsxRuntime.jsxs("section",{"aria-label":K.careTimeline,style:t.section,children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{style:t.sectionTitle,children:K.careTimeline}),jsxRuntime.jsx("p",{style:t.sectionSub,children:K.careTimelineSub})]}),o.map(n=>jsxRuntime.jsxs("div",{style:t.group,children:[n.label===null?null:jsxRuntime.jsx("p",{style:t.eyebrow,children:n.label}),n.series.map(l=>jsxRuntime.jsx(Ff,{series:l,styles:t},l.key))]},n.entityType??"_"))]})}i(vd,"TrendRangeCard");function Ff({series:e,styles:r}){let t=react.useMemo(()=>Rd([e]),[e]);if(t===null){let n=e.points[e.points.length-1]?.display??null;return jsxRuntime.jsxs("div",{style:r.card,children:[jsxRuntime.jsx("p",{style:r.eyebrow,children:e.label}),n!==null&&n.length>0?jsxRuntime.jsx("p",{style:r.hero,children:n}):null]})}return jsxRuntime.jsx(zf,{model:t,styles:r})}i(Ff,"SeriesChart");function zf({model:e,styles:r}){let t=e.heroDisplay.length>0?`${e.label}, ${e.heroDisplay}`:e.label,o=Math.max(0,e.bandBottomPct-e.bandTopPct),n=e.points.length-1;return jsxRuntime.jsxs("div",{style:r.card,children:[jsxRuntime.jsxs("div",{role:"img","aria-label":t,children:[jsxRuntime.jsx("p",{style:r.eyebrow,children:e.label}),e.heroDisplay.length>0?jsxRuntime.jsx("p",{style:r.hero,children:e.heroDisplay}):null]}),jsxRuntime.jsxs("div",{"aria-hidden":"true",style:r.plot,children:[e.points.map((l,a)=>jsxRuntime.jsx("div",{style:{...r.guide,left:`${l.xPct}%`}},`g-${a}`)),jsxRuntime.jsx("div",{style:{...r.band,top:`${e.bandTopPct}%`,height:`${o}%`}}),e.points.map((l,a)=>jsxRuntime.jsx("div",{style:{...r.point,...a===n?r.pointLatest:null,left:`${l.xPct}%`,top:`${l.yPct}%`}},`pt-${a}`)),e.maxDisplay.length>0?jsxRuntime.jsx("span",{style:{...r.edgeLabel,top:`${e.bandTopPct}%`},children:e.maxDisplay}):null,e.minDisplay.length>0?jsxRuntime.jsx("span",{style:{...r.edgeLabel,top:`${e.bandBottomPct}%`},children:e.minDisplay}):null]}),e.firstDate.length>0||e.lastDate.length>0?jsxRuntime.jsxs("div",{"aria-hidden":"true",style:r.dates,children:[jsxRuntime.jsx("span",{children:e.firstDate}),jsxRuntime.jsx("span",{children:e.lastDate})]}):null]})}i(zf,"TrendChart");function Mf(e){let{color:r,space:t,radius:o,type:n}=e,l=i((c,s)=>`${Math.round(c*s)}px`,"lh"),a=t.sm;return {section:{display:"flex",flexDirection:"column",gap:t.lg},sectionTitle:{margin:0,...O(e,"bold"),fontSize:n.size.bodyTight,lineHeight:l(n.size.bodyTight,n.lineHeight.tight),color:r.text.primary},sectionSub:{margin:`${t.xs}px 0 0`,...O(e,"regular"),fontSize:n.size.caption,lineHeight:l(n.size.caption,n.lineHeight.normal),color:r.text.muted},group:{display:"flex",flexDirection:"column",gap:t.sm},card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.sm,padding:t.lg,borderRadius:o.md,backgroundColor:r.surfaceCream,border:`1px solid ${r.brandBorder}`},eyebrow:{margin:0,...O(e,"regular"),fontSize:n.size.caption,lineHeight:l(n.size.caption,n.lineHeight.normal),color:r.text.muted,letterSpacing:n.letterSpacing.eyebrow,textTransform:"uppercase",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},hero:{margin:0,...O(e,"bold"),fontSize:n.size.verdict,lineHeight:l(n.size.verdict,n.lineHeight.tight),color:r.text.primary,letterSpacing:n.letterSpacing.tight},plot:{position:"relative",height:t.xxl*3,marginTop:t.xs},guide:{position:"absolute",top:0,bottom:0,width:1,backgroundColor:r.borderHairlineGreen},band:{position:"absolute",left:t.xs,right:t.xs,borderRadius:o.sm,backgroundColor:r.brandSoft},point:{boxSizing:"border-box",position:"absolute",width:a,height:a,marginLeft:-(a/2),marginTop:-(a/2),borderRadius:o.pill,backgroundColor:r.brand,border:`1px solid ${r.surfaceCream}`},pointLatest:{backgroundColor:r.accent,borderColor:r.onAccent},edgeLabel:{position:"absolute",right:0,marginTop:-t.sm,...O(e,"medium"),fontSize:n.size.tiny,lineHeight:l(n.size.tiny,n.lineHeight.tight),color:r.text.muted,whiteSpace:"nowrap"},dates:{display:"flex",justifyContent:"space-between",...O(e,"regular"),fontSize:n.size.tiny,lineHeight:l(n.size.tiny,n.lineHeight.normal),color:r.text.muted}}}i(Mf,"makeStyles");var jf=300,Hf=900,Ed=120,xd=44,Sd=40,wd=24,Vf=3;function vt(e,r,t){let o=Wr(e,t);switch(o.kind){case "consent_required":return jsxRuntime.jsx(Wf,{onGrant:r});case "consent_unavailable":return jsxRuntime.jsx(Je,{label:G.consentRequired,glyph:"empty"});case "session_required":return jsxRuntime.jsx(Je,{label:G.sessionRequired,glyph:"empty"});case "withheld":return jsxRuntime.jsx(Je,{label:G.recordUnavailable,glyph:"withheld"});case "pet_not_found":case "error":return jsxRuntime.jsx(Gf,{error:o.error,onRetry:e.refresh});default:return Dr(o)}}i(vt,"renderErrorFamily");function kd(){let{theme:e,styles:r}=nn(),[t,o]=react.useState(false),n=react.useRef(null);react.useEffect(()=>{let a=setTimeout(()=>o(true),jf);return ()=>clearTimeout(a)},[]);let l=t&&!e.motion.reducedMotion;return react.useEffect(()=>{let a=n.current;if(!l||a===null||typeof a.animate!="function")return;let c=a.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:Hf,iterations:1/0});return ()=>c.cancel()},[l]),jsxRuntime.jsx("div",{role:"status","aria-busy":"true","aria-label":G.loading,style:r.centered,children:t?jsxRuntime.jsx("div",{ref:n,"aria-hidden":"true",style:r.spinner}):null})}i(kd,"LoadingState");function _d({records:e}){let{styles:r}=nn(),t=e.uploadQueue;if(t.length===0)return null;let o=t.filter(a=>a.status!=="skipped"),n=o.filter(a=>a.status==="done").length,l=ko(pd(t));return jsxRuntime.jsxs("div",{style:r.card,"data-testid":"records-upload-queue",children:[l!==null?jsxRuntime.jsx("p",{role:"alert",style:r.errorText,children:l}):null,o.length>0?jsxRuntime.jsx("ul",{"aria-live":"polite","aria-label":e.isUploading?Nt.uploading(n,o.length):Nt.uploaded(n,o.length),style:{listStyle:"none",margin:0,padding:0},children:o.map(a=>{let c=Math.round(a.progress*100);return jsxRuntime.jsxs("li",{style:r.row,"data-testid":`records-upload-file-${a.status}`,children:[jsxRuntime.jsx("span",{style:r.rowLabel,children:a.name??""}),jsxRuntime.jsx("span",{style:r.rowValue,children:ud(a)}),a.status==="uploading"?jsxRuntime.jsx("progress",{max:100,value:c,style:{width:"100%"}}):null,a.status==="failed"&&a.error?jsxRuntime.jsx("span",{style:r.timelineMeta,children:a.error.displayMessage}):null]},a.key)})}):null]})}i(_d,"UploadQueue");function Wf({onGrant:e}){let{styles:r}=nn();return jsxRuntime.jsxs("div",{role:"alert","aria-live":"assertive",style:r.centered,children:[jsxRuntime.jsx("p",{style:r.alertText,children:G.consentRequired}),jsxRuntime.jsx("button",{type:"button",onClick:e,style:r.primaryButton,children:G.allow})]})}i(Wf,"ConsentRequiredState");function Je({label:e,glyph:r}){let{styles:t}=nn();return jsxRuntime.jsxs("div",{role:"alert","aria-live":"assertive",style:t.centered,children:[jsxRuntime.jsx("div",{"aria-hidden":"true",style:r==="withheld"?t.withheldGlyph:t.emptyGlyph}),jsxRuntime.jsx("p",{style:t.alertText,children:e})]})}i(Je,"AlertState");function Gf({error:e,onRetry:r}){let{styles:t}=nn();return jsxRuntime.jsxs("div",{role:"alert","aria-live":"assertive",style:t.centered,children:[jsxRuntime.jsx("p",{style:t.errorText,children:e.displayMessage}),e.retryable?jsxRuntime.jsx("button",{type:"button",onClick:r,style:t.primaryButton,children:G.retry}):null]})}i(Gf,"ErrorState");function Pd({call:e,prompt:r}){let{styles:t}=nn(),o=r.trim().length>0?r:In.fallbackPrompt;return jsxRuntime.jsxs("div",{style:t.callCard,children:[jsxRuntime.jsx("p",{style:t.timelineLabel,children:In.heading}),jsxRuntime.jsx("p",{style:t.timelineMeta,children:o}),jsxRuntime.jsx("a",{href:e.dial,"aria-label":In.callAt(e.phone),style:t.linkButton,"data-testid":"records-call-clinic",children:In.call})]})}i(Pd,"ClinicCallCard");function nn(){let e=ce(),r=react.useMemo(()=>Yf(e),[e]);return {theme:e,styles:r}}i(nn,"useRecordsTheme");function Yf(e){let{color:r,space:t,radius:o,type:n,slots:l}=e,a=i((f,R)=>`${Math.round(f*R)}px`,"lh"),c=`1px solid ${r.brandBorder}`,s=Ar(l.recordCard,1),d=Yr(l.recordCard),u=i((f,R,b,E="regular")=>({margin:0,...O(e,E),fontSize:f,lineHeight:a(f,R),color:b}),"text"),p=i((f,R,b,E="regular")=>({...u(f,R,b,E),...d}),"inCard"),m={boxSizing:"border-box",minHeight:xd,minWidth:xd,padding:`${t.md}px ${t.xl}px`,borderRadius:o.pill,...O(e,"bold"),fontSize:n.size.body,letterSpacing:n.letterSpacing.tight},y={boxSizing:"border-box",width:Sd,height:Sd},g=e.brightness==="dark"?r.errorRed:r.danger;return {container:{boxSizing:"border-box",display:"flex",flexDirection:"column",minHeight:Ed,height:"100%",backgroundColor:r.background,color:r.text.primary,...O(e,"regular")},body:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",overflowY:"auto"},centered:{boxSizing:"border-box",flex:"1 1 auto",minHeight:Ed,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:t.lg,padding:t.xl,textAlign:"center"},spinner:{boxSizing:"border-box",width:wd,height:wd,borderRadius:o.pill,border:`${Vf}px solid ${r.brandSofter}`,borderTopColor:r.brand},emptyGlyph:{...y,borderRadius:o.lg,backgroundColor:r.brandSoft,border:c},withheldGlyph:{...y,borderRadius:o.sm,backgroundColor:r.badgeBgCaution,border:`1px solid ${r.cautionAccent}`},alertText:u(n.size.subtitle,n.lineHeight.snug,r.text.secondary),errorText:u(n.size.subtitle,n.lineHeight.snug,g),primaryButton:{...m,border:0,cursor:"pointer",backgroundColor:r.primary,color:r.onPrimary,...Ar(l.primaryButton),...Yr(l.primaryButton)},disabledButton:{...m,border:c,cursor:"default",backgroundColor:r.surfaceSubtle,color:r.text.muted},list:{display:"flex",flexDirection:"column",gap:t.md,padding:t.lg},card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.xs,padding:`${t.md}px ${t.lg}px`,borderRadius:o.md,backgroundColor:r.surfaceCream,border:c,...s},cardTitle:{...p(n.size.heading,n.lineHeight.snug,r.text.primary,"bold"),letterSpacing:n.letterSpacing.tight},callCard:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.sm,padding:t.md,borderRadius:o.md,backgroundColor:r.surfaceCream,border:c,...s},linkButton:{...m,display:"inline-flex",alignItems:"center",justifyContent:"center",alignSelf:"flex-start",textDecoration:"none",border:0,backgroundColor:r.primary,color:r.onPrimary,...Ar(l.primaryButton),...Yr(l.primaryButton)},timelineLabel:{...p(n.size.subtitle,n.lineHeight.snug,r.text.secondary,"bold")},timelineMeta:p(n.size.bodyTight,n.lineHeight.normal,r.text.muted),row:{display:"flex",justifyContent:"space-between",gap:t.md,padding:`${t.xs}px 0`,borderBottom:`1px solid ${r.borderHairlineGreen}`},rowLabel:p(n.size.body,n.lineHeight.normal,r.text.muted),rowValue:{...p(n.size.body,n.lineHeight.normal,r.text.primary,"medium"),textAlign:"right"},disclaimer:u(n.size.caption,n.lineHeight.normal,r.text.muted)}}i(Yf,"makeStyles");var Io="everfur-record.pdf";function Ao(e){return typeof navigator>"u"||!navigator.clipboard?Promise.reject(new Error("clipboard unavailable")):navigator.clipboard.writeText(e)}i(Ao,"copyText");function Kf(e){return typeof e=="object"&&e!==null&&e.name==="AbortError"}i(Kf,"isAbort");async function Dd(e,r=Ao){let t=typeof navigator>"u"?void 0:navigator;if(t!==void 0&&typeof t.share=="function")try{return await t.share({url:e}),"shared"}catch(o){if(Kf(o))return "dismissed"}return await r(e),"copied"}i(Dd,"shareLinkInPlace");function Qf(e,r){let t;try{t=new URL(e,r);}catch{return null}if(t.protocol==="blob:"||t.protocol==="data:")return "download";if(r!==void 0)try{if(new URL(r).origin===t.origin)return "download"}catch{}let o=t.searchParams.get("response-content-disposition");return o!==null&&/^\s*attachment\b/i.test(o)?"attachment":null}i(Qf,"inPlaceRoute");function Xf(){return typeof location>"u"?void 0:location.href}i(Xf,"locationHref");function Jf(e=typeof window>"u"?void 0:window){if(e===void 0)return false;try{return e.self!==e.top}catch{return true}}i(Jf,"isFramedDocument");function Td(e,r){let t=document.createElement("a");t.href=e,t.download=r,t.rel="noopener",t.style.display="none",document.body.appendChild(t);try{t.click();}finally{t.remove();}}i(Td,"clickDownload");var Zf=6e4;function ey(e){let r=document.createElement("iframe");r.setAttribute("sandbox","allow-downloads"),r.setAttribute("aria-hidden","true"),r.tabIndex=-1,r.style.display="none",r.src=e,document.body.appendChild(r),setTimeout(()=>r.remove(),Zf);}i(ey,"saveThroughNestedFrame");async function on(e,r,t=Jf()){if(typeof document>"u")return false;let o=Qf(e,Xf());if(o==="attachment"&&t)return ey(e),true;if(o!==null)return Td(e,r),true;let n;try{let a=await fetch(e,{credentials:"omit"});if(!a.ok)return !1;n=await a.blob();}catch{return false}let l=URL.createObjectURL(n);try{Td(l,r);}finally{setTimeout(()=>URL.revokeObjectURL(l),1e4);}return true}i(on,"downloadInPlace");var gr=K.document,Od=Object.freeze(["medication","vaccination","problem","allergy","procedure","body_weight","vital"]),ty=i((e,r)=>e.getRecordDepth(r),"readDepth"),ny=i(e=>!e.available,"depthEmpty");function oy(e,r){return e.identity.length===0&&e.entities.length===0&&e.forwardLooking.length===0&&(r===null||r.labResults.length===0&&r.physicalExams.length===0&&r.clinicianNotes.length===0)}i(oy,"documentIsEmpty");function Ln(e){let{style:r,className:t,renderPending:o,...n}=_e(e,["onBack"]),{userRef:l}=ee(),{theme:a,styles:c}=j();return jsxRuntime.jsx(Te,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Oe(n.onBack,Le),children:jsxRuntime.jsxs("div",{className:t,style:{...c.root,backgroundColor:a.color.surface,...r},"data-testid":"record-document-screen",children:[l===null?jsxRuntime.jsx("div",{style:c.body,children:jsxRuntime.jsx(Je,{label:G.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(iy,{...n}),jsxRuntime.jsx(De,{})]})})}i(Ln,"EverfurRecordDocument");function iy({petRef:e,petName:r,controller:t,consentVersion:o,onBack:n,onOpenUrl:l}){let{theme:a,styles:c}=j(),s=Id(),d=react.useMemo(()=>t?{petRef:e,controller:t}:{petRef:e},[e,t]),u=We(d),p=zr(e,ty,ny),m=na(e),y=tt(o,u.consent),g=i(()=>{let C=Vr(o,u.consent);C.length!==0&&u.grantConsent(C,`records-consent-${Date.now().toString(36)}`);},"onGrant"),f=p.value!==null&&!p.value.withheld&&p.value.available?p.value:null,R=u.record,[b,E]=react.useState(false),h=i(()=>{E(false),m.pdfLink().then(C=>{C.ok&&(l?Et(l,C.value.downloadUrl,"record_pdf"):on(C.value.downloadUrl,Io).then(k=>E(!k)));});},"download"),v,S=false;if(u.status==="loading"||p.status==="loading"&&R!==null)v=jsxRuntime.jsx("div",{"data-testid":"record-document-loading",children:jsxRuntime.jsx(kd,{})});else if(u.status==="error"){let C=Wr(u,y);v=C.kind==="error"||C.kind==="pet_not_found"?jsxRuntime.jsx(Fe,{variant:Xe(C.error),message:C.error.displayMessage,onAction:C.error.retryable?()=>{u.refresh(),p.refresh();}:void 0,testID:"record-document-error"}):vt(u,g,y);}else R===null||oy(R,f)?v=jsxRuntime.jsx("p",{style:s.empty,"data-testid":"record-document-empty",children:gr.empty}):(S=true,v=jsxRuntime.jsx(ay,{record:R,depth:f,petName:r,wordmark:a.meta.displayName}));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(He,{title:gr.title,variant:"document",onBack:n,testID:"record-document-header",right:m.available&&S?jsxRuntime.jsx("button",{type:"button",onClick:h,disabled:m.preparing,"aria-busy":m.preparing,"aria-label":gr.download,style:c.iconButton,"data-testid":"record-document-download",children:jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"block",width:12,height:12,borderLeft:`2px solid ${a.color.brand}`,borderBottom:`2px solid ${a.color.brand}`,transform:"rotate(-45deg)"}})}):void 0}),m.error?jsxRuntime.jsx("p",{role:"alert",style:{...c.errorText,padding:`0 ${a.space.lg}px`},children:m.error.displayMessage}):b?jsxRuntime.jsx("p",{role:"alert",style:{...c.errorText,padding:`0 ${a.space.lg}px`},"data-testid":"record-document-save-failed",children:_t(null,"download")}):null,jsxRuntime.jsx("div",{style:c.body,children:v})]})}i(iy,"DocumentBody");function ay({record:e,depth:r,petName:t,wordmark:o}){let n=Id(),l=react.useMemo(()=>{let d=[],u=new Map;for(let y of e.entities){let g=y.category.trim();if(g.length===0)continue;let f=u.get(g);f===void 0?(d.push(g),u.set(g,[y])):f.push(y);}let p=Od.filter(y=>d.includes(y)),m=d.filter(y=>!Od.includes(y));return [...p,...m].map(y=>({type:y,rows:u.get(y)??[]}))},[e.entities]),a=Date.now(),c=i((d,u,p)=>jsxRuntime.jsxs("section",{style:n.section,"data-testid":p,children:[jsxRuntime.jsxs("div",{style:n.sectionHeader,children:[jsxRuntime.jsx("h3",{style:n.sectionTitle,children:d}),jsxRuntime.jsx("span",{style:n.rule})]}),jsxRuntime.jsx("div",{children:u})]},p),"section"),s=i((d,u)=>({...n.row,...d>0?n.rowDivider:{},...u}),"row");return jsxRuntime.jsxs("article",{style:n.page,"data-testid":"record-document",children:[jsxRuntime.jsxs("header",{style:n.letterhead,children:[jsxRuntime.jsx("span",{style:n.wordmark,children:o}),jsxRuntime.jsx("span",{style:n.docTitle,children:gr.docTitle}),jsxRuntime.jsx("span",{style:n.petName,children:t?.trim()||gr.namelessPet}),jsxRuntime.jsx("span",{style:n.generated,children:gr.generated(e.generatedAt)})]}),e.identity.length>0?c(gr.identity,e.identity.map((d,u)=>jsxRuntime.jsxs("div",{style:s(u),children:[jsxRuntime.jsx("span",{style:n.rowLabel,children:d.label}),jsxRuntime.jsx("span",{style:n.rowValue,children:d.value})]},`${u}:${d.label}`)),"record-document-identity"):null,r&&r.labResults.length>0?c(gr.labs,r.labResults.map((d,u)=>{let p=Kr(d.latest.status),m=sd(d.points[d.points.length-1]??null),y=ur(d.latest.value,d.latest.unit??d.unit,d.latest.qualitativeResult);return jsxRuntime.jsxs("div",{style:s(u,p.outOfRange?n.rowFlag:void 0),children:[jsxRuntime.jsxs("span",{style:n.rowMain,children:[jsxRuntime.jsx("span",{style:n.rowLabel,children:d.name}),jsxRuntime.jsxs("span",{style:n.rowMeta,children:[m?gr.ref(m):gr.noRange,d.latest.at?` \xB7 ${J(d.latest.at)}`:""]})]}),jsxRuntime.jsxs("span",{style:n.rowRight,children:[y!=="-"?jsxRuntime.jsx("span",{style:{...n.rowValue,...p.outOfRange?n.alert:{}},children:y}):null,jsxRuntime.jsx("span",{style:{...n.markerStatus,...p.outOfRange?n.alert:{}},children:p.label})]})]},d.markerId)}),"record-document-labs"):null,l.map(({type:d,rows:u})=>c(qt(d),u.map((p,m)=>{let y=[Ht(p.value,p.unit),p.observedAt?J(p.observedAt):null].filter(g=>g&&g.length>0).join(" \xB7 ");return jsxRuntime.jsx("div",{style:s(m),children:jsxRuntime.jsxs("span",{style:n.rowMain,children:[jsxRuntime.jsx("span",{style:n.rowLabel,children:p.label}),y?jsxRuntime.jsx("span",{style:n.rowMeta,children:y}):null]})},p.key)}),`record-document-${d}`)),e.forwardLooking.length>0?c(gr.upcomingCare,e.forwardLooking.map((d,u)=>{let p=Dn(d.dueAt,a);return jsxRuntime.jsxs("div",{style:s(u),children:[jsxRuntime.jsxs("span",{style:n.rowMain,children:[jsxRuntime.jsx("span",{style:n.rowLabel,children:d.title}),d.detail?jsxRuntime.jsx("span",{style:n.rowMeta,children:d.detail}):null]}),p?jsxRuntime.jsx("span",{style:{...n.rowValue,...p.overdue?n.alert:{}},children:p.label}):null]},`${d.title}-${u}`)}),"record-document-upcoming"):null,r&&r.physicalExams.length>0?c(gr.physicalExams,r.physicalExams.map((d,u)=>jsxRuntime.jsxs("div",{style:{...n.block,...u>0?n.rowDivider:{}},children:[d.observedOn?jsxRuntime.jsx("span",{style:n.blockDate,children:J(d.observedOn)}):null,d.systems.filter(p=>p.finding).map(p=>jsxRuntime.jsxs("div",{style:n.fieldRow,children:[jsxRuntime.jsx("span",{style:n.fieldLabel,children:Wt(p.system)}),jsxRuntime.jsx("span",{style:n.fieldValue,children:p.finding})]},p.system))]},d.examId)),"record-document-exams"):null,r&&r.clinicianNotes.length>0?c(gr.clinicianNotes,r.clinicianNotes.map((d,u)=>jsxRuntime.jsxs("div",{style:{...n.block,...u>0?n.rowDivider:{}},children:[d.observedOn?jsxRuntime.jsx("span",{style:n.blockDate,children:J(d.observedOn)}):null,d.sections.filter(p=>p.text).map((p,m)=>jsxRuntime.jsxs("div",{style:n.noteSection,children:[jsxRuntime.jsx("span",{style:n.noteLabel,children:Gt(p.section)}),jsxRuntime.jsx("p",{style:n.noteBody,children:p.text})]},`${p.section}-${m}`))]},d.noteId)),"record-document-notes"):null,e.disclaimer.length>0?jsxRuntime.jsx("p",{style:n.disclaimer,children:e.disclaimer}):null]})}i(ay,"RecordDocument");function Id(){let e=ce();return react.useMemo(()=>sy(e),[e])}i(Id,"useDocStyles");function sy(e){let{color:r,space:t,radius:o,type:n}=e,l=i((s,d,u,p="regular")=>({margin:0,...O(e,p),fontSize:s,lineHeight:`${Math.round(s*d)}px`,color:u}),"text"),a=i((s,d)=>({margin:0,...O(e,"mono"),fontSize:s,lineHeight:`${s+t.xs-1}px`,color:d,letterSpacing:n.letterSpacing.eyebrow/2,textTransform:"uppercase"}),"monoText"),c=`1px solid ${r.borderHairlineGreen}`;return {empty:{...l(n.size.body,n.lineHeight.normal,r.text.muted,"medium"),textAlign:"center",padding:`${t.xxl}px ${t.xxl}px`},page:{padding:`0 ${t.lg+t.xs}px ${t.xxl+t.lg}px`,...O(e,"regular")},letterhead:{display:"flex",flexDirection:"column",alignItems:"center",gap:t.xs+t.xs/2,padding:`${t.md}px 0 ${t.lg+t.xs+t.xs/2}px`,borderBottom:`2px solid ${r.brand}`,marginBottom:t.sm},wordmark:{...l(n.size.heading,n.lineHeight.snug,r.brand,"bold"),letterSpacing:n.letterSpacing.headerBrand},docTitle:{...a(n.size.caption,r.brand),marginTop:t.sm+t.xs/2,letterSpacing:n.letterSpacing.eyebrow+.4},petName:l(n.size.verdict+t.xs/2,n.lineHeight.tight,r.text.primary),generated:{...a(n.size.tiny,r.text.muted),textTransform:"none"},section:{marginTop:t.lg+t.xs+t.xs/2},sectionHeader:{display:"flex",alignItems:"center",gap:t.sm+t.xs/2,marginBottom:t.sm},sectionTitle:a(n.size.tiny,r.brand),rule:{flex:1,height:1,backgroundColor:r.borderHairlineGreen},row:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:t.md+t.xs/2,padding:`${t.sm+1}px 0`},rowDivider:{borderTop:c},rowFlag:{backgroundColor:r.badgeBgCritical,margin:`0 -${t.sm}px`,padding:`${t.sm+1}px ${t.sm}px`,borderRadius:o.xs},rowMain:{display:"flex",flexDirection:"column",minWidth:0},rowRight:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:t.xs/2},rowLabel:{...l(n.size.body,n.lineHeight.normal,r.text.primary,"medium")},rowValue:{...l(n.size.body,n.lineHeight.normal,r.text.primary,"bold"),textAlign:"right"},alert:{color:r.danger},rowMeta:{marginTop:t.xs/2,...O(e,"mono"),fontSize:n.size.tiny,lineHeight:`${n.size.body}px`,color:r.text.muted},markerStatus:a(n.size.micro,r.text.muted),block:{padding:`${t.sm+t.xs/2}px 0`},blockDate:{...a(n.size.tiny,r.text.muted),display:"block",marginBottom:t.xs+t.xs/2},fieldRow:{display:"flex",alignItems:"flex-start",gap:t.md+t.xs/2,padding:`${t.xs-1}px 0`},fieldLabel:{width:120,flexShrink:0,...l(n.size.bodyTight,n.lineHeight.normal,r.text.muted,"medium")},fieldValue:{flex:1,...l(n.size.bodyTight,n.lineHeight.normal,r.text.primary,"medium")},noteSection:{marginTop:t.sm},noteLabel:{...a(n.size.tiny,r.brand),display:"block",marginBottom:t.xs/2},noteBody:l(n.size.bodyTight,n.lineHeight.relaxed,r.text.primary),disclaimer:{...l(n.size.tiny,n.lineHeight.relaxed,r.text.muted),marginTop:o.xl,paddingTop:t.md+t.xs/2,borderTop:c}}}i(sy,"makeDocStyles");var rr=Object.freeze({editA11y:i(e=>`Edit ${e}. Correct or remove this record detail.`,"editA11y"),title:i(e=>`Edit ${e}`,"title"),helper:"Corrects your record. Your vet can still review it.",close:"Close",closeEditorA11y:"Close editor",save:"Save changes",saving:"Saving...",remove:"Remove this detail",removeA11y:i(e=>`Remove ${e}`,"removeA11y"),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 Ad(e,r){return Jr(e)?r==="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.":zl(e)?r==="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.":r==="remove"?"Couldn't remove that. Please check your connection and try again.":"Couldn't save that. Please check your connection and try again."}i(Ad,"factEditErrorMessage");var dy=Object.freeze({edits:Object.freeze({}),removed:Object.freeze([])});function ca(e,r){if(Object.keys(r.edits).length===0&&r.removed.length===0)return e;let t=[];for(let o of e){let n=o.canonicalKey??null;if(n!==null&&r.removed.includes(n))continue;let l=n!==null?r.edits[n]:void 0;t.push(l===void 0?o:Object.freeze({...o,value:l}));}return Object.freeze(t)}i(ca,"applyFactOverlay");function ua(e){return typeof e.canonicalKey=="string"&&e.canonicalKey.length>0}i(ua,"isFactEditable");function cy(){return `records-fact-${Date.now().toString(36)}`}i(cy,"defaultFactKey");function pa(e,r={}){let t=pr(),{userRef:o}=ee(),[n,l]=react.useState(dy),[a,c]=react.useState(false),[s,d]=react.useState(null),u=react.useMemo(()=>({}),[t,e,o]),[p,m]=react.useState(null),y=react.useCallback(()=>m(u),[u]),g=o!==null&&p!==u,f=react.useRef(false),R=react.useRef(r.newIdempotencyKey);R.current=r.newIdempotencyKey;let b=react.useCallback(()=>(R.current??cy)(),[]),E=react.useCallback((C,k,_)=>{if(c(false),!C.ok){if(k(),Rt(C.error)){y();return}d(Ad(C.error,_));}},[y]),h=react.useCallback(async(C,k)=>{let _=C.canonicalKey??"",T=k.trim();if(f.current||_.length===0||T.length===0)return Y(z("validationFailed",{retryable:false}));f.current=true,c(true),d(null);let I=n;l(q=>({...q,edits:{...q.edits,[_]:T}}));let F=await t.editFact(e,{entityType:C.category,canonicalKey:_,correctedFields:Gi(C.value,T),idempotencyKey:b()});return f.current=false,E(F,()=>l(I),"edit"),F},[t,e,n,E,b]),v=react.useCallback(async C=>{let k=C.canonicalKey??"";if(f.current||k.length===0)return Y(z("validationFailed",{retryable:false}));f.current=true,c(true),d(null);let _=n;l(I=>({...I,removed:[...I.removed,k]}));let T=await t.removeFact(e,{entityType:C.category,canonicalKey:k,idempotencyKey:b()});return f.current=false,E(T,()=>l(_),"remove"),T},[t,e,n,E,b]),S=react.useCallback(()=>d(null),[]);return react.useMemo(()=>({overlay:n,busy:a,error:s,available:g,edit:h,remove:v,clearError:S}),[n,a,s,g,h,v,S])}i(pa,"useRecordFactEdit");var uy=Object.freeze({vaccination:"Vaccination",medication:"Medication",problem:"Problem",body_weight:"Weight",allergy:"Allergy",vital:"Vital",lab_result:"Lab result",parasite_prevention:"Preventive"}),py="Given",my=/^\d{4}-\d{2}-\d{2}/,fy=" \xB7 ";function at(e){let r=e.filter(t=>t!==null&&t.trim().length>0);return r.length>0?r.join(fy):null}i(at,"joinDetail");function yy(e,r){let t=e.label.trim();if(t.length>0)return t;let o=uy[e.category];return o!==void 0?o:r(e.category)}i(yy,"rowTitle");function Ld(e,r){let t=yy(e,r.humanize),o=r.formatEntityValue(e.value,e.unit),n=o.trim().length>0?o:null,l=e.observedAt!==null&&e.observedAt.trim().length>0?r.formatRecordsDate(e.observedAt):null,a=l!==null&&l!=="-"?l:null;switch(e.category){case "vaccination":{let c=e.value!==null&&my.test(e.value.trim()),s=c?r.formatRecordsDate(e.value):a;return s!==null&&s!=="-"?{title:t,detail:at([`${py} ${s}`,c?null:n])}:{title:t,detail:at([n])}}case "medication":return {title:t,detail:at([a])};case "problem":return {title:t,detail:at([a])};case "body_weight":return {title:t,detail:at([a])};case "allergy":return {title:t,detail:at([a])};case "vital":return {title:t,detail:at([n,a])};case "lab_result":return {title:t,detail:at([n,a])};default:return {title:t,detail:at([n,a])}}}i(Ld,"entityRowSummary");function No(e){return e==="above"||e==="below"?"critical":e==="in_range"?"positive":"neutral"}i(No,"markerStatusTone");function gy(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"}}i(gy,"markerStatusSpoken");function by(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}`:""}i(by,"rangePhrase");function Lo(e,r){let t=r?` ${r}`:"";return e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}${t}`:e.refLow!==null?`\u2265 ${e.refLow}${t}`:e.refHigh!==null?`\u2264 ${e.refHigh}${t}`:"-"}i(Lo,"formatReferenceRange");function ma(e,r){let t=r.reviewed?", reviewed by our team":"",o=r.sourceClinic?`, from ${r.sourceClinic}`:"";return `${J(r.at)}: ${ur(r.value,e.unit,r.qualitativeResult)}, ${gy(r.status)}${by(r)}${o}${t}`}i(ma,"markerPointSpoken");function Ve(e){return e?.trim()||"my pet"}i(Ve,"lead");function Fd(e){let r=e.trim();return /[.!?]$/.test(r)?r:`${r}.`}i(Fd,"clause");function zd(e,r){let t=r.canonicalName.trim()||"a lab marker",o=[`I'm looking at ${Ve(e)}'s ${t}`],n=[r.latestValueText?.trim(),r.statusText?.trim(),r.trajectoryText?.trim()].filter(Boolean).join(", ");return o[0]+=n?`: ${n}.`:".",r.meaningText?.trim()&&o.push(Fd(r.meaningText)),o.push(`What does this trend tell me, and should I do anything differently for ${Ve(e)}?`),{prompt:o.join(" "),entityRef:{type:"marker",id:r.markerId,payload:{marker:t,...r.statusText?.trim()?{status:r.statusText.trim()}:{}}}}}i(zd,"buildMarkerAskPrompt");function Md(e,r,t){let{totalMarkers:o,inRangeCount:n,outOfRangeCount:l,unknownCount:a}=r;if(o===0)return {prompt:`I'm looking at ${Ve(e)}'s lab markers, but there aren't any on file yet. What lab work is worth running for ${Ve(e)}?`,entityRef:{type:"marker_summary",id:t,payload:{total:0}}};let c=a>0?`, ${a} without a reference range`:"";return {prompt:`I'm looking at ${Ve(e)}'s lab markers: ${o} total, ${n} in range, ${l} out of range${c}. What should I focus on?`,entityRef:{type:"marker_summary",id:t,payload:{total:o,inRange:n,outOfRange:l,unknown:a}}}}i(Md,"buildMarkerSummaryAskPrompt");function $d(e,r){let t=r.canonicalName.trim()||"a lab marker",o=[`${t}: ${r.valueText.trim()}`];r.collectedAt?.trim()&&o.push(`collected ${r.collectedAt.trim()}`),r.sourceClinic?.trim()&&o.push(`from ${r.sourceClinic.trim()}`),r.referenceText?.trim()&&o.push(`reference range ${r.referenceText.trim()}`),r.flagged&&o.push(`flagged ${r.flagged}`);let n={marker:t};return r.flagged&&(n.status=r.flagged),r.reviewed!==void 0&&(n.reviewed=r.reviewed),{prompt:`I'm looking at ${Ve(e)}'s ${o.join(", ")}. What does this mean, and should I be concerned?`,entityRef:{type:"lab_reading",id:r.entityId,payload:n}}}i($d,"buildMarkerReadingAskPrompt");function Ud(e,r,t){let o=r.clinicName?.trim(),n=r.heldItemCount??0,l=n>0?`, ${n} fact${n===1?"":"s"} being verified`:"";return {prompt:`I'm looking at ${Ve(e)}'s records request${o?` to ${o}`:""}, status: ${r.statusLabel.trim()}${l}. What does this status mean, and what happens next?`,entityRef:{type:"records_request",id:t,payload:{status:r.status,held:n,...o?{clinic:o}:{}}}}}i(Ud,"buildRecordsRequestAskPrompt");var Ry=Object.freeze({vaccination:"vaccine",medication:"medication",body_weight:"weight",vital:"weight"});function Bd(e,r,t,o){let n=r.entityTypeLabel.trim()||"record",l=r.title.trim()||n,a=r.detail?.trim();return {prompt:`I'm looking at ${Ve(e)}'s ${n.toLowerCase()}: ${l}${a?`, ${a}`:""}. What does this mean, and what should I keep on top of for ${Ve(e)}?`,entityRef:{type:Ry[t]??t,id:o,payload:{kind:n,title:l,...a?{detail:a}:{}}}}}i(Bd,"buildEntityRowAskPrompt");function jd(e,r,t){let o=r.filter(a=>a.label.trim()),n={type:"upcoming_care",id:t};if(o.length===0)return {prompt:`I'm looking at ${Ve(e)}'s upcoming care, but nothing is scheduled yet. What preventive care and checkups should ${Ve(e)} be on?`,entityRef:n};let l=[...o].sort((a,c)=>(a.tone==="overdue"?0:1)-(c.tone==="overdue"?0:1)).slice(0,4).map(a=>a.relativeText.trim()?`${a.label.trim()} (${a.relativeText.trim().toLowerCase()})`:a.label.trim());return {prompt:`I'm looking at ${Ve(e)}'s upcoming care: ${l.join(", ")}. What should I prioritize for ${Ve(e)}, and how do I stay on top of these?`,entityRef:n}}i(jd,"buildUpcomingCareAskPrompt");function Hd(e,r,t){let o=[`I'm looking at ${Ve(e)}'s physical exam${r.observedOn?.trim()?` from ${r.observedOn.trim()}`:""}.`],n=r.abnormal.filter(l=>l.system.trim());return n.length>0?(o.push(`Abnormal: ${n.slice(0,6).map(l=>`${l.system.trim()}: ${l.finding.trim()}`).join("; ")}.`),o.push(`What do these findings mean, and what should I follow up on for ${Ve(e)}?`)):o.push(`Everything examined came back normal. What does this tell me about ${Ve(e)}'s health?`),{prompt:o.join(" "),entityRef:{type:"physical_exam",id:t}}}i(Hd,"buildPhysicalExamAskPrompt");function Vd(e,r,t){let o=[`I'm looking at ${Ve(e)}'s visit notes${r.observedOn?.trim()?` from ${r.observedOn.trim()}`:""}.`];for(let n of r.sections.filter(l=>l.text.trim()).slice(0,3))o.push(`${n.label.trim()||"Note"}: ${Fd(n.text)}`);return o.push(`Can you summarize what happened and what I should follow up on for ${Ve(e)}?`),{prompt:o.join(" "),entityRef:{type:"visit",id:t}}}i(Vd,"buildVisitNoteAskPrompt");function Wd(e,r,t){let o=r.scopeLabel.trim()||"a detail",n=r.candidates.filter(a=>a.value.trim()),l=n.slice(0,3).map(a=>`"${a.value.trim()}"${a.clinicName?.trim()?` (${a.clinicName.trim()})`:""}`).join(" vs ");return {prompt:`Two of ${Ve(e)}'s documents disagree on ${o}: ${l}. Which is likely correct, and what should I ask my vet?`,entityRef:{type:"conflict",id:t,payload:{field:o,severity:r.severity,values:n.map(a=>a.value.trim()).join(" | ")}}}}i(Wd,"buildConflictAskPrompt");var Gd='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function ga(e){return e.tagName==="DIALOG"}i(ga,"isDialogElement");function hy(e,r){if(r.isDefaultPrevented()||r.nativeEvent.isComposing)return false;let t=r.target;return !(t instanceof Element)||t.closest("dialog")===e}i(hy,"ownsEscape");function Yd(e,r,t,o){let n=o?.escapeAtKeyDown===true,l=react.useRef(null),a=react.useRef(false),c=react.useRef(null),s=react.useRef(t);s.current=t;let d=react.useCallback(()=>{if(!a.current)return;a.current=false;let m=s.current===void 0?c.current:s.current.current;m&&m.isConnected&&m.focus(),(!m||!m.isConnected||document.activeElement===m)&&(c.current=null);},[]);react.useEffect(()=>{if(!e){d();return}let m=l.current;if(!a.current){let g=typeof document>"u"?null:document.activeElement;g!==null&&m!==null&&m.contains(g)||(c.current=g instanceof HTMLElement?g:null);}if(a.current=true,m===null)return;if(!ga(m)){m.contains(document.activeElement)||(m.querySelector(Gd)??m).focus();return}let y=m;typeof y.showModal=="function"?y.open||y.showModal():y.setAttribute("open","");},[e,d]),react.useEffect(()=>d,[d]),react.useEffect(()=>{let m=l.current;if(!e||m===null||!ga(m))return;let y=m;if(typeof y.showModal!="function")return;let g=null,f=i(b=>{b.target instanceof HTMLElement&&(g=b.target);},"onFocusIn"),R=i(()=>{if(!y.isConnected||y.open)return;let b=g;y.showModal(),b!==null&&b.isConnected&&y.contains(b)&&document.activeElement!==b&&b.focus();},"onNativeClose");return y.addEventListener("focusin",f),y.addEventListener("close",R),()=>{y.removeEventListener("focusin",f),y.removeEventListener("close",R);}},[e]);let u=react.useCallback(m=>{let y=l.current;if(y===null)return;if(m.key==="Escape"&&!ga(y)){m.preventDefault(),m.stopPropagation(),r();return}if(m.key==="Escape"&&n&&hy(y,m)){m.preventDefault(),r();return}if(m.key!=="Tab")return;let g=Array.from(y.querySelectorAll(Gd)),f=g[0],R=g[g.length-1];if(!f||!R){m.preventDefault();return}let b=document.activeElement;m.shiftKey&&(b===f||!y.contains(b))?(m.preventDefault(),R.focus()):!m.shiftKey&&(b===R||!y.contains(b))&&(m.preventDefault(),f.focus());},[r,n]),p=react.useCallback(m=>{m.target===m.currentTarget&&(m.preventDefault(),r());},[r]);return {dialogRef:l,onKeyDown:u,onCancel:p}}i(Yd,"useModalDialog");var Cy='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function Ct({label:e,onClose:r,shape:t="modal",returnFocusTo:o,panelStyle:n,testID:l,children:a}){let{styles:c}=j(),s=Yd(true,r,o);react.useEffect(()=>{let u=s.dialogRef.current;u===null||u.contains(document.activeElement)||(u.querySelector(Cy)??u).focus();},[s.dialogRef]);let d=t==="side";return jsxRuntime.jsx("dialog",{ref:s.dialogRef,"aria-label":e,"aria-modal":"true",onCancel:s.onCancel,onKeyDown:s.onKeyDown,style:c.dialogFrame,"data-testid":l,children:jsxRuntime.jsx("div",{style:d?c.dialogScrimSide:c.dialogScrim,onClick:u=>{u.target===u.currentTarget&&r();},"data-testid":l?`${l}-scrim`:void 0,children:jsxRuntime.jsx("div",{style:{...d?c.dialogPanelSide:c.dialogPanel,...n},children:a})})})}i(Ct,"RecordsDialog");function Kd({entity:e,factEdit:r,children:t}){let{theme:o,styles:n}=j(),[l,a]=react.useState(false),c=react.useRef(null),s=e.label.trim()||rr.detail;return jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:o.space.sm},children:[jsxRuntime.jsx("div",{style:{flex:1,minWidth:0},children:t}),jsxRuntime.jsx("button",{ref:c,type:"button",onClick:()=>a(true),"aria-label":rr.editA11y(s),style:n.iconButton,"data-testid":`fact-edit-open-${e.canonicalKey??e.key}`,children:jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"block",width:o.space.md+o.space.xs/2,height:2,backgroundColor:o.color.brand,borderRadius:o.radius.pill,transform:"rotate(-45deg)"}})}),l?jsxRuntime.jsx(Sy,{entity:e,title:s,factEdit:r,onClose:()=>a(false),returnFocusTo:c}):null]})}i(Kd,"FactEditAffordance");function Sy({entity:e,title:r,factEdit:t,onClose:o,returnFocusTo:n}){let{theme:l,styles:a}=j(),[c,s]=react.useState(e.value??""),[d,u]=react.useState(null),[p,m]=react.useState(false);react.useEffect(()=>{t.clearError();},[t]);let y=c.trim().length>0&&c.trim()!==(e.value??"").trim(),g=d??t.error,f=t.busy,R=i(()=>{if(!y){u(rr.noChange);return}u(null),t.edit(e,c).then(h=>{h.ok&&o();});},"submitEdit"),b=i(()=>{u(null),t.remove(e).then(h=>{h.ok?o():m(false);});},"submitRemove"),E=`fact-edit-${e.key}`;return jsxRuntime.jsxs(Ct,{label:rr.title(r),onClose:o,returnFocusTo:n,testID:"fact-edit-sheet",children:[jsxRuntime.jsxs("div",{style:a.sheetHeader,children:[jsxRuntime.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:l.space.xs},children:[jsxRuntime.jsx("h3",{style:a.sheetTitle,children:rr.title(r)}),jsxRuntime.jsx("p",{role:"status","aria-live":"polite",style:{...a.sheetHelper,...g?a.errorText:{}},children:g??rr.helper})]}),jsxRuntime.jsx("button",{type:"button",onClick:o,"aria-label":rr.close,style:a.iconButton,"data-testid":"fact-edit-close",children:jsxRuntime.jsx("span",{style:a.closeGlyph,"aria-hidden":"true",children:"\xD7"})})]}),jsxRuntime.jsx("label",{htmlFor:E,style:a.fieldLabel,children:e.label}),jsxRuntime.jsx("input",{id:E,style:a.field,value:c,onChange:h=>{s(h.target.value),u(null);},disabled:f,maxLength:512,"data-testid":"fact-edit-field"}),p?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:l.space.sm,padding:l.space.md,borderRadius:l.radius.md,backgroundColor:l.color.badgeBgCritical},"data-testid":"fact-edit-confirm-remove",children:[jsxRuntime.jsx("p",{style:a.bodyText,children:rr.confirmRemove}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:l.space.sm},children:[jsxRuntime.jsx(B,{label:f?rr.removing:rr.removeConfirm,kind:"danger",busy:f,onClick:b,style:{flex:1},testID:"fact-edit-remove-confirm"}),jsxRuntime.jsx(B,{label:rr.keep,kind:"outline",disabled:f,onClick:()=>m(false),style:{flex:1},testID:"fact-edit-remove-cancel"})]})]}):jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:l.space.sm},children:[jsxRuntime.jsx(B,{label:f?rr.saving:rr.save,busy:f,disabled:!y,onClick:R,testID:"fact-edit-save"}),jsxRuntime.jsx("button",{type:"button","aria-label":rr.removeA11y(r),disabled:f,onClick:()=>{u(null),m(true);},style:{...a.pill,...a.pillLink,color:l.color.danger,...f?a.pillDisabled:{}},"data-testid":"fact-edit-remove",children:rr.remove})]})]})}i(Sy,"FactEditSheet");function Mo({record:e,depth:r,petName:t,showLabs:o=true,onNavigate:n,onAsk:l,factEdit:a,nowMs:c}){let{theme:s,styles:d}=j(),u=c??Date.now(),p=react.useMemo(()=>a?ca(e.entities,a.overlay):e.entities,[e.entities,a]),m=react.useMemo(()=>{let h=[],v=new Map;for(let S of p){let C=S.category.trim();if(C.length===0)continue;let k=v.get(C);k===void 0?(h.push(C),v.set(C,[S])):k.push(S);}return {order:ad(h),groups:v}},[p]),y=Object.values(e.documents),g=a!==void 0&&a.available,f=i((h,v,S)=>l?jsxRuntime.jsx("button",{type:"button",onClick:()=>{let C=h();l(C.prompt,C.entityRef);},"aria-label":v,style:{...d.pill,...d.pillAsk,marginTop:s.space.lg,alignSelf:"flex-start"},"data-testid":S,children:v}):null,"ask"),R={display:"flex",flexDirection:"column",gap:s.space.lg+s.space.xs},b=i(h=>({...d.row,...h>0?d.rowDivider:{}}),"rowStyle"),E={...d.card,padding:`${s.space.md}px ${s.space.lg}px`,display:"flex",flexDirection:"column"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{style:R,children:[r&&r.conflicts.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-conflicts",children:[jsxRuntime.jsx(qr,{title:K.needsAttention,count:r.conflicts.length}),[...r.conflicts].sort((h,v)=>xo(h.severity).rank-xo(v.severity).rank).map(h=>{let v=xo(h.severity),S=Qr(h.field??h.entityType);return jsxRuntime.jsxs("div",{style:{...E,borderColor:d.chipTones[v.tone].color,gap:s.space.sm},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:s.space.sm},children:[jsxRuntime.jsx("span",{style:{...d.rowTitle,...O(s,"bold"),flex:1},children:v.label}),jsxRuntime.jsx(cr,{label:S,tone:v.tone})]}),jsxRuntime.jsx("p",{style:d.rowDetail,children:K.conflictSub}),h.candidates.map((C,k)=>jsxRuntime.jsxs("div",{style:{borderTop:`1px solid ${s.color.borderHairlineGreen}`,paddingTop:s.space.sm},children:[jsxRuntime.jsx("p",{style:d.rowTitle,children:C.value}),jsxRuntime.jsx("p",{style:d.rowMuted,children:[C.docId?e.documents[C.docId]?.title??K.uploadedDocument:K.uploadedDocument,C.collectedAt?J(C.collectedAt):null].filter(Boolean).join(" \xB7 ")})]},k)),f(()=>Wd(t,{scopeLabel:S,severity:h.severity,candidates:h.candidates.map(C=>({value:C.value,clinicName:C.docId?e.documents[C.docId]?.title??null:null}))},h.conflictId),K.askConflict,`records-ask-conflict-${h.conflictId}`)]},h.conflictId)})]}):null,r?.completeness?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-completeness",children:[jsxRuntime.jsx(qr,{title:K.whatsOnFile}),jsxRuntime.jsxs("div",{style:d.card,children:[jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:s.space.sm,padding:`${s.space.md}px 0`},children:[[K.coverage.labs,r.completeness.hasLabHistory],[K.coverage.vaccines,r.completeness.hasVaccinationHistory],[K.coverage.weight,r.completeness.hasWeightHistory],[K.coverage.vitals,r.completeness.hasVitalsHistory],[K.coverage.exams,r.completeness.hasPhysicalExamHistory],[K.coverage.procedures,r.completeness.hasProcedureHistory],[K.coverage.genetics,r.completeness.hasGeneticHistory],[K.coverage.parasite,r.completeness.hasParasitePreventionHistory],[K.coverage.reproductive,r.completeness.hasReproductiveHistory]].map(([h,v])=>jsxRuntime.jsx("span",{"aria-label":`${h}: ${v?K.onFile:K.noneOnFile}`,style:{...d.chip,...v?d.chipTones.positive:{backgroundColor:s.color.badgeBgNeutral,color:s.color.text.muted},fontSize:s.type.size.caption},children:h},h))}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:s.space.sm,paddingBottom:s.space.md},children:[jsxRuntime.jsx("span",{style:{...d.rowDetail,flex:1,marginTop:0},children:K.documentsOnFile(r.completeness.documentsIngested)}),r.completeness.documentsInReview>0?jsxRuntime.jsx(cr,{label:K.inReviewChip(r.completeness.documentsInReview),tone:"warning"}):null,Ra(r.completeness.heldTotal,r.completeness.entitiesPendingReview)>0?jsxRuntime.jsx("span",{"aria-label":K.beingVerifiedA11y(Ra(r.completeness.heldTotal,r.completeness.entitiesPendingReview)),children:jsxRuntime.jsx(cr,{label:K.beingVerified(Ra(r.completeness.heldTotal,r.completeness.entitiesPendingReview)),tone:"warning"})}):null]}),r.completeness.earliestRecordAt||r.completeness.latestRecordAt?jsxRuntime.jsx("p",{style:{...d.rowDetail,paddingBottom:s.space.md},children:K.dateRange(r.completeness.earliestRecordAt,r.completeness.latestRecordAt)}):null,Object.entries(r.completeness.entitiesPendingReview).filter(([,h])=>h>0).length>0?jsxRuntime.jsxs("p",{style:{...d.rowMuted,paddingBottom:s.space.md},children:[K.pendingReview,Object.entries(r.completeness.entitiesPendingReview).filter(([,h])=>h>0).map(([h,v])=>`${qt(h)} (${v})`).join(", ")]}):null]})]}):null,y.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-documents",children:[jsxRuntime.jsx(qr,{title:K.documents,count:y.length}),jsxRuntime.jsx("ul",{style:d.card,children:y.map((h,v)=>{let S=h.title?.trim()||K.uploadedDocument,C=h.receivedAt?J(h.receivedAt):null,k=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:d.rowMain,children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:S}),C?jsxRuntime.jsx("span",{style:{...d.rowDetail,display:"block"},children:C}):null]}),n?jsxRuntime.jsx(kt,{}):null]});return jsxRuntime.jsx("li",{style:b(v),children:n?jsxRuntime.jsx("button",{type:"button",onClick:()=>n({name:"contributions",docId:h.docId}),"aria-label":K.documentRowA11y(S),style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:s.space.md,width:"100%",background:"transparent",border:0,padding:0,cursor:"pointer",textAlign:"left",font:"inherit",color:"inherit"},"data-testid":`records-document-row-${h.docId}`,children:k}):k},h.docId)})})]}):null,e.identity.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-identity",children:[jsxRuntime.jsx(qr,{title:K.identity}),jsxRuntime.jsx("dl",{style:d.card,children:e.identity.map((h,v)=>jsxRuntime.jsxs("div",{style:b(v),children:[jsxRuntime.jsx("dt",{style:{...d.rowDetail,...O(s,"medium"),marginTop:0},children:h.label}),jsxRuntime.jsx("dd",{style:{...d.rowTitle,margin:0,textAlign:"right"},children:h.value})]},`${v}:${h.label}`))})]}):null,jsxRuntime.jsx(vd,{series:e.entitySeries}),e.forwardLooking.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-upcoming",children:[jsxRuntime.jsx(qr,{title:K.upcomingCare,count:e.forwardLooking.length}),jsxRuntime.jsx("ul",{style:d.card,children:e.forwardLooking.map((h,v)=>{let S=Dn(h.dueAt,u);return jsxRuntime.jsxs("li",{style:b(v),children:[jsxRuntime.jsxs("span",{style:d.rowMain,children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:h.title}),h.detail?jsxRuntime.jsx("span",{style:{...d.rowDetail,display:"block"},children:h.detail}):null]}),S?jsxRuntime.jsx(cr,{label:S.label,tone:S.overdue?"critical":"info"}):null]},`${h.title}-${v}`)})}),f(()=>jd(t,e.forwardLooking.map(h=>{let v=Dn(h.dueAt,u);return {label:h.title,relativeText:v?.label??"",tone:v?.overdue?"overdue":"upcoming"}}),e.petRef),K.askUpcomingCare,"records-ask-upcoming-care")]}):null,m.order.map(h=>{let v=m.groups.get(h)??[];if(v.length===0)return null;let S=qt(h);return jsxRuntime.jsxs("section",{style:d.section,"data-testid":`record-section-${h}`,children:[jsxRuntime.jsx(qr,{title:S,count:v.length}),jsxRuntime.jsx("ul",{style:d.card,children:v.map((C,k)=>{let _=Ld(C,{formatEntityValue:Ht,formatRecordsDate:J,humanize:Qr}),T=_.detail,I=jsxRuntime.jsxs("div",{style:b(k),children:[jsxRuntime.jsxs("div",{style:{...d.rowMain,display:"flex",flexDirection:"column"},children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:_.title}),T?jsxRuntime.jsx("span",{style:d.rowDetail,children:T}):null,f(()=>Bd(t,{entityTypeLabel:S,title:_.title,detail:T},h,C.key),K.askEverfur,`records-ask-entity-${C.key}`)]}),C.status?jsxRuntime.jsx(cr,{label:Qr(C.status)}):null]});return jsxRuntime.jsx("li",{children:g&&ua(C)&&a?jsxRuntime.jsx(Kd,{entity:C,factEdit:a,children:I}):I},C.key)})})]},h)}),r&&r.physicalExams.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-exams",children:[jsxRuntime.jsx(qr,{title:K.physicalExams,count:r.physicalExams.length}),r.physicalExams.map(h=>jsxRuntime.jsxs("div",{style:E,children:[jsxRuntime.jsx("h4",{style:{...d.rowTitle,paddingTop:s.space.sm},children:h.observedOn?J(h.observedOn):me.exam}),jsxRuntime.jsx("ul",{style:d.plainList,children:h.systems.map((v,S)=>{let C=v.findingStatus==="abnormal",k=C?me.abnormal:v.findingStatus==="not_examined"?me.notExamined:me.normal;return jsxRuntime.jsxs("li",{style:b(S),children:[jsxRuntime.jsxs("span",{style:d.rowMain,children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:Wt(v.system)}),C&&v.finding?jsxRuntime.jsx("span",{style:{...d.rowDetail,display:"block"},children:v.finding}):null]}),jsxRuntime.jsx(cr,{label:k,tone:C?"warning":v.findingStatus==="not_examined"?"neutral":"positive"})]},v.system)})}),f(()=>Hd(t,{observedOn:h.observedOn?J(h.observedOn):null,abnormal:h.systems.filter(v=>v.findingStatus==="abnormal").map(v=>({system:Wt(v.system),finding:v.finding??""}))},h.examId),K.askExam,`records-ask-exam-${h.examId}`)]},h.examId))]}):null,r&&r.clinicianNotes.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-notes",children:[jsxRuntime.jsx(qr,{title:K.visitNotes,count:r.clinicianNotes.length}),r.clinicianNotes.map(h=>jsxRuntime.jsxs("div",{style:E,children:[jsxRuntime.jsx("h4",{style:{...d.rowTitle,paddingTop:s.space.sm},children:h.observedOn?J(h.observedOn):me.visitNote}),jsxRuntime.jsx("dl",{style:d.plainList,children:h.sections.map((v,S)=>jsxRuntime.jsxs("div",{style:{padding:`${s.space.md}px 0`,...S>0?d.rowDivider:{}},children:[jsxRuntime.jsx("dt",{style:{...d.rowDetail,...O(s,"bold"),marginTop:0,textTransform:"uppercase"},children:Gt(v.section)}),jsxRuntime.jsx("dd",{style:{...d.bodyText,marginLeft:0,...v.text?{}:{color:s.color.text.muted,fontStyle:"italic"}},children:v.text||me.notRecorded})]},`${v.section}:${S}`))}),f(()=>Vd(t,{observedOn:h.observedOn?J(h.observedOn):null,sections:h.sections.map(v=>({label:Gt(v.section),text:v.text}))},h.noteId),K.askVisit,`records-ask-note-${h.noteId}`)]},h.noteId))]}):null,o&&r&&r.labResults.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-labs",children:[jsxRuntime.jsx(qr,{title:K.labResults,count:r.labResults.length}),jsxRuntime.jsx("ul",{style:d.card,children:r.labResults.map((h,v)=>{let S=Kr(h.latest.status),C=$i(h.latest.at,h.trajectory,h.points.length);return jsxRuntime.jsxs("li",{style:b(v),children:[jsxRuntime.jsxs("span",{style:{...d.rowMain,display:"flex",flexDirection:"column"},children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:h.name}),jsxRuntime.jsx("span",{style:d.rowValue,children:ur(h.latest.value,h.latest.unit,h.latest.qualitativeResult)}),C?jsxRuntime.jsx("span",{style:d.rowDetail,children:C}):null]}),jsxRuntime.jsx(cr,{label:S.label,tone:No(h.latest.status)})]},h.markerId)})})]}):null,r&&r.encounters.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-visits",children:[jsxRuntime.jsx(qr,{title:K.visits,count:r.encounters.length}),jsxRuntime.jsx("ul",{style:d.card,children:r.encounters.map((h,v)=>{let S=[h.date?J(h.date):null,h.clinicName,h.veterinarian].filter(C=>C&&C!=="-").join(" \xB7 ");return jsxRuntime.jsx("li",{style:b(v),children:jsxRuntime.jsxs("span",{style:d.rowMain,children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:h.type?Qr(h.type):me.visit}),S?jsxRuntime.jsx("span",{style:{...d.rowDetail,display:"block"},children:S}):null]})},h.encounterId)})})]}):null]}),jsxRuntime.jsx(bt,{disclaimer:e.disclaimer})]})}i(Mo,"RecordSections");function Ra(e,r){return e>0?e:Object.values(r).reduce((t,o)=>t+o,0)}i(Ra,"heldCount");function Zd({petRef:e,onClose:r,onNavigate:t,onOpenUrl:o,onCopy:n,returnFocusTo:l}){let{theme:a,styles:c}=j(),s=ra(e),[d,u]=react.useState(null),[p,m]=react.useState(null),y=s.available&&!s.consentRequired,g=i((v,S)=>{if(o){Et(o,v,S).then(C=>{C.ok||u(se.toasts.shareSheet);});return}if(S==="share_link"){Dd(v,n??Ao).then(C=>{C==="copied"&&u(se.toasts.copied);},()=>u(se.toasts.shareSheet));return}on(v,Io).then(C=>{C||u(_t(null,"download"));});},"open"),f=i(()=>{u(null),s.createLink().then(v=>{v.ok?g(v.value.shareUrl,"share_link"):u(_t(v.error,"create"));});},"onCreateLink"),R=i(()=>{u(null),s.pdfLink().then(v=>{v.ok?g(v.value.downloadUrl,"record_pdf"):u(_t(v.error,"download"));});},"onDownload"),b=i(v=>{v.shareUrl!==null&&Et(n??Ao,v.shareUrl).then(S=>u(S.ok?se.toasts.copied:se.toasts.copyFailed));},"onCopyRow"),E=i(v=>{s.revoke(v).then(S=>{m(null),u(S.ok?se.toasts.turnedOff:_t(S.error,"revoke"));});},"onConfirmRevoke"),h={display:"flex",flexDirection:"column",gap:a.space.sm,padding:a.space.md,borderRadius:a.radius.md,backgroundColor:a.color.surfaceCream,border:`1px solid ${a.color.brandBorder}`};return jsxRuntime.jsxs(Ct,{label:se.title,onClose:r,shape:"side",returnFocusTo:l,testID:"share-record-sheet",children:[jsxRuntime.jsxs("div",{style:c.sheetHeader,children:[jsxRuntime.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:a.space.xs},children:[jsxRuntime.jsx("h3",{style:c.sheetTitle,children:se.title}),jsxRuntime.jsx("p",{style:c.sheetHelper,children:se.helper})]}),jsxRuntime.jsx("button",{type:"button",onClick:r,"aria-label":se.close,style:c.iconButton,"data-testid":"share-record-close",children:jsxRuntime.jsx("span",{style:c.closeGlyph,"aria-hidden":"true",children:"\xD7"})})]}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:a.space.sm},children:[t?jsxRuntime.jsx(B,{label:se.viewDocument,onClick:()=>{r(),t({name:"document"});},testID:"share-view-document"}):null,y?jsxRuntime.jsx(B,{label:s.creating?se.creatingLink:se.createLink,kind:"outline",busy:s.creating,onClick:f,testID:"share-create-link"}):null,y?jsxRuntime.jsx(B,{label:s.preparingPdf?se.preparingPdf:se.downloadPdf,kind:"outline",busy:s.preparingPdf,onClick:R,testID:"share-download-pdf"}):null]}),s.consentRequired?jsxRuntime.jsxs("div",{style:h,"data-testid":"share-consent-off",children:[jsxRuntime.jsx("p",{style:c.rowTitle,children:se.consentOffTitle}),jsxRuntime.jsx("p",{style:c.muted,children:se.consentOffBody}),jsxRuntime.jsx(B,{label:se.retry,kind:"outline",onClick:s.refresh,testID:"share-consent-retry"})]}):null,d?jsxRuntime.jsx("p",{role:"status","aria-live":"polite",style:c.infoNote,"data-testid":"share-notice",children:d}):null,dd(s)?jsxRuntime.jsxs("section",{"aria-label":se.activeLinks,style:{display:"flex",flexDirection:"column",gap:a.space.sm},children:[jsxRuntime.jsx("h4",{style:{...c.fieldLabel,...O(a,"bold"),textTransform:"uppercase"},children:se.activeLinks}),s.status==="loading"?jsxRuntime.jsx(_l,{testID:"share-record-loading"}):s.status==="error"?jsxRuntime.jsxs("div",{style:h,"data-testid":"share-record-error",children:[jsxRuntime.jsx("p",{style:c.rowTitle,children:se.errorTitle}),jsxRuntime.jsx("p",{style:c.muted,children:se.errorBody}),jsxRuntime.jsx(B,{label:se.retry,kind:"outline",onClick:s.refresh,testID:"share-record-retry"})]}):s.rows.length===0?jsxRuntime.jsxs("div",{style:h,"data-testid":"share-record-empty",children:[jsxRuntime.jsx("p",{style:c.rowTitle,children:se.emptyTitle}),jsxRuntime.jsx("p",{style:c.muted,children:se.emptyBody})]}):jsxRuntime.jsx("ul",{style:{...c.plainList,gap:a.space.md},children:s.rows.map(v=>jsxRuntime.jsxs("li",{style:{...h},"data-testid":`share-row-${v.shareId}`,children:[jsxRuntime.jsxs("div",{"aria-label":v.a11yLabel,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:a.space.sm},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:a.space.sm,height:a.space.sm,borderRadius:a.space.xs,backgroundColor:v.active?a.color.success:a.color.text.muted}}),jsxRuntime.jsx("span",{style:{...c.rowTitle,...O(a,"bold")},children:v.statusLabel}),jsxRuntime.jsx("span",{style:c.muted,children:v.expiryLabel})]}),v.createdLabel?jsxRuntime.jsx("p",{style:c.muted,children:v.createdLabel}):null]}),p===v.shareId?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:a.space.sm},"data-testid":`share-revoke-confirm-${v.shareId}`,children:[jsxRuntime.jsx("p",{style:c.bodyText,children:se.confirmTurnOff}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:a.space.sm},children:[jsxRuntime.jsx(B,{label:s.revokingId===v.shareId?se.turningOff:se.turnOff,kind:"danger",busy:s.revokingId===v.shareId,onClick:()=>E(v.shareId),testID:`share-revoke-do-${v.shareId}`}),jsxRuntime.jsx(B,{label:se.keep,kind:"outline",disabled:s.revokingId===v.shareId,onClick:()=>m(null),testID:`share-revoke-cancel-${v.shareId}`})]})]}):jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:a.space.sm},children:[jsxRuntime.jsx(B,{label:se.copyLink,kind:"outline",disabled:v.shareUrl===null,ariaLabel:se.copyLinkA11y(v.actionContext),onClick:()=>b(v),testID:`share-copy-${v.shareId}`}),jsxRuntime.jsx(B,{label:se.turnOff,kind:"danger",ariaLabel:se.turnOffA11y(v.actionContext),onClick:()=>m(v.shareId),testID:`share-ask-revoke-${v.shareId}`})]})]},v.shareId))})]}):null]})}i(Zd,"ShareSheet");var Py=i((e,r)=>e.getRecordDepth(r),"readDepth"),Ty=i(e=>!e.available,"depthEmpty");function Fn(e){let{style:r,className:t,renderPending:o,...n}=_e(e,["onNavigate","onBack","onAsk"]),{userRef:l}=ee(),{styles:a}=j();return jsxRuntime.jsx(Te,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Oe(n.onBack,Le),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...r},"data-testid":"everfur-record-screen",children:[l===null?jsxRuntime.jsx("div",{style:a.body,children:jsxRuntime.jsx(Je,{label:G.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(Dy,{...n}),jsxRuntime.jsx(De,{})]})})}i(Fn,"EverfurRecordDetail");function Dy({petRef:e,petName:r,controller:t,consentVersion:o,onNavigate:n,onBack:l,onAsk:a,onOpenUrl:c,onCopy:s}){let{theme:d,styles:u}=j(),p=react.useMemo(()=>t?{petRef:e,controller:t}:{petRef:e},[e,t]),m=We(p),y=zr(e,Py,Ty),g=pa(e),f=ta(e),[R,b]=react.useState(false),E=react.useRef(null),h=tt(o,m.consent),v=i(()=>{let I=Vr(o,m.consent);I.length!==0&&m.grantConsent(I,`records-consent-${Date.now().toString(36)}`);},"onGrant"),S=y.value!==null&&!y.value.withheld&&y.value.available?y.value:null,C=m.record,k=i(()=>{m.refresh(),y.refresh();},"retry"),_=n!==void 0||f.lit===true,T;if(m.status==="loading"||y.status==="loading"&&C!==null&&!C.isEmpty)T=jsxRuntime.jsx(Yt,{testID:"everfur-record-loading"});else if(m.status==="error"){let I=Wr(m,h);T=I.kind==="error"||I.kind==="pet_not_found"?jsxRuntime.jsx(Fe,{variant:Xe(I.error),message:I.error.displayMessage,onAction:I.error.retryable?k:void 0,testID:"everfur-record-error"}):vt(m,v,h);}else if(C===null||C.isEmpty){let I=S?.completeness?.documentsInReview??0;T=jsxRuntime.jsxs("div",{style:u.content,"data-testid":"everfur-record-empty",children:[jsxRuntime.jsx(Fe,{variant:"no_records",message:I>0?K.inReview(I):void 0}),jsxRuntime.jsx(bt,{disclaimer:C?.disclaimer??""})]});}else T=jsxRuntime.jsx("div",{style:{...u.content,gap:d.space.lg+d.space.xs,paddingBottom:d.space.xxl+d.space.sm},"data-testid":"everfur-record",children:jsxRuntime.jsx(Mo,{record:C,depth:S,petName:r,onNavigate:n,onAsk:a,factEdit:g})});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(He,{title:K.title,onBack:l,testID:"everfur-record-header",right:_||n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n?jsxRuntime.jsx("button",{type:"button",onClick:()=>n({name:"clinicBatch"}),"aria-label":K.requestClinicsA11y,style:u.iconButton,"data-testid":"everfur-record-request-clinics",children:jsxRuntime.jsx(zi,{name:"send",color:d.color.brand})}):null,_?jsxRuntime.jsx("button",{ref:E,type:"button",onClick:()=>b(true),"aria-label":K.shareA11y,style:u.iconButton,"data-testid":"everfur-record-share",children:jsxRuntime.jsx(zi,{name:"share2",color:d.color.brand})}):null]}):void 0}),jsxRuntime.jsx("div",{style:u.body,children:T}),R?jsxRuntime.jsx(Zd,{petRef:e,onClose:()=>b(false),returnFocusTo:E,onNavigate:n,...c?{onOpenUrl:c}:{},...s?{onCopy:s}:{}}):null]})}i(Dy,"RecordBody");var Uo=Object.freeze({download:"Download",downloadA11y:i(e=>`Download, ${e}`,"downloadA11y"),listA11y:"You added these records"});function Oy(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i(Oy,"formatBytes");function Iy(e){let r=e?.trim();return r?r.toUpperCase():null}i(Iy,"formatLabel");function ha(e){return Object.freeze(e.map(r=>{let t=Iy(r.docFormat),o=r.receivedAt?J(r.receivedAt):null,n=r.fileName??t??o??r.sourceDocId,a=[r.fileName!==null&&t!==null&&r.fileName.toUpperCase().endsWith(`.${t}`)||n===t?null:t,r.byteSize!==null?Oy(r.byteSize):null,n===o?null:o].filter(c=>!!c).join(" \xB7 ");return Object.freeze({key:r.sourceDocId,title:n,meta:a||null,downloadUrl:r.downloadUrl})}))}i(ha,"requestDocumentRows");function rc(e){let r=e.fileName?.trim()||e.sourceDocId,t=e.docFormat?.trim().toLowerCase().replace(/^\./,"")??"";return t.length===0||r.toLowerCase().endsWith(`.${t}`)?r:`${r}.${t}`}i(rc,"requestDocumentFileName");function Ca(e,r={}){let t=r.enabled??true,o=pr(),{userRef:n}=ee(),[l,a]=react.useState(null),[c,s]=react.useState(t),[d,u]=react.useState(null),p=react.useRef(0),m=react.useRef(true),y=react.useCallback(async()=>{let b=p.current+=1;if(!t||n===null){a(null),u(null),s(false);return}s(true),u(null);let E=await o.listRequestDocuments(e);b!==p.current||!m.current||(E.ok?a(E.value):(a(null),u(E.error)),s(false));},[o,t,e,n]);react.useEffect(()=>(m.current=true,y(),()=>{m.current=false,p.current+=1;}),[y]);let g=react.useMemo(()=>l===null?[]:ha(l),[l]),f=react.useCallback(()=>{y();},[y]),R=c?"loading":d!==null?"error":g.length===0?"empty":"populated";return react.useMemo(()=>({status:R,rows:g,error:d,refresh:f}),[R,g,d,f])}i(Ca,"useRequestDocuments");function zn({requestId:e,open:r=true,onOpenUrl:t,testID:o="records-request-documents"}){let{theme:n,styles:l}=j(),a=Ca(e,{enabled:r}),c=pr(),[s,d]=react.useState(null),[u,p]=react.useState(null),m=react.useRef(true);react.useEffect(()=>(m.current=true,()=>{m.current=false;}),[]);let y=i(async g=>{d(g.key),p(null);let f=await c.listRequestDocuments(e),R=f.ok?f.value.find(E=>E.sourceDocId===g.key)??null:null,b=R===null;R!==null&&m.current&&(t?await Et(t,R.downloadUrl,"request_document"):b=!await on(R.downloadUrl,rc(R))),m.current&&(d(null),b&&p(g.key));},"save");return r?a.status==="loading"?jsxRuntime.jsx("div",{style:{paddingTop:n.space.sm},"aria-busy":"true","data-testid":`${o}-loading`,children:jsxRuntime.jsx(fe,{width:"100%",height:n.space.lg+n.space.md})}):a.status==="error"?jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:n.space.sm,paddingTop:n.space.sm},"data-testid":`${o}-error`,children:[jsxRuntime.jsx("p",{style:{...l.muted,margin:0},role:"alert",children:a.error?.displayMessage??""}),a.error?.retryable===true?jsxRuntime.jsx(B,{label:G.retry,kind:"outline",onClick:a.refresh,testID:`${o}-retry`}):null]}):a.status==="empty"?null:jsxRuntime.jsx("ul",{"aria-label":Uo.listA11y,style:{...l.plainList,paddingTop:n.space.sm},"data-testid":o,children:a.rows.map((g,f)=>jsxRuntime.jsxs("li",{style:Ly(n.space.sm,f===0?null:n.color.brandBorder),children:[jsxRuntime.jsxs("div",{style:{minWidth:0},children:[jsxRuntime.jsx("p",{style:{...l.rowTitle,margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title}),g.meta!==null?jsxRuntime.jsx("p",{style:{...l.muted,margin:0,fontVariantNumeric:"tabular-nums"},children:g.meta}):null]}),jsxRuntime.jsx(B,{label:Uo.download,kind:"outline",ariaLabel:Uo.downloadA11y(g.title),busy:s===g.key,onClick:()=>{y(g);},testID:`${o}-download-${g.key}`}),u===g.key?jsxRuntime.jsx("p",{role:"alert",style:{...l.errorText,flexBasis:"100%"},"data-testid":`${o}-save-failed-${g.key}`,children:fo.error.title}):null]},g.key))}):null}i(zn,"RequestDocumentsList");function Ly(e,r){return {display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:e,paddingTop:e,paddingBottom:e,...r!==null?{borderTop:`1px solid ${r}`}:{}}}i(Ly,"rowStyle");var Fy=Math.round(jr/(1024*1024)),Ke=Object.freeze({title:i(e=>`Upload ${Pe(e)}\u2019s records`,"title"),subtitle:i(e=>`Already have lab results, a vet summary, or test reports? Add them here and we\u2019ll read them and pull out ${Pe(e)}\u2019s health markers.`,"subtitle"),noPet:"Select a pet first, then upload their records.",cardTitle:"Add records",cardSubtitle:`Upload PDF records you already have, up to ${Fy} MB each. You can pick several at once. We\u2019ll read them and add the results to your records.`,chooseFiles:"Choose files",chooseFilesA11y:"Choose records to upload",uploading:i((e,r)=>`Uploading ${Math.min(e+1,r)} of ${r}\u2026`,"uploading"),cancel:"Cancel",cancelA11y:"Cancel these uploads",received:i(e=>`${e===1?"Record received.":`${e} records received.`} We\u2019ll read and review ${e===1?"it":"them"}, then add the results to your records, usually within 1-2 business days.`,"received"),retryFailed:i(e=>`Retry ${e} that didn\u2019t upload`,"retryFailed"),retryFailedA11y:i(e=>`Retry ${e} failed upload${e>1?"s":""}`,"retryFailedA11y"),addMore:"Add more files",addMoreA11y:"Add more records",done:"Done",doneA11y:"Done, view records",errors:Object.freeze({start:"We couldn\u2019t start that upload. Check your connection and try again.",startPlain:"We couldn\u2019t start that upload. Please try again.",upload:"We couldn\u2019t upload that record. Check your connection and try again."})});function Mn(e){let{style:r,className:t,renderPending:o,...n}=_e(e,["onNavigate","onBack"]),{userRef:l}=ee(),{styles:a}=j();return jsxRuntime.jsx(Te,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Oe(n.onBack,Le),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...r},"data-testid":"upload-screen",children:[l===null?jsxRuntime.jsx("div",{style:a.body,children:jsxRuntime.jsx(Je,{label:G.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx($y,{...n}),jsxRuntime.jsx(De,{})]})})}i(Mn,"EverfurRecordsUpload");function $y({petRef:e,petName:r,controller:t,onNavigate:o,onBack:n}){let{theme:l,styles:a}=j(),{runtime:c}=ee(),s=react.useMemo(()=>t?{petRef:e,controller:t}:{petRef:e},[e,t]),d=We(s),u=t!==void 0||Gn(c.registry.services.uploadTransport);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(He,{title:"",onBack:n,testID:"upload-header"}),jsxRuntime.jsxs("div",{style:{...a.body,...a.content,padding:l.space.lg+l.space.xs,gap:l.space.lg+l.space.xs},children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:l.space.sm,textAlign:"center"},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"block",width:52,height:52,borderRadius:l.radius.pill,backgroundColor:l.color.brandSoft,border:`1px solid ${l.color.brandBorder}`}}),jsxRuntime.jsx("h3",{style:{...a.sectionTitle,fontSize:l.type.size.heading+2,color:l.color.brand},children:Ke.title(r)}),jsxRuntime.jsx("p",{style:{...a.muted,fontSize:l.type.size.body,maxWidth:340},children:Ke.subtitle(r)})]}),jsxRuntime.jsx(wa,{records:d,requestId:null,canUpload:u,onDone:o?p=>o({name:"request",requestId:p}):void 0})]})]})}i($y,"UploadBody");function wa({records:e,requestId:r,canUpload:t,onDone:o}){let{theme:n,styles:l}=j(),a=react.useRef(null),c=`records-upload-format-hint-${r??"new"}`,[s,d]=react.useState(null),[u,p]=react.useState(0),[m,y]=react.useState(false),g=react.useRef(r),f=react.useRef([]),R=e.uploadQueue.filter(_=>_.status!=="skipped"),b=R.filter(_=>_.status==="done").length,E=R.filter(_=>_.status==="failed").length,h=!e.isUploading&&!m&&u>0,v=react.useCallback(async _=>{let{uploadable:T,skipped:I}=bs(_),F=ko(I);if(T.length===0){F!==null&&d(F);return}d(F),y(true);try{let q=g.current;if(q===null){let $=await e.createRequest(`records-upload-${Date.now().toString(36)}`);if(!$.ok){d(Ke.errors.start);return}q=$.value.id,g.current=q;}p($=>$+1);let M=await e.uploadDocuments(q,T);f.current=M.flatMap(($,V)=>$.status==="failed"&&T[V]!==void 0?[T[V]]:[]);}finally{y(false);}},[e]),S=i(_=>{let T=Array.from(_.currentTarget.files??[]);_.currentTarget.value="",!(T.length===0||!t)&&(async()=>{let I=[];for(let F of T)I.push(await Po(F));await v(I);})();},"onChange"),C=i(()=>a.current?.click(),"pick"),k=e.isUploading||m;return jsxRuntime.jsxs("section",{style:{...l.creamCard,backgroundColor:n.color.surface,border:`1px solid ${n.color.brandSoft}`,borderRadius:n.radius.md},"data-testid":"records-upload-card",children:[jsxRuntime.jsx("h4",{style:{...l.rowTitle,...O(n,"bold"),fontSize:n.type.size.subtitle},children:Ke.cardTitle}),jsxRuntime.jsx("p",{id:c,style:l.muted,children:Ke.cardSubtitle}),jsxRuntime.jsx("input",{ref:a,type:"file",accept:_o,multiple:true,tabIndex:-1,"aria-hidden":"true",hidden:true,disabled:!t,onChange:S,"data-testid":"records-upload-input"}),s?jsxRuntime.jsx("p",{role:"alert",style:l.errorBanner,children:s}):null,jsxRuntime.jsx(_d,{records:e}),k?jsxRuntime.jsx("p",{style:l.muted,children:Ke.uploading(b,R.length)}):h?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:n.space.sm},children:[b>0?jsxRuntime.jsx("p",{role:"status",style:l.bodyText,children:Ke.received(b)}):null,E>0?jsxRuntime.jsx(B,{label:Ke.retryFailed(E),kind:"link",ariaLabel:Ke.retryFailedA11y(E),onClick:()=>{v(f.current);},testID:"records-upload-retry-failed"}):null,jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:n.space.sm},children:[jsxRuntime.jsx(B,{label:Ke.addMore,kind:"link",ariaLabel:Ke.addMoreA11y,ariaDescribedBy:c,disabled:!t,onClick:C,testID:"records-upload-another"}),o&&g.current!==null&&b>0?jsxRuntime.jsx(B,{label:Ke.done,ariaLabel:Ke.doneA11y,onClick:()=>o(g.current),testID:"records-upload-done"}):null]})]}):jsxRuntime.jsx(B,{label:Ke.chooseFiles,ariaLabel:Ke.chooseFilesA11y,ariaDescribedBy:c,disabled:!t,onClick:C,testID:"records-upload-choose"})]})}i(wa,"UploadRecordCard");function $n(e){let{style:r,className:t,renderPending:o,...n}=_e(e,["onNavigate","onBack"]),{userRef:l}=ee(),{styles:a}=j();return jsxRuntime.jsx(Te,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Oe(n.onBack,Le),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...r},"data-testid":"records-request-screen",children:[l===null?jsxRuntime.jsx("div",{style:a.body,children:jsxRuntime.jsx(Je,{label:G.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(Hy,{...n}),jsxRuntime.jsx(De,{})]})})}i($n,"EverfurRecordsRequest");function Hy({petRef:e,requestId:r,controller:t,onNavigate:o,onBack:n,onOpenUrl:l,nowMs:a}){let{styles:c}=j(),{runtime:s,userRef:d,scopeEpoch:u}=ee(),p=We(t?{petRef:e,controller:t}:{petRef:e}),m=p.requests.find(f=>f.id===r)??null,y=t!==void 0||Gn(s.registry.services.uploadTransport),g;return p.status==="loading"?g=jsxRuntime.jsx(yo,{testID:"records-request-loading"}):p.status==="error"&&p.error?g=jsxRuntime.jsx(Fe,{variant:Xe(p.error),message:p.error.displayMessage,onAction:p.error.retryable?p.refresh:void 0,testID:"records-request-error"}):m===null?g=jsxRuntime.jsx(Fe,{variant:"no_requests",testID:"records-request-missing"}):g=jsxRuntime.jsx(Vy,{request:m,records:p,canUpload:y,onNavigate:o,onOpenUrl:l,nowMs:a},JSON.stringify([d,u,m.id])),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(He,{title:m?oo(m):"",onBack:n,testID:"records-request-header"}),jsxRuntime.jsx("div",{style:c.body,children:g})]})}i(Hy,"RequestBody");function Vy({request:e,records:r,canUpload:t,onNavigate:o,onOpenUrl:n,nowMs:l}){let{theme:a,styles:c}=j(),s=fd({request:e,onRecovered:r.refresh,canUpload:t},Ir()),[d,u]=react.useState(null),[p,m]=react.useState(false),[y,g]=react.useState(null),f=react.useRef(true);react.useEffect(()=>(f.current=true,()=>{f.current=false;}),[]);let R=s.request,b=l??Date.now(),E=R.status==="published",h=R.status==="published"||R.status==="failed"||R.status==="revoked",v=Ai(R),S=R.wireStatus==="clinic_responded_no_records",C=Qs(R,b),k=h?null:R.waitingExpectation?.trim()||null,_=io(R),T=s.error!==null&&d!==null?d==="revoke"?ue.errors.cancel:ue.errors[d]:null,I=i((V,re)=>{u(V),re();},"run"),F=i(()=>{p||(m(true),g(null),r.createRequest(`records-upload-${Date.now().toString(36)}`).then(V=>{if(f.current){if(m(false),!V.ok){g(ue.errors.start);return}o?.({name:"request",requestId:V.value.id});}}));},"startFresh"),q={display:"flex",flexDirection:"column",gap:a.space.sm},M=i(V=>jsxRuntime.jsx("p",{role:"alert",style:c.errorBanner,children:V}),"errorBanner"),$=`records-failure-clinic-email-${R.id}`;return jsxRuntime.jsxs("div",{style:{...c.content,gap:a.space.lg+a.space.xs/2},"data-testid":`records-request-${R.id}`,children:[R.statusLabel.length>0||R.heldItemCount>0?jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:a.space.sm},"data-testid":"records-request-status-row",children:[R.statusLabel.length>0?jsxRuntime.jsx(cr,{label:R.statusLabel,tone:Ss(R),testID:"records-request-status-chip"}):null,R.heldItemCount>0?jsxRuntime.jsx(cr,{label:Ri(R.heldItemCount),tone:"neutral",testID:"records-request-held-count"}):null]}):null,R.status==="awaiting_upload"?jsxRuntime.jsx(wa,{records:r,requestId:R.id,canUpload:t}):null,k&&!C?jsxRuntime.jsx("p",{style:c.infoNote,children:k}):R.wireStatus==="awaiting_response"&&!C?jsxRuntime.jsx("p",{style:c.infoNote,children:ue.awaitingNote}):null,C?jsxRuntime.jsx("p",{style:c.cautionNote,"data-testid":"records-request-waiting-banner",children:ue.waitingBanner(Ii(R,b))}):null,E&&o?jsxRuntime.jsx(B,{label:ue.viewRecords,onClick:()=>o({name:"dashboard"}),testID:"records-request-view-dashboard"}):null,Xs(R)?jsxRuntime.jsxs("section",{style:{...q,gap:a.space.md,borderRadius:a.radius.lg-a.space.xs,padding:a.space.md+a.space.xs/2,backgroundColor:v?a.color.badgeBgCritical:a.color.badgeBgCaution},"data-testid":"records-failure-card",children:[jsxRuntime.jsx("p",{style:{...c.rowTitle,...O(a,"bold"),color:v?a.color.danger:a.color.warningStrong},children:Ks(R)}),R.canUpdateClinicEmail!==true&&R.canRetrySend!==true?jsxRuntime.jsx("p",{style:c.rowDetail,children:ue.nextStep}):null,R.canUpdateClinicEmail===true?jsxRuntime.jsxs("div",{style:q,children:[jsxRuntime.jsx("label",{htmlFor:$,style:c.fieldLabel,children:$r.email}),jsxRuntime.jsx("input",{id:$,type:"email",style:c.field,placeholder:$r.emailPlaceholder,autoComplete:"off",maxLength:320,value:s.email,disabled:s.busy,onChange:V=>s.setEmail(V.target.value),"data-testid":"records-failure-clinic-email"}),s.emailInvalid?jsxRuntime.jsx("p",{role:"alert",style:c.errorText,children:ue.errors.invalidEmail}):null,jsxRuntime.jsx(B,{label:$r.updateEmail,ariaLabel:$r.updateEmailA11y,disabled:!s.canUpdateEmail,busy:s.busy&&d==="email",onClick:()=>I("email",s.updateEmail),testID:"records-failure-update-email"})]}):null,R.canRetrySend===true?jsxRuntime.jsx(B,{label:$r.retry,kind:"outline",ariaLabel:$r.retryA11y,disabled:!s.canRetry,busy:s.busy&&d==="retry",onClick:()=>I("retry",s.retry),testID:"records-failure-retry-send"}):null,R.canRetrySend===true&&s.hasEmailEdit?jsxRuntime.jsx("p",{style:c.rowDetail,children:$r.retryHint}):null,T&&(d==="email"||d==="retry")?M(T):null]}):null,(v||S)&&o?jsxRuntime.jsx(B,{label:ue.tryAnotherClinic,kind:"outline",ariaLabel:ue.tryAnotherClinicA11y,onClick:()=>o({name:"clinicPicker"}),testID:"records-request-try-another-clinic"}):null,_!==null?jsxRuntime.jsxs("div",{style:q,children:[jsxRuntime.jsx(Pd,{call:_,prompt:R.statusLabel}),R.canRetrySend===true?jsxRuntime.jsx(B,{label:s.busy&&d==="retry"?ue.resending:ue.resend,kind:"outline",ariaLabel:s.busy&&d==="retry"?ue.resendingA11y:ue.resendA11y,disabled:!s.canRetry,onClick:()=>I("retry",s.retry),testID:"records-resend-authorization"}):null]}):null,s.canConvert?jsxRuntime.jsxs("div",{style:q,children:[jsxRuntime.jsx(B,{label:s.busy&&d==="convert"?ue.converting:ue.convert,busy:s.busy&&d==="convert",onClick:()=>I("convert",s.convert),testID:"records-convert-upload"}),jsxRuntime.jsx("p",{style:c.muted,children:ue.convertHint}),T&&d==="convert"?M(T):null]}):null,h&&!E?jsxRuntime.jsxs("div",{style:q,children:[jsxRuntime.jsx(B,{label:p?ue.freshUploadStarting:ue.freshUpload,kind:v||S?"outline":"primary",busy:p,onClick:F,testID:"records-upload-own-fresh"}),y?M(y):null]}):null,T&&d==="revoke"?M(T):null,R.canRevoke===true?s.confirmingRevoke?jsxRuntime.jsxs("div",{style:q,"data-testid":"records-revoke-confirm",children:[jsxRuntime.jsx("p",{style:{...c.rowTitle,...O(a,"bold"),fontSize:a.type.size.subtitle},children:$r.cancelQuestion}),jsxRuntime.jsx("p",{style:c.bodyText,children:$r.cancelConsequence}),jsxRuntime.jsx(B,{label:s.busy&&d==="revoke"?ue.cancelling:ue.cancel,kind:"danger",ariaLabel:s.busy&&d==="revoke"?ue.cancellingA11y:ue.cancelA11y,busy:s.busy&&d==="revoke",onClick:()=>I("revoke",s.revoke),testID:"records-revoke-do"}),jsxRuntime.jsx(B,{label:$r.keepRequest,kind:"outline",disabled:s.busy,onClick:s.keepRequest,testID:"records-revoke-keep"})]}):jsxRuntime.jsx(B,{label:ue.cancel,kind:"danger",ariaLabel:ue.cancelA11y,disabled:s.busy,onClick:s.askRevoke,testID:"records-revoke"}):null,jsxRuntime.jsx("div",{"aria-hidden":"true",style:{height:1,backgroundColor:a.color.borderHairlineGreen,margin:`${a.space.xs}px 0`}}),jsxRuntime.jsx(rn,{request:R}),Nn(R)?jsxRuntime.jsx(zn,{requestId:R.id,...n?{onOpenUrl:n}:{}}):null]})}i(Vy,"RequestDetail");function Bn(e){return e.name==="request"||e.name==="clinicPicker"||e.name==="consent"||e.name==="clinicBatch"||e.name==="upload"}i(Bn,"isOverlayScreen");function ac(e,r){if(r.type!=="closeOverlay")return gn(e,r);let t=e.stack.length;for(;t>1&&Bn(e.stack[t-1]);)t-=1;return t===e.stack.length?e:Object.freeze({stack:Object.freeze(e.stack.slice(0,t))})}i(ac,"recordsPageNavReducer");function sc(e){let{stack:r}=e,t=r[r.length-1],o=Bn(t)?t:null,n=r.length-1;for(;n>0&&Bn(r[n]);)n-=1;let l=r[n],a=Bn(l)?{name:"dashboard"}:l,c=o===null?null:r[r.length-2];return Object.freeze({body:a,overlay:o,overlayCanStepBack:c!=null&&Bn(c),bodyCanGoBack:n>0})}i(sc,"splitRecordsPageNav");function lc(e){return {...e.petName!==void 0?{petName:e.petName}:{},...e.onOpenUrl?{onOpenUrl:e.onOpenUrl}:{},...e.onCopy?{onCopy:e.onCopy}:{},...e.onAsk?{onAsk:e.onAsk}:{},...e.location?{location:e.location}:{}}}i(lc,"seamsOf");function dc({screen:e,ctx:r,onBack:t}){let o={...lc(r),onNavigate:r.navigate,onBack:t},n={...r.controller?{controller:r.controller}:{},...r.consentVersion!==void 0?{consentVersion:r.consentVersion}:{}},l=Ky;switch(e.name){case "record":return jsxRuntime.jsx(Fn,{petRef:r.petRef,...o,...n,style:l});case "timeline":return jsxRuntime.jsx(vo,{petRef:r.petRef,...o,style:l});case "document":return jsxRuntime.jsx(Ln,{petRef:r.petRef,...o,...n,style:l});case "contributions":return jsxRuntime.jsx(Co,{petRef:r.petRef,docId:e.docId,...o,style:l});default:return Dr(e)}}i(dc,"RecordsPageBodyScreenView");function cc({screen:e,ctx:r,requests:t,onBack:o,onClose:n}){let l=jt(e),a=react.useMemo(()=>Yy(e,t),[e,t]),c=r.onAsk,s=c?{onAsk:i((y,g)=>{n(),c(y,g);},"onAsk")}:{},d={...lc(r),...s,onNavigate:r.navigate,onBack:o},u=r.clinicController?{controller:r.clinicController}:{},p=r.onCaptureSignature?{onCaptureSignature:r.onCaptureSignature}:{},m;switch(e.name){case "request":m=jsxRuntime.jsx($n,{petRef:r.petRef,requestId:e.requestId,...d,...r.controller?{controller:r.controller}:{},style:Un});break;case "clinicPicker":m=jsxRuntime.jsx(En,{petRef:r.petRef,...d,...u,...r.controller?{recordsController:r.controller}:{},style:Un});break;case "consent":m=jsxRuntime.jsx(Tn,{petRef:r.petRef,clinic:e.clinic,...d,...r.ownerName!==void 0?{ownerName:r.ownerName}:{},...p,...u,style:Un});break;case "clinicBatch":m=jsxRuntime.jsx(wn,{petRef:r.petRef,petName:r.petName??"",ownerName:r.ownerName??"",onClose:o,onCreated:()=>r.navigate({name:"dashboard"}),...p,...u,style:Un});break;case "upload":m=jsxRuntime.jsx(Mn,{petRef:r.petRef,...d,...r.controller?{controller:r.controller}:{},style:Un});break;default:m=Dr(e);}return jsxRuntime.jsx(Ct,{label:a,onClose:n,shape:"side",panelStyle:Qy,testID:"everfur-records-page-sheet",children:jsxRuntime.jsx("div",{ref:l,tabIndex:-1,style:Xy,children:m})})}i(cc,"RecordsPageOverlay");function Yy(e,r){if(e.name==="upload")return Se.uploadAction;if(e.name!=="request")return Se.requestRecords;let t=r.find(o=>o.id===e.requestId);return t?eo(t):Se.requestTimeline}i(Yy,"overlayLabel");var Ky=Object.freeze({height:"auto"}),Qy=Object.freeze({padding:0,gap:0}),Xy=Object.freeze({height:"100%",outline:"none"}),Un=Object.freeze({height:"100%"});function Bo({requests:e,petName:r,level:t,headingId:o,onOpenRequest:n,onUpload:l,onOpenUrl:a}){let{theme:c,styles:s}=j(),d=co(t),u=e.length>0;return jsxRuntime.jsxs("section",{"aria-labelledby":o,style:s.section,"data-testid":"everfur-records-page-requests",children:[jsxRuntime.jsxs("div",{style:s.sectionHeader,children:[jsxRuntime.jsx(d,{id:o,style:{...s.sectionTitle,color:c.color.brand},children:Se.requestsFor(r)}),u?jsxRuntime.jsx("span",{style:s.sectionCount,"data-testid":"everfur-records-page-requests-count",children:e.length}):null]}),u?jsxRuntime.jsx("ul",{style:{...s.plainList,gap:c.space.md},children:e.map(p=>{let m=eo(p),y=bi(null,p)!==null;return jsxRuntime.jsxs("li",{style:s.creamCard,"data-testid":`everfur-records-page-request-${p.id}`,children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:c.space.sm},children:[jsxRuntime.jsx("span",{style:{...s.rowTitle,fontSize:c.type.size.subtitle},children:m}),n?jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:c.space.sm},children:[y?jsxRuntime.jsx(B,{label:Ke.cardTitle,onClick:()=>n(p),testID:`everfur-records-page-resume-upload-${p.id}`}):null,jsxRuntime.jsx(B,{label:Se.requestTimeline,kind:"outline",ariaLabel:Se.requestTimelineA11y(m),onClick:()=>n(p),testID:`everfur-records-page-open-${p.id}`})]}):null]}),jsxRuntime.jsx(rn,{request:p}),Nn(p)?jsxRuntime.jsx(zn,{requestId:p.id,...a?{onOpenUrl:a}:{}}):null]},p.id)})}):jsxRuntime.jsxs("div",{style:s.creamCard,"data-testid":"everfur-records-page-upload-prompt",children:[jsxRuntime.jsx("span",{style:{...s.rowTitle,fontSize:c.type.size.subtitle},children:Se.uploadPromptTitle(r)}),jsxRuntime.jsx("p",{style:s.bodyText,children:Se.uploadPromptBody}),l?jsxRuntime.jsx(B,{label:Se.uploadAction,onClick:l,testID:"everfur-records-page-upload"}):null]})]})}i(Bo,"RecordsPageRequests");var og=1248,ig=Object.freeze({height:"auto"}),jo=Object.freeze({overflowY:"visible",flex:"0 0 auto"});function ag(e){let{style:r,className:t,renderPending:o,...n}=_e(e,["onNavigate","onBack","onAsk"]),{userRef:l}=ee(),{styles:a}=j();return jsxRuntime.jsx(Te,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Oe(n.onBack,Le),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...ig,...r},"data-testid":"everfur-records-page",children:[l===null?jsxRuntime.jsx("div",{style:{...a.body,...jo},children:jsxRuntime.jsx(Je,{label:G.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(sg,{...n}),jsxRuntime.jsx(De,{})]})})}i(ag,"EverfurRecordsPage");function sg(e){let{petRef:r,petName:t,controller:o,clinicController:n,consentVersion:l,ownerName:a,onCaptureSignature:c,onNavigate:s,onOpenUrl:d,onCopy:u,onAsk:p,location:m}=e,[y,g]=react.useReducer(ac,void 0,()=>Ut()),f=react.useCallback(F=>{s?s(F):g({type:"navigate",screen:F});},[s]),{body:R,overlay:b,overlayCanStepBack:E,bodyCanGoBack:h}=sc(y),v=react.useMemo(()=>o?{petRef:r,controller:o}:{petRef:r},[r,o]),S=We(v),{refresh:C}=S,k=react.useRef(false);react.useEffect(()=>{b!==null?k.current=true:k.current&&(k.current=false,C());},[b,C]);let _=jt(R),T={petRef:r,petName:t,controller:o,clinicController:n,consentVersion:l,ownerName:a,onCaptureSignature:c,navigate:f,...d?{onOpenUrl:d}:{},...u?{onCopy:u}:{},...p?{onAsk:p}:{},...m?{location:m}:{}},I=R.name==="dashboard"||R.name==="requests";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:_,tabIndex:-1,style:lg,children:I?jsxRuntime.jsx(dg,{...e,records:S,navigate:f}):jsxRuntime.jsx(dc,{screen:R,ctx:T,onBack:h?()=>g({type:"pop"}):()=>f({name:"dashboard"})})}),b!==null?jsxRuntime.jsx(cc,{screen:b,ctx:T,requests:S.requests,onBack:E?()=>g({type:"pop"}):()=>g({type:"closeOverlay"}),onClose:()=>g({type:"closeOverlay"})}):null]})}i(sg,"RecordsPageBody");var lg=Object.freeze({outline:"none"});function dg({petRef:e,petName:r,consentVersion:t,onAsk:o,onOpenUrl:n,headingLevel:l,records:a,navigate:c}){let{theme:s,styles:d}=j(),u=St("recordsClinic"),p=u.enabled||u.isPending,m=Bs(l??lo),y=co(m),g=`${react.useId()}-requests-heading`,f=tt(t,a.consent),R=i(()=>{let E=Vr(t,a.consent);E.length!==0&&a.grantConsent(E,`records-consent-${Date.now().toString(36)}`);},"onGrant"),b={boxSizing:"border-box",width:"100%",maxWidth:og,margin:"0 auto",display:"flex",flexDirection:"column",gap:s.space.lg+s.space.xs,padding:`${s.space.lg}px ${s.space.lg}px ${s.space.xxl}px`};if(a.status==="loading")return jsxRuntime.jsx("div",{style:{...d.body,...jo},children:jsxRuntime.jsx("div",{style:b,children:jsxRuntime.jsx(Yt,{testID:"everfur-records-page-loading"})})});if(a.status==="error"){let E=Wr(a,f),h=E.kind==="error"||E.kind==="pet_not_found"?jsxRuntime.jsx(Fe,{variant:Xe(E.error),message:E.error.displayMessage,onAction:E.error.retryable?()=>a.refresh():void 0,testID:"everfur-records-page-error"}):vt(a,R,f);return jsxRuntime.jsx("div",{style:{...d.body,...jo},children:jsxRuntime.jsx("div",{style:b,children:h})})}return jsxRuntime.jsx("div",{style:{...d.body,...jo},children:jsxRuntime.jsxs("div",{style:b,"data-testid":"everfur-records-page-content",children:[jsxRuntime.jsxs("header",{style:{...d.creamCard,gap:s.space.md,padding:`${s.space.lg+s.space.xs}px ${s.space.lg+s.space.md}px`},"data-testid":"everfur-records-page-header",children:[jsxRuntime.jsx(y,{tabIndex:-1,[hn]:"",style:{...d.headerTitle,whiteSpace:"normal",overflow:"visible"},children:Se.title}),jsxRuntime.jsx("p",{style:d.bodyText,children:Se.lead}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:s.space.sm},"data-testid":"everfur-records-page-actions",children:[p?jsxRuntime.jsx(B,{label:Se.requestRecords,onClick:()=>c({name:"clinicPicker"}),testID:"everfur-records-page-request-records"}):null,jsxRuntime.jsx(B,{label:Se.uploadAction,kind:"outline",onClick:()=>c({name:"upload"}),testID:"everfur-records-page-upload-action"}),o?jsxRuntime.jsx(B,{label:Se.askA11y(r),kind:"ask",ariaLabel:Se.askA11y(r),onClick:()=>o(hs(r),{type:"marker_summary",id:e}),testID:"everfur-records-page-ask"}):null]}),jsxRuntime.jsxs("nav",{style:{display:"flex",flexWrap:"wrap",columnGap:s.space.lg,rowGap:s.space.xs},"data-testid":"everfur-records-page-links",children:[jsxRuntime.jsx(uc,{label:Se.viewRecord,onClick:()=>c({name:"record"}),testID:"everfur-records-page-link-record"}),jsxRuntime.jsx(uc,{label:Se.viewTimeline,onClick:()=>c({name:"timeline"}),testID:"everfur-records-page-link-timeline"})]})]}),jsxRuntime.jsx(Bo,{requests:a.requests,petName:r,level:Ti(m),headingId:g,onOpenRequest:E=>c({name:"request",requestId:E.id}),onUpload:()=>c({name:"upload"}),...n?{onOpenUrl:n}:{}})]})})}i(dg,"RecordsPageContent");function uc({label:e,onClick:r,testID:t}){let{theme:o,styles:n}=j();return jsxRuntime.jsx("button",{type:"button",onClick:r,style:{...n.pill,...n.pillLink,minHeight:44,padding:0,fontSize:o.type.size.bodyTight,textDecoration:"underline",textUnderlineOffset:4},"data-testid":t,children:e})}i(uc,"PageLink");var br=200,_a=16,Pa=(br-_a)/2,pc=2*Math.PI*Pa;function fc({summary:e,onAsk:r,testID:t}){let o=ug(),{theme:n,styles:l}=j(),{totalMarkers:a,inRangeCount:c,outOfRangeCount:s,unknownCount:d}=e,u=c+s+d,p=react.useMemo(()=>{if(!(u>0))return [];let m=[{key:"in_range",color:n.color.success,count:c},{key:"out_of_range",color:n.color.danger,count:s},{key:"unknown",color:n.color.text.muted,count:d}],y=0;return m.filter(g=>g.count>0).map(g=>{let f=g.count/u*pc,R=-y;return y+=f,{key:g.key,color:g.color,length:f,offset:R}})},[u,c,s,d,n]);return jsxRuntime.jsxs("section",{role:"group","aria-label":hr.title,style:o.card,"data-testid":t,children:[jsxRuntime.jsx("h3",{style:o.title,children:hr.title}),jsxRuntime.jsx("div",{style:o.ringRow,children:jsxRuntime.jsxs("div",{style:o.ringWrap,role:"img","aria-label":hr.a11y(a,c,s,d),children:[jsxRuntime.jsxs("svg",{width:br,height:br,viewBox:`0 0 ${br} ${br}`,"aria-hidden":"true",focusable:"false",children:[jsxRuntime.jsx("circle",{cx:br/2,cy:br/2,r:Pa,stroke:n.color.surfaceSubtle,strokeWidth:_a,fill:"none"}),jsxRuntime.jsx("g",{transform:`rotate(-90 ${br/2} ${br/2})`,children:p.map(m=>jsxRuntime.jsx("circle",{cx:br/2,cy:br/2,r:Pa,stroke:m.color,strokeWidth:_a,fill:"none",strokeDasharray:`${m.length} ${pc}`,strokeDashoffset:m.offset,strokeLinecap:p.length>1?"round":"butt","data-testid":`marker-ring-${m.key}`},m.key))})]}),jsxRuntime.jsxs("div",{style:o.center,"aria-hidden":"true",children:[jsxRuntime.jsx("span",{style:o.centerCount,children:a}),jsxRuntime.jsx("span",{style:o.centerLabel,children:a===1?hr.marker:hr.markers})]})]})}),p.length>0?jsxRuntime.jsxs("div",{style:o.badges,children:[jsxRuntime.jsx("span",{style:{...o.badge,borderColor:n.color.danger,color:n.color.danger},children:`${s} ${hr.outOfRange}`}),jsxRuntime.jsx("span",{style:{...o.badge,borderColor:n.color.success,color:n.color.success},children:`${c} ${hr.inRange}`}),d>0?jsxRuntime.jsx("span",{style:{...o.badge,borderColor:n.color.text.muted,color:n.color.text.muted},children:`${d} ${hr.noRange}`}):null]}):null,jsxRuntime.jsx("p",{style:o.subtitle,children:hr.subtitle}),r?jsxRuntime.jsx("button",{type:"button",onClick:r,"aria-label":hr.askA11y,style:{...l.pill,...l.pillAsk},"data-testid":"marker-summary-ask",children:hr.ask}):null]})}i(fc,"MarkerSummaryCard");function ug(){let e=ce();return react.useMemo(()=>pg(e),[e])}i(ug,"useStyles");function pg(e){let{color:r,space:t,radius:o,type:n}=e;return {card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.sm+t.xs/2,borderRadius:o.sm,backgroundColor:r.surfaceCream,border:`1px solid ${r.brandBorder}`,padding:t.lg-1},title:{margin:0,...O(e,"bold"),fontSize:n.size.body,color:r.brand,letterSpacing:n.letterSpacing.headerBrand},ringRow:{display:"flex",justifyContent:"center"},ringWrap:{position:"relative",width:br,height:br},center:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",pointerEvents:"none"},centerCount:{...O(e,"medium"),fontSize:n.size.verdict*2,lineHeight:1.1,color:r.text.primary},centerLabel:{...O(e,"medium"),fontSize:n.size.heading-1,lineHeight:1.2,color:r.text.primary},badges:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:t.sm},badge:{border:"1px solid",borderRadius:o.pill,padding:`${t.xs}px ${t.sm+t.xs/2}px`,...O(e,"mono"),fontSize:n.size.nano,lineHeight:`${n.size.tiny}px`,textTransform:"uppercase",letterSpacing:n.letterSpacing.headerBrand/2},subtitle:{margin:0,...O(e,"regular"),fontSize:n.size.caption,lineHeight:`${Math.round(n.size.caption*n.lineHeight.relaxed)}px`,color:r.text.primary}}}i(pg,"makeStyles");function mg(e){return e.value!==null&&Number.isFinite(e.value)}i(mg,"numeric");function yc(e){let r=e.points.filter(mg);if(r.length===0)return null;let t=e.points[e.points.length-1]??null,o=t?.refLow??null,n=t?.refHigh??null,l=r.map(b=>b.value),a=Math.min(...l,...o!==null?[o]:[],...n!==null?[n]:[]),c=Math.max(...l,...o!==null?[o]:[],...n!==null?[n]:[]);a===c&&(a-=1,c+=1);let s=(c-a)*.18,d=a-s,u=c+s,p=u-d,m=i(b=>(u-b)/p*100,"y"),y=6,g=r.length,f=r.map((b,E)=>({index:E,xPct:g<=1?50:y+E/(g-1)*(100-2*y),yPct:m(b.value),status:b.status,point:b})),R=o!==null||n!==null?{topPct:n!==null?m(n):0,bottomPct:o!==null?m(o):100}:null;return {points:f,band:R,firstDate:r[0]?.at??null,lastDate:r[r.length-1]?.at??null}}i(yc,"buildMarkerChart");var gc=100,Ho=44;function yg({marker:e,onPointPress:r,onAsk:t}){let o=Ta(),{theme:n,styles:l}=j(),a=Kr(e.latest?.status??null),c=Vt(e.trajectory,e.points.length),s=react.useMemo(()=>yc(e),[e]),d=e.latest?ur(e.latest.value,e.unit,e.latest.qualitativeResult):null;return jsxRuntime.jsx("li",{style:o.page,"data-testid":`marker-card-${e.markerId}`,children:jsxRuntime.jsxs("article",{style:o.card,children:[jsxRuntime.jsxs("div",{style:o.headerRow,children:[jsxRuntime.jsxs("div",{style:o.nameColumn,children:[jsxRuntime.jsx("span",{style:o.markerName,children:e.name}),e.unit?jsxRuntime.jsx("span",{style:o.unit,children:e.unit}):null]}),jsxRuntime.jsx("span",{"aria-label":rt.status(a.label),children:jsxRuntime.jsx(cr,{label:a.label,tone:No(e.latest?.status??null)})})]}),e.latest&&d!==null?jsxRuntime.jsxs("div",{style:o.latestRow,children:[jsxRuntime.jsx("span",{style:{...o.latestValue,...a.outOfRange?o.latestValueDanger:{}},"aria-label":rt.latestA11y(d,a.label,J(e.latest.at)),children:d}),jsxRuntime.jsx("span",{style:o.latestDate,children:J(e.latest.at)})]}):null,c?jsxRuntime.jsx("p",{style:o.trajectory,children:c}):null,s!==null?jsxRuntime.jsxs("div",{style:o.chartWrap,children:[jsxRuntime.jsxs("svg",{viewBox:`0 0 ${gc} ${Ho}`,preserveAspectRatio:"none",style:o.plot,"aria-hidden":"true",focusable:"false",children:[s.band?jsxRuntime.jsx("rect",{x:0,y:s.band.topPct/100*Ho,width:gc,height:Math.max(0,(s.band.bottomPct-s.band.topPct)/100*Ho),fill:n.color.badgeBgPositive}):null,s.points.length>1?jsxRuntime.jsx("polyline",{fill:"none",stroke:n.color.brandBorder,strokeWidth:.6,vectorEffect:"non-scaling-stroke",points:s.points.map(u=>`${u.xPct},${u.yPct/100*Ho}`).join(" ")}):null]}),jsxRuntime.jsx("div",{style:o.dotLayer,children:s.points.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>r(e,u.point),"aria-label":ma(e,u.point),style:{...o.dot,...u.status==="above"||u.status==="below"?o.dotDanger:{},left:`${u.xPct}%`,top:`${u.yPct}%`},"data-testid":`marker-point-${e.markerId}-${u.index}`},u.index))}),jsxRuntime.jsx("ul",{"aria-label":rt.readingsA11y(e.name),style:o.a11yTable,children:e.points.map((u,p)=>jsxRuntime.jsx("li",{children:ma(e,u)},p))}),jsxRuntime.jsx("p",{style:e.points.length===1?o.singleHint:o.tapHint,children:e.points.length===1?rt.singleHint:rt.tapHint})]}):jsxRuntime.jsx("p",{style:o.emptyBody,children:rt.empty}),t?jsxRuntime.jsx("button",{type:"button",onClick:()=>t(e),"aria-label":rt.askA11y(e.name),style:{...l.pill,...l.pillAsk},"data-testid":`marker-ask-${e.markerId}`,children:rt.ask}):null]})})}i(yg,"MarkerTrendCard");function Rc({markers:e,onPointPress:r,onAsk:t}){let o=Ta(),[n,l]=react.useState(0),a=i(s=>{let d=s.currentTarget;d.clientWidth<=0||l(Math.max(0,Math.min(Math.round(d.scrollLeft/d.clientWidth),e.length-1)));},"onScroll"),c=e[n]??null;return jsxRuntime.jsxs("div",{style:o.carousel,"data-testid":"marker-carousel",children:[jsxRuntime.jsx("ul",{style:o.track,onScroll:a,children:e.map(s=>jsxRuntime.jsx(yg,{marker:s,onPointPress:r,onAsk:t},s.markerId))}),jsxRuntime.jsxs("div",{style:o.footer,"aria-label":ui.a11y(c?.name??null,n,e.length),children:[jsxRuntime.jsx("div",{style:o.dots,"aria-hidden":"true",children:e.map((s,d)=>jsxRuntime.jsx("span",{style:{...o.dotIndicator,...d===n?o.dotActive:{}}},s.markerId))}),jsxRuntime.jsx("span",{style:o.counter,children:ui.counter(n,e.length)})]})]})}i(Rc,"MarkerTrendCarousel");function hc({marker:e,point:r,onClose:t,onAsk:o}){let n=Ta(),{styles:l}=j();if(e===null||r===null)return null;let a=i((c,s)=>jsxRuntime.jsxs("div",{style:n.detailRow,children:[jsxRuntime.jsx("dt",{style:n.detailLabel,children:c}),jsxRuntime.jsx("dd",{style:n.detailValue,children:s})]},c),"row");return jsxRuntime.jsxs(Ct,{label:dr.title,onClose:t,panelStyle:n.sheetBg,testID:"marker-provenance-sheet",children:[jsxRuntime.jsxs("div",{style:l.sheetHeader,children:[jsxRuntime.jsx("h3",{style:l.sheetTitle,children:dr.title}),jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":dr.close,style:l.iconButton,"data-testid":"marker-provenance-close",children:jsxRuntime.jsx("span",{style:l.closeGlyph,"aria-hidden":"true",children:"\xD7"})})]}),jsxRuntime.jsxs("div",{style:n.valueRow,children:[jsxRuntime.jsx("span",{style:n.markerName,children:e.name}),jsxRuntime.jsx("span",{style:n.latestValue,children:ur(r.value,e.unit,r.qualitativeResult)})]}),r.reviewed?jsxRuntime.jsx("span",{style:n.reviewed,children:dr.reviewed}):null,jsxRuntime.jsxs("dl",{style:n.details,children:[a(dr.collected,J(r.at)),r.sourceClinic?a(dr.clinic,r.sourceClinic):null,a(dr.referenceRange,r.refLow!==null||r.refHigh!==null?Lo(r,e.unit):dr.noRange),r.docId?a(dr.sourceDocument,r.docId):null]}),r.reviewed?null:jsxRuntime.jsx("p",{style:n.unverified,children:dr.unverified}),o?jsxRuntime.jsx("button",{type:"button",onClick:o,"aria-label":dr.askA11y,style:{...l.pill,...l.pillAsk},"data-testid":"marker-provenance-ask",children:dr.ask}):null]})}i(hc,"MarkerProvenanceDialog");function Ta(){let e=ce();return react.useMemo(()=>gg(e),[e])}i(Ta,"useStyles");function gg(e){let{color:r,space:t,radius:o,type:n}=e,l=i((c,s,d,u="regular")=>({margin:0,...O(e,u),fontSize:c,lineHeight:`${Math.round(c*s)}px`,color:d}),"text"),a=t.md;return {page:{flex:"0 0 100%",scrollSnapAlign:"start",boxSizing:"border-box",padding:`0 ${t.sm}px`,listStyle:"none"},card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.md,borderRadius:o.lg-t.xs/2,border:`1px solid ${r.brandBorder}`,backgroundColor:r.surface,padding:t.lg},headerRow:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:t.sm+t.xs/2},nameColumn:{flex:1,display:"flex",flexDirection:"column",gap:t.xs/2,minWidth:0},markerName:{...l(n.size.subtitle,n.lineHeight.snug,r.text.primary,"bold")},unit:{...O(e,"mono"),fontSize:n.size.tiny,lineHeight:`${n.size.body}px`,color:r.text.muted},latestRow:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:t.md},latestValue:{...l(n.size.verdict+t.xs,n.lineHeight.tight,r.text.primary,"bold")},latestValueDanger:{color:r.danger},latestDate:l(n.size.caption,n.lineHeight.normal,r.text.muted),trajectory:l(n.size.bodyTight,n.lineHeight.normal,r.text.muted),chartWrap:{position:"relative",display:"flex",flexDirection:"column",gap:t.sm},plot:{display:"block",width:"100%",height:140,borderRadius:o.sm,backgroundColor:r.surfaceCream,border:`1px solid ${r.borderHairlineGreen}`},dotLayer:{position:"absolute",left:0,right:0,top:0,height:140},dot:{position:"absolute",boxSizing:"border-box",width:a,height:a,borderRadius:a/2,marginLeft:-a/2,marginTop:-a/2,backgroundColor:r.brand,border:`2px solid ${r.surface}`,padding:0,cursor:"pointer"},dotDanger:{backgroundColor:r.danger},a11yTable:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",margin:0,padding:0,listStyle:"none"},tapHint:{...l(n.size.tiny,n.lineHeight.normal,r.text.placeholder),textAlign:"center"},singleHint:{...l(n.size.caption,n.lineHeight.normal,r.text.muted),textAlign:"center"},emptyBody:{...l(n.size.bodyTight,n.lineHeight.normal,r.text.muted),textAlign:"center",padding:`${t.xxl+t.xs}px 0`},carousel:{display:"flex",flexDirection:"column"},track:{display:"flex",overflowX:"auto",scrollSnapType:"x mandatory",margin:0,padding:0,listStyle:"none"},footer:{display:"flex",flexDirection:"column",alignItems:"center",gap:t.sm,paddingTop:t.md},dots:{display:"flex",gap:t.xs+t.xs/2},dotIndicator:{display:"block",width:t.xs+t.xs/2,height:t.xs+t.xs/2,borderRadius:t.xs-1,backgroundColor:r.borderHairlineGreen},dotActive:{width:t.lg+t.xs/2,backgroundColor:r.brand},counter:{...O(e,"mono"),fontSize:n.size.tiny,lineHeight:`${n.size.body}px`,letterSpacing:n.letterSpacing.eyebrow/3,color:r.text.muted},sheetBg:{backgroundColor:r.surfaceCream},valueRow:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:t.md},reviewed:{alignSelf:"flex-start",borderRadius:o.pill,padding:`${t.xs}px ${t.sm+t.xs/2}px`,backgroundColor:r.badgeBgPositive,...l(n.size.tiny,n.lineHeight.normal,r.success,"medium")},details:{margin:0,display:"flex",flexDirection:"column",gap:t.md},detailRow:{display:"flex",flexDirection:"column",gap:t.xs/2},detailLabel:{...l(n.size.caption,n.lineHeight.normal,r.text.muted,"medium")},detailValue:{...l(n.size.body,n.lineHeight.normal,r.text.primary),marginLeft:0},unverified:l(n.size.caption,n.lineHeight.normal,r.text.muted)}}i(gg,"makeStyles");var vg=i((e,r)=>e.getRecordDepth(r),"readDepth"),Cg=i(e=>!e.available,"depthEmpty");function Oa(e){let{style:r,className:t,renderPending:o,...n}=_e(e,["onNavigate","onBack","onAsk"]),{userRef:l}=ee(),{styles:a}=j();return jsxRuntime.jsx(Te,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Oe(n.onBack,Le),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...r},"data-testid":"records-dashboard",children:[l===null?jsxRuntime.jsx("div",{style:a.body,children:jsxRuntime.jsx(Je,{label:G.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(Eg,{...n}),jsxRuntime.jsx(De,{})]})})}i(Oa,"EverfurRecordsDashboard");function Eg({petRef:e,petName:r,controller:t,consentVersion:o,onNavigate:n,onBack:l,onAsk:a}){let{theme:c,styles:s}=j(),d=react.useMemo(()=>t?{petRef:e,controller:t}:{petRef:e},[e,t]),u=We(d),p=Ji(e),m=zr(e,vg,Cg),[y,g]=react.useState(null),f=react.useCallback((x,A)=>g({marker:x,point:A}),[]),R=tt(o,u.consent),b=i(()=>{let x=Vr(o,u.consent);x.length!==0&&u.grantConsent(x,`records-consent-${Date.now().toString(36)}`);},"onGrant"),E=p.markers?.markers??[],h=E.length>0,v=u.record!==null&&!u.record.isEmpty&&!u.record.withheld,S=ro(u.requests,e),C=pi({hasMarkers:h,requests:u.requests,petRef:e}),k=mi({recordLoading:u.status==="loading",hasFullRecord:v,recordError:u.status==="error",markersLoading:p.status==="loading",markersError:p.status==="error",hasMarkers:h,requestsLoading:u.status==="loading",dashboardState:C,drivingRequest:S}),_=p.markers?.disclaimer??u.record?.disclaimer??"",T=i(()=>{u.refresh(),p.refresh(),m.refresh();},"retryAll"),I=m.value!==null&&!m.value.withheld&&m.value.available?m.value:null,F=Pe(r),q=a&&p.markers?.summary?()=>{let x=Md(r,p.markers?.summary??{totalMarkers:0,inRangeCount:0,outOfRangeCount:0,unknownCount:0},e);a(x.prompt,x.entityRef);}:void 0,M=a?x=>{let A=zd(r,{canonicalName:x.name,markerId:x.markerId,latestValueText:x.latest?ur(x.latest.value,x.unit,x.latest.qualitativeResult):null,statusText:x.latest?Kr(x.latest.status).label:null,trajectoryText:Vt(x.trajectory,x.points.length),meaningText:x.meaning});a(A.prompt,A.entityRef);}:void 0,$=a&&y?()=>{let{marker:x,point:A}=y,D=$d(r,{canonicalName:x.name,valueText:ur(A.value,x.unit,A.qualitativeResult),collectedAt:J(A.at),sourceClinic:A.sourceClinic,referenceText:A.refLow!==null||A.refHigh!==null?Lo(A,x.unit):null,flagged:A.status==="above"?"above":A.status==="below"?"below":null,reviewed:A.reviewed,entityId:A.docId??x.markerId});g(null),a(D.prompt,D.entityRef);}:void 0,V=i((x,A,D)=>jsxRuntime.jsxs("button",{type:"button",onClick:A,"aria-label":x,style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",borderRadius:c.radius.md,border:`1px solid ${c.color.brandBorder}`,backgroundColor:c.color.surface,padding:c.space.lg,cursor:"pointer",font:"inherit",color:c.color.text.primary,textAlign:"left"},"data-testid":D,children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:c.space.md},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:18,height:18,borderRadius:c.radius.xs,backgroundColor:c.color.brandSoft,border:`1px solid ${c.color.brandBorder}`}}),jsxRuntime.jsx("span",{style:{...s.rowTitle},children:x})]}),jsxRuntime.jsx(kt,{})]}),"actionRow"),re=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p.markers?.summary?jsxRuntime.jsx("div",{style:s.inset,children:jsxRuntime.jsx(fc,{summary:p.markers.summary,onAsk:q,testID:"dashboard-marker-summary"})}):null,jsxRuntime.jsx("p",{style:s.lead,children:lr.lead(r)}),jsxRuntime.jsx(Rc,{markers:E,onPointPress:f,onAsk:M})]}),Q=i(x=>n?jsxRuntime.jsxs("div",{style:{...s.inset,display:"flex",flexDirection:"column",gap:c.space.sm+c.space.xs/2},children:[x?V(lr.viewFullRecord,()=>n({name:"record"}),"dashboard-full-record-action"):null,V(lr.viewTimeline,()=>n({name:"timeline"}),"dashboard-timeline-action")]}):null,"actions"),w;if(u.status==="error"){let x=Wr(u,R);w=x.kind==="error"||x.kind==="pet_not_found"?jsxRuntime.jsx(Fe,{variant:Xe(x.error),message:x.error.displayMessage,onAction:x.error.retryable?T:void 0,testID:"dashboard-error"}):vt(u,b,R);}else switch(k){case "loading":w=jsxRuntime.jsx(Yt,{testID:"dashboard-loading"});break;case "record":w=jsxRuntime.jsxs("div",{style:s.contentTight,"data-testid":"dashboard-record",children:[h?re:p.status==="error"?jsxRuntime.jsx("div",{style:s.inset,children:V(lr.retryMarkers,T,"dashboard-markers-retry")}):null,jsxRuntime.jsx("div",{style:s.inset,children:u.record?jsxRuntime.jsx(Mo,{record:u.record,depth:I,petName:r,showLabs:!h,onNavigate:n,onAsk:a}):null}),Q(true)]});break;case "error":{let x=p.error??u.error;w=jsxRuntime.jsx(Fe,{variant:Xe(x),message:x?.displayMessage,onAction:x?.retryable?T:void 0,testID:"dashboard-error"});break}case "in_progress":w=jsxRuntime.jsxs("div",{style:s.content,"data-testid":"dashboard-in-progress",children:[S?jsxRuntime.jsx(xg,{request:S,petName:F,onOpen:n?()=>n({name:"request",requestId:S.id}):void 0,onAsk:a?()=>{let x=Ud(r,{clinicName:S.clinicName??null,statusLabel:bn(S),status:S.status,heldItemCount:S.heldItemCount},S.id);a(x.prompt,x.entityRef);}:void 0}):null,jsxRuntime.jsx(bt,{disclaimer:_})]});break;case "none":w=jsxRuntime.jsxs("div",{style:s.content,"data-testid":"dashboard-request-prompt",children:[jsxRuntime.jsxs("section",{style:{borderRadius:c.radius.sm,backgroundColor:c.color.surfaceCream,border:`1px solid ${c.color.borderRingCream}`,padding:`${c.space.lg+c.space.xs/2}px ${c.space.lg+c.space.xs}px`,display:"flex",flexDirection:"column",gap:c.space.sm},children:[jsxRuntime.jsx("h3",{style:{...s.sectionTitle,fontSize:c.type.size.subtitle,color:c.color.brand},children:xt.title(r)}),jsxRuntime.jsx("p",{style:s.bodyText,children:xt.body}),n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(B,{label:xt.requestFromClinic,ariaLabel:xt.requestFromClinicA11y(r),onClick:()=>n({name:"clinicPicker"}),testID:"dashboard-request-prompt-clinic"}),jsxRuntime.jsx(B,{label:xt.uploadDocument,kind:"outline",ariaLabel:xt.uploadDocumentA11y(r),onClick:()=>n({name:"upload"}),testID:"dashboard-request-prompt-upload"})]}):null]}),jsxRuntime.jsx(bt,{disclaimer:_})]});break;case "labs_only":w=jsxRuntime.jsxs("div",{style:s.contentTight,"data-testid":"dashboard-labs-only",children:[re,jsxRuntime.jsx("div",{style:s.inset,children:jsxRuntime.jsx(bt,{disclaimer:_})}),Q(false)]});break;default:w=Dr(k);}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(He,{title:lr.title,onBack:l,testID:"dashboard-header",right:n?jsxRuntime.jsx("button",{type:"button",onClick:()=>n({name:"timeline"}),"aria-label":lr.openTimeline,style:s.iconButton,"data-testid":"dashboard-timeline-link",children:jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"flex",flexDirection:"column",gap:4},children:[0,1,2].map(x=>jsxRuntime.jsx("span",{style:{display:"block",width:18,height:2,borderRadius:2,backgroundColor:c.color.brand}},x))})}):void 0}),jsxRuntime.jsx("div",{style:s.body,children:w}),jsxRuntime.jsx(hc,{marker:y?.marker??null,point:y?.point??null,onClose:()=>g(null),onAsk:$})]})}i(Eg,"DashboardBody");function xg({request:e,petName:r,onOpen:t,onAsk:o}){let{theme:n,styles:l}=j(),a=e.clinicName?.trim()||$t.title(r),c=bn(e),s=jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:n.space.lg},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:n.space.sm},children:[jsxRuntime.jsx("span",{style:{...l.rowTitle,...O(n,"bold"),fontSize:n.type.size.subtitle},children:a}),t?jsxRuntime.jsx(kt,{}):null]}),jsxRuntime.jsx(rn,{request:e}),c.length>0?jsxRuntime.jsx("p",{style:l.statusCard,children:c}):null]});return jsxRuntime.jsxs("section",{"aria-label":t?void 0:$t.a11y(r),style:{...l.creamCard,backgroundColor:n.color.surface,padding:n.space.lg+n.space.xs/2,gap:n.space.lg},"data-testid":"dashboard-in-progress-card",children:[t?jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":$t.openA11y(r,c),style:{background:"transparent",border:0,padding:0,cursor:"pointer",textAlign:"left",font:"inherit",color:"inherit",width:"100%"},"data-testid":"dashboard-in-progress-open",children:s}):s,o?jsxRuntime.jsx(B,{label:$t.ask,kind:"ask",ariaLabel:$t.askA11y,onClick:o,testID:"dashboard-in-progress-ask"}):null]})}i(xg,"InProgressCard");function Ia(e){let{style:r,className:t,renderPending:o,...n}=_e(e,["onNavigate","onBack"]),{userRef:l}=ee(),{styles:a}=j();return jsxRuntime.jsx(Te,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Oe(n.onBack,Le),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...r},"data-testid":"records-requests-screen",children:[l===null?jsxRuntime.jsx("div",{style:a.body,children:jsxRuntime.jsx(Je,{label:G.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(kg,{...n}),jsxRuntime.jsx(De,{})]})})}i(Ia,"EverfurRecordsRequests");function kg({petRef:e,petName:r,controller:t,onNavigate:o,onBack:n,onOpenUrl:l}){let{theme:a,styles:c}=j(),s=We(t?{petRef:e,controller:t}:{petRef:e}),d=react.useMemo(()=>hi(s.requests.filter(y=>y.petRef===e)),[s.requests,e]),u=St("recordsClinic"),p=`${react.useId()}-requests-heading`,m;return s.status==="loading"&&d.length===0?m=jsxRuntime.jsx(yo,{testID:"records-requests-loading"}):s.status==="error"&&s.error&&d.length===0?m=jsxRuntime.jsx(Fe,{variant:Xe(s.error),message:s.error.displayMessage,onAction:s.error.retryable?s.refresh:void 0,testID:"records-requests-error"}):m=jsxRuntime.jsx(Bo,{requests:d,petName:r,level:3,headingId:p,onOpenRequest:o?y=>o({name:"request",requestId:y.id}):void 0,onUpload:o?()=>o({name:"upload"}):void 0,...l?{onOpenUrl:l}:{}}),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(He,{title:Se.title,onBack:n,testID:"records-requests-header"}),jsxRuntime.jsx("div",{style:c.body,children:jsxRuntime.jsxs("div",{style:{...c.content,gap:a.space.lg},children:[o?jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:a.space.sm},"data-testid":"records-requests-actions",children:[u.enabled||u.isPending?jsxRuntime.jsx(B,{label:Se.requestRecords,onClick:()=>o({name:"clinicPicker"}),testID:"records-requests-request-records"}):null,jsxRuntime.jsx(B,{label:Se.uploadAction,kind:"outline",onClick:()=>o({name:"upload"}),testID:"records-requests-upload"})]}):null,m]})})]})}i(kg,"RequestsBody");function Cc(e){let{petRef:r,petName:t,controller:o,clinicController:n,consentVersion:l,ownerName:a,onCaptureSignature:c,initialScreen:s,historyMode:d="memory",onExit:u,style:p,className:m,renderPending:y,onOpenUrl:g,onCopy:f,onAsk:R,location:b}=_e(e,["onExit"]),[E,h]=react.useReducer(gn,s,Ut),v=to(E),S=E.stack.length,C=react.useRef(S);C.current=S;let k=react.useRef(S),_=react.useRef(false);react.useEffect(()=>{if(d!=="browser"||typeof window>"u")return;let Q=i(w=>{let x=w.state;(typeof x?.efRecords=="number"?x.efRecords:1)<C.current&&(_.current=true,h({type:"pop"}));},"onPopState");return window.addEventListener("popstate",Q),()=>window.removeEventListener("popstate",Q)},[d]),react.useEffect(()=>{if(d!=="browser"||typeof window>"u")return;let Q=k.current;S>Q?window.history.pushState({efRecords:S},""):S<Q&&!_.current&&window.history.go(S-Q),_.current=false,k.current=S;},[d,S]);let T=react.useCallback(Q=>h({type:"navigate",screen:Q}),[]),I=react.useMemo(()=>no(E).handled?()=>h({type:"pop"}):u,[E,u]),F=jt(v),q={onNavigate:T,...I?{onBack:I}:{},...t!==void 0?{petName:t}:{},...g?{onOpenUrl:g}:{},...f?{onCopy:f}:{},...R?{onAsk:R}:{},...b?{location:b}:{}},M={...o?{controller:o}:{},...l!==void 0?{consentVersion:l}:{}},$={...p?{style:p}:{},...m!==void 0?{className:m}:{}},V=y?{renderPending:y}:{},re;switch(v.name){case "dashboard":re=jsxRuntime.jsx(Oa,{petRef:r,...q,...M,...V,...$});break;case "request":re=jsxRuntime.jsx($n,{petRef:r,requestId:v.requestId,...q,...o?{controller:o}:{},...V,...$});break;case "timeline":re=jsxRuntime.jsx(vo,{petRef:r,...q,...$});break;case "record":re=jsxRuntime.jsx(Fn,{petRef:r,...q,...M,...V,...$});break;case "document":re=jsxRuntime.jsx(Ln,{petRef:r,...q,...M,...V,...$});break;case "contributions":re=jsxRuntime.jsx(Co,{petRef:r,docId:v.docId,...q,...$});break;case "clinicPicker":re=jsxRuntime.jsx(En,{petRef:r,...q,...n?{controller:n}:{},...o?{recordsController:o}:{},...$});break;case "clinicBatch":re=jsxRuntime.jsx(wn,{petRef:r,petName:t??"",ownerName:a??"",...I?{onClose:I}:{},onCreated:()=>h({type:"navigate",screen:{name:"dashboard"}}),...c?{onCaptureSignature:c}:{},...n?{controller:n}:{},...$});break;case "consent":re=jsxRuntime.jsx(Tn,{petRef:r,clinic:v.clinic,...q,...a!==void 0?{ownerName:a}:{},...c?{onCaptureSignature:c}:{},...n?{controller:n}:{},...$});break;case "upload":re=jsxRuntime.jsx(Mn,{petRef:r,...q,...o?{controller:o}:{},...V,...$});break;case "requests":re=jsxRuntime.jsx(Ia,{petRef:r,...q,...o?{controller:o}:{},...V,...$});break;default:re=Dr(v);}return jsxRuntime.jsx("div",{ref:F,style:Og,"data-testid":"everfur-records-flow",children:re})}i(Cc,"EverfurRecordsFlow");var Og=Object.freeze({display:"contents"}),Ig=Cc;function Ag(e){let{userRef:r,scopeEpoch:t}=ee();return jsxRuntime.jsx(Te,{capability:"recordsClinic",...Oe(e.onClose,X.cancel),children:r===null?jsxRuntime.jsx("p",{role:"alert",children:G.sessionRequired}):jsxRuntime.jsx(qg,{..._e(e,["onClose","onCreated"])},JSON.stringify([r,t,e.petRef,e.petName]))})}i(Ag,"EverfurClinicRequest");function qg(e){let r=Ir(),t=e.controller??r,o=ce(),n={current:null},l=Ot(()=>n.current?.invalidate()),a=Pl(e,t,e.onCaptureSignature??(async u=>l.signed?l.register(t,u.signal):null));n.current=a;let c={minHeight:44,padding:o.space.sm,border:`1px solid ${o.color.borderHairlineGreen}`,borderRadius:o.radius.sm,background:o.color.surface,color:o.color.text.primary,font:"inherit"},s={...c,cursor:"pointer"},d=i(()=>{a.busy||l.clear();},"clear");return jsxRuntime.jsxs("section",{className:e.className,"aria-label":X.title,style:{background:o.color.surface,color:o.color.text.primary,padding:o.space.lg,borderRadius:o.radius.lg,minHeight:120,minWidth:0,overflowWrap:"anywhere",...e.style},children:[jsxRuntime.jsx("h2",{style:{margin:0,fontSize:o.type.size.heading},children:X.title}),jsxRuntime.jsx("p",{style:{margin:`${o.space.sm}px 0 ${o.space.lg}px`},children:e.petName}),a.created?jsxRuntime.jsx("p",{role:"status",children:a.created.statusLabel||G.records}):jsxRuntime.jsxs("div",{style:{display:"grid",gap:o.space.md},children:[jsxRuntime.jsxs("label",{children:[X.ownerName,jsxRuntime.jsx("input",{style:{...c,display:"block",width:"100%",boxSizing:"border-box"},maxLength:200,value:a.ownerName,disabled:a.busy,autoComplete:"name",onChange:u=>{d(),a.setOwnerName(u.target.value);}})]}),jsxRuntime.jsxs("label",{children:[X.clinic,jsxRuntime.jsx("input",{style:{...c,display:"block",width:"100%",boxSizing:"border-box"},placeholder:X.placeholder,maxLength:200,value:a.query,disabled:a.busy,autoComplete:"off",onChange:u=>{d(),a.setQuery(u.target.value);}})]}),jsxRuntime.jsx("button",{type:"button",style:s,disabled:a.busy||a.searching||a.query.trim().length<2,onClick:()=>{a.search();},children:X.search}),a.searching&&jsxRuntime.jsx("p",{role:"status",children:G.loading}),a.recent.length>0&&jsxRuntime.jsx("h3",{style:{margin:`${o.space.sm}px 0 0`,fontSize:o.type.size.subtitle},"data-testid":"records-clinic-recent-label",children:X.recentlyUsed}),a.recent.map(u=>jsxRuntime.jsxs("button",{type:"button",style:s,disabled:a.busy,onClick:()=>{d(),a.selectClinic(u);},children:[u.name,u.address?`, ${u.address}`:"",u.phone?`, ${u.phone}`:""]},`recent-${u.id}`)),a.clinics.map(u=>jsxRuntime.jsxs("button",{type:"button",style:s,disabled:a.busy,onClick:()=>{d(),a.selectClinic(u);},children:[u.name,u.address?`, ${u.address}`:"",u.phone?`, ${u.phone}`:""]},u.id)),a.needsEmail&&jsxRuntime.jsxs("label",{children:[X.email,jsxRuntime.jsx("input",{style:{...c,display:"block",width:"100%",boxSizing:"border-box"},type:"email",placeholder:X.emailPlaceholder,maxLength:320,autoComplete:"off",value:a.email,disabled:a.busy,onChange:u=>{d(),a.setEmail(u.target.value);}})]}),jsxRuntime.jsx("h3",{style:{margin:`${o.space.sm}px 0 0`,fontSize:o.type.size.subtitle},children:X.scopeHeading}),a.copy?jsxRuntime.jsx("p",{style:{whiteSpace:"pre-wrap",margin:0},children:a.query.trim()&&a.ownerName.trim()?a.scope??z("internalError").displayMessage:G.consentRequired}):!a.error&&jsxRuntime.jsx("p",{role:"status",children:G.loading}),!e.onCaptureSignature&&jsxRuntime.jsx(It,{pad:l,disabled:a.busy}),a.error&&jsxRuntime.jsx("p",{role:"alert",children:a.error.displayMessage}),!a.copy&&a.error&&jsxRuntime.jsx("button",{type:"button",style:s,onClick:a.retryCopy,children:G.retry}),jsxRuntime.jsx("button",{type:"button",style:{...s,background:o.color.primary,color:o.color.onPrimary,opacity:a.busy||!a.ready||!e.onCaptureSignature&&!l.signed?.5:1},disabled:a.busy||!a.ready||!e.onCaptureSignature&&!l.signed,onClick:()=>{a.submit();},children:a.busy?X.sending:X.send})]}),e.onClose&&jsxRuntime.jsx("button",{type:"button",style:s,disabled:a.busy,onClick:e.onClose,children:X.cancel}),jsxRuntime.jsx(De,{})]})}i(qg,"ClinicRequestBody");var Ng="file",Lg="document.pdf",Fg="records upload: the file handle carries no bytes",Ec="records upload failed";function zg(e={}){let r=e.xhr??(()=>new XMLHttpRequest);return Object.freeze({postMultipart(t,o,n){return new Promise((l,a)=>{let c=o.blob;if(c===void 0){a(new Error(Fg));return}let{signal:s,onProgress:d}=n;if(s?.aborted===true){a(new Error(Ec));return}let u=new FormData;for(let[f,R]of Object.entries(t.upload_fields))u.append(f,R);u.append(Ng,c,Lg);let p=r(),m=false,y=i(f=>{m||(m=true,s?.removeEventListener("abort",g),f?l():a(new Error(Ec)));},"settle"),g=i(()=>{p.abort(),y(false);},"onAbort");p.open("POST",t.upload_url,true),p.withCredentials=false,d&&(p.upload.onprogress=f=>{!f.lengthComputable||f.total<=0||d(Math.min(1,Math.max(0,f.loaded/f.total)));}),p.onload=()=>y(p.status>=200&&p.status<300),p.onerror=()=>y(false),p.onabort=()=>y(false),p.ontimeout=()=>y(false),s?.addEventListener("abort",g,{once:true}),p.send(u);})}})}i(zg,"createWebRecordsUploadTransport");
4
- exports.EverfurClinicPicker=En;exports.EverfurClinicRequest=Ag;exports.EverfurClinicRequestBatch=wn;exports.EverfurRecordDetail=Fn;exports.EverfurRecordDocument=Ln;exports.EverfurRecords=Ig;exports.EverfurRecordsConsent=Tn;exports.EverfurRecordsDashboard=Oa;exports.EverfurRecordsFlow=Cc;exports.EverfurRecordsPage=ag;exports.EverfurRecordsRequest=$n;exports.EverfurRecordsRequests=Ia;exports.EverfurRecordsUpload=Mn;exports.RECORDS_CLINIC_BATCH_MAX=Bt;exports.RECORDS_DOCUMENT_ACCEPT=_o;exports.RECORDS_TERMINAL=Ja;exports.REQUEST_TIMELINE_TITLES=qn;exports.RequestDocumentsList=zn;exports.SignatureCanvas=It;exports.applyFactOverlay=ca;exports.buildRequestTimeline=sa;exports.createWebRecordsUploadTransport=zg;exports.currentRecordsScreen=to;exports.deriveRecordsDashboardState=pi;exports.fileToHandle=Po;exports.initialRecordsNav=Ut;exports.isFactEditable=ua;exports.isPdfBlob=md;exports.isTerminalStatus=Mt;exports.isUploadableHandle=uf;exports.pickDocument=pf;exports.pickPetRecordsRequest=ro;exports.popRecordsNav=no;exports.pushRecordsNav=fi;exports.recordsDenialReasonOf=dt;exports.recordsNavReducer=gn;exports.replaceRecordsNav=yi;exports.requestDocumentRows=ha;exports.resetRecordsNav=gi;exports.selectClinicCall=io;exports.selectDashboardView=mi;exports.selectPrimaryLabel=bn;exports.selectRequestList=hi;exports.selectRequestTitle=oo;exports.transitionRecordsNav=Es;exports.useEverfurRecords=We;exports.useEverfurRecordsClinic=Ir;exports.useEverfurRecordsClinicBatch=Li;exports.useRecordFactEdit=pa;exports.useRecordPdfLink=na;exports.useRecordShares=ra;exports.useRecordsMarkers=Ji;exports.useRequestDocuments=Ca;exports.useSignatureCanvas=Ot;
3
+ `):null,Ne=y.length>0&&y.every(ie=>!dn(ie)||nf.test(ie.email.trim())),re=y.length>=en,oe=!!(f&&me&&s.trim()&&e.petName.trim()&&Ne&&o)&&k===null,Se=i(async()=>{if(B.current)return;let ie=++x.current;C(true);try{let ke=await r.searchClinics({query:c.trim(),limit:Fo});if(!N.current||ie!==x.current)return;ke.ok?(u(ke.value.clinics),R(null)):R(ke.error);}catch{N.current&&ie===x.current&&R(H("internalError"));}finally{N.current&&ie===x.current&&C(false);}},"search"),Pe=i(ie=>{B.current||re||k!==null||ie.clinic!==null&&y.some(ke=>ke.clinic?.id===ie.clinic?.id)||(A(),g(ke=>[...ke,{...ie,key:F.current(),idempotencyKey:F.current()}]),u([]),l(""));},"add"),Ge=i(async()=>{if(B.current||k!==null||!oe||!f||!me||!o)return;B.current=true;let ie=L.current,ke=i(()=>N.current&&L.current===ie,"current");E(true),R(null);try{if(W.current===null){I.current=new AbortController;let fr=await o({petRef:e.petRef,petName:e.petName,ownerName:s.trim(),clinicName:_.join(", "),authorizationVersion:f.authorizationVersion,scopeText:me,signal:I.current.signal});if(!ke()||fr===null)return;if(W.current=fr,fr.signaturePngBase64!==void 0&&n!==void 0){let lu=await n(fr.signaturePngBase64,I.current.signal);if(!ke())return;W.current={signatureId:lu.signatureId};}}let qr=W.current,Cn=y.map(fr=>({...fr.clinic!==null&&(!dn(fr)||fr.clinic.emailStatus==="none")?{clinicId:fr.clinic.id}:{clinicFreeText:cn(fr)},...dn(fr)?{clinicEmail:fr.email.trim().toLowerCase()}:{},...qr.signatureId!==void 0?{signatureId:qr.signatureId}:{signaturePngBase64:qr.signaturePngBase64},idempotencyKey:fr.idempotencyKey})),En=await t.createClinicRequestBatch({petRef:e.petRef,ownerName:s.trim(),authorizationVersion:f.authorizationVersion,clinics:Cn});if(!ke())return;if(!En.ok){R(En.error);return}M(En.value),e.onCreated?.(En.value),xe(En.value.requestGroupId,ie);}catch{ke()&&R(H("internalError"));}finally{B.current=false,ke()&&E(false);}},"submit"),xe=i(async(ie,ke)=>{try{let qr=await r.getRequestGroup(ie);if(!N.current||L.current!==ke)return;qr.ok&&qr.value.petRef===e.petRef&&O(qr.value);}catch{}},"loadGroup"),ur=i(async()=>{k===null||B.current||await xe(k.requestGroupId,L.current);},"refreshGroup");return {ownerName:s,query:c,clinics:d,copy:f,scopeText:me,error:b,busy:h,searching:S,drafts:y,outcome:k,group:T,ready:oe,atCap:re,visibleClinics:w.visible,hasMoreClinics:w.hasMore,showMoreClinics:w.showMore,recent:d.length===0?p.filter(ie=>!y.some(ke=>ke.clinic?.id===ie.id)):[],setOwnerName(ie){B.current||(A(),a(ie));},setQuery(ie){B.current||(x.current+=1,C(false),u([]),l(ie));},search:Se,addClinic(ie){Pe({clinic:ie,freeText:null,email:""});},addFreeText(){let ie=c.trim();ie.length!==0&&Pe({clinic:null,freeText:ie,email:""});},setDraftEmail(ie,ke){B.current||(A(),g(qr=>qr.map(Cn=>Cn.key===ie?{...Cn,email:ke}:Cn)));},removeDraft(ie){B.current||k!==null||(A(),g(ke=>ke.filter(qr=>qr.key!==ie)));},submit:Ge,refreshGroup:ur,retryCopy(){R(null),q(ie=>ie+1);}}}i(bd,"useClinicBatchForm");function hd(e){try{let r=new URL(e);if(r.protocol!=="https:"||r.username||r.password||r.port&&r.port!=="443")return !1;let t=r.hostname.toLowerCase();return t==="s3.amazonaws.com"||t.endsWith(".s3.amazonaws.com")||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3[.-][a-z0-9-]+\.amazonaws\.com$/.test(t)||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3\.dualstack\.[a-z0-9-]+\.amazonaws\.com$/.test(t)||t==="s3-accelerate.amazonaws.com"||t.endsWith(".s3-accelerate.amazonaws.com")||t==="s3-accelerate.dualstack.amazonaws.com"||t.endsWith(".s3-accelerate.dualstack.amazonaws.com")}catch{return false}}i(hd,"trustedSignatureUploadUrl");function Rd(e,r,t,o){e.clearRect(0,0,t,o);let n=r.trim();if(!n)return;let s=Math.max(1,t-32),a=Math.min(44,Math.max(16,Math.round(o*.34))),c=i(()=>{e.font=`italic 700 ${a}px Georgia, "Times New Roman", serif`;},"font");for(c();a>12&&e.measureText(n).width>s;)a-=2,c();e.textAlign="center",e.textBaseline="middle",e.fillText(n,t/2,o/2,s);}i(Rd,"paintClinicTypedSignature");function vd(e,r,t,o){e.clearRect(0,0,t,o);for(let n of r){let s=n[0];if(s!==void 0){e.beginPath(),e.moveTo(s[0],s[1]),n.length===1&&e.lineTo(s[0],s[1]);for(let a=1;a<n.length;a+=1){let c=n[a];c!==void 0&&e.lineTo(c[0],c[1]);}e.stroke();}}}i(vd,"paintSignatureStrokes");async function Cd(e,r,t,o=fetch){let n=i(()=>new Error("Signature upload failed"),"fail"),s=await new Promise(m=>e.toBlob(m,"image/png"));if(!s||!s.size||s.size>2*1024*1024||t.aborted)throw n();let a=await r.initiateSignatureUpload(s.size);if(!a.ok||t.aborted||!hd(a.value.uploadUrl))throw n();let c=new FormData;for(let[m,y]of Object.entries(a.value.uploadFields))c.append(m,y);c.append("file",s,"signature.png");let l=new AbortController,d=i(()=>l.abort(),"onAbort");t.addEventListener("abort",d,{once:true});let u=setTimeout(d,9e4);try{if(!(await o(a.value.uploadUrl,{method:"POST",body:c,credentials:"omit",redirect:"error",referrerPolicy:"no-referrer",signal:l.signal})).ok||t.aborted)throw n()}catch{throw n()}finally{clearTimeout(u),t.removeEventListener("abort",d);}let p=await r.completeSignatureUpload(a.value.uploadId);if(!p.ok||t.aborted)throw n();return {signatureId:p.value}}i(Cd,"registerClinicSignature");var af=8,sf=480,lf=160;function Mt(e){let r=react.useRef(null),t=react.useRef(false),o=react.useRef([]),[n,s]=react.useState("draw"),[a,c]=react.useState(""),[l,d]=react.useState(false),u=react.useRef(a);u.current=a;let p=react.useCallback(()=>{let f=r.current,v=f?.getContext("2d");if(!f||!v)return;let b=typeof window<"u"&&window.devicePixelRatio||1;v.setTransform(b,0,0,b,0,0);let R=f.width/b,h=f.height/b;if(u.current.trim().length>0){v.fillStyle="#111",Rd(v,u.current,R,h);return}v.lineWidth=2,v.lineCap="round",v.lineJoin="round",v.strokeStyle="#111",vd(v,o.current,R,h);},[]);react.useEffect(()=>{let f=r.current;if(!f)return;let v=i(()=>{let R=f.getBoundingClientRect(),h=typeof window<"u"&&window.devicePixelRatio||1,E=Math.max(1,Math.round((R.width||f.clientWidth||sf)*h)),S=Math.max(1,Math.round((R.height||f.clientHeight||lf)*h));f.width!==E&&(f.width=E),f.height!==S&&(f.height=S),p();},"resize");if(v(),typeof ResizeObserver>"u")return;let b=new ResizeObserver(v);return b.observe(f),()=>b.disconnect()},[p]);let m=react.useCallback(()=>{e?.(),o.current=[],d(false),c(""),u.current="",p();},[e,p]),y=i(f=>{let v=f.currentTarget.getBoundingClientRect();return [f.clientX-v.left,f.clientY-v.top]},"point"),g=i(()=>o.current.reduce((f,v)=>f+v.length,0),"countPoints");return {canvas:r,mode:n,typed:a,signed:l,clear:m,setTyped(f){e?.(),c(f),u.current=f,d(!!f.trim()),p();},toggle(){m(),s(f=>f==="draw"?"type":"draw");},onPointerDown(f){n==="draw"&&(e?.(),t.current=true,f.currentTarget.setPointerCapture(f.pointerId),o.current=[...o.current,[y(f)]],p());},onPointerMove(f){if(!t.current||n!=="draw")return;let v=o.current[o.current.length-1];v!==void 0&&(o.current=[...o.current.slice(0,-1),[...v,y(f)]],p(),d(g()>=af));},onPointerUp(){t.current=false;},register(f,v){return !r.current||!l?Promise.reject(new Error("Signature upload failed")):Cd(r.current,f,v)}}}i(Mt,"useSignatureCanvas");function $t({pad:e,disabled:r}){let t=ye(),o=e.mode==="type"?e.typed.trim():"",n={minHeight:44,padding:t.space.sm,border:`1px solid ${t.color.borderHairlineGreen}`,borderRadius:t.radius.sm,background:t.color.surface,color:t.color.text.primary,font:"inherit"},s={...n,cursor:"pointer"};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{style:{margin:`0 0 ${t.space.sm}px`},children:e.mode==="draw"?te.draw:te.type}),jsxRuntime.jsx("button",{type:"button",style:{...s,alignSelf:"flex-start",marginBottom:t.space.sm,textDecoration:"underline"},disabled:r,onClick:e.toggle,"data-testid":"records-consent-sign-mode-toggle",children:e.mode==="draw"?te.toType:te.toDraw}),e.mode==="type"&&jsxRuntime.jsx("input",{"aria-label":te.type,style:{...n,display:"block",width:"100%",boxSizing:"border-box"},maxLength:xl,value:e.typed,disabled:r,autoComplete:"off",onChange:a=>e.setTyped(a.target.value)}),jsxRuntime.jsx("canvas",{ref:e.canvas,role:"img","aria-label":o.length>0?te.typedSignatureA11y(o):te.sign,style:{display:"block",width:"100%",height:160,maxWidth:"100%",boxSizing:"border-box",touchAction:"none",background:"#fff",border:`1px solid ${t.color.borderHairlineGreen}`,...r?{opacity:.6,pointerEvents:"none"}:{},...e.mode==="type"?{pointerEvents:"none"}:{}},onPointerDown:a=>{r||e.onPointerDown(a);},onPointerMove:a=>{r||e.onPointerMove(a);},onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerUp}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:t.space.sm,marginTop:t.space.sm},children:[jsxRuntime.jsx("p",{style:{margin:0,fontSize:t.type.size.tiny,color:t.color.text.muted},"data-testid":"records-signature-hint",children:e.signed||e.mode==="type"?"\xA0":te.drawHint}),e.mode==="type"?null:jsxRuntime.jsx("button",{type:"button",style:s,disabled:r,onClick:e.clear,"aria-label":te.clearA11y,"data-testid":"records-signature-clear",children:te.clear})]})]})}i($t,"SignatureCanvas");function $n(e){let{userRef:r,scopeEpoch:t}=se();return jsxRuntime.jsx(Oe,{capability:"recordsClinic",...Fe(e.onClose,te.cancel),children:r===null?jsxRuntime.jsx("p",{role:"alert",children:X.sessionRequired}):jsxRuntime.jsx(df,{...Ie(e,["onClose","onCreated"])},JSON.stringify([r,t,e.petRef,e.petName]))})}i($n,"EverfurClinicRequestBatch");function df(e){let r=zr(),t=ra(),o=e.controller??r,n=ye(),s=Mt(),a=bd(e,o,e.batchClient??t,e.onCaptureSignature??(async f=>s.signed?s.register(o,f.signal):null)),c=e.onCaptureSignature!==void 0||s.signed,l={minHeight:44,padding:n.space.sm,border:`1px solid ${n.color.borderHairlineGreen}`,borderRadius:n.radius.sm,background:n.color.surface,color:n.color.text.primary,font:"inherit"},d={...l,display:"block",width:"100%",boxSizing:"border-box"},u={...l,cursor:"pointer"},p={margin:0,color:n.color.text.muted,fontSize:n.type.size.bodyTight},m=i(f=>[f.name,f.address,f.phone].filter(Boolean).join(", "),"clinicLabel"),y=a.busy?je.sending:a.drafts.length===0?je.addToContinue:a.error?je.tryAgain:je.send(a.drafts.length),g=a.outcome?je.resultTitle:je.title;return jsxRuntime.jsxs("section",{className:e.className,"aria-label":g,style:{...Rt,background:n.color.surface,color:n.color.text.primary,padding:n.space.lg,borderRadius:n.radius.lg,minHeight:120,minWidth:0,overflowWrap:"anywhere",...e.style},children:[jsxRuntime.jsx("h2",{style:{margin:0,fontSize:n.type.size.heading},children:g}),jsxRuntime.jsx("p",{style:{margin:`${n.space.sm}px 0 ${n.space.lg}px`},children:e.petName}),a.outcome?jsxRuntime.jsxs("div",{style:{display:"grid",gap:n.space.sm},"data-testid":"records-batch-result",children:[jsxRuntime.jsx("p",{role:"status",style:{margin:0},children:a.outcome.createdCount===0?je.allFailed:a.outcome.failedCount>0?je.partial(a.outcome.createdCount,a.outcome.results.length,a.outcome.failedCount):je.allSent(a.outcome.createdCount)}),jsxRuntime.jsx("h3",{style:{margin:0,fontSize:n.type.size.subtitle},children:je.perClinic}),jsxRuntime.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:n.space.sm},children:a.outcome.results.map((f,v)=>{let b=f.request?.clinicName??a.drafts[v]?.clinic?.name??f.clinicFreeText??"";return jsxRuntime.jsxs("li",{"data-testid":`records-batch-row-${f.created?"created":"failed"}`,children:[jsxRuntime.jsx("span",{children:b})," ",jsxRuntime.jsx("span",{style:p,children:f.created?je.sent:je.notSent}),f.created&&f.request?.statusLabel?jsxRuntime.jsx("p",{style:p,children:f.request.statusLabel}):null,!f.created&&f.failureReason?jsxRuntime.jsx("p",{style:p,children:f.failureReason}):null]},f.idempotencyKey)})}),a.group?jsxRuntime.jsx("p",{"aria-live":"polite",style:{margin:0},children:je.responded(a.group.responded,a.group.total)}):null,a.group?.members.map(f=>f.statusLabel?jsxRuntime.jsx("p",{style:p,children:[f.clinicName,f.statusLabel].filter(Boolean).join(": ")},f.id):null)]}):jsxRuntime.jsxs("div",{style:{display:"grid",gap:n.space.md},children:[jsxRuntime.jsxs("label",{children:[te.ownerName,jsxRuntime.jsx("input",{style:d,maxLength:200,value:a.ownerName,disabled:a.busy,autoComplete:"name",onChange:f=>{s.clear(),a.setOwnerName(f.target.value);}})]}),a.drafts.length>0&&jsxRuntime.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:n.space.sm},children:a.drafts.map(f=>jsxRuntime.jsxs("li",{"data-testid":`records-batch-draft-${f.key}`,style:{display:"grid",gap:n.space.xs},children:[jsxRuntime.jsx("span",{children:cn(f)}),dn(f)?jsxRuntime.jsxs("label",{children:[te.email,jsxRuntime.jsx("input",{style:d,type:"email",placeholder:te.emailPlaceholder,maxLength:320,autoComplete:"off",value:f.email,disabled:a.busy,onChange:v=>{s.clear(),a.setDraftEmail(f.key,v.target.value);}})]}):null,dn(f)&&!f.email.trim()?jsxRuntime.jsx("p",{style:p,children:je.emailToAdd}):null,jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,"aria-label":je.remove(cn(f)),onClick:()=>{s.clear(),a.removeDraft(f.key);},children:je.remove(cn(f))})]},f.key))}),jsxRuntime.jsx("p",{style:{margin:0},children:a.atCap?je.atCap:je.addClinic}),!a.atCap&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("label",{children:[te.clinic,jsxRuntime.jsx("input",{style:d,placeholder:te.placeholder,maxLength:200,value:a.query,disabled:a.busy,autoComplete:"off",onChange:f=>a.setQuery(f.target.value)})]}),jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy||a.searching||a.query.trim().length<2,onClick:()=>{a.search();},children:te.search}),a.query.trim().length>0&&a.clinics.length===0&&!a.searching&&jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,onClick:()=>{s.clear(),a.addFreeText();},children:je.addClinic}),a.searching&&jsxRuntime.jsx("p",{role:"status",children:X.loading}),a.recent.length>0&&jsxRuntime.jsx("h3",{style:{margin:0,fontSize:n.type.size.subtitle},children:te.recentlyUsed}),a.recent.map(f=>jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,onClick:()=>{s.clear(),a.addClinic(f);},children:m(f)},`recent-${f.id}`)),a.visibleClinics.map(f=>jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,onClick:()=>{s.clear(),a.addClinic(f);},children:m(f)},f.id)),a.hasMoreClinics&&jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,onClick:a.showMoreClinics,"data-testid":"records-clinic-results-more",children:te.moreClinics})]}),jsxRuntime.jsx("h3",{style:{margin:`${n.space.sm}px 0 0`,fontSize:n.type.size.subtitle},children:te.scopeHeading}),a.copy?jsxRuntime.jsx("p",{style:{whiteSpace:"pre-wrap",margin:0},children:a.drafts.length>0&&a.ownerName.trim()?a.scopeText??H("internalError").displayMessage:X.consentRequired}):!a.error&&jsxRuntime.jsx("p",{role:"status",children:X.loading}),!e.onCaptureSignature&&jsxRuntime.jsx($t,{pad:s,disabled:a.busy}),!c&&a.ready&&jsxRuntime.jsx("p",{role:"alert","data-testid":"records-batch-missing-signature",children:te.missingSignature}),a.error&&jsxRuntime.jsx("p",{role:"alert",children:a.error.displayMessage}),!a.copy&&a.error&&jsxRuntime.jsx("button",{type:"button",style:u,onClick:a.retryCopy,children:X.retry}),jsxRuntime.jsx("button",{type:"button","aria-label":je.sendA11y(a.drafts.length),style:{...u,background:n.color.primary,color:n.color.onPrimary,opacity:a.busy||!a.ready||!c?.5:1},disabled:a.busy||!a.ready||!c,onClick:()=>{a.submit();},children:y})]}),e.onClose&&jsxRuntime.jsx("button",{type:"button",style:u,disabled:a.busy,onClick:e.onClose,children:te.cancel}),jsxRuntime.jsx(Ae,{})]})}i(df,"BatchBody");var be=Object.freeze({scopeHeading:"What we ask for",scopeBody:"You\u2019re asking your pet\u2019s clinic to release their medical records to Everfur, on your behalf, so we can organize them for you.",whatWeDo: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:i(e=>`I\u2019m ${Re(e)}\u2019s owner. I authorize Everfur to request these records on my behalf.`,"authorizeLabel"),missingSignatureError:"Please add your signature before submitting.",missingDraftError:"Something went wrong with your selection. Please go back and pick the clinic again.",newClinicDirectSendNote:"We\u2019ll email this clinic directly to request your pet\u2019s medical records. Clinics usually reply within a week.",titleFreeText:"Check and send",titleDirectory:"Check and send",leadWeb:i(e=>`The clinic gets a secure request, with your permission to release ${Re(e)}\u2019s records to Everfur.`,"leadWeb"),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:i((e,r)=>`We don\u2019t have an email on file for ${r}. Add it so we can request ${Re(e)}\u2019s records.`,"noEmailNote"),emailLabel:"Clinic email for records",emailPlaceholder:"records@clinic.com",emailRequired:"Add the clinic\u2019s records email to send the request.",emailInvalid:"That email doesn\u2019t look right. Check it and try again.",reuseSignature:"Reuse a previous signature",reuseHint:"\u2026or 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\u2019t draw? Type your name instead",toTypeA11y:"Can\u2019t draw? Type your name to sign instead",toDraw:"Draw your signature instead",signatureHint:i(e=>`Your signature is added to the authorization sent to ${e}.`,"signatureHint"),submit:"Send request",submitting:"Sending\u2026",submitA11y:"Send request"});var uf="value_text",xd=64,wd=512;function kd(e){return e!==null&&e.httpStatus===409&&!Yr(e)}i(kd,"isFactReviewerLocked");var Un=Object.freeze({num:"value_num",date:"value_date",bool:"value_bool",text:uf}),_d=/^[+-]?(?:\d+\.?\d*|\.\d+)$/,Pd=/^\d{4}-\d{2}-\d{2}$/;function Td(e){if(e==null)return "text";let r=e.trim();return _d.test(r)?"num":Pd.test(r)&&!Number.isNaN(Date.parse(r))?"date":r==="true"||r==="false"?"bool":"text"}i(Td,"inferFactValueKind");function fa(e,r){let t=r.trim(),o=Td(e);if(o==="num"&&_d.test(t)){let n=Number(t);if(Number.isFinite(n))return Object.freeze({[Un.num]:n})}return o==="date"&&Pd.test(t)&&!Number.isNaN(Date.parse(t))?Object.freeze({[Un.date]:t}):Object.freeze(o==="bool"&&(t==="true"||t==="false")?{[Un.bool]:t==="true"}:{[Un.text]:t})}i(fa,"factCorrectionFor");var qe=zod.z.string().nullish(),Lo=zod.z.number().nullish(),pf=zod.z.object({collected_at:qe,at:qe,value:Lo,unit:qe,qualitative_result:qe,ref_low:Lo,ref_high:Lo,status:qe,source_clinic:qe,source_doc_id:qe,doc_id:qe,reviewed:zod.z.boolean().nullish()}),mf=zod.z.object({collected_at:qe,at:qe,value:Lo,unit:qe,qualitative_result:qe,status:qe}),ff=zod.z.object({marker_id:zod.z.string().min(1),canonical_name:qe,name:qe,loinc_code:qe,canonical_unit:qe,unit:qe,panel_name:qe,panel:qe,meaning_text:qe,meaning:qe,latest:mf.nullish(),trajectory:qe,points:zod.z.array(pf).optional()}),yf=zod.z.object({total_markers:zod.z.number().int().nonnegative(),in_range_count:zod.z.number().int().nonnegative(),out_of_range_count:zod.z.number().int().nonnegative(),unknown_count:zod.z.number().int().nonnegative()}),gf=zod.z.object({markers:zod.z.array(ff).optional(),summary:yf.nullish(),disclaimer:zod.z.string().optional(),featured_marker_id:qe});function bf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(bf,"isObject");function Dd(e){return Object.freeze({petRef:e,withheld:true,markers:Object.freeze([]),summary:null,disclaimer:"",featuredMarkerId:null})}i(Dd,"withheldMarkers");function Id(e,r){let t=bf(r)?r:{},o=typeof t.pet_ref=="string"&&t.pet_ref.length>0?t.pet_ref:e;if(t.withheld===true)return Dd(o);let n=gf.safeParse(t);if(!n.success)return Dd(o);let s=n.data,a=i(l=>Object.freeze({at:l.collected_at??l.at??null,value:l.value??null,unit:l.unit??null,qualitativeResult:l.qualitative_result??null,refLow:l.ref_low??null,refHigh:l.ref_high??null,status:l.status??null,sourceClinic:l.source_clinic??null,docId:l.source_doc_id??l.doc_id??null,reviewed:l.reviewed===true}),"point"),c=(s.markers??[]).map(l=>Object.freeze({markerId:l.marker_id,name:l.canonical_name??l.name??l.marker_id,loincCode:l.loinc_code??null,unit:l.canonical_unit??l.unit??null,panel:l.panel_name??l.panel??null,meaning:l.meaning_text??l.meaning??null,latest:l.latest?Object.freeze({at:l.latest.collected_at??l.latest.at??null,value:l.latest.value??null,unit:l.latest.unit??null,qualitativeResult:l.latest.qualitative_result??null,status:l.latest.status??null}):null,trajectory:l.trajectory??null,points:Object.freeze((l.points??[]).map(a))}));return Object.freeze({petRef:o,withheld:false,markers:Object.freeze(c),summary:s.summary?Object.freeze({totalMarkers:s.summary.total_markers,inRangeCount:s.summary.in_range_count,outOfRangeCount:s.summary.out_of_range_count,unknownCount:s.summary.unknown_count}):null,disclaimer:s.disclaimer??"",featuredMarkerId:s.featured_marker_id??null})}i(Id,"mapRecordMarkers");var hf=zod.z.string().min(1).refine(e=>e.startsWith("https://")),Rf=zod.z.object({source_doc_id:zod.z.string().min(1),file_name:zod.z.string().nullish(),doc_format:zod.z.string().nullish(),byte_size:zod.z.number().int().nonnegative().nullish(),received_at:zod.z.string().nullish(),download_url:hf,expires_in_seconds:zod.z.number().int().nonnegative().nullish()}),vf=zod.z.object({items:zod.z.array(zod.z.unknown()).optional()});function Od(e){let r=vf.safeParse(e);if(!r.success)return null;let t=[];for(let o of r.data.items??[]){let n=Rf.safeParse(o);n.success&&t.push(Object.freeze({sourceDocId:n.data.source_doc_id,fileName:n.data.file_name??null,docFormat:n.data.doc_format??null,byteSize:n.data.byte_size??null,receivedAt:n.data.received_at??null,downloadUrl:n.data.download_url,expiresInSeconds:n.data.expires_in_seconds??0}));}return Object.freeze(t)}i(Od,"mapRequestDocuments");var Cf=zod.z.object({signatures:zod.z.array(zod.z.object({signature_id:zod.z.string().min(1),preview_url:zod.z.string().min(1).refine(e=>e.startsWith("https://")),created_at:zod.z.string().nullish()})).optional()});function Ad(e){let r=Cf.safeParse(e);return r.success?Object.freeze((r.data.signatures??[]).map(t=>Object.freeze({signatureId:t.signature_id,previewUrl:t.preview_url,createdAt:t.created_at??null}))):null}i(Ad,"mapSignatureSuggestions");var G=zod.z.string().nullish(),Bn=zod.z.number().nullish(),Ef=zod.z.object({at:G,value:Bn,unit:G,qualitative_result:G,ref_low:Bn,ref_high:Bn,status:G,doc_id:G}),Sf=zod.z.object({marker_id:zod.z.string(),name:zod.z.string(),loinc_code:G,unit:G,panel:G,meaning:G,latest:zod.z.object({at:G,value:Bn,unit:G,qualitative_result:G,status:G}).nullish(),trajectory:G,points:zod.z.array(Ef).optional()}),xf=zod.z.object({encounter_id:zod.z.string(),date:G,type:G,clinic_name:G,veterinarian:G,doc_id:G}),wf=zod.z.object({note_id:zod.z.string(),encounter_id:G,observed_on:G,sections:zod.z.array(zod.z.object({section:zod.z.string(),text:zod.z.string()})).optional()}),kf=zod.z.object({exam_id:zod.z.string(),encounter_id:G,observed_on:G,doc_id:G,systems:zod.z.record(zod.z.object({finding_status:G,finding:G})).optional()}),_f=zod.z.object({has_lab_history:zod.z.boolean().optional(),has_vaccination_history:zod.z.boolean().optional(),has_weight_history:zod.z.boolean().optional(),has_vitals_history:zod.z.boolean().optional(),has_physical_exam_history:zod.z.boolean().optional(),has_procedure_history:zod.z.boolean().optional(),has_genetic_history:zod.z.boolean().optional(),has_reproductive_history:zod.z.boolean().optional(),has_parasite_prevention_history:zod.z.boolean().optional(),earliest_record_at:G,latest_record_at:G,documents_ingested:zod.z.number().int().nonnegative().optional(),documents_in_review:zod.z.number().int().nonnegative().optional(),entities_pending_review:zod.z.record(zod.z.number().int().nonnegative()).optional(),held_total:zod.z.number().int().nonnegative().optional()}),Pf=zod.z.object({conflict_id:zod.z.string(),entity_type:zod.z.string(),field:G,severity:G,candidates:zod.z.array(zod.z.object({value:zod.z.string(),source_doc_id:G,doc_id:G,collected_at:G})).optional()}),Tf=zod.z.object({lab_results:zod.z.array(Sf).optional(),encounters:zod.z.array(xf).optional(),clinician_notes:zod.z.array(wf).optional(),physical_exams:zod.z.array(kf).optional(),completeness:_f.nullish(),conflicts:zod.z.array(Pf).optional()}),Df=zod.z.object({visits:zod.z.array(zod.z.object({visit_id:zod.z.string(),visit_date:G,veterinarian:G,summary:G,doc_id:G})),vaccines:zod.z.array(zod.z.object({vaccine_id:zod.z.string(),product:G,lot:G,administered_on:G,expires_on:G,doc_id:G})),weights:zod.z.array(zod.z.object({weight_id:zod.z.string(),observed_on:G,weight_kg:Bn,doc_id:G})),medications:zod.z.array(zod.z.object({medication_id:zod.z.string(),drug_name:G,dose:G,route:G,frequency:G,sig:G,rx_number:G,started_on:G,stopped_on:G,doc_id:G})),disclaimer:zod.z.string().optional()}),If=zod.z.object({document:Ri,contributions:zod.z.array(hi),contribution_count:zod.z.number().int().nonnegative().optional()});function ga(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(ga,"isObject");function ba(e,r){return typeof e.pet_ref=="string"&&e.pet_ref.length>0?e.pet_ref:r}i(ba,"petOf");function ya(e,r){return Object.freeze({petRef:e,available:false,withheld:r,labResults:Object.freeze([]),encounters:Object.freeze([]),clinicianNotes:Object.freeze([]),physicalExams:Object.freeze([]),completeness:null,conflicts:Object.freeze([])})}i(ya,"emptyDepth");function Of(e,r){let t=ga(r)?r:{},o=ba(t,e);if(t.withheld===true)return ya(o,true);if(!["lab_results","encounters","clinician_notes","physical_exams","completeness","conflicts"].some(l=>l in t))return ya(o,false);let s=Tf.safeParse(t);if(!s.success)return ya(o,true);let a=s.data,c=i(l=>Object.freeze({at:l.at??null,value:l.value??null,unit:l.unit??null,qualitativeResult:l.qualitative_result??null,refLow:l.ref_low??null,refHigh:l.ref_high??null,status:l.status??null,docId:l.doc_id??null}),"point");return Object.freeze({petRef:o,available:true,withheld:false,labResults:Object.freeze((a.lab_results??[]).map(l=>Object.freeze({markerId:l.marker_id,name:l.name,loincCode:l.loinc_code??null,unit:l.unit??null,panel:l.panel??null,meaning:l.meaning??null,latest:Object.freeze({at:l.latest?.at??null,value:l.latest?.value??null,unit:l.latest?.unit??null,qualitativeResult:l.latest?.qualitative_result??null,status:l.latest?.status??null}),trajectory:l.trajectory??null,points:Object.freeze((l.points??[]).map(c))}))),encounters:Object.freeze((a.encounters??[]).map(l=>Object.freeze({encounterId:l.encounter_id,date:l.date??null,type:l.type??null,clinicName:l.clinic_name??null,veterinarian:l.veterinarian??null,docId:l.doc_id??null}))),clinicianNotes:Object.freeze((a.clinician_notes??[]).map(l=>Object.freeze({noteId:l.note_id,encounterId:l.encounter_id??null,observedOn:l.observed_on??null,sections:Object.freeze((l.sections??[]).map(d=>Object.freeze({section:d.section,text:d.text})))}))),physicalExams:Object.freeze((a.physical_exams??[]).map(l=>Object.freeze({examId:l.exam_id,encounterId:l.encounter_id??null,observedOn:l.observed_on??null,docId:l.doc_id??null,systems:Object.freeze(Object.entries(l.systems??{}).map(([d,u])=>Object.freeze({system:d,findingStatus:u.finding_status??null,finding:u.finding??null})))}))),completeness:a.completeness?Object.freeze({hasLabHistory:a.completeness.has_lab_history===true,hasVaccinationHistory:a.completeness.has_vaccination_history===true,hasWeightHistory:a.completeness.has_weight_history===true,hasVitalsHistory:a.completeness.has_vitals_history===true,hasPhysicalExamHistory:a.completeness.has_physical_exam_history===true,hasProcedureHistory:a.completeness.has_procedure_history===true,hasGeneticHistory:a.completeness.has_genetic_history===true,hasReproductiveHistory:a.completeness.has_reproductive_history===true,hasParasitePreventionHistory:a.completeness.has_parasite_prevention_history===true,earliestRecordAt:a.completeness.earliest_record_at??null,latestRecordAt:a.completeness.latest_record_at??null,documentsIngested:a.completeness.documents_ingested??0,documentsInReview:a.completeness.documents_in_review??0,entitiesPendingReview:Object.freeze({...a.completeness.entities_pending_review??{}}),heldTotal:a.completeness.held_total??0}):null,conflicts:Object.freeze((a.conflicts??[]).map(l=>Object.freeze({conflictId:l.conflict_id,entityType:l.entity_type,field:l.field??null,severity:l.severity??"needs_review",candidates:Object.freeze((l.candidates??[]).map(d=>Object.freeze({value:d.value,docId:d.source_doc_id??d.doc_id??null,collectedAt:d.collected_at??null})))})))})}i(Of,"mapRecordDepth");function Fd(e){return Object.freeze({petRef:e,withheld:true,isEmpty:false,visits:Object.freeze([]),vaccines:Object.freeze([]),weights:Object.freeze([]),medications:Object.freeze([]),disclaimer:""})}i(Fd,"withheldTimeline");function Af(e,r){let t=ga(r)?r:{},o=ba(t,e);if(t.withheld===true)return Fd(o);let n=Df.safeParse(t);if(!n.success)return Fd(o);let s=n.data,a=s.visits.map(u=>Object.freeze({visitId:u.visit_id,visitDate:u.visit_date??null,veterinarian:u.veterinarian??null,summary:u.summary??null,docId:u.doc_id??null})),c=s.vaccines.map(u=>Object.freeze({vaccineId:u.vaccine_id,product:u.product??null,lot:u.lot??null,administeredOn:u.administered_on??null,expiresOn:u.expires_on??null,docId:u.doc_id??null})),l=s.weights.map(u=>Object.freeze({weightId:u.weight_id,observedOn:u.observed_on??null,weightKg:u.weight_kg??null,docId:u.doc_id??null})),d=s.medications.map(u=>Object.freeze({medicationId:u.medication_id,drugName:u.drug_name??null,dose:u.dose??null,route:u.route??null,frequency:u.frequency??null,sig:u.sig??null,rxNumber:u.rx_number??null,startedOn:u.started_on??null,stoppedOn:u.stopped_on??null,docId:u.doc_id??null}));return Object.freeze({petRef:o,withheld:false,isEmpty:a.length===0&&c.length===0&&l.length===0&&d.length===0,visits:Object.freeze(a),vaccines:Object.freeze(c),weights:Object.freeze(l),medications:Object.freeze(d),disclaimer:s.disclaimer??""})}i(Af,"mapRecordsTimeline");function Ff(e,r){let t=ga(r)?r:{},o=ba(t,e),n=i(()=>Object.freeze({petRef:o,withheld:true,document:null,contributions:Object.freeze([]),contributionCount:0}),"withheld");if(t.withheld===true)return n();let s=If.safeParse(t);if(!s.success)return n();let a=Object.freeze(s.data.contributions.map(vi));return Object.freeze({petRef:o,withheld:false,document:Ci(s.data.document),contributions:a,contributionCount:s.data.contribution_count??a.length})}i(Ff,"mapDocumentContributions");var qf="/widget/v1/records/pets";function qd(e){let r=e.funnel??ht({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),t=i((l,d)=>typeof l=="string"&&l.length>0&&!at(l)&&[...l].length<=d,"segment"),o=i(async(l,d,u,p)=>{if(!t(d,lr))return Br();let m=await r.send(l,{method:"GET",path:u});if(!m.ok)return m;let y=p(m.value);return y.petRef===d?Te(y):J(H("internalError",{retryable:false}))},"read"),n=i(l=>`${qf}/${encodeURIComponent(l)}`,"pet"),s=i(l=>`${n(l)}/everfur_record`,"record"),a=i(async(l,d,u)=>{let p=await r.send(l,d,d.method==="POST"?{idempotent:false,maxAttempts:1}:void 0);if(!p.ok)return p;let m=u(p.value);return m===null?J(H("internalError",{retryable:false})):Te(m)},"parsed"),c=i((l,d)=>!t(l.entityType,xd)||!t(l.canonicalKey,wd)||l.idempotencyKey!==void 0&&!t(l.idempotencyKey,wn)||d!==void 0&&Object.keys(d).length===0?null:{entity_type:l.entityType,canonical_key:l.canonicalKey,...d!==void 0?{corrected_fields:d}:{},...l.idempotencyKey!==void 0?{idempotency_key:l.idempotencyKey}:{}},"factBody");return {getRecordDepth:i(l=>o("records.depth.record",l,`${n(l)}/record`,d=>Of(l,d)),"getRecordDepth"),getTimeline:i(l=>o("records.depth.timeline",l,`${n(l)}/timeline`,d=>Af(l,d)),"getTimeline"),getDocumentContributions(l,d){return t(d,64)?o("records.depth.contributions",l,`${n(l)}/documents/${encodeURIComponent(d)}/contributions`,u=>Ff(l,u)):Br()},getMarkers:i(l=>o("records.depth.markers",l,`${n(l)}/markers`,d=>Id(l,d)),"getMarkers"),createShare(l,d){if(!t(l,lr))return Br();let u=d?.audience;return u!==void 0&&!Kt.includes(u)?Br():a("records.share.create",{method:"POST",path:`${s(l)}/share`,...u!==void 0?{body:{audience:u}}:{}},p=>ys(p,e.apiBaseUrl))},emailShare(l,d){let u=d.recipientKind,p=typeof d.recipientEmail=="string"?d.recipientEmail.trim():"",m=u==="other"||Kt.includes(u);return !t(l,lr)||!m||!ao(p)||at(p)?Br():a("records.share.email",{method:"POST",path:`${s(l)}/share/email`,body:{recipient_email:p,recipient_kind:u}},bs)},async readFeatures(){try{let l=await r.send("records.getFeatures",{method:"GET",path:"/widget/v1/records/features"});return l.ok?so(l.value):kr}catch{return kr}},listShares(l){return t(l,lr)?a("records.share.list",{method:"GET",path:`${s(l)}/shares`},gs):Br()},async revokeShare(l,d){if(!t(l,lr)||!t(d,64))return Br();let u=await r.send("records.share.revoke",{method:"DELETE",path:`${s(l)}/shares/${encodeURIComponent(d)}`},{idempotent:false,maxAttempts:1});return u.ok?Te(void 0):u},getPdfLink(l){return t(l,lr)?a("records.pdf.link",{method:"GET",path:`${s(l)}/pdf-link`},hs):Br()},async editFact(l,d){let u=t(l,lr)?c(d,d.correctedFields):null;if(u===null)return Br();let p=await r.send("records.fact.edit",{method:"POST",path:`${s(l)}/facts/edit`,body:u},{idempotent:false,maxAttempts:1});return p.ok?Te(void 0):p},async removeFact(l,d){let u=t(l,lr)?c(d):null;if(u===null)return Br();let p=await r.send("records.fact.remove",{method:"POST",path:`${s(l)}/facts/remove`,body:u},{idempotent:false,maxAttempts:1});return p.ok?Te(void 0):p},listRequestDocuments(l){return t(l,64)?a("records.request.documents",{method:"GET",path:`/widget/v1/records/requests/${encodeURIComponent(l)}/documents`},Od):Br()},listAuthorizationSignatures:i(()=>a("records.signatures.list",{method:"GET",path:"/widget/v1/records/authorization-signatures"},Ad),"listAuthorizationSignatures")}}i(qd,"createRecordsDepthClient");function Br(){return Promise.resolve(J(H("validationFailed",{retryable:false})))}i(Br,"invalid");function Rr(){let{runtime:e,userRef:r,scopeEpoch:t}=se();return react.useMemo(()=>{let{services:o}=e.registry;return qd({auth:o.authFor(r),...o.errorPolicy?{errorPolicy:o.errorPolicy}:{},...typeof o.apiBaseUrl=="string"?{apiBaseUrl:o.apiBaseUrl}:{}})},[e,r,t])}i(Rr,"useEverfurRecordsDepthClient");function Hr(e,r,t,o=""){let n=Rr(),{userRef:s}=se(),a=po(e),c=react.useMemo(()=>({}),[n,e,o,a]),[l,d]=react.useState({scope:c,value:null,error:null,loading:true}),u=react.useRef(0),p=react.useCallback(async()=>{let b=u.current+=1;if(d({scope:c,value:null,error:null,loading:true}),s===null){d({scope:c,value:null,error:null,loading:false});return}let R=await r(n,e);b===u.current&&(R.ok?d({scope:c,value:R.value,error:null,loading:false}):d({scope:c,value:null,error:R.error,loading:false}));},[n,e,r,c,s]);react.useEffect(()=>(p(),()=>{u.current+=1;}),[p]);let m=l.scope===c?l:{value:null,error:null,loading:true},y=react.useCallback(()=>{p();},[p]),g=m.error===null||m.error.httpStatus!==404,f=g?m.error:null,v=m.loading?"loading":f!==null?"error":m.value===null?"empty":m.value.withheld?"populated":t(m.value)?"empty":"populated";return react.useMemo(()=>({status:v,value:m.value,error:f,available:g,refresh:y}),[v,m.value,f,g,y])}i(Hr,"useRecordsDepthRead");function pt(e){return e!==null&&e.httpStatus===404}i(pt,"isDarkRouteError");var $f=i((e,r)=>e.getMarkers(r),"readMarkers"),Uf=i(e=>e.markers.length===0,"markersEmpty");function Ra(e){let r=Hr(e,$f,Uf);return react.useMemo(()=>{let t=r.available&&r.value!==null&&!r.value.withheld?r.value:null;return {status:r.status,markers:t,available:r.available,error:r.error,refresh:r.refresh}},[r])}i(Ra,"useRecordsMarkers");var Bf=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function zd(e){let{clinic:r,controller:t,depthClient:o,capture:n,onCreated:s}=e,a=r.clinic?.name??r.freeText??"",c=r.clinic===null,[l,d]=react.useState(false),[u,p]=react.useState(e.ownerName),[m,y]=react.useState(r.email),[g,f]=react.useState(false),[v,b]=react.useState(null),[R,h]=react.useState(null),[E,S]=react.useState(0),[C,k]=react.useState(null),[M,T]=react.useState(false),[O,z]=react.useState(null),[q,N]=react.useState([]),[B,x]=react.useState(null),[L,F]=react.useState(false),W=react.useRef(false),I=react.useRef(true),w=react.useRef(it()),A=react.useRef(null);react.useEffect(()=>(I.current=true,()=>{I.current=false,A.current=null;}),[t]),react.useEffect(()=>{let xe=true;return b(null),A.current=null,t.getAuthorizationCopy().then(ur=>{xe&&(ur.ok?(b(ur.value),h(null)):h(ur.error));}).catch(()=>{xe&&h(H("internalError"));}),()=>{xe=false;}},[t,E]),react.useEffect(()=>{if(o===void 0)return;let xe=true;return o.listAuthorizationSignatures().then(ur=>{xe&&(ur.ok?N(ur.value):pt(ur.error)||N([]));}).catch(()=>{}),()=>{xe=false;}},[o]);let _=Mn(r.clinic),Y=m.trim().toLowerCase(),me=Bf.test(Y),Ne=_&&(g||Y.length>0)&&!me?Y.length>0?be.emailInvalid:be.emailRequired:null,re=v?zn(v,u.trim(),Re(e.petName),a):null,oe=e.hostCapture===true||L||B!==null,Se=!!(l&&v&&re&&u.trim()&&a&&oe&&(!_||me)),Pe=react.useCallback(async()=>{if(!(W.current||O!==null||!v||!re)){if(!a){k(be.missingDraftError);return}if(_&&!me){f(true),k(Y.length>0?be.emailInvalid:be.emailRequired);return}if(!(!l||!u.trim())){W.current=true,T(true),k(null);try{if(A.current===null){let ur=B!==null?{signatureId:B}:await n();if(!I.current)return;if(ur===null){k(be.missingSignatureError);return}let ie=r.clinic&&(!_||r.clinic.emailStatus==="none")?{clinicId:r.clinic.id}:{clinicFreeText:a};A.current={petRef:e.petRef,ownerName:u.trim(),authorizationVersion:v.authorizationVersion,...ie,..._?{clinicEmail:Y}:{},...ur.signatureId!==void 0?{signatureId:ur.signatureId}:{signaturePngBase64:ur.signaturePngBase64},idempotencyKey:w.current()};}let xe=await t.createClinicRequest(A.current);if(!I.current)return;if(!xe.ok){k(xe.error.displayMessage);return}if(xe.value.petRef!==e.petRef){k(H("internalError").displayMessage);return}z(xe.value),A.current=null,s?.(xe.value);}catch{I.current&&k(H("internalError").displayMessage);}finally{W.current=false,I.current&&T(false);}}}},[l,n,r.clinic,a,t,v,O,e.petRef,_,Y,s,u,B,re,me]),Ge=react.useCallback(()=>{A.current=null,k(null);},[]);return {title:c?be.titleFreeText:be.titleDirectory,clinicName:a,isFreeText:c,authorized:l,ownerName:u,email:m,emailError:Ne,needsEmail:_,directoryClinicNoEmail:_&&r.clinic!==null,copy:v,copyError:R,scope:re,error:C,busy:M,created:O,ready:Se,signatures:q,reuseSignatureId:B,hasSignature:oe,setAuthorized(xe){W.current||(Ge(),d(xe));},setOwnerName(xe){W.current||(Ge(),p(xe));},setEmail(xe){W.current||(Ge(),f(false),y(xe));},setSigned(xe){W.current||(Ge(),F(xe),xe&&x(null));},pickReuseSignature(xe){W.current||(Ge(),x(xe));},retryCopy(){h(null),S(xe=>xe+1);},submit:Pe}}i(zd,"useRecordsConsentForm");function Hn(e){let{userRef:r,scopeEpoch:t}=se();return jsxRuntime.jsx(Oe,{capability:"recordsClinic",style:e.style,className:e.className,...Fe(e.onBack,Me),children:r===null?jsxRuntime.jsx("p",{role:"alert",children:X.sessionRequired}):jsxRuntime.jsx(Vf,{...Ie(e,["onCreated","onNavigate","onBack"])},JSON.stringify([r,t,e.petRef,e.clinic.key]))})}i(Hn,"EverfurRecordsConsent");function Vf({petRef:e,petName:r,clinic:t,ownerName:o,onCaptureSignature:n,onCreated:s,controller:a,onNavigate:c,onBack:l,style:d,className:u}){let{theme:p,styles:m}=V(),y=zr(),g=a??y,f=Rr(),v=Mt(),b=xt(),R=zd({petRef:e,petName:r,ownerName:o??"",clinic:t,controller:g,depthClient:f,capture:n?()=>n({petRef:e,petName:Re(r),ownerName:R.ownerName,clinicName:R.clinicName,authorizationVersion:R.copy?.authorizationVersion??"",scopeText:R.scope??"",signal:new AbortController().signal}):async()=>v.signed?v.register(g,new AbortController().signal):null,hostCapture:n!==void 0,onCreated:i(T=>{s?.(T),c?.({name:"dashboard"});},"onCreated")}),h=v.signed,E=react.useRef(R);E.current=R,react.useEffect(()=>{E.current.setSigned(h);},[h]);let S=R.busy,C={display:"flex",flexDirection:"column",gap:p.space.sm},k="records-consent-owner-name",M="records-consent-clinic-email";return jsxRuntime.jsxs("div",{className:u,style:{...m.root,...d},"data-testid":"records-consent-screen",children:[jsxRuntime.jsx(Ke,{title:R.title,onBack:l,testID:"records-consent-header"}),jsxRuntime.jsx("p",{style:m.subLead,"data-testid":"records-consent-lead",children:be.leadWeb(r)}),jsxRuntime.jsxs("div",{ref:b,style:{...m.body,...m.content,gap:p.space.lg+p.space.xs/2},"data-testid":"records-consent",children:[jsxRuntime.jsxs("section",{style:m.creamCard,"aria-label":be.scopeHeading,children:[jsxRuntime.jsx("h3",{style:{...m.sectionTitle,color:p.color.brandInk},children:be.scopeHeading}),jsxRuntime.jsx("p",{style:m.bodyText,children:be.scopeBody}),jsxRuntime.jsx("ul",{style:{...m.plainList,gap:p.space.sm},children:be.whatWeDo.map(T=>jsxRuntime.jsxs("li",{style:{...m.bodyText,display:"flex",gap:p.space.sm},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{color:p.color.brandInk,...D(p,"bold")},children:"\u2713"}),jsxRuntime.jsx("span",{children:T})]},T))}),jsxRuntime.jsx("p",{style:{...m.muted,paddingTop:p.space.xs,borderTop:`1px solid ${p.color.borderHairlineGreen}`},children:be.retentionNote}),R.copy&&R.scope?jsxRuntime.jsx("p",{style:{...m.rowDetail,whiteSpace:"pre-wrap"},"data-testid":"records-consent-scope",children:R.scope}):R.copyError?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{role:"alert",style:m.errorText,children:R.copyError.displayMessage}),jsxRuntime.jsx(j,{label:X.retry,kind:"outline",onClick:R.retryCopy,testID:"records-consent-copy-retry"})]}):jsxRuntime.jsx("p",{role:"status",style:m.muted,children:X.loading})]}),jsxRuntime.jsxs("button",{type:"button",role:"checkbox","aria-checked":R.authorized,onClick:()=>R.setAuthorized(!R.authorized),style:{display:"flex",alignItems:"flex-start",gap:p.space.md,textAlign:"left",font:"inherit",cursor:"pointer",borderRadius:p.radius.lg-p.space.xs,border:`1px solid ${R.authorized?p.color.brand:p.color.brandBorder}`,backgroundColor:R.authorized?p.color.brandSoft:p.color.surface,padding:p.space.md+p.space.xs/2,color:p.color.text.primary},"data-testid":"records-authorize-toggle",children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{boxSizing:"border-box",flexShrink:0,width:p.space.xl,height:p.space.xl,borderRadius:p.radius.xs+1,border:`1.6px solid ${p.color.brandInk}`,backgroundColor:R.authorized?p.color.brand:p.color.surface,color:p.color.onPrimary,display:"inline-flex",alignItems:"center",justifyContent:"center",...D(p,"bold")},children:R.authorized?"\u2713":""}),jsxRuntime.jsx("span",{style:{...m.rowTitle,...D(p,"bold"),fontSize:p.type.size.bodyTight},children:be.authorizeLabel(r)})]}),jsxRuntime.jsxs("div",{style:C,children:[jsxRuntime.jsx("label",{htmlFor:k,style:m.fieldLabel,children:be.fullName}),jsxRuntime.jsx("input",{id:k,style:m.field,value:R.ownerName,placeholder:be.fullNamePlaceholder,maxLength:200,disabled:S,autoComplete:"name",onChange:T=>R.setOwnerName(T.target.value),"data-testid":"records-consent-owner-name"})]}),R.needsEmail?jsxRuntime.jsxs("div",{style:C,"data-testid":"records-consent-email-block",children:[R.directoryClinicNoEmail?jsxRuntime.jsx("p",{style:m.cautionNote,"data-testid":"records-consent-no-email-note",children:be.noEmailNote(r,R.clinicName)}):null,jsxRuntime.jsx("label",{htmlFor:M,style:m.fieldLabel,children:be.emailLabel}),jsxRuntime.jsx("input",{id:M,type:"email",style:m.field,value:R.email,placeholder:be.emailPlaceholder,maxLength:320,disabled:S,autoComplete:"off",onChange:T=>R.setEmail(T.target.value),"data-testid":"records-consent-clinic-email"}),R.emailError?jsxRuntime.jsx("p",{role:"alert",style:m.errorText,children:R.emailError}):null,jsxRuntime.jsx("p",{style:m.muted,"data-testid":"records-consent-review-note",children:be.newClinicDirectSendNote})]}):null,n?null:jsxRuntime.jsxs("div",{style:C,children:[R.signatures.length>0?jsxRuntime.jsxs("div",{style:C,children:[jsxRuntime.jsx("span",{style:m.fieldLabel,children:be.reuseSignature}),jsxRuntime.jsx("div",{style:{display:"flex",gap:p.space.sm,overflowX:"auto",padding:`${p.space.xs}px 0`},children:R.signatures.map(T=>{let O=R.reuseSignatureId===T.signatureId;return jsxRuntime.jsx("button",{type:"button",onClick:()=>R.pickReuseSignature(O?null:T.signatureId),"aria-label":O?be.reuseTileSelectedA11y:be.reuseTileA11y,"aria-pressed":O,style:{flexShrink:0,width:112,height:56,borderRadius:p.radius.sm,border:O?`2px solid ${p.color.brandInk}`:`1px solid ${p.color.brandBorder}`,backgroundColor:p.color.surface,padding:0,overflow:"hidden",cursor:"pointer"},"data-testid":`records-consent-reuse-${T.signatureId}`,children:jsxRuntime.jsx("img",{src:T.previewUrl,alt:"",style:{width:"100%",height:"100%",objectFit:"contain"}})},T.signatureId)})}),jsxRuntime.jsx("p",{style:m.muted,children:be.reuseHint})]}):null,jsxRuntime.jsx($t,{pad:v,disabled:S}),jsxRuntime.jsx("p",{style:m.muted,children:be.signatureHint(R.clinicName)}),!R.hasSignature&&R.clinicName.length>0?jsxRuntime.jsx("p",{style:m.muted,"data-testid":"records-consent-signature-required",children:be.missingSignatureError}):null]}),jsxRuntime.jsxs("section",{style:{...m.creamCard,backgroundColor:p.color.surfaceSubtle,border:0},"aria-label":be.whatHappensNext,"data-testid":"records-consent-next",children:[jsxRuntime.jsx("h3",{style:m.sectionTitle,children:be.whatHappensNext}),jsxRuntime.jsx("p",{style:m.bodyText,children:be.whatHappensNextBody})]}),R.error?jsxRuntime.jsx("p",{role:"alert","aria-live":"assertive",style:m.errorBanner,children:R.error}):null,R.created?jsxRuntime.jsx("p",{role:"status",style:m.bodyText,children:R.created.statusLabel||X.records}):null]}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:p.space.sm,padding:`${p.space.md}px ${p.space.lg}px ${p.space.xxl}px`,borderTop:`1px solid ${p.color.borderHairlineGreen}`,backgroundColor:p.color.background},children:[l?jsxRuntime.jsx(j,{label:Me,kind:"link",disabled:S,onClick:l,style:{flex:"0 0 auto"},testID:"records-consent-cancel"}):null,jsxRuntime.jsx(j,{label:S?be.submitting:be.submit,ariaLabel:be.submitA11y,disabled:!R.ready,busy:S,onClick:()=>{R.submit();},style:{flex:"1 1 12rem",minWidth:0,minHeight:54},testID:"records-consent-submit"})]}),jsxRuntime.jsx(Ae,{})]})}i(Vf,"ConsentBody");var Mo=Object.freeze({visit:0,vaccine:1,weight:2,medication:3});function Md(e){if(!e)return null;let r=Date.parse(e);return Number.isNaN(r)?null:r}i(Md,"toMillis");function $d(e){let r=[...e.visits.map((t,o)=>({key:`visit-${o}-${t.visitId}`,kind:"visit",kindLabel:ge.kind.visit,at:t.visitDate,date:ee(t.visitDate),title:t.summary??ge.clinicVisit,detail:t.veterinarian?ge.doctor(t.veterinarian):null,docId:t.docId})),...e.vaccines.map((t,o)=>{let n=[];return t.lot&&n.push(ge.lot(t.lot)),t.expiresOn&&n.push(ge.expires(ee(t.expiresOn))),{key:`vaccine-${o}-${t.vaccineId}`,kind:"vaccine",kindLabel:ge.kind.vaccine,at:t.administeredOn,date:ee(t.administeredOn),title:t.product||ge.kind.vaccine,detail:n.length?n.join(" \xB7 "):null,docId:t.docId}}),...e.weights.map((t,o)=>({key:`weight-${o}-${t.weightId}`,kind:"weight",kindLabel:ge.kind.weight,at:t.observedOn,date:ee(t.observedOn),title:od(t.weightKg),detail:null,docId:t.docId})),...e.medications.map((t,o)=>{let n=[t.dose,t.route,t.frequency].filter(s=>!!s);return {key:`medication-${o}-${t.medicationId}`,kind:"medication",kindLabel:ge.kind.medication,at:t.startedOn,date:ee(t.startedOn),title:t.drugName||ge.kind.medication,detail:n.length?n.join(" \xB7 "):null,docId:t.docId}})];return Object.freeze(r.sort((t,o)=>{let n=Md(t.at),s=Md(o.at);return n===null&&s===null?Mo[t.kind]-Mo[o.kind]:n===null?1:s===null?-1:s!==n?s-n:Mo[t.kind]-Mo[o.kind]}))}i($d,"buildTimelineRows");var Xf=300,Ud=120,Bd=44,Jf=i((e,r)=>e.getTimeline(r),"readTimeline"),Zf=i(e=>e.isEmpty,"timelineEmpty");var ey=i(e=>e.contributions.length===0,"contributionsEmpty");function $o({petRef:e,style:r,className:t,onBack:o}){let n=Hr(e,Jf,Zf);return jsxRuntime.jsx(Hd,{state:n,style:r,className:t,onBack:o,header:jsxRuntime.jsx(Ke,{title:ge.timeline,onBack:Dn(o),testID:"timeline-header"}),loading:jsxRuntime.jsx(md,{testID:"timeline-loading"}),empty:jsxRuntime.jsx(He,{variant:"no_records",testID:"timeline-empty"}),render:s=>jsxRuntime.jsx(ny,{timeline:s})})}i($o,"EverfurRecordsTimeline");function Uo({petRef:e,docId:r,style:t,className:o,onBack:n}){let s=react.useCallback((l,d)=>l.getDocumentContributions(d,r),[r]),a=Hr(e,s,ey,r),c=a.value?.document?.title?.trim()||ge.uploadedDocument;return jsxRuntime.jsx(Hd,{state:a,style:t,className:o,onBack:n,header:jsxRuntime.jsx(Ke,{title:c,onBack:Dn(n),testID:"contributions-header"}),empty:jsxRuntime.jsx(He,{variant:"no_records",testID:"contributions-empty"}),render:l=>jsxRuntime.jsx(oy,{view:l})})}i(Uo,"EverfurDocumentContributions");function Hd({state:e,style:r,className:t,header:o,loading:n,empty:s,render:a,onBack:c}){let{styles:l}=Ca(),{userRef:d}=se();return jsxRuntime.jsx(Oe,{capability:"records",style:r,className:t,...Fe(Dn(c),Me),children:jsxRuntime.jsxs("div",{className:t,style:{...l.container,...r},children:[o??null,jsxRuntime.jsx("div",{style:l.body,children:d===null?jsxRuntime.jsx("p",{role:"alert",style:l.alertText,children:X.sessionRequired}):ry(e,a,l,n,s)}),jsxRuntime.jsx(Ae,{})]})})}i(Hd,"DepthSurface");function ry(e,r,t,o,n){switch(e.status){case "loading":return o??jsxRuntime.jsx(ty,{styles:t});case "empty":return n??jsxRuntime.jsx("div",{style:t.centered,children:jsxRuntime.jsx("div",{role:"img","aria-label":X.empty,style:t.emptyGlyph})});case "error":return e.error?jsxRuntime.jsx(He,{variant:nr(e.error),message:e.error.displayMessage,onAction:e.error.retryable?e.refresh:void 0,testID:"depth-error"}):null;case "populated":return e.value===null||e.value.withheld?null:r(e.value);default:return null}}i(ry,"renderState");function ty({styles:e}){let[r,t]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>t(true),Xf);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx("div",{role:"status","aria-busy":"true","aria-label":X.loading,style:e.centered,children:r?jsxRuntime.jsx("div",{"aria-hidden":"true",style:e.spinner}):null})}i(ty,"LoadingState");function ny({timeline:e}){let{styles:r}=Ca(),t=$d(e);return jsxRuntime.jsxs("section",{"aria-label":ge.timeline,style:r.timelineList,children:[e.disclaimer.length>0?jsxRuntime.jsx("p",{role:"note","aria-label":yr.important(e.disclaimer),style:r.timelineBand,children:e.disclaimer}):null,jsxRuntime.jsx("ul",{style:r.plainList,children:t.map((o,n)=>jsxRuntime.jsx("li",{style:n>0?r.timelineSeparated:void 0,"data-testid":`records-timeline-row-${o.kind}`,children:jsxRuntime.jsxs("div",{style:r.timelineRow,"aria-label":[o.kindLabel,o.date,o.title,o.detail].filter(Boolean).join(", "),children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:r.timelineBubble}),jsxRuntime.jsxs("div",{style:r.timelineBody,children:[jsxRuntime.jsxs("div",{style:r.topLine,children:[jsxRuntime.jsx("span",{style:r.timelineKind,children:o.kindLabel}),jsxRuntime.jsx("span",{style:r.date,children:o.date})]}),jsxRuntime.jsx("span",{style:r.timelineTitle,children:o.title}),o.detail?jsxRuntime.jsx("span",{style:r.rowDetail,children:o.detail}):null]})]})},o.key))})]})}i(ny,"TimelineBody");function oy({view:e}){let{styles:r}=Ca();return jsxRuntime.jsxs("section",{"aria-label":X.records,style:r.list,children:[e.document?.receivedAt?jsxRuntime.jsx("p",{style:r.rowDetail,children:ee(e.document.receivedAt)}):null,jsxRuntime.jsx("dl",{style:r.card,children:e.contributions.map(t=>jsxRuntime.jsxs("div",{style:r.row,children:[jsxRuntime.jsx("dt",{style:r.rowTitle,children:t.label}),jsxRuntime.jsx("dd",{style:r.rowValue,children:tn(t.value,t.unit)}),t.observedAt?jsxRuntime.jsx("dd",{style:r.rowDetail,children:ee(t.observedAt)}):null]},t.key))})]})}i(oy,"ContributionsBody");function Ca(){let e=ye(),r=react.useMemo(()=>iy(e),[e]);return {theme:e,styles:r}}i(Ca,"useDepthTheme");function iy(e){let{color:r,space:t,radius:o,type:n,slots:s}=e,a=i((m,y)=>`${Math.round(m*y)}px`,"lh"),c=i((m,y,g,f="regular")=>({margin:0,...D(e,f),fontSize:m,lineHeight:a(m,y),color:g}),"text"),l=tt(s.recordCard),d=i((m,y,g,f="regular")=>({...c(m,y,g,f),...l}),"inCard"),u=`1px solid ${r.brandBorder}`,p=e.brightness==="dark"?r.errorRed:r.danger;return {container:{boxSizing:"border-box",display:"flex",flexDirection:"column",minHeight:Ud,height:"100%",backgroundColor:r.background,color:r.text.primary,...D(e,"regular")},body:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",overflowY:"auto"},centered:{boxSizing:"border-box",flex:"1 1 auto",minHeight:Ud,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:t.lg,padding:t.xl,textAlign:"center"},spinner:{boxSizing:"border-box",width:24,height:24,borderRadius:o.pill,border:`3px solid ${r.brandSofter}`,borderTopColor:r.brandInk},emptyGlyph:{boxSizing:"border-box",width:40,height:40,borderRadius:o.lg,backgroundColor:r.brandSoft,border:u},alertText:c(n.size.subtitle,n.lineHeight.snug,r.text.secondary),errorText:c(n.size.subtitle,n.lineHeight.snug,p),primaryButton:{boxSizing:"border-box",minHeight:Bd,minWidth:Bd,padding:`${t.md}px ${t.xl}px`,borderRadius:o.pill,...D(e,"bold"),fontSize:n.size.body,border:0,cursor:"pointer",backgroundColor:r.primary,color:r.onPrimary,...Mr(s.primaryButton),...tt(s.primaryButton)},list:{display:"flex",flexDirection:"column",gap:t.md,padding:t.lg},section:{display:"flex",flexDirection:"column",gap:t.sm},heading:{...c(n.size.heading,n.lineHeight.snug,r.text.primary,"bold")},card:{boxSizing:"border-box",listStyle:"none",display:"flex",flexDirection:"column",gap:t.sm,margin:0,padding:t.md,borderRadius:o.md,backgroundColor:r.surfaceCream,border:u,...Mr(s.recordCard,1)},plainList:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:t.sm},row:{display:"flex",flexDirection:"column",gap:t.xs,padding:`${t.xs}px 0`,borderBottom:`1px solid ${r.borderHairlineGreen}`},topLine:{display:"flex",justifyContent:"space-between",gap:t.md},kindLabel:{...d(n.size.caption,n.lineHeight.normal,r.text.muted,"medium")},date:d(n.size.caption,n.lineHeight.normal,r.text.muted),rowTitle:{...d(n.size.body,n.lineHeight.normal,r.text.primary,"bold")},rowValue:{...d(n.size.body,n.lineHeight.normal,r.text.primary,"medium")},rowDetail:d(n.size.bodyTight,n.lineHeight.normal,r.text.muted),rowMuted:{...d(n.size.bodyTight,n.lineHeight.normal,r.text.muted),opacity:.7},chip:{...c(n.size.caption,n.lineHeight.normal,r.text.primary),alignSelf:"flex-start",padding:`${t.xs}px ${t.sm}px`,borderRadius:o.pill},chipNeutral:{backgroundColor:r.badgeBgNeutral},chipCaution:{backgroundColor:r.badgeBgCaution},chipCritical:{backgroundColor:r.badgeBgCritical},disclaimer:c(n.size.caption,n.lineHeight.normal,r.text.muted),timelineList:{display:"flex",flexDirection:"column",paddingBottom:t.xxl},timelineBand:{...c(n.size.caption,n.lineHeight.normal,r.text.secondary),borderRadius:o.md-t.xs/2,padding:t.md,backgroundColor:r.brandSoft,margin:`${t.xs}px ${t.lg}px ${t.md}px`},timelineSeparated:{borderTop:`1px solid ${r.brandBorder}`,marginLeft:ca,paddingLeft:0},timelineRow:{display:"flex",gap:t.md,padding:`${t.md+t.xs/2}px ${t.lg}px`},timelineBubble:{boxSizing:"border-box",flexShrink:0,width:34,height:34,borderRadius:o.pill,backgroundColor:r.brandSoft,border:u},timelineBody:{flex:1,display:"flex",flexDirection:"column",gap:t.xs-1,minWidth:0},timelineKind:{...D(e,"mono"),fontSize:n.size.micro,lineHeight:`${n.size.bodyTight}px`,letterSpacing:n.letterSpacing.eyebrow/3,textTransform:"uppercase",color:r.text.secondary},timelineTitle:{...c(n.size.body,n.lineHeight.normal,r.text.primary,"medium")}}}i(iy,"makeStyles");function Ea(e,r={}){let t=Rr(),{userRef:o}=se(),n=r.now??Date.now,[s,a]=react.useState(null),[c,l]=react.useState(true),[d,u]=react.useState(null),[p,m]=react.useState(null),y=p===true,[g,f]=react.useState({}),[v,b]=react.useState(false),[R,h]=react.useState(null),[E,S]=react.useState(false),[C,k]=react.useState(false),[M,T]=react.useState(false),[O,z]=react.useState(null),q=O!==null&&O.client===t?O.value:kr,N=q.shareAudiences,B=po(e),x=react.useRef(0),L=react.useRef(true),F=react.useCallback(async()=>{let oe=x.current+=1;if(l(true),u(null),o===null){a(null),l(false);return}let Se=await t.listShares(e);oe!==x.current||!L.current||(Se.ok?(a(Se.value),m(true)):pt(Se.error)?(a(null),m(false)):(a(null),u(Se.error),jd(Se)&&m(true)),l(false));},[t,e,o]);react.useEffect(()=>(L.current=true,F(),()=>{L.current=false,x.current+=1;}),[F]),react.useEffect(()=>{if(o===null||t.readFeatures===void 0)return;let oe=true;return t.readFeatures().then(Se=>{oe&&z({client:t,value:Se});},()=>{}),()=>{oe=false;}},[t,o]);let W=react.useRef(B);react.useEffect(()=>{W.current!==B&&(W.current=B,f({}),k(true),F());},[B,F]);let I=react.useCallback(async oe=>{b(true);let Pe=await(oe!==void 0&&N.some(Ge=>Ge.audience===oe)?t.createShare(e,{audience:oe}):t.createShare(e));return L.current&&(b(false),Pe.ok?(f(Ge=>({...Ge,[Pe.value.shareId]:Pe.value.shareUrl})),F()):pt(Pe.error)?m(false):Yr(Pe.error)&&k(true)),Pe},[t,e,F,N]),w=react.useCallback(async oe=>{T(true);let Se=await t.emailShare(e,oe);return L.current&&(T(false),Se.ok?F():pt(Se.error)?m(false):Yr(Se.error)?k(true):Se.error.httpStatus===502&&F()),Se},[t,e,F]),A=react.useCallback(async oe=>{h(oe);let Se=await t.revokeShare(e,oe);return L.current&&(h(null),F()),Se},[t,e,F]),_=react.useCallback(async()=>{S(true);let oe=await t.getPdfLink(e);return L.current&&(S(false),!oe.ok&&Yr(oe.error)&&k(true)),oe},[t,e]),Y=react.useCallback(()=>{k(false),F();},[F]),me=react.useMemo(()=>cd(s??[],g,n()),[s,g,n]),Ne=c?"loading":d!==null?"error":me.length===0?"empty":"populated",re=q.features;return react.useMemo(()=>({status:Ne,rows:me,available:y,consentRequired:C,error:d,creating:v,revokingId:R,preparingPdf:E,shareAudiences:N,features:re,sending:M,createLink:I,sendEmail:w,revoke:A,pdfLink:_,refresh:Y}),[Ne,me,y,C,d,v,R,E,N,re,M,I,w,A,_,Y])}i(Ea,"useRecordShares");function jd(e){return e.ok||e.error.httpStatus!==void 0&&e.error.httpStatus!==404}i(jd,"answeredBehindGate");function Vd(e){return e.available||e.status!=="empty"}i(Vd,"sharesListShown");function Sa(e){let r=Rr(),{userRef:t}=se(),o=react.useMemo(()=>({}),[r,e,t]),[n,s]=react.useState({scope:o,lit:null});react.useEffect(()=>{if(t===null)return;let c=true;return r.listShares(e).then(l=>{c&&(!l.ok&&pt(l.error)?s({scope:o,lit:false}):jd(l)&&s({scope:o,lit:true}));},()=>{}),()=>{c=false;}},[r,e,t,o]);let a=n.scope===o?n.lit:null;return react.useMemo(()=>({lit:a}),[a])}i(Sa,"useRecordsDepthProbe");function xa(e){let r=Rr(),o=Sa(e).lit===true,[n,s]=react.useState(false),[a,c]=react.useState(null),l=react.useRef(true);react.useEffect(()=>(l.current=true,()=>{l.current=false;}),[]);let d=react.useCallback(async()=>{s(true),c(null);let u=await r.getPdfLink(e);return l.current&&(s(false),u.ok||c(u.error)),u},[r,e]);return react.useMemo(()=>({preparing:n,available:o,error:a,pdfLink:d}),[n,o,a,d])}i(xa,"useRecordPdfLink");var Wn=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:i(e=>`Call the clinic at ${e}`,"callAt")});var ay=Math.round(Kr/(1024*1024)),Qe=Object.freeze({title:i(e=>`Upload ${Re(e)}\u2019s records`,"title"),screenTitle:"Upload a document",subtitle:i(e=>`Already have lab results, a vet summary, or test reports? Add them here and we\u2019ll read them and pull out ${Re(e)}\u2019s health markers.`,"subtitle"),noPet:"Select a pet first, then upload their records.",cardTitle:"Add records",cardSubtitle:`Upload PDF records you already have, up to ${ay} MB each. You can pick several at once. We\u2019ll read them and add the results to your records.`,chooseFiles:"Choose a file",chooseFilesA11y:"Choose records to upload",uploading:i((e,r)=>`Uploading ${Math.min(e+1,r)} of ${r}\u2026`,"uploading"),cancel:"Cancel",cancelA11y:"Cancel these uploads",received:i(e=>`${e===1?"Record received.":`${e} records received.`} We\u2019ll read and review ${e===1?"it":"them"}, then add the results to your records, usually within 1-2 business days.`,"received"),retryFailed:i(e=>`Retry ${e} that didn\u2019t upload`,"retryFailed"),retryFailedA11y:i(e=>`Retry ${e} failed upload${e>1?"s":""}`,"retryFailedA11y"),haveMore:"Have more?",addMore:"Upload another document",addMoreA11y:"Upload another document",done:"Done",doneA11y:"Done, view records",errors:Object.freeze({start:"We couldn\u2019t start that upload. Check your connection and try again.",startPlain:"We couldn\u2019t start that upload. Please try again.",upload:"We couldn\u2019t upload that record. Check your connection and try again."})}),Gn=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\u2019t read this kind of file. Upload a PDF or a photo of the record."});var wa=Math.round(Kr/(1024*1024)),Ht=Object.freeze({queued:"Queued",verifying:"Verifying\u2026",done:"Done",failed:"Failed",uploading:i((e,r)=>`Uploading ${Math.min(e+1,r)} of ${r} records`,"uploading"),uploaded:i((e,r)=>`${e} of ${r} records uploaded`,"uploaded")});function Wd(e){let r=Math.round(e.progress*100);switch(e.status){case "done":return Ht.done;case "failed":return Ht.failed;case "uploading":return e.progress>=1?Ht.verifying:`${r}%`;case "queued":return Ht.queued;default:return null}}i(Wd,"uploadItemStatusLabel");function Ho(e,r=false){if(e.length===0)return null;let t=i(a=>{let c=a.map(l=>l.name??"");return c.length<=3?c.join(", "):`${c.slice(0,3).join(", ")} and ${c.length-3} more`},"nameList"),o=e.filter(a=>a.reason==="too_large"),n=e.filter(a=>a.reason==="unsupported");if(r){let a=[];return n.length>0&&a.push(Gn.unreadable),o.length>0&&a.push(`Didn\u2019t upload: ${t(o)} ${o.length>1?"are":"is"} over ${wa} MB.`),a.join(" ")}let s=[];return n.length>0&&s.push(`${t(n)} ${n.length>1?"are not PDFs":"is not a PDF"}`),o.length>0&&s.push(`${t(o)} ${o.length>1?"are":"is"} over ${wa} MB`),`Didn\u2019t upload: ${s.join("; ")}. We can only read PDFs up to ${wa} MB right now.`}i(Ho,"skippedFilesMessage");function Gd(e){let r=[];for(let t of e)t.status==="skipped"&&t.skipReason!==null&&r.push({name:t.name,reason:t.skipReason});return r}i(Gd,"skippedOf");var ka=[37,80,68,70,45],sy=[255,216,255],ly=[137,80,78,71,13,10,26,10],Yd=12,dy=Object.freeze({heic:"image/heic",heix:"image/heic",heim:"image/heic",heis:"image/heic",mif1:"image/heif",msf1:"image/heif"}),Kd="application/pdf,.pdf",cy=Object.freeze({"image/jpeg":"image/jpeg,.jpg,.jpeg","image/png":"image/png,.png","image/heic":"image/heic,.heic","image/heif":"image/heif,.heif"});function jo(e){let r=Xt.filter(t=>Gr(t,e));return [Kd,...r.map(t=>cy[t])].join(",")}i(jo,"recordsDocumentAccept");var uy="application/octet-stream",py="file:web-document";async function Qd(e,r){let t=e.slice(0,r);try{return typeof t.arrayBuffer=="function"?new Uint8Array(await t.arrayBuffer()):await new Promise(o=>{let n=new FileReader;n.onload=()=>{o(n.result instanceof ArrayBuffer?new Uint8Array(n.result):new Uint8Array);},n.onerror=()=>o(new Uint8Array),n.readAsArrayBuffer(t);})}catch{return new Uint8Array}}i(Qd,"readHead");async function Xd(e){if(e.size<ka.length)return false;let r=await Qd(e,ka.length);return _a(r,ka)}i(Xd,"isPdfBlob");function _a(e,r,t=0){return e.length>=t+r.length&&r.every((o,n)=>e[t+n]===o)}i(_a,"startsWith");function my(e){return _a(e,sy)?"image/jpeg":_a(e,ly)?"image/png":e.length>=Yd&&String.fromCharCode(...e.slice(4,8))==="ftyp"?dy[String.fromCharCode(...e.slice(8,12))]??null:null}i(my,"photoTypeOf");async function fy(e,r){if(await Xd(e))return Fs;if(!Xt.some(o=>Gr(o,r)))return null;let t=my(await Qd(e,Yd));return t!==null&&Gr(t,r)?t:null}i(fy,"detectedType");async function Vo(e,r){let t=await fy(e,r),o=e.name,n=typeof o=="string"?o:void 0;return Object.freeze({uri:py,mimeType:t??uy,sizeBytes:e.size,blob:e,...n!==void 0?{name:n}:{}})}i(Vo,"fileToHandle");function yy(e,r){let t=e.sizeBytes;return Gr(e.mimeType,r)&&typeof t=="number"&&Number.isFinite(t)&&t>0&&t<=Kr}i(yy,"isUploadableHandle");function gy(e=document,r){return new Promise(t=>{let o=e.createElement("input");o.type="file",o.accept=jo(r),o.hidden=true;let n=i(()=>{o.remove();},"done");o.addEventListener("change",()=>{let s=o.files?.[0];if(n(),s===void 0){t(null);return}Vo(s,r).then(t);},{once:true}),o.addEventListener("cancel",()=>{n(),t(null);},{once:true}),e.body.appendChild(o),o.click();})}i(gy,"pickDocument");var jr=Object.freeze({email:"Clinic email",emailPlaceholder:"records@clinic.com",emailError:"Enter a valid clinic email.",updateEmail:"Update email & resend",updateEmailA11y:"Update clinic email and resend request",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\u2019ll 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 Jd({request:e,onRecovered:r,canUpload:t=false},o){let[n,s]=react.useState(""),[a,c]=react.useState(false),[l,d]=react.useState(null),[u,p]=react.useState(false),[m,y]=react.useState(null),g=react.useRef(false),f=react.useRef(false),v=react.useRef(0);react.useEffect(()=>(f.current=true,()=>{f.current=false,v.current+=1;}),[o]);let b=m!==null&&m.before===e.updatedAt?{...m.value,canRetrySend:e.canRetrySend===true&&m.value.canRetrySend===true,canUpdateClinicEmail:e.canUpdateClinicEmail===true&&m.value.canUpdateClinicEmail===true,canRevoke:e.canRevoke===true&&m.value.canRevoke===true,canConvertToUpload:e.canConvertToUpload===true&&m.value.canConvertToUpload===true}:e,R=n.trim(),h=R.length<=320&&!Array.from(R).some(T=>T.charCodeAt(0)<=32||T.charCodeAt(0)===127)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(R),E=b.canUpdateClinicEmail===true&&R.length>0,S=b.canRetrySend===true&&!a&&!E,C=b.canUpdateClinicEmail===true&&!a&&h,k=b.canConvertToUpload===true&&t,M=i(async T=>{let O={retry:S,email:C,revoke:b.canRevoke===true&&u,convert:k};if(g.current||!f.current||!O[T])return;g.current=true,c(true),d(null);let z=v.current,q=i(()=>f.current&&z===v.current,"live");try{let N=T==="retry"?await o.retryRequest(e.id):T==="email"?await o.updateClinicEmail(e.id,R):T==="revoke"?await o.revokeRequest(e.id):await o.convertToUpload(e.id);if(!q())return;if(!N.ok){d(N.error);return}if(N.value.id!==e.id||N.value.petRef!==e.petRef){d(H("internalError"));return}y({before:e.updatedAt,value:N.value}),s(""),p(!1),r();}catch{q()&&d(H("internalError"));}finally{g.current=false,q()&&c(false);}},"run");return {request:b,email:n,busy:a,error:l,canRetry:S,canUpdateEmail:C,canConvert:k,hasEmailEdit:E,confirmingRevoke:u&&b.canRevoke===true,emailInvalid:R.length>0&&!h,setEmail(T){g.current||(s(T),d(null));},retry:i(()=>M("retry"),"retry"),updateEmail:i(()=>M("email"),"updateEmail"),revoke:i(()=>M("revoke"),"revoke"),convert:i(()=>M("convert"),"convert"),askRevoke(){!g.current&&b.canRevoke===true&&p(true);},keepRequest(){g.current||p(false);}}}i(Jd,"useRecordsRecovery");var hy=["requested","sent_to_clinic","awaiting_clinic","records_received","processing","ready"],Ry=["requested","awaiting_upload","records_received","processing","ready"],vy=["requested","sent_to_clinic","awaiting_clinic","awaiting_upload","records_received","processing","ready"],mn=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"}),Cy=Object.freeze({requested:"Request sent",sent_to_clinic:"Clinic notified",awaiting_clinic:"Waiting for records\u2026"}),Ta=Object.freeze({notified:i(e=>`A secure request went to ${e}.`,"notified"),received:"Everfur reads every page: dates, vaccines, labs and prescriptions.",added:i(e=>`Added to ${e}\u2019s records`,"added")}),Cr=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\u2019t read this one automatically",manualReview:"Checking these by hand so nothing\u2019s missed",switchedTitle:"Stopped waiting on the clinic",switched:"You switched to uploading your own records"}),Ey=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"}),Sy=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 xy(e){return e.wireStatus??Sy[e.status]??"sent"}i(xy,"wireStatusOf");function wy(e,r){return e!=="awaiting_response"||r<=0?null:`${r} ${r===1?"reminder":"reminders"} sent`}i(wy,"reminderProgressLabel");function ky(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}}i(ky,"reachedRailIndex");function _y(e){switch(e.dispatchStatus){case "sent":return Cr.delivered;case "preparing":case "queued":case "sending":return Cr.emailing;case "failed":return Cr.bounced;default:return null}}i(_y,"deliveryDetail");function Py(e,r){return wy(r,e.reminderCount??0)??Cr.waiting}i(Py,"awaitingDetail");function jt(e){return e.source==="owner_provided"||!!e.convertedToUploadAt}i(jt,"isOwnerSourcedRequest");function Ty(e,r,t){let o=jt(r);switch(e){case "sent_to_clinic":return _y(r);case "awaiting_clinic":return Py(r,t);case "awaiting_upload":return Cr.upload;case "records_received":return o?Cr.ownerAdded:Cr.clinicSent;case "processing":return Cr.preparing;case "ready":return Cr.ready;default:return null}}i(Ty,"railDetail");function Dy(e,r){return !!e.reviewStartedAt||r==="parsing_failed"||r==="review_email_failed"}i(Dy,"tookReviewBranch");function Iy(e,r,t){if(e.key!=="processing"||!Dy(r,t))return [e];let o=t==="parsing_failed",n=t==="published",s=n?"done":o?"current":"done",a=n?"done":o?"upcoming":"current";return [{key:"parsing_failed",title:mn.parsing_failed,detail:Cr.parsingFailed,at:null,state:s},{key:"manual_review",title:mn.manual_review,detail:Cr.manualReview,at:r.reviewStartedAt??null,state:a}]}i(Iy,"expandProcessingPhase");function Oy(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}}i(Oy,"convertedReachedIndex");function Zd(e){return {key:"awaiting_clinic",title:Cr.switchedTitle,detail:Cr.switched,at:e.convertedToUploadAt??null,state:"done"}}i(Zd,"convertedClinicSwitchEvent");function Ay(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}}i(Ay,"ownerReachedIndex");function Fy(e,r,t){switch(e){case "requested":return r.createdAt||null;case "awaiting_clinic":return r.lastReminderAt??null;case "processing":return r.parsingStartedAt??r.reviewStartedAt??null;case "ready":return t==="published"&&r.updatedAt||null;default:return null}}i(Fy,"railTimestamp");function ec(e,r,t,o){return {key:e,title:mn[e],detail:Ty(e,r,t),at:Fy(e,r,t),state:o}}i(ec,"railEvent");function mt(e,r){return {key:e,title:mn[e],detail:Ey[e]??null,at:r.updatedAt||null,state:"failed"}}i(mt,"terminalEvent");function Da(e,r,t,o,n){return e.map((s,a)=>{let c=n?.(s)??null;if(c!==null)return c;let l=o==="published"||a<r?"done":a===r?"current":"upcoming";return ec(s,t,o,l)}).flatMap(s=>Iy(s,t,o))}i(Da,"walkRail");function Ia(e,r={}){return qy(Ny(e),e,r.petName??null)}i(Ia,"buildRequestTimeline");function qy(e,r,t){let o=r.source!=="owner_provided"&&!e.some(s=>s.key==="delivery_failed"),n=r.clinicEmail?.trim()??"";return e.map(s=>{if(s.title!==mn[s.key])return s;if(s.key==="ready")return {...s,title:Ta.added(Re(t))};if(!o)return s;let a=Cy[s.key]??s.title;return s.key==="sent_to_clinic"&&r.dispatchStatus==="sent"&&n.length>0?{...s,title:a,detail:Ta.notified(n)}:s.key==="records_received"&&!jt(r)?{...s,title:a,detail:Ta.received}:{...s,title:a}})}i(qy,"inArtifactWords");function Ny(e){let r=xy(e),t=i(n=>ec(n,e,r,"done"),"done");if(r==="revoked")return [t("requested"),mt("revoked",e)];if(e.convertedToUploadAt)return r==="failed"?[t("requested"),t("sent_to_clinic"),Zd(e),t("awaiting_upload"),t("records_received"),mt("processing_failed",e)]:Da(vy,Oy(r),e,r,n=>n==="awaiting_clinic"?Zd(e):null);if(e.source==="owner_provided"){if(r==="failed"||r==="clinic_declined")return [t("requested"),t("awaiting_upload"),t("records_received"),mt("processing_failed",e)];let n=Ay(r);return Da(Ry,n<0?1:n,e,r)}if(r==="clinic_declined")return [t("requested"),t("sent_to_clinic"),t("awaiting_clinic"),mt("clinic_declined",e)];if(r==="clinic_responded_no_records")return [t("requested"),t("sent_to_clinic"),t("awaiting_clinic"),mt("clinic_no_records",e)];if(r==="failed"){let n=e.failureCode??null;return n==="no_response"?[t("requested"),t("sent_to_clinic"),t("awaiting_clinic"),mt("no_response",e)]:n==="hard_bounce"||n==="dispatch_failed"?[t("requested"),mt("delivery_failed",e)]:n==="parse_timeout"||n==="parse_error"||e.dispatchStatus==="sent"?[t("requested"),t("sent_to_clinic"),t("awaiting_clinic"),t("records_received"),mt("processing_failed",e)]:[t("requested"),mt("delivery_failed",e)]}let o=ky(r);return Da(hy,o<0?1:o,e,r)}i(Ny,"buildRailEvents");var zy=Object.freeze({done:"completed",current:"in progress",failed:"needs attention",upcoming:"not started"}),Wo=28,My="Now";function fn({request:e,petName:r}){let t=By(),o=Ia(e,{petName:r??null});return jsxRuntime.jsx("ol",{style:t.list,"aria-label":le.timelineA11y,"data-testid":"records-timeline",children:o.map((n,s)=>jsxRuntime.jsx($y,{event:n,isLast:s===o.length-1,styles:t},n.key))})}i(fn,"RequestTimeline");function $y({event:e,isLast:r,styles:t}){let o=e.at?ee(e.at):null,n={...t.title,...e.state==="current"?t.titleCurrent:{},...e.state==="failed"?t.titleFailed:{},...e.state==="upcoming"?t.titleUpcoming:{}};return jsxRuntime.jsxs("li",{style:t.row,"data-testid":`records-timeline-${e.key}`,children:[jsxRuntime.jsxs("div",{style:t.railColumn,"aria-hidden":"true",children:[jsxRuntime.jsx(Uy,{state:e.state,styles:t}),r?null:jsxRuntime.jsx("div",{style:{...t.connector,...e.state==="done"?t.connectorDone:{}}})]}),jsxRuntime.jsxs("div",{style:t.body,children:[jsxRuntime.jsxs("div",{style:t.titleRow,children:[jsxRuntime.jsxs("span",{style:n,children:[e.title,e.state==="current"?jsxRuntime.jsx("span",{"aria-hidden":"true",style:t.now,children:My}):null]}),o&&e.at?jsxRuntime.jsx("time",{dateTime:e.at,style:t.date,children:o}):null]}),e.detail?jsxRuntime.jsx("span",{style:{...t.detail,...e.state==="upcoming"?t.detailUpcoming:{}},children:e.detail}):null,jsxRuntime.jsx("span",{style:t.srOnly,children:zy[e.state]})]})]})}i($y,"TimelineRow");function Uy({state:e,styles:r}){return e==="done"?jsxRuntime.jsx("div",{style:{...r.dot,...r.dotDone},children:"\u2713"}):e==="failed"?jsxRuntime.jsx("div",{style:{...r.dot,...r.dotFailed},children:"!"}):e==="current"?jsxRuntime.jsx("div",{style:{...r.dot,...r.dotCurrent},children:jsxRuntime.jsx("div",{style:r.dotCurrentCore})}):jsxRuntime.jsx("div",{style:{...r.dot,...r.dotUpcoming}})}i(Uy,"Dot");function By(){let e=ye();return react.useMemo(()=>Hy(e),[e])}i(By,"useStyles");function Hy(e){let{color:r,space:t,type:o,radius:n}=e,s=i(c=>`${Math.round(c*o.lineHeight.snug)}px`,"lh"),a={boxSizing:"border-box",width:Wo,height:Wo,borderRadius:Wo/2,display:"flex",alignItems:"center",justifyContent:"center",...D(e,"bold"),fontSize:o.size.caption,lineHeight:s(o.size.caption)};return {list:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column"},row:{display:"flex",alignItems:"flex-start",gap:t.md},railColumn:{display:"flex",flexDirection:"column",alignItems:"center",alignSelf:"stretch",width:Wo,flexShrink:0},body:{flex:1,minWidth:0,paddingTop:t.xs/2,paddingBottom:t.lg+t.xs/2,display:"flex",flexDirection:"column",gap:t.xs/2},titleRow:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:t.sm},dot:a,dotDone:{backgroundColor:r.brand,color:r.onPrimary},dotFailed:{backgroundColor:r.danger,color:r.onDanger},dotCurrent:{border:`2px solid ${r.brandInk}`,backgroundColor:r.surface},dotCurrentCore:{width:10,height:10,borderRadius:5,backgroundColor:r.success},dotUpcoming:{border:`2px solid ${r.borderHairlineGreen}`,backgroundColor:r.surface},connector:{width:2,flex:1,minHeight:22,backgroundColor:r.borderHairlineGreen,margin:"2px 0"},connectorDone:{backgroundColor:r.brand},title:{flex:1,display:"flex",flexWrap:"wrap",alignItems:"center",gap:t.sm,...D(e,"bold"),fontSize:o.size.bodyTight,lineHeight:s(o.size.bodyTight),color:r.text.primary},titleCurrent:{color:r.brandInk},titleFailed:{color:r.danger},titleUpcoming:{color:r.text.muted,...D(e,"regular")},date:{...D(e,"regular"),fontSize:o.size.caption,lineHeight:s(o.size.caption),color:r.text.muted},detail:{...D(e,"regular"),fontSize:o.size.caption,lineHeight:`${Math.round(o.size.caption*o.lineHeight.normal)}px`,color:r.text.muted},now:{display:"inline-flex",alignItems:"center",minHeight:20,padding:`0 ${t.sm}px`,borderRadius:n.pill,backgroundColor:r.scanButtonPink,color:r.onBubbleVet,...D(e,"monoBold"),fontSize:o.size.tiny,lineHeight:s(o.size.tiny),letterSpacing:"0.06em",textTransform:"uppercase"},detailUpcoming:{opacity:.7},srOnly:{position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0}}}i(Hy,"makeStyles");function rc(e){return e.value!==null&&Number.isFinite(e.value)}i(rc,"isFinitePoint");function Go(e){return e.display!==null&&e.display.length>0?e.display:e.value!==null?String(e.value):""}i(Go,"pointDisplay");function tc(e){let r=e.find(C=>C.points.some(rc));if(r===void 0)return null;let t=r.points.filter(rc),o=t[0];if(o===void 0)return null;let n=t.map(C=>C.value),s=Math.min(...n),a=Math.max(...n);s===a&&(s-=1,a+=1);let c=(a-s)*.18,l=s-c,d=a+c,u=d-l,p=6,m=t.length,y=t.map((C,k)=>({xPct:m<=1?50:p+k/(m-1)*(100-2*p),yPct:(d-C.value)/u*100})),g=(d-a)/u*100,f=(d-s)/u*100,v=t.reduce((C,k)=>k.value<C.value?k:C,o),b=t.reduce((C,k)=>k.value>C.value?k:C,o),R=t[t.length-1]??o,h=r.points[r.points.length-1]??R,E=Go(h),S=E.length>0?E:Go(R);return {label:r.label,heroDisplay:S,minDisplay:Go(v),maxDisplay:Go(b),firstDate:aa(r.points[0]?.at??null),lastDate:aa(h.at),points:y,bandTopPct:g,bandBottomPct:f}}i(tc,"buildTrendModel");function jy(e){let r=e.indexOf(":");return r<=0?null:e.slice(0,r)}i(jy,"entityTypeOf");function nc(e,r,t){let o=new Map,n=[];for(let c of e){let l=jy(c.key)??"",d=o.get(l);d===void 0?(o.set(l,[c]),n.push(l)):d.push(c);}let s=r.filter(c=>o.has(c)),a=n.filter(c=>!s.includes(c));return Object.freeze([...s,...a].map(c=>Object.freeze({entityType:c.length>0?c:null,label:c.length>0?t(c):null,series:Object.freeze([...o.get(c)??[]])})))}i(nc,"groupSeriesByEntityType");function oc({series:e}){let r=ye(),t=react.useMemo(()=>Gy(r),[r]),o=react.useMemo(()=>nc(e,To,ct),[e]);return o.length===0?null:jsxRuntime.jsxs("section",{"aria-label":K.careTimeline,style:t.section,children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{style:t.sectionTitle,children:K.careTimeline}),jsxRuntime.jsx("p",{style:t.sectionSub,children:K.careTimelineSub})]}),o.map(n=>jsxRuntime.jsxs("div",{style:t.group,children:[n.label===null?null:jsxRuntime.jsx("p",{style:t.eyebrow,children:n.label}),n.series.map(s=>jsxRuntime.jsx(Vy,{series:s,styles:t},s.key))]},n.entityType??"_"))]})}i(oc,"TrendRangeCard");function Vy({series:e,styles:r}){let t=react.useMemo(()=>tc([e]),[e]);if(t===null){let n=e.points[e.points.length-1]?.display??null;return jsxRuntime.jsxs("div",{style:r.card,children:[jsxRuntime.jsx("p",{style:r.eyebrow,children:e.label}),n!==null&&n.length>0?jsxRuntime.jsx("p",{style:r.hero,children:n}):null]})}return jsxRuntime.jsx(Wy,{model:t,styles:r})}i(Vy,"SeriesChart");function Wy({model:e,styles:r}){let t=e.heroDisplay.length>0?`${e.label}, ${e.heroDisplay}`:e.label,o=Math.max(0,e.bandBottomPct-e.bandTopPct),n=e.points.length-1;return jsxRuntime.jsxs("div",{style:r.card,children:[jsxRuntime.jsxs("div",{role:"img","aria-label":t,children:[jsxRuntime.jsx("p",{style:r.eyebrow,children:e.label}),e.heroDisplay.length>0?jsxRuntime.jsx("p",{style:r.hero,children:e.heroDisplay}):null]}),jsxRuntime.jsxs("div",{"aria-hidden":"true",style:r.plot,children:[e.points.map((s,a)=>jsxRuntime.jsx("div",{style:{...r.guide,left:`${s.xPct}%`}},`g-${a}`)),jsxRuntime.jsx("div",{style:{...r.band,top:`${e.bandTopPct}%`,height:`${o}%`}}),e.points.map((s,a)=>jsxRuntime.jsx("div",{style:{...r.point,...a===n?r.pointLatest:null,left:`${s.xPct}%`,top:`${s.yPct}%`}},`pt-${a}`)),e.maxDisplay.length>0?jsxRuntime.jsx("span",{style:{...r.edgeLabel,top:`${e.bandTopPct}%`},children:e.maxDisplay}):null,e.minDisplay.length>0?jsxRuntime.jsx("span",{style:{...r.edgeLabel,top:`${e.bandBottomPct}%`},children:e.minDisplay}):null]}),e.firstDate.length>0||e.lastDate.length>0?jsxRuntime.jsxs("div",{"aria-hidden":"true",style:r.dates,children:[jsxRuntime.jsx("span",{children:e.firstDate}),jsxRuntime.jsx("span",{children:e.lastDate})]}):null]})}i(Wy,"TrendChart");function Gy(e){let{color:r,space:t,radius:o,type:n}=e,s=i((c,l)=>`${Math.round(c*l)}px`,"lh"),a=t.sm;return {section:{display:"flex",flexDirection:"column",gap:t.lg},sectionTitle:{margin:0,...D(e,"bold"),fontSize:n.size.subtitle,lineHeight:s(n.size.subtitle,n.lineHeight.snug),letterSpacing:"-0.02em",color:r.text.primary},sectionSub:{margin:`${t.xs}px 0 0`,...D(e,"regular"),fontSize:n.size.caption,lineHeight:s(n.size.caption,n.lineHeight.normal),color:r.text.muted},group:{display:"flex",flexDirection:"column",gap:t.sm},card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.sm,padding:t.lg,borderRadius:o.lg,backgroundColor:r.surfaceCream,border:`1px solid ${r.borderRingCream}`},eyebrow:{margin:0,...D(e,"regular"),fontSize:n.size.caption,lineHeight:s(n.size.caption,n.lineHeight.normal),color:r.text.muted,letterSpacing:n.letterSpacing.eyebrow,textTransform:"uppercase",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},hero:{margin:0,...D(e,"bold"),fontSize:n.size.verdict,lineHeight:s(n.size.verdict,n.lineHeight.tight),color:r.text.primary,letterSpacing:n.letterSpacing.tight},plot:{position:"relative",height:t.xxl*3,marginTop:t.xs},guide:{position:"absolute",top:0,bottom:0,width:1,backgroundColor:r.borderHairlineGreen},band:{position:"absolute",left:t.xs,right:t.xs,borderRadius:o.sm,backgroundColor:r.brandSoft},point:{boxSizing:"border-box",position:"absolute",width:a,height:a,marginLeft:-(a/2),marginTop:-(a/2),borderRadius:o.pill,backgroundColor:r.brand,border:`1px solid ${r.surfaceCream}`},pointLatest:{backgroundColor:r.accent,borderColor:r.onAccent},edgeLabel:{position:"absolute",right:0,marginTop:-t.sm,...D(e,"medium"),fontSize:n.size.tiny,lineHeight:s(n.size.tiny,n.lineHeight.tight),color:r.text.muted,whiteSpace:"nowrap"},dates:{display:"flex",justifyContent:"space-between",...D(e,"regular"),fontSize:n.size.tiny,lineHeight:s(n.size.tiny,n.lineHeight.normal),color:r.text.muted}}}i(Gy,"makeStyles");var Xy=300,Jy=900,ac=120,sc=44,lc=40,dc=24,Zy=3;function Tt(e,r,t){let o=et(e,t);switch(o.kind){case "consent_required":return jsxRuntime.jsx(eg,{onGrant:r});case "consent_unavailable":return jsxRuntime.jsx(or,{label:X.consentRequired,glyph:"empty"});case "session_required":return jsxRuntime.jsx(or,{label:X.sessionRequired,glyph:"empty"});case "withheld":return jsxRuntime.jsx(or,{label:X.recordUnavailable,glyph:"withheld"});case "pet_not_found":case "error":return jsxRuntime.jsx(rg,{error:o.error,onRetry:e.refresh});default:return Nr(o)}}i(Tt,"renderErrorFamily");function cc(){let{theme:e,styles:r}=gn(),[t,o]=react.useState(false),n=react.useRef(null);react.useEffect(()=>{let a=setTimeout(()=>o(true),Xy);return ()=>clearTimeout(a)},[]);let s=t&&!e.motion.reducedMotion;return react.useEffect(()=>{let a=n.current;if(!s||a===null||typeof a.animate!="function")return;let c=a.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:Jy,iterations:1/0});return ()=>c.cancel()},[s]),jsxRuntime.jsx("div",{role:"status","aria-busy":"true","aria-label":X.loading,style:r.centered,children:t?jsxRuntime.jsx("div",{ref:n,"aria-hidden":"true",style:r.spinner}):null})}i(cc,"LoadingState");function uc({records:e}){let{styles:r}=gn(),t=e.uploadQueue;if(t.length===0)return null;let o=t.filter(a=>a.status!=="skipped"),n=o.filter(a=>a.status==="done").length,s=Ho(Gd(t));return jsxRuntime.jsxs("div",{style:r.card,"data-testid":"records-upload-queue",children:[s!==null?jsxRuntime.jsx("p",{role:"alert",style:r.errorText,children:s}):null,o.length>0?jsxRuntime.jsx("ul",{"aria-live":"polite","aria-label":e.isUploading?Ht.uploading(n,o.length):Ht.uploaded(n,o.length),style:{listStyle:"none",margin:0,padding:0},children:o.map(a=>{let c=Math.round(a.progress*100);return jsxRuntime.jsxs("li",{style:r.row,"data-testid":`records-upload-file-${a.status}`,children:[jsxRuntime.jsx("span",{style:r.rowLabel,children:a.name??""}),jsxRuntime.jsx("span",{style:r.rowValue,children:Wd(a)}),a.status==="uploading"?jsxRuntime.jsx("progress",{max:100,value:c,style:{width:"100%"}}):null,a.status==="failed"&&a.error?jsxRuntime.jsx("span",{style:r.timelineMeta,children:a.error.displayMessage}):null]},a.key)})}):null]})}i(uc,"UploadQueue");function eg({onGrant:e}){let{styles:r}=gn();return jsxRuntime.jsxs("div",{role:"alert","aria-live":"assertive",style:r.centered,children:[jsxRuntime.jsx("p",{style:r.alertText,children:X.consentRequired}),jsxRuntime.jsx("button",{type:"button",onClick:e,style:r.primaryButton,children:X.allow})]})}i(eg,"ConsentRequiredState");function or({label:e,glyph:r}){let{styles:t}=gn();return jsxRuntime.jsxs("div",{role:"alert","aria-live":"assertive",style:t.centered,children:[jsxRuntime.jsx("div",{"aria-hidden":"true",style:r==="withheld"?t.withheldGlyph:t.emptyGlyph}),jsxRuntime.jsx("p",{style:t.alertText,children:e})]})}i(or,"AlertState");function rg({error:e,onRetry:r}){let{styles:t}=gn();return jsxRuntime.jsxs("div",{role:"alert","aria-live":"assertive",style:t.centered,children:[jsxRuntime.jsx("p",{style:t.errorText,children:e.displayMessage}),e.retryable?jsxRuntime.jsx("button",{type:"button",onClick:r,style:t.primaryButton,children:X.retry}):null]})}i(rg,"ErrorState");function pc({call:e,prompt:r}){let{styles:t}=gn(),o=r.trim().length>0?r:Wn.fallbackPrompt;return jsxRuntime.jsxs("div",{style:t.callCard,children:[jsxRuntime.jsx("p",{style:t.timelineLabel,children:Wn.heading}),jsxRuntime.jsx("p",{style:t.timelineMeta,children:o}),jsxRuntime.jsx("a",{href:e.dial,"aria-label":Wn.callAt(e.phone),style:t.linkButton,"data-testid":"records-call-clinic",children:Wn.call})]})}i(pc,"ClinicCallCard");function gn(){let e=ye(),r=react.useMemo(()=>tg(e),[e]);return {theme:e,styles:r}}i(gn,"useRecordsTheme");function tg(e){let{color:r,space:t,radius:o,type:n,slots:s}=e,a=i((f,v)=>`${Math.round(f*v)}px`,"lh"),c=`1px solid ${r.brandBorder}`,l=Mr(s.recordCard,1),d=tt(s.recordCard),u=i((f,v,b,R="regular")=>({margin:0,...D(e,R),fontSize:f,lineHeight:a(f,v),color:b}),"text"),p=i((f,v,b,R="regular")=>({...u(f,v,b,R),...d}),"inCard"),m={boxSizing:"border-box",minHeight:sc,minWidth:sc,padding:`${t.md}px ${t.xl}px`,borderRadius:o.pill,...D(e,"bold"),fontSize:n.size.body,letterSpacing:n.letterSpacing.tight},y={boxSizing:"border-box",width:lc,height:lc},g=e.brightness==="dark"?r.errorRed:r.danger;return {container:{boxSizing:"border-box",display:"flex",flexDirection:"column",minHeight:ac,height:"100%",backgroundColor:r.background,color:r.text.primary,...D(e,"regular")},body:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",overflowY:"auto"},centered:{boxSizing:"border-box",flex:"1 1 auto",minHeight:ac,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:t.lg,padding:t.xl,textAlign:"center"},spinner:{boxSizing:"border-box",width:dc,height:dc,borderRadius:o.pill,border:`${Zy}px solid ${r.brandSofter}`,borderTopColor:r.brandInk},emptyGlyph:{...y,borderRadius:o.lg,backgroundColor:r.brandSoft,border:c},withheldGlyph:{...y,borderRadius:o.sm,backgroundColor:r.badgeBgCaution,border:`1px solid ${r.cautionAccent}`},alertText:u(n.size.subtitle,n.lineHeight.snug,r.text.secondary),errorText:u(n.size.subtitle,n.lineHeight.snug,g),primaryButton:{...m,border:0,cursor:"pointer",backgroundColor:r.primary,color:r.onPrimary,...Mr(s.primaryButton),...tt(s.primaryButton)},disabledButton:{...m,border:c,cursor:"default",backgroundColor:r.surfaceSubtle,color:r.text.muted},list:{display:"flex",flexDirection:"column",gap:t.md,padding:t.lg},card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.xs,padding:`${t.md}px ${t.lg}px`,borderRadius:o.md,backgroundColor:r.surfaceCream,border:c,...l},cardTitle:{...p(n.size.heading,n.lineHeight.snug,r.text.primary,"bold"),letterSpacing:n.letterSpacing.tight},callCard:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.sm,padding:t.md,borderRadius:o.md,backgroundColor:r.surfaceCream,border:c,...l},linkButton:{...m,display:"inline-flex",alignItems:"center",justifyContent:"center",alignSelf:"flex-start",textDecoration:"none",border:0,backgroundColor:r.primary,color:r.onPrimary,...Mr(s.primaryButton),...tt(s.primaryButton)},timelineLabel:{...p(n.size.subtitle,n.lineHeight.snug,r.text.secondary,"bold")},timelineMeta:p(n.size.bodyTight,n.lineHeight.normal,r.text.muted),row:{display:"flex",justifyContent:"space-between",gap:t.md,padding:`${t.xs}px 0`,borderBottom:`1px solid ${r.borderHairlineGreen}`},rowLabel:p(n.size.body,n.lineHeight.normal,r.text.muted),rowValue:{...p(n.size.body,n.lineHeight.normal,r.text.primary,"medium"),textAlign:"right"},disclaimer:u(n.size.caption,n.lineHeight.normal,r.text.muted)}}i(tg,"makeStyles");var Yo="everfur-record.pdf";function Ko(e){return typeof navigator>"u"||!navigator.clipboard?Promise.reject(new Error("clipboard unavailable")):navigator.clipboard.writeText(e)}i(Ko,"copyText");function ng(e){return typeof e=="object"&&e!==null&&e.name==="AbortError"}i(ng,"isAbort");async function fc(e,r=Ko){let t=typeof navigator>"u"?void 0:navigator;if(t!==void 0&&typeof t.share=="function")try{return await t.share({url:e}),"shared"}catch(o){if(ng(o))return "dismissed"}return await r(e),"copied"}i(fc,"shareLinkInPlace");function og(e,r){let t;try{t=new URL(e,r);}catch{return null}if(t.protocol==="blob:"||t.protocol==="data:")return "download";if(r!==void 0)try{if(new URL(r).origin===t.origin)return "download"}catch{}let o=t.searchParams.get("response-content-disposition");return o!==null&&/^\s*attachment\b/i.test(o)?"attachment":null}i(og,"inPlaceRoute");function ig(){return typeof location>"u"?void 0:location.href}i(ig,"locationHref");function ag(e=typeof window>"u"?void 0:window){if(e===void 0)return false;try{return e.self!==e.top}catch{return true}}i(ag,"isFramedDocument");function mc(e,r){let t=document.createElement("a");t.href=e,t.download=r,t.rel="noopener",t.style.display="none",document.body.appendChild(t);try{t.click();}finally{t.remove();}}i(mc,"clickDownload");var sg=6e4;function lg(e){let r=document.createElement("iframe");r.setAttribute("sandbox","allow-downloads"),r.setAttribute("aria-hidden","true"),r.tabIndex=-1,r.style.display="none",r.src=e,document.body.appendChild(r),setTimeout(()=>r.remove(),sg);}i(lg,"saveThroughNestedFrame");async function bn(e,r,t=ag()){if(typeof document>"u")return false;let o=og(e,ig());if(o==="attachment"&&t)return lg(e),true;if(o!==null)return mc(e,r),true;let n;try{let a=await fetch(e,{credentials:"omit"});if(!a.ok)return !1;n=await a.blob();}catch{return false}let s=URL.createObjectURL(n);try{mc(s,r);}finally{setTimeout(()=>URL.revokeObjectURL(s),1e4);}return true}i(bn,"downloadInPlace");var Sr=K.document,yc=Object.freeze(["medication","vaccination","problem","allergy","procedure","body_weight","vital"]),cg=i((e,r)=>e.getRecordDepth(r),"readDepth"),ug=i(e=>!e.available,"depthEmpty");function pg(e,r){return e.identity.length===0&&e.entities.length===0&&e.forwardLooking.length===0&&(r===null||r.labResults.length===0&&r.physicalExams.length===0&&r.clinicianNotes.length===0)}i(pg,"documentIsEmpty");function Qn(e){let{style:r,className:t,renderPending:o,...n}=Ie(e,["onBack"]),{userRef:s}=se(),{theme:a,styles:c}=V();return jsxRuntime.jsx(Oe,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Fe(n.onBack,Me),children:jsxRuntime.jsxs("div",{className:t,style:{...c.root,backgroundColor:a.color.surface,...r},"data-testid":"record-document-screen",children:[s===null?jsxRuntime.jsx("div",{style:c.body,children:jsxRuntime.jsx(or,{label:X.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(mg,{...n}),jsxRuntime.jsx(Ae,{})]})})}i(Qn,"EverfurRecordDocument");function mg({petRef:e,petName:r,controller:t,consentVersion:o,onBack:n,onOpenUrl:s}){let{theme:a,styles:c}=V(),l=gc(),d=react.useMemo(()=>t?{petRef:e,controller:t}:{petRef:e},[e,t]),u=er(d),p=Hr(e,cg,ug),m=xa(e),y=dt(o,u.consent),g=i(()=>{let C=Zr(o,u.consent);C.length!==0&&u.grantConsent(C,`records-consent-${Date.now().toString(36)}`);},"onGrant"),f=p.value!==null&&!p.value.withheld&&p.value.available?p.value:null,v=u.record,[b,R]=react.useState(false),h=i(()=>{R(false),m.pdfLink().then(C=>{C.ok&&(s?It(s,C.value.downloadUrl,"record_pdf"):bn(C.value.downloadUrl,Yo).then(k=>R(!k)));});},"download"),E,S=false;if(u.status==="loading"||p.status==="loading"&&v!==null)E=jsxRuntime.jsx("div",{"data-testid":"record-document-loading",children:jsxRuntime.jsx(cc,{})});else if(u.status==="error"){let C=et(u,y);E=C.kind==="error"||C.kind==="pet_not_found"?jsxRuntime.jsx(He,{variant:nr(C.error),message:C.error.displayMessage,onAction:C.error.retryable?()=>{u.refresh(),p.refresh();}:void 0,testID:"record-document-error"}):Tt(u,g,y);}else v===null||pg(v,f)?E=jsxRuntime.jsx("p",{style:l.empty,"data-testid":"record-document-empty",children:Sr.empty}):(S=true,E=jsxRuntime.jsx(fg,{record:v,depth:f,petName:r,wordmark:a.meta.displayName}));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ke,{title:Sr.titleFor(r),variant:"document",onBack:n,testID:"record-document-header",right:m.available&&S?jsxRuntime.jsx("button",{type:"button",onClick:h,disabled:m.preparing,"aria-busy":m.preparing,"aria-label":Sr.download,style:c.iconButton,"data-testid":"record-document-download",children:jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"block",width:12,height:12,borderLeft:`2px solid ${a.color.brandInk}`,borderBottom:`2px solid ${a.color.brandInk}`,transform:"rotate(-45deg)"}})}):void 0}),m.error?jsxRuntime.jsx("p",{role:"alert",style:{...c.errorText,padding:`0 ${a.space.lg}px`},children:m.error.displayMessage}):b?jsxRuntime.jsx("p",{role:"alert",style:{...c.errorText,padding:`0 ${a.space.lg}px`},"data-testid":"record-document-save-failed",children:_t(null,"download")}):null,jsxRuntime.jsx("div",{style:c.body,children:E})]})}i(mg,"DocumentBody");function fg({record:e,depth:r,petName:t,wordmark:o}){let n=gc(),s=react.useMemo(()=>{let d=[],u=new Map;for(let y of e.entities){let g=y.category.trim();if(g.length===0)continue;let f=u.get(g);f===void 0?(d.push(g),u.set(g,[y])):f.push(y);}let p=yc.filter(y=>d.includes(y)),m=d.filter(y=>!yc.includes(y));return [...p,...m].map(y=>({type:y,rows:u.get(y)??[]}))},[e.entities]),a=Date.now(),c=i((d,u,p)=>jsxRuntime.jsxs("section",{style:n.section,"data-testid":p,children:[jsxRuntime.jsxs("div",{style:n.sectionHeader,children:[jsxRuntime.jsx("h3",{style:n.sectionTitle,children:d}),jsxRuntime.jsx("span",{style:n.rule})]}),jsxRuntime.jsx("div",{children:u})]},p),"section"),l=i((d,u)=>({...n.row,...d>0?n.rowDivider:{},...u}),"row");return jsxRuntime.jsxs("article",{style:n.page,"data-testid":"record-document",children:[jsxRuntime.jsxs("header",{style:n.letterhead,children:[jsxRuntime.jsx("span",{style:n.wordmark,children:o}),jsxRuntime.jsx("span",{style:n.docTitle,children:Sr.docTitle}),jsxRuntime.jsx("span",{style:n.petName,children:t?.trim()||Sr.namelessPet}),jsxRuntime.jsx("span",{style:n.generated,children:Sr.generated(e.generatedAt)})]}),e.identity.length>0?c(Sr.identity,e.identity.map((d,u)=>jsxRuntime.jsxs("div",{style:l(u),children:[jsxRuntime.jsx("span",{style:n.rowLabel,children:d.label}),jsxRuntime.jsx("span",{style:n.rowValue,children:d.value})]},`${u}:${d.label}`)),"record-document-identity"):null,r&&r.labResults.length>0?c(Sr.labs,r.labResults.map((d,u)=>{let p=nt(d.latest.status),m=ld(d.points[d.points.length-1]??null),y=hr(d.latest.value,d.latest.unit??d.unit,d.latest.qualitativeResult);return jsxRuntime.jsxs("div",{style:l(u,p.outOfRange?n.rowFlag:void 0),children:[jsxRuntime.jsxs("span",{style:n.rowMain,children:[jsxRuntime.jsx("span",{style:n.rowLabel,children:d.name}),jsxRuntime.jsxs("span",{style:n.rowMeta,children:[m?Sr.ref(m):Sr.noRange,d.latest.at?` \xB7 ${ee(d.latest.at)}`:""]})]}),jsxRuntime.jsxs("span",{style:n.rowRight,children:[y!=="-"?jsxRuntime.jsx("span",{style:{...n.rowValue,...p.outOfRange?n.alert:{}},children:y}):null,jsxRuntime.jsx("span",{style:{...n.markerStatus,...p.outOfRange?n.alert:{}},children:p.label})]})]},d.markerId)}),"record-document-labs"):null,s.map(({type:d,rows:u})=>c(ct(d),u.map((p,m)=>{let y=[tn(p.value,p.unit),p.observedAt?ee(p.observedAt):null].filter(g=>g&&g.length>0).join(" \xB7 ");return jsxRuntime.jsx("div",{style:l(m),children:jsxRuntime.jsxs("span",{style:n.rowMain,children:[jsxRuntime.jsx("span",{style:n.rowLabel,children:p.label}),y?jsxRuntime.jsx("span",{style:n.rowMeta,children:y}):null]})},p.key)}),`record-document-${d}`)),e.forwardLooking.length>0?c(Sr.upcomingCare,e.forwardLooking.map((d,u)=>{let p=Nn(d.dueAt,a);return jsxRuntime.jsxs("div",{style:l(u),children:[jsxRuntime.jsxs("span",{style:n.rowMain,children:[jsxRuntime.jsx("span",{style:n.rowLabel,children:d.title}),d.detail?jsxRuntime.jsx("span",{style:n.rowMeta,children:d.detail}):null]}),p?jsxRuntime.jsx("span",{style:{...n.rowValue,...p.overdue?n.alert:{}},children:p.label}):null]},`${d.title}-${u}`)}),"record-document-upcoming"):null,r&&r.physicalExams.length>0?c(Sr.physicalExams,r.physicalExams.map((d,u)=>jsxRuntime.jsxs("div",{style:{...n.block,...u>0?n.rowDivider:{}},children:[d.observedOn?jsxRuntime.jsx("span",{style:n.blockDate,children:ee(d.observedOn)}):null,d.systems.filter(p=>p.finding).map(p=>jsxRuntime.jsxs("div",{style:n.fieldRow,children:[jsxRuntime.jsx("span",{style:n.fieldLabel,children:on(p.system)}),jsxRuntime.jsx("span",{style:n.fieldValue,children:p.finding})]},p.system))]},d.examId)),"record-document-exams"):null,r&&r.clinicianNotes.length>0?c(Sr.clinicianNotes,r.clinicianNotes.map((d,u)=>jsxRuntime.jsxs("div",{style:{...n.block,...u>0?n.rowDivider:{}},children:[d.observedOn?jsxRuntime.jsx("span",{style:n.blockDate,children:ee(d.observedOn)}):null,d.sections.filter(p=>p.text).map((p,m)=>jsxRuntime.jsxs("div",{style:n.noteSection,children:[jsxRuntime.jsx("span",{style:n.noteLabel,children:an(p.section)}),jsxRuntime.jsx("p",{style:n.noteBody,children:p.text})]},`${p.section}-${m}`))]},d.noteId)),"record-document-notes"):null,e.disclaimer.length>0?jsxRuntime.jsx("p",{style:n.disclaimer,children:e.disclaimer}):null]})}i(fg,"RecordDocument");function gc(){let e=ye();return react.useMemo(()=>yg(e),[e])}i(gc,"useDocStyles");function yg(e){let{color:r,space:t,radius:o,type:n}=e,s=i((l,d,u,p="regular")=>({margin:0,...D(e,p),fontSize:l,lineHeight:`${Math.round(l*d)}px`,color:u}),"text"),a=i((l,d)=>({margin:0,...D(e,"mono"),fontSize:l,lineHeight:`${l+t.xs-1}px`,color:d,letterSpacing:n.letterSpacing.eyebrow/2,textTransform:"uppercase"}),"monoText"),c=`1px solid ${r.borderHairlineGreen}`;return {empty:{...s(n.size.body,n.lineHeight.normal,r.text.muted,"medium"),textAlign:"center",padding:`${t.xxl}px ${t.xxl}px`},page:{padding:`0 ${t.lg+t.xs}px ${t.xxl+t.lg}px`,...D(e,"regular")},letterhead:{display:"flex",flexDirection:"column",alignItems:"center",gap:t.xs+t.xs/2,padding:`${t.md}px 0 ${t.lg+t.xs+t.xs/2}px`,borderBottom:`2px solid ${r.brandInk}`,marginBottom:t.sm},wordmark:{...s(n.size.heading,n.lineHeight.snug,r.brandInk,"bold"),letterSpacing:n.letterSpacing.headerBrand},docTitle:{...a(n.size.caption,r.brandInk),marginTop:t.sm+t.xs/2,letterSpacing:n.letterSpacing.eyebrow+.4},petName:s(n.size.verdict+t.xs/2,n.lineHeight.tight,r.text.primary),generated:{...a(n.size.tiny,r.text.muted),textTransform:"none"},section:{marginTop:t.lg+t.xs+t.xs/2},sectionHeader:{display:"flex",alignItems:"center",gap:t.sm+t.xs/2,marginBottom:t.sm},sectionTitle:a(n.size.tiny,r.brandInk),rule:{flex:1,height:1,backgroundColor:r.borderHairlineGreen},row:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:t.md+t.xs/2,padding:`${t.sm+1}px 0`},rowDivider:{borderTop:c},rowFlag:{backgroundColor:r.badgeBgCritical,margin:`0 -${t.sm}px`,padding:`${t.sm+1}px ${t.sm}px`,borderRadius:o.xs},rowMain:{display:"flex",flexDirection:"column",minWidth:0},rowRight:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:t.xs/2},rowLabel:{...s(n.size.body,n.lineHeight.normal,r.text.primary,"medium")},rowValue:{...s(n.size.body,n.lineHeight.normal,r.text.primary,"bold"),textAlign:"right"},alert:{color:r.danger},rowMeta:{marginTop:t.xs/2,...D(e,"mono"),fontSize:n.size.tiny,lineHeight:`${n.size.body}px`,color:r.text.muted},markerStatus:a(n.size.micro,r.text.muted),block:{padding:`${t.sm+t.xs/2}px 0`},blockDate:{...a(n.size.tiny,r.text.muted),display:"block",marginBottom:t.xs+t.xs/2},fieldRow:{display:"flex",alignItems:"flex-start",gap:t.md+t.xs/2,padding:`${t.xs-1}px 0`},fieldLabel:{width:120,flexShrink:0,...s(n.size.bodyTight,n.lineHeight.normal,r.text.muted,"medium")},fieldValue:{flex:1,...s(n.size.bodyTight,n.lineHeight.normal,r.text.primary,"medium")},noteSection:{marginTop:t.sm},noteLabel:{...a(n.size.tiny,r.brandInk),display:"block",marginBottom:t.xs/2},noteBody:s(n.size.bodyTight,n.lineHeight.relaxed,r.text.primary),disclaimer:{...s(n.size.tiny,n.lineHeight.relaxed,r.text.muted),marginTop:o.xl,paddingTop:t.md+t.xs/2,borderTop:c}}}i(yg,"makeDocStyles");var sr=Object.freeze({editA11y:i(e=>`Edit ${e}. Correct or remove this record detail.`,"editA11y"),title:i(e=>`Edit ${e}`,"title"),helper:"Corrects your record. Your vet can still review it.",close:"Close",closeEditorA11y:"Close editor",save:"Save changes",saving:"Saving...",remove:"Remove this detail",removeA11y:i(e=>`Remove ${e}`,"removeA11y"),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 bc(e,r){return Yr(e)?r==="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.":kd(e)?r==="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.":r==="remove"?"Couldn't remove that. Please check your connection and try again.":"Couldn't save that. Please check your connection and try again."}i(bc,"factEditErrorMessage");var bg=Object.freeze({edits:Object.freeze({}),removed:Object.freeze([])});function Fa(e,r){if(Object.keys(r.edits).length===0&&r.removed.length===0)return e;let t=[];for(let o of e){let n=o.canonicalKey??null;if(n!==null&&r.removed.includes(n))continue;let s=n!==null?r.edits[n]:void 0;t.push(s===void 0?o:Object.freeze({...o,value:s}));}return Object.freeze(t)}i(Fa,"applyFactOverlay");function qa(e){return typeof e.canonicalKey=="string"&&e.canonicalKey.length>0}i(qa,"isFactEditable");function hg(){return `records-fact-${Date.now().toString(36)}`}i(hg,"defaultFactKey");function Na(e,r={}){let t=Rr(),{userRef:o}=se(),[n,s]=react.useState(bg),[a,c]=react.useState(false),[l,d]=react.useState(null),u=react.useMemo(()=>({}),[t,e,o]),[p,m]=react.useState(null),y=react.useCallback(()=>m(u),[u]),g=o!==null&&p!==u,f=react.useRef(false),v=react.useRef(r.newIdempotencyKey);v.current=r.newIdempotencyKey;let b=react.useCallback(()=>(v.current??hg)(),[]),R=react.useCallback((C,k,M)=>{if(c(false),!C.ok){if(k(),pt(C.error)){y();return}d(bc(C.error,M));}},[y]),h=react.useCallback(async(C,k)=>{let M=C.canonicalKey??"",T=k.trim();if(f.current||M.length===0||T.length===0)return J(H("validationFailed",{retryable:false}));f.current=true,c(true),d(null);let O=n;s(q=>({...q,edits:{...q.edits,[M]:T}}));let z=await t.editFact(e,{entityType:C.category,canonicalKey:M,correctedFields:fa(C.value,T),idempotencyKey:b()});return f.current=false,R(z,()=>s(O),"edit"),z},[t,e,n,R,b]),E=react.useCallback(async C=>{let k=C.canonicalKey??"";if(f.current||k.length===0)return J(H("validationFailed",{retryable:false}));f.current=true,c(true),d(null);let M=n;s(O=>({...O,removed:[...O.removed,k]}));let T=await t.removeFact(e,{entityType:C.category,canonicalKey:k,idempotencyKey:b()});return f.current=false,R(T,()=>s(M),"remove"),T},[t,e,n,R,b]),S=react.useCallback(()=>d(null),[]);return react.useMemo(()=>({overlay:n,busy:a,error:l,available:g,edit:h,remove:E,clearError:S}),[n,a,l,g,h,E,S])}i(Na,"useRecordFactEdit");var Rg=Object.freeze({vaccination:"Vaccination",medication:"Medication",problem:"Problem",body_weight:"Weight",allergy:"Allergy",vital:"Vital",lab_result:"Lab result",parasite_prevention:"Preventive"}),vg="Given",Cg=/^\d{4}-\d{2}-\d{2}/,Eg=" \xB7 ";function ft(e){let r=e.filter(t=>t!==null&&t.trim().length>0);return r.length>0?r.join(Eg):null}i(ft,"joinDetail");function Sg(e,r){let t=e.label.trim();if(t.length>0)return t;let o=Rg[e.category];return o!==void 0?o:r(e.category)}i(Sg,"rowTitle");function vc(e,r){let t=Sg(e,r.humanize),o=r.formatEntityValue(e.value,e.unit),n=o.trim().length>0?o:null,s=e.observedAt!==null&&e.observedAt.trim().length>0?r.formatRecordsDate(e.observedAt):null,a=s!==null&&s!=="-"?s:null;switch(e.category){case "vaccination":{let c=e.value!==null&&Cg.test(e.value.trim()),l=c?r.formatRecordsDate(e.value):a;return l!==null&&l!=="-"?{title:t,detail:ft([`${vg} ${l}`,c?null:n])}:{title:t,detail:ft([n])}}case "medication":return {title:t,detail:ft([a])};case "problem":return {title:t,detail:ft([a])};case "body_weight":return {title:t,detail:ft([a])};case "allergy":return {title:t,detail:ft([a])};case "vital":return {title:t,detail:ft([n,a])};case "lab_result":return {title:t,detail:ft([n,a])};default:return {title:t,detail:ft([n,a])}}}i(vc,"entityRowSummary");function Xo(e){return e==="above"||e==="below"?"critical":e==="in_range"?"positive":"neutral"}i(Xo,"markerStatusTone");function xg(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"}}i(xg,"markerStatusSpoken");function wg(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}`:""}i(wg,"rangePhrase");function Jo(e,r){let t=r?` ${r}`:"";return e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}${t}`:e.refLow!==null?`\u2265 ${e.refLow}${t}`:e.refHigh!==null?`\u2264 ${e.refHigh}${t}`:"-"}i(Jo,"formatReferenceRange");function La(e,r){let t=r.reviewed?", reviewed by our team":"",o=r.sourceClinic?`, from ${r.sourceClinic}`:"";return `${ee(r.at)}: ${hr(r.value,e.unit,r.qualitativeResult)}, ${xg(r.status)}${wg(r)}${o}${t}`}i(La,"markerPointSpoken");function Xe(e){return e?.trim()||"my pet"}i(Xe,"lead");function Cc(e){let r=e.trim();return /[.!?]$/.test(r)?r:`${r}.`}i(Cc,"clause");function Ec(e,r){let t=r.canonicalName.trim()||"a lab marker",o=[`I'm looking at ${Xe(e)}'s ${t}`],n=[r.latestValueText?.trim(),r.statusText?.trim(),r.trajectoryText?.trim()].filter(Boolean).join(", ");return o[0]+=n?`: ${n}.`:".",r.meaningText?.trim()&&o.push(Cc(r.meaningText)),o.push(`What does this trend tell me, and should I do anything differently for ${Xe(e)}?`),{prompt:o.join(" "),entityRef:{type:"marker",id:r.markerId,payload:{marker:t,...r.statusText?.trim()?{status:r.statusText.trim()}:{}}}}}i(Ec,"buildMarkerAskPrompt");function Sc(e,r,t){let{totalMarkers:o,inRangeCount:n,outOfRangeCount:s,unknownCount:a}=r;if(o===0)return {prompt:`I'm looking at ${Xe(e)}'s lab markers, but there aren't any on file yet. What lab work is worth running for ${Xe(e)}?`,entityRef:{type:"marker_summary",id:t,payload:{total:0}}};let c=a>0?`, ${a} without a reference range`:"";return {prompt:`I'm looking at ${Xe(e)}'s lab markers: ${o} total, ${n} in range, ${s} out of range${c}. What should I focus on?`,entityRef:{type:"marker_summary",id:t,payload:{total:o,inRange:n,outOfRange:s,unknown:a}}}}i(Sc,"buildMarkerSummaryAskPrompt");function xc(e,r){let t=r.canonicalName.trim()||"a lab marker",o=[`${t}: ${r.valueText.trim()}`];r.collectedAt?.trim()&&o.push(`collected ${r.collectedAt.trim()}`),r.sourceClinic?.trim()&&o.push(`from ${r.sourceClinic.trim()}`),r.referenceText?.trim()&&o.push(`reference range ${r.referenceText.trim()}`),r.flagged&&o.push(`flagged ${r.flagged}`);let n={marker:t};return r.flagged&&(n.status=r.flagged),r.reviewed!==void 0&&(n.reviewed=r.reviewed),{prompt:`I'm looking at ${Xe(e)}'s ${o.join(", ")}. What does this mean, and should I be concerned?`,entityRef:{type:"lab_reading",id:r.entityId,payload:n}}}i(xc,"buildMarkerReadingAskPrompt");function wc(e,r,t){let o=r.clinicName?.trim(),n=r.heldItemCount??0,s=n>0?`, ${n} fact${n===1?"":"s"} being verified`:"";return {prompt:`I'm looking at ${Xe(e)}'s records request${o?` to ${o}`:""}, status: ${r.statusLabel.trim()}${s}. What does this status mean, and what happens next?`,entityRef:{type:"records_request",id:t,payload:{status:r.status,held:n,...o?{clinic:o}:{}}}}}i(wc,"buildRecordsRequestAskPrompt");var kg=Object.freeze({vaccination:"vaccine",medication:"medication",body_weight:"weight",vital:"weight"});function kc(e,r,t,o){let n=r.entityTypeLabel.trim()||"record",s=r.title.trim()||n,a=r.detail?.trim();return {prompt:`I'm looking at ${Xe(e)}'s ${n.toLowerCase()}: ${s}${a?`, ${a}`:""}. What does this mean, and what should I keep on top of for ${Xe(e)}?`,entityRef:{type:kg[t]??t,id:o,payload:{kind:n,title:s,...a?{detail:a}:{}}}}}i(kc,"buildEntityRowAskPrompt");function _c(e,r,t){let o=r.filter(a=>a.label.trim()),n={type:"upcoming_care",id:t};if(o.length===0)return {prompt:`I'm looking at ${Xe(e)}'s upcoming care, but nothing is scheduled yet. What preventive care and checkups should ${Xe(e)} be on?`,entityRef:n};let s=[...o].sort((a,c)=>(a.tone==="overdue"?0:1)-(c.tone==="overdue"?0:1)).slice(0,4).map(a=>a.relativeText.trim()?`${a.label.trim()} (${a.relativeText.trim().toLowerCase()})`:a.label.trim());return {prompt:`I'm looking at ${Xe(e)}'s upcoming care: ${s.join(", ")}. What should I prioritize for ${Xe(e)}, and how do I stay on top of these?`,entityRef:n}}i(_c,"buildUpcomingCareAskPrompt");function Pc(e,r,t){let o=[`I'm looking at ${Xe(e)}'s physical exam${r.observedOn?.trim()?` from ${r.observedOn.trim()}`:""}.`],n=r.abnormal.filter(s=>s.system.trim());return n.length>0?(o.push(`Abnormal: ${n.slice(0,6).map(s=>`${s.system.trim()}: ${s.finding.trim()}`).join("; ")}.`),o.push(`What do these findings mean, and what should I follow up on for ${Xe(e)}?`)):o.push(`Everything examined came back normal. What does this tell me about ${Xe(e)}'s health?`),{prompt:o.join(" "),entityRef:{type:"physical_exam",id:t}}}i(Pc,"buildPhysicalExamAskPrompt");function Tc(e,r,t){let o=[`I'm looking at ${Xe(e)}'s visit notes${r.observedOn?.trim()?` from ${r.observedOn.trim()}`:""}.`];for(let n of r.sections.filter(s=>s.text.trim()).slice(0,3))o.push(`${n.label.trim()||"Note"}: ${Cc(n.text)}`);return o.push(`Can you summarize what happened and what I should follow up on for ${Xe(e)}?`),{prompt:o.join(" "),entityRef:{type:"visit",id:t}}}i(Tc,"buildVisitNoteAskPrompt");function Dc(e,r,t){let o=r.scopeLabel.trim()||"a detail",n=r.candidates.filter(a=>a.value.trim()),s=n.slice(0,3).map(a=>`"${a.value.trim()}"${a.clinicName?.trim()?` (${a.clinicName.trim()})`:""}`).join(" vs ");return {prompt:`Two of ${Xe(e)}'s documents disagree on ${o}: ${s}. Which is likely correct, and what should I ask my vet?`,entityRef:{type:"conflict",id:t,payload:{field:o,severity:r.severity,values:n.map(a=>a.value.trim()).join(" | ")}}}}i(Dc,"buildConflictAskPrompt");var Ic='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function $a(e){return e.tagName==="DIALOG"}i($a,"isDialogElement");function _g(e,r){if(r.isDefaultPrevented()||r.nativeEvent.isComposing)return false;let t=r.target;return !(t instanceof Element)||t.closest("dialog")===e}i(_g,"ownsEscape");function Oc(e,r,t,o){let n=o?.escapeAtKeyDown===true,s=react.useRef(null),a=react.useRef(false),c=react.useRef(null),l=react.useRef(t);l.current=t;let d=react.useCallback(()=>{if(!a.current)return;a.current=false;let m=l.current===void 0?c.current:l.current.current;m&&m.isConnected&&m.focus(),(!m||!m.isConnected||document.activeElement===m)&&(c.current=null);},[]);react.useEffect(()=>{if(!e){d();return}let m=s.current;if(!a.current){let g=typeof document>"u"?null:document.activeElement;g!==null&&m!==null&&m.contains(g)||(c.current=g instanceof HTMLElement?g:null);}if(a.current=true,m===null)return;if(!$a(m)){m.contains(document.activeElement)||(m.querySelector(Ic)??m).focus();return}let y=m;typeof y.showModal=="function"?y.open||y.showModal():y.setAttribute("open","");},[e,d]),react.useEffect(()=>d,[d]),react.useEffect(()=>{let m=s.current;if(!e||m===null||!$a(m))return;let y=m;if(typeof y.showModal!="function")return;let g=null,f=i(b=>{b.target instanceof HTMLElement&&(g=b.target);},"onFocusIn"),v=i(()=>{if(!y.isConnected||y.open)return;let b=g;y.showModal(),b!==null&&b.isConnected&&y.contains(b)&&document.activeElement!==b&&b.focus();},"onNativeClose");return y.addEventListener("focusin",f),y.addEventListener("close",v),()=>{y.removeEventListener("focusin",f),y.removeEventListener("close",v);}},[e]);let u=react.useCallback(m=>{let y=s.current;if(y===null)return;if(m.key==="Escape"&&!$a(y)){m.preventDefault(),m.stopPropagation(),r();return}if(m.key==="Escape"&&n&&_g(y,m)){m.preventDefault(),r();return}if(m.key!=="Tab")return;let g=Array.from(y.querySelectorAll(Ic)),f=g[0],v=g[g.length-1];if(!f||!v){m.preventDefault();return}let b=document.activeElement;m.shiftKey&&(b===f||!y.contains(b))?(m.preventDefault(),v.focus()):!m.shiftKey&&(b===v||!y.contains(b))&&(m.preventDefault(),f.focus());},[r,n]),p=react.useCallback(m=>{m.target===m.currentTarget&&(m.preventDefault(),r());},[r]);return {dialogRef:s,onKeyDown:u,onCancel:p}}i(Oc,"useModalDialog");var Tg='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function Dt({label:e,onClose:r,shape:t="modal",returnFocusTo:o,panelStyle:n,testID:s,children:a}){let{styles:c}=V(),l=Oc(true,r,o);react.useEffect(()=>{let u=l.dialogRef.current;u===null||u.contains(document.activeElement)||(u.querySelector(Tg)??u).focus();},[l.dialogRef]);let d=t==="side";return jsxRuntime.jsx("dialog",{ref:l.dialogRef,"aria-label":e,"aria-modal":"true",onCancel:l.onCancel,onKeyDown:l.onKeyDown,style:c.dialogFrame,"data-testid":s,children:jsxRuntime.jsx("div",{style:d?c.dialogScrimSide:c.dialogScrim,onClick:u=>{u.target===u.currentTarget&&r();},"data-testid":s?`${s}-scrim`:void 0,children:jsxRuntime.jsx("div",{style:{...d?c.dialogPanelSide:c.dialogPanel,...n},children:a})})})}i(Dt,"RecordsDialog");function Ac({entity:e,factEdit:r,children:t}){let{theme:o,styles:n}=V(),[s,a]=react.useState(false),c=react.useRef(null),l=e.label.trim()||sr.detail;return jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:o.space.sm},children:[jsxRuntime.jsx("div",{style:{flex:1,minWidth:0},children:t}),jsxRuntime.jsx("button",{ref:c,type:"button",onClick:()=>a(true),"aria-label":sr.editA11y(l),style:n.iconButton,"data-testid":`fact-edit-open-${e.canonicalKey??e.key}`,children:jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"block",width:o.space.md+o.space.xs/2,height:2,backgroundColor:o.color.brand,borderRadius:o.radius.pill,transform:"rotate(-45deg)"}})}),s?jsxRuntime.jsx(Og,{entity:e,title:l,factEdit:r,onClose:()=>a(false),returnFocusTo:c}):null]})}i(Ac,"FactEditAffordance");function Og({entity:e,title:r,factEdit:t,onClose:o,returnFocusTo:n}){let{theme:s,styles:a}=V(),[c,l]=react.useState(e.value??""),[d,u]=react.useState(null),[p,m]=react.useState(false);react.useEffect(()=>{t.clearError();},[t]);let y=c.trim().length>0&&c.trim()!==(e.value??"").trim(),g=d??t.error,f=t.busy,v=i(()=>{if(!y){u(sr.noChange);return}u(null),t.edit(e,c).then(h=>{h.ok&&o();});},"submitEdit"),b=i(()=>{u(null),t.remove(e).then(h=>{h.ok?o():m(false);});},"submitRemove"),R=`fact-edit-${e.key}`;return jsxRuntime.jsxs(Dt,{label:sr.title(r),onClose:o,returnFocusTo:n,testID:"fact-edit-sheet",children:[jsxRuntime.jsxs("div",{style:a.sheetHeader,children:[jsxRuntime.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:s.space.xs},children:[jsxRuntime.jsx("h3",{style:a.sheetTitle,children:sr.title(r)}),jsxRuntime.jsx("p",{role:"status","aria-live":"polite",style:{...a.sheetHelper,...g?a.errorText:{}},children:g??sr.helper})]}),jsxRuntime.jsx("button",{type:"button",onClick:o,"aria-label":sr.close,style:a.iconButton,"data-testid":"fact-edit-close",children:jsxRuntime.jsx("span",{style:a.closeGlyph,"aria-hidden":"true",children:"\xD7"})})]}),jsxRuntime.jsx("label",{htmlFor:R,style:a.fieldLabel,children:e.label}),jsxRuntime.jsx("input",{id:R,style:a.field,value:c,onChange:h=>{l(h.target.value),u(null);},disabled:f,maxLength:512,"data-testid":"fact-edit-field"}),p?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:s.space.sm,padding:s.space.md,borderRadius:s.radius.md,backgroundColor:s.color.badgeBgCritical},"data-testid":"fact-edit-confirm-remove",children:[jsxRuntime.jsx("p",{style:a.bodyText,children:sr.confirmRemove}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:s.space.sm},children:[jsxRuntime.jsx(j,{label:f?sr.removing:sr.removeConfirm,kind:"danger",busy:f,onClick:b,style:{flex:1},testID:"fact-edit-remove-confirm"}),jsxRuntime.jsx(j,{label:sr.keep,kind:"outline",disabled:f,onClick:()=>m(false),style:{flex:1},testID:"fact-edit-remove-cancel"})]})]}):jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:s.space.sm},children:[jsxRuntime.jsx(j,{label:f?sr.saving:sr.save,busy:f,disabled:!y,onClick:v,testID:"fact-edit-save"}),jsxRuntime.jsx("button",{type:"button","aria-label":sr.removeA11y(r),disabled:f,onClick:()=>{u(null),m(true);},style:{...a.pill,...a.pillLink,color:s.color.danger,...f?a.pillDisabled:{}},"data-testid":"fact-edit-remove",children:sr.remove})]})]})}i(Og,"FactEditSheet");function ri({record:e,depth:r,petName:t,showLabs:o=true,onNavigate:n,onAsk:s,factEdit:a,nowMs:c}){let{theme:l,styles:d}=V(),u=c??Date.now(),p=react.useMemo(()=>a?Fa(e.entities,a.overlay):e.entities,[e.entities,a]),m=react.useMemo(()=>{let h=[],E=new Map;for(let S of p){let C=S.category.trim();if(C.length===0)continue;let k=E.get(C);k===void 0?(h.push(C),E.set(C,[S])):k.push(S);}return {order:Do(h),groups:E}},[p]),y=Object.values(e.documents),g=a!==void 0&&a.available,f=i((h,E,S)=>s?jsxRuntime.jsx("button",{type:"button",onClick:()=>{let C=h();s(C.prompt,C.entityRef);},"aria-label":E,style:{...d.pill,...d.pillAsk,marginTop:l.space.lg,alignSelf:"flex-start"},"data-testid":S,children:E}):null,"ask"),v={display:"flex",flexDirection:"column",gap:l.space.lg+l.space.xs},b=i(h=>({...d.row,...h>0?d.rowDivider:{}}),"rowStyle"),R={...d.card,padding:`${l.space.md}px ${l.space.lg}px`,display:"flex",flexDirection:"column"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{style:v,children:[r&&r.conflicts.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-conflicts",children:[jsxRuntime.jsx($r,{title:K.needsAttention,count:r.conflicts.length}),[...r.conflicts].sort((h,E)=>Io(h.severity).rank-Io(E.severity).rank).map(h=>{let E=Io(h.severity),S=ot(h.field??h.entityType);return jsxRuntime.jsxs("div",{style:{...R,borderColor:d.chipTones[E.tone].color,gap:l.space.sm},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:l.space.sm},children:[jsxRuntime.jsx("span",{style:{...d.rowTitle,...D(l,"bold"),flex:1},children:E.label}),jsxRuntime.jsx(br,{label:S,tone:E.tone})]}),jsxRuntime.jsx("p",{style:d.rowDetail,children:K.conflictSub}),h.candidates.map((C,k)=>jsxRuntime.jsxs("div",{style:{borderTop:`1px solid ${l.color.borderHairlineGreen}`,paddingTop:l.space.sm},children:[jsxRuntime.jsx("p",{style:d.rowTitle,children:C.value}),jsxRuntime.jsx("p",{style:d.rowMuted,children:[C.docId?e.documents[C.docId]?.title??K.uploadedDocument:K.uploadedDocument,C.collectedAt?ee(C.collectedAt):null].filter(Boolean).join(" \xB7 ")})]},k)),f(()=>Dc(t,{scopeLabel:S,severity:h.severity,candidates:h.candidates.map(C=>({value:C.value,clinicName:C.docId?e.documents[C.docId]?.title??null:null}))},h.conflictId),K.askConflict,`records-ask-conflict-${h.conflictId}`)]},h.conflictId)})]}):null,r?.completeness?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-completeness",children:[jsxRuntime.jsx($r,{title:K.whatsOnFile}),jsxRuntime.jsxs("div",{style:d.card,children:[jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:l.space.sm,padding:`${l.space.md}px 0`},children:[[K.coverage.labs,r.completeness.hasLabHistory],[K.coverage.vaccines,r.completeness.hasVaccinationHistory],[K.coverage.weight,r.completeness.hasWeightHistory],[K.coverage.vitals,r.completeness.hasVitalsHistory],[K.coverage.exams,r.completeness.hasPhysicalExamHistory],[K.coverage.procedures,r.completeness.hasProcedureHistory],[K.coverage.genetics,r.completeness.hasGeneticHistory],[K.coverage.parasite,r.completeness.hasParasitePreventionHistory],[K.coverage.reproductive,r.completeness.hasReproductiveHistory]].map(([h,E])=>jsxRuntime.jsx("span",{"aria-label":`${h}: ${E?K.onFile:K.noneOnFile}`,style:{...d.chip,...E?d.chipTones.positive:{backgroundColor:l.color.badgeBgNeutral,color:l.color.text.muted},fontSize:l.type.size.caption},children:h},h))}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:l.space.sm,paddingBottom:l.space.md},children:[jsxRuntime.jsx("span",{style:{...d.rowDetail,flex:1,marginTop:0},children:K.documentsOnFile(r.completeness.documentsIngested)}),r.completeness.documentsInReview>0?jsxRuntime.jsx(br,{label:K.inReviewChip(r.completeness.documentsInReview),tone:"warning"}):null,Ba(r.completeness.heldTotal,r.completeness.entitiesPendingReview)>0?jsxRuntime.jsx("span",{"aria-label":K.beingVerifiedA11y(Ba(r.completeness.heldTotal,r.completeness.entitiesPendingReview)),children:jsxRuntime.jsx(br,{label:K.beingVerified(Ba(r.completeness.heldTotal,r.completeness.entitiesPendingReview)),tone:"warning"})}):null]}),r.completeness.earliestRecordAt||r.completeness.latestRecordAt?jsxRuntime.jsx("p",{style:{...d.rowDetail,paddingBottom:l.space.md},children:K.dateRange(r.completeness.earliestRecordAt,r.completeness.latestRecordAt)}):null,Object.entries(r.completeness.entitiesPendingReview).filter(([,h])=>h>0).length>0?jsxRuntime.jsxs("p",{style:{...d.rowMuted,paddingBottom:l.space.md},children:[K.pendingReview,Object.entries(r.completeness.entitiesPendingReview).filter(([,h])=>h>0).map(([h,E])=>`${ct(h)} (${E})`).join(", ")]}):null]})]}):null,y.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-documents",children:[jsxRuntime.jsx($r,{title:K.documents,count:y.length}),jsxRuntime.jsx("ul",{style:d.card,children:y.map((h,E)=>{let S=h.title?.trim()||K.uploadedDocument,C=K.documentMeta(h.pageCount,h.receivedAt),k=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:d.rowMain,children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:S}),C?jsxRuntime.jsx("span",{style:{...d.rowDetail,display:"block"},children:C}):null]}),n?jsxRuntime.jsx(kt,{}):null]});return jsxRuntime.jsx("li",{style:b(E),children:n?jsxRuntime.jsx("button",{type:"button",onClick:()=>n({name:"contributions",docId:h.docId}),"aria-label":K.documentRowA11y(S),style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:l.space.md,width:"100%",background:"transparent",border:0,padding:0,cursor:"pointer",textAlign:"left",font:"inherit",color:"inherit"},"data-testid":`records-document-row-${h.docId}`,children:k}):k},h.docId)})})]}):null,e.identity.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-identity",children:[jsxRuntime.jsx($r,{title:K.identity}),jsxRuntime.jsx("dl",{style:d.card,children:e.identity.map((h,E)=>jsxRuntime.jsxs("div",{style:b(E),children:[jsxRuntime.jsx("dt",{style:{...d.rowDetail,...D(l,"medium"),marginTop:0},children:h.label}),jsxRuntime.jsx("dd",{style:{...d.rowTitle,margin:0,textAlign:"right"},children:rd(h.value)})]},`${E}:${h.label}`))})]}):null,jsxRuntime.jsx(oc,{series:e.entitySeries}),e.forwardLooking.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-upcoming",children:[jsxRuntime.jsx($r,{title:K.upcomingCare,count:e.forwardLooking.length}),jsxRuntime.jsx("ul",{style:d.card,children:e.forwardLooking.map((h,E)=>{let S=Nn(h.dueAt,u);return jsxRuntime.jsxs("li",{style:b(E),children:[jsxRuntime.jsxs("span",{style:d.rowMain,children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:h.title}),h.detail?jsxRuntime.jsx("span",{style:{...d.rowDetail,display:"block"},children:h.detail}):null]}),S?jsxRuntime.jsx(br,{label:S.label,tone:S.overdue?"critical":"info"}):null]},`${h.title}-${E}`)})}),f(()=>_c(t,e.forwardLooking.map(h=>{let E=Nn(h.dueAt,u);return {label:h.title,relativeText:E?.label??"",tone:E?.overdue?"overdue":"upcoming"}}),e.petRef),K.askUpcomingCare,"records-ask-upcoming-care")]}):null,m.order.map(h=>{let E=m.groups.get(h)??[];if(E.length===0)return null;let S=ct(h);return jsxRuntime.jsxs("section",{style:d.section,"data-testid":`record-section-${h}`,children:[jsxRuntime.jsx($r,{title:S,count:E.length}),jsxRuntime.jsx("ul",{style:d.card,children:E.map((C,k)=>{let M=vc(C,{formatEntityValue:tn,formatRecordsDate:ee,humanize:ot}),T=M.detail,O=jsxRuntime.jsxs("div",{style:b(k),children:[jsxRuntime.jsxs("div",{style:{...d.rowMain,display:"flex",flexDirection:"column"},children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:M.title}),T?jsxRuntime.jsx("span",{style:d.rowDetail,children:T}):null,f(()=>kc(t,{entityTypeLabel:S,title:M.title,detail:T},h,C.key),K.askEverfur,`records-ask-entity-${C.key}`)]}),C.status?jsxRuntime.jsx(br,{label:ot(C.status)}):null]});return jsxRuntime.jsx("li",{children:g&&qa(C)&&a?jsxRuntime.jsx(Ac,{entity:C,factEdit:a,children:O}):O},C.key)})})]},h)}),r&&r.physicalExams.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-exams",children:[jsxRuntime.jsx($r,{title:K.physicalExams,count:r.physicalExams.length}),r.physicalExams.map(h=>jsxRuntime.jsxs("div",{style:R,children:[jsxRuntime.jsx("h4",{style:{...d.rowTitle,paddingTop:l.space.sm},children:h.observedOn?ee(h.observedOn):ge.exam}),jsxRuntime.jsx("ul",{style:d.plainList,children:h.systems.map((E,S)=>{let C=E.findingStatus==="abnormal",k=C?ge.abnormal:E.findingStatus==="not_examined"?ge.notExamined:ge.normal;return jsxRuntime.jsxs("li",{style:b(S),children:[jsxRuntime.jsxs("span",{style:d.rowMain,children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:on(E.system)}),C&&E.finding?jsxRuntime.jsx("span",{style:{...d.rowDetail,display:"block"},children:E.finding}):null]}),jsxRuntime.jsx(br,{label:k,tone:C?"warning":E.findingStatus==="not_examined"?"neutral":"positive"})]},E.system)})}),f(()=>Pc(t,{observedOn:h.observedOn?ee(h.observedOn):null,abnormal:h.systems.filter(E=>E.findingStatus==="abnormal").map(E=>({system:on(E.system),finding:E.finding??""}))},h.examId),K.askExam,`records-ask-exam-${h.examId}`)]},h.examId))]}):null,r&&r.clinicianNotes.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-notes",children:[jsxRuntime.jsx($r,{title:K.visitNotes,count:r.clinicianNotes.length}),r.clinicianNotes.map(h=>jsxRuntime.jsxs("div",{style:R,children:[jsxRuntime.jsx("h4",{style:{...d.rowTitle,paddingTop:l.space.sm},children:h.observedOn?ee(h.observedOn):ge.visitNote}),jsxRuntime.jsx("dl",{style:d.plainList,children:h.sections.map((E,S)=>jsxRuntime.jsxs("div",{style:{padding:`${l.space.md}px 0`,...S>0?d.rowDivider:{}},children:[jsxRuntime.jsx("dt",{style:{...d.rowDetail,...D(l,"bold"),marginTop:0,textTransform:"uppercase"},children:an(E.section)}),jsxRuntime.jsx("dd",{style:{...d.bodyText,marginLeft:0,...E.text?{}:{color:l.color.text.muted,fontStyle:"italic"}},children:E.text||ge.notRecorded})]},`${E.section}:${S}`))}),f(()=>Tc(t,{observedOn:h.observedOn?ee(h.observedOn):null,sections:h.sections.map(E=>({label:an(E.section),text:E.text}))},h.noteId),K.askVisit,`records-ask-note-${h.noteId}`)]},h.noteId))]}):null,o&&r&&r.labResults.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-labs",children:[jsxRuntime.jsx($r,{title:K.labResults,count:r.labResults.length}),jsxRuntime.jsx("ul",{style:d.card,children:r.labResults.map((h,E)=>{let S=nt(h.latest.status),C=sa(h.latest.at,h.trajectory,h.points.length);return jsxRuntime.jsxs("li",{style:b(E),children:[jsxRuntime.jsxs("span",{style:{...d.rowMain,display:"flex",flexDirection:"column"},children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:h.name}),jsxRuntime.jsx("span",{style:d.rowValue,children:hr(h.latest.value,h.latest.unit,h.latest.qualitativeResult)}),C?jsxRuntime.jsx("span",{style:d.rowDetail,children:C}):null]}),jsxRuntime.jsx(br,{label:S.label,tone:Xo(h.latest.status)})]},h.markerId)})})]}):null,r&&r.encounters.length>0?jsxRuntime.jsxs("section",{style:d.section,"data-testid":"record-section-visits",children:[jsxRuntime.jsx($r,{title:K.visits,count:r.encounters.length}),jsxRuntime.jsx("ul",{style:d.card,children:r.encounters.map((h,E)=>{let S=[h.date?ee(h.date):null,h.clinicName,h.veterinarian].filter(C=>C&&C!=="-").join(" \xB7 ");return jsxRuntime.jsx("li",{style:b(E),children:jsxRuntime.jsxs("span",{style:d.rowMain,children:[jsxRuntime.jsx("span",{style:d.rowTitle,children:h.type?ot(h.type):ge.visit}),S?jsxRuntime.jsx("span",{style:{...d.rowDetail,display:"block"},children:S}):null]})},h.encounterId)})})]}):null]}),jsxRuntime.jsx(wt,{disclaimer:e.disclaimer})]})}i(ri,"RecordSections");function Ba(e,r){return e>0?e:Object.values(r).reduce((t,o)=>t+o,0)}i(Ba,"heldCount");function Nc({petRef:e,petName:r,onClose:t,onNavigate:o,onOpenUrl:n,onCopy:s,returnFocusTo:a}){let{theme:c,styles:l}=V(),d=Ea(e),[u,p]=react.useState(null),[m,y]=react.useState(null),[g,f]=react.useState("vet"),[v,b]=react.useState(""),R=react.useId(),h=d.available&&!d.consentRequired,E=d.shareAudiences.length>0,S=d.shareAudiences.find(x=>x.audience===g)??null,C=S!==null?dd(S,d.features):[],k=i((x,L)=>{if(n){It(n,x,L).then(F=>{F.ok||p(Q.toasts.shareSheet);});return}if(L==="share_link"){fc(x,s??Ko).then(F=>{F==="copied"&&p(Q.toasts.copied);},()=>p(Q.toasts.shareSheet));return}bn(x,Yo).then(F=>{F||p(_t(null,"download"));});},"open"),M=i(()=>{p(null),d.createLink(E?g:void 0).then(x=>{x.ok?k(x.value.shareUrl,"share_link"):p(_t(x.error,"create"));});},"onCreateLink"),T=i(x=>{if(x?.preventDefault(),d.sending)return;p(null);let L=v.trim();if(L.length===0){p(Q.addEmailFor(r));return}if(!ao(L)){p(Q.emailInvalid);return}d.sendEmail({recipientEmail:L,recipientKind:g}).then(F=>{F.ok?(b(""),p(Q.toasts.sentTo(L))):p(_t(F.error,"email"));});},"onSend"),O=i(()=>{p(null),d.pdfLink().then(x=>{x.ok?k(x.value.downloadUrl,"record_pdf"):p(_t(x.error,"download"));});},"onDownload"),z=i(x=>{x.shareUrl!==null&&It(s??Ko,x.shareUrl).then(L=>p(L.ok?Q.toasts.copied:Q.toasts.copyFailed));},"onCopyRow"),q=i(x=>{d.revoke(x).then(L=>{y(null),p(L.ok?Q.toasts.turnedOff:_t(L.error,"revoke"));});},"onConfirmRevoke"),N={display:"flex",flexDirection:"column",gap:c.space.sm,padding:c.space.md,borderRadius:c.radius.md,backgroundColor:c.color.surfaceCream,border:`1px solid ${c.color.brandBorder}`},B=i(x=>({boxSizing:"border-box",flex:"1 1 0",minWidth:0,minHeight:qt,display:"flex",alignItems:"center",gap:c.space.sm,padding:`${c.space.sm}px ${c.space.md}px`,borderRadius:c.radius.md,cursor:"pointer",border:x?`1.5px solid ${c.color.brandInk}`:`1px solid ${c.color.borderHairlineGreen}`,backgroundColor:x?c.color.brandSoft:c.color.surface,...l.rowTitle,...D(c,x?"bold":"medium")}),"choice");return jsxRuntime.jsxs(Dt,{label:Q.titleFor(r),onClose:t,shape:"side",returnFocusTo:a,testID:"share-record-sheet",children:[jsxRuntime.jsxs("div",{style:l.sheetHeader,children:[jsxRuntime.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:c.space.xs},children:[jsxRuntime.jsx("h3",{style:l.sheetTitle,children:Q.titleFor(r)}),jsxRuntime.jsx("p",{style:l.sheetHelper,children:E?Q.leadWebFor(r):Q.helper})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":Q.close,style:l.iconButton,"data-testid":"share-record-close",children:jsxRuntime.jsx("span",{style:l.closeGlyph,"aria-hidden":"true",children:"\xD7"})})]}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c.space.sm},children:[o?jsxRuntime.jsx(j,{label:Q.viewDocument,onClick:()=>{t(),o({name:"document"});},testID:"share-view-document"}):null,h?jsxRuntime.jsxs("form",{onSubmit:T,noValidate:true,style:{display:"flex",flexDirection:"column",gap:c.space.md,margin:0},"data-testid":"share-email-form",children:[jsxRuntime.jsxs("fieldset",{style:{border:0,margin:0,padding:0,minWidth:0},children:[jsxRuntime.jsx("legend",{style:{...l.fieldLabel,padding:0},children:Q.audienceLabel}),jsxRuntime.jsx("div",{style:{display:"flex",gap:c.space.sm},children:Kt.map(x=>jsxRuntime.jsxs("label",{style:B(g===x),children:[jsxRuntime.jsx("input",{type:"radio",name:R,value:x,checked:g===x,onChange:()=>f(x),style:{margin:0,accentColor:c.color.brandInk},"data-testid":`share-audience-${x}`}),Q.audiences[x]]},x))})]}),E&&C.length>0?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c.space.xs},"data-testid":"share-included",children:[jsxRuntime.jsx("p",{style:{...l.fieldLabel,margin:0},children:Q.included}),jsxRuntime.jsx("ul",{style:{...l.bodyText,margin:0,paddingLeft:c.space.lg},children:C.map(x=>jsxRuntime.jsx("li",{children:x},x))})]}):null,jsxRuntime.jsxs("label",{style:{...l.fieldLabel,margin:0},children:[Q.sendTo,jsxRuntime.jsx("input",{type:"email",style:{...l.field,marginTop:c.space.xs},placeholder:Q.sendToPlaceholder,value:v,maxLength:fi,autoComplete:"email",disabled:d.sending,onChange:x=>b(x.target.value),"data-testid":"share-email-input"})]}),jsxRuntime.jsx(j,{label:d.sending?Q.sending:Q.send,busy:d.sending,onClick:()=>T(),testID:"share-email-send"})]}):null,h?jsxRuntime.jsx(j,{label:d.creating?Q.creatingLink:Q.createLink,kind:"outline",busy:d.creating,onClick:M,testID:"share-create-link"}):null,h?jsxRuntime.jsx(j,{label:d.preparingPdf?Q.preparingPdf:Q.downloadPdf,kind:"outline",busy:d.preparingPdf,onClick:O,testID:"share-download-pdf"}):null,h?jsxRuntime.jsx("p",{style:{...l.muted,textAlign:"center"},"data-testid":"share-link-terms",children:Q.linkTerms}):null]}),d.consentRequired?jsxRuntime.jsxs("div",{style:N,"data-testid":"share-consent-off",children:[jsxRuntime.jsx("p",{style:l.rowTitle,children:Q.consentOffTitle}),jsxRuntime.jsx("p",{style:l.muted,children:Q.consentOffBody}),jsxRuntime.jsx(j,{label:Q.retry,kind:"outline",onClick:d.refresh,testID:"share-consent-retry"})]}):null,u?jsxRuntime.jsx("p",{role:"status","aria-live":"polite",style:l.infoNote,"data-testid":"share-notice",children:u}):null,Vd(d)?jsxRuntime.jsxs("section",{"aria-label":Q.activeLinks,style:{display:"flex",flexDirection:"column",gap:c.space.sm},children:[jsxRuntime.jsx("h4",{style:{...l.fieldLabel,...D(c,"bold"),textTransform:"uppercase"},children:Q.activeLinks}),d.status==="loading"?jsxRuntime.jsx(yd,{testID:"share-record-loading"}):d.status==="error"?jsxRuntime.jsxs("div",{style:N,"data-testid":"share-record-error",children:[jsxRuntime.jsx("p",{style:l.rowTitle,children:Q.errorTitle}),jsxRuntime.jsx("p",{style:l.muted,children:Q.errorBody}),jsxRuntime.jsx(j,{label:Q.retry,kind:"outline",onClick:d.refresh,testID:"share-record-retry"})]}):d.rows.length===0?jsxRuntime.jsxs("div",{style:N,"data-testid":"share-record-empty",children:[jsxRuntime.jsx("p",{style:l.rowTitle,children:Q.emptyTitle}),jsxRuntime.jsx("p",{style:l.muted,children:Q.emptyBody})]}):jsxRuntime.jsx("ul",{style:{...l.plainList,gap:c.space.md},children:d.rows.map(x=>jsxRuntime.jsxs("li",{style:{...N},"data-testid":`share-row-${x.shareId}`,children:[jsxRuntime.jsxs("div",{"aria-label":x.a11yLabel,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:c.space.sm},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:c.space.sm,height:c.space.sm,borderRadius:c.space.xs,backgroundColor:x.active?c.color.success:c.color.text.muted}}),jsxRuntime.jsx("span",{style:{...l.rowTitle,...D(c,"bold")},children:x.statusLabel}),jsxRuntime.jsx("span",{style:l.muted,children:x.expiryLabel})]}),x.createdLabel?jsxRuntime.jsx("p",{style:l.muted,children:x.createdLabel}):null]}),m===x.shareId?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c.space.sm},"data-testid":`share-revoke-confirm-${x.shareId}`,children:[jsxRuntime.jsx("p",{style:l.bodyText,children:Q.confirmTurnOff}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:c.space.sm},children:[jsxRuntime.jsx(j,{label:d.revokingId===x.shareId?Q.turningOff:Q.turnOff,kind:"danger",busy:d.revokingId===x.shareId,onClick:()=>q(x.shareId),testID:`share-revoke-do-${x.shareId}`}),jsxRuntime.jsx(j,{label:Q.keep,kind:"outline",disabled:d.revokingId===x.shareId,onClick:()=>y(null),testID:`share-revoke-cancel-${x.shareId}`})]})]}):jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:c.space.sm},children:[jsxRuntime.jsx(j,{label:Q.copyLink,kind:"outline",disabled:x.shareUrl===null,ariaLabel:Q.copyLinkA11y(x.actionContext),onClick:()=>z(x),testID:`share-copy-${x.shareId}`}),jsxRuntime.jsx(j,{label:Q.turnOff,kind:"danger",ariaLabel:Q.turnOffA11y(x.actionContext),onClick:()=>y(x.shareId),testID:`share-ask-revoke-${x.shareId}`})]})]},x.shareId))})]}):null]})}i(Nc,"ShareSheet");var Lg=i((e,r)=>e.getRecordDepth(r),"readDepth"),zg=i(e=>!e.available,"depthEmpty");function Xn(e){let{style:r,className:t,renderPending:o,...n}=Ie(e,["onNavigate","onBack","onAsk"]),{userRef:s}=se(),{styles:a}=V();return jsxRuntime.jsx(Oe,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Fe(n.onBack,Me),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...r},"data-testid":"everfur-record-screen",children:[s===null?jsxRuntime.jsx("div",{style:a.body,children:jsxRuntime.jsx(or,{label:X.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(Mg,{...n}),jsxRuntime.jsx(Ae,{})]})})}i(Xn,"EverfurRecordDetail");function Mg({petRef:e,petName:r,controller:t,consentVersion:o,onNavigate:n,onBack:s,onAsk:a,onOpenUrl:c,onCopy:l}){let{theme:d,styles:u}=V(),p=react.useMemo(()=>t?{petRef:e,controller:t}:{petRef:e},[e,t]),m=er(p),y=Hr(e,Lg,zg),g=Na(e),f=Sa(e),[v,b]=react.useState(false),R=xt(),h=react.useRef(null),E=dt(o,m.consent),S=i(()=>{let z=Zr(o,m.consent);z.length!==0&&m.grantConsent(z,`records-consent-${Date.now().toString(36)}`);},"onGrant"),C=y.value!==null&&!y.value.withheld&&y.value.available?y.value:null,k=m.record,M=i(()=>{m.refresh(),y.refresh();},"retry"),T=n!==void 0||f.lit===true,O;if(m.status==="loading"||y.status==="loading"&&k!==null&&!k.isEmpty)O=jsxRuntime.jsx(sn,{testID:"everfur-record-loading"});else if(m.status==="error"){let z=et(m,E);O=z.kind==="error"||z.kind==="pet_not_found"?jsxRuntime.jsx(He,{variant:nr(z.error),message:z.error.displayMessage,onAction:z.error.retryable?M:void 0,testID:"everfur-record-error"}):Tt(m,S,E);}else if(k===null||k.isEmpty){let z=C?.completeness?.documentsInReview??0;O=jsxRuntime.jsxs("div",{style:u.content,"data-testid":"everfur-record-empty",children:[jsxRuntime.jsx(He,{variant:"no_records",message:z>0?K.inReview(z):void 0}),jsxRuntime.jsx(wt,{disclaimer:k?.disclaimer??""})]});}else O=jsxRuntime.jsx("div",{ref:R,style:{...u.content,gap:d.space.lg+d.space.xs,paddingBottom:d.space.xxl+d.space.sm},"data-testid":"everfur-record",children:jsxRuntime.jsx(ri,{record:k,depth:C,petName:r,onNavigate:n,onAsk:a,factEdit:g})});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ke,{title:K.title,onBack:s,testID:"everfur-record-header",right:T||n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n?jsxRuntime.jsx("button",{type:"button",onClick:()=>n({name:"clinicBatch"}),"aria-label":K.requestClinicsA11y,style:u.iconButton,"data-testid":"everfur-record-request-clinics",children:jsxRuntime.jsx(ia,{name:"send",color:d.color.brandInk})}):null,T?jsxRuntime.jsx("button",{ref:h,type:"button",onClick:()=>b(true),"aria-label":Q.openA11yFor(r),style:u.iconButton,"data-testid":"everfur-record-share",children:jsxRuntime.jsx(ia,{name:"share2",color:d.color.brandInk})}):null]}):void 0}),jsxRuntime.jsx("div",{style:u.body,children:O}),v?jsxRuntime.jsx(Nc,{petRef:e,petName:r,onClose:()=>b(false),returnFocusTo:h,onNavigate:n,...c?{onOpenUrl:c}:{},...l?{onCopy:l}:{}}):null]})}i(Mg,"RecordBody");var oi=Object.freeze({download:"Download",downloadA11y:i(e=>`Download, ${e}`,"downloadA11y"),listA11y:"You added these records"});function $g(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i($g,"formatBytes");function Ug(e){let r=e?.trim();return r?r.toUpperCase():null}i(Ug,"formatLabel");function Ha(e){return Object.freeze(e.map(r=>{let t=Ug(r.docFormat),o=r.receivedAt?ee(r.receivedAt):null,n=r.fileName??t??o??r.sourceDocId,a=[r.fileName!==null&&t!==null&&r.fileName.toUpperCase().endsWith(`.${t}`)||n===t?null:t,r.byteSize!==null?$g(r.byteSize):null,n===o?null:o].filter(c=>!!c).join(" \xB7 ");return Object.freeze({key:r.sourceDocId,title:n,meta:a||null,downloadUrl:r.downloadUrl})}))}i(Ha,"requestDocumentRows");function zc(e){let r=e.fileName?.trim()||e.sourceDocId,t=e.docFormat?.trim().toLowerCase().replace(/^\./,"")??"";return t.length===0||r.toLowerCase().endsWith(`.${t}`)?r:`${r}.${t}`}i(zc,"requestDocumentFileName");function Va(e,r={}){let t=r.enabled??true,o=Rr(),{userRef:n}=se(),[s,a]=react.useState(null),[c,l]=react.useState(t),[d,u]=react.useState(null),p=react.useRef(0),m=react.useRef(true),y=react.useCallback(async()=>{let b=p.current+=1;if(!t||n===null){a(null),u(null),l(false);return}l(true),u(null);let R=await o.listRequestDocuments(e);b!==p.current||!m.current||(R.ok?a(R.value):(a(null),u(R.error)),l(false));},[o,t,e,n]);react.useEffect(()=>(m.current=true,y(),()=>{m.current=false,p.current+=1;}),[y]);let g=react.useMemo(()=>s===null?[]:Ha(s),[s]),f=react.useCallback(()=>{y();},[y]),v=c?"loading":d!==null?"error":g.length===0?"empty":"populated";return react.useMemo(()=>({status:v,rows:g,error:d,refresh:f}),[v,g,d,f])}i(Va,"useRequestDocuments");function Jn({requestId:e,open:r=true,onOpenUrl:t,testID:o="records-request-documents"}){let{theme:n,styles:s}=V(),a=Va(e,{enabled:r}),c=Rr(),[l,d]=react.useState(null),[u,p]=react.useState(null),m=react.useRef(true);react.useEffect(()=>(m.current=true,()=>{m.current=false;}),[]);let y=i(async g=>{d(g.key),p(null);let f=await c.listRequestDocuments(e),v=f.ok?f.value.find(R=>R.sourceDocId===g.key)??null:null,b=v===null;v!==null&&m.current&&(t?await It(t,v.downloadUrl,"request_document"):b=!await bn(v.downloadUrl,zc(v))),m.current&&(d(null),b&&p(g.key));},"save");return r?a.status==="loading"?jsxRuntime.jsx("div",{style:{paddingTop:n.space.sm},"aria-busy":"true","data-testid":`${o}-loading`,children:jsxRuntime.jsx(ve,{width:"100%",height:n.space.lg+n.space.md})}):a.status==="error"?jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:n.space.sm,paddingTop:n.space.sm},"data-testid":`${o}-error`,children:[jsxRuntime.jsx("p",{style:{...s.muted,margin:0},role:"alert",children:a.error?.displayMessage??""}),a.error?.retryable===true?jsxRuntime.jsx(j,{label:X.retry,kind:"outline",onClick:a.refresh,testID:`${o}-retry`}):null]}):a.status==="empty"?null:jsxRuntime.jsx("ul",{"aria-label":oi.listA11y,style:{...s.plainList,paddingTop:n.space.sm},"data-testid":o,children:a.rows.map((g,f)=>jsxRuntime.jsxs("li",{style:Vg(n.space.sm,f===0?null:n.color.brandBorder),children:[jsxRuntime.jsxs("div",{style:{minWidth:0},children:[jsxRuntime.jsx("p",{style:{...s.rowTitle,margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title}),g.meta!==null?jsxRuntime.jsx("p",{style:{...s.muted,margin:0,fontVariantNumeric:"tabular-nums"},children:g.meta}):null]}),jsxRuntime.jsx(j,{label:oi.download,kind:"outline",ariaLabel:oi.downloadA11y(g.title),busy:l===g.key,onClick:()=>{y(g);},testID:`${o}-download-${g.key}`}),u===g.key?jsxRuntime.jsx("p",{role:"alert",style:{...s.errorText,flexBasis:"100%"},"data-testid":`${o}-save-failed-${g.key}`,children:Po.error.title}):null]},g.key))}):null}i(Jn,"RequestDocumentsList");function Vg(e,r){return {display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:e,paddingTop:e,paddingBottom:e,...r!==null?{borderTop:`1px solid ${r}`}:{}}}i(Vg,"rowStyle");function Zn(e){let{style:r,className:t,renderPending:o,...n}=Ie(e,["onNavigate","onBack"]),{userRef:s}=se(),{styles:a}=V();return jsxRuntime.jsx(Oe,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Fe(n.onBack,Me),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...r},"data-testid":"upload-screen",children:[s===null?jsxRuntime.jsx("div",{style:a.body,children:jsxRuntime.jsx(or,{label:X.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(Yg,{...n}),jsxRuntime.jsx(Ae,{})]})})}i(Zn,"EverfurRecordsUpload");function Yg({petRef:e,petName:r,controller:t,onNavigate:o,onBack:n}){let{theme:s,styles:a}=V(),{runtime:c}=se(),l=react.useMemo(()=>t?{petRef:e,controller:t,readUploadFeatures:true}:{petRef:e,readUploadFeatures:true},[e,t]),d=er(l),u=t!==void 0||co(c.registry.services.uploadTransport);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ke,{title:"",onBack:n,testID:"upload-header"}),jsxRuntime.jsxs("div",{style:{...a.body,...a.content,padding:s.space.lg+s.space.xs,gap:s.space.lg+s.space.xs},children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:s.space.sm,textAlign:"center"},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"block",width:52,height:52,borderRadius:s.radius.pill,backgroundColor:s.color.brandSoft,border:`1px solid ${s.color.brandBorder}`}}),jsxRuntime.jsx("h2",{tabIndex:-1,[Ft]:"",style:{...a.sectionTitle,fontSize:s.type.size.heading,color:s.color.brandInk},"data-testid":"upload-title",children:Qe.screenTitle}),jsxRuntime.jsx("p",{style:{...a.muted,fontSize:s.type.size.body,maxWidth:340},children:Qe.subtitle(r)})]}),jsxRuntime.jsx(Ka,{records:d,requestId:null,canUpload:u,onDone:o?p=>o({name:"request",requestId:p}):void 0})]})]})}i(Yg,"UploadBody");function Ka({records:e,requestId:r,canUpload:t,onDone:o}){let{theme:n,styles:s}=V(),a=react.useRef(null),c=`records-upload-format-hint-${r??"new"}`,[l,d]=react.useState(null),[u,p]=react.useState(0),[m,y]=react.useState(false),g=react.useRef(r),f=react.useRef([]),v=e.uploadQueue.filter(O=>O.status!=="skipped"),b=v.filter(O=>O.status==="done").length,R=v.filter(O=>O.status==="failed").length,h=!e.isUploading&&!m&&u>0,E=e.uploadContentTypes,S=xn(E),C=react.useCallback(async O=>{let{uploadable:z,skipped:q}=Xs(O,E),N=Ho(q,S);if(z.length===0){N!==null&&d(N);return}d(N),y(true);try{let B=g.current;if(B===null){let L=await e.createRequest(`records-upload-${Date.now().toString(36)}`);if(!L.ok){d(Qe.errors.start);return}B=L.value.id,g.current=B;}p(L=>L+1);let x=await e.uploadDocuments(B,z);f.current=x.flatMap((L,F)=>L.status==="failed"&&z[F]!==void 0?[z[F]]:[]);}finally{y(false);}},[e,E,S]),k=i(O=>{let z=Array.from(O.currentTarget.files??[]);O.currentTarget.value="",!(z.length===0||!t)&&(async()=>{let q=[];for(let N of z)q.push(await Vo(N,E));await C(q);})();},"onChange"),M=i(()=>a.current?.click(),"pick"),T=e.isUploading||m;return jsxRuntime.jsxs("section",{style:{...s.creamCard,backgroundColor:n.color.surface},"data-testid":"records-upload-card",children:[jsxRuntime.jsx("h4",{style:{...s.rowTitle,...D(n,"bold"),fontSize:n.type.size.subtitle},children:Qe.cardTitle}),jsxRuntime.jsx("p",{id:c,style:s.muted,children:S?Gn.note:Qe.cardSubtitle}),jsxRuntime.jsx("input",{ref:a,type:"file",accept:jo(E),multiple:true,tabIndex:-1,"aria-hidden":"true",hidden:true,disabled:!t,onChange:k,"data-testid":"records-upload-input"}),l?jsxRuntime.jsx("p",{role:"alert",style:s.errorBanner,children:l}):null,jsxRuntime.jsx(uc,{records:e}),T?jsxRuntime.jsx("p",{style:s.muted,children:Qe.uploading(b,v.length)}):h?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:n.space.sm},children:[b>0?jsxRuntime.jsx("p",{role:"status",style:s.bodyText,children:Qe.received(b)}):null,R>0?jsxRuntime.jsx(j,{label:Qe.retryFailed(R),kind:"link",ariaLabel:Qe.retryFailedA11y(R),onClick:()=>{C(f.current);},testID:"records-upload-retry-failed"}):null,jsxRuntime.jsx("p",{style:{...s.rowTitle,...D(n,"bold"),marginTop:n.space.xs},children:Qe.haveMore}),S?jsxRuntime.jsx("p",{style:s.muted,children:Gn.haveMoreLead}):null,jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:n.space.sm},children:[jsxRuntime.jsx(j,{label:Qe.addMore,kind:"link",ariaLabel:Qe.addMoreA11y,ariaDescribedBy:c,disabled:!t,onClick:M,testID:"records-upload-another"}),o&&g.current!==null&&b>0?jsxRuntime.jsx(j,{label:Qe.done,ariaLabel:Qe.doneA11y,onClick:()=>o(g.current),testID:"records-upload-done"}):null]})]}):jsxRuntime.jsx(j,{label:Qe.chooseFiles,ariaLabel:Qe.chooseFilesA11y,ariaDescribedBy:c,disabled:!t,onClick:M,testID:"records-upload-choose"})]})}i(Ka,"UploadRecordCard");function eo(e){let{style:r,className:t,renderPending:o,...n}=Ie(e,["onNavigate","onBack"]),{userRef:s}=se(),{styles:a}=V();return jsxRuntime.jsx(Oe,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Fe(n.onBack,Me),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...r},"data-testid":"records-request-screen",children:[s===null?jsxRuntime.jsx("div",{style:a.body,children:jsxRuntime.jsx(or,{label:X.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(Jg,{...n}),jsxRuntime.jsx(Ae,{})]})})}i(eo,"EverfurRecordsRequest");function Jg({petRef:e,petName:r,requestId:t,controller:o,onNavigate:n,onBack:s,onOpenUrl:a,nowMs:c}){let{styles:l}=V(),{runtime:d,userRef:u,scopeEpoch:p}=se(),m=er(o?{petRef:e,controller:o,readUploadFeatures:true}:{petRef:e,readUploadFeatures:true}),y=m.requests.find(v=>v.id===t)??null,g=o!==void 0||co(d.registry.services.uploadTransport),f;return m.status==="loading"?f=jsxRuntime.jsx(Oo,{testID:"records-request-loading"}):m.status==="error"&&m.error?f=jsxRuntime.jsx(He,{variant:nr(m.error),message:m.error.displayMessage,onAction:m.error.retryable?m.refresh:void 0,testID:"records-request-error"}):y===null?f=jsxRuntime.jsx(He,{variant:"no_requests",testID:"records-request-missing"}):f=jsxRuntime.jsx(Zg,{petName:r,request:y,records:m,canUpload:g,onNavigate:n,onOpenUrl:a,nowMs:c},JSON.stringify([u,p,y.id])),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ke,{title:y?Ro(y):"",onBack:s,testID:"records-request-header"}),jsxRuntime.jsx("div",{style:l.body,children:f})]})}i(Jg,"RequestBody");function Zg({petName:e,request:r,records:t,canUpload:o,onNavigate:n,onOpenUrl:s,nowMs:a}){let{theme:c,styles:l}=V(),d=Jd({request:r,onRecovered:t.refresh,canUpload:o},zr()),[u,p]=react.useState(null),[m,y]=react.useState(false),[g,f]=react.useState(null),v=react.useRef(true);react.useEffect(()=>(v.current=true,()=>{v.current=false;}),[]);let b=d.request,R=a??Date.now(),h=b.status==="published",E=b.status==="published"||b.status==="failed"||b.status==="revoked",S=Ji(b),C=b.wireStatus==="clinic_responded_no_records",k=Il(b,R),M=E?null:b.waitingExpectation?.trim()||null,T=vo(b),O=d.error!==null&&u!==null?u==="revoke"?le.errors.cancel:le.errors[u]:null,z=i((A,_)=>{p(A),_();},"run"),q=i(()=>{m||(y(true),f(null),t.createRequest(`records-upload-${Date.now().toString(36)}`).then(A=>{if(v.current){if(y(false),!A.ok){f(le.errors.start);return}n?.({name:"request",requestId:A.value.id});}}));},"startFresh"),N={display:"flex",flexDirection:"column",gap:c.space.sm},B=i(A=>jsxRuntime.jsx("p",{role:"alert",style:l.errorBanner,children:A}),"errorBanner"),x=`records-failure-clinic-email-${b.id}`,L=xt(),F=b.clinicName?.trim()??"",W=!jt(b)&&F.length>0,I=W&&(b.status==="requested"||b.status==="awaiting_clinic"),w=ee(b.createdAt);return jsxRuntime.jsxs("div",{ref:L,style:{...l.content,gap:c.space.lg+c.space.xs/2},"data-testid":`records-request-${b.id}`,children:[I?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c.space.xs},"data-testid":"records-request-sent",children:[jsxRuntime.jsx("h3",{style:{...l.sectionTitle,color:c.color.brandInk},children:le.sentTitle}),jsxRuntime.jsx("p",{style:l.bodyText,children:le.sentLeadWeb(F,Re(e))})]}):null,b.statusLabel.length>0||b.heldItemCount>0?jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:c.space.sm},"data-testid":"records-request-status-row",children:[b.statusLabel.length>0?jsxRuntime.jsx(br,{label:b.statusLabel,tone:il(b),testID:"records-request-status-chip"}):null,b.heldItemCount>0?jsxRuntime.jsx(br,{label:Mi(b.heldItemCount),tone:"neutral",testID:"records-request-held-count"}):null]}):null,b.status==="awaiting_upload"?jsxRuntime.jsx(Ka,{records:t,requestId:b.id,canUpload:o}):null,M&&!k?jsxRuntime.jsx("p",{style:l.infoNote,children:M}):b.wireStatus==="awaiting_response"&&!k?jsxRuntime.jsx("p",{style:l.infoNote,children:le.awaitingNote}):null,k?jsxRuntime.jsx("p",{style:l.cautionNote,"data-testid":"records-request-waiting-banner",children:le.waitingBanner(Xi(b,R))}):null,h&&n?jsxRuntime.jsx(j,{label:le.viewRecords,onClick:()=>n({name:"dashboard"}),testID:"records-request-view-dashboard"}):null,Ol(b)?jsxRuntime.jsxs("section",{style:{...N,gap:c.space.md,borderRadius:c.radius.lg-c.space.xs,padding:c.space.md+c.space.xs/2,backgroundColor:S?c.color.badgeBgCritical:c.color.badgeBgCaution},"data-testid":"records-failure-card",children:[jsxRuntime.jsx("p",{style:{...l.rowTitle,...D(c,"bold"),color:S?c.color.danger:c.color.warningStrong},children:Dl(b)}),b.canUpdateClinicEmail!==true&&b.canRetrySend!==true?jsxRuntime.jsx("p",{style:l.rowDetail,children:le.nextStep}):null,b.canUpdateClinicEmail===true?jsxRuntime.jsxs("div",{style:N,children:[jsxRuntime.jsx("label",{htmlFor:x,style:l.fieldLabel,children:jr.email}),jsxRuntime.jsx("input",{id:x,type:"email",style:l.field,placeholder:jr.emailPlaceholder,autoComplete:"off",maxLength:320,value:d.email,disabled:d.busy,onChange:A=>d.setEmail(A.target.value),"data-testid":"records-failure-clinic-email"}),d.emailInvalid?jsxRuntime.jsx("p",{role:"alert",style:l.errorText,children:le.errors.invalidEmail}):null,jsxRuntime.jsx(j,{label:jr.updateEmail,ariaLabel:jr.updateEmailA11y,disabled:!d.canUpdateEmail,busy:d.busy&&u==="email",onClick:()=>z("email",d.updateEmail),testID:"records-failure-update-email"})]}):null,b.canRetrySend===true?jsxRuntime.jsx(j,{label:jr.retry,kind:"outline",ariaLabel:jr.retryA11y,disabled:!d.canRetry,busy:d.busy&&u==="retry",onClick:()=>z("retry",d.retry),testID:"records-failure-retry-send"}):null,b.canRetrySend===true&&d.hasEmailEdit?jsxRuntime.jsx("p",{style:l.rowDetail,children:jr.retryHint}):null,O&&(u==="email"||u==="retry")?B(O):null]}):null,(S||C)&&n?jsxRuntime.jsx(j,{label:le.tryAnotherClinic,kind:"outline",ariaLabel:le.tryAnotherClinicA11y,onClick:()=>n({name:"clinicPicker"}),testID:"records-request-try-another-clinic"}):null,T!==null?jsxRuntime.jsxs("div",{style:N,children:[jsxRuntime.jsx(pc,{call:T,prompt:b.statusLabel}),b.canRetrySend===true?jsxRuntime.jsx(j,{label:d.busy&&u==="retry"?le.resending:le.resend,kind:"outline",ariaLabel:d.busy&&u==="retry"?le.resendingA11y:le.resendA11y,disabled:!d.canRetry,onClick:()=>z("retry",d.retry),testID:"records-resend-authorization"}):null]}):null,d.canConvert?jsxRuntime.jsxs("div",{style:N,children:[jsxRuntime.jsx(j,{label:d.busy&&u==="convert"?le.converting:le.convert,busy:d.busy&&u==="convert",onClick:()=>z("convert",d.convert),testID:"records-convert-upload"}),jsxRuntime.jsx("p",{style:l.muted,children:le.convertHint}),O&&u==="convert"?B(O):null]}):null,E&&!h?jsxRuntime.jsxs("div",{style:N,children:[jsxRuntime.jsx(j,{label:m?le.freshUploadStarting:le.freshUpload,kind:S||C?"outline":"primary",busy:m,onClick:q,testID:"records-upload-own-fresh"}),g?B(g):null]}):null,O&&u==="revoke"?B(O):null,b.canRevoke===true?d.confirmingRevoke?jsxRuntime.jsxs("div",{style:N,"data-testid":"records-revoke-confirm",children:[jsxRuntime.jsx("p",{style:{...l.rowTitle,...D(c,"bold"),fontSize:c.type.size.subtitle},children:jr.cancelQuestion}),jsxRuntime.jsx("p",{style:l.bodyText,children:jr.cancelConsequence}),jsxRuntime.jsx(j,{label:d.busy&&u==="revoke"?le.cancelling:le.cancel,kind:"danger",ariaLabel:d.busy&&u==="revoke"?le.cancellingA11y:le.cancelA11y,busy:d.busy&&u==="revoke",onClick:()=>z("revoke",d.revoke),testID:"records-revoke-do"}),jsxRuntime.jsx(j,{label:jr.keepRequest,kind:"outline",disabled:d.busy,onClick:d.keepRequest,testID:"records-revoke-keep"})]}):jsxRuntime.jsx(j,{label:le.cancel,kind:"danger",ariaLabel:le.cancelA11y,disabled:d.busy,onClick:d.askRevoke,testID:"records-revoke"}):null,jsxRuntime.jsxs("section",{style:{...l.creamCard,backgroundColor:c.color.surface},"aria-label":le.whereItStands,"data-testid":"records-request-where",children:[jsxRuntime.jsx("h3",{style:l.sectionTitle,children:le.whereItStands}),jsxRuntime.jsx(fn,{request:b,petName:e})]}),W?jsxRuntime.jsxs("section",{style:{...l.creamCard,backgroundColor:c.color.surface},"aria-label":le.details,"data-testid":"records-request-details",children:[jsxRuntime.jsx("h3",{style:l.sectionTitle,children:le.details}),jsxRuntime.jsxs("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",alignItems:"baseline",columnGap:c.space.lg,rowGap:c.space.sm},children:[jsxRuntime.jsx("dt",{style:l.muted,children:le.detailsClinic}),jsxRuntime.jsx("dd",{style:{...l.bodyText,margin:0},children:F}),w!=="-"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("dt",{style:l.muted,children:le.detailsSent}),jsxRuntime.jsx("dd",{style:{...l.bodyText,margin:0},children:jsxRuntime.jsx("time",{dateTime:b.createdAt,children:w})})]}):null]})]}):null,jt(b)?jsxRuntime.jsx(Jn,{requestId:b.id,...s?{onOpenUrl:s}:{}}):null]})}i(Zg,"RequestDetail");function to(e){return e.name==="request"||e.name==="clinicPicker"||e.name==="consent"||e.name==="clinicBatch"||e.name==="upload"}i(to,"isOverlayScreen");function jc(e,r){if(r.type!=="closeOverlay")return In(e,r);let t=e.stack.length;for(;t>1&&to(e.stack[t-1]);)t-=1;return t===e.stack.length?e:Object.freeze({stack:Object.freeze(e.stack.slice(0,t))})}i(jc,"recordsPageNavReducer");function Vc(e){let{stack:r}=e,t=r[r.length-1],o=to(t)?t:null,n=r.length-1;for(;n>0&&to(r[n]);)n-=1;let s=r[n],a=to(s)?{name:"dashboard"}:s,c=o===null?null:r[r.length-2];return Object.freeze({body:a,overlay:o,overlayCanStepBack:c!=null&&to(c),bodyCanGoBack:n>0})}i(Vc,"splitRecordsPageNav");function Wc(e){return {...e.petName!==void 0?{petName:e.petName}:{},...e.onOpenUrl?{onOpenUrl:e.onOpenUrl}:{},...e.onCopy?{onCopy:e.onCopy}:{},...e.onAsk?{onAsk:e.onAsk}:{},...e.location?{location:e.location}:{}}}i(Wc,"seamsOf");function Gc({screen:e,ctx:r,onBack:t}){let o={...Wc(r),onNavigate:r.navigate,onBack:t},n={...r.controller?{controller:r.controller}:{},...r.consentVersion!==void 0?{consentVersion:r.consentVersion}:{}},s=tb;switch(e.name){case "record":return jsxRuntime.jsx(Xn,{petRef:r.petRef,...o,...n,style:s});case "timeline":return jsxRuntime.jsx($o,{petRef:r.petRef,...o,style:s});case "document":return jsxRuntime.jsx(Qn,{petRef:r.petRef,...o,...n,style:s});case "contributions":return jsxRuntime.jsx(Uo,{petRef:r.petRef,docId:e.docId,...o,style:s});default:return Nr(e)}}i(Gc,"RecordsPageBodyScreenView");function Yc({screen:e,ctx:r,requests:t,onBack:o,onClose:n}){let s=rn(e),a=react.useMemo(()=>rb(e,t),[e,t]),c=r.onAsk,l=c?{onAsk:i((y,g)=>{n(),c(y,g);},"onAsk")}:{},d={...Wc(r),...l,onNavigate:r.navigate,onBack:o},u=r.clinicController?{controller:r.clinicController}:{},p=r.onCaptureSignature?{onCaptureSignature:r.onCaptureSignature}:{},m;switch(e.name){case "request":m=jsxRuntime.jsx(eo,{petRef:r.petRef,requestId:e.requestId,...d,...r.controller?{controller:r.controller}:{},style:ro});break;case "clinicPicker":m=jsxRuntime.jsx(Ln,{petRef:r.petRef,...d,...u,...r.controller?{recordsController:r.controller}:{},style:ro});break;case "consent":m=jsxRuntime.jsx(Hn,{petRef:r.petRef,clinic:e.clinic,...d,...r.ownerName!==void 0?{ownerName:r.ownerName}:{},...p,...u,style:ro});break;case "clinicBatch":m=jsxRuntime.jsx($n,{petRef:r.petRef,petName:r.petName??"",ownerName:r.ownerName??"",onClose:o,onCreated:()=>r.navigate({name:"dashboard"}),...p,...u,style:ro});break;case "upload":m=jsxRuntime.jsx(Zn,{petRef:r.petRef,...d,...r.controller?{controller:r.controller}:{},style:ro});break;default:m=Nr(e);}return jsxRuntime.jsx(Dt,{label:a,onClose:n,shape:"side",panelStyle:nb,testID:"everfur-records-page-sheet",children:jsxRuntime.jsx("div",{ref:s,tabIndex:-1,style:ob,children:m})})}i(Yc,"RecordsPageOverlay");function rb(e,r){if(e.name==="upload")return _e.uploadAction;if(e.name!=="request")return _e.requestRecords;let t=r.find(o=>o.id===e.requestId);return t?yo(t):_e.requestTimeline}i(rb,"overlayLabel");var tb=Object.freeze({height:"auto"}),nb=Object.freeze({padding:0,gap:0}),ob=Object.freeze({height:"100%",outline:"none"}),ro=Object.freeze({height:"100%"});function ii({requests:e,petName:r,level:t,headingId:o,onOpenRequest:n,onUpload:s,onOpenUrl:a}){let{theme:c,styles:l}=V(),d=xo(t),u=e.length>0;return jsxRuntime.jsxs("section",{"aria-labelledby":o,style:l.section,"data-testid":"everfur-records-page-requests",children:[jsxRuntime.jsxs("div",{style:l.sectionHeader,children:[jsxRuntime.jsx(d,{id:o,style:{...l.sectionTitle,color:c.color.brandInk},children:_e.requestsFor(r)}),u?jsxRuntime.jsx("span",{style:l.sectionCount,"data-testid":"everfur-records-page-requests-count",children:e.length}):null]}),u?jsxRuntime.jsx("ul",{style:{...l.plainList,gap:c.space.md},children:e.map(p=>{let m=yo(p),y=zi(null,p)!==null;return jsxRuntime.jsxs("li",{style:l.creamCard,"data-testid":`everfur-records-page-request-${p.id}`,children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:c.space.sm},children:[jsxRuntime.jsx("span",{style:{...l.rowTitle,fontSize:c.type.size.subtitle},children:m}),n?jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:c.space.sm},children:[y?jsxRuntime.jsx(j,{label:Qe.cardTitle,onClick:()=>n(p),testID:`everfur-records-page-resume-upload-${p.id}`}):null,jsxRuntime.jsx(j,{label:_e.requestTimeline,kind:"outline",ariaLabel:_e.requestTimelineA11y(m),onClick:()=>n(p),testID:`everfur-records-page-open-${p.id}`})]}):null]}),jsxRuntime.jsx(fn,{request:p}),jt(p)?jsxRuntime.jsx(Jn,{requestId:p.id,...a?{onOpenUrl:a}:{}}):null]},p.id)})}):jsxRuntime.jsxs("div",{style:l.creamCard,"data-testid":"everfur-records-page-upload-prompt",children:[jsxRuntime.jsx("span",{style:{...l.rowTitle,fontSize:c.type.size.subtitle},children:_e.uploadPromptTitle(r)}),jsxRuntime.jsx("p",{style:l.bodyText,children:_e.uploadPromptBody}),s?jsxRuntime.jsx(j,{label:_e.uploadAction,onClick:s,testID:"everfur-records-page-upload"}):null]})]})}i(ii,"RecordsPageRequests");var ub=1248,pb=Object.freeze({height:"auto"}),ai=Object.freeze({overflowY:"visible",flex:"0 0 auto"});function mb(e){let{style:r,className:t,renderPending:o,...n}=Ie(e,["onNavigate","onBack","onAsk"]),{userRef:s}=se(),{styles:a}=V();return jsxRuntime.jsx(Oe,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Fe(n.onBack,Me),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...pb,...r},"data-testid":"everfur-records-page",children:[s===null?jsxRuntime.jsx("div",{style:{...a.body,...ai},children:jsxRuntime.jsx(or,{label:X.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(fb,{...n}),jsxRuntime.jsx(Ae,{})]})})}i(mb,"EverfurRecordsPage");function fb(e){let{petRef:r,petName:t,controller:o,clinicController:n,consentVersion:s,ownerName:a,onCaptureSignature:c,onNavigate:l,onOpenUrl:d,onCopy:u,onAsk:p,location:m}=e,[y,g]=react.useReducer(jc,void 0,()=>Zt()),f=react.useCallback(z=>{l?l(z):g({type:"navigate",screen:z});},[l]),{body:v,overlay:b,overlayCanStepBack:R,bodyCanGoBack:h}=Vc(y),E=react.useMemo(()=>o?{petRef:r,controller:o}:{petRef:r},[r,o]),S=er(E),{refresh:C}=S,k=react.useRef(false);react.useEffect(()=>{b!==null?k.current=true:k.current&&(k.current=false,C());},[b,C]);let M=rn(v),T={petRef:r,petName:t,controller:o,clinicController:n,consentVersion:s,ownerName:a,onCaptureSignature:c,navigate:f,...d?{onOpenUrl:d}:{},...u?{onCopy:u}:{},...p?{onAsk:p}:{},...m?{location:m}:{}},O=v.name==="dashboard"||v.name==="requests";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:M,tabIndex:-1,style:yb,children:O?jsxRuntime.jsx(gb,{...e,records:S,navigate:f}):jsxRuntime.jsx(Gc,{screen:v,ctx:T,onBack:h?()=>g({type:"pop"}):()=>f({name:"dashboard"})})}),b!==null?jsxRuntime.jsx(Yc,{screen:b,ctx:T,requests:S.requests,onBack:R?()=>g({type:"pop"}):()=>g({type:"closeOverlay"}),onClose:()=>g({type:"closeOverlay"})}):null]})}i(fb,"RecordsPageBody");var yb=Object.freeze({outline:"none"});function gb({petRef:e,petName:r,consentVersion:t,onAsk:o,onOpenUrl:n,headingLevel:s,records:a,navigate:c}){let{theme:l,styles:d}=V(),u=Ot("recordsClinic"),p=u.enabled||u.isPending,m=Sl(s??So),y=xo(m),g=`${react.useId()}-requests-heading`,f=dt(t,a.consent),v=i(()=>{let R=Zr(t,a.consent);R.length!==0&&a.grantConsent(R,`records-consent-${Date.now().toString(36)}`);},"onGrant"),b={boxSizing:"border-box",width:"100%",maxWidth:ub,margin:"0 auto",display:"flex",flexDirection:"column",gap:l.space.lg+l.space.xs,padding:`${l.space.lg}px ${l.space.lg}px ${l.space.xxl}px`};if(a.status==="loading")return jsxRuntime.jsx("div",{style:{...d.body,...ai},children:jsxRuntime.jsx("div",{style:b,children:jsxRuntime.jsx(sn,{testID:"everfur-records-page-loading"})})});if(a.status==="error"){let R=et(a,f),h=R.kind==="error"||R.kind==="pet_not_found"?jsxRuntime.jsx(He,{variant:nr(R.error),message:R.error.displayMessage,onAction:R.error.retryable?()=>a.refresh():void 0,testID:"everfur-records-page-error"}):Tt(a,v,f);return jsxRuntime.jsx("div",{style:{...d.body,...ai},children:jsxRuntime.jsx("div",{style:b,children:h})})}return jsxRuntime.jsx("div",{style:{...d.body,...ai},children:jsxRuntime.jsxs("div",{style:b,"data-testid":"everfur-records-page-content",children:[jsxRuntime.jsxs("header",{style:{...d.creamCard,gap:l.space.md,padding:`${l.space.lg+l.space.xs}px ${l.space.lg+l.space.md}px`},"data-testid":"everfur-records-page-header",children:[jsxRuntime.jsx(y,{tabIndex:-1,[Ft]:"",style:{...d.headerTitle,whiteSpace:"normal",overflow:"visible"},children:_e.titleFor(r)}),jsxRuntime.jsx("p",{style:d.bodyText,children:_e.lead}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:l.space.sm},"data-testid":"everfur-records-page-actions",children:[p?jsxRuntime.jsx(j,{label:_e.requestRecords,onClick:()=>c({name:"clinicPicker"}),testID:"everfur-records-page-request-records"}):null,jsxRuntime.jsx(j,{label:_e.uploadAction,kind:"outline",onClick:()=>c({name:"upload"}),testID:"everfur-records-page-upload-action"}),o?jsxRuntime.jsx(j,{label:_e.askA11y(r),kind:"ask",ariaLabel:_e.askA11y(r),onClick:()=>o(Zs(r),{type:"marker_summary",id:e}),testID:"everfur-records-page-ask"}):null]}),jsxRuntime.jsxs("nav",{style:{display:"flex",flexWrap:"wrap",columnGap:l.space.lg,rowGap:l.space.xs},"data-testid":"everfur-records-page-links",children:[jsxRuntime.jsx(Kc,{label:_e.viewRecord,onClick:()=>c({name:"record"}),testID:"everfur-records-page-link-record"}),jsxRuntime.jsx(Kc,{label:_e.viewTimeline,onClick:()=>c({name:"timeline"}),testID:"everfur-records-page-link-timeline"})]})]}),jsxRuntime.jsx(ii,{requests:a.requests,petName:r,level:Ki(m),headingId:g,onOpenRequest:R=>c({name:"request",requestId:R.id}),onUpload:()=>c({name:"upload"}),...n?{onOpenUrl:n}:{}})]})})}i(gb,"RecordsPageContent");function Kc({label:e,onClick:r,testID:t}){let{theme:o,styles:n}=V();return jsxRuntime.jsx("button",{type:"button",onClick:r,style:{...n.pill,...n.pillLink,minHeight:44,padding:0,fontSize:o.type.size.bodyTight,textDecoration:"underline",textUnderlineOffset:4},"data-testid":t,children:e})}i(Kc,"PageLink");var xr=200,Xa=16,Ja=(xr-Xa)/2,Qc=2*Math.PI*Ja;function Jc({summary:e,onAsk:r,testID:t}){let o=hb(),{theme:n,styles:s}=V(),{totalMarkers:a,inRangeCount:c,outOfRangeCount:l,unknownCount:d}=e,u=c+l+d,p=react.useMemo(()=>{if(!(u>0))return [];let m=[{key:"in_range",color:n.color.success,count:c},{key:"out_of_range",color:n.color.danger,count:l},{key:"unknown",color:n.color.text.muted,count:d}],y=0;return m.filter(g=>g.count>0).map(g=>{let f=g.count/u*Qc,v=-y;return y+=f,{key:g.key,color:g.color,length:f,offset:v}})},[u,c,l,d,n]);return jsxRuntime.jsxs("section",{role:"group","aria-label":_r.title,style:o.card,"data-testid":t,children:[jsxRuntime.jsx("h3",{style:o.title,children:_r.title}),jsxRuntime.jsx("div",{style:o.ringRow,children:jsxRuntime.jsxs("div",{style:o.ringWrap,role:"img","aria-label":_r.a11y(a,c,l,d),children:[jsxRuntime.jsxs("svg",{width:xr,height:xr,viewBox:`0 0 ${xr} ${xr}`,"aria-hidden":"true",focusable:"false",children:[jsxRuntime.jsx("circle",{cx:xr/2,cy:xr/2,r:Ja,stroke:n.color.surfaceSubtle,strokeWidth:Xa,fill:"none"}),jsxRuntime.jsx("g",{transform:`rotate(-90 ${xr/2} ${xr/2})`,children:p.map(m=>jsxRuntime.jsx("circle",{cx:xr/2,cy:xr/2,r:Ja,stroke:m.color,strokeWidth:Xa,fill:"none",strokeDasharray:`${m.length} ${Qc}`,strokeDashoffset:m.offset,strokeLinecap:p.length>1?"round":"butt","data-testid":`marker-ring-${m.key}`},m.key))})]}),jsxRuntime.jsxs("div",{style:o.center,"aria-hidden":"true",children:[jsxRuntime.jsx("span",{style:o.centerCount,children:a}),jsxRuntime.jsx("span",{style:o.centerLabel,children:a===1?_r.marker:_r.markers})]})]})}),p.length>0?jsxRuntime.jsxs("div",{style:o.badges,children:[jsxRuntime.jsx("span",{style:{...o.badge,borderColor:n.color.danger,color:n.color.danger},children:`${l} ${_r.outOfRange}`}),jsxRuntime.jsx("span",{style:{...o.badge,borderColor:n.color.success,color:n.color.success},children:`${c} ${_r.inRange}`}),d>0?jsxRuntime.jsx("span",{style:{...o.badge,borderColor:n.color.text.muted,color:n.color.text.muted},children:`${d} ${_r.noRange}`}):null]}):null,jsxRuntime.jsx("p",{style:o.subtitle,children:_r.subtitle}),r?jsxRuntime.jsx("button",{type:"button",onClick:r,"aria-label":_r.askA11y,style:{...s.pill,...s.pillAsk},"data-testid":"marker-summary-ask",children:_r.ask}):null]})}i(Jc,"MarkerSummaryCard");function hb(){let e=ye();return react.useMemo(()=>Rb(e),[e])}i(hb,"useStyles");function Rb(e){let{color:r,space:t,radius:o,type:n}=e;return {card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.sm+t.xs/2,borderRadius:o.lg,backgroundColor:r.surfaceCream,border:`1px solid ${r.borderRingCream}`,padding:t.lg},title:{margin:0,...D(e,"bold"),fontSize:n.size.subtitle,color:r.brandInk,letterSpacing:"-0.02em"},ringRow:{display:"flex",justifyContent:"center"},ringWrap:{position:"relative",width:xr,height:xr},center:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",pointerEvents:"none"},centerCount:{...D(e,"medium"),fontSize:n.size.verdict*2,lineHeight:1.1,color:r.text.primary},centerLabel:{...D(e,"medium"),fontSize:n.size.heading-1,lineHeight:1.2,color:r.text.primary},badges:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:t.sm},badge:{border:"1px solid",borderRadius:o.pill,padding:`${t.xs}px ${t.sm+t.xs/2}px`,...D(e,"mono"),fontSize:n.size.nano,lineHeight:`${n.size.tiny}px`,textTransform:"uppercase",letterSpacing:n.letterSpacing.headerBrand/2},subtitle:{margin:0,...D(e,"regular"),fontSize:n.size.caption,lineHeight:`${Math.round(n.size.caption*n.lineHeight.relaxed)}px`,color:r.text.primary}}}i(Rb,"makeStyles");function vb(e){return e.value!==null&&Number.isFinite(e.value)}i(vb,"numeric");function Zc(e){let r=e.points.filter(vb);if(r.length===0)return null;let t=e.points[e.points.length-1]??null,o=t?.refLow??null,n=t?.refHigh??null,s=r.map(b=>b.value),a=Math.min(...s,...o!==null?[o]:[],...n!==null?[n]:[]),c=Math.max(...s,...o!==null?[o]:[],...n!==null?[n]:[]);a===c&&(a-=1,c+=1);let l=(c-a)*.18,d=a-l,u=c+l,p=u-d,m=i(b=>(u-b)/p*100,"y"),y=6,g=r.length,f=r.map((b,R)=>({index:R,xPct:g<=1?50:y+R/(g-1)*(100-2*y),yPct:m(b.value),status:b.status,point:b})),v=o!==null||n!==null?{topPct:n!==null?m(n):0,bottomPct:o!==null?m(o):100}:null;return {points:f,band:v,firstDate:r[0]?.at??null,lastDate:r[r.length-1]?.at??null}}i(Zc,"buildMarkerChart");var eu=100,si=44;function Eb({marker:e,onPointPress:r,onAsk:t}){let o=Za(),{theme:n,styles:s}=V(),a=nt(e.latest?.status??null),c=nn(e.trajectory,e.points.length),l=react.useMemo(()=>Zc(e),[e]),d=e.latest?hr(e.latest.value,e.unit,e.latest.qualitativeResult):null;return jsxRuntime.jsx("li",{style:o.page,"data-testid":`marker-card-${e.markerId}`,children:jsxRuntime.jsxs("article",{style:o.card,children:[jsxRuntime.jsxs("div",{style:o.headerRow,children:[jsxRuntime.jsxs("div",{style:o.nameColumn,children:[jsxRuntime.jsx("span",{style:o.markerName,children:e.name}),e.unit?jsxRuntime.jsx("span",{style:o.unit,children:e.unit}):null]}),jsxRuntime.jsx("span",{"aria-label":st.status(a.label),children:jsxRuntime.jsx(br,{label:a.label,tone:Xo(e.latest?.status??null)})})]}),e.latest&&d!==null?jsxRuntime.jsxs("div",{style:o.latestRow,children:[jsxRuntime.jsx("span",{style:{...o.latestValue,...a.outOfRange?o.latestValueDanger:{}},"aria-label":st.latestA11y(d,a.label,ee(e.latest.at)),children:d}),jsxRuntime.jsx("span",{style:o.latestDate,children:ee(e.latest.at)})]}):null,c?jsxRuntime.jsx("p",{style:o.trajectory,children:c}):null,l!==null?jsxRuntime.jsxs("div",{style:o.chartWrap,children:[jsxRuntime.jsxs("svg",{viewBox:`0 0 ${eu} ${si}`,preserveAspectRatio:"none",style:o.plot,"aria-hidden":"true",focusable:"false",children:[l.band?jsxRuntime.jsx("rect",{x:0,y:l.band.topPct/100*si,width:eu,height:Math.max(0,(l.band.bottomPct-l.band.topPct)/100*si),fill:n.color.badgeBgPositive}):null,l.points.length>1?jsxRuntime.jsx("polyline",{fill:"none",stroke:n.color.brandBorder,strokeWidth:.6,vectorEffect:"non-scaling-stroke",points:l.points.map(u=>`${u.xPct},${u.yPct/100*si}`).join(" ")}):null]}),jsxRuntime.jsx("div",{style:o.dotLayer,children:l.points.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>r(e,u.point),"aria-label":La(e,u.point),style:{...o.dot,...u.status==="above"||u.status==="below"?o.dotDanger:{},left:`${u.xPct}%`,top:`${u.yPct}%`},"data-testid":`marker-point-${e.markerId}-${u.index}`},u.index))}),jsxRuntime.jsx("ul",{"aria-label":st.readingsA11y(e.name),style:o.a11yTable,children:e.points.map((u,p)=>jsxRuntime.jsx("li",{children:La(e,u)},p))}),jsxRuntime.jsx("p",{style:e.points.length===1?o.singleHint:o.tapHint,children:e.points.length===1?st.singleHint:st.tapHint})]}):jsxRuntime.jsx("p",{style:o.emptyBody,children:st.empty}),t?jsxRuntime.jsx("button",{type:"button",onClick:()=>t(e),"aria-label":st.askA11y(e.name),style:{...s.pill,...s.pillAsk},"data-testid":`marker-ask-${e.markerId}`,children:st.askNamed(e.name)}):null]})})}i(Eb,"MarkerTrendCard");function tu({markers:e,onPointPress:r,onAsk:t}){let o=Za(),[n,s]=react.useState(0),a=i(l=>{let d=l.currentTarget;d.clientWidth<=0||s(Math.max(0,Math.min(Math.round(d.scrollLeft/d.clientWidth),e.length-1)));},"onScroll"),c=e[n]??null;return jsxRuntime.jsxs("div",{style:o.carousel,"data-testid":"marker-carousel",children:[jsxRuntime.jsx("ul",{style:o.track,onScroll:a,children:e.map(l=>jsxRuntime.jsx(Eb,{marker:l,onPointPress:r,onAsk:t},l.markerId))}),jsxRuntime.jsxs("div",{style:o.footer,"aria-label":Oi.a11y(c?.name??null,n,e.length),children:[jsxRuntime.jsx("div",{style:o.dots,"aria-hidden":"true",children:e.map((l,d)=>jsxRuntime.jsx("span",{style:{...o.dotIndicator,...d===n?o.dotActive:{}}},l.markerId))}),jsxRuntime.jsx("span",{style:o.counter,children:Oi.counter(n,e.length)})]})]})}i(tu,"MarkerTrendCarousel");function nu({marker:e,point:r,onClose:t,onAsk:o}){let n=Za(),{styles:s}=V();if(e===null||r===null)return null;let a=i((c,l)=>jsxRuntime.jsxs("div",{style:n.detailRow,children:[jsxRuntime.jsx("dt",{style:n.detailLabel,children:c}),jsxRuntime.jsx("dd",{style:n.detailValue,children:l})]},c),"row");return jsxRuntime.jsxs(Dt,{label:gr.title,onClose:t,panelStyle:n.sheetBg,testID:"marker-provenance-sheet",children:[jsxRuntime.jsxs("div",{style:s.sheetHeader,children:[jsxRuntime.jsx("h3",{style:s.sheetTitle,children:gr.title}),jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":gr.close,style:s.iconButton,"data-testid":"marker-provenance-close",children:jsxRuntime.jsx("span",{style:s.closeGlyph,"aria-hidden":"true",children:"\xD7"})})]}),jsxRuntime.jsxs("div",{style:n.valueRow,children:[jsxRuntime.jsx("span",{style:n.markerName,children:e.name}),jsxRuntime.jsx("span",{style:n.latestValue,children:hr(r.value,e.unit,r.qualitativeResult)})]}),r.reviewed?jsxRuntime.jsx("span",{style:n.reviewed,children:gr.reviewed}):null,jsxRuntime.jsxs("dl",{style:n.details,children:[a(gr.collected,ee(r.at)),r.sourceClinic?a(gr.clinic,r.sourceClinic):null,a(gr.referenceRange,r.refLow!==null||r.refHigh!==null?Jo(r,e.unit):gr.noRange),r.docId?a(gr.sourceDocument,r.docId):null]}),r.reviewed?null:jsxRuntime.jsx("p",{style:n.unverified,children:gr.unverified}),o?jsxRuntime.jsx("button",{type:"button",onClick:o,"aria-label":gr.askA11y,style:{...s.pill,...s.pillAsk},"data-testid":"marker-provenance-ask",children:gr.ask}):null]})}i(nu,"MarkerProvenanceDialog");function Za(){let e=ye();return react.useMemo(()=>Sb(e),[e])}i(Za,"useStyles");function Sb(e){let{color:r,space:t,radius:o,type:n}=e,s=i((c,l,d,u="regular")=>({margin:0,...D(e,u),fontSize:c,lineHeight:`${Math.round(c*l)}px`,color:d}),"text"),a=t.md;return {page:{flex:"0 0 100%",scrollSnapAlign:"start",boxSizing:"border-box",padding:`0 ${t.sm}px`,listStyle:"none"},card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:t.md,borderRadius:o.lg,border:`1px solid ${r.borderRingCream}`,backgroundColor:r.surface,padding:t.lg},headerRow:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:t.sm+t.xs/2},nameColumn:{flex:1,display:"flex",flexDirection:"column",gap:t.xs/2,minWidth:0},markerName:{...s(n.size.subtitle,n.lineHeight.snug,r.text.primary,"bold")},unit:{...D(e,"mono"),fontSize:n.size.tiny,lineHeight:`${n.size.body}px`,color:r.text.muted},latestRow:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:t.md},latestValue:{...s(n.size.verdict+t.xs,n.lineHeight.tight,r.text.primary,"bold")},latestValueDanger:{color:r.danger},latestDate:s(n.size.caption,n.lineHeight.normal,r.text.muted),trajectory:s(n.size.bodyTight,n.lineHeight.normal,r.text.muted),chartWrap:{position:"relative",display:"flex",flexDirection:"column",gap:t.sm},plot:{display:"block",width:"100%",height:140,borderRadius:o.sm,backgroundColor:r.surfaceCream,border:`1px solid ${r.borderHairlineGreen}`},dotLayer:{position:"absolute",left:0,right:0,top:0,height:140},dot:{position:"absolute",boxSizing:"border-box",width:a,height:a,borderRadius:a/2,marginLeft:-a/2,marginTop:-a/2,backgroundColor:r.brand,border:`2px solid ${r.surface}`,padding:0,cursor:"pointer"},dotDanger:{backgroundColor:r.danger},a11yTable:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",margin:0,padding:0,listStyle:"none"},tapHint:{...s(n.size.tiny,n.lineHeight.normal,r.text.placeholder),textAlign:"center"},singleHint:{...s(n.size.caption,n.lineHeight.normal,r.text.muted),textAlign:"center"},emptyBody:{...s(n.size.bodyTight,n.lineHeight.normal,r.text.muted),textAlign:"center",padding:`${t.xxl+t.xs}px 0`},carousel:{display:"flex",flexDirection:"column"},track:{display:"flex",overflowX:"auto",scrollSnapType:"x mandatory",margin:0,padding:0,listStyle:"none"},footer:{display:"flex",flexDirection:"column",alignItems:"center",gap:t.sm,paddingTop:t.md},dots:{display:"flex",gap:t.xs+t.xs/2},dotIndicator:{display:"block",width:t.xs+t.xs/2,height:t.xs+t.xs/2,borderRadius:t.xs-1,backgroundColor:r.borderHairlineGreen},dotActive:{width:t.lg+t.xs/2,backgroundColor:r.brand},counter:{...D(e,"mono"),fontSize:n.size.tiny,lineHeight:`${n.size.body}px`,letterSpacing:n.letterSpacing.eyebrow/3,color:r.text.muted},sheetBg:{backgroundColor:r.surfaceCream},valueRow:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:t.md},reviewed:{alignSelf:"flex-start",borderRadius:o.pill,padding:`${t.xs}px ${t.sm+t.xs/2}px`,backgroundColor:r.badgeBgPositive,...s(n.size.tiny,n.lineHeight.normal,r.success,"medium")},details:{margin:0,display:"flex",flexDirection:"column",gap:t.md},detailRow:{display:"flex",flexDirection:"column",gap:t.xs/2},detailLabel:{...s(n.size.caption,n.lineHeight.normal,r.text.muted,"medium")},detailValue:{...s(n.size.body,n.lineHeight.normal,r.text.primary),marginLeft:0},unverified:s(n.size.caption,n.lineHeight.normal,r.text.muted)}}i(Sb,"makeStyles");var _b=i((e,r)=>e.getRecordDepth(r),"readDepth"),Pb=i(e=>!e.available,"depthEmpty");function rs(e){let{style:r,className:t,renderPending:o,...n}=Ie(e,["onNavigate","onBack","onAsk"]),{userRef:s}=se(),{styles:a}=V();return jsxRuntime.jsx(Oe,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Fe(n.onBack,Me),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...r},"data-testid":"records-dashboard",children:[s===null?jsxRuntime.jsx("div",{style:a.body,children:jsxRuntime.jsx(or,{label:X.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(Tb,{...n}),jsxRuntime.jsx(Ae,{})]})})}i(rs,"EverfurRecordsDashboard");function Tb({petRef:e,petName:r,controller:t,consentVersion:o,onNavigate:n,onBack:s,onAsk:a}){let{theme:c,styles:l}=V(),d=react.useMemo(()=>t?{petRef:e,controller:t,readUploadFeatures:true}:{petRef:e,readUploadFeatures:true},[e,t]),u=er(d),p=Ra(e),m=Hr(e,_b,Pb),[y,g]=react.useState(null),f=react.useCallback((w,A)=>g({marker:w,point:A}),[]),v=dt(o,u.consent),b=i(()=>{let w=Zr(o,u.consent);w.length!==0&&u.grantConsent(w,`records-consent-${Date.now().toString(36)}`);},"onGrant"),R=p.markers?.markers??[],h=R.length>0,E=u.record!==null&&!u.record.isEmpty&&!u.record.withheld,S=go(u.requests,e),C=Ai({hasMarkers:h,requests:u.requests,petRef:e}),k=Fi({recordLoading:u.status==="loading",hasFullRecord:E,recordError:u.status==="error",markersLoading:p.status==="loading",markersError:p.status==="error",hasMarkers:h,requestsLoading:u.status==="loading",dashboardState:C,drivingRequest:S}),M=p.markers?.disclaimer??u.record?.disclaimer??"",T=i(()=>{u.refresh(),p.refresh(),m.refresh();},"retryAll"),O=m.value!==null&&!m.value.withheld&&m.value.available?m.value:null,z=Re(r),q=xt(),N=a&&p.markers?.summary?()=>{let w=Sc(r,p.markers?.summary??{totalMarkers:0,inRangeCount:0,outOfRangeCount:0,unknownCount:0},e);a(w.prompt,w.entityRef);}:void 0,B=a?w=>{let A=Ec(r,{canonicalName:w.name,markerId:w.markerId,latestValueText:w.latest?hr(w.latest.value,w.unit,w.latest.qualitativeResult):null,statusText:w.latest?nt(w.latest.status).label:null,trajectoryText:nn(w.trajectory,w.points.length),meaningText:w.meaning});a(A.prompt,A.entityRef);}:void 0,x=a&&y?()=>{let{marker:w,point:A}=y,_=xc(r,{canonicalName:w.name,valueText:hr(A.value,w.unit,A.qualitativeResult),collectedAt:ee(A.at),sourceClinic:A.sourceClinic,referenceText:A.refLow!==null||A.refHigh!==null?Jo(A,w.unit):null,flagged:A.status==="above"?"above":A.status==="below"?"below":null,reviewed:A.reviewed,entityId:A.docId??w.markerId});g(null),a(_.prompt,_.entityRef);}:void 0,L=i((w,A,_)=>jsxRuntime.jsxs("button",{type:"button",onClick:A,"aria-label":w,style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",borderRadius:c.radius.lg,border:`1px solid ${c.color.borderRingCream}`,backgroundColor:c.color.surface,padding:c.space.lg,cursor:"pointer",font:"inherit",color:c.color.text.primary,textAlign:"left"},"data-testid":_,children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:c.space.md},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:18,height:18,borderRadius:c.radius.xs,backgroundColor:c.color.brandSoft,border:`1px solid ${c.color.brandBorder}`}}),jsxRuntime.jsx("span",{style:{...l.rowTitle},children:w})]}),jsxRuntime.jsx(kt,{})]}),"actionRow"),F=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p.markers?.summary?jsxRuntime.jsx("div",{style:l.inset,children:jsxRuntime.jsx(Jc,{summary:p.markers.summary,onAsk:N,testID:"dashboard-marker-summary"})}):null,jsxRuntime.jsx("p",{style:l.lead,children:yr.lead(r)}),jsxRuntime.jsx(tu,{markers:R,onPointPress:f,onAsk:B})]}),W=i(w=>n?jsxRuntime.jsxs("div",{style:{...l.inset,display:"flex",flexDirection:"column",gap:c.space.sm+c.space.xs/2},children:[w?L(yr.viewFullRecord,()=>n({name:"record"}),"dashboard-full-record-action"):null,L(yr.viewTimeline,()=>n({name:"timeline"}),"dashboard-timeline-action")]}):null,"actions"),I;if(u.status==="error"){let w=et(u,v);I=w.kind==="error"||w.kind==="pet_not_found"?jsxRuntime.jsx(He,{variant:nr(w.error),message:w.error.displayMessage,onAction:w.error.retryable?T:void 0,testID:"dashboard-error"}):Tt(u,b,v);}else switch(k){case "loading":I=jsxRuntime.jsx(sn,{testID:"dashboard-loading"});break;case "record":I=jsxRuntime.jsxs("div",{ref:q,style:l.contentTight,"data-testid":"dashboard-record",children:[h?F:p.status==="error"?jsxRuntime.jsx("div",{style:l.inset,children:L(yr.retryMarkers,T,"dashboard-markers-retry")}):null,jsxRuntime.jsx("div",{style:l.inset,children:u.record?jsxRuntime.jsx(ri,{record:u.record,depth:O,petName:r,showLabs:!h,onNavigate:n,onAsk:a}):null}),W(true)]});break;case "error":{let w=p.error??u.error;I=jsxRuntime.jsx(He,{variant:nr(w),message:w?.displayMessage,onAction:w?.retryable?T:void 0,testID:"dashboard-error"});break}case "in_progress":I=jsxRuntime.jsxs("div",{ref:q,style:l.content,"data-testid":"dashboard-in-progress",children:[S?jsxRuntime.jsx(Db,{request:S,petName:z,onOpen:n?()=>n({name:"request",requestId:S.id}):void 0,onAsk:a?()=>{let w=wc(r,{clinicName:S.clinicName??null,statusLabel:On(S),status:S.status,heldItemCount:S.heldItemCount},S.id);a(w.prompt,w.entityRef);}:void 0}):null,n?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c.space.sm},"data-testid":"dashboard-ways",children:[jsxRuntime.jsx(ou,{title:lt.anotherClinic,sub:lt.anotherClinicSub,onClick:()=>n({name:"clinicPicker"}),testID:"dashboard-way-clinic"}),jsxRuntime.jsx(ou,{title:Jr.uploadDocument,...xn(u.uploadContentTypes)?{sub:lt.uploadDocumentPhotoSub}:{},ariaLabel:Jr.uploadDocumentA11y(r),dashed:true,onClick:()=>n({name:"upload"}),testID:"dashboard-way-upload"})]}):null,jsxRuntime.jsx(wt,{disclaimer:M})]});break;case "none":I=jsxRuntime.jsxs("div",{ref:q,style:l.content,"data-testid":"dashboard-request-prompt",children:[jsxRuntime.jsxs("section",{style:{...l.creamCard,gap:c.space.md},children:[jsxRuntime.jsx("h3",{style:{...l.sectionTitle,color:c.color.brandInk},children:Jr.firstRecordTitle(r)}),jsxRuntime.jsx("p",{style:l.bodyText,children:Jr.body}),n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{style:l.muted,children:Jr.requestFromClinicSub}),jsxRuntime.jsx(j,{label:Jr.requestFromClinic,ariaLabel:Jr.requestFromClinicA11y(r),onClick:()=>n({name:"clinicPicker"}),testID:"dashboard-request-prompt-clinic"}),jsxRuntime.jsx(j,{label:Jr.uploadDocument,kind:"outline",ariaLabel:Jr.uploadDocumentA11y(r),onClick:()=>n({name:"upload"}),testID:"dashboard-request-prompt-upload"})]}):null]}),jsxRuntime.jsx(wt,{disclaimer:M})]});break;case "labs_only":I=jsxRuntime.jsxs("div",{ref:q,style:l.contentTight,"data-testid":"dashboard-labs-only",children:[F,jsxRuntime.jsx("div",{style:l.inset,children:jsxRuntime.jsx(wt,{disclaimer:M})}),W(false)]});break;default:I=Nr(k);}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ke,{title:yr.titleWeb(r),onBack:s,testID:"dashboard-header",right:n?jsxRuntime.jsx("button",{type:"button",onClick:()=>n({name:"timeline"}),"aria-label":yr.openTimeline,style:l.iconButton,"data-testid":"dashboard-timeline-link",children:jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"flex",flexDirection:"column",gap:4},children:[0,1,2].map(w=>jsxRuntime.jsx("span",{style:{display:"block",width:18,height:2,borderRadius:2,backgroundColor:c.color.brand}},w))})}):void 0}),jsxRuntime.jsx("div",{style:l.body,children:I}),jsxRuntime.jsx(nu,{marker:y?.marker??null,point:y?.point??null,onClose:()=>g(null),onAsk:x})]})}i(Tb,"DashboardBody");function Db({request:e,petName:r,onOpen:t,onAsk:o}){let{theme:n,styles:s}=V(),a=lt.title(r),c=e.clinicName?.trim()??"",l=On(e),d=jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:n.space.lg},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:n.space.sm},children:[jsxRuntime.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:n.space.xs/2,minWidth:0},children:[jsxRuntime.jsx("span",{style:{...s.sectionTitle,color:n.color.brandInk},children:a}),c.length>0?jsxRuntime.jsx("span",{style:s.rowDetail,children:c}):null]}),t?jsxRuntime.jsx(kt,{}):null]}),jsxRuntime.jsx(fn,{request:e,petName:r}),l.length>0?jsxRuntime.jsx("p",{style:s.statusCard,children:l}):null]});return jsxRuntime.jsxs("section",{"aria-label":t?void 0:lt.a11y(r),style:{...s.creamCard,backgroundColor:n.color.surface,padding:n.space.lg+n.space.xs/2,gap:n.space.lg},"data-testid":"dashboard-in-progress-card",children:[t?jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":lt.openA11y(r,l),style:{background:"transparent",border:0,padding:0,cursor:"pointer",textAlign:"left",font:"inherit",color:"inherit",width:"100%"},"data-testid":"dashboard-in-progress-open",children:d}):d,o?jsxRuntime.jsx(j,{label:lt.ask,kind:"ask",ariaLabel:lt.askA11y,onClick:o,testID:"dashboard-in-progress-ask"}):null]})}i(Db,"InProgressCard");function ou({title:e,sub:r,ariaLabel:t,dashed:o=false,onClick:n,testID:s}){let{theme:a,styles:c}=V();return jsxRuntime.jsxs("button",{type:"button",onClick:n,"aria-label":t,style:{...c.creamCard,width:"100%",textAlign:"left",cursor:"pointer",font:"inherit",color:"inherit",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:a.space.md,...o?{borderStyle:"dashed",borderColor:a.color.brandBorderStrong}:{}},"data-testid":s,children:[jsxRuntime.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:a.space.xs/2},children:[jsxRuntime.jsx("span",{style:{...c.rowTitle,...D(a,"bold")},children:e}),r?jsxRuntime.jsx("span",{style:c.muted,children:r}):null]}),jsxRuntime.jsx(kt,{})]})}i(ou,"WayCard");function ts(e){let{style:r,className:t,renderPending:o,...n}=Ie(e,["onNavigate","onBack"]),{userRef:s}=se(),{styles:a}=V();return jsxRuntime.jsx(Oe,{capability:"records",style:r,className:t,...o?{renderPending:o}:{},...Fe(n.onBack,Me),children:jsxRuntime.jsxs("div",{className:t,style:{...a.root,...r},"data-testid":"records-requests-screen",children:[s===null?jsxRuntime.jsx("div",{style:a.body,children:jsxRuntime.jsx(or,{label:X.sessionRequired,glyph:"empty"})}):jsxRuntime.jsx(Ab,{...n}),jsxRuntime.jsx(Ae,{})]})})}i(ts,"EverfurRecordsRequests");function Ab({petRef:e,petName:r,controller:t,onNavigate:o,onBack:n,onOpenUrl:s}){let{theme:a,styles:c}=V(),l=er(t?{petRef:e,controller:t}:{petRef:e}),d=react.useMemo(()=>$i(l.requests.filter(y=>y.petRef===e)),[l.requests,e]),u=Ot("recordsClinic"),p=`${react.useId()}-requests-heading`,m;return l.status==="loading"&&d.length===0?m=jsxRuntime.jsx(Oo,{testID:"records-requests-loading"}):l.status==="error"&&l.error&&d.length===0?m=jsxRuntime.jsx(He,{variant:nr(l.error),message:l.error.displayMessage,onAction:l.error.retryable?l.refresh:void 0,testID:"records-requests-error"}):m=jsxRuntime.jsx(ii,{requests:d,petName:r,level:3,headingId:p,onOpenRequest:o?y=>o({name:"request",requestId:y.id}):void 0,onUpload:o?()=>o({name:"upload"}):void 0,...s?{onOpenUrl:s}:{}}),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ke,{title:_e.title,onBack:n,testID:"records-requests-header"}),jsxRuntime.jsx("div",{style:c.body,children:jsxRuntime.jsxs("div",{style:{...c.content,gap:a.space.lg},children:[o?jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:a.space.sm},"data-testid":"records-requests-actions",children:[u.enabled||u.isPending?jsxRuntime.jsx(j,{label:_e.requestRecords,onClick:()=>o({name:"clinicPicker"}),testID:"records-requests-request-records"}):null,jsxRuntime.jsx(j,{label:_e.uploadAction,kind:"outline",onClick:()=>o({name:"upload"}),testID:"records-requests-upload"})]}):null,m]})})]})}i(Ab,"RequestsBody");function au(e){let{petRef:r,petName:t,controller:o,clinicController:n,consentVersion:s,ownerName:a,onCaptureSignature:c,initialScreen:l,historyMode:d="memory",onExit:u,style:p,className:m,renderPending:y,onOpenUrl:g,onCopy:f,onAsk:v,location:b}=Ie(e,["onExit"]),[R,h]=react.useReducer(In,l,Zt),E=bo(R),S=R.stack.length,C=react.useRef(S);C.current=S;let k=react.useRef(S),M=react.useRef(false);react.useEffect(()=>{if(d!=="browser"||typeof window>"u")return;let F=i(W=>{let I=W.state;(typeof I?.efRecords=="number"?I.efRecords:1)<C.current&&(M.current=true,h({type:"pop"}));},"onPopState");return window.addEventListener("popstate",F),()=>window.removeEventListener("popstate",F)},[d]),react.useEffect(()=>{if(d!=="browser"||typeof window>"u")return;let F=k.current;S>F?window.history.pushState({efRecords:S},""):S<F&&!M.current&&window.history.go(S-F),M.current=false,k.current=S;},[d,S]);let T=react.useCallback(F=>h({type:"navigate",screen:F}),[]),O=react.useMemo(()=>ho(R).handled?()=>h({type:"pop"}):u,[R,u]),z=rn(E),q={onNavigate:T,...O?{onBack:O}:{},...t!==void 0?{petName:t}:{},...g?{onOpenUrl:g}:{},...f?{onCopy:f}:{},...v?{onAsk:v}:{},...b?{location:b}:{}},N={...o?{controller:o}:{},...s!==void 0?{consentVersion:s}:{}},B={...p?{style:p}:{},...m!==void 0?{className:m}:{}},x=y?{renderPending:y}:{},L;switch(E.name){case "dashboard":L=jsxRuntime.jsx(rs,{petRef:r,...q,...N,...x,...B});break;case "request":L=jsxRuntime.jsx(eo,{petRef:r,requestId:E.requestId,...q,...o?{controller:o}:{},...x,...B});break;case "timeline":L=jsxRuntime.jsx($o,{petRef:r,...q,...B});break;case "record":L=jsxRuntime.jsx(Xn,{petRef:r,...q,...N,...x,...B});break;case "document":L=jsxRuntime.jsx(Qn,{petRef:r,...q,...N,...x,...B});break;case "contributions":L=jsxRuntime.jsx(Uo,{petRef:r,docId:E.docId,...q,...B});break;case "clinicPicker":L=jsxRuntime.jsx(Ln,{petRef:r,...q,...n?{controller:n}:{},...o?{recordsController:o}:{},...B});break;case "clinicBatch":L=jsxRuntime.jsx($n,{petRef:r,petName:t??"",ownerName:a??"",...O?{onClose:O}:{},onCreated:()=>h({type:"navigate",screen:{name:"dashboard"}}),...c?{onCaptureSignature:c}:{},...n?{controller:n}:{},...B});break;case "consent":L=jsxRuntime.jsx(Hn,{petRef:r,clinic:E.clinic,...q,...a!==void 0?{ownerName:a}:{},...c?{onCaptureSignature:c}:{},...n?{controller:n}:{},...B});break;case "upload":L=jsxRuntime.jsx(Zn,{petRef:r,...q,...o?{controller:o}:{},...x,...B});break;case "requests":L=jsxRuntime.jsx(ts,{petRef:r,...q,...o?{controller:o}:{},...x,...B});break;default:L=Nr(E);}return jsxRuntime.jsx("div",{ref:z,style:zb,"data-testid":"everfur-records-flow",children:L})}i(au,"EverfurRecordsFlow");var zb=Object.freeze({display:"contents"}),Mb=au;function $b(e){let{userRef:r,scopeEpoch:t}=se();return jsxRuntime.jsx(Oe,{capability:"recordsClinic",...Fe(e.onClose,te.cancel),children:r===null?jsxRuntime.jsx("p",{role:"alert",children:X.sessionRequired}):jsxRuntime.jsx(Ub,{...Ie(e,["onClose","onCreated"])},JSON.stringify([r,t,e.petRef,e.petName]))})}i($b,"EverfurClinicRequest");function Ub(e){let r=zr(),t=e.controller??r,o=ye(),n={current:null},s=Mt(()=>n.current?.invalidate()),a=gd(e,t,e.onCaptureSignature??(async u=>s.signed?s.register(t,u.signal):null));n.current=a;let c={minHeight:44,padding:o.space.sm,border:`1px solid ${o.color.borderHairlineGreen}`,borderRadius:o.radius.sm,background:o.color.surface,color:o.color.text.primary,font:"inherit"},l={...c,cursor:"pointer"},d=i(()=>{a.busy||s.clear();},"clear");return jsxRuntime.jsxs("section",{className:e.className,"aria-label":te.title,style:{background:o.color.surface,color:o.color.text.primary,padding:o.space.lg,borderRadius:o.radius.lg,minHeight:120,minWidth:0,overflowWrap:"anywhere",...e.style},children:[jsxRuntime.jsx("h2",{style:{margin:0,fontSize:o.type.size.heading},children:te.title}),jsxRuntime.jsx("p",{style:{margin:`${o.space.sm}px 0 ${o.space.lg}px`},children:e.petName}),a.created?jsxRuntime.jsx("p",{role:"status",children:a.created.statusLabel||X.records}):jsxRuntime.jsxs("div",{style:{display:"grid",gap:o.space.md},children:[jsxRuntime.jsxs("label",{children:[te.ownerName,jsxRuntime.jsx("input",{style:{...c,display:"block",width:"100%",boxSizing:"border-box"},maxLength:200,value:a.ownerName,disabled:a.busy,autoComplete:"name",onChange:u=>{d(),a.setOwnerName(u.target.value);}})]}),jsxRuntime.jsxs("label",{children:[te.clinic,jsxRuntime.jsx("input",{style:{...c,display:"block",width:"100%",boxSizing:"border-box"},placeholder:te.placeholder,maxLength:200,value:a.query,disabled:a.busy,autoComplete:"off",onChange:u=>{d(),a.setQuery(u.target.value);}})]}),jsxRuntime.jsx("button",{type:"button",style:l,disabled:a.busy||a.searching||a.query.trim().length<2,onClick:()=>{a.search();},children:te.search}),a.searching&&jsxRuntime.jsx("p",{role:"status",children:X.loading}),a.recent.length>0&&jsxRuntime.jsx("h3",{style:{margin:`${o.space.sm}px 0 0`,fontSize:o.type.size.subtitle},"data-testid":"records-clinic-recent-label",children:te.recentlyUsed}),a.recent.map(u=>jsxRuntime.jsxs("button",{type:"button",style:l,disabled:a.busy,onClick:()=>{d(),a.selectClinic(u);},children:[u.name,u.address?`, ${u.address}`:"",u.phone?`, ${u.phone}`:""]},`recent-${u.id}`)),a.visibleClinics.map(u=>jsxRuntime.jsxs("button",{type:"button",style:l,disabled:a.busy,onClick:()=>{d(),a.selectClinic(u);},children:[u.name,u.address?`, ${u.address}`:"",u.phone?`, ${u.phone}`:""]},u.id)),a.hasMoreClinics&&jsxRuntime.jsx("button",{type:"button",style:l,disabled:a.busy,onClick:a.showMoreClinics,"data-testid":"records-clinic-results-more",children:te.moreClinics}),a.needsEmail&&jsxRuntime.jsxs("label",{children:[te.email,jsxRuntime.jsx("input",{style:{...c,display:"block",width:"100%",boxSizing:"border-box"},type:"email",placeholder:te.emailPlaceholder,maxLength:320,autoComplete:"off",value:a.email,disabled:a.busy,onChange:u=>{d(),a.setEmail(u.target.value);}})]}),jsxRuntime.jsx("h3",{style:{margin:`${o.space.sm}px 0 0`,fontSize:o.type.size.subtitle},children:te.scopeHeading}),a.copy?jsxRuntime.jsx("p",{style:{whiteSpace:"pre-wrap",margin:0},children:a.query.trim()&&a.ownerName.trim()?a.scope??H("internalError").displayMessage:X.consentRequired}):!a.error&&jsxRuntime.jsx("p",{role:"status",children:X.loading}),!e.onCaptureSignature&&jsxRuntime.jsx($t,{pad:s,disabled:a.busy}),a.error&&jsxRuntime.jsx("p",{role:"alert",children:a.error.displayMessage}),!a.copy&&a.error&&jsxRuntime.jsx("button",{type:"button",style:l,onClick:a.retryCopy,children:X.retry}),jsxRuntime.jsx("button",{type:"button",style:{...l,background:o.color.primary,color:o.color.onPrimary,opacity:a.busy||!a.ready||!e.onCaptureSignature&&!s.signed?.5:1},disabled:a.busy||!a.ready||!e.onCaptureSignature&&!s.signed,onClick:()=>{a.submit();},children:a.busy?te.sending:te.send})]}),e.onClose&&jsxRuntime.jsx("button",{type:"button",style:l,disabled:a.busy,onClick:e.onClose,children:te.cancel}),jsxRuntime.jsx(Ae,{})]})}i(Ub,"ClinicRequestBody");var Bb="file",Hb="records upload: the file handle carries no bytes",su="records upload failed";function jb(e={}){let r=e.xhr??(()=>new XMLHttpRequest);return Object.freeze({postMultipart(t,o,n){return new Promise((s,a)=>{let c=o.blob;if(c===void 0){a(new Error(Hb));return}let{signal:l,onProgress:d}=n;if(l?.aborted===true){a(new Error(su));return}let u=new FormData;for(let[f,v]of Object.entries(t.upload_fields))u.append(f,v);u.append(Bb,c,Cs(o.mimeType));let p=r(),m=false,y=i(f=>{m||(m=true,l?.removeEventListener("abort",g),f?s():a(new Error(su)));},"settle"),g=i(()=>{p.abort(),y(false);},"onAbort");p.open("POST",t.upload_url,true),p.withCredentials=false,d&&(p.upload.onprogress=f=>{!f.lengthComputable||f.total<=0||d(Math.min(1,Math.max(0,f.loaded/f.total)));}),p.onload=()=>y(p.status>=200&&p.status<300),p.onerror=()=>y(false),p.onabort=()=>y(false),p.ontimeout=()=>y(false),l?.addEventListener("abort",g,{once:true}),p.send(u);})}})}i(jb,"createWebRecordsUploadTransport");
4
+ exports.EverfurClinicPicker=Ln;exports.EverfurClinicRequest=$b;exports.EverfurClinicRequestBatch=$n;exports.EverfurRecordDetail=Xn;exports.EverfurRecordDocument=Qn;exports.EverfurRecords=Mb;exports.EverfurRecordsConsent=Hn;exports.EverfurRecordsDashboard=rs;exports.EverfurRecordsFlow=au;exports.EverfurRecordsPage=mb;exports.EverfurRecordsRequest=eo;exports.EverfurRecordsRequests=ts;exports.EverfurRecordsUpload=Zn;exports.RECORDS_CLINIC_BATCH_MAX=en;exports.RECORDS_DOCUMENT_ACCEPT=Kd;exports.RECORDS_TERMINAL=Is;exports.REQUEST_TIMELINE_TITLES=mn;exports.RequestDocumentsList=Jn;exports.SignatureCanvas=$t;exports.acceptsPhotos=xn;exports.applyFactOverlay=Fa;exports.buildRequestTimeline=Ia;exports.createWebRecordsUploadTransport=jb;exports.currentRecordsScreen=bo;exports.deriveRecordsDashboardState=Ai;exports.fileToHandle=Vo;exports.initialRecordsNav=Zt;exports.isFactEditable=qa;exports.isPdfBlob=Xd;exports.isTerminalStatus=Jt;exports.isUploadableHandle=yy;exports.pickDocument=gy;exports.pickPetRecordsRequest=go;exports.popRecordsNav=ho;exports.pushRecordsNav=qi;exports.recordsDenialReasonOf=bt;exports.recordsDocumentAccept=jo;exports.recordsNavReducer=In;exports.replaceRecordsNav=Ni;exports.requestDocumentRows=Ha;exports.resetRecordsNav=Li;exports.selectClinicCall=vo;exports.selectDashboardView=Fi;exports.selectPrimaryLabel=On;exports.selectRequestList=$i;exports.selectRequestTitle=Ro;exports.transitionRecordsNav=nl;exports.useEverfurRecords=er;exports.useEverfurRecordsClinic=zr;exports.useEverfurRecordsClinicBatch=ra;exports.useRecordFactEdit=Na;exports.useRecordPdfLink=xa;exports.useRecordShares=Ea;exports.useRecordsMarkers=Ra;exports.useRequestDocuments=Va;exports.useSignatureCanvas=Mt;