@everfur/sdk 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryab
11
11
  return Object.freeze({kind:"analysisStarted",requestId:e,lastEventId:t,serverRequestId:r,terminal:false})}function analysisCompleteFrame(e,t=null){/* @__PURE__ */
12
12
  return Object.freeze({kind:"analysisComplete",terminal:false,resultId:e.resultId,analysisType:e.analysisType,modelVersion:e.modelVersion,confidence:e.confidence,detections:/* @__PURE__ */Object.freeze([...e.detections]),interpretation:e.interpretation,lastEventId:e.lastEventId,serverRequestId:t})}function unknownFrame(e,t,r=null){/* @__PURE__ */
13
13
  return Object.freeze({kind:"unknown",raw:{...e},lastEventId:t,serverRequestId:r,terminal:false})}var S="/widget/v1/anon-identity",j="x-everfur-anon-token",_="anonTokenInvalid";function R(e,t){if(typeof e!="string"||t===null)return null;let r=Date.parse(e)-Date.parse(t);return Number.isFinite(r)&&r>0?r:null}function createAnonIdentityProvider(e,t,r,n=Date.now){let l=null,i=null,o=null,a=null,s=e=>Math.max(0,n()-e),u=(e,t)=>e!==null&&n()>=e&&n()-e<t,c=()=>l!==null&&(l.ttlMs===null||s(l.mintedAtMs)<l.ttlMs-2592e5),d=()=>l!==null&&(l.ttlMs===null||s(l.mintedAtMs)<l.ttlMs)?l.token:null,f=()=>i||(i=(async()=>{try{let i=null,a={method:"POST",path:S,headers:{"x-everfur-partner-key":t,"x-everfur-session-id":r},onResponseHeaders:e=>{i=e("date")}},s=await e.request(a),u=s.ok?s.value:null,c=typeof u?.anon_token=="string"&&u.anon_token.length>0?u.anon_token:null;return c===null?(o=n(),d()):(l={token:c,mintedAtMs:n(),ttlMs:R(u?.expires_at,i)},o=null,c)}catch{return o=n(),d()}finally{i=null}})(),i);return{token(e){return e?.forceRefresh?i||(u(a,3e4)?Promise.resolve(l?.token??null):(a=n(),l=null,f())):c()||u(o,3e5)?Promise.resolve(d()):f()}}}async function E(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}var I="This feature isn't available on your account right now.",z="Something in that request was not right. Check the details and try again.",T=/* @__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:I,paymentRequired:"This is part of a paid plan.",quotaExceeded:"You have used today's messages. This resets tomorrow.",rateLimited:"You are sending messages quickly. Try again in a few seconds.",validationFailed:z,sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",identitySignatureRequired:I,runtimeDisposed:z,unknown:"Something went wrong. Please try again."}),O="This session has ended. Please sign in again.",P="linked_account_read_only";function F(e,t,r){return e==="conflict"&&r===P?I:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?O:userFacingError(e)}function userFacingError(e){return T[e]}function M(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var A=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===P,l={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:F(e,t?.wireCode,n?P:null)};t?.httpStatus!==void 0&&(l.httpStatus=t.httpStatus),t?.requestId&&(l.requestId=t.requestId),typeof t?.reasonCode=="string"&&A.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&&M(l,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&M(l,"raw",t.raw),/* @__PURE__ */Object.freeze(l)}function $(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 createIdentityProvider(e,t,r,n){let l=null,i=false,o=null,a=false,u=()=>o||(o=(async()=>{try{let e=await t(),n=typeof e=="string"?e:e?.token;if(typeof n!="string"||n.length===0)throw new s("invalid-argument","TokenProvider returned an empty token");return l=n,i=!1,r?.(typeof e=="string"?null:D(e.expiresAt)),n}finally{o=null}})(),o);return{userRef:e,async currentToken(e){if(a)throw new s("not-initialized","This identity was cleared (sign-out); mint a new one.");return e?.forceRefresh&&(l=null),l!==null?l:u()},hasToken(){return!a&&l!==null},clear(){a=true,l=null},reportRejected(){a||i||(i=true,n?.())}}}function D(e){if(e===void 0)return null;let t=typeof e=="number"?e<1e11?e*1e3:e:new Date(e).getTime();return Number.isFinite(t)?t:null}function newSessionId(){let e=new Uint8Array(16),t=globalThis.crypto;if(typeof t?.getRandomValues=="function")t.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let r=[];for(let t=0;t<e.length;t+=1)r.push(e[t].toString(16).padStart(2,"0"));return r.slice(0,4).join("")+"-"+r.slice(4,6).join("")+"-"+r.slice(6,8).join("")+"-"+r.slice(8,10).join("")+"-"+r.slice(10,16).join("")}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[j]=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:{...B(e.headers),...authHeaders(t)}}}function B(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===j||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await E(t),n=await t.transport.request(withAuthHeaders(e,N(t,r)));if(n.ok||U(n.error.raw)!==_||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,N(t,l)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err($(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($(e,{wireCode:U(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(L(i.error))):i}function N(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function L(e){let t=e.raw,r=U(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 U(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 H="DAILY_QUOTA_EXCEEDED",W=/* @__PURE__ */new Set(["THROTTLINGEXCEPTION","RATELIMITED","TOOMANYREQUESTS"]);function q(e,t){if(!W.has(e.toUpperCase().replace(/[^A-Z0-9]/g,"")))return e;let r=t,n=r?.daily_limit??r?.error?.daily_limit;return typeof n=="number"&&Number.isFinite(n)?H:e}var V="free_cap_reached";function K(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function G(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!==V&&n.code!==V)return null;let l=K(n.limit),i=K(n.used);if(l===null||i===null)return null;let o=n.resets_at,a=n.emergency_guidance;/* @__PURE__ */
14
- 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 Y(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:G(t)}function Z(){let e=[];return{decode(t,r){let n=r?.stream===true,l=e.length>0?e.slice():[];if(t!==void 0)for(let e=0;e<t.length;e+=1)l.push(t[e]);e=[];let i="",o=0;for(;o<l.length;){let t=l[o];if(t<128){i+=String.fromCharCode(t),o+=1;continue}let r,a=128,s=191,u;if(t>=194&&t<=223)r=1,u=t&31;else if(t>=224&&t<=239)r=2,u=t&15,t===224&&(a=160),t===237&&(s=159);else if(t>=240&&t<=244)r=3,u=t&7,t===240&&(a=144),t===244&&(s=143);else{i+="�",o+=1;continue}let c=1,d=true;for(;c<=r&&!(o+c>=l.length);){let e=l[o+c],t=c===1?a:128,r=c===1?s:191;if(e<t||e>r){d=false;break}u=u<<6|e&63,c+=1}if(!d){i+="�",o+=c;continue}if(c<=r){n?e=l.slice(o):i+="�";break}i+=String.fromCodePoint(u),o+=r+1}return i}}}function Q(){let e=globalThis.TextDecoder;return typeof e=="function"?new e("utf-8"):Z()}var X=`\n\n`,J=1048576,ee=/* @__PURE__ */t.z.record(/* @__PURE__ */t.z.string(),/* @__PURE__ */t.z.unknown()),te=["emergency","schedule_soon","home_care"];async function*parseSse(e,t=null){let r=null,n=()=>(r!==null||(r=typeof t=="function"?t():t),r),l=Q(),i="",o=0,a=false;for await(let t of e){for(i+=l.decode(t,{stream:true});;){let e=i.indexOf(X,o);if(e===-1)break;let t=i.slice(0,e);i=i.slice(e+X.length),o=0;let r=re(t,n());if(r!==null&&(r.kind==="delta"&&(a=true),yield r,r.terminal))return}if(o=i.length>0?i.length-1:0,i.length>J){yield errorFrame({code:a?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});return}}if(i+=l.decode(),i.trim().length>0){let e=re(i,n());if(e!==null&&(e.kind==="delta"&&(a=true),yield e,e.terminal))return}yield errorFrame({code:a?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()})}function re(e,t){let r=null,n=[];for(let t of e.split(`\n`)){let e=t.replace(/\s+$/,"");e.length===0||e.startsWith(":")||(e.startsWith("id:")?r=e.slice(3).trim():e.startsWith("data:")&&n.push(e.slice(5).replace(/^ /,"")))}if(n.length===0)return null;let l;try{l=JSON.parse(n.join(`\n`))}catch{return null}if(typeof l!="object"||l===null||Array.isArray(l))return null;let i=ee.safeParse(l);return i.success?ne(i.data,r,t):null}function ne(e,t,r){let n=e.type,l=e.event;if(n==="error"||"error"in e)return errorFrame({code:le(e.code)??"unknown",retryable:e.retryable===true,wireMessage:le(e.error),synthesized:false,lastEventId:t,serverRequestId:r,freeCap:G(e)});if(n==="done"||e.done===true)return doneFrame({conversationId:le(e.conversation_id)??"",messageId:le(e.message_id),title:le(e.title),followUpQuestions:se(e.follow_up_questions),citations:ce(e.citations),recordCitations:ce(e.record_citations),citationStatus:le(e.citation_status),urgencyLevel:oe(e.urgency_level),urgencyReason:le(e.urgency_reason),urgencyProvided:ae(e),resultId:le(e.result_id),lastEventId:t},r);if(n==="accepted"||e.status==="reasoning")return acceptedFrame(le(e.stream_id),t,r);if(n==="heartbeat"||e.heartbeat===true)return heartbeatFrame(t,r);if(n==="text.delta"||"delta"in e||"token"in e){let n=le(e.delta)??le(e.token)??"";return deltaFrame(n,t,r)}return l==="analysis_started"?analysisStartedFrame(le(e.request_id),t,r):l==="analysis_complete"?analysisCompleteFrame({resultId:le(e.result_id),analysisType:le(e.analysis_type),modelVersion:le(e.model_version),confidence:ie(e.confidence),detections:ce(e.detections),interpretation:le(e.interpretation),lastEventId:t},r):unknownFrame(e,t,r)}function le(e){return typeof e=="string"?e:null}function ie(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function oe(e){return typeof e=="string"&&te.includes(e)?e:null}function ae(e){if(!Object.prototype.hasOwnProperty.call(e,"urgency_level"))return false;let t=e.urgency_level;return t===null||oe(t)!==null}function se(e){return Array.isArray(e)?e.map(e=>typeof e=="string"?e:String(e)):[]}function ue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ce(e){return Array.isArray(e)?e.filter(ue):[]}var de=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function fe(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 me(e)}var pe=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,he=/[\s\u0000-\u001f\u007f\\]/,ge={"http:":"80","https:":"443"};function me(e,t){let r=e.trim();let n=he.test(r)?null:pe.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",c="",d=""]=n,f=`${l.toLowerCase()}:`,p=Number(s);if(p>65535)return null;let h=s===""||String(p)===ge[f]?"":String(p),g=ge[f]!==void 0,m=a.toLowerCase()+(h&&`:${h}`),b=u||(g?"/":""),y=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${f}//${y}${m}${b}${c}${d}`,protocol:f,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:g?`${f}//${m}`:"null",pathname:b,search:c==="?"?"":c,hash:d==="#"?"":d}}function be(e,t,r){return{...e,surface:t,requestId:r||null}}var ye=64,ve=/^[A-Za-z0-9._+() -]+$/;function xe(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0||t.length>ye?null:ve.test(t)?t:null}var ke="1.7.0";var we="react-native",Ce="2026-09-19",Se="EVERFUR_API_BASE_URL";function je(e,t){/* @__PURE__ */
14
+ 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 Y(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:G(t)}function Z(){let e=[];return{decode(t,r){let n=r?.stream===true,l=e.length>0?e.slice():[];if(t!==void 0)for(let e=0;e<t.length;e+=1)l.push(t[e]);e=[];let i="",o=0;for(;o<l.length;){let t=l[o];if(t<128){i+=String.fromCharCode(t),o+=1;continue}let r,a=128,s=191,u;if(t>=194&&t<=223)r=1,u=t&31;else if(t>=224&&t<=239)r=2,u=t&15,t===224&&(a=160),t===237&&(s=159);else if(t>=240&&t<=244)r=3,u=t&7,t===240&&(a=144),t===244&&(s=143);else{i+="�",o+=1;continue}let c=1,d=true;for(;c<=r&&!(o+c>=l.length);){let e=l[o+c],t=c===1?a:128,r=c===1?s:191;if(e<t||e>r){d=false;break}u=u<<6|e&63,c+=1}if(!d){i+="�",o+=c;continue}if(c<=r){n?e=l.slice(o):i+="�";break}i+=String.fromCodePoint(u),o+=r+1}return i}}}function Q(){let e=globalThis.TextDecoder;return typeof e=="function"?new e("utf-8"):Z()}var X=`\n\n`,J=1048576,ee=/* @__PURE__ */t.z.record(/* @__PURE__ */t.z.string(),/* @__PURE__ */t.z.unknown()),te=["emergency","schedule_soon","home_care"];async function*parseSse(e,t=null){let r=null,n=()=>(r!==null||(r=typeof t=="function"?t():t),r),l=Q(),i="",o=0,a=false;for await(let t of e){for(i+=l.decode(t,{stream:true});;){let e=i.indexOf(X,o);if(e===-1)break;let t=i.slice(0,e);i=i.slice(e+X.length),o=0;let r=re(t,n());if(r!==null&&(r.kind==="delta"&&(a=true),yield r,r.terminal))return}if(o=i.length>0?i.length-1:0,i.length>J){yield errorFrame({code:a?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});return}}if(i+=l.decode(),i.trim().length>0){let e=re(i,n());if(e!==null&&(e.kind==="delta"&&(a=true),yield e,e.terminal))return}yield errorFrame({code:a?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()})}function re(e,t){let r=null,n=[];for(let t of e.split(`\n`)){let e=t.replace(/\s+$/,"");e.length===0||e.startsWith(":")||(e.startsWith("id:")?r=e.slice(3).trim():e.startsWith("data:")&&n.push(e.slice(5).replace(/^ /,"")))}if(n.length===0)return null;let l;try{l=JSON.parse(n.join(`\n`))}catch{return null}if(typeof l!="object"||l===null||Array.isArray(l))return null;let i=ee.safeParse(l);return i.success?ne(i.data,r,t):null}function ne(e,t,r){let n=e.type,l=e.event;if(n==="error"||"error"in e)return errorFrame({code:le(e.code)??"unknown",retryable:e.retryable===true,wireMessage:le(e.error),synthesized:false,lastEventId:t,serverRequestId:r,freeCap:G(e)});if(n==="done"||e.done===true)return doneFrame({conversationId:le(e.conversation_id)??"",messageId:le(e.message_id),title:le(e.title),followUpQuestions:se(e.follow_up_questions),citations:ce(e.citations),recordCitations:ce(e.record_citations),citationStatus:le(e.citation_status),urgencyLevel:oe(e.urgency_level),urgencyReason:le(e.urgency_reason),urgencyProvided:ae(e),resultId:le(e.result_id),lastEventId:t},r);if(n==="accepted"||e.status==="reasoning")return acceptedFrame(le(e.stream_id),t,r);if(n==="heartbeat"||e.heartbeat===true)return heartbeatFrame(t,r);if(n==="text.delta"||"delta"in e||"token"in e){let n=le(e.delta)??le(e.token)??"";return deltaFrame(n,t,r)}return l==="analysis_started"?analysisStartedFrame(le(e.request_id),t,r):l==="analysis_complete"?analysisCompleteFrame({resultId:le(e.result_id),analysisType:le(e.analysis_type),modelVersion:le(e.model_version),confidence:ie(e.confidence),detections:ce(e.detections),interpretation:le(e.interpretation),lastEventId:t},r):unknownFrame(e,t,r)}function le(e){return typeof e=="string"?e:null}function ie(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function oe(e){return typeof e=="string"&&te.includes(e)?e:null}function ae(e){if(!Object.prototype.hasOwnProperty.call(e,"urgency_level"))return false;let t=e.urgency_level;return t===null||oe(t)!==null}function se(e){return Array.isArray(e)?e.map(e=>typeof e=="string"?e:String(e)):[]}function ue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ce(e){return Array.isArray(e)?e.filter(ue):[]}var de=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function fe(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 me(e)}var pe=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,he=/[\s\u0000-\u001f\u007f\\]/,ge={"http:":"80","https:":"443"};function me(e,t){let r=e.trim();let n=he.test(r)?null:pe.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",c="",d=""]=n,f=`${l.toLowerCase()}:`,p=Number(s);if(p>65535)return null;let h=s===""||String(p)===ge[f]?"":String(p),g=ge[f]!==void 0,m=a.toLowerCase()+(h&&`:${h}`),b=u||(g?"/":""),y=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${f}//${y}${m}${b}${c}${d}`,protocol:f,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:g?`${f}//${m}`:"null",pathname:b,search:c==="?"?"":c,hash:d==="#"?"":d}}function be(e,t,r){return{...e,surface:t,requestId:r||null}}var ye=64,ve=/^[A-Za-z0-9._+() -]+$/;function xe(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0||t.length>ye?null:ve.test(t)?t:null}var ke="1.7.1";var we="react-native",Ce="2026-09-19",Se="EVERFUR_API_BASE_URL";function je(e,t){/* @__PURE__ */
15
15
  return Object.freeze({ok:false,failure:/* @__PURE__ */Object.freeze({reason:e,message:t})})}function checkPublishableKey(e){let t=typeof e=="string"?e.trim():"";return t.length===0?{reason:"missing-publishable-key",message:"publishableKey is required"}:/^sk[_-]/i.test(t)?{reason:"secret-key-as-publishable-key",message:"publishableKey looks like a SECRET key (sk_...). A device must never hold a partner secret key: use the pk_ publishable key here, and keep the secret key on your server."}:null}function tryResolveClientConfig(e,t){let r=checkPublishableKey(e?.publishableKey);if(r!==null)/* @__PURE__ */
16
16
  return Object.freeze({ok:false,failure:r});let n=e.publishableKey.trim(),l=tryResolveApiBaseUrl(e.apiBaseUrl);if(!l.ok)return l;let i=e.contractVersion?.trim()||Ce,o=xe(e.appVersion);/* @__PURE__ */
17
17
  return Object.freeze({ok:true,config:/* @__PURE__ */Object.freeze({publishableKey:n,apiBaseUrl:l.value,contractVersion:i,sdkVersion:ke,platform:t?.platform??we,debug:e.debug===true,...o!==null?{appVersion:o}:{}})})}function tryResolveApiBaseUrl(e){let t=e?.trim(),r=t&&t.length>0?t:Oe(Se);return r?ze(r):je("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${Se}. The SDK never ships a hardcoded host.`)}function buildBaseHeaders(e){let t={"X-Everfur-SDK-Version":e.sdkVersion,"X-Everfur-SDK-Platform":e.platform,"X-Everfur-Contract":e.contractVersion};return e.appVersion!=null&&e.platform==="react-native"&&(t["X-Everfur-App-Version"]=e.appVersion),t}function _e(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}function Re(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}function Ee(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:Re(t)}function Ie(e,t){return`${e}://${t}`}function ze(e){let t=e.trim(),r=de.exec(t);if(r===null||r[2]===void 0||r[2].length===0)return je("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let n=(r[1]??"").toLowerCase(),l=_e(r[2]);if(l.length===0)return je("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let i=Ee(t,l)?`: ${Ie(n,l)}`:"";if(n!=="https"){if(!(n==="http"&&Te(l)))return n==="http"?je("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${i}`):je("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${i}`)}let o=t.endsWith("/")?t.slice(0,-1):t;/* @__PURE__ */
@@ -47,7 +47,7 @@ return Object.freeze([/* @__PURE__ */Object.freeze({resource:"chat.message.creat
47
47
  return Object.freeze({track(t,r){try{e.track(t,r)}catch{}},trackExpectedFailure(r,n){try{e.trackExpectedFailure(r,t===void 0?n:ic(r,n,t))}catch{}}})}function ic(e,t,r){let n=e.indexOf("."),l=typeof t?.surface=="string"?t.surface:n>0?e.slice(0,n):"sdk",i=typeof t?.requestId=="string"?t.requestId:null;return{...be(r,l,i),...t}}function oc(e,t,r){if(e===void 0)return;let n=e.onExpectedFailure;return{shouldRetry:(t,r)=>e.shouldRetry(t,r),maxAttempts:t=>e.maxAttempts(t),...typeof n=="function"?{onExpectedFailure:(l,i)=>n.call(e,l,i??be(t,r,l.requestId))}:{}}}var ac=/* @__PURE__ */Object.freeze({"react-native":"If the value is set in your environment, note that babel-preset-expo inlines only EXPO_PUBLIC_* variables into a release bundle.",web:`If the value is set in your environment, note that a browser bundle does not expose ${Se} to the SDK at run time (bundlers inline only the variables your own code names), so pass apiBaseUrl in config.`});function sc(e,t,r=we){try{t.trackExpectedFailure("sdk.config.invalid",{reason:e.reason})}catch{}globalThis.console?.error?.(`[everfur] SDK disabled: ${e.message}\n[everfur] Every Everfur capability will render its off-state until this is fixed. `+ac[r])}function uc(e){/* @__PURE__ */
48
48
  return Object.freeze({request(){return Promise.resolve(err(rc(e)))},stream(t,r){let n=errorFrame({code:"sdk_not_configured",retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`,synthesized:true,lastEventId:null});return async function*(){r.aborted||(yield n)}()}})}var cc=/* @__PURE__ */new WeakSet;function dc(){let e=/* @__PURE__ */new Map,t={async getItem(t){return e.get(t)??null},async setItem(t,r){e.set(t,r)},async removeItem(t){e.delete(t)},async keys(t){return[...e.keys()].filter(e=>e.startsWith(t))}};return cc.add(t),t}var fc=/* @__PURE__ */Object.freeze({clearMemoryCache(){},clearDiskCache(){}});function createEverfurRuntime(e,t){return new hc(e,t)}var pc=6e4,hc=class{constructor(e,t){this.sessionId=newSessionId();this.anonIdentity=null;this.entries=/* @__PURE__ */new Map;this.destroyers=/* @__PURE__ */new Map;this.epoch=0;this.disposed=false;this.verdictSettled=false;this.brandingCache=null;this.verdictLanded=false;this.refreshTimer=null;this.bootstraps=/* @__PURE__ */new WeakMap;this.prepared=null;this.beforeLogoutHooks=/* @__PURE__ */new Set;this.pendingBeforeLogout=null;this.leavingSessionId=null;let r=e.config;if(r.secureStore!==void 0&&r.secureStore.isAvailable===true)throw new s("invalid-argument","config.secureStore is not yet consumable: SDK token persistence is unimplemented. Omit secureStore to keep memory-only tokens (SPEC-10 §5.3).");this.errorContext=/* @__PURE__ */Object.freeze({sdkVersion:ke,platform:t?.platform??we,partnerKey:checkPublishableKey(r?.publishableKey)===null?r.publishableKey.trim():null,appVersion:xe(r?.appVersion)}),this.telemetry=r.telemetry?lc(r.telemetry,this.errorContext):u,this.onEvent=typeof r.onEvent=="function"?r.onEvent:void 0;let n=typeof r?.publishableKey=="string"?r.publishableKey.trim():"",l=checkPublishableKey(r?.publishableKey),i=r.transport!==void 0,o,a=typeof r.apiBaseUrl=="string"&&r.apiBaseUrl.trim().length>0?r.apiBaseUrl.trim():null;if(l!==null)o=uc(l);else if(r.transport!==void 0)o=r.transport;else{let e=nc(r,t?.platform);e.ok?(a=e.config.apiBaseUrl,o=createHttpTransport({config:e.config,...t?.eventSourceFactory?{eventSourceFactory:t.eventSourceFactory}:{}})):(l=e.failure,o=uc(e.failure))}if(this.configFailure=l,this.reportsDeviceTimezone=l===null&&(t?.reportDeviceTimezone??!i),this.publishableKey=l===null?n:"",this.mintScope=`${this.publishableKey}|${a??""}`,$l(this,this.mintScope),this.transport=o,l!==null&&(sc(l,this.telemetry,t?.platform),this.emit({type:"error",code:rc(l).code,requestId:null,context:be(this.errorContext,"runtime",null)})),this.errorPolicy=oc(r.errorPolicy,this.errorContext,"runtime"),this.camera=r.camera??C,this.upload=r.upload??Lt,this.uploadTransport=r.uploadTransport??un,this.imageCache=r.imageCache??fc,this.kv=r.storage??dc(),this.currentUser=e.user??null,this.identity=this.buildIdentity(e.user??null),this.activePet=e.activePet,this.store=l===null?qu():qu(()=>deniedDecisionsFor("sdk_config",userFacingError("accessDenied"))),this.services={authFor:e=>this.buildAuth(e),telemetry:this.telemetry,errorPolicy:this.errorPolicy,camera:this.camera,upload:this.upload,uploadTransport:this.uploadTransport,imageCache:this.imageCache,kv:this.kv,apiBaseUrl:a},this.registry={services:this.services,acquireChat:e=>this.acquireInternal("chat",gc(e),()=>this.buildChatController(e),mc),releaseChat:e=>this.releaseInternal(e),peekChat:e=>this.entries.get(`${this.epoch}|chat|${gc(e)}`)?.controller??null,acquire:(e,t,r,n)=>this.acquireInternal(e,t,r,n),release:e=>this.releaseInternal(e)},this.entitlements=this.store,this.unread=Fu({read:e=>this.disposed||this.currentUser===null||this.configFailure!==null?null:Mu(this.buildAuth(this.currentUser.userRef),e,this.errorPolicy),emit:e=>this.emit(e)}),l===null){this.brandingCache=Ju(this.kv,this.mintScope);let e=this.epoch;this.brandingCache.restore(t=>{let r=this.store.getSnapshot();this.disposed||this.verdictLanded||this.epoch!==e||r.branding||this.store.set({...r,branding:t})})}this.sdkConfigHost=l===null?tc({kv:this.kv,scope:this.mintScope,funnel:()=>createRequestFunnel({auth:this.buildAuth(this.currentUser?.userRef??null)})}):void 0;let c=l===null&&(t?.startEntitlementPolling??!i);this.poller=l===null?this.buildPoller(t?.pollScheduler):null,c&&this.poller?.start()}get isDisposed(){return this.disposed}get scopeEpoch(){return this.epoch}buildIdentity(e){if(e===null)return null;let t=ql(`${this.mintScope}|${e.userRef}`,e.getToken),r=createIdentityProvider(e.userRef,t,t=>{this.armTokenRefresh(r,t),this.reportsDeviceTimezone&&!this.disposed&&r===this.identity&&Zl(`${this.mintScope}|${e.userRef}`,this.buildAuth(e.userRef))},()=>{r===this.identity&&this.emit({type:"session_expired",userRef:e.userRef})});return r}armTokenRefresh(e,t){if(this.clearTokenRefresh(),t===null||this.disposed||e!==this.identity)return;let r=t-Date.now();if(r<=0)return;let n=Math.max(r-pc,r/2);this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,!(this.disposed||e!==this.identity)&&e.currentToken({forceRefresh:true}).catch(()=>{})},n),this.refreshTimer.unref?.()}emit(e){let t=this.onEvent;if(t===void 0)return;let r=()=>{this.disposed||Pl(t,e)};typeof queueMicrotask=="function"?queueMicrotask(r):Promise.resolve().then(r)}clearTokenRefresh(){this.refreshTimer!==null&&clearTimeout(this.refreshTimer),this.refreshTimer=null}buildPoller(e){return createEntitlementPoller({authFor:()=>this.buildAuth(this.currentUser?.userRef??null),update:(e,t,r,n)=>{this.verdictLanded=true;let l=this.store.getSnapshot().branding??null,i=l!==null&&t!=null&&Zu(l)===Zu(t)?l:t;this.updateEntitlements({decisions:e,isPending:false,branding:i,...r===false?{livemode:r}:{},...n!==void 0?{smsProfilePublic:n}:{}}),this.brandingCache?.persist(i??null)},onFetch:()=>{this.verdictSettled||this.store.setPending(true)},onSettled:()=>{this.verdictSettled=true,this.store.setPending(false)},telemetry:this.telemetry,...e?{scheduler:e}:{}})}acquireInternal(e,t,r,n,l=false){let i=`${this.epoch}|${e}|${t}`,o=this.entries.get(i);if(o)return l||(o.warm?o.warm=false:o.refCount+=1),o.controller;let a=r();return this.entries.set(i,{controller:a,refCount:1,warm:l}),this.destroyers.set(a,n),a}releaseInternal(e){for(let[t,r]of this.entries)if(r.controller===e){r.refCount-=1,r.refCount<=0&&(this.runDestroyer(e),this.entries.delete(t));return}}runDestroyer(e){let t=this.destroyers.get(e);this.destroyers.delete(e),t&&t(e)}buildChatController(e){let t=createChatController({auth:this.buildAuth(e.userRef),telemetry:this.telemetry,...this.errorPolicy?{errorPolicy:oc(this.errorPolicy,this.errorContext,"chat")}:{},initialConversationId:e.conversationId,petRef:e.petRef,onConversationStarted:e=>this.emit({type:"conversation_started",conversationId:e}),unread:this.unread});return this.runBootstrap(t,e),t}runBootstrap(e,t){let r={};t.petRef!==null&&(r.petRef=t.petRef),t.conversationId!==null&&(r.resumeConversationId=t.conversationId);let n=bootstrapChat(r,{controller:e});return n.then(t=>e.adoptPrompts(t.suggestedPrompts)).catch(()=>{}),this.bootstraps.set(e,n),n}buildAuth(e){return this.identity!==null&&this.currentUser!==null?{mode:"personalized",transport:this.transport,identity:this.identity,userRef:this.currentUser.userRef,sessionId:this.sessionId}:{mode:"anonymous",transport:this.transport,publishableKey:this.publishableKey,userRef:this.currentUser===null?null:e,sessionId:this.sessionId,anonIdentity:this.anonIdentity??=createAnonIdentityProvider(this.transport,this.publishableKey,this.sessionId)}}setUser(e){if(this.disposed)return;let t=e?.userRef??null,r=this.currentUser?.userRef??null;if(t===r){this.currentUser=e,e&&this.identity===null&&(this.identity=this.buildIdentity(e));return}this.pendingBeforeLogout=this.beforeLogoutSettlement(),this.identity?.clear(),this.clearTokenRefresh(),this.currentUser=e,this.identity=this.buildIdentity(e),this.rescopeAll()}async logout(){if(this.disposed)return;let e=this.currentUser===null;this.leavingSessionId=this.sessionId,this.sessionId=newSessionId(),this.anonIdentity=null,this.setUser(null),this.leavingSessionId=null,e&&this.rescopeAll();let t=this.pendingBeforeLogout;this.pendingBeforeLogout=null,t!==null&&await t,await Hu(this.kv,this.telemetry)}onBeforeLogout(e){return this.disposed?()=>{}:(this.beforeLogoutHooks.add(e),()=>{this.beforeLogoutHooks.delete(e)})}beforeLogoutSettlement(){let e=this.currentUser,t=this.identity;return Lu({leaving:e,identity:t,hooks:this.beforeLogoutHooks,telemetry:this.telemetry,graceAuth:()=>Uu({leaving:e,identity:t,transport:this.transport,sessionId:this.leavingSessionId??this.sessionId})})}async registerPet(e,t){return this.withPets("registerPet",(r,n)=>Bl(Dl(this,n,e,t),()=>t===void 0?r.registerPet(e):r.registerPet(e,t)))}updatePet(e,t){return this.withPets("updatePet",r=>r.updatePet(e,t))}deletePet(e){return this.withPets("deletePet",t=>t.deletePet(e))}eraseUserData(){return this.withPets("eraseUserData",e=>e.eraseUserData())}async withPets(e,t){if(this.disposed)return err(bc(e));let r=this.buildAuth(this.currentUser?.userRef??null),n=await t(createPetsRepository(r),r);return n.ok&&!this.disposed&&Hl(this),n}prepare(e){let t=e?.petRef??null,r=`${this.epoch}|${this.currentUser?.userRef??""}|${t??""}`,n=this.prepared;if(n!==null&&n.key===r&&(n.result===null||n.result.status==="ready"))return n.promise;let l={key:r,result:null,promise:this.runPrepare(t).then(e=>(l.result=e,e))};return this.prepared=l,l.promise}async runPrepare(e){let t=Date.now(),r=this.configFailure,n=this.disposed?bc("prepare"):r===null?null:rc(r),l=this.identity,[i,o,a]=await Promise.all([n?err(n):l===null?ok(void 0):l.currentToken().then(()=>ok(void 0),e=>(l.reportRejected?.(),err($(e)))),n?err(n):this.primeEntitlements(),e===null?void 0:n?err(n):this.primeChat(e)]),s=i.ok?o.ok&&(a?.ok??true)?"ready":"partial":"failed",u=Date.now()-t;try{this.telemetry.track("sdk.prepare.timing",{durationMs:u,status:s})}catch{}if(s==="ready")this.emit({type:"ready"});else if(s==="failed"&&!i.ok&&r===null&&!this.disposed){let e=i.error.requestId??null;this.emit({type:"error",code:i.error.code,requestId:e,context:be(this.errorContext,"runtime",e)})}/* @__PURE__ */
49
49
  return Object.freeze({status:s,durationMs:u,session:i,entitlements:o,...a?{chat:a}:{}})}async primeEntitlements(){let e=await(this.poller?.prime());return e?e.kind==="failed"?err(e.error):ok(void 0):err(makeEverfurError("internalError",{retryable:true}))}async primeChat(e){let t={userRef:this.currentUser?.userRef??null,petRef:e,conversationId:null},r=this.acquireInternal("chat",gc(t),()=>this.buildChatController(t),mc,true),n=await this.bootstraps.get(r);return n?.cause&&r.getSnapshot().conversationId===null&&(n=await this.runBootstrap(r,t)),n?.cause?err(n.cause):ok(void 0)}setActivePet(e){if(this.disposed)return;let t=e??null;t!==this.activePet&&(this.activePet=t,this.rescopeAll({keepBranding:true}))}updateEntitlements(e){this.disposed||this.configFailure===null&&this.store.set(e)}open(e){this.telemetry.track("sdk.open",{capability:e})}dispose(){this.disposed||(this.disposed=true,this.epoch+=1,this.poller?.stop(),this.sdkConfigHost!==void 0&&(this.sdkConfigHost.disposed=true,this.sdkConfigHost.store?.dispose(),this.sdkConfigHost.store=null,this.sdkConfigHost.branding.set(null)),this.identity?.clear(),this.clearTokenRefresh(),this.disposeAllControllers())}rescopeAll(e){this.epoch+=1,this.disposeAllControllers(),this.unread.reset(),this.store.reset(e),this.verdictSettled=false,this.poller?.refresh()}disposeAllControllers(){for(let e of this.entries.values())this.runDestroyer(e.controller);this.entries.clear(),this.destroyers.clear()}};function gc(e){return`${e.userRef??""}|${e.petRef??""}|${e.conversationId??""}`}function mc(e){e.dispose()}function bc(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}function yc(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function vc(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 xc(e){return e.ok?e:err(vc(e.error))}function kc(e){return{send:async(...t)=>xc(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var wc=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Cc=globalThis,Sc=Cc[wc]??(Cc[wc]=e.createContext(null));Sc.displayName??="EverfurContext";function jc(){let t=e.useContext(Sc);if(t===null)throw new s("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return t}function useEverfur(){return jc().handle}var _c=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Rc=globalThis,Ec=Rc[_c]??(Rc[_c]=e.createContext(fo));Ec.displayName??="EverfurThemeContext";function useEverfurTheme(){return e.useContext(Ec)}var Ic=()=>()=>{},zc=()=>null;function Tc(t,r){return e.useSyncExternalStore(r?.subscribe??Ic,r?.get??zc,r?.get??zc)??t}function EverfurThemeProviderCore(t){let{runtime:r}=jc(),n=r.entitlements,l=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot),i=t.seams.useColorScheme(),o=t.seams.useReducedMotion(),a=t.seams.useTextScale(),s=t.seams.useHighContrast(),u=t.seams.scaleTypeSizes,c=t.seams.typeProfile,d=t.seams.platformMonoFamily?.(),f=t.seams.isFontRegistered,p=t.clientTheme?Oc(t.clientTheme):"",h=e.useMemo(()=>t.clientTheme?parseClientBranding(t.clientTheme):null,[p]),g=Tc(l.branding??null,r.sdkConfigHost?.branding),m=e.useMemo(()=>resolveTheme({branding:g,clientOverride:h,colorScheme:i,reducedMotion:o,textScale:a,scaleTypeSizes:u,highContrast:s,...c===void 0?{}:{typeProfile:c},...d===void 0?{}:{platformMonoFamily:d},...f===void 0?{}:{isFontRegistered:f}}),[g,h,i,o,a,u,c,s,d,f]);t.seams.useResolvedTheme?.(m);let b=t.seams.isDevelopment;return e.useEffect(()=>{b===void 0||!Pc(b)||Ao(themeAdjustments({branding:g,clientOverride:h,colorScheme:i}))},[b,g,h,i]),e.createElement(Ec.Provider,{value:m},t.children)}function Oc(e){try{return JSON.stringify(e)}catch{return Object.keys(e).join("&")}}function Pc(e){try{return e()===!0}catch{return false}}function EverfurProviderCore(t){let{config:r,user:n,activePet:l,theme:i,warmUp:o,children:a,seams:s}=t,u=`${r?.publishableKey??""}|${r?.apiBaseUrl??""}|${r?.contractVersion??""}`,c=e.useRef(null),d=e.useRef(null),f=e.useRef(r?.onEvent);f.current=r?.onEvent;let p=e.useRef(e=>{f.current?.(e)}),[h,g]=e.useReducer(e=>e+1,0),m=e.useRef(null),b=e.useRef(void 0),y=n?.userRef??null;b.current!==y&&(b.current!==void 0&&(m.current=null),b.current=y);let v=m.current!==null?m.current.user:n??null,x=e.useRef(null),k=e.useRef(void 0),w=l??null;k.current!==w&&(k.current!==void 0&&(x.current=null),k.current=w);let C=x.current!==null?x.current.pet:l??null;(c.current===null||c.current.key!==u||c.current.runtime.isDisposed)&&(c.current!==null&&!c.current.runtime.isDisposed&&(d.current=c.current.runtime),c.current={key:u,runtime:createEverfurRuntime({config:Fc(s.withDefaults?s.withDefaults(r):r,p.current),user:v,activePet:C,theme:i??null},{platform:s.platform,...s.eventSourceFactory?{eventSourceFactory:s.eventSourceFactory}:{}})});let S=c.current.runtime,j=e.useRef(null);e.useEffect(()=>{let e=c.current?.runtime;e===void 0||!e.isDisposed||j.current!==e&&(j.current=e,g())}),e.useEffect(()=>{let e=d.current;e!==null&&(d.current=null,e.dispose())});let _=v?.userRef??null;e.useLayoutEffect(()=>{S.setUser(v)},[S,_]),e.useLayoutEffect(()=>{S.setActivePet(C)},[S,C]);let R=e.useRef(null);e.useEffect(()=>(R.current===S&&(R.current=null),()=>{R.current=S,Mc(()=>{R.current===S&&(R.current=null,S.dispose())})}),[S]),e.useEffect(()=>{o==="onMount"&&S.prepare(C===null?{}:{petRef:C})},[S,o,_,C]);let E=e.useMemo(()=>({setUser:e=>{m.current={user:e},S.setUser(e),g()},setActivePet:e=>{x.current={pet:e},S.setActivePet(e),g()},open:e=>S.open(e),prepare:e=>S.prepare(e),registerPet:(e,t)=>S.registerPet(e,t),updatePet:(e,t)=>S.updatePet(e,t),deletePet:e=>S.deletePet(e),eraseUserData:()=>S.eraseUserData(),logout:()=>{m.current={user:null};let e=S.logout();return g(),e}}),[S,g]),I=e.useMemo(()=>({runtime:S,handle:E,userRef:_,activePet:C,scopeEpoch:S.scopeEpoch,publishableKey:Ac(r)}),[S,E,_,C,h,u]),z=e.createElement(EverfurThemeProviderCore,{clientTheme:i??null,seams:s.theme,children:a});return e.createElement(Sc.Provider,{value:I},s.wrap?s.wrap(z):z)}function Fc(e,t){return typeof e!="object"||e===null?e:{...e,onEvent:t}}function Mc(e){if(typeof queueMicrotask=="function"){queueMicrotask(e);return}Promise.resolve().then(e)}function Ac(e){return typeof e?.publishableKey=="string"?e.publishableKey.trim():""}var $c="everfur:";function Dc(){try{if(typeof window>"u")return null;let e=window.localStorage;return e&&typeof e.getItem=="function"?e:null}catch{return null}}function createLocalStorageKv(){return{async getItem(e){try{return Dc()?.getItem($c+e)??null}catch{return null}},async setItem(e,t){try{Dc()?.setItem($c+e,t)}catch{}},async removeItem(e){try{Dc()?.removeItem($c+e)}catch{}},async keys(e){try{let t=Dc();if(t===null)return[];let r=[],n=$c+e;for(let e=0;e<t.length;e+=1){let l=t.key(e);l!==null&&l.startsWith(n)&&r.push(l.slice($c.length))}/* @__PURE__ */
50
- return Object.freeze(r)}catch{return[]}}}}var Bc="https://sdk.everfur.com",Nc=/* @__PURE__ */Object.freeze({k1:"X4wc1hwVONs4I9Vmclo9ExrfPZlH8-tgY7NmzxuA5lI"}),Lc=/* @__PURE__ */Object.freeze(["health-plan","health-plan-today","shop","shop-orders-v2","ui","televet-booking","televet-call"]),Uc=/* @__PURE__ */Object.freeze({"@everfur/sdk/web/health-plan":"health-plan","@everfur/sdk/web/health-plan/today":"health-plan-today","@everfur/sdk/web/shop":"shop","@everfur/sdk/web/shop/orders-v2":"shop-orders-v2","@everfur/sdk/web/ui":"ui","@everfur/sdk/web/televet/booking":"televet-booking","@everfur/sdk/web/televet/call":"televet-call"}),Hc=1795440709e3,Wc=3e3,qc=8e3,Vc=256*1024,Kc=4*1024*1024,Gc="web_runtime.fallback";var Yc=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeBridge@v${1}`);function Zc(){let e=globalThis,t=e[Yc];if(t!==void 0)return t;let r={major:1,host:null,defined:/* @__PURE__ */new Map,waiters:/* @__PURE__ */new Map,importSubpath:null};return e[Yc]=r,r}function Qc(e){if(typeof e!="string")return null;let t=/^(\d+)\./.exec(e);return t===null?null:Number(t[1])}function Xc(e){let t=Qc(e.React?.version);if(t===null||typeof e.React.createElement!="function")return null;let r=Zc();return r.host===null?(r.host={...e,reactMajor:t},{reactMajor:t}):r.host.React.createElement===e.React.createElement&&r.host.reactMajor===t?{reactMajor:t}:null}function Jc(){return Zc().host}var ed=(e,t)=>`${e}@${t}`;function td(e,t){return Zc().defined.get(ed(e,t))??null}function rd(e,t,r){let n=Zc(),l=n.ran??=/* @__PURE__ */new Map,i=ed(e,t),o=l.get(i);return o===void 0?n.defined.has(i)?false:(l.set(i,r),true):o===r}function nd(e,t,r){let n=td(e,t);if(n!==null)return Promise.resolve(n);let l=Zc(),i=ed(e,t);return new Promise(e=>{let t=l.waiters.get(i)??/* @__PURE__ */new Set;l.waiters.set(i,t);let n=r=>{clearTimeout(a),t.delete(o),e(r)},o=e=>n(e),a=setTimeout(()=>n(null),r);t.add(o)})}function ld(e){Zc().importSubpath=e}function id(e,t){let r=Object.keys(t).sort().map(e=>`${e}=${t[e]}`).join(",");return`v${1}|${e}|${r}`}var od=id(ke,Nc);var ad=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeBundledOnly@v${1}`),sd=globalThis,ud=()=>sd[ad]===true,cd=()=>{sd[ad]=true};var dd=/^\d{1,4}\.\d{1,5}\.\d{1,6}(?:-[0-9A-Za-z.-]{1,64})?$/,fd=/^[a-z0-9][a-z0-9.-]{0,80}\.js$/,pd=/^sha384-[A-Za-z0-9+/]{64}$/,hd=/^[0-9a-f]{32}$/,gd=/^[A-Za-z0-9_-]+$/,md=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function bd(e){if(typeof e!="string"||e.length===0||!gd.test(e))return null;let t=e.replace(/-/g,"+").replace(/_/g,"/");try{let e=atob(t+"=".repeat((4-t.length%4)%4)),r=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)r[t]=e.charCodeAt(t);return r}catch{return null}}var yd=/^\d{4}(-\d\d){2}T\d\d(:\d\d){2}(\.\d{1,3})?Z$/,vd=14*864e5;function xd(e){if(typeof e!="string"||!yd.test(e))return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function kd(e){if(!md(e)||!Array.isArray(e.react)||!md(e.parts))return null;let t=e.react.filter(e=>Number.isInteger(e)&&e>0);if(t.length===0||t.length!==e.react.length)return null;let r={};for(let[t,n]of Object.entries(e.parts))if(Lc.includes(t)){if(!md(n)||typeof n.path!="string"||typeof n.integrity!="string"||!fd.test(n.path)||!pd.test(n.integrity))return null;r[t]={path:n.path,integrity:n.integrity}}return{react:t,parts:r}}function wd(e){if(!md(e)||e.schema!==1||!Number.isInteger(e.major))return null;let t=xd(e.issuedAt),r=xd(e.expiresAt);if(t===null||r===null||typeof e.stable!="string"||!dd.test(e.stable)||r<=t||r-t>vd||!md(e.versions))return null;let n={};for(let[t,r]of Object.entries(e.versions)){let e=kd(r);if(!dd.test(t)||e===null)return null;n[t]=e}let l=null;if(e.canary!==void 0&&e.canary!==null){let t=e.canary;if(!md(t)||typeof t.version!="string"||!dd.test(t.version)||typeof t.percent!="number"||!Number.isFinite(t.percent)||t.percent<0||t.percent>100)return null;l={version:t.version,percent:t.percent}}let i={};if(e.pins!==void 0){if(!md(e.pins))return null;for(let[t,r]of Object.entries(e.pins)){if(!hd.test(t)||typeof r!="string"||!dd.test(r))return null;i[t]=r}}let o=[];if(e.revoked!==void 0){if(!Array.isArray(e.revoked)||!e.revoked.every(e=>typeof e=="string"&&dd.test(e)))return null;o=e.revoked}return{schema:1,major:e.major,issuedAt:t,expiresAt:r,stable:e.stable,canary:l,pins:i,revoked:o,versions:n}}async function Cd(e,t,r,n,l=Hc){if(!md(e)||e.v!==1||typeof e.keyId!="string")return{ok:false,reason:"manifest-shape"};let i=bd(e.payload),o=bd(e.signature);if(i===null||o===null||o.length!==64)return{ok:false,reason:"manifest-shape"};let a=Object.prototype.hasOwnProperty.call(t,e.keyId)?bd(t[e.keyId]):null;if(a===null||a.length!==32)return{ok:false,reason:"signature-key"};let s;try{let e=await r.subtle.importKey("raw",a,{name:"Ed25519"},!1,["verify"]);s=await r.subtle.verify({name:"Ed25519"},e,o,i)}catch{return{ok:false,reason:"signature-unsupported"}}if(!s)return{ok:false,reason:"signature-invalid"};let u;try{u=JSON.parse((new TextDecoder).decode(i))}catch{return{ok:false,reason:"manifest-shape"}}let c=wd(u);return c===null?{ok:false,reason:"manifest-shape"}:c.major!==1?{ok:false,reason:"manifest-major"}:n>=c.expiresAt?{ok:false,reason:"manifest-expired"}:c.issuedAt<l?{ok:false,reason:"manifest-stale"}:{ok:true,manifest:c}}function Sd(e,t){let[r="",n]=e.split(/-(.*)/s,2),[l="",i]=t.split(/-(.*)/s,2),o=r.split(".").map(Number),a=l.split(".").map(Number);for(let e=0;e<3;e+=1){let t=(o[e]??0)-(a[e]??0);if(t!==0)return t<0?-1:1}if(n===i)return 0;if(n===void 0)return 1;if(i===void 0)return-1;let s=n.split("."),u=i.split(".");for(let e=0;;e+=1){let t=s[e],r=u[e];if(t===r)continue;if(t===void 0||r===void 0)return t===void 0?-1:1;let n=/^\d+$/.test(t),l=/^\d+$/.test(r);return n!==l?n?-1:1:(n?Number(t)<Number(r):t<r)?-1:1}}function jd(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619)>>>0;return t>>>0}function _d(e,t){return jd(`${e??"-"}:${t}`)%100}async function Rd(e,t){try{let r=await t.subtle.digest("SHA-256",(new TextEncoder).encode(e));return Array.from(new Uint8Array(r),e=>e.toString(16).padStart(2,"0")).join("").slice(0,32)}catch{return null}}function Ed(e,t){let r=t.tenantKey===null?void 0:e.pins[t.tenantKey],n,l;if(r!==void 0?(n=r,l="pin"):e.canary!==null&&_d(t.tenantKey,t.sessionBucket)<e.canary.percent?(n=e.canary.version,l="canary"):(n=e.stable,l="stable"),e.revoked.includes(n))return{use:"bundled",reason:"revoked"};if(l!=="pin"&&Sd(n,t.bundledVersion)<0&&!e.revoked.includes(t.bundledVersion))return{use:"bundled",reason:"bundled-newer"};let i=e.versions[n];return i===void 0?{use:"bundled",reason:"version-missing"}:{use:"remote",version:n,entry:i,reason:l}}var Id=/^manifest-(fetch|timeout)$/,zd="everfur:web-runtime:unreachable",Td=10*6e4;function Od(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}async function Pd(e,t,r,n,l="default"){let i=typeof AbortController=="function"?new AbortController:null,o=null,a=()=>{},s=new Promise(e=>{a=e}),u=setTimeout(()=>{a("timeout"),i?.abort(),o?.()},r),c=e=>Promise.race([e,s]);try{let r=await c(e(t,{mode:"cors",credentials:"omit",referrerPolicy:"no-referrer",redirect:"error",cache:l,...i?{signal:i.signal}:{}}));if(r==="timeout")return{ok:!1,why:"timeout"};if(!r.ok)return{ok:!1,why:"http"};let a=Number(r.headers.get("content-length")??Number.NaN),s=r.body?.getReader()??null;if(o=()=>{s!==null&&s.cancel().catch(()=>{})},Number.isFinite(a)&&a>n)return o(),{ok:!1,why:"too-large"};if(s===null){let e=await c(r.arrayBuffer());return e==="timeout"?{ok:!1,why:"timeout"}:e.byteLength>n?{ok:!1,why:"too-large"}:{ok:!0,bytes:new Uint8Array(e)}}let u=[],d=0;for(;;){let e=await c(s.read());if(e==="timeout")return{ok:!1,why:"timeout"};if(e.done)break;if(d+=e.value.byteLength,d>n)return o(),{ok:!1,why:"too-large"};u.push(e.value)}let f=new Uint8Array(d),p=0;for(let e of u)f.set(e,p),p+=e.byteLength;return{ok:!0,bytes:f}}catch{return{ok:false,why:i?.signal.aborted?"timeout":"error"}}finally{clearTimeout(u)}}function Fd(e){let t=e.hasDom&&Object.keys(e.keys).length>0&&e.fetch!==null&&e.crypto!==null,r=e.manifestTimeoutMs??Wc,n=e.partTimeoutMs??qc,l=e.manifestMaxBytes??Vc,i=e.partMaxBytes??Kc,o=`${e.origin}/web-runtime`,a=null,s=/* @__PURE__ */new Map,u=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map,f=null,p=null;async function h(){let t=await Pd(e.fetch,`${o}/${1}/manifest.json`,r,l,"no-store");if(!t.ok){let r=t.why==="timeout"?"manifest-timeout":t.why==="too-large"?"manifest-too-large":"manifest-fetch";if(t.why==="error"||t.why==="timeout")try{e.unreachable?.()?.setItem(zd,`${e.now()+Td}|${r}`)}catch{}return{ok:false,reason:r}}let n;try{n=JSON.parse((new TextDecoder).decode(t.bytes))}catch{return{ok:false,reason:"manifest-shape"}}return Cd(n,e.keys,e.crypto,e.now(),e.minIssuedAt??Hc)}function g(t){let r=t??"",n=s.get(r);if(n)return n;let l=(async()=>{a??=h();let r=await a;if(!r.ok)return{ok:false,reason:r.reason};let n=t===null?null:await Rd(t,e.crypto),l=Ed(r.manifest,{tenantKey:n,sessionBucket:e.sessionBucket(),bundledVersion:e.bundledVersion});return l.use==="remote"?{ok:true,choice:l}:{ok:false,reason:l.reason}})();return s.set(r,l),l}async function m(t,r){if(await Promise.resolve(),ud())return{ok:false,reason:"disabled",version:null};let l=Jc();if(l===null)return{ok:false,reason:"react-unregistered",version:null};let a=await g(r);if(!a.ok)return{ok:false,reason:a.reason,version:null};let{version:s,entry:u}=a.choice;if(!u.react.includes(l.reactMajor))return{ok:false,reason:"react-mismatch",version:s};let c=u.parts[t];if(c===void 0)return{ok:false,reason:"part-missing",version:s};if(!rd(t,s,c.integrity))return{ok:false,reason:"part-integrity",version:s};let d=td(t,s);if(d!==null)return{ok:true,namespace:d,version:s};let f=`${o}/${s}/${c.path}`;if(ud())return{ok:false,reason:"disabled",version:s};let h=await Pd(e.fetch,f,n,i);if(!h.ok)return{ok:false,reason:h.why==="timeout"?"part-timeout":h.why==="too-large"?"part-too-large":"part-fetch",version:s};let m=h.bytes,b;try{b=`sha384-${Od(new Uint8Array(await e.crypto.subtle.digest("SHA-384",m)))}`}catch{return{ok:false,reason:"part-integrity",version:s}}if(b!==c.integrity)return{ok:false,reason:"part-integrity",version:s};if(ud())return{ok:false,reason:"disabled",version:s};let y=e.createBlobUrl?.(m)??null,v="error";if(y!==null&&(v=await e.runScript(y,c.integrity,"blob",p),e.revokeBlobUrl(y)),v==="error"&&(v=await e.runScript(f,c.integrity,"cdn",p)),v==="error")return{ok:false,reason:"part-load",version:s};let x=await nd(t,s,50);return x===null?{ok:false,reason:"part-load",version:s}:{ok:true,namespace:x,version:s}}let b=t?null:e.hasDom?"disabled":"server";try{let[t,r]=(e.unreachable?.()?.getItem(zd)??"").split("|");Number(t)>e.now()&&Id.test(String(r))&&(b??=r)}catch{}function y(e,t){if(b!==null)return Promise.resolve({ok:false,reason:b,version:null});f??=t;let r=`${t??""}|${e}`,n=u.get(r);if(n)return n;let l=m(e,t).then(e=>e,()=>({ok:false,reason:"part-load",version:null}));return l.then(e=>c.set(r,e)),u.set(r,l),l}return t&&ld(e=>{let t=Object.prototype.hasOwnProperty.call(Uc,e)?Uc[e]:void 0,r=()=>{let t=d.get(e);return t?t():Promise.reject(new TypeError(`${e} is not available to the Everfur web runtime`))};return t===void 0?r():y(t,f).then(e=>e.ok?e.namespace:r())}),{enabled:t,peek:(e,t)=>b!==null?{ok:false,reason:b,version:null}:c.get(`${t??""}|${e}`)??null,load:y,registerHostSubpaths:e=>{for(let[t,r]of Object.entries(e))d.has(t)||d.set(t,r)},setCspNonce:e=>{p=e===null||e===""?null:e}}}var Md="everfur:web-runtime:bucket",Ad=null;function $d(){try{let e=globalThis.sessionStorage?.getItem(Md);if(e)return e}catch{}Ad??=Math.floor(Math.random()*4294967296).toString(16);try{globalThis.sessionStorage?.setItem(Md,Ad)}catch{}return Ad}function Dd(e){return(t,r,n,l)=>new Promise(i=>{let o;try{o=e.createElement("script"),o.type="module",n==="cdn"&&(o.integrity=r,o.crossOrigin="anonymous"),l!==null&&(o.nonce=l),o.addEventListener("load",()=>{o.remove(),i("load")}),o.addEventListener("error",()=>{o.remove(),i("error")}),o.src=t,(e.head??e.documentElement).appendChild(o)}catch{i("error")}})}function Bd(){let e=typeof document>"u"?null:document,t=globalThis.crypto;return{origin:Bc,keys:Nc,bundledVersion:ke,fetch:typeof fetch=="function"?fetch.bind(globalThis):null,crypto:t?.subtle?t:null,hasDom:e!==null&&typeof window<"u",runScript:e===null?()=>Promise.resolve("error"):Dd(e),createBlobUrl:typeof Blob=="function"&&typeof URL.createObjectURL=="function"?e=>{try{return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}catch{return null}}:null,revokeBlobUrl:e=>{try{URL.revokeObjectURL(e)}catch{}},now:()=>Date.now(),sessionBucket:$d,unreachable:()=>globalThis.sessionStorage}}var Nd=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeLoader@${od}`);function Ld(){let e=globalThis;return e[Nd]??=Fd(Bd())}var Ud=/* @__PURE__ */new Set(["disabled","server","bundled-newer"]),Hd=/* @__PURE__ */new Set;function Wd(e,t,r,n){if(Ud.has(r))return;let l=`${t}|${r}`;if(!Hd.has(l)){Hd.add(l);try{e?.trackExpectedFailure(Gc,{part:t,reason:r,version:n,bundled:ke})}catch{}}}var qd=/* @__PURE__ */new Set,Vd=class extends e.Component{constructor(){super(...arguments);this.state={failed:false}}static getDerivedStateFromError(){return{failed:true}}componentDidCatch(){this.props.onError()}render(){return this.state.failed?this.props.fallback():this.props.children}},Kd=/* @__PURE__ */new Map;function Gd(t,r,n){let l=`${r??""}|${t.part}|${t.name}`,i=Kd.get(l);return i===void 0&&(i=e.lazy(async()=>{let e=await Ld().load(t.part,r),l=e.ok?e.namespace[t.name]:void 0;return e.ok&&typeof l!="function"&&(typeof l!="object"||l===null)?(Wd(n.current,t.part,"part-missing",e.version),{default:t.bundled}):(e.ok||Wd(n.current,t.part,e.reason,e.version),{default:e.ok?l:t.bundled})}),Kd.set(l,i)),i}var Yd=()=>()=>{},Zd=()=>false,Qd=()=>true;function RuntimeSurface({spec:t,props:r}){let n=e.useContext(Sc),l=ud(),a=n?.publishableKey?n.publishableKey:null,s=e.useRef(null);s.current=n?.runtime.registry?.services?.telemetry??null;let u=e.useSyncExternalStore(Yd,Zd,Qd),c=e.useRef(null),[,d]=e.useState(0),f=l?null:Ld();if(t.hostSubpaths!==void 0&&f?.enabled&&f.registerHostSubpaths(t.hostSubpaths),u)c.current=t.wait==="bundled"&&f!==null?"hydrate":"bundled";else if(c.current===null)if(!f?.enabled||qd.has(t.part))c.current="bundled";else if(Xc({React:i,ReactDOM:o})===null)Wd(s.current,t.part,"react-mismatch",null),c.current="bundled";else{let e=f.peek(t.part,a);c.current=e===null?"suspense":e.ok?"direct":"bundled"}let p=c.current,h=u||p!=="hydrate"?null:f?.peek(t.part,a)??null,g=!u&&p==="hydrate"&&h===null&&f?.enabled===true&&!qd.has(t.part);e.useEffect(()=>{if(!g||f===null)return;if(Xc({React:i,ReactDOM:o})===null){Wd(s.current,t.part,"react-mismatch",null);return}let e=true;return f.load(t.part,a).then(r=>{r.ok||Wd(s.current,t.part,r.reason,r.version),e&&d(e=>e+1)}),()=>{e=false}},[g,f,t.part,a]);let m=()=>e.createElement(t.bundled,r),b=r=>e.createElement(Vd,{fallback:m,onError:()=>{qd.add(t.part),Wd(s.current,t.part,"render",null)},children:r});if(u||p==="bundled")return m();if(p==="hydrate"||p==="direct"){let n=h??f?.peek(t.part,a),l=n?.ok?n.namespace[t.name]:void 0;return l===void 0||qd.has(t.part)?m():b(e.createElement(l,r))}let y=Gd(t,a,s),v=t.wait==="bundled"?m():e.createElement("div",{"data-everfur-runtime":"loading","aria-busy":true});return b(e.createElement(e.Suspense,{fallback:v},e.createElement(y,r)))}var Xd=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeRenderer@${od}`),Jd=globalThis;function ef(e,t=false){e===null?delete Jd[Xd]:(t||Jd[Xd]===void 0)&&(Jd[Xd]=e)}var tf=RuntimeSurface,rf=(t,r)=>e.createElement(tf,{spec:t,props:r});function nf(e){if(ef(rf),e!==void 0&&e!==""){let t=Ld();t.enabled&&t.setCspNonce(e)}}var lf=/* @__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[lf[t]]}}function of(e,t){let{scale:r,scaleCaps:n}=e.type,l=n[t];return l>0?Math.min(r,l):r}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[lf[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function af(){try{return process.env.NODE_ENV!=="production"}catch{return false}}var sf=/* @__PURE__ */new Map,uf=/* @__PURE__ */new Set,cf=typeof document>"u"?e.useEffect:e.useLayoutEffect;function df(e){return e.cssSrc!==void 0?`css\n${e.cssSrc}`:`file\n${e.family}\n${e.src??""}\n${e.weight??"400"}\n${e.style??"normal"}`}function ff(e,t){if(!t)return;let r=e.cssSrc??e.src??"",n=`[everfur] A font in appearance.fonts did not load: "${e.family}" from ${r}. The text renders in the fallback font. If your page sets a Content-Security-Policy, allow this host in font-src`+(e.cssSrc!==void 0?" and style-src (and the font files the stylesheet names in font-src).":".");if(!uf.has(n)){uf.add(n);try{globalThis.console?.warn?.(n)}catch{}}}function pf(e){let t=document.getElementsByTagName("link");for(let r=0;r<t.length;r+=1){let n=t[r];if(n.rel==="stylesheet"&&n.getAttribute("href")===e)return n}return null}function hf(e){return pf(e)!==null?Promise.resolve(true):new Promise(t=>{let r=document.createElement("link");r.rel="stylesheet",r.href=e,r.setAttribute("data-everfur-font",""),r.addEventListener("load",()=>t(true)),r.addEventListener("error",()=>t(false)),document.head.appendChild(r)})}function gf(e){let t=document.fonts;return new FontFace(e.family,`url("${e.src}")`,{display:"swap",weight:e.weight??"400",style:e.style??"normal"}).load().then(e=>(t.add(e),true)).catch(()=>false)}function mf(e,t=false){let r=df(e),n=sf.get(r);if(n===void 0){n=Promise.resolve(false);try{if(typeof document<"u"){let t=e.cssSrc===void 0?null:Qa(e.cssSrc),r=e.src===void 0?null:Qa(e.src);t!==null?n=hf(t):r!==null&&(n=gf({...e,src:r}))}}catch{n=Promise.resolve(false)}let l=n.then(r=>(r||ff(e,t),r));sf.set(r,l),n=l}return n}function bf(e,t){let r=e.type.fontSources;cf(()=>{if(r.length===0)return;let e=false;try{e=t()}catch{}for(let t of r)mf(t,e)},[r,t])}var yf=/* @__PURE__ */new RegExp(`^${Oa}\\/fonts\\/[\\w./-]+\\.woff2$`);function vf(e){return yf.test(e)&&!e.includes("..")}var xf=/* @__PURE__ */new Map;function kf(e,t,r="400"){let n=e.trim(),l=`${n}\n${t}\n${r}`,i=xf.get(l);if(i===void 0){if(i=Promise.resolve(false),t!==null&&n!==""&&n!=="System"&&vf(t))try{let e=document.fonts;i=new FontFace(n,`url("${t}") format("woff2")`,{display:"swap",weight:r}).load().then(t=>(e.add(t),!0)).catch(()=>!1)}catch{}xf.set(l,i)}return i}var wf=["regular","medium","bold","mono","monoMedium","monoBold"];function Cf(t){let{families:r,fontUrls:n,weight:l,namedFaces:i}=t.type;e.useEffect(()=>{for(let e of wf){let t=n[e];t!=null&&kf(r[e],t,i[e]?l.regular:l[lf[e]])}},[r,n,l,i]),bf(t,af)}function Sf(e){if(typeof window>"u"||typeof window.matchMedia!="function")return null;try{return window.matchMedia(e)??null}catch{return null}}function jf(e){return t=>{let r=Sf(e);return r===null||typeof r.addEventListener!="function"?()=>{}:(r.addEventListener("change",t),()=>r.removeEventListener?.("change",t))}}var _f="(prefers-color-scheme: dark)",Rf="(prefers-color-scheme: light)",Ef="(prefers-reduced-motion: reduce)",If="(prefers-contrast: more)",zf=jf(_f),Tf=jf(Ef),Of=jf(If);function Pf(){let e=Sf(_f);return e===null?null:e.matches?"dark":Sf(Rf)?.matches?"light":null}function Ff(){return Sf(Ef)?.matches===true}function Mf(){return Sf(If)?.matches===true}var Af=16,$f=false;var Df=null;function Bf(e){return Number.parseFloat(window.getComputedStyle(e).fontSize)}function Nf(){let e=document.body??document.documentElement,t=document.createElement("span");t.setAttribute("aria-hidden","true"),t.style.setProperty("position","absolute","important"),t.style.setProperty("visibility","hidden","important"),t.style.setProperty("font-size","medium","important"),e.appendChild(t);try{return Bf(t)}finally{t.remove()}}function Lf(){if(typeof document>"u"||typeof window>"u"||typeof window.getComputedStyle!="function")return 1;try{let e=$f?Bf(document.documentElement):Nf();return Number.isFinite(e)&&e>0?e/Af:1}catch{return 1}}function Uf(){return Df===null&&(Df=Lf()),Df}function Hf(e){if(typeof window>"u"||typeof window.addEventListener!="function")return()=>{};let t=()=>{Df=null,e()};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}function Wf(){return e.useSyncExternalStore(zf,Pf,()=>null)}function qf(){return e.useSyncExternalStore(Tf,Ff,()=>false)}function Vf(){return e.useSyncExternalStore(Of,Mf,()=>false)}function Kf(){return e.useSyncExternalStore(Hf,Uf,()=>1)}var Gf=/* @__PURE__ */Object.freeze({useColorScheme:Wf,useReducedMotion:qf,useTextScale:Kf,useHighContrast:Vf,scaleTypeSizes:true,useResolvedTheme:Cf,isDevelopment:af});function Yf(e){return e.storage===void 0?{...e,storage:createLocalStorageKv()}:e}var Zf=/* @__PURE__ */Object.freeze({platform:"web",withDefaults:Yf,theme:Gf});function EverfurProvider(t){let{cspNonce:r,webRuntime:n,...l}=t;return n!==void 0&&n!=="updates"&&cd(),ud()||nf(r),e.createElement(EverfurProviderCore,{...l,seams:Zf})}function useCapability(t){let{runtime:r}=jc(),n=r.entitlements,l=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return e.useMemo(()=>decideCapability(t,l.decisions,{isPending:l.isPending}),[t,l])}function Qf(t){let{runtime:r}=jc(),n=r.entitlements,l=e.useCallback(e=>n===void 0?()=>{}:n.subscribe(e),[n]),i=e.useCallback(()=>{if(n===void 0)return false;let e=n.getSnapshot();return decideCapability(t,e.decisions,{isPending:e.isPending}).enabled},[n,t]);return e.useSyncExternalStore(l,i,i)}var Xf=class extends e.Component{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:t,fallback:r,resetKey:n}){return e.createElement(Xf,{fallback:r,resetKey:n,children:e.createElement(RenderHost,{render:t})})}function Jf(e,t,r){return Math.round(r*of(e,t)*10)/10}var ep='system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',tp="System";function rp(e){let t=e.trim();return t.length===0||t===tp?ep:`${lp(t)}, ${ep}`}function np(e){let t=e.trim();return t.length===0||t==="monospace"?"ui-monospace, Menlo, Consolas, monospace":`${lp(t)}, ui-monospace, Menlo, Consolas, monospace`}function lp(e){return`"${e.replace(/[\\"]/g,"\\$&")}"`}function faceCss(e,t){let r=e.type,n=r.families[t];return{fontFamily:t==="mono"||t==="monoMedium"||t==="monoBold"?np(n):rp(n),fontWeight:r.namedFaces[t]?r.weight.regular:r.weight[lf[t]]}}function headingFaceCss(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type,l=faceCss(e,t);return r===null&&n===null?l:r!==null?{fontFamily:rp(r),fontWeight:n??e.type.weight[lf[t]]}:e.type.namedFaces[t]||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}var ip=/* @__PURE__ */Object.freeze({textAlign:"start"});var op=48;function ap(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(t){let{capability:r,children:l,renderDisabled:i,renderPending:o,style:a,className:s}=t,u=useCapability(r),c=e.useMemo(()=>ap(u),[u]);switch(c){case"enabled":return l;case"pending":return o?/* @__PURE__ */n.jsx(HostRender,{render:o,fallback:/* @__PURE__ */n.jsx(PendingSkeleton,{capability:r,style:a,className:s})}):/* @__PURE__ */n.jsx(PendingSkeleton,{capability:r,style:a,className:s});case"disabled":return i?/* @__PURE__ */n.jsx(HostRender,{render:()=>i(u),fallback:/* @__PURE__ */n.jsx(OffState,{decision:u,style:a,className:s}),resetKey:u}):/* @__PURE__ */n.jsx(OffState,{decision:u,style:a,className:s});default:return assertNever(c)}}function PendingSkeleton({capability:t,style:r,className:l}){let i=useEverfurTheme(),o=e.useMemo(()=>sp(i),[i]);/* @__PURE__ */
50
+ return Object.freeze(r)}catch{return[]}}}}var Bc="https://sdk.everfur.com",Nc=/* @__PURE__ */Object.freeze({k1:"X4wc1hwVONs4I9Vmclo9ExrfPZlH8-tgY7NmzxuA5lI"}),Lc=/* @__PURE__ */Object.freeze(["health-plan","health-plan-today","shop","shop-orders-v2","ui","televet-booking","televet-call"]),Uc=/* @__PURE__ */Object.freeze({"@everfur/sdk/web/health-plan":"health-plan","@everfur/sdk/web/health-plan/today":"health-plan-today","@everfur/sdk/web/shop":"shop","@everfur/sdk/web/shop/orders-v2":"shop-orders-v2","@everfur/sdk/web/ui":"ui","@everfur/sdk/web/televet/booking":"televet-booking","@everfur/sdk/web/televet/call":"televet-call"}),Hc=1795449278e3,Wc=3e3,qc=8e3,Vc=256*1024,Kc=4*1024*1024,Gc="web_runtime.fallback";var Yc=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeBridge@v${1}`);function Zc(){let e=globalThis,t=e[Yc];if(t!==void 0)return t;let r={major:1,host:null,defined:/* @__PURE__ */new Map,waiters:/* @__PURE__ */new Map,importSubpath:null};return e[Yc]=r,r}function Qc(e){if(typeof e!="string")return null;let t=/^(\d+)\./.exec(e);return t===null?null:Number(t[1])}function Xc(e){let t=Qc(e.React?.version);if(t===null||typeof e.React.createElement!="function")return null;let r=Zc();return r.host===null?(r.host={...e,reactMajor:t},{reactMajor:t}):r.host.React.createElement===e.React.createElement&&r.host.reactMajor===t?{reactMajor:t}:null}function Jc(){return Zc().host}var ed=(e,t)=>`${e}@${t}`;function td(e,t){return Zc().defined.get(ed(e,t))??null}function rd(e,t,r){let n=Zc(),l=n.ran??=/* @__PURE__ */new Map,i=ed(e,t),o=l.get(i);return o===void 0?n.defined.has(i)?false:(l.set(i,r),true):o===r}function nd(e,t,r){let n=td(e,t);if(n!==null)return Promise.resolve(n);let l=Zc(),i=ed(e,t);return new Promise(e=>{let t=l.waiters.get(i)??/* @__PURE__ */new Set;l.waiters.set(i,t);let n=r=>{clearTimeout(a),t.delete(o),e(r)},o=e=>n(e),a=setTimeout(()=>n(null),r);t.add(o)})}function ld(e){Zc().importSubpath=e}function id(e,t){let r=Object.keys(t).sort().map(e=>`${e}=${t[e]}`).join(",");return`v${1}|${e}|${r}`}var od=id(ke,Nc);var ad=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeBundledOnly@v${1}`),sd=globalThis,ud=()=>sd[ad]===true,cd=()=>{sd[ad]=true};var dd=/^\d{1,4}\.\d{1,5}\.\d{1,6}(?:-[0-9A-Za-z.-]{1,64})?$/,fd=/^[a-z0-9][a-z0-9.-]{0,80}\.js$/,pd=/^sha384-[A-Za-z0-9+/]{64}$/,hd=/^[0-9a-f]{32}$/,gd=/^[A-Za-z0-9_-]+$/,md=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function bd(e){if(typeof e!="string"||e.length===0||!gd.test(e))return null;let t=e.replace(/-/g,"+").replace(/_/g,"/");try{let e=atob(t+"=".repeat((4-t.length%4)%4)),r=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)r[t]=e.charCodeAt(t);return r}catch{return null}}var yd=/^\d{4}(-\d\d){2}T\d\d(:\d\d){2}(\.\d{1,3})?Z$/,vd=14*864e5;function xd(e){if(typeof e!="string"||!yd.test(e))return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function kd(e){if(!md(e)||!Array.isArray(e.react)||!md(e.parts))return null;let t=e.react.filter(e=>Number.isInteger(e)&&e>0);if(t.length===0||t.length!==e.react.length)return null;let r={};for(let[t,n]of Object.entries(e.parts))if(Lc.includes(t)){if(!md(n)||typeof n.path!="string"||typeof n.integrity!="string"||!fd.test(n.path)||!pd.test(n.integrity))return null;r[t]={path:n.path,integrity:n.integrity}}return{react:t,parts:r}}function wd(e){if(!md(e)||e.schema!==1||!Number.isInteger(e.major))return null;let t=xd(e.issuedAt),r=xd(e.expiresAt);if(t===null||r===null||typeof e.stable!="string"||!dd.test(e.stable)||r<=t||r-t>vd||!md(e.versions))return null;let n={};for(let[t,r]of Object.entries(e.versions)){let e=kd(r);if(!dd.test(t)||e===null)return null;n[t]=e}let l=null;if(e.canary!==void 0&&e.canary!==null){let t=e.canary;if(!md(t)||typeof t.version!="string"||!dd.test(t.version)||typeof t.percent!="number"||!Number.isFinite(t.percent)||t.percent<0||t.percent>100)return null;l={version:t.version,percent:t.percent}}let i={};if(e.pins!==void 0){if(!md(e.pins))return null;for(let[t,r]of Object.entries(e.pins)){if(!hd.test(t)||typeof r!="string"||!dd.test(r))return null;i[t]=r}}let o=[];if(e.revoked!==void 0){if(!Array.isArray(e.revoked)||!e.revoked.every(e=>typeof e=="string"&&dd.test(e)))return null;o=e.revoked}return{schema:1,major:e.major,issuedAt:t,expiresAt:r,stable:e.stable,canary:l,pins:i,revoked:o,versions:n}}async function Cd(e,t,r,n,l=Hc){if(!md(e)||e.v!==1||typeof e.keyId!="string")return{ok:false,reason:"manifest-shape"};let i=bd(e.payload),o=bd(e.signature);if(i===null||o===null||o.length!==64)return{ok:false,reason:"manifest-shape"};let a=Object.prototype.hasOwnProperty.call(t,e.keyId)?bd(t[e.keyId]):null;if(a===null||a.length!==32)return{ok:false,reason:"signature-key"};let s;try{let e=await r.subtle.importKey("raw",a,{name:"Ed25519"},!1,["verify"]);s=await r.subtle.verify({name:"Ed25519"},e,o,i)}catch{return{ok:false,reason:"signature-unsupported"}}if(!s)return{ok:false,reason:"signature-invalid"};let u;try{u=JSON.parse((new TextDecoder).decode(i))}catch{return{ok:false,reason:"manifest-shape"}}let c=wd(u);return c===null?{ok:false,reason:"manifest-shape"}:c.major!==1?{ok:false,reason:"manifest-major"}:n>=c.expiresAt?{ok:false,reason:"manifest-expired"}:c.issuedAt<l?{ok:false,reason:"manifest-stale"}:{ok:true,manifest:c}}function Sd(e,t){let[r="",n]=e.split(/-(.*)/s,2),[l="",i]=t.split(/-(.*)/s,2),o=r.split(".").map(Number),a=l.split(".").map(Number);for(let e=0;e<3;e+=1){let t=(o[e]??0)-(a[e]??0);if(t!==0)return t<0?-1:1}if(n===i)return 0;if(n===void 0)return 1;if(i===void 0)return-1;let s=n.split("."),u=i.split(".");for(let e=0;;e+=1){let t=s[e],r=u[e];if(t===r)continue;if(t===void 0||r===void 0)return t===void 0?-1:1;let n=/^\d+$/.test(t),l=/^\d+$/.test(r);return n!==l?n?-1:1:(n?Number(t)<Number(r):t<r)?-1:1}}function jd(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619)>>>0;return t>>>0}function _d(e,t){return jd(`${e??"-"}:${t}`)%100}async function Rd(e,t){try{let r=await t.subtle.digest("SHA-256",(new TextEncoder).encode(e));return Array.from(new Uint8Array(r),e=>e.toString(16).padStart(2,"0")).join("").slice(0,32)}catch{return null}}function Ed(e,t){let r=t.tenantKey===null?void 0:e.pins[t.tenantKey],n,l;if(r!==void 0?(n=r,l="pin"):e.canary!==null&&_d(t.tenantKey,t.sessionBucket)<e.canary.percent?(n=e.canary.version,l="canary"):(n=e.stable,l="stable"),e.revoked.includes(n))return{use:"bundled",reason:"revoked"};if(l!=="pin"&&Sd(n,t.bundledVersion)<0&&!e.revoked.includes(t.bundledVersion))return{use:"bundled",reason:"bundled-newer"};let i=e.versions[n];return i===void 0?{use:"bundled",reason:"version-missing"}:{use:"remote",version:n,entry:i,reason:l}}var Id=/^manifest-(fetch|timeout)$/,zd="everfur:web-runtime:unreachable",Td=10*6e4;function Od(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}async function Pd(e,t,r,n,l="default"){let i=typeof AbortController=="function"?new AbortController:null,o=null,a=()=>{},s=new Promise(e=>{a=e}),u=setTimeout(()=>{a("timeout"),i?.abort(),o?.()},r),c=e=>Promise.race([e,s]);try{let r=await c(e(t,{mode:"cors",credentials:"omit",referrerPolicy:"no-referrer",redirect:"error",cache:l,...i?{signal:i.signal}:{}}));if(r==="timeout")return{ok:!1,why:"timeout"};if(!r.ok)return{ok:!1,why:"http"};let a=Number(r.headers.get("content-length")??Number.NaN),s=r.body?.getReader()??null;if(o=()=>{s!==null&&s.cancel().catch(()=>{})},Number.isFinite(a)&&a>n)return o(),{ok:!1,why:"too-large"};if(s===null){let e=await c(r.arrayBuffer());return e==="timeout"?{ok:!1,why:"timeout"}:e.byteLength>n?{ok:!1,why:"too-large"}:{ok:!0,bytes:new Uint8Array(e)}}let u=[],d=0;for(;;){let e=await c(s.read());if(e==="timeout")return{ok:!1,why:"timeout"};if(e.done)break;if(d+=e.value.byteLength,d>n)return o(),{ok:!1,why:"too-large"};u.push(e.value)}let f=new Uint8Array(d),p=0;for(let e of u)f.set(e,p),p+=e.byteLength;return{ok:!0,bytes:f}}catch{return{ok:false,why:i?.signal.aborted?"timeout":"error"}}finally{clearTimeout(u)}}function Fd(e){let t=e.hasDom&&Object.keys(e.keys).length>0&&e.fetch!==null&&e.crypto!==null,r=e.manifestTimeoutMs??Wc,n=e.partTimeoutMs??qc,l=e.manifestMaxBytes??Vc,i=e.partMaxBytes??Kc,o=`${e.origin}/web-runtime`,a=null,s=/* @__PURE__ */new Map,u=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map,f=null,p=null;async function h(){let t=await Pd(e.fetch,`${o}/${1}/manifest.json`,r,l,"no-store");if(!t.ok){let r=t.why==="timeout"?"manifest-timeout":t.why==="too-large"?"manifest-too-large":"manifest-fetch";if(t.why==="error"||t.why==="timeout")try{e.unreachable?.()?.setItem(zd,`${e.now()+Td}|${r}`)}catch{}return{ok:false,reason:r}}let n;try{n=JSON.parse((new TextDecoder).decode(t.bytes))}catch{return{ok:false,reason:"manifest-shape"}}return Cd(n,e.keys,e.crypto,e.now(),e.minIssuedAt??Hc)}function g(t){let r=t??"",n=s.get(r);if(n)return n;let l=(async()=>{a??=h();let r=await a;if(!r.ok)return{ok:false,reason:r.reason};let n=t===null?null:await Rd(t,e.crypto),l=Ed(r.manifest,{tenantKey:n,sessionBucket:e.sessionBucket(),bundledVersion:e.bundledVersion});return l.use==="remote"?{ok:true,choice:l}:{ok:false,reason:l.reason}})();return s.set(r,l),l}async function m(t,r){if(await Promise.resolve(),ud())return{ok:false,reason:"disabled",version:null};let l=Jc();if(l===null)return{ok:false,reason:"react-unregistered",version:null};let a=await g(r);if(!a.ok)return{ok:false,reason:a.reason,version:null};let{version:s,entry:u}=a.choice;if(!u.react.includes(l.reactMajor))return{ok:false,reason:"react-mismatch",version:s};let c=u.parts[t];if(c===void 0)return{ok:false,reason:"part-missing",version:s};if(!rd(t,s,c.integrity))return{ok:false,reason:"part-integrity",version:s};let d=td(t,s);if(d!==null)return{ok:true,namespace:d,version:s};let f=`${o}/${s}/${c.path}`;if(ud())return{ok:false,reason:"disabled",version:s};let h=await Pd(e.fetch,f,n,i);if(!h.ok)return{ok:false,reason:h.why==="timeout"?"part-timeout":h.why==="too-large"?"part-too-large":"part-fetch",version:s};let m=h.bytes,b;try{b=`sha384-${Od(new Uint8Array(await e.crypto.subtle.digest("SHA-384",m)))}`}catch{return{ok:false,reason:"part-integrity",version:s}}if(b!==c.integrity)return{ok:false,reason:"part-integrity",version:s};if(ud())return{ok:false,reason:"disabled",version:s};let y=e.createBlobUrl?.(m)??null,v="error";if(y!==null&&(v=await e.runScript(y,c.integrity,"blob",p),e.revokeBlobUrl(y)),v==="error"&&(v=await e.runScript(f,c.integrity,"cdn",p)),v==="error")return{ok:false,reason:"part-load",version:s};let x=await nd(t,s,50);return x===null?{ok:false,reason:"part-load",version:s}:{ok:true,namespace:x,version:s}}let b=t?null:e.hasDom?"disabled":"server";try{let[t,r]=(e.unreachable?.()?.getItem(zd)??"").split("|");Number(t)>e.now()&&Id.test(String(r))&&(b??=r)}catch{}function y(e,t){if(b!==null)return Promise.resolve({ok:false,reason:b,version:null});f??=t;let r=`${t??""}|${e}`,n=u.get(r);if(n)return n;let l=m(e,t).then(e=>e,()=>({ok:false,reason:"part-load",version:null}));return l.then(e=>c.set(r,e)),u.set(r,l),l}return t&&ld(e=>{let t=Object.prototype.hasOwnProperty.call(Uc,e)?Uc[e]:void 0,r=()=>{let t=d.get(e);return t?t():Promise.reject(new TypeError(`${e} is not available to the Everfur web runtime`))};return t===void 0?r():y(t,f).then(e=>e.ok?e.namespace:r())}),{enabled:t,peek:(e,t)=>b!==null?{ok:false,reason:b,version:null}:c.get(`${t??""}|${e}`)??null,load:y,registerHostSubpaths:e=>{for(let[t,r]of Object.entries(e))d.has(t)||d.set(t,r)},setCspNonce:e=>{p=e===null||e===""?null:e}}}var Md="everfur:web-runtime:bucket",Ad=null;function $d(){try{let e=globalThis.sessionStorage?.getItem(Md);if(e)return e}catch{}Ad??=Math.floor(Math.random()*4294967296).toString(16);try{globalThis.sessionStorage?.setItem(Md,Ad)}catch{}return Ad}function Dd(e){return(t,r,n,l)=>new Promise(i=>{let o;try{o=e.createElement("script"),o.type="module",n==="cdn"&&(o.integrity=r,o.crossOrigin="anonymous"),l!==null&&(o.nonce=l),o.addEventListener("load",()=>{o.remove(),i("load")}),o.addEventListener("error",()=>{o.remove(),i("error")}),o.src=t,(e.head??e.documentElement).appendChild(o)}catch{i("error")}})}function Bd(){let e=typeof document>"u"?null:document,t=globalThis.crypto;return{origin:Bc,keys:Nc,bundledVersion:ke,fetch:typeof fetch=="function"?fetch.bind(globalThis):null,crypto:t?.subtle?t:null,hasDom:e!==null&&typeof window<"u",runScript:e===null?()=>Promise.resolve("error"):Dd(e),createBlobUrl:typeof Blob=="function"&&typeof URL.createObjectURL=="function"?e=>{try{return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}catch{return null}}:null,revokeBlobUrl:e=>{try{URL.revokeObjectURL(e)}catch{}},now:()=>Date.now(),sessionBucket:$d,unreachable:()=>globalThis.sessionStorage}}var Nd=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeLoader@${od}`);function Ld(){let e=globalThis;return e[Nd]??=Fd(Bd())}var Ud=/* @__PURE__ */new Set(["disabled","server","bundled-newer"]),Hd=/* @__PURE__ */new Set;function Wd(e,t,r,n){if(Ud.has(r))return;let l=`${t}|${r}`;if(!Hd.has(l)){Hd.add(l);try{e?.trackExpectedFailure(Gc,{part:t,reason:r,version:n,bundled:ke})}catch{}}}var qd=/* @__PURE__ */new Set,Vd=class extends e.Component{constructor(){super(...arguments);this.state={failed:false}}static getDerivedStateFromError(){return{failed:true}}componentDidCatch(){this.props.onError()}render(){return this.state.failed?this.props.fallback():this.props.children}},Kd=/* @__PURE__ */new Map;function Gd(t,r,n){let l=`${r??""}|${t.part}|${t.name}`,i=Kd.get(l);return i===void 0&&(i=e.lazy(async()=>{let e=await Ld().load(t.part,r),l=e.ok?e.namespace[t.name]:void 0;return e.ok&&typeof l!="function"&&(typeof l!="object"||l===null)?(Wd(n.current,t.part,"part-missing",e.version),{default:t.bundled}):(e.ok||Wd(n.current,t.part,e.reason,e.version),{default:e.ok?l:t.bundled})}),Kd.set(l,i)),i}var Yd=()=>()=>{},Zd=()=>false,Qd=()=>true;function RuntimeSurface({spec:t,props:r}){let n=e.useContext(Sc),l=ud(),a=n?.publishableKey?n.publishableKey:null,s=e.useRef(null);s.current=n?.runtime.registry?.services?.telemetry??null;let u=e.useSyncExternalStore(Yd,Zd,Qd),c=e.useRef(null),[,d]=e.useState(0),f=l?null:Ld();if(t.hostSubpaths!==void 0&&f?.enabled&&f.registerHostSubpaths(t.hostSubpaths),u)c.current=t.wait==="bundled"&&f!==null?"hydrate":"bundled";else if(c.current===null)if(!f?.enabled||qd.has(t.part))c.current="bundled";else if(Xc({React:i,ReactDOM:o})===null)Wd(s.current,t.part,"react-mismatch",null),c.current="bundled";else{let e=f.peek(t.part,a);c.current=e===null?"suspense":e.ok?"direct":"bundled"}let p=c.current,h=u||p!=="hydrate"?null:f?.peek(t.part,a)??null,g=!u&&p==="hydrate"&&h===null&&f?.enabled===true&&!qd.has(t.part);e.useEffect(()=>{if(!g||f===null)return;if(Xc({React:i,ReactDOM:o})===null){Wd(s.current,t.part,"react-mismatch",null);return}let e=true;return f.load(t.part,a).then(r=>{r.ok||Wd(s.current,t.part,r.reason,r.version),e&&d(e=>e+1)}),()=>{e=false}},[g,f,t.part,a]);let m=()=>e.createElement(t.bundled,r),b=r=>e.createElement(Vd,{fallback:m,onError:()=>{qd.add(t.part),Wd(s.current,t.part,"render",null)},children:r});if(u||p==="bundled")return m();if(p==="hydrate"||p==="direct"){let n=h??f?.peek(t.part,a),l=n?.ok?n.namespace[t.name]:void 0;return l===void 0||qd.has(t.part)?m():b(e.createElement(l,r))}let y=Gd(t,a,s),v=t.wait==="bundled"?m():e.createElement("div",{"data-everfur-runtime":"loading","aria-busy":true});return b(e.createElement(e.Suspense,{fallback:v},e.createElement(y,r)))}var Xd=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeRenderer@${od}`),Jd=globalThis;function ef(e,t=false){e===null?delete Jd[Xd]:(t||Jd[Xd]===void 0)&&(Jd[Xd]=e)}var tf=RuntimeSurface,rf=(t,r)=>e.createElement(tf,{spec:t,props:r});function nf(e){if(ef(rf),e!==void 0&&e!==""){let t=Ld();t.enabled&&t.setCspNonce(e)}}var lf=/* @__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[lf[t]]}}function of(e,t){let{scale:r,scaleCaps:n}=e.type,l=n[t];return l>0?Math.min(r,l):r}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[lf[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function af(){try{return process.env.NODE_ENV!=="production"}catch{return false}}var sf=/* @__PURE__ */new Map,uf=/* @__PURE__ */new Set,cf=typeof document>"u"?e.useEffect:e.useLayoutEffect;function df(e){return e.cssSrc!==void 0?`css\n${e.cssSrc}`:`file\n${e.family}\n${e.src??""}\n${e.weight??"400"}\n${e.style??"normal"}`}function ff(e,t){if(!t)return;let r=e.cssSrc??e.src??"",n=`[everfur] A font in appearance.fonts did not load: "${e.family}" from ${r}. The text renders in the fallback font. If your page sets a Content-Security-Policy, allow this host in font-src`+(e.cssSrc!==void 0?" and style-src (and the font files the stylesheet names in font-src).":".");if(!uf.has(n)){uf.add(n);try{globalThis.console?.warn?.(n)}catch{}}}function pf(e){let t=document.getElementsByTagName("link");for(let r=0;r<t.length;r+=1){let n=t[r];if(n.rel==="stylesheet"&&n.getAttribute("href")===e)return n}return null}function hf(e){return pf(e)!==null?Promise.resolve(true):new Promise(t=>{let r=document.createElement("link");r.rel="stylesheet",r.href=e,r.setAttribute("data-everfur-font",""),r.addEventListener("load",()=>t(true)),r.addEventListener("error",()=>t(false)),document.head.appendChild(r)})}function gf(e){let t=document.fonts;return new FontFace(e.family,`url("${e.src}")`,{display:"swap",weight:e.weight??"400",style:e.style??"normal"}).load().then(e=>(t.add(e),true)).catch(()=>false)}function mf(e,t=false){let r=df(e),n=sf.get(r);if(n===void 0){n=Promise.resolve(false);try{if(typeof document<"u"){let t=e.cssSrc===void 0?null:Qa(e.cssSrc),r=e.src===void 0?null:Qa(e.src);t!==null?n=hf(t):r!==null&&(n=gf({...e,src:r}))}}catch{n=Promise.resolve(false)}let l=n.then(r=>(r||ff(e,t),r));sf.set(r,l),n=l}return n}function bf(e,t){let r=e.type.fontSources;cf(()=>{if(r.length===0)return;let e=false;try{e=t()}catch{}for(let t of r)mf(t,e)},[r,t])}var yf=/* @__PURE__ */new RegExp(`^${Oa}\\/fonts\\/[\\w./-]+\\.woff2$`);function vf(e){return yf.test(e)&&!e.includes("..")}var xf=/* @__PURE__ */new Map;function kf(e,t,r="400"){let n=e.trim(),l=`${n}\n${t}\n${r}`,i=xf.get(l);if(i===void 0){if(i=Promise.resolve(false),t!==null&&n!==""&&n!=="System"&&vf(t))try{let e=document.fonts;i=new FontFace(n,`url("${t}") format("woff2")`,{display:"swap",weight:r}).load().then(t=>(e.add(t),!0)).catch(()=>!1)}catch{}xf.set(l,i)}return i}var wf=["regular","medium","bold","mono","monoMedium","monoBold"];function Cf(t){let{families:r,fontUrls:n,weight:l,namedFaces:i}=t.type;e.useEffect(()=>{for(let e of wf){let t=n[e];t!=null&&kf(r[e],t,i[e]?l.regular:l[lf[e]])}},[r,n,l,i]),bf(t,af)}function Sf(e){if(typeof window>"u"||typeof window.matchMedia!="function")return null;try{return window.matchMedia(e)??null}catch{return null}}function jf(e){return t=>{let r=Sf(e);return r===null||typeof r.addEventListener!="function"?()=>{}:(r.addEventListener("change",t),()=>r.removeEventListener?.("change",t))}}var _f="(prefers-color-scheme: dark)",Rf="(prefers-color-scheme: light)",Ef="(prefers-reduced-motion: reduce)",If="(prefers-contrast: more)",zf=jf(_f),Tf=jf(Ef),Of=jf(If);function Pf(){let e=Sf(_f);return e===null?null:e.matches?"dark":Sf(Rf)?.matches?"light":null}function Ff(){return Sf(Ef)?.matches===true}function Mf(){return Sf(If)?.matches===true}var Af=16,$f=false;var Df=null;function Bf(e){return Number.parseFloat(window.getComputedStyle(e).fontSize)}function Nf(){let e=document.body??document.documentElement,t=document.createElement("span");t.setAttribute("aria-hidden","true"),t.style.setProperty("position","absolute","important"),t.style.setProperty("visibility","hidden","important"),t.style.setProperty("font-size","medium","important"),e.appendChild(t);try{return Bf(t)}finally{t.remove()}}function Lf(){if(typeof document>"u"||typeof window>"u"||typeof window.getComputedStyle!="function")return 1;try{let e=$f?Bf(document.documentElement):Nf();return Number.isFinite(e)&&e>0?e/Af:1}catch{return 1}}function Uf(){return Df===null&&(Df=Lf()),Df}function Hf(e){if(typeof window>"u"||typeof window.addEventListener!="function")return()=>{};let t=()=>{Df=null,e()};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}function Wf(){return e.useSyncExternalStore(zf,Pf,()=>null)}function qf(){return e.useSyncExternalStore(Tf,Ff,()=>false)}function Vf(){return e.useSyncExternalStore(Of,Mf,()=>false)}function Kf(){return e.useSyncExternalStore(Hf,Uf,()=>1)}var Gf=/* @__PURE__ */Object.freeze({useColorScheme:Wf,useReducedMotion:qf,useTextScale:Kf,useHighContrast:Vf,scaleTypeSizes:true,useResolvedTheme:Cf,isDevelopment:af});function Yf(e){return e.storage===void 0?{...e,storage:createLocalStorageKv()}:e}var Zf=/* @__PURE__ */Object.freeze({platform:"web",withDefaults:Yf,theme:Gf});function EverfurProvider(t){let{cspNonce:r,webRuntime:n,...l}=t;return n!==void 0&&n!=="updates"&&cd(),ud()||nf(r),e.createElement(EverfurProviderCore,{...l,seams:Zf})}function useCapability(t){let{runtime:r}=jc(),n=r.entitlements,l=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return e.useMemo(()=>decideCapability(t,l.decisions,{isPending:l.isPending}),[t,l])}function Qf(t){let{runtime:r}=jc(),n=r.entitlements,l=e.useCallback(e=>n===void 0?()=>{}:n.subscribe(e),[n]),i=e.useCallback(()=>{if(n===void 0)return false;let e=n.getSnapshot();return decideCapability(t,e.decisions,{isPending:e.isPending}).enabled},[n,t]);return e.useSyncExternalStore(l,i,i)}var Xf=class extends e.Component{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:t,fallback:r,resetKey:n}){return e.createElement(Xf,{fallback:r,resetKey:n,children:e.createElement(RenderHost,{render:t})})}function Jf(e,t,r){return Math.round(r*of(e,t)*10)/10}var ep='system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',tp="System";function rp(e){let t=e.trim();return t.length===0||t===tp?ep:`${lp(t)}, ${ep}`}function np(e){let t=e.trim();return t.length===0||t==="monospace"?"ui-monospace, Menlo, Consolas, monospace":`${lp(t)}, ui-monospace, Menlo, Consolas, monospace`}function lp(e){return`"${e.replace(/[\\"]/g,"\\$&")}"`}function faceCss(e,t){let r=e.type,n=r.families[t];return{fontFamily:t==="mono"||t==="monoMedium"||t==="monoBold"?np(n):rp(n),fontWeight:r.namedFaces[t]?r.weight.regular:r.weight[lf[t]]}}function headingFaceCss(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type,l=faceCss(e,t);return r===null&&n===null?l:r!==null?{fontFamily:rp(r),fontWeight:n??e.type.weight[lf[t]]}:e.type.namedFaces[t]||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}var ip=/* @__PURE__ */Object.freeze({textAlign:"start"});var op=48;function ap(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(t){let{capability:r,children:l,renderDisabled:i,renderPending:o,style:a,className:s}=t,u=useCapability(r),c=e.useMemo(()=>ap(u),[u]);switch(c){case"enabled":return l;case"pending":return o?/* @__PURE__ */n.jsx(HostRender,{render:o,fallback:/* @__PURE__ */n.jsx(PendingSkeleton,{capability:r,style:a,className:s})}):/* @__PURE__ */n.jsx(PendingSkeleton,{capability:r,style:a,className:s});case"disabled":return i?/* @__PURE__ */n.jsx(HostRender,{render:()=>i(u),fallback:/* @__PURE__ */n.jsx(OffState,{decision:u,style:a,className:s}),resetKey:u}):/* @__PURE__ */n.jsx(OffState,{decision:u,style:a,className:s});default:return assertNever(c)}}function PendingSkeleton({capability:t,style:r,className:l}){let i=useEverfurTheme(),o=e.useMemo(()=>sp(i),[i]);/* @__PURE__ */
51
51
  return n.jsx("div",{role:"status","aria-busy":"true","aria-label":`Loading ${t}`,className:l,style:{...o.offstate,...r},children:/* @__PURE__ */n.jsx("div",{style:o.skeletonBar})})}function OffState({decision:t,style:r,className:l}){let i=useEverfurTheme(),o=e.useMemo(()=>sp(i),[i]),a=t.disabled?.reason??"";/* @__PURE__ */
52
52
  return n.jsx("div",{className:l,style:{...o.offstate,...r},children:a.length>0?/* @__PURE__ */n.jsx("p",{style:o.offstateText,children:a}):null})}function sp(e){let{color:t,space:r,radius:n,type:l}=e;return{offstate:{...ip,boxSizing:"border-box",minHeight:op,display:"flex",flexDirection:"column",justifyContent:"center",padding:`${r.md}px ${r.lg}px`,backgroundColor:t.surfaceCream,borderRadius:n.md,border:`1px solid ${t.brandBorder}`},offstateText:{margin:0,...faceCss(e,"regular"),fontSize:l.size.body,lineHeight:`${Math.round(l.size.body*l.lineHeight.normal)}px`,color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}}}var up="Go to the nearest emergency vet now.";var cp=/* @__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:up,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 dp(e,t){return e.replace(/\{(\w+)\}/g,(e,r)=>{let n=t[r];return n===void 0?e:String(n)})}function fp(e){return e?.trim()||cp.emptyTitlePetFallback}function pp(e,t){return dp(e,{petName:fp(t)})}var hp="tel:+18884264435";var gp=/* @__PURE__ */Object.freeze([
53
53
  /* @__PURE__ */Object.freeze({key:"inaccurate",label:cp.feedbackReasonInaccurate,feedbackType:"wrong"}),
package/dist/web/index.js CHANGED
@@ -11,7 +11,7 @@ return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryab
11
11
  return Object.freeze({kind:"analysisStarted",requestId:e,lastEventId:t,serverRequestId:r,terminal:false})}function analysisCompleteFrame(e,t=null){/* @__PURE__ */
12
12
  return Object.freeze({kind:"analysisComplete",terminal:false,resultId:e.resultId,analysisType:e.analysisType,modelVersion:e.modelVersion,confidence:e.confidence,detections:/* @__PURE__ */Object.freeze([...e.detections]),interpretation:e.interpretation,lastEventId:e.lastEventId,serverRequestId:t})}function unknownFrame(e,t,r=null){/* @__PURE__ */
13
13
  return Object.freeze({kind:"unknown",raw:{...e},lastEventId:t,serverRequestId:r,terminal:false})}var B="/widget/v1/anon-identity",N="x-everfur-anon-token",U="anonTokenInvalid";function L(e,t){if(typeof e!="string"||t===null)return null;let r=Date.parse(e)-Date.parse(t);return Number.isFinite(r)&&r>0?r:null}function createAnonIdentityProvider(e,t,r,n=Date.now){let l=null,i=null,o=null,a=null,s=e=>Math.max(0,n()-e),u=(e,t)=>e!==null&&n()>=e&&n()-e<t,d=()=>l!==null&&(l.ttlMs===null||s(l.mintedAtMs)<l.ttlMs-2592e5),c=()=>l!==null&&(l.ttlMs===null||s(l.mintedAtMs)<l.ttlMs)?l.token:null,f=()=>i||(i=(async()=>{try{let i=null,a={method:"POST",path:B,headers:{"x-everfur-partner-key":t,"x-everfur-session-id":r},onResponseHeaders:e=>{i=e("date")}},s=await e.request(a),u=s.ok?s.value:null,d=typeof u?.anon_token=="string"&&u.anon_token.length>0?u.anon_token:null;return d===null?(o=n(),c()):(l={token:d,mintedAtMs:n(),ttlMs:L(u?.expires_at,i)},o=null,d)}catch{return o=n(),c()}finally{i=null}})(),i);return{token(e){return e?.forceRefresh?i||(u(a,3e4)?Promise.resolve(l?.token??null):(a=n(),l=null,f())):d()||u(o,3e5)?Promise.resolve(c()):f()}}}async function H(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}var W="This feature isn't available on your account right now.",q="Something in that request was not right. Check the details and try again.",V=/* @__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:W,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:q,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:W,runtimeDisposed:q,unknown:"Something went wrong. Please try again."}),K="This session has ended. Please sign in again.",G="linked_account_read_only";function Y(e,t,r){return e==="conflict"&&r===G?W:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?K:userFacingError(e)}function userFacingError(e){return V[e]}function Z(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var Q=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===G,l={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:Y(e,t?.wireCode,n?G:null)};t?.httpStatus!==void 0&&(l.httpStatus=t.httpStatus),t?.requestId&&(l.requestId=t.requestId),typeof t?.reasonCode=="string"&&Q.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&&Z(l,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Z(l,"raw",t.raw),/* @__PURE__ */Object.freeze(l)}function X(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 createIdentityProvider(e,t,r,n){let l=null,i=false,o=null,a=false,s=()=>o||(o=(async()=>{try{let e=await t(),n=typeof e=="string"?e:e?.token;if(typeof n!="string"||n.length===0)throw new C("invalid-argument","TokenProvider returned an empty token");return l=n,i=!1,r?.(typeof e=="string"?null:J(e.expiresAt)),n}finally{o=null}})(),o);return{userRef:e,async currentToken(e){if(a)throw new C("not-initialized","This identity was cleared (sign-out); mint a new one.");return e?.forceRefresh&&(l=null),l!==null?l:s()},hasToken(){return!a&&l!==null},clear(){a=true,l=null},reportRejected(){a||i||(i=true,n?.())}}}function J(e){if(e===void 0)return null;let t=typeof e=="number"?e<1e11?e*1e3:e:new Date(e).getTime();return Number.isFinite(t)?t:null}function newSessionId(){let e=new Uint8Array(16),t=globalThis.crypto;if(typeof t?.getRandomValues=="function")t.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let r=[];for(let t=0;t<e.length;t+=1)r.push(e[t].toString(16).padStart(2,"0"));return r.slice(0,4).join("")+"-"+r.slice(4,6).join("")+"-"+r.slice(6,8).join("")+"-"+r.slice(8,10).join("")+"-"+r.slice(10,16).join("")}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[N]=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:{...ee(e.headers),...authHeaders(t)}}}function ee(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===N||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await H(t),n=await t.transport.request(withAuthHeaders(e,te(t,r)));if(n.ok||ne(n.error.raw)!==U||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,te(t,l)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(X(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(X(e,{wireCode:ne(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(re(i.error))):i}function te(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function re(e){let t=e.raw,r=ne(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 ne(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 le="DAILY_QUOTA_EXCEEDED",ie=/* @__PURE__ */new Set(["THROTTLINGEXCEPTION","RATELIMITED","TOOMANYREQUESTS"]);function oe(e,t){if(!ie.has(e.toUpperCase().replace(/[^A-Z0-9]/g,"")))return e;let r=t,n=r?.daily_limit??r?.error?.daily_limit;return typeof n=="number"&&Number.isFinite(n)?le:e}var ae="free_cap_reached";function se(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ue(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!==ae&&n.code!==ae)return null;let l=se(n.limit),i=se(n.used);if(l===null||i===null)return null;let o=n.resets_at,a=n.emergency_guidance;/* @__PURE__ */
14
- 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 de(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:ue(t)}function ce(){let e=[];return{decode(t,r){let n=r?.stream===true,l=e.length>0?e.slice():[];if(t!==void 0)for(let e=0;e<t.length;e+=1)l.push(t[e]);e=[];let i="",o=0;for(;o<l.length;){let t=l[o];if(t<128){i+=String.fromCharCode(t),o+=1;continue}let r,a=128,s=191,u;if(t>=194&&t<=223)r=1,u=t&31;else if(t>=224&&t<=239)r=2,u=t&15,t===224&&(a=160),t===237&&(s=159);else if(t>=240&&t<=244)r=3,u=t&7,t===240&&(a=144),t===244&&(s=143);else{i+="�",o+=1;continue}let d=1,c=true;for(;d<=r&&!(o+d>=l.length);){let e=l[o+d],t=d===1?a:128,r=d===1?s:191;if(e<t||e>r){c=false;break}u=u<<6|e&63,d+=1}if(!c){i+="�",o+=d;continue}if(d<=r){n?e=l.slice(o):i+="�";break}i+=String.fromCodePoint(u),o+=r+1}return i}}}function fe(){let e=globalThis.TextDecoder;return typeof e=="function"?new e("utf-8"):ce()}var pe=`\n\n`,he=1048576,ge=/* @__PURE__ */m.record(/* @__PURE__ */m.string(),/* @__PURE__ */m.unknown()),me=["emergency","schedule_soon","home_care"];async function*parseSse(e,t=null){let r=null,n=()=>(r!==null||(r=typeof t=="function"?t():t),r),l=fe(),i="",o=0,a=false;for await(let t of e){for(i+=l.decode(t,{stream:true});;){let e=i.indexOf(pe,o);if(e===-1)break;let t=i.slice(0,e);i=i.slice(e+pe.length),o=0;let r=be(t,n());if(r!==null&&(r.kind==="delta"&&(a=true),yield r,r.terminal))return}if(o=i.length>0?i.length-1:0,i.length>he){yield errorFrame({code:a?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});return}}if(i+=l.decode(),i.trim().length>0){let e=be(i,n());if(e!==null&&(e.kind==="delta"&&(a=true),yield e,e.terminal))return}yield errorFrame({code:a?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()})}function be(e,t){let r=null,n=[];for(let t of e.split(`\n`)){let e=t.replace(/\s+$/,"");e.length===0||e.startsWith(":")||(e.startsWith("id:")?r=e.slice(3).trim():e.startsWith("data:")&&n.push(e.slice(5).replace(/^ /,"")))}if(n.length===0)return null;let l;try{l=JSON.parse(n.join(`\n`))}catch{return null}if(typeof l!="object"||l===null||Array.isArray(l))return null;let i=ge.safeParse(l);return i.success?ye(i.data,r,t):null}function ye(e,t,r){let n=e.type,l=e.event;if(n==="error"||"error"in e)return errorFrame({code:ve(e.code)??"unknown",retryable:e.retryable===true,wireMessage:ve(e.error),synthesized:false,lastEventId:t,serverRequestId:r,freeCap:ue(e)});if(n==="done"||e.done===true)return doneFrame({conversationId:ve(e.conversation_id)??"",messageId:ve(e.message_id),title:ve(e.title),followUpQuestions:Ce(e.follow_up_questions),citations:_e(e.citations),recordCitations:_e(e.record_citations),citationStatus:ve(e.citation_status),urgencyLevel:ke(e.urgency_level),urgencyReason:ve(e.urgency_reason),urgencyProvided:xe(e),resultId:ve(e.result_id),lastEventId:t},r);if(n==="accepted"||e.status==="reasoning")return acceptedFrame(ve(e.stream_id),t,r);if(n==="heartbeat"||e.heartbeat===true)return heartbeatFrame(t,r);if(n==="text.delta"||"delta"in e||"token"in e){let n=ve(e.delta)??ve(e.token)??"";return deltaFrame(n,t,r)}return l==="analysis_started"?analysisStartedFrame(ve(e.request_id),t,r):l==="analysis_complete"?analysisCompleteFrame({resultId:ve(e.result_id),analysisType:ve(e.analysis_type),modelVersion:ve(e.model_version),confidence:we(e.confidence),detections:_e(e.detections),interpretation:ve(e.interpretation),lastEventId:t},r):unknownFrame(e,t,r)}function ve(e){return typeof e=="string"?e:null}function we(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function ke(e){return typeof e=="string"&&me.includes(e)?e:null}function xe(e){if(!Object.prototype.hasOwnProperty.call(e,"urgency_level"))return false;let t=e.urgency_level;return t===null||ke(t)!==null}function Ce(e){return Array.isArray(e)?e.map(e=>typeof e=="string"?e:String(e)):[]}function Se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _e(e){return Array.isArray(e)?e.filter(Se):[]}var Re=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function Ie(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 Pe(e)}var ze=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,Te=/[\s\u0000-\u001f\u007f\\]/,Oe={"http:":"80","https:":"443"};function Pe(e,t){let r=e.trim();let n=Te.test(r)?null:ze.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",d="",c=""]=n,f=`${l.toLowerCase()}:`,p=Number(s);if(p>65535)return null;let h=s===""||String(p)===Oe[f]?"":String(p),g=Oe[f]!==void 0,m=a.toLowerCase()+(h&&`:${h}`),b=u||(g?"/":""),y=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${f}//${y}${m}${b}${d}${c}`,protocol:f,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:g?`${f}//${m}`:"null",pathname:b,search:d==="?"?"":d,hash:c==="#"?"":c}}function Ee(e,t,r){return{...e,surface:t,requestId:r||null}}var Fe=64,je=/^[A-Za-z0-9._+() -]+$/;function Ae(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0||t.length>Fe?null:je.test(t)?t:null}var Me="1.7.0";var $e="react-native",De="2026-09-19",Be="EVERFUR_API_BASE_URL";function Ne(e,t){/* @__PURE__ */
14
+ 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 de(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:ue(t)}function ce(){let e=[];return{decode(t,r){let n=r?.stream===true,l=e.length>0?e.slice():[];if(t!==void 0)for(let e=0;e<t.length;e+=1)l.push(t[e]);e=[];let i="",o=0;for(;o<l.length;){let t=l[o];if(t<128){i+=String.fromCharCode(t),o+=1;continue}let r,a=128,s=191,u;if(t>=194&&t<=223)r=1,u=t&31;else if(t>=224&&t<=239)r=2,u=t&15,t===224&&(a=160),t===237&&(s=159);else if(t>=240&&t<=244)r=3,u=t&7,t===240&&(a=144),t===244&&(s=143);else{i+="�",o+=1;continue}let d=1,c=true;for(;d<=r&&!(o+d>=l.length);){let e=l[o+d],t=d===1?a:128,r=d===1?s:191;if(e<t||e>r){c=false;break}u=u<<6|e&63,d+=1}if(!c){i+="�",o+=d;continue}if(d<=r){n?e=l.slice(o):i+="�";break}i+=String.fromCodePoint(u),o+=r+1}return i}}}function fe(){let e=globalThis.TextDecoder;return typeof e=="function"?new e("utf-8"):ce()}var pe=`\n\n`,he=1048576,ge=/* @__PURE__ */m.record(/* @__PURE__ */m.string(),/* @__PURE__ */m.unknown()),me=["emergency","schedule_soon","home_care"];async function*parseSse(e,t=null){let r=null,n=()=>(r!==null||(r=typeof t=="function"?t():t),r),l=fe(),i="",o=0,a=false;for await(let t of e){for(i+=l.decode(t,{stream:true});;){let e=i.indexOf(pe,o);if(e===-1)break;let t=i.slice(0,e);i=i.slice(e+pe.length),o=0;let r=be(t,n());if(r!==null&&(r.kind==="delta"&&(a=true),yield r,r.terminal))return}if(o=i.length>0?i.length-1:0,i.length>he){yield errorFrame({code:a?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});return}}if(i+=l.decode(),i.trim().length>0){let e=be(i,n());if(e!==null&&(e.kind==="delta"&&(a=true),yield e,e.terminal))return}yield errorFrame({code:a?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()})}function be(e,t){let r=null,n=[];for(let t of e.split(`\n`)){let e=t.replace(/\s+$/,"");e.length===0||e.startsWith(":")||(e.startsWith("id:")?r=e.slice(3).trim():e.startsWith("data:")&&n.push(e.slice(5).replace(/^ /,"")))}if(n.length===0)return null;let l;try{l=JSON.parse(n.join(`\n`))}catch{return null}if(typeof l!="object"||l===null||Array.isArray(l))return null;let i=ge.safeParse(l);return i.success?ye(i.data,r,t):null}function ye(e,t,r){let n=e.type,l=e.event;if(n==="error"||"error"in e)return errorFrame({code:ve(e.code)??"unknown",retryable:e.retryable===true,wireMessage:ve(e.error),synthesized:false,lastEventId:t,serverRequestId:r,freeCap:ue(e)});if(n==="done"||e.done===true)return doneFrame({conversationId:ve(e.conversation_id)??"",messageId:ve(e.message_id),title:ve(e.title),followUpQuestions:Ce(e.follow_up_questions),citations:_e(e.citations),recordCitations:_e(e.record_citations),citationStatus:ve(e.citation_status),urgencyLevel:ke(e.urgency_level),urgencyReason:ve(e.urgency_reason),urgencyProvided:xe(e),resultId:ve(e.result_id),lastEventId:t},r);if(n==="accepted"||e.status==="reasoning")return acceptedFrame(ve(e.stream_id),t,r);if(n==="heartbeat"||e.heartbeat===true)return heartbeatFrame(t,r);if(n==="text.delta"||"delta"in e||"token"in e){let n=ve(e.delta)??ve(e.token)??"";return deltaFrame(n,t,r)}return l==="analysis_started"?analysisStartedFrame(ve(e.request_id),t,r):l==="analysis_complete"?analysisCompleteFrame({resultId:ve(e.result_id),analysisType:ve(e.analysis_type),modelVersion:ve(e.model_version),confidence:we(e.confidence),detections:_e(e.detections),interpretation:ve(e.interpretation),lastEventId:t},r):unknownFrame(e,t,r)}function ve(e){return typeof e=="string"?e:null}function we(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function ke(e){return typeof e=="string"&&me.includes(e)?e:null}function xe(e){if(!Object.prototype.hasOwnProperty.call(e,"urgency_level"))return false;let t=e.urgency_level;return t===null||ke(t)!==null}function Ce(e){return Array.isArray(e)?e.map(e=>typeof e=="string"?e:String(e)):[]}function Se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _e(e){return Array.isArray(e)?e.filter(Se):[]}var Re=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function Ie(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 Pe(e)}var ze=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,Te=/[\s\u0000-\u001f\u007f\\]/,Oe={"http:":"80","https:":"443"};function Pe(e,t){let r=e.trim();let n=Te.test(r)?null:ze.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",d="",c=""]=n,f=`${l.toLowerCase()}:`,p=Number(s);if(p>65535)return null;let h=s===""||String(p)===Oe[f]?"":String(p),g=Oe[f]!==void 0,m=a.toLowerCase()+(h&&`:${h}`),b=u||(g?"/":""),y=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${f}//${y}${m}${b}${d}${c}`,protocol:f,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:g?`${f}//${m}`:"null",pathname:b,search:d==="?"?"":d,hash:c==="#"?"":c}}function Ee(e,t,r){return{...e,surface:t,requestId:r||null}}var Fe=64,je=/^[A-Za-z0-9._+() -]+$/;function Ae(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0||t.length>Fe?null:je.test(t)?t:null}var Me="1.7.1";var $e="react-native",De="2026-09-19",Be="EVERFUR_API_BASE_URL";function Ne(e,t){/* @__PURE__ */
15
15
  return Object.freeze({ok:false,failure:/* @__PURE__ */Object.freeze({reason:e,message:t})})}function checkPublishableKey(e){let t=typeof e=="string"?e.trim():"";return t.length===0?{reason:"missing-publishable-key",message:"publishableKey is required"}:/^sk[_-]/i.test(t)?{reason:"secret-key-as-publishable-key",message:"publishableKey looks like a SECRET key (sk_...). A device must never hold a partner secret key: use the pk_ publishable key here, and keep the secret key on your server."}:null}function tryResolveClientConfig(e,t){let r=checkPublishableKey(e?.publishableKey);if(r!==null)/* @__PURE__ */
16
16
  return Object.freeze({ok:false,failure:r});let n=e.publishableKey.trim(),l=tryResolveApiBaseUrl(e.apiBaseUrl);if(!l.ok)return l;let i=e.contractVersion?.trim()||De,o=Ae(e.appVersion);/* @__PURE__ */
17
17
  return Object.freeze({ok:true,config:/* @__PURE__ */Object.freeze({publishableKey:n,apiBaseUrl:l.value,contractVersion:i,sdkVersion:Me,platform:t?.platform??$e,debug:e.debug===true,...o!==null?{appVersion:o}:{}})})}function tryResolveApiBaseUrl(e){let t=e?.trim(),r=t&&t.length>0?t:Ke(Be);return r?qe(r):Ne("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${Be}. The SDK never ships a hardcoded host.`)}function buildBaseHeaders(e){let t={"X-Everfur-SDK-Version":e.sdkVersion,"X-Everfur-SDK-Platform":e.platform,"X-Everfur-Contract":e.contractVersion};return e.appVersion!=null&&e.platform==="react-native"&&(t["X-Everfur-App-Version"]=e.appVersion),t}function Ue(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}function Le(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}function He(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:Le(t)}function We(e,t){return`${e}://${t}`}function qe(e){let t=e.trim(),r=Re.exec(t);if(r===null||r[2]===void 0||r[2].length===0)return Ne("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let n=(r[1]??"").toLowerCase(),l=Ue(r[2]);if(l.length===0)return Ne("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let i=He(t,l)?`: ${We(n,l)}`:"";if(n!=="https"){if(!(n==="http"&&Ve(l)))return n==="http"?Ne("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${i}`):Ne("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${i}`)}let o=t.endsWith("/")?t.slice(0,-1):t;/* @__PURE__ */
@@ -47,7 +47,7 @@ return Object.freeze([/* @__PURE__ */Object.freeze({resource:"chat.message.creat
47
47
  return Object.freeze({track(t,r){try{e.track(t,r)}catch{}},trackExpectedFailure(r,n){try{e.trackExpectedFailure(r,t===void 0?n:wd(r,n,t))}catch{}}})}function wd(e,t,r){let n=e.indexOf("."),l=typeof t?.surface=="string"?t.surface:n>0?e.slice(0,n):"sdk",i=typeof t?.requestId=="string"?t.requestId:null;return{...Ee(r,l,i),...t}}function kd(e,t,r){if(e===void 0)return;let n=e.onExpectedFailure;return{shouldRetry:(t,r)=>e.shouldRetry(t,r),maxAttempts:t=>e.maxAttempts(t),...typeof n=="function"?{onExpectedFailure:(l,i)=>n.call(e,l,i??Ee(t,r,l.requestId))}:{}}}var xd=/* @__PURE__ */Object.freeze({"react-native":"If the value is set in your environment, note that babel-preset-expo inlines only EXPO_PUBLIC_* variables into a release bundle.",web:`If the value is set in your environment, note that a browser bundle does not expose ${Be} to the SDK at run time (bundlers inline only the variables your own code names), so pass apiBaseUrl in config.`});function Cd(e,t,r=$e){try{t.trackExpectedFailure("sdk.config.invalid",{reason:e.reason})}catch{}globalThis.console?.error?.(`[everfur] SDK disabled: ${e.message}\n[everfur] Every Everfur capability will render its off-state until this is fixed. `+xd[r])}function Sd(e){/* @__PURE__ */
48
48
  return Object.freeze({request(){return Promise.resolve(err(bd(e)))},stream(t,r){let n=errorFrame({code:"sdk_not_configured",retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`,synthesized:true,lastEventId:null});return async function*(){r.aborted||(yield n)}()}})}var _d=/* @__PURE__ */new WeakSet;function Rd(){let e=/* @__PURE__ */new Map,t={async getItem(t){return e.get(t)??null},async setItem(t,r){e.set(t,r)},async removeItem(t){e.delete(t)},async keys(t){return[...e.keys()].filter(e=>e.startsWith(t))}};return _d.add(t),t}var Id=/* @__PURE__ */Object.freeze({clearMemoryCache(){},clearDiskCache(){}});function createEverfurRuntime(e,t){return new Td(e,t)}var zd=6e4,Td=class{constructor(e,t){this.sessionId=newSessionId();this.anonIdentity=null;this.entries=/* @__PURE__ */new Map;this.destroyers=/* @__PURE__ */new Map;this.epoch=0;this.disposed=false;this.verdictSettled=false;this.brandingCache=null;this.verdictLanded=false;this.refreshTimer=null;this.bootstraps=/* @__PURE__ */new WeakMap;this.prepared=null;this.beforeLogoutHooks=/* @__PURE__ */new Set;this.pendingBeforeLogout=null;this.leavingSessionId=null;let r=e.config;if(r.secureStore!==void 0&&r.secureStore.isAvailable===true)throw new C("invalid-argument","config.secureStore is not yet consumable: SDK token persistence is unimplemented. Omit secureStore to keep memory-only tokens (SPEC-10 §5.3).");this.errorContext=/* @__PURE__ */Object.freeze({sdkVersion:Me,platform:t?.platform??$e,partnerKey:checkPublishableKey(r?.publishableKey)===null?r.publishableKey.trim():null,appVersion:Ae(r?.appVersion)}),this.telemetry=r.telemetry?vd(r.telemetry,this.errorContext):S,this.onEvent=typeof r.onEvent=="function"?r.onEvent:void 0;let n=typeof r?.publishableKey=="string"?r.publishableKey.trim():"",l=checkPublishableKey(r?.publishableKey),i=r.transport!==void 0,o,a=typeof r.apiBaseUrl=="string"&&r.apiBaseUrl.trim().length>0?r.apiBaseUrl.trim():null;if(l!==null)o=Sd(l);else if(r.transport!==void 0)o=r.transport;else{let e=yd(r,t?.platform);e.ok?(a=e.config.apiBaseUrl,o=createHttpTransport({config:e.config,...t?.eventSourceFactory?{eventSourceFactory:t.eventSourceFactory}:{}})):(l=e.failure,o=Sd(e.failure))}if(this.configFailure=l,this.reportsDeviceTimezone=l===null&&(t?.reportDeviceTimezone??!i),this.publishableKey=l===null?n:"",this.mintScope=`${this.publishableKey}|${a??""}`,Xl(this,this.mintScope),this.transport=o,l!==null&&(Cd(l,this.telemetry,t?.platform),this.emit({type:"error",code:bd(l).code,requestId:null,context:Ee(this.errorContext,"runtime",null)})),this.errorPolicy=kd(r.errorPolicy,this.errorContext,"runtime"),this.camera=r.camera??D,this.upload=r.upload??rr,this.uploadTransport=r.uploadTransport??Sn,this.imageCache=r.imageCache??Id,this.kv=r.storage??Rd(),this.currentUser=e.user??null,this.identity=this.buildIdentity(e.user??null),this.activePet=e.activePet,this.store=l===null?od():od(()=>deniedDecisionsFor("sdk_config",userFacingError("accessDenied"))),this.services={authFor:e=>this.buildAuth(e),telemetry:this.telemetry,errorPolicy:this.errorPolicy,camera:this.camera,upload:this.upload,uploadTransport:this.uploadTransport,imageCache:this.imageCache,kv:this.kv,apiBaseUrl:a},this.registry={services:this.services,acquireChat:e=>this.acquireInternal("chat",Od(e),()=>this.buildChatController(e),Pd),releaseChat:e=>this.releaseInternal(e),peekChat:e=>this.entries.get(`${this.epoch}|chat|${Od(e)}`)?.controller??null,acquire:(e,t,r,n)=>this.acquireInternal(e,t,r,n),release:e=>this.releaseInternal(e)},this.entitlements=this.store,this.unread=Yu({read:e=>this.disposed||this.currentUser===null||this.configFailure!==null?null:Zu(this.buildAuth(this.currentUser.userRef),e,this.errorPolicy),emit:e=>this.emit(e)}),l===null){this.brandingCache=hd(this.kv,this.mintScope);let e=this.epoch;this.brandingCache.restore(t=>{let r=this.store.getSnapshot();this.disposed||this.verdictLanded||this.epoch!==e||r.branding||this.store.set({...r,branding:t})})}this.sdkConfigHost=l===null?md({kv:this.kv,scope:this.mintScope,funnel:()=>createRequestFunnel({auth:this.buildAuth(this.currentUser?.userRef??null)})}):void 0;let s=l===null&&(t?.startEntitlementPolling??!i);this.poller=l===null?this.buildPoller(t?.pollScheduler):null,s&&this.poller?.start()}get isDisposed(){return this.disposed}get scopeEpoch(){return this.epoch}buildIdentity(e){if(e===null)return null;let t=oi(`${this.mintScope}|${e.userRef}`,e.getToken),r=createIdentityProvider(e.userRef,t,t=>{this.armTokenRefresh(r,t),this.reportsDeviceTimezone&&!this.disposed&&r===this.identity&&ci(`${this.mintScope}|${e.userRef}`,this.buildAuth(e.userRef))},()=>{r===this.identity&&this.emit({type:"session_expired",userRef:e.userRef})});return r}armTokenRefresh(e,t){if(this.clearTokenRefresh(),t===null||this.disposed||e!==this.identity)return;let r=t-Date.now();if(r<=0)return;let n=Math.max(r-zd,r/2);this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,!(this.disposed||e!==this.identity)&&e.currentToken({forceRefresh:true}).catch(()=>{})},n),this.refreshTimer.unref?.()}emit(e){let t=this.onEvent;if(t===void 0)return;let r=()=>{this.disposed||Gl(t,e)};typeof queueMicrotask=="function"?queueMicrotask(r):Promise.resolve().then(r)}clearTokenRefresh(){this.refreshTimer!==null&&clearTimeout(this.refreshTimer),this.refreshTimer=null}buildPoller(e){return createEntitlementPoller({authFor:()=>this.buildAuth(this.currentUser?.userRef??null),update:(e,t,r,n)=>{this.verdictLanded=true;let l=this.store.getSnapshot().branding??null,i=l!==null&&t!=null&&cd(l)===cd(t)?l:t;this.updateEntitlements({decisions:e,isPending:false,branding:i,...r===false?{livemode:r}:{},...n!==void 0?{smsProfilePublic:n}:{}}),this.brandingCache?.persist(i??null)},onFetch:()=>{this.verdictSettled||this.store.setPending(true)},onSettled:()=>{this.verdictSettled=true,this.store.setPending(false)},telemetry:this.telemetry,...e?{scheduler:e}:{}})}acquireInternal(e,t,r,n,l=false){let i=`${this.epoch}|${e}|${t}`,o=this.entries.get(i);if(o)return l||(o.warm?o.warm=false:o.refCount+=1),o.controller;let a=r();return this.entries.set(i,{controller:a,refCount:1,warm:l}),this.destroyers.set(a,n),a}releaseInternal(e){for(let[t,r]of this.entries)if(r.controller===e){r.refCount-=1,r.refCount<=0&&(this.runDestroyer(e),this.entries.delete(t));return}}runDestroyer(e){let t=this.destroyers.get(e);this.destroyers.delete(e),t&&t(e)}buildChatController(e){let t=createChatController({auth:this.buildAuth(e.userRef),telemetry:this.telemetry,...this.errorPolicy?{errorPolicy:kd(this.errorPolicy,this.errorContext,"chat")}:{},initialConversationId:e.conversationId,petRef:e.petRef,onConversationStarted:e=>this.emit({type:"conversation_started",conversationId:e}),unread:this.unread});return this.runBootstrap(t,e),t}runBootstrap(e,t){let r={};t.petRef!==null&&(r.petRef=t.petRef),t.conversationId!==null&&(r.resumeConversationId=t.conversationId);let n=bootstrapChat(r,{controller:e});return n.then(t=>e.adoptPrompts(t.suggestedPrompts)).catch(()=>{}),this.bootstraps.set(e,n),n}buildAuth(e){return this.identity!==null&&this.currentUser!==null?{mode:"personalized",transport:this.transport,identity:this.identity,userRef:this.currentUser.userRef,sessionId:this.sessionId}:{mode:"anonymous",transport:this.transport,publishableKey:this.publishableKey,userRef:this.currentUser===null?null:e,sessionId:this.sessionId,anonIdentity:this.anonIdentity??=createAnonIdentityProvider(this.transport,this.publishableKey,this.sessionId)}}setUser(e){if(this.disposed)return;let t=e?.userRef??null,r=this.currentUser?.userRef??null;if(t===r){this.currentUser=e,e&&this.identity===null&&(this.identity=this.buildIdentity(e));return}this.pendingBeforeLogout=this.beforeLogoutSettlement(),this.identity?.clear(),this.clearTokenRefresh(),this.currentUser=e,this.identity=this.buildIdentity(e),this.rescopeAll()}async logout(){if(this.disposed)return;let e=this.currentUser===null;this.leavingSessionId=this.sessionId,this.sessionId=newSessionId(),this.anonIdentity=null,this.setUser(null),this.leavingSessionId=null,e&&this.rescopeAll();let t=this.pendingBeforeLogout;this.pendingBeforeLogout=null,t!==null&&await t,await ld(this.kv,this.telemetry)}onBeforeLogout(e){return this.disposed?()=>{}:(this.beforeLogoutHooks.add(e),()=>{this.beforeLogoutHooks.delete(e)})}beforeLogoutSettlement(){let e=this.currentUser,t=this.identity;return rd({leaving:e,identity:t,hooks:this.beforeLogoutHooks,telemetry:this.telemetry,graceAuth:()=>nd({leaving:e,identity:t,transport:this.transport,sessionId:this.leavingSessionId??this.sessionId})})}async registerPet(e,t){return this.withPets("registerPet",(r,n)=>ei(Jl(this,n,e,t),()=>t===void 0?r.registerPet(e):r.registerPet(e,t)))}updatePet(e,t){return this.withPets("updatePet",r=>r.updatePet(e,t))}deletePet(e){return this.withPets("deletePet",t=>t.deletePet(e))}eraseUserData(){return this.withPets("eraseUserData",e=>e.eraseUserData())}async withPets(e,t){if(this.disposed)return err(Ed(e));let r=this.buildAuth(this.currentUser?.userRef??null),n=await t(createPetsRepository(r),r);return n.ok&&!this.disposed&&li(this),n}prepare(e){let t=e?.petRef??null,r=`${this.epoch}|${this.currentUser?.userRef??""}|${t??""}`,n=this.prepared;if(n!==null&&n.key===r&&(n.result===null||n.result.status==="ready"))return n.promise;let l={key:r,result:null,promise:this.runPrepare(t).then(e=>(l.result=e,e))};return this.prepared=l,l.promise}async runPrepare(e){let t=Date.now(),r=this.configFailure,n=this.disposed?Ed("prepare"):r===null?null:bd(r),l=this.identity,[i,o,a]=await Promise.all([n?err(n):l===null?ok(void 0):l.currentToken().then(()=>ok(void 0),e=>(l.reportRejected?.(),err(X(e)))),n?err(n):this.primeEntitlements(),e===null?void 0:n?err(n):this.primeChat(e)]),s=i.ok?o.ok&&(a?.ok??true)?"ready":"partial":"failed",u=Date.now()-t;try{this.telemetry.track("sdk.prepare.timing",{durationMs:u,status:s})}catch{}if(s==="ready")this.emit({type:"ready"});else if(s==="failed"&&!i.ok&&r===null&&!this.disposed){let e=i.error.requestId??null;this.emit({type:"error",code:i.error.code,requestId:e,context:Ee(this.errorContext,"runtime",e)})}/* @__PURE__ */
49
49
  return Object.freeze({status:s,durationMs:u,session:i,entitlements:o,...a?{chat:a}:{}})}async primeEntitlements(){let e=await(this.poller?.prime());return e?e.kind==="failed"?err(e.error):ok(void 0):err(makeEverfurError("internalError",{retryable:true}))}async primeChat(e){let t={userRef:this.currentUser?.userRef??null,petRef:e,conversationId:null},r=this.acquireInternal("chat",Od(t),()=>this.buildChatController(t),Pd,true),n=await this.bootstraps.get(r);return n?.cause&&r.getSnapshot().conversationId===null&&(n=await this.runBootstrap(r,t)),n?.cause?err(n.cause):ok(void 0)}setActivePet(e){if(this.disposed)return;let t=e??null;t!==this.activePet&&(this.activePet=t,this.rescopeAll({keepBranding:true}))}updateEntitlements(e){this.disposed||this.configFailure===null&&this.store.set(e)}open(e){this.telemetry.track("sdk.open",{capability:e})}dispose(){this.disposed||(this.disposed=true,this.epoch+=1,this.poller?.stop(),this.sdkConfigHost!==void 0&&(this.sdkConfigHost.disposed=true,this.sdkConfigHost.store?.dispose(),this.sdkConfigHost.store=null,this.sdkConfigHost.branding.set(null)),this.identity?.clear(),this.clearTokenRefresh(),this.disposeAllControllers())}rescopeAll(e){this.epoch+=1,this.disposeAllControllers(),this.unread.reset(),this.store.reset(e),this.verdictSettled=false,this.poller?.refresh()}disposeAllControllers(){for(let e of this.entries.values())this.runDestroyer(e.controller);this.entries.clear(),this.destroyers.clear()}};function Od(e){return`${e.userRef??""}|${e.petRef??""}|${e.conversationId??""}`}function Pd(e){e.dispose()}function Ed(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}function Fd(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function jd(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 Ad(e){return e.ok?e:err(jd(e.error))}function Md(e){return{send:async(...t)=>Ad(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var $d=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Dd=globalThis,Bd=Dd[$d]??(Dd[$d]=createContext(null));Bd.displayName??="EverfurContext";function Nd(){let e=t(Bd);if(e===null)throw new C("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}function useEverfur(){return Nd().handle}var Ud=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Ld=globalThis,Hd=Ld[Ud]??(Ld[Ud]=createContext(Io));Hd.displayName??="EverfurThemeContext";function useEverfurTheme(){return t(Hd)}var Wd=()=>()=>{},qd=()=>null;function Vd(e,t){return n(t?.subscribe??Wd,t?.get??qd,t?.get??qd)??e}function EverfurThemeProviderCore(e){let{runtime:t}=Nd(),i=t.entitlements,o=n(i.subscribe,i.getSnapshot,i.getSnapshot),s=e.seams.useColorScheme(),u=e.seams.useReducedMotion(),d=e.seams.useTextScale(),c=e.seams.useHighContrast(),f=e.seams.scaleTypeSizes,p=e.seams.typeProfile,h=e.seams.platformMonoFamily?.(),g=e.seams.isFontRegistered,m=e.clientTheme?Kd(e.clientTheme):"",b=l(()=>e.clientTheme?parseClientBranding(e.clientTheme):null,[m]),y=Vd(o.branding??null,t.sdkConfigHost?.branding),v=l(()=>resolveTheme({branding:y,clientOverride:b,colorScheme:s,reducedMotion:u,textScale:d,scaleTypeSizes:f,highContrast:c,...p===void 0?{}:{typeProfile:p},...h===void 0?{}:{platformMonoFamily:h},...g===void 0?{}:{isFontRegistered:g}}),[y,b,s,u,d,f,p,c,h,g]);e.seams.useResolvedTheme?.(v);let w=e.seams.isDevelopment;return a(()=>{w===void 0||!Gd(w)||Qo(themeAdjustments({branding:y,clientOverride:b,colorScheme:s}))},[w,y,b,s]),r(Hd.Provider,{value:v},e.children)}function Kd(e){try{return JSON.stringify(e)}catch{return Object.keys(e).join("&")}}function Gd(e){try{return e()===!0}catch{return false}}function EverfurProviderCore(e){let{config:t,user:n,activePet:i,theme:s,warmUp:d,children:f,seams:p}=e,h=`${t?.publishableKey??""}|${t?.apiBaseUrl??""}|${t?.contractVersion??""}`,g=o(null),m=o(null),b=o(t?.onEvent);b.current=t?.onEvent;let y=o(e=>{b.current?.(e)}),[v,w]=c(e=>e+1,0),k=o(null),x=o(void 0),C=n?.userRef??null;x.current!==C&&(x.current!==void 0&&(k.current=null),x.current=C);let S=k.current!==null?k.current.user:n??null,_=o(null),R=o(void 0),I=i??null;R.current!==I&&(R.current!==void 0&&(_.current=null),R.current=I);let z=_.current!==null?_.current.pet:i??null;(g.current===null||g.current.key!==h||g.current.runtime.isDisposed)&&(g.current!==null&&!g.current.runtime.isDisposed&&(m.current=g.current.runtime),g.current={key:h,runtime:createEverfurRuntime({config:Yd(p.withDefaults?p.withDefaults(t):t,y.current),user:S,activePet:z,theme:s??null},{platform:p.platform,...p.eventSourceFactory?{eventSourceFactory:p.eventSourceFactory}:{}})});let T=g.current.runtime,O=o(null);a(()=>{let e=g.current?.runtime;e===void 0||!e.isDisposed||O.current!==e&&(O.current=e,w())}),a(()=>{let e=m.current;e!==null&&(m.current=null,e.dispose())});let P=S?.userRef??null;u(()=>{T.setUser(S)},[T,P]),u(()=>{T.setActivePet(z)},[T,z]);let E=o(null);a(()=>(E.current===T&&(E.current=null),()=>{E.current=T,Zd(()=>{E.current===T&&(E.current=null,T.dispose())})}),[T]),a(()=>{d==="onMount"&&T.prepare(z===null?{}:{petRef:z})},[T,d,P,z]);let F=l(()=>({setUser:e=>{k.current={user:e},T.setUser(e),w()},setActivePet:e=>{_.current={pet:e},T.setActivePet(e),w()},open:e=>T.open(e),prepare:e=>T.prepare(e),registerPet:(e,t)=>T.registerPet(e,t),updatePet:(e,t)=>T.updatePet(e,t),deletePet:e=>T.deletePet(e),eraseUserData:()=>T.eraseUserData(),logout:()=>{k.current={user:null};let e=T.logout();return w(),e}}),[T,w]),j=l(()=>({runtime:T,handle:F,userRef:P,activePet:z,scopeEpoch:T.scopeEpoch,publishableKey:Qd(t)}),[T,F,P,z,v,h]),A=r(EverfurThemeProviderCore,{clientTheme:s??null,seams:p.theme,children:f});return r(Bd.Provider,{value:j},p.wrap?p.wrap(A):A)}function Yd(e,t){return typeof e!="object"||e===null?e:{...e,onEvent:t}}function Zd(e){if(typeof queueMicrotask=="function"){queueMicrotask(e);return}Promise.resolve().then(e)}function Qd(e){return typeof e?.publishableKey=="string"?e.publishableKey.trim():""}var Xd="everfur:";function Jd(){try{if(typeof window>"u")return null;let e=window.localStorage;return e&&typeof e.getItem=="function"?e:null}catch{return null}}function createLocalStorageKv(){return{async getItem(e){try{return Jd()?.getItem(Xd+e)??null}catch{return null}},async setItem(e,t){try{Jd()?.setItem(Xd+e,t)}catch{}},async removeItem(e){try{Jd()?.removeItem(Xd+e)}catch{}},async keys(e){try{let t=Jd();if(t===null)return[];let r=[],n=Xd+e;for(let e=0;e<t.length;e+=1){let l=t.key(e);l!==null&&l.startsWith(n)&&r.push(l.slice(Xd.length))}/* @__PURE__ */
50
- return Object.freeze(r)}catch{return[]}}}}var ec="https://sdk.everfur.com",tc=/* @__PURE__ */Object.freeze({k1:"X4wc1hwVONs4I9Vmclo9ExrfPZlH8-tgY7NmzxuA5lI"}),rc=/* @__PURE__ */Object.freeze(["health-plan","health-plan-today","shop","shop-orders-v2","ui","televet-booking","televet-call"]),nc=/* @__PURE__ */Object.freeze({"@everfur/sdk/web/health-plan":"health-plan","@everfur/sdk/web/health-plan/today":"health-plan-today","@everfur/sdk/web/shop":"shop","@everfur/sdk/web/shop/orders-v2":"shop-orders-v2","@everfur/sdk/web/ui":"ui","@everfur/sdk/web/televet/booking":"televet-booking","@everfur/sdk/web/televet/call":"televet-call"}),lc=1795440709e3,ic=3e3,oc=8e3,ac=256*1024,sc=4*1024*1024,uc="web_runtime.fallback";var dc=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeBridge@v${1}`);function cc(){let e=globalThis,t=e[dc];if(t!==void 0)return t;let r={major:1,host:null,defined:/* @__PURE__ */new Map,waiters:/* @__PURE__ */new Map,importSubpath:null};return e[dc]=r,r}function fc(e){if(typeof e!="string")return null;let t=/^(\d+)\./.exec(e);return t===null?null:Number(t[1])}function pc(e){let t=fc(e.React?.version);if(t===null||typeof e.React.createElement!="function")return null;let r=cc();return r.host===null?(r.host={...e,reactMajor:t},{reactMajor:t}):r.host.React.createElement===e.React.createElement&&r.host.reactMajor===t?{reactMajor:t}:null}function hc(){return cc().host}var gc=(e,t)=>`${e}@${t}`;function mc(e,t){return cc().defined.get(gc(e,t))??null}function bc(e,t,r){let n=cc(),l=n.ran??=/* @__PURE__ */new Map,i=gc(e,t),o=l.get(i);return o===void 0?n.defined.has(i)?false:(l.set(i,r),true):o===r}function yc(e,t,r){let n=mc(e,t);if(n!==null)return Promise.resolve(n);let l=cc(),i=gc(e,t);return new Promise(e=>{let t=l.waiters.get(i)??/* @__PURE__ */new Set;l.waiters.set(i,t);let n=r=>{clearTimeout(a),t.delete(o),e(r)},o=e=>n(e),a=setTimeout(()=>n(null),r);t.add(o)})}function vc(e){cc().importSubpath=e}function wc(e,t){let r=Object.keys(t).sort().map(e=>`${e}=${t[e]}`).join(",");return`v${1}|${e}|${r}`}var kc=wc(Me,tc);var xc=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeBundledOnly@v${1}`),Cc=globalThis,Sc=()=>Cc[xc]===true,_c=()=>{Cc[xc]=true};var Rc=/^\d{1,4}\.\d{1,5}\.\d{1,6}(?:-[0-9A-Za-z.-]{1,64})?$/,Ic=/^[a-z0-9][a-z0-9.-]{0,80}\.js$/,zc=/^sha384-[A-Za-z0-9+/]{64}$/,Tc=/^[0-9a-f]{32}$/,Oc=/^[A-Za-z0-9_-]+$/,Pc=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Ec(e){if(typeof e!="string"||e.length===0||!Oc.test(e))return null;let t=e.replace(/-/g,"+").replace(/_/g,"/");try{let e=atob(t+"=".repeat((4-t.length%4)%4)),r=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)r[t]=e.charCodeAt(t);return r}catch{return null}}var Fc=/^\d{4}(-\d\d){2}T\d\d(:\d\d){2}(\.\d{1,3})?Z$/,jc=14*864e5;function Ac(e){if(typeof e!="string"||!Fc.test(e))return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function Mc(e){if(!Pc(e)||!Array.isArray(e.react)||!Pc(e.parts))return null;let t=e.react.filter(e=>Number.isInteger(e)&&e>0);if(t.length===0||t.length!==e.react.length)return null;let r={};for(let[t,n]of Object.entries(e.parts))if(rc.includes(t)){if(!Pc(n)||typeof n.path!="string"||typeof n.integrity!="string"||!Ic.test(n.path)||!zc.test(n.integrity))return null;r[t]={path:n.path,integrity:n.integrity}}return{react:t,parts:r}}function $c(e){if(!Pc(e)||e.schema!==1||!Number.isInteger(e.major))return null;let t=Ac(e.issuedAt),r=Ac(e.expiresAt);if(t===null||r===null||typeof e.stable!="string"||!Rc.test(e.stable)||r<=t||r-t>jc||!Pc(e.versions))return null;let n={};for(let[t,r]of Object.entries(e.versions)){let e=Mc(r);if(!Rc.test(t)||e===null)return null;n[t]=e}let l=null;if(e.canary!==void 0&&e.canary!==null){let t=e.canary;if(!Pc(t)||typeof t.version!="string"||!Rc.test(t.version)||typeof t.percent!="number"||!Number.isFinite(t.percent)||t.percent<0||t.percent>100)return null;l={version:t.version,percent:t.percent}}let i={};if(e.pins!==void 0){if(!Pc(e.pins))return null;for(let[t,r]of Object.entries(e.pins)){if(!Tc.test(t)||typeof r!="string"||!Rc.test(r))return null;i[t]=r}}let o=[];if(e.revoked!==void 0){if(!Array.isArray(e.revoked)||!e.revoked.every(e=>typeof e=="string"&&Rc.test(e)))return null;o=e.revoked}return{schema:1,major:e.major,issuedAt:t,expiresAt:r,stable:e.stable,canary:l,pins:i,revoked:o,versions:n}}async function Dc(e,t,r,n,l=lc){if(!Pc(e)||e.v!==1||typeof e.keyId!="string")return{ok:false,reason:"manifest-shape"};let i=Ec(e.payload),o=Ec(e.signature);if(i===null||o===null||o.length!==64)return{ok:false,reason:"manifest-shape"};let a=Object.prototype.hasOwnProperty.call(t,e.keyId)?Ec(t[e.keyId]):null;if(a===null||a.length!==32)return{ok:false,reason:"signature-key"};let s;try{let e=await r.subtle.importKey("raw",a,{name:"Ed25519"},!1,["verify"]);s=await r.subtle.verify({name:"Ed25519"},e,o,i)}catch{return{ok:false,reason:"signature-unsupported"}}if(!s)return{ok:false,reason:"signature-invalid"};let u;try{u=JSON.parse((new TextDecoder).decode(i))}catch{return{ok:false,reason:"manifest-shape"}}let d=$c(u);return d===null?{ok:false,reason:"manifest-shape"}:d.major!==1?{ok:false,reason:"manifest-major"}:n>=d.expiresAt?{ok:false,reason:"manifest-expired"}:d.issuedAt<l?{ok:false,reason:"manifest-stale"}:{ok:true,manifest:d}}function Bc(e,t){let[r="",n]=e.split(/-(.*)/s,2),[l="",i]=t.split(/-(.*)/s,2),o=r.split(".").map(Number),a=l.split(".").map(Number);for(let e=0;e<3;e+=1){let t=(o[e]??0)-(a[e]??0);if(t!==0)return t<0?-1:1}if(n===i)return 0;if(n===void 0)return 1;if(i===void 0)return-1;let s=n.split("."),u=i.split(".");for(let e=0;;e+=1){let t=s[e],r=u[e];if(t===r)continue;if(t===void 0||r===void 0)return t===void 0?-1:1;let n=/^\d+$/.test(t),l=/^\d+$/.test(r);return n!==l?n?-1:1:(n?Number(t)<Number(r):t<r)?-1:1}}function Nc(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619)>>>0;return t>>>0}function Uc(e,t){return Nc(`${e??"-"}:${t}`)%100}async function Lc(e,t){try{let r=await t.subtle.digest("SHA-256",(new TextEncoder).encode(e));return Array.from(new Uint8Array(r),e=>e.toString(16).padStart(2,"0")).join("").slice(0,32)}catch{return null}}function Hc(e,t){let r=t.tenantKey===null?void 0:e.pins[t.tenantKey],n,l;if(r!==void 0?(n=r,l="pin"):e.canary!==null&&Uc(t.tenantKey,t.sessionBucket)<e.canary.percent?(n=e.canary.version,l="canary"):(n=e.stable,l="stable"),e.revoked.includes(n))return{use:"bundled",reason:"revoked"};if(l!=="pin"&&Bc(n,t.bundledVersion)<0&&!e.revoked.includes(t.bundledVersion))return{use:"bundled",reason:"bundled-newer"};let i=e.versions[n];return i===void 0?{use:"bundled",reason:"version-missing"}:{use:"remote",version:n,entry:i,reason:l}}var Wc=/^manifest-(fetch|timeout)$/,qc="everfur:web-runtime:unreachable",Vc=10*6e4;function Kc(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}async function Gc(e,t,r,n,l="default"){let i=typeof AbortController=="function"?new AbortController:null,o=null,a=()=>{},s=new Promise(e=>{a=e}),u=setTimeout(()=>{a("timeout"),i?.abort(),o?.()},r),d=e=>Promise.race([e,s]);try{let r=await d(e(t,{mode:"cors",credentials:"omit",referrerPolicy:"no-referrer",redirect:"error",cache:l,...i?{signal:i.signal}:{}}));if(r==="timeout")return{ok:!1,why:"timeout"};if(!r.ok)return{ok:!1,why:"http"};let a=Number(r.headers.get("content-length")??Number.NaN),s=r.body?.getReader()??null;if(o=()=>{s!==null&&s.cancel().catch(()=>{})},Number.isFinite(a)&&a>n)return o(),{ok:!1,why:"too-large"};if(s===null){let e=await d(r.arrayBuffer());return e==="timeout"?{ok:!1,why:"timeout"}:e.byteLength>n?{ok:!1,why:"too-large"}:{ok:!0,bytes:new Uint8Array(e)}}let u=[],c=0;for(;;){let e=await d(s.read());if(e==="timeout")return{ok:!1,why:"timeout"};if(e.done)break;if(c+=e.value.byteLength,c>n)return o(),{ok:!1,why:"too-large"};u.push(e.value)}let f=new Uint8Array(c),p=0;for(let e of u)f.set(e,p),p+=e.byteLength;return{ok:!0,bytes:f}}catch{return{ok:false,why:i?.signal.aborted?"timeout":"error"}}finally{clearTimeout(u)}}function Yc(e){let t=e.hasDom&&Object.keys(e.keys).length>0&&e.fetch!==null&&e.crypto!==null,r=e.manifestTimeoutMs??ic,n=e.partTimeoutMs??oc,l=e.manifestMaxBytes??ac,i=e.partMaxBytes??sc,o=`${e.origin}/web-runtime`,a=null,s=/* @__PURE__ */new Map,u=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map,f=null,p=null;async function h(){let t=await Gc(e.fetch,`${o}/${1}/manifest.json`,r,l,"no-store");if(!t.ok){let r=t.why==="timeout"?"manifest-timeout":t.why==="too-large"?"manifest-too-large":"manifest-fetch";if(t.why==="error"||t.why==="timeout")try{e.unreachable?.()?.setItem(qc,`${e.now()+Vc}|${r}`)}catch{}return{ok:false,reason:r}}let n;try{n=JSON.parse((new TextDecoder).decode(t.bytes))}catch{return{ok:false,reason:"manifest-shape"}}return Dc(n,e.keys,e.crypto,e.now(),e.minIssuedAt??lc)}function g(t){let r=t??"",n=s.get(r);if(n)return n;let l=(async()=>{a??=h();let r=await a;if(!r.ok)return{ok:false,reason:r.reason};let n=t===null?null:await Lc(t,e.crypto),l=Hc(r.manifest,{tenantKey:n,sessionBucket:e.sessionBucket(),bundledVersion:e.bundledVersion});return l.use==="remote"?{ok:true,choice:l}:{ok:false,reason:l.reason}})();return s.set(r,l),l}async function m(t,r){if(await Promise.resolve(),Sc())return{ok:false,reason:"disabled",version:null};let l=hc();if(l===null)return{ok:false,reason:"react-unregistered",version:null};let a=await g(r);if(!a.ok)return{ok:false,reason:a.reason,version:null};let{version:s,entry:u}=a.choice;if(!u.react.includes(l.reactMajor))return{ok:false,reason:"react-mismatch",version:s};let d=u.parts[t];if(d===void 0)return{ok:false,reason:"part-missing",version:s};if(!bc(t,s,d.integrity))return{ok:false,reason:"part-integrity",version:s};let c=mc(t,s);if(c!==null)return{ok:true,namespace:c,version:s};let f=`${o}/${s}/${d.path}`;if(Sc())return{ok:false,reason:"disabled",version:s};let h=await Gc(e.fetch,f,n,i);if(!h.ok)return{ok:false,reason:h.why==="timeout"?"part-timeout":h.why==="too-large"?"part-too-large":"part-fetch",version:s};let m=h.bytes,b;try{b=`sha384-${Kc(new Uint8Array(await e.crypto.subtle.digest("SHA-384",m)))}`}catch{return{ok:false,reason:"part-integrity",version:s}}if(b!==d.integrity)return{ok:false,reason:"part-integrity",version:s};if(Sc())return{ok:false,reason:"disabled",version:s};let y=e.createBlobUrl?.(m)??null,v="error";if(y!==null&&(v=await e.runScript(y,d.integrity,"blob",p),e.revokeBlobUrl(y)),v==="error"&&(v=await e.runScript(f,d.integrity,"cdn",p)),v==="error")return{ok:false,reason:"part-load",version:s};let w=await yc(t,s,50);return w===null?{ok:false,reason:"part-load",version:s}:{ok:true,namespace:w,version:s}}let b=t?null:e.hasDom?"disabled":"server";try{let[t,r]=(e.unreachable?.()?.getItem(qc)??"").split("|");Number(t)>e.now()&&Wc.test(String(r))&&(b??=r)}catch{}function y(e,t){if(b!==null)return Promise.resolve({ok:false,reason:b,version:null});f??=t;let r=`${t??""}|${e}`,n=u.get(r);if(n)return n;let l=m(e,t).then(e=>e,()=>({ok:false,reason:"part-load",version:null}));return l.then(e=>d.set(r,e)),u.set(r,l),l}return t&&vc(e=>{let t=Object.prototype.hasOwnProperty.call(nc,e)?nc[e]:void 0,r=()=>{let t=c.get(e);return t?t():Promise.reject(new TypeError(`${e} is not available to the Everfur web runtime`))};return t===void 0?r():y(t,f).then(e=>e.ok?e.namespace:r())}),{enabled:t,peek:(e,t)=>b!==null?{ok:false,reason:b,version:null}:d.get(`${t??""}|${e}`)??null,load:y,registerHostSubpaths:e=>{for(let[t,r]of Object.entries(e))c.has(t)||c.set(t,r)},setCspNonce:e=>{p=e===null||e===""?null:e}}}var Zc="everfur:web-runtime:bucket",Qc=null;function Xc(){try{let e=globalThis.sessionStorage?.getItem(Zc);if(e)return e}catch{}Qc??=Math.floor(Math.random()*4294967296).toString(16);try{globalThis.sessionStorage?.setItem(Zc,Qc)}catch{}return Qc}function Jc(e){return(t,r,n,l)=>new Promise(i=>{let o;try{o=e.createElement("script"),o.type="module",n==="cdn"&&(o.integrity=r,o.crossOrigin="anonymous"),l!==null&&(o.nonce=l),o.addEventListener("load",()=>{o.remove(),i("load")}),o.addEventListener("error",()=>{o.remove(),i("error")}),o.src=t,(e.head??e.documentElement).appendChild(o)}catch{i("error")}})}function ef(){let e=typeof document>"u"?null:document,t=globalThis.crypto;return{origin:ec,keys:tc,bundledVersion:Me,fetch:typeof fetch=="function"?fetch.bind(globalThis):null,crypto:t?.subtle?t:null,hasDom:e!==null&&typeof window<"u",runScript:e===null?()=>Promise.resolve("error"):Jc(e),createBlobUrl:typeof Blob=="function"&&typeof URL.createObjectURL=="function"?e=>{try{return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}catch{return null}}:null,revokeBlobUrl:e=>{try{URL.revokeObjectURL(e)}catch{}},now:()=>Date.now(),sessionBucket:Xc,unreachable:()=>globalThis.sessionStorage}}var tf=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeLoader@${kc}`);function rf(){let e=globalThis;return e[tf]??=Yc(ef())}var nf=/* @__PURE__ */new Set(["disabled","server","bundled-newer"]),lf=/* @__PURE__ */new Set;function of(e,t,r,n){if(nf.has(r))return;let l=`${t}|${r}`;if(!lf.has(l)){lf.add(l);try{e?.trackExpectedFailure(uc,{part:t,reason:r,version:n,bundled:Me})}catch{}}}var af=/* @__PURE__ */new Set,sf=class extends g{constructor(){super(...arguments);this.state={failed:false}}static getDerivedStateFromError(){return{failed:true}}componentDidCatch(){this.props.onError()}render(){return this.state.failed?this.props.fallback():this.props.children}},uf=/* @__PURE__ */new Map;function df(e,t,r){let n=`${t??""}|${e.part}|${e.name}`,l=uf.get(n);return l===void 0&&(l=h(async()=>{let n=await rf().load(e.part,t),l=n.ok?n.namespace[e.name]:void 0;return n.ok&&typeof l!="function"&&(typeof l!="object"||l===null)?(of(r.current,e.part,"part-missing",n.version),{default:e.bundled}):(n.ok||of(r.current,e.part,n.reason,n.version),{default:n.ok?l:e.bundled})}),uf.set(n,l)),l}var cf=()=>()=>{},ff=()=>false,pf=()=>true;function RuntimeSurface({spec:l,props:s}){let u=t(Bd),c=Sc(),f=u?.publishableKey?u.publishableKey:null,p=o(null);p.current=u?.runtime.registry?.services?.telemetry??null;let h=n(cf,ff,pf),g=o(null),[,m]=i(0),y=c?null:rf();if(l.hostSubpaths!==void 0&&y?.enabled&&y.registerHostSubpaths(l.hostSubpaths),h)g.current=l.wait==="bundled"&&y!==null?"hydrate":"bundled";else if(g.current===null)if(!y?.enabled||af.has(l.part))g.current="bundled";else if(pc({React:e,ReactDOM:b})===null)of(p.current,l.part,"react-mismatch",null),g.current="bundled";else{let e=y.peek(l.part,f);g.current=e===null?"suspense":e.ok?"direct":"bundled"}let v=g.current,w=h||v!=="hydrate"?null:y?.peek(l.part,f)??null,k=!h&&v==="hydrate"&&w===null&&y?.enabled===true&&!af.has(l.part);a(()=>{if(!k||y===null)return;if(pc({React:e,ReactDOM:b})===null){of(p.current,l.part,"react-mismatch",null);return}let t=true;return y.load(l.part,f).then(e=>{e.ok||of(p.current,l.part,e.reason,e.version),t&&m(e=>e+1)}),()=>{t=false}},[k,y,l.part,f]);let x=()=>r(l.bundled,s),C=e=>r(sf,{fallback:x,onError:()=>{af.add(l.part),of(p.current,l.part,"render",null)},children:e});if(h||v==="bundled")return x();if(v==="hydrate"||v==="direct"){let e=w??y?.peek(l.part,f),t=e?.ok?e.namespace[l.name]:void 0;return t===void 0||af.has(l.part)?x():C(r(t,s))}let S=df(l,f,p),_=l.wait==="bundled"?x():r("div",{"data-everfur-runtime":"loading","aria-busy":true});return C(r(d,{fallback:_},r(S,s)))}var hf=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeRenderer@${kc}`),gf=globalThis;function mf(e,t=false){e===null?delete gf[hf]:(t||gf[hf]===void 0)&&(gf[hf]=e)}var bf=RuntimeSurface,yf=(e,t)=>r(bf,{spec:e,props:t});function vf(e){if(mf(yf),e!==void 0&&e!==""){let t=rf();t.enabled&&t.setCspNonce(e)}}var wf=/* @__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[wf[t]]}}function kf(e,t){let{scale:r,scaleCaps:n}=e.type,l=n[t];return l>0?Math.min(r,l):r}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[wf[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function xf(){try{return process.env.NODE_ENV!=="production"}catch{return false}}var Cf=/* @__PURE__ */new Map,Sf=/* @__PURE__ */new Set,_f=typeof document>"u"?a:u;function Rf(e){return e.cssSrc!==void 0?`css\n${e.cssSrc}`:`file\n${e.family}\n${e.src??""}\n${e.weight??"400"}\n${e.style??"normal"}`}function If(e,t){if(!t)return;let r=e.cssSrc??e.src??"",n=`[everfur] A font in appearance.fonts did not load: "${e.family}" from ${r}. The text renders in the fallback font. If your page sets a Content-Security-Policy, allow this host in font-src`+(e.cssSrc!==void 0?" and style-src (and the font files the stylesheet names in font-src).":".");if(!Sf.has(n)){Sf.add(n);try{globalThis.console?.warn?.(n)}catch{}}}function zf(e){let t=document.getElementsByTagName("link");for(let r=0;r<t.length;r+=1){let n=t[r];if(n.rel==="stylesheet"&&n.getAttribute("href")===e)return n}return null}function Tf(e){return zf(e)!==null?Promise.resolve(true):new Promise(t=>{let r=document.createElement("link");r.rel="stylesheet",r.href=e,r.setAttribute("data-everfur-font",""),r.addEventListener("load",()=>t(true)),r.addEventListener("error",()=>t(false)),document.head.appendChild(r)})}function Of(e){let t=document.fonts;return new FontFace(e.family,`url("${e.src}")`,{display:"swap",weight:e.weight??"400",style:e.style??"normal"}).load().then(e=>(t.add(e),true)).catch(()=>false)}function Pf(e,t=false){let r=Rf(e),n=Cf.get(r);if(n===void 0){n=Promise.resolve(false);try{if(typeof document<"u"){let t=e.cssSrc===void 0?null:fs(e.cssSrc),r=e.src===void 0?null:fs(e.src);t!==null?n=Tf(t):r!==null&&(n=Of({...e,src:r}))}}catch{n=Promise.resolve(false)}let l=n.then(r=>(r||If(e,t),r));Cf.set(r,l),n=l}return n}function Ef(e,t){let r=e.type.fontSources;_f(()=>{if(r.length===0)return;let e=false;try{e=t()}catch{}for(let t of r)Pf(t,e)},[r,t])}var Ff=/* @__PURE__ */new RegExp(`^${Ka}\\/fonts\\/[\\w./-]+\\.woff2$`);function jf(e){return Ff.test(e)&&!e.includes("..")}var Af=/* @__PURE__ */new Map;function Mf(e,t,r="400"){let n=e.trim(),l=`${n}\n${t}\n${r}`,i=Af.get(l);if(i===void 0){if(i=Promise.resolve(false),t!==null&&n!==""&&n!=="System"&&jf(t))try{let e=document.fonts;i=new FontFace(n,`url("${t}") format("woff2")`,{display:"swap",weight:r}).load().then(t=>(e.add(t),!0)).catch(()=>!1)}catch{}Af.set(l,i)}return i}var $f=["regular","medium","bold","mono","monoMedium","monoBold"];function Df(e){let{families:t,fontUrls:r,weight:n,namedFaces:l}=e.type;a(()=>{for(let e of $f){let i=r[e];i!=null&&Mf(t[e],i,l[e]?n.regular:n[wf[e]])}},[t,r,n,l]),Ef(e,xf)}function Bf(e){if(typeof window>"u"||typeof window.matchMedia!="function")return null;try{return window.matchMedia(e)??null}catch{return null}}function Nf(e){return t=>{let r=Bf(e);return r===null||typeof r.addEventListener!="function"?()=>{}:(r.addEventListener("change",t),()=>r.removeEventListener?.("change",t))}}var Uf="(prefers-color-scheme: dark)",Lf="(prefers-color-scheme: light)",Hf="(prefers-reduced-motion: reduce)",Wf="(prefers-contrast: more)",qf=Nf(Uf),Vf=Nf(Hf),Kf=Nf(Wf);function Gf(){let e=Bf(Uf);return e===null?null:e.matches?"dark":Bf(Lf)?.matches?"light":null}function Yf(){return Bf(Hf)?.matches===true}function Zf(){return Bf(Wf)?.matches===true}var Qf=16,Xf=false;var Jf=null;function ep(e){return Number.parseFloat(window.getComputedStyle(e).fontSize)}function tp(){let e=document.body??document.documentElement,t=document.createElement("span");t.setAttribute("aria-hidden","true"),t.style.setProperty("position","absolute","important"),t.style.setProperty("visibility","hidden","important"),t.style.setProperty("font-size","medium","important"),e.appendChild(t);try{return ep(t)}finally{t.remove()}}function rp(){if(typeof document>"u"||typeof window>"u"||typeof window.getComputedStyle!="function")return 1;try{let e=Xf?ep(document.documentElement):tp();return Number.isFinite(e)&&e>0?e/Qf:1}catch{return 1}}function np(){return Jf===null&&(Jf=rp()),Jf}function lp(e){if(typeof window>"u"||typeof window.addEventListener!="function")return()=>{};let t=()=>{Jf=null,e()};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}function ip(){return n(qf,Gf,()=>null)}function op(){return n(Vf,Yf,()=>false)}function ap(){return n(Kf,Zf,()=>false)}function sp(){return n(lp,np,()=>1)}var up=/* @__PURE__ */Object.freeze({useColorScheme:ip,useReducedMotion:op,useTextScale:sp,useHighContrast:ap,scaleTypeSizes:true,useResolvedTheme:Df,isDevelopment:xf});function dp(e){return e.storage===void 0?{...e,storage:createLocalStorageKv()}:e}var cp=/* @__PURE__ */Object.freeze({platform:"web",withDefaults:dp,theme:up});function EverfurProvider(e){let{cspNonce:t,webRuntime:n,...l}=e;return n!==void 0&&n!=="updates"&&_c(),Sc()||vf(t),r(EverfurProviderCore,{...l,seams:cp})}function useCapability(e){let{runtime:t}=Nd(),r=t.entitlements,i=n(r.subscribe,r.getSnapshot,r.getSnapshot);return l(()=>decideCapability(e,i.decisions,{isPending:i.isPending}),[e,i])}function fp(e){let{runtime:t}=Nd(),r=t.entitlements,l=s(e=>r===void 0?()=>{}:r.subscribe(e),[r]),i=s(()=>{if(r===void 0)return false;let t=r.getSnapshot();return decideCapability(e,t.decisions,{isPending:t.isPending}).enabled},[r,e]);return n(l,i,i)}var pp=class extends g{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:t,resetKey:n}){return r(pp,{fallback:t,resetKey:n,children:r(RenderHost,{render:e})})}function hp(e,t,r){return Math.round(r*kf(e,t)*10)/10}var gp='system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',mp="System";function bp(e){let t=e.trim();return t.length===0||t===mp?gp:`${vp(t)}, ${gp}`}function yp(e){let t=e.trim();return t.length===0||t==="monospace"?"ui-monospace, Menlo, Consolas, monospace":`${vp(t)}, ui-monospace, Menlo, Consolas, monospace`}function vp(e){return`"${e.replace(/[\\"]/g,"\\$&")}"`}function faceCss(e,t){let r=e.type,n=r.families[t];return{fontFamily:t==="mono"||t==="monoMedium"||t==="monoBold"?yp(n):bp(n),fontWeight:r.namedFaces[t]?r.weight.regular:r.weight[wf[t]]}}function headingFaceCss(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type,l=faceCss(e,t);return r===null&&n===null?l:r!==null?{fontFamily:bp(r),fontWeight:n??e.type.weight[wf[t]]}:e.type.namedFaces[t]||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}var wp=/* @__PURE__ */Object.freeze({textAlign:"start"});var kp=48;function xp(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(e){let{capability:t,children:r,renderDisabled:n,renderPending:i,style:o,className:a}=e,s=useCapability(t),u=l(()=>xp(s),[s]);switch(u){case"enabled":return r;case"pending":return i?/* @__PURE__ */v(HostRender,{render:i,fallback:/* @__PURE__ */v(PendingSkeleton,{capability:t,style:o,className:a})}):/* @__PURE__ */v(PendingSkeleton,{capability:t,style:o,className:a});case"disabled":return n?/* @__PURE__ */v(HostRender,{render:()=>n(s),fallback:/* @__PURE__ */v(OffState,{decision:s,style:o,className:a}),resetKey:s}):/* @__PURE__ */v(OffState,{decision:s,style:o,className:a});default:return assertNever(u)}}function PendingSkeleton({capability:e,style:t,className:r}){let n=useEverfurTheme(),i=l(()=>Cp(n),[n]);/* @__PURE__ */
50
+ return Object.freeze(r)}catch{return[]}}}}var ec="https://sdk.everfur.com",tc=/* @__PURE__ */Object.freeze({k1:"X4wc1hwVONs4I9Vmclo9ExrfPZlH8-tgY7NmzxuA5lI"}),rc=/* @__PURE__ */Object.freeze(["health-plan","health-plan-today","shop","shop-orders-v2","ui","televet-booking","televet-call"]),nc=/* @__PURE__ */Object.freeze({"@everfur/sdk/web/health-plan":"health-plan","@everfur/sdk/web/health-plan/today":"health-plan-today","@everfur/sdk/web/shop":"shop","@everfur/sdk/web/shop/orders-v2":"shop-orders-v2","@everfur/sdk/web/ui":"ui","@everfur/sdk/web/televet/booking":"televet-booking","@everfur/sdk/web/televet/call":"televet-call"}),lc=1795449278e3,ic=3e3,oc=8e3,ac=256*1024,sc=4*1024*1024,uc="web_runtime.fallback";var dc=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeBridge@v${1}`);function cc(){let e=globalThis,t=e[dc];if(t!==void 0)return t;let r={major:1,host:null,defined:/* @__PURE__ */new Map,waiters:/* @__PURE__ */new Map,importSubpath:null};return e[dc]=r,r}function fc(e){if(typeof e!="string")return null;let t=/^(\d+)\./.exec(e);return t===null?null:Number(t[1])}function pc(e){let t=fc(e.React?.version);if(t===null||typeof e.React.createElement!="function")return null;let r=cc();return r.host===null?(r.host={...e,reactMajor:t},{reactMajor:t}):r.host.React.createElement===e.React.createElement&&r.host.reactMajor===t?{reactMajor:t}:null}function hc(){return cc().host}var gc=(e,t)=>`${e}@${t}`;function mc(e,t){return cc().defined.get(gc(e,t))??null}function bc(e,t,r){let n=cc(),l=n.ran??=/* @__PURE__ */new Map,i=gc(e,t),o=l.get(i);return o===void 0?n.defined.has(i)?false:(l.set(i,r),true):o===r}function yc(e,t,r){let n=mc(e,t);if(n!==null)return Promise.resolve(n);let l=cc(),i=gc(e,t);return new Promise(e=>{let t=l.waiters.get(i)??/* @__PURE__ */new Set;l.waiters.set(i,t);let n=r=>{clearTimeout(a),t.delete(o),e(r)},o=e=>n(e),a=setTimeout(()=>n(null),r);t.add(o)})}function vc(e){cc().importSubpath=e}function wc(e,t){let r=Object.keys(t).sort().map(e=>`${e}=${t[e]}`).join(",");return`v${1}|${e}|${r}`}var kc=wc(Me,tc);var xc=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeBundledOnly@v${1}`),Cc=globalThis,Sc=()=>Cc[xc]===true,_c=()=>{Cc[xc]=true};var Rc=/^\d{1,4}\.\d{1,5}\.\d{1,6}(?:-[0-9A-Za-z.-]{1,64})?$/,Ic=/^[a-z0-9][a-z0-9.-]{0,80}\.js$/,zc=/^sha384-[A-Za-z0-9+/]{64}$/,Tc=/^[0-9a-f]{32}$/,Oc=/^[A-Za-z0-9_-]+$/,Pc=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Ec(e){if(typeof e!="string"||e.length===0||!Oc.test(e))return null;let t=e.replace(/-/g,"+").replace(/_/g,"/");try{let e=atob(t+"=".repeat((4-t.length%4)%4)),r=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)r[t]=e.charCodeAt(t);return r}catch{return null}}var Fc=/^\d{4}(-\d\d){2}T\d\d(:\d\d){2}(\.\d{1,3})?Z$/,jc=14*864e5;function Ac(e){if(typeof e!="string"||!Fc.test(e))return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function Mc(e){if(!Pc(e)||!Array.isArray(e.react)||!Pc(e.parts))return null;let t=e.react.filter(e=>Number.isInteger(e)&&e>0);if(t.length===0||t.length!==e.react.length)return null;let r={};for(let[t,n]of Object.entries(e.parts))if(rc.includes(t)){if(!Pc(n)||typeof n.path!="string"||typeof n.integrity!="string"||!Ic.test(n.path)||!zc.test(n.integrity))return null;r[t]={path:n.path,integrity:n.integrity}}return{react:t,parts:r}}function $c(e){if(!Pc(e)||e.schema!==1||!Number.isInteger(e.major))return null;let t=Ac(e.issuedAt),r=Ac(e.expiresAt);if(t===null||r===null||typeof e.stable!="string"||!Rc.test(e.stable)||r<=t||r-t>jc||!Pc(e.versions))return null;let n={};for(let[t,r]of Object.entries(e.versions)){let e=Mc(r);if(!Rc.test(t)||e===null)return null;n[t]=e}let l=null;if(e.canary!==void 0&&e.canary!==null){let t=e.canary;if(!Pc(t)||typeof t.version!="string"||!Rc.test(t.version)||typeof t.percent!="number"||!Number.isFinite(t.percent)||t.percent<0||t.percent>100)return null;l={version:t.version,percent:t.percent}}let i={};if(e.pins!==void 0){if(!Pc(e.pins))return null;for(let[t,r]of Object.entries(e.pins)){if(!Tc.test(t)||typeof r!="string"||!Rc.test(r))return null;i[t]=r}}let o=[];if(e.revoked!==void 0){if(!Array.isArray(e.revoked)||!e.revoked.every(e=>typeof e=="string"&&Rc.test(e)))return null;o=e.revoked}return{schema:1,major:e.major,issuedAt:t,expiresAt:r,stable:e.stable,canary:l,pins:i,revoked:o,versions:n}}async function Dc(e,t,r,n,l=lc){if(!Pc(e)||e.v!==1||typeof e.keyId!="string")return{ok:false,reason:"manifest-shape"};let i=Ec(e.payload),o=Ec(e.signature);if(i===null||o===null||o.length!==64)return{ok:false,reason:"manifest-shape"};let a=Object.prototype.hasOwnProperty.call(t,e.keyId)?Ec(t[e.keyId]):null;if(a===null||a.length!==32)return{ok:false,reason:"signature-key"};let s;try{let e=await r.subtle.importKey("raw",a,{name:"Ed25519"},!1,["verify"]);s=await r.subtle.verify({name:"Ed25519"},e,o,i)}catch{return{ok:false,reason:"signature-unsupported"}}if(!s)return{ok:false,reason:"signature-invalid"};let u;try{u=JSON.parse((new TextDecoder).decode(i))}catch{return{ok:false,reason:"manifest-shape"}}let d=$c(u);return d===null?{ok:false,reason:"manifest-shape"}:d.major!==1?{ok:false,reason:"manifest-major"}:n>=d.expiresAt?{ok:false,reason:"manifest-expired"}:d.issuedAt<l?{ok:false,reason:"manifest-stale"}:{ok:true,manifest:d}}function Bc(e,t){let[r="",n]=e.split(/-(.*)/s,2),[l="",i]=t.split(/-(.*)/s,2),o=r.split(".").map(Number),a=l.split(".").map(Number);for(let e=0;e<3;e+=1){let t=(o[e]??0)-(a[e]??0);if(t!==0)return t<0?-1:1}if(n===i)return 0;if(n===void 0)return 1;if(i===void 0)return-1;let s=n.split("."),u=i.split(".");for(let e=0;;e+=1){let t=s[e],r=u[e];if(t===r)continue;if(t===void 0||r===void 0)return t===void 0?-1:1;let n=/^\d+$/.test(t),l=/^\d+$/.test(r);return n!==l?n?-1:1:(n?Number(t)<Number(r):t<r)?-1:1}}function Nc(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619)>>>0;return t>>>0}function Uc(e,t){return Nc(`${e??"-"}:${t}`)%100}async function Lc(e,t){try{let r=await t.subtle.digest("SHA-256",(new TextEncoder).encode(e));return Array.from(new Uint8Array(r),e=>e.toString(16).padStart(2,"0")).join("").slice(0,32)}catch{return null}}function Hc(e,t){let r=t.tenantKey===null?void 0:e.pins[t.tenantKey],n,l;if(r!==void 0?(n=r,l="pin"):e.canary!==null&&Uc(t.tenantKey,t.sessionBucket)<e.canary.percent?(n=e.canary.version,l="canary"):(n=e.stable,l="stable"),e.revoked.includes(n))return{use:"bundled",reason:"revoked"};if(l!=="pin"&&Bc(n,t.bundledVersion)<0&&!e.revoked.includes(t.bundledVersion))return{use:"bundled",reason:"bundled-newer"};let i=e.versions[n];return i===void 0?{use:"bundled",reason:"version-missing"}:{use:"remote",version:n,entry:i,reason:l}}var Wc=/^manifest-(fetch|timeout)$/,qc="everfur:web-runtime:unreachable",Vc=10*6e4;function Kc(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}async function Gc(e,t,r,n,l="default"){let i=typeof AbortController=="function"?new AbortController:null,o=null,a=()=>{},s=new Promise(e=>{a=e}),u=setTimeout(()=>{a("timeout"),i?.abort(),o?.()},r),d=e=>Promise.race([e,s]);try{let r=await d(e(t,{mode:"cors",credentials:"omit",referrerPolicy:"no-referrer",redirect:"error",cache:l,...i?{signal:i.signal}:{}}));if(r==="timeout")return{ok:!1,why:"timeout"};if(!r.ok)return{ok:!1,why:"http"};let a=Number(r.headers.get("content-length")??Number.NaN),s=r.body?.getReader()??null;if(o=()=>{s!==null&&s.cancel().catch(()=>{})},Number.isFinite(a)&&a>n)return o(),{ok:!1,why:"too-large"};if(s===null){let e=await d(r.arrayBuffer());return e==="timeout"?{ok:!1,why:"timeout"}:e.byteLength>n?{ok:!1,why:"too-large"}:{ok:!0,bytes:new Uint8Array(e)}}let u=[],c=0;for(;;){let e=await d(s.read());if(e==="timeout")return{ok:!1,why:"timeout"};if(e.done)break;if(c+=e.value.byteLength,c>n)return o(),{ok:!1,why:"too-large"};u.push(e.value)}let f=new Uint8Array(c),p=0;for(let e of u)f.set(e,p),p+=e.byteLength;return{ok:!0,bytes:f}}catch{return{ok:false,why:i?.signal.aborted?"timeout":"error"}}finally{clearTimeout(u)}}function Yc(e){let t=e.hasDom&&Object.keys(e.keys).length>0&&e.fetch!==null&&e.crypto!==null,r=e.manifestTimeoutMs??ic,n=e.partTimeoutMs??oc,l=e.manifestMaxBytes??ac,i=e.partMaxBytes??sc,o=`${e.origin}/web-runtime`,a=null,s=/* @__PURE__ */new Map,u=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map,f=null,p=null;async function h(){let t=await Gc(e.fetch,`${o}/${1}/manifest.json`,r,l,"no-store");if(!t.ok){let r=t.why==="timeout"?"manifest-timeout":t.why==="too-large"?"manifest-too-large":"manifest-fetch";if(t.why==="error"||t.why==="timeout")try{e.unreachable?.()?.setItem(qc,`${e.now()+Vc}|${r}`)}catch{}return{ok:false,reason:r}}let n;try{n=JSON.parse((new TextDecoder).decode(t.bytes))}catch{return{ok:false,reason:"manifest-shape"}}return Dc(n,e.keys,e.crypto,e.now(),e.minIssuedAt??lc)}function g(t){let r=t??"",n=s.get(r);if(n)return n;let l=(async()=>{a??=h();let r=await a;if(!r.ok)return{ok:false,reason:r.reason};let n=t===null?null:await Lc(t,e.crypto),l=Hc(r.manifest,{tenantKey:n,sessionBucket:e.sessionBucket(),bundledVersion:e.bundledVersion});return l.use==="remote"?{ok:true,choice:l}:{ok:false,reason:l.reason}})();return s.set(r,l),l}async function m(t,r){if(await Promise.resolve(),Sc())return{ok:false,reason:"disabled",version:null};let l=hc();if(l===null)return{ok:false,reason:"react-unregistered",version:null};let a=await g(r);if(!a.ok)return{ok:false,reason:a.reason,version:null};let{version:s,entry:u}=a.choice;if(!u.react.includes(l.reactMajor))return{ok:false,reason:"react-mismatch",version:s};let d=u.parts[t];if(d===void 0)return{ok:false,reason:"part-missing",version:s};if(!bc(t,s,d.integrity))return{ok:false,reason:"part-integrity",version:s};let c=mc(t,s);if(c!==null)return{ok:true,namespace:c,version:s};let f=`${o}/${s}/${d.path}`;if(Sc())return{ok:false,reason:"disabled",version:s};let h=await Gc(e.fetch,f,n,i);if(!h.ok)return{ok:false,reason:h.why==="timeout"?"part-timeout":h.why==="too-large"?"part-too-large":"part-fetch",version:s};let m=h.bytes,b;try{b=`sha384-${Kc(new Uint8Array(await e.crypto.subtle.digest("SHA-384",m)))}`}catch{return{ok:false,reason:"part-integrity",version:s}}if(b!==d.integrity)return{ok:false,reason:"part-integrity",version:s};if(Sc())return{ok:false,reason:"disabled",version:s};let y=e.createBlobUrl?.(m)??null,v="error";if(y!==null&&(v=await e.runScript(y,d.integrity,"blob",p),e.revokeBlobUrl(y)),v==="error"&&(v=await e.runScript(f,d.integrity,"cdn",p)),v==="error")return{ok:false,reason:"part-load",version:s};let w=await yc(t,s,50);return w===null?{ok:false,reason:"part-load",version:s}:{ok:true,namespace:w,version:s}}let b=t?null:e.hasDom?"disabled":"server";try{let[t,r]=(e.unreachable?.()?.getItem(qc)??"").split("|");Number(t)>e.now()&&Wc.test(String(r))&&(b??=r)}catch{}function y(e,t){if(b!==null)return Promise.resolve({ok:false,reason:b,version:null});f??=t;let r=`${t??""}|${e}`,n=u.get(r);if(n)return n;let l=m(e,t).then(e=>e,()=>({ok:false,reason:"part-load",version:null}));return l.then(e=>d.set(r,e)),u.set(r,l),l}return t&&vc(e=>{let t=Object.prototype.hasOwnProperty.call(nc,e)?nc[e]:void 0,r=()=>{let t=c.get(e);return t?t():Promise.reject(new TypeError(`${e} is not available to the Everfur web runtime`))};return t===void 0?r():y(t,f).then(e=>e.ok?e.namespace:r())}),{enabled:t,peek:(e,t)=>b!==null?{ok:false,reason:b,version:null}:d.get(`${t??""}|${e}`)??null,load:y,registerHostSubpaths:e=>{for(let[t,r]of Object.entries(e))c.has(t)||c.set(t,r)},setCspNonce:e=>{p=e===null||e===""?null:e}}}var Zc="everfur:web-runtime:bucket",Qc=null;function Xc(){try{let e=globalThis.sessionStorage?.getItem(Zc);if(e)return e}catch{}Qc??=Math.floor(Math.random()*4294967296).toString(16);try{globalThis.sessionStorage?.setItem(Zc,Qc)}catch{}return Qc}function Jc(e){return(t,r,n,l)=>new Promise(i=>{let o;try{o=e.createElement("script"),o.type="module",n==="cdn"&&(o.integrity=r,o.crossOrigin="anonymous"),l!==null&&(o.nonce=l),o.addEventListener("load",()=>{o.remove(),i("load")}),o.addEventListener("error",()=>{o.remove(),i("error")}),o.src=t,(e.head??e.documentElement).appendChild(o)}catch{i("error")}})}function ef(){let e=typeof document>"u"?null:document,t=globalThis.crypto;return{origin:ec,keys:tc,bundledVersion:Me,fetch:typeof fetch=="function"?fetch.bind(globalThis):null,crypto:t?.subtle?t:null,hasDom:e!==null&&typeof window<"u",runScript:e===null?()=>Promise.resolve("error"):Jc(e),createBlobUrl:typeof Blob=="function"&&typeof URL.createObjectURL=="function"?e=>{try{return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}catch{return null}}:null,revokeBlobUrl:e=>{try{URL.revokeObjectURL(e)}catch{}},now:()=>Date.now(),sessionBucket:Xc,unreachable:()=>globalThis.sessionStorage}}var tf=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeLoader@${kc}`);function rf(){let e=globalThis;return e[tf]??=Yc(ef())}var nf=/* @__PURE__ */new Set(["disabled","server","bundled-newer"]),lf=/* @__PURE__ */new Set;function of(e,t,r,n){if(nf.has(r))return;let l=`${t}|${r}`;if(!lf.has(l)){lf.add(l);try{e?.trackExpectedFailure(uc,{part:t,reason:r,version:n,bundled:Me})}catch{}}}var af=/* @__PURE__ */new Set,sf=class extends g{constructor(){super(...arguments);this.state={failed:false}}static getDerivedStateFromError(){return{failed:true}}componentDidCatch(){this.props.onError()}render(){return this.state.failed?this.props.fallback():this.props.children}},uf=/* @__PURE__ */new Map;function df(e,t,r){let n=`${t??""}|${e.part}|${e.name}`,l=uf.get(n);return l===void 0&&(l=h(async()=>{let n=await rf().load(e.part,t),l=n.ok?n.namespace[e.name]:void 0;return n.ok&&typeof l!="function"&&(typeof l!="object"||l===null)?(of(r.current,e.part,"part-missing",n.version),{default:e.bundled}):(n.ok||of(r.current,e.part,n.reason,n.version),{default:n.ok?l:e.bundled})}),uf.set(n,l)),l}var cf=()=>()=>{},ff=()=>false,pf=()=>true;function RuntimeSurface({spec:l,props:s}){let u=t(Bd),c=Sc(),f=u?.publishableKey?u.publishableKey:null,p=o(null);p.current=u?.runtime.registry?.services?.telemetry??null;let h=n(cf,ff,pf),g=o(null),[,m]=i(0),y=c?null:rf();if(l.hostSubpaths!==void 0&&y?.enabled&&y.registerHostSubpaths(l.hostSubpaths),h)g.current=l.wait==="bundled"&&y!==null?"hydrate":"bundled";else if(g.current===null)if(!y?.enabled||af.has(l.part))g.current="bundled";else if(pc({React:e,ReactDOM:b})===null)of(p.current,l.part,"react-mismatch",null),g.current="bundled";else{let e=y.peek(l.part,f);g.current=e===null?"suspense":e.ok?"direct":"bundled"}let v=g.current,w=h||v!=="hydrate"?null:y?.peek(l.part,f)??null,k=!h&&v==="hydrate"&&w===null&&y?.enabled===true&&!af.has(l.part);a(()=>{if(!k||y===null)return;if(pc({React:e,ReactDOM:b})===null){of(p.current,l.part,"react-mismatch",null);return}let t=true;return y.load(l.part,f).then(e=>{e.ok||of(p.current,l.part,e.reason,e.version),t&&m(e=>e+1)}),()=>{t=false}},[k,y,l.part,f]);let x=()=>r(l.bundled,s),C=e=>r(sf,{fallback:x,onError:()=>{af.add(l.part),of(p.current,l.part,"render",null)},children:e});if(h||v==="bundled")return x();if(v==="hydrate"||v==="direct"){let e=w??y?.peek(l.part,f),t=e?.ok?e.namespace[l.name]:void 0;return t===void 0||af.has(l.part)?x():C(r(t,s))}let S=df(l,f,p),_=l.wait==="bundled"?x():r("div",{"data-everfur-runtime":"loading","aria-busy":true});return C(r(d,{fallback:_},r(S,s)))}var hf=/* @__PURE__ */Symbol.for(`@everfur/sdk#WebRuntimeRenderer@${kc}`),gf=globalThis;function mf(e,t=false){e===null?delete gf[hf]:(t||gf[hf]===void 0)&&(gf[hf]=e)}var bf=RuntimeSurface,yf=(e,t)=>r(bf,{spec:e,props:t});function vf(e){if(mf(yf),e!==void 0&&e!==""){let t=rf();t.enabled&&t.setCspNonce(e)}}var wf=/* @__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[wf[t]]}}function kf(e,t){let{scale:r,scaleCaps:n}=e.type,l=n[t];return l>0?Math.min(r,l):r}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[wf[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function xf(){try{return process.env.NODE_ENV!=="production"}catch{return false}}var Cf=/* @__PURE__ */new Map,Sf=/* @__PURE__ */new Set,_f=typeof document>"u"?a:u;function Rf(e){return e.cssSrc!==void 0?`css\n${e.cssSrc}`:`file\n${e.family}\n${e.src??""}\n${e.weight??"400"}\n${e.style??"normal"}`}function If(e,t){if(!t)return;let r=e.cssSrc??e.src??"",n=`[everfur] A font in appearance.fonts did not load: "${e.family}" from ${r}. The text renders in the fallback font. If your page sets a Content-Security-Policy, allow this host in font-src`+(e.cssSrc!==void 0?" and style-src (and the font files the stylesheet names in font-src).":".");if(!Sf.has(n)){Sf.add(n);try{globalThis.console?.warn?.(n)}catch{}}}function zf(e){let t=document.getElementsByTagName("link");for(let r=0;r<t.length;r+=1){let n=t[r];if(n.rel==="stylesheet"&&n.getAttribute("href")===e)return n}return null}function Tf(e){return zf(e)!==null?Promise.resolve(true):new Promise(t=>{let r=document.createElement("link");r.rel="stylesheet",r.href=e,r.setAttribute("data-everfur-font",""),r.addEventListener("load",()=>t(true)),r.addEventListener("error",()=>t(false)),document.head.appendChild(r)})}function Of(e){let t=document.fonts;return new FontFace(e.family,`url("${e.src}")`,{display:"swap",weight:e.weight??"400",style:e.style??"normal"}).load().then(e=>(t.add(e),true)).catch(()=>false)}function Pf(e,t=false){let r=Rf(e),n=Cf.get(r);if(n===void 0){n=Promise.resolve(false);try{if(typeof document<"u"){let t=e.cssSrc===void 0?null:fs(e.cssSrc),r=e.src===void 0?null:fs(e.src);t!==null?n=Tf(t):r!==null&&(n=Of({...e,src:r}))}}catch{n=Promise.resolve(false)}let l=n.then(r=>(r||If(e,t),r));Cf.set(r,l),n=l}return n}function Ef(e,t){let r=e.type.fontSources;_f(()=>{if(r.length===0)return;let e=false;try{e=t()}catch{}for(let t of r)Pf(t,e)},[r,t])}var Ff=/* @__PURE__ */new RegExp(`^${Ka}\\/fonts\\/[\\w./-]+\\.woff2$`);function jf(e){return Ff.test(e)&&!e.includes("..")}var Af=/* @__PURE__ */new Map;function Mf(e,t,r="400"){let n=e.trim(),l=`${n}\n${t}\n${r}`,i=Af.get(l);if(i===void 0){if(i=Promise.resolve(false),t!==null&&n!==""&&n!=="System"&&jf(t))try{let e=document.fonts;i=new FontFace(n,`url("${t}") format("woff2")`,{display:"swap",weight:r}).load().then(t=>(e.add(t),!0)).catch(()=>!1)}catch{}Af.set(l,i)}return i}var $f=["regular","medium","bold","mono","monoMedium","monoBold"];function Df(e){let{families:t,fontUrls:r,weight:n,namedFaces:l}=e.type;a(()=>{for(let e of $f){let i=r[e];i!=null&&Mf(t[e],i,l[e]?n.regular:n[wf[e]])}},[t,r,n,l]),Ef(e,xf)}function Bf(e){if(typeof window>"u"||typeof window.matchMedia!="function")return null;try{return window.matchMedia(e)??null}catch{return null}}function Nf(e){return t=>{let r=Bf(e);return r===null||typeof r.addEventListener!="function"?()=>{}:(r.addEventListener("change",t),()=>r.removeEventListener?.("change",t))}}var Uf="(prefers-color-scheme: dark)",Lf="(prefers-color-scheme: light)",Hf="(prefers-reduced-motion: reduce)",Wf="(prefers-contrast: more)",qf=Nf(Uf),Vf=Nf(Hf),Kf=Nf(Wf);function Gf(){let e=Bf(Uf);return e===null?null:e.matches?"dark":Bf(Lf)?.matches?"light":null}function Yf(){return Bf(Hf)?.matches===true}function Zf(){return Bf(Wf)?.matches===true}var Qf=16,Xf=false;var Jf=null;function ep(e){return Number.parseFloat(window.getComputedStyle(e).fontSize)}function tp(){let e=document.body??document.documentElement,t=document.createElement("span");t.setAttribute("aria-hidden","true"),t.style.setProperty("position","absolute","important"),t.style.setProperty("visibility","hidden","important"),t.style.setProperty("font-size","medium","important"),e.appendChild(t);try{return ep(t)}finally{t.remove()}}function rp(){if(typeof document>"u"||typeof window>"u"||typeof window.getComputedStyle!="function")return 1;try{let e=Xf?ep(document.documentElement):tp();return Number.isFinite(e)&&e>0?e/Qf:1}catch{return 1}}function np(){return Jf===null&&(Jf=rp()),Jf}function lp(e){if(typeof window>"u"||typeof window.addEventListener!="function")return()=>{};let t=()=>{Jf=null,e()};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}function ip(){return n(qf,Gf,()=>null)}function op(){return n(Vf,Yf,()=>false)}function ap(){return n(Kf,Zf,()=>false)}function sp(){return n(lp,np,()=>1)}var up=/* @__PURE__ */Object.freeze({useColorScheme:ip,useReducedMotion:op,useTextScale:sp,useHighContrast:ap,scaleTypeSizes:true,useResolvedTheme:Df,isDevelopment:xf});function dp(e){return e.storage===void 0?{...e,storage:createLocalStorageKv()}:e}var cp=/* @__PURE__ */Object.freeze({platform:"web",withDefaults:dp,theme:up});function EverfurProvider(e){let{cspNonce:t,webRuntime:n,...l}=e;return n!==void 0&&n!=="updates"&&_c(),Sc()||vf(t),r(EverfurProviderCore,{...l,seams:cp})}function useCapability(e){let{runtime:t}=Nd(),r=t.entitlements,i=n(r.subscribe,r.getSnapshot,r.getSnapshot);return l(()=>decideCapability(e,i.decisions,{isPending:i.isPending}),[e,i])}function fp(e){let{runtime:t}=Nd(),r=t.entitlements,l=s(e=>r===void 0?()=>{}:r.subscribe(e),[r]),i=s(()=>{if(r===void 0)return false;let t=r.getSnapshot();return decideCapability(e,t.decisions,{isPending:t.isPending}).enabled},[r,e]);return n(l,i,i)}var pp=class extends g{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:t,resetKey:n}){return r(pp,{fallback:t,resetKey:n,children:r(RenderHost,{render:e})})}function hp(e,t,r){return Math.round(r*kf(e,t)*10)/10}var gp='system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',mp="System";function bp(e){let t=e.trim();return t.length===0||t===mp?gp:`${vp(t)}, ${gp}`}function yp(e){let t=e.trim();return t.length===0||t==="monospace"?"ui-monospace, Menlo, Consolas, monospace":`${vp(t)}, ui-monospace, Menlo, Consolas, monospace`}function vp(e){return`"${e.replace(/[\\"]/g,"\\$&")}"`}function faceCss(e,t){let r=e.type,n=r.families[t];return{fontFamily:t==="mono"||t==="monoMedium"||t==="monoBold"?yp(n):bp(n),fontWeight:r.namedFaces[t]?r.weight.regular:r.weight[wf[t]]}}function headingFaceCss(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type,l=faceCss(e,t);return r===null&&n===null?l:r!==null?{fontFamily:bp(r),fontWeight:n??e.type.weight[wf[t]]}:e.type.namedFaces[t]||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}var wp=/* @__PURE__ */Object.freeze({textAlign:"start"});var kp=48;function xp(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(e){let{capability:t,children:r,renderDisabled:n,renderPending:i,style:o,className:a}=e,s=useCapability(t),u=l(()=>xp(s),[s]);switch(u){case"enabled":return r;case"pending":return i?/* @__PURE__ */v(HostRender,{render:i,fallback:/* @__PURE__ */v(PendingSkeleton,{capability:t,style:o,className:a})}):/* @__PURE__ */v(PendingSkeleton,{capability:t,style:o,className:a});case"disabled":return n?/* @__PURE__ */v(HostRender,{render:()=>n(s),fallback:/* @__PURE__ */v(OffState,{decision:s,style:o,className:a}),resetKey:s}):/* @__PURE__ */v(OffState,{decision:s,style:o,className:a});default:return assertNever(u)}}function PendingSkeleton({capability:e,style:t,className:r}){let n=useEverfurTheme(),i=l(()=>Cp(n),[n]);/* @__PURE__ */
51
51
  return v("div",{role:"status","aria-busy":"true","aria-label":`Loading ${e}`,className:r,style:{...i.offstate,...t},children:/* @__PURE__ */v("div",{style:i.skeletonBar})})}function OffState({decision:e,style:t,className:r}){let n=useEverfurTheme(),i=l(()=>Cp(n),[n]),o=e.disabled?.reason??"";/* @__PURE__ */
52
52
  return v("div",{className:r,style:{...i.offstate,...t},children:o.length>0?/* @__PURE__ */v("p",{style:i.offstateText,children:o}):null})}function Cp(e){let{color:t,space:r,radius:n,type:l}=e;return{offstate:{...wp,boxSizing:"border-box",minHeight:kp,display:"flex",flexDirection:"column",justifyContent:"center",padding:`${r.md}px ${r.lg}px`,backgroundColor:t.surfaceCream,borderRadius:n.md,border:`1px solid ${t.brandBorder}`},offstateText:{margin:0,...faceCss(e,"regular"),fontSize:l.size.body,lineHeight:`${Math.round(l.size.body*l.lineHeight.normal)}px`,color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}}}var Sp="Go to the nearest emergency vet now.";var _p=/* @__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:Sp,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 Rp(e,t){return e.replace(/\{(\w+)\}/g,(e,r)=>{let n=t[r];return n===void 0?e:String(n)})}function Ip(e){return e?.trim()||_p.emptyTitlePetFallback}function zp(e,t){return Rp(e,{petName:Ip(t)})}var Tp="tel:+18884264435";var Op=/* @__PURE__ */Object.freeze([
53
53
  /* @__PURE__ */Object.freeze({key:"inaccurate",label:_p.feedbackReasonInaccurate,feedbackType:"wrong"}),