@everfur/sdk 0.6.0 → 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 +213 -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-CHqcgMyw.d.ts → Chat-DZpYH8Uh.d.ts} +4 -4
  5. package/dist/{Chat-BoAvCWhI.d.cts → Chat-bATY4atj.d.cts} +4 -4
  6. package/dist/{DepthViews-7Y8Ur058.d.ts → DepthViews-BpHUbjSY.d.cts} +1 -1
  7. package/dist/{DepthViews-B0g83e_N.d.cts → DepthViews-C4DC4Kom.d.cts} +1 -1
  8. package/dist/{DepthViews-Dg2bIon_.d.ts → DepthViews-dLTizxjr.d.ts} +1 -1
  9. package/dist/{DepthViews-CT5mQld9.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-CfxsVg7W.d.ts → attachments-CPRFfoHT.d.ts} +2 -2
  15. package/dist/{attachments-rkox0ewd.d.cts → attachments-CUOGILir.d.cts} +5 -5
  16. package/dist/{attachments-CThFsH4b.d.ts → attachments-CXAnZcEg.d.ts} +5 -5
  17. package/dist/{attachments-C3HJNYQ7.d.cts → attachments-Ce06TWqe.d.cts} +2 -2
  18. package/dist/{bookingCopy-Do3zMeXb.d.cts → bookingCopy-BwVopcoV.d.cts} +451 -50
  19. package/dist/{bookingCopy-Y3OGdoMT.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-DYWma2il.d.ts → branding-Bio5MM6g.d.cts} +3 -3
  23. package/dist/{branding-ChXm8gxI.d.cts → branding-ytH4jJq1.d.ts} +3 -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-Jj6t60AY.d.cts → casesRepository-CJchNp3x.d.cts} +1 -1
  27. package/dist/{casesRepository-BbgXYPxa.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 +2 -2
  33. package/dist/client/index.d.cts +10 -10
  34. package/dist/client/index.d.ts +10 -10
  35. package/dist/client/index.js +2 -2
  36. package/dist/{config-Dfbj5mlx.d.ts → config-ZxwCylac.d.ts} +1 -1
  37. package/dist/{config-BZX97FmW.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-DJXnZ1Mx.d.cts → context-CtsAgJnc.d.cts} +7 -7
  43. package/dist/{context-Cbe0zYym.d.ts → context-DtPIshVA.d.ts} +7 -7
  44. package/dist/{copy-dKK5KoAQ.d.cts → copy-CaWaplQc.d.cts} +2 -2
  45. package/dist/{copy-DHekqSKE.d.ts → copy-Cg89Qoal.d.ts} +2 -2
  46. package/dist/core/index.cjs +7 -7
  47. package/dist/core/index.d.cts +21 -21
  48. package/dist/core/index.d.ts +21 -21
  49. package/dist/core/index.js +7 -7
  50. package/dist/{depth-CrpRjWGB.d.ts → depth-Bo4bAwcn.d.ts} +132 -38
  51. package/dist/{depth-NmWSbvfi.d.cts → depth-EXZYEO70.d.cts} +132 -38
  52. package/dist/{entitlementRepository-iL-9vS1i.d.cts → entitlementRepository-BYtVb1oU.d.cts} +3 -3
  53. package/dist/{entitlementRepository-tVNazi8R.d.ts → entitlementRepository-DcbIx8yV.d.ts} +3 -3
  54. package/dist/{identity-B8rp0L9G.d.ts → identity-EC5-apbY.d.ts} +1 -1
  55. package/dist/{identity-D7PO5s9m.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-BQbXmICf.d.ts → pets-B_27_agU.d.ts} +1 -1
  63. package/dist/{pets-BWx9BKea.d.cts → pets-DM8QvKLo.d.cts} +1 -1
  64. package/dist/{petsRepository-SqIvEMiT.d.cts → petsRepository-BJsJ4cju.d.cts} +1 -1
  65. package/dist/{petsRepository-0oBVydl6.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-ChnzSy4E.d.cts → ports-ZmJYgd5I.d.cts} +10 -9
  69. package/dist/{ports-iXPWd7Vt.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-DAwb7haa.d.cts → requestFunnel-C_cZXhIA.d.cts} +2 -2
  79. package/dist/{requestFunnel-CQzz2DIW.d.ts → requestFunnel-Ve9BshTB.d.ts} +2 -2
  80. package/dist/{runtimeTypes-BNOxfmfg.d.ts → runtimeTypes-ByKsp8hm.d.ts} +5 -5
  81. package/dist/{runtimeTypes-DB9-kigO.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-BuNhzDbH.d.cts → timelineRows-BNF43SXK.d.cts} +1 -1
  111. package/dist/{timelineRows-Dll2IGFg.d.ts → timelineRows-DXpjECfA.d.ts} +1 -1
  112. package/dist/{tokens-ARWZtMOU.d.cts → tokens-BYtbKwFh.d.cts} +6 -3
  113. package/dist/{tokens-ARWZtMOU.d.ts → tokens-BYtbKwFh.d.ts} +6 -3
  114. package/dist/{typeStyle-YCS8dt19.d.cts → typeStyle-BqfwxZH4.d.cts} +2 -2
  115. package/dist/{typeStyle-8iEqQmP_.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-CNEHZJtj.d.cts → useRecordsDepth-CARTuHKh.d.cts} +1 -1
  119. package/dist/{useRecordsDepth-CuNdne6E.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-BhqWlYrZ.d.cts → view-DGPaVno8.d.cts} +47 -5
  123. package/dist/{view-DFy8EDwf.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 +3 -3
  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 +3 -3
  154. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1,12 +1,12 @@
1
- 'use strict';var react=require('react'),reactNativeSafeAreaContext=require('react-native-safe-area-context'),zod=require('zod'),ub=require('react-native-sse'),reactNative=require('react-native'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ub__default=/*#__PURE__*/_interopDefault(ub);var $f=Object.defineProperty;var i=(e,t)=>$f(e,"name",{value:t,configurable:true});function ve(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let n=e.charCodeAt(t+1);if(!(n>=56320&&n<=57343))return true;t+=1;}else if(r>=56320&&r<=57343)return true}return false}i(ve,"hasLoneSurrogate");function pt(e){return [...e].length}i(pt,"serverLength");function L(e,t){return Object.freeze(t===void 0?{ok:true,value:e}:{ok:true,value:e,warning:t})}i(L,"ok");function E(e){return Object.freeze({ok:false,error:e})}i(E,"err");function Yf(e){return e.ok}i(Yf,"isOk");function Xf(e){return !e.ok}i(Xf,"isErr");var Hr=class Hr extends Error{constructor(t){super(`${t.code}: ${t.displayMessage}`),this.name="EverfurThrownError",this.error=t,this.code=t.code,this.category=t.category,Object.setPrototypeOf(this,Hr.prototype);}};i(Hr,"EverfurThrownError");var Br=Hr;function Qf(e){if(e.ok)return e.value;throw new Br(e.error)}i(Qf,"unwrap");var zr=class zr extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,zr.prototype);}};i(zr,"EverfurConfigError");var ee=zr;var xs=128,_s=128,ws=/[\u0000-\u001F\u007F]/,Zf=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Jf(e){let t=e,r=pt(t);if(r===0||r>_s)throw new ee("invalid-argument",`petRef must be 1..${_s} characters`);if(ws.test(t))throw new ee("invalid-argument","petRef must be printable (no control characters)");return t}i(Jf,"petRef");function em(e){let t=e,r=pt(t);if(r===0||r>xs)throw new ee("invalid-argument",`userRef must be 1..${xs} characters`);if(t.includes("@"))throw new ee("invalid-argument","userRef must not contain '@'");if(ws.test(t))throw new ee("invalid-argument","userRef must be printable (no control characters)");return t}i(em,"userRef");function tm(e){if(!Zf.test(e))throw new ee("invalid-argument","conversationId must be a UUID");return e}i(tm,"conversationId");var Jn=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(Jn.map(e=>e.wireCode));var rm=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"}),As=Object.freeze(Jn.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:rm[e.wireCode]}))),nm=new Map(As.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),om=Object.freeze(["http_envelope",...[...new Set(As.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function jr(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let n of [t??"http_envelope",...om]){let o=nm.get(n+r);if(o)return o}}i(jr,"contractErrorFor");function im(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(im,"contractDocUrl");function Os(e){return null}i(Os,"publishedDocUrl");var sm=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 eo(e){return sm[e]}i(eo,"categoryFor");function Me(e){let t=jr(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return "authRejected";if(r.startsWith("AUTH"))return "authExpired";switch(n){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":case "TELEVETRATELIMITED":return "rateLimited";case "IDEMPOTENCYKEYCONFLICT":case "IDEMPOTENCYCONFLICT":return "idempotencyConflict";case "ACCESSDENIED":case "FORBIDDEN":return "accessDenied";case "NOTFOUND":case "CONVERSATIONNOTFOUND":return "conversationNotFound";case "PETNOTFOUND":return "petNotFound";case "TIMEOUT":case "STREAMTIMEOUT":return "streamTimeout";case "MEDIAUPLOADFAILED":case "UNRECOGNIZEDVIDEOFORMAT":case "FILETOOSMALL":return "mediaUploadFailed";case "MODERATIONBLOCKED":return "moderationBlocked";case "UPSTREAMLLMTIMEOUT":return "upstreamLlmTimeout";case "INTERNALERROR":case "INTERNALSERVERERROR":return "internalError";case "STREAMINCOMPLETE":case "CHATSTREAMINCOMPLETE":return "streamIncomplete";case "INVALIDANALYSISTYPE":case "INVALIDUPLOADPURPOSE":return "unknown";default:return "unknown"}}i(Me,"fromWire");function Fs(e){return e===401?"authExpired":e===403?"accessDenied":e===404?"conversationNotFound":e===409?"idempotencyConflict":e===421?"unknown":e===429?"rateLimited":e===400||e===422?"unknown":e>=500?"internalError":"unknown"}i(Fs,"fromHttpStatus");var am=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function We(e){return am.has(e)}i(We,"isAutoRetryable");var lm=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function to(e){return We(e)||lm.has(e)}i(to,"isRetryableCode");function Wr(e,t=false){return t||We(e)}i(Wr,"shouldRetry");var um=500,ro=8e3,rr=4;function Gr(e,t=Math.random){let r=Math.max(0,e),n=Math.min(um*2**r,ro);return Math.floor(t()*n)}i(Gr,"backoffDelayMs");function Ms(e){return e==="conversationNotFound"}i(Ms,"canRecreateOnNotFound");var dm=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 Mt(e){return dm[e]}i(Mt,"userFacingError");function Ls(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(Ls,"defineHidden");var cm=/^[a-z][a-z0-9_]{0,63}$/;function D(e,t){let r=jr(t?.wireCode,t?.wireEnvelope),n={code:e,category:eo(e),retryable:t?.retryable??to(e),displayMessage:Mt(e)};if(t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&cm.test(t.reasonCode)&&(n.reasonCode=t.reasonCode),r);return t?.wireMessage&&Ls(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Ls(n,"raw",t.raw),Object.freeze(n)}i(D,"makeEverfurError");var pm="file",no="multipart upload failed";function Kr(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(pm,e.file);}catch{return Promise.reject(new Error(no))}return e.fetch!==void 0?ym(e.fetch,e.url,t,e.signal):mm(e.url,t,e.signal)}i(Kr,"postRnMultipart");function fm(e){return e>=200&&e<300}i(fm,"stored");function mm(e,t,r){return new Promise((n,o)=>{let s=globalThis.XMLHttpRequest;if(typeof s!="function"||r?.aborted===true){o(new Error(no));return}let a=null,l=i(()=>{a!==null&&r?.removeEventListener("abort",a);},"release"),u=i(()=>{l(),o(new Error(no));},"fail");try{let d=new s;d.open("POST",e),d.withCredentials=!1,d.onload=()=>{l(),n(fm(d.status));},d.onerror=u,d.ontimeout=u,d.onabort=u,r!==void 0&&(a=i(()=>{try{d.abort();}finally{u();}},"onAbort"),r.addEventListener("abort",a,{once:!0})),d.send(t);}catch{u();}})}i(mm,"postWithXhr");function ym(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(o=>o.ok)}i(ym,"postWithFetch");var gm="document.pdf",hm="records upload: the file handle has no uri",bm="records upload failed";function vm(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(hm));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(bm)),"failed");return o?.aborted===true?a():Kr({url:t.upload_url,fields:t.upload_fields,file:{uri:r.uri,name:gm,type:"application/pdf"},signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(vm,"createRnRecordsUploadTransport");var qr=Object.freeze({track(){},trackExpectedFailure(){}});var Ds=Object.freeze({shouldRetry(e,t){return We(e)&&t<rr},maxAttempts(){return rr}});var Ns=Object.freeze({isAvailable:false,async capture(){return Promise.reject(new Error("CameraPort is unavailable; check isAvailable before calling capture"))}});function nt(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(nt,"assertNever");function Us(e,t,r=null){return Object.freeze({kind:"accepted",streamId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(Us,"acceptedFrame");function Vs(e,t=null){return Object.freeze({kind:"heartbeat",lastEventId:e,serverRequestId:t,terminal:false})}i(Vs,"heartbeatFrame");function Bs(e,t,r=null){return Object.freeze({kind:"delta",delta:e,lastEventId:t,serverRequestId:r,terminal:false})}i(Bs,"deltaFrame");function Hs(e,t=null){return Object.freeze({kind:"done",terminal:true,conversationId:e.conversationId,messageId:e.messageId,title:e.title,followUpQuestions:Object.freeze([...e.followUpQuestions]),citations:Object.freeze([...e.citations]),citationStatus:e.citationStatus,urgencyLevel:e.urgencyLevel,urgencyReason:e.urgencyReason,urgencyProvided:e.urgencyProvided??e.urgencyLevel!==null,resultId:e.resultId,lastEventId:e.lastEventId,serverRequestId:t})}i(Hs,"doneFrame");function fe(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(fe,"errorFrame");function zs(e,t,r=null){return Object.freeze({kind:"analysisStarted",requestId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(zs,"analysisStartedFrame");function js(e,t=null){return Object.freeze({kind:"analysisComplete",terminal:false,resultId:e.resultId,analysisType:e.analysisType,modelVersion:e.modelVersion,confidence:e.confidence,detections:Object.freeze([...e.detections]),interpretation:e.interpretation,lastEventId:e.lastEventId,serverRequestId:t})}i(js,"analysisCompleteFrame");function Ws(e,t,r=null){return Object.freeze({kind:"unknown",raw:{...e},lastEventId:t,serverRequestId:r,terminal:false})}i(Ws,"unknownFrame");function Gs(e,t,r){let n=null,o=null,s=false,a=i(()=>o||(o=(async()=>{try{let l=await t(),u=typeof l=="string"?l:l?.token;if(typeof u!="string"||u.length===0)throw new ee("invalid-argument","TokenProvider returned an empty token");return n=u,r?.(typeof l=="string"?null:Rm(l.expiresAt)),u}finally{o=null;}})(),o),"load");return {userRef:e,async currentToken(l){if(s)throw new ee("not-initialized","This identity was cleared (sign-out); mint a new one.");return l?.forceRefresh&&(n=null),n!==null?n:a()},hasToken(){return !s&&n!==null},clear(){s=true,n=null;}}}i(Gs,"createIdentityProvider");function Rm(e){if(e===void 0)return null;let t=typeof e=="number"?e<1e11?e*1e3:e:new Date(e).getTime();return Number.isFinite(t)?t:null}i(Rm,"expiryMs");function io(){let e=new Uint8Array(16),t=globalThis.crypto;if(typeof t?.getRandomValues=="function")t.getRandomValues(e);else for(let n=0;n<e.length;n+=1)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let r=[];for(let n=0;n<e.length;n+=1)r.push(e[n].toString(16).padStart(2,"0"));return r.slice(0,4).join("")+"-"+r.slice(4,6).join("")+"-"+r.slice(6,8).join("")+"-"+r.slice(8,10).join("")+"-"+r.slice(10,16).join("")}i(io,"newSessionId");function Sm(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:t["x-everfur-partner-key"]=e.publishableKey,e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}i(Sm,"authHeaders");function nr(e,t){return {...e,headers:{...Tm(e.headers),...Sm(t)}}}i(nr,"withAuthHeaders");function Tm(e){if(!e)return {};let t={};for(let[r,n]of Object.entries(e)){let o=r.toLowerCase();o==="authorization"||o==="x-everfur-partner-key"||(t[r]=n);}return t}i(Tm,"stripAuthHeaders");async function Ks(e,t){if(t.mode==="anonymous")return t.transport.request(nr(e,{mode:"anonymous",publishableKey:t.publishableKey,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));let r;try{r=await t.identity.currentToken();}catch{return E(oo())}let n=await t.transport.request(nr(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let o;try{o=await t.identity.currentToken({forceRefresh:!0});}catch{return E(oo())}let s=await t.transport.request(nr(e,{mode:"personalized",token:o,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !s.ok&&s.error.httpStatus===401?E(oo(s.error.httpStatus)):s}i(Ks,"authedSend");function oo(e){return D("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(oo,"authRejectedError");var qs=`
1
+ 'use strict';var zod=require('zod'),react=require('react'),reactNativeSafeAreaContext=require('react-native-safe-area-context'),fb=require('react-native-sse'),reactNative=require('react-native'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var fb__default=/*#__PURE__*/_interopDefault(fb);var Xf=Object.defineProperty;var i=(e,t)=>Xf(e,"name",{value:t,configurable:true});function Ce(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let n=e.charCodeAt(t+1);if(!(n>=56320&&n<=57343))return true;t+=1;}else if(r>=56320&&r<=57343)return true}return false}i(Ce,"hasLoneSurrogate");function gt(e){return [...e].length}i(gt,"serverLength");function L(e,t){return Object.freeze(t===void 0?{ok:true,value:e}:{ok:true,value:e,warning:t})}i(L,"ok");function v(e){return Object.freeze({ok:false,error:e})}i(v,"err");function Qf(e){return e.ok}i(Qf,"isOk");function Zf(e){return !e.ok}i(Zf,"isErr");var Wr=class Wr extends Error{constructor(t){super(`${t.code}: ${t.displayMessage}`),this.name="EverfurThrownError",this.error=t,this.code=t.code,this.category=t.category,Object.setPrototypeOf(this,Wr.prototype);}};i(Wr,"EverfurThrownError");var jr=Wr;function Jf(e){if(e.ok)return e.value;throw new jr(e.error)}i(Jf,"unwrap");var Gr=class Gr extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,Gr.prototype);}};i(Gr,"EverfurConfigError");var re=Gr;var As=128,Os=128,Fs=/[\u0000-\u001F\u007F]/,em=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function tm(e){let t=e,r=gt(t);if(r===0||r>Os)throw new re("invalid-argument",`petRef must be 1..${Os} characters`);if(Fs.test(t))throw new re("invalid-argument","petRef must be printable (no control characters)");return t}i(tm,"petRef");function rm(e){let t=e,r=gt(t);if(r===0||r>As)throw new re("invalid-argument",`userRef must be 1..${As} characters`);if(t.includes("@"))throw new re("invalid-argument","userRef must not contain '@'");if(Fs.test(t))throw new re("invalid-argument","userRef must be printable (no control characters)");return t}i(rm,"userRef");function nm(e){if(!em.test(e))throw new re("invalid-argument","conversationId must be a UUID");return e}i(nm,"conversationId");var ao=Object.freeze([Object.freeze({wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false}),Object.freeze({wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true}),Object.freeze({wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true}),Object.freeze({wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true}),Object.freeze({wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false}),Object.freeze({wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false}),Object.freeze({wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false}),Object.freeze({wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false}),Object.freeze({wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false}),Object.freeze({wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true}),Object.freeze({wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false}),Object.freeze({wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false}),Object.freeze({wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false}),Object.freeze({wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false}),Object.freeze({wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false}),Object.freeze({wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false}),Object.freeze({wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false}),Object.freeze({wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true}),Object.freeze({wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true}),Object.freeze({wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true}),Object.freeze({wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false}),Object.freeze({wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false})]);Object.freeze(ao.map(e=>e.wireCode));var om=Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict"}),Ls=Object.freeze(ao.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:om[e.wireCode]}))),im=new Map(Ls.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),sm=Object.freeze(["http_envelope",...[...new Set(Ls.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function Kr(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let n of [t??"http_envelope",...sm]){let o=im.get(n+r);if(o)return o}}i(Kr,"contractErrorFor");function am(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(am,"contractDocUrl");function Ns(e){return null}i(Ns,"publishedDocUrl");var lm=Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function lo(e){return lm[e]}i(lo,"categoryFor");function Fe(e){let t=Kr(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return "authRejected";if(r.startsWith("AUTH"))return "authExpired";switch(n){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":case "TELEVETRATELIMITED":return "rateLimited";case "IDEMPOTENCYKEYCONFLICT":case "IDEMPOTENCYCONFLICT":return "idempotencyConflict";case "ACCESSDENIED":case "FORBIDDEN":return "accessDenied";case "NOTFOUND":case "CONVERSATIONNOTFOUND":return "conversationNotFound";case "PETNOTFOUND":return "petNotFound";case "TIMEOUT":case "STREAMTIMEOUT":return "streamTimeout";case "MEDIAUPLOADFAILED":case "UNRECOGNIZEDVIDEOFORMAT":case "FILETOOSMALL":return "mediaUploadFailed";case "MODERATIONBLOCKED":return "moderationBlocked";case "UPSTREAMLLMTIMEOUT":return "upstreamLlmTimeout";case "INTERNALERROR":case "INTERNALSERVERERROR":return "internalError";case "STREAMINCOMPLETE":case "CHATSTREAMINCOMPLETE":return "streamIncomplete";case "INVALIDANALYSISTYPE":case "INVALIDUPLOADPURPOSE":return "unknown";default:return "unknown"}}i(Fe,"fromWire");function Ds(e){return e===401?"authExpired":e===403?"accessDenied":e===404?"conversationNotFound":e===409?"idempotencyConflict":e===421?"unknown":e===429?"rateLimited":e===400||e===422?"unknown":e>=500?"internalError":"unknown"}i(Ds,"fromHttpStatus");var um=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function Ge(e){return um.has(e)}i(Ge,"isAutoRetryable");var dm=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function uo(e){return Ge(e)||dm.has(e)}i(uo,"isRetryableCode");function qr(e,t=false){return t||Ge(e)}i(qr,"shouldRetry");var cm=500,co=8e3,rr=4;function $r(e,t=Math.random){let r=Math.max(0,e),n=Math.min(cm*2**r,co);return Math.floor(t()*n)}i($r,"backoffDelayMs");function Us(e){return e==="conversationNotFound"}i(Us,"canRecreateOnNotFound");var pm=Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:"This feature isn't available on your account right now.",paymentRequired:"This is part of a paid plan.",quotaExceeded:"You have used today's messages. This resets tomorrow.",rateLimited:"You are sending messages quickly. Try again in a few seconds.",validationFailed:"Something in that request was not right. Check the details and try again.",sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",unknown:"Something went wrong. Please try again."});function Dt(e){return pm[e]}i(Dt,"userFacingError");function Vs(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(Vs,"defineHidden");var fm=/^[a-z][a-z0-9_]{0,63}$/;function D(e,t){let r=Kr(t?.wireCode,t?.wireEnvelope),n={code:e,category:lo(e),retryable:t?.retryable??uo(e),displayMessage:Dt(e)};if(t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&fm.test(t.reasonCode)&&(n.reasonCode=t.reasonCode),r);return t?.wireMessage&&Vs(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Vs(n,"raw",t.raw),Object.freeze(n)}i(D,"makeEverfurError");var Hs="application/pdf",Yr=Object.freeze(["image/jpeg","image/png","image/heic","image/heif"]);zod.z.object({features:zod.z.record(zod.z.boolean()),upload_content_types:zod.z.array(zod.z.string()).nullish(),share_audiences:zod.z.unknown().optional()});var mm=i(e=>Yr.includes(e),"isPhotoType");function po(e,t){return e===Hs||t!==void 0&&mm(e)&&t.includes(e)}i(po,"isAcceptedUploadType");var Bs=Object.freeze({"application/pdf":"document.pdf","image/jpeg":"document.jpg","image/png":"document.png","image/heic":"document.heic","image/heif":"document.heif"});function zs(e){return po(e,Yr)?Bs[e]:Bs["application/pdf"]}i(zs,"recordsUploadFilename");var ym="file",fo="multipart upload failed";function Xr(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(ym,e.file);}catch{return Promise.reject(new Error(fo))}return e.fetch!==void 0?bm(e.fetch,e.url,t,e.signal):hm(e.url,t,e.signal)}i(Xr,"postRnMultipart");function gm(e){return e>=200&&e<300}i(gm,"stored");function hm(e,t,r){return new Promise((n,o)=>{let s=globalThis.XMLHttpRequest;if(typeof s!="function"||r?.aborted===true){o(new Error(fo));return}let a=null,l=i(()=>{a!==null&&r?.removeEventListener("abort",a);},"release"),u=i(()=>{l(),o(new Error(fo));},"fail");try{let d=new s;d.open("POST",e),d.withCredentials=!1,d.onload=()=>{l(),n(gm(d.status));},d.onerror=u,d.ontimeout=u,d.onabort=u,r!==void 0&&(a=i(()=>{try{d.abort();}finally{u();}},"onAbort"),r.addEventListener("abort",a,{once:!0})),d.send(t);}catch{u();}})}i(hm,"postWithXhr");function bm(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(o=>o.ok)}i(bm,"postWithFetch");var vm="records upload: the file handle has no uri",Em="records upload failed";function Cm(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(vm));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(Em)),"failed");return o?.aborted===true?a():Xr({url:t.upload_url,fields:t.upload_fields,file:{uri:r.uri,name:zs(r.mimeType),type:Rm(r.mimeType)},signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(Cm,"createRnRecordsUploadTransport");function Rm(e){return po(e,Yr)?e:"application/pdf"}i(Rm,"partType");var Qr=Object.freeze({track(){},trackExpectedFailure(){}});var js=Object.freeze({shouldRetry(e,t){return Ge(e)&&t<rr},maxAttempts(){return rr}});var Ws=Object.freeze({isAvailable:false,async capture(){return Promise.reject(new Error("CameraPort is unavailable; check isAvailable before calling capture"))}});function at(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(at,"assertNever");function Gs(e,t,r=null){return Object.freeze({kind:"accepted",streamId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(Gs,"acceptedFrame");function Ks(e,t=null){return Object.freeze({kind:"heartbeat",lastEventId:e,serverRequestId:t,terminal:false})}i(Ks,"heartbeatFrame");function qs(e,t,r=null){return Object.freeze({kind:"delta",delta:e,lastEventId:t,serverRequestId:r,terminal:false})}i(qs,"deltaFrame");function $s(e,t=null){return Object.freeze({kind:"done",terminal:true,conversationId:e.conversationId,messageId:e.messageId,title:e.title,followUpQuestions:Object.freeze([...e.followUpQuestions]),citations:Object.freeze([...e.citations]),citationStatus:e.citationStatus,urgencyLevel:e.urgencyLevel,urgencyReason:e.urgencyReason,urgencyProvided:e.urgencyProvided??e.urgencyLevel!==null,resultId:e.resultId,lastEventId:e.lastEventId,serverRequestId:t})}i($s,"doneFrame");function ye(e){return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:e.serverRequestId??null})}i(ye,"errorFrame");function Ys(e,t,r=null){return Object.freeze({kind:"analysisStarted",requestId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(Ys,"analysisStartedFrame");function Xs(e,t=null){return Object.freeze({kind:"analysisComplete",terminal:false,resultId:e.resultId,analysisType:e.analysisType,modelVersion:e.modelVersion,confidence:e.confidence,detections:Object.freeze([...e.detections]),interpretation:e.interpretation,lastEventId:e.lastEventId,serverRequestId:t})}i(Xs,"analysisCompleteFrame");function Qs(e,t,r=null){return Object.freeze({kind:"unknown",raw:{...e},lastEventId:t,serverRequestId:r,terminal:false})}i(Qs,"unknownFrame");function Zs(e,t,r){let n=null,o=null,s=false,a=i(()=>o||(o=(async()=>{try{let l=await t(),u=typeof l=="string"?l:l?.token;if(typeof u!="string"||u.length===0)throw new re("invalid-argument","TokenProvider returned an empty token");return n=u,r?.(typeof l=="string"?null:Pm(l.expiresAt)),u}finally{o=null;}})(),o),"load");return {userRef:e,async currentToken(l){if(s)throw new re("not-initialized","This identity was cleared (sign-out); mint a new one.");return l?.forceRefresh&&(n=null),n!==null?n:a()},hasToken(){return !s&&n!==null},clear(){s=true,n=null;}}}i(Zs,"createIdentityProvider");function Pm(e){if(e===void 0)return null;let t=typeof e=="number"?e<1e11?e*1e3:e:new Date(e).getTime();return Number.isFinite(t)?t:null}i(Pm,"expiryMs");function yo(){let e=new Uint8Array(16),t=globalThis.crypto;if(typeof t?.getRandomValues=="function")t.getRandomValues(e);else for(let n=0;n<e.length;n+=1)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let r=[];for(let n=0;n<e.length;n+=1)r.push(e[n].toString(16).padStart(2,"0"));return r.slice(0,4).join("")+"-"+r.slice(4,6).join("")+"-"+r.slice(6,8).join("")+"-"+r.slice(8,10).join("")+"-"+r.slice(10,16).join("")}i(yo,"newSessionId");function km(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:t["x-everfur-partner-key"]=e.publishableKey,e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}i(km,"authHeaders");function nr(e,t){return {...e,headers:{...xm(e.headers),...km(t)}}}i(nr,"withAuthHeaders");function xm(e){if(!e)return {};let t={};for(let[r,n]of Object.entries(e)){let o=r.toLowerCase();o==="authorization"||o==="x-everfur-partner-key"||(t[r]=n);}return t}i(xm,"stripAuthHeaders");async function Js(e,t){if(t.mode==="anonymous")return t.transport.request(nr(e,{mode:"anonymous",publishableKey:t.publishableKey,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));let r;try{r=await t.identity.currentToken();}catch{return v(mo())}let n=await t.transport.request(nr(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let o;try{o=await t.identity.currentToken({forceRefresh:!0});}catch{return v(mo())}let s=await t.transport.request(nr(e,{mode:"personalized",token:o,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !s.ok&&s.error.httpStatus===401?v(mo(s.error.httpStatus)):s}i(Js,"authedSend");function mo(e){return D("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(mo,"authRejectedError");var ea=`
2
2
 
3
- `,Pm=1048576,km=zod.z.record(zod.z.string(),zod.z.unknown()),xm=["emergency","schedule_soon","home_care"];async function*$r(e,t=null){let r=null,n=i(()=>(r!==null||(r=typeof t=="function"?t():t),r),"requestIdNow"),o=new TextDecoder("utf-8"),s="",a=0,l=false;for await(let u of e){for(s+=o.decode(u,{stream:true});;){let d=s.indexOf(qs,a);if(d===-1)break;let c=s.slice(0,d);s=s.slice(d+qs.length),a=0;let p=$s(c,n());if(p!==null&&(p.kind==="delta"&&(l=true),yield p,p.terminal))return}if(a=s.length>0?s.length-1:0,s.length>Pm){yield fe({code:l?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});return}}if(s+=o.decode(),s.trim().length>0){let u=$s(s,n());if(u!==null&&(u.kind==="delta"&&(l=true),yield u,u.terminal))return}yield fe({code:l?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});}i($r,"parseSse");function $s(e,t){let r=null,n=[];for(let a of e.split(`
3
+ `,_m=1048576,wm=zod.z.record(zod.z.string(),zod.z.unknown()),Im=["emergency","schedule_soon","home_care"];async function*Zr(e,t=null){let r=null,n=i(()=>(r!==null||(r=typeof t=="function"?t():t),r),"requestIdNow"),o=new TextDecoder("utf-8"),s="",a=0,l=false;for await(let u of e){for(s+=o.decode(u,{stream:true});;){let d=s.indexOf(ea,a);if(d===-1)break;let c=s.slice(0,d);s=s.slice(d+ea.length),a=0;let p=ta(c,n());if(p!==null&&(p.kind==="delta"&&(l=true),yield p,p.terminal))return}if(a=s.length>0?s.length-1:0,s.length>_m){yield ye({code:l?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});return}}if(s+=o.decode(),s.trim().length>0){let u=ta(s,n());if(u!==null&&(u.kind==="delta"&&(l=true),yield u,u.terminal))return}yield ye({code:l?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});}i(Zr,"parseSse");function ta(e,t){let r=null,n=[];for(let a of e.split(`
4
4
  `)){let l=a.replace(/\s+$/,"");l.length===0||l.startsWith(":")||(l.startsWith("id:")?r=l.slice(3).trim():l.startsWith("data:")&&n.push(l.slice(5).replace(/^ /,"")));}if(n.length===0)return null;let o;try{o=JSON.parse(n.join(`
5
- `));}catch{return null}if(typeof o!="object"||o===null||Array.isArray(o))return null;let s=km.safeParse(o);return s.success?_m(s.data,r,t):null}i($s,"parseBlock");function _m(e,t,r){let n=e.type,o=e.event;if(n==="error"||"error"in e)return fe({code:ce(e.code)??"unknown",retryable:e.retryable===true,wireMessage:ce(e.error),synthesized:false,lastEventId:t,serverRequestId:r});if(n==="done"||e.done===true)return Hs({conversationId:ce(e.conversation_id)??"",messageId:ce(e.message_id),title:ce(e.title),followUpQuestions:Am(e.follow_up_questions),citations:Ys(e.citations),citationStatus:ce(e.citation_status),urgencyLevel:Xs(e.urgency_level),urgencyReason:ce(e.urgency_reason),urgencyProvided:Im(e),resultId:ce(e.result_id),lastEventId:t},r);if(n==="accepted"||e.status==="reasoning")return Us(ce(e.stream_id),t,r);if(n==="heartbeat"||e.heartbeat===true)return Vs(t,r);if(n==="text.delta"||"delta"in e||"token"in e){let s=ce(e.delta)??ce(e.token)??"";return Bs(s,t,r)}return o==="analysis_started"?zs(ce(e.request_id),t,r):o==="analysis_complete"?js({resultId:ce(e.result_id),analysisType:ce(e.analysis_type),modelVersion:ce(e.model_version),confidence:wm(e.confidence),detections:Ys(e.detections),interpretation:ce(e.interpretation),lastEventId:t},r):Ws(e,t,r)}i(_m,"frameFromWire");function ce(e){return typeof e=="string"?e:null}i(ce,"asString");function wm(e){return typeof e=="number"&&Number.isFinite(e)?e:null}i(wm,"asNumber");function Xs(e){return typeof e=="string"&&xm.includes(e)?e:null}i(Xs,"asUrgency");function Im(e){if(!Object.prototype.hasOwnProperty.call(e,"urgency_level"))return false;let t=e.urgency_level;return t===null||Xs(t)!==null}i(Im,"urgencySlotProvided");function Am(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t:String(t)):[]}i(Am,"asStringList");function Om(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Om,"isPlainObject");function Ys(e){return Array.isArray(e)?e.filter(Om):[]}i(Ys,"asMapList");var Fm="0.6.0",ao="react-native",Mm="2026-09-19",Yr="EVERFUR_API_BASE_URL";function or(e,t){return Object.freeze({ok:false,failure:Object.freeze({reason:e,message:t})})}i(or,"configFailure");function lo(e){let t=typeof e=="string"?e.trim():"";return t.length===0?{reason:"missing-publishable-key",message:"publishableKey is required"}:/^sk[_-]/i.test(t)?{reason:"secret-key-as-publishable-key",message:"publishableKey looks like a SECRET key (sk_...). A device must never hold a partner secret key: use the pk_ publishable key here, and keep the secret key on your server."}:null}i(lo,"checkPublishableKey");function Qs(e,t){let r=lo(e?.publishableKey);if(r!==null)return Object.freeze({ok:false,failure:r});let n=e.publishableKey.trim(),o=Lm(e.apiBaseUrl);if(!o.ok)return o;let s=e.contractVersion?.trim()||Mm;return Object.freeze({ok:true,config:Object.freeze({publishableKey:n,apiBaseUrl:o.value,contractVersion:s,sdkVersion:Fm,platform:t?.platform??ao,debug:e.debug===true})})}i(Qs,"tryResolveClientConfig");function Lm(e){let t=e?.trim(),r=t&&t.length>0?t:jm(Yr);return r?Hm(r):or("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${Yr}. The SDK never ships a hardcoded host.`)}i(Lm,"tryResolveApiBaseUrl");function Zs(e){return {"X-Everfur-SDK-Version":e.sdkVersion,"X-Everfur-SDK-Platform":e.platform,"X-Everfur-Contract":e.contractVersion}}i(Zs,"buildBaseHeaders");var Dm=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function Nm(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}i(Nm,"hostOf");function Um(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}i(Um,"isPrintableHost");function Vm(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:Um(t)}i(Vm,"canEchoOrigin");function Bm(e,t){return `${e}://${t}`}i(Bm,"safeOrigin");function Hm(e){let t=e.trim(),r=Dm.exec(t);if(r===null||r[2]===void 0||r[2].length===0)return or("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let n=(r[1]??"").toLowerCase(),o=Nm(r[2]);if(o.length===0)return or("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let s=Vm(t,o)?`: ${Bm(n,o)}`:"";if(n!=="https"){if(!(n==="http"&&zm(o)))return n==="http"?or("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${s}`):or("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${s}`)}let a=t.endsWith("/")?t.slice(0,-1):t;return Object.freeze({ok:true,value:a})}i(Hm,"normalizeBaseUrl");function zm(e){let t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t==="::1"}i(zm,"isLoopbackHost");function jm(e){let r=globalThis.process?.env?.[e];return typeof r=="string"&&r.trim().length>0?r.trim():void 0}i(jm,"readEnv");var Wm=3e4,ra="x-request-id";async function*Js(e){if(!e)return;let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;n&&n.length>0&&(yield n);}}finally{await t.cancel?.();}}i(Js,"fetchByteSource");function Gm(e){let t=new TextEncoder,r=qm(),n=false,o=i(u=>{let d="";u.lastEventId&&(d+=`id: ${u.lastEventId}
5
+ `));}catch{return null}if(typeof o!="object"||o===null||Array.isArray(o))return null;let s=wm.safeParse(o);return s.success?Am(s.data,r,t):null}i(ta,"parseBlock");function Am(e,t,r){let n=e.type,o=e.event;if(n==="error"||"error"in e)return ye({code:pe(e.code)??"unknown",retryable:e.retryable===true,wireMessage:pe(e.error),synthesized:false,lastEventId:t,serverRequestId:r});if(n==="done"||e.done===true)return $s({conversationId:pe(e.conversation_id)??"",messageId:pe(e.message_id),title:pe(e.title),followUpQuestions:Mm(e.follow_up_questions),citations:ra(e.citations),citationStatus:pe(e.citation_status),urgencyLevel:na(e.urgency_level),urgencyReason:pe(e.urgency_reason),urgencyProvided:Fm(e),resultId:pe(e.result_id),lastEventId:t},r);if(n==="accepted"||e.status==="reasoning")return Gs(pe(e.stream_id),t,r);if(n==="heartbeat"||e.heartbeat===true)return Ks(t,r);if(n==="text.delta"||"delta"in e||"token"in e){let s=pe(e.delta)??pe(e.token)??"";return qs(s,t,r)}return o==="analysis_started"?Ys(pe(e.request_id),t,r):o==="analysis_complete"?Xs({resultId:pe(e.result_id),analysisType:pe(e.analysis_type),modelVersion:pe(e.model_version),confidence:Om(e.confidence),detections:ra(e.detections),interpretation:pe(e.interpretation),lastEventId:t},r):Qs(e,t,r)}i(Am,"frameFromWire");function pe(e){return typeof e=="string"?e:null}i(pe,"asString");function Om(e){return typeof e=="number"&&Number.isFinite(e)?e:null}i(Om,"asNumber");function na(e){return typeof e=="string"&&Im.includes(e)?e:null}i(na,"asUrgency");function Fm(e){if(!Object.prototype.hasOwnProperty.call(e,"urgency_level"))return false;let t=e.urgency_level;return t===null||na(t)!==null}i(Fm,"urgencySlotProvided");function Mm(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t:String(t)):[]}i(Mm,"asStringList");function Lm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Lm,"isPlainObject");function ra(e){return Array.isArray(e)?e.filter(Lm):[]}i(ra,"asMapList");var Nm="0.7.0",ho="react-native",Dm="2026-09-19",Jr="EVERFUR_API_BASE_URL";function or(e,t){return Object.freeze({ok:false,failure:Object.freeze({reason:e,message:t})})}i(or,"configFailure");function bo(e){let t=typeof e=="string"?e.trim():"";return t.length===0?{reason:"missing-publishable-key",message:"publishableKey is required"}:/^sk[_-]/i.test(t)?{reason:"secret-key-as-publishable-key",message:"publishableKey looks like a SECRET key (sk_...). A device must never hold a partner secret key: use the pk_ publishable key here, and keep the secret key on your server."}:null}i(bo,"checkPublishableKey");function oa(e,t){let r=bo(e?.publishableKey);if(r!==null)return Object.freeze({ok:false,failure:r});let n=e.publishableKey.trim(),o=Um(e.apiBaseUrl);if(!o.ok)return o;let s=e.contractVersion?.trim()||Dm;return Object.freeze({ok:true,config:Object.freeze({publishableKey:n,apiBaseUrl:o.value,contractVersion:s,sdkVersion:Nm,platform:t?.platform??ho,debug:e.debug===true})})}i(oa,"tryResolveClientConfig");function Um(e){let t=e?.trim(),r=t&&t.length>0?t:Km(Jr);return r?Wm(r):or("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${Jr}. The SDK never ships a hardcoded host.`)}i(Um,"tryResolveApiBaseUrl");function ia(e){return {"X-Everfur-SDK-Version":e.sdkVersion,"X-Everfur-SDK-Platform":e.platform,"X-Everfur-Contract":e.contractVersion}}i(ia,"buildBaseHeaders");var Vm=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function Bm(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}i(Bm,"hostOf");function Hm(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}i(Hm,"isPrintableHost");function zm(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:Hm(t)}i(zm,"canEchoOrigin");function jm(e,t){return `${e}://${t}`}i(jm,"safeOrigin");function Wm(e){let t=e.trim(),r=Vm.exec(t);if(r===null||r[2]===void 0||r[2].length===0)return or("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let n=(r[1]??"").toLowerCase(),o=Bm(r[2]);if(o.length===0)return or("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let s=zm(t,o)?`: ${jm(n,o)}`:"";if(n!=="https"){if(!(n==="http"&&Gm(o)))return n==="http"?or("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${s}`):or("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${s}`)}let a=t.endsWith("/")?t.slice(0,-1):t;return Object.freeze({ok:true,value:a})}i(Wm,"normalizeBaseUrl");function Gm(e){let t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t==="::1"}i(Gm,"isLoopbackHost");function Km(e){let r=globalThis.process?.env?.[e];return typeof r=="string"&&r.trim().length>0?r.trim():void 0}i(Km,"readEnv");var qm=3e4,ua="x-request-id";async function*sa(e){if(!e)return;let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;n&&n.length>0&&(yield n);}}finally{await t.cancel?.();}}i(sa,"fetchByteSource");function $m(e){let t=new TextEncoder,r=Xm(),n=false,o=i(u=>{let d="";u.lastEventId&&(d+=`id: ${u.lastEventId}
6
6
  `);let c=u.data??"";for(let p of c.split(`
7
7
  `))d+=`data: ${p}
8
8
  `;d+=`
9
- `,r.push(t.encode(d));},"onMessage"),s=i(()=>{l(),r.end();},"onDone"),a=i(u=>{let d=typeof u.xhrStatus=="number"?u.xhrStatus:0;if(d>=400){let c=ia(d),p=We(Me(c));r.push(t.encode(`data: ${JSON.stringify({type:"error",code:c,retryable:p})}
9
+ `,r.push(t.encode(d));},"onMessage"),s=i(()=>{l(),r.end();},"onDone"),a=i(u=>{let d=typeof u.xhrStatus=="number"?u.xhrStatus:0;if(d>=400){let c=pa(d),p=Ge(Fe(c));r.push(t.encode(`data: ${JSON.stringify({type:"error",code:c,retryable:p})}
10
10
 
11
- `));}l(),r.end();},"onError");e.addEventListener("message",o),e.addEventListener("done",s),e.addEventListener("error",a);function l(){if(!n){n=true,e.removeEventListener("message",o),e.removeEventListener("done",s),e.removeEventListener("error",a);try{e.close();}catch{}}}return i(l,"cleanup"),Km(r.source,l)}i(Gm,"eventSourceByteSource");async function*Km(e,t){try{yield*e;}finally{t();}}i(Km,"sourceWithCleanup");function qm(){let e=[],t=false,r=null,n=i(()=>{if(r){let s=r;r=null,s();}},"signal");async function*o(){for(;;){let s=e.shift();if(s!==void 0){yield s;continue}if(t)return;await new Promise(a=>{r=a;});}}return i(o,"gen"),{source:o(),push:i(s=>{e.push(s),n();},"push"),end:i(()=>{t=true,n();},"end")}}i(qm,"createByteQueue");async function $m(e,t){let r=t.fetchImpl??sa(),n=aa(t.config.apiBaseUrl,e.path,e.query),o=la(t.config,e.headers,"application/json",e.body!==void 0&&e.multipart===void 0),s=ey(Wm),a=ty(s.signal,e.signal),l;try{l=await r(n,ua({...e,signal:a},o));}catch(d){return E(uo(d))}finally{s.cancel();}let u=await da(l);return l.ok?L(u):E(Qm(l.status,u,oa(l)))}i($m,"requestJson");function na(e){return {request:i(t=>$m(t,e),"request"),stream:i((t,r)=>Ym(Jm(t,r),e),"stream")}}i(na,"createHttpTransport");async function*Ym(e,t){let r=aa(t.config.apiBaseUrl,e.path,e.query),n=la(t.config,e.headers,"text/event-stream",e.body!==void 0&&e.multipart===void 0);if(t.eventSourceFactory){let l=t.eventSourceFactory(r,Xm(e,n));yield*$r(Gm(l),()=>Zm(l));return}let o=t.fetchImpl??sa(),s;try{s=await o(r,ua(e,n));}catch(l){yield ea("",true,ma(l));return}let a=oa(s);if(!s.ok){let l=await da(s),u=ca(l)??ia(s.status),d=fa(l)||We(Me(u));yield ea(u,d,pa(l),a);return}if(s.body){yield*$r(Js(s.body),a);return}yield*$r(Js(null),a);}i(Ym,"streamFrames");function Xm(e,t){return {method:e.method,headers:t,pollingInterval:0,...e.body!==void 0?{body:JSON.stringify(e.body)}:{}}}i(Xm,"buildEventSourceInit");function Qm(e,t,r){let n=ca(t),o=n?Me(n):Fs(e),s=pa(t);return D(o,{httpStatus:e,...fa(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...ta(t)?{reasonCode:ta(t)}:{},...s?{wireMessage:s}:{},...t!=null?{raw:t}:{}})}i(Qm,"errorFromResponse");function uo(e){return D("internalError",{retryable:true,wireMessage:ma(e)})}i(uo,"networkError");function oa(e){let t=e.headers.get(ra);return typeof t=="string"&&t.length>0?t:null}i(oa,"requestIdOf");function Zm(e){if(typeof e.getResponseHeader!="function")return null;let t;try{t=e.getResponseHeader(ra);}catch{return null}return typeof t=="string"&&t.length>0?t:null}i(Zm,"eventSourceRequestId");function ia(e){return e===401?"AUTH_EXPIRED":e===403?"ACCESS_DENIED":e===404?"NOT_FOUND":e===409?"IDEMPOTENCY_CONFLICT":e===421?"MISDIRECTED_REQUEST":e===429?"RATE_LIMITED":e===400||e===422?"INVALID_REQUEST":e===503||e>=500?"INTERNAL_ERROR":""}i(ia,"statusToWireCode");function ea(e,t,r,n=null){return fe({code:e,retryable:t,wireMessage:r,synthesized:true,lastEventId:null,serverRequestId:n})}i(ea,"syntheticErrorFrame");function sa(){let e=globalThis.fetch;if(typeof e!="function")throw new ee("missing-peer-dependency","global fetch is unavailable; provide config.transport or an injected fetch implementation");return e}i(sa,"getGlobalFetch");function aa(e,t,r){let n=t.startsWith("/")?t:`/${t}`,o=`${e}${n}`;if(r){let s=Object.entries(r).filter(a=>a[1]!==void 0).map(([a,l])=>`${encodeURIComponent(a)}=${encodeURIComponent(String(l))}`).join("&");s&&(o+=`?${s}`);}return o}i(aa,"buildUrl");function la(e,t,r,n){let o={...Zs(e),accept:r};return n&&(o["content-type"]="application/json"),t&&Object.assign(o,t),o}i(la,"mergeHeaders");function ua(e,t){let r={method:e.method,headers:t};return e.multipart!==void 0?r.body=e.multipart:e.body!==void 0&&(r.body=JSON.stringify(e.body)),e.signal&&(r.signal=e.signal),r}i(ua,"buildInit");function Jm(e,t){return e.signal?e:{...e,signal:t}}i(Jm,"withSignal");function ey(e){let t=new AbortController,r=setTimeout(()=>t.abort(),e);return {signal:t.signal,cancel:i(()=>clearTimeout(r),"cancel")}}i(ey,"timeoutSignal");function ty(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(ty,"mergeAbortSignals");async function da(e){try{return await e.json()}catch{return null}}i(da,"safeJson");function ta(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}i(ta,"extractReasonCode");function ca(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?r:null}i(ca,"extractWireCode");function pa(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}i(pa,"extractWireMessage");function fa(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}i(fa,"extractRetryable");function ma(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(ma,"describeCause");var ry=3e4,ny=ro*2,oy="idempotency-key",iy=new Set(["POST","PUT","PATCH","DELETE"]),sy=Object.freeze({onEvent(){}}),ay=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function ly(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}i(ly,"seededIdempotencyKey");function Ae(e){let t=e.observer??sy,r=e.timers??ay,n=e.rng??Math.random,o=e.sleep??((f,m)=>Ry(f,r,m)),s=e.maxAttempts??rr,a=e.unaryTimeoutMs??ry,l=e.newIdempotencyKey??dy(),u=i(f=>{try{t.onEvent(f);}catch{}},"emit");async function d(f,m,y){let R=y?.maxAttempts,h=Math.max(1,R??s),C=y?.idempotent??iy.has(m.method),_=y?.idempotencyKey===void 0?null:ly(y.idempotencyKey),P=C?_??l():null,x=uy(m,P),g=0;for(;;){let w=i(W=>Object.freeze({call:f,method:m.method,path:m.path,attempt:g,...P?{idempotencyKey:P}:{},...W}),"stamp");u(w({phase:"attempt"}));let O=Ey(a,r),M=Cy(O.signal,m.signal),I;try{I=await Ks({...x,signal:M.signal},e.auth);}catch(W){I=E(uo(W));}finally{M.dispose(),O.cancel();}if(I.ok)return u(w({phase:"settled",ok:true,reason:"ok"})),I;let v=I.error,k=py(v,g,{maxAttempts:h,rng:n,now:r.now(),aborted:m.signal?.aborted===true,...R!==void 0?{perCallMaxAttempts:R}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),V={ok:false,code:v.code,reason:k.reason,...v.httpStatus!==void 0?{httpStatus:v.httpStatus}:{},...v.requestId!==void 0?{requestId:v.requestId}:{}};if(!k.retry)return u(w({phase:"settled",...V})),E(v);if(u(w({phase:"retry",...V,delayMs:k.delayMs})),await o(k.delayMs,m.signal),m.signal?.aborted===true)return u(w({phase:"settled",...V,reason:"aborted"})),E(v);g+=1;}}i(d,"send");async function c(f){return nr(f,await vy(e.auth))}i(c,"authorize");async function*p(f,m,y){u(Object.freeze({call:f,phase:"stream.open",method:m.method,path:m.path,attempt:0}));try{yield*e.auth.transport.stream(m,y);}catch{yield fe({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(p,"stream"),Object.freeze({send:d,authorize:c,stream:p})}i(Ae,"createRequestFunnel");function uy(e,t){let r={};for(let[n,o]of Object.entries(e.headers??{}))n.toLowerCase()!==oy&&(r[n]=o);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(uy,"assembleHeaders");function dy(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(dy,"defaultIdempotencyKeyFactory");var cy=10;function py(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let n=fy(e);if(n==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!We(e.code))return {retry:false,reason:"terminal-code"};let o=n==="burst"?"burst-throttle":"retryable-code";if(i(()=>{if(r.policy===void 0)return false;try{return !r.policy.shouldRetry(e.code,t)}catch{return false}},"policyVetoedRetry")())return {retry:false,reason:"terminal-code"};let a=i(()=>{if(r.policy===void 0)return null;let d;try{d=r.policy.maxAttempts(e.code);}catch{return null}return typeof d!="number"||!Number.isFinite(d)?null:Math.max(1,Math.min(cy,Math.floor(d)))},"policyCeiling"),l=r.perCallMaxAttempts??a()??r.maxAttempts;if(t+1>=l)return {retry:false,reason:"attempts-exhausted"};let u=my(e,r.now);return u!==null?u>ny?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:o,delayMs:u}:{retry:true,reason:o,delayMs:Gr(t,r.rng)}}i(py,"decideRetry");function fy(e){let t=e.code==="unknown"?Me(by(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(fy,"throttleKind");function my(e,t){let r=gy(e.raw);if(r!==null){let o=r-t;return o>0?o:0}let n=yy(e.raw);return n===null?null:Math.round(n*1e3)}i(my,"retryOverrideMs");function yy(e){for(let t of co(e)){let r=t.retry_after_seconds;if(typeof r=="number"&&Number.isFinite(r)&&r>=0)return r}return null}i(yy,"findRetryAfterSeconds");function gy(e){for(let t of co(e)){let r=t.resets_at,n=hy(r);if(n!==null)return n}return null}i(gy,"findResetsAt");function co(e){if(!ya(e))return [];let t=[e];for(let r of ["error","detail"]){let n=e[r];ya(n)&&t.push(n);}return t}i(co,"candidateScopes");function hy(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e11?Math.round(e*1e3):Math.round(e);if(typeof e=="string"&&e.trim().length>0){let t=Date.parse(e);return Number.isFinite(t)?t:null}return null}i(hy,"parseInstantMs");function by(e){for(let t of co(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i(by,"rawWireCode");function ya(e){return typeof e=="object"&&e!==null}i(ya,"isRecord");async function vy(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(vy,"resolveDeviceAuth");function Ey(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(n),"cancel")}}i(Ey,"boundedSignal");function Cy(e,t){let r=i(()=>{},"noop");if(!t)return {signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let o=i(()=>n.abort(),"onAbort");return e.addEventListener("abort",o,{once:true}),t.addEventListener("abort",o,{once:true}),{signal:n.signal,dispose:i(()=>{e.removeEventListener("abort",o),t.removeEventListener("abort",o);},"dispose")}}i(Cy,"mergeSignals");function Ry(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let o=t.setTimeout(()=>{r?.removeEventListener("abort",s),n();},e),s=i(()=>{t.clearTimeout(o),n();},"onAbort");r?.addEventListener("abort",s,{once:true});})}i(Ry,"delayAbortable");var Xr=Object.freeze(["better","same","worse"]),fo=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ga(e){return E(D("validationFailed",{retryable:false,wireMessage:e}))}i(ga,"invalid");function po(){return E(D("internalError",{retryable:false}))}i(po,"malformed");function ha(e){return typeof e!="string"||e.trim().length===0?D("validationFailed",{retryable:false,wireMessage:"pet_ref must not be blank"}):ve(e)?D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}):`/widget/v1/pets/${encodeURIComponent(e)}/cases`}i(ha,"petPath");var Ge=i(e=>typeof e=="string"?e:null,"str"),ba=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"count");function va(e){if(typeof e!="object"||e===null)return null;let t=e,r=Ge(t.case_id),n=Ge(t.status);if(r===null||n===null)return null;let o=Ge(t.last_response);return Object.freeze({caseId:r,status:n,bodyLocation:Ge(t.body_location),lastResponse:o!==null&&Xr.includes(o)?o:null,checkInDueAt:Ge(t.check_in_due_at),openedAt:Ge(t.opened_at),resolvedAt:Ge(t.resolved_at),resolutionText:Ge(t.resolution_text),checkinAskCount:ba(t.checkin_ask_count),checkinAnswerCount:ba(t.checkin_answer_count)})}i(va,"caseFromWire");function Ea(e){return {async list(t,r){let n=ha(t);if(typeof n!="string")return E(n);let o=await e.send("cases.list",{method:"GET",path:n,...r?.signal?{signal:r.signal}:{}});if(!o.ok)return E(o.error);let s=typeof o.value=="object"&&o.value!==null?o.value.cases:null;if(!Array.isArray(s))return po();let a=s.map(va);return a.every(l=>l!==null)?L(Object.freeze(a)):po()},async checkin(t,r,n,o){let s=ha(t);if(typeof s!="string")return E(s);if(typeof r!="string"||!fo.test(r))return ga("case_id must be a UUID");if(!Xr.includes(n))return ga("response must be one of better, same, worse");let a=await e.send("cases.checkin",{method:"POST",path:`${s}/${r}/checkin`,body:{response:n},...o?.signal?{signal:o.signal}:{}});if(!a.ok)return E(a.error);let l=typeof a.value=="object"&&a.value!==null?a.value:{},u=va(l.case);return u===null?po():L(Object.freeze({case:u,ctaDeepLink:Ge(l.cta_deep_link)}))}}}i(Ea,"createCasesRepositoryOver");var Ca=Object.freeze({async presignedPut(){return Promise.reject(new Error("UploadPort is unavailable; no presigned-upload adapter was injected"))}});var Ra=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function Zr(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let o={handle:void 0},s=i(()=>{r.clearTimeout(o.handle),t.removeEventListener("abort",s),n();},"done");o.handle=r.setTimeout(s,e),t.addEventListener("abort",s,{once:true});})}i(Zr,"delayAbortable");function Jr(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(Jr,"mergeSignals");var mo=class mo{constructor(t){this.listeners=new Set;this.epoch=0;this.inFlight=null;this.snapshot=Object.freeze({...t});}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t);}}getSnapshot(){return this.snapshot}patch(t){this.snapshot=Object.freeze({...this.snapshot,...t});for(let r of this.listeners)r();}beginOperation(t){this.inFlight?.abort();let r=new AbortController;this.inFlight=r;let n=this.epoch;return {signal:t?Jr(r.signal,t):r.signal,epoch:n,settle:i(()=>{this.inFlight===r&&(this.inFlight=null);},"settle")}}alive(t){return t===this.epoch}rescope(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null;}dispose(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null,this.listeners.clear();}};i(mo,"MediaStore");var Qr=mo;function go(e,t,r){return Object.freeze({id:e,role:"user",text:t,createdAt:r,pending:true})}i(go,"makeUser");function ho(e,t,r){return Object.freeze({id:e,role:"assistant",text:t,createdAt:r})}i(ho,"makeAssistant");function sr(e){return Object.freeze({id:e.id,role:e.role,text:e.text,createdAt:e.createdAt})}i(sr,"stripPending");function Sa(e,t){let r={id:e.id,role:e.role,text:e.text+t,createdAt:e.createdAt};return e.citations&&(r.citations=e.citations),e.responseId&&(r.responseId=e.responseId),Object.freeze(r)}i(Sa,"appendText");function bo(e,t){let r={id:t.messageId?t.messageId:e.id,role:"assistant",text:e.text,createdAt:e.createdAt};return t.citations.length>0&&(r.citations=t.citations),t.messageId&&(r.responseId=t.messageId),r.urgencyLevel=t.urgencyLevel,r.urgencyReason=t.urgencyReason,r.urgencyProvided=t.urgencyProvided,Object.freeze(r)}i(bo,"finalizeAssistant");function Ta(e){return Object.freeze({status:e.status,messages:Object.freeze([...e.messages]),conversationId:e.conversationId,error:e.error,isStreaming:e.isStreaming,isBootstrapping:e.isBootstrapping,suggestedPrompts:Object.freeze([...e.suggestedPrompts]),unreadCount:e.unreadCount})}i(Ta,"freezeSnapshot");function U(e,t,r){return D(e,{retryable:t,...r?{wireMessage:r}:{}})}i(U,"makeError");function vo(e){let t=Me(e.code);return D(t,{retryable:e.retryable||Wr(t),wireCode:e.code,wireEnvelope:"sse_frame",...e.serverRequestId?{requestId:e.serverRequestId}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},raw:e})}i(vo,"errorFromFrame");function Le(e){return fe({code:Sy(e.code),retryable:e.retryable,wireMessage:e.wireMessage??null,synthesized:true,lastEventId:null,serverRequestId:e.requestId??null})}i(Le,"synthErrorFrame");function Sy(e){switch(e){case "authExpired":return "AUTH_EXPIRED";case "authRejected":return "AuthorizationException";case "sessionRequired":return "session_required";case "accessDenied":return "ACCESS_DENIED";case "paymentRequired":return "TIER_UPGRADE_REQUIRED";case "quotaExceeded":return "QUOTA_EXCEEDED";case "rateLimited":return "RATE_LIMITED";case "validationFailed":return "ValidationException";case "sdkUpdateRequired":return "invalidRequest";case "conflict":return "ConflictException";case "idempotencyConflict":return "IDEMPOTENCY_CONFLICT";case "idempotencyInFlight":return "IDEMPOTENCY_KEY_IN_FLIGHT";case "conversationNotFound":return "CONVERSATION_NOT_FOUND";case "petNotFound":return "PET_NOT_FOUND";case "resourceNotFound":return "ResourceNotFoundException";case "streamTimeout":return "STREAM_TIMEOUT";case "mediaUploadFailed":return "MEDIA_UPLOAD_FAILED";case "moderationBlocked":return "MODERATION_BLOCKED";case "upstreamLlmTimeout":return "UPSTREAM_LLM_TIMEOUT";case "internalError":return "INTERNAL_ERROR";case "notImplemented":return "NotImplementedException";case "serviceUnavailable":return "ServiceUnavailableException";case "streamIncomplete":return "STREAM_INCOMPLETE";case "unknown":return "UNKNOWN";default:return nt(e)}}i(Sy,"canonicalWireCode");function Pa(e){let t=Array.isArray(e)?e:yo(e)&&Array.isArray(e.categories)?e.categories:[],r=[];for(let n of t){if(!yo(n))continue;let o=ir(n.category)??ir(n.title)??"",s=Ty(n.prompts??n.questions);o.length===0&&s.length===0||r.push(Object.freeze({category:o,prompts:Object.freeze(s)}));}return Object.freeze(r)}i(Pa,"parsePromptCategories");function Eo(e){let t=new Set,r=[];for(let n of e)for(let o of n.prompts){let s=o.trim();s.length===0||t.has(s)||(t.add(s),r.push(s));}return r}i(Eo,"flattenPrompts");function yo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(yo,"isPlainObject");function ir(e){return typeof e=="string"?e:null}i(ir,"asStr");function Ty(e){if(!Array.isArray(e))return [];let t=[];for(let r of e)if(typeof r=="string")t.push(r);else if(yo(r)){let n=ir(r.text)??ir(r.prompt)??ir(r.title);n!==null&&t.push(n);}return t}i(Ty,"asPromptTextList");function ka(){let e=0;return ()=>`m-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,8)}`}i(ka,"defaultIdFactory");function xa(){let e=0;return ()=>`chat-send-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(xa,"defaultIdempotencyFactory");var wa={setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")};async function*Ia(e,t,r,n){let o=e[Symbol.asyncIterator](),s=_a(t.overallMs,n),a=_a(t.idleMs,n),l=xy(r);try{for(;;){if(r.aborted)return;let u=o.next().then(p=>({tag:"next",value:p}),()=>({tag:"streamError"})),d=await Promise.race([u,a.promise.then(()=>({tag:"idle"})),s.promise.then(()=>({tag:"overall"})),l.then(()=>({tag:"abort"}))]);if(d.tag==="abort")return;if(d.tag==="streamError"){if(r.aborted)return;yield ky();return}if(d.tag==="idle"||d.tag==="overall"){yield Py();return}let c=d.value;if(c.done||(a.reset(t.idleMs),yield c.value,c.value.terminal))return}}finally{a.cancel(),s.cancel(),Promise.resolve(o.return?.(void 0)).catch(()=>{});}}i(Ia,"withWatchdog");function Py(){return fe({code:"STREAM_TIMEOUT",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(Py,"synthTimeoutFrame");function ky(){return fe({code:"STREAM_INCOMPLETE",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(ky,"synthStreamErrorFrame");function _a(e,t){let r=i(()=>{},"resolveFn"),n=new Promise(s=>{r=s;}),o=t.setTimeout(()=>r(),e);return {promise:n,reset(s){t.clearTimeout(o),o=t.setTimeout(()=>r(),s);},cancel(){t.clearTimeout(o);}}}i(_a,"deadline");function xy(e){return new Promise(t=>{if(e.aborted){t();return}e.addEventListener("abort",()=>t(),{once:true});})}i(xy,"abortPromise");var _y="checkin",wy=/^\d{4}-\d{2}-\d{2}$/,en="watching";function Aa(e){return e.status!=null&&e.status!==en}i(Aa,"isCheckinSettled");function Oa(e){let{askCount:t,answerCount:r}=e;return typeof t!="number"||!Number.isFinite(t)||typeof r!="number"||!Number.isFinite(r)||t<=0?true:r>=t}i(Oa,"isLiveAskAnswered");function Co(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,o]=t;return r!==_y||n===void 0||o===void 0||!fo.test(n)||!wy.test(o)?null:{caseId:n,dueDay:o}}i(Co,"parseCheckinOrigin");function Fa(e){return Co(e)?.caseId??null}i(Fa,"parseCheckinOriginRef");function So(e,t){if(e?.limit!==void 0&&(!Number.isInteger(e.limit)||e.limit<1||e.limit>t))return E(D("validationFailed"));let r=[];for(let[n,o]of [["cursor",e?.cursor],["pet_ref",e?.petRef]])if(o!==void 0){if(typeof o!="string"||o.length===0||ve(o))return E(D("validationFailed"));r.push(`${n}=${encodeURIComponent(o)}`);}return e?.limit!==void 0&&r.push(`limit=${e.limit}`),L(r.length?`?${r.join("&")}`:"")}i(So,"historyQuery");function lr(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}i(lr,"validConversationId");function Lt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}i(Lt,"object");function Ma(e){return e==null||typeof e=="string"&&e.length>0&&!ve(e)}i(Ma,"cursor");function ar(){return E(D("internalError",{retryable:false}))}i(ar,"malformed");function La(e){let t=Lt(e);if(!t||!Array.isArray(t.conversations)||!Ma(t.next_cursor))return ar();let r=[];for(let n of t.conversations){let o=Lt(n);if(!o||typeof o.conversation_id!="string"||!lr(o.conversation_id)||!(o.title==null||typeof o.title=="string")||typeof o.created_at!="string"||typeof o.updated_at!="string")return ar();let s=o.unread_message_count;if(!(s==null||Number.isInteger(s)&&s>=0))return ar();r.push(Object.freeze({id:o.conversation_id,title:o.title??null,createdAt:o.created_at,updatedAt:o.updated_at,unreadCount:s??null}));}return L(Object.freeze({conversations:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(La,"mapConversationPage");function Da(e){let t=Lt(e);if(!t||!Array.isArray(t.messages)||!Ma(t.next_cursor))return ar();let r=[],n=new Set;for(let o of t.messages){let s=Lt(o);if(!s||typeof s.message_id!="string"||!lr(s.message_id)||typeof s.role!="string"||typeof s.content!="string"||typeof s.created_at!="string")return ar();if(s.role!=="user"&&s.role!=="assistant"&&s.role!=="vet"||n.has(s.message_id))continue;if(n.add(s.message_id),s.role==="vet"){r.push(Iy(s,s.message_id,s.content,s.created_at));continue}let a=typeof s.proactive_origin_ref=="string"?s.proactive_origin_ref:null,l=s.role==="assistant"?Fa(a):null;r.push(Object.freeze({id:s.message_id,role:s.role,text:s.content,createdAt:s.created_at,...s.role==="assistant"?{responseId:s.message_id}:{},...s.urgency_level!==void 0?{urgencyLevel:Ay(s.urgency_level)}:{},...Array.isArray(s.citations)?{citations:Oy(s.citations)}:{},...a!==null?{proactiveOriginRef:a}:{},...l!==null?{checkin:Object.freeze({caseId:l,answer:null,resolutionText:null,status:null})}:{}}));}return L(Object.freeze({messages:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(Da,"mapMessagePage");function Iy(e,t,r,n){let o=Lt(e.sender),s=Ro(o?.display_name)??Ro(e.sender_display_name),a=Ro(o?.specialty);return Object.freeze({id:t,role:"vet",text:r,createdAt:n,sender:Object.freeze({displayName:s,specialty:a})})}i(Iy,"vetMessage");function Ro(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&!ve(t)?t:null}i(Ro,"trimmedText");function Ay(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(Ay,"normalizeUrgency");function Oy(e){let t=["source_name","source_abbrev","section","authority_tier","doi","url","title","year","study_type","journal","excerpt","monograph_chunk_id"];return Object.freeze(e.flatMap(r=>{let n=Lt(r);if(!n||typeof n.source_name!="string"||typeof n.authority_tier!="string")return [];let o={};for(let s of t){let a=n[s];(typeof a=="string"||a===null)&&(o[s]=a);}return [Object.freeze(o)]}))}i(Oy,"historyCitations");var To=Object.freeze(["helpful","neutral","not_helpful","wrong","outdated","dangerous","unclear"]),Dt=4e3;var Nt=4e3;function Na(e){return e===void 0?null:!Array.isArray(e)||e.length>5?{reason:"too_many_images",error:U("validationFailed",false,`image_s3_keys accepts at most ${5} keys`)}:e.some(t=>typeof t!="string"||t.trim().length===0)?{reason:"bad_image_key",error:U("validationFailed",false,"image_s3_keys must be non-empty strings")}:null}i(Na,"validateImageKeys");function ko(e){let t=typeof e=="string"?e:"";if(t.trim().length===0)return {reason:"empty",error:U("validationFailed",false,"message is empty or whitespace-only")};let r=[...t].length;return r>Nt?{reason:"too_long",error:U("validationFailed",false,`message is ${r} characters; the server accepts at most ${Nt}`)}:null}i(ko,"validateMessageText");function Ua(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(Ua,"urgencyTier");async function*ur(e){yield e;}i(ur,"singleFrameStream");async function*Va(){}i(Va,"emptyStream");var Fy=6e4,My=18e4,Ly=24,Dy=512,Ny=false;function Ba(e){return new xo(e)}i(Ba,"createChatController");var _o=class _o extends Qr{constructor(r){super(Ta({status:"idle",messages:[],conversationId:r.initialConversationId??null,error:null,isStreaming:false,isBootstrapping:false,suggestedPrompts:[],unreadCount:null}));this.handlerTeardowns=new Set;this.lastTurn=null;this.unadoptedCreate=null;this.lastResponseIdValue=null;this.historyGeneration=0;this.disposed=false;this.bootstrapPrompts=[];this.scopePrompts=[];this.replyPrompts=null;this.unreadByConversation=new Map;this.classifiedMessageIds=new Set;this.pendingDelta="";this.flushHandle=null;this.auth=r.auth,this.funnel=r.funnel??Ae({auth:r.auth,...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),this.petRef=r.petRef??null,this.cases=Ea(this.funnel),this.telemetry=r.telemetry??qr,this.errorPolicy=r.errorPolicy??Ds,this.timers=r.timers??wa,this.rng=r.rng??Math.random,this.newId=r.newId??ka(),this.makeIdempotencyKey=r.makeIdempotencyKey??xa(),this.budget={idleMs:r.budget?.idleMs??Fy,overallMs:r.budget?.overallMs??My};}patch(r){if(r.messages!==void 0){let n=Object.freeze([...r.messages]);super.patch({...r,messages:n});return}super.patch(r);}send(r,n,o){let s=n??{};if(this.disposed||this.snapshot.isBootstrapping){let u=U(this.disposed?"accessDenied":"internalError",!this.disposed);return o?(o.onError(u),()=>{}):ur(Le(u))}let a=ko(r)??Na(s.imageS3Keys);if(a!==null)return this.telemetry.track("chat.send.rejected",{reason:a.reason}),this.patch({status:"error",isStreaming:false,error:a.error}),o?(o.onError(a.error),()=>{}):ur(Le(a.error));if(o)return this.driveWithHandlers(r,s,o);let l=this.beginTurn(r,s);return this.runTurn(l,s.signal)}askEverfur(r,n){if(this.disposed)return ur(Le(U("accessDenied",false)));let o=ko(r);return o!==null?(this.telemetry.track("chat.send.rejected",{reason:o.reason}),ur(Le(o.error))):(this.resetThread(),this.send(r,n??{}))}retryLast(){let r=this.lastTurn;if(r===null){let s=this.snapshot.conversationId;return s!==null&&this.snapshot.status==="error"?this.retryHistory(s):Va()}r.assistantMessageId=null,r.sawDelta=false,r.conversationIdOverride=null,this.discardPendingDelta();let o=this.snapshot.messages.some(s=>s.id===r.userMessageId)?this.snapshot.messages:[...this.snapshot.messages,go(r.userMessageId,r.text,this.stamp())];return this.patch({error:null,stopped:false,messages:o}),this.runTurn(r,void 0)}stop(){this.inFlight?.abort(),this.inFlight=null,this.discardPendingDelta(),this.telemetry.track("chat.cancel",{});let r=this.snapshot.messages.some(o=>o.role==="user"&&o.pending===true),n=r?this.snapshot.messages.map(o=>o.pending===true?sr(o):o):this.snapshot.messages;(this.snapshot.status==="streaming"||r)&&this.patch({status:"idle",isStreaming:false,reconnecting:false,...r?{messages:n,stopped:true}:{}});}rescope(){this.resetThread(),this.scopePrompts=[],this.unreadByConversation.clear(),this.classifiedMessageIds.clear(),this.reflectUnreadDot();}resetThread(r=[]){super.rescope(),this.historyGeneration+=1,this.unadoptedCreate=null,this.lastTurn=null,this.lastResponseIdValue=null,this.bootstrapPrompts=r,this.replyPrompts=null,this.discardPendingDelta(),this.patch({status:"idle",isStreaming:false,messages:[],conversationId:null,error:null,suggestedPrompts:r,historyCursor:null,isLoadingHistory:false,isBootstrapping:false,unreadCount:null,stopped:false,reconnecting:false});}newConversation(){this.disposed||this.resetThread(this.scopePrompts);}dispose(){this.rescope(),this.disposed=true,this.unadoptedCreate=null,this.discardPendingDelta();for(let r of this.handlerTeardowns)r();this.handlerTeardowns.clear(),super.dispose();}adoptConversation(r){this.disposed||(this.unadoptedCreate=null,this.snapshot.conversationId!==r&&this.patch({conversationId:r}));}adoptPrompts(r){if(this.disposed)return;let n=Object.freeze(Eo(r));this.bootstrapPrompts=n,this.scopePrompts=n,this.replyPrompts===null&&(n.length===0&&this.snapshot.suggestedPrompts.length===0||this.patch({suggestedPrompts:n}));}async listConversations(r){return this.listConversationsWith(r)}async listConversationsWith(r,n){let o=So(r,100);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return E(U("accessDenied",false));let a=await this.authedUnary("chat.listConversations",{method:"GET",path:`/widget/v1/conversations${o.value}`},r?.signal,n);if(!this.alive(s)||this.disposed)return E(U("accessDenied",false));if(!a.ok)return a;let l=La(a.value);if(l.ok){for(let c of l.value.conversations)c.unreadCount!==null&&this.unreadByConversation.set(c.id,c.unreadCount);let u=this.snapshot.conversationId,d=u===null?void 0:this.unreadByConversation.get(u);d!==void 0&&d!==this.snapshot.unreadCount&&this.patch({unreadCount:d}),this.reflectUnreadDot();}return l}reflectUnreadDot(){let r=false;for(let n of this.unreadByConversation.values())if(n>0){r=true;break}r!==(this.snapshot.hasUnreadThreads??false)&&this.patch({hasUnreadThreads:r});}async openCheckin(r){if(this.disposed)return E(U("accessDenied",false));let n=r?.conversationId??null;if(n!==null){let u=await this.resumeConversation(n);return u.ok?L(n):E(u.error)}let o=r?.petRef??this.petRef,s=await this.listConversations({...o===null?{}:{petRef:o},limit:1});if(!s.ok)return E(s.error);let a=s.value.conversations[0];if(a===void 0)return L(null);let l=await this.resumeConversation(a.id);return l.ok?L(a.id):E(l.error)}async markRead(r){if(this.disposed)return E(U("accessDenied",false));let n=this.snapshot.conversationId;if(n===null)return L(void 0);let o=this.epoch,s=await this.authedUnary("chat.markRead",{method:"POST",path:`/widget/v1/conversations/${n}/read`},r?.signal);return !this.alive(o)||this.disposed?E(U("accessDenied",false)):s.ok?(this.unreadByConversation.set(n,0),this.snapshot.conversationId===n&&this.snapshot.unreadCount!==0&&this.patch({unreadCount:0}),this.reflectUnreadDot(),L(void 0)):E(s.error)}async submitFeedback(r,n,o,s){if(this.disposed)return E(U("accessDenied",false));if(typeof r!="string"||r.trim().length===0||ve(r))return E(U("validationFailed",false,"feedback needs the server message id of an assistant reply"));if(!To.includes(n))return E(U("validationFailed",false,`feedback_type must be one of ${To.join(", ")}`));let a=typeof o=="string"?o.trim():"";if([...a].length>Dt)return E(U("validationFailed",false,`notes is over ${Dt} characters`));let l={feedback_type:n};a.length>0&&(l.notes=a);let u=this.epoch,d=await this.authedUnary("chat.submitFeedback",{method:"POST",path:`/widget/v1/messages/${encodeURIComponent(r)}/feedback`,body:l},s?.signal);if(!this.alive(u)||this.disposed)return E(U("accessDenied",false));if(!d.ok)return E(d.error);let c=d.value?.feedback_id;return L(Object.freeze({feedbackId:typeof c=="string"?c:""}))}async answerCheckin(r,n,o){if(this.disposed)return E(U("accessDenied",false));let s=o?.petRef??this.petRef;if(s===null)return E(U("validationFailed",false,"a check-in needs the pet the case belongs to"));let a=this.epoch,l=await this.cases.checkin(s,r,n,o?.signal?{signal:o.signal}:{});if(!this.alive(a)||this.disposed)return E(U("accessDenied",false));if(!l.ok)return l;let u=l.value.case.openedAt,d=Object.freeze({caseId:r,answer:n,resolutionText:l.value.case.resolutionText,status:l.value.case.status??null,...u!==null?{openedAt:u}:{}}),c=i(p=>p.checkin?.caseId===r,"carries");return this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,checkin:d}):p)}),l}async getMessages(r,n){if(!lr(r))return E(U("validationFailed",false));let o=So(n,200);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return E(U("accessDenied",false));let a=await this.authedUnary("chat.getMessages",{method:"GET",path:`/widget/v1/conversations/${r}/messages${o.value}`},n?.signal);return !this.alive(s)||this.disposed?E(U("accessDenied",false)):a.ok?Da(a.value):a}async resumeConversation(r){if(this.disposed)return E(U("accessDenied",false));if(!lr(r))return E(U("validationFailed",false));this.resetThread();let n=this.historyGeneration;this.patch({conversationId:r,isBootstrapping:true,isLoadingHistory:true});let o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return E(U("accessDenied",false));if(!o.ok)return this.patch({status:"error",error:o.error,isBootstrapping:false,isLoadingHistory:false}),o;let s=this.unreadByConversation.get(r)??null;return this.patch({messages:o.value.messages,historyCursor:o.value.nextCursor,isBootstrapping:false,isLoadingHistory:false,unreadCount:s}),this.stampCheckinStatuses(n),s!==null&&s>0&&this.markRead(),L(void 0)}async stampCheckinStatuses(r){let n=this.petRef;if(n===null||!this.snapshot.messages.some(d=>d.checkin!==void 0&&d.checkin.status===null))return;let o=await this.cases.list(n);if(!o.ok||r!==this.historyGeneration||this.disposed)return;let s=new Set(o.value.filter(d=>d.status===en).map(d=>d.caseId)),a=new Map(o.value.map(d=>[d.caseId,d])),l=false,u=this.snapshot.messages.map(d=>{let c=d.checkin;if(c===void 0||c.status!==null)return d;l=true;let p=a.get(c.caseId),f=c.openedAt??p?.openedAt??null,m=s.has(c.caseId),y=p!==void 0&&(!m||Oa({askCount:p.checkinAskCount,answerCount:p.checkinAnswerCount}))?p.lastResponse:null;return Object.freeze({...d,checkin:Object.freeze({...c,status:m?en:p?.status??"resolved",answer:c.answer??y,resolutionText:c.resolutionText??p?.resolutionText??null,...f!==null?{openedAt:f}:{}})})});l&&this.patch({messages:u});}async refreshActiveThread(){if(this.disposed)return E(U("accessDenied",false));let r=this.snapshot.conversationId;if(r===null||this.snapshot.isStreaming)return L(void 0);let n=this.historyGeneration,o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return E(U("accessDenied",false));if(!o.ok)return E(o.error);let s=new Set(this.snapshot.messages.map(l=>l.id)),a=o.value.messages.filter(l=>!s.has(l.id));return a.length>0&&this.patch({messages:[...this.snapshot.messages,...a]}),await this.listConversationsWith({...this.petRef===null?{}:{petRef:this.petRef},limit:1},{maxAttempts:1}),L(void 0)}async loadOlderMessages(){if(this.disposed)return E(U("accessDenied",false));let r=this.snapshot.conversationId,n=this.snapshot.historyCursor;if(!r||!n||this.snapshot.isLoadingHistory)return L(void 0);let o=this.historyGeneration;this.patch({isLoadingHistory:true});let s=await this.getMessages(r,{cursor:n});if(o!==this.historyGeneration||this.disposed)return E(U("accessDenied",false));if(this.patch({isLoadingHistory:false}),!s.ok)return s;let a=new Set(this.snapshot.messages.map(u=>u.id)),l=s.value.messages.filter(u=>!a.has(u.id));return this.patch({messages:[...l,...this.snapshot.messages],historyCursor:s.value.nextCursor===n?null:s.value.nextCursor}),L(void 0)}async*retryHistory(r){let n=await this.resumeConversation(r);n.ok||(yield Le(n.error));}async primeConversation(r){if(this.disposed)return E(U("accessDenied",false));let n=r?.petRef??null,o={petRef:n,settled:this.primeBounded(n)};this.unadoptedCreate=o;let s=await o.settled;return this.disposed?E(U("accessDenied",false)):(!s.ok&&this.unadoptedCreate===o&&(this.unadoptedCreate=null),s)}async primeBounded(r){let n=await this.headThreadWithUnread(r);if(n!==null&&!this.snapshot.isStreaming&&this.snapshot.conversationId===null&&(await this.resumeConversation(n)).ok)return L(n);let o=this.snapshot.conversationId;return o!==null?L(o):this.createConversationBounded(r)}async headThreadWithUnread(r){let n=await this.listConversationsWith({...r===null?{}:{petRef:r},limit:1},{maxAttempts:1});if(!n.ok)return null;let o=n.value.conversations[0];return o===void 0||o.unreadCount===null||o.unreadCount<=0?null:o.id}async createConversation(r){let n=this.epoch;if(this.disposed)return E(U("accessDenied",false));let o=r?.petRef??null,s={petRef:o,settled:this.createConversationBounded(o)};this.unadoptedCreate=s;let a=await s.settled;return !this.alive(n)||this.disposed?E(U("accessDenied",false)):(!a.ok&&this.unadoptedCreate===s&&(this.unadoptedCreate=null),a)}async createConversationBounded(r,n){let o={method:"POST",path:"/widget/v1/conversations",body:r?{pet_ref:r}:{}},s=await this.authedUnary("chat.createConversation",o,n,{maxAttempts:1});if(!s.ok)return E(s.error);let a=s.value?.conversation_id??s.value?.id;return typeof a!="string"||a.length===0?E(U("internalError",true)):L(a)}async getPrompts(r){let n=this.epoch;if(this.disposed)return E(U("accessDenied",false));let o=r?.petRef??null;if(o!==null&&ve(o))return E(D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}));let s=o!==null?`?pet_ref=${encodeURIComponent(o)}`:"",a=await this.authedUnary("chat.getPrompts",{method:"GET",path:`/widget/v1/suggested-prompts${s}`});return !this.alive(n)||this.disposed?E(U("accessDenied",false)):a.ok?L(Pa(a.value)):E(a.error)}async authedUnary(r,n,o,s){return this.funnel.send(r,o?{...n,signal:o}:n,s)}driveWithHandlers(r,n,o){let s=new AbortController,a=Jr(s.signal,n.signal),l=this.beginTurn(r,n),u=this.runTurn(l,a),d=false,c=i(()=>{d||(d=true,s.abort(),this.handlerTeardowns.delete(c));},"teardown");return this.handlerTeardowns.add(c),(async()=>{for await(let p of u){if(d)break;o.onFrame(p),p.kind==="done"&&o.onDone(this.lastResponseIdValue);}!d&&this.snapshot.status==="error"&&this.snapshot.error!==null&&o.onError(this.snapshot.error),this.handlerTeardowns.delete(c);})(),c}beginTurn(r,n){let o={epoch:this.epoch,text:r,petRef:n.petRef??null,imageS3Keys:Object.freeze([...n.imageS3Keys??[]]),idempotencyKey:n.idempotencyKey??this.makeIdempotencyKey(),userMessageId:this.newId(),assistantMessageId:null,sawDelta:false,conversationIdOverride:n.conversationId??null};return this.patch({error:null,stopped:false,reconnecting:false,messages:[...this.snapshot.messages,go(o.userMessageId,r,this.stamp())]}),o}async*runTurn(r,n){let o=this.beginOperation(n);r.epoch=o.epoch,this.patch({status:"streaming",isStreaming:true,error:null}),this.lastTurn=r;let s=0,a=false,l=false;try{for(;;){if(o.signal.aborted||!this.alive(o.epoch))return;let u=r.conversationIdOverride===null&&this.snapshot.conversationId===null,d=u?this.unadoptedCreate:null;if(d!==null&&(r.petRef===null||r.petRef===d.petRef)){let h=await d.settled;if(o.signal.aborted||!this.alive(o.epoch))return;h.ok&&this.snapshot.conversationId===null&&this.adoptConversation(h.value);}if(u&&this.snapshot.conversationId===null){let h=await this.createConversationBounded(r.petRef,o.signal);if(o.signal.aborted||!this.alive(o.epoch))return;if(!h.ok){yield*this.emitTerminal(r,h.error,Le(h.error));return}this.adoptConversation(h.value);}let c=r.conversationIdOverride??this.snapshot.conversationId;if(c===null){let h=U("internalError",!0);yield*this.emitTerminal(r,h,Le(h));return}this.clearAssistantInProgress(r);let p=new AbortController,f=Jr(o.signal,p.signal),m=null;try{let h;try{h=await this.funnel.authorize(this.buildSendRequest(r,c));}catch{let _=this.authRejected();yield*this.emitTerminal(r,_,Le(_));return}if(o.signal.aborted||!this.alive(o.epoch))return;let C=this.funnel.stream("chat.send",h,f);for await(let _ of Ia(C,this.budget,f,this.timers)){if(!this.alive(o.epoch))return;if(_.kind==="error"&&_.terminal){m=_;break}if(this.applyFrame(_,r),yield _,_.terminal){o.settle();return}}}finally{p.abort();}if(o.signal.aborted||!this.alive(o.epoch))return;if(m===null){if(this.snapshot.status==="complete")return;let h=U("streamIncomplete",!0);yield*this.emitTerminal(r,h,Le(h));return}let y=Me(m.code);if(y==="authExpired"&&this.auth.mode==="personalized"&&!l){l=!0,this.telemetry.track("chat.auth.refresh",{});let h=await this.tryForceRefresh();if(o.signal.aborted||!this.alive(o.epoch))return;if(!h){let C=this.authRejected();yield*this.emitTerminal(r,C,m);return}this.patch({reconnecting:!0});continue}if(y==="authExpired"){this.telemetry.track("chat.auth.rejected",{});let h=this.authRejected();yield*this.emitTerminal(r,h,m);return}if(y==="accessDenied"){this.telemetry.track("chat.access_denied",{}),yield*this.emitTerminal(r,vo(m),m);return}if(Ms(y)&&!a){a=!0,this.telemetry.track("chat.conv.recreate",{}),this.adoptConversation(null),r.conversationIdOverride=null,this.patch({reconnecting:!0});continue}let R=m.retryable&&Wr(y,!0);if(Ny&&R&&s+1<this.errorPolicy.maxAttempts(y));yield*this.emitTerminal(r,vo(m),m);return}}finally{o.settle();}}*emitTerminal(r,n,o){this.applyError(r,n),yield o;}applyFrame(r,n){switch(r.kind){case "accepted":this.snapshot.isStreaming||this.patch({status:"streaming",isStreaming:true});return;case "heartbeat":return;case "delta":this.applyDelta(r.delta,n);return;case "done":this.applyDone(r,n);return;case "analysisStarted":case "analysisComplete":return;case "unknown":this.telemetry.track("chat.frame.unknown",{});return;case "error":return;default:return nt(r)}}stamp(){return new Date(this.timers.now()).toISOString()}applyDelta(r,n){if(n.assistantMessageId===null){let o=this.newId();n.assistantMessageId=o,n.sawDelta=true;let s=this.snapshot.messages.map(a=>a.id===n.userMessageId&&a.pending===true?sr(a):a);this.patch({status:"streaming",isStreaming:true,messages:[...s,ho(o,r,this.stamp())]});return}if(this.pendingDelta+=r,this.pendingDelta.length>=Dy){this.flushPendingDelta(n);return}this.scheduleDeltaFlush(n);}scheduleDeltaFlush(r){if(this.flushHandle!==null)return;let n=this.epoch;this.flushHandle=this.timers.setTimeout(()=>{if(this.flushHandle=null,!this.alive(n)){this.pendingDelta="";return}this.flushPendingDelta(r);},Ly);}flushPendingDelta(r){if(this.clearFlushTimer(),this.pendingDelta.length===0)return;let n=this.pendingDelta;this.pendingDelta="";let o=r.assistantMessageId;if(o===null)return;let s=this.snapshot.messages.map(a=>a.id===o?Sa(a,n):a);this.patch({messages:s});}discardPendingDelta(){this.clearFlushTimer(),this.pendingDelta="";}clearFlushTimer(){this.flushHandle!==null&&(this.timers.clearTimeout(this.flushHandle),this.flushHandle=null);}applyDone(r,n){this.flushPendingDelta(n),this.lastResponseIdValue=r.messageId?r.messageId:null;let o=r.conversationId?r.conversationId:this.snapshot.conversationId,s;if(n.assistantMessageId!==null)s=this.snapshot.messages.map(l=>l.id===n.assistantMessageId?bo(l,r):l);else {let l=this.newId();n.assistantMessageId=l,n.sawDelta=true,s=[...this.snapshot.messages.map(d=>d.id===n.userMessageId&&d.pending===true?sr(d):d),bo(ho(l,"",this.stamp()),r)];}let a=Eo([{category:"",prompts:r.followUpQuestions}]);this.replyPrompts=a.length>0?Object.freeze(a):null,this.patch({status:"complete",isStreaming:false,error:null,conversationId:o,messages:s,suggestedPrompts:this.replyPrompts??this.bootstrapPrompts,reconnecting:false}),!r.urgencyProvided&&o!==null&&this.classifyTurn(o,this.lastResponseIdValue);}async classifyTurn(r,n){if(n===null||this.disposed)return;let o=String(n);if(this.classifiedMessageIds.has(o))return;this.classifiedMessageIds.add(o);let s=this.epoch,a=this.historyGeneration,l=await this.authedUnary("chat.classifyUrgency",{method:"POST",path:`/widget/v1/conversations/${r}/classify`});if(!l.ok||!this.alive(s)||this.disposed||a!==this.historyGeneration||this.snapshot.conversationId!==r)return;let u=Ua(l.value?.urgency),d=typeof l.value?.reason=="string"?l.value.reason:null,c=i(p=>p.responseId===n,"carries");this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,urgencyLevel:u,urgencyReason:d,urgencyProvided:true}):p)});}applyError(r,n){this.flushPendingDelta(r);let o=this.snapshot.messages.map(s=>s.id===r.userMessageId&&s.pending===true?sr(s):s);this.patch({status:"error",isStreaming:false,error:n,messages:o,reconnecting:false});try{this.errorPolicy.onExpectedFailure?.(n);}catch{}}clearAssistantInProgress(r){if(this.discardPendingDelta(),r.assistantMessageId===null)return;let n=r.assistantMessageId;r.assistantMessageId=null,r.sawDelta=false;let o=this.snapshot.messages.filter(s=>s.id!==n);o.length!==this.snapshot.messages.length&&this.patch({messages:o});}buildSendRequest(r,n){let o={message:r.text};return r.imageS3Keys.length>0&&(o.image_s3_keys=r.imageS3Keys),{method:"POST",path:`/widget/v1/conversations/${n}/messages`,body:o,headers:{"Idempotency-Key":r.idempotencyKey}}}async tryForceRefresh(){if(this.auth.mode!=="personalized")return false;try{return await this.auth.identity.currentToken({forceRefresh:!0}),!0}catch{return false}}authRejected(){return U("authRejected",false)}};i(_o,"ChatControllerImpl");var xo=_o;async function ja(e,t){let{controller:r}=t,n=e.petRef??null,o=e.resumeConversationId??null,s=[],a=false,l=false,u=false,d=null,c=null,p=o?r.resumeConversation(o).then(x=>x.ok?L(o):x):r.primeConversation(n?{petRef:n}:void 0),f=r.getPrompts(n!==null?{petRef:n}:void 0),[m,y]=await Promise.all([p,f]),R=null;if(m.ok)R=m.value,s.push(m.value),r.getSnapshot().conversationId===null&&r.adoptConversation(m.value);else {let x=m.error;c=x,Ha(x)?(l=true,d=x):(za(x)&&(a=true),u=true);}let h=[];y.ok?h=y.value:C(y.error);function C(x){Ha(x)?(l=true,d===null&&(d=x)):za(x)&&(a=true);}i(C,"recordAuthSignals");let _=d!==null?d.displayMessage:null;return Object.freeze({conversationId:R,petRef:n,suggestedPrompts:h,error:_,warning:_===null&&R===null&&u?Uy:null,cause:d??c,diagnostics:Object.freeze({candidateConversationIds:Object.freeze([...s]),sawForbidden:a,sawUnauthorized:l,sawConversationInitFailure:u})})}i(ja,"bootstrapChat");var Uy="Chat is ready. Your first message will start the conversation.";function Ha(e){return e.httpStatus===401||e.code==="authExpired"||e.code==="authRejected"}i(Ha,"isUnauthorized");function za(e){return e.httpStatus===403||e.code==="accessDenied"}i(za,"isForbidden");var wo=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Wa(e){return e!==wo}i(Wa,"isUploadTransportAvailable");var Vy=Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var tn=10*1024*1024,rn=5,dr=120,By="/widget/v1/uploads/initiate";function Hy(e){return typeof e=="string"&&Vy.includes(e.trim().toLowerCase())}i(Hy,"isAttachmentMime");function Io(e){if(!e)return "attachment";let t=e.replace(/[\\/]+/g," ").replace(/[\x00-\x1f\x7f"]/g,"").replace(/\s+/g," ").trim();if(!t)return "attachment";if(t.length<=dr)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,dr);let n=t.slice(r);return n.length>=dr?t.slice(0,dr):`${t.slice(0,r).slice(0,dr-n.length)}${n}`}i(Io,"sanitizeFilename");function Ao(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i(Ao,"formatBytes");var cr=i(e=>Object.freeze({ok:true,value:e}),"ok"),Oe=i(e=>Object.freeze({ok:false,error:e}),"err");function le(e,t,r,n){return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}i(le,"failure");function zy(e){if(typeof e.sizeBytes=="number"&&Number.isFinite(e.sizeBytes)&&e.sizeBytes>=0)return e.sizeBytes;let t=e.blob;return t!==void 0&&typeof t.size=="number"&&Number.isFinite(t.size)?t.size:null}i(zy,"attachmentSize");function jy(e){let t=Io(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!Hy(r))return Oe(le("unsupported_type",false,t));let n=zy(e);return n===null?Oe(le("unknown",false,t)):n>tn?Oe(le("too_large",false,t,{sizeBytes:n})):cr(Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}i(jy,"validateAttachment");function Wy(e){if(typeof e!="object"||e===null)return null;let t=e,r=i(d=>typeof d=="string"&&d.length>0?d:null,"str"),n=i(d=>typeof d=="number"&&Number.isFinite(d)?d:null,"num"),o=r(t.upload_id),s=r(t.upload_url),a=r(t.s3_key);if(o===null||s===null||a===null)return null;let l={},u=t.upload_fields;if(typeof u=="object"&&u!==null)for(let[d,c]of Object.entries(u))typeof c=="string"&&(l[d]=c);return Object.freeze({upload_id:o,upload_url:s,upload_fields:Object.freeze(l),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??tn,s3_key:a,purpose:r(t.purpose)})}i(Wy,"parsePolicy");function Gy(e,t){let r=e.httpStatus;switch(e.code){case "quotaExceeded":return le("quota_exceeded",false,t,{cause:e});case "rateLimited":return le("rate_limited",true,t,{cause:e});case "idempotencyConflict":case "idempotencyInFlight":return le("idempotency_conflict",true,t,{cause:e});case "validationFailed":return le("unsupported_type",false,t,{cause:e});case "serviceUnavailable":case "streamTimeout":return le("network",true,t,{cause:e});default:return r===429?le("rate_limited",true,t,{cause:e}):r===503?le("network",true,t,{cause:e}):r===void 0?le("network",true,t,{cause:e}):le("server",e.retryable,t,{httpStatus:r,cause:e})}}i(Gy,"initiateFailure");async function Ky(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:By,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return Oe(Gy(n.error,t.filename));let o=Wy(n.value);return o===null?Oe(le("server",false,t.filename)):cr(o)}i(Ky,"initiateAttachmentUpload");async function qy(e,t,r,n){let o=i(()=>n?.signal?.aborted===true,"cancelled");if(o())return Oe(le("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),cr(void 0)}catch{return o()?Oe(le("cancelled",true,r.filename)):Oe(le("server",true,r.filename))}}i(qy,"uploadAttachmentBytes");var $y=2,Yy=3,Xy=Object.freeze([1e3,2e3,4e3]),Ga=0;function Qy(){return Ga+=1,`attachment-${Ga}`}i(Qy,"defaultNewId");function Ka(e){let t=Math.max(1,e.concurrency??$y),r=Math.max(1,e.maxAttempts??Yy),n=e.backoffMs??Xy,o=Math.max(1,e.maxPerMessage??rn),s=e.timers??Ra,a=e.newId??Qy,l=Wa(e.transport),u=new Map,d=[],c=[],p=new Set,f=new Set,m=Object.freeze({attachments:Object.freeze([])}),y=false,R=i(()=>{m=Object.freeze({attachments:Object.freeze(d.flatMap(g=>{let w=u.get(g);return w===void 0?[]:[w.state]}))});for(let g of f)g();},"publish"),h=i((g,w)=>{g.state=Object.freeze({...g.state,...w}),R();},"patch"),C=i(()=>{for(;!y&&p.size<t&&c.length>0;){let g=c.shift(),w=u.get(g);w!==void 0&&(p.add(g),_(w).finally(()=>{p.delete(g),C();}));}},"pump"),_=i(async g=>{let{attachment:w}=g;for(;g.attempts<r;){if(y||g.controller.signal.aborted)return;g.attempts+=1;let O=g.controller.signal;h(g,{status:"uploading",error:null,progress:0});let M=await Ky(e.funnel,w,{signal:O});if(y||O.aborted)return;let I;if(!M.ok)I=Oe(M.error);else {let W=await qy(e.transport,M.value,w,{signal:O,onProgress:i(G=>{!O.aborted&&g.state.status==="uploading"&&h(g,{progress:Zy(G)});},"onProgress")});if(y||O.aborted)return;I=W.ok?cr(M.value.s3_key):Oe(W.error);}if(I.ok){h(g,{status:"uploaded",s3Key:I.value,error:null,progress:1});return}let v=I.error,k=v.retryable&&g.attempts<r;if(h(g,{status:k?"uploading":"failed",error:v,progress:0}),!k)return;let V=n[Math.min(g.attempts-1,n.length-1)]??0;await Zr(V,O,s);}},"run"),P=i(g=>{c.push(g.state.id),C();},"enqueue"),x={available:l,subscribe(g){return f.add(g),()=>{f.delete(g);}},getSnapshot:i(()=>m,"getSnapshot"),get uploading(){return m.attachments.some(g=>g.status==="uploading")},get s3Keys(){return m.attachments.flatMap(g=>g.status==="uploaded"&&g.s3Key!==null?[g.s3Key]:[])},add(g){let w=jy(g);if(!w.ok)return w;if(y||d.length>=o)return Oe(le("too_many",false,w.value.filename));let O=a(),M={attachment:w.value,controller:new AbortController,attempts:0,state:Object.freeze({id:O,filename:w.value.filename,previewUri:g.uri,contentType:w.value.contentType,sizeBytes:w.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return u.set(O,M),d.push(O),R(),P(M),cr(M.state)},retry(g){let w=u.get(g);w===void 0||y||w.state.status!=="failed"||(w.controller=new AbortController,w.attempts=0,h(w,{status:"uploading",error:null,progress:0,s3Key:null}),P(w));},remove(g){let w=u.get(g);if(w===void 0)return;w.controller.abort(),u.delete(g);let O=d.indexOf(g);O>=0&&d.splice(O,1);let M=c.indexOf(g);M>=0&&c.splice(M,1),R();},clear(){for(let g of [...d])x.remove(g);},dispose(){y=true;for(let g of u.values())g.controller.abort();u.clear(),d.length=0,c.length=0,f.clear(),m=Object.freeze({attachments:Object.freeze([])});}};return x}i(Ka,"createAttachmentQueue");function Zy(e){return Number.isNaN(e)||e<0?0:e>1?1:e}i(Zy,"clamp");var qa=Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function pr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(qa,t)?qa[t]:null}i(pr,"canonicalPetSpecies");var $a=50,Jy=128,Oo=120,Ya=120,eg=2e3,Xa=120,tg=80,Ja=new Set(["male","female","unknown"]),el=new Set(["day","month","year"]),tl=new Set(["low","medium","high","athletic"]),rl=new Set(["indoor","outdoor","both"]),nl=new Set(["mild","moderate","severe"]),rg=/^(\d{4})-(\d{2})-(\d{2})$/,ol=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],il=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];Object.freeze([...ol,...il].map(([e])=>e));function ng(e){let t=rg.exec(e);if(t===null)return false;let[r,n,o]=[Number(t[1]),Number(t[2]),Number(t[3])],s=new Date(Date.UTC(r,n-1,o));return s.getUTCFullYear()===r&&s.getUTCMonth()===n-1&&s.getUTCDate()===o}i(ng,"isRealDate");var mr=i(e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,"oneOf"),og=i((e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,"boolean"),on=i((e,t)=>typeof t=="string"&&ng(t)?null:`${e} must be a real date written YYYY-MM-DD`,"date"),De=i((e,t={})=>(r,n)=>{if(typeof n!="string")return `${r} must be a string`;if(ve(n))return `${r} contains an unpaired surrogate and cannot be encoded`;let o=t.trimmed?n.trim():n;if(t.required&&o.length===0)return `${r} is required and must not be blank`;let s=pt(o);return s<=e?null:`${r} is ${s} characters; the server accepts at most ${e}`},"text"),ig={sex:mr(Ja),spayedNeutered:og,birthDate:on,birthDatePrecision:mr(el),activityLevel:mr(tl),indoorOutdoor:mr(rl),foodBrand:De(Xa),foodType:De(Xa),microchipId:De(tg)},Fo=["ref","ref",false,De(Jy,{required:true,trimmed:true})],Mo=["notes","notes",false,De(eg,{trimmed:true})],Qa=[Fo,["name","name",true,De(Oo,{required:true,trimmed:true})],["dose","dose",false,De(Ya,{trimmed:true})],["frequency","frequency",false,De(Ya,{trimmed:true})],["startDate","start_date",false,on],["endDate","end_date",false,on],Mo],sg={allergies:[Fo,["allergen","allergen",true,De(Oo,{required:true,trimmed:true})],["severity","severity",false,mr(nl)],Mo],medications:Qa,supplements:Qa,conditions:[Fo,["conditionName","condition_name",true,De(Oo,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,on],Mo]};function ag(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return {error:`${n} must be an object`};let o=r,s={};for(let[u,d,c,p]of sg[e]){let f=o[u];if(f==null){if(c)return {error:`${n}.${u} is required`};f===null&&(s[d]=null);continue}let m=p(`${n}.${u}`,f);if(m!==null)return {error:m};s[d]=f;}let a=s.start_date,l=s.end_date;return typeof a=="string"&&typeof l=="string"&&l<a?{error:`${n}.endDate must not be before startDate`}:{item:s}}i(ag,"itemToWire");function lg(e,t){if(!Array.isArray(t))return {error:`${e} must be an array (send [] to clear it)`};if(t.length>$a)return {error:`${e} has ${t.length} items; the server accepts at most ${$a}`};let r=[],n=new Set;for(let o=0;o<t.length;o+=1){let s=ag(e,o,t[o]);if("error"in s)return s;let a=s.item.ref;if(typeof a=="string"){let l=a.trim();if(n.has(l))return {error:`${e}: ref ${JSON.stringify(l)} is used twice; a ref names one item`};n.add(l);}r.push(s.item);}return {items:r}}i(lg,"listToWire");function sl(e,t){let r=e,n={};for(let[a,l]of ol){let u=r[a];if(u!==void 0){if(u!==null){let d=ig[a](a,u);if(d!==null)return {error:d}}n[l]=u;}}let o=r.birthDate!==void 0,s=r.birthDatePrecision!==void 0;if(o!==s||o&&r.birthDate===null!=(r.birthDatePrecision===null))return {error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[a,l]of il){let u=r[a];if(u===void 0)continue;let d=lg(a,u);if("error"in d)return d;n[l]=d.items;}return Object.keys(n).length>0&&t!==void 0&&pr(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}i(sl,"petHealthToWire");var ne=i(e=>typeof e=="string"?e:null,"str"),fr=i((e,t)=>typeof t=="string"&&e.has(t)?t:null,"pick"),ug=i(e=>typeof e=="boolean"?e:null,"bool");function nn(e,t){return Array.isArray(e)?Object.freeze(e.flatMap(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return [];let n=t(r);return n===null?[]:[n]})):Object.freeze([])}i(nn,"itemsFromWire");function Za(e){let t=ne(e.name);return t===null||t.length===0?null:Object.freeze({ref:ne(e.ref),name:t,dose:ne(e.dose),frequency:ne(e.frequency),startDate:ne(e.start_date),endDate:ne(e.end_date),notes:ne(e.notes)})}i(Za,"medicationFromWire");function al(e){let t=e.profile_version;return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:fr(Ja,e.sex),spayedNeutered:ug(e.spayed_neutered),birthDate:ne(e.birth_date),birthDatePrecision:fr(el,e.birth_date_precision),activityLevel:fr(tl,e.activity_level),indoorOutdoor:fr(rl,e.indoor_outdoor),foodBrand:ne(e.food_brand),foodType:ne(e.food_type),microchipId:ne(e.microchip_id),allergies:nn(e.allergies,r=>{let n=ne(r.allergen);return n===null||n.length===0?null:Object.freeze({ref:ne(r.ref),allergen:n,severity:fr(nl,r.severity),notes:ne(r.notes)})}),medications:nn(e.medications,Za),supplements:nn(e.supplements,Za),conditions:nn(e.conditions,r=>{let n=ne(r.condition_name);return n===null||n.length===0?null:Object.freeze({ref:ne(r.ref),conditionName:n,diagnosedDate:ne(r.diagnosed_date),notes:ne(r.notes)})})})}i(al,"petHealthFromWire");var dl=100,cl=50,pl=100,fl=50,ml=500,dg=128,cg=6e4;function Ue(e){return D("validationFailed",{retryable:false,wireMessage:e})}i(Ue,"invalid");function ft(e,t,r){if(typeof t!="string")return Ue(`${e} must be a string`);let n=pt(t);return n<=r?null:Ue(`${e} is ${n} characters; the server accepts at most ${r}`)}i(ft,"checkString");function sn(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:Ue(`${e} must be a finite number between 0 and ${r}`)}i(sn,"outOfRange");function ll(e,t){if(typeof e!="string")return Ue("pet_ref must be a string");if(e.trim().length===0)return Ue("pet_ref must not be blank");if(ve(e))return Ue("pet_ref contains an unpaired surrogate and cannot be encoded");if(t!=null&&typeof t!="object")return Ue("profile must be an object");let r=[ft("pet_ref",e,dg)];return t?.name!==void 0&&r.push(ft("name",t.name,dl)),t?.species!==void 0&&r.push(ft("species",t.species,cl)),t?.breed!==void 0&&r.push(ft("breed",t.breed,pl)),t?.ageYears!==void 0&&r.push(sn("age_years",t.ageYears,fl)),t?.weightKg!==void 0&&r.push(sn("weight_kg",t.weightKg,ml)),r.find(n=>n!==null)??null}i(ll,"validate");function yl(e,t){let r=sl(e,t);return "error"in r?{error:Ue(r.error)}:r}i(yl,"healthToWire");function pg(e){if(typeof e!="object"||e===null)return {error:Ue("patch must be an object")};let t=e,r=[["name","name",s=>ft("name",s,dl)],["species","species",s=>ft("species",s,cl)],["breed","breed",s=>ft("breed",s,pl)],["ageYears","age_years",s=>sn("age_years",s,fl)],["weightKg","weight_kg",s=>sn("weight_kg",s,ml)]],n={};for(let[s,a,l]of r){let u=t[s];if(u!==void 0){if(u!==null){let d=l(u);if(d!==null)return {error:d}}n[a]=u;}}let o=yl(t,t.species);return "error"in o?o:(Object.assign(n,o.body),Object.keys(n).length===0?{error:Ue("patch must change at least one field")}:{body:n})}i(pg,"patchToWire");function fg(e){if(e==null)return {body:{}};let t=yl(e,e.species);return "error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}i(fg,"toWire");var Ne=i(e=>typeof e=="string"?e:null,"str"),an=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"num");function ul(e,t){let r=typeof e=="object"&&e!==null?e:{};return Object.freeze({petRef:Ne(r.pet_ref)??t,name:Ne(r.name),species:Ne(r.species),breed:Ne(r.breed),ageYears:an(r.age_years),weightKg:an(r.weight_kg)})}i(ul,"fromWire");function gl(e){if(typeof e!="object"||e===null)return null;let t=e,r=Ne(t.pet_ref);return r===null||r.length===0?null:Object.freeze({petId:Ne(t.pet_id),petRef:r,name:Ne(t.name),species:Ne(t.species),breed:Ne(t.breed),ageYears:an(t.age_years),weightKg:an(t.weight_kg),updatedAt:Ne(t.updated_at)})}i(gl,"widgetPetFromWire");function mg(e){let t=gl(e);return t===null?null:Object.freeze({...t,...al(e)})}i(mg,"widgetPetProfileFromWire");function yg(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];return Object.freeze(t.flatMap(r=>{let n=gl(r);return n===null?[]:[n]}))}i(yg,"petListFromWire");function ot(e){return gg(Ae({auth:e}),Ae({auth:e,unaryTimeoutMs:cg}))}i(ot,"createPetsRepository");function gg(e,t=e){let r=i((o,s)=>s?{...o,signal:s}:o,"withSignal"),n=i(o=>ll(o,void 0)??`/widget/v1/pets/${encodeURIComponent(o)}`,"petPath");return {async list(o){let s=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},o?.signal));return s.ok?L(yg(s.value)):E(s.error)},async registerPet(o,s,a){let l=ll(o,s);if(l!==null)return E(l);let u=fg(s);if("error"in u)return E(u.error);let c={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(o)}`,body:u.body},p=await e.send("pets.registerPet",a?.signal?{...c,signal:a.signal}:c);return p.ok?L(ul(p.value,o)):E(p.error)},async updatePet(o,s,a){let l=n(o);if(typeof l!="string")return E(l);let u=pg(s);if("error"in u)return E(u.error);let d=await e.send("pets.updatePet",r({method:"PATCH",path:l,body:u.body},a?.signal));return d.ok?L(ul(d.value,o)):E(d.error)},async getPetProfile(o,s){let a=n(o);if(typeof a!="string")return E(a);let l=await e.send("pets.getPetProfile",r({method:"GET",path:`${a}/profile`},s?.signal));if(!l.ok)return E(l.error);let u=mg(l.value);return u===null?E(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):L(u)},async deletePet(o,s){let a=n(o);if(typeof a!="string")return E(a);let l=await e.send("pets.deletePet",r({method:"DELETE",path:a},s?.signal));return l.ok?L(void 0):E(l.error)},async eraseUserData(o){let s=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},o?.signal),{maxAttempts:1});return s.ok?L(void 0):E(s.error)}}}i(gg,"createPetsRepositoryOver");var Do=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 hg(e){return Do[e]}i(hg,"requires");function hl(e,t){let r=Object.freeze({reason:t,level:e,recoverable:false}),n=[],o=new Set;for(let s of Object.keys(Do))for(let a of Do[s])o.has(a)||(o.add(a),n.push(Object.freeze({resource:a,granted:false,disabled:r})));return Object.freeze(n)}i(hl,"deniedDecisionsFor");function bl(e,t,r){let n=hg(e),o=new Map;for(let l of t)o.set(l.resource,l);if(r?.isPending===true&&n.some(l=>!o.has(l)))return Lo({name:e,enabled:false,isPending:true,limits:{}});let s=bg(n,o);return n.filter(l=>o.get(l)?.granted!==true).length===0?Lo({name:e,enabled:true,isPending:false,limits:s}):Lo({name:e,enabled:false,isPending:false,limits:s,disabled:vg(n,o)})}i(bl,"decideCapability");function bg(e,t){let r={};for(let n of e){let o=t.get(n)?.limits;if(o)for(let[s,a]of Object.entries(o)){let l=r[s];r[s]=l===void 0?a:Math.min(l,a);}}return r}i(bg,"mergeLimits");function vg(e,t){for(let r of e){let n=t.get(r)?.disabled;if(n)return Object.freeze({reason:n.reason,level:n.level,recoverable:n.recoverable})}return Object.freeze({reason:Mt("accessDenied"),level:"user_entitlement",recoverable:false})}i(vg,"disabledFor");function Lo(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),Object.freeze(t)}i(Lo,"freezeDecision");function X(e){let t=Y(e);return t===null?null:Cg(t)}i(X,"parseColor");function Y(e){if(typeof e=="number")return vl(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return No(t.slice(1));if(t.toLowerCase().startsWith("0x"))return No(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Eg(t);if(/^[0-9a-fA-F]+$/.test(t)){let r=No(t);if(r!==null)return r}return /^\d+$/.test(t)?vl(Number.parseInt(t,10)):null}i(Y,"toRgba");function No(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return {r:Uo(t[0]),g:Uo(t[1]),b:Uo(t[2]),a:1};if(t.length===6)return {r:mt(t,0),g:mt(t,2),b:mt(t,4),a:1};if(t.length===8){let r=mt(t,0);return {r:mt(t,2),g:mt(t,4),b:mt(t,6),a:r/255}}return null}i(No,"fromHex");function Eg(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(u=>u.trim());if(n.length<3)return null;let o=Vo(Number(n[0])),s=Vo(Number(n[1])),a=Vo(Number(n[2]));if(o===null||s===null||a===null)return null;let l=1;if(n.length>=4){let u=Number(n[3]);if(!Number.isFinite(u))return null;l=Math.min(1,Math.max(0,u));}return {r:o,g:s,b:a,a:l}}i(Eg,"fromRgbFunc");function vl(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return {r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}i(vl,"argbIntToRgba");function mt(e,t){return Number.parseInt(e.slice(t,t+2),16)}i(mt,"byte");function Uo(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}i(Uo,"dup");function Vo(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}i(Vo,"clampByte");function Cg(e){if(e.a>=1)return Ke(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return `rgba(${e.r},${e.g},${e.b},${t})`}i(Cg,"normalizeRgba");function Ke(e,t,r){return `#${Bo(e)}${Bo(t)}${Bo(r)}`.toUpperCase()}i(Ke,"rgbToHex");function Bo(e){return e.toString(16).padStart(2,"0")}i(Bo,"hex2");var Rg="#111111",Ut="#FFFFFF",ln="#000000";function Cl(e){let t=Y(e);if(t===null)return Ut;let r=yt(t),n=yt({r:17,g:17,b:17}),o=yt({r:255,g:255,b:255});return jo(r,o)>=jo(r,n)?Ut:Rg}i(Cl,"readableOn");function Vt(e,t){let r=Cl(e);return oe(r,e)>=t?r:oe(Ut,e)>=oe(ln,e)?Ut:ln}i(Vt,"legibleOn");function Ee(e){let t=i(r=>e.reduce((n,o)=>Math.min(n,oe(r,o)),Number.POSITIVE_INFINITY),"worst");return t(Ut)>=t(ln)?Ut:ln}i(Ee,"poleForGrounds");function yt(e){let t=Ho(e.r/255),r=Ho(e.g/255),n=Ho(e.b/255);return .2126*t+.7152*r+.0722*n}i(yt,"relativeLuminance");function Ho(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}i(Ho,"linearize");function jo(e,t){let r=Math.max(e,t),n=Math.min(e,t);return (r+.05)/(n+.05)}i(jo,"luminanceContrast");function oe(e,t){let r=Y(e),n=Y(t);if(r===null||n===null)return 1;let o=n.a>=1?n:{...n},s=r.a>=1?r:Rl(r,o);return jo(yt(s),yt(o))}i(oe,"contrastRatio");function Rl(e,t){let r=e.a,n=i((o,s)=>Math.round(o*r+s*(1-r)),"mix");return {r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}i(Rl,"composite");function Ve(e,t){let r=Y(e),n=Y(t);if(r===null||n===null)return null;let o=r.a>=1?r:Rl(r,{...n});return Ke(o.r,o.g,o.b)}i(Ve,"flattenOnto");function Sl(e,t){let r=Y(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return `rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}i(Sl,"withAlpha");var El=.05;function yr(e,t,r,n){let o=t[0];if(o===void 0)return r;let s=i(d=>t.every(c=>oe(d,c)>=n),"reads");if(Y(e)===null)return r;if(s(e))return e;let a=Ve(e,o),l=a===null?null:Y(a),u=Y(r);if(l===null||u===null)return r;for(let d=1;d<1/El;d+=1){let c=d*El,p=i((m,y)=>Math.round(m+(y-m)*c),"mix"),f=Ke(p(l.r,u.r),p(l.g,u.g),p(l.b,u.b));if(s(f))return f}return r}i(yr,"pushToContrast");function Tl(e,t,r){let n=e/255,o=t/255,s=r/255,a=Math.max(n,o,s),l=Math.min(n,o,s),u=(a+l)/2;if(a===l)return {h:0,s:0,l:u};let d=a-l,c=d/(1-Math.abs(2*u-1)),p;return a===n?(p=(o-s)/d*60,p<0&&(p=p+360)):a===o?p=((s-n)/d+2)*60:p=((n-o)/d+4)*60,{h:p,s:c,l:u}}i(Tl,"rgbToHsl");function Wo(e){let{h:t,s:r,l:n}=e,o=(1-Math.abs(2*n-1))*r,s=t/60,a=o*(1-Math.abs(s%2-1)),l=n-o/2,u=Math.floor(s)%6,d=[[o,a,0],[a,o,0],[0,o,a],[0,a,o],[a,0,o],[o,0,a]],[c,p,f]=d[u];return {r:zo(c+l),g:zo(p+l),b:zo(f+l)}}i(Wo,"hslToRgb");function zo(e){return Math.min(255,Math.max(0,Math.floor(e*255+.5)))}i(zo,"channel");var qe=Object.freeze(["composerInput","sendButton","userBubble","assistantBubble","vetBubble","recordCard","vetVisitButton","primaryButton","link"]),Sg=Object.freeze(["backgroundColor","borderColor","borderRadius","textColor"]),Q=4.5,Tg=Object.freeze({});function Pg(e){return qe.includes(e)}i(Pg,"isSlotName");function kg(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)?Math.max(0,t):null}i(kg,"parseRadius");function Pl(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t={},r=false;for(let[n,o]of Object.entries(e)){if(!Pg(n)||o===null||typeof o!="object")continue;let s=xg(o);s!==null&&(t[n]=s,r=true);}return r?Object.freeze(t):null}i(Pl,"parseThemeSlots");function un(e,t,r){return e[t]!==void 0?e[t]:e[r]}i(un,"pick");function xg(e){let t={},r=X(un(e,"background_color","backgroundColor"));r!==null&&(t.backgroundColor=r);let n=X(un(e,"border_color","borderColor"));n!==null&&(t.borderColor=n);let o=kg(un(e,"border_radius","borderRadius"));o!==null&&(t.borderRadius=o);let s=X(un(e,"text_color","textColor"));return s!==null&&(t.textColor=s),Object.keys(t).length===0?null:Object.freeze(t)}i(xg,"parseSlot");function dn(e,t){return t===null||Object.keys(t).length===0?e??Tg:e===null||Object.keys(e).length===0?t:Object.freeze({...e,...t})}i(dn,"mergeThemeSlots");var gr=3;function _g(e,t){return e===void 0?t:t.length===0?[e]:t.map(r=>Ve(e,r)??r)}i(_g,"seatsOf");function wg(e,t){let r=Ee(e);return e.every(n=>oe(r,n)>=t)}i(wg,"someInkReads");function Ig(e,t){let r=t[0];return r===void 0?null:Ve(e,r)}i(Ig,"collapseUnsatisfiableFill");function Ag(e){let t=Vt(e[0],Q);return e.every(r=>oe(t,r)>=Q)?t:Ee(e)}i(Ag,"inkFor");function kl(e,t){let r=false,n={};for(let o of qe){let s=e[o];if(s===void 0)continue;let a=s.backgroundColor,l=t?.[o]??[],u=_g(a,l),d={...s},c=false;if(a!==void 0&&u.length>1&&!wg(u,Q)){let p=Ig(a,l);p!==null&&(d.backgroundColor=p,u=[p],c=true);}if(u.length>0){let p=s.textColor;if(a!==void 0)(p===void 0||u.some(f=>oe(p,f)<Q))&&(d.textColor=Ag(u),c=true);else if(p!==void 0){let f=yr(p,u,Ee(u),Q);f!==p&&(d.textColor=f,c=true);}if(s.borderColor!==void 0){let f=yr(s.borderColor,u,Ee(u),gr);f!==s.borderColor&&(d.borderColor=f,c=true);}}n[o]=c?Object.freeze(d):s,r=r||c;}return r?Object.freeze(n):e}i(kl,"guardSlotContrast");function $e(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.keys(e))$e(e[t]);}return e}i($e,"deepFreeze");var pn=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),_l={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},wl={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},xl={nano:8,small:9,micro:10,tiny:11,caption:12,bodyTight:13,body:14,subtitle:16,heading:18,verdict:24},Og={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Fg={regular:"400",medium:"500",bold:"700"},Mg={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},Go=0,gt="System",Be="monospace",Lg=["content","heading","control","compact","badge"];function Dg(e){let t={};for(let r of Lg)t[r]=e;return t}i(Dg,"authoredTierSizes");function Il(){return {family:gt,mono:Be,fontUrl:null,families:{regular:gt,medium:gt,bold:gt,mono:Be,monoMedium:Be,monoBold:Be},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:xl,tierSizes:Dg(xl),lineHeight:Og,weight:Fg,letterSpacing:Mg,scale:1,maxScale:Go,scaleCaps:pn}}i(Il,"baseType");var Al={},ht=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function cn(e){return `cubic-bezier(${e.join(", ")})`}i(cn,"cssCubicBezier");var Ol={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cn(ht.standard),emphasized:cn(ht.emphasized),exit:cn(ht.exit)},reducedMotion:false},Ng={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",onDanger:"#FFFFFF",errorRed:"#CC1600",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)"},Ce=$e({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Ng,space:_l,radius:wl,type:Il(),motion:Ol,slots:Al}),Ug={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",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:"#111111",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"},it=$e({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Ug,space:_l,radius:wl,type:Il(),motion:Ol,slots:Al});function bt(e){return [e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}i(bt,"textGrounds");function Fl(e){return [e.surface,e.surfaceCream,e.background,e.chatGround,e.composerFill]}i(Fl,"controlGrounds");function Ko(e){return [e.chatGround,e.surface,e.surfaceCream]}i(Ko,"linkGrounds");function Ml(e,t){return [e.surface,e.surfaceCream,e.background,e.chatGround,e.composerFill,...Ll(e,t)]}i(Ml,"statusGrounds");function Ll(e,t){return [Ve(t,e.surface)??e.surface,Ve(t,e.surfaceCream)??e.surfaceCream]}i(Ll,"washGrounds");function Vg(e){return [e.composerFill,e.chatGround]}i(Vg,"composerGrounds");var Bg=new Set(["text.timestamp","text.placeholder","errorRed","warningStrong","composerBorder"]);function Dl(e,t){let r=new Set(bt(t));return bt(e).every(n=>r.has(n))}i(Dl,"onCompiledGrounds");function Nl(e){let t=e.color,r=(e.brightness==="dark"?it:Ce).color,n=(e.brightness==="dark"?Ce:it).color,o=bt(t),s=Ee(o)!==Ee(bt(r)),a=Dl(t,r),l=t.danger===r.danger&&t.badgeBgCritical===r.badgeBgCritical,u=i((R,h,C,_,P,x)=>{let g=h===C&&(R!=="errorRed"||l);return g&&a&&Bg.has(R)?h:yr(g&&s?_:h,P,Ee(P),x)},"ink"),d=i((R,h,C)=>u(`text.${R}`,t.text[R],r.text[R],n.text[R],h,C),"text"),c=i((R,h,C,_)=>u(R,h,r[R],n[R],C,_),"token"),p=i(R=>s&&t[R]===r[R]?n[R]:t[R],"tint"),f=t.primary,m=Vt(f,Q),y=c("danger",t.danger,[...o,...Ll(t,t.badgeBgCritical)],Q);return {...t,onPrimary:m,onAccent:Vt(t.accent,Q),onDanger:oe(m,y)>=Q?m:Vt(y,Q),brandSoft:p("brandSoft"),brandSofter:p("brandSofter"),brandBorder:p("brandBorder"),borderHairlineGreen:p("borderHairlineGreen"),brandInk:c("brandInk",t.brandInk,o,Q),linkInk:c("linkInk",e.slots.link?.textColor??t.accent,Ko(t),Q),text:{...t.text,primary:d("primary",o,Q),secondary:d("secondary",o,Q),muted:d("muted",o,Q),metaCool:d("metaCool",o,Q),timestamp:d("timestamp",o,Q),placeholder:d("placeholder",Fl(t),gr)},danger:y,errorRed:c("errorRed",t.errorRed,Ml(t,t.badgeBgCritical),Q),warningStrong:c("warningStrong",t.warningStrong,Ml(t,t.badgeBgCaution),Q),composerBorder:c("composerBorder",t.composerBorder,Vg(t),gr),brandBorderStrong:c("brandBorderStrong",t.brandBorderStrong,Fl(t),gr)}}i(Nl,"guardInks");function Ul(e){let t=(e.brightness==="dark"?it:Ce).color;return e.color.brand===t.brand&&!Dl(e.color,t)}i(Ul,"everfurBrandOnPartnerGround");var Hg="#23272C",Vl=4.5,zg=.6,qo=.9,jg=.02,Wg="#FFFFFF",Gg="#111111";function Kg(e){return oe(e,Hg)>=Vl&&Math.max(oe(e,Wg),oe(e,Gg))>=Vl}i(Kg,"readsOnDark");function jl(e){let t=Y(e);if(t===null)return null;let{h:r,s:n,l:o}=Tl(t.r,t.g,t.b),s=Math.min(Math.max(o,zg),qo);for(let l=0;;l+=1){let u=s+l*jg;if(u>qo)break;let d=Wo({h:r,s:n,l:u}),c=Ke(d.r,d.g,d.b);if(Kg(c))return c}let a=Wo({h:r,s:n,l:qo});return Ke(a.r,a.g,a.b)}i(jl,"deriveDarkVariant");var qg=7,Bl=.05,$g="#000000",Hl="#FFFFFF";function Yg(e,t,r,n){let o=Ve(e,t);if(o===null)return r;if(oe(o,t)>=n)return o;let s=Y(o),a=Y(r);if(s===null||a===null)return r;for(let l=1;l<1/Bl;l+=1){let u=l*Bl,d=i((p,f)=>Math.round(p+(f-p)*u),"mix"),c=Ke(d(s.r,a.r),d(s.g,a.g),d(s.b,a.b));if(oe(c,t)>=n)return c}return r}i(Yg,"pushContrast");function Xg(e,t){let r=bt(e),n=r[0],o=zl(n);for(let s of r){let a=zl(s);(t?a>o:a<o)&&(n=s,o=a);}return n}i(Xg,"hardestGround");function zl(e){let t=Y(e);return t===null?0:yt(t)}i(zl,"luminanceOf");function st(e,t){return Ve(e,t)??X(e)??t}i(st,"solid");function Wl(e){let t=e.color,r=Ee(bt(t))===Hl,n=r?Hl:$g,o=Xg(t,r),s=i(l=>Yg(l,o,n,qg),"text"),a={...t,brandSoft:st(t.brandSoft,t.surface),brandSofter:st(t.brandSofter,t.surface),brandBorder:s(t.brandBorder),borderHairlineGreen:s(t.borderHairlineGreen),brandBorderStrong:s(t.brandBorderStrong),brandInk:s(t.brandInk),linkInk:s(t.linkInk),borderRingCream:s(t.borderRingCream),composerBorder:s(t.composerBorder),text:{primary:s(t.text.primary),secondary:s(t.text.secondary),muted:s(t.text.muted),placeholder:s(t.text.placeholder),onBrand:t.text.onBrand,metaCool:s(t.text.metaCool),timestamp:s(t.text.timestamp)},badgeBgPositive:st(t.badgeBgPositive,t.surface),badgeBgCaution:st(t.badgeBgCaution,t.surface),badgeBgCritical:st(t.badgeBgCritical,t.surface),badgeBgNeutral:st(t.badgeBgNeutral,t.surface),checkupCardLowRiskBg:st(t.checkupCardLowRiskBg,t.surface),checkupCardConcernBg:st(t.checkupCardConcernBg,t.surface)};return $e({...e,highContrast:true,color:a})}i(Wl,"deriveHighContrast");var Yo=Object.freeze({cream:.03,subtle:.07,ring:.16}),Qg=Yo.cream,Zg=Yo.subtle,Jg=Yo.ring,eh=10;function $o(e,t,r){let n=Y(e),o=Y(t);if(n===null||o===null)return null;let s=i((a,l)=>Math.round(a+(l-a)*r),"at");return Ke(s(n.r,o.r),s(n.g,o.g),s(n.b,o.b))}i($o,"mix");function Gl(e){if(e===null)return {};let t=Ee([e]),r=$o(e,t,Qg),n=$o(e,t,Zg),o=$o(e,t,Jg);return r===null||n===null||o===null?{}:{surface:e,background:e,chatGround:e,bubbleAssistant:e,surfaceCream:r,composerFill:r,surfaceSubtle:n,skeleton:n,borderRingCream:o}}i(Gl,"surfaceFamily");function Kl(e){if(e===null)return {};let t=Y(e);return t===null?{}:{danger:e,errorRed:e,badgeBgCritical:`rgba(${t.r},${t.g},${t.b},0.12)`}}i(Kl,"dangerFamily");function ql(e,t,r){if(e===null)return t;let n=e/r.type.size.body;if(n===1)return r.type.size;let o={};for(let[s,a]of Object.entries(r.type.size))o[s]=Math.max(eh,Math.round(a*n*10)/10);return o}i(ql,"typeSizesFor");function $l(e,t,r){if(e===null)return t;let n=e/r.space.xs,o=i(a=>Math.round(a*n),"s"),s=r.space;return {xs:o(s.xs),sm:o(s.sm),md:o(s.md),lg:o(s.lg),xl:o(s.xl),xxl:o(s.xxl)}}i($l,"spaceFor");function Yl(e,t){let r=e/t.radius.md,n=i(s=>Math.round(s*r),"s"),o=t.radius;return {tile:n(o.tile),xs:n(o.xs),sm:n(o.sm),md:n(o.md),lg:n(o.lg),xl:n(o.xl),pill:o.pill}}i(Yl,"radiiFor");var Xl=Object.freeze(["everfur","minimal","night"]),Ql=Object.freeze({everfur:Object.freeze({}),minimal:Object.freeze({colorPrimary:"#111111",colorAccent:"#111111",borderRadius:6}),night:Object.freeze({colorScheme:"dark"})}),br=Object.freeze({fontSizeBase:Object.freeze({min:12,max:20,default:14}),borderRadius:Object.freeze({min:0,max:32,default:14}),spacingUnit:Object.freeze({min:3,max:6,default:4})});function fn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(fn,"isRecord");function th(e){return typeof e=="string"&&Xl.includes(e.trim().toLowerCase())}i(th,"isPreset");function hr(e,t){let r=e[t];return r??void 0}i(hr,"present");var rh=16;function nh(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.length>rh)return;let t=/^(-?\d+(?:\.\d+)?)(?: ?px)?$/i.exec(e.trim());return t===null?void 0:Number(t[1])}i(nh,"parsePx");var oh=[["colorPrimary","primary_color"],["colorAccent","accent_color"],["colorBackground","background_color"],["colorText","text_color"]],ih=[["fontSizeBase","font_size_base"],["borderRadius","border_radius"],["spacingUnit","spacing_unit"]];function Xo(e){if(!fn(e))return null;let t=th(e.theme)?Ql[e.theme.trim().toLowerCase()]:{},r=fn(e.variables)?e.variables:{},n={...t};for(let[p,f]of Object.entries(r))f!=null&&(n[p]=f);let o={},s=hr(n,"colorScheme"),a=typeof s=="string"?s.trim().toLowerCase():null;(a==="light"||a==="dark"||a==="auto")&&(o.color_scheme=a);let l=a==="dark"?"_dark":"";for(let[p,f]of oh){let m=hr(n,p);m!==void 0&&(o[`${f}${l}`]=m);}let u=hr(n,"colorDanger");u!==void 0&&(o[`danger_color${l}`]=u);let d=hr(n,"fontFamily");typeof d=="string"&&d.trim().length>0&&(o.font_family=d.trim());for(let[p,f]of ih){let m=nh(hr(n,p));m!==void 0&&(o[f]=m);}let c=e.rules;if(fn(c)){let p={};for(let f of qe){let m=c[f];fn(m)&&(p[f]=m);}Object.keys(p).length>0&&(o.slots=p);}return Object.keys(o).length===0?null:Object.freeze(o)}i(Xo,"expandAppearance");var tu=Object.freeze(["display_name","logo_url","logo_url_dark","primary_color","accent_color","primary_color_dark","accent_color_dark","brightness","color_scheme","font_family","font_url","fonts","font_urls","chat_placeholder","surface_style","radius_scale","accessibility_max_font_scale","slots","background_color","background_color_dark","text_color","text_color_dark","danger_color","danger_color_dark","font_size_base","border_radius","spacing_unit"]),vr="slots.",ru=Object.freeze([1,2]);function yn(e){return Object.keys(e).every(t=>t==="schemaVersion"||(e[t]??null)===null)}i(yn,"isEmptyBranding");function nu(e){let t=e?.schemaVersion??null;return t===null||ru.includes(t)}i(nu,"isKnownBrandingSchema");function ou(e){return new Set(["hide_powered_by",...e?.lockedFields??[]])}i(ou,"lockedFieldsOf");function sh(e){return e==="hide_powered_by"||tu.includes(e)?true:e.startsWith(vr)&&qe.includes(e.slice(vr.length))}i(sh,"isThemeLockName");function Ye(e){if(e===null||typeof e!="object")return null;let t=e,r=Zl(t),n=Xo(z(t,"appearance")),o=n===null?r:ah(Zl(n),r);return yn(o)?null:Object.freeze(o)}i(Ye,"parseClientBranding");function ah(e,t){let r={...e};for(let[o,s]of Object.entries(t))s!=null&&(r[o]=s);let n=dn(e.slots??null,t.slots??null);return r.slots=Object.keys(n).length===0?null:n,r}i(ah,"overlayFlat");function Zl(e){return {displayName:vt(z(e,"display_name","displayName")),logoUrl:vt(z(e,"logo_url","logoUrl")),primaryColor:X(z(e,"primary_color","primaryColor")),accentColor:X(z(e,"accent_color","accentColor")),brightness:ch(z(e,"brightness","color_scheme","colorScheme")),fontFamily:vt(z(e,"font_family","fontFamily")),fontUrl:vt(z(e,"font_url","fontUrl")),fonts:Jl(z(e,"fonts")),fontUrls:Jl(z(e,"font_urls","fontUrls")),placeholder:vt(z(e,"chat_placeholder","placeholder","chatPlaceholder")),hidePoweredBy:lh(z(e,"hide_powered_by","hidePoweredBy")),primaryColorDark:X(z(e,"primary_color_dark","primaryColorDark")),accentColorDark:X(z(e,"accent_color_dark","accentColorDark")),surfaceStyle:eu(z(e,"surface_style","surfaceStyle"),uh),radiusScale:eu(z(e,"radius_scale","radiusScale"),dh),logoUrlDark:vt(z(e,"logo_url_dark","logoUrlDark")),slots:Pl(z(e,"slots")),accessibilityMaxFontScale:fh(z(e,"accessibility_max_font_scale","accessibilityMaxFontScale")),lockedFields:yh(z(e,"locked_fields","lockedFields")),schemaVersion:mh(z(e,"schema_version","schemaVersion")),backgroundColor:X(z(e,"background_color","backgroundColor")),backgroundColorDark:X(z(e,"background_color_dark","backgroundColorDark")),textColor:X(z(e,"text_color","textColor")),textColorDark:X(z(e,"text_color_dark","textColorDark")),dangerColor:X(z(e,"danger_color","dangerColor")),dangerColorDark:X(z(e,"danger_color_dark","dangerColorDark")),fontSizeBase:Qo(z(e,"font_size_base","fontSizeBase"),br.fontSizeBase),borderRadius:Qo(z(e,"border_radius","borderRadius"),br.borderRadius),spacingUnit:Qo(z(e,"spacing_unit","spacingUnit"),br.spacingUnit)}}i(Zl,"parseFlat");function Qo(e,t){let r=mn(typeof e=="string"?e.trim().replace(/px$/i,""):e);return r===null?null:Math.min(t.max,Math.max(t.min,r))}i(Qo,"parseClamped");function lh(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true")return true;if(t==="false")return false}return null}i(lh,"parseBool");function z(e,...t){for(let r of t)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];if(n!==void 0)return n}}i(z,"pick");function vt(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(vt,"parseNonEmptyString");var Er=["regular","medium","bold","mono","monoMedium","monoBold"];function Jl(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let n of Er){let o=vt(z(t,n));o!==null&&(r[n]=o);}return Object.keys(r).length===0?null:Object.freeze(r)}i(Jl,"parseFaceMap");var uh=["white","cream","subtle"],dh=["sharp","default","round"];function eu(e,t){if(typeof e!="string")return null;let r=e.trim().toLowerCase();return t.includes(r)?r:null}i(eu,"parseEnum");function ch(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="light"||t==="dark"||t==="auto"?t:null}i(ch,"parseBrightness");function mn(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)&&(typeof e!="string"||e.trim().length>0)?t:null}i(mn,"parseNumber");var ph=1,iu=3.1;function fh(e){let t=mn(e);return t===null?null:t<=0?0:Math.min(iu,Math.max(ph,t))}i(fh,"parseMaxFontScale");function mh(e){if(e==null)return null;let t=mn(e);return t!==null&&Number.isInteger(t)&&t>=1?t:0}i(mh,"parseSchemaVersion");function Zo(e){let t=e.trim();return t.startsWith(vr)?t:t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}i(Zo,"toWireName");function yh(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="string")continue;let n=Zo(r);sh(n)&&!t.includes(n)&&t.push(n);}return t.length===0?null:Object.freeze(t)}i(yh,"parseLockedFields");function Jo(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}i(Jo,"hardenHttpsUrl");function su(e,t){if(t===null||yn(t))return e;let r=(t.brightness==="light"||t.brightness==="dark")&&t.brightness!==e.brightness?t.brightness==="dark"?it:Ce:e,n=r.brightness==="dark"?it:Ce,o=r.brightness==="dark",s=o?t.primaryColorDark??ei(t.primaryColor):t.primaryColor,a=o?t.accentColorDark??ei(t.accentColor):t.accentColor,l=s??r.color.primary,u=a??r.color.accent,d=s!==null&&Eh(t,l,n,o),c=d?n.color.primary:l,p=s!==null&&!d?Y(c):null,f=i(P=>Math.round(P+(255-P)*.4),"lift"),m=p!==null?{brand:c,bubbleUser:c,brandInk:c,text:{...r.color.text,secondary:c},brandSoft:`rgba(${p.r}, ${p.g}, ${p.b}, 0.10)`,brandSofter:`rgba(${p.r}, ${p.g}, ${p.b}, 0.15)`,brandBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.20)`,borderHairlineGreen:`rgba(${p.r}, ${p.g}, ${p.b}, 0.28)`,brandBorderStrong:`rgba(${p.r}, ${p.g}, ${p.b}, 0.55)`,composerBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.75)`,accentEdge:`rgb(${f(p.r)}, ${f(p.g)}, ${f(p.b)})`}:d?Ch(n,r.color.text):{},y=(o?t.backgroundColorDark:t.backgroundColor)??null,R=Gl(y),h={...r.color,...R},C=(o?t.textColorDark:t.textColor)??null,_={brightness:r.brightness,highContrast:r.highContrast,meta:{displayName:t.displayName??r.meta.displayName,logoUrl:(o?t.logoUrlDark??t.logoUrl:t.logoUrl)??r.meta.logoUrl,placeholder:t.placeholder??r.meta.placeholder,hidePoweredBy:t.hidePoweredBy??r.meta.hidePoweredBy},color:{...r.color,...m,...R,...Kl((o?t.dangerColorDark??ei(t.dangerColor??null):t.dangerColor)??null),...C!==null?{text:{...m.text??r.color.text,primary:C}}:{},...vh(t.surfaceStyle??null,h),primary:c,accent:u,onPrimary:r.color.onPrimary,onAccent:r.color.onAccent},space:$l(t.spacingUnit??null,r.space,n),radius:t.borderRadius!=null?Yl(t.borderRadius,n):Sh(t.radiusScale??null,r.radius,n),type:{...r.type,...bh(r.type,t),size:ql(t.fontSizeBase??null,r.type.size,n),maxScale:t.accessibilityMaxFontScale??r.type.maxScale},motion:r.motion,slots:dn(r.slots,t.slots??null)};return $e(_)}i(su,"withServerBranding");var gh={regular:["regular"],medium:["medium","regular"],bold:["bold","medium","regular"],mono:["mono"],monoMedium:["monoMedium","mono"],monoBold:["monoBold","monoMedium","mono"]},hh=[["regular","medium","bold"],["mono","monoMedium","monoBold"]];function ti(e){return e==="mono"||e==="monoMedium"||e==="monoBold"}i(ti,"isMonoFace");function bh(e,t){let r=t.fonts??{},n=t.fontUrls??{},o={...e.families},s={...e.namedFaces},a={...e.fontUrls};for(let l of Er){let u=gh[l].map(p=>r[p]).find(p=>p!==void 0),d=ti(l)?null:t.fontFamily;u!==void 0?(o[l]=u,s[l]=true):d!==null&&(o[l]=d,s[l]=false);let c=n[l]??(l==="regular"?t.fontUrl:null)??null;c!==null?a[l]=c:u!==void 0&&delete a[l];}for(let l of hh)for(let u of l)s[u]&&l.some(d=>d!==u&&o[d]===o[u])&&(s[u]=false);return {family:o.regular,mono:o.mono,fontUrl:a.regular??null,families:o,namedFaces:s,fontUrls:a}}i(bh,"mergeFaces");function ei(e){return e===null?null:jl(e)}i(ei,"darkVariantOf");function vh(e,t){if(e===null)return {};let r=t;return {chatGround:e==="white"?r.surface:e==="subtle"?r.surfaceSubtle:r.surfaceCream}}i(vh,"surfaceOf");function au(e,t){return e==null?false:X(e)===X(t)}i(au,"sameColor");function Eh(e,t,r,n){return au(t,r.color.primary)?true:n&&(e.primaryColorDark??null)===null&&au(e.primaryColor,Ce.color.primary)}i(Eh,"isCompiledPrimary");function Ch(e,t){let r=e.color;return {text:{...t,secondary:r.text.secondary},brand:r.brand,bubbleUser:r.bubbleUser,brandInk:r.brandInk,brandSoft:r.brandSoft,brandSofter:r.brandSofter,brandBorder:r.brandBorder,borderHairlineGreen:r.borderHairlineGreen,brandBorderStrong:r.brandBorderStrong,composerBorder:r.composerBorder,accentEdge:r.accentEdge}}i(Ch,"compiledBrandFamily");var Rh={sharp:.5,default:1,round:1.5};function Sh(e,t,r){if(e===null)return t;let n=Rh[e],o=r.radius,s=i(a=>Math.round(a*n),"s");return {tile:s(o.tile),xs:s(o.xs),sm:s(o.sm),md:s(o.md),lg:s(o.lg),xl:s(o.xl),pill:o.pill}}i(Sh,"radiusOf");var Th="Everfur",Ph=.5;function ri(e){let t=e?.branding??null,r=nu(t)?t:null,n=Ih(e?.clientOverride??null,ou(r)),o=e?.colorScheme==="dark"?"dark":"light",s=n?.brightness??r?.brightness??"light",u=su((s==="auto"?o:s)==="dark"?it:Ce,lu(r)),d=su(u,lu(n));return Vh(d,e)}i(ri,"resolveTheme");function kh(e,t,r){return ri({...r,branding:Ye(t),clientOverride:Ye(e)})}i(kh,"previewTheme");function xh(e){return e==="placeholder"?"chat_placeholder":Zo(e)}i(xh,"wireNameOf");var _h={brightness:["color_scheme"],fontUrl:["font_family"],fonts:["font_family"],fontUrls:["font_url","font_family","fonts"],primaryColorDark:["primary_color"],accentColorDark:["accent_color"],logoUrlDark:["logo_url"],backgroundColorDark:["background_color"],textColorDark:["text_color"],dangerColorDark:["danger_color"],borderRadius:["radius_scale"],radiusScale:["border_radius"]};function wh(e,t){return t.has(xh(e))?true:(_h[e]??[]).some(r=>t.has(r))}i(wh,"isLocked");function Ih(e,t){if(e===null)return null;let r=false,n={...e};for(let a of Object.keys(e))(e[a]??null)!==null&&(wh(a,t)||a==="lockedFields")&&(n[a]=null,r=true);let o=n.slots??null;if(o!==null){let a={},l=false;for(let u of qe){let d=o[u];d!==void 0&&(t.has(`${vr}${u}`)?l=true:a[u]=d);}l&&(n.slots=Object.keys(a).length===0?null:Object.freeze(a),r=true);}if(!r)return e;let s=Object.freeze(n);return yn(s)?null:s}i(Ih,"withoutFields");function lu(e){return e===null||e.brightness===null?e:Object.freeze({...e,brightness:null})}i(lu,"withoutBrightness");function Ah(e,t){if(t===1)return e;let r={};for(let[n,o]of Object.entries(e))r[n]=Math.round(o*t*10)/10;return r}i(Ah,"scaledSizes");function Oh(e){return e===void 0||!Number.isFinite(e)?1:Math.max(Ph,e)}i(Oh,"effectiveScale");var uu=["content","heading","control","compact","badge"];function Fh(e){if(!(e>0))return pn;let t={};for(let r of uu){let n=pn[r];t[r]=n===0?0:Math.min(n,e);}return t}i(Fh,"tierCaps");function Mh(e,t){return t>0?Math.min(e,t):e}i(Mh,"capped");function Lh(e,t,r,n){let o={};for(let s of uu)o[s]=n?Ah(e,Mh(t,r[s])):e;return o}i(Lh,"sizesByTier");function Dh(e){return {composerInput:[e.composerFill],sendButton:[e.composerFill],userBubble:[e.bubbleUser],assistantBubble:[e.chatGround,e.surfaceCream],vetBubble:[e.bubbleVet],recordCard:[e.surface],vetVisitButton:[e.primary],primaryButton:[e.brand],link:Ko(e)}}i(Dh,"slotGrounds");function Nh(e,t){try{let r=e(t);return r===!0||r===!1?r:null}catch{return null}}i(Nh,"registration");function Uh(e,t){let r=t?.isFontRegistered,n=t?.platformMonoFamily?.trim()||null;if(r===void 0&&n===null)return {family:e.family,mono:e.mono,families:e.families,namedFaces:e.namedFaces};let o={...e.families},s={...e.namedFaces};for(let a of Er)!(o[a]===gt||o[a]===Be)&&r!==void 0&&Nh(r,o[a])===false&&(o[a]=ti(a)?Be:gt,s[a]=false),n!==null&&ti(a)&&o[a]===Be&&(o[a]=n);return {family:o.regular,mono:o.mono,families:o,namedFaces:s}}i(Uh,"platformFaces");function Vh(e,t){let r=e.meta.displayName.trim().length===0?Th:e.meta.displayName,n=Jo(e.meta.logoUrl),o={};for(let y of Er){let R=e.type.fontUrls[y];R!==void 0&&(o[y]=Jo(R));}let s=o.regular??null,l=t?.reducedMotion===true?{duration:{instant:0,fast:0,normal:0,slow:0},spring:{gentle:{damping:100,stiffness:1e3}},easing:e.motion.easing,reducedMotion:true}:e.motion,u=Number.isFinite(e.type.maxScale)?e.type.maxScale:Go,d=Oh(t?.textScale),c=Fh(u),p=Lh(e.type.size,d,c,t?.scaleTypeSizes===true),f=Nl(e),m={brightness:e.brightness,highContrast:false,meta:{displayName:r,logoUrl:n,placeholder:e.meta.placeholder,hidePoweredBy:e.meta.hidePoweredBy},color:f,space:e.space,radius:e.radius,type:{...e.type,...Uh(e.type,t),fontUrl:s,fontUrls:o,size:p.content,tierSizes:p,scale:d,maxScale:u,scaleCaps:c},motion:l,slots:kl(e.slots,Dh(f))};return t?.highContrast===true?Wl($e(m)):$e(m)}i(Vh,"finalize");var du="/widget/v1/entitlements",Bh=304,Hh=Object.freeze({kind:"notModified"});async function pu(e,t={},r=Ae({auth:e})){let n=await r.send("entitlements.fetch",jh(t));return n.ok?Wh(n.value):n.error.httpStatus===Bh?Hh:{kind:"failed",error:n.error}}i(pu,"fetchEntitlements");var zh=64;function jh(e){let t={};return ni(e.cachedRevision)&&(t["if-none-match"]=`"${e.cachedRevision}"`),e.region&&e.region.length<=zh?{method:"GET",path:du,headers:t,query:{region:e.region}}:{method:"GET",path:du,headers:t}}i(jh,"buildRequest");function Wh(e){if(e===null||typeof e!="object"||!ni(e.revision))return cu();let t=typeof e.region=="string"?e.region:"",r=ni(e.ttl_seconds)?e.ttl_seconds:0;return Object.freeze({kind:"updated",revision:e.revision,region:t,ttlSeconds:r,decisions:Kh(e.capabilities),branding:Gh(e),livemode:e.livemode!==false})}i(Wh,"parseUpdated");function Gh(e){let t=Ye(e.branding);if(t!==null)return t;let r=e.render_hints;if(r!==null&&typeof r=="object"){let n=Ye(r.branding);return n!==null?n:Ye(r)}return null}i(Gh,"parseBranding");function Kh(e){if(e===null||typeof e!="object")return Object.freeze([]);let t=[];for(let[r,n]of Object.entries(e))qh(n)&&t.push(Object.freeze({resource:r,granted:true}));return Object.freeze(t)}i(Kh,"mapCapabilities");function qh(e){return typeof e=="object"&&e!==null&&e.enabled===true}i(qh,"isEnabled");function cu(){return {kind:"failed",error:D("internalError",{retryable:true,wireMessage:"malformed entitlements response"})}}i(cu,"malformed");function ni(e){return typeof e=="number"&&Number.isFinite(e)}i(ni,"isFiniteNumber");var $h=30;function fu(e){let t=e.scheduler??Yh,r=e.resolve??pu,n=Math.max(1,e.floorSeconds??$h),o=e.rng??Math.random,s=i(()=>n+o()*n,"jitteredFloorSeconds"),a=false,l=false,u=null,d=null,c=n,p=0,f=i(()=>{u!==null&&(t.clear(u),u=null);},"clearTimer"),m=i(C=>{l||!a||(c=Math.max(n,C),u=t.set(()=>{u=null,h();},c*1e3));},"schedule"),y=null,R=i(async()=>{if(l)return null;let C=p;e.onFetch?.();let _=e.region?{cachedRevision:d,region:e.region}:{cachedRevision:d},P;try{P=await r(e.authFor(),_);}catch(x){return e.telemetry?.track("sdk.entitlements.poll_error",{reason:Xh(x)}),!l&&C===p&&(e.onSettled?.(),m(s())),null}if(l||C!==p)return null;switch(P.kind){case "updated":d=P.revision,e.update(P.decisions,P.branding??null,P.livemode!==false),m(P.ttlSeconds);break;case "notModified":m(c);break;case "failed":e.telemetry?.track("sdk.entitlements.poll_failed",{code:P.error.code}),m(s());break;default:m(s());}return e.onSettled?.(),P},"tick"),h=i(()=>{let C=R().finally(()=>{y===C&&(y=null);});return y=C,C},"run");return {start(){a||l||(a=true,h());},prime(){return l?Promise.resolve(null):y??h()},stop(){l||(l=true,p++,f());},refresh(){l||!a||(p++,d=null,f(),h());}}}i(fu,"createEntitlementPoller");var Yh={set(e,t){let r=setTimeout(e,t);return r.unref?.(),r},clear(e){clearTimeout(e);}};function Xh(e){return e instanceof Error?e.message:"poll failed"}i(Xh,"describe");var mu="everfur.notifications.device";var Qh=3e3,yu=Object.freeze([mu]);function gu(e){let{leaving:t,identity:r,hooks:n,telemetry:o}=e;if(t===null||r===null||n.size===0)return null;let s=Object.freeze({userRef:t.userRef,auth:e.graceAuth()}),a=[...n].map(d=>{try{return Promise.resolve(d(s))}catch(c){return Promise.reject(c)}}),l=i((d,c)=>{try{o.track("sdk.logout.hookFailed",{reason:d,count:c,totalCount:a.length});}catch{}},"report"),u=Promise.allSettled(a).then(d=>{let c=d.filter(p=>p.status==="rejected").length;c>0&&l("failed",c);});return new Promise(d=>{let c=false,p=i(()=>{c||(c=true,clearTimeout(f),d());},"finish"),f=setTimeout(()=>{c||l("timeout",a.length),p();},Qh);u.then(p,p);})}i(gu,"startBeforeLogoutHooks");function hu(e){let{leaving:t,identity:r,transport:n,sessionId:o}=e,s=r.currentToken();s.catch(()=>{});let a={userRef:t.userRef,currentToken:i(()=>s,"currentToken"),hasToken:i(()=>true,"hasToken"),clear:i(()=>{},"clear")};return {mode:"personalized",transport:n,identity:a,userRef:t.userRef,sessionId:o}}i(hu,"graceAuth");async function bu(e,t){if(yu.length===0)return;let r=await Promise.allSettled(yu.map(o=>e.removeItem(o))),n=r.filter(o=>o.status==="rejected").length;n>0&&t.track("sdk.logout.sweepPartialFailure",{failedCount:n,totalCount:r.length});}i(bu,"sweepPerUserKv");function Zh(){return Object.freeze([Object.freeze({resource:"chat.message.create",granted:true})])}i(Zh,"compiledDefaultDecisions");function oi(e=Zh){let t=new Set,r=Object.freeze({decisions:e(),isPending:false,branding:null}),n=i(()=>{for(let o of t)o();},"emit");return {subscribe(o){return t.add(o),()=>{t.delete(o);}},getSnapshot(){return r},set(o){r=Object.freeze({decisions:Object.freeze([...o.decisions]),isPending:o.isPending,branding:o.branding??null,...o.livemode===false?{livemode:false}:{}}),n();},reset(){r=Object.freeze({decisions:e(),isPending:false,branding:null}),n();},setPending(o){r.isPending!==o&&(r=Object.freeze({...r,isPending:o}),n());}}}i(oi,"createEntitlementStore");function ii(e){return D("validationFailed",{retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`})}i(ii,"notConfiguredError");function vu(e,t){let r={publishableKey:e.publishableKey,...e.apiBaseUrl!==void 0?{apiBaseUrl:e.apiBaseUrl}:{},...e.contractVersion!==void 0?{contractVersion:e.contractVersion}:{},...e.debug!==void 0?{debug:e.debug}:{}};return Qs(r,t===void 0?void 0:{platform:t})}i(vu,"tryResolveClient");function Eu(e){return Object.freeze({track(t,r){try{e.track(t,r);}catch{}},trackExpectedFailure(t,r){try{e.trackExpectedFailure(t,r);}catch{}}})}i(Eu,"guardTelemetry");var Jh=Object.freeze({"react-native":"If the value is set in your environment, note that babel-preset-expo inlines only EXPO_PUBLIC_* variables into a release bundle.",web:`If the value is set in your environment, note that a browser bundle does not expose ${Yr} to the SDK at run time (bundlers inline only the variables your own code names), so pass apiBaseUrl in config.`});function Cu(e,t,r=ao){try{t.trackExpectedFailure("sdk.config.invalid",{reason:e.reason});}catch{}globalThis.console?.error?.(`[everfur] SDK disabled: ${e.message}
12
- [everfur] Every Everfur capability will render its off-state until this is fixed. `+Jh[r]);}i(Cu,"reportConfigFailure");function si(e){return Object.freeze({request(){return Promise.resolve(E(ii(e)))},stream(t,r){let n=fe({code:"sdk_not_configured",retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`,synthesized:true,lastEventId:null});return {async*[Symbol.asyncIterator](){r.aborted||(yield n);}}}})}i(si,"refusingTransport");function Ru(){let e=new Map;return {async getItem(t){return e.get(t)??null},async setItem(t,r){e.set(t,r);},async removeItem(t){e.delete(t);},async keys(t){return [...e.keys()].filter(r=>r.startsWith(t))}}}i(Ru,"createInMemoryKv");var Su=Object.freeze({clearMemoryCache(){},clearDiskCache(){}});function ku(e,t){return new li(e,t)}i(ku,"createEverfurRuntime");var eb=6e4,ui=class ui{constructor(t,r){this.sessionId=io();this.entries=new Map;this.destroyers=new Map;this.epoch=0;this.disposed=false;this.verdictSettled=false;this.refreshTimer=null;this.bootstraps=new WeakMap;this.prepared=null;this.beforeLogoutHooks=new Set;this.pendingBeforeLogout=null;this.leavingSessionId=null;let n=t.config;if(n.secureStore!==void 0&&n.secureStore.isAvailable===true)throw new ee("invalid-argument","config.secureStore is not yet consumable: SDK token persistence is unimplemented. Omit secureStore to keep memory-only tokens (SPEC-10 \xA75.3).");this.telemetry=n.telemetry?Eu(n.telemetry):qr;let o=typeof n?.publishableKey=="string"?n.publishableKey.trim():"",s=lo(n?.publishableKey),a=n.transport!==void 0,l,u=typeof n.apiBaseUrl=="string"&&n.apiBaseUrl.trim().length>0?n.apiBaseUrl.trim():null;if(s!==null)l=si(s);else if(n.transport!==void 0)l=n.transport;else {let c=vu(n,r?.platform);c.ok?(u=c.config.apiBaseUrl,l=na({config:c.config,...r?.eventSourceFactory?{eventSourceFactory:r.eventSourceFactory}:{}})):(s=c.failure,l=si(c.failure));}this.configFailure=s,this.publishableKey=s===null?o:"",this.transport=l,s!==null&&Cu(s,this.telemetry,r?.platform),this.errorPolicy=n.errorPolicy,this.camera=n.camera??Ns,this.upload=n.upload??Ca,this.uploadTransport=n.uploadTransport??wo,this.imageCache=n.imageCache??Su,this.kv=n.storage??Ru(),this.currentUser=t.user??null,this.identity=this.buildIdentity(t.user??null),this.activePet=t.activePet,this.store=s===null?oi():oi(()=>hl("sdk_config",Mt("accessDenied"))),this.services={authFor:i(c=>this.buildAuth(c),"authFor"),telemetry:this.telemetry,errorPolicy:this.errorPolicy,camera:this.camera,upload:this.upload,uploadTransport:this.uploadTransport,imageCache:this.imageCache,kv:this.kv,apiBaseUrl:u},this.registry={services:this.services,acquireChat:i(c=>this.acquireInternal("chat",ai(c),()=>this.buildChatController(c),Tu),"acquireChat"),releaseChat:i(c=>this.releaseInternal(c),"releaseChat"),peekChat:i(c=>this.entries.get(`${this.epoch}|chat|${ai(c)}`)?.controller??null,"peekChat"),acquire:i((c,p,f,m)=>this.acquireInternal(c,p,f,m),"acquire"),release:i(c=>this.releaseInternal(c),"release")},this.entitlements=this.store;let d=s===null&&(r?.startEntitlementPolling??!a);this.poller=s===null?this.buildPoller(r?.pollScheduler):null,d&&this.poller?.start();}get isDisposed(){return this.disposed}get scopeEpoch(){return this.epoch}buildIdentity(t){if(t===null)return null;let r=Gs(t.userRef,t.getToken,n=>this.armTokenRefresh(r,n));return r}armTokenRefresh(t,r){if(this.clearTokenRefresh(),r===null||this.disposed||t!==this.identity)return;let n=r-Date.now();if(n<=0)return;let o=Math.max(n-eb,n/2);this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,!(this.disposed||t!==this.identity)&&t.currentToken({forceRefresh:true}).catch(()=>{});},o),this.refreshTimer.unref?.();}clearTokenRefresh(){this.refreshTimer!==null&&clearTimeout(this.refreshTimer),this.refreshTimer=null;}buildPoller(t){return fu({authFor:i(()=>this.buildAuth(this.currentUser?.userRef??null),"authFor"),update:i((r,n,o)=>this.updateEntitlements({decisions:r,isPending:false,branding:n,...o===false?{livemode:o}:{}}),"update"),onFetch:i(()=>{this.verdictSettled||this.store.setPending(true);},"onFetch"),onSettled:i(()=>{this.verdictSettled=true,this.store.setPending(false);},"onSettled"),telemetry:this.telemetry,...t?{scheduler:t}:{}})}acquireInternal(t,r,n,o,s=false){let a=`${this.epoch}|${t}|${r}`,l=this.entries.get(a);if(l)return s||(l.warm?l.warm=false:l.refCount+=1),l.controller;let u=n();return this.entries.set(a,{controller:u,refCount:1,warm:s}),this.destroyers.set(u,o),u}releaseInternal(t){for(let[r,n]of this.entries)if(n.controller===t){n.refCount-=1,n.refCount<=0&&(this.runDestroyer(t),this.entries.delete(r));return}}runDestroyer(t){let r=this.destroyers.get(t);this.destroyers.delete(t),r&&r(t);}buildChatController(t){let r=Ba({auth:this.buildAuth(t.userRef),telemetry:this.telemetry,...this.errorPolicy?{errorPolicy:this.errorPolicy}:{},initialConversationId:t.conversationId,petRef:t.petRef});return this.runBootstrap(r,t),r}runBootstrap(t,r){let n={};r.petRef!==null&&(n.petRef=r.petRef),r.conversationId!==null&&(n.resumeConversationId=r.conversationId);let o=ja(n,{controller:t});return o.then(s=>t.adoptPrompts(s.suggestedPrompts)).catch(()=>{}),this.bootstraps.set(t,o),o}buildAuth(t){return this.identity!==null&&this.currentUser!==null?{mode:"personalized",transport:this.transport,identity:this.identity,userRef:this.currentUser.userRef,sessionId:this.sessionId}:{mode:"anonymous",transport:this.transport,publishableKey:this.publishableKey,userRef:this.currentUser===null?null:t,sessionId:this.sessionId}}setUser(t){if(this.disposed)return;let r=t?.userRef??null,n=this.currentUser?.userRef??null;if(r===n){this.currentUser=t,t&&this.identity===null&&(this.identity=this.buildIdentity(t));return}this.pendingBeforeLogout=this.beforeLogoutSettlement(),this.identity?.clear(),this.clearTokenRefresh(),this.currentUser=t,this.identity=this.buildIdentity(t),this.rescopeAll();}async logout(){if(this.disposed)return;let t=this.currentUser===null;this.leavingSessionId=this.sessionId,this.sessionId=io(),this.setUser(null),this.leavingSessionId=null,t&&this.rescopeAll();let r=this.pendingBeforeLogout;this.pendingBeforeLogout=null,r!==null&&await r,await bu(this.kv,this.telemetry);}onBeforeLogout(t){return this.disposed?()=>{}:(this.beforeLogoutHooks.add(t),()=>{this.beforeLogoutHooks.delete(t);})}beforeLogoutSettlement(){let t=this.currentUser,r=this.identity;return gu({leaving:t,identity:r,hooks:this.beforeLogoutHooks,telemetry:this.telemetry,graceAuth:i(()=>hu({leaving:t,identity:r,transport:this.transport,sessionId:this.leavingSessionId??this.sessionId}),"graceAuth")})}async registerPet(t,r){return this.withPets("registerPet",n=>r===void 0?n.registerPet(t):n.registerPet(t,r))}updatePet(t,r){return this.withPets("updatePet",n=>n.updatePet(t,r))}deletePet(t){return this.withPets("deletePet",r=>r.deletePet(t))}eraseUserData(){return this.withPets("eraseUserData",t=>t.eraseUserData())}async withPets(t,r){return this.disposed?E(Pu(t)):r(ot(this.buildAuth(this.currentUser?.userRef??null)))}prepare(t){let r=t?.petRef??null,n=`${this.epoch}|${this.currentUser?.userRef??""}|${r??""}`,o=this.prepared;if(o!==null&&o.key===n&&(o.result===null||o.result.status==="ready"))return o.promise;let s={key:n,result:null,promise:this.runPrepare(r).then(a=>(s.result=a,a))};return this.prepared=s,s.promise}async runPrepare(t){let r=Date.now(),n=this.configFailure,o=this.disposed?Pu("prepare"):n===null?null:ii(n),s=this.identity,[a,l,u]=await Promise.all([o?E(o):s===null?L(void 0):s.currentToken().then(()=>L(void 0),()=>E(D("authRejected",{retryable:false}))),o?E(o):this.primeEntitlements(),t===null?void 0:o?E(o):this.primeChat(t)]),d=a.ok?l.ok&&(u?.ok??true)?"ready":"partial":"failed",c=Date.now()-r;try{this.telemetry.track("sdk.prepare.timing",{durationMs:c,status:d});}catch{}return Object.freeze({status:d,durationMs:c,session:a,entitlements:l,...u?{chat:u}:{}})}async primeEntitlements(){let t=await this.poller?.prime();return t?t.kind==="failed"?E(t.error):L(void 0):E(D("internalError",{retryable:true}))}async primeChat(t){let r={userRef:this.currentUser?.userRef??null,petRef:t,conversationId:null},n=this.acquireInternal("chat",ai(r),()=>this.buildChatController(r),Tu,true),o=await this.bootstraps.get(n);return o?.cause&&n.getSnapshot().conversationId===null&&(o=await this.runBootstrap(n,r)),o?.cause?E(o.cause):L(void 0)}setActivePet(t){if(this.disposed)return;let r=t??null;r!==this.activePet&&(this.activePet=r,this.rescopeAll());}updateEntitlements(t){this.disposed||this.configFailure===null&&this.store.set(t);}open(t){this.telemetry.track("sdk.open",{capability:t});}dispose(){this.disposed||(this.disposed=true,this.epoch+=1,this.poller?.stop(),this.identity?.clear(),this.clearTokenRefresh(),this.disposeAllControllers());}rescopeAll(){this.epoch+=1,this.disposeAllControllers(),this.store.reset(),this.verdictSettled=false,this.poller?.refresh();}disposeAllControllers(){for(let t of this.entries.values())this.runDestroyer(t.controller);this.entries.clear(),this.destroyers.clear();}};i(ui,"EverfurRuntimeImpl");var li=ui;function ai(e){return `${e.userRef??""}|${e.petRef??""}|${e.conversationId??""}`}i(ai,"chatScopeKey");function Tu(e){e.dispose();}i(Tu,"disposeChat");function Pu(e){return D("validationFailed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}i(Pu,"disposedError");var xu=Symbol.for("@everfur/sdk#EverfurContext@v1"),_u=globalThis,gn=_u[xu]??(_u[xu]=react.createContext(null));gn.displayName??="EverfurContext";function Z(){let e=react.useContext(gn);if(e===null)throw new ee("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(Z,"useEverfurContext");function wu(){return Z().handle}i(wu,"useEverfur");var Iu=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Au=globalThis,Cr=Au[Iu]??(Au[Iu]=react.createContext(Ce));Cr.displayName??="EverfurThemeContext";function F(){return react.useContext(Cr)}i(F,"useEverfurTheme");function hn(e){let{runtime:t}=Z(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot),o=e.seams.useColorScheme(),s=e.seams.useReducedMotion(),a=e.seams.useTextScale(),l=e.seams.useHighContrast(),u=e.seams.scaleTypeSizes,d=e.seams.platformMonoFamily?.(),c=e.seams.isFontRegistered,p=e.clientTheme?ab(e.clientTheme):"",f=react.useMemo(()=>e.clientTheme?Ye(e.clientTheme):null,[p]),m=n.branding??null,y=react.useMemo(()=>ri({branding:m,clientOverride:f,colorScheme:o,reducedMotion:s,textScale:a,scaleTypeSizes:u,highContrast:l,...d===void 0?{}:{platformMonoFamily:d},...c===void 0?{}:{isFontRegistered:c}}),[m,f,o,s,a,u,l,d,c]);return e.seams.useResolvedTheme?.(y),react.createElement(Cr.Provider,{value:y},e.children)}i(hn,"EverfurThemeProviderCore");function ab(e){try{return JSON.stringify(e)}catch{return Object.keys(e).join("&")}}i(ab,"stableKey");function Du(e){let{config:t,user:r,activePet:n,theme:o,warmUp:s,children:a,seams:l}=e,u=`${t?.publishableKey??""}|${t?.apiBaseUrl??""}|${t?.contractVersion??""}`,d=react.useRef(null),c=react.useRef(null),[p,f]=react.useReducer(k=>k+1,0),m=react.useRef(null),y=react.useRef(void 0),R=r?.userRef??null;y.current!==R&&(y.current!==void 0&&(m.current=null),y.current=R);let h=m.current!==null?m.current.user:r??null,C=react.useRef(null),_=react.useRef(void 0),P=n??null;_.current!==P&&(_.current!==void 0&&(C.current=null),_.current=P);let x=C.current!==null?C.current.pet:n??null;(d.current===null||d.current.key!==u||d.current.runtime.isDisposed)&&(d.current!==null&&!d.current.runtime.isDisposed&&(c.current=d.current.runtime),d.current={key:u,runtime:ku({config:l.withDefaults?l.withDefaults(t):t,user:h,activePet:x,theme:o??null},{platform:l.platform,...l.eventSourceFactory?{eventSourceFactory:l.eventSourceFactory}:{}})});let g=d.current.runtime,w=react.useRef(null);react.useEffect(()=>{let k=d.current?.runtime;k===void 0||!k.isDisposed||w.current!==k&&(w.current=k,f());}),react.useEffect(()=>{let k=c.current;k!==null&&(c.current=null,k.dispose());});let O=h?.userRef??null;react.useLayoutEffect(()=>{g.setUser(h);},[g,O]),react.useLayoutEffect(()=>{g.setActivePet(x);},[g,x]),react.useEffect(()=>()=>g.dispose(),[g]),react.useEffect(()=>{s==="onMount"&&g.prepare(x===null?{}:{petRef:x});},[g,s,O,x]);let M=react.useMemo(()=>({setUser:i(k=>{m.current={user:k},g.setUser(k),f();},"setUser"),setActivePet:i(k=>{C.current={pet:k},g.setActivePet(k),f();},"setActivePet"),open:i(k=>g.open(k),"open"),prepare:i(k=>g.prepare(k),"prepare"),registerPet:i((k,V)=>g.registerPet(k,V),"registerPet"),updatePet:i((k,V)=>g.updatePet(k,V),"updatePet"),deletePet:i(k=>g.deletePet(k),"deletePet"),eraseUserData:i(()=>g.eraseUserData(),"eraseUserData"),logout:i(()=>{m.current={user:null};let k=g.logout();return f(),k},"logout")}),[g,f]),I=react.useMemo(()=>({runtime:g,handle:M,userRef:O,activePet:x,scopeEpoch:g.scopeEpoch}),[g,M,O,x,p]),v=react.createElement(hn,{clientTheme:o??null,seams:l.theme,children:a});return react.createElement(gn.Provider,{value:I},l.wrap?l.wrap(v):v)}i(Du,"EverfurProviderCore");var db=2;function cb(e,t){let r=e?._xhr;if(!r||typeof r.getResponseHeader!="function"||typeof r.readyState=="number"&&r.readyState<db)return null;let n;try{n=r.getResponseHeader(t);}catch{return null}return typeof n=="string"&&n.length>0?n:null}i(cb,"readEventSourceResponseHeader");function Nu(){let e=ub__default.default;return (t,r)=>{let n=new e(t,{method:r.method,headers:r.headers,pollingInterval:r.pollingInterval??0,...r.body!==void 0?{body:r.body}:{}});return Object.assign(n,{getResponseHeader:i(o=>cb(n,o),"getResponseHeader")})}}i(Nu,"createRnEventSourceFactory");function yb(){let e=reactNative.useColorScheme();return e==="dark"?"dark":e==="light"?"light":null}i(yb,"useRnColorScheme");function gb(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(gb,"isThenable");function hb(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,n=reactNative.AccessibilityInfo?.isReduceMotionEnabled;if(typeof n=="function"){let s=n.call(reactNative.AccessibilityInfo);s!=null&&typeof s.then=="function"&&s.then(a=>{r&&t(a===true);},()=>{});}let o=reactNative.AccessibilityInfo?.addEventListener?.("reduceMotionChanged",s=>t(s===true));return ()=>{r=false,o?.remove?.();}},[]),e}i(hb,"useRnReducedMotion");function Bu(){let e=reactNative.PixelRatio?.getFontScale;if(typeof e!="function")return 1;try{let t=e.call(reactNative.PixelRatio);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}catch{return 1}}i(Bu,"readFontScale");function bb(e){let t=reactNative.Dimensions?.addEventListener;if(typeof t!="function")return ()=>{};let r=t.call(reactNative.Dimensions,"change",e);return ()=>r?.remove?.()}i(bb,"subscribeFontScale");function vb(){return react.useSyncExternalStore(bb,Bu,Bu)}i(vb,"useRnTextScale");function Wu(){try{let e=reactNative.Platform?.OS;return typeof e=="string"?e:null}catch{return null}}i(Wu,"platformOS");function Eb(){return Wu()==="android"?{query:"isHighTextContrastEnabled",event:"highTextContrastChanged"}:{query:"isDarkerSystemColorsEnabled",event:"darkerSystemColorsChanged"}}i(Eb,"contrastSignal");function Cb(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,{query:n,event:o}=Eb(),a=reactNative.AccessibilityInfo?.[n];if(typeof a!="function")return ()=>{};try{let d=a.call(reactNative.AccessibilityInfo);gb(d)&&Promise.resolve(d).then(c=>{r&&t(c===!0);},()=>{});}catch{}let l=reactNative.AccessibilityInfo?.addEventListener,u=typeof l=="function"?l.call(reactNative.AccessibilityInfo,o,d=>t(d===true)):void 0;return ()=>{r=false,u?.remove?.();}},[]),e}i(Cb,"useRnHighContrast");function Rb(){return Wu()==="ios"?"Menlo":Be}i(Rb,"rnPlatformMonoFamily");function Sb(){return globalThis.__DEV__!==false}i(Sb,"isDevelopment");var Hu=new Set;function Tb(e){if(!Sb()||Hu.has(e))return;Hu.add(e);let t=globalThis.console;try{t?.warn?.(`[everfur] The theme names the font face "${e}", which this app has not registered; the SDK renders the platform font at that weight instead. Register the font file (expo-font or your native font assets) or name a registered face.`);}catch{}}i(Tb,"warnUnregisteredFace");function Pb(e){let t=globalThis.expo?.modules?.ExpoFontLoader,r=t?.getLoadedFonts;if(typeof r!="function")return null;let n;try{n=r.call(t);}catch{return null}if(!Array.isArray(n)||n.length===0)return null;let o=n.includes(e);return o||Tb(e),o}i(Pb,"rnIsFontRegistered");var vn=Object.freeze({useColorScheme:yb,useReducedMotion:hb,useTextScale:vb,useHighContrast:Cb,scaleTypeSizes:false,platformMonoFamily:Rb,isFontRegistered:Pb});function xb(e){return react.createElement(reactNativeSafeAreaContext.SafeAreaProvider,null,e)}i(xb,"wrapInSafeArea");var _b=Object.freeze({platform:"react-native",eventSourceFactory:Nu(),wrap:xb,theme:vn});function wb(e){return react.createElement(Du,{...e,seams:_b})}i(wb,"EverfurProvider");function Bt(e){let{runtime:t}=Z(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return react.useMemo(()=>bl(e,n.decisions,{isPending:n.isPending}),[e,n])}i(Bt,"useCapability");function Lb(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(Lb,"tierMultiplier");function S({tier:e="content",...t}){let{type:r}=F(),n=Lb(r,e);return react.createElement(reactNative.Text,n===void 0?t:{maxFontSizeMultiplier:n,...t})}i(S,"Text");var Ht=react.forwardRef(i(function(t,r){return react.createElement(reactNative.TextInput,{...t,...r===null?{}:{ref:r}})},"TextInput"));var Db=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function T(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[Db[t]]}}i(T,"face");var ci=class ci extends react.Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(r,n){return Object.is(r.resetKey,n.key)?null:{failed:false,key:r.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};i(ci,"HostRenderBoundary");var di=ci;function Ub({render:e}){return e()}i(Ub,"RenderHost");function Rt({render:e,fallback:t,resetKey:r}){return react.createElement(di,{fallback:t,resetKey:r,children:react.createElement(Ub,{render:e})})}i(Rt,"HostRender");var Vb=48;function Bb(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(Bb,"selectView");function mi(e){let{capability:t,children:r,renderDisabled:n,renderPending:o,style:s}=e,a=Bt(t),l=react.useMemo(()=>Bb(a),[a]);switch(l){case "enabled":return r;case "pending":return o?jsxRuntime.jsx(Rt,{render:o,fallback:jsxRuntime.jsx(Yu,{capability:t,style:s})}):jsxRuntime.jsx(Yu,{capability:t,style:s});case "disabled":return n?jsxRuntime.jsx(Rt,{render:()=>n(a),fallback:jsxRuntime.jsx(Xu,{decision:a,style:s}),resetKey:a}):jsxRuntime.jsx(Xu,{decision:a,style:s});default:return nt(l)}}i(mi,"CapabilityGate");function Yu({capability:e,style:t}){let r=F(),n=react.useMemo(()=>Qu(r),[r]);return jsxRuntime.jsx(reactNative.View,{style:[n.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:jsxRuntime.jsx(reactNative.View,{style:n.skeletonBar})})}i(Yu,"PendingSkeleton");function Xu({decision:e,style:t}){let r=F(),n=react.useMemo(()=>Qu(r),[r]),o=e.disabled?.reason??"";return jsxRuntime.jsx(reactNative.View,{style:[n.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:o,children:o.length>0?jsxRuntime.jsx(S,{style:n.offstateText,children:o}):null})}i(Xu,"OffState");function Qu(e){let{color:t,space:r,radius:n,type:o}=e;return reactNative.StyleSheet.create({offstate:{minHeight:Vb,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...T(e,"regular"),fontSize:o.size.body,lineHeight:Math.round(o.size.body*o.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}i(Qu,"makeStyles");var b=Object.freeze({placeholder:"Ask me anything!",send:"Send",stop:"Stop",retry:"Try again",followUps:"Helpful follow-ups",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",senderVet:"Your vet",typing:"Assistant is typing",loading:"Loading",empty:"No messages yet",transcript:"Conversation",emptyTitle:"What can we help {petName} with today?",emptyTitlePetFallback:"your pet",copied:"Copied",copyUserMessage:"Copy your message",copyAssistantMessage:"Copy assistant message",feedbackHelpful:"Helpful",feedbackNeutral:"Neutral",feedbackNotHelpful:"Not helpful",feedbackTitle:"What went wrong?",feedbackSubtitle:"Your feedback helps make answers more reliable.",feedbackReasonInaccurate:"Inaccurate",feedbackReasonOutdated:"Out of date",feedbackReasonUnsafe:"Unsafe advice",feedbackReasonUnclear:"Confusing or unclear",feedbackReasonOther:"Something else",feedbackNotesPlaceholder:"Add details (optional)",feedbackSubmit:"Submit feedback",feedbackSkip:"Skip",feedbackSkipA11y:"Skip feedback",feedbackThanks:"Thanks for the feedback",feedbackFailed:"Couldn't send feedback. Please try again.",turnFailedTitle:"Message failed",turnRetry:"Retry",turnUnreachableTitle:"Couldn't reach this chat",turnStartNewChat:"Start a new chat",reconnecting:"Reconnecting\u2026",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",openSource:"Open source",urgencyGeneralReason:"Just general info about {petName}. Nothing here needs action right now.",findVet:"Find a vet",findVetA11y:"Find a vet near you",showLatestVetAlert:"Show latest vet alert",dismissBanner:"Dismiss {label} banner",openMenu:"Open menu",openMenuUnread:"Open menu, unread chats",yourPets:"Your Pets",yourPet:"Your pet",switchActivePet:"Switch active pet, {name}",petCurrentlyActive:"{name}, currently active",switchToPet:"Switch to {name}",activePrefix:"Active \xB7 ",close:"Close",addAnotherPet:"Add another pet",addPet:"Add a pet",attachmentPhoto:"Photo",attachmentCamera:"Camera",closeAttachmentPicker:"Close attachment picker",addAttachment:"Add attachment, {used} of {total} used",attachmentsFull:"Attachments full, {used} of {total} used",retryUpload:"Retry uploading {filename}",removeAttachment:"Remove {filename}",previewAttachment:"Preview {filename}",closePreview:"Close preview",attachedImage:"Attached image: {filename}, opens a full-screen preview",attachmentTooLarge:"Files must be under {max}. {filename} is {size}.",attachmentTooMany:"You can attach up to {max} files per message.",attachmentUnsupported:"{filename} isn't a supported file type yet.",attachmentNetwork:"Couldn't reach the server. Check your connection and try again.",attachmentServer:"Upload failed{status}. Please try again.",attachmentCancelled:"Upload cancelled.",attachmentRateLimited:"Slow down. Please wait a moment and try again.",attachmentQuota:"Daily image limit reached. Try again tomorrow.",attachmentConflict:"Something went wrong. Tap to retry.",attachmentUnknown:"Something went wrong. Please try again.",attachmentsFailedBlocked:"Some attachments failed to upload. Remove or retry them before sending.",dictate:"Dictate a message",stopDictation:"Stop dictation",listening:"Listening",micBlocked:"Microphone access is blocked. Allow it in your browser settings to dictate.",noSpeech:"We didn't catch that. Tap the mic and try again.",dictationUnavailable:"Voice typing isn't available right now."});function q(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let o=t[n];return o===void 0?r:String(o)})}i(q,"fillCopy");var yi=Object.freeze([Object.freeze({key:"inaccurate",label:b.feedbackReasonInaccurate,feedbackType:"wrong"}),Object.freeze({key:"outdated",label:b.feedbackReasonOutdated,feedbackType:"outdated"}),Object.freeze({key:"unsafe",label:b.feedbackReasonUnsafe,feedbackType:"dangerous"}),Object.freeze({key:"unclear",label:b.feedbackReasonUnclear,feedbackType:"unclear"}),Object.freeze({key:"other",label:b.feedbackReasonOther,feedbackType:"not_helpful"})]),Zu=Object.freeze([Object.freeze({sentiment:"up",label:b.feedbackHelpful}),Object.freeze({sentiment:"neutral",label:b.feedbackNeutral}),Object.freeze({sentiment:"down",label:b.feedbackNotHelpful})]);function Hb(e){switch(e){case "up":return "helpful";case "neutral":return "neutral";case "down":return "not_helpful"}}i(Hb,"sentimentToFeedbackType");function Ju(e,t){if(e==="down"&&t!==null){let r=yi.find(n=>n.key===t);if(r!==void 0)return r.feedbackType}return Hb(e)}i(Ju,"feedbackTypeFor");var Gb=Object.freeze({status:"idle",messages:Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:Object.freeze([]),unreadCount:null});function Rr(e){let{runtime:t,userRef:r,activePet:n,scopeEpoch:o}=Z(),s=e?.petRef??n??null,a=e?.conversationId??null,l=react.useMemo(()=>({runtime:t,userRef:r,petRef:s,conversationId:a,scopeEpoch:o}),[t,r,s,a,o]),[u,d]=react.useState(null),c=u?.scope===l?u.controller:t.registry.peekChat({userRef:r,petRef:s,conversationId:a}),p=react.useRef(null);react.useEffect(()=>{let I=t.registry.acquireChat({userRef:r,petRef:s,conversationId:a});return p.current=I,d({scope:l,controller:I}),()=>{p.current=null,d(v=>v?.controller===I?null:v),t.registry.releaseChat(I);}},[t,r,s,a,o,l]);let f=react.useCallback(I=>c?c.subscribe(I):Kb,[c]),m=react.useCallback(()=>c?c.getSnapshot():Gb,[c]),y=react.useSyncExternalStore(f,m,m),R=react.useCallback((I,v)=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?hi(c,c.send(I,v?.imageS3Keys===void 0?{}:{imageS3Keys:v.imageS3Keys}),()=>p.current===c):Promise.resolve(bi()),[c]),h=react.useCallback(I=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?hi(c,c.askEverfur(I),()=>p.current===c):Promise.resolve(bi()),[c]),C=react.useCallback(()=>c&&p.current===c?hi(c,c.retryLast(),()=>p.current===c):Promise.resolve(bi()),[c]),_=react.useCallback(()=>{c&&p.current===c&&c.stop();},[c]),P=react.useCallback(()=>{c&&p.current===c&&c.newConversation();},[c]),[x,g]=react.useState({controller:null,byMessage:{}}),w=x.controller===c?x.byMessage:qb,O=react.useCallback(async(I,v,k,V)=>{if(!c||p.current!==c)return E(D("accessDenied"));let W=String(I),G=x.controller===c?x.byMessage[W]:void 0;if(G===v&&k==null)return g(be=>{let Ie={...be.controller===c?be.byMessage:{}};return delete Ie[W],{controller:c,byMessage:Ie}}),L(Object.freeze({feedbackId:""}));g(be=>({controller:c,byMessage:{...be.controller===c?be.byMessage:{},[W]:v}}));let ae=await c.submitFeedback(I,Ju(v,k??null),V??null);return p.current!==c?E(D("accessDenied")):(ae.ok||g(be=>{let Ie={...be.controller===c?be.byMessage:{}};return G===void 0?delete Ie[W]:Ie[W]=G,{controller:c,byMessage:Ie}}),ae)},[c,x]),M=react.useMemo(()=>{let I=i(async v=>{if(!c||p.current!==c)return E(D("accessDenied"));let k=await v(c);return p.current===c?k:E(D("accessDenied"))},"run");return {listConversations:i(v=>I(k=>k.listConversations({...s?{petRef:s}:{},...v})),"listConversations"),getMessages:i((v,k)=>I(V=>V.getMessages(v,k)),"getMessages"),resumeConversation:i(v=>I(k=>k.resumeConversation(v)),"resumeConversation"),loadOlderMessages:i(()=>I(v=>v.loadOlderMessages()),"loadOlderMessages"),markRead:i(()=>I(v=>v.markRead()),"markRead"),refreshActiveThread:i(()=>I(v=>v.refreshActiveThread()),"refreshActiveThread"),answerCheckin:i((v,k)=>I(V=>V.answerCheckin(v,k)),"answerCheckin"),openCheckin:i(v=>I(k=>k.openCheckin(v)),"openCheckin")}},[c,s]);return react.useMemo(()=>({status:y.status,messages:y.messages,conversationId:y.conversationId,petRef:s,error:y.error,isStreaming:y.isStreaming,isBootstrapping:y.isBootstrapping,historyCursor:y.historyCursor??null,isLoadingHistory:y.isLoadingHistory??false,stopped:y.stopped??false,reconnecting:y.reconnecting??false,...M,suggestedPrompts:y.suggestedPrompts,unreadCount:y.unreadCount,hasUnreadThreads:y.hasUnreadThreads??false,newConversation:P,sentimentByMessage:w,feedback:O,send:R,askEverfur:h,retryLast:C,stop:_}),[y,s,R,h,C,_,M,P,w,O])}i(Rr,"useEverfurChat");var Kb=i(()=>{},"NOOP_UNSUBSCRIBE"),qb=Object.freeze({});async function hi(e,t,r){for await(let o of t);if(!r())return E(D("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?E(n.error):L($b(n.messages))}i(hi,"driveToResult");function $b(e){for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(r&&r.role==="assistant"&&r.responseId!==void 0)return r.responseId}return null}i($b,"lastAssistantResponseId");function bi(){return E(D("internalError",{retryable:true}))}i(bi,"notReadyError");function nd(e){switch(e.code){case "too_large":return q(b.attachmentTooLarge,{max:Ao(tn),filename:e.filename,size:Ao(e.sizeBytes??0)});case "too_many":return q(b.attachmentTooMany,{max:rn});case "unsupported_type":return q(b.attachmentUnsupported,{filename:e.filename});case "network":return b.attachmentNetwork;case "server":return q(b.attachmentServer,{status:e.httpStatus?` (${e.httpStatus})`:""});case "cancelled":return b.attachmentCancelled;case "rate_limited":return b.attachmentRateLimited;case "quota_exceeded":return b.attachmentQuota;case "idempotency_conflict":return b.attachmentConflict;case "unknown":return b.attachmentUnknown}}i(nd,"attachmentErrorMessage");function od(e,t){return q(e>=t?b.attachmentsFull:b.addAttachment,{used:e,total:t})}i(od,"attachControlLabel");var Zb=Object.freeze({attachments:Object.freeze([])});function En(e={}){let{runtime:t,userRef:r,scopeEpoch:n}=Z(),o=e.maxPerMessage??rn,s=react.useCallback(()=>{let{services:g}=t.registry;return Ka({funnel:Ae({auth:g.authFor(r),...g.errorPolicy?{errorPolicy:g.errorPolicy}:{}}),transport:e.transport??g.uploadTransport,maxPerMessage:o})},[t,r,n,o,e.transport]),a=react.useMemo(()=>e.queue??s(),[e.queue,s]),l=react.useRef(new WeakSet),[u,d]=react.useState(null),c=u!==null&&u.of===a?u.queue:a;react.useEffect(()=>{if(c!==e.queue){if(l.current.has(c)){d({of:a,queue:s()});return}return ()=>{c.dispose(),l.current.add(c);}}},[c,a,s,e.queue]);let p=react.useSyncExternalStore(c.subscribe,c.getSnapshot,()=>Zb),[f,m]=react.useState(null),y=react.useCallback(g=>{let O=(Array.isArray(g)?g:[g]).map(I=>c.add(I)),M=O.find(I=>!I.ok);return M!==void 0&&!M.ok&&m(M.error),O},[c,m]),R=react.useCallback(g=>c.retry(g),[c]),h=react.useCallback(g=>c.remove(g),[c]),C=react.useCallback(()=>c.clear(),[c]),_=react.useCallback(()=>m(null),[m]),P=p.attachments.some(g=>g.status==="uploading"),x=p.attachments.some(g=>g.status==="failed");return react.useMemo(()=>({available:c.available,attachments:p.attachments,maxPerMessage:o,uploading:P,failed:x,blocked:P||x,s3Keys:p.attachments.flatMap(g=>g.status==="uploaded"&&g.s3Key!==null?[g.s3Key]:[]),rejected:f,add:y,retry:R,remove:h,clear:C,dismissRejected:_}),[c.available,p,o,P,x,f,y,R,h,C,_])}i(En,"useChatAttachments");var tv="pet_not_registered";function ad(e){return e!=null&&e.reasonCode===tv}i(ad,"isPetNotRegistered");var rv=Object.freeze({status:"idle",error:null,registered:null,retry:i(()=>{},"retry")});function ld(e,t,r){let{runtime:n,userRef:o,scopeEpoch:s}=Z(),a=react.useCallback(()=>ot(n.registry.services.authFor(o)),[n,o,s]),l=react.useMemo(()=>t===void 0?null:Ei(t),[t]),[u,d]=react.useState({key:null,status:"idle",error:null,registered:null}),c=react.useRef(0),p=react.useRef(r);p.current=r;let f=e===null||l===null?null:`${String(o)}|${s}|${e}|${l}`,m=react.useCallback(()=>{if(e===null||t===void 0||f===null)return;let R=++c.current;d({key:f,status:"registering",error:null,registered:null}),a().registerPet(e,t).then(h=>{R===c.current&&(h.ok?(d({key:f,status:"registered",error:null,registered:h.value}),p.current?.()):d({key:f,status:"failed",error:h.error,registered:null}));});},[a,e,f]);react.useEffect(()=>{if(f===null){c.current+=1;return}return m(),()=>{c.current+=1;}},[f,m]);let y=react.useCallback(()=>{u.status==="failed"&&m();},[u.status,m]);return react.useMemo(()=>f===null?rv:u.key!==f?{status:"registering",error:null,registered:null,retry:y}:{status:u.status,error:u.error,registered:u.registered,retry:y},[f,u,y])}i(ld,"useChatPetRegistration");function Ei(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(Ei).join(",")}]`:`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>`${JSON.stringify(r)}:${Ei(n)}`).join(",")}}`}i(Ei,"stableKey");var Ci=Object.freeze({});function dd(e){let[t,r]=react.useState(Ci),n=react.useRef(null),o=react.useRef([]);o.current=e.map(a=>a.id),react.useEffect(()=>{if(e.length===0){n.current=null,r(u=>u===Ci?u:Ci);return}let a=n.current;if(a===null)return;let l=e.find(u=>u.role==="user"&&!a.known.has(u.id));l!==void 0&&(n.current=null,r(u=>({...u,[l.id]:a.images})));},[e]);let s=react.useCallback(a=>{n.current=a.length===0?null:{images:a,known:new Set(o.current)};},[]);return react.useMemo(()=>({byMessage:t,stage:s}),[t,s])}i(dd,"useSentImages");var lv=500;function Ri(e){if(!e)return null;let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g," ").replace(/\s+/g," ").trim();return t?t.slice(0,lv):null}i(Ri,"sanitizeSeedPrompt");function pd(e,t,r){let n=Ri(r),o=react.useRef(e);o.current=e;let s=react.useRef(null);react.useEffect(()=>{if(n===null||t||s.current===n)return;let a=o.current;a!==void 0&&(s.current=n,Promise.resolve(a(n)).catch(()=>{}));},[n,t]);}i(pd,"useInitialAsk");function uv(e,t,r){if(e==="announced")return false;let n=r.lastRefresh;return n===null||n.conversationId!==t?false:r.now-n.at<15e3}i(uv,"isCoalesced");function fd(e,t){let r=t.activeConversationId;return r===null||r.length===0?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:uv(e,r,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:r}}i(fd,"decideChatRefresh");function Si(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(Si,"reportHostFailure");function dv(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(dv,"isThenable");function $(e,...t){if(typeof e=="function")try{let r=e(...t);return dv(r)&&Promise.resolve(r).then(void 0,Si),r}catch(r){Si(r);return}}i($,"callHost");var md=new WeakMap;function yd(e){if(typeof e!="function")return;let t=md.get(e);if(t!==void 0)return t;let r=i((...n)=>{$(e,...n);},"guarded");return md.set(e,r),r}i(yd,"guardHost");function jt(e,...t){let r;try{r=e(...t);}catch(n){return Si(n),Promise.resolve({ok:false,error:n})}return Promise.resolve(r).then(n=>({ok:true,value:n}),n=>({ok:false,error:n}))}i(jt,"callHostAsync");function hd(e,t){let r=react.useRef(t);r.current=t;let n=react.useRef(null),o=react.useRef(null),s=e?.isOffline===void 0?false:$(()=>e.isOffline?.()===!0)===true,a=react.useRef(()=>{});a.current=l=>{let{conversationId:u,isTurnInFlight:d,refresh:c}=r.current,p=fd(l,{activeConversationId:u,isTurnInFlight:d,isOffline:s,lastRefresh:n.current,now:Date.now()});if(p.action!=="skip"){if(p.action==="defer"){o.current!=="announced"&&(o.current=l);return}o.current=null,n.current={conversationId:p.conversationId,at:Date.now()},c!==void 0&&Promise.resolve(c()).catch(()=>{});}},react.useEffect(()=>{if(t.isTurnInFlight||s)return;let l=o.current;l!==null&&a.current(l);},[t.isTurnInFlight,s]),react.useEffect(()=>{if(e===void 0)return;let l=[],u=i((d,c)=>{if(d===void 0)return;let p=$(()=>d(()=>{a.current(c);}));typeof p=="function"&&l.push(p);},"subscribe");return u(e.onForeground?.bind(e),"foreground"),u(e.onOnline?.bind(e),"foreground"),u(e.onAnnounced?.bind(e),"announced"),()=>{for(let d of l)$(d);}},[e]);}i(hd,"useChatLifecycle");function pv(e){if(e===void 0)return null;let t=e.conversationId??"",r=e.petRef??"";return t===""&&r===""?null:`${String(t)}|${String(r)}`}i(pv,"targetKey");function vd(e,t){let r=pv(t),n=react.useRef({openCheckin:e,target:t});n.current={openCheckin:e,target:t};let o=react.useRef(null);react.useEffect(()=>{if(r===null||o.current===r)return;o.current=r;let{openCheckin:s,target:a}=n.current;s===void 0||a===void 0||Promise.resolve(s(a)).catch(()=>{});},[r]);}i(vd,"useCheckinTarget");function Rd(e,t,r){let[n,o]=react.useState({send:e,conversationId:t,text:r??"",seeded:r??null}),s=n.send===e&&(n.conversationId===null||n.conversationId===t);react.useEffect(()=>{o(l=>{let u=l.send===e&&(l.conversationId===null||l.conversationId===t),d=u?l.text:"",c=u?l.seeded:null,p=r!=null&&r!==c&&d.length===0;return {send:e,conversationId:t,text:p?r:d,seeded:p?r:c}});},[e,t,r]);let a=react.useCallback(l=>o(u=>({send:e,conversationId:t,text:l,seeded:u.seeded})),[e,t]);return [s?n.text:"",a]}i(Rd,"useChatDraft");function Sd(e,t,r,n){let o=react.useRef({draft:r,setDraft:n});o.current={draft:r,setDraft:n};let s=react.useRef(null),[a,l]=react.useState(null);react.useEffect(()=>{if(e===void 0)return;let u=`${t??""}`;if(s.current===u)return;s.current=u;let d=true;return (async()=>{let c=await jt(()=>e.read(t));if(!d)return;let p=c.ok&&typeof c.value=="string"?c.value:"";p.length>0&&o.current.draft.length===0&&o.current.setDraft(p),l(u);})(),()=>{d=false;}},[e,t]),react.useEffect(()=>{e===void 0||a!==`${t??""}`||$(()=>e.write(t,r));},[e,t,r,a]);}i(Sd,"usePersistedDraft");var te=Object.freeze({heading:"Chat History",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No matching chats",noMatchBody:"Try a different title or start a new conversation.",loading:"Loading your chats\u2026",loadFailed:"Couldn\u2019t load your chats",loadingMore:"Loading more\u2026",untitled:"New conversation",newConversation:"New conversation",newChat:"New chat",search:"Search",retry:"Try again",retryA11y:"Retry loading chats",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages\u2026",openConversation:"Open conversation",unreadPrefix:"Unread. "});function Rn(e){let t=e?.replace(/\s+/g," ").trim();return t||te.untitled}i(Rn,"conversationTitle");function Pd(e){return `${e.unreadCount!==null&&e.unreadCount>0?te.unreadPrefix:""}${te.openConversation} ${Rn(e.title)}`}i(Pd,"openConversationLabel");function Td(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}i(Td,"normalizeForSearch");function bv(e,t){let r=Td(t);if(r.length===0)return e;let n=[[],[],[]];for(let o of e){let s=Td(Rn(o.title)),a=s.indexOf(r);if(a<0)continue;let l=a===0?0:s.charAt(a-1)===" "?1:2;n[l]?.push(o);}return n.flat()}i(bv,"filterConversations");function ki(e){return {scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}i(ki,"fresh");function kd(e){let[t,r]=react.useState(false),[n,o]=react.useState(""),s=e.listConversations,a=react.useRef(0),[l,u]=react.useState(()=>ki(s)),d=l.scope===s?l:ki(s);react.useEffect(()=>(a.current+=1,r(false),o(""),u(ki(s)),()=>{a.current+=1;}),[s]);let c=react.useCallback(async P=>{let x=++a.current,g=P!==void 0;u(O=>({...O,scope:s,loading:!g,loadingMore:g,error:null}));let w=await e.listConversations(P?{cursor:P}:void 0);if(x===a.current){if(!w.ok){u(O=>({...O,loading:false,loadingMore:false,error:w.error.displayMessage}));return}u(O=>{let M=P&&O.scope===s?O.rows:[],I=new Set(M.map(v=>v.id));return {scope:s,loading:false,loadingMore:false,error:null,rows:[...M,...w.value.conversations.filter(v=>!I.has(v.id))],cursor:w.value.nextCursor===P?null:w.value.nextCursor}});}},[e.listConversations,s]),p=i(()=>{r(true),o(""),c();},"show"),f=i(()=>{a.current+=1,r(false);},"close"),m=i(async P=>{let x=++a.current;u(w=>({...w,loading:true,error:null}));let g=await e.resumeConversation(P);x===a.current&&(u(w=>({...w,loading:false,error:g.ok?null:g.error.displayMessage})),g.ok&&r(false));},"resume"),y=i(async()=>{let P=a.current,x=await e.loadOlderMessages();P===a.current&&!x.ok&&u(g=>({...g,error:x.error.displayMessage}));},"earlier"),R=i(()=>{e.newConversation(),a.current+=1,r(false);},"newConversation"),h=i(()=>{d.cursor===null||d.loading||d.loadingMore||n.trim().length>0||c(d.cursor);},"loadMore"),C=react.useMemo(()=>bv(d.rows,n),[d.rows,n]),_=n.trim().length>0;return {...d,open:t,show:p,close:f,load:c,resume:m,earlier:y,newConversation:R,loadMore:h,query:n,setQuery:o,searching:_,filtered:C,emptyKind:d.rows.length===0?"empty":"noMatch"}}i(kd,"useHistoryPanel");var Sn="#111111",Tn="#FFFFFF",Cv=Object.freeze({emergency:Object.freeze({level:"emergency",label:"Vet care now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:Sn,pillColor:Tn,showsVetAction:true}),schedule_soon:Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:Sn,pillColor:Tn,showsVetAction:true}),home_care:Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Sn,pillColor:Tn,showsVetAction:false}),general:Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Sn,pillColor:Tn,showsVetAction:false})});function Rv(e){return `${e.messageId}:${e.level}:${e.reason??""}`}i(Rv,"urgencySignature");function Sv(e){return q(b.urgencyGeneralReason,{petName:e?.trim()||b.emptyTitlePetFallback})}i(Sv,"generalUrgencyReason");function wd(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n?.role!=="assistant"||n.responseId===void 0)continue;let o=n.urgencyLevel;return o?{messageId:n.id,level:o,reason:Tv(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:Sv(t)}:null}return null}i(wd,"latestUrgencySource");function Tv(e){return typeof e=="string"&&e.trim().length>0?e:null}i(Tv,"shownReason");function Id(e){let t=e===null?null:Rv(e),[r,n]=react.useState(null),[o,s]=react.useState(false);react.useEffect(()=>s(false),[t]);let l=e!==null&&(o||!(r!==null&&r===t)),u=e===null?null:Cv[e.level],d=e!==null&&!l&&e.level!=="general",c=react.useCallback(()=>{t!==null&&n(t),s(false);},[t]),p=react.useCallback(()=>s(true),[]);return react.useMemo(()=>({source:e,tier:u,signature:t,showBanner:l,showCompactIcon:d,showVetAction:l&&u!==null&&u.showsVetAction,dismissLabel:u===null?null:q(b.dismissBanner,{label:u.label}),dismiss:c,expand:p}),[e,u,t,l,d,c,p])}i(Id,"useUrgencySurface");function Ad(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}i(Ad,"selectView");function Pv(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}i(Pv,"needsNewConversation");function Od(e){if(e.messages.length===0)return null;let t=e.status==="error"?e.error:null;if(t!==null){let r=Pv(t);return {tone:"error",title:r?b.turnUnreachableTitle:b.turnFailedTitle,body:t.displayMessage,actionLabel:r?b.turnStartNewChat:b.turnRetry,action:r?"startNew":"retry"}}return e.stopped===true?{tone:"neutral",title:b.turnStoppedTitle,body:b.turnStoppedBody,actionLabel:b.turnRetry,action:"retry"}:null}i(Od,"turnNotice");function Fd(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}i(Fd,"awaitingAssistant");var kv=3,xv=Object.freeze([]);function Md(e){let t=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||t===void 0||t.role!=="assistant")return xv;let r=new Set,n=[];for(let o of e.suggestedPrompts){let s=o.trim(),a=s.replace(/\s+/g," ").toLowerCase();if(!(a.length===0||r.has(a))&&(r.add(a),n.push(s),n.length===kv))break}return Object.freeze(n)}i(Md,"visibleFollowUps");function Ld(e){return e.sender?.displayName??b.senderVet}i(Ld,"vetSenderLabel");function Dd(e,t){let r={};return e!==void 0&&(r.petRef=e),t!==void 0&&(r.conversationId=t),r}i(Dd,"buildChatOpts");var Sr=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 Vd(e){let t=F(),r=react.useMemo(()=>Iv(t),[t]);return jsxRuntime.jsxs(reactNative.View,{style:[r.container,e.style],accessible:true,accessibilityRole:"text",accessibilityLabel:`${Sr.title}. ${Sr.body}`,children:[jsxRuntime.jsx(S,{style:r.title,children:Sr.title}),jsxRuntime.jsx(S,{style:r.body,children:Sr.body})]})}i(Vd,"ClinicalDisclaimer");function Iv(e){let{color:t,space:r,type:n}=e;return reactNative.StyleSheet.create({container:{paddingHorizontal:r.lg,paddingVertical:r.md,borderTopWidth:reactNative.StyleSheet.hairlineWidth,borderTopColor:t.borderHairlineGreen,backgroundColor:t.surfaceCream,gap:r.xs},title:{...T(e,"bold"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.secondary,letterSpacing:n.letterSpacing.eyebrow},body:{...T(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.muted}})}i(Iv,"makeStyles");var ue={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function ie(e){return {width:e,height:e,alignItems:"center",justifyContent:"center"}}i(ie,"box");function me(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}i(me,"stroke");function Bd({size:e,color:t,strokeWidth:r}){let n=me(e,r),o={width:e*.82,height:n,borderRadius:n,backgroundColor:t};return jsxRuntime.jsxs(reactNative.View,{style:[ie(e),{gap:e*.22}],...ue,children:[jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o})]})}i(Bd,"MenuGlyph");function Hd({size:e,color:t,strokeWidth:r,rotate:n}){let o=me(e,r),s=e*.78;return jsxRuntime.jsxs(reactNative.View,{style:[ie(e),{transform:[{rotate:n}]}],...ue,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:s,height:o,borderRadius:o,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:o,height:s,borderRadius:o,backgroundColor:t}})]})}i(Hd,"Cross");function zd(e){return jsxRuntime.jsx(Hd,{...e,rotate:"0deg"})}i(zd,"PlusGlyph");function St(e){return jsxRuntime.jsx(Hd,{...e,rotate:"45deg"})}i(St,"CloseGlyph");function lt({size:e,color:t,strokeWidth:r}){let n=me(e,r);return jsxRuntime.jsx(reactNative.View,{style:ie(e),...ue,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}i(lt,"CheckGlyph");var Fv={down:{rotate:"45deg",marginTop:-0.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-0.4}};function Pn({size:e,color:t,strokeWidth:r,direction:n}){let o=me(e,r),s=e*.46,a=Fv[n];return jsxRuntime.jsx(reactNative.View,{style:ie(e),...ue,children:jsxRuntime.jsx(reactNative.View,{style:{width:s,height:s,borderRightWidth:o,borderBottomWidth:o,borderColor:t,marginTop:s*a.marginTop,marginLeft:s*a.marginLeft,transform:[{rotate:a.rotate}]}})})}i(Pn,"ChevronGlyph");function jd({size:e,color:t,strokeWidth:r}){let n=me(e,r),o={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};return jsxRuntime.jsxs(reactNative.View,{style:[ie(e),{flexDirection:"row",gap:1}],...ue,children:[jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopLeftRadius:e*.2}]}),jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}i(jd,"BookGlyph");function Wd({size:e,color:t,strokeWidth:r}){let n=me(e,r),o=e*.5;return jsxRuntime.jsxs(reactNative.View,{style:ie(e),...ue,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:e*.78,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.16,right:e*.16,width:o,height:o,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}i(Wd,"ArrowUpRightGlyph");function Gd({size:e,color:t,strokeWidth:r}){let n=me(e,r),o=e*.6,s={position:"absolute",width:o,height:o,borderWidth:n,borderColor:t,borderRadius:e*.14};return jsxRuntime.jsxs(reactNative.View,{style:ie(e),...ue,children:[jsxRuntime.jsx(reactNative.View,{style:[s,{top:0,left:0}]}),jsxRuntime.jsx(reactNative.View,{style:[s,{bottom:0,right:0}]})]})}i(Gd,"CopyGlyph");function kn({size:e,color:t,strokeWidth:r,active:n,rotate:o}){let s=me(e,r),a=n?t:"transparent";return jsxRuntime.jsxs(reactNative.View,{style:[ie(e),{transform:[{rotate:o}]}],...ue,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.05}})]})}i(kn,"ThumbGlyph");function Kd({size:e,color:t,strokeWidth:r}){let n=me(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[ie(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...ue,children:[jsxRuntime.jsx(reactNative.View,{style:{width:n,height:n,borderRadius:n,backgroundColor:t,marginBottom:e*.1}}),jsxRuntime.jsx(reactNative.View,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}i(Kd,"InfoGlyph");function qd({size:e,color:t,strokeWidth:r}){let n=me(e,r),o=e*.34;return jsxRuntime.jsxs(reactNative.View,{style:ie(e),...ue,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.06,width:o,height:o,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.1,width:n,height:e*.56,borderRadius:n,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}i(qd,"UploadGlyph");function $d({size:e,color:t,strokeWidth:r}){let n=me(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[ie(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...ue,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i($d,"PhotoGlyph");function Yd({size:e,color:t,strokeWidth:r}){let n=me(e,r);return jsxRuntime.jsxs(reactNative.View,{style:ie(e),...ue,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderTopLeftRadius:n,borderTopRightRadius:n}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}i(Yd,"CameraGlyph");function Xd({size:e,color:t,strokeWidth:r}){let n=me(e,r),o=e*.66;return jsxRuntime.jsxs(reactNative.View,{style:ie(e),...ue,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:0,left:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.02,right:e*.02,width:n,height:e*.4,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}})]})}i(Xd,"SearchGlyph");function Qd({size:e,color:t,strokeWidth:r}){let n=me(e,r);return jsxRuntime.jsxs(reactNative.View,{style:ie(e),...ue,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:n,borderColor:t,borderRadius:n,transform:[{rotate:"45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:n,borderRadius:n,backgroundColor:t}})]})}i(Qd,"EditGlyph");function Zd({size:e,color:t,strokeWidth:r}){let n=me(e,r),o=e*.62;return jsxRuntime.jsxs(reactNative.View,{style:ie(e),...ue,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t,alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(reactNative.View,{style:{width:n*1.4,height:n*1.4,borderRadius:n,backgroundColor:t}})}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.04,width:o*.5,height:o*.5,borderRightWidth:n,borderBottomWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(Zd,"MapPinGlyph");function Jd({size:e,color:t,testID:r}){let n=e*.36;return jsxRuntime.jsx(reactNative.View,{style:ie(e),testID:r,...ue,children:jsxRuntime.jsx(reactNative.View,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}i(Jd,"SendGlyph");function ec({size:e,color:t,testID:r}){return jsxRuntime.jsx(reactNative.View,{style:ie(e),testID:r,...ue,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}i(ec,"StopGlyph");function xn({size:e,strokeWidth:t,color:r,children:n}){return jsxRuntime.jsx(reactNative.View,{style:[ie(e),{borderRadius:e/2,borderWidth:t??reactNative.StyleSheet.hairlineWidth,borderColor:r}],children:n})}i(xn,"Ring");var Tr=Object.freeze({standard:ht.standard,emphasized:ht.emphasized,exit:ht.exit,outQuad:Object.freeze([.25,.46,.45,.94])});var tc=Object.freeze({layoutMs:220,messageInMs:200,bannerInMs:220,bannerOutMs:160,iconInMs:180,iconOutMs:120,followUpInMs:180,followUpStaggerMs:70,citationsInMs:220,citationsRisePx:6,drawerMs:220,pressScale:.97,pressMs:140,revealTickMs:24,revealDivisor:12,dotsCycleMs:520,dotsMinOpacity:.44,dotsLiftPx:3.5,dotsStagger:Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,reduced:false}),Mv=Object.freeze({...tc,layoutMs:0,messageInMs:0,bannerInMs:0,bannerOutMs:0,iconInMs:0,iconOutMs:0,followUpInMs:0,followUpStaggerMs:0,citationsInMs:0,citationsRisePx:0,drawerMs:0,pressScale:1,pressMs:0,revealTickMs:0,dotsCycleMs:0,dotsMinOpacity:1,dotsLiftPx:0,reduced:true});function rc(e){return e.motion.reducedMotion?Mv:tc}i(rc,"chatMotion");function _n(e,t){return Math.max(0,t)*e.followUpStaggerMs}i(_n,"followUpDelayMs");function nc(e,t,r){if(e.reduced||t>=r)return r;let n=Math.max(1,Math.ceil((r-t)/e.revealDivisor));return Math.min(r,t+n)}i(nc,"nextRevealLength");function J(){let e=F();return rc(e)}i(J,"useChatMotion");var Bv=8;function ic(e,t,r){return ((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}i(ic,"bezierComponent");function Hv(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}i(Hv,"bezierSlope");function wn(e){let[t,r,n,o]=e;return s=>{if(s<=0)return 0;if(s>=1)return 1;let a=s;for(let l=0;l<Bv;l+=1){let u=Hv(a,t,n);if(u===0)break;a-=(ic(a,t,n)-s)/u;}return ic(Math.min(1,Math.max(0,a)),r,o)}}i(wn,"bezierEasing");var xi=wn(Tr.standard),zv=wn(Tr.outQuad);function Ai(e){let t=react.useRef(null);return t.current===null&&(t.current=new reactNative.Animated.Value(e)),t.current}i(Ai,"useAnimatedValue");function Tt(e,t={}){let r=t.risePx??0,n=t.delayMs??0,o=Ai(e>0?0:1);return react.useEffect(()=>{if(e<=0)return;let s=reactNative.Animated.timing(o,{toValue:1,duration:e,easing:zv,useNativeDriver:true}),a=n>0?reactNative.Animated.sequence([reactNative.Animated.delay(n),s]):s;return a.start(),()=>a.stop()},[o,e,n]),react.useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[o,r])}i(Tt,"useFadeIn");function Oi({visible:e,inMs:t,outMs:r,style:n,children:o}){let[s,a]=react.useState(e),l=Ai(e&&t<=0?1:0);return react.useEffect(()=>{if(e){a(true);let d=reactNative.Animated.timing(l,{toValue:1,duration:Math.max(0,t),easing:xi,useNativeDriver:true});return d.start(),()=>d.stop()}if(!s)return;if(r<=0){a(false);return}let u=reactNative.Animated.timing(l,{toValue:0,duration:r,easing:xi,useNativeDriver:true});return u.start(({finished:d})=>{d&&a(false);}),()=>u.stop()},[e,s,t,r,l]),!s&&!e?null:jsxRuntime.jsx(reactNative.Animated.View,{style:[n,{opacity:l}],children:o})}i(Oi,"FadePresence");var jv=12;function H({style:e,containerStyle:t,children:r,onPressIn:n,onPressOut:o,hitSlop:s,...a}){let l=J(),u=Ai(1),d=react.useCallback(c=>{l.pressMs<=0||l.pressScale===1||reactNative.Animated.timing(u,{toValue:c,duration:l.pressMs,easing:xi,useNativeDriver:true}).start();},[u,l.pressMs,l.pressScale]);return jsxRuntime.jsx(reactNative.Pressable,{...a,hitSlop:s??jv,style:t,onPressIn:c=>{d(l.pressScale),n?.(c);},onPressOut:c=>{d(1),o?.(c);},children:jsxRuntime.jsx(reactNative.Animated.View,{style:[e,{transform:[{scale:u}]}],children:r})})}i(H,"PressScale");function lc(e,t,r){let n=t&&r.revealTickMs>0,[o,s]=react.useState(0),a=react.useRef(e);return a.current=e,react.useEffect(()=>{if(!n)return;let l=setInterval(()=>{s(u=>nc(r,u,a.current.length));},r.revealTickMs);return ()=>clearInterval(l)},[n,r]),n?e.slice(0,Math.min(o,e.length)):e}i(lc,"useRevealedText");var sc=false;function Wv(e){e.layoutMs<=0||(sc||(sc=true,reactNative.Platform.OS==="android"&&typeof reactNative.UIManager.setLayoutAnimationEnabledExperimental=="function"&&reactNative.UIManager.setLayoutAnimationEnabledExperimental(true)),reactNative.LayoutAnimation.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}));}i(Wv,"animateLayout");function Pr(e,t){let r=react.useRef(e);r.current!==e&&(r.current=e,Wv(t));}i(Pr,"useAnimateLayoutOn");var Fi=36,Qv=22,Zv=12,Jv=12,eE=16,tE="#000",rE="rgba(0,0,0,0.45)";function uc({uri:e,label:t,onClose:r}){let n=F(),o=reactNativeSafeAreaContext.useSafeAreaInsets();return e===null?null:jsxRuntime.jsxs(reactNative.Modal,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:b.closePreview,style:In.backdrop,onPress:r,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:In.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),jsxRuntime.jsx(reactNative.View,{pointerEvents:"box-none",style:[In.closeWrap,{top:o.top+Jv}],children:jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:b.closePreview,hitSlop:Zv,style:In.closeButton,onPress:r,children:jsxRuntime.jsx(St,{size:Qv,color:n.color.surface,strokeWidth:2})})})]})}i(uc,"AttachmentImageLightbox");var In=reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:tE,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:eE},closeButton:{width:Fi,height:Fi,borderRadius:Fi/2,backgroundColor:rE,alignItems:"center",justifyContent:"center"}});var An=12,aE=80,Mi=44,dc=22,lE=.14,uE=18,dE=8,cc=Object.freeze({photo:b.attachmentPhoto,camera:b.attachmentCamera});function pc({sources:e,full:t,onPick:r,onClose:n}){let o=F(),s=react.useMemo(()=>cE(o),[o]);return jsxRuntime.jsxs(reactNative.View,{style:s.anchor,pointerEvents:"box-none",children:[jsxRuntime.jsx(reactNative.Pressable,{style:s.dismissLayer,accessibilityRole:"button",accessibilityLabel:b.closeAttachmentPicker,onPress:n}),jsxRuntime.jsxs(reactNative.View,{style:s.bubble,children:[jsxRuntime.jsx(reactNative.View,{style:s.tilesRow,children:e.map(a=>jsxRuntime.jsxs(H,{accessibilityRole:"button",accessibilityLabel:cc[a],accessibilityState:{disabled:t},disabled:t,containerStyle:s.tile,style:s.tileInner,onPress:()=>r(a),children:[jsxRuntime.jsx(reactNative.View,{style:s.tileIconWrap,children:a==="photo"?jsxRuntime.jsx($d,{size:dc,color:o.color.brandInk,strokeWidth:1.5}):jsxRuntime.jsx(Yd,{size:dc,color:o.color.brandInk,strokeWidth:1.5})}),jsxRuntime.jsx(S,{tier:"control",style:s.tileLabel,children:cc[a]})]},a))}),jsxRuntime.jsx(reactNative.View,{style:s.tail}),jsxRuntime.jsx(reactNative.View,{style:s.tailFill})]})]})}i(pc,"AttachmentPickerPopover");function cE(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({anchor:{position:"absolute",left:0,right:0,bottom:"100%",paddingHorizontal:8,paddingBottom:10,alignItems:"flex-start"},dismissLayer:{position:"absolute",left:-1e3,right:-1e3,top:-2e3,bottom:0},bubble:{backgroundColor:t.surfaceCream,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:6,paddingVertical:8,shadowColor:t.shadow,shadowOpacity:lE,shadowRadius:uE,shadowOffset:{width:0,height:dE},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:aE,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:Mi,height:Mi,borderRadius:Mi/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...T(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-An/2,width:An,height:An,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:An+4,height:2,backgroundColor:t.surfaceCream}})}i(cE,"makeStyles");var xe=Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var mc=56,yc=12,mE=14,yE=10,gE=.45,hE="rgba(7,193,104,0.55)",bE="rgba(185,28,28,0.55)",vE=200,EE=300,Sc=20,Di=22,CE=12,RE="rgba(0,0,0,0.78)",gc=220,hc=100,bc="rgba(255,255,255,0.15)";function Tc({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:o,onPreview:s}){let a=F(),l=react.useMemo(()=>kc(a),[a]);return e.length===0&&t===null?null:jsxRuntime.jsxs(reactNative.View,{style:l.strip,children:[e.length>0?jsxRuntime.jsx(reactNative.View,{style:l.cards,children:e.map(u=>jsxRuntime.jsx(SE,{row:u,styles:l,onRetry:n,onRemove:o,onPreview:s},u.id))}):null,r?jsxRuntime.jsx(S,{style:l.rejected,accessibilityRole:"alert",children:b.attachmentsFailedBlocked}):null,t!==null?jsxRuntime.jsx(S,{style:l.rejected,accessibilityRole:"alert",children:nd(t)}):null]})}i(Tc,"AttachmentStrip");function SE({row:e,styles:t,onRetry:r,onRemove:n,onPreview:o}){let s=F(),a=e.status==="uploading",l=e.status==="failed",u=e.status==="uploaded",d=react.useRef(e.status),[c,p]=react.useState(false);return react.useEffect(()=>{let f=d.current;d.current=e.status,e.status==="uploaded"&&f==="uploading"&&p(true);},[e.status]),jsxRuntime.jsxs(reactNative.View,{style:t.card,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:u?"button":"image",accessibilityLabel:u?q(b.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:a,disabled:!u},disabled:!u,style:t.thumbHit,onPress:()=>o(e),children:jsxRuntime.jsxs(reactNative.View,{style:t.thumb,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),a?jsxRuntime.jsx(reactNative.View,{style:t.uploadingOverlay,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:s.color.surface})}):null,c?jsxRuntime.jsx(TE,{styles:t,onDone:()=>p(false)}):null]})}),l?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:q(b.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:jsxRuntime.jsx(reactNative.View,{style:t.failedInner,children:jsxRuntime.jsx(St,{size:Sc,color:s.color.surface,strokeWidth:2})})}):null,jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:q(b.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:jsxRuntime.jsx(St,{size:CE,color:s.color.surface,strokeWidth:1.5})})]})}i(SE,"PreviewCard");function TE({styles:e,onDone:t}){let r=F(),n=J(),o=react.useRef(null);o.current===null&&(o.current=new reactNative.Animated.Value(0));let s=o.current;return react.useEffect(()=>{let a=reactNative.Animated.sequence([reactNative.Animated.timing(s,{toValue:1,duration:vE,useNativeDriver:true}),reactNative.Animated.delay(n.uploadFlashMs),reactNative.Animated.timing(s,{toValue:0,duration:EE,useNativeDriver:true})]);return a.start(({finished:l})=>{l&&t();}),()=>a.stop()},[s,n.uploadFlashMs,t]),jsxRuntime.jsx(reactNative.Animated.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:s}],children:jsxRuntime.jsx(lt,{size:Sc,color:r.color.surface,strokeWidth:2})})}i(TE,"SuccessFlash");function Pc({images:e,onPreview:t}){let r=F(),n=react.useMemo(()=>kc(r),[r]);if(e.length===0)return null;let o=e.length===1;return jsxRuntime.jsx(reactNative.View,{style:o?n.sentSingle:n.sentGrid,children:e.map((s,a)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:q(b.attachedImage,{filename:s.filename}),onPress:()=>t(s),children:jsxRuntime.jsx(reactNative.Image,{source:{uri:s.uri},style:o?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${s.uri}-${a}`))})}i(Pc,"SentImages");function kc(e){let t=e.color,r=e.type;return reactNative.StyleSheet.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:mc,height:mc,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:yc,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...xe,alignItems:"center",justifyContent:"center",backgroundColor:Sl(e.color.brandInk,gE)??e.color.brandSofter},successOverlay:{...xe,alignItems:"center",justifyContent:"center",backgroundColor:hE},failedOverlay:{...xe,borderRadius:yc,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:bE},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:Di,height:Di,borderRadius:Di/2,backgroundColor:RE,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...T(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},sentSingle:{marginBottom:6},sentGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,marginBottom:6},singleImage:{width:gc,height:gc,borderRadius:mE,backgroundColor:bc},gridImage:{width:hc,height:hc,borderRadius:yE,backgroundColor:bc}})}i(kc,"makeStyles");var PE="chat attachment upload: the file handle has no uri",kE="chat attachment upload failed";function xE(e){return {uri:e.uri,name:Io(e.name),type:e.mimeType}}i(xE,"filePartOf");function xc(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(PE));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(kE)),"failed");return o?.aborted===true?a():Kr({url:t.upload_url,fields:t.upload_fields,file:xE(r),signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(xc,"createRnChatAttachmentTransport");function On(){let{runtime:e,userRef:t,activePet:r,scopeEpoch:n}=Z(),o=react.useMemo(()=>ot(e.registry.services.authFor(t)),[e,t,n]),[s,a]=react.useState({repository:o,pets:[],loading:true,error:null}),l=s.repository===o?s:{pets:[],loading:true,error:null},u=react.useRef(0),d=react.useCallback(async()=>{let p=++u.current;a(m=>({...m,repository:o,loading:true,error:null,pets:m.repository===o?m.pets:[]}));let f=await o.list();p===u.current&&a(f.ok?{repository:o,pets:f.value,loading:false,error:null}:m=>({repository:o,pets:m.repository===o?m.pets:[],loading:false,error:f.error}));},[o]);react.useEffect(()=>(d(),()=>{u.current+=1;}),[d]);let c=react.useMemo(()=>r===null?null:l.pets.find(p=>p.petRef===r)??null,[r,l.pets]);return react.useMemo(()=>({pets:l.pets,activePet:c,loading:l.loading,error:l.error,refresh:d}),[l.pets,l.loading,l.error,c,d])}i(On,"useEverfurPets");function _c(e,t){if(t!==null){let r=e.find(n=>n.petRef===t);if(r!==void 0)return r}return e[0]??null}i(_c,"headerPetOf");function pe(e,t){if(e===void 0)return {};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}i(pe,"slotBox");function Bi(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}i(Bi,"ownGroundSlot");function Se(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(Se,"slotText");var wc=Object.freeze({visitButton:"Talk to a vet"});var Ic=Symbol.for("@everfur/sdk/televet");function Qe(){let e=globalThis,t=e[Ic];if(t!==void 0)return t;let r={presenter:null,snapshot:Object.freeze({request:null,serial:0,activeHost:null}),hosts:[],nextHost:1,listeners:new Set,dailyRegistered:false};return e[Ic]=r,r}i(Qe,"televetGlobal");function Fn(e){let t=Qe();t.snapshot=Object.freeze({...t.snapshot,...e});for(let r of [...t.listeners])try{r();}catch{}}i(Fn,"publish");function Ac(e){let t=Qe().presenter;if(t===null)return "absent";try{return t(e)===!1?"declined":"presented"}catch(r){return console.warn("[everfur] Your registerEverfurTelevetFlow presenter threw; the in-app visit opened instead.",r),"threw"}}i(Ac,"callTelevetPresenter");function Oc(e){let t=Qe();return t.listeners.add(e),()=>{t.listeners.delete(e);}}i(Oc,"subscribeTelevetExperience");function Hi(){return Qe().snapshot}i(Hi,"televetExperienceSnapshot");function OE(){return Qe().hosts.length>0}i(OE,"hasTelevetHost");function Fc(e){if(!OE())return false;let t=Object.freeze({...e});return Fn({request:t,serial:Qe().snapshot.serial+1}),true}i(Fc,"presentTelevetExperience");function zi(){Qe().snapshot.request!==null&&Fn({request:null});}i(zi,"dismissTelevetExperience");function Mc(){let e=Qe(),t=e.nextHost;return e.nextHost+=1,e.hosts=[...e.hosts,t],Fn({activeHost:e.hosts[0]??null}),t}i(Mc,"claimTelevetHost");function Lc(e){let t=Qe();t.hosts=t.hosts.filter(n=>n!==e);let r=t.hosts[0]??null;Fn(r===null?{activeHost:r,request:null}:{activeHost:r});}i(Lc,"releaseTelevetHost");var Dc=false;function Mn(e,t){return t!==void 0?($(t,e),"onStartInApp"):Ac(e)==="presented"?"presenter":Fc(e)?"experience":(Dc||(Dc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}i(Mn,"openVetVisitInApp");function Vc(e){let t=null;return ()=>{if(t!==null)return t;let r=e();return t=r,r.then(void 0,()=>{t===r&&(t=null);}),r}}i(Vc,"memoizeTelevetLoader");function Bc(e){let[t,r]=react.useState(null);react.useEffect(()=>{let d=Mc();return r(d),()=>{Lc(d);}},[]);let n=react.useSyncExternalStore(Oc,Hi,Hi),s=t!==null&&n.activeHost===t?n.request:null,[a,l]=react.useState(null),u=s!==null&&a===null;return react.useEffect(()=>{if(!u)return;let d=true;return e().then(c=>{d&&l(()=>c);},c=>{d&&(console.warn("[everfur] The in-app vet visit could not load its screens.",c),zi());}),()=>{d=false;}},[u,e]),s===null||a===null?null:{module:a,request:s,serial:n.serial,dismiss:zi}}i(Bc,"useTelevetExperienceHost");var ME=Vc(()=>import('@everfur/sdk/televet/booking'));function xr(){let e=Bc(ME);if(e===null)return null;let{EverfurTelevetModal:t}=e.module;return jsxRuntime.jsx(t,{request:e.request,onClose:e.dismiss},e.serial)}i(xr,"EverfurTelevetHost");var ji=Object.freeze(["visit","join","summary","messages"]);function Wi(e){return typeof e=="string"&&ji.includes(e)}i(Wi,"isVetVisitIntent");var DE="/widget/v1/televet/handoffs",NE="/widget/v1/televet/availability",UE="/widget/v1/televet/chat-entry",VE=/^[a-z0-9][a-z0-9_-]{0,39}$/,BE=/^[A-Za-z0-9_-]{22}$/;var Hc=32,zc=128,jc=64;function Ki(e){let t=e.httpStatus;switch(e.code){case "sessionRequired":return "sessionRequired";case "authExpired":case "authRejected":return "authRejected";case "sdkUpdateRequired":return "sdkUpdateRequired";case "validationFailed":return "invalidRequest";case "rateLimited":case "quotaExceeded":return "rateLimited";}return t===void 0?e.code==="internalError"?"network":"unknown":t===429?"rateLimited":t===404?"unavailable":t===403?"accessDenied":t===401?"authRejected":t===400||t===422?"invalidRequest":t>=500?"serverError":"unknown"}i(Ki,"vetVisitErrorReasonOf");function Wc(e){return E(D("validationFailed",{retryable:false,wireMessage:e}))}i(Wc,"invalid");function Gi(e){return E(D("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}i(Gi,"unusable");function HE(e,t){let r={};e!==void 0&&(r.pet_ref=e);let n=t?.returnTo;if(n!=null){if(typeof n!="string"||!VE.test(n))return {ok:false,message:"returnTo must be a registered return destination key"};r.return_to=n;}let o=t?.entry;if(o!=null){if(o!=="chat"||e===void 0)return {ok:false,message:"entry 'chat' needs the pet the chat is about"};r.entry=o;}let s=t?.visitRef,a=t?.intent,l=s!=null;if(l){let u=typeof s=="string"?s.trim():"";if(u.length<1||[...u].length>jc)return {ok:false,message:`visitRef must be 1..${jc} characters`};r.visit_ref=u;}if(a!=null){if(!l)return {ok:false,message:"intent needs the visitRef it opens"};if(!Wi(a))return {ok:false,message:`intent must be one of ${ji.join(", ")}`};r.intent=a;}return {ok:true,body:r}}i(HE,"handoffBody");function zE(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!Wi(r)?null:Object.freeze({visitRef:t,intent:r})}i(zE,"parseVisitEcho");function Kc(e){let t=e.funnel??Ae({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=i(o=>(Gc(r,"televet.visit.handoff_failed",{reason:Ki(o)}),E(o)),"failed");return {async createHandoff(o,s){let a;if(o!=null){let h=typeof o=="string"?[...o].length:0;if(h<1||h>zc)return n(D("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${zc} characters`}));a=o;}let l=HE(a,s);if(!l.ok){let h=Wc(l.message);return h.ok?h:n(h.error)}let u=l.body,d=await t.send("televet.visit.handoff",{method:"POST",path:DE,body:u},{idempotent:false,maxAttempts:1});if(!d.ok)return n(d.error);let c=jE(d.value),p=u.return_to!==void 0,f=p?d.value?.flow_id:void 0;if(p&&(typeof f!="string"||!BE.test(f))){let h=Gi("the handoff response carried no usable return flow id");return h.ok?h:n(h.error)}let m=u.visit_ref!==void 0,y=m?zE(d.value?.visit):null;if(m&&y===null){let h=Gi("the handoff response did not confirm the visit it opens");return h.ok?h:n(h.error)}let R=c===null?null:Object.freeze({...c,...p?{flowId:f}:{},...y!==null?{visit:y}:{}});return R===null?n(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Gc(r,"televet.visit.handoff_created",{pet_scoped:u.pet_ref!==void 0}),L(R))},async checkAvailability(o){if(typeof o!="string"||o.length>Hc)return Wc(`state must be at most ${Hc} characters`);let s=await t.send("televet.visit.availability",{method:"POST",path:NE,body:{state:o}},{idempotent:false,maxAttempts:1});if(!s.ok)return E(s.error);let a=s.value?.available;return typeof a!="boolean"?Gi("the availability response carried no usable answer"):L(Object.freeze({available:a}))},async chatEntryOpen(){try{let o=await t.send("televet.visit.chat_entry",{method:"GET",path:UE},{maxAttempts:1});return o.ok&&o.value?.open===!0}catch{return false}}}}i(Kc,"createVetVisitController");function jE(e){if(typeof e!="object"||e===null)return null;let{url:t,expires_at:r}=e;return typeof t!="string"||typeof r!="string"||r.length===0||!qE(t)?null:Object.freeze({url:t,expiresAt:r})}i(jE,"parseHandoff");var WE=new Set(["localhost","127.0.0.1","[::1]"]),GE=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,KE=/[\s\u0000-\u001f\u007f]/;function qE(e){if(KE.test(e))return false;let t=GE.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let o=n.replace(/:\d+$/,"").toLowerCase(),s=r==="https",a=r==="http"&&WE.has(o);if(!s&&!a)return false;let l=e.indexOf("#");if(l<0)return false;let u=e.slice(l);return u.startsWith("#h=")&&u.length>3}i(qE,"isOpenableVisitUrl");function Gc(e,t,r){if(e)try{e.track(t,r);}catch{}}i(Gc,"safeTrack");var qi=Object.freeze({status:"idle",error:null,errorReason:null});function YE(e,t,r){let{usState:n,chat:o,scope:s}=r,a=t&&(n!==null||o),l=`${n??""}|${o?"chat":""}`,[u,d]=react.useState(null);if(react.useEffect(()=>{if(!a)return;let p=true,f=e.current;return d(null),i(async()=>{try{if(o&&!(f.chatEntryOpen&&await f.chatEntryOpen()))return !1;if(n===null)return !0;if(!f.checkAvailability)return !1;let y=await f.checkAvailability(n);return y.ok&&y.value.available}catch{return false}},"ask")().then(y=>{p&&d({key:l,open:y});}),()=>{p=false;}},[a,l,n,o,s,e]),!a)return null;let c=u!==null&&u.key===l;return {open:c&&u.open,pending:!c}}i(YE,"usePreflight");var XE=Object.freeze({status:"opening",error:null,errorReason:null});function Yc(e,t={}){let{runtime:r,userRef:n,scopeEpoch:o}=Z(),s=Bt("televet"),a=s.enabled&&n!==null,l=t.usState??null,u=t.entry==="chat",d=t.petRef??null,c=t.prefer==="redirect",p=react.useMemo(()=>{if(t.controller)return t.controller;let{services:k}=r.registry;return Kc({auth:k.authFor(n),telemetry:k.telemetry,...k.errorPolicy?{errorPolicy:k.errorPolicy}:{}})},[r,n,o,t.controller]),f=react.useRef(p);f.current=p;let m=react.useMemo(()=>({runtime:r,userRef:n,scopeEpoch:o}),[r,n,o]),y=YE(f,a,{usState:l,chat:u,scope:m}),R=a&&(y===null||y.open)&&(!u||d!==null),h=t.returnTo??null,[C,_]=react.useState(qi),P=react.useRef(null),x=react.useRef({runtime:r,userRef:n,scopeEpoch:o});x.current={runtime:r,userRef:n,scopeEpoch:o};let g=react.useRef(p);g.current=p;let w=react.useRef(R);w.current=R;let O=react.useCallback((k,V)=>{if(P.current)return P.current;let W=i((ye,rt)=>(_({status:ye==="cancelled"?"idle":"error",error:rt,errorReason:ye==="cancelled"?null:ye}),Object.freeze({opened:false,reason:ye,error:rt})),"fail");if(!w.current)return Promise.resolve(W("unavailable",null));let G=e.prepare();if(!G.ok)return Promise.resolve(W(G.reason,null));let ae=x.current,be=g.current;_(XE);let ct=(async()=>{let ye,rt={...h!==null?{returnTo:h}:{},...u?{entry:"chat"}:{},...V!==null?{visitRef:V.visitRef}:{},...V!==null&&V.intent!==null&&V.intent!==void 0?{intent:V.intent}:{}},Dr=Object.keys(rt).length===0?void 0:rt,Nr=k===void 0?d:k;try{ye=await(Dr===void 0?be.createHandoff(Nr):be.createHandoff(Nr,Dr));}catch{return e.abandon(G.value),W("unknown",null)}let Ot=x.current;if(Ot.runtime!==ae.runtime||Ot.userRef!==ae.userRef||Ot.scopeEpoch!==ae.scopeEpoch)return e.abandon(G.value),W("cancelled",null);if(!ye.ok)return e.abandon(G.value),W(Ki(ye.error),ye.error);let Jt=await e.finish(G.value,ye.value);return Jt!==null?W(Jt,null):(_(qi),Object.freeze(ye.value.flowId===void 0?{opened:true}:{opened:true,flowId:ye.value.flowId}))})().finally(()=>{P.current===ct&&(P.current=null);});return P.current=ct,ct},[e,d,h,u]),M=react.useCallback((k,V)=>{if(!w.current)return _({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}));let W=k===void 0?d:k,G={...W!==null?{petRef:W}:{},...l!==null?{usState:l}:{},...V!==null?{visitRef:V.visitRef,intent:V.intent}:{}};return Mn(G)===null?(_({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}))):(_(qi),Promise.resolve(Object.freeze({opened:true})))},[d,l]),I=react.useCallback(k=>c?O(k,null):M(k,null),[c,O,M]),v=react.useCallback((k,V)=>c?O(void 0,{visitRef:k,intent:V??null}):M(void 0,{visitRef:k,intent:V??null}),[c,O,M]);return {available:R,isPending:s.isPending||(y?.pending??false),status:C.status,error:C.error,errorReason:C.errorReason,open:I,openVisit:v}}i(Yc,"useVetVisitWith");var JE=i(e=>reactNative.Linking.openURL(e),"defaultOpenUrl");function Dn(e={}){let{openUrl:t,...r}=e,n=react.useMemo(()=>{let o=t??JE;return {prepare:i(()=>({ok:true,value:null}),"prepare"),async finish(s,a){try{return await o(a.url),null}catch{return "openFailed"}},abandon:i(()=>{},"abandon")}},[t]);return Yc(n,r)}i(Dn,"useVetVisit");var Xc=44,oC=.6;function Kt(e){let{petRef:t,label:r,openUrl:n,onOpened:o,onError:s,style:a,labelStyle:l,controller:u,returnTo:d,usState:c,entry:p,visitRef:f,intent:m,onStartInApp:y,prefer:R}=e,h=R==="redirect",C=Dn({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...t!==void 0?{petRef:t}:{},...n!==void 0?{openUrl:n}:{},...u!==void 0?{controller:u}:{},prefer:h?"redirect":"in-app"}),_=F(),P=react.useMemo(()=>iC(_),[_]),x=react.useRef(false);if(!C.available)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[null,jsxRuntime.jsx(xr,{})]});let g=C.status==="opening",w=r??wc.visitButton;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.Pressable,{onPress:i(()=>{if(!(g||x.current)){if(!h){let M={...t!==void 0?{petRef:t}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:m??null}:{}};Mn(M,y)===null&&$(s,"unavailable",null);return}x.current=true,(f==null?C.open():C.openVisit(f,m??null)).then(M=>{M.opened?$(o,M.flowId??null):M.reason!=="cancelled"&&$(s,M.reason,M.error);}).finally(()=>{x.current=false;});}},"onPress"),accessibilityRole:"button",accessibilityLabel:w,accessibilityState:{busy:g,disabled:g},style:[P.button,g?P.busy:null,a],children:jsxRuntime.jsx(S,{style:[P.label,l],children:w})}),jsxRuntime.jsx(xr,{})]})}i(Kt,"VetVisitButton");function iC(e){let{color:t,space:r,radius:n,type:o,slots:s}=e;return reactNative.StyleSheet.create({button:{minHeight:Xc,minWidth:Xc,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...pe(s.vetVisitButton)},busy:{opacity:oC},label:{...T(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug,...Se(s.vetVisitButton)}})}i(iC,"makeStyles");function $i(e){return pr(e)==="cat"?"cat":"dog"}i($i,"speciesOf");function Yi(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}i(Yi,"petAgeYears");function ep(e){let t=Yi(e.ageYears),r=$i(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return `${r} \xB7 ${n}`}i(ep,"formatPetMeta");var Jc=Object.freeze([Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),Object.freeze({background:"#fbc558",foreground:"#10462e"}),Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function sC(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return Jc[t%Jc.length]}i(sC,"pickInitialsPalette");function Xi(e){let t=(e??"").trim();return (Array.from(t)[0]??"?").toUpperCase()}i(Xi,"getInitial");function tp(e){return {...sC(e.petRef),initial:Xi(e.name)}}i(tp,"petInitials");function dC(e){return Math.max(12,Math.round(e*.42))}i(dC,"letterSize");function wr({pet:e,size:t,ringStroke:r}){let n=F(),o=react.useMemo(()=>cC(n),[n]),s=t-r*2,a=e===null?null:tp(e),l=dC(s);return jsxRuntime.jsx(xn,{size:t,strokeWidth:r,color:n.color.success,children:jsxRuntime.jsx(reactNative.View,{style:[o.disc,{width:s,height:s,borderRadius:s/2},a===null?o.discEmpty:{backgroundColor:a.background}],children:jsxRuntime.jsx(S,{tier:"badge",style:[o.letter,{fontSize:l,lineHeight:Math.round(l*1.2),color:a===null?n.color.text.muted:a.foreground}],children:a===null?Xi(null):a.initial})})})}i(wr,"PetDisc");function cC(e){return reactNative.StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...T(e,"bold"),textAlign:"center",includeFontPadding:false}})}i(cC,"makeStyles");var Zi=48,op=2,hC=320,bC="80%",vC="rgba(17,17,17,0.45)",EC=18,rp=22,CC=12,np=.4,RC=44;function Ji(e){return e?.name?.trim()||b.yourPet}i(Ji,"petDisplayName");function ip({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:o=null,onClose:s}){let a=F(),l=react.useMemo(()=>SC(a),[a]);return e?jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:s,children:jsxRuntime.jsxs(reactNative.View,{style:l.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:xe,onPress:s,accessibilityRole:"button",accessibilityLabel:b.close,children:jsxRuntime.jsx(reactNative.View,{style:l.backdrop})}),jsxRuntime.jsxs(reactNative.View,{style:l.panel,accessibilityViewIsModal:true,children:[jsxRuntime.jsx(S,{tier:"heading",style:l.title,accessibilityRole:"header",children:b.yourPets}),jsxRuntime.jsx(reactNative.ScrollView,{style:l.list,contentContainerStyle:l.listContent,showsVerticalScrollIndicator:true,children:t.map(u=>{let d=u.petRef===r,c=Ji(u),p=ep(u);return jsxRuntime.jsxs(H,{accessibilityRole:"button",accessibilityLabel:q(d?b.petCurrentlyActive:b.switchToPet,{name:c}),accessibilityState:{selected:d},style:[l.row,d?l.rowActive:null],onPress:()=>n(u.petRef),children:[jsxRuntime.jsx(wr,{pet:u,size:Zi,ringStroke:op}),jsxRuntime.jsxs(reactNative.View,{style:l.copy,children:[jsxRuntime.jsx(S,{style:l.name,numberOfLines:1,children:c}),jsxRuntime.jsx(S,{tier:"compact",style:l.meta,numberOfLines:1,children:d?`${b.activePrefix}${p}`:p})]}),d?jsxRuntime.jsx(lt,{size:EC,color:a.color.brandInk}):null]},u.petRef)})}),o!==null?jsxRuntime.jsxs(H,{accessibilityRole:"button",accessibilityLabel:b.addAnotherPet,style:l.addRow,onPress:o,children:[jsxRuntime.jsx(reactNative.View,{style:l.addDisc,children:jsxRuntime.jsx(S,{tier:"control",style:l.addPlus,children:"+"})}),jsxRuntime.jsx(S,{style:l.addLabel,children:b.addAnotherPet})]}):null,jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:b.close,containerStyle:l.closeSlot,style:l.closeButton,onPress:s,children:jsxRuntime.jsx(S,{tier:"control",style:l.closeText,children:b.close})})]})]})}):null}i(ip,"PetSwitcherSheet");function SC(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:vC},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:rp,borderTopRightRadius:rp,gap:14,maxHeight:bC},title:{...T(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk},list:{maxHeight:hC,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:RC,paddingHorizontal:8},addDisc:{width:Zi,height:Zi,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:op,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...T(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...T(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary},row:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:r.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},rowActive:{borderColor:t.brandInk,backgroundColor:t.brandSoft},copy:{flex:1,gap:2},name:{...T(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...T(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:np},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:CC,backgroundColor:t.brandSoft},closeText:{...T(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:np}})}i(SC,"makeStyles");var kC=44,Un=36,xC=22,es=9,_C=1.5,ap=6,kt=35,Vn=1.75,ts=12.4,wC=.5,IC=8,AC=28,OC=160;function ns(e,t){return _c(e,t)}i(ns,"headerPet");function up({pets:e,petRef:t,historyUnread:r,onOpenHistory:n,onPetChange:o,onAddPet:s,vet:a}){let l=F(),u=react.useMemo(()=>MC(l),[l]),[d,c]=react.useState(false),p=ns(e.pets,t),f=e.pets.length>=2,m=t??p?.petRef??null,y=Ji(p),R=i(C=>{c(false),e.setActivePet(C),$(o,C);},"select"),h=s===void 0?null:()=>{c(false),$(s);};return jsxRuntime.jsxs(reactNative.View,{style:u.row,children:[jsxRuntime.jsxs(H,{accessibilityRole:"button",accessibilityLabel:r?b.openMenuUnread:b.openMenu,containerStyle:u.iconSlot,style:u.iconButton,onPress:n,children:[jsxRuntime.jsx(Bd,{size:xC,color:l.color.text.primary,strokeWidth:2}),r?jsxRuntime.jsx(reactNative.View,{style:u.unreadDot,pointerEvents:"none"}):null]}),jsxRuntime.jsx(reactNative.View,{style:u.center,pointerEvents:"box-none",children:jsxRuntime.jsx(FC,{logoUrl:l.meta.logoUrl,name:l.meta.displayName,styles:u})}),m===null?null:jsxRuntime.jsx(Kt,{entry:"chat",petRef:m,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:u.vetEntry,labelStyle:u.vetEntryLabel}),jsxRuntime.jsx(reactNative.View,{style:u.right,children:f?jsxRuntime.jsxs(H,{accessibilityRole:"button",accessibilityLabel:q(b.switchActivePet,{name:y}),containerStyle:u.avatarSlot,style:u.avatarWrap,onPress:()=>c(true),children:[jsxRuntime.jsx(wr,{pet:p,size:kt,ringStroke:Vn}),jsxRuntime.jsx(reactNative.View,{style:u.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:jsxRuntime.jsx(zd,{size:IC,color:l.color.brandInk,strokeWidth:2})})]}):e.loading&&p===null?jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityLabel:b.yourPet,children:jsxRuntime.jsx(xn,{size:kt,strokeWidth:Vn,color:l.color.success,children:jsxRuntime.jsx(reactNative.View,{style:u.placeholderDisc})})}):jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:p===null?b.yourPet:y,children:jsxRuntime.jsx(wr,{pet:p,size:kt,ringStroke:Vn})})}),jsxRuntime.jsx(ip,{visible:d,pets:e.pets,activePetRef:p?.petRef??null,onSelect:R,onAddPet:h,onClose:()=>c(false)})]})}i(up,"ChatHeader");function FC({logoUrl:e,name:t,styles:r}){let[n,o]=react.useState(null);return e===null||n===e?null:jsxRuntime.jsx(reactNative.View,{style:r.logoBar,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:r.logo,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:()=>o(e)})})}i(FC,"BrandLogo");function MC(e){let t=e.color,r=kt-Vn*2;return reactNative.StyleSheet.create({vetEntry:{minHeight:kC,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},vetEntryLabel:{...T(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingVertical:10,backgroundColor:t.surface},iconSlot:{borderRadius:Un/2},iconButton:{width:Un,height:Un,borderRadius:Un/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:ap,right:ap,width:es,height:es,borderRadius:es,backgroundColor:t.danger,borderWidth:_C,borderColor:t.surface},center:{...xe,alignItems:"center",justifyContent:"center"},logoBar:{alignItems:"center",paddingHorizontal:e.space.lg},logo:{height:AC,width:OC},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:kt/2},avatarWrap:{width:kt,height:kt,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:ts,height:ts,borderRadius:ts/2,borderWidth:wC,borderColor:t.success,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}i(MC,"makeStyles");var pp=44,VC="rgba(17,17,17,0.55)",fp=26,BC=36,mp=4,os=20,is=38,HC=18,zC=12;function yp({visible:e,onSubmit:t,onSkip:r}){let n=F(),o=react.useMemo(()=>jC(n),[n]),[s,a]=react.useState(null),[l,u]=react.useState(""),[d,c]=react.useState(false),[p,f]=react.useState(false),m=i(()=>{a(null),u(""),c(false),f(false);},"reset"),y=i(()=>{d||(m(),r());},"skip"),R=i(async()=>{if(d)return;c(true),f(false);let C=l.trim();await t(s,C.length>0?C:null)?m():(c(false),f(true));},"submit");if(!e)return null;let h=[...l].length>Dt;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:n.motion.reducedMotion?"none":"slide",onRequestClose:y,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:reactNative.Platform.OS==="ios"?"padding":void 0,style:o.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:o.scrim,onPress:y,accessibilityRole:"button",accessibilityLabel:b.feedbackSkipA11y}),jsxRuntime.jsxs(reactNative.View,{style:o.sheet,accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[jsxRuntime.jsx(reactNative.View,{style:o.handle}),jsxRuntime.jsxs(reactNative.View,{style:o.header,children:[jsxRuntime.jsx(reactNative.View,{style:o.iconBadge,children:jsxRuntime.jsx(kn,{size:HC,color:n.color.brandInk,active:false,rotate:"180deg"})}),jsxRuntime.jsxs(reactNative.View,{style:o.headerText,children:[jsxRuntime.jsx(S,{tier:"heading",style:o.title,accessibilityRole:"header",children:b.feedbackTitle}),jsxRuntime.jsx(S,{style:o.subtitle,children:b.feedbackSubtitle})]})]}),jsxRuntime.jsx(reactNative.View,{style:o.options,children:yi.map(C=>{let _=s===C.key;return jsxRuntime.jsxs(H,{accessibilityRole:"button",accessibilityLabel:C.label,accessibilityState:{selected:_},style:[o.option,_?o.optionSelected:null],onPress:()=>a(P=>P===C.key?null:C.key),children:[jsxRuntime.jsx(S,{style:[o.optionLabel,_?o.optionLabelSelected:null],children:C.label}),jsxRuntime.jsx(reactNative.View,{style:[o.radio,_?o.radioSelected:null],children:_?jsxRuntime.jsx(lt,{size:zC,color:n.color.surface,strokeWidth:2}):null})]},C.key)})}),jsxRuntime.jsxs(reactNative.View,{style:o.inputWrap,children:[jsxRuntime.jsx(Ht,{style:o.input,placeholder:b.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:b.feedbackNotesPlaceholder,value:l,onChangeText:u,multiline:true,editable:!d}),l.length>0?jsxRuntime.jsx(S,{tier:"compact",style:[o.counter,h?o.counterOver:null],children:`${[...l].length}/${Dt}`}):null]}),p?jsxRuntime.jsx(S,{style:o.failed,accessibilityRole:"alert",children:b.feedbackFailed}):null,jsxRuntime.jsxs(reactNative.View,{style:o.actions,children:[jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:b.feedbackSubmit,accessibilityState:{busy:d,disabled:d||h},disabled:d||h,style:[o.submit,d||h?o.submitDisabled:null],onPress:()=>{R();},children:jsxRuntime.jsx(S,{tier:"control",style:o.submitLabel,children:b.feedbackSubmit})}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:b.feedbackSkipA11y,hitSlop:8,onPress:y,style:o.skip,children:jsxRuntime.jsx(S,{tier:"control",style:o.skipLabel,children:b.feedbackSkip})})]})]})]})})}i(yp,"FeedbackReasons");function jC(e){let t=e.color,r=e.type,n=e.radius,o=e.slots;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...xe,backgroundColor:VC},sheet:{backgroundColor:t.surface,borderTopLeftRadius:fp,borderTopRightRadius:fp,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14},handle:{alignSelf:"center",width:BC,height:mp,borderRadius:mp/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:is,height:is,borderRadius:is/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...T(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight},subtitle:{...T(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,backgroundColor:t.surface},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...T(e,"medium"),fontSize:r.size.body,color:t.text.primary},optionLabelSelected:{color:t.brandInk},radio:{width:os,height:os,borderRadius:os/2,borderWidth:2,borderColor:t.brandBorderStrong,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...T(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top"},counter:{...T(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...T(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},actions:{gap:10,alignItems:"center"},submit:{alignSelf:"stretch",minHeight:pp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...pe(o.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...T(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...Se(o.primaryButton)},skip:{minHeight:pp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...T(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}i(jC,"makeStyles");var oR=.88,iR=420,sR=58,aR="rgba(17,17,17,0.28)",lR=.08,uR=.1,dR=.08,cR=.18,pR=.78,fR=.7,ss=36,mR=10,yR=14,gR=12,hR=16,bR=14,as=8,vR=1.5,ER=.5,CR=wn(Tr.standard);function RR(e){return Math.min(Math.round(e*oR),iR)}i(RR,"drawerPanelWidth");function gp({chat:e,history:t}){let[r,n]=react.useState(t.open),o=react.useCallback(()=>n(false),[]);return t.open&&!r&&n(true),r?jsxRuntime.jsx(SR,{chat:e,history:t,onHidden:o}):null}i(gp,"HistoryDrawer");function SR({chat:e,history:t,onHidden:r}){let n=F(),o=react.useMemo(()=>PR(n),[n]),s=J(),a=reactNativeSafeAreaContext.useSafeAreaInsets(),{width:l}=reactNative.useWindowDimensions(),u=RR(l),d=t.open,c=react.useRef(null);c.current===null&&(c.current=new reactNative.Animated.Value(s.drawerMs<=0&&d?1:0));let p=c.current;react.useEffect(()=>{if(!d&&s.drawerMs<=0){r();return}let C=reactNative.Animated.timing(p,{toValue:d?1:0,duration:s.drawerMs,easing:CR,useNativeDriver:true});return C.start(({finished:_})=>{_&&!d&&r();}),()=>C.stop()},[d,p,s.drawerMs,r]);let f=p.interpolate({inputRange:[0,1],outputRange:[-u,0]}),m=t.filtered,y=t.rows.length===0,R=y&&t.loading?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,accessibilityLabel:te.loading,accessibilityState:{busy:true},children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{color:o.emptyTitle.color}),jsxRuntime.jsx(S,{style:o.emptyBody,children:te.loading})]}):y&&t.error!==null?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(S,{style:o.emptyTitle,accessibilityRole:"alert",children:te.loadFailed}),jsxRuntime.jsx(S,{style:o.emptyBody,children:t.error}),jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:te.retryA11y,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load();},children:jsxRuntime.jsx(S,{tier:"control",style:o.retryText,children:te.retry})})]}):jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(S,{style:o.emptyTitle,children:t.emptyKind==="empty"?te.empty:te.noMatch}),jsxRuntime.jsx(S,{style:o.emptyBody,children:t.emptyKind==="empty"?te.emptyBody:te.noMatchBody})]}),h=!t.searching&&t.loadingMore?jsxRuntime.jsx(reactNative.View,{style:o.loadMoreFooter,children:jsxRuntime.jsx(S,{style:o.loadMoreLabel,children:te.loadingMore})}):null;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:"none",onRequestClose:t.close,children:jsxRuntime.jsxs(reactNative.View,{style:o.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:xe,onPress:t.close,accessibilityRole:"button",accessibilityLabel:te.closeA11y,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[o.backdrop,{opacity:p}]})}),jsxRuntime.jsx(reactNative.Animated.View,{style:[o.panel,{width:u,paddingTop:Math.max(sR,a.top+n.space.md),transform:[{translateX:f}]}],accessibilityViewIsModal:true,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:o.keyboardAvoider,behavior:reactNative.Platform.OS==="ios"?"padding":"height",children:[jsxRuntime.jsxs(reactNative.View,{style:o.searchRow,children:[jsxRuntime.jsxs(reactNative.View,{style:o.searchPill,children:[jsxRuntime.jsx(Xd,{size:bR,color:n.color.text.muted,strokeWidth:1.5}),jsxRuntime.jsx(Ht,{value:t.query,onChangeText:C=>t.setQuery(C.replace(/^\s+/,"")),style:o.searchInput,placeholder:te.search,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:te.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:te.newConversation,style:o.newButton,onPress:t.newConversation,children:jsxRuntime.jsx(Qd,{size:hR,color:n.color.text.primary,strokeWidth:1.5})})]}),jsxRuntime.jsx(S,{tier:"heading",style:o.heading,accessibilityRole:"header",children:te.heading}),t.error!==null&&!y?jsxRuntime.jsx(reactNative.View,{style:o.errorCard,children:jsxRuntime.jsx(S,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,jsxRuntime.jsx(reactNative.FlatList,{data:m,keyExtractor:C=>C.id,renderItem:({item:C})=>jsxRuntime.jsx(TR,{row:C,active:C.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(C.id);}}),contentContainerStyle:m.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:R,ListFooterComponent:h,onEndReached:t.loadMore,onEndReachedThreshold:ER})]})})]})})}i(SR,"DrawerModal");function TR({row:e,active:t,disabled:r,styles:n,onPress:o}){let s=e.unreadCount!==null&&e.unreadCount>0;return jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:Pd(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:o,children:jsxRuntime.jsxs(reactNative.View,{style:n.itemRow,children:[jsxRuntime.jsx(S,{style:[n.itemTitle,s?n.itemTitleUnread:null],numberOfLines:1,children:Rn(e.title)}),s?jsxRuntime.jsx(reactNative.View,{style:n.unreadDot}):null]})})}i(TR,"Row");function zn(e,t){if(!/^#[0-9a-f]{6}$/i.test(e))return "transparent";let r=Math.round(Math.min(1,Math.max(0,t))*255);return `${e}${r.toString(16).padStart(2,"0").toUpperCase()}`}i(zn,"inkWash");function PR(e){let t=e.color,r=e.slots,n=!Ul(e),o=n?t.onPrimary:t.text.primary;return reactNative.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:aR},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:n?t.brand:t.surface,paddingHorizontal:16,borderRightWidth:.5,borderRightColor:t.brandBorder,gap:12},keyboardAvoider:{flex:1,gap:12},searchRow:{flexDirection:"row",alignItems:"center",gap:10},searchPill:{flex:1,flexDirection:"row",alignItems:"center",gap:8,borderRadius:e.radius.pill,backgroundColor:t.surface,paddingHorizontal:14,paddingVertical:10,borderWidth:1,borderColor:zn(o,uR)},searchInput:{...T(e,"regular"),flex:1,fontSize:13,lineHeight:16,color:t.text.primary,padding:0},newButton:{width:ss,height:ss,borderRadius:ss/2,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},heading:{...T(e,"bold"),fontSize:14,lineHeight:17,color:o,marginTop:4},list:{gap:10,paddingBottom:28},listEmpty:{flexGrow:1},item:{paddingVertical:12,paddingHorizontal:4,borderRadius:mR},itemActive:{backgroundColor:zn(o,lR)},itemRow:{flexDirection:"row",alignItems:"center",gap:8},itemTitle:{...T(e,"regular"),flex:1,fontSize:14,lineHeight:18,color:o},itemTitleUnread:T(e,"bold"),unreadDot:{width:as,height:as,borderRadius:as/2,backgroundColor:t.danger,borderWidth:vR,borderColor:o},errorCard:{borderRadius:gR,borderWidth:.5,borderColor:t.danger,backgroundColor:t.surface,padding:12},errorText:{...T(e,"regular"),fontSize:11,lineHeight:16,color:t.danger},emptyCard:{borderRadius:yR,padding:14,gap:6,backgroundColor:zn(o,dR),borderWidth:.5,borderColor:zn(o,cR)},emptyTitle:{...T(e,"bold"),fontSize:12,lineHeight:15,color:o},emptyBody:{...T(e,"regular"),fontSize:11,lineHeight:17,color:o,opacity:pR},retrySlot:{marginTop:8,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:7,borderWidth:1,borderColor:o,...pe(r.primaryButton)},retryText:{...T(e,"bold"),fontSize:12,lineHeight:15,color:o,...Se(r.primaryButton)},loadMoreFooter:{paddingVertical:14,alignItems:"center"},loadMoreLabel:{...T(e,"regular"),fontSize:11,lineHeight:14,color:o,opacity:fR}})}i(PR,"makeStyles");var AR=Object.freeze({}),OR=100,FR=20;function MR(e,t,r,n){return ![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}i(MR,"readWindowTops");function hp(e,t){let r=typeof e=="number"&&Number.isFinite(e),n=react.useRef(null),[o,s]=react.useState(null),a=react.useRef(null),l=react.useRef(null),u=react.useRef(true),d=react.useCallback(()=>{l.current!==null&&clearTimeout(l.current),l.current=null;},[]);react.useEffect(()=>(u.current=true,()=>{u.current=false,d();}),[d]);let c=react.useCallback(i(function f(m){n.current?.measureInWindow((y,R)=>{let h=a.current;if(!u.current||h===null)return;let C=MR(R,h.y,h.height,reactNative.Dimensions.get("window").height);if(C!==null){s(_=>_!==null&&_.chatTop===C.chatTop&&_.parentTop===C.parentTop?_:C);return}m>=FR||(l.current=setTimeout(()=>{l.current=null,f(m+1);},OR));});},"measureAt"),[]),p=react.useCallback(f=>{let{y:m,height:y}=f.nativeEvent.layout;a.current={y:m,height:y},d(),c(0);},[c,d]);return react.useMemo(()=>{if(!t)return {avoidingProps:r?{keyboardVerticalOffset:e}:AR,probeRef:null,topInWindow:null};let f=o?.parentTop??0;return {avoidingProps:r?{keyboardVerticalOffset:e,onLayout:p}:f>0?{keyboardVerticalOffset:f,onLayout:p}:{onLayout:p},probeRef:n,topInWindow:o?.chatTop??null}},[t,r,e,o,p])}i(hp,"useChatKeyboardOffset");function bp({probeRef:e}){return e===null?null:jsxRuntime.jsx(reactNative.View,{ref:e,collapsable:false,pointerEvents:"none",style:LR})}i(bp,"KeyboardOffsetProbe");var LR=Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function vp(e,t){let r={entry:"chat",petRef:e};return t?.returnTo!==void 0&&(r.returnTo=t.returnTo),t?.usState!==void 0&&(r.usState=t.usState),t?.prefer!==void 0&&(r.prefer=t.prefer),r}i(vp,"chatVetVisitOptions");var BR=16,HR=.75,us=12,Ep=15,zR=18,Wn=22,jR=14,WR=8,GR=20,KR=10,qR=13;function Rp({surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o}){let s=F(),a=react.useMemo(()=>$R(s),[s]),l=J(),u=e.tier,d=e.source;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Oi,{visible:e.showBanner&&u!==null,inMs:l.bannerInMs,outMs:l.bannerOutMs,style:a.pinned,children:u!==null&&d!==null?jsxRuntime.jsxs(reactNative.View,{accessibilityRole:"alert",style:[a.card,{borderColor:u.borderColor,backgroundColor:u.backgroundColor}],children:[jsxRuntime.jsx(S,{tier:"compact",style:[a.label,{color:u.textColor}],children:u.label}),d.reason!==null?jsxRuntime.jsx(S,{style:[a.reason,{color:u.reasonColor}],children:d.reason}):null,e.showVetAction?r!==void 0?jsxRuntime.jsx(Rt,{render:()=>r(u.level),fallback:jsxRuntime.jsx(Cp,{tier:u,petRef:t,onFindVet:n,vet:o,styles:a}),resetKey:u.level}):jsxRuntime.jsx(Cp,{tier:u,petRef:t,onFindVet:n,vet:o,styles:a}):null,e.dismissLabel!==null?jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:e.dismissLabel,hitSlop:WR,containerStyle:a.closeSlot,style:a.closeButton,onPress:e.dismiss,children:jsxRuntime.jsx(St,{size:jR,color:u.textColor,strokeWidth:1.5})}):null]}):null}),jsxRuntime.jsx(Oi,{visible:e.showCompactIcon,inMs:l.iconInMs,outMs:l.iconOutMs,style:a.indicatorRow,children:jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:b.showLatestVetAlert,hitSlop:KR,onPress:e.expand,children:jsxRuntime.jsx(Kd,{size:GR,color:s.color.text.muted,strokeWidth:2})})})]})}i(Rp,"UrgencyBanner");function Cp({tier:e,petRef:t,onFindVet:r,vet:n,styles:o}){let s=F(),a=Dn(vp(t,n)),l=a.status==="opening",u=a.available?()=>{a.open();}:r!==void 0?()=>{$(r,e.level);}:null;if(u===null)return null;let d=Bi(s.slots.vetVisitButton)?.textColor??e.textColor;return jsxRuntime.jsxs(H,{accessibilityRole:"button",accessibilityLabel:b.findVetA11y,accessibilityState:{busy:l},containerStyle:o.findVetSlot,style:[o.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},o.findVetSlotBox,l?o.findVetBusy:null],onPress:u,children:[jsxRuntime.jsx(Zd,{size:qR,color:d,strokeWidth:1.5}),jsxRuntime.jsx(S,{tier:"control",style:[o.findVetLabel,{color:d}],children:b.findVet})]})}i(Cp,"VetAction");function $R(e){let t=Bi(e.slots.vetVisitButton);return reactNative.StyleSheet.create({pinned:{marginTop:0,marginBottom:4,paddingHorizontal:e.space.lg},card:{borderRadius:BR,borderWidth:HR,paddingHorizontal:14,paddingVertical:8,gap:2},label:{...T(e,"monoBold"),fontSize:us,lineHeight:Ep},reason:{...T(e,"regular"),fontSize:us,lineHeight:zR,paddingRight:Wn},findVetSlot:{alignSelf:"flex-start",marginTop:6},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...pe(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...T(e,"monoBold"),fontSize:us,lineHeight:Ep},closeSlot:{position:"absolute",top:6,right:6},closeButton:{width:Wn,height:Wn,borderRadius:Wn/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:16,paddingTop:2,paddingBottom:4}})}i($R,"makeStyles");function Sp(){let e=On(),{handle:t}=Z(),r=react.useCallback(n=>t.setActivePet(n),[t]);return react.useMemo(()=>({...e,setActivePet:r}),[e,r])}i(Sp,"useChatPets");var Ap=300,Op=3e3,Pp=120,$t=44,JR=120,eS="86%",cs=15,kp=22,Or=.5,tS=.04,rS=8,nS=2,oS=1,iS=.6,sS=22,aS=48,xp=1.25,lS=14,uS=18,dS=6,cS=14,pS=.04,fS=12,mS=2,yS=2,_p=36,wp=20,qt=36,Yt=($t-qt)/2,Fp=24,Mp=22,gS=.4,Gn=30,Lp=20,hS=.4,bS=480,vS=8,Ip=14,ES=10,CS=14,RS=12,SS=13,TS=18,PS="12%";function Pe(){let e=F(),t=react.useMemo(()=>kS(e),[e]);return {theme:e,styles:t}}i(Pe,"useChatTheme");function kS(e){let t=e.color,r=e.space,n=e.radius,o=e.type,s=o.size.body/Ce.type.size.body,a=s===1?kp:Math.round(kp*s),l=s===1?wp:Math.round(wp*s),u=e.slots;return reactNative.StyleSheet.create({container:{flex:1,minHeight:Pp,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:Pp,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},emptyContent:{flexGrow:1,alignItems:"center",justifyContent:"flex-start",paddingTop:PS,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:bS,gap:18},errorText:{...T(e,"regular"),fontSize:o.size.subtitle,lineHeight:o.size.subtitle*o.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:$t,minWidth:$t,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...pe(u.primaryButton)},retryLabel:{...T(e,"medium"),color:t.onPrimary,fontSize:o.size.body,...Se(u.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...T(e,"regular"),color:t.danger,fontSize:o.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.lg,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...T(e,"bold"),color:t.text.primary,fontSize:o.size.body},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...T(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal},turnNoticeAction:{minHeight:$t,justifyContent:"center"},turnNoticeActionLabel:{...T(e,"medium"),color:t.brandInk,fontSize:o.size.body},setupNoticeAction:{...T(e,"medium"),color:t.brandInk,fontSize:o.size.caption},reconnectingCaption:{...T(e,"medium"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},list:{flex:1},listContent:{padding:r.lg,gap:r.md},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:eS},bubbleUser:{padding:cs,backgroundColor:t.bubbleUser,borderRadius:n.xl,borderBottomRightRadius:n.sm,borderWidth:Or,borderColor:t.accentEdge,shadowColor:t.brand,shadowOpacity:tS,shadowRadius:rS,shadowOffset:{width:0,height:nS},elevation:oS,...pe(u.userBubble,Or)},bubbleAssistant:u.assistantBubble?.backgroundColor===void 0?{...pe(u.assistantBubble,Or)}:{padding:cs,borderRadius:n.xl,...pe(u.assistantBubble,Or)},bubbleVet:{padding:cs,backgroundColor:t.bubbleVet,borderRadius:n.xl,borderBottomLeftRadius:n.sm,...pe(u.vetBubble,Or)},bubblePending:{opacity:iS},bubbleTextUser:{...T(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:a,...Se(u.userBubble)},bubbleTextAssistant:{...T(e,"medium"),color:t.text.primary,fontSize:o.size.body,lineHeight:a,...Se(u.assistantBubble)},bubbleTextVet:{...T(e,"medium"),color:t.onBubbleVet,fontSize:o.size.body,lineHeight:a,...Se(u.vetBubble)},vetSender:{...T(e,"bold"),color:t.onBubbleVet,fontSize:o.size.caption,lineHeight:Math.round(o.size.caption*o.lineHeight.normal),marginBottom:r.xs,...Se(u.vetBubble)},bubbleBold:T(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:T(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.sm,gap:vS},followUpSlot:{alignSelf:"stretch",borderRadius:Ip},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:RS,paddingVertical:ES,paddingHorizontal:CS,borderRadius:Ip,backgroundColor:t.brandSoft},followUpText:{...T(e,"medium"),flex:1,color:t.text.primary,fontSize:SS,lineHeight:TS},composerOuter:{position:"relative"},composer:{marginHorizontal:r.md,marginTop:r.xs,marginBottom:r.sm,minHeight:aS,justifyContent:"center",paddingLeft:lS,paddingRight:uS,paddingVertical:dS,backgroundColor:t.composerFill,borderWidth:xp,borderColor:t.composerBorder,borderRadius:sS,shadowColor:t.shadow,shadowOpacity:pS,shadowRadius:fS,shadowOffset:{width:0,height:mS},elevation:yS,...pe(u.composerInput,xp)},composerRow:{flexDirection:"row",alignItems:"center",gap:cS,minHeight:_p},attachControl:{width:Gn,height:Gn,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:hS},input:{flex:1,minHeight:_p,maxHeight:JR,paddingHorizontal:0,paddingVertical:0,...T(e,"regular"),fontSize:o.size.body,lineHeight:l,color:t.text.primary,...Se(u.composerInput)},sendControl:{minHeight:qt,minWidth:qt,alignItems:"center",justifyContent:"center"},sendDisc:{width:qt,height:qt,borderRadius:qt/2,alignItems:"center",justifyContent:"center",...pe(u.sendButton)},sendControlDisabled:{opacity:gS},poweredBy:{...T(e,"regular"),color:t.text.muted,fontSize:o.size.micro,textAlign:"center",paddingBottom:r.xs}})}i(kS,"makeStyles");var xS=Object.freeze({kind:"live"}),_S=Object.freeze({kind:"folded"});function ps(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=Co(e.proactiveOriginRef);return {caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}i(ps,"askOf");function Np(e){let t=new Map,r=new Map;for(let o of e){let s=ps(o);if(s===null)continue;let a=r.get(s.caseId);(a===void 0||s.dueDay>=a.dueDay)&&r.set(s.caseId,{messageId:o.id,dueDay:s.dueDay});}if(r.size===0)return t;let n=null;for(let o of e){let s=ps(o);if(s===null){n=null;continue}if(r.get(s.caseId)?.messageId===o.id){t.set(o.id,xS),n=null;continue}if(n!==null&&n.caseId===s.caseId){n.days.push(s.dueDay),t.set(o.id,_S);continue}let a=[s.dueDay];n={id:o.id,caseId:s.caseId,days:a},t.set(o.id,{kind:"past",runDueDays:a});}return t}i(Np,"placeCheckins");var Dp=864e5,wS=365;function Kn(e,t){if(typeof e!="string"||typeof t!="string")return null;let r=Date.parse(e),n=Date.parse(t);if(Number.isNaN(r)||Number.isNaN(n))return null;let o=Math.floor(n/Dp)-Math.floor(r/Dp);return o<1||o>wS?null:o}i(Kn,"checkinDayNumber");function Up(e){return ps(e)?.dueDay||null}i(Up,"checkinDueDay");var _e=Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" \xB7 ",answers:Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),Vp=Object.freeze(Xr.map(e=>Object.freeze({answer:e,label:_e.answers[e]})));function Bp(e,t){let[r,n]=react.useState(null),[o,s]=react.useState(null),[a,l]=react.useState(null),u=react.useCallback(c=>{t!==null&&(n(c),s(null),t(e.caseId,c).then(p=>{n(null),p.ok?l(c):s(p.error);}));},[t,e.caseId]),d=a??e.answer;return {answer:d,answerable:!Aa(e),escalated:d==="worse",pending:r,error:o,choose:u}}i(Bp,"useCheckinCard");var jp=44,OS=.6;function Gp({message:e,checkin:t,onAnswer:r,petRef:n,onFindVet:o,vet:s,onLayout:a}){let l=F(),u=react.useMemo(()=>FS(l),[l]),d=Bp(t,r),c=d.answer!==null||d.pending!==null,p=r!==null&&d.answerable,f=Kn(t.openedAt,Up(e));return jsxRuntime.jsxs(reactNative.View,{style:u.card,accessibilityLabel:_e.eyebrow,onLayout:a,children:[jsxRuntime.jsxs(reactNative.View,{style:u.head,children:[jsxRuntime.jsx(S,{tier:"compact",style:u.eyebrow,children:_e.eyebrow}),f!==null?jsxRuntime.jsx(S,{tier:"compact",style:u.headDay,children:q(_e.day,{day:f})}):null]}),jsxRuntime.jsx(S,{style:u.question,accessibilityRole:"text",children:e.text}),p?jsxRuntime.jsx(reactNative.View,{style:[u.row,d.pending?u.rowPending:null],children:Vp.map(({answer:m,label:y})=>{let R=(d.pending??d.answer)===m;return jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>d.choose(m),disabled:c,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{selected:R,disabled:c,busy:d.pending===m},style:[u.pill,R?u.pillSelected:null],children:jsxRuntime.jsx(S,{tier:"control",style:[u.pillLabel,R?u.pillLabelSelected:null],children:y})},m)})}):null,d.answer!==null?jsxRuntime.jsx(S,{style:u.logged,children:_e.logged}):null,d.escalated?o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:_e.findVet,style:u.findVet,children:jsxRuntime.jsx(S,{tier:"control",style:u.findVetLabel,children:_e.findVet})}):n?jsxRuntime.jsx(Kt,{entry:"chat",petRef:n,label:_e.findVet,...s?.returnTo!==void 0?{returnTo:s.returnTo}:{},...s?.usState!==void 0?{usState:s.usState}:{},...s?.prefer!==void 0?{prefer:s.prefer}:{},style:u.findVet,labelStyle:u.findVetLabel}):null:null,t.resolutionText?jsxRuntime.jsx(S,{style:u.resolution,children:t.resolutionText}):null,d.error?jsxRuntime.jsx(S,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}i(Gp,"CheckinCard");function FS(e){let t=e.color,r=e.space,n=e.radius,o=e.type;return reactNative.StyleSheet.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...T(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},headDay:{...T(e,"bold"),color:t.text.primary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},question:{...T(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:OS},pill:{flex:1,minHeight:jp,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brandInk},pillLabel:{...T(e,"regular"),color:t.text.primary,fontSize:o.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...T(e,"regular"),color:t.text.secondary,fontSize:o.size.caption},resolution:{...T(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},error:{...T(e,"regular"),color:t.danger,fontSize:o.size.caption},findVet:{alignSelf:"stretch",minHeight:jp,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.brandBorder,backgroundColor:t.surface},findVetLabel:{...T(e,"bold"),color:t.brandInk,fontSize:o.size.body}})}i(FS,"makeStyles");var DS=1.5,NS=3;function qp({text:e,runDueDays:t,openedAt:r,onLayout:n}){let o=F(),s=react.useMemo(()=>US(o),[o]),a=t.map(u=>Kn(r,u)).filter(u=>u!==null),l=t.length>1;return l&&a.length===0?null:jsxRuntime.jsxs(reactNative.View,{style:s.row,onLayout:n,children:[jsxRuntime.jsx(reactNative.View,{style:s.rule,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}),jsxRuntime.jsxs(reactNative.View,{style:s.body,children:[a.length>0?jsxRuntime.jsx(S,{tier:"compact",style:s.days,children:a.map(u=>q(_e.day,{day:u})).join(_e.daySeparator)}):null,l?null:jsxRuntime.jsx(S,{style:s.question,accessibilityRole:"text",children:e})]})]})}i(qp,"CheckinPastAsk");function US(e){let t=e.color,r=e.space,n=e.type;return reactNative.StyleSheet.create({row:{flexDirection:"row",paddingVertical:r.xs},rule:{width:DS,borderRadius:1,backgroundColor:t.borderHairlineGreen,marginRight:r.md},body:{flex:1,gap:NS},days:{...T(e,"monoMedium"),fontSize:n.size.nano,letterSpacing:n.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},question:{...T(e,"regular"),fontSize:n.size.bodyTight,lineHeight:n.size.bodyTight*n.lineHeight.normal,color:t.text.muted}})}i(US,"makeStyles");var VS=Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),$p="#C8BEB4";function BS(e){return e?VS[e.toUpperCase()]??$p:$p}i(BS,"tierColor");function HS(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}i(HS,"tierLabel");function je(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(je,"text");function zS(e){let t=je(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}i(zS,"httpsUrl");function jS(e,t){let r=je(e.source_name)??je(e.sourceName),n=je(e.section),o=je(e.authority_tier)??je(e.authorityTier),s=HS(o),a=r??je(e.title)??`Source ${t+1}`,l=je(e.monograph_chunk_id)??je(e.chunkId),u=[n,s].filter(d=>d!==null).join(" \xB7 ");return Object.freeze({title:a,sourceName:r,section:n,authorityTier:o,tierLabel:s,meta:u.length===0?null:u,url:zS(e.url),excerpt:je(e.excerpt),tierColor:BS(o),key:`${a}-${l??"none"}-${t}`})}i(jS,"toCitationCard");function Yp(e){return e===void 0||e.length===0?WS:Object.freeze(e.map((t,r)=>jS(t,r)))}i(Yp,"toCitationCards");var WS=Object.freeze([]);function hs(e){return e===1?`1 ${b.sourceSingular}`:`${e} ${b.sourcePlural}`}i(hs,"sourcesLabel");function Xp(e,t){return `${t?b.hideSources:b.showSources} ${hs(e)}`}i(Xp,"sourcesToggleLabel");function Qp(e){return [e.url!==null?`${b.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(t=>t!==null&&t.length>0).join(". ")}i(Qp,"citationA11yLabel");var YS=244,Jp=8,ef=13,XS=14,QS=.3,ZS=-0.24,JS=22,eT=10,tT=15;function tf({citations:e,onOpenUrl:t}){let r=F(),n=react.useMemo(()=>oT(r),[r]),o=react.useMemo(()=>Yp(e),[e]),[s,a]=react.useState(false);if(o.length===0)return null;let l=o.length;return jsxRuntime.jsxs(reactNative.View,{style:n.block,children:[jsxRuntime.jsxs(H,{accessibilityRole:"button",accessibilityLabel:Xp(l,s),accessibilityState:{expanded:s},containerStyle:n.toggleSlot,style:n.togglePill,onPress:()=>a(u=>!u),children:[jsxRuntime.jsx(jd,{size:ef,color:r.color.brandInk,strokeWidth:1.5}),jsxRuntime.jsx(S,{tier:"compact",style:n.toggleLabel,children:hs(l)}),jsxRuntime.jsx(Pn,{size:ef,color:r.color.brandInk,strokeWidth:1.5,direction:s?"up":"down"})]}),s?jsxRuntime.jsx(rT,{cards:o,styles:n,open:t}):null]})}i(tf,"CitationCards");function rT({cards:e,styles:t,open:r}){let n=J(),o=Tt(n.citationsInMs,{risePx:n.citationsRisePx});return jsxRuntime.jsx(reactNative.Animated.View,{style:o,children:jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(s=>jsxRuntime.jsx(nT,{card:s,styles:t,open:r},s.key))})})}i(rT,"Deck");function nT({card:e,styles:t,open:r}){let n=F(),o=e.url!==null&&r!==void 0,s=Qp(o?e:{...e,url:null}),a=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:t.cardHeader,children:[jsxRuntime.jsx(reactNative.View,{style:[t.tierDot,{backgroundColor:e.tierColor}]}),jsxRuntime.jsx(S,{style:[t.cardTitle,o?t.cardTitleLink:null],numberOfLines:2,children:e.title}),o?jsxRuntime.jsx(Wd,{size:XS,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?jsxRuntime.jsx(S,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?jsxRuntime.jsx(S,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let l=e.url;return jsxRuntime.jsx(H,{accessibilityRole:"link",accessibilityLabel:s,style:t.card,onPress:()=>r(l),children:a})}return jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:s,style:t.card,children:a})}i(nT,"Card");function oT(e){let t=e.color,r=e.space,n=e.radius,o=e.type.size;return reactNative.StyleSheet.create({block:{gap:r.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:n.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:r.xs+2,paddingHorizontal:r.md,paddingVertical:r.xs+2,borderRadius:n.pill,backgroundColor:t.brandSoft},toggleLabel:{...T(e,"monoBold"),fontSize:o.micro,lineHeight:o.micro,letterSpacing:QS,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:YS,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:Jp,height:Jp,borderRadius:n.pill},cardTitle:{...T(e,"bold"),flex:1,fontSize:o.bodyTight,lineHeight:JS,color:t.text.primary,letterSpacing:ZS},cardTitleLink:{color:t.linkInk},cardMeta:{...T(e,"monoMedium"),fontSize:o.nano,lineHeight:eT,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},cardExcerpt:{...T(e,"regular"),fontSize:o.tiny,lineHeight:tT,color:t.text.muted}})}i(oT,"makeStyles");function rf(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}i(rf,"formatMessageTime");var Fr=15,dT=15,cT=6,pT=Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function lf({message:e,onCopy:t,sentiment:r=null,onSentiment:n,thanks:o=false}){let s=F(),a=react.useMemo(()=>fT(s),[s]),l=J(),u=e.role==="user",d=react.useMemo(()=>rf(e.createdAt),[e.createdAt]),c=t!==void 0&&e.role!=="vet"&&e.text.length>0,p=e.role==="assistant"&&n!==void 0&&e.responseId!==void 0,[f,m]=react.useState(false),y=react.useRef(null);react.useEffect(()=>()=>{y.current&&clearTimeout(y.current);},[]);let R=i(()=>{t!==void 0&&(jt(t,e.text),m(true),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{m(false),y.current=null;},l.copiedMs));},"copy");return d===null&&!c&&!p?null:jsxRuntime.jsxs(reactNative.View,{style:a.wrap,children:[jsxRuntime.jsxs(reactNative.View,{style:[a.row,u?a.rowUser:a.rowAssistant],children:[d!==null?jsxRuntime.jsx(S,{tier:"compact",style:a.timestamp,children:d}):null,c?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:f?b.copied:u?b.copyUserMessage:b.copyAssistantMessage,hitSlop:dT,onPress:R,style:a.iconHit,children:f?jsxRuntime.jsx(lt,{size:Fr,color:s.color.success,strokeWidth:2}):jsxRuntime.jsx(Gd,{size:Fr,color:s.color.text.timestamp,strokeWidth:1.5})}):null,p?Zu.map(({sentiment:h,label:C})=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:C,accessibilityState:{selected:r===h},hitSlop:cT,onPress:()=>n?.(h),style:a.iconHit,children:jsxRuntime.jsx(kn,{size:Fr,color:s.color.sentiment[h],active:r===h,rotate:pT[h],strokeWidth:1.5})},h)):null]}),o?jsxRuntime.jsx(S,{style:a.thanks,accessibilityLiveRegion:"polite",children:b.feedbackThanks}):null]})}i(lf,"MessageFooter");function fT(e){let t=e.type;return reactNative.StyleSheet.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...T(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:Fr,height:Fr,alignItems:"center",justifyContent:"center"},thanks:{...T(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary}})}i(fT,"makeStyles");var uf="#10462E",df="#000000",mT="#83E0B4",yT=Object.freeze([Object.freeze({id:"breed-health-miss",intent:"send",label:"What {breed} health issue do owners miss most?",fallbackLabel:"What {species} health issue do owners miss most?",background:"#A0C4F6",borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"attention-at-age",intent:"send",label:"What changes should I expect at {ageYears} years old?",fallbackLabel:"What changes should I expect as my {species} ages?",background:mT,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:uf,brandEdge:true,borderWidth:1}),Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}\u2019s vet visit.",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]),gT=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function hT(e){return e==null?e:e.replace(gT,"").trim()}i(hT,"formatBreedForPrompt");var bT=new Set(["","?","-","--",".","n/a","na","none","null","nil","unknown","unspecified","unsure","not sure","not specified","not applicable","no idea","dunno","idk","tbd","other","i dont know","i don't know","dont know","don't know","do not know","i do not know","not known","no clue"]);function vT(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return bT.has(t)}i(vT,"isUninformativeBreed");function ET(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}i(ET,"unspecifiedBreedLabel");function CT(e,t){return vT(e)?ET(t):String(e).replace(/\s+/gu," ").trim()}i(CT,"resolveBreedLabel");function cf(e){let t=e?.name?.trim()||b.emptyTitlePetFallback;return q(b.emptyTitle,{petName:t})}i(cf,"emptyStateTitle");function pf(e,t=uf){let r=$i(e?.species),n=r==="cat"?"my cat":"my dog",o=e?.name?.trim()||null,s=o||n,a=CT(hT(e?.breed),r)||null,l=Yi(e?.ageYears),u=l===null?null:String(l);return Object.freeze(yT.map(d=>{let c=d.label.includes("{breed}"),p=d.label.includes("{ageYears}"),m=d.fallbackLabel!==void 0&&(c&&!a||p&&!u)&&d.fallbackLabel?d.fallbackLabel:d.label,y=q(m,{petName:s,breed:a??n,species:r,ageYears:u??""}),R=!o&&m.startsWith("{petName}")?y.charAt(0).toUpperCase()+y.slice(1):y;return Object.freeze({id:d.id,intent:d.intent,label:R,background:d.background,borderColor:d.brandEdge===true?t:d.borderColor,borderWidth:d.borderWidth})}))}i(pf,"resolveQuickPrompts");var ST=36,yf=4,TT=340;function gf({pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o}){let s=F(),a=react.useMemo(()=>kT(s),[s]),l=react.useMemo(()=>pf(e,s.color.brandInk),[e,s.color.brandInk]),u=cf(e);return jsxRuntime.jsxs(reactNative.View,{style:a.block,children:[jsxRuntime.jsx(S,{tier:"heading",style:a.title,accessibilityRole:"header",children:u}),jsxRuntime.jsx(reactNative.View,{style:a.list,children:l.map((d,c)=>jsxRuntime.jsx(PT,{prompt:d,index:c,petRef:t,onSend:r,onVetPrep:n,vet:o,pet:e,styles:a},d.id))})]})}i(gf,"QuickPrompts");function PT({prompt:e,index:t,pet:r,petRef:n,onSend:o,onVetPrep:s,vet:a,styles:l}){let u=J(),d=Tt(u.followUpInMs,{delayMs:_n(u,t)}),c={backgroundColor:e.background,borderColor:e.borderColor,borderWidth:e.borderWidth};return e.intent==="vet_report"?s!==void 0?jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:yf,style:[l.chip,c],onPress:()=>{$(s,r);},children:jsxRuntime.jsx(S,{tier:"compact",style:l.chipLabel,children:e.label})})}):n===null?null:jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(Kt,{entry:"chat",petRef:n,label:e.label,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:[l.chip,c],labelStyle:l.chipLabel})}):jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(H,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:yf,style:[l.chip,c],onPress:()=>o(e.label),children:jsxRuntime.jsx(S,{tier:"compact",style:l.chipLabel,children:e.label})})})}i(PT,"Chip");function kT(e){let t=e.color;return reactNative.StyleSheet.create({block:{gap:18,alignItems:"center",width:"100%"},title:{...T(e,"bold"),fontSize:28,lineHeight:34,color:t.text.primary,letterSpacing:-0.8,textAlign:"center",maxWidth:TT},list:{width:"100%",gap:12,alignItems:"center"},chip:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:9,minHeight:ST,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipLabel:{...T(e,"bold"),fontSize:12,lineHeight:14,color:df,textAlign:"center"}})}i(kT,"makeStyles");var vs=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;function hf(e){return e.includes("*")||e.includes("`")}i(hf,"hasInlineMarkup");function bf(e){let t=[],r=0;vs.lastIndex=0;for(let n=vs.exec(e);n!==null;n=vs.exec(e)){n.index>r&&t.push({kind:"text",text:e.slice(r,n.index)});let o=n[1],s=n[2],a=n[3];o!==void 0?t.push({kind:"bold",text:o}):s!==void 0?t.push({kind:"italic",text:s}):a!==void 0&&t.push({kind:"code",text:a}),r=n.index+n[0].length;}return r<e.length&&t.push({kind:"text",text:e.slice(r)}),t}i(bf,"tokenizeInlineMarkdown");function vf(e,t){return hf(e)?bf(e).map((r,n)=>{switch(r.kind){case "bold":return jsxRuntime.jsx(S,{style:t.bold,children:r.text},n);case "italic":return t.italic?jsxRuntime.jsx(S,{style:t.italic,children:r.text},n):r.text;case "code":return t.code?jsxRuntime.jsx(S,{style:t.code,children:r.text},n):r.text;default:return r.text}}):e}i(vf,"renderInlineMarkdown");var Rf=6,Pf=520,OT=Math.round(Pf*.18),Sf=.44,FT=.5,Tf=[0,.5,1],MT=[0,1,2];function kf(){let e=F(),t=react.useMemo(()=>DT(e),[e]),r=!e.motion.reducedMotion;return jsxRuntime.jsx(reactNative.View,{style:t.card,accessible:true,accessibilityRole:"text",accessibilityLabel:b.typing,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:MT.map(n=>r?jsxRuntime.jsx(LT,{index:n,style:t.dot},n):jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotStatic]},n))})}i(kf,"TypingIndicator");function LT({index:e,style:t}){let r=react.useRef(new reactNative.Animated.Value(0)).current;react.useEffect(()=>{let s=reactNative.Animated.sequence([reactNative.Animated.delay(e*OT),reactNative.Animated.loop(reactNative.Animated.timing(r,{toValue:1,duration:Pf,useNativeDriver:true}))]);return s.start(),()=>s.stop()},[r,e]);let n=r.interpolate({inputRange:Tf,outputRange:[Sf,1,Sf]}),o=r.interpolate({inputRange:Tf,outputRange:[0,-3.5,0]});return jsxRuntime.jsx(reactNative.Animated.View,{style:[t,{opacity:n,transform:[{translateY:o}]}]})}i(LT,"AnimatedDot");function DT(e){let t=e.color,r=e.space,n=e.radius;return reactNative.StyleSheet.create({card:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:r.xs,paddingHorizontal:r.md,paddingVertical:r.sm,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},dot:{width:Rf,height:Rf,borderRadius:n.pill,backgroundColor:t.brand},dotStatic:{opacity:FT}})}i(DT,"makeStyles");function xf(e,t,r){let n=e-r,o=t!=null?Math.min(n,t):n;return Math.max(0,o)}i(xf,"resolveTurnScrollTarget");function _f(e){let t=e.length-1,r=e[t];if(r===void 0||r.role!=="assistant")return null;let n=e[t-1];return {assistantIndex:t,userIndex:n!==void 0&&n.role==="user"?t-1:null}}i(_f,"latestTurn");function wf(e,t,r){let n=Math.max(0,r),o=e===null?n:Math.min(Math.max(0,e),n);return o>t+1?o:null}i(wf,"nextFollowOffset");function If(e,t){let r=react.useRef(null),n=react.useRef(true),o=react.useRef(t),s=react.useRef(0),a=react.useRef(0),l=react.useRef(0),u=react.useRef(new Map),d=_f(e),c=d===null?null:e[d.assistantIndex]?.id??null,p=d===null||d.userIndex===null?null:e[d.userIndex]?.id??null,f=react.useCallback(()=>{let P=r.current;if(P===null||!n.current||a.current===0)return;let x=null;if(c!==null){let w=u.current.get(c);if(w===void 0)return;let O=p===null?null:u.current.get(p)??null;x=xf(w,O,96);}let g=wf(x,s.current,l.current-a.current);g!==null&&(s.current=g,P.scrollTo({y:g,animated:false}));},[c,p]);react.useEffect(()=>{t&&!o.current&&(n.current=true),o.current=t,f();},[e,t,f]);let m=react.useCallback(P=>{a.current=P.nativeEvent.layout.height,f();},[f]),y=react.useCallback((P,x)=>{l.current=x,a.current>0&&(s.current=Math.min(s.current,Math.max(0,x-a.current))),f();},[f]),R=react.useCallback(P=>{s.current=P.nativeEvent.contentOffset.y;},[]),h=react.useCallback(()=>{n.current=false;},[]),C=react.useCallback(P=>{let{contentOffset:x,contentSize:g,layoutMeasurement:w}=P.nativeEvent;s.current=x.y,n.current=g.height-x.y-w.height<=24;},[]),_=react.useCallback(P=>x=>{u.current.set(P,x.nativeEvent.layout.y),(P===c||P===p)&&f();},[c,p,f]);return {ref:r,onLayout:m,onContentSizeChange:y,onScroll:R,onScrollBeginDrag:h,onScrollEnd:C,rowLayout:_}}i(If,"useThreadFollow");function Lf(e,t,r){switch(e){case "loading":return r.renderPending?jsxRuntime.jsx(Rt,{render:r.renderPending,fallback:jsxRuntime.jsx(Of,{})}):jsxRuntime.jsx(Of,{});case "empty":return jsxRuntime.jsx(WT,{pet:r.shownPet,petRef:t.petRef,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet});case "error":return jsxRuntime.jsx(qT,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case "populated":return jsxRuntime.jsx($T,{messages:t.messages,prompts:Md(t),onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,thanksFor:r.thanksFor,imagesByMessage:r.imagesByMessage,onPreview:r.onPreview,notice:r.notice,reconnecting:t.reconnecting===true,onRetry:t.retryLast,onStartNew:t.newConversation,petRef:t.petRef,onFindVet:r.onCheckinFindVet,vet:r.vet,onOpenUrl:r.onOpenUrl});default:return nt(e)}}i(Lf,"renderView");function Of(){let{theme:e,styles:t}=Pe(),[r,n]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>n(true),Ap);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx(reactNative.View,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:b.loading,children:r?jsxRuntime.jsx(reactNative.ActivityIndicator,{color:e.color.brandInk}):null})}i(Of,"LoadingState");function WT({pet:e,petRef:t,onSelectPrompt:r,onVetPrep:n,vet:o}){let{styles:s}=Pe();return jsxRuntime.jsx(reactNative.ScrollView,{contentContainerStyle:s.emptyContent,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,accessibilityLabel:b.empty,children:jsxRuntime.jsx(gf,{pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o})})}i(WT,"EmptyState");function GT({prompts:e,onSelectPrompt:t}){let{styles:r}=Pe();return e.length===0?null:jsxRuntime.jsx(reactNative.View,{style:r.followUps,children:e.map((n,o)=>jsxRuntime.jsx(KT,{prompt:n,index:o,onSelectPrompt:t},n))})}i(GT,"FollowUps");function KT({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:o}=Pe(),s=J(),a=Tt(s.followUpInMs,{delayMs:_n(s,t)});return jsxRuntime.jsx(reactNative.Animated.View,{style:a,children:jsxRuntime.jsxs(H,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:o.followUpSlot,style:o.followUpRow,children:[jsxRuntime.jsx(S,{style:o.followUpText,children:e}),jsxRuntime.jsx(Pn,{size:ZT,color:n.color.brandInk,direction:"right"})]})})}i(KT,"FollowUpRow");function qT({error:e,onRetry:t,onAddPet:r}){let{styles:n}=Pe(),o=ad(e)?yd(r):void 0;return jsxRuntime.jsxs(reactNative.View,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(S,{style:n.errorText,children:e.displayMessage}),o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:b.addPet,style:n.retryButton,children:jsxRuntime.jsx(S,{tier:"control",style:n.retryLabel,children:b.addPet})}):null,e.retryable?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:b.retry,style:n.retryButton,children:jsxRuntime.jsx(S,{tier:"control",style:n.retryLabel,children:b.retry})}):null]})}i(qT,"ErrorState");function $T({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:o,onCopy:s,sentimentByMessage:a,onSentiment:l,thanksFor:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:f,onRetry:m,onStartNew:y,petRef:R,onFindVet:h,vet:C,onOpenUrl:_}){let{styles:P}=Pe(),x=J();Pr(e.length,x);let g=react.useMemo(()=>Np(e),[e]),w=Fd(e,n),O=e[e.length-1],M=react.useMemo(()=>e.filter(v=>!(v.checkin&&g.get(v.id)?.kind==="folded")),[e,g]),I=If(M,n);return jsxRuntime.jsxs(reactNative.ScrollView,{ref:I.ref,style:P.list,contentContainerStyle:P.listContent,accessibilityLabel:b.transcript,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,onLayout:I.onLayout,onContentSizeChange:I.onContentSizeChange,onScroll:I.onScroll,scrollEventThrottle:QT,onScrollBeginDrag:I.onScrollBeginDrag,onScrollEndDrag:I.onScrollEnd,onMomentumScrollEnd:I.onScrollEnd,children:[e.map(v=>{let k=v.checkin?g.get(v.id):void 0;return k?.kind==="folded"?null:k?.kind==="past"?jsxRuntime.jsx(qp,{text:v.text,runDueDays:k.runDueDays,openedAt:v.checkin?.openedAt,onLayout:I.rowLayout(v.id)},v.id):v.checkin&&k!==void 0?jsxRuntime.jsx(Gp,{message:v,checkin:v.checkin,onAnswer:o,petRef:R,onFindVet:h,vet:C,onLayout:I.rowLayout(v.id)},v.id):jsxRuntime.jsx(JT,{onLayout:I.rowLayout(v.id),message:v,revealing:n&&v===O&&v.role==="assistant",onCopy:s,sentiment:v.responseId===void 0?null:a[String(v.responseId)]??null,onSentiment:l,thanks:u!==null&&v.responseId!==void 0&&String(v.responseId)===u,images:d[v.id]??XT,onPreview:c,onOpenUrl:_},v.id)}),f?jsxRuntime.jsx(S,{tier:"compact",style:P.reconnectingCaption,accessibilityRole:"text",children:b.reconnecting}):null,w?jsxRuntime.jsx(kf,{}):null,p!==null?jsxRuntime.jsx(YT,{notice:p,onRetry:m,onStartNew:y}):null,jsxRuntime.jsx(GT,{prompts:t,onSelectPrompt:r})]})}i($T,"PopulatedState");function YT({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=Pe(),o=e.tone==="error";return jsxRuntime.jsxs(reactNative.View,{style:[n.turnNotice,o?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(S,{tier:"control",style:[n.turnNoticeTitle,o?n.turnNoticeTitleError:null],children:e.title}),jsxRuntime.jsx(S,{tier:"compact",style:n.turnNoticeBody,children:e.body}),jsxRuntime.jsx(reactNative.Pressable,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:Yt,style:n.turnNoticeAction,children:jsxRuntime.jsx(S,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}i(YT,"TurnNoticeCard");var XT=Object.freeze([]),QT=16,ZT=14;function JT({message:e,revealing:t,onCopy:r,sentiment:n,onSentiment:o,thanks:s,images:a,onPreview:l,onOpenUrl:u,onLayout:d}){let{styles:c}=Pe(),p=J(),f=Tt(p.messageInMs),m=lc(e.text,t,p),y=e.role==="user",R=e.role==="vet",h=y?b.senderUser:R?Ld(e):b.senderAssistant,C=react.useCallback(P=>o(e,P),[o,e]),_=e.pending!==true;return jsxRuntime.jsxs(reactNative.Animated.View,{style:[c.rowBlock,y?c.rowBlockUser:c.rowBlockAssistant,f],onLayout:d,children:[jsxRuntime.jsx(reactNative.View,{style:[c.row,y?c.rowUser:c.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${h}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:jsxRuntime.jsxs(reactNative.View,{style:[c.bubble,y?c.bubbleUser:R?c.bubbleVet:c.bubbleAssistant,e.pending?c.bubblePending:null],children:[y&&a.length>0?jsxRuntime.jsx(Pc,{images:a,onPreview:P=>l({uri:P.uri,label:P.filename})}):null,R?jsxRuntime.jsx(S,{style:c.vetSender,children:h}):null,jsxRuntime.jsx(S,{style:y?c.bubbleTextUser:R?c.bubbleTextVet:c.bubbleTextAssistant,children:e.role==="assistant"?vf(m,{bold:c.bubbleBold,italic:c.bubbleItalic,code:c.bubbleCode}):e.text})]})}),e.role==="assistant"&&!t?jsxRuntime.jsx(tf,{citations:e.citations,onOpenUrl:u}):null,_?jsxRuntime.jsx(lf,{message:e,onCopy:r,sentiment:n,onSentiment:e.responseId===void 0?void 0:C,thanks:s}):null]})}i(JT,"MessageRow");var oP=Object.freeze(["photo"]),iP=1;function Nf(e){let{style:t,renderPending:r}=e;return jsxRuntime.jsx(mi,{capability:"chat",style:t,...r?{renderPending:r}:{},children:jsxRuntime.jsx(sP,{...e})})}i(Nf,"EverfurChat");function sP({petRef:e,conversationId:t,style:r,renderPending:n,onCopy:o,onPetChange:s,onVetPrep:a,onFindVet:l,renderVetAction:u,attachments:d,pet:c,onAddPet:p,checkinTarget:f,initialAsk:m,composerSeed:y,lifecycle:R,draftStore:h,vetReturnTo:C,vetUsState:_,vetPrefer:P,onOpenUrl:x,keyboardVerticalOffset:g}){let{theme:w,styles:O}=Pe(),M=J(),I=react.useMemo(()=>Dd(e,t),[e,t]),v=Rr(I),k=Ad(v),V=Sp(),W=kd(v),G=reactNativeSafeAreaContext.useSafeAreaInsets(),ae=Od(v),be=react.useMemo(()=>l===void 0?void 0:()=>{$(l,"emergency");},[l]),Ie=react.useMemo(()=>C===void 0&&_===void 0&&P===void 0?void 0:{returnTo:C,usState:_,prefer:P},[C,_,P]),ct=ns(V.pets,v.petRef),ye=react.useMemo(()=>wd(v.messages,ct?.name??null),[v.messages,ct?.name]),rt=Id(ye);Pr(rt.showBanner,M),vd(v.openCheckin,f),pd(v.askEverfur,v.isBootstrapping,m);let Dr=react.useMemo(()=>Ri(y),[y]);hd(R,{conversationId:v.conversationId===null?null:String(v.conversationId),isTurnInFlight:v.isStreaming,refresh:v.refreshActiveThread});let Nr=(v.hasUnreadThreads??false)||W.rows.some(ke=>ke.unreadCount!==null&&ke.unreadCount>0)||(v.unreadCount??0)>0,Ot=dd(v.messages),[Jt,Qn]=react.useState(null),Vf=react.useCallback(()=>Qn(null),[]),[er,Zn]=react.useState(null),[Bf,Ss]=react.useState(null),Ft=react.useRef(null);react.useEffect(()=>()=>{Ft.current&&clearTimeout(Ft.current);},[]);let Ts=react.useCallback(ke=>{Ss(String(ke)),Ft.current&&clearTimeout(Ft.current),Ft.current=setTimeout(()=>{Ss(null),Ft.current=null;},Op);},[]),Hf=react.useCallback((ke,Vr)=>{let tr=ke.responseId;if(tr===void 0)return;let qf=v.sentimentByMessage[String(tr)];v.feedback(tr,Vr),Vr==="down"&&qf!=="down"&&Zn(tr);},[v]),zf=react.useCallback(async(ke,Vr)=>er===null||!(await v.feedback(er,"down",ke??"other",Vr)).ok?false:(Zn(null),Ts(er),true),[v,er,Ts]),jf=react.useCallback(()=>Zn(null),[]),Wf=react.useCallback(ke=>{v.send(ke);},[v.send]),Gf=react.useMemo(()=>x===void 0?void 0:ke=>{$(x,ke,"citation");},[x]),Ps=reactNative.Platform.OS==="ios"?"padding":void 0,Ur=hp(g,Ps!==void 0),Kf=Ur.topInWindow===null?G.top:Math.max(0,G.top-Ur.topInWindow),ks={send:v.send,stop:v.stop,isStreaming:v.isStreaming,conversationId:v.conversationId,seed:Dr,draftStore:h,onStage:Ot.stage,onPreview:Qn};return jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:[O.container,{paddingTop:Kf},r],behavior:Ps,...Ur.avoidingProps,children:[jsxRuntime.jsx(bp,{probeRef:Ur.probeRef}),jsxRuntime.jsx(up,{pets:V,petRef:v.petRef,historyUnread:Nr,onOpenHistory:W.show,onPetChange:s,onAddPet:p,vet:Ie}),c!==void 0?jsxRuntime.jsx(aP,{petRef:e??null,pet:c,onRegistered:V.refresh}):null,jsxRuntime.jsx(Rp,{surface:rt,petRef:v.petRef,renderVetAction:u,onFindVet:l,vet:Ie}),jsxRuntime.jsx(reactNative.View,{style:O.body,children:Lf(k,v,{notice:ae,vet:Ie,onCheckinFindVet:be,onSelectPrompt:Wf,renderPending:n,shownPet:ct,onVetPrep:a,onCopy:o,onSentiment:Hf,thanksFor:Bf,imagesByMessage:Ot.byMessage,onPreview:Qn,onAddPet:p,onOpenUrl:Gf})}),d!==void 0?jsxRuntime.jsx(lP,{...ks,attachments:d}):jsxRuntime.jsx(Uf,{...ks,attachments:null}),jsxRuntime.jsx(Vd,{}),w.meta.hidePoweredBy?null:jsxRuntime.jsx(S,{tier:"compact",style:O.poweredBy,accessibilityRole:"text",accessibilityLabel:b.poweredBy,children:b.poweredBy}),jsxRuntime.jsx(gp,{chat:v,history:W}),jsxRuntime.jsx(yp,{visible:er!==null,onSubmit:zf,onSkip:jf}),jsxRuntime.jsx(uc,{uri:Jt?.uri??null,label:Jt?.label??"",onClose:Vf}),jsxRuntime.jsx(xr,{})]})}i(sP,"ChatBody");function aP({petRef:e,pet:t,onRegistered:r}){let{styles:n}=Pe(),o=ld(e,t,r);return o.status!=="failed"||o.error===null?null:jsxRuntime.jsxs(reactNative.View,{style:n.setupNotice,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(S,{tier:"compact",style:n.setupNoticeText,children:o.error.displayMessage}),jsxRuntime.jsx(reactNative.Pressable,{onPress:o.retry,accessibilityRole:"button",accessibilityLabel:b.retry,hitSlop:Yt,children:jsxRuntime.jsx(S,{tier:"control",style:n.setupNoticeAction,children:b.retry})})]})}i(aP,"PetSetupNotice");function lP({attachments:e,...t}){let r=react.useMemo(()=>xc(),[]),n=En({maxPerMessage:e.maxPerMessage??iP,transport:r}),o=react.useMemo(()=>({state:n,sources:e.sources??oP,pick:e.pick}),[n,e.sources,e.pick]);return jsxRuntime.jsx(Uf,{...t,attachments:o})}i(lP,"ComposerWithAttachments");function Uf({send:e,stop:t,isStreaming:r,conversationId:n,attachments:o,seed:s,draftStore:a,onStage:l,onPreview:u}){let{theme:d,styles:c}=Pe(),p=J(),[f,m]=Rd(e,n,s);Sd(a,n===null?null:String(n),f,m);let[y,R]=react.useState(false),[h,C]=react.useState(false);react.useEffect(()=>{C(false);},[n]);let _=d.meta.placeholder??b.placeholder,P=o?.state.uploading??false,x=o?.state.failed??false,g=P||x,w=o?.state.attachments??uP;Pr(w.length,p);let O=react.useCallback(()=>{if(f.trim().length===0||g||[...f].length>Nt)return;let G=o?.state.s3Keys??dP;o!==null&&G.length>0?(l(o.state.attachments.filter(ae=>ae.status==="uploaded").map(ae=>({uri:ae.previewUri,filename:ae.filename}))),e(f,{imageS3Keys:G}),o.state.clear()):e(f),m(""),C(false);},[f,e,g,o,l]),M=react.useCallback(()=>{t();},[t]),I=react.useCallback(G=>{R(false),o!==null&&(C(false),o.state.dismissRejected(),jt(o.pick,G).then(ae=>{if(!ae.ok){C(true);return}ae.value!==null&&o.state.add(ae.value);}));},[o]),k=react.useMemo(()=>[...f].length>Nt,[f])||g,V=o!==null&&w.length>=o.state.maxPerMessage,W=d.slots.sendButton?.textColor??d.color.brandInk;return jsxRuntime.jsxs(reactNative.View,{style:c.composerOuter,children:[o!==null&&y?jsxRuntime.jsx(pc,{sources:o.sources,full:V,onPick:I,onClose:()=>R(false)}):null,jsxRuntime.jsxs(reactNative.View,{style:c.composer,children:[o!==null?jsxRuntime.jsx(Tc,{attachments:w,rejected:h?cP:o.state.rejected,uploadFailed:x,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:G=>u({uri:G.previewUri,label:G.filename})}):null,jsxRuntime.jsxs(reactNative.View,{style:c.composerRow,children:[o!==null?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:od(w.length,o.state.maxPerMessage),accessibilityState:{disabled:V,expanded:y},disabled:V,hitSlop:($t-Gn)/2,style:[c.attachControl,V?c.attachControlDisabled:null],onPress:()=>R(G=>!G),children:jsxRuntime.jsx(qd,{size:Lp,color:V?d.color.text.muted:d.color.brandInk,strokeWidth:1.75})}):null,jsxRuntime.jsx(Ht,{style:c.input,value:f,onChangeText:m,placeholder:_,placeholderTextColor:d.slots.composerInput?.textColor??d.color.text.placeholder,onSubmitEditing:O,returnKeyType:"send",blurOnSubmit:false,multiline:true,editable:true}),r?jsxRuntime.jsx(reactNative.Pressable,{onPress:M,accessibilityRole:"button",accessibilityLabel:b.stop,hitSlop:Yt,style:c.sendControl,children:jsxRuntime.jsx(reactNative.View,{style:c.sendDisc,testID:"everfur-stop-disc",children:jsxRuntime.jsx(ec,{size:Mp,color:W,testID:"everfur-stop-glyph"})})}):jsxRuntime.jsx(reactNative.Pressable,{onPress:O,disabled:k,accessibilityRole:"button",accessibilityLabel:b.send,accessibilityState:{disabled:k,busy:P},hitSlop:Yt,style:[c.sendControl,k?c.sendControlDisabled:null],children:jsxRuntime.jsx(reactNative.View,{style:c.sendDisc,testID:"everfur-send-disc",children:jsxRuntime.jsx(Jd,{size:Fp,color:W,testID:"everfur-send-glyph"})})})]})]})]})}i(Uf,"Composer");var uP=Object.freeze([]),dP=Object.freeze([]),cP=Object.freeze({code:"unknown",retryable:true,filename:""});function gP(e){let{runtime:t,userRef:r,scopeEpoch:n}=Z(),o=react.useMemo(()=>ot(t.registry.services.authFor(r)),[t,r,n]),s=react.useMemo(()=>({repository:o,petRef:e}),[o,e]),[a,l]=react.useState({key:s,profile:null,loading:e!==null,error:null}),u=a.key===s?a:{profile:null,loading:e!==null,error:null},d=react.useRef(0),c=react.useCallback(async()=>{let p=++d.current;if(s.petRef===null){l({key:s,profile:null,loading:false,error:null});return}l(m=>({key:s,profile:m.key===s?m.profile:null,loading:true,error:null}));let f=await s.repository.getPetProfile(s.petRef);p===d.current&&l(f.ok?{key:s,profile:f.value,loading:false,error:null}:{key:s,profile:null,loading:false,error:f.error});},[s]);return react.useEffect(()=>(c(),()=>{d.current+=1;}),[c]),react.useMemo(()=>({profile:u.profile,loading:u.loading,error:u.error,refresh:c}),[u.profile,u.loading,u.error,c])}i(gP,"useEverfurPetProfile");function bP(e){return react.createElement(hn,{clientTheme:e.clientTheme??null,seams:vn,children:e.children})}i(bP,"EverfurThemeProvider");exports.APPEARANCE_PRESETS=Ql;exports.APPEARANCE_PRESET_NAMES=Xl;exports.APPEARANCE_SIZE_RANGES=br;exports.CapabilityGate=mi;exports.EverfurChat=Nf;exports.EverfurConfigError=ee;exports.EverfurProvider=wb;exports.EverfurThemeProvider=bP;exports.EverfurThrownError=Br;exports.THEME_SLOT_KEYS=Sg;exports.THEME_SLOT_NAMES=qe;exports.canonicalPetSpecies=pr;exports.categoryFor=eo;exports.conversationId=tm;exports.createRnRecordsUploadTransport=vm;exports.expandAppearance=Xo;exports.face=T;exports.isErr=Xf;exports.isOk=Yf;exports.isRetryableCode=to;exports.petRef=Jf;exports.previewTheme=kh;exports.unwrap=Qf;exports.useCapability=Bt;exports.useChatAttachments=En;exports.useEverfur=wu;exports.useEverfurChat=Rr;exports.useEverfurPetProfile=gP;exports.useEverfurPets=On;exports.useEverfurTheme=F;exports.userFacingError=Mt;exports.userRef=em;
11
+ `));}l(),r.end();},"onError");e.addEventListener("message",o),e.addEventListener("done",s),e.addEventListener("error",a);function l(){if(!n){n=true,e.removeEventListener("message",o),e.removeEventListener("done",s),e.removeEventListener("error",a);try{e.close();}catch{}}}return i(l,"cleanup"),Ym(r.source,l)}i($m,"eventSourceByteSource");async function*Ym(e,t){try{yield*e;}finally{t();}}i(Ym,"sourceWithCleanup");function Xm(){let e=[],t=false,r=null,n=i(()=>{if(r){let s=r;r=null,s();}},"signal");async function*o(){for(;;){let s=e.shift();if(s!==void 0){yield s;continue}if(t)return;await new Promise(a=>{r=a;});}}return i(o,"gen"),{source:o(),push:i(s=>{e.push(s),n();},"push"),end:i(()=>{t=true,n();},"end")}}i(Xm,"createByteQueue");async function Qm(e,t){let r=t.fetchImpl??fa(),n=ma(t.config.apiBaseUrl,e.path,e.query),o=ya(t.config,e.headers,"application/json",e.body!==void 0&&e.multipart===void 0),s=ny(qm),a=oy(s.signal,e.signal),l;try{l=await r(n,ga({...e,signal:a},o));}catch(d){return v(vo(d))}finally{s.cancel();}let u=await ha(l);return l.ok?L(u):v(ey(l.status,u,ca(l)))}i(Qm,"requestJson");function da(e){return {request:i(t=>Qm(t,e),"request"),stream:i((t,r)=>Zm(ry(t,r),e),"stream")}}i(da,"createHttpTransport");async function*Zm(e,t){let r=ma(t.config.apiBaseUrl,e.path,e.query),n=ya(t.config,e.headers,"text/event-stream",e.body!==void 0&&e.multipart===void 0);if(t.eventSourceFactory){let l=t.eventSourceFactory(r,Jm(e,n));yield*Zr($m(l),()=>ty(l));return}let o=t.fetchImpl??fa(),s;try{s=await o(r,ga(e,n));}catch(l){yield aa("",true,Ca(l));return}let a=ca(s);if(!s.ok){let l=await ha(s),u=ba(l)??pa(s.status),d=Ea(l)||Ge(Fe(u));yield aa(u,d,va(l),a);return}if(s.body){yield*Zr(sa(s.body),a);return}yield*Zr(sa(null),a);}i(Zm,"streamFrames");function Jm(e,t){return {method:e.method,headers:t,pollingInterval:0,...e.body!==void 0?{body:JSON.stringify(e.body)}:{}}}i(Jm,"buildEventSourceInit");function ey(e,t,r){let n=ba(t),o=n?Fe(n):Ds(e),s=va(t);return D(o,{httpStatus:e,...Ea(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...la(t)?{reasonCode:la(t)}:{},...s?{wireMessage:s}:{},...t!=null?{raw:t}:{}})}i(ey,"errorFromResponse");function vo(e){return D("internalError",{retryable:true,wireMessage:Ca(e)})}i(vo,"networkError");function ca(e){let t=e.headers.get(ua);return typeof t=="string"&&t.length>0?t:null}i(ca,"requestIdOf");function ty(e){if(typeof e.getResponseHeader!="function")return null;let t;try{t=e.getResponseHeader(ua);}catch{return null}return typeof t=="string"&&t.length>0?t:null}i(ty,"eventSourceRequestId");function pa(e){return e===401?"AUTH_EXPIRED":e===403?"ACCESS_DENIED":e===404?"NOT_FOUND":e===409?"IDEMPOTENCY_CONFLICT":e===421?"MISDIRECTED_REQUEST":e===429?"RATE_LIMITED":e===400||e===422?"INVALID_REQUEST":e===503||e>=500?"INTERNAL_ERROR":""}i(pa,"statusToWireCode");function aa(e,t,r,n=null){return ye({code:e,retryable:t,wireMessage:r,synthesized:true,lastEventId:null,serverRequestId:n})}i(aa,"syntheticErrorFrame");function fa(){let e=globalThis.fetch;if(typeof e!="function")throw new re("missing-peer-dependency","global fetch is unavailable; provide config.transport or an injected fetch implementation");return e}i(fa,"getGlobalFetch");function ma(e,t,r){let n=t.startsWith("/")?t:`/${t}`,o=`${e}${n}`;if(r){let s=Object.entries(r).filter(a=>a[1]!==void 0).map(([a,l])=>`${encodeURIComponent(a)}=${encodeURIComponent(String(l))}`).join("&");s&&(o+=`?${s}`);}return o}i(ma,"buildUrl");function ya(e,t,r,n){let o={...ia(e),accept:r};return n&&(o["content-type"]="application/json"),t&&Object.assign(o,t),o}i(ya,"mergeHeaders");function ga(e,t){let r={method:e.method,headers:t};return e.multipart!==void 0?r.body=e.multipart:e.body!==void 0&&(r.body=JSON.stringify(e.body)),e.signal&&(r.signal=e.signal),r}i(ga,"buildInit");function ry(e,t){return e.signal?e:{...e,signal:t}}i(ry,"withSignal");function ny(e){let t=new AbortController,r=setTimeout(()=>t.abort(),e);return {signal:t.signal,cancel:i(()=>clearTimeout(r),"cancel")}}i(ny,"timeoutSignal");function oy(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(oy,"mergeAbortSignals");async function ha(e){try{return await e.json()}catch{return null}}i(ha,"safeJson");function la(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}i(la,"extractReasonCode");function ba(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?r:null}i(ba,"extractWireCode");function va(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}i(va,"extractWireMessage");function Ea(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}i(Ea,"extractRetryable");function Ca(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(Ca,"describeCause");var iy=3e4,sy=co*2,ay="idempotency-key",ly=new Set(["POST","PUT","PATCH","DELETE"]),uy=Object.freeze({onEvent(){}}),dy=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function cy(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}i(cy,"seededIdempotencyKey");function Ie(e){let t=e.observer??uy,r=e.timers??dy,n=e.rng??Math.random,o=e.sleep??((f,m)=>Py(f,r,m)),s=e.maxAttempts??rr,a=e.unaryTimeoutMs??iy,l=e.newIdempotencyKey??fy(),u=i(f=>{try{t.onEvent(f);}catch{}},"emit");async function d(f,m,h){let T=h?.maxAttempts,b=Math.max(1,T??s),S=h?.idempotent??ly.has(m.method),P=h?.idempotencyKey===void 0?null:cy(h.idempotencyKey),k=S?P??l():null,x=py(m,k),y=0;for(;;){let _=i(H=>Object.freeze({call:f,method:m.method,path:m.path,attempt:y,...k?{idempotencyKey:k}:{},...H}),"stamp");u(_({phase:"attempt"}));let A=Sy(a,r),O=Ty(A.signal,m.signal),F;try{F=await Js({...x,signal:O.signal},e.auth);}catch(H){F=v(vo(H));}finally{O.dispose(),A.cancel();}if(F.ok)return u(_({phase:"settled",ok:true,reason:"ok"})),F;let C=F.error,w=yy(C,y,{maxAttempts:b,rng:n,now:r.now(),aborted:m.signal?.aborted===true,...T!==void 0?{perCallMaxAttempts:T}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),I={ok:false,code:C.code,reason:w.reason,...C.httpStatus!==void 0?{httpStatus:C.httpStatus}:{},...C.requestId!==void 0?{requestId:C.requestId}:{}};if(!w.retry)return u(_({phase:"settled",...I})),v(C);if(u(_({phase:"retry",...I,delayMs:w.delayMs})),await o(w.delayMs,m.signal),m.signal?.aborted===true)return u(_({phase:"settled",...I,reason:"aborted"})),v(C);y+=1;}}i(d,"send");async function c(f){return nr(f,await Ry(e.auth))}i(c,"authorize");async function*p(f,m,h){u(Object.freeze({call:f,phase:"stream.open",method:m.method,path:m.path,attempt:0}));try{yield*e.auth.transport.stream(m,h);}catch{yield ye({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(p,"stream"),Object.freeze({send:d,authorize:c,stream:p})}i(Ie,"createRequestFunnel");function py(e,t){let r={};for(let[n,o]of Object.entries(e.headers??{}))n.toLowerCase()!==ay&&(r[n]=o);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(py,"assembleHeaders");function fy(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(fy,"defaultIdempotencyKeyFactory");var my=10;function yy(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let n=gy(e);if(n==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!Ge(e.code))return {retry:false,reason:"terminal-code"};let o=n==="burst"?"burst-throttle":"retryable-code";if(i(()=>{if(r.policy===void 0)return false;try{return !r.policy.shouldRetry(e.code,t)}catch{return false}},"policyVetoedRetry")())return {retry:false,reason:"terminal-code"};let a=i(()=>{if(r.policy===void 0)return null;let d;try{d=r.policy.maxAttempts(e.code);}catch{return null}return typeof d!="number"||!Number.isFinite(d)?null:Math.max(1,Math.min(my,Math.floor(d)))},"policyCeiling"),l=r.perCallMaxAttempts??a()??r.maxAttempts;if(t+1>=l)return {retry:false,reason:"attempts-exhausted"};let u=hy(e,r.now);return u!==null?u>sy?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:o,delayMs:u}:{retry:true,reason:o,delayMs:$r(t,r.rng)}}i(yy,"decideRetry");function gy(e){let t=e.code==="unknown"?Fe(Cy(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(gy,"throttleKind");function hy(e,t){let r=vy(e.raw);if(r!==null){let o=r-t;return o>0?o:0}let n=by(e.raw);return n===null?null:Math.round(n*1e3)}i(hy,"retryOverrideMs");function by(e){for(let t of Eo(e)){let r=t.retry_after_seconds;if(typeof r=="number"&&Number.isFinite(r)&&r>=0)return r}return null}i(by,"findRetryAfterSeconds");function vy(e){for(let t of Eo(e)){let r=t.resets_at,n=Ey(r);if(n!==null)return n}return null}i(vy,"findResetsAt");function Eo(e){if(!Ra(e))return [];let t=[e];for(let r of ["error","detail"]){let n=e[r];Ra(n)&&t.push(n);}return t}i(Eo,"candidateScopes");function Ey(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e11?Math.round(e*1e3):Math.round(e);if(typeof e=="string"&&e.trim().length>0){let t=Date.parse(e);return Number.isFinite(t)?t:null}return null}i(Ey,"parseInstantMs");function Cy(e){for(let t of Eo(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i(Cy,"rawWireCode");function Ra(e){return typeof e=="object"&&e!==null}i(Ra,"isRecord");async function Ry(e){return e.mode==="anonymous"?{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}:{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}i(Ry,"resolveDeviceAuth");function Sy(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(n),"cancel")}}i(Sy,"boundedSignal");function Ty(e,t){let r=i(()=>{},"noop");if(!t)return {signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let o=i(()=>n.abort(),"onAbort");return e.addEventListener("abort",o,{once:true}),t.addEventListener("abort",o,{once:true}),{signal:n.signal,dispose:i(()=>{e.removeEventListener("abort",o),t.removeEventListener("abort",o);},"dispose")}}i(Ty,"mergeSignals");function Py(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let o=t.setTimeout(()=>{r?.removeEventListener("abort",s),n();},e),s=i(()=>{t.clearTimeout(o),n();},"onAbort");r?.addEventListener("abort",s,{once:true});})}i(Py,"delayAbortable");var en=Object.freeze(["better","same","worse"]),Ro=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Sa(e){return v(D("validationFailed",{retryable:false,wireMessage:e}))}i(Sa,"invalid");function Co(){return v(D("internalError",{retryable:false}))}i(Co,"malformed");function Ta(e){return typeof e!="string"||e.trim().length===0?D("validationFailed",{retryable:false,wireMessage:"pet_ref must not be blank"}):Ce(e)?D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}):`/widget/v1/pets/${encodeURIComponent(e)}/cases`}i(Ta,"petPath");var Ke=i(e=>typeof e=="string"?e:null,"str"),Pa=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"count");function ka(e){if(typeof e!="object"||e===null)return null;let t=e,r=Ke(t.case_id),n=Ke(t.status);if(r===null||n===null)return null;let o=Ke(t.last_response);return Object.freeze({caseId:r,status:n,bodyLocation:Ke(t.body_location),lastResponse:o!==null&&en.includes(o)?o:null,checkInDueAt:Ke(t.check_in_due_at),openedAt:Ke(t.opened_at),resolvedAt:Ke(t.resolved_at),resolutionText:Ke(t.resolution_text),checkinAskCount:Pa(t.checkin_ask_count),checkinAnswerCount:Pa(t.checkin_answer_count)})}i(ka,"caseFromWire");function xa(e){return {async list(t,r){let n=Ta(t);if(typeof n!="string")return v(n);let o=await e.send("cases.list",{method:"GET",path:n,...r?.signal?{signal:r.signal}:{}});if(!o.ok)return v(o.error);let s=typeof o.value=="object"&&o.value!==null?o.value.cases:null;if(!Array.isArray(s))return Co();let a=s.map(ka);return a.every(l=>l!==null)?L(Object.freeze(a)):Co()},async checkin(t,r,n,o){let s=Ta(t);if(typeof s!="string")return v(s);if(typeof r!="string"||!Ro.test(r))return Sa("case_id must be a UUID");if(!en.includes(n))return Sa("response must be one of better, same, worse");let a=await e.send("cases.checkin",{method:"POST",path:`${s}/${r}/checkin`,body:{response:n},...o?.signal?{signal:o.signal}:{}});if(!a.ok)return v(a.error);let l=typeof a.value=="object"&&a.value!==null?a.value:{},u=ka(l.case);return u===null?Co():L(Object.freeze({case:u,ctaDeepLink:Ke(l.cta_deep_link)}))}}}i(xa,"createCasesRepositoryOver");var _a=Object.freeze({async presignedPut(){return Promise.reject(new Error("UploadPort is unavailable; no presigned-upload adapter was injected"))}});var wa=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function rn(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let o={handle:void 0},s=i(()=>{r.clearTimeout(o.handle),t.removeEventListener("abort",s),n();},"done");o.handle=r.setTimeout(s,e),t.addEventListener("abort",s,{once:true});})}i(rn,"delayAbortable");function nn(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(nn,"mergeSignals");var So=class So{constructor(t){this.listeners=new Set;this.epoch=0;this.inFlight=null;this.snapshot=Object.freeze({...t});}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t);}}getSnapshot(){return this.snapshot}patch(t){this.snapshot=Object.freeze({...this.snapshot,...t});for(let r of this.listeners)r();}beginOperation(t){this.inFlight?.abort();let r=new AbortController;this.inFlight=r;let n=this.epoch;return {signal:t?nn(r.signal,t):r.signal,epoch:n,settle:i(()=>{this.inFlight===r&&(this.inFlight=null);},"settle")}}alive(t){return t===this.epoch}rescope(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null;}dispose(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null,this.listeners.clear();}};i(So,"MediaStore");var tn=So;function Po(e,t,r){return Object.freeze({id:e,role:"user",text:t,createdAt:r,pending:true})}i(Po,"makeUser");function ko(e,t,r){return Object.freeze({id:e,role:"assistant",text:t,createdAt:r})}i(ko,"makeAssistant");function sr(e){return Object.freeze({id:e.id,role:e.role,text:e.text,createdAt:e.createdAt})}i(sr,"stripPending");function Ia(e,t){let r={id:e.id,role:e.role,text:e.text+t,createdAt:e.createdAt};return e.citations&&(r.citations=e.citations),e.responseId&&(r.responseId=e.responseId),Object.freeze(r)}i(Ia,"appendText");function xo(e,t){let r={id:t.messageId?t.messageId:e.id,role:"assistant",text:e.text,createdAt:e.createdAt};return t.citations.length>0&&(r.citations=t.citations),t.messageId&&(r.responseId=t.messageId),r.urgencyLevel=t.urgencyLevel,r.urgencyReason=t.urgencyReason,r.urgencyProvided=t.urgencyProvided,Object.freeze(r)}i(xo,"finalizeAssistant");function Aa(e){return Object.freeze({status:e.status,messages:Object.freeze([...e.messages]),conversationId:e.conversationId,error:e.error,isStreaming:e.isStreaming,isBootstrapping:e.isBootstrapping,suggestedPrompts:Object.freeze([...e.suggestedPrompts]),unreadCount:e.unreadCount})}i(Aa,"freezeSnapshot");function U(e,t,r){return D(e,{retryable:t,...r?{wireMessage:r}:{}})}i(U,"makeError");function _o(e){let t=Fe(e.code);return D(t,{retryable:e.retryable||qr(t),wireCode:e.code,wireEnvelope:"sse_frame",...e.serverRequestId?{requestId:e.serverRequestId}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},raw:e})}i(_o,"errorFromFrame");function Me(e){return ye({code:ky(e.code),retryable:e.retryable,wireMessage:e.wireMessage??null,synthesized:true,lastEventId:null,serverRequestId:e.requestId??null})}i(Me,"synthErrorFrame");function ky(e){switch(e){case "authExpired":return "AUTH_EXPIRED";case "authRejected":return "AuthorizationException";case "sessionRequired":return "session_required";case "accessDenied":return "ACCESS_DENIED";case "paymentRequired":return "TIER_UPGRADE_REQUIRED";case "quotaExceeded":return "QUOTA_EXCEEDED";case "rateLimited":return "RATE_LIMITED";case "validationFailed":return "ValidationException";case "sdkUpdateRequired":return "invalidRequest";case "conflict":return "ConflictException";case "idempotencyConflict":return "IDEMPOTENCY_CONFLICT";case "idempotencyInFlight":return "IDEMPOTENCY_KEY_IN_FLIGHT";case "conversationNotFound":return "CONVERSATION_NOT_FOUND";case "petNotFound":return "PET_NOT_FOUND";case "resourceNotFound":return "ResourceNotFoundException";case "streamTimeout":return "STREAM_TIMEOUT";case "mediaUploadFailed":return "MEDIA_UPLOAD_FAILED";case "moderationBlocked":return "MODERATION_BLOCKED";case "upstreamLlmTimeout":return "UPSTREAM_LLM_TIMEOUT";case "internalError":return "INTERNAL_ERROR";case "notImplemented":return "NotImplementedException";case "serviceUnavailable":return "ServiceUnavailableException";case "streamIncomplete":return "STREAM_INCOMPLETE";case "unknown":return "UNKNOWN";default:return at(e)}}i(ky,"canonicalWireCode");function Oa(e){let t=Array.isArray(e)?e:To(e)&&Array.isArray(e.categories)?e.categories:[],r=[];for(let n of t){if(!To(n))continue;let o=ir(n.category)??ir(n.title)??"",s=xy(n.prompts??n.questions);o.length===0&&s.length===0||r.push(Object.freeze({category:o,prompts:Object.freeze(s)}));}return Object.freeze(r)}i(Oa,"parsePromptCategories");function wo(e){let t=new Set,r=[];for(let n of e)for(let o of n.prompts){let s=o.trim();s.length===0||t.has(s)||(t.add(s),r.push(s));}return r}i(wo,"flattenPrompts");function To(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(To,"isPlainObject");function ir(e){return typeof e=="string"?e:null}i(ir,"asStr");function xy(e){if(!Array.isArray(e))return [];let t=[];for(let r of e)if(typeof r=="string")t.push(r);else if(To(r)){let n=ir(r.text)??ir(r.prompt)??ir(r.title);n!==null&&t.push(n);}return t}i(xy,"asPromptTextList");function Fa(){let e=0;return ()=>`m-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,8)}`}i(Fa,"defaultIdFactory");function Ma(){let e=0;return ()=>`chat-send-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(Ma,"defaultIdempotencyFactory");var Na={setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")};async function*Da(e,t,r,n){let o=e[Symbol.asyncIterator](),s=La(t.overallMs,n),a=La(t.idleMs,n),l=Iy(r);try{for(;;){if(r.aborted)return;let u=o.next().then(p=>({tag:"next",value:p}),()=>({tag:"streamError"})),d=await Promise.race([u,a.promise.then(()=>({tag:"idle"})),s.promise.then(()=>({tag:"overall"})),l.then(()=>({tag:"abort"}))]);if(d.tag==="abort")return;if(d.tag==="streamError"){if(r.aborted)return;yield wy();return}if(d.tag==="idle"||d.tag==="overall"){yield _y();return}let c=d.value;if(c.done||(a.reset(t.idleMs),yield c.value,c.value.terminal))return}}finally{a.cancel(),s.cancel(),Promise.resolve(o.return?.(void 0)).catch(()=>{});}}i(Da,"withWatchdog");function _y(){return ye({code:"STREAM_TIMEOUT",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(_y,"synthTimeoutFrame");function wy(){return ye({code:"STREAM_INCOMPLETE",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(wy,"synthStreamErrorFrame");function La(e,t){let r=i(()=>{},"resolveFn"),n=new Promise(s=>{r=s;}),o=t.setTimeout(()=>r(),e);return {promise:n,reset(s){t.clearTimeout(o),o=t.setTimeout(()=>r(),s);},cancel(){t.clearTimeout(o);}}}i(La,"deadline");function Iy(e){return new Promise(t=>{if(e.aborted){t();return}e.addEventListener("abort",()=>t(),{once:true});})}i(Iy,"abortPromise");var Ay="checkin",Oy=/^\d{4}-\d{2}-\d{2}$/,on="watching";function Ua(e){return e.status!=null&&e.status!==on}i(Ua,"isCheckinSettled");function Va(e){let{askCount:t,answerCount:r}=e;return typeof t!="number"||!Number.isFinite(t)||typeof r!="number"||!Number.isFinite(r)||t<=0?true:r>=t}i(Va,"isLiveAskAnswered");function Io(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,o]=t;return r!==Ay||n===void 0||o===void 0||!Ro.test(n)||!Oy.test(o)?null:{caseId:n,dueDay:o}}i(Io,"parseCheckinOrigin");function Ba(e){return Io(e)?.caseId??null}i(Ba,"parseCheckinOriginRef");function Oo(e,t){if(e?.limit!==void 0&&(!Number.isInteger(e.limit)||e.limit<1||e.limit>t))return v(D("validationFailed"));let r=[];for(let[n,o]of [["cursor",e?.cursor],["pet_ref",e?.petRef]])if(o!==void 0){if(typeof o!="string"||o.length===0||Ce(o))return v(D("validationFailed"));r.push(`${n}=${encodeURIComponent(o)}`);}return e?.limit!==void 0&&r.push(`limit=${e.limit}`),L(r.length?`?${r.join("&")}`:"")}i(Oo,"historyQuery");function lr(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}i(lr,"validConversationId");function Vt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}i(Vt,"object");function Ha(e){return e==null||typeof e=="string"&&e.length>0&&!Ce(e)}i(Ha,"cursor");function ar(){return v(D("internalError",{retryable:false}))}i(ar,"malformed");function za(e){let t=Vt(e);if(!t||!Array.isArray(t.conversations)||!Ha(t.next_cursor))return ar();let r=[];for(let n of t.conversations){let o=Vt(n);if(!o||typeof o.conversation_id!="string"||!lr(o.conversation_id)||!(o.title==null||typeof o.title=="string")||typeof o.created_at!="string"||typeof o.updated_at!="string")return ar();let s=o.unread_message_count;if(!(s==null||Number.isInteger(s)&&s>=0))return ar();r.push(Object.freeze({id:o.conversation_id,title:o.title??null,createdAt:o.created_at,updatedAt:o.updated_at,unreadCount:s??null}));}return L(Object.freeze({conversations:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(za,"mapConversationPage");function ja(e){let t=Vt(e);if(!t||!Array.isArray(t.messages)||!Ha(t.next_cursor))return ar();let r=[],n=new Set;for(let o of t.messages){let s=Vt(o);if(!s||typeof s.message_id!="string"||!lr(s.message_id)||typeof s.role!="string"||typeof s.content!="string"||typeof s.created_at!="string")return ar();if(s.role!=="user"&&s.role!=="assistant"&&s.role!=="vet"||n.has(s.message_id))continue;if(n.add(s.message_id),s.role==="vet"){r.push(Fy(s,s.message_id,s.content,s.created_at));continue}let a=typeof s.proactive_origin_ref=="string"?s.proactive_origin_ref:null,l=s.role==="assistant"?Ba(a):null;r.push(Object.freeze({id:s.message_id,role:s.role,text:s.content,createdAt:s.created_at,...s.role==="assistant"?{responseId:s.message_id}:{},...s.urgency_level!==void 0?{urgencyLevel:My(s.urgency_level)}:{},...Array.isArray(s.citations)?{citations:Ly(s.citations)}:{},...a!==null?{proactiveOriginRef:a}:{},...l!==null?{checkin:Object.freeze({caseId:l,answer:null,resolutionText:null,status:null})}:{}}));}return L(Object.freeze({messages:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(ja,"mapMessagePage");function Fy(e,t,r,n){let o=Vt(e.sender),s=Ao(o?.display_name)??Ao(e.sender_display_name),a=Ao(o?.specialty);return Object.freeze({id:t,role:"vet",text:r,createdAt:n,sender:Object.freeze({displayName:s,specialty:a})})}i(Fy,"vetMessage");function Ao(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&!Ce(t)?t:null}i(Ao,"trimmedText");function My(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(My,"normalizeUrgency");function Ly(e){let t=["source_name","source_abbrev","section","authority_tier","doi","url","title","year","study_type","journal","excerpt","monograph_chunk_id"];return Object.freeze(e.flatMap(r=>{let n=Vt(r);if(!n||typeof n.source_name!="string"||typeof n.authority_tier!="string")return [];let o={};for(let s of t){let a=n[s];(typeof a=="string"||a===null)&&(o[s]=a);}return [Object.freeze(o)]}))}i(Ly,"historyCitations");var Fo=Object.freeze(["helpful","neutral","not_helpful","wrong","outdated","dangerous","unclear"]),Bt=4e3;var Ht=4e3;function Wa(e){return e===void 0?null:!Array.isArray(e)||e.length>5?{reason:"too_many_images",error:U("validationFailed",false,`image_s3_keys accepts at most ${5} keys`)}:e.some(t=>typeof t!="string"||t.trim().length===0)?{reason:"bad_image_key",error:U("validationFailed",false,"image_s3_keys must be non-empty strings")}:null}i(Wa,"validateImageKeys");function Lo(e){let t=typeof e=="string"?e:"";if(t.trim().length===0)return {reason:"empty",error:U("validationFailed",false,"message is empty or whitespace-only")};let r=[...t].length;return r>Ht?{reason:"too_long",error:U("validationFailed",false,`message is ${r} characters; the server accepts at most ${Ht}`)}:null}i(Lo,"validateMessageText");function Ga(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(Ga,"urgencyTier");async function*ur(e){yield e;}i(ur,"singleFrameStream");async function*Ka(){}i(Ka,"emptyStream");var Ny=6e4,Dy=18e4,Uy=24,Vy=512,By=false;function qa(e){return new No(e)}i(qa,"createChatController");var Do=class Do extends tn{constructor(r){super(Aa({status:"idle",messages:[],conversationId:r.initialConversationId??null,error:null,isStreaming:false,isBootstrapping:false,suggestedPrompts:[],unreadCount:null}));this.handlerTeardowns=new Set;this.lastTurn=null;this.unadoptedCreate=null;this.lastResponseIdValue=null;this.historyGeneration=0;this.disposed=false;this.bootstrapPrompts=[];this.scopePrompts=[];this.replyPrompts=null;this.unreadByConversation=new Map;this.classifiedMessageIds=new Set;this.pendingDelta="";this.flushHandle=null;this.auth=r.auth,this.funnel=r.funnel??Ie({auth:r.auth,...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),this.petRef=r.petRef??null,this.cases=xa(this.funnel),this.telemetry=r.telemetry??Qr,this.errorPolicy=r.errorPolicy??js,this.timers=r.timers??Na,this.rng=r.rng??Math.random,this.newId=r.newId??Fa(),this.makeIdempotencyKey=r.makeIdempotencyKey??Ma(),this.budget={idleMs:r.budget?.idleMs??Ny,overallMs:r.budget?.overallMs??Dy};}patch(r){if(r.messages!==void 0){let n=Object.freeze([...r.messages]);super.patch({...r,messages:n});return}super.patch(r);}send(r,n,o){let s=n??{};if(this.disposed||this.snapshot.isBootstrapping){let u=U(this.disposed?"accessDenied":"internalError",!this.disposed);return o?(o.onError(u),()=>{}):ur(Me(u))}let a=Lo(r)??Wa(s.imageS3Keys);if(a!==null)return this.telemetry.track("chat.send.rejected",{reason:a.reason}),this.patch({status:"error",isStreaming:false,error:a.error}),o?(o.onError(a.error),()=>{}):ur(Me(a.error));if(o)return this.driveWithHandlers(r,s,o);let l=this.beginTurn(r,s);return this.runTurn(l,s.signal)}askEverfur(r,n){if(this.disposed)return ur(Me(U("accessDenied",false)));let o=Lo(r);return o!==null?(this.telemetry.track("chat.send.rejected",{reason:o.reason}),ur(Me(o.error))):(this.resetThread(),this.send(r,n??{}))}retryLast(){let r=this.lastTurn;if(r===null){let s=this.snapshot.conversationId;return s!==null&&this.snapshot.status==="error"?this.retryHistory(s):Ka()}r.assistantMessageId=null,r.sawDelta=false,r.conversationIdOverride=null,this.discardPendingDelta();let o=this.snapshot.messages.some(s=>s.id===r.userMessageId)?this.snapshot.messages:[...this.snapshot.messages,Po(r.userMessageId,r.text,this.stamp())];return this.patch({error:null,stopped:false,messages:o}),this.runTurn(r,void 0)}stop(){this.inFlight?.abort(),this.inFlight=null,this.discardPendingDelta(),this.telemetry.track("chat.cancel",{});let r=this.snapshot.messages.some(o=>o.role==="user"&&o.pending===true),n=r?this.snapshot.messages.map(o=>o.pending===true?sr(o):o):this.snapshot.messages;(this.snapshot.status==="streaming"||r)&&this.patch({status:"idle",isStreaming:false,reconnecting:false,...r?{messages:n,stopped:true}:{}});}rescope(){this.resetThread(),this.scopePrompts=[],this.unreadByConversation.clear(),this.classifiedMessageIds.clear(),this.reflectUnreadDot();}resetThread(r=[]){super.rescope(),this.historyGeneration+=1,this.unadoptedCreate=null,this.lastTurn=null,this.lastResponseIdValue=null,this.bootstrapPrompts=r,this.replyPrompts=null,this.discardPendingDelta(),this.patch({status:"idle",isStreaming:false,messages:[],conversationId:null,error:null,suggestedPrompts:r,historyCursor:null,isLoadingHistory:false,isBootstrapping:false,unreadCount:null,stopped:false,reconnecting:false});}newConversation(){this.disposed||this.resetThread(this.scopePrompts);}dispose(){this.rescope(),this.disposed=true,this.unadoptedCreate=null,this.discardPendingDelta();for(let r of this.handlerTeardowns)r();this.handlerTeardowns.clear(),super.dispose();}adoptConversation(r){this.disposed||(this.unadoptedCreate=null,this.snapshot.conversationId!==r&&this.patch({conversationId:r}));}adoptPrompts(r){if(this.disposed)return;let n=Object.freeze(wo(r));this.bootstrapPrompts=n,this.scopePrompts=n,this.replyPrompts===null&&(n.length===0&&this.snapshot.suggestedPrompts.length===0||this.patch({suggestedPrompts:n}));}async listConversations(r){return this.listConversationsWith(r)}async listConversationsWith(r,n){let o=Oo(r,100);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return v(U("accessDenied",false));let a=await this.authedUnary("chat.listConversations",{method:"GET",path:`/widget/v1/conversations${o.value}`},r?.signal,n);if(!this.alive(s)||this.disposed)return v(U("accessDenied",false));if(!a.ok)return a;let l=za(a.value);if(l.ok){for(let c of l.value.conversations)c.unreadCount!==null&&this.unreadByConversation.set(c.id,c.unreadCount);let u=this.snapshot.conversationId,d=u===null?void 0:this.unreadByConversation.get(u);d!==void 0&&d!==this.snapshot.unreadCount&&this.patch({unreadCount:d}),this.reflectUnreadDot();}return l}reflectUnreadDot(){let r=false;for(let n of this.unreadByConversation.values())if(n>0){r=true;break}r!==(this.snapshot.hasUnreadThreads??false)&&this.patch({hasUnreadThreads:r});}async openCheckin(r){if(this.disposed)return v(U("accessDenied",false));let n=r?.conversationId??null;if(n!==null){let u=await this.resumeConversation(n);return u.ok?L(n):v(u.error)}let o=r?.petRef??this.petRef,s=await this.listConversations({...o===null?{}:{petRef:o},limit:1});if(!s.ok)return v(s.error);let a=s.value.conversations[0];if(a===void 0)return L(null);let l=await this.resumeConversation(a.id);return l.ok?L(a.id):v(l.error)}async markRead(r){if(this.disposed)return v(U("accessDenied",false));let n=this.snapshot.conversationId;if(n===null)return L(void 0);let o=this.epoch,s=await this.authedUnary("chat.markRead",{method:"POST",path:`/widget/v1/conversations/${n}/read`},r?.signal);return !this.alive(o)||this.disposed?v(U("accessDenied",false)):s.ok?(this.unreadByConversation.set(n,0),this.snapshot.conversationId===n&&this.snapshot.unreadCount!==0&&this.patch({unreadCount:0}),this.reflectUnreadDot(),L(void 0)):v(s.error)}async submitFeedback(r,n,o,s){if(this.disposed)return v(U("accessDenied",false));if(typeof r!="string"||r.trim().length===0||Ce(r))return v(U("validationFailed",false,"feedback needs the server message id of an assistant reply"));if(!Fo.includes(n))return v(U("validationFailed",false,`feedback_type must be one of ${Fo.join(", ")}`));let a=typeof o=="string"?o.trim():"";if([...a].length>Bt)return v(U("validationFailed",false,`notes is over ${Bt} characters`));let l={feedback_type:n};a.length>0&&(l.notes=a);let u=this.epoch,d=await this.authedUnary("chat.submitFeedback",{method:"POST",path:`/widget/v1/messages/${encodeURIComponent(r)}/feedback`,body:l},s?.signal);if(!this.alive(u)||this.disposed)return v(U("accessDenied",false));if(!d.ok)return v(d.error);let c=d.value?.feedback_id;return L(Object.freeze({feedbackId:typeof c=="string"?c:""}))}async answerCheckin(r,n,o){if(this.disposed)return v(U("accessDenied",false));let s=o?.petRef??this.petRef;if(s===null)return v(U("validationFailed",false,"a check-in needs the pet the case belongs to"));let a=this.epoch,l=await this.cases.checkin(s,r,n,o?.signal?{signal:o.signal}:{});if(!this.alive(a)||this.disposed)return v(U("accessDenied",false));if(!l.ok)return l;let u=l.value.case.openedAt,d=Object.freeze({caseId:r,answer:n,resolutionText:l.value.case.resolutionText,status:l.value.case.status??null,...u!==null?{openedAt:u}:{}}),c=i(p=>p.checkin?.caseId===r,"carries");return this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,checkin:d}):p)}),l}async getMessages(r,n){if(!lr(r))return v(U("validationFailed",false));let o=Oo(n,200);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return v(U("accessDenied",false));let a=await this.authedUnary("chat.getMessages",{method:"GET",path:`/widget/v1/conversations/${r}/messages${o.value}`},n?.signal);return !this.alive(s)||this.disposed?v(U("accessDenied",false)):a.ok?ja(a.value):a}async resumeConversation(r){if(this.disposed)return v(U("accessDenied",false));if(!lr(r))return v(U("validationFailed",false));this.resetThread();let n=this.historyGeneration;this.patch({conversationId:r,isBootstrapping:true,isLoadingHistory:true});let o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return v(U("accessDenied",false));if(!o.ok)return this.patch({status:"error",error:o.error,isBootstrapping:false,isLoadingHistory:false}),o;let s=this.unreadByConversation.get(r)??null;return this.patch({messages:o.value.messages,historyCursor:o.value.nextCursor,isBootstrapping:false,isLoadingHistory:false,unreadCount:s}),this.stampCheckinStatuses(n),s!==null&&s>0&&this.markRead(),L(void 0)}async stampCheckinStatuses(r){let n=this.petRef;if(n===null||!this.snapshot.messages.some(d=>d.checkin!==void 0&&d.checkin.status===null))return;let o=await this.cases.list(n);if(!o.ok||r!==this.historyGeneration||this.disposed)return;let s=new Set(o.value.filter(d=>d.status===on).map(d=>d.caseId)),a=new Map(o.value.map(d=>[d.caseId,d])),l=false,u=this.snapshot.messages.map(d=>{let c=d.checkin;if(c===void 0||c.status!==null)return d;l=true;let p=a.get(c.caseId),f=c.openedAt??p?.openedAt??null,m=s.has(c.caseId),h=p!==void 0&&(!m||Va({askCount:p.checkinAskCount,answerCount:p.checkinAnswerCount}))?p.lastResponse:null;return Object.freeze({...d,checkin:Object.freeze({...c,status:m?on:p?.status??"resolved",answer:c.answer??h,resolutionText:c.resolutionText??p?.resolutionText??null,...f!==null?{openedAt:f}:{}})})});l&&this.patch({messages:u});}async refreshActiveThread(){if(this.disposed)return v(U("accessDenied",false));let r=this.snapshot.conversationId;if(r===null||this.snapshot.isStreaming)return L(void 0);let n=this.historyGeneration,o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return v(U("accessDenied",false));if(!o.ok)return v(o.error);let s=new Set(this.snapshot.messages.map(l=>l.id)),a=o.value.messages.filter(l=>!s.has(l.id));return a.length>0&&this.patch({messages:[...this.snapshot.messages,...a]}),await this.listConversationsWith({...this.petRef===null?{}:{petRef:this.petRef},limit:1},{maxAttempts:1}),L(void 0)}async loadOlderMessages(){if(this.disposed)return v(U("accessDenied",false));let r=this.snapshot.conversationId,n=this.snapshot.historyCursor;if(!r||!n||this.snapshot.isLoadingHistory)return L(void 0);let o=this.historyGeneration;this.patch({isLoadingHistory:true});let s=await this.getMessages(r,{cursor:n});if(o!==this.historyGeneration||this.disposed)return v(U("accessDenied",false));if(this.patch({isLoadingHistory:false}),!s.ok)return s;let a=new Set(this.snapshot.messages.map(u=>u.id)),l=s.value.messages.filter(u=>!a.has(u.id));return this.patch({messages:[...l,...this.snapshot.messages],historyCursor:s.value.nextCursor===n?null:s.value.nextCursor}),L(void 0)}async*retryHistory(r){let n=await this.resumeConversation(r);n.ok||(yield Me(n.error));}async primeConversation(r){if(this.disposed)return v(U("accessDenied",false));let n=r?.petRef??null,o={petRef:n,settled:this.primeBounded(n)};this.unadoptedCreate=o;let s=await o.settled;return this.disposed?v(U("accessDenied",false)):(!s.ok&&this.unadoptedCreate===o&&(this.unadoptedCreate=null),s)}async primeBounded(r){let n=await this.headThreadWithUnread(r);return n.ok?n.value!==null&&!this.snapshot.isStreaming&&this.snapshot.conversationId===null&&(await this.resumeConversation(n.value)).ok?L(n.value):L(this.snapshot.conversationId):n.error.code==="accessDenied"||n.error.httpStatus===403?L(null):v(n.error)}async headThreadWithUnread(r){let n=await this.listConversationsWith({...r===null?{}:{petRef:r},limit:1},{maxAttempts:1});if(!n.ok)return v(n.error);let o=n.value.conversations[0];return o===void 0||o.unreadCount===null||o.unreadCount<=0?L(null):L(o.id)}async createConversation(r){let n=this.epoch;if(this.disposed)return v(U("accessDenied",false));let o=r?.petRef??null,s={petRef:o,settled:this.createConversationBounded(o)};this.unadoptedCreate=s;let a=await s.settled;return !this.alive(n)||this.disposed?v(U("accessDenied",false)):(!a.ok&&this.unadoptedCreate===s&&(this.unadoptedCreate=null),a)}async createConversationBounded(r,n){let o={method:"POST",path:"/widget/v1/conversations",body:r?{pet_ref:r}:{}},s=await this.authedUnary("chat.createConversation",o,n,{maxAttempts:1});if(!s.ok)return v(s.error);let a=s.value?.conversation_id??s.value?.id;return typeof a!="string"||a.length===0?v(U("internalError",true)):L(a)}async getPrompts(r){let n=this.epoch;if(this.disposed)return v(U("accessDenied",false));let o=r?.petRef??null;if(o!==null&&Ce(o))return v(D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}));let s=o!==null?`?pet_ref=${encodeURIComponent(o)}`:"",a=await this.authedUnary("chat.getPrompts",{method:"GET",path:`/widget/v1/suggested-prompts${s}`});return !this.alive(n)||this.disposed?v(U("accessDenied",false)):a.ok?L(Oa(a.value)):v(a.error)}async authedUnary(r,n,o,s){return this.funnel.send(r,o?{...n,signal:o}:n,s)}driveWithHandlers(r,n,o){let s=new AbortController,a=nn(s.signal,n.signal),l=this.beginTurn(r,n),u=this.runTurn(l,a),d=false,c=i(()=>{d||(d=true,s.abort(),this.handlerTeardowns.delete(c));},"teardown");return this.handlerTeardowns.add(c),(async()=>{for await(let p of u){if(d)break;o.onFrame(p),p.kind==="done"&&o.onDone(this.lastResponseIdValue);}!d&&this.snapshot.status==="error"&&this.snapshot.error!==null&&o.onError(this.snapshot.error),this.handlerTeardowns.delete(c);})(),c}beginTurn(r,n){let o={epoch:this.epoch,text:r,petRef:n.petRef??null,imageS3Keys:Object.freeze([...n.imageS3Keys??[]]),idempotencyKey:n.idempotencyKey??this.makeIdempotencyKey(),userMessageId:this.newId(),assistantMessageId:null,sawDelta:false,conversationIdOverride:n.conversationId??null};return this.patch({error:null,stopped:false,reconnecting:false,messages:[...this.snapshot.messages,Po(o.userMessageId,r,this.stamp())]}),o}async*runTurn(r,n){let o=this.beginOperation(n);r.epoch=o.epoch,this.patch({status:"streaming",isStreaming:true,error:null}),this.lastTurn=r;let s=0,a=false,l=false;try{for(;;){if(o.signal.aborted||!this.alive(o.epoch))return;let u=r.conversationIdOverride===null&&this.snapshot.conversationId===null,d=u?this.unadoptedCreate:null;if(d!==null&&(r.petRef===null||r.petRef===d.petRef)){let b=await d.settled;if(o.signal.aborted||!this.alive(o.epoch))return;b.ok&&b.value!==null&&this.snapshot.conversationId===null&&this.adoptConversation(b.value);}if(u&&this.snapshot.conversationId===null){let b=await this.createConversationBounded(r.petRef,o.signal);if(o.signal.aborted||!this.alive(o.epoch))return;if(!b.ok){yield*this.emitTerminal(r,b.error,Me(b.error));return}this.adoptConversation(b.value);}let c=r.conversationIdOverride??this.snapshot.conversationId;if(c===null){let b=U("internalError",!0);yield*this.emitTerminal(r,b,Me(b));return}this.clearAssistantInProgress(r);let p=new AbortController,f=nn(o.signal,p.signal),m=null;try{let b;try{b=await this.funnel.authorize(this.buildSendRequest(r,c));}catch{let P=this.authRejected();yield*this.emitTerminal(r,P,Me(P));return}if(o.signal.aborted||!this.alive(o.epoch))return;let S=this.funnel.stream("chat.send",b,f);for await(let P of Da(S,this.budget,f,this.timers)){if(!this.alive(o.epoch))return;if(P.kind==="error"&&P.terminal){m=P;break}if(this.applyFrame(P,r),yield P,P.terminal){o.settle();return}}}finally{p.abort();}if(o.signal.aborted||!this.alive(o.epoch))return;if(m===null){if(this.snapshot.status==="complete")return;let b=U("streamIncomplete",!0);yield*this.emitTerminal(r,b,Me(b));return}let h=Fe(m.code);if(h==="authExpired"&&this.auth.mode==="personalized"&&!l){l=!0,this.telemetry.track("chat.auth.refresh",{});let b=await this.tryForceRefresh();if(o.signal.aborted||!this.alive(o.epoch))return;if(!b){let S=this.authRejected();yield*this.emitTerminal(r,S,m);return}this.patch({reconnecting:!0});continue}if(h==="authExpired"){this.telemetry.track("chat.auth.rejected",{});let b=this.authRejected();yield*this.emitTerminal(r,b,m);return}if(h==="accessDenied"){this.telemetry.track("chat.access_denied",{}),yield*this.emitTerminal(r,_o(m),m);return}if(Us(h)&&!a){a=!0,this.telemetry.track("chat.conv.recreate",{}),this.adoptConversation(null),r.conversationIdOverride=null,this.patch({reconnecting:!0});continue}let T=m.retryable&&qr(h,!0);if(By&&T&&s+1<this.errorPolicy.maxAttempts(h));yield*this.emitTerminal(r,_o(m),m);return}}finally{o.settle();}}*emitTerminal(r,n,o){this.applyError(r,n),yield o;}applyFrame(r,n){switch(r.kind){case "accepted":this.snapshot.isStreaming||this.patch({status:"streaming",isStreaming:true});return;case "heartbeat":return;case "delta":this.applyDelta(r.delta,n);return;case "done":this.applyDone(r,n);return;case "analysisStarted":case "analysisComplete":return;case "unknown":this.telemetry.track("chat.frame.unknown",{});return;case "error":return;default:return at(r)}}stamp(){return new Date(this.timers.now()).toISOString()}applyDelta(r,n){if(n.assistantMessageId===null){let o=this.newId();n.assistantMessageId=o,n.sawDelta=true;let s=this.snapshot.messages.map(a=>a.id===n.userMessageId&&a.pending===true?sr(a):a);this.patch({status:"streaming",isStreaming:true,messages:[...s,ko(o,r,this.stamp())]});return}if(this.pendingDelta+=r,this.pendingDelta.length>=Vy){this.flushPendingDelta(n);return}this.scheduleDeltaFlush(n);}scheduleDeltaFlush(r){if(this.flushHandle!==null)return;let n=this.epoch;this.flushHandle=this.timers.setTimeout(()=>{if(this.flushHandle=null,!this.alive(n)){this.pendingDelta="";return}this.flushPendingDelta(r);},Uy);}flushPendingDelta(r){if(this.clearFlushTimer(),this.pendingDelta.length===0)return;let n=this.pendingDelta;this.pendingDelta="";let o=r.assistantMessageId;if(o===null)return;let s=this.snapshot.messages.map(a=>a.id===o?Ia(a,n):a);this.patch({messages:s});}discardPendingDelta(){this.clearFlushTimer(),this.pendingDelta="";}clearFlushTimer(){this.flushHandle!==null&&(this.timers.clearTimeout(this.flushHandle),this.flushHandle=null);}applyDone(r,n){this.flushPendingDelta(n),this.lastResponseIdValue=r.messageId?r.messageId:null;let o=r.conversationId?r.conversationId:this.snapshot.conversationId,s;if(n.assistantMessageId!==null)s=this.snapshot.messages.map(l=>l.id===n.assistantMessageId?xo(l,r):l);else {let l=this.newId();n.assistantMessageId=l,n.sawDelta=true,s=[...this.snapshot.messages.map(d=>d.id===n.userMessageId&&d.pending===true?sr(d):d),xo(ko(l,"",this.stamp()),r)];}let a=wo([{category:"",prompts:r.followUpQuestions}]);this.replyPrompts=a.length>0?Object.freeze(a):null,this.patch({status:"complete",isStreaming:false,error:null,conversationId:o,messages:s,suggestedPrompts:this.replyPrompts??this.bootstrapPrompts,reconnecting:false}),!r.urgencyProvided&&o!==null&&this.classifyTurn(o,this.lastResponseIdValue);}async classifyTurn(r,n){if(n===null||this.disposed)return;let o=String(n);if(this.classifiedMessageIds.has(o))return;this.classifiedMessageIds.add(o);let s=this.epoch,a=this.historyGeneration,l=await this.authedUnary("chat.classifyUrgency",{method:"POST",path:`/widget/v1/conversations/${r}/classify`});if(!l.ok||!this.alive(s)||this.disposed||a!==this.historyGeneration||this.snapshot.conversationId!==r)return;let u=Ga(l.value?.urgency),d=typeof l.value?.reason=="string"?l.value.reason:null,c=i(p=>p.responseId===n,"carries");this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,urgencyLevel:u,urgencyReason:d,urgencyProvided:true}):p)});}applyError(r,n){this.flushPendingDelta(r);let o=this.snapshot.messages.map(s=>s.id===r.userMessageId&&s.pending===true?sr(s):s);this.patch({status:"error",isStreaming:false,error:n,messages:o,reconnecting:false});try{this.errorPolicy.onExpectedFailure?.(n);}catch{}}clearAssistantInProgress(r){if(this.discardPendingDelta(),r.assistantMessageId===null)return;let n=r.assistantMessageId;r.assistantMessageId=null,r.sawDelta=false;let o=this.snapshot.messages.filter(s=>s.id!==n);o.length!==this.snapshot.messages.length&&this.patch({messages:o});}buildSendRequest(r,n){let o={message:r.text};return r.imageS3Keys.length>0&&(o.image_s3_keys=r.imageS3Keys),{method:"POST",path:`/widget/v1/conversations/${n}/messages`,body:o,headers:{"Idempotency-Key":r.idempotencyKey}}}async tryForceRefresh(){if(this.auth.mode!=="personalized")return false;try{return await this.auth.identity.currentToken({forceRefresh:!0}),!0}catch{return false}}authRejected(){return U("authRejected",false)}};i(Do,"ChatControllerImpl");var No=Do;async function Xa(e,t){let{controller:r}=t,n=e.petRef??null,o=e.resumeConversationId??null,s=[],a=false,l=false,u=false,d=null,c=null,p=o?r.resumeConversation(o).then(x=>x.ok?L(o):v(x.error)):r.primeConversation(n?{petRef:n}:void 0),f=r.getPrompts(n!==null?{petRef:n}:void 0),[m,h]=await Promise.all([p,f]),T=null;if(m.ok)T=m.value,m.value!==null&&s.push(m.value),m.value!==null&&r.getSnapshot().conversationId===null&&r.adoptConversation(m.value);else {let x=m.error;c=x,$a(x)?(l=true,d=x):(Ya(x)&&(a=true),u=true);}let b=[];h.ok?b=h.value:S(h.error);function S(x){$a(x)?(l=true,d===null&&(d=x)):Ya(x)&&(a=true);}i(S,"recordAuthSignals");let P=d!==null?d.displayMessage:null;return Object.freeze({conversationId:T,petRef:n,suggestedPrompts:b,error:P,warning:P===null&&T===null&&u?Hy:null,cause:d??c,diagnostics:Object.freeze({candidateConversationIds:Object.freeze([...s]),sawForbidden:a,sawUnauthorized:l,sawConversationInitFailure:u})})}i(Xa,"bootstrapChat");var Hy="Chat is ready. Your first message will start the conversation.";function $a(e){return e.httpStatus===401||e.code==="authExpired"||e.code==="authRejected"}i($a,"isUnauthorized");function Ya(e){return e.httpStatus===403||e.code==="accessDenied"}i(Ya,"isForbidden");var Uo=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Qa(e){return e!==Uo}i(Qa,"isUploadTransportAvailable");var zy=Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var sn=10*1024*1024,an=5,dr=120,jy="/widget/v1/uploads/initiate";function Wy(e){return typeof e=="string"&&zy.includes(e.trim().toLowerCase())}i(Wy,"isAttachmentMime");function Vo(e){if(!e)return "attachment";let t=e.replace(/[\\/]+/g," ").replace(/[\x00-\x1f\x7f"]/g,"").replace(/\s+/g," ").trim();if(!t)return "attachment";if(t.length<=dr)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,dr);let n=t.slice(r);return n.length>=dr?t.slice(0,dr):`${t.slice(0,r).slice(0,dr-n.length)}${n}`}i(Vo,"sanitizeFilename");function Bo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i(Bo,"formatBytes");var cr=i(e=>Object.freeze({ok:true,value:e}),"ok"),Ae=i(e=>Object.freeze({ok:false,error:e}),"err");function ue(e,t,r,n){return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}i(ue,"failure");function Gy(e){if(typeof e.sizeBytes=="number"&&Number.isFinite(e.sizeBytes)&&e.sizeBytes>=0)return e.sizeBytes;let t=e.blob;return t!==void 0&&typeof t.size=="number"&&Number.isFinite(t.size)?t.size:null}i(Gy,"attachmentSize");function Ky(e){let t=Vo(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!Wy(r))return Ae(ue("unsupported_type",false,t));let n=Gy(e);return n===null?Ae(ue("unknown",false,t)):n>sn?Ae(ue("too_large",false,t,{sizeBytes:n})):cr(Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}i(Ky,"validateAttachment");function qy(e){if(typeof e!="object"||e===null)return null;let t=e,r=i(d=>typeof d=="string"&&d.length>0?d:null,"str"),n=i(d=>typeof d=="number"&&Number.isFinite(d)?d:null,"num"),o=r(t.upload_id),s=r(t.upload_url),a=r(t.s3_key);if(o===null||s===null||a===null)return null;let l={},u=t.upload_fields;if(typeof u=="object"&&u!==null)for(let[d,c]of Object.entries(u))typeof c=="string"&&(l[d]=c);return Object.freeze({upload_id:o,upload_url:s,upload_fields:Object.freeze(l),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??sn,s3_key:a,purpose:r(t.purpose)})}i(qy,"parsePolicy");function $y(e,t){let r=e.httpStatus;switch(e.code){case "quotaExceeded":return ue("quota_exceeded",false,t,{cause:e});case "rateLimited":return ue("rate_limited",true,t,{cause:e});case "idempotencyConflict":case "idempotencyInFlight":return ue("idempotency_conflict",true,t,{cause:e});case "validationFailed":return ue("unsupported_type",false,t,{cause:e});case "serviceUnavailable":case "streamTimeout":return ue("network",true,t,{cause:e});default:return r===429?ue("rate_limited",true,t,{cause:e}):r===503?ue("network",true,t,{cause:e}):r===void 0?ue("network",true,t,{cause:e}):ue("server",e.retryable,t,{httpStatus:r,cause:e})}}i($y,"initiateFailure");async function Yy(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:jy,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return Ae($y(n.error,t.filename));let o=qy(n.value);return o===null?Ae(ue("server",false,t.filename)):cr(o)}i(Yy,"initiateAttachmentUpload");async function Xy(e,t,r,n){let o=i(()=>n?.signal?.aborted===true,"cancelled");if(o())return Ae(ue("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),cr(void 0)}catch{return o()?Ae(ue("cancelled",true,r.filename)):Ae(ue("server",true,r.filename))}}i(Xy,"uploadAttachmentBytes");var Qy=2,Zy=3,Jy=Object.freeze([1e3,2e3,4e3]),Za=0;function eg(){return Za+=1,`attachment-${Za}`}i(eg,"defaultNewId");function Ja(e){let t=Math.max(1,e.concurrency??Qy),r=Math.max(1,e.maxAttempts??Zy),n=e.backoffMs??Jy,o=Math.max(1,e.maxPerMessage??an),s=e.timers??wa,a=e.newId??eg,l=Qa(e.transport),u=new Map,d=[],c=[],p=new Set,f=new Set,m=Object.freeze({attachments:Object.freeze([])}),h=false,T=i(()=>{m=Object.freeze({attachments:Object.freeze(d.flatMap(y=>{let _=u.get(y);return _===void 0?[]:[_.state]}))});for(let y of f)y();},"publish"),b=i((y,_)=>{y.state=Object.freeze({...y.state,..._}),T();},"patch"),S=i(()=>{for(;!h&&p.size<t&&c.length>0;){let y=c.shift(),_=u.get(y);_!==void 0&&(p.add(y),P(_).finally(()=>{p.delete(y),S();}));}},"pump"),P=i(async y=>{let{attachment:_}=y;for(;y.attempts<r;){if(h||y.controller.signal.aborted)return;y.attempts+=1;let A=y.controller.signal;b(y,{status:"uploading",error:null,progress:0});let O=await Yy(e.funnel,_,{signal:A});if(h||A.aborted)return;let F;if(!O.ok)F=Ae(O.error);else {let H=await Xy(e.transport,O.value,_,{signal:A,onProgress:i(Q=>{!A.aborted&&y.state.status==="uploading"&&b(y,{progress:tg(Q)});},"onProgress")});if(h||A.aborted)return;F=H.ok?cr(O.value.s3_key):Ae(H.error);}if(F.ok){b(y,{status:"uploaded",s3Key:F.value,error:null,progress:1});return}let C=F.error,w=C.retryable&&y.attempts<r;if(b(y,{status:w?"uploading":"failed",error:C,progress:0}),!w)return;let I=n[Math.min(y.attempts-1,n.length-1)]??0;await rn(I,A,s);}},"run"),k=i(y=>{c.push(y.state.id),S();},"enqueue"),x={available:l,subscribe(y){return f.add(y),()=>{f.delete(y);}},getSnapshot:i(()=>m,"getSnapshot"),get uploading(){return m.attachments.some(y=>y.status==="uploading")},get s3Keys(){return m.attachments.flatMap(y=>y.status==="uploaded"&&y.s3Key!==null?[y.s3Key]:[])},add(y){let _=Ky(y);if(!_.ok)return _;if(h||d.length>=o)return Ae(ue("too_many",false,_.value.filename));let A=a(),O={attachment:_.value,controller:new AbortController,attempts:0,state:Object.freeze({id:A,filename:_.value.filename,previewUri:y.uri,contentType:_.value.contentType,sizeBytes:_.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return u.set(A,O),d.push(A),T(),k(O),cr(O.state)},retry(y){let _=u.get(y);_===void 0||h||_.state.status!=="failed"||(_.controller=new AbortController,_.attempts=0,b(_,{status:"uploading",error:null,progress:0,s3Key:null}),k(_));},remove(y){let _=u.get(y);if(_===void 0)return;_.controller.abort(),u.delete(y);let A=d.indexOf(y);A>=0&&d.splice(A,1);let O=c.indexOf(y);O>=0&&c.splice(O,1),T();},clear(){for(let y of [...d])x.remove(y);},dispose(){h=true;for(let y of u.values())y.controller.abort();u.clear(),d.length=0,c.length=0,f.clear(),m=Object.freeze({attachments:Object.freeze([])});}};return x}i(Ja,"createAttachmentQueue");function tg(e){return Number.isNaN(e)||e<0?0:e>1?1:e}i(tg,"clamp");var el=Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function pr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(el,t)?el[t]:null}i(pr,"canonicalPetSpecies");var tl=50,rg=128,Ho=120,rl=120,ng=2e3,nl=120,og=80,sl=new Set(["male","female","unknown"]),al=new Set(["day","month","year"]),ll=new Set(["low","medium","high","athletic"]),ul=new Set(["indoor","outdoor","both"]),dl=new Set(["mild","moderate","severe"]),ig=/^(\d{4})-(\d{2})-(\d{2})$/,cl=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],pl=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];Object.freeze([...cl,...pl].map(([e])=>e));function sg(e){let t=ig.exec(e);if(t===null)return false;let[r,n,o]=[Number(t[1]),Number(t[2]),Number(t[3])],s=new Date(Date.UTC(r,n-1,o));return s.getUTCFullYear()===r&&s.getUTCMonth()===n-1&&s.getUTCDate()===o}i(sg,"isRealDate");var mr=i(e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,"oneOf"),ag=i((e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,"boolean"),un=i((e,t)=>typeof t=="string"&&sg(t)?null:`${e} must be a real date written YYYY-MM-DD`,"date"),Le=i((e,t={})=>(r,n)=>{if(typeof n!="string")return `${r} must be a string`;if(Ce(n))return `${r} contains an unpaired surrogate and cannot be encoded`;let o=t.trimmed?n.trim():n;if(t.required&&o.length===0)return `${r} is required and must not be blank`;let s=gt(o);return s<=e?null:`${r} is ${s} characters; the server accepts at most ${e}`},"text"),lg={sex:mr(sl),spayedNeutered:ag,birthDate:un,birthDatePrecision:mr(al),activityLevel:mr(ll),indoorOutdoor:mr(ul),foodBrand:Le(nl),foodType:Le(nl),microchipId:Le(og)},zo=["ref","ref",false,Le(rg,{required:true,trimmed:true})],jo=["notes","notes",false,Le(ng,{trimmed:true})],ol=[zo,["name","name",true,Le(Ho,{required:true,trimmed:true})],["dose","dose",false,Le(rl,{trimmed:true})],["frequency","frequency",false,Le(rl,{trimmed:true})],["startDate","start_date",false,un],["endDate","end_date",false,un],jo],ug={allergies:[zo,["allergen","allergen",true,Le(Ho,{required:true,trimmed:true})],["severity","severity",false,mr(dl)],jo],medications:ol,supplements:ol,conditions:[zo,["conditionName","condition_name",true,Le(Ho,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,un],jo]};function dg(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return {error:`${n} must be an object`};let o=r,s={};for(let[u,d,c,p]of ug[e]){let f=o[u];if(f==null){if(c)return {error:`${n}.${u} is required`};f===null&&(s[d]=null);continue}let m=p(`${n}.${u}`,f);if(m!==null)return {error:m};s[d]=f;}let a=s.start_date,l=s.end_date;return typeof a=="string"&&typeof l=="string"&&l<a?{error:`${n}.endDate must not be before startDate`}:{item:s}}i(dg,"itemToWire");function cg(e,t){if(!Array.isArray(t))return {error:`${e} must be an array (send [] to clear it)`};if(t.length>tl)return {error:`${e} has ${t.length} items; the server accepts at most ${tl}`};let r=[],n=new Set;for(let o=0;o<t.length;o+=1){let s=dg(e,o,t[o]);if("error"in s)return s;let a=s.item.ref;if(typeof a=="string"){let l=a.trim();if(n.has(l))return {error:`${e}: ref ${JSON.stringify(l)} is used twice; a ref names one item`};n.add(l);}r.push(s.item);}return {items:r}}i(cg,"listToWire");function fl(e,t){let r=e,n={};for(let[a,l]of cl){let u=r[a];if(u!==void 0){if(u!==null){let d=lg[a](a,u);if(d!==null)return {error:d}}n[l]=u;}}let o=r.birthDate!==void 0,s=r.birthDatePrecision!==void 0;if(o!==s||o&&r.birthDate===null!=(r.birthDatePrecision===null))return {error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[a,l]of pl){let u=r[a];if(u===void 0)continue;let d=cg(a,u);if("error"in d)return d;n[l]=d.items;}return Object.keys(n).length>0&&t!==void 0&&pr(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}i(fl,"petHealthToWire");var ie=i(e=>typeof e=="string"?e:null,"str"),fr=i((e,t)=>typeof t=="string"&&e.has(t)?t:null,"pick"),pg=i(e=>typeof e=="boolean"?e:null,"bool");function ln(e,t){return Array.isArray(e)?Object.freeze(e.flatMap(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return [];let n=t(r);return n===null?[]:[n]})):Object.freeze([])}i(ln,"itemsFromWire");function il(e){let t=ie(e.name);return t===null||t.length===0?null:Object.freeze({ref:ie(e.ref),name:t,dose:ie(e.dose),frequency:ie(e.frequency),startDate:ie(e.start_date),endDate:ie(e.end_date),notes:ie(e.notes)})}i(il,"medicationFromWire");function ml(e){let t=e.profile_version;return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:fr(sl,e.sex),spayedNeutered:pg(e.spayed_neutered),birthDate:ie(e.birth_date),birthDatePrecision:fr(al,e.birth_date_precision),activityLevel:fr(ll,e.activity_level),indoorOutdoor:fr(ul,e.indoor_outdoor),foodBrand:ie(e.food_brand),foodType:ie(e.food_type),microchipId:ie(e.microchip_id),allergies:ln(e.allergies,r=>{let n=ie(r.allergen);return n===null||n.length===0?null:Object.freeze({ref:ie(r.ref),allergen:n,severity:fr(dl,r.severity),notes:ie(r.notes)})}),medications:ln(e.medications,il),supplements:ln(e.supplements,il),conditions:ln(e.conditions,r=>{let n=ie(r.condition_name);return n===null||n.length===0?null:Object.freeze({ref:ie(r.ref),conditionName:n,diagnosedDate:ie(r.diagnosed_date),notes:ie(r.notes)})})})}i(ml,"petHealthFromWire");var hl=100,bl=50,vl=100,El=50,Cl=500,fg=128,mg=6e4;function De(e){return D("validationFailed",{retryable:false,wireMessage:e})}i(De,"invalid");function ht(e,t,r){if(typeof t!="string")return De(`${e} must be a string`);let n=gt(t);return n<=r?null:De(`${e} is ${n} characters; the server accepts at most ${r}`)}i(ht,"checkString");function dn(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:De(`${e} must be a finite number between 0 and ${r}`)}i(dn,"outOfRange");function yl(e,t){if(typeof e!="string")return De("pet_ref must be a string");if(e.trim().length===0)return De("pet_ref must not be blank");if(Ce(e))return De("pet_ref contains an unpaired surrogate and cannot be encoded");if(t!=null&&typeof t!="object")return De("profile must be an object");let r=[ht("pet_ref",e,fg)];return t?.name!==void 0&&r.push(ht("name",t.name,hl)),t?.species!==void 0&&r.push(ht("species",t.species,bl)),t?.breed!==void 0&&r.push(ht("breed",t.breed,vl)),t?.ageYears!==void 0&&r.push(dn("age_years",t.ageYears,El)),t?.weightKg!==void 0&&r.push(dn("weight_kg",t.weightKg,Cl)),r.find(n=>n!==null)??null}i(yl,"validate");function Rl(e,t){let r=fl(e,t);return "error"in r?{error:De(r.error)}:r}i(Rl,"healthToWire");function yg(e){if(typeof e!="object"||e===null)return {error:De("patch must be an object")};let t=e,r=[["name","name",s=>ht("name",s,hl)],["species","species",s=>ht("species",s,bl)],["breed","breed",s=>ht("breed",s,vl)],["ageYears","age_years",s=>dn("age_years",s,El)],["weightKg","weight_kg",s=>dn("weight_kg",s,Cl)]],n={};for(let[s,a,l]of r){let u=t[s];if(u!==void 0){if(u!==null){let d=l(u);if(d!==null)return {error:d}}n[a]=u;}}let o=Rl(t,t.species);return "error"in o?o:(Object.assign(n,o.body),Object.keys(n).length===0?{error:De("patch must change at least one field")}:{body:n})}i(yg,"patchToWire");function gg(e){if(e==null)return {body:{}};let t=Rl(e,e.species);return "error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}i(gg,"toWire");var Ne=i(e=>typeof e=="string"?e:null,"str"),cn=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"num");function gl(e,t){let r=typeof e=="object"&&e!==null?e:{};return Object.freeze({petRef:Ne(r.pet_ref)??t,name:Ne(r.name),species:Ne(r.species),breed:Ne(r.breed),ageYears:cn(r.age_years),weightKg:cn(r.weight_kg)})}i(gl,"fromWire");function Sl(e){if(typeof e!="object"||e===null)return null;let t=e,r=Ne(t.pet_ref);return r===null||r.length===0?null:Object.freeze({petId:Ne(t.pet_id),petRef:r,name:Ne(t.name),species:Ne(t.species),breed:Ne(t.breed),ageYears:cn(t.age_years),weightKg:cn(t.weight_kg),updatedAt:Ne(t.updated_at)})}i(Sl,"widgetPetFromWire");function hg(e){let t=Sl(e);return t===null?null:Object.freeze({...t,...ml(e)})}i(hg,"widgetPetProfileFromWire");function bg(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];return Object.freeze(t.flatMap(r=>{let n=Sl(r);return n===null?[]:[n]}))}i(bg,"petListFromWire");function lt(e){return vg(Ie({auth:e}),Ie({auth:e,unaryTimeoutMs:mg}))}i(lt,"createPetsRepository");function vg(e,t=e){let r=i((o,s)=>s?{...o,signal:s}:o,"withSignal"),n=i(o=>yl(o,void 0)??`/widget/v1/pets/${encodeURIComponent(o)}`,"petPath");return {async list(o){let s=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},o?.signal));return s.ok?L(bg(s.value)):v(s.error)},async registerPet(o,s,a){let l=yl(o,s);if(l!==null)return v(l);let u=gg(s);if("error"in u)return v(u.error);let c={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(o)}`,body:u.body},p=await e.send("pets.registerPet",a?.signal?{...c,signal:a.signal}:c);return p.ok?L(gl(p.value,o)):v(p.error)},async updatePet(o,s,a){let l=n(o);if(typeof l!="string")return v(l);let u=yg(s);if("error"in u)return v(u.error);let d=await e.send("pets.updatePet",r({method:"PATCH",path:l,body:u.body},a?.signal));return d.ok?L(gl(d.value,o)):v(d.error)},async getPetProfile(o,s){let a=n(o);if(typeof a!="string")return v(a);let l=await e.send("pets.getPetProfile",r({method:"GET",path:`${a}/profile`},s?.signal));if(!l.ok)return v(l.error);let u=hg(l.value);return u===null?v(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):L(u)},async deletePet(o,s){let a=n(o);if(typeof a!="string")return v(a);let l=await e.send("pets.deletePet",r({method:"DELETE",path:a},s?.signal));return l.ok?L(void 0):v(l.error)},async eraseUserData(o){let s=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},o?.signal),{maxAttempts:1});return s.ok?L(void 0):v(s.error)}}}i(vg,"createPetsRepositoryOver");var Go=Object.freeze({chat:Object.freeze(["chat.message.create"]),records:Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:Object.freeze(["records.clinic.create"]),video:Object.freeze(["video.gait.execute"]),photo:Object.freeze(["photo.checkup.execute"]),animations:Object.freeze(["animations.state.read"]),televet:Object.freeze(["televet.visit.create"])});function Eg(e){return Go[e]}i(Eg,"requires");function Tl(e,t){let r=Object.freeze({reason:t,level:e,recoverable:false}),n=[],o=new Set;for(let s of Object.keys(Go))for(let a of Go[s])o.has(a)||(o.add(a),n.push(Object.freeze({resource:a,granted:false,disabled:r})));return Object.freeze(n)}i(Tl,"deniedDecisionsFor");function Pl(e,t,r){let n=Eg(e),o=new Map;for(let l of t)o.set(l.resource,l);if(r?.isPending===true&&n.some(l=>!o.has(l)))return Wo({name:e,enabled:false,isPending:true,limits:{}});let s=Cg(n,o);return n.filter(l=>o.get(l)?.granted!==true).length===0?Wo({name:e,enabled:true,isPending:false,limits:s}):Wo({name:e,enabled:false,isPending:false,limits:s,disabled:Rg(n,o)})}i(Pl,"decideCapability");function Cg(e,t){let r={};for(let n of e){let o=t.get(n)?.limits;if(o)for(let[s,a]of Object.entries(o)){let l=r[s];r[s]=l===void 0?a:Math.min(l,a);}}return r}i(Cg,"mergeLimits");function Rg(e,t){for(let r of e){let n=t.get(r)?.disabled;if(n)return Object.freeze({reason:n.reason,level:n.level,recoverable:n.recoverable})}return Object.freeze({reason:Dt("accessDenied"),level:"user_entitlement",recoverable:false})}i(Rg,"disabledFor");function Wo(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),Object.freeze(t)}i(Wo,"freezeDecision");function Z(e){let t=X(e);return t===null?null:Tg(t)}i(Z,"parseColor");function X(e){if(typeof e=="number")return kl(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return Ko(t.slice(1));if(t.toLowerCase().startsWith("0x"))return Ko(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Sg(t);if(/^[0-9a-fA-F]+$/.test(t)){let r=Ko(t);if(r!==null)return r}return /^\d+$/.test(t)?kl(Number.parseInt(t,10)):null}i(X,"toRgba");function Ko(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return {r:qo(t[0]),g:qo(t[1]),b:qo(t[2]),a:1};if(t.length===6)return {r:bt(t,0),g:bt(t,2),b:bt(t,4),a:1};if(t.length===8){let r=bt(t,0);return {r:bt(t,2),g:bt(t,4),b:bt(t,6),a:r/255}}return null}i(Ko,"fromHex");function Sg(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(u=>u.trim());if(n.length<3)return null;let o=$o(Number(n[0])),s=$o(Number(n[1])),a=$o(Number(n[2]));if(o===null||s===null||a===null)return null;let l=1;if(n.length>=4){let u=Number(n[3]);if(!Number.isFinite(u))return null;l=Math.min(1,Math.max(0,u));}return {r:o,g:s,b:a,a:l}}i(Sg,"fromRgbFunc");function kl(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return {r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}i(kl,"argbIntToRgba");function bt(e,t){return Number.parseInt(e.slice(t,t+2),16)}i(bt,"byte");function qo(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}i(qo,"dup");function $o(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}i($o,"clampByte");function Tg(e){if(e.a>=1)return qe(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return `rgba(${e.r},${e.g},${e.b},${t})`}i(Tg,"normalizeRgba");function qe(e,t,r){return `#${Yo(e)}${Yo(t)}${Yo(r)}`.toUpperCase()}i(qe,"rgbToHex");function Yo(e){return e.toString(16).padStart(2,"0")}i(Yo,"hex2");var Pg="#111111",zt="#FFFFFF",pn="#000000";function _l(e){let t=X(e);if(t===null)return zt;let r=vt(t),n=vt({r:17,g:17,b:17}),o=vt({r:255,g:255,b:255});return Zo(r,o)>=Zo(r,n)?zt:Pg}i(_l,"readableOn");function jt(e,t){let r=_l(e);return se(r,e)>=t?r:se(zt,e)>=se(pn,e)?zt:pn}i(jt,"legibleOn");function Re(e){let t=i(r=>e.reduce((n,o)=>Math.min(n,se(r,o)),Number.POSITIVE_INFINITY),"worst");return t(zt)>=t(pn)?zt:pn}i(Re,"poleForGrounds");function vt(e){let t=Xo(e.r/255),r=Xo(e.g/255),n=Xo(e.b/255);return .2126*t+.7152*r+.0722*n}i(vt,"relativeLuminance");function Xo(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}i(Xo,"linearize");function Zo(e,t){let r=Math.max(e,t),n=Math.min(e,t);return (r+.05)/(n+.05)}i(Zo,"luminanceContrast");function se(e,t){let r=X(e),n=X(t);if(r===null||n===null)return 1;let o=n.a>=1?n:{...n},s=r.a>=1?r:wl(r,o);return Zo(vt(s),vt(o))}i(se,"contrastRatio");function wl(e,t){let r=e.a,n=i((o,s)=>Math.round(o*r+s*(1-r)),"mix");return {r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}i(wl,"composite");function Ue(e,t){let r=X(e),n=X(t);if(r===null||n===null)return null;let o=r.a>=1?r:wl(r,{...n});return qe(o.r,o.g,o.b)}i(Ue,"flattenOnto");function ut(e,t){let r=X(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return `rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}i(ut,"withAlpha");var xl=.05;function yr(e,t,r,n){let o=t[0];if(o===void 0)return r;let s=i(d=>t.every(c=>se(d,c)>=n),"reads");if(X(e)===null)return r;if(s(e))return e;let a=Ue(e,o),l=a===null?null:X(a),u=X(r);if(l===null||u===null)return r;for(let d=1;d<1/xl;d+=1){let c=d*xl,p=i((m,h)=>Math.round(m+(h-m)*c),"mix"),f=qe(p(l.r,u.r),p(l.g,u.g),p(l.b,u.b));if(s(f))return f}return r}i(yr,"pushToContrast");function Il(e,t,r){let n=e/255,o=t/255,s=r/255,a=Math.max(n,o,s),l=Math.min(n,o,s),u=(a+l)/2;if(a===l)return {h:0,s:0,l:u};let d=a-l,c=d/(1-Math.abs(2*u-1)),p;return a===n?(p=(o-s)/d*60,p<0&&(p=p+360)):a===o?p=((s-n)/d+2)*60:p=((n-o)/d+4)*60,{h:p,s:c,l:u}}i(Il,"rgbToHsl");function Jo(e){let{h:t,s:r,l:n}=e,o=(1-Math.abs(2*n-1))*r,s=t/60,a=o*(1-Math.abs(s%2-1)),l=n-o/2,u=Math.floor(s)%6,d=[[o,a,0],[a,o,0],[0,o,a],[0,a,o],[a,0,o],[o,0,a]],[c,p,f]=d[u];return {r:Qo(c+l),g:Qo(p+l),b:Qo(f+l)}}i(Jo,"hslToRgb");function Qo(e){return Math.min(255,Math.max(0,Math.floor(e*255+.5)))}i(Qo,"channel");var $e=Object.freeze(["composerInput","sendButton","userBubble","assistantBubble","vetBubble","recordCard","vetVisitButton","primaryButton","link"]),kg=Object.freeze(["backgroundColor","borderColor","borderRadius","textColor"]),J=4.5,xg=Object.freeze({});function _g(e){return $e.includes(e)}i(_g,"isSlotName");function wg(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)?Math.max(0,t):null}i(wg,"parseRadius");function Al(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t={},r=false;for(let[n,o]of Object.entries(e)){if(!_g(n)||o===null||typeof o!="object")continue;let s=Ig(o);s!==null&&(t[n]=s,r=true);}return r?Object.freeze(t):null}i(Al,"parseThemeSlots");function fn(e,t,r){return e[t]!==void 0?e[t]:e[r]}i(fn,"pick");function Ig(e){let t={},r=Z(fn(e,"background_color","backgroundColor"));r!==null&&(t.backgroundColor=r);let n=Z(fn(e,"border_color","borderColor"));n!==null&&(t.borderColor=n);let o=wg(fn(e,"border_radius","borderRadius"));o!==null&&(t.borderRadius=o);let s=Z(fn(e,"text_color","textColor"));return s!==null&&(t.textColor=s),Object.keys(t).length===0?null:Object.freeze(t)}i(Ig,"parseSlot");function mn(e,t){return t===null||Object.keys(t).length===0?e??xg:e===null||Object.keys(e).length===0?t:Object.freeze({...e,...t})}i(mn,"mergeThemeSlots");var gr=3;function Ag(e,t){return e===void 0?t:t.length===0?[e]:t.map(r=>Ue(e,r)??r)}i(Ag,"seatsOf");function Og(e,t){let r=Re(e);return e.every(n=>se(r,n)>=t)}i(Og,"someInkReads");function Fg(e,t){let r=t[0];return r===void 0?null:Ue(e,r)}i(Fg,"collapseUnsatisfiableFill");function Mg(e){let t=jt(e[0],J);return e.every(r=>se(t,r)>=J)?t:Re(e)}i(Mg,"inkFor");function Ol(e,t){let r=false,n={};for(let o of $e){let s=e[o];if(s===void 0)continue;let a=s.backgroundColor,l=t?.[o]??[],u=Ag(a,l),d={...s},c=false;if(a!==void 0&&u.length>1&&!Og(u,J)){let p=Fg(a,l);p!==null&&(d.backgroundColor=p,u=[p],c=true);}if(u.length>0){let p=s.textColor;if(a!==void 0)(p===void 0||u.some(f=>se(p,f)<J))&&(d.textColor=Mg(u),c=true);else if(p!==void 0){let f=yr(p,u,Re(u),J);f!==p&&(d.textColor=f,c=true);}if(s.borderColor!==void 0){let f=yr(s.borderColor,u,Re(u),gr);f!==s.borderColor&&(d.borderColor=f,c=true);}}n[o]=c?Object.freeze(d):s,r=r||c;}return r?Object.freeze(n):e}i(Ol,"guardSlotContrast");function Ye(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.keys(e))Ye(e[t]);}return e}i(Ye,"deepFreeze");var gn=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),Ml={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},Ll={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},Fl={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},Lg={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Ng={regular:"400",medium:"500",bold:"700"},Dg={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},ei=0,Et="System",Ve="monospace",Ug=["content","heading","control","compact","badge"];function Vg(e){let t={};for(let r of Ug)t[r]=e;return t}i(Vg,"authoredTierSizes");function Nl(){return {family:Et,mono:Ve,fontUrl:null,families:{regular:Et,medium:Et,bold:Et,mono:Ve,monoMedium:Ve,monoBold:Ve},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:Fl,tierSizes:Vg(Fl),lineHeight:Lg,weight:Ng,letterSpacing:Dg,scale:1,maxScale:ei,scaleCaps:gn}}i(Nl,"baseType");var Dl={},Ct=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function yn(e){return `cubic-bezier(${e.join(", ")})`}i(yn,"cssCubicBezier");var Ul={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:yn(Ct.standard),emphasized:yn(Ct.emphasized),exit:yn(Ct.exit)},reducedMotion:false},Bg={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},Be=Ye({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Bg,space:Ml,radius:Ll,type:Nl(),motion:Ul,slots:Dl}),Hg={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"},Rt=Ye({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Hg,space:Ml,radius:Ll,type:Nl(),motion:Ul,slots:Dl});function St(e){return [e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}i(St,"textGrounds");function Vl(e){return [e.surface,e.surfaceCream,e.background,e.chatGround,e.composerFill]}i(Vl,"controlGrounds");function ti(e){return [e.chatGround,e.surface,e.surfaceCream]}i(ti,"linkGrounds");function Bl(e,t){return [e.surface,e.surfaceCream,e.background,e.chatGround,e.composerFill,...Hl(e,t)]}i(Bl,"statusGrounds");function Hl(e,t){return [Ue(t,e.surface)??e.surface,Ue(t,e.surfaceCream)??e.surfaceCream]}i(Hl,"washGrounds");function zg(e){return [e.composerFill,e.chatGround]}i(zg,"composerGrounds");var jg=new Set(["text.timestamp","text.placeholder","errorRed","warningStrong","composerBorder"]);function Wg(e,t){let r=new Set(St(t));return St(e).every(n=>r.has(n))}i(Wg,"onCompiledGrounds");function zl(e){let t=e.color,r=(e.brightness==="dark"?Rt:Be).color,n=(e.brightness==="dark"?Be:Rt).color,o=St(t),s=Re(o)!==Re(St(r)),a=Wg(t,r),l=t.danger===r.danger&&t.badgeBgCritical===r.badgeBgCritical,u=i((T,b,S,P,k,x)=>{let y=b===S&&(T!=="errorRed"||l);return y&&a&&jg.has(T)?b:yr(y&&s?P:b,k,Re(k),x)},"ink"),d=i((T,b,S)=>u(`text.${T}`,t.text[T],r.text[T],n.text[T],b,S),"text"),c=i((T,b,S,P)=>u(T,b,r[T],n[T],S,P),"token"),p=i(T=>s&&t[T]===r[T]?n[T]:t[T],"tint"),f=t.primary,m=jt(f,J),h=c("danger",t.danger,[...o,...Hl(t,t.badgeBgCritical)],J);return {...t,onPrimary:m,onAccent:jt(t.accent,J),onDanger:se(m,h)>=J?m:jt(h,J),brandSoft:p("brandSoft"),brandSofter:p("brandSofter"),brandBorder:p("brandBorder"),borderHairlineGreen:p("borderHairlineGreen"),brandInk:c("brandInk",t.brandInk,o,J),linkInk:c("linkInk",e.slots.link?.textColor??t.accent,ti(t),J),text:{...t.text,primary:d("primary",o,J),secondary:d("secondary",o,J),muted:d("muted",o,J),metaCool:d("metaCool",o,J),timestamp:d("timestamp",o,J),placeholder:d("placeholder",Vl(t),gr)},danger:h,errorRed:c("errorRed",t.errorRed,Bl(t,t.badgeBgCritical),J),warningStrong:c("warningStrong",t.warningStrong,Bl(t,t.badgeBgCaution),J),composerBorder:c("composerBorder",t.composerBorder,zg(t),gr),brandBorderStrong:c("brandBorderStrong",t.brandBorderStrong,Vl(t),gr)}}i(zl,"guardInks");var Gg="#23272C",jl=4.5,Kg=.6,ri=.9,qg=.02,$g="#FFFFFF",Yg="#111111";function Xg(e){return se(e,Gg)>=jl&&Math.max(se(e,$g),se(e,Yg))>=jl}i(Xg,"readsOnDark");function ql(e){let t=X(e);if(t===null)return null;let{h:r,s:n,l:o}=Il(t.r,t.g,t.b),s=Math.min(Math.max(o,Kg),ri);for(let l=0;;l+=1){let u=s+l*qg;if(u>ri)break;let d=Jo({h:r,s:n,l:u}),c=qe(d.r,d.g,d.b);if(Xg(c))return c}let a=Jo({h:r,s:n,l:ri});return qe(a.r,a.g,a.b)}i(ql,"deriveDarkVariant");var Qg=7,Wl=.05,Zg="#000000",Gl="#FFFFFF";function Jg(e,t,r,n){let o=Ue(e,t);if(o===null)return r;if(se(o,t)>=n)return o;let s=X(o),a=X(r);if(s===null||a===null)return r;for(let l=1;l<1/Wl;l+=1){let u=l*Wl,d=i((p,f)=>Math.round(p+(f-p)*u),"mix"),c=qe(d(s.r,a.r),d(s.g,a.g),d(s.b,a.b));if(se(c,t)>=n)return c}return r}i(Jg,"pushContrast");function eh(e,t){let r=St(e),n=r[0],o=Kl(n);for(let s of r){let a=Kl(s);(t?a>o:a<o)&&(n=s,o=a);}return n}i(eh,"hardestGround");function Kl(e){let t=X(e);return t===null?0:vt(t)}i(Kl,"luminanceOf");function dt(e,t){return Ue(e,t)??Z(e)??t}i(dt,"solid");function $l(e){let t=e.color,r=Re(St(t))===Gl,n=r?Gl:Zg,o=eh(t,r),s=i(l=>Jg(l,o,n,Qg),"text"),a={...t,brandSoft:dt(t.brandSoft,t.surface),brandSofter:dt(t.brandSofter,t.surface),brandBorder:s(t.brandBorder),borderHairlineGreen:s(t.borderHairlineGreen),brandBorderStrong:s(t.brandBorderStrong),brandInk:s(t.brandInk),linkInk:s(t.linkInk),borderRingCream:s(t.borderRingCream),composerBorder:s(t.composerBorder),text:{primary:s(t.text.primary),secondary:s(t.text.secondary),muted:s(t.text.muted),placeholder:s(t.text.placeholder),onBrand:t.text.onBrand,metaCool:s(t.text.metaCool),timestamp:s(t.text.timestamp)},badgeBgPositive:dt(t.badgeBgPositive,t.surface),badgeBgCaution:dt(t.badgeBgCaution,t.surface),badgeBgCritical:dt(t.badgeBgCritical,t.surface),badgeBgNeutral:dt(t.badgeBgNeutral,t.surface),checkupCardLowRiskBg:dt(t.checkupCardLowRiskBg,t.surface),checkupCardConcernBg:dt(t.checkupCardConcernBg,t.surface)};return Ye({...e,highContrast:true,color:a})}i($l,"deriveHighContrast");var oi=Object.freeze({cream:.03,subtle:.07,ring:.16}),th=oi.cream,rh=oi.subtle,nh=oi.ring,oh=10;function ni(e,t,r){let n=X(e),o=X(t);if(n===null||o===null)return null;let s=i((a,l)=>Math.round(a+(l-a)*r),"at");return qe(s(n.r,o.r),s(n.g,o.g),s(n.b,o.b))}i(ni,"mix");function Yl(e){if(e===null)return {};let t=Re([e]),r=ni(e,t,th),n=ni(e,t,rh),o=ni(e,t,nh);return r===null||n===null||o===null?{}:{surface:e,background:e,chatGround:e,bubbleAssistant:e,surfaceCream:r,composerFill:r,surfaceSubtle:n,skeleton:n,borderRingCream:o}}i(Yl,"surfaceFamily");function Xl(e){if(e===null)return {};let t=X(e);return t===null?{}:{danger:e,errorRed:e,badgeBgCritical:`rgba(${t.r},${t.g},${t.b},0.12)`}}i(Xl,"dangerFamily");function Ql(e,t,r){if(e===null)return t;let n=e/r.type.size.body;if(n===1)return r.type.size;let o={};for(let[s,a]of Object.entries(r.type.size))o[s]=Math.max(oh,Math.round(a*n*10)/10);return o}i(Ql,"typeSizesFor");function Zl(e,t,r){if(e===null)return t;let n=e/r.space.xs,o=i(a=>Math.round(a*n),"s"),s=r.space;return {xs:o(s.xs),sm:o(s.sm),md:o(s.md),lg:o(s.lg),xl:o(s.xl),xxl:o(s.xxl)}}i(Zl,"spaceFor");function Jl(e,t){let r=e/t.radius.md,n=i(s=>Math.round(s*r),"s"),o=t.radius;return {tile:n(o.tile),xs:n(o.xs),sm:n(o.sm),md:n(o.md),lg:n(o.lg),xl:n(o.xl),pill:o.pill}}i(Jl,"radiiFor");var eu=Object.freeze(["everfur","minimal","night"]),tu=Object.freeze({everfur:Object.freeze({}),minimal:Object.freeze({colorPrimary:"#111111",colorAccent:"#111111",borderRadius:6}),night:Object.freeze({colorScheme:"dark"})}),br=Object.freeze({fontSizeBase:Object.freeze({min:12,max:20,default:14}),borderRadius:Object.freeze({min:0,max:32,default:14}),spacingUnit:Object.freeze({min:3,max:6,default:4})});function hn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(hn,"isRecord");function ih(e){return typeof e=="string"&&eu.includes(e.trim().toLowerCase())}i(ih,"isPreset");function hr(e,t){let r=e[t];return r??void 0}i(hr,"present");var sh=16;function ah(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.length>sh)return;let t=/^(-?\d+(?:\.\d+)?)(?: ?px)?$/i.exec(e.trim());return t===null?void 0:Number(t[1])}i(ah,"parsePx");var lh=[["colorPrimary","primary_color"],["colorAccent","accent_color"],["colorBackground","background_color"],["colorText","text_color"]],uh=[["fontSizeBase","font_size_base"],["borderRadius","border_radius"],["spacingUnit","spacing_unit"]];function ii(e){if(!hn(e))return null;let t=ih(e.theme)?tu[e.theme.trim().toLowerCase()]:{},r=hn(e.variables)?e.variables:{},n={...t};for(let[p,f]of Object.entries(r))f!=null&&(n[p]=f);let o={},s=hr(n,"colorScheme"),a=typeof s=="string"?s.trim().toLowerCase():null;(a==="light"||a==="dark"||a==="auto")&&(o.color_scheme=a);let l=a==="dark"?"_dark":"";for(let[p,f]of lh){let m=hr(n,p);m!==void 0&&(o[`${f}${l}`]=m);}let u=hr(n,"colorDanger");u!==void 0&&(o[`danger_color${l}`]=u);let d=hr(n,"fontFamily");typeof d=="string"&&d.trim().length>0&&(o.font_family=d.trim());for(let[p,f]of uh){let m=ah(hr(n,p));m!==void 0&&(o[f]=m);}let c=e.rules;if(hn(c)){let p={};for(let f of $e){let m=c[f];hn(m)&&(p[f]=m);}Object.keys(p).length>0&&(o.slots=p);}return Object.keys(o).length===0?null:Object.freeze(o)}i(ii,"expandAppearance");var iu=Object.freeze(["display_name","logo_url","logo_url_dark","primary_color","accent_color","primary_color_dark","accent_color_dark","brightness","color_scheme","font_family","font_url","fonts","font_urls","chat_placeholder","surface_style","radius_scale","accessibility_max_font_scale","slots","background_color","background_color_dark","text_color","text_color_dark","danger_color","danger_color_dark","font_size_base","border_radius","spacing_unit"]),vr="slots.",su=Object.freeze([1,2]);function vn(e){return Object.keys(e).every(t=>t==="schemaVersion"||(e[t]??null)===null)}i(vn,"isEmptyBranding");function au(e){let t=e?.schemaVersion??null;return t===null||su.includes(t)}i(au,"isKnownBrandingSchema");function lu(e){return new Set(["hide_powered_by",...e?.lockedFields??[]])}i(lu,"lockedFieldsOf");function dh(e){return e==="hide_powered_by"||iu.includes(e)?true:e.startsWith(vr)&&$e.includes(e.slice(vr.length))}i(dh,"isThemeLockName");function Xe(e){if(e===null||typeof e!="object")return null;let t=e,r=ru(t),n=ii(j(t,"appearance")),o=n===null?r:ch(ru(n),r);return vn(o)?null:Object.freeze(o)}i(Xe,"parseClientBranding");function ch(e,t){let r={...e};for(let[o,s]of Object.entries(t))s!=null&&(r[o]=s);let n=mn(e.slots??null,t.slots??null);return r.slots=Object.keys(n).length===0?null:n,r}i(ch,"overlayFlat");function ru(e){return {displayName:Tt(j(e,"display_name","displayName")),logoUrl:Tt(j(e,"logo_url","logoUrl")),primaryColor:Z(j(e,"primary_color","primaryColor")),accentColor:Z(j(e,"accent_color","accentColor")),brightness:yh(j(e,"brightness","color_scheme","colorScheme")),fontFamily:Tt(j(e,"font_family","fontFamily")),fontUrl:Tt(j(e,"font_url","fontUrl")),fonts:nu(j(e,"fonts")),fontUrls:nu(j(e,"font_urls","fontUrls")),placeholder:Tt(j(e,"chat_placeholder","placeholder","chatPlaceholder")),hidePoweredBy:ph(j(e,"hide_powered_by","hidePoweredBy")),primaryColorDark:Z(j(e,"primary_color_dark","primaryColorDark")),accentColorDark:Z(j(e,"accent_color_dark","accentColorDark")),surfaceStyle:ou(j(e,"surface_style","surfaceStyle"),fh),radiusScale:ou(j(e,"radius_scale","radiusScale"),mh),logoUrlDark:Tt(j(e,"logo_url_dark","logoUrlDark")),slots:Al(j(e,"slots")),accessibilityMaxFontScale:hh(j(e,"accessibility_max_font_scale","accessibilityMaxFontScale")),lockedFields:vh(j(e,"locked_fields","lockedFields")),schemaVersion:bh(j(e,"schema_version","schemaVersion")),backgroundColor:Z(j(e,"background_color","backgroundColor")),backgroundColorDark:Z(j(e,"background_color_dark","backgroundColorDark")),textColor:Z(j(e,"text_color","textColor")),textColorDark:Z(j(e,"text_color_dark","textColorDark")),dangerColor:Z(j(e,"danger_color","dangerColor")),dangerColorDark:Z(j(e,"danger_color_dark","dangerColorDark")),fontSizeBase:si(j(e,"font_size_base","fontSizeBase"),br.fontSizeBase),borderRadius:si(j(e,"border_radius","borderRadius"),br.borderRadius),spacingUnit:si(j(e,"spacing_unit","spacingUnit"),br.spacingUnit)}}i(ru,"parseFlat");function si(e,t){let r=bn(typeof e=="string"?e.trim().replace(/px$/i,""):e);return r===null?null:Math.min(t.max,Math.max(t.min,r))}i(si,"parseClamped");function ph(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true")return true;if(t==="false")return false}return null}i(ph,"parseBool");function j(e,...t){for(let r of t)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];if(n!==void 0)return n}}i(j,"pick");function Tt(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(Tt,"parseNonEmptyString");var Er=["regular","medium","bold","mono","monoMedium","monoBold"];function nu(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let n of Er){let o=Tt(j(t,n));o!==null&&(r[n]=o);}return Object.keys(r).length===0?null:Object.freeze(r)}i(nu,"parseFaceMap");var fh=["white","cream","subtle"],mh=["sharp","default","round"];function ou(e,t){if(typeof e!="string")return null;let r=e.trim().toLowerCase();return t.includes(r)?r:null}i(ou,"parseEnum");function yh(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="light"||t==="dark"||t==="auto"?t:null}i(yh,"parseBrightness");function bn(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)&&(typeof e!="string"||e.trim().length>0)?t:null}i(bn,"parseNumber");var gh=1,uu=3.1;function hh(e){let t=bn(e);return t===null?null:t<=0?0:Math.min(uu,Math.max(gh,t))}i(hh,"parseMaxFontScale");function bh(e){if(e==null)return null;let t=bn(e);return t!==null&&Number.isInteger(t)&&t>=1?t:0}i(bh,"parseSchemaVersion");function ai(e){let t=e.trim();return t.startsWith(vr)?t:t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}i(ai,"toWireName");function vh(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="string")continue;let n=ai(r);dh(n)&&!t.includes(n)&&t.push(n);}return t.length===0?null:Object.freeze(t)}i(vh,"parseLockedFields");function li(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}i(li,"hardenHttpsUrl");function du(e,t){if(t===null||vn(t))return e;let r=(t.brightness==="light"||t.brightness==="dark")&&t.brightness!==e.brightness?t.brightness==="dark"?Rt:Be:e,n=r.brightness==="dark"?Rt:Be,o=r.brightness==="dark",s=o?t.primaryColorDark??ui(t.primaryColor):t.primaryColor,a=o?t.accentColorDark??ui(t.accentColor):t.accentColor,l=s??r.color.primary,u=a??r.color.accent,d=s!==null&&Th(t,l,n,o),c=d?n.color.primary:l,p=s!==null&&!d?X(c):null,f=i(k=>Math.round(k+(255-k)*.4),"lift"),m=p!==null?{brand:c,bubbleUser:c,brandInk:c,text:{...r.color.text,secondary:c},brandSoft:`rgba(${p.r}, ${p.g}, ${p.b}, 0.10)`,brandSofter:`rgba(${p.r}, ${p.g}, ${p.b}, 0.15)`,brandBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.20)`,borderHairlineGreen:`rgba(${p.r}, ${p.g}, ${p.b}, 0.28)`,brandBorderStrong:`rgba(${p.r}, ${p.g}, ${p.b}, 0.55)`,composerBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.75)`,accentEdge:`rgb(${f(p.r)}, ${f(p.g)}, ${f(p.b)})`}:d?Ph(n,r.color.text):{},h=(o?t.backgroundColorDark:t.backgroundColor)??null,T=Yl(h),b={...r.color,...T},S=(o?t.textColorDark:t.textColor)??null,P={brightness:r.brightness,highContrast:r.highContrast,meta:{displayName:t.displayName??r.meta.displayName,logoUrl:(o?t.logoUrlDark??t.logoUrl:t.logoUrl)??r.meta.logoUrl,placeholder:t.placeholder??r.meta.placeholder,hidePoweredBy:t.hidePoweredBy??r.meta.hidePoweredBy},color:{...r.color,...m,...T,...Xl((o?t.dangerColorDark??ui(t.dangerColor??null):t.dangerColor)??null),...S!==null?{text:{...m.text??r.color.text,primary:S}}:{},...Sh(t.surfaceStyle??null,b),primary:c,accent:u,onPrimary:r.color.onPrimary,onAccent:r.color.onAccent},space:Zl(t.spacingUnit??null,r.space,n),radius:t.borderRadius!=null?Jl(t.borderRadius,n):xh(t.radiusScale??null,r.radius,n),type:{...r.type,...Rh(r.type,t),size:Ql(t.fontSizeBase??null,r.type.size,n),maxScale:t.accessibilityMaxFontScale??r.type.maxScale},motion:r.motion,slots:mn(r.slots,t.slots??null)};return Ye(P)}i(du,"withServerBranding");var Eh={regular:["regular"],medium:["medium","regular"],bold:["bold","medium","regular"],mono:["mono"],monoMedium:["monoMedium","mono"],monoBold:["monoBold","monoMedium","mono"]},Ch=[["regular","medium","bold"],["mono","monoMedium","monoBold"]];function di(e){return e==="mono"||e==="monoMedium"||e==="monoBold"}i(di,"isMonoFace");function Rh(e,t){let r=t.fonts??{},n=t.fontUrls??{},o={...e.families},s={...e.namedFaces},a={...e.fontUrls};for(let l of Er){let u=Eh[l].map(p=>r[p]).find(p=>p!==void 0),d=di(l)?null:t.fontFamily;u!==void 0?(o[l]=u,s[l]=true):d!==null&&(o[l]=d,s[l]=false);let c=n[l]??(l==="regular"?t.fontUrl:null)??null;c!==null?a[l]=c:u!==void 0&&delete a[l];}for(let l of Ch)for(let u of l)s[u]&&l.some(d=>d!==u&&o[d]===o[u])&&(s[u]=false);return {family:o.regular,mono:o.mono,fontUrl:a.regular??null,families:o,namedFaces:s,fontUrls:a}}i(Rh,"mergeFaces");function ui(e){return e===null?null:ql(e)}i(ui,"darkVariantOf");function Sh(e,t){if(e===null)return {};let r=t;return {chatGround:e==="white"?r.surface:e==="subtle"?r.surfaceSubtle:r.surfaceCream}}i(Sh,"surfaceOf");function cu(e,t){return e==null?false:Z(e)===Z(t)}i(cu,"sameColor");function Th(e,t,r,n){return cu(t,r.color.primary)?true:n&&(e.primaryColorDark??null)===null&&cu(e.primaryColor,Be.color.primary)}i(Th,"isCompiledPrimary");function Ph(e,t){let r=e.color;return {text:{...t,secondary:r.text.secondary},brand:r.brand,bubbleUser:r.bubbleUser,brandInk:r.brandInk,brandSoft:r.brandSoft,brandSofter:r.brandSofter,brandBorder:r.brandBorder,borderHairlineGreen:r.borderHairlineGreen,brandBorderStrong:r.brandBorderStrong,composerBorder:r.composerBorder,accentEdge:r.accentEdge}}i(Ph,"compiledBrandFamily");var kh={sharp:.5,default:1,round:1.5};function xh(e,t,r){if(e===null)return t;let n=kh[e],o=r.radius,s=i(a=>Math.round(a*n),"s");return {tile:s(o.tile),xs:s(o.xs),sm:s(o.sm),md:s(o.md),lg:s(o.lg),xl:s(o.xl),pill:o.pill}}i(xh,"radiusOf");var _h="Everfur",wh=.5;function ci(e){let t=e?.branding??null,r=au(t)?t:null,n=Mh(e?.clientOverride??null,lu(r)),o=e?.colorScheme==="dark"?"dark":"light",s=n?.brightness??r?.brightness??"light",u=du((s==="auto"?o:s)==="dark"?Rt:Be,pu(r)),d=du(u,pu(n));return jh(d,e)}i(ci,"resolveTheme");function Ih(e,t,r){return ci({...r,branding:Xe(t),clientOverride:Xe(e)})}i(Ih,"previewTheme");function Ah(e){return e==="placeholder"?"chat_placeholder":ai(e)}i(Ah,"wireNameOf");var Oh={brightness:["color_scheme"],fontUrl:["font_family"],fonts:["font_family"],fontUrls:["font_url","font_family","fonts"],primaryColorDark:["primary_color"],accentColorDark:["accent_color"],logoUrlDark:["logo_url"],backgroundColorDark:["background_color"],textColorDark:["text_color"],dangerColorDark:["danger_color"],borderRadius:["radius_scale"],radiusScale:["border_radius"]};function Fh(e,t){return t.has(Ah(e))?true:(Oh[e]??[]).some(r=>t.has(r))}i(Fh,"isLocked");function Mh(e,t){if(e===null)return null;let r=false,n={...e};for(let a of Object.keys(e))(e[a]??null)!==null&&(Fh(a,t)||a==="lockedFields")&&(n[a]=null,r=true);let o=n.slots??null;if(o!==null){let a={},l=false;for(let u of $e){let d=o[u];d!==void 0&&(t.has(`${vr}${u}`)?l=true:a[u]=d);}l&&(n.slots=Object.keys(a).length===0?null:Object.freeze(a),r=true);}if(!r)return e;let s=Object.freeze(n);return vn(s)?null:s}i(Mh,"withoutFields");function pu(e){return e===null||e.brightness===null?e:Object.freeze({...e,brightness:null})}i(pu,"withoutBrightness");function Lh(e,t){if(t===1)return e;let r={};for(let[n,o]of Object.entries(e))r[n]=Math.round(o*t*10)/10;return r}i(Lh,"scaledSizes");function Nh(e){return e===void 0||!Number.isFinite(e)?1:Math.max(wh,e)}i(Nh,"effectiveScale");var fu=["content","heading","control","compact","badge"];function Dh(e){if(!(e>0))return gn;let t={};for(let r of fu){let n=gn[r];t[r]=n===0?0:Math.min(n,e);}return t}i(Dh,"tierCaps");function Uh(e,t){return t>0?Math.min(e,t):e}i(Uh,"capped");function Vh(e,t,r,n){let o={};for(let s of fu)o[s]=n?Lh(e,Uh(t,r[s])):e;return o}i(Vh,"sizesByTier");function Bh(e){return {composerInput:[e.composerFill],sendButton:[e.composerFill],userBubble:[e.bubbleUser],assistantBubble:[e.chatGround,e.surfaceCream],vetBubble:[e.bubbleVet],recordCard:[e.surface],vetVisitButton:[e.primary],primaryButton:[e.brand],link:ti(e)}}i(Bh,"slotGrounds");function Hh(e,t){try{let r=e(t);return r===!0||r===!1?r:null}catch{return null}}i(Hh,"registration");function zh(e,t){let r=t?.isFontRegistered,n=t?.platformMonoFamily?.trim()||null;if(r===void 0&&n===null)return {family:e.family,mono:e.mono,families:e.families,namedFaces:e.namedFaces};let o={...e.families},s={...e.namedFaces};for(let a of Er)!(o[a]===Et||o[a]===Ve)&&r!==void 0&&Hh(r,o[a])===false&&(o[a]=di(a)?Ve:Et,s[a]=false),n!==null&&di(a)&&o[a]===Ve&&(o[a]=n);return {family:o.regular,mono:o.mono,families:o,namedFaces:s}}i(zh,"platformFaces");function jh(e,t){let r=e.meta.displayName.trim().length===0?_h:e.meta.displayName,n=li(e.meta.logoUrl),o={};for(let h of Er){let T=e.type.fontUrls[h];T!==void 0&&(o[h]=li(T));}let s=o.regular??null,l=t?.reducedMotion===true?{duration:{instant:0,fast:0,normal:0,slow:0},spring:{gentle:{damping:100,stiffness:1e3}},easing:e.motion.easing,reducedMotion:true}:e.motion,u=Number.isFinite(e.type.maxScale)?e.type.maxScale:ei,d=Nh(t?.textScale),c=Dh(u),p=Vh(e.type.size,d,c,t?.scaleTypeSizes===true),f=zl(e),m={brightness:e.brightness,highContrast:false,meta:{displayName:r,logoUrl:n,placeholder:e.meta.placeholder,hidePoweredBy:e.meta.hidePoweredBy},color:f,space:e.space,radius:e.radius,type:{...e.type,...zh(e.type,t),fontUrl:s,fontUrls:o,size:p.content,tierSizes:p,scale:d,maxScale:u,scaleCaps:c},motion:l,slots:Ol(e.slots,Bh(f))};return t?.highContrast===true?$l(Ye(m)):Ye(m)}i(jh,"finalize");var mu="/widget/v1/entitlements",Wh=304,Gh=Object.freeze({kind:"notModified"});async function gu(e,t={},r=Ie({auth:e})){let n=await r.send("entitlements.fetch",qh(t));return n.ok?$h(n.value):n.error.httpStatus===Wh?Gh:{kind:"failed",error:n.error}}i(gu,"fetchEntitlements");var Kh=64;function qh(e){let t={};return pi(e.cachedRevision)&&(t["if-none-match"]=`"${e.cachedRevision}"`),e.region&&e.region.length<=Kh?{method:"GET",path:mu,headers:t,query:{region:e.region}}:{method:"GET",path:mu,headers:t}}i(qh,"buildRequest");function $h(e){if(e===null||typeof e!="object"||!pi(e.revision))return yu();let t=typeof e.region=="string"?e.region:"",r=pi(e.ttl_seconds)?e.ttl_seconds:0;return Object.freeze({kind:"updated",revision:e.revision,region:t,ttlSeconds:r,decisions:Xh(e.capabilities),branding:Yh(e),livemode:e.livemode!==false})}i($h,"parseUpdated");function Yh(e){let t=Xe(e.branding);if(t!==null)return t;let r=e.render_hints;if(r!==null&&typeof r=="object"){let n=Xe(r.branding);return n!==null?n:Xe(r)}return null}i(Yh,"parseBranding");function Xh(e){if(e===null||typeof e!="object")return Object.freeze([]);let t=[];for(let[r,n]of Object.entries(e))Qh(n)&&t.push(Object.freeze({resource:r,granted:true}));return Object.freeze(t)}i(Xh,"mapCapabilities");function Qh(e){return typeof e=="object"&&e!==null&&e.enabled===true}i(Qh,"isEnabled");function yu(){return {kind:"failed",error:D("internalError",{retryable:true,wireMessage:"malformed entitlements response"})}}i(yu,"malformed");function pi(e){return typeof e=="number"&&Number.isFinite(e)}i(pi,"isFiniteNumber");var Zh=30;function hu(e){let t=e.scheduler??Jh,r=e.resolve??gu,n=Math.max(1,e.floorSeconds??Zh),o=e.rng??Math.random,s=i(()=>n+o()*n,"jitteredFloorSeconds"),a=false,l=false,u=null,d=null,c=n,p=0,f=i(()=>{u!==null&&(t.clear(u),u=null);},"clearTimer"),m=i(S=>{l||!a||(c=Math.max(n,S),u=t.set(()=>{u=null,b();},c*1e3));},"schedule"),h=null,T=i(async()=>{if(l)return null;let S=p;e.onFetch?.();let P=e.region?{cachedRevision:d,region:e.region}:{cachedRevision:d},k;try{k=await r(e.authFor(),P);}catch(x){return e.telemetry?.track("sdk.entitlements.poll_error",{reason:eb(x)}),!l&&S===p&&(e.onSettled?.(),m(s())),null}if(l||S!==p)return null;switch(k.kind){case "updated":d=k.revision,e.update(k.decisions,k.branding??null,k.livemode!==false),m(k.ttlSeconds);break;case "notModified":m(c);break;case "failed":e.telemetry?.track("sdk.entitlements.poll_failed",{code:k.error.code}),m(s());break;default:m(s());}return e.onSettled?.(),k},"tick"),b=i(()=>{let S=T().finally(()=>{h===S&&(h=null);});return h=S,S},"run");return {start(){a||l||(a=true,b());},prime(){return l?Promise.resolve(null):h??b()},stop(){l||(l=true,p++,f());},refresh(){l||!a||(p++,d=null,f(),b());}}}i(hu,"createEntitlementPoller");var Jh={set(e,t){let r=setTimeout(e,t);return r.unref?.(),r},clear(e){clearTimeout(e);}};function eb(e){return e instanceof Error?e.message:"poll failed"}i(eb,"describe");var bu="everfur.notifications.device";var tb=3e3,vu=Object.freeze([bu]);function Eu(e){let{leaving:t,identity:r,hooks:n,telemetry:o}=e;if(t===null||r===null||n.size===0)return null;let s=Object.freeze({userRef:t.userRef,auth:e.graceAuth()}),a=[...n].map(d=>{try{return Promise.resolve(d(s))}catch(c){return Promise.reject(c)}}),l=i((d,c)=>{try{o.track("sdk.logout.hookFailed",{reason:d,count:c,totalCount:a.length});}catch{}},"report"),u=Promise.allSettled(a).then(d=>{let c=d.filter(p=>p.status==="rejected").length;c>0&&l("failed",c);});return new Promise(d=>{let c=false,p=i(()=>{c||(c=true,clearTimeout(f),d());},"finish"),f=setTimeout(()=>{c||l("timeout",a.length),p();},tb);u.then(p,p);})}i(Eu,"startBeforeLogoutHooks");function Cu(e){let{leaving:t,identity:r,transport:n,sessionId:o}=e,s=r.currentToken();s.catch(()=>{});let a={userRef:t.userRef,currentToken:i(()=>s,"currentToken"),hasToken:i(()=>true,"hasToken"),clear:i(()=>{},"clear")};return {mode:"personalized",transport:n,identity:a,userRef:t.userRef,sessionId:o}}i(Cu,"graceAuth");async function Ru(e,t){if(vu.length===0)return;let r=await Promise.allSettled(vu.map(o=>e.removeItem(o))),n=r.filter(o=>o.status==="rejected").length;n>0&&t.track("sdk.logout.sweepPartialFailure",{failedCount:n,totalCount:r.length});}i(Ru,"sweepPerUserKv");function rb(){return Object.freeze([Object.freeze({resource:"chat.message.create",granted:true})])}i(rb,"compiledDefaultDecisions");function fi(e=rb){let t=new Set,r=Object.freeze({decisions:e(),isPending:false,branding:null}),n=i(()=>{for(let o of t)o();},"emit");return {subscribe(o){return t.add(o),()=>{t.delete(o);}},getSnapshot(){return r},set(o){r=Object.freeze({decisions:Object.freeze([...o.decisions]),isPending:o.isPending,branding:o.branding??null,...o.livemode===false?{livemode:false}:{}}),n();},reset(){r=Object.freeze({decisions:e(),isPending:false,branding:null}),n();},setPending(o){r.isPending!==o&&(r=Object.freeze({...r,isPending:o}),n());}}}i(fi,"createEntitlementStore");function mi(e){return D("validationFailed",{retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`})}i(mi,"notConfiguredError");function Su(e,t){let r={publishableKey:e.publishableKey,...e.apiBaseUrl!==void 0?{apiBaseUrl:e.apiBaseUrl}:{},...e.contractVersion!==void 0?{contractVersion:e.contractVersion}:{},...e.debug!==void 0?{debug:e.debug}:{}};return oa(r,t===void 0?void 0:{platform:t})}i(Su,"tryResolveClient");function Tu(e){return Object.freeze({track(t,r){try{e.track(t,r);}catch{}},trackExpectedFailure(t,r){try{e.trackExpectedFailure(t,r);}catch{}}})}i(Tu,"guardTelemetry");var nb=Object.freeze({"react-native":"If the value is set in your environment, note that babel-preset-expo inlines only EXPO_PUBLIC_* variables into a release bundle.",web:`If the value is set in your environment, note that a browser bundle does not expose ${Jr} to the SDK at run time (bundlers inline only the variables your own code names), so pass apiBaseUrl in config.`});function Pu(e,t,r=ho){try{t.trackExpectedFailure("sdk.config.invalid",{reason:e.reason});}catch{}globalThis.console?.error?.(`[everfur] SDK disabled: ${e.message}
12
+ [everfur] Every Everfur capability will render its off-state until this is fixed. `+nb[r]);}i(Pu,"reportConfigFailure");function yi(e){return Object.freeze({request(){return Promise.resolve(v(mi(e)))},stream(t,r){let n=ye({code:"sdk_not_configured",retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`,synthesized:true,lastEventId:null});return {async*[Symbol.asyncIterator](){r.aborted||(yield n);}}}})}i(yi,"refusingTransport");function ku(){let e=new Map;return {async getItem(t){return e.get(t)??null},async setItem(t,r){e.set(t,r);},async removeItem(t){e.delete(t);},async keys(t){return [...e.keys()].filter(r=>r.startsWith(t))}}}i(ku,"createInMemoryKv");var xu=Object.freeze({clearMemoryCache(){},clearDiskCache(){}});function Iu(e,t){return new hi(e,t)}i(Iu,"createEverfurRuntime");var ob=6e4,bi=class bi{constructor(t,r){this.sessionId=yo();this.entries=new Map;this.destroyers=new Map;this.epoch=0;this.disposed=false;this.verdictSettled=false;this.refreshTimer=null;this.bootstraps=new WeakMap;this.prepared=null;this.beforeLogoutHooks=new Set;this.pendingBeforeLogout=null;this.leavingSessionId=null;let n=t.config;if(n.secureStore!==void 0&&n.secureStore.isAvailable===true)throw new re("invalid-argument","config.secureStore is not yet consumable: SDK token persistence is unimplemented. Omit secureStore to keep memory-only tokens (SPEC-10 \xA75.3).");this.telemetry=n.telemetry?Tu(n.telemetry):Qr;let o=typeof n?.publishableKey=="string"?n.publishableKey.trim():"",s=bo(n?.publishableKey),a=n.transport!==void 0,l,u=typeof n.apiBaseUrl=="string"&&n.apiBaseUrl.trim().length>0?n.apiBaseUrl.trim():null;if(s!==null)l=yi(s);else if(n.transport!==void 0)l=n.transport;else {let c=Su(n,r?.platform);c.ok?(u=c.config.apiBaseUrl,l=da({config:c.config,...r?.eventSourceFactory?{eventSourceFactory:r.eventSourceFactory}:{}})):(s=c.failure,l=yi(c.failure));}this.configFailure=s,this.publishableKey=s===null?o:"",this.transport=l,s!==null&&Pu(s,this.telemetry,r?.platform),this.errorPolicy=n.errorPolicy,this.camera=n.camera??Ws,this.upload=n.upload??_a,this.uploadTransport=n.uploadTransport??Uo,this.imageCache=n.imageCache??xu,this.kv=n.storage??ku(),this.currentUser=t.user??null,this.identity=this.buildIdentity(t.user??null),this.activePet=t.activePet,this.store=s===null?fi():fi(()=>Tl("sdk_config",Dt("accessDenied"))),this.services={authFor:i(c=>this.buildAuth(c),"authFor"),telemetry:this.telemetry,errorPolicy:this.errorPolicy,camera:this.camera,upload:this.upload,uploadTransport:this.uploadTransport,imageCache:this.imageCache,kv:this.kv,apiBaseUrl:u},this.registry={services:this.services,acquireChat:i(c=>this.acquireInternal("chat",gi(c),()=>this.buildChatController(c),_u),"acquireChat"),releaseChat:i(c=>this.releaseInternal(c),"releaseChat"),peekChat:i(c=>this.entries.get(`${this.epoch}|chat|${gi(c)}`)?.controller??null,"peekChat"),acquire:i((c,p,f,m)=>this.acquireInternal(c,p,f,m),"acquire"),release:i(c=>this.releaseInternal(c),"release")},this.entitlements=this.store;let d=s===null&&(r?.startEntitlementPolling??!a);this.poller=s===null?this.buildPoller(r?.pollScheduler):null,d&&this.poller?.start();}get isDisposed(){return this.disposed}get scopeEpoch(){return this.epoch}buildIdentity(t){if(t===null)return null;let r=Zs(t.userRef,t.getToken,n=>this.armTokenRefresh(r,n));return r}armTokenRefresh(t,r){if(this.clearTokenRefresh(),r===null||this.disposed||t!==this.identity)return;let n=r-Date.now();if(n<=0)return;let o=Math.max(n-ob,n/2);this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,!(this.disposed||t!==this.identity)&&t.currentToken({forceRefresh:true}).catch(()=>{});},o),this.refreshTimer.unref?.();}clearTokenRefresh(){this.refreshTimer!==null&&clearTimeout(this.refreshTimer),this.refreshTimer=null;}buildPoller(t){return hu({authFor:i(()=>this.buildAuth(this.currentUser?.userRef??null),"authFor"),update:i((r,n,o)=>this.updateEntitlements({decisions:r,isPending:false,branding:n,...o===false?{livemode:o}:{}}),"update"),onFetch:i(()=>{this.verdictSettled||this.store.setPending(true);},"onFetch"),onSettled:i(()=>{this.verdictSettled=true,this.store.setPending(false);},"onSettled"),telemetry:this.telemetry,...t?{scheduler:t}:{}})}acquireInternal(t,r,n,o,s=false){let a=`${this.epoch}|${t}|${r}`,l=this.entries.get(a);if(l)return s||(l.warm?l.warm=false:l.refCount+=1),l.controller;let u=n();return this.entries.set(a,{controller:u,refCount:1,warm:s}),this.destroyers.set(u,o),u}releaseInternal(t){for(let[r,n]of this.entries)if(n.controller===t){n.refCount-=1,n.refCount<=0&&(this.runDestroyer(t),this.entries.delete(r));return}}runDestroyer(t){let r=this.destroyers.get(t);this.destroyers.delete(t),r&&r(t);}buildChatController(t){let r=qa({auth:this.buildAuth(t.userRef),telemetry:this.telemetry,...this.errorPolicy?{errorPolicy:this.errorPolicy}:{},initialConversationId:t.conversationId,petRef:t.petRef});return this.runBootstrap(r,t),r}runBootstrap(t,r){let n={};r.petRef!==null&&(n.petRef=r.petRef),r.conversationId!==null&&(n.resumeConversationId=r.conversationId);let o=Xa(n,{controller:t});return o.then(s=>t.adoptPrompts(s.suggestedPrompts)).catch(()=>{}),this.bootstraps.set(t,o),o}buildAuth(t){return this.identity!==null&&this.currentUser!==null?{mode:"personalized",transport:this.transport,identity:this.identity,userRef:this.currentUser.userRef,sessionId:this.sessionId}:{mode:"anonymous",transport:this.transport,publishableKey:this.publishableKey,userRef:this.currentUser===null?null:t,sessionId:this.sessionId}}setUser(t){if(this.disposed)return;let r=t?.userRef??null,n=this.currentUser?.userRef??null;if(r===n){this.currentUser=t,t&&this.identity===null&&(this.identity=this.buildIdentity(t));return}this.pendingBeforeLogout=this.beforeLogoutSettlement(),this.identity?.clear(),this.clearTokenRefresh(),this.currentUser=t,this.identity=this.buildIdentity(t),this.rescopeAll();}async logout(){if(this.disposed)return;let t=this.currentUser===null;this.leavingSessionId=this.sessionId,this.sessionId=yo(),this.setUser(null),this.leavingSessionId=null,t&&this.rescopeAll();let r=this.pendingBeforeLogout;this.pendingBeforeLogout=null,r!==null&&await r,await Ru(this.kv,this.telemetry);}onBeforeLogout(t){return this.disposed?()=>{}:(this.beforeLogoutHooks.add(t),()=>{this.beforeLogoutHooks.delete(t);})}beforeLogoutSettlement(){let t=this.currentUser,r=this.identity;return Eu({leaving:t,identity:r,hooks:this.beforeLogoutHooks,telemetry:this.telemetry,graceAuth:i(()=>Cu({leaving:t,identity:r,transport:this.transport,sessionId:this.leavingSessionId??this.sessionId}),"graceAuth")})}async registerPet(t,r){return this.withPets("registerPet",n=>r===void 0?n.registerPet(t):n.registerPet(t,r))}updatePet(t,r){return this.withPets("updatePet",n=>n.updatePet(t,r))}deletePet(t){return this.withPets("deletePet",r=>r.deletePet(t))}eraseUserData(){return this.withPets("eraseUserData",t=>t.eraseUserData())}async withPets(t,r){return this.disposed?v(wu(t)):r(lt(this.buildAuth(this.currentUser?.userRef??null)))}prepare(t){let r=t?.petRef??null,n=`${this.epoch}|${this.currentUser?.userRef??""}|${r??""}`,o=this.prepared;if(o!==null&&o.key===n&&(o.result===null||o.result.status==="ready"))return o.promise;let s={key:n,result:null,promise:this.runPrepare(r).then(a=>(s.result=a,a))};return this.prepared=s,s.promise}async runPrepare(t){let r=Date.now(),n=this.configFailure,o=this.disposed?wu("prepare"):n===null?null:mi(n),s=this.identity,[a,l,u]=await Promise.all([o?v(o):s===null?L(void 0):s.currentToken().then(()=>L(void 0),()=>v(D("authRejected",{retryable:false}))),o?v(o):this.primeEntitlements(),t===null?void 0:o?v(o):this.primeChat(t)]),d=a.ok?l.ok&&(u?.ok??true)?"ready":"partial":"failed",c=Date.now()-r;try{this.telemetry.track("sdk.prepare.timing",{durationMs:c,status:d});}catch{}return Object.freeze({status:d,durationMs:c,session:a,entitlements:l,...u?{chat:u}:{}})}async primeEntitlements(){let t=await this.poller?.prime();return t?t.kind==="failed"?v(t.error):L(void 0):v(D("internalError",{retryable:true}))}async primeChat(t){let r={userRef:this.currentUser?.userRef??null,petRef:t,conversationId:null},n=this.acquireInternal("chat",gi(r),()=>this.buildChatController(r),_u,true),o=await this.bootstraps.get(n);return o?.cause&&n.getSnapshot().conversationId===null&&(o=await this.runBootstrap(n,r)),o?.cause?v(o.cause):L(void 0)}setActivePet(t){if(this.disposed)return;let r=t??null;r!==this.activePet&&(this.activePet=r,this.rescopeAll());}updateEntitlements(t){this.disposed||this.configFailure===null&&this.store.set(t);}open(t){this.telemetry.track("sdk.open",{capability:t});}dispose(){this.disposed||(this.disposed=true,this.epoch+=1,this.poller?.stop(),this.identity?.clear(),this.clearTokenRefresh(),this.disposeAllControllers());}rescopeAll(){this.epoch+=1,this.disposeAllControllers(),this.store.reset(),this.verdictSettled=false,this.poller?.refresh();}disposeAllControllers(){for(let t of this.entries.values())this.runDestroyer(t.controller);this.entries.clear(),this.destroyers.clear();}};i(bi,"EverfurRuntimeImpl");var hi=bi;function gi(e){return `${e.userRef??""}|${e.petRef??""}|${e.conversationId??""}`}i(gi,"chatScopeKey");function _u(e){e.dispose();}i(_u,"disposeChat");function wu(e){return D("validationFailed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}i(wu,"disposedError");var Au=Symbol.for("@everfur/sdk#EverfurContext@v1"),Ou=globalThis,En=Ou[Au]??(Ou[Au]=react.createContext(null));En.displayName??="EverfurContext";function ee(){let e=react.useContext(En);if(e===null)throw new re("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(ee,"useEverfurContext");function Fu(){return ee().handle}i(Fu,"useEverfur");var Mu=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Lu=globalThis,Cr=Lu[Mu]??(Lu[Mu]=react.createContext(Be));Cr.displayName??="EverfurThemeContext";function N(){return react.useContext(Cr)}i(N,"useEverfurTheme");function Cn(e){let{runtime:t}=ee(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot),o=e.seams.useColorScheme(),s=e.seams.useReducedMotion(),a=e.seams.useTextScale(),l=e.seams.useHighContrast(),u=e.seams.scaleTypeSizes,d=e.seams.platformMonoFamily?.(),c=e.seams.isFontRegistered,p=e.clientTheme?cb(e.clientTheme):"",f=react.useMemo(()=>e.clientTheme?Xe(e.clientTheme):null,[p]),m=n.branding??null,h=react.useMemo(()=>ci({branding:m,clientOverride:f,colorScheme:o,reducedMotion:s,textScale:a,scaleTypeSizes:u,highContrast:l,...d===void 0?{}:{platformMonoFamily:d},...c===void 0?{}:{isFontRegistered:c}}),[m,f,o,s,a,u,l,d,c]);return e.seams.useResolvedTheme?.(h),react.createElement(Cr.Provider,{value:h},e.children)}i(Cn,"EverfurThemeProviderCore");function cb(e){try{return JSON.stringify(e)}catch{return Object.keys(e).join("&")}}i(cb,"stableKey");function Bu(e){let{config:t,user:r,activePet:n,theme:o,warmUp:s,children:a,seams:l}=e,u=`${t?.publishableKey??""}|${t?.apiBaseUrl??""}|${t?.contractVersion??""}`,d=react.useRef(null),c=react.useRef(null),[p,f]=react.useReducer(w=>w+1,0),m=react.useRef(null),h=react.useRef(void 0),T=r?.userRef??null;h.current!==T&&(h.current!==void 0&&(m.current=null),h.current=T);let b=m.current!==null?m.current.user:r??null,S=react.useRef(null),P=react.useRef(void 0),k=n??null;P.current!==k&&(P.current!==void 0&&(S.current=null),P.current=k);let x=S.current!==null?S.current.pet:n??null;(d.current===null||d.current.key!==u||d.current.runtime.isDisposed)&&(d.current!==null&&!d.current.runtime.isDisposed&&(c.current=d.current.runtime),d.current={key:u,runtime:Iu({config:l.withDefaults?l.withDefaults(t):t,user:b,activePet:x,theme:o??null},{platform:l.platform,...l.eventSourceFactory?{eventSourceFactory:l.eventSourceFactory}:{}})});let y=d.current.runtime,_=react.useRef(null);react.useEffect(()=>{let w=d.current?.runtime;w===void 0||!w.isDisposed||_.current!==w&&(_.current=w,f());}),react.useEffect(()=>{let w=c.current;w!==null&&(c.current=null,w.dispose());});let A=b?.userRef??null;react.useLayoutEffect(()=>{y.setUser(b);},[y,A]),react.useLayoutEffect(()=>{y.setActivePet(x);},[y,x]),react.useEffect(()=>()=>y.dispose(),[y]),react.useEffect(()=>{s==="onMount"&&y.prepare(x===null?{}:{petRef:x});},[y,s,A,x]);let O=react.useMemo(()=>({setUser:i(w=>{m.current={user:w},y.setUser(w),f();},"setUser"),setActivePet:i(w=>{S.current={pet:w},y.setActivePet(w),f();},"setActivePet"),open:i(w=>y.open(w),"open"),prepare:i(w=>y.prepare(w),"prepare"),registerPet:i((w,I)=>y.registerPet(w,I),"registerPet"),updatePet:i((w,I)=>y.updatePet(w,I),"updatePet"),deletePet:i(w=>y.deletePet(w),"deletePet"),eraseUserData:i(()=>y.eraseUserData(),"eraseUserData"),logout:i(()=>{m.current={user:null};let w=y.logout();return f(),w},"logout")}),[y,f]),F=react.useMemo(()=>({runtime:y,handle:O,userRef:A,activePet:x,scopeEpoch:y.scopeEpoch}),[y,O,A,x,p]),C=react.createElement(Cn,{clientTheme:o??null,seams:l.theme,children:a});return react.createElement(En.Provider,{value:F},l.wrap?l.wrap(C):C)}i(Bu,"EverfurProviderCore");var mb=2;function yb(e,t){let r=e?._xhr;if(!r||typeof r.getResponseHeader!="function"||typeof r.readyState=="number"&&r.readyState<mb)return null;let n;try{n=r.getResponseHeader(t);}catch{return null}return typeof n=="string"&&n.length>0?n:null}i(yb,"readEventSourceResponseHeader");function Hu(){let e=fb__default.default;return (t,r)=>{let n=new e(t,{method:r.method,headers:r.headers,pollingInterval:r.pollingInterval??0,...r.body!==void 0?{body:r.body}:{}});return Object.assign(n,{getResponseHeader:i(o=>yb(n,o),"getResponseHeader")})}}i(Hu,"createRnEventSourceFactory");function vb(){let e=reactNative.useColorScheme();return e==="dark"?"dark":e==="light"?"light":null}i(vb,"useRnColorScheme");function Eb(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(Eb,"isThenable");function Cb(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,n=reactNative.AccessibilityInfo?.isReduceMotionEnabled;if(typeof n=="function"){let s=n.call(reactNative.AccessibilityInfo);s!=null&&typeof s.then=="function"&&s.then(a=>{r&&t(a===true);},()=>{});}let o=reactNative.AccessibilityInfo?.addEventListener?.("reduceMotionChanged",s=>t(s===true));return ()=>{r=false,o?.remove?.();}},[]),e}i(Cb,"useRnReducedMotion");function Wu(){let e=reactNative.PixelRatio?.getFontScale;if(typeof e!="function")return 1;try{let t=e.call(reactNative.PixelRatio);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}catch{return 1}}i(Wu,"readFontScale");function Rb(e){let t=reactNative.Dimensions?.addEventListener;if(typeof t!="function")return ()=>{};let r=t.call(reactNative.Dimensions,"change",e);return ()=>r?.remove?.()}i(Rb,"subscribeFontScale");function Sb(){return react.useSyncExternalStore(Rb,Wu,Wu)}i(Sb,"useRnTextScale");function $u(){try{let e=reactNative.Platform?.OS;return typeof e=="string"?e:null}catch{return null}}i($u,"platformOS");function Tb(){return $u()==="android"?{query:"isHighTextContrastEnabled",event:"highTextContrastChanged"}:{query:"isDarkerSystemColorsEnabled",event:"darkerSystemColorsChanged"}}i(Tb,"contrastSignal");function Pb(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,{query:n,event:o}=Tb(),a=reactNative.AccessibilityInfo?.[n];if(typeof a!="function")return ()=>{};try{let d=a.call(reactNative.AccessibilityInfo);Eb(d)&&Promise.resolve(d).then(c=>{r&&t(c===!0);},()=>{});}catch{}let l=reactNative.AccessibilityInfo?.addEventListener,u=typeof l=="function"?l.call(reactNative.AccessibilityInfo,o,d=>t(d===true)):void 0;return ()=>{r=false,u?.remove?.();}},[]),e}i(Pb,"useRnHighContrast");function kb(){return $u()==="ios"?"Menlo":Ve}i(kb,"rnPlatformMonoFamily");function xb(){return globalThis.__DEV__!==false}i(xb,"isDevelopment");var Gu=new Set;function _b(e){if(!xb()||Gu.has(e))return;Gu.add(e);let t=globalThis.console;try{t?.warn?.(`[everfur] The theme names the font face "${e}", which this app has not registered; the SDK renders the platform font at that weight instead. Register the font file (expo-font or your native font assets) or name a registered face.`);}catch{}}i(_b,"warnUnregisteredFace");function wb(e){let t=globalThis.expo?.modules?.ExpoFontLoader,r=t?.getLoadedFonts;if(typeof r!="function")return null;let n;try{n=r.call(t);}catch{return null}if(!Array.isArray(n)||n.length===0)return null;let o=n.includes(e);return o||_b(e),o}i(wb,"rnIsFontRegistered");var Sn=Object.freeze({useColorScheme:vb,useReducedMotion:Cb,useTextScale:Sb,useHighContrast:Pb,scaleTypeSizes:false,platformMonoFamily:kb,isFontRegistered:wb});function Ab(e){return react.createElement(reactNativeSafeAreaContext.SafeAreaProvider,null,e)}i(Ab,"wrapInSafeArea");var Ob=Object.freeze({platform:"react-native",eventSourceFactory:Hu(),wrap:Ab,theme:Sn});function Fb(e){return react.createElement(Bu,{...e,seams:Ob})}i(Fb,"EverfurProvider");function Wt(e){let{runtime:t}=ee(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return react.useMemo(()=>Pl(e,n.decisions,{isPending:n.isPending}),[e,n])}i(Wt,"useCapability");function Vb(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(Vb,"tierMultiplier");function E({tier:e="content",...t}){let{type:r}=N(),n=Vb(r,e);return react.createElement(reactNative.Text,n===void 0?t:{maxFontSizeMultiplier:n,...t})}i(E,"Text");var Gt=react.forwardRef(i(function(t,r){return react.createElement(reactNative.TextInput,{...t,...r===null?{}:{ref:r}})},"TextInput"));var Bb=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function R(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[Bb[t]]}}i(R,"face");var Ei=class Ei extends react.Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(r,n){return Object.is(r.resetKey,n.key)?null:{failed:false,key:r.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};i(Ei,"HostRenderBoundary");var vi=Ei;function zb({render:e}){return e()}i(zb,"RenderHost");function xt({render:e,fallback:t,resetKey:r}){return react.createElement(vi,{fallback:t,resetKey:r,children:react.createElement(zb,{render:e})})}i(xt,"HostRender");var jb=48;function Wb(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(Wb,"selectView");function Si(e){let{capability:t,children:r,renderDisabled:n,renderPending:o,style:s}=e,a=Wt(t),l=react.useMemo(()=>Wb(a),[a]);switch(l){case "enabled":return r;case "pending":return o?jsxRuntime.jsx(xt,{render:o,fallback:jsxRuntime.jsx(Ju,{capability:t,style:s})}):jsxRuntime.jsx(Ju,{capability:t,style:s});case "disabled":return n?jsxRuntime.jsx(xt,{render:()=>n(a),fallback:jsxRuntime.jsx(ed,{decision:a,style:s}),resetKey:a}):jsxRuntime.jsx(ed,{decision:a,style:s});default:return at(l)}}i(Si,"CapabilityGate");function Ju({capability:e,style:t}){let r=N(),n=react.useMemo(()=>td(r),[r]);return jsxRuntime.jsx(reactNative.View,{style:[n.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:jsxRuntime.jsx(reactNative.View,{style:n.skeletonBar})})}i(Ju,"PendingSkeleton");function ed({decision:e,style:t}){let r=N(),n=react.useMemo(()=>td(r),[r]),o=e.disabled?.reason??"";return jsxRuntime.jsx(reactNative.View,{style:[n.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:o,children:o.length>0?jsxRuntime.jsx(E,{style:n.offstateText,children:o}):null})}i(ed,"OffState");function td(e){let{color:t,space:r,radius:n,type:o}=e;return reactNative.StyleSheet.create({offstate:{minHeight:jb,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...R(e,"regular"),fontSize:o.size.body,lineHeight:Math.round(o.size.body*o.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}i(td,"makeStyles");var g=Object.freeze({placeholder:"Ask anything about {petName}\u2026",placeholderFollowUpWeb:"Ask a follow-up\u2026",placeholderUrgentWeb:"Tell us what\u2019s happening\u2026",composerLabel:"Message",attachPhotoOrFileNative:"Add a photo or file",footnoteNative:"Educational, not a diagnosis. Emergency? Call a vet.",footnoteWeb:"Everfur\u2019s assistant isn\u2019t a vet and doesn\u2019t diagnose. Your vet makes the calls. Not for emergencies: if {petName} is in distress, go to the nearest emergency animal hospital now.",suggestions:"Suggestions",reading:"Reading {petName}\u2019s records\u2026",answered:"Everfur answered.",assistantName:"Everfur",followUpsHeadingNative:"Follow-up questions",turnFailedTitleWeb:"Everfur couldn\u2019t answer that just now.",send:"Send",stop:"Stop",retry:"Try again",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",senderVet:"Your vet",loading:"Loading",empty:"No messages yet",transcript:"Chat with Everfur",emptyTitle:"What can we help {petName} with today?",emptyTitlePetFallback:"your pet",copied:"Copied",copyUserMessage:"Copy your message",copyAssistantMessage:"Copy assistant message",feedbackHelpful:"Helpful",feedbackNeutral:"Neutral",feedbackNotHelpful:"Not helpful",feedbackTitle:"What went wrong?",feedbackSubtitle:"Your feedback helps make answers more reliable.",feedbackReasonInaccurate:"Inaccurate",feedbackReasonOutdated:"Out of date",feedbackReasonUnsafe:"Unsafe advice",feedbackReasonUnclear:"Confusing or unclear",feedbackReasonOther:"Something else",feedbackNotesPlaceholder:"Add details (optional)",feedbackSubmit:"Submit feedback",feedbackSkip:"Skip",feedbackSkipA11y:"Skip feedback",feedbackThanks:"Thanks for the feedback",feedbackFailed:"Couldn't send feedback. Please try again.",turnFailedTitle:"Message failed",turnRetry:"Retry",turnUnreachableTitle:"Couldn't reach this chat",turnStartNewChat:"Start a new chat",reconnecting:"Reconnecting\u2026",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",openSource:"Open source",urgencyGeneralReason:"Just general info about {petName}. Nothing here needs action right now.",findVet:"Find a vet",findVetA11y:"Find a vet near you",nearestEmergencyVet:"Nearest emergency vet",poisonControlWeb:"ASPCA Poison Control",poisonControlNative:"ASPCA Animal Poison Control, (888) 426-4435",showLatestVetAlert:"Show latest vet alert",dismissBanner:"Dismiss {label} banner",openHistoryNative:"Chats and vet messages",openHistoryWeb:"Chats",showChatsWeb:"Show chats",hideChatsWeb:"Hide chats",newReplySuffix:", a new reply",yourPets:"Your pets",yourPet:"Your pet",switchActivePet:"{name}. Switch pet",petCurrentlyActive:"{name}, currently active",switchToPet:"Switch to {name}",activePrefix:"Active \xB7 ",close:"Close",addAnotherPet:"Add a pet",addPet:"Add a pet",attachmentPhoto:"Photo",attachmentCamera:"Camera",closeAttachmentPicker:"Close attachment picker",addAttachment:"Add attachment, {used} of {total} used",attachmentsFull:"Attachments full, {used} of {total} used",retryUpload:"Retry uploading {filename}",removeAttachment:"Remove {filename}",previewAttachment:"Preview {filename}",closePreview:"Close preview",attachedImage:"Attached image: {filename}, opens a full-screen preview",attachmentTooLarge:"Files must be under {max}. {filename} is {size}.",attachmentTooMany:"You can attach up to {max} files per message.",attachmentUnsupported:"{filename} isn't a supported file type yet.",attachmentNetwork:"Couldn't reach the server. Check your connection and try again.",attachmentServer:"Upload failed{status}. Please try again.",attachmentCancelled:"Upload cancelled.",attachmentRateLimited:"Slow down. Please wait a moment and try again.",attachmentQuota:"Daily image limit reached. Try again tomorrow.",attachmentConflict:"Something went wrong. Tap to retry.",attachmentUnknown:"Something went wrong. Please try again.",attachmentsFailedBlocked:"Some attachments failed to upload. Remove or retry them before sending.",dictate:"Dictate a message",stopDictation:"Stop dictation",listening:"Listening",micBlocked:"Microphone access is blocked. Allow it in your browser settings to dictate.",noSpeech:"We didn't catch that. Tap the mic and try again.",dictationUnavailable:"Voice typing isn't available right now."});function K(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let o=t[n];return o===void 0?r:String(o)})}i(K,"fillCopy");function Gb(e){return e?.trim()||g.emptyTitlePetFallback}i(Gb,"petNameSlot");function Tn(e,t){return K(e,{petName:Gb(t)})}i(Tn,"forPet");var rd="tel:+18884264435";var Ti=Object.freeze([Object.freeze({key:"inaccurate",label:g.feedbackReasonInaccurate,feedbackType:"wrong"}),Object.freeze({key:"outdated",label:g.feedbackReasonOutdated,feedbackType:"outdated"}),Object.freeze({key:"unsafe",label:g.feedbackReasonUnsafe,feedbackType:"dangerous"}),Object.freeze({key:"unclear",label:g.feedbackReasonUnclear,feedbackType:"unclear"}),Object.freeze({key:"other",label:g.feedbackReasonOther,feedbackType:"not_helpful"})]),nd=Object.freeze([Object.freeze({sentiment:"up",label:g.feedbackHelpful}),Object.freeze({sentiment:"neutral",label:g.feedbackNeutral}),Object.freeze({sentiment:"down",label:g.feedbackNotHelpful})]);function Kb(e){switch(e){case "up":return "helpful";case "neutral":return "neutral";case "down":return "not_helpful"}}i(Kb,"sentimentToFeedbackType");function od(e,t){if(e==="down"&&t!==null){let r=Ti.find(n=>n.key===t);if(r!==void 0)return r.feedbackType}return Kb(e)}i(od,"feedbackTypeFor");var Xb=Object.freeze({status:"idle",messages:Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:Object.freeze([]),unreadCount:null});function Rr(e){let{runtime:t,userRef:r,activePet:n,scopeEpoch:o}=ee(),s=e?.petRef??n??null,a=e?.conversationId??null,l=react.useMemo(()=>({runtime:t,userRef:r,petRef:s,conversationId:a,scopeEpoch:o}),[t,r,s,a,o]),[u,d]=react.useState(null),c=u?.scope===l?u.controller:t.registry.peekChat({userRef:r,petRef:s,conversationId:a}),p=react.useRef(null);react.useEffect(()=>{let F=t.registry.acquireChat({userRef:r,petRef:s,conversationId:a});return p.current=F,d({scope:l,controller:F}),()=>{p.current=null,d(C=>C?.controller===F?null:C),t.registry.releaseChat(F);}},[t,r,s,a,o,l]);let f=react.useCallback(F=>c?c.subscribe(F):Qb,[c]),m=react.useCallback(()=>c?c.getSnapshot():Xb,[c]),h=react.useSyncExternalStore(f,m,m),T=react.useCallback((F,C)=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?ki(c,c.send(F,C?.imageS3Keys===void 0?{}:{imageS3Keys:C.imageS3Keys}),()=>p.current===c):Promise.resolve(xi()),[c]),b=react.useCallback(F=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?ki(c,c.askEverfur(F),()=>p.current===c):Promise.resolve(xi()),[c]),S=react.useCallback(()=>c&&p.current===c?ki(c,c.retryLast(),()=>p.current===c):Promise.resolve(xi()),[c]),P=react.useCallback(()=>{c&&p.current===c&&c.stop();},[c]),k=react.useCallback(()=>{c&&p.current===c&&c.newConversation();},[c]),[x,y]=react.useState({controller:null,byMessage:{}}),_=x.controller===c?x.byMessage:Zb,A=react.useCallback(async(F,C,w,I)=>{if(!c||p.current!==c)return v(D("accessDenied"));let H=String(F),Q=x.controller===c?x.byMessage[H]:void 0;if(Q===C&&w==null)return y(Y=>{let we={...Y.controller===c?Y.byMessage:{}};return delete we[H],{controller:c,byMessage:we}}),L(Object.freeze({feedbackId:""}));y(Y=>({controller:c,byMessage:{...Y.controller===c?Y.byMessage:{},[H]:C}}));let oe=await c.submitFeedback(F,od(C,w??null),I??null);return p.current!==c?v(D("accessDenied")):(oe.ok||y(Y=>{let we={...Y.controller===c?Y.byMessage:{}};return Q===void 0?delete we[H]:we[H]=Q,{controller:c,byMessage:we}}),oe)},[c,x]),O=react.useMemo(()=>{let F=i(async C=>{if(!c||p.current!==c)return v(D("accessDenied"));let w=await C(c);return p.current===c?w:v(D("accessDenied"))},"run");return {listConversations:i(C=>F(w=>w.listConversations({...s?{petRef:s}:{},...C})),"listConversations"),getMessages:i((C,w)=>F(I=>I.getMessages(C,w)),"getMessages"),resumeConversation:i(C=>F(w=>w.resumeConversation(C)),"resumeConversation"),loadOlderMessages:i(()=>F(C=>C.loadOlderMessages()),"loadOlderMessages"),markRead:i(()=>F(C=>C.markRead()),"markRead"),refreshActiveThread:i(()=>F(C=>C.refreshActiveThread()),"refreshActiveThread"),answerCheckin:i((C,w)=>F(I=>I.answerCheckin(C,w)),"answerCheckin"),openCheckin:i(C=>F(w=>w.openCheckin(C)),"openCheckin")}},[c,s]);return react.useMemo(()=>({status:h.status,messages:h.messages,conversationId:h.conversationId,petRef:s,error:h.error,isStreaming:h.isStreaming,isBootstrapping:h.isBootstrapping,historyCursor:h.historyCursor??null,isLoadingHistory:h.isLoadingHistory??false,stopped:h.stopped??false,reconnecting:h.reconnecting??false,...O,suggestedPrompts:h.suggestedPrompts,unreadCount:h.unreadCount,hasUnreadThreads:h.hasUnreadThreads??false,newConversation:k,sentimentByMessage:_,feedback:A,send:T,askEverfur:b,retryLast:S,stop:P}),[h,s,T,b,S,P,O,k,_,A])}i(Rr,"useEverfurChat");var Qb=i(()=>{},"NOOP_UNSUBSCRIBE"),Zb=Object.freeze({});async function ki(e,t,r){for await(let o of t);if(!r())return v(D("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?v(n.error):L(Jb(n.messages))}i(ki,"driveToResult");function Jb(e){for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(r&&r.role==="assistant"&&r.responseId!==void 0)return r.responseId}return null}i(Jb,"lastAssistantResponseId");function xi(){return v(D("internalError",{retryable:true}))}i(xi,"notReadyError");function ld(e){switch(e.code){case "too_large":return K(g.attachmentTooLarge,{max:Bo(sn),filename:e.filename,size:Bo(e.sizeBytes??0)});case "too_many":return K(g.attachmentTooMany,{max:an});case "unsupported_type":return K(g.attachmentUnsupported,{filename:e.filename});case "network":return g.attachmentNetwork;case "server":return K(g.attachmentServer,{status:e.httpStatus?` (${e.httpStatus})`:""});case "cancelled":return g.attachmentCancelled;case "rate_limited":return g.attachmentRateLimited;case "quota_exceeded":return g.attachmentQuota;case "idempotency_conflict":return g.attachmentConflict;case "unknown":return g.attachmentUnknown}}i(ld,"attachmentErrorMessage");function ud(e,t){return K(e>=t?g.attachmentsFull:g.addAttachment,{used:e,total:t})}i(ud,"attachControlLabel");var nv=Object.freeze({attachments:Object.freeze([])});function Pn(e={}){let{runtime:t,userRef:r,scopeEpoch:n}=ee(),o=e.maxPerMessage??an,s=react.useCallback(()=>{let{services:y}=t.registry;return Ja({funnel:Ie({auth:y.authFor(r),...y.errorPolicy?{errorPolicy:y.errorPolicy}:{}}),transport:e.transport??y.uploadTransport,maxPerMessage:o})},[t,r,n,o,e.transport]),a=react.useMemo(()=>e.queue??s(),[e.queue,s]),l=react.useRef(new WeakSet),[u,d]=react.useState(null),c=u!==null&&u.of===a?u.queue:a;react.useEffect(()=>{if(c!==e.queue){if(l.current.has(c)){d({of:a,queue:s()});return}return ()=>{c.dispose(),l.current.add(c);}}},[c,a,s,e.queue]);let p=react.useSyncExternalStore(c.subscribe,c.getSnapshot,()=>nv),[f,m]=react.useState(null),h=react.useCallback(y=>{let A=(Array.isArray(y)?y:[y]).map(F=>c.add(F)),O=A.find(F=>!F.ok);return O!==void 0&&!O.ok&&m(O.error),A},[c,m]),T=react.useCallback(y=>c.retry(y),[c]),b=react.useCallback(y=>c.remove(y),[c]),S=react.useCallback(()=>c.clear(),[c]),P=react.useCallback(()=>m(null),[m]),k=p.attachments.some(y=>y.status==="uploading"),x=p.attachments.some(y=>y.status==="failed");return react.useMemo(()=>({available:c.available,attachments:p.attachments,maxPerMessage:o,uploading:k,failed:x,blocked:k||x,s3Keys:p.attachments.flatMap(y=>y.status==="uploaded"&&y.s3Key!==null?[y.s3Key]:[]),rejected:f,add:h,retry:T,remove:b,clear:S,dismissRejected:P}),[c.available,p,o,k,x,f,h,T,b,S,P])}i(Pn,"useChatAttachments");var sv="pet_not_registered";function pd(e){return e!=null&&e.reasonCode===sv}i(pd,"isPetNotRegistered");var av=Object.freeze({status:"idle",error:null,registered:null,retry:i(()=>{},"retry")});function fd(e,t,r){let{runtime:n,userRef:o,scopeEpoch:s}=ee(),a=react.useCallback(()=>lt(n.registry.services.authFor(o)),[n,o,s]),l=react.useMemo(()=>t===void 0?null:wi(t),[t]),[u,d]=react.useState({key:null,status:"idle",error:null,registered:null}),c=react.useRef(0),p=react.useRef(r);p.current=r;let f=e===null||l===null?null:`${String(o)}|${s}|${e}|${l}`,m=react.useCallback(()=>{if(e===null||t===void 0||f===null)return;let T=++c.current;d({key:f,status:"registering",error:null,registered:null}),a().registerPet(e,t).then(b=>{T===c.current&&(b.ok?(d({key:f,status:"registered",error:null,registered:b.value}),p.current?.()):d({key:f,status:"failed",error:b.error,registered:null}));});},[a,e,f]);react.useEffect(()=>{if(f===null){c.current+=1;return}return m(),()=>{c.current+=1;}},[f,m]);let h=react.useCallback(()=>{u.status==="failed"&&m();},[u.status,m]);return react.useMemo(()=>f===null?av:u.key!==f?{status:"registering",error:null,registered:null,retry:h}:{status:u.status,error:u.error,registered:u.registered,retry:h},[f,u,h])}i(fd,"useChatPetRegistration");function wi(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(wi).join(",")}]`:`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>`${JSON.stringify(r)}:${wi(n)}`).join(",")}}`}i(wi,"stableKey");var Ii=Object.freeze({});function yd(e){let[t,r]=react.useState(Ii),n=react.useRef(null),o=react.useRef([]);o.current=e.map(a=>a.id),react.useEffect(()=>{if(e.length===0){n.current=null,r(u=>u===Ii?u:Ii);return}let a=n.current;if(a===null)return;let l=e.find(u=>u.role==="user"&&!a.known.has(u.id));l!==void 0&&(n.current=null,r(u=>({...u,[l.id]:a.images})));},[e]);let s=react.useCallback(a=>{n.current=a.length===0?null:{images:a,known:new Set(o.current)};},[]);return react.useMemo(()=>({byMessage:t,stage:s}),[t,s])}i(yd,"useSentImages");var fv=500;function Ai(e){if(!e)return null;let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g," ").replace(/\s+/g," ").trim();return t?t.slice(0,fv):null}i(Ai,"sanitizeSeedPrompt");function hd(e,t,r){let n=Ai(r),o=react.useRef(e);o.current=e;let s=react.useRef(null);react.useEffect(()=>{if(n===null||t||s.current===n)return;let a=o.current;a!==void 0&&(s.current=n,Promise.resolve(a(n)).catch(()=>{}));},[n,t]);}i(hd,"useInitialAsk");function mv(e,t,r){if(e==="announced")return false;let n=r.lastRefresh;return n===null||n.conversationId!==t?false:r.now-n.at<15e3}i(mv,"isCoalesced");function bd(e,t){let r=t.activeConversationId;return r===null||r.length===0?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:mv(e,r,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:r}}i(bd,"decideChatRefresh");function Oi(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(Oi,"reportHostFailure");function yv(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(yv,"isThenable");function $(e,...t){if(typeof e=="function")try{let r=e(...t);return yv(r)&&Promise.resolve(r).then(void 0,Oi),r}catch(r){Oi(r);return}}i($,"callHost");var vd=new WeakMap;function Ed(e){if(typeof e!="function")return;let t=vd.get(e);if(t!==void 0)return t;let r=i((...n)=>{$(e,...n);},"guarded");return vd.set(e,r),r}i(Ed,"guardHost");function qt(e,...t){let r;try{r=e(...t);}catch(n){return Oi(n),Promise.resolve({ok:false,error:n})}return Promise.resolve(r).then(n=>({ok:true,value:n}),n=>({ok:false,error:n}))}i(qt,"callHostAsync");function Rd(e,t){let r=react.useRef(t);r.current=t;let n=react.useRef(null),o=react.useRef(null),s=e?.isOffline===void 0?false:$(()=>e.isOffline?.()===!0)===true,a=react.useRef(()=>{});a.current=l=>{let{conversationId:u,isTurnInFlight:d,refresh:c}=r.current,p=bd(l,{activeConversationId:u,isTurnInFlight:d,isOffline:s,lastRefresh:n.current,now:Date.now()});if(p.action!=="skip"){if(p.action==="defer"){o.current!=="announced"&&(o.current=l);return}o.current=null,n.current={conversationId:p.conversationId,at:Date.now()},c!==void 0&&Promise.resolve(c()).catch(()=>{});}},react.useEffect(()=>{if(t.isTurnInFlight||s)return;let l=o.current;l!==null&&a.current(l);},[t.isTurnInFlight,s]),react.useEffect(()=>{if(e===void 0)return;let l=[],u=i((d,c)=>{if(d===void 0)return;let p=$(()=>d(()=>{a.current(c);}));typeof p=="function"&&l.push(p);},"subscribe");return u(e.onForeground?.bind(e),"foreground"),u(e.onOnline?.bind(e),"foreground"),u(e.onAnnounced?.bind(e),"announced"),()=>{for(let d of l)$(d);}},[e]);}i(Rd,"useChatLifecycle");function hv(e){if(e===void 0)return null;let t=e.conversationId??"",r=e.petRef??"";return t===""&&r===""?null:`${String(t)}|${String(r)}`}i(hv,"targetKey");function Td(e,t){let r=hv(t),n=react.useRef({openCheckin:e,target:t});n.current={openCheckin:e,target:t};let o=react.useRef(null);react.useEffect(()=>{if(r===null||o.current===r)return;o.current=r;let{openCheckin:s,target:a}=n.current;s===void 0||a===void 0||Promise.resolve(s(a)).catch(()=>{});},[r]);}i(Td,"useCheckinTarget");function xd(e,t,r){let[n,o]=react.useState({send:e,conversationId:t,text:r??"",seeded:r??null}),s=n.send===e&&(n.conversationId===null||n.conversationId===t);react.useEffect(()=>{o(l=>{let u=l.send===e&&(l.conversationId===null||l.conversationId===t),d=u?l.text:"",c=u?l.seeded:null,p=r!=null&&r!==c&&d.length===0;return {send:e,conversationId:t,text:p?r:d,seeded:p?r:c}});},[e,t,r]);let a=react.useCallback(l=>o(u=>({send:e,conversationId:t,text:l,seeded:u.seeded})),[e,t]);return [s?n.text:"",a]}i(xd,"useChatDraft");function _d(e,t,r,n){let o=react.useRef({draft:r,setDraft:n});o.current={draft:r,setDraft:n};let s=react.useRef(null),[a,l]=react.useState(null);react.useEffect(()=>{if(e===void 0)return;let u=`${t??""}`;if(s.current===u)return;s.current=u;let d=true;return (async()=>{let c=await qt(()=>e.read(t));if(!d)return;let p=c.ok&&typeof c.value=="string"?c.value:"";p.length>0&&o.current.draft.length===0&&o.current.setDraft(p),l(u);})(),()=>{d=false;}},[e,t]),react.useEffect(()=>{e===void 0||a!==`${t??""}`||$(()=>e.write(t,r));},[e,t,r,a]);}i(_d,"usePersistedDraft");var q=Object.freeze({heading:"Chats",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No chats match that.",loading:"Loading your chats\u2026",loadFailed:"Couldn\u2019t load your chats",loadingMore:"Loading more\u2026",untitled:"New conversation",newChat:"New chat",searchPlaceholder:"Search chats\u2026",search:"Search chats",countLabel:"Chats and vet messages",countSeparator:" \xB7 ",newReply:"New reply \xB7 {date}",retry:"Try again",retryA11y:"Retry loading chats",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages\u2026",openConversation:"Open conversation",unreadPrefix:"Unread. "});function xn(e){let t=e?.replace(/\s+/g," ").trim();return t||q.untitled}i(xn,"conversationTitle");function Sv(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}i(Sv,"conversationDate");function Id(e){let t=Sv(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?q.newReply.replace("{date}",t):t}i(Id,"conversationMeta");function Ad(e,t){return t?`${q.countLabel}${q.countSeparator}${e}`:q.countLabel}i(Ad,"historyCountLabel");function Od(e){return `${e.unreadCount!==null&&e.unreadCount>0?q.unreadPrefix:""}${q.openConversation} ${xn(e.title)}`}i(Od,"openConversationLabel");function wd(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}i(wd,"normalizeForSearch");function Tv(e,t){let r=wd(t);if(r.length===0)return e;let n=[[],[],[]];for(let o of e){let s=wd(xn(o.title)),a=s.indexOf(r);if(a<0)continue;let l=a===0?0:s.charAt(a-1)===" "?1:2;n[l]?.push(o);}return n.flat()}i(Tv,"filterConversations");function Li(e){return {scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}i(Li,"fresh");function Fd(e){let[t,r]=react.useState(false),[n,o]=react.useState(""),s=e.listConversations,a=react.useRef(0),[l,u]=react.useState(()=>Li(s)),d=l.scope===s?l:Li(s);react.useEffect(()=>(a.current+=1,r(false),o(""),u(Li(s)),()=>{a.current+=1;}),[s]);let c=react.useCallback(async k=>{let x=++a.current,y=k!==void 0;u(A=>({...A,scope:s,loading:!y,loadingMore:y,error:null}));let _=await e.listConversations(k?{cursor:k}:void 0);if(x===a.current){if(!_.ok){u(A=>({...A,loading:false,loadingMore:false,error:_.error.displayMessage}));return}u(A=>{let O=k&&A.scope===s?A.rows:[],F=new Set(O.map(C=>C.id));return {scope:s,loading:false,loadingMore:false,error:null,rows:[...O,..._.value.conversations.filter(C=>!F.has(C.id))],cursor:_.value.nextCursor===k?null:_.value.nextCursor}});}},[e.listConversations,s]),p=i(()=>{r(true),o(""),c();},"show"),f=i(()=>{a.current+=1,r(false);},"close"),m=i(async k=>{let x=++a.current;u(_=>({..._,loading:true,error:null}));let y=await e.resumeConversation(k);x===a.current&&(u(_=>({..._,loading:false,error:y.ok?null:y.error.displayMessage})),y.ok&&r(false));},"resume"),h=i(async()=>{let k=a.current,x=await e.loadOlderMessages();k===a.current&&!x.ok&&u(y=>({...y,error:x.error.displayMessage}));},"earlier"),T=i(()=>{e.newConversation(),a.current+=1,r(false);},"newConversation"),b=i(()=>{d.cursor===null||d.loading||d.loadingMore||n.trim().length>0||c(d.cursor);},"loadMore"),S=react.useMemo(()=>Tv(d.rows,n),[d.rows,n]),P=n.trim().length>0;return {...d,open:t,show:p,close:f,load:c,resume:m,earlier:h,newConversation:T,loadMore:b,query:n,setQuery:o,searching:P,filtered:S,emptyKind:d.rows.length===0?"empty":"noMatch"}}i(Fd,"useHistoryPanel");var _n="#111111",wn="#FFFFFF",xv=Object.freeze({emergency:Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:_n,pillColor:wn,showsVetAction:true}),schedule_soon:Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:_n,pillColor:wn,showsVetAction:true}),home_care:Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:_n,pillColor:wn,showsVetAction:false}),general:Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:_n,pillColor:wn,showsVetAction:false})});function _v(e){return `${e.messageId}:${e.level}:${e.reason??""}`}i(_v,"urgencySignature");function wv(e){return K(g.urgencyGeneralReason,{petName:e?.trim()||g.emptyTitlePetFallback})}i(wv,"generalUrgencyReason");function Nd(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n?.role!=="assistant"||n.responseId===void 0)continue;let o=n.urgencyLevel;return o?{messageId:n.id,level:o,reason:Iv(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:wv(t)}:null}return null}i(Nd,"latestUrgencySource");function Iv(e){return typeof e=="string"&&e.trim().length>0?e:null}i(Iv,"shownReason");function Dd(e){let t=e===null?null:_v(e),[r,n]=react.useState(null),[o,s]=react.useState(false);react.useEffect(()=>s(false),[t]);let l=e!==null&&(o||!(r!==null&&r===t)),u=e===null?null:xv[e.level],d=e!==null&&!l&&e.level!=="general",c=react.useCallback(()=>{t!==null&&n(t),s(false);},[t]),p=react.useCallback(()=>s(true),[]);return react.useMemo(()=>({source:e,tier:u,signature:t,showBanner:l,showCompactIcon:d,showVetAction:l&&u!==null&&u.showsVetAction,dismissLabel:u===null?null:K(g.dismissBanner,{label:u.label}),dismiss:c,expand:p}),[e,u,t,l,d,c,p])}i(Dd,"useUrgencySurface");function Ud(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}i(Ud,"selectView");function Av(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}i(Av,"needsNewConversation");function Vd(e,t="native"){if(e.messages.length===0)return null;let r=e.status==="error"?e.error:null;if(r!==null){let n=Av(r),o=t==="web";return {tone:"error",title:n?g.turnUnreachableTitle:o?g.turnFailedTitleWeb:g.turnFailedTitle,body:r.displayMessage,actionLabel:n?g.turnStartNewChat:o?g.retry:g.turnRetry,action:n?"startNew":"retry"}}return e.stopped===true?{tone:"neutral",title:g.turnStoppedTitle,body:g.turnStoppedBody,actionLabel:g.turnRetry,action:"retry"}:null}i(Vd,"turnNotice");function Bd(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}i(Bd,"awaitingAssistant");var Ov=3,Fv=Object.freeze([]);function Hd(e){let t=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||t===void 0||t.role!=="assistant")return Fv;let r=new Set,n=[];for(let o of e.suggestedPrompts){let s=o.trim(),a=s.replace(/\s+/g," ").toLowerCase();if(!(a.length===0||r.has(a))&&(r.add(a),n.push(s),n.length===Ov))break}return Object.freeze(n)}i(Hd,"visibleFollowUps");function zd(e){return e.sender?.displayName??g.senderVet}i(zd,"vetSenderLabel");function jd(e,t){let r={};return e!==void 0&&(r.petRef=e),t!==void 0&&(r.conversationId=t),r}i(jd,"buildChatOpts");var fe={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function de(e){return {width:e,height:e,alignItems:"center",justifyContent:"center"}}i(de,"box");function be(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}i(be,"stroke");function Wd({size:e,color:t,strokeWidth:r}){let n=be(e,r),o={width:e*.82,height:n,borderRadius:n,backgroundColor:t};return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{gap:e*.22}],...fe,children:[jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o})]})}i(Wd,"MenuGlyph");function Gd({size:e,color:t,strokeWidth:r,rotate:n}){let o=be(e,r),s=e*.78;return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{transform:[{rotate:n}]}],...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:s,height:o,borderRadius:o,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:o,height:s,borderRadius:o,backgroundColor:t}})]})}i(Gd,"Cross");function In(e){return jsxRuntime.jsx(Gd,{...e,rotate:"0deg"})}i(In,"PlusGlyph");function Qe(e){return jsxRuntime.jsx(Gd,{...e,rotate:"45deg"})}i(Qe,"CloseGlyph");function pt({size:e,color:t,strokeWidth:r}){let n=be(e,r);return jsxRuntime.jsx(reactNative.View,{style:de(e),...fe,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}i(pt,"CheckGlyph");var Lv={down:{rotate:"45deg",marginTop:-0.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-0.4}};function Kd({size:e,color:t,strokeWidth:r,direction:n}){let o=be(e,r),s=e*.46,a=Lv[n];return jsxRuntime.jsx(reactNative.View,{style:de(e),...fe,children:jsxRuntime.jsx(reactNative.View,{style:{width:s,height:s,borderRightWidth:o,borderBottomWidth:o,borderColor:t,marginTop:s*a.marginTop,marginLeft:s*a.marginLeft,transform:[{rotate:a.rotate}]}})})}i(Kd,"ChevronGlyph");function qd({size:e,color:t,strokeWidth:r}){let n=be(e,r),o={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{flexDirection:"row",gap:1}],...fe,children:[jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopLeftRadius:e*.2}]}),jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}i(qd,"BookGlyph");function $d({size:e,color:t,strokeWidth:r}){let n=be(e,r),o=e*.5;return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:e*.78,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.16,right:e*.16,width:o,height:o,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}i($d,"ArrowUpRightGlyph");function Yd({size:e,color:t,strokeWidth:r}){let n=be(e,r),o=e*.6,s={position:"absolute",width:o,height:o,borderWidth:n,borderColor:t,borderRadius:e*.14};return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,children:[jsxRuntime.jsx(reactNative.View,{style:[s,{top:0,left:0}]}),jsxRuntime.jsx(reactNative.View,{style:[s,{bottom:0,right:0}]})]})}i(Yd,"CopyGlyph");function An({size:e,color:t,strokeWidth:r,active:n,rotate:o}){let s=be(e,r),a=n?t:"transparent";return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{transform:[{rotate:o}]}],...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.05}})]})}i(An,"ThumbGlyph");function Xd({size:e,color:t,strokeWidth:r}){let n=be(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{width:n,height:n,borderRadius:n,backgroundColor:t,marginBottom:e*.1}}),jsxRuntime.jsx(reactNative.View,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}i(Xd,"InfoGlyph");function Qd({size:e,color:t,strokeWidth:r}){let n=be(e,r),o=e*.34;return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.06,width:o,height:o,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.1,width:n,height:e*.56,borderRadius:n,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}i(Qd,"UploadGlyph");function Zd({size:e,color:t,strokeWidth:r}){let n=be(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[de(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(Zd,"PhotoGlyph");function Jd({size:e,color:t,strokeWidth:r}){let n=be(e,r);return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderTopLeftRadius:n,borderTopRightRadius:n}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}i(Jd,"CameraGlyph");function ec({size:e,color:t,strokeWidth:r}){let n=be(e,r),o=e*.66;return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:0,left:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.02,right:e*.02,width:n,height:e*.4,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}})]})}i(ec,"SearchGlyph");function Ni({size:e,color:t,strokeWidth:r}){let n=be(e,r),o=e*.62;return jsxRuntime.jsxs(reactNative.View,{style:de(e),...fe,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t,alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(reactNative.View,{style:{width:n*1.4,height:n*1.4,borderRadius:n,backgroundColor:t}})}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.04,width:o*.5,height:o*.5,borderRightWidth:n,borderBottomWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(Ni,"MapPinGlyph");function tc({size:e,color:t,testID:r}){let n=e*.36;return jsxRuntime.jsx(reactNative.View,{style:de(e),testID:r,...fe,children:jsxRuntime.jsx(reactNative.View,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}i(tc,"SendGlyph");function rc({size:e,color:t,testID:r}){return jsxRuntime.jsx(reactNative.View,{style:de(e),testID:r,...fe,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}i(rc,"StopGlyph");function On({size:e,strokeWidth:t,color:r,children:n}){return jsxRuntime.jsx(reactNative.View,{style:[de(e),{borderRadius:e/2,borderWidth:t??reactNative.StyleSheet.hairlineWidth,borderColor:r}],children:n})}i(On,"Ring");var $t=Object.freeze({standard:Ct.standard,emphasized:Ct.emphasized,exit:Ct.exit,outQuad:Object.freeze([.25,.46,.45,.94]),out:Object.freeze([.23,1,.32,1])});var nc=Object.freeze({layoutMs:220,messageInMs:200,bannerInMs:220,bannerOutMs:160,iconInMs:180,iconOutMs:120,followUpInMs:180,followUpStaggerMs:70,citationsInMs:220,citationsRisePx:6,drawerMs:220,pressScale:.97,pressMs:140,revealTickMs:24,revealDivisor:12,dotsCycleMs:520,dotsMinOpacity:.44,dotsLiftPx:3.5,dotsStagger:Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,bubbleInMs:280,bubbleFromScale:.94,bubbleRisePx:6,promptRisePx:8,reduced:false}),Nv=Object.freeze({...nc,layoutMs:0,messageInMs:0,bannerInMs:0,bannerOutMs:0,iconInMs:0,iconOutMs:0,followUpInMs:0,followUpStaggerMs:0,citationsInMs:0,citationsRisePx:0,drawerMs:0,pressScale:1,pressMs:0,revealTickMs:0,dotsCycleMs:0,dotsMinOpacity:1,dotsLiftPx:0,bubbleInMs:0,bubbleFromScale:1,bubbleRisePx:0,promptRisePx:0,reduced:true});function oc(e){return e.motion.reducedMotion?Nv:nc}i(oc,"chatMotion");function Fn(e,t){return Math.max(0,t)*e.followUpStaggerMs}i(Fn,"followUpDelayMs");function ic(e,t,r){if(e.reduced||t>=r)return r;let n=Math.max(1,Math.ceil((r-t)/e.revealDivisor));return Math.min(r,t+n)}i(ic,"nextRevealLength");function te(){let e=N();return oc(e)}i(te,"useChatMotion");var Bv=8;function ac(e,t,r){return ((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}i(ac,"bezierComponent");function Hv(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}i(Hv,"bezierSlope");function Tr(e){let[t,r,n,o]=e;return s=>{if(s<=0)return 0;if(s>=1)return 1;let a=s;for(let l=0;l<Bv;l+=1){let u=Hv(a,t,n);if(u===0)break;a-=(ac(a,t,n)-s)/u;}return ac(Math.min(1,Math.max(0,a)),r,o)}}i(Tr,"bezierEasing");var Di=Tr($t.standard),zv=Tr($t.outQuad),jv=Tr($t.out);function Ln(e){let t=react.useRef(null);return t.current===null&&(t.current=new reactNative.Animated.Value(e)),t.current}i(Ln,"useAnimatedValue");function Yt(e,t={}){let r=t.risePx??0,n=t.delayMs??0,o=Ln(e>0?0:1);return react.useEffect(()=>{if(e<=0)return;let s=reactNative.Animated.timing(o,{toValue:1,duration:e,easing:zv,useNativeDriver:true}),a=n>0?reactNative.Animated.sequence([reactNative.Animated.delay(n),s]):s;return a.start(),()=>a.stop()},[o,e,n]),react.useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[o,r])}i(Yt,"useFadeIn");function Bi({visible:e,inMs:t,outMs:r,style:n,children:o}){let[s,a]=react.useState(e),l=Ln(e&&t<=0?1:0);return react.useEffect(()=>{if(e){a(true);let d=reactNative.Animated.timing(l,{toValue:1,duration:Math.max(0,t),easing:Di,useNativeDriver:true});return d.start(),()=>d.stop()}if(!s)return;if(r<=0){a(false);return}let u=reactNative.Animated.timing(l,{toValue:0,duration:r,easing:Di,useNativeDriver:true});return u.start(({finished:d})=>{d&&a(false);}),()=>u.stop()},[e,s,t,r,l]),!s&&!e?null:jsxRuntime.jsx(reactNative.Animated.View,{style:[n,{opacity:l}],children:o})}i(Bi,"FadePresence");var Wv=Object.freeze({opacity:1,transform:Object.freeze([{translateY:0},{scale:1}])});function cc(e,t){let[r]=react.useState(()=>e?t.bubbleInMs:0),n=r>0,o=Ln(n?0:1);react.useEffect(()=>{if(r<=0)return;let l=reactNative.Animated.timing(o,{toValue:1,duration:r,easing:jv,useNativeDriver:true});return l.start(),()=>l.stop()},[r,o]);let s=t.bubbleFromScale,a=t.bubbleRisePx;return react.useMemo(()=>n?{opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[a,0]})},{scale:o.interpolate({inputRange:[0,1],outputRange:[s,1]})}]}:Wv,[n,o,a,s])}i(cc,"useBubbleEnter");function pc(e){let t=react.useRef(null),r=react.useRef(null),n=e[0]?.id??null;if(t.current===null||r.current!==n){let s=t.current===null;t.current=new Map(e.map(a=>[a.id,s&&a.pending===true])),r.current=n;}let o=t.current;for(let s of e)o.has(s.id)||o.set(s.id,true);return react.useCallback(s=>o.get(s)===true,[o])}i(pc,"useEnteringRows");var Gv=12;function z({style:e,containerStyle:t,children:r,onPressIn:n,onPressOut:o,hitSlop:s,...a}){let l=te(),u=Ln(1),d=react.useCallback(c=>{l.pressMs<=0||l.pressScale===1||reactNative.Animated.timing(u,{toValue:c,duration:l.pressMs,easing:Di,useNativeDriver:true}).start();},[u,l.pressMs,l.pressScale]);return jsxRuntime.jsx(reactNative.Pressable,{...a,hitSlop:s??Gv,style:t,onPressIn:c=>{d(l.pressScale),n?.(c);},onPressOut:c=>{d(1),o?.(c);},children:jsxRuntime.jsx(reactNative.Animated.View,{style:[e,{transform:[{scale:u}]}],children:r})})}i(z,"PressScale");function fc(e,t,r){let n=t&&r.revealTickMs>0,[o,s]=react.useState(0),a=react.useRef(e);return a.current=e,react.useEffect(()=>{if(!n)return;let l=setInterval(()=>{s(u=>ic(r,u,a.current.length));},r.revealTickMs);return ()=>clearInterval(l)},[n,r]),n?e.slice(0,Math.min(o,e.length)):e}i(fc,"useRevealedText");var lc=false;function Kv(e){e.layoutMs<=0||(lc||(lc=true,reactNative.Platform.OS==="android"&&typeof reactNative.UIManager.setLayoutAnimationEnabledExperimental=="function"&&reactNative.UIManager.setLayoutAnimationEnabledExperimental(true)),reactNative.LayoutAnimation.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}));}i(Kv,"animateLayout");function Pr(e,t){let r=react.useRef(e);r.current!==e&&(r.current=e,Kv(t));}i(Pr,"useAnimateLayoutOn");var Hi=36,Jv=22,eE=12,tE=12,rE=16,nE="#000",oE="rgba(0,0,0,0.45)";function mc({uri:e,label:t,onClose:r}){let n=N(),o=reactNativeSafeAreaContext.useSafeAreaInsets();return e===null?null:jsxRuntime.jsxs(reactNative.Modal,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:g.closePreview,style:Nn.backdrop,onPress:r,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:Nn.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),jsxRuntime.jsx(reactNative.View,{pointerEvents:"box-none",style:[Nn.closeWrap,{top:o.top+tE}],children:jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:g.closePreview,hitSlop:eE,style:Nn.closeButton,onPress:r,children:jsxRuntime.jsx(Qe,{size:Jv,color:n.color.surface,strokeWidth:2})})})]})}i(mc,"AttachmentImageLightbox");var Nn=reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:nE,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:rE},closeButton:{width:Hi,height:Hi,borderRadius:Hi/2,backgroundColor:oE,alignItems:"center",justifyContent:"center"}});var Dn=12,uE=80,zi=44,yc=22,dE=.14,cE=18,pE=8,gc=Object.freeze({photo:g.attachmentPhoto,camera:g.attachmentCamera});function hc({sources:e,full:t,onPick:r,onClose:n}){let o=N(),s=react.useMemo(()=>fE(o),[o]);return jsxRuntime.jsxs(reactNative.View,{style:s.anchor,pointerEvents:"box-none",children:[jsxRuntime.jsx(reactNative.Pressable,{style:s.dismissLayer,accessibilityRole:"button",accessibilityLabel:g.closeAttachmentPicker,onPress:n}),jsxRuntime.jsxs(reactNative.View,{style:s.bubble,children:[jsxRuntime.jsx(reactNative.View,{style:s.tilesRow,children:e.map(a=>jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:gc[a],accessibilityState:{disabled:t},disabled:t,containerStyle:s.tile,style:s.tileInner,onPress:()=>r(a),children:[jsxRuntime.jsx(reactNative.View,{style:s.tileIconWrap,children:a==="photo"?jsxRuntime.jsx(Zd,{size:yc,color:o.color.brandInk,strokeWidth:1.5}):jsxRuntime.jsx(Jd,{size:yc,color:o.color.brandInk,strokeWidth:1.5})}),jsxRuntime.jsx(E,{tier:"control",style:s.tileLabel,children:gc[a]})]},a))}),jsxRuntime.jsx(reactNative.View,{style:s.tail}),jsxRuntime.jsx(reactNative.View,{style:s.tailFill})]})]})}i(hc,"AttachmentPickerPopover");function fE(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({anchor:{position:"absolute",left:0,right:0,bottom:"100%",paddingHorizontal:8,paddingBottom:10,alignItems:"flex-start"},dismissLayer:{position:"absolute",left:-1e3,right:-1e3,top:-2e3,bottom:0},bubble:{backgroundColor:t.surfaceCream,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:6,paddingVertical:8,shadowColor:t.shadow,shadowOpacity:dE,shadowRadius:cE,shadowOffset:{width:0,height:pE},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:uE,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:zi,height:zi,borderRadius:zi/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...R(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-Dn/2,width:Dn,height:Dn,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:Dn+4,height:2,backgroundColor:t.surfaceCream}})}i(fE,"makeStyles");var Pe=Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var vc=56,Ec=12,gE=14,hE=10,bE=.45,vE="rgba(7,193,104,0.55)",EE="rgba(185,28,28,0.55)",CE=200,RE=300,_c=20,Wi=22,SE=12,TE="rgba(0,0,0,0.78)",Cc=220,Rc=100,Sc="rgba(255,255,255,0.15)";function wc({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:o,onPreview:s}){let a=N(),l=react.useMemo(()=>Ac(a),[a]);return e.length===0&&t===null?null:jsxRuntime.jsxs(reactNative.View,{style:l.strip,children:[e.length>0?jsxRuntime.jsx(reactNative.View,{style:l.cards,children:e.map(u=>jsxRuntime.jsx(PE,{row:u,styles:l,onRetry:n,onRemove:o,onPreview:s},u.id))}):null,r?jsxRuntime.jsx(E,{style:l.rejected,accessibilityRole:"alert",children:g.attachmentsFailedBlocked}):null,t!==null?jsxRuntime.jsx(E,{style:l.rejected,accessibilityRole:"alert",children:ld(t)}):null]})}i(wc,"AttachmentStrip");function PE({row:e,styles:t,onRetry:r,onRemove:n,onPreview:o}){let s=N(),a=e.status==="uploading",l=e.status==="failed",u=e.status==="uploaded",d=react.useRef(e.status),[c,p]=react.useState(false);return react.useEffect(()=>{let f=d.current;d.current=e.status,e.status==="uploaded"&&f==="uploading"&&p(true);},[e.status]),jsxRuntime.jsxs(reactNative.View,{style:t.card,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:u?"button":"image",accessibilityLabel:u?K(g.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:a,disabled:!u},disabled:!u,style:t.thumbHit,onPress:()=>o(e),children:jsxRuntime.jsxs(reactNative.View,{style:t.thumb,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),a?jsxRuntime.jsx(reactNative.View,{style:t.uploadingOverlay,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:s.color.surface})}):null,c?jsxRuntime.jsx(kE,{styles:t,onDone:()=>p(false)}):null]})}),l?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K(g.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:jsxRuntime.jsx(reactNative.View,{style:t.failedInner,children:jsxRuntime.jsx(Qe,{size:_c,color:s.color.surface,strokeWidth:2})})}):null,jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:K(g.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:jsxRuntime.jsx(Qe,{size:SE,color:s.color.surface,strokeWidth:1.5})})]})}i(PE,"PreviewCard");function kE({styles:e,onDone:t}){let r=N(),n=te(),o=react.useRef(null);o.current===null&&(o.current=new reactNative.Animated.Value(0));let s=o.current;return react.useEffect(()=>{let a=reactNative.Animated.sequence([reactNative.Animated.timing(s,{toValue:1,duration:CE,useNativeDriver:true}),reactNative.Animated.delay(n.uploadFlashMs),reactNative.Animated.timing(s,{toValue:0,duration:RE,useNativeDriver:true})]);return a.start(({finished:l})=>{l&&t();}),()=>a.stop()},[s,n.uploadFlashMs,t]),jsxRuntime.jsx(reactNative.Animated.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:s}],children:jsxRuntime.jsx(pt,{size:_c,color:r.color.surface,strokeWidth:2})})}i(kE,"SuccessFlash");function Ic({images:e,onPreview:t}){let r=N(),n=react.useMemo(()=>Ac(r),[r]);if(e.length===0)return null;let o=e.length===1;return jsxRuntime.jsx(reactNative.View,{style:o?n.sentSingle:n.sentGrid,children:e.map((s,a)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K(g.attachedImage,{filename:s.filename}),onPress:()=>t(s),children:jsxRuntime.jsx(reactNative.Image,{source:{uri:s.uri},style:o?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${s.uri}-${a}`))})}i(Ic,"SentImages");function Ac(e){let t=e.color,r=e.type;return reactNative.StyleSheet.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:vc,height:vc,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:Ec,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...Pe,alignItems:"center",justifyContent:"center",backgroundColor:ut(e.color.brandInk,bE)??e.color.brandSofter},successOverlay:{...Pe,alignItems:"center",justifyContent:"center",backgroundColor:vE},failedOverlay:{...Pe,borderRadius:Ec,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:EE},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:Wi,height:Wi,borderRadius:Wi/2,backgroundColor:TE,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...R(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},sentSingle:{marginBottom:6},sentGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,marginBottom:6},singleImage:{width:Cc,height:Cc,borderRadius:gE,backgroundColor:Sc},gridImage:{width:Rc,height:Rc,borderRadius:hE,backgroundColor:Sc}})}i(Ac,"makeStyles");var xE="chat attachment upload: the file handle has no uri",_E="chat attachment upload failed";function wE(e){return {uri:e.uri,name:Vo(e.name),type:e.mimeType}}i(wE,"filePartOf");function Oc(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(xE));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(_E)),"failed");return o?.aborted===true?a():Xr({url:t.upload_url,fields:t.upload_fields,file:wE(r),signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(Oc,"createRnChatAttachmentTransport");function Un(){let{runtime:e,userRef:t,activePet:r,scopeEpoch:n}=ee(),o=react.useMemo(()=>lt(e.registry.services.authFor(t)),[e,t,n]),[s,a]=react.useState({repository:o,pets:[],loading:true,error:null}),l=s.repository===o?s:{pets:[],loading:true,error:null},u=react.useRef(0),d=react.useCallback(async()=>{let p=++u.current;a(m=>({...m,repository:o,loading:true,error:null,pets:m.repository===o?m.pets:[]}));let f=await o.list();p===u.current&&a(f.ok?{repository:o,pets:f.value,loading:false,error:null}:m=>({repository:o,pets:m.repository===o?m.pets:[],loading:false,error:f.error}));},[o]);react.useEffect(()=>(d(),()=>{u.current+=1;}),[d]);let c=react.useMemo(()=>r===null?null:l.pets.find(p=>p.petRef===r)??null,[r,l.pets]);return react.useMemo(()=>({pets:l.pets,activePet:c,loading:l.loading,error:l.error,refresh:d}),[l.pets,l.loading,l.error,c,d])}i(Un,"useEverfurPets");function Fc(e,t){if(t!==null){let r=e.find(n=>n.petRef===t);if(r!==void 0)return r}return e[0]??null}i(Fc,"headerPetOf");function me(e,t){if(e===void 0)return {};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}i(me,"slotBox");function Vn(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}i(Vn,"ownGroundSlot");function ke(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(ke,"slotText");var Mc=Object.freeze({visitButton:"Vet"});var Lc=Symbol.for("@everfur/sdk/televet");function Ze(){let e=globalThis,t=e[Lc];if(t!==void 0)return t;let r={presenter:null,snapshot:Object.freeze({request:null,serial:0,activeHost:null}),hosts:[],nextHost:1,listeners:new Set,dailyRegistered:false};return e[Lc]=r,r}i(Ze,"televetGlobal");function Bn(e){let t=Ze();t.snapshot=Object.freeze({...t.snapshot,...e});for(let r of [...t.listeners])try{r();}catch{}}i(Bn,"publish");function Nc(e){let t=Ze().presenter;if(t===null)return "absent";try{return t(e)===!1?"declined":"presented"}catch(r){return console.warn("[everfur] Your registerEverfurTelevetFlow presenter threw; the in-app visit opened instead.",r),"threw"}}i(Nc,"callTelevetPresenter");function Dc(e){let t=Ze();return t.listeners.add(e),()=>{t.listeners.delete(e);}}i(Dc,"subscribeTelevetExperience");function $i(){return Ze().snapshot}i($i,"televetExperienceSnapshot");function ME(){return Ze().hosts.length>0}i(ME,"hasTelevetHost");function Uc(e){if(!ME())return false;let t=Object.freeze({...e});return Bn({request:t,serial:Ze().snapshot.serial+1}),true}i(Uc,"presentTelevetExperience");function Yi(){Ze().snapshot.request!==null&&Bn({request:null});}i(Yi,"dismissTelevetExperience");function Vc(){let e=Ze(),t=e.nextHost;return e.nextHost+=1,e.hosts=[...e.hosts,t],Bn({activeHost:e.hosts[0]??null}),t}i(Vc,"claimTelevetHost");function Bc(e){let t=Ze();t.hosts=t.hosts.filter(n=>n!==e);let r=t.hosts[0]??null;Bn(r===null?{activeHost:r,request:null}:{activeHost:r});}i(Bc,"releaseTelevetHost");var Hc=false;function Hn(e,t){return t!==void 0?($(t,e),"onStartInApp"):Nc(e)==="presented"?"presenter":Uc(e)?"experience":(Hc||(Hc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}i(Hn,"openVetVisitInApp");function Wc(e){let t=null;return ()=>{if(t!==null)return t;let r=e();return t=r,r.then(void 0,()=>{t===r&&(t=null);}),r}}i(Wc,"memoizeTelevetLoader");function Gc(e){let[t,r]=react.useState(null);react.useEffect(()=>{let d=Vc();return r(d),()=>{Bc(d);}},[]);let n=react.useSyncExternalStore(Dc,$i,$i),s=t!==null&&n.activeHost===t?n.request:null,[a,l]=react.useState(null),u=s!==null&&a===null;return react.useEffect(()=>{if(!u)return;let d=true;return e().then(c=>{d&&l(()=>c);},c=>{d&&(console.warn("[everfur] The in-app vet visit could not load its screens.",c),Yi());}),()=>{d=false;}},[u,e]),s===null||a===null?null:{module:a,request:s,serial:n.serial,dismiss:Yi}}i(Gc,"useTelevetExperienceHost");var NE=Wc(()=>import('@everfur/sdk/televet/booking'));function xr(){let e=Gc(NE);if(e===null)return null;let{EverfurTelevetModal:t}=e.module;return jsxRuntime.jsx(t,{request:e.request,onClose:e.dismiss},e.serial)}i(xr,"EverfurTelevetHost");var Xi=Object.freeze(["visit","join","summary","messages"]);function Qi(e){return typeof e=="string"&&Xi.includes(e)}i(Qi,"isVetVisitIntent");var UE="/widget/v1/televet/handoffs",VE="/widget/v1/televet/availability",BE="/widget/v1/televet/chat-entry",HE=/^[a-z0-9][a-z0-9_-]{0,39}$/,zE=/^[A-Za-z0-9_-]{22}$/;var Kc=32,qc=128,$c=64;function Ji(e){let t=e.httpStatus;switch(e.code){case "sessionRequired":return "sessionRequired";case "authExpired":case "authRejected":return "authRejected";case "sdkUpdateRequired":return "sdkUpdateRequired";case "validationFailed":return "invalidRequest";case "rateLimited":case "quotaExceeded":return "rateLimited";}return t===void 0?e.code==="internalError"?"network":"unknown":t===429?"rateLimited":t===404?"unavailable":t===403?"accessDenied":t===401?"authRejected":t===400||t===422?"invalidRequest":t>=500?"serverError":"unknown"}i(Ji,"vetVisitErrorReasonOf");function Yc(e){return v(D("validationFailed",{retryable:false,wireMessage:e}))}i(Yc,"invalid");function Zi(e){return v(D("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}i(Zi,"unusable");function jE(e,t){let r={};e!==void 0&&(r.pet_ref=e);let n=t?.returnTo;if(n!=null){if(typeof n!="string"||!HE.test(n))return {ok:false,message:"returnTo must be a registered return destination key"};r.return_to=n;}let o=t?.entry;if(o!=null){if(o!=="chat"||e===void 0)return {ok:false,message:"entry 'chat' needs the pet the chat is about"};r.entry=o;}let s=t?.visitRef,a=t?.intent,l=s!=null;if(l){let u=typeof s=="string"?s.trim():"";if(u.length<1||[...u].length>$c)return {ok:false,message:`visitRef must be 1..${$c} characters`};r.visit_ref=u;}if(a!=null){if(!l)return {ok:false,message:"intent needs the visitRef it opens"};if(!Qi(a))return {ok:false,message:`intent must be one of ${Xi.join(", ")}`};r.intent=a;}return {ok:true,body:r}}i(jE,"handoffBody");function WE(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!Qi(r)?null:Object.freeze({visitRef:t,intent:r})}i(WE,"parseVisitEcho");function Qc(e){let t=e.funnel??Ie({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=i(o=>(Xc(r,"televet.visit.handoff_failed",{reason:Ji(o)}),v(o)),"failed");return {async createHandoff(o,s){let a;if(o!=null){let b=typeof o=="string"?[...o].length:0;if(b<1||b>qc)return n(D("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${qc} characters`}));a=o;}let l=jE(a,s);if(!l.ok){let b=Yc(l.message);return b.ok?b:n(b.error)}let u=l.body,d=await t.send("televet.visit.handoff",{method:"POST",path:UE,body:u},{idempotent:false,maxAttempts:1});if(!d.ok)return n(d.error);let c=GE(d.value),p=u.return_to!==void 0,f=p?d.value?.flow_id:void 0;if(p&&(typeof f!="string"||!zE.test(f))){let b=Zi("the handoff response carried no usable return flow id");return b.ok?b:n(b.error)}let m=u.visit_ref!==void 0,h=m?WE(d.value?.visit):null;if(m&&h===null){let b=Zi("the handoff response did not confirm the visit it opens");return b.ok?b:n(b.error)}let T=c===null?null:Object.freeze({...c,...p?{flowId:f}:{},...h!==null?{visit:h}:{}});return T===null?n(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Xc(r,"televet.visit.handoff_created",{pet_scoped:u.pet_ref!==void 0}),L(T))},async checkAvailability(o){if(typeof o!="string"||o.length>Kc)return Yc(`state must be at most ${Kc} characters`);let s=await t.send("televet.visit.availability",{method:"POST",path:VE,body:{state:o}},{idempotent:false,maxAttempts:1});if(!s.ok)return v(s.error);let a=s.value?.available;return typeof a!="boolean"?Zi("the availability response carried no usable answer"):L(Object.freeze({available:a}))},async chatEntryOpen(){try{let o=await t.send("televet.visit.chat_entry",{method:"GET",path:BE},{maxAttempts:1});return o.ok&&o.value?.open===!0}catch{return false}}}}i(Qc,"createVetVisitController");function GE(e){if(typeof e!="object"||e===null)return null;let{url:t,expires_at:r}=e;return typeof t!="string"||typeof r!="string"||r.length===0||!YE(t)?null:Object.freeze({url:t,expiresAt:r})}i(GE,"parseHandoff");var KE=new Set(["localhost","127.0.0.1","[::1]"]),qE=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,$E=/[\s\u0000-\u001f\u007f]/;function YE(e){if($E.test(e))return false;let t=qE.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let o=n.replace(/:\d+$/,"").toLowerCase(),s=r==="https",a=r==="http"&&KE.has(o);if(!s&&!a)return false;let l=e.indexOf("#");if(l<0)return false;let u=e.slice(l);return u.startsWith("#h=")&&u.length>3}i(YE,"isOpenableVisitUrl");function Xc(e,t,r){if(e)try{e.track(t,r);}catch{}}i(Xc,"safeTrack");var es=Object.freeze({status:"idle",error:null,errorReason:null});function QE(e,t,r){let{usState:n,chat:o,scope:s}=r,a=t&&(n!==null||o),l=`${n??""}|${o?"chat":""}`,[u,d]=react.useState(null);if(react.useEffect(()=>{if(!a)return;let p=true,f=e.current;return d(null),i(async()=>{try{if(o&&!(f.chatEntryOpen&&await f.chatEntryOpen()))return !1;if(n===null)return !0;if(!f.checkAvailability)return !1;let h=await f.checkAvailability(n);return h.ok&&h.value.available}catch{return false}},"ask")().then(h=>{p&&d({key:l,open:h});}),()=>{p=false;}},[a,l,n,o,s,e]),!a)return null;let c=u!==null&&u.key===l;return {open:c&&u.open,pending:!c}}i(QE,"usePreflight");var ZE=Object.freeze({status:"opening",error:null,errorReason:null});function ep(e,t={}){let{runtime:r,userRef:n,scopeEpoch:o}=ee(),s=Wt("televet"),a=s.enabled&&n!==null,l=t.usState??null,u=t.entry==="chat",d=t.petRef??null,c=t.prefer==="redirect",p=react.useMemo(()=>{if(t.controller)return t.controller;let{services:w}=r.registry;return Qc({auth:w.authFor(n),telemetry:w.telemetry,...w.errorPolicy?{errorPolicy:w.errorPolicy}:{}})},[r,n,o,t.controller]),f=react.useRef(p);f.current=p;let m=react.useMemo(()=>({runtime:r,userRef:n,scopeEpoch:o}),[r,n,o]),h=QE(f,a,{usState:l,chat:u,scope:m}),T=a&&(h===null||h.open)&&(!u||d!==null),b=t.returnTo??null,[S,P]=react.useState(es),k=react.useRef(null),x=react.useRef({runtime:r,userRef:n,scopeEpoch:o});x.current={runtime:r,userRef:n,scopeEpoch:o};let y=react.useRef(p);y.current=p;let _=react.useRef(T);_.current=T;let A=react.useCallback((w,I)=>{if(k.current)return k.current;let H=i((he,st)=>(P({status:he==="cancelled"?"idle":"error",error:st,errorReason:he==="cancelled"?null:he}),Object.freeze({opened:false,reason:he,error:st})),"fail");if(!_.current)return Promise.resolve(H("unavailable",null));let Q=e.prepare();if(!Q.ok)return Promise.resolve(H(Q.reason,null));let oe=x.current,Y=y.current;P(ZE);let it=(async()=>{let he,st={...b!==null?{returnTo:b}:{},...u?{entry:"chat"}:{},...I!==null?{visitRef:I.visitRef}:{},...I!==null&&I.intent!==null&&I.intent!==void 0?{intent:I.intent}:{}},Vr=Object.keys(st).length===0?void 0:st,Br=w===void 0?d:w;try{he=await(Vr===void 0?Y.createHandoff(Br):Y.createHandoff(Br,Vr));}catch{return e.abandon(Q.value),H("unknown",null)}let Lt=x.current;if(Lt.runtime!==oe.runtime||Lt.userRef!==oe.userRef||Lt.scopeEpoch!==oe.scopeEpoch)return e.abandon(Q.value),H("cancelled",null);if(!he.ok)return e.abandon(Q.value),H(Ji(he.error),he.error);let Jt=await e.finish(Q.value,he.value);return Jt!==null?H(Jt,null):(P(es),Object.freeze(he.value.flowId===void 0?{opened:true}:{opened:true,flowId:he.value.flowId}))})().finally(()=>{k.current===it&&(k.current=null);});return k.current=it,it},[e,d,b,u]),O=react.useCallback((w,I)=>{if(!_.current)return P({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}));let H=w===void 0?d:w,Q={...H!==null?{petRef:H}:{},...l!==null?{usState:l}:{},...I!==null?{visitRef:I.visitRef,intent:I.intent}:{}};return Hn(Q)===null?(P({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}))):(P(es),Promise.resolve(Object.freeze({opened:true})))},[d,l]),F=react.useCallback(w=>c?A(w,null):O(w,null),[c,A,O]),C=react.useCallback((w,I)=>c?A(void 0,{visitRef:w,intent:I??null}):O(void 0,{visitRef:w,intent:I??null}),[c,A,O]);return {available:T,isPending:s.isPending||(h?.pending??false),status:S.status,error:S.error,errorReason:S.errorReason,open:F,openVisit:C}}i(ep,"useVetVisitWith");var tC=i(e=>reactNative.Linking.openURL(e),"defaultOpenUrl");function jn(e={}){let{openUrl:t,...r}=e,n=react.useMemo(()=>{let o=t??tC;return {prepare:i(()=>({ok:true,value:null}),"prepare"),async finish(s,a){try{return await o(a.url),null}catch{return "openFailed"}},abandon:i(()=>{},"abandon")}},[t]);return ep(n,r)}i(jn,"useVetVisit");var tp=44,sC=.6;function Zt(e){let{petRef:t,label:r,openUrl:n,onOpened:o,onError:s,style:a,labelStyle:l,controller:u,returnTo:d,usState:c,entry:p,visitRef:f,intent:m,onStartInApp:h,prefer:T}=e,b=T==="redirect",S=jn({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...t!==void 0?{petRef:t}:{},...n!==void 0?{openUrl:n}:{},...u!==void 0?{controller:u}:{},prefer:b?"redirect":"in-app"}),P=N(),k=react.useMemo(()=>aC(P),[P]),x=react.useRef(false);if(!S.available)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[null,jsxRuntime.jsx(xr,{})]});let y=S.status==="opening",_=r??Mc.visitButton;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.Pressable,{onPress:i(()=>{if(!(y||x.current)){if(!b){let O={...t!==void 0?{petRef:t}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:m??null}:{}};Hn(O,h)===null&&$(s,"unavailable",null);return}x.current=true,(f==null?S.open():S.openVisit(f,m??null)).then(O=>{O.opened?$(o,O.flowId??null):O.reason!=="cancelled"&&$(s,O.reason,O.error);}).finally(()=>{x.current=false;});}},"onPress"),accessibilityRole:"button",accessibilityLabel:_,accessibilityState:{busy:y,disabled:y},style:[k.button,y?k.busy:null,a],children:jsxRuntime.jsx(E,{style:[k.label,l],children:_})}),jsxRuntime.jsx(xr,{})]})}i(Zt,"VetVisitButton");function aC(e){let{color:t,space:r,radius:n,type:o,slots:s}=e;return reactNative.StyleSheet.create({button:{minHeight:tp,minWidth:tp,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...me(s.vetVisitButton)},busy:{opacity:sC},label:{...R(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug,...ke(s.vetVisitButton)}})}i(aC,"makeStyles");function ts(e){return pr(e)==="cat"?"cat":"dog"}i(ts,"speciesOf");function rs(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}i(rs,"petAgeYears");function ip(e){let t=rs(e.ageYears),r=ts(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return `${r} \xB7 ${n}`}i(ip,"formatPetMeta");var op=Object.freeze([Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),Object.freeze({background:"#fbc558",foreground:"#10462e"}),Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function lC(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return op[t%op.length]}i(lC,"pickInitialsPalette");function ns(e){let t=(e??"").trim();return (Array.from(t)[0]??"?").toUpperCase()}i(ns,"getInitial");function sp(e){return {...lC(e.petRef),initial:ns(e.name)}}i(sp,"petInitials");function pC(e){return Math.max(12,Math.round(e*.42))}i(pC,"letterSize");function wr({pet:e,size:t,ringStroke:r}){let n=N(),o=react.useMemo(()=>fC(n),[n]),s=t-r*2,a=e===null?null:sp(e),l=pC(s);return jsxRuntime.jsx(On,{size:t,strokeWidth:r,color:n.color.success,children:jsxRuntime.jsx(reactNative.View,{style:[o.disc,{width:s,height:s,borderRadius:s/2},a===null?o.discEmpty:{backgroundColor:a.background}],children:jsxRuntime.jsx(E,{tier:"badge",style:[o.letter,{fontSize:l,lineHeight:Math.round(l*1.2),color:a===null?n.color.text.muted:a.foreground}],children:a===null?ns(null):a.initial})})})}i(wr,"PetDisc");function fC(e){return reactNative.StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...R(e,"bold"),textAlign:"center",includeFontPadding:false}})}i(fC,"makeStyles");var is=48,up=2,vC=320,EC="80%",CC="rgba(17,17,17,0.45)",RC=18,ap=22,SC=12,lp=.4,TC=44;function ss(e){return e?.name?.trim()||g.yourPet}i(ss,"petDisplayName");function dp({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:o=null,onClose:s}){let a=N(),l=react.useMemo(()=>PC(a),[a]);return e?jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:s,children:jsxRuntime.jsxs(reactNative.View,{style:l.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:Pe,onPress:s,accessibilityRole:"button",accessibilityLabel:g.close,children:jsxRuntime.jsx(reactNative.View,{style:l.backdrop})}),jsxRuntime.jsxs(reactNative.View,{style:l.panel,accessibilityViewIsModal:true,children:[jsxRuntime.jsx(E,{tier:"heading",style:l.title,accessibilityRole:"header",children:g.yourPets}),jsxRuntime.jsx(reactNative.ScrollView,{style:l.list,contentContainerStyle:l.listContent,showsVerticalScrollIndicator:true,children:t.map(u=>{let d=u.petRef===r,c=ss(u),p=ip(u);return jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:K(d?g.petCurrentlyActive:g.switchToPet,{name:c}),accessibilityState:{selected:d},style:[l.row,d?l.rowActive:null],onPress:()=>n(u.petRef),children:[jsxRuntime.jsx(wr,{pet:u,size:is,ringStroke:up}),jsxRuntime.jsxs(reactNative.View,{style:l.copy,children:[jsxRuntime.jsx(E,{style:l.name,numberOfLines:1,children:c}),jsxRuntime.jsx(E,{tier:"compact",style:l.meta,numberOfLines:1,children:d?`${g.activePrefix}${p}`:p})]}),d?jsxRuntime.jsx(pt,{size:RC,color:a.color.brandInk}):null]},u.petRef)})}),o!==null?jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:g.addAnotherPet,style:l.addRow,onPress:o,children:[jsxRuntime.jsx(reactNative.View,{style:l.addDisc,children:jsxRuntime.jsx(E,{tier:"control",style:l.addPlus,children:"+"})}),jsxRuntime.jsx(E,{style:l.addLabel,children:g.addAnotherPet})]}):null,jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:g.close,containerStyle:l.closeSlot,style:l.closeButton,onPress:s,children:jsxRuntime.jsx(E,{tier:"control",style:l.closeText,children:g.close})})]})]})}):null}i(dp,"PetSwitcherSheet");function PC(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:CC},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:ap,borderTopRightRadius:ap,gap:14,maxHeight:EC},title:{...R(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk},list:{maxHeight:vC,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:TC,paddingHorizontal:8},addDisc:{width:is,height:is,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:up,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...R(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...R(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary},row:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:r.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},rowActive:{borderColor:t.brandInk,backgroundColor:t.brandSoft},copy:{flex:1,gap:2},name:{...R(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...R(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:lp},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:SC,backgroundColor:t.brandSoft},closeText:{...R(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:lp}})}i(PC,"makeStyles");var _C=44,Gn=36,wC=22,as=9,IC=1.5,pp=6,wt=35,Kn=1.75,ls=12.4,AC=.5,OC=8,FC=28,MC=160;function ds(e,t){return Fc(e,t)}i(ds,"headerPet");function mp({pets:e,petRef:t,historyUnread:r,onOpenHistory:n,onPetChange:o,onAddPet:s,vet:a}){let l=N(),u=react.useMemo(()=>NC(l),[l]),[d,c]=react.useState(false),p=ds(e.pets,t),f=e.pets.length>=2,m=t??p?.petRef??null,h=ss(p),T=i(S=>{c(false),e.setActivePet(S),$(o,S);},"select"),b=s===void 0?null:()=>{c(false),$(s);};return jsxRuntime.jsxs(reactNative.View,{style:u.row,children:[jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:r?`${g.openHistoryNative}${g.newReplySuffix}`:g.openHistoryNative,containerStyle:u.iconSlot,style:u.iconButton,onPress:n,children:[jsxRuntime.jsx(Wd,{size:wC,color:l.color.text.primary,strokeWidth:2}),r?jsxRuntime.jsx(reactNative.View,{style:u.unreadDot,pointerEvents:"none"}):null]}),jsxRuntime.jsx(reactNative.View,{style:u.center,pointerEvents:"box-none",children:jsxRuntime.jsx(LC,{logoUrl:l.meta.logoUrl,name:l.meta.displayName,styles:u})}),m===null?null:jsxRuntime.jsx(Zt,{entry:"chat",petRef:m,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:u.vetEntry,labelStyle:u.vetEntryLabel}),jsxRuntime.jsx(reactNative.View,{style:u.right,children:f?jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:K(g.switchActivePet,{name:h}),containerStyle:u.avatarSlot,style:u.avatarWrap,onPress:()=>c(true),children:[jsxRuntime.jsx(wr,{pet:p,size:wt,ringStroke:Kn}),jsxRuntime.jsx(reactNative.View,{style:u.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:jsxRuntime.jsx(In,{size:OC,color:l.color.brandInk,strokeWidth:2})})]}):e.loading&&p===null?jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityLabel:g.yourPet,children:jsxRuntime.jsx(On,{size:wt,strokeWidth:Kn,color:l.color.success,children:jsxRuntime.jsx(reactNative.View,{style:u.placeholderDisc})})}):jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:p===null?g.yourPet:h,children:jsxRuntime.jsx(wr,{pet:p,size:wt,ringStroke:Kn})})}),jsxRuntime.jsx(dp,{visible:d,pets:e.pets,activePetRef:p?.petRef??null,onSelect:T,onAddPet:b,onClose:()=>c(false)})]})}i(mp,"ChatHeader");function LC({logoUrl:e,name:t,styles:r}){let[n,o]=react.useState(null);return e===null||n===e?null:jsxRuntime.jsx(reactNative.View,{style:r.logoBar,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:r.logo,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:()=>o(e)})})}i(LC,"BrandLogo");function NC(e){let t=e.color,r=wt-Kn*2;return reactNative.StyleSheet.create({vetEntry:{minHeight:_C,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},vetEntryLabel:{...R(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingVertical:10,backgroundColor:t.surface},iconSlot:{borderRadius:Gn/2},iconButton:{width:Gn,height:Gn,borderRadius:Gn/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:pp,right:pp,width:as,height:as,borderRadius:as,backgroundColor:t.danger,borderWidth:IC,borderColor:t.surface},center:{...Pe,alignItems:"center",justifyContent:"center"},logoBar:{alignItems:"center",paddingHorizontal:e.space.lg},logo:{height:FC,width:MC},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:wt/2},avatarWrap:{width:wt,height:wt,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:ls,height:ls,borderRadius:ls/2,borderWidth:AC,borderColor:t.success,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}i(NC,"makeStyles");var hp=44,HC="rgba(17,17,17,0.55)",bp=26,zC=36,vp=4,cs=20,ps=38,jC=18,WC=12;function Ep({visible:e,onSubmit:t,onSkip:r}){let n=N(),o=react.useMemo(()=>GC(n),[n]),[s,a]=react.useState(null),[l,u]=react.useState(""),[d,c]=react.useState(false),[p,f]=react.useState(false),m=i(()=>{a(null),u(""),c(false),f(false);},"reset"),h=i(()=>{d||(m(),r());},"skip"),T=i(async()=>{if(d)return;c(true),f(false);let S=l.trim();await t(s,S.length>0?S:null)?m():(c(false),f(true));},"submit");if(!e)return null;let b=[...l].length>Bt;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:n.motion.reducedMotion?"none":"slide",onRequestClose:h,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:reactNative.Platform.OS==="ios"?"padding":void 0,style:o.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:o.scrim,onPress:h,accessibilityRole:"button",accessibilityLabel:g.feedbackSkipA11y}),jsxRuntime.jsxs(reactNative.View,{style:o.sheet,accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[jsxRuntime.jsx(reactNative.View,{style:o.handle}),jsxRuntime.jsxs(reactNative.View,{style:o.header,children:[jsxRuntime.jsx(reactNative.View,{style:o.iconBadge,children:jsxRuntime.jsx(An,{size:jC,color:n.color.brandInk,active:false,rotate:"180deg"})}),jsxRuntime.jsxs(reactNative.View,{style:o.headerText,children:[jsxRuntime.jsx(E,{tier:"heading",style:o.title,accessibilityRole:"header",children:g.feedbackTitle}),jsxRuntime.jsx(E,{style:o.subtitle,children:g.feedbackSubtitle})]})]}),jsxRuntime.jsx(reactNative.View,{style:o.options,children:Ti.map(S=>{let P=s===S.key;return jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:S.label,accessibilityState:{selected:P},style:[o.option,P?o.optionSelected:null],onPress:()=>a(k=>k===S.key?null:S.key),children:[jsxRuntime.jsx(E,{style:[o.optionLabel,P?o.optionLabelSelected:null],children:S.label}),jsxRuntime.jsx(reactNative.View,{style:[o.radio,P?o.radioSelected:null],children:P?jsxRuntime.jsx(pt,{size:WC,color:n.color.surface,strokeWidth:2}):null})]},S.key)})}),jsxRuntime.jsxs(reactNative.View,{style:o.inputWrap,children:[jsxRuntime.jsx(Gt,{style:o.input,placeholder:g.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:g.feedbackNotesPlaceholder,value:l,onChangeText:u,multiline:true,editable:!d}),l.length>0?jsxRuntime.jsx(E,{tier:"compact",style:[o.counter,b?o.counterOver:null],children:`${[...l].length}/${Bt}`}):null]}),p?jsxRuntime.jsx(E,{style:o.failed,accessibilityRole:"alert",children:g.feedbackFailed}):null,jsxRuntime.jsxs(reactNative.View,{style:o.actions,children:[jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:g.feedbackSubmit,accessibilityState:{busy:d,disabled:d||b},disabled:d||b,style:[o.submit,d||b?o.submitDisabled:null],onPress:()=>{T();},children:jsxRuntime.jsx(E,{tier:"control",style:o.submitLabel,children:g.feedbackSubmit})}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:g.feedbackSkipA11y,hitSlop:8,onPress:h,style:o.skip,children:jsxRuntime.jsx(E,{tier:"control",style:o.skipLabel,children:g.feedbackSkip})})]})]})]})})}i(Ep,"FeedbackReasons");function GC(e){let t=e.color,r=e.type,n=e.radius,o=e.slots;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...Pe,backgroundColor:HC},sheet:{backgroundColor:t.surface,borderTopLeftRadius:bp,borderTopRightRadius:bp,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14},handle:{alignSelf:"center",width:zC,height:vp,borderRadius:vp/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:ps,height:ps,borderRadius:ps/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...R(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight},subtitle:{...R(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,backgroundColor:t.surface},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...R(e,"medium"),fontSize:r.size.body,color:t.text.primary},optionLabelSelected:{color:t.brandInk},radio:{width:cs,height:cs,borderRadius:cs/2,borderWidth:2,borderColor:t.brandBorderStrong,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...R(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top"},counter:{...R(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...R(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},actions:{gap:10,alignItems:"center"},submit:{alignSelf:"stretch",minHeight:hp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...me(o.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...R(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...ke(o.primaryButton)},skip:{minHeight:hp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...R(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}i(GC,"makeStyles");var oR=.88,iR=420,sR=58,aR="rgba(17,17,17,0.28)",lR=.15,uR=14,dR=12,fs=44,cR=16,pR=14,fR=12,mR=14,ms=8,mt=2,yR=.5,gR=Tr($t.standard);function hR(e){return Math.min(Math.round(e*oR),iR)}i(hR,"drawerPanelWidth");function Rp({chat:e,history:t}){let[r,n]=react.useState(t.open),o=react.useCallback(()=>n(false),[]);return t.open&&!r&&n(true),r?jsxRuntime.jsx(bR,{chat:e,history:t,onHidden:o}):null}i(Rp,"HistoryDrawer");function bR({chat:e,history:t,onHidden:r}){let n=N(),o=react.useMemo(()=>ER(n),[n]),s=te(),a=reactNativeSafeAreaContext.useSafeAreaInsets(),{width:l}=reactNative.useWindowDimensions(),u=hR(l),d=t.open,c=react.useRef(null);c.current===null&&(c.current=new reactNative.Animated.Value(s.drawerMs<=0&&d?1:0));let p=c.current;react.useEffect(()=>{if(!d&&s.drawerMs<=0){r();return}let P=reactNative.Animated.timing(p,{toValue:d?1:0,duration:s.drawerMs,easing:gR,useNativeDriver:true});return P.start(({finished:k})=>{k&&!d&&r();}),()=>P.stop()},[d,p,s.drawerMs,r]);let f=p.interpolate({inputRange:[0,1],outputRange:[-u,0]}),m=t.filtered,h=t.rows.length===0,T=t.cursor===null&&!t.loading&&t.error===null,b=h&&t.loading?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,accessibilityLabel:q.loading,accessibilityState:{busy:true},children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{color:o.emptyTitle.color}),jsxRuntime.jsx(E,{style:o.emptyBody,children:q.loading})]}):h&&t.error!==null?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(E,{style:o.emptyTitle,accessibilityRole:"alert",children:q.loadFailed}),jsxRuntime.jsx(E,{style:o.emptyBody,children:t.error}),jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:q.retryA11y,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load();},children:jsxRuntime.jsx(E,{tier:"control",style:o.retryText,children:q.retry})})]}):t.emptyKind==="empty"?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(E,{style:o.emptyTitle,children:q.empty}),jsxRuntime.jsx(E,{style:o.emptyBody,children:q.emptyBody})]}):jsxRuntime.jsx(E,{style:o.noMatch,children:q.noMatch}),S=!t.searching&&t.loadingMore?jsxRuntime.jsx(reactNative.View,{style:o.loadMoreFooter,children:jsxRuntime.jsx(E,{style:o.loadMoreLabel,children:q.loadingMore})}):null;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:"none",onRequestClose:t.close,children:jsxRuntime.jsxs(reactNative.View,{style:o.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:Pe,onPress:t.close,accessibilityRole:"button",accessibilityLabel:q.closeA11y,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[o.backdrop,{opacity:p}]})}),jsxRuntime.jsx(reactNative.Animated.View,{style:[o.panel,{width:u,paddingTop:Math.max(sR,a.top+n.space.md),transform:[{translateX:f}]}],accessibilityViewIsModal:true,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:o.keyboardAvoider,behavior:reactNative.Platform.OS==="ios"?"padding":"height",children:[jsxRuntime.jsxs(reactNative.View,{style:o.header,children:[jsxRuntime.jsx(E,{tier:"heading",style:o.heading,accessibilityRole:"header",children:q.heading}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:q.newChat,style:o.newChat,onPress:t.newConversation,children:jsxRuntime.jsx(E,{tier:"control",style:o.newChatLabel,children:q.newChat})}),jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:q.close,hitSlop:0,style:o.closeButton,onPress:t.close,children:jsxRuntime.jsx(Qe,{size:cR,color:n.color.text.muted,strokeWidth:1.75})})]}),jsxRuntime.jsxs(reactNative.View,{style:o.searchPill,children:[jsxRuntime.jsx(ec,{size:mR,color:n.color.text.muted,strokeWidth:1.5}),jsxRuntime.jsx(Gt,{value:t.query,onChangeText:P=>t.setQuery(P.replace(/^\s+/,"")),style:o.searchInput,placeholder:q.searchPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:q.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),jsxRuntime.jsx(E,{tier:"compact",style:o.countLabel,children:Ad(t.rows.length,T)}),t.error!==null&&!h?jsxRuntime.jsx(reactNative.View,{style:o.errorCard,children:jsxRuntime.jsx(E,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,jsxRuntime.jsx(reactNative.FlatList,{data:m,keyExtractor:P=>P.id,renderItem:({item:P})=>jsxRuntime.jsx(vR,{row:P,active:P.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(P.id);}}),contentContainerStyle:m.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:b,ListFooterComponent:S,onEndReached:t.loadMore,onEndReachedThreshold:yR})]})})]})})}i(bR,"DrawerModal");function vR({row:e,active:t,disabled:r,styles:n,onPress:o}){let s=e.unreadCount!==null&&e.unreadCount>0,a=Id(e);return jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:Od(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:o,children:[jsxRuntime.jsxs(reactNative.View,{style:n.itemRow,children:[jsxRuntime.jsx(E,{tier:"control",style:n.itemTitle,numberOfLines:1,children:xn(e.title)}),s?jsxRuntime.jsx(reactNative.View,{style:n.unreadDot}):null]}),a!==null?jsxRuntime.jsx(E,{tier:"compact",style:n.itemMeta,numberOfLines:1,children:a}):null]})}i(vR,"Row");function ER(e){let t=e.color,r=e.space,n=e.type,o=e.slots,s=t.text.primary;return reactNative.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:aR},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.surface,paddingHorizontal:r.lg,borderRightWidth:reactNative.StyleSheet.hairlineWidth,borderRightColor:t.borderRingCream,gap:r.md},keyboardAvoider:{flex:1,gap:r.md},header:{flexDirection:"row",alignItems:"center",gap:r.sm},heading:{...R(e,"bold"),flex:1,fontSize:n.size.subtitle,color:s},newChat:{minHeight:fs,justifyContent:"center",paddingHorizontal:r.xs},newChatLabel:{...R(e,"bold"),fontSize:uR,color:t.brandInk},closeButton:{width:fs,height:fs,alignItems:"center",justifyContent:"center"},searchPill:{flexDirection:"row",alignItems:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,paddingHorizontal:r.md+mt,paddingVertical:r.sm+mt,borderWidth:1,borderColor:t.borderRingCream},searchInput:{...R(e,"regular"),flex:1,fontSize:n.size.bodyTight,color:t.text.primary,padding:0},countLabel:{...R(e,"mono"),fontSize:dR,color:t.text.muted},list:{gap:r.xs,paddingBottom:r.xl},listEmpty:{flexGrow:1},item:{paddingVertical:r.sm+mt,paddingHorizontal:r.sm,borderRadius:e.radius.md,gap:mt},itemActive:{backgroundColor:ut(t.scanButtonPink,lR)??t.surfaceSubtle},itemRow:{flexDirection:"row",alignItems:"center",gap:r.sm},itemTitle:{...R(e,"bold"),flex:1,fontSize:n.size.bodyTight,color:s},itemMeta:{...R(e,"regular"),fontSize:n.size.caption,color:t.text.muted},unreadDot:{width:ms,height:ms,borderRadius:ms/2,backgroundColor:t.danger},errorCard:{borderRadius:fR,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.danger,backgroundColor:t.surface,padding:r.md},errorText:{...R(e,"regular"),fontSize:n.size.caption,color:t.danger},emptyCard:{borderRadius:pR,padding:r.md+mt,gap:r.xs+mt,backgroundColor:t.surfaceSubtle,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.borderRingCream},emptyTitle:{...R(e,"bold"),fontSize:n.size.bodyTight,color:s},emptyBody:{...R(e,"regular"),fontSize:n.size.caption,color:t.text.secondary},noMatch:{...R(e,"regular"),fontSize:n.size.bodyTight,color:t.text.muted,paddingVertical:r.sm},retrySlot:{marginTop:r.sm,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:r.md+mt,paddingVertical:r.sm,borderWidth:1,borderColor:t.brandInk,...me(o.primaryButton)},retryText:{...R(e,"bold"),fontSize:n.size.caption,color:t.brandInk,...ke(o.primaryButton)},loadMoreFooter:{paddingVertical:r.md+mt,alignItems:"center"},loadMoreLabel:{...R(e,"regular"),fontSize:n.size.caption,color:t.text.muted}})}i(ER,"makeStyles");var kR=Object.freeze({}),xR=100,_R=20;function wR(e,t,r,n){return ![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}i(wR,"readWindowTops");function Sp(e,t){let r=typeof e=="number"&&Number.isFinite(e),n=react.useRef(null),[o,s]=react.useState(null),a=react.useRef(null),l=react.useRef(null),u=react.useRef(true),d=react.useCallback(()=>{l.current!==null&&clearTimeout(l.current),l.current=null;},[]);react.useEffect(()=>(u.current=true,()=>{u.current=false,d();}),[d]);let c=react.useCallback(i(function f(m){n.current?.measureInWindow((h,T)=>{let b=a.current;if(!u.current||b===null)return;let S=wR(T,b.y,b.height,reactNative.Dimensions.get("window").height);if(S!==null){s(P=>P!==null&&P.chatTop===S.chatTop&&P.parentTop===S.parentTop?P:S);return}m>=_R||(l.current=setTimeout(()=>{l.current=null,f(m+1);},xR));});},"measureAt"),[]),p=react.useCallback(f=>{let{y:m,height:h}=f.nativeEvent.layout;a.current={y:m,height:h},d(),c(0);},[c,d]);return react.useMemo(()=>{if(!t)return {avoidingProps:r?{keyboardVerticalOffset:e}:kR,probeRef:null,topInWindow:null};let f=o?.parentTop??0;return {avoidingProps:r?{keyboardVerticalOffset:e,onLayout:p}:f>0?{keyboardVerticalOffset:f,onLayout:p}:{onLayout:p},probeRef:n,topInWindow:o?.chatTop??null}},[t,r,e,o,p])}i(Sp,"useChatKeyboardOffset");function Tp({probeRef:e}){return e===null?null:jsxRuntime.jsx(reactNative.View,{ref:e,collapsable:false,pointerEvents:"none",style:IR})}i(Tp,"KeyboardOffsetProbe");var IR=Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function Pp(e,t){let r={entry:"chat",petRef:e};return t?.returnTo!==void 0&&(r.returnTo=t.returnTo),t?.usState!==void 0&&(r.usState=t.usState),t?.prefer!==void 0&&(r.prefer=t.prefer),r}i(Pp,"chatVetVisitOptions");var LR=.75,NR=1.5,DR=.4,UR=4,VR=1.5,Or=22,BR=14,HR=8,zR=20,jR=10,xp=13,WR=12,GR=15,KR=44,qR=14,$R=1.25,YR=14,XR=6;function QR(e,t){let r=e.color;return t.level==="emergency"?{card:{backgroundColor:r.badgeBgCritical,borderColor:ut(r.danger,DR)??r.danger,borderWidth:NR},label:r.danger,reason:r.text.primary,close:r.danger,action:{fill:r.surface,edge:r.danger,ink:r.danger}}:{card:{backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:LR},label:t.textColor,reason:t.reasonColor,close:t.textColor,action:null}}i(QR,"tierPaint");function _p({surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o}){let s=N(),a=react.useMemo(()=>tS(s),[s]),l=te(),u=e.tier,d=e.source;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bi,{visible:e.showBanner&&u!==null,inMs:l.bannerInMs,outMs:l.bannerOutMs,style:a.pinned,children:u!==null&&d!==null?jsxRuntime.jsx(ZR,{tier:u,reason:d.reason,surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o,styles:a}):null}),jsxRuntime.jsx(Bi,{visible:e.showCompactIcon,inMs:l.iconInMs,outMs:l.iconOutMs,style:a.indicatorRow,children:jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:g.showLatestVetAlert,hitSlop:jR,onPress:e.expand,children:jsxRuntime.jsx(Xd,{size:zR,color:s.color.text.muted,strokeWidth:2})})})]})}i(_p,"UrgencyBanner");function ZR({tier:e,reason:t,surface:r,petRef:n,renderVetAction:o,onFindVet:s,vet:a,styles:l}){let u=N(),d=QR(u,e),c=jsxRuntime.jsx(eS,{tier:e,paint:d,petRef:n,onFindVet:s,vet:a,styles:l}),p=r.showVetAction?o!==void 0?jsxRuntime.jsx(xt,{render:()=>o(e.level),fallback:c,resetKey:e.level}):c:null,f=d.action!==null?jsxRuntime.jsx(JR,{paint:d.action,styles:l}):null;return jsxRuntime.jsxs(reactNative.View,{accessibilityRole:"alert",style:[l.card,d.card],children:[jsxRuntime.jsx(E,{tier:"control",style:[l.label,{color:d.label}],children:e.label}),t!==null?jsxRuntime.jsx(E,{style:[l.reason,{color:d.reason}],children:t}):null,p!==null||f!==null?jsxRuntime.jsxs(reactNative.View,{style:l.actions,children:[p,f]}):null,r.dismissLabel!==null?jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:r.dismissLabel,hitSlop:HR,containerStyle:l.closeSlot,style:l.closeButton,onPress:r.dismiss,children:jsxRuntime.jsx(Qe,{size:BR,color:d.close,strokeWidth:1.5})}):null]})}i(ZR,"BannerCard");function JR({paint:e,styles:t}){let r=i(()=>{try{reactNative.Linking.openURL(rd).catch(()=>{});}catch{}},"call");return jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:g.poisonControlNative,hitSlop:0,style:[t.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:r,children:jsxRuntime.jsx(E,{tier:"control",style:[t.actionLabel,{color:e.ink}],children:g.poisonControlNative})})}i(JR,"PoisonControl");function eS({tier:e,paint:t,petRef:r,onFindVet:n,vet:o,styles:s}){let a=N(),l=jn(Pp(r,o)),u=l.status==="opening",d=!l.available&&n!==void 0,c=l.available?()=>{l.open();}:n!==void 0?()=>{$(n,e.level);}:null;if(c===null)return null;let p=t.action;if(p!==null){let m=d?g.nearestEmergencyVet:g.findVet,h=Vn(a.slots.vetVisitButton)?.textColor??p.ink;return jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:d?g.nearestEmergencyVet:g.findVetA11y,accessibilityState:{busy:u},hitSlop:0,style:[s.action,{backgroundColor:p.fill,borderColor:p.edge},s.findVetSlotBox,u?s.findVetBusy:null],onPress:c,children:[jsxRuntime.jsx(Ni,{size:xp,color:h,strokeWidth:1.5}),jsxRuntime.jsx(E,{tier:"control",style:[s.actionLabel,{color:h}],children:m})]})}let f=Vn(a.slots.vetVisitButton)?.textColor??e.textColor;return jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:g.findVetA11y,accessibilityState:{busy:u},style:[s.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},s.findVetSlotBox,u?s.findVetBusy:null],onPress:c,children:[jsxRuntime.jsx(Ni,{size:xp,color:f,strokeWidth:1.5}),jsxRuntime.jsx(E,{tier:"control",style:[s.findVetLabel,{color:f}],children:g.findVet})]})}i(eS,"VetAction");function tS(e){let t=Vn(e.slots.vetVisitButton),r=e.space,n=e.type;return reactNative.StyleSheet.create({pinned:{marginTop:0,marginBottom:r.xs,paddingHorizontal:r.lg},card:{borderRadius:e.radius.lg,paddingHorizontal:r.lg+UR,paddingVertical:r.lg,gap:r.sm},label:{...R(e,"bold"),fontSize:n.size.body,paddingRight:Or},reason:{...R(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*VR),paddingRight:Or},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm},action:{flexDirection:"row",alignItems:"center",gap:XR,minHeight:KR,paddingHorizontal:qR,borderRadius:e.radius.pill,borderWidth:$R},actionLabel:{...R(e,"bold"),fontSize:YR},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...me(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...R(e,"monoBold"),fontSize:WR,lineHeight:GR},closeSlot:{position:"absolute",top:r.md,right:r.md},closeButton:{width:Or,height:Or,borderRadius:Or/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:r.lg,paddingTop:2,paddingBottom:r.xs}})}i(tS,"makeStyles");function wp(){let e=Un(),{handle:t}=ee(),r=react.useCallback(n=>t.setActivePet(n),[t]);return react.useMemo(()=>({...e,setActivePet:r}),[e,r])}i(wp,"useChatPets");function sS(){try{let e=reactNative.AccessibilityInfo?.announceForAccessibility;typeof e=="function"&&e.call(reactNative.AccessibilityInfo,g.answered);}catch{}}i(sS,"announceAnswered");function Op(e){let t=react.useRef(false),r=react.useRef({send:e.send,id:e.conversationId});react.useEffect(()=>{let n=r.current;if((n.send!==e.send||n.id!==null&&n.id!==e.conversationId)&&(t.current=false),r.current={send:e.send,id:e.conversationId},t.current&&!e.isStreaming){let o=e.messages[e.messages.length-1];o!==void 0&&o.role==="assistant"&&sS();}t.current=e.isStreaming;},[e.isStreaming,e.messages,e.send,e.conversationId]);}i(Op,"useSettleAnnouncement");var Bp=300,Hp=3e3,Mp=120,Lr=44,lS=120,uS="88%",Lp=520,Qn=2,Zn=.5,dS=1.5,cS=1.6,pS=.6,fS=56,Np=1.5,mS=5,yS=5,Dp=36,gS=20,hS=14,Mr=Lr,Jn=4,zp=24,jp=22,bS=.4,Up=Lr,Wp=20,vS=.4,ES=480,CS=12,RS=.72,SS=48,Vp=1,TS=12,PS=18,kS="12%";function ge(){let e=N(),t=react.useMemo(()=>xS(e),[e]);return {theme:e,styles:t}}i(ge,"useChatTheme");function xS(e){let t=e.color,r=e.space,n=e.radius,o=e.type,s=Math.round(o.size.body*dS),a=Math.round(o.size.body*cS),l=Math.round(gS*o.size.body/hS),u=t.borderRingCream,d=e.slots;return reactNative.StyleSheet.create({container:{flex:1,minHeight:Mp,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:Mp,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},emptyContent:{flexGrow:1,alignItems:"stretch",justifyContent:"flex-start",paddingTop:kS,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:ES,gap:r.lg},errorText:{...R(e,"regular"),fontSize:o.size.subtitle,lineHeight:o.size.subtitle*o.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:Lr,minWidth:Lr,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...me(d.primaryButton)},retryLabel:{...R(e,"medium"),color:t.onPrimary,fontSize:o.size.body,...ke(d.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...R(e,"regular"),color:t.danger,fontSize:o.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.lg,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...R(e,"bold"),color:t.text.primary,fontSize:o.size.body},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...R(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal},turnNoticeAction:{minHeight:Lr,justifyContent:"center"},turnNoticeActionLabel:{...R(e,"medium"),color:t.brandInk,fontSize:o.size.body},setupNoticeAction:{...R(e,"medium"),color:t.brandInk,fontSize:o.size.caption},reconnectingCaption:{...R(e,"medium"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},readingLine:{...R(e,"regular"),color:t.text.muted,fontSize:o.size.bodyTight,lineHeight:Math.round(o.size.bodyTight*o.lineHeight.relaxed)},list:{flex:1},listContent:{padding:r.lg,gap:r.xl},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:uS,alignItems:"flex-start"},bubbleSideUser:{alignItems:"flex-end"},bubbleUser:{maxWidth:Lp,paddingVertical:r.md,paddingHorizontal:r.lg+Qn,backgroundColor:t.bubbleUser,borderRadius:n.lg,borderBottomRightRadius:n.xs,...me(d.userBubble,Zn)},bubbleAssistant:d.assistantBubble?.backgroundColor===void 0?{...me(d.assistantBubble,Zn)}:{paddingVertical:r.md,paddingHorizontal:r.lg+Qn,borderRadius:n.lg,...me(d.assistantBubble,Zn)},bubbleVet:{maxWidth:Lp,paddingVertical:r.md,paddingHorizontal:r.lg+Qn,backgroundColor:t.bubbleVet,borderRadius:n.lg,borderTopLeftRadius:n.xs,...me(d.vetBubble,Zn)},bubblePending:{opacity:pS},bubbleTextUser:{...R(e,"regular"),color:t.onPrimary,fontSize:o.size.body,lineHeight:s,...ke(d.userBubble)},bubbleTextAssistant:{...R(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:a,...ke(d.assistantBubble)},bubbleTextVet:{...R(e,"regular"),color:t.onBubbleVet,fontSize:o.size.body,lineHeight:s,...ke(d.vetBubble)},assistantName:{...R(e,"bold"),color:t.brandInk,fontSize:o.size.bodyTight,marginBottom:r.xs},vetHeader:{flexDirection:"row",alignItems:"baseline",gap:r.sm,marginBottom:r.xs},vetSender:{...R(e,"bold"),color:t.text.primary,fontSize:o.size.bodyTight},vetTime:{...R(e,"regular"),color:t.text.muted,fontSize:o.size.caption},bubbleBold:R(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:R(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.md},followUpsHeading:{...R(e,"monoBold"),color:t.text.muted,fontSize:CS,textTransform:"uppercase",letterSpacing:RS,paddingBottom:r.sm,borderBottomWidth:Vp,borderBottomColor:u},followUpSlot:{alignSelf:"stretch"},followUpSlotRuled:{borderTopWidth:Vp,borderTopColor:u},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,minHeight:SS,paddingVertical:r.sm+Qn},followUpText:{...R(e,"bold"),flex:1,color:t.brandInk,fontSize:o.size.bodyTight},composerOuter:{position:"relative"},composer:{marginHorizontal:r.md,marginTop:r.xs,minHeight:fS,justifyContent:"center",paddingLeft:r.sm,paddingRight:mS,paddingVertical:yS,backgroundColor:t.composerFill,borderWidth:Np,borderColor:t.composerBorder,borderRadius:n.pill,...me(d.composerInput,Np)},composerRow:{flexDirection:"row",alignItems:"center",gap:r.xs,minHeight:Dp},attachControl:{width:Up,height:Up,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:vS},input:{flex:1,minHeight:Dp,maxHeight:lS,paddingHorizontal:0,paddingVertical:0,...R(e,"regular"),fontSize:o.size.body,lineHeight:l,color:t.text.primary,...ke(d.composerInput)},sendControl:{minHeight:Mr,minWidth:Mr,alignItems:"center",justifyContent:"center"},sendDisc:{width:Mr,height:Mr,borderRadius:Mr/2,alignItems:"center",justifyContent:"center",...me(d.sendButton)},sendControlDisabled:{opacity:bS},footnote:{...R(e,"regular"),color:t.text.muted,fontSize:TS,lineHeight:PS,textAlign:"center",marginTop:r.sm,marginBottom:r.xs,paddingHorizontal:r.lg},poweredBy:{...R(e,"regular"),color:t.text.muted,fontSize:o.size.micro,textAlign:"center",paddingBottom:r.xs}})}i(xS,"makeStyles");var _S=Object.freeze({kind:"live"}),wS=Object.freeze({kind:"folded"});function gs(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=Io(e.proactiveOriginRef);return {caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}i(gs,"askOf");function Kp(e){let t=new Map,r=new Map;for(let o of e){let s=gs(o);if(s===null)continue;let a=r.get(s.caseId);(a===void 0||s.dueDay>=a.dueDay)&&r.set(s.caseId,{messageId:o.id,dueDay:s.dueDay});}if(r.size===0)return t;let n=null;for(let o of e){let s=gs(o);if(s===null){n=null;continue}if(r.get(s.caseId)?.messageId===o.id){t.set(o.id,_S),n=null;continue}if(n!==null&&n.caseId===s.caseId){n.days.push(s.dueDay),t.set(o.id,wS);continue}let a=[s.dueDay];n={id:o.id,caseId:s.caseId,days:a},t.set(o.id,{kind:"past",runDueDays:a});}return t}i(Kp,"placeCheckins");var Gp=864e5,IS=365;function eo(e,t){if(typeof e!="string"||typeof t!="string")return null;let r=Date.parse(e),n=Date.parse(t);if(Number.isNaN(r)||Number.isNaN(n))return null;let o=Math.floor(n/Gp)-Math.floor(r/Gp);return o<1||o>IS?null:o}i(eo,"checkinDayNumber");function qp(e){return gs(e)?.dueDay||null}i(qp,"checkinDueDay");function to(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}i(to,"formatMessageTime");var xe=Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" \xB7 ",answers:Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),$p=Object.freeze(en.map(e=>Object.freeze({answer:e,label:xe.answers[e]})));function Yp(e,t){let[r,n]=react.useState(null),[o,s]=react.useState(null),[a,l]=react.useState(null),u=react.useCallback(c=>{t!==null&&(n(c),s(null),t(e.caseId,c).then(p=>{n(null),p.ok?l(c):s(p.error);}));},[t,e.caseId]),d=a??e.answer;return {answer:d,answerable:!Ua(e),escalated:d==="worse",pending:r,error:o,choose:u}}i(Yp,"useCheckinCard");var Zp=44,FS=.6;function ef({message:e,checkin:t,onAnswer:r,petRef:n,onFindVet:o,vet:s,onLayout:a}){let l=N(),u=react.useMemo(()=>MS(l),[l]),d=Yp(t,r),c=d.answer!==null||d.pending!==null,p=r!==null&&d.answerable,f=eo(t.openedAt,qp(e));return jsxRuntime.jsxs(reactNative.View,{style:u.card,accessibilityLabel:xe.eyebrow,onLayout:a,children:[jsxRuntime.jsxs(reactNative.View,{style:u.head,children:[jsxRuntime.jsx(E,{tier:"compact",style:u.eyebrow,children:xe.eyebrow}),f!==null?jsxRuntime.jsx(E,{tier:"compact",style:u.headDay,children:K(xe.day,{day:f})}):null]}),jsxRuntime.jsx(E,{style:u.question,accessibilityRole:"text",children:e.text}),p?jsxRuntime.jsx(reactNative.View,{style:[u.row,d.pending?u.rowPending:null],children:$p.map(({answer:m,label:h})=>{let T=(d.pending??d.answer)===m;return jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>d.choose(m),disabled:c,accessibilityRole:"button",accessibilityLabel:h,accessibilityState:{selected:T,disabled:c,busy:d.pending===m},style:[u.pill,T?u.pillSelected:null],children:jsxRuntime.jsx(E,{tier:"control",style:[u.pillLabel,T?u.pillLabelSelected:null],children:h})},m)})}):null,d.answer!==null?jsxRuntime.jsx(E,{style:u.logged,children:xe.logged}):null,d.escalated?o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:xe.findVet,style:u.findVet,children:jsxRuntime.jsx(E,{tier:"control",style:u.findVetLabel,children:xe.findVet})}):n?jsxRuntime.jsx(Zt,{entry:"chat",petRef:n,label:xe.findVet,...s?.returnTo!==void 0?{returnTo:s.returnTo}:{},...s?.usState!==void 0?{usState:s.usState}:{},...s?.prefer!==void 0?{prefer:s.prefer}:{},style:u.findVet,labelStyle:u.findVetLabel}):null:null,t.resolutionText?jsxRuntime.jsx(E,{style:u.resolution,children:t.resolutionText}):null,d.error?jsxRuntime.jsx(E,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}i(ef,"CheckinCard");function MS(e){let t=e.color,r=e.space,n=e.radius,o=e.type;return reactNative.StyleSheet.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...R(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},headDay:{...R(e,"bold"),color:t.text.primary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},question:{...R(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:FS},pill:{flex:1,minHeight:Zp,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brandInk},pillLabel:{...R(e,"regular"),color:t.text.primary,fontSize:o.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...R(e,"regular"),color:t.text.secondary,fontSize:o.size.caption},resolution:{...R(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},error:{...R(e,"regular"),color:t.danger,fontSize:o.size.caption},findVet:{alignSelf:"stretch",minHeight:Zp,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.brandBorder,backgroundColor:t.surface},findVetLabel:{...R(e,"bold"),color:t.brandInk,fontSize:o.size.body}})}i(MS,"makeStyles");var DS=1.5,US=3;function rf({text:e,runDueDays:t,openedAt:r,onLayout:n}){let o=N(),s=react.useMemo(()=>VS(o),[o]),a=t.map(u=>eo(r,u)).filter(u=>u!==null),l=t.length>1;return l&&a.length===0?null:jsxRuntime.jsxs(reactNative.View,{style:s.row,onLayout:n,children:[jsxRuntime.jsx(reactNative.View,{style:s.rule,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}),jsxRuntime.jsxs(reactNative.View,{style:s.body,children:[a.length>0?jsxRuntime.jsx(E,{tier:"compact",style:s.days,children:a.map(u=>K(xe.day,{day:u})).join(xe.daySeparator)}):null,l?null:jsxRuntime.jsx(E,{style:s.question,accessibilityRole:"text",children:e})]})]})}i(rf,"CheckinPastAsk");function VS(e){let t=e.color,r=e.space,n=e.type;return reactNative.StyleSheet.create({row:{flexDirection:"row",paddingVertical:r.xs},rule:{width:DS,borderRadius:1,backgroundColor:t.borderHairlineGreen,marginRight:r.md},body:{flex:1,gap:US},days:{...R(e,"monoMedium"),fontSize:n.size.nano,letterSpacing:n.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},question:{...R(e,"regular"),fontSize:n.size.bodyTight,lineHeight:n.size.bodyTight*n.lineHeight.normal,color:t.text.muted}})}i(VS,"makeStyles");var BS=Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),nf="#C8BEB4";function HS(e){return e?BS[e.toUpperCase()]??nf:nf}i(HS,"tierColor");function zS(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}i(zS,"tierLabel");function We(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(We,"text");function jS(e){let t=We(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}i(jS,"httpsUrl");function WS(e,t){let r=We(e.source_name)??We(e.sourceName),n=We(e.section),o=We(e.authority_tier)??We(e.authorityTier),s=zS(o),a=r??We(e.title)??`Source ${t+1}`,l=We(e.monograph_chunk_id)??We(e.chunkId),u=[n,s].filter(d=>d!==null).join(" \xB7 ");return Object.freeze({title:a,sourceName:r,section:n,authorityTier:o,tierLabel:s,meta:u.length===0?null:u,url:jS(e.url),excerpt:We(e.excerpt),tierColor:HS(o),key:`${a}-${l??"none"}-${t}`})}i(WS,"toCitationCard");function of(e){return e===void 0||e.length===0?GS:Object.freeze(e.map((t,r)=>WS(t,r)))}i(of,"toCitationCards");var GS=Object.freeze([]);function Cs(e){return e===1?`1 ${g.sourceSingular}`:`${e} ${g.sourcePlural}`}i(Cs,"sourcesLabel");function sf(e,t){return `${t?g.hideSources:g.showSources} ${Cs(e)}`}i(sf,"sourcesToggleLabel");function af(e){return [e.url!==null?`${g.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(t=>t!==null&&t.length>0).join(". ")}i(af,"citationA11yLabel");var XS=244,uf=8,df=13,QS=14,ZS=.3,JS=-0.24,eT=22,tT=10,rT=15;function cf({citations:e,onOpenUrl:t}){let r=N(),n=react.useMemo(()=>iT(r),[r]),o=react.useMemo(()=>of(e),[e]),[s,a]=react.useState(false);if(o.length===0)return null;let l=o.length;return jsxRuntime.jsxs(reactNative.View,{style:n.block,children:[jsxRuntime.jsxs(z,{accessibilityRole:"button",accessibilityLabel:sf(l,s),accessibilityState:{expanded:s},containerStyle:n.toggleSlot,style:n.togglePill,onPress:()=>a(u=>!u),children:[jsxRuntime.jsx(qd,{size:df,color:r.color.brandInk,strokeWidth:1.5}),jsxRuntime.jsx(E,{tier:"compact",style:n.toggleLabel,children:Cs(l)}),jsxRuntime.jsx(Kd,{size:df,color:r.color.brandInk,strokeWidth:1.5,direction:s?"up":"down"})]}),s?jsxRuntime.jsx(nT,{cards:o,styles:n,open:t}):null]})}i(cf,"CitationCards");function nT({cards:e,styles:t,open:r}){let n=te(),o=Yt(n.citationsInMs,{risePx:n.citationsRisePx});return jsxRuntime.jsx(reactNative.Animated.View,{style:o,children:jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(s=>jsxRuntime.jsx(oT,{card:s,styles:t,open:r},s.key))})})}i(nT,"Deck");function oT({card:e,styles:t,open:r}){let n=N(),o=e.url!==null&&r!==void 0,s=af(o?e:{...e,url:null}),a=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:t.cardHeader,children:[jsxRuntime.jsx(reactNative.View,{style:[t.tierDot,{backgroundColor:e.tierColor}]}),jsxRuntime.jsx(E,{style:[t.cardTitle,o?t.cardTitleLink:null],numberOfLines:2,children:e.title}),o?jsxRuntime.jsx($d,{size:QS,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?jsxRuntime.jsx(E,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?jsxRuntime.jsx(E,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let l=e.url;return jsxRuntime.jsx(z,{accessibilityRole:"link",accessibilityLabel:s,style:t.card,onPress:()=>r(l),children:a})}return jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:s,style:t.card,children:a})}i(oT,"Card");function iT(e){let t=e.color,r=e.space,n=e.radius,o=e.type.size;return reactNative.StyleSheet.create({block:{gap:r.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:n.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:r.xs+2,paddingHorizontal:r.md,paddingVertical:r.xs+2,borderRadius:n.pill,backgroundColor:t.brandSoft},toggleLabel:{...R(e,"monoBold"),fontSize:o.micro,lineHeight:o.micro,letterSpacing:ZS,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:XS,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:uf,height:uf,borderRadius:n.pill},cardTitle:{...R(e,"bold"),flex:1,fontSize:o.bodyTight,lineHeight:eT,color:t.text.primary,letterSpacing:JS},cardTitleLink:{color:t.linkInk},cardMeta:{...R(e,"monoMedium"),fontSize:o.nano,lineHeight:tT,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},cardExcerpt:{...R(e,"regular"),fontSize:o.tiny,lineHeight:rT,color:t.text.muted}})}i(iT,"makeStyles");var Nr=15,cT=15,pT=6,fT=Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function gf({message:e,onCopy:t,sentiment:r=null,onSentiment:n,thanks:o=false}){let s=N(),a=react.useMemo(()=>mT(s),[s]),l=te(),u=e.role==="user",d=react.useMemo(()=>to(e.createdAt),[e.createdAt]),c=t!==void 0&&e.role!=="vet"&&e.text.length>0,p=e.role==="assistant"&&n!==void 0&&e.responseId!==void 0,[f,m]=react.useState(false),h=react.useRef(null);react.useEffect(()=>()=>{h.current&&clearTimeout(h.current);},[]);let T=i(()=>{t!==void 0&&(qt(t,e.text),m(true),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{m(false),h.current=null;},l.copiedMs));},"copy");return d===null&&!c&&!p?null:jsxRuntime.jsxs(reactNative.View,{style:a.wrap,children:[jsxRuntime.jsxs(reactNative.View,{style:[a.row,u?a.rowUser:a.rowAssistant],children:[d!==null?jsxRuntime.jsx(E,{tier:"compact",style:a.timestamp,children:d}):null,c?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:f?g.copied:u?g.copyUserMessage:g.copyAssistantMessage,hitSlop:cT,onPress:T,style:a.iconHit,children:f?jsxRuntime.jsx(pt,{size:Nr,color:s.color.success,strokeWidth:2}):jsxRuntime.jsx(Yd,{size:Nr,color:s.color.text.timestamp,strokeWidth:1.5})}):null,p?nd.map(({sentiment:b,label:S})=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:S,accessibilityState:{selected:r===b},hitSlop:pT,onPress:()=>n?.(b),style:a.iconHit,children:jsxRuntime.jsx(An,{size:Nr,color:s.color.sentiment[b],active:r===b,rotate:fT[b],strokeWidth:1.5})},b)):null]}),o?jsxRuntime.jsx(E,{style:a.thanks,accessibilityLiveRegion:"polite",children:g.feedbackThanks}):null]})}i(gf,"MessageFooter");function mT(e){let t=e.type;return reactNative.StyleSheet.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...R(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:Nr,height:Nr,alignItems:"center",justifyContent:"center"},thanks:{...R(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary}})}i(mT,"makeStyles");var hf="#10462E";var bf="#000000",yT="#83E0B4",gT=Object.freeze([Object.freeze({id:"breed-health-miss",intent:"send",label:"What {breed} health issue do owners miss most?",fallbackLabel:"What {species} health issue do owners miss most?",background:"#A0C4F6",borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"attention-at-age",intent:"send",label:"What changes should I expect at {ageYears} years old?",fallbackLabel:"What changes should I expect as my {species} ages?",background:yT,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:hf,brandEdge:true,borderWidth:1}),Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}\u2019s vet visit",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]),hT=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function bT(e){return e==null?e:e.replace(hT,"").trim()}i(bT,"formatBreedForPrompt");var vT=new Set(["","?","-","--",".","n/a","na","none","null","nil","unknown","unspecified","unsure","not sure","not specified","not applicable","no idea","dunno","idk","tbd","other","i dont know","i don't know","dont know","don't know","do not know","i do not know","not known","no clue"]);function ET(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return vT.has(t)}i(ET,"isUninformativeBreed");function CT(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}i(CT,"unspecifiedBreedLabel");function RT(e,t){return ET(e)?CT(t):String(e).replace(/\s+/gu," ").trim()}i(RT,"resolveBreedLabel");function vf(e){let t=e?.name?.trim()||g.emptyTitlePetFallback;return K(g.emptyTitle,{petName:t})}i(vf,"emptyStateTitle");function Ef(e,t=hf){let r=ts(e?.species),n=r==="cat"?"my cat":"my dog",o=e?.name?.trim()||null,s=o||n,a=RT(bT(e?.breed),r)||null,l=rs(e?.ageYears),u=l===null?null:String(l);return Object.freeze(gT.map(d=>{let c=d.label.includes("{breed}"),p=d.label.includes("{ageYears}"),m=d.fallbackLabel!==void 0&&(c&&!a||p&&!u)&&d.fallbackLabel?d.fallbackLabel:d.label,h=K(m,{petName:s,breed:a??n,species:r,ageYears:u??""}),T=!o&&m.startsWith("{petName}")?h.charAt(0).toUpperCase()+h.slice(1):h;return Object.freeze({id:d.id,intent:d.intent,label:T,background:d.background,borderColor:d.brandEdge===true?t:d.borderColor,borderWidth:d.borderWidth})}))}i(Ef,"resolveQuickPrompts");var TT=44,Sf=0,PT=1,kT=.28,xT=2,_T=2,wT=1.3,IT=-0.015;function Tf({pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o}){let s=N(),a=react.useMemo(()=>OT(s),[s]),l=react.useMemo(()=>Ef(e,s.color.brandInk),[e,s.color.brandInk]),u=vf(e);return jsxRuntime.jsxs(reactNative.View,{style:a.block,children:[jsxRuntime.jsx(E,{tier:"heading",style:a.title,accessibilityRole:"header",children:u}),jsxRuntime.jsx(reactNative.View,{style:a.list,accessibilityLabel:g.suggestions,children:l.map((d,c)=>jsxRuntime.jsx(AT,{prompt:d,index:c,petRef:t,onSend:r,onVetPrep:n,vet:o,pet:e,styles:a},d.id))})]})}i(Tf,"QuickPrompts");function AT({prompt:e,index:t,pet:r,petRef:n,onSend:o,onVetPrep:s,vet:a,styles:l}){let u=te(),d=Yt(u.followUpInMs,{delayMs:Fn(u,t),risePx:u.promptRisePx}),c={backgroundColor:e.background};return e.intent==="vet_report"?s!==void 0?jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Sf,style:[l.chip,l.chipEdge,c],onPress:()=>{$(s,r);},children:jsxRuntime.jsx(E,{tier:"compact",style:l.chipLabel,children:e.label})})}):n===null?null:jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(Zt,{entry:"chat",petRef:n,label:e.label,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:[l.chip,l.chipEdge,c],labelStyle:l.chipLabel})}):jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(z,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Sf,style:[l.chip,l.chipEdge,c],onPress:()=>o(e.label),children:jsxRuntime.jsx(E,{tier:"compact",style:l.chipLabel,children:e.label})})})}i(AT,"Chip");function OT(e){let t=e.color,r=e.space,n=e.type;return reactNative.StyleSheet.create({block:{gap:r.lg,alignItems:"stretch",width:"100%"},title:{...R(e,"medium"),fontSize:n.size.heading,lineHeight:Math.round(n.size.heading*n.lineHeight.snug),color:t.brandInk,letterSpacing:n.size.heading*IT,textAlign:"left"},list:{width:"100%",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",gap:r.sm+xT},chip:{borderRadius:e.radius.pill,paddingHorizontal:r.lg+_T,paddingVertical:r.sm,minHeight:TT,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipEdge:{borderWidth:PT,borderColor:ut(t.brandInk,kT)??t.borderRingCream},chipLabel:{...R(e,"bold"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*wT),color:bf,textAlign:"left"}})}i(OT,"makeStyles");var Ss=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;function Pf(e){return e.includes("*")||e.includes("`")}i(Pf,"hasInlineMarkup");function kf(e){let t=[],r=0;Ss.lastIndex=0;for(let n=Ss.exec(e);n!==null;n=Ss.exec(e)){n.index>r&&t.push({kind:"text",text:e.slice(r,n.index)});let o=n[1],s=n[2],a=n[3];o!==void 0?t.push({kind:"bold",text:o}):s!==void 0?t.push({kind:"italic",text:s}):a!==void 0&&t.push({kind:"code",text:a}),r=n.index+n[0].length;}return r<e.length&&t.push({kind:"text",text:e.slice(r)}),t}i(kf,"tokenizeInlineMarkdown");function xf(e,t){return Pf(e)?kf(e).map((r,n)=>{switch(r.kind){case "bold":return jsxRuntime.jsx(E,{style:t.bold,children:r.text},n);case "italic":return t.italic?jsxRuntime.jsx(E,{style:t.italic,children:r.text},n):r.text;case "code":return t.code?jsxRuntime.jsx(E,{style:t.code,children:r.text},n):r.text;default:return r.text}}):e}i(xf,"renderInlineMarkdown");function _f({petName:e=null}){let{styles:t}=ge(),r=Tn(g.reading,e);return jsxRuntime.jsx(E,{tier:"compact",style:t.readingLine,accessibilityRole:"text",accessibilityLabel:r,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:r})}i(_f,"TypingIndicator");function wf(e,t,r){let n=e-r,o=t!=null?Math.min(n,t):n;return Math.max(0,o)}i(wf,"resolveTurnScrollTarget");function If(e){let t=e.length-1,r=e[t];if(r===void 0||r.role!=="assistant")return null;let n=e[t-1];return {assistantIndex:t,userIndex:n!==void 0&&n.role==="user"?t-1:null}}i(If,"latestTurn");function Af(e,t,r){let n=Math.max(0,r),o=e===null?n:Math.min(Math.max(0,e),n);return o>t+1?o:null}i(Af,"nextFollowOffset");function Of(e,t){let r=react.useRef(null),n=react.useRef(true),o=react.useRef(t),s=react.useRef(0),a=react.useRef(0),l=react.useRef(0),u=react.useRef(new Map),d=If(e),c=d===null?null:e[d.assistantIndex]?.id??null,p=d===null||d.userIndex===null?null:e[d.userIndex]?.id??null,f=react.useCallback(()=>{let k=r.current;if(k===null||!n.current||a.current===0)return;let x=null;if(c!==null){let _=u.current.get(c);if(_===void 0)return;let A=p===null?null:u.current.get(p)??null;x=wf(_,A,96);}let y=Af(x,s.current,l.current-a.current);y!==null&&(s.current=y,k.scrollTo({y,animated:false}));},[c,p]);react.useEffect(()=>{t&&!o.current&&(n.current=true),o.current=t,f();},[e,t,f]);let m=react.useCallback(k=>{a.current=k.nativeEvent.layout.height,f();},[f]),h=react.useCallback((k,x)=>{l.current=x,a.current>0&&(s.current=Math.min(s.current,Math.max(0,x-a.current))),f();},[f]),T=react.useCallback(k=>{s.current=k.nativeEvent.contentOffset.y;},[]),b=react.useCallback(()=>{n.current=false;},[]),S=react.useCallback(k=>{let{contentOffset:x,contentSize:y,layoutMeasurement:_}=k.nativeEvent;s.current=x.y,n.current=y.height-x.y-_.height<=24;},[]),P=react.useCallback(k=>x=>{u.current.set(k,x.nativeEvent.layout.y),(k===c||k===p)&&f();},[c,p,f]);return {ref:r,onLayout:m,onContentSizeChange:h,onScroll:T,onScrollBeginDrag:b,onScrollEnd:S,rowLayout:P}}i(Of,"useThreadFollow");function Df(e,t,r){switch(e){case "loading":return r.renderPending?jsxRuntime.jsx(xt,{render:r.renderPending,fallback:jsxRuntime.jsx(Mf,{})}):jsxRuntime.jsx(Mf,{});case "empty":return jsxRuntime.jsx(zT,{pet:r.shownPet,petRef:t.petRef,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet});case "error":return jsxRuntime.jsx(GT,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case "populated":return jsxRuntime.jsx(KT,{messages:t.messages,prompts:Hd(t),onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,thanksFor:r.thanksFor,imagesByMessage:r.imagesByMessage,onPreview:r.onPreview,notice:r.notice,reconnecting:t.reconnecting===true,onRetry:t.retryLast,onStartNew:t.newConversation,petRef:t.petRef,onFindVet:r.onCheckinFindVet,vet:r.vet,onOpenUrl:r.onOpenUrl,petName:r.shownPet?.name??null});default:return at(e)}}i(Df,"renderView");function Mf(){let{theme:e,styles:t}=ge(),[r,n]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>n(true),Bp);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx(reactNative.View,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:g.loading,children:r?jsxRuntime.jsx(reactNative.ActivityIndicator,{color:e.color.brandInk}):null})}i(Mf,"LoadingState");function zT({pet:e,petRef:t,onSelectPrompt:r,onVetPrep:n,vet:o}){let{styles:s}=ge();return jsxRuntime.jsx(reactNative.ScrollView,{contentContainerStyle:s.emptyContent,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,accessibilityLabel:g.empty,children:jsxRuntime.jsx(Tf,{pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o})})}i(zT,"EmptyState");function jT({prompts:e,onSelectPrompt:t}){let{styles:r}=ge();return e.length===0?null:jsxRuntime.jsxs(reactNative.View,{style:r.followUps,children:[jsxRuntime.jsx(E,{tier:"compact",style:r.followUpsHeading,accessibilityRole:"header",children:g.followUpsHeadingNative}),e.map((n,o)=>jsxRuntime.jsx(WT,{prompt:n,index:o,onSelectPrompt:t},n))]})}i(jT,"FollowUps");function WT({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:o}=ge(),s=te(),a=Yt(s.followUpInMs,{delayMs:Fn(s,t)});return jsxRuntime.jsx(reactNative.Animated.View,{style:a,children:jsxRuntime.jsxs(z,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:[o.followUpSlot,t>0?o.followUpSlotRuled:null],style:o.followUpRow,children:[jsxRuntime.jsx(E,{tier:"control",style:o.followUpText,children:e}),jsxRuntime.jsx(In,{size:XT,color:n.color.text.muted,strokeWidth:1.75})]})})}i(WT,"FollowUpRow");function GT({error:e,onRetry:t,onAddPet:r}){let{styles:n}=ge(),o=pd(e)?Ed(r):void 0;return jsxRuntime.jsxs(reactNative.View,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(E,{style:n.errorText,children:e.displayMessage}),o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:g.addPet,style:n.retryButton,children:jsxRuntime.jsx(E,{tier:"control",style:n.retryLabel,children:g.addPet})}):null,e.retryable?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:g.retry,style:n.retryButton,children:jsxRuntime.jsx(E,{tier:"control",style:n.retryLabel,children:g.retry})}):null]})}i(GT,"ErrorState");function KT({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:o,onCopy:s,sentimentByMessage:a,onSentiment:l,thanksFor:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:f,onRetry:m,onStartNew:h,petRef:T,onFindVet:b,vet:S,onOpenUrl:P,petName:k}){let{styles:x}=ge(),y=te();Pr(e.length,y);let _=react.useMemo(()=>Kp(e),[e]),A=Bd(e,n),O=e[e.length-1],F=react.useMemo(()=>e.filter(I=>!(I.checkin&&_.get(I.id)?.kind==="folded")),[e,_]),C=Of(F,n),w=pc(F);return jsxRuntime.jsxs(reactNative.ScrollView,{ref:C.ref,style:x.list,contentContainerStyle:x.listContent,accessibilityLabel:g.transcript,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,onLayout:C.onLayout,onContentSizeChange:C.onContentSizeChange,onScroll:C.onScroll,scrollEventThrottle:YT,onScrollBeginDrag:C.onScrollBeginDrag,onScrollEndDrag:C.onScrollEnd,onMomentumScrollEnd:C.onScrollEnd,children:[e.map(I=>{let H=I.checkin?_.get(I.id):void 0;return H?.kind==="folded"?null:H?.kind==="past"?jsxRuntime.jsx(rf,{text:I.text,runDueDays:H.runDueDays,openedAt:I.checkin?.openedAt,onLayout:C.rowLayout(I.id)},I.id):I.checkin&&H!==void 0?jsxRuntime.jsx(ef,{message:I,checkin:I.checkin,onAnswer:o,petRef:T,onFindVet:b,vet:S,onLayout:C.rowLayout(I.id)},I.id):jsxRuntime.jsx(QT,{onLayout:C.rowLayout(I.id),message:I,revealing:n&&I===O&&I.role==="assistant",onCopy:s,sentiment:I.responseId===void 0?null:a[String(I.responseId)]??null,onSentiment:l,thanks:u!==null&&I.responseId!==void 0&&String(I.responseId)===u,images:d[I.id]??$T,onPreview:c,onOpenUrl:P,entering:w(I.id)},I.id)}),f?jsxRuntime.jsx(E,{tier:"compact",style:x.reconnectingCaption,accessibilityRole:"text",children:g.reconnecting}):null,A?jsxRuntime.jsx(_f,{petName:k}):null,p!==null?jsxRuntime.jsx(qT,{notice:p,onRetry:m,onStartNew:h}):null,jsxRuntime.jsx(jT,{prompts:t,onSelectPrompt:r})]})}i(KT,"PopulatedState");function qT({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=ge(),o=e.tone==="error";return jsxRuntime.jsxs(reactNative.View,{style:[n.turnNotice,o?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(E,{tier:"control",style:[n.turnNoticeTitle,o?n.turnNoticeTitleError:null],children:e.title}),jsxRuntime.jsx(E,{tier:"compact",style:n.turnNoticeBody,children:e.body}),jsxRuntime.jsx(reactNative.Pressable,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:Jn,style:n.turnNoticeAction,children:jsxRuntime.jsx(E,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}i(qT,"TurnNoticeCard");var $T=Object.freeze([]),YT=16,XT=18;function QT({message:e,revealing:t,onCopy:r,sentiment:n,onSentiment:o,thanks:s,images:a,onPreview:l,onOpenUrl:u,onLayout:d,entering:c}){let{theme:p,styles:f}=ge(),m=te(),h=cc(c,m),T=fc(e.text,t,m),b=e.role==="user",S=e.role==="vet",P=e.role==="assistant",k=P&&!p.meta.hidePoweredBy,x=b?g.senderUser:S?zd(e):k?g.assistantName:g.senderAssistant,y=S?to(e.createdAt):null,_=react.useCallback(O=>o(e,O),[o,e]),A=e.pending!==true;return jsxRuntime.jsxs(reactNative.View,{style:[f.rowBlock,b?f.rowBlockUser:f.rowBlockAssistant],onLayout:d,children:[jsxRuntime.jsx(reactNative.View,{style:[f.row,b?f.rowUser:f.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${x}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:jsxRuntime.jsxs(reactNative.Animated.View,{style:[f.bubble,b?f.bubbleSideUser:null,h],children:[k?jsxRuntime.jsx(E,{tier:"control",style:f.assistantName,children:g.assistantName}):null,S?jsxRuntime.jsxs(reactNative.View,{style:f.vetHeader,children:[jsxRuntime.jsx(E,{tier:"control",style:f.vetSender,children:x}),y!==null?jsxRuntime.jsx(E,{tier:"compact",style:f.vetTime,children:y}):null]}):null,jsxRuntime.jsxs(reactNative.View,{style:[b?f.bubbleUser:S?f.bubbleVet:f.bubbleAssistant,e.pending?f.bubblePending:null],children:[b&&a.length>0?jsxRuntime.jsx(Ic,{images:a,onPreview:O=>l({uri:O.uri,label:O.filename})}):null,jsxRuntime.jsx(E,{style:b?f.bubbleTextUser:S?f.bubbleTextVet:f.bubbleTextAssistant,children:P?xf(T,{bold:f.bubbleBold,italic:f.bubbleItalic,code:f.bubbleCode}):e.text})]})]})}),P&&!t?jsxRuntime.jsx(cf,{citations:e.citations,onOpenUrl:u}):null,A?jsxRuntime.jsx(gf,{message:e,onCopy:r,sentiment:n,onSentiment:e.responseId===void 0?void 0:_,thanks:s}):null]})}i(QT,"MessageRow");var rP=Object.freeze(["photo"]),nP=1;function Vf(e){let{style:t,renderPending:r}=e;return jsxRuntime.jsx(Si,{capability:"chat",style:t,...r?{renderPending:r}:{},children:jsxRuntime.jsx(oP,{...e})})}i(Vf,"EverfurChat");function oP({petRef:e,conversationId:t,style:r,renderPending:n,onCopy:o,onPetChange:s,onVetPrep:a,onFindVet:l,renderVetAction:u,attachments:d,pet:c,onAddPet:p,checkinTarget:f,initialAsk:m,composerSeed:h,lifecycle:T,draftStore:b,vetReturnTo:S,vetUsState:P,vetPrefer:k,onOpenUrl:x,keyboardVerticalOffset:y}){let{theme:_,styles:A}=ge(),O=te(),F=react.useMemo(()=>jd(e,t),[e,t]),C=Rr(F),w=Ud(C),I=wp(),H=Fd(C),Q=reactNativeSafeAreaContext.useSafeAreaInsets(),oe=Vd(C),Y=react.useMemo(()=>l===void 0?void 0:()=>{$(l,"emergency");},[l]),we=react.useMemo(()=>S===void 0&&P===void 0&&k===void 0?void 0:{returnTo:S,usState:P,prefer:k},[S,P,k]),it=ds(I.pets,C.petRef),he=react.useMemo(()=>Nd(C.messages,it?.name??null),[C.messages,it?.name]),st=Dd(he);Op(C),Pr(st.showBanner,O),Td(C.openCheckin,f),hd(C.askEverfur,C.isBootstrapping,m);let Vr=react.useMemo(()=>Ai(h),[h]);Rd(T,{conversationId:C.conversationId===null?null:String(C.conversationId),isTurnInFlight:C.isStreaming,refresh:C.refreshActiveThread});let Br=(C.hasUnreadThreads??false)||H.rows.some(Se=>Se.unreadCount!==null&&Se.unreadCount>0)||(C.unreadCount??0)>0,Lt=yd(C.messages),[Jt,io]=react.useState(null),Hf=react.useCallback(()=>io(null),[]),[er,so]=react.useState(null),[zf,xs]=react.useState(null),Nt=react.useRef(null);react.useEffect(()=>()=>{Nt.current&&clearTimeout(Nt.current);},[]);let _s=react.useCallback(Se=>{xs(String(Se)),Nt.current&&clearTimeout(Nt.current),Nt.current=setTimeout(()=>{xs(null),Nt.current=null;},Hp);},[]),jf=react.useCallback((Se,zr)=>{let tr=Se.responseId;if(tr===void 0)return;let Yf=C.sentimentByMessage[String(tr)];C.feedback(tr,zr),zr==="down"&&Yf!=="down"&&so(tr);},[C]),Wf=react.useCallback(async(Se,zr)=>er===null||!(await C.feedback(er,"down",Se??"other",zr)).ok?false:(so(null),_s(er),true),[C,er,_s]),Gf=react.useCallback(()=>so(null),[]),Kf=react.useCallback(Se=>{C.send(Se);},[C.send]),qf=react.useMemo(()=>x===void 0?void 0:Se=>{$(x,Se,"citation");},[x]),ws=reactNative.Platform.OS==="ios"?"padding":void 0,Hr=Sp(y,ws!==void 0),$f=Hr.topInWindow===null?Q.top:Math.max(0,Q.top-Hr.topInWindow),Is={send:C.send,stop:C.stop,isStreaming:C.isStreaming,conversationId:C.conversationId,seed:Vr,draftStore:b,onStage:Lt.stage,onPreview:io,petName:it?.name??null};return jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:[A.container,{paddingTop:$f},r],behavior:ws,...Hr.avoidingProps,children:[jsxRuntime.jsx(Tp,{probeRef:Hr.probeRef}),jsxRuntime.jsx(mp,{pets:I,petRef:C.petRef,historyUnread:Br,onOpenHistory:H.show,onPetChange:s,onAddPet:p,vet:we}),c!==void 0?jsxRuntime.jsx(iP,{petRef:e??null,pet:c,onRegistered:I.refresh}):null,jsxRuntime.jsx(_p,{surface:st,petRef:C.petRef,renderVetAction:u,onFindVet:l,vet:we}),jsxRuntime.jsx(reactNative.View,{style:A.body,children:Df(w,C,{notice:oe,vet:we,onCheckinFindVet:Y,onSelectPrompt:Kf,renderPending:n,shownPet:it,onVetPrep:a,onCopy:o,onSentiment:jf,thanksFor:zf,imagesByMessage:Lt.byMessage,onPreview:io,onAddPet:p,onOpenUrl:qf})}),d!==void 0?jsxRuntime.jsx(sP,{...Is,attachments:d}):jsxRuntime.jsx(Bf,{...Is,attachments:null}),jsxRuntime.jsx(E,{tier:"compact",style:A.footnote,accessibilityRole:"text",children:g.footnoteNative}),_.meta.hidePoweredBy?null:jsxRuntime.jsx(E,{tier:"compact",style:A.poweredBy,accessibilityRole:"text",accessibilityLabel:g.poweredBy,children:g.poweredBy}),jsxRuntime.jsx(Rp,{chat:C,history:H}),jsxRuntime.jsx(Ep,{visible:er!==null,onSubmit:Wf,onSkip:Gf}),jsxRuntime.jsx(mc,{uri:Jt?.uri??null,label:Jt?.label??"",onClose:Hf}),jsxRuntime.jsx(xr,{})]})}i(oP,"ChatBody");function iP({petRef:e,pet:t,onRegistered:r}){let{styles:n}=ge(),o=fd(e,t,r);return o.status!=="failed"||o.error===null?null:jsxRuntime.jsxs(reactNative.View,{style:n.setupNotice,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(E,{tier:"compact",style:n.setupNoticeText,children:o.error.displayMessage}),jsxRuntime.jsx(reactNative.Pressable,{onPress:o.retry,accessibilityRole:"button",accessibilityLabel:g.retry,hitSlop:Jn,children:jsxRuntime.jsx(E,{tier:"control",style:n.setupNoticeAction,children:g.retry})})]})}i(iP,"PetSetupNotice");function sP({attachments:e,...t}){let r=react.useMemo(()=>Oc(),[]),n=Pn({maxPerMessage:e.maxPerMessage??nP,transport:r}),o=react.useMemo(()=>({state:n,sources:e.sources??rP,pick:e.pick}),[n,e.sources,e.pick]);return jsxRuntime.jsx(Bf,{...t,attachments:o})}i(sP,"ComposerWithAttachments");function Bf({send:e,stop:t,isStreaming:r,conversationId:n,attachments:o,seed:s,draftStore:a,onStage:l,onPreview:u,petName:d}){let{theme:c,styles:p}=ge(),f=te(),[m,h]=xd(e,n,s);_d(a,n===null?null:String(n),m,h);let[T,b]=react.useState(false),[S,P]=react.useState(false);react.useEffect(()=>{P(false);},[n]);let k=c.meta.placeholder??Tn(g.placeholder,d),x=o?.state.uploading??false,y=o?.state.failed??false,_=x||y,A=o?.state.attachments??aP;Pr(A.length,f);let O=react.useCallback(()=>{if(m.trim().length===0||_||[...m].length>Ht)return;let oe=o?.state.s3Keys??lP;o!==null&&oe.length>0?(l(o.state.attachments.filter(Y=>Y.status==="uploaded").map(Y=>({uri:Y.previewUri,filename:Y.filename}))),e(m,{imageS3Keys:oe}),o.state.clear()):e(m),h(""),P(false);},[m,e,_,o,l]),F=react.useCallback(()=>{t();},[t]),C=react.useCallback(oe=>{b(false),o!==null&&(P(false),o.state.dismissRejected(),qt(o.pick,oe).then(Y=>{if(!Y.ok){P(true);return}Y.value!==null&&o.state.add(Y.value);}));},[o]),I=react.useMemo(()=>[...m].length>Ht,[m])||_,H=o!==null&&A.length>=o.state.maxPerMessage,Q=c.slots.sendButton?.textColor??c.color.brandInk;return jsxRuntime.jsxs(reactNative.View,{style:p.composerOuter,children:[o!==null&&T?jsxRuntime.jsx(hc,{sources:o.sources,full:H,onPick:C,onClose:()=>b(false)}):null,jsxRuntime.jsxs(reactNative.View,{style:p.composer,children:[o!==null?jsxRuntime.jsx(wc,{attachments:A,rejected:S?uP:o.state.rejected,uploadFailed:y,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:oe=>u({uri:oe.previewUri,label:oe.filename})}):null,jsxRuntime.jsxs(reactNative.View,{style:p.composerRow,children:[o!==null?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:H?ud(A.length,o.state.maxPerMessage):g.attachPhotoOrFileNative,accessibilityState:{disabled:H,expanded:T},disabled:H,style:[p.attachControl,H?p.attachControlDisabled:null],onPress:()=>b(oe=>!oe),children:jsxRuntime.jsx(Qd,{size:Wp,color:H?c.color.text.muted:c.color.brandInk,strokeWidth:1.75})}):null,jsxRuntime.jsx(Gt,{style:p.input,value:m,onChangeText:h,placeholder:k,placeholderTextColor:c.slots.composerInput?.textColor??c.color.text.placeholder,accessibilityLabel:g.composerLabel,onSubmitEditing:O,returnKeyType:"send",blurOnSubmit:false,multiline:true,editable:true}),r?jsxRuntime.jsx(reactNative.Pressable,{onPress:F,accessibilityRole:"button",accessibilityLabel:g.stop,style:p.sendControl,children:jsxRuntime.jsx(reactNative.View,{style:p.sendDisc,testID:"everfur-stop-disc",children:jsxRuntime.jsx(rc,{size:jp,color:Q,testID:"everfur-stop-glyph"})})}):jsxRuntime.jsx(reactNative.Pressable,{onPress:O,disabled:I,accessibilityRole:"button",accessibilityLabel:g.send,accessibilityState:{disabled:I,busy:x},style:[p.sendControl,I?p.sendControlDisabled:null],children:jsxRuntime.jsx(reactNative.View,{style:p.sendDisc,testID:"everfur-send-disc",children:jsxRuntime.jsx(tc,{size:zp,color:Q,testID:"everfur-send-glyph"})})})]})]})]})}i(Bf,"Composer");var aP=Object.freeze([]),lP=Object.freeze([]),uP=Object.freeze({code:"unknown",retryable:true,filename:""});function mP(e){let{runtime:t,userRef:r,scopeEpoch:n}=ee(),o=react.useMemo(()=>lt(t.registry.services.authFor(r)),[t,r,n]),s=react.useMemo(()=>({repository:o,petRef:e}),[o,e]),[a,l]=react.useState({key:s,profile:null,loading:e!==null,error:null}),u=a.key===s?a:{profile:null,loading:e!==null,error:null},d=react.useRef(0),c=react.useCallback(async()=>{let p=++d.current;if(s.petRef===null){l({key:s,profile:null,loading:false,error:null});return}l(m=>({key:s,profile:m.key===s?m.profile:null,loading:true,error:null}));let f=await s.repository.getPetProfile(s.petRef);p===d.current&&l(f.ok?{key:s,profile:f.value,loading:false,error:null}:{key:s,profile:null,loading:false,error:f.error});},[s]);return react.useEffect(()=>(c(),()=>{d.current+=1;}),[c]),react.useMemo(()=>({profile:u.profile,loading:u.loading,error:u.error,refresh:c}),[u.profile,u.loading,u.error,c])}i(mP,"useEverfurPetProfile");function gP(e){return react.createElement(Cn,{clientTheme:e.clientTheme??null,seams:Sn,children:e.children})}i(gP,"EverfurThemeProvider");exports.APPEARANCE_PRESETS=tu;exports.APPEARANCE_PRESET_NAMES=eu;exports.APPEARANCE_SIZE_RANGES=br;exports.CapabilityGate=Si;exports.EverfurChat=Vf;exports.EverfurConfigError=re;exports.EverfurProvider=Fb;exports.EverfurThemeProvider=gP;exports.EverfurThrownError=jr;exports.THEME_SLOT_KEYS=kg;exports.THEME_SLOT_NAMES=$e;exports.canonicalPetSpecies=pr;exports.categoryFor=lo;exports.conversationId=nm;exports.createRnRecordsUploadTransport=Cm;exports.expandAppearance=ii;exports.face=R;exports.isErr=Zf;exports.isOk=Qf;exports.isRetryableCode=uo;exports.petRef=tm;exports.previewTheme=Ih;exports.unwrap=Jf;exports.useCapability=Wt;exports.useChatAttachments=Pn;exports.useEverfur=Fu;exports.useEverfurChat=Rr;exports.useEverfurPetProfile=mP;exports.useEverfurPets=Un;exports.useEverfurTheme=N;exports.userFacingError=Dt;exports.userRef=rm;