nervoscan-js-sdk 1.1.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var A_=Object.defineProperty;var R_=(t,e,n)=>e in t?A_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var w=(t,e,n)=>R_(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Qn=typeof document<"u"?document.currentScript:null;class j extends Error{constructor(e){super(e)}}class Ld extends j{constructor(e){super(e)}}class Dd extends j{constructor(e){super(e)}}class Pd extends j{constructor(e){super(e)}}class Fd extends j{constructor(e){super(e)}}class Md extends j{constructor(e){super(e)}}class Bd extends j{constructor(e){super(e)}}class Ud extends j{constructor(e){super(e)}}class Vd extends j{constructor(e){super(e)}}class Hd extends j{constructor(e){super(e)}}class Gd extends j{constructor(e){super(e)}}class Wd extends j{constructor(e){super(e)}}class $d extends j{constructor(e){super(e)}}class jd extends j{constructor(e){super(e)}}class qd extends j{constructor(e){super(e)}}class zd extends j{constructor(e){super(e)}}class Kd extends j{constructor(e){super(e)}}class Yd extends j{constructor(e){super(e)}}class Xd extends j{constructor(e){super(e)}}class Jd extends j{constructor(n){super(n.message);w(this,"errorCode");this.errorCode=n.code}}class Qd extends j{constructor(e){super(e)}}class Zd extends j{constructor(e){super(e)}}class ef extends j{constructor(e){super(e)}}class tf extends j{constructor(e){super(e)}}class nf extends j{constructor(e){super(e)}}class sf extends j{constructor(e){super(e)}}class rf extends j{constructor(e){super(e)}}class of extends j{constructor(e){super(e)}}class af extends j{constructor(e){super(e)}}class cf extends j{constructor(e){super(e)}}class lf extends j{constructor(e){super(e)}}class hf extends j{constructor(e){super(e)}}class uf extends j{constructor(e){super(e)}}class df extends j{constructor(e){super(e)}}const K={NotInitializedError:Ld,EmptyVideoError:Dd,VideoTypeError:Pd,InvalidUsernameError:Fd,InvalidPasswordError:Md,NoScansAvailableError:Bd,InvalidAccessTokenError:Ud,NoScanDataError:Vd,InvalidServerTypeError:Hd,NotImplementedError:Gd,LowFPSError:Wd,FPSCalculationError:$d,FaceNotCenteredError:jd,FaceTooFarError:qd,FaceTooCloseError:zd,FaceLookingLeftError:Kd,FaceLookingRightError:Yd,ErrorCallbackNotSetError:Xd,UnhandledScanError:Jd,SkinExtractionError:Qd,InvalidContentTypeError:Zd,JobNotRegisteredError:ef,LowFrameCountError:nf,ConnectionLostError:sf,ScanFailedError:rf,VideoError:of,InvalidCredentialsError:af,LicenseInactiveError:cf,RGBError:lf,FaceLandmarkerNotInitializedError:hf,EnvIncompatibleError:uf,UnhandledError:tf,InsufficientDataError:df},v={NotInitializedError:new K.NotInitializedError("Nervoscan Client not initialized!"),EmptyVideoError:new K.EmptyVideoError("Video is empty!"),VideoTypeError:new K.VideoTypeError("Video is not a Blob!"),InvalidUsernameError:new K.InvalidUsernameError("Invalid username!"),InvalidPasswordError:new K.InvalidPasswordError("Invalid password!"),NoScansAvailableError:new K.NoScansAvailableError("No scans available, Please purchase a plan!"),InvalidAccessTokenError:new K.InvalidAccessTokenError("Invalid access token!"),NoScanDataError:new K.NoScanDataError("No scan data found!"),InvalidServerTypeError:new K.InvalidServerTypeError("Invalid server type!"),NotImplementedError:new K.NotImplementedError("Not implemented!"),LowFPSError:new K.LowFPSError("Low FPS!"),FPSCalculationError:new K.FPSCalculationError("Error calculating FPS!"),FaceNotCenteredError:new K.FaceNotCenteredError("Face not centered!"),FaceTooFarError:new K.FaceTooFarError("Face too far!"),FaceTooCloseError:new K.FaceTooCloseError("Face too close!"),FaceLookingLeftError:new K.FaceLookingLeftError("Face looking left!"),FaceLookingRightError:new K.FaceLookingRightError("Face looking right!"),ErrorCallbackNotSetError:new K.ErrorCallbackNotSetError("Error callback not set!"),SkinExtractionError:new K.SkinExtractionError("Skin extraction error! Please use a better lighting!"),InvalidContentTypeError:new K.InvalidContentTypeError("Invalid content type!"),JobNotRegisteredError:new K.JobNotRegisteredError("Job not registered! Please await initializeStreaming method!"),LowFrameCountError:new K.LowFrameCountError("Low frame count! Don't stop streaming prematurely!"),ConnectionLostError:new K.ConnectionLostError("Connection lost! Run Client.initializeStreaming() again!"),ScanFailedError:new K.ScanFailedError("Scan failed! Please try again!"),VideoError:new K.VideoError("Video error! Please check your video source! FPS could be very low!"),InvalidCredentialsError:new K.InvalidCredentialsError("Invalid credentials! Please provide correct username and password or license key!"),LicenseInactiveError:new K.LicenseInactiveError("License inactive! Please enter a valid license key!"),RGBError:new K.RGBError("RGB error! Please check your video source! FPS could be very low!"),FaceLandmarkerNotInitializedError:new K.FaceLandmarkerNotInitializedError("Face landmarker not initialized!"),EnvIncompatibleError:new K.EnvIncompatibleError("Environment not found! Please check your environment variables!"),UnhandledError:new K.UnhandledError("Unhandled error! Please contact support! If you are on production, retry scan!"),InsufficientDataError:new K.InsufficientDataError("Insufficient data received for calculations. Please try again with better lighting and good visibility of the face.")};function k_(){try{const t=typeof globalThis<"u"?globalThis:{},e=t.NERVOSCAN_DEBUG??t.__NERVOSCAN_DEBUG__;if(typeof e=="string"){const s=e.trim().toLowerCase();if(s==="1"||s==="true"||s==="yes"||s==="on")return!0;if(s==="0"||s==="false"||s==="no"||s==="off")return!1}else{if(typeof e=="number")return e===1;if(typeof e=="boolean")return e}const n=t.VITE_IS_DEV;if(typeof n=="string"){const s=n.trim().toLowerCase();if(s==="1"||s==="true"||s==="yes"||s==="on")return!0;if(s==="0"||s==="false"||s==="no"||s==="off")return!1}else{if(typeof n=="number")return n===1;if(typeof n=="boolean")return n}try{const s=typeof localStorage<"u"?localStorage:void 0,r=s==null?void 0:s.getItem("NERVOSCAN_DEBUG");if(typeof r=="string"){const i=r.trim().toLowerCase();if(i==="1"||i==="true"||i==="yes"||i==="on")return!0;if(i==="0"||i==="false"||i==="no"||i==="off")return!1}}catch{}}catch{}try{const t={url:typeof document>"u"?require("url").pathToFileURL(__filename).href:Qn&&Qn.tagName.toUpperCase()==="SCRIPT"&&Qn.src||new URL("nervoscan-js-sdk.cjs",document.baseURI).href},e=(t==null?void 0:t.env)??{};if(typeof e.VITE_IS_DEV=="string"){const n=e.VITE_IS_DEV.trim().toLowerCase();if(n==="1"||n==="true"||n==="yes"||n==="on")return!0;if(n==="0"||n==="false"||n==="no"||n==="off")return!1}if(typeof e.VITE_IS_DEV=="number")return e.VITE_IS_DEV===1;if(typeof e.PROD=="boolean")return e.PROD===!1;if(typeof e.DEV=="boolean")return e.DEV===!0}catch{}try{const e=typeof process<"u"&&process.env?process.env.NODE_ENV:void 0;return typeof e=="string"?e!=="production":!1}catch{return!1}}const Ur=k_(),Do=()=>{},T={log:Ur?(...t)=>console.log(...t):Do,info:Ur?(...t)=>console.info(...t):Do,debug:Ur?(...t)=>console.debug(...t):Do,warn:(...t)=>console.warn(...t),error:(...t)=>console.error(...t),isDev:Ur},Ne=class Ne{constructor(){}static getInstance(){return Ne.instance||(Ne.instance=new Ne),Ne.instance}static throwKnownError(e){throw e}static throwUnknownError(e){throw v.UnhandledError}static handleErrorResponse(e){var n,s,r,i,o,a,c,l,h,u,d,p,f,g,E,R,y,S,D,C,_,I,P;((r=(s=(n=e.response)==null?void 0:n.data)==null?void 0:s.error)==null?void 0:r.code)==="INVALID_USERNAME"?Ne.throwKnownError(v.InvalidUsernameError):((a=(o=(i=e.response)==null?void 0:i.data)==null?void 0:o.error)==null?void 0:a.code)==="INVALID_PASSWORD"?Ne.throwKnownError(v.InvalidPasswordError):((h=(l=(c=e.response)==null?void 0:c.data)==null?void 0:l.error)==null?void 0:h.code)==="NO_SCANS_AVAILABLE"||((d=(u=e.response)==null?void 0:u.data)==null?void 0:d.message)==="No packages available!"||((f=(p=e.response)==null?void 0:p.data)==null?void 0:f.message)==="No scans available!"?Ne.throwKnownError(v.NoScansAvailableError):((g=e.error)==null?void 0:g.code)==="INVALID_CONTENT_TYPE"?Ne.throwKnownError(v.InvalidContentTypeError):((y=(R=(E=e.response)==null?void 0:E.data)==null?void 0:R.error)==null?void 0:y.code)==="JOB_NOT_REGISTERED"?Ne.throwKnownError(v.JobNotRegisteredError):((C=(D=(S=e.response)==null?void 0:S.data)==null?void 0:D.error)==null?void 0:C.code)==="LICENSE_KEY_INVALID"?Ne.throwKnownError(v.InvalidCredentialsError):((P=(I=(_=e.response)==null?void 0:_.data)==null?void 0:I.error)==null?void 0:P.code)==="LICENSE_INACTIVE"?Ne.throwKnownError(v.LicenseInactiveError):(T.error("Unhandled error encountered in handleErrorResponse:",e),Ne.throwUnknownError(e))}static handleBackendError(e,n){var o,a,c,l,h;T.debug("[ERROR] Handling backend error:",e);let s;const r=typeof(e==null?void 0:e.message)=="string"?e.message:"";if(e instanceof j||r.includes("Invalid access token")||r.includes("Client is not initialized"))s=e instanceof j?e:r.includes("Invalid access token")?v.InvalidAccessTokenError:v.UnhandledError;else if((a=(o=e.response)==null?void 0:o.data)!=null&&a.error){const u=e.response.data.error;T.debug("[ERROR] Backend error code:",u.code),T.debug("[ERROR] Backend error message:",u.message),s=this.mapBackendErrorCode(u.code,u.message)}else if(((l=(c=e.response)==null?void 0:c.data)==null?void 0:l.success)===!1){T.debug("[ERROR] Backend returned success: false");const u=e.response.data.message||"Unknown error occurred";s=new Error(u)}else(h=e.response)!=null&&h.status?(T.debug("[ERROR] HTTP status error:",e.response.status),s=this.mapHttpStatusError(e.response.status)):e.code==="ERR_NETWORK"?(T.debug("[ERROR] Network error"),s=v.ConnectionLostError):(e.response||T.debug("[ERROR] Non-HTTP error without response"),s=v.UnhandledError);n?(T.debug("[ERROR] Calling onError callback with mapped error"),n(s)):Ne.throwKnownError(s)}static mapBackendErrorCode(e,n){switch(e){case"LOW_FPS_ERROR":return v.LowFPSError;case"FPS_CALCULATION_ERROR":return v.FPSCalculationError;case"FACE_NOT_CENTERED_ERROR":return v.FaceNotCenteredError;case"FACE_TOO_FAR_ERROR":return v.FaceTooFarError;case"FACE_TOO_CLOSE_ERROR":return v.FaceTooCloseError;case"FACE_LOOKING_LEFT_ERROR":return v.FaceLookingLeftError;case"FACE_LOOKING_RIGHT_ERROR":return v.FaceLookingRightError;case"SKIN_EXTRACTION_ERROR":return v.SkinExtractionError;case"LOW_FRAME_COUNT_ERROR":return v.LowFrameCountError;case"VIDEO_ERROR":return v.VideoError;case"INVALID_USERNAME":return v.InvalidUsernameError;case"INVALID_PASSWORD":return v.InvalidPasswordError;case"NO_SCANS_AVAILABLE":return v.NoScansAvailableError;case"INVALID_CONTENT_TYPE":return v.InvalidContentTypeError;case"JOB_NOT_REGISTERED":return v.JobNotRegisteredError;case"LICENSE_KEY_INVALID":return v.InvalidCredentialsError;case"LICENSE_INACTIVE":return v.LicenseInactiveError;case"INVALID_API_KEY":return v.InvalidAccessTokenError;case"PACKAGE_LIMIT_REACHED":return v.NoScansAvailableError;case"TRIAL_ENDED":return v.LicenseInactiveError;case"ACCOUNT_ON_HOLD":return v.LicenseInactiveError;case"DEVICE_NOT_REGISTERED":return v.InvalidCredentialsError;case"UNAUTHERIZED_ACTION":return v.InvalidCredentialsError;case"CHUNK_ERROR":return v.VideoError;case"JOBID_NOT_EXIST":return v.NoScanDataError;case"BAD_REQUEST":return v.VideoTypeError;case"MISSING_FIELDS":return v.NotInitializedError;case"MISSING_INPUT":return v.EmptyVideoError;case"MALFORMED_JSON":return v.VideoTypeError;case"INVALID_EMAIL":return v.InvalidUsernameError;case"USER_NAME_EXIST":return v.InvalidUsernameError;case"EMAIL_EXIST":return v.InvalidUsernameError;case"UNVERFIED_EMAIL":return v.InvalidCredentialsError;case"DATABASE_ERROR":return v.UnhandledError;case"FILETYPE_NOT_ALLOWED":return v.VideoTypeError;case"FILE_PART_NOT_FOUND":return v.EmptyVideoError;case"UNHANDLED_ERROR":default:return v.UnhandledError}}static mapHttpStatusError(e){switch(e){case 400:return v.VideoTypeError;case 401:return v.InvalidCredentialsError;case 403:return v.InvalidCredentialsError;case 404:return v.NoScanDataError;case 429:return v.ConnectionLostError;case 500:return v.UnhandledError;default:return v.ConnectionLostError}}static handleScanError(e){return e.code==="LOW_FPS_ERROR"?v.LowFPSError:e.code==="FPS_CALCULATION_ERROR"?v.FPSCalculationError:e.code==="FACE_NOT_CENTERED_ERROR"?v.FaceNotCenteredError:e.code==="FACE_TOO_FAR_ERROR"?v.FaceTooFarError:e.code==="FACE_TOO_CLOSE_ERROR"?v.FaceTooCloseError:e.code==="FACE_LOOKING_LEFT_ERROR"?v.FaceLookingLeftError:e.code==="FACE_LOOKING_RIGHT_ERROR"?v.FaceLookingRightError:e.code==="SKIN_EXTRACTION_ERROR"?v.SkinExtractionError:e.code==="LOW_FRAME_COUNT_ERROR"?v.LowFrameCountError:e.code==="VIDEO_ERROR"?v.VideoError:e.code==="UNHANDLED_ERROR"?v.UnhandledError:v.ScanFailedError}};w(Ne,"instance");let W=Ne;const I_=()=>{};/**
1
+ "use strict";var A_=Object.defineProperty;var R_=(t,e,n)=>e in t?A_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var w=(t,e,n)=>R_(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Qn=typeof document<"u"?document.currentScript:null;class j extends Error{constructor(e){super(e)}}class Ld extends j{constructor(e){super(e)}}class Dd extends j{constructor(e){super(e)}}class Pd extends j{constructor(e){super(e)}}class Fd extends j{constructor(e){super(e)}}class Md extends j{constructor(e){super(e)}}class Bd extends j{constructor(e){super(e)}}class Ud extends j{constructor(e){super(e)}}class Vd extends j{constructor(e){super(e)}}class Hd extends j{constructor(e){super(e)}}class Wd extends j{constructor(e){super(e)}}class Gd extends j{constructor(e){super(e)}}class $d extends j{constructor(e){super(e)}}class jd extends j{constructor(e){super(e)}}class qd extends j{constructor(e){super(e)}}class zd extends j{constructor(e){super(e)}}class Kd extends j{constructor(e){super(e)}}class Yd extends j{constructor(e){super(e)}}class Xd extends j{constructor(e){super(e)}}class Jd extends j{constructor(n){super(n.message);w(this,"errorCode");this.errorCode=n.code}}class Qd extends j{constructor(e){super(e)}}class Zd extends j{constructor(e){super(e)}}class ef extends j{constructor(e){super(e)}}class tf extends j{constructor(e){super(e)}}class nf extends j{constructor(e){super(e)}}class sf extends j{constructor(e){super(e)}}class rf extends j{constructor(e){super(e)}}class of extends j{constructor(e){super(e)}}class af extends j{constructor(e){super(e)}}class cf extends j{constructor(e){super(e)}}class lf extends j{constructor(e){super(e)}}class hf extends j{constructor(e){super(e)}}class uf extends j{constructor(e){super(e)}}class df extends j{constructor(e){super(e)}}const K={NotInitializedError:Ld,EmptyVideoError:Dd,VideoTypeError:Pd,InvalidUsernameError:Fd,InvalidPasswordError:Md,NoScansAvailableError:Bd,InvalidAccessTokenError:Ud,NoScanDataError:Vd,InvalidServerTypeError:Hd,NotImplementedError:Wd,LowFPSError:Gd,FPSCalculationError:$d,FaceNotCenteredError:jd,FaceTooFarError:qd,FaceTooCloseError:zd,FaceLookingLeftError:Kd,FaceLookingRightError:Yd,ErrorCallbackNotSetError:Xd,UnhandledScanError:Jd,SkinExtractionError:Qd,InvalidContentTypeError:Zd,JobNotRegisteredError:ef,LowFrameCountError:nf,ConnectionLostError:sf,ScanFailedError:rf,VideoError:of,InvalidCredentialsError:af,LicenseInactiveError:cf,RGBError:lf,FaceLandmarkerNotInitializedError:hf,EnvIncompatibleError:uf,UnhandledError:tf,InsufficientDataError:df},v={NotInitializedError:new K.NotInitializedError("Nervoscan Client not initialized!"),EmptyVideoError:new K.EmptyVideoError("Video is empty!"),VideoTypeError:new K.VideoTypeError("Video is not a Blob!"),InvalidUsernameError:new K.InvalidUsernameError("Invalid username!"),InvalidPasswordError:new K.InvalidPasswordError("Invalid password!"),NoScansAvailableError:new K.NoScansAvailableError("No scans available, Please purchase a plan!"),InvalidAccessTokenError:new K.InvalidAccessTokenError("Invalid access token!"),NoScanDataError:new K.NoScanDataError("No scan data found!"),InvalidServerTypeError:new K.InvalidServerTypeError("Invalid server type!"),NotImplementedError:new K.NotImplementedError("Not implemented!"),LowFPSError:new K.LowFPSError("Low FPS!"),FPSCalculationError:new K.FPSCalculationError("Error calculating FPS!"),FaceNotCenteredError:new K.FaceNotCenteredError("Face not centered!"),FaceTooFarError:new K.FaceTooFarError("Face too far!"),FaceTooCloseError:new K.FaceTooCloseError("Face too close!"),FaceLookingLeftError:new K.FaceLookingLeftError("Face looking left!"),FaceLookingRightError:new K.FaceLookingRightError("Face looking right!"),ErrorCallbackNotSetError:new K.ErrorCallbackNotSetError("Error callback not set!"),SkinExtractionError:new K.SkinExtractionError("Skin extraction error! Please use a better lighting!"),InvalidContentTypeError:new K.InvalidContentTypeError("Invalid content type!"),JobNotRegisteredError:new K.JobNotRegisteredError("Job not registered! Please await initializeStreaming method!"),LowFrameCountError:new K.LowFrameCountError("Low frame count! Don't stop streaming prematurely!"),ConnectionLostError:new K.ConnectionLostError("Connection lost! Run Client.initializeStreaming() again!"),ScanFailedError:new K.ScanFailedError("Scan failed! Please try again!"),VideoError:new K.VideoError("Video error! Please check your video source! FPS could be very low!"),InvalidCredentialsError:new K.InvalidCredentialsError("Invalid credentials! Please provide correct username and password or license key!"),LicenseInactiveError:new K.LicenseInactiveError("License inactive! Please enter a valid license key!"),RGBError:new K.RGBError("RGB error! Please check your video source! FPS could be very low!"),FaceLandmarkerNotInitializedError:new K.FaceLandmarkerNotInitializedError("Face landmarker not initialized!"),EnvIncompatibleError:new K.EnvIncompatibleError("Environment not found! Please check your environment variables!"),UnhandledError:new K.UnhandledError("Unhandled error! Please contact support! If you are on production, retry scan!"),InsufficientDataError:new K.InsufficientDataError("Insufficient data received for calculations. Please try again with better lighting and good visibility of the face.")};function k_(){try{const t=typeof globalThis<"u"?globalThis:{},e=t.NERVOSCAN_DEBUG??t.__NERVOSCAN_DEBUG__;if(typeof e=="string"){const s=e.trim().toLowerCase();if(s==="1"||s==="true"||s==="yes"||s==="on")return!0;if(s==="0"||s==="false"||s==="no"||s==="off")return!1}else{if(typeof e=="number")return e===1;if(typeof e=="boolean")return e}const n=t.VITE_IS_DEV;if(typeof n=="string"){const s=n.trim().toLowerCase();if(s==="1"||s==="true"||s==="yes"||s==="on")return!0;if(s==="0"||s==="false"||s==="no"||s==="off")return!1}else{if(typeof n=="number")return n===1;if(typeof n=="boolean")return n}try{const s=typeof localStorage<"u"?localStorage:void 0,r=s==null?void 0:s.getItem("NERVOSCAN_DEBUG");if(typeof r=="string"){const i=r.trim().toLowerCase();if(i==="1"||i==="true"||i==="yes"||i==="on")return!0;if(i==="0"||i==="false"||i==="no"||i==="off")return!1}}catch{}}catch{}try{const t={url:typeof document>"u"?require("url").pathToFileURL(__filename).href:Qn&&Qn.tagName.toUpperCase()==="SCRIPT"&&Qn.src||new URL("nervoscan-js-sdk.cjs",document.baseURI).href},e=(t==null?void 0:t.env)??{};if(typeof e.VITE_IS_DEV=="string"){const n=e.VITE_IS_DEV.trim().toLowerCase();if(n==="1"||n==="true"||n==="yes"||n==="on")return!0;if(n==="0"||n==="false"||n==="no"||n==="off")return!1}if(typeof e.VITE_IS_DEV=="number")return e.VITE_IS_DEV===1;if(typeof e.PROD=="boolean")return e.PROD===!1;if(typeof e.DEV=="boolean")return e.DEV===!0}catch{}try{const e=typeof process<"u"&&process.env?process.env.NODE_ENV:void 0;return typeof e=="string"?e!=="production":!1}catch{return!1}}const Ur=k_(),Do=()=>{},T={log:Ur?(...t)=>console.log(...t):Do,info:Ur?(...t)=>console.info(...t):Do,debug:Ur?(...t)=>console.debug(...t):Do,warn:(...t)=>console.warn(...t),error:(...t)=>console.error(...t),isDev:Ur},Ne=class Ne{constructor(){}static getInstance(){return Ne.instance||(Ne.instance=new Ne),Ne.instance}static throwKnownError(e){throw e}static throwUnknownError(e){throw v.UnhandledError}static handleErrorResponse(e){var n,s,r,i,o,a,c,l,h,u,d,p,f,g,E,R,y,S,D,C,_,I,P;((r=(s=(n=e.response)==null?void 0:n.data)==null?void 0:s.error)==null?void 0:r.code)==="INVALID_USERNAME"?Ne.throwKnownError(v.InvalidUsernameError):((a=(o=(i=e.response)==null?void 0:i.data)==null?void 0:o.error)==null?void 0:a.code)==="INVALID_PASSWORD"?Ne.throwKnownError(v.InvalidPasswordError):((h=(l=(c=e.response)==null?void 0:c.data)==null?void 0:l.error)==null?void 0:h.code)==="NO_SCANS_AVAILABLE"||((d=(u=e.response)==null?void 0:u.data)==null?void 0:d.message)==="No packages available!"||((f=(p=e.response)==null?void 0:p.data)==null?void 0:f.message)==="No scans available!"?Ne.throwKnownError(v.NoScansAvailableError):((g=e.error)==null?void 0:g.code)==="INVALID_CONTENT_TYPE"?Ne.throwKnownError(v.InvalidContentTypeError):((y=(R=(E=e.response)==null?void 0:E.data)==null?void 0:R.error)==null?void 0:y.code)==="JOB_NOT_REGISTERED"?Ne.throwKnownError(v.JobNotRegisteredError):((C=(D=(S=e.response)==null?void 0:S.data)==null?void 0:D.error)==null?void 0:C.code)==="LICENSE_KEY_INVALID"?Ne.throwKnownError(v.InvalidCredentialsError):((P=(I=(_=e.response)==null?void 0:_.data)==null?void 0:I.error)==null?void 0:P.code)==="LICENSE_INACTIVE"?Ne.throwKnownError(v.LicenseInactiveError):(T.error("Unhandled error encountered in handleErrorResponse:",e),Ne.throwUnknownError(e))}static handleBackendError(e,n){var o,a,c,l,h;T.debug("[ERROR] Handling backend error:",e);let s;const r=typeof(e==null?void 0:e.message)=="string"?e.message:"";if(e instanceof j||r.includes("Invalid access token")||r.includes("Client is not initialized"))s=e instanceof j?e:r.includes("Invalid access token")?v.InvalidAccessTokenError:v.UnhandledError;else if((a=(o=e.response)==null?void 0:o.data)!=null&&a.error){const u=e.response.data.error;T.debug("[ERROR] Backend error code:",u.code),T.debug("[ERROR] Backend error message:",u.message),s=this.mapBackendErrorCode(u.code,u.message)}else if(((l=(c=e.response)==null?void 0:c.data)==null?void 0:l.success)===!1){T.debug("[ERROR] Backend returned success: false");const u=e.response.data.message||"Unknown error occurred";s=new Error(u)}else(h=e.response)!=null&&h.status?(T.debug("[ERROR] HTTP status error:",e.response.status),s=this.mapHttpStatusError(e.response.status)):e.code==="ERR_NETWORK"?(T.debug("[ERROR] Network error"),s=v.ConnectionLostError):(e.response||T.debug("[ERROR] Non-HTTP error without response"),s=v.UnhandledError);n?(T.debug("[ERROR] Calling onError callback with mapped error"),n(s)):Ne.throwKnownError(s)}static mapBackendErrorCode(e,n){switch(e){case"LOW_FPS_ERROR":return v.LowFPSError;case"FPS_CALCULATION_ERROR":return v.FPSCalculationError;case"FACE_NOT_CENTERED_ERROR":return v.FaceNotCenteredError;case"FACE_TOO_FAR_ERROR":return v.FaceTooFarError;case"FACE_TOO_CLOSE_ERROR":return v.FaceTooCloseError;case"FACE_LOOKING_LEFT_ERROR":return v.FaceLookingLeftError;case"FACE_LOOKING_RIGHT_ERROR":return v.FaceLookingRightError;case"SKIN_EXTRACTION_ERROR":return v.SkinExtractionError;case"LOW_FRAME_COUNT_ERROR":return v.LowFrameCountError;case"VIDEO_ERROR":return v.VideoError;case"INVALID_USERNAME":return v.InvalidUsernameError;case"INVALID_PASSWORD":return v.InvalidPasswordError;case"NO_SCANS_AVAILABLE":return v.NoScansAvailableError;case"INVALID_CONTENT_TYPE":return v.InvalidContentTypeError;case"JOB_NOT_REGISTERED":return v.JobNotRegisteredError;case"LICENSE_KEY_INVALID":return v.InvalidCredentialsError;case"LICENSE_INACTIVE":return v.LicenseInactiveError;case"INVALID_API_KEY":return v.InvalidAccessTokenError;case"PACKAGE_LIMIT_REACHED":return v.NoScansAvailableError;case"TRIAL_ENDED":return v.LicenseInactiveError;case"ACCOUNT_ON_HOLD":return v.LicenseInactiveError;case"DEVICE_NOT_REGISTERED":return v.InvalidCredentialsError;case"UNAUTHERIZED_ACTION":return v.InvalidCredentialsError;case"CHUNK_ERROR":return v.VideoError;case"JOBID_NOT_EXIST":return v.NoScanDataError;case"BAD_REQUEST":return v.VideoTypeError;case"MISSING_FIELDS":return v.NotInitializedError;case"MISSING_INPUT":return v.EmptyVideoError;case"MALFORMED_JSON":return v.VideoTypeError;case"INVALID_EMAIL":return v.InvalidUsernameError;case"USER_NAME_EXIST":return v.InvalidUsernameError;case"EMAIL_EXIST":return v.InvalidUsernameError;case"UNVERFIED_EMAIL":return v.InvalidCredentialsError;case"DATABASE_ERROR":return v.UnhandledError;case"FILETYPE_NOT_ALLOWED":return v.VideoTypeError;case"FILE_PART_NOT_FOUND":return v.EmptyVideoError;case"UNHANDLED_ERROR":default:return v.UnhandledError}}static mapHttpStatusError(e){switch(e){case 400:return v.VideoTypeError;case 401:return v.InvalidCredentialsError;case 403:return v.InvalidCredentialsError;case 404:return v.NoScanDataError;case 429:return v.ConnectionLostError;case 500:return v.UnhandledError;default:return v.ConnectionLostError}}static handleScanError(e){return e.code==="LOW_FPS_ERROR"?v.LowFPSError:e.code==="FPS_CALCULATION_ERROR"?v.FPSCalculationError:e.code==="FACE_NOT_CENTERED_ERROR"?v.FaceNotCenteredError:e.code==="FACE_TOO_FAR_ERROR"?v.FaceTooFarError:e.code==="FACE_TOO_CLOSE_ERROR"?v.FaceTooCloseError:e.code==="FACE_LOOKING_LEFT_ERROR"?v.FaceLookingLeftError:e.code==="FACE_LOOKING_RIGHT_ERROR"?v.FaceLookingRightError:e.code==="SKIN_EXTRACTION_ERROR"?v.SkinExtractionError:e.code==="LOW_FRAME_COUNT_ERROR"?v.LowFrameCountError:e.code==="VIDEO_ERROR"?v.VideoError:e.code==="UNHANDLED_ERROR"?v.UnhandledError:v.ScanFailedError}};w(Ne,"instance");let G=Ne;const I_=()=>{};/**
2
2
  * @license
3
3
  * Copyright 2017 Google LLC
4
4
  *
@@ -133,7 +133,7 @@
133
133
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134
134
  * See the License for the specific language governing permissions and
135
135
  * limitations under the License.
136
- */function H_(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Ef(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(H_())}function G_(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function W_(){return ff.NODE_ADMIN===!0}function $_(){try{return typeof indexedDB=="object"}catch{return!1}}function j_(){return new Promise((t,e)=>{try{let n=!0;const s="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(s);r.onsuccess=()=>{r.result.close(),n||self.indexedDB.deleteDatabase(s),t(!0)},r.onupgradeneeded=()=>{n=!1},r.onerror=()=>{var i;e(((i=r.error)===null||i===void 0?void 0:i.message)||"")}}catch(n){e(n)}})}/**
136
+ */function H_(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Ef(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(H_())}function W_(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function G_(){return ff.NODE_ADMIN===!0}function $_(){try{return typeof indexedDB=="object"}catch{return!1}}function j_(){return new Promise((t,e)=>{try{let n=!0;const s="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(s);r.onsuccess=()=>{r.result.close(),n||self.indexedDB.deleteDatabase(s),t(!0)},r.onupgradeneeded=()=>{n=!1},r.onerror=()=>{var i;e(((i=r.error)===null||i===void 0?void 0:i.message)||"")}}catch(n){e(n)}})}/**
137
137
  * @license
138
138
  * Copyright 2017 Google LLC
139
139
  *
@@ -238,7 +238,7 @@
238
238
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
239
239
  * See the License for the specific language governing permissions and
240
240
  * limitations under the License.
241
- */const Z_=function(t){const e=[];let n=0;for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);if(r>=55296&&r<=56319){const i=r-55296;s++,b(s<t.length,"Surrogate pair missing trail surrogate.");const o=t.charCodeAt(s)-56320;r=65536+(i<<10)+o}r<128?e[n++]=r:r<2048?(e[n++]=r>>6|192,e[n++]=r&63|128):r<65536?(e[n++]=r>>12|224,e[n++]=r>>6&63|128,e[n++]=r&63|128):(e[n++]=r>>18|240,e[n++]=r>>12&63|128,e[n++]=r>>6&63|128,e[n++]=r&63|128)}return e},Wi=function(t){let e=0;for(let n=0;n<t.length;n++){const s=t.charCodeAt(n);s<128?e++:s<2048?e+=2:s>=55296&&s<=56319?(e+=4,n++):e+=3}return e};/**
241
+ */const Z_=function(t){const e=[];let n=0;for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);if(r>=55296&&r<=56319){const i=r-55296;s++,b(s<t.length,"Surrogate pair missing trail surrogate.");const o=t.charCodeAt(s)-56320;r=65536+(i<<10)+o}r<128?e[n++]=r:r<2048?(e[n++]=r>>6|192,e[n++]=r&63|128):r<65536?(e[n++]=r>>12|224,e[n++]=r>>6&63|128,e[n++]=r&63|128):(e[n++]=r>>18|240,e[n++]=r>>12&63|128,e[n++]=r>>6&63|128,e[n++]=r&63|128)}return e},Gi=function(t){let e=0;for(let n=0;n<t.length;n++){const s=t.charCodeAt(n);s<128?e++:s<2048?e+=2:s>=55296&&s<=56319?(e+=4,n++):e+=3}return e};/**
242
242
  * @license
243
243
  * Copyright 2021 Google LLC
244
244
  *
@@ -343,7 +343,7 @@
343
343
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
344
344
  * See the License for the specific language governing permissions and
345
345
  * limitations under the License.
346
- */const zt=new Tf("@firebase/app"),w1="@firebase/app-compat",b1="@firebase/analytics-compat",T1="@firebase/analytics",C1="@firebase/app-check-compat",S1="@firebase/app-check",A1="@firebase/auth",R1="@firebase/auth-compat",k1="@firebase/database",I1="@firebase/data-connect",N1="@firebase/database-compat",x1="@firebase/functions",O1="@firebase/functions-compat",L1="@firebase/installations",D1="@firebase/installations-compat",P1="@firebase/messaging",F1="@firebase/messaging-compat",M1="@firebase/performance",B1="@firebase/performance-compat",U1="@firebase/remote-config",V1="@firebase/remote-config-compat",H1="@firebase/storage",G1="@firebase/storage-compat",W1="@firebase/firestore",$1="@firebase/vertexai",j1="@firebase/firestore-compat",q1="firebase",z1="11.6.1";/**
346
+ */const zt=new Tf("@firebase/app"),w1="@firebase/app-compat",b1="@firebase/analytics-compat",T1="@firebase/analytics",C1="@firebase/app-check-compat",S1="@firebase/app-check",A1="@firebase/auth",R1="@firebase/auth-compat",k1="@firebase/database",I1="@firebase/data-connect",N1="@firebase/database-compat",x1="@firebase/functions",O1="@firebase/functions-compat",L1="@firebase/installations",D1="@firebase/installations-compat",P1="@firebase/messaging",F1="@firebase/messaging-compat",M1="@firebase/performance",B1="@firebase/performance-compat",U1="@firebase/remote-config",V1="@firebase/remote-config-compat",H1="@firebase/storage",W1="@firebase/storage-compat",G1="@firebase/firestore",$1="@firebase/vertexai",j1="@firebase/firestore-compat",q1="firebase",z1="11.6.1";/**
347
347
  * @license
348
348
  * Copyright 2019 Google LLC
349
349
  *
@@ -358,7 +358,7 @@
358
358
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
359
359
  * See the License for the specific language governing permissions and
360
360
  * limitations under the License.
361
- */const Ea="[DEFAULT]",K1={[ya]:"fire-core",[w1]:"fire-core-compat",[T1]:"fire-analytics",[b1]:"fire-analytics-compat",[S1]:"fire-app-check",[C1]:"fire-app-check-compat",[A1]:"fire-auth",[R1]:"fire-auth-compat",[k1]:"fire-rtdb",[I1]:"fire-data-connect",[N1]:"fire-rtdb-compat",[x1]:"fire-fn",[O1]:"fire-fn-compat",[L1]:"fire-iid",[D1]:"fire-iid-compat",[P1]:"fire-fcm",[F1]:"fire-fcm-compat",[M1]:"fire-perf",[B1]:"fire-perf-compat",[U1]:"fire-rc",[V1]:"fire-rc-compat",[H1]:"fire-gcs",[G1]:"fire-gcs-compat",[W1]:"fire-fst",[j1]:"fire-fst-compat",[$1]:"fire-vertex","fire-js":"fire-js",[q1]:"fire-js-all"};/**
361
+ */const Ea="[DEFAULT]",K1={[ya]:"fire-core",[w1]:"fire-core-compat",[T1]:"fire-analytics",[b1]:"fire-analytics-compat",[S1]:"fire-app-check",[C1]:"fire-app-check-compat",[A1]:"fire-auth",[R1]:"fire-auth-compat",[k1]:"fire-rtdb",[I1]:"fire-data-connect",[N1]:"fire-rtdb-compat",[x1]:"fire-fn",[O1]:"fire-fn-compat",[L1]:"fire-iid",[D1]:"fire-iid-compat",[P1]:"fire-fcm",[F1]:"fire-fcm-compat",[M1]:"fire-perf",[B1]:"fire-perf-compat",[U1]:"fire-rc",[V1]:"fire-rc-compat",[H1]:"fire-gcs",[W1]:"fire-gcs-compat",[G1]:"fire-fst",[j1]:"fire-fst-compat",[$1]:"fire-vertex","fire-js":"fire-js",[q1]:"fire-js-all"};/**
362
362
  * @license
363
363
  * Copyright 2019 Google LLC
364
364
  *
@@ -598,7 +598,7 @@
598
598
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
599
599
  * See the License for the specific language governing permissions and
600
600
  * limitations under the License.
601
- */const pc="5",Ff="v",Mf="s",Bf="r",Uf="f",Vf=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,Hf="ls",Gf="p",ba="ac",Wf="websocket",$f="long_polling";/**
601
+ */const pc="5",Ff="v",Mf="s",Bf="r",Uf="f",Vf=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,Hf="ls",Wf="p",ba="ac",Gf="websocket",$f="long_polling";/**
602
602
  * @license
603
603
  * Copyright 2017 Google LLC
604
604
  *
@@ -613,7 +613,7 @@
613
613
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
614
614
  * See the License for the specific language governing permissions and
615
615
  * limitations under the License.
616
- */class jf{constructor(e,n,s,r,i=!1,o="",a=!1,c=!1,l=null){this.secure=n,this.namespace=s,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=c,this.emulatorOptions=l,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=An.get("host:"+e)||this._host}isCacheableHost(){return this.internalHost.substr(0,2)==="s-"}isCustomHost(){return this._domain!=="firebaseio.com"&&this._domain!=="firebaseio-demo.com"}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&An.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){const e=this.secure?"https://":"http://",n=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${n}`}}function O2(t){return t.host!==t.internalHost||t.isCustomHost()||t.includeNamespaceInQueryParams}function qf(t,e,n){b(typeof e=="string","typeof type must == string"),b(typeof n=="object","typeof params must == object");let s;if(e===Wf)s=(t.secure?"wss://":"ws://")+t.internalHost+"/.ws?";else if(e===$f)s=(t.secure?"https://":"http://")+t.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+e);O2(t)&&(n.ns=t.namespace);const r=[];return Ke(n,(i,o)=>{r.push(i+"="+o)}),s+r.join("&")}/**
616
+ */class jf{constructor(e,n,s,r,i=!1,o="",a=!1,c=!1,l=null){this.secure=n,this.namespace=s,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=c,this.emulatorOptions=l,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=An.get("host:"+e)||this._host}isCacheableHost(){return this.internalHost.substr(0,2)==="s-"}isCustomHost(){return this._domain!=="firebaseio.com"&&this._domain!=="firebaseio-demo.com"}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&An.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){const e=this.secure?"https://":"http://",n=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${n}`}}function O2(t){return t.host!==t.internalHost||t.isCustomHost()||t.includeNamespaceInQueryParams}function qf(t,e,n){b(typeof e=="string","typeof type must == string"),b(typeof n=="object","typeof params must == object");let s;if(e===Gf)s=(t.secure?"wss://":"ws://")+t.internalHost+"/.ws?";else if(e===$f)s=(t.secure?"https://":"http://")+t.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+e);O2(t)&&(n.ns=t.namespace);const r=[];return Ke(n,(i,o)=>{r.push(i+"="+o)}),s+r.join("&")}/**
617
617
  * @license
618
618
  * Copyright 2017 Google LLC
619
619
  *
@@ -673,7 +673,7 @@
673
673
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
674
674
  * See the License for the specific language governing permissions and
675
675
  * limitations under the License.
676
- */const gh="start",F2="close",M2="pLPCommand",B2="pRTLPCB",zf="id",Kf="pw",Yf="ser",U2="cb",V2="seg",H2="ts",G2="d",W2="dframe",Xf=1870,Jf=30,$2=Xf-Jf,j2=25e3,q2=3e4;class Kn{constructor(e,n,s,r,i,o,a){this.connId=e,this.repoInfo=n,this.applicationId=s,this.appCheckToken=r,this.authToken=i,this.transportSessionId=o,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Sr(e),this.stats_=mc(n),this.urlFn=c=>(this.appCheckToken&&(c[ba]=this.appCheckToken),qf(n,$f,c))}open(e,n){this.curSegmentNum=0,this.onDisconnect_=n,this.myPacketOrderer=new P2(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(q2)),w2(()=>{if(this.isClosed_)return;this.scriptTagHolder=new gc((...i)=>{const[o,a,c,l,h]=i;if(this.incrementIncomingBytes_(i),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,o===gh)this.id=a,this.password=c;else if(o===F2)a?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(a,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+o)},(...i)=>{const[o,a]=i;this.incrementIncomingBytes_(i),this.myPacketOrderer.handleResponse(o,a)},()=>{this.onClosed_()},this.urlFn);const s={};s[gh]="t",s[Yf]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(s[U2]=this.scriptTagHolder.uniqueCallbackIdentifier),s[Ff]=pc,this.transportSessionId&&(s[Mf]=this.transportSessionId),this.lastSessionId&&(s[Hf]=this.lastSessionId),this.applicationId&&(s[Gf]=this.applicationId),this.appCheckToken&&(s[ba]=this.appCheckToken),typeof location<"u"&&location.hostname&&Vf.test(location.hostname)&&(s[Bf]=Uf);const r=this.urlFn(s);this.log_("Connecting via long-poll to "+r),this.scriptTagHolder.addTag(r,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){Kn.forceAllow_=!0}static forceDisallow(){Kn.forceDisallow_=!0}static isAvailable(){return Kn.forceAllow_?!0:!Kn.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!T2()&&!C2()}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const n=Le(e);this.bytesSent+=n.length,this.stats_.incrementCounter("bytes_sent",n.length);const s=mf(n),r=Df(s,$2);for(let i=0;i<r.length;i++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,r.length,r[i]),this.curSegmentNum++}addDisconnectPingFrame(e,n){this.myDisconnFrame=document.createElement("iframe");const s={};s[W2]="t",s[zf]=e,s[Kf]=n,this.myDisconnFrame.src=this.urlFn(s),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const n=Le(e).length;this.bytesReceived+=n,this.stats_.incrementCounter("bytes_received",n)}}class gc{constructor(e,n,s,r){this.onDisconnect=s,this.urlFn=r,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=y2(),window[M2+this.uniqueCallbackIdentifier]=e,window[B2+this.uniqueCallbackIdentifier]=n,this.myIFrame=gc.createIFrame_();let i="";this.myIFrame.src&&this.myIFrame.src.substr(0,11)==="javascript:"&&(i='<script>document.domain="'+document.domain+'";<\/script>');const o="<html><body>"+i+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(o),this.myIFrame.doc.close()}catch(a){Fe("frame writing exception"),a.stack&&Fe(a.stack),Fe(a)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",document.body){document.body.appendChild(e);try{e.contentWindow.document||Fe("No IE domain setting required")}catch{const s=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+s+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{this.myIFrame!==null&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,n){for(this.myID=e,this.myPW=n,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e[zf]=this.myID,e[Kf]=this.myPW,e[Yf]=this.currentSerial;let n=this.urlFn(e),s="",r=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+Jf+s.length<=Xf;){const o=this.pendingSegs.shift();s=s+"&"+V2+r+"="+o.seg+"&"+H2+r+"="+o.ts+"&"+G2+r+"="+o.d,r++}return n=n+s,this.addLongPollTag_(n,this.currentSerial),!0}else return!1}enqueueSegment(e,n,s){this.pendingSegs.push({seg:e,ts:n,d:s}),this.alive&&this.newRequest_()}addLongPollTag_(e,n){this.outstandingRequests.add(n);const s=()=>{this.outstandingRequests.delete(n),this.newRequest_()},r=setTimeout(s,Math.floor(j2)),i=()=>{clearTimeout(r),s()};this.addTag(e,i)}addTag(e,n){setTimeout(()=>{try{if(!this.sendNewPolls)return;const s=this.myIFrame.doc.createElement("script");s.type="text/javascript",s.async=!0,s.src=e,s.onload=s.onreadystatechange=function(){const r=s.readyState;(!r||r==="loaded"||r==="complete")&&(s.onload=s.onreadystatechange=null,s.parentNode&&s.parentNode.removeChild(s),n())},s.onerror=()=>{Fe("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(s)}catch{}},Math.floor(1))}}/**
676
+ */const gh="start",F2="close",M2="pLPCommand",B2="pRTLPCB",zf="id",Kf="pw",Yf="ser",U2="cb",V2="seg",H2="ts",W2="d",G2="dframe",Xf=1870,Jf=30,$2=Xf-Jf,j2=25e3,q2=3e4;class Kn{constructor(e,n,s,r,i,o,a){this.connId=e,this.repoInfo=n,this.applicationId=s,this.appCheckToken=r,this.authToken=i,this.transportSessionId=o,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Sr(e),this.stats_=mc(n),this.urlFn=c=>(this.appCheckToken&&(c[ba]=this.appCheckToken),qf(n,$f,c))}open(e,n){this.curSegmentNum=0,this.onDisconnect_=n,this.myPacketOrderer=new P2(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(q2)),w2(()=>{if(this.isClosed_)return;this.scriptTagHolder=new gc((...i)=>{const[o,a,c,l,h]=i;if(this.incrementIncomingBytes_(i),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,o===gh)this.id=a,this.password=c;else if(o===F2)a?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(a,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+o)},(...i)=>{const[o,a]=i;this.incrementIncomingBytes_(i),this.myPacketOrderer.handleResponse(o,a)},()=>{this.onClosed_()},this.urlFn);const s={};s[gh]="t",s[Yf]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(s[U2]=this.scriptTagHolder.uniqueCallbackIdentifier),s[Ff]=pc,this.transportSessionId&&(s[Mf]=this.transportSessionId),this.lastSessionId&&(s[Hf]=this.lastSessionId),this.applicationId&&(s[Wf]=this.applicationId),this.appCheckToken&&(s[ba]=this.appCheckToken),typeof location<"u"&&location.hostname&&Vf.test(location.hostname)&&(s[Bf]=Uf);const r=this.urlFn(s);this.log_("Connecting via long-poll to "+r),this.scriptTagHolder.addTag(r,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){Kn.forceAllow_=!0}static forceDisallow(){Kn.forceDisallow_=!0}static isAvailable(){return Kn.forceAllow_?!0:!Kn.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!T2()&&!C2()}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const n=Le(e);this.bytesSent+=n.length,this.stats_.incrementCounter("bytes_sent",n.length);const s=mf(n),r=Df(s,$2);for(let i=0;i<r.length;i++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,r.length,r[i]),this.curSegmentNum++}addDisconnectPingFrame(e,n){this.myDisconnFrame=document.createElement("iframe");const s={};s[G2]="t",s[zf]=e,s[Kf]=n,this.myDisconnFrame.src=this.urlFn(s),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const n=Le(e).length;this.bytesReceived+=n,this.stats_.incrementCounter("bytes_received",n)}}class gc{constructor(e,n,s,r){this.onDisconnect=s,this.urlFn=r,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=y2(),window[M2+this.uniqueCallbackIdentifier]=e,window[B2+this.uniqueCallbackIdentifier]=n,this.myIFrame=gc.createIFrame_();let i="";this.myIFrame.src&&this.myIFrame.src.substr(0,11)==="javascript:"&&(i='<script>document.domain="'+document.domain+'";<\/script>');const o="<html><body>"+i+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(o),this.myIFrame.doc.close()}catch(a){Fe("frame writing exception"),a.stack&&Fe(a.stack),Fe(a)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",document.body){document.body.appendChild(e);try{e.contentWindow.document||Fe("No IE domain setting required")}catch{const s=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+s+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{this.myIFrame!==null&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,n){for(this.myID=e,this.myPW=n,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e[zf]=this.myID,e[Kf]=this.myPW,e[Yf]=this.currentSerial;let n=this.urlFn(e),s="",r=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+Jf+s.length<=Xf;){const o=this.pendingSegs.shift();s=s+"&"+V2+r+"="+o.seg+"&"+H2+r+"="+o.ts+"&"+W2+r+"="+o.d,r++}return n=n+s,this.addLongPollTag_(n,this.currentSerial),!0}else return!1}enqueueSegment(e,n,s){this.pendingSegs.push({seg:e,ts:n,d:s}),this.alive&&this.newRequest_()}addLongPollTag_(e,n){this.outstandingRequests.add(n);const s=()=>{this.outstandingRequests.delete(n),this.newRequest_()},r=setTimeout(s,Math.floor(j2)),i=()=>{clearTimeout(r),s()};this.addTag(e,i)}addTag(e,n){setTimeout(()=>{try{if(!this.sendNewPolls)return;const s=this.myIFrame.doc.createElement("script");s.type="text/javascript",s.async=!0,s.src=e,s.onload=s.onreadystatechange=function(){const r=s.readyState;(!r||r==="loaded"||r==="complete")&&(s.onload=s.onreadystatechange=null,s.parentNode&&s.parentNode.removeChild(s),n())},s.onerror=()=>{Fe("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(s)}catch{}},Math.floor(1))}}/**
677
677
  * @license
678
678
  * Copyright 2017 Google LLC
679
679
  *
@@ -688,7 +688,7 @@
688
688
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
689
689
  * See the License for the specific language governing permissions and
690
690
  * limitations under the License.
691
- */const z2=16384,K2=45e3;let gi=null;typeof MozWebSocket<"u"?gi=MozWebSocket:typeof WebSocket<"u"&&(gi=WebSocket);class vt{constructor(e,n,s,r,i,o,a){this.connId=e,this.applicationId=s,this.appCheckToken=r,this.authToken=i,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Sr(this.connId),this.stats_=mc(n),this.connURL=vt.connectionURL_(n,o,a,r,s),this.nodeAdmin=n.nodeAdmin}static connectionURL_(e,n,s,r,i){const o={};return o[Ff]=pc,typeof location<"u"&&location.hostname&&Vf.test(location.hostname)&&(o[Bf]=Uf),n&&(o[Mf]=n),s&&(o[Hf]=s),r&&(o[ba]=r),i&&(o[Gf]=i),qf(e,Wf,o)}open(e,n){this.onDisconnect=n,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,An.set("previous_websocket_failure",!0);try{let s;W_(),this.mySock=new gi(this.connURL,[],s)}catch(s){this.log_("Error instantiating WebSocket.");const r=s.message||s.data;r&&this.log_(r),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=s=>{this.handleIncomingFrame(s)},this.mySock.onerror=s=>{this.log_("WebSocket error. Closing connection.");const r=s.message||s.data;r&&this.log_(r),this.onClosed_()}}start(){}static forceDisallow(){vt.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){const n=/Android ([0-9]{0,}\.[0-9]{0,})/,s=navigator.userAgent.match(n);s&&s.length>1&&parseFloat(s[1])<4.4&&(e=!0)}return!e&&gi!==null&&!vt.forceDisallow_}static previouslyFailed(){return An.isInMemoryStorage||An.get("previous_websocket_failure")===!0}markConnectionHealthy(){An.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const n=this.frames.join("");this.frames=null;const s=or(n);this.onMessage(s)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(b(this.frames===null,"We already have a frame buffer"),e.length<=6){const n=Number(e);if(!isNaN(n))return this.handleNewFrameCount_(n),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(this.mySock===null)return;const n=e.data;if(this.bytesReceived+=n.length,this.stats_.incrementCounter("bytes_received",n.length),this.resetKeepAlive(),this.frames!==null)this.appendFrame_(n);else{const s=this.extractFrameCount_(n);s!==null&&this.appendFrame_(s)}}send(e){this.resetKeepAlive();const n=Le(e);this.bytesSent+=n.length,this.stats_.incrementCounter("bytes_sent",n.length);const s=Df(n,z2);s.length>1&&this.sendString_(String(s.length));for(let r=0;r<s.length;r++)this.sendString_(s[r])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(K2))}sendString_(e){try{this.mySock.send(e)}catch(n){this.log_("Exception thrown from WebSocket.send():",n.message||n.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}vt.responsesRequiredToBeHealthy=2;vt.healthyTimeout=3e4;/**
691
+ */const z2=16384,K2=45e3;let gi=null;typeof MozWebSocket<"u"?gi=MozWebSocket:typeof WebSocket<"u"&&(gi=WebSocket);class vt{constructor(e,n,s,r,i,o,a){this.connId=e,this.applicationId=s,this.appCheckToken=r,this.authToken=i,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Sr(this.connId),this.stats_=mc(n),this.connURL=vt.connectionURL_(n,o,a,r,s),this.nodeAdmin=n.nodeAdmin}static connectionURL_(e,n,s,r,i){const o={};return o[Ff]=pc,typeof location<"u"&&location.hostname&&Vf.test(location.hostname)&&(o[Bf]=Uf),n&&(o[Mf]=n),s&&(o[Hf]=s),r&&(o[ba]=r),i&&(o[Wf]=i),qf(e,Gf,o)}open(e,n){this.onDisconnect=n,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,An.set("previous_websocket_failure",!0);try{let s;G_(),this.mySock=new gi(this.connURL,[],s)}catch(s){this.log_("Error instantiating WebSocket.");const r=s.message||s.data;r&&this.log_(r),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=s=>{this.handleIncomingFrame(s)},this.mySock.onerror=s=>{this.log_("WebSocket error. Closing connection.");const r=s.message||s.data;r&&this.log_(r),this.onClosed_()}}start(){}static forceDisallow(){vt.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){const n=/Android ([0-9]{0,}\.[0-9]{0,})/,s=navigator.userAgent.match(n);s&&s.length>1&&parseFloat(s[1])<4.4&&(e=!0)}return!e&&gi!==null&&!vt.forceDisallow_}static previouslyFailed(){return An.isInMemoryStorage||An.get("previous_websocket_failure")===!0}markConnectionHealthy(){An.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const n=this.frames.join("");this.frames=null;const s=or(n);this.onMessage(s)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(b(this.frames===null,"We already have a frame buffer"),e.length<=6){const n=Number(e);if(!isNaN(n))return this.handleNewFrameCount_(n),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(this.mySock===null)return;const n=e.data;if(this.bytesReceived+=n.length,this.stats_.incrementCounter("bytes_received",n.length),this.resetKeepAlive(),this.frames!==null)this.appendFrame_(n);else{const s=this.extractFrameCount_(n);s!==null&&this.appendFrame_(s)}}send(e){this.resetKeepAlive();const n=Le(e);this.bytesSent+=n.length,this.stats_.incrementCounter("bytes_sent",n.length);const s=Df(n,z2);s.length>1&&this.sendString_(String(s.length));for(let r=0;r<s.length;r++)this.sendString_(s[r])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(K2))}sendString_(e){try{this.mySock.send(e)}catch(n){this.log_("Exception thrown from WebSocket.send():",n.message||n.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}vt.responsesRequiredToBeHealthy=2;vt.healthyTimeout=3e4;/**
692
692
  * @license
693
693
  * Copyright 2017 Google LLC
694
694
  *
@@ -778,7 +778,7 @@
778
778
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
779
779
  * See the License for the specific language governing permissions and
780
780
  * limitations under the License.
781
- */const Th=32,Ch=768;class re{constructor(e,n){if(n===void 0){this.pieces_=e.split("/");let s=0;for(let r=0;r<this.pieces_.length;r++)this.pieces_[r].length>0&&(this.pieces_[s]=this.pieces_[r],s++);this.pieces_.length=s,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=n}toString(){let e="";for(let n=this.pieceNum_;n<this.pieces_.length;n++)this.pieces_[n]!==""&&(e+="/"+this.pieces_[n]);return e||"/"}}function J(){return new re("")}function H(t){return t.pieceNum_>=t.pieces_.length?null:t.pieces_[t.pieceNum_]}function un(t){return t.pieces_.length-t.pieceNum_}function oe(t){let e=t.pieceNum_;return e<t.pieces_.length&&e++,new re(t.pieces_,e)}function ep(t){return t.pieceNum_<t.pieces_.length?t.pieces_[t.pieces_.length-1]:null}function s0(t){let e="";for(let n=t.pieceNum_;n<t.pieces_.length;n++)t.pieces_[n]!==""&&(e+="/"+encodeURIComponent(String(t.pieces_[n])));return e||"/"}function tp(t,e=0){return t.pieces_.slice(t.pieceNum_+e)}function np(t){if(t.pieceNum_>=t.pieces_.length)return null;const e=[];for(let n=t.pieceNum_;n<t.pieces_.length-1;n++)e.push(t.pieces_[n]);return new re(e,0)}function ke(t,e){const n=[];for(let s=t.pieceNum_;s<t.pieces_.length;s++)n.push(t.pieces_[s]);if(e instanceof re)for(let s=e.pieceNum_;s<e.pieces_.length;s++)n.push(e.pieces_[s]);else{const s=e.split("/");for(let r=0;r<s.length;r++)s[r].length>0&&n.push(s[r])}return new re(n,0)}function G(t){return t.pieceNum_>=t.pieces_.length}function $e(t,e){const n=H(t),s=H(e);if(n===null)return e;if(n===s)return $e(oe(t),oe(e));throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")}function _c(t,e){if(un(t)!==un(e))return!1;for(let n=t.pieceNum_,s=e.pieceNum_;n<=t.pieces_.length;n++,s++)if(t.pieces_[n]!==e.pieces_[s])return!1;return!0}function wt(t,e){let n=t.pieceNum_,s=e.pieceNum_;if(un(t)>un(e))return!1;for(;n<t.pieces_.length;){if(t.pieces_[n]!==e.pieces_[s])return!1;++n,++s}return!0}class r0{constructor(e,n){this.errorPrefix_=n,this.parts_=tp(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let s=0;s<this.parts_.length;s++)this.byteLength_+=Wi(this.parts_[s]);sp(this)}}function i0(t,e){t.parts_.length>0&&(t.byteLength_+=1),t.parts_.push(e),t.byteLength_+=Wi(e),sp(t)}function o0(t){const e=t.parts_.pop();t.byteLength_-=Wi(e),t.parts_.length>0&&(t.byteLength_-=1)}function sp(t){if(t.byteLength_>Ch)throw new Error(t.errorPrefix_+"has a key path longer than "+Ch+" bytes ("+t.byteLength_+").");if(t.parts_.length>Th)throw new Error(t.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+Th+") or object contains a cycle "+wn(t))}function wn(t){return t.parts_.length===0?"":"in property '"+t.parts_.join(".")+"'"}/**
781
+ */const Th=32,Ch=768;class re{constructor(e,n){if(n===void 0){this.pieces_=e.split("/");let s=0;for(let r=0;r<this.pieces_.length;r++)this.pieces_[r].length>0&&(this.pieces_[s]=this.pieces_[r],s++);this.pieces_.length=s,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=n}toString(){let e="";for(let n=this.pieceNum_;n<this.pieces_.length;n++)this.pieces_[n]!==""&&(e+="/"+this.pieces_[n]);return e||"/"}}function J(){return new re("")}function H(t){return t.pieceNum_>=t.pieces_.length?null:t.pieces_[t.pieceNum_]}function un(t){return t.pieces_.length-t.pieceNum_}function oe(t){let e=t.pieceNum_;return e<t.pieces_.length&&e++,new re(t.pieces_,e)}function ep(t){return t.pieceNum_<t.pieces_.length?t.pieces_[t.pieces_.length-1]:null}function s0(t){let e="";for(let n=t.pieceNum_;n<t.pieces_.length;n++)t.pieces_[n]!==""&&(e+="/"+encodeURIComponent(String(t.pieces_[n])));return e||"/"}function tp(t,e=0){return t.pieces_.slice(t.pieceNum_+e)}function np(t){if(t.pieceNum_>=t.pieces_.length)return null;const e=[];for(let n=t.pieceNum_;n<t.pieces_.length-1;n++)e.push(t.pieces_[n]);return new re(e,0)}function ke(t,e){const n=[];for(let s=t.pieceNum_;s<t.pieces_.length;s++)n.push(t.pieces_[s]);if(e instanceof re)for(let s=e.pieceNum_;s<e.pieces_.length;s++)n.push(e.pieces_[s]);else{const s=e.split("/");for(let r=0;r<s.length;r++)s[r].length>0&&n.push(s[r])}return new re(n,0)}function W(t){return t.pieceNum_>=t.pieces_.length}function $e(t,e){const n=H(t),s=H(e);if(n===null)return e;if(n===s)return $e(oe(t),oe(e));throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")}function _c(t,e){if(un(t)!==un(e))return!1;for(let n=t.pieceNum_,s=e.pieceNum_;n<=t.pieces_.length;n++,s++)if(t.pieces_[n]!==e.pieces_[s])return!1;return!0}function wt(t,e){let n=t.pieceNum_,s=e.pieceNum_;if(un(t)>un(e))return!1;for(;n<t.pieces_.length;){if(t.pieces_[n]!==e.pieces_[s])return!1;++n,++s}return!0}class r0{constructor(e,n){this.errorPrefix_=n,this.parts_=tp(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let s=0;s<this.parts_.length;s++)this.byteLength_+=Gi(this.parts_[s]);sp(this)}}function i0(t,e){t.parts_.length>0&&(t.byteLength_+=1),t.parts_.push(e),t.byteLength_+=Gi(e),sp(t)}function o0(t){const e=t.parts_.pop();t.byteLength_-=Gi(e),t.parts_.length>0&&(t.byteLength_-=1)}function sp(t){if(t.byteLength_>Ch)throw new Error(t.errorPrefix_+"has a key path longer than "+Ch+" bytes ("+t.byteLength_+").");if(t.parts_.length>Th)throw new Error(t.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+Th+") or object contains a cycle "+wn(t))}function wn(t){return t.parts_.length===0?"":"in property '"+t.parts_.join(".")+"'"}/**
782
782
  * @license
783
783
  * Copyright 2017 Google LLC
784
784
  *
@@ -811,7 +811,7 @@
811
811
  */const Vs=1e3,a0=60*5*1e3,Sh=30*1e3,c0=1.3,l0=3e4,h0="server_kill",Ah=3;class $t extends Qf{constructor(e,n,s,r,i,o,a,c){if(super(),this.repoInfo_=e,this.applicationId_=n,this.onDataUpdate_=s,this.onConnectStatus_=r,this.onServerInfoUpdate_=i,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=c,this.id=$t.nextPersistentConnectionId_++,this.log_=Sr("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=Vs,this.maxReconnectDelay_=a0,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,c)throw new Error("Auth override specified in options, but not supported on non Node.js platforms");yc.getInstance().on("visible",this.onVisible_,this),e.host.indexOf("fblocal")===-1&&_i.getInstance().on("online",this.onOnline_,this)}sendRequest(e,n,s){const r=++this.requestNumber_,i={r,a:e,b:n};this.log_(Le(i)),b(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),s&&(this.requestCBHash_[r]=s)}get(e){this.initConnection_();const n=new uc,r={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:o=>{const a=o.d;o.s==="ok"?n.resolve(a):n.reject(a)}};this.outstandingGets_.push(r),this.outstandingGetCount_++;const i=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(i),n.promise}listen(e,n,s,r){this.initConnection_();const i=e._queryIdentifier,o=e._path.toString();this.log_("Listen called for "+o+" "+i),this.listens.has(o)||this.listens.set(o,new Map),b(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),b(!this.listens.get(o).has(i),"listen() called twice for same path/queryId.");const a={onComplete:r,hashFn:n,query:e,tag:s};this.listens.get(o).set(i,a),this.connected_&&this.sendListen_(a)}sendGet_(e){const n=this.outstandingGets_[e];this.sendRequest("g",n.request,s=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,this.outstandingGetCount_===0&&(this.outstandingGets_=[]),n.onComplete&&n.onComplete(s)})}sendListen_(e){const n=e.query,s=n._path.toString(),r=n._queryIdentifier;this.log_("Listen on "+s+" for "+r);const i={p:s},o="q";e.tag&&(i.q=n._queryObject,i.t=e.tag),i.h=e.hashFn(),this.sendRequest(o,i,a=>{const c=a.d,l=a.s;$t.warnOnListenWarnings_(c,n),(this.listens.get(s)&&this.listens.get(s).get(r))===e&&(this.log_("listen response",a),l!=="ok"&&this.removeListen_(s,r),e.onComplete&&e.onComplete(l,c))})}static warnOnListenWarnings_(e,n){if(e&&typeof e=="object"&&Jt(e,"w")){const s=ls(e,"w");if(Array.isArray(s)&&~s.indexOf("no_index")){const r='".indexOn": "'+n._queryParams.getIndex().toString()+'"',i=n._path.toString();nt(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${r} at ${i} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&e.length===40||X_(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=Sh)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const e=this.authToken_,n=Y_(e)?"auth":"gauth",s={cred:e};this.authOverride_===null?s.noauth=!0:typeof this.authOverride_=="object"&&(s.authvar=this.authOverride_),this.sendRequest(n,s,r=>{const i=r.s,o=r.d||"error";this.authToken_===e&&(i==="ok"?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(i,o))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{const n=e.s,s=e.d||"error";n==="ok"?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(n,s)})}unlisten(e,n){const s=e._path.toString(),r=e._queryIdentifier;this.log_("Unlisten called for "+s+" "+r),b(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(s,r)&&this.connected_&&this.sendUnlisten_(s,r,e._queryObject,n)}sendUnlisten_(e,n,s,r){this.log_("Unlisten on "+e+" for "+n);const i={p:e},o="n";r&&(i.q=s,i.t=r),this.sendRequest(o,i)}onDisconnectPut(e,n,s){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,n,s):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:n,onComplete:s})}onDisconnectMerge(e,n,s){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,n,s):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:n,onComplete:s})}onDisconnectCancel(e,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:n})}sendOnDisconnect_(e,n,s,r){const i={p:n,d:s};this.log_("onDisconnect "+e,i),this.sendRequest(e,i,o=>{r&&setTimeout(()=>{r(o.s,o.d)},Math.floor(0))})}put(e,n,s,r){this.putInternal("p",e,n,s,r)}merge(e,n,s,r){this.putInternal("m",e,n,s,r)}putInternal(e,n,s,r,i){this.initConnection_();const o={p:n,d:s};i!==void 0&&(o.h=i),this.outstandingPuts_.push({action:e,request:o,onComplete:r}),this.outstandingPutCount_++;const a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+n)}sendPut_(e){const n=this.outstandingPuts_[e].action,s=this.outstandingPuts_[e].request,r=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(n,s,i=>{this.log_(n+" response",i),delete this.outstandingPuts_[e],this.outstandingPutCount_--,this.outstandingPutCount_===0&&(this.outstandingPuts_=[]),r&&r(i.s,i.d)})}reportStats(e){if(this.connected_){const n={c:e};this.log_("reportStats",n),this.sendRequest("s",n,s=>{if(s.s!=="ok"){const i=s.d;this.log_("reportStats","Error sending stats: "+i)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+Le(e));const n=e.r,s=this.requestCBHash_[n];s&&(delete this.requestCBHash_[n],s(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,n){this.log_("handleServerMessage",e,n),e==="d"?this.onDataUpdate_(n.p,n.d,!1,n.t):e==="m"?this.onDataUpdate_(n.p,n.d,!0,n.t):e==="c"?this.onListenRevoked_(n.p,n.q):e==="ac"?this.onAuthRevoked_(n.s,n.d):e==="apc"?this.onAppCheckRevoked_(n.s,n.d):e==="sd"?this.onSecurityDebugPacket_(n):wa("Unrecognized action received from server: "+Le(e)+`
812
812
  Are you using the latest client?`)}onReady_(e,n){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=new Date().getTime(),this.handleTimestamp_(e),this.lastSessionId=n,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){b(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=Vs,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=Vs,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&(new Date().getTime()-this.lastConnectionEstablishedTime_>l0&&(this.reconnectDelay_=Vs),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=new Date().getTime());const e=Math.max(0,new Date().getTime()-this.lastConnectionAttemptTime_);let n=Math.max(0,this.reconnectDelay_-e);n=Math.random()*n,this.log_("Trying to reconnect in "+n+"ms"),this.scheduleConnect_(n),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*c0)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=new Date().getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),n=this.onReady_.bind(this),s=this.onRealtimeDisconnect_.bind(this),r=this.id+":"+$t.nextConnectionId_++,i=this.lastSessionId;let o=!1,a=null;const c=function(){a?a.close():(o=!0,s())},l=function(u){b(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(u)};this.realtime_={close:c,sendRequest:l};const h=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[u,d]=await Promise.all([this.authTokenProvider_.getToken(h),this.appCheckTokenProvider_.getToken(h)]);o?Fe("getToken() completed but was canceled"):(Fe("getToken() completed. Creating connection."),this.authToken_=u&&u.accessToken,this.appCheckToken_=d&&d.token,a=new n0(r,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,n,s,p=>{nt(p+" ("+this.repoInfo_.toString()+")"),this.interrupt(h0)},i))}catch(u){this.log_("Failed to get token: "+u),o||(this.repoInfo_.nodeAdmin&&nt(u),c())}}}interrupt(e){Fe("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){Fe("Resuming connection for reason: "+e),delete this.interruptReasons_[e],nh(this.interruptReasons_)&&(this.reconnectDelay_=Vs,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const n=e-new Date().getTime();this.onServerInfoUpdate_({serverTimeOffset:n})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const n=this.outstandingPuts_[e];n&&"h"in n.request&&n.queued&&(n.onComplete&&n.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}this.outstandingPutCount_===0&&(this.outstandingPuts_=[])}onListenRevoked_(e,n){let s;n?s=n.map(i=>fc(i)).join("$"):s="default";const r=this.removeListen_(e,s);r&&r.onComplete&&r.onComplete("permission_denied")}removeListen_(e,n){const s=new re(e).toString();let r;if(this.listens.has(s)){const i=this.listens.get(s);r=i.get(n),i.delete(n),i.size===0&&this.listens.delete(s)}else r=void 0;return r}onAuthRevoked_(e,n){Fe("Auth token revoked: "+e+"/"+n),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),(e==="invalid_token"||e==="permission_denied")&&(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=Ah&&(this.reconnectDelay_=Sh,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,n){Fe("App check token revoked: "+e+"/"+n),this.appCheckToken_=null,this.forceTokenRefresh_=!0,(e==="invalid_token"||e==="permission_denied")&&(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=Ah&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace(`
813
813
  `,`
814
- FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const n of e.values())this.sendListen_(n);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){const e={};let n="js";e["sdk."+n+"."+Nf.replace(/\./g,"-")]=1,Ef()?e["framework.cordova"]=1:G_()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=_i.getInstance().currentlyOnline();return nh(this.interruptReasons_)&&e}}$t.nextPersistentConnectionId_=0;$t.nextConnectionId_=0;/**
814
+ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const n of e.values())this.sendListen_(n);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){const e={};let n="js";e["sdk."+n+"."+Nf.replace(/\./g,"-")]=1,Ef()?e["framework.cordova"]=1:W_()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=_i.getInstance().currentlyOnline();return nh(this.interruptReasons_)&&e}}$t.nextPersistentConnectionId_=0;$t.nextConnectionId_=0;/**
815
815
  * @license
816
816
  * Copyright 2017 Google LLC
817
817
  *
@@ -916,7 +916,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
916
916
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
917
917
  * See the License for the specific language governing permissions and
918
918
  * limitations under the License.
919
- */let Rh;class xe{static set __childrenNodeConstructor(e){Rh=e}static get __childrenNodeConstructor(){return Rh}constructor(e,n=xe.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=n,this.lazyHash_=null,b(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),op(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new xe(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:xe.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return G(e)?this:H(e)===".priority"?this.priorityNode_:xe.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,n){return null}updateImmediateChild(e,n){return e===".priority"?this.updatePriority(n):n.isEmpty()&&e!==".priority"?this:xe.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,n).updatePriority(this.priorityNode_)}updateChild(e,n){const s=H(e);return s===null?n:n.isEmpty()&&s!==".priority"?this:(b(s!==".priority"||un(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(s,xe.__childrenNodeConstructor.EMPTY_NODE.updateChild(oe(e),n)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,n){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(this.lazyHash_===null){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+ip(this.priorityNode_.val())+":");const n=typeof this.value_;e+=n+":",n==="number"?e+=Pf(this.value_):e+=this.value_,this.lazyHash_=Of(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===xe.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof xe.__childrenNodeConstructor?-1:(b(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const n=typeof e.value_,s=typeof this.value_,r=xe.VALUE_TYPE_ORDER.indexOf(n),i=xe.VALUE_TYPE_ORDER.indexOf(s);return b(r>=0,"Unknown leaf type: "+n),b(i>=0,"Unknown leaf type: "+s),r===i?s==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:i-r}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const n=e;return this.value_===n.value_&&this.priorityNode_.equals(n.priorityNode_)}else return!1}}xe.VALUE_TYPE_ORDER=["object","boolean","number","string"];/**
919
+ */let Rh;class xe{static set __childrenNodeConstructor(e){Rh=e}static get __childrenNodeConstructor(){return Rh}constructor(e,n=xe.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=n,this.lazyHash_=null,b(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),op(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new xe(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:xe.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return W(e)?this:H(e)===".priority"?this.priorityNode_:xe.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,n){return null}updateImmediateChild(e,n){return e===".priority"?this.updatePriority(n):n.isEmpty()&&e!==".priority"?this:xe.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,n).updatePriority(this.priorityNode_)}updateChild(e,n){const s=H(e);return s===null?n:n.isEmpty()&&s!==".priority"?this:(b(s!==".priority"||un(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(s,xe.__childrenNodeConstructor.EMPTY_NODE.updateChild(oe(e),n)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,n){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(this.lazyHash_===null){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+ip(this.priorityNode_.val())+":");const n=typeof this.value_;e+=n+":",n==="number"?e+=Pf(this.value_):e+=this.value_,this.lazyHash_=Of(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===xe.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof xe.__childrenNodeConstructor?-1:(b(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const n=typeof e.value_,s=typeof this.value_,r=xe.VALUE_TYPE_ORDER.indexOf(n),i=xe.VALUE_TYPE_ORDER.indexOf(s);return b(r>=0,"Unknown leaf type: "+n),b(i>=0,"Unknown leaf type: "+s),r===i?s==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:i-r}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const n=e;return this.value_===n.value_&&this.priorityNode_.equals(n.priorityNode_)}else return!1}}xe.VALUE_TYPE_ORDER=["object","boolean","number","string"];/**
920
920
  * @license
921
921
  * Copyright 2017 Google LLC
922
922
  *
@@ -961,7 +961,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
961
961
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
962
962
  * See the License for the specific language governing permissions and
963
963
  * limitations under the License.
964
- */let Go;const Gn={};class Gt{static get Default(){return b(Gn&&ye,"ChildrenNode.ts has not been loaded"),Go=Go||new Gt({".priority":Gn},{".priority":ye}),Go}constructor(e,n){this.indexes_=e,this.indexSet_=n}get(e){const n=ls(this.indexes_,e);if(!n)throw new Error("No index defined for "+e);return n instanceof je?n:null}hasIndex(e){return Jt(this.indexSet_,e.toString())}addIndex(e,n){b(e!==ts,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const s=[];let r=!1;const i=n.getIterator(B.Wrap);let o=i.getNext();for(;o;)r=r||e.isDefinedOn(o.node),s.push(o),o=i.getNext();let a;r?a=yi(s,e.getCompare()):a=Gn;const c=e.toString(),l=Object.assign({},this.indexSet_);l[c]=e;const h=Object.assign({},this.indexes_);return h[c]=a,new Gt(h,l)}addToIndexes(e,n){const s=fi(this.indexes_,(r,i)=>{const o=ls(this.indexSet_,i);if(b(o,"Missing index implementation for "+i),r===Gn)if(o.isDefinedOn(e.node)){const a=[],c=n.getIterator(B.Wrap);let l=c.getNext();for(;l;)l.name!==e.name&&a.push(l),l=c.getNext();return a.push(e),yi(a,o.getCompare())}else return Gn;else{const a=n.get(e.name);let c=r;return a&&(c=c.remove(new B(e.name,a))),c.insert(e,e.node)}});return new Gt(s,this.indexSet_)}removeFromIndexes(e,n){const s=fi(this.indexes_,r=>{if(r===Gn)return r;{const i=n.get(e.name);return i?r.remove(new B(e.name,i)):r}});return new Gt(s,this.indexSet_)}}/**
964
+ */let Wo;const Wn={};class Wt{static get Default(){return b(Wn&&ye,"ChildrenNode.ts has not been loaded"),Wo=Wo||new Wt({".priority":Wn},{".priority":ye}),Wo}constructor(e,n){this.indexes_=e,this.indexSet_=n}get(e){const n=ls(this.indexes_,e);if(!n)throw new Error("No index defined for "+e);return n instanceof je?n:null}hasIndex(e){return Jt(this.indexSet_,e.toString())}addIndex(e,n){b(e!==ts,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const s=[];let r=!1;const i=n.getIterator(B.Wrap);let o=i.getNext();for(;o;)r=r||e.isDefinedOn(o.node),s.push(o),o=i.getNext();let a;r?a=yi(s,e.getCompare()):a=Wn;const c=e.toString(),l=Object.assign({},this.indexSet_);l[c]=e;const h=Object.assign({},this.indexes_);return h[c]=a,new Wt(h,l)}addToIndexes(e,n){const s=fi(this.indexes_,(r,i)=>{const o=ls(this.indexSet_,i);if(b(o,"Missing index implementation for "+i),r===Wn)if(o.isDefinedOn(e.node)){const a=[],c=n.getIterator(B.Wrap);let l=c.getNext();for(;l;)l.name!==e.name&&a.push(l),l=c.getNext();return a.push(e),yi(a,o.getCompare())}else return Wn;else{const a=n.get(e.name);let c=r;return a&&(c=c.remove(new B(e.name,a))),c.insert(e,e.node)}});return new Wt(s,this.indexSet_)}removeFromIndexes(e,n){const s=fi(this.indexes_,r=>{if(r===Wn)return r;{const i=n.get(e.name);return i?r.remove(new B(e.name,i)):r}});return new Wt(s,this.indexSet_)}}/**
965
965
  * @license
966
966
  * Copyright 2017 Google LLC
967
967
  *
@@ -976,7 +976,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
976
976
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
977
977
  * See the License for the specific language governing permissions and
978
978
  * limitations under the License.
979
- */let Hs;class F{static get EMPTY_NODE(){return Hs||(Hs=new F(new je(Ec),null,Gt.Default))}constructor(e,n,s){this.children_=e,this.priorityNode_=n,this.indexMap_=s,this.lazyHash_=null,this.priorityNode_&&op(this.priorityNode_),this.children_.isEmpty()&&b(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||Hs}updatePriority(e){return this.children_.isEmpty()?this:new F(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{const n=this.children_.get(e);return n===null?Hs:n}}getChild(e){const n=H(e);return n===null?this:this.getImmediateChild(n).getChild(oe(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,n){if(b(n,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(n);{const s=new B(e,n);let r,i;n.isEmpty()?(r=this.children_.remove(e),i=this.indexMap_.removeFromIndexes(s,this.children_)):(r=this.children_.insert(e,n),i=this.indexMap_.addToIndexes(s,this.children_));const o=r.isEmpty()?Hs:this.priorityNode_;return new F(r,o,i)}}updateChild(e,n){const s=H(e);if(s===null)return n;{b(H(e)!==".priority"||un(e)===1,".priority must be the last token in a path");const r=this.getImmediateChild(s).updateChild(oe(e),n);return this.updateImmediateChild(s,r)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const n={};let s=0,r=0,i=!0;if(this.forEachChild(ye,(o,a)=>{n[o]=a.val(e),s++,i&&F.INTEGER_REGEXP_.test(o)?r=Math.max(r,Number(o)):i=!1}),!e&&i&&r<2*s){const o=[];for(const a in n)o[a]=n[a];return o}else return e&&!this.getPriority().isEmpty()&&(n[".priority"]=this.getPriority().val()),n}hash(){if(this.lazyHash_===null){let e="";this.getPriority().isEmpty()||(e+="priority:"+ip(this.getPriority().val())+":"),this.forEachChild(ye,(n,s)=>{const r=s.hash();r!==""&&(e+=":"+n+":"+r)}),this.lazyHash_=e===""?"":Of(e)}return this.lazyHash_}getPredecessorChildName(e,n,s){const r=this.resolveIndex_(s);if(r){const i=r.getPredecessorKey(new B(e,n));return i?i.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){const n=this.resolveIndex_(e);if(n){const s=n.minKey();return s&&s.name}else return this.children_.minKey()}getFirstChild(e){const n=this.getFirstChildName(e);return n?new B(n,this.children_.get(n)):null}getLastChildName(e){const n=this.resolveIndex_(e);if(n){const s=n.maxKey();return s&&s.name}else return this.children_.maxKey()}getLastChild(e){const n=this.getLastChildName(e);return n?new B(n,this.children_.get(n)):null}forEachChild(e,n){const s=this.resolveIndex_(e);return s?s.inorderTraversal(r=>n(r.name,r.node)):this.children_.inorderTraversal(n)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,n){const s=this.resolveIndex_(n);if(s)return s.getIteratorFrom(e,r=>r);{const r=this.children_.getIteratorFrom(e.name,B.Wrap);let i=r.peek();for(;i!=null&&n.compare(i,e)<0;)r.getNext(),i=r.peek();return r}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,n){const s=this.resolveIndex_(n);if(s)return s.getReverseIteratorFrom(e,r=>r);{const r=this.children_.getReverseIteratorFrom(e.name,B.Wrap);let i=r.peek();for(;i!=null&&n.compare(i,e)>0;)r.getNext(),i=r.peek();return r}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===Rr?-1:0}withIndex(e){if(e===ts||this.indexMap_.hasIndex(e))return this;{const n=this.indexMap_.addIndex(e,this.children_);return new F(this.children_,this.priorityNode_,n)}}isIndexed(e){return e===ts||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const n=e;if(this.getPriority().equals(n.getPriority()))if(this.children_.count()===n.children_.count()){const s=this.getIterator(ye),r=n.getIterator(ye);let i=s.getNext(),o=r.getNext();for(;i&&o;){if(i.name!==o.name||!i.node.equals(o.node))return!1;i=s.getNext(),o=r.getNext()}return i===null&&o===null}else return!1;else return!1}}resolveIndex_(e){return e===ts?null:this.indexMap_.get(e.toString())}}F.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class E0 extends F{constructor(){super(new je(Ec),F.EMPTY_NODE,Gt.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return F.EMPTY_NODE}isEmpty(){return!1}}const Rr=new E0;Object.defineProperties(B,{MIN:{value:new B(hs,F.EMPTY_NODE)},MAX:{value:new B(On,Rr)}});rp.__EMPTY_NODE=F.EMPTY_NODE;xe.__childrenNodeConstructor=F;f0(Rr);m0(Rr);/**
979
+ */let Hs;class F{static get EMPTY_NODE(){return Hs||(Hs=new F(new je(Ec),null,Wt.Default))}constructor(e,n,s){this.children_=e,this.priorityNode_=n,this.indexMap_=s,this.lazyHash_=null,this.priorityNode_&&op(this.priorityNode_),this.children_.isEmpty()&&b(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||Hs}updatePriority(e){return this.children_.isEmpty()?this:new F(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{const n=this.children_.get(e);return n===null?Hs:n}}getChild(e){const n=H(e);return n===null?this:this.getImmediateChild(n).getChild(oe(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,n){if(b(n,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(n);{const s=new B(e,n);let r,i;n.isEmpty()?(r=this.children_.remove(e),i=this.indexMap_.removeFromIndexes(s,this.children_)):(r=this.children_.insert(e,n),i=this.indexMap_.addToIndexes(s,this.children_));const o=r.isEmpty()?Hs:this.priorityNode_;return new F(r,o,i)}}updateChild(e,n){const s=H(e);if(s===null)return n;{b(H(e)!==".priority"||un(e)===1,".priority must be the last token in a path");const r=this.getImmediateChild(s).updateChild(oe(e),n);return this.updateImmediateChild(s,r)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const n={};let s=0,r=0,i=!0;if(this.forEachChild(ye,(o,a)=>{n[o]=a.val(e),s++,i&&F.INTEGER_REGEXP_.test(o)?r=Math.max(r,Number(o)):i=!1}),!e&&i&&r<2*s){const o=[];for(const a in n)o[a]=n[a];return o}else return e&&!this.getPriority().isEmpty()&&(n[".priority"]=this.getPriority().val()),n}hash(){if(this.lazyHash_===null){let e="";this.getPriority().isEmpty()||(e+="priority:"+ip(this.getPriority().val())+":"),this.forEachChild(ye,(n,s)=>{const r=s.hash();r!==""&&(e+=":"+n+":"+r)}),this.lazyHash_=e===""?"":Of(e)}return this.lazyHash_}getPredecessorChildName(e,n,s){const r=this.resolveIndex_(s);if(r){const i=r.getPredecessorKey(new B(e,n));return i?i.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){const n=this.resolveIndex_(e);if(n){const s=n.minKey();return s&&s.name}else return this.children_.minKey()}getFirstChild(e){const n=this.getFirstChildName(e);return n?new B(n,this.children_.get(n)):null}getLastChildName(e){const n=this.resolveIndex_(e);if(n){const s=n.maxKey();return s&&s.name}else return this.children_.maxKey()}getLastChild(e){const n=this.getLastChildName(e);return n?new B(n,this.children_.get(n)):null}forEachChild(e,n){const s=this.resolveIndex_(e);return s?s.inorderTraversal(r=>n(r.name,r.node)):this.children_.inorderTraversal(n)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,n){const s=this.resolveIndex_(n);if(s)return s.getIteratorFrom(e,r=>r);{const r=this.children_.getIteratorFrom(e.name,B.Wrap);let i=r.peek();for(;i!=null&&n.compare(i,e)<0;)r.getNext(),i=r.peek();return r}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,n){const s=this.resolveIndex_(n);if(s)return s.getReverseIteratorFrom(e,r=>r);{const r=this.children_.getReverseIteratorFrom(e.name,B.Wrap);let i=r.peek();for(;i!=null&&n.compare(i,e)>0;)r.getNext(),i=r.peek();return r}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===Rr?-1:0}withIndex(e){if(e===ts||this.indexMap_.hasIndex(e))return this;{const n=this.indexMap_.addIndex(e,this.children_);return new F(this.children_,this.priorityNode_,n)}}isIndexed(e){return e===ts||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const n=e;if(this.getPriority().equals(n.getPriority()))if(this.children_.count()===n.children_.count()){const s=this.getIterator(ye),r=n.getIterator(ye);let i=s.getNext(),o=r.getNext();for(;i&&o;){if(i.name!==o.name||!i.node.equals(o.node))return!1;i=s.getNext(),o=r.getNext()}return i===null&&o===null}else return!1;else return!1}}resolveIndex_(e){return e===ts?null:this.indexMap_.get(e.toString())}}F.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class E0 extends F{constructor(){super(new je(Ec),F.EMPTY_NODE,Wt.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return F.EMPTY_NODE}isEmpty(){return!1}}const Rr=new E0;Object.defineProperties(B,{MIN:{value:new B(hs,F.EMPTY_NODE)},MAX:{value:new B(On,Rr)}});rp.__EMPTY_NODE=F.EMPTY_NODE;xe.__childrenNodeConstructor=F;f0(Rr);m0(Rr);/**
980
980
  * @license
981
981
  * Copyright 2017 Google LLC
982
982
  *
@@ -991,7 +991,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
991
991
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
992
992
  * See the License for the specific language governing permissions and
993
993
  * limitations under the License.
994
- */const v0=!0;function Me(t,e=null){if(t===null)return F.EMPTY_NODE;if(typeof t=="object"&&".priority"in t&&(e=t[".priority"]),b(e===null||typeof e=="string"||typeof e=="number"||typeof e=="object"&&".sv"in e,"Invalid priority type found: "+typeof e),typeof t=="object"&&".value"in t&&t[".value"]!==null&&(t=t[".value"]),typeof t!="object"||".sv"in t){const n=t;return new xe(n,Me(e))}if(!(t instanceof Array)&&v0){const n=[];let s=!1;if(Ke(t,(o,a)=>{if(o.substring(0,1)!=="."){const c=Me(a);c.isEmpty()||(s=s||!c.getPriority().isEmpty(),n.push(new B(o,c)))}}),n.length===0)return F.EMPTY_NODE;const i=yi(n,d0,o=>o.name,Ec);if(s){const o=yi(n,ye.getCompare());return new F(i,Me(e),new Gt({".priority":o},{".priority":ye}))}else return new F(i,Me(e),Gt.Default)}else{let n=F.EMPTY_NODE;return Ke(t,(s,r)=>{if(Jt(t,s)&&s.substring(0,1)!=="."){const i=Me(r);(i.isLeafNode()||!i.isEmpty())&&(n=n.updateImmediateChild(s,i))}}),n.updatePriority(Me(e))}}p0(Me);/**
994
+ */const v0=!0;function Me(t,e=null){if(t===null)return F.EMPTY_NODE;if(typeof t=="object"&&".priority"in t&&(e=t[".priority"]),b(e===null||typeof e=="string"||typeof e=="number"||typeof e=="object"&&".sv"in e,"Invalid priority type found: "+typeof e),typeof t=="object"&&".value"in t&&t[".value"]!==null&&(t=t[".value"]),typeof t!="object"||".sv"in t){const n=t;return new xe(n,Me(e))}if(!(t instanceof Array)&&v0){const n=[];let s=!1;if(Ke(t,(o,a)=>{if(o.substring(0,1)!=="."){const c=Me(a);c.isEmpty()||(s=s||!c.getPriority().isEmpty(),n.push(new B(o,c)))}}),n.length===0)return F.EMPTY_NODE;const i=yi(n,d0,o=>o.name,Ec);if(s){const o=yi(n,ye.getCompare());return new F(i,Me(e),new Wt({".priority":o},{".priority":ye}))}else return new F(i,Me(e),Wt.Default)}else{let n=F.EMPTY_NODE;return Ke(t,(s,r)=>{if(Jt(t,s)&&s.substring(0,1)!=="."){const i=Me(r);(i.isLeafNode()||!i.isEmpty())&&(n=n.updateImmediateChild(s,i))}}),n.updatePriority(Me(e))}}p0(Me);/**
995
995
  * @license
996
996
  * Copyright 2017 Google LLC
997
997
  *
@@ -1006,7 +1006,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1006
1006
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1007
1007
  * See the License for the specific language governing permissions and
1008
1008
  * limitations under the License.
1009
- */class w0 extends ji{constructor(e){super(),this.indexPath_=e,b(!G(e)&&H(e)!==".priority","Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,n){const s=this.extractChild(e.node),r=this.extractChild(n.node),i=s.compareTo(r);return i===0?Cs(e.name,n.name):i}makePost(e,n){const s=Me(e),r=F.EMPTY_NODE.updateChild(this.indexPath_,s);return new B(n,r)}maxPost(){const e=F.EMPTY_NODE.updateChild(this.indexPath_,Rr);return new B(On,e)}toString(){return tp(this.indexPath_,0).join("/")}}/**
1009
+ */class w0 extends ji{constructor(e){super(),this.indexPath_=e,b(!W(e)&&H(e)!==".priority","Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,n){const s=this.extractChild(e.node),r=this.extractChild(n.node),i=s.compareTo(r);return i===0?Cs(e.name,n.name):i}makePost(e,n){const s=Me(e),r=F.EMPTY_NODE.updateChild(this.indexPath_,s);return new B(n,r)}maxPost(){const e=F.EMPTY_NODE.updateChild(this.indexPath_,Rr);return new B(On,e)}toString(){return tp(this.indexPath_,0).join("/")}}/**
1010
1010
  * @license
1011
1011
  * Copyright 2017 Google LLC
1012
1012
  *
@@ -1141,7 +1141,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1141
1141
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1142
1142
  * See the License for the specific language governing permissions and
1143
1143
  * limitations under the License.
1144
- */function vi(){return{value:null,children:new Map}}function hp(t,e,n){if(G(e))t.value=n,t.children.clear();else if(t.value!==null)t.value=t.value.updateChild(e,n);else{const s=H(e);t.children.has(s)||t.children.set(s,vi());const r=t.children.get(s);e=oe(e),hp(r,e,n)}}function Ca(t,e,n){t.value!==null?n(e,t.value):k0(t,(s,r)=>{const i=new re(e.toString()+"/"+s);Ca(r,i,n)})}function k0(t,e){t.children.forEach((n,s)=>{e(s,n)})}/**
1144
+ */function vi(){return{value:null,children:new Map}}function hp(t,e,n){if(W(e))t.value=n,t.children.clear();else if(t.value!==null)t.value=t.value.updateChild(e,n);else{const s=H(e);t.children.has(s)||t.children.set(s,vi());const r=t.children.get(s);e=oe(e),hp(r,e,n)}}function Ca(t,e,n){t.value!==null?n(e,t.value):k0(t,(s,r)=>{const i=new re(e.toString()+"/"+s);Ca(r,i,n)})}function k0(t,e){t.children.forEach((n,s)=>{e(s,n)})}/**
1145
1145
  * @license
1146
1146
  * Copyright 2017 Google LLC
1147
1147
  *
@@ -1201,7 +1201,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1201
1201
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1202
1202
  * See the License for the specific language governing permissions and
1203
1203
  * limitations under the License.
1204
- */class wi{constructor(e,n,s){this.path=e,this.affectedTree=n,this.revert=s,this.type=bt.ACK_USER_WRITE,this.source=up()}operationForChild(e){if(G(this.path)){if(this.affectedTree.value!=null)return b(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const n=this.affectedTree.subtree(new re(e));return new wi(J(),n,this.revert)}}else return b(H(this.path)===e,"operationForChild called for unrelated child."),new wi(oe(this.path),this.affectedTree,this.revert)}}/**
1204
+ */class wi{constructor(e,n,s){this.path=e,this.affectedTree=n,this.revert=s,this.type=bt.ACK_USER_WRITE,this.source=up()}operationForChild(e){if(W(this.path)){if(this.affectedTree.value!=null)return b(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const n=this.affectedTree.subtree(new re(e));return new wi(J(),n,this.revert)}}else return b(H(this.path)===e,"operationForChild called for unrelated child."),new wi(oe(this.path),this.affectedTree,this.revert)}}/**
1205
1205
  * @license
1206
1206
  * Copyright 2017 Google LLC
1207
1207
  *
@@ -1216,7 +1216,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1216
1216
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1217
1217
  * See the License for the specific language governing permissions and
1218
1218
  * limitations under the License.
1219
- */class pr{constructor(e,n){this.source=e,this.path=n,this.type=bt.LISTEN_COMPLETE}operationForChild(e){return G(this.path)?new pr(this.source,J()):new pr(this.source,oe(this.path))}}/**
1219
+ */class pr{constructor(e,n){this.source=e,this.path=n,this.type=bt.LISTEN_COMPLETE}operationForChild(e){return W(this.path)?new pr(this.source,J()):new pr(this.source,oe(this.path))}}/**
1220
1220
  * @license
1221
1221
  * Copyright 2017 Google LLC
1222
1222
  *
@@ -1231,7 +1231,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1231
1231
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1232
1232
  * See the License for the specific language governing permissions and
1233
1233
  * limitations under the License.
1234
- */class Ln{constructor(e,n,s){this.source=e,this.path=n,this.snap=s,this.type=bt.OVERWRITE}operationForChild(e){return G(this.path)?new Ln(this.source,J(),this.snap.getImmediateChild(e)):new Ln(this.source,oe(this.path),this.snap)}}/**
1234
+ */class Ln{constructor(e,n,s){this.source=e,this.path=n,this.snap=s,this.type=bt.OVERWRITE}operationForChild(e){return W(this.path)?new Ln(this.source,J(),this.snap.getImmediateChild(e)):new Ln(this.source,oe(this.path),this.snap)}}/**
1235
1235
  * @license
1236
1236
  * Copyright 2017 Google LLC
1237
1237
  *
@@ -1246,7 +1246,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1246
1246
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1247
1247
  * See the License for the specific language governing permissions and
1248
1248
  * limitations under the License.
1249
- */class mr{constructor(e,n,s){this.source=e,this.path=n,this.children=s,this.type=bt.MERGE}operationForChild(e){if(G(this.path)){const n=this.children.subtree(new re(e));return n.isEmpty()?null:n.value?new Ln(this.source,J(),n.value):new mr(this.source,J(),n)}else return b(H(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new mr(this.source,oe(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}/**
1249
+ */class mr{constructor(e,n,s){this.source=e,this.path=n,this.children=s,this.type=bt.MERGE}operationForChild(e){if(W(this.path)){const n=this.children.subtree(new re(e));return n.isEmpty()?null:n.value?new Ln(this.source,J(),n.value):new mr(this.source,J(),n)}else return b(H(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new mr(this.source,oe(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}/**
1250
1250
  * @license
1251
1251
  * Copyright 2017 Google LLC
1252
1252
  *
@@ -1261,7 +1261,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1261
1261
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1262
1262
  * See the License for the specific language governing permissions and
1263
1263
  * limitations under the License.
1264
- */class Dn{constructor(e,n,s){this.node_=e,this.fullyInitialized_=n,this.filtered_=s}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(G(e))return this.isFullyInitialized()&&!this.filtered_;const n=H(e);return this.isCompleteForChild(n)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}/**
1264
+ */class Dn{constructor(e,n,s){this.node_=e,this.fullyInitialized_=n,this.filtered_=s}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(W(e))return this.isFullyInitialized()&&!this.filtered_;const n=H(e);return this.isCompleteForChild(n)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}/**
1265
1265
  * @license
1266
1266
  * Copyright 2017 Google LLC
1267
1267
  *
@@ -1276,7 +1276,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1276
1276
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1277
1277
  * See the License for the specific language governing permissions and
1278
1278
  * limitations under the License.
1279
- */class L0{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function D0(t,e,n,s){const r=[],i=[];return e.forEach(o=>{o.type==="child_changed"&&t.index_.indexedValueChanged(o.oldSnap,o.snapshotNode)&&i.push(C0(o.childName,o.snapshotNode))}),Gs(t,r,"child_removed",e,s,n),Gs(t,r,"child_added",e,s,n),Gs(t,r,"child_moved",i,s,n),Gs(t,r,"child_changed",e,s,n),Gs(t,r,"value",e,s,n),r}function Gs(t,e,n,s,r,i){const o=s.filter(a=>a.type===n);o.sort((a,c)=>F0(t,a,c)),o.forEach(a=>{const c=P0(t,a,i);r.forEach(l=>{l.respondsTo(a.type)&&e.push(l.createEvent(c,t.query_))})})}function P0(t,e,n){return e.type==="value"||e.type==="child_removed"||(e.prevName=n.getPredecessorChildName(e.childName,e.snapshotNode,t.index_)),e}function F0(t,e,n){if(e.childName==null||n.childName==null)throw Ts("Should only compare child_ events.");const s=new B(e.childName,e.snapshotNode),r=new B(n.childName,n.snapshotNode);return t.index_.compare(s,r)}/**
1279
+ */class L0{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function D0(t,e,n,s){const r=[],i=[];return e.forEach(o=>{o.type==="child_changed"&&t.index_.indexedValueChanged(o.oldSnap,o.snapshotNode)&&i.push(C0(o.childName,o.snapshotNode))}),Ws(t,r,"child_removed",e,s,n),Ws(t,r,"child_added",e,s,n),Ws(t,r,"child_moved",i,s,n),Ws(t,r,"child_changed",e,s,n),Ws(t,r,"value",e,s,n),r}function Ws(t,e,n,s,r,i){const o=s.filter(a=>a.type===n);o.sort((a,c)=>F0(t,a,c)),o.forEach(a=>{const c=P0(t,a,i);r.forEach(l=>{l.respondsTo(a.type)&&e.push(l.createEvent(c,t.query_))})})}function P0(t,e,n){return e.type==="value"||e.type==="child_removed"||(e.prevName=n.getPredecessorChildName(e.childName,e.snapshotNode,t.index_)),e}function F0(t,e,n){if(e.childName==null||n.childName==null)throw Ts("Should only compare child_ events.");const s=new B(e.childName,e.snapshotNode),r=new B(n.childName,n.snapshotNode);return t.index_.compare(s,r)}/**
1280
1280
  * @license
1281
1281
  * Copyright 2017 Google LLC
1282
1282
  *
@@ -1306,7 +1306,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1306
1306
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1307
1307
  * See the License for the specific language governing permissions and
1308
1308
  * limitations under the License.
1309
- */let Wo;const M0=()=>(Wo||(Wo=new je(b2)),Wo);class he{static fromObject(e){let n=new he(null);return Ke(e,(s,r)=>{n=n.set(new re(s),r)}),n}constructor(e,n=M0()){this.value=e,this.children=n}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,n){if(this.value!=null&&n(this.value))return{path:J(),value:this.value};if(G(e))return null;{const s=H(e),r=this.children.get(s);if(r!==null){const i=r.findRootMostMatchingPathAndValue(oe(e),n);return i!=null?{path:ke(new re(s),i.path),value:i.value}:null}else return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(G(e))return this;{const n=H(e),s=this.children.get(n);return s!==null?s.subtree(oe(e)):new he(null)}}set(e,n){if(G(e))return new he(n,this.children);{const s=H(e),i=(this.children.get(s)||new he(null)).set(oe(e),n),o=this.children.insert(s,i);return new he(this.value,o)}}remove(e){if(G(e))return this.children.isEmpty()?new he(null):new he(null,this.children);{const n=H(e),s=this.children.get(n);if(s){const r=s.remove(oe(e));let i;return r.isEmpty()?i=this.children.remove(n):i=this.children.insert(n,r),this.value===null&&i.isEmpty()?new he(null):new he(this.value,i)}else return this}}get(e){if(G(e))return this.value;{const n=H(e),s=this.children.get(n);return s?s.get(oe(e)):null}}setTree(e,n){if(G(e))return n;{const s=H(e),i=(this.children.get(s)||new he(null)).setTree(oe(e),n);let o;return i.isEmpty()?o=this.children.remove(s):o=this.children.insert(s,i),new he(this.value,o)}}fold(e){return this.fold_(J(),e)}fold_(e,n){const s={};return this.children.inorderTraversal((r,i)=>{s[r]=i.fold_(ke(e,r),n)}),n(e,this.value,s)}findOnPath(e,n){return this.findOnPath_(e,J(),n)}findOnPath_(e,n,s){const r=this.value?s(n,this.value):!1;if(r)return r;if(G(e))return null;{const i=H(e),o=this.children.get(i);return o?o.findOnPath_(oe(e),ke(n,i),s):null}}foreachOnPath(e,n){return this.foreachOnPath_(e,J(),n)}foreachOnPath_(e,n,s){if(G(e))return this;{this.value&&s(n,this.value);const r=H(e),i=this.children.get(r);return i?i.foreachOnPath_(oe(e),ke(n,r),s):new he(null)}}foreach(e){this.foreach_(J(),e)}foreach_(e,n){this.children.inorderTraversal((s,r)=>{r.foreach_(ke(e,s),n)}),this.value&&n(e,this.value)}foreachChild(e){this.children.inorderTraversal((n,s)=>{s.value&&e(n,s.value)})}}/**
1309
+ */let Go;const M0=()=>(Go||(Go=new je(b2)),Go);class he{static fromObject(e){let n=new he(null);return Ke(e,(s,r)=>{n=n.set(new re(s),r)}),n}constructor(e,n=M0()){this.value=e,this.children=n}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,n){if(this.value!=null&&n(this.value))return{path:J(),value:this.value};if(W(e))return null;{const s=H(e),r=this.children.get(s);if(r!==null){const i=r.findRootMostMatchingPathAndValue(oe(e),n);return i!=null?{path:ke(new re(s),i.path),value:i.value}:null}else return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(W(e))return this;{const n=H(e),s=this.children.get(n);return s!==null?s.subtree(oe(e)):new he(null)}}set(e,n){if(W(e))return new he(n,this.children);{const s=H(e),i=(this.children.get(s)||new he(null)).set(oe(e),n),o=this.children.insert(s,i);return new he(this.value,o)}}remove(e){if(W(e))return this.children.isEmpty()?new he(null):new he(null,this.children);{const n=H(e),s=this.children.get(n);if(s){const r=s.remove(oe(e));let i;return r.isEmpty()?i=this.children.remove(n):i=this.children.insert(n,r),this.value===null&&i.isEmpty()?new he(null):new he(this.value,i)}else return this}}get(e){if(W(e))return this.value;{const n=H(e),s=this.children.get(n);return s?s.get(oe(e)):null}}setTree(e,n){if(W(e))return n;{const s=H(e),i=(this.children.get(s)||new he(null)).setTree(oe(e),n);let o;return i.isEmpty()?o=this.children.remove(s):o=this.children.insert(s,i),new he(this.value,o)}}fold(e){return this.fold_(J(),e)}fold_(e,n){const s={};return this.children.inorderTraversal((r,i)=>{s[r]=i.fold_(ke(e,r),n)}),n(e,this.value,s)}findOnPath(e,n){return this.findOnPath_(e,J(),n)}findOnPath_(e,n,s){const r=this.value?s(n,this.value):!1;if(r)return r;if(W(e))return null;{const i=H(e),o=this.children.get(i);return o?o.findOnPath_(oe(e),ke(n,i),s):null}}foreachOnPath(e,n){return this.foreachOnPath_(e,J(),n)}foreachOnPath_(e,n,s){if(W(e))return this;{this.value&&s(n,this.value);const r=H(e),i=this.children.get(r);return i?i.foreachOnPath_(oe(e),ke(n,r),s):new he(null)}}foreach(e){this.foreach_(J(),e)}foreach_(e,n){this.children.inorderTraversal((s,r)=>{r.foreach_(ke(e,s),n)}),this.value&&n(e,this.value)}foreachChild(e){this.children.inorderTraversal((n,s)=>{s.value&&e(n,s.value)})}}/**
1310
1310
  * @license
1311
1311
  * Copyright 2017 Google LLC
1312
1312
  *
@@ -1321,7 +1321,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1321
1321
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1322
1322
  * See the License for the specific language governing permissions and
1323
1323
  * limitations under the License.
1324
- */class Tt{constructor(e){this.writeTree_=e}static empty(){return new Tt(new he(null))}}function tr(t,e,n){if(G(e))return new Tt(new he(n));{const s=t.writeTree_.findRootMostValueAndPath(e);if(s!=null){const r=s.path;let i=s.value;const o=$e(r,e);return i=i.updateChild(o,n),new Tt(t.writeTree_.set(r,i))}else{const r=new he(n),i=t.writeTree_.setTree(e,r);return new Tt(i)}}}function xh(t,e,n){let s=t;return Ke(n,(r,i)=>{s=tr(s,ke(e,r),i)}),s}function Oh(t,e){if(G(e))return Tt.empty();{const n=t.writeTree_.setTree(e,new he(null));return new Tt(n)}}function Aa(t,e){return Un(t,e)!=null}function Un(t,e){const n=t.writeTree_.findRootMostValueAndPath(e);return n!=null?t.writeTree_.get(n.path).getChild($e(n.path,e)):null}function Lh(t){const e=[],n=t.writeTree_.value;return n!=null?n.isLeafNode()||n.forEachChild(ye,(s,r)=>{e.push(new B(s,r))}):t.writeTree_.children.inorderTraversal((s,r)=>{r.value!=null&&e.push(new B(s,r.value))}),e}function an(t,e){if(G(e))return t;{const n=Un(t,e);return n!=null?new Tt(new he(n)):new Tt(t.writeTree_.subtree(e))}}function Ra(t){return t.writeTree_.isEmpty()}function ds(t,e){return fp(J(),t.writeTree_,e)}function fp(t,e,n){if(e.value!=null)return n.updateChild(t,e.value);{let s=null;return e.children.inorderTraversal((r,i)=>{r===".priority"?(b(i.value!==null,"Priority writes must always be leaf nodes"),s=i.value):n=fp(ke(t,r),i,n)}),!n.getChild(t).isEmpty()&&s!==null&&(n=n.updateChild(ke(t,".priority"),s)),n}}/**
1324
+ */class Tt{constructor(e){this.writeTree_=e}static empty(){return new Tt(new he(null))}}function tr(t,e,n){if(W(e))return new Tt(new he(n));{const s=t.writeTree_.findRootMostValueAndPath(e);if(s!=null){const r=s.path;let i=s.value;const o=$e(r,e);return i=i.updateChild(o,n),new Tt(t.writeTree_.set(r,i))}else{const r=new he(n),i=t.writeTree_.setTree(e,r);return new Tt(i)}}}function xh(t,e,n){let s=t;return Ke(n,(r,i)=>{s=tr(s,ke(e,r),i)}),s}function Oh(t,e){if(W(e))return Tt.empty();{const n=t.writeTree_.setTree(e,new he(null));return new Tt(n)}}function Aa(t,e){return Un(t,e)!=null}function Un(t,e){const n=t.writeTree_.findRootMostValueAndPath(e);return n!=null?t.writeTree_.get(n.path).getChild($e(n.path,e)):null}function Lh(t){const e=[],n=t.writeTree_.value;return n!=null?n.isLeafNode()||n.forEachChild(ye,(s,r)=>{e.push(new B(s,r))}):t.writeTree_.children.inorderTraversal((s,r)=>{r.value!=null&&e.push(new B(s,r.value))}),e}function an(t,e){if(W(e))return t;{const n=Un(t,e);return n!=null?new Tt(new he(n)):new Tt(t.writeTree_.subtree(e))}}function Ra(t){return t.writeTree_.isEmpty()}function ds(t,e){return fp(J(),t.writeTree_,e)}function fp(t,e,n){if(e.value!=null)return n.updateChild(t,e.value);{let s=null;return e.children.inorderTraversal((r,i)=>{r===".priority"?(b(i.value!==null,"Priority writes must always be leaf nodes"),s=i.value):n=fp(ke(t,r),i,n)}),!n.getChild(t).isEmpty()&&s!==null&&(n=n.updateChild(ke(t,".priority"),s)),n}}/**
1325
1325
  * @license
1326
1326
  * Copyright 2017 Google LLC
1327
1327
  *
@@ -1336,7 +1336,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1336
1336
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1337
1337
  * See the License for the specific language governing permissions and
1338
1338
  * limitations under the License.
1339
- */function Cc(t,e){return _p(e,t)}function B0(t,e,n,s,r){b(s>t.lastWriteId,"Stacking an older write on top of newer ones"),r===void 0&&(r=!0),t.allWrites.push({path:e,snap:n,writeId:s,visible:r}),r&&(t.visibleWrites=tr(t.visibleWrites,e,n)),t.lastWriteId=s}function U0(t,e){for(let n=0;n<t.allWrites.length;n++){const s=t.allWrites[n];if(s.writeId===e)return s}return null}function V0(t,e){const n=t.allWrites.findIndex(a=>a.writeId===e);b(n>=0,"removeWrite called with nonexistent writeId.");const s=t.allWrites[n];t.allWrites.splice(n,1);let r=s.visible,i=!1,o=t.allWrites.length-1;for(;r&&o>=0;){const a=t.allWrites[o];a.visible&&(o>=n&&H0(a,s.path)?r=!1:wt(s.path,a.path)&&(i=!0)),o--}if(r){if(i)return G0(t),!0;if(s.snap)t.visibleWrites=Oh(t.visibleWrites,s.path);else{const a=s.children;Ke(a,c=>{t.visibleWrites=Oh(t.visibleWrites,ke(s.path,c))})}return!0}else return!1}function H0(t,e){if(t.snap)return wt(t.path,e);for(const n in t.children)if(t.children.hasOwnProperty(n)&&wt(ke(t.path,n),e))return!0;return!1}function G0(t){t.visibleWrites=pp(t.allWrites,W0,J()),t.allWrites.length>0?t.lastWriteId=t.allWrites[t.allWrites.length-1].writeId:t.lastWriteId=-1}function W0(t){return t.visible}function pp(t,e,n){let s=Tt.empty();for(let r=0;r<t.length;++r){const i=t[r];if(e(i)){const o=i.path;let a;if(i.snap)wt(n,o)?(a=$e(n,o),s=tr(s,a,i.snap)):wt(o,n)&&(a=$e(o,n),s=tr(s,J(),i.snap.getChild(a)));else if(i.children){if(wt(n,o))a=$e(n,o),s=xh(s,a,i.children);else if(wt(o,n))if(a=$e(o,n),G(a))s=xh(s,J(),i.children);else{const c=ls(i.children,H(a));if(c){const l=c.getChild(oe(a));s=tr(s,J(),l)}}}else throw Ts("WriteRecord should have .snap or .children")}}return s}function mp(t,e,n,s,r){if(!s&&!r){const i=Un(t.visibleWrites,e);if(i!=null)return i;{const o=an(t.visibleWrites,e);if(Ra(o))return n;if(n==null&&!Aa(o,J()))return null;{const a=n||F.EMPTY_NODE;return ds(o,a)}}}else{const i=an(t.visibleWrites,e);if(!r&&Ra(i))return n;if(!r&&n==null&&!Aa(i,J()))return null;{const o=function(l){return(l.visible||r)&&(!s||!~s.indexOf(l.writeId))&&(wt(l.path,e)||wt(e,l.path))},a=pp(t.allWrites,o,e),c=n||F.EMPTY_NODE;return ds(a,c)}}}function $0(t,e,n){let s=F.EMPTY_NODE;const r=Un(t.visibleWrites,e);if(r)return r.isLeafNode()||r.forEachChild(ye,(i,o)=>{s=s.updateImmediateChild(i,o)}),s;if(n){const i=an(t.visibleWrites,e);return n.forEachChild(ye,(o,a)=>{const c=ds(an(i,new re(o)),a);s=s.updateImmediateChild(o,c)}),Lh(i).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}else{const i=an(t.visibleWrites,e);return Lh(i).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}}function j0(t,e,n,s,r){b(s||r,"Either existingEventSnap or existingServerSnap must exist");const i=ke(e,n);if(Aa(t.visibleWrites,i))return null;{const o=an(t.visibleWrites,i);return Ra(o)?r.getChild(n):ds(o,r.getChild(n))}}function q0(t,e,n,s){const r=ke(e,n),i=Un(t.visibleWrites,r);if(i!=null)return i;if(s.isCompleteForChild(n)){const o=an(t.visibleWrites,r);return ds(o,s.getNode().getImmediateChild(n))}else return null}function z0(t,e){return Un(t.visibleWrites,e)}function K0(t,e,n,s,r,i,o){let a;const c=an(t.visibleWrites,e),l=Un(c,J());if(l!=null)a=l;else if(n!=null)a=ds(c,n);else return[];if(a=a.withIndex(o),!a.isEmpty()&&!a.isLeafNode()){const h=[],u=o.getCompare(),d=i?a.getReverseIteratorFrom(s,o):a.getIteratorFrom(s,o);let p=d.getNext();for(;p&&h.length<r;)u(p,s)!==0&&h.push(p),p=d.getNext();return h}else return[]}function Y0(){return{visibleWrites:Tt.empty(),allWrites:[],lastWriteId:-1}}function bi(t,e,n,s){return mp(t.writeTree,t.treePath,e,n,s)}function Sc(t,e){return $0(t.writeTree,t.treePath,e)}function Dh(t,e,n,s){return j0(t.writeTree,t.treePath,e,n,s)}function Ti(t,e){return z0(t.writeTree,ke(t.treePath,e))}function X0(t,e,n,s,r,i){return K0(t.writeTree,t.treePath,e,n,s,r,i)}function Ac(t,e,n){return q0(t.writeTree,t.treePath,e,n)}function gp(t,e){return _p(ke(t.treePath,e),t.writeTree)}function _p(t,e){return{treePath:t,writeTree:e}}/**
1339
+ */function Cc(t,e){return _p(e,t)}function B0(t,e,n,s,r){b(s>t.lastWriteId,"Stacking an older write on top of newer ones"),r===void 0&&(r=!0),t.allWrites.push({path:e,snap:n,writeId:s,visible:r}),r&&(t.visibleWrites=tr(t.visibleWrites,e,n)),t.lastWriteId=s}function U0(t,e){for(let n=0;n<t.allWrites.length;n++){const s=t.allWrites[n];if(s.writeId===e)return s}return null}function V0(t,e){const n=t.allWrites.findIndex(a=>a.writeId===e);b(n>=0,"removeWrite called with nonexistent writeId.");const s=t.allWrites[n];t.allWrites.splice(n,1);let r=s.visible,i=!1,o=t.allWrites.length-1;for(;r&&o>=0;){const a=t.allWrites[o];a.visible&&(o>=n&&H0(a,s.path)?r=!1:wt(s.path,a.path)&&(i=!0)),o--}if(r){if(i)return W0(t),!0;if(s.snap)t.visibleWrites=Oh(t.visibleWrites,s.path);else{const a=s.children;Ke(a,c=>{t.visibleWrites=Oh(t.visibleWrites,ke(s.path,c))})}return!0}else return!1}function H0(t,e){if(t.snap)return wt(t.path,e);for(const n in t.children)if(t.children.hasOwnProperty(n)&&wt(ke(t.path,n),e))return!0;return!1}function W0(t){t.visibleWrites=pp(t.allWrites,G0,J()),t.allWrites.length>0?t.lastWriteId=t.allWrites[t.allWrites.length-1].writeId:t.lastWriteId=-1}function G0(t){return t.visible}function pp(t,e,n){let s=Tt.empty();for(let r=0;r<t.length;++r){const i=t[r];if(e(i)){const o=i.path;let a;if(i.snap)wt(n,o)?(a=$e(n,o),s=tr(s,a,i.snap)):wt(o,n)&&(a=$e(o,n),s=tr(s,J(),i.snap.getChild(a)));else if(i.children){if(wt(n,o))a=$e(n,o),s=xh(s,a,i.children);else if(wt(o,n))if(a=$e(o,n),W(a))s=xh(s,J(),i.children);else{const c=ls(i.children,H(a));if(c){const l=c.getChild(oe(a));s=tr(s,J(),l)}}}else throw Ts("WriteRecord should have .snap or .children")}}return s}function mp(t,e,n,s,r){if(!s&&!r){const i=Un(t.visibleWrites,e);if(i!=null)return i;{const o=an(t.visibleWrites,e);if(Ra(o))return n;if(n==null&&!Aa(o,J()))return null;{const a=n||F.EMPTY_NODE;return ds(o,a)}}}else{const i=an(t.visibleWrites,e);if(!r&&Ra(i))return n;if(!r&&n==null&&!Aa(i,J()))return null;{const o=function(l){return(l.visible||r)&&(!s||!~s.indexOf(l.writeId))&&(wt(l.path,e)||wt(e,l.path))},a=pp(t.allWrites,o,e),c=n||F.EMPTY_NODE;return ds(a,c)}}}function $0(t,e,n){let s=F.EMPTY_NODE;const r=Un(t.visibleWrites,e);if(r)return r.isLeafNode()||r.forEachChild(ye,(i,o)=>{s=s.updateImmediateChild(i,o)}),s;if(n){const i=an(t.visibleWrites,e);return n.forEachChild(ye,(o,a)=>{const c=ds(an(i,new re(o)),a);s=s.updateImmediateChild(o,c)}),Lh(i).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}else{const i=an(t.visibleWrites,e);return Lh(i).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}}function j0(t,e,n,s,r){b(s||r,"Either existingEventSnap or existingServerSnap must exist");const i=ke(e,n);if(Aa(t.visibleWrites,i))return null;{const o=an(t.visibleWrites,i);return Ra(o)?r.getChild(n):ds(o,r.getChild(n))}}function q0(t,e,n,s){const r=ke(e,n),i=Un(t.visibleWrites,r);if(i!=null)return i;if(s.isCompleteForChild(n)){const o=an(t.visibleWrites,r);return ds(o,s.getNode().getImmediateChild(n))}else return null}function z0(t,e){return Un(t.visibleWrites,e)}function K0(t,e,n,s,r,i,o){let a;const c=an(t.visibleWrites,e),l=Un(c,J());if(l!=null)a=l;else if(n!=null)a=ds(c,n);else return[];if(a=a.withIndex(o),!a.isEmpty()&&!a.isLeafNode()){const h=[],u=o.getCompare(),d=i?a.getReverseIteratorFrom(s,o):a.getIteratorFrom(s,o);let p=d.getNext();for(;p&&h.length<r;)u(p,s)!==0&&h.push(p),p=d.getNext();return h}else return[]}function Y0(){return{visibleWrites:Tt.empty(),allWrites:[],lastWriteId:-1}}function bi(t,e,n,s){return mp(t.writeTree,t.treePath,e,n,s)}function Sc(t,e){return $0(t.writeTree,t.treePath,e)}function Dh(t,e,n,s){return j0(t.writeTree,t.treePath,e,n,s)}function Ti(t,e){return z0(t.writeTree,ke(t.treePath,e))}function X0(t,e,n,s,r,i){return K0(t.writeTree,t.treePath,e,n,s,r,i)}function Ac(t,e,n){return q0(t.writeTree,t.treePath,e,n)}function gp(t,e){return _p(ke(t.treePath,e),t.writeTree)}function _p(t,e){return{treePath:t,writeTree:e}}/**
1340
1340
  * @license
1341
1341
  * Copyright 2017 Google LLC
1342
1342
  *
@@ -1381,7 +1381,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1381
1381
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1382
1382
  * See the License for the specific language governing permissions and
1383
1383
  * limitations under the License.
1384
- */function Z0(t){return{filter:t}}function ey(t,e){b(e.eventCache.getNode().isIndexed(t.filter.getIndex()),"Event snap not indexed"),b(e.serverCache.getNode().isIndexed(t.filter.getIndex()),"Server snap not indexed")}function ty(t,e,n,s,r){const i=new J0;let o,a;if(n.type===bt.OVERWRITE){const l=n;l.source.fromUser?o=ka(t,e,l.path,l.snap,s,r,i):(b(l.source.fromServer,"Unknown source."),a=l.source.tagged||e.serverCache.isFiltered()&&!G(l.path),o=Ci(t,e,l.path,l.snap,s,r,a,i))}else if(n.type===bt.MERGE){const l=n;l.source.fromUser?o=sy(t,e,l.path,l.children,s,r,i):(b(l.source.fromServer,"Unknown source."),a=l.source.tagged||e.serverCache.isFiltered(),o=Ia(t,e,l.path,l.children,s,r,a,i))}else if(n.type===bt.ACK_USER_WRITE){const l=n;l.revert?o=oy(t,e,l.path,s,r,i):o=ry(t,e,l.path,l.affectedTree,s,r,i)}else if(n.type===bt.LISTEN_COMPLETE)o=iy(t,e,n.path,s,i);else throw Ts("Unknown operation type: "+n.type);const c=i.getChanges();return ny(e,o,c),{viewCache:o,changes:c}}function ny(t,e,n){const s=e.eventCache;if(s.isFullyInitialized()){const r=s.getNode().isLeafNode()||s.getNode().isEmpty(),i=Sa(t);(n.length>0||!t.eventCache.isFullyInitialized()||r&&!s.getNode().equals(i)||!s.getNode().getPriority().equals(i.getPriority()))&&n.push(lp(Sa(e)))}}function Ep(t,e,n,s,r,i){const o=e.eventCache;if(Ti(s,n)!=null)return e;{let a,c;if(G(n))if(b(e.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),e.serverCache.isFiltered()){const l=Pn(e),h=l instanceof F?l:F.EMPTY_NODE,u=Sc(s,h);a=t.filter.updateFullNode(e.eventCache.getNode(),u,i)}else{const l=bi(s,Pn(e));a=t.filter.updateFullNode(e.eventCache.getNode(),l,i)}else{const l=H(n);if(l===".priority"){b(un(n)===1,"Can't have a priority with additional path components");const h=o.getNode();c=e.serverCache.getNode();const u=Dh(s,n,h,c);u!=null?a=t.filter.updatePriority(h,u):a=o.getNode()}else{const h=oe(n);let u;if(o.isCompleteForChild(l)){c=e.serverCache.getNode();const d=Dh(s,n,o.getNode(),c);d!=null?u=o.getNode().getImmediateChild(l).updateChild(h,d):u=o.getNode().getImmediateChild(l)}else u=Ac(s,l,e.serverCache);u!=null?a=t.filter.updateChild(o.getNode(),l,u,h,r,i):a=o.getNode()}}return er(e,a,o.isFullyInitialized()||G(n),t.filter.filtersNodes())}}function Ci(t,e,n,s,r,i,o,a){const c=e.serverCache;let l;const h=o?t.filter:t.filter.getIndexedFilter();if(G(n))l=h.updateFullNode(c.getNode(),s,null);else if(h.filtersNodes()&&!c.isFiltered()){const p=c.getNode().updateChild(n,s);l=h.updateFullNode(c.getNode(),p,null)}else{const p=H(n);if(!c.isCompleteForPath(n)&&un(n)>1)return e;const f=oe(n),E=c.getNode().getImmediateChild(p).updateChild(f,s);p===".priority"?l=h.updatePriority(c.getNode(),E):l=h.updateChild(c.getNode(),p,E,f,yp,null)}const u=dp(e,l,c.isFullyInitialized()||G(n),h.filtersNodes()),d=new Rc(r,u,i);return Ep(t,u,n,r,d,a)}function ka(t,e,n,s,r,i,o){const a=e.eventCache;let c,l;const h=new Rc(r,e,i);if(G(n))l=t.filter.updateFullNode(e.eventCache.getNode(),s,o),c=er(e,l,!0,t.filter.filtersNodes());else{const u=H(n);if(u===".priority")l=t.filter.updatePriority(e.eventCache.getNode(),s),c=er(e,l,a.isFullyInitialized(),a.isFiltered());else{const d=oe(n),p=a.getNode().getImmediateChild(u);let f;if(G(d))f=s;else{const g=h.getCompleteChild(u);g!=null?ep(d)===".priority"&&g.getChild(np(d)).isEmpty()?f=g:f=g.updateChild(d,s):f=F.EMPTY_NODE}if(p.equals(f))c=e;else{const g=t.filter.updateChild(a.getNode(),u,f,d,h,o);c=er(e,g,a.isFullyInitialized(),t.filter.filtersNodes())}}}return c}function Ph(t,e){return t.eventCache.isCompleteForChild(e)}function sy(t,e,n,s,r,i,o){let a=e;return s.foreach((c,l)=>{const h=ke(n,c);Ph(e,H(h))&&(a=ka(t,a,h,l,r,i,o))}),s.foreach((c,l)=>{const h=ke(n,c);Ph(e,H(h))||(a=ka(t,a,h,l,r,i,o))}),a}function Fh(t,e,n){return n.foreach((s,r)=>{e=e.updateChild(s,r)}),e}function Ia(t,e,n,s,r,i,o,a){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let c=e,l;G(n)?l=s:l=new he(null).setTree(n,s);const h=e.serverCache.getNode();return l.children.inorderTraversal((u,d)=>{if(h.hasChild(u)){const p=e.serverCache.getNode().getImmediateChild(u),f=Fh(t,p,d);c=Ci(t,c,new re(u),f,r,i,o,a)}}),l.children.inorderTraversal((u,d)=>{const p=!e.serverCache.isCompleteForChild(u)&&d.value===null;if(!h.hasChild(u)&&!p){const f=e.serverCache.getNode().getImmediateChild(u),g=Fh(t,f,d);c=Ci(t,c,new re(u),g,r,i,o,a)}}),c}function ry(t,e,n,s,r,i,o){if(Ti(r,n)!=null)return e;const a=e.serverCache.isFiltered(),c=e.serverCache;if(s.value!=null){if(G(n)&&c.isFullyInitialized()||c.isCompleteForPath(n))return Ci(t,e,n,c.getNode().getChild(n),r,i,a,o);if(G(n)){let l=new he(null);return c.getNode().forEachChild(ts,(h,u)=>{l=l.set(new re(h),u)}),Ia(t,e,n,l,r,i,a,o)}else return e}else{let l=new he(null);return s.foreach((h,u)=>{const d=ke(n,h);c.isCompleteForPath(d)&&(l=l.set(h,c.getNode().getChild(d)))}),Ia(t,e,n,l,r,i,a,o)}}function iy(t,e,n,s,r){const i=e.serverCache,o=dp(e,i.getNode(),i.isFullyInitialized()||G(n),i.isFiltered());return Ep(t,o,n,s,yp,r)}function oy(t,e,n,s,r,i){let o;if(Ti(s,n)!=null)return e;{const a=new Rc(s,e,r),c=e.eventCache.getNode();let l;if(G(n)||H(n)===".priority"){let h;if(e.serverCache.isFullyInitialized())h=bi(s,Pn(e));else{const u=e.serverCache.getNode();b(u instanceof F,"serverChildren would be complete if leaf node"),h=Sc(s,u)}h=h,l=t.filter.updateFullNode(c,h,i)}else{const h=H(n);let u=Ac(s,h,e.serverCache);u==null&&e.serverCache.isCompleteForChild(h)&&(u=c.getImmediateChild(h)),u!=null?l=t.filter.updateChild(c,h,u,oe(n),a,i):e.eventCache.getNode().hasChild(h)?l=t.filter.updateChild(c,h,F.EMPTY_NODE,oe(n),a,i):l=c,l.isEmpty()&&e.serverCache.isFullyInitialized()&&(o=bi(s,Pn(e)),o.isLeafNode()&&(l=t.filter.updateFullNode(l,o,i)))}return o=e.serverCache.isFullyInitialized()||Ti(s,J())!=null,er(e,l,o,t.filter.filtersNodes())}}/**
1384
+ */function Z0(t){return{filter:t}}function ey(t,e){b(e.eventCache.getNode().isIndexed(t.filter.getIndex()),"Event snap not indexed"),b(e.serverCache.getNode().isIndexed(t.filter.getIndex()),"Server snap not indexed")}function ty(t,e,n,s,r){const i=new J0;let o,a;if(n.type===bt.OVERWRITE){const l=n;l.source.fromUser?o=ka(t,e,l.path,l.snap,s,r,i):(b(l.source.fromServer,"Unknown source."),a=l.source.tagged||e.serverCache.isFiltered()&&!W(l.path),o=Ci(t,e,l.path,l.snap,s,r,a,i))}else if(n.type===bt.MERGE){const l=n;l.source.fromUser?o=sy(t,e,l.path,l.children,s,r,i):(b(l.source.fromServer,"Unknown source."),a=l.source.tagged||e.serverCache.isFiltered(),o=Ia(t,e,l.path,l.children,s,r,a,i))}else if(n.type===bt.ACK_USER_WRITE){const l=n;l.revert?o=oy(t,e,l.path,s,r,i):o=ry(t,e,l.path,l.affectedTree,s,r,i)}else if(n.type===bt.LISTEN_COMPLETE)o=iy(t,e,n.path,s,i);else throw Ts("Unknown operation type: "+n.type);const c=i.getChanges();return ny(e,o,c),{viewCache:o,changes:c}}function ny(t,e,n){const s=e.eventCache;if(s.isFullyInitialized()){const r=s.getNode().isLeafNode()||s.getNode().isEmpty(),i=Sa(t);(n.length>0||!t.eventCache.isFullyInitialized()||r&&!s.getNode().equals(i)||!s.getNode().getPriority().equals(i.getPriority()))&&n.push(lp(Sa(e)))}}function Ep(t,e,n,s,r,i){const o=e.eventCache;if(Ti(s,n)!=null)return e;{let a,c;if(W(n))if(b(e.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),e.serverCache.isFiltered()){const l=Pn(e),h=l instanceof F?l:F.EMPTY_NODE,u=Sc(s,h);a=t.filter.updateFullNode(e.eventCache.getNode(),u,i)}else{const l=bi(s,Pn(e));a=t.filter.updateFullNode(e.eventCache.getNode(),l,i)}else{const l=H(n);if(l===".priority"){b(un(n)===1,"Can't have a priority with additional path components");const h=o.getNode();c=e.serverCache.getNode();const u=Dh(s,n,h,c);u!=null?a=t.filter.updatePriority(h,u):a=o.getNode()}else{const h=oe(n);let u;if(o.isCompleteForChild(l)){c=e.serverCache.getNode();const d=Dh(s,n,o.getNode(),c);d!=null?u=o.getNode().getImmediateChild(l).updateChild(h,d):u=o.getNode().getImmediateChild(l)}else u=Ac(s,l,e.serverCache);u!=null?a=t.filter.updateChild(o.getNode(),l,u,h,r,i):a=o.getNode()}}return er(e,a,o.isFullyInitialized()||W(n),t.filter.filtersNodes())}}function Ci(t,e,n,s,r,i,o,a){const c=e.serverCache;let l;const h=o?t.filter:t.filter.getIndexedFilter();if(W(n))l=h.updateFullNode(c.getNode(),s,null);else if(h.filtersNodes()&&!c.isFiltered()){const p=c.getNode().updateChild(n,s);l=h.updateFullNode(c.getNode(),p,null)}else{const p=H(n);if(!c.isCompleteForPath(n)&&un(n)>1)return e;const f=oe(n),E=c.getNode().getImmediateChild(p).updateChild(f,s);p===".priority"?l=h.updatePriority(c.getNode(),E):l=h.updateChild(c.getNode(),p,E,f,yp,null)}const u=dp(e,l,c.isFullyInitialized()||W(n),h.filtersNodes()),d=new Rc(r,u,i);return Ep(t,u,n,r,d,a)}function ka(t,e,n,s,r,i,o){const a=e.eventCache;let c,l;const h=new Rc(r,e,i);if(W(n))l=t.filter.updateFullNode(e.eventCache.getNode(),s,o),c=er(e,l,!0,t.filter.filtersNodes());else{const u=H(n);if(u===".priority")l=t.filter.updatePriority(e.eventCache.getNode(),s),c=er(e,l,a.isFullyInitialized(),a.isFiltered());else{const d=oe(n),p=a.getNode().getImmediateChild(u);let f;if(W(d))f=s;else{const g=h.getCompleteChild(u);g!=null?ep(d)===".priority"&&g.getChild(np(d)).isEmpty()?f=g:f=g.updateChild(d,s):f=F.EMPTY_NODE}if(p.equals(f))c=e;else{const g=t.filter.updateChild(a.getNode(),u,f,d,h,o);c=er(e,g,a.isFullyInitialized(),t.filter.filtersNodes())}}}return c}function Ph(t,e){return t.eventCache.isCompleteForChild(e)}function sy(t,e,n,s,r,i,o){let a=e;return s.foreach((c,l)=>{const h=ke(n,c);Ph(e,H(h))&&(a=ka(t,a,h,l,r,i,o))}),s.foreach((c,l)=>{const h=ke(n,c);Ph(e,H(h))||(a=ka(t,a,h,l,r,i,o))}),a}function Fh(t,e,n){return n.foreach((s,r)=>{e=e.updateChild(s,r)}),e}function Ia(t,e,n,s,r,i,o,a){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let c=e,l;W(n)?l=s:l=new he(null).setTree(n,s);const h=e.serverCache.getNode();return l.children.inorderTraversal((u,d)=>{if(h.hasChild(u)){const p=e.serverCache.getNode().getImmediateChild(u),f=Fh(t,p,d);c=Ci(t,c,new re(u),f,r,i,o,a)}}),l.children.inorderTraversal((u,d)=>{const p=!e.serverCache.isCompleteForChild(u)&&d.value===null;if(!h.hasChild(u)&&!p){const f=e.serverCache.getNode().getImmediateChild(u),g=Fh(t,f,d);c=Ci(t,c,new re(u),g,r,i,o,a)}}),c}function ry(t,e,n,s,r,i,o){if(Ti(r,n)!=null)return e;const a=e.serverCache.isFiltered(),c=e.serverCache;if(s.value!=null){if(W(n)&&c.isFullyInitialized()||c.isCompleteForPath(n))return Ci(t,e,n,c.getNode().getChild(n),r,i,a,o);if(W(n)){let l=new he(null);return c.getNode().forEachChild(ts,(h,u)=>{l=l.set(new re(h),u)}),Ia(t,e,n,l,r,i,a,o)}else return e}else{let l=new he(null);return s.foreach((h,u)=>{const d=ke(n,h);c.isCompleteForPath(d)&&(l=l.set(h,c.getNode().getChild(d)))}),Ia(t,e,n,l,r,i,a,o)}}function iy(t,e,n,s,r){const i=e.serverCache,o=dp(e,i.getNode(),i.isFullyInitialized()||W(n),i.isFiltered());return Ep(t,o,n,s,yp,r)}function oy(t,e,n,s,r,i){let o;if(Ti(s,n)!=null)return e;{const a=new Rc(s,e,r),c=e.eventCache.getNode();let l;if(W(n)||H(n)===".priority"){let h;if(e.serverCache.isFullyInitialized())h=bi(s,Pn(e));else{const u=e.serverCache.getNode();b(u instanceof F,"serverChildren would be complete if leaf node"),h=Sc(s,u)}h=h,l=t.filter.updateFullNode(c,h,i)}else{const h=H(n);let u=Ac(s,h,e.serverCache);u==null&&e.serverCache.isCompleteForChild(h)&&(u=c.getImmediateChild(h)),u!=null?l=t.filter.updateChild(c,h,u,oe(n),a,i):e.eventCache.getNode().hasChild(h)?l=t.filter.updateChild(c,h,F.EMPTY_NODE,oe(n),a,i):l=c,l.isEmpty()&&e.serverCache.isFullyInitialized()&&(o=bi(s,Pn(e)),o.isLeafNode()&&(l=t.filter.updateFullNode(l,o,i)))}return o=e.serverCache.isFullyInitialized()||Ti(s,J())!=null,er(e,l,o,t.filter.filtersNodes())}}/**
1385
1385
  * @license
1386
1386
  * Copyright 2017 Google LLC
1387
1387
  *
@@ -1396,7 +1396,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1396
1396
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1397
1397
  * See the License for the specific language governing permissions and
1398
1398
  * limitations under the License.
1399
- */class ay{constructor(e,n){this.query_=e,this.eventRegistrations_=[];const s=this.query_._queryParams,r=new vc(s.getIndex()),i=A0(s);this.processor_=Z0(i);const o=n.serverCache,a=n.eventCache,c=r.updateFullNode(F.EMPTY_NODE,o.getNode(),null),l=i.updateFullNode(F.EMPTY_NODE,a.getNode(),null),h=new Dn(c,o.isFullyInitialized(),r.filtersNodes()),u=new Dn(l,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=qi(u,h),this.eventGenerator_=new L0(this.query_)}get query(){return this.query_}}function cy(t){return t.viewCache_.serverCache.getNode()}function ly(t,e){const n=Pn(t.viewCache_);return n&&(t.query._queryParams.loadsAllData()||!G(e)&&!n.getImmediateChild(H(e)).isEmpty())?n.getChild(e):null}function Mh(t){return t.eventRegistrations_.length===0}function hy(t,e){t.eventRegistrations_.push(e)}function Bh(t,e,n){const s=[];if(n){b(e==null,"A cancel should cancel all event registrations.");const r=t.query._path;t.eventRegistrations_.forEach(i=>{const o=i.createCancelEvent(n,r);o&&s.push(o)})}if(e){let r=[];for(let i=0;i<t.eventRegistrations_.length;++i){const o=t.eventRegistrations_[i];if(!o.matches(e))r.push(o);else if(e.hasAnyCallback()){r=r.concat(t.eventRegistrations_.slice(i+1));break}}t.eventRegistrations_=r}else t.eventRegistrations_=[];return s}function Uh(t,e,n,s){e.type===bt.MERGE&&e.source.queryId!==null&&(b(Pn(t.viewCache_),"We should always have a full cache before handling merges"),b(Sa(t.viewCache_),"Missing event cache, even though we have a server cache"));const r=t.viewCache_,i=ty(t.processor_,r,e,n,s);return ey(t.processor_,i.viewCache),b(i.viewCache.serverCache.isFullyInitialized()||!r.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),t.viewCache_=i.viewCache,vp(t,i.changes,i.viewCache.eventCache.getNode(),null)}function uy(t,e){const n=t.viewCache_.eventCache,s=[];return n.getNode().isLeafNode()||n.getNode().forEachChild(ye,(i,o)=>{s.push(us(i,o))}),n.isFullyInitialized()&&s.push(lp(n.getNode())),vp(t,s,n.getNode(),e)}function vp(t,e,n,s){const r=s?[s]:t.eventRegistrations_;return D0(t.eventGenerator_,e,n,r)}/**
1399
+ */class ay{constructor(e,n){this.query_=e,this.eventRegistrations_=[];const s=this.query_._queryParams,r=new vc(s.getIndex()),i=A0(s);this.processor_=Z0(i);const o=n.serverCache,a=n.eventCache,c=r.updateFullNode(F.EMPTY_NODE,o.getNode(),null),l=i.updateFullNode(F.EMPTY_NODE,a.getNode(),null),h=new Dn(c,o.isFullyInitialized(),r.filtersNodes()),u=new Dn(l,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=qi(u,h),this.eventGenerator_=new L0(this.query_)}get query(){return this.query_}}function cy(t){return t.viewCache_.serverCache.getNode()}function ly(t,e){const n=Pn(t.viewCache_);return n&&(t.query._queryParams.loadsAllData()||!W(e)&&!n.getImmediateChild(H(e)).isEmpty())?n.getChild(e):null}function Mh(t){return t.eventRegistrations_.length===0}function hy(t,e){t.eventRegistrations_.push(e)}function Bh(t,e,n){const s=[];if(n){b(e==null,"A cancel should cancel all event registrations.");const r=t.query._path;t.eventRegistrations_.forEach(i=>{const o=i.createCancelEvent(n,r);o&&s.push(o)})}if(e){let r=[];for(let i=0;i<t.eventRegistrations_.length;++i){const o=t.eventRegistrations_[i];if(!o.matches(e))r.push(o);else if(e.hasAnyCallback()){r=r.concat(t.eventRegistrations_.slice(i+1));break}}t.eventRegistrations_=r}else t.eventRegistrations_=[];return s}function Uh(t,e,n,s){e.type===bt.MERGE&&e.source.queryId!==null&&(b(Pn(t.viewCache_),"We should always have a full cache before handling merges"),b(Sa(t.viewCache_),"Missing event cache, even though we have a server cache"));const r=t.viewCache_,i=ty(t.processor_,r,e,n,s);return ey(t.processor_,i.viewCache),b(i.viewCache.serverCache.isFullyInitialized()||!r.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),t.viewCache_=i.viewCache,vp(t,i.changes,i.viewCache.eventCache.getNode(),null)}function uy(t,e){const n=t.viewCache_.eventCache,s=[];return n.getNode().isLeafNode()||n.getNode().forEachChild(ye,(i,o)=>{s.push(us(i,o))}),n.isFullyInitialized()&&s.push(lp(n.getNode())),vp(t,s,n.getNode(),e)}function vp(t,e,n,s){const r=s?[s]:t.eventRegistrations_;return D0(t.eventGenerator_,e,n,r)}/**
1400
1400
  * @license
1401
1401
  * Copyright 2017 Google LLC
1402
1402
  *
@@ -1426,7 +1426,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1426
1426
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1427
1427
  * See the License for the specific language governing permissions and
1428
1428
  * limitations under the License.
1429
- */let Ai;function Ey(t){b(!Ai,"__referenceConstructor has already been defined"),Ai=t}function vy(){return b(Ai,"Reference.ts has not been loaded"),Ai}let wy=1;class Vh{constructor(e){this.listenProvider_=e,this.syncPointTree_=new he(null),this.pendingWriteTree_=Y0(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function by(t,e,n,s,r){return B0(t.pendingWriteTree_,e,n,s,r),r?kr(t,new Ln(up(),e,n)):[]}function Yn(t,e,n=!1){const s=U0(t.pendingWriteTree_,e);if(V0(t.pendingWriteTree_,e)){let i=new he(null);return s.snap!=null?i=i.set(J(),!0):Ke(s.children,o=>{i=i.set(new re(o),!0)}),kr(t,new wi(s.path,i,n))}else return[]}function Ki(t,e,n){return kr(t,new Ln(bc(),e,n))}function Ty(t,e,n){const s=he.fromObject(n);return kr(t,new mr(bc(),e,s))}function Cy(t,e){return kr(t,new pr(bc(),e))}function Sy(t,e,n){const s=Ic(t,n);if(s){const r=Nc(s),i=r.path,o=r.queryId,a=$e(i,e),c=new pr(Tc(o),a);return xc(t,i,c)}else return[]}function Na(t,e,n,s,r=!1){const i=e._path,o=t.syncPointTree_.get(i);let a=[];if(o&&(e._queryIdentifier==="default"||Tp(o,e))){const c=yy(o,e,n,s);my(o)&&(t.syncPointTree_=t.syncPointTree_.remove(i));const l=c.removed;if(a=c.events,!r){const h=l.findIndex(d=>d._queryParams.loadsAllData())!==-1,u=t.syncPointTree_.findOnPath(i,(d,p)=>dn(p));if(h&&!u){const d=t.syncPointTree_.subtree(i);if(!d.isEmpty()){const p=ky(d);for(let f=0;f<p.length;++f){const g=p[f],E=g.query,R=Rp(t,g);t.listenProvider_.startListening(nr(E),Ri(t,E),R.hashFn,R.onComplete)}}}!u&&l.length>0&&!s&&(h?t.listenProvider_.stopListening(nr(e),null):l.forEach(d=>{const p=t.queryToTagMap.get(Yi(d));t.listenProvider_.stopListening(nr(d),p)}))}Iy(t,l)}return a}function Ay(t,e,n,s){const r=Ic(t,s);if(r!=null){const i=Nc(r),o=i.path,a=i.queryId,c=$e(o,e),l=new Ln(Tc(a),c,n);return xc(t,o,l)}else return[]}function Ry(t,e,n,s){const r=Ic(t,s);if(r){const i=Nc(r),o=i.path,a=i.queryId,c=$e(o,e),l=he.fromObject(n),h=new mr(Tc(a),c,l);return xc(t,o,h)}else return[]}function Hh(t,e,n,s=!1){const r=e._path;let i=null,o=!1;t.syncPointTree_.foreachOnPath(r,(d,p)=>{const f=$e(d,r);i=i||ns(p,f),o=o||dn(p)});let a=t.syncPointTree_.get(r);a?(o=o||dn(a),i=i||ns(a,J())):(a=new dy,t.syncPointTree_=t.syncPointTree_.set(r,a));let c;i!=null?c=!0:(c=!1,i=F.EMPTY_NODE,t.syncPointTree_.subtree(r).foreachChild((p,f)=>{const g=ns(f,J());g&&(i=i.updateImmediateChild(p,g))}));const l=Tp(a,e);if(!l&&!e._queryParams.loadsAllData()){const d=Yi(e);b(!t.queryToTagMap.has(d),"View does not exist, but we have a tag");const p=Ny();t.queryToTagMap.set(d,p),t.tagToQueryMap.set(p,d)}const h=Cc(t.pendingWriteTree_,r);let u=_y(a,e,n,h,i,c);if(!l&&!o&&!s){const d=bp(a,e);u=u.concat(xy(t,e,d))}return u}function Cp(t,e,n){const r=t.pendingWriteTree_,i=t.syncPointTree_.findOnPath(e,(o,a)=>{const c=$e(o,e),l=ns(a,c);if(l)return l});return mp(r,e,i,n,!0)}function kr(t,e){return Sp(e,t.syncPointTree_,null,Cc(t.pendingWriteTree_,J()))}function Sp(t,e,n,s){if(G(t.path))return Ap(t,e,n,s);{const r=e.get(J());n==null&&r!=null&&(n=ns(r,J()));let i=[];const o=H(t.path),a=t.operationForChild(o),c=e.children.get(o);if(c&&a){const l=n?n.getImmediateChild(o):null,h=gp(s,o);i=i.concat(Sp(a,c,l,h))}return r&&(i=i.concat(kc(r,t,s,n))),i}}function Ap(t,e,n,s){const r=e.get(J());n==null&&r!=null&&(n=ns(r,J()));let i=[];return e.children.inorderTraversal((o,a)=>{const c=n?n.getImmediateChild(o):null,l=gp(s,o),h=t.operationForChild(o);h&&(i=i.concat(Ap(h,a,c,l)))}),r&&(i=i.concat(kc(r,t,s,n))),i}function Rp(t,e){const n=e.query,s=Ri(t,n);return{hashFn:()=>(cy(e)||F.EMPTY_NODE).hash(),onComplete:r=>{if(r==="ok")return s?Sy(t,n._path,s):Cy(t,n._path);{const i=S2(r,n);return Na(t,n,null,i)}}}}function Ri(t,e){const n=Yi(e);return t.queryToTagMap.get(n)}function Yi(t){return t._path.toString()+"$"+t._queryIdentifier}function Ic(t,e){return t.tagToQueryMap.get(e)}function Nc(t){const e=t.indexOf("$");return b(e!==-1&&e<t.length-1,"Bad queryKey."),{queryId:t.substr(e+1),path:new re(t.substr(0,e))}}function xc(t,e,n){const s=t.syncPointTree_.get(e);b(s,"Missing sync point for query tag that we're tracking");const r=Cc(t.pendingWriteTree_,e);return kc(s,n,r,null)}function ky(t){return t.fold((e,n,s)=>{if(n&&dn(n))return[zi(n)];{let r=[];return n&&(r=wp(n)),Ke(s,(i,o)=>{r=r.concat(o)}),r}})}function nr(t){return t._queryParams.loadsAllData()&&!t._queryParams.isDefault()?new(vy())(t._repo,t._path):t}function Iy(t,e){for(let n=0;n<e.length;++n){const s=e[n];if(!s._queryParams.loadsAllData()){const r=Yi(s),i=t.queryToTagMap.get(r);t.queryToTagMap.delete(r),t.tagToQueryMap.delete(i)}}}function Ny(){return wy++}function xy(t,e,n){const s=e._path,r=Ri(t,e),i=Rp(t,n),o=t.listenProvider_.startListening(nr(e),r,i.hashFn,i.onComplete),a=t.syncPointTree_.subtree(s);if(r)b(!dn(a.value),"If we're adding a query, it shouldn't be shadowed");else{const c=a.fold((l,h,u)=>{if(!G(l)&&h&&dn(h))return[zi(h).query];{let d=[];return h&&(d=d.concat(wp(h).map(p=>p.query))),Ke(u,(p,f)=>{d=d.concat(f)}),d}});for(let l=0;l<c.length;++l){const h=c[l];t.listenProvider_.stopListening(nr(h),Ri(t,h))}}return o}/**
1429
+ */let Ai;function Ey(t){b(!Ai,"__referenceConstructor has already been defined"),Ai=t}function vy(){return b(Ai,"Reference.ts has not been loaded"),Ai}let wy=1;class Vh{constructor(e){this.listenProvider_=e,this.syncPointTree_=new he(null),this.pendingWriteTree_=Y0(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function by(t,e,n,s,r){return B0(t.pendingWriteTree_,e,n,s,r),r?kr(t,new Ln(up(),e,n)):[]}function Yn(t,e,n=!1){const s=U0(t.pendingWriteTree_,e);if(V0(t.pendingWriteTree_,e)){let i=new he(null);return s.snap!=null?i=i.set(J(),!0):Ke(s.children,o=>{i=i.set(new re(o),!0)}),kr(t,new wi(s.path,i,n))}else return[]}function Ki(t,e,n){return kr(t,new Ln(bc(),e,n))}function Ty(t,e,n){const s=he.fromObject(n);return kr(t,new mr(bc(),e,s))}function Cy(t,e){return kr(t,new pr(bc(),e))}function Sy(t,e,n){const s=Ic(t,n);if(s){const r=Nc(s),i=r.path,o=r.queryId,a=$e(i,e),c=new pr(Tc(o),a);return xc(t,i,c)}else return[]}function Na(t,e,n,s,r=!1){const i=e._path,o=t.syncPointTree_.get(i);let a=[];if(o&&(e._queryIdentifier==="default"||Tp(o,e))){const c=yy(o,e,n,s);my(o)&&(t.syncPointTree_=t.syncPointTree_.remove(i));const l=c.removed;if(a=c.events,!r){const h=l.findIndex(d=>d._queryParams.loadsAllData())!==-1,u=t.syncPointTree_.findOnPath(i,(d,p)=>dn(p));if(h&&!u){const d=t.syncPointTree_.subtree(i);if(!d.isEmpty()){const p=ky(d);for(let f=0;f<p.length;++f){const g=p[f],E=g.query,R=Rp(t,g);t.listenProvider_.startListening(nr(E),Ri(t,E),R.hashFn,R.onComplete)}}}!u&&l.length>0&&!s&&(h?t.listenProvider_.stopListening(nr(e),null):l.forEach(d=>{const p=t.queryToTagMap.get(Yi(d));t.listenProvider_.stopListening(nr(d),p)}))}Iy(t,l)}return a}function Ay(t,e,n,s){const r=Ic(t,s);if(r!=null){const i=Nc(r),o=i.path,a=i.queryId,c=$e(o,e),l=new Ln(Tc(a),c,n);return xc(t,o,l)}else return[]}function Ry(t,e,n,s){const r=Ic(t,s);if(r){const i=Nc(r),o=i.path,a=i.queryId,c=$e(o,e),l=he.fromObject(n),h=new mr(Tc(a),c,l);return xc(t,o,h)}else return[]}function Hh(t,e,n,s=!1){const r=e._path;let i=null,o=!1;t.syncPointTree_.foreachOnPath(r,(d,p)=>{const f=$e(d,r);i=i||ns(p,f),o=o||dn(p)});let a=t.syncPointTree_.get(r);a?(o=o||dn(a),i=i||ns(a,J())):(a=new dy,t.syncPointTree_=t.syncPointTree_.set(r,a));let c;i!=null?c=!0:(c=!1,i=F.EMPTY_NODE,t.syncPointTree_.subtree(r).foreachChild((p,f)=>{const g=ns(f,J());g&&(i=i.updateImmediateChild(p,g))}));const l=Tp(a,e);if(!l&&!e._queryParams.loadsAllData()){const d=Yi(e);b(!t.queryToTagMap.has(d),"View does not exist, but we have a tag");const p=Ny();t.queryToTagMap.set(d,p),t.tagToQueryMap.set(p,d)}const h=Cc(t.pendingWriteTree_,r);let u=_y(a,e,n,h,i,c);if(!l&&!o&&!s){const d=bp(a,e);u=u.concat(xy(t,e,d))}return u}function Cp(t,e,n){const r=t.pendingWriteTree_,i=t.syncPointTree_.findOnPath(e,(o,a)=>{const c=$e(o,e),l=ns(a,c);if(l)return l});return mp(r,e,i,n,!0)}function kr(t,e){return Sp(e,t.syncPointTree_,null,Cc(t.pendingWriteTree_,J()))}function Sp(t,e,n,s){if(W(t.path))return Ap(t,e,n,s);{const r=e.get(J());n==null&&r!=null&&(n=ns(r,J()));let i=[];const o=H(t.path),a=t.operationForChild(o),c=e.children.get(o);if(c&&a){const l=n?n.getImmediateChild(o):null,h=gp(s,o);i=i.concat(Sp(a,c,l,h))}return r&&(i=i.concat(kc(r,t,s,n))),i}}function Ap(t,e,n,s){const r=e.get(J());n==null&&r!=null&&(n=ns(r,J()));let i=[];return e.children.inorderTraversal((o,a)=>{const c=n?n.getImmediateChild(o):null,l=gp(s,o),h=t.operationForChild(o);h&&(i=i.concat(Ap(h,a,c,l)))}),r&&(i=i.concat(kc(r,t,s,n))),i}function Rp(t,e){const n=e.query,s=Ri(t,n);return{hashFn:()=>(cy(e)||F.EMPTY_NODE).hash(),onComplete:r=>{if(r==="ok")return s?Sy(t,n._path,s):Cy(t,n._path);{const i=S2(r,n);return Na(t,n,null,i)}}}}function Ri(t,e){const n=Yi(e);return t.queryToTagMap.get(n)}function Yi(t){return t._path.toString()+"$"+t._queryIdentifier}function Ic(t,e){return t.tagToQueryMap.get(e)}function Nc(t){const e=t.indexOf("$");return b(e!==-1&&e<t.length-1,"Bad queryKey."),{queryId:t.substr(e+1),path:new re(t.substr(0,e))}}function xc(t,e,n){const s=t.syncPointTree_.get(e);b(s,"Missing sync point for query tag that we're tracking");const r=Cc(t.pendingWriteTree_,e);return kc(s,n,r,null)}function ky(t){return t.fold((e,n,s)=>{if(n&&dn(n))return[zi(n)];{let r=[];return n&&(r=wp(n)),Ke(s,(i,o)=>{r=r.concat(o)}),r}})}function nr(t){return t._queryParams.loadsAllData()&&!t._queryParams.isDefault()?new(vy())(t._repo,t._path):t}function Iy(t,e){for(let n=0;n<e.length;++n){const s=e[n];if(!s._queryParams.loadsAllData()){const r=Yi(s),i=t.queryToTagMap.get(r);t.queryToTagMap.delete(r),t.tagToQueryMap.delete(i)}}}function Ny(){return wy++}function xy(t,e,n){const s=e._path,r=Ri(t,e),i=Rp(t,n),o=t.listenProvider_.startListening(nr(e),r,i.hashFn,i.onComplete),a=t.syncPointTree_.subtree(s);if(r)b(!dn(a.value),"If we're adding a query, it shouldn't be shadowed");else{const c=a.fold((l,h,u)=>{if(!W(l)&&h&&dn(h))return[zi(h).query];{let d=[];return h&&(d=d.concat(wp(h).map(p=>p.query))),Ke(u,(p,f)=>{d=d.concat(f)}),d}});for(let l=0;l<c.length;++l){const h=c[l];t.listenProvider_.stopListening(nr(h),Ri(t,h))}}return o}/**
1430
1430
  * @license
1431
1431
  * Copyright 2017 Google LLC
1432
1432
  *
@@ -1441,7 +1441,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1441
1441
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1442
1442
  * See the License for the specific language governing permissions and
1443
1443
  * limitations under the License.
1444
- */class Oc{constructor(e){this.node_=e}getImmediateChild(e){const n=this.node_.getImmediateChild(e);return new Oc(n)}node(){return this.node_}}class Lc{constructor(e,n){this.syncTree_=e,this.path_=n}getImmediateChild(e){const n=ke(this.path_,e);return new Lc(this.syncTree_,n)}node(){return Cp(this.syncTree_,this.path_)}}const Oy=function(t){return t=t||{},t.timestamp=t.timestamp||new Date().getTime(),t},Gh=function(t,e,n){if(!t||typeof t!="object")return t;if(b(".sv"in t,"Unexpected leaf node or priority contents"),typeof t[".sv"]=="string")return Ly(t[".sv"],e,n);if(typeof t[".sv"]=="object")return Dy(t[".sv"],e);b(!1,"Unexpected server value: "+JSON.stringify(t,null,2))},Ly=function(t,e,n){switch(t){case"timestamp":return n.timestamp;default:b(!1,"Unexpected server value: "+t)}},Dy=function(t,e,n){t.hasOwnProperty("increment")||b(!1,"Unexpected server value: "+JSON.stringify(t,null,2));const s=t.increment;typeof s!="number"&&b(!1,"Unexpected increment value: "+s);const r=e.node();if(b(r!==null&&typeof r<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!r.isLeafNode())return s;const o=r.getValue();return typeof o!="number"?s:o+s},Py=function(t,e,n,s){return Dc(e,new Lc(n,t),s)},Fy=function(t,e,n){return Dc(t,new Oc(e),n)};function Dc(t,e,n){const s=t.getPriority().val(),r=Gh(s,e.getImmediateChild(".priority"),n);let i;if(t.isLeafNode()){const o=t,a=Gh(o.getValue(),e,n);return a!==o.getValue()||r!==o.getPriority().val()?new xe(a,Me(r)):t}else{const o=t;return i=o,r!==o.getPriority().val()&&(i=i.updatePriority(new xe(r))),o.forEachChild(ye,(a,c)=>{const l=Dc(c,e.getImmediateChild(a),n);l!==c&&(i=i.updateImmediateChild(a,l))}),i}}/**
1444
+ */class Oc{constructor(e){this.node_=e}getImmediateChild(e){const n=this.node_.getImmediateChild(e);return new Oc(n)}node(){return this.node_}}class Lc{constructor(e,n){this.syncTree_=e,this.path_=n}getImmediateChild(e){const n=ke(this.path_,e);return new Lc(this.syncTree_,n)}node(){return Cp(this.syncTree_,this.path_)}}const Oy=function(t){return t=t||{},t.timestamp=t.timestamp||new Date().getTime(),t},Wh=function(t,e,n){if(!t||typeof t!="object")return t;if(b(".sv"in t,"Unexpected leaf node or priority contents"),typeof t[".sv"]=="string")return Ly(t[".sv"],e,n);if(typeof t[".sv"]=="object")return Dy(t[".sv"],e);b(!1,"Unexpected server value: "+JSON.stringify(t,null,2))},Ly=function(t,e,n){switch(t){case"timestamp":return n.timestamp;default:b(!1,"Unexpected server value: "+t)}},Dy=function(t,e,n){t.hasOwnProperty("increment")||b(!1,"Unexpected server value: "+JSON.stringify(t,null,2));const s=t.increment;typeof s!="number"&&b(!1,"Unexpected increment value: "+s);const r=e.node();if(b(r!==null&&typeof r<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!r.isLeafNode())return s;const o=r.getValue();return typeof o!="number"?s:o+s},Py=function(t,e,n,s){return Dc(e,new Lc(n,t),s)},Fy=function(t,e,n){return Dc(t,new Oc(e),n)};function Dc(t,e,n){const s=t.getPriority().val(),r=Wh(s,e.getImmediateChild(".priority"),n);let i;if(t.isLeafNode()){const o=t,a=Wh(o.getValue(),e,n);return a!==o.getValue()||r!==o.getPriority().val()?new xe(a,Me(r)):t}else{const o=t;return i=o,r!==o.getPriority().val()&&(i=i.updatePriority(new xe(r))),o.forEachChild(ye,(a,c)=>{const l=Dc(c,e.getImmediateChild(a),n);l!==c&&(i=i.updateImmediateChild(a,l))}),i}}/**
1445
1445
  * @license
1446
1446
  * Copyright 2017 Google LLC
1447
1447
  *
@@ -1471,7 +1471,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1471
1471
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1472
1472
  * See the License for the specific language governing permissions and
1473
1473
  * limitations under the License.
1474
- */const Vy=/[\[\].#$\/\u0000-\u001F\u007F]/,Hy=/[\[\].#$\u0000-\u001F\u007F]/,$o=10*1024*1024,xp=function(t){return typeof t=="string"&&t.length!==0&&!Vy.test(t)},Op=function(t){return typeof t=="string"&&t.length!==0&&!Hy.test(t)},Gy=function(t){return t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),Op(t)},Lp=function(t,e,n){const s=n instanceof re?new r0(n,t):n;if(e===void 0)throw new Error(t+"contains undefined "+wn(s));if(typeof e=="function")throw new Error(t+"contains a function "+wn(s)+" with contents = "+e.toString());if(Lf(e))throw new Error(t+"contains "+e.toString()+" "+wn(s));if(typeof e=="string"&&e.length>$o/3&&Wi(e)>$o)throw new Error(t+"contains a string greater than "+$o+" utf8 bytes "+wn(s)+" ('"+e.substring(0,50)+"...')");if(e&&typeof e=="object"){let r=!1,i=!1;if(Ke(e,(o,a)=>{if(o===".value")r=!0;else if(o!==".priority"&&o!==".sv"&&(i=!0,!xp(o)))throw new Error(t+" contains an invalid key ("+o+") "+wn(s)+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);i0(s,o),Lp(t,a,s),o0(s)}),r&&i)throw new Error(t+' contains ".value" child '+wn(s)+" in addition to actual children.")}},Dp=function(t,e,n,s){if(!Op(n))throw new Error(bf(t,e)+'was an invalid path = "'+n+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},Wy=function(t,e,n,s){n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),Dp(t,e,n)},$y=function(t,e){const n=e.path.toString();if(typeof e.repoInfo.host!="string"||e.repoInfo.host.length===0||!xp(e.repoInfo.namespace)&&e.repoInfo.host.split(":")[0]!=="localhost"||n.length!==0&&!Gy(n))throw new Error(bf(t,"url")+`must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".`)};/**
1474
+ */const Vy=/[\[\].#$\/\u0000-\u001F\u007F]/,Hy=/[\[\].#$\u0000-\u001F\u007F]/,$o=10*1024*1024,xp=function(t){return typeof t=="string"&&t.length!==0&&!Vy.test(t)},Op=function(t){return typeof t=="string"&&t.length!==0&&!Hy.test(t)},Wy=function(t){return t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),Op(t)},Lp=function(t,e,n){const s=n instanceof re?new r0(n,t):n;if(e===void 0)throw new Error(t+"contains undefined "+wn(s));if(typeof e=="function")throw new Error(t+"contains a function "+wn(s)+" with contents = "+e.toString());if(Lf(e))throw new Error(t+"contains "+e.toString()+" "+wn(s));if(typeof e=="string"&&e.length>$o/3&&Gi(e)>$o)throw new Error(t+"contains a string greater than "+$o+" utf8 bytes "+wn(s)+" ('"+e.substring(0,50)+"...')");if(e&&typeof e=="object"){let r=!1,i=!1;if(Ke(e,(o,a)=>{if(o===".value")r=!0;else if(o!==".priority"&&o!==".sv"&&(i=!0,!xp(o)))throw new Error(t+" contains an invalid key ("+o+") "+wn(s)+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);i0(s,o),Lp(t,a,s),o0(s)}),r&&i)throw new Error(t+' contains ".value" child '+wn(s)+" in addition to actual children.")}},Dp=function(t,e,n,s){if(!Op(n))throw new Error(bf(t,e)+'was an invalid path = "'+n+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},Gy=function(t,e,n,s){n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),Dp(t,e,n)},$y=function(t,e){const n=e.path.toString();if(typeof e.repoInfo.host!="string"||e.repoInfo.host.length===0||!xp(e.repoInfo.namespace)&&e.repoInfo.host.split(":")[0]!=="localhost"||n.length!==0&&!Wy(n))throw new Error(bf(t,"url")+`must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".`)};/**
1475
1475
  * @license
1476
1476
  * Copyright 2017 Google LLC
1477
1477
  *
@@ -1501,7 +1501,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1501
1501
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1502
1502
  * See the License for the specific language governing permissions and
1503
1503
  * limitations under the License.
1504
- */const zy="repo_interrupt",Ky=25;class Yy{constructor(e,n,s,r){this.repoInfo_=e,this.forceRestClient_=n,this.authTokenProvider_=s,this.appCheckProvider_=r,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new jy,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=vi(),this.transactionQueueTree_=new Pc,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function Xy(t,e,n){if(t.stats_=mc(t.repoInfo_),t.forceRestClient_||I2())t.server_=new Ei(t.repoInfo_,(s,r,i,o)=>{Wh(t,s,r,i,o)},t.authTokenProvider_,t.appCheckProvider_),setTimeout(()=>$h(t,!0),0);else{if(typeof n<"u"&&n!==null){if(typeof n!="object")throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{Le(n)}catch(s){throw new Error("Invalid authOverride provided: "+s)}}t.persistentConnection_=new $t(t.repoInfo_,e,(s,r,i,o)=>{Wh(t,s,r,i,o)},s=>{$h(t,s)},s=>{Qy(t,s)},t.authTokenProvider_,t.appCheckProvider_,n),t.server_=t.persistentConnection_}t.authTokenProvider_.addTokenChangeListener(s=>{t.server_.refreshAuthToken(s)}),t.appCheckProvider_.addTokenChangeListener(s=>{t.server_.refreshAppCheckToken(s.token)}),t.statsReporter_=D2(t.repoInfo_,()=>new O0(t.stats_,t.server_)),t.infoData_=new R0,t.infoSyncTree_=new Vh({startListening:(s,r,i,o)=>{let a=[];const c=t.infoData_.getNode(s._path);return c.isEmpty()||(a=Ki(t.infoSyncTree_,s._path,c),setTimeout(()=>{o("ok")},0)),a},stopListening:()=>{}}),Mc(t,"connected",!1),t.serverSyncTree_=new Vh({startListening:(s,r,i,o)=>(t.server_.listen(s,i,r,(a,c)=>{const l=o(a,c);Vn(t.eventQueue_,s._path,l)}),[]),stopListening:(s,r)=>{t.server_.unlisten(s,r)}})}function Jy(t){const n=t.infoData_.getNode(new re(".info/serverTimeOffset")).val()||0;return new Date().getTime()+n}function Bp(t){return Oy({timestamp:Jy(t)})}function Wh(t,e,n,s,r){t.dataUpdateCount++;const i=new re(e);n=t.interceptServerDataCallback_?t.interceptServerDataCallback_(e,n):n;let o=[];if(r)if(s){const c=fi(n,l=>Me(l));o=Ry(t.serverSyncTree_,i,c,r)}else{const c=Me(n);o=Ay(t.serverSyncTree_,i,c,r)}else if(s){const c=fi(n,l=>Me(l));o=Ty(t.serverSyncTree_,i,c)}else{const c=Me(n);o=Ki(t.serverSyncTree_,i,c)}let a=i;o.length>0&&(a=Uc(t,i)),Vn(t.eventQueue_,a,o)}function $h(t,e){Mc(t,"connected",e),e===!1&&e3(t)}function Qy(t,e){Ke(e,(n,s)=>{Mc(t,n,s)})}function Mc(t,e,n){const s=new re("/.info/"+e),r=Me(n);t.infoData_.updateSnapshot(s,r);const i=Ki(t.infoSyncTree_,s,r);Vn(t.eventQueue_,s,i)}function Zy(t){return t.nextWriteId_++}function e3(t){Up(t,"onDisconnectEvents");const e=Bp(t),n=vi();Ca(t.onDisconnect_,J(),(r,i)=>{const o=Py(r,i,t.serverSyncTree_,e);hp(n,r,o)});let s=[];Ca(n,J(),(r,i)=>{s=s.concat(Ki(t.serverSyncTree_,r,i));const o=o3(t,r);Uc(t,o)}),t.onDisconnect_=vi(),Vn(t.eventQueue_,J(),s)}function t3(t,e,n){let s;H(e._path)===".info"?s=Hh(t.infoSyncTree_,e,n):s=Hh(t.serverSyncTree_,e,n),Fp(t.eventQueue_,e._path,s)}function n3(t,e,n){let s;H(e._path)===".info"?s=Na(t.infoSyncTree_,e,n):s=Na(t.serverSyncTree_,e,n),Fp(t.eventQueue_,e._path,s)}function s3(t){t.persistentConnection_&&t.persistentConnection_.interrupt(zy)}function Up(t,...e){let n="";t.persistentConnection_&&(n=t.persistentConnection_.id+":"),Fe(n,...e)}function Vp(t,e,n){return Cp(t.serverSyncTree_,e,n)||F.EMPTY_NODE}function Bc(t,e=t.transactionQueueTree_){if(e||Ji(t,e),Ss(e)){const n=Gp(t,e);b(n.length>0,"Sending zero length transaction queue"),n.every(r=>r.status===0)&&r3(t,Ir(e),n)}else Ip(e)&&Xi(e,n=>{Bc(t,n)})}function r3(t,e,n){const s=n.map(l=>l.currentWriteId),r=Vp(t,e,s);let i=r;const o=r.hash();for(let l=0;l<n.length;l++){const h=n[l];b(h.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),h.status=1,h.retryCount++;const u=$e(e,h.path);i=i.updateChild(u,h.currentOutputSnapshotRaw)}const a=i.val(!0),c=e;t.server_.put(c.toString(),a,l=>{Up(t,"transaction put response",{path:c.toString(),status:l});let h=[];if(l==="ok"){const u=[];for(let d=0;d<n.length;d++)n[d].status=2,h=h.concat(Yn(t.serverSyncTree_,n[d].currentWriteId)),n[d].onComplete&&u.push(()=>n[d].onComplete(null,!0,n[d].currentOutputSnapshotResolved)),n[d].unwatcher();Ji(t,Fc(t.transactionQueueTree_,e)),Bc(t,t.transactionQueueTree_),Vn(t.eventQueue_,e,h);for(let d=0;d<u.length;d++)Ar(u[d])}else{if(l==="datastale")for(let u=0;u<n.length;u++)n[u].status===3?n[u].status=4:n[u].status=0;else{nt("transaction at "+c.toString()+" failed: "+l);for(let u=0;u<n.length;u++)n[u].status=4,n[u].abortReason=l}Uc(t,e)}},o)}function Uc(t,e){const n=Hp(t,e),s=Ir(n),r=Gp(t,n);return i3(t,r,s),s}function i3(t,e,n){if(e.length===0)return;const s=[];let r=[];const o=e.filter(a=>a.status===0).map(a=>a.currentWriteId);for(let a=0;a<e.length;a++){const c=e[a],l=$e(n,c.path);let h=!1,u;if(b(l!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),c.status===4)h=!0,u=c.abortReason,r=r.concat(Yn(t.serverSyncTree_,c.currentWriteId,!0));else if(c.status===0)if(c.retryCount>=Ky)h=!0,u="maxretry",r=r.concat(Yn(t.serverSyncTree_,c.currentWriteId,!0));else{const d=Vp(t,c.path,o);c.currentInputSnapshot=d;const p=e[a].update(d.val());if(p!==void 0){Lp("transaction failed: Data returned ",p,c.path);let f=Me(p);typeof p=="object"&&p!=null&&Jt(p,".priority")||(f=f.updatePriority(d.getPriority()));const E=c.currentWriteId,R=Bp(t),y=Fy(f,d,R);c.currentOutputSnapshotRaw=f,c.currentOutputSnapshotResolved=y,c.currentWriteId=Zy(t),o.splice(o.indexOf(E),1),r=r.concat(by(t.serverSyncTree_,c.path,y,c.currentWriteId,c.applyLocally)),r=r.concat(Yn(t.serverSyncTree_,E,!0))}else h=!0,u="nodata",r=r.concat(Yn(t.serverSyncTree_,c.currentWriteId,!0))}Vn(t.eventQueue_,n,r),r=[],h&&(e[a].status=2,function(d){setTimeout(d,Math.floor(0))}(e[a].unwatcher),e[a].onComplete&&(u==="nodata"?s.push(()=>e[a].onComplete(null,!1,e[a].currentInputSnapshot)):s.push(()=>e[a].onComplete(new Error(u),!1,null))))}Ji(t,t.transactionQueueTree_);for(let a=0;a<s.length;a++)Ar(s[a]);Bc(t,t.transactionQueueTree_)}function Hp(t,e){let n,s=t.transactionQueueTree_;for(n=H(e);n!==null&&Ss(s)===void 0;)s=Fc(s,n),e=oe(e),n=H(e);return s}function Gp(t,e){const n=[];return Wp(t,e,n),n.sort((s,r)=>s.order-r.order),n}function Wp(t,e,n){const s=Ss(e);if(s)for(let r=0;r<s.length;r++)n.push(s[r]);Xi(e,r=>{Wp(t,r,n)})}function Ji(t,e){const n=Ss(e);if(n){let s=0;for(let r=0;r<n.length;r++)n[r].status!==2&&(n[s]=n[r],s++);n.length=s,kp(e,n.length>0?n:void 0)}Xi(e,s=>{Ji(t,s)})}function o3(t,e){const n=Ir(Hp(t,e)),s=Fc(t.transactionQueueTree_,e);return By(s,r=>{jo(t,r)}),jo(t,s),Np(s,r=>{jo(t,r)}),n}function jo(t,e){const n=Ss(e);if(n){const s=[];let r=[],i=-1;for(let o=0;o<n.length;o++)n[o].status===3||(n[o].status===1?(b(i===o-1,"All SENT items should be at beginning of queue."),i=o,n[o].status=3,n[o].abortReason="set"):(b(n[o].status===0,"Unexpected transaction status in abort"),n[o].unwatcher(),r=r.concat(Yn(t.serverSyncTree_,n[o].currentWriteId,!0)),n[o].onComplete&&s.push(n[o].onComplete.bind(null,new Error("set"),!1,null))));i===-1?kp(e,void 0):n.length=i+1,Vn(t.eventQueue_,Ir(e),r);for(let o=0;o<s.length;o++)Ar(s[o])}}/**
1504
+ */const zy="repo_interrupt",Ky=25;class Yy{constructor(e,n,s,r){this.repoInfo_=e,this.forceRestClient_=n,this.authTokenProvider_=s,this.appCheckProvider_=r,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new jy,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=vi(),this.transactionQueueTree_=new Pc,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function Xy(t,e,n){if(t.stats_=mc(t.repoInfo_),t.forceRestClient_||I2())t.server_=new Ei(t.repoInfo_,(s,r,i,o)=>{Gh(t,s,r,i,o)},t.authTokenProvider_,t.appCheckProvider_),setTimeout(()=>$h(t,!0),0);else{if(typeof n<"u"&&n!==null){if(typeof n!="object")throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{Le(n)}catch(s){throw new Error("Invalid authOverride provided: "+s)}}t.persistentConnection_=new $t(t.repoInfo_,e,(s,r,i,o)=>{Gh(t,s,r,i,o)},s=>{$h(t,s)},s=>{Qy(t,s)},t.authTokenProvider_,t.appCheckProvider_,n),t.server_=t.persistentConnection_}t.authTokenProvider_.addTokenChangeListener(s=>{t.server_.refreshAuthToken(s)}),t.appCheckProvider_.addTokenChangeListener(s=>{t.server_.refreshAppCheckToken(s.token)}),t.statsReporter_=D2(t.repoInfo_,()=>new O0(t.stats_,t.server_)),t.infoData_=new R0,t.infoSyncTree_=new Vh({startListening:(s,r,i,o)=>{let a=[];const c=t.infoData_.getNode(s._path);return c.isEmpty()||(a=Ki(t.infoSyncTree_,s._path,c),setTimeout(()=>{o("ok")},0)),a},stopListening:()=>{}}),Mc(t,"connected",!1),t.serverSyncTree_=new Vh({startListening:(s,r,i,o)=>(t.server_.listen(s,i,r,(a,c)=>{const l=o(a,c);Vn(t.eventQueue_,s._path,l)}),[]),stopListening:(s,r)=>{t.server_.unlisten(s,r)}})}function Jy(t){const n=t.infoData_.getNode(new re(".info/serverTimeOffset")).val()||0;return new Date().getTime()+n}function Bp(t){return Oy({timestamp:Jy(t)})}function Gh(t,e,n,s,r){t.dataUpdateCount++;const i=new re(e);n=t.interceptServerDataCallback_?t.interceptServerDataCallback_(e,n):n;let o=[];if(r)if(s){const c=fi(n,l=>Me(l));o=Ry(t.serverSyncTree_,i,c,r)}else{const c=Me(n);o=Ay(t.serverSyncTree_,i,c,r)}else if(s){const c=fi(n,l=>Me(l));o=Ty(t.serverSyncTree_,i,c)}else{const c=Me(n);o=Ki(t.serverSyncTree_,i,c)}let a=i;o.length>0&&(a=Uc(t,i)),Vn(t.eventQueue_,a,o)}function $h(t,e){Mc(t,"connected",e),e===!1&&e3(t)}function Qy(t,e){Ke(e,(n,s)=>{Mc(t,n,s)})}function Mc(t,e,n){const s=new re("/.info/"+e),r=Me(n);t.infoData_.updateSnapshot(s,r);const i=Ki(t.infoSyncTree_,s,r);Vn(t.eventQueue_,s,i)}function Zy(t){return t.nextWriteId_++}function e3(t){Up(t,"onDisconnectEvents");const e=Bp(t),n=vi();Ca(t.onDisconnect_,J(),(r,i)=>{const o=Py(r,i,t.serverSyncTree_,e);hp(n,r,o)});let s=[];Ca(n,J(),(r,i)=>{s=s.concat(Ki(t.serverSyncTree_,r,i));const o=o3(t,r);Uc(t,o)}),t.onDisconnect_=vi(),Vn(t.eventQueue_,J(),s)}function t3(t,e,n){let s;H(e._path)===".info"?s=Hh(t.infoSyncTree_,e,n):s=Hh(t.serverSyncTree_,e,n),Fp(t.eventQueue_,e._path,s)}function n3(t,e,n){let s;H(e._path)===".info"?s=Na(t.infoSyncTree_,e,n):s=Na(t.serverSyncTree_,e,n),Fp(t.eventQueue_,e._path,s)}function s3(t){t.persistentConnection_&&t.persistentConnection_.interrupt(zy)}function Up(t,...e){let n="";t.persistentConnection_&&(n=t.persistentConnection_.id+":"),Fe(n,...e)}function Vp(t,e,n){return Cp(t.serverSyncTree_,e,n)||F.EMPTY_NODE}function Bc(t,e=t.transactionQueueTree_){if(e||Ji(t,e),Ss(e)){const n=Wp(t,e);b(n.length>0,"Sending zero length transaction queue"),n.every(r=>r.status===0)&&r3(t,Ir(e),n)}else Ip(e)&&Xi(e,n=>{Bc(t,n)})}function r3(t,e,n){const s=n.map(l=>l.currentWriteId),r=Vp(t,e,s);let i=r;const o=r.hash();for(let l=0;l<n.length;l++){const h=n[l];b(h.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),h.status=1,h.retryCount++;const u=$e(e,h.path);i=i.updateChild(u,h.currentOutputSnapshotRaw)}const a=i.val(!0),c=e;t.server_.put(c.toString(),a,l=>{Up(t,"transaction put response",{path:c.toString(),status:l});let h=[];if(l==="ok"){const u=[];for(let d=0;d<n.length;d++)n[d].status=2,h=h.concat(Yn(t.serverSyncTree_,n[d].currentWriteId)),n[d].onComplete&&u.push(()=>n[d].onComplete(null,!0,n[d].currentOutputSnapshotResolved)),n[d].unwatcher();Ji(t,Fc(t.transactionQueueTree_,e)),Bc(t,t.transactionQueueTree_),Vn(t.eventQueue_,e,h);for(let d=0;d<u.length;d++)Ar(u[d])}else{if(l==="datastale")for(let u=0;u<n.length;u++)n[u].status===3?n[u].status=4:n[u].status=0;else{nt("transaction at "+c.toString()+" failed: "+l);for(let u=0;u<n.length;u++)n[u].status=4,n[u].abortReason=l}Uc(t,e)}},o)}function Uc(t,e){const n=Hp(t,e),s=Ir(n),r=Wp(t,n);return i3(t,r,s),s}function i3(t,e,n){if(e.length===0)return;const s=[];let r=[];const o=e.filter(a=>a.status===0).map(a=>a.currentWriteId);for(let a=0;a<e.length;a++){const c=e[a],l=$e(n,c.path);let h=!1,u;if(b(l!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),c.status===4)h=!0,u=c.abortReason,r=r.concat(Yn(t.serverSyncTree_,c.currentWriteId,!0));else if(c.status===0)if(c.retryCount>=Ky)h=!0,u="maxretry",r=r.concat(Yn(t.serverSyncTree_,c.currentWriteId,!0));else{const d=Vp(t,c.path,o);c.currentInputSnapshot=d;const p=e[a].update(d.val());if(p!==void 0){Lp("transaction failed: Data returned ",p,c.path);let f=Me(p);typeof p=="object"&&p!=null&&Jt(p,".priority")||(f=f.updatePriority(d.getPriority()));const E=c.currentWriteId,R=Bp(t),y=Fy(f,d,R);c.currentOutputSnapshotRaw=f,c.currentOutputSnapshotResolved=y,c.currentWriteId=Zy(t),o.splice(o.indexOf(E),1),r=r.concat(by(t.serverSyncTree_,c.path,y,c.currentWriteId,c.applyLocally)),r=r.concat(Yn(t.serverSyncTree_,E,!0))}else h=!0,u="nodata",r=r.concat(Yn(t.serverSyncTree_,c.currentWriteId,!0))}Vn(t.eventQueue_,n,r),r=[],h&&(e[a].status=2,function(d){setTimeout(d,Math.floor(0))}(e[a].unwatcher),e[a].onComplete&&(u==="nodata"?s.push(()=>e[a].onComplete(null,!1,e[a].currentInputSnapshot)):s.push(()=>e[a].onComplete(new Error(u),!1,null))))}Ji(t,t.transactionQueueTree_);for(let a=0;a<s.length;a++)Ar(s[a]);Bc(t,t.transactionQueueTree_)}function Hp(t,e){let n,s=t.transactionQueueTree_;for(n=H(e);n!==null&&Ss(s)===void 0;)s=Fc(s,n),e=oe(e),n=H(e);return s}function Wp(t,e){const n=[];return Gp(t,e,n),n.sort((s,r)=>s.order-r.order),n}function Gp(t,e,n){const s=Ss(e);if(s)for(let r=0;r<s.length;r++)n.push(s[r]);Xi(e,r=>{Gp(t,r,n)})}function Ji(t,e){const n=Ss(e);if(n){let s=0;for(let r=0;r<n.length;r++)n[r].status!==2&&(n[s]=n[r],s++);n.length=s,kp(e,n.length>0?n:void 0)}Xi(e,s=>{Ji(t,s)})}function o3(t,e){const n=Ir(Hp(t,e)),s=Fc(t.transactionQueueTree_,e);return By(s,r=>{jo(t,r)}),jo(t,s),Np(s,r=>{jo(t,r)}),n}function jo(t,e){const n=Ss(e);if(n){const s=[];let r=[],i=-1;for(let o=0;o<n.length;o++)n[o].status===3||(n[o].status===1?(b(i===o-1,"All SENT items should be at beginning of queue."),i=o,n[o].status=3,n[o].abortReason="set"):(b(n[o].status===0,"Unexpected transaction status in abort"),n[o].unwatcher(),r=r.concat(Yn(t.serverSyncTree_,n[o].currentWriteId,!0)),n[o].onComplete&&s.push(n[o].onComplete.bind(null,new Error("set"),!1,null))));i===-1?kp(e,void 0):n.length=i+1,Vn(t.eventQueue_,Ir(e),r);for(let o=0;o<s.length;o++)Ar(s[o])}}/**
1505
1505
  * @license
1506
1506
  * Copyright 2017 Google LLC
1507
1507
  *
@@ -1561,7 +1561,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1561
1561
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1562
1562
  * See the License for the specific language governing permissions and
1563
1563
  * limitations under the License.
1564
- */class Vc{constructor(e,n,s,r){this._repo=e,this._path=n,this._queryParams=s,this._orderByCalled=r}get key(){return G(this._path)?null:ep(this._path)}get ref(){return new Qt(this._repo,this._path)}get _queryIdentifier(){const e=Ih(this._queryParams),n=fc(e);return n==="{}"?"default":n}get _queryObject(){return Ih(this._queryParams)}isEqual(e){if(e=$i(e),!(e instanceof Vc))return!1;const n=this._repo===e._repo,s=_c(this._path,e._path),r=this._queryIdentifier===e._queryIdentifier;return n&&s&&r}toJSON(){return this.toString()}toString(){return this._repo.toString()+s0(this._path)}}class Qt extends Vc{constructor(e,n){super(e,n,new wc,!1)}get parent(){const e=np(this._path);return e===null?null:new Qt(this._repo,e)}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}}class gr{constructor(e,n,s){this._node=e,this.ref=n,this._index=s}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const n=new re(e),s=ki(this.ref,e);return new gr(this._node.getChild(n),s,ye)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){return this._node.isLeafNode()?!1:!!this._node.forEachChild(this._index,(s,r)=>e(new gr(r,ki(this.ref,s),ye)))}hasChild(e){const n=new re(e);return!this._node.getChild(n).isEmpty()}hasChildren(){return this._node.isLeafNode()?!1:!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Ks(t,e){return t=$i(t),t._checkNotDeleted("ref"),e!==void 0?ki(t._root,e):t._root}function ki(t,e){return t=$i(t),H(t._path)===null?Wy("child","path",e):Dp("child","path",e),new Qt(t._repo,ke(t._path,e))}class Hc{constructor(e){this.callbackContext=e}respondsTo(e){return e==="value"}createEvent(e,n){const s=n._queryParams.getIndex();return new $p("value",this,new gr(e.snapshotNode,new Qt(n._repo,n._path),s))}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,n){return this.callbackContext.hasCancelCallback?new jp(this,e,n):null}matches(e){return e instanceof Hc?!e.callbackContext||!this.callbackContext?!0:e.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}}class Gc{constructor(e,n){this.eventType=e,this.callbackContext=n}respondsTo(e){let n=e==="children_added"?"child_added":e;return n=n==="children_removed"?"child_removed":n,this.eventType===n}createCancelEvent(e,n){return this.callbackContext.hasCancelCallback?new jp(this,e,n):null}createEvent(e,n){b(e.childName!=null,"Child events should have a childName.");const s=ki(new Qt(n._repo,n._path),e.childName),r=n._queryParams.getIndex();return new $p(e.type,this,new gr(e.snapshotNode,s,r),e.prevName)}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof Gc?this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}}function qp(t,e,n,s,r){const i=new h3(n,void 0),o=e==="value"?new Hc(i):new Gc(e,i);return t3(t._repo,t,o),()=>n3(t._repo,t,o)}function Jr(t,e,n,s){return qp(t,"value",e)}function u3(t,e,n,s){return qp(t,"child_added",e)}fy(Qt);Ey(Qt);/**
1564
+ */class Vc{constructor(e,n,s,r){this._repo=e,this._path=n,this._queryParams=s,this._orderByCalled=r}get key(){return W(this._path)?null:ep(this._path)}get ref(){return new Qt(this._repo,this._path)}get _queryIdentifier(){const e=Ih(this._queryParams),n=fc(e);return n==="{}"?"default":n}get _queryObject(){return Ih(this._queryParams)}isEqual(e){if(e=$i(e),!(e instanceof Vc))return!1;const n=this._repo===e._repo,s=_c(this._path,e._path),r=this._queryIdentifier===e._queryIdentifier;return n&&s&&r}toJSON(){return this.toString()}toString(){return this._repo.toString()+s0(this._path)}}class Qt extends Vc{constructor(e,n){super(e,n,new wc,!1)}get parent(){const e=np(this._path);return e===null?null:new Qt(this._repo,e)}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}}class gr{constructor(e,n,s){this._node=e,this.ref=n,this._index=s}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const n=new re(e),s=ki(this.ref,e);return new gr(this._node.getChild(n),s,ye)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){return this._node.isLeafNode()?!1:!!this._node.forEachChild(this._index,(s,r)=>e(new gr(r,ki(this.ref,s),ye)))}hasChild(e){const n=new re(e);return!this._node.getChild(n).isEmpty()}hasChildren(){return this._node.isLeafNode()?!1:!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Ks(t,e){return t=$i(t),t._checkNotDeleted("ref"),e!==void 0?ki(t._root,e):t._root}function ki(t,e){return t=$i(t),H(t._path)===null?Gy("child","path",e):Dp("child","path",e),new Qt(t._repo,ke(t._path,e))}class Hc{constructor(e){this.callbackContext=e}respondsTo(e){return e==="value"}createEvent(e,n){const s=n._queryParams.getIndex();return new $p("value",this,new gr(e.snapshotNode,new Qt(n._repo,n._path),s))}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,n){return this.callbackContext.hasCancelCallback?new jp(this,e,n):null}matches(e){return e instanceof Hc?!e.callbackContext||!this.callbackContext?!0:e.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}}class Wc{constructor(e,n){this.eventType=e,this.callbackContext=n}respondsTo(e){let n=e==="children_added"?"child_added":e;return n=n==="children_removed"?"child_removed":n,this.eventType===n}createCancelEvent(e,n){return this.callbackContext.hasCancelCallback?new jp(this,e,n):null}createEvent(e,n){b(e.childName!=null,"Child events should have a childName.");const s=ki(new Qt(n._repo,n._path),e.childName),r=n._queryParams.getIndex();return new $p(e.type,this,new gr(e.snapshotNode,s,r),e.prevName)}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof Wc?this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}}function qp(t,e,n,s,r){const i=new h3(n,void 0),o=e==="value"?new Hc(i):new Wc(e,i);return t3(t._repo,t,o),()=>n3(t._repo,t,o)}function Jr(t,e,n,s){return qp(t,"value",e)}function u3(t,e,n,s){return qp(t,"child_added",e)}fy(Qt);Ey(Qt);/**
1565
1565
  * @license
1566
1566
  * Copyright 2020 Google LLC
1567
1567
  *
@@ -1576,7 +1576,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1576
1576
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1577
1577
  * See the License for the specific language governing permissions and
1578
1578
  * limitations under the License.
1579
- */const d3="FIREBASE_DATABASE_EMULATOR_HOST",Oa={};let f3=!1;function p3(t,e,n,s){t.repoInfo_=new jf(e,!1,t.repoInfo_.namespace,t.repoInfo_.webSocketOnly,t.repoInfo_.nodeAdmin,t.repoInfo_.persistenceKey,t.repoInfo_.includeNamespaceInQueryParams,!0,n),s&&(t.authTokenProvider_=s)}function m3(t,e,n,s,r){let i=s||t.options.databaseURL;i===void 0&&(t.options.projectId||Kt("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),Fe("Using default host for project ",t.options.projectId),i=`${t.options.projectId}-default-rtdb.firebaseio.com`);let o=jh(i,r),a=o.repoInfo,c;typeof process<"u"&&process.env&&(c=process.env[d3]),c?(i=`http://${c}?ns=${a.namespace}`,o=jh(i,r),a=o.repoInfo):o.repoInfo.secure;const l=new x2(t.name,t.options,e);$y("Invalid Firebase Database URL",o),G(o.path)||Kt("Database URL must point to the root of a Firebase Database (not including a child path).");const h=_3(a,t,l,new N2(t,n));return new y3(h,t)}function g3(t,e){const n=Oa[e];(!n||n[t.key]!==t)&&Kt(`Database ${e}(${t.repoInfo_}) has already been deleted.`),s3(t),delete n[t.key]}function _3(t,e,n,s){let r=Oa[e.name];r||(r={},Oa[e.name]=r);let i=r[t.toURLString()];return i&&Kt("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),i=new Yy(t,f3,n,s),r[t.toURLString()]=i,i}class y3{constructor(e,n){this._repoInternal=e,this.app=n,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(Xy(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Qt(this._repo,J())),this._rootInternal}_delete(){return this._rootInternal!==null&&(g3(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){this._rootInternal===null&&Kt("Cannot call "+e+" on a deleted database.")}}function zp(t=Rf(),e){const n=X1(t,"database").getImmediate({identifier:e});if(!n._instanceStarted){const s=U_("database");s&&E3(n,...s)}return n}function E3(t,e,n,s={}){t=$i(t),t._checkNotDeleted("useEmulator");const r=`${e}:${n}`,i=t._repoInternal;if(t._instanceStarted){if(r===t._repoInternal.repoInfo_.host&&pi(s,i.repoInfo_.emulatorOptions))return;Kt("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let o;if(i.repoInfo_.nodeAdmin)s.mockUserToken&&Kt('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new Xr(Xr.OWNER);else if(s.mockUserToken){const a=typeof s.mockUserToken=="string"?s.mockUserToken:V_(s.mockUserToken,t.app.options.projectId);o=new Xr(a)}p3(i,r,s,o)}/**
1579
+ */const d3="FIREBASE_DATABASE_EMULATOR_HOST",Oa={};let f3=!1;function p3(t,e,n,s){t.repoInfo_=new jf(e,!1,t.repoInfo_.namespace,t.repoInfo_.webSocketOnly,t.repoInfo_.nodeAdmin,t.repoInfo_.persistenceKey,t.repoInfo_.includeNamespaceInQueryParams,!0,n),s&&(t.authTokenProvider_=s)}function m3(t,e,n,s,r){let i=s||t.options.databaseURL;i===void 0&&(t.options.projectId||Kt("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),Fe("Using default host for project ",t.options.projectId),i=`${t.options.projectId}-default-rtdb.firebaseio.com`);let o=jh(i,r),a=o.repoInfo,c;typeof process<"u"&&process.env&&(c=process.env[d3]),c?(i=`http://${c}?ns=${a.namespace}`,o=jh(i,r),a=o.repoInfo):o.repoInfo.secure;const l=new x2(t.name,t.options,e);$y("Invalid Firebase Database URL",o),W(o.path)||Kt("Database URL must point to the root of a Firebase Database (not including a child path).");const h=_3(a,t,l,new N2(t,n));return new y3(h,t)}function g3(t,e){const n=Oa[e];(!n||n[t.key]!==t)&&Kt(`Database ${e}(${t.repoInfo_}) has already been deleted.`),s3(t),delete n[t.key]}function _3(t,e,n,s){let r=Oa[e.name];r||(r={},Oa[e.name]=r);let i=r[t.toURLString()];return i&&Kt("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),i=new Yy(t,f3,n,s),r[t.toURLString()]=i,i}class y3{constructor(e,n){this._repoInternal=e,this.app=n,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(Xy(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Qt(this._repo,J())),this._rootInternal}_delete(){return this._rootInternal!==null&&(g3(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){this._rootInternal===null&&Kt("Cannot call "+e+" on a deleted database.")}}function zp(t=Rf(),e){const n=X1(t,"database").getImmediate({identifier:e});if(!n._instanceStarted){const s=U_("database");s&&E3(n,...s)}return n}function E3(t,e,n,s={}){t=$i(t),t._checkNotDeleted("useEmulator");const r=`${e}:${n}`,i=t._repoInternal;if(t._instanceStarted){if(r===t._repoInternal.repoInfo_.host&&pi(s,i.repoInfo_.emulatorOptions))return;Kt("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let o;if(i.repoInfo_.nodeAdmin)s.mockUserToken&&Kt('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new Xr(Xr.OWNER);else if(s.mockUserToken){const a=typeof s.mockUserToken=="string"?s.mockUserToken:V_(s.mockUserToken,t.app.options.projectId);o=new Xr(a)}p3(i,r,s,o)}/**
1580
1580
  * @license
1581
1581
  * Copyright 2021 Google LLC
1582
1582
  *
@@ -1591,7 +1591,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1591
1591
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1592
1592
  * See the License for the specific language governing permissions and
1593
1593
  * limitations under the License.
1594
- */function v3(t){p2(e2),mi(new ar("database",(e,{instanceIdentifier:n})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return m3(s,r,i,n)},"PUBLIC").setMultipleInstances(!0)),Zn(dh,fh,t),Zn(dh,fh,"esm2017")}$t.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)};$t.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)};v3();class w3{constructor(e,n){w(this,"app");w(this,"handlers");w(this,"subscriptions",[]);this.app=e,this.handlers=n}attach(e){const n=zp(this.app),s=Ks(n,`${e}`),r=u3(s,u=>{var p,f;const d=u.val();d!==null&&u.key&&/^\d+$/.test(u.key)&&((f=(p=this.handlers).onWindow)==null||f.call(p,d))});this.subscriptions.push(r);const i=Ks(n,`/${e}/averaged_results/`),o=Jr(i,u=>{var p,f;const d=u.val();d!==null&&((f=(p=this.handlers).onFinal)==null||f.call(p,d),this.detachAll())});this.subscriptions.push(o);const a=Ks(n,`/${e}/error/`),c=Jr(a,u=>{var p,f;const d=u.val();d!==null&&((f=(p=this.handlers).onError)==null||f.call(p,d),this.detachAll())});this.subscriptions.push(c);const l=Ks(n,`/${e}/job_completed/`),h=Jr(l,u=>{var p,f;const d=u.val();d!==null&&(d==="failed"?((f=(p=this.handlers).onError)==null||f.call(p,{name:"ScanFailedError"}),this.detachAll()):d==="success"&&this.detachAll())});this.subscriptions.push(h)}detachAll(){for(const e of this.subscriptions)try{e()}catch{}this.subscriptions=[]}}var Fn=typeof self<"u"?self:{};function En(){throw Error("Invalid UTF8")}function qh(t,e){return e=String.fromCharCode.apply(null,e),t==null?e:t+e}let Gr,qo;const b3=typeof TextDecoder<"u";let T3;const C3=typeof TextEncoder<"u";function Kp(t){if(C3)t=(T3||(T3=new TextEncoder)).encode(t);else{let n=0;const s=new Uint8Array(3*t.length);for(let r=0;r<t.length;r++){var e=t.charCodeAt(r);if(e<128)s[n++]=e;else{if(e<2048)s[n++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&r<t.length){const i=t.charCodeAt(++r);if(i>=56320&&i<=57343){e=1024*(e-55296)+i-56320+65536,s[n++]=e>>18|240,s[n++]=e>>12&63|128,s[n++]=e>>6&63|128,s[n++]=63&e|128;continue}r--}e=65533}s[n++]=e>>12|224,s[n++]=e>>6&63|128}s[n++]=63&e|128}}t=n===s.length?s:s.subarray(0,n)}return t}var Wc,Ii;e:{for(var zh=["CLOSURE_FLAGS"],zo=Fn,Ko=0;Ko<zh.length;Ko++)if((zo=zo[zh[Ko]])==null){Ii=null;break e}Ii=zo}var _r,Kh=Ii&&Ii[610401301];Wc=Kh!=null&&Kh;const Yh=Fn.navigator;function La(t){return!!Wc&&!!_r&&_r.brands.some(({brand:e})=>e&&e.indexOf(t)!=-1)}function ut(t){var e;return(e=Fn.navigator)&&(e=e.userAgent)||(e=""),e.indexOf(t)!=-1}function nn(){return!!Wc&&!!_r&&_r.brands.length>0}function Yo(){return nn()?La("Chromium"):(ut("Chrome")||ut("CriOS"))&&!(!nn()&&ut("Edge"))||ut("Silk")}function $c(t){return $c[" "](t),t}_r=Yh&&Yh.userAgentData||null,$c[" "]=function(){};var S3=!nn()&&(ut("Trident")||ut("MSIE"));!ut("Android")||Yo(),Yo(),ut("Safari")&&(Yo()||!nn()&&ut("Coast")||!nn()&&ut("Opera")||!nn()&&ut("Edge")||(nn()?La("Microsoft Edge"):ut("Edg/"))||nn()&&La("Opera"));var Yp={},Ys=null;function A3(t){const e=t.length;let n=3*e/4;n%3?n=Math.floor(n):"=.".indexOf(t[e-1])!=-1&&(n="=.".indexOf(t[e-2])!=-1?n-2:n-1);const s=new Uint8Array(n);let r=0;return function(i,o){function a(l){for(;c<i.length;){const h=i.charAt(c++),u=Ys[h];if(u!=null)return u;if(!/^[\s\xa0]*$/.test(h))throw Error("Unknown base64 encoding at char: "+h)}return l}Xp();let c=0;for(;;){const l=a(-1),h=a(0),u=a(64),d=a(64);if(d===64&&l===-1)break;o(l<<2|h>>4),u!=64&&(o(h<<4&240|u>>2),d!=64&&o(u<<6&192|d))}}(t,function(i){s[r++]=i}),r!==n?s.subarray(0,r):s}function Xp(){if(!Ys){Ys={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let n=0;n<5;n++){const s=t.concat(e[n].split(""));Yp[n]=s;for(let r=0;r<s.length;r++){const i=s[r];Ys[i]===void 0&&(Ys[i]=r)}}}}var Jp=typeof Uint8Array<"u",Qp=!S3&&typeof btoa=="function";function Xh(t){if(!Qp){var e;e===void 0&&(e=0),Xp(),e=Yp[e];var n=Array(Math.floor(t.length/3)),s=e[64]||"";let c=0,l=0;for(;c<t.length-2;c+=3){var r=t[c],i=t[c+1],o=t[c+2],a=e[r>>2];r=e[(3&r)<<4|i>>4],i=e[(15&i)<<2|o>>6],o=e[63&o],n[l++]=a+r+i+o}switch(a=0,o=s,t.length-c){case 2:o=e[(15&(a=t[c+1]))<<2]||s;case 1:t=t[c],n[l]=e[t>>2]+e[(3&t)<<4|a>>4]+o+s}return n.join("")}for(e="",n=0,s=t.length-10240;n<s;)e+=String.fromCharCode.apply(null,t.subarray(n,n+=10240));return e+=String.fromCharCode.apply(null,n?t.subarray(n):t),btoa(e)}const Jh=/[-_.]/g,R3={"-":"+",_:"/",".":"="};function k3(t){return R3[t]||""}function Zp(t){if(!Qp)return A3(t);Jh.test(t)&&(t=t.replace(Jh,k3)),t=atob(t);const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}function Nr(t){return Jp&&t!=null&&t instanceof Uint8Array}var fs={};function Mn(){return I3||(I3=new jt(null,fs))}function jc(t){em(fs);var e=t.g;return(e=e==null||Nr(e)?e:typeof e=="string"?Zp(e):null)==null?e:t.g=e}var jt=class{h(){return new Uint8Array(jc(this)||0)}constructor(t,e){if(em(e),this.g=t,t!=null&&t.length===0)throw Error("ByteString should be constructed with non-empty values")}};let I3,N3;function em(t){if(t!==fs)throw Error("illegal external caller")}function tm(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}function Da(t){return tm(t=Error(t),"warning"),t}var Qi=typeof Symbol=="function"&&typeof Symbol()=="symbol",x3=new Set;function xr(t,e,n=!1,s=!1){return t=typeof Symbol=="function"&&typeof Symbol()=="symbol"?s&&Symbol.for&&t?Symbol.for(t):t!=null?Symbol(t):Symbol():e,n&&x3.add(t),t}var O3=xr("jas",void 0,!0,!0),Qh=xr(void 0,"0di"),Xo=xr(void 0,"2ex"),Ws=xr(void 0,"1oa",!0),ps=xr(void 0,Symbol(),!0);const O=Qi?O3:"Ga",nm={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},sm=Object.defineProperties;function Zi(t,e){Qi||O in t||sm(t,nm),t[O]|=e}function be(t,e){Qi||O in t||sm(t,nm),t[O]=e}function As(t){return Zi(t,34),t}function L3(t,e){be(e,-30975&(0|t))}function Pa(t,e){be(e,-30941&(34|t))}function qc(){return typeof BigInt=="function"}function qe(t){return Array.prototype.slice.call(t)}var zc,Or={},rm={};function Zh(t){return!(!t||typeof t!="object"||t.Ia!==rm)}function Kc(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&t.constructor===Object}function Yc(t,e){if(t!=null){if(typeof t=="string")t=t?new jt(t,fs):Mn();else if(t.constructor!==jt)if(Nr(t))t=t.length?new jt(new Uint8Array(t),fs):Mn();else{if(!e)throw Error();t=void 0}}return t}function Ni(t){return!(!Array.isArray(t)||t.length)&&!!(1&(0|t[O]))}const eu=[];function gn(t){if(2&t)throw Error()}be(eu,55),zc=Object.freeze(eu);class xi{constructor(e,n,s){this.l=0,this.g=e,this.h=n,this.m=s}next(){if(this.l<this.g.length){const e=this.g[this.l++];return{done:!1,value:this.h?this.h.call(this.m,e):e}}return{done:!0,value:void 0}}[Symbol.iterator](){return new xi(this.g,this.h,this.m)}}function Xc(t){return ps?t[ps]:void 0}var D3=Object.freeze({});function eo(t){return t.Qa=!0,t}var P3=eo(t=>typeof t=="number"),tu=eo(t=>typeof t=="string"),F3=eo(t=>typeof t=="boolean"),to=typeof Fn.BigInt=="function"&&typeof Fn.BigInt(0)=="bigint",Fa=eo(t=>to?t>=B3&&t<=V3:t[0]==="-"?nu(t,M3):nu(t,U3));const M3=Number.MIN_SAFE_INTEGER.toString(),B3=to?BigInt(Number.MIN_SAFE_INTEGER):void 0,U3=Number.MAX_SAFE_INTEGER.toString(),V3=to?BigInt(Number.MAX_SAFE_INTEGER):void 0;function nu(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let n=0;n<t.length;n++){const s=t[n],r=e[n];if(s>r)return!1;if(s<r)return!0}}const H3=typeof Uint8Array.prototype.slice=="function";let im,se=0,_e=0;function su(t){const e=t>>>0;se=e,_e=(t-e)/4294967296>>>0}function ms(t){if(t<0){su(-t);const[e,n]=el(se,_e);se=e>>>0,_e=n>>>0}else su(t)}function Jc(t){const e=im||(im=new DataView(new ArrayBuffer(8)));e.setFloat32(0,+t,!0),_e=0,se=e.getUint32(0,!0)}function Qc(t,e){const n=4294967296*e+(t>>>0);return Number.isSafeInteger(n)?n:yr(t,e)}function Zc(t,e){const n=2147483648&e;return n&&(e=~e>>>0,(t=1+~t>>>0)==0&&(e=e+1>>>0)),typeof(t=Qc(t,e))=="number"?n?-t:t:n?"-"+t:t}function yr(t,e){if(t>>>=0,(e>>>=0)<=2097151)var n=""+(4294967296*e+t);else qc()?n=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(n=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),n+=8147497*e,e*=2,t>=1e7&&(n+=t/1e7>>>0,t%=1e7),n>=1e7&&(e+=n/1e7>>>0,n%=1e7),n=e+ru(n)+ru(t));return n}function ru(t){return t=String(t),"0000000".slice(t.length)+t}function no(t){if(t.length<16)ms(Number(t));else if(qc())t=BigInt(t),se=Number(t&BigInt(4294967295))>>>0,_e=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+(t[0]==="-");_e=se=0;const n=t.length;for(let s=e,r=(n-e)%6+e;r<=n;s=r,r+=6){const i=Number(t.slice(s,r));_e*=1e6,se=1e6*se+i,se>=4294967296&&(_e+=Math.trunc(se/4294967296),_e>>>=0,se>>>=0)}if(e){const[s,r]=el(se,_e);se=s,_e=r}}}function el(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}const tl=typeof BigInt=="function"?BigInt.asIntN:void 0,G3=typeof BigInt=="function"?BigInt.asUintN:void 0,ss=Number.isSafeInteger,so=Number.isFinite,Oi=Math.trunc;function _n(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function om(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const W3=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function ro(t){switch(typeof t){case"bigint":return!0;case"number":return so(t);case"string":return W3.test(t);default:return!1}}function Rs(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return so(t)?0|t:void 0}function am(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return so(t)?t>>>0:void 0}function iu(t){if(t[0]==="-")return!1;const e=t.length;return e<20||e===20&&Number(t.substring(0,6))<184467}function nl(t){return t=Oi(t),ss(t)||(ms(t),t=Zc(se,_e)),t}function sl(t){var e=Oi(Number(t));if(ss(e))return String(e);if((e=t.indexOf("."))!==-1&&(t=t.substring(0,e)),e=t.length,!(t[0]==="-"?e<20||e===20&&Number(t.substring(0,7))>-922337:e<19||e===19&&Number(t.substring(0,6))<922337))if(no(t),t=se,2147483648&(e=_e))if(qc())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{const[n,s]=el(t,e);t="-"+yr(n,s)}else t=yr(t,e);return t}function Li(t){return t==null?t:typeof t=="bigint"?(Fa(t)?t=Number(t):(t=tl(64,t),t=Fa(t)?Number(t):String(t)),t):ro(t)?typeof t=="number"?nl(t):sl(t):void 0}function $3(t){if(t==null)return t;var e=typeof t;if(e==="bigint")return String(G3(64,t));if(ro(t)){if(e==="string")return e=Oi(Number(t)),ss(e)&&e>=0?t=String(e):((e=t.indexOf("."))!==-1&&(t=t.substring(0,e)),iu(t)||(no(t),t=yr(se,_e))),t;if(e==="number")return(t=Oi(t))>=0&&ss(t)?t:function(n){if(n<0){ms(n);var s=yr(se,_e);return n=Number(s),ss(n)?n:s}return iu(s=String(n))?s:(ms(n),Qc(se,_e))}(t)}}function cm(t){if(typeof t!="string")throw Error();return t}function ks(t){if(t!=null&&typeof t!="string")throw Error();return t}function gs(t){return t==null||typeof t=="string"?t:void 0}function rl(t,e,n,s){if(t!=null&&typeof t=="object"&&t.W===Or)return t;if(!Array.isArray(t))return n?2&s?((t=e[Qh])||(As((t=new e).u),t=e[Qh]=t),e=t):e=new e:e=void 0,e;let r=n=0|t[O];return r===0&&(r|=32&s),r|=2&s,r!==n&&be(t,r),new e(t)}function j3(t,e,n){if(e)e:{if(!ro(e=t))throw Da("int64");switch(typeof e){case"string":e=sl(e);break e;case"bigint":if(t=e=tl(64,e),tu(t)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(t))throw Error(String(t))}else if(P3(t)&&!Number.isSafeInteger(t))throw Error(String(t));e=to?BigInt(e):F3(e)?e?"1":"0":tu(e)?e.trim()||"0":String(e);break e;default:e=nl(e)}}else e=Li(t);return typeof(n=(t=e)==null?n?0:void 0:t)=="string"&&ss(e=+n)?e:n}const q3={};let z3=function(){try{return $c(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class Jo{constructor(){this.g=new Map}get(e){return this.g.get(e)}set(e,n){return this.g.set(e,n),this.size=this.g.size,this}delete(e){return e=this.g.delete(e),this.size=this.g.size,e}clear(){this.g.clear(),this.size=this.g.size}has(e){return this.g.has(e)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(e,n){return this.g.forEach(e,n)}[Symbol.iterator](){return this.entries()}}const K3=z3?(Object.setPrototypeOf(Jo.prototype,Map.prototype),Object.defineProperties(Jo.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Jo):class extends Map{constructor(){super()}};function ou(t){return t}function Qo(t){if(2&t.L)throw Error("Cannot mutate an immutable Map")}var pt=class extends K3{constructor(t,e,n=ou,s=ou){super();let r=0|t[O];r|=64,be(t,r),this.L=r,this.S=e,this.R=n,this.Y=this.S?Y3:s;for(let i=0;i<t.length;i++){const o=t[i],a=n(o[0],!1,!0);let c=o[1];e?c===void 0&&(c=null):c=s(o[1],!1,!0,void 0,void 0,r),super.set(a,c)}}na(t=au){if(this.size!==0)return this.X(t)}X(t=au){const e=[],n=super.entries();for(var s;!(s=n.next()).done;)(s=s.value)[0]=t(s[0]),s[1]=t(s[1]),e.push(s);return e}clear(){Qo(this),super.clear()}delete(t){return Qo(this),super.delete(this.R(t,!0,!1))}entries(){var t=this.ma();return new xi(t,X3,this)}keys(){return this.Ha()}values(){var t=this.ma();return new xi(t,pt.prototype.get,this)}forEach(t,e){super.forEach((n,s)=>{t.call(e,this.get(s),s,this)})}set(t,e){return Qo(this),(t=this.R(t,!0,!1))==null?this:e==null?(super.delete(t),this):super.set(t,this.Y(e,!0,!0,this.S,!1,this.L))}Na(t){const e=this.R(t[0],!1,!0);t=t[1],t=this.S?t===void 0?null:t:this.Y(t,!1,!0,void 0,!1,this.L),super.set(e,t)}has(t){return super.has(this.R(t,!1,!1))}get(t){t=this.R(t,!1,!1);const e=super.get(t);if(e!==void 0){var n=this.S;return n?((n=this.Y(e,!1,!0,n,this.ra,this.L))!==e&&super.set(t,n),n):e}}ma(){return Array.from(super.keys())}Ha(){return super.keys()}[Symbol.iterator](){return this.entries()}};function Y3(t,e,n,s,r,i){return t=rl(t,s,n,i),r&&(t=oo(t)),t}function au(t){return t}function X3(t){return[t,this.get(t)]}let J3,lm,Q3;function cu(){return J3||(J3=new pt(As([]),void 0,void 0,void 0,q3))}function il(t,e,n,s,r){if(t!=null){if(Array.isArray(t))t=Ni(t)?void 0:r&&2&(0|t[O])?t:ol(t,e,n,s!==void 0,r);else if(Kc(t)){const i={};for(let o in t)i[o]=il(t[o],e,n,s,r);t=i}else t=e(t,s);return t}}function ol(t,e,n,s,r){const i=s||n?0|t[O]:0,o=s?!!(32&i):void 0;s=qe(t);for(let a=0;a<s.length;a++)s[a]=il(s[a],e,n,o,r);return n&&((t=Xc(t))&&(s[ps]=qe(t)),n(i,s)),s}function Z3(t){return il(t,hm,void 0,void 0,!1)}function hm(t){return t.W===Or?t.toJSON():t instanceof pt?t.na(Z3):function(e){switch(typeof e){case"number":return isFinite(e)?e:String(e);case"bigint":return Fa(e)?Number(e):String(e);case"boolean":return e?1:0;case"object":if(e)if(Array.isArray(e)){if(Ni(e))return}else{if(Nr(e))return Xh(e);if(e instanceof jt){const n=e.g;return n==null?"":typeof n=="string"?n:e.g=Xh(n)}if(e instanceof pt)return e.na()}}return e}(t)}function um(t){return ol(t,hm,void 0,void 0,!1)}function cn(t,e,n){return t=dm(t,e[0],e[1],n?1:2),e!==lm&&n&&Zi(t,16384),t}function dm(t,e,n,s){if(t==null){var r=96;n?(t=[n],r|=512):t=[],e&&(r=-33521665&r|(1023&e)<<15)}else{if(!Array.isArray(t))throw Error("narr");if(2048&(r=0|t[O]))throw Error("farr");if(64&r)return t;if(s===1||s===2||(r|=64),n&&(r|=512,n!==t[0]))throw Error("mid");e:{if(s=(n=t).length){const i=s-1;if(Kc(n[i])){if((e=i-(512&(r|=256)?0:-1))>=1024)throw Error("pvtlmt");r=-33521665&r|(1023&e)<<15;break e}}if(e){if((e=Math.max(e,s-(512&r?0:-1)))>1024)throw Error("spvt");r=-33521665&r|(1023&e)<<15}}}return be(t,r),t}function Ma(t,e,n=Pa){if(t!=null){if(Jp&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var s=0|t[O];return 2&s?t:(e&&(e=s===0||!!(32&s)&&!(64&s||!(16&s))),e?(be(t,-12293&(34|s)),t):ol(t,Ma,4&s?Pa:n,!0,!0))}return t.W===Or?t=2&(s=0|(n=t.u)[O])?t:new t.constructor(io(n,s,!0)):t instanceof pt&&!(2&t.L)&&(n=As(t.X(Ma)),t=new pt(n,t.S,t.R,t.Y)),t}}function io(t,e,n){const s=n||2&e?Pa:L3,r=!!(32&e);return t=function(i,o,a){const c=qe(i);var l=c.length;const h=256&o?c[l-1]:void 0;for(l+=h?-1:0,o=512&o?1:0;o<l;o++)c[o]=a(c[o]);if(h){o=c[o]={};for(const u in h)o[u]=a(h[u])}return(i=Xc(i))&&(c[ps]=qe(i)),c}(t,e,i=>Ma(i,r,s)),Zi(t,32|(n?2:0)),t}function oo(t){const e=t.u,n=0|e[O];return 2&n?new t.constructor(io(e,n,!1)):t}function _s(t,e){return Zt(t=t.u,0|t[O],e)}function Zt(t,e,n,s){if(n===-1)return null;var r=n+(512&e?0:-1);const i=t.length-1;return r>=i&&256&e?t[i][n]:s&&256&e&&(e=t[i][n])!=null?(t[r]!=null&&Xo!=null&&((r=(t=N3??(N3={}))[Xo]||0)>=4||(t[Xo]=r+1,tm(t=Error(),"incident"),function(o){Fn.setTimeout(()=>{throw o},0)}(t))),e):r<=i?t[r]:void 0}function ae(t,e,n){const s=t.u;let r=0|s[O];return gn(r),ge(s,r,e,n),t}function ge(t,e,n,s){const r=512&e?0:-1,i=n+r;var o=t.length-1;return i>=o&&256&e?(t[o][n]=s,e):i<=o?(t[i]=s,256&e&&n in(t=t[o])&&delete t[n],e):(s!==void 0&&(n>=(o=e>>15&1023||536870912)?s!=null&&(t[o+r]={[n]:s},be(t,e|=256)):t[i]=s),e)}function Qr(t,e){let n=0|(t=t.u)[O];const s=Zt(t,n,e),r=_n(s);return r!=null&&r!==s&&ge(t,n,e,r),r}function fm(t){let e=0|(t=t.u)[O];const n=Zt(t,e,1),s=Yc(n,!0);return s!=null&&s!==n&&ge(t,e,1,s),s}function Rn(){return D3===void 0?2:4}function kn(t,e,n,s,r){const i=t.u,o=2&(t=0|i[O])?1:s;r=!!r;let a=0|(s=al(i,t,e))[O];if(!(4&a)){4&a&&(s=qe(s),a=qt(a,t),t=ge(i,t,e,s));let c=0,l=0;for(;c<s.length;c++){const h=n(s[c]);h!=null&&(s[l++]=h)}l<c&&(s.length=l),a=cl(a,t),n=-4097&(20|a),a=n&=-8193,be(s,a),2&a&&Object.freeze(s)}return o===1||o===4&&32&a?Wt(a)||(r=a,a|=2,a!==r&&be(s,a),Object.freeze(s)):(o===2&&Wt(a)&&(s=qe(s),a=qt(a,t),a=ln(a,t,r),be(s,a),t=ge(i,t,e,s)),Wt(a)||(e=a,a=ln(a,t,r),a!==e&&be(s,a))),s}function al(t,e,n,s){return t=Zt(t,e,n,s),Array.isArray(t)?t:zc}function cl(t,e){return t===0&&(t=qt(t,e)),1|t}function Wt(t){return!!(2&t)&&!!(4&t)||!!(2048&t)}function pm(t){t=qe(t);for(let e=0;e<t.length;e++){const n=t[e]=qe(t[e]);Array.isArray(n[1])&&(n[1]=As(n[1]))}return t}function Ba(t,e,n,s){let r=0|(t=t.u)[O];gn(r),ge(t,r,e,(s==="0"?Number(n)===0:n===s)?void 0:n)}function Is(t,e,n,s,r){gn(e);var i=!(!(64&e)&&16384&e);const o=(r=al(t,e,n,r))!==zc;if(i||!o){let a=i=o?0|r[O]:0;(!o||2&a||Wt(a)||4&a&&!(32&a))&&(r=qe(r),a=qt(a,e),e=ge(t,e,n,r)),a=-13&cl(a,e),a=ln(s?-17&a:16|a,e,!0),a!==i&&be(r,a)}return r}function Zo(t,e){var n=sg;return hl(ll(t=t.u),t,0|t[O],n)===e?e:-1}function ll(t){if(Qi)return t[Ws]??(t[Ws]=new Map);if(Ws in t)return t[Ws];const e=new Map;return Object.defineProperty(t,Ws,{value:e}),e}function mm(t,e,n,s){const r=ll(t),i=hl(r,t,e,n);return i!==s&&(i&&(e=ge(t,e,i)),r.set(n,s)),e}function hl(t,e,n,s){let r=t.get(s);if(r!=null)return r;r=0;for(let i=0;i<s.length;i++){const o=s[i];Zt(e,n,o)!=null&&(r!==0&&(n=ge(e,n,r)),r=o)}return t.set(s,r),r}function ul(t,e,n,s){let r,i=0|t[O];if((s=Zt(t,i,n,s))!=null&&s.W===Or)return(e=oo(s))!==s&&ge(t,i,n,e),e.u;if(Array.isArray(s)){const o=0|s[O];r=2&o?cn(io(s,o,!1),e,!0):64&o?s:cn(r,e,!0)}else r=cn(void 0,e,!0);return r!==s&&ge(t,i,n,r),r}function gm(t,e,n,s){let r=0|(t=t.u)[O];return(e=rl(s=Zt(t,r,n,s),e,!1,r))!==s&&e!=null&&ge(t,r,n,e),e}function Y(t,e,n,s=!1){if((e=gm(t,e,n,s))==null)return e;if(!(2&(s=0|(t=t.u)[O]))){const r=oo(e);r!==e&&ge(t,s,n,e=r)}return e}function _m(t,e,n,s,r,i,o){t=t.u;var a=!!(2&e);const c=a?1:r;i=!!i,o&&(o=!a);var l=0|(r=al(t,e,s))[O];if(!(a=!!(4&l))){var h=r,u=e;const d=!!(2&(l=cl(l,e)));d&&(u|=2);let p=!d,f=!0,g=0,E=0;for(;g<h.length;g++){const R=rl(h[g],n,!1,u);if(R instanceof n){if(!d){const y=!!(2&(0|R.u[O]));p&&(p=!y),f&&(f=y)}h[E++]=R}}E<g&&(h.length=E),l|=4,l=f?16|l:-17&l,be(h,l=p?8|l:-9&l),d&&Object.freeze(h)}if(o&&!(8&l||!r.length&&(c===1||c===4&&32&l))){for(Wt(l)&&(r=qe(r),l=qt(l,e),e=ge(t,e,s,r)),n=r,o=l,h=0;h<n.length;h++)(l=n[h])!==(u=oo(l))&&(n[h]=u);o|=8,be(n,o=n.length?-17&o:16|o),l=o}return c===1||c===4&&32&l?Wt(l)||(e=l,(l|=!r.length||16&l&&(!a||32&l)?2:2048)!==e&&be(r,l),Object.freeze(r)):(c===2&&Wt(l)&&(be(r=qe(r),l=ln(l=qt(l,e),e,i)),e=ge(t,e,s,r)),Wt(l)||(s=l,(l=ln(l,e,i))!==s&&be(r,l))),r}function Yt(t,e,n){const s=0|t.u[O];return _m(t,s,e,n,Rn(),!1,!(2&s))}function L(t,e,n,s){return s==null&&(s=void 0),ae(t,n,s)}function sr(t,e,n,s){s==null&&(s=void 0);e:{let r=0|(t=t.u)[O];if(gn(r),s==null){const i=ll(t);if(hl(i,t,r,n)!==e)break e;i.set(n,0)}else r=mm(t,r,n,e);ge(t,r,e,s)}}function qt(t,e){return-2049&(t=32|(2&e?2|t:-3&t))}function ln(t,e,n){return 32&e&&n||(t&=-33),t}function Di(t,e,n,s){const r=0|t.u[O];gn(r),t=_m(t,r,n,e,2,!0),s=s??new n,t.push(s),t[O]=2&(0|s.u[O])?-9&t[O]:-17&t[O]}function ft(t,e){return Rs(_s(t,e))}function mt(t,e){return gs(_s(t,e))}function ve(t,e){return Qr(t,e)??0}function Er(t,e,n){if(n!=null&&typeof n!="boolean")throw t=typeof n,Error(`Expected boolean but got ${t!="object"?t:n?Array.isArray(n)?"array":t:"null"}: ${n}`);ae(t,e,n)}function Ft(t,e,n){if(n!=null){if(typeof n!="number"||!so(n))throw Da("int32");n|=0}ae(t,e,n)}function N(t,e,n){if(n!=null&&typeof n!="number")throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);ae(t,e,n)}function Pi(t,e,n){{const o=t.u;let a=0|o[O];if(gn(a),n==null)ge(o,a,e);else{var s=t=0|n[O],r=Wt(t),i=r||Object.isFrozen(n);for(r||(t=0),i||(n=qe(n),s=0,t=ln(t=qt(t,a),a,!0),i=!1),t|=21,r=0;r<n.length;r++){const c=n[r],l=cm(c);Object.is(c,l)||(i&&(n=qe(n),s=0,t=ln(t=qt(t,a),a,!0),i=!1),n[r]=l)}t!==s&&(i&&(n=qe(n),t=ln(t=qt(t,a),a,!0)),be(n,t)),ge(o,a,e,n)}}}function ao(t,e,n){gn(0|t.u[O]),kn(t,e,gs,2,!0).push(cm(n))}function ym(t,e){return Error(`Invalid wire type: ${t} (at position ${e})`)}function dl(){return Error("Failed to read varint, encoding is invalid.")}function Em(t,e){return Error(`Tried to read past the end of the data ${e} > ${t}`)}function fl(t){if(typeof t=="string")return{buffer:Zp(t),N:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),N:!1};if(t.constructor===Uint8Array)return{buffer:t,N:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),N:!1};if(t.constructor===jt)return{buffer:jc(t)||new Uint8Array(0),N:!0};if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),N:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function pl(t,e){let n,s=0,r=0,i=0;const o=t.h;let a=t.g;do n=o[a++],s|=(127&n)<<i,i+=7;while(i<32&&128&n);for(i>32&&(r|=(127&n)>>4),i=3;i<32&&128&n;i+=7)n=o[a++],r|=(127&n)<<i;if(Nn(t,a),n<128)return e(s>>>0,r>>>0);throw dl()}function ml(t){let e=0,n=t.g;const s=n+10,r=t.h;for(;n<s;){const i=r[n++];if(e|=i,(128&i)==0)return Nn(t,n),!!(127&e)}throw dl()}function fn(t){const e=t.h;let n=t.g,s=e[n++],r=127&s;if(128&s&&(s=e[n++],r|=(127&s)<<7,128&s&&(s=e[n++],r|=(127&s)<<14,128&s&&(s=e[n++],r|=(127&s)<<21,128&s&&(s=e[n++],r|=s<<28,128&s&&128&e[n++]&&128&e[n++]&&128&e[n++]&&128&e[n++]&&128&e[n++])))))throw dl();return Nn(t,n),r}function Xt(t){return fn(t)>>>0}function Ua(t){var e=t.h;const n=t.g,s=e[n],r=e[n+1],i=e[n+2];return e=e[n+3],Nn(t,t.g+4),(s<<0|r<<8|i<<16|e<<24)>>>0}function Va(t){var e=Ua(t);t=2*(e>>31)+1;const n=e>>>23&255;return e&=8388607,n==255?e?NaN:t*(1/0):n==0?1401298464324817e-60*t*e:t*Math.pow(2,n-150)*(e+8388608)}function eE(t){return fn(t)}function ea(t,e,{ba:n=!1}={}){t.ba=n,e&&(e=fl(e),t.h=e.buffer,t.m=e.N,t.j=0,t.l=t.h.length,t.g=t.j)}function Nn(t,e){if(t.g=e,e>t.l)throw Em(t.l,e)}function vm(t,e){if(e<0)throw Error(`Tried to read a negative byte length: ${e}`);const n=t.g,s=n+e;if(s>t.l)throw Em(e,t.l-n);return t.g=s,n}function wm(t,e){if(e==0)return Mn();var n=vm(t,e);return t.ba&&t.m?n=t.h.subarray(n,n+e):(t=t.h,n=n===(e=n+e)?new Uint8Array(0):H3?t.slice(n,e):new Uint8Array(t.subarray(n,e))),n.length==0?Mn():new jt(n,fs)}pt.prototype.toJSON=void 0,pt.prototype.Ia=rm;var lu=[];function bm(t){var e=t.g;if(e.g==e.l)return!1;t.l=t.g.g;var n=Xt(t.g);if(e=n>>>3,!((n&=7)>=0&&n<=5))throw ym(n,t.l);if(e<1)throw Error(`Invalid field number: ${e} (at position ${t.l})`);return t.m=e,t.h=n,!0}function Zr(t){switch(t.h){case 0:t.h!=0?Zr(t):ml(t.g);break;case 1:Nn(t=t.g,t.g+8);break;case 2:if(t.h!=2)Zr(t);else{var e=Xt(t.g);Nn(t=t.g,t.g+e)}break;case 5:Nn(t=t.g,t.g+4);break;case 3:for(e=t.m;;){if(!bm(t))throw Error("Unmatched start-group tag: stream EOF");if(t.h==4){if(t.m!=e)throw Error("Unmatched end-group tag");break}Zr(t)}break;default:throw ym(t.h,t.l)}}function Lr(t,e,n){const s=t.g.l,r=Xt(t.g),i=t.g.g+r;let o=i-s;if(o<=0&&(t.g.l=i,n(e,t,void 0,void 0,void 0),o=i-t.g.g),o)throw Error(`Message parsing ended unexpectedly. Expected to read ${r} bytes, instead read ${r-o} bytes, either the data ended unexpectedly or the message misreported its own length`);return t.g.g=i,t.g.l=s,e}function gl(t){var e=Xt(t.g),n=vm(t=t.g,e);if(t=t.h,b3){var s,r=t;(s=qo)||(s=qo=new TextDecoder("utf-8",{fatal:!0})),e=n+e,r=n===0&&e===r.length?r:r.subarray(n,e);try{var i=s.decode(r)}catch(a){if(Gr===void 0){try{s.decode(new Uint8Array([128]))}catch{}try{s.decode(new Uint8Array([97])),Gr=!0}catch{Gr=!1}}throw!Gr&&(qo=void 0),a}}else{e=(i=n)+e,n=[];let a,c=null;for(;i<e;){var o=t[i++];o<128?n.push(o):o<224?i>=e?En():(a=t[i++],o<194||(192&a)!=128?(i--,En()):n.push((31&o)<<6|63&a)):o<240?i>=e-1?En():(a=t[i++],(192&a)!=128||o===224&&a<160||o===237&&a>=160||(192&(s=t[i++]))!=128?(i--,En()):n.push((15&o)<<12|(63&a)<<6|63&s)):o<=244?i>=e-2?En():(a=t[i++],(192&a)!=128||a-144+(o<<28)>>30!=0||(192&(s=t[i++]))!=128||(192&(r=t[i++]))!=128?(i--,En()):(o=(7&o)<<18|(63&a)<<12|(63&s)<<6|63&r,o-=65536,n.push(55296+(o>>10&1023),56320+(1023&o)))):En(),n.length>=8192&&(c=qh(c,n),n.length=0)}i=qh(c,n)}return i}function Tm(t){const e=Xt(t.g);return wm(t.g,e)}function co(t,e,n){var s=Xt(t.g);for(s=t.g.g+s;t.g.g<s;)n.push(e(t.g))}var Wr=[];function tE(t){return t}let rs;function Ct(t,e,n){e.g?e.m(t,e.g,e.h,n):e.m(t,e.h,n)}var k=class{constructor(t,e){this.u=dm(t,e)}toJSON(){const t=!rs;try{return t&&(rs=um),Cm(this)}finally{t&&(rs=void 0)}}l(){var t=ME;return t.g?t.l(this,t.g,t.h,!0):t.l(this,t.h,t.defaultValue,!0)}clone(){const t=this.u;return new this.constructor(io(t,0|t[O],!1))}N(){return!!(2&(0|this.u[O]))}};function Cm(t){var e=t.u;{e=(t=rs(e))!==e;let l=t.length;if(l){var n=t[l-1],s=Kc(n);s?l--:n=void 0;var r=t;if(s){e:{var i,o=n,a=!1;if(o)for(let h in o)isNaN(+h)?(i??(i={}))[h]=o[h]:(s=o[h],Array.isArray(s)&&(Ni(s)||Zh(s)&&s.size===0)&&(s=null),s==null&&(a=!0),s!=null&&((i??(i={}))[h]=s));if(a||(i=o),i)for(let h in i){a=i;break e}a=null}o=a==null?n!=null:a!==n}for(;l>0&&((i=r[l-1])==null||Ni(i)||Zh(i)&&i.size===0);l--)var c=!0;(r!==t||o||c)&&(e?(c||o||a)&&(r.length=l):r=Array.prototype.slice.call(r,0,l),a&&r.push(a)),c=r}else c=t}return c}function hu(t){return t?/^\d+$/.test(t)?(no(t),new Ha(se,_e)):null:nE||(nE=new Ha(0,0))}k.prototype.W=Or,k.prototype.toString=function(){try{return rs=tE,Cm(this).toString()}finally{rs=void 0}};var Ha=class{constructor(t,e){this.h=t>>>0,this.g=e>>>0}};let nE;function uu(t){return t?/^-?\d+$/.test(t)?(no(t),new Ga(se,_e)):null:sE||(sE=new Ga(0,0))}var Ga=class{constructor(t,e){this.h=t>>>0,this.g=e>>>0}};let sE;function is(t,e,n){for(;n>0||e>127;)t.g.push(127&e|128),e=(e>>>7|n<<25)>>>0,n>>>=7;t.g.push(e)}function Ns(t,e){for(;e>127;)t.g.push(127&e|128),e>>>=7;t.g.push(e)}function lo(t,e){if(e>=0)Ns(t,e);else{for(let n=0;n<9;n++)t.g.push(127&e|128),e>>=7;t.g.push(1)}}function vr(t,e){t.g.push(e>>>0&255),t.g.push(e>>>8&255),t.g.push(e>>>16&255),t.g.push(e>>>24&255)}function ys(t,e){e.length!==0&&(t.l.push(e),t.h+=e.length)}function it(t,e,n){Ns(t.g,8*e+n)}function _l(t,e){return it(t,e,2),e=t.g.end(),ys(t,e),e.push(t.h),e}function yl(t,e){var n=e.pop();for(n=t.h+t.g.length()-n;n>127;)e.push(127&n|128),n>>>=7,t.h++;e.push(n),t.h++}function ho(t,e,n){it(t,e,2),Ns(t.g,n.length),ys(t,t.g.end()),ys(t,n)}function Fi(t,e,n,s){n!=null&&(e=_l(t,e),s(n,t),yl(t,e))}function St(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var El=St(),Sm=St(),vl=St(),wl=St(),Am=St(),Rm=St(),bl=St(),km=St(),Im=St(),xs=class{constructor(t,e,n){this.g=t,this.h=e,t=El,this.l=!!t&&n===t||!1}};function uo(t,e){return new xs(t,e,El)}function Nm(t,e,n,s,r){Fi(t,n,Dm(e,s),r)}const rE=uo(function(t,e,n,s,r){return t.h===2&&(Lr(t,ul(e,s,n),r),!0)},Nm),iE=uo(function(t,e,n,s,r){return t.h===2&&(Lr(t,ul(e,s,n,!0),r),!0)},Nm);var fo=Symbol(),Tl=Symbol(),du=Symbol(),fu=Symbol();let xm,Om;function Hn(t,e,n,s){var r=s[t];if(r)return r;(r={}).Pa=s,r.V=function(u){switch(typeof u){case"boolean":return lm||(lm=[0,void 0,!0]);case"number":return u>0?void 0:u===0?Q3||(Q3=[0,void 0]):[-u,void 0];case"string":return[0,u];case"object":return u}}(s[0]);var i=s[1];let o=1;i&&i.constructor===Object&&(r.ga=i,typeof(i=s[++o])=="function"&&(r.la=!0,xm??(xm=i),Om??(Om=s[o+1]),i=s[o+=2]));const a={};for(;i&&Array.isArray(i)&&i.length&&typeof i[0]=="number"&&i[0]>0;){for(var c=0;c<i.length;c++)a[i[c]]=i;i=s[++o]}for(c=1;i!==void 0;){let u;typeof i=="number"&&(c+=i,i=s[++o]);var l=void 0;if(i instanceof xs?u=i:(u=rE,o--),u==null?void 0:u.l){i=s[++o],l=s;var h=o;typeof i=="function"&&(i=i(),l[h]=i),l=i}for(h=c+1,typeof(i=s[++o])=="number"&&i<0&&(h-=i,i=s[++o]);c<h;c++){const d=a[c];l?n(r,c,u,l,d):e(r,c,u,d)}}return s[t]=r}function Lm(t){return Array.isArray(t)?t[0]instanceof xs?t:[iE,t]:[t,void 0]}function Dm(t,e){return t instanceof k?t.u:Array.isArray(t)?cn(t,e,!1):void 0}function Cl(t,e,n,s){const r=n.g;t[e]=s?(i,o,a)=>r(i,o,a,s):r}function Sl(t,e,n,s,r){const i=n.g;let o,a;t[e]=(c,l,h)=>i(c,l,h,a||(a=Hn(Tl,Cl,Sl,s).V),o||(o=Al(s)),r)}function Al(t){let e=t[du];if(e!=null)return e;const n=Hn(Tl,Cl,Sl,t);return e=n.la?(s,r)=>xm(s,r,n):(s,r)=>{const i=0|s[O];for(;bm(r)&&r.h!=4;){var o=r.m,a=n[o];if(a==null){var c=n.ga;c&&(c=c[o])&&(c=oE(c))!=null&&(a=n[o]=c)}a!=null&&a(r,s,o)||(o=(a=r).l,Zr(a),a.fa?a=void 0:(c=a.g.g-o,a.g.g=o,a=wm(a.g,c)),o=s,a&&((c=o[ps])?c.push(a):o[ps]=[a]))}return 16384&i&&As(s),!0},t[du]=e}function oE(t){const e=(t=Lm(t))[0].g;if(t=t[1]){const n=Al(t),s=Hn(Tl,Cl,Sl,t).V;return(r,i,o)=>e(r,i,o,s,n)}return e}function po(t,e,n){t[e]=n.h}function mo(t,e,n,s){let r,i;const o=n.h;t[e]=(a,c,l)=>o(a,c,l,i||(i=Hn(fo,po,mo,s).V),r||(r=Pm(s)))}function Pm(t){let e=t[fu];if(!e){const n=Hn(fo,po,mo,t);e=(s,r)=>Fm(s,r,n),t[fu]=e}return e}function Fm(t,e,n){for(var s=0|t[O],r=512&s?0:-1,i=t.length,o=512&s?1:0,a=i+(256&s?-1:0);o<a;o++){const c=t[o];if(c==null)continue;const l=o-r,h=pu(n,l);h&&h(e,c,l)}if(256&s){s=t[i-1];for(const c in s)r=+c,Number.isNaN(r)||(i=s[r])!=null&&(a=pu(n,r))&&a(e,i,r)}if(t=Xc(t))for(ys(e,e.g.end()),n=0;n<t.length;n++)ys(e,jc(t[n])||new Uint8Array(0))}function pu(t,e){var n=t[e];if(n)return n;if((n=t.ga)&&(n=n[e])){var s=(n=Lm(n))[0].h;if(n=n[1]){const r=Pm(n),i=Hn(fo,po,mo,n).V;n=t.la?Om(i,r):(o,a,c)=>s(o,a,c,i,r)}else n=s;return t[e]=n}}function Os(t,e){if(Array.isArray(e)){var n=0|e[O];if(4&n)return e;for(var s=0,r=0;s<e.length;s++){const i=t(e[s]);i!=null&&(e[r++]=i)}return r<s&&(e.length=r),be(e,-12289&(5|n)),2&n&&Object.freeze(e),e}}function He(t,e,n){return new xs(t,e,n)}function Ls(t,e,n){return new xs(t,e,n)}function Ge(t,e,n){ge(t,0|t[O],e,n)}var aE=uo(function(t,e,n,s,r){return t.h===2&&(t=Lr(t,cn([void 0,void 0],s,!0),r),gn(s=0|e[O]),(r=Zt(e,s,n))instanceof pt?(2&r.L)!=0?((r=r.X()).push(t),ge(e,s,n,r)):r.Na(t):Array.isArray(r)?(2&(0|r[O])&&ge(e,s,n,r=pm(r)),r.push(t)):ge(e,s,n,[t]),!0)},function(t,e,n,s,r){if(e instanceof pt)e.forEach((i,o)=>{Fi(t,n,cn([o,i],s,!1),r)});else if(Array.isArray(e))for(let i=0;i<e.length;i++){const o=e[i];Array.isArray(o)&&Fi(t,n,cn(o,s,!1),r)}});function Mm(t,e,n){if(e=function(s){if(s==null)return s;const r=typeof s;if(r==="bigint")return String(tl(64,s));if(ro(s)){if(r==="string")return sl(s);if(r==="number")return nl(s)}}(e),e!=null&&(typeof e=="string"&&uu(e),e!=null))switch(it(t,n,0),typeof e){case"number":t=t.g,ms(e),is(t,se,_e);break;case"bigint":n=BigInt.asUintN(64,e),n=new Ga(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),is(t.g,n.h,n.g);break;default:n=uu(e),is(t.g,n.h,n.g)}}function Bm(t,e,n){(e=Rs(e))!=null&&e!=null&&(it(t,n,0),lo(t.g,e))}function Um(t,e,n){(e=om(e))!=null&&(it(t,n,0),t.g.g.push(e?1:0))}function Vm(t,e,n){(e=gs(e))!=null&&ho(t,n,Kp(e))}function Hm(t,e,n,s,r){Fi(t,n,Dm(e,s),r)}function Gm(t,e,n){(e=e==null||typeof e=="string"||Nr(e)||e instanceof jt?e:void 0)!=null&&ho(t,n,fl(e).buffer)}function Wm(t,e,n){return(t.h===5||t.h===2)&&(e=Is(e,0|e[O],n,!1,!1),t.h==2?co(t,Va,e):e.push(Va(t.g)),!0)}var Vt=He(function(t,e,n){if(t.h!==1)return!1;var s=t.g;t=Ua(s);const r=Ua(s);s=2*(r>>31)+1;const i=r>>>20&2047;return t=4294967296*(1048575&r)+t,Ge(e,n,i==2047?t?NaN:s*(1/0):i==0?5e-324*s*t:s*Math.pow(2,i-1075)*(t+4503599627370496)),!0},function(t,e,n){(e=_n(e))!=null&&(it(t,n,1),t=t.g,(n=im||(im=new DataView(new ArrayBuffer(8)))).setFloat64(0,+e,!0),se=n.getUint32(0,!0),_e=n.getUint32(4,!0),vr(t,se),vr(t,_e))},St()),Te=He(function(t,e,n){return t.h===5&&(Ge(e,n,Va(t.g)),!0)},function(t,e,n){(e=_n(e))!=null&&(it(t,n,5),t=t.g,Jc(e),vr(t,se))},bl),cE=Ls(Wm,function(t,e,n){if((e=Os(_n,e))!=null)for(let o=0;o<e.length;o++){var s=t,r=n,i=e[o];i!=null&&(it(s,r,5),s=s.g,Jc(i),vr(s,se))}},bl),Rl=Ls(Wm,function(t,e,n){if((e=Os(_n,e))!=null&&e.length){it(t,n,2),Ns(t.g,4*e.length);for(let s=0;s<e.length;s++)n=t.g,Jc(e[s]),vr(n,se)}},bl),pn=He(function(t,e,n){return t.h===0&&(Ge(e,n,pl(t.g,Zc)),!0)},Mm,Rm),ta=He(function(t,e,n){return t.h===0&&(Ge(e,n,(t=pl(t.g,Zc))===0?void 0:t),!0)},Mm,Rm),lE=He(function(t,e,n){return t.h===0&&(Ge(e,n,pl(t.g,Qc)),!0)},function(t,e,n){if((e=$3(e))!=null&&(typeof e=="string"&&hu(e),e!=null))switch(it(t,n,0),typeof e){case"number":t=t.g,ms(e),is(t,se,_e);break;case"bigint":n=BigInt.asUintN(64,e),n=new Ha(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),is(t.g,n.h,n.g);break;default:n=hu(e),is(t.g,n.h,n.g)}},St()),Ee=He(function(t,e,n){return t.h===0&&(Ge(e,n,fn(t.g)),!0)},Bm,wl),go=Ls(function(t,e,n){return(t.h===0||t.h===2)&&(e=Is(e,0|e[O],n,!1,!1),t.h==2?co(t,fn,e):e.push(fn(t.g)),!0)},function(t,e,n){if((e=Os(Rs,e))!=null&&e.length){n=_l(t,n);for(let s=0;s<e.length;s++)lo(t.g,e[s]);yl(t,n)}},wl),Xn=He(function(t,e,n){return t.h===0&&(Ge(e,n,(t=fn(t.g))===0?void 0:t),!0)},Bm,wl),fe=He(function(t,e,n){return t.h===0&&(Ge(e,n,ml(t.g)),!0)},Um,Sm),os=He(function(t,e,n){return t.h===0&&(Ge(e,n,(t=ml(t.g))===!1?void 0:t),!0)},Um,Sm),Pe=Ls(function(t,e,n){return t.h===2&&(t=gl(t),Is(e,0|e[O],n,!1).push(t),!0)},function(t,e,n){if((e=Os(gs,e))!=null)for(let o=0;o<e.length;o++){var s=t,r=n,i=e[o];i!=null&&ho(s,r,Kp(i))}},vl),sn=He(function(t,e,n){return t.h===2&&(Ge(e,n,(t=gl(t))===""?void 0:t),!0)},Vm,vl),Q=He(function(t,e,n){return t.h===2&&(Ge(e,n,gl(t)),!0)},Vm,vl),Re=function(t,e,n=El){return new xs(t,e,n)}(function(t,e,n,s,r){return t.h===2&&(s=cn(void 0,s,!0),Is(e,0|e[O],n,!0).push(s),Lr(t,s,r),!0)},function(t,e,n,s,r){if(Array.isArray(e))for(let i=0;i<e.length;i++)Hm(t,e[i],n,s,r)}),ee=uo(function(t,e,n,s,r,i){return t.h===2&&(mm(e,0|e[O],i,n),Lr(t,e=ul(e,s,n),r),!0)},Hm),$m=He(function(t,e,n){return t.h===2&&(Ge(e,n,Tm(t)),!0)},Gm,km),hE=Ls(function(t,e,n){return(t.h===0||t.h===2)&&(e=Is(e,0|e[O],n,!1,!1),t.h==2?co(t,Xt,e):e.push(Xt(t.g)),!0)},function(t,e,n){if((e=Os(am,e))!=null)for(let o=0;o<e.length;o++){var s=t,r=n,i=e[o];i!=null&&(it(s,r,0),Ns(s.g,i))}},Am),uE=He(function(t,e,n){return t.h===0&&(Ge(e,n,(t=Xt(t.g))===0?void 0:t),!0)},function(t,e,n){(e=am(e))!=null&&e!=null&&(it(t,n,0),Ns(t.g,e))},Am),gt=He(function(t,e,n){return t.h===0&&(Ge(e,n,fn(t.g)),!0)},function(t,e,n){(e=Rs(e))!=null&&(e=parseInt(e,10),it(t,n,0),lo(t.g,e))},Im);class dE{constructor(e,n){this.h=e,this.g=n,this.l=Y,this.m=L,this.defaultValue=void 0}}function At(t,e){return new dE(t,e)}function yn(t,e){return(n,s)=>{if(Wr.length){const i=Wr.pop();i.o(s),ea(i.g,n,s),n=i}else n=new class{constructor(i,o){if(lu.length){const a=lu.pop();ea(a,i,o),i=a}else i=new class{constructor(a,c){this.h=null,this.m=!1,this.g=this.l=this.j=0,ea(this,a,c)}clear(){this.h=null,this.m=!1,this.g=this.l=this.j=0,this.ba=!1}}(i,o);this.g=i,this.l=this.g.g,this.h=this.m=-1,this.o(o)}o({fa:i=!1}={}){this.fa=i}}(n,s);try{const i=new t,o=i.u;Al(e)(o,n);var r=i}finally{n.g.clear(),n.m=-1,n.h=-1,Wr.length<100&&Wr.push(n)}return r}}function _o(t){return function(){const e=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const o=this.g;return this.g=[],o}}}};Fm(this.u,e,Hn(fo,po,mo,t)),ys(e,e.g.end());const n=new Uint8Array(e.h),s=e.l,r=s.length;let i=0;for(let o=0;o<r;o++){const a=s[o];n.set(a,i),i+=a.length}return e.l=[n],n}}var mu=class extends k{constructor(t){super(t)}},gu=[0,sn,He(function(t,e,n){return t.h===2&&(Ge(e,n,(t=Tm(t))===Mn()?void 0:t),!0)},function(t,e,n){if(e!=null){if(e instanceof k){const s=e.Ra;return void(s&&(e=s(e),e!=null&&ho(t,n,fl(e).buffer)))}if(Array.isArray(e))return}Gm(t,e,n)},km)];let na,_u=globalThis.trustedTypes;function yu(t){na===void 0&&(na=function(){let n=null;if(!_u)return n;try{const s=r=>r;n=_u.createPolicy("goog#html",{createHTML:s,createScript:s,createScriptURL:s})}catch{}return n}());var e=na;return new class{constructor(n){this.g=n}toString(){return this.g+""}}(e?e.createScriptURL(t):t)}function fE(t,...e){if(e.length===0)return yu(t[0]);let n=t[0];for(let s=0;s<e.length;s++)n+=encodeURIComponent(e[s])+t[s+1];return yu(n)}var jm=[0,Ee,gt,fe,-1,go,gt,-1],pE=class extends k{constructor(t){super(t)}},qm=[0,fe,Q,fe,gt,-1,Ls(function(t,e,n){return(t.h===0||t.h===2)&&(e=Is(e,0|e[O],n,!1,!1),t.h==2?co(t,eE,e):e.push(fn(t.g)),!0)},function(t,e,n){if((e=Os(Rs,e))!=null&&e.length){n=_l(t,n);for(let s=0;s<e.length;s++)lo(t.g,e[s]);yl(t,n)}},Im),Q,-1,[0,fe,-1],gt,fe,-1],zm=[0,Q,-2],Eu=class extends k{constructor(t){super(t)}},Km=[0],Ym=[0,Ee,fe,1,fe,-3],rt=class extends k{constructor(t){super(t,2)}},Se={};Se[336783863]=[0,Q,fe,-1,Ee,[0,[1,2,3,4,5,6,7,8],ee,Km,ee,qm,ee,zm,ee,Ym,ee,jm,ee,[0,Q,-2],ee,[0,Q,gt],ee,[0,gt,Q]],[0,Q],fe,[0,[1,3],[2,4],ee,[0,go],-1,ee,[0,Pe],-1,Re,[0,Q,-1]],Q];var vu=[0,ta,-1,os,-3,ta,go,sn,Xn,ta,-1,os,Xn,os,-2,sn];function ot(t,e){Ba(t,2,ks(e),"")}function ce(t,e){ao(t,3,e)}function z(t,e){ao(t,4,e)}var Ve=class extends k{constructor(t){super(t,500)}o(t){return L(this,0,7,t)}},rr=[-1,{}],wu=[0,Q,1,rr],bu=[0,Q,Pe,rr];function at(t,e){Di(t,1,Ve,e)}function ue(t,e){ao(t,10,e)}function X(t,e){ao(t,15,e)}var Xe=class extends k{constructor(t){super(t,500)}o(t){return L(this,0,1001,t)}},Xm=[-500,Re,[-500,sn,-1,Pe,-3,[-2,Se,fe],Re,gu,Xn,-1,wu,bu,Re,[0,sn,os],sn,vu,Xn,Pe,987,Pe],4,Re,[-500,Q,-1,[-1,{}],998,Q],Re,[-500,Q,Pe,-1,[-2,{},fe],997,Pe,-1],Xn,Re,[-500,Q,Pe,rr,998,Pe],Pe,Xn,wu,bu,Re,[0,sn,-1,rr],Pe,-2,vu,sn,-1,os,[0,os,uE],978,rr,Re,gu];Xe.prototype.g=_o(Xm);var mE=yn(Xe,Xm),gE=class extends k{constructor(t){super(t)}},Jm=class extends k{constructor(t){super(t)}g(){return Yt(this,gE,1)}},Qm=[0,Re,[0,Ee,Te,Q,-1]],yo=yn(Jm,Qm),_E=class extends k{constructor(t){super(t)}},yE=class extends k{constructor(t){super(t)}},sa=class extends k{constructor(t){super(t)}h(){return Y(this,_E,2)}g(){return Yt(this,yE,5)}},Zm=yn(class extends k{constructor(t){super(t)}},[0,Pe,go,Rl,[0,gt,[0,Ee,-3],[0,Te,-3],[0,Ee,-1,[0,Re,[0,Ee,-2]]],Re,[0,Te,-1,Q,Te]],Q,-1,pn,Re,[0,Ee,Te],Pe,pn]),eg=class extends k{constructor(t){super(t)}},as=yn(class extends k{constructor(t){super(t)}},[0,Re,[0,Te,-4]]),tg=class extends k{constructor(t){super(t)}},Dr=yn(class extends k{constructor(t){super(t)}},[0,Re,[0,Te,-4]]),EE=class extends k{constructor(t){super(t)}},vE=[0,Ee,-1,Rl,gt],ng=class extends k{constructor(t){super(t)}};ng.prototype.g=_o([0,Te,-4,pn]);var wE=class extends k{constructor(t){super(t)}},bE=yn(class extends k{constructor(t){super(t)}},[0,Re,[0,1,Ee,Q,Qm],pn]),Tu=class extends k{constructor(t){super(t)}},TE=class extends k{constructor(t){super(t)}oa(){const t=fm(this);return t??Mn()}},CE=class extends k{constructor(t){super(t)}},sg=[1,2],SE=yn(class extends k{constructor(t){super(t)}},[0,Re,[0,sg,ee,[0,Rl],ee,[0,$m],Ee,Q],pn]),kl=class extends k{constructor(t){super(t)}},rg=[0,Q,Ee,Te,Pe,-1],Cu=class extends k{constructor(t){super(t)}},AE=[0,fe,-1],Su=class extends k{constructor(t){super(t)}},ei=[1,2,3,4,5],Mi=class extends k{constructor(t){super(t)}g(){return fm(this)!=null}h(){return mt(this,2)!=null}},pe=class extends k{constructor(t){super(t)}g(){return om(_s(this,2))??!1}},ig=[0,$m,Q,[0,Ee,pn,-1],[0,lE,pn]],we=[0,ig,fe,[0,ei,ee,Ym,ee,qm,ee,jm,ee,Km,ee,zm],gt],Eo=class extends k{constructor(t){super(t)}},Il=[0,we,Te,-1,Ee],RE=At(502141897,Eo);Se[502141897]=Il;var kE=yn(class extends k{constructor(t){super(t)}},[0,[0,gt,-1,cE,hE],vE]),og=class extends k{constructor(t){super(t)}},ag=class extends k{constructor(t){super(t)}},Nl=[0,we,Te,[0,we],fe],cg=[0,we,Il,Nl,Te,[0,[0,ig]]],IE=At(508968150,ag);Se[508968150]=cg,Se[508968149]=Nl;var lg=class extends k{constructor(t){super(t)}},NE=At(513916220,lg);Se[513916220]=[0,we,cg,Ee];var Wn=class extends k{constructor(t){super(t)}h(){return Y(this,kl,2)}g(){ae(this,2)}},hg=[0,we,rg];Se[478825465]=hg;var xE=class extends k{constructor(t){super(t)}},ug=class extends k{constructor(t){super(t)}},xl=class extends k{constructor(t){super(t)}},Ol=class extends k{constructor(t){super(t)}},dg=class extends k{constructor(t){super(t)}},Au=[0,we,[0,we],hg,-1],fg=[0,we,Te,Ee],Ll=[0,we,Te],pg=[0,we,fg,Ll,Te],OE=At(479097054,dg);Se[479097054]=[0,we,pg,Au],Se[463370452]=Au,Se[464864288]=fg;var LE=At(462713202,Ol);Se[462713202]=pg,Se[474472470]=Ll;var DE=class extends k{constructor(t){super(t)}},mg=class extends k{constructor(t){super(t)}},gg=class extends k{constructor(t){super(t)}},_g=class extends k{constructor(t){super(t)}},Dl=[0,we,Te,-1,Ee],Wa=[0,we,Te,fe];_g.prototype.g=_o([0,we,Ll,[0,we],Il,Nl,Dl,Wa]);var yg=class extends k{constructor(t){super(t)}},PE=At(456383383,yg);Se[456383383]=[0,we,rg];var Eg=class extends k{constructor(t){super(t)}},FE=At(476348187,Eg);Se[476348187]=[0,we,AE];var vg=class extends k{constructor(t){super(t)}},Ru=class extends k{constructor(t){super(t)}},wg=[0,gt,-1],ME=At(458105876,class extends k{constructor(t){super(t)}g(){var t=this.u;const e=0|t[O],n=2&e;return t=function(s,r,i){var o=Ru;const a=2&r;let c=!1;if(i==null){if(a)return cu();i=[]}else if(i.constructor===pt){if((2&i.L)==0||a)return i;i=i.X()}else Array.isArray(i)?c=!!(2&(0|i[O])):i=[];if(a){if(!i.length)return cu();c||(c=!0,As(i))}else c&&(c=!1,i=pm(i));return c||(64&(0|i[O])?i[O]&=-33:32&r&&Zi(i,32)),ge(s,r,2,o=new pt(i,o,j3,void 0)),o}(t,e,Zt(t,e,2)),!n&&Ru&&(t.ra=!0),t}});Se[458105876]=[0,wg,aE,[!0,pn,[0,Q,-1,Pe]]];var Pl=class extends k{constructor(t){super(t)}},bg=At(458105758,Pl);Se[458105758]=[0,we,Q,wg];var Tg=class extends k{constructor(t){super(t)}},BE=At(443442058,Tg);Se[443442058]=[0,we,Q,Ee,Te,Pe,-1,fe,Te],Se[514774813]=Dl;var Cg=class extends k{constructor(t){super(t)}},UE=At(516587230,Cg);function $a(t,e){return e=e?e.clone():new kl,t.displayNamesLocale!==void 0?ae(e,1,ks(t.displayNamesLocale)):t.displayNamesLocale===void 0&&ae(e,1),t.maxResults!==void 0?Ft(e,2,t.maxResults):"maxResults"in t&&ae(e,2),t.scoreThreshold!==void 0?N(e,3,t.scoreThreshold):"scoreThreshold"in t&&ae(e,3),t.categoryAllowlist!==void 0?Pi(e,4,t.categoryAllowlist):"categoryAllowlist"in t&&ae(e,4),t.categoryDenylist!==void 0?Pi(e,5,t.categoryDenylist):"categoryDenylist"in t&&ae(e,5),e}function Fl(t,e=-1,n=""){return{categories:t.map(s=>({index:ft(s,1)??0??-1,score:ve(s,2)??0,categoryName:mt(s,3)??""??"",displayName:mt(s,4)??""??""})),headIndex:e,headName:n}}function Sg(t){var o,a;var e=kn(t,3,_n,Rn()),n=kn(t,2,Rs,Rn()),s=kn(t,1,gs,Rn()),r=kn(t,9,gs,Rn());const i={categories:[],keypoints:[]};for(let c=0;c<e.length;c++)i.categories.push({score:e[c],index:n[c]??-1,categoryName:s[c]??"",displayName:r[c]??""});if((e=(o=Y(t,sa,4))==null?void 0:o.h())&&(i.boundingBox={originX:ft(e,1)??0,originY:ft(e,2)??0,width:ft(e,3)??0,height:ft(e,4)??0,angle:0}),(a=Y(t,sa,4))==null?void 0:a.g().length)for(const c of Y(t,sa,4).g())i.keypoints.push({x:Qr(c,1)??0,y:Qr(c,2)??0,score:Qr(c,4)??0,label:mt(c,3)??""});return i}function vo(t){const e=[];for(const n of Yt(t,tg,1))e.push({x:ve(n,1)??0,y:ve(n,2)??0,z:ve(n,3)??0,visibility:ve(n,4)??0});return e}function ir(t){const e=[];for(const n of Yt(t,eg,1))e.push({x:ve(n,1)??0,y:ve(n,2)??0,z:ve(n,3)??0,visibility:ve(n,4)??0});return e}function ku(t){return Array.from(t,e=>e>127?e-256:e)}function Iu(t,e){if(t.length!==e.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${e.length}).`);let n=0,s=0,r=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i],s+=t[i]*t[i],r+=e[i]*e[i];if(s<=0||r<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(s*r)}let $r;Se[516587230]=[0,we,Dl,Wa,Te],Se[518928384]=Wa;const VE=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function Ag(){if($r===void 0)try{await WebAssembly.instantiate(VE),$r=!0}catch{$r=!1}return $r}async function $s(t,e=fE``){const n=await Ag()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${n}.js`,wasmBinaryPath:`${e}/${t}_${n}.wasm`}}var bn=class{};function Rg(){var t=navigator;return typeof OffscreenCanvas<"u"&&(!function(e=navigator){return(e=e.userAgent).includes("Safari")&&!e.includes("Chrome")}(t)||!!((t=t.userAgent.match(/Version\/([\d]+).*Safari/))&&t.length>=1&&Number(t[1])>=17))}async function Nu(t){if(typeof importScripts!="function"){const e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise((n,s)=>{e.addEventListener("load",()=>{n()},!1),e.addEventListener("error",r=>{s(r)},!1),document.body.appendChild(e)})}importScripts(t.toString())}function kg(t){return t.videoWidth!==void 0?[t.videoWidth,t.videoHeight]:t.naturalWidth!==void 0?[t.naturalWidth,t.naturalHeight]:t.displayWidth!==void 0?[t.displayWidth,t.displayHeight]:[t.width,t.height]}function x(t,e,n){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(e=t.i.stringToNewUTF8(e)),t.i._free(e)}function xu(t,e,n){if(!t.i.canvas)throw Error("No OpenGL canvas configured.");if(n?t.i._bindTextureToStream(n):t.i._bindTextureToCanvas(),!(n=t.i.canvas.getContext("webgl2")||t.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");t.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e),t.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1);const[s,r]=kg(e);return!t.l||s===t.i.canvas.width&&r===t.i.canvas.height||(t.i.canvas.width=s,t.i.canvas.height=r),[s,r]}function Ou(t,e,n){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const s=new Uint32Array(e.length);for(let r=0;r<e.length;r++)s[r]=t.i.stringToNewUTF8(e[r]);e=t.i._malloc(4*s.length),t.i.HEAPU32.set(s,e>>2),n(e);for(const r of s)t.i._free(r);t.i._free(e)}function Nt(t,e,n){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[e]=n}function tn(t,e,n){let s=[];t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[e]=(r,i,o)=>{i?(n(s,o),s=[]):s.push(r)}}bn.forVisionTasks=function(t){return $s("vision",t)},bn.forTextTasks=function(t){return $s("text",t)},bn.forGenAiExperimentalTasks=function(t){return $s("genai_experimental",t)},bn.forGenAiTasks=function(t){return $s("genai",t)},bn.forAudioTasks=function(t){return $s("audio",t)},bn.isSimdSupported=function(){return Ag()};async function HE(t,e,n,s){return t=await(async(r,i,o,a,c)=>{if(i&&await Nu(i),!self.ModuleFactory||o&&(await Nu(o),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&c&&((i=self.Module).locateFile=c.locateFile,c.mainScriptUrlOrBlob&&(i.mainScriptUrlOrBlob=c.mainScriptUrlOrBlob)),c=await self.ModuleFactory(self.Module||c),self.ModuleFactory=self.Module=void 0,new r(c,a)})(t,n.wasmLoaderPath,n.assetLoaderPath,e,{locateFile:r=>r.endsWith(".wasm")?n.wasmBinaryPath.toString():n.assetBinaryPath&&r.endsWith(".data")?n.assetBinaryPath.toString():r}),await t.o(s),t}function ra(t,e){const n=Y(t.baseOptions,Mi,1)||new Mi;typeof e=="string"?(ae(n,2,ks(e)),ae(n,1)):e instanceof Uint8Array&&(ae(n,1,Yc(e,!1)),ae(n,2)),L(t.baseOptions,0,1,n)}function Lu(t){try{const e=t.G.length;if(e===1)throw Error(t.G[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.G.map(n=>n.message).join(", "))}finally{t.G=[]}}function A(t,e){t.B=Math.max(t.B,e)}function wo(t,e){t.A=new Ve,ot(t.A,"PassThroughCalculator"),ce(t.A,"free_memory"),z(t.A,"free_memory_unused_out"),ue(e,"free_memory"),at(e,t.A)}function Es(t,e){ce(t.A,e),z(t.A,e+"_unused_out")}function bo(t){t.g.addBoolToStream(!0,"free_memory",t.B)}var ti=class{constructor(t){this.g=t,this.G=[],this.B=0,this.g.setAutoRenderToScreen(!1)}l(t,e=!0){var n,s,r,i,o,a;if(e){const c=t.baseOptions||{};if((n=t.baseOptions)!=null&&n.modelAssetBuffer&&((s=t.baseOptions)!=null&&s.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((r=Y(this.baseOptions,Mi,1))!=null&&r.g()||(i=Y(this.baseOptions,Mi,1))!=null&&i.h()||(o=t.baseOptions)!=null&&o.modelAssetBuffer||(a=t.baseOptions)!=null&&a.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(l,h){let u=Y(l.baseOptions,Su,3);if(!u){var d=u=new Su,p=new Eu;sr(d,4,ei,p)}"delegate"in h&&(h.delegate==="GPU"?(h=u,d=new pE,sr(h,2,ei,d)):(h=u,d=new Eu,sr(h,4,ei,d))),L(l.baseOptions,0,3,u)}(this,c),c.modelAssetPath)return fetch(c.modelAssetPath.toString()).then(l=>{if(l.ok)return l.arrayBuffer();throw Error(`Failed to fetch model: ${c.modelAssetPath} (${l.status})`)}).then(l=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(l),!0,!1,!1),ra(this,"/model.dat"),this.m(),this.I()});if(c.modelAssetBuffer instanceof Uint8Array)ra(this,c.modelAssetBuffer);else if(c.modelAssetBuffer)return async function(l){const h=[];for(var u=0;;){const{done:d,value:p}=await l.read();if(d)break;h.push(p),u+=p.length}if(h.length===0)return new Uint8Array(0);if(h.length===1)return h[0];l=new Uint8Array(u),u=0;for(const d of h)l.set(d,u),u+=d.length;return l}(c.modelAssetBuffer).then(l=>{ra(this,l),this.m(),this.I()})}return this.m(),this.I(),Promise.resolve()}I(){}da(){let t;if(this.g.da(e=>{t=mE(e)}),!t)throw Error("Failed to retrieve CalculatorGraphConfig");return t}setGraph(t,e){this.g.attachErrorListener((n,s)=>{this.G.push(Error(s))}),this.g.La(),this.g.setGraph(t,e),this.A=void 0,Lu(this)}finishProcessing(){this.g.finishProcessing(),Lu(this)}close(){this.A=void 0,this.g.closeGraph()}};function Ue(t,e){if(!t)throw Error(`Unable to obtain required WebGL resource: ${e}`);return t}ti.prototype.close=ti.prototype.close,function(t,e){t=t.split(".");var n,s=Fn;for((t[0]in s)||s.execScript===void 0||s.execScript("var "+t[0]);t.length&&(n=t.shift());)t.length||e===void 0?s=s[n]&&s[n]!==Object.prototype[n]?s[n]:s[n]={}:s[n]=e}("TaskRunner",ti);class GE{constructor(e,n,s,r){this.g=e,this.h=n,this.m=s,this.l=r}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function Du(t,e,n){const s=t.g;if(n=Ue(s.createShader(n),"Failed to create WebGL shader"),s.shaderSource(n,e),s.compileShader(n),!s.getShaderParameter(n,s.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${s.getShaderInfoLog(n)}`);return s.attachShader(t.h,n),n}function Pu(t,e){const n=t.g,s=Ue(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(s);const r=Ue(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,r),n.enableVertexAttribArray(t.O),n.vertexAttribPointer(t.O,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW);const i=Ue(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,i),n.enableVertexAttribArray(t.I),n.vertexAttribPointer(t.I,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array(e?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindVertexArray(null),new GE(n,s,r,i)}function Ml(t,e){if(t.g){if(e!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=e}function Pr(t,e,n,s){return Ml(t,e),t.h||(t.m(),t.C()),n?(t.s||(t.s=Pu(t,!0)),n=t.s):(t.v||(t.v=Pu(t,!1)),n=t.v),e.useProgram(t.h),n.bind(),t.l(),t=s(),n.g.bindVertexArray(null),t}function mn(t,e,n){return Ml(t,e),t=Ue(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n??e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,n??e.LINEAR),e.bindTexture(e.TEXTURE_2D,null),t}function To(t,e,n){Ml(t,e),t.A||(t.A=Ue(e.createFramebuffer(),"Failed to create framebuffe.")),e.bindFramebuffer(e.FRAMEBUFFER,t.A),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0)}function Bl(t){var e;(e=t.g)==null||e.bindFramebuffer(t.g.FRAMEBUFFER,null)}var Ds=class{G(){return`
1594
+ */function v3(t){p2(e2),mi(new ar("database",(e,{instanceIdentifier:n})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return m3(s,r,i,n)},"PUBLIC").setMultipleInstances(!0)),Zn(dh,fh,t),Zn(dh,fh,"esm2017")}$t.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)};$t.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)};v3();class w3{constructor(e,n){w(this,"app");w(this,"handlers");w(this,"subscriptions",[]);this.app=e,this.handlers=n}attach(e){const n=zp(this.app),s=Ks(n,`${e}`),r=u3(s,u=>{var p,f;const d=u.val();d!==null&&u.key&&/^\d+$/.test(u.key)&&((f=(p=this.handlers).onWindow)==null||f.call(p,d))});this.subscriptions.push(r);const i=Ks(n,`/${e}/averaged_results/`),o=Jr(i,u=>{var p,f;const d=u.val();d!==null&&((f=(p=this.handlers).onFinal)==null||f.call(p,d),this.detachAll())});this.subscriptions.push(o);const a=Ks(n,`/${e}/error/`),c=Jr(a,u=>{var p,f;const d=u.val();d!==null&&((f=(p=this.handlers).onError)==null||f.call(p,d),this.detachAll())});this.subscriptions.push(c);const l=Ks(n,`/${e}/job_completed/`),h=Jr(l,u=>{var p,f;const d=u.val();d!==null&&(d==="failed"?((f=(p=this.handlers).onError)==null||f.call(p,{name:"ScanFailedError"}),this.detachAll()):d==="success"&&this.detachAll())});this.subscriptions.push(h)}detachAll(){for(const e of this.subscriptions)try{e()}catch{}this.subscriptions=[]}}var Fn=typeof self<"u"?self:{};function En(){throw Error("Invalid UTF8")}function qh(t,e){return e=String.fromCharCode.apply(null,e),t==null?e:t+e}let Wr,qo;const b3=typeof TextDecoder<"u";let T3;const C3=typeof TextEncoder<"u";function Kp(t){if(C3)t=(T3||(T3=new TextEncoder)).encode(t);else{let n=0;const s=new Uint8Array(3*t.length);for(let r=0;r<t.length;r++){var e=t.charCodeAt(r);if(e<128)s[n++]=e;else{if(e<2048)s[n++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&r<t.length){const i=t.charCodeAt(++r);if(i>=56320&&i<=57343){e=1024*(e-55296)+i-56320+65536,s[n++]=e>>18|240,s[n++]=e>>12&63|128,s[n++]=e>>6&63|128,s[n++]=63&e|128;continue}r--}e=65533}s[n++]=e>>12|224,s[n++]=e>>6&63|128}s[n++]=63&e|128}}t=n===s.length?s:s.subarray(0,n)}return t}var Gc,Ii;e:{for(var zh=["CLOSURE_FLAGS"],zo=Fn,Ko=0;Ko<zh.length;Ko++)if((zo=zo[zh[Ko]])==null){Ii=null;break e}Ii=zo}var _r,Kh=Ii&&Ii[610401301];Gc=Kh!=null&&Kh;const Yh=Fn.navigator;function La(t){return!!Gc&&!!_r&&_r.brands.some(({brand:e})=>e&&e.indexOf(t)!=-1)}function ut(t){var e;return(e=Fn.navigator)&&(e=e.userAgent)||(e=""),e.indexOf(t)!=-1}function nn(){return!!Gc&&!!_r&&_r.brands.length>0}function Yo(){return nn()?La("Chromium"):(ut("Chrome")||ut("CriOS"))&&!(!nn()&&ut("Edge"))||ut("Silk")}function $c(t){return $c[" "](t),t}_r=Yh&&Yh.userAgentData||null,$c[" "]=function(){};var S3=!nn()&&(ut("Trident")||ut("MSIE"));!ut("Android")||Yo(),Yo(),ut("Safari")&&(Yo()||!nn()&&ut("Coast")||!nn()&&ut("Opera")||!nn()&&ut("Edge")||(nn()?La("Microsoft Edge"):ut("Edg/"))||nn()&&La("Opera"));var Yp={},Ys=null;function A3(t){const e=t.length;let n=3*e/4;n%3?n=Math.floor(n):"=.".indexOf(t[e-1])!=-1&&(n="=.".indexOf(t[e-2])!=-1?n-2:n-1);const s=new Uint8Array(n);let r=0;return function(i,o){function a(l){for(;c<i.length;){const h=i.charAt(c++),u=Ys[h];if(u!=null)return u;if(!/^[\s\xa0]*$/.test(h))throw Error("Unknown base64 encoding at char: "+h)}return l}Xp();let c=0;for(;;){const l=a(-1),h=a(0),u=a(64),d=a(64);if(d===64&&l===-1)break;o(l<<2|h>>4),u!=64&&(o(h<<4&240|u>>2),d!=64&&o(u<<6&192|d))}}(t,function(i){s[r++]=i}),r!==n?s.subarray(0,r):s}function Xp(){if(!Ys){Ys={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let n=0;n<5;n++){const s=t.concat(e[n].split(""));Yp[n]=s;for(let r=0;r<s.length;r++){const i=s[r];Ys[i]===void 0&&(Ys[i]=r)}}}}var Jp=typeof Uint8Array<"u",Qp=!S3&&typeof btoa=="function";function Xh(t){if(!Qp){var e;e===void 0&&(e=0),Xp(),e=Yp[e];var n=Array(Math.floor(t.length/3)),s=e[64]||"";let c=0,l=0;for(;c<t.length-2;c+=3){var r=t[c],i=t[c+1],o=t[c+2],a=e[r>>2];r=e[(3&r)<<4|i>>4],i=e[(15&i)<<2|o>>6],o=e[63&o],n[l++]=a+r+i+o}switch(a=0,o=s,t.length-c){case 2:o=e[(15&(a=t[c+1]))<<2]||s;case 1:t=t[c],n[l]=e[t>>2]+e[(3&t)<<4|a>>4]+o+s}return n.join("")}for(e="",n=0,s=t.length-10240;n<s;)e+=String.fromCharCode.apply(null,t.subarray(n,n+=10240));return e+=String.fromCharCode.apply(null,n?t.subarray(n):t),btoa(e)}const Jh=/[-_.]/g,R3={"-":"+",_:"/",".":"="};function k3(t){return R3[t]||""}function Zp(t){if(!Qp)return A3(t);Jh.test(t)&&(t=t.replace(Jh,k3)),t=atob(t);const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}function Nr(t){return Jp&&t!=null&&t instanceof Uint8Array}var fs={};function Mn(){return I3||(I3=new jt(null,fs))}function jc(t){em(fs);var e=t.g;return(e=e==null||Nr(e)?e:typeof e=="string"?Zp(e):null)==null?e:t.g=e}var jt=class{h(){return new Uint8Array(jc(this)||0)}constructor(t,e){if(em(e),this.g=t,t!=null&&t.length===0)throw Error("ByteString should be constructed with non-empty values")}};let I3,N3;function em(t){if(t!==fs)throw Error("illegal external caller")}function tm(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}function Da(t){return tm(t=Error(t),"warning"),t}var Qi=typeof Symbol=="function"&&typeof Symbol()=="symbol",x3=new Set;function xr(t,e,n=!1,s=!1){return t=typeof Symbol=="function"&&typeof Symbol()=="symbol"?s&&Symbol.for&&t?Symbol.for(t):t!=null?Symbol(t):Symbol():e,n&&x3.add(t),t}var O3=xr("jas",void 0,!0,!0),Qh=xr(void 0,"0di"),Xo=xr(void 0,"2ex"),Gs=xr(void 0,"1oa",!0),ps=xr(void 0,Symbol(),!0);const O=Qi?O3:"Ga",nm={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},sm=Object.defineProperties;function Zi(t,e){Qi||O in t||sm(t,nm),t[O]|=e}function be(t,e){Qi||O in t||sm(t,nm),t[O]=e}function As(t){return Zi(t,34),t}function L3(t,e){be(e,-30975&(0|t))}function Pa(t,e){be(e,-30941&(34|t))}function qc(){return typeof BigInt=="function"}function qe(t){return Array.prototype.slice.call(t)}var zc,Or={},rm={};function Zh(t){return!(!t||typeof t!="object"||t.Ia!==rm)}function Kc(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&t.constructor===Object}function Yc(t,e){if(t!=null){if(typeof t=="string")t=t?new jt(t,fs):Mn();else if(t.constructor!==jt)if(Nr(t))t=t.length?new jt(new Uint8Array(t),fs):Mn();else{if(!e)throw Error();t=void 0}}return t}function Ni(t){return!(!Array.isArray(t)||t.length)&&!!(1&(0|t[O]))}const eu=[];function gn(t){if(2&t)throw Error()}be(eu,55),zc=Object.freeze(eu);class xi{constructor(e,n,s){this.l=0,this.g=e,this.h=n,this.m=s}next(){if(this.l<this.g.length){const e=this.g[this.l++];return{done:!1,value:this.h?this.h.call(this.m,e):e}}return{done:!0,value:void 0}}[Symbol.iterator](){return new xi(this.g,this.h,this.m)}}function Xc(t){return ps?t[ps]:void 0}var D3=Object.freeze({});function eo(t){return t.Qa=!0,t}var P3=eo(t=>typeof t=="number"),tu=eo(t=>typeof t=="string"),F3=eo(t=>typeof t=="boolean"),to=typeof Fn.BigInt=="function"&&typeof Fn.BigInt(0)=="bigint",Fa=eo(t=>to?t>=B3&&t<=V3:t[0]==="-"?nu(t,M3):nu(t,U3));const M3=Number.MIN_SAFE_INTEGER.toString(),B3=to?BigInt(Number.MIN_SAFE_INTEGER):void 0,U3=Number.MAX_SAFE_INTEGER.toString(),V3=to?BigInt(Number.MAX_SAFE_INTEGER):void 0;function nu(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let n=0;n<t.length;n++){const s=t[n],r=e[n];if(s>r)return!1;if(s<r)return!0}}const H3=typeof Uint8Array.prototype.slice=="function";let im,se=0,_e=0;function su(t){const e=t>>>0;se=e,_e=(t-e)/4294967296>>>0}function ms(t){if(t<0){su(-t);const[e,n]=el(se,_e);se=e>>>0,_e=n>>>0}else su(t)}function Jc(t){const e=im||(im=new DataView(new ArrayBuffer(8)));e.setFloat32(0,+t,!0),_e=0,se=e.getUint32(0,!0)}function Qc(t,e){const n=4294967296*e+(t>>>0);return Number.isSafeInteger(n)?n:yr(t,e)}function Zc(t,e){const n=2147483648&e;return n&&(e=~e>>>0,(t=1+~t>>>0)==0&&(e=e+1>>>0)),typeof(t=Qc(t,e))=="number"?n?-t:t:n?"-"+t:t}function yr(t,e){if(t>>>=0,(e>>>=0)<=2097151)var n=""+(4294967296*e+t);else qc()?n=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(n=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),n+=8147497*e,e*=2,t>=1e7&&(n+=t/1e7>>>0,t%=1e7),n>=1e7&&(e+=n/1e7>>>0,n%=1e7),n=e+ru(n)+ru(t));return n}function ru(t){return t=String(t),"0000000".slice(t.length)+t}function no(t){if(t.length<16)ms(Number(t));else if(qc())t=BigInt(t),se=Number(t&BigInt(4294967295))>>>0,_e=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+(t[0]==="-");_e=se=0;const n=t.length;for(let s=e,r=(n-e)%6+e;r<=n;s=r,r+=6){const i=Number(t.slice(s,r));_e*=1e6,se=1e6*se+i,se>=4294967296&&(_e+=Math.trunc(se/4294967296),_e>>>=0,se>>>=0)}if(e){const[s,r]=el(se,_e);se=s,_e=r}}}function el(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}const tl=typeof BigInt=="function"?BigInt.asIntN:void 0,W3=typeof BigInt=="function"?BigInt.asUintN:void 0,ss=Number.isSafeInteger,so=Number.isFinite,Oi=Math.trunc;function _n(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function om(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const G3=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function ro(t){switch(typeof t){case"bigint":return!0;case"number":return so(t);case"string":return G3.test(t);default:return!1}}function Rs(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return so(t)?0|t:void 0}function am(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return so(t)?t>>>0:void 0}function iu(t){if(t[0]==="-")return!1;const e=t.length;return e<20||e===20&&Number(t.substring(0,6))<184467}function nl(t){return t=Oi(t),ss(t)||(ms(t),t=Zc(se,_e)),t}function sl(t){var e=Oi(Number(t));if(ss(e))return String(e);if((e=t.indexOf("."))!==-1&&(t=t.substring(0,e)),e=t.length,!(t[0]==="-"?e<20||e===20&&Number(t.substring(0,7))>-922337:e<19||e===19&&Number(t.substring(0,6))<922337))if(no(t),t=se,2147483648&(e=_e))if(qc())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{const[n,s]=el(t,e);t="-"+yr(n,s)}else t=yr(t,e);return t}function Li(t){return t==null?t:typeof t=="bigint"?(Fa(t)?t=Number(t):(t=tl(64,t),t=Fa(t)?Number(t):String(t)),t):ro(t)?typeof t=="number"?nl(t):sl(t):void 0}function $3(t){if(t==null)return t;var e=typeof t;if(e==="bigint")return String(W3(64,t));if(ro(t)){if(e==="string")return e=Oi(Number(t)),ss(e)&&e>=0?t=String(e):((e=t.indexOf("."))!==-1&&(t=t.substring(0,e)),iu(t)||(no(t),t=yr(se,_e))),t;if(e==="number")return(t=Oi(t))>=0&&ss(t)?t:function(n){if(n<0){ms(n);var s=yr(se,_e);return n=Number(s),ss(n)?n:s}return iu(s=String(n))?s:(ms(n),Qc(se,_e))}(t)}}function cm(t){if(typeof t!="string")throw Error();return t}function ks(t){if(t!=null&&typeof t!="string")throw Error();return t}function gs(t){return t==null||typeof t=="string"?t:void 0}function rl(t,e,n,s){if(t!=null&&typeof t=="object"&&t.W===Or)return t;if(!Array.isArray(t))return n?2&s?((t=e[Qh])||(As((t=new e).u),t=e[Qh]=t),e=t):e=new e:e=void 0,e;let r=n=0|t[O];return r===0&&(r|=32&s),r|=2&s,r!==n&&be(t,r),new e(t)}function j3(t,e,n){if(e)e:{if(!ro(e=t))throw Da("int64");switch(typeof e){case"string":e=sl(e);break e;case"bigint":if(t=e=tl(64,e),tu(t)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(t))throw Error(String(t))}else if(P3(t)&&!Number.isSafeInteger(t))throw Error(String(t));e=to?BigInt(e):F3(e)?e?"1":"0":tu(e)?e.trim()||"0":String(e);break e;default:e=nl(e)}}else e=Li(t);return typeof(n=(t=e)==null?n?0:void 0:t)=="string"&&ss(e=+n)?e:n}const q3={};let z3=function(){try{return $c(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class Jo{constructor(){this.g=new Map}get(e){return this.g.get(e)}set(e,n){return this.g.set(e,n),this.size=this.g.size,this}delete(e){return e=this.g.delete(e),this.size=this.g.size,e}clear(){this.g.clear(),this.size=this.g.size}has(e){return this.g.has(e)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(e,n){return this.g.forEach(e,n)}[Symbol.iterator](){return this.entries()}}const K3=z3?(Object.setPrototypeOf(Jo.prototype,Map.prototype),Object.defineProperties(Jo.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Jo):class extends Map{constructor(){super()}};function ou(t){return t}function Qo(t){if(2&t.L)throw Error("Cannot mutate an immutable Map")}var pt=class extends K3{constructor(t,e,n=ou,s=ou){super();let r=0|t[O];r|=64,be(t,r),this.L=r,this.S=e,this.R=n,this.Y=this.S?Y3:s;for(let i=0;i<t.length;i++){const o=t[i],a=n(o[0],!1,!0);let c=o[1];e?c===void 0&&(c=null):c=s(o[1],!1,!0,void 0,void 0,r),super.set(a,c)}}na(t=au){if(this.size!==0)return this.X(t)}X(t=au){const e=[],n=super.entries();for(var s;!(s=n.next()).done;)(s=s.value)[0]=t(s[0]),s[1]=t(s[1]),e.push(s);return e}clear(){Qo(this),super.clear()}delete(t){return Qo(this),super.delete(this.R(t,!0,!1))}entries(){var t=this.ma();return new xi(t,X3,this)}keys(){return this.Ha()}values(){var t=this.ma();return new xi(t,pt.prototype.get,this)}forEach(t,e){super.forEach((n,s)=>{t.call(e,this.get(s),s,this)})}set(t,e){return Qo(this),(t=this.R(t,!0,!1))==null?this:e==null?(super.delete(t),this):super.set(t,this.Y(e,!0,!0,this.S,!1,this.L))}Na(t){const e=this.R(t[0],!1,!0);t=t[1],t=this.S?t===void 0?null:t:this.Y(t,!1,!0,void 0,!1,this.L),super.set(e,t)}has(t){return super.has(this.R(t,!1,!1))}get(t){t=this.R(t,!1,!1);const e=super.get(t);if(e!==void 0){var n=this.S;return n?((n=this.Y(e,!1,!0,n,this.ra,this.L))!==e&&super.set(t,n),n):e}}ma(){return Array.from(super.keys())}Ha(){return super.keys()}[Symbol.iterator](){return this.entries()}};function Y3(t,e,n,s,r,i){return t=rl(t,s,n,i),r&&(t=oo(t)),t}function au(t){return t}function X3(t){return[t,this.get(t)]}let J3,lm,Q3;function cu(){return J3||(J3=new pt(As([]),void 0,void 0,void 0,q3))}function il(t,e,n,s,r){if(t!=null){if(Array.isArray(t))t=Ni(t)?void 0:r&&2&(0|t[O])?t:ol(t,e,n,s!==void 0,r);else if(Kc(t)){const i={};for(let o in t)i[o]=il(t[o],e,n,s,r);t=i}else t=e(t,s);return t}}function ol(t,e,n,s,r){const i=s||n?0|t[O]:0,o=s?!!(32&i):void 0;s=qe(t);for(let a=0;a<s.length;a++)s[a]=il(s[a],e,n,o,r);return n&&((t=Xc(t))&&(s[ps]=qe(t)),n(i,s)),s}function Z3(t){return il(t,hm,void 0,void 0,!1)}function hm(t){return t.W===Or?t.toJSON():t instanceof pt?t.na(Z3):function(e){switch(typeof e){case"number":return isFinite(e)?e:String(e);case"bigint":return Fa(e)?Number(e):String(e);case"boolean":return e?1:0;case"object":if(e)if(Array.isArray(e)){if(Ni(e))return}else{if(Nr(e))return Xh(e);if(e instanceof jt){const n=e.g;return n==null?"":typeof n=="string"?n:e.g=Xh(n)}if(e instanceof pt)return e.na()}}return e}(t)}function um(t){return ol(t,hm,void 0,void 0,!1)}function cn(t,e,n){return t=dm(t,e[0],e[1],n?1:2),e!==lm&&n&&Zi(t,16384),t}function dm(t,e,n,s){if(t==null){var r=96;n?(t=[n],r|=512):t=[],e&&(r=-33521665&r|(1023&e)<<15)}else{if(!Array.isArray(t))throw Error("narr");if(2048&(r=0|t[O]))throw Error("farr");if(64&r)return t;if(s===1||s===2||(r|=64),n&&(r|=512,n!==t[0]))throw Error("mid");e:{if(s=(n=t).length){const i=s-1;if(Kc(n[i])){if((e=i-(512&(r|=256)?0:-1))>=1024)throw Error("pvtlmt");r=-33521665&r|(1023&e)<<15;break e}}if(e){if((e=Math.max(e,s-(512&r?0:-1)))>1024)throw Error("spvt");r=-33521665&r|(1023&e)<<15}}}return be(t,r),t}function Ma(t,e,n=Pa){if(t!=null){if(Jp&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var s=0|t[O];return 2&s?t:(e&&(e=s===0||!!(32&s)&&!(64&s||!(16&s))),e?(be(t,-12293&(34|s)),t):ol(t,Ma,4&s?Pa:n,!0,!0))}return t.W===Or?t=2&(s=0|(n=t.u)[O])?t:new t.constructor(io(n,s,!0)):t instanceof pt&&!(2&t.L)&&(n=As(t.X(Ma)),t=new pt(n,t.S,t.R,t.Y)),t}}function io(t,e,n){const s=n||2&e?Pa:L3,r=!!(32&e);return t=function(i,o,a){const c=qe(i);var l=c.length;const h=256&o?c[l-1]:void 0;for(l+=h?-1:0,o=512&o?1:0;o<l;o++)c[o]=a(c[o]);if(h){o=c[o]={};for(const u in h)o[u]=a(h[u])}return(i=Xc(i))&&(c[ps]=qe(i)),c}(t,e,i=>Ma(i,r,s)),Zi(t,32|(n?2:0)),t}function oo(t){const e=t.u,n=0|e[O];return 2&n?new t.constructor(io(e,n,!1)):t}function _s(t,e){return Zt(t=t.u,0|t[O],e)}function Zt(t,e,n,s){if(n===-1)return null;var r=n+(512&e?0:-1);const i=t.length-1;return r>=i&&256&e?t[i][n]:s&&256&e&&(e=t[i][n])!=null?(t[r]!=null&&Xo!=null&&((r=(t=N3??(N3={}))[Xo]||0)>=4||(t[Xo]=r+1,tm(t=Error(),"incident"),function(o){Fn.setTimeout(()=>{throw o},0)}(t))),e):r<=i?t[r]:void 0}function ae(t,e,n){const s=t.u;let r=0|s[O];return gn(r),ge(s,r,e,n),t}function ge(t,e,n,s){const r=512&e?0:-1,i=n+r;var o=t.length-1;return i>=o&&256&e?(t[o][n]=s,e):i<=o?(t[i]=s,256&e&&n in(t=t[o])&&delete t[n],e):(s!==void 0&&(n>=(o=e>>15&1023||536870912)?s!=null&&(t[o+r]={[n]:s},be(t,e|=256)):t[i]=s),e)}function Qr(t,e){let n=0|(t=t.u)[O];const s=Zt(t,n,e),r=_n(s);return r!=null&&r!==s&&ge(t,n,e,r),r}function fm(t){let e=0|(t=t.u)[O];const n=Zt(t,e,1),s=Yc(n,!0);return s!=null&&s!==n&&ge(t,e,1,s),s}function Rn(){return D3===void 0?2:4}function kn(t,e,n,s,r){const i=t.u,o=2&(t=0|i[O])?1:s;r=!!r;let a=0|(s=al(i,t,e))[O];if(!(4&a)){4&a&&(s=qe(s),a=qt(a,t),t=ge(i,t,e,s));let c=0,l=0;for(;c<s.length;c++){const h=n(s[c]);h!=null&&(s[l++]=h)}l<c&&(s.length=l),a=cl(a,t),n=-4097&(20|a),a=n&=-8193,be(s,a),2&a&&Object.freeze(s)}return o===1||o===4&&32&a?Gt(a)||(r=a,a|=2,a!==r&&be(s,a),Object.freeze(s)):(o===2&&Gt(a)&&(s=qe(s),a=qt(a,t),a=ln(a,t,r),be(s,a),t=ge(i,t,e,s)),Gt(a)||(e=a,a=ln(a,t,r),a!==e&&be(s,a))),s}function al(t,e,n,s){return t=Zt(t,e,n,s),Array.isArray(t)?t:zc}function cl(t,e){return t===0&&(t=qt(t,e)),1|t}function Gt(t){return!!(2&t)&&!!(4&t)||!!(2048&t)}function pm(t){t=qe(t);for(let e=0;e<t.length;e++){const n=t[e]=qe(t[e]);Array.isArray(n[1])&&(n[1]=As(n[1]))}return t}function Ba(t,e,n,s){let r=0|(t=t.u)[O];gn(r),ge(t,r,e,(s==="0"?Number(n)===0:n===s)?void 0:n)}function Is(t,e,n,s,r){gn(e);var i=!(!(64&e)&&16384&e);const o=(r=al(t,e,n,r))!==zc;if(i||!o){let a=i=o?0|r[O]:0;(!o||2&a||Gt(a)||4&a&&!(32&a))&&(r=qe(r),a=qt(a,e),e=ge(t,e,n,r)),a=-13&cl(a,e),a=ln(s?-17&a:16|a,e,!0),a!==i&&be(r,a)}return r}function Zo(t,e){var n=sg;return hl(ll(t=t.u),t,0|t[O],n)===e?e:-1}function ll(t){if(Qi)return t[Gs]??(t[Gs]=new Map);if(Gs in t)return t[Gs];const e=new Map;return Object.defineProperty(t,Gs,{value:e}),e}function mm(t,e,n,s){const r=ll(t),i=hl(r,t,e,n);return i!==s&&(i&&(e=ge(t,e,i)),r.set(n,s)),e}function hl(t,e,n,s){let r=t.get(s);if(r!=null)return r;r=0;for(let i=0;i<s.length;i++){const o=s[i];Zt(e,n,o)!=null&&(r!==0&&(n=ge(e,n,r)),r=o)}return t.set(s,r),r}function ul(t,e,n,s){let r,i=0|t[O];if((s=Zt(t,i,n,s))!=null&&s.W===Or)return(e=oo(s))!==s&&ge(t,i,n,e),e.u;if(Array.isArray(s)){const o=0|s[O];r=2&o?cn(io(s,o,!1),e,!0):64&o?s:cn(r,e,!0)}else r=cn(void 0,e,!0);return r!==s&&ge(t,i,n,r),r}function gm(t,e,n,s){let r=0|(t=t.u)[O];return(e=rl(s=Zt(t,r,n,s),e,!1,r))!==s&&e!=null&&ge(t,r,n,e),e}function Y(t,e,n,s=!1){if((e=gm(t,e,n,s))==null)return e;if(!(2&(s=0|(t=t.u)[O]))){const r=oo(e);r!==e&&ge(t,s,n,e=r)}return e}function _m(t,e,n,s,r,i,o){t=t.u;var a=!!(2&e);const c=a?1:r;i=!!i,o&&(o=!a);var l=0|(r=al(t,e,s))[O];if(!(a=!!(4&l))){var h=r,u=e;const d=!!(2&(l=cl(l,e)));d&&(u|=2);let p=!d,f=!0,g=0,E=0;for(;g<h.length;g++){const R=rl(h[g],n,!1,u);if(R instanceof n){if(!d){const y=!!(2&(0|R.u[O]));p&&(p=!y),f&&(f=y)}h[E++]=R}}E<g&&(h.length=E),l|=4,l=f?16|l:-17&l,be(h,l=p?8|l:-9&l),d&&Object.freeze(h)}if(o&&!(8&l||!r.length&&(c===1||c===4&&32&l))){for(Gt(l)&&(r=qe(r),l=qt(l,e),e=ge(t,e,s,r)),n=r,o=l,h=0;h<n.length;h++)(l=n[h])!==(u=oo(l))&&(n[h]=u);o|=8,be(n,o=n.length?-17&o:16|o),l=o}return c===1||c===4&&32&l?Gt(l)||(e=l,(l|=!r.length||16&l&&(!a||32&l)?2:2048)!==e&&be(r,l),Object.freeze(r)):(c===2&&Gt(l)&&(be(r=qe(r),l=ln(l=qt(l,e),e,i)),e=ge(t,e,s,r)),Gt(l)||(s=l,(l=ln(l,e,i))!==s&&be(r,l))),r}function Yt(t,e,n){const s=0|t.u[O];return _m(t,s,e,n,Rn(),!1,!(2&s))}function L(t,e,n,s){return s==null&&(s=void 0),ae(t,n,s)}function sr(t,e,n,s){s==null&&(s=void 0);e:{let r=0|(t=t.u)[O];if(gn(r),s==null){const i=ll(t);if(hl(i,t,r,n)!==e)break e;i.set(n,0)}else r=mm(t,r,n,e);ge(t,r,e,s)}}function qt(t,e){return-2049&(t=32|(2&e?2|t:-3&t))}function ln(t,e,n){return 32&e&&n||(t&=-33),t}function Di(t,e,n,s){const r=0|t.u[O];gn(r),t=_m(t,r,n,e,2,!0),s=s??new n,t.push(s),t[O]=2&(0|s.u[O])?-9&t[O]:-17&t[O]}function ft(t,e){return Rs(_s(t,e))}function mt(t,e){return gs(_s(t,e))}function ve(t,e){return Qr(t,e)??0}function Er(t,e,n){if(n!=null&&typeof n!="boolean")throw t=typeof n,Error(`Expected boolean but got ${t!="object"?t:n?Array.isArray(n)?"array":t:"null"}: ${n}`);ae(t,e,n)}function Ft(t,e,n){if(n!=null){if(typeof n!="number"||!so(n))throw Da("int32");n|=0}ae(t,e,n)}function N(t,e,n){if(n!=null&&typeof n!="number")throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);ae(t,e,n)}function Pi(t,e,n){{const o=t.u;let a=0|o[O];if(gn(a),n==null)ge(o,a,e);else{var s=t=0|n[O],r=Gt(t),i=r||Object.isFrozen(n);for(r||(t=0),i||(n=qe(n),s=0,t=ln(t=qt(t,a),a,!0),i=!1),t|=21,r=0;r<n.length;r++){const c=n[r],l=cm(c);Object.is(c,l)||(i&&(n=qe(n),s=0,t=ln(t=qt(t,a),a,!0),i=!1),n[r]=l)}t!==s&&(i&&(n=qe(n),t=ln(t=qt(t,a),a,!0)),be(n,t)),ge(o,a,e,n)}}}function ao(t,e,n){gn(0|t.u[O]),kn(t,e,gs,2,!0).push(cm(n))}function ym(t,e){return Error(`Invalid wire type: ${t} (at position ${e})`)}function dl(){return Error("Failed to read varint, encoding is invalid.")}function Em(t,e){return Error(`Tried to read past the end of the data ${e} > ${t}`)}function fl(t){if(typeof t=="string")return{buffer:Zp(t),N:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),N:!1};if(t.constructor===Uint8Array)return{buffer:t,N:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),N:!1};if(t.constructor===jt)return{buffer:jc(t)||new Uint8Array(0),N:!0};if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),N:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function pl(t,e){let n,s=0,r=0,i=0;const o=t.h;let a=t.g;do n=o[a++],s|=(127&n)<<i,i+=7;while(i<32&&128&n);for(i>32&&(r|=(127&n)>>4),i=3;i<32&&128&n;i+=7)n=o[a++],r|=(127&n)<<i;if(Nn(t,a),n<128)return e(s>>>0,r>>>0);throw dl()}function ml(t){let e=0,n=t.g;const s=n+10,r=t.h;for(;n<s;){const i=r[n++];if(e|=i,(128&i)==0)return Nn(t,n),!!(127&e)}throw dl()}function fn(t){const e=t.h;let n=t.g,s=e[n++],r=127&s;if(128&s&&(s=e[n++],r|=(127&s)<<7,128&s&&(s=e[n++],r|=(127&s)<<14,128&s&&(s=e[n++],r|=(127&s)<<21,128&s&&(s=e[n++],r|=s<<28,128&s&&128&e[n++]&&128&e[n++]&&128&e[n++]&&128&e[n++]&&128&e[n++])))))throw dl();return Nn(t,n),r}function Xt(t){return fn(t)>>>0}function Ua(t){var e=t.h;const n=t.g,s=e[n],r=e[n+1],i=e[n+2];return e=e[n+3],Nn(t,t.g+4),(s<<0|r<<8|i<<16|e<<24)>>>0}function Va(t){var e=Ua(t);t=2*(e>>31)+1;const n=e>>>23&255;return e&=8388607,n==255?e?NaN:t*(1/0):n==0?1401298464324817e-60*t*e:t*Math.pow(2,n-150)*(e+8388608)}function eE(t){return fn(t)}function ea(t,e,{ba:n=!1}={}){t.ba=n,e&&(e=fl(e),t.h=e.buffer,t.m=e.N,t.j=0,t.l=t.h.length,t.g=t.j)}function Nn(t,e){if(t.g=e,e>t.l)throw Em(t.l,e)}function vm(t,e){if(e<0)throw Error(`Tried to read a negative byte length: ${e}`);const n=t.g,s=n+e;if(s>t.l)throw Em(e,t.l-n);return t.g=s,n}function wm(t,e){if(e==0)return Mn();var n=vm(t,e);return t.ba&&t.m?n=t.h.subarray(n,n+e):(t=t.h,n=n===(e=n+e)?new Uint8Array(0):H3?t.slice(n,e):new Uint8Array(t.subarray(n,e))),n.length==0?Mn():new jt(n,fs)}pt.prototype.toJSON=void 0,pt.prototype.Ia=rm;var lu=[];function bm(t){var e=t.g;if(e.g==e.l)return!1;t.l=t.g.g;var n=Xt(t.g);if(e=n>>>3,!((n&=7)>=0&&n<=5))throw ym(n,t.l);if(e<1)throw Error(`Invalid field number: ${e} (at position ${t.l})`);return t.m=e,t.h=n,!0}function Zr(t){switch(t.h){case 0:t.h!=0?Zr(t):ml(t.g);break;case 1:Nn(t=t.g,t.g+8);break;case 2:if(t.h!=2)Zr(t);else{var e=Xt(t.g);Nn(t=t.g,t.g+e)}break;case 5:Nn(t=t.g,t.g+4);break;case 3:for(e=t.m;;){if(!bm(t))throw Error("Unmatched start-group tag: stream EOF");if(t.h==4){if(t.m!=e)throw Error("Unmatched end-group tag");break}Zr(t)}break;default:throw ym(t.h,t.l)}}function Lr(t,e,n){const s=t.g.l,r=Xt(t.g),i=t.g.g+r;let o=i-s;if(o<=0&&(t.g.l=i,n(e,t,void 0,void 0,void 0),o=i-t.g.g),o)throw Error(`Message parsing ended unexpectedly. Expected to read ${r} bytes, instead read ${r-o} bytes, either the data ended unexpectedly or the message misreported its own length`);return t.g.g=i,t.g.l=s,e}function gl(t){var e=Xt(t.g),n=vm(t=t.g,e);if(t=t.h,b3){var s,r=t;(s=qo)||(s=qo=new TextDecoder("utf-8",{fatal:!0})),e=n+e,r=n===0&&e===r.length?r:r.subarray(n,e);try{var i=s.decode(r)}catch(a){if(Wr===void 0){try{s.decode(new Uint8Array([128]))}catch{}try{s.decode(new Uint8Array([97])),Wr=!0}catch{Wr=!1}}throw!Wr&&(qo=void 0),a}}else{e=(i=n)+e,n=[];let a,c=null;for(;i<e;){var o=t[i++];o<128?n.push(o):o<224?i>=e?En():(a=t[i++],o<194||(192&a)!=128?(i--,En()):n.push((31&o)<<6|63&a)):o<240?i>=e-1?En():(a=t[i++],(192&a)!=128||o===224&&a<160||o===237&&a>=160||(192&(s=t[i++]))!=128?(i--,En()):n.push((15&o)<<12|(63&a)<<6|63&s)):o<=244?i>=e-2?En():(a=t[i++],(192&a)!=128||a-144+(o<<28)>>30!=0||(192&(s=t[i++]))!=128||(192&(r=t[i++]))!=128?(i--,En()):(o=(7&o)<<18|(63&a)<<12|(63&s)<<6|63&r,o-=65536,n.push(55296+(o>>10&1023),56320+(1023&o)))):En(),n.length>=8192&&(c=qh(c,n),n.length=0)}i=qh(c,n)}return i}function Tm(t){const e=Xt(t.g);return wm(t.g,e)}function co(t,e,n){var s=Xt(t.g);for(s=t.g.g+s;t.g.g<s;)n.push(e(t.g))}var Gr=[];function tE(t){return t}let rs;function Ct(t,e,n){e.g?e.m(t,e.g,e.h,n):e.m(t,e.h,n)}var k=class{constructor(t,e){this.u=dm(t,e)}toJSON(){const t=!rs;try{return t&&(rs=um),Cm(this)}finally{t&&(rs=void 0)}}l(){var t=ME;return t.g?t.l(this,t.g,t.h,!0):t.l(this,t.h,t.defaultValue,!0)}clone(){const t=this.u;return new this.constructor(io(t,0|t[O],!1))}N(){return!!(2&(0|this.u[O]))}};function Cm(t){var e=t.u;{e=(t=rs(e))!==e;let l=t.length;if(l){var n=t[l-1],s=Kc(n);s?l--:n=void 0;var r=t;if(s){e:{var i,o=n,a=!1;if(o)for(let h in o)isNaN(+h)?(i??(i={}))[h]=o[h]:(s=o[h],Array.isArray(s)&&(Ni(s)||Zh(s)&&s.size===0)&&(s=null),s==null&&(a=!0),s!=null&&((i??(i={}))[h]=s));if(a||(i=o),i)for(let h in i){a=i;break e}a=null}o=a==null?n!=null:a!==n}for(;l>0&&((i=r[l-1])==null||Ni(i)||Zh(i)&&i.size===0);l--)var c=!0;(r!==t||o||c)&&(e?(c||o||a)&&(r.length=l):r=Array.prototype.slice.call(r,0,l),a&&r.push(a)),c=r}else c=t}return c}function hu(t){return t?/^\d+$/.test(t)?(no(t),new Ha(se,_e)):null:nE||(nE=new Ha(0,0))}k.prototype.W=Or,k.prototype.toString=function(){try{return rs=tE,Cm(this).toString()}finally{rs=void 0}};var Ha=class{constructor(t,e){this.h=t>>>0,this.g=e>>>0}};let nE;function uu(t){return t?/^-?\d+$/.test(t)?(no(t),new Wa(se,_e)):null:sE||(sE=new Wa(0,0))}var Wa=class{constructor(t,e){this.h=t>>>0,this.g=e>>>0}};let sE;function is(t,e,n){for(;n>0||e>127;)t.g.push(127&e|128),e=(e>>>7|n<<25)>>>0,n>>>=7;t.g.push(e)}function Ns(t,e){for(;e>127;)t.g.push(127&e|128),e>>>=7;t.g.push(e)}function lo(t,e){if(e>=0)Ns(t,e);else{for(let n=0;n<9;n++)t.g.push(127&e|128),e>>=7;t.g.push(1)}}function vr(t,e){t.g.push(e>>>0&255),t.g.push(e>>>8&255),t.g.push(e>>>16&255),t.g.push(e>>>24&255)}function ys(t,e){e.length!==0&&(t.l.push(e),t.h+=e.length)}function it(t,e,n){Ns(t.g,8*e+n)}function _l(t,e){return it(t,e,2),e=t.g.end(),ys(t,e),e.push(t.h),e}function yl(t,e){var n=e.pop();for(n=t.h+t.g.length()-n;n>127;)e.push(127&n|128),n>>>=7,t.h++;e.push(n),t.h++}function ho(t,e,n){it(t,e,2),Ns(t.g,n.length),ys(t,t.g.end()),ys(t,n)}function Fi(t,e,n,s){n!=null&&(e=_l(t,e),s(n,t),yl(t,e))}function St(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var El=St(),Sm=St(),vl=St(),wl=St(),Am=St(),Rm=St(),bl=St(),km=St(),Im=St(),xs=class{constructor(t,e,n){this.g=t,this.h=e,t=El,this.l=!!t&&n===t||!1}};function uo(t,e){return new xs(t,e,El)}function Nm(t,e,n,s,r){Fi(t,n,Dm(e,s),r)}const rE=uo(function(t,e,n,s,r){return t.h===2&&(Lr(t,ul(e,s,n),r),!0)},Nm),iE=uo(function(t,e,n,s,r){return t.h===2&&(Lr(t,ul(e,s,n,!0),r),!0)},Nm);var fo=Symbol(),Tl=Symbol(),du=Symbol(),fu=Symbol();let xm,Om;function Hn(t,e,n,s){var r=s[t];if(r)return r;(r={}).Pa=s,r.V=function(u){switch(typeof u){case"boolean":return lm||(lm=[0,void 0,!0]);case"number":return u>0?void 0:u===0?Q3||(Q3=[0,void 0]):[-u,void 0];case"string":return[0,u];case"object":return u}}(s[0]);var i=s[1];let o=1;i&&i.constructor===Object&&(r.ga=i,typeof(i=s[++o])=="function"&&(r.la=!0,xm??(xm=i),Om??(Om=s[o+1]),i=s[o+=2]));const a={};for(;i&&Array.isArray(i)&&i.length&&typeof i[0]=="number"&&i[0]>0;){for(var c=0;c<i.length;c++)a[i[c]]=i;i=s[++o]}for(c=1;i!==void 0;){let u;typeof i=="number"&&(c+=i,i=s[++o]);var l=void 0;if(i instanceof xs?u=i:(u=rE,o--),u==null?void 0:u.l){i=s[++o],l=s;var h=o;typeof i=="function"&&(i=i(),l[h]=i),l=i}for(h=c+1,typeof(i=s[++o])=="number"&&i<0&&(h-=i,i=s[++o]);c<h;c++){const d=a[c];l?n(r,c,u,l,d):e(r,c,u,d)}}return s[t]=r}function Lm(t){return Array.isArray(t)?t[0]instanceof xs?t:[iE,t]:[t,void 0]}function Dm(t,e){return t instanceof k?t.u:Array.isArray(t)?cn(t,e,!1):void 0}function Cl(t,e,n,s){const r=n.g;t[e]=s?(i,o,a)=>r(i,o,a,s):r}function Sl(t,e,n,s,r){const i=n.g;let o,a;t[e]=(c,l,h)=>i(c,l,h,a||(a=Hn(Tl,Cl,Sl,s).V),o||(o=Al(s)),r)}function Al(t){let e=t[du];if(e!=null)return e;const n=Hn(Tl,Cl,Sl,t);return e=n.la?(s,r)=>xm(s,r,n):(s,r)=>{const i=0|s[O];for(;bm(r)&&r.h!=4;){var o=r.m,a=n[o];if(a==null){var c=n.ga;c&&(c=c[o])&&(c=oE(c))!=null&&(a=n[o]=c)}a!=null&&a(r,s,o)||(o=(a=r).l,Zr(a),a.fa?a=void 0:(c=a.g.g-o,a.g.g=o,a=wm(a.g,c)),o=s,a&&((c=o[ps])?c.push(a):o[ps]=[a]))}return 16384&i&&As(s),!0},t[du]=e}function oE(t){const e=(t=Lm(t))[0].g;if(t=t[1]){const n=Al(t),s=Hn(Tl,Cl,Sl,t).V;return(r,i,o)=>e(r,i,o,s,n)}return e}function po(t,e,n){t[e]=n.h}function mo(t,e,n,s){let r,i;const o=n.h;t[e]=(a,c,l)=>o(a,c,l,i||(i=Hn(fo,po,mo,s).V),r||(r=Pm(s)))}function Pm(t){let e=t[fu];if(!e){const n=Hn(fo,po,mo,t);e=(s,r)=>Fm(s,r,n),t[fu]=e}return e}function Fm(t,e,n){for(var s=0|t[O],r=512&s?0:-1,i=t.length,o=512&s?1:0,a=i+(256&s?-1:0);o<a;o++){const c=t[o];if(c==null)continue;const l=o-r,h=pu(n,l);h&&h(e,c,l)}if(256&s){s=t[i-1];for(const c in s)r=+c,Number.isNaN(r)||(i=s[r])!=null&&(a=pu(n,r))&&a(e,i,r)}if(t=Xc(t))for(ys(e,e.g.end()),n=0;n<t.length;n++)ys(e,jc(t[n])||new Uint8Array(0))}function pu(t,e){var n=t[e];if(n)return n;if((n=t.ga)&&(n=n[e])){var s=(n=Lm(n))[0].h;if(n=n[1]){const r=Pm(n),i=Hn(fo,po,mo,n).V;n=t.la?Om(i,r):(o,a,c)=>s(o,a,c,i,r)}else n=s;return t[e]=n}}function Os(t,e){if(Array.isArray(e)){var n=0|e[O];if(4&n)return e;for(var s=0,r=0;s<e.length;s++){const i=t(e[s]);i!=null&&(e[r++]=i)}return r<s&&(e.length=r),be(e,-12289&(5|n)),2&n&&Object.freeze(e),e}}function He(t,e,n){return new xs(t,e,n)}function Ls(t,e,n){return new xs(t,e,n)}function We(t,e,n){ge(t,0|t[O],e,n)}var aE=uo(function(t,e,n,s,r){return t.h===2&&(t=Lr(t,cn([void 0,void 0],s,!0),r),gn(s=0|e[O]),(r=Zt(e,s,n))instanceof pt?(2&r.L)!=0?((r=r.X()).push(t),ge(e,s,n,r)):r.Na(t):Array.isArray(r)?(2&(0|r[O])&&ge(e,s,n,r=pm(r)),r.push(t)):ge(e,s,n,[t]),!0)},function(t,e,n,s,r){if(e instanceof pt)e.forEach((i,o)=>{Fi(t,n,cn([o,i],s,!1),r)});else if(Array.isArray(e))for(let i=0;i<e.length;i++){const o=e[i];Array.isArray(o)&&Fi(t,n,cn(o,s,!1),r)}});function Mm(t,e,n){if(e=function(s){if(s==null)return s;const r=typeof s;if(r==="bigint")return String(tl(64,s));if(ro(s)){if(r==="string")return sl(s);if(r==="number")return nl(s)}}(e),e!=null&&(typeof e=="string"&&uu(e),e!=null))switch(it(t,n,0),typeof e){case"number":t=t.g,ms(e),is(t,se,_e);break;case"bigint":n=BigInt.asUintN(64,e),n=new Wa(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),is(t.g,n.h,n.g);break;default:n=uu(e),is(t.g,n.h,n.g)}}function Bm(t,e,n){(e=Rs(e))!=null&&e!=null&&(it(t,n,0),lo(t.g,e))}function Um(t,e,n){(e=om(e))!=null&&(it(t,n,0),t.g.g.push(e?1:0))}function Vm(t,e,n){(e=gs(e))!=null&&ho(t,n,Kp(e))}function Hm(t,e,n,s,r){Fi(t,n,Dm(e,s),r)}function Wm(t,e,n){(e=e==null||typeof e=="string"||Nr(e)||e instanceof jt?e:void 0)!=null&&ho(t,n,fl(e).buffer)}function Gm(t,e,n){return(t.h===5||t.h===2)&&(e=Is(e,0|e[O],n,!1,!1),t.h==2?co(t,Va,e):e.push(Va(t.g)),!0)}var Vt=He(function(t,e,n){if(t.h!==1)return!1;var s=t.g;t=Ua(s);const r=Ua(s);s=2*(r>>31)+1;const i=r>>>20&2047;return t=4294967296*(1048575&r)+t,We(e,n,i==2047?t?NaN:s*(1/0):i==0?5e-324*s*t:s*Math.pow(2,i-1075)*(t+4503599627370496)),!0},function(t,e,n){(e=_n(e))!=null&&(it(t,n,1),t=t.g,(n=im||(im=new DataView(new ArrayBuffer(8)))).setFloat64(0,+e,!0),se=n.getUint32(0,!0),_e=n.getUint32(4,!0),vr(t,se),vr(t,_e))},St()),Te=He(function(t,e,n){return t.h===5&&(We(e,n,Va(t.g)),!0)},function(t,e,n){(e=_n(e))!=null&&(it(t,n,5),t=t.g,Jc(e),vr(t,se))},bl),cE=Ls(Gm,function(t,e,n){if((e=Os(_n,e))!=null)for(let o=0;o<e.length;o++){var s=t,r=n,i=e[o];i!=null&&(it(s,r,5),s=s.g,Jc(i),vr(s,se))}},bl),Rl=Ls(Gm,function(t,e,n){if((e=Os(_n,e))!=null&&e.length){it(t,n,2),Ns(t.g,4*e.length);for(let s=0;s<e.length;s++)n=t.g,Jc(e[s]),vr(n,se)}},bl),pn=He(function(t,e,n){return t.h===0&&(We(e,n,pl(t.g,Zc)),!0)},Mm,Rm),ta=He(function(t,e,n){return t.h===0&&(We(e,n,(t=pl(t.g,Zc))===0?void 0:t),!0)},Mm,Rm),lE=He(function(t,e,n){return t.h===0&&(We(e,n,pl(t.g,Qc)),!0)},function(t,e,n){if((e=$3(e))!=null&&(typeof e=="string"&&hu(e),e!=null))switch(it(t,n,0),typeof e){case"number":t=t.g,ms(e),is(t,se,_e);break;case"bigint":n=BigInt.asUintN(64,e),n=new Ha(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),is(t.g,n.h,n.g);break;default:n=hu(e),is(t.g,n.h,n.g)}},St()),Ee=He(function(t,e,n){return t.h===0&&(We(e,n,fn(t.g)),!0)},Bm,wl),go=Ls(function(t,e,n){return(t.h===0||t.h===2)&&(e=Is(e,0|e[O],n,!1,!1),t.h==2?co(t,fn,e):e.push(fn(t.g)),!0)},function(t,e,n){if((e=Os(Rs,e))!=null&&e.length){n=_l(t,n);for(let s=0;s<e.length;s++)lo(t.g,e[s]);yl(t,n)}},wl),Xn=He(function(t,e,n){return t.h===0&&(We(e,n,(t=fn(t.g))===0?void 0:t),!0)},Bm,wl),fe=He(function(t,e,n){return t.h===0&&(We(e,n,ml(t.g)),!0)},Um,Sm),os=He(function(t,e,n){return t.h===0&&(We(e,n,(t=ml(t.g))===!1?void 0:t),!0)},Um,Sm),Pe=Ls(function(t,e,n){return t.h===2&&(t=gl(t),Is(e,0|e[O],n,!1).push(t),!0)},function(t,e,n){if((e=Os(gs,e))!=null)for(let o=0;o<e.length;o++){var s=t,r=n,i=e[o];i!=null&&ho(s,r,Kp(i))}},vl),sn=He(function(t,e,n){return t.h===2&&(We(e,n,(t=gl(t))===""?void 0:t),!0)},Vm,vl),Q=He(function(t,e,n){return t.h===2&&(We(e,n,gl(t)),!0)},Vm,vl),Re=function(t,e,n=El){return new xs(t,e,n)}(function(t,e,n,s,r){return t.h===2&&(s=cn(void 0,s,!0),Is(e,0|e[O],n,!0).push(s),Lr(t,s,r),!0)},function(t,e,n,s,r){if(Array.isArray(e))for(let i=0;i<e.length;i++)Hm(t,e[i],n,s,r)}),ee=uo(function(t,e,n,s,r,i){return t.h===2&&(mm(e,0|e[O],i,n),Lr(t,e=ul(e,s,n),r),!0)},Hm),$m=He(function(t,e,n){return t.h===2&&(We(e,n,Tm(t)),!0)},Wm,km),hE=Ls(function(t,e,n){return(t.h===0||t.h===2)&&(e=Is(e,0|e[O],n,!1,!1),t.h==2?co(t,Xt,e):e.push(Xt(t.g)),!0)},function(t,e,n){if((e=Os(am,e))!=null)for(let o=0;o<e.length;o++){var s=t,r=n,i=e[o];i!=null&&(it(s,r,0),Ns(s.g,i))}},Am),uE=He(function(t,e,n){return t.h===0&&(We(e,n,(t=Xt(t.g))===0?void 0:t),!0)},function(t,e,n){(e=am(e))!=null&&e!=null&&(it(t,n,0),Ns(t.g,e))},Am),gt=He(function(t,e,n){return t.h===0&&(We(e,n,fn(t.g)),!0)},function(t,e,n){(e=Rs(e))!=null&&(e=parseInt(e,10),it(t,n,0),lo(t.g,e))},Im);class dE{constructor(e,n){this.h=e,this.g=n,this.l=Y,this.m=L,this.defaultValue=void 0}}function At(t,e){return new dE(t,e)}function yn(t,e){return(n,s)=>{if(Gr.length){const i=Gr.pop();i.o(s),ea(i.g,n,s),n=i}else n=new class{constructor(i,o){if(lu.length){const a=lu.pop();ea(a,i,o),i=a}else i=new class{constructor(a,c){this.h=null,this.m=!1,this.g=this.l=this.j=0,ea(this,a,c)}clear(){this.h=null,this.m=!1,this.g=this.l=this.j=0,this.ba=!1}}(i,o);this.g=i,this.l=this.g.g,this.h=this.m=-1,this.o(o)}o({fa:i=!1}={}){this.fa=i}}(n,s);try{const i=new t,o=i.u;Al(e)(o,n);var r=i}finally{n.g.clear(),n.m=-1,n.h=-1,Gr.length<100&&Gr.push(n)}return r}}function _o(t){return function(){const e=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const o=this.g;return this.g=[],o}}}};Fm(this.u,e,Hn(fo,po,mo,t)),ys(e,e.g.end());const n=new Uint8Array(e.h),s=e.l,r=s.length;let i=0;for(let o=0;o<r;o++){const a=s[o];n.set(a,i),i+=a.length}return e.l=[n],n}}var mu=class extends k{constructor(t){super(t)}},gu=[0,sn,He(function(t,e,n){return t.h===2&&(We(e,n,(t=Tm(t))===Mn()?void 0:t),!0)},function(t,e,n){if(e!=null){if(e instanceof k){const s=e.Ra;return void(s&&(e=s(e),e!=null&&ho(t,n,fl(e).buffer)))}if(Array.isArray(e))return}Wm(t,e,n)},km)];let na,_u=globalThis.trustedTypes;function yu(t){na===void 0&&(na=function(){let n=null;if(!_u)return n;try{const s=r=>r;n=_u.createPolicy("goog#html",{createHTML:s,createScript:s,createScriptURL:s})}catch{}return n}());var e=na;return new class{constructor(n){this.g=n}toString(){return this.g+""}}(e?e.createScriptURL(t):t)}function fE(t,...e){if(e.length===0)return yu(t[0]);let n=t[0];for(let s=0;s<e.length;s++)n+=encodeURIComponent(e[s])+t[s+1];return yu(n)}var jm=[0,Ee,gt,fe,-1,go,gt,-1],pE=class extends k{constructor(t){super(t)}},qm=[0,fe,Q,fe,gt,-1,Ls(function(t,e,n){return(t.h===0||t.h===2)&&(e=Is(e,0|e[O],n,!1,!1),t.h==2?co(t,eE,e):e.push(fn(t.g)),!0)},function(t,e,n){if((e=Os(Rs,e))!=null&&e.length){n=_l(t,n);for(let s=0;s<e.length;s++)lo(t.g,e[s]);yl(t,n)}},Im),Q,-1,[0,fe,-1],gt,fe,-1],zm=[0,Q,-2],Eu=class extends k{constructor(t){super(t)}},Km=[0],Ym=[0,Ee,fe,1,fe,-3],rt=class extends k{constructor(t){super(t,2)}},Se={};Se[336783863]=[0,Q,fe,-1,Ee,[0,[1,2,3,4,5,6,7,8],ee,Km,ee,qm,ee,zm,ee,Ym,ee,jm,ee,[0,Q,-2],ee,[0,Q,gt],ee,[0,gt,Q]],[0,Q],fe,[0,[1,3],[2,4],ee,[0,go],-1,ee,[0,Pe],-1,Re,[0,Q,-1]],Q];var vu=[0,ta,-1,os,-3,ta,go,sn,Xn,ta,-1,os,Xn,os,-2,sn];function ot(t,e){Ba(t,2,ks(e),"")}function ce(t,e){ao(t,3,e)}function z(t,e){ao(t,4,e)}var Ve=class extends k{constructor(t){super(t,500)}o(t){return L(this,0,7,t)}},rr=[-1,{}],wu=[0,Q,1,rr],bu=[0,Q,Pe,rr];function at(t,e){Di(t,1,Ve,e)}function ue(t,e){ao(t,10,e)}function X(t,e){ao(t,15,e)}var Xe=class extends k{constructor(t){super(t,500)}o(t){return L(this,0,1001,t)}},Xm=[-500,Re,[-500,sn,-1,Pe,-3,[-2,Se,fe],Re,gu,Xn,-1,wu,bu,Re,[0,sn,os],sn,vu,Xn,Pe,987,Pe],4,Re,[-500,Q,-1,[-1,{}],998,Q],Re,[-500,Q,Pe,-1,[-2,{},fe],997,Pe,-1],Xn,Re,[-500,Q,Pe,rr,998,Pe],Pe,Xn,wu,bu,Re,[0,sn,-1,rr],Pe,-2,vu,sn,-1,os,[0,os,uE],978,rr,Re,gu];Xe.prototype.g=_o(Xm);var mE=yn(Xe,Xm),gE=class extends k{constructor(t){super(t)}},Jm=class extends k{constructor(t){super(t)}g(){return Yt(this,gE,1)}},Qm=[0,Re,[0,Ee,Te,Q,-1]],yo=yn(Jm,Qm),_E=class extends k{constructor(t){super(t)}},yE=class extends k{constructor(t){super(t)}},sa=class extends k{constructor(t){super(t)}h(){return Y(this,_E,2)}g(){return Yt(this,yE,5)}},Zm=yn(class extends k{constructor(t){super(t)}},[0,Pe,go,Rl,[0,gt,[0,Ee,-3],[0,Te,-3],[0,Ee,-1,[0,Re,[0,Ee,-2]]],Re,[0,Te,-1,Q,Te]],Q,-1,pn,Re,[0,Ee,Te],Pe,pn]),eg=class extends k{constructor(t){super(t)}},as=yn(class extends k{constructor(t){super(t)}},[0,Re,[0,Te,-4]]),tg=class extends k{constructor(t){super(t)}},Dr=yn(class extends k{constructor(t){super(t)}},[0,Re,[0,Te,-4]]),EE=class extends k{constructor(t){super(t)}},vE=[0,Ee,-1,Rl,gt],ng=class extends k{constructor(t){super(t)}};ng.prototype.g=_o([0,Te,-4,pn]);var wE=class extends k{constructor(t){super(t)}},bE=yn(class extends k{constructor(t){super(t)}},[0,Re,[0,1,Ee,Q,Qm],pn]),Tu=class extends k{constructor(t){super(t)}},TE=class extends k{constructor(t){super(t)}oa(){const t=fm(this);return t??Mn()}},CE=class extends k{constructor(t){super(t)}},sg=[1,2],SE=yn(class extends k{constructor(t){super(t)}},[0,Re,[0,sg,ee,[0,Rl],ee,[0,$m],Ee,Q],pn]),kl=class extends k{constructor(t){super(t)}},rg=[0,Q,Ee,Te,Pe,-1],Cu=class extends k{constructor(t){super(t)}},AE=[0,fe,-1],Su=class extends k{constructor(t){super(t)}},ei=[1,2,3,4,5],Mi=class extends k{constructor(t){super(t)}g(){return fm(this)!=null}h(){return mt(this,2)!=null}},pe=class extends k{constructor(t){super(t)}g(){return om(_s(this,2))??!1}},ig=[0,$m,Q,[0,Ee,pn,-1],[0,lE,pn]],we=[0,ig,fe,[0,ei,ee,Ym,ee,qm,ee,jm,ee,Km,ee,zm],gt],Eo=class extends k{constructor(t){super(t)}},Il=[0,we,Te,-1,Ee],RE=At(502141897,Eo);Se[502141897]=Il;var kE=yn(class extends k{constructor(t){super(t)}},[0,[0,gt,-1,cE,hE],vE]),og=class extends k{constructor(t){super(t)}},ag=class extends k{constructor(t){super(t)}},Nl=[0,we,Te,[0,we],fe],cg=[0,we,Il,Nl,Te,[0,[0,ig]]],IE=At(508968150,ag);Se[508968150]=cg,Se[508968149]=Nl;var lg=class extends k{constructor(t){super(t)}},NE=At(513916220,lg);Se[513916220]=[0,we,cg,Ee];var Gn=class extends k{constructor(t){super(t)}h(){return Y(this,kl,2)}g(){ae(this,2)}},hg=[0,we,rg];Se[478825465]=hg;var xE=class extends k{constructor(t){super(t)}},ug=class extends k{constructor(t){super(t)}},xl=class extends k{constructor(t){super(t)}},Ol=class extends k{constructor(t){super(t)}},dg=class extends k{constructor(t){super(t)}},Au=[0,we,[0,we],hg,-1],fg=[0,we,Te,Ee],Ll=[0,we,Te],pg=[0,we,fg,Ll,Te],OE=At(479097054,dg);Se[479097054]=[0,we,pg,Au],Se[463370452]=Au,Se[464864288]=fg;var LE=At(462713202,Ol);Se[462713202]=pg,Se[474472470]=Ll;var DE=class extends k{constructor(t){super(t)}},mg=class extends k{constructor(t){super(t)}},gg=class extends k{constructor(t){super(t)}},_g=class extends k{constructor(t){super(t)}},Dl=[0,we,Te,-1,Ee],Ga=[0,we,Te,fe];_g.prototype.g=_o([0,we,Ll,[0,we],Il,Nl,Dl,Ga]);var yg=class extends k{constructor(t){super(t)}},PE=At(456383383,yg);Se[456383383]=[0,we,rg];var Eg=class extends k{constructor(t){super(t)}},FE=At(476348187,Eg);Se[476348187]=[0,we,AE];var vg=class extends k{constructor(t){super(t)}},Ru=class extends k{constructor(t){super(t)}},wg=[0,gt,-1],ME=At(458105876,class extends k{constructor(t){super(t)}g(){var t=this.u;const e=0|t[O],n=2&e;return t=function(s,r,i){var o=Ru;const a=2&r;let c=!1;if(i==null){if(a)return cu();i=[]}else if(i.constructor===pt){if((2&i.L)==0||a)return i;i=i.X()}else Array.isArray(i)?c=!!(2&(0|i[O])):i=[];if(a){if(!i.length)return cu();c||(c=!0,As(i))}else c&&(c=!1,i=pm(i));return c||(64&(0|i[O])?i[O]&=-33:32&r&&Zi(i,32)),ge(s,r,2,o=new pt(i,o,j3,void 0)),o}(t,e,Zt(t,e,2)),!n&&Ru&&(t.ra=!0),t}});Se[458105876]=[0,wg,aE,[!0,pn,[0,Q,-1,Pe]]];var Pl=class extends k{constructor(t){super(t)}},bg=At(458105758,Pl);Se[458105758]=[0,we,Q,wg];var Tg=class extends k{constructor(t){super(t)}},BE=At(443442058,Tg);Se[443442058]=[0,we,Q,Ee,Te,Pe,-1,fe,Te],Se[514774813]=Dl;var Cg=class extends k{constructor(t){super(t)}},UE=At(516587230,Cg);function $a(t,e){return e=e?e.clone():new kl,t.displayNamesLocale!==void 0?ae(e,1,ks(t.displayNamesLocale)):t.displayNamesLocale===void 0&&ae(e,1),t.maxResults!==void 0?Ft(e,2,t.maxResults):"maxResults"in t&&ae(e,2),t.scoreThreshold!==void 0?N(e,3,t.scoreThreshold):"scoreThreshold"in t&&ae(e,3),t.categoryAllowlist!==void 0?Pi(e,4,t.categoryAllowlist):"categoryAllowlist"in t&&ae(e,4),t.categoryDenylist!==void 0?Pi(e,5,t.categoryDenylist):"categoryDenylist"in t&&ae(e,5),e}function Fl(t,e=-1,n=""){return{categories:t.map(s=>({index:ft(s,1)??0??-1,score:ve(s,2)??0,categoryName:mt(s,3)??""??"",displayName:mt(s,4)??""??""})),headIndex:e,headName:n}}function Sg(t){var o,a;var e=kn(t,3,_n,Rn()),n=kn(t,2,Rs,Rn()),s=kn(t,1,gs,Rn()),r=kn(t,9,gs,Rn());const i={categories:[],keypoints:[]};for(let c=0;c<e.length;c++)i.categories.push({score:e[c],index:n[c]??-1,categoryName:s[c]??"",displayName:r[c]??""});if((e=(o=Y(t,sa,4))==null?void 0:o.h())&&(i.boundingBox={originX:ft(e,1)??0,originY:ft(e,2)??0,width:ft(e,3)??0,height:ft(e,4)??0,angle:0}),(a=Y(t,sa,4))==null?void 0:a.g().length)for(const c of Y(t,sa,4).g())i.keypoints.push({x:Qr(c,1)??0,y:Qr(c,2)??0,score:Qr(c,4)??0,label:mt(c,3)??""});return i}function vo(t){const e=[];for(const n of Yt(t,tg,1))e.push({x:ve(n,1)??0,y:ve(n,2)??0,z:ve(n,3)??0,visibility:ve(n,4)??0});return e}function ir(t){const e=[];for(const n of Yt(t,eg,1))e.push({x:ve(n,1)??0,y:ve(n,2)??0,z:ve(n,3)??0,visibility:ve(n,4)??0});return e}function ku(t){return Array.from(t,e=>e>127?e-256:e)}function Iu(t,e){if(t.length!==e.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${e.length}).`);let n=0,s=0,r=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i],s+=t[i]*t[i],r+=e[i]*e[i];if(s<=0||r<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(s*r)}let $r;Se[516587230]=[0,we,Dl,Ga,Te],Se[518928384]=Ga;const VE=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function Ag(){if($r===void 0)try{await WebAssembly.instantiate(VE),$r=!0}catch{$r=!1}return $r}async function $s(t,e=fE``){const n=await Ag()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${n}.js`,wasmBinaryPath:`${e}/${t}_${n}.wasm`}}var bn=class{};function Rg(){var t=navigator;return typeof OffscreenCanvas<"u"&&(!function(e=navigator){return(e=e.userAgent).includes("Safari")&&!e.includes("Chrome")}(t)||!!((t=t.userAgent.match(/Version\/([\d]+).*Safari/))&&t.length>=1&&Number(t[1])>=17))}async function Nu(t){if(typeof importScripts!="function"){const e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise((n,s)=>{e.addEventListener("load",()=>{n()},!1),e.addEventListener("error",r=>{s(r)},!1),document.body.appendChild(e)})}importScripts(t.toString())}function kg(t){return t.videoWidth!==void 0?[t.videoWidth,t.videoHeight]:t.naturalWidth!==void 0?[t.naturalWidth,t.naturalHeight]:t.displayWidth!==void 0?[t.displayWidth,t.displayHeight]:[t.width,t.height]}function x(t,e,n){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(e=t.i.stringToNewUTF8(e)),t.i._free(e)}function xu(t,e,n){if(!t.i.canvas)throw Error("No OpenGL canvas configured.");if(n?t.i._bindTextureToStream(n):t.i._bindTextureToCanvas(),!(n=t.i.canvas.getContext("webgl2")||t.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");t.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e),t.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1);const[s,r]=kg(e);return!t.l||s===t.i.canvas.width&&r===t.i.canvas.height||(t.i.canvas.width=s,t.i.canvas.height=r),[s,r]}function Ou(t,e,n){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const s=new Uint32Array(e.length);for(let r=0;r<e.length;r++)s[r]=t.i.stringToNewUTF8(e[r]);e=t.i._malloc(4*s.length),t.i.HEAPU32.set(s,e>>2),n(e);for(const r of s)t.i._free(r);t.i._free(e)}function Nt(t,e,n){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[e]=n}function tn(t,e,n){let s=[];t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[e]=(r,i,o)=>{i?(n(s,o),s=[]):s.push(r)}}bn.forVisionTasks=function(t){return $s("vision",t)},bn.forTextTasks=function(t){return $s("text",t)},bn.forGenAiExperimentalTasks=function(t){return $s("genai_experimental",t)},bn.forGenAiTasks=function(t){return $s("genai",t)},bn.forAudioTasks=function(t){return $s("audio",t)},bn.isSimdSupported=function(){return Ag()};async function HE(t,e,n,s){return t=await(async(r,i,o,a,c)=>{if(i&&await Nu(i),!self.ModuleFactory||o&&(await Nu(o),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&c&&((i=self.Module).locateFile=c.locateFile,c.mainScriptUrlOrBlob&&(i.mainScriptUrlOrBlob=c.mainScriptUrlOrBlob)),c=await self.ModuleFactory(self.Module||c),self.ModuleFactory=self.Module=void 0,new r(c,a)})(t,n.wasmLoaderPath,n.assetLoaderPath,e,{locateFile:r=>r.endsWith(".wasm")?n.wasmBinaryPath.toString():n.assetBinaryPath&&r.endsWith(".data")?n.assetBinaryPath.toString():r}),await t.o(s),t}function ra(t,e){const n=Y(t.baseOptions,Mi,1)||new Mi;typeof e=="string"?(ae(n,2,ks(e)),ae(n,1)):e instanceof Uint8Array&&(ae(n,1,Yc(e,!1)),ae(n,2)),L(t.baseOptions,0,1,n)}function Lu(t){try{const e=t.G.length;if(e===1)throw Error(t.G[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.G.map(n=>n.message).join(", "))}finally{t.G=[]}}function A(t,e){t.B=Math.max(t.B,e)}function wo(t,e){t.A=new Ve,ot(t.A,"PassThroughCalculator"),ce(t.A,"free_memory"),z(t.A,"free_memory_unused_out"),ue(e,"free_memory"),at(e,t.A)}function Es(t,e){ce(t.A,e),z(t.A,e+"_unused_out")}function bo(t){t.g.addBoolToStream(!0,"free_memory",t.B)}var ti=class{constructor(t){this.g=t,this.G=[],this.B=0,this.g.setAutoRenderToScreen(!1)}l(t,e=!0){var n,s,r,i,o,a;if(e){const c=t.baseOptions||{};if((n=t.baseOptions)!=null&&n.modelAssetBuffer&&((s=t.baseOptions)!=null&&s.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((r=Y(this.baseOptions,Mi,1))!=null&&r.g()||(i=Y(this.baseOptions,Mi,1))!=null&&i.h()||(o=t.baseOptions)!=null&&o.modelAssetBuffer||(a=t.baseOptions)!=null&&a.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(l,h){let u=Y(l.baseOptions,Su,3);if(!u){var d=u=new Su,p=new Eu;sr(d,4,ei,p)}"delegate"in h&&(h.delegate==="GPU"?(h=u,d=new pE,sr(h,2,ei,d)):(h=u,d=new Eu,sr(h,4,ei,d))),L(l.baseOptions,0,3,u)}(this,c),c.modelAssetPath)return fetch(c.modelAssetPath.toString()).then(l=>{if(l.ok)return l.arrayBuffer();throw Error(`Failed to fetch model: ${c.modelAssetPath} (${l.status})`)}).then(l=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(l),!0,!1,!1),ra(this,"/model.dat"),this.m(),this.I()});if(c.modelAssetBuffer instanceof Uint8Array)ra(this,c.modelAssetBuffer);else if(c.modelAssetBuffer)return async function(l){const h=[];for(var u=0;;){const{done:d,value:p}=await l.read();if(d)break;h.push(p),u+=p.length}if(h.length===0)return new Uint8Array(0);if(h.length===1)return h[0];l=new Uint8Array(u),u=0;for(const d of h)l.set(d,u),u+=d.length;return l}(c.modelAssetBuffer).then(l=>{ra(this,l),this.m(),this.I()})}return this.m(),this.I(),Promise.resolve()}I(){}da(){let t;if(this.g.da(e=>{t=mE(e)}),!t)throw Error("Failed to retrieve CalculatorGraphConfig");return t}setGraph(t,e){this.g.attachErrorListener((n,s)=>{this.G.push(Error(s))}),this.g.La(),this.g.setGraph(t,e),this.A=void 0,Lu(this)}finishProcessing(){this.g.finishProcessing(),Lu(this)}close(){this.A=void 0,this.g.closeGraph()}};function Ue(t,e){if(!t)throw Error(`Unable to obtain required WebGL resource: ${e}`);return t}ti.prototype.close=ti.prototype.close,function(t,e){t=t.split(".");var n,s=Fn;for((t[0]in s)||s.execScript===void 0||s.execScript("var "+t[0]);t.length&&(n=t.shift());)t.length||e===void 0?s=s[n]&&s[n]!==Object.prototype[n]?s[n]:s[n]={}:s[n]=e}("TaskRunner",ti);class WE{constructor(e,n,s,r){this.g=e,this.h=n,this.m=s,this.l=r}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function Du(t,e,n){const s=t.g;if(n=Ue(s.createShader(n),"Failed to create WebGL shader"),s.shaderSource(n,e),s.compileShader(n),!s.getShaderParameter(n,s.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${s.getShaderInfoLog(n)}`);return s.attachShader(t.h,n),n}function Pu(t,e){const n=t.g,s=Ue(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(s);const r=Ue(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,r),n.enableVertexAttribArray(t.O),n.vertexAttribPointer(t.O,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW);const i=Ue(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,i),n.enableVertexAttribArray(t.I),n.vertexAttribPointer(t.I,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array(e?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindVertexArray(null),new WE(n,s,r,i)}function Ml(t,e){if(t.g){if(e!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=e}function Pr(t,e,n,s){return Ml(t,e),t.h||(t.m(),t.C()),n?(t.s||(t.s=Pu(t,!0)),n=t.s):(t.v||(t.v=Pu(t,!1)),n=t.v),e.useProgram(t.h),n.bind(),t.l(),t=s(),n.g.bindVertexArray(null),t}function mn(t,e,n){return Ml(t,e),t=Ue(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n??e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,n??e.LINEAR),e.bindTexture(e.TEXTURE_2D,null),t}function To(t,e,n){Ml(t,e),t.A||(t.A=Ue(e.createFramebuffer(),"Failed to create framebuffe.")),e.bindFramebuffer(e.FRAMEBUFFER,t.A),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0)}function Bl(t){var e;(e=t.g)==null||e.bindFramebuffer(t.g.FRAMEBUFFER,null)}var Ds=class{G(){return`
1595
1595
  precision mediump float;
1596
1596
  varying vec2 vTex;
1597
1597
  uniform sampler2D inputTexture;
@@ -1605,7 +1605,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1605
1605
  void main(void) {
1606
1606
  gl_Position = vec4(aVertex, 0.0, 1.0);
1607
1607
  vTex = aTex;
1608
- }`,t.VERTEX_SHADER),this.Z=Du(this,this.G(),t.FRAGMENT_SHADER),t.linkProgram(this.h),!t.getProgramParameter(this.h,t.LINK_STATUS))throw Error(`Error during program linking: ${t.getProgramInfoLog(this.h)}`);this.O=t.getAttribLocation(this.h,"aVertex"),this.I=t.getAttribLocation(this.h,"aTex")}C(){}l(){}close(){if(this.h){const t=this.g;t.deleteProgram(this.h),t.deleteShader(this.aa),t.deleteShader(this.Z)}this.A&&this.g.deleteFramebuffer(this.A),this.v&&this.v.close(),this.s&&this.s.close()}},WE=class extends Ds{G(){return`
1608
+ }`,t.VERTEX_SHADER),this.Z=Du(this,this.G(),t.FRAGMENT_SHADER),t.linkProgram(this.h),!t.getProgramParameter(this.h,t.LINK_STATUS))throw Error(`Error during program linking: ${t.getProgramInfoLog(this.h)}`);this.O=t.getAttribLocation(this.h,"aVertex"),this.I=t.getAttribLocation(this.h,"aTex")}C(){}l(){}close(){if(this.h){const t=this.g;t.deleteProgram(this.h),t.deleteShader(this.aa),t.deleteShader(this.Z)}this.A&&this.g.deleteFramebuffer(this.A),this.v&&this.v.close(),this.s&&this.s.close()}},GE=class extends Ds{G(){return`
1609
1609
  precision mediump float;
1610
1610
  uniform sampler2D backgroundTexture;
1611
1611
  uniform sampler2D maskTexture;
@@ -1631,14 +1631,14 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1631
1631
  overlayColor = mix(defaultColor, overlayColor, overlayColor.a);
1632
1632
  gl_FragColor = mix(defaultColor, overlayColor, confidence);
1633
1633
  }
1634
- `}C(){const t=this.g;t.activeTexture(t.TEXTURE1),this.j=mn(this,t),t.activeTexture(t.TEXTURE2),this.B=mn(this,t)}m(){super.m();const t=this.g;this.J=Ue(t.getUniformLocation(this.h,"defaultTexture"),"Uniform location"),this.K=Ue(t.getUniformLocation(this.h,"overlayTexture"),"Uniform location"),this.H=Ue(t.getUniformLocation(this.h,"maskTexture"),"Uniform location")}l(){super.l();const t=this.g;t.uniform1i(this.H,0),t.uniform1i(this.J,1),t.uniform1i(this.K,2)}close(){this.j&&this.g.deleteTexture(this.j),this.B&&this.g.deleteTexture(this.B),super.close()}};function Ht(t,e){switch(e){case 0:return t.g.find(n=>n instanceof Uint8Array);case 1:return t.g.find(n=>n instanceof Float32Array);case 2:return t.g.find(n=>typeof WebGLTexture<"u"&&n instanceof WebGLTexture);default:throw Error(`Type is not supported: ${e}`)}}function ja(t){var e=Ht(t,1);if(!e){if(e=Ht(t,0))e=new Float32Array(e).map(s=>s/255);else{e=new Float32Array(t.width*t.height);const s=vs(t);var n=Ul(t);if(To(n,s,Ig(t)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){n=new Float32Array(t.width*t.height*4),s.readPixels(0,0,t.width,t.height,s.RGBA,s.FLOAT,n);for(let r=0,i=0;r<e.length;++r,i+=4)e[r]=n[i]}else s.readPixels(0,0,t.width,t.height,s.RED,s.FLOAT,e)}t.g.push(e)}return e}function Ig(t){let e=Ht(t,2);if(!e){const n=vs(t);e=xg(t);const s=ja(t),r=Ng(t);n.texImage2D(n.TEXTURE_2D,0,r,t.width,t.height,0,n.RED,n.FLOAT,s),qa(t)}return e}function vs(t){if(!t.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return t.h||(t.h=Ue(t.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),t.h}function Ng(t){if(t=vs(t),!jr)if(t.getExtension("EXT_color_buffer_float")&&t.getExtension("OES_texture_float_linear")&&t.getExtension("EXT_float_blend"))jr=t.R32F;else{if(!t.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");jr=t.R16F}return jr}function Ul(t){return t.l||(t.l=new Ds),t.l}function xg(t){const e=vs(t);e.viewport(0,0,t.width,t.height),e.activeTexture(e.TEXTURE0);let n=Ht(t,2);return n||(n=mn(Ul(t),e,t.m?e.LINEAR:e.NEAREST),t.g.push(n),t.j=!0),e.bindTexture(e.TEXTURE_2D,n),n}function qa(t){t.h.bindTexture(t.h.TEXTURE_2D,null)}var jr,Ae=class{constructor(t,e,n,s,r,i,o){this.g=t,this.m=e,this.j=n,this.canvas=s,this.l=r,this.width=i,this.height=o,this.j&&--Fu===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Fa(){return!!Ht(this,0)}ja(){return!!Ht(this,1)}P(){return!!Ht(this,2)}ia(){return(e=Ht(t=this,0))||(e=ja(t),e=new Uint8Array(e.map(n=>255*n)),t.g.push(e)),e;var t,e}ha(){return ja(this)}M(){return Ig(this)}clone(){const t=[];for(const e of this.g){let n;if(e instanceof Uint8Array)n=new Uint8Array(e);else if(e instanceof Float32Array)n=new Float32Array(e);else{if(!(e instanceof WebGLTexture))throw Error(`Type is not supported: ${e}`);{const s=vs(this),r=Ul(this);s.activeTexture(s.TEXTURE1),n=mn(r,s,this.m?s.LINEAR:s.NEAREST),s.bindTexture(s.TEXTURE_2D,n);const i=Ng(this);s.texImage2D(s.TEXTURE_2D,0,i,this.width,this.height,0,s.RED,s.FLOAT,null),s.bindTexture(s.TEXTURE_2D,null),To(r,s,n),Pr(r,s,!1,()=>{xg(this),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.drawArrays(s.TRIANGLE_FAN,0,4),qa(this)}),Bl(r),qa(this)}}t.push(n)}return new Ae(t,this.m,this.P(),this.canvas,this.l,this.width,this.height)}close(){this.j&&vs(this).deleteTexture(Ht(this,2)),Fu=-1}};Ae.prototype.close=Ae.prototype.close,Ae.prototype.clone=Ae.prototype.clone,Ae.prototype.getAsWebGLTexture=Ae.prototype.M,Ae.prototype.getAsFloat32Array=Ae.prototype.ha,Ae.prototype.getAsUint8Array=Ae.prototype.ia,Ae.prototype.hasWebGLTexture=Ae.prototype.P,Ae.prototype.hasFloat32Array=Ae.prototype.ja,Ae.prototype.hasUint8Array=Ae.prototype.Fa;var Fu=250;const jE={color:"white",lineWidth:4,radius:6};function ia(t){return{...jE,fillColor:(t=t||{}).color,...t}}function Ut(t,e){return t instanceof Function?t(e):t}function Mu(t,e,n){return Math.max(Math.min(e,n),Math.min(Math.max(e,n),t))}function js(t){if(!t.l)throw Error("CPU rendering requested but CanvasRenderingContext2D not provided.");return t.l}function wr(t){if(!t.j)throw Error("GPU rendering requested but WebGL2RenderingContext not provided.");return t.j}function Bu(t,e,n){if(e.P())n(e.M());else{const s=e.ja()?e.ha():e.ia();t.m=t.m??new Ds;const r=wr(t);n((t=new Ae([s],e.m,!1,r.canvas,t.m,e.width,e.height)).M()),t.close()}}function Uu(t,e,n,s){const r=function(a){return a.g||(a.g=new WE),a.g}(t),i=wr(t),o=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n;Pr(r,i,!0,()=>{(function(c,l,h,u){const d=c.g;if(d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,l),d.activeTexture(d.TEXTURE1),d.bindTexture(d.TEXTURE_2D,c.B),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,h),c.H&&function(p,f){if(p!==f)return!1;p=p.entries(),f=f.entries();for(const[E,R]of p){p=E;const y=R;var g=f.next();if(g.done)return!1;const[S,D]=g.value;if(g=D,p!==S||y[0]!==g[0]||y[1]!==g[1]||y[2]!==g[2]||y[3]!==g[3])return!1}return!!f.next().done}(c.H,u))d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j);else{c.H=u;const p=Array(1024).fill(0);u.forEach((f,g)=>{if(f.length!==4)throw Error(`Color at index ${g} is not a four-channel value.`);p[4*g]=f[0],p[4*g+1]=f[1],p[4*g+2]=f[2],p[4*g+3]=f[3]}),d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,256,1,0,d.RGBA,d.UNSIGNED_BYTE,new Uint8Array(p))}})(r,e,o,s),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4);const a=r.g;a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,null),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,null),a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,null)})}function Vu(t,e,n,s){const r=wr(t),i=function(c){return c.h||(c.h=new $E),c.h}(t),o=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n,a=Array.isArray(s)?new ImageData(new Uint8ClampedArray(s),1,1):s;Pr(i,r,!0,()=>{var c=i.g;c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,e),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,i.j),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,o),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,i.B),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.drawArrays(r.TRIANGLE_FAN,0,4),r.bindTexture(r.TEXTURE_2D,null),(c=i.g).activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,null)})}var De=class{constructor(t,e){t instanceof CanvasRenderingContext2D||t instanceof OffscreenCanvasRenderingContext2D?(this.l=t,this.j=e):this.j=t}ya(t,e){if(t){var n=js(this);e=ia(e),n.save();var s=n.canvas,r=0;for(const i of t)n.fillStyle=Ut(e.fillColor,{index:r,from:i}),n.strokeStyle=Ut(e.color,{index:r,from:i}),n.lineWidth=Ut(e.lineWidth,{index:r,from:i}),(t=new Path2D).arc(i.x*s.width,i.y*s.height,Ut(e.radius,{index:r,from:i}),0,2*Math.PI),n.fill(t),n.stroke(t),++r;n.restore()}}xa(t,e,n){if(t&&e){var s=js(this);n=ia(n),s.save();var r=s.canvas,i=0;for(const o of e){s.beginPath(),e=t[o.start];const a=t[o.end];e&&a&&(s.strokeStyle=Ut(n.color,{index:i,from:e,to:a}),s.lineWidth=Ut(n.lineWidth,{index:i,from:e,to:a}),s.moveTo(e.x*r.width,e.y*r.height),s.lineTo(a.x*r.width,a.y*r.height)),++i,s.stroke()}s.restore()}}ua(t,e){const n=js(this);e=ia(e),n.save(),n.beginPath(),n.lineWidth=Ut(e.lineWidth,{}),n.strokeStyle=Ut(e.color,{}),n.fillStyle=Ut(e.fillColor,{}),n.moveTo(t.originX,t.originY),n.lineTo(t.originX+t.width,t.originY),n.lineTo(t.originX+t.width,t.originY+t.height),n.lineTo(t.originX,t.originY+t.height),n.lineTo(t.originX,t.originY),n.stroke(),n.fill(),n.restore()}va(t,e,n=[0,0,0,255]){this.l?function(s,r,i,o){const a=wr(s);Bu(s,r,c=>{Uu(s,c,i,o),(c=js(s)).drawImage(a.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,t,n,e):Uu(this,t.M(),n,e)}wa(t,e,n){this.l?function(s,r,i,o){const a=wr(s);Bu(s,r,c=>{Vu(s,c,i,o),(c=js(s)).drawImage(a.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,t,e,n):Vu(this,t.M(),e,n)}close(){var t,e,n;(t=this.g)==null||t.close(),this.g=void 0,(e=this.h)==null||e.close(),this.h=void 0,(n=this.m)==null||n.close(),this.m=void 0}};function Pt(t,e){switch(e){case 0:return t.g.find(n=>n instanceof ImageData);case 1:return t.g.find(n=>typeof ImageBitmap<"u"&&n instanceof ImageBitmap);case 2:return t.g.find(n=>typeof WebGLTexture<"u"&&n instanceof WebGLTexture);default:throw Error(`Type is not supported: ${e}`)}}function Og(t){var e=Pt(t,0);if(!e){e=ws(t);const n=Co(t),s=new Uint8Array(t.width*t.height*4);To(n,e,ni(t)),e.readPixels(0,0,t.width,t.height,e.RGBA,e.UNSIGNED_BYTE,s),Bl(n),e=new ImageData(new Uint8ClampedArray(s.buffer),t.width,t.height),t.g.push(e)}return e}function ni(t){let e=Pt(t,2);if(!e){const n=ws(t);e=si(t);const s=Pt(t,1)||Og(t);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,s),Xs(t)}return e}function ws(t){if(!t.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return t.h||(t.h=Ue(t.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),t.h}function Co(t){return t.l||(t.l=new Ds),t.l}function si(t){const e=ws(t);e.viewport(0,0,t.width,t.height),e.activeTexture(e.TEXTURE0);let n=Pt(t,2);return n||(n=mn(Co(t),e),t.g.push(n),t.m=!0),e.bindTexture(e.TEXTURE_2D,n),n}function Xs(t){t.h.bindTexture(t.h.TEXTURE_2D,null)}function Hu(t){const e=ws(t);return Pr(Co(t),e,!0,()=>function(n,s){const r=n.canvas;if(r.width===n.width&&r.height===n.height)return s();const i=r.width,o=r.height;return r.width=n.width,r.height=n.height,n=s(),r.width=i,r.height=o,n}(t,()=>{if(e.bindFramebuffer(e.FRAMEBUFFER,null),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),!(t.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return t.canvas.transferToImageBitmap()}))}De.prototype.close=De.prototype.close,De.prototype.drawConfidenceMask=De.prototype.wa,De.prototype.drawCategoryMask=De.prototype.va,De.prototype.drawBoundingBox=De.prototype.ua,De.prototype.drawConnectors=De.prototype.xa,De.prototype.drawLandmarks=De.prototype.ya,De.lerp=function(t,e,n,s,r){return Mu(s*(1-(t-e)/(n-e))+r*(1-(n-t)/(n-e)),s,r)},De.clamp=Mu;var Ie=class{constructor(t,e,n,s,r,i,o){this.g=t,this.j=e,this.m=n,this.canvas=s,this.l=r,this.width=i,this.height=o,(this.j||this.m)&&--Gu===0&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}Ea(){return!!Pt(this,0)}ka(){return!!Pt(this,1)}P(){return!!Pt(this,2)}Ca(){return Og(this)}Ba(){var t=Pt(this,1);return t||(ni(this),si(this),t=Hu(this),Xs(this),this.g.push(t),this.j=!0),t}M(){return ni(this)}clone(){const t=[];for(const e of this.g){let n;if(e instanceof ImageData)n=new ImageData(e.data,this.width,this.height);else if(e instanceof WebGLTexture){const s=ws(this),r=Co(this);s.activeTexture(s.TEXTURE1),n=mn(r,s),s.bindTexture(s.TEXTURE_2D,n),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,this.width,this.height,0,s.RGBA,s.UNSIGNED_BYTE,null),s.bindTexture(s.TEXTURE_2D,null),To(r,s,n),Pr(r,s,!1,()=>{si(this),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.drawArrays(s.TRIANGLE_FAN,0,4),Xs(this)}),Bl(r),Xs(this)}else{if(!(e instanceof ImageBitmap))throw Error(`Type is not supported: ${e}`);ni(this),si(this),n=Hu(this),Xs(this)}t.push(n)}return new Ie(t,this.ka(),this.P(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Pt(this,1).close(),this.m&&ws(this).deleteTexture(Pt(this,2)),Gu=-1}};Ie.prototype.close=Ie.prototype.close,Ie.prototype.clone=Ie.prototype.clone,Ie.prototype.getAsWebGLTexture=Ie.prototype.M,Ie.prototype.getAsImageBitmap=Ie.prototype.Ba,Ie.prototype.getAsImageData=Ie.prototype.Ca,Ie.prototype.hasWebGLTexture=Ie.prototype.P,Ie.prototype.hasImageBitmap=Ie.prototype.ka,Ie.prototype.hasImageData=Ie.prototype.Ea;var Gu=250;function Rt(...t){return t.map(([e,n])=>({start:e,end:n}))}const qE=function(t){return class extends t{La(){this.i._registerModelResourcesGraphService()}}}((Wu=class{constructor(t,e){this.l=!0,this.i=t,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",e!==void 0?this.i.canvas=e:Rg()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(t){const e=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(e),t)}setGraphFromString(t){this.setGraph(new TextEncoder().encode(t),!1)}setGraph(t,e){const n=t.length,s=this.i._malloc(n);this.i.HEAPU8.set(t,s),e?this.i._changeBinaryGraph(n,s):this.i._changeTextGraph(n,s),this.i._free(s)}configureAudio(t,e,n,s,r){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),x(this,s||"input_audio",i=>{x(this,r=r||"audio_header",o=>{this.i._configureAudio(i,o,t,e??0,n)})})}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.i._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.i.gpuOriginForWebTexturesIsBottomLeft=t}da(t){Nt(this,"__graph_config__",e=>{t(e)}),x(this,"__graph_config__",e=>{this.i._getGraphConfig(e,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(t){this.i.errorListener=t}attachEmptyPacketListener(t,e){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[t]=e}addAudioToStream(t,e,n){this.addAudioToStreamWithShape(t,0,0,e,n)}addAudioToStreamWithShape(t,e,n,s,r){const i=4*t.length;this.h!==i&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(i),this.h=i),this.i.HEAPF32.set(t,this.g/4),x(this,s,o=>{this.i._addAudioToInputStream(this.g,e,n,o,r)})}addGpuBufferToStream(t,e,n){x(this,e,s=>{const[r,i]=xu(this,t,s);this.i._addBoundTextureToStream(s,r,i,n)})}addBoolToStream(t,e,n){x(this,e,s=>{this.i._addBoolToInputStream(t,s,n)})}addDoubleToStream(t,e,n){x(this,e,s=>{this.i._addDoubleToInputStream(t,s,n)})}addFloatToStream(t,e,n){x(this,e,s=>{this.i._addFloatToInputStream(t,s,n)})}addIntToStream(t,e,n){x(this,e,s=>{this.i._addIntToInputStream(t,s,n)})}addUintToStream(t,e,n){x(this,e,s=>{this.i._addUintToInputStream(t,s,n)})}addStringToStream(t,e,n){x(this,e,s=>{x(this,t,r=>{this.i._addStringToInputStream(r,s,n)})})}addStringRecordToStream(t,e,n){x(this,e,s=>{Ou(this,Object.keys(t),r=>{Ou(this,Object.values(t),i=>{this.i._addFlatHashMapToInputStream(r,i,Object.keys(t).length,s,n)})})})}addProtoToStream(t,e,n,s){x(this,n,r=>{x(this,e,i=>{const o=this.i._malloc(t.length);this.i.HEAPU8.set(t,o),this.i._addProtoToInputStream(o,t.length,i,r,s),this.i._free(o)})})}addEmptyPacketToStream(t,e){x(this,t,n=>{this.i._addEmptyPacketToInputStream(n,e)})}addBoolVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(const i of t)this.i._addBoolVectorEntry(r,i);this.i._addBoolVectorToInputStream(r,s,n)})}addDoubleVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(const i of t)this.i._addDoubleVectorEntry(r,i);this.i._addDoubleVectorToInputStream(r,s,n)})}addFloatVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(const i of t)this.i._addFloatVectorEntry(r,i);this.i._addFloatVectorToInputStream(r,s,n)})}addIntVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(const i of t)this.i._addIntVectorEntry(r,i);this.i._addIntVectorToInputStream(r,s,n)})}addUintVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(const i of t)this.i._addUintVectorEntry(r,i);this.i._addUintVectorToInputStream(r,s,n)})}addStringVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(const i of t)x(this,i,o=>{this.i._addStringVectorEntry(r,o)});this.i._addStringVectorToInputStream(r,s,n)})}addBoolToInputSidePacket(t,e){x(this,e,n=>{this.i._addBoolToInputSidePacket(t,n)})}addDoubleToInputSidePacket(t,e){x(this,e,n=>{this.i._addDoubleToInputSidePacket(t,n)})}addFloatToInputSidePacket(t,e){x(this,e,n=>{this.i._addFloatToInputSidePacket(t,n)})}addIntToInputSidePacket(t,e){x(this,e,n=>{this.i._addIntToInputSidePacket(t,n)})}addUintToInputSidePacket(t,e){x(this,e,n=>{this.i._addUintToInputSidePacket(t,n)})}addStringToInputSidePacket(t,e){x(this,e,n=>{x(this,t,s=>{this.i._addStringToInputSidePacket(s,n)})})}addProtoToInputSidePacket(t,e,n){x(this,n,s=>{x(this,e,r=>{const i=this.i._malloc(t.length);this.i.HEAPU8.set(t,i),this.i._addProtoToInputSidePacket(i,t.length,r,s),this.i._free(i)})})}addBoolVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateBoolVector(t.length);if(!s)throw Error("Unable to allocate new bool vector on heap.");for(const r of t)this.i._addBoolVectorEntry(s,r);this.i._addBoolVectorToInputSidePacket(s,n)})}addDoubleVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateDoubleVector(t.length);if(!s)throw Error("Unable to allocate new double vector on heap.");for(const r of t)this.i._addDoubleVectorEntry(s,r);this.i._addDoubleVectorToInputSidePacket(s,n)})}addFloatVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateFloatVector(t.length);if(!s)throw Error("Unable to allocate new float vector on heap.");for(const r of t)this.i._addFloatVectorEntry(s,r);this.i._addFloatVectorToInputSidePacket(s,n)})}addIntVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateIntVector(t.length);if(!s)throw Error("Unable to allocate new int vector on heap.");for(const r of t)this.i._addIntVectorEntry(s,r);this.i._addIntVectorToInputSidePacket(s,n)})}addUintVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateUintVector(t.length);if(!s)throw Error("Unable to allocate new unsigned int vector on heap.");for(const r of t)this.i._addUintVectorEntry(s,r);this.i._addUintVectorToInputSidePacket(s,n)})}addStringVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateStringVector(t.length);if(!s)throw Error("Unable to allocate new string vector on heap.");for(const r of t)x(this,r,i=>{this.i._addStringVectorEntry(s,i)});this.i._addStringVectorToInputSidePacket(s,n)})}attachBoolListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachBoolListener(n)})}attachBoolVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachBoolVectorListener(n)})}attachIntListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachIntListener(n)})}attachIntVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachIntVectorListener(n)})}attachUintListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachUintListener(n)})}attachUintVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachUintVectorListener(n)})}attachDoubleListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachDoubleListener(n)})}attachDoubleVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachDoubleVectorListener(n)})}attachFloatListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachFloatListener(n)})}attachFloatVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachFloatVectorListener(n)})}attachStringListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachStringListener(n)})}attachStringVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachStringVectorListener(n)})}attachProtoListener(t,e,n){Nt(this,t,e),x(this,t,s=>{this.i._attachProtoListener(s,n||!1)})}attachProtoVectorListener(t,e,n){tn(this,t,e),x(this,t,s=>{this.i._attachProtoVectorListener(s,n||!1)})}attachAudioListener(t,e,n){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Nt(this,t,(s,r)=>{s=new Float32Array(s.buffer,s.byteOffset,s.length/4),e(s,r)}),x(this,t,s=>{this.i._attachAudioListener(s,n||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Wu{get ea(){return this.i}qa(t,e,n){x(this,e,s=>{const[r,i]=xu(this,t,s);this.ea._addBoundTextureAsImageToStream(s,r,i,n)})}U(t,e){Nt(this,t,e),x(this,t,n=>{this.ea._attachImageListener(n)})}ca(t,e){tn(this,t,e),x(this,t,n=>{this.ea._attachImageVectorListener(n)})}}));var Wu,_t=class extends qE{};async function $(t,e,n){return async function(s,r,i,o){return HE(s,r,i,o)}(t,n.canvas??(Rg()?void 0:document.createElement("canvas")),e,n)}function Lg(t,e,n,s){if(t.T){const i=new ng;if(n!=null&&n.regionOfInterest){if(!t.pa)throw Error("This task doesn't support region-of-interest.");var r=n.regionOfInterest;if(r.left>=r.right||r.top>=r.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(r.left<0||r.top<0||r.right>1||r.bottom>1)throw Error("Expected RectF values to be in [0,1].");N(i,1,(r.left+r.right)/2),N(i,2,(r.top+r.bottom)/2),N(i,4,r.right-r.left),N(i,3,r.bottom-r.top)}else N(i,1,.5),N(i,2,.5),N(i,4,1),N(i,3,1);if(n!=null&&n.rotationDegrees){if((n==null?void 0:n.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90°.");if(N(i,5,-Math.PI*n.rotationDegrees/180),(n==null?void 0:n.rotationDegrees)%180!=0){const[o,a]=kg(e);n=ve(i,3)*a/o,r=ve(i,4)*o/a,N(i,4,n),N(i,3,r)}}t.g.addProtoToStream(i.g(),"mediapipe.NormalizedRect",t.T,s)}t.g.qa(e,t.aa,s??performance.now()),t.finishProcessing()}function yt(t,e,n){var s;if((s=t.baseOptions)!=null&&s.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");Lg(t,e,n,t.B+1)}function Bt(t,e,n,s){var r;if(!((r=t.baseOptions)!=null&&r.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");Lg(t,e,n,s)}function bs(t,e,n,s){var r=e.data;const i=e.width,o=i*(e=e.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==o)throw Error("Unsupported channel count: "+r.length/o);return t=new Ae([r],n,!1,t.g.i.canvas,t.O,i,e),s?t.clone():t}var Ye=class extends ti{constructor(t,e,n,s){super(t),this.g=t,this.aa=e,this.T=n,this.pa=s,this.O=new Ds}l(t,e=!0){if("runningMode"in t&&Er(this.baseOptions,2,!!t.runningMode&&t.runningMode!=="IMAGE"),t.canvas!==void 0&&this.g.i.canvas!==t.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(t,e)}close(){this.O.close(),super.close()}};Ye.prototype.close=Ye.prototype.close;var ct=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect_in",!1),this.j={detections:[]},L(t=this.h=new Eo,0,1,e=new pe),N(this.h,2,.5),N(this.h,3,.3)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&N(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&N(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}D(t,e){return this.j={detections:[]},yt(this,t,e),this.j}F(t,e,n){return this.j={detections:[]},Bt(this,t,n,e),this.j}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect_in"),X(t,"detections");const e=new rt;Ct(e,RE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect_in"),z(n,"DETECTIONS:detections"),n.o(e),at(t,n),this.g.attachProtoVectorListener("detections",(s,r)=>{for(const i of s)s=Zm(i),this.j.detections.push(Sg(s));A(this,r)}),this.g.attachEmptyPacketListener("detections",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ct.prototype.detectForVideo=ct.prototype.F,ct.prototype.detect=ct.prototype.D,ct.prototype.setOptions=ct.prototype.o,ct.createFromModelPath=async function(t,e){return $(ct,t,{baseOptions:{modelAssetPath:e}})},ct.createFromModelBuffer=function(t,e){return $(ct,t,{baseOptions:{modelAssetBuffer:e}})},ct.createFromOptions=function(t,e){return $(ct,t,e)};var Vl=Rt([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),Hl=Rt([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),Gl=Rt([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Dg=Rt([474,475],[475,476],[476,477],[477,474]),Wl=Rt([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),$l=Rt([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Pg=Rt([469,470],[470,471],[471,472],[472,469]),jl=Rt([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),Fg=[...Vl,...Hl,...Gl,...Wl,...$l,...jl],Mg=Rt([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function $u(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var ne=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,L(t=this.h=new ag,0,1,e=new pe),this.v=new og,L(this.h,0,3,this.v),this.s=new Eo,L(this.h,0,2,this.s),Ft(this.s,4,1),N(this.s,2,.5),N(this.v,2,.5),N(this.h,4,.5)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return"numFaces"in t&&Ft(this.s,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&N(this.s,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&N(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&N(this.v,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in t&&(this.outputFacialTransformationMatrixes=!!t.outputFacialTransformationMatrixes),this.l(t)}D(t,e){return $u(this),yt(this,t,e),this.j}F(t,e,n){return $u(this),Bt(this,t,n,e),this.j}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"face_landmarks");const e=new rt;Ct(e,IE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"NORM_LANDMARKS:face_landmarks"),n.o(e),at(t,n),this.g.attachProtoVectorListener("face_landmarks",(s,r)=>{for(const i of s)s=Dr(i),this.j.faceLandmarks.push(vo(s));A(this,r)}),this.g.attachEmptyPacketListener("face_landmarks",s=>{A(this,s)}),this.outputFaceBlendshapes&&(X(t,"blendshapes"),z(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(s,r)=>{if(this.outputFaceBlendshapes)for(const i of s)s=yo(i),this.j.faceBlendshapes.push(Fl(s.g()??[]));A(this,r)}),this.g.attachEmptyPacketListener("blendshapes",s=>{A(this,s)})),this.outputFacialTransformationMatrixes&&(X(t,"face_geometry"),z(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(s,r)=>{if(this.outputFacialTransformationMatrixes)for(const i of s)(s=Y(kE(i),EE,2))&&this.j.facialTransformationMatrixes.push({rows:ft(s,1)??0??0,columns:ft(s,2)??0??0,data:kn(s,3,_n,Rn()).slice()??[]});A(this,r)}),this.g.attachEmptyPacketListener("face_geometry",s=>{A(this,s)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ne.prototype.detectForVideo=ne.prototype.F,ne.prototype.detect=ne.prototype.D,ne.prototype.setOptions=ne.prototype.o,ne.createFromModelPath=function(t,e){return $(ne,t,{baseOptions:{modelAssetPath:e}})},ne.createFromModelBuffer=function(t,e){return $(ne,t,{baseOptions:{modelAssetBuffer:e}})},ne.createFromOptions=function(t,e){return $(ne,t,e)},ne.FACE_LANDMARKS_LIPS=Vl,ne.FACE_LANDMARKS_LEFT_EYE=Hl,ne.FACE_LANDMARKS_LEFT_EYEBROW=Gl,ne.FACE_LANDMARKS_LEFT_IRIS=Dg,ne.FACE_LANDMARKS_RIGHT_EYE=Wl,ne.FACE_LANDMARKS_RIGHT_EYEBROW=$l,ne.FACE_LANDMARKS_RIGHT_IRIS=Pg,ne.FACE_LANDMARKS_FACE_OVAL=jl,ne.FACE_LANDMARKS_CONTOURS=Fg,ne.FACE_LANDMARKS_TESSELATION=Mg;var xt=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!0),L(t=this.j=new lg,0,1,e=new pe)}get baseOptions(){return Y(this.j,pe,1)}set baseOptions(t){L(this.j,0,1,t)}o(t){return super.l(t)}Oa(t,e,n){const s=typeof e!="function"?e:{};if(this.h=typeof e=="function"?e:n,yt(this,t,s??{}),!this.h)return this.s}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"stylized_image");const e=new rt;Ct(e,NE,this.j);const n=new Ve;ot(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"STYLIZED_IMAGE:stylized_image"),n.o(e),at(t,n),this.g.U("stylized_image",(s,r)=>{var i=!this.h,o=s.data,a=s.width;const c=a*(s=s.height);if(o instanceof Uint8Array)if(o.length===3*c){const l=new Uint8ClampedArray(4*c);for(let h=0;h<c;++h)l[4*h]=o[3*h],l[4*h+1]=o[3*h+1],l[4*h+2]=o[3*h+2],l[4*h+3]=255;o=new ImageData(l,a,s)}else{if(o.length!==4*c)throw Error("Unsupported channel count: "+o.length/c);o=new ImageData(new Uint8ClampedArray(o.buffer,o.byteOffset,o.length),a,s)}else if(!(o instanceof WebGLTexture))throw Error(`Unsupported format: ${o.constructor.name}`);a=new Ie([o],!1,!1,this.g.i.canvas,this.O,a,s),this.s=i=i?a.clone():a,this.h&&this.h(i),A(this,r)}),this.g.attachEmptyPacketListener("stylized_image",s=>{this.s=null,this.h&&this.h(null),A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};xt.prototype.stylize=xt.prototype.Oa,xt.prototype.setOptions=xt.prototype.o,xt.createFromModelPath=function(t,e){return $(xt,t,{baseOptions:{modelAssetPath:e}})},xt.createFromModelBuffer=function(t,e){return $(xt,t,{baseOptions:{modelAssetBuffer:e}})},xt.createFromOptions=function(t,e){return $(xt,t,e)};var ql=Rt([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function ju(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function qu(t){return t.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:t.gestures,landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handedness:t.handedness,handednesses:t.handedness}}function zu(t,e=!0){const n=[];for(const r of t){var s=yo(r);t=[];for(const i of s.g())s=e&&ft(i,1)!=null?ft(i,1)??0:-1,t.push({score:ve(i,2)??0,index:s,categoryName:mt(i,3)??""??"",displayName:mt(i,4)??""??""});n.push(t)}return n}var Qe=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],L(t=this.j=new dg,0,1,e=new pe),this.s=new Ol,L(this.j,0,2,this.s),this.C=new xl,L(this.s,0,3,this.C),this.v=new ug,L(this.s,0,2,this.v),this.h=new xE,L(this.j,0,3,this.h),N(this.v,2,.5),N(this.s,4,.5),N(this.C,2,.5)}get baseOptions(){return Y(this.j,pe,1)}set baseOptions(t){L(this.j,0,1,t)}o(t){var r,i,o,a;if(Ft(this.v,3,t.numHands??1),"minHandDetectionConfidence"in t&&N(this.v,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&N(this.s,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&N(this.C,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var e=new Wn,n=e,s=$a(t.cannedGesturesClassifierOptions,(r=Y(this.h,Wn,3))==null?void 0:r.h());L(n,0,2,s),L(this.h,0,3,e)}else t.cannedGesturesClassifierOptions===void 0&&((i=Y(this.h,Wn,3))==null||i.g());return t.customGesturesClassifierOptions?(L(n=e=new Wn,0,2,s=$a(t.customGesturesClassifierOptions,(o=Y(this.h,Wn,4))==null?void 0:o.h())),L(this.h,0,4,e)):t.customGesturesClassifierOptions===void 0&&((a=Y(this.h,Wn,4))==null||a.g()),this.l(t)}Ja(t,e){return ju(this),yt(this,t,e),qu(this)}Ka(t,e,n){return ju(this),Bt(this,t,n,e),qu(this)}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"hand_gestures"),X(t,"hand_landmarks"),X(t,"world_hand_landmarks"),X(t,"handedness");const e=new rt;Ct(e,OE,this.j);const n=new Ve;ot(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"HAND_GESTURES:hand_gestures"),z(n,"LANDMARKS:hand_landmarks"),z(n,"WORLD_LANDMARKS:world_hand_landmarks"),z(n,"HANDEDNESS:handedness"),n.o(e),at(t,n),this.g.attachProtoVectorListener("hand_landmarks",(s,r)=>{for(const i of s){s=Dr(i);const o=[];for(const a of Yt(s,tg,1))o.push({x:ve(a,1)??0,y:ve(a,2)??0,z:ve(a,3)??0,visibility:ve(a,4)??0});this.landmarks.push(o)}A(this,r)}),this.g.attachEmptyPacketListener("hand_landmarks",s=>{A(this,s)}),this.g.attachProtoVectorListener("world_hand_landmarks",(s,r)=>{for(const i of s){s=as(i);const o=[];for(const a of Yt(s,eg,1))o.push({x:ve(a,1)??0,y:ve(a,2)??0,z:ve(a,3)??0,visibility:ve(a,4)??0});this.worldLandmarks.push(o)}A(this,r)}),this.g.attachEmptyPacketListener("world_hand_landmarks",s=>{A(this,s)}),this.g.attachProtoVectorListener("hand_gestures",(s,r)=>{this.gestures.push(...zu(s,!1)),A(this,r)}),this.g.attachEmptyPacketListener("hand_gestures",s=>{A(this,s)}),this.g.attachProtoVectorListener("handedness",(s,r)=>{this.handedness.push(...zu(s)),A(this,r)}),this.g.attachEmptyPacketListener("handedness",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function Ku(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Qe.prototype.recognizeForVideo=Qe.prototype.Ka,Qe.prototype.recognize=Qe.prototype.Ja,Qe.prototype.setOptions=Qe.prototype.o,Qe.createFromModelPath=function(t,e){return $(Qe,t,{baseOptions:{modelAssetPath:e}})},Qe.createFromModelBuffer=function(t,e){return $(Qe,t,{baseOptions:{modelAssetBuffer:e}})},Qe.createFromOptions=function(t,e){return $(Qe,t,e)},Qe.HAND_CONNECTIONS=ql;var Ze=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],L(t=this.h=new Ol,0,1,e=new pe),this.s=new xl,L(this.h,0,3,this.s),this.j=new ug,L(this.h,0,2,this.j),Ft(this.j,3,1),N(this.j,2,.5),N(this.s,2,.5),N(this.h,4,.5)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return"numHands"in t&&Ft(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&N(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&N(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&N(this.s,2,t.minHandPresenceConfidence??.5),this.l(t)}D(t,e){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],yt(this,t,e),Ku(this)}F(t,e,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Bt(this,t,n,e),Ku(this)}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"hand_landmarks"),X(t,"world_hand_landmarks"),X(t,"handedness");const e=new rt;Ct(e,LE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"LANDMARKS:hand_landmarks"),z(n,"WORLD_LANDMARKS:world_hand_landmarks"),z(n,"HANDEDNESS:handedness"),n.o(e),at(t,n),this.g.attachProtoVectorListener("hand_landmarks",(s,r)=>{for(const i of s)s=Dr(i),this.landmarks.push(vo(s));A(this,r)}),this.g.attachEmptyPacketListener("hand_landmarks",s=>{A(this,s)}),this.g.attachProtoVectorListener("world_hand_landmarks",(s,r)=>{for(const i of s)s=as(i),this.worldLandmarks.push(ir(s));A(this,r)}),this.g.attachEmptyPacketListener("world_hand_landmarks",s=>{A(this,s)}),this.g.attachProtoVectorListener("handedness",(s,r)=>{var i=this.handedness,o=i.push;const a=[];for(const c of s){s=yo(c);const l=[];for(const h of s.g())l.push({score:ve(h,2)??0,index:ft(h,1)??0??-1,categoryName:mt(h,3)??""??"",displayName:mt(h,4)??""??""});a.push(l)}o.call(i,...a),A(this,r)}),this.g.attachEmptyPacketListener("handedness",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ze.prototype.detectForVideo=Ze.prototype.F,Ze.prototype.detect=Ze.prototype.D,Ze.prototype.setOptions=Ze.prototype.o,Ze.createFromModelPath=function(t,e){return $(Ze,t,{baseOptions:{modelAssetPath:e}})},Ze.createFromModelBuffer=function(t,e){return $(Ze,t,{baseOptions:{modelAssetBuffer:e}})},Ze.createFromOptions=function(t,e){return $(Ze,t,e)},Ze.HAND_CONNECTIONS=ql;var Bg=Rt([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function Yu(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function Xu(t){try{if(!t.C)return t.h;t.C(t.h)}finally{bo(t)}}function qr(t,e){t=Dr(t),e.push(vo(t))}var de=class extends Ye{constructor(t,e){super(new _t(t,e),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,L(t=this.j=new _g,0,1,e=new pe),this.J=new xl,L(this.j,0,2,this.J),this.Z=new DE,L(this.j,0,3,this.Z),this.s=new Eo,L(this.j,0,4,this.s),this.H=new og,L(this.j,0,5,this.H),this.v=new mg,L(this.j,0,6,this.v),this.K=new gg,L(this.j,0,7,this.K),N(this.s,2,.5),N(this.s,3,.3),N(this.H,2,.5),N(this.v,2,.5),N(this.v,3,.3),N(this.K,2,.5),N(this.J,2,.5)}get baseOptions(){return Y(this.j,pe,1)}set baseOptions(t){L(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&N(this.s,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&N(this.s,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&N(this.H,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&N(this.v,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&N(this.v,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&N(this.K,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&N(this.J,2,t.minHandLandmarksConfidence??.5),this.l(t)}D(t,e,n){const s=typeof e!="function"?e:{};return this.C=typeof e=="function"?e:n,Yu(this),yt(this,t,s),Xu(this)}F(t,e,n,s){const r=typeof n!="function"?n:{};return this.C=typeof n=="function"?n:s,Yu(this),Bt(this,t,r,e),Xu(this)}m(){var t=new Xe;ue(t,"input_frames_image"),X(t,"pose_landmarks"),X(t,"pose_world_landmarks"),X(t,"face_landmarks"),X(t,"left_hand_landmarks"),X(t,"left_hand_world_landmarks"),X(t,"right_hand_landmarks"),X(t,"right_hand_world_landmarks");const e=new rt,n=new mu;Ba(n,1,ks("type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),""),function(r,i){if(i!=null)if(Array.isArray(i))ae(r,2,um(i));else{if(!(typeof i=="string"||i instanceof jt||Nr(i)))throw Error("invalid value in Any.value field: "+i+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");Ba(r,2,Yc(i,!1),Mn())}}(n,this.j.g());const s=new Ve;ot(s,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),Di(s,8,mu,n),ce(s,"IMAGE:input_frames_image"),z(s,"POSE_LANDMARKS:pose_landmarks"),z(s,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),z(s,"FACE_LANDMARKS:face_landmarks"),z(s,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),z(s,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),z(s,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),z(s,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),s.o(e),at(t,s),wo(this,t),this.g.attachProtoListener("pose_landmarks",(r,i)=>{qr(r,this.h.poseLandmarks),A(this,i)}),this.g.attachEmptyPacketListener("pose_landmarks",r=>{A(this,r)}),this.g.attachProtoListener("pose_world_landmarks",(r,i)=>{var o=this.h.poseWorldLandmarks;r=as(r),o.push(ir(r)),A(this,i)}),this.g.attachEmptyPacketListener("pose_world_landmarks",r=>{A(this,r)}),this.outputPoseSegmentationMasks&&(z(s,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Es(this,"pose_segmentation_mask"),this.g.U("pose_segmentation_mask",(r,i)=>{this.h.poseSegmentationMasks=[bs(this,r,!0,!this.C)],A(this,i)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",r=>{this.h.poseSegmentationMasks=[],A(this,r)})),this.g.attachProtoListener("face_landmarks",(r,i)=>{qr(r,this.h.faceLandmarks),A(this,i)}),this.g.attachEmptyPacketListener("face_landmarks",r=>{A(this,r)}),this.outputFaceBlendshapes&&(X(t,"extra_blendshapes"),z(s,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(r,i)=>{var o=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(r=yo(r),o.push(Fl(r.g()??[]))),A(this,i)}),this.g.attachEmptyPacketListener("extra_blendshapes",r=>{A(this,r)})),this.g.attachProtoListener("left_hand_landmarks",(r,i)=>{qr(r,this.h.leftHandLandmarks),A(this,i)}),this.g.attachEmptyPacketListener("left_hand_landmarks",r=>{A(this,r)}),this.g.attachProtoListener("left_hand_world_landmarks",(r,i)=>{var o=this.h.leftHandWorldLandmarks;r=as(r),o.push(ir(r)),A(this,i)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",r=>{A(this,r)}),this.g.attachProtoListener("right_hand_landmarks",(r,i)=>{qr(r,this.h.rightHandLandmarks),A(this,i)}),this.g.attachEmptyPacketListener("right_hand_landmarks",r=>{A(this,r)}),this.g.attachProtoListener("right_hand_world_landmarks",(r,i)=>{var o=this.h.rightHandWorldLandmarks;r=as(r),o.push(ir(r)),A(this,i)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",r=>{A(this,r)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};de.prototype.detectForVideo=de.prototype.F,de.prototype.detect=de.prototype.D,de.prototype.setOptions=de.prototype.o,de.createFromModelPath=function(t,e){return $(de,t,{baseOptions:{modelAssetPath:e}})},de.createFromModelBuffer=function(t,e){return $(de,t,{baseOptions:{modelAssetBuffer:e}})},de.createFromOptions=function(t,e){return $(de,t,e)},de.HAND_CONNECTIONS=ql,de.POSE_CONNECTIONS=Bg,de.FACE_LANDMARKS_LIPS=Vl,de.FACE_LANDMARKS_LEFT_EYE=Hl,de.FACE_LANDMARKS_LEFT_EYEBROW=Gl,de.FACE_LANDMARKS_LEFT_IRIS=Dg,de.FACE_LANDMARKS_RIGHT_EYE=Wl,de.FACE_LANDMARKS_RIGHT_EYEBROW=$l,de.FACE_LANDMARKS_RIGHT_IRIS=Pg,de.FACE_LANDMARKS_FACE_OVAL=jl,de.FACE_LANDMARKS_CONTOURS=Fg,de.FACE_LANDMARKS_TESSELATION=Mg;var lt=class extends Ye{constructor(t,e){super(new _t(t,e),"input_image","norm_rect",!0),this.j={classifications:[]},L(t=this.h=new yg,0,1,e=new pe)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return L(this.h,0,2,$a(t,Y(this.h,kl,2))),this.l(t)}sa(t,e){return this.j={classifications:[]},yt(this,t,e),this.j}ta(t,e,n){return this.j={classifications:[]},Bt(this,t,n,e),this.j}m(){var t=new Xe;ue(t,"input_image"),ue(t,"norm_rect"),X(t,"classifications");const e=new rt;Ct(e,PE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),ce(n,"IMAGE:input_image"),ce(n,"NORM_RECT:norm_rect"),z(n,"CLASSIFICATIONS:classifications"),n.o(e),at(t,n),this.g.attachProtoListener("classifications",(s,r)=>{this.j=function(i){const o={classifications:Yt(i,wE,1).map(a=>{var c;return Fl(((c=Y(a,Jm,4))==null?void 0:c.g())??[],ft(a,2)??0,mt(a,3)??"")})};return Li(_s(i,2))!=null&&(o.timestampMs=Li(_s(i,2))??0),o}(bE(s)),A(this,r)}),this.g.attachEmptyPacketListener("classifications",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};lt.prototype.classifyForVideo=lt.prototype.ta,lt.prototype.classify=lt.prototype.sa,lt.prototype.setOptions=lt.prototype.o,lt.createFromModelPath=function(t,e){return $(lt,t,{baseOptions:{modelAssetPath:e}})},lt.createFromModelBuffer=function(t,e){return $(lt,t,{baseOptions:{modelAssetBuffer:e}})},lt.createFromOptions=function(t,e){return $(lt,t,e)};var et=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!0),this.h=new Eg,this.embeddings={embeddings:[]},L(t=this.h,0,1,e=new pe)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){var e=this.h,n=Y(this.h,Cu,2);return n=n?n.clone():new Cu,t.l2Normalize!==void 0?Er(n,1,t.l2Normalize):"l2Normalize"in t&&ae(n,1),t.quantize!==void 0?Er(n,2,t.quantize):"quantize"in t&&ae(n,2),L(e,0,2,n),this.l(t)}za(t,e){return yt(this,t,e),this.embeddings}Aa(t,e,n){return Bt(this,t,n,e),this.embeddings}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"embeddings_out");const e=new rt;Ct(e,FE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"EMBEDDINGS:embeddings_out"),n.o(e),at(t,n),this.g.attachProtoListener("embeddings_out",(s,r)=>{s=SE(s),this.embeddings=function(i){return{embeddings:Yt(i,CE,1).map(o=>{var c,l;const a={headIndex:ft(o,3)??0??-1,headName:mt(o,4)??""??""};if(gm(o,Tu,Zo(o,1))!==void 0)o=kn(o=Y(o,Tu,Zo(o,1)),1,_n,Rn()),a.floatEmbedding=o.slice();else{const h=new Uint8Array(0);a.quantizedEmbedding=((l=(c=Y(o,TE,Zo(o,2)))==null?void 0:c.oa())==null?void 0:l.h())??h}return a}),timestampMs:Li(_s(i,2))??0}}(s),A(this,r)}),this.g.attachEmptyPacketListener("embeddings_out",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};et.cosineSimilarity=function(t,e){if(t.floatEmbedding&&e.floatEmbedding)t=Iu(t.floatEmbedding,e.floatEmbedding);else{if(!t.quantizedEmbedding||!e.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=Iu(ku(t.quantizedEmbedding),ku(e.quantizedEmbedding))}return t},et.prototype.embedForVideo=et.prototype.Aa,et.prototype.embed=et.prototype.za,et.prototype.setOptions=et.prototype.o,et.createFromModelPath=function(t,e){return $(et,t,{baseOptions:{modelAssetPath:e}})},et.createFromModelBuffer=function(t,e){return $(et,t,{baseOptions:{modelAssetBuffer:e}})},et.createFromOptions=function(t,e){return $(et,t,e)};var za=class{constructor(t,e,n){this.confidenceMasks=t,this.categoryMask=e,this.qualityScores=n}close(){var t,e;(t=this.confidenceMasks)==null||t.forEach(n=>{n.close()}),(e=this.categoryMask)==null||e.close()}};function Ju(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function Qu(t){try{const e=new za(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return e;t.j(e)}finally{bo(t)}}za.prototype.close=za.prototype.close;var We=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Pl,this.v=new vg,L(this.h,0,3,this.v),L(t=this.h,0,1,e=new pe)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?ae(this.h,2,ks(t.displayNamesLocale)):"displayNamesLocale"in t&&ae(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}I(){(function(t){var n,s;const e=Yt(t.da(),Ve,1).filter(r=>(mt(r,1)??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(t.s=[],e.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");e.length===1&&(((s=(n=Y(e[0],rt,7))==null?void 0:n.l())==null?void 0:s.g())??new Map).forEach((r,i)=>{t.s[Number(i)]=mt(r,1)??""})})(this)}segment(t,e,n){const s=typeof e!="function"?e:{};return this.j=typeof e=="function"?e:n,Ju(this),yt(this,t,s),Qu(this)}Ma(t,e,n,s){const r=typeof n!="function"?n:{};return this.j=typeof n=="function"?n:s,Ju(this),Bt(this,t,r,e),Qu(this)}Da(){return this.s}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect");const e=new rt;Ct(e,bg,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),n.o(e),at(t,n),wo(this,t),this.outputConfidenceMasks&&(X(t,"confidence_masks"),z(n,"CONFIDENCE_MASKS:confidence_masks"),Es(this,"confidence_masks"),this.g.ca("confidence_masks",(s,r)=>{this.confidenceMasks=s.map(i=>bs(this,i,!0,!this.j)),A(this,r)}),this.g.attachEmptyPacketListener("confidence_masks",s=>{this.confidenceMasks=[],A(this,s)})),this.outputCategoryMask&&(X(t,"category_mask"),z(n,"CATEGORY_MASK:category_mask"),Es(this,"category_mask"),this.g.U("category_mask",(s,r)=>{this.categoryMask=bs(this,s,!1,!this.j),A(this,r)}),this.g.attachEmptyPacketListener("category_mask",s=>{this.categoryMask=void 0,A(this,s)})),X(t,"quality_scores"),z(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(s,r)=>{this.qualityScores=s,A(this,r)}),this.g.attachEmptyPacketListener("quality_scores",s=>{this.categoryMask=void 0,A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};We.prototype.getLabels=We.prototype.Da,We.prototype.segmentForVideo=We.prototype.Ma,We.prototype.segment=We.prototype.segment,We.prototype.setOptions=We.prototype.o,We.createFromModelPath=function(t,e){return $(We,t,{baseOptions:{modelAssetPath:e}})},We.createFromModelBuffer=function(t,e){return $(We,t,{baseOptions:{modelAssetBuffer:e}})},We.createFromOptions=function(t,e){return $(We,t,e)};var Ka=class{constructor(t,e,n){this.confidenceMasks=t,this.categoryMask=e,this.qualityScores=n}close(){var t,e;(t=this.confidenceMasks)==null||t.forEach(n=>{n.close()}),(e=this.categoryMask)==null||e.close()}};Ka.prototype.close=Ka.prototype.close;var zE=class extends k{constructor(t){super(t)}},$n=[0,Ee,-2],Bi=[0,Vt,-3,fe,Vt,-1],Zu=[0,Bi],ed=[0,Bi,Ee,-1],oa=class extends k{constructor(t){super(t)}},td=[0,Vt,-1,fe],KE=class extends k{constructor(t){super(t)}},nd=class extends k{constructor(t){super(t)}},Ya=[1,2,3,4,5,6,7,8,9,10,14,15],Ug=class extends k{constructor(t){super(t)}};Ug.prototype.g=_o([0,Re,[0,Ya,ee,Bi,ee,[0,Bi,$n],ee,Zu,ee,[0,Zu,$n],ee,td,ee,[0,Vt,-3,fe,gt],ee,[0,Vt,-3,fe],ee,[0,Q,Vt,-2,fe,Ee,fe,-1,2,Vt,$n],ee,ed,ee,[0,ed,$n],Vt,$n,Q,ee,[0,Vt,-3,fe,$n,-1],ee,[0,Re,td]],Q,[0,Q,Ee,-1,fe]]);var Ot=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Pl,this.s=new vg,L(this.h,0,3,this.s),L(t=this.h,0,1,e=new pe)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}segment(t,e,n,s){const r=typeof n!="function"?n:{};this.j=typeof n=="function"?n:s,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.B+1,s=new Ug;const i=new nd;var o=new zE;if(Ft(o,1,255),L(i,0,12,o),e.keypoint&&e.scribble)throw Error("Cannot provide both keypoint and scribble.");if(e.keypoint){var a=new oa;Er(a,3,!0),N(a,1,e.keypoint.x),N(a,2,e.keypoint.y),sr(i,5,Ya,a)}else{if(!e.scribble)throw Error("Must provide either a keypoint or a scribble.");for(a of(o=new KE,e.scribble))Er(e=new oa,3,!0),N(e,1,a.x),N(e,2,a.y),Di(o,1,oa,e);sr(i,15,Ya,o)}Di(s,1,nd,i),this.g.addProtoToStream(s.g(),"drishti.RenderData","roi_in",n),yt(this,t,r);e:{try{const l=new Ka(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var c=l;break e}this.j(l)}finally{bo(this)}c=void 0}return c}m(){var t=new Xe;ue(t,"image_in"),ue(t,"roi_in"),ue(t,"norm_rect_in");const e=new rt;Ct(e,bg,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),ce(n,"IMAGE:image_in"),ce(n,"ROI:roi_in"),ce(n,"NORM_RECT:norm_rect_in"),n.o(e),at(t,n),wo(this,t),this.outputConfidenceMasks&&(X(t,"confidence_masks"),z(n,"CONFIDENCE_MASKS:confidence_masks"),Es(this,"confidence_masks"),this.g.ca("confidence_masks",(s,r)=>{this.confidenceMasks=s.map(i=>bs(this,i,!0,!this.j)),A(this,r)}),this.g.attachEmptyPacketListener("confidence_masks",s=>{this.confidenceMasks=[],A(this,s)})),this.outputCategoryMask&&(X(t,"category_mask"),z(n,"CATEGORY_MASK:category_mask"),Es(this,"category_mask"),this.g.U("category_mask",(s,r)=>{this.categoryMask=bs(this,s,!1,!this.j),A(this,r)}),this.g.attachEmptyPacketListener("category_mask",s=>{this.categoryMask=void 0,A(this,s)})),X(t,"quality_scores"),z(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(s,r)=>{this.qualityScores=s,A(this,r)}),this.g.attachEmptyPacketListener("quality_scores",s=>{this.categoryMask=void 0,A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ot.prototype.segment=Ot.prototype.segment,Ot.prototype.setOptions=Ot.prototype.o,Ot.createFromModelPath=function(t,e){return $(Ot,t,{baseOptions:{modelAssetPath:e}})},Ot.createFromModelBuffer=function(t,e){return $(Ot,t,{baseOptions:{modelAssetBuffer:e}})},Ot.createFromOptions=function(t,e){return $(Ot,t,e)};var ht=class extends Ye{constructor(t,e){super(new _t(t,e),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},L(t=this.h=new Tg,0,1,e=new pe)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?ae(this.h,2,ks(t.displayNamesLocale)):"displayNamesLocale"in t&&ae(this.h,2),t.maxResults!==void 0?Ft(this.h,3,t.maxResults):"maxResults"in t&&ae(this.h,3),t.scoreThreshold!==void 0?N(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&ae(this.h,4),t.categoryAllowlist!==void 0?Pi(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&ae(this.h,5),t.categoryDenylist!==void 0?Pi(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&ae(this.h,6),this.l(t)}D(t,e){return this.j={detections:[]},yt(this,t,e),this.j}F(t,e,n){return this.j={detections:[]},Bt(this,t,n,e),this.j}m(){var t=new Xe;ue(t,"input_frame_gpu"),ue(t,"norm_rect"),X(t,"detections");const e=new rt;Ct(e,BE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),ce(n,"IMAGE:input_frame_gpu"),ce(n,"NORM_RECT:norm_rect"),z(n,"DETECTIONS:detections"),n.o(e),at(t,n),this.g.attachProtoVectorListener("detections",(s,r)=>{for(const i of s)s=Zm(i),this.j.detections.push(Sg(s));A(this,r)}),this.g.attachEmptyPacketListener("detections",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ht.prototype.detectForVideo=ht.prototype.F,ht.prototype.detect=ht.prototype.D,ht.prototype.setOptions=ht.prototype.o,ht.createFromModelPath=async function(t,e){return $(ht,t,{baseOptions:{modelAssetPath:e}})},ht.createFromModelBuffer=function(t,e){return $(ht,t,{baseOptions:{modelAssetBuffer:e}})},ht.createFromOptions=function(t,e){return $(ht,t,e)};var Xa=class{constructor(t,e,n){this.landmarks=t,this.worldLandmarks=e,this.segmentationMasks=n}close(){var t;(t=this.segmentationMasks)==null||t.forEach(e=>{e.close()})}};function sd(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function rd(t){try{const e=new Xa(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.s)return e;t.s(e)}finally{bo(t)}}Xa.prototype.close=Xa.prototype.close;var tt=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,L(t=this.h=new Cg,0,1,e=new pe),this.v=new gg,L(this.h,0,3,this.v),this.j=new mg,L(this.h,0,2,this.j),Ft(this.j,4,1),N(this.j,2,.5),N(this.v,2,.5),N(this.h,4,.5)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return"numPoses"in t&&Ft(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&N(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&N(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&N(this.v,2,t.minPosePresenceConfidence??.5),"outputSegmentationMasks"in t&&(this.outputSegmentationMasks=t.outputSegmentationMasks??!1),this.l(t)}D(t,e,n){const s=typeof e!="function"?e:{};return this.s=typeof e=="function"?e:n,sd(this),yt(this,t,s),rd(this)}F(t,e,n,s){const r=typeof n!="function"?n:{};return this.s=typeof n=="function"?n:s,sd(this),Bt(this,t,r,e),rd(this)}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"normalized_landmarks"),X(t,"world_landmarks"),X(t,"segmentation_masks");const e=new rt;Ct(e,UE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"NORM_LANDMARKS:normalized_landmarks"),z(n,"WORLD_LANDMARKS:world_landmarks"),n.o(e),at(t,n),wo(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(s,r)=>{this.landmarks=[];for(const i of s)s=Dr(i),this.landmarks.push(vo(s));A(this,r)}),this.g.attachEmptyPacketListener("normalized_landmarks",s=>{this.landmarks=[],A(this,s)}),this.g.attachProtoVectorListener("world_landmarks",(s,r)=>{this.worldLandmarks=[];for(const i of s)s=as(i),this.worldLandmarks.push(ir(s));A(this,r)}),this.g.attachEmptyPacketListener("world_landmarks",s=>{this.worldLandmarks=[],A(this,s)}),this.outputSegmentationMasks&&(z(n,"SEGMENTATION_MASK:segmentation_masks"),Es(this,"segmentation_masks"),this.g.ca("segmentation_masks",(s,r)=>{this.segmentationMasks=s.map(i=>bs(this,i,!0,!this.s)),A(this,r)}),this.g.attachEmptyPacketListener("segmentation_masks",s=>{this.segmentationMasks=[],A(this,s)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};tt.prototype.detectForVideo=tt.prototype.F,tt.prototype.detect=tt.prototype.D,tt.prototype.setOptions=tt.prototype.o,tt.createFromModelPath=function(t,e){return $(tt,t,{baseOptions:{modelAssetPath:e}})},tt.createFromModelBuffer=function(t,e){return $(tt,t,{baseOptions:{modelAssetBuffer:e}})},tt.createFromOptions=function(t,e){return $(tt,t,e)},tt.POSE_CONNECTIONS=Bg;function YE(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function XE(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function s(){return this instanceof s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(s){var r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:function(){return t[s]}})}),n}const JE={},QE=Object.freeze(Object.defineProperty({__proto__:null,default:JE},Symbol.toStringTag,{value:"Module"})),Jn=XE(QE);var Lt={exports:{}};const ZE="16.6.1",e4={version:ZE};var id;function t4(){if(id)return Lt.exports;id=1;const t=Jn,e=Jn,n=Jn,s=Jn,i=e4.version,o=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function a(_){const I={};let P=_.toString();P=P.replace(/\r\n?/mg,`
1634
+ `}C(){const t=this.g;t.activeTexture(t.TEXTURE1),this.j=mn(this,t),t.activeTexture(t.TEXTURE2),this.B=mn(this,t)}m(){super.m();const t=this.g;this.J=Ue(t.getUniformLocation(this.h,"defaultTexture"),"Uniform location"),this.K=Ue(t.getUniformLocation(this.h,"overlayTexture"),"Uniform location"),this.H=Ue(t.getUniformLocation(this.h,"maskTexture"),"Uniform location")}l(){super.l();const t=this.g;t.uniform1i(this.H,0),t.uniform1i(this.J,1),t.uniform1i(this.K,2)}close(){this.j&&this.g.deleteTexture(this.j),this.B&&this.g.deleteTexture(this.B),super.close()}};function Ht(t,e){switch(e){case 0:return t.g.find(n=>n instanceof Uint8Array);case 1:return t.g.find(n=>n instanceof Float32Array);case 2:return t.g.find(n=>typeof WebGLTexture<"u"&&n instanceof WebGLTexture);default:throw Error(`Type is not supported: ${e}`)}}function ja(t){var e=Ht(t,1);if(!e){if(e=Ht(t,0))e=new Float32Array(e).map(s=>s/255);else{e=new Float32Array(t.width*t.height);const s=vs(t);var n=Ul(t);if(To(n,s,Ig(t)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){n=new Float32Array(t.width*t.height*4),s.readPixels(0,0,t.width,t.height,s.RGBA,s.FLOAT,n);for(let r=0,i=0;r<e.length;++r,i+=4)e[r]=n[i]}else s.readPixels(0,0,t.width,t.height,s.RED,s.FLOAT,e)}t.g.push(e)}return e}function Ig(t){let e=Ht(t,2);if(!e){const n=vs(t);e=xg(t);const s=ja(t),r=Ng(t);n.texImage2D(n.TEXTURE_2D,0,r,t.width,t.height,0,n.RED,n.FLOAT,s),qa(t)}return e}function vs(t){if(!t.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return t.h||(t.h=Ue(t.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),t.h}function Ng(t){if(t=vs(t),!jr)if(t.getExtension("EXT_color_buffer_float")&&t.getExtension("OES_texture_float_linear")&&t.getExtension("EXT_float_blend"))jr=t.R32F;else{if(!t.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");jr=t.R16F}return jr}function Ul(t){return t.l||(t.l=new Ds),t.l}function xg(t){const e=vs(t);e.viewport(0,0,t.width,t.height),e.activeTexture(e.TEXTURE0);let n=Ht(t,2);return n||(n=mn(Ul(t),e,t.m?e.LINEAR:e.NEAREST),t.g.push(n),t.j=!0),e.bindTexture(e.TEXTURE_2D,n),n}function qa(t){t.h.bindTexture(t.h.TEXTURE_2D,null)}var jr,Ae=class{constructor(t,e,n,s,r,i,o){this.g=t,this.m=e,this.j=n,this.canvas=s,this.l=r,this.width=i,this.height=o,this.j&&--Fu===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Fa(){return!!Ht(this,0)}ja(){return!!Ht(this,1)}P(){return!!Ht(this,2)}ia(){return(e=Ht(t=this,0))||(e=ja(t),e=new Uint8Array(e.map(n=>255*n)),t.g.push(e)),e;var t,e}ha(){return ja(this)}M(){return Ig(this)}clone(){const t=[];for(const e of this.g){let n;if(e instanceof Uint8Array)n=new Uint8Array(e);else if(e instanceof Float32Array)n=new Float32Array(e);else{if(!(e instanceof WebGLTexture))throw Error(`Type is not supported: ${e}`);{const s=vs(this),r=Ul(this);s.activeTexture(s.TEXTURE1),n=mn(r,s,this.m?s.LINEAR:s.NEAREST),s.bindTexture(s.TEXTURE_2D,n);const i=Ng(this);s.texImage2D(s.TEXTURE_2D,0,i,this.width,this.height,0,s.RED,s.FLOAT,null),s.bindTexture(s.TEXTURE_2D,null),To(r,s,n),Pr(r,s,!1,()=>{xg(this),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.drawArrays(s.TRIANGLE_FAN,0,4),qa(this)}),Bl(r),qa(this)}}t.push(n)}return new Ae(t,this.m,this.P(),this.canvas,this.l,this.width,this.height)}close(){this.j&&vs(this).deleteTexture(Ht(this,2)),Fu=-1}};Ae.prototype.close=Ae.prototype.close,Ae.prototype.clone=Ae.prototype.clone,Ae.prototype.getAsWebGLTexture=Ae.prototype.M,Ae.prototype.getAsFloat32Array=Ae.prototype.ha,Ae.prototype.getAsUint8Array=Ae.prototype.ia,Ae.prototype.hasWebGLTexture=Ae.prototype.P,Ae.prototype.hasFloat32Array=Ae.prototype.ja,Ae.prototype.hasUint8Array=Ae.prototype.Fa;var Fu=250;const jE={color:"white",lineWidth:4,radius:6};function ia(t){return{...jE,fillColor:(t=t||{}).color,...t}}function Ut(t,e){return t instanceof Function?t(e):t}function Mu(t,e,n){return Math.max(Math.min(e,n),Math.min(Math.max(e,n),t))}function js(t){if(!t.l)throw Error("CPU rendering requested but CanvasRenderingContext2D not provided.");return t.l}function wr(t){if(!t.j)throw Error("GPU rendering requested but WebGL2RenderingContext not provided.");return t.j}function Bu(t,e,n){if(e.P())n(e.M());else{const s=e.ja()?e.ha():e.ia();t.m=t.m??new Ds;const r=wr(t);n((t=new Ae([s],e.m,!1,r.canvas,t.m,e.width,e.height)).M()),t.close()}}function Uu(t,e,n,s){const r=function(a){return a.g||(a.g=new GE),a.g}(t),i=wr(t),o=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n;Pr(r,i,!0,()=>{(function(c,l,h,u){const d=c.g;if(d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,l),d.activeTexture(d.TEXTURE1),d.bindTexture(d.TEXTURE_2D,c.B),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,h),c.H&&function(p,f){if(p!==f)return!1;p=p.entries(),f=f.entries();for(const[E,R]of p){p=E;const y=R;var g=f.next();if(g.done)return!1;const[S,D]=g.value;if(g=D,p!==S||y[0]!==g[0]||y[1]!==g[1]||y[2]!==g[2]||y[3]!==g[3])return!1}return!!f.next().done}(c.H,u))d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j);else{c.H=u;const p=Array(1024).fill(0);u.forEach((f,g)=>{if(f.length!==4)throw Error(`Color at index ${g} is not a four-channel value.`);p[4*g]=f[0],p[4*g+1]=f[1],p[4*g+2]=f[2],p[4*g+3]=f[3]}),d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,256,1,0,d.RGBA,d.UNSIGNED_BYTE,new Uint8Array(p))}})(r,e,o,s),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4);const a=r.g;a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,null),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,null),a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,null)})}function Vu(t,e,n,s){const r=wr(t),i=function(c){return c.h||(c.h=new $E),c.h}(t),o=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n,a=Array.isArray(s)?new ImageData(new Uint8ClampedArray(s),1,1):s;Pr(i,r,!0,()=>{var c=i.g;c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,e),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,i.j),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,o),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,i.B),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.drawArrays(r.TRIANGLE_FAN,0,4),r.bindTexture(r.TEXTURE_2D,null),(c=i.g).activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,null)})}var De=class{constructor(t,e){t instanceof CanvasRenderingContext2D||t instanceof OffscreenCanvasRenderingContext2D?(this.l=t,this.j=e):this.j=t}ya(t,e){if(t){var n=js(this);e=ia(e),n.save();var s=n.canvas,r=0;for(const i of t)n.fillStyle=Ut(e.fillColor,{index:r,from:i}),n.strokeStyle=Ut(e.color,{index:r,from:i}),n.lineWidth=Ut(e.lineWidth,{index:r,from:i}),(t=new Path2D).arc(i.x*s.width,i.y*s.height,Ut(e.radius,{index:r,from:i}),0,2*Math.PI),n.fill(t),n.stroke(t),++r;n.restore()}}xa(t,e,n){if(t&&e){var s=js(this);n=ia(n),s.save();var r=s.canvas,i=0;for(const o of e){s.beginPath(),e=t[o.start];const a=t[o.end];e&&a&&(s.strokeStyle=Ut(n.color,{index:i,from:e,to:a}),s.lineWidth=Ut(n.lineWidth,{index:i,from:e,to:a}),s.moveTo(e.x*r.width,e.y*r.height),s.lineTo(a.x*r.width,a.y*r.height)),++i,s.stroke()}s.restore()}}ua(t,e){const n=js(this);e=ia(e),n.save(),n.beginPath(),n.lineWidth=Ut(e.lineWidth,{}),n.strokeStyle=Ut(e.color,{}),n.fillStyle=Ut(e.fillColor,{}),n.moveTo(t.originX,t.originY),n.lineTo(t.originX+t.width,t.originY),n.lineTo(t.originX+t.width,t.originY+t.height),n.lineTo(t.originX,t.originY+t.height),n.lineTo(t.originX,t.originY),n.stroke(),n.fill(),n.restore()}va(t,e,n=[0,0,0,255]){this.l?function(s,r,i,o){const a=wr(s);Bu(s,r,c=>{Uu(s,c,i,o),(c=js(s)).drawImage(a.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,t,n,e):Uu(this,t.M(),n,e)}wa(t,e,n){this.l?function(s,r,i,o){const a=wr(s);Bu(s,r,c=>{Vu(s,c,i,o),(c=js(s)).drawImage(a.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,t,e,n):Vu(this,t.M(),e,n)}close(){var t,e,n;(t=this.g)==null||t.close(),this.g=void 0,(e=this.h)==null||e.close(),this.h=void 0,(n=this.m)==null||n.close(),this.m=void 0}};function Pt(t,e){switch(e){case 0:return t.g.find(n=>n instanceof ImageData);case 1:return t.g.find(n=>typeof ImageBitmap<"u"&&n instanceof ImageBitmap);case 2:return t.g.find(n=>typeof WebGLTexture<"u"&&n instanceof WebGLTexture);default:throw Error(`Type is not supported: ${e}`)}}function Og(t){var e=Pt(t,0);if(!e){e=ws(t);const n=Co(t),s=new Uint8Array(t.width*t.height*4);To(n,e,ni(t)),e.readPixels(0,0,t.width,t.height,e.RGBA,e.UNSIGNED_BYTE,s),Bl(n),e=new ImageData(new Uint8ClampedArray(s.buffer),t.width,t.height),t.g.push(e)}return e}function ni(t){let e=Pt(t,2);if(!e){const n=ws(t);e=si(t);const s=Pt(t,1)||Og(t);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,s),Xs(t)}return e}function ws(t){if(!t.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return t.h||(t.h=Ue(t.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),t.h}function Co(t){return t.l||(t.l=new Ds),t.l}function si(t){const e=ws(t);e.viewport(0,0,t.width,t.height),e.activeTexture(e.TEXTURE0);let n=Pt(t,2);return n||(n=mn(Co(t),e),t.g.push(n),t.m=!0),e.bindTexture(e.TEXTURE_2D,n),n}function Xs(t){t.h.bindTexture(t.h.TEXTURE_2D,null)}function Hu(t){const e=ws(t);return Pr(Co(t),e,!0,()=>function(n,s){const r=n.canvas;if(r.width===n.width&&r.height===n.height)return s();const i=r.width,o=r.height;return r.width=n.width,r.height=n.height,n=s(),r.width=i,r.height=o,n}(t,()=>{if(e.bindFramebuffer(e.FRAMEBUFFER,null),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),!(t.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return t.canvas.transferToImageBitmap()}))}De.prototype.close=De.prototype.close,De.prototype.drawConfidenceMask=De.prototype.wa,De.prototype.drawCategoryMask=De.prototype.va,De.prototype.drawBoundingBox=De.prototype.ua,De.prototype.drawConnectors=De.prototype.xa,De.prototype.drawLandmarks=De.prototype.ya,De.lerp=function(t,e,n,s,r){return Mu(s*(1-(t-e)/(n-e))+r*(1-(n-t)/(n-e)),s,r)},De.clamp=Mu;var Ie=class{constructor(t,e,n,s,r,i,o){this.g=t,this.j=e,this.m=n,this.canvas=s,this.l=r,this.width=i,this.height=o,(this.j||this.m)&&--Wu===0&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}Ea(){return!!Pt(this,0)}ka(){return!!Pt(this,1)}P(){return!!Pt(this,2)}Ca(){return Og(this)}Ba(){var t=Pt(this,1);return t||(ni(this),si(this),t=Hu(this),Xs(this),this.g.push(t),this.j=!0),t}M(){return ni(this)}clone(){const t=[];for(const e of this.g){let n;if(e instanceof ImageData)n=new ImageData(e.data,this.width,this.height);else if(e instanceof WebGLTexture){const s=ws(this),r=Co(this);s.activeTexture(s.TEXTURE1),n=mn(r,s),s.bindTexture(s.TEXTURE_2D,n),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,this.width,this.height,0,s.RGBA,s.UNSIGNED_BYTE,null),s.bindTexture(s.TEXTURE_2D,null),To(r,s,n),Pr(r,s,!1,()=>{si(this),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.drawArrays(s.TRIANGLE_FAN,0,4),Xs(this)}),Bl(r),Xs(this)}else{if(!(e instanceof ImageBitmap))throw Error(`Type is not supported: ${e}`);ni(this),si(this),n=Hu(this),Xs(this)}t.push(n)}return new Ie(t,this.ka(),this.P(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Pt(this,1).close(),this.m&&ws(this).deleteTexture(Pt(this,2)),Wu=-1}};Ie.prototype.close=Ie.prototype.close,Ie.prototype.clone=Ie.prototype.clone,Ie.prototype.getAsWebGLTexture=Ie.prototype.M,Ie.prototype.getAsImageBitmap=Ie.prototype.Ba,Ie.prototype.getAsImageData=Ie.prototype.Ca,Ie.prototype.hasWebGLTexture=Ie.prototype.P,Ie.prototype.hasImageBitmap=Ie.prototype.ka,Ie.prototype.hasImageData=Ie.prototype.Ea;var Wu=250;function Rt(...t){return t.map(([e,n])=>({start:e,end:n}))}const qE=function(t){return class extends t{La(){this.i._registerModelResourcesGraphService()}}}((Gu=class{constructor(t,e){this.l=!0,this.i=t,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",e!==void 0?this.i.canvas=e:Rg()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(t){const e=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(e),t)}setGraphFromString(t){this.setGraph(new TextEncoder().encode(t),!1)}setGraph(t,e){const n=t.length,s=this.i._malloc(n);this.i.HEAPU8.set(t,s),e?this.i._changeBinaryGraph(n,s):this.i._changeTextGraph(n,s),this.i._free(s)}configureAudio(t,e,n,s,r){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),x(this,s||"input_audio",i=>{x(this,r=r||"audio_header",o=>{this.i._configureAudio(i,o,t,e??0,n)})})}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.i._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.i.gpuOriginForWebTexturesIsBottomLeft=t}da(t){Nt(this,"__graph_config__",e=>{t(e)}),x(this,"__graph_config__",e=>{this.i._getGraphConfig(e,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(t){this.i.errorListener=t}attachEmptyPacketListener(t,e){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[t]=e}addAudioToStream(t,e,n){this.addAudioToStreamWithShape(t,0,0,e,n)}addAudioToStreamWithShape(t,e,n,s,r){const i=4*t.length;this.h!==i&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(i),this.h=i),this.i.HEAPF32.set(t,this.g/4),x(this,s,o=>{this.i._addAudioToInputStream(this.g,e,n,o,r)})}addGpuBufferToStream(t,e,n){x(this,e,s=>{const[r,i]=xu(this,t,s);this.i._addBoundTextureToStream(s,r,i,n)})}addBoolToStream(t,e,n){x(this,e,s=>{this.i._addBoolToInputStream(t,s,n)})}addDoubleToStream(t,e,n){x(this,e,s=>{this.i._addDoubleToInputStream(t,s,n)})}addFloatToStream(t,e,n){x(this,e,s=>{this.i._addFloatToInputStream(t,s,n)})}addIntToStream(t,e,n){x(this,e,s=>{this.i._addIntToInputStream(t,s,n)})}addUintToStream(t,e,n){x(this,e,s=>{this.i._addUintToInputStream(t,s,n)})}addStringToStream(t,e,n){x(this,e,s=>{x(this,t,r=>{this.i._addStringToInputStream(r,s,n)})})}addStringRecordToStream(t,e,n){x(this,e,s=>{Ou(this,Object.keys(t),r=>{Ou(this,Object.values(t),i=>{this.i._addFlatHashMapToInputStream(r,i,Object.keys(t).length,s,n)})})})}addProtoToStream(t,e,n,s){x(this,n,r=>{x(this,e,i=>{const o=this.i._malloc(t.length);this.i.HEAPU8.set(t,o),this.i._addProtoToInputStream(o,t.length,i,r,s),this.i._free(o)})})}addEmptyPacketToStream(t,e){x(this,t,n=>{this.i._addEmptyPacketToInputStream(n,e)})}addBoolVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(const i of t)this.i._addBoolVectorEntry(r,i);this.i._addBoolVectorToInputStream(r,s,n)})}addDoubleVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(const i of t)this.i._addDoubleVectorEntry(r,i);this.i._addDoubleVectorToInputStream(r,s,n)})}addFloatVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(const i of t)this.i._addFloatVectorEntry(r,i);this.i._addFloatVectorToInputStream(r,s,n)})}addIntVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(const i of t)this.i._addIntVectorEntry(r,i);this.i._addIntVectorToInputStream(r,s,n)})}addUintVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(const i of t)this.i._addUintVectorEntry(r,i);this.i._addUintVectorToInputStream(r,s,n)})}addStringVectorToStream(t,e,n){x(this,e,s=>{const r=this.i._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(const i of t)x(this,i,o=>{this.i._addStringVectorEntry(r,o)});this.i._addStringVectorToInputStream(r,s,n)})}addBoolToInputSidePacket(t,e){x(this,e,n=>{this.i._addBoolToInputSidePacket(t,n)})}addDoubleToInputSidePacket(t,e){x(this,e,n=>{this.i._addDoubleToInputSidePacket(t,n)})}addFloatToInputSidePacket(t,e){x(this,e,n=>{this.i._addFloatToInputSidePacket(t,n)})}addIntToInputSidePacket(t,e){x(this,e,n=>{this.i._addIntToInputSidePacket(t,n)})}addUintToInputSidePacket(t,e){x(this,e,n=>{this.i._addUintToInputSidePacket(t,n)})}addStringToInputSidePacket(t,e){x(this,e,n=>{x(this,t,s=>{this.i._addStringToInputSidePacket(s,n)})})}addProtoToInputSidePacket(t,e,n){x(this,n,s=>{x(this,e,r=>{const i=this.i._malloc(t.length);this.i.HEAPU8.set(t,i),this.i._addProtoToInputSidePacket(i,t.length,r,s),this.i._free(i)})})}addBoolVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateBoolVector(t.length);if(!s)throw Error("Unable to allocate new bool vector on heap.");for(const r of t)this.i._addBoolVectorEntry(s,r);this.i._addBoolVectorToInputSidePacket(s,n)})}addDoubleVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateDoubleVector(t.length);if(!s)throw Error("Unable to allocate new double vector on heap.");for(const r of t)this.i._addDoubleVectorEntry(s,r);this.i._addDoubleVectorToInputSidePacket(s,n)})}addFloatVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateFloatVector(t.length);if(!s)throw Error("Unable to allocate new float vector on heap.");for(const r of t)this.i._addFloatVectorEntry(s,r);this.i._addFloatVectorToInputSidePacket(s,n)})}addIntVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateIntVector(t.length);if(!s)throw Error("Unable to allocate new int vector on heap.");for(const r of t)this.i._addIntVectorEntry(s,r);this.i._addIntVectorToInputSidePacket(s,n)})}addUintVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateUintVector(t.length);if(!s)throw Error("Unable to allocate new unsigned int vector on heap.");for(const r of t)this.i._addUintVectorEntry(s,r);this.i._addUintVectorToInputSidePacket(s,n)})}addStringVectorToInputSidePacket(t,e){x(this,e,n=>{const s=this.i._allocateStringVector(t.length);if(!s)throw Error("Unable to allocate new string vector on heap.");for(const r of t)x(this,r,i=>{this.i._addStringVectorEntry(s,i)});this.i._addStringVectorToInputSidePacket(s,n)})}attachBoolListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachBoolListener(n)})}attachBoolVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachBoolVectorListener(n)})}attachIntListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachIntListener(n)})}attachIntVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachIntVectorListener(n)})}attachUintListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachUintListener(n)})}attachUintVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachUintVectorListener(n)})}attachDoubleListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachDoubleListener(n)})}attachDoubleVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachDoubleVectorListener(n)})}attachFloatListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachFloatListener(n)})}attachFloatVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachFloatVectorListener(n)})}attachStringListener(t,e){Nt(this,t,e),x(this,t,n=>{this.i._attachStringListener(n)})}attachStringVectorListener(t,e){tn(this,t,e),x(this,t,n=>{this.i._attachStringVectorListener(n)})}attachProtoListener(t,e,n){Nt(this,t,e),x(this,t,s=>{this.i._attachProtoListener(s,n||!1)})}attachProtoVectorListener(t,e,n){tn(this,t,e),x(this,t,s=>{this.i._attachProtoVectorListener(s,n||!1)})}attachAudioListener(t,e,n){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Nt(this,t,(s,r)=>{s=new Float32Array(s.buffer,s.byteOffset,s.length/4),e(s,r)}),x(this,t,s=>{this.i._attachAudioListener(s,n||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Gu{get ea(){return this.i}qa(t,e,n){x(this,e,s=>{const[r,i]=xu(this,t,s);this.ea._addBoundTextureAsImageToStream(s,r,i,n)})}U(t,e){Nt(this,t,e),x(this,t,n=>{this.ea._attachImageListener(n)})}ca(t,e){tn(this,t,e),x(this,t,n=>{this.ea._attachImageVectorListener(n)})}}));var Gu,_t=class extends qE{};async function $(t,e,n){return async function(s,r,i,o){return HE(s,r,i,o)}(t,n.canvas??(Rg()?void 0:document.createElement("canvas")),e,n)}function Lg(t,e,n,s){if(t.T){const i=new ng;if(n!=null&&n.regionOfInterest){if(!t.pa)throw Error("This task doesn't support region-of-interest.");var r=n.regionOfInterest;if(r.left>=r.right||r.top>=r.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(r.left<0||r.top<0||r.right>1||r.bottom>1)throw Error("Expected RectF values to be in [0,1].");N(i,1,(r.left+r.right)/2),N(i,2,(r.top+r.bottom)/2),N(i,4,r.right-r.left),N(i,3,r.bottom-r.top)}else N(i,1,.5),N(i,2,.5),N(i,4,1),N(i,3,1);if(n!=null&&n.rotationDegrees){if((n==null?void 0:n.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90°.");if(N(i,5,-Math.PI*n.rotationDegrees/180),(n==null?void 0:n.rotationDegrees)%180!=0){const[o,a]=kg(e);n=ve(i,3)*a/o,r=ve(i,4)*o/a,N(i,4,n),N(i,3,r)}}t.g.addProtoToStream(i.g(),"mediapipe.NormalizedRect",t.T,s)}t.g.qa(e,t.aa,s??performance.now()),t.finishProcessing()}function yt(t,e,n){var s;if((s=t.baseOptions)!=null&&s.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");Lg(t,e,n,t.B+1)}function Bt(t,e,n,s){var r;if(!((r=t.baseOptions)!=null&&r.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");Lg(t,e,n,s)}function bs(t,e,n,s){var r=e.data;const i=e.width,o=i*(e=e.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==o)throw Error("Unsupported channel count: "+r.length/o);return t=new Ae([r],n,!1,t.g.i.canvas,t.O,i,e),s?t.clone():t}var Ye=class extends ti{constructor(t,e,n,s){super(t),this.g=t,this.aa=e,this.T=n,this.pa=s,this.O=new Ds}l(t,e=!0){if("runningMode"in t&&Er(this.baseOptions,2,!!t.runningMode&&t.runningMode!=="IMAGE"),t.canvas!==void 0&&this.g.i.canvas!==t.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(t,e)}close(){this.O.close(),super.close()}};Ye.prototype.close=Ye.prototype.close;var ct=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect_in",!1),this.j={detections:[]},L(t=this.h=new Eo,0,1,e=new pe),N(this.h,2,.5),N(this.h,3,.3)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&N(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&N(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}D(t,e){return this.j={detections:[]},yt(this,t,e),this.j}F(t,e,n){return this.j={detections:[]},Bt(this,t,n,e),this.j}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect_in"),X(t,"detections");const e=new rt;Ct(e,RE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect_in"),z(n,"DETECTIONS:detections"),n.o(e),at(t,n),this.g.attachProtoVectorListener("detections",(s,r)=>{for(const i of s)s=Zm(i),this.j.detections.push(Sg(s));A(this,r)}),this.g.attachEmptyPacketListener("detections",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ct.prototype.detectForVideo=ct.prototype.F,ct.prototype.detect=ct.prototype.D,ct.prototype.setOptions=ct.prototype.o,ct.createFromModelPath=async function(t,e){return $(ct,t,{baseOptions:{modelAssetPath:e}})},ct.createFromModelBuffer=function(t,e){return $(ct,t,{baseOptions:{modelAssetBuffer:e}})},ct.createFromOptions=function(t,e){return $(ct,t,e)};var Vl=Rt([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),Hl=Rt([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),Wl=Rt([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Dg=Rt([474,475],[475,476],[476,477],[477,474]),Gl=Rt([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),$l=Rt([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Pg=Rt([469,470],[470,471],[471,472],[472,469]),jl=Rt([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),Fg=[...Vl,...Hl,...Wl,...Gl,...$l,...jl],Mg=Rt([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function $u(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var ne=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,L(t=this.h=new ag,0,1,e=new pe),this.v=new og,L(this.h,0,3,this.v),this.s=new Eo,L(this.h,0,2,this.s),Ft(this.s,4,1),N(this.s,2,.5),N(this.v,2,.5),N(this.h,4,.5)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return"numFaces"in t&&Ft(this.s,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&N(this.s,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&N(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&N(this.v,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in t&&(this.outputFacialTransformationMatrixes=!!t.outputFacialTransformationMatrixes),this.l(t)}D(t,e){return $u(this),yt(this,t,e),this.j}F(t,e,n){return $u(this),Bt(this,t,n,e),this.j}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"face_landmarks");const e=new rt;Ct(e,IE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"NORM_LANDMARKS:face_landmarks"),n.o(e),at(t,n),this.g.attachProtoVectorListener("face_landmarks",(s,r)=>{for(const i of s)s=Dr(i),this.j.faceLandmarks.push(vo(s));A(this,r)}),this.g.attachEmptyPacketListener("face_landmarks",s=>{A(this,s)}),this.outputFaceBlendshapes&&(X(t,"blendshapes"),z(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(s,r)=>{if(this.outputFaceBlendshapes)for(const i of s)s=yo(i),this.j.faceBlendshapes.push(Fl(s.g()??[]));A(this,r)}),this.g.attachEmptyPacketListener("blendshapes",s=>{A(this,s)})),this.outputFacialTransformationMatrixes&&(X(t,"face_geometry"),z(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(s,r)=>{if(this.outputFacialTransformationMatrixes)for(const i of s)(s=Y(kE(i),EE,2))&&this.j.facialTransformationMatrixes.push({rows:ft(s,1)??0??0,columns:ft(s,2)??0??0,data:kn(s,3,_n,Rn()).slice()??[]});A(this,r)}),this.g.attachEmptyPacketListener("face_geometry",s=>{A(this,s)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ne.prototype.detectForVideo=ne.prototype.F,ne.prototype.detect=ne.prototype.D,ne.prototype.setOptions=ne.prototype.o,ne.createFromModelPath=function(t,e){return $(ne,t,{baseOptions:{modelAssetPath:e}})},ne.createFromModelBuffer=function(t,e){return $(ne,t,{baseOptions:{modelAssetBuffer:e}})},ne.createFromOptions=function(t,e){return $(ne,t,e)},ne.FACE_LANDMARKS_LIPS=Vl,ne.FACE_LANDMARKS_LEFT_EYE=Hl,ne.FACE_LANDMARKS_LEFT_EYEBROW=Wl,ne.FACE_LANDMARKS_LEFT_IRIS=Dg,ne.FACE_LANDMARKS_RIGHT_EYE=Gl,ne.FACE_LANDMARKS_RIGHT_EYEBROW=$l,ne.FACE_LANDMARKS_RIGHT_IRIS=Pg,ne.FACE_LANDMARKS_FACE_OVAL=jl,ne.FACE_LANDMARKS_CONTOURS=Fg,ne.FACE_LANDMARKS_TESSELATION=Mg;var xt=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!0),L(t=this.j=new lg,0,1,e=new pe)}get baseOptions(){return Y(this.j,pe,1)}set baseOptions(t){L(this.j,0,1,t)}o(t){return super.l(t)}Oa(t,e,n){const s=typeof e!="function"?e:{};if(this.h=typeof e=="function"?e:n,yt(this,t,s??{}),!this.h)return this.s}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"stylized_image");const e=new rt;Ct(e,NE,this.j);const n=new Ve;ot(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"STYLIZED_IMAGE:stylized_image"),n.o(e),at(t,n),this.g.U("stylized_image",(s,r)=>{var i=!this.h,o=s.data,a=s.width;const c=a*(s=s.height);if(o instanceof Uint8Array)if(o.length===3*c){const l=new Uint8ClampedArray(4*c);for(let h=0;h<c;++h)l[4*h]=o[3*h],l[4*h+1]=o[3*h+1],l[4*h+2]=o[3*h+2],l[4*h+3]=255;o=new ImageData(l,a,s)}else{if(o.length!==4*c)throw Error("Unsupported channel count: "+o.length/c);o=new ImageData(new Uint8ClampedArray(o.buffer,o.byteOffset,o.length),a,s)}else if(!(o instanceof WebGLTexture))throw Error(`Unsupported format: ${o.constructor.name}`);a=new Ie([o],!1,!1,this.g.i.canvas,this.O,a,s),this.s=i=i?a.clone():a,this.h&&this.h(i),A(this,r)}),this.g.attachEmptyPacketListener("stylized_image",s=>{this.s=null,this.h&&this.h(null),A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};xt.prototype.stylize=xt.prototype.Oa,xt.prototype.setOptions=xt.prototype.o,xt.createFromModelPath=function(t,e){return $(xt,t,{baseOptions:{modelAssetPath:e}})},xt.createFromModelBuffer=function(t,e){return $(xt,t,{baseOptions:{modelAssetBuffer:e}})},xt.createFromOptions=function(t,e){return $(xt,t,e)};var ql=Rt([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function ju(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function qu(t){return t.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:t.gestures,landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handedness:t.handedness,handednesses:t.handedness}}function zu(t,e=!0){const n=[];for(const r of t){var s=yo(r);t=[];for(const i of s.g())s=e&&ft(i,1)!=null?ft(i,1)??0:-1,t.push({score:ve(i,2)??0,index:s,categoryName:mt(i,3)??""??"",displayName:mt(i,4)??""??""});n.push(t)}return n}var Qe=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],L(t=this.j=new dg,0,1,e=new pe),this.s=new Ol,L(this.j,0,2,this.s),this.C=new xl,L(this.s,0,3,this.C),this.v=new ug,L(this.s,0,2,this.v),this.h=new xE,L(this.j,0,3,this.h),N(this.v,2,.5),N(this.s,4,.5),N(this.C,2,.5)}get baseOptions(){return Y(this.j,pe,1)}set baseOptions(t){L(this.j,0,1,t)}o(t){var r,i,o,a;if(Ft(this.v,3,t.numHands??1),"minHandDetectionConfidence"in t&&N(this.v,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&N(this.s,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&N(this.C,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var e=new Gn,n=e,s=$a(t.cannedGesturesClassifierOptions,(r=Y(this.h,Gn,3))==null?void 0:r.h());L(n,0,2,s),L(this.h,0,3,e)}else t.cannedGesturesClassifierOptions===void 0&&((i=Y(this.h,Gn,3))==null||i.g());return t.customGesturesClassifierOptions?(L(n=e=new Gn,0,2,s=$a(t.customGesturesClassifierOptions,(o=Y(this.h,Gn,4))==null?void 0:o.h())),L(this.h,0,4,e)):t.customGesturesClassifierOptions===void 0&&((a=Y(this.h,Gn,4))==null||a.g()),this.l(t)}Ja(t,e){return ju(this),yt(this,t,e),qu(this)}Ka(t,e,n){return ju(this),Bt(this,t,n,e),qu(this)}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"hand_gestures"),X(t,"hand_landmarks"),X(t,"world_hand_landmarks"),X(t,"handedness");const e=new rt;Ct(e,OE,this.j);const n=new Ve;ot(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"HAND_GESTURES:hand_gestures"),z(n,"LANDMARKS:hand_landmarks"),z(n,"WORLD_LANDMARKS:world_hand_landmarks"),z(n,"HANDEDNESS:handedness"),n.o(e),at(t,n),this.g.attachProtoVectorListener("hand_landmarks",(s,r)=>{for(const i of s){s=Dr(i);const o=[];for(const a of Yt(s,tg,1))o.push({x:ve(a,1)??0,y:ve(a,2)??0,z:ve(a,3)??0,visibility:ve(a,4)??0});this.landmarks.push(o)}A(this,r)}),this.g.attachEmptyPacketListener("hand_landmarks",s=>{A(this,s)}),this.g.attachProtoVectorListener("world_hand_landmarks",(s,r)=>{for(const i of s){s=as(i);const o=[];for(const a of Yt(s,eg,1))o.push({x:ve(a,1)??0,y:ve(a,2)??0,z:ve(a,3)??0,visibility:ve(a,4)??0});this.worldLandmarks.push(o)}A(this,r)}),this.g.attachEmptyPacketListener("world_hand_landmarks",s=>{A(this,s)}),this.g.attachProtoVectorListener("hand_gestures",(s,r)=>{this.gestures.push(...zu(s,!1)),A(this,r)}),this.g.attachEmptyPacketListener("hand_gestures",s=>{A(this,s)}),this.g.attachProtoVectorListener("handedness",(s,r)=>{this.handedness.push(...zu(s)),A(this,r)}),this.g.attachEmptyPacketListener("handedness",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function Ku(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Qe.prototype.recognizeForVideo=Qe.prototype.Ka,Qe.prototype.recognize=Qe.prototype.Ja,Qe.prototype.setOptions=Qe.prototype.o,Qe.createFromModelPath=function(t,e){return $(Qe,t,{baseOptions:{modelAssetPath:e}})},Qe.createFromModelBuffer=function(t,e){return $(Qe,t,{baseOptions:{modelAssetBuffer:e}})},Qe.createFromOptions=function(t,e){return $(Qe,t,e)},Qe.HAND_CONNECTIONS=ql;var Ze=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],L(t=this.h=new Ol,0,1,e=new pe),this.s=new xl,L(this.h,0,3,this.s),this.j=new ug,L(this.h,0,2,this.j),Ft(this.j,3,1),N(this.j,2,.5),N(this.s,2,.5),N(this.h,4,.5)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return"numHands"in t&&Ft(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&N(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&N(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&N(this.s,2,t.minHandPresenceConfidence??.5),this.l(t)}D(t,e){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],yt(this,t,e),Ku(this)}F(t,e,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Bt(this,t,n,e),Ku(this)}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"hand_landmarks"),X(t,"world_hand_landmarks"),X(t,"handedness");const e=new rt;Ct(e,LE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"LANDMARKS:hand_landmarks"),z(n,"WORLD_LANDMARKS:world_hand_landmarks"),z(n,"HANDEDNESS:handedness"),n.o(e),at(t,n),this.g.attachProtoVectorListener("hand_landmarks",(s,r)=>{for(const i of s)s=Dr(i),this.landmarks.push(vo(s));A(this,r)}),this.g.attachEmptyPacketListener("hand_landmarks",s=>{A(this,s)}),this.g.attachProtoVectorListener("world_hand_landmarks",(s,r)=>{for(const i of s)s=as(i),this.worldLandmarks.push(ir(s));A(this,r)}),this.g.attachEmptyPacketListener("world_hand_landmarks",s=>{A(this,s)}),this.g.attachProtoVectorListener("handedness",(s,r)=>{var i=this.handedness,o=i.push;const a=[];for(const c of s){s=yo(c);const l=[];for(const h of s.g())l.push({score:ve(h,2)??0,index:ft(h,1)??0??-1,categoryName:mt(h,3)??""??"",displayName:mt(h,4)??""??""});a.push(l)}o.call(i,...a),A(this,r)}),this.g.attachEmptyPacketListener("handedness",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ze.prototype.detectForVideo=Ze.prototype.F,Ze.prototype.detect=Ze.prototype.D,Ze.prototype.setOptions=Ze.prototype.o,Ze.createFromModelPath=function(t,e){return $(Ze,t,{baseOptions:{modelAssetPath:e}})},Ze.createFromModelBuffer=function(t,e){return $(Ze,t,{baseOptions:{modelAssetBuffer:e}})},Ze.createFromOptions=function(t,e){return $(Ze,t,e)},Ze.HAND_CONNECTIONS=ql;var Bg=Rt([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function Yu(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function Xu(t){try{if(!t.C)return t.h;t.C(t.h)}finally{bo(t)}}function qr(t,e){t=Dr(t),e.push(vo(t))}var de=class extends Ye{constructor(t,e){super(new _t(t,e),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,L(t=this.j=new _g,0,1,e=new pe),this.J=new xl,L(this.j,0,2,this.J),this.Z=new DE,L(this.j,0,3,this.Z),this.s=new Eo,L(this.j,0,4,this.s),this.H=new og,L(this.j,0,5,this.H),this.v=new mg,L(this.j,0,6,this.v),this.K=new gg,L(this.j,0,7,this.K),N(this.s,2,.5),N(this.s,3,.3),N(this.H,2,.5),N(this.v,2,.5),N(this.v,3,.3),N(this.K,2,.5),N(this.J,2,.5)}get baseOptions(){return Y(this.j,pe,1)}set baseOptions(t){L(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&N(this.s,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&N(this.s,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&N(this.H,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&N(this.v,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&N(this.v,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&N(this.K,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&N(this.J,2,t.minHandLandmarksConfidence??.5),this.l(t)}D(t,e,n){const s=typeof e!="function"?e:{};return this.C=typeof e=="function"?e:n,Yu(this),yt(this,t,s),Xu(this)}F(t,e,n,s){const r=typeof n!="function"?n:{};return this.C=typeof n=="function"?n:s,Yu(this),Bt(this,t,r,e),Xu(this)}m(){var t=new Xe;ue(t,"input_frames_image"),X(t,"pose_landmarks"),X(t,"pose_world_landmarks"),X(t,"face_landmarks"),X(t,"left_hand_landmarks"),X(t,"left_hand_world_landmarks"),X(t,"right_hand_landmarks"),X(t,"right_hand_world_landmarks");const e=new rt,n=new mu;Ba(n,1,ks("type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),""),function(r,i){if(i!=null)if(Array.isArray(i))ae(r,2,um(i));else{if(!(typeof i=="string"||i instanceof jt||Nr(i)))throw Error("invalid value in Any.value field: "+i+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");Ba(r,2,Yc(i,!1),Mn())}}(n,this.j.g());const s=new Ve;ot(s,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),Di(s,8,mu,n),ce(s,"IMAGE:input_frames_image"),z(s,"POSE_LANDMARKS:pose_landmarks"),z(s,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),z(s,"FACE_LANDMARKS:face_landmarks"),z(s,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),z(s,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),z(s,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),z(s,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),s.o(e),at(t,s),wo(this,t),this.g.attachProtoListener("pose_landmarks",(r,i)=>{qr(r,this.h.poseLandmarks),A(this,i)}),this.g.attachEmptyPacketListener("pose_landmarks",r=>{A(this,r)}),this.g.attachProtoListener("pose_world_landmarks",(r,i)=>{var o=this.h.poseWorldLandmarks;r=as(r),o.push(ir(r)),A(this,i)}),this.g.attachEmptyPacketListener("pose_world_landmarks",r=>{A(this,r)}),this.outputPoseSegmentationMasks&&(z(s,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Es(this,"pose_segmentation_mask"),this.g.U("pose_segmentation_mask",(r,i)=>{this.h.poseSegmentationMasks=[bs(this,r,!0,!this.C)],A(this,i)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",r=>{this.h.poseSegmentationMasks=[],A(this,r)})),this.g.attachProtoListener("face_landmarks",(r,i)=>{qr(r,this.h.faceLandmarks),A(this,i)}),this.g.attachEmptyPacketListener("face_landmarks",r=>{A(this,r)}),this.outputFaceBlendshapes&&(X(t,"extra_blendshapes"),z(s,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(r,i)=>{var o=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(r=yo(r),o.push(Fl(r.g()??[]))),A(this,i)}),this.g.attachEmptyPacketListener("extra_blendshapes",r=>{A(this,r)})),this.g.attachProtoListener("left_hand_landmarks",(r,i)=>{qr(r,this.h.leftHandLandmarks),A(this,i)}),this.g.attachEmptyPacketListener("left_hand_landmarks",r=>{A(this,r)}),this.g.attachProtoListener("left_hand_world_landmarks",(r,i)=>{var o=this.h.leftHandWorldLandmarks;r=as(r),o.push(ir(r)),A(this,i)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",r=>{A(this,r)}),this.g.attachProtoListener("right_hand_landmarks",(r,i)=>{qr(r,this.h.rightHandLandmarks),A(this,i)}),this.g.attachEmptyPacketListener("right_hand_landmarks",r=>{A(this,r)}),this.g.attachProtoListener("right_hand_world_landmarks",(r,i)=>{var o=this.h.rightHandWorldLandmarks;r=as(r),o.push(ir(r)),A(this,i)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",r=>{A(this,r)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};de.prototype.detectForVideo=de.prototype.F,de.prototype.detect=de.prototype.D,de.prototype.setOptions=de.prototype.o,de.createFromModelPath=function(t,e){return $(de,t,{baseOptions:{modelAssetPath:e}})},de.createFromModelBuffer=function(t,e){return $(de,t,{baseOptions:{modelAssetBuffer:e}})},de.createFromOptions=function(t,e){return $(de,t,e)},de.HAND_CONNECTIONS=ql,de.POSE_CONNECTIONS=Bg,de.FACE_LANDMARKS_LIPS=Vl,de.FACE_LANDMARKS_LEFT_EYE=Hl,de.FACE_LANDMARKS_LEFT_EYEBROW=Wl,de.FACE_LANDMARKS_LEFT_IRIS=Dg,de.FACE_LANDMARKS_RIGHT_EYE=Gl,de.FACE_LANDMARKS_RIGHT_EYEBROW=$l,de.FACE_LANDMARKS_RIGHT_IRIS=Pg,de.FACE_LANDMARKS_FACE_OVAL=jl,de.FACE_LANDMARKS_CONTOURS=Fg,de.FACE_LANDMARKS_TESSELATION=Mg;var lt=class extends Ye{constructor(t,e){super(new _t(t,e),"input_image","norm_rect",!0),this.j={classifications:[]},L(t=this.h=new yg,0,1,e=new pe)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return L(this.h,0,2,$a(t,Y(this.h,kl,2))),this.l(t)}sa(t,e){return this.j={classifications:[]},yt(this,t,e),this.j}ta(t,e,n){return this.j={classifications:[]},Bt(this,t,n,e),this.j}m(){var t=new Xe;ue(t,"input_image"),ue(t,"norm_rect"),X(t,"classifications");const e=new rt;Ct(e,PE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),ce(n,"IMAGE:input_image"),ce(n,"NORM_RECT:norm_rect"),z(n,"CLASSIFICATIONS:classifications"),n.o(e),at(t,n),this.g.attachProtoListener("classifications",(s,r)=>{this.j=function(i){const o={classifications:Yt(i,wE,1).map(a=>{var c;return Fl(((c=Y(a,Jm,4))==null?void 0:c.g())??[],ft(a,2)??0,mt(a,3)??"")})};return Li(_s(i,2))!=null&&(o.timestampMs=Li(_s(i,2))??0),o}(bE(s)),A(this,r)}),this.g.attachEmptyPacketListener("classifications",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};lt.prototype.classifyForVideo=lt.prototype.ta,lt.prototype.classify=lt.prototype.sa,lt.prototype.setOptions=lt.prototype.o,lt.createFromModelPath=function(t,e){return $(lt,t,{baseOptions:{modelAssetPath:e}})},lt.createFromModelBuffer=function(t,e){return $(lt,t,{baseOptions:{modelAssetBuffer:e}})},lt.createFromOptions=function(t,e){return $(lt,t,e)};var et=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!0),this.h=new Eg,this.embeddings={embeddings:[]},L(t=this.h,0,1,e=new pe)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){var e=this.h,n=Y(this.h,Cu,2);return n=n?n.clone():new Cu,t.l2Normalize!==void 0?Er(n,1,t.l2Normalize):"l2Normalize"in t&&ae(n,1),t.quantize!==void 0?Er(n,2,t.quantize):"quantize"in t&&ae(n,2),L(e,0,2,n),this.l(t)}za(t,e){return yt(this,t,e),this.embeddings}Aa(t,e,n){return Bt(this,t,n,e),this.embeddings}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"embeddings_out");const e=new rt;Ct(e,FE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"EMBEDDINGS:embeddings_out"),n.o(e),at(t,n),this.g.attachProtoListener("embeddings_out",(s,r)=>{s=SE(s),this.embeddings=function(i){return{embeddings:Yt(i,CE,1).map(o=>{var c,l;const a={headIndex:ft(o,3)??0??-1,headName:mt(o,4)??""??""};if(gm(o,Tu,Zo(o,1))!==void 0)o=kn(o=Y(o,Tu,Zo(o,1)),1,_n,Rn()),a.floatEmbedding=o.slice();else{const h=new Uint8Array(0);a.quantizedEmbedding=((l=(c=Y(o,TE,Zo(o,2)))==null?void 0:c.oa())==null?void 0:l.h())??h}return a}),timestampMs:Li(_s(i,2))??0}}(s),A(this,r)}),this.g.attachEmptyPacketListener("embeddings_out",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};et.cosineSimilarity=function(t,e){if(t.floatEmbedding&&e.floatEmbedding)t=Iu(t.floatEmbedding,e.floatEmbedding);else{if(!t.quantizedEmbedding||!e.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=Iu(ku(t.quantizedEmbedding),ku(e.quantizedEmbedding))}return t},et.prototype.embedForVideo=et.prototype.Aa,et.prototype.embed=et.prototype.za,et.prototype.setOptions=et.prototype.o,et.createFromModelPath=function(t,e){return $(et,t,{baseOptions:{modelAssetPath:e}})},et.createFromModelBuffer=function(t,e){return $(et,t,{baseOptions:{modelAssetBuffer:e}})},et.createFromOptions=function(t,e){return $(et,t,e)};var za=class{constructor(t,e,n){this.confidenceMasks=t,this.categoryMask=e,this.qualityScores=n}close(){var t,e;(t=this.confidenceMasks)==null||t.forEach(n=>{n.close()}),(e=this.categoryMask)==null||e.close()}};function Ju(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function Qu(t){try{const e=new za(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return e;t.j(e)}finally{bo(t)}}za.prototype.close=za.prototype.close;var Ge=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Pl,this.v=new vg,L(this.h,0,3,this.v),L(t=this.h,0,1,e=new pe)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?ae(this.h,2,ks(t.displayNamesLocale)):"displayNamesLocale"in t&&ae(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}I(){(function(t){var n,s;const e=Yt(t.da(),Ve,1).filter(r=>(mt(r,1)??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(t.s=[],e.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");e.length===1&&(((s=(n=Y(e[0],rt,7))==null?void 0:n.l())==null?void 0:s.g())??new Map).forEach((r,i)=>{t.s[Number(i)]=mt(r,1)??""})})(this)}segment(t,e,n){const s=typeof e!="function"?e:{};return this.j=typeof e=="function"?e:n,Ju(this),yt(this,t,s),Qu(this)}Ma(t,e,n,s){const r=typeof n!="function"?n:{};return this.j=typeof n=="function"?n:s,Ju(this),Bt(this,t,r,e),Qu(this)}Da(){return this.s}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect");const e=new rt;Ct(e,bg,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),n.o(e),at(t,n),wo(this,t),this.outputConfidenceMasks&&(X(t,"confidence_masks"),z(n,"CONFIDENCE_MASKS:confidence_masks"),Es(this,"confidence_masks"),this.g.ca("confidence_masks",(s,r)=>{this.confidenceMasks=s.map(i=>bs(this,i,!0,!this.j)),A(this,r)}),this.g.attachEmptyPacketListener("confidence_masks",s=>{this.confidenceMasks=[],A(this,s)})),this.outputCategoryMask&&(X(t,"category_mask"),z(n,"CATEGORY_MASK:category_mask"),Es(this,"category_mask"),this.g.U("category_mask",(s,r)=>{this.categoryMask=bs(this,s,!1,!this.j),A(this,r)}),this.g.attachEmptyPacketListener("category_mask",s=>{this.categoryMask=void 0,A(this,s)})),X(t,"quality_scores"),z(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(s,r)=>{this.qualityScores=s,A(this,r)}),this.g.attachEmptyPacketListener("quality_scores",s=>{this.categoryMask=void 0,A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ge.prototype.getLabels=Ge.prototype.Da,Ge.prototype.segmentForVideo=Ge.prototype.Ma,Ge.prototype.segment=Ge.prototype.segment,Ge.prototype.setOptions=Ge.prototype.o,Ge.createFromModelPath=function(t,e){return $(Ge,t,{baseOptions:{modelAssetPath:e}})},Ge.createFromModelBuffer=function(t,e){return $(Ge,t,{baseOptions:{modelAssetBuffer:e}})},Ge.createFromOptions=function(t,e){return $(Ge,t,e)};var Ka=class{constructor(t,e,n){this.confidenceMasks=t,this.categoryMask=e,this.qualityScores=n}close(){var t,e;(t=this.confidenceMasks)==null||t.forEach(n=>{n.close()}),(e=this.categoryMask)==null||e.close()}};Ka.prototype.close=Ka.prototype.close;var zE=class extends k{constructor(t){super(t)}},$n=[0,Ee,-2],Bi=[0,Vt,-3,fe,Vt,-1],Zu=[0,Bi],ed=[0,Bi,Ee,-1],oa=class extends k{constructor(t){super(t)}},td=[0,Vt,-1,fe],KE=class extends k{constructor(t){super(t)}},nd=class extends k{constructor(t){super(t)}},Ya=[1,2,3,4,5,6,7,8,9,10,14,15],Ug=class extends k{constructor(t){super(t)}};Ug.prototype.g=_o([0,Re,[0,Ya,ee,Bi,ee,[0,Bi,$n],ee,Zu,ee,[0,Zu,$n],ee,td,ee,[0,Vt,-3,fe,gt],ee,[0,Vt,-3,fe],ee,[0,Q,Vt,-2,fe,Ee,fe,-1,2,Vt,$n],ee,ed,ee,[0,ed,$n],Vt,$n,Q,ee,[0,Vt,-3,fe,$n,-1],ee,[0,Re,td]],Q,[0,Q,Ee,-1,fe]]);var Ot=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Pl,this.s=new vg,L(this.h,0,3,this.s),L(t=this.h,0,1,e=new pe)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}segment(t,e,n,s){const r=typeof n!="function"?n:{};this.j=typeof n=="function"?n:s,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.B+1,s=new Ug;const i=new nd;var o=new zE;if(Ft(o,1,255),L(i,0,12,o),e.keypoint&&e.scribble)throw Error("Cannot provide both keypoint and scribble.");if(e.keypoint){var a=new oa;Er(a,3,!0),N(a,1,e.keypoint.x),N(a,2,e.keypoint.y),sr(i,5,Ya,a)}else{if(!e.scribble)throw Error("Must provide either a keypoint or a scribble.");for(a of(o=new KE,e.scribble))Er(e=new oa,3,!0),N(e,1,a.x),N(e,2,a.y),Di(o,1,oa,e);sr(i,15,Ya,o)}Di(s,1,nd,i),this.g.addProtoToStream(s.g(),"drishti.RenderData","roi_in",n),yt(this,t,r);e:{try{const l=new Ka(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var c=l;break e}this.j(l)}finally{bo(this)}c=void 0}return c}m(){var t=new Xe;ue(t,"image_in"),ue(t,"roi_in"),ue(t,"norm_rect_in");const e=new rt;Ct(e,bg,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),ce(n,"IMAGE:image_in"),ce(n,"ROI:roi_in"),ce(n,"NORM_RECT:norm_rect_in"),n.o(e),at(t,n),wo(this,t),this.outputConfidenceMasks&&(X(t,"confidence_masks"),z(n,"CONFIDENCE_MASKS:confidence_masks"),Es(this,"confidence_masks"),this.g.ca("confidence_masks",(s,r)=>{this.confidenceMasks=s.map(i=>bs(this,i,!0,!this.j)),A(this,r)}),this.g.attachEmptyPacketListener("confidence_masks",s=>{this.confidenceMasks=[],A(this,s)})),this.outputCategoryMask&&(X(t,"category_mask"),z(n,"CATEGORY_MASK:category_mask"),Es(this,"category_mask"),this.g.U("category_mask",(s,r)=>{this.categoryMask=bs(this,s,!1,!this.j),A(this,r)}),this.g.attachEmptyPacketListener("category_mask",s=>{this.categoryMask=void 0,A(this,s)})),X(t,"quality_scores"),z(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(s,r)=>{this.qualityScores=s,A(this,r)}),this.g.attachEmptyPacketListener("quality_scores",s=>{this.categoryMask=void 0,A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ot.prototype.segment=Ot.prototype.segment,Ot.prototype.setOptions=Ot.prototype.o,Ot.createFromModelPath=function(t,e){return $(Ot,t,{baseOptions:{modelAssetPath:e}})},Ot.createFromModelBuffer=function(t,e){return $(Ot,t,{baseOptions:{modelAssetBuffer:e}})},Ot.createFromOptions=function(t,e){return $(Ot,t,e)};var ht=class extends Ye{constructor(t,e){super(new _t(t,e),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},L(t=this.h=new Tg,0,1,e=new pe)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?ae(this.h,2,ks(t.displayNamesLocale)):"displayNamesLocale"in t&&ae(this.h,2),t.maxResults!==void 0?Ft(this.h,3,t.maxResults):"maxResults"in t&&ae(this.h,3),t.scoreThreshold!==void 0?N(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&ae(this.h,4),t.categoryAllowlist!==void 0?Pi(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&ae(this.h,5),t.categoryDenylist!==void 0?Pi(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&ae(this.h,6),this.l(t)}D(t,e){return this.j={detections:[]},yt(this,t,e),this.j}F(t,e,n){return this.j={detections:[]},Bt(this,t,n,e),this.j}m(){var t=new Xe;ue(t,"input_frame_gpu"),ue(t,"norm_rect"),X(t,"detections");const e=new rt;Ct(e,BE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),ce(n,"IMAGE:input_frame_gpu"),ce(n,"NORM_RECT:norm_rect"),z(n,"DETECTIONS:detections"),n.o(e),at(t,n),this.g.attachProtoVectorListener("detections",(s,r)=>{for(const i of s)s=Zm(i),this.j.detections.push(Sg(s));A(this,r)}),this.g.attachEmptyPacketListener("detections",s=>{A(this,s)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ht.prototype.detectForVideo=ht.prototype.F,ht.prototype.detect=ht.prototype.D,ht.prototype.setOptions=ht.prototype.o,ht.createFromModelPath=async function(t,e){return $(ht,t,{baseOptions:{modelAssetPath:e}})},ht.createFromModelBuffer=function(t,e){return $(ht,t,{baseOptions:{modelAssetBuffer:e}})},ht.createFromOptions=function(t,e){return $(ht,t,e)};var Xa=class{constructor(t,e,n){this.landmarks=t,this.worldLandmarks=e,this.segmentationMasks=n}close(){var t;(t=this.segmentationMasks)==null||t.forEach(e=>{e.close()})}};function sd(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function rd(t){try{const e=new Xa(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.s)return e;t.s(e)}finally{bo(t)}}Xa.prototype.close=Xa.prototype.close;var tt=class extends Ye{constructor(t,e){super(new _t(t,e),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,L(t=this.h=new Cg,0,1,e=new pe),this.v=new gg,L(this.h,0,3,this.v),this.j=new mg,L(this.h,0,2,this.j),Ft(this.j,4,1),N(this.j,2,.5),N(this.v,2,.5),N(this.h,4,.5)}get baseOptions(){return Y(this.h,pe,1)}set baseOptions(t){L(this.h,0,1,t)}o(t){return"numPoses"in t&&Ft(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&N(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&N(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&N(this.v,2,t.minPosePresenceConfidence??.5),"outputSegmentationMasks"in t&&(this.outputSegmentationMasks=t.outputSegmentationMasks??!1),this.l(t)}D(t,e,n){const s=typeof e!="function"?e:{};return this.s=typeof e=="function"?e:n,sd(this),yt(this,t,s),rd(this)}F(t,e,n,s){const r=typeof n!="function"?n:{};return this.s=typeof n=="function"?n:s,sd(this),Bt(this,t,r,e),rd(this)}m(){var t=new Xe;ue(t,"image_in"),ue(t,"norm_rect"),X(t,"normalized_landmarks"),X(t,"world_landmarks"),X(t,"segmentation_masks");const e=new rt;Ct(e,UE,this.h);const n=new Ve;ot(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),ce(n,"IMAGE:image_in"),ce(n,"NORM_RECT:norm_rect"),z(n,"NORM_LANDMARKS:normalized_landmarks"),z(n,"WORLD_LANDMARKS:world_landmarks"),n.o(e),at(t,n),wo(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(s,r)=>{this.landmarks=[];for(const i of s)s=Dr(i),this.landmarks.push(vo(s));A(this,r)}),this.g.attachEmptyPacketListener("normalized_landmarks",s=>{this.landmarks=[],A(this,s)}),this.g.attachProtoVectorListener("world_landmarks",(s,r)=>{this.worldLandmarks=[];for(const i of s)s=as(i),this.worldLandmarks.push(ir(s));A(this,r)}),this.g.attachEmptyPacketListener("world_landmarks",s=>{this.worldLandmarks=[],A(this,s)}),this.outputSegmentationMasks&&(z(n,"SEGMENTATION_MASK:segmentation_masks"),Es(this,"segmentation_masks"),this.g.ca("segmentation_masks",(s,r)=>{this.segmentationMasks=s.map(i=>bs(this,i,!0,!this.s)),A(this,r)}),this.g.attachEmptyPacketListener("segmentation_masks",s=>{this.segmentationMasks=[],A(this,s)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};tt.prototype.detectForVideo=tt.prototype.F,tt.prototype.detect=tt.prototype.D,tt.prototype.setOptions=tt.prototype.o,tt.createFromModelPath=function(t,e){return $(tt,t,{baseOptions:{modelAssetPath:e}})},tt.createFromModelBuffer=function(t,e){return $(tt,t,{baseOptions:{modelAssetBuffer:e}})},tt.createFromOptions=function(t,e){return $(tt,t,e)},tt.POSE_CONNECTIONS=Bg;function YE(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function XE(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function s(){return this instanceof s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(s){var r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:function(){return t[s]}})}),n}const JE={},QE=Object.freeze(Object.defineProperty({__proto__:null,default:JE},Symbol.toStringTag,{value:"Module"})),Jn=XE(QE);var Lt={exports:{}};const ZE="16.6.1",e4={version:ZE};var id;function t4(){if(id)return Lt.exports;id=1;const t=Jn,e=Jn,n=Jn,s=Jn,i=e4.version,o=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function a(_){const I={};let P=_.toString();P=P.replace(/\r\n?/mg,`
1635
1635
  `);let U;for(;(U=o.exec(P))!=null;){const me=U[1];let V=U[2]||"";V=V.trim();const te=V[0];V=V.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),te==='"'&&(V=V.replace(/\\n/g,`
1636
- `),V=V.replace(/\\r/g,"\r")),I[me]=V}return I}function c(_){_=_||{};const I=f(_);_.path=I;const P=C.configDotenv(_);if(!P.parsed){const te=new Error(`MISSING_DATA: Cannot parse ${I} for an unknown reason`);throw te.code="MISSING_DATA",te}const U=d(_).split(","),me=U.length;let V;for(let te=0;te<me;te++)try{const le=U[te].trim(),It=p(P,le);V=C.decrypt(It.ciphertext,It.key);break}catch(le){if(te+1>=me)throw le}return C.parse(V)}function l(_){console.log(`[dotenv@${i}][WARN] ${_}`)}function h(_){console.log(`[dotenv@${i}][DEBUG] ${_}`)}function u(_){console.log(`[dotenv@${i}] ${_}`)}function d(_){return _&&_.DOTENV_KEY&&_.DOTENV_KEY.length>0?_.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function p(_,I){let P;try{P=new URL(I)}catch(le){if(le.code==="ERR_INVALID_URL"){const It=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw It.code="INVALID_DOTENV_KEY",It}throw le}const U=P.password;if(!U){const le=new Error("INVALID_DOTENV_KEY: Missing key part");throw le.code="INVALID_DOTENV_KEY",le}const me=P.searchParams.get("environment");if(!me){const le=new Error("INVALID_DOTENV_KEY: Missing environment part");throw le.code="INVALID_DOTENV_KEY",le}const V=`DOTENV_VAULT_${me.toUpperCase()}`,te=_.parsed[V];if(!te){const le=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${V} in your .env.vault file.`);throw le.code="NOT_FOUND_DOTENV_ENVIRONMENT",le}return{ciphertext:te,key:U}}function f(_){let I=null;if(_&&_.path&&_.path.length>0)if(Array.isArray(_.path))for(const P of _.path)t.existsSync(P)&&(I=P.endsWith(".vault")?P:`${P}.vault`);else I=_.path.endsWith(".vault")?_.path:`${_.path}.vault`;else I=e.resolve(process.cwd(),".env.vault");return t.existsSync(I)?I:null}function g(_){return _[0]==="~"?e.join(n.homedir(),_.slice(1)):_}function E(_){const I=!!(_&&_.debug),P=_&&"quiet"in _?_.quiet:!0;(I||!P)&&u("Loading env from encrypted .env.vault");const U=C._parseVault(_);let me=process.env;return _&&_.processEnv!=null&&(me=_.processEnv),C.populate(me,U,_),{parsed:U}}function R(_){const I=e.resolve(process.cwd(),".env");let P="utf8";const U=!!(_&&_.debug),me=_&&"quiet"in _?_.quiet:!0;_&&_.encoding?P=_.encoding:U&&h("No encoding is specified. UTF-8 is used by default");let V=[I];if(_&&_.path)if(!Array.isArray(_.path))V=[g(_.path)];else{V=[];for(const en of _.path)V.push(g(en))}let te;const le={};for(const en of V)try{const Je=C.parse(t.readFileSync(en,{encoding:P}));C.populate(le,Je,_)}catch(Je){U&&h(`Failed to load ${en} ${Je.message}`),te=Je}let It=process.env;if(_&&_.processEnv!=null&&(It=_.processEnv),C.populate(It,le,_),U||!me){const en=Object.keys(le).length,Je=[];for(const th of V)try{const Br=e.relative(process.cwd(),th);Je.push(Br)}catch(Br){U&&h(`Failed to load ${th} ${Br.message}`),te=Br}u(`injecting env (${en}) from ${Je.join(",")}`)}return te?{parsed:le,error:te}:{parsed:le}}function y(_){if(d(_).length===0)return C.configDotenv(_);const I=f(_);return I?C._configVault(_):(l(`You set DOTENV_KEY but you are missing a .env.vault file at ${I}. Did you forget to build it?`),C.configDotenv(_))}function S(_,I){const P=Buffer.from(I.slice(-64),"hex");let U=Buffer.from(_,"base64");const me=U.subarray(0,12),V=U.subarray(-16);U=U.subarray(12,-16);try{const te=s.createDecipheriv("aes-256-gcm",P,me);return te.setAuthTag(V),`${te.update(U)}${te.final()}`}catch(te){const le=te instanceof RangeError,It=te.message==="Invalid key length",en=te.message==="Unsupported state or unable to authenticate data";if(le||It){const Je=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw Je.code="INVALID_DOTENV_KEY",Je}else if(en){const Je=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw Je.code="DECRYPTION_FAILED",Je}else throw te}}function D(_,I,P={}){const U=!!(P&&P.debug),me=!!(P&&P.override);if(typeof I!="object"){const V=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw V.code="OBJECT_REQUIRED",V}for(const V of Object.keys(I))Object.prototype.hasOwnProperty.call(_,V)?(me===!0&&(_[V]=I[V]),U&&h(me===!0?`"${V}" is already defined and WAS overwritten`:`"${V}" is already defined and was NOT overwritten`)):_[V]=I[V]}const C={configDotenv:R,_configVault:E,_parseVault:c,config:y,decrypt:S,parse:a,populate:D};return Lt.exports.configDotenv=C.configDotenv,Lt.exports._configVault=C._configVault,Lt.exports._parseVault=C._parseVault,Lt.exports.config=C.config,Lt.exports.decrypt=C.decrypt,Lt.exports.parse=C.parse,Lt.exports.populate=C.populate,Lt.exports=C,Lt.exports}const n4="4.1.0",s4={version:n4};var aa,od;function r4(){if(od)return aa;od=1;const t=Jn,e=Jn,n=t4(),{version:s}=s4,r=".env[.node_env][.local]",i=/\[(\W*\blocal\b\W*)]/g,o=/\[(\W*\b)node_env(\b\W*)]/g;function a(y,S){let D=y;return D=D.replace(i,S&&S.local?"$1":""),D=D.replace(o,S&&S.node_env?`$1${S.node_env}$2`:""),D}function c(y={}){y.debug&&R("listing effective `.env*` files…");const{node_env:S,path:D=process.cwd(),pattern:C=r}=y,_=i.test(C),I={};if(C===r&&(I[".env.defaults"]=".env.defaults"),I[".env"]=a(C),_){const P=a(C,{local:!0});S!=="test"?I[".env.local"]=P:y.debug&&t.existsSync(e.resolve(D,P))&&R('[!] note that `%s` is being skipped for "test" environment',P)}return S&&o.test(C)&&(I[".env.node_env"]=a(C,{node_env:S}),_&&(I[".env.node_env.local"]=a(C,{node_env:S,local:!0}))),[".env.defaults",".env",".env.local",".env.node_env",".env.node_env.local"].reduce((P,U)=>{if(!I[U])return P;const me=e.resolve(D,I[U]);return t.existsSync(me)&&(y.debug&&R(">> %s",me),P.push(me)),P},[])}function l(y,S={}){if(typeof y=="string"){S.debug&&R('parsing "%s"…',y);const D=n.parse(t.readFileSync(y,S.encoding&&{encoding:S.encoding}));return S.debug&&Object.keys(D).forEach(C=>R(">> %s",C)),D}return y.reduce((D,C)=>{const _=l(C,S);return S.debug&&Object.keys(_).filter(I=>D.hasOwnProperty(I)).forEach(I=>R('`%s` is being overwritten by merge from "%s"',I,C)),Object.assign(D,_)},{})}function h(y,S={}){try{const D=l(y,{encoding:S.encoding,debug:S.debug});S.debug&&R("safe-merging parsed environment variables into `process.env`…");for(const C of Object.keys(D))process.env.hasOwnProperty(C)?S.debug&&process.env[C]!==D[C]&&R("environment variable `%s` is predefined and not being overwritten",C):(S.debug&&R(">> process.env.%s",C),process.env[C]=D[C]);return{parsed:D}}catch(D){return g(D,S)}}function u(y,S={}){const D=l(y,S);Object.keys(D).forEach(C=>{process.env[C]===D[C]&&delete process.env[C]})}function d(y={}){if(y.node_env)return y.debug&&R(`operating in "${y.node_env}" environment (set by \`options.node_env\`)`),y.node_env;if(process.env.NODE_ENV)return y.debug&&R(`operating in "${process.env.NODE_ENV}" environment (as per \`process.env.NODE_ENV\`)`),process.env.NODE_ENV;if(y.default_node_env)return y.debug&&R(`operating in "${y.default_node_env}" environment (taken from \`options.default_node_env\`)`),y.default_node_env;y.debug&&R('operating in "no environment" mode (no environment-related options are set)')}const p=["node_env","default_node_env","path","pattern","files","encoding","purge_dotenv","silent"];function f(y={}){y.debug&&(R("initializing…"),p.filter(C=>C in y).forEach(C=>R(`| options.${C} =`,y[C])));const{path:S=process.cwd(),pattern:D=r}=y;if(y.purge_dotenv){y.debug&&R("`options.purge_dotenv` is enabled, unloading potentially pre-loaded `.env`…");const C=e.resolve(S,".env");try{t.existsSync(C)&&u(C,{encoding:y.encoding})}catch(_){!y.silent&&E("unloading failed: ",_)}}try{let C;if(y.files)y.debug&&R("using explicit list of `.env*` files: %s…",y.files.join(", ")),C=y.files.reduce((I,P)=>{const U=e.resolve(S,P);return t.existsSync(U)?I.push(U):y.debug&&R(">> %s does not exist, skipping…",U),I},[]);else{const I=d(y);if(C=c({node_env:I,path:S,pattern:D,debug:y.debug}),C.length===0){const P=I?D.replace(o,`[$1${I}$2]`):D;return g(new Error(`no ".env*" files matching pattern "${P}" in "${S}" dir`),y)}}const _=h(C,{encoding:y.encoding,debug:y.debug,silent:y.silent});return y.debug&&R("initialization completed."),_}catch(C){return g(C,y)}}function g(y,S){return S.silent||E(`".env*" files loading failed: ${y.message||y}`),{error:y}}function E(y,S){S&&(y+=": %s"),console.warn(`[dotenv-flow@${s}]: ${y}`,S)}function R(y,...S){console.debug(`[dotenv-flow@${s}]: ${y}`,...S)}return aa={DEFAULT_PATTERN:r,listFiles:c,parse:l,load:h,unload:u,config:f},aa}var i4=r4();const o4=YE(i4),ca={BASE_URL:"/",DEV:!1,MODE:"staging",PROD:!0,SSR:!1,VITE_IS_DEV:"0",VITE_LOCAL_URL:"http://localhost:5001",VITE_SERVERLESS_URL:"https://backendv2-dev.nervoscan.com",VITE_SERVER_URL:"https://staging.backend.nervoscan.com"};var Od;typeof process<"u"&&process.env&&((Od=process.versions)!=null&&Od.node)&&o4.config();const zr=t=>typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:Qn&&Qn.tagName.toUpperCase()==="SCRIPT"&&Qn.src||new URL("nervoscan-js-sdk.cjs",document.baseURI).href}<"u"&&ca&&t in ca?ca[t]||"":typeof process<"u"&&process.env&&t in process.env?process.env[t]||"":(W.throwKnownError(v.EnvIncompatibleError),""),So=t=>zr("VITE_IS_DEV")==="1"?zr("VITE_LOCAL_URL"):zr(t==="serverless"?"VITE_SERVERLESS_URL":"VITE_SERVER_URL"),a4=t=>{let e=t.reduce((n,s)=>[n[0]+s[0],n[1]+s[1]],[0,0]);return e=[e[0]/t.length,e[1]/t.length],t.slice().sort((n,s)=>{const r=Math.atan2(n[1]-e[1],n[0]-e[0]),i=Math.atan2(s[1]-e[1],s[0]-e[0]);return r-i})},Vg=["bigForehead","smallForehead","leftCheek","rightCheek","cheeksNose","face"];function c4(t){return t==null||Number.isNaN(t)?"Unknown":t>=.8?"Excellent":t>=.65?"Good":t>=.45?"Fair":t>=.25?"Poor":"Reject"}function l4(){return{r:[],g:[],b:[],timestamps:[]}}function ad(){return Object.fromEntries(Vg.map(t=>[t,l4()]))}function jn(t,e){if(!(e.length<3)){t.beginPath(),t.moveTo(e[0][0],e[0][1]);for(let n=1;n<e.length;n++)t.lineTo(e[n][0],e[n][1]);t.closePath(),t.stroke()}}function qn(t,e,n,s,r){const i=t[e],o=(s-r)/1e3;if(i.timestamps.length>0){const a=i.timestamps[i.timestamps.length-1];if(o<=a){T.warn(`Timestamp inconsistency detected in ${e}: ${o} <= ${a}`);return}}i.r.push(n[0]),i.g.push(n[1]),i.b.push(n[2]),i.timestamps.push(o)}function zn(t,e,n,s,r){if(!t||t.length<3)return 0;let i=0;const o=t.length;for(let a=0;a<o;a++){const c=(a+1)%o;i+=t[a][0]*t[c][1],i-=t[c][0]*t[a][1]}return Math.abs(i)/2}function cd(t,e,n,s,r){let i="ALIGNED";const u=s/640,d=r/480,p=u*d,f=19e3*p,g=5e4*p,E=800*p;return t<f?i="TOO_FAR":t>g?i="TOO_CLOSE":e<E?i="LOOKING_LEFT":n<E&&(i="LOOKING_RIGHT"),i}const h4=[[67,109],[109,10],[10,338],[338,297],[66,107],[107,9],[9,336],[336,296],[67,69],[69,66],[297,299],[299,296]],u4=[[109,10],[10,338],[338,337],[337,151],[151,108],[108,109]],d4=[[345,352],[352,376],[376,433],[433,416],[416,436],[436,426],[426,423],[423,266],[266,330],[330,347],[347,346],[346,345]],f4=[[116,123],[123,147],[147,213],[213,192],[192,216],[216,206],[206,203],[203,36],[36,101],[101,118],[118,117],[117,116]],p4=[[118,50],[50,216],[216,2],[2,436],[436,280],[280,347],[347,6],[6,118]],m4=[[103,67],[67,109],[109,10],[10,338],[338,297],[297,332],[332,298],[298,300],[300,383],[383,372],[372,345],[345,352],[352,411],[411,427],[427,436],[436,322],[322,2],[2,92],[92,216],[216,207],[207,187],[187,123],[123,116],[116,143],[143,156],[156,70],[70,68],[68,103]];function Ps(t){const e=new Set;for(const n of t)e.add(n[0]),e.add(n[1]);return Array.from(e)}const g4=Ps(h4),_4=Ps(u4),ld=Ps(d4),hd=Ps(f4),y4=Ps(p4),ud=Ps(m4);class E4{constructor(e){w(this,"wasmUrl","https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.3/wasm");w(this,"modelUrl","https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task");w(this,"assetConfig",{});w(this,"faceLandmarker");w(this,"canvasCtx");w(this,"video");w(this,"videoWidth");w(this,"canvas");w(this,"drawingUtils");w(this,"rgbDataBuffer");w(this,"alignmentStatusCallback");w(this,"startTimeMs",0);w(this,"backendRepository");w(this,"isDetectionActive",!1);w(this,"mediaPipeTimestamp",0);w(this,"lastVideoTime",0);w(this,"videoTimeOffset",0);w(this,"timestampAdjustmentCount",0);w(this,"dataCollectionThreshold",500);w(this,"batchCount",0);w(this,"totalFramesProcessed",0);w(this,"isStreamingActive",!1);w(this,"pendingResults",[]);w(this,"finalResultsCallback");w(this,"mediaPipeTimingData",{capture:[],mlDetection:[],rgbCalc:[],dataStorage:[],alignment:[]});w(this,"faceDetectionLoop",async()=>{const e=async()=>{if(this.isDetectionActive){try{await this.predictAlignmentOnly()}catch(n){T.warn("Face detection error:",n)}setTimeout(e,200)}};e()});this.videoWidth=640,e&&(this.assetConfig=e)}async probeUrl(e,n){try{const s=new AbortController,r=setTimeout(()=>s.abort(),Math.max(1e3,n)),i=await fetch(e,{method:"HEAD",signal:s.signal});return clearTimeout(r),!!i.ok}catch{return!1}}normalizeWasmBase(e){return e.replace(/\/+$/,"")}async resolveAssetUrls(){const e="https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.3/wasm",n="https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task",s=this.assetConfig.timeoutMs??2500,r=this.assetConfig.wasmBaseUrl?this.normalizeWasmBase(this.assetConfig.wasmBaseUrl):void 0,i=this.assetConfig.modelAssetPath,o=this.normalizeWasmBase(e),a=n,c=[{wasm:r,model:i??a,tag:"configured"},{wasm:o,model:a,tag:"cdn"}];for(const l of c){if(!l.wasm||!l.model)continue;const h=await this.probeUrl(`${l.wasm}/vision_wasm_internal.js`,s),u=await this.probeUrl(l.model,s);if(h&&u)return T.log(`[MediaPipe] Assets resolved via ${l.tag}: wasmBase=${l.wasm}`),{wasmBaseUrl:l.wasm,modelUrl:l.model};T.log(`[MediaPipe] ${l.tag} assets probe failed (wasm=${h}, model=${u}). Trying next...`)}return T.log("[MediaPipe] Falling back to CDN assets without successful probe."),{wasmBaseUrl:o,modelUrl:a}}calculateTimingStats(e){if(e.length===0)return{min:0,max:0,avg:0,total:0};let n=1/0,s=-1/0,r=0;for(const i of e)i<n&&(n=i),i>s&&(s=i),r+=i;return{min:n,max:s,avg:r/e.length,total:r}}getTimingBreakdown(){return{capture:this.calculateTimingStats(this.mediaPipeTimingData.capture),mlDetection:this.calculateTimingStats(this.mediaPipeTimingData.mlDetection),rgbCalc:this.calculateTimingStats(this.mediaPipeTimingData.rgbCalc),dataStorage:this.calculateTimingStats(this.mediaPipeTimingData.dataStorage),alignment:this.calculateTimingStats(this.mediaPipeTimingData.alignment)}}resetTimingData(){this.mediaPipeTimingData={capture:[],mlDetection:[],rgbCalc:[],dataStorage:[],alignment:[]}}setStartTimeMs(e){this.startTimeMs=e}setDataCollectionThreshold(e){if(e<=0)throw new Error("Data collection threshold must be greater than 0");this.dataCollectionThreshold=e,T.log(`[RGB] Data collection threshold set to ${e} points`)}startContinuousDataCollection(e,n){T.log(`[FaceLandmarker] Starting continuous data collection (threshold: ${this.dataCollectionThreshold})`),this.isStreamingActive=!0,this.batchCount=0,this.totalFramesProcessed=0,this.pendingResults=[],this.finalResultsCallback=n}stopContinuousDataCollection(){this.isStreamingActive=!1,T.log(`[FaceLandmarker] Stopped. Processed ${this.totalFramesProcessed} frames in ${this.batchCount} batches`),this.pendingResults.length>0&&this.aggregateFinalResults()}async initialize(e,n){if(this.backendRepository=n,await this.createFaceLandmarker(),this.video=e,this.canvas=document.createElement("canvas"),this.canvas.width=e.videoWidth||640,this.canvas.height=e.videoHeight||480,T.log(`[RGB] Initial canvas resolution: ${this.canvas.width}x${this.canvas.height}`),this.canvasCtx=this.canvas.getContext("2d",{willReadFrequently:!0}),!this.canvasCtx)throw new Error("Failed to get canvas context");this.drawingUtils=new De(this.canvasCtx),this.rgbDataBuffer=ad(),this.resetTimingData()}setAlignmentStatusCallback(e){this.alignmentStatusCallback=e}startFaceDetection(){this.isDetectionActive=!0,this.faceDetectionLoop()}stopFaceDetection(){this.isDetectionActive=!1}generateMediaPipeTimestamp(){if(!this.video)return this.mediaPipeTimestamp;const e=this.video.currentTime;e<this.lastVideoTime&&(this.videoTimeOffset+=this.lastVideoTime,T.log(`Video time reset detected. New offset: ${this.videoTimeOffset.toFixed(3)}s`));const n=(e+this.videoTimeOffset)*1e3;if(n<=this.mediaPipeTimestamp){const s=this.mediaPipeTimestamp+1;this.timestampAdjustmentCount++,this.timestampAdjustmentCount%100===0&&T.log(`MediaPipe ts adjusted: ${n.toFixed(1)} → ${s.toFixed(1)} (#${this.timestampAdjustmentCount})`),this.mediaPipeTimestamp=s}else this.mediaPipeTimestamp=n;return this.lastVideoTime=e,this.mediaPipeTimestamp}resetMediaPipeTimestamps(){T.log(`MediaPipe timestamps reset (was: ${this.mediaPipeTimestamp}ms, adjustments: ${this.timestampAdjustmentCount})`),this.mediaPipeTimestamp=0,this.lastVideoTime=0,this.videoTimeOffset=0,this.timestampAdjustmentCount=0}async createFaceLandmarker(){const e=await this.resolveAssetUrls();this.wasmUrl=e.wasmBaseUrl,this.modelUrl=e.modelUrl;const n=await bn.forVisionTasks(this.wasmUrl),s=this.assetConfig.delegate??"GPU";T.log(`[MediaPipe] Creating FaceLandmarker with ${s} delegate`),this.faceLandmarker=await ne.createFromOptions(n,{baseOptions:{modelAssetPath:this.modelUrl,delegate:s},outputFaceBlendshapes:!1,runningMode:"VIDEO",numFaces:1})}getLandmarkCoordinates(e,n,s,r){const i=[];for(const o of n)if(e[0]&&o<e[0].length){const a=e[0][o];i.push([Math.round(a.x*s),Math.round(a.y*r)])}return i.length>0?a4(i):[]}calculateRgbMean(e,n,s,r){if(e.length<3||s<=0||r<=0)return[0,0,0];const i=this.getBoundingBox(e),o=Math.max(0,Math.floor(i.minX)),a=Math.min(s-1,Math.ceil(i.maxX)),c=Math.max(0,Math.floor(i.minY)),l=Math.min(r-1,Math.ceil(i.maxY));if(o>=a||c>=l)return[0,0,0];let h=0,u=0,d=0,p=0;for(let f=c;f<=l;f++)for(let g=o;g<=a;g++)if(this.isPointInPolygon(g,f,e)){const E=(f*s+g)*4;u+=n.data[E],d+=n.data[E+1],p+=n.data[E+2],h++}return h>0?[Math.round(u/h),Math.round(d/h),Math.round(p/h)]:[0,0,0]}getBoundingBox(e){let n=1/0,s=-1/0,r=1/0,i=-1/0;for(const[o,a]of e)o<n&&(n=o),o>s&&(s=o),a<r&&(r=a),a>i&&(i=a);return{minX:n,maxX:s,minY:r,maxY:i}}isPointInPolygon(e,n,s){let r=!1;const i=s.length;for(let o=0,a=i-1;o<i;a=o++){const c=s[o][0],l=s[o][1],h=s[a][0],u=s[a][1];l>n!=u>n&&e<(h-c)*(n-l)/(u-l)+c&&(r=!r)}return r}async predictAlignmentOnly(){if(!this.canvasCtx||!this.video||!this.video.videoWidth||!this.video.videoHeight||this.video.readyState<2||!this.faceLandmarker)return;const e=this.generateMediaPipeTimestamp();let n;try{n=this.faceLandmarker.detectForVideo(this.video,e)}catch(s){if(s instanceof Error&&s.message.includes("timestamp mismatch")){T.warn("MediaPipe timestamp error in alignment, recovering..."),this.mediaPipeTimestamp+=100,this.timestampAdjustmentCount++;try{n=this.faceLandmarker.detectForVideo(this.video,this.mediaPipeTimestamp)}catch(r){T.error("MediaPipe recovery failed in alignment:",r);return}}else throw s}if(n.faceLandmarks&&n.faceLandmarks.length>0){const s=this.video.videoWidth,r=this.video.videoHeight,i=this.getLandmarkCoordinates(n.faceLandmarks,ud,s,r),o=this.getLandmarkCoordinates(n.faceLandmarks,ld,s,r),a=this.getLandmarkCoordinates(n.faceLandmarks,hd,s,r),c=zn(i),l=zn(o),h=zn(a),u=cd(c,l,h,s,r);this.alignmentStatusCallback&&this.alignmentStatusCallback(u)}else this.alignmentStatusCallback&&this.alignmentStatusCallback("NO_FACE")}captureAndProcess(e,n){this.stopFaceDetection();const s=this.checkDataCollectionStatus(e);if(!this.canvasCtx||!this.video||this.video.readyState<2||!this.video.videoWidth||!this.video.videoHeight)return s;const r=this.video.videoWidth,i=this.video.videoHeight;if(this.canvas.width!==r||this.canvas.height!==i){this.canvas.width=r,this.canvas.height=i;const u=i/r;this.canvas.style.width=this.videoWidth+"px",this.canvas.style.height=this.videoWidth*u+"px",this.drawingUtils=new De(this.canvasCtx),T.log(`[RGB] Canvas resized to ${r}x${i}`)}const o=performance.now();this.canvasCtx.drawImage(this.video,0,0,r,i);const a=this.canvasCtx.getImageData(0,0,r,i);this.mediaPipeTimingData.capture.push(performance.now()-o),this.canvasCtx.clearRect(0,0,r,i),this.faceLandmarker||W.throwKnownError(v.FaceLandmarkerNotInitializedError);const c=performance.now(),l=this.generateMediaPipeTimestamp();let h;try{h=this.faceLandmarker.detectForVideo(this.video,l)}catch(u){if(u instanceof Error&&u.message.includes("timestamp mismatch")){T.warn("[RGB] MediaPipe timestamp mismatch, recovering..."),this.mediaPipeTimestamp+=100,this.timestampAdjustmentCount++;try{h=this.faceLandmarker.detectForVideo(this.video,this.mediaPipeTimestamp)}catch(d){return T.error("[RGB] MediaPipe recovery failed, skipping frame:",d),s}}else return T.error("[RGB] MediaPipe detection error:",u),s}if(this.mediaPipeTimingData.mlDetection.push(performance.now()-c),h.faceLandmarks&&h.faceLandmarks.length>0){this.rgbDataBuffer.bigForehead.r.length%100===0&&T.log(`[RGB] Frame ${this.rgbDataBuffer.bigForehead.r.length} at ${r}x${i}`),this.drawFaceLandmarks(this.drawingUtils,h.faceLandmarks);const u=this.getLandmarkCoordinates(h.faceLandmarks,g4,r,i),d=this.getLandmarkCoordinates(h.faceLandmarks,_4,r,i),p=this.getLandmarkCoordinates(h.faceLandmarks,ld,r,i),f=this.getLandmarkCoordinates(h.faceLandmarks,hd,r,i),g=this.getLandmarkCoordinates(h.faceLandmarks,y4,r,i),E=this.getLandmarkCoordinates(h.faceLandmarks,ud,r,i);this.canvasCtx.strokeStyle="rgba(255, 255, 255, 0.7)",this.canvasCtx.lineWidth=1,jn(this.canvasCtx,u),jn(this.canvasCtx,d),jn(this.canvasCtx,p),jn(this.canvasCtx,f),jn(this.canvasCtx,g),jn(this.canvasCtx,E);const R=performance.now(),y=this.calculateRgbMean(u,a,r,i),S=this.calculateRgbMean(d,a,r,i),D=this.calculateRgbMean(p,a,r,i),C=this.calculateRgbMean(f,a,r,i),_=this.calculateRgbMean(g,a,r,i),I=this.calculateRgbMean(E,a,r,i);this.mediaPipeTimingData.rgbCalc.push(performance.now()-R);const P=performance.now();s&&(qn(this.rgbDataBuffer,"bigForehead",y,n,this.startTimeMs),qn(this.rgbDataBuffer,"smallForehead",S,n,this.startTimeMs),qn(this.rgbDataBuffer,"leftCheek",D,n,this.startTimeMs),qn(this.rgbDataBuffer,"rightCheek",C,n,this.startTimeMs),qn(this.rgbDataBuffer,"cheeksNose",_,n,this.startTimeMs),qn(this.rgbDataBuffer,"face",I,n,this.startTimeMs)),this.mediaPipeTimingData.dataStorage.push(performance.now()-P);const U=performance.now(),me=zn(E),V=zn(p),te=zn(f),le=cd(me,V,te,r,i);this.alignmentStatusCallback&&this.alignmentStatusCallback(le),this.mediaPipeTimingData.alignment.push(performance.now()-U)}else this.alignmentStatusCallback&&this.alignmentStatusCallback("NO_FACE");return s}drawFaceLandmarks(e,n){for(const s of n)e.drawConnectors(s,ne.FACE_LANDMARKS_FACE_OVAL,{color:"#E0E0E0"}),e.drawConnectors(s,ne.FACE_LANDMARKS_RIGHT_EYE,{color:"#FF3030"}),e.drawConnectors(s,ne.FACE_LANDMARKS_LEFT_EYE,{color:"#30FF30"}),e.drawConnectors(s,ne.FACE_LANDMARKS_LIPS,{color:"#E0E0E0"})}checkDataCollectionStatus(e){var s,r,i,o;let n=!0;return this.rgbDataBuffer.bigForehead.r.length>=this.dataCollectionThreshold?(this.batchCount++,this.totalFramesProcessed+=this.rgbDataBuffer.bigForehead.r.length,T.log(`[RGB] Sending batch ${this.batchCount} (${this.dataCollectionThreshold} pts, ${((s=this.video)==null?void 0:s.videoWidth)||0}x${((r=this.video)==null?void 0:r.videoHeight)||0})`),this.backendRepository.sendRgbDataToBackend(this.rgbDataBuffer,((i=this.video)==null?void 0:i.videoWidth)||0,((o=this.video)==null?void 0:o.videoHeight)||0,e),this.resetDataBuffer(),n=this.isStreamingActive,T.log(`[RGB] ${n?`Continuing for batch ${this.batchCount+1}`:"Stopping collection"}`)):this.rgbDataBuffer.bigForehead.r.length%50===0&&T.log(`[RGB] Buffer: ${this.rgbDataBuffer.bigForehead.r.length}/${this.dataCollectionThreshold}`),n}getRGBDataBufferSize(){var e,n,s;return((s=(n=(e=this.rgbDataBuffer)==null?void 0:e.bigForehead)==null?void 0:n.r)==null?void 0:s.length)||0}getDataCollectionThreshold(){return this.dataCollectionThreshold}getRGBTimestamps(){var e,n;return((n=(e=this.rgbDataBuffer)==null?void 0:e.bigForehead)==null?void 0:n.timestamps)||[]}isDetectionCurrentlyActive(){return this.isDetectionActive}aggregateFinalResults(){if(this.pendingResults.length===0){T.warn("[FaceLandmarker] No pending results to aggregate");return}T.log(`[FaceLandmarker] Aggregating ${this.pendingResults.length} batch results`);const e={},n=["HR","RR","SDNN","SPO2","DBP","SBP","GLUCOSE","HEMOGLOBIN","AGE","HEALTHSCORE","PNN50","RMSSD"];for(const s of n){const r=this.pendingResults.map(i=>i[s]).filter(i=>i!=null&&!isNaN(i));r.length>0&&(e[s]=Math.round(r.reduce((i,o)=>i+o,0)/r.length*100)/100)}e.batchCount=this.batchCount,e.totalFramesProcessed=this.totalFramesProcessed,e.aggregatedFrom=this.pendingResults.length,T.log("[FaceLandmarker] Aggregated results:",e),this.finalResultsCallback&&this.finalResultsCallback(e)}handleBatchResults(e){if(!this.isStreamingActive){T.warn("[FaceLandmarker] Received batch results but continuous collection is not active");return}this.pendingResults.push(e),T.log(`[FaceLandmarker] Batch ${this.pendingResults.length} added. Total pending: ${this.pendingResults.length}`)}resetDataBuffer(){this.rgbDataBuffer=ad()}}const Tn=class Tn{constructor(){w(this,"faceLandmarker");w(this,"isCollectingData",!1);w(this,"videoElement");w(this,"apiKey","");w(this,"onAlignmentStatus");w(this,"captureLoopId",null);w(this,"frameInterval",1e3/30);w(this,"lastCaptureTime",0);w(this,"config",{targetFPS:30,mediapipe:{}});w(this,"frameCount",0);w(this,"totalFrameCount",0);w(this,"duplicateFrames",0);w(this,"startTime",0);w(this,"frameTimes",[]);w(this,"lastVideoTime",0);w(this,"maxFrameTimesSize",100);w(this,"minFrameTimeDelta",.001);w(this,"totalFrameTimes",[]);w(this,"isContinuousMode",!1)}static getInstance(){return Tn.instance||(Tn.instance=new Tn),Tn.instance}async initialize(e,n,s,r,i={}){this.config={...this.config,...i},this.frameInterval=1e3/this.config.targetFPS,this.videoElement=n,this.videoElement.srcObject=e,this.faceLandmarker||(this.faceLandmarker=new E4(this.config.mediapipe),this.faceLandmarker.setDataCollectionThreshold(300)),await this.faceLandmarker.initialize(this.videoElement,s),this.onAlignmentStatus&&this.faceLandmarker.setAlignmentStatusCallback(this.onAlignmentStatus),T.log("[RGBManager] Initialized:",this.config),T.log(`[RGBManager] Video: ${n.videoWidth}x${n.videoHeight}`)}startFaceDetection(){this.faceLandmarker&&(T.log("[RGBManager] Starting face detection..."),this.faceLandmarker.startFaceDetection())}stopFaceDetection(){this.faceLandmarker&&(T.log("[RGBManager] Stopping face detection..."),this.faceLandmarker.stopFaceDetection())}setAlignmentStatusCallback(e){this.onAlignmentStatus=e,this.faceLandmarker&&this.faceLandmarker.setAlignmentStatusCallback(e)}async startStreaming(e){this.isCollectingData=!0,this.apiKey=e,this.resetStatistics(),T.log(`[RGBManager] Starting streaming at ${this.config.targetFPS} FPS`),this.faceLandmarker.setStartTimeMs(performance.now()),this.isContinuousMode&&this.faceLandmarker&&this.faceLandmarker.startContinuousDataCollection(e),this.startCaptureLoop()}startCaptureLoop(){const e=n=>{if(!this.isCollectingData){this.captureLoopId=null;return}n-this.lastCaptureTime>=this.frameInterval&&(this.lastCaptureTime=n,this.runCaptureTick(n)),this.captureLoopId=requestAnimationFrame(e)};this.captureLoopId=requestAnimationFrame(e)}runCaptureTick(e){if(!this.videoElement)return;const n=this.videoElement.currentTime;if(n-this.lastVideoTime<this.minFrameTimeDelta){this.duplicateFrames++;return}this.lastVideoTime=n,this.frameCount++,this.totalFrameCount++,this.frameTimes.push(e),this.frameTimes.length>this.maxFrameTimesSize&&this.frameTimes.shift();const s=performance.now();try{const r=this.isCollectingData;this.isCollectingData=this.faceLandmarker.captureAndProcess(this.apiKey,n*1e3),r!==this.isCollectingData&&T.log(`[RGBManager] isCollectingData: ${r} → ${this.isCollectingData} (continuous=${this.isContinuousMode})`);const i=performance.now()-s;this.totalFrameTimes.push(i),this.frameCount%100===0&&T.log(`📊 [Progress] Frame ${this.frameCount} — ${i.toFixed(1)}ms`)}catch(r){const i=performance.now()-s;this.totalFrameTimes.push(i),T.error(`❌ [Frame ${this.frameCount}] Error after ${i.toFixed(2)}ms:`,r)}}resetStatistics(){this.startTime=performance.now(),this.frameCount=0,this.duplicateFrames=0,this.frameTimes=[],this.totalFrameTimes=[],this.lastVideoTime=0,this.lastCaptureTime=0}stopStreaming(){this.isCollectingData=!1,this.captureLoopId!==null&&(cancelAnimationFrame(this.captureLoopId),this.captureLoopId=null),this.isContinuousMode&&this.faceLandmarker&&this.faceLandmarker.stopContinuousDataCollection(),this.logFinalStatistics()}calculateTimingStats(e){if(e.length===0)return{min:0,max:0,avg:0,total:0};let n=1/0,s=-1/0,r=0;for(const i of e)i<n&&(n=i),i>s&&(s=i),r+=i;return{min:n,max:s,avg:r/e.length,total:r}}logFinalStatistics(){var i,o;const e=this.getFrameStatistics();if(e.frameCount===0){T.log("[RGBManager] No frames processed.");return}const s=this.calculateTimingStats(this.totalFrameTimes).avg,r=(o=(i=this.faceLandmarker)==null?void 0:i.getTimingBreakdown)==null?void 0:o.call(i);T.log(`
1636
+ `),V=V.replace(/\\r/g,"\r")),I[me]=V}return I}function c(_){_=_||{};const I=f(_);_.path=I;const P=C.configDotenv(_);if(!P.parsed){const te=new Error(`MISSING_DATA: Cannot parse ${I} for an unknown reason`);throw te.code="MISSING_DATA",te}const U=d(_).split(","),me=U.length;let V;for(let te=0;te<me;te++)try{const le=U[te].trim(),It=p(P,le);V=C.decrypt(It.ciphertext,It.key);break}catch(le){if(te+1>=me)throw le}return C.parse(V)}function l(_){console.log(`[dotenv@${i}][WARN] ${_}`)}function h(_){console.log(`[dotenv@${i}][DEBUG] ${_}`)}function u(_){console.log(`[dotenv@${i}] ${_}`)}function d(_){return _&&_.DOTENV_KEY&&_.DOTENV_KEY.length>0?_.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function p(_,I){let P;try{P=new URL(I)}catch(le){if(le.code==="ERR_INVALID_URL"){const It=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw It.code="INVALID_DOTENV_KEY",It}throw le}const U=P.password;if(!U){const le=new Error("INVALID_DOTENV_KEY: Missing key part");throw le.code="INVALID_DOTENV_KEY",le}const me=P.searchParams.get("environment");if(!me){const le=new Error("INVALID_DOTENV_KEY: Missing environment part");throw le.code="INVALID_DOTENV_KEY",le}const V=`DOTENV_VAULT_${me.toUpperCase()}`,te=_.parsed[V];if(!te){const le=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${V} in your .env.vault file.`);throw le.code="NOT_FOUND_DOTENV_ENVIRONMENT",le}return{ciphertext:te,key:U}}function f(_){let I=null;if(_&&_.path&&_.path.length>0)if(Array.isArray(_.path))for(const P of _.path)t.existsSync(P)&&(I=P.endsWith(".vault")?P:`${P}.vault`);else I=_.path.endsWith(".vault")?_.path:`${_.path}.vault`;else I=e.resolve(process.cwd(),".env.vault");return t.existsSync(I)?I:null}function g(_){return _[0]==="~"?e.join(n.homedir(),_.slice(1)):_}function E(_){const I=!!(_&&_.debug),P=_&&"quiet"in _?_.quiet:!0;(I||!P)&&u("Loading env from encrypted .env.vault");const U=C._parseVault(_);let me=process.env;return _&&_.processEnv!=null&&(me=_.processEnv),C.populate(me,U,_),{parsed:U}}function R(_){const I=e.resolve(process.cwd(),".env");let P="utf8";const U=!!(_&&_.debug),me=_&&"quiet"in _?_.quiet:!0;_&&_.encoding?P=_.encoding:U&&h("No encoding is specified. UTF-8 is used by default");let V=[I];if(_&&_.path)if(!Array.isArray(_.path))V=[g(_.path)];else{V=[];for(const en of _.path)V.push(g(en))}let te;const le={};for(const en of V)try{const Je=C.parse(t.readFileSync(en,{encoding:P}));C.populate(le,Je,_)}catch(Je){U&&h(`Failed to load ${en} ${Je.message}`),te=Je}let It=process.env;if(_&&_.processEnv!=null&&(It=_.processEnv),C.populate(It,le,_),U||!me){const en=Object.keys(le).length,Je=[];for(const th of V)try{const Br=e.relative(process.cwd(),th);Je.push(Br)}catch(Br){U&&h(`Failed to load ${th} ${Br.message}`),te=Br}u(`injecting env (${en}) from ${Je.join(",")}`)}return te?{parsed:le,error:te}:{parsed:le}}function y(_){if(d(_).length===0)return C.configDotenv(_);const I=f(_);return I?C._configVault(_):(l(`You set DOTENV_KEY but you are missing a .env.vault file at ${I}. Did you forget to build it?`),C.configDotenv(_))}function S(_,I){const P=Buffer.from(I.slice(-64),"hex");let U=Buffer.from(_,"base64");const me=U.subarray(0,12),V=U.subarray(-16);U=U.subarray(12,-16);try{const te=s.createDecipheriv("aes-256-gcm",P,me);return te.setAuthTag(V),`${te.update(U)}${te.final()}`}catch(te){const le=te instanceof RangeError,It=te.message==="Invalid key length",en=te.message==="Unsupported state or unable to authenticate data";if(le||It){const Je=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw Je.code="INVALID_DOTENV_KEY",Je}else if(en){const Je=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw Je.code="DECRYPTION_FAILED",Je}else throw te}}function D(_,I,P={}){const U=!!(P&&P.debug),me=!!(P&&P.override);if(typeof I!="object"){const V=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw V.code="OBJECT_REQUIRED",V}for(const V of Object.keys(I))Object.prototype.hasOwnProperty.call(_,V)?(me===!0&&(_[V]=I[V]),U&&h(me===!0?`"${V}" is already defined and WAS overwritten`:`"${V}" is already defined and was NOT overwritten`)):_[V]=I[V]}const C={configDotenv:R,_configVault:E,_parseVault:c,config:y,decrypt:S,parse:a,populate:D};return Lt.exports.configDotenv=C.configDotenv,Lt.exports._configVault=C._configVault,Lt.exports._parseVault=C._parseVault,Lt.exports.config=C.config,Lt.exports.decrypt=C.decrypt,Lt.exports.parse=C.parse,Lt.exports.populate=C.populate,Lt.exports=C,Lt.exports}const n4="4.1.0",s4={version:n4};var aa,od;function r4(){if(od)return aa;od=1;const t=Jn,e=Jn,n=t4(),{version:s}=s4,r=".env[.node_env][.local]",i=/\[(\W*\blocal\b\W*)]/g,o=/\[(\W*\b)node_env(\b\W*)]/g;function a(y,S){let D=y;return D=D.replace(i,S&&S.local?"$1":""),D=D.replace(o,S&&S.node_env?`$1${S.node_env}$2`:""),D}function c(y={}){y.debug&&R("listing effective `.env*` files…");const{node_env:S,path:D=process.cwd(),pattern:C=r}=y,_=i.test(C),I={};if(C===r&&(I[".env.defaults"]=".env.defaults"),I[".env"]=a(C),_){const P=a(C,{local:!0});S!=="test"?I[".env.local"]=P:y.debug&&t.existsSync(e.resolve(D,P))&&R('[!] note that `%s` is being skipped for "test" environment',P)}return S&&o.test(C)&&(I[".env.node_env"]=a(C,{node_env:S}),_&&(I[".env.node_env.local"]=a(C,{node_env:S,local:!0}))),[".env.defaults",".env",".env.local",".env.node_env",".env.node_env.local"].reduce((P,U)=>{if(!I[U])return P;const me=e.resolve(D,I[U]);return t.existsSync(me)&&(y.debug&&R(">> %s",me),P.push(me)),P},[])}function l(y,S={}){if(typeof y=="string"){S.debug&&R('parsing "%s"…',y);const D=n.parse(t.readFileSync(y,S.encoding&&{encoding:S.encoding}));return S.debug&&Object.keys(D).forEach(C=>R(">> %s",C)),D}return y.reduce((D,C)=>{const _=l(C,S);return S.debug&&Object.keys(_).filter(I=>D.hasOwnProperty(I)).forEach(I=>R('`%s` is being overwritten by merge from "%s"',I,C)),Object.assign(D,_)},{})}function h(y,S={}){try{const D=l(y,{encoding:S.encoding,debug:S.debug});S.debug&&R("safe-merging parsed environment variables into `process.env`…");for(const C of Object.keys(D))process.env.hasOwnProperty(C)?S.debug&&process.env[C]!==D[C]&&R("environment variable `%s` is predefined and not being overwritten",C):(S.debug&&R(">> process.env.%s",C),process.env[C]=D[C]);return{parsed:D}}catch(D){return g(D,S)}}function u(y,S={}){const D=l(y,S);Object.keys(D).forEach(C=>{process.env[C]===D[C]&&delete process.env[C]})}function d(y={}){if(y.node_env)return y.debug&&R(`operating in "${y.node_env}" environment (set by \`options.node_env\`)`),y.node_env;if(process.env.NODE_ENV)return y.debug&&R(`operating in "${process.env.NODE_ENV}" environment (as per \`process.env.NODE_ENV\`)`),process.env.NODE_ENV;if(y.default_node_env)return y.debug&&R(`operating in "${y.default_node_env}" environment (taken from \`options.default_node_env\`)`),y.default_node_env;y.debug&&R('operating in "no environment" mode (no environment-related options are set)')}const p=["node_env","default_node_env","path","pattern","files","encoding","purge_dotenv","silent"];function f(y={}){y.debug&&(R("initializing…"),p.filter(C=>C in y).forEach(C=>R(`| options.${C} =`,y[C])));const{path:S=process.cwd(),pattern:D=r}=y;if(y.purge_dotenv){y.debug&&R("`options.purge_dotenv` is enabled, unloading potentially pre-loaded `.env`…");const C=e.resolve(S,".env");try{t.existsSync(C)&&u(C,{encoding:y.encoding})}catch(_){!y.silent&&E("unloading failed: ",_)}}try{let C;if(y.files)y.debug&&R("using explicit list of `.env*` files: %s…",y.files.join(", ")),C=y.files.reduce((I,P)=>{const U=e.resolve(S,P);return t.existsSync(U)?I.push(U):y.debug&&R(">> %s does not exist, skipping…",U),I},[]);else{const I=d(y);if(C=c({node_env:I,path:S,pattern:D,debug:y.debug}),C.length===0){const P=I?D.replace(o,`[$1${I}$2]`):D;return g(new Error(`no ".env*" files matching pattern "${P}" in "${S}" dir`),y)}}const _=h(C,{encoding:y.encoding,debug:y.debug,silent:y.silent});return y.debug&&R("initialization completed."),_}catch(C){return g(C,y)}}function g(y,S){return S.silent||E(`".env*" files loading failed: ${y.message||y}`),{error:y}}function E(y,S){S&&(y+=": %s"),console.warn(`[dotenv-flow@${s}]: ${y}`,S)}function R(y,...S){console.debug(`[dotenv-flow@${s}]: ${y}`,...S)}return aa={DEFAULT_PATTERN:r,listFiles:c,parse:l,load:h,unload:u,config:f},aa}var i4=r4();const o4=YE(i4),ca={BASE_URL:"/",DEV:!1,MODE:"staging",PROD:!0,SSR:!1,VITE_IS_DEV:"0",VITE_LOCAL_URL:"http://localhost:5001",VITE_SERVERLESS_URL:"https://backendv2-dev.nervoscan.com",VITE_SERVER_URL:"https://staging.backend.nervoscan.com"};var Od;typeof process<"u"&&process.env&&((Od=process.versions)!=null&&Od.node)&&o4.config();const zr=t=>typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:Qn&&Qn.tagName.toUpperCase()==="SCRIPT"&&Qn.src||new URL("nervoscan-js-sdk.cjs",document.baseURI).href}<"u"&&ca&&t in ca?ca[t]||"":typeof process<"u"&&process.env&&t in process.env?process.env[t]||"":(G.throwKnownError(v.EnvIncompatibleError),""),So=t=>zr("VITE_IS_DEV")==="1"?zr("VITE_LOCAL_URL"):zr(t==="serverless"?"VITE_SERVERLESS_URL":"VITE_SERVER_URL"),a4=t=>{let e=t.reduce((n,s)=>[n[0]+s[0],n[1]+s[1]],[0,0]);return e=[e[0]/t.length,e[1]/t.length],t.slice().sort((n,s)=>{const r=Math.atan2(n[1]-e[1],n[0]-e[0]),i=Math.atan2(s[1]-e[1],s[0]-e[0]);return r-i})},Vg=["bigForehead","smallForehead","leftCheek","rightCheek","cheeksNose","face"];function c4(){return{r:[],g:[],b:[],timestamps:[]}}function ad(){return Object.fromEntries(Vg.map(t=>[t,c4()]))}function jn(t,e){if(!(e.length<3)){t.beginPath(),t.moveTo(e[0][0],e[0][1]);for(let n=1;n<e.length;n++)t.lineTo(e[n][0],e[n][1]);t.closePath(),t.stroke()}}function qn(t,e,n,s,r){const i=t[e],o=(s-r)/1e3;if(i.timestamps.length>0){const a=i.timestamps[i.timestamps.length-1];if(o<=a){T.warn(`Timestamp inconsistency detected in ${e}: ${o} <= ${a}`);return}}i.r.push(n[0]),i.g.push(n[1]),i.b.push(n[2]),i.timestamps.push(o)}function zn(t,e,n,s,r){if(!t||t.length<3)return 0;let i=0;const o=t.length;for(let a=0;a<o;a++){const c=(a+1)%o;i+=t[a][0]*t[c][1],i-=t[c][0]*t[a][1]}return Math.abs(i)/2}function cd(t,e,n,s,r){let i="ALIGNED";const u=s/640,d=r/480,p=u*d,f=19e3*p,g=5e4*p,E=800*p;return t<f?i="TOO_FAR":t>g?i="TOO_CLOSE":e<E?i="LOOKING_LEFT":n<E&&(i="LOOKING_RIGHT"),i}const l4=[[67,109],[109,10],[10,338],[338,297],[66,107],[107,9],[9,336],[336,296],[67,69],[69,66],[297,299],[299,296]],h4=[[109,10],[10,338],[338,337],[337,151],[151,108],[108,109]],u4=[[345,352],[352,376],[376,433],[433,416],[416,436],[436,426],[426,423],[423,266],[266,330],[330,347],[347,346],[346,345]],d4=[[116,123],[123,147],[147,213],[213,192],[192,216],[216,206],[206,203],[203,36],[36,101],[101,118],[118,117],[117,116]],f4=[[118,50],[50,216],[216,2],[2,436],[436,280],[280,347],[347,6],[6,118]],p4=[[103,67],[67,109],[109,10],[10,338],[338,297],[297,332],[332,298],[298,300],[300,383],[383,372],[372,345],[345,352],[352,411],[411,427],[427,436],[436,322],[322,2],[2,92],[92,216],[216,207],[207,187],[187,123],[123,116],[116,143],[143,156],[156,70],[70,68],[68,103]];function Ps(t){const e=new Set;for(const n of t)e.add(n[0]),e.add(n[1]);return Array.from(e)}const m4=Ps(l4),g4=Ps(h4),ld=Ps(u4),hd=Ps(d4),_4=Ps(f4),ud=Ps(p4);class y4{constructor(e){w(this,"wasmUrl","https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.3/wasm");w(this,"modelUrl","https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task");w(this,"assetConfig",{});w(this,"faceLandmarker");w(this,"canvasCtx");w(this,"video");w(this,"videoWidth");w(this,"canvas");w(this,"drawingUtils");w(this,"rgbDataBuffer");w(this,"alignmentStatusCallback");w(this,"startTimeMs",0);w(this,"backendRepository");w(this,"isDetectionActive",!1);w(this,"mediaPipeTimestamp",0);w(this,"lastVideoTime",0);w(this,"videoTimeOffset",0);w(this,"timestampAdjustmentCount",0);w(this,"dataCollectionThreshold",500);w(this,"batchCount",0);w(this,"totalFramesProcessed",0);w(this,"isStreamingActive",!1);w(this,"pendingResults",[]);w(this,"finalResultsCallback");w(this,"mediaPipeTimingData",{capture:[],mlDetection:[],rgbCalc:[],dataStorage:[],alignment:[]});w(this,"faceDetectionLoop",async()=>{const e=async()=>{if(this.isDetectionActive){try{await this.predictAlignmentOnly()}catch(n){T.warn("Face detection error:",n)}setTimeout(e,200)}};e()});this.videoWidth=640,e&&(this.assetConfig=e)}async probeUrl(e,n){try{const s=new AbortController,r=setTimeout(()=>s.abort(),Math.max(1e3,n)),i=await fetch(e,{method:"HEAD",signal:s.signal});return clearTimeout(r),!!i.ok}catch{return!1}}normalizeWasmBase(e){return e.replace(/\/+$/,"")}async resolveAssetUrls(){const e="https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.3/wasm",n="https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task",s=this.assetConfig.timeoutMs??2500,r=this.assetConfig.wasmBaseUrl?this.normalizeWasmBase(this.assetConfig.wasmBaseUrl):void 0,i=this.assetConfig.modelAssetPath,o=this.normalizeWasmBase(e),a=n,c=[{wasm:r,model:i??a,tag:"configured"},{wasm:o,model:a,tag:"cdn"}];for(const l of c){if(!l.wasm||!l.model)continue;const h=await this.probeUrl(`${l.wasm}/vision_wasm_internal.js`,s),u=await this.probeUrl(l.model,s);if(h&&u)return T.log(`[MediaPipe] Assets resolved via ${l.tag}: wasmBase=${l.wasm}`),{wasmBaseUrl:l.wasm,modelUrl:l.model};T.log(`[MediaPipe] ${l.tag} assets probe failed (wasm=${h}, model=${u}). Trying next...`)}return T.log("[MediaPipe] Falling back to CDN assets without successful probe."),{wasmBaseUrl:o,modelUrl:a}}calculateTimingStats(e){if(e.length===0)return{min:0,max:0,avg:0,total:0};let n=1/0,s=-1/0,r=0;for(const i of e)i<n&&(n=i),i>s&&(s=i),r+=i;return{min:n,max:s,avg:r/e.length,total:r}}getTimingBreakdown(){return{capture:this.calculateTimingStats(this.mediaPipeTimingData.capture),mlDetection:this.calculateTimingStats(this.mediaPipeTimingData.mlDetection),rgbCalc:this.calculateTimingStats(this.mediaPipeTimingData.rgbCalc),dataStorage:this.calculateTimingStats(this.mediaPipeTimingData.dataStorage),alignment:this.calculateTimingStats(this.mediaPipeTimingData.alignment)}}resetTimingData(){this.mediaPipeTimingData={capture:[],mlDetection:[],rgbCalc:[],dataStorage:[],alignment:[]}}setStartTimeMs(e){this.startTimeMs=e}setDataCollectionThreshold(e){if(e<=0)throw new Error("Data collection threshold must be greater than 0");this.dataCollectionThreshold=e,T.log(`[RGB] Data collection threshold set to ${e} points`)}startContinuousDataCollection(e,n){T.log(`[FaceLandmarker] Starting continuous data collection (threshold: ${this.dataCollectionThreshold})`),this.isStreamingActive=!0,this.batchCount=0,this.totalFramesProcessed=0,this.pendingResults=[],this.finalResultsCallback=n}stopContinuousDataCollection(){this.isStreamingActive=!1,T.log(`[FaceLandmarker] Stopped. Processed ${this.totalFramesProcessed} frames in ${this.batchCount} batches`),this.pendingResults.length>0&&this.aggregateFinalResults()}async initialize(e,n){if(this.backendRepository=n,await this.createFaceLandmarker(),this.video=e,this.canvas=document.createElement("canvas"),this.canvas.width=e.videoWidth||640,this.canvas.height=e.videoHeight||480,T.log(`[RGB] Initial canvas resolution: ${this.canvas.width}x${this.canvas.height}`),this.canvasCtx=this.canvas.getContext("2d",{willReadFrequently:!0}),!this.canvasCtx)throw new Error("Failed to get canvas context");this.drawingUtils=new De(this.canvasCtx),this.rgbDataBuffer=ad(),this.resetTimingData()}setAlignmentStatusCallback(e){this.alignmentStatusCallback=e}startFaceDetection(){this.isDetectionActive=!0,this.faceDetectionLoop()}stopFaceDetection(){this.isDetectionActive=!1}generateMediaPipeTimestamp(){if(!this.video)return this.mediaPipeTimestamp;const e=this.video.currentTime;e<this.lastVideoTime&&(this.videoTimeOffset+=this.lastVideoTime,T.log(`Video time reset detected. New offset: ${this.videoTimeOffset.toFixed(3)}s`));const n=(e+this.videoTimeOffset)*1e3;if(n<=this.mediaPipeTimestamp){const s=this.mediaPipeTimestamp+1;this.timestampAdjustmentCount++,this.timestampAdjustmentCount%100===0&&T.log(`MediaPipe ts adjusted: ${n.toFixed(1)} → ${s.toFixed(1)} (#${this.timestampAdjustmentCount})`),this.mediaPipeTimestamp=s}else this.mediaPipeTimestamp=n;return this.lastVideoTime=e,this.mediaPipeTimestamp}resetMediaPipeTimestamps(){T.log(`MediaPipe timestamps reset (was: ${this.mediaPipeTimestamp}ms, adjustments: ${this.timestampAdjustmentCount})`),this.mediaPipeTimestamp=0,this.lastVideoTime=0,this.videoTimeOffset=0,this.timestampAdjustmentCount=0}async createFaceLandmarker(){const e=await this.resolveAssetUrls();this.wasmUrl=e.wasmBaseUrl,this.modelUrl=e.modelUrl;const n=await bn.forVisionTasks(this.wasmUrl),s=this.assetConfig.delegate??"GPU";T.log(`[MediaPipe] Creating FaceLandmarker with ${s} delegate`),this.faceLandmarker=await ne.createFromOptions(n,{baseOptions:{modelAssetPath:this.modelUrl,delegate:s},outputFaceBlendshapes:!1,runningMode:"VIDEO",numFaces:1})}getLandmarkCoordinates(e,n,s,r){const i=[];for(const o of n)if(e[0]&&o<e[0].length){const a=e[0][o];i.push([Math.round(a.x*s),Math.round(a.y*r)])}return i.length>0?a4(i):[]}calculateRgbMean(e,n,s,r){if(e.length<3||s<=0||r<=0)return[0,0,0];const i=this.getBoundingBox(e),o=Math.max(0,Math.floor(i.minX)),a=Math.min(s-1,Math.ceil(i.maxX)),c=Math.max(0,Math.floor(i.minY)),l=Math.min(r-1,Math.ceil(i.maxY));if(o>=a||c>=l)return[0,0,0];let h=0,u=0,d=0,p=0;for(let f=c;f<=l;f++)for(let g=o;g<=a;g++)if(this.isPointInPolygon(g,f,e)){const E=(f*s+g)*4;u+=n.data[E],d+=n.data[E+1],p+=n.data[E+2],h++}return h>0?[Math.round(u/h),Math.round(d/h),Math.round(p/h)]:[0,0,0]}getBoundingBox(e){let n=1/0,s=-1/0,r=1/0,i=-1/0;for(const[o,a]of e)o<n&&(n=o),o>s&&(s=o),a<r&&(r=a),a>i&&(i=a);return{minX:n,maxX:s,minY:r,maxY:i}}isPointInPolygon(e,n,s){let r=!1;const i=s.length;for(let o=0,a=i-1;o<i;a=o++){const c=s[o][0],l=s[o][1],h=s[a][0],u=s[a][1];l>n!=u>n&&e<(h-c)*(n-l)/(u-l)+c&&(r=!r)}return r}async predictAlignmentOnly(){if(!this.canvasCtx||!this.video||!this.video.videoWidth||!this.video.videoHeight||this.video.readyState<2||!this.faceLandmarker)return;const e=this.generateMediaPipeTimestamp();let n;try{n=this.faceLandmarker.detectForVideo(this.video,e)}catch(s){if(s instanceof Error&&s.message.includes("timestamp mismatch")){T.warn("MediaPipe timestamp error in alignment, recovering..."),this.mediaPipeTimestamp+=100,this.timestampAdjustmentCount++;try{n=this.faceLandmarker.detectForVideo(this.video,this.mediaPipeTimestamp)}catch(r){T.error("MediaPipe recovery failed in alignment:",r);return}}else throw s}if(n.faceLandmarks&&n.faceLandmarks.length>0){const s=this.video.videoWidth,r=this.video.videoHeight,i=this.getLandmarkCoordinates(n.faceLandmarks,ud,s,r),o=this.getLandmarkCoordinates(n.faceLandmarks,ld,s,r),a=this.getLandmarkCoordinates(n.faceLandmarks,hd,s,r),c=zn(i),l=zn(o),h=zn(a),u=cd(c,l,h,s,r);this.alignmentStatusCallback&&this.alignmentStatusCallback(u)}else this.alignmentStatusCallback&&this.alignmentStatusCallback("NO_FACE")}captureAndProcess(e,n){this.stopFaceDetection();const s=this.checkDataCollectionStatus(e);if(!this.canvasCtx||!this.video||this.video.readyState<2||!this.video.videoWidth||!this.video.videoHeight)return s;const r=this.video.videoWidth,i=this.video.videoHeight;if(this.canvas.width!==r||this.canvas.height!==i){this.canvas.width=r,this.canvas.height=i;const u=i/r;this.canvas.style.width=this.videoWidth+"px",this.canvas.style.height=this.videoWidth*u+"px",this.drawingUtils=new De(this.canvasCtx),T.log(`[RGB] Canvas resized to ${r}x${i}`)}const o=performance.now();this.canvasCtx.drawImage(this.video,0,0,r,i);const a=this.canvasCtx.getImageData(0,0,r,i);this.mediaPipeTimingData.capture.push(performance.now()-o),this.canvasCtx.clearRect(0,0,r,i),this.faceLandmarker||G.throwKnownError(v.FaceLandmarkerNotInitializedError);const c=performance.now(),l=this.generateMediaPipeTimestamp();let h;try{h=this.faceLandmarker.detectForVideo(this.video,l)}catch(u){if(u instanceof Error&&u.message.includes("timestamp mismatch")){T.warn("[RGB] MediaPipe timestamp mismatch, recovering..."),this.mediaPipeTimestamp+=100,this.timestampAdjustmentCount++;try{h=this.faceLandmarker.detectForVideo(this.video,this.mediaPipeTimestamp)}catch(d){return T.error("[RGB] MediaPipe recovery failed, skipping frame:",d),s}}else return T.error("[RGB] MediaPipe detection error:",u),s}if(this.mediaPipeTimingData.mlDetection.push(performance.now()-c),h.faceLandmarks&&h.faceLandmarks.length>0){this.rgbDataBuffer.bigForehead.r.length%100===0&&T.log(`[RGB] Frame ${this.rgbDataBuffer.bigForehead.r.length} at ${r}x${i}`),this.drawFaceLandmarks(this.drawingUtils,h.faceLandmarks);const u=this.getLandmarkCoordinates(h.faceLandmarks,m4,r,i),d=this.getLandmarkCoordinates(h.faceLandmarks,g4,r,i),p=this.getLandmarkCoordinates(h.faceLandmarks,ld,r,i),f=this.getLandmarkCoordinates(h.faceLandmarks,hd,r,i),g=this.getLandmarkCoordinates(h.faceLandmarks,_4,r,i),E=this.getLandmarkCoordinates(h.faceLandmarks,ud,r,i);this.canvasCtx.strokeStyle="rgba(255, 255, 255, 0.7)",this.canvasCtx.lineWidth=1,jn(this.canvasCtx,u),jn(this.canvasCtx,d),jn(this.canvasCtx,p),jn(this.canvasCtx,f),jn(this.canvasCtx,g),jn(this.canvasCtx,E);const R=performance.now(),y=this.calculateRgbMean(u,a,r,i),S=this.calculateRgbMean(d,a,r,i),D=this.calculateRgbMean(p,a,r,i),C=this.calculateRgbMean(f,a,r,i),_=this.calculateRgbMean(g,a,r,i),I=this.calculateRgbMean(E,a,r,i);this.mediaPipeTimingData.rgbCalc.push(performance.now()-R);const P=performance.now();s&&(qn(this.rgbDataBuffer,"bigForehead",y,n,this.startTimeMs),qn(this.rgbDataBuffer,"smallForehead",S,n,this.startTimeMs),qn(this.rgbDataBuffer,"leftCheek",D,n,this.startTimeMs),qn(this.rgbDataBuffer,"rightCheek",C,n,this.startTimeMs),qn(this.rgbDataBuffer,"cheeksNose",_,n,this.startTimeMs),qn(this.rgbDataBuffer,"face",I,n,this.startTimeMs)),this.mediaPipeTimingData.dataStorage.push(performance.now()-P);const U=performance.now(),me=zn(E),V=zn(p),te=zn(f),le=cd(me,V,te,r,i);this.alignmentStatusCallback&&this.alignmentStatusCallback(le),this.mediaPipeTimingData.alignment.push(performance.now()-U)}else this.alignmentStatusCallback&&this.alignmentStatusCallback("NO_FACE");return s}drawFaceLandmarks(e,n){for(const s of n)e.drawConnectors(s,ne.FACE_LANDMARKS_FACE_OVAL,{color:"#E0E0E0"}),e.drawConnectors(s,ne.FACE_LANDMARKS_RIGHT_EYE,{color:"#FF3030"}),e.drawConnectors(s,ne.FACE_LANDMARKS_LEFT_EYE,{color:"#30FF30"}),e.drawConnectors(s,ne.FACE_LANDMARKS_LIPS,{color:"#E0E0E0"})}checkDataCollectionStatus(e){var s,r,i,o;let n=!0;return this.rgbDataBuffer.bigForehead.r.length>=this.dataCollectionThreshold?(this.batchCount++,this.totalFramesProcessed+=this.rgbDataBuffer.bigForehead.r.length,T.log(`[RGB] Sending batch ${this.batchCount} (${this.dataCollectionThreshold} pts, ${((s=this.video)==null?void 0:s.videoWidth)||0}x${((r=this.video)==null?void 0:r.videoHeight)||0})`),this.backendRepository.sendRgbDataToBackend(this.rgbDataBuffer,((i=this.video)==null?void 0:i.videoWidth)||0,((o=this.video)==null?void 0:o.videoHeight)||0,e),this.resetDataBuffer(),n=this.isStreamingActive,T.log(`[RGB] ${n?`Continuing for batch ${this.batchCount+1}`:"Stopping collection"}`)):this.rgbDataBuffer.bigForehead.r.length%50===0&&T.log(`[RGB] Buffer: ${this.rgbDataBuffer.bigForehead.r.length}/${this.dataCollectionThreshold}`),n}getRGBDataBufferSize(){var e,n,s;return((s=(n=(e=this.rgbDataBuffer)==null?void 0:e.bigForehead)==null?void 0:n.r)==null?void 0:s.length)||0}getDataCollectionThreshold(){return this.dataCollectionThreshold}getRGBTimestamps(){var e,n;return((n=(e=this.rgbDataBuffer)==null?void 0:e.bigForehead)==null?void 0:n.timestamps)||[]}isDetectionCurrentlyActive(){return this.isDetectionActive}aggregateFinalResults(){if(this.pendingResults.length===0){T.warn("[FaceLandmarker] No pending results to aggregate");return}T.log(`[FaceLandmarker] Aggregating ${this.pendingResults.length} batch results`);const e={},n=["HR","RR","SDNN","SPO2","DBP","SBP","GLUCOSE","HEMOGLOBIN","AGE","HEALTHSCORE","PNN50","RMSSD"];for(const s of n){const r=this.pendingResults.map(i=>i[s]).filter(i=>i!=null&&!isNaN(i));r.length>0&&(e[s]=Math.round(r.reduce((i,o)=>i+o,0)/r.length*100)/100)}e.batchCount=this.batchCount,e.totalFramesProcessed=this.totalFramesProcessed,e.aggregatedFrom=this.pendingResults.length,T.log("[FaceLandmarker] Aggregated results:",e),this.finalResultsCallback&&this.finalResultsCallback(e)}handleBatchResults(e){if(!this.isStreamingActive){T.warn("[FaceLandmarker] Received batch results but continuous collection is not active");return}this.pendingResults.push(e),T.log(`[FaceLandmarker] Batch ${this.pendingResults.length} added. Total pending: ${this.pendingResults.length}`)}resetDataBuffer(){this.rgbDataBuffer=ad()}}const Tn=class Tn{constructor(){w(this,"faceLandmarker");w(this,"isCollectingData",!1);w(this,"videoElement");w(this,"apiKey","");w(this,"onAlignmentStatus");w(this,"captureLoopId",null);w(this,"frameInterval",1e3/30);w(this,"lastCaptureTime",0);w(this,"config",{targetFPS:30,mediapipe:{}});w(this,"frameCount",0);w(this,"totalFrameCount",0);w(this,"duplicateFrames",0);w(this,"startTime",0);w(this,"frameTimes",[]);w(this,"lastVideoTime",0);w(this,"maxFrameTimesSize",100);w(this,"minFrameTimeDelta",.001);w(this,"totalFrameTimes",[]);w(this,"isContinuousMode",!1)}static getInstance(){return Tn.instance||(Tn.instance=new Tn),Tn.instance}async initialize(e,n,s,r,i={}){this.config={...this.config,...i},this.frameInterval=1e3/this.config.targetFPS,this.videoElement=n,this.videoElement.srcObject=e,this.faceLandmarker||(this.faceLandmarker=new y4(this.config.mediapipe),this.faceLandmarker.setDataCollectionThreshold(300)),await this.faceLandmarker.initialize(this.videoElement,s),this.onAlignmentStatus&&this.faceLandmarker.setAlignmentStatusCallback(this.onAlignmentStatus),T.log("[RGBManager] Initialized:",this.config),T.log(`[RGBManager] Video: ${n.videoWidth}x${n.videoHeight}`)}startFaceDetection(){this.faceLandmarker&&(T.log("[RGBManager] Starting face detection..."),this.faceLandmarker.startFaceDetection())}stopFaceDetection(){this.faceLandmarker&&(T.log("[RGBManager] Stopping face detection..."),this.faceLandmarker.stopFaceDetection())}setAlignmentStatusCallback(e){this.onAlignmentStatus=e,this.faceLandmarker&&this.faceLandmarker.setAlignmentStatusCallback(e)}async startStreaming(e){this.isCollectingData=!0,this.apiKey=e,this.resetStatistics(),T.log(`[RGBManager] Starting streaming at ${this.config.targetFPS} FPS`),this.faceLandmarker.setStartTimeMs(performance.now()),this.isContinuousMode&&this.faceLandmarker&&this.faceLandmarker.startContinuousDataCollection(e),this.startCaptureLoop()}startCaptureLoop(){const e=n=>{if(!this.isCollectingData){this.captureLoopId=null;return}n-this.lastCaptureTime>=this.frameInterval&&(this.lastCaptureTime=n,this.runCaptureTick(n)),this.captureLoopId=requestAnimationFrame(e)};this.captureLoopId=requestAnimationFrame(e)}runCaptureTick(e){if(!this.videoElement)return;const n=this.videoElement.currentTime;if(n-this.lastVideoTime<this.minFrameTimeDelta){this.duplicateFrames++;return}this.lastVideoTime=n,this.frameCount++,this.totalFrameCount++,this.frameTimes.push(e),this.frameTimes.length>this.maxFrameTimesSize&&this.frameTimes.shift();const s=performance.now();try{const r=this.isCollectingData;this.isCollectingData=this.faceLandmarker.captureAndProcess(this.apiKey,n*1e3),r!==this.isCollectingData&&T.log(`[RGBManager] isCollectingData: ${r} → ${this.isCollectingData} (continuous=${this.isContinuousMode})`);const i=performance.now()-s;this.totalFrameTimes.push(i),this.frameCount%100===0&&T.log(`📊 [Progress] Frame ${this.frameCount} — ${i.toFixed(1)}ms`)}catch(r){const i=performance.now()-s;this.totalFrameTimes.push(i),T.error(`❌ [Frame ${this.frameCount}] Error after ${i.toFixed(2)}ms:`,r)}}resetStatistics(){this.startTime=performance.now(),this.frameCount=0,this.duplicateFrames=0,this.frameTimes=[],this.totalFrameTimes=[],this.lastVideoTime=0,this.lastCaptureTime=0}stopStreaming(){this.isCollectingData=!1,this.captureLoopId!==null&&(cancelAnimationFrame(this.captureLoopId),this.captureLoopId=null),this.isContinuousMode&&this.faceLandmarker&&this.faceLandmarker.stopContinuousDataCollection(),this.logFinalStatistics()}calculateTimingStats(e){if(e.length===0)return{min:0,max:0,avg:0,total:0};let n=1/0,s=-1/0,r=0;for(const i of e)i<n&&(n=i),i>s&&(s=i),r+=i;return{min:n,max:s,avg:r/e.length,total:r}}logFinalStatistics(){var i,o;const e=this.getFrameStatistics();if(e.frameCount===0){T.log("[RGBManager] No frames processed.");return}const s=this.calculateTimingStats(this.totalFrameTimes).avg,r=(o=(i=this.faceLandmarker)==null?void 0:i.getTimingBreakdown)==null?void 0:o.call(i);T.log(`
1637
1637
  🎯 ===== PERFORMANCE SUMMARY =====`),T.log(`📊 ${e.frameCount} frames in ${(e.elapsedTime/1e3).toFixed(1)}s — ${e.actualFPS.toFixed(1)} FPS (target ${e.targetFPS})`),T.log(`⚠️ Duplicates: ${e.duplicateFrames}`),T.log(`⏱️ Avg frame: ${s.toFixed(2)}ms (${(1e3/s).toFixed(1)} FPS capacity)`),T.log(`${s>33.33?"❌ MISSING 30 FPS target":"✅ Within 30 FPS target"}`),r&&(T.log(`
1638
1638
  🧠 MediaPipe breakdown:`),T.log(` Capture (GPU→CPU): ${r.capture.avg.toFixed(2)}ms avg (drawImage + getImageData)`),T.log(` ML detection: ${r.mlDetection.avg.toFixed(2)}ms avg`),T.log(` RGB calc: ${r.rgbCalc.avg.toFixed(2)}ms avg`),T.log(` Data storage: ${r.dataStorage.avg.toFixed(2)}ms avg`),T.log(` Alignment: ${r.alignment.avg.toFixed(2)}ms avg`)),T.log(`==================================
1639
- `)}getFrameStatistics(){const e=performance.now()-this.startTime,n=this.isContinuousMode?this.totalFrameCount:this.frameCount,s=e>0?n*1e3/e:0;let r=100;if(this.frameTimes.length>10){const i=[];for(let c=1;c<this.frameTimes.length;c++)i.push(this.frameTimes[c]-this.frameTimes[c-1]);const o=i.reduce((c,l)=>c+l,0)/i.length,a=i.reduce((c,l)=>c+Math.pow(l-o,2),0)/i.length;r=Math.max(0,(1-Math.sqrt(a)/o)*100)}return{frameCount:n,duplicateFrames:this.duplicateFrames,targetFPS:this.config.targetFPS,actualFPS:s,elapsedTime:e,temporalStability:r}}setTargetFPS(e){this.config.targetFPS=Math.max(1,Math.min(120,e)),this.frameInterval=1e3/this.config.targetFPS}isContinuousModeEnabled(){return this.isContinuousMode}getDataCollectionStatus(){var e,n,s,r,i,o;return this.faceLandmarker?{isCollectingData:this.isCollectingData,bufferSize:((n=(e=this.faceLandmarker).getRGBDataBufferSize)==null?void 0:n.call(e))??"Unknown",threshold:((r=(s=this.faceLandmarker).getDataCollectionThreshold)==null?void 0:r.call(s))??300,frameCount:this.frameCount,isContinuousMode:this.isContinuousMode,isDetectionActive:((o=(i=this.faceLandmarker).isDetectionCurrentlyActive)==null?void 0:o.call(i))??!1}:{error:"Face landmarker not initialized"}}getRGBTimestamps(){var e,n;return this.faceLandmarker?((n=(e=this.faceLandmarker).getRGBTimestamps)==null?void 0:n.call(e))??[]:[]}handleBatchResults(e){this.faceLandmarker&&this.faceLandmarker.handleBatchResults(e)}};w(Tn,"instance");let Ui=Tn;function Hg(t,e){return function(){return t.apply(e,arguments)}}const{toString:v4}=Object.prototype,{getPrototypeOf:zl}=Object,Ao=(t=>e=>{const n=v4.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),kt=t=>(t=t.toLowerCase(),e=>Ao(e)===t),Ro=t=>e=>typeof e===t,{isArray:Fs}=Array,br=Ro("undefined");function w4(t){return t!==null&&!br(t)&&t.constructor!==null&&!br(t.constructor)&&st(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Gg=kt("ArrayBuffer");function b4(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Gg(t.buffer),e}const T4=Ro("string"),st=Ro("function"),Wg=Ro("number"),ko=t=>t!==null&&typeof t=="object",C4=t=>t===!0||t===!1,ri=t=>{if(Ao(t)!=="object")return!1;const e=zl(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},S4=kt("Date"),A4=kt("File"),R4=kt("Blob"),k4=kt("FileList"),I4=t=>ko(t)&&st(t.pipe),N4=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||st(t.append)&&((e=Ao(t))==="formdata"||e==="object"&&st(t.toString)&&t.toString()==="[object FormData]"))},x4=kt("URLSearchParams"),[O4,L4,D4,P4]=["ReadableStream","Request","Response","Headers"].map(kt),F4=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Fr(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let s,r;if(typeof t!="object"&&(t=[t]),Fs(t))for(s=0,r=t.length;s<r;s++)e.call(null,t[s],s,t);else{const i=n?Object.getOwnPropertyNames(t):Object.keys(t),o=i.length;let a;for(s=0;s<o;s++)a=i[s],e.call(null,t[a],a,t)}}function $g(t,e){e=e.toLowerCase();const n=Object.keys(t);let s=n.length,r;for(;s-- >0;)if(r=n[s],e===r.toLowerCase())return r;return null}const In=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,jg=t=>!br(t)&&t!==In;function Ja(){const{caseless:t}=jg(this)&&this||{},e={},n=(s,r)=>{const i=t&&$g(e,r)||r;ri(e[i])&&ri(s)?e[i]=Ja(e[i],s):ri(s)?e[i]=Ja({},s):Fs(s)?e[i]=s.slice():e[i]=s};for(let s=0,r=arguments.length;s<r;s++)arguments[s]&&Fr(arguments[s],n);return e}const M4=(t,e,n,{allOwnKeys:s}={})=>(Fr(e,(r,i)=>{n&&st(r)?t[i]=Hg(r,n):t[i]=r},{allOwnKeys:s}),t),B4=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),U4=(t,e,n,s)=>{t.prototype=Object.create(e.prototype,s),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},V4=(t,e,n,s)=>{let r,i,o;const a={};if(e=e||{},t==null)return e;do{for(r=Object.getOwnPropertyNames(t),i=r.length;i-- >0;)o=r[i],(!s||s(o,t,e))&&!a[o]&&(e[o]=t[o],a[o]=!0);t=n!==!1&&zl(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},H4=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const s=t.indexOf(e,n);return s!==-1&&s===n},G4=t=>{if(!t)return null;if(Fs(t))return t;let e=t.length;if(!Wg(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},W4=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&zl(Uint8Array)),$4=(t,e)=>{const s=(t&&t[Symbol.iterator]).call(t);let r;for(;(r=s.next())&&!r.done;){const i=r.value;e.call(t,i[0],i[1])}},j4=(t,e)=>{let n;const s=[];for(;(n=t.exec(e))!==null;)s.push(n);return s},q4=kt("HTMLFormElement"),z4=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),dd=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),K4=kt("RegExp"),qg=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),s={};Fr(n,(r,i)=>{let o;(o=e(r,i,t))!==!1&&(s[i]=o||r)}),Object.defineProperties(t,s)},Y4=t=>{qg(t,(e,n)=>{if(st(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const s=t[n];if(st(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},X4=(t,e)=>{const n={},s=r=>{r.forEach(i=>{n[i]=!0})};return Fs(t)?s(t):s(String(t).split(e)),n},J4=()=>{},Q4=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function Z4(t){return!!(t&&st(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const ev=t=>{const e=new Array(10),n=(s,r)=>{if(ko(s)){if(e.indexOf(s)>=0)return;if(!("toJSON"in s)){e[r]=s;const i=Fs(s)?[]:{};return Fr(s,(o,a)=>{const c=n(o,r+1);!br(c)&&(i[a]=c)}),e[r]=void 0,i}}return s};return n(t,0)},tv=kt("AsyncFunction"),nv=t=>t&&(ko(t)||st(t))&&st(t.then)&&st(t.catch),zg=((t,e)=>t?setImmediate:e?((n,s)=>(In.addEventListener("message",({source:r,data:i})=>{r===In&&i===n&&s.length&&s.shift()()},!1),r=>{s.push(r),In.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",st(In.postMessage)),sv=typeof queueMicrotask<"u"?queueMicrotask.bind(In):typeof process<"u"&&process.nextTick||zg,m={isArray:Fs,isArrayBuffer:Gg,isBuffer:w4,isFormData:N4,isArrayBufferView:b4,isString:T4,isNumber:Wg,isBoolean:C4,isObject:ko,isPlainObject:ri,isReadableStream:O4,isRequest:L4,isResponse:D4,isHeaders:P4,isUndefined:br,isDate:S4,isFile:A4,isBlob:R4,isRegExp:K4,isFunction:st,isStream:I4,isURLSearchParams:x4,isTypedArray:W4,isFileList:k4,forEach:Fr,merge:Ja,extend:M4,trim:F4,stripBOM:B4,inherits:U4,toFlatObject:V4,kindOf:Ao,kindOfTest:kt,endsWith:H4,toArray:G4,forEachEntry:$4,matchAll:j4,isHTMLForm:q4,hasOwnProperty:dd,hasOwnProp:dd,reduceDescriptors:qg,freezeMethods:Y4,toObjectSet:X4,toCamelCase:z4,noop:J4,toFiniteNumber:Q4,findKey:$g,global:In,isContextDefined:jg,isSpecCompliantForm:Z4,toJSONObject:ev,isAsyncFn:tv,isThenable:nv,setImmediate:zg,asap:sv};function M(t,e,n,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),s&&(this.request=s),r&&(this.response=r,this.status=r.status?r.status:null)}m.inherits(M,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:m.toJSONObject(this.config),code:this.code,status:this.status}}});const Kg=M.prototype,Yg={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{Yg[t]={value:t}});Object.defineProperties(M,Yg);Object.defineProperty(Kg,"isAxiosError",{value:!0});M.from=(t,e,n,s,r,i)=>{const o=Object.create(Kg);return m.toFlatObject(t,o,function(c){return c!==Error.prototype},a=>a!=="isAxiosError"),M.call(o,t.message,e,n,s,r),o.cause=t,o.name=t.name,i&&Object.assign(o,i),o};const rv=null;function Qa(t){return m.isPlainObject(t)||m.isArray(t)}function Xg(t){return m.endsWith(t,"[]")?t.slice(0,-2):t}function fd(t,e,n){return t?t.concat(e).map(function(r,i){return r=Xg(r),!n&&i?"["+r+"]":r}).join(n?".":""):e}function iv(t){return m.isArray(t)&&!t.some(Qa)}const ov=m.toFlatObject(m,{},null,function(e){return/^is[A-Z]/.test(e)});function Io(t,e,n){if(!m.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=m.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,E){return!m.isUndefined(E[g])});const s=n.metaTokens,r=n.visitor||h,i=n.dots,o=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&m.isSpecCompliantForm(e);if(!m.isFunction(r))throw new TypeError("visitor must be a function");function l(f){if(f===null)return"";if(m.isDate(f))return f.toISOString();if(!c&&m.isBlob(f))throw new M("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(f)||m.isTypedArray(f)?c&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function h(f,g,E){let R=f;if(f&&!E&&typeof f=="object"){if(m.endsWith(g,"{}"))g=s?g:g.slice(0,-2),f=JSON.stringify(f);else if(m.isArray(f)&&iv(f)||(m.isFileList(f)||m.endsWith(g,"[]"))&&(R=m.toArray(f)))return g=Xg(g),R.forEach(function(S,D){!(m.isUndefined(S)||S===null)&&e.append(o===!0?fd([g],D,i):o===null?g:g+"[]",l(S))}),!1}return Qa(f)?!0:(e.append(fd(E,g,i),l(f)),!1)}const u=[],d=Object.assign(ov,{defaultVisitor:h,convertValue:l,isVisitable:Qa});function p(f,g){if(!m.isUndefined(f)){if(u.indexOf(f)!==-1)throw Error("Circular reference detected in "+g.join("."));u.push(f),m.forEach(f,function(R,y){(!(m.isUndefined(R)||R===null)&&r.call(e,R,m.isString(y)?y.trim():y,g,d))===!0&&p(R,g?g.concat(y):[y])}),u.pop()}}if(!m.isObject(t))throw new TypeError("data must be an object");return p(t),e}function pd(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function Kl(t,e){this._pairs=[],t&&Io(t,this,e)}const Jg=Kl.prototype;Jg.append=function(e,n){this._pairs.push([e,n])};Jg.toString=function(e){const n=e?function(s){return e.call(this,s,pd)}:pd;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function av(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Qg(t,e,n){if(!e)return t;const s=n&&n.encode||av;m.isFunction(n)&&(n={serialize:n});const r=n&&n.serialize;let i;if(r?i=r(e,n):i=m.isURLSearchParams(e)?e.toString():new Kl(e,n).toString(s),i){const o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+i}return t}class md{constructor(){this.handlers=[]}use(e,n,s){return this.handlers.push({fulfilled:e,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){m.forEach(this.handlers,function(s){s!==null&&e(s)})}}const Zg={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},cv=typeof URLSearchParams<"u"?URLSearchParams:Kl,lv=typeof FormData<"u"?FormData:null,hv=typeof Blob<"u"?Blob:null,uv={isBrowser:!0,classes:{URLSearchParams:cv,FormData:lv,Blob:hv},protocols:["http","https","file","blob","url","data"]},Yl=typeof window<"u"&&typeof document<"u",Za=typeof navigator=="object"&&navigator||void 0,dv=Yl&&(!Za||["ReactNative","NativeScript","NS"].indexOf(Za.product)<0),fv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",pv=Yl&&window.location.href||"http://localhost",mv=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Yl,hasStandardBrowserEnv:dv,hasStandardBrowserWebWorkerEnv:fv,navigator:Za,origin:pv},Symbol.toStringTag,{value:"Module"})),Be={...mv,...uv};function gv(t,e){return Io(t,new Be.classes.URLSearchParams,Object.assign({visitor:function(n,s,r,i){return Be.isNode&&m.isBuffer(n)?(this.append(s,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function _v(t){return m.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function yv(t){const e={},n=Object.keys(t);let s;const r=n.length;let i;for(s=0;s<r;s++)i=n[s],e[i]=t[i];return e}function e_(t){function e(n,s,r,i){let o=n[i++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),c=i>=n.length;return o=!o&&m.isArray(r)?r.length:o,c?(m.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!a):((!r[o]||!m.isObject(r[o]))&&(r[o]=[]),e(n,s,r[o],i)&&m.isArray(r[o])&&(r[o]=yv(r[o])),!a)}if(m.isFormData(t)&&m.isFunction(t.entries)){const n={};return m.forEachEntry(t,(s,r)=>{e(_v(s),r,n,0)}),n}return null}function Ev(t,e,n){if(m.isString(t))try{return(e||JSON.parse)(t),m.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(t)}const Mr={transitional:Zg,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const s=n.getContentType()||"",r=s.indexOf("application/json")>-1,i=m.isObject(e);if(i&&m.isHTMLForm(e)&&(e=new FormData(e)),m.isFormData(e))return r?JSON.stringify(e_(e)):e;if(m.isArrayBuffer(e)||m.isBuffer(e)||m.isStream(e)||m.isFile(e)||m.isBlob(e)||m.isReadableStream(e))return e;if(m.isArrayBufferView(e))return e.buffer;if(m.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return gv(e,this.formSerializer).toString();if((a=m.isFileList(e))||s.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Io(a?{"files[]":e}:e,c&&new c,this.formSerializer)}}return i||r?(n.setContentType("application/json",!1),Ev(e)):e}],transformResponse:[function(e){const n=this.transitional||Mr.transitional,s=n&&n.forcedJSONParsing,r=this.responseType==="json";if(m.isResponse(e)||m.isReadableStream(e))return e;if(e&&m.isString(e)&&(s&&!this.responseType||r)){const o=!(n&&n.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?M.from(a,M.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Be.classes.FormData,Blob:Be.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};m.forEach(["delete","get","head","post","put","patch"],t=>{Mr.headers[t]={}});const vv=m.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),wv=t=>{const e={};let n,s,r;return t&&t.split(`
1640
- `).forEach(function(o){r=o.indexOf(":"),n=o.substring(0,r).trim().toLowerCase(),s=o.substring(r+1).trim(),!(!n||e[n]&&vv[n])&&(n==="set-cookie"?e[n]?e[n].push(s):e[n]=[s]:e[n]=e[n]?e[n]+", "+s:s)}),e},gd=Symbol("internals");function qs(t){return t&&String(t).trim().toLowerCase()}function ii(t){return t===!1||t==null?t:m.isArray(t)?t.map(ii):String(t)}function bv(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=n.exec(t);)e[s[1]]=s[2];return e}const Tv=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function la(t,e,n,s,r){if(m.isFunction(s))return s.call(this,e,n);if(r&&(e=n),!!m.isString(e)){if(m.isString(s))return e.indexOf(s)!==-1;if(m.isRegExp(s))return s.test(e)}}function Cv(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,s)=>n.toUpperCase()+s)}function Sv(t,e){const n=m.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(t,s+n,{value:function(r,i,o){return this[s].call(this,e,r,i,o)},configurable:!0})})}let ze=class{constructor(e){e&&this.set(e)}set(e,n,s){const r=this;function i(a,c,l){const h=qs(c);if(!h)throw new Error("header name must be a non-empty string");const u=m.findKey(r,h);(!u||r[u]===void 0||l===!0||l===void 0&&r[u]!==!1)&&(r[u||c]=ii(a))}const o=(a,c)=>m.forEach(a,(l,h)=>i(l,h,c));if(m.isPlainObject(e)||e instanceof this.constructor)o(e,n);else if(m.isString(e)&&(e=e.trim())&&!Tv(e))o(wv(e),n);else if(m.isHeaders(e))for(const[a,c]of e.entries())i(c,a,s);else e!=null&&i(n,e,s);return this}get(e,n){if(e=qs(e),e){const s=m.findKey(this,e);if(s){const r=this[s];if(!n)return r;if(n===!0)return bv(r);if(m.isFunction(n))return n.call(this,r,s);if(m.isRegExp(n))return n.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=qs(e),e){const s=m.findKey(this,e);return!!(s&&this[s]!==void 0&&(!n||la(this,this[s],s,n)))}return!1}delete(e,n){const s=this;let r=!1;function i(o){if(o=qs(o),o){const a=m.findKey(s,o);a&&(!n||la(s,s[a],a,n))&&(delete s[a],r=!0)}}return m.isArray(e)?e.forEach(i):i(e),r}clear(e){const n=Object.keys(this);let s=n.length,r=!1;for(;s--;){const i=n[s];(!e||la(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){const n=this,s={};return m.forEach(this,(r,i)=>{const o=m.findKey(s,i);if(o){n[o]=ii(r),delete n[i];return}const a=e?Cv(i):String(i).trim();a!==i&&delete n[i],n[a]=ii(r),s[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return m.forEach(this,(s,r)=>{s!=null&&s!==!1&&(n[r]=e&&m.isArray(s)?s.join(", "):s)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
1641
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const s=new this(e);return n.forEach(r=>s.set(r)),s}static accessor(e){const s=(this[gd]=this[gd]={accessors:{}}).accessors,r=this.prototype;function i(o){const a=qs(o);s[a]||(Sv(r,o),s[a]=!0)}return m.isArray(e)?e.forEach(i):i(e),this}};ze.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);m.reduceDescriptors(ze.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(s){this[n]=s}}});m.freezeMethods(ze);function ha(t,e){const n=this||Mr,s=e||n,r=ze.from(s.headers);let i=s.data;return m.forEach(t,function(a){i=a.call(n,i,r.normalize(),e?e.status:void 0)}),r.normalize(),i}function t_(t){return!!(t&&t.__CANCEL__)}function Ms(t,e,n){M.call(this,t??"canceled",M.ERR_CANCELED,e,n),this.name="CanceledError"}m.inherits(Ms,M,{__CANCEL__:!0});function n_(t,e,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?t(n):e(new M("Request failed with status code "+n.status,[M.ERR_BAD_REQUEST,M.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Av(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Rv(t,e){t=t||10;const n=new Array(t),s=new Array(t);let r=0,i=0,o;return e=e!==void 0?e:1e3,function(c){const l=Date.now(),h=s[i];o||(o=l),n[r]=c,s[r]=l;let u=i,d=0;for(;u!==r;)d+=n[u++],u=u%t;if(r=(r+1)%t,r===i&&(i=(i+1)%t),l-o<e)return;const p=h&&l-h;return p?Math.round(d*1e3/p):void 0}}function kv(t,e){let n=0,s=1e3/e,r,i;const o=(l,h=Date.now())=>{n=h,r=null,i&&(clearTimeout(i),i=null),t.apply(null,l)};return[(...l)=>{const h=Date.now(),u=h-n;u>=s?o(l,h):(r=l,i||(i=setTimeout(()=>{i=null,o(r)},s-u)))},()=>r&&o(r)]}const Vi=(t,e,n=3)=>{let s=0;const r=Rv(50,250);return kv(i=>{const o=i.loaded,a=i.lengthComputable?i.total:void 0,c=o-s,l=r(c),h=o<=a;s=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&h?(a-o)/l:void 0,event:i,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(u)},n)},_d=(t,e)=>{const n=t!=null;return[s=>e[0]({lengthComputable:n,total:t,loaded:s}),e[1]]},yd=t=>(...e)=>m.asap(()=>t(...e)),Iv=Be.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,Be.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(Be.origin),Be.navigator&&/(msie|trident)/i.test(Be.navigator.userAgent)):()=>!0,Nv=Be.hasStandardBrowserEnv?{write(t,e,n,s,r,i){const o=[t+"="+encodeURIComponent(e)];m.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),m.isString(s)&&o.push("path="+s),m.isString(r)&&o.push("domain="+r),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function xv(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Ov(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function s_(t,e,n){let s=!xv(e);return t&&(s||n==!1)?Ov(t,e):e}const Ed=t=>t instanceof ze?{...t}:t;function Bn(t,e){e=e||{};const n={};function s(l,h,u,d){return m.isPlainObject(l)&&m.isPlainObject(h)?m.merge.call({caseless:d},l,h):m.isPlainObject(h)?m.merge({},h):m.isArray(h)?h.slice():h}function r(l,h,u,d){if(m.isUndefined(h)){if(!m.isUndefined(l))return s(void 0,l,u,d)}else return s(l,h,u,d)}function i(l,h){if(!m.isUndefined(h))return s(void 0,h)}function o(l,h){if(m.isUndefined(h)){if(!m.isUndefined(l))return s(void 0,l)}else return s(void 0,h)}function a(l,h,u){if(u in e)return s(l,h);if(u in t)return s(void 0,l)}const c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(l,h,u)=>r(Ed(l),Ed(h),u,!0)};return m.forEach(Object.keys(Object.assign({},t,e)),function(h){const u=c[h]||r,d=u(t[h],e[h],h);m.isUndefined(d)&&u!==a||(n[h]=d)}),n}const r_=t=>{const e=Bn({},t);let{data:n,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:i,headers:o,auth:a}=e;e.headers=o=ze.from(o),e.url=Qg(s_(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let c;if(m.isFormData(n)){if(Be.hasStandardBrowserEnv||Be.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((c=o.getContentType())!==!1){const[l,...h]=c?c.split(";").map(u=>u.trim()).filter(Boolean):[];o.setContentType([l||"multipart/form-data",...h].join("; "))}}if(Be.hasStandardBrowserEnv&&(s&&m.isFunction(s)&&(s=s(e)),s||s!==!1&&Iv(e.url))){const l=r&&i&&Nv.read(i);l&&o.set(r,l)}return e},Lv=typeof XMLHttpRequest<"u",Dv=Lv&&function(t){return new Promise(function(n,s){const r=r_(t);let i=r.data;const o=ze.from(r.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:l}=r,h,u,d,p,f;function g(){p&&p(),f&&f(),r.cancelToken&&r.cancelToken.unsubscribe(h),r.signal&&r.signal.removeEventListener("abort",h)}let E=new XMLHttpRequest;E.open(r.method.toUpperCase(),r.url,!0),E.timeout=r.timeout;function R(){if(!E)return;const S=ze.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?E.responseText:E.response,status:E.status,statusText:E.statusText,headers:S,config:t,request:E};n_(function(I){n(I),g()},function(I){s(I),g()},C),E=null}"onloadend"in E?E.onloadend=R:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.indexOf("file:")===0)||setTimeout(R)},E.onabort=function(){E&&(s(new M("Request aborted",M.ECONNABORTED,t,E)),E=null)},E.onerror=function(){s(new M("Network Error",M.ERR_NETWORK,t,E)),E=null},E.ontimeout=function(){let D=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const C=r.transitional||Zg;r.timeoutErrorMessage&&(D=r.timeoutErrorMessage),s(new M(D,C.clarifyTimeoutError?M.ETIMEDOUT:M.ECONNABORTED,t,E)),E=null},i===void 0&&o.setContentType(null),"setRequestHeader"in E&&m.forEach(o.toJSON(),function(D,C){E.setRequestHeader(C,D)}),m.isUndefined(r.withCredentials)||(E.withCredentials=!!r.withCredentials),a&&a!=="json"&&(E.responseType=r.responseType),l&&([d,f]=Vi(l,!0),E.addEventListener("progress",d)),c&&E.upload&&([u,p]=Vi(c),E.upload.addEventListener("progress",u),E.upload.addEventListener("loadend",p)),(r.cancelToken||r.signal)&&(h=S=>{E&&(s(!S||S.type?new Ms(null,t,E):S),E.abort(),E=null)},r.cancelToken&&r.cancelToken.subscribe(h),r.signal&&(r.signal.aborted?h():r.signal.addEventListener("abort",h)));const y=Av(r.url);if(y&&Be.protocols.indexOf(y)===-1){s(new M("Unsupported protocol "+y+":",M.ERR_BAD_REQUEST,t));return}E.send(i||null)})},Pv=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let s=new AbortController,r;const i=function(l){if(!r){r=!0,a();const h=l instanceof Error?l:this.reason;s.abort(h instanceof M?h:new Ms(h instanceof Error?h.message:h))}};let o=e&&setTimeout(()=>{o=null,i(new M(`timeout ${e} of ms exceeded`,M.ETIMEDOUT))},e);const a=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(l=>{l.unsubscribe?l.unsubscribe(i):l.removeEventListener("abort",i)}),t=null)};t.forEach(l=>l.addEventListener("abort",i));const{signal:c}=s;return c.unsubscribe=()=>m.asap(a),c}},Fv=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let s=0,r;for(;s<n;)r=s+e,yield t.slice(s,r),s=r},Mv=async function*(t,e){for await(const n of Bv(t))yield*Fv(n,e)},Bv=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:s}=await e.read();if(n)break;yield s}}finally{await e.cancel()}},vd=(t,e,n,s)=>{const r=Mv(t,e);let i=0,o,a=c=>{o||(o=!0,s&&s(c))};return new ReadableStream({async pull(c){try{const{done:l,value:h}=await r.next();if(l){a(),c.close();return}let u=h.byteLength;if(n){let d=i+=u;n(d)}c.enqueue(new Uint8Array(h))}catch(l){throw a(l),l}},cancel(c){return a(c),r.return()}},{highWaterMark:2})},No=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",i_=No&&typeof ReadableStream=="function",Uv=No&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),o_=(t,...e)=>{try{return!!t(...e)}catch{return!1}},Vv=i_&&o_(()=>{let t=!1;const e=new Request(Be.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),wd=64*1024,ec=i_&&o_(()=>m.isReadableStream(new Response("").body)),Hi={stream:ec&&(t=>t.body)};No&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Hi[e]&&(Hi[e]=m.isFunction(t[e])?n=>n[e]():(n,s)=>{throw new M(`Response type '${e}' is not supported`,M.ERR_NOT_SUPPORT,s)})})})(new Response);const Hv=async t=>{if(t==null)return 0;if(m.isBlob(t))return t.size;if(m.isSpecCompliantForm(t))return(await new Request(Be.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(m.isArrayBufferView(t)||m.isArrayBuffer(t))return t.byteLength;if(m.isURLSearchParams(t)&&(t=t+""),m.isString(t))return(await Uv(t)).byteLength},Gv=async(t,e)=>{const n=m.toFiniteNumber(t.getContentLength());return n??Hv(e)},Wv=No&&(async t=>{let{url:e,method:n,data:s,signal:r,cancelToken:i,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:l,headers:h,withCredentials:u="same-origin",fetchOptions:d}=r_(t);l=l?(l+"").toLowerCase():"text";let p=Pv([r,i&&i.toAbortSignal()],o),f;const g=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let E;try{if(c&&Vv&&n!=="get"&&n!=="head"&&(E=await Gv(h,s))!==0){let C=new Request(e,{method:"POST",body:s,duplex:"half"}),_;if(m.isFormData(s)&&(_=C.headers.get("content-type"))&&h.setContentType(_),C.body){const[I,P]=_d(E,Vi(yd(c)));s=vd(C.body,wd,I,P)}}m.isString(u)||(u=u?"include":"omit");const R="credentials"in Request.prototype;f=new Request(e,{...d,signal:p,method:n.toUpperCase(),headers:h.normalize().toJSON(),body:s,duplex:"half",credentials:R?u:void 0});let y=await fetch(f);const S=ec&&(l==="stream"||l==="response");if(ec&&(a||S&&g)){const C={};["status","statusText","headers"].forEach(U=>{C[U]=y[U]});const _=m.toFiniteNumber(y.headers.get("content-length")),[I,P]=a&&_d(_,Vi(yd(a),!0))||[];y=new Response(vd(y.body,wd,I,()=>{P&&P(),g&&g()}),C)}l=l||"text";let D=await Hi[m.findKey(Hi,l)||"text"](y,t);return!S&&g&&g(),await new Promise((C,_)=>{n_(C,_,{data:D,headers:ze.from(y.headers),status:y.status,statusText:y.statusText,config:t,request:f})})}catch(R){throw g&&g(),R&&R.name==="TypeError"&&/fetch/i.test(R.message)?Object.assign(new M("Network Error",M.ERR_NETWORK,t,f),{cause:R.cause||R}):M.from(R,R&&R.code,t,f)}}),tc={http:rv,xhr:Dv,fetch:Wv};m.forEach(tc,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const bd=t=>`- ${t}`,$v=t=>m.isFunction(t)||t===null||t===!1,a_={getAdapter:t=>{t=m.isArray(t)?t:[t];const{length:e}=t;let n,s;const r={};for(let i=0;i<e;i++){n=t[i];let o;if(s=n,!$v(n)&&(s=tc[(o=String(n)).toLowerCase()],s===void 0))throw new M(`Unknown adapter '${o}'`);if(s)break;r[o||"#"+i]=s}if(!s){const i=Object.entries(r).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since :
1639
+ `)}getFrameStatistics(){const e=performance.now()-this.startTime,n=this.isContinuousMode?this.totalFrameCount:this.frameCount,s=e>0?n*1e3/e:0;let r=100;if(this.frameTimes.length>10){const i=[];for(let c=1;c<this.frameTimes.length;c++)i.push(this.frameTimes[c]-this.frameTimes[c-1]);const o=i.reduce((c,l)=>c+l,0)/i.length,a=i.reduce((c,l)=>c+Math.pow(l-o,2),0)/i.length;r=Math.max(0,(1-Math.sqrt(a)/o)*100)}return{frameCount:n,duplicateFrames:this.duplicateFrames,targetFPS:this.config.targetFPS,actualFPS:s,elapsedTime:e,temporalStability:r}}setTargetFPS(e){this.config.targetFPS=Math.max(1,Math.min(120,e)),this.frameInterval=1e3/this.config.targetFPS}isContinuousModeEnabled(){return this.isContinuousMode}getDataCollectionStatus(){var e,n,s,r,i,o;return this.faceLandmarker?{isCollectingData:this.isCollectingData,bufferSize:((n=(e=this.faceLandmarker).getRGBDataBufferSize)==null?void 0:n.call(e))??"Unknown",threshold:((r=(s=this.faceLandmarker).getDataCollectionThreshold)==null?void 0:r.call(s))??300,frameCount:this.frameCount,isContinuousMode:this.isContinuousMode,isDetectionActive:((o=(i=this.faceLandmarker).isDetectionCurrentlyActive)==null?void 0:o.call(i))??!1}:{error:"Face landmarker not initialized"}}getRGBTimestamps(){var e,n;return this.faceLandmarker?((n=(e=this.faceLandmarker).getRGBTimestamps)==null?void 0:n.call(e))??[]:[]}handleBatchResults(e){this.faceLandmarker&&this.faceLandmarker.handleBatchResults(e)}};w(Tn,"instance");let Ui=Tn;function Hg(t,e){return function(){return t.apply(e,arguments)}}const{toString:E4}=Object.prototype,{getPrototypeOf:zl}=Object,Ao=(t=>e=>{const n=E4.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),kt=t=>(t=t.toLowerCase(),e=>Ao(e)===t),Ro=t=>e=>typeof e===t,{isArray:Fs}=Array,br=Ro("undefined");function v4(t){return t!==null&&!br(t)&&t.constructor!==null&&!br(t.constructor)&&st(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Wg=kt("ArrayBuffer");function w4(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Wg(t.buffer),e}const b4=Ro("string"),st=Ro("function"),Gg=Ro("number"),ko=t=>t!==null&&typeof t=="object",T4=t=>t===!0||t===!1,ri=t=>{if(Ao(t)!=="object")return!1;const e=zl(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},C4=kt("Date"),S4=kt("File"),A4=kt("Blob"),R4=kt("FileList"),k4=t=>ko(t)&&st(t.pipe),I4=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||st(t.append)&&((e=Ao(t))==="formdata"||e==="object"&&st(t.toString)&&t.toString()==="[object FormData]"))},N4=kt("URLSearchParams"),[x4,O4,L4,D4]=["ReadableStream","Request","Response","Headers"].map(kt),P4=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Fr(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let s,r;if(typeof t!="object"&&(t=[t]),Fs(t))for(s=0,r=t.length;s<r;s++)e.call(null,t[s],s,t);else{const i=n?Object.getOwnPropertyNames(t):Object.keys(t),o=i.length;let a;for(s=0;s<o;s++)a=i[s],e.call(null,t[a],a,t)}}function $g(t,e){e=e.toLowerCase();const n=Object.keys(t);let s=n.length,r;for(;s-- >0;)if(r=n[s],e===r.toLowerCase())return r;return null}const In=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,jg=t=>!br(t)&&t!==In;function Ja(){const{caseless:t}=jg(this)&&this||{},e={},n=(s,r)=>{const i=t&&$g(e,r)||r;ri(e[i])&&ri(s)?e[i]=Ja(e[i],s):ri(s)?e[i]=Ja({},s):Fs(s)?e[i]=s.slice():e[i]=s};for(let s=0,r=arguments.length;s<r;s++)arguments[s]&&Fr(arguments[s],n);return e}const F4=(t,e,n,{allOwnKeys:s}={})=>(Fr(e,(r,i)=>{n&&st(r)?t[i]=Hg(r,n):t[i]=r},{allOwnKeys:s}),t),M4=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),B4=(t,e,n,s)=>{t.prototype=Object.create(e.prototype,s),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},U4=(t,e,n,s)=>{let r,i,o;const a={};if(e=e||{},t==null)return e;do{for(r=Object.getOwnPropertyNames(t),i=r.length;i-- >0;)o=r[i],(!s||s(o,t,e))&&!a[o]&&(e[o]=t[o],a[o]=!0);t=n!==!1&&zl(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},V4=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const s=t.indexOf(e,n);return s!==-1&&s===n},H4=t=>{if(!t)return null;if(Fs(t))return t;let e=t.length;if(!Gg(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},W4=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&zl(Uint8Array)),G4=(t,e)=>{const s=(t&&t[Symbol.iterator]).call(t);let r;for(;(r=s.next())&&!r.done;){const i=r.value;e.call(t,i[0],i[1])}},$4=(t,e)=>{let n;const s=[];for(;(n=t.exec(e))!==null;)s.push(n);return s},j4=kt("HTMLFormElement"),q4=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),dd=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),z4=kt("RegExp"),qg=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),s={};Fr(n,(r,i)=>{let o;(o=e(r,i,t))!==!1&&(s[i]=o||r)}),Object.defineProperties(t,s)},K4=t=>{qg(t,(e,n)=>{if(st(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const s=t[n];if(st(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Y4=(t,e)=>{const n={},s=r=>{r.forEach(i=>{n[i]=!0})};return Fs(t)?s(t):s(String(t).split(e)),n},X4=()=>{},J4=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function Q4(t){return!!(t&&st(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const Z4=t=>{const e=new Array(10),n=(s,r)=>{if(ko(s)){if(e.indexOf(s)>=0)return;if(!("toJSON"in s)){e[r]=s;const i=Fs(s)?[]:{};return Fr(s,(o,a)=>{const c=n(o,r+1);!br(c)&&(i[a]=c)}),e[r]=void 0,i}}return s};return n(t,0)},ev=kt("AsyncFunction"),tv=t=>t&&(ko(t)||st(t))&&st(t.then)&&st(t.catch),zg=((t,e)=>t?setImmediate:e?((n,s)=>(In.addEventListener("message",({source:r,data:i})=>{r===In&&i===n&&s.length&&s.shift()()},!1),r=>{s.push(r),In.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",st(In.postMessage)),nv=typeof queueMicrotask<"u"?queueMicrotask.bind(In):typeof process<"u"&&process.nextTick||zg,m={isArray:Fs,isArrayBuffer:Wg,isBuffer:v4,isFormData:I4,isArrayBufferView:w4,isString:b4,isNumber:Gg,isBoolean:T4,isObject:ko,isPlainObject:ri,isReadableStream:x4,isRequest:O4,isResponse:L4,isHeaders:D4,isUndefined:br,isDate:C4,isFile:S4,isBlob:A4,isRegExp:z4,isFunction:st,isStream:k4,isURLSearchParams:N4,isTypedArray:W4,isFileList:R4,forEach:Fr,merge:Ja,extend:F4,trim:P4,stripBOM:M4,inherits:B4,toFlatObject:U4,kindOf:Ao,kindOfTest:kt,endsWith:V4,toArray:H4,forEachEntry:G4,matchAll:$4,isHTMLForm:j4,hasOwnProperty:dd,hasOwnProp:dd,reduceDescriptors:qg,freezeMethods:K4,toObjectSet:Y4,toCamelCase:q4,noop:X4,toFiniteNumber:J4,findKey:$g,global:In,isContextDefined:jg,isSpecCompliantForm:Q4,toJSONObject:Z4,isAsyncFn:ev,isThenable:tv,setImmediate:zg,asap:nv};function M(t,e,n,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),s&&(this.request=s),r&&(this.response=r,this.status=r.status?r.status:null)}m.inherits(M,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:m.toJSONObject(this.config),code:this.code,status:this.status}}});const Kg=M.prototype,Yg={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{Yg[t]={value:t}});Object.defineProperties(M,Yg);Object.defineProperty(Kg,"isAxiosError",{value:!0});M.from=(t,e,n,s,r,i)=>{const o=Object.create(Kg);return m.toFlatObject(t,o,function(c){return c!==Error.prototype},a=>a!=="isAxiosError"),M.call(o,t.message,e,n,s,r),o.cause=t,o.name=t.name,i&&Object.assign(o,i),o};const sv=null;function Qa(t){return m.isPlainObject(t)||m.isArray(t)}function Xg(t){return m.endsWith(t,"[]")?t.slice(0,-2):t}function fd(t,e,n){return t?t.concat(e).map(function(r,i){return r=Xg(r),!n&&i?"["+r+"]":r}).join(n?".":""):e}function rv(t){return m.isArray(t)&&!t.some(Qa)}const iv=m.toFlatObject(m,{},null,function(e){return/^is[A-Z]/.test(e)});function Io(t,e,n){if(!m.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=m.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,E){return!m.isUndefined(E[g])});const s=n.metaTokens,r=n.visitor||h,i=n.dots,o=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&m.isSpecCompliantForm(e);if(!m.isFunction(r))throw new TypeError("visitor must be a function");function l(f){if(f===null)return"";if(m.isDate(f))return f.toISOString();if(!c&&m.isBlob(f))throw new M("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(f)||m.isTypedArray(f)?c&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function h(f,g,E){let R=f;if(f&&!E&&typeof f=="object"){if(m.endsWith(g,"{}"))g=s?g:g.slice(0,-2),f=JSON.stringify(f);else if(m.isArray(f)&&rv(f)||(m.isFileList(f)||m.endsWith(g,"[]"))&&(R=m.toArray(f)))return g=Xg(g),R.forEach(function(S,D){!(m.isUndefined(S)||S===null)&&e.append(o===!0?fd([g],D,i):o===null?g:g+"[]",l(S))}),!1}return Qa(f)?!0:(e.append(fd(E,g,i),l(f)),!1)}const u=[],d=Object.assign(iv,{defaultVisitor:h,convertValue:l,isVisitable:Qa});function p(f,g){if(!m.isUndefined(f)){if(u.indexOf(f)!==-1)throw Error("Circular reference detected in "+g.join("."));u.push(f),m.forEach(f,function(R,y){(!(m.isUndefined(R)||R===null)&&r.call(e,R,m.isString(y)?y.trim():y,g,d))===!0&&p(R,g?g.concat(y):[y])}),u.pop()}}if(!m.isObject(t))throw new TypeError("data must be an object");return p(t),e}function pd(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function Kl(t,e){this._pairs=[],t&&Io(t,this,e)}const Jg=Kl.prototype;Jg.append=function(e,n){this._pairs.push([e,n])};Jg.toString=function(e){const n=e?function(s){return e.call(this,s,pd)}:pd;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function ov(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Qg(t,e,n){if(!e)return t;const s=n&&n.encode||ov;m.isFunction(n)&&(n={serialize:n});const r=n&&n.serialize;let i;if(r?i=r(e,n):i=m.isURLSearchParams(e)?e.toString():new Kl(e,n).toString(s),i){const o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+i}return t}class md{constructor(){this.handlers=[]}use(e,n,s){return this.handlers.push({fulfilled:e,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){m.forEach(this.handlers,function(s){s!==null&&e(s)})}}const Zg={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},av=typeof URLSearchParams<"u"?URLSearchParams:Kl,cv=typeof FormData<"u"?FormData:null,lv=typeof Blob<"u"?Blob:null,hv={isBrowser:!0,classes:{URLSearchParams:av,FormData:cv,Blob:lv},protocols:["http","https","file","blob","url","data"]},Yl=typeof window<"u"&&typeof document<"u",Za=typeof navigator=="object"&&navigator||void 0,uv=Yl&&(!Za||["ReactNative","NativeScript","NS"].indexOf(Za.product)<0),dv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",fv=Yl&&window.location.href||"http://localhost",pv=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Yl,hasStandardBrowserEnv:uv,hasStandardBrowserWebWorkerEnv:dv,navigator:Za,origin:fv},Symbol.toStringTag,{value:"Module"})),Be={...pv,...hv};function mv(t,e){return Io(t,new Be.classes.URLSearchParams,Object.assign({visitor:function(n,s,r,i){return Be.isNode&&m.isBuffer(n)?(this.append(s,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function gv(t){return m.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function _v(t){const e={},n=Object.keys(t);let s;const r=n.length;let i;for(s=0;s<r;s++)i=n[s],e[i]=t[i];return e}function e_(t){function e(n,s,r,i){let o=n[i++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),c=i>=n.length;return o=!o&&m.isArray(r)?r.length:o,c?(m.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!a):((!r[o]||!m.isObject(r[o]))&&(r[o]=[]),e(n,s,r[o],i)&&m.isArray(r[o])&&(r[o]=_v(r[o])),!a)}if(m.isFormData(t)&&m.isFunction(t.entries)){const n={};return m.forEachEntry(t,(s,r)=>{e(gv(s),r,n,0)}),n}return null}function yv(t,e,n){if(m.isString(t))try{return(e||JSON.parse)(t),m.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(t)}const Mr={transitional:Zg,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const s=n.getContentType()||"",r=s.indexOf("application/json")>-1,i=m.isObject(e);if(i&&m.isHTMLForm(e)&&(e=new FormData(e)),m.isFormData(e))return r?JSON.stringify(e_(e)):e;if(m.isArrayBuffer(e)||m.isBuffer(e)||m.isStream(e)||m.isFile(e)||m.isBlob(e)||m.isReadableStream(e))return e;if(m.isArrayBufferView(e))return e.buffer;if(m.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return mv(e,this.formSerializer).toString();if((a=m.isFileList(e))||s.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Io(a?{"files[]":e}:e,c&&new c,this.formSerializer)}}return i||r?(n.setContentType("application/json",!1),yv(e)):e}],transformResponse:[function(e){const n=this.transitional||Mr.transitional,s=n&&n.forcedJSONParsing,r=this.responseType==="json";if(m.isResponse(e)||m.isReadableStream(e))return e;if(e&&m.isString(e)&&(s&&!this.responseType||r)){const o=!(n&&n.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?M.from(a,M.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Be.classes.FormData,Blob:Be.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};m.forEach(["delete","get","head","post","put","patch"],t=>{Mr.headers[t]={}});const Ev=m.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),vv=t=>{const e={};let n,s,r;return t&&t.split(`
1640
+ `).forEach(function(o){r=o.indexOf(":"),n=o.substring(0,r).trim().toLowerCase(),s=o.substring(r+1).trim(),!(!n||e[n]&&Ev[n])&&(n==="set-cookie"?e[n]?e[n].push(s):e[n]=[s]:e[n]=e[n]?e[n]+", "+s:s)}),e},gd=Symbol("internals");function qs(t){return t&&String(t).trim().toLowerCase()}function ii(t){return t===!1||t==null?t:m.isArray(t)?t.map(ii):String(t)}function wv(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=n.exec(t);)e[s[1]]=s[2];return e}const bv=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function la(t,e,n,s,r){if(m.isFunction(s))return s.call(this,e,n);if(r&&(e=n),!!m.isString(e)){if(m.isString(s))return e.indexOf(s)!==-1;if(m.isRegExp(s))return s.test(e)}}function Tv(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,s)=>n.toUpperCase()+s)}function Cv(t,e){const n=m.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(t,s+n,{value:function(r,i,o){return this[s].call(this,e,r,i,o)},configurable:!0})})}let ze=class{constructor(e){e&&this.set(e)}set(e,n,s){const r=this;function i(a,c,l){const h=qs(c);if(!h)throw new Error("header name must be a non-empty string");const u=m.findKey(r,h);(!u||r[u]===void 0||l===!0||l===void 0&&r[u]!==!1)&&(r[u||c]=ii(a))}const o=(a,c)=>m.forEach(a,(l,h)=>i(l,h,c));if(m.isPlainObject(e)||e instanceof this.constructor)o(e,n);else if(m.isString(e)&&(e=e.trim())&&!bv(e))o(vv(e),n);else if(m.isHeaders(e))for(const[a,c]of e.entries())i(c,a,s);else e!=null&&i(n,e,s);return this}get(e,n){if(e=qs(e),e){const s=m.findKey(this,e);if(s){const r=this[s];if(!n)return r;if(n===!0)return wv(r);if(m.isFunction(n))return n.call(this,r,s);if(m.isRegExp(n))return n.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=qs(e),e){const s=m.findKey(this,e);return!!(s&&this[s]!==void 0&&(!n||la(this,this[s],s,n)))}return!1}delete(e,n){const s=this;let r=!1;function i(o){if(o=qs(o),o){const a=m.findKey(s,o);a&&(!n||la(s,s[a],a,n))&&(delete s[a],r=!0)}}return m.isArray(e)?e.forEach(i):i(e),r}clear(e){const n=Object.keys(this);let s=n.length,r=!1;for(;s--;){const i=n[s];(!e||la(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){const n=this,s={};return m.forEach(this,(r,i)=>{const o=m.findKey(s,i);if(o){n[o]=ii(r),delete n[i];return}const a=e?Tv(i):String(i).trim();a!==i&&delete n[i],n[a]=ii(r),s[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return m.forEach(this,(s,r)=>{s!=null&&s!==!1&&(n[r]=e&&m.isArray(s)?s.join(", "):s)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
1641
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const s=new this(e);return n.forEach(r=>s.set(r)),s}static accessor(e){const s=(this[gd]=this[gd]={accessors:{}}).accessors,r=this.prototype;function i(o){const a=qs(o);s[a]||(Cv(r,o),s[a]=!0)}return m.isArray(e)?e.forEach(i):i(e),this}};ze.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);m.reduceDescriptors(ze.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(s){this[n]=s}}});m.freezeMethods(ze);function ha(t,e){const n=this||Mr,s=e||n,r=ze.from(s.headers);let i=s.data;return m.forEach(t,function(a){i=a.call(n,i,r.normalize(),e?e.status:void 0)}),r.normalize(),i}function t_(t){return!!(t&&t.__CANCEL__)}function Ms(t,e,n){M.call(this,t??"canceled",M.ERR_CANCELED,e,n),this.name="CanceledError"}m.inherits(Ms,M,{__CANCEL__:!0});function n_(t,e,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?t(n):e(new M("Request failed with status code "+n.status,[M.ERR_BAD_REQUEST,M.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Sv(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Av(t,e){t=t||10;const n=new Array(t),s=new Array(t);let r=0,i=0,o;return e=e!==void 0?e:1e3,function(c){const l=Date.now(),h=s[i];o||(o=l),n[r]=c,s[r]=l;let u=i,d=0;for(;u!==r;)d+=n[u++],u=u%t;if(r=(r+1)%t,r===i&&(i=(i+1)%t),l-o<e)return;const p=h&&l-h;return p?Math.round(d*1e3/p):void 0}}function Rv(t,e){let n=0,s=1e3/e,r,i;const o=(l,h=Date.now())=>{n=h,r=null,i&&(clearTimeout(i),i=null),t.apply(null,l)};return[(...l)=>{const h=Date.now(),u=h-n;u>=s?o(l,h):(r=l,i||(i=setTimeout(()=>{i=null,o(r)},s-u)))},()=>r&&o(r)]}const Vi=(t,e,n=3)=>{let s=0;const r=Av(50,250);return Rv(i=>{const o=i.loaded,a=i.lengthComputable?i.total:void 0,c=o-s,l=r(c),h=o<=a;s=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&h?(a-o)/l:void 0,event:i,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(u)},n)},_d=(t,e)=>{const n=t!=null;return[s=>e[0]({lengthComputable:n,total:t,loaded:s}),e[1]]},yd=t=>(...e)=>m.asap(()=>t(...e)),kv=Be.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,Be.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(Be.origin),Be.navigator&&/(msie|trident)/i.test(Be.navigator.userAgent)):()=>!0,Iv=Be.hasStandardBrowserEnv?{write(t,e,n,s,r,i){const o=[t+"="+encodeURIComponent(e)];m.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),m.isString(s)&&o.push("path="+s),m.isString(r)&&o.push("domain="+r),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Nv(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function xv(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function s_(t,e,n){let s=!Nv(e);return t&&(s||n==!1)?xv(t,e):e}const Ed=t=>t instanceof ze?{...t}:t;function Bn(t,e){e=e||{};const n={};function s(l,h,u,d){return m.isPlainObject(l)&&m.isPlainObject(h)?m.merge.call({caseless:d},l,h):m.isPlainObject(h)?m.merge({},h):m.isArray(h)?h.slice():h}function r(l,h,u,d){if(m.isUndefined(h)){if(!m.isUndefined(l))return s(void 0,l,u,d)}else return s(l,h,u,d)}function i(l,h){if(!m.isUndefined(h))return s(void 0,h)}function o(l,h){if(m.isUndefined(h)){if(!m.isUndefined(l))return s(void 0,l)}else return s(void 0,h)}function a(l,h,u){if(u in e)return s(l,h);if(u in t)return s(void 0,l)}const c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(l,h,u)=>r(Ed(l),Ed(h),u,!0)};return m.forEach(Object.keys(Object.assign({},t,e)),function(h){const u=c[h]||r,d=u(t[h],e[h],h);m.isUndefined(d)&&u!==a||(n[h]=d)}),n}const r_=t=>{const e=Bn({},t);let{data:n,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:i,headers:o,auth:a}=e;e.headers=o=ze.from(o),e.url=Qg(s_(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let c;if(m.isFormData(n)){if(Be.hasStandardBrowserEnv||Be.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((c=o.getContentType())!==!1){const[l,...h]=c?c.split(";").map(u=>u.trim()).filter(Boolean):[];o.setContentType([l||"multipart/form-data",...h].join("; "))}}if(Be.hasStandardBrowserEnv&&(s&&m.isFunction(s)&&(s=s(e)),s||s!==!1&&kv(e.url))){const l=r&&i&&Iv.read(i);l&&o.set(r,l)}return e},Ov=typeof XMLHttpRequest<"u",Lv=Ov&&function(t){return new Promise(function(n,s){const r=r_(t);let i=r.data;const o=ze.from(r.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:l}=r,h,u,d,p,f;function g(){p&&p(),f&&f(),r.cancelToken&&r.cancelToken.unsubscribe(h),r.signal&&r.signal.removeEventListener("abort",h)}let E=new XMLHttpRequest;E.open(r.method.toUpperCase(),r.url,!0),E.timeout=r.timeout;function R(){if(!E)return;const S=ze.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?E.responseText:E.response,status:E.status,statusText:E.statusText,headers:S,config:t,request:E};n_(function(I){n(I),g()},function(I){s(I),g()},C),E=null}"onloadend"in E?E.onloadend=R:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.indexOf("file:")===0)||setTimeout(R)},E.onabort=function(){E&&(s(new M("Request aborted",M.ECONNABORTED,t,E)),E=null)},E.onerror=function(){s(new M("Network Error",M.ERR_NETWORK,t,E)),E=null},E.ontimeout=function(){let D=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const C=r.transitional||Zg;r.timeoutErrorMessage&&(D=r.timeoutErrorMessage),s(new M(D,C.clarifyTimeoutError?M.ETIMEDOUT:M.ECONNABORTED,t,E)),E=null},i===void 0&&o.setContentType(null),"setRequestHeader"in E&&m.forEach(o.toJSON(),function(D,C){E.setRequestHeader(C,D)}),m.isUndefined(r.withCredentials)||(E.withCredentials=!!r.withCredentials),a&&a!=="json"&&(E.responseType=r.responseType),l&&([d,f]=Vi(l,!0),E.addEventListener("progress",d)),c&&E.upload&&([u,p]=Vi(c),E.upload.addEventListener("progress",u),E.upload.addEventListener("loadend",p)),(r.cancelToken||r.signal)&&(h=S=>{E&&(s(!S||S.type?new Ms(null,t,E):S),E.abort(),E=null)},r.cancelToken&&r.cancelToken.subscribe(h),r.signal&&(r.signal.aborted?h():r.signal.addEventListener("abort",h)));const y=Sv(r.url);if(y&&Be.protocols.indexOf(y)===-1){s(new M("Unsupported protocol "+y+":",M.ERR_BAD_REQUEST,t));return}E.send(i||null)})},Dv=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let s=new AbortController,r;const i=function(l){if(!r){r=!0,a();const h=l instanceof Error?l:this.reason;s.abort(h instanceof M?h:new Ms(h instanceof Error?h.message:h))}};let o=e&&setTimeout(()=>{o=null,i(new M(`timeout ${e} of ms exceeded`,M.ETIMEDOUT))},e);const a=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(l=>{l.unsubscribe?l.unsubscribe(i):l.removeEventListener("abort",i)}),t=null)};t.forEach(l=>l.addEventListener("abort",i));const{signal:c}=s;return c.unsubscribe=()=>m.asap(a),c}},Pv=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let s=0,r;for(;s<n;)r=s+e,yield t.slice(s,r),s=r},Fv=async function*(t,e){for await(const n of Mv(t))yield*Pv(n,e)},Mv=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:s}=await e.read();if(n)break;yield s}}finally{await e.cancel()}},vd=(t,e,n,s)=>{const r=Fv(t,e);let i=0,o,a=c=>{o||(o=!0,s&&s(c))};return new ReadableStream({async pull(c){try{const{done:l,value:h}=await r.next();if(l){a(),c.close();return}let u=h.byteLength;if(n){let d=i+=u;n(d)}c.enqueue(new Uint8Array(h))}catch(l){throw a(l),l}},cancel(c){return a(c),r.return()}},{highWaterMark:2})},No=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",i_=No&&typeof ReadableStream=="function",Bv=No&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),o_=(t,...e)=>{try{return!!t(...e)}catch{return!1}},Uv=i_&&o_(()=>{let t=!1;const e=new Request(Be.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),wd=64*1024,ec=i_&&o_(()=>m.isReadableStream(new Response("").body)),Hi={stream:ec&&(t=>t.body)};No&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Hi[e]&&(Hi[e]=m.isFunction(t[e])?n=>n[e]():(n,s)=>{throw new M(`Response type '${e}' is not supported`,M.ERR_NOT_SUPPORT,s)})})})(new Response);const Vv=async t=>{if(t==null)return 0;if(m.isBlob(t))return t.size;if(m.isSpecCompliantForm(t))return(await new Request(Be.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(m.isArrayBufferView(t)||m.isArrayBuffer(t))return t.byteLength;if(m.isURLSearchParams(t)&&(t=t+""),m.isString(t))return(await Bv(t)).byteLength},Hv=async(t,e)=>{const n=m.toFiniteNumber(t.getContentLength());return n??Vv(e)},Wv=No&&(async t=>{let{url:e,method:n,data:s,signal:r,cancelToken:i,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:l,headers:h,withCredentials:u="same-origin",fetchOptions:d}=r_(t);l=l?(l+"").toLowerCase():"text";let p=Dv([r,i&&i.toAbortSignal()],o),f;const g=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let E;try{if(c&&Uv&&n!=="get"&&n!=="head"&&(E=await Hv(h,s))!==0){let C=new Request(e,{method:"POST",body:s,duplex:"half"}),_;if(m.isFormData(s)&&(_=C.headers.get("content-type"))&&h.setContentType(_),C.body){const[I,P]=_d(E,Vi(yd(c)));s=vd(C.body,wd,I,P)}}m.isString(u)||(u=u?"include":"omit");const R="credentials"in Request.prototype;f=new Request(e,{...d,signal:p,method:n.toUpperCase(),headers:h.normalize().toJSON(),body:s,duplex:"half",credentials:R?u:void 0});let y=await fetch(f);const S=ec&&(l==="stream"||l==="response");if(ec&&(a||S&&g)){const C={};["status","statusText","headers"].forEach(U=>{C[U]=y[U]});const _=m.toFiniteNumber(y.headers.get("content-length")),[I,P]=a&&_d(_,Vi(yd(a),!0))||[];y=new Response(vd(y.body,wd,I,()=>{P&&P(),g&&g()}),C)}l=l||"text";let D=await Hi[m.findKey(Hi,l)||"text"](y,t);return!S&&g&&g(),await new Promise((C,_)=>{n_(C,_,{data:D,headers:ze.from(y.headers),status:y.status,statusText:y.statusText,config:t,request:f})})}catch(R){throw g&&g(),R&&R.name==="TypeError"&&/fetch/i.test(R.message)?Object.assign(new M("Network Error",M.ERR_NETWORK,t,f),{cause:R.cause||R}):M.from(R,R&&R.code,t,f)}}),tc={http:sv,xhr:Lv,fetch:Wv};m.forEach(tc,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const bd=t=>`- ${t}`,Gv=t=>m.isFunction(t)||t===null||t===!1,a_={getAdapter:t=>{t=m.isArray(t)?t:[t];const{length:e}=t;let n,s;const r={};for(let i=0;i<e;i++){n=t[i];let o;if(s=n,!Gv(n)&&(s=tc[(o=String(n)).toLowerCase()],s===void 0))throw new M(`Unknown adapter '${o}'`);if(s)break;r[o||"#"+i]=s}if(!s){const i=Object.entries(r).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since :
1642
1642
  `+i.map(bd).join(`
1643
- `):" "+bd(i[0]):"as no adapter specified";throw new M("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return s},adapters:tc};function ua(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ms(null,t)}function Td(t){return ua(t),t.headers=ze.from(t.headers),t.data=ha.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),a_.getAdapter(t.adapter||Mr.adapter)(t).then(function(s){return ua(t),s.data=ha.call(t,t.transformResponse,s),s.headers=ze.from(s.headers),s},function(s){return t_(s)||(ua(t),s&&s.response&&(s.response.data=ha.call(t,t.transformResponse,s.response),s.response.headers=ze.from(s.response.headers))),Promise.reject(s)})}const c_="1.8.4",xo={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{xo[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}});const Cd={};xo.transitional=function(e,n,s){function r(i,o){return"[Axios v"+c_+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return(i,o,a)=>{if(e===!1)throw new M(r(o," has been removed"+(n?" in "+n:"")),M.ERR_DEPRECATED);return n&&!Cd[o]&&(Cd[o]=!0,console.warn(r(o," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(i,o,a):!0}};xo.spelling=function(e){return(n,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function jv(t,e,n){if(typeof t!="object")throw new M("options must be an object",M.ERR_BAD_OPTION_VALUE);const s=Object.keys(t);let r=s.length;for(;r-- >0;){const i=s[r],o=e[i];if(o){const a=t[i],c=a===void 0||o(a,i,t);if(c!==!0)throw new M("option "+i+" must be "+c,M.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new M("Unknown option "+i,M.ERR_BAD_OPTION)}}const oi={assertOptions:jv,validators:xo},Dt=oi.validators;let xn=class{constructor(e){this.defaults=e,this.interceptors={request:new md,response:new md}}async request(e,n){try{return await this._request(e,n)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{s.stack?i&&!String(s.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(s.stack+=`
1644
- `+i):s.stack=i}catch{}}throw s}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=Bn(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:i}=n;s!==void 0&&oi.assertOptions(s,{silentJSONParsing:Dt.transitional(Dt.boolean),forcedJSONParsing:Dt.transitional(Dt.boolean),clarifyTimeoutError:Dt.transitional(Dt.boolean)},!1),r!=null&&(m.isFunction(r)?n.paramsSerializer={serialize:r}:oi.assertOptions(r,{encode:Dt.function,serialize:Dt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),oi.assertOptions(n,{baseUrl:Dt.spelling("baseURL"),withXsrfToken:Dt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&m.merge(i.common,i[n.method]);i&&m.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),n.headers=ze.concat(o,i);const a=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(c=c&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const l=[];this.interceptors.response.forEach(function(g){l.push(g.fulfilled,g.rejected)});let h,u=0,d;if(!c){const f=[Td.bind(this),void 0];for(f.unshift.apply(f,a),f.push.apply(f,l),d=f.length,h=Promise.resolve(n);u<d;)h=h.then(f[u++],f[u++]);return h}d=a.length;let p=n;for(u=0;u<d;){const f=a[u++],g=a[u++];try{p=f(p)}catch(E){g.call(this,E);break}}try{h=Td.call(this,p)}catch(f){return Promise.reject(f)}for(u=0,d=l.length;u<d;)h=h.then(l[u++],l[u++]);return h}getUri(e){e=Bn(this.defaults,e);const n=s_(e.baseURL,e.url,e.allowAbsoluteUrls);return Qg(n,e.params,e.paramsSerializer)}};m.forEach(["delete","get","head","options"],function(e){xn.prototype[e]=function(n,s){return this.request(Bn(s||{},{method:e,url:n,data:(s||{}).data}))}});m.forEach(["post","put","patch"],function(e){function n(s){return function(i,o,a){return this.request(Bn(a||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}xn.prototype[e]=n(),xn.prototype[e+"Form"]=n(!0)});let qv=class l_{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const s=this;this.promise.then(r=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](r);s._listeners=null}),this.promise.then=r=>{let i;const o=new Promise(a=>{s.subscribe(a),i=a}).then(r);return o.cancel=function(){s.unsubscribe(i)},o},e(function(i,o,a){s.reason||(s.reason=new Ms(i,o,a),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=s=>{e.abort(s)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new l_(function(r){e=r}),cancel:e}}};function zv(t){return function(n){return t.apply(null,n)}}function Kv(t){return m.isObject(t)&&t.isAxiosError===!0}const nc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(nc).forEach(([t,e])=>{nc[e]=t});function h_(t){const e=new xn(t),n=Hg(xn.prototype.request,e);return m.extend(n,xn.prototype,e,{allOwnKeys:!0}),m.extend(n,e,null,{allOwnKeys:!0}),n.create=function(r){return h_(Bn(t,r))},n}const Z=h_(Mr);Z.Axios=xn;Z.CanceledError=Ms;Z.CancelToken=qv;Z.isCancel=t_;Z.VERSION=c_;Z.toFormData=Io;Z.AxiosError=M;Z.Cancel=Z.CanceledError;Z.all=function(e){return Promise.all(e)};Z.spread=zv;Z.isAxiosError=Kv;Z.mergeConfig=Bn;Z.AxiosHeaders=ze;Z.formToJSON=t=>e_(m.isHTMLForm(t)?new FormData(t):t);Z.getAdapter=a_.getAdapter;Z.HttpStatusCode=nc;Z.default=Z;const{Axios:Qw,AxiosError:Zw,CanceledError:eb,isCancel:tb,CancelToken:nb,VERSION:sb,all:rb,Cancel:ib,isAxiosError:ob,spread:ab,toFormData:cb,AxiosHeaders:lb,HttpStatusCode:hb,formToJSON:ub,getAdapter:db,mergeConfig:fb}=Z,Mt=Object.create(null);Mt.open="0";Mt.close="1";Mt.ping="2";Mt.pong="3";Mt.message="4";Mt.upgrade="5";Mt.noop="6";const ai=Object.create(null);Object.keys(Mt).forEach(t=>{ai[Mt[t]]=t});const sc={type:"error",data:"parser error"},u_=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",d_=typeof ArrayBuffer=="function",f_=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,Xl=({type:t,data:e},n,s)=>u_&&e instanceof Blob?n?s(e):Sd(e,s):d_&&(e instanceof ArrayBuffer||f_(e))?n?s(e):Sd(new Blob([e]),s):s(Mt[t]+(e||"")),Sd=(t,e)=>{const n=new FileReader;return n.onload=function(){const s=n.result.split(",")[1];e("b"+(s||""))},n.readAsDataURL(t)};function Ad(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let da;function Yv(t,e){if(u_&&t.data instanceof Blob)return t.data.arrayBuffer().then(Ad).then(e);if(d_&&(t.data instanceof ArrayBuffer||f_(t.data)))return e(Ad(t.data));Xl(t,!1,n=>{da||(da=new TextEncoder),e(da.encode(n))})}const Rd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Js=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Rd.length;t++)Js[Rd.charCodeAt(t)]=t;const Xv=t=>{let e=t.length*.75,n=t.length,s,r=0,i,o,a,c;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const l=new ArrayBuffer(e),h=new Uint8Array(l);for(s=0;s<n;s+=4)i=Js[t.charCodeAt(s)],o=Js[t.charCodeAt(s+1)],a=Js[t.charCodeAt(s+2)],c=Js[t.charCodeAt(s+3)],h[r++]=i<<2|o>>4,h[r++]=(o&15)<<4|a>>2,h[r++]=(a&3)<<6|c&63;return l},Jv=typeof ArrayBuffer=="function",Jl=(t,e)=>{if(typeof t!="string")return{type:"message",data:p_(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:Qv(t.substring(1),e)}:ai[n]?t.length>1?{type:ai[n],data:t.substring(1)}:{type:ai[n]}:sc},Qv=(t,e)=>{if(Jv){const n=Xv(t);return p_(n,e)}else return{base64:!0,data:t}},p_=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},m_="",Zv=(t,e)=>{const n=t.length,s=new Array(n);let r=0;t.forEach((i,o)=>{Xl(i,!1,a=>{s[o]=a,++r===n&&e(s.join(m_))})})},ew=(t,e)=>{const n=t.split(m_),s=[];for(let r=0;r<n.length;r++){const i=Jl(n[r],e);if(s.push(i),i.type==="error")break}return s};function tw(){return new TransformStream({transform(t,e){Yv(t,n=>{const s=n.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,s)}else{r=new Uint8Array(9);const i=new DataView(r.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(s))}t.data&&typeof t.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(n)})}})}let fa;function Kr(t){return t.reduce((e,n)=>e+n.length,0)}function Yr(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let s=0;for(let r=0;r<e;r++)n[r]=t[0][s++],s===t[0].length&&(t.shift(),s=0);return t.length&&s<t[0].length&&(t[0]=t[0].slice(s)),n}function nw(t,e){fa||(fa=new TextDecoder);const n=[];let s=0,r=-1,i=!1;return new TransformStream({transform(o,a){for(n.push(o);;){if(s===0){if(Kr(n)<1)break;const c=Yr(n,1);i=(c[0]&128)===128,r=c[0]&127,r<126?s=3:r===126?s=1:s=2}else if(s===1){if(Kr(n)<2)break;const c=Yr(n,2);r=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),s=3}else if(s===2){if(Kr(n)<8)break;const c=Yr(n,8),l=new DataView(c.buffer,c.byteOffset,c.length),h=l.getUint32(0);if(h>Math.pow(2,21)-1){a.enqueue(sc);break}r=h*Math.pow(2,32)+l.getUint32(4),s=3}else{if(Kr(n)<r)break;const c=Yr(n,r);a.enqueue(Jl(i?c:fa.decode(c),e)),s=0}if(r===0||r>t){a.enqueue(sc);break}}}})}const g_=4;function Ce(t){if(t)return sw(t)}function sw(t){for(var e in Ce.prototype)t[e]=Ce.prototype[e];return t}Ce.prototype.on=Ce.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};Ce.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};Ce.prototype.off=Ce.prototype.removeListener=Ce.prototype.removeAllListeners=Ce.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var s,r=0;r<n.length;r++)if(s=n[r],s===e||s.fn===e){n.splice(r,1);break}return n.length===0&&delete this._callbacks["$"+t],this};Ce.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(n){n=n.slice(0);for(var s=0,r=n.length;s<r;++s)n[s].apply(this,e)}return this};Ce.prototype.emitReserved=Ce.prototype.emit;Ce.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};Ce.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Oo=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),dt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),rw="arraybuffer";function __(t,...e){return e.reduce((n,s)=>(t.hasOwnProperty(s)&&(n[s]=t[s]),n),{})}const iw=dt.setTimeout,ow=dt.clearTimeout;function Lo(t,e){e.useNativeTimers?(t.setTimeoutFn=iw.bind(dt),t.clearTimeoutFn=ow.bind(dt)):(t.setTimeoutFn=dt.setTimeout.bind(dt),t.clearTimeoutFn=dt.clearTimeout.bind(dt))}const aw=1.33;function cw(t){return typeof t=="string"?lw(t):Math.ceil((t.byteLength||t.size)*aw)}function lw(t){let e=0,n=0;for(let s=0,r=t.length;s<r;s++)e=t.charCodeAt(s),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(s++,n+=4);return n}function y_(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function hw(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function uw(t){let e={},n=t.split("&");for(let s=0,r=n.length;s<r;s++){let i=n[s].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}class dw extends Error{constructor(e,n,s){super(e),this.description=n,this.context=s,this.type="TransportError"}}class Ql extends Ce{constructor(e){super(),this.writable=!1,Lo(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,s){return super.emitReserved("error",new dw(e,n,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=Jl(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=hw(e);return n.length?"?"+n:""}}class fw extends Ql{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||n()})),this.writable||(s++,this.once("drain",function(){--s||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};ew(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Zv(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=y_()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let E_=!1;try{E_=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const pw=E_;function mw(){}class gw extends fw{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let s=location.port;s||(s=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,n){const s=this.request({method:"POST",data:e});s.on("success",n),s.on("error",(r,i)=>{this.onError("xhr post error",r,i)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,s)=>{this.onError("xhr poll error",n,s)}),this.pollXhr=e}}let cs=class ci extends Ce{constructor(e,n,s){super(),this.createRequest=e,Lo(this,s),this._opts=s,this._method=s.method||"GET",this._uri=n,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var e;const n=__(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(n);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&s.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var r;s.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=ci.requestsCount++,ci.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=mw,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete ci.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};cs.requestsCount=0;cs.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",kd);else if(typeof addEventListener=="function"){const t="onpagehide"in dt?"pagehide":"unload";addEventListener(t,kd,!1)}}function kd(){for(let t in cs.requests)cs.requests.hasOwnProperty(t)&&cs.requests[t].abort()}const _w=function(){const t=v_({xdomain:!1});return t&&t.responseType!==null}();class yw extends gw{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=_w&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new cs(v_,this.uri(),e)}}function v_(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||pw))return new XMLHttpRequest}catch{}if(!e)try{return new dt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const w_=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Ew extends Ql{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,s=w_?{}:__(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,s)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const s=e[n],r=n===e.length-1;Xl(s,this.supportsBinary,i=>{try{this.doWrite(s,i)}catch{}r&&Oo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=y_()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const pa=dt.WebSocket||dt.MozWebSocket;class vw extends Ew{createSocket(e,n,s){return w_?new pa(e,n,s):n?new pa(e,n):new pa(e)}doWrite(e,n){this.ws.send(n)}}class ww extends Ql{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=nw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(n).getReader(),r=tw();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const i=()=>{s.read().then(({done:a,value:c})=>{a||(this.onPacket(c),i())}).catch(a=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const s=e[n],r=n===e.length-1;this._writer.write(s).then(()=>{r&&Oo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const bw={websocket:vw,webtransport:ww,polling:yw},Tw=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Cw=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function rc(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),s=t.indexOf("]");n!=-1&&s!=-1&&(t=t.substring(0,n)+t.substring(n,s).replace(/:/g,";")+t.substring(s,t.length));let r=Tw.exec(t||""),i={},o=14;for(;o--;)i[Cw[o]]=r[o]||"";return n!=-1&&s!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Sw(i,i.path),i.queryKey=Aw(i,i.query),i}function Sw(t,e){const n=/\/{2,9}/g,s=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function Aw(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,i){r&&(n[r]=i)}),n}const ic=typeof addEventListener=="function"&&typeof removeEventListener=="function",li=[];ic&&addEventListener("offline",()=>{li.forEach(t=>t())},!1);class hn extends Ce{constructor(e,n){if(super(),this.binaryType=rw,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const s=rc(e);n.hostname=s.host,n.secure=s.protocol==="https"||s.protocol==="wss",n.port=s.port,s.query&&(n.query=s.query)}else n.host&&(n.hostname=rc(n.host).host);Lo(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(s=>{const r=s.prototype.name;this.transports.push(r),this._transportsByName[r]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=uw(this.opts.query)),ic&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},li.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=g_,n.transport=e,this.id&&(n.sid=this.id);const s=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&hn.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",hn.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(n+=cw(r)),s>0&&n>this._maxPayload)return this.writeBuffer.slice(0,s);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Oo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,s){return this._sendPacket("message",e,n,s),this}send(e,n,s){return this._sendPacket("message",e,n,s),this}_sendPacket(e,n,s,r){if(typeof n=="function"&&(r=n,n=void 0),typeof s=="function"&&(r=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const i={type:e,data:n,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},s=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(hn.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ic&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=li.indexOf(this._offlineEventListener);s!==-1&&li.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}hn.protocol=g_;class Rw extends hn{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let n=this.createTransport(e),s=!1;hn.priorWebsocketSuccess=!1;const r=()=>{s||(n.send([{type:"ping",data:"probe"}]),n.once("packet",u=>{if(!s)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;hn.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(h(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const d=new Error("probe error");d.transport=n.name,this.emitReserved("upgradeError",d)}}))};function i(){s||(s=!0,h(),n.close(),n=null)}const o=u=>{const d=new Error("probe error: "+u);d.transport=n.name,i(),this.emitReserved("upgradeError",d)};function a(){o("transport closed")}function c(){o("socket closed")}function l(u){n&&u.name!==n.name&&i()}const h=()=>{n.removeListener("open",r),n.removeListener("error",o),n.removeListener("close",a),this.off("close",c),this.off("upgrading",l)};n.once("open",r),n.once("error",o),n.once("close",a),this.once("close",c),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&n.push(e[s]);return n}}let kw=class extends Rw{constructor(e,n={}){const s=typeof e=="object"?e:n;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(r=>bw[r]).filter(r=>!!r)),super(e,s)}};function Iw(t,e="",n){let s=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),s=rc(t)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const i=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+i+":"+s.port+e,s.href=s.protocol+"://"+i+(n&&n.port===s.port?"":":"+s.port),s}const Nw=typeof ArrayBuffer=="function",xw=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,b_=Object.prototype.toString,Ow=typeof Blob=="function"||typeof Blob<"u"&&b_.call(Blob)==="[object BlobConstructor]",Lw=typeof File=="function"||typeof File<"u"&&b_.call(File)==="[object FileConstructor]";function Zl(t){return Nw&&(t instanceof ArrayBuffer||xw(t))||Ow&&t instanceof Blob||Lw&&t instanceof File}function hi(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,s=t.length;n<s;n++)if(hi(t[n]))return!0;return!1}if(Zl(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return hi(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&hi(t[n]))return!0;return!1}function Dw(t){const e=[],n=t.data,s=t;return s.data=oc(n,e),s.attachments=e.length,{packet:s,buffers:e}}function oc(t,e){if(!t)return t;if(Zl(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let s=0;s<t.length;s++)n[s]=oc(t[s],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[s]=oc(t[s],e));return n}return t}function Pw(t,e){return t.data=ac(t.data,e),delete t.attachments,t}function ac(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=ac(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=ac(t[n],e));return t}const Fw=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Mw=5;var q;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(q||(q={}));class Bw{constructor(e){this.replacer=e}encode(e){return(e.type===q.EVENT||e.type===q.ACK)&&hi(e)?this.encodeAsBinary({type:e.type===q.EVENT?q.BINARY_EVENT:q.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===q.BINARY_EVENT||e.type===q.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=Dw(e),s=this.encodeAsString(n.packet),r=n.buffers;return r.unshift(s),r}}function Id(t){return Object.prototype.toString.call(t)==="[object Object]"}class eh extends Ce{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const s=n.type===q.BINARY_EVENT;s||n.type===q.BINARY_ACK?(n.type=s?q.EVENT:q.ACK,this.reconstructor=new Uw(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Zl(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const s={type:Number(e.charAt(0))};if(q[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===q.BINARY_EVENT||s.type===q.BINARY_ACK){const i=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const o=e.substring(i,n);if(o!=Number(o)||e.charAt(n)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(e.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););s.nsp=e.substring(i,n)}else s.nsp="/";const r=e.charAt(n+1);if(r!==""&&Number(r)==r){const i=n+1;for(;++n;){const o=e.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===e.length)break}s.id=Number(e.substring(i,n+1))}if(e.charAt(++n)){const i=this.tryParse(e.substr(n));if(eh.isPayloadValid(s.type,i))s.data=i;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case q.CONNECT:return Id(n);case q.DISCONNECT:return n===void 0;case q.CONNECT_ERROR:return typeof n=="string"||Id(n);case q.EVENT:case q.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&Fw.indexOf(n[0])===-1);case q.ACK:case q.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Uw{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=Pw(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Vw=Object.freeze(Object.defineProperty({__proto__:null,Decoder:eh,Encoder:Bw,get PacketType(){return q},protocol:Mw},Symbol.toStringTag,{value:"Module"}));function Et(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const Hw=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class T_ extends Ce{constructor(e,n,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Et(e,"open",this.onopen.bind(this)),Et(e,"packet",this.onpacket.bind(this)),Et(e,"error",this.onerror.bind(this)),Et(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var s,r,i;if(Hw.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:q.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const h=this.ids++,u=n.pop();this._registerAckCallback(h,u),o.id=h}const a=(r=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||r===void 0?void 0:r.writable,c=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!a||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,n){var s;const r=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(r===void 0){this.acks[e]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);n.call(this,new Error("operation has timed out"))},r),o=(...a)=>{this.io.clearTimeoutFn(i),n.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...n){return new Promise((s,r)=>{const i=(o,a)=>o?r(o):s(a);i.withError=!0,n.push(i),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...i)=>s!==this._queue[0]?void 0:(r!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(r)):(this._queue.shift(),n&&n(null,...i)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:q.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){const s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case q.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case q.EVENT:case q.BINARY_EVENT:this.onevent(e);break;case q.ACK:case q.BINARY_ACK:this.onack(e);break;case q.DISCONNECT:this.ondisconnect();break;case q.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const s of n)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let s=!1;return function(...r){s||(s=!0,n.packet({type:q.ACK,id:e,data:r}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:q.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let s=0;s<n.length;s++)if(e===n[s])return n.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let s=0;s<n.length;s++)if(e===n[s])return n.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const s of n)s.apply(this,e.data)}}}function Bs(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Bs.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};Bs.prototype.reset=function(){this.attempts=0};Bs.prototype.setMin=function(t){this.ms=t};Bs.prototype.setMax=function(t){this.max=t};Bs.prototype.setJitter=function(t){this.jitter=t};class cc extends Ce{constructor(e,n){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Lo(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((s=n.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new Bs({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const r=n.parser||Vw;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new kw(this.uri,this.opts);const n=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=Et(n,"open",function(){s.onopen(),e&&e()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=Et(n,"error",i);if(this._timeout!==!1){const a=this._timeout,c=this.setTimeoutFn(()=>{r(),i(new Error("timeout")),n.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Et(e,"ping",this.onping.bind(this)),Et(e,"data",this.ondata.bind(this)),Et(e,"error",this.onerror.bind(this)),Et(e,"close",this.onclose.bind(this)),Et(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){Oo(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new T_(this,e,n),this.nsps[e]=s),s}_destroy(e){const n=Object.keys(this.nsps);for(const s of n)if(this.nsps[s].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let s=0;s<n.length;s++)this.engine.write(n[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):e.onreconnect()}))},n);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const zs={};function ui(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=Iw(t,e.path||"/socket.io"),s=n.source,r=n.id,i=n.path,o=zs[r]&&i in zs[r].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let c;return a?c=new cc(s,e):(zs[r]||(zs[r]=new cc(s,e)),c=zs[r]),n.query&&!e.query&&(e.query=n.queryKey),c.socket(n.path,e)}Object.assign(ui,{Manager:cc,Socket:T_,io:ui,connect:ui});const Cn=class Cn{constructor(){w(this,"socket");w(this,"backendUrl",So("server"));w(this,"videoStream");w(this,"videoElement");w(this,"isConnected",!1);w(this,"isStreaming",!1);w(this,"jobId");w(this,"onDisconnection");w(this,"canvas");w(this,"encoderBusy",!1);w(this,"playHandler",()=>{if(!this.videoElement||!this.canvas)return;const e=this.videoElement,n=this.canvas,s=()=>{const o=e.videoWidth||640,a=e.videoHeight||480;(n.width!==o||n.height!==a)&&(n.width=o,n.height=a)},r=n.getContext("2d");if(!r)return;const i=()=>{if(this.isStreaming){if((e.videoWidth||0)===0||(e.videoHeight||0)===0){requestAnimationFrame(i);return}s(),!e.paused&&!e.ended&&(r.drawImage(e,0,0,n.width,n.height),this.encoderBusy||(this.encoderBusy=!0,this.sendFrameToBackend(n,()=>{this.encoderBusy=!1}))),requestAnimationFrame(i)}};i()});w(this,"stopStreaming",()=>{this.isStreaming=!1,this.removePlayEventListener()})}static getInstance(){return Cn.instance||(Cn.instance=new Cn),Cn.instance}async setupWebSocketConnection(){return new Promise((e,n)=>{if(this.socket)return e(!0);this.socket=ui(this.backendUrl,{transports:["websocket","polling"]}),this.socket.once("connect",()=>{this.isConnected=!0,e(!0)}),this.socket.once("connect_error",s=>{n(v.ConnectionLostError)}),this.socket.once("disconnect",s=>{this.handleSocketDisconnection(s)})})}handleSocketDisconnection(e){this.isConnected=!1}async initializeStreaming(e,n){this.videoStream=e,this.videoElement=n,this.videoElement.srcObject=e,this.canvas=document.createElement("canvas"),this.canvas.width=n.videoWidth||640,this.canvas.height=n.videoHeight||480,await this.setupWebSocketConnection()}startStreaming(e){var n;this.jobId=e,(n=this.socket)==null||n.emit("register",e),this.sendInitialRequest(e),this.isStreaming=!0,this.startVideoStream(),this.addDisconnectionListener()}async sendInitialRequest(e){await Z.post(`${this.backendUrl}/react`,{username:e,uuid:e,device_id:"1234567",face_detector:"BlazefaceFacemesh",motion_tracking:!0,skin_segmentor:"HSVandYCrCbSkinSegmentation",extreme_pixel_removal:!1,gamma_value:1,eularian_color_magnification:!1},{headers:{"Content-Type":"application/json"}})}startVideoStream(){if(!this.videoElement){T.error("Video stream not found when trying to start streaming");return}const e=this.videoElement,n=()=>{e.videoWidth>0&&e.videoHeight>0&&(this.playHandler(),e.removeEventListener("loadedmetadata",n),e.removeEventListener("playing",n))};e.addEventListener("playing",n),e.addEventListener("loadedmetadata",n),e.readyState>=2&&e.videoWidth>0&&e.videoHeight>0&&n(),e.addEventListener("play",this.playHandler),e.play().catch(s=>T.error("Error starting video stream:",s))}sendFrameToBackend(e,n){e.toBlob(s=>{if(n&&n(),!s){T.warn("[WARN] canvas.toBlob returned null (likely 0×0 canvas or tainted).");return}const r=new FileReader;r.onloadend=()=>{var i;if(this.isConnected&&this.isStreaming){const o=r.result;(i=this.socket)==null||i.emit("frame",o)}},r.readAsArrayBuffer(s)},"image/jpeg",.7)}removePlayEventListener(){this.videoElement&&this.videoElement.removeEventListener("play",this.playHandler)}setOnDisconnection(e){this.onDisconnection=e}addDisconnectionListener(){const e=zp(),n=Ks(e,`${this.jobId}/disconnect`),s=Jr(n,r=>{r.val()!=null&&(this.stopStreaming(),this.onDisconnection&&this.onDisconnection(),s())})}};w(Cn,"instance");let Gi=Cn;const Gw="__cookie_auth__";function Ww(){return typeof document<"u"&&typeof window<"u"}function Nd(t){try{const e=document.cookie.match(new RegExp(`(?:^|;\\s*)${t}=([^;]*)`));return e?decodeURIComponent(e[1]):null}catch{return null}}const $w="csrf_nervotec_client_access";function jw(){return Ww()?Nd($w)??Nd("csrf_access_token"):null}function xd(t="application/json"){const e={};t&&(e["Content-Type"]=t);const n=jw();return n&&(e["X-CSRF-TOKEN"]=n),e}class C_{constructor(){w(this,"backendUrl",So("server"));w(this,"streamingManager",Gi.getInstance());w(this,"accessTokenProvider");w(this,"onFinalResultsCallback");w(this,"onErrorCallback");w(this,"authMode","bearer")}setAuthMode(e){this.authMode=e}getAuthMode(){return this.authMode}setBaseUrl(e){typeof e=="string"&&e.trim().length>0&&(this.backendUrl=e,T.log("[DEBUG] BackendRepository baseUrl override:",this.backendUrl))}setOnErrorCallback(e){this.onErrorCallback=e}setOnFinalResultsCallback(e){this.onFinalResultsCallback=e}mapStructuredVitals(e){const n=d=>{if(!d||typeof d!="object")return;const p=d.value,f=typeof p=="number"?p:parseFloat(String(p));return Number.isFinite(f)?f:void 0},s={},r=n(e.heart_rate);r!==void 0&&(s.HR=r);const i=n(e.hrv);i!==void 0&&(s.RMSSD=i,s.SDNN=i);const o=n(e.spo2);o!==void 0&&(s.SPO2=o);const a=n(e.respiratory_rate);a!==void 0&&(s.RR=a);const c=e.blood_pressure;if(c&&typeof c=="object"){const d=n(c.systolic),p=n(c.diastolic);d!==void 0&&(s.SBP=d),p!==void 0&&(s.DBP=p)}const l=n(e.stress_score);l!==void 0&&(s.STRESS_LEVEL=l);const h=n(e.hba1c);h!==void 0&&(s.GLUCOSE=h);const u=n(e.hemoglobin);return u!==void 0&&(s.HEMOGLOBIN=u),s}setAccessTokenProvider(e){this.accessTokenProvider=e}}class qw extends C_{constructor(n){super();w(this,"streamingManager",Gi.getInstance());w(this,"rgbManager",Ui.getInstance());this.backendUrl=So("server"),this.setBaseUrl(n),T.log("ServerRepository",this.backendUrl)}async getTokenWithUsernameAndPassword(n,s){try{return(await Z.post(this.backendUrl.concat("/clientlogin"),{username:n,password:s})).data.access_token}catch(r){W.handleErrorResponse(r)}}async getTokenWithLicenseKey(n){var s,r;try{const i=this.backendUrl.concat("/clientloginwithlicensekey");if(this.authMode==="cookie"){const c=await Z.post(i,{license_key:n},{withCredentials:!0,headers:xd()});((s=c.data)==null?void 0:s.success)===!1&&W.handleErrorResponse({response:c});const l=(r=c.data)==null?void 0:r.access_token;return l&&String(l).length>0?String(l):Gw}return(await Z.post(i,{license_key:n})).data.access_token}catch(i){W.handleErrorResponse(i)}}async getAPIKey(n){n||W.throwKnownError(v.InvalidAccessTokenError);try{return(await Z.post(this.backendUrl.concat("/clientgeturl"),{host_name:"www.nervoscan.com"},{headers:{Authorization:`Bearer ${n}`}})).data.url.split("?api_key=")[1]}catch(s){W.handleErrorResponse(s)}}async uploadVideoToServer(n,s,r){(!s||!r)&&W.throwKnownError(v.InvalidAccessTokenError);const i=new FormData;i.append("file",n,"recording.webm"),i.append("data",JSON.stringify({uuid:r,meta_data:{}}));const a=await(await fetch(this.backendUrl.concat("/submitscan"),{method:"POST",headers:{Authorization:`Bearer ${s}`},body:i})).json();return a.success===!1&&W.handleErrorResponse(a),a}async sendRgbDataToBackend(n,s,r,i){try{const o=this.authMode==="cookie";let a;o?this.accessTokenProvider&&await this.accessTokenProvider():(a=this.accessTokenProvider?await this.accessTokenProvider():void 0,a||W.throwKnownError(v.InvalidAccessTokenError));const c={job_id:i,timestamp:Date.now(),rgbData:n,resolution:{width:s,height:r}};T.log(`[Backend] Sending RGB data to backend with resolution: ${s}x${r}`),T.debug("Sending RGB data to backend:",c);const l=o?xd():{"Content-Type":"application/json",Authorization:`Bearer ${a}`},h=await Z.post(`${this.backendUrl}/rgb-data`,c,{headers:l,withCredentials:o}),u=h.data;if(T.debug("[Backend] RGB response",{status:h.status,keys:u&&typeof u=="object"?Object.keys(u):[]}),u&&typeof u=="object"){const d=u.processedData;if(d){const p=d.averaged_results,f=d.vitals;if(this.onFinalResultsCallback&&(p||f)){const g={...p&&typeof p=="object"?p:{},...f&&typeof f=="object"?{vitals:f}:{},...f&&typeof f=="object"?this.mapStructuredVitals(f):{}};this.onFinalResultsCallback(g)}else this.onFinalResultsCallback||T.debug("[Backend] No onFinalResults callback set")}}return h.data}catch(o){T.debug("[Backend] sendRgbDataToBackend error:",o),W.handleBackendError(o,this.onErrorCallback)}}}class zw extends C_{constructor(e){super(),this.backendUrl=So("serverless"),this.setBaseUrl(e)}async getTokenWithUsernameAndPassword(e,n){try{const s=await Z.post(this.backendUrl.concat("/user/login"),{username:e,password:n});if(s.data.success===!1)W.throwKnownError(v.InvalidUsernameError);else return JSON.parse(s.data.body).idToken}catch(s){T.error("error printed in serverless repository",s),W.handleErrorResponse(s)}}async getTokenWithLicenseKey(e){W.throwKnownError(v.NotImplementedError)}async getAPIKey(e){e||W.throwKnownError(v.InvalidAccessTokenError);try{return(await Z.post(this.backendUrl.concat("/get-redirection-url"),{host_name:"www.nervoscan.com"},{headers:{Authorization:`Bearer ${e}`}})).data.url.split("?api_key=")[1]}catch(n){W.handleErrorResponse(n)}}async uploadVideoToServer(e,n,s){(!n||!s)&&W.throwKnownError(v.InvalidAccessTokenError);try{const r=await this.generatePreSignedUrl(s);return r||W.throwKnownError(v.InvalidAccessTokenError),await this.uploadVideoToS3(e,r)}catch(r){throw T.error("Error uploading video:",r),r.response?(T.error("Error response:",r.response.data),T.error("Error status:",r.response.status),T.error("Error headers:",r.response.headers)):r.request?T.error("Error request:",r.request):T.error("Error message:",r.message),r}}async generatePreSignedUrl(e){try{return(await Z.get(this.backendUrl.concat("/generate-presigned-url?job_id="+e))).data.upload_url}catch(n){W.handleErrorResponse(n)}}async uploadVideoToS3(e,n){try{return(await Z.put(n,e,{headers:{"Content-Type":"video/mp4"}})).data}catch(s){W.handleErrorResponse(s)}}async sendRgbDataToBackend(e,n,s,r){W.throwKnownError(v.NotImplementedError)}}class S_{static createBackendRepository(e,n,s,r="bearer"){let i;return e==="server"?i=new qw(s):e==="serverless"?i=new zw(s):W.throwKnownError(v.InvalidServerTypeError),i.setAuthMode(r),i}}class Kw{constructor(e,n,s,r="server",i,o="bearer"){w(this,"backendRepository");w(this,"username");w(this,"password");w(this,"licenseKey");w(this,"baseUrl");this.backendRepository=S_.createBackendRepository(r,!1,i,o),this.username=e,this.password=n,this.licenseKey=s,this.baseUrl=i,e&&n&&T.warn("Using username and password for authentication is deprecated. Please use license key instead.")}async validate(){if(this.licenseKey)return this.validateWithKey(this.licenseKey);if(this.username&&this.password)return this.validatewithUsernameAndPassword(this.username,this.password);W.throwKnownError(v.InvalidCredentialsError)}async validateWithKey(e){return this.backendRepository.getTokenWithLicenseKey(e)}async validatewithUsernameAndPassword(e,n){return this.backendRepository.getTokenWithUsernameAndPassword(e,n)}}const Sn=class Sn{constructor(){w(this,"initialized",!1);w(this,"accessToken");w(this,"backendRepository");w(this,"onWindowResults");w(this,"onFinalResults");w(this,"onError");w(this,"useRgb",!1);w(this,"rgbManager",Ui.getInstance());w(this,"onDisconnection",()=>{});w(this,"licenceManager");w(this,"firebaseApp");w(this,"listener");const e={apiKey:"AIzaSyAid2Ds7N0uusVOKbhMQjRY7qoGGM9ABe0",authDomain:"nervowebreact.firebaseapp.com",databaseURL:"https://nervowebreact-default-rtdb.asia-southeast1.firebasedatabase.app",projectId:"nervowebreact",storageBucket:"nervowebreact.firebasestorage.app",messagingSenderId:"1025695568936",appId:"1:1025695568936:web:fe7f415cf383fd2eda511d"},n="nervoscan-sdk";t2().some(s=>s.name===n)?this.firebaseApp=Rf(n):this.firebaseApp=Af(e,n)}static getInstance(){return Sn.instance||(Sn.instance=new Sn),Sn.instance}addfirebaseListeners(e){var n;(n=this.listener)==null||n.detachAll(),this.listener=new w3(this.firebaseApp,{onWindow:s=>{var r;return(r=this.onWindowResults)==null?void 0:r.call(this,s)},onFinal:s=>{var r;T.log(`[Client] Received results for job ${e}:`,s),this.useRgb&&this.rgbManager.isContinuousModeEnabled()?this.rgbManager.handleBatchResults(s):(r=this.onFinalResults)==null||r.call(this,s)},onError:s=>{const r=W.handleScanError(s);this.onError?this.onError(r):W.throwKnownError(v.ErrorCallbackNotSetError)}}),this.listener.attach(e)}initialize({username:e,password:n,licenseKey:s,serverType:r="server",useRgb:i=!1,baseUrl:o,authMode:a="bearer"}){this.initialized=!0,this.useRgb=i,this.licenceManager=new Kw(e,n,s,r,o,a),this.backendRepository=S_.createBackendRepository(r,i,o,a),this.backendRepository.setAccessTokenProvider(async()=>this.licenceManager.validate()),this.backendRepository.setOnFinalResultsCallback(c=>{T.debug("[Client] Received final results via direct backend callback"),this.onFinalResults&&this.onFinalResults(c)}),this.backendRepository.setOnErrorCallback(c=>{T.debug("[Client] Received error via direct backend callback"),this.onError&&this.onError(c)})}async uploadVideo(e){var n,s;this.initialized||W.throwKnownError(v.NotInitializedError),e instanceof Blob||W.throwKnownError(v.VideoTypeError),(e===null||e.size===0)&&W.throwKnownError(v.EmptyVideoError),performance.now();try{const r=await this.licenceManager.validate(),i=await((n=this.backendRepository)==null?void 0:n.getAPIKey(r)),o=(s=this.backendRepository)==null?void 0:s.uploadVideoToServer(e,r,i);return i&&this.addfirebaseListeners(i),i}catch(r){throw r}}setOnFinalResults(e){this.onFinalResults=e}setOnWindowResults(e){this.onWindowResults=e}setOnError(e){this.onError=e}setOnDisconnection(e){var n;(n=this.backendRepository)==null||n.streamingManager.setOnDisconnection(e),this.onDisconnection=e}setOnAlignmentStatus(e){this.rgbManager.setAlignmentStatusCallback(e)}startFaceDetection(){this.useRgb&&this.rgbManager.startFaceDetection()}stopFaceDetection(){this.useRgb&&this.rgbManager.stopFaceDetection()}async initializeStreaming(e,n,s={}){var r;this.useRgb?await this.rgbManager.initialize(e,n,this.backendRepository,this.onDisconnection,s):await((r=this.backendRepository)==null?void 0:r.streamingManager.initializeStreaming(e,n))}async startStreaming(){var e;this.initialized||W.throwKnownError(v.NotInitializedError),performance.now();try{if(this.backendRepository.getAuthMode()==="cookie")try{await this.licenceManager.validate()}catch{W.throwKnownError(v.InvalidAccessTokenError)}else await this.licenceManager.validate()||W.throwKnownError(v.InvalidCredentialsError);const s=crypto.randomUUID();return this.useRgb?(T.log("Starting RGB streaming"),await this.rgbManager.startStreaming(s)):((e=this.backendRepository)==null||e.streamingManager.startStreaming(s),this.addfirebaseListeners(s)),s}catch(n){throw n}}async stopStreaming(e=!1){var n;if((n=this.backendRepository)==null||n.streamingManager.stopStreaming(),this.rgbManager.stopStreaming(),!e)try{await this.validateScanCompletion()}catch(s){throw s}}async validateScanCompletion(){if(this.initialized||W.throwKnownError(v.NotInitializedError),!this.useRgb)return;const e=this.getRGBDataCollectionStatus();if(e.error&&e.error==="RGB mode not enabled")return;const n=300,s=13.5,r=(e==null?void 0:e.bufferSize)||0,i=this.getRGBTimestamps();let o=null;if(i.length>=2){const a=i[i.length-1]-i[0];a>0&&(o=(i.length-1)/a)}if(o!==null&&o<s){const a=`Camera frame rate is too low (${o.toFixed(1)} FPS). Please try again with better lighting and ensure your device is not under heavy load.`;throw new K.LowFPSError(a)}r<n&&W.throwKnownError(v.InsufficientDataError),o===null&&W.throwKnownError(v.FPSCalculationError)}getRGBDataCollectionStatus(){return this.useRgb&&this.rgbManager?this.rgbManager.getDataCollectionStatus():{error:"RGB mode not enabled"}}getRGBTimestamps(){return this.useRgb&&this.rgbManager?this.rgbManager.getRGBTimestamps():[]}};w(Sn,"instance");let lc=Sn;exports.Client=lc;exports.ConnectionLostError=sf;exports.EmptyVideoError=Dd;exports.EnvIncompatibleError=uf;exports.ErrorCallbackNotSetError=Xd;exports.Errors=K;exports.FPSCalculationError=$d;exports.FaceLandmarkerNotInitializedError=hf;exports.FaceLookingLeftError=Kd;exports.FaceLookingRightError=Yd;exports.FaceNotCenteredError=jd;exports.FaceTooCloseError=zd;exports.FaceTooFarError=qd;exports.InsufficientDataError=df;exports.InvalidAccessTokenError=Ud;exports.InvalidContentTypeError=Zd;exports.InvalidCredentialsError=af;exports.InvalidPasswordError=Md;exports.InvalidServerTypeError=Hd;exports.InvalidUsernameError=Fd;exports.JobNotRegisteredError=ef;exports.LicenseInactiveError=cf;exports.LowFPSError=Wd;exports.LowFrameCountError=nf;exports.NervoscanError=j;exports.NoScanDataError=Vd;exports.NoScansAvailableError=Bd;exports.NotImplementedError=Gd;exports.NotInitializedError=Ld;exports.REGION_NAMES=Vg;exports.RGBError=lf;exports.ScanFailedError=rf;exports.SkinExtractionError=Qd;exports.UnhandledError=tf;exports.UnhandledScanError=Jd;exports.VideoError=of;exports.VideoTypeError=Pd;exports.scoreToConfidenceLevel=c4;
1643
+ `):" "+bd(i[0]):"as no adapter specified";throw new M("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return s},adapters:tc};function ua(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ms(null,t)}function Td(t){return ua(t),t.headers=ze.from(t.headers),t.data=ha.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),a_.getAdapter(t.adapter||Mr.adapter)(t).then(function(s){return ua(t),s.data=ha.call(t,t.transformResponse,s),s.headers=ze.from(s.headers),s},function(s){return t_(s)||(ua(t),s&&s.response&&(s.response.data=ha.call(t,t.transformResponse,s.response),s.response.headers=ze.from(s.response.headers))),Promise.reject(s)})}const c_="1.8.4",xo={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{xo[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}});const Cd={};xo.transitional=function(e,n,s){function r(i,o){return"[Axios v"+c_+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return(i,o,a)=>{if(e===!1)throw new M(r(o," has been removed"+(n?" in "+n:"")),M.ERR_DEPRECATED);return n&&!Cd[o]&&(Cd[o]=!0,console.warn(r(o," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(i,o,a):!0}};xo.spelling=function(e){return(n,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function $v(t,e,n){if(typeof t!="object")throw new M("options must be an object",M.ERR_BAD_OPTION_VALUE);const s=Object.keys(t);let r=s.length;for(;r-- >0;){const i=s[r],o=e[i];if(o){const a=t[i],c=a===void 0||o(a,i,t);if(c!==!0)throw new M("option "+i+" must be "+c,M.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new M("Unknown option "+i,M.ERR_BAD_OPTION)}}const oi={assertOptions:$v,validators:xo},Dt=oi.validators;let xn=class{constructor(e){this.defaults=e,this.interceptors={request:new md,response:new md}}async request(e,n){try{return await this._request(e,n)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{s.stack?i&&!String(s.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(s.stack+=`
1644
+ `+i):s.stack=i}catch{}}throw s}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=Bn(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:i}=n;s!==void 0&&oi.assertOptions(s,{silentJSONParsing:Dt.transitional(Dt.boolean),forcedJSONParsing:Dt.transitional(Dt.boolean),clarifyTimeoutError:Dt.transitional(Dt.boolean)},!1),r!=null&&(m.isFunction(r)?n.paramsSerializer={serialize:r}:oi.assertOptions(r,{encode:Dt.function,serialize:Dt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),oi.assertOptions(n,{baseUrl:Dt.spelling("baseURL"),withXsrfToken:Dt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&m.merge(i.common,i[n.method]);i&&m.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),n.headers=ze.concat(o,i);const a=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(c=c&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const l=[];this.interceptors.response.forEach(function(g){l.push(g.fulfilled,g.rejected)});let h,u=0,d;if(!c){const f=[Td.bind(this),void 0];for(f.unshift.apply(f,a),f.push.apply(f,l),d=f.length,h=Promise.resolve(n);u<d;)h=h.then(f[u++],f[u++]);return h}d=a.length;let p=n;for(u=0;u<d;){const f=a[u++],g=a[u++];try{p=f(p)}catch(E){g.call(this,E);break}}try{h=Td.call(this,p)}catch(f){return Promise.reject(f)}for(u=0,d=l.length;u<d;)h=h.then(l[u++],l[u++]);return h}getUri(e){e=Bn(this.defaults,e);const n=s_(e.baseURL,e.url,e.allowAbsoluteUrls);return Qg(n,e.params,e.paramsSerializer)}};m.forEach(["delete","get","head","options"],function(e){xn.prototype[e]=function(n,s){return this.request(Bn(s||{},{method:e,url:n,data:(s||{}).data}))}});m.forEach(["post","put","patch"],function(e){function n(s){return function(i,o,a){return this.request(Bn(a||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}xn.prototype[e]=n(),xn.prototype[e+"Form"]=n(!0)});let jv=class l_{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const s=this;this.promise.then(r=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](r);s._listeners=null}),this.promise.then=r=>{let i;const o=new Promise(a=>{s.subscribe(a),i=a}).then(r);return o.cancel=function(){s.unsubscribe(i)},o},e(function(i,o,a){s.reason||(s.reason=new Ms(i,o,a),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=s=>{e.abort(s)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new l_(function(r){e=r}),cancel:e}}};function qv(t){return function(n){return t.apply(null,n)}}function zv(t){return m.isObject(t)&&t.isAxiosError===!0}const nc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(nc).forEach(([t,e])=>{nc[e]=t});function h_(t){const e=new xn(t),n=Hg(xn.prototype.request,e);return m.extend(n,xn.prototype,e,{allOwnKeys:!0}),m.extend(n,e,null,{allOwnKeys:!0}),n.create=function(r){return h_(Bn(t,r))},n}const Z=h_(Mr);Z.Axios=xn;Z.CanceledError=Ms;Z.CancelToken=jv;Z.isCancel=t_;Z.VERSION=c_;Z.toFormData=Io;Z.AxiosError=M;Z.Cancel=Z.CanceledError;Z.all=function(e){return Promise.all(e)};Z.spread=qv;Z.isAxiosError=zv;Z.mergeConfig=Bn;Z.AxiosHeaders=ze;Z.formToJSON=t=>e_(m.isHTMLForm(t)?new FormData(t):t);Z.getAdapter=a_.getAdapter;Z.HttpStatusCode=nc;Z.default=Z;const{Axios:Jw,AxiosError:Qw,CanceledError:Zw,isCancel:eb,CancelToken:tb,VERSION:nb,all:sb,Cancel:rb,isAxiosError:ib,spread:ob,toFormData:ab,AxiosHeaders:cb,HttpStatusCode:lb,formToJSON:hb,getAdapter:ub,mergeConfig:db}=Z,Mt=Object.create(null);Mt.open="0";Mt.close="1";Mt.ping="2";Mt.pong="3";Mt.message="4";Mt.upgrade="5";Mt.noop="6";const ai=Object.create(null);Object.keys(Mt).forEach(t=>{ai[Mt[t]]=t});const sc={type:"error",data:"parser error"},u_=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",d_=typeof ArrayBuffer=="function",f_=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,Xl=({type:t,data:e},n,s)=>u_&&e instanceof Blob?n?s(e):Sd(e,s):d_&&(e instanceof ArrayBuffer||f_(e))?n?s(e):Sd(new Blob([e]),s):s(Mt[t]+(e||"")),Sd=(t,e)=>{const n=new FileReader;return n.onload=function(){const s=n.result.split(",")[1];e("b"+(s||""))},n.readAsDataURL(t)};function Ad(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let da;function Kv(t,e){if(u_&&t.data instanceof Blob)return t.data.arrayBuffer().then(Ad).then(e);if(d_&&(t.data instanceof ArrayBuffer||f_(t.data)))return e(Ad(t.data));Xl(t,!1,n=>{da||(da=new TextEncoder),e(da.encode(n))})}const Rd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Js=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Rd.length;t++)Js[Rd.charCodeAt(t)]=t;const Yv=t=>{let e=t.length*.75,n=t.length,s,r=0,i,o,a,c;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const l=new ArrayBuffer(e),h=new Uint8Array(l);for(s=0;s<n;s+=4)i=Js[t.charCodeAt(s)],o=Js[t.charCodeAt(s+1)],a=Js[t.charCodeAt(s+2)],c=Js[t.charCodeAt(s+3)],h[r++]=i<<2|o>>4,h[r++]=(o&15)<<4|a>>2,h[r++]=(a&3)<<6|c&63;return l},Xv=typeof ArrayBuffer=="function",Jl=(t,e)=>{if(typeof t!="string")return{type:"message",data:p_(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:Jv(t.substring(1),e)}:ai[n]?t.length>1?{type:ai[n],data:t.substring(1)}:{type:ai[n]}:sc},Jv=(t,e)=>{if(Xv){const n=Yv(t);return p_(n,e)}else return{base64:!0,data:t}},p_=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},m_="",Qv=(t,e)=>{const n=t.length,s=new Array(n);let r=0;t.forEach((i,o)=>{Xl(i,!1,a=>{s[o]=a,++r===n&&e(s.join(m_))})})},Zv=(t,e)=>{const n=t.split(m_),s=[];for(let r=0;r<n.length;r++){const i=Jl(n[r],e);if(s.push(i),i.type==="error")break}return s};function ew(){return new TransformStream({transform(t,e){Kv(t,n=>{const s=n.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,s)}else{r=new Uint8Array(9);const i=new DataView(r.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(s))}t.data&&typeof t.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(n)})}})}let fa;function Kr(t){return t.reduce((e,n)=>e+n.length,0)}function Yr(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let s=0;for(let r=0;r<e;r++)n[r]=t[0][s++],s===t[0].length&&(t.shift(),s=0);return t.length&&s<t[0].length&&(t[0]=t[0].slice(s)),n}function tw(t,e){fa||(fa=new TextDecoder);const n=[];let s=0,r=-1,i=!1;return new TransformStream({transform(o,a){for(n.push(o);;){if(s===0){if(Kr(n)<1)break;const c=Yr(n,1);i=(c[0]&128)===128,r=c[0]&127,r<126?s=3:r===126?s=1:s=2}else if(s===1){if(Kr(n)<2)break;const c=Yr(n,2);r=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),s=3}else if(s===2){if(Kr(n)<8)break;const c=Yr(n,8),l=new DataView(c.buffer,c.byteOffset,c.length),h=l.getUint32(0);if(h>Math.pow(2,21)-1){a.enqueue(sc);break}r=h*Math.pow(2,32)+l.getUint32(4),s=3}else{if(Kr(n)<r)break;const c=Yr(n,r);a.enqueue(Jl(i?c:fa.decode(c),e)),s=0}if(r===0||r>t){a.enqueue(sc);break}}}})}const g_=4;function Ce(t){if(t)return nw(t)}function nw(t){for(var e in Ce.prototype)t[e]=Ce.prototype[e];return t}Ce.prototype.on=Ce.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};Ce.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};Ce.prototype.off=Ce.prototype.removeListener=Ce.prototype.removeAllListeners=Ce.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var s,r=0;r<n.length;r++)if(s=n[r],s===e||s.fn===e){n.splice(r,1);break}return n.length===0&&delete this._callbacks["$"+t],this};Ce.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(n){n=n.slice(0);for(var s=0,r=n.length;s<r;++s)n[s].apply(this,e)}return this};Ce.prototype.emitReserved=Ce.prototype.emit;Ce.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};Ce.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Oo=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),dt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),sw="arraybuffer";function __(t,...e){return e.reduce((n,s)=>(t.hasOwnProperty(s)&&(n[s]=t[s]),n),{})}const rw=dt.setTimeout,iw=dt.clearTimeout;function Lo(t,e){e.useNativeTimers?(t.setTimeoutFn=rw.bind(dt),t.clearTimeoutFn=iw.bind(dt)):(t.setTimeoutFn=dt.setTimeout.bind(dt),t.clearTimeoutFn=dt.clearTimeout.bind(dt))}const ow=1.33;function aw(t){return typeof t=="string"?cw(t):Math.ceil((t.byteLength||t.size)*ow)}function cw(t){let e=0,n=0;for(let s=0,r=t.length;s<r;s++)e=t.charCodeAt(s),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(s++,n+=4);return n}function y_(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function lw(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function hw(t){let e={},n=t.split("&");for(let s=0,r=n.length;s<r;s++){let i=n[s].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}class uw extends Error{constructor(e,n,s){super(e),this.description=n,this.context=s,this.type="TransportError"}}class Ql extends Ce{constructor(e){super(),this.writable=!1,Lo(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,s){return super.emitReserved("error",new uw(e,n,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=Jl(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=lw(e);return n.length?"?"+n:""}}class dw extends Ql{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||n()})),this.writable||(s++,this.once("drain",function(){--s||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};Zv(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Qv(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=y_()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let E_=!1;try{E_=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const fw=E_;function pw(){}class mw extends dw{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let s=location.port;s||(s=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,n){const s=this.request({method:"POST",data:e});s.on("success",n),s.on("error",(r,i)=>{this.onError("xhr post error",r,i)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,s)=>{this.onError("xhr poll error",n,s)}),this.pollXhr=e}}let cs=class ci extends Ce{constructor(e,n,s){super(),this.createRequest=e,Lo(this,s),this._opts=s,this._method=s.method||"GET",this._uri=n,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var e;const n=__(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(n);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&s.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var r;s.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=ci.requestsCount++,ci.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=pw,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete ci.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};cs.requestsCount=0;cs.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",kd);else if(typeof addEventListener=="function"){const t="onpagehide"in dt?"pagehide":"unload";addEventListener(t,kd,!1)}}function kd(){for(let t in cs.requests)cs.requests.hasOwnProperty(t)&&cs.requests[t].abort()}const gw=function(){const t=v_({xdomain:!1});return t&&t.responseType!==null}();class _w extends mw{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=gw&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new cs(v_,this.uri(),e)}}function v_(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||fw))return new XMLHttpRequest}catch{}if(!e)try{return new dt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const w_=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class yw extends Ql{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,s=w_?{}:__(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,s)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const s=e[n],r=n===e.length-1;Xl(s,this.supportsBinary,i=>{try{this.doWrite(s,i)}catch{}r&&Oo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=y_()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const pa=dt.WebSocket||dt.MozWebSocket;class Ew extends yw{createSocket(e,n,s){return w_?new pa(e,n,s):n?new pa(e,n):new pa(e)}doWrite(e,n){this.ws.send(n)}}class vw extends Ql{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=tw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(n).getReader(),r=ew();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const i=()=>{s.read().then(({done:a,value:c})=>{a||(this.onPacket(c),i())}).catch(a=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const s=e[n],r=n===e.length-1;this._writer.write(s).then(()=>{r&&Oo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const ww={websocket:Ew,webtransport:vw,polling:_w},bw=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Tw=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function rc(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),s=t.indexOf("]");n!=-1&&s!=-1&&(t=t.substring(0,n)+t.substring(n,s).replace(/:/g,";")+t.substring(s,t.length));let r=bw.exec(t||""),i={},o=14;for(;o--;)i[Tw[o]]=r[o]||"";return n!=-1&&s!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Cw(i,i.path),i.queryKey=Sw(i,i.query),i}function Cw(t,e){const n=/\/{2,9}/g,s=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function Sw(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,i){r&&(n[r]=i)}),n}const ic=typeof addEventListener=="function"&&typeof removeEventListener=="function",li=[];ic&&addEventListener("offline",()=>{li.forEach(t=>t())},!1);class hn extends Ce{constructor(e,n){if(super(),this.binaryType=sw,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const s=rc(e);n.hostname=s.host,n.secure=s.protocol==="https"||s.protocol==="wss",n.port=s.port,s.query&&(n.query=s.query)}else n.host&&(n.hostname=rc(n.host).host);Lo(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(s=>{const r=s.prototype.name;this.transports.push(r),this._transportsByName[r]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=hw(this.opts.query)),ic&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},li.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=g_,n.transport=e,this.id&&(n.sid=this.id);const s=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&hn.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",hn.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(n+=aw(r)),s>0&&n>this._maxPayload)return this.writeBuffer.slice(0,s);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Oo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,s){return this._sendPacket("message",e,n,s),this}send(e,n,s){return this._sendPacket("message",e,n,s),this}_sendPacket(e,n,s,r){if(typeof n=="function"&&(r=n,n=void 0),typeof s=="function"&&(r=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const i={type:e,data:n,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},s=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(hn.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ic&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=li.indexOf(this._offlineEventListener);s!==-1&&li.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}hn.protocol=g_;class Aw extends hn{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let n=this.createTransport(e),s=!1;hn.priorWebsocketSuccess=!1;const r=()=>{s||(n.send([{type:"ping",data:"probe"}]),n.once("packet",u=>{if(!s)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;hn.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(h(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const d=new Error("probe error");d.transport=n.name,this.emitReserved("upgradeError",d)}}))};function i(){s||(s=!0,h(),n.close(),n=null)}const o=u=>{const d=new Error("probe error: "+u);d.transport=n.name,i(),this.emitReserved("upgradeError",d)};function a(){o("transport closed")}function c(){o("socket closed")}function l(u){n&&u.name!==n.name&&i()}const h=()=>{n.removeListener("open",r),n.removeListener("error",o),n.removeListener("close",a),this.off("close",c),this.off("upgrading",l)};n.once("open",r),n.once("error",o),n.once("close",a),this.once("close",c),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&n.push(e[s]);return n}}let Rw=class extends Aw{constructor(e,n={}){const s=typeof e=="object"?e:n;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(r=>ww[r]).filter(r=>!!r)),super(e,s)}};function kw(t,e="",n){let s=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),s=rc(t)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const i=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+i+":"+s.port+e,s.href=s.protocol+"://"+i+(n&&n.port===s.port?"":":"+s.port),s}const Iw=typeof ArrayBuffer=="function",Nw=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,b_=Object.prototype.toString,xw=typeof Blob=="function"||typeof Blob<"u"&&b_.call(Blob)==="[object BlobConstructor]",Ow=typeof File=="function"||typeof File<"u"&&b_.call(File)==="[object FileConstructor]";function Zl(t){return Iw&&(t instanceof ArrayBuffer||Nw(t))||xw&&t instanceof Blob||Ow&&t instanceof File}function hi(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,s=t.length;n<s;n++)if(hi(t[n]))return!0;return!1}if(Zl(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return hi(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&hi(t[n]))return!0;return!1}function Lw(t){const e=[],n=t.data,s=t;return s.data=oc(n,e),s.attachments=e.length,{packet:s,buffers:e}}function oc(t,e){if(!t)return t;if(Zl(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let s=0;s<t.length;s++)n[s]=oc(t[s],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[s]=oc(t[s],e));return n}return t}function Dw(t,e){return t.data=ac(t.data,e),delete t.attachments,t}function ac(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=ac(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=ac(t[n],e));return t}const Pw=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Fw=5;var q;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(q||(q={}));class Mw{constructor(e){this.replacer=e}encode(e){return(e.type===q.EVENT||e.type===q.ACK)&&hi(e)?this.encodeAsBinary({type:e.type===q.EVENT?q.BINARY_EVENT:q.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===q.BINARY_EVENT||e.type===q.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=Lw(e),s=this.encodeAsString(n.packet),r=n.buffers;return r.unshift(s),r}}function Id(t){return Object.prototype.toString.call(t)==="[object Object]"}class eh extends Ce{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const s=n.type===q.BINARY_EVENT;s||n.type===q.BINARY_ACK?(n.type=s?q.EVENT:q.ACK,this.reconstructor=new Bw(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Zl(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const s={type:Number(e.charAt(0))};if(q[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===q.BINARY_EVENT||s.type===q.BINARY_ACK){const i=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const o=e.substring(i,n);if(o!=Number(o)||e.charAt(n)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(e.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););s.nsp=e.substring(i,n)}else s.nsp="/";const r=e.charAt(n+1);if(r!==""&&Number(r)==r){const i=n+1;for(;++n;){const o=e.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===e.length)break}s.id=Number(e.substring(i,n+1))}if(e.charAt(++n)){const i=this.tryParse(e.substr(n));if(eh.isPayloadValid(s.type,i))s.data=i;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case q.CONNECT:return Id(n);case q.DISCONNECT:return n===void 0;case q.CONNECT_ERROR:return typeof n=="string"||Id(n);case q.EVENT:case q.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&Pw.indexOf(n[0])===-1);case q.ACK:case q.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Bw{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=Dw(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Uw=Object.freeze(Object.defineProperty({__proto__:null,Decoder:eh,Encoder:Mw,get PacketType(){return q},protocol:Fw},Symbol.toStringTag,{value:"Module"}));function Et(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const Vw=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class T_ extends Ce{constructor(e,n,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Et(e,"open",this.onopen.bind(this)),Et(e,"packet",this.onpacket.bind(this)),Et(e,"error",this.onerror.bind(this)),Et(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var s,r,i;if(Vw.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:q.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const h=this.ids++,u=n.pop();this._registerAckCallback(h,u),o.id=h}const a=(r=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||r===void 0?void 0:r.writable,c=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!a||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,n){var s;const r=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(r===void 0){this.acks[e]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);n.call(this,new Error("operation has timed out"))},r),o=(...a)=>{this.io.clearTimeoutFn(i),n.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...n){return new Promise((s,r)=>{const i=(o,a)=>o?r(o):s(a);i.withError=!0,n.push(i),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...i)=>s!==this._queue[0]?void 0:(r!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(r)):(this._queue.shift(),n&&n(null,...i)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:q.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){const s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case q.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case q.EVENT:case q.BINARY_EVENT:this.onevent(e);break;case q.ACK:case q.BINARY_ACK:this.onack(e);break;case q.DISCONNECT:this.ondisconnect();break;case q.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const s of n)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let s=!1;return function(...r){s||(s=!0,n.packet({type:q.ACK,id:e,data:r}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:q.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let s=0;s<n.length;s++)if(e===n[s])return n.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let s=0;s<n.length;s++)if(e===n[s])return n.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const s of n)s.apply(this,e.data)}}}function Bs(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Bs.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};Bs.prototype.reset=function(){this.attempts=0};Bs.prototype.setMin=function(t){this.ms=t};Bs.prototype.setMax=function(t){this.max=t};Bs.prototype.setJitter=function(t){this.jitter=t};class cc extends Ce{constructor(e,n){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Lo(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((s=n.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new Bs({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const r=n.parser||Uw;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Rw(this.uri,this.opts);const n=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=Et(n,"open",function(){s.onopen(),e&&e()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=Et(n,"error",i);if(this._timeout!==!1){const a=this._timeout,c=this.setTimeoutFn(()=>{r(),i(new Error("timeout")),n.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Et(e,"ping",this.onping.bind(this)),Et(e,"data",this.ondata.bind(this)),Et(e,"error",this.onerror.bind(this)),Et(e,"close",this.onclose.bind(this)),Et(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){Oo(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new T_(this,e,n),this.nsps[e]=s),s}_destroy(e){const n=Object.keys(this.nsps);for(const s of n)if(this.nsps[s].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let s=0;s<n.length;s++)this.engine.write(n[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):e.onreconnect()}))},n);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const zs={};function ui(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=kw(t,e.path||"/socket.io"),s=n.source,r=n.id,i=n.path,o=zs[r]&&i in zs[r].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let c;return a?c=new cc(s,e):(zs[r]||(zs[r]=new cc(s,e)),c=zs[r]),n.query&&!e.query&&(e.query=n.queryKey),c.socket(n.path,e)}Object.assign(ui,{Manager:cc,Socket:T_,io:ui,connect:ui});const Cn=class Cn{constructor(){w(this,"socket");w(this,"backendUrl",So("server"));w(this,"videoStream");w(this,"videoElement");w(this,"isConnected",!1);w(this,"isStreaming",!1);w(this,"jobId");w(this,"onDisconnection");w(this,"canvas");w(this,"encoderBusy",!1);w(this,"playHandler",()=>{if(!this.videoElement||!this.canvas)return;const e=this.videoElement,n=this.canvas,s=()=>{const o=e.videoWidth||640,a=e.videoHeight||480;(n.width!==o||n.height!==a)&&(n.width=o,n.height=a)},r=n.getContext("2d");if(!r)return;const i=()=>{if(this.isStreaming){if((e.videoWidth||0)===0||(e.videoHeight||0)===0){requestAnimationFrame(i);return}s(),!e.paused&&!e.ended&&(r.drawImage(e,0,0,n.width,n.height),this.encoderBusy||(this.encoderBusy=!0,this.sendFrameToBackend(n,()=>{this.encoderBusy=!1}))),requestAnimationFrame(i)}};i()});w(this,"stopStreaming",()=>{this.isStreaming=!1,this.removePlayEventListener()})}static getInstance(){return Cn.instance||(Cn.instance=new Cn),Cn.instance}async setupWebSocketConnection(){return new Promise((e,n)=>{if(this.socket)return e(!0);this.socket=ui(this.backendUrl,{transports:["websocket","polling"]}),this.socket.once("connect",()=>{this.isConnected=!0,e(!0)}),this.socket.once("connect_error",s=>{n(v.ConnectionLostError)}),this.socket.once("disconnect",s=>{this.handleSocketDisconnection(s)})})}handleSocketDisconnection(e){this.isConnected=!1}async initializeStreaming(e,n){this.videoStream=e,this.videoElement=n,this.videoElement.srcObject=e,this.canvas=document.createElement("canvas"),this.canvas.width=n.videoWidth||640,this.canvas.height=n.videoHeight||480,await this.setupWebSocketConnection()}startStreaming(e){var n;this.jobId=e,(n=this.socket)==null||n.emit("register",e),this.sendInitialRequest(e),this.isStreaming=!0,this.startVideoStream(),this.addDisconnectionListener()}async sendInitialRequest(e){await Z.post(`${this.backendUrl}/react`,{username:e,uuid:e,device_id:"1234567",face_detector:"BlazefaceFacemesh",motion_tracking:!0,skin_segmentor:"HSVandYCrCbSkinSegmentation",extreme_pixel_removal:!1,gamma_value:1,eularian_color_magnification:!1},{headers:{"Content-Type":"application/json"}})}startVideoStream(){if(!this.videoElement){T.error("Video stream not found when trying to start streaming");return}const e=this.videoElement,n=()=>{e.videoWidth>0&&e.videoHeight>0&&(this.playHandler(),e.removeEventListener("loadedmetadata",n),e.removeEventListener("playing",n))};e.addEventListener("playing",n),e.addEventListener("loadedmetadata",n),e.readyState>=2&&e.videoWidth>0&&e.videoHeight>0&&n(),e.addEventListener("play",this.playHandler),e.play().catch(s=>T.error("Error starting video stream:",s))}sendFrameToBackend(e,n){e.toBlob(s=>{if(n&&n(),!s){T.warn("[WARN] canvas.toBlob returned null (likely 0×0 canvas or tainted).");return}const r=new FileReader;r.onloadend=()=>{var i;if(this.isConnected&&this.isStreaming){const o=r.result;(i=this.socket)==null||i.emit("frame",o)}},r.readAsArrayBuffer(s)},"image/jpeg",.7)}removePlayEventListener(){this.videoElement&&this.videoElement.removeEventListener("play",this.playHandler)}setOnDisconnection(e){this.onDisconnection=e}addDisconnectionListener(){const e=zp(),n=Ks(e,`${this.jobId}/disconnect`),s=Jr(n,r=>{r.val()!=null&&(this.stopStreaming(),this.onDisconnection&&this.onDisconnection(),s())})}};w(Cn,"instance");let Wi=Cn;const Hw="__cookie_auth__";function Ww(){return typeof document<"u"&&typeof window<"u"}function Nd(t){try{const e=document.cookie.match(new RegExp(`(?:^|;\\s*)${t}=([^;]*)`));return e?decodeURIComponent(e[1]):null}catch{return null}}const Gw="csrf_nervotec_client_access";function $w(){return Ww()?Nd(Gw)??Nd("csrf_access_token"):null}function xd(t="application/json"){const e={};t&&(e["Content-Type"]=t);const n=$w();return n&&(e["X-CSRF-TOKEN"]=n),e}class C_{constructor(){w(this,"backendUrl",So("server"));w(this,"streamingManager",Wi.getInstance());w(this,"accessTokenProvider");w(this,"onFinalResultsCallback");w(this,"onErrorCallback");w(this,"authMode","bearer")}setAuthMode(e){this.authMode=e}getAuthMode(){return this.authMode}setBaseUrl(e){typeof e=="string"&&e.trim().length>0&&(this.backendUrl=e,T.log("[DEBUG] BackendRepository baseUrl override:",this.backendUrl))}setOnErrorCallback(e){this.onErrorCallback=e}setOnFinalResultsCallback(e){this.onFinalResultsCallback=e}mapStructuredVitals(e){const n=d=>{if(!d||typeof d!="object")return;const p=d.value,f=typeof p=="number"?p:parseFloat(String(p));return Number.isFinite(f)?f:void 0},s={},r=n(e.heart_rate);r!==void 0&&(s.HR=r);const i=n(e.hrv);i!==void 0&&(s.RMSSD=i,s.SDNN=i);const o=n(e.spo2);o!==void 0&&(s.SPO2=o);const a=n(e.respiratory_rate);a!==void 0&&(s.RR=a);const c=e.blood_pressure;if(c&&typeof c=="object"){const d=n(c.systolic),p=n(c.diastolic);d!==void 0&&(s.SBP=d),p!==void 0&&(s.DBP=p)}const l=n(e.stress_score);l!==void 0&&(s.STRESS_LEVEL=l);const h=n(e.hba1c);h!==void 0&&(s.GLUCOSE=h);const u=n(e.hemoglobin);return u!==void 0&&(s.HEMOGLOBIN=u),s}setAccessTokenProvider(e){this.accessTokenProvider=e}}class jw extends C_{constructor(n){super();w(this,"streamingManager",Wi.getInstance());w(this,"rgbManager",Ui.getInstance());this.backendUrl=So("server"),this.setBaseUrl(n),T.log("ServerRepository",this.backendUrl)}async getTokenWithUsernameAndPassword(n,s){try{return(await Z.post(this.backendUrl.concat("/clientlogin"),{username:n,password:s})).data.access_token}catch(r){G.handleErrorResponse(r)}}async getTokenWithLicenseKey(n){var s,r;try{const i=this.backendUrl.concat("/clientloginwithlicensekey");if(this.authMode==="cookie"){const c=await Z.post(i,{license_key:n},{withCredentials:!0,headers:xd()});((s=c.data)==null?void 0:s.success)===!1&&G.handleErrorResponse({response:c});const l=(r=c.data)==null?void 0:r.access_token;return l&&String(l).length>0?String(l):Hw}return(await Z.post(i,{license_key:n})).data.access_token}catch(i){G.handleErrorResponse(i)}}async getAPIKey(n){n||G.throwKnownError(v.InvalidAccessTokenError);try{return(await Z.post(this.backendUrl.concat("/clientgeturl"),{host_name:"www.nervoscan.com"},{headers:{Authorization:`Bearer ${n}`}})).data.url.split("?api_key=")[1]}catch(s){G.handleErrorResponse(s)}}async uploadVideoToServer(n,s,r){(!s||!r)&&G.throwKnownError(v.InvalidAccessTokenError);const i=new FormData;i.append("file",n,"recording.webm"),i.append("data",JSON.stringify({uuid:r,meta_data:{}}));const a=await(await fetch(this.backendUrl.concat("/submitscan"),{method:"POST",headers:{Authorization:`Bearer ${s}`},body:i})).json();return a.success===!1&&G.handleErrorResponse(a),a}async sendRgbDataToBackend(n,s,r,i){try{const o=this.authMode==="cookie";let a;o?this.accessTokenProvider&&await this.accessTokenProvider():(a=this.accessTokenProvider?await this.accessTokenProvider():void 0,a||G.throwKnownError(v.InvalidAccessTokenError));const c={job_id:i,timestamp:Date.now(),rgbData:n,resolution:{width:s,height:r}};T.log(`[Backend] Sending RGB data to backend with resolution: ${s}x${r}`),T.debug("Sending RGB data to backend:",c);const l=o?xd():{"Content-Type":"application/json",Authorization:`Bearer ${a}`},h=await Z.post(`${this.backendUrl}/rgb-data`,c,{headers:l,withCredentials:o}),u=h.data;if(T.debug("[Backend] RGB response",{status:h.status,keys:u&&typeof u=="object"?Object.keys(u):[]}),u&&typeof u=="object"){const d=u.processedData;if(d){const p=d.averaged_results,f=d.vitals;if(this.onFinalResultsCallback&&(p||f)){const g={...p&&typeof p=="object"?p:{},...f&&typeof f=="object"?{vitals:f}:{},...f&&typeof f=="object"?this.mapStructuredVitals(f):{}};this.onFinalResultsCallback(g)}else this.onFinalResultsCallback||T.debug("[Backend] No onFinalResults callback set")}}return h.data}catch(o){T.debug("[Backend] sendRgbDataToBackend error:",o),G.handleBackendError(o,this.onErrorCallback)}}}class qw extends C_{constructor(e){super(),this.backendUrl=So("serverless"),this.setBaseUrl(e)}async getTokenWithUsernameAndPassword(e,n){try{const s=await Z.post(this.backendUrl.concat("/user/login"),{username:e,password:n});if(s.data.success===!1)G.throwKnownError(v.InvalidUsernameError);else return JSON.parse(s.data.body).idToken}catch(s){T.error("error printed in serverless repository",s),G.handleErrorResponse(s)}}async getTokenWithLicenseKey(e){G.throwKnownError(v.NotImplementedError)}async getAPIKey(e){e||G.throwKnownError(v.InvalidAccessTokenError);try{return(await Z.post(this.backendUrl.concat("/get-redirection-url"),{host_name:"www.nervoscan.com"},{headers:{Authorization:`Bearer ${e}`}})).data.url.split("?api_key=")[1]}catch(n){G.handleErrorResponse(n)}}async uploadVideoToServer(e,n,s){(!n||!s)&&G.throwKnownError(v.InvalidAccessTokenError);try{const r=await this.generatePreSignedUrl(s);return r||G.throwKnownError(v.InvalidAccessTokenError),await this.uploadVideoToS3(e,r)}catch(r){throw T.error("Error uploading video:",r),r.response?(T.error("Error response:",r.response.data),T.error("Error status:",r.response.status),T.error("Error headers:",r.response.headers)):r.request?T.error("Error request:",r.request):T.error("Error message:",r.message),r}}async generatePreSignedUrl(e){try{return(await Z.get(this.backendUrl.concat("/generate-presigned-url?job_id="+e))).data.upload_url}catch(n){G.handleErrorResponse(n)}}async uploadVideoToS3(e,n){try{return(await Z.put(n,e,{headers:{"Content-Type":"video/mp4"}})).data}catch(s){G.handleErrorResponse(s)}}async sendRgbDataToBackend(e,n,s,r){G.throwKnownError(v.NotImplementedError)}}class S_{static createBackendRepository(e,n,s,r="bearer"){let i;return e==="server"?i=new jw(s):e==="serverless"?i=new qw(s):G.throwKnownError(v.InvalidServerTypeError),i.setAuthMode(r),i}}class zw{constructor(e,n,s,r="server",i,o="bearer"){w(this,"backendRepository");w(this,"username");w(this,"password");w(this,"licenseKey");w(this,"baseUrl");this.backendRepository=S_.createBackendRepository(r,!1,i,o),this.username=e,this.password=n,this.licenseKey=s,this.baseUrl=i,e&&n&&T.warn("Using username and password for authentication is deprecated. Please use license key instead.")}async validate(){if(this.licenseKey)return this.validateWithKey(this.licenseKey);if(this.username&&this.password)return this.validatewithUsernameAndPassword(this.username,this.password);G.throwKnownError(v.InvalidCredentialsError)}async validateWithKey(e){return this.backendRepository.getTokenWithLicenseKey(e)}async validatewithUsernameAndPassword(e,n){return this.backendRepository.getTokenWithUsernameAndPassword(e,n)}}const Sn=class Sn{constructor(){w(this,"initialized",!1);w(this,"accessToken");w(this,"backendRepository");w(this,"onWindowResults");w(this,"onFinalResults");w(this,"onError");w(this,"useRgb",!1);w(this,"rgbManager",Ui.getInstance());w(this,"onDisconnection",()=>{});w(this,"licenceManager");w(this,"firebaseApp");w(this,"listener");const e={apiKey:"AIzaSyAid2Ds7N0uusVOKbhMQjRY7qoGGM9ABe0",authDomain:"nervowebreact.firebaseapp.com",databaseURL:"https://nervowebreact-default-rtdb.asia-southeast1.firebasedatabase.app",projectId:"nervowebreact",storageBucket:"nervowebreact.firebasestorage.app",messagingSenderId:"1025695568936",appId:"1:1025695568936:web:fe7f415cf383fd2eda511d"},n="nervoscan-sdk";t2().some(s=>s.name===n)?this.firebaseApp=Rf(n):this.firebaseApp=Af(e,n)}static getInstance(){return Sn.instance||(Sn.instance=new Sn),Sn.instance}addfirebaseListeners(e){var n;(n=this.listener)==null||n.detachAll(),this.listener=new w3(this.firebaseApp,{onWindow:s=>{var r;return(r=this.onWindowResults)==null?void 0:r.call(this,s)},onFinal:s=>{var r;T.log(`[Client] Received results for job ${e}:`,s),this.useRgb&&this.rgbManager.isContinuousModeEnabled()?this.rgbManager.handleBatchResults(s):(r=this.onFinalResults)==null||r.call(this,s)},onError:s=>{const r=G.handleScanError(s);this.onError?this.onError(r):G.throwKnownError(v.ErrorCallbackNotSetError)}}),this.listener.attach(e)}initialize({username:e,password:n,licenseKey:s,serverType:r="server",useRgb:i=!1,baseUrl:o,authMode:a="bearer"}){this.initialized=!0,this.useRgb=i,this.licenceManager=new zw(e,n,s,r,o,a),this.backendRepository=S_.createBackendRepository(r,i,o,a),this.backendRepository.setAccessTokenProvider(async()=>this.licenceManager.validate()),this.backendRepository.setOnFinalResultsCallback(c=>{T.debug("[Client] Received final results via direct backend callback"),this.onFinalResults&&this.onFinalResults(c)}),this.backendRepository.setOnErrorCallback(c=>{T.debug("[Client] Received error via direct backend callback"),this.onError&&this.onError(c)})}async uploadVideo(e){var n,s;this.initialized||G.throwKnownError(v.NotInitializedError),e instanceof Blob||G.throwKnownError(v.VideoTypeError),(e===null||e.size===0)&&G.throwKnownError(v.EmptyVideoError),performance.now();try{const r=await this.licenceManager.validate(),i=await((n=this.backendRepository)==null?void 0:n.getAPIKey(r)),o=(s=this.backendRepository)==null?void 0:s.uploadVideoToServer(e,r,i);return i&&this.addfirebaseListeners(i),i}catch(r){throw r}}setOnFinalResults(e){this.onFinalResults=e}setOnWindowResults(e){this.onWindowResults=e}setOnError(e){this.onError=e}setOnDisconnection(e){var n;(n=this.backendRepository)==null||n.streamingManager.setOnDisconnection(e),this.onDisconnection=e}setOnAlignmentStatus(e){this.rgbManager.setAlignmentStatusCallback(e)}startFaceDetection(){this.useRgb&&this.rgbManager.startFaceDetection()}stopFaceDetection(){this.useRgb&&this.rgbManager.stopFaceDetection()}async initializeStreaming(e,n,s={}){var r;this.useRgb?await this.rgbManager.initialize(e,n,this.backendRepository,this.onDisconnection,s):await((r=this.backendRepository)==null?void 0:r.streamingManager.initializeStreaming(e,n))}async startStreaming(){var e;this.initialized||G.throwKnownError(v.NotInitializedError),performance.now();try{if(this.backendRepository.getAuthMode()==="cookie")try{await this.licenceManager.validate()}catch{G.throwKnownError(v.InvalidAccessTokenError)}else await this.licenceManager.validate()||G.throwKnownError(v.InvalidCredentialsError);const s=crypto.randomUUID();return this.useRgb?(T.log("Starting RGB streaming"),await this.rgbManager.startStreaming(s)):((e=this.backendRepository)==null||e.streamingManager.startStreaming(s),this.addfirebaseListeners(s)),s}catch(n){throw n}}async stopStreaming(e=!1){var n;if((n=this.backendRepository)==null||n.streamingManager.stopStreaming(),this.rgbManager.stopStreaming(),!e)try{await this.validateScanCompletion()}catch(s){throw s}}async validateScanCompletion(){if(this.initialized||G.throwKnownError(v.NotInitializedError),!this.useRgb)return;const e=this.getRGBDataCollectionStatus();if(e.error&&e.error==="RGB mode not enabled")return;const n=300,s=13.5,r=(e==null?void 0:e.bufferSize)||0,i=this.getRGBTimestamps();let o=null;if(i.length>=2){const a=i[i.length-1]-i[0];a>0&&(o=(i.length-1)/a)}if(o!==null&&o<s){const a=`Camera frame rate is too low (${o.toFixed(1)} FPS). Please try again with better lighting and ensure your device is not under heavy load.`;throw new K.LowFPSError(a)}r<n&&G.throwKnownError(v.InsufficientDataError),o===null&&G.throwKnownError(v.FPSCalculationError)}getRGBDataCollectionStatus(){return this.useRgb&&this.rgbManager?this.rgbManager.getDataCollectionStatus():{error:"RGB mode not enabled"}}getRGBTimestamps(){return this.useRgb&&this.rgbManager?this.rgbManager.getRGBTimestamps():[]}};w(Sn,"instance");let lc=Sn;exports.Client=lc;exports.ConnectionLostError=sf;exports.EmptyVideoError=Dd;exports.EnvIncompatibleError=uf;exports.ErrorCallbackNotSetError=Xd;exports.Errors=K;exports.FPSCalculationError=$d;exports.FaceLandmarkerNotInitializedError=hf;exports.FaceLookingLeftError=Kd;exports.FaceLookingRightError=Yd;exports.FaceNotCenteredError=jd;exports.FaceTooCloseError=zd;exports.FaceTooFarError=qd;exports.InsufficientDataError=df;exports.InvalidAccessTokenError=Ud;exports.InvalidContentTypeError=Zd;exports.InvalidCredentialsError=af;exports.InvalidPasswordError=Md;exports.InvalidServerTypeError=Hd;exports.InvalidUsernameError=Fd;exports.JobNotRegisteredError=ef;exports.LicenseInactiveError=cf;exports.LowFPSError=Gd;exports.LowFrameCountError=nf;exports.NervoscanError=j;exports.NoScanDataError=Vd;exports.NoScansAvailableError=Bd;exports.NotImplementedError=Wd;exports.NotInitializedError=Ld;exports.REGION_NAMES=Vg;exports.RGBError=lf;exports.ScanFailedError=rf;exports.SkinExtractionError=Qd;exports.UnhandledError=tf;exports.UnhandledScanError=Jd;exports.VideoError=of;exports.VideoTypeError=Pd;