@everfur/sdk 1.5.0 → 1.5.2

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 (87) hide show
  1. package/dist/{bookingCopy.d-BuDv16WP.d.ts → bookingCopy.d-BL2-URcv.d.ts} +3 -2
  2. package/dist/{bookingCopy.d-rnBSqOSN.d.cts → bookingCopy.d-Dfew1pjY.d.cts} +3 -2
  3. package/dist/care/index.cjs +2 -2
  4. package/dist/care/index.js +2 -2
  5. package/dist/chat/index.cjs +235 -234
  6. package/dist/chat/index.js +311 -310
  7. package/dist/chat/lite/index.cjs +339 -338
  8. package/dist/chat/lite/index.js +314 -313
  9. package/dist/{chunk-4KFFE42Z.js → chunk-2T5CB5MW.js} +20 -20
  10. package/dist/{chunk-HHCGXQJR.js → chunk-ASE36WGP.js} +11 -11
  11. package/dist/{chunk-6IHY7HS7.js → chunk-CMDCBYUH.js} +1 -1
  12. package/dist/{chunk-BMYNDBUR.js → chunk-K7YHXFPQ.js} +1 -1
  13. package/dist/client/index.cjs +1 -1
  14. package/dist/client/index.d.cts +2 -2
  15. package/dist/client/index.d.ts +2 -2
  16. package/dist/client/index.js +1 -1
  17. package/dist/core/index.cjs +31 -31
  18. package/dist/core/index.js +31 -31
  19. package/dist/health-plan/index.cjs +266 -266
  20. package/dist/health-plan/index.js +443 -443
  21. package/dist/{inbox.d-DJ9xgU1Z.d.ts → inbox.d-B2JXK0uI.d.ts} +1 -1
  22. package/dist/{inbox.d-CPcMMz-Y.d.cts → inbox.d-CwA1ogzV.d.cts} +1 -1
  23. package/dist/index.cjs +257 -256
  24. package/dist/index.js +364 -363
  25. package/dist/{models.d-BULqCO2R.d.ts → models.d-NAWqF1wC.d.ts} +4 -1
  26. package/dist/{models.d-BKmOfoqV.d.cts → models.d-wJ_Ze4p5.d.cts} +4 -1
  27. package/dist/notifications/inbox/index.cjs +28 -28
  28. package/dist/notifications/inbox/index.d.cts +5 -5
  29. package/dist/notifications/inbox/index.d.ts +5 -5
  30. package/dist/notifications/inbox/index.js +53 -53
  31. package/dist/notifications/index.cjs +1 -1
  32. package/dist/notifications/index.d.cts +3 -3
  33. package/dist/notifications/index.d.ts +3 -3
  34. package/dist/notifications/index.js +1 -1
  35. package/dist/{parse.d-Cj3fURer.d.ts → parse.d-QjB2LJCd.d.ts} +19 -10
  36. package/dist/{parse.d-cH7ZmMeo.d.cts → parse.d-_Ttu2h5g.d.cts} +19 -10
  37. package/dist/records/depth/index.cjs +80 -80
  38. package/dist/records/depth/index.js +115 -115
  39. package/dist/records/index.cjs +653 -653
  40. package/dist/records/index.js +1074 -1074
  41. package/dist/{route.d-DSYEd2MR.d.ts → route.d-DtuKY5dM.d.ts} +1 -1
  42. package/dist/{route.d-DCzQh4ix.d.cts → route.d-Nt-r-7IO.d.cts} +1 -1
  43. package/dist/server/events/index.cjs +1 -1
  44. package/dist/server/events/index.js +1 -1
  45. package/dist/server/index.cjs +1 -1
  46. package/dist/server/index.js +1 -1
  47. package/dist/shop/index.cjs +188 -188
  48. package/dist/shop/index.js +386 -386
  49. package/dist/shop/orders-v2/index.cjs +72 -72
  50. package/dist/shop/orders-v2/index.js +126 -126
  51. package/dist/tabs/index.cjs +114 -111
  52. package/dist/tabs/index.d.cts +19 -6
  53. package/dist/tabs/index.d.ts +19 -6
  54. package/dist/tabs/index.js +191 -188
  55. package/dist/televet/booking/index.cjs +214 -212
  56. package/dist/televet/booking/index.d.cts +2 -2
  57. package/dist/televet/booking/index.d.ts +2 -2
  58. package/dist/televet/booking/index.js +344 -342
  59. package/dist/televet/call/index.cjs +53 -53
  60. package/dist/televet/call/index.js +67 -67
  61. package/dist/{useInboxUnread.d-CXiaR3BZ.d.ts → useInboxUnread.d-0DrQPn7J.d.ts} +1 -1
  62. package/dist/{useInboxUnread.d-DERpMelw.d.cts → useInboxUnread.d-CRcOTkmu.d.cts} +1 -1
  63. package/dist/web/health-plan/index.cjs +1 -1
  64. package/dist/web/health-plan/index.js +1 -1
  65. package/dist/web/inbox/index.cjs +1 -1
  66. package/dist/web/inbox/index.d.cts +6 -6
  67. package/dist/web/inbox/index.d.ts +6 -6
  68. package/dist/web/inbox/index.js +1 -1
  69. package/dist/web/index.cjs +184 -184
  70. package/dist/web/index.js +181 -181
  71. package/dist/web/notifications/index.cjs +1 -1
  72. package/dist/web/notifications/index.d.cts +2 -2
  73. package/dist/web/notifications/index.d.ts +2 -2
  74. package/dist/web/notifications/index.js +1 -1
  75. package/dist/web/records-sheet/index.cjs +1 -1
  76. package/dist/web/records-sheet/index.js +1 -1
  77. package/dist/web/shop/index.cjs +1 -1
  78. package/dist/web/shop/index.js +2 -2
  79. package/dist/web/televet/booking/index.cjs +7 -8
  80. package/dist/web/televet/booking/index.d.cts +2 -2
  81. package/dist/web/televet/booking/index.d.ts +2 -2
  82. package/dist/web/televet/booking/index.js +7 -8
  83. package/dist/web/televet/call/index.cjs +1 -1
  84. package/dist/web/televet/call/index.js +1 -1
  85. package/dist/web/ui/index.cjs +1 -1
  86. package/dist/web/ui/index.js +33 -33
  87. package/package.json +1 -1
@@ -1,353 +1,354 @@
1
1
  /*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
2
- import{createContext,forwardRef as e,createElement as t,useCallback as r,useMemo as n,useRef as l,useState as i,useEffect as o,useSyncExternalStore as a,useContext as s,Component as u,Fragment as d}from"react";import{TextInput as c,StyleSheet as p,Platform as f,AppState as h,Text as g,View as b,Linking as y,KeyboardAvoidingView as m,Pressable as v,Dimensions as w,Keyboard as k,Modal as C,ScrollView as S,ActivityIndicator as x,Image as R,AccessibilityInfo as _,UIManager as T,LayoutAnimation as z,Animated as I,useWindowDimensions as P,FlatList as F}from"react-native";import{useSafeAreaInsets as L}from"react-native-safe-area-context";import{jsx as E,jsxs as O,Fragment as A}from"react/jsx-runtime";import*as j from"@everfur/sdk/texting";var D=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[D[t]]}}function headingFace(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type;if(r===null&&n===null)return face(e,t);if(r!==null)return{fontFamily:r,fontWeight:n??e.type.weight[D[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function M(e){return e<=450?"regular":e<=650?"medium":"bold"}var B={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=H.get(e);r===void 0&&(r=/* @__PURE__ */new Map,H.set(e,r));let n=r.get(t);if(n!==void 0)return n;let l=W(e,t);return r.set(t,l),l}var H=/* @__PURE__ */new WeakMap;function W(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,l=M(Number(n)),i=r.face==="mono"?face(e,B[l]):r.face==="heading"?headingFace(e,l):face(e,l),o=r.face==="heading"?e.type.headingWeight??n:n,a=i.fontWeight===void 0?i:{fontFamily:i.fontFamily,fontWeight:o},s=r.size,u={...a,fontSize:s,lineHeight:Math.round(s*r.lineHeight*100)/100};return r.letterSpacing!==0&&(u.letterSpacing=Math.round(s*r.letterSpacing*100)/100),r.uppercase&&(u.textTransform="uppercase"),/* @__PURE__ */Object.freeze(u)}var N=/* @__PURE__ */Object.freeze({display:/* @__PURE__ */Object.freeze({size:29,lineHeight:1.06,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),title:/* @__PURE__ */Object.freeze({size:23,lineHeight:1.12,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),cardTitle:/* @__PURE__ */Object.freeze({size:19,lineHeight:1.22,weight:"800",face:"sans",letterSpacing:0,uppercase:false,tier:"heading"}),rowTitle:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.4,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),body:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),message:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),bodySmall:/* @__PURE__ */Object.freeze({size:14.5,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),caption:/* @__PURE__ */Object.freeze({size:13,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),label:/* @__PURE__ */Object.freeze({size:10.5,lineHeight:1.4,weight:"400",face:"mono",letterSpacing:.05,uppercase:true,tier:"compact"}),eyebrow:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"mono",letterSpacing:.07,uppercase:true,tier:"compact"}),chip:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.3,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),tab:/* @__PURE__ */Object.freeze({size:16,lineHeight:1.5,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),button:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"control"}),badge:/* @__PURE__ */Object.freeze({size:12,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"badge"})});var U=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){U(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var $=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var V={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},q={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},G={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},K={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Y={regular:"400",medium:"500",bold:"700"},Q={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},Z=0,J="System",X="monospace",ee=["content","heading","control","compact","badge"];function te(e){let t={};for(let r of ee)t[r]=e;return t}var re=[];function ne(){return{family:J,mono:X,fontUrl:null,families:{regular:J,medium:J,bold:J,mono:X,monoMedium:X,monoBold:X},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:G,tierSizes:te(G),lineHeight:K,weight:Y,letterSpacing:Q,scale:1,maxScale:Z,scaleCaps:$,headingFamily:null,headingWeight:null,fontSources:re,roles:N,typeScale:1}}var le={},ie=/* @__PURE__ */Object.freeze({standard:/* @__PURE__ */Object.freeze([.2,0,0,1]),emphasized:/* @__PURE__ */Object.freeze([.2,.8,.2,1]),exit:/* @__PURE__ */Object.freeze([.4,0,1,1])});function cssCubicBezier(e){return`cubic-bezier(${e.join(", ")})`}var oe={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(ie.standard),emphasized:cssCubicBezier(ie.emphasized),exit:cssCubicBezier(ie.exit)},reducedMotion:false},ae={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",highlight:"#FFC3BC",onHighlight:"#000000",mark:"#07C168",controlEdge:"rgba(16,70,46,0.18)",structureEdge:"rgba(16,70,46,0.25)",primaryEdge:"#10462E",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)",info:"#10462E",badgeBgInfo:"rgba(16,70,46,0.10)",infoEdge:"rgba(16,70,46,0.25)"},se=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:ae,space:V,radius:q,type:ne(),motion:oe,slots:le}),ue={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",highlight:"#605051",onHighlight:"#F5F3F0",mark:"#07C168",controlEdge:"rgba(107,211,154,0.22)",structureEdge:"rgba(107,211,154,0.28)",primaryEdge:"#6BD39A",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)",info:"#6BD39A",badgeBgInfo:"rgba(107,211,154,0.12)",infoEdge:"rgba(107,211,154,0.28)"},de=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:ue,space:V,radius:q,type:ne(),motion:oe,slots:le});var ce=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),pe=globalThis,fe=pe[ce]??(pe[ce]=createContext(se));fe.displayName??="EverfurThemeContext";function useEverfurTheme(){return s(fe)}function he(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:e,variant:r,...n}){let l=useEverfurTheme(),i=r===void 0?void 0:l.type.roles[r],o=he(l.type,e??i?.tier??"content"),a=r===void 0?n:{...n,style:[{...textRole(l,r),color:l.color.text.primary,flexShrink:1},n.style]};return t(g,o===void 0?a:{maxFontSizeMultiplier:o,...a})}var ge=e(function(e,r){return t(c,{...e,...r===null?{}:{ref:r}})});var be=/* @__PURE__ */Object.freeze({chatAnswerStyle:"cards",chatHistoryStyle:"sheet",chatTopCard:"focus",chatFollowUpCount:3,chatFollowUpsExcludeTelevet:false,chatComposerMic:true,chatComposerUpload:true,safetyDisclaimerPlacement:"composer",healthPlanLayout:"focus_plan",recordsTopRiskLine:true,recordsClearResultsFilter:true,chatComposerStyle:"compact",chatComposerPlaceholder:"pet_name",chatHistoryBar:"scroll",chatGeneralBanner:true,chatSendButton:"always_dark",chatTextingAsk:true,serverSlots:false}),ye=/* @__PURE__ */Object.freeze({chatAnswerStyle:"chat_answer_style",chatHistoryStyle:"chat_history_style",chatTopCard:"chat_top_card",chatFollowUpCount:"chat_follow_up_count",chatFollowUpsExcludeTelevet:"chat_follow_ups_exclude_televet",chatComposerMic:"chat_composer_mic",chatComposerUpload:"chat_composer_upload",safetyDisclaimerPlacement:"safety_disclaimer_placement",healthPlanLayout:"health_plan_layout",recordsTopRiskLine:"records_top_risk_line",recordsClearResultsFilter:"records_clear_results_filter",chatComposerStyle:"chat_composer_style",chatComposerPlaceholder:"chat_composer_placeholder",chatHistoryBar:"chat_history_bar",chatGeneralBanner:"chat_general_banner",chatSendButton:"chat_send_button",chatTextingAsk:"chat_texting_ask",serverSlots:"server_slots"}),me=Object.keys(ye),ve="presentation",we="presentation.";var ke={chatAnswerStyle:["bubbles","cards"],chatHistoryStyle:["drawer","sheet"],chatTopCard:["none","focus"],safetyDisclaimerPlacement:["composer","answer_footer","none"],healthPlanLayout:["standard","focus_plan"],chatComposerStyle:["standard","compact"],chatComposerPlaceholder:["generic","pet_name"],chatHistoryBar:["pinned","scroll"],chatSendButton:["always_dark","dim_when_empty"]},Ce=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner","chatTextingAsk","serverSlots"]);function Se(e,t){if(t==null)return;let r=ke[e];return r!==void 0?typeof t=="string"&&r.includes(t)?t:void 0:Ce.has(e)?typeof t=="boolean"?t:void 0:typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=3?t:void 0}function parsePresentation(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let e of me){let n=ye[e],l=Object.prototype.hasOwnProperty.call(t,n)?t[n]:t[e],i=Se(e,l);i!==void 0&&(r[e]=i)}return Object.keys(r).length===0?null:/* @__PURE__ */Object.freeze(r)}function isPresentationFieldLocked(e,t){if(t==null)return false;let r=`${we}${ye[e]}`;for(let e of t)if(e===ve||e===r)return true;return false}function resolvePresentation(e){let t=parsePresentation(e?.server??null)??{},{safetyDisclaimerPlacement:r,...n}=t,l=r==="none"||r===void 0?n:{...n,safetyDisclaimerPlacement:r},i=parsePresentation(e?.client??null)??{},o=e?.locked?[...e.locked]:null,a={};for(let e of me){let t=l[e],r=isPresentationFieldLocked(e,o)?void 0:i[e];a[e]=r??t??be[e]}/* @__PURE__ */
3
- return Object.freeze(a)}var xe="Go to the nearest emergency vet now.";var Re=/* @__PURE__ */Object.freeze({placeholder:"Ask anything about {petName}…",placeholderFollowUpWeb:"Ask a follow-up…",placeholderUrgentWeb:"Tell us what’s happening…",composerLabel:"Message",attachPhotoOrFileNative:"Add a photo or file",suggestions:"Suggestions",reading:"Reading {petName}’s records…",answered:"Everfur answered.",assistantName:"Everfur",followUpsHeadingNative:"Follow-up questions",turnFailedTitleWeb:"Everfur couldn’t 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…",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",sourcesHeading:"Sources",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",goToNearestEmergencyVet:xe,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 · ",close:"Close",addAnotherPet:"Add a pet",addPet:"Add a pet",capReached:"You've used your {cap} free messages this month.",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 _e(e,t){return e.replace(/\{(\w+)\}/g,(e,r)=>{let n=t[r];return n===void 0?e:String(n)})}function Te(e){return e?.trim()||Re.emptyTitlePetFallback}function ze(e,t){return _e(e,{petName:Te(t)})}var Ie="tel:+18884264435";function ok(e,t){/* @__PURE__ */
2
+ import{createContext,forwardRef as e,createElement as t,useCallback as r,useMemo as n,useRef as l,useState as i,useEffect as o,useSyncExternalStore as a,useContext as s,Component as u,Fragment as d}from"react";import*as c from"react-native";import{TextInput as p,StyleSheet as f,Platform as h,AppState as g,Text as b,View as y,Linking as m,KeyboardAvoidingView as v,Pressable as w,Dimensions as k,Keyboard as C,Modal as S,ScrollView as x,ActivityIndicator as R,Image as T,AccessibilityInfo as _,UIManager as z,LayoutAnimation as I,Animated as P,useWindowDimensions as F,FlatList as L}from"react-native";import{jsx as E,jsxs as O,Fragment as A}from"react/jsx-runtime";import{useSafeAreaInsets as j}from"react-native-safe-area-context";import*as D from"@everfur/sdk/texting";var M=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[M[t]]}}function headingFace(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type;if(r===null&&n===null)return face(e,t);if(r!==null)return{fontFamily:r,fontWeight:n??e.type.weight[M[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function B(e){return e<=450?"regular":e<=650?"medium":"bold"}var H={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=W.get(e);r===void 0&&(r=/* @__PURE__ */new Map,W.set(e,r));let n=r.get(t);if(n!==void 0)return n;let l=N(e,t);return r.set(t,l),l}var W=/* @__PURE__ */new WeakMap;function N(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,l=B(Number(n)),i=r.face==="mono"?face(e,H[l]):r.face==="heading"?headingFace(e,l):face(e,l),o=r.face==="heading"?e.type.headingWeight??n:n,a=i.fontWeight===void 0?i:{fontFamily:i.fontFamily,fontWeight:o},s=r.size,u={...a,fontSize:s,lineHeight:Math.round(s*r.lineHeight*100)/100};return r.letterSpacing!==0&&(u.letterSpacing=Math.round(s*r.letterSpacing*100)/100),r.uppercase&&(u.textTransform="uppercase"),/* @__PURE__ */Object.freeze(u)}var U=/* @__PURE__ */Object.freeze({display:/* @__PURE__ */Object.freeze({size:29,lineHeight:1.06,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),title:/* @__PURE__ */Object.freeze({size:23,lineHeight:1.12,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),cardTitle:/* @__PURE__ */Object.freeze({size:19,lineHeight:1.22,weight:"800",face:"sans",letterSpacing:0,uppercase:false,tier:"heading"}),rowTitle:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.4,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),body:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),message:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),bodySmall:/* @__PURE__ */Object.freeze({size:14.5,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),caption:/* @__PURE__ */Object.freeze({size:13,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),label:/* @__PURE__ */Object.freeze({size:10.5,lineHeight:1.4,weight:"400",face:"mono",letterSpacing:.05,uppercase:true,tier:"compact"}),eyebrow:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"mono",letterSpacing:.07,uppercase:true,tier:"compact"}),chip:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.3,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),tab:/* @__PURE__ */Object.freeze({size:16,lineHeight:1.5,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),button:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"control"}),badge:/* @__PURE__ */Object.freeze({size:12,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"badge"})});var $=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){$(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var V=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var q={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},G={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},K={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},Y={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Q={regular:"400",medium:"500",bold:"700"},Z={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},J=0,X="System",ee="monospace",te=["content","heading","control","compact","badge"];function re(e){let t={};for(let r of te)t[r]=e;return t}var ne=[];function le(){return{family:X,mono:ee,fontUrl:null,families:{regular:X,medium:X,bold:X,mono:ee,monoMedium:ee,monoBold:ee},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:K,tierSizes:re(K),lineHeight:Y,weight:Q,letterSpacing:Z,scale:1,maxScale:J,scaleCaps:V,headingFamily:null,headingWeight:null,fontSources:ne,roles:U,typeScale:1}}var ie={},oe=/* @__PURE__ */Object.freeze({standard:/* @__PURE__ */Object.freeze([.2,0,0,1]),emphasized:/* @__PURE__ */Object.freeze([.2,.8,.2,1]),exit:/* @__PURE__ */Object.freeze([.4,0,1,1])});function cssCubicBezier(e){return`cubic-bezier(${e.join(", ")})`}var ae={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(oe.standard),emphasized:cssCubicBezier(oe.emphasized),exit:cssCubicBezier(oe.exit)},reducedMotion:false},se={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",highlight:"#FFC3BC",onHighlight:"#000000",mark:"#07C168",controlEdge:"rgba(16,70,46,0.18)",structureEdge:"rgba(16,70,46,0.25)",primaryEdge:"#10462E",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)",info:"#10462E",badgeBgInfo:"rgba(16,70,46,0.10)",infoEdge:"rgba(16,70,46,0.25)"},ue=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:se,space:q,radius:G,type:le(),motion:ae,slots:ie}),de={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",highlight:"#605051",onHighlight:"#F5F3F0",mark:"#07C168",controlEdge:"rgba(107,211,154,0.22)",structureEdge:"rgba(107,211,154,0.28)",primaryEdge:"#6BD39A",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)",info:"#6BD39A",badgeBgInfo:"rgba(107,211,154,0.12)",infoEdge:"rgba(107,211,154,0.28)"},ce=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:de,space:q,radius:G,type:le(),motion:ae,slots:ie});var pe=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),fe=globalThis,he=fe[pe]??(fe[pe]=createContext(ue));he.displayName??="EverfurThemeContext";function useEverfurTheme(){return s(he)}function ge(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:e,variant:r,...n}){let l=useEverfurTheme(),i=r===void 0?void 0:l.type.roles[r],o=ge(l.type,e??i?.tier??"content"),a=r===void 0?n:{...n,style:[{...textRole(l,r),color:l.color.text.primary,flexShrink:1},n.style]};return t(b,o===void 0?a:{maxFontSizeMultiplier:o,...a})}var be=e(function(e,r){return t(p,{...e,...r===null?{}:{ref:r}})});var ye=640,me=600,ve=/* @__PURE__ */Object.freeze({width:0,height:0}),we="useWindowDimensions"in c&&typeof c.useWindowDimensions=="function"?c.useWindowDimensions:()=>ve,ke=/* @__PURE__ */Object.freeze({width:"100%",maxWidth:ye,alignSelf:"center"});/* @__PURE__ */Object.freeze({...ke,flex:1});var Ce=/* @__PURE__ */Object.freeze({...ke,flexGrow:1,flexShrink:1});function Se(){return we().width>=me}function xe(e="flow"){let{width:t}=we();if(t<me)return null;if(e==="flow")return ke;let r=Math.max(0,Math.round((t-ye)/2));return{left:r,right:r}}function Re(e,t){return t===null?e:[e,t]}var Te=/* @__PURE__ */Symbol.for("@everfur/sdk#InSdkColumn@v1"),_e=globalThis,ze=_e[Te]??(_e[Te]=createContext(false));ze.displayName??="EverfurInSdkColumn";function SdkTabletColumn({children:e,style:t,testID:r}){let n=Se(),l=s(ze);return!n||l?e:/* @__PURE__ */E(y,{style:t===void 0?Ce:[Ce,t],testID:r??"everfur-tablet-column",children:/* @__PURE__ */E(ze.Provider,{value:true,children:e})})}var Ie=/* @__PURE__ */Object.freeze({chatAnswerStyle:"cards",chatHistoryStyle:"sheet",chatTopCard:"focus",chatFollowUpCount:3,chatFollowUpsExcludeTelevet:false,chatComposerMic:true,chatComposerUpload:true,safetyDisclaimerPlacement:"composer",healthPlanLayout:"focus_plan",recordsTopRiskLine:true,recordsClearResultsFilter:true,chatComposerStyle:"compact",chatComposerPlaceholder:"pet_name",chatHistoryBar:"scroll",chatGeneralBanner:true,chatSendButton:"always_dark",chatTextingAsk:true,serverSlots:false}),Pe=/* @__PURE__ */Object.freeze({chatAnswerStyle:"chat_answer_style",chatHistoryStyle:"chat_history_style",chatTopCard:"chat_top_card",chatFollowUpCount:"chat_follow_up_count",chatFollowUpsExcludeTelevet:"chat_follow_ups_exclude_televet",chatComposerMic:"chat_composer_mic",chatComposerUpload:"chat_composer_upload",safetyDisclaimerPlacement:"safety_disclaimer_placement",healthPlanLayout:"health_plan_layout",recordsTopRiskLine:"records_top_risk_line",recordsClearResultsFilter:"records_clear_results_filter",chatComposerStyle:"chat_composer_style",chatComposerPlaceholder:"chat_composer_placeholder",chatHistoryBar:"chat_history_bar",chatGeneralBanner:"chat_general_banner",chatSendButton:"chat_send_button",chatTextingAsk:"chat_texting_ask",serverSlots:"server_slots"}),Fe=Object.keys(Pe),Le="presentation",Ee="presentation.";var Oe={chatAnswerStyle:["bubbles","cards"],chatHistoryStyle:["drawer","sheet"],chatTopCard:["none","focus"],safetyDisclaimerPlacement:["composer","answer_footer","none"],healthPlanLayout:["standard","focus_plan"],chatComposerStyle:["standard","compact"],chatComposerPlaceholder:["generic","pet_name"],chatHistoryBar:["pinned","scroll"],chatSendButton:["always_dark","dim_when_empty"]},Ae=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner","chatTextingAsk","serverSlots"]);function je(e,t){if(t==null)return;let r=Oe[e];return r!==void 0?typeof t=="string"&&r.includes(t)?t:void 0:Ae.has(e)?typeof t=="boolean"?t:void 0:typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=3?t:void 0}function parsePresentation(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let e of Fe){let n=Pe[e],l=Object.prototype.hasOwnProperty.call(t,n)?t[n]:t[e],i=je(e,l);i!==void 0&&(r[e]=i)}return Object.keys(r).length===0?null:/* @__PURE__ */Object.freeze(r)}function isPresentationFieldLocked(e,t){if(t==null)return false;let r=`${Ee}${Pe[e]}`;for(let e of t)if(e===Le||e===r)return true;return false}function resolvePresentation(e){let t=parsePresentation(e?.server??null)??{},{safetyDisclaimerPlacement:r,...n}=t,l=r==="none"||r===void 0?n:{...n,safetyDisclaimerPlacement:r},i=parsePresentation(e?.client??null)??{},o=e?.locked?[...e.locked]:null,a={};for(let e of Fe){let t=l[e],r=isPresentationFieldLocked(e,o)?void 0:i[e];a[e]=r??t??Ie[e]}/* @__PURE__ */
3
+ return Object.freeze(a)}var De="Go to the nearest emergency vet now.";var Me=/* @__PURE__ */Object.freeze({placeholder:"Ask anything about {petName}…",placeholderFollowUpWeb:"Ask a follow-up…",placeholderUrgentWeb:"Tell us what’s happening…",composerLabel:"Message",attachPhotoOrFileNative:"Add a photo or file",suggestions:"Suggestions",reading:"Reading {petName}’s records…",answered:"Everfur answered.",assistantName:"Everfur",followUpsHeadingNative:"Follow-up questions",turnFailedTitleWeb:"Everfur couldn’t 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…",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",sourcesHeading:"Sources",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",goToNearestEmergencyVet:De,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 · ",close:"Close",addAnotherPet:"Add a pet",addPet:"Add a pet",capReached:"You've used your {cap} free messages this month.",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 Be(e,t){return e.replace(/\{(\w+)\}/g,(e,r)=>{let n=t[r];return n===void 0?e:String(n)})}function He(e){return e?.trim()||Me.emptyTitlePetFallback}function We(e,t){return Be(e,{petName:He(t)})}var Ne="tel:+18884264435";function ok(e,t){/* @__PURE__ */
4
4
  return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
5
- return Object.freeze({ok:false,error:e})}var Pe=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var Fe=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Le=globalThis,Ee=Le[Fe]??(Le[Fe]=createContext(null));Ee.displayName??="EverfurContext";function Oe(){let e=s(Ee);if(e===null)throw new Pe("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}var Ae=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"timezone_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],je=/* @__PURE__ */Object.freeze(Ae.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(je.map(e=>e.wireCode));var De=/* @__PURE__ */Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),Me=/* @__PURE__ */Object.freeze(je.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:De[e.wireCode]}))),Be=new Map(Me.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),He=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(Me.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...He]){let t=Be.get(e+r);if(t)return t}}var We=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function categoryFor(e){return We[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var Ne=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return Ne.has(e)}var Ue=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||Ue.has(e)}var $e=500,Ve=8e3,qe=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min($e*2**r,Ve);return Math.floor(t()*n)}var Ge="This feature isn't available on your account right now.",Ke="Something in that request was not right. Check the details and try again.",Ye=/* @__PURE__ */Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:Ge,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:Ke,sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",identitySignatureRequired:Ge,runtimeDisposed:Ke,unknown:"Something went wrong. Please try again."}),Qe="This session has ended. Please sign in again.",Ze="linked_account_read_only";function Je(e,t,r){return e==="conflict"&&r===Ze?Ge:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?Qe:userFacingError(e)}function userFacingError(e){return Ye[e]}function Xe(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var et=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===Ze,l={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:Je(e,t?.wireCode,n?Ze:null)};t?.httpStatus!==void 0&&(l.httpStatus=t.httpStatus),t?.requestId&&(l.requestId=t.requestId),typeof t?.reasonCode=="string"&&et.test(t.reasonCode)&&(l.reasonCode=t.reasonCode);let i=t?.retryAfterSeconds;if(typeof i=="number"&&Number.isFinite(i)&&i>=0&&(l.retryAfterSeconds=Math.round(i)),r);return t?.wireMessage&&Xe(l,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Xe(l,"raw",t.raw),/* @__PURE__ */Object.freeze(l)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
6
- return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var tt="x-everfur-anon-token",rt="anonTokenInvalid";async function nt(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function lt(e,t){let r=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...r?{wireMessage:r}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[tt]=e.anonToken)),e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}function withAuthHeaders(e,t){return{...e,headers:{...it(e.headers),...authHeaders(t)}}}function it(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let e=r.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===tt||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await nt(t),n=await t.transport.request(withAuthHeaders(e,ot(t,r)));if(n.ok||st(n.error.raw)!==rt||t.anonIdentity===void 0||t.userRef!==null)return n;let l=await t.anonIdentity.token({forceRefresh:true});return l===null||l===r?n:t.transport.request(withAuthHeaders(e,ot(t,l)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(lt(e))}let n=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let l;try{l=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(lt(e,{wireCode:st(n.error.raw),requestId:n.error.requestId}))}let i=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:l,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!i.ok&&i.error.httpStatus===401?(t.identity.reportRejected?.(),err(at(i.error))):i}function ot(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function at(e){let t=e.raw,r=st(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...r?{wireCode:r}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function st(e){if(typeof e!="object"||e===null)return null;let t=e,r=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof r=="string"&&r.length>0?r:null}var ut="free_cap_reached";function dt(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ct(e){if(typeof e!="object"||e===null)return null;let t=e,r=t.detail,n=typeof r=="object"&&r!==null?r:t;if(n.error!==ut&&n.code!==ut)return null;let l=dt(n.limit),i=dt(n.used);if(l===null||i===null)return null;let o=n.resets_at,a=n.emergency_guidance;/* @__PURE__ */
7
- return Object.freeze({limit:l,used:i,resetsAt:typeof o=="string"&&o.length>0?o:null,...typeof a=="string"&&a.trim().length>0?{emergencyGuidance:a}:{}})}function pt(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:ct(t)}function ft(e,t){let r=globalThis.URL;if(typeof r=="function"){let n;try{n=t===void 0?new r(e):new r(e,t)}catch{return null}try{if(n.protocol)return n}catch{}}return yt(e)}var ht=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,gt=/[\s\u0000-\u001f\u007f\\]/,bt={"http:":"80","https:":"443"};function yt(e,t){let r=e.trim();let n=gt.test(r)?null:ht.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",d="",c=""]=n,p=`${l.toLowerCase()}:`,f=Number(s);if(f>65535)return null;let h=s===""||String(f)===bt[p]?"":String(f),g=bt[p]!==void 0,b=a.toLowerCase()+(h&&`:${h}`),y=u||(g?"/":""),m=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${p}//${m}${b}${y}${d}${c}`,protocol:p,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:g?`${p}//${b}`:"null",pathname:y,search:d==="?"?"":d,hash:c==="#"?"":c}}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:mt(e)})}function mt(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var vt=3e4,wt=Ve*2,kt="idempotency-key",Ct=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),St=/* @__PURE__ */Object.freeze({onEvent(){}}),xt=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Rt(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}function createRequestFunnel(e){let t=e.observer??St,r=e.timers??xt,n=e.rng??Math.random,l=e.sleep??((e,t)=>Wt(e,r,t)),i=e.maxAttempts??qe,o=e.unaryTimeoutMs??vt,a=e.newIdempotencyKey??Tt(),s=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,d){let c=d?.maxAttempts,p=Math.max(1,c??i),f=d?.idempotent??Ct.has(u.method),h=d?.idempotencyKey===void 0?null:Rt(d.idempotencyKey),g=f?h??a():null,b=_t(u,g),y=0;for(;;){let i=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:y,...g?{idempotencyKey:g}:{},...e});s(i({phase:"attempt"}));let a=Bt(o,r),d=Ht(a.signal,u.signal),f;try{f=await authedSend({...b,signal:d.signal},e.auth)}catch(e){f=err(networkError(e))}finally{d.dispose(),a.cancel()}if(f.ok)return s(i({phase:"settled",ok:true,reason:"ok"})),f;let h=f.error,m=It(h,y,{maxAttempts:p,rng:n,now:r.now(),aborted:u.signal?.aborted===true,...c!==void 0?{perCallMaxAttempts:c}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),v={ok:false,code:h.code,reason:m.reason,...h.httpStatus!==void 0?{httpStatus:h.httpStatus}:{},...h.requestId!==void 0?{requestId:h.requestId}:{}};if(!m.retry)return s(i({phase:"settled",...v})),err(h);if(s(i({phase:"retry",...v,delayMs:m.delayMs})),await l(m.delayMs,u.signal),u.signal?.aborted===true)return s(i({phase:"settled",...v,reason:"aborted"})),err(h);y+=1}}async function d(t){return withAuthHeaders(t,await Mt(e.auth))}async function*c(t,r,n){s(
5
+ return Object.freeze({ok:false,error:e})}var Ue=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var $e=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Ve=globalThis,qe=Ve[$e]??(Ve[$e]=createContext(null));qe.displayName??="EverfurContext";function Ge(){let e=s(qe);if(e===null)throw new Ue("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}var Ke=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"timezone_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],Ye=/* @__PURE__ */Object.freeze(Ke.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(Ye.map(e=>e.wireCode));var Qe=/* @__PURE__ */Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),Ze=/* @__PURE__ */Object.freeze(Ye.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:Qe[e.wireCode]}))),Je=new Map(Ze.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),Xe=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(Ze.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...Xe]){let t=Je.get(e+r);if(t)return t}}var et=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function categoryFor(e){return et[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var tt=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return tt.has(e)}var rt=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||rt.has(e)}var nt=500,lt=8e3,it=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(nt*2**r,lt);return Math.floor(t()*n)}var ot="This feature isn't available on your account right now.",at="Something in that request was not right. Check the details and try again.",st=/* @__PURE__ */Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:ot,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:at,sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",identitySignatureRequired:ot,runtimeDisposed:at,unknown:"Something went wrong. Please try again."}),ut="This session has ended. Please sign in again.",dt="linked_account_read_only";function ct(e,t,r){return e==="conflict"&&r===dt?ot:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?ut:userFacingError(e)}function userFacingError(e){return st[e]}function pt(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var ft=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===dt,l={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:ct(e,t?.wireCode,n?dt:null)};t?.httpStatus!==void 0&&(l.httpStatus=t.httpStatus),t?.requestId&&(l.requestId=t.requestId),typeof t?.reasonCode=="string"&&ft.test(t.reasonCode)&&(l.reasonCode=t.reasonCode);let i=t?.retryAfterSeconds;if(typeof i=="number"&&Number.isFinite(i)&&i>=0&&(l.retryAfterSeconds=Math.round(i)),r);return t?.wireMessage&&pt(l,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&pt(l,"raw",t.raw),/* @__PURE__ */Object.freeze(l)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
6
+ return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var ht="x-everfur-anon-token",gt="anonTokenInvalid";async function bt(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function yt(e,t){let r=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...r?{wireMessage:r}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[ht]=e.anonToken)),e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}function withAuthHeaders(e,t){return{...e,headers:{...mt(e.headers),...authHeaders(t)}}}function mt(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let e=r.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===ht||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await bt(t),n=await t.transport.request(withAuthHeaders(e,vt(t,r)));if(n.ok||kt(n.error.raw)!==gt||t.anonIdentity===void 0||t.userRef!==null)return n;let l=await t.anonIdentity.token({forceRefresh:true});return l===null||l===r?n:t.transport.request(withAuthHeaders(e,vt(t,l)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(yt(e))}let n=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let l;try{l=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(yt(e,{wireCode:kt(n.error.raw),requestId:n.error.requestId}))}let i=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:l,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!i.ok&&i.error.httpStatus===401?(t.identity.reportRejected?.(),err(wt(i.error))):i}function vt(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function wt(e){let t=e.raw,r=kt(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...r?{wireCode:r}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function kt(e){if(typeof e!="object"||e===null)return null;let t=e,r=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof r=="string"&&r.length>0?r:null}var Ct="free_cap_reached";function St(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function xt(e){if(typeof e!="object"||e===null)return null;let t=e,r=t.detail,n=typeof r=="object"&&r!==null?r:t;if(n.error!==Ct&&n.code!==Ct)return null;let l=St(n.limit),i=St(n.used);if(l===null||i===null)return null;let o=n.resets_at,a=n.emergency_guidance;/* @__PURE__ */
7
+ return Object.freeze({limit:l,used:i,resetsAt:typeof o=="string"&&o.length>0?o:null,...typeof a=="string"&&a.trim().length>0?{emergencyGuidance:a}:{}})}function Rt(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:xt(t)}function Tt(e,t){let r=globalThis.URL;if(typeof r=="function"){let n;try{n=t===void 0?new r(e):new r(e,t)}catch{return null}try{if(n.protocol)return n}catch{}}return Pt(e)}var _t=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,zt=/[\s\u0000-\u001f\u007f\\]/,It={"http:":"80","https:":"443"};function Pt(e,t){let r=e.trim();let n=zt.test(r)?null:_t.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",d="",c=""]=n,p=`${l.toLowerCase()}:`,f=Number(s);if(f>65535)return null;let h=s===""||String(f)===It[p]?"":String(f),g=It[p]!==void 0,b=a.toLowerCase()+(h&&`:${h}`),y=u||(g?"/":""),m=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${p}//${m}${b}${y}${d}${c}`,protocol:p,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:g?`${p}//${b}`:"null",pathname:y,search:d==="?"?"":d,hash:c==="#"?"":c}}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:Ft(e)})}function Ft(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var Lt=3e4,Et=lt*2,Ot="idempotency-key",At=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),jt=/* @__PURE__ */Object.freeze({onEvent(){}}),Dt=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Mt(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}function createRequestFunnel(e){let t=e.observer??jt,r=e.timers??Dt,n=e.rng??Math.random,l=e.sleep??((e,t)=>er(e,r,t)),i=e.maxAttempts??it,o=e.unaryTimeoutMs??Lt,a=e.newIdempotencyKey??Ht(),s=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,d){let c=d?.maxAttempts,p=Math.max(1,c??i),f=d?.idempotent??At.has(u.method),h=d?.idempotencyKey===void 0?null:Mt(d.idempotencyKey),g=f?h??a():null,b=Bt(u,g),y=0;for(;;){let i=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:y,...g?{idempotencyKey:g}:{},...e});s(i({phase:"attempt"}));let a=Jt(o,r),d=Xt(a.signal,u.signal),f;try{f=await authedSend({...b,signal:d.signal},e.auth)}catch(e){f=err(networkError(e))}finally{d.dispose(),a.cancel()}if(f.ok)return s(i({phase:"settled",ok:true,reason:"ok"})),f;let h=f.error,m=Nt(h,y,{maxAttempts:p,rng:n,now:r.now(),aborted:u.signal?.aborted===true,...c!==void 0?{perCallMaxAttempts:c}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),v={ok:false,code:h.code,reason:m.reason,...h.httpStatus!==void 0?{httpStatus:h.httpStatus}:{},...h.requestId!==void 0?{requestId:h.requestId}:{}};if(!m.retry)return s(i({phase:"settled",...v})),err(h);if(s(i({phase:"retry",...v,delayMs:m.delayMs})),await l(m.delayMs,u.signal),u.signal?.aborted===true)return s(i({phase:"settled",...v,reason:"aborted"})),err(h);y+=1}}async function d(t){return withAuthHeaders(t,await Zt(e.auth))}async function*c(t,r,n){s(
8
8
  /* @__PURE__ */Object.freeze({call:t,phase:"stream.open",method:r.method,path:r.path,attempt:0}));try{yield*e.auth.transport.stream(r,n)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}}/* @__PURE__ */
9
- return Object.freeze({send:u,authorize:d,stream:c})}function _t(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==kt&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function Tt(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var zt=10;function It(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=Pt(e);if(n==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let l=n==="burst"?"burst-throttle":"retryable-code";if((()=>{if(r.policy===void 0)return false;try{return!r.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let i=()=>{if(r.policy===void 0)return null;let t;try{t=r.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min(zt,Math.floor(t)))},o=r.perCallMaxAttempts??i()??r.maxAttempts;if(t+1>=o)return{retry:false,reason:"attempts-exhausted"};let a=Ft(e,r.now);return a!==null?a>wt?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:l,delayMs:a}:{retry:true,reason:l,delayMs:backoffDelayMs(t,r.rng)}}function Pt(e){let t=e.code==="unknown"?fromWire(jt(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function Ft(e,t){let r=Et(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=Lt(e.raw);return n===null?null:Math.round(n*1e3)}function Lt(e){for(let t of Ot(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function Et(e){for(let t of Ot(e)){let e=t.resets_at,r=At(e);if(r!==null)return r}return null}function Ot(e){if(!Dt(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];Dt(n)&&t.push(n)}return t}function At(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e11?Math.round(e*1e3):Math.round(e);if(typeof e=="string"&&e.trim().length>0){let t=Date.parse(e);return Number.isFinite(t)?t:null}return null}function jt(e){for(let t of Ot(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function Dt(e){return typeof e=="object"&&e!==null}async function Mt(e){if(e.mode==="anonymous"){let t=await nt(e);return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}return{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}function Bt(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function Ht(e,t){let r=()=>{};if(!t)return{signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let l=()=>n.abort();return e.addEventListener("abort",l,{once:true}),t.addEventListener("abort",l,{once:true}),{signal:n.signal,dispose:()=>{e.removeEventListener("abort",l),t.removeEventListener("abort",l)}}}function Wt(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let l=t.setTimeout(()=>{r?.removeEventListener("abort",i),n()},e),i=()=>{t.clearTimeout(l),n()};r?.addEventListener("abort",i,{once:true})})}function Nt(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function Ut(e){return e.code!=="conversationNotFound"?e:makeEverfurError("resourceNotFound",{retryable:false,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.requestId===void 0?{}:{requestId:e.requestId},...e.reasonCode===void 0?{}:{reasonCode:e.reasonCode},...e.wireMessage===void 0?{}:{wireMessage:e.wireMessage},...e.raw===void 0?{}:{raw:e.raw}})}function $t(e){return e.ok?e:err(Ut(e.error))}function Vt(e){return{send:async(...t)=>$t(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var qt=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function Gt(e){let t=qt(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}var Kt=6;function Yt(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=400?e:null}function Qt(e,t,r){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let n=[];for(let l of e){if(n.length>=r)break;if(l===null||typeof l!="object"||Array.isArray(l))continue;let e=t(l);e!==null&&n.push(e)}/* @__PURE__ */
10
- return Object.freeze(n)}function Zt(e){let t=qt(e.title,80),r=qt(e.body,600);return t===null||r===null?null:/* @__PURE__ */Object.freeze({title:t,body:r})}function Jt(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,r=[];if(Array.isArray(t.gallery))for(let e of t.gallery){let t=Gt(e);t!==null&&r.length<Kt&&r.push(t)}let n=Qt(t.doses,e=>{let t=qt(e.label,60),r=qt(e.amount,60);return t===null||r===null?null:/* @__PURE__ */Object.freeze({label:t,amount:r,minLb:Yt(e.minLb??e.min_lb),maxLb:Yt(e.maxLb??e.max_lb)})},Kt),l=Qt(t.details,Zt,Kt),i=t.fit,o=i!==null&&typeof i=="object"&&!Array.isArray(i)?Zt(i):null,a=o!==null&&i.pet===true?/* @__PURE__ */Object.freeze({...o,pet:true}):o,s=/* @__PURE__ */Object.freeze({kicker:qt(t.kicker,80),gallery:/* @__PURE__ */Object.freeze(r),doses:n,details:l,fine:qt(t.fine,300),fit:a});return s.kicker===null&&r.length===0&&n.length===0&&l.length===0&&s.fine===null&&a===null?void 0:s}var Xt=128;var er=/* @__PURE__ */new Set(["shield","arrow","check","star","truck","refresh","card","alert","x","chat","repeat","calendar","flame","box","cart","minus","plus","chev","pulse","file","kit","dna","heart","bottle","harness","ramp"]),tr=/* @__PURE__ */new Set(["y","c","g","r"]),rr=/* @__PURE__ */new Set(["done","now","next"]),nr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null,lr=(e,t=1e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null,ir=e=>typeof e=="string"&&/^[A-Za-z0-9_-]{1,40}$/.test(e)?e:null,or=e=>typeof e=="string"&&er.has(e)?e:null;function ar(e){let t=lr(e,2048);return t===null||/\s/.test(t)?null:/^https:\/\/[^/]/i.test(t)||/^\/(?![/\\])/.test(t)?t:null}var sr=e=>typeof e=="number"&&Number.isInteger(e)?String(e):lr(e,Xt);function ur(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function dr(e){/* @__PURE__ */
11
- return Object.freeze(Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)))}function cr(e,t,r=20){if(!Array.isArray(e))return null;let n=[];for(let l of e){if(n.length>=r)break;let e=t(l);e!==null&&n.push(e)}return n.length===0?null:/* @__PURE__ */Object.freeze(n)}var pr=(e,t=12,r=300)=>cr(e,e=>lr(e,r),t);function fr(e){let t=nr(e),r=lr(t?.kicker,120),n=lr(t?.title,300);if(t===null||r===null||n===null)return null;let l=nr(t.risk),i=nr(t.odds),o=nr(t.quote),a=nr(t.jump);return dr({kicker:r,title:n,sources:cr(t.sources,e=>{let t=lr(nr(e)?.label,60);return t===null?null:dr({label:t,kind:ir(nr(e)?.kind)})},6),risk:lr(l?.lead,300)===null?null:dr({lead:lr(l?.lead,300),body:lr(l?.body),kind:ir(l?.kind)}),odds:lr(i?.label,120)===null||lr(i?.from,20)===null||lr(i?.to,20)===null?null:dr({label:lr(i?.label,120),tag:lr(i?.tag,40),from:lr(i?.from,20),to:lr(i?.to,20),toLabel:lr(i?.toLabel,120)}),quote:lr(o?.text)===null?null:dr({kicker:lr(o?.kicker,120),tag:lr(o?.tag,40),text:lr(o?.text)}),jump:lr(a?.title,300)===null||lr(a?.go,60)===null?null:dr({title:lr(a?.title,300),go:lr(a?.go,60)}),report:hr(t.report)})}function hr(e){let t=nr(e),r=lr(t?.label,120),n=lr(t?.text,1200);return r===null||n===null?null:dr({label:r,text:n,actions:pr(t?.actions,5,300)})}function gr(e){let t=nr(e),r=lr(t?.title,300),n=cr(t?.steps,e=>{let t=nr(e),r=lr(t?.title,300),n=t?.tone;return r===null?null:dr({title:r,body:lr(t?.body),source:lr(t?.source,200),tone:typeof n=="string"&&tr.has(n)?n:null,icon:or(t?.icon),fromVet:t?.fromVet===true?true:null})});return r===null||n===null?null:dr({title:r,label:lr(t?.label,60),steps:n})}function br(e){let t=nr(e),r=lr(t?.title,300);if(t===null||r===null)return null;let n=nr(t.rating),l=nr(t.reviews),i=nr(t.why),o=nr(i?.score),a=nr(t.dose),s=nr(t.ingredients),u=cr(l?.items,e=>{let t=nr(e),r=t?.stars,n=lr(t?.text),l=lr(t?.by,80);return typeof r!="number"||!Number.isFinite(r)||r<1||r>5||n===null||l===null?null:dr({stars:Math.round(r),text:n,by:l})},5),d=cr(i?.rows,e=>{let t=nr(e),r=lr(t?.chip,40),n=lr(t?.title,300);return r===null||n===null?null:dr({chip:r,kind:ir(t?.kind),title:n,body:lr(t?.body)})}),c=cr(a?.stats,e=>{let t=nr(e),r=lr(t?.value,40),n=lr(t?.label,120),l=t?.kind;return r===null||n===null?null:dr({value:r,label:n,kind:l==="weight"||l==="dose"||l==="days"?l:null})},6),p=pr(s?.items,12,80);return dr({title:r,none:t.none===true?true:null,hidden:t.none===true&&t.hidden===true?true:null,productId:sr(t.productId),partnerSku:lr(t.partnerSku,200),rating:lr(n?.value,20)===null?null:dr({value:lr(n?.value,20),label:lr(n?.label,120)}),line:lr(t.line),reviews:lr(l?.label,200)===null||u===null?null:dr({label:lr(l?.label,200),items:u}),checkoutLine:lr(t.checkoutLine,300),why:lr(i?.title,200)===null||d===null?null:dr({title:lr(i?.title,200),rows:d,score:lr(o?.text,200)===null||lr(o?.value,20)===null?null:dr({text:lr(o?.text,200),value:lr(o?.value,20)})}),dose:lr(a?.title,200)===null||c===null?null:dr({title:lr(a?.title,200),stats:c,note:lr(a?.note)}),doseLabel:lr(t.doseLabel,120),ingredients:p===null?null:dr({label:lr(s?.label,200),items:p}),proof:lr(t.proof,300),trust:cr(t.trust,e=>{let t=nr(e),r=or(t?.icon),n=lr(t?.label,120);return r===null||n===null?null:dr({icon:r,label:n})},6),more:lr(t.more,120),fine:lr(t.fine),checkin:lr(t.checkin,200),detail:Jt(t.detail)??null})}function yr(e){let t=nr(e),r=lr(t?.title,200),n=cr(t?.items,e=>{let t=nr(e),r=lr(t?.title,300),n=lr(t?.body);return r===null||n===null?null:dr({title:r,body:n,urgent:t?.urgent===true?true:null,callVet:t?.callVet===true?true:null})});return r===null||n===null?null:dr({title:r,items:n})}function mr(e){let t=nr(e),r=lr(t?.title,200),n=pr(t?.questions,12,300),l=lr(t?.add,80),i=lr(t?.added,80);return r===null||n===null||l===null||i===null?null:dr({title:r,questions:n,add:l,added:i})}function vr(e){let t=nr(e),r=lr(t?.title,200),n=cr(t?.items,e=>{let t=nr(e),r=lr(t?.key,Xt),n=lr(t?.title,300),l=lr(t?.action,80),i=sr(t?.productId),o=lr(t?.added,80)??(i!==null?l:null);return r===null||n===null||l===null||o===null?null:dr({key:r,productId:i,title:n,body:lr(t?.body),price:lr(t?.price,40),was:lr(t?.was,40),tag:lr(t?.tag,40),imageUrl:ar(t?.imageUrl),icon:or(t?.icon),kind:ir(t?.kind),action:l,added:o,owned:t?.owned===true?true:null,detail:Jt(t?.detail)??null})},6);return r===null||n===null?null:dr({title:r,items:n})}function wr(e){let t=nr(e),r=lr(t?.kicker,120),n=lr(t?.title,120);return t===null||r===null||n===null?null:dr({kicker:r,title:n,icon:or(t.icon),track:cr(t.track,e=>{let t=nr(e),r=lr(t?.title,120),n=t?.state;return r===null?null:dr({title:r,detail:lr(t?.detail,120),state:typeof n=="string"&&rr.has(n)?n:null,tag:lr(t?.tag,40)})},6),heading:lr(t.heading,200),rows:cr(t.rows,e=>{let t=nr(e),r=or(t?.icon),n=lr(t?.label,120);if(r===null||n===null)return null;if(t?.fromVet===true)return dr({icon:r,label:n,text:"",fromVet:true});let l=lr(t?.text,300);return l===null?null:dr({icon:r,label:n,text:l})},6),note:lr(t.note,300),action:lr(t.action,80)})}function healthPlanFocusDesignFromWire(e){let t=nr(e),r=lr(t?.title,300),n=br(t?.pick);if(t===null||r===null||n===null)return null;let l=nr(t.byline);return dr({eyebrow:lr(t.eyebrow,120),title:r,subtitle:lr(t.subtitle,300),subtitleNoRecords:lr(t.subtitleNoRecords,300),headImageUrl:ar(t.headImageUrl),byline:lr(l?.name,120)===null?null:dr({name:lr(l?.name,120),role:lr(l?.role,120),imageUrl:ar(l?.imageUrl),shortName:lr(l?.shortName,60)}),focus:fr(t.focus),routine:gr(t.routine),pick:n,signs:yr(t.signs),checkup:mr(t.checkup),extras:vr(t.extras),wait:wr(t.wait),fine:lr(t.fine),checkoutRows:cr(t.checkoutRows,e=>{let t=nr(e),r=or(t?.icon),n=lr(t?.label,60),l=lr(t?.value,200);return r===null||n===null||l===null?null:dr({icon:r,label:n,value:l})},6)})}function healthPlanPageFromWire(e,petRef){let t=nr(e);if(t===null||!("page"in t))return null;let r=nr(t.pet),n=r?.sex;/* @__PURE__ */
12
- return Object.freeze({petRef:lr(t.pet_ref,Xt)??petRef,pet:/* @__PURE__ */Object.freeze({name:lr(r?.name,120),species:lr(r?.species,60),sex:n==="female"||n==="male"?n:null,breed:lr(r?.breed,120),weightKg:ur(r?.weight_kg),weightLb:ur(r?.weight_lb)}),checkout:t.checkout==="everfur_stripe"?"everfur_stripe":"partner",page:healthPlanFocusDesignFromWire(t.page),vetReviewed:t.vet_reviewed===true,trackingTextsEnabled:t.tracking_texts_enabled===true})}function kr(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Cr(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the expected shape`})}function Sr(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}var xr=e=>typeof e=="string"&&e.length>0&&e.length<=Xt;function Rr(petRef){return`/widget/v1/pets/${encodeURIComponent(petRef)}/plan`}async function _r(e,petRef,t){if(!xr(petRef))return err(kr("petRef must be 1..128 characters"));let r=await e.send("healthPlan.page.read",{method:"GET",path:`${Rr(petRef)}/page`,...t?.signal?{signal:t.signal}:{}});if(!r.ok)return err(r.error);let n=healthPlanPageFromWire(r.value,petRef);return n===null?err(Cr("healthPlan.page.read")):ok(n)}var Tr=/* @__PURE__ */new WeakMap;function zr(e){let t=Tr.get(e);if(t!==void 0)return t;let r=Ir(e);return Tr.set(e,r),r}function Ir(e){return{getPage:(petRef,t)=>{if(e.isDisposed)return Promise.resolve(err(Sr("getPage")));let{services:r}=e.registry,n=Vt(createRequestFunnel({auth:r.authFor(null),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}));return _r(n,petRef,t)}}}function Pr(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function Fr(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function Lr(e,...t){if(typeof e=="function")try{let r=e(...t);return Fr(r)&&Promise.resolve(r).then(void 0,Pr),r}catch(e){Pr(e);return}}var Er=/* @__PURE__ */new WeakMap;function Or(e){if(typeof e!="function")return;let t=Er.get(e);if(t!==void 0)return t;let r=(...t)=>{Lr(e,...t)};return Er.set(e,r),r}function Ar(e,...t){let r;try{r=e(...t)}catch(e){return Pr(e),Promise.resolve({ok:false,error:e})}return Promise.resolve(r).then(e=>({ok:true,value:e}),e=>({ok:false,error:e}))}var jr=6e4;function Dr({lifecycle:e,refreshKey:t,readyAt:r,revalidate:n,refresh:i,now:a=Date.now}){let s=l({readyAt:r,revalidate:n,refresh:i??n,now:a});s.current={readyAt:r,revalidate:n,refresh:i??n,now:a},o(()=>{if(e==null)return;let t=Lr(()=>e.onForeground(()=>{let{readyAt:e,revalidate:t,now:r}=s.current;e!==null&&r()-e>=jr&&t()}));return()=>{typeof t=="function"&&Lr(t)}},[e]);let u=l(t);o(()=>{Object.is(u.current,t)||(u.current=t,s.current.refresh())},[t])}var Mr=jr,Br=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanPageReads@v1");function Hr(){let e=globalThis,t=e[Br];if(t instanceof WeakMap)return t;let r=/* @__PURE__ */new WeakMap;return e[Br]=r,r}function Wr(e,t,userRef,petRef,r){let n=Hr(),l=n.get(t);l===void 0&&(l=/* @__PURE__ */new Map,n.set(t,l));let i=l,o=`${userRef}\0${petRef}`,a=i.get(o);if(!r&&a!==void 0&&(a.at===null||Date.now()-a.at<Mr))return a.promise;let s={at:null,promise:e.getPage(petRef).then(e=>(i.get(o)===s&&(e.ok||Nt(e.error)?s.at=Date.now():i.delete(o)),e))};return i.set(o,s),s.promise}function useHealthPlanPage(e){let{userRef:userRef,runtime:t}=Oe(),a=n(()=>zr(t),[t]),s=e.repository,u=s??a,d=r((e,r)=>s!==void 0||userRef==null?u.getPage(e):Wr(a,t,userRef,e,r),[s,u,a,t,userRef]),{petRef:petRef}=e,c=e.enabled!==false&&userRef!=null&&petRef!==null,[p,f]=i({phase:"idle",petRef:null,page:null,error:null}),h=l(0),g=l(0),b=r(async e=>{let t=++h.current;if(!c||petRef===null){f(e=>e.phase==="idle"&&e.petRef===null?e:{phase:"idle",petRef:null,page:null,error:null});return}f(e=>({phase:"loading",petRef:petRef,page:e.petRef===petRef?e.page:null,error:null}));let r=await d(petRef,e);t===h.current&&(r.ok?f({phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}):Nt(r.error)?f({phase:"ready",petRef:petRef,page:null,error:null,missing:true,readyAt:Date.now()}):f({phase:"failed",petRef:petRef,page:null,error:r.error}))},[c,petRef,d]),y=r(()=>b(true),[b]),m=p.phase==="ready"&&p.petRef===petRef,v=r(async()=>{if(!c||petRef===null||!m)return;let e=h.current,t=++g.current,r=await d(petRef,true);e!==h.current||t!==g.current||!r.ok||f(e=>e.phase==="ready"&&e.petRef===petRef?{phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}:e)},[c,petRef,m,d]);Dr({lifecycle:e.lifecycle,refreshKey:e.refreshKey,readyAt:m?p.readyAt??null:null,revalidate:()=>{v()},refresh:()=>{m?v():y()}}),o(()=>(b(false),()=>{h.current+=1}),[b]);let w=c&&p.petRef!==petRef;return n(()=>({phase:w?"loading":p.phase,page:w?null:p.page,error:w?null:p.error,missing:!w&&p.missing===true,refresh:y}),[w,p,y])}var Nr=/* @__PURE__ */Object.freeze({chat:/* @__PURE__ */Object.freeze(["chat.message.create"]),records:/* @__PURE__ */Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:/* @__PURE__ */Object.freeze(["records.clinic.create"]),video:/* @__PURE__ */Object.freeze(["video.gait.execute"]),photo:/* @__PURE__ */Object.freeze(["photo.checkup.execute"]),animations:/* @__PURE__ */Object.freeze(["animations.state.read"]),televet:/* @__PURE__ */Object.freeze(["televet.visit.create"]),texting:/* @__PURE__ */Object.freeze(["sms.identity.read","sms.identity.update"]),healthPlan:/* @__PURE__ */Object.freeze(["shop.plan.read","shop.plan.update"])});function requires(e){return Nr[e]}function decideCapability(e,t,r){let n=requires(e),l=/* @__PURE__ */new Map;for(let e of t)l.set(e.resource,e);if(r?.isPending===true&&n.some(e=>!l.has(e)))return Vr({name:e,enabled:false,isPending:true,limits:{}});let i=Ur(n,l);return n.filter(e=>l.get(e)?.granted!==true).length===0?Vr({name:e,enabled:true,isPending:false,limits:i}):Vr({name:e,enabled:false,isPending:false,limits:i,disabled:$r(n,l)})}function Ur(e,t){let r={};for(let n of e){let e=t.get(n)?.limits;if(e)for(let[t,n]of Object.entries(e)){let e=r[t];r[t]=e===void 0?n:Math.min(e,n)}}return r}function $r(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
9
+ return Object.freeze({send:u,authorize:d,stream:c})}function Bt(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==Ot&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function Ht(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var Wt=10;function Nt(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=Ut(e);if(n==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let l=n==="burst"?"burst-throttle":"retryable-code";if((()=>{if(r.policy===void 0)return false;try{return!r.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let i=()=>{if(r.policy===void 0)return null;let t;try{t=r.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min(Wt,Math.floor(t)))},o=r.perCallMaxAttempts??i()??r.maxAttempts;if(t+1>=o)return{retry:false,reason:"attempts-exhausted"};let a=$t(e,r.now);return a!==null?a>Et?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:l,delayMs:a}:{retry:true,reason:l,delayMs:backoffDelayMs(t,r.rng)}}function Ut(e){let t=e.code==="unknown"?fromWire(Yt(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function $t(e,t){let r=qt(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=Vt(e.raw);return n===null?null:Math.round(n*1e3)}function Vt(e){for(let t of Gt(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function qt(e){for(let t of Gt(e)){let e=t.resets_at,r=Kt(e);if(r!==null)return r}return null}function Gt(e){if(!Qt(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];Qt(n)&&t.push(n)}return t}function Kt(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e11?Math.round(e*1e3):Math.round(e);if(typeof e=="string"&&e.trim().length>0){let t=Date.parse(e);return Number.isFinite(t)?t:null}return null}function Yt(e){for(let t of Gt(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function Qt(e){return typeof e=="object"&&e!==null}async function Zt(e){if(e.mode==="anonymous"){let t=await bt(e);return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}return{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}function Jt(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function Xt(e,t){let r=()=>{};if(!t)return{signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let l=()=>n.abort();return e.addEventListener("abort",l,{once:true}),t.addEventListener("abort",l,{once:true}),{signal:n.signal,dispose:()=>{e.removeEventListener("abort",l),t.removeEventListener("abort",l)}}}function er(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let l=t.setTimeout(()=>{r?.removeEventListener("abort",i),n()},e),i=()=>{t.clearTimeout(l),n()};r?.addEventListener("abort",i,{once:true})})}function tr(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function rr(e){return e.code!=="conversationNotFound"?e:makeEverfurError("resourceNotFound",{retryable:false,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.requestId===void 0?{}:{requestId:e.requestId},...e.reasonCode===void 0?{}:{reasonCode:e.reasonCode},...e.wireMessage===void 0?{}:{wireMessage:e.wireMessage},...e.raw===void 0?{}:{raw:e.raw}})}function nr(e){return e.ok?e:err(rr(e.error))}function lr(e){return{send:async(...t)=>nr(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var ir=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function or(e){let t=ir(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}var ar=6;function sr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=400?e:null}function ur(e,t,r){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let n=[];for(let l of e){if(n.length>=r)break;if(l===null||typeof l!="object"||Array.isArray(l))continue;let e=t(l);e!==null&&n.push(e)}/* @__PURE__ */
10
+ return Object.freeze(n)}function dr(e){let t=ir(e.title,80),r=ir(e.body,600);return t===null||r===null?null:/* @__PURE__ */Object.freeze({title:t,body:r})}function cr(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,r=[];if(Array.isArray(t.gallery))for(let e of t.gallery){let t=or(e);t!==null&&r.length<ar&&r.push(t)}let n=ur(t.doses,e=>{let t=ir(e.label,60),r=ir(e.amount,60);return t===null||r===null?null:/* @__PURE__ */Object.freeze({label:t,amount:r,minLb:sr(e.minLb??e.min_lb),maxLb:sr(e.maxLb??e.max_lb)})},ar),l=ur(t.details,dr,ar),i=t.fit,o=i!==null&&typeof i=="object"&&!Array.isArray(i)?dr(i):null,a=o!==null&&i.pet===true?/* @__PURE__ */Object.freeze({...o,pet:true}):o,s=/* @__PURE__ */Object.freeze({kicker:ir(t.kicker,80),gallery:/* @__PURE__ */Object.freeze(r),doses:n,details:l,fine:ir(t.fine,300),fit:a});return s.kicker===null&&r.length===0&&n.length===0&&l.length===0&&s.fine===null&&a===null?void 0:s}var pr=128;var fr=/* @__PURE__ */new Set(["shield","arrow","check","star","truck","refresh","card","alert","x","chat","repeat","calendar","flame","box","cart","minus","plus","chev","pulse","file","kit","dna","heart","bottle","harness","ramp"]),hr=/* @__PURE__ */new Set(["y","c","g","r"]),gr=/* @__PURE__ */new Set(["done","now","next"]),br=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null,yr=(e,t=1e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null,mr=e=>typeof e=="string"&&/^[A-Za-z0-9_-]{1,40}$/.test(e)?e:null,vr=e=>typeof e=="string"&&fr.has(e)?e:null;function wr(e){let t=yr(e,2048);return t===null||/\s/.test(t)?null:/^https:\/\/[^/]/i.test(t)||/^\/(?![/\\])/.test(t)?t:null}var kr=e=>typeof e=="number"&&Number.isInteger(e)?String(e):yr(e,pr);function Cr(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Sr(e){/* @__PURE__ */
11
+ return Object.freeze(Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)))}function xr(e,t,r=20){if(!Array.isArray(e))return null;let n=[];for(let l of e){if(n.length>=r)break;let e=t(l);e!==null&&n.push(e)}return n.length===0?null:/* @__PURE__ */Object.freeze(n)}var Rr=(e,t=12,r=300)=>xr(e,e=>yr(e,r),t);function Tr(e){let t=br(e),r=yr(t?.kicker,120),n=yr(t?.title,300);if(t===null||r===null||n===null)return null;let l=br(t.risk),i=br(t.odds),o=br(t.quote),a=br(t.jump);return Sr({kicker:r,title:n,sources:xr(t.sources,e=>{let t=yr(br(e)?.label,60);return t===null?null:Sr({label:t,kind:mr(br(e)?.kind)})},6),risk:yr(l?.lead,300)===null?null:Sr({lead:yr(l?.lead,300),body:yr(l?.body),kind:mr(l?.kind)}),odds:yr(i?.label,120)===null||yr(i?.from,20)===null||yr(i?.to,20)===null?null:Sr({label:yr(i?.label,120),tag:yr(i?.tag,40),from:yr(i?.from,20),to:yr(i?.to,20),toLabel:yr(i?.toLabel,120)}),quote:yr(o?.text)===null?null:Sr({kicker:yr(o?.kicker,120),tag:yr(o?.tag,40),text:yr(o?.text)}),jump:yr(a?.title,300)===null||yr(a?.go,60)===null?null:Sr({title:yr(a?.title,300),go:yr(a?.go,60)}),report:_r(t.report)})}function _r(e){let t=br(e),r=yr(t?.label,120),n=yr(t?.text,1200);return r===null||n===null?null:Sr({label:r,text:n,actions:Rr(t?.actions,5,300)})}function zr(e){let t=br(e),r=yr(t?.title,300),n=xr(t?.steps,e=>{let t=br(e),r=yr(t?.title,300),n=t?.tone;return r===null?null:Sr({title:r,body:yr(t?.body),source:yr(t?.source,200),tone:typeof n=="string"&&hr.has(n)?n:null,icon:vr(t?.icon),fromVet:t?.fromVet===true?true:null})});return r===null||n===null?null:Sr({title:r,label:yr(t?.label,60),steps:n})}function Ir(e){let t=br(e),r=yr(t?.title,300);if(t===null||r===null)return null;let n=br(t.rating),l=br(t.reviews),i=br(t.why),o=br(i?.score),a=br(t.dose),s=br(t.ingredients),u=xr(l?.items,e=>{let t=br(e),r=t?.stars,n=yr(t?.text),l=yr(t?.by,80);return typeof r!="number"||!Number.isFinite(r)||r<1||r>5||n===null||l===null?null:Sr({stars:Math.round(r),text:n,by:l})},5),d=xr(i?.rows,e=>{let t=br(e),r=yr(t?.chip,40),n=yr(t?.title,300);return r===null||n===null?null:Sr({chip:r,kind:mr(t?.kind),title:n,body:yr(t?.body)})}),c=xr(a?.stats,e=>{let t=br(e),r=yr(t?.value,40),n=yr(t?.label,120),l=t?.kind;return r===null||n===null?null:Sr({value:r,label:n,kind:l==="weight"||l==="dose"||l==="days"?l:null})},6),p=Rr(s?.items,12,80);return Sr({title:r,none:t.none===true?true:null,hidden:t.none===true&&t.hidden===true?true:null,productId:kr(t.productId),partnerSku:yr(t.partnerSku,200),rating:yr(n?.value,20)===null?null:Sr({value:yr(n?.value,20),label:yr(n?.label,120)}),line:yr(t.line),reviews:yr(l?.label,200)===null||u===null?null:Sr({label:yr(l?.label,200),items:u}),checkoutLine:yr(t.checkoutLine,300),why:yr(i?.title,200)===null||d===null?null:Sr({title:yr(i?.title,200),rows:d,score:yr(o?.text,200)===null||yr(o?.value,20)===null?null:Sr({text:yr(o?.text,200),value:yr(o?.value,20)})}),dose:yr(a?.title,200)===null||c===null?null:Sr({title:yr(a?.title,200),stats:c,note:yr(a?.note)}),doseLabel:yr(t.doseLabel,120),ingredients:p===null?null:Sr({label:yr(s?.label,200),items:p}),proof:yr(t.proof,300),trust:xr(t.trust,e=>{let t=br(e),r=vr(t?.icon),n=yr(t?.label,120);return r===null||n===null?null:Sr({icon:r,label:n})},6),more:yr(t.more,120),fine:yr(t.fine),checkin:yr(t.checkin,200),detail:cr(t.detail)??null})}function Pr(e){let t=br(e),r=yr(t?.title,200),n=xr(t?.items,e=>{let t=br(e),r=yr(t?.title,300),n=yr(t?.body);return r===null||n===null?null:Sr({title:r,body:n,urgent:t?.urgent===true?true:null,callVet:t?.callVet===true?true:null})});return r===null||n===null?null:Sr({title:r,items:n})}function Fr(e){let t=br(e),r=yr(t?.title,200),n=Rr(t?.questions,12,300),l=yr(t?.add,80),i=yr(t?.added,80);return r===null||n===null||l===null||i===null?null:Sr({title:r,questions:n,add:l,added:i})}function Lr(e){let t=br(e),r=yr(t?.title,200),n=xr(t?.items,e=>{let t=br(e),r=yr(t?.key,pr),n=yr(t?.title,300),l=yr(t?.action,80),i=kr(t?.productId),o=yr(t?.added,80)??(i!==null?l:null);return r===null||n===null||l===null||o===null?null:Sr({key:r,productId:i,title:n,body:yr(t?.body),price:yr(t?.price,40),was:yr(t?.was,40),tag:yr(t?.tag,40),imageUrl:wr(t?.imageUrl),icon:vr(t?.icon),kind:mr(t?.kind),action:l,added:o,owned:t?.owned===true?true:null,detail:cr(t?.detail)??null})},6);return r===null||n===null?null:Sr({title:r,items:n})}function Er(e){let t=br(e),r=yr(t?.kicker,120),n=yr(t?.title,120);return t===null||r===null||n===null?null:Sr({kicker:r,title:n,icon:vr(t.icon),track:xr(t.track,e=>{let t=br(e),r=yr(t?.title,120),n=t?.state;return r===null?null:Sr({title:r,detail:yr(t?.detail,120),state:typeof n=="string"&&gr.has(n)?n:null,tag:yr(t?.tag,40)})},6),heading:yr(t.heading,200),rows:xr(t.rows,e=>{let t=br(e),r=vr(t?.icon),n=yr(t?.label,120);if(r===null||n===null)return null;if(t?.fromVet===true)return Sr({icon:r,label:n,text:"",fromVet:true});let l=yr(t?.text,300);return l===null?null:Sr({icon:r,label:n,text:l})},6),note:yr(t.note,300),action:yr(t.action,80)})}function healthPlanFocusDesignFromWire(e){let t=br(e),r=yr(t?.title,300),n=Ir(t?.pick);if(t===null||r===null||n===null)return null;let l=br(t.byline);return Sr({eyebrow:yr(t.eyebrow,120),title:r,subtitle:yr(t.subtitle,300),subtitleNoRecords:yr(t.subtitleNoRecords,300),headImageUrl:wr(t.headImageUrl),byline:yr(l?.name,120)===null?null:Sr({name:yr(l?.name,120),role:yr(l?.role,120),imageUrl:wr(l?.imageUrl),shortName:yr(l?.shortName,60)}),focus:Tr(t.focus),routine:zr(t.routine),pick:n,signs:Pr(t.signs),checkup:Fr(t.checkup),extras:Lr(t.extras),wait:Er(t.wait),fine:yr(t.fine),checkoutRows:xr(t.checkoutRows,e=>{let t=br(e),r=vr(t?.icon),n=yr(t?.label,60),l=yr(t?.value,200);return r===null||n===null||l===null?null:Sr({icon:r,label:n,value:l})},6)})}function healthPlanPageFromWire(e,petRef){let t=br(e);if(t===null||!("page"in t))return null;let r=br(t.pet),n=r?.sex;/* @__PURE__ */
12
+ return Object.freeze({petRef:yr(t.pet_ref,pr)??petRef,pet:/* @__PURE__ */Object.freeze({name:yr(r?.name,120),species:yr(r?.species,60),sex:n==="female"||n==="male"?n:null,breed:yr(r?.breed,120),weightKg:Cr(r?.weight_kg),weightLb:Cr(r?.weight_lb)}),checkout:t.checkout==="everfur_stripe"?"everfur_stripe":"partner",page:healthPlanFocusDesignFromWire(t.page),vetReviewed:t.vet_reviewed===true,trackingTextsEnabled:t.tracking_texts_enabled===true})}function Or(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Ar(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the expected shape`})}function jr(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}var Dr=e=>typeof e=="string"&&e.length>0&&e.length<=pr;function Mr(petRef){return`/widget/v1/pets/${encodeURIComponent(petRef)}/plan`}async function Br(e,petRef,t){if(!Dr(petRef))return err(Or("petRef must be 1..128 characters"));let r=await e.send("healthPlan.page.read",{method:"GET",path:`${Mr(petRef)}/page`,...t?.signal?{signal:t.signal}:{}});if(!r.ok)return err(r.error);let n=healthPlanPageFromWire(r.value,petRef);return n===null?err(Ar("healthPlan.page.read")):ok(n)}var Hr=/* @__PURE__ */new WeakMap;function Wr(e){let t=Hr.get(e);if(t!==void 0)return t;let r=Nr(e);return Hr.set(e,r),r}function Nr(e){return{getPage:(petRef,t)=>{if(e.isDisposed)return Promise.resolve(err(jr("getPage")));let{services:r}=e.registry,n=lr(createRequestFunnel({auth:r.authFor(null),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}));return Br(n,petRef,t)}}}function Ur(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function $r(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function Vr(e,...t){if(typeof e=="function")try{let r=e(...t);return $r(r)&&Promise.resolve(r).then(void 0,Ur),r}catch(e){Ur(e);return}}var qr=/* @__PURE__ */new WeakMap;function Gr(e){if(typeof e!="function")return;let t=qr.get(e);if(t!==void 0)return t;let r=(...t)=>{Vr(e,...t)};return qr.set(e,r),r}function Kr(e,...t){let r;try{r=e(...t)}catch(e){return Ur(e),Promise.resolve({ok:false,error:e})}return Promise.resolve(r).then(e=>({ok:true,value:e}),e=>({ok:false,error:e}))}var Yr=6e4;function Qr({lifecycle:e,refreshKey:t,readyAt:r,revalidate:n,refresh:i,now:a=Date.now}){let s=l({readyAt:r,revalidate:n,refresh:i??n,now:a});s.current={readyAt:r,revalidate:n,refresh:i??n,now:a},o(()=>{if(e==null)return;let t=Vr(()=>e.onForeground(()=>{let{readyAt:e,revalidate:t,now:r}=s.current;e!==null&&r()-e>=Yr&&t()}));return()=>{typeof t=="function"&&Vr(t)}},[e]);let u=l(t);o(()=>{Object.is(u.current,t)||(u.current=t,s.current.refresh())},[t])}var Zr=Yr,Jr=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanPageReads@v1");function Xr(){let e=globalThis,t=e[Jr];if(t instanceof WeakMap)return t;let r=/* @__PURE__ */new WeakMap;return e[Jr]=r,r}function en(e,t,userRef,petRef,r){let n=Xr(),l=n.get(t);l===void 0&&(l=/* @__PURE__ */new Map,n.set(t,l));let i=l,o=`${userRef}\0${petRef}`,a=i.get(o);if(!r&&a!==void 0&&(a.at===null||Date.now()-a.at<Zr))return a.promise;let s={at:null,promise:e.getPage(petRef).then(e=>(i.get(o)===s&&(e.ok||tr(e.error)?s.at=Date.now():i.delete(o)),e))};return i.set(o,s),s.promise}function useHealthPlanPage(e){let{userRef:userRef,runtime:t}=Ge(),a=n(()=>Wr(t),[t]),s=e.repository,u=s??a,d=r((e,r)=>s!==void 0||userRef==null?u.getPage(e):en(a,t,userRef,e,r),[s,u,a,t,userRef]),{petRef:petRef}=e,c=e.enabled!==false&&userRef!=null&&petRef!==null,[p,f]=i({phase:"idle",petRef:null,page:null,error:null}),h=l(0),g=l(0),b=r(async e=>{let t=++h.current;if(!c||petRef===null){f(e=>e.phase==="idle"&&e.petRef===null?e:{phase:"idle",petRef:null,page:null,error:null});return}f(e=>({phase:"loading",petRef:petRef,page:e.petRef===petRef?e.page:null,error:null}));let r=await d(petRef,e);t===h.current&&(r.ok?f({phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}):tr(r.error)?f({phase:"ready",petRef:petRef,page:null,error:null,missing:true,readyAt:Date.now()}):f({phase:"failed",petRef:petRef,page:null,error:r.error}))},[c,petRef,d]),y=r(()=>b(true),[b]),m=p.phase==="ready"&&p.petRef===petRef,v=r(async()=>{if(!c||petRef===null||!m)return;let e=h.current,t=++g.current,r=await d(petRef,true);e!==h.current||t!==g.current||!r.ok||f(e=>e.phase==="ready"&&e.petRef===petRef?{phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}:e)},[c,petRef,m,d]);Qr({lifecycle:e.lifecycle,refreshKey:e.refreshKey,readyAt:m?p.readyAt??null:null,revalidate:()=>{v()},refresh:()=>{m?v():y()}}),o(()=>(b(false),()=>{h.current+=1}),[b]);let w=c&&p.petRef!==petRef;return n(()=>({phase:w?"loading":p.phase,page:w?null:p.page,error:w?null:p.error,missing:!w&&p.missing===true,refresh:y}),[w,p,y])}var tn=/* @__PURE__ */Object.freeze({chat:/* @__PURE__ */Object.freeze(["chat.message.create"]),records:/* @__PURE__ */Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:/* @__PURE__ */Object.freeze(["records.clinic.create"]),video:/* @__PURE__ */Object.freeze(["video.gait.execute"]),photo:/* @__PURE__ */Object.freeze(["photo.checkup.execute"]),animations:/* @__PURE__ */Object.freeze(["animations.state.read"]),televet:/* @__PURE__ */Object.freeze(["televet.visit.create"]),texting:/* @__PURE__ */Object.freeze(["sms.identity.read","sms.identity.update"]),healthPlan:/* @__PURE__ */Object.freeze(["shop.plan.read","shop.plan.update"])});function requires(e){return tn[e]}function decideCapability(e,t,r){let n=requires(e),l=/* @__PURE__ */new Map;for(let e of t)l.set(e.resource,e);if(r?.isPending===true&&n.some(e=>!l.has(e)))return ln({name:e,enabled:false,isPending:true,limits:{}});let i=rn(n,l);return n.filter(e=>l.get(e)?.granted!==true).length===0?ln({name:e,enabled:true,isPending:false,limits:i}):ln({name:e,enabled:false,isPending:false,limits:i,disabled:nn(n,l)})}function rn(e,t){let r={};for(let n of e){let e=t.get(n)?.limits;if(e)for(let[t,n]of Object.entries(e)){let e=r[t];r[t]=e===void 0?n:Math.min(e,n)}}return r}function nn(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
13
13
  return Object.freeze({reason:e.reason,level:e.level,recoverable:e.recoverable})}/* @__PURE__ */
14
- return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function Vr(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:/* @__PURE__ */Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),/* @__PURE__ */Object.freeze(t)}function useCapability(e){let{runtime:t}=Oe(),r=t.entitlements,l=a(r.subscribe,r.getSnapshot,r.getSnapshot);return n(()=>decideCapability(e,l.decisions,{isPending:l.isPending}),[e,l])}function qr(e){let{runtime:t}=Oe(),n=t.entitlements,l=r(e=>n===void 0?()=>{}:n.subscribe(e),[n]),i=r(()=>{if(n===void 0)return false;let t=n.getSnapshot();return decideCapability(e,t.decisions,{isPending:t.isPending}).enabled},[n,e]);return a(l,i,i)}var Gr=()=>()=>{},Kr=()=>null;function Yr(e,t){return a(t?.subscribe??Gr,t?.get??Kr,t?.get??Kr)??e}var Qr=/* @__PURE__ */Object.freeze({branding:null}),Zr=/* @__PURE__ */Object.freeze({subscribe:()=>()=>{},getSnapshot:()=>Qr});function Jr(e){return e?Object.keys(e).sort().map(t=>`${t}=${String(e[t])}`).join("&"):""}function Xr(e){let{runtime:t}=Oe(),l=t?.entitlements??Zr,i=r(()=>l.getSnapshot()?.branding??null,[l]),o=Yr(a(l.subscribe,i,i),t?.sdkConfigHost?.branding),s=Jr(e);return n(()=>{let t=o?.lockedFields??null;return{presentation:resolvePresentation({server:o?.presentation??null,locked:t,client:e??null}),isLocked:e=>isPresentationFieldLocked(e,t)}},[o,s])}function en(e){let t={};for(let[r,n]of Object.entries(e))n!==void 0&&(t[r]=n);return t}function tn(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}function rn(e){let t=pt(e);return t===null?null:{reached:Re.capReached.replace("{cap}",String(t.limit)),guidance:t.emergencyGuidance??null}}function nn(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}function ln(e,t="native"){if(e.messages.length===0)return null;let r=e.status==="error"?e.error:null;if(r!==null){let e=nn(r),n=t==="web",l=rn(r);return{tone:"error",title:l!==null?l.reached:e?Re.turnUnreachableTitle:n?Re.turnFailedTitleWeb:Re.turnFailedTitle,body:r.displayMessage,actionLabel:e?Re.turnStartNewChat:n?Re.retry:Re.turnRetry,action:e?"startNew":"retry",...l!==null&&l.guidance!==null?{guidance:l.guidance}:{}}}return e.stopped===true?{tone:"neutral",title:Re.turnStoppedTitle,body:Re.turnStoppedBody,actionLabel:Re.turnRetry,action:"retry"}:null}function on(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}var an=3,sn=/* @__PURE__ */Object.freeze([]);function un(e){let t=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||t===void 0||t.role!=="assistant")return sn;let r=/* @__PURE__ */new Set,n=[];for(let t of e.suggestedPrompts){let e=t.trim(),l=e.replace(/\s+/g," ").toLowerCase();if(!(l.length===0||r.has(l))&&(r.add(l),n.push(e),n.length===an))break}/* @__PURE__ */
15
- return Object.freeze(n)}var dn=5;function cn(e,t){if(e===void 0)return false;if(typeof e=="function")try{return e(t)===!0}catch{return false}return e.lastIndex=0,e.test(t)}function pn(e,t){if(t===void 0)return un(e);let r=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||r===void 0||r.role!=="assistant")return sn;let n=Math.max(1,Math.min(dn,Math.floor(t.count??an))),l=null;for(let t=e.messages.length-1;t>=0;t-=1){let r=e.messages[t];if(r!==void 0&&r.role==="user"){l=r.text;break}}let i=e=>e.trim().replace(/\s+/g," ").toLowerCase(),o=new Set(l===null?[]:[i(l)]),a=[],s=e=>{let r=e.trim(),l=i(r);a.length>=n||l.length===0||o.has(l)||cn(t.exclude,r)||(o.add(l),a.push(r))};for(let t of e.suggestedPrompts)s(t);let u=[];try{u=typeof t.fill=="function"?t.fill(l):t.fill??[]}catch{u=[]}for(let e of Array.isArray(u)?u:[])typeof e=="string"&&s(e);/* @__PURE__ */
16
- return Object.freeze(a)}function fn(e){return e.sender?.displayName??Re.senderVet}function hn(petRef,conversationId){let e={};return petRef!==void 0&&(e.petRef=petRef),conversationId!==void 0&&(e.conversationId=conversationId),e}var gn=new RegExp([String.raw`\b(book|booking|schedule|scheduling|arrange|set\s+up)\s+(an?\s+|the\s+|her\s+|his\s+|their\s+|my\s+|your\s+)?(next\s+)?((vet|veterinary|video|virtual|televet|follow-up|follow up)\s+)?(visit|appointment|appt|consult|consultation|call|vet|checkup|check-up|exam)\b`,String.raw`\bmake\s+(an?\s+|the\s+)?((vet|veterinary|video|virtual|follow-up|follow up)\s+)?(appointment|appt)\b`,String.raw`\bneed\s+(an?\s+)?((vet|veterinary|video|virtual)\s+)?(appointment|appt|visit|consult|consultation)\b`,String.raw`\b(video|virtual)\s+(visit|appointment|appt|consult|consultation|call)s?\b`,String.raw`\b(televet|telehealth|telemedicine)\b`,String.raw`\b(talk|speak|chat)\s+(to|with)\s+(an?|the|your|my)\s+vet\b`,String.raw`\bsee\s+(an?|the|your|my)\s+vet\b`].join("|"),"i"),NONE=()=>true;function bn(e,t){if(e===void 0)return false;if(typeof e=="function")try{return e(t)===!0}catch{return false}return e.lastIndex=0,e.test(t)}function yn(e,t,r){let n=t.chatFollowUpsExcludeTelevet,l=e?.count!==void 0&&!r?e.count:t.chatFollowUpCount;if(e===void 0&&l===an&&!n)return;if(l<=0)return{...e??{},count:1,exclude:NONE,fill:[]};let i=e?.exclude,o=n?e=>gn.test(e)||bn(i,e):i;return{...e??{},count:l,...o!==void 0?{exclude:o}:{}}}function mn(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function vn(e){return[...e].length}var wn=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(wn,t)?wn[t]:null}var kn=50,Cn=128,Sn=120,xn=120,Rn=2e3,_n=120,Tn=80,zn=/* @__PURE__ */new Set(["male","female","unknown"]),In=/* @__PURE__ */new Set(["day","month","year"]),Pn=/* @__PURE__ */new Set(["low","medium","high","athletic"]),Fn=/* @__PURE__ */new Set(["indoor","outdoor","both"]),Ln=/* @__PURE__ */new Set(["mild","moderate","severe"]),En=/^(\d{4})-(\d{2})-(\d{2})$/,On=[["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"]],An=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...On,...An].map(([e])=>e));function jn(e){let t=En.exec(e);if(t===null)return false;let[r,n,l]=[Number(t[1]),Number(t[2]),Number(t[3])],i=new Date(Date.UTC(r,n-1,l));return i.getUTCFullYear()===r&&i.getUTCMonth()===n-1&&i.getUTCDate()===l}var Dn=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,Mn=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,Bn=(e,t)=>typeof t=="string"&&jn(t)?null:`${e} must be a real date written YYYY-MM-DD`,Hn=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(mn(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let l=t.trimmed?n.trim():n;if(t.required&&l.length===0)return`${r} is required and must not be blank`;let i=vn(l);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},Wn={sex:Dn(zn),spayedNeutered:Mn,birthDate:Bn,birthDatePrecision:Dn(In),activityLevel:Dn(Pn),indoorOutdoor:Dn(Fn),foodBrand:Hn(_n),foodType:Hn(_n),microchipId:Hn(Tn)},Nn=["ref","ref",false,Hn(Cn,{required:true,trimmed:true})],Un=["notes","notes",false,Hn(Rn,{trimmed:true})],$n=[Nn,["name","name",true,Hn(Sn,{required:true,trimmed:true})],["dose","dose",false,Hn(xn,{trimmed:true})],["frequency","frequency",false,Hn(xn,{trimmed:true})],["startDate","start_date",false,Bn],["endDate","end_date",false,Bn],Un],Vn={allergies:[Nn,["allergen","allergen",true,Hn(Sn,{required:true,trimmed:true})],["severity","severity",false,Dn(Ln)],Un],medications:$n,supplements:$n,conditions:[Nn,["conditionName","condition_name",true,Hn(Sn,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Bn],Un]};function qn(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let l=r,i={};for(let[t,r,o,a]of Vn[e]){let e=l[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(i[r]=null);continue}let s=a(`${n}.${t}`,e);if(s!==null)return{error:s};i[r]=e}let o=i.start_date,a=i.end_date;return typeof o=="string"&&typeof a=="string"&&a<o?{error:`${n}.endDate must not be before startDate`}:{item:i}}function Gn(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>kn)return{error:`${e} has ${t.length} items; the server accepts at most ${kn}`};let r=[],n=/* @__PURE__ */new Set;for(let l=0;l<t.length;l+=1){let i=qn(e,l,t[l]);if("error"in i)return i;let o=i.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(i.item)}return{items:r}}function Kn(e,t){let r=e,n={};for(let[e,t]of On){let l=r[e];if(l!==void 0){if(l!==null){let t=Wn[e](e,l);if(t!==null)return{error:t}}n[t]=l}}let l=r.birthDate!==void 0,i=r.birthDatePrecision!==void 0;if(l!==i||l&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of An){let l=r[e];if(l===void 0)continue;let i=Gn(e,l);if("error"in i)return i;n[t]=i.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}var Yn=e=>typeof e=="string"?e:null,Qn=(e,t)=>typeof t=="string"&&e.has(t)?t:null,Zn=e=>typeof e=="boolean"?e:null;function Jn(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function Xn(e){let t=Yn(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Yn(e.ref),name:t,dose:Yn(e.dose),frequency:Yn(e.frequency),startDate:Yn(e.start_date),endDate:Yn(e.end_date),notes:Yn(e.notes)})}function el(e){let t=e.profile_version;/* @__PURE__ */
17
- return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:Qn(zn,e.sex),spayedNeutered:Zn(e.spayed_neutered),birthDate:Yn(e.birth_date),birthDatePrecision:Qn(In,e.birth_date_precision),activityLevel:Qn(Pn,e.activity_level),indoorOutdoor:Qn(Fn,e.indoor_outdoor),foodBrand:Yn(e.food_brand),foodType:Yn(e.food_type),microchipId:Yn(e.microchip_id),allergies:Jn(e.allergies,e=>{let t=Yn(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Yn(e.ref),allergen:t,severity:Qn(Ln,e.severity),notes:Yn(e.notes)})}),medications:Jn(e.medications,Xn),supplements:Jn(e.supplements,Xn),conditions:Jn(e.conditions,e=>{let t=Yn(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Yn(e.ref),conditionName:t,diagnosedDate:Yn(e.diagnosed_date),notes:Yn(e.notes)})})})}var tl=100,rl=50,nl=100,ll=50,il=500,ol=128,al=6e4;function sl(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function ul(e,t,r){if(typeof t!="string")return sl(`${e} must be a string`);let n=vn(t);return n<=r?null:sl(`${e} is ${n} characters; the server accepts at most ${r}`)}function dl(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:sl(`${e} must be a finite number between 0 and ${r}`)}function cl(petRef,e){if(typeof petRef!="string")return sl("pet_ref must be a string");if(petRef.trim().length===0)return sl("pet_ref must not be blank");if(mn(petRef))return sl("pet_ref contains an unpaired surrogate and cannot be encoded");if(e!=null&&typeof e!="object")return sl("profile must be an object");let t=[ul("pet_ref",petRef,ol)];return e?.name!==void 0&&t.push(ul("name",e.name,tl)),e?.species!==void 0&&t.push(ul("species",e.species,rl)),e?.breed!==void 0&&t.push(ul("breed",e.breed,nl)),e?.ageYears!==void 0&&t.push(dl("age_years",e.ageYears,ll)),e?.weightKg!==void 0&&t.push(dl("weight_kg",e.weightKg,il)),t.find(e=>e!==null)??null}function pl(e,t){let r=Kn(e,t);return"error"in r?{error:sl(r.error)}:r}function fl(e){if(typeof e!="object"||e===null)return{error:sl("patch must be an object")};let t=e,r=[["name","name",e=>ul("name",e,tl)],["species","species",e=>ul("species",e,rl)],["breed","breed",e=>ul("breed",e,nl)],["ageYears","age_years",e=>dl("age_years",e,ll)],["weightKg","weight_kg",e=>dl("weight_kg",e,il)]],n={};for(let[e,l,i]of r){let r=t[e];if(r!==void 0){if(r!==null){let e=i(r);if(e!==null)return{error:e}}n[l]=r}}let l=pl(t,t.species);return"error"in l?l:(Object.assign(n,l.body),Object.keys(n).length===0?{error:sl("patch must change at least one field")}:{body:n})}function hl(e){if(e==null)return{body:{}};let t=pl(e,e.species);return"error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}var gl=e=>typeof e=="string"?e:null,bl=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function yl(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
18
- return Object.freeze({petRef:gl(t.pet_ref)??petRef,name:gl(t.name),species:gl(t.species),breed:gl(t.breed),ageYears:bl(t.age_years),weightKg:bl(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=gl(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:gl(t.pet_id),petRef:petRef,name:gl(t.name),species:gl(t.species),breed:gl(t.breed),ageYears:bl(t.age_years),weightKg:bl(t.weight_kg),updatedAt:gl(t.updated_at)})}function ml(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...el(e)})}function vl(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];/* @__PURE__ */
19
- return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return wl(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:al}))}function wl(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>cl(petRef,void 0)??`/widget/v1/pets/${encodeURIComponent(petRef)}`;return{async list(t){let n=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},t?.signal));return n.ok?ok(vl(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=cl(petRef,t);if(n!==null)return err(n);let l=hl(t);if("error"in l)return err(l.error);let i={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(petRef)}`,body:l.body},o=await e.send("pets.registerPet",r?.signal?{...i,signal:r.signal}:i);return o.ok?ok(yl(o.value,petRef)):err(o.error)},async updatePet(petRef,t,l){let i=n(petRef);if(typeof i!="string")return err(i);let o=fl(t);if("error"in o)return err(o.error);let a=await e.send("pets.updatePet",r({method:"PATCH",path:i,body:o.body},l?.signal));return a.ok?ok(yl(a.value,petRef)):err(a.error)},async getPetProfile(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.getPetProfile",r({method:"GET",path:`${l}/profile`},t?.signal));if(!i.ok)return err(i.error);let o=ml(i.value);return o===null?err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):ok(o)},async deletePet(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.deletePet",r({method:"DELETE",path:l},t?.signal));return i.ok?ok(void 0):err(i.error)},async eraseUserData(e){let n=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},e?.signal),{maxAttempts:1});return n.ok?ok(void 0):err(n.error)}}}var kl=/* @__PURE__ */new WeakMap,Cl=/* @__PURE__ */new Map;function Sl(e,t,petRef,r){let n=kl.get(e);if(n===void 0)return null;let l;if(t.mode==="personalized"&&typeof t.userRef=="string")l=`u:${t.userRef}`;else if(t.mode==="anonymous"&&typeof t.sessionId=="string")l=`a:${t.sessionId}|${t.userRef??""}`;else return null;return`${n}|${l}|${petRef}|${Rl(r)}`}function xl(e,t){if(e===null)return t();let r=Cl.get(e);if(r!==void 0)return r;let n=t().finally(()=>{Cl.get(e)===n&&Cl.delete(e)});return Cl.set(e,n),n}function Rl(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(Rl).join(",")}]`:`{${Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:e>t?1:0).map(([e,t])=>`${JSON.stringify(e)}:${Rl(t)}`).join(",")}}`}var _l="pet_not_registered";function Tl(e){return e!=null&&e.reasonCode===_l}var zl=/* @__PURE__ */Object.freeze({status:"idle",error:null,registered:null,retry:()=>{}});function Il(petRef,e,t){let{runtime:a,userRef:userRef,scopeEpoch:s}=Oe(),u=r((e,t)=>{let r=a.registry.services.authFor(userRef);return xl(Sl(a,r,e,t),()=>createPetsRepository(r).registerPet(e,t))},[a,userRef,s]),d=n(()=>e===void 0?null:Rl(e),[e]),[c,p]=i({key:null,status:"idle",error:null,registered:null}),f=l(0),h=l(t);h.current=t;let g=petRef===null||d===null?null:`${String(userRef)}|${s}|${petRef}|${d}`,b=r(()=>{if(petRef===null||e===void 0||g===null)return;let t=++f.current;p({key:g,status:"registering",error:null,registered:null}),u(petRef,e).then(e=>{t===f.current&&(e.ok?(p({key:g,status:"registered",error:null,registered:e.value}),h.current?.()):p({key:g,status:"failed",error:e.error,registered:null}))})},[u,petRef,g]);o(()=>{if(g===null){f.current+=1;return}return b(),()=>{f.current+=1}},[g,b]);let y=r(()=>{c.status==="failed"&&b()},[c.status,b]);return n(()=>g===null?zl:c.key!==g?{status:"registering",error:null,registered:null,retry:y}:{status:c.status,error:c.error,registered:c.registered,retry:y},[g,c,y])}var Pl=/* @__PURE__ */Object.freeze({});function Fl(e){let[t,a]=i(Pl),s=l(null),u=l([]);u.current=e.map(e=>e.id),o(()=>{if(e.length===0){s.current=null,a(e=>e===Pl?e:Pl);return}let t=s.current;if(t===null)return;let r=e.find(e=>e.role==="user"&&!t.known.has(e.id));r!==void 0&&(s.current=null,a(e=>({...e,[r.id]:t.images})))},[e]);let d=r(e=>{s.current=e.length===0?null:{images:e,known:new Set(u.current)}},[]);return n(()=>({byMessage:t,stage:d}),[t,d])}var Ll=/* @__PURE__ */new WeakSet;function El(){let e=makeEverfurError("internalError",{retryable:true});return Ll.add(e),err(e)}function Ol(e){if(typeof e!="object"||e===null||e.ok!==false)return false;let t=e.error;return typeof t=="object"&&t!==null&&Ll.has(t)}var Al=500;function jl(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,Al):null}function Dl(e,t,r,n){let i=jl(r),a=i===null?null:n!==void 0?`key:${String(n)}`:`prompt:${i}`,s=l(e);s.current=e;let u=l(null),d=l(null),c=l(a);c.current=a,o(()=>{if(i===null||a===null||t||u.current===a||d.current===a)return;let e=s.current;if(e===void 0)return;d.current=a;let r=e=>{d.current===a&&(d.current=null),!Ol(e)&&c.current===a&&(u.current=a)};Promise.resolve(e(i)).then(r,()=>r(void 0))},[i,a,t,e])}var Ml=/* @__PURE__ */Object.freeze({openUnreadHead:true,reportLoadFailures:true}),Bl=/* @__PURE__ */Object.freeze({reportLoadFailures:true}),Hl=/* @__PURE__ */Object.freeze({...Ml,markRead:true}),Wl=/* @__PURE__ */Object.freeze({...Bl,markRead:true});function Nl(e,t){return e?t?Hl:Ml:t?Wl:Bl}function Ul(e,t){let r=e?.isVisible===void 0?t:e.isVisible.bind(e);return r===void 0?true:Lr(()=>r()!==!1)===true}function $l(e,t){let r=l({target:e,isVisible:t});r.current={target:e,isVisible:t};let n=l(e.isStreaming);o(()=>{let t=n.current;if(n.current=e.isStreaming,!t||e.isStreaming)return;let{target:l,isVisible:i}=r.current;l.status!=="complete"||l.conversationId===null||l.unreadCount===null||!i()||l.markRead()},[e.isStreaming])}function Vl(e,conversationId,t){if(e==="announced")return false;let r=t.lastRefresh;return r===null||r.conversationId!==conversationId?false:t.now-r.at<15e3}function ql(e,t){let conversationId=t.activeConversationId===null||t.activeConversationId.length===0?null:t.activeConversationId;return conversationId===null&&t.refreshesBlankThread!==true?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:Vl(e,conversationId,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:conversationId}}var Gl=3e5;function Kl(e){if(e===null||typeof e!="object"||e.ok!==false)return false;let t=e.error;if(t===null||typeof t!="object")return false;if(t.category==="rateLimit"||t.category==="server")return true;let r=t.httpStatus;return typeof r=="number"&&(r===429||r>=500)}function Yl(e,t,r){let n=l(t);n.current=t;let i=l(null),a=l(null),s=l(false),u=l(0),d=l(0),c=l(3e4),p=()=>e?.isOffline===void 0?false:Lr(()=>e.isOffline?.()===!0)===true,f=p(),h=l(()=>{});h.current=e=>{let{conversationId:conversationId,isTurnInFlight:t,refresh:r,refreshesBlankThread:l}=n.current,o=ql(e,{activeConversationId:conversationId,isTurnInFlight:t,refreshesBlankThread:l===true,isOffline:p(),lastRefresh:i.current,now:Date.now()});if(o.action==="skip")return;if(o.action==="defer"){a.current!=="announced"&&(a.current=e);return}if(s.current){if(e==="poll")return;a.current!=="announced"&&(a.current=e);return}if(a.current=null,i.current={conversationId:o.conversationId,at:Date.now()},r===void 0)return;s.current=true;let f=e=>{s.current=false,Kl(e)?(u.current=Math.min(u.current===0?c.current*2:u.current*2,Gl),d.current=Date.now()+u.current):(u.current=0,d.current=0);let t=a.current;t!==null&&h.current(t)};Promise.resolve(r()).then(f,()=>f({ok:false,error:{category:"server"}}))},o(()=>{if(t.isTurnInFlight||f)return;let e=a.current;e!==null&&h.current(e)},[t.isTurnInFlight,f]),o(()=>{if(e===void 0)return;let t=[],r=(e,r)=>{if(e===void 0)return;let n=Lr(()=>e(()=>{h.current(r)}));typeof n=="function"&&t.push(n)};return r(e.onForeground?.bind(e),"foreground"),r(e.onOnline?.bind(e),"foreground"),r(e.onAnnounced?.bind(e),"announced"),()=>{for(let e of t)Lr(e)}},[e]);let g=r?.intervalMs??null,b=r?.isVisibleFallback;o(()=>{if(e===void 0||g===null||!Number.isFinite(g)||g<=0)return;c.current=g;let t=setInterval(()=>{Date.now()<d.current||Ul(e,b)&&h.current("poll")},g);return()=>clearInterval(t)},[e,g,b])}var Ql=/^efch_[A-Za-z0-9_-]{43}$/,Zl="efch";function Jl(e){return typeof e=="string"&&Ql.test(e)}function chatHandoffTokenFromUrl(e){if(typeof e!="string")return null;let t=e.indexOf("#");if(t<0)return null;for(let r of e.slice(t+1).split("&")){if(!r.startsWith(`${Zl}=`))continue;let e=r.slice(Zl.length+1);return Jl(e)?e:null}return null}var Xl=/* @__PURE__ */Object.freeze(["better","same","worse"]),ei=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var ti="checkin",ri=/^\d{4}-\d{2}-\d{2}$/,ni="watching";function isCheckinSettled(e){return e.status!=null&&e.status!==ni}function li(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,l]=t;return r!==ti||n===void 0||l===void 0||!ei.test(n)||!ri.test(l)?null:{caseId:n,dueDay:l}}function ii(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)}function oi(e,t,r){return makeEverfurError(e,{retryable:t,...{}})}var ai=128,si=/[\u0000-\u001f\u007f]/;function ui(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function di(e){return typeof e!="string"||e.length===0||e.length>ai||si.test(e)||e.includes("://")?null:e}function ci(e){if(e===null)return null;let conversationId=e.conversation_id,petRef=di(e.pet_ref);return typeof conversationId!="string"||!ii(conversationId)||petRef===null?null:{conversationId:conversationId,petRef:petRef}}function pi(e,t,r){return Jl(t)?createRequestFunnel({auth:e,...r?{errorPolicy:r}:{}}).send("chat.redeemHandoff",{method:"POST",path:"/widget/v1/chat/handoffs/redeem",body:{token:t}},{maxAttempts:1}).then(e=>e.ok?ok(ci(ui(e.value))):e.error.httpStatus===404?ok(null):err(e.error),()=>err(oi("internalError",false))):Promise.resolve(ok(null))}function fi(e,t){let r=t?.runtime??null,userRef=t?.userRef??null,n=Jl(e)?e:null,l=n===null||userRef===null?null:`${String(userRef)}|${n}`,[a,s]=i(null);return o(()=>{if(l===null||n===null||userRef===null||r===null)return;let e=true,t=r.registry.services;return pi(t.authFor(userRef),n,t.errorPolicy).then(t=>{!e||!t.ok||t.value===null||s({key:l,target:/* @__PURE__ */Object.freeze({kind:"chat",conversationId:t.value.conversationId,petRef:t.value.petRef})})}),()=>{e=false}},[l,r,n,userRef]),a!==null&&a.key===l?a.target:void 0}function hi(e){if(e===void 0)return null;let conversationId=e.conversationId??"",petRef=e.petRef??"";return conversationId===""&&petRef===""?null:`${String(conversationId)}|${String(petRef)}`}function gi(e,t,r){let n=hi(t),i=t?.kind==="chat",a=t?.petRef??null,s=i&&!r.pinned&&a!==null&&r.petRef!==null&&a!==r.petRef,u=l({openCheckin:e,target:t,selectPet:r.selectPet});u.current={openCheckin:e,target:t,selectPet:r.selectPet};let d=l(null),c=l(null),petRef=r.petRef;o(()=>{if(n===null||d.current===n)return;let{openCheckin:e,target:t,selectPet:l}=u.current;if(s&&a!==null){if(c.current?.key!==n){c.current={key:n,from:petRef},l(a);return}petRef!==c.current.from&&(d.current=n);return}i&&!r.ready||(d.current=n,!(e===void 0||t===void 0)&&Promise.resolve(e(t)).catch(()=>{}))},[n,i,s,a,petRef,r.ready])}var bi=/* @__PURE__ */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…",loadFailed:"Couldn’t load your chats",loadingMore:"Loading more…",untitled:"New conversation",newChat:"New chat",searchPlaceholder:"Search chats…",search:"Search chats",countLabel:"Chats and vet messages",countSeparator:" · ",newReply:"New reply · {date}",retry:"Try again",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages…",openConversation:"Open conversation",unreadPrefix:"Unread. "});function yi(e){let t=e?.replace(/\s+/g," ").trim();return t||bi.untitled}function mi(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}function vi(e){let t=mi(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?bi.newReply.replace("{date}",t):t}function wi(e,t){return t?`${bi.countLabel}${bi.countSeparator}${e}`:bi.countLabel}function ki(e){return`${e.unreadCount!==null&&e.unreadCount>0?bi.unreadPrefix:""}${bi.openConversation} ${yi(e.title)}`}function Ci(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}function Si(e,t){let r=Ci(t);if(r.length===0)return e;let n=[[],[],[]];for(let t of e){let e=Ci(yi(t.title)),l=e.indexOf(r);if(l<0)continue;let i=l===0?0:e.charAt(l-1)===" "?1:2;n[i]?.push(t)}return n.flat()}function xi(e){return{scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}function Ri(e){let[t,a]=i(false),[s,u]=i(""),d=e.listConversations,c=l(0),[p,f]=i(()=>xi(d)),h=p.scope===d?p:xi(d);o(()=>(c.current+=1,a(false),u(""),f(xi(d)),()=>{c.current+=1}),[d]);let g=r(async t=>{let r=++c.current,n=t!==void 0;f(e=>({...e,scope:d,loading:!n,loadingMore:n,error:null}));let l=await e.listConversations(t?{cursor:t}:void 0);if(r===c.current){if(!l.ok){f(e=>({...e,loading:false,loadingMore:false,error:l.error.displayMessage}));return}f(e=>{let r=t&&e.scope===d?e.rows:[],n=new Set(r.map(e=>e.id));return{scope:d,loading:false,loadingMore:false,error:null,rows:[...r,...l.value.conversations.filter(e=>!n.has(e.id))],cursor:l.value.nextCursor===t?null:l.value.nextCursor}})}},[e.listConversations,d]),b=()=>{a(true),u(""),g()},y=()=>{c.current+=1,a(false)},m=async t=>{let r=++c.current;f(e=>({...e,loading:true,error:null}));let n=await e.resumeConversation(t);r===c.current&&(f(e=>({...e,loading:false,error:n.ok?null:n.error.displayMessage})),n.ok&&a(false))},v=async()=>{let t=c.current,r=await e.loadOlderMessages();t===c.current&&!r.ok&&f(e=>({...e,error:r.error.displayMessage}))},w=()=>{e.newConversation(),c.current+=1,a(false)},k=()=>{h.cursor===null||h.loading||h.loadingMore||s.trim().length>0||g(h.cursor)},C=n(()=>Si(h.rows,s),[h.rows,s]),S=s.trim().length>0;return{...h,open:t,show:b,close:y,load:g,resume:m,earlier:v,newConversation:w,loadMore:k,query:s,setQuery:u,searching:S,filtered:C,emptyKind:h.rows.length===0?"empty":"noMatch"}}var _i="#111111",Ti="#FFFFFF",zi=/* @__PURE__ */Object.freeze({emergency:/* @__PURE__ */Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:_i,pillColor:Ti,showsVetAction:true}),schedule_soon:/* @__PURE__ */Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:_i,pillColor:Ti,showsVetAction:true}),home_care:/* @__PURE__ */Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:_i,pillColor:Ti,showsVetAction:false}),general:/* @__PURE__ */Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:_i,pillColor:Ti,showsVetAction:false})});function Ii(e){return`${e.messageId}:${e.level}:${e.reason??""}`}function Pi(e){return _e(Re.urgencyGeneralReason,{petName:e?.trim()||Re.emptyTitlePetFallback})}function Fi(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 l=n.urgencyLevel;return l?{messageId:n.id,level:l,reason:Li(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:Pi(t)}:null}return null}function Li(e){return typeof e=="string"&&e.trim().length>0?e:null}function Ei(e){let t=e===null?null:Ii(e),[l,a]=i(null),[s,u]=i(false);o(()=>u(false),[t]);let d=e!==null&&(s||!(l!==null&&l===t)),c=e===null?null:zi[e.level],p=e!==null&&!d&&e.level!=="general",f=r(()=>{t!==null&&a(t),u(false)},[t]),h=r(()=>u(true),[]);return n(()=>({source:e,tier:c,signature:t,showBanner:d,showCompactIcon:p,showVetAction:d&&c!==null&&c.showsVetAction,dismissLabel:c===null?null:_e(Re.dismissBanner,{label:c.label}),dismiss:f,expand:h}),[e,c,t,d,p,f,h])}var Oi=class extends u{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(e,t){return Object.is(e.resetKey,t.key)?null:{failed:false,key:e.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:e}){return e()}function HostRender({render:e,fallback:r,resetKey:n}){return t(Oi,{fallback:r,resetKey:n,children:t(RenderHost,{render:e})})}var Ai=48;function ji(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(e){let{capability:t,children:r,renderDisabled:l,renderPending:i,style:o}=e,a=useCapability(t),s=n(()=>ji(a),[a]);switch(s){case"enabled":return r;case"pending":return i?/* @__PURE__ */E(HostRender,{render:i,fallback:/* @__PURE__ */E(PendingSkeleton,{capability:t,style:o})}):/* @__PURE__ */E(PendingSkeleton,{capability:t,style:o});case"disabled":return l?/* @__PURE__ */E(HostRender,{render:()=>l(a),fallback:/* @__PURE__ */E(OffState,{decision:a,style:o}),resetKey:a}):/* @__PURE__ */E(OffState,{decision:a,style:o});default:return assertNever(s)}}function PendingSkeleton({capability:e,style:t}){let r=useEverfurTheme(),l=n(()=>Di(r),[r]);/* @__PURE__ */
20
- return E(b,{style:[l.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:/* @__PURE__ */E(b,{style:l.skeletonBar})})}function OffState({decision:e,style:t}){let r=useEverfurTheme(),l=n(()=>Di(r),[r]),i=e.disabled?.reason??"";/* @__PURE__ */
21
- return E(b,{style:[l.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:i,children:i.length>0?/* @__PURE__ */E(Text,{style:l.offstateText,children:i}):null})}function Di(e){let{color:t,space:r,radius:n,type:l}=e;return p.create({offstate:{minHeight:Ai,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:p.hairlineWidth,borderColor:t.brandBorder},offstateText:{...face(e,"regular"),fontSize:l.size.body,lineHeight:Math.round(l.size.body*l.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}var Mi="everfur.com",Bi=2048,Hi=/^(\*\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function Wi(e){if(!Array.isArray(e))return[];let t=/* @__PURE__ */new Set;for(let r of e){if(typeof r!="string")continue;let e=r.trim().toLowerCase();e.length<=253&&Hi.test(e)&&t.add(e)}/* @__PURE__ */
22
- return Object.freeze([...t])}function Ni(e,t){if(e===Mi||e.endsWith(`.${Mi}`))return true;for(let r of t)if(r.startsWith("*.")?e.endsWith(r.slice(1)):e===r)return true;return false}function Ui(e,t){if(typeof e!="string"||e.length===0||e.length>Bi||!/^https:\/\//i.test(e))return null;let r=ft(e);return r===null||r.protocol!=="https:"||r.username!==""||r.password!==""||r.port!==""?null:Ni(r.hostname,t)?r.href:null}function $i(e){try{Promise.resolve(y.openURL(e)).catch(()=>{})}catch{}}var Vi=createContext(null);function qi(){return s(Vi)??void 0}function MessageLinksScope({linkHosts:e,onOpenUrl:r,children:l}){let i=e===false?null:Array.isArray(e)?e.join(`\n`):"",o=n(()=>{if(i===null)return null;let e=Wi(i===""?[]:i.split(`\n`));/* @__PURE__ */
23
- return Object.freeze({hosts:e,open:r!==void 0?e=>{Lr(r,e,"message")}:$i})},[i,r]);return t(Vi.Provider,{value:o},l)}var Gi={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function Ki(e){return{width:e,height:e,alignItems:"center",justifyContent:"center"}}function Yi(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}function MenuGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r),l={width:e*.82,height:n,borderRadius:n,backgroundColor:t};/* @__PURE__ */
24
- return O(b,{style:[Ki(e),{gap:e*.22}],...Gi,children:[
25
- /* @__PURE__ */E(b,{style:l}),
26
- /* @__PURE__ */E(b,{style:l}),
27
- /* @__PURE__ */E(b,{style:l})]})}function Cross({size:e,color:t,strokeWidth:r,rotate:n}){let l=Yi(e,r),i=e*.78;/* @__PURE__ */
28
- return O(b,{style:[Ki(e),{transform:[{rotate:n}]}],...Gi,children:[
29
- /* @__PURE__ */E(b,{style:{position:"absolute",width:i,height:l,borderRadius:l,backgroundColor:t}}),
30
- /* @__PURE__ */E(b,{style:{position:"absolute",width:l,height:i,borderRadius:l,backgroundColor:t}})]})}function PlusGlyph(e){/* @__PURE__ */
14
+ return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function ln(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:/* @__PURE__ */Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),/* @__PURE__ */Object.freeze(t)}function useCapability(e){let{runtime:t}=Ge(),r=t.entitlements,l=a(r.subscribe,r.getSnapshot,r.getSnapshot);return n(()=>decideCapability(e,l.decisions,{isPending:l.isPending}),[e,l])}function on(e){let{runtime:t}=Ge(),n=t.entitlements,l=r(e=>n===void 0?()=>{}:n.subscribe(e),[n]),i=r(()=>{if(n===void 0)return false;let t=n.getSnapshot();return decideCapability(e,t.decisions,{isPending:t.isPending}).enabled},[n,e]);return a(l,i,i)}var an=()=>()=>{},sn=()=>null;function un(e,t){return a(t?.subscribe??an,t?.get??sn,t?.get??sn)??e}var dn=/* @__PURE__ */Object.freeze({branding:null}),cn=/* @__PURE__ */Object.freeze({subscribe:()=>()=>{},getSnapshot:()=>dn});function pn(e){return e?Object.keys(e).sort().map(t=>`${t}=${String(e[t])}`).join("&"):""}function fn(e){let{runtime:t}=Ge(),l=t?.entitlements??cn,i=r(()=>l.getSnapshot()?.branding??null,[l]),o=un(a(l.subscribe,i,i),t?.sdkConfigHost?.branding),s=pn(e);return n(()=>{let t=o?.lockedFields??null;return{presentation:resolvePresentation({server:o?.presentation??null,locked:t,client:e??null}),isLocked:e=>isPresentationFieldLocked(e,t)}},[o,s])}function hn(e){let t={};for(let[r,n]of Object.entries(e))n!==void 0&&(t[r]=n);return t}function gn(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}function bn(e){let t=Rt(e);return t===null?null:{reached:Me.capReached.replace("{cap}",String(t.limit)),guidance:t.emergencyGuidance??null}}function yn(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}function mn(e,t="native"){if(e.messages.length===0)return null;let r=e.status==="error"?e.error:null;if(r!==null){let e=yn(r),n=t==="web",l=bn(r);return{tone:"error",title:l!==null?l.reached:e?Me.turnUnreachableTitle:n?Me.turnFailedTitleWeb:Me.turnFailedTitle,body:r.displayMessage,actionLabel:e?Me.turnStartNewChat:n?Me.retry:Me.turnRetry,action:e?"startNew":"retry",...l!==null&&l.guidance!==null?{guidance:l.guidance}:{}}}return e.stopped===true?{tone:"neutral",title:Me.turnStoppedTitle,body:Me.turnStoppedBody,actionLabel:Me.turnRetry,action:"retry"}:null}function vn(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}var wn=3,kn=/* @__PURE__ */Object.freeze([]);function Cn(e){let t=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||t===void 0||t.role!=="assistant")return kn;let r=/* @__PURE__ */new Set,n=[];for(let t of e.suggestedPrompts){let e=t.trim(),l=e.replace(/\s+/g," ").toLowerCase();if(!(l.length===0||r.has(l))&&(r.add(l),n.push(e),n.length===wn))break}/* @__PURE__ */
15
+ return Object.freeze(n)}var Sn=5;function xn(e,t){if(e===void 0)return false;if(typeof e=="function")try{return e(t)===!0}catch{return false}return e.lastIndex=0,e.test(t)}function Rn(e,t){if(t===void 0)return Cn(e);let r=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||r===void 0||r.role!=="assistant")return kn;let n=Math.max(1,Math.min(Sn,Math.floor(t.count??wn))),l=null;for(let t=e.messages.length-1;t>=0;t-=1){let r=e.messages[t];if(r!==void 0&&r.role==="user"){l=r.text;break}}let i=e=>e.trim().replace(/\s+/g," ").toLowerCase(),o=new Set(l===null?[]:[i(l)]),a=[],s=e=>{let r=e.trim(),l=i(r);a.length>=n||l.length===0||o.has(l)||xn(t.exclude,r)||(o.add(l),a.push(r))};for(let t of e.suggestedPrompts)s(t);let u=[];try{u=typeof t.fill=="function"?t.fill(l):t.fill??[]}catch{u=[]}for(let e of Array.isArray(u)?u:[])typeof e=="string"&&s(e);/* @__PURE__ */
16
+ return Object.freeze(a)}function Tn(e){return e.sender?.displayName??Me.senderVet}function _n(petRef,conversationId){let e={};return petRef!==void 0&&(e.petRef=petRef),conversationId!==void 0&&(e.conversationId=conversationId),e}var zn=new RegExp([String.raw`\b(book|booking|schedule|scheduling|arrange|set\s+up)\s+(an?\s+|the\s+|her\s+|his\s+|their\s+|my\s+|your\s+)?(next\s+)?((vet|veterinary|video|virtual|televet|follow-up|follow up)\s+)?(visit|appointment|appt|consult|consultation|call|vet|checkup|check-up|exam)\b`,String.raw`\bmake\s+(an?\s+|the\s+)?((vet|veterinary|video|virtual|follow-up|follow up)\s+)?(appointment|appt)\b`,String.raw`\bneed\s+(an?\s+)?((vet|veterinary|video|virtual)\s+)?(appointment|appt|visit|consult|consultation)\b`,String.raw`\b(video|virtual)\s+(visit|appointment|appt|consult|consultation|call)s?\b`,String.raw`\b(televet|telehealth|telemedicine)\b`,String.raw`\b(talk|speak|chat)\s+(to|with)\s+(an?|the|your|my)\s+vet\b`,String.raw`\bsee\s+(an?|the|your|my)\s+vet\b`].join("|"),"i"),NONE=()=>true;function In(e,t){if(e===void 0)return false;if(typeof e=="function")try{return e(t)===!0}catch{return false}return e.lastIndex=0,e.test(t)}function Pn(e,t,r){let n=t.chatFollowUpsExcludeTelevet,l=e?.count!==void 0&&!r?e.count:t.chatFollowUpCount;if(e===void 0&&l===wn&&!n)return;if(l<=0)return{...e??{},count:1,exclude:NONE,fill:[]};let i=e?.exclude,o=n?e=>zn.test(e)||In(i,e):i;return{...e??{},count:l,...o!==void 0?{exclude:o}:{}}}function Fn(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function Ln(e){return[...e].length}var En=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(En,t)?En[t]:null}var On=50,An=128,jn=120,Dn=120,Mn=2e3,Bn=120,Hn=80,Wn=/* @__PURE__ */new Set(["male","female","unknown"]),Nn=/* @__PURE__ */new Set(["day","month","year"]),Un=/* @__PURE__ */new Set(["low","medium","high","athletic"]),$n=/* @__PURE__ */new Set(["indoor","outdoor","both"]),Vn=/* @__PURE__ */new Set(["mild","moderate","severe"]),qn=/^(\d{4})-(\d{2})-(\d{2})$/,Gn=[["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"]],Kn=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...Gn,...Kn].map(([e])=>e));function Yn(e){let t=qn.exec(e);if(t===null)return false;let[r,n,l]=[Number(t[1]),Number(t[2]),Number(t[3])],i=new Date(Date.UTC(r,n-1,l));return i.getUTCFullYear()===r&&i.getUTCMonth()===n-1&&i.getUTCDate()===l}var Qn=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,Zn=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,Jn=(e,t)=>typeof t=="string"&&Yn(t)?null:`${e} must be a real date written YYYY-MM-DD`,Xn=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(Fn(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let l=t.trimmed?n.trim():n;if(t.required&&l.length===0)return`${r} is required and must not be blank`;let i=Ln(l);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},el={sex:Qn(Wn),spayedNeutered:Zn,birthDate:Jn,birthDatePrecision:Qn(Nn),activityLevel:Qn(Un),indoorOutdoor:Qn($n),foodBrand:Xn(Bn),foodType:Xn(Bn),microchipId:Xn(Hn)},tl=["ref","ref",false,Xn(An,{required:true,trimmed:true})],rl=["notes","notes",false,Xn(Mn,{trimmed:true})],nl=[tl,["name","name",true,Xn(jn,{required:true,trimmed:true})],["dose","dose",false,Xn(Dn,{trimmed:true})],["frequency","frequency",false,Xn(Dn,{trimmed:true})],["startDate","start_date",false,Jn],["endDate","end_date",false,Jn],rl],ll={allergies:[tl,["allergen","allergen",true,Xn(jn,{required:true,trimmed:true})],["severity","severity",false,Qn(Vn)],rl],medications:nl,supplements:nl,conditions:[tl,["conditionName","condition_name",true,Xn(jn,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Jn],rl]};function il(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let l=r,i={};for(let[t,r,o,a]of ll[e]){let e=l[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(i[r]=null);continue}let s=a(`${n}.${t}`,e);if(s!==null)return{error:s};i[r]=e}let o=i.start_date,a=i.end_date;return typeof o=="string"&&typeof a=="string"&&a<o?{error:`${n}.endDate must not be before startDate`}:{item:i}}function ol(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>On)return{error:`${e} has ${t.length} items; the server accepts at most ${On}`};let r=[],n=/* @__PURE__ */new Set;for(let l=0;l<t.length;l+=1){let i=il(e,l,t[l]);if("error"in i)return i;let o=i.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(i.item)}return{items:r}}function al(e,t){let r=e,n={};for(let[e,t]of Gn){let l=r[e];if(l!==void 0){if(l!==null){let t=el[e](e,l);if(t!==null)return{error:t}}n[t]=l}}let l=r.birthDate!==void 0,i=r.birthDatePrecision!==void 0;if(l!==i||l&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of Kn){let l=r[e];if(l===void 0)continue;let i=ol(e,l);if("error"in i)return i;n[t]=i.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}var sl=e=>typeof e=="string"?e:null,ul=(e,t)=>typeof t=="string"&&e.has(t)?t:null,dl=e=>typeof e=="boolean"?e:null;function cl(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function pl(e){let t=sl(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:sl(e.ref),name:t,dose:sl(e.dose),frequency:sl(e.frequency),startDate:sl(e.start_date),endDate:sl(e.end_date),notes:sl(e.notes)})}function fl(e){let t=e.profile_version;/* @__PURE__ */
17
+ return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:ul(Wn,e.sex),spayedNeutered:dl(e.spayed_neutered),birthDate:sl(e.birth_date),birthDatePrecision:ul(Nn,e.birth_date_precision),activityLevel:ul(Un,e.activity_level),indoorOutdoor:ul($n,e.indoor_outdoor),foodBrand:sl(e.food_brand),foodType:sl(e.food_type),microchipId:sl(e.microchip_id),allergies:cl(e.allergies,e=>{let t=sl(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:sl(e.ref),allergen:t,severity:ul(Vn,e.severity),notes:sl(e.notes)})}),medications:cl(e.medications,pl),supplements:cl(e.supplements,pl),conditions:cl(e.conditions,e=>{let t=sl(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:sl(e.ref),conditionName:t,diagnosedDate:sl(e.diagnosed_date),notes:sl(e.notes)})})})}var hl=100,gl=50,bl=100,yl=50,ml=500,vl=128,wl=6e4;function kl(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Cl(e,t,r){if(typeof t!="string")return kl(`${e} must be a string`);let n=Ln(t);return n<=r?null:kl(`${e} is ${n} characters; the server accepts at most ${r}`)}function Sl(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:kl(`${e} must be a finite number between 0 and ${r}`)}function xl(petRef,e){if(typeof petRef!="string")return kl("pet_ref must be a string");if(petRef.trim().length===0)return kl("pet_ref must not be blank");if(Fn(petRef))return kl("pet_ref contains an unpaired surrogate and cannot be encoded");if(e!=null&&typeof e!="object")return kl("profile must be an object");let t=[Cl("pet_ref",petRef,vl)];return e?.name!==void 0&&t.push(Cl("name",e.name,hl)),e?.species!==void 0&&t.push(Cl("species",e.species,gl)),e?.breed!==void 0&&t.push(Cl("breed",e.breed,bl)),e?.ageYears!==void 0&&t.push(Sl("age_years",e.ageYears,yl)),e?.weightKg!==void 0&&t.push(Sl("weight_kg",e.weightKg,ml)),t.find(e=>e!==null)??null}function Rl(e,t){let r=al(e,t);return"error"in r?{error:kl(r.error)}:r}function Tl(e){if(typeof e!="object"||e===null)return{error:kl("patch must be an object")};let t=e,r=[["name","name",e=>Cl("name",e,hl)],["species","species",e=>Cl("species",e,gl)],["breed","breed",e=>Cl("breed",e,bl)],["ageYears","age_years",e=>Sl("age_years",e,yl)],["weightKg","weight_kg",e=>Sl("weight_kg",e,ml)]],n={};for(let[e,l,i]of r){let r=t[e];if(r!==void 0){if(r!==null){let e=i(r);if(e!==null)return{error:e}}n[l]=r}}let l=Rl(t,t.species);return"error"in l?l:(Object.assign(n,l.body),Object.keys(n).length===0?{error:kl("patch must change at least one field")}:{body:n})}function _l(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}}}var zl=e=>typeof e=="string"?e:null,Il=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function Pl(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
18
+ return Object.freeze({petRef:zl(t.pet_ref)??petRef,name:zl(t.name),species:zl(t.species),breed:zl(t.breed),ageYears:Il(t.age_years),weightKg:Il(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=zl(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:zl(t.pet_id),petRef:petRef,name:zl(t.name),species:zl(t.species),breed:zl(t.breed),ageYears:Il(t.age_years),weightKg:Il(t.weight_kg),updatedAt:zl(t.updated_at)})}function Fl(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...fl(e)})}function Ll(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];/* @__PURE__ */
19
+ return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return El(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:wl}))}function El(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>xl(petRef,void 0)??`/widget/v1/pets/${encodeURIComponent(petRef)}`;return{async list(t){let n=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},t?.signal));return n.ok?ok(Ll(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=xl(petRef,t);if(n!==null)return err(n);let l=_l(t);if("error"in l)return err(l.error);let i={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(petRef)}`,body:l.body},o=await e.send("pets.registerPet",r?.signal?{...i,signal:r.signal}:i);return o.ok?ok(Pl(o.value,petRef)):err(o.error)},async updatePet(petRef,t,l){let i=n(petRef);if(typeof i!="string")return err(i);let o=Tl(t);if("error"in o)return err(o.error);let a=await e.send("pets.updatePet",r({method:"PATCH",path:i,body:o.body},l?.signal));return a.ok?ok(Pl(a.value,petRef)):err(a.error)},async getPetProfile(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.getPetProfile",r({method:"GET",path:`${l}/profile`},t?.signal));if(!i.ok)return err(i.error);let o=Fl(i.value);return o===null?err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):ok(o)},async deletePet(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.deletePet",r({method:"DELETE",path:l},t?.signal));return i.ok?ok(void 0):err(i.error)},async eraseUserData(e){let n=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},e?.signal),{maxAttempts:1});return n.ok?ok(void 0):err(n.error)}}}var Ol=/* @__PURE__ */new WeakMap,Al=/* @__PURE__ */new Map;function jl(e,t,petRef,r){let n=Ol.get(e);if(n===void 0)return null;let l;if(t.mode==="personalized"&&typeof t.userRef=="string")l=`u:${t.userRef}`;else if(t.mode==="anonymous"&&typeof t.sessionId=="string")l=`a:${t.sessionId}|${t.userRef??""}`;else return null;return`${n}|${l}|${petRef}|${Ml(r)}`}function Dl(e,t){if(e===null)return t();let r=Al.get(e);if(r!==void 0)return r;let n=t().finally(()=>{Al.get(e)===n&&Al.delete(e)});return Al.set(e,n),n}function Ml(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(Ml).join(",")}]`:`{${Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:e>t?1:0).map(([e,t])=>`${JSON.stringify(e)}:${Ml(t)}`).join(",")}}`}var Bl="pet_not_registered";function Hl(e){return e!=null&&e.reasonCode===Bl}var Wl=/* @__PURE__ */Object.freeze({status:"idle",error:null,registered:null,retry:()=>{}});function Nl(petRef,e,t){let{runtime:a,userRef:userRef,scopeEpoch:s}=Ge(),u=r((e,t)=>{let r=a.registry.services.authFor(userRef);return Dl(jl(a,r,e,t),()=>createPetsRepository(r).registerPet(e,t))},[a,userRef,s]),d=n(()=>e===void 0?null:Ml(e),[e]),[c,p]=i({key:null,status:"idle",error:null,registered:null}),f=l(0),h=l(t);h.current=t;let g=petRef===null||d===null?null:`${String(userRef)}|${s}|${petRef}|${d}`,b=r(()=>{if(petRef===null||e===void 0||g===null)return;let t=++f.current;p({key:g,status:"registering",error:null,registered:null}),u(petRef,e).then(e=>{t===f.current&&(e.ok?(p({key:g,status:"registered",error:null,registered:e.value}),h.current?.()):p({key:g,status:"failed",error:e.error,registered:null}))})},[u,petRef,g]);o(()=>{if(g===null){f.current+=1;return}return b(),()=>{f.current+=1}},[g,b]);let y=r(()=>{c.status==="failed"&&b()},[c.status,b]);return n(()=>g===null?Wl:c.key!==g?{status:"registering",error:null,registered:null,retry:y}:{status:c.status,error:c.error,registered:c.registered,retry:y},[g,c,y])}var Ul=/* @__PURE__ */Object.freeze({});function $l(e){let[t,a]=i(Ul),s=l(null),u=l([]);u.current=e.map(e=>e.id),o(()=>{if(e.length===0){s.current=null,a(e=>e===Ul?e:Ul);return}let t=s.current;if(t===null)return;let r=e.find(e=>e.role==="user"&&!t.known.has(e.id));r!==void 0&&(s.current=null,a(e=>({...e,[r.id]:t.images})))},[e]);let d=r(e=>{s.current=e.length===0?null:{images:e,known:new Set(u.current)}},[]);return n(()=>({byMessage:t,stage:d}),[t,d])}var Vl=/* @__PURE__ */new WeakSet;function ql(){let e=makeEverfurError("internalError",{retryable:true});return Vl.add(e),err(e)}function Gl(e){if(typeof e!="object"||e===null||e.ok!==false)return false;let t=e.error;return typeof t=="object"&&t!==null&&Vl.has(t)}var Kl=500;function Yl(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,Kl):null}function Ql(e,t,r,n){let i=Yl(r),a=i===null?null:n!==void 0?`key:${String(n)}`:`prompt:${i}`,s=l(e);s.current=e;let u=l(null),d=l(null),c=l(a);c.current=a,o(()=>{if(i===null||a===null||t||u.current===a||d.current===a)return;let e=s.current;if(e===void 0)return;d.current=a;let r=e=>{d.current===a&&(d.current=null),!Gl(e)&&c.current===a&&(u.current=a)};Promise.resolve(e(i)).then(r,()=>r(void 0))},[i,a,t,e])}var Zl=/* @__PURE__ */Object.freeze({openUnreadHead:true,reportLoadFailures:true}),Jl=/* @__PURE__ */Object.freeze({reportLoadFailures:true}),Xl=/* @__PURE__ */Object.freeze({...Zl,markRead:true}),ei=/* @__PURE__ */Object.freeze({...Jl,markRead:true});function ti(e,t){return e?t?Xl:Zl:t?ei:Jl}function ri(e,t){let r=e?.isVisible===void 0?t:e.isVisible.bind(e);return r===void 0?true:Vr(()=>r()!==!1)===true}function ni(e,t){let r=l({target:e,isVisible:t});r.current={target:e,isVisible:t};let n=l(e.isStreaming);o(()=>{let t=n.current;if(n.current=e.isStreaming,!t||e.isStreaming)return;let{target:l,isVisible:i}=r.current;l.status!=="complete"||l.conversationId===null||l.unreadCount===null||!i()||l.markRead()},[e.isStreaming])}function li(e,conversationId,t){if(e==="announced")return false;let r=t.lastRefresh;return r===null||r.conversationId!==conversationId?false:t.now-r.at<15e3}function ii(e,t){let conversationId=t.activeConversationId===null||t.activeConversationId.length===0?null:t.activeConversationId;return conversationId===null&&t.refreshesBlankThread!==true?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:li(e,conversationId,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:conversationId}}var oi=3e5;function ai(e){if(e===null||typeof e!="object"||e.ok!==false)return false;let t=e.error;if(t===null||typeof t!="object")return false;if(t.category==="rateLimit"||t.category==="server")return true;let r=t.httpStatus;return typeof r=="number"&&(r===429||r>=500)}function si(e,t,r){let n=l(t);n.current=t;let i=l(null),a=l(null),s=l(false),u=l(0),d=l(0),c=l(3e4),p=()=>e?.isOffline===void 0?false:Vr(()=>e.isOffline?.()===!0)===true,f=p(),h=l(()=>{});h.current=e=>{let{conversationId:conversationId,isTurnInFlight:t,refresh:r,refreshesBlankThread:l}=n.current,o=ii(e,{activeConversationId:conversationId,isTurnInFlight:t,refreshesBlankThread:l===true,isOffline:p(),lastRefresh:i.current,now:Date.now()});if(o.action==="skip")return;if(o.action==="defer"){a.current!=="announced"&&(a.current=e);return}if(s.current){if(e==="poll")return;a.current!=="announced"&&(a.current=e);return}if(a.current=null,i.current={conversationId:o.conversationId,at:Date.now()},r===void 0)return;s.current=true;let f=e=>{s.current=false,ai(e)?(u.current=Math.min(u.current===0?c.current*2:u.current*2,oi),d.current=Date.now()+u.current):(u.current=0,d.current=0);let t=a.current;t!==null&&h.current(t)};Promise.resolve(r()).then(f,()=>f({ok:false,error:{category:"server"}}))},o(()=>{if(t.isTurnInFlight||f)return;let e=a.current;e!==null&&h.current(e)},[t.isTurnInFlight,f]),o(()=>{if(e===void 0)return;let t=[],r=(e,r)=>{if(e===void 0)return;let n=Vr(()=>e(()=>{h.current(r)}));typeof n=="function"&&t.push(n)};return r(e.onForeground?.bind(e),"foreground"),r(e.onOnline?.bind(e),"foreground"),r(e.onAnnounced?.bind(e),"announced"),()=>{for(let e of t)Vr(e)}},[e]);let g=r?.intervalMs??null,b=r?.isVisibleFallback;o(()=>{if(e===void 0||g===null||!Number.isFinite(g)||g<=0)return;c.current=g;let t=setInterval(()=>{Date.now()<d.current||ri(e,b)&&h.current("poll")},g);return()=>clearInterval(t)},[e,g,b])}var ui=/^efch_[A-Za-z0-9_-]{43}$/,di="efch";function ci(e){return typeof e=="string"&&ui.test(e)}function chatHandoffTokenFromUrl(e){if(typeof e!="string")return null;let t=e.indexOf("#");if(t<0)return null;for(let r of e.slice(t+1).split("&")){if(!r.startsWith(`${di}=`))continue;let e=r.slice(di.length+1);return ci(e)?e:null}return null}var pi=/* @__PURE__ */Object.freeze(["better","same","worse"]),fi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var hi="checkin",gi=/^\d{4}-\d{2}-\d{2}$/,bi="watching";function isCheckinSettled(e){return e.status!=null&&e.status!==bi}function yi(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,l]=t;return r!==hi||n===void 0||l===void 0||!fi.test(n)||!gi.test(l)?null:{caseId:n,dueDay:l}}function mi(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)}function vi(e,t,r){return makeEverfurError(e,{retryable:t,...{}})}var wi=128,ki=/[\u0000-\u001f\u007f]/;function Ci(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Si(e){return typeof e!="string"||e.length===0||e.length>wi||ki.test(e)||e.includes("://")?null:e}function xi(e){if(e===null)return null;let conversationId=e.conversation_id,petRef=Si(e.pet_ref);return typeof conversationId!="string"||!mi(conversationId)||petRef===null?null:{conversationId:conversationId,petRef:petRef}}function Ri(e,t,r){return ci(t)?createRequestFunnel({auth:e,...r?{errorPolicy:r}:{}}).send("chat.redeemHandoff",{method:"POST",path:"/widget/v1/chat/handoffs/redeem",body:{token:t}},{maxAttempts:1}).then(e=>e.ok?ok(xi(Ci(e.value))):e.error.httpStatus===404?ok(null):err(e.error),()=>err(vi("internalError",false))):Promise.resolve(ok(null))}function Ti(e,t){let r=t?.runtime??null,userRef=t?.userRef??null,n=ci(e)?e:null,l=n===null||userRef===null?null:`${String(userRef)}|${n}`,[a,s]=i(null);return o(()=>{if(l===null||n===null||userRef===null||r===null)return;let e=true,t=r.registry.services;return Ri(t.authFor(userRef),n,t.errorPolicy).then(t=>{!e||!t.ok||t.value===null||s({key:l,target:/* @__PURE__ */Object.freeze({kind:"chat",conversationId:t.value.conversationId,petRef:t.value.petRef})})}),()=>{e=false}},[l,r,n,userRef]),a!==null&&a.key===l?a.target:void 0}function _i(e){if(e===void 0)return null;let conversationId=e.conversationId??"",petRef=e.petRef??"";return conversationId===""&&petRef===""?null:`${String(conversationId)}|${String(petRef)}`}function zi(e,t,r){let n=_i(t),i=t?.kind==="chat",a=t?.petRef??null,s=i&&!r.pinned&&a!==null&&r.petRef!==null&&a!==r.petRef,u=l({openCheckin:e,target:t,selectPet:r.selectPet});u.current={openCheckin:e,target:t,selectPet:r.selectPet};let d=l(null),c=l(null),petRef=r.petRef;o(()=>{if(n===null||d.current===n)return;let{openCheckin:e,target:t,selectPet:l}=u.current;if(s&&a!==null){if(c.current?.key!==n){c.current={key:n,from:petRef},l(a);return}petRef!==c.current.from&&(d.current=n);return}i&&!r.ready||(d.current=n,!(e===void 0||t===void 0)&&Promise.resolve(e(t)).catch(()=>{}))},[n,i,s,a,petRef,r.ready])}var Ii=/* @__PURE__ */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…",loadFailed:"Couldn’t load your chats",loadingMore:"Loading more…",untitled:"New conversation",newChat:"New chat",searchPlaceholder:"Search chats…",search:"Search chats",countLabel:"Chats and vet messages",countSeparator:" · ",newReply:"New reply · {date}",retry:"Try again",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages…",openConversation:"Open conversation",unreadPrefix:"Unread. "});function Pi(e){let t=e?.replace(/\s+/g," ").trim();return t||Ii.untitled}function Fi(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}function Li(e){let t=Fi(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?Ii.newReply.replace("{date}",t):t}function Ei(e,t){return t?`${Ii.countLabel}${Ii.countSeparator}${e}`:Ii.countLabel}function Oi(e){return`${e.unreadCount!==null&&e.unreadCount>0?Ii.unreadPrefix:""}${Ii.openConversation} ${Pi(e.title)}`}function Ai(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}function ji(e,t){let r=Ai(t);if(r.length===0)return e;let n=[[],[],[]];for(let t of e){let e=Ai(Pi(t.title)),l=e.indexOf(r);if(l<0)continue;let i=l===0?0:e.charAt(l-1)===" "?1:2;n[i]?.push(t)}return n.flat()}function Di(e){return{scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}function Mi(e){let[t,a]=i(false),[s,u]=i(""),d=e.listConversations,c=l(0),[p,f]=i(()=>Di(d)),h=p.scope===d?p:Di(d);o(()=>(c.current+=1,a(false),u(""),f(Di(d)),()=>{c.current+=1}),[d]);let g=r(async t=>{let r=++c.current,n=t!==void 0;f(e=>({...e,scope:d,loading:!n,loadingMore:n,error:null}));let l=await e.listConversations(t?{cursor:t}:void 0);if(r===c.current){if(!l.ok){f(e=>({...e,loading:false,loadingMore:false,error:l.error.displayMessage}));return}f(e=>{let r=t&&e.scope===d?e.rows:[],n=new Set(r.map(e=>e.id));return{scope:d,loading:false,loadingMore:false,error:null,rows:[...r,...l.value.conversations.filter(e=>!n.has(e.id))],cursor:l.value.nextCursor===t?null:l.value.nextCursor}})}},[e.listConversations,d]),b=()=>{a(true),u(""),g()},y=()=>{c.current+=1,a(false)},m=async t=>{let r=++c.current;f(e=>({...e,loading:true,error:null}));let n=await e.resumeConversation(t);r===c.current&&(f(e=>({...e,loading:false,error:n.ok?null:n.error.displayMessage})),n.ok&&a(false))},v=async()=>{let t=c.current,r=await e.loadOlderMessages();t===c.current&&!r.ok&&f(e=>({...e,error:r.error.displayMessage}))},w=()=>{e.newConversation(),c.current+=1,a(false)},k=()=>{h.cursor===null||h.loading||h.loadingMore||s.trim().length>0||g(h.cursor)},C=n(()=>ji(h.rows,s),[h.rows,s]),S=s.trim().length>0;return{...h,open:t,show:b,close:y,load:g,resume:m,earlier:v,newConversation:w,loadMore:k,query:s,setQuery:u,searching:S,filtered:C,emptyKind:h.rows.length===0?"empty":"noMatch"}}var Bi="#111111",Hi="#FFFFFF",Wi=/* @__PURE__ */Object.freeze({emergency:/* @__PURE__ */Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:Bi,pillColor:Hi,showsVetAction:true}),schedule_soon:/* @__PURE__ */Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:Bi,pillColor:Hi,showsVetAction:true}),home_care:/* @__PURE__ */Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Bi,pillColor:Hi,showsVetAction:false}),general:/* @__PURE__ */Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Bi,pillColor:Hi,showsVetAction:false})});function Ni(e){return`${e.messageId}:${e.level}:${e.reason??""}`}function Ui(e){return Be(Me.urgencyGeneralReason,{petName:e?.trim()||Me.emptyTitlePetFallback})}function $i(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 l=n.urgencyLevel;return l?{messageId:n.id,level:l,reason:Vi(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:Ui(t)}:null}return null}function Vi(e){return typeof e=="string"&&e.trim().length>0?e:null}function qi(e){let t=e===null?null:Ni(e),[l,a]=i(null),[s,u]=i(false);o(()=>u(false),[t]);let d=e!==null&&(s||!(l!==null&&l===t)),c=e===null?null:Wi[e.level],p=e!==null&&!d&&e.level!=="general",f=r(()=>{t!==null&&a(t),u(false)},[t]),h=r(()=>u(true),[]);return n(()=>({source:e,tier:c,signature:t,showBanner:d,showCompactIcon:p,showVetAction:d&&c!==null&&c.showsVetAction,dismissLabel:c===null?null:Be(Me.dismissBanner,{label:c.label}),dismiss:f,expand:h}),[e,c,t,d,p,f,h])}var Gi=class extends u{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(e,t){return Object.is(e.resetKey,t.key)?null:{failed:false,key:e.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:e}){return e()}function HostRender({render:e,fallback:r,resetKey:n}){return t(Gi,{fallback:r,resetKey:n,children:t(RenderHost,{render:e})})}var Ki=48;function Yi(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(e){let{capability:t,children:r,renderDisabled:l,renderPending:i,style:o}=e,a=useCapability(t),s=n(()=>Yi(a),[a]);switch(s){case"enabled":return r;case"pending":return i?/* @__PURE__ */E(HostRender,{render:i,fallback:/* @__PURE__ */E(PendingSkeleton,{capability:t,style:o})}):/* @__PURE__ */E(PendingSkeleton,{capability:t,style:o});case"disabled":return l?/* @__PURE__ */E(HostRender,{render:()=>l(a),fallback:/* @__PURE__ */E(OffState,{decision:a,style:o}),resetKey:a}):/* @__PURE__ */E(OffState,{decision:a,style:o});default:return assertNever(s)}}function PendingSkeleton({capability:e,style:t}){let r=useEverfurTheme(),l=n(()=>Qi(r),[r]);/* @__PURE__ */
20
+ return E(y,{style:[l.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:/* @__PURE__ */E(y,{style:l.skeletonBar})})}function OffState({decision:e,style:t}){let r=useEverfurTheme(),l=n(()=>Qi(r),[r]),i=e.disabled?.reason??"";/* @__PURE__ */
21
+ return E(y,{style:[l.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:i,children:i.length>0?/* @__PURE__ */E(Text,{style:l.offstateText,children:i}):null})}function Qi(e){let{color:t,space:r,radius:n,type:l}=e;return f.create({offstate:{minHeight:Ki,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:f.hairlineWidth,borderColor:t.brandBorder},offstateText:{...face(e,"regular"),fontSize:l.size.body,lineHeight:Math.round(l.size.body*l.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}var Zi="everfur.com",Ji=2048,Xi=/^(\*\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function eo(e){if(!Array.isArray(e))return[];let t=/* @__PURE__ */new Set;for(let r of e){if(typeof r!="string")continue;let e=r.trim().toLowerCase();e.length<=253&&Xi.test(e)&&t.add(e)}/* @__PURE__ */
22
+ return Object.freeze([...t])}function to(e,t){if(e===Zi||e.endsWith(`.${Zi}`))return true;for(let r of t)if(r.startsWith("*.")?e.endsWith(r.slice(1)):e===r)return true;return false}function ro(e,t){if(typeof e!="string"||e.length===0||e.length>Ji||!/^https:\/\//i.test(e))return null;let r=Tt(e);return r===null||r.protocol!=="https:"||r.username!==""||r.password!==""||r.port!==""?null:to(r.hostname,t)?r.href:null}function no(e){try{Promise.resolve(m.openURL(e)).catch(()=>{})}catch{}}var lo=createContext(null);function io(){return s(lo)??void 0}function MessageLinksScope({linkHosts:e,onOpenUrl:r,children:l}){let i=e===false?null:Array.isArray(e)?e.join(`\n`):"",o=n(()=>{if(i===null)return null;let e=eo(i===""?[]:i.split(`\n`));/* @__PURE__ */
23
+ return Object.freeze({hosts:e,open:r!==void 0?e=>{Vr(r,e,"message")}:no})},[i,r]);return t(lo.Provider,{value:o},l)}var oo={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function ao(e){return{width:e,height:e,alignItems:"center",justifyContent:"center"}}function so(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}function MenuGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r),l={width:e*.82,height:n,borderRadius:n,backgroundColor:t};/* @__PURE__ */
24
+ return O(y,{style:[ao(e),{gap:e*.22}],...oo,children:[
25
+ /* @__PURE__ */E(y,{style:l}),
26
+ /* @__PURE__ */E(y,{style:l}),
27
+ /* @__PURE__ */E(y,{style:l})]})}function Cross({size:e,color:t,strokeWidth:r,rotate:n}){let l=so(e,r),i=e*.78;/* @__PURE__ */
28
+ return O(y,{style:[ao(e),{transform:[{rotate:n}]}],...oo,children:[
29
+ /* @__PURE__ */E(y,{style:{position:"absolute",width:i,height:l,borderRadius:l,backgroundColor:t}}),
30
+ /* @__PURE__ */E(y,{style:{position:"absolute",width:l,height:i,borderRadius:l,backgroundColor:t}})]})}function PlusGlyph(e){/* @__PURE__ */
31
31
  return E(Cross,{...e,rotate:"0deg"})}function CloseGlyph(e){/* @__PURE__ */
32
- return E(Cross,{...e,rotate:"45deg"})}function CheckGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r);/* @__PURE__ */
33
- return E(b,{style:Ki(e),...Gi,children:/* @__PURE__ */E(b,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}var Qi={down:{rotate:"45deg",marginTop:-.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-.4}};function ChevronGlyph({size:e,color:t,strokeWidth:r,direction:n}){let l=Yi(e,r),i=e*.46,o=Qi[n];/* @__PURE__ */
34
- return E(b,{style:Ki(e),...Gi,children:/* @__PURE__ */E(b,{style:{width:i,height:i,borderRightWidth:l,borderBottomWidth:l,borderColor:t,marginTop:i*o.marginTop,marginLeft:i*o.marginLeft,transform:[{rotate:o.rotate}]}})})}function BookGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r),l={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};/* @__PURE__ */
35
- return O(b,{style:[Ki(e),{flexDirection:"row",gap:1}],...Gi,children:[
36
- /* @__PURE__ */E(b,{style:[l,{borderTopLeftRadius:e*.2}]}),
37
- /* @__PURE__ */E(b,{style:[l,{borderTopRightRadius:e*.2}]})]})}function ArrowUpRightGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r),l=e*.5;/* @__PURE__ */
38
- return O(b,{style:Ki(e),...Gi,children:[
39
- /* @__PURE__ */E(b,{style:{position:"absolute",width:e*.78,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}}),
40
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.16,right:e*.16,width:l,height:l,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}function CopyGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r),l=e*.6,i={position:"absolute",width:l,height:l,borderWidth:n,borderColor:t,borderRadius:e*.14};/* @__PURE__ */
41
- return O(b,{style:Ki(e),...Gi,children:[
42
- /* @__PURE__ */E(b,{style:[i,{top:0,left:0}]}),
43
- /* @__PURE__ */E(b,{style:[i,{bottom:0,right:0}]})]})}function ThumbGlyph({size:e,color:t,strokeWidth:r,active:n,rotate:l}){let i=Yi(e,r),o=n?t:"transparent";/* @__PURE__ */
44
- return O(b,{style:[Ki(e),{transform:[{rotate:l}]}],...Gi,children:[
45
- /* @__PURE__ */E(b,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),
46
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),
47
- /* @__PURE__ */E(b,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.05}})]})}function InfoGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r);/* @__PURE__ */
48
- return O(b,{style:[Ki(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...Gi,children:[
49
- /* @__PURE__ */E(b,{style:{width:n,height:n,borderRadius:n,backgroundColor:t,marginBottom:e*.1}}),
50
- /* @__PURE__ */E(b,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}function UploadGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r),l=e*.34;/* @__PURE__ */
51
- return O(b,{style:Ki(e),...Gi,children:[
52
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.06,width:l,height:l,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}}),
53
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.1,width:n,height:e*.56,borderRadius:n,backgroundColor:t}}),
54
- /* @__PURE__ */E(b,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}function PhotoGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r);/* @__PURE__ */
55
- return O(b,{style:[Ki(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...Gi,children:[
56
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:t}}),
57
- /* @__PURE__ */E(b,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function CameraGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r);/* @__PURE__ */
58
- return O(b,{style:Ki(e),...Gi,children:[
59
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderTopLeftRadius:n,borderTopRightRadius:n}}),
60
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */E(b,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}function SearchGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r),l=e/24,i=16*l+n,o=11*l-i/2,a=11+8/Math.SQRT2,s=(21-a)*Math.SQRT2*l,u=(a+21)/2*l;/* @__PURE__ */
61
- return O(b,{style:Ki(e),...Gi,children:[
62
- /* @__PURE__ */E(b,{style:{position:"absolute",top:o,left:o,width:i,height:i,borderRadius:i,borderWidth:n,borderColor:t}}),
63
- /* @__PURE__ */E(b,{style:{position:"absolute",top:u-n/2,left:u-(s+n)/2,width:s+n,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"45deg"}]}})]})}function EditGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r);/* @__PURE__ */
64
- return O(b,{style:Ki(e),...Gi,children:[
65
- /* @__PURE__ */E(b,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:n,borderColor:t,borderRadius:n,transform:[{rotate:"45deg"}]}}),
66
- /* @__PURE__ */E(b,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:n,borderRadius:n,backgroundColor:t}})]})}function MapPinGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r),l=e*.62;/* @__PURE__ */
67
- return O(b,{style:Ki(e),...Gi,children:[
68
- /* @__PURE__ */E(b,{style:{position:"absolute",top:0,width:l,height:l,borderRadius:l,borderWidth:n,borderColor:t,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */E(b,{style:{width:n*1.4,height:n*1.4,borderRadius:n,backgroundColor:t}})}),
69
- /* @__PURE__ */E(b,{style:{position:"absolute",bottom:e*.04,width:l*.5,height:l*.5,borderRightWidth:n,borderBottomWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function SendGlyph({size:e,color:t,testID:r}){let n=e*.36;/* @__PURE__ */
70
- return E(b,{style:Ki(e),testID:r,...Gi,children:/* @__PURE__ */E(b,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}function StopGlyph({size:e,color:t,testID:r}){/* @__PURE__ */
71
- return E(b,{style:Ki(e),testID:r,...Gi,children:/* @__PURE__ */E(b,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}function MicGlyph({size:e,color:t,strokeWidth:r,testID:n}){let l=Yi(e,r);/* @__PURE__ */
72
- return O(b,{style:Ki(e),testID:n,...Gi,children:[
73
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.08,width:e*.26,height:e*.48,borderWidth:l,borderColor:t,borderRadius:e*.13}}),
74
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.38,width:e*.56,height:e*.36,borderBottomWidth:l,borderLeftWidth:l,borderRightWidth:l,borderColor:t,borderBottomLeftRadius:e*.28,borderBottomRightRadius:e*.28}}),
75
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.74,width:l,height:e*.18,backgroundColor:t}})]})}function Ring({size:e,strokeWidth:t,color:r,children:n}){/* @__PURE__ */
76
- return E(b,{style:[Ki(e),{borderRadius:e/2,borderWidth:t??p.hairlineWidth,borderColor:r}],children:n})}function ArrowUpGlyph({size:e,color:t,strokeWidth:r,testID:n}){let l=Yi(e,r),i=e*.46;/* @__PURE__ */
77
- return O(b,{style:Ki(e),testID:n,...Gi,children:[
78
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.16,bottom:e*.12,width:l,borderRadius:l,backgroundColor:t}}),
79
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.16+l/2,width:i,height:i,borderLeftWidth:l,borderTopWidth:l,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function ChatBubbleGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r);/* @__PURE__ */
80
- return O(b,{style:Ki(e),...Gi,children:[
81
- /* @__PURE__ */E(b,{style:{width:e*.8,height:e*.6,marginTop:-e*.12,borderWidth:n,borderColor:t,borderRadius:e*.14}}),
82
- /* @__PURE__ */E(b,{style:{position:"absolute",bottom:e*.1,left:e*.22,width:e*.2,height:e*.2,borderLeftWidth:n,borderBottomWidth:n,borderColor:t}})]})}function HistoryGlyph({size:e,color:t,strokeWidth:r}){let n=Yi(e,r),l=e*.72,i=e/2;/* @__PURE__ */
83
- return O(b,{style:Ki(e),...Gi,children:[
84
- /* @__PURE__ */E(b,{style:{width:l,height:l,borderRadius:l/2,borderWidth:n,borderColor:t,borderLeftColor:"transparent",transform:[{rotate:"45deg"}]}}),
85
- /* @__PURE__ */E(b,{style:{position:"absolute",top:e*.16,left:e*.12,width:e*.2,height:e*.2,borderLeftWidth:n,borderBottomWidth:n,borderColor:t}}),
86
- /* @__PURE__ */E(b,{style:{position:"absolute",top:i-e*.2,left:i-n/2,width:n,height:e*.2+n/2,borderRadius:n,backgroundColor:t}}),
87
- /* @__PURE__ */E(b,{style:{position:"absolute",top:i-n/2,left:i-n/2,width:e*.15+n/2,height:n,borderRadius:n,backgroundColor:t}})]})}var Zi=/* @__PURE__ */Object.freeze({standard:ie.standard,emphasized:ie.emphasized,exit:ie.exit,outQuad:/* @__PURE__ */Object.freeze([.25,.46,.45,.94]),out:/* @__PURE__ */Object.freeze([.23,1,.32,1])});var Ji=/* @__PURE__ */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:/* @__PURE__ */Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,bubbleInMs:280,bubbleFromScale:.94,bubbleRisePx:6,promptRisePx:8,reduced:false}),Xi=/* @__PURE__ */Object.freeze({...Ji,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 eo(e){return e.motion.reducedMotion?Xi:Ji}function to(e,t){return Math.max(0,t)*e.followUpStaggerMs}function ro(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)}function no(){let e=useEverfurTheme();return eo(e)}var lo=8;function io(e,t,r){return((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}function oo(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}function ao(e){let[t,r,n,l]=e;return e=>{if(e<=0)return 0;if(e>=1)return 1;let i=e;for(let r=0;r<lo;r+=1){let r=oo(i,t,n);if(r===0)break;i-=(io(i,t,n)-e)/r}return io(Math.min(1,Math.max(0,i)),r,l)}}var so=ao(Zi.standard),uo=ao(Zi.outQuad),co=ao(Zi.out);function po(e){let t=l(null);return t.current===null&&(t.current=new I.Value(e)),t.current}function fo(e,t={}){let r=t.risePx??0,l=t.delayMs??0,i=po(e>0?0:1);return o(()=>{if(e<=0){i.setValue(1);return}let t=I.timing(i,{toValue:1,duration:e,easing:uo,useNativeDriver:true}),r=l>0?I.sequence([I.delay(l),t]):t;return r.start(),()=>r.stop()},[i,e,l]),n(()=>({opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[i,r])}function FadePresence({visible:e,inMs:t,outMs:r,style:n,children:l}){let[a,s]=i(e),u=po(e&&t<=0?1:0);return o(()=>{if(e){s(true);let e=I.timing(u,{toValue:1,duration:Math.max(0,t),easing:so,useNativeDriver:true});return e.start(),()=>e.stop()}if(!a)return;if(r<=0){s(false);return}let n=I.timing(u,{toValue:0,duration:r,easing:so,useNativeDriver:true});return n.start(({finished:e})=>{e&&s(false)}),()=>n.stop()},[e,a,t,r,u]),!a&&!e?null:/* @__PURE__ */E(I.View,{style:[n,{opacity:u}],children:l})}var ho=/* @__PURE__ */Object.freeze({opacity:1,transform:/* @__PURE__ */Object.freeze([{translateY:0},{scale:1}])});function go(e,t){let[r]=i(()=>e?t.bubbleInMs:0),l=r>0,a=po(l?0:1);o(()=>{if(r<=0)return;let e=I.timing(a,{toValue:1,duration:r,easing:co,useNativeDriver:true});return e.start(),()=>e.stop()},[r,a]);let s=t.bubbleFromScale,u=t.bubbleRisePx;return n(()=>l?{opacity:a,transform:[{translateY:a.interpolate({inputRange:[0,1],outputRange:[u,0]})},{scale:a.interpolate({inputRange:[0,1],outputRange:[s,1]})}]}:ho,[l,a,u,s])}function bo(e){let t=l(null),n=l(null),i=e[0]?.id??null;if(t.current===null||n.current!==i){let r=t.current===null;t.current=new Map(e.map(e=>[e.id,r&&e.pending===true])),n.current=i}let o=t.current;for(let t of e)o.has(t.id)||o.set(t.id,true);return r(e=>o.get(e)===true,[o])}var yo=12;function PressScale({style:e,containerStyle:t,children:n,onPressIn:l,onPressOut:i,hitSlop:o,...a}){let s=no(),u=po(1),d=r(e=>{s.pressMs<=0||s.pressScale===1||I.timing(u,{toValue:e,duration:s.pressMs,easing:so,useNativeDriver:true}).start()},[u,s.pressMs,s.pressScale]);/* @__PURE__ */
88
- return E(v,{...a,hitSlop:o??yo,style:t,onPressIn:e=>{d(s.pressScale),l?.(e)},onPressOut:e=>{d(1),i?.(e)},children:/* @__PURE__ */E(I.View,{style:[e,{transform:[{scale:u}]}],children:n})})}function mo(e,t,r){let n=t&&r.revealTickMs>0,[a,s]=i(0),u=l(e);return u.current=e,o(()=>{if(!n)return;let e=setInterval(()=>{s(e=>ro(r,e,u.current.length))},r.revealTickMs);return()=>clearInterval(e)},[n,r]),n?e.slice(0,Math.min(a,e.length)):e}var vo=false;function wo(e){e.layoutMs<=0||(vo||(vo=true,f.OS==="android"&&typeof T.setLayoutAnimationEnabledExperimental=="function"&&T.setLayoutAnimationEnabledExperimental(true)),z.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}))}function ko(e,t){let r=l(e);r.current!==e&&(r.current=e,wo(t))}var Co=36,So=22,xo=12,Ro=12,_o=16,To="#000",zo="rgba(0,0,0,0.45)";function AttachmentImageLightbox({uri:e,label:t,onClose:r}){let n=useEverfurTheme(),l=L();return e===null?null:/* @__PURE__ */O(C,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[
89
- /* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:Re.closePreview,style:Io.backdrop,onPress:r,children:/* @__PURE__ */E(R,{source:{uri:e},style:Io.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),
90
- /* @__PURE__ */E(b,{pointerEvents:"box-none",style:[Io.closeWrap,{top:l.top+Ro}],children:/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Re.closePreview,hitSlop:xo,style:Io.closeButton,onPress:r,children:/* @__PURE__ */E(CloseGlyph,{size:So,color:n.color.surface,strokeWidth:2})})})]})}var Io=p.create({backdrop:{flex:1,backgroundColor:To,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:_o},closeButton:{width:Co,height:Co,borderRadius:Co/2,backgroundColor:zo,alignItems:"center",justifyContent:"center"}});var Po=()=>{};function Fo(){try{return h.currentState==="active"}catch{return false}}function createAppStateLifecycle(){return{onForeground(e){let t;try{let r=h.currentState==="background";t=h.addEventListener("change",t=>{t==="background"?r=!0:t==="active"&&r&&(r=!1,e())})}catch{return Po}return()=>t.remove()},isVisible:Fo}}function Lo(e,t){if(e===void 0)return{};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}function Eo(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}function Oo(e){return e?.textColor===void 0?{}:{color:e.textColor}}var Ao=/* @__PURE__ */Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function jo(e){return e!==Ao}var Do=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Mo(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let l={handle:void 0},i=()=>{r.clearTimeout(l.handle),t.removeEventListener("abort",i),n()};l.handle=r.setTimeout(i,e),t.addEventListener("abort",i,{once:true})})}var Bo=4e3;var Ho=4e3;var Wo=/* @__PURE__ */Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var No=10*1024*1024,Uo=5,$o=120,Vo="/widget/v1/uploads/initiate";function isAttachmentMime(e){return typeof e=="string"&&Wo.includes(e.trim().toLowerCase())}function sanitizeFilename(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<=$o)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,$o);let n=t.slice(r);return n.length>=$o?t.slice(0,$o):`${t.slice(0,r).slice(0,$o-n.length)}${n}`}function formatBytes(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var qo=e=>/* @__PURE__ */Object.freeze({ok:true,value:e}),Go=e=>/* @__PURE__ */Object.freeze({ok:false,error:e});function Ko(e,t,r,n){/* @__PURE__ */
91
- return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}function attachmentSize(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}function validateAttachment(e){let t=sanitizeFilename(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!isAttachmentMime(r))return Go(Ko("unsupported_type",false,t));let n=attachmentSize(e);return n===null?Go(Ko("unknown",false,t)):n>No?Go(Ko("too_large",false,t,{sizeBytes:n})):qo(/* @__PURE__ */Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}function Yo(e){if(typeof e!="object"||e===null)return null;let t=e,r=e=>typeof e=="string"&&e.length>0?e:null,n=e=>typeof e=="number"&&Number.isFinite(e)?e:null,l=r(t.upload_id),i=r(t.upload_url),o=r(t.s3_key);if(l===null||i===null||o===null)return null;let a={},s=t.upload_fields;if(typeof s=="object"&&s!==null)for(let[e,t]of Object.entries(s))typeof t=="string"&&(a[e]=t);/* @__PURE__ */
92
- return Object.freeze({upload_id:l,upload_url:i,upload_fields:/* @__PURE__ */Object.freeze(a),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??No,s3_key:o,purpose:r(t.purpose)})}function Qo(e,t){let r=e.httpStatus;switch(e.code){case"quotaExceeded":return Ko("quota_exceeded",false,t,{cause:e});case"rateLimited":return Ko("rate_limited",true,t,{cause:e});case"idempotencyConflict":case"idempotencyInFlight":return Ko("idempotency_conflict",true,t,{cause:e});case"validationFailed":return Ko("unsupported_type",false,t,{cause:e});case"serviceUnavailable":case"streamTimeout":return Ko("network",true,t,{cause:e});default:return r===429?Ko("rate_limited",true,t,{cause:e}):r===503?Ko("network",true,t,{cause:e}):r===void 0?Ko("network",true,t,{cause:e}):Ko("server",e.retryable,t,{httpStatus:r,cause:e})}}async function initiateAttachmentUpload(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:Vo,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return Go(Qo(n.error,t.filename));let l=Yo(n.value);return l===null?Go(Ko("server",false,t.filename)):qo(l)}async function uploadAttachmentBytes(e,t,r,n){let l=()=>n?.signal?.aborted===true;if(l())return Go(Ko("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),qo(void 0)}catch{return l()?Go(Ko("cancelled",true,r.filename)):Go(Ko("server",true,r.filename))}}var Zo=2,Jo=3,Xo=/* @__PURE__ */Object.freeze([1e3,2e3,4e3]),ea=0;function ta(){return ea+=1,`attachment-${ea}`}function createAttachmentQueue(e){let t=Math.max(1,e.concurrency??Zo),r=Math.max(1,e.maxAttempts??Jo),n=e.backoffMs??Xo,l=Math.max(1,e.maxPerMessage??Uo),i=e.timers??Do,o=e.newId??ta,a=jo(e.transport),s=/* @__PURE__ */new Map,u=[],d=[],c=/* @__PURE__ */new Set,p=/* @__PURE__ */new Set,f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])}),h=false,g=()=>{f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze(u.flatMap(e=>{let t=s.get(e);return t===void 0?[]:[t.state]}))});for(let e of p)e()},b=(e,t)=>{e.state=/* @__PURE__ */Object.freeze({...e.state,...t}),g()},y=()=>{for(;!h&&c.size<t&&d.length>0;){let e=d.shift(),t=s.get(e);t!==void 0&&(c.add(e),m(t).finally(()=>{c.delete(e),y()}))}},m=async t=>{let{attachment:l}=t;for(;t.attempts<r;){if(h||t.controller.signal.aborted)return;t.attempts+=1;let o=t.controller.signal;b(t,{status:"uploading",error:null,progress:0});let a=await initiateAttachmentUpload(e.funnel,l,{signal:o});if(h||o.aborted)return;let s;if(!a.ok)s=Go(a.error);else{let r=await uploadAttachmentBytes(e.transport,a.value,l,{signal:o,onProgress:e=>{!o.aborted&&t.state.status==="uploading"&&b(t,{progress:ra(e)})}});if(h||o.aborted)return;s=r.ok?qo(a.value.s3_key):Go(r.error)}if(s.ok){b(t,{status:"uploaded",s3Key:s.value,error:null,progress:1});return}let u=s.error,d=u.retryable&&t.attempts<r;if(b(t,{status:d?"uploading":"failed",error:u,progress:0}),!d)return;let c=n[Math.min(t.attempts-1,n.length-1)]??0;await Mo(c,o,i)}},v=e=>{d.push(e.state.id),y()},w={available:a,subscribe(e){return p.add(e),()=>{p.delete(e)}},getSnapshot:()=>f,get uploading(){return f.attachments.some(e=>e.status==="uploading")},get s3Keys(){return f.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[])},add(e){let t=validateAttachment(e);if(!t.ok)return t;if(h||u.length>=l)return Go(Ko("too_many",false,t.value.filename));let r=o(),n={attachment:t.value,controller:new AbortController,attempts:0,state:/* @__PURE__ */Object.freeze({id:r,filename:t.value.filename,previewUri:e.uri,contentType:t.value.contentType,sizeBytes:t.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return s.set(r,n),u.push(r),g(),v(n),qo(n.state)},retry(e){let t=s.get(e);t===void 0||h||t.state.status!=="failed"||(t.controller=new AbortController,t.attempts=0,b(t,{status:"uploading",error:null,progress:0,s3Key:null}),v(t))},remove(e){let t=s.get(e);if(t===void 0)return;t.controller.abort(),s.delete(e);let r=u.indexOf(e);r>=0&&u.splice(r,1);let n=d.indexOf(e);n>=0&&d.splice(n,1),g()},clear(){for(let e of[...u])w.remove(e)},dispose(){h=true;for(let e of s.values())e.controller.abort();s.clear(),u.length=0,d.length=0,p.clear(),f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])})}};return w}function ra(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function na(e){switch(e.code){case"too_large":return _e(Re.attachmentTooLarge,{max:formatBytes(No),filename:e.filename,size:formatBytes(e.sizeBytes??0)});case"too_many":return _e(Re.attachmentTooMany,{max:Uo});case"unsupported_type":return _e(Re.attachmentUnsupported,{filename:e.filename});case"network":return Re.attachmentNetwork;case"server":return _e(Re.attachmentServer,{status:e.httpStatus?` (${e.httpStatus})`:""});case"cancelled":return Re.attachmentCancelled;case"rate_limited":return Re.attachmentRateLimited;case"quota_exceeded":return Re.attachmentQuota;case"idempotency_conflict":return Re.attachmentConflict;case"unknown":return Re.attachmentUnknown}}function la(e,t){return _e(e>=t?Re.attachmentsFull:Re.addAttachment,{used:e,total:t})}var ia=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])});function useChatAttachments(e={}){let{runtime:t,userRef:userRef,scopeEpoch:s}=Oe(),u=e.maxPerMessage??Uo,d=r(()=>{let{services:r}=t.registry;return createAttachmentQueue({funnel:createRequestFunnel({auth:r.authFor(userRef),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),transport:e.transport??r.uploadTransport,maxPerMessage:u})},[t,userRef,s,u,e.transport]),c=n(()=>e.queue??d(),[e.queue,d]),p=l(/* @__PURE__ */new WeakSet),[f,h]=i(null),g=f!==null&&f.of===c?f.queue:c;o(()=>{if(g!==e.queue){if(p.current.has(g)){h({of:c,queue:d()});return}return()=>{g.dispose(),p.current.add(g)}}},[g,c,d,e.queue]);let b=a(g.subscribe,g.getSnapshot,()=>ia),[y,m]=i(null),v=r(e=>{let t=(Array.isArray(e)?e:[e]).map(e=>g.add(e)),r=t.find(e=>!e.ok);return r!==void 0&&!r.ok&&m(r.error),t},[g,m]),w=r(e=>g.retry(e),[g]),k=r(e=>g.remove(e),[g]),C=r(()=>g.clear(),[g]),S=r(()=>m(null),[m]),x=b.attachments.some(e=>e.status==="uploading"),R=b.attachments.some(e=>e.status==="failed");return n(()=>({available:g.available,attachments:b.attachments,maxPerMessage:u,uploading:x,failed:R,blocked:x||R,s3Keys:b.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[]),rejected:y,add:v,retry:w,remove:k,clear:C,dismissRejected:S}),[g.available,b,u,x,R,y,v,w,k,C,S])}var oa=6e3;function aa(e,t,r){let n=t.trim();if(!n)return e;let l=e===""||/\s$/.test(e)?"":" ",i=`${e}${l}${n}`;return typeof r=="number"&&r>0?i.slice(0,r):i}function sa(e){let t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/60),n=t%60;return`${r}:${n.toString().padStart(2,"0")}`}function ua(e){switch(e){case"permissionDenied":return Re.micBlocked;case"noSpeech":return Re.noSpeech;case"unavailable":return Re.dictationUnavailable}}function da(e,t,r){if(e)try{e.track(t,{...r})}catch{}}var ca=["Apoquel","Cytopoint","Bravecto","NexGard","Simparica Trio","Credelio","Revolution","Heartgard","Interceptor","Sentinel","ProHeart","Rimadyl","carprofen","meloxicam","Metacam","Galliprant","gabapentin","trazodone","Librela","Solensia","Zenrelia","prednisone","prednisolone","amoxicillin","Clavamox","cephalexin","Convenia","metronidazole","doxycycline","Cerenia","maropitant","famotidine","omeprazole","Proin","Vetmedin","pimobendan","enalapril","furosemide","levothyroxine","methimazole","Vetsulin","fluoxetine","Sileo","tramadol","buprenorphine","Denamarin","Dasuquin","Cosequin","parvovirus","distemper","Bordetella","leptospirosis","heartworm","giardia","coccidia","pancreatitis","hypothyroidism","Cushing's disease","Addison's disease","IVDD","cruciate ligament","luxating patella","hip dysplasia","pyometra","kennel cough","otitis","FIV","FeLV","DHPP","FVRCP","Labrador Retriever","Golden Retriever","French Bulldog","German Shepherd","Dachshund","Cavalier King Charles Spaniel","Shih Tzu","Pomeranian","Chihuahua","Yorkshire Terrier","Bichon Frise","Havanese","Cockapoo","Goldendoodle","Labradoodle","Weimaraner","Vizsla","Shiba Inu","Springer Spaniel","Miniature Schnauzer","Corgi","Australian Shepherd","Border Collie","Siberian Husky","Beagle","Maine Coon","Ragdoll","Sphynx","Bengal cat","British Shorthair"];function pa(e={}){let t=/* @__PURE__ */new Set,r=[];for(let n of[e.name,e.breed,...ca]){let e=(n??"").trim();if(!e)continue;let l=e.toLowerCase();if(!t.has(l)&&(t.add(l),r.push(e),r.length>=100))break}return r}function fa(e,conversationId,t){let[n,l]=i({send:e,conversationId:conversationId,text:t??"",seeded:t??null}),a=n.send===e&&(n.conversationId===null||n.conversationId===conversationId);o(()=>{l(r=>{let n=r.send===e&&(r.conversationId===null||r.conversationId===conversationId),l=n?r.text:"",i=n?r.seeded:null,o=t!=null&&t!==i&&l.length===0;return{send:e,conversationId:conversationId,text:o?t:l,seeded:o?t:i}})},[e,conversationId,t]);let s=r(t=>l(r=>({send:e,conversationId:conversationId,text:t,seeded:r.seeded})),[e,conversationId]);return[a?n.text:"",s]}function ha(e,conversationId,t,r,n=false){let a=l({draft:t,setDraft:r});a.current={draft:t,setDraft:r};let s=l(null),[u,d]=i(null);o(()=>{if(e===void 0)return;let t=`${conversationId??""}`;if(s.current===t)return;s.current=t;let r=true;return(async()=>{let n=await Ar(()=>e.read(conversationId));if(!r)return;let l=n.ok&&typeof n.value=="string"?n.value:"";l.length>0&&a.current.draft.length===0&&a.current.setDraft(l),d(t)})(),()=>{r=false}},[e,conversationId]),o(()=>{e===void 0||n||u!==`${conversationId??""}`||Lr(()=>e.write(conversationId,t))},[e,conversationId,t,u,n])}function ga(e){if(!(f.OS!=="ios"||e===""))try{let t=_?.announceForAccessibility;typeof t=="function"&&t.call(_,e)}catch{}}function AnnounceLine({line:e}){return o(()=>{ga(e)},[e]),null}var ba=12,ya=80,ma=44,va=22,wa=.14,ka=18,Ca=8,Sa=/* @__PURE__ */Object.freeze({photo:Re.attachmentPhoto,camera:Re.attachmentCamera});function AttachmentPickerPopover({sources:e,full:t,onPick:r,onClose:l}){let i=useEverfurTheme(),o=n(()=>xa(i),[i]);/* @__PURE__ */
93
- return O(b,{style:o.anchor,pointerEvents:"box-none",children:[
94
- /* @__PURE__ */E(v,{style:o.dismissLayer,accessibilityRole:"button",accessibilityLabel:Re.closeAttachmentPicker,onPress:l}),
95
- /* @__PURE__ */O(b,{style:o.bubble,children:[
96
- /* @__PURE__ */E(b,{style:o.tilesRow,children:e.map(e=>/* @__PURE__ */O(PressScale,{accessibilityRole:"button",accessibilityLabel:Sa[e],accessibilityState:{disabled:t},disabled:t,containerStyle:o.tile,style:o.tileInner,onPress:()=>r(e),children:[
97
- /* @__PURE__ */E(b,{style:o.tileIconWrap,children:e==="photo"?/* @__PURE__ */E(PhotoGlyph,{size:va,color:i.color.brandInk,strokeWidth:1.5}):/* @__PURE__ */E(CameraGlyph,{size:va,color:i.color.brandInk,strokeWidth:1.5})}),
98
- /* @__PURE__ */E(Text,{tier:"control",style:o.tileLabel,children:Sa[e]})]},e))}),
99
- /* @__PURE__ */E(b,{style:o.tail}),
100
- /* @__PURE__ */E(b,{style:o.tailFill})]})]})}function xa(e){let t=e.color,r=e.radius;return p.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:wa,shadowRadius:ka,shadowOffset:{width:0,height:Ca},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:ya,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:ma,height:ma,borderRadius:ma/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...face(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-ba/2,width:ba,height:ba,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:ba+4,height:2,backgroundColor:t.surfaceCream}})}function parseColor(e){let t=Ra(e);return t===null?null:La(t)}function Ra(e){if(typeof e=="number")return za(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return _a(t.slice(1));if(t.toLowerCase().startsWith("0x"))return _a(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Ta(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=_a(t);if(e!==null)return e}return/^\d+$/.test(t)?za(Number.parseInt(t,10)):null}function _a(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:Pa(t[0]),g:Pa(t[1]),b:Pa(t[2]),a:1};if(t.length===6)return{r:Ia(t,0),g:Ia(t,2),b:Ia(t,4),a:1};if(t.length===8){let e=Ia(t,0);return{r:Ia(t,2),g:Ia(t,4),b:Ia(t,6),a:e/255}}return null}function Ta(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(e=>e.trim());if(n.length<3)return null;let l=Fa(Number(n[0])),i=Fa(Number(n[1])),o=Fa(Number(n[2]));if(l===null||i===null||o===null)return null;let a=1;if(n.length>=4){let e=Number(n[3]);if(!Number.isFinite(e))return null;a=Math.min(1,Math.max(0,e))}return{r:l,g:i,b:o,a:a}}function za(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return{r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}function Ia(e,t){return Number.parseInt(e.slice(t,t+2),16)}function Pa(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function Fa(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function La(e){if(e.a>=1)return Ea(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return`rgba(${e.r},${e.g},${e.b},${t})`}function Ea(e,t,r){return`#${Oa(e)}${Oa(t)}${Oa(r)}`.toUpperCase()}function Oa(e){return e.toString(16).padStart(2,"0")}var Aa="#111111",ja="#FFFFFF",Da="#000000";function readableOn(e){let t=Ra(e);if(t===null)return ja;let r=Ha(t),n=Ha({r:17,g:17,b:17}),l=Ha({r:255,g:255,b:255});return Na(r,l)>=Na(r,n)?ja:Aa}function Ma(e,t){let r=readableOn(e);return contrastRatio(r,e)>=t?r:contrastRatio(ja,e)>=contrastRatio(Da,e)?ja:Da}function Ba(e){let t=t=>e.reduce((e,r)=>Math.min(e,contrastRatio(t,r)),Number.POSITIVE_INFINITY);return t(ja)>=t(Da)?ja:Da}function Ha(e){let t=Wa(e.r/255),r=Wa(e.g/255),n=Wa(e.b/255);return.2126*t+.7152*r+.0722*n}function Wa(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Na(e,t){let r=Math.max(e,t),n=Math.min(e,t);return(r+.05)/(n+.05)}function contrastRatio(e,t){let r=Ra(e),n=Ra(t);if(r===null||n===null)return 1;let l=n.a>=1?n:{...n},i=r.a>=1?r:Ua(r,l);return Na(Ha(i),Ha(l))}function Ua(e,t){let r=e.a,n=(e,t)=>Math.round(e*r+t*(1-r));return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}function $a(e,t){let r=Ra(e),n=Ra(t);if(r===null||n===null)return null;let l=r.a>=1?r:Ua(r,{...n});return Ea(l.r,l.g,l.b)}function Va(e,t){let r=Ra(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return`rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}var qa=.05;function Ga(e,t,r,n){let l=t[0];if(l===void 0)return r;let i=e=>t.every(t=>contrastRatio(e,t)>=n);if(Ra(e)===null)return r;if(i(e))return e;let o=$a(e,l),a=o===null?null:Ra(o),s=Ra(r);if(a===null||s===null)return r;for(let e=1;e<1/qa;e+=1){let t=e*qa,r=(e,r)=>Math.round(e+(r-e)*t),n=Ea(r(a.r,s.r),r(a.g,s.g),r(a.b,s.b));if(i(n))return n}return r}var Ka=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var Ya=56,Qa=12,Za=14,Ja=10,Xa=.45,es="rgba(7,193,104,0.55)",ts="rgba(185,28,28,0.55)",rs=200,ns=300,ls=20,is=22,os=12,as="rgba(0,0,0,0.78)",ss=220,us=100,ds="rgba(255,255,255,0.15)";function AttachmentStrip({attachments:e,rejected:t,uploadFailed:r=false,onRetry:l,onRemove:i,onPreview:o,style:a}){let s=useEverfurTheme(),u=n(()=>cs(s),[s]);return e.length===0&&t===null?null:/* @__PURE__ */O(b,{style:[u.strip,a],children:[e.length>0?/* @__PURE__ */E(b,{style:u.cards,children:e.map(e=>/* @__PURE__ */E(PreviewCard,{row:e,styles:u,onRetry:l,onRemove:i,onPreview:o},e.id))}):null,r?/* @__PURE__ */E(Text,{style:u.rejected,accessibilityRole:"alert",children:Re.attachmentsFailedBlocked}):null,t!==null?/* @__PURE__ */E(Text,{style:u.rejected,accessibilityRole:"alert",children:na(t)}):null]})}function PreviewCard({row:e,styles:t,onRetry:r,onRemove:n,onPreview:a}){let s=useEverfurTheme(),u=e.status==="uploading",d=e.status==="failed",c=e.status==="uploaded",p=l(e.status),[f,h]=i(false);return o(()=>{let t=p.current;p.current=e.status,e.status==="uploaded"&&t==="uploading"&&h(true)},[e.status]),/* @__PURE__ */O(b,{style:t.card,children:[
101
- /* @__PURE__ */E(v,{accessibilityRole:c?"button":"image",accessibilityLabel:c?_e(Re.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:u,disabled:!c},disabled:!c,style:t.thumbHit,onPress:()=>a(e),children:/* @__PURE__ */O(b,{style:t.thumb,children:[
102
- /* @__PURE__ */E(R,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),u?/* @__PURE__ */E(b,{style:t.uploadingOverlay,children:/* @__PURE__ */E(x,{size:"small",color:s.color.surface})}):null,f?/* @__PURE__ */E(SuccessFlash,{styles:t,onDone:()=>h(false)}):null]})}),d?/* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:_e(Re.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:/* @__PURE__ */E(b,{style:t.failedInner,children:/* @__PURE__ */E(CloseGlyph,{size:ls,color:s.color.surface,strokeWidth:2})})}):null,
103
- /* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:_e(Re.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:/* @__PURE__ */E(CloseGlyph,{size:os,color:s.color.surface,strokeWidth:1.5})})]})}function SuccessFlash({styles:e,onDone:t}){let r=useEverfurTheme(),n=no(),i=l(null);i.current===null&&(i.current=new I.Value(0));let a=i.current;return o(()=>{let e=I.sequence([I.timing(a,{toValue:1,duration:rs,useNativeDriver:true}),I.delay(n.uploadFlashMs),I.timing(a,{toValue:0,duration:ns,useNativeDriver:true})]);return e.start(({finished:e})=>{e&&t()}),()=>e.stop()},[a,n.uploadFlashMs,t]),/* @__PURE__ */E(I.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:a}],children:/* @__PURE__ */E(CheckGlyph,{size:ls,color:r.color.surface,strokeWidth:2})})}function SentImages({images:e,onPreview:t}){let r=useEverfurTheme(),l=n(()=>cs(r),[r]);if(e.length===0)return null;let i=e.length===1;/* @__PURE__ */
104
- return E(b,{style:i?l.sentSingle:l.sentGrid,children:e.map((e,r)=>/* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:_e(Re.attachedImage,{filename:e.filename}),onPress:()=>t(e),children:/* @__PURE__ */E(R,{source:{uri:e.uri},style:i?l.singleImage:l.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${e.uri}-${r}`))})}function cs(e){let t=e.color,r=e.type;return p.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:Ya,height:Ya,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:Qa,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:p.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...Ka,alignItems:"center",justifyContent:"center",backgroundColor:Va(e.color.brandInk,Xa)??e.color.brandSofter},successOverlay:{...Ka,alignItems:"center",justifyContent:"center",backgroundColor:es},failedOverlay:{...Ka,borderRadius:Qa,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:ts},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:is,height:is,borderRadius:is/2,backgroundColor:as,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...face(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:ss,height:ss,borderRadius:Za,backgroundColor:ds},gridImage:{width:us,height:us,borderRadius:Ja,backgroundColor:ds}})}var ps="file",fs="multipart upload failed";function hs(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(ps,e.file)}catch{return Promise.reject(new Error(fs))}return e.fetch!==void 0?ys(e.fetch,e.url,t,e.signal):bs(e.url,t,e.signal)}function gs(e){return e>=200&&e<300}function bs(e,t,r){return new Promise((n,l)=>{let i=globalThis.XMLHttpRequest;if(typeof i!="function"||r?.aborted===true){l(new Error(fs));return}let o=null,a=()=>{o!==null&&r?.removeEventListener("abort",o)},s=()=>{a(),l(new Error(fs))};try{let l=new i;l.open("POST",e),l.withCredentials=!1,l.onload=()=>{a(),n(gs(l.status))},l.onerror=s,l.ontimeout=s,l.onabort=s,r!==void 0&&(o=()=>{try{l.abort()}finally{s()}},r.addEventListener("abort",o,{once:!0})),l.send(t)}catch{s()}})}function ys(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(e=>e.ok)}var ms="chat attachment upload: the file handle has no uri",vs="chat attachment upload failed";function ws(e){return{uri:e.uri,name:sanitizeFilename(e.name),type:e.mimeType}}function createRnChatAttachmentTransport(e={}){/* @__PURE__ */
105
- return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(ms));let{signal:l,onProgress:i}=n,o=()=>Promise.reject(new Error(vs));return l?.aborted===true?o():hs({url:t.upload_url,fields:t.upload_fields,file:ws(r),signal:l,fetch:e.fetch}).then(e=>{if(!e)return o();i?.(1)},o)}})}var ks=300,Cs=3e3,Ss=120,xs=44,Rs=120,_s="88%",Ts=520,zs=2,Is=.5,Ps=1.5,Fs=1.6,Ls=.6,Es=56,Os=1.5,As=5,js=5,Ds=36,Ms=20,Bs=14,Hs=xs,Ws=4,Ns=24,Us=22,$s=.4,Vs=xs,qs=20,Gs=.4,Ks=480,Ys=12,Qs=.72,Zs=48,Js=1.5,Xs=1.3,eu=1,tu=1,ru="12%",nu=14,lu=16,iu=28,ou=18,au="84%",su=10,uu=15,du=1.42,cu=4,pu=3,fu=14,hu=20;function gu(){let e=useEverfurTheme(),t=n(()=>bu(e),[e]);return{theme:e,styles:t}}function bu(e){let t=e.color,r=e.space,n=e.radius,l=e.type,i=Math.round(l.size.body*Ps),o=Math.round(l.size.body*Fs),a=Math.round(Ms*l.size.body/Bs),s=t.borderRingCream,u=e.slots;return p.create({container:{flex:1,minHeight:Ss,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:Ss,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},homeEmpty:{flexGrow:1},emptyContent:{flexGrow:1,alignItems:"stretch",justifyContent:"flex-start",paddingTop:ru,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:Ks,gap:r.lg},errorText:{...face(e,"regular"),fontSize:l.size.subtitle,lineHeight:l.size.subtitle*l.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:xs,minWidth:xs,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...Lo(u.primaryButton)},retryLabel:{...face(e,"medium"),color:t.onPrimary,fontSize:l.size.body,...Oo(u.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...face(e,"regular"),color:t.danger,fontSize:l.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,borderWidth:tu,borderColor:t.borderRingCream,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.bodyTight},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal},turnNoticeAction:{minHeight:xs,justifyContent:"center"},turnNoticeActionLabel:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight},setupNoticeAction:{...face(e,"medium"),color:t.brandInk,fontSize:l.size.caption},reconnectingCaption:{...face(e,"medium"),color:t.text.secondary,fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},readingBox:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:r.xs,paddingVertical:r.md,paddingHorizontal:r.md+r.xs/2,backgroundColor:t.surfaceSubtle,borderRadius:n.md},readingDot:{width:6,height:6,borderRadius:n.pill,backgroundColor:t.brandInk},readingInline:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:pu,minHeight:fu},readingDotInline:{width:cu,height:cu,borderRadius:n.pill,backgroundColor:t.text.muted},list:{flex:1},earlierButton:{alignSelf:"center",minHeight:xs,justifyContent:"center",paddingHorizontal:r.md+r.xs/2},earlierLabel:{...face(e,"monoBold"),color:t.linkInk,fontSize:l.size.caption},listContent:{padding:r.lg,gap:r.xl},listContentCards:{paddingTop:nu,paddingHorizontal:lu,paddingBottom:iu,gap:ou},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:_s,alignItems:"flex-start"},bubbleSideUser:{alignItems:"flex-end"},bubbleUser:{maxWidth:Ts,paddingVertical:r.md,paddingHorizontal:r.lg+zs,backgroundColor:t.bubbleUser,...t.primaryEdge!==t.primary&&t.bubbleUser===t.primary?{borderWidth:Is,borderColor:t.primaryEdge}:{},borderRadius:n.lg,borderBottomRightRadius:n.xs,...Lo(u.userBubble,Is)},bubbleAssistant:u.assistantBubble?.backgroundColor===void 0?{...Lo(u.assistantBubble,Is)}:{paddingVertical:r.md,paddingHorizontal:r.lg+zs,borderRadius:n.lg,...Lo(u.assistantBubble,Is)},bubbleVet:{maxWidth:Ts,paddingVertical:r.md,paddingHorizontal:r.lg+zs,backgroundColor:t.bubbleVet,borderRadius:n.lg,borderTopLeftRadius:n.xs,...Lo(u.vetBubble,Is)},bubbleCards:{maxWidth:au},bubbleUserCards:{paddingVertical:su,paddingHorizontal:uu},bubbleTextUserCards:{fontSize:textRole(e,"message").fontSize,lineHeight:Math.round(textRole(e,"message").fontSize*du)},bubblePending:{opacity:Ls},bubbleTextUser:{...face(e,"regular"),color:t.onPrimary,fontSize:l.size.body,lineHeight:i,...Oo(u.userBubble)},bubbleTextAssistant:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:o,...Oo(u.assistantBubble)},bubbleTextVet:{...face(e,"regular"),color:t.onBubbleVet,fontSize:l.size.body,lineHeight:i,...Oo(u.vetBubble)},assistantName:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight,marginBottom:r.xs},assistantSender:{flexDirection:"row",alignItems:"center",gap:r.sm,marginBottom:r.xs},assistantAvatar:{width:hu,height:hu,borderRadius:hu/2},assistantNameInRow:{marginBottom:0},vetHeader:{flexDirection:"row",alignItems:"baseline",gap:r.sm,marginBottom:r.xs},vetSender:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.bodyTight},vetTime:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.caption},bubbleBold:face(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:face(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.md},followUpsHeading:{...face(e,"monoBold"),color:t.text.muted,fontSize:Ys,textTransform:"uppercase",letterSpacing:Qs,paddingBottom:r.sm,borderBottomWidth:eu,borderBottomColor:s},followUpSlot:{alignSelf:"stretch"},followUpSlotRuled:{borderTopWidth:eu,borderTopColor:s},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,minHeight:Zs,paddingVertical:r.sm+zs,...u.chip?.backgroundColor!==void 0||u.chip?.borderColor!==void 0?{paddingHorizontal:r.md}:{},...Lo(u.chip)},followUpText:{...face(e,"bold"),flex:1,color:t.brandInk,fontSize:l.size.bodyTight,...Oo(u.chip)},askChips:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,marginTop:r.md},askChip:{minHeight:xs,maxWidth:"100%",justifyContent:"center",paddingVertical:r.sm,paddingHorizontal:r.lg,borderRadius:n.pill,borderWidth:Js,borderColor:t.brandInk,backgroundColor:t.chatGround,...Lo(u.chip,Js)},askChipText:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*Xs),...Oo(u.chip)},composerOuter:{position:"relative"},askEntry:{marginHorizontal:r.md,marginTop:r.xs},composer:{marginHorizontal:r.md,marginTop:r.xs,minHeight:Es,justifyContent:"center",paddingLeft:r.sm,paddingRight:As,paddingVertical:js,backgroundColor:t.composerFill,borderWidth:Os,borderColor:t.composerBorder,borderRadius:n.pill,...Lo(u.composerInput,Os)},composerRow:{flexDirection:"row",alignItems:"center",gap:r.xs,minHeight:Ds},dictationError:{...face(e,"regular"),fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal,color:t.danger,paddingHorizontal:r.xs},attachControl:{width:Vs,height:Vs,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:Gs},input:{flex:1,minHeight:Ds,maxHeight:Rs,paddingHorizontal:0,paddingVertical:0,...face(e,"regular"),fontSize:l.size.body,lineHeight:a,color:t.text.primary,...Oo(u.composerInput)},sendControl:{minHeight:Hs,minWidth:Hs,alignItems:"center",justifyContent:"center"},sendDisc:{width:Hs,height:Hs,borderRadius:Hs/2,alignItems:"center",justifyContent:"center",...Lo(u.sendButton)},sendControlDisabled:{opacity:$s},poweredBy:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.micro,textAlign:"center",paddingBottom:r.xs}})}var yu=18,mu=28,vu=6,wu=1200,ku=.4,Cu=.4;function DictationButton({active:e,listening:t,elapsedMs:r,disabled:l=false,onToggle:i}){let a=useEverfurTheme(),s=n(()=>Su(a),[a]);return o(()=>{if(t)try{_.announceForAccessibility(Re.listening)}catch{}},[t]),/* @__PURE__ */O(b,{style:s.wrap,children:[t?/* @__PURE__ */E(Text,{style:s.timer,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",testID:"everfur-dictation-timer",children:sa(r)}):null,
106
- /* @__PURE__ */E(v,{onPress:()=>i(),disabled:l,accessibilityRole:"button",accessibilityLabel:e?Re.stopDictation:Re.dictate,accessibilityState:{selected:e,disabled:l},style:[s.button,l?s.buttonDisabled:null],testID:"everfur-dictation-button",children:e?/* @__PURE__ */O(A,{children:[
32
+ return E(Cross,{...e,rotate:"45deg"})}function CheckGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r);/* @__PURE__ */
33
+ return E(y,{style:ao(e),...oo,children:/* @__PURE__ */E(y,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}var uo={down:{rotate:"45deg",marginTop:-.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-.4}};function ChevronGlyph({size:e,color:t,strokeWidth:r,direction:n}){let l=so(e,r),i=e*.46,o=uo[n];/* @__PURE__ */
34
+ return E(y,{style:ao(e),...oo,children:/* @__PURE__ */E(y,{style:{width:i,height:i,borderRightWidth:l,borderBottomWidth:l,borderColor:t,marginTop:i*o.marginTop,marginLeft:i*o.marginLeft,transform:[{rotate:o.rotate}]}})})}function BookGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r),l={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};/* @__PURE__ */
35
+ return O(y,{style:[ao(e),{flexDirection:"row",gap:1}],...oo,children:[
36
+ /* @__PURE__ */E(y,{style:[l,{borderTopLeftRadius:e*.2}]}),
37
+ /* @__PURE__ */E(y,{style:[l,{borderTopRightRadius:e*.2}]})]})}function ArrowUpRightGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r),l=e*.5;/* @__PURE__ */
38
+ return O(y,{style:ao(e),...oo,children:[
39
+ /* @__PURE__ */E(y,{style:{position:"absolute",width:e*.78,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}}),
40
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.16,right:e*.16,width:l,height:l,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}function CopyGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r),l=e*.6,i={position:"absolute",width:l,height:l,borderWidth:n,borderColor:t,borderRadius:e*.14};/* @__PURE__ */
41
+ return O(y,{style:ao(e),...oo,children:[
42
+ /* @__PURE__ */E(y,{style:[i,{top:0,left:0}]}),
43
+ /* @__PURE__ */E(y,{style:[i,{bottom:0,right:0}]})]})}function ThumbGlyph({size:e,color:t,strokeWidth:r,active:n,rotate:l}){let i=so(e,r),o=n?t:"transparent";/* @__PURE__ */
44
+ return O(y,{style:[ao(e),{transform:[{rotate:l}]}],...oo,children:[
45
+ /* @__PURE__ */E(y,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),
46
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),
47
+ /* @__PURE__ */E(y,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.05}})]})}function InfoGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r);/* @__PURE__ */
48
+ return O(y,{style:[ao(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...oo,children:[
49
+ /* @__PURE__ */E(y,{style:{width:n,height:n,borderRadius:n,backgroundColor:t,marginBottom:e*.1}}),
50
+ /* @__PURE__ */E(y,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}function UploadGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r),l=e*.34;/* @__PURE__ */
51
+ return O(y,{style:ao(e),...oo,children:[
52
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.06,width:l,height:l,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}}),
53
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.1,width:n,height:e*.56,borderRadius:n,backgroundColor:t}}),
54
+ /* @__PURE__ */E(y,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}function PhotoGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r);/* @__PURE__ */
55
+ return O(y,{style:[ao(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...oo,children:[
56
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:t}}),
57
+ /* @__PURE__ */E(y,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function CameraGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r);/* @__PURE__ */
58
+ return O(y,{style:ao(e),...oo,children:[
59
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderTopLeftRadius:n,borderTopRightRadius:n}}),
60
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */E(y,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}function SearchGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r),l=e/24,i=16*l+n,o=11*l-i/2,a=11+8/Math.SQRT2,s=(21-a)*Math.SQRT2*l,u=(a+21)/2*l;/* @__PURE__ */
61
+ return O(y,{style:ao(e),...oo,children:[
62
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:o,left:o,width:i,height:i,borderRadius:i,borderWidth:n,borderColor:t}}),
63
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:u-n/2,left:u-(s+n)/2,width:s+n,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"45deg"}]}})]})}function EditGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r);/* @__PURE__ */
64
+ return O(y,{style:ao(e),...oo,children:[
65
+ /* @__PURE__ */E(y,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:n,borderColor:t,borderRadius:n,transform:[{rotate:"45deg"}]}}),
66
+ /* @__PURE__ */E(y,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:n,borderRadius:n,backgroundColor:t}})]})}function MapPinGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r),l=e*.62;/* @__PURE__ */
67
+ return O(y,{style:ao(e),...oo,children:[
68
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:0,width:l,height:l,borderRadius:l,borderWidth:n,borderColor:t,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */E(y,{style:{width:n*1.4,height:n*1.4,borderRadius:n,backgroundColor:t}})}),
69
+ /* @__PURE__ */E(y,{style:{position:"absolute",bottom:e*.04,width:l*.5,height:l*.5,borderRightWidth:n,borderBottomWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function SendGlyph({size:e,color:t,testID:r}){let n=e*.36;/* @__PURE__ */
70
+ return E(y,{style:ao(e),testID:r,...oo,children:/* @__PURE__ */E(y,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}function StopGlyph({size:e,color:t,testID:r}){/* @__PURE__ */
71
+ return E(y,{style:ao(e),testID:r,...oo,children:/* @__PURE__ */E(y,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}function MicGlyph({size:e,color:t,strokeWidth:r,testID:n}){let l=so(e,r);/* @__PURE__ */
72
+ return O(y,{style:ao(e),testID:n,...oo,children:[
73
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.08,width:e*.26,height:e*.48,borderWidth:l,borderColor:t,borderRadius:e*.13}}),
74
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.38,width:e*.56,height:e*.36,borderBottomWidth:l,borderLeftWidth:l,borderRightWidth:l,borderColor:t,borderBottomLeftRadius:e*.28,borderBottomRightRadius:e*.28}}),
75
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.74,width:l,height:e*.18,backgroundColor:t}})]})}function Ring({size:e,strokeWidth:t,color:r,children:n}){/* @__PURE__ */
76
+ return E(y,{style:[ao(e),{borderRadius:e/2,borderWidth:t??f.hairlineWidth,borderColor:r}],children:n})}function ArrowUpGlyph({size:e,color:t,strokeWidth:r,testID:n}){let l=so(e,r),i=e*.46;/* @__PURE__ */
77
+ return O(y,{style:ao(e),testID:n,...oo,children:[
78
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.16,bottom:e*.12,width:l,borderRadius:l,backgroundColor:t}}),
79
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.16+l/2,width:i,height:i,borderLeftWidth:l,borderTopWidth:l,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function ChatBubbleGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r);/* @__PURE__ */
80
+ return O(y,{style:ao(e),...oo,children:[
81
+ /* @__PURE__ */E(y,{style:{width:e*.8,height:e*.6,marginTop:-e*.12,borderWidth:n,borderColor:t,borderRadius:e*.14}}),
82
+ /* @__PURE__ */E(y,{style:{position:"absolute",bottom:e*.1,left:e*.22,width:e*.2,height:e*.2,borderLeftWidth:n,borderBottomWidth:n,borderColor:t}})]})}function HistoryGlyph({size:e,color:t,strokeWidth:r}){let n=so(e,r),l=e*.72,i=e/2;/* @__PURE__ */
83
+ return O(y,{style:ao(e),...oo,children:[
84
+ /* @__PURE__ */E(y,{style:{width:l,height:l,borderRadius:l/2,borderWidth:n,borderColor:t,borderLeftColor:"transparent",transform:[{rotate:"45deg"}]}}),
85
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:e*.16,left:e*.12,width:e*.2,height:e*.2,borderLeftWidth:n,borderBottomWidth:n,borderColor:t}}),
86
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:i-e*.2,left:i-n/2,width:n,height:e*.2+n/2,borderRadius:n,backgroundColor:t}}),
87
+ /* @__PURE__ */E(y,{style:{position:"absolute",top:i-n/2,left:i-n/2,width:e*.15+n/2,height:n,borderRadius:n,backgroundColor:t}})]})}var co=/* @__PURE__ */Object.freeze({standard:oe.standard,emphasized:oe.emphasized,exit:oe.exit,outQuad:/* @__PURE__ */Object.freeze([.25,.46,.45,.94]),out:/* @__PURE__ */Object.freeze([.23,1,.32,1])});var po=/* @__PURE__ */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:/* @__PURE__ */Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,bubbleInMs:280,bubbleFromScale:.94,bubbleRisePx:6,promptRisePx:8,reduced:false}),fo=/* @__PURE__ */Object.freeze({...po,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 ho(e){return e.motion.reducedMotion?fo:po}function go(e,t){return Math.max(0,t)*e.followUpStaggerMs}function bo(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)}function yo(){let e=useEverfurTheme();return ho(e)}var mo=8;function vo(e,t,r){return((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}function wo(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}function ko(e){let[t,r,n,l]=e;return e=>{if(e<=0)return 0;if(e>=1)return 1;let i=e;for(let r=0;r<mo;r+=1){let r=wo(i,t,n);if(r===0)break;i-=(vo(i,t,n)-e)/r}return vo(Math.min(1,Math.max(0,i)),r,l)}}var Co=ko(co.standard),So=ko(co.outQuad),xo=ko(co.out);function Ro(e){let t=l(null);return t.current===null&&(t.current=new P.Value(e)),t.current}function To(e,t={}){let r=t.risePx??0,l=t.delayMs??0,i=Ro(e>0?0:1);return o(()=>{if(e<=0){i.setValue(1);return}let t=P.timing(i,{toValue:1,duration:e,easing:So,useNativeDriver:true}),r=l>0?P.sequence([P.delay(l),t]):t;return r.start(),()=>r.stop()},[i,e,l]),n(()=>({opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[i,r])}function FadePresence({visible:e,inMs:t,outMs:r,style:n,children:l}){let[a,s]=i(e),u=Ro(e&&t<=0?1:0);return o(()=>{if(e){s(true);let e=P.timing(u,{toValue:1,duration:Math.max(0,t),easing:Co,useNativeDriver:true});return e.start(),()=>e.stop()}if(!a)return;if(r<=0){s(false);return}let n=P.timing(u,{toValue:0,duration:r,easing:Co,useNativeDriver:true});return n.start(({finished:e})=>{e&&s(false)}),()=>n.stop()},[e,a,t,r,u]),!a&&!e?null:/* @__PURE__ */E(P.View,{style:[n,{opacity:u}],children:l})}var _o=/* @__PURE__ */Object.freeze({opacity:1,transform:/* @__PURE__ */Object.freeze([{translateY:0},{scale:1}])});function zo(e,t){let[r]=i(()=>e?t.bubbleInMs:0),l=r>0,a=Ro(l?0:1);o(()=>{if(r<=0)return;let e=P.timing(a,{toValue:1,duration:r,easing:xo,useNativeDriver:true});return e.start(),()=>e.stop()},[r,a]);let s=t.bubbleFromScale,u=t.bubbleRisePx;return n(()=>l?{opacity:a,transform:[{translateY:a.interpolate({inputRange:[0,1],outputRange:[u,0]})},{scale:a.interpolate({inputRange:[0,1],outputRange:[s,1]})}]}:_o,[l,a,u,s])}function Io(e){let t=l(null),n=l(null),i=e[0]?.id??null;if(t.current===null||n.current!==i){let r=t.current===null;t.current=new Map(e.map(e=>[e.id,r&&e.pending===true])),n.current=i}let o=t.current;for(let t of e)o.has(t.id)||o.set(t.id,true);return r(e=>o.get(e)===true,[o])}var Po=12;function PressScale({style:e,containerStyle:t,children:n,onPressIn:l,onPressOut:i,hitSlop:o,...a}){let s=yo(),u=Ro(1),d=r(e=>{s.pressMs<=0||s.pressScale===1||P.timing(u,{toValue:e,duration:s.pressMs,easing:Co,useNativeDriver:true}).start()},[u,s.pressMs,s.pressScale]);/* @__PURE__ */
88
+ return E(w,{...a,hitSlop:o??Po,style:t,onPressIn:e=>{d(s.pressScale),l?.(e)},onPressOut:e=>{d(1),i?.(e)},children:/* @__PURE__ */E(P.View,{style:[e,{transform:[{scale:u}]}],children:n})})}function Fo(e,t,r){let n=t&&r.revealTickMs>0,[a,s]=i(0),u=l(e);return u.current=e,o(()=>{if(!n)return;let e=setInterval(()=>{s(e=>bo(r,e,u.current.length))},r.revealTickMs);return()=>clearInterval(e)},[n,r]),n?e.slice(0,Math.min(a,e.length)):e}var Lo=false;function Eo(e){e.layoutMs<=0||(Lo||(Lo=true,h.OS==="android"&&typeof z.setLayoutAnimationEnabledExperimental=="function"&&z.setLayoutAnimationEnabledExperimental(true)),I.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}))}function Oo(e,t){let r=l(e);r.current!==e&&(r.current=e,Eo(t))}var Ao=36,jo=22,Do=12,Mo=12,Bo=16,Ho="#000",Wo="rgba(0,0,0,0.45)";function AttachmentImageLightbox({uri:e,label:t,onClose:r}){let n=useEverfurTheme(),l=j();return e===null?null:/* @__PURE__ */O(S,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[
89
+ /* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:Me.closePreview,style:No.backdrop,onPress:r,children:/* @__PURE__ */E(T,{source:{uri:e},style:No.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),
90
+ /* @__PURE__ */E(y,{pointerEvents:"box-none",style:[No.closeWrap,{top:l.top+Mo}],children:/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Me.closePreview,hitSlop:Do,style:No.closeButton,onPress:r,children:/* @__PURE__ */E(CloseGlyph,{size:jo,color:n.color.surface,strokeWidth:2})})})]})}var No=f.create({backdrop:{flex:1,backgroundColor:Ho,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:Bo},closeButton:{width:Ao,height:Ao,borderRadius:Ao/2,backgroundColor:Wo,alignItems:"center",justifyContent:"center"}});var Uo=()=>{};function $o(){try{return g.currentState==="active"}catch{return false}}function createAppStateLifecycle(){return{onForeground(e){let t;try{let r=g.currentState==="background";t=g.addEventListener("change",t=>{t==="background"?r=!0:t==="active"&&r&&(r=!1,e())})}catch{return Uo}return()=>t.remove()},isVisible:$o}}function Vo(e,t){if(e===void 0)return{};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}function qo(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}function Go(e){return e?.textColor===void 0?{}:{color:e.textColor}}var Ko=/* @__PURE__ */Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Yo(e){return e!==Ko}var Qo=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Zo(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let l={handle:void 0},i=()=>{r.clearTimeout(l.handle),t.removeEventListener("abort",i),n()};l.handle=r.setTimeout(i,e),t.addEventListener("abort",i,{once:true})})}var Jo=4e3;var Xo=4e3;var ea=/* @__PURE__ */Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var ta=10*1024*1024,ra=5,na=120,la="/widget/v1/uploads/initiate";function isAttachmentMime(e){return typeof e=="string"&&ea.includes(e.trim().toLowerCase())}function sanitizeFilename(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<=na)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,na);let n=t.slice(r);return n.length>=na?t.slice(0,na):`${t.slice(0,r).slice(0,na-n.length)}${n}`}function formatBytes(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var ia=e=>/* @__PURE__ */Object.freeze({ok:true,value:e}),oa=e=>/* @__PURE__ */Object.freeze({ok:false,error:e});function aa(e,t,r,n){/* @__PURE__ */
91
+ return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}function attachmentSize(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}function validateAttachment(e){let t=sanitizeFilename(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!isAttachmentMime(r))return oa(aa("unsupported_type",false,t));let n=attachmentSize(e);return n===null?oa(aa("unknown",false,t)):n>ta?oa(aa("too_large",false,t,{sizeBytes:n})):ia(/* @__PURE__ */Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}function sa(e){if(typeof e!="object"||e===null)return null;let t=e,r=e=>typeof e=="string"&&e.length>0?e:null,n=e=>typeof e=="number"&&Number.isFinite(e)?e:null,l=r(t.upload_id),i=r(t.upload_url),o=r(t.s3_key);if(l===null||i===null||o===null)return null;let a={},s=t.upload_fields;if(typeof s=="object"&&s!==null)for(let[e,t]of Object.entries(s))typeof t=="string"&&(a[e]=t);/* @__PURE__ */
92
+ return Object.freeze({upload_id:l,upload_url:i,upload_fields:/* @__PURE__ */Object.freeze(a),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??ta,s3_key:o,purpose:r(t.purpose)})}function ua(e,t){let r=e.httpStatus;switch(e.code){case"quotaExceeded":return aa("quota_exceeded",false,t,{cause:e});case"rateLimited":return aa("rate_limited",true,t,{cause:e});case"idempotencyConflict":case"idempotencyInFlight":return aa("idempotency_conflict",true,t,{cause:e});case"validationFailed":return aa("unsupported_type",false,t,{cause:e});case"serviceUnavailable":case"streamTimeout":return aa("network",true,t,{cause:e});default:return r===429?aa("rate_limited",true,t,{cause:e}):r===503?aa("network",true,t,{cause:e}):r===void 0?aa("network",true,t,{cause:e}):aa("server",e.retryable,t,{httpStatus:r,cause:e})}}async function initiateAttachmentUpload(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:la,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return oa(ua(n.error,t.filename));let l=sa(n.value);return l===null?oa(aa("server",false,t.filename)):ia(l)}async function uploadAttachmentBytes(e,t,r,n){let l=()=>n?.signal?.aborted===true;if(l())return oa(aa("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),ia(void 0)}catch{return l()?oa(aa("cancelled",true,r.filename)):oa(aa("server",true,r.filename))}}var da=2,ca=3,pa=/* @__PURE__ */Object.freeze([1e3,2e3,4e3]),fa=0;function ha(){return fa+=1,`attachment-${fa}`}function createAttachmentQueue(e){let t=Math.max(1,e.concurrency??da),r=Math.max(1,e.maxAttempts??ca),n=e.backoffMs??pa,l=Math.max(1,e.maxPerMessage??ra),i=e.timers??Qo,o=e.newId??ha,a=Yo(e.transport),s=/* @__PURE__ */new Map,u=[],d=[],c=/* @__PURE__ */new Set,p=/* @__PURE__ */new Set,f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])}),h=false,g=()=>{f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze(u.flatMap(e=>{let t=s.get(e);return t===void 0?[]:[t.state]}))});for(let e of p)e()},b=(e,t)=>{e.state=/* @__PURE__ */Object.freeze({...e.state,...t}),g()},y=()=>{for(;!h&&c.size<t&&d.length>0;){let e=d.shift(),t=s.get(e);t!==void 0&&(c.add(e),m(t).finally(()=>{c.delete(e),y()}))}},m=async t=>{let{attachment:l}=t;for(;t.attempts<r;){if(h||t.controller.signal.aborted)return;t.attempts+=1;let o=t.controller.signal;b(t,{status:"uploading",error:null,progress:0});let a=await initiateAttachmentUpload(e.funnel,l,{signal:o});if(h||o.aborted)return;let s;if(!a.ok)s=oa(a.error);else{let r=await uploadAttachmentBytes(e.transport,a.value,l,{signal:o,onProgress:e=>{!o.aborted&&t.state.status==="uploading"&&b(t,{progress:ga(e)})}});if(h||o.aborted)return;s=r.ok?ia(a.value.s3_key):oa(r.error)}if(s.ok){b(t,{status:"uploaded",s3Key:s.value,error:null,progress:1});return}let u=s.error,d=u.retryable&&t.attempts<r;if(b(t,{status:d?"uploading":"failed",error:u,progress:0}),!d)return;let c=n[Math.min(t.attempts-1,n.length-1)]??0;await Zo(c,o,i)}},v=e=>{d.push(e.state.id),y()},w={available:a,subscribe(e){return p.add(e),()=>{p.delete(e)}},getSnapshot:()=>f,get uploading(){return f.attachments.some(e=>e.status==="uploading")},get s3Keys(){return f.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[])},add(e){let t=validateAttachment(e);if(!t.ok)return t;if(h||u.length>=l)return oa(aa("too_many",false,t.value.filename));let r=o(),n={attachment:t.value,controller:new AbortController,attempts:0,state:/* @__PURE__ */Object.freeze({id:r,filename:t.value.filename,previewUri:e.uri,contentType:t.value.contentType,sizeBytes:t.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return s.set(r,n),u.push(r),g(),v(n),ia(n.state)},retry(e){let t=s.get(e);t===void 0||h||t.state.status!=="failed"||(t.controller=new AbortController,t.attempts=0,b(t,{status:"uploading",error:null,progress:0,s3Key:null}),v(t))},remove(e){let t=s.get(e);if(t===void 0)return;t.controller.abort(),s.delete(e);let r=u.indexOf(e);r>=0&&u.splice(r,1);let n=d.indexOf(e);n>=0&&d.splice(n,1),g()},clear(){for(let e of[...u])w.remove(e)},dispose(){h=true;for(let e of s.values())e.controller.abort();s.clear(),u.length=0,d.length=0,p.clear(),f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])})}};return w}function ga(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function ba(e){switch(e.code){case"too_large":return Be(Me.attachmentTooLarge,{max:formatBytes(ta),filename:e.filename,size:formatBytes(e.sizeBytes??0)});case"too_many":return Be(Me.attachmentTooMany,{max:ra});case"unsupported_type":return Be(Me.attachmentUnsupported,{filename:e.filename});case"network":return Me.attachmentNetwork;case"server":return Be(Me.attachmentServer,{status:e.httpStatus?` (${e.httpStatus})`:""});case"cancelled":return Me.attachmentCancelled;case"rate_limited":return Me.attachmentRateLimited;case"quota_exceeded":return Me.attachmentQuota;case"idempotency_conflict":return Me.attachmentConflict;case"unknown":return Me.attachmentUnknown}}function ya(e,t){return Be(e>=t?Me.attachmentsFull:Me.addAttachment,{used:e,total:t})}var ma=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])});function useChatAttachments(e={}){let{runtime:t,userRef:userRef,scopeEpoch:s}=Ge(),u=e.maxPerMessage??ra,d=r(()=>{let{services:r}=t.registry;return createAttachmentQueue({funnel:createRequestFunnel({auth:r.authFor(userRef),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),transport:e.transport??r.uploadTransport,maxPerMessage:u})},[t,userRef,s,u,e.transport]),c=n(()=>e.queue??d(),[e.queue,d]),p=l(/* @__PURE__ */new WeakSet),[f,h]=i(null),g=f!==null&&f.of===c?f.queue:c;o(()=>{if(g!==e.queue){if(p.current.has(g)){h({of:c,queue:d()});return}return()=>{g.dispose(),p.current.add(g)}}},[g,c,d,e.queue]);let b=a(g.subscribe,g.getSnapshot,()=>ma),[y,m]=i(null),v=r(e=>{let t=(Array.isArray(e)?e:[e]).map(e=>g.add(e)),r=t.find(e=>!e.ok);return r!==void 0&&!r.ok&&m(r.error),t},[g,m]),w=r(e=>g.retry(e),[g]),k=r(e=>g.remove(e),[g]),C=r(()=>g.clear(),[g]),S=r(()=>m(null),[m]),x=b.attachments.some(e=>e.status==="uploading"),R=b.attachments.some(e=>e.status==="failed");return n(()=>({available:g.available,attachments:b.attachments,maxPerMessage:u,uploading:x,failed:R,blocked:x||R,s3Keys:b.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[]),rejected:y,add:v,retry:w,remove:k,clear:C,dismissRejected:S}),[g.available,b,u,x,R,y,v,w,k,C,S])}var va=6e3;function wa(e,t,r){let n=t.trim();if(!n)return e;let l=e===""||/\s$/.test(e)?"":" ",i=`${e}${l}${n}`;return typeof r=="number"&&r>0?i.slice(0,r):i}function ka(e){let t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/60),n=t%60;return`${r}:${n.toString().padStart(2,"0")}`}function Ca(e){switch(e){case"permissionDenied":return Me.micBlocked;case"noSpeech":return Me.noSpeech;case"unavailable":return Me.dictationUnavailable}}function Sa(e,t,r){if(e)try{e.track(t,{...r})}catch{}}var xa=["Apoquel","Cytopoint","Bravecto","NexGard","Simparica Trio","Credelio","Revolution","Heartgard","Interceptor","Sentinel","ProHeart","Rimadyl","carprofen","meloxicam","Metacam","Galliprant","gabapentin","trazodone","Librela","Solensia","Zenrelia","prednisone","prednisolone","amoxicillin","Clavamox","cephalexin","Convenia","metronidazole","doxycycline","Cerenia","maropitant","famotidine","omeprazole","Proin","Vetmedin","pimobendan","enalapril","furosemide","levothyroxine","methimazole","Vetsulin","fluoxetine","Sileo","tramadol","buprenorphine","Denamarin","Dasuquin","Cosequin","parvovirus","distemper","Bordetella","leptospirosis","heartworm","giardia","coccidia","pancreatitis","hypothyroidism","Cushing's disease","Addison's disease","IVDD","cruciate ligament","luxating patella","hip dysplasia","pyometra","kennel cough","otitis","FIV","FeLV","DHPP","FVRCP","Labrador Retriever","Golden Retriever","French Bulldog","German Shepherd","Dachshund","Cavalier King Charles Spaniel","Shih Tzu","Pomeranian","Chihuahua","Yorkshire Terrier","Bichon Frise","Havanese","Cockapoo","Goldendoodle","Labradoodle","Weimaraner","Vizsla","Shiba Inu","Springer Spaniel","Miniature Schnauzer","Corgi","Australian Shepherd","Border Collie","Siberian Husky","Beagle","Maine Coon","Ragdoll","Sphynx","Bengal cat","British Shorthair"];function Ra(e={}){let t=/* @__PURE__ */new Set,r=[];for(let n of[e.name,e.breed,...xa]){let e=(n??"").trim();if(!e)continue;let l=e.toLowerCase();if(!t.has(l)&&(t.add(l),r.push(e),r.length>=100))break}return r}function Ta(e,conversationId,t){let[n,l]=i({send:e,conversationId:conversationId,text:t??"",seeded:t??null}),a=n.send===e&&(n.conversationId===null||n.conversationId===conversationId);o(()=>{l(r=>{let n=r.send===e&&(r.conversationId===null||r.conversationId===conversationId),l=n?r.text:"",i=n?r.seeded:null,o=t!=null&&t!==i&&l.length===0;return{send:e,conversationId:conversationId,text:o?t:l,seeded:o?t:i}})},[e,conversationId,t]);let s=r(t=>l(r=>({send:e,conversationId:conversationId,text:t,seeded:r.seeded})),[e,conversationId]);return[a?n.text:"",s]}function _a(e,conversationId,t,r,n=false){let a=l({draft:t,setDraft:r});a.current={draft:t,setDraft:r};let s=l(null),[u,d]=i(null);o(()=>{if(e===void 0)return;let t=`${conversationId??""}`;if(s.current===t)return;s.current=t;let r=true;return(async()=>{let n=await Kr(()=>e.read(conversationId));if(!r)return;let l=n.ok&&typeof n.value=="string"?n.value:"";l.length>0&&a.current.draft.length===0&&a.current.setDraft(l),d(t)})(),()=>{r=false}},[e,conversationId]),o(()=>{e===void 0||n||u!==`${conversationId??""}`||Vr(()=>e.write(conversationId,t))},[e,conversationId,t,u,n])}function za(e){if(!(h.OS!=="ios"||e===""))try{let t=_?.announceForAccessibility;typeof t=="function"&&t.call(_,e)}catch{}}function AnnounceLine({line:e}){return o(()=>{za(e)},[e]),null}var Ia=12,Pa=80,Fa=44,La=22,Ea=.14,Oa=18,Aa=8,ja=/* @__PURE__ */Object.freeze({photo:Me.attachmentPhoto,camera:Me.attachmentCamera});function AttachmentPickerPopover({sources:e,full:t,onPick:r,onClose:l}){let i=useEverfurTheme(),o=n(()=>Da(i),[i]);/* @__PURE__ */
93
+ return O(y,{style:o.anchor,pointerEvents:"box-none",children:[
94
+ /* @__PURE__ */E(w,{style:o.dismissLayer,accessibilityRole:"button",accessibilityLabel:Me.closeAttachmentPicker,onPress:l}),
95
+ /* @__PURE__ */O(y,{style:o.bubble,children:[
96
+ /* @__PURE__ */E(y,{style:o.tilesRow,children:e.map(e=>/* @__PURE__ */O(PressScale,{accessibilityRole:"button",accessibilityLabel:ja[e],accessibilityState:{disabled:t},disabled:t,containerStyle:o.tile,style:o.tileInner,onPress:()=>r(e),children:[
97
+ /* @__PURE__ */E(y,{style:o.tileIconWrap,children:e==="photo"?/* @__PURE__ */E(PhotoGlyph,{size:La,color:i.color.brandInk,strokeWidth:1.5}):/* @__PURE__ */E(CameraGlyph,{size:La,color:i.color.brandInk,strokeWidth:1.5})}),
98
+ /* @__PURE__ */E(Text,{tier:"control",style:o.tileLabel,children:ja[e]})]},e))}),
99
+ /* @__PURE__ */E(y,{style:o.tail}),
100
+ /* @__PURE__ */E(y,{style:o.tailFill})]})]})}function Da(e){let t=e.color,r=e.radius;return f.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:Ea,shadowRadius:Oa,shadowOffset:{width:0,height:Aa},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:Pa,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:Fa,height:Fa,borderRadius:Fa/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...face(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-Ia/2,width:Ia,height:Ia,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:Ia+4,height:2,backgroundColor:t.surfaceCream}})}function parseColor(e){let t=Ma(e);return t===null?null:Va(t)}function Ma(e){if(typeof e=="number")return Wa(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return Ba(t.slice(1));if(t.toLowerCase().startsWith("0x"))return Ba(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Ha(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=Ba(t);if(e!==null)return e}return/^\d+$/.test(t)?Wa(Number.parseInt(t,10)):null}function Ba(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:Ua(t[0]),g:Ua(t[1]),b:Ua(t[2]),a:1};if(t.length===6)return{r:Na(t,0),g:Na(t,2),b:Na(t,4),a:1};if(t.length===8){let e=Na(t,0);return{r:Na(t,2),g:Na(t,4),b:Na(t,6),a:e/255}}return null}function Ha(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(e=>e.trim());if(n.length<3)return null;let l=$a(Number(n[0])),i=$a(Number(n[1])),o=$a(Number(n[2]));if(l===null||i===null||o===null)return null;let a=1;if(n.length>=4){let e=Number(n[3]);if(!Number.isFinite(e))return null;a=Math.min(1,Math.max(0,e))}return{r:l,g:i,b:o,a:a}}function Wa(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return{r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}function Na(e,t){return Number.parseInt(e.slice(t,t+2),16)}function Ua(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function $a(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function Va(e){if(e.a>=1)return qa(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return`rgba(${e.r},${e.g},${e.b},${t})`}function qa(e,t,r){return`#${Ga(e)}${Ga(t)}${Ga(r)}`.toUpperCase()}function Ga(e){return e.toString(16).padStart(2,"0")}var Ka="#111111",Ya="#FFFFFF",Qa="#000000";function readableOn(e){let t=Ma(e);if(t===null)return Ya;let r=Xa(t),n=Xa({r:17,g:17,b:17}),l=Xa({r:255,g:255,b:255});return ts(r,l)>=ts(r,n)?Ya:Ka}function Za(e,t){let r=readableOn(e);return contrastRatio(r,e)>=t?r:contrastRatio(Ya,e)>=contrastRatio(Qa,e)?Ya:Qa}function Ja(e){let t=t=>e.reduce((e,r)=>Math.min(e,contrastRatio(t,r)),Number.POSITIVE_INFINITY);return t(Ya)>=t(Qa)?Ya:Qa}function Xa(e){let t=es(e.r/255),r=es(e.g/255),n=es(e.b/255);return.2126*t+.7152*r+.0722*n}function es(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function ts(e,t){let r=Math.max(e,t),n=Math.min(e,t);return(r+.05)/(n+.05)}function contrastRatio(e,t){let r=Ma(e),n=Ma(t);if(r===null||n===null)return 1;let l=n.a>=1?n:{...n},i=r.a>=1?r:rs(r,l);return ts(Xa(i),Xa(l))}function rs(e,t){let r=e.a,n=(e,t)=>Math.round(e*r+t*(1-r));return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}function ns(e,t){let r=Ma(e),n=Ma(t);if(r===null||n===null)return null;let l=r.a>=1?r:rs(r,{...n});return qa(l.r,l.g,l.b)}function ls(e,t){let r=Ma(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return`rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}var is=.05;function os(e,t,r,n){let l=t[0];if(l===void 0)return r;let i=e=>t.every(t=>contrastRatio(e,t)>=n);if(Ma(e)===null)return r;if(i(e))return e;let o=ns(e,l),a=o===null?null:Ma(o),s=Ma(r);if(a===null||s===null)return r;for(let e=1;e<1/is;e+=1){let t=e*is,r=(e,r)=>Math.round(e+(r-e)*t),n=qa(r(a.r,s.r),r(a.g,s.g),r(a.b,s.b));if(i(n))return n}return r}var as=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var ss=56,us=12,ds=14,cs=10,ps=.45,fs="rgba(7,193,104,0.55)",hs="rgba(185,28,28,0.55)",gs=200,bs=300,ys=20,ms=22,vs=12,ws="rgba(0,0,0,0.78)",ks=220,Cs=100,Ss="rgba(255,255,255,0.15)";function AttachmentStrip({attachments:e,rejected:t,uploadFailed:r=false,onRetry:l,onRemove:i,onPreview:o,style:a}){let s=useEverfurTheme(),u=n(()=>xs(s),[s]);return e.length===0&&t===null?null:/* @__PURE__ */O(y,{style:[u.strip,a],children:[e.length>0?/* @__PURE__ */E(y,{style:u.cards,children:e.map(e=>/* @__PURE__ */E(PreviewCard,{row:e,styles:u,onRetry:l,onRemove:i,onPreview:o},e.id))}):null,r?/* @__PURE__ */E(Text,{style:u.rejected,accessibilityRole:"alert",children:Me.attachmentsFailedBlocked}):null,t!==null?/* @__PURE__ */E(Text,{style:u.rejected,accessibilityRole:"alert",children:ba(t)}):null]})}function PreviewCard({row:e,styles:t,onRetry:r,onRemove:n,onPreview:a}){let s=useEverfurTheme(),u=e.status==="uploading",d=e.status==="failed",c=e.status==="uploaded",p=l(e.status),[f,h]=i(false);return o(()=>{let t=p.current;p.current=e.status,e.status==="uploaded"&&t==="uploading"&&h(true)},[e.status]),/* @__PURE__ */O(y,{style:t.card,children:[
101
+ /* @__PURE__ */E(w,{accessibilityRole:c?"button":"image",accessibilityLabel:c?Be(Me.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:u,disabled:!c},disabled:!c,style:t.thumbHit,onPress:()=>a(e),children:/* @__PURE__ */O(y,{style:t.thumb,children:[
102
+ /* @__PURE__ */E(T,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),u?/* @__PURE__ */E(y,{style:t.uploadingOverlay,children:/* @__PURE__ */E(R,{size:"small",color:s.color.surface})}):null,f?/* @__PURE__ */E(SuccessFlash,{styles:t,onDone:()=>h(false)}):null]})}),d?/* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:Be(Me.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:/* @__PURE__ */E(y,{style:t.failedInner,children:/* @__PURE__ */E(CloseGlyph,{size:ys,color:s.color.surface,strokeWidth:2})})}):null,
103
+ /* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Be(Me.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:/* @__PURE__ */E(CloseGlyph,{size:vs,color:s.color.surface,strokeWidth:1.5})})]})}function SuccessFlash({styles:e,onDone:t}){let r=useEverfurTheme(),n=yo(),i=l(null);i.current===null&&(i.current=new P.Value(0));let a=i.current;return o(()=>{let e=P.sequence([P.timing(a,{toValue:1,duration:gs,useNativeDriver:true}),P.delay(n.uploadFlashMs),P.timing(a,{toValue:0,duration:bs,useNativeDriver:true})]);return e.start(({finished:e})=>{e&&t()}),()=>e.stop()},[a,n.uploadFlashMs,t]),/* @__PURE__ */E(P.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:a}],children:/* @__PURE__ */E(CheckGlyph,{size:ys,color:r.color.surface,strokeWidth:2})})}function SentImages({images:e,onPreview:t}){let r=useEverfurTheme(),l=n(()=>xs(r),[r]);if(e.length===0)return null;let i=e.length===1;/* @__PURE__ */
104
+ return E(y,{style:i?l.sentSingle:l.sentGrid,children:e.map((e,r)=>/* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:Be(Me.attachedImage,{filename:e.filename}),onPress:()=>t(e),children:/* @__PURE__ */E(T,{source:{uri:e.uri},style:i?l.singleImage:l.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${e.uri}-${r}`))})}function xs(e){let t=e.color,r=e.type;return f.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:ss,height:ss,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:us,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:f.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...as,alignItems:"center",justifyContent:"center",backgroundColor:ls(e.color.brandInk,ps)??e.color.brandSofter},successOverlay:{...as,alignItems:"center",justifyContent:"center",backgroundColor:fs},failedOverlay:{...as,borderRadius:us,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:hs},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:ms,height:ms,borderRadius:ms/2,backgroundColor:ws,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...face(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:ks,height:ks,borderRadius:ds,backgroundColor:Ss},gridImage:{width:Cs,height:Cs,borderRadius:cs,backgroundColor:Ss}})}var Rs="file",Ts="multipart upload failed";function _s(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(Rs,e.file)}catch{return Promise.reject(new Error(Ts))}return e.fetch!==void 0?Ps(e.fetch,e.url,t,e.signal):Is(e.url,t,e.signal)}function zs(e){return e>=200&&e<300}function Is(e,t,r){return new Promise((n,l)=>{let i=globalThis.XMLHttpRequest;if(typeof i!="function"||r?.aborted===true){l(new Error(Ts));return}let o=null,a=()=>{o!==null&&r?.removeEventListener("abort",o)},s=()=>{a(),l(new Error(Ts))};try{let l=new i;l.open("POST",e),l.withCredentials=!1,l.onload=()=>{a(),n(zs(l.status))},l.onerror=s,l.ontimeout=s,l.onabort=s,r!==void 0&&(o=()=>{try{l.abort()}finally{s()}},r.addEventListener("abort",o,{once:!0})),l.send(t)}catch{s()}})}function Ps(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(e=>e.ok)}var Fs="chat attachment upload: the file handle has no uri",Ls="chat attachment upload failed";function Es(e){return{uri:e.uri,name:sanitizeFilename(e.name),type:e.mimeType}}function createRnChatAttachmentTransport(e={}){/* @__PURE__ */
105
+ return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(Fs));let{signal:l,onProgress:i}=n,o=()=>Promise.reject(new Error(Ls));return l?.aborted===true?o():_s({url:t.upload_url,fields:t.upload_fields,file:Es(r),signal:l,fetch:e.fetch}).then(e=>{if(!e)return o();i?.(1)},o)}})}var Os=300,As=3e3,js=120,Ds=44,Ms=120,Bs="88%",Hs=520,Ws=2,Ns=.5,Us=1.5,$s=1.6,Vs=.6,qs=56,Gs=1.5,Ks=5,Ys=5,Qs=36,Zs=20,Js=14,Xs=Ds,eu=4,tu=24,ru=22,nu=.4,lu=Ds,iu=20,ou=.4,au=480,su=12,uu=.72,du=48,cu=1.5,pu=1.3,fu=1,hu=1,gu="12%",bu=14,yu=16,mu=28,vu=18,wu="84%",ku=10,Cu=15,Su=1.42,xu=4,Ru=3,Tu=14,_u=20;function zu(){let e=useEverfurTheme(),t=n(()=>Iu(e),[e]);return{theme:e,styles:t}}function Iu(e){let t=e.color,r=e.space,n=e.radius,l=e.type,i=Math.round(l.size.body*Us),o=Math.round(l.size.body*$s),a=Math.round(Zs*l.size.body/Js),s=t.borderRingCream,u=e.slots;return f.create({container:{flex:1,minHeight:js,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:js,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},homeEmpty:{flexGrow:1},emptyContent:{flexGrow:1,alignItems:"stretch",justifyContent:"flex-start",paddingTop:gu,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:au,gap:r.lg},errorText:{...face(e,"regular"),fontSize:l.size.subtitle,lineHeight:l.size.subtitle*l.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:Ds,minWidth:Ds,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...Vo(u.primaryButton)},retryLabel:{...face(e,"medium"),color:t.onPrimary,fontSize:l.size.body,...Go(u.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...face(e,"regular"),color:t.danger,fontSize:l.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,borderWidth:hu,borderColor:t.borderRingCream,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.bodyTight},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal},turnNoticeAction:{minHeight:Ds,justifyContent:"center"},turnNoticeActionLabel:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight},setupNoticeAction:{...face(e,"medium"),color:t.brandInk,fontSize:l.size.caption},reconnectingCaption:{...face(e,"medium"),color:t.text.secondary,fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},readingBox:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:r.xs,paddingVertical:r.md,paddingHorizontal:r.md+r.xs/2,backgroundColor:t.surfaceSubtle,borderRadius:n.md},readingDot:{width:6,height:6,borderRadius:n.pill,backgroundColor:t.brandInk},readingInline:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:Ru,minHeight:Tu},readingDotInline:{width:xu,height:xu,borderRadius:n.pill,backgroundColor:t.text.muted},list:{flex:1},earlierButton:{alignSelf:"center",minHeight:Ds,justifyContent:"center",paddingHorizontal:r.md+r.xs/2},earlierLabel:{...face(e,"monoBold"),color:t.linkInk,fontSize:l.size.caption},listContent:{padding:r.lg,gap:r.xl},listContentCards:{paddingTop:bu,paddingHorizontal:yu,paddingBottom:mu,gap:vu},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:Bs,alignItems:"flex-start"},bubbleSideUser:{alignItems:"flex-end"},bubbleUser:{maxWidth:Hs,paddingVertical:r.md,paddingHorizontal:r.lg+Ws,backgroundColor:t.bubbleUser,...t.primaryEdge!==t.primary&&t.bubbleUser===t.primary?{borderWidth:Ns,borderColor:t.primaryEdge}:{},borderRadius:n.lg,borderBottomRightRadius:n.xs,...Vo(u.userBubble,Ns)},bubbleAssistant:u.assistantBubble?.backgroundColor===void 0?{...Vo(u.assistantBubble,Ns)}:{paddingVertical:r.md,paddingHorizontal:r.lg+Ws,borderRadius:n.lg,...Vo(u.assistantBubble,Ns)},bubbleVet:{maxWidth:Hs,paddingVertical:r.md,paddingHorizontal:r.lg+Ws,backgroundColor:t.bubbleVet,borderRadius:n.lg,borderTopLeftRadius:n.xs,...Vo(u.vetBubble,Ns)},bubbleCards:{maxWidth:wu},bubbleUserCards:{paddingVertical:ku,paddingHorizontal:Cu},bubbleTextUserCards:{fontSize:textRole(e,"message").fontSize,lineHeight:Math.round(textRole(e,"message").fontSize*Su)},bubblePending:{opacity:Vs},bubbleTextUser:{...face(e,"regular"),color:t.onPrimary,fontSize:l.size.body,lineHeight:i,...Go(u.userBubble)},bubbleTextAssistant:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:o,...Go(u.assistantBubble)},bubbleTextVet:{...face(e,"regular"),color:t.onBubbleVet,fontSize:l.size.body,lineHeight:i,...Go(u.vetBubble)},assistantName:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight,marginBottom:r.xs},assistantSender:{flexDirection:"row",alignItems:"center",gap:r.sm,marginBottom:r.xs},assistantAvatar:{width:_u,height:_u,borderRadius:_u/2},assistantNameInRow:{marginBottom:0},vetHeader:{flexDirection:"row",alignItems:"baseline",gap:r.sm,marginBottom:r.xs},vetSender:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.bodyTight},vetTime:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.caption},bubbleBold:face(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:face(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.md},followUpsHeading:{...face(e,"monoBold"),color:t.text.muted,fontSize:su,textTransform:"uppercase",letterSpacing:uu,paddingBottom:r.sm,borderBottomWidth:fu,borderBottomColor:s},followUpSlot:{alignSelf:"stretch"},followUpSlotRuled:{borderTopWidth:fu,borderTopColor:s},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,minHeight:du,paddingVertical:r.sm+Ws,...u.chip?.backgroundColor!==void 0||u.chip?.borderColor!==void 0?{paddingHorizontal:r.md}:{},...Vo(u.chip)},followUpText:{...face(e,"bold"),flex:1,color:t.brandInk,fontSize:l.size.bodyTight,...Go(u.chip)},askChips:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,marginTop:r.md},askChip:{minHeight:Ds,maxWidth:"100%",justifyContent:"center",paddingVertical:r.sm,paddingHorizontal:r.lg,borderRadius:n.pill,borderWidth:cu,borderColor:t.brandInk,backgroundColor:t.chatGround,...Vo(u.chip,cu)},askChipText:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*pu),...Go(u.chip)},composerOuter:{position:"relative"},askEntry:{marginHorizontal:r.md,marginTop:r.xs},composer:{marginHorizontal:r.md,marginTop:r.xs,minHeight:qs,justifyContent:"center",paddingLeft:r.sm,paddingRight:Ks,paddingVertical:Ys,backgroundColor:t.composerFill,borderWidth:Gs,borderColor:t.composerBorder,borderRadius:n.pill,...Vo(u.composerInput,Gs)},composerRow:{flexDirection:"row",alignItems:"center",gap:r.xs,minHeight:Qs},dictationError:{...face(e,"regular"),fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal,color:t.danger,paddingHorizontal:r.xs},attachControl:{width:lu,height:lu,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:ou},input:{flex:1,minHeight:Qs,maxHeight:Ms,paddingHorizontal:0,paddingVertical:0,...face(e,"regular"),fontSize:l.size.body,lineHeight:a,color:t.text.primary,...Go(u.composerInput)},sendControl:{minHeight:Xs,minWidth:Xs,alignItems:"center",justifyContent:"center"},sendDisc:{width:Xs,height:Xs,borderRadius:Xs/2,alignItems:"center",justifyContent:"center",...Vo(u.sendButton)},sendControlDisabled:{opacity:nu},poweredBy:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.micro,textAlign:"center",paddingBottom:r.xs}})}var Pu=18,Fu=28,Lu=6,Eu=1200,Ou=.4,Au=.4;function DictationButton({active:e,listening:t,elapsedMs:r,disabled:l=false,onToggle:i}){let a=useEverfurTheme(),s=n(()=>ju(a),[a]);return o(()=>{if(t)try{_.announceForAccessibility(Me.listening)}catch{}},[t]),/* @__PURE__ */O(y,{style:s.wrap,children:[t?/* @__PURE__ */E(Text,{style:s.timer,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",testID:"everfur-dictation-timer",children:ka(r)}):null,
106
+ /* @__PURE__ */E(w,{onPress:()=>i(),disabled:l,accessibilityRole:"button",accessibilityLabel:e?Me.stopDictation:Me.dictate,accessibilityState:{selected:e,disabled:l},style:[s.button,l?s.buttonDisabled:null],testID:"everfur-dictation-button",children:e?/* @__PURE__ */O(A,{children:[
107
107
  /* @__PURE__ */E(Pulse,{style:s.pulse,reduced:a.motion.reducedMotion}),
108
- /* @__PURE__ */E(StopGlyph,{size:mu,color:a.color.brandInk,testID:"everfur-dictation-stop"})]}):/* @__PURE__ */E(MicGlyph,{size:yu,color:a.color.brandInk,testID:"everfur-dictation-mic"})})]})}function Pulse({style:e,reduced:t}){let r=l(new I.Value(1)).current;return o(()=>{if(t)return;let e=I.loop(I.sequence([I.timing(r,{toValue:ku,duration:wu/2,useNativeDriver:true}),I.timing(r,{toValue:1,duration:wu/2,useNativeDriver:true})]));return e.start(),()=>e.stop()},[r,t]),/* @__PURE__ */E(I.View,{style:[e,{opacity:r}],accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"})}function Su(e){let t=e.color,r=e.type.tierSizes.compact.micro;return p.create({wrap:{flexDirection:"row",flexShrink:0,alignItems:"center",gap:e.space.xs},timer:{...face(e,"mono"),fontSize:r,lineHeight:r+2,fontVariant:["tabular-nums"],color:t.text.muted},button:{width:xs,height:xs,borderRadius:e.radius.pill,alignItems:"center",justifyContent:"center"},buttonDisabled:{opacity:Cu},pulse:{position:"absolute",top:vu,right:vu,bottom:vu,left:vu,borderRadius:e.radius.pill,backgroundColor:t.brandSofter}})}function optionalModule(e,t,r){let n;try{n=t()}catch(t){return Ru(`optional peer '${e}' is not installed: ${_u(t)}`)}let l=xu(n);return l==null?Ru(`optional peer '${e}' resolved to no module`):r&&!r(l)?Ru(`optional peer '${e}' is present but failed its shape check`):/* @__PURE__ */Object.freeze({available:true,module:l})}function xu(e){return typeof e=="object"&&e!==null&&"default"in e&&Object.keys(e).length<=2?e.default:e}function Ru(e){/* @__PURE__ */
109
- return Object.freeze({available:false,module:null,reason:e})}function _u(e){return e instanceof Error?e.message:typeof e=="string"?e:"unknown load error"}var Tu=/* @__PURE__ */Symbol.for("@everfur/sdk/rn-dictation");function zu(){let e=globalThis,t=e[Tu];if(t!==void 0)return t;let r={loader:null,memo:void 0};return e[Tu]=r,r}function registerEverfurDictation(e){let t=zu();t.loader=e,t.memo=void 0,t.version=(t.version??0)+1;for(let e of[...t.listeners??[]])try{e()}catch{}}function Iu(){return zu().version??0}function Pu(e){let t=zu(),r=t.listeners??/* @__PURE__ */new Set;t.listeners=r;let n=()=>e();return r.add(n),()=>{r.delete(n)}}function Fu(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.start=="function"&&typeof t.isRecognitionAvailable=="function"&&typeof t.addListener=="function"}function Lu(e){return typeof e!="object"||e===null?null:e.ExpoSpeechRecognitionModule??e}function Eu(){let e=zu();if(e.memo!==void 0)return e.memo;e.memo=null;let t=e.loader;if(t===null||f.OS!=="ios"&&f.OS!=="android")return e.memo;let r=optionalModule("expo-speech-recognition",()=>({box:Lu(t())}),e=>typeof e=="object"&&e!==null&&Fu(e.box));return r.available&&(e.memo=r.module.box),e.memo}function Ou(e){if(e===null)return false;try{return e.isRecognitionAvailable()===!0}catch{return false}}function Au(){try{return Intl.DateTimeFormat().resolvedOptions().locale||Du}catch{return Du}}function ju(e){return e.replace(/_/g,"-").toLowerCase()}var Du="en-US";function Mu(e=Au()){let[t=""]=e.replace(/_/g,"-").split("-u-"),r=t.split("-");if(r[0]?.toLowerCase()!=="en")return Du;let n=r.slice(1).find(e=>/^[A-Za-z]{2}$/.test(e));return n?`en-${n.toUpperCase()}`:Du}function Bu(e,t){if(t.length===0)return null;let r=e=>t.find(t=>ju(t)===ju(e));return r(e)??r(Du)??t.find(e=>ju(e).startsWith("en-"))??null}async function Hu(e,t){if(f.OS!=="ios")return t;try{let{locales:r}=await e.getSupportedLocales({});return Bu(t,r??[])??t}catch{return t}}async function Wu(e,t){let r=false;try{r=e.supportsOnDeviceRecognition()===!0}catch{r=false}if(!r)return"network";if(f.OS!=="android")return"on_device";try{let{installedLocales:r}=await e.getSupportedLocales({}),n=ju(t);return(r??[]).some(e=>ju(e)===n)?"on_device":"network"}catch{return"network"}}function Nu(){return f.OS!=="android"?true:Number(f.Version)>=Uu}var Uu=33;function $u(e,t,r){return{lang:t,interimResults:true,continuous:Nu(),maxAlternatives:1,addsPunctuation:true,requiresOnDeviceRecognition:e==="on_device",contextualStrings:r.slice(0,100),iosTaskHint:"dictation"}}var Vu=/* @__PURE__ */new Set(["not-allowed","no-speech","speech-timeout","aborted","interrupted"]),qu=/* @__PURE__ */new Set(["busy","client","network","audio-capture","too-many-requests","unknown"]);function Gu(e){return qu.has(e)}var Ku=600,Yu=3;function Qu(e,t,r){if(Vu.has(r))return null;let n=Gu(r)?Ku:0;return r==="language-not-supported"&&ju(t)!==ju(Du)?{mode:"network",lang:Du,delayMs:n}:e==="on_device"?{mode:"network",lang:t,delayMs:n}:n>0?{mode:"network",lang:t,delayMs:n}:null}function Zu(e){return e==="not-allowed"?"permissionDenied":e==="no-speech"||e==="speech-timeout"?"noSpeech":"unavailable"}async function Ju(e){try{if((await e.getPermissionsAsync()).granted)return"granted"}catch{}try{return(await e.requestPermissionsAsync()).granted?"granted":"denied"}catch{return"error"}}var Xu=55e3,ed=3e3,td=1e3;function rd(e){return nd.has(e)||Gu(e)}var nd=/* @__PURE__ */new Set(["no-speech","speech-timeout","aborted","interrupted"]),ld=/* @__PURE__ */Object.freeze({committed:/* @__PURE__ */Object.freeze([]),interim:""});function id(e){return e.replace(/\s+/g," ").trim()}function od(e,t,r){let n=id(t);return r?n?{committed:[...e.committed,n],interim:""}:{committed:e.committed,interim:""}:{committed:e.committed,interim:n}}function ad(e){return id([...e.committed,e.interim].join(" "))}function sd(e,t,r,n=Date.now){let l=0,i=null,o=Number.NEGATIVE_INFINITY,a=e=>i!==null&&i.token===e?i:null;function s(e){for(let t of e.subscriptions)try{t.remove()}catch{}e.subscriptions=[]}function u(e){s(e),e.autoStopTimer!==null&&clearTimeout(e.autoStopTimer),e.graceTimer!==null&&clearTimeout(e.graceTimer),e.retryTimer!==null&&clearTimeout(e.retryTimer),e.autoStopTimer=null,e.graceTimer=null,e.retryTimer=null,i===e&&(i=null)}function d(e){return!e.sawStart&&e.errorCode===null&&e.pendingRetry===null&&ad(e.transcript)===""&&e.launchedAt-o<td}function c(e){return e.mode??"none"}function p(e,t){da(r(),"chat_dictation_completed",{mode:c(e),duration_ms:e.startedAt===null?0:Math.max(0,n()-e.startedAt),char_count:t.length})}function f(e,n){da(r(),"chat_dictation_failed",{mode:c(e),error:n}),t.onStatus("idle"),t.onError(n)}function h(e){if(a(e.token)===null)return;u(e);let r=ad(e.transcript),n=e.errorCode;if(n!==null&&!(r&&rd(n))){f(e,Zu(n));return}if(!r){f(e,"noSpeech");return}p(e,r),t.onStatus("idle")}function g(l){l.subscriptions=[e.addListener("start",()=>{a(l.token)!==null&&(l.sawStart=true,l.startedAt===null&&(l.startedAt=n()),da(r(),"chat_dictation_started",{mode:c(l)}),t.onStatus("listening"))}),e.addListener("result",e=>{if(a(l.token)===null)return;let r=e?.results?.[0]?.transcript??"";l.transcript=od(l.transcript,r,e?.isFinal===true),t.onText(ad(l.transcript))}),e.addListener("error",e=>{if(a(l.token)===null)return;let t=e?.error??"unknown";if(l.userStopped&&(t==="aborted"||Gu(t)))return;let r=ad(l.transcript)==="",n=l.mode!==null&&!l.userStopped&&r&&l.retries<Yu?Qu(l.mode,l.lang,t):null;if(n!==null){l.pendingRetry=n;return}l.errorCode===null&&(l.errorCode=t)}),e.addListener("end",()=>{if(a(l.token)!==null&&!d(l)){if(l.pendingRetry!==null){let e=l.pendingRetry;if(l.pendingRetry=null,l.retries+=1,l.lang=e.lang,e.delayMs<=0){b(l,e.mode);return}s(l),l.retryTimer=setTimeout(()=>{l.retryTimer=null,!(a(l.token)===null||l.userStopped)&&b(l,e.mode)},e.delayMs);return}h(l)}})]}function b(t,r){s(t),t.mode=r,t.sawStart=false,t.launchedAt=n(),t.transcript=ld,t.errorCode=null,g(t);try{e.start($u(r,t.lang,t.phrases))}catch{t.errorCode="unknown",h(t)}}async function y(t){let r=await Ju(e);if(a(t.token)===null)return;if(r!=="granted"){u(t),f(t,r==="denied"?"permissionDenied":"unavailable");return}if(t.lang=await Hu(e,t.lang),a(t.token)===null)return;let n=await Wu(e,t.lang);a(t.token)!==null&&(t.autoStopTimer=setTimeout(()=>m(t),Xu),b(t,n))}function m(r){if(!(a(r.token)===null||r.userStopped)){if(r.userStopped=true,r.pendingRetry=null,r.mode===null||r.retryTimer!==null){u(r),t.onStatus("idle");return}r.graceTimer=setTimeout(()=>h(r),ed);try{e.stop()}catch{h(r)}}}return{start(e){if(i!==null)return;let r={token:++l,phrases:e,lang:Mu(),mode:null,retries:0,pendingRetry:null,userStopped:false,transcript:ld,errorCode:null,startedAt:null,sawStart:false,launchedAt:0,subscriptions:[],autoStopTimer:null,graceTimer:null,retryTimer:null};i=r,t.onStatus("starting"),y(r)},stop(){i!==null&&m(i)},cancel(){let r=i;if(r===null)return;let l=r.mode!==null&&r.retryTimer===null,a=ad(r.transcript);if(u(r),t.onStatus("idle"),!!l){a&&p(r,a),o=n();try{e.abort()}catch{}}},isActive:()=>i!==null,isPreparing:()=>i!==null&&i.mode===null}}function ud({enabled:e,input:t,setInput:s,phrases:u,maxLength:d,telemetry:c}){let p=a(Pu,Iu,Iu),f=n(()=>e?Eu():null,[e,p]),g=n(()=>Ou(f),[f]),[b,y]=i("idle"),[m,v]=i(null),[w,k]=i(0),C=l(t);C.current=t;let S=l(s);S.current=s;let x=l(c);x.current=c;let R=l(""),_=l(d);_.current=d;let T=l(null);f!==null&&T.current?.mod!==f&&(T.current?.controller.cancel(),T.current={mod:f,controller:sd(f,{onStatus:e=>{y(t=>e==="idle"&&t==="error"?t:e)},onText:e=>S.current(aa(R.current,e,_.current)),onError:e=>{v(e),y("error")}},()=>x.current)});let z=f===null?null:T.current?.controller??null,I=r(()=>{z?.cancel()},[z]),P=r(()=>{if(z!==null){if(z.isActive()){z.stop();return}v(null),k(0),R.current=C.current,z.start(u)}},[z,u]);o(()=>{if(b!=="listening")return;let e=Date.now();k(0);let t=setInterval(()=>k(Date.now()-e),1e3);return()=>clearInterval(t)},[b]),o(()=>{if(b!=="error")return;let e=setTimeout(()=>{v(null),y("idle")},oa);return()=>clearTimeout(e)},[b]),o(()=>{if(z===null)return;let e=null;try{e=h.addEventListener("change",e=>{e==="background"&&!z.isPreparing()&&z.cancel()})}catch{}return()=>{e?.remove(),z.cancel()}},[z]);let F=e&&g;return o(()=>{F||z?.cancel()},[F,z]),{supported:F,status:b,active:b==="starting"||b==="listening",error:m,elapsedMs:w,toggle:P,cancel:I}}var dd=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatPaneShown");function cd(){let e=globalThis,t=e[dd];if(t!==void 0)return t;let r=createContext(true);return e[dd]=r,r}var pd=cd();function fd(){return s(pd)}var hd=/* @__PURE__ */Object.freeze(["photo"]),gd=52,bd=1.5,yd=10,md=14,vd=10,wd=40,kd=20,Cd=.3,Sd=2.5,xd=1,Rd=1.5,_d=38,Td=22,zd=3;function Id(e,t,r,n="ask",l=false){let i=typeof t=="string"&&t.trim()!=="";return r&&i&&n!=="urgent"?ze(Re.placeholder,t):e!==null?!l||!e.includes("{pet}")?e:i?e.split("{pet}").join(t.trim()):ze(Re.placeholder,t):n==="urgent"?Re.placeholderUrgentWeb:n==="followUp"?Re.placeholderFollowUpWeb:ze(Re.placeholder,t)}function ComposerWithAttachments({attachments:e,...t}){let r=n(()=>createRnChatAttachmentTransport(),[]),l=useChatAttachments({maxPerMessage:e.maxPerMessage??Uo,transport:r}),i=n(()=>({state:l,sources:e.sources??hd,pick:e.pick}),[l,e.sources,e.pick]);/* @__PURE__ */
110
- return E(Composer,{...t,attachments:i})}function Composer({send:e,stop:t,isStreaming:a,conversationId:conversationId,attachments:s,seed:u,draftStore:d,onStage:c,onPreview:p,petName:f,petBreed:h=null,mood:g="ask",dictation:y=false,telemetry:m=null,compact:w=false,petPlaceholder:k=false,dimEmptySend:C=false}){let{theme:S,styles:x}=gu(),R=n(()=>Ad(S),[S]),_=n(()=>jd(S),[S]),T=no(),[z,I]=fa(e,conversationId,u),[P,F]=i(false),[L,j]=i(false),D=r(()=>j(true),[]),M=r(()=>j(false),[]),[B,H]=i(false);o(()=>{H(false)},[conversationId]);let W=Id(S.meta.placeholder,f,k,g,S.meta.placeholderFillsPet===true),N=n(()=>pa({name:f,breed:h}),[f,h]),U=ud({enabled:y,input:z,setInput:I,phrases:N,maxLength:Ho,telemetry:m}),$=U.cancel,V=U.active;ha(d,conversationId===null?null:String(conversationId),z,I,V);let q=l(conversationId);o(()=>{q.current!==conversationId&&(q.current=conversationId,$())},[conversationId,$]);let G=fd();o(()=>{G||$()},[G,$]);let K=s?.state.uploading??false,Y=s?.state.failed??false,Q=K||Y,Z=s?.state.attachments??Pd;ko(Z.length,T);let J=r(()=>{let t=z.trim();if(t.length===0||Q||[...t].length>Ho)return;V&&$();let r=s?.state.s3Keys??Fd;s!==null&&r.length>0?(c(s.state.attachments.filter(e=>e.status==="uploaded").map(e=>({uri:e.previewUri,filename:e.filename}))),e(t,{imageS3Keys:r}),s.state.clear()):e(t),I(""),H(false)},[z,e,Q,V,$,s,c]),X=r(e=>{V&&$(),I(e)},[V,$,I]),ee=r(()=>{t()},[t]),te=r(e=>{F(false),s!==null&&(H(false),s.state.dismissRejected(),Ar(s.pick,e).then(e=>{if(!e.ok){H(true);return}e.value!==null&&s.state.add(e.value)}))},[s]),re=n(()=>[...z.trim()].length>Ho,[z]),ne=re||Q||z.trim().length===0,le=re||Q||C&&z.trim().length===0,ie=s!==null&&Z.length>=s.state.maxPerMessage,oe=S.slots.sendButton?.textColor??S.color.brandInk,ae=S.slots.sendButton?.textColor??S.color.surface;/* @__PURE__ */
111
- return O(b,{style:x.composerOuter,children:[s!==null&&P?/* @__PURE__ */E(AttachmentPickerPopover,{sources:s.sources,full:ie,onPick:te,onClose:()=>F(false)}):null,s!==null?/* @__PURE__ */E(AttachmentStrip,{attachments:Z,rejected:B?Od:s.state.rejected,uploadFailed:Y,onRetry:s.state.retry,onRemove:s.state.remove,onPreview:e=>p({uri:e.previewUri,label:e.filename}),style:w?R.tray:_.tray}):null,
112
- /* @__PURE__ */O(b,{style:w?[x.composer,R.bar,L?R.barFocused:null]:x.composer,children:[U.supported&&U.error!==null?/* @__PURE__ */O(A,{children:[
113
- /* @__PURE__ */E(Text,{style:x.dictationError,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:ua(U.error)}),
114
- /* @__PURE__ */E(AnnounceLine,{line:ua(U.error)})]}):null,
115
- /* @__PURE__ */O(b,{style:x.composerRow,children:[s!==null?/* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:ie?la(Z.length,s.state.maxPerMessage):Re.attachPhotoOrFileNative,accessibilityState:{disabled:ie,expanded:P},disabled:ie,style:[x.attachControl,w?R.add:null,ie?x.attachControlDisabled:null],hitSlop:w?zd:void 0,onPress:()=>F(e=>!e),children:/* @__PURE__ */E(UploadGlyph,{size:w?Td:qs,color:ie?S.color.text.muted:w?S.color.text.primary:S.color.brandInk,strokeWidth:1.75})}):null,
116
- /* @__PURE__ */E(ge,{style:w?[x.input,R.input]:x.input,onFocus:D,onBlur:M,value:z,onChangeText:X,placeholder:W,placeholderTextColor:S.slots.composerInput?.textColor??S.color.text.placeholder,accessibilityLabel:Re.composerLabel,onSubmitEditing:J,returnKeyType:"send",...Ld,...w?Ed:null,blurOnSubmit:false,multiline:true,editable:true}),U.supported?/* @__PURE__ */E(DictationButton,{active:U.active,listening:U.status==="listening",elapsedMs:U.elapsedMs,onToggle:U.toggle}):null,a?/* @__PURE__ */E(v,{onPress:ee,accessibilityRole:"button",accessibilityLabel:Re.stop,style:x.sendControl,children:/* @__PURE__ */E(b,{style:w?R.disc:x.sendDisc,testID:"everfur-stop-disc",children:/* @__PURE__ */E(StopGlyph,{size:w?kd:Us,color:w?ae:oe,testID:"everfur-stop-glyph"})})}):/* @__PURE__ */E(v,{onPress:J,disabled:ne,accessibilityRole:"button",accessibilityLabel:Re.send,accessibilityState:{disabled:ne,busy:K},style:[x.sendControl,le?w?R.dimmed:x.sendControlDisabled:null],children:w?/* @__PURE__ */E(b,{style:R.disc,testID:"everfur-send-disc",children:/* @__PURE__ */E(ArrowUpGlyph,{size:kd,color:ae,strokeWidth:2.25,testID:"everfur-send-arrow"})}):/* @__PURE__ */E(b,{style:x.sendDisc,testID:"everfur-send-disc",children:/* @__PURE__ */E(SendGlyph,{size:Ns,color:oe,testID:"everfur-send-glyph"})})})]})]})]})}var Pd=/* @__PURE__ */Object.freeze([]),Fd=/* @__PURE__ */Object.freeze([]),Ld=/* @__PURE__ */Object.freeze({submitBehavior:"submit"}),Ed=/* @__PURE__ */Object.freeze(f.OS==="web"?{rows:1}:{}),Od=/* @__PURE__ */Object.freeze({code:"unknown",retryable:true,filename:""});function Ad(e){let t=e.color,r=e.slots.sendButton,n=textRole(e,"body").fontSize+xd;return p.create({bar:{marginTop:yd,marginHorizontal:md,marginBottom:vd,minHeight:gd,paddingLeft:8,paddingRight:6,paddingVertical:0,borderWidth:bd,borderColor:e.slots.composerInput?.borderColor??t.text.primary},barFocused:{borderWidth:Sd,paddingLeft:8-(Sd-bd),paddingRight:6-(Sd-bd)},input:{fontSize:n,lineHeight:Math.round(n*Rd),minHeight:Math.round(n*Rd),...f.OS==="web"?{outlineStyle:"none"}:null},add:{width:_d,height:_d,borderRadius:_d/2},disc:{width:wd,height:wd,borderRadius:wd/2,alignItems:"center",justifyContent:"center",backgroundColor:r?.backgroundColor??t.text.primary,...Lo(r)},dimmed:{opacity:Cd},tray:{marginHorizontal:md,marginTop:yd,paddingBottom:0}})}function jd(e){return p.create({tray:{marginHorizontal:e.space.md,marginTop:e.space.xs,paddingBottom:0}})}var Dd=/* @__PURE__ */new WeakMap;function Md(e,t){let r=Dd.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,Dd.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:e,userRef:userRef,activePet:t,scopeEpoch:a}=Oe(),s=n(()=>createPetsRepository(e.registry.services.authFor(userRef)),[e,userRef,a]),[u,d]=i({repository:s,pets:[],loading:true,error:null}),c=u.repository===s?u:{pets:[],loading:true,error:null},p=l(0),f=r(async()=>{let e=++p.current;d(e=>({...e,repository:s,loading:true,error:null,pets:e.repository===s?e.pets:[]}));let t=await s.list();e===p.current&&d(t.ok?{repository:s,pets:t.value,loading:false,error:null}:e=>({repository:s,pets:e.repository===s?e.pets:[],loading:false,error:t.error}))},[s]);o(()=>(f(),()=>{p.current+=1}),[f]),o(()=>Md(e,()=>{f()}),[e,f]);let h=n(()=>t===null?null:c.pets.find(e=>e.petRef===t)??null,[t,c.pets]);return n(()=>({pets:c.pets,activePet:h,loading:c.loading,error:c.error,refresh:f}),[c.pets,c.loading,c.error,h,f])}function Bd(e,t){if(t!==null){let r=e.find(e=>e.petRef===t);if(r!==void 0)return r}return e[0]??null}var Hd=/* @__PURE__ */Object.freeze({visitButton:"Vet"});var Wd=/* @__PURE__ */Symbol.for("@everfur/sdk/televet");function Nd(){let e=globalThis,t=e[Wd];if(t!==void 0)return t;let r={presenter:null,snapshot:/* @__PURE__ */Object.freeze({request:null,serial:0,activeHost:null}),hosts:[],nextHost:1,listeners:/* @__PURE__ */new Set,dailyRegistered:false};return e[Wd]=r,r}function Ud(e){let t=Nd();t.snapshot=/* @__PURE__ */Object.freeze({...t.snapshot,...e});for(let e of[...t.listeners])try{e()}catch{}}function $d(e){let t=Nd().presenter;if(t===null)return"absent";try{return t(e)===!1?"declined":"presented"}catch(e){return console.warn("[everfur] Your registerEverfurTelevetFlow presenter threw; the in-app visit opened instead.",e),"threw"}}function Vd(){return Nd().hosts.length>0}function qd(e){if(!Vd())return false;let t=/* @__PURE__ */Object.freeze({...e});return Ud({request:t,serial:Nd().snapshot.serial+1}),true}var Gd=false;function Kd(e,t){return t!==void 0?(Lr(t,e),"onStartInApp"):$d(e)==="presented"?"presenter":qd(e)?"experience":(Gd||(Gd=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}var Yd=createContext(null);function TelevetHostOutlet(){let e=s(Yd);return e===null?null:/* @__PURE__ */E(e,{})}var Qd=/* @__PURE__ */Object.freeze(["visit","join","summary","messages"]);function isVetVisitIntent(e){return typeof e=="string"&&Qd.includes(e)}var Zd="/widget/v1/televet/handoffs",Jd="/widget/v1/televet/availability",Xd="/widget/v1/televet/chat-entry",ec=/^[a-z0-9][a-z0-9_-]{0,39}$/,tc=/^[A-Za-z0-9_-]{22}$/;var rc=32,nc=128,lc=64;function vetVisitErrorReasonOf(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"}function ic(e){return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:e}))}function oc(e){return err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}function ac(petRef,e){let t={};petRef!==void 0&&(t.pet_ref=petRef);let r=e?.returnTo;if(r!=null){if(typeof r!="string"||!ec.test(r))return{ok:false,message:"returnTo must be a registered return destination key"};t.return_to=r}let n=e?.entry;if(n!=null){if(n!=="chat"||petRef===void 0)return{ok:false,message:"entry 'chat' needs the pet the chat is about"};t.entry=n}let l=e?.visitRef,i=e?.intent,o=l!=null;if(o){let e=typeof l=="string"?l.trim():"";if(e.length<1||[...e].length>lc)return{ok:false,message:`visitRef must be 1..${lc} characters`};t.visit_ref=e}if(i!=null){if(!o)return{ok:false,message:"intent needs the visitRef it opens"};if(!isVetVisitIntent(i))return{ok:false,message:`intent must be one of ${Qd.join(", ")}`};t.intent=i}return{ok:true,body:t}}function sc(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!isVetVisitIntent(r)?null:/* @__PURE__ */Object.freeze({visitRef:t,intent:r})}function uc(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=e=>(gc(r,"televet.visit.handoff_failed",{reason:vetVisitErrorReasonOf(e)}),err(e));return{async createHandoff(petRef,e){let l;if(petRef!=null){let e=typeof petRef=="string"?[...petRef].length:0;if(e<1||e>nc)return n(makeEverfurError("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${nc} characters`}));l=petRef}let i=ac(l,e);if(!i.ok){let e=ic(i.message);return e.ok?e:n(e.error)}let o=i.body,a=await t.send("televet.visit.handoff",{method:"POST",path:Zd,body:o},{idempotent:false,maxAttempts:1});if(!a.ok)return n(a.error);let s=dc(a.value),u=o.return_to!==void 0,d=u?a.value?.flow_id:void 0;if(u&&(typeof d!="string"||!tc.test(d))){let e=oc("the handoff response carried no usable return flow id");return e.ok?e:n(e.error)}let c=o.visit_ref!==void 0,p=c?sc(a.value?.visit):null;if(c&&p===null){let e=oc("the handoff response did not confirm the visit it opens");return e.ok?e:n(e.error)}let f=s===null?null:/* @__PURE__ */Object.freeze({...s,...u?{flowId:d}:{},...p!==null?{visit:p}:{}});return f===null?n(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(gc(r,"televet.visit.handoff_created",{pet_scoped:o.pet_ref!==void 0}),ok(f))},async checkAvailability(e){if(typeof e!="string"||e.length>rc)return ic(`state must be at most ${rc} characters`);let r=await t.send("televet.visit.availability",{method:"POST",path:Jd,body:{state:e}},{idempotent:false,maxAttempts:1});if(!r.ok)return err(r.error);let n=r.value?.available;return typeof n!="boolean"?oc("the availability response carried no usable answer"):ok(/* @__PURE__ */Object.freeze({available:n}))},async chatEntryOpen(){try{let e=await t.send("televet.visit.chat_entry",{method:"GET",path:Xd},{maxAttempts:1});return e.ok&&e.value?.open===!0}catch{return false}}}}function dc(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||!hc(t)?null:/* @__PURE__ */Object.freeze({url:t,expiresAt:r})}var cc=/* @__PURE__ */new Set(["localhost","127.0.0.1","[::1]"]),pc=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,fc=/[\s\u0000-\u001f\u007f]/;function hc(e){if(fc.test(e))return false;let t=pc.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let l=n.replace(/:\d+$/,"").toLowerCase(),i=r==="https",o=r==="http"&&cc.has(l);if(!i&&!o)return false;let a=e.indexOf("#");if(a<0)return false;let s=e.slice(a);return s.startsWith("#h=")&&s.length>3}function gc(e,t,r){if(e)try{e.track(t,r)}catch{}}var bc=/* @__PURE__ */Object.freeze({status:"idle",error:null,errorReason:null});function yc(e,t,r){let{usState:n,chat:l,scope:a}=r,s=t&&(n!==null||l),u=`${n??""}|${l?"chat":""}`,[d,c]=i(null);if(o(()=>{if(!s)return;let t=true,r=e.current;return c(null),(async()=>{try{if(l&&!(r.chatEntryOpen&&await r.chatEntryOpen()))return!1;if(n===null)return!0;if(!r.checkAvailability)return!1;let e=await r.checkAvailability(n);return e.ok&&e.value.available}catch{return false}})().then(e=>{t&&c({key:u,open:e})}),()=>{t=false}},[s,u,n,l,a,e]),!s)return null;let p=d!==null&&d.key===u;return{open:p&&d.open,pending:!p}}var mc=/* @__PURE__ */Object.freeze({status:"opening",error:null,errorReason:null});function vc(e,t={}){let{runtime:o,userRef:userRef,scopeEpoch:a}=Oe(),s=useCapability("televet"),u=s.enabled&&userRef!==null,d=t.usState??null,c=t.entry==="chat",p=t.petRef??null,f=t.prefer==="redirect",h=n(()=>{if(t.controller)return t.controller;let{services:e}=o.registry;return uc({auth:e.authFor(userRef),telemetry:e.telemetry,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})},[o,userRef,a,t.controller]),g=l(h);g.current=h;let b=n(()=>({runtime:o,userRef:userRef,scopeEpoch:a}),[o,userRef,a]),y=yc(g,u,{usState:d,chat:c,scope:b}),m=u&&(y===null||y.open)&&(!c||p!==null),v=t.returnTo??null,[w,k]=i(bc),C=l(null),S=l({runtime:o,userRef:userRef,scopeEpoch:a});S.current={runtime:o,userRef:userRef,scopeEpoch:a};let x=l(h);x.current=h;let R=l(m);R.current=m;let _=r((petRef,t)=>{if(C.current)return C.current;let r=(e,t)=>(k({status:e==="cancelled"?"idle":"error",error:t,errorReason:e==="cancelled"?null:e}),/* @__PURE__ */Object.freeze({opened:false,reason:e,error:t}));if(!R.current)return Promise.resolve(r("unavailable",null));let n=e.prepare();if(!n.ok)return Promise.resolve(r(n.reason,null));let l=S.current,i=x.current;k(mc);let o=(async()=>{let o,a={...v!==null?{returnTo:v}:{},...c?{entry:"chat"}:{},...t!==null?{visitRef:t.visitRef}:{},...t!==null&&t.intent!==null&&t.intent!==void 0?{intent:t.intent}:{}},s=Object.keys(a).length===0?void 0:a,u=petRef===void 0?p:petRef;try{o=await(s===void 0?i.createHandoff(u):i.createHandoff(u,s))}catch{return e.abandon(n.value),r("unknown",null)}let d=S.current;if(d.runtime!==l.runtime||d.userRef!==l.userRef||d.scopeEpoch!==l.scopeEpoch)return e.abandon(n.value),r("cancelled",null);if(!o.ok)return e.abandon(n.value),r(vetVisitErrorReasonOf(o.error),o.error);let f=await e.finish(n.value,o.value);return f!==null?r(f,null):(k(bc),/* @__PURE__ */Object.freeze(o.value.flowId===void 0?{opened:true}:{opened:true,flowId:o.value.flowId}))})().finally(()=>{C.current===o&&(C.current=null)});return C.current=o,o},[e,p,v,c]),T=r((petRef,e)=>{if(!R.current)return k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}));let t=petRef===void 0?p:petRef,r={...t!==null?{petRef:t}:{},...d!==null?{usState:d}:{},...e!==null&&"consultId"in e?{consultId:e.consultId}:{},...e!==null&&"visitRef"in e?{visitRef:e.visitRef,intent:e.intent}:{}};return Kd(r)===null?(k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}))):(k(bc),Promise.resolve(/* @__PURE__ */Object.freeze({opened:true})))},[p,d]),z=r(petRef=>f?_(petRef,null):T(petRef,null),[f,_,T]),I=r((e,t)=>f?_(void 0,{visitRef:e,intent:t??null}):T(void 0,{visitRef:e,intent:t??null}),[f,_,T]),P=r(e=>f?_(void 0,null):T(void 0,{consultId:e.trim()}),[f,_,T]);return{available:m,isPending:s.isPending||(y?.pending??false),status:w.status,error:w.error,errorReason:w.errorReason,open:z,openVisit:I,joinVisit:P}}var wc=e=>y.openURL(e);function useVetVisit(e={}){let{openUrl:t,...r}=e,l=n(()=>{let e=t??wc;return{prepare:()=>({ok:true,value:null}),async finish(t,r){try{return await e(r.url),null}catch{return"openFailed"}},abandon:()=>{}}},[t]);return vc(l,r)}var kc=44,Cc=.6;function VetVisitButtonCore(e){let{petRef:petRef,label:t,openUrl:r,onOpened:i,onError:o,style:a,labelStyle:s,controller:u,returnTo:d,usState:c,entry:p,visitRef:f,intent:h,onStartInApp:g,prefer:b}=e,y=b==="redirect",m=useVetVisit({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...petRef!==void 0?{petRef:petRef}:{},...r!==void 0?{openUrl:r}:{},...u!==void 0?{controller:u}:{},prefer:y?"redirect":"in-app"}),w=useEverfurTheme(),k=n(()=>Sc(w),[w]),C=l(false);if(!m.available)/* @__PURE__ */
108
+ /* @__PURE__ */E(StopGlyph,{size:Fu,color:a.color.brandInk,testID:"everfur-dictation-stop"})]}):/* @__PURE__ */E(MicGlyph,{size:Pu,color:a.color.brandInk,testID:"everfur-dictation-mic"})})]})}function Pulse({style:e,reduced:t}){let r=l(new P.Value(1)).current;return o(()=>{if(t)return;let e=P.loop(P.sequence([P.timing(r,{toValue:Ou,duration:Eu/2,useNativeDriver:true}),P.timing(r,{toValue:1,duration:Eu/2,useNativeDriver:true})]));return e.start(),()=>e.stop()},[r,t]),/* @__PURE__ */E(P.View,{style:[e,{opacity:r}],accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"})}function ju(e){let t=e.color,r=e.type.tierSizes.compact.micro;return f.create({wrap:{flexDirection:"row",flexShrink:0,alignItems:"center",gap:e.space.xs},timer:{...face(e,"mono"),fontSize:r,lineHeight:r+2,fontVariant:["tabular-nums"],color:t.text.muted},button:{width:Ds,height:Ds,borderRadius:e.radius.pill,alignItems:"center",justifyContent:"center"},buttonDisabled:{opacity:Au},pulse:{position:"absolute",top:Lu,right:Lu,bottom:Lu,left:Lu,borderRadius:e.radius.pill,backgroundColor:t.brandSofter}})}function optionalModule(e,t,r){let n;try{n=t()}catch(t){return Mu(`optional peer '${e}' is not installed: ${Bu(t)}`)}let l=Du(n);return l==null?Mu(`optional peer '${e}' resolved to no module`):r&&!r(l)?Mu(`optional peer '${e}' is present but failed its shape check`):/* @__PURE__ */Object.freeze({available:true,module:l})}function Du(e){return typeof e=="object"&&e!==null&&"default"in e&&Object.keys(e).length<=2?e.default:e}function Mu(e){/* @__PURE__ */
109
+ return Object.freeze({available:false,module:null,reason:e})}function Bu(e){return e instanceof Error?e.message:typeof e=="string"?e:"unknown load error"}var Hu=/* @__PURE__ */Symbol.for("@everfur/sdk/rn-dictation");function Wu(){let e=globalThis,t=e[Hu];if(t!==void 0)return t;let r={loader:null,memo:void 0};return e[Hu]=r,r}function registerEverfurDictation(e){let t=Wu();t.loader=e,t.memo=void 0,t.version=(t.version??0)+1;for(let e of[...t.listeners??[]])try{e()}catch{}}function Nu(){return Wu().version??0}function Uu(e){let t=Wu(),r=t.listeners??/* @__PURE__ */new Set;t.listeners=r;let n=()=>e();return r.add(n),()=>{r.delete(n)}}function $u(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.start=="function"&&typeof t.isRecognitionAvailable=="function"&&typeof t.addListener=="function"}function Vu(e){return typeof e!="object"||e===null?null:e.ExpoSpeechRecognitionModule??e}function qu(){let e=Wu();if(e.memo!==void 0)return e.memo;e.memo=null;let t=e.loader;if(t===null||h.OS!=="ios"&&h.OS!=="android")return e.memo;let r=optionalModule("expo-speech-recognition",()=>({box:Vu(t())}),e=>typeof e=="object"&&e!==null&&$u(e.box));return r.available&&(e.memo=r.module.box),e.memo}function Gu(e){if(e===null)return false;try{return e.isRecognitionAvailable()===!0}catch{return false}}function Ku(){try{return Intl.DateTimeFormat().resolvedOptions().locale||Qu}catch{return Qu}}function Yu(e){return e.replace(/_/g,"-").toLowerCase()}var Qu="en-US";function Zu(e=Ku()){let[t=""]=e.replace(/_/g,"-").split("-u-"),r=t.split("-");if(r[0]?.toLowerCase()!=="en")return Qu;let n=r.slice(1).find(e=>/^[A-Za-z]{2}$/.test(e));return n?`en-${n.toUpperCase()}`:Qu}function Ju(e,t){if(t.length===0)return null;let r=e=>t.find(t=>Yu(t)===Yu(e));return r(e)??r(Qu)??t.find(e=>Yu(e).startsWith("en-"))??null}async function Xu(e,t){if(h.OS!=="ios")return t;try{let{locales:r}=await e.getSupportedLocales({});return Ju(t,r??[])??t}catch{return t}}async function ed(e,t){let r=false;try{r=e.supportsOnDeviceRecognition()===!0}catch{r=false}if(!r)return"network";if(h.OS!=="android")return"on_device";try{let{installedLocales:r}=await e.getSupportedLocales({}),n=Yu(t);return(r??[]).some(e=>Yu(e)===n)?"on_device":"network"}catch{return"network"}}function td(){return h.OS!=="android"?true:Number(h.Version)>=rd}var rd=33;function nd(e,t,r){return{lang:t,interimResults:true,continuous:td(),maxAlternatives:1,addsPunctuation:true,requiresOnDeviceRecognition:e==="on_device",contextualStrings:r.slice(0,100),iosTaskHint:"dictation"}}var ld=/* @__PURE__ */new Set(["not-allowed","no-speech","speech-timeout","aborted","interrupted"]),id=/* @__PURE__ */new Set(["busy","client","network","audio-capture","too-many-requests","unknown"]);function od(e){return id.has(e)}var ad=600,sd=3;function ud(e,t,r){if(ld.has(r))return null;let n=od(r)?ad:0;return r==="language-not-supported"&&Yu(t)!==Yu(Qu)?{mode:"network",lang:Qu,delayMs:n}:e==="on_device"?{mode:"network",lang:t,delayMs:n}:n>0?{mode:"network",lang:t,delayMs:n}:null}function dd(e){return e==="not-allowed"?"permissionDenied":e==="no-speech"||e==="speech-timeout"?"noSpeech":"unavailable"}async function cd(e){try{if((await e.getPermissionsAsync()).granted)return"granted"}catch{}try{return(await e.requestPermissionsAsync()).granted?"granted":"denied"}catch{return"error"}}var pd=55e3,fd=3e3,hd=1e3;function gd(e){return bd.has(e)||od(e)}var bd=/* @__PURE__ */new Set(["no-speech","speech-timeout","aborted","interrupted"]),yd=/* @__PURE__ */Object.freeze({committed:/* @__PURE__ */Object.freeze([]),interim:""});function md(e){return e.replace(/\s+/g," ").trim()}function vd(e,t,r){let n=md(t);return r?n?{committed:[...e.committed,n],interim:""}:{committed:e.committed,interim:""}:{committed:e.committed,interim:n}}function wd(e){return md([...e.committed,e.interim].join(" "))}function kd(e,t,r,n=Date.now){let l=0,i=null,o=Number.NEGATIVE_INFINITY,a=e=>i!==null&&i.token===e?i:null;function s(e){for(let t of e.subscriptions)try{t.remove()}catch{}e.subscriptions=[]}function u(e){s(e),e.autoStopTimer!==null&&clearTimeout(e.autoStopTimer),e.graceTimer!==null&&clearTimeout(e.graceTimer),e.retryTimer!==null&&clearTimeout(e.retryTimer),e.autoStopTimer=null,e.graceTimer=null,e.retryTimer=null,i===e&&(i=null)}function d(e){return!e.sawStart&&e.errorCode===null&&e.pendingRetry===null&&wd(e.transcript)===""&&e.launchedAt-o<hd}function c(e){return e.mode??"none"}function p(e,t){Sa(r(),"chat_dictation_completed",{mode:c(e),duration_ms:e.startedAt===null?0:Math.max(0,n()-e.startedAt),char_count:t.length})}function f(e,n){Sa(r(),"chat_dictation_failed",{mode:c(e),error:n}),t.onStatus("idle"),t.onError(n)}function h(e){if(a(e.token)===null)return;u(e);let r=wd(e.transcript),n=e.errorCode;if(n!==null&&!(r&&gd(n))){f(e,dd(n));return}if(!r){f(e,"noSpeech");return}p(e,r),t.onStatus("idle")}function g(l){l.subscriptions=[e.addListener("start",()=>{a(l.token)!==null&&(l.sawStart=true,l.startedAt===null&&(l.startedAt=n()),Sa(r(),"chat_dictation_started",{mode:c(l)}),t.onStatus("listening"))}),e.addListener("result",e=>{if(a(l.token)===null)return;let r=e?.results?.[0]?.transcript??"";l.transcript=vd(l.transcript,r,e?.isFinal===true),t.onText(wd(l.transcript))}),e.addListener("error",e=>{if(a(l.token)===null)return;let t=e?.error??"unknown";if(l.userStopped&&(t==="aborted"||od(t)))return;let r=wd(l.transcript)==="",n=l.mode!==null&&!l.userStopped&&r&&l.retries<sd?ud(l.mode,l.lang,t):null;if(n!==null){l.pendingRetry=n;return}l.errorCode===null&&(l.errorCode=t)}),e.addListener("end",()=>{if(a(l.token)!==null&&!d(l)){if(l.pendingRetry!==null){let e=l.pendingRetry;if(l.pendingRetry=null,l.retries+=1,l.lang=e.lang,e.delayMs<=0){b(l,e.mode);return}s(l),l.retryTimer=setTimeout(()=>{l.retryTimer=null,!(a(l.token)===null||l.userStopped)&&b(l,e.mode)},e.delayMs);return}h(l)}})]}function b(t,r){s(t),t.mode=r,t.sawStart=false,t.launchedAt=n(),t.transcript=yd,t.errorCode=null,g(t);try{e.start(nd(r,t.lang,t.phrases))}catch{t.errorCode="unknown",h(t)}}async function y(t){let r=await cd(e);if(a(t.token)===null)return;if(r!=="granted"){u(t),f(t,r==="denied"?"permissionDenied":"unavailable");return}if(t.lang=await Xu(e,t.lang),a(t.token)===null)return;let n=await ed(e,t.lang);a(t.token)!==null&&(t.autoStopTimer=setTimeout(()=>m(t),pd),b(t,n))}function m(r){if(!(a(r.token)===null||r.userStopped)){if(r.userStopped=true,r.pendingRetry=null,r.mode===null||r.retryTimer!==null){u(r),t.onStatus("idle");return}r.graceTimer=setTimeout(()=>h(r),fd);try{e.stop()}catch{h(r)}}}return{start(e){if(i!==null)return;let r={token:++l,phrases:e,lang:Zu(),mode:null,retries:0,pendingRetry:null,userStopped:false,transcript:yd,errorCode:null,startedAt:null,sawStart:false,launchedAt:0,subscriptions:[],autoStopTimer:null,graceTimer:null,retryTimer:null};i=r,t.onStatus("starting"),y(r)},stop(){i!==null&&m(i)},cancel(){let r=i;if(r===null)return;let l=r.mode!==null&&r.retryTimer===null,a=wd(r.transcript);if(u(r),t.onStatus("idle"),!!l){a&&p(r,a),o=n();try{e.abort()}catch{}}},isActive:()=>i!==null,isPreparing:()=>i!==null&&i.mode===null}}function Cd({enabled:e,input:t,setInput:s,phrases:u,maxLength:d,telemetry:c}){let p=a(Uu,Nu,Nu),f=n(()=>e?qu():null,[e,p]),h=n(()=>Gu(f),[f]),[b,y]=i("idle"),[m,v]=i(null),[w,k]=i(0),C=l(t);C.current=t;let S=l(s);S.current=s;let x=l(c);x.current=c;let R=l(""),T=l(d);T.current=d;let _=l(null);f!==null&&_.current?.mod!==f&&(_.current?.controller.cancel(),_.current={mod:f,controller:kd(f,{onStatus:e=>{y(t=>e==="idle"&&t==="error"?t:e)},onText:e=>S.current(wa(R.current,e,T.current)),onError:e=>{v(e),y("error")}},()=>x.current)});let z=f===null?null:_.current?.controller??null,I=r(()=>{z?.cancel()},[z]),P=r(()=>{if(z!==null){if(z.isActive()){z.stop();return}v(null),k(0),R.current=C.current,z.start(u)}},[z,u]);o(()=>{if(b!=="listening")return;let e=Date.now();k(0);let t=setInterval(()=>k(Date.now()-e),1e3);return()=>clearInterval(t)},[b]),o(()=>{if(b!=="error")return;let e=setTimeout(()=>{v(null),y("idle")},va);return()=>clearTimeout(e)},[b]),o(()=>{if(z===null)return;let e=null;try{e=g.addEventListener("change",e=>{e==="background"&&!z.isPreparing()&&z.cancel()})}catch{}return()=>{e?.remove(),z.cancel()}},[z]);let F=e&&h;return o(()=>{F||z?.cancel()},[F,z]),{supported:F,status:b,active:b==="starting"||b==="listening",error:m,elapsedMs:w,toggle:P,cancel:I}}var Sd=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatPaneShown");function xd(){let e=globalThis,t=e[Sd];if(t!==void 0)return t;let r=createContext(true);return e[Sd]=r,r}var Rd=xd();function Td(){return s(Rd)}var _d=/* @__PURE__ */Object.freeze(["photo"]),zd=52,Id=1.5,Pd=10,Fd=14,Ld=10,Ed=40,Od=20,Ad=.3,jd=2.5,Dd=1,Md=1.5,Bd=38,Hd=22,Wd=3;function Nd(e,t,r,n="ask",l=false){let i=typeof t=="string"&&t.trim()!=="";return r&&i&&n!=="urgent"?We(Me.placeholder,t):e!==null?!l||!e.includes("{pet}")?e:i?e.split("{pet}").join(t.trim()):We(Me.placeholder,t):n==="urgent"?Me.placeholderUrgentWeb:n==="followUp"?Me.placeholderFollowUpWeb:We(Me.placeholder,t)}function ComposerWithAttachments({attachments:e,...t}){let r=n(()=>createRnChatAttachmentTransport(),[]),l=useChatAttachments({maxPerMessage:e.maxPerMessage??ra,transport:r}),i=n(()=>({state:l,sources:e.sources??_d,pick:e.pick}),[l,e.sources,e.pick]);/* @__PURE__ */
110
+ return E(Composer,{...t,attachments:i})}function Composer({send:e,stop:t,isStreaming:a,conversationId:conversationId,attachments:s,seed:u,draftStore:d,onStage:c,onPreview:p,petName:f,petBreed:h=null,mood:g="ask",dictation:b=false,telemetry:m=null,compact:v=false,petPlaceholder:k=false,dimEmptySend:C=false}){let{theme:S,styles:x}=zu(),R=n(()=>Kd(S),[S]),T=n(()=>Yd(S),[S]),_=yo(),[z,I]=Ta(e,conversationId,u),[P,F]=i(false),[L,j]=i(false),D=r(()=>j(true),[]),M=r(()=>j(false),[]),[B,H]=i(false);o(()=>{H(false)},[conversationId]);let W=Nd(S.meta.placeholder,f,k,g,S.meta.placeholderFillsPet===true),N=n(()=>Ra({name:f,breed:h}),[f,h]),U=Cd({enabled:b,input:z,setInput:I,phrases:N,maxLength:Xo,telemetry:m}),$=U.cancel,V=U.active;_a(d,conversationId===null?null:String(conversationId),z,I,V);let q=l(conversationId);o(()=>{q.current!==conversationId&&(q.current=conversationId,$())},[conversationId,$]);let G=Td();o(()=>{G||$()},[G,$]);let K=s?.state.uploading??false,Y=s?.state.failed??false,Q=K||Y,Z=s?.state.attachments??Ud;Oo(Z.length,_);let J=r(()=>{let t=z.trim();if(t.length===0||Q||[...t].length>Xo)return;V&&$();let r=s?.state.s3Keys??$d;s!==null&&r.length>0?(c(s.state.attachments.filter(e=>e.status==="uploaded").map(e=>({uri:e.previewUri,filename:e.filename}))),e(t,{imageS3Keys:r}),s.state.clear()):e(t),I(""),H(false)},[z,e,Q,V,$,s,c]),X=r(e=>{V&&$(),I(e)},[V,$,I]),ee=r(()=>{t()},[t]),te=r(e=>{F(false),s!==null&&(H(false),s.state.dismissRejected(),Kr(s.pick,e).then(e=>{if(!e.ok){H(true);return}e.value!==null&&s.state.add(e.value)}))},[s]),re=n(()=>[...z.trim()].length>Xo,[z]),ne=re||Q||z.trim().length===0,le=re||Q||C&&z.trim().length===0,ie=s!==null&&Z.length>=s.state.maxPerMessage,oe=S.slots.sendButton?.textColor??S.color.brandInk,ae=S.slots.sendButton?.textColor??S.color.surface;/* @__PURE__ */
111
+ return O(y,{style:x.composerOuter,children:[s!==null&&P?/* @__PURE__ */E(AttachmentPickerPopover,{sources:s.sources,full:ie,onPick:te,onClose:()=>F(false)}):null,s!==null?/* @__PURE__ */E(AttachmentStrip,{attachments:Z,rejected:B?Gd:s.state.rejected,uploadFailed:Y,onRetry:s.state.retry,onRemove:s.state.remove,onPreview:e=>p({uri:e.previewUri,label:e.filename}),style:v?R.tray:T.tray}):null,
112
+ /* @__PURE__ */O(y,{style:v?[x.composer,R.bar,L?R.barFocused:null]:x.composer,children:[U.supported&&U.error!==null?/* @__PURE__ */O(A,{children:[
113
+ /* @__PURE__ */E(Text,{style:x.dictationError,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:Ca(U.error)}),
114
+ /* @__PURE__ */E(AnnounceLine,{line:Ca(U.error)})]}):null,
115
+ /* @__PURE__ */O(y,{style:x.composerRow,children:[s!==null?/* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:ie?ya(Z.length,s.state.maxPerMessage):Me.attachPhotoOrFileNative,accessibilityState:{disabled:ie,expanded:P},disabled:ie,style:[x.attachControl,v?R.add:null,ie?x.attachControlDisabled:null],hitSlop:v?Wd:void 0,onPress:()=>F(e=>!e),children:/* @__PURE__ */E(UploadGlyph,{size:v?Hd:iu,color:ie?S.color.text.muted:v?S.color.text.primary:S.color.brandInk,strokeWidth:1.75})}):null,
116
+ /* @__PURE__ */E(be,{style:v?[x.input,R.input]:x.input,onFocus:D,onBlur:M,value:z,onChangeText:X,placeholder:W,placeholderTextColor:S.slots.composerInput?.textColor??S.color.text.placeholder,accessibilityLabel:Me.composerLabel,onSubmitEditing:J,returnKeyType:"send",...Vd,...v?qd:null,blurOnSubmit:false,multiline:true,editable:true}),U.supported?/* @__PURE__ */E(DictationButton,{active:U.active,listening:U.status==="listening",elapsedMs:U.elapsedMs,onToggle:U.toggle}):null,a?/* @__PURE__ */E(w,{onPress:ee,accessibilityRole:"button",accessibilityLabel:Me.stop,style:x.sendControl,children:/* @__PURE__ */E(y,{style:v?R.disc:x.sendDisc,testID:"everfur-stop-disc",children:/* @__PURE__ */E(StopGlyph,{size:v?Od:ru,color:v?ae:oe,testID:"everfur-stop-glyph"})})}):/* @__PURE__ */E(w,{onPress:J,disabled:ne,accessibilityRole:"button",accessibilityLabel:Me.send,accessibilityState:{disabled:ne,busy:K},style:[x.sendControl,le?v?R.dimmed:x.sendControlDisabled:null],children:v?/* @__PURE__ */E(y,{style:R.disc,testID:"everfur-send-disc",children:/* @__PURE__ */E(ArrowUpGlyph,{size:Od,color:ae,strokeWidth:2.25,testID:"everfur-send-arrow"})}):/* @__PURE__ */E(y,{style:x.sendDisc,testID:"everfur-send-disc",children:/* @__PURE__ */E(SendGlyph,{size:tu,color:oe,testID:"everfur-send-glyph"})})})]})]})]})}var Ud=/* @__PURE__ */Object.freeze([]),$d=/* @__PURE__ */Object.freeze([]),Vd=/* @__PURE__ */Object.freeze({submitBehavior:"submit"}),qd=/* @__PURE__ */Object.freeze(h.OS==="web"?{rows:1}:{}),Gd=/* @__PURE__ */Object.freeze({code:"unknown",retryable:true,filename:""});function Kd(e){let t=e.color,r=e.slots.sendButton,n=textRole(e,"body").fontSize+Dd;return f.create({bar:{marginTop:Pd,marginHorizontal:Fd,marginBottom:Ld,minHeight:zd,paddingLeft:8,paddingRight:6,paddingVertical:0,borderWidth:Id,borderColor:e.slots.composerInput?.borderColor??t.text.primary},barFocused:{borderWidth:jd,paddingLeft:8-(jd-Id),paddingRight:6-(jd-Id)},input:{fontSize:n,lineHeight:Math.round(n*Md),minHeight:Math.round(n*Md),...h.OS==="web"?{outlineStyle:"none"}:null},add:{width:Bd,height:Bd,borderRadius:Bd/2},disc:{width:Ed,height:Ed,borderRadius:Ed/2,alignItems:"center",justifyContent:"center",backgroundColor:r?.backgroundColor??t.text.primary,...Vo(r)},dimmed:{opacity:Ad},tray:{marginHorizontal:Fd,marginTop:Pd,paddingBottom:0}})}function Yd(e){return f.create({tray:{marginHorizontal:e.space.md,marginTop:e.space.xs,paddingBottom:0}})}var Qd=/* @__PURE__ */new WeakMap;function Zd(e,t){let r=Qd.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,Qd.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:e,userRef:userRef,activePet:t,scopeEpoch:a}=Ge(),s=n(()=>createPetsRepository(e.registry.services.authFor(userRef)),[e,userRef,a]),[u,d]=i({repository:s,pets:[],loading:true,error:null}),c=u.repository===s?u:{pets:[],loading:true,error:null},p=l(0),f=r(async()=>{let e=++p.current;d(e=>({...e,repository:s,loading:true,error:null,pets:e.repository===s?e.pets:[]}));let t=await s.list();e===p.current&&d(t.ok?{repository:s,pets:t.value,loading:false,error:null}:e=>({repository:s,pets:e.repository===s?e.pets:[],loading:false,error:t.error}))},[s]);o(()=>(f(),()=>{p.current+=1}),[f]),o(()=>Zd(e,()=>{f()}),[e,f]);let h=n(()=>t===null?null:c.pets.find(e=>e.petRef===t)??null,[t,c.pets]);return n(()=>({pets:c.pets,activePet:h,loading:c.loading,error:c.error,refresh:f}),[c.pets,c.loading,c.error,h,f])}function Jd(e,t){if(t!==null){let r=e.find(e=>e.petRef===t);if(r!==void 0)return r}return e[0]??null}var Xd=/* @__PURE__ */Object.freeze({visitButton:"Vet"});var ec=/* @__PURE__ */Symbol.for("@everfur/sdk/televet");function tc(){let e=globalThis,t=e[ec];if(t!==void 0)return t;let r={presenter:null,snapshot:/* @__PURE__ */Object.freeze({request:null,serial:0,activeHost:null}),hosts:[],nextHost:1,listeners:/* @__PURE__ */new Set,dailyRegistered:false};return e[ec]=r,r}function rc(e){let t=tc();t.snapshot=/* @__PURE__ */Object.freeze({...t.snapshot,...e});for(let e of[...t.listeners])try{e()}catch{}}function nc(e){let t=tc().presenter;if(t===null)return"absent";try{return t(e)===!1?"declined":"presented"}catch(e){return console.warn("[everfur] Your registerEverfurTelevetFlow presenter threw; the in-app visit opened instead.",e),"threw"}}function lc(){return tc().hosts.length>0}function ic(e){if(!lc())return false;let t=/* @__PURE__ */Object.freeze({...e});return rc({request:t,serial:tc().snapshot.serial+1}),true}var oc=false;function ac(e,t){return t!==void 0?(Vr(t,e),"onStartInApp"):nc(e)==="presented"?"presenter":ic(e)?"experience":(oc||(oc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}var sc=createContext(null);function TelevetHostOutlet(){let e=s(sc);return e===null?null:/* @__PURE__ */E(e,{})}var uc=/* @__PURE__ */Object.freeze(["visit","join","summary","messages"]);function isVetVisitIntent(e){return typeof e=="string"&&uc.includes(e)}var dc="/widget/v1/televet/handoffs",cc="/widget/v1/televet/availability",pc="/widget/v1/televet/chat-entry",fc=/^[a-z0-9][a-z0-9_-]{0,39}$/,hc=/^[A-Za-z0-9_-]{22}$/;var gc=32,bc=128,yc=64;function vetVisitErrorReasonOf(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"}function mc(e){return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:e}))}function vc(e){return err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}function wc(petRef,e){let t={};petRef!==void 0&&(t.pet_ref=petRef);let r=e?.returnTo;if(r!=null){if(typeof r!="string"||!fc.test(r))return{ok:false,message:"returnTo must be a registered return destination key"};t.return_to=r}let n=e?.entry;if(n!=null){if(n!=="chat"||petRef===void 0)return{ok:false,message:"entry 'chat' needs the pet the chat is about"};t.entry=n}let l=e?.visitRef,i=e?.intent,o=l!=null;if(o){let e=typeof l=="string"?l.trim():"";if(e.length<1||[...e].length>yc)return{ok:false,message:`visitRef must be 1..${yc} characters`};t.visit_ref=e}if(i!=null){if(!o)return{ok:false,message:"intent needs the visitRef it opens"};if(!isVetVisitIntent(i))return{ok:false,message:`intent must be one of ${uc.join(", ")}`};t.intent=i}return{ok:true,body:t}}function kc(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!isVetVisitIntent(r)?null:/* @__PURE__ */Object.freeze({visitRef:t,intent:r})}function Cc(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=e=>(zc(r,"televet.visit.handoff_failed",{reason:vetVisitErrorReasonOf(e)}),err(e));return{async createHandoff(petRef,e){let l;if(petRef!=null){let e=typeof petRef=="string"?[...petRef].length:0;if(e<1||e>bc)return n(makeEverfurError("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${bc} characters`}));l=petRef}let i=wc(l,e);if(!i.ok){let e=mc(i.message);return e.ok?e:n(e.error)}let o=i.body,a=await t.send("televet.visit.handoff",{method:"POST",path:dc,body:o},{idempotent:false,maxAttempts:1});if(!a.ok)return n(a.error);let s=Sc(a.value),u=o.return_to!==void 0,d=u?a.value?.flow_id:void 0;if(u&&(typeof d!="string"||!hc.test(d))){let e=vc("the handoff response carried no usable return flow id");return e.ok?e:n(e.error)}let c=o.visit_ref!==void 0,p=c?kc(a.value?.visit):null;if(c&&p===null){let e=vc("the handoff response did not confirm the visit it opens");return e.ok?e:n(e.error)}let f=s===null?null:/* @__PURE__ */Object.freeze({...s,...u?{flowId:d}:{},...p!==null?{visit:p}:{}});return f===null?n(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(zc(r,"televet.visit.handoff_created",{pet_scoped:o.pet_ref!==void 0}),ok(f))},async checkAvailability(e){if(typeof e!="string"||e.length>gc)return mc(`state must be at most ${gc} characters`);let r=await t.send("televet.visit.availability",{method:"POST",path:cc,body:{state:e}},{idempotent:false,maxAttempts:1});if(!r.ok)return err(r.error);let n=r.value?.available;return typeof n!="boolean"?vc("the availability response carried no usable answer"):ok(/* @__PURE__ */Object.freeze({available:n}))},async chatEntryOpen(){try{let e=await t.send("televet.visit.chat_entry",{method:"GET",path:pc},{maxAttempts:1});return e.ok&&e.value?.open===!0}catch{return false}}}}function Sc(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||!_c(t)?null:/* @__PURE__ */Object.freeze({url:t,expiresAt:r})}var xc=/* @__PURE__ */new Set(["localhost","127.0.0.1","[::1]"]),Rc=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,Tc=/[\s\u0000-\u001f\u007f]/;function _c(e){if(Tc.test(e))return false;let t=Rc.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let l=n.replace(/:\d+$/,"").toLowerCase(),i=r==="https",o=r==="http"&&xc.has(l);if(!i&&!o)return false;let a=e.indexOf("#");if(a<0)return false;let s=e.slice(a);return s.startsWith("#h=")&&s.length>3}function zc(e,t,r){if(e)try{e.track(t,r)}catch{}}var Ic=/* @__PURE__ */Object.freeze({status:"idle",error:null,errorReason:null});function Pc(e,t,r){let{usState:n,chat:l,scope:a}=r,s=t&&(n!==null||l),u=`${n??""}|${l?"chat":""}`,[d,c]=i(null);if(o(()=>{if(!s)return;let t=true,r=e.current;return c(null),(async()=>{try{if(l&&!(r.chatEntryOpen&&await r.chatEntryOpen()))return!1;if(n===null)return!0;if(!r.checkAvailability)return!1;let e=await r.checkAvailability(n);return e.ok&&e.value.available}catch{return false}})().then(e=>{t&&c({key:u,open:e})}),()=>{t=false}},[s,u,n,l,a,e]),!s)return null;let p=d!==null&&d.key===u;return{open:p&&d.open,pending:!p}}var Fc=/* @__PURE__ */Object.freeze({status:"opening",error:null,errorReason:null});function Lc(e,t={}){let{runtime:o,userRef:userRef,scopeEpoch:a}=Ge(),s=useCapability("televet"),u=s.enabled&&userRef!==null,d=t.usState??null,c=t.entry==="chat",p=t.petRef??null,f=t.prefer==="redirect",h=n(()=>{if(t.controller)return t.controller;let{services:e}=o.registry;return Cc({auth:e.authFor(userRef),telemetry:e.telemetry,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})},[o,userRef,a,t.controller]),g=l(h);g.current=h;let b=n(()=>({runtime:o,userRef:userRef,scopeEpoch:a}),[o,userRef,a]),y=Pc(g,u,{usState:d,chat:c,scope:b}),m=u&&(y===null||y.open)&&(!c||p!==null),v=t.returnTo??null,[w,k]=i(Ic),C=l(null),S=l({runtime:o,userRef:userRef,scopeEpoch:a});S.current={runtime:o,userRef:userRef,scopeEpoch:a};let x=l(h);x.current=h;let R=l(m);R.current=m;let T=r((petRef,t)=>{if(C.current)return C.current;let r=(e,t)=>(k({status:e==="cancelled"?"idle":"error",error:t,errorReason:e==="cancelled"?null:e}),/* @__PURE__ */Object.freeze({opened:false,reason:e,error:t}));if(!R.current)return Promise.resolve(r("unavailable",null));let n=e.prepare();if(!n.ok)return Promise.resolve(r(n.reason,null));let l=S.current,i=x.current;k(Fc);let o=(async()=>{let o,a={...v!==null?{returnTo:v}:{},...c?{entry:"chat"}:{},...t!==null?{visitRef:t.visitRef}:{},...t!==null&&t.intent!==null&&t.intent!==void 0?{intent:t.intent}:{}},s=Object.keys(a).length===0?void 0:a,u=petRef===void 0?p:petRef;try{o=await(s===void 0?i.createHandoff(u):i.createHandoff(u,s))}catch{return e.abandon(n.value),r("unknown",null)}let d=S.current;if(d.runtime!==l.runtime||d.userRef!==l.userRef||d.scopeEpoch!==l.scopeEpoch)return e.abandon(n.value),r("cancelled",null);if(!o.ok)return e.abandon(n.value),r(vetVisitErrorReasonOf(o.error),o.error);let f=await e.finish(n.value,o.value);return f!==null?r(f,null):(k(Ic),/* @__PURE__ */Object.freeze(o.value.flowId===void 0?{opened:true}:{opened:true,flowId:o.value.flowId}))})().finally(()=>{C.current===o&&(C.current=null)});return C.current=o,o},[e,p,v,c]),_=r((petRef,e)=>{if(!R.current)return k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}));let t=petRef===void 0?p:petRef,r={...t!==null?{petRef:t}:{},...d!==null?{usState:d}:{},...e!==null&&"consultId"in e?{consultId:e.consultId}:{},...e!==null&&"visitRef"in e?{visitRef:e.visitRef,intent:e.intent}:{}};return ac(r)===null?(k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}))):(k(Ic),Promise.resolve(/* @__PURE__ */Object.freeze({opened:true})))},[p,d]),z=r(petRef=>f?T(petRef,null):_(petRef,null),[f,T,_]),I=r((e,t)=>f?T(void 0,{visitRef:e,intent:t??null}):_(void 0,{visitRef:e,intent:t??null}),[f,T,_]),P=r(e=>f?T(void 0,null):_(void 0,{consultId:e.trim()}),[f,T,_]);return{available:m,isPending:s.isPending||(y?.pending??false),status:w.status,error:w.error,errorReason:w.errorReason,open:z,openVisit:I,joinVisit:P}}var Ec=e=>m.openURL(e);function useVetVisit(e={}){let{openUrl:t,...r}=e,l=n(()=>{let e=t??Ec;return{prepare:()=>({ok:true,value:null}),async finish(t,r){try{return await e(r.url),null}catch{return"openFailed"}},abandon:()=>{}}},[t]);return Lc(l,r)}var Oc=44,Ac=.6;function VetVisitButtonCore(e){let{petRef:petRef,label:t,openUrl:r,onOpened:i,onError:o,style:a,labelStyle:s,controller:u,returnTo:d,usState:c,entry:p,visitRef:f,intent:h,onStartInApp:g,prefer:b}=e,y=b==="redirect",m=useVetVisit({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...petRef!==void 0?{petRef:petRef}:{},...r!==void 0?{openUrl:r}:{},...u!==void 0?{controller:u}:{},prefer:y?"redirect":"in-app"}),v=useEverfurTheme(),k=n(()=>jc(v),[v]),C=l(false);if(!m.available)/* @__PURE__ */
117
117
  return O(A,{children:[null,
118
- /* @__PURE__ */E(TelevetHostOutlet,{})]});let S=m.status==="opening",x=t??Hd.visitButton;/* @__PURE__ */
118
+ /* @__PURE__ */E(TelevetHostOutlet,{})]});let S=m.status==="opening",x=t??Xd.visitButton;/* @__PURE__ */
119
119
  return O(A,{children:[
120
- /* @__PURE__ */E(v,{onPress:()=>{if(!(S||C.current)){if(!y){let e={...petRef!==void 0?{petRef:petRef}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:h??null}:{}};Kd(e,g)===null&&Lr(o,"unavailable",null);return}C.current=true,(f==null?m.open():m.openVisit(f,h??null)).then(e=>{e.opened?Lr(i,e.flowId??null):e.reason!=="cancelled"&&Lr(o,e.reason,e.error)}).finally(()=>{C.current=false})}},accessibilityRole:"button",accessibilityLabel:x,accessibilityState:{busy:S,disabled:S},style:[k.button,S?k.busy:null,a],children:/* @__PURE__ */E(Text,{style:[k.label,s],children:x})}),
121
- /* @__PURE__ */E(TelevetHostOutlet,{})]})}function Sc(e){let{color:t,space:r,radius:n,type:l,slots:i}=e;return p.create({button:{minHeight:kc,minWidth:kc,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...Lo(i.vetVisitButton)},busy:{opacity:Cc},label:{...face(e,"medium"),color:t.onPrimary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.snug,...Oo(i.vetVisitButton)}})}function xc(e){let[t,r]=i(null);return{shown:e!==null&&t!==e,onError:()=>r(e)}}function BrandImage({uri:e,label:t,decorative:r=false,style:n,resizeMode:l="contain",fallback:i=null,onError:o,testID:a}){let s=xc(e);if(e===null||!s.shown)return i;let u=r?{accessible:false,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}:{accessible:true,accessibilityRole:"image",...t===void 0?{}:{accessibilityLabel:t}};/* @__PURE__ */
122
- return E(R,{source:{uri:e},style:n,resizeMode:l,...u,onError:()=>{s.onError(),o?.()},...a===void 0?{}:{testID:a}})}function BrandLogo({logoUrl:e,name:t,barStyle:r,logoStyle:n,testID:l}){let i=xc(e);return e===null||!i.shown?null:/* @__PURE__ */E(b,{style:r,...l===void 0?{}:{testID:l},children:/* @__PURE__ */E(R,{source:{uri:e},style:n,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:i.onError})})}var Rc=/* @__PURE__ */Object.freeze({row:null,leading:null,trailing:null}),_c=/* @__PURE__ */Object.freeze({leading:void 0,trailing:void 0});function Tc(e,t,r){if(e.row===null||e.leading===null||e.trailing===null)return _c;let n=Math.abs(e.leading-e.trailing);if(n<.5)return _c;let l=e.row-t-e.leading-e.trailing,i=Math.min(n,Math.max(0,l-r));return i<.5?_c:e.leading<e.trailing?{leading:e.leading+i,trailing:void 0}:{leading:void 0,trailing:e.trailing+i}}function zc(e,t,r){let n=e[t];return n!==null&&Math.abs(n-r)<.5?e:{...e,[t]:r}}function Ic(e){return[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}function Pc(e){if(e.brightness!=="light")return false;let t=se.color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t),l=new Set(Ic(t));return n(r.brand,t.brand)&&n(r.accent,t.accent)&&Ic(r).every(e=>l.has(e))}function Fc(e){let t=(e.brightness==="dark"?de:se).color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t);return{success:!n(r.success,t.success),warning:!n(r.warningStrong,t.warningStrong)||!n(r.cautionAccent,t.cautionAccent),info:!(n(r.info,r.brandInk)&&n(r.badgeBgInfo,r.brandSoft)&&n(r.infoEdge,r.structureEdge))}}function Lc(e){return canonicalPetSpecies(e)==="cat"?"cat":"dog"}function Ec(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}function Oc(e){let t=Ec(e.ageYears),r=Lc(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return`${r} · ${n}`}var Ac=/* @__PURE__ */Object.freeze([
120
+ /* @__PURE__ */E(w,{onPress:()=>{if(!(S||C.current)){if(!y){let e={...petRef!==void 0?{petRef:petRef}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:h??null}:{}};ac(e,g)===null&&Vr(o,"unavailable",null);return}C.current=true,(f==null?m.open():m.openVisit(f,h??null)).then(e=>{e.opened?Vr(i,e.flowId??null):e.reason!=="cancelled"&&Vr(o,e.reason,e.error)}).finally(()=>{C.current=false})}},accessibilityRole:"button",accessibilityLabel:x,accessibilityState:{busy:S,disabled:S},style:[k.button,S?k.busy:null,a],children:/* @__PURE__ */E(Text,{style:[k.label,s],children:x})}),
121
+ /* @__PURE__ */E(TelevetHostOutlet,{})]})}function jc(e){let{color:t,space:r,radius:n,type:l,slots:i}=e;return f.create({button:{minHeight:Oc,minWidth:Oc,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...Vo(i.vetVisitButton)},busy:{opacity:Ac},label:{...face(e,"medium"),color:t.onPrimary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.snug,...Go(i.vetVisitButton)}})}function Dc(e){let[t,r]=i(null);return{shown:e!==null&&t!==e,onError:()=>r(e)}}function BrandImage({uri:e,label:t,decorative:r=false,style:n,resizeMode:l="contain",fallback:i=null,onError:o,testID:a}){let s=Dc(e);if(e===null||!s.shown)return i;let u=r?{accessible:false,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}:{accessible:true,accessibilityRole:"image",...t===void 0?{}:{accessibilityLabel:t}};/* @__PURE__ */
122
+ return E(T,{source:{uri:e},style:n,resizeMode:l,...u,onError:()=>{s.onError(),o?.()},...a===void 0?{}:{testID:a}})}function BrandLogo({logoUrl:e,name:t,barStyle:r,logoStyle:n,testID:l}){let i=Dc(e);return e===null||!i.shown?null:/* @__PURE__ */E(y,{style:r,...l===void 0?{}:{testID:l},children:/* @__PURE__ */E(T,{source:{uri:e},style:n,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:i.onError})})}var Mc=/* @__PURE__ */Object.freeze({row:null,leading:null,trailing:null}),Bc=/* @__PURE__ */Object.freeze({leading:void 0,trailing:void 0});function Hc(e,t,r){if(e.row===null||e.leading===null||e.trailing===null)return Bc;let n=Math.abs(e.leading-e.trailing);if(n<.5)return Bc;let l=e.row-t-e.leading-e.trailing,i=Math.min(n,Math.max(0,l-r));return i<.5?Bc:e.leading<e.trailing?{leading:e.leading+i,trailing:void 0}:{leading:void 0,trailing:e.trailing+i}}function Wc(e,t,r){let n=e[t];return n!==null&&Math.abs(n-r)<.5?e:{...e,[t]:r}}function Nc(e){return[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}function Uc(e){if(e.brightness!=="light")return false;let t=ue.color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t),l=new Set(Nc(t));return n(r.brand,t.brand)&&n(r.accent,t.accent)&&Nc(r).every(e=>l.has(e))}function $c(e){let t=(e.brightness==="dark"?ce:ue).color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t);return{success:!n(r.success,t.success),warning:!n(r.warningStrong,t.warningStrong)||!n(r.cautionAccent,t.cautionAccent),info:!(n(r.info,r.brandInk)&&n(r.badgeBgInfo,r.brandSoft)&&n(r.infoEdge,r.structureEdge))}}function Vc(e){return canonicalPetSpecies(e)==="cat"?"cat":"dog"}function qc(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}function Gc(e){let t=qc(e.ageYears),r=Vc(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return`${r} · ${n}`}var Kc=/* @__PURE__ */Object.freeze([
123
123
  /* @__PURE__ */Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),
124
124
  /* @__PURE__ */Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),
125
125
  /* @__PURE__ */Object.freeze({background:"#fbc558",foreground:"#10462e"}),
126
126
  /* @__PURE__ */Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),
127
127
  /* @__PURE__ */Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),
128
- /* @__PURE__ */Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function jc(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return Ac[t%Ac.length]}function Dc(e){let t=(e??"").trim();return(Array.from(t)[0]??"?").toUpperCase()}function Mc(e){return{...jc(e.petRef),initial:Dc(e.name)}}function Bc(e,t,r){let n=Mc(e);return t?n:{background:r.fill,foreground:r.ink,initial:n.initial}}function Hc(e){return Math.max(12,Math.round(e*.42))}function PetDisc({pet:e,size:t,ringStroke:r}){let l=useEverfurTheme(),i=n(()=>Wc(l),[l]),o=t-r*2,a=e===null?null:Bc(e,Pc(l),{fill:l.color.highlight,ink:l.color.onHighlight}),s=Hc(o);/* @__PURE__ */
129
- return E(Ring,{size:t,strokeWidth:r,color:l.color.mark,children:/* @__PURE__ */E(b,{style:[i.disc,{width:o,height:o,borderRadius:o/2},a===null?i.discEmpty:{backgroundColor:a.background}],children:/* @__PURE__ */E(Text,{tier:"badge",style:[i.letter,{fontSize:s,lineHeight:Math.round(s*1.2),color:a===null?l.color.text.muted:a.foreground}],children:a===null?Dc(null):a.initial})})})}function Wc(e){return p.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...face(e,"bold"),textAlign:"center",includeFontPadding:false}})}function Nc(e,t){let{borderRadius:r,...n}=Lo(e,t);return r===void 0?n:{...n,borderTopLeftRadius:r,borderTopRightRadius:r}}function Uc(e,t){let{backgroundColor:r,borderColor:n,borderWidth:l,borderRadius:i}=Lo(e,t);return{...r===void 0?{}:{backgroundColor:r},...n===void 0?{}:{borderRightColor:n,borderRightWidth:l??1},...i===void 0?{}:{borderTopRightRadius:i,borderBottomRightRadius:i}}}var $c=48,Vc=2,qc=320,Gc="80%",Kc="rgba(17,17,17,0.45)",Yc=18,Qc=22,Zc=12,Jc=.4,Xc=44;function ep(e){return e?.name?.trim()||Re.yourPet}function PetSwitcherSheet({visible:e,pets:t,activePetRef:r,onSelect:l,onAddPet:i=null,onClose:o}){let a=useEverfurTheme(),s=n(()=>tp(a),[a]);return e?/* @__PURE__ */E(C,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:o,children:/* @__PURE__ */O(b,{style:s.root,children:[
130
- /* @__PURE__ */E(v,{style:Ka,onPress:o,accessibilityRole:"button",accessibilityLabel:Re.close,children:/* @__PURE__ */E(b,{style:s.backdrop})}),
131
- /* @__PURE__ */O(b,{style:s.panel,accessibilityViewIsModal:true,children:[
132
- /* @__PURE__ */E(Text,{tier:"heading",style:s.title,accessibilityRole:"header",children:Re.yourPets}),
133
- /* @__PURE__ */E(S,{style:s.list,contentContainerStyle:s.listContent,showsVerticalScrollIndicator:true,children:t.map(e=>{let t=e.petRef===r,n=ep(e),i=Oc(e);/* @__PURE__ */
134
- return O(PressScale,{accessibilityRole:"button",accessibilityLabel:_e(t?Re.petCurrentlyActive:Re.switchToPet,{name:n}),accessibilityState:{selected:t},style:[s.row,t?s.rowActive:null],onPress:()=>l(e.petRef),children:[
135
- /* @__PURE__ */E(PetDisc,{pet:e,size:$c,ringStroke:Vc}),
136
- /* @__PURE__ */O(b,{style:s.copy,children:[
128
+ /* @__PURE__ */Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function Yc(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return Kc[t%Kc.length]}function Qc(e){let t=(e??"").trim();return(Array.from(t)[0]??"?").toUpperCase()}function Zc(e){return{...Yc(e.petRef),initial:Qc(e.name)}}function Jc(e,t,r){let n=Zc(e);return t?n:{background:r.fill,foreground:r.ink,initial:n.initial}}function Xc(e){return Math.max(12,Math.round(e*.42))}function PetDisc({pet:e,size:t,ringStroke:r}){let l=useEverfurTheme(),i=n(()=>ep(l),[l]),o=t-r*2,a=e===null?null:Jc(e,Uc(l),{fill:l.color.highlight,ink:l.color.onHighlight}),s=Xc(o);/* @__PURE__ */
129
+ return E(Ring,{size:t,strokeWidth:r,color:l.color.mark,children:/* @__PURE__ */E(y,{style:[i.disc,{width:o,height:o,borderRadius:o/2},a===null?i.discEmpty:{backgroundColor:a.background}],children:/* @__PURE__ */E(Text,{tier:"badge",style:[i.letter,{fontSize:s,lineHeight:Math.round(s*1.2),color:a===null?l.color.text.muted:a.foreground}],children:a===null?Qc(null):a.initial})})})}function ep(e){return f.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...face(e,"bold"),textAlign:"center",includeFontPadding:false}})}function tp(e,t){let{borderRadius:r,...n}=Vo(e,t);return r===void 0?n:{...n,borderTopLeftRadius:r,borderTopRightRadius:r}}function rp(e,t){let{backgroundColor:r,borderColor:n,borderWidth:l,borderRadius:i}=Vo(e,t);return{...r===void 0?{}:{backgroundColor:r},...n===void 0?{}:{borderRightColor:n,borderRightWidth:l??1},...i===void 0?{}:{borderTopRightRadius:i,borderBottomRightRadius:i}}}var np=48,lp=2,ip=320,op="80%",ap="rgba(17,17,17,0.45)",sp=18,up=22,dp=12,cp=.4,pp=44;function fp(e){return e?.name?.trim()||Me.yourPet}function PetSwitcherSheet({visible:e,pets:t,activePetRef:r,onSelect:l,onAddPet:i=null,onClose:o}){let a=useEverfurTheme(),s=n(()=>hp(a),[a]),u=xe();return e?/* @__PURE__ */E(S,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:o,children:/* @__PURE__ */O(y,{style:s.root,children:[
130
+ /* @__PURE__ */E(w,{style:as,onPress:o,accessibilityRole:"button",accessibilityLabel:Me.close,children:/* @__PURE__ */E(y,{style:s.backdrop})}),
131
+ /* @__PURE__ */O(y,{style:Re(s.panel,u),accessibilityViewIsModal:true,children:[
132
+ /* @__PURE__ */E(Text,{tier:"heading",style:s.title,accessibilityRole:"header",children:Me.yourPets}),
133
+ /* @__PURE__ */E(x,{style:s.list,contentContainerStyle:s.listContent,showsVerticalScrollIndicator:true,children:t.map(e=>{let t=e.petRef===r,n=fp(e),i=Gc(e);/* @__PURE__ */
134
+ return O(PressScale,{accessibilityRole:"button",accessibilityLabel:Be(t?Me.petCurrentlyActive:Me.switchToPet,{name:n}),accessibilityState:{selected:t},style:[s.row,t?s.rowActive:null],onPress:()=>l(e.petRef),children:[
135
+ /* @__PURE__ */E(PetDisc,{pet:e,size:np,ringStroke:lp}),
136
+ /* @__PURE__ */O(y,{style:s.copy,children:[
137
137
  /* @__PURE__ */E(Text,{style:s.name,numberOfLines:1,children:n}),
138
- /* @__PURE__ */E(Text,{tier:"compact",style:s.meta,numberOfLines:1,children:t?`${Re.activePrefix}${i}`:i})]}),t?/* @__PURE__ */E(CheckGlyph,{size:Yc,color:a.color.brandInk}):null]},e.petRef)})}),i!==null?/* @__PURE__ */O(PressScale,{accessibilityRole:"button",accessibilityLabel:Re.addAnotherPet,style:s.addRow,onPress:i,children:[
139
- /* @__PURE__ */E(b,{style:s.addDisc,children:/* @__PURE__ */E(Text,{tier:"control",style:s.addPlus,children:"+"})}),
140
- /* @__PURE__ */E(Text,{style:s.addLabel,children:Re.addAnotherPet})]}):null,
141
- /* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Re.close,containerStyle:s.closeSlot,style:s.closeButton,onPress:o,children:/* @__PURE__ */E(Text,{tier:"control",style:s.closeText,children:Re.close})})]})]})}):null}function tp(e){let t=e.color,r=e.radius,n=Oo(e.slots.dialog);return p.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:Kc},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:Qc,borderTopRightRadius:Qc,gap:14,maxHeight:Gc,...Nc(e.slots.dialog)},title:{...headingFace(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk,...n},list:{maxHeight:qc,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:Xc,paddingHorizontal:8},addDisc:{width:$c,height:$c,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:Vc,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...face(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...face(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary,...n},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:{...face(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...face(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:Jc},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:Zc,backgroundColor:t.brandSoft},closeText:{...face(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:Jc}})}var rp=44,np=36,lp=22,ip=20,op=9,ap=1.5,sp=6,up=35,dp=1.75,cp=12.4,pp=.5,fp=8,hp=28,gp=160,bp=16,yp=8;function mp(e,petRef){return Bd(e,petRef)}function ChatHeader({pets:e,petRef:petRef,historyUnread:t,onOpenHistory:l,onNewChat:o,onPetChange:a,onAddPet:s,vet:u,textingEntry:d=null}){let c=useEverfurTheme(),p=n(()=>vp(c),[c]),[f,h]=i(false),g=mp(e.pets,petRef),y=g!==null&&(e.pets.length>=2||s!==void 0),m=petRef??g?.petRef??null,v=ep(g),[w,k]=i(Rc),C=r(e=>t=>{let r=t.nativeEvent.layout.width;k(t=>zc(t,e,r))},[]),S=n(()=>C("row"),[C]),x=n(()=>C("leading"),[C]),R=n(()=>C("trailing"),[C]),_=2*bp+2*(c.slots.header?.borderColor!==void 0?1:0)+2*yp,T=Tc(w,_,gp),z=t=>{h(false),e.setActivePet(t),Lr(a,t)},I=s===void 0?null:()=>{h(false),Lr(s)};/* @__PURE__ */
138
+ /* @__PURE__ */E(Text,{tier:"compact",style:s.meta,numberOfLines:1,children:t?`${Me.activePrefix}${i}`:i})]}),t?/* @__PURE__ */E(CheckGlyph,{size:sp,color:a.color.brandInk}):null]},e.petRef)})}),i!==null?/* @__PURE__ */O(PressScale,{accessibilityRole:"button",accessibilityLabel:Me.addAnotherPet,style:s.addRow,onPress:i,children:[
139
+ /* @__PURE__ */E(y,{style:s.addDisc,children:/* @__PURE__ */E(Text,{tier:"control",style:s.addPlus,children:"+"})}),
140
+ /* @__PURE__ */E(Text,{style:s.addLabel,children:Me.addAnotherPet})]}):null,
141
+ /* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Me.close,containerStyle:s.closeSlot,style:s.closeButton,onPress:o,children:/* @__PURE__ */E(Text,{tier:"control",style:s.closeText,children:Me.close})})]})]})}):null}function hp(e){let t=e.color,r=e.radius,n=Go(e.slots.dialog);return f.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:ap},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:up,borderTopRightRadius:up,gap:14,maxHeight:op,...tp(e.slots.dialog)},title:{...headingFace(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk,...n},list:{maxHeight:ip,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:pp,paddingHorizontal:8},addDisc:{width:np,height:np,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:lp,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...face(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...face(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary,...n},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:{...face(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...face(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:cp},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:dp,backgroundColor:t.brandSoft},closeText:{...face(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:cp}})}var gp=44,bp=36,yp=22,mp=20,vp=9,wp=1.5,kp=6,Cp=35,Sp=1.75,xp=12.4,Rp=.5,Tp=8,_p=28,zp=160,Ip=16,Pp=8;function Fp(e,petRef){return Jd(e,petRef)}function ChatHeader({pets:e,petRef:petRef,historyUnread:t,onOpenHistory:l,onNewChat:o,onPetChange:a,onAddPet:s,vet:u,textingEntry:d=null}){let c=useEverfurTheme(),p=n(()=>Lp(c),[c]),[f,h]=i(false),g=Fp(e.pets,petRef),b=g!==null&&(e.pets.length>=2||s!==void 0),m=petRef??g?.petRef??null,v=fp(g),[w,k]=i(Mc),C=r(e=>t=>{let r=t.nativeEvent.layout.width;k(t=>Wc(t,e,r))},[]),S=n(()=>C("row"),[C]),x=n(()=>C("leading"),[C]),R=n(()=>C("trailing"),[C]),T=2*Ip+2*(c.slots.header?.borderColor!==void 0?1:0)+2*Pp,_=Hc(w,T,zp),z=t=>{h(false),e.setActivePet(t),Vr(a,t)},I=s===void 0?null:()=>{h(false),Vr(s)};/* @__PURE__ */
142
142
  return O(A,{children:[
143
- /* @__PURE__ */O(b,{style:p.row,onLayout:S,children:[
144
- /* @__PURE__ */E(b,{style:[p.leading,T.leading===void 0?null:{minWidth:T.leading}],children:/* @__PURE__ */O(b,{style:p.sideContent,onLayout:x,children:[o!==void 0?/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:bi.newChat,containerStyle:p.iconSlot,style:p.iconButton,onPress:o,children:/* @__PURE__ */E(EditGlyph,{size:ip,color:c.slots.header?.textColor??c.color.text.primary,strokeWidth:2})}):null,
145
- /* @__PURE__ */O(PressScale,{accessibilityRole:"button",accessibilityLabel:t?`${Re.openHistoryNative}${Re.newReplySuffix}`:Re.openHistoryNative,containerStyle:p.iconSlot,style:p.iconButton,onPress:l,children:[
146
- /* @__PURE__ */E(MenuGlyph,{size:lp,color:c.slots.header?.textColor??c.color.text.primary,strokeWidth:2}),t?/* @__PURE__ */E(b,{style:p.unreadDot,pointerEvents:"none"}):null]})]})}),
147
- /* @__PURE__ */E(b,{style:p.centre,pointerEvents:"box-none",children:/* @__PURE__ */E(BrandLogo,{logoUrl:c.meta.logoUrl,name:c.meta.displayName,barStyle:p.logoBar,logoStyle:p.logo})}),
148
- /* @__PURE__ */E(b,{style:[p.trailing,T.trailing===void 0?null:{minWidth:T.trailing}],children:/* @__PURE__ */O(b,{style:p.trailingContent,onLayout:R,children:[m===null?null:/* @__PURE__ */E(VetVisitButtonCore,{entry:"chat",petRef:m,...u?.returnTo!==void 0?{returnTo:u.returnTo}:{},...u?.usState!==void 0?{usState:u.usState}:{},...u?.prefer!==void 0?{prefer:u.prefer}:{},style:p.vetEntry,labelStyle:p.vetEntryLabel}),
149
- /* @__PURE__ */E(b,{style:p.right,children:y?/* @__PURE__ */O(PressScale,{accessibilityRole:"button",accessibilityLabel:_e(Re.switchActivePet,{name:v}),containerStyle:p.avatarSlot,style:p.avatarWrap,onPress:()=>h(true),children:[
150
- /* @__PURE__ */E(PetDisc,{pet:g,size:up,ringStroke:dp}),
151
- /* @__PURE__ */E(b,{style:p.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */E(PlusGlyph,{size:fp,color:c.color.brandInk,strokeWidth:2})})]}):e.loading&&g===null?
152
- /* @__PURE__ */E(b,{style:p.avatarWrap,accessible:true,accessibilityLabel:Re.yourPet,children:/* @__PURE__ */E(Ring,{size:up,strokeWidth:dp,color:c.color.mark,children:/* @__PURE__ */E(b,{style:p.placeholderDisc})})}):/* @__PURE__ */E(b,{style:p.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:g===null?Re.yourPet:v,children:/* @__PURE__ */E(PetDisc,{pet:g,size:up,ringStroke:dp})})})]})}),
153
- /* @__PURE__ */E(PetSwitcherSheet,{visible:f,pets:e.pets,activePetRef:g?.petRef??null,onSelect:z,onAddPet:I,onClose:()=>h(false)})]}),d===null?null:/* @__PURE__ */E(TextingEntryRow,{entry:d,place:"header"})]})}function TextingEntryRow({entry:e,place:t}){let r=useEverfurTheme(),l=n(()=>vp(r),[r]);/* @__PURE__ */
154
- return E(b,{style:t==="header"?l.textingEntryRowHeader:l.textingEntryRowThread,children:/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,containerStyle:l.textingEntrySlot,style:l.vetEntry,onPress:e.onOpen,testID:"everfur-texting-entry",children:/* @__PURE__ */E(Text,{tier:"control",style:l.vetEntryLabel,numberOfLines:1,children:e.label})})})}function vp(e){let t=e.color,r=up-dp*2,n=e.slots.header;return p.create({vetEntry:{minHeight:rp,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:p.hairlineWidth,borderColor:t.controlEdge},vetEntryLabel:{...face(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},textingEntrySlot:{borderRadius:e.radius.pill,maxWidth:"100%"},textingEntryRowHeader:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:bp,paddingBottom:10,backgroundColor:n?.backgroundColor??t.surface},textingEntryRowThread:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:bp,paddingTop:e.space.sm},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:bp,paddingVertical:10,backgroundColor:t.surface,...Lo(n)},iconSlot:{borderRadius:np/2},iconButton:{width:np,height:np,borderRadius:np/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:sp,right:sp,width:op,height:op,borderRadius:op,backgroundColor:t.danger,borderWidth:ap,borderColor:n?.backgroundColor??t.surface},leading:{flexShrink:0,alignItems:"flex-start"},trailing:{flexShrink:0,alignItems:"flex-end"},sideContent:{flexDirection:"row",alignItems:"center"},trailingContent:{flexDirection:"row",alignItems:"center",gap:e.space.sm},centre:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,marginHorizontal:yp,alignItems:"center",justifyContent:"center"},logoBar:{alignSelf:"stretch",alignItems:"center"},logo:{height:hp,width:gp,maxWidth:"100%"},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:up/2},avatarWrap:{width:up,height:up,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:cp,height:cp,borderRadius:cp/2,borderWidth:pp,borderColor:t.mark,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}var wp=/* @__PURE__ */Object.freeze([
155
- /* @__PURE__ */Object.freeze({key:"inaccurate",label:Re.feedbackReasonInaccurate,feedbackType:"wrong"}),
156
- /* @__PURE__ */Object.freeze({key:"outdated",label:Re.feedbackReasonOutdated,feedbackType:"outdated"}),
157
- /* @__PURE__ */Object.freeze({key:"unsafe",label:Re.feedbackReasonUnsafe,feedbackType:"dangerous"}),
158
- /* @__PURE__ */Object.freeze({key:"unclear",label:Re.feedbackReasonUnclear,feedbackType:"unclear"}),
159
- /* @__PURE__ */Object.freeze({key:"other",label:Re.feedbackReasonOther,feedbackType:"not_helpful"})]),kp=/* @__PURE__ */Object.freeze([
160
- /* @__PURE__ */Object.freeze({sentiment:"up",label:Re.feedbackHelpful}),
161
- /* @__PURE__ */Object.freeze({sentiment:"down",label:Re.feedbackNotHelpful})]);function Cp(e){switch(e){case"up":return"helpful";case"neutral":return"neutral";case"down":return"not_helpful"}}function Sp(e,t){if(e==="down"&&t!==null){let e=wp.find(e=>e.key===t);if(e!==void 0)return e.feedbackType}return Cp(e)}var xp=44,Rp="rgba(17,17,17,0.55)",_p=26,Tp=36,zp=4,Ip=20,Pp=38,Fp=18,Lp=12;function FeedbackReasons({visible:e,onSubmit:t,onSkip:r}){let l=useEverfurTheme(),o=n(()=>Ep(l),[l]),[a,s]=i(null),[u,d]=i(""),[c,p]=i(false),[h,g]=i(false),y=()=>{s(null),d(""),p(false),g(false)},w=()=>{c||(y(),r())},k=async()=>{if(c)return;p(true),g(false);let e=u.trim();await t(a,e.length>0?e:null)?y():(p(false),g(true))};if(!e)return null;let S=[...u].length>Bo;/* @__PURE__ */
162
- return E(C,{visible:true,transparent:true,animationType:l.motion.reducedMotion?"none":"slide",onRequestClose:w,children:/* @__PURE__ */O(m,{behavior:f.OS==="ios"?"padding":void 0,style:o.root,children:[
163
- /* @__PURE__ */E(v,{style:o.scrim,onPress:w,accessibilityRole:"button",accessibilityLabel:Re.feedbackSkipA11y}),
164
- /* @__PURE__ */O(b,{style:o.sheet,accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[
165
- /* @__PURE__ */E(b,{style:o.handle}),
166
- /* @__PURE__ */O(b,{style:o.header,children:[
167
- /* @__PURE__ */E(b,{style:o.iconBadge,children:/* @__PURE__ */E(ThumbGlyph,{size:Fp,color:l.color.brandInk,active:false,rotate:"180deg"})}),
168
- /* @__PURE__ */O(b,{style:o.headerText,children:[
169
- /* @__PURE__ */E(Text,{tier:"heading",style:o.title,accessibilityRole:"header",children:Re.feedbackTitle}),
170
- /* @__PURE__ */E(Text,{style:o.subtitle,children:Re.feedbackSubtitle})]})]}),
171
- /* @__PURE__ */E(b,{style:o.options,children:wp.map(e=>{let t=a===e.key;/* @__PURE__ */
172
- return O(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,accessibilityState:{selected:t},style:[o.option,t?o.optionSelected:null],onPress:()=>s(t=>t===e.key?null:e.key),children:[
143
+ /* @__PURE__ */O(y,{style:p.row,onLayout:S,children:[
144
+ /* @__PURE__ */E(y,{style:[p.leading,_.leading===void 0?null:{minWidth:_.leading}],children:/* @__PURE__ */O(y,{style:p.sideContent,onLayout:x,children:[o!==void 0?/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Ii.newChat,containerStyle:p.iconSlot,style:p.iconButton,onPress:o,children:/* @__PURE__ */E(EditGlyph,{size:mp,color:c.slots.header?.textColor??c.color.text.primary,strokeWidth:2})}):null,
145
+ /* @__PURE__ */O(PressScale,{accessibilityRole:"button",accessibilityLabel:t?`${Me.openHistoryNative}${Me.newReplySuffix}`:Me.openHistoryNative,containerStyle:p.iconSlot,style:p.iconButton,onPress:l,children:[
146
+ /* @__PURE__ */E(MenuGlyph,{size:yp,color:c.slots.header?.textColor??c.color.text.primary,strokeWidth:2}),t?/* @__PURE__ */E(y,{style:p.unreadDot,pointerEvents:"none"}):null]})]})}),
147
+ /* @__PURE__ */E(y,{style:p.centre,pointerEvents:"box-none",children:/* @__PURE__ */E(BrandLogo,{logoUrl:c.meta.logoUrl,name:c.meta.displayName,barStyle:p.logoBar,logoStyle:p.logo})}),
148
+ /* @__PURE__ */E(y,{style:[p.trailing,_.trailing===void 0?null:{minWidth:_.trailing}],children:/* @__PURE__ */O(y,{style:p.trailingContent,onLayout:R,children:[m===null?null:/* @__PURE__ */E(VetVisitButtonCore,{entry:"chat",petRef:m,...u?.returnTo!==void 0?{returnTo:u.returnTo}:{},...u?.usState!==void 0?{usState:u.usState}:{},...u?.prefer!==void 0?{prefer:u.prefer}:{},style:p.vetEntry,labelStyle:p.vetEntryLabel}),
149
+ /* @__PURE__ */E(y,{style:p.right,children:b?/* @__PURE__ */O(PressScale,{accessibilityRole:"button",accessibilityLabel:Be(Me.switchActivePet,{name:v}),containerStyle:p.avatarSlot,style:p.avatarWrap,onPress:()=>h(true),children:[
150
+ /* @__PURE__ */E(PetDisc,{pet:g,size:Cp,ringStroke:Sp}),
151
+ /* @__PURE__ */E(y,{style:p.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */E(PlusGlyph,{size:Tp,color:c.color.brandInk,strokeWidth:2})})]}):e.loading&&g===null?
152
+ /* @__PURE__ */E(y,{style:p.avatarWrap,accessible:true,accessibilityLabel:Me.yourPet,children:/* @__PURE__ */E(Ring,{size:Cp,strokeWidth:Sp,color:c.color.mark,children:/* @__PURE__ */E(y,{style:p.placeholderDisc})})}):/* @__PURE__ */E(y,{style:p.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:g===null?Me.yourPet:v,children:/* @__PURE__ */E(PetDisc,{pet:g,size:Cp,ringStroke:Sp})})})]})}),
153
+ /* @__PURE__ */E(PetSwitcherSheet,{visible:f,pets:e.pets,activePetRef:g?.petRef??null,onSelect:z,onAddPet:I,onClose:()=>h(false)})]}),d===null?null:/* @__PURE__ */E(TextingEntryRow,{entry:d,place:"header"})]})}function TextingEntryRow({entry:e,place:t}){let r=useEverfurTheme(),l=n(()=>Lp(r),[r]);/* @__PURE__ */
154
+ return E(y,{style:t==="header"?l.textingEntryRowHeader:l.textingEntryRowThread,children:/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,containerStyle:l.textingEntrySlot,style:l.vetEntry,onPress:e.onOpen,testID:"everfur-texting-entry",children:/* @__PURE__ */E(Text,{tier:"control",style:l.vetEntryLabel,numberOfLines:1,children:e.label})})})}function Lp(e){let t=e.color,r=Cp-Sp*2,n=e.slots.header;return f.create({vetEntry:{minHeight:gp,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:f.hairlineWidth,borderColor:t.controlEdge},vetEntryLabel:{...face(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},textingEntrySlot:{borderRadius:e.radius.pill,maxWidth:"100%"},textingEntryRowHeader:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:Ip,paddingBottom:10,backgroundColor:n?.backgroundColor??t.surface},textingEntryRowThread:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:Ip,paddingTop:e.space.md,paddingBottom:e.space.xs},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:Ip,paddingVertical:10,backgroundColor:t.surface,...Vo(n)},iconSlot:{borderRadius:bp/2},iconButton:{width:bp,height:bp,borderRadius:bp/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:kp,right:kp,width:vp,height:vp,borderRadius:vp,backgroundColor:t.danger,borderWidth:wp,borderColor:n?.backgroundColor??t.surface},leading:{flexShrink:0,alignItems:"flex-start"},trailing:{flexShrink:0,alignItems:"flex-end"},sideContent:{flexDirection:"row",alignItems:"center"},trailingContent:{flexDirection:"row",alignItems:"center",gap:e.space.sm},centre:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,marginHorizontal:Pp,alignItems:"center",justifyContent:"center"},logoBar:{alignSelf:"stretch",alignItems:"center"},logo:{height:_p,width:zp,maxWidth:"100%"},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:Cp/2},avatarWrap:{width:Cp,height:Cp,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:xp,height:xp,borderRadius:xp/2,borderWidth:Rp,borderColor:t.mark,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}var Ep=/* @__PURE__ */Object.freeze([
155
+ /* @__PURE__ */Object.freeze({key:"inaccurate",label:Me.feedbackReasonInaccurate,feedbackType:"wrong"}),
156
+ /* @__PURE__ */Object.freeze({key:"outdated",label:Me.feedbackReasonOutdated,feedbackType:"outdated"}),
157
+ /* @__PURE__ */Object.freeze({key:"unsafe",label:Me.feedbackReasonUnsafe,feedbackType:"dangerous"}),
158
+ /* @__PURE__ */Object.freeze({key:"unclear",label:Me.feedbackReasonUnclear,feedbackType:"unclear"}),
159
+ /* @__PURE__ */Object.freeze({key:"other",label:Me.feedbackReasonOther,feedbackType:"not_helpful"})]),Op=/* @__PURE__ */Object.freeze([
160
+ /* @__PURE__ */Object.freeze({sentiment:"up",label:Me.feedbackHelpful}),
161
+ /* @__PURE__ */Object.freeze({sentiment:"down",label:Me.feedbackNotHelpful})]);function Ap(e){switch(e){case"up":return"helpful";case"neutral":return"neutral";case"down":return"not_helpful"}}function jp(e,t){if(e==="down"&&t!==null){let e=Ep.find(e=>e.key===t);if(e!==void 0)return e.feedbackType}return Ap(e)}var Dp=44,Mp="rgba(17,17,17,0.55)",Bp=26,Hp=36,Wp=4,Np=20,Up=38,$p=18,Vp=12;function FeedbackReasons({visible:e,onSubmit:t,onSkip:r}){let l=useEverfurTheme(),o=n(()=>qp(l),[l]),a=xe(),[s,u]=i(null),[d,c]=i(""),[p,f]=i(false),[g,b]=i(false),m=()=>{u(null),c(""),f(false),b(false)},k=()=>{p||(m(),r())},C=async()=>{if(p)return;f(true),b(false);let e=d.trim();await t(s,e.length>0?e:null)?m():(f(false),b(true))};if(!e)return null;let x=[...d].length>Jo;/* @__PURE__ */
162
+ return E(S,{visible:true,transparent:true,animationType:l.motion.reducedMotion?"none":"slide",onRequestClose:k,children:/* @__PURE__ */O(v,{behavior:h.OS==="ios"?"padding":void 0,style:o.root,children:[
163
+ /* @__PURE__ */E(w,{style:o.scrim,onPress:k,accessibilityRole:"button",accessibilityLabel:Me.feedbackSkipA11y}),
164
+ /* @__PURE__ */O(y,{style:Re(o.sheet,a),accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[
165
+ /* @__PURE__ */E(y,{style:o.handle}),
166
+ /* @__PURE__ */O(y,{style:o.header,children:[
167
+ /* @__PURE__ */E(y,{style:o.iconBadge,children:/* @__PURE__ */E(ThumbGlyph,{size:$p,color:l.color.brandInk,active:false,rotate:"180deg"})}),
168
+ /* @__PURE__ */O(y,{style:o.headerText,children:[
169
+ /* @__PURE__ */E(Text,{tier:"heading",style:o.title,accessibilityRole:"header",children:Me.feedbackTitle}),
170
+ /* @__PURE__ */E(Text,{style:o.subtitle,children:Me.feedbackSubtitle})]})]}),
171
+ /* @__PURE__ */E(y,{style:o.options,children:Ep.map(e=>{let t=s===e.key;/* @__PURE__ */
172
+ return O(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,accessibilityState:{selected:t},style:[o.option,t?o.optionSelected:null],onPress:()=>u(t=>t===e.key?null:e.key),children:[
173
173
  /* @__PURE__ */E(Text,{style:[o.optionLabel,t?o.optionLabelSelected:null],children:e.label}),
174
- /* @__PURE__ */E(b,{style:[o.radio,t?o.radioSelected:null],children:t?/* @__PURE__ */E(CheckGlyph,{size:Lp,color:l.color.surface,strokeWidth:2}):null})]},e.key)})}),
175
- /* @__PURE__ */O(b,{style:o.inputWrap,children:[
176
- /* @__PURE__ */E(ge,{style:o.input,placeholder:Re.feedbackNotesPlaceholder,placeholderTextColor:l.color.text.placeholder,accessibilityLabel:Re.feedbackNotesPlaceholder,value:u,onChangeText:d,multiline:true,editable:!c}),u.length>0?/* @__PURE__ */E(Text,{tier:"compact",style:[o.counter,S?o.counterOver:null],children:`${[...u].length}/${Bo}`}):null]}),h?/* @__PURE__ */E(Text,{style:o.failed,accessibilityRole:"alert",children:Re.feedbackFailed}):null,
177
- /* @__PURE__ */O(b,{style:o.actions,children:[
178
- /* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Re.feedbackSubmit,accessibilityState:{busy:c,disabled:c||S},disabled:c||S,style:[o.submit,c||S?o.submitDisabled:null],onPress:()=>{k()},children:/* @__PURE__ */E(Text,{tier:"control",style:o.submitLabel,children:Re.feedbackSubmit})}),
179
- /* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:Re.feedbackSkipA11y,hitSlop:8,onPress:w,style:o.skip,children:/* @__PURE__ */E(Text,{tier:"control",style:o.skipLabel,children:Re.feedbackSkip})})]})]})]})})}function Ep(e){let t=e.color,r=e.type,n=e.radius,l=e.slots,i=Oo(l.dialog);return p.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...Ka,backgroundColor:Rp},sheet:{backgroundColor:t.surface,borderTopLeftRadius:_p,borderTopRightRadius:_p,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14,...Nc(l.dialog)},handle:{alignSelf:"center",width:Tp,height:zp,borderRadius:zp/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:Pp,height:Pp,borderRadius:Pp/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...headingFace(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight,...i},subtitle:{...face(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted,...i},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:p.hairlineWidth,borderColor:t.controlEdge,backgroundColor:t.surface,...Lo(l.chip,p.hairlineWidth)},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.primary,...Oo(l.chip)},optionLabelSelected:{color:t.brandInk},radio:{width:Ip,height:Ip,borderRadius:Ip/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,...face(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top",...Lo(l.input,1),...Oo(l.input)},counter:{...face(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...face(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:xp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...Lo(l.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...Oo(l.primaryButton)},skip:{minHeight:xp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}var Op=/* @__PURE__ */Symbol.for("everfur.sdk.rn.askHome");function Ap(){let e=globalThis,t=e[Op];if(t!==void 0)return t;let r={factory:createContext(null),home:createContext(null)};return e[Op]=r,r}var jp=Ap().factory,Dp=Ap().home;function Mp(){return s(jp)}function Bp(){return s(Dp)?.kit??null}function Hp(){return s(Dp)}var Wp=15,Np=8;function HistoryBar({bar:e,history:t,empty:r,unread:l,extra:i}){let o=useEverfurTheme(),a=Bp(),s=n(()=>a!==null?Vp(o,a):qp(o),[o,a]),u=t.cursor===null?t.rows.length:0,d=t=>{let r=e.renderIcon;if(r!==void 0)/* @__PURE__ */return E(HostRender,{render:()=>r(t),fallback:null});if(a===null)return null;let n=String(p.flatten(s.label).color??o.color.linkInk);return t==="history"?/* @__PURE__ */E(HistoryGlyph,{size:$p,color:n,strokeWidth:1.8}):/* @__PURE__ */E(EditGlyph,{size:$p,color:n,strokeWidth:1.8})};/* @__PURE__ */
180
- return O(b,{style:s.bar,testID:"everfur-history-bar",children:[
181
- /* @__PURE__ */O(v,{accessibilityRole:"button",accessibilityLabel:u>0?`${e.chats} ${u}`:e.chats,accessibilityState:{expanded:t.open},onPress:t.open?t.close:t.show,style:s.control,hitSlop:a!==null?Up:void 0,children:[d("history"),
182
- /* @__PURE__ */E(Text,{tier:"control",style:s.label,children:e.chats}),u>0?/* @__PURE__ */E(b,{style:s.count,children:/* @__PURE__ */E(Text,{tier:"badge",style:s.countText,children:String(u)})}):null,l?/* @__PURE__ */E(b,{style:s.dot,testID:"everfur-chat-history-bar-unread"}):null]}),e.extra??null,i??null,
183
- /* @__PURE__ */E(b,{style:s.spacer}),r?null:/* @__PURE__ */O(v,{accessibilityRole:"button",accessibilityLabel:e.newChat,onPress:t.newConversation,style:s.control,hitSlop:a!==null?Up:void 0,children:[d("edit"),
184
- /* @__PURE__ */E(Text,{tier:"control",style:s.label,children:e.newChat})]})]})}var Up=4,$p=18;function Vp(e,t){return{...qp(e),bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.sm},control:t.view(".thread__hist"),label:t.text(".thread__hist"),count:t.view(".thread__count"),countText:t.text(".thread__count")}}function qp(e){let t=e.color,r=e.space;return p.create({bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.xs},control:{flexDirection:"row",alignItems:"center",gap:6,minHeight:xs},label:{...face(e,"bold"),fontSize:Wp,color:t.brandInk},count:{minWidth:22,paddingHorizontal:7,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,alignItems:"center"},countText:{...face(e,"bold"),fontSize:e.type.size.caption,color:t.text.primary},dot:{width:Np,height:Np,borderRadius:Np/2,backgroundColor:t.danger},spacer:{flexGrow:1}})}var Gp=.88,Kp=420,Yp=58,Qp="rgba(17,17,17,0.28)",Zp=.15,Jp=14,Xp=12,ef=44,tf=16,rf=14,nf=12,lf=14,of=8,af=2,sf=.5,uf=ao(Zi.standard);function df(e){return Math.min(Math.round(e*Gp),Kp)}function HistoryDrawer({chat:e,history:t}){let[n,l]=i(t.open),o=r(()=>l(false),[]);return t.open&&!n&&l(true),n?/* @__PURE__ */E(DrawerModal,{chat:e,history:t,onHidden:o}):null}function DrawerModal({chat:e,history:t,onHidden:r}){let i=useEverfurTheme(),a=n(()=>cf(i),[i]),s=no(),u=L(),{width:d}=P(),c=df(d),p=t.open,h=l(null);h.current===null&&(h.current=new I.Value(s.drawerMs<=0&&p?1:0));let g=h.current;o(()=>{if(!p&&s.drawerMs<=0){r();return}let e=I.timing(g,{toValue:p?1:0,duration:s.drawerMs,easing:uf,useNativeDriver:true});return e.start(({finished:e})=>{e&&!p&&r()}),()=>e.stop()},[p,g,s.drawerMs,r]);let y=g.interpolate({inputRange:[0,1],outputRange:[-c,0]}),w=t.filtered,k=t.rows.length===0,S=t.cursor===null&&!t.loading&&t.error===null,R=k&&t.loading?/* @__PURE__ */O(b,{style:a.emptyCard,accessibilityLabel:bi.loading,accessibilityState:{busy:true},children:[
185
- /* @__PURE__ */E(x,{color:a.emptyTitle.color}),
186
- /* @__PURE__ */E(Text,{style:a.emptyBody,children:bi.loading})]}):k&&t.error!==null?/* @__PURE__ */O(b,{style:a.emptyCard,children:[
187
- /* @__PURE__ */E(Text,{style:a.emptyTitle,accessibilityRole:"alert",children:bi.loadFailed}),
174
+ /* @__PURE__ */E(y,{style:[o.radio,t?o.radioSelected:null],children:t?/* @__PURE__ */E(CheckGlyph,{size:Vp,color:l.color.surface,strokeWidth:2}):null})]},e.key)})}),
175
+ /* @__PURE__ */O(y,{style:o.inputWrap,children:[
176
+ /* @__PURE__ */E(be,{style:o.input,placeholder:Me.feedbackNotesPlaceholder,placeholderTextColor:l.color.text.placeholder,accessibilityLabel:Me.feedbackNotesPlaceholder,value:d,onChangeText:c,multiline:true,editable:!p}),d.length>0?/* @__PURE__ */E(Text,{tier:"compact",style:[o.counter,x?o.counterOver:null],children:`${[...d].length}/${Jo}`}):null]}),g?/* @__PURE__ */E(Text,{style:o.failed,accessibilityRole:"alert",children:Me.feedbackFailed}):null,
177
+ /* @__PURE__ */O(y,{style:o.actions,children:[
178
+ /* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Me.feedbackSubmit,accessibilityState:{busy:p,disabled:p||x},disabled:p||x,style:[o.submit,p||x?o.submitDisabled:null],onPress:()=>{C()},children:/* @__PURE__ */E(Text,{tier:"control",style:o.submitLabel,children:Me.feedbackSubmit})}),
179
+ /* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:Me.feedbackSkipA11y,hitSlop:8,onPress:k,style:o.skip,children:/* @__PURE__ */E(Text,{tier:"control",style:o.skipLabel,children:Me.feedbackSkip})})]})]})]})})}function qp(e){let t=e.color,r=e.type,n=e.radius,l=e.slots,i=Go(l.dialog);return f.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...as,backgroundColor:Mp},sheet:{backgroundColor:t.surface,borderTopLeftRadius:Bp,borderTopRightRadius:Bp,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14,...tp(l.dialog)},handle:{alignSelf:"center",width:Hp,height:Wp,borderRadius:Wp/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:Up,height:Up,borderRadius:Up/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...headingFace(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight,...i},subtitle:{...face(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted,...i},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:f.hairlineWidth,borderColor:t.controlEdge,backgroundColor:t.surface,...Vo(l.chip,f.hairlineWidth)},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.primary,...Go(l.chip)},optionLabelSelected:{color:t.brandInk},radio:{width:Np,height:Np,borderRadius:Np/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,...face(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top",...Vo(l.input,1),...Go(l.input)},counter:{...face(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...face(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:Dp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...Vo(l.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...Go(l.primaryButton)},skip:{minHeight:Dp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}var Gp=/* @__PURE__ */Symbol.for("everfur.sdk.rn.askHome");function Kp(){let e=globalThis,t=e[Gp];if(t!==void 0)return t;let r={factory:createContext(null),home:createContext(null)};return e[Gp]=r,r}var Yp=Kp().factory,Qp=Kp().home;function Zp(){return s(Yp)}function Jp(){return s(Qp)?.kit??null}function Xp(){return s(Qp)}var ef=15,tf=8;function HistoryBar({bar:e,history:t,empty:r,unread:l,extra:i}){let o=useEverfurTheme(),a=Jp(),s=n(()=>a!==null?lf(o,a):of(o),[o,a]),u=t.cursor===null?t.rows.length:0,d=t=>{let r=e.renderIcon;if(r!==void 0)/* @__PURE__ */return E(HostRender,{render:()=>r(t),fallback:null});if(a===null)return null;let n=String(f.flatten(s.label).color??o.color.linkInk);return t==="history"?/* @__PURE__ */E(HistoryGlyph,{size:nf,color:n,strokeWidth:1.8}):/* @__PURE__ */E(EditGlyph,{size:nf,color:n,strokeWidth:1.8})};/* @__PURE__ */
180
+ return O(y,{style:s.bar,testID:"everfur-history-bar",children:[
181
+ /* @__PURE__ */O(w,{accessibilityRole:"button",accessibilityLabel:u>0?`${e.chats} ${u}`:e.chats,accessibilityState:{expanded:t.open},onPress:t.open?t.close:t.show,style:s.control,hitSlop:a!==null?rf:void 0,children:[d("history"),
182
+ /* @__PURE__ */E(Text,{tier:"control",style:s.label,children:e.chats}),u>0?/* @__PURE__ */E(y,{style:s.count,children:/* @__PURE__ */E(Text,{tier:"badge",style:s.countText,children:String(u)})}):null,l?/* @__PURE__ */E(y,{style:s.dot,testID:"everfur-chat-history-bar-unread"}):null]}),e.extra??null,i??null,
183
+ /* @__PURE__ */E(y,{style:s.spacer}),r?null:/* @__PURE__ */O(w,{accessibilityRole:"button",accessibilityLabel:e.newChat,onPress:t.newConversation,style:s.control,hitSlop:a!==null?rf:void 0,children:[d("edit"),
184
+ /* @__PURE__ */E(Text,{tier:"control",style:s.label,children:e.newChat})]})]})}var rf=4,nf=18;function lf(e,t){return{...of(e),bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.sm},control:t.view(".thread__hist"),label:t.text(".thread__hist"),count:t.view(".thread__count"),countText:t.text(".thread__count")}}function of(e){let t=e.color,r=e.space;return f.create({bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.xs},control:{flexDirection:"row",alignItems:"center",gap:6,minHeight:Ds},label:{...face(e,"bold"),fontSize:ef,color:t.brandInk},count:{minWidth:22,paddingHorizontal:7,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,alignItems:"center"},countText:{...face(e,"bold"),fontSize:e.type.size.caption,color:t.text.primary},dot:{width:tf,height:tf,borderRadius:tf/2,backgroundColor:t.danger},spacer:{flexGrow:1}})}var af=.88,sf=420,uf=58,df="rgba(17,17,17,0.28)",cf=.15,pf=14,ff=12,hf=44,gf=16,bf=14,yf=12,mf=14,vf=8,wf=2,kf=.5,Cf=ko(co.standard);function Sf(e){return Math.min(Math.round(e*af),sf)}function HistoryDrawer({chat:e,history:t}){let[n,l]=i(t.open),o=r(()=>l(false),[]);return t.open&&!n&&l(true),n?/* @__PURE__ */E(DrawerModal,{chat:e,history:t,onHidden:o}):null}function DrawerModal({chat:e,history:t,onHidden:r}){let i=useEverfurTheme(),a=n(()=>xf(i),[i]),s=yo(),u=j(),{width:d}=F(),c=Sf(d),p=t.open,f=l(null);f.current===null&&(f.current=new P.Value(s.drawerMs<=0&&p?1:0));let g=f.current;o(()=>{if(!p&&s.drawerMs<=0){r();return}let e=P.timing(g,{toValue:p?1:0,duration:s.drawerMs,easing:Cf,useNativeDriver:true});return e.start(({finished:e})=>{e&&!p&&r()}),()=>e.stop()},[p,g,s.drawerMs,r]);let b=g.interpolate({inputRange:[0,1],outputRange:[-c,0]}),m=t.filtered,k=t.rows.length===0,C=t.cursor===null&&!t.loading&&t.error===null,x=k&&t.loading?/* @__PURE__ */O(y,{style:a.emptyCard,accessibilityLabel:Ii.loading,accessibilityState:{busy:true},children:[
185
+ /* @__PURE__ */E(R,{color:a.emptyTitle.color}),
186
+ /* @__PURE__ */E(Text,{style:a.emptyBody,children:Ii.loading})]}):k&&t.error!==null?/* @__PURE__ */O(y,{style:a.emptyCard,children:[
187
+ /* @__PURE__ */E(Text,{style:a.emptyTitle,accessibilityRole:"alert",children:Ii.loadFailed}),
188
188
  /* @__PURE__ */E(Text,{style:a.emptyBody,children:t.error}),
189
- /* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:bi.retry,containerStyle:a.retrySlot,style:a.retryButton,onPress:()=>{t.load()},children:/* @__PURE__ */E(Text,{tier:"control",style:a.retryText,children:bi.retry})})]}):t.emptyKind==="empty"?/* @__PURE__ */O(b,{style:a.emptyCard,children:[
190
- /* @__PURE__ */E(Text,{style:a.emptyTitle,children:bi.empty}),
191
- /* @__PURE__ */E(Text,{style:a.emptyBody,children:bi.emptyBody})]}):
192
- /* @__PURE__ */E(Text,{style:a.noMatch,children:bi.noMatch}),_=!t.searching&&t.loadingMore?/* @__PURE__ */E(b,{style:a.loadMoreFooter,children:/* @__PURE__ */E(Text,{style:a.loadMoreLabel,children:bi.loadingMore})}):null;/* @__PURE__ */
193
- return E(C,{visible:true,transparent:true,animationType:"none",onRequestClose:t.close,children:/* @__PURE__ */O(b,{style:a.root,children:[
194
- /* @__PURE__ */E(v,{style:Ka,onPress:t.close,accessibilityRole:"button",accessibilityLabel:bi.closeA11y,children:/* @__PURE__ */E(I.View,{style:[a.backdrop,{opacity:g}]})}),
195
- /* @__PURE__ */E(I.View,{style:[a.panel,{width:c,paddingTop:Math.max(Yp,u.top+i.space.md),transform:[{translateX:y}]}],accessibilityViewIsModal:true,children:/* @__PURE__ */O(m,{style:a.keyboardAvoider,behavior:f.OS==="ios"?"padding":"height",children:[
196
- /* @__PURE__ */O(b,{style:a.header,children:[
197
- /* @__PURE__ */E(Text,{tier:"heading",style:a.heading,accessibilityRole:"header",children:bi.heading}),
198
- /* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:bi.newChat,style:a.newChat,onPress:t.newConversation,children:/* @__PURE__ */E(Text,{tier:"control",style:a.newChatLabel,children:bi.newChat})}),
199
- /* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:bi.close,hitSlop:0,style:a.closeButton,onPress:t.close,children:/* @__PURE__ */E(CloseGlyph,{size:tf,color:i.color.text.muted,strokeWidth:1.75})})]}),
200
- /* @__PURE__ */O(b,{style:a.searchPill,children:[
201
- /* @__PURE__ */E(SearchGlyph,{size:lf,color:i.color.text.muted,strokeWidth:1.5}),
202
- /* @__PURE__ */E(ge,{value:t.query,onChangeText:e=>t.setQuery(e.replace(/^\s+/,"")),style:a.searchInput,placeholder:bi.searchPlaceholder,placeholderTextColor:i.color.text.placeholder,accessibilityLabel:bi.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),
203
- /* @__PURE__ */E(Text,{tier:"compact",style:a.countLabel,children:wi(t.rows.length,S)}),t.error!==null&&!k?/* @__PURE__ */E(b,{style:a.errorCard,children:/* @__PURE__ */E(Text,{style:a.errorText,accessibilityRole:"alert",children:t.error})}):null,
204
- /* @__PURE__ */E(F,{data:w,keyExtractor:e=>e.id,renderItem:({item:r})=>/* @__PURE__ */E(Row,{row:r,active:r.id===e.conversationId,disabled:t.loading,styles:a,onPress:()=>{t.resume(r.id)}}),contentContainerStyle:w.length===0?a.listEmpty:a.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:R,ListFooterComponent:_,onEndReached:t.loadMore,onEndReachedThreshold:sf})]})})]})})}function Row({row:e,active:t,disabled:r,styles:n,onPress:l}){let i=e.unreadCount!==null&&e.unreadCount>0,o=vi(e);/* @__PURE__ */
205
- return O(PressScale,{accessibilityRole:"button",accessibilityLabel:ki(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:l,children:[
206
- /* @__PURE__ */O(b,{style:n.itemRow,children:[
207
- /* @__PURE__ */E(Text,{tier:"control",style:n.itemTitle,numberOfLines:1,children:yi(e.title)}),i?/* @__PURE__ */E(b,{style:n.unreadDot}):null]}),o!==null?/* @__PURE__ */E(Text,{tier:"compact",style:n.itemMeta,numberOfLines:1,children:o}):null]})}function cf(e){let t=e.color,r=e.space,n=e.type,l=e.slots,i=t.text.primary,o=Oo(l.card);return p.create({root:{flex:1},backdrop:{flex:1,backgroundColor:Qp},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.surface,paddingHorizontal:r.lg,borderRightWidth:p.hairlineWidth,borderRightColor:t.borderRingCream,gap:r.md,...Uc(l.dialog,p.hairlineWidth)},keyboardAvoider:{flex:1,gap:r.md},header:{flexDirection:"row",alignItems:"center",gap:r.sm},heading:{...headingFace(e,"bold"),flex:1,fontSize:n.size.subtitle,color:i,...Oo(l.dialog)},newChat:{minHeight:ef,justifyContent:"center",paddingHorizontal:r.xs},newChatLabel:{...face(e,"bold"),fontSize:Jp,color:t.brandInk},closeButton:{width:ef,height:ef,alignItems:"center",justifyContent:"center"},searchPill:{flexDirection:"row",alignItems:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,paddingHorizontal:r.md+af,paddingVertical:r.sm+af,borderWidth:1,borderColor:t.borderRingCream,...Lo(l.input,1)},searchInput:{...face(e,"regular"),flex:1,fontSize:n.size.bodyTight,color:t.text.primary,padding:0,...Oo(l.input)},countLabel:{...face(e,"mono"),fontSize:Xp,color:t.text.muted},list:{gap:r.xs,paddingBottom:r.xl},listEmpty:{flexGrow:1},item:{paddingVertical:r.sm+af,paddingHorizontal:r.sm,borderRadius:e.radius.md,gap:af},itemActive:{backgroundColor:Va(t.highlight,Zp)??t.surfaceSubtle},itemRow:{flexDirection:"row",alignItems:"center",gap:r.sm},itemTitle:{...face(e,"bold"),flex:1,fontSize:n.size.bodyTight,color:i},itemMeta:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.muted},unreadDot:{width:of,height:of,borderRadius:of/2,backgroundColor:t.danger},errorCard:{borderRadius:nf,borderWidth:p.hairlineWidth,borderColor:t.danger,backgroundColor:t.surface,padding:r.md},errorText:{...face(e,"regular"),fontSize:n.size.caption,color:t.danger},emptyCard:{borderRadius:rf,padding:r.md+af,gap:r.xs+af,backgroundColor:t.surfaceSubtle,borderWidth:p.hairlineWidth,borderColor:t.borderRingCream,...Lo(l.card,p.hairlineWidth)},emptyTitle:{...headingFace(e,"bold"),fontSize:n.size.bodyTight,color:i,...o},emptyBody:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.secondary,...o},noMatch:{...face(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+af,paddingVertical:r.sm,borderWidth:1,borderColor:t.brandInk,...Lo(l.primaryButton)},retryText:{...face(e,"bold"),fontSize:n.size.caption,color:t.brandInk,...Oo(l.primaryButton)},loadMoreFooter:{paddingVertical:r.md+af,alignItems:"center"},loadMoreLabel:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.muted}})}function pf(e,t=/* @__PURE__ */new Date,r){let n=new Date(e);if(Number.isNaN(n.getTime()))return null;let l=new Date(t);l.setHours(0,0,0,0);let i=new Date(n);i.setHours(0,0,0,0);let o=Math.round((l.getTime()-i.getTime())/864e5);if(o===0||o===1)try{let e=new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(-o,"day");return e.charAt(0).toLocaleUpperCase(r)+e.slice(1)}catch{}return n.toLocaleDateString(r,{month:"short",day:"numeric"})}function ff(e,t){let r=new Date(e);return Number.isNaN(r.getTime())?null:r.toLocaleTimeString(t,{hour:"numeric",minute:"2-digit"})}function hf(e,t=/* @__PURE__ */new Date){let r=[];for(let n of e){let e=pf(n.updatedAt,t)??"",l=r[r.length-1];l!==void 0&&l.day===e?l.rows.push(n):r.push({day:e,rows:[n]})}return r}var gf="rgba(38,37,35,0.38)",bf=28,yf=40,mf=5,vf=11,wf=10.5,kf=36,Cf=11,Sf=14,xf=15,Rf=13.5,_f=48,Tf=2,zf=1.3,If=.12,Pf=16,Ff=8,Lf="80%";function Ef(e,t,r){let n=e?.renderIcon;return n===void 0?r:/* @__PURE__ */E(HostRender,{render:()=>n(t),fallback:r})}function HistorySheet({chat:e,history:t,sheet:r}){let l=useEverfurTheme(),i=n(()=>Of(l),[l]),o=L(),a=n(()=>hf(t.rows),[t.rows]);if(!t.open)return null;let s=l.color,u=r?.title?.trim(),c=u!==void 0&&u!==""?u:bi.heading;/* @__PURE__ */
208
- return E(C,{visible:true,transparent:true,animationType:"slide",onRequestClose:t.close,children:/* @__PURE__ */O(b,{style:i.root,children:[
209
- /* @__PURE__ */E(v,{style:[Ka,i.scrim],onPress:t.close,accessibilityRole:"button",accessibilityLabel:bi.closeA11y}),
210
- /* @__PURE__ */O(b,{style:[i.sheet,{paddingBottom:Math.max(40,o.bottom+l.space.lg)}],accessibilityViewIsModal:true,testID:"everfur-history-sheet",children:[
211
- /* @__PURE__ */E(b,{style:i.grab}),
212
- /* @__PURE__ */O(b,{style:i.top,children:[
213
- /* @__PURE__ */E(Text,{tier:"compact",style:i.kicker,accessibilityRole:"header",children:c}),
214
- /* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:bi.closeA11y,onPress:t.close,style:i.close,children:Ef(r,"close",/* @__PURE__ */E(CloseGlyph,{size:22,color:s.text.primary,strokeWidth:2}))})]}),
215
- /* @__PURE__ */O(S,{style:i.scroll,contentContainerStyle:i.scrollContent,keyboardShouldPersistTaps:"handled",children:[t.loading&&t.rows.length===0?/* @__PURE__ */O(b,{style:i.state,accessibilityLabel:bi.loading,accessibilityState:{busy:true},children:[
216
- /* @__PURE__ */E(x,{color:s.brandInk}),
217
- /* @__PURE__ */E(Text,{tier:"compact",style:i.mono,children:bi.loading})]}):null,t.error!==null?/* @__PURE__ */O(b,{style:i.state,children:[
218
- /* @__PURE__ */E(Text,{style:i.stateText,accessibilityRole:"alert",children:bi.loadFailed}),
219
- /* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:bi.retry,onPress:()=>{t.load()},style:i.link,children:/* @__PURE__ */E(Text,{tier:"control",style:i.linkText,children:bi.retry})})]}):null,!t.loading&&t.error===null&&t.rows.length===0?/* @__PURE__ */E(Text,{style:[i.stateText,i.state],children:bi.empty}):null,a.map((n,l)=>/* @__PURE__ */O(d,{children:[n.day?/* @__PURE__ */E(Text,{tier:"compact",style:[i.mono,i.day,l===0?i.dayFirst:null],children:n.day}):null,n.rows.map(n=>{let l=n.id===e.conversationId,o=n.unreadCount!==null&&n.unreadCount>0,a=ff(n.updatedAt);/* @__PURE__ */
220
- return O(v,{accessibilityRole:"button",accessibilityLabel:ki(n),accessibilityState:{selected:l},onPress:()=>{t.resume(n.id)},style:[i.row,l?i.rowCurrent:null],children:[
221
- /* @__PURE__ */E(b,{style:i.icon,children:Ef(r,"chat",/* @__PURE__ */E(ChatBubbleGlyph,{size:19,color:s.linkInk,strokeWidth:1.75}))}),
222
- /* @__PURE__ */O(b,{style:i.rowWords,children:[
223
- /* @__PURE__ */E(Text,{tier:"control",style:i.rowTitle,numberOfLines:1,children:yi(n.title)}),n.preview!==void 0?/* @__PURE__ */E(Text,{tier:"compact",style:i.preview,numberOfLines:1,children:n.preview}):null]}),
224
- /* @__PURE__ */O(b,{style:i.rowEnd,children:[a!==null?/* @__PURE__ */E(Text,{tier:"compact",style:[i.mono,i.time,o?i.timeUnread:null],children:a}):null,o?/* @__PURE__ */E(b,{style:i.unreadDot,testID:`everfur-history-sheet-unread-${String(n.id)}`}):null]})]},String(n.id))})]},n.day)),t.cursor!==null&&!t.loadingMore?/* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:bi.more,onPress:t.loadMore,style:i.link,children:/* @__PURE__ */E(Text,{tier:"control",style:i.linkText,children:bi.more})}):null]}),
225
- /* @__PURE__ */O(v,{accessibilityRole:"button",accessibilityLabel:bi.newChat,onPress:t.newConversation,style:i.newChat,children:[Ef(r,"edit",/* @__PURE__ */E(EditGlyph,{size:18,color:l.slots.primaryButton?.textColor??s.onPrimary,strokeWidth:1.75})),
226
- /* @__PURE__ */E(Text,{tier:"control",style:i.newChatText,children:bi.newChat})]})]})]})})}function Of(e){let t=e.color,r=e.space,n={...face(e,"mono"),fontSize:wf,letterSpacing:wf*.06,textTransform:"uppercase",color:t.text.muted};return p.create({root:{flex:1,justifyContent:"flex-end"},scrim:{backgroundColor:gf},sheet:{maxHeight:Lf,backgroundColor:t.surface,borderTopLeftRadius:bf,borderTopRightRadius:bf,paddingTop:10,paddingHorizontal:20},grab:{width:yf,height:mf,borderRadius:3,backgroundColor:t.borderRingCream,alignSelf:"center",marginBottom:10},top:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},kicker:{...n,fontSize:vf,letterSpacing:vf*.08,flexShrink:1},close:{width:xs,height:xs,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:xs/2},scroll:{flexGrow:0},scrollContent:{paddingBottom:r.xs},mono:n,day:{marginTop:r.lg,marginBottom:r.xs},dayFirst:{marginTop:Tf},state:{marginVertical:r.md,gap:r.sm,alignItems:"flex-start"},stateText:{...face(e,"regular"),fontSize:e.type.size.body,color:t.text.primary},link:{minHeight:xs,justifyContent:"center"},linkText:{...face(e,"bold"),fontSize:e.type.size.body,color:t.brandInk},row:{flexDirection:"row",alignItems:"center",gap:r.md,paddingVertical:10,paddingHorizontal:r.sm,borderRadius:Sf,minHeight:xs},rowCurrent:{backgroundColor:t.surfaceSubtle},icon:{width:kf,height:kf,borderRadius:Cf,backgroundColor:Va(t.linkInk,If)??t.surfaceSubtle,alignItems:"center",justifyContent:"center"},rowWords:{flex:1,minWidth:0},rowTitle:{...face(e,"bold"),fontSize:xf,lineHeight:xf*zf,color:t.text.primary},preview:{...face(e,"regular"),fontSize:Rf,color:t.text.muted,marginTop:2},rowEnd:{alignSelf:"flex-start",alignItems:"flex-end",gap:6},time:{marginTop:3,letterSpacing:wf*.04,textTransform:"none"},timeUnread:{...face(e,"monoBold"),color:t.text.primary},unreadDot:{width:Ff,height:Ff,borderRadius:Ff/2,backgroundColor:t.danger},newChat:{marginTop:r.lg,minHeight:_f,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.primary,...Lo(e.slots.primaryButton)},newChatText:{...face(e,"bold"),fontSize:Pf,color:t.onPrimary,...Oo(e.slots.primaryButton)}})}var Af="Close",jf=/* @__PURE__ */Object.freeze({action:e=>e.possessive===null?null:`See ${e.possessive} Health Plan`,ask:"What does it mean?",askPrompt:(e,t)=>e.risk?.lead?`${e.risk.lead} ${t}`:`${e.title}: ${t}`,close:e=>e.possessive===null?null:`Close ${e.possessive} focus`,resultsKicker:e=>e.possessive===null?null:`${Df(e.possessive)} results`,resultsClose:e=>e.possessive===null?null:`Close ${e.possessive} results`,resultsTopRisk:"Top risk"});function Df(e){return e.charAt(0).toUpperCase()+e.slice(1)}function healthPlanPossessive(e){let t=typeof e.sex=="string"?e.sex.trim().toLowerCase():null;if(t==="female")return"her";if(t==="male")return"his";let r=typeof e.name=="string"?e.name.trim():"";return r!==""?`${r}'s`:null}function healthPlanTopCard(e,t={}){let r=e?.page?.focus;if(e===null||r===void 0||r.title.trim()===""||r.kicker.trim()==="")return;let n={...jf,...t.copy},l={pet:e.pet,possessive:healthPlanPossessive(e.pet)},i=r.sources?.find(e=>e.label.trim()!=="")?.label,o=t.onOpenPlan,a=o===void 0?null:n.action(l),s=n.close(l),u=n.ask.trim(),d=t.results!==void 0&&r.report!==void 0?t.results:void 0;if(d!==void 0){let e=n.resultsKicker(l)?.trim()||r.kicker,s=n.resultsClose(l),c=d.onTopRisk??o,p={key:"top-risk",label:n.resultsTopRisk,title:r.title,...r.risk?.lead?{line:r.risk.lead}:{},tone:"risk",...c===void 0?{}:{onPress:c}};return{kicker:e,...i===void 0?{}:{badge:i},title:r.title,results:[p,...d.rows??[]],...a===null||a.trim()===""||o===void 0?{}:{action:{label:a,onPress:o}},...u===""?{}:{ask:{label:u,prompt:n.askPrompt(r,u)}},closeLabel:s===null||s.trim()===""?Af:s,pill:e,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}return{kicker:r.kicker,...i===void 0?{}:{badge:i},title:r.title,...r.risk?.lead?{lead:r.risk.lead}:{},...r.risk?.body?{body:r.risk.body}:{},...a===null||a.trim()===""||o===void 0?{}:{action:{label:a,onPress:o}},...u===""?{}:{ask:{label:u,prompt:n.askPrompt(r,u)}},closeLabel:s===null||s.trim()===""?Af:s,pill:r.kicker,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}function Mf(e){let t=face(e,"medium");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"600"}}function Bf(e){let t=face(e,"bold");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"800"}}var Hf=20,Wf=14,Nf=16,Uf=18,$f=22,Vf=15,qf=12,Gf=24,Kf=15,Yf=14.5,Qf=21,Zf=14.5,Jf=18,Xf=9,eh=36,th=14,rh=15,nh=8,lh=40;function TopCard({card:e,open:t,onOpenChange:r,ask:l}){let i=useEverfurTheme(),o=Bp(),a=n(()=>o!==null?oh(o):ah(i),[i,o]),s=n(()=>Lo(i.slots.card),[i.slots.card]);if(!t)return null;let u=e.closeLabel===void 0?null:e.closeLabel.trim()!==""?e.closeLabel:Re.close,d=e.action,c=e.ask,p=/* @__PURE__ */E(CloseGlyph,{size:o!==null?HOME_CLOSE_GLYPH(o):Jf,color:o!==null?String(o.text(".ask-focus__x").color):i.color.text.primary,strokeWidth:2});/* @__PURE__ */
227
- return O(b,{style:[a.card,s],testID:"everfur-top-card",children:[
228
- /* @__PURE__ */O(b,{style:a.kickerRow,children:[
229
- /* @__PURE__ */E(Text,{tier:"control",style:a.kicker,children:e.kicker}),e.badge!==void 0?/* @__PURE__ */E(b,{style:a.badge,children:/* @__PURE__ */E(Text,{tier:"compact",style:a.badgeText,numberOfLines:1,children:e.badge})}):null,u!==null?/* @__PURE__ */E(v,{onPress:()=>r(false),accessibilityRole:"button",accessibilityLabel:u,style:a.close,hitSlop:o!==null?ih:void 0,testID:"everfur-top-card-close",children:e.renderIcon!==void 0?/* @__PURE__ */E(HostRender,{render:()=>e.renderIcon?.("close"),fallback:p}):p}):null]}),
230
- /* @__PURE__ */E(Text,{tier:"heading",style:a.title,accessibilityRole:"header",children:e.title}),e.lead!==void 0||e.body!==void 0?/* @__PURE__ */O(b,{style:a.finding,children:[
231
- /* @__PURE__ */E(b,{style:a.dot}),
232
- /* @__PURE__ */O(Text,{style:a.findingText,children:[e.lead!==void 0?/* @__PURE__ */E(Text,{style:a.lead,children:e.lead}):null,e.lead!==void 0&&e.body!==void 0?" ":null,e.body??null]})]}):null,d!==void 0||c!==void 0?/* @__PURE__ */O(b,{style:a.actions,children:[d!==void 0?/* @__PURE__ */E(v,{onPress:()=>{Lr(d.onPress)},accessibilityRole:"button",accessibilityLabel:d.label,style:a.action,hitSlop:o!==null?ih:void 0,children:/* @__PURE__ */E(Text,{tier:"control",style:a.actionText,children:d.label})}):null,c!==void 0?/* @__PURE__ */E(v,{onPress:()=>l(c.prompt),accessibilityRole:"button",accessibilityLabel:c.label,style:a.ask,hitSlop:o!==null?ih:void 0,children:/* @__PURE__ */E(Text,{tier:"control",style:a.askText,children:c.label})}):null]}):null]})}function TopCardPill({card:e,open:t,onOpenChange:r}){let l=useEverfurTheme(),i=Bp(),o=n(()=>i!==null?oh(i):ah(l),[l,i]);if(t||e.closeLabel===void 0)return null;let a=e.pill??e.kicker;/* @__PURE__ */
233
- return O(v,{onPress:()=>r(true),accessibilityRole:"button",accessibilityLabel:a,accessibilityState:{expanded:false},style:o.pill,hitSlop:i!==null?ih:void 0,testID:"everfur-top-card-pill",children:[
234
- /* @__PURE__ */E(b,{style:o.pillDot}),
235
- /* @__PURE__ */E(Text,{tier:"control",style:o.pillText,numberOfLines:1,children:a})]})}var ih=4,HOME_CLOSE_GLYPH=e=>{let t=e.icon(".ask-focus__x svg").width;return typeof t=="number"?t:Jf};function oh(e){let t=e.text(".hp-need__s",".ask-focus .hp-need__s"),r=typeof t.lineHeight=="number"?t.lineHeight:21,n=e.view(".dot",".dot--risk"),l=typeof n.height=="number"?n.height:Xf;return{card:e.view(".ask-focus"),kickerRow:e.view(".hp-need__k"),kicker:[e.text(".hp-need__k"),{flexShrink:1}],badge:[e.view(".hp-srcs"),e.view(".hp-src",".hp-src--dna"),{flexShrink:1}],badgeText:e.text(".hp-src",".hp-src--dna"),close:e.view(".ask-focus__x"),title:[e.view(".ask-focus h3"),e.text(".ask-focus h3")],finding:[e.view(".hp-need__s"),{alignItems:"flex-start"}],dot:[e.col(".hp-need__s",0),n,{marginTop:Math.round((r-l)/2)}],findingText:[e.col(".hp-need__s",1),t],lead:(({fontFamily:e,fontWeight:t,color:r})=>({fontFamily:e,fontWeight:t,color:r}))(e.strong(".hp-need__s b")),actions:e.view(".ask-focus__acts"),action:[e.view(".emb-btn",".emb-btn--sm"),{maxWidth:"100%"}],actionText:e.text(".emb-btn",".emb-btn--sm"),ask:[e.view(".ask-focus__q"),{justifyContent:"center",maxWidth:"100%"}],askText:e.text(".ask-focus__q"),pill:[e.view(".ask-focus-pill"),{maxWidth:"100%"}],pillDot:e.view(".ask-focus-pill i"),pillText:[e.text(".ask-focus-pill"),{flexShrink:1}]}}function ah(e){let t=e.color,r=e.space;return p.create({card:{paddingTop:Wf,paddingHorizontal:Nf,paddingBottom:Nf,borderRadius:Hf,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,alignSelf:"stretch"},kickerRow:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:xs-8},kicker:{...Bf(e),fontSize:Vf,color:t.text.primary,flexShrink:1},badge:{marginLeft:"auto",minHeight:Gf,justifyContent:"center",paddingHorizontal:9,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,flexShrink:1},badgeText:{...face(e,"bold"),fontSize:qf,color:t.text.secondary},close:{width:xs,height:xs,marginVertical:-4,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:xs/2},title:{...Bf(e),fontSize:Uf,lineHeight:$f,color:t.text.primary,marginTop:r.xs},finding:{flexDirection:"row",gap:r.sm,marginTop:r.xs+2},dot:{width:Xf,height:Xf,borderRadius:Xf/2,marginTop:7,backgroundColor:t.danger},findingText:{...face(e,"regular"),flex:1,fontSize:Yf,lineHeight:Qf,color:t.text.primary},lead:face(e,"bold"),actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.lg,marginTop:14},action:{minHeight:Math.max(lh,xs),paddingHorizontal:r.lg,borderRadius:e.radius.pill,backgroundColor:t.primary,alignItems:"center",justifyContent:"center",maxWidth:"100%"},actionText:{...face(e,"bold"),fontSize:Kf,color:t.onPrimary},ask:{minHeight:xs,justifyContent:"center",maxWidth:"100%"},askText:{...face(e,"bold"),fontSize:Zf,color:t.brandInk,textDecorationLine:"underline"},pill:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Math.max(eh,xs),paddingHorizontal:th,borderRadius:e.radius.pill,backgroundColor:t.badgeBgCritical,alignSelf:"flex-start",maxWidth:"100%"},pillDot:{width:nh,height:nh,borderRadius:nh/2,backgroundColor:t.danger},pillText:{...face(e,"bold"),fontSize:rh,color:t.danger,flexShrink:1}})}var sh=/* @__PURE__ */Object.freeze({ink:"#262523",ink2:"#4A4845",ink3:"#6B6863",paper:"#F8F7F4",card:"#FFFFFF",line:"#E7E6E2",tile:"#F2F1EE",shadow:"rgba(38, 37, 35, .07)",riskBg:"#FFE3E1",riskInk:"#B0231B",riskDot:"#E5372B",clearBg:"#E6F4D3",clearInk:"#2F6A12",clearDot:"#5FA82B",watchDot:"#E5A000"}),uh=/* @__PURE__ */new WeakMap;function dh(e){let t=uh.get(e);if(t!==void 0)return t;let r=e.color,n=e.brightness==="dark",l=n?{dark:n,ink:r.text.primary,ink2:r.text.secondary,ink3:r.text.muted,paper:r.background,card:r.surface,line:r.borderRingCream,tile:r.surfaceSubtle,shadow:r.shadow,riskBg:r.badgeBgCritical,riskInk:r.danger,riskDot:r.danger,clearBg:r.badgeBgPositive,clearInk:r.success,clearDot:r.success,watchDot:r.warningStrong}:{dark:n,...sh},i=(e,t)=>Ga(e,t,Ba(t),ch),o=(e,t)=>contrastRatio(e,t)>=ch?e:Ma(t,ch),a=[l.card,l.paper].map(e=>$a(r.brandSoft,e)??e),s={primary:r.primary,onPrimary:o(r.onPrimary,r.primary),accent:r.accent,onAccent:o(r.onAccent,r.accent),link:i(r.linkInk,[l.card,l.paper,l.tile]),badge:r.brandSoft,onBadge:i(r.brandInk,a)},u=/* @__PURE__ */Object.freeze({...l,...s});return uh.set(e,u),u}var ch=4.5;function ph(e,t){for(let r of t)if(contrastRatio(r,e)>=ch)return r;return Ma(e,ch)}function fh(e,t,r){let n=Va(e,t);return(n===null?null:$a(n,r))??r}function hh(e){let t=dh(e),r=e.color,n=t.card;return{ink:t.ink,ink2:t.ink2,ink3:t.ink3,paper:t.paper,tile:t.tile,line:t.line,card:n,onInk:t.dark?r.background:"#FFFFFF",primary:t.primary,onPrimary:t.onPrimary,accent:t.accent,onAccent:ph(t.accent,[t.ink,t.onAccent]),accent2:fh(t.accent,.75,n),accent4:fh(t.accent,.17,n),accentChip:fh(t.accent,.47,n),link:t.link,linkChip:fh(t.link,.2,n),riskDot:t.riskDot,riskChip:t.dark?r.badgeBgCritical:"#FFD8D6",clearBg:t.clearBg,clearInk:t.clearInk,clearChip:t.dark?r.badgeBgPositive:"#DDEFC4",byInk:r.brandInk}}var gh=/* @__PURE__ */new Set(["color","fontSize","fontWeight","fontStyle","lh","ls","family","textAlign","textTransform","textDecorationLine"]),bh=/* @__PURE__ */new Set(["dur","delay","stagger","ease","tint","k","cols","nowrap"]),yh=["paddingTop","paddingRight","paddingBottom","paddingLeft"],mh=17,vh=1.5,wh=400,kh=700;function Ch(e){return e<=450?"regular":e<=650?"medium":"bold"}function Sh(e){let t=Math.min(900,Math.max(100,Math.round(e/100)*100));return String(t)}function xh(e,t,r){if(t==="$mono"){let t=r<=450?"mono":r<=650?"monoMedium":"monoBold",n=face(e,t);return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:Sh(r)}}let n=t==="$serif"?headingFace(e,Ch(r)):face(e,Ch(r));return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:Sh(r)}}function Rh(e,t,r={}){let n=hh(e),l=e.brightness==="dark",i=e.motion.reducedMotion,o=e=>{if(typeof e=="string"&&e.startsWith("$")){let t=e.slice(1);return t.startsWith("n_")?l?n.line??e:`#${t.slice(2)}`:t==="sans"||t==="serif"||t==="mono"?e:n[t]??e}return Array.isArray(e)?e.map(e=>o(e)):e},a=/* @__PURE__ */new Map,s=e=>{let n=e.filter(e=>typeof e=="string"&&e!==""),l=n.join("|"),s=a.get(l);if(s!==void 0)return s;let u={},d=e=>{if(e!==void 0)for(let[t,r]of Object.entries(e))u[t]=o(r)};for(let e of n)d(t[e]),i&&d(r[e]);let c=/* @__PURE__ */Object.freeze(u);return a.set(l,c),c},u=/* @__PURE__ */new Map,d=(...e)=>{let t=e.filter(Boolean).join("|"),r=u.get(t);if(r!==void 0)return r;let n=s(e),l={};for(let[e,t]of Object.entries(n))gh.has(e)||bh.has(e)||e==="ring"||e==="edge"||e==="shadow"||e==="round"||e==="zIndex"&&typeof t=="number"&&t<0||t!==null&&(l[e]=t);if((typeof n.fontSize=="number"||n.flexDirection==="row")&&n.position!=="absolute"&&typeof n.height=="number"&&typeof n.width!="number"){let e=l.height;delete l.height,typeof l.minHeight!="number"&&(l.minHeight=e)}let i=n.ring;if(Array.isArray(i)){let[e,t]=i;l.borderWidth=e,l.borderColor=t;for(let t of yh){let r=l[t];typeof r=="number"&&(l[t]=Math.max(0,r-e))}}let o=n.edge;if(Array.isArray(o)){let[e,t]=o;l.borderBottomWidth=e,l.borderBottomColor=t}let a=n.shadow;if(Array.isArray(a)){let[e,t,r,n]=a;l.shadowColor=n,l.shadowOffset={width:e,height:t},l.shadowOpacity=1,l.shadowRadius=r/2}if(n.round===1){let e=typeof n.width=="number"?n.width:typeof n.height=="number"?n.height:999;l.borderRadius=e/2}let d=/* @__PURE__ */Object.freeze(l);return u.set(t,d),d},c=/* @__PURE__ */new Map,p=(t,r)=>{let l=`${t}|${r.filter(Boolean).join("|")}`,i=c.get(l);if(i!==void 0)return i;let o=s(r),a=typeof o.fontSize=="number"?o.fontSize:mh,u=typeof o.lh=="number"?o.lh:vh,d=typeof o.fontWeight=="string"?Number(o.fontWeight):t,p=typeof o.family=="string"?o.family:"$sans",f={...xh(e,p,d),fontSize:a,lineHeight:Math.round(a*u*100)/100,color:typeof o.color=="string"?o.color:n.ink};typeof o.ls=="number"&&(f.letterSpacing=Math.round(o.ls*a*100)/100);for(let e of["fontStyle","textAlign","textTransform","textDecorationLine"])typeof o[e]=="string"&&(f[e]=o[e]);let h=/* @__PURE__ */Object.freeze(f);return c.set(l,h),h};return{reduced:i,colors:n,view:d,text:(...e)=>p(wh,e),strong:(...e)=>p(kh,e),icon:(...e)=>{let t=s(e),r={tintColor:typeof t.color=="string"?t.color:n.ink};for(let e of["width","height","opacity"])typeof t[e]=="number"&&(r[e]=t[e]);return r},col:(e,t)=>{let r=s([e]).cols;if(!Array.isArray(r))return{};let n=r[Math.min(t,r.length-1)];if(typeof n=="number")return{width:n,flexShrink:0};let l=typeof n=="string"?Number.parseFloat(n):1;return{flex:Number.isFinite(l)?l:1,minWidth:0}},motion:(...e)=>{let t=s(e),r=t.ease;return{dur:typeof t.dur=="number"?t.dur:0,delay:typeof t.delay=="number"?t.delay:0,stagger:typeof t.stagger=="number"?t.stagger:0,ease:Array.isArray(r)&&r.length===4?r:null}},raw:(e,...t)=>s(t)[e]}}var _h={".serif":{family:"$serif",fontWeight:"800",ls:-.01},".emb-btn":{flexDirection:"row",alignItems:"center",justifyContent:"center",minHeight:48,paddingTop:0,paddingRight:22,paddingBottom:0,paddingLeft:22,borderRadius:999,backgroundColor:"$primary",color:"$onPrimary",fontWeight:"700",fontSize:16,textDecorationLine:"none",dur:160,ease:[.23,1,.32,1],gap:8},".emb-btn--sm":{minHeight:40,paddingTop:0,paddingRight:16,paddingBottom:0,paddingLeft:16,fontSize:15},".dot":{width:9,height:9,round:1,flexGrow:0,flexShrink:0},".dot--risk":{backgroundColor:"$riskDot"},".ask-chips":{flexDirection:"column",alignItems:"center",marginTop:22,gap:10},".chip":{paddingTop:10,paddingRight:16,paddingBottom:10,paddingLeft:16,borderRadius:999,fontSize:15,fontWeight:"600",lh:1.3,textAlign:"center",dur:160,ease:[.23,1,.32,1]},".ask-empty":{minHeight:"100%",flexDirection:"column",alignItems:"center",paddingTop:14,paddingRight:16,paddingBottom:22,paddingLeft:16,textAlign:"center"},".ask-empty h2":{fontSize:23,lh:1.12},".ask-start":{width:"100%",marginTop:"auto",marginRight:0,marginBottom:"auto",marginLeft:0,paddingTop:18,paddingRight:0,paddingBottom:18,paddingLeft:0,flexDirection:"column",alignItems:"center"},".ask-empty .ask-chips":{marginTop:14,alignSelf:"center",alignItems:"stretch",width:"100%",maxWidth:340},".hp-need__k":{flexDirection:"row",alignItems:"center",fontSize:15,fontWeight:"800",gap:8},".hp-srcs":{marginLeft:"auto",flexDirection:"row",gap:4},".hp-src":{height:24,paddingTop:0,paddingRight:9,paddingBottom:0,paddingLeft:9,borderRadius:999,backgroundColor:"$tile",color:"$ink2",fontSize:12,fontWeight:"700",flexDirection:"row",alignItems:"center",nowrap:1},".hp-src--dna":{backgroundColor:"$n_E0FDFF",color:"$link"},".hp-need__s":{alignItems:"baseline",marginTop:6,fontSize:15,lh:1.45,color:"$ink2",flexDirection:"row",cols:[9,"1fr"],gap:9},".hp-need__s b":{color:"$ink",fontWeight:"800"},".ask-focus":{width:"100%",paddingTop:14,paddingRight:16,paddingBottom:16,paddingLeft:16,borderRadius:20,backgroundColor:"$card",textAlign:"left",shadow:[0,1,3,"rgba(38, 37, 35, .07)"]},".ask-focus h3":{marginTop:10,fontSize:18,fontWeight:"800",lh:1.22},".ask-focus__x":{width:36,height:36,marginTop:-8,marginRight:-10,marginBottom:-8,marginLeft:-2,alignItems:"center",justifyContent:"center",round:1,color:"$ink2"},".ask-focus__x svg":{width:18,height:18},".ask-focus-pill":{marginLeft:"auto",flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:14,paddingBottom:0,paddingLeft:14,borderRadius:999,backgroundColor:"$n_FFE3E1",color:"$n_B0231B",fontSize:15,fontWeight:"800",gap:7},".ask-focus-pill i":{width:8,height:8,round:1,backgroundColor:"$riskDot"},".ask-focus .hp-need__s":{fontSize:14.5},".ask-focus__acts":{flexDirection:"row",flexWrap:"wrap",alignItems:"center",marginTop:12,rowGap:4,columnGap:16},".ask-focus__q":{minHeight:36,fontSize:14.5,fontWeight:"700",color:"$link",textDecorationLine:"underline"},".ask-top":{alignSelf:"stretch",flexDirection:"row",marginTop:-8,marginRight:0,marginBottom:6,marginLeft:0},".thread__hist":{flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:4,paddingBottom:0,paddingLeft:4,fontSize:15,fontWeight:"700",color:"$link",gap:6},".thread__hist svg":{width:18,height:18},".thread__count":{minWidth:22,height:20,paddingTop:0,paddingRight:6,paddingBottom:0,paddingLeft:6,borderRadius:999,backgroundColor:"$card",color:"$ink2",fontSize:12,fontWeight:"800",alignItems:"center",justifyContent:"center",ring:[1,"$line"]}},Th=16;var zh=4e3,Ih=.5;function Ph(e,t,r){let n=1,l=-1;for(let i of e)l<0?l=i:l+t+i<=r?l+=t+i:(n+=1,l=i);return n}function Fh(e,t,r){if(e.length===0)return r;let n=Ph(e,t,r),l=[];for(let n=0;n<e.length;n+=1){let i=0;for(let o=n;o<e.length;o+=1)i+=(o>n?t:0)+e[o],i<=r&&l.push(i)}l.sort((e,t)=>e-t);let i=Ih*e.length+1;for(let o of l)if(Ph(e,t,o)<=n)return Math.min(r,o+i);return r}function BalancedTitle({text:e,style:t,measureCh:r}){let o=n(()=>e.split(/\s+/).filter(e=>e!==""),[e]),a=p.flatten(t),s=[e,a.fontFamily,a.fontSize,a.fontWeight,a.letterSpacing].join("|"),u=l({key:"",ch:null,line:null,words:[]});u.current.key!==s&&(u.current={key:s,ch:null,line:null,words:o.map(()=>null)});let[d,c]=i(null),f=d!==null&&d.key===s?d.value:null,h=()=>{let e=u.current;if(e.ch===null||e.line===null||e.words.some(e=>e===null))return;let t=e.words,n=t.reduce((e,t)=>e+t,0),l=t.length>1?Math.max(0,(e.line-n)/(t.length-1)):0,i=Fh(t,l,(e.ch+Ih)*r);c(t=>t!==null&&t.key===e.key&&t.value===i?t:{key:e.key,value:i})},g=e=>t=>{u.current.key===s&&(e(u.current,t.nativeEvent.layout.width),h())};/* @__PURE__ */
236
- return O(b,{style:Lh.wrap,children:[
237
- /* @__PURE__ */E(Text,{tier:"heading",style:f===null?t:[t,{maxWidth:f}],accessibilityRole:"header",children:e}),
238
- /* @__PURE__ */E(b,{style:Lh.probeClip,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */O(b,{style:Lh.probeRow,children:[
189
+ /* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Ii.retry,containerStyle:a.retrySlot,style:a.retryButton,onPress:()=>{t.load()},children:/* @__PURE__ */E(Text,{tier:"control",style:a.retryText,children:Ii.retry})})]}):t.emptyKind==="empty"?/* @__PURE__ */O(y,{style:a.emptyCard,children:[
190
+ /* @__PURE__ */E(Text,{style:a.emptyTitle,children:Ii.empty}),
191
+ /* @__PURE__ */E(Text,{style:a.emptyBody,children:Ii.emptyBody})]}):
192
+ /* @__PURE__ */E(Text,{style:a.noMatch,children:Ii.noMatch}),T=!t.searching&&t.loadingMore?/* @__PURE__ */E(y,{style:a.loadMoreFooter,children:/* @__PURE__ */E(Text,{style:a.loadMoreLabel,children:Ii.loadingMore})}):null;/* @__PURE__ */
193
+ return E(S,{visible:true,transparent:true,animationType:"none",onRequestClose:t.close,children:/* @__PURE__ */O(y,{style:a.root,children:[
194
+ /* @__PURE__ */E(w,{style:as,onPress:t.close,accessibilityRole:"button",accessibilityLabel:Ii.closeA11y,children:/* @__PURE__ */E(P.View,{style:[a.backdrop,{opacity:g}]})}),
195
+ /* @__PURE__ */E(P.View,{style:[a.panel,{width:c,paddingTop:Math.max(uf,u.top+i.space.md),transform:[{translateX:b}]}],accessibilityViewIsModal:true,children:/* @__PURE__ */O(v,{style:a.keyboardAvoider,behavior:h.OS==="ios"?"padding":"height",children:[
196
+ /* @__PURE__ */O(y,{style:a.header,children:[
197
+ /* @__PURE__ */E(Text,{tier:"heading",style:a.heading,accessibilityRole:"header",children:Ii.heading}),
198
+ /* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:Ii.newChat,style:a.newChat,onPress:t.newConversation,children:/* @__PURE__ */E(Text,{tier:"control",style:a.newChatLabel,children:Ii.newChat})}),
199
+ /* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Ii.close,hitSlop:0,style:a.closeButton,onPress:t.close,children:/* @__PURE__ */E(CloseGlyph,{size:gf,color:i.color.text.muted,strokeWidth:1.75})})]}),
200
+ /* @__PURE__ */O(y,{style:a.searchPill,children:[
201
+ /* @__PURE__ */E(SearchGlyph,{size:mf,color:i.color.text.muted,strokeWidth:1.5}),
202
+ /* @__PURE__ */E(be,{value:t.query,onChangeText:e=>t.setQuery(e.replace(/^\s+/,"")),style:a.searchInput,placeholder:Ii.searchPlaceholder,placeholderTextColor:i.color.text.placeholder,accessibilityLabel:Ii.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),
203
+ /* @__PURE__ */E(Text,{tier:"compact",style:a.countLabel,children:Ei(t.rows.length,C)}),t.error!==null&&!k?/* @__PURE__ */E(y,{style:a.errorCard,children:/* @__PURE__ */E(Text,{style:a.errorText,accessibilityRole:"alert",children:t.error})}):null,
204
+ /* @__PURE__ */E(L,{data:m,keyExtractor:e=>e.id,renderItem:({item:r})=>/* @__PURE__ */E(Row,{row:r,active:r.id===e.conversationId,disabled:t.loading,styles:a,onPress:()=>{t.resume(r.id)}}),contentContainerStyle:m.length===0?a.listEmpty:a.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:x,ListFooterComponent:T,onEndReached:t.loadMore,onEndReachedThreshold:kf})]})})]})})}function Row({row:e,active:t,disabled:r,styles:n,onPress:l}){let i=e.unreadCount!==null&&e.unreadCount>0,o=Li(e);/* @__PURE__ */
205
+ return O(PressScale,{accessibilityRole:"button",accessibilityLabel:Oi(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:l,children:[
206
+ /* @__PURE__ */O(y,{style:n.itemRow,children:[
207
+ /* @__PURE__ */E(Text,{tier:"control",style:n.itemTitle,numberOfLines:1,children:Pi(e.title)}),i?/* @__PURE__ */E(y,{style:n.unreadDot}):null]}),o!==null?/* @__PURE__ */E(Text,{tier:"compact",style:n.itemMeta,numberOfLines:1,children:o}):null]})}function xf(e){let t=e.color,r=e.space,n=e.type,l=e.slots,i=t.text.primary,o=Go(l.card);return f.create({root:{flex:1},backdrop:{flex:1,backgroundColor:df},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.surface,paddingHorizontal:r.lg,borderRightWidth:f.hairlineWidth,borderRightColor:t.borderRingCream,gap:r.md,...rp(l.dialog,f.hairlineWidth)},keyboardAvoider:{flex:1,gap:r.md},header:{flexDirection:"row",alignItems:"center",gap:r.sm},heading:{...headingFace(e,"bold"),flex:1,fontSize:n.size.subtitle,color:i,...Go(l.dialog)},newChat:{minHeight:hf,justifyContent:"center",paddingHorizontal:r.xs},newChatLabel:{...face(e,"bold"),fontSize:pf,color:t.brandInk},closeButton:{width:hf,height:hf,alignItems:"center",justifyContent:"center"},searchPill:{flexDirection:"row",alignItems:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,paddingHorizontal:r.md+wf,paddingVertical:r.sm+wf,borderWidth:1,borderColor:t.borderRingCream,...Vo(l.input,1)},searchInput:{...face(e,"regular"),flex:1,fontSize:n.size.bodyTight,color:t.text.primary,padding:0,...Go(l.input)},countLabel:{...face(e,"mono"),fontSize:ff,color:t.text.muted},list:{gap:r.xs,paddingBottom:r.xl},listEmpty:{flexGrow:1},item:{paddingVertical:r.sm+wf,paddingHorizontal:r.sm,borderRadius:e.radius.md,gap:wf},itemActive:{backgroundColor:ls(t.highlight,cf)??t.surfaceSubtle},itemRow:{flexDirection:"row",alignItems:"center",gap:r.sm},itemTitle:{...face(e,"bold"),flex:1,fontSize:n.size.bodyTight,color:i},itemMeta:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.muted},unreadDot:{width:vf,height:vf,borderRadius:vf/2,backgroundColor:t.danger},errorCard:{borderRadius:yf,borderWidth:f.hairlineWidth,borderColor:t.danger,backgroundColor:t.surface,padding:r.md},errorText:{...face(e,"regular"),fontSize:n.size.caption,color:t.danger},emptyCard:{borderRadius:bf,padding:r.md+wf,gap:r.xs+wf,backgroundColor:t.surfaceSubtle,borderWidth:f.hairlineWidth,borderColor:t.borderRingCream,...Vo(l.card,f.hairlineWidth)},emptyTitle:{...headingFace(e,"bold"),fontSize:n.size.bodyTight,color:i,...o},emptyBody:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.secondary,...o},noMatch:{...face(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+wf,paddingVertical:r.sm,borderWidth:1,borderColor:t.brandInk,...Vo(l.primaryButton)},retryText:{...face(e,"bold"),fontSize:n.size.caption,color:t.brandInk,...Go(l.primaryButton)},loadMoreFooter:{paddingVertical:r.md+wf,alignItems:"center"},loadMoreLabel:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.muted}})}function Rf(e,t=/* @__PURE__ */new Date,r){let n=new Date(e);if(Number.isNaN(n.getTime()))return null;let l=new Date(t);l.setHours(0,0,0,0);let i=new Date(n);i.setHours(0,0,0,0);let o=Math.round((l.getTime()-i.getTime())/864e5);if(o===0||o===1)try{let e=new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(-o,"day");return e.charAt(0).toLocaleUpperCase(r)+e.slice(1)}catch{}return n.toLocaleDateString(r,{month:"short",day:"numeric"})}function Tf(e,t){let r=new Date(e);return Number.isNaN(r.getTime())?null:r.toLocaleTimeString(t,{hour:"numeric",minute:"2-digit"})}function _f(e,t=/* @__PURE__ */new Date){let r=[];for(let n of e){let e=Rf(n.updatedAt,t)??"",l=r[r.length-1];l!==void 0&&l.day===e?l.rows.push(n):r.push({day:e,rows:[n]})}return r}var zf="rgba(38,37,35,0.38)",If=28,Pf=40,Ff=5,Lf=11,Ef=10.5,Of=36,Af=11,jf=14,Df=15,Mf=13.5,Bf=48,Hf=2,Wf=1.3,Nf=.12,Uf=16,$f=8,Vf="80%";function qf(e,t,r){let n=e?.renderIcon;return n===void 0?r:/* @__PURE__ */E(HostRender,{render:()=>n(t),fallback:r})}function HistorySheet({chat:e,history:t,sheet:r}){let l=useEverfurTheme(),i=n(()=>Gf(l),[l]),o=j(),a=n(()=>_f(t.rows),[t.rows]),s=xe();if(!t.open)return null;let u=l.color,c=r?.title?.trim(),p=c!==void 0&&c!==""?c:Ii.heading;/* @__PURE__ */
208
+ return E(S,{visible:true,transparent:true,animationType:"slide",onRequestClose:t.close,children:/* @__PURE__ */O(y,{style:i.root,children:[
209
+ /* @__PURE__ */E(w,{style:[as,i.scrim],onPress:t.close,accessibilityRole:"button",accessibilityLabel:Ii.closeA11y}),
210
+ /* @__PURE__ */O(y,{style:Re([i.sheet,{paddingBottom:Math.max(40,o.bottom+l.space.lg)}],s),accessibilityViewIsModal:true,testID:"everfur-history-sheet",children:[
211
+ /* @__PURE__ */E(y,{style:i.grab}),
212
+ /* @__PURE__ */O(y,{style:i.top,children:[
213
+ /* @__PURE__ */E(Text,{tier:"compact",style:i.kicker,accessibilityRole:"header",children:p}),
214
+ /* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:Ii.closeA11y,onPress:t.close,style:i.close,children:qf(r,"close",/* @__PURE__ */E(CloseGlyph,{size:22,color:u.text.primary,strokeWidth:2}))})]}),
215
+ /* @__PURE__ */O(x,{style:i.scroll,contentContainerStyle:i.scrollContent,keyboardShouldPersistTaps:"handled",children:[t.loading&&t.rows.length===0?/* @__PURE__ */O(y,{style:i.state,accessibilityLabel:Ii.loading,accessibilityState:{busy:true},children:[
216
+ /* @__PURE__ */E(R,{color:u.brandInk}),
217
+ /* @__PURE__ */E(Text,{tier:"compact",style:i.mono,children:Ii.loading})]}):null,t.error!==null?/* @__PURE__ */O(y,{style:i.state,children:[
218
+ /* @__PURE__ */E(Text,{style:i.stateText,accessibilityRole:"alert",children:Ii.loadFailed}),
219
+ /* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:Ii.retry,onPress:()=>{t.load()},style:i.link,children:/* @__PURE__ */E(Text,{tier:"control",style:i.linkText,children:Ii.retry})})]}):null,!t.loading&&t.error===null&&t.rows.length===0?/* @__PURE__ */E(Text,{style:[i.stateText,i.state],children:Ii.empty}):null,a.map((n,l)=>/* @__PURE__ */O(d,{children:[n.day?/* @__PURE__ */E(Text,{tier:"compact",style:[i.mono,i.day,l===0?i.dayFirst:null],children:n.day}):null,n.rows.map(n=>{let l=n.id===e.conversationId,o=n.unreadCount!==null&&n.unreadCount>0,a=Tf(n.updatedAt);/* @__PURE__ */
220
+ return O(w,{accessibilityRole:"button",accessibilityLabel:Oi(n),accessibilityState:{selected:l},onPress:()=>{t.resume(n.id)},style:[i.row,l?i.rowCurrent:null],children:[
221
+ /* @__PURE__ */E(y,{style:i.icon,children:qf(r,"chat",/* @__PURE__ */E(ChatBubbleGlyph,{size:19,color:u.linkInk,strokeWidth:1.75}))}),
222
+ /* @__PURE__ */O(y,{style:i.rowWords,children:[
223
+ /* @__PURE__ */E(Text,{tier:"control",style:i.rowTitle,numberOfLines:1,children:Pi(n.title)}),n.preview!==void 0?/* @__PURE__ */E(Text,{tier:"compact",style:i.preview,numberOfLines:1,children:n.preview}):null]}),
224
+ /* @__PURE__ */O(y,{style:i.rowEnd,children:[a!==null?/* @__PURE__ */E(Text,{tier:"compact",style:[i.mono,i.time,o?i.timeUnread:null],children:a}):null,o?/* @__PURE__ */E(y,{style:i.unreadDot,testID:`everfur-history-sheet-unread-${String(n.id)}`}):null]})]},String(n.id))})]},n.day)),t.cursor!==null&&!t.loadingMore?/* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:Ii.more,onPress:t.loadMore,style:i.link,children:/* @__PURE__ */E(Text,{tier:"control",style:i.linkText,children:Ii.more})}):null]}),
225
+ /* @__PURE__ */O(w,{accessibilityRole:"button",accessibilityLabel:Ii.newChat,onPress:t.newConversation,style:i.newChat,children:[qf(r,"edit",/* @__PURE__ */E(EditGlyph,{size:18,color:l.slots.primaryButton?.textColor??u.onPrimary,strokeWidth:1.75})),
226
+ /* @__PURE__ */E(Text,{tier:"control",style:i.newChatText,children:Ii.newChat})]})]})]})})}function Gf(e){let t=e.color,r=e.space,n={...face(e,"mono"),fontSize:Ef,letterSpacing:Ef*.06,textTransform:"uppercase",color:t.text.muted};return f.create({root:{flex:1,justifyContent:"flex-end"},scrim:{backgroundColor:zf},sheet:{maxHeight:Vf,backgroundColor:t.surface,borderTopLeftRadius:If,borderTopRightRadius:If,paddingTop:10,paddingHorizontal:20},grab:{width:Pf,height:Ff,borderRadius:3,backgroundColor:t.borderRingCream,alignSelf:"center",marginBottom:10},top:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},kicker:{...n,fontSize:Lf,letterSpacing:Lf*.08,flexShrink:1},close:{width:Ds,height:Ds,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:Ds/2},scroll:{flexGrow:0},scrollContent:{paddingBottom:r.xs},mono:n,day:{marginTop:r.lg,marginBottom:r.xs},dayFirst:{marginTop:Hf},state:{marginVertical:r.md,gap:r.sm,alignItems:"flex-start"},stateText:{...face(e,"regular"),fontSize:e.type.size.body,color:t.text.primary},link:{minHeight:Ds,justifyContent:"center"},linkText:{...face(e,"bold"),fontSize:e.type.size.body,color:t.brandInk},row:{flexDirection:"row",alignItems:"center",gap:r.md,paddingVertical:10,paddingHorizontal:r.sm,borderRadius:jf,minHeight:Ds},rowCurrent:{backgroundColor:t.surfaceSubtle},icon:{width:Of,height:Of,borderRadius:Af,backgroundColor:ls(t.linkInk,Nf)??t.surfaceSubtle,alignItems:"center",justifyContent:"center"},rowWords:{flex:1,minWidth:0},rowTitle:{...face(e,"bold"),fontSize:Df,lineHeight:Df*Wf,color:t.text.primary},preview:{...face(e,"regular"),fontSize:Mf,color:t.text.muted,marginTop:2},rowEnd:{alignSelf:"flex-start",alignItems:"flex-end",gap:6},time:{marginTop:3,letterSpacing:Ef*.04,textTransform:"none"},timeUnread:{...face(e,"monoBold"),color:t.text.primary},unreadDot:{width:$f,height:$f,borderRadius:$f/2,backgroundColor:t.danger},newChat:{marginTop:r.lg,minHeight:Bf,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.primary,...Vo(e.slots.primaryButton)},newChatText:{...face(e,"bold"),fontSize:Uf,color:t.onPrimary,...Go(e.slots.primaryButton)}})}var Kf="Close",Yf=/* @__PURE__ */Object.freeze({action:e=>e.possessive===null?null:`See ${e.possessive} Health Plan`,ask:"What does it mean?",askPrompt:(e,t)=>e.risk?.lead?`${e.risk.lead} ${t}`:`${e.title}: ${t}`,close:e=>e.possessive===null?null:`Close ${e.possessive} focus`,resultsKicker:e=>e.possessive===null?null:`${Qf(e.possessive)} results`,resultsClose:e=>e.possessive===null?null:`Close ${e.possessive} results`,resultsTopRisk:"Top risk"});function Qf(e){return e.charAt(0).toUpperCase()+e.slice(1)}function healthPlanPossessive(e){let t=typeof e.sex=="string"?e.sex.trim().toLowerCase():null;if(t==="female")return"her";if(t==="male")return"his";let r=typeof e.name=="string"?e.name.trim():"";return r!==""?`${r}'s`:null}function healthPlanTopCard(e,t={}){let r=e?.page?.focus;if(e===null||r===void 0||r.title.trim()===""||r.kicker.trim()==="")return;let n={...Yf,...t.copy},l={pet:e.pet,possessive:healthPlanPossessive(e.pet)},i=r.sources?.find(e=>e.label.trim()!=="")?.label,o=t.onOpenPlan,a=o===void 0?null:n.action(l),s=n.close(l),u=n.ask.trim(),d=t.results!==void 0&&r.report!==void 0?t.results:void 0;if(d!==void 0){let e=n.resultsKicker(l)?.trim()||r.kicker,s=n.resultsClose(l),c=d.onTopRisk??o,p={key:"top-risk",label:n.resultsTopRisk,title:r.title,...r.risk?.lead?{line:r.risk.lead}:{},tone:"risk",...c===void 0?{}:{onPress:c}};return{kicker:e,...i===void 0?{}:{badge:i},title:r.title,results:[p,...d.rows??[]],...a===null||a.trim()===""||o===void 0?{}:{action:{label:a,onPress:o}},...u===""?{}:{ask:{label:u,prompt:n.askPrompt(r,u)}},closeLabel:s===null||s.trim()===""?Kf:s,pill:e,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}return{kicker:r.kicker,...i===void 0?{}:{badge:i},title:r.title,...r.risk?.lead?{lead:r.risk.lead}:{},...r.risk?.body?{body:r.risk.body}:{},...a===null||a.trim()===""||o===void 0?{}:{action:{label:a,onPress:o}},...u===""?{}:{ask:{label:u,prompt:n.askPrompt(r,u)}},closeLabel:s===null||s.trim()===""?Kf:s,pill:r.kicker,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}function Zf(e){let t=face(e,"medium");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"600"}}function Jf(e){let t=face(e,"bold");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"800"}}var Xf=20,eh=14,th=16,rh=18,nh=22,lh=15,ih=12,oh=24,ah=15,sh=14.5,uh=21,dh=14.5,ch=18,ph=9,fh=36,hh=14,gh=15,bh=8,yh=40;function TopCard({card:e,open:t,onOpenChange:r,ask:l}){let i=useEverfurTheme(),o=Jp(),a=n(()=>o!==null?vh(o):wh(i),[i,o]),s=n(()=>Vo(i.slots.card),[i.slots.card]);if(!t)return null;let u=e.closeLabel===void 0?null:e.closeLabel.trim()!==""?e.closeLabel:Me.close,d=e.action,c=e.ask,p=/* @__PURE__ */E(CloseGlyph,{size:o!==null?HOME_CLOSE_GLYPH(o):ch,color:o!==null?String(o.text(".ask-focus__x").color):i.color.text.primary,strokeWidth:2});/* @__PURE__ */
227
+ return O(y,{style:[a.card,s],testID:"everfur-top-card",children:[
228
+ /* @__PURE__ */O(y,{style:a.kickerRow,children:[
229
+ /* @__PURE__ */E(Text,{tier:"control",style:a.kicker,children:e.kicker}),e.badge!==void 0?/* @__PURE__ */E(y,{style:a.badge,children:/* @__PURE__ */E(Text,{tier:"compact",style:a.badgeText,numberOfLines:1,children:e.badge})}):null,u!==null?/* @__PURE__ */E(w,{onPress:()=>r(false),accessibilityRole:"button",accessibilityLabel:u,style:a.close,hitSlop:o!==null?mh:void 0,testID:"everfur-top-card-close",children:e.renderIcon!==void 0?/* @__PURE__ */E(HostRender,{render:()=>e.renderIcon?.("close"),fallback:p}):p}):null]}),
230
+ /* @__PURE__ */E(Text,{tier:"heading",style:a.title,accessibilityRole:"header",children:e.title}),e.lead!==void 0||e.body!==void 0?/* @__PURE__ */O(y,{style:a.finding,children:[
231
+ /* @__PURE__ */E(y,{style:a.dot}),
232
+ /* @__PURE__ */O(Text,{style:a.findingText,children:[e.lead!==void 0?/* @__PURE__ */E(Text,{style:a.lead,children:e.lead}):null,e.lead!==void 0&&e.body!==void 0?" ":null,e.body??null]})]}):null,d!==void 0||c!==void 0?/* @__PURE__ */O(y,{style:a.actions,children:[d!==void 0?/* @__PURE__ */E(w,{onPress:()=>{Vr(d.onPress)},accessibilityRole:"button",accessibilityLabel:d.label,style:a.action,hitSlop:o!==null?mh:void 0,children:/* @__PURE__ */E(Text,{tier:"control",style:a.actionText,children:d.label})}):null,c!==void 0?/* @__PURE__ */E(w,{onPress:()=>l(c.prompt),accessibilityRole:"button",accessibilityLabel:c.label,style:a.ask,hitSlop:o!==null?mh:void 0,children:/* @__PURE__ */E(Text,{tier:"control",style:a.askText,children:c.label})}):null]}):null]})}function TopCardPill({card:e,open:t,onOpenChange:r}){let l=useEverfurTheme(),i=Jp(),o=n(()=>i!==null?vh(i):wh(l),[l,i]);if(t||e.closeLabel===void 0)return null;let a=e.pill??e.kicker;/* @__PURE__ */
233
+ return O(w,{onPress:()=>r(true),accessibilityRole:"button",accessibilityLabel:a,accessibilityState:{expanded:false},style:o.pill,hitSlop:i!==null?mh:void 0,testID:"everfur-top-card-pill",children:[
234
+ /* @__PURE__ */E(y,{style:o.pillDot}),
235
+ /* @__PURE__ */E(Text,{tier:"control",style:o.pillText,numberOfLines:1,children:a})]})}var mh=4,HOME_CLOSE_GLYPH=e=>{let t=e.icon(".ask-focus__x svg").width;return typeof t=="number"?t:ch};function vh(e){let t=e.text(".hp-need__s",".ask-focus .hp-need__s"),r=typeof t.lineHeight=="number"?t.lineHeight:21,n=e.view(".dot",".dot--risk"),l=typeof n.height=="number"?n.height:ph;return{card:e.view(".ask-focus"),kickerRow:e.view(".hp-need__k"),kicker:[e.text(".hp-need__k"),{flexShrink:1}],badge:[e.view(".hp-srcs"),e.view(".hp-src",".hp-src--dna"),{flexShrink:1}],badgeText:e.text(".hp-src",".hp-src--dna"),close:e.view(".ask-focus__x"),title:[e.view(".ask-focus h3"),e.text(".ask-focus h3")],finding:[e.view(".hp-need__s"),{alignItems:"flex-start"}],dot:[e.col(".hp-need__s",0),n,{marginTop:Math.round((r-l)/2)}],findingText:[e.col(".hp-need__s",1),t],lead:(({fontFamily:e,fontWeight:t,color:r})=>({fontFamily:e,fontWeight:t,color:r}))(e.strong(".hp-need__s b")),actions:e.view(".ask-focus__acts"),action:[e.view(".emb-btn",".emb-btn--sm"),{maxWidth:"100%"}],actionText:e.text(".emb-btn",".emb-btn--sm"),ask:[e.view(".ask-focus__q"),{justifyContent:"center",maxWidth:"100%"}],askText:e.text(".ask-focus__q"),pill:[e.view(".ask-focus-pill"),{maxWidth:"100%"}],pillDot:e.view(".ask-focus-pill i"),pillText:[e.text(".ask-focus-pill"),{flexShrink:1}]}}function wh(e){let t=e.color,r=e.space;return f.create({card:{paddingTop:eh,paddingHorizontal:th,paddingBottom:th,borderRadius:Xf,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,alignSelf:"stretch"},kickerRow:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Ds-8},kicker:{...Jf(e),fontSize:lh,color:t.text.primary,flexShrink:1},badge:{marginLeft:"auto",minHeight:oh,justifyContent:"center",paddingHorizontal:9,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,flexShrink:1},badgeText:{...face(e,"bold"),fontSize:ih,color:t.text.secondary},close:{width:Ds,height:Ds,marginVertical:-4,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:Ds/2},title:{...Jf(e),fontSize:rh,lineHeight:nh,color:t.text.primary,marginTop:r.xs},finding:{flexDirection:"row",gap:r.sm,marginTop:r.xs+2},dot:{width:ph,height:ph,borderRadius:ph/2,marginTop:7,backgroundColor:t.danger},findingText:{...face(e,"regular"),flex:1,fontSize:sh,lineHeight:uh,color:t.text.primary},lead:face(e,"bold"),actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.lg,marginTop:14},action:{minHeight:Math.max(yh,Ds),paddingHorizontal:r.lg,borderRadius:e.radius.pill,backgroundColor:t.primary,alignItems:"center",justifyContent:"center",maxWidth:"100%"},actionText:{...face(e,"bold"),fontSize:ah,color:t.onPrimary},ask:{minHeight:Ds,justifyContent:"center",maxWidth:"100%"},askText:{...face(e,"bold"),fontSize:dh,color:t.brandInk,textDecorationLine:"underline"},pill:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Math.max(fh,Ds),paddingHorizontal:hh,borderRadius:e.radius.pill,backgroundColor:t.badgeBgCritical,alignSelf:"flex-start",maxWidth:"100%"},pillDot:{width:bh,height:bh,borderRadius:bh/2,backgroundColor:t.danger},pillText:{...face(e,"bold"),fontSize:gh,color:t.danger,flexShrink:1}})}var kh=/* @__PURE__ */Object.freeze({ink:"#262523",ink2:"#4A4845",ink3:"#6B6863",paper:"#F8F7F4",card:"#FFFFFF",line:"#E7E6E2",tile:"#F2F1EE",shadow:"rgba(38, 37, 35, .07)",riskBg:"#FFE3E1",riskInk:"#B0231B",riskDot:"#E5372B",clearBg:"#E6F4D3",clearInk:"#2F6A12",clearDot:"#5FA82B",watchDot:"#E5A000"}),Ch=/* @__PURE__ */new WeakMap;function Sh(e){let t=Ch.get(e);if(t!==void 0)return t;let r=e.color,n=e.brightness==="dark",l=n?{dark:n,ink:r.text.primary,ink2:r.text.secondary,ink3:r.text.muted,paper:r.background,card:r.surface,line:r.borderRingCream,tile:r.surfaceSubtle,shadow:r.shadow,riskBg:r.badgeBgCritical,riskInk:r.danger,riskDot:r.danger,clearBg:r.badgeBgPositive,clearInk:r.success,clearDot:r.success,watchDot:r.warningStrong}:{dark:n,...kh},i=(e,t)=>os(e,t,Ja(t),xh),o=(e,t)=>contrastRatio(e,t)>=xh?e:Za(t,xh),a=[l.card,l.paper].map(e=>ns(r.brandSoft,e)??e),s={primary:r.primary,onPrimary:o(r.onPrimary,r.primary),accent:r.accent,onAccent:o(r.onAccent,r.accent),link:i(r.linkInk,[l.card,l.paper,l.tile]),badge:r.brandSoft,onBadge:i(r.brandInk,a)},u=/* @__PURE__ */Object.freeze({...l,...s});return Ch.set(e,u),u}var xh=4.5;function Rh(e,t){for(let r of t)if(contrastRatio(r,e)>=xh)return r;return Za(e,xh)}function Th(e,t,r){let n=ls(e,t);return(n===null?null:ns(n,r))??r}function _h(e){let t=Sh(e),r=e.color,n=t.card;return{ink:t.ink,ink2:t.ink2,ink3:t.ink3,paper:t.paper,tile:t.tile,line:t.line,card:n,onInk:t.dark?r.background:"#FFFFFF",primary:t.primary,onPrimary:t.onPrimary,accent:t.accent,onAccent:Rh(t.accent,[t.ink,t.onAccent]),accent2:Th(t.accent,.75,n),accent4:Th(t.accent,.17,n),accentChip:Th(t.accent,.47,n),link:t.link,linkChip:Th(t.link,.2,n),riskDot:t.riskDot,riskChip:t.dark?r.badgeBgCritical:"#FFD8D6",clearBg:t.clearBg,clearInk:t.clearInk,clearChip:t.dark?r.badgeBgPositive:"#DDEFC4",byInk:r.brandInk}}var zh=/* @__PURE__ */new Set(["color","fontSize","fontWeight","fontStyle","lh","ls","family","textAlign","textTransform","textDecorationLine"]),Ih=/* @__PURE__ */new Set(["dur","delay","stagger","ease","tint","k","cols","nowrap"]),Ph=["paddingTop","paddingRight","paddingBottom","paddingLeft"],Fh=17,Lh=1.5,Eh=400,Oh=700;function Ah(e){return e<=450?"regular":e<=650?"medium":"bold"}function jh(e){let t=Math.min(900,Math.max(100,Math.round(e/100)*100));return String(t)}function Dh(e,t,r){if(t==="$mono"){let t=r<=450?"mono":r<=650?"monoMedium":"monoBold",n=face(e,t);return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:jh(r)}}let n=t==="$serif"?headingFace(e,Ah(r)):face(e,Ah(r));return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:jh(r)}}function Mh(e,t,r={}){let n=_h(e),l=e.brightness==="dark",i=e.motion.reducedMotion,o=e=>{if(typeof e=="string"&&e.startsWith("$")){let t=e.slice(1);return t.startsWith("n_")?l?n.line??e:`#${t.slice(2)}`:t==="sans"||t==="serif"||t==="mono"?e:n[t]??e}return Array.isArray(e)?e.map(e=>o(e)):e},a=/* @__PURE__ */new Map,s=e=>{let n=e.filter(e=>typeof e=="string"&&e!==""),l=n.join("|"),s=a.get(l);if(s!==void 0)return s;let u={},d=e=>{if(e!==void 0)for(let[t,r]of Object.entries(e))u[t]=o(r)};for(let e of n)d(t[e]),i&&d(r[e]);let c=/* @__PURE__ */Object.freeze(u);return a.set(l,c),c},u=/* @__PURE__ */new Map,d=(...e)=>{let t=e.filter(Boolean).join("|"),r=u.get(t);if(r!==void 0)return r;let n=s(e),l={};for(let[e,t]of Object.entries(n))zh.has(e)||Ih.has(e)||e==="ring"||e==="edge"||e==="shadow"||e==="round"||e==="zIndex"&&typeof t=="number"&&t<0||t!==null&&(l[e]=t);if((typeof n.fontSize=="number"||n.flexDirection==="row")&&n.position!=="absolute"&&typeof n.height=="number"&&typeof n.width!="number"){let e=l.height;delete l.height,typeof l.minHeight!="number"&&(l.minHeight=e)}let i=n.ring;if(Array.isArray(i)){let[e,t]=i;l.borderWidth=e,l.borderColor=t;for(let t of Ph){let r=l[t];typeof r=="number"&&(l[t]=Math.max(0,r-e))}}let o=n.edge;if(Array.isArray(o)){let[e,t]=o;l.borderBottomWidth=e,l.borderBottomColor=t}let a=n.shadow;if(Array.isArray(a)){let[e,t,r,n]=a;l.shadowColor=n,l.shadowOffset={width:e,height:t},l.shadowOpacity=1,l.shadowRadius=r/2}if(n.round===1){let e=typeof n.width=="number"?n.width:typeof n.height=="number"?n.height:999;l.borderRadius=e/2}let d=/* @__PURE__ */Object.freeze(l);return u.set(t,d),d},c=/* @__PURE__ */new Map,p=(t,r)=>{let l=`${t}|${r.filter(Boolean).join("|")}`,i=c.get(l);if(i!==void 0)return i;let o=s(r),a=typeof o.fontSize=="number"?o.fontSize:Fh,u=typeof o.lh=="number"?o.lh:Lh,d=typeof o.fontWeight=="string"?Number(o.fontWeight):t,p=typeof o.family=="string"?o.family:"$sans",f={...Dh(e,p,d),fontSize:a,lineHeight:Math.round(a*u*100)/100,color:typeof o.color=="string"?o.color:n.ink};typeof o.ls=="number"&&(f.letterSpacing=Math.round(o.ls*a*100)/100);for(let e of["fontStyle","textAlign","textTransform","textDecorationLine"])typeof o[e]=="string"&&(f[e]=o[e]);let h=/* @__PURE__ */Object.freeze(f);return c.set(l,h),h};return{reduced:i,colors:n,view:d,text:(...e)=>p(Eh,e),strong:(...e)=>p(Oh,e),icon:(...e)=>{let t=s(e),r={tintColor:typeof t.color=="string"?t.color:n.ink};for(let e of["width","height","opacity"])typeof t[e]=="number"&&(r[e]=t[e]);return r},col:(e,t)=>{let r=s([e]).cols;if(!Array.isArray(r))return{};let n=r[Math.min(t,r.length-1)];if(typeof n=="number")return{width:n,flexShrink:0};let l=typeof n=="string"?Number.parseFloat(n):1;return{flex:Number.isFinite(l)?l:1,minWidth:0}},motion:(...e)=>{let t=s(e),r=t.ease;return{dur:typeof t.dur=="number"?t.dur:0,delay:typeof t.delay=="number"?t.delay:0,stagger:typeof t.stagger=="number"?t.stagger:0,ease:Array.isArray(r)&&r.length===4?r:null}},raw:(e,...t)=>s(t)[e]}}var Bh={".serif":{family:"$serif",fontWeight:"800",ls:-.01},".emb-btn":{flexDirection:"row",alignItems:"center",justifyContent:"center",minHeight:48,paddingTop:0,paddingRight:22,paddingBottom:0,paddingLeft:22,borderRadius:999,backgroundColor:"$primary",color:"$onPrimary",fontWeight:"700",fontSize:16,textDecorationLine:"none",dur:160,ease:[.23,1,.32,1],gap:8},".emb-btn--sm":{minHeight:40,paddingTop:0,paddingRight:16,paddingBottom:0,paddingLeft:16,fontSize:15},".dot":{width:9,height:9,round:1,flexGrow:0,flexShrink:0},".dot--risk":{backgroundColor:"$riskDot"},".ask-chips":{flexDirection:"column",alignItems:"center",marginTop:22,gap:10},".chip":{paddingTop:10,paddingRight:16,paddingBottom:10,paddingLeft:16,borderRadius:999,fontSize:15,fontWeight:"600",lh:1.3,textAlign:"center",dur:160,ease:[.23,1,.32,1]},".ask-empty":{minHeight:"100%",flexDirection:"column",alignItems:"center",paddingTop:14,paddingRight:16,paddingBottom:22,paddingLeft:16,textAlign:"center"},".ask-empty h2":{fontSize:23,lh:1.12},".ask-start":{width:"100%",marginTop:"auto",marginRight:0,marginBottom:"auto",marginLeft:0,paddingTop:18,paddingRight:0,paddingBottom:18,paddingLeft:0,flexDirection:"column",alignItems:"center"},".ask-empty .ask-chips":{marginTop:14,alignSelf:"center",alignItems:"stretch",width:"100%",maxWidth:340},".hp-need__k":{flexDirection:"row",alignItems:"center",fontSize:15,fontWeight:"800",gap:8},".hp-srcs":{marginLeft:"auto",flexDirection:"row",gap:4},".hp-src":{height:24,paddingTop:0,paddingRight:9,paddingBottom:0,paddingLeft:9,borderRadius:999,backgroundColor:"$tile",color:"$ink2",fontSize:12,fontWeight:"700",flexDirection:"row",alignItems:"center",nowrap:1},".hp-src--dna":{backgroundColor:"$n_E0FDFF",color:"$link"},".hp-need__s":{alignItems:"baseline",marginTop:6,fontSize:15,lh:1.45,color:"$ink2",flexDirection:"row",cols:[9,"1fr"],gap:9},".hp-need__s b":{color:"$ink",fontWeight:"800"},".ask-focus":{width:"100%",paddingTop:14,paddingRight:16,paddingBottom:16,paddingLeft:16,borderRadius:20,backgroundColor:"$card",textAlign:"left",shadow:[0,1,3,"rgba(38, 37, 35, .07)"]},".ask-focus h3":{marginTop:10,fontSize:18,fontWeight:"800",lh:1.22},".ask-focus__x":{width:36,height:36,marginTop:-8,marginRight:-10,marginBottom:-8,marginLeft:-2,alignItems:"center",justifyContent:"center",round:1,color:"$ink2"},".ask-focus__x svg":{width:18,height:18},".ask-focus-pill":{marginLeft:"auto",flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:14,paddingBottom:0,paddingLeft:14,borderRadius:999,backgroundColor:"$n_FFE3E1",color:"$n_B0231B",fontSize:15,fontWeight:"800",gap:7},".ask-focus-pill i":{width:8,height:8,round:1,backgroundColor:"$riskDot"},".ask-focus .hp-need__s":{fontSize:14.5},".ask-focus__acts":{flexDirection:"row",flexWrap:"wrap",alignItems:"center",marginTop:12,rowGap:4,columnGap:16},".ask-focus__q":{minHeight:36,fontSize:14.5,fontWeight:"700",color:"$link",textDecorationLine:"underline"},".ask-top":{alignSelf:"stretch",flexDirection:"row",marginTop:-8,marginRight:0,marginBottom:6,marginLeft:0},".thread__hist":{flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:4,paddingBottom:0,paddingLeft:4,fontSize:15,fontWeight:"700",color:"$link",gap:6},".thread__hist svg":{width:18,height:18},".thread__count":{minWidth:22,height:20,paddingTop:0,paddingRight:6,paddingBottom:0,paddingLeft:6,borderRadius:999,backgroundColor:"$card",color:"$ink2",fontSize:12,fontWeight:"800",alignItems:"center",justifyContent:"center",ring:[1,"$line"]}},Hh=16;var Wh=4e3,Nh=.5;function Uh(e,t,r){let n=1,l=-1;for(let i of e)l<0?l=i:l+t+i<=r?l+=t+i:(n+=1,l=i);return n}function $h(e,t,r){if(e.length===0)return r;let n=Uh(e,t,r),l=[];for(let n=0;n<e.length;n+=1){let i=0;for(let o=n;o<e.length;o+=1)i+=(o>n?t:0)+e[o],i<=r&&l.push(i)}l.sort((e,t)=>e-t);let i=Nh*e.length+1;for(let o of l)if(Uh(e,t,o)<=n)return Math.min(r,o+i);return r}function BalancedTitle({text:e,style:t,measureCh:r}){let o=n(()=>e.split(/\s+/).filter(e=>e!==""),[e]),a=f.flatten(t),s=[e,a.fontFamily,a.fontSize,a.fontWeight,a.letterSpacing].join("|"),u=l({key:"",ch:null,line:null,words:[]});u.current.key!==s&&(u.current={key:s,ch:null,line:null,words:o.map(()=>null)});let[d,c]=i(null),p=d!==null&&d.key===s?d.value:null,h=()=>{let e=u.current;if(e.ch===null||e.line===null||e.words.some(e=>e===null))return;let t=e.words,n=t.reduce((e,t)=>e+t,0),l=t.length>1?Math.max(0,(e.line-n)/(t.length-1)):0,i=$h(t,l,(e.ch+Nh)*r);c(t=>t!==null&&t.key===e.key&&t.value===i?t:{key:e.key,value:i})},g=e=>t=>{u.current.key===s&&(e(u.current,t.nativeEvent.layout.width),h())};/* @__PURE__ */
236
+ return O(y,{style:Vh.wrap,children:[
237
+ /* @__PURE__ */E(Text,{tier:"heading",style:p===null?t:[t,{maxWidth:p}],accessibilityRole:"header",children:e}),
238
+ /* @__PURE__ */E(y,{style:Vh.probeClip,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */O(y,{style:Vh.probeRow,children:[
239
239
  /* @__PURE__ */E(Text,{tier:"heading",style:t,onLayout:g((e,t)=>{e.ch=t}),children:"0"}),
240
- /* @__PURE__ */E(Text,{tier:"heading",style:t,onLayout:g((e,t)=>{e.line=t}),children:o.join(" ")}),o.map((e,r)=>/* @__PURE__ */E(Text,{tier:"heading",style:t,onLayout:g((e,t)=>{e.words[r]=t}),children:e},`${r}:${e}`))]})})]})}var Lh=p.create({wrap:{alignSelf:"stretch",alignItems:"center"},probeClip:{position:"absolute",left:0,top:0,width:0,height:0,overflow:"hidden",opacity:0},probeRow:{width:zh,flexDirection:"row",alignItems:"flex-start"}});function Eh(e){return{kit:Rh(e,_h),Title:BalancedTitle,titleCh:Th}}var Oh=/* @__PURE__ */Symbol.for("everfur.sdk.rn.poweredBy");function Ah(){let e=globalThis,t=e[Oh];if(t!==void 0)return t;let r={count:0,listeners:/* @__PURE__ */new Set};return e[Oh]=r,r}var jh=e=>{let t=Ah();return t.listeners.add(e),()=>t.listeners.delete(e)},Dh=()=>Ah().count>0;function useHostPoweredBy(){return a(jh,Dh,Dh)}function EverfurPoweredBy({children:e,style:t}){let r=useEverfurTheme().meta.hidePoweredBy;return o(()=>{if(r)return;let e=Ah();return e.count+=1,e.listeners.forEach(e=>e()),()=>{e.count-=1,e.listeners.forEach(e=>e())}},[r]),r?null:e??/* @__PURE__ */E(Text,{tier:"compact",style:t,accessibilityRole:"text",children:Re.poweredBy})}var Mh=/* @__PURE__ */Object.freeze({}),Bh=100,Hh=20;function Wh(e,t,r,n){return![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}function Nh(e,t){let a=typeof e=="number"&&Number.isFinite(e),s=l(null),[u,d]=i(null),c=l(null),p=l(null),f=l(true),h=r(()=>{p.current!==null&&clearTimeout(p.current),p.current=null},[]);o(()=>(f.current=true,()=>{f.current=false,h()}),[h]);let g=r(function e(t){s.current?.measureInWindow((r,n)=>{let l=c.current;if(!f.current||l===null)return;let i=Wh(n,l.y,l.height,w.get("window").height);if(i!==null){d(e=>e!==null&&e.chatTop===i.chatTop&&e.parentTop===i.parentTop?e:i);return}t>=Hh||(p.current=setTimeout(()=>{p.current=null,e(t+1)},Bh))})},[]),b=r(e=>{let{y:t,height:r}=e.nativeEvent.layout;c.current={y:t,height:r},h(),g(0)},[g,h]);return n(()=>{if(!t)return{avoidingProps:a?{keyboardVerticalOffset:e}:Mh,probeRef:null,topInWindow:null};let r=u?.parentTop??0;return{avoidingProps:a?{keyboardVerticalOffset:e,onLayout:b}:r>0?{keyboardVerticalOffset:r,onLayout:b}:{onLayout:b},probeRef:s,topInWindow:u?.chatTop??null}},[t,a,e,u,b])}function KeyboardOffsetProbe({probeRef:e}){return e===null?null:/* @__PURE__ */E(b,{ref:e,collapsable:false,pointerEvents:"none",style:Uh})}var Uh=/* @__PURE__ */Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function $h(){let[e,t]=i(false);return o(()=>{let e=k;if(typeof e?.addListener!="function")return;let r=f.OS==="ios",n=e.addListener(r?"keyboardWillShow":"keyboardDidShow",()=>t(true)),l=e.addListener(r?"keyboardWillHide":"keyboardDidHide",()=>t(false));return()=>{n.remove(),l.remove()}},[]),e}var Vh=4.5;var qh=3;function Gh(e,t,r){return Ga(e,t,Ba(t),r)}function Kh(e,t){if(e.level==="emergency")return e;let r=e.level==="schedule_soon",n=Fc(t),l=r?n.warning:n.info,i=Pc(t)&&!l?e:Yh(e,t,r);return Qh(i,t.slots.banner)}function Yh(e,t,r){let n=t.color,l=$a(r?n.badgeBgCaution:n.badgeBgInfo,n.surface)??n.surface,i=r?n.cautionAccent:n.infoEdge,o=Gh($a(i,n.surface)??i,[n.surface,n.chatGround],qh),a=Gh(r?n.warningStrong:n.info,[l,n.surface],Vh);/* @__PURE__ */
241
- return Object.freeze({...e,borderColor:o,backgroundColor:l,textColor:a,reasonColor:Gh(n.text.primary,[l],Vh),pillColor:n.surface})}function Qh(e,t){if(t===void 0)return e;let r={...e};return t.backgroundColor!==void 0&&(r.backgroundColor=t.backgroundColor),t.borderColor!==void 0&&(r.borderColor=t.borderColor),t.textColor!==void 0&&(r.textColor=t.textColor,r.reasonColor=t.textColor),/* @__PURE__ */Object.freeze(r)}function Zh(petRef,e){let t={entry:"chat",petRef:petRef};return e?.returnTo!==void 0&&(t.returnTo=e.returnTo),e?.usState!==void 0&&(t.usState=e.usState),e?.prefer!==void 0&&(t.prefer=e.prefer),t}var Jh=.75,Xh=1.5,eg=.4,tg=4,rg=1.5,ng=22,lg=14,ig=8,og=20,ag=10,sg=13,ug=12,dg=15,cg=44,pg=14,fg=1.25,hg=14,gg=6,bg=2;function yg(e,t){let r=e.color;if(t.level==="emergency")return{card:{backgroundColor:r.badgeBgCritical,borderColor:Va(r.danger,eg)??r.danger,borderWidth:Xh},label:r.danger,reason:r.text.primary,close:r.danger,action:{fill:r.surface,edge:r.danger,ink:r.danger}};let n=e.slots.banner?.borderRadius;return{card:{backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:Jh,...n===void 0?{}:{borderRadius:n}},label:t.textColor,reason:t.reasonColor,close:t.textColor,action:null}}function UrgencyBanner({surface:e,petRef:petRef,renderVetAction:t,onFindVet:r,vet:l,compact:i=false}){let o=useEverfurTheme(),a=n(()=>mg(o),[o]),s=no(),u=e.tier===null?null:Kh(e.tier,o),d=e.source;/* @__PURE__ */
240
+ /* @__PURE__ */E(Text,{tier:"heading",style:t,onLayout:g((e,t)=>{e.line=t}),children:o.join(" ")}),o.map((e,r)=>/* @__PURE__ */E(Text,{tier:"heading",style:t,onLayout:g((e,t)=>{e.words[r]=t}),children:e},`${r}:${e}`))]})})]})}var Vh=f.create({wrap:{alignSelf:"stretch",alignItems:"center"},probeClip:{position:"absolute",left:0,top:0,width:0,height:0,overflow:"hidden",opacity:0},probeRow:{width:Wh,flexDirection:"row",alignItems:"flex-start"}});function qh(e){return{kit:Mh(e,Bh),Title:BalancedTitle,titleCh:Hh}}var Gh=/* @__PURE__ */Symbol.for("everfur.sdk.rn.poweredBy");function Kh(){let e=globalThis,t=e[Gh];if(t!==void 0)return t;let r={count:0,listeners:/* @__PURE__ */new Set};return e[Gh]=r,r}var Yh=e=>{let t=Kh();return t.listeners.add(e),()=>t.listeners.delete(e)},Qh=()=>Kh().count>0;function useHostPoweredBy(){return a(Yh,Qh,Qh)}function EverfurPoweredBy({children:e,style:t}){let r=useEverfurTheme().meta.hidePoweredBy;return o(()=>{if(r)return;let e=Kh();return e.count+=1,e.listeners.forEach(e=>e()),()=>{e.count-=1,e.listeners.forEach(e=>e())}},[r]),r?null:e??/* @__PURE__ */E(Text,{tier:"compact",style:t,accessibilityRole:"text",children:Me.poweredBy})}var Zh=/* @__PURE__ */Object.freeze({}),Jh=100,Xh=20;function eg(e,t,r,n){return![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}function tg(e,t){let a=typeof e=="number"&&Number.isFinite(e),s=l(null),[u,d]=i(null),c=l(null),p=l(null),f=l(true),h=r(()=>{p.current!==null&&clearTimeout(p.current),p.current=null},[]);o(()=>(f.current=true,()=>{f.current=false,h()}),[h]);let g=r(function e(t){s.current?.measureInWindow((r,n)=>{let l=c.current;if(!f.current||l===null)return;let i=eg(n,l.y,l.height,k.get("window").height);if(i!==null){d(e=>e!==null&&e.chatTop===i.chatTop&&e.parentTop===i.parentTop?e:i);return}t>=Xh||(p.current=setTimeout(()=>{p.current=null,e(t+1)},Jh))})},[]),b=r(e=>{let{y:t,height:r}=e.nativeEvent.layout;c.current={y:t,height:r},h(),g(0)},[g,h]);return n(()=>{if(!t)return{avoidingProps:a?{keyboardVerticalOffset:e}:Zh,probeRef:null,topInWindow:null};let r=u?.parentTop??0;return{avoidingProps:a?{keyboardVerticalOffset:e,onLayout:b}:r>0?{keyboardVerticalOffset:r,onLayout:b}:{onLayout:b},probeRef:s,topInWindow:u?.chatTop??null}},[t,a,e,u,b])}function KeyboardOffsetProbe({probeRef:e}){return e===null?null:/* @__PURE__ */E(y,{ref:e,collapsable:false,pointerEvents:"none",style:rg})}var rg=/* @__PURE__ */Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function ng(){let[e,t]=i(false);return o(()=>{let e=C;if(typeof e?.addListener!="function")return;let r=h.OS==="ios",n=e.addListener(r?"keyboardWillShow":"keyboardDidShow",()=>t(true)),l=e.addListener(r?"keyboardWillHide":"keyboardDidHide",()=>t(false));return()=>{n.remove(),l.remove()}},[]),e}var lg=4.5;var ig=3;function og(e,t,r){return os(e,t,Ja(t),r)}function ag(e,t){if(e.level==="emergency")return e;let r=e.level==="schedule_soon",n=$c(t),l=r?n.warning:n.info,i=Uc(t)&&!l?e:sg(e,t,r);return ug(i,t.slots.banner)}function sg(e,t,r){let n=t.color,l=ns(r?n.badgeBgCaution:n.badgeBgInfo,n.surface)??n.surface,i=r?n.cautionAccent:n.infoEdge,o=og(ns(i,n.surface)??i,[n.surface,n.chatGround],ig),a=og(r?n.warningStrong:n.info,[l,n.surface],lg);/* @__PURE__ */
241
+ return Object.freeze({...e,borderColor:o,backgroundColor:l,textColor:a,reasonColor:og(n.text.primary,[l],lg),pillColor:n.surface})}function ug(e,t){if(t===void 0)return e;let r={...e};return t.backgroundColor!==void 0&&(r.backgroundColor=t.backgroundColor),t.borderColor!==void 0&&(r.borderColor=t.borderColor),t.textColor!==void 0&&(r.textColor=t.textColor,r.reasonColor=t.textColor),/* @__PURE__ */Object.freeze(r)}function dg(petRef,e){let t={entry:"chat",petRef:petRef};return e?.returnTo!==void 0&&(t.returnTo=e.returnTo),e?.usState!==void 0&&(t.usState=e.usState),e?.prefer!==void 0&&(t.prefer=e.prefer),t}var cg=.75,pg=1.5,fg=.4,hg=4,gg=1.5,bg=22,yg=14,mg=8,vg=20,wg=10,kg=13,Cg=12,Sg=15,xg=44,Rg=14,Tg=1.25,_g=14,zg=6,Ig=2;function Pg(e,t){let r=e.color;if(t.level==="emergency")return{card:{backgroundColor:r.badgeBgCritical,borderColor:ls(r.danger,fg)??r.danger,borderWidth:pg},label:r.danger,reason:r.text.primary,close:r.danger,action:{fill:r.surface,edge:r.danger,ink:r.danger}};let n=e.slots.banner?.borderRadius;return{card:{backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:cg,...n===void 0?{}:{borderRadius:n}},label:t.textColor,reason:t.reasonColor,close:t.textColor,action:null}}function UrgencyBanner({surface:e,petRef:petRef,renderVetAction:t,onFindVet:r,vet:l,compact:i=false}){let o=useEverfurTheme(),a=n(()=>Fg(o),[o]),s=yo(),u=e.tier===null?null:ag(e.tier,o),d=e.source;/* @__PURE__ */
242
242
  return O(A,{children:[
243
243
  /* @__PURE__ */E(FadePresence,{visible:e.showBanner&&u!==null,inMs:s.bannerInMs,outMs:s.bannerOutMs,style:a.pinned,children:u!==null&&d!==null?/* @__PURE__ */E(BannerCard,{tier:u,reason:d.reason,surface:e,petRef:petRef,renderVetAction:t,onFindVet:r,vet:l,styles:a,compact:i}):null}),
244
- /* @__PURE__ */E(FadePresence,{visible:e.showCompactIcon,inMs:s.iconInMs,outMs:s.iconOutMs,style:a.indicatorRow,children:/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Re.showLatestVetAlert,hitSlop:ag,onPress:e.expand,children:/* @__PURE__ */E(InfoGlyph,{size:og,color:o.color.text.muted,strokeWidth:2})})})]})}function BannerCard({tier:e,reason:t,surface:r,petRef:petRef,renderVetAction:n,onFindVet:l,vet:i,styles:o,compact:a}){let s=useEverfurTheme(),u=yg(s,e),d=/* @__PURE__ */E(VetAction,{tier:e,paint:u,petRef:petRef,onFindVet:l,vet:i,styles:o}),c=r.showVetAction?n!==void 0?/* @__PURE__ */E(HostRender,{render:()=>n(e.level),fallback:d,resetKey:e.level}):d:null,p=u.action!==null?/* @__PURE__ */E(PoisonControl,{paint:u.action,styles:o}):null,f=e.level==="emergency"&&l===void 0,h=e.level==="emergency"||e.level==="schedule_soon";/* @__PURE__ */
245
- return O(b,{...h?{accessibilityRole:"alert"}:{accessibilityLiveRegion:"polite"},style:[o.card,u.card,a?o.cardCompact:null],testID:a?"chat-urgency-compact":void 0,children:[
246
- /* @__PURE__ */E(Text,{tier:"control",style:[o.label,{color:u.label}],children:e.label}),t!==null?/* @__PURE__ */E(Text,{style:[o.reason,{color:u.reason}],numberOfLines:a?bg:void 0,accessibilityLabel:a?t:void 0,children:t}):null,f?/* @__PURE__ */E(Text,{style:[o.reason,o.erLine,{color:u.reason}],children:Re.goToNearestEmergencyVet}):null,c!==null||p!==null?/* @__PURE__ */O(b,{style:o.actions,children:[c,p]}):null,r.dismissLabel!==null?/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:r.dismissLabel,hitSlop:ig,containerStyle:o.closeSlot,style:o.closeButton,onPress:r.dismiss,children:/* @__PURE__ */E(CloseGlyph,{size:lg,color:u.close,strokeWidth:1.5})}):null]})}function PoisonControl({paint:e,styles:t}){let r=()=>{try{y.openURL(Ie).catch(()=>{})}catch{}};/* @__PURE__ */
247
- return E(PressScale,{accessibilityRole:"button",accessibilityLabel:Re.poisonControlNative,hitSlop:0,style:[t.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:r,children:/* @__PURE__ */E(Text,{tier:"control",style:[t.actionLabel,{color:e.ink}],children:Re.poisonControlNative})})}function VetAction({tier:e,paint:t,petRef:petRef,onFindVet:r,vet:n,styles:l}){let i=useEverfurTheme(),o=useVetVisit(Zh(petRef,n)),a=o.status==="opening",s=!o.available&&r!==void 0,u=o.available?()=>{o.open()}:r!==void 0?()=>{Lr(r,e.level)}:null;if(u===null)return null;let d=t.action;if(d!==null){let e=s?Re.nearestEmergencyVet:Re.findVet,t=Eo(i.slots.vetVisitButton)?.textColor??d.ink;/* @__PURE__ */
248
- return O(PressScale,{accessibilityRole:"button",accessibilityLabel:s?Re.nearestEmergencyVet:Re.findVetA11y,accessibilityState:{busy:a},hitSlop:0,style:[l.action,{backgroundColor:d.fill,borderColor:d.edge},l.findVetSlotBox,a?l.findVetBusy:null],onPress:u,children:[
249
- /* @__PURE__ */E(MapPinGlyph,{size:sg,color:t,strokeWidth:1.5}),
250
- /* @__PURE__ */E(Text,{tier:"control",style:[l.actionLabel,{color:t}],children:e})]})}let c=Eo(i.slots.vetVisitButton)?.textColor??e.textColor;/* @__PURE__ */
251
- return O(PressScale,{accessibilityRole:"button",accessibilityLabel:Re.findVetA11y,accessibilityState:{busy:a},style:[l.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},l.findVetSlotBox,a?l.findVetBusy:null],onPress:u,children:[
252
- /* @__PURE__ */E(MapPinGlyph,{size:sg,color:c,strokeWidth:1.5}),
253
- /* @__PURE__ */E(Text,{tier:"control",style:[l.findVetLabel,{color:c}],children:Re.findVet})]})}function mg(e){let t=Eo(e.slots.vetVisitButton),r=e.space,n=e.type;return p.create({pinned:{marginTop:0,marginBottom:r.xs,paddingHorizontal:r.lg},card:{borderRadius:e.radius.lg,paddingHorizontal:r.lg+tg,paddingVertical:r.lg,gap:r.sm},cardCompact:{paddingVertical:r.md,gap:r.xs},label:{...face(e,"bold"),fontSize:n.size.body,paddingRight:ng},reason:{...face(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*rg),paddingRight:ng},erLine:{...face(e,"bold")},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm},action:{flexDirection:"row",alignItems:"center",gap:gg,minHeight:cg,paddingHorizontal:pg,borderRadius:e.radius.pill,borderWidth:fg},actionLabel:{...face(e,"bold"),fontSize:hg},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...Lo(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...face(e,"monoBold"),fontSize:ug,lineHeight:dg},closeSlot:{position:"absolute",top:r.md,right:r.md},closeButton:{width:ng,height:ng,borderRadius:ng/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:r.lg,paddingTop:2,paddingBottom:r.xs}})}function vg(e,userRef,petRef,t){let[r,n]=i({pet:petRef,user:userRef}),l=r.pet!==petRef||r.user===null&&userRef!==null;l&&n({pet:petRef,user:userRef});let a=l?{user:userRef}:r,s=petRef!==null&&a.user!==null&&a.user!==userRef;return o(()=>{if(!s||userRef===null||petRef===null)return;let t=true,r=createPetsRepository(e.registry.services.authFor(userRef)),l=async()=>{let e=await r.list();t&&e.ok&&e.value.some(e=>e.petRef===petRef)&&n({pet:petRef,user:userRef})};l();let i=Md(e,()=>{l()});return()=>{t=false,i()}},[s,e,userRef,petRef,t]),s}var wg=/* @__PURE__ */Object.freeze({status:"idle",messages:/* @__PURE__ */Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:/* @__PURE__ */Object.freeze([]),unreadCount:null});function useEverfurChat(e){let{runtime:t,userRef:userRef,activePet:s,scopeEpoch:u}=Oe(),petRef=e?.petRef??s??null,conversationId=e?.conversationId??null,d=vg(t,userRef,petRef,u),c=n(()=>({runtime:t,userRef:userRef,petRef:petRef,conversationId:conversationId,scopeEpoch:u,held:d}),[t,userRef,petRef,conversationId,u,d]),[p,f]=i(null),h=d?null:p?.scope===c?p.controller:t.registry.peekChat({userRef:userRef,petRef:petRef,conversationId:conversationId}),g=l(null);o(()=>{if(d)return;let e=t.registry.acquireChat({userRef:userRef,petRef:petRef,conversationId:conversationId});return g.current=e,f({scope:c,controller:e}),()=>{g.current=null,f(t=>t?.controller===e?null:t),t.registry.releaseChat(e)}},[t,userRef,petRef,conversationId,u,d,c]);let b=r(e=>h?h.subscribe(e):NOOP_UNSUBSCRIBE,[h]),y=r(()=>h?h.getSnapshot():wg,[h]),m=a(b,y,y),v=r((e,t)=>h&&g.current===h&&!h.getSnapshot().isBootstrapping?Cg(h,h.send(e,t?.imageS3Keys===void 0?{}:{imageS3Keys:t.imageS3Keys}),()=>g.current===h):Promise.resolve(xg()),[h]),w=r(e=>h&&g.current===h&&!h.getSnapshot().isBootstrapping?Cg(h,h.askEverfur(e),()=>g.current===h):Promise.resolve(xg()),[h]),k=r(()=>h&&g.current===h?Cg(h,h.retryLast(),()=>g.current===h):Promise.resolve(xg()),[h]),C=r(()=>{h&&g.current===h&&h.stop()},[h]),S=r(()=>{h&&g.current===h&&h.newConversation()},[h]),[x,R]=i({controller:null,byMessage:{}}),_=x.controller===h?x.byMessage:kg,T=r(async(e,t,r,n)=>{if(!h||g.current!==h)return err(makeEverfurError("accessDenied"));let l=String(e),i=x.controller===h?x.byMessage[l]:void 0;if(i===t&&r==null)return R(e=>{let t={...e.controller===h?e.byMessage:{}};return delete t[l],{controller:h,byMessage:t}}),ok(/* @__PURE__ */Object.freeze({feedbackId:""}));R(e=>({controller:h,byMessage:{...e.controller===h?e.byMessage:{},[l]:t}}));let o=await h.submitFeedback(e,Sp(t,r??null),n??null);return g.current!==h?err(makeEverfurError("accessDenied")):(o.ok||R(e=>{let t={...e.controller===h?e.byMessage:{}};return i===void 0?delete t[l]:t[l]=i,{controller:h,byMessage:t}}),o)},[h,x]),z=n(()=>{let e=async e=>{if(!h||g.current!==h)return err(makeEverfurError("accessDenied"));let t=await e(h);return g.current===h?t:err(makeEverfurError("accessDenied"))};return{listConversations:t=>e(e=>e.listConversations({...petRef?{petRef:petRef}:{},...t})),getMessages:(t,r)=>e(e=>e.getMessages(t,r)),resumeConversation:t=>e(e=>e.resumeConversation(t)),loadOlderMessages:()=>e(e=>e.loadOlderMessages()),markRead:()=>e(e=>e.markRead()),refreshActiveThread:t=>e(e=>e.refreshActiveThread(t)),answerCheckin:(t,r)=>e(e=>e.answerCheckin(t,r)),openCheckin:t=>e(e=>e.openCheckin(t))}},[h,petRef]);return n(()=>({status:m.status,messages:m.messages,conversationId:m.conversationId,petRef:petRef,error:m.error,isStreaming:m.isStreaming,isBootstrapping:m.isBootstrapping,historyCursor:m.historyCursor??null,isLoadingHistory:m.isLoadingHistory??false,stopped:m.stopped??false,reconnecting:m.reconnecting??false,...z,suggestedPrompts:m.suggestedPrompts,unreadCount:m.unreadCount,hasUnreadThreads:m.hasUnreadThreads??false,pendingCheckin:m.pendingCheckin??null,newConversation:S,sentimentByMessage:_,feedback:T,send:v,askEverfur:w,retryLast:k,stop:C}),[m,petRef,v,w,k,C,z,S,_,T])}var NOOP_UNSUBSCRIBE=()=>{},kg=/* @__PURE__ */Object.freeze({});async function Cg(e,t,r){for await(let e of t);if(!r())return err(makeEverfurError("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?err(n.error):ok(Sg(n.messages))}function Sg(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}function xg(){return El()}function Rg(){let e=useEverfurPets(),{handle:t}=Oe(),l=r(petRef=>t.setActivePet(petRef),[t]);return n(()=>({...e,setActivePet:l}),[e,l])}function _g(){try{let e=_?.announceForAccessibility;typeof e=="function"&&e.call(_,Re.answered)}catch{}}function Tg(e){let t=l(false),r=l({send:e.send,id:e.conversationId});o(()=>{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 t=e.messages[e.messages.length-1];t!==void 0&&t.role==="assistant"&&_g()}t.current=e.isStreaming},[e.isStreaming,e.messages,e.send,e.conversationId])}var zg=/* @__PURE__ */Object.freeze({kind:"live"}),Ig=/* @__PURE__ */Object.freeze({kind:"folded"});function Pg(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=li(e.proactiveOriginRef);return{caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}function Fg(e){let t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(let t of e){let e=Pg(t);if(e===null)continue;let n=r.get(e.caseId);(n===void 0||e.dueDay>=n.dueDay)&&r.set(e.caseId,{messageId:t.id,dueDay:e.dueDay})}if(r.size===0)return t;let n=null;for(let l of e){let e=Pg(l);if(e===null){n=null;continue}if(r.get(e.caseId)?.messageId===l.id){t.set(l.id,zg),n=null;continue}if(n!==null&&n.caseId===e.caseId){n.days.push(e.dueDay),t.set(l.id,Ig);continue}let i=[e.dueDay];n={id:l.id,caseId:e.caseId,days:i},t.set(l.id,{kind:"past",runDueDays:i})}return t}function Lg(e){let t=/* @__PURE__ */new Set;for(let[r,n]of e)n.kind==="live"&&t.add(r);return t}var Eg=864e5,Og=365;function Ag(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 l=Math.floor(n/Eg)-Math.floor(r/Eg);return l<1||l>Og?null:l}function jg(e){return Pg(e)?.dueDay||null}function Dg(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function AssistantSender({avatarUrl:e,named:t,styles:r}){let n=xc(e);return n.shown?/* @__PURE__ */O(b,{style:r.assistantSender,testID:"everfur-assistant-sender",children:[
254
- /* @__PURE__ */E(BrandImage,{uri:e,decorative:true,style:r.assistantAvatar,resizeMode:"cover",onError:n.onError,testID:"everfur-assistant-avatar"}),t?/* @__PURE__ */E(Text,{tier:"control",style:[r.assistantName,r.assistantNameInRow],children:Re.assistantName}):null]}):t?/* @__PURE__ */E(Text,{tier:"control",style:r.assistantName,children:Re.assistantName}):null}var Mg=/* @__PURE__ */Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),Bg="#C8BEB4";function Hg(e){return e?Mg[e.toUpperCase()]??Bg:Bg}function Wg(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}function Ng(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}function Ug(e){let t=Ng(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}function $g(e,t){let r=Ng(e.source_name)??Ng(e.sourceName),n=Ng(e.section),l=Ng(e.authority_tier)??Ng(e.authorityTier),i=Wg(l),o=r??Ng(e.title)??`Source ${t+1}`,a=Ng(e.monograph_chunk_id)??Ng(e.chunkId),s=[n,i].filter(e=>e!==null).join(" · ");/* @__PURE__ */
255
- return Object.freeze({title:o,sourceName:r,section:n,authorityTier:l,tierLabel:i,meta:s.length===0?null:s,url:Ug(e.url),excerpt:Ng(e.excerpt),tierColor:Hg(l),key:`${o}-${a??"none"}-${t}`})}function Vg(e){return e===void 0||e.length===0?qg:/* @__PURE__ */Object.freeze(e.map((e,t)=>$g(e,t)))}var qg=/* @__PURE__ */Object.freeze([]);function Gg(e){return e===1?`1 ${Re.sourceSingular}`:`${e} ${Re.sourcePlural}`}function Kg(e,t){return`${t?Re.hideSources:Re.showSources} ${Gg(e)}`}function Yg(e){return[e.url!==null?`${Re.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(e=>e!==null&&e.length>0).join(". ")}var Qg="https:\\/\\/sdk(?:-[a-z]+)?\\.everfur\\.com";function Zg(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}typeof __EVERFUR_BRAND_CDN_ORIGIN__=="string"&&__EVERFUR_BRAND_CDN_ORIGIN__.length>0?Zg(__EVERFUR_BRAND_CDN_ORIGIN__):Qg;function hardenHttpsUrl(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}function Jg(e){let t=e.split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:[e]}var Xg=/^\s*[-*]\s+(\S.*)$/,eb=/^\s*(\d{1,3})[.)]\s+(\S.*)$/;function tb(e){let t=[],r=[],n=null,l=()=>{r.length>0&&t.push({kind:"text",text:r.join(`\n`)}),r=[]},i=()=>{n!==null&&t.push(n.ordered?{kind:"list",ordered:true,start:n.start,items:n.items}:{kind:"list",ordered:false,items:n.items}),n=null};for(let t of e.split(`\n`)){let e=Xg.exec(t),o=e===null?eb.exec(t):null,a=e?.[1]??o?.[2];if(a===void 0){i(),r.push(t);continue}let s=o!==null;l(),n!==null&&n.ordered!==s&&i(),n===null&&(n={ordered:s,start:o===null?1:Number(o[1]),items:[]}),n.items.push(a.trim())}return l(),i(),t}function rb(e,t){let r=e.findIndex(e=>e.id===t);for(let t=r-1;t>=0;t-=1){let r=e[t];if(r!==void 0&&r.role==="user")return r.text}return null}function nb(e,t){if(e===void 0)return[];try{let r=e(t);return Array.isArray(r)?r:[]}catch{return[]}}function lb(e){return hardenHttpsUrl(e.trim())}function ib(e,t){if(t?.followUpActions===void 0||e.isStreaming||e.status==="error")return[];let r=e.messages[e.messages.length-1];return r===void 0||r.role!=="assistant"||r.pending===true?[]:nb(t.followUpActions,{answer:r.text,question:rb(e.messages,r.id),messageId:r.id})}var ob=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g,ab=new RegExp(`\\[([^\\]\\n]{1,300})\\]\\((https:\\/\\/[^\\s()<>]{1,${Bi}})\\)|(https:\\/\\/[^\\s<>"'\`*\\[\\]]{1,${Bi}})`,"gi"),sb=/https:\/\//i,ub=`.,;:!?'"`;function db(e,t){return e.includes("*")||e.includes("`")||t!==void 0&&sb.test(e)}function cb(e,t){let r=[],n=e=>{t===void 0?r.push({kind:"text",text:e}):hb(r,e,t)},l=0;ob.lastIndex=0;for(let t=ob.exec(e);t!==null;t=ob.exec(e)){t.index>l&&n(e.slice(l,t.index));let i=t[1],o=t[2],a=t[3];i!==void 0?r.push({kind:"bold",text:i}):o!==void 0?r.push({kind:"italic",text:o}):a!==void 0&&r.push({kind:"code",text:a}),l=t.index+t[0].length}return l<e.length&&n(e.slice(l)),r}function pb(e){let t=e.length;for(;;){let r=e[t-1];if(r===void 0)break;if(ub.includes(r))t-=1;else if(r===")"&&fb(e,"(",t)<fb(e,")",t))t-=1;else break}return e.slice(0,t)}function fb(e,t,r){let n=0;for(let l=0;l<r;l+=1)e[l]===t&&(n+=1);return n}function hb(e,t,r){if(!sb.test(t)){e.push({kind:"text",text:t});return}let n=0;ab.lastIndex=0;for(let l=ab.exec(t);l!==null;l=ab.exec(t)){let i=l[1],o=l[2],a=l[3],s,u,d;if(i!==void 0&&o!==void 0)s=i.trim(),u=s.length>0?Ui(o,r):null,d=l[0].length;else if(a!==void 0)s=pb(a),u=Ui(s,r),d=s.length;else continue;u!==null&&(l.index>n&&e.push({kind:"text",text:t.slice(n,l.index)}),e.push({kind:"link",text:s,href:u}),n=l.index+d,ab.lastIndex=n)}n<t.length&&e.push({kind:"text",text:t.slice(n)})}var gb=/* @__PURE__ */Object.freeze({textDecorationLine:"underline"});function bb(e,t){return t===void 0||!db(e,t.hosts)?false:cb(e,t.hosts).some(e=>e.kind==="link")}function yb(e,t,r){let n=r?.hosts;return db(e,n)?cb(e,n).map((e,n)=>{switch(e.kind){case"bold":/* @__PURE__ */
244
+ /* @__PURE__ */E(FadePresence,{visible:e.showCompactIcon,inMs:s.iconInMs,outMs:s.iconOutMs,style:a.indicatorRow,children:/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:Me.showLatestVetAlert,hitSlop:wg,onPress:e.expand,children:/* @__PURE__ */E(InfoGlyph,{size:vg,color:o.color.text.muted,strokeWidth:2})})})]})}function BannerCard({tier:e,reason:t,surface:r,petRef:petRef,renderVetAction:n,onFindVet:l,vet:i,styles:o,compact:a}){let s=useEverfurTheme(),u=Pg(s,e),d=/* @__PURE__ */E(VetAction,{tier:e,paint:u,petRef:petRef,onFindVet:l,vet:i,styles:o}),c=r.showVetAction?n!==void 0?/* @__PURE__ */E(HostRender,{render:()=>n(e.level),fallback:d,resetKey:e.level}):d:null,p=u.action!==null?/* @__PURE__ */E(PoisonControl,{paint:u.action,styles:o}):null,f=e.level==="emergency"&&l===void 0,h=e.level==="emergency"||e.level==="schedule_soon";/* @__PURE__ */
245
+ return O(y,{...h?{accessibilityRole:"alert"}:{accessibilityLiveRegion:"polite"},style:[o.card,u.card,a?o.cardCompact:null],testID:a?"chat-urgency-compact":void 0,children:[
246
+ /* @__PURE__ */E(Text,{tier:"control",style:[o.label,{color:u.label}],children:e.label}),t!==null?/* @__PURE__ */E(Text,{style:[o.reason,{color:u.reason}],numberOfLines:a?Ig:void 0,accessibilityLabel:a?t:void 0,children:t}):null,f?/* @__PURE__ */E(Text,{style:[o.reason,o.erLine,{color:u.reason}],children:Me.goToNearestEmergencyVet}):null,c!==null||p!==null?/* @__PURE__ */O(y,{style:o.actions,children:[c,p]}):null,r.dismissLabel!==null?/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:r.dismissLabel,hitSlop:mg,containerStyle:o.closeSlot,style:o.closeButton,onPress:r.dismiss,children:/* @__PURE__ */E(CloseGlyph,{size:yg,color:u.close,strokeWidth:1.5})}):null]})}function PoisonControl({paint:e,styles:t}){let r=()=>{try{m.openURL(Ne).catch(()=>{})}catch{}};/* @__PURE__ */
247
+ return E(PressScale,{accessibilityRole:"button",accessibilityLabel:Me.poisonControlNative,hitSlop:0,style:[t.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:r,children:/* @__PURE__ */E(Text,{tier:"control",style:[t.actionLabel,{color:e.ink}],children:Me.poisonControlNative})})}function VetAction({tier:e,paint:t,petRef:petRef,onFindVet:r,vet:n,styles:l}){let i=useEverfurTheme(),o=useVetVisit(dg(petRef,n)),a=o.status==="opening",s=!o.available&&r!==void 0,u=o.available?()=>{o.open()}:r!==void 0?()=>{Vr(r,e.level)}:null;if(u===null)return null;let d=t.action;if(d!==null){let e=s?Me.nearestEmergencyVet:Me.findVet,t=qo(i.slots.vetVisitButton)?.textColor??d.ink;/* @__PURE__ */
248
+ return O(PressScale,{accessibilityRole:"button",accessibilityLabel:s?Me.nearestEmergencyVet:Me.findVetA11y,accessibilityState:{busy:a},hitSlop:0,style:[l.action,{backgroundColor:d.fill,borderColor:d.edge},l.findVetSlotBox,a?l.findVetBusy:null],onPress:u,children:[
249
+ /* @__PURE__ */E(MapPinGlyph,{size:kg,color:t,strokeWidth:1.5}),
250
+ /* @__PURE__ */E(Text,{tier:"control",style:[l.actionLabel,{color:t}],children:e})]})}let c=qo(i.slots.vetVisitButton)?.textColor??e.textColor;/* @__PURE__ */
251
+ return O(PressScale,{accessibilityRole:"button",accessibilityLabel:Me.findVetA11y,accessibilityState:{busy:a},style:[l.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},l.findVetSlotBox,a?l.findVetBusy:null],onPress:u,children:[
252
+ /* @__PURE__ */E(MapPinGlyph,{size:kg,color:c,strokeWidth:1.5}),
253
+ /* @__PURE__ */E(Text,{tier:"control",style:[l.findVetLabel,{color:c}],children:Me.findVet})]})}function Fg(e){let t=qo(e.slots.vetVisitButton),r=e.space,n=e.type;return f.create({pinned:{marginTop:0,marginBottom:r.xs,paddingHorizontal:r.lg},card:{borderRadius:e.radius.lg,paddingHorizontal:r.lg+hg,paddingVertical:r.lg,gap:r.sm},cardCompact:{paddingVertical:r.md,gap:r.xs},label:{...face(e,"bold"),fontSize:n.size.body,paddingRight:bg},reason:{...face(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*gg),paddingRight:bg},erLine:{...face(e,"bold")},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm},action:{flexDirection:"row",alignItems:"center",gap:zg,minHeight:xg,paddingHorizontal:Rg,borderRadius:e.radius.pill,borderWidth:Tg},actionLabel:{...face(e,"bold"),fontSize:_g},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...Vo(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...face(e,"monoBold"),fontSize:Cg,lineHeight:Sg},closeSlot:{position:"absolute",top:r.md,right:r.md},closeButton:{width:bg,height:bg,borderRadius:bg/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:r.lg,paddingTop:2,paddingBottom:r.xs}})}function Lg(e,userRef,petRef,t){let[r,n]=i({pet:petRef,user:userRef}),l=r.pet!==petRef||r.user===null&&userRef!==null;l&&n({pet:petRef,user:userRef});let a=l?{user:userRef}:r,s=petRef!==null&&a.user!==null&&a.user!==userRef;return o(()=>{if(!s||userRef===null||petRef===null)return;let t=true,r=createPetsRepository(e.registry.services.authFor(userRef)),l=async()=>{let e=await r.list();t&&e.ok&&e.value.some(e=>e.petRef===petRef)&&n({pet:petRef,user:userRef})};l();let i=Zd(e,()=>{l()});return()=>{t=false,i()}},[s,e,userRef,petRef,t]),s}var Eg=/* @__PURE__ */Object.freeze({status:"idle",messages:/* @__PURE__ */Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:/* @__PURE__ */Object.freeze([]),unreadCount:null});function useEverfurChat(e){let{runtime:t,userRef:userRef,activePet:s,scopeEpoch:u}=Ge(),petRef=e?.petRef??s??null,conversationId=e?.conversationId??null,d=Lg(t,userRef,petRef,u),c=n(()=>({runtime:t,userRef:userRef,petRef:petRef,conversationId:conversationId,scopeEpoch:u,held:d}),[t,userRef,petRef,conversationId,u,d]),[p,f]=i(null),h=d?null:p?.scope===c?p.controller:t.registry.peekChat({userRef:userRef,petRef:petRef,conversationId:conversationId}),g=l(null);o(()=>{if(d)return;let e=t.registry.acquireChat({userRef:userRef,petRef:petRef,conversationId:conversationId});return g.current=e,f({scope:c,controller:e}),()=>{g.current=null,f(t=>t?.controller===e?null:t),t.registry.releaseChat(e)}},[t,userRef,petRef,conversationId,u,d,c]);let b=r(e=>h?h.subscribe(e):NOOP_UNSUBSCRIBE,[h]),y=r(()=>h?h.getSnapshot():Eg,[h]),m=a(b,y,y),v=r((e,t)=>h&&g.current===h&&!h.getSnapshot().isBootstrapping?Ag(h,h.send(e,t?.imageS3Keys===void 0?{}:{imageS3Keys:t.imageS3Keys}),()=>g.current===h):Promise.resolve(Dg()),[h]),w=r(e=>h&&g.current===h&&!h.getSnapshot().isBootstrapping?Ag(h,h.askEverfur(e),()=>g.current===h):Promise.resolve(Dg()),[h]),k=r(()=>h&&g.current===h?Ag(h,h.retryLast(),()=>g.current===h):Promise.resolve(Dg()),[h]),C=r(()=>{h&&g.current===h&&h.stop()},[h]),S=r(()=>{h&&g.current===h&&h.newConversation()},[h]),[x,R]=i({controller:null,byMessage:{}}),T=x.controller===h?x.byMessage:Og,_=r(async(e,t,r,n)=>{if(!h||g.current!==h)return err(makeEverfurError("accessDenied"));let l=String(e),i=x.controller===h?x.byMessage[l]:void 0;if(i===t&&r==null)return R(e=>{let t={...e.controller===h?e.byMessage:{}};return delete t[l],{controller:h,byMessage:t}}),ok(/* @__PURE__ */Object.freeze({feedbackId:""}));R(e=>({controller:h,byMessage:{...e.controller===h?e.byMessage:{},[l]:t}}));let o=await h.submitFeedback(e,jp(t,r??null),n??null);return g.current!==h?err(makeEverfurError("accessDenied")):(o.ok||R(e=>{let t={...e.controller===h?e.byMessage:{}};return i===void 0?delete t[l]:t[l]=i,{controller:h,byMessage:t}}),o)},[h,x]),z=n(()=>{let e=async e=>{if(!h||g.current!==h)return err(makeEverfurError("accessDenied"));let t=await e(h);return g.current===h?t:err(makeEverfurError("accessDenied"))};return{listConversations:t=>e(e=>e.listConversations({...petRef?{petRef:petRef}:{},...t})),getMessages:(t,r)=>e(e=>e.getMessages(t,r)),resumeConversation:t=>e(e=>e.resumeConversation(t)),loadOlderMessages:()=>e(e=>e.loadOlderMessages()),markRead:()=>e(e=>e.markRead()),refreshActiveThread:t=>e(e=>e.refreshActiveThread(t)),answerCheckin:(t,r)=>e(e=>e.answerCheckin(t,r)),openCheckin:t=>e(e=>e.openCheckin(t))}},[h,petRef]);return n(()=>({status:m.status,messages:m.messages,conversationId:m.conversationId,petRef:petRef,error:m.error,isStreaming:m.isStreaming,isBootstrapping:m.isBootstrapping,historyCursor:m.historyCursor??null,isLoadingHistory:m.isLoadingHistory??false,stopped:m.stopped??false,reconnecting:m.reconnecting??false,...z,suggestedPrompts:m.suggestedPrompts,unreadCount:m.unreadCount,hasUnreadThreads:m.hasUnreadThreads??false,pendingCheckin:m.pendingCheckin??null,newConversation:S,sentimentByMessage:T,feedback:_,send:v,askEverfur:w,retryLast:k,stop:C}),[m,petRef,v,w,k,C,z,S,T,_])}var NOOP_UNSUBSCRIBE=()=>{},Og=/* @__PURE__ */Object.freeze({});async function Ag(e,t,r){for await(let e of t);if(!r())return err(makeEverfurError("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?err(n.error):ok(jg(n.messages))}function jg(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}function Dg(){return ql()}function Mg(){let e=useEverfurPets(),{handle:t}=Ge(),l=r(petRef=>t.setActivePet(petRef),[t]);return n(()=>({...e,setActivePet:l}),[e,l])}function Bg(){try{let e=_?.announceForAccessibility;typeof e=="function"&&e.call(_,Me.answered)}catch{}}function Hg(e){let t=l(false),r=l({send:e.send,id:e.conversationId});o(()=>{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 t=e.messages[e.messages.length-1];t!==void 0&&t.role==="assistant"&&Bg()}t.current=e.isStreaming},[e.isStreaming,e.messages,e.send,e.conversationId])}var Wg=/* @__PURE__ */Object.freeze({kind:"live"}),Ng=/* @__PURE__ */Object.freeze({kind:"folded"});function Ug(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=yi(e.proactiveOriginRef);return{caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}function $g(e){let t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(let t of e){let e=Ug(t);if(e===null)continue;let n=r.get(e.caseId);(n===void 0||e.dueDay>=n.dueDay)&&r.set(e.caseId,{messageId:t.id,dueDay:e.dueDay})}if(r.size===0)return t;let n=null;for(let l of e){let e=Ug(l);if(e===null){n=null;continue}if(r.get(e.caseId)?.messageId===l.id){t.set(l.id,Wg),n=null;continue}if(n!==null&&n.caseId===e.caseId){n.days.push(e.dueDay),t.set(l.id,Ng);continue}let i=[e.dueDay];n={id:l.id,caseId:e.caseId,days:i},t.set(l.id,{kind:"past",runDueDays:i})}return t}function Vg(e){let t=/* @__PURE__ */new Set;for(let[r,n]of e)n.kind==="live"&&t.add(r);return t}var qg=864e5,Gg=365;function Kg(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 l=Math.floor(n/qg)-Math.floor(r/qg);return l<1||l>Gg?null:l}function Yg(e){return Ug(e)?.dueDay||null}function Qg(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function AssistantSender({avatarUrl:e,named:t,styles:r}){let n=Dc(e);return n.shown?/* @__PURE__ */O(y,{style:r.assistantSender,testID:"everfur-assistant-sender",children:[
254
+ /* @__PURE__ */E(BrandImage,{uri:e,decorative:true,style:r.assistantAvatar,resizeMode:"cover",onError:n.onError,testID:"everfur-assistant-avatar"}),t?/* @__PURE__ */E(Text,{tier:"control",style:[r.assistantName,r.assistantNameInRow],children:Me.assistantName}):null]}):t?/* @__PURE__ */E(Text,{tier:"control",style:r.assistantName,children:Me.assistantName}):null}var Zg=/* @__PURE__ */Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),Jg="#C8BEB4";function Xg(e){return e?Zg[e.toUpperCase()]??Jg:Jg}function eb(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}function tb(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}function rb(e){let t=tb(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}function nb(e,t){let r=tb(e.source_name)??tb(e.sourceName),n=tb(e.section),l=tb(e.authority_tier)??tb(e.authorityTier),i=eb(l),o=r??tb(e.title)??`Source ${t+1}`,a=tb(e.monograph_chunk_id)??tb(e.chunkId),s=[n,i].filter(e=>e!==null).join(" · ");/* @__PURE__ */
255
+ return Object.freeze({title:o,sourceName:r,section:n,authorityTier:l,tierLabel:i,meta:s.length===0?null:s,url:rb(e.url),excerpt:tb(e.excerpt),tierColor:Xg(l),key:`${o}-${a??"none"}-${t}`})}function lb(e){return e===void 0||e.length===0?ib:/* @__PURE__ */Object.freeze(e.map((e,t)=>nb(e,t)))}var ib=/* @__PURE__ */Object.freeze([]);function ob(e){return e===1?`1 ${Me.sourceSingular}`:`${e} ${Me.sourcePlural}`}function ab(e,t){return`${t?Me.hideSources:Me.showSources} ${ob(e)}`}function sb(e){return[e.url!==null?`${Me.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(e=>e!==null&&e.length>0).join(". ")}var ub="https:\\/\\/sdk(?:-[a-z]+)?\\.everfur\\.com";function db(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}typeof __EVERFUR_BRAND_CDN_ORIGIN__=="string"&&__EVERFUR_BRAND_CDN_ORIGIN__.length>0?db(__EVERFUR_BRAND_CDN_ORIGIN__):ub;function hardenHttpsUrl(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}function cb(e){let t=e.split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:[e]}var pb=/^\s*[-*]\s+(\S.*)$/,fb=/^\s*(\d{1,3})[.)]\s+(\S.*)$/;function hb(e){let t=[],r=[],n=null,l=()=>{r.length>0&&t.push({kind:"text",text:r.join(`\n`)}),r=[]},i=()=>{n!==null&&t.push(n.ordered?{kind:"list",ordered:true,start:n.start,items:n.items}:{kind:"list",ordered:false,items:n.items}),n=null};for(let t of e.split(`\n`)){let e=pb.exec(t),o=e===null?fb.exec(t):null,a=e?.[1]??o?.[2];if(a===void 0){i(),r.push(t);continue}let s=o!==null;l(),n!==null&&n.ordered!==s&&i(),n===null&&(n={ordered:s,start:o===null?1:Number(o[1]),items:[]}),n.items.push(a.trim())}return l(),i(),t}function gb(e,t){let r=e.findIndex(e=>e.id===t);for(let t=r-1;t>=0;t-=1){let r=e[t];if(r!==void 0&&r.role==="user")return r.text}return null}function bb(e,t){if(e===void 0)return[];try{let r=e(t);return Array.isArray(r)?r:[]}catch{return[]}}function yb(e){return hardenHttpsUrl(e.trim())}function mb(e,t){if(t?.followUpActions===void 0||e.isStreaming||e.status==="error")return[];let r=e.messages[e.messages.length-1];return r===void 0||r.role!=="assistant"||r.pending===true?[]:bb(t.followUpActions,{answer:r.text,question:gb(e.messages,r.id),messageId:r.id})}var vb=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g,wb=new RegExp(`\\[([^\\]\\n]{1,300})\\]\\((https:\\/\\/[^\\s()<>]{1,${Ji}})\\)|(https:\\/\\/[^\\s<>"'\`*\\[\\]]{1,${Ji}})`,"gi"),kb=/https:\/\//i,Cb=`.,;:!?'"`;function Sb(e,t){return e.includes("*")||e.includes("`")||t!==void 0&&kb.test(e)}function xb(e,t){let r=[],n=e=>{t===void 0?r.push({kind:"text",text:e}):_b(r,e,t)},l=0;vb.lastIndex=0;for(let t=vb.exec(e);t!==null;t=vb.exec(e)){t.index>l&&n(e.slice(l,t.index));let i=t[1],o=t[2],a=t[3];i!==void 0?r.push({kind:"bold",text:i}):o!==void 0?r.push({kind:"italic",text:o}):a!==void 0&&r.push({kind:"code",text:a}),l=t.index+t[0].length}return l<e.length&&n(e.slice(l)),r}function Rb(e){let t=e.length;for(;;){let r=e[t-1];if(r===void 0)break;if(Cb.includes(r))t-=1;else if(r===")"&&Tb(e,"(",t)<Tb(e,")",t))t-=1;else break}return e.slice(0,t)}function Tb(e,t,r){let n=0;for(let l=0;l<r;l+=1)e[l]===t&&(n+=1);return n}function _b(e,t,r){if(!kb.test(t)){e.push({kind:"text",text:t});return}let n=0;wb.lastIndex=0;for(let l=wb.exec(t);l!==null;l=wb.exec(t)){let i=l[1],o=l[2],a=l[3],s,u,d;if(i!==void 0&&o!==void 0)s=i.trim(),u=s.length>0?ro(o,r):null,d=l[0].length;else if(a!==void 0)s=Rb(a),u=ro(s,r),d=s.length;else continue;u!==null&&(l.index>n&&e.push({kind:"text",text:t.slice(n,l.index)}),e.push({kind:"link",text:s,href:u}),n=l.index+d,wb.lastIndex=n)}n<t.length&&e.push({kind:"text",text:t.slice(n)})}var zb=/* @__PURE__ */Object.freeze({textDecorationLine:"underline"});function Ib(e,t){return t===void 0||!Sb(e,t.hosts)?false:xb(e,t.hosts).some(e=>e.kind==="link")}function Pb(e,t,r){let n=r?.hosts;return Sb(e,n)?xb(e,n).map((e,n)=>{switch(e.kind){case"bold":/* @__PURE__ */
256
256
  return E(Text,{style:t.bold,children:e.text},n);case"italic":return t.italic?/* @__PURE__ */E(Text,{style:t.italic,children:e.text},n):e.text;case"code":return t.code?/* @__PURE__ */E(Text,{style:t.code,children:e.text},n):e.text;case"link":{if(r===void 0)return e.text;let{href:t}=e;/* @__PURE__ */
257
- return E(Text,{style:gb,accessibilityRole:"link",accessibilityLabel:e.text,onPress:()=>r.open(t),children:e.text},n)}default:return e.text}}):e}var mb=10.5,vb=16,wb=12,kb=38,Cb=11,Sb=15,xb=22,Rb=32,_b=13.5,Tb=14,zb=15,Ib=16,Pb=13,Fb=13,Lb=26,Eb=21,Ob=42,Ab=1,jb=.06,Db=.07,Mb=.12,Bb="45%";function Hb(){let e=useEverfurTheme(),t=n(()=>Wb(e),[e]);return{theme:e,styles:t}}function Chevron({options:e,color:t}){let r=/* @__PURE__ */E(ChevronGlyph,{size:Ib,color:t,strokeWidth:2,direction:"right"}),n=e?.renderIcon;return n===void 0?r:/* @__PURE__ */E(HostRender,{render:()=>n("chevron"),fallback:r})}function AnswerCard({card:e,options:t}){let{theme:r,styles:n}=Hb();if(e.render!==void 0){let r=e.render;/* @__PURE__ */
258
- return E(b,{style:[n.card,e.variant!==void 0?t?.styles?.cardVariant?.[e.variant]:null],accessible:false,accessibilityLabel:e.title,testID:"everfur-answer-host-card",children:/* @__PURE__ */E(HostRender,{render:r,fallback:null})})}let l=e.value!==void 0,i=t?.styles,o=[n.card,l?i?.cardStat:null,e.variant!==void 0?i?.cardVariant?.[e.variant]:null],a=e.tile?.tone,s=e.pill?.tone,u=e.tile?.imageUrl!==void 0?lb(e.tile.imageUrl):null,d=/* @__PURE__ */O(A,{children:[l?null:/* @__PURE__ */E(b,{style:[n.tile,a!==void 0?i?.tileTone?.[a]:null],children:u!==null?/* @__PURE__ */E(R,{source:{uri:u},style:n.tileImage,accessibilityIgnoresInvertColors:true}):e.tile?.icon??null}),
259
- /* @__PURE__ */O(b,{style:n.cardWords,children:[
260
- /* @__PURE__ */E(Text,{tier:"control",style:n.cardTitle,children:e.title}),e.meta!==void 0?/* @__PURE__ */E(Text,{tier:"compact",style:n.cardMeta,children:e.meta}):null]}),l?/* @__PURE__ */O(Text,{tier:"control",style:n.stat,children:[e.value?.amount,e.value?.unit!==void 0?/* @__PURE__ */E(Text,{style:n.statUnit,children:e.value.unit}):null]}):/* @__PURE__ */O(A,{children:[e.pill!==void 0?/* @__PURE__ */E(b,{style:[n.pill,s!==void 0?i?.pillTone?.[s]:null],children:/* @__PURE__ */E(Text,{tier:"badge",style:[n.pillText,s!==void 0?i?.pillToneText?.[s]:null],numberOfLines:1,ellipsizeMode:"tail",children:e.pill.label})}):null,e.onPress!==void 0?/* @__PURE__ */E(Chevron,{options:t,color:r.color.text.muted}):null]})]});if(e.onPress!==void 0){let t=e.onPress;/* @__PURE__ */
261
- return E(v,{onPress:()=>{Lr(t)},accessibilityRole:"button",accessibilityLabel:e.title,style:o,children:d})}/* @__PURE__ */
262
- return E(b,{style:o,children:d})}function CardsAnswer({message:e,text:t,streaming:r,messages:l,options:i,sentiment:o,onSentiment:a,sender:s,footer:u,onOpenUrl:d}){let{styles:c}=Hb(),p=n(()=>({answer:e.text,question:rb(l,e.id),messageId:e.id}),[e.text,e.id,l]),f=!r&&e.pending!==true,h=f?nb(i?.cards,p):[],g=n(()=>f?Vg(e.citations):[],[f,e.citations]),y=i?.byline,m=i?.feedback!==void 0&&e.responseId!==void 0&&a!==void 0?i.feedback:null,v={bold:c.bold,italic:c.italic,code:c.code},w=qi(),k=f?w:void 0;/* @__PURE__ */
263
- return O(b,{style:c.answer,testID:"everfur-answer-cards",children:[y!==void 0?/* @__PURE__ */O(b,{style:c.byline,children:[y.icon??null,
264
- /* @__PURE__ */E(Text,{tier:"compact",style:c.bylineText,children:y.label})]}):s,
265
- /* @__PURE__ */E(b,{style:c.body,children:Jg(t).flatMap((e,t)=>tb(e).map((e,r)=>{let n=`${t}-${r}`;return e.kind==="text"?/* @__PURE__ */E(Text,{style:c.paragraph,children:yb(e.text,v,k)},n):/* @__PURE__ */E(b,{style:c.list,children:e.items.map((t,r)=>/* @__PURE__ */O(b,{style:c.listItem,children:[
257
+ return E(Text,{style:zb,accessibilityRole:"link",accessibilityLabel:e.text,onPress:()=>r.open(t),children:e.text},n)}default:return e.text}}):e}var Fb=10.5,Lb=16,Eb=12,Ob=38,Ab=11,jb=15,Db=22,Mb=32,Bb=13.5,Hb=14,Wb=15,Nb=16,Ub=13,$b=13,Vb=26,qb=21,Gb=42,Kb=1,Yb=.06,Qb=.07,Zb=.12,Jb="45%";function Xb(){let e=useEverfurTheme(),t=n(()=>ey(e),[e]);return{theme:e,styles:t}}function Chevron({options:e,color:t}){let r=/* @__PURE__ */E(ChevronGlyph,{size:Nb,color:t,strokeWidth:2,direction:"right"}),n=e?.renderIcon;return n===void 0?r:/* @__PURE__ */E(HostRender,{render:()=>n("chevron"),fallback:r})}function AnswerCard({card:e,options:t}){let{theme:r,styles:n}=Xb();if(e.render!==void 0){let r=e.render;/* @__PURE__ */
258
+ return E(y,{style:[n.card,e.variant!==void 0?t?.styles?.cardVariant?.[e.variant]:null],accessible:false,accessibilityLabel:e.title,testID:"everfur-answer-host-card",children:/* @__PURE__ */E(HostRender,{render:r,fallback:null})})}let l=e.value!==void 0,i=t?.styles,o=[n.card,l?i?.cardStat:null,e.variant!==void 0?i?.cardVariant?.[e.variant]:null],a=e.tile?.tone,s=e.pill?.tone,u=e.tile?.imageUrl!==void 0?yb(e.tile.imageUrl):null,d=/* @__PURE__ */O(A,{children:[l?null:/* @__PURE__ */E(y,{style:[n.tile,a!==void 0?i?.tileTone?.[a]:null],children:u!==null?/* @__PURE__ */E(T,{source:{uri:u},style:n.tileImage,accessibilityIgnoresInvertColors:true}):e.tile?.icon??null}),
259
+ /* @__PURE__ */O(y,{style:n.cardWords,children:[
260
+ /* @__PURE__ */E(Text,{tier:"control",style:n.cardTitle,children:e.title}),e.meta!==void 0?/* @__PURE__ */E(Text,{tier:"compact",style:n.cardMeta,children:e.meta}):null]}),l?/* @__PURE__ */O(Text,{tier:"control",style:n.stat,children:[e.value?.amount,e.value?.unit!==void 0?/* @__PURE__ */E(Text,{style:n.statUnit,children:e.value.unit}):null]}):/* @__PURE__ */O(A,{children:[e.pill!==void 0?/* @__PURE__ */E(y,{style:[n.pill,s!==void 0?i?.pillTone?.[s]:null],children:/* @__PURE__ */E(Text,{tier:"badge",style:[n.pillText,s!==void 0?i?.pillToneText?.[s]:null],numberOfLines:1,ellipsizeMode:"tail",children:e.pill.label})}):null,e.onPress!==void 0?/* @__PURE__ */E(Chevron,{options:t,color:r.color.text.muted}):null]})]});if(e.onPress!==void 0){let t=e.onPress;/* @__PURE__ */
261
+ return E(w,{onPress:()=>{Vr(t)},accessibilityRole:"button",accessibilityLabel:e.title,style:o,children:d})}/* @__PURE__ */
262
+ return E(y,{style:o,children:d})}function CardsAnswer({message:e,text:t,streaming:r,messages:l,options:i,sentiment:o,onSentiment:a,sender:s,footer:u,onOpenUrl:d}){let{styles:c}=Xb(),p=n(()=>({answer:e.text,question:gb(l,e.id),messageId:e.id}),[e.text,e.id,l]),f=!r&&e.pending!==true,h=f?bb(i?.cards,p):[],g=n(()=>f?lb(e.citations):[],[f,e.citations]),b=i?.byline,m=i?.feedback!==void 0&&e.responseId!==void 0&&a!==void 0?i.feedback:null,v={bold:c.bold,italic:c.italic,code:c.code},w=io(),k=f?w:void 0;/* @__PURE__ */
263
+ return O(y,{style:c.answer,testID:"everfur-answer-cards",children:[b!==void 0?/* @__PURE__ */O(y,{style:c.byline,children:[b.icon??null,
264
+ /* @__PURE__ */E(Text,{tier:"compact",style:c.bylineText,children:b.label})]}):s,
265
+ /* @__PURE__ */E(y,{style:c.body,children:cb(t).flatMap((e,t)=>hb(e).map((e,r)=>{let n=`${t}-${r}`;return e.kind==="text"?/* @__PURE__ */E(Text,{style:c.paragraph,children:Pb(e.text,v,k)},n):/* @__PURE__ */E(y,{style:c.list,children:e.items.map((t,r)=>/* @__PURE__ */O(y,{style:c.listItem,children:[
266
266
  /* @__PURE__ */E(Text,{style:c.paragraph,children:e.ordered?`${e.start+r}.`:"•"}),
267
- /* @__PURE__ */E(Text,{style:[c.paragraph,c.listText],children:yb(t,v,k)})]},r))},n)}))}),h.length>0?/* @__PURE__ */E(b,{style:c.cards,children:h.map(e=>/* @__PURE__ */E(AnswerCard,{card:e,options:i},e.key))}):null,g.length>0?/* @__PURE__ */O(b,{style:c.cards,accessibilityLabel:Gg(g.length),children:[
268
- /* @__PURE__ */E(Text,{tier:"compact",style:c.label,children:Re.sourcesHeading}),g.map(e=>{let t=e.url;/* @__PURE__ */
269
- return E(AnswerCard,{card:{key:e.key,title:e.title,...e.meta!==null?{meta:e.meta}:{},tile:{icon:/* @__PURE__ */E(SourceTileGlyph,{})},...d!==void 0&&t!==null?{onPress:()=>d(t)}:{}},options:i},e.key)})]}):null,f&&m!==null&&a!==void 0?/* @__PURE__ */O(b,{style:[c.feedback,i?.styles?.feedback],children:[
267
+ /* @__PURE__ */E(Text,{style:[c.paragraph,c.listText],children:Pb(t,v,k)})]},r))},n)}))}),h.length>0?/* @__PURE__ */E(y,{style:c.cards,children:h.map(e=>/* @__PURE__ */E(AnswerCard,{card:e,options:i},e.key))}):null,g.length>0?/* @__PURE__ */O(y,{style:c.cards,accessibilityLabel:ob(g.length),children:[
268
+ /* @__PURE__ */E(Text,{tier:"compact",style:c.label,children:Me.sourcesHeading}),g.map(e=>{let t=e.url;/* @__PURE__ */
269
+ return E(AnswerCard,{card:{key:e.key,title:e.title,...e.meta!==null?{meta:e.meta}:{},tile:{icon:/* @__PURE__ */E(SourceTileGlyph,{})},...d!==void 0&&t!==null?{onPress:()=>d(t)}:{}},options:i},e.key)})]}):null,f&&m!==null&&a!==void 0?/* @__PURE__ */O(y,{style:[c.feedback,i?.styles?.feedback],children:[
270
270
  /* @__PURE__ */E(FeedbackChip,{label:m.helpful,on:o==="up",onPress:()=>a("up"),styles:c,host:i?.styles}),
271
271
  /* @__PURE__ */E(FeedbackChip,{label:m.notHelpful,on:o==="down",onPress:()=>a("down"),styles:c,host:i?.styles})]}):null,f?u(m===null):null]})}function SourceTileGlyph(){let e=useEverfurTheme();/* @__PURE__ */
272
- return E(BookGlyph,{size:Eb,color:e.color.linkInk,strokeWidth:1.5})}function FeedbackChip({label:e,on:t,onPress:r,styles:n,host:l}){/* @__PURE__ */
273
- return E(v,{onPress:r,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{selected:t},style:[n.chip,l?.feedbackChip,t?n.chipOn:null],hitSlop:(xs-Rb)/2,children:/* @__PURE__ */E(Text,{tier:"control",style:[n.chipText,l?.feedbackChipText],children:e})})}function CardsFollowUps({prompts:e,onSelectPrompt:t,label:r,actions:n,options:l}){let{theme:i,styles:o}=Hb();if(e.length===0&&n.length===0)return null;let a=l?.styles,s=r??Re.followUpsHeadingNative;/* @__PURE__ */
274
- return O(b,{style:[o.followUps,a?.followUps],accessibilityLabel:s,testID:"everfur-cards-follow-ups",children:[
275
- /* @__PURE__ */E(Text,{tier:"compact",style:[o.label,a?.followUpsLabel],accessibilityRole:"header",children:s}),n.map(e=>/* @__PURE__ */O(v,{onPress:()=>{Lr(e.onPress)},accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Ab,style:[o.row,o.rowAction,a?.followUp,a?.followUpAction],children:[e.icon??null,
272
+ return E(BookGlyph,{size:qb,color:e.color.linkInk,strokeWidth:1.5})}function FeedbackChip({label:e,on:t,onPress:r,styles:n,host:l}){/* @__PURE__ */
273
+ return E(w,{onPress:r,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{selected:t},style:[n.chip,l?.feedbackChip,t?n.chipOn:null],hitSlop:(Ds-Mb)/2,children:/* @__PURE__ */E(Text,{tier:"control",style:[n.chipText,l?.feedbackChipText],children:e})})}function CardsFollowUps({prompts:e,onSelectPrompt:t,label:r,actions:n,options:l}){let{theme:i,styles:o}=Xb();if(e.length===0&&n.length===0)return null;let a=l?.styles,s=r??Me.followUpsHeadingNative;/* @__PURE__ */
274
+ return O(y,{style:[o.followUps,a?.followUps],accessibilityLabel:s,testID:"everfur-cards-follow-ups",children:[
275
+ /* @__PURE__ */E(Text,{tier:"compact",style:[o.label,a?.followUpsLabel],accessibilityRole:"header",children:s}),n.map(e=>/* @__PURE__ */O(w,{onPress:()=>{Vr(e.onPress)},accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Kb,style:[o.row,o.rowAction,a?.followUp,a?.followUpAction],children:[e.icon??null,
276
276
  /* @__PURE__ */E(Text,{tier:"control",style:[o.rowText,o.rowTextAction,a?.followUpText,a?.followUpActionText],children:e.label}),
277
- /* @__PURE__ */E(Chevron,{options:l,color:i.color.text.primary})]},`action:${e.key}`)),e.map(e=>/* @__PURE__ */O(v,{onPress:()=>t(e),accessibilityRole:"button",accessibilityLabel:e,hitSlop:Ab,style:[o.row,a?.followUp],children:[
277
+ /* @__PURE__ */E(Chevron,{options:l,color:i.color.text.primary})]},`action:${e.key}`)),e.map(e=>/* @__PURE__ */O(w,{onPress:()=>t(e),accessibilityRole:"button",accessibilityLabel:e,hitSlop:Kb,style:[o.row,a?.followUp],children:[
278
278
  /* @__PURE__ */E(Text,{tier:"control",style:[o.rowText,a?.followUpText],children:e}),
279
- /* @__PURE__ */E(Chevron,{options:l,color:i.color.linkInk})]},e))]})}function CardsByline({label:e}){let{styles:t}=Hb();/* @__PURE__ */
280
- return E(b,{style:t.byline,children:/* @__PURE__ */E(Text,{tier:"compact",style:t.bylineText,children:e})})}function Wb(e){let t=e.color,r=e.space,n={...face(e,"mono"),fontSize:mb,textTransform:"uppercase",color:t.text.muted},l={borderWidth:1,borderColor:t.borderRingCream},i={borderWidth:1,borderColor:Va(t.text.primary,jb)??t.borderRingCream},o={shadowColor:t.text.primary,shadowOffset:{width:0,height:1},shadowOpacity:Db,shadowRadius:2,elevation:1},a=textRole(e,"message"),chipInk=Oo(e.slots.chip);return p.create({answer:{gap:r.md,alignSelf:"stretch"},byline:{flexDirection:"row",alignItems:"center",gap:10,minHeight:14},bylineText:{...n,letterSpacing:mb*.06,flexShrink:1},body:{gap:10},paragraph:{...face(e,"regular"),fontSize:a.fontSize,lineHeight:Math.round(a.lineHeight),color:t.text.primary},list:{gap:4},listItem:{flexDirection:"row",gap:r.sm,paddingLeft:r.xs},listText:{flex:1},bold:face(e,"bold"),italic:{fontStyle:"italic"},code:face(e,"mono"),cards:{gap:r.sm},card:{flexDirection:"row",alignItems:"center",gap:r.md,padding:wb,borderRadius:vb,backgroundColor:t.surface,...i,...o,minHeight:xs,...Lo(e.slots.card)},tile:{width:kb,height:kb,borderRadius:Cb,backgroundColor:Va(t.linkInk,Mb)??t.surfaceSubtle,alignItems:"center",justifyContent:"center",overflow:"hidden"},tileImage:{width:kb,height:kb},cardWords:{flex:1,minWidth:0},cardTitle:{...face(e,"bold"),fontSize:Sb,lineHeight:Math.round(Sb*1.25),color:t.text.primary,...Oo(e.slots.card)},cardMeta:{...n,letterSpacing:mb*.04,marginTop:3},stat:{...face(e,"mono"),fontSize:xb,color:t.text.primary},statUnit:{...face(e,"mono"),fontSize:mb+2,color:t.text.muted},pill:{minHeight:Lb,paddingHorizontal:10,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,justifyContent:"center",flexShrink:1,maxWidth:Bb},pillText:{...face(e,"bold"),fontSize:Fb,color:t.text.primary},feedback:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,alignItems:"center"},chip:{minHeight:Rb,paddingHorizontal:12,borderRadius:e.radius.pill,...l,justifyContent:"center"},chipOn:{backgroundColor:t.surfaceSubtle},chipText:{...Mf(e),fontSize:_b,color:t.text.primary,...chipInk},followUps:{gap:r.sm,alignSelf:"stretch",marginTop:r.xs},label:{...face(e,"bold"),fontSize:Pb,lineHeight:Math.round(Pb*1.5),color:t.text.muted,marginTop:2},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:Ob,paddingTop:11,paddingBottom:11,paddingRight:12,paddingLeft:14,borderRadius:Tb,backgroundColor:t.surface,...i},rowAction:{},rowText:{...Mf(e),flex:1,fontSize:zb,lineHeight:Math.round(zb*1.3),color:t.linkInk},rowTextAction:{color:t.text.primary}})}var Nb=/* @__PURE__ */Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" · ",answers:/* @__PURE__ */Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),Ub=/* @__PURE__ */Object.freeze(Xl.map(e=>/* @__PURE__ */Object.freeze({answer:e,label:Nb.answers[e]})));function $b(e,t){let[n,l]=i(null),[o,a]=i(null),[s,u]=i(null),d=r(r=>{t!==null&&(l(r),a(null),t(e.caseId,r).then(e=>{l(null),e.ok?u(r):a(e.error)}))},[t,e.caseId]),c=s??e.answer;return{answer:c,answerable:!isCheckinSettled(e),escalated:c==="worse",pending:n,error:o,choose:d}}var Vb=44,qb=.6,Gb=/* @__PURE__ */Object.freeze({caseId:"",answer:null,resolutionText:null,status:null});function CheckinCard({message:e,checkin:t,onAnswer:r,petRef:petRef,onFindVet:l,vet:i,onLayout:o,onOpen:a}){let s=useEverfurTheme(),u=n(()=>Kb(s),[s]),d=$b(t??Gb,t===null?null:r),c=d.answer!==null||d.pending!==null,p=t!==null&&r!==null&&d.answerable,f=t===null?null:Ag(t.openedAt,jg(e));/* @__PURE__ */
281
- return O(b,{style:u.card,accessibilityLabel:Nb.eyebrow,onLayout:o,children:[
282
- /* @__PURE__ */O(b,{style:u.head,children:[
283
- /* @__PURE__ */E(Text,{tier:"compact",style:u.eyebrow,children:Nb.eyebrow}),f!==null?/* @__PURE__ */E(Text,{tier:"compact",style:u.headDay,children:_e(Nb.day,{day:f})}):null]}),a?/* @__PURE__ */E(v,{onPress:a,accessibilityRole:"button",accessibilityLabel:e.text,style:u.open,children:/* @__PURE__ */E(Text,{style:[u.question,u.openText],children:e.text})}):/* @__PURE__ */E(Text,{style:u.question,accessibilityRole:"text",children:e.text}),p?/* @__PURE__ */E(b,{style:[u.row,d.pending?u.rowPending:null],children:Ub.map(({answer:e,label:t})=>{let r=(d.pending??d.answer)===e;/* @__PURE__ */
284
- return E(v,{onPress:()=>d.choose(e),disabled:c,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{selected:r,disabled:c,busy:d.pending===e},style:[u.pill,r?u.pillSelected:null],children:/* @__PURE__ */E(Text,{tier:"control",style:[u.pillLabel,r?u.pillLabelSelected:null],children:t})},e)})}):null,d.answer!==null?/* @__PURE__ */E(Text,{style:u.logged,children:Nb.logged}):null,d.escalated?/* @__PURE__ */E(CheckinFindVet,{petRef:petRef??null,onFindVet:l,vet:i,styles:u}):null,t?.resolutionText?/* @__PURE__ */E(Text,{style:u.resolution,children:t.resolutionText}):null,d.error?/* @__PURE__ */E(Text,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}function CheckinFindVet({petRef:petRef,onFindVet:e,vet:t,styles:r}){return useVetVisit(Zh(petRef,t)).available&&petRef!==null?/* @__PURE__ */E(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:Nb.findVet,...t?.returnTo!==void 0?{returnTo:t.returnTo}:{},...t?.usState!==void 0?{usState:t.usState}:{},...t?.prefer!==void 0?{prefer:t.prefer}:{},style:r.findVet,labelStyle:r.findVetLabel}):e===void 0?null:/* @__PURE__ */E(v,{onPress:e,accessibilityRole:"button",accessibilityLabel:Nb.findVet,style:r.findVet,children:/* @__PURE__ */E(Text,{tier:"control",style:r.findVetLabel,children:Nb.findVet})})}function Kb(e){let t=e.color,r=e.space,n=e.radius,l=e.type,i=Eo(e.slots.card),o=Oo(i);return p.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:p.hairlineWidth,borderColor:t.brandBorder,...Lo(i,p.hairlineWidth)},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...face(e,"regular"),color:t.text.secondary,fontSize:l.size.caption,letterSpacing:l.letterSpacing.eyebrow,textTransform:"uppercase",...o},headDay:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.caption,letterSpacing:l.letterSpacing.eyebrow,textTransform:"uppercase",...o},question:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.normal,...o},open:{minHeight:Vb,justifyContent:"center"},openText:{textDecorationLine:"underline"},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:qb},pill:{flex:1,minHeight:Vb,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.controlEdge,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brandInk},pillLabel:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...face(e,"regular"),color:t.text.secondary,fontSize:l.size.caption,...o},resolution:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.normal,...o},error:{...face(e,"regular"),color:t.danger,fontSize:l.size.caption},findVet:{alignSelf:"stretch",minHeight:Vb,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.controlEdge,backgroundColor:t.surface},findVetLabel:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.body}})}var Yb=244,Qb=8,Zb=13,Jb=14,Xb=.3,ey=-.24,ty=22,ry=10,ny=15;function CitationCards({citations:e,onOpenUrl:t}){let r=useEverfurTheme(),l=n(()=>ly(r),[r]),o=n(()=>Vg(e),[e]),[a,s]=i(false);if(o.length===0)return null;let u=o.length;/* @__PURE__ */
285
- return O(b,{style:l.block,children:[
286
- /* @__PURE__ */O(PressScale,{accessibilityRole:"button",accessibilityLabel:Kg(u,a),accessibilityState:{expanded:a},containerStyle:l.toggleSlot,style:l.togglePill,onPress:()=>s(e=>!e),children:[
287
- /* @__PURE__ */E(BookGlyph,{size:Zb,color:r.color.brandInk,strokeWidth:1.5}),
288
- /* @__PURE__ */E(Text,{tier:"compact",style:l.toggleLabel,children:Gg(u)}),
289
- /* @__PURE__ */E(ChevronGlyph,{size:Zb,color:r.color.brandInk,strokeWidth:1.5,direction:a?"up":"down"})]}),a?/* @__PURE__ */E(Deck,{cards:o,styles:l,open:t}):null]})}function Deck({cards:e,styles:t,open:r}){let n=no(),l=fo(n.citationsInMs,{risePx:n.citationsRisePx});/* @__PURE__ */
290
- return E(I.View,{style:l,children:/* @__PURE__ */E(S,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(e=>/* @__PURE__ */E(Card,{card:e,styles:t,open:r},e.key))})})}function Card({card:e,styles:t,open:r}){let n=useEverfurTheme(),l=e.url!==null&&r!==void 0,i=Yg(l?e:{...e,url:null}),o=/* @__PURE__ */O(A,{children:[
291
- /* @__PURE__ */O(b,{style:t.cardHeader,children:[
292
- /* @__PURE__ */E(b,{style:[t.tierDot,{backgroundColor:e.tierColor}]}),
293
- /* @__PURE__ */E(Text,{style:[t.cardTitle,l?t.cardTitleLink:null],numberOfLines:2,children:e.title}),l?/* @__PURE__ */E(ArrowUpRightGlyph,{size:Jb,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?/* @__PURE__ */E(Text,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?/* @__PURE__ */E(Text,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let n=e.url;/* @__PURE__ */
279
+ /* @__PURE__ */E(Chevron,{options:l,color:i.color.linkInk})]},e))]})}function CardsByline({label:e}){let{styles:t}=Xb();/* @__PURE__ */
280
+ return E(y,{style:t.byline,children:/* @__PURE__ */E(Text,{tier:"compact",style:t.bylineText,children:e})})}function ey(e){let t=e.color,r=e.space,n={...face(e,"mono"),fontSize:Fb,textTransform:"uppercase",color:t.text.muted},l={borderWidth:1,borderColor:t.borderRingCream},i={borderWidth:1,borderColor:ls(t.text.primary,Yb)??t.borderRingCream},o={shadowColor:t.text.primary,shadowOffset:{width:0,height:1},shadowOpacity:Qb,shadowRadius:2,elevation:1},a=textRole(e,"message"),chipInk=Go(e.slots.chip);return f.create({answer:{gap:r.md,alignSelf:"stretch"},byline:{flexDirection:"row",alignItems:"center",gap:10,minHeight:14},bylineText:{...n,letterSpacing:Fb*.06,flexShrink:1},body:{gap:10},paragraph:{...face(e,"regular"),fontSize:a.fontSize,lineHeight:Math.round(a.lineHeight),color:t.text.primary},list:{gap:4},listItem:{flexDirection:"row",gap:r.sm,paddingLeft:r.xs},listText:{flex:1},bold:face(e,"bold"),italic:{fontStyle:"italic"},code:face(e,"mono"),cards:{gap:r.sm},card:{flexDirection:"row",alignItems:"center",gap:r.md,padding:Eb,borderRadius:Lb,backgroundColor:t.surface,...i,...o,minHeight:Ds,...Vo(e.slots.card)},tile:{width:Ob,height:Ob,borderRadius:Ab,backgroundColor:ls(t.linkInk,Zb)??t.surfaceSubtle,alignItems:"center",justifyContent:"center",overflow:"hidden"},tileImage:{width:Ob,height:Ob},cardWords:{flex:1,minWidth:0},cardTitle:{...face(e,"bold"),fontSize:jb,lineHeight:Math.round(jb*1.25),color:t.text.primary,...Go(e.slots.card)},cardMeta:{...n,letterSpacing:Fb*.04,marginTop:3},stat:{...face(e,"mono"),fontSize:Db,color:t.text.primary},statUnit:{...face(e,"mono"),fontSize:Fb+2,color:t.text.muted},pill:{minHeight:Vb,paddingHorizontal:10,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,justifyContent:"center",flexShrink:1,maxWidth:Jb},pillText:{...face(e,"bold"),fontSize:$b,color:t.text.primary},feedback:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,alignItems:"center"},chip:{minHeight:Mb,paddingHorizontal:12,borderRadius:e.radius.pill,...l,justifyContent:"center"},chipOn:{backgroundColor:t.surfaceSubtle},chipText:{...Zf(e),fontSize:Bb,color:t.text.primary,...chipInk},followUps:{gap:r.sm,alignSelf:"stretch",marginTop:r.xs},label:{...face(e,"bold"),fontSize:Ub,lineHeight:Math.round(Ub*1.5),color:t.text.muted,marginTop:2},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:Gb,paddingTop:11,paddingBottom:11,paddingRight:12,paddingLeft:14,borderRadius:Hb,backgroundColor:t.surface,...i},rowAction:{},rowText:{...Zf(e),flex:1,fontSize:Wb,lineHeight:Math.round(Wb*1.3),color:t.linkInk},rowTextAction:{color:t.text.primary}})}var ty=/* @__PURE__ */Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" · ",answers:/* @__PURE__ */Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),ry=/* @__PURE__ */Object.freeze(pi.map(e=>/* @__PURE__ */Object.freeze({answer:e,label:ty.answers[e]})));function ny(e,t){let[n,l]=i(null),[o,a]=i(null),[s,u]=i(null),d=r(r=>{t!==null&&(l(r),a(null),t(e.caseId,r).then(e=>{l(null),e.ok?u(r):a(e.error)}))},[t,e.caseId]),c=s??e.answer;return{answer:c,answerable:!isCheckinSettled(e),escalated:c==="worse",pending:n,error:o,choose:d}}var ly=44,iy=.6,oy=/* @__PURE__ */Object.freeze({caseId:"",answer:null,resolutionText:null,status:null});function CheckinCard({message:e,checkin:t,onAnswer:r,petRef:petRef,onFindVet:l,vet:i,onLayout:o,onOpen:a}){let s=useEverfurTheme(),u=n(()=>ay(s),[s]),d=ny(t??oy,t===null?null:r),c=d.answer!==null||d.pending!==null,p=t!==null&&r!==null&&d.answerable,f=t===null?null:Kg(t.openedAt,Yg(e));/* @__PURE__ */
281
+ return O(y,{style:u.card,accessibilityLabel:ty.eyebrow,onLayout:o,children:[
282
+ /* @__PURE__ */O(y,{style:u.head,children:[
283
+ /* @__PURE__ */E(Text,{tier:"compact",style:u.eyebrow,children:ty.eyebrow}),f!==null?/* @__PURE__ */E(Text,{tier:"compact",style:u.headDay,children:Be(ty.day,{day:f})}):null]}),a?/* @__PURE__ */E(w,{onPress:a,accessibilityRole:"button",accessibilityLabel:e.text,style:u.open,children:/* @__PURE__ */E(Text,{style:[u.question,u.openText],children:e.text})}):/* @__PURE__ */E(Text,{style:u.question,accessibilityRole:"text",children:e.text}),p?/* @__PURE__ */E(y,{style:[u.row,d.pending?u.rowPending:null],children:ry.map(({answer:e,label:t})=>{let r=(d.pending??d.answer)===e;/* @__PURE__ */
284
+ return E(w,{onPress:()=>d.choose(e),disabled:c,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{selected:r,disabled:c,busy:d.pending===e},style:[u.pill,r?u.pillSelected:null],children:/* @__PURE__ */E(Text,{tier:"control",style:[u.pillLabel,r?u.pillLabelSelected:null],children:t})},e)})}):null,d.answer!==null?/* @__PURE__ */E(Text,{style:u.logged,children:ty.logged}):null,d.escalated?/* @__PURE__ */E(CheckinFindVet,{petRef:petRef??null,onFindVet:l,vet:i,styles:u}):null,t?.resolutionText?/* @__PURE__ */E(Text,{style:u.resolution,children:t.resolutionText}):null,d.error?/* @__PURE__ */E(Text,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}function CheckinFindVet({petRef:petRef,onFindVet:e,vet:t,styles:r}){return useVetVisit(dg(petRef,t)).available&&petRef!==null?/* @__PURE__ */E(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:ty.findVet,...t?.returnTo!==void 0?{returnTo:t.returnTo}:{},...t?.usState!==void 0?{usState:t.usState}:{},...t?.prefer!==void 0?{prefer:t.prefer}:{},style:r.findVet,labelStyle:r.findVetLabel}):e===void 0?null:/* @__PURE__ */E(w,{onPress:e,accessibilityRole:"button",accessibilityLabel:ty.findVet,style:r.findVet,children:/* @__PURE__ */E(Text,{tier:"control",style:r.findVetLabel,children:ty.findVet})})}function ay(e){let t=e.color,r=e.space,n=e.radius,l=e.type,i=qo(e.slots.card),o=Go(i);return f.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:f.hairlineWidth,borderColor:t.brandBorder,...Vo(i,f.hairlineWidth)},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...face(e,"regular"),color:t.text.secondary,fontSize:l.size.caption,letterSpacing:l.letterSpacing.eyebrow,textTransform:"uppercase",...o},headDay:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.caption,letterSpacing:l.letterSpacing.eyebrow,textTransform:"uppercase",...o},question:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.normal,...o},open:{minHeight:ly,justifyContent:"center"},openText:{textDecorationLine:"underline"},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:iy},pill:{flex:1,minHeight:ly,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.controlEdge,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brandInk},pillLabel:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...face(e,"regular"),color:t.text.secondary,fontSize:l.size.caption,...o},resolution:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.normal,...o},error:{...face(e,"regular"),color:t.danger,fontSize:l.size.caption},findVet:{alignSelf:"stretch",minHeight:ly,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.controlEdge,backgroundColor:t.surface},findVetLabel:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.body}})}var sy=244,uy=8,dy=13,cy=14,py=.3,fy=-.24,hy=22,gy=10,by=15;function CitationCards({citations:e,onOpenUrl:t}){let r=useEverfurTheme(),l=n(()=>yy(r),[r]),o=n(()=>lb(e),[e]),[a,s]=i(false);if(o.length===0)return null;let u=o.length;/* @__PURE__ */
285
+ return O(y,{style:l.block,children:[
286
+ /* @__PURE__ */O(PressScale,{accessibilityRole:"button",accessibilityLabel:ab(u,a),accessibilityState:{expanded:a},containerStyle:l.toggleSlot,style:l.togglePill,onPress:()=>s(e=>!e),children:[
287
+ /* @__PURE__ */E(BookGlyph,{size:dy,color:r.color.brandInk,strokeWidth:1.5}),
288
+ /* @__PURE__ */E(Text,{tier:"compact",style:l.toggleLabel,children:ob(u)}),
289
+ /* @__PURE__ */E(ChevronGlyph,{size:dy,color:r.color.brandInk,strokeWidth:1.5,direction:a?"up":"down"})]}),a?/* @__PURE__ */E(Deck,{cards:o,styles:l,open:t}):null]})}function Deck({cards:e,styles:t,open:r}){let n=yo(),l=To(n.citationsInMs,{risePx:n.citationsRisePx});/* @__PURE__ */
290
+ return E(P.View,{style:l,children:/* @__PURE__ */E(x,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(e=>/* @__PURE__ */E(Card,{card:e,styles:t,open:r},e.key))})})}function Card({card:e,styles:t,open:r}){let n=useEverfurTheme(),l=e.url!==null&&r!==void 0,i=sb(l?e:{...e,url:null}),o=/* @__PURE__ */O(A,{children:[
291
+ /* @__PURE__ */O(y,{style:t.cardHeader,children:[
292
+ /* @__PURE__ */E(y,{style:[t.tierDot,{backgroundColor:e.tierColor}]}),
293
+ /* @__PURE__ */E(Text,{style:[t.cardTitle,l?t.cardTitleLink:null],numberOfLines:2,children:e.title}),l?/* @__PURE__ */E(ArrowUpRightGlyph,{size:cy,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?/* @__PURE__ */E(Text,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?/* @__PURE__ */E(Text,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let n=e.url;/* @__PURE__ */
294
294
  return E(PressScale,{accessibilityRole:"link",accessibilityLabel:i,style:t.card,onPress:()=>r(n),children:o})}/* @__PURE__ */
295
- return E(b,{accessible:true,accessibilityRole:"text",accessibilityLabel:i,style:t.card,children:o})}function ly(e){let t=e.color,r=e.space,n=e.radius,l=e.type.size,i=Oo(e.slots.card);return p.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:{...face(e,"monoBold"),fontSize:l.micro,lineHeight:l.micro,letterSpacing:Xb,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:Yb,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2,...Lo(e.slots.card,1)},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:Qb,height:Qb,borderRadius:n.pill},cardTitle:{...headingFace(e,"bold"),flex:1,fontSize:l.bodyTight,lineHeight:ty,color:t.text.primary,letterSpacing:ey,...i},cardTitleLink:{color:t.linkInk},cardMeta:{...face(e,"monoMedium"),fontSize:l.nano,lineHeight:ry,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase",...i},cardExcerpt:{...face(e,"regular"),fontSize:l.tiny,lineHeight:ny,color:t.text.muted,...i}})}var iy=15,oy=44,ay=16,sy=/* @__PURE__ */Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function MessageFooter({message:e,onCopy:t,sentiment:r=null,onSentiment:a,note:s=null}){let u=useEverfurTheme(),d=n(()=>uy(u),[u]),c=no(),p=e.role==="user",f=n(()=>Dg(e.createdAt),[e.createdAt]),h=t!==void 0&&e.role!=="vet"&&e.text.length>0,g=e.role==="assistant"&&a!==void 0&&e.responseId!==void 0,[y,m]=i(false),w=l(null);o(()=>()=>{w.current&&clearTimeout(w.current)},[]);let k=()=>{t!==void 0&&(Ar(t,e.text),m(true),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{m(false),w.current=null},c.copiedMs))};return f===null&&!h&&!g?null:/* @__PURE__ */O(b,{style:d.wrap,children:[
296
- /* @__PURE__ */O(b,{style:[d.row,p?d.rowUser:d.rowAssistant],children:[f!==null?/* @__PURE__ */E(Text,{tier:"compact",style:d.timestamp,children:f}):null,h?/* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:y?Re.copied:p?Re.copyUserMessage:Re.copyAssistantMessage,onPress:k,style:d.iconHit,children:y?/* @__PURE__ */E(CheckGlyph,{size:iy,color:u.color.success,strokeWidth:2}):/* @__PURE__ */E(CopyGlyph,{size:iy,color:u.color.text.timestamp,strokeWidth:1.5})}):null,g?kp.map(({sentiment:e,label:t})=>/* @__PURE__ */E(v,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{selected:r===e},onPress:()=>a?.(e),style:d.iconHit,children:/* @__PURE__ */E(ThumbGlyph,{size:iy,color:r===e?u.color.sentiment[e]:u.color.text.timestamp,active:r===e,rotate:sy[e],strokeWidth:1.5})},e)):null]}),s==="thanks"?/* @__PURE__ */E(Text,{style:d.thanks,accessibilityLiveRegion:"polite",children:Re.feedbackThanks}):null,s==="failed"?/* @__PURE__ */O(A,{children:[
297
- /* @__PURE__ */E(Text,{style:d.failed,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:Re.feedbackFailed}),
298
- /* @__PURE__ */E(AnnounceLine,{line:Re.feedbackFailed})]}):null]})}function uy(e){let t=e.type;return p.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:ay,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...face(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:oy,height:oy,marginVertical:-28/2,alignItems:"center",justifyContent:"center"},thanks:{...face(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary},failed:{...face(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.danger}})}var dy=16,cy=10,py=12,fy=10,hy=2,gy=.06,by=34,yy=9,my=10.5,vy=.06,wy=15,ky=19.5,Cy=14,Sy=19.6;function OpeningCard({card:e,onLayout:t}){let r=useEverfurTheme(),l=n(()=>xy(r),[r]),i=e.styles;/* @__PURE__ */
299
- return O(b,{testID:"everfur-opening-card",onLayout:t,accessible:true,accessibilityLabel:[e.kicker,e.title,e.body].filter(e=>e!==void 0).join(", "),style:[l.card,i?.card],children:[e.icon!==void 0?/* @__PURE__ */E(b,{style:[l.icon,i?.icon],children:e.icon}):null,
300
- /* @__PURE__ */O(b,{style:l.words,children:[
295
+ return E(y,{accessible:true,accessibilityRole:"text",accessibilityLabel:i,style:t.card,children:o})}function yy(e){let t=e.color,r=e.space,n=e.radius,l=e.type.size,i=Go(e.slots.card);return f.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:{...face(e,"monoBold"),fontSize:l.micro,lineHeight:l.micro,letterSpacing:py,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:sy,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2,...Vo(e.slots.card,1)},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:uy,height:uy,borderRadius:n.pill},cardTitle:{...headingFace(e,"bold"),flex:1,fontSize:l.bodyTight,lineHeight:hy,color:t.text.primary,letterSpacing:fy,...i},cardTitleLink:{color:t.linkInk},cardMeta:{...face(e,"monoMedium"),fontSize:l.nano,lineHeight:gy,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase",...i},cardExcerpt:{...face(e,"regular"),fontSize:l.tiny,lineHeight:by,color:t.text.muted,...i}})}var my=15,vy=44,wy=16,ky=/* @__PURE__ */Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function MessageFooter({message:e,onCopy:t,sentiment:r=null,onSentiment:a,note:s=null}){let u=useEverfurTheme(),d=n(()=>Cy(u),[u]),c=yo(),p=e.role==="user",f=n(()=>Qg(e.createdAt),[e.createdAt]),h=t!==void 0&&e.role!=="vet"&&e.text.length>0,g=e.role==="assistant"&&a!==void 0&&e.responseId!==void 0,[b,m]=i(false),v=l(null);o(()=>()=>{v.current&&clearTimeout(v.current)},[]);let k=()=>{t!==void 0&&(Kr(t,e.text),m(true),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{m(false),v.current=null},c.copiedMs))};return f===null&&!h&&!g?null:/* @__PURE__ */O(y,{style:d.wrap,children:[
296
+ /* @__PURE__ */O(y,{style:[d.row,p?d.rowUser:d.rowAssistant],children:[f!==null?/* @__PURE__ */E(Text,{tier:"compact",style:d.timestamp,children:f}):null,h?/* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:b?Me.copied:p?Me.copyUserMessage:Me.copyAssistantMessage,onPress:k,style:d.iconHit,children:b?/* @__PURE__ */E(CheckGlyph,{size:my,color:u.color.success,strokeWidth:2}):/* @__PURE__ */E(CopyGlyph,{size:my,color:u.color.text.timestamp,strokeWidth:1.5})}):null,g?Op.map(({sentiment:e,label:t})=>/* @__PURE__ */E(w,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{selected:r===e},onPress:()=>a?.(e),style:d.iconHit,children:/* @__PURE__ */E(ThumbGlyph,{size:my,color:r===e?u.color.sentiment[e]:u.color.text.timestamp,active:r===e,rotate:ky[e],strokeWidth:1.5})},e)):null]}),s==="thanks"?/* @__PURE__ */E(Text,{style:d.thanks,accessibilityLiveRegion:"polite",children:Me.feedbackThanks}):null,s==="failed"?/* @__PURE__ */O(A,{children:[
297
+ /* @__PURE__ */E(Text,{style:d.failed,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:Me.feedbackFailed}),
298
+ /* @__PURE__ */E(AnnounceLine,{line:Me.feedbackFailed})]}):null]})}function Cy(e){let t=e.type;return f.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:wy,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...face(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:vy,height:vy,marginVertical:-28/2,alignItems:"center",justifyContent:"center"},thanks:{...face(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary},failed:{...face(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.danger}})}var Sy=16,xy=10,Ry=12,Ty=10,_y=2,zy=.06,Iy=34,Py=9,Fy=10.5,Ly=.06,Ey=15,Oy=19.5,Ay=14,jy=19.6;function OpeningCard({card:e,onLayout:t}){let r=useEverfurTheme(),l=n(()=>Dy(r),[r]),i=e.styles;/* @__PURE__ */
299
+ return O(y,{testID:"everfur-opening-card",onLayout:t,accessible:true,accessibilityLabel:[e.kicker,e.title,e.body].filter(e=>e!==void 0).join(", "),style:[l.card,i?.card],children:[e.icon!==void 0?/* @__PURE__ */E(y,{style:[l.icon,i?.icon],children:e.icon}):null,
300
+ /* @__PURE__ */O(y,{style:l.words,children:[
301
301
  /* @__PURE__ */E(Text,{tier:"compact",style:[l.kicker,i?.kicker],children:e.kicker}),
302
- /* @__PURE__ */E(Text,{tier:"control",style:[l.title,i?.title],children:e.title}),e.body!==void 0?/* @__PURE__ */E(Text,{style:[l.body,i?.body],children:e.body}):null]})]})}function xy(e){let t=e.color;return p.create({card:{flexDirection:"row",alignItems:"flex-start",gap:fy,paddingVertical:cy,paddingHorizontal:py,alignSelf:"stretch",borderRadius:dy,backgroundColor:t.surface,borderWidth:1,borderColor:Va(t.text.primary,gy)??t.borderRingCream},icon:{flexShrink:0,width:by,height:by,borderRadius:yy,backgroundColor:t.highlight,alignItems:"center",justifyContent:"center",overflow:"hidden"},words:{flex:1,minWidth:0,gap:hy},kicker:{...face(e,"mono"),fontSize:my,letterSpacing:my*vy,textTransform:"uppercase",color:t.text.muted},title:{...face(e,"bold"),fontSize:wy,lineHeight:ky,color:t.text.primary},body:{...face(e,"regular"),fontSize:Cy,lineHeight:Sy,color:t.text.secondary}})}var Ry="#10462E",_y="Book a video visit",Ty="#000000",zy="#83E0B4",Iy=/* @__PURE__ */Object.freeze([
302
+ /* @__PURE__ */E(Text,{tier:"control",style:[l.title,i?.title],children:e.title}),e.body!==void 0?/* @__PURE__ */E(Text,{style:[l.body,i?.body],children:e.body}):null]})]})}function Dy(e){let t=e.color;return f.create({card:{flexDirection:"row",alignItems:"flex-start",gap:Ty,paddingVertical:xy,paddingHorizontal:Ry,alignSelf:"stretch",borderRadius:Sy,backgroundColor:t.surface,borderWidth:1,borderColor:ls(t.text.primary,zy)??t.borderRingCream},icon:{flexShrink:0,width:Iy,height:Iy,borderRadius:Py,backgroundColor:t.highlight,alignItems:"center",justifyContent:"center",overflow:"hidden"},words:{flex:1,minWidth:0,gap:_y},kicker:{...face(e,"mono"),fontSize:Fy,letterSpacing:Fy*Ly,textTransform:"uppercase",color:t.text.muted},title:{...face(e,"bold"),fontSize:Ey,lineHeight:Oy,color:t.text.primary},body:{...face(e,"regular"),fontSize:Ay,lineHeight:jy,color:t.text.secondary}})}var My="#10462E",By="Book a video visit",Hy="#000000",Wy="#83E0B4",Ny=/* @__PURE__ */Object.freeze([
303
303
  /* @__PURE__ */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}),
304
- /* @__PURE__ */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:zy,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),
305
- /* @__PURE__ */Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:Ry,brandEdge:true,borderWidth:1}),
306
- /* @__PURE__ */Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}’s vet visit",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]);function Py(e,t){return e?null:{fill:t.fill,ink:t.ink}}var Fy=8;function Ly(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&t.length<=64&&!/[;{}<>]/u.test(t)?t:null}function Ey(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(t.length>=Fy)break;if(r===null||typeof r!="object"||typeof r.label!="string")continue;let e=r.label.trim();if(e.length===0)continue;let n=typeof r.prompt=="string"&&r.prompt.trim().length>0?r.prompt.trim():e,l=Ly(r.tint);t.push(/* @__PURE__ */Object.freeze({id:`starter-${t.length}`,label:e,prompt:n,tint:l,ink:l===null?null:Ly(r.ink)}))}return t.length>0?/* @__PURE__ */Object.freeze(t):null}var Oy=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function Ay(e){return e==null?e:e.replace(Oy,"").trim()}var jy=/* @__PURE__ */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 Dy(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return jy.has(t)}function My(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}function By(e,t){let r=e?.trim();if(r===void 0||r==="")return Hy(t);let n=t?.name?.trim()||Re.emptyTitlePetFallback,l=n.charAt(0).toUpperCase()+n.slice(1);return r.replace(/\{(pet|petName)\}/g,(e,t,r)=>r===0?l:n)}function Hy(e){let t=e?.name?.trim()||Re.emptyTitlePetFallback;return _e(Re.emptyTitle,{petName:t})}function Wy(e){let t=e.toLowerCase();return t===My("dog").toLowerCase()||t===My("cat").toLowerCase()}function Ny(e){let t=Ay(e);if(Dy(t))return null;let r=String(t).replace(/\s+/gu," ").trim();return Wy(r)?null:r}function Uy(e,t=Ry,r){let n=canonicalPetSpecies(e?.species),l=e?.name?.trim()||null,i=Ny(e?.breed),o=Ec(e?.ageYears),a=o===null?null:String(o),s=r?.vetPrepLabel?.trim()||null;/* @__PURE__ */
307
- return Object.freeze(Iy.flatMap(e=>{let r=e.intent==="vet_report"&&s!==null?s:e.label,o=r.includes("{breed}"),u=r.includes("{ageYears}"),d=e.fallbackLabel!==void 0&&(o&&!i||u&&!a)&&e.fallbackLabel?e.fallbackLabel:r;if(d.includes("{breed}")&&i===null||d.includes("{ageYears}")&&a===null||n===null&&(d.includes("{species}")||d.includes("{petName}")&&l===null))return[];let c=_e(d,{petName:l??(n==="cat"?"my cat":"my dog"),breed:i??"",species:n??"",ageYears:a??""}),p=!l&&d.startsWith("{petName}")?c.charAt(0).toUpperCase()+c.slice(1):c;return[/* @__PURE__ */Object.freeze({id:e.id,intent:e.intent,label:p,background:e.background,borderColor:e.brandEdge===true?t:e.borderColor,borderWidth:e.borderWidth})]}))}var $y=44,Vy=0,qy={top:3,bottom:3},Gy=1,Ky=.28,Yy=2,Qy=2,Zy=1.3,Jy=-.015,Xy=/* @__PURE__ */Object.freeze([
304
+ /* @__PURE__ */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:Wy,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),
305
+ /* @__PURE__ */Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:My,brandEdge:true,borderWidth:1}),
306
+ /* @__PURE__ */Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}’s vet visit",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]);function Uy(e,t){return e?null:{fill:t.fill,ink:t.ink}}var $y=8;function Vy(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&t.length<=64&&!/[;{}<>]/u.test(t)?t:null}function qy(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(t.length>=$y)break;if(r===null||typeof r!="object"||typeof r.label!="string")continue;let e=r.label.trim();if(e.length===0)continue;let n=typeof r.prompt=="string"&&r.prompt.trim().length>0?r.prompt.trim():e,l=Vy(r.tint);t.push(/* @__PURE__ */Object.freeze({id:`starter-${t.length}`,label:e,prompt:n,tint:l,ink:l===null?null:Vy(r.ink)}))}return t.length>0?/* @__PURE__ */Object.freeze(t):null}var Gy=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function Ky(e){return e==null?e:e.replace(Gy,"").trim()}var Yy=/* @__PURE__ */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 Qy(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return Yy.has(t)}function Zy(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}function Jy(e,t){let r=e?.trim();if(r===void 0||r==="")return Xy(t);let n=t?.name?.trim()||Me.emptyTitlePetFallback,l=n.charAt(0).toUpperCase()+n.slice(1);return r.replace(/\{(pet|petName)\}/g,(e,t,r)=>r===0?l:n)}function Xy(e){let t=e?.name?.trim()||Me.emptyTitlePetFallback;return Be(Me.emptyTitle,{petName:t})}function em(e){let t=e.toLowerCase();return t===Zy("dog").toLowerCase()||t===Zy("cat").toLowerCase()}function tm(e){let t=Ky(e);if(Qy(t))return null;let r=String(t).replace(/\s+/gu," ").trim();return em(r)?null:r}function rm(e,t=My,r){let n=canonicalPetSpecies(e?.species),l=e?.name?.trim()||null,i=tm(e?.breed),o=qc(e?.ageYears),a=o===null?null:String(o),s=r?.vetPrepLabel?.trim()||null;/* @__PURE__ */
307
+ return Object.freeze(Ny.flatMap(e=>{let r=e.intent==="vet_report"&&s!==null?s:e.label,o=r.includes("{breed}"),u=r.includes("{ageYears}"),d=e.fallbackLabel!==void 0&&(o&&!i||u&&!a)&&e.fallbackLabel?e.fallbackLabel:r;if(d.includes("{breed}")&&i===null||d.includes("{ageYears}")&&a===null||n===null&&(d.includes("{species}")||d.includes("{petName}")&&l===null))return[];let c=Be(d,{petName:l??(n==="cat"?"my cat":"my dog"),breed:i??"",species:n??"",ageYears:a??""}),p=!l&&d.startsWith("{petName}")?c.charAt(0).toUpperCase()+c.slice(1):c;return[/* @__PURE__ */Object.freeze({id:e.id,intent:e.intent,label:p,background:e.background,borderColor:e.brandEdge===true?t:e.borderColor,borderWidth:e.borderWidth})]}))}var nm=44,lm=0,im={top:3,bottom:3},om=1,am=.28,sm=2,um=2,dm=1.3,cm=-.015,pm=/* @__PURE__ */Object.freeze([
308
308
  /* @__PURE__ */Object.freeze({tint:"#FFE7A1",ink:"#262523"}),
309
309
  /* @__PURE__ */Object.freeze({tint:"#C8F4F8",ink:"#262523"}),
310
310
  /* @__PURE__ */Object.freeze({tint:"#DDEFC4",ink:"#262523"}),
311
- /* @__PURE__ */Object.freeze({tint:"#FFD8D6",ink:"#262523"})]);function QuickPrompts({pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:l,starterPrompts:i,emptyState:o,centered:a=false}){let s=useEverfurTheme(),u=n(()=>em(s),[s]),d=n(()=>Ey(i),[i]),c=n(()=>d!==null?d.map(e=>({prompt:{id:e.id,intent:"send",label:e.label,background:e.tint??s.color.highlight,borderColor:"transparent",borderWidth:1},send:e.prompt,paint:e.tint===null?null:{fill:e.tint,ink:e.ink??s.color.text.primary}})):Uy(e,s.color.brandInk,{vetPrepLabel:_y}).map(e=>({prompt:e,send:e.label,paint:null})),[d,e,s.color.brandInk,s.color.highlight,s.color.text.primary]),p=o?.chipTints!==void 0,f=n(()=>(o?.chipTints??(s.brightness==="light"?Xy:[])).filter(e=>typeof e.tint=="string"&&e.tint.trim()!==""),[o?.chipTints,s.brightness]),h=n(()=>f.length===0?c:c.map((e,t)=>{if(e.paint!==null)return e;let r=f[t%f.length];return{...e,paint:{fill:r.tint,ink:r.ink??s.color.text.primary},...p?{}:{cycleDefault:true}}}),[c,f,p,s.color.text.primary]),g=n(()=>Py(Pc(s),{fill:s.color.highlight,ink:s.color.onHighlight}),[s]),y=n(()=>({fill:s.color.highlight,ink:s.color.onHighlight}),[s.color.highlight,s.color.onHighlight]),m=By(o?.title,e),v=Bp(),w=Hp(),k=v!==null&&w!==null?/* @__PURE__ */E(w.Title,{text:m,style:[u.title,v.text(".serif",".ask-empty h2"),u.centerText],measureCh:w.titleCh}):/* @__PURE__ */E(Text,{tier:"heading",style:a?[u.title,u.centerText]:u.title,accessibilityRole:"header",children:m});/* @__PURE__ */
312
- return O(b,{style:v!==null?u.homeBlock:u.block,children:[k,
313
- /* @__PURE__ */E(b,{style:v!==null?[u.list,u.listCentered,v.view(".ask-chips",".ask-empty .ask-chips")]:a?[u.list,u.listCentered]:u.list,accessibilityLabel:Re.suggestions,children:h.map(({prompt:n,send:i,paint:o,cycleDefault:s},c)=>/* @__PURE__ */E(Chip,{prompt:n,send:i,themed:o??(d!==null?y:g),index:c,petRef:petRef,onSend:t,onVetPrep:r,vet:l,pet:e,styles:u,tinted:o!==null&&s!==true,soft:o!==null,centered:a},n.id))})]})}function Chip({prompt:e,send:t,themed:r,index:n,pet:l,petRef:petRef,onSend:i,onVetPrep:o,vet:a,styles:s,tinted:u,soft:d,centered:c}){let p=no(),f=fo(p.followUpInMs,{delayMs:to(p,n),risePx:p.promptRisePx}),h=Bp(),g=h!==null?[s.chipHome,h.view(".chip")]:c&&d?s.chipNoEdge:s.chipEdge,b={backgroundColor:r?.fill??e.background},y=s.chipSlot===null?b:u?{...s.chipSlot,...b}:{...b,...s.chipSlot},m=h!==null?[s.chipLabel,h.text(".chip")]:c?[s.chipLabel,s.centerText]:[s.chipLabel],v=h!==null?qy:Vy,w=r===null?s.chipSlotLabel===null?m:[...m,s.chipSlotLabel]:u?[...m,...s.chipSlotLabel===null?[]:[s.chipSlotLabel],{color:r.ink}]:[...m,{color:r.ink},...s.chipSlotLabel===null?[]:[s.chipSlotLabel]];return e.intent==="vet_report"?o!==void 0?/* @__PURE__ */E(I.View,{style:f,children:/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:v,style:[s.chip,g,y],onPress:()=>{Lr(o,l)},children:/* @__PURE__ */E(Text,{tier:"compact",style:w,children:e.label})})}):petRef===null?null:/* @__PURE__ */E(I.View,{style:f,children:/* @__PURE__ */E(VetVisitButtonCore,{entry:"chat",petRef:petRef,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:[s.chip,g,y],labelStyle:w})}):/* @__PURE__ */E(I.View,{style:f,children:/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:v,style:[s.chip,g,y],onPress:()=>i(t),children:/* @__PURE__ */E(Text,{tier:"compact",style:w,children:e.label})})})}function em(e){let t=Eo(e.slots.chip),r=Oo(t);return{chipSlot:t===void 0?null:Lo(t,Gy),chipSlotLabel:r.color===void 0?null:r,...tm(e)}}function tm(e){let t=e.color,r=e.space,n=e.type;return p.create({block:{gap:r.lg,alignItems:"stretch",width:"100%"},homeBlock:{alignItems:"stretch",width:"100%"},chipHome:{borderWidth:0,minHeight:0},title:{...headingFace(e,"medium"),fontSize:n.size.heading,lineHeight:Math.round(n.size.heading*n.lineHeight.snug),color:t.brandInk,letterSpacing:n.size.heading*Jy,textAlign:"left"},list:{width:"100%",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",gap:r.sm+Yy},listCentered:{flexDirection:"column",flexWrap:"nowrap",alignItems:"stretch"},centerText:{textAlign:"center"},chipNoEdge:{borderWidth:Gy,borderColor:"transparent"},chip:{borderRadius:e.radius.pill,paddingHorizontal:r.lg+Qy,paddingVertical:r.sm,minHeight:$y,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipEdge:{borderWidth:Gy,borderColor:Va(t.brandInk,Ky)??t.borderRingCream},chipLabel:{...face(e,"bold"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*Zy),color:Ty,textAlign:"left"}})}var rm=1e3,nm=150,lm=.25,im=.5,om=3;function TypingIndicator({petName:e=null,inline:t=false}){let{theme:r,styles:n}=gu(),i=r.motion.reducedMotion,a=ze(Re.reading,e),s=l(Array.from({length:om},()=>new I.Value(0))).current;return o(()=>{if(i)return;let e=s.map((e,t)=>I.loop(I.sequence([I.delay(t*nm),I.timing(e,{toValue:1,duration:rm*.4,useNativeDriver:true}),I.timing(e,{toValue:0,duration:rm*.6,useNativeDriver:true}),I.delay((om-t-1)*nm)])));for(let t of e)t.start();return()=>{for(let t of e)t.stop()}},[i,s]),/* @__PURE__ */E(b,{style:t?n.readingInline:n.readingBox,accessible:true,accessibilityRole:"text",accessibilityLabel:a,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:s.map((e,r)=>/* @__PURE__ */E(I.View,{accessibilityElementsHidden:true,importantForAccessibility:"no",style:[t?n.readingDotInline:n.readingDot,i?{opacity:im}:{opacity:e.interpolate({inputRange:[0,1],outputRange:[lm,1]}),transform:[{translateY:e.interpolate({inputRange:[0,1],outputRange:[0,-3]})}]}]},r))})}function am(e,t,r){let n=e-r,l=t!=null?Math.min(n,t):n;return Math.max(0,l)}function sm(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}}function um(e,t,r){let n=Math.max(0,r),l=e===null?n:Math.min(Math.max(0,e),n);return l>t+1?l:null}var dm=16;function cm(e,t,n=null){let i=l(null),a=l(true),s=l(t),u=l(0),d=l(0),c=l(0),p=l(/* @__PURE__ */new Map),f=l(null),h=l(false),g=e[0]?.id??null,b=l(g),y=l(null);o(()=>{let t=b.current;if(b.current=g,t===null||t===g||(y.current=null,a.current||!e.some(e=>e.id===t)))return;let r=p.current.get(t);r!==void 0&&(y.current={id:t,top:r,offset:u.current})},[g,e]);let m=sm(e),v=m===null?null:e[m.assistantIndex]?.id??null,w=m===null||m.userIndex===null?null:e[m.userIndex]?.id??null,k=r(()=>{let e=i.current;if(e===null||!a.current||d.current===0)return;let t=null;if(v!==null){let e=p.current.get(v);if(e===void 0)return;let r=w===null?null:p.current.get(w)??null;t=am(e,r,96)}let r=um(t,u.current,c.current-d.current);if(r!==null&&(u.current=r,e.scrollTo({y:r,animated:false})),!h.current||f.current===null)return;let n=um(f.current+dm-d.current,u.current,c.current-d.current);n!==null&&(u.current=n,e.scrollTo({y:n,animated:false}))},[v,w]);o(()=>{h.current=n!==null,n===null&&(f.current=null),k()},[n,k]),o(()=>{t&&!s.current&&(a.current=true,h.current=false),s.current=t,k()},[e,t,k]);let C=r(e=>{d.current=e.nativeEvent.layout.height,k()},[k]),S=r((e,t)=>{c.current=t,d.current>0&&(u.current=Math.min(u.current,Math.max(0,t-d.current))),k()},[k]),x=r(e=>{u.current=e.nativeEvent.contentOffset.y},[]),R=r(()=>{a.current=false,h.current=false},[]),_=r(e=>{let{contentOffset:t,contentSize:r,layoutMeasurement:n}=e.nativeEvent;u.current=t.y,a.current=r.height-t.y-n.height<=24},[]),T=r(e=>t=>{let r=t.nativeEvent.layout.y;p.current.set(e,r);let n=y.current;if(n!==null&&n.id===e&&r!==n.top){y.current=null;let e=Math.max(0,n.offset+r-n.top);u.current=e,i.current?.scrollTo({y:e,animated:false})}(e===v||e===w)&&k()},[v,w,k]),z=r(e=>{let{y:t,height:r}=e.nativeEvent.layout;f.current=t+r,k()},[k]);return{ref:i,onLayout:C,onContentSizeChange:S,onScroll:x,onScrollBeginDrag:R,onScrollEnd:_,rowLayout:T,asideLayout:z}}function pm(e,t,r){switch(e){case"loading":return r.renderPending?/* @__PURE__ */E(HostRender,{render:r.renderPending,fallback:/* @__PURE__ */E(LoadingState,{})}):/* @__PURE__ */E(LoadingState,{});case"empty":/* @__PURE__ */
311
+ /* @__PURE__ */Object.freeze({tint:"#FFD8D6",ink:"#262523"})]);function QuickPrompts({pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:l,starterPrompts:i,emptyState:o,centered:a=false}){let s=useEverfurTheme(),u=n(()=>fm(s),[s]),d=n(()=>qy(i),[i]),c=n(()=>d!==null?d.map(e=>({prompt:{id:e.id,intent:"send",label:e.label,background:e.tint??s.color.highlight,borderColor:"transparent",borderWidth:1},send:e.prompt,paint:e.tint===null?null:{fill:e.tint,ink:e.ink??s.color.text.primary}})):rm(e,s.color.brandInk,{vetPrepLabel:By}).map(e=>({prompt:e,send:e.label,paint:null})),[d,e,s.color.brandInk,s.color.highlight,s.color.text.primary]),p=o?.chipTints!==void 0,f=n(()=>(o?.chipTints??(s.brightness==="light"?pm:[])).filter(e=>typeof e.tint=="string"&&e.tint.trim()!==""),[o?.chipTints,s.brightness]),h=n(()=>f.length===0?c:c.map((e,t)=>{if(e.paint!==null)return e;let r=f[t%f.length];return{...e,paint:{fill:r.tint,ink:r.ink??s.color.text.primary},...p?{}:{cycleDefault:true}}}),[c,f,p,s.color.text.primary]),g=n(()=>Uy(Uc(s),{fill:s.color.highlight,ink:s.color.onHighlight}),[s]),b=n(()=>({fill:s.color.highlight,ink:s.color.onHighlight}),[s.color.highlight,s.color.onHighlight]),m=Jy(o?.title,e),v=Jp(),w=Xp(),k=v!==null&&w!==null?/* @__PURE__ */E(w.Title,{text:m,style:[u.title,v.text(".serif",".ask-empty h2"),u.centerText],measureCh:w.titleCh}):/* @__PURE__ */E(Text,{tier:"heading",style:a?[u.title,u.centerText]:u.title,accessibilityRole:"header",children:m});/* @__PURE__ */
312
+ return O(y,{style:v!==null?u.homeBlock:u.block,children:[k,
313
+ /* @__PURE__ */E(y,{style:v!==null?[u.list,u.listCentered,v.view(".ask-chips",".ask-empty .ask-chips")]:a?[u.list,u.listCentered]:u.list,accessibilityLabel:Me.suggestions,children:h.map(({prompt:n,send:i,paint:o,cycleDefault:s},c)=>/* @__PURE__ */E(Chip,{prompt:n,send:i,themed:o??(d!==null?b:g),index:c,petRef:petRef,onSend:t,onVetPrep:r,vet:l,pet:e,styles:u,tinted:o!==null&&s!==true,soft:o!==null,centered:a},n.id))})]})}function Chip({prompt:e,send:t,themed:r,index:n,pet:l,petRef:petRef,onSend:i,onVetPrep:o,vet:a,styles:s,tinted:u,soft:d,centered:c}){let p=yo(),f=To(p.followUpInMs,{delayMs:go(p,n),risePx:p.promptRisePx}),h=Jp(),g=h!==null?[s.chipHome,h.view(".chip")]:c&&d?s.chipNoEdge:s.chipEdge,b={backgroundColor:r?.fill??e.background},y=s.chipSlot===null?b:u?{...s.chipSlot,...b}:{...b,...s.chipSlot},m=h!==null?[s.chipLabel,h.text(".chip")]:c?[s.chipLabel,s.centerText]:[s.chipLabel],v=h!==null?im:lm,w=r===null?s.chipSlotLabel===null?m:[...m,s.chipSlotLabel]:u?[...m,...s.chipSlotLabel===null?[]:[s.chipSlotLabel],{color:r.ink}]:[...m,{color:r.ink},...s.chipSlotLabel===null?[]:[s.chipSlotLabel]];return e.intent==="vet_report"?o!==void 0?/* @__PURE__ */E(P.View,{style:f,children:/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:v,style:[s.chip,g,y],onPress:()=>{Vr(o,l)},children:/* @__PURE__ */E(Text,{tier:"compact",style:w,children:e.label})})}):petRef===null?null:/* @__PURE__ */E(P.View,{style:f,children:/* @__PURE__ */E(VetVisitButtonCore,{entry:"chat",petRef:petRef,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:[s.chip,g,y],labelStyle:w})}):/* @__PURE__ */E(P.View,{style:f,children:/* @__PURE__ */E(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:v,style:[s.chip,g,y],onPress:()=>i(t),children:/* @__PURE__ */E(Text,{tier:"compact",style:w,children:e.label})})})}function fm(e){let t=qo(e.slots.chip),r=Go(t);return{chipSlot:t===void 0?null:Vo(t,om),chipSlotLabel:r.color===void 0?null:r,...hm(e)}}function hm(e){let t=e.color,r=e.space,n=e.type;return f.create({block:{gap:r.lg,alignItems:"stretch",width:"100%"},homeBlock:{alignItems:"stretch",width:"100%"},chipHome:{borderWidth:0,minHeight:0},title:{...headingFace(e,"medium"),fontSize:n.size.heading,lineHeight:Math.round(n.size.heading*n.lineHeight.snug),color:t.brandInk,letterSpacing:n.size.heading*cm,textAlign:"left"},list:{width:"100%",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",gap:r.sm+sm},listCentered:{flexDirection:"column",flexWrap:"nowrap",alignItems:"stretch"},centerText:{textAlign:"center"},chipNoEdge:{borderWidth:om,borderColor:"transparent"},chip:{borderRadius:e.radius.pill,paddingHorizontal:r.lg+um,paddingVertical:r.sm,minHeight:nm,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipEdge:{borderWidth:om,borderColor:ls(t.brandInk,am)??t.borderRingCream},chipLabel:{...face(e,"bold"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*dm),color:Hy,textAlign:"left"}})}var gm=1e3,bm=150,ym=.25,mm=.5,vm=3;function TypingIndicator({petName:e=null,inline:t=false}){let{theme:r,styles:n}=zu(),i=r.motion.reducedMotion,a=We(Me.reading,e),s=l(Array.from({length:vm},()=>new P.Value(0))).current;return o(()=>{if(i)return;let e=s.map((e,t)=>P.loop(P.sequence([P.delay(t*bm),P.timing(e,{toValue:1,duration:gm*.4,useNativeDriver:true}),P.timing(e,{toValue:0,duration:gm*.6,useNativeDriver:true}),P.delay((vm-t-1)*bm)])));for(let t of e)t.start();return()=>{for(let t of e)t.stop()}},[i,s]),/* @__PURE__ */E(y,{style:t?n.readingInline:n.readingBox,accessible:true,accessibilityRole:"text",accessibilityLabel:a,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:s.map((e,r)=>/* @__PURE__ */E(P.View,{accessibilityElementsHidden:true,importantForAccessibility:"no",style:[t?n.readingDotInline:n.readingDot,i?{opacity:mm}:{opacity:e.interpolate({inputRange:[0,1],outputRange:[ym,1]}),transform:[{translateY:e.interpolate({inputRange:[0,1],outputRange:[0,-3]})}]}]},r))})}function wm(e,t,r){let n=e-r,l=t!=null?Math.min(n,t):n;return Math.max(0,l)}function km(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}}function Cm(e,t,r){let n=Math.max(0,r),l=e===null?n:Math.min(Math.max(0,e),n);return l>t+1?l:null}var Sm=16;function xm(e,t,n=null){let i=l(null),a=l(true),s=l(t),u=l(0),d=l(0),c=l(0),p=l(/* @__PURE__ */new Map),f=l(null),h=l(false),g=e[0]?.id??null,b=l(g),y=l(null);o(()=>{let t=b.current;if(b.current=g,t===null||t===g||(y.current=null,a.current||!e.some(e=>e.id===t)))return;let r=p.current.get(t);r!==void 0&&(y.current={id:t,top:r,offset:u.current})},[g,e]);let m=km(e),v=m===null?null:e[m.assistantIndex]?.id??null,w=m===null||m.userIndex===null?null:e[m.userIndex]?.id??null,k=r(()=>{let e=i.current;if(e===null||!a.current||d.current===0)return;let t=null;if(v!==null){let e=p.current.get(v);if(e===void 0)return;let r=w===null?null:p.current.get(w)??null;t=wm(e,r,96)}let r=Cm(t,u.current,c.current-d.current);if(r!==null&&(u.current=r,e.scrollTo({y:r,animated:false})),!h.current||f.current===null)return;let n=Cm(f.current+Sm-d.current,u.current,c.current-d.current);n!==null&&(u.current=n,e.scrollTo({y:n,animated:false}))},[v,w]);o(()=>{h.current=n!==null,n===null&&(f.current=null),k()},[n,k]),o(()=>{t&&!s.current&&(a.current=true,h.current=false),s.current=t,k()},[e,t,k]);let C=r(e=>{d.current=e.nativeEvent.layout.height,k()},[k]),S=r((e,t)=>{c.current=t,d.current>0&&(u.current=Math.min(u.current,Math.max(0,t-d.current))),k()},[k]),x=r(e=>{u.current=e.nativeEvent.contentOffset.y},[]),R=r(()=>{a.current=false,h.current=false},[]),T=r(e=>{let{contentOffset:t,contentSize:r,layoutMeasurement:n}=e.nativeEvent;u.current=t.y,a.current=r.height-t.y-n.height<=24},[]),_=r(e=>t=>{let r=t.nativeEvent.layout.y;p.current.set(e,r);let n=y.current;if(n!==null&&n.id===e&&r!==n.top){y.current=null;let e=Math.max(0,n.offset+r-n.top);u.current=e,i.current?.scrollTo({y:e,animated:false})}(e===v||e===w)&&k()},[v,w,k]),z=r(e=>{let{y:t,height:r}=e.nativeEvent.layout;f.current=t+r,k()},[k]);return{ref:i,onLayout:C,onContentSizeChange:S,onScroll:x,onScrollBeginDrag:R,onScrollEnd:T,rowLayout:_,asideLayout:z}}function Rm(e,t,r){switch(e){case"loading":return r.renderPending?/* @__PURE__ */E(HostRender,{render:r.renderPending,fallback:/* @__PURE__ */E(LoadingState,{})}):/* @__PURE__ */E(LoadingState,{});case"empty":/* @__PURE__ */
314
314
  return E(EmptyState,{pet:r.shownPet,petRef:t.petRef,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet,top:r.threadTop,pendingCheckin:r.pendingCheckin??null,topCard:r.topCard,starterPrompts:r.starterPrompts,emptyState:r.emptyState,centered:r.emptyCentered===true,renderEmptyHeader:r.renderEmptyHeader});case"error":/* @__PURE__ */
315
315
  return E(ErrorState,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case"populated":/* @__PURE__ */
316
- return E(PopulatedState,{messages:t.messages,prompts:pn(t,r.followUpPolicy),actions:r.answerCards?ib(t,r.answerCards):hm,answerCards:r.answerCards??null,threadTop:r.threadTop,pendingCheckin:r.pendingCheckin??null,threadAside:r.threadAside,threadAsideKey:r.threadAsideKey??null,onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,feedbackNote:r.feedbackNote,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,followUpLabel:r.followUpPolicy?.label,openingCard:r.openingCard,earlier:t.historyCursor?{loading:t.isLoadingHistory,load:t.loadOlderMessages}:null});default:return assertNever(e)}}function LoadingState(){let{theme:e,styles:t}=gu(),[r,n]=i(false);return o(()=>{let e=setTimeout(()=>n(true),ks);return()=>clearTimeout(e)},[]),/* @__PURE__ */E(b,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:Re.loading,children:r?/* @__PURE__ */E(x,{color:e.color.brandInk}):null})}function EmptyState({pet:e,petRef:petRef,onSelectPrompt:t,onVetPrep:r,vet:n,top:l,topCard:i,pendingCheckin:o,starterPrompts:a,emptyState:s,centered:u,renderEmptyHeader:d}){let{styles:c}=gu(),p=Bp(),f=d===void 0?null:/* @__PURE__ */E(b,{testID:"everfur-empty-header",children:/* @__PURE__ */E(HostRender,{render:()=>d({ask:t}),fallback:null})});if(p!==null){let{minHeight:u,...d}=p.view(".ask-empty");/* @__PURE__ */
317
- return O(S,{contentContainerStyle:[d,c.homeEmpty],keyboardShouldPersistTaps:"handled",keyboardDismissMode:bm,nestedScrollEnabled:true,accessibilityLabel:Re.empty,children:[l!=null?/* @__PURE__ */E(b,{style:p.view(".ask-top"),children:l}):null,o,i??null,f,
318
- /* @__PURE__ */E(b,{style:p.view(".ask-start"),children:/* @__PURE__ */E(QuickPrompts,{pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:a,emptyState:s,centered:true})})]})}
316
+ return E(PopulatedState,{messages:t.messages,prompts:Rn(t,r.followUpPolicy),actions:r.answerCards?mb(t,r.answerCards):_m,answerCards:r.answerCards??null,threadTop:r.threadTop,pendingCheckin:r.pendingCheckin??null,threadAside:r.threadAside,threadAsideKey:r.threadAsideKey??null,onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,feedbackNote:r.feedbackNote,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,followUpLabel:r.followUpPolicy?.label,openingCard:r.openingCard,earlier:t.historyCursor?{loading:t.isLoadingHistory,load:t.loadOlderMessages}:null});default:return assertNever(e)}}function LoadingState(){let{theme:e,styles:t}=zu(),[r,n]=i(false);return o(()=>{let e=setTimeout(()=>n(true),Os);return()=>clearTimeout(e)},[]),/* @__PURE__ */E(y,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:Me.loading,children:r?/* @__PURE__ */E(R,{color:e.color.brandInk}):null})}function EmptyState({pet:e,petRef:petRef,onSelectPrompt:t,onVetPrep:r,vet:n,top:l,topCard:i,pendingCheckin:o,starterPrompts:a,emptyState:s,centered:u,renderEmptyHeader:d}){let{styles:c}=zu(),p=Jp(),f=d===void 0?null:/* @__PURE__ */E(y,{testID:"everfur-empty-header",children:/* @__PURE__ */E(HostRender,{render:()=>d({ask:t}),fallback:null})});if(p!==null){let{minHeight:u,...d}=p.view(".ask-empty");/* @__PURE__ */
317
+ return O(x,{contentContainerStyle:[d,c.homeEmpty],keyboardShouldPersistTaps:"handled",keyboardDismissMode:Im,nestedScrollEnabled:true,accessibilityLabel:Me.empty,children:[l!=null?/* @__PURE__ */E(y,{style:p.view(".ask-top"),children:l}):null,o,i??null,f,
318
+ /* @__PURE__ */E(y,{style:p.view(".ask-start"),children:/* @__PURE__ */E(QuickPrompts,{pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:a,emptyState:s,centered:true})})]})}
319
319
  /* @__PURE__ */
320
- return O(S,{contentContainerStyle:c.emptyContent,keyboardShouldPersistTaps:"handled",keyboardDismissMode:bm,nestedScrollEnabled:true,accessibilityLabel:Re.empty,children:[l??null,o,i??null,f,
321
- /* @__PURE__ */E(QuickPrompts,{pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:a,emptyState:s,centered:u})]})}function FollowUps({prompts:e,onSelectPrompt:t,label:r}){let{styles:n}=gu();return e.length===0?null:/* @__PURE__ */O(b,{style:n.followUps,children:[
322
- /* @__PURE__ */E(Text,{tier:"compact",style:n.followUpsHeading,accessibilityRole:"header",children:r??Re.followUpsHeadingNative}),e.map((e,r)=>/* @__PURE__ */E(FollowUpRow,{prompt:e,index:r,onSelectPrompt:t},e))]})}function FollowUpRow({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:l}=gu(),i=no(),o=fo(i.followUpInMs,{delayMs:to(i,t)});/* @__PURE__ */
323
- return E(I.View,{style:o,children:/* @__PURE__ */O(PressScale,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:[l.followUpSlot,t>0?l.followUpSlotRuled:null],style:l.followUpRow,children:[
320
+ return O(x,{contentContainerStyle:c.emptyContent,keyboardShouldPersistTaps:"handled",keyboardDismissMode:Im,nestedScrollEnabled:true,accessibilityLabel:Me.empty,children:[l??null,o,i??null,f,
321
+ /* @__PURE__ */E(QuickPrompts,{pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:a,emptyState:s,centered:u})]})}function FollowUps({prompts:e,onSelectPrompt:t,label:r}){let{styles:n}=zu();return e.length===0?null:/* @__PURE__ */O(y,{style:n.followUps,children:[
322
+ /* @__PURE__ */E(Text,{tier:"compact",style:n.followUpsHeading,accessibilityRole:"header",children:r??Me.followUpsHeadingNative}),e.map((e,r)=>/* @__PURE__ */E(FollowUpRow,{prompt:e,index:r,onSelectPrompt:t},e))]})}function FollowUpRow({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:l}=zu(),i=yo(),o=To(i.followUpInMs,{delayMs:go(i,t)});/* @__PURE__ */
323
+ return E(P.View,{style:o,children:/* @__PURE__ */O(PressScale,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:[l.followUpSlot,t>0?l.followUpSlotRuled:null],style:l.followUpRow,children:[
324
324
  /* @__PURE__ */E(Text,{tier:"control",style:l.followUpText,children:e}),
325
- /* @__PURE__ */E(PlusGlyph,{size:ym,color:n.slots.chip?.textColor??n.color.text.muted,strokeWidth:1.75})]})})}function ErrorState({error:e,onRetry:t,onAddPet:r}){let{styles:n}=gu(),l=Tl(e)?Or(r):void 0,i=rn(e);/* @__PURE__ */
326
- return O(b,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[i!==null?/* @__PURE__ */E(Text,{style:n.errorText,testID:"everfur-chat-cap-reached",children:i.reached}):null,
327
- /* @__PURE__ */E(Text,{style:n.errorText,children:e.displayMessage}),i!==null&&i.guidance!==null?/* @__PURE__ */E(Text,{style:n.errorText,testID:"everfur-chat-cap-guidance",children:i.guidance}):null,l!==void 0?/* @__PURE__ */E(v,{onPress:l,accessibilityRole:"button",accessibilityLabel:Re.addPet,style:n.retryButton,children:/* @__PURE__ */E(Text,{tier:"control",style:n.retryLabel,children:Re.addPet})}):null,e.retryable?/* @__PURE__ */E(v,{onPress:t,accessibilityRole:"button",accessibilityLabel:Re.retry,style:n.retryButton,children:/* @__PURE__ */E(Text,{tier:"control",style:n.retryLabel,children:Re.retry})}):null]})}function PopulatedState({messages:e,prompts:t,onSelectPrompt:r,isStreaming:l,onAnswerCheckin:i,onCopy:o,sentimentByMessage:a,onSentiment:s,feedbackNote:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:f,onRetry:h,onStartNew:g,petRef:petRef,onFindVet:y,vet:m,onOpenUrl:w,petName:k,actions:C,answerCards:x,threadTop:R,pendingCheckin:_,threadAside:T,threadAsideKey:z,followUpLabel:I,openingCard:P,earlier:F}){let{styles:L}=gu(),A=no();ko(e.length,A);let j=n(()=>Lg(Fg(e)),[e]),D=on(e,l),M=e[e.length-1],B=T??null,H=cm(e,l,B===null?null:z??"shown"),W=bo(e),N=e[0],U=P!==void 0&&N!==void 0&&N.role==="user"&&N.text.trim()===P.prompt?N.id:null;/* @__PURE__ */
328
- return O(S,{ref:H.ref,style:L.list,contentContainerStyle:x!==null?L.listContentCards:L.listContent,accessibilityLabel:Re.transcript,keyboardShouldPersistTaps:"handled",keyboardDismissMode:bm,nestedScrollEnabled:true,onLayout:H.onLayout,onContentSizeChange:H.onContentSizeChange,onScroll:H.onScroll,scrollEventThrottle:gm,onScrollBeginDrag:H.onScrollBeginDrag,onScrollEndDrag:H.onScrollEnd,onMomentumScrollEnd:H.onScrollEnd,children:[R??null,_,F!==null?/* @__PURE__ */E(v,{onPress:()=>{F.load()},disabled:F.loading,accessibilityRole:"button",accessibilityLabel:F.loading?bi.loadingEarlier:bi.earlier,accessibilityState:{disabled:F.loading,busy:F.loading},hitSlop:Ws,style:L.earlierButton,children:/* @__PURE__ */E(Text,{tier:"compact",style:L.earlierLabel,children:F.loading?bi.loadingEarlier:bi.earlier})}):null,e.map(t=>t.id===U&&P!==void 0?/* @__PURE__ */E(OpeningCard,{card:P.card,onLayout:H.rowLayout(t.id)},t.id):t.checkin&&j.has(t.id)?/* @__PURE__ */E(CheckinCard,{message:t,checkin:t.checkin,onAnswer:i,petRef:petRef,onFindVet:y,vet:m,onLayout:H.rowLayout(t.id)},t.id):/* @__PURE__ */E(MessageRow,{onLayout:H.rowLayout(t.id),message:t,revealing:l&&t===M&&t.role==="assistant",onCopy:o,sentiment:t.responseId===void 0?null:a[String(t.responseId)]??null,onSentiment:s,note:t.responseId!==void 0&&u?.responseId===String(t.responseId)?u.kind:null,images:d[t.id]??fm,onPreview:c,onOpenUrl:w,entering:W(t.id),answerCards:x,messages:e},t.id)),f?/* @__PURE__ */E(Text,{tier:"compact",style:L.reconnectingCaption,accessibilityRole:"text",children:Re.reconnecting}):null,D?/* @__PURE__ */E(TypingIndicator,{petName:k,inline:x!==null}):null,p!==null?/* @__PURE__ */E(TurnNoticeCard,{notice:p,onRetry:h,onStartNew:g}):null,x!==null?/* @__PURE__ */E(CardsFollowUps,{prompts:t,onSelectPrompt:r,label:I,actions:C,options:x}):/* @__PURE__ */E(FollowUps,{prompts:t,onSelectPrompt:r,label:I}),B!==null?/* @__PURE__ */E(b,{onLayout:H.asideLayout,children:B}):null]})}function TurnNoticeCard({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=gu(),l=e.tone==="error";/* @__PURE__ */
329
- return O(b,{style:[n.turnNotice,l?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[
325
+ /* @__PURE__ */E(PlusGlyph,{size:Pm,color:n.slots.chip?.textColor??n.color.text.muted,strokeWidth:1.75})]})})}function ErrorState({error:e,onRetry:t,onAddPet:r}){let{styles:n}=zu(),l=Hl(e)?Gr(r):void 0,i=bn(e);/* @__PURE__ */
326
+ return O(y,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[i!==null?/* @__PURE__ */E(Text,{style:n.errorText,testID:"everfur-chat-cap-reached",children:i.reached}):null,
327
+ /* @__PURE__ */E(Text,{style:n.errorText,children:e.displayMessage}),i!==null&&i.guidance!==null?/* @__PURE__ */E(Text,{style:n.errorText,testID:"everfur-chat-cap-guidance",children:i.guidance}):null,l!==void 0?/* @__PURE__ */E(w,{onPress:l,accessibilityRole:"button",accessibilityLabel:Me.addPet,style:n.retryButton,children:/* @__PURE__ */E(Text,{tier:"control",style:n.retryLabel,children:Me.addPet})}):null,e.retryable?/* @__PURE__ */E(w,{onPress:t,accessibilityRole:"button",accessibilityLabel:Me.retry,style:n.retryButton,children:/* @__PURE__ */E(Text,{tier:"control",style:n.retryLabel,children:Me.retry})}):null]})}function PopulatedState({messages:e,prompts:t,onSelectPrompt:r,isStreaming:l,onAnswerCheckin:i,onCopy:o,sentimentByMessage:a,onSentiment:s,feedbackNote:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:f,onRetry:h,onStartNew:g,petRef:petRef,onFindVet:b,vet:m,onOpenUrl:v,petName:k,actions:C,answerCards:S,threadTop:R,pendingCheckin:T,threadAside:_,threadAsideKey:z,followUpLabel:I,openingCard:P,earlier:F}){let{styles:L}=zu(),A=yo();Oo(e.length,A);let j=n(()=>Vg($g(e)),[e]),D=vn(e,l),M=e[e.length-1],B=_??null,H=xm(e,l,B===null?null:z??"shown"),W=Io(e),N=e[0],U=P!==void 0&&N!==void 0&&N.role==="user"&&N.text.trim()===P.prompt?N.id:null;/* @__PURE__ */
328
+ return O(x,{ref:H.ref,style:L.list,contentContainerStyle:S!==null?L.listContentCards:L.listContent,accessibilityLabel:Me.transcript,keyboardShouldPersistTaps:"handled",keyboardDismissMode:Im,nestedScrollEnabled:true,onLayout:H.onLayout,onContentSizeChange:H.onContentSizeChange,onScroll:H.onScroll,scrollEventThrottle:zm,onScrollBeginDrag:H.onScrollBeginDrag,onScrollEndDrag:H.onScrollEnd,onMomentumScrollEnd:H.onScrollEnd,children:[R??null,T,F!==null?/* @__PURE__ */E(w,{onPress:()=>{F.load()},disabled:F.loading,accessibilityRole:"button",accessibilityLabel:F.loading?Ii.loadingEarlier:Ii.earlier,accessibilityState:{disabled:F.loading,busy:F.loading},hitSlop:eu,style:L.earlierButton,children:/* @__PURE__ */E(Text,{tier:"compact",style:L.earlierLabel,children:F.loading?Ii.loadingEarlier:Ii.earlier})}):null,e.map(t=>t.id===U&&P!==void 0?/* @__PURE__ */E(OpeningCard,{card:P.card,onLayout:H.rowLayout(t.id)},t.id):t.checkin&&j.has(t.id)?/* @__PURE__ */E(CheckinCard,{message:t,checkin:t.checkin,onAnswer:i,petRef:petRef,onFindVet:b,vet:m,onLayout:H.rowLayout(t.id)},t.id):/* @__PURE__ */E(MessageRow,{onLayout:H.rowLayout(t.id),message:t,revealing:l&&t===M&&t.role==="assistant",onCopy:o,sentiment:t.responseId===void 0?null:a[String(t.responseId)]??null,onSentiment:s,note:t.responseId!==void 0&&u?.responseId===String(t.responseId)?u.kind:null,images:d[t.id]??Tm,onPreview:c,onOpenUrl:v,entering:W(t.id),answerCards:S,messages:e},t.id)),f?/* @__PURE__ */E(Text,{tier:"compact",style:L.reconnectingCaption,accessibilityRole:"text",children:Me.reconnecting}):null,D?/* @__PURE__ */E(TypingIndicator,{petName:k,inline:S!==null}):null,p!==null?/* @__PURE__ */E(TurnNoticeCard,{notice:p,onRetry:h,onStartNew:g}):null,S!==null?/* @__PURE__ */E(CardsFollowUps,{prompts:t,onSelectPrompt:r,label:I,actions:C,options:S}):/* @__PURE__ */E(FollowUps,{prompts:t,onSelectPrompt:r,label:I}),B!==null?/* @__PURE__ */E(y,{onLayout:H.asideLayout,children:B}):null]})}function TurnNoticeCard({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=zu(),l=e.tone==="error";/* @__PURE__ */
329
+ return O(y,{style:[n.turnNotice,l?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[
330
330
  /* @__PURE__ */E(Text,{tier:"control",style:[n.turnNoticeTitle,l?n.turnNoticeTitleError:null],children:e.title}),
331
331
  /* @__PURE__ */E(Text,{tier:"compact",style:n.turnNoticeBody,children:e.body}),e.guidance!==void 0?/* @__PURE__ */E(Text,{tier:"compact",style:n.turnNoticeBody,testID:"everfur-chat-cap-guidance",children:e.guidance}):null,
332
- /* @__PURE__ */E(v,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:Ws,style:n.turnNoticeAction,children:/* @__PURE__ */E(Text,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}var fm=/* @__PURE__ */Object.freeze([]),hm=/* @__PURE__ */Object.freeze([]),gm=16,bm=f.OS==="ios"?"interactive":"on-drag",ym=18;function MessageRow({message:e,revealing:t,onCopy:n,sentiment:l,onSentiment:i,note:o,images:a,onPreview:s,onOpenUrl:u,onLayout:d,entering:c,answerCards:p,messages:f}){let{theme:h,styles:g}=gu(),y=no(),m=go(c,y),v=mo(e.text,t,y),w=e.role==="user",k=e.role==="vet",C=e.role==="assistant",S=qi(),x=C&&!t?S:void 0,R=x!==void 0&&bb(e.text,x),_=C&&!h.meta.hidePoweredBy,T=w?Re.senderUser:k?fn(e):_?Re.assistantName:Re.senderAssistant,z=k?Dg(e.createdAt):null,P=r(t=>i(e,t),[i,e]),F=e.pending!==true,L=C&&h.meta.assistantAvatarUrl!==null?/* @__PURE__ */E(AssistantSender,{avatarUrl:h.meta.assistantAvatarUrl,named:_,styles:g}):_?p!==null?/* @__PURE__ */E(CardsByline,{label:Re.assistantName}):/* @__PURE__ */E(Text,{tier:"control",style:g.assistantName,children:Re.assistantName}):null,A=p!==null;return C&&p!==null?/* @__PURE__ */E(I.View,{style:[g.rowBlock,m],onLayout:d,accessibilityLabel:`${T}: ${e.text}`,children:/* @__PURE__ */E(CardsAnswer,{message:e,text:v,streaming:t,messages:f,options:p,sentiment:l,onSentiment:e.responseId===void 0?void 0:P,sender:L,onOpenUrl:u,footer:t=>/* @__PURE__ */E(MessageFooter,{message:e,onCopy:n,sentiment:l,onSentiment:t&&e.responseId!==void 0?P:void 0,note:o})})}):/* @__PURE__ */O(b,{style:[g.rowBlock,w?g.rowBlockUser:g.rowBlockAssistant],onLayout:d,children:[
333
- /* @__PURE__ */E(b,{style:[g.row,w?g.rowUser:g.rowAssistant],accessible:!R,accessibilityRole:R?void 0:"text",accessibilityLabel:R?void 0:`${T}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:/* @__PURE__ */O(I.View,{style:[g.bubble,A?g.bubbleCards:null,w?g.bubbleSideUser:null,m],children:[L,k?/* @__PURE__ */O(b,{style:g.vetHeader,children:[
334
- /* @__PURE__ */E(Text,{tier:"control",style:g.vetSender,children:T}),z!==null?/* @__PURE__ */E(Text,{tier:"compact",style:g.vetTime,children:z}):null]}):null,
335
- /* @__PURE__ */O(b,{style:[w?g.bubbleUser:k?g.bubbleVet:g.bubbleAssistant,w&&A?g.bubbleUserCards:null,e.pending?g.bubblePending:null],children:[w&&a.length>0?/* @__PURE__ */E(SentImages,{images:a,onPreview:e=>s({uri:e.uri,label:e.filename})}):null,
336
- /* @__PURE__ */E(Text,{style:w?A?[g.bubbleTextUser,g.bubbleTextUserCards]:g.bubbleTextUser:k?g.bubbleTextVet:g.bubbleTextAssistant,children:C?yb(v,{bold:g.bubbleBold,italic:g.bubbleItalic,code:g.bubbleCode},x):e.text})]})]})}),C&&!t?/* @__PURE__ */E(CitationCards,{citations:e.citations,onOpenUrl:u}):null,F&&!(w&&p!==null)?/* @__PURE__ */E(MessageFooter,{message:e,onCopy:n,sentiment:l,onSentiment:e.responseId===void 0?void 0:P,note:o}):null]})}var mm=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(e){if(e.isBootstrapping===true||e.isLoadingHistory===true||e.isStreaming===true||e.status==="error"||e.stopped===true)return false;let t=e.messages[e.messages.length-1];return t===void 0||t.role!=="assistant"||t.pending===true||t.checkin!==void 0||t.text.trim().length===0?false:!(typeof t.urgencyLevel=="string"&&mm.has(t.urgencyLevel))}var NO_SNAPSHOT2=()=>null;function vm(){let{runtime:e}=Oe(),t=e.entitlements??null,l=r(e=>t===null?()=>{}:t.subscribe(e),[t]),i=t===null?NO_SNAPSHOT2:t.getSnapshot,o=a(l,i,i);return n(()=>o!==null&&decideCapability("texting",o.decisions,{isPending:o.isPending}).enabled,[o])}var wm=/* @__PURE__ */Object.freeze({runner:null,line:null,entry:null,stage:null,headerEntry:null});function km(e,t,r=false){let[n,l]=i(null);if(!e)return wm;let o=/* @__PURE__ */E(AskRunner,{ready:textingAskThreadReady(t),onAsk:l,entry:r}),a=r&&n!==null&&n.canOpen?{label:j.textingAskLines(n).accept,onOpen:n.open}:null;if(n===null||n.stage==="hidden"||n.stage==="dismissed")return{runner:o,line:null,entry:null,stage:null,headerEntry:a};let s=j.textingAskLines(n),u=/* @__PURE__ */E(AskLine,{stage:n.stage,text:n.stage==="verified"?s.verified:s.line,accept:s.accept,dismiss:s.dismiss,onAccept:n.accept,onDismiss:n.dismiss}),d=n.stage==="enrolling"?/* @__PURE__ */E(j.ChatTextingAskComposer,{ask:n}):null;return{runner:o,line:u,entry:d,stage:n.stage,headerEntry:a}}function AskRunner({ready:e,onAsk:t,entry:r}){let{userRef:userRef}=Oe(),n=vm(),l=userRef!==null&&n;return o(()=>{l||t(null)},[l,t]),l?/* @__PURE__ */E(j.ChatTextingAskController,{enabled:true,ready:e,onAsk:t,entry:r}):null}function AskLine({stage:e,text:t,accept:r,dismiss:n,onAccept:l,onDismiss:i}){let{theme:o,styles:a}=gu(),s=!o.meta.hidePoweredBy,u=s?Re.assistantName:Re.senderAssistant,d=o.meta.assistantAvatarUrl!==null?/* @__PURE__ */E(AssistantSender,{avatarUrl:o.meta.assistantAvatarUrl,named:s,styles:a}):s?/* @__PURE__ */E(Text,{tier:"control",style:a.assistantName,children:Re.assistantName}):null;/* @__PURE__ */
337
- return O(b,{style:[a.rowBlock,a.rowBlockAssistant],testID:`everfur-texting-ask-${e}`,children:[
338
- /* @__PURE__ */E(b,{style:[a.row,a.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${u}: ${t}`,children:/* @__PURE__ */O(b,{style:a.bubble,children:[d,
339
- /* @__PURE__ */E(b,{style:a.bubbleAssistant,children:/* @__PURE__ */E(Text,{style:a.bubbleTextAssistant,children:t})})]})}),e==="offered"?/* @__PURE__ */E(b,{style:a.askChips,children:[{label:r,onPress:l,testID:"everfur-texting-ask-accept"},{label:n,onPress:i,testID:"everfur-texting-ask-dismiss"}].map(e=>/* @__PURE__ */E(PressScale,{onPress:e.onPress,accessibilityRole:"button",accessibilityLabel:e.label,style:a.askChip,testID:e.testID,children:/* @__PURE__ */E(Text,{tier:"control",style:a.askChipText,children:e.label})},e.testID))}):null]})}function Cm(){let e=/* @__PURE__ */Symbol.for("@everfur/sdk#SdkSurfaceHooks@v1"),t=globalThis;return t[e]??(t[e]=createContext(null))}var Sm=/* @__PURE__ */Cm();function xm(e){return typeof e=="object"&&e!==null&&e.ok===true}function Rm(e){if(typeof e!="object"||e===null)return null;let t=e;return t.ok!==false||typeof t.error!="object"||t.error===null?null:pt(t.error)}function _m(e){let t=s(Sm),n=t?.onMessageSent,l=t?.onFreeCapReached,i=r((...t)=>{let r=e(...t);return Promise.resolve(r).then(e=>{try{if(xm(e)){n?.();return}let t=l===void 0?null:Rm(e);t!==null&&l?.(t)}catch{}},()=>{}),r},[e,n,l]);return n===void 0&&l===void 0?e:i}function EverfurChatCore(e){let{style:t,renderPending:r}=e;/* @__PURE__ */
340
- return E(CapabilityGate,{capability:"chat",style:t,...r?{renderPending:r}:{},children:/* @__PURE__ */E(MessageLinksScope,{linkHosts:e.linkHosts,onOpenUrl:e.onOpenUrl,children:/* @__PURE__ */E(ChatBody,{...e})})})}function Tm(){try{return Oe()}catch{return null}}function zm(e){return en({...e.presentation,chatComposerMic:e.presentation?.chatComposerMic??(e.dictation===void 0?void 0:e.dictation!==false),chatComposerUpload:e.presentation?.chatComposerUpload??(e.attachments===void 0?void 0:true)})}function ChatBody(e){let t=Tm();return t===null?/* @__PURE__ */E(ChatBodyAlone,{...e}):/* @__PURE__ */E(ChatBodyInProvider,{...e,activePet:t.activePet,telemetry:t.runtime.registry?.services?.telemetry??null})}function ChatBodyAlone(e){let t=zm(e),r=JSON.stringify(t),l=e.petRef??null,i=n(()=>({presentation:resolvePresentation({server:null,locked:null,client:t}),isLocked:()=>false,planPage:null,planPetRef:l,inProvider:false,telemetry:null}),[r,l]);/* @__PURE__ */
341
- return E(ChatSurface,{...e,settings:i})}function ChatBodyInProvider({activePet:e,telemetry:t,...r}){let{presentation:l,isLocked:isLocked}=Xr(zm(r)),i=qr("healthPlan"),o=l.chatTopCard==="focus"&&r.topCard===void 0&&i,a=r.petRef??e??null,s=useHealthPlanPage({petRef:a,enabled:o}),u=o&&s.phase==="ready"?s.page:null,d=n(()=>({presentation:l,isLocked:isLocked,planPage:u,planPetRef:a,inProvider:true,telemetry:t}),[l,isLocked,u,a,t]);/* @__PURE__ */
342
- return E(ChatSurface,{...r,settings:d})}function ChatSurface({settings:e,petRef:petRef,conversationId:conversationId,style:t,renderPending:a,onCopy:s,onPetChange:u,onVetPrep:d,onFindVet:c,renderVetAction:p,attachments:h,pet:g,onAddPet:y,checkinTarget:v,handoffToken:w,initialAsk:k,initialAskKey:C,composerSeed:S,lifecycle:x,refreshIntervalMs:R,refreshesBlankThread:_,openUnreadOnRefresh:T,draftStore:z,vetReturnTo:I,vetUsState:P,vetPrefer:F,onOpenUrl:j,keyboardVerticalOffset:D,topCard:M,onOpenHealthPlan:B,answerCards:H,historySheet:W,historyBar:N,starterPrompts:U,emptyState:$,header:V=true,textingEntry:q=true,renderEmptyHeader:G,followUpPolicy:K,initialAskCard:Y}){let{presentation:Q,isLocked:isLocked,planPage:Z,planPetRef:J}=e,{theme:X,styles:ee}=gu(),te=Mp()??(Q.chatAnswerStyle==="cards"?Eh:null),re=n(()=>te===null?null:te(X),[te,X]),ne=useHostPoweredBy(),le=no(),ie=n(()=>hn(petRef,conversationId),[petRef,conversationId]),oe=useEverfurChat(ie),ae=_m(oe.send),se=n(()=>ae===oe.send?oe:{...oe,send:ae},[oe,ae]),ue=tn(se),de=Rg(),ce=Ri(se),pe=L(),fe=ln(se,"web"),he=n(()=>c===void 0?void 0:()=>{Lr(c,"emergency")},[c]),ge=n(()=>I===void 0&&P===void 0&&F===void 0?void 0:{returnTo:I,usState:P,prefer:F},[I,P,F]),be=mp(de.pets,se.petRef),ye=n(()=>Fi(se.messages,be?.name??null),[se.messages,be?.name]),me=Ei(ye);Tg(se),ko(me.showBanner,le);let ve=Tm(),we=fi(w,ve);gi(se.openCheckin,v??we,{petRef:se.petRef,pinned:petRef!==void 0,ready:!se.isBootstrapping,selectPet:e=>{de.setActivePet(e),Lr(u,e)}}),Dl(se.askEverfur,se.isBootstrapping,k,C);let ke=n(()=>jl(S),[S]),Ce=n(()=>jl(k),[k]),Se=n(()=>Y!==void 0&&Ce!==null?{card:Y,prompt:Ce}:void 0,[Y,Ce]),xe=n(()=>x===void 0?createAppStateLifecycle():x??void 0,[x]);Yl(xe,{conversationId:se.conversationId===null?null:String(se.conversationId),isTurnInFlight:se.isStreaming,refreshesBlankThread:_===true||T===true,refresh:se.refreshActiveThread===void 0?void 0:()=>se.refreshActiveThread?.(Nl(T===true,Ul(xe,Fo)))??Promise.resolve()},{intervalMs:R===void 0?3e4:R,isVisibleFallback:Fo}),$l({isStreaming:se.isStreaming,status:se.status,conversationId:se.conversationId===null?null:String(se.conversationId),unreadCount:se.unreadCount,markRead:se.markRead},()=>Ul(xe,Fo));let _e=se.pendingCheckin??null,Te=_e===null?null:/* @__PURE__ */E(b,{testID:"everfur-pending-checkin",accessibilityLiveRegion:"polite",children:/* @__PURE__ */E(CheckinCard,{message:_e.message,checkin:_e.checkin,onAnswer:se.petRef?se.answerCheckin:null,petRef:se.petRef,onFindVet:he,vet:ge,onOpen:()=>{se.resumeConversation(_e.conversationId)}})}),ze=(se.hasUnreadThreads??false)||ce.rows.some(e=>e.unreadCount!==null&&e.unreadCount>0)||(se.unreadCount??0)>0,Ie=Fl(se.messages),[Pe,Fe]=i(null),Le=r(()=>Fe(null),[]),[Ee,Oe]=i(null),[Ae,je]=i(null),De=l(null);o(()=>()=>{De.current&&clearTimeout(De.current)},[]);let Me=r((e,t)=>{je({responseId:String(e),kind:t}),De.current&&clearTimeout(De.current),De.current=t==="thanks"?setTimeout(()=>{je(null),De.current=null},Cs):null},[]),Be=r((e,t)=>{let r=e.responseId;if(r===void 0)return;let n=se.sentimentByMessage[String(r)];je(e=>e?.responseId===String(r)?null:e),se.feedback(r,t).then(e=>{e.ok||Me(r,"failed")}),t==="down"&&n!=="down"&&Oe(r)},[se,Me]),He=r(async(e,t)=>Ee===null||!(e==null&&t===null?{ok:true}:await se.feedback(Ee,"down",e??"other",t)).ok?false:(Oe(null),Me(Ee,"thanks"),true),[se,Ee,Me]),We=r(()=>Oe(null),[]),Ne=r(e=>{se.send(e)},[se.send]),Ue=n(()=>j===void 0?void 0:e=>{Lr(j,e,"citation")},[j]),$e=f.OS==="ios"?"padding":void 0,Ve=Nh(D,$e!==void 0),qe=Ve.topInWindow===null?pe.top:Math.max(0,pe.top-Ve.topInWindow),Ge=$h(),Ke=n(()=>B===void 0?void 0:()=>{Lr(B,J)},[B,J]),Ye=n(()=>M===void 0?healthPlanTopCard(Z,{onOpenPlan:Ke}):void 0,[M,Z,Ke]),Qe=Q.chatTopCard==="focus"?M??Ye:void 0,[Ze,Je]=i(true),Xe=r(e=>{se.send(e)},[se.send]),et=n(()=>yn(K,Q,isLocked("chatFollowUpCount")),[K,Q,isLocked]),tt=Q.chatAnswerStyle==="cards",rt=n(()=>tt&&se.messages.length===0?Fm(se.suggestedPrompts):void 0,[tt,se.messages.length,se.suggestedPrompts]),nt=Q.chatHistoryStyle==="sheet",lt=se.messages.length===0,it=Qe!==void 0?/* @__PURE__ */E(TopCardPill,{card:Qe,open:Ze,onOpenChange:Je}):null,ot=N??(V?void 0:Lm),at=ot!==void 0?/* @__PURE__ */E(HistoryBar,{bar:ot,history:ce,empty:lt,unread:ze,extra:it}):null,st=Q.chatHistoryBar==="scroll"&&(ue==="empty"||ue==="populated"),ut=Qe===void 0?null:/* @__PURE__ */O(A,{children:[
343
- /* @__PURE__ */E(TopCard,{card:Qe,open:Ze,onOpenChange:Je,ask:Xe}),ot===void 0?it:null]}),dt=ot!==void 0,ct=ce.load,pt=ce.open;o(()=>{dt&&!pt&&ct()},[dt,pt,se.conversationId,ct]);let ft={send:se.send,stop:se.stop,isStreaming:se.isStreaming,conversationId:se.conversationId,seed:ke,draftStore:z,onStage:Ie.stage,onPreview:Fe,petName:be?.name??null,petBreed:be?.breed??null,compact:Q.chatComposerStyle==="compact",petPlaceholder:Q.chatComposerPlaceholder==="pet_name",dimEmptySend:Q.chatSendButton==="dim_when_empty",mood:Em(ue,me.source?.level??null),dictation:Q.chatComposerMic,telemetry:e.telemetry},ht=km(Q.chatTextingAsk&&e.inProvider,se,q),gt=h!==void 0&&Q.chatComposerUpload,bt=!Q.chatGeneralBanner&&me.source?.level==="general";
332
+ /* @__PURE__ */E(w,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:eu,style:n.turnNoticeAction,children:/* @__PURE__ */E(Text,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}var Tm=/* @__PURE__ */Object.freeze([]),_m=/* @__PURE__ */Object.freeze([]),zm=16,Im=h.OS==="ios"?"interactive":"on-drag",Pm=18;function MessageRow({message:e,revealing:t,onCopy:n,sentiment:l,onSentiment:i,note:o,images:a,onPreview:s,onOpenUrl:u,onLayout:d,entering:c,answerCards:p,messages:f}){let{theme:h,styles:g}=zu(),b=yo(),m=zo(c,b),v=Fo(e.text,t,b),w=e.role==="user",k=e.role==="vet",C=e.role==="assistant",S=io(),x=C&&!t?S:void 0,R=x!==void 0&&Ib(e.text,x),T=C&&!h.meta.hidePoweredBy,_=w?Me.senderUser:k?Tn(e):T?Me.assistantName:Me.senderAssistant,z=k?Qg(e.createdAt):null,I=r(t=>i(e,t),[i,e]),F=e.pending!==true,L=C&&h.meta.assistantAvatarUrl!==null?/* @__PURE__ */E(AssistantSender,{avatarUrl:h.meta.assistantAvatarUrl,named:T,styles:g}):T?p!==null?/* @__PURE__ */E(CardsByline,{label:Me.assistantName}):/* @__PURE__ */E(Text,{tier:"control",style:g.assistantName,children:Me.assistantName}):null,A=p!==null;return C&&p!==null?/* @__PURE__ */E(P.View,{style:[g.rowBlock,m],onLayout:d,accessibilityLabel:`${_}: ${e.text}`,children:/* @__PURE__ */E(CardsAnswer,{message:e,text:v,streaming:t,messages:f,options:p,sentiment:l,onSentiment:e.responseId===void 0?void 0:I,sender:L,onOpenUrl:u,footer:t=>/* @__PURE__ */E(MessageFooter,{message:e,onCopy:n,sentiment:l,onSentiment:t&&e.responseId!==void 0?I:void 0,note:o})})}):/* @__PURE__ */O(y,{style:[g.rowBlock,w?g.rowBlockUser:g.rowBlockAssistant],onLayout:d,children:[
333
+ /* @__PURE__ */E(y,{style:[g.row,w?g.rowUser:g.rowAssistant],accessible:!R,accessibilityRole:R?void 0:"text",accessibilityLabel:R?void 0:`${_}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:/* @__PURE__ */O(P.View,{style:[g.bubble,A?g.bubbleCards:null,w?g.bubbleSideUser:null,m],children:[L,k?/* @__PURE__ */O(y,{style:g.vetHeader,children:[
334
+ /* @__PURE__ */E(Text,{tier:"control",style:g.vetSender,children:_}),z!==null?/* @__PURE__ */E(Text,{tier:"compact",style:g.vetTime,children:z}):null]}):null,
335
+ /* @__PURE__ */O(y,{style:[w?g.bubbleUser:k?g.bubbleVet:g.bubbleAssistant,w&&A?g.bubbleUserCards:null,e.pending?g.bubblePending:null],children:[w&&a.length>0?/* @__PURE__ */E(SentImages,{images:a,onPreview:e=>s({uri:e.uri,label:e.filename})}):null,
336
+ /* @__PURE__ */E(Text,{style:w?A?[g.bubbleTextUser,g.bubbleTextUserCards]:g.bubbleTextUser:k?g.bubbleTextVet:g.bubbleTextAssistant,children:C?Pb(v,{bold:g.bubbleBold,italic:g.bubbleItalic,code:g.bubbleCode},x):e.text})]})]})}),C&&!t?/* @__PURE__ */E(CitationCards,{citations:e.citations,onOpenUrl:u}):null,F&&!(w&&p!==null)?/* @__PURE__ */E(MessageFooter,{message:e,onCopy:n,sentiment:l,onSentiment:e.responseId===void 0?void 0:I,note:o}):null]})}var Fm=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(e){if(e.isBootstrapping===true||e.isLoadingHistory===true||e.isStreaming===true||e.status==="error"||e.stopped===true)return false;let t=e.messages[e.messages.length-1];return t===void 0||t.role!=="assistant"||t.pending===true||t.checkin!==void 0||t.text.trim().length===0?false:!(typeof t.urgencyLevel=="string"&&Fm.has(t.urgencyLevel))}var NO_SNAPSHOT2=()=>null;function Lm(){let{runtime:e}=Ge(),t=e.entitlements??null,l=r(e=>t===null?()=>{}:t.subscribe(e),[t]),i=t===null?NO_SNAPSHOT2:t.getSnapshot,o=a(l,i,i);return n(()=>o!==null&&decideCapability("texting",o.decisions,{isPending:o.isPending}).enabled,[o])}var Em=/* @__PURE__ */Object.freeze({runner:null,line:null,entry:null,stage:null,headerEntry:null});function Om(e,t,r=false){let[n,l]=i(null);if(!e)return Em;let o=/* @__PURE__ */E(AskRunner,{ready:textingAskThreadReady(t),onAsk:l,entry:r}),a=r&&n!==null&&n.canOpen?{label:D.textingAskLines(n).accept,onOpen:n.open}:null;if(n===null||n.stage==="hidden"||n.stage==="dismissed")return{runner:o,line:null,entry:null,stage:null,headerEntry:a};let s=D.textingAskLines(n),u=/* @__PURE__ */E(AskLine,{stage:n.stage,text:n.stage==="verified"?s.verified:s.line,accept:s.accept,dismiss:s.dismiss,onAccept:n.accept,onDismiss:n.dismiss}),d=n.stage==="enrolling"?/* @__PURE__ */E(D.ChatTextingAskComposer,{ask:n}):null;return{runner:o,line:u,entry:d,stage:n.stage,headerEntry:a}}function AskRunner({ready:e,onAsk:t,entry:r}){let{userRef:userRef}=Ge(),n=Lm(),l=userRef!==null&&n;return o(()=>{l||t(null)},[l,t]),l?/* @__PURE__ */E(D.ChatTextingAskController,{enabled:true,ready:e,onAsk:t,entry:r}):null}function AskLine({stage:e,text:t,accept:r,dismiss:n,onAccept:l,onDismiss:i}){let{theme:o,styles:a}=zu(),s=!o.meta.hidePoweredBy,u=s?Me.assistantName:Me.senderAssistant,d=o.meta.assistantAvatarUrl!==null?/* @__PURE__ */E(AssistantSender,{avatarUrl:o.meta.assistantAvatarUrl,named:s,styles:a}):s?/* @__PURE__ */E(Text,{tier:"control",style:a.assistantName,children:Me.assistantName}):null;/* @__PURE__ */
337
+ return O(y,{style:[a.rowBlock,a.rowBlockAssistant],testID:`everfur-texting-ask-${e}`,children:[
338
+ /* @__PURE__ */E(y,{style:[a.row,a.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${u}: ${t}`,children:/* @__PURE__ */O(y,{style:a.bubble,children:[d,
339
+ /* @__PURE__ */E(y,{style:a.bubbleAssistant,children:/* @__PURE__ */E(Text,{style:a.bubbleTextAssistant,children:t})})]})}),e==="offered"?/* @__PURE__ */E(y,{style:a.askChips,children:[{label:r,onPress:l,testID:"everfur-texting-ask-accept"},{label:n,onPress:i,testID:"everfur-texting-ask-dismiss"}].map(e=>/* @__PURE__ */E(PressScale,{onPress:e.onPress,accessibilityRole:"button",accessibilityLabel:e.label,style:a.askChip,testID:e.testID,children:/* @__PURE__ */E(Text,{tier:"control",style:a.askChipText,children:e.label})},e.testID))}):null]})}function Am(){let e=/* @__PURE__ */Symbol.for("@everfur/sdk#SdkSurfaceHooks@v1"),t=globalThis;return t[e]??(t[e]=createContext(null))}var jm=/* @__PURE__ */Am();function Dm(e){return typeof e=="object"&&e!==null&&e.ok===true}function Mm(e){if(typeof e!="object"||e===null)return null;let t=e;return t.ok!==false||typeof t.error!="object"||t.error===null?null:Rt(t.error)}function Bm(e){let t=s(jm),n=t?.onMessageSent,l=t?.onFreeCapReached,i=r((...t)=>{let r=e(...t);return Promise.resolve(r).then(e=>{try{if(Dm(e)){n?.();return}let t=l===void 0?null:Mm(e);t!==null&&l?.(t)}catch{}},()=>{}),r},[e,n,l]);return n===void 0&&l===void 0?e:i}function EverfurChatCore(e){let{style:t,renderPending:r}=e;/* @__PURE__ */
340
+ return E(CapabilityGate,{capability:"chat",style:t,...r?{renderPending:r}:{},children:/* @__PURE__ */E(MessageLinksScope,{linkHosts:e.linkHosts,onOpenUrl:e.onOpenUrl,children:/* @__PURE__ */E(ChatBody,{...e})})})}function Hm(){try{return Ge()}catch{return null}}function Wm(e){return hn({...e.presentation,chatComposerMic:e.presentation?.chatComposerMic??(e.dictation===void 0?void 0:e.dictation!==false),chatComposerUpload:e.presentation?.chatComposerUpload??(e.attachments===void 0?void 0:true)})}function ChatBody(e){let t=Hm();return t===null?/* @__PURE__ */E(ChatBodyAlone,{...e}):/* @__PURE__ */E(ChatBodyInProvider,{...e,activePet:t.activePet,telemetry:t.runtime.registry?.services?.telemetry??null})}function ChatBodyAlone(e){let t=Wm(e),r=JSON.stringify(t),l=e.petRef??null,i=n(()=>({presentation:resolvePresentation({server:null,locked:null,client:t}),isLocked:()=>false,planPage:null,planPetRef:l,inProvider:false,telemetry:null}),[r,l]);/* @__PURE__ */
341
+ return E(ChatSurface,{...e,settings:i})}function ChatBodyInProvider({activePet:e,telemetry:t,...r}){let{presentation:l,isLocked:isLocked}=fn(Wm(r)),i=on("healthPlan"),o=l.chatTopCard==="focus"&&r.topCard===void 0&&i,a=r.petRef??e??null,s=useHealthPlanPage({petRef:a,enabled:o}),u=o&&s.phase==="ready"?s.page:null,d=n(()=>({presentation:l,isLocked:isLocked,planPage:u,planPetRef:a,inProvider:true,telemetry:t}),[l,isLocked,u,a,t]);/* @__PURE__ */
342
+ return E(ChatSurface,{...r,settings:d})}function ChatSurface({settings:e,petRef:petRef,conversationId:conversationId,style:t,renderPending:a,onCopy:s,onPetChange:u,onVetPrep:d,onFindVet:c,renderVetAction:p,attachments:f,pet:g,onAddPet:b,checkinTarget:m,handoffToken:w,initialAsk:k,initialAskKey:C,composerSeed:S,lifecycle:x,refreshIntervalMs:R,refreshesBlankThread:T,openUnreadOnRefresh:_,draftStore:z,vetReturnTo:I,vetUsState:P,vetPrefer:F,onOpenUrl:L,keyboardVerticalOffset:D,topCard:M,onOpenHealthPlan:B,answerCards:H,historySheet:W,historyBar:N,starterPrompts:U,emptyState:$,header:V=true,textingEntry:q=true,renderEmptyHeader:G,followUpPolicy:K,initialAskCard:Y}){let{presentation:Q,isLocked:isLocked,planPage:Z,planPetRef:J}=e,{theme:X,styles:ee}=zu(),te=Zp()??(Q.chatAnswerStyle==="cards"?qh:null),re=n(()=>te===null?null:te(X),[te,X]),ne=useHostPoweredBy(),le=yo(),ie=n(()=>_n(petRef,conversationId),[petRef,conversationId]),oe=useEverfurChat(ie),ae=Bm(oe.send),se=n(()=>ae===oe.send?oe:{...oe,send:ae},[oe,ae]),ue=gn(se),de=Mg(),ce=Mi(se),pe=j(),fe=mn(se,"web"),he=n(()=>c===void 0?void 0:()=>{Vr(c,"emergency")},[c]),ge=n(()=>I===void 0&&P===void 0&&F===void 0?void 0:{returnTo:I,usState:P,prefer:F},[I,P,F]),be=Fp(de.pets,se.petRef),ye=n(()=>$i(se.messages,be?.name??null),[se.messages,be?.name]),me=qi(ye);Hg(se),Oo(me.showBanner,le);let ve=Hm(),we=Ti(w,ve);zi(se.openCheckin,m??we,{petRef:se.petRef,pinned:petRef!==void 0,ready:!se.isBootstrapping,selectPet:e=>{de.setActivePet(e),Vr(u,e)}}),Ql(se.askEverfur,se.isBootstrapping,k,C);let ke=n(()=>Yl(S),[S]),Ce=n(()=>Yl(k),[k]),Se=n(()=>Y!==void 0&&Ce!==null?{card:Y,prompt:Ce}:void 0,[Y,Ce]),xe=n(()=>x===void 0?createAppStateLifecycle():x??void 0,[x]);si(xe,{conversationId:se.conversationId===null?null:String(se.conversationId),isTurnInFlight:se.isStreaming,refreshesBlankThread:T===true||_===true,refresh:se.refreshActiveThread===void 0?void 0:()=>se.refreshActiveThread?.(ti(_===true,ri(xe,$o)))??Promise.resolve()},{intervalMs:R===void 0?3e4:R,isVisibleFallback:$o}),ni({isStreaming:se.isStreaming,status:se.status,conversationId:se.conversationId===null?null:String(se.conversationId),unreadCount:se.unreadCount,markRead:se.markRead},()=>ri(xe,$o));let Re=se.pendingCheckin??null,Te=Re===null?null:/* @__PURE__ */E(y,{testID:"everfur-pending-checkin",accessibilityLiveRegion:"polite",children:/* @__PURE__ */E(CheckinCard,{message:Re.message,checkin:Re.checkin,onAnswer:se.petRef?se.answerCheckin:null,petRef:se.petRef,onFindVet:he,vet:ge,onOpen:()=>{se.resumeConversation(Re.conversationId)}})}),_e=(se.hasUnreadThreads??false)||ce.rows.some(e=>e.unreadCount!==null&&e.unreadCount>0)||(se.unreadCount??0)>0,ze=$l(se.messages),[Ie,Pe]=i(null),Fe=r(()=>Pe(null),[]),[Le,Ee]=i(null),[Oe,Ae]=i(null),je=l(null);o(()=>()=>{je.current&&clearTimeout(je.current)},[]);let De=r((e,t)=>{Ae({responseId:String(e),kind:t}),je.current&&clearTimeout(je.current),je.current=t==="thanks"?setTimeout(()=>{Ae(null),je.current=null},As):null},[]),Be=r((e,t)=>{let r=e.responseId;if(r===void 0)return;let n=se.sentimentByMessage[String(r)];Ae(e=>e?.responseId===String(r)?null:e),se.feedback(r,t).then(e=>{e.ok||De(r,"failed")}),t==="down"&&n!=="down"&&Ee(r)},[se,De]),He=r(async(e,t)=>Le===null||!(e==null&&t===null?{ok:true}:await se.feedback(Le,"down",e??"other",t)).ok?false:(Ee(null),De(Le,"thanks"),true),[se,Le,De]),We=r(()=>Ee(null),[]),Ne=r(e=>{se.send(e)},[se.send]),Ue=n(()=>L===void 0?void 0:e=>{Vr(L,e,"citation")},[L]),$e=h.OS==="ios"?"padding":void 0,Ve=tg(D,$e!==void 0),qe=Ve.topInWindow===null?pe.top:Math.max(0,pe.top-Ve.topInWindow),Ge=ng(),Ke=n(()=>B===void 0?void 0:()=>{Vr(B,J)},[B,J]),Ye=n(()=>M===void 0?healthPlanTopCard(Z,{onOpenPlan:Ke}):void 0,[M,Z,Ke]),Qe=Q.chatTopCard==="focus"?M??Ye:void 0,[Ze,Je]=i(true),Xe=r(e=>{se.send(e)},[se.send]),et=n(()=>Pn(K,Q,isLocked("chatFollowUpCount")),[K,Q,isLocked]),tt=Q.chatAnswerStyle==="cards",rt=n(()=>tt&&se.messages.length===0?$m(se.suggestedPrompts):void 0,[tt,se.messages.length,se.suggestedPrompts]),nt=Q.chatHistoryStyle==="sheet",lt=se.messages.length===0,it=Qe!==void 0?/* @__PURE__ */E(TopCardPill,{card:Qe,open:Ze,onOpenChange:Je}):null,ot=N??(V?void 0:Vm),at=ot!==void 0?/* @__PURE__ */E(HistoryBar,{bar:ot,history:ce,empty:lt,unread:_e,extra:it}):null,st=Q.chatHistoryBar==="scroll"&&(ue==="empty"||ue==="populated"),ut=Qe===void 0?null:/* @__PURE__ */O(A,{children:[
343
+ /* @__PURE__ */E(TopCard,{card:Qe,open:Ze,onOpenChange:Je,ask:Xe}),ot===void 0?it:null]}),dt=ot!==void 0,ct=ce.load,pt=ce.open;o(()=>{dt&&!pt&&ct()},[dt,pt,se.conversationId,ct]);let ft={send:se.send,stop:se.stop,isStreaming:se.isStreaming,conversationId:se.conversationId,seed:ke,draftStore:z,onStage:ze.stage,onPreview:Pe,petName:be?.name??null,petBreed:be?.breed??null,compact:Q.chatComposerStyle==="compact",petPlaceholder:Q.chatComposerPlaceholder==="pet_name",dimEmptySend:Q.chatSendButton==="dim_when_empty",mood:qm(ue,me.source?.level??null),dictation:Q.chatComposerMic,telemetry:e.telemetry},ht=Om(Q.chatTextingAsk&&e.inProvider,se,q),gt=f!==void 0&&Q.chatComposerUpload,bt=!Q.chatGeneralBanner&&me.source?.level==="general";
344
344
  /* @__PURE__ */
345
- return E(Dp.Provider,{value:re,children:/* @__PURE__ */O(m,{style:[ee.container,{paddingTop:qe},t],behavior:$e,...Ve.avoidingProps,children:[
346
- /* @__PURE__ */E(KeyboardOffsetProbe,{probeRef:Ve.probeRef}),V?/* @__PURE__ */E(ChatHeader,{pets:de,petRef:se.petRef,historyUnread:ze,onOpenHistory:ce.show,onNewChat:ce.newConversation,onPetChange:u,onAddPet:y,vet:ge,textingEntry:ht.headerEntry}):null,g!==void 0?/* @__PURE__ */E(PetSetupNotice,{petRef:petRef??null,pet:g,onRegistered:de.refresh}):null,!V&&ht.headerEntry!==null?/* @__PURE__ */E(TextingEntryRow,{entry:ht.headerEntry,place:"thread"}):null,st?null:at,bt?null:/* @__PURE__ */E(UrgencyBanner,{surface:me,petRef:se.petRef,renderVetAction:p,onFindVet:c,vet:ge,compact:Ge}),
347
- /* @__PURE__ */E(b,{style:ee.body,children:pm(ue,se,{notice:fe,vet:ge,onCheckinFindVet:he,onSelectPrompt:Ne,renderPending:a,shownPet:be,onVetPrep:d,onCopy:s,onSentiment:Be,feedbackNote:Ae,imagesByMessage:Ie.byMessage,onPreview:Fe,onAddPet:y,onOpenUrl:Ue,threadTop:st?at:null,pendingCheckin:Te,topCard:ut,starterPrompts:U??rt,emptyState:$,emptyCentered:Q.chatAnswerStyle==="cards",followUpPolicy:et,answerCards:Q.chatAnswerStyle==="cards"?H??Im:null,threadAside:ht.line,threadAsideKey:ht.stage,renderEmptyHeader:G,openingCard:Se})}),ht.runner,ht.entry!==null?/* @__PURE__ */E(b,{style:ee.composerOuter,children:/* @__PURE__ */E(b,{style:ee.askEntry,children:ht.entry})}):gt&&h!==void 0?/* @__PURE__ */E(ComposerWithAttachments,{...ft,attachments:h}):/* @__PURE__ */E(Composer,{...ft,attachments:null}),X.meta.hidePoweredBy||ne?null:/* @__PURE__ */E(Text,{tier:"compact",style:ee.poweredBy,accessibilityRole:"text",accessibilityLabel:Re.poweredBy,children:Re.poweredBy}),nt?/* @__PURE__ */E(HistorySheet,{chat:se,history:ce,sheet:W}):/* @__PURE__ */E(HistoryDrawer,{chat:se,history:ce}),
348
- /* @__PURE__ */E(FeedbackReasons,{visible:Ee!==null,onSubmit:He,onSkip:We}),
349
- /* @__PURE__ */E(AttachmentImageLightbox,{uri:Pe?.uri??null,label:Pe?.label??"",onClose:Le}),
350
- /* @__PURE__ */E(TelevetHostOutlet,{})]})})}function PetSetupNotice({petRef:petRef,pet:e,onRegistered:t}){let{styles:r}=gu(),n=Il(petRef,e,t);return n.status!=="failed"||n.error===null?null:/* @__PURE__ */O(b,{style:r.setupNotice,accessible:true,accessibilityRole:"alert",children:[
345
+ return E(Qp.Provider,{value:re,children:/* @__PURE__ */O(v,{style:[ee.container,{paddingTop:qe},t],behavior:$e,...Ve.avoidingProps,children:[
346
+ /* @__PURE__ */E(KeyboardOffsetProbe,{probeRef:Ve.probeRef}),
347
+ /* @__PURE__ */O(SdkTabletColumn,{children:[V?/* @__PURE__ */E(ChatHeader,{pets:de,petRef:se.petRef,historyUnread:_e,onOpenHistory:ce.show,onNewChat:ce.newConversation,onPetChange:u,onAddPet:b,vet:ge,textingEntry:ht.headerEntry}):null,g!==void 0?/* @__PURE__ */E(PetSetupNotice,{petRef:petRef??null,pet:g,onRegistered:de.refresh}):null,!V&&ht.headerEntry!==null?/* @__PURE__ */E(TextingEntryRow,{entry:ht.headerEntry,place:"thread"}):null,st?null:at,bt?null:/* @__PURE__ */E(UrgencyBanner,{surface:me,petRef:se.petRef,renderVetAction:p,onFindVet:c,vet:ge,compact:Ge}),
348
+ /* @__PURE__ */E(y,{style:ee.body,children:Rm(ue,se,{notice:fe,vet:ge,onCheckinFindVet:he,onSelectPrompt:Ne,renderPending:a,shownPet:be,onVetPrep:d,onCopy:s,onSentiment:Be,feedbackNote:Oe,imagesByMessage:ze.byMessage,onPreview:Pe,onAddPet:b,onOpenUrl:Ue,threadTop:st?at:null,pendingCheckin:Te,topCard:ut,starterPrompts:U??rt,emptyState:$,emptyCentered:Q.chatAnswerStyle==="cards",followUpPolicy:et,answerCards:Q.chatAnswerStyle==="cards"?H??Nm:null,threadAside:ht.line,threadAsideKey:ht.stage,renderEmptyHeader:G,openingCard:Se})}),ht.runner,ht.entry!==null?/* @__PURE__ */E(y,{style:ee.composerOuter,children:/* @__PURE__ */E(y,{style:ee.askEntry,children:ht.entry})}):gt&&f!==void 0?/* @__PURE__ */E(ComposerWithAttachments,{...ft,attachments:f}):/* @__PURE__ */E(Composer,{...ft,attachments:null}),X.meta.hidePoweredBy||ne?null:/* @__PURE__ */E(Text,{tier:"compact",style:ee.poweredBy,accessibilityRole:"text",accessibilityLabel:Me.poweredBy,children:Me.poweredBy})]}),nt?/* @__PURE__ */E(HistorySheet,{chat:se,history:ce,sheet:W}):/* @__PURE__ */E(HistoryDrawer,{chat:se,history:ce}),
349
+ /* @__PURE__ */E(FeedbackReasons,{visible:Le!==null,onSubmit:He,onSkip:We}),
350
+ /* @__PURE__ */E(AttachmentImageLightbox,{uri:Ie?.uri??null,label:Ie?.label??"",onClose:Fe}),
351
+ /* @__PURE__ */E(TelevetHostOutlet,{})]})})}function PetSetupNotice({petRef:petRef,pet:e,onRegistered:t}){let{styles:r}=zu(),n=Nl(petRef,e,t);return n.status!=="failed"||n.error===null?null:/* @__PURE__ */O(y,{style:r.setupNotice,accessible:true,accessibilityRole:"alert",children:[
351
352
  /* @__PURE__ */E(Text,{tier:"compact",style:r.setupNoticeText,children:n.error.displayMessage}),
352
- /* @__PURE__ */E(v,{onPress:n.retry,accessibilityRole:"button",accessibilityLabel:Re.retry,hitSlop:Ws,children:/* @__PURE__ */E(Text,{tier:"control",style:r.setupNoticeAction,children:Re.retry})})]})}var Im=/* @__PURE__ */Object.freeze({}),Pm=3;function Fm(e){let t=[];for(let r of e){let e=r.trim();if(e.length>0&&!t.some(t=>t.label===e)&&t.push(/* @__PURE__ */Object.freeze({label:e})),t.length===Pm)break}return t.length>0?/* @__PURE__ */Object.freeze(t):void 0}var Lm=/* @__PURE__ */Object.freeze({chats:bi.heading,newChat:bi.newChat});function Em(e,t){return t==="emergency"?"urgent":e==="populated"?"followUp":"ask"}function EverfurChat(e){/* @__PURE__ */
353
- return E(EverfurChatCore,{...e})}var Om=/* @__PURE__ */Object.freeze({hasUnread:null,unreadCount:null,conversationId:null,petRef:null}),NO_SUBSCRIPTION=()=>()=>{};function Am(e,t){let{runtime:l,userRef:userRef,activePet:i,scopeEpoch:s}=Oe(),u=l.unread??null,petRef=e===void 0?i:e,d=r(e=>u===null?NO_SUBSCRIPTION():u.subscribe(e),[u]),c=r(()=>u===null||userRef===null?Om:u.get(petRef),[u,userRef,petRef]),p=a(d,c,c),f=r(()=>u===null||userRef===null?Promise.resolve():u.refresh(petRef),[u,userRef,petRef]);return o(()=>{f()},[f,s]),Yl(t,{conversationId:null,isTurnInFlight:false,refreshesBlankThread:true,refresh:f}),n(()=>({...p,refresh:f}),[p,f])}function useEverfurUnread(e={}){let{lifecycle:t}=e,r=n(()=>t===void 0?createAppStateLifecycle():t??void 0,[t]);return Am(e.petRef,r)}export{EverfurChat,EverfurPoweredBy,chatHandoffTokenFromUrl,createAppStateLifecycle,createRnChatAttachmentTransport,registerEverfurDictation,useChatAttachments,useEverfurChat,useEverfurPets,useEverfurUnread,useHostPoweredBy};
353
+ /* @__PURE__ */E(w,{onPress:n.retry,accessibilityRole:"button",accessibilityLabel:Me.retry,hitSlop:eu,children:/* @__PURE__ */E(Text,{tier:"control",style:r.setupNoticeAction,children:Me.retry})})]})}var Nm=/* @__PURE__ */Object.freeze({}),Um=3;function $m(e){let t=[];for(let r of e){let e=r.trim();if(e.length>0&&!t.some(t=>t.label===e)&&t.push(/* @__PURE__ */Object.freeze({label:e})),t.length===Um)break}return t.length>0?/* @__PURE__ */Object.freeze(t):void 0}var Vm=/* @__PURE__ */Object.freeze({chats:Ii.heading,newChat:Ii.newChat});function qm(e,t){return t==="emergency"?"urgent":e==="populated"?"followUp":"ask"}function EverfurChat(e){/* @__PURE__ */
354
+ return E(EverfurChatCore,{...e})}var Gm=/* @__PURE__ */Object.freeze({hasUnread:null,unreadCount:null,conversationId:null,petRef:null}),NO_SUBSCRIPTION=()=>()=>{};function Km(e,t){let{runtime:l,userRef:userRef,activePet:i,scopeEpoch:s}=Ge(),u=l.unread??null,petRef=e===void 0?i:e,d=r(e=>u===null?NO_SUBSCRIPTION():u.subscribe(e),[u]),c=r(()=>u===null||userRef===null?Gm:u.get(petRef),[u,userRef,petRef]),p=a(d,c,c),f=r(()=>u===null||userRef===null?Promise.resolve():u.refresh(petRef),[u,userRef,petRef]);return o(()=>{f()},[f,s]),si(t,{conversationId:null,isTurnInFlight:false,refreshesBlankThread:true,refresh:f}),n(()=>({...p,refresh:f}),[p,f])}function useEverfurUnread(e={}){let{lifecycle:t}=e,r=n(()=>t===void 0?createAppStateLifecycle():t??void 0,[t]);return Km(e.petRef,r)}export{EverfurChat,EverfurPoweredBy,chatHandoffTokenFromUrl,createAppStateLifecycle,createRnChatAttachmentTransport,registerEverfurDictation,useChatAttachments,useEverfurChat,useEverfurPets,useEverfurUnread,useHostPoweredBy};