idmission-web-sdk 0.0.21 → 0.0.22
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.
- package/README.md +2 -2
- package/dist/components/customer_flows/CustomerBiometricsEnrollment.d.ts +7 -1
- package/dist/components/customer_flows/CustomerIdAndBiometricsEnrollment.d.ts +12 -2
- package/dist/components/customer_flows/CustomerIdentification.d.ts +5 -1
- package/dist/components/customer_flows/CustomerVerification.d.ts +5 -1
- package/dist/components/customer_flows/FaceValidation.d.ts +5 -1
- package/dist/components/customer_flows/IdAndFaceValidation.d.ts +10 -2
- package/dist/components/customer_flows/IdValidation.d.ts +10 -2
- package/dist/components/submission/SubmissionProvider.d.ts +12 -2
- package/dist/contexts/SubmissionContext.d.ts +25 -4
- package/package.json +1 -1
- package/dist/index.js +0 -7
- package/dist/sdk2.cjs.development.js +0 -13395
- package/dist/sdk2.cjs.development.js.map +0 -1
- package/dist/sdk2.cjs.production.js +0 -2
- package/dist/sdk2.cjs.production.js.map +0 -1
- package/dist/sdk2.esm.js +0 -13343
- package/dist/sdk2.esm.js.map +0 -1
- package/dist/sdk2.umd.development.js +0 -17632
- package/dist/sdk2.umd.development.js.map +0 -1
- package/dist/sdk2.umd.production.js +0 -2
- package/dist/sdk2.umd.production.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react-dom"),require("react"),require("@sentry/react"),require("styled-components"),require("@tensorflow/tfjs")):"function"==typeof define&&define.amd?define(["exports","react-dom","react","@sentry/react","styled-components","@tensorflow/tfjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Sdk2={},e.ReactDOM,e.React,e.Sentry,e.styled,e.tf)}(this,(function(e,t,n,r,i,a){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var l=o(t),u=o(n),c=s(n),d=s(r),h=o(i),f=s(a),p=function(){return p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},p.apply(this,arguments)};function g(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}l((r=r.apply(e,t||[])).next())}))}function m(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function v(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function y(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}const b={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console&&console[e]&&console[e].apply(console,t)}};class w{constructor(e){this.init(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}init(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||b,this.options=t,this.debug=t.debug}log(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}warn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}error(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}deprecate(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,n,r){return r&&!this.debug?null:("string"==typeof e[0]&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new w(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new w(this.logger,e)}}var x=new w;class E{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach((e=>{this.observers[e]=this.observers[e]||[],this.observers[e].push(t)})),this}off(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((e=>e!==t)):delete this.observers[e])}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(this.observers[e]){[].concat(this.observers[e]).forEach((e=>{e(...n)}))}if(this.observers["*"]){[].concat(this.observers["*"]).forEach((t=>{t.apply(t,[e,...n])}))}}}function S(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));return n.resolve=e,n.reject=t,n}function T(e){return null==e?"":""+e}function k(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}const a="string"!=typeof t?[].concat(t):t.split(".");for(;a.length>1;){if(i())return{};const t=r(a.shift());!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}return i()?{}:{obj:e,k:r(a.shift())}}function C(e,t,n){const{obj:r,k:i}=k(e,t,Object);r[i]=n}function A(e,t){const{obj:n,k:r}=k(e,t);if(n)return n[r]}function R(e,t,n){for(const r in t)"__proto__"!==r&&"constructor"!==r&&(r in e?"string"==typeof e[r]||e[r]instanceof String||"string"==typeof t[r]||t[r]instanceof String?n&&(e[r]=t[r]):R(e[r],t[r],n):e[r]=t[r]);return e}function _(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var I={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function D(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(e=>I[e])):e}const F=[" ",",","?","!",";"];function L(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(!e)return;if(e[t])return e[t];const r=t.split(n);let i=e;for(let e=0;e<r.length;++e){if(!i)return;if("string"==typeof i[r[e]]&&e+1<r.length)return;if(void 0===i[r[e]]){let a=2,o=r.slice(e,e+a).join(n),s=i[o];for(;void 0===s&&r.length>e+a;)a++,o=r.slice(e,e+a).join(n),s=i[o];if(void 0===s)return;if(null===s)return null;if(t.endsWith(o)){if("string"==typeof s)return s;if(o&&"string"==typeof s[o])return s[o]}const l=r.slice(e+a).join(n);return l?L(s,l,n):void 0}i=i[r[e]]}return i}function M(e){return e&&e.indexOf("_")>0?e.replace("_","-"):e}class N extends E{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,a=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let o=[e,t];n&&"string"!=typeof n&&(o=o.concat(n)),n&&"string"==typeof n&&(o=o.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(o=e.split("."));const s=A(this.data,o);return s||!a||"string"!=typeof n?s:L(this.data&&this.data[e]&&this.data[e][t],n,i)}addResource(e,t,n,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const a=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator;let o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.indexOf(".")>-1&&(o=e.split("."),r=t,t=o[1]),this.addNamespaces(t),C(this.data,o,r),i.silent||this.emit("added",e,t,n,r)}addResources(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(const r in n)"string"!=typeof n[r]&&"[object Array]"!==Object.prototype.toString.apply(n[r])||this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit("added",e,t,n)}addResourceBundle(e,t,n,r,i){let a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},o=[e,t];e.indexOf(".")>-1&&(o=e.split("."),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=A(this.data,o)||{};r?R(s,n,i):s={...s,...n},C(this.data,o,s),a.silent||this.emit("added",e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?{...this.getResource(e,t)}:this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((e=>t[e]&&Object.keys(t[e]).length>0))}toJSON(){return this.data}}var O={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach((e=>{this.processors[e]&&(t=this.processors[e].process(t,n,r,i))})),t}};const P={};class B extends E{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),function(e,t,n){e.forEach((e=>{t[e]&&(n[e]=t[e])}))}(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=x.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){if(null==e)return!1;const t=this.resolve(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}});return t&&void 0!==t.res}extractFromKey(e,t){let n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");const r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator;let i=t.ns||this.options.defaultNS||[];const a=n&&e.indexOf(n)>-1,o=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||"",n=n||"";const r=F.filter((e=>t.indexOf(e)<0&&n.indexOf(e)<0));if(0===r.length)return!0;const i=new RegExp(`(${r.map((e=>"?"===e?"\\?":e)).join("|")})`);let a=!i.test(e);if(!a){const t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a}(e,n,r));if(a&&!o){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:i};const a=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(a[0])>-1)&&(i=a.shift()),e=a.join(r)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}translate(e,t,n){if("object"!=typeof t&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof t&&(t={...t}),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);const r=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,{key:a,namespaces:o}=this.extractFromKey(e[e.length-1],t),s=o[o.length-1],l=t.lng||this.language,u=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(u){const e=t.nsSeparator||this.options.nsSeparator;return r?{res:`${s}${e}${a}`,usedKey:a,exactUsedKey:a,usedLng:l,usedNS:s}:`${s}${e}${a}`}return r?{res:a,usedKey:a,exactUsedKey:a,usedLng:l,usedNS:s}:a}const c=this.resolve(e,t);let d=c&&c.res;const h=c&&c.usedKey||a,f=c&&c.exactUsedKey||a,p=Object.prototype.toString.apply(d),g=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,m=!this.i18nFormat||this.i18nFormat.handleAsObject;if(m&&d&&("string"!=typeof d&&"boolean"!=typeof d&&"number"!=typeof d)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(p)<0&&("string"!=typeof g||"[object Array]"!==p)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,d,{...t,ns:o}):`key '${a} (${this.language})' returned an object instead of string.`;return r?(c.res=e,c):e}if(i){const e="[object Array]"===p,n=e?[]:{},r=e?f:h;for(const e in d)if(Object.prototype.hasOwnProperty.call(d,e)){const a=`${r}${i}${e}`;n[e]=this.translate(a,{...t,joinArrays:!1,ns:o}),n[e]===a&&(n[e]=d[e])}d=n}}else if(m&&"string"==typeof g&&"[object Array]"===p)d=d.join(g),d&&(d=this.extendTranslation(d,e,t,n));else{let r=!1,o=!1;const u=void 0!==t.count&&"string"!=typeof t.count,h=B.hasDefaultValue(t),f=u?this.pluralResolver.getSuffix(l,t.count,t):"",p=t.ordinal&&u?this.pluralResolver.getSuffix(l,t.count,{ordinal:!1}):"",g=t[`defaultValue${f}`]||t[`defaultValue${p}`]||t.defaultValue;!this.isValidLookup(d)&&h&&(r=!0,d=g),this.isValidLookup(d)||(o=!0,d=a);const m=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&o?void 0:d,v=h&&g!==d&&this.options.updateMissing;if(o||r||v){if(this.logger.log(v?"updateKey":"missingKey",l,s,a,v?g:d),i){const e=this.resolve(a,{...t,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[];const n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&n&&n[0])for(let t=0;t<n.length;t++)e.push(n[t]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(t.lng||this.language):e.push(t.lng||this.language);const r=(e,n,r)=>{const i=h&&r!==d?r:m;this.options.missingKeyHandler?this.options.missingKeyHandler(e,s,n,i,v,t):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(e,s,n,i,v,t),this.emit("missingKey",e,s,n,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&u?e.forEach((e=>{this.pluralResolver.getSuffixes(e,t).forEach((n=>{r([e],a+n,t[`defaultValue${n}`]||g)}))})):r(e,a,g))}d=this.extendTranslation(d,e,t,c,n),o&&d===a&&this.options.appendNamespaceToMissingKey&&(d=`${s}:${a}`),(o||r)&&this.options.parseMissingKeyHandler&&(d="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${s}:${a}`:a,r?d:void 0):this.options.parseMissingKeyHandler(d))}return r?(c.res=d,c):d}extendTranslation(e,t,n,r,i){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});const o="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let s;if(o){const t=e.match(this.interpolator.nestingRegexp);s=t&&t.length}let l=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),e=this.interpolator.interpolate(e,l,n.lng||this.language,n),o){const t=e.match(this.interpolator.nestingRegexp);s<(t&&t.length)&&(n.nest=!1)}!n.lng&&"v1"!==this.options.compatibilityAPI&&r&&r.res&&(n.lng=r.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return i&&i[0]===r[0]&&!n.context?(a.logger.warn(`It seems you are nesting recursively key: ${r[0]} in key: ${t[0]}`),null):a.translate(...r,t)}),n)),n.interpolation&&this.interpolator.reset()}const o=n.postProcess||this.options.postProcess,s="string"==typeof o?[o]:o;return null!=e&&s&&s.length&&!1!==n.applyPostProcessor&&(e=O.handle(s,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:r,...n}:n,this)),e}resolve(e){let t,n,r,i,a,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((e=>{if(this.isValidLookup(t))return;const s=this.extractFromKey(e,o),l=s.key;n=l;let u=s.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const c=void 0!==o.count&&"string"!=typeof o.count,d=c&&!o.ordinal&&0===o.count&&this.pluralResolver.shouldUseIntlApi(),h=void 0!==o.context&&("string"==typeof o.context||"number"==typeof o.context)&&""!==o.context,f=o.lngs?o.lngs:this.languageUtils.toResolveHierarchy(o.lng||this.language,o.fallbackLng);u.forEach((e=>{this.isValidLookup(t)||(a=e,!P[`${f[0]}-${e}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(a)&&(P[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${n}" for languages "${f.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),f.forEach((n=>{if(this.isValidLookup(t))return;i=n;const a=[l];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(a,l,n,e,o);else{let e;c&&(e=this.pluralResolver.getSuffix(n,o.count,o));const t=`${this.options.pluralSeparator}zero`,r=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(a.push(l+e),o.ordinal&&0===e.indexOf(r)&&a.push(l+e.replace(r,this.options.pluralSeparator)),d&&a.push(l+t)),h){const n=`${l}${this.options.contextSeparator}${o.context}`;a.push(n),c&&(a.push(n+e),o.ordinal&&0===e.indexOf(r)&&a.push(n+e.replace(r,this.options.pluralSeparator)),d&&a.push(n+t))}}let s;for(;s=a.pop();)this.isValidLookup(t)||(r=s,t=this.getResource(n,e,s,o))})))}))})),{res:t,usedKey:n,exactUsedKey:r,usedLng:i,usedNS:a}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}getResource(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}static hasDefaultValue(e){const t="defaultValue";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&void 0!==e[n])return!0;return!1}}function U(e){return e.charAt(0).toUpperCase()+e.slice(1)}class ${constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=x.create("languageUtils")}getScriptPartFromCode(e){if(!(e=M(e))||e.indexOf("-")<0)return null;const t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}getLanguagePartFromCode(e){if(!(e=M(e))||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if("string"==typeof e&&e.indexOf("-")>-1){const t=["hans","hant","latn","cyrl","cans","mong","arab"];let n=e.split("-");return this.options.lowerCaseLng?n=n.map((e=>e.toLowerCase())):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=U(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=U(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=U(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach((e=>{if(t)return;const n=this.formatLanguageCode(e);this.options.supportedLngs&&!this.isSupportedCode(n)||(t=n)})),!t&&this.options.supportedLngs&&e.forEach((e=>{if(t)return;const n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find((e=>e===n?e:e.indexOf("-")<0&&n.indexOf("-")<0?void 0:0===e.indexOf(n)?e:void 0))})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];let n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}toResolveHierarchy(e,t){const n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],i=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return"string"==typeof e&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&i(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&i(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&i(this.getLanguagePartFromCode(e))):"string"==typeof e&&i(this.formatLanguageCode(e)),n.forEach((e=>{r.indexOf(e)<0&&i(this.formatLanguageCode(e))})),r}}let j=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],G={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}};const z=["v1","v2","v3"],q=["v4"],H={zero:0,one:1,two:2,few:3,many:4,other:5};class V{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.languageUtils=e,this.options=t,this.logger=x.create("pluralResolver"),this.options.compatibilityJSON&&!q.includes(this.options.compatibilityJSON)||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=function(){const e={};return j.forEach((t=>{t.lngs.forEach((n=>{e[n]={numbers:t.nr,plurals:G[t.fc]}}))})),e}()}addRule(e,t){this.rules[e]=t}getRule(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(M(e),{type:t.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}needsPlural(e){const t=this.getRule(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return this.shouldUseIntlApi()?t&&t.resolvedOptions().pluralCategories.length>1:t&&t.numbers.length>1}getPluralFormsOfKey(e,t){return this.getSuffixes(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).map((e=>`${t}${e}`))}getSuffixes(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.getRule(e,t);return n?this.shouldUseIntlApi()?n.resolvedOptions().pluralCategories.sort(((e,t)=>H[e]-H[t])).map((e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`)):n.numbers.map((n=>this.getSuffix(e,n,t))):[]}getSuffix(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=this.getRule(e,n);return r?this.shouldUseIntlApi()?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r.select(t)}`:this.getSuffixRetroCompatible(r,t):(this.logger.warn(`no plural rule found for: ${e}`),"")}getSuffixRetroCompatible(e,t){const n=e.plurals(e.noAbs?t:Math.abs(t));let r=e.numbers[n];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===r?r="plural":1===r&&(r=""));const i=()=>this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString();return"v1"===this.options.compatibilityJSON?1===r?"":"number"==typeof r?`_plural_${r.toString()}`:i():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?i():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}shouldUseIntlApi(){return!z.includes(this.options.compatibilityJSON)}}function W(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=function(e,t,n){const r=A(e,n);return void 0!==r?r:A(t,n)}(e,t,n);return!a&&i&&"string"==typeof n&&(a=L(e,n,r),void 0===a&&(a=L(t,n,r))),a}class K{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=x.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||(e=>e),this.init(e)}init(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const t=e.interpolation;this.escape=void 0!==t.escape?t.escape:D,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?_(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?_(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?_(t.nestingPrefix):t.nestingPrefixEscaped||_("$t("),this.nestingSuffix=t.nestingSuffix?_(t.nestingSuffix):t.nestingSuffixEscaped||_(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){this.regexp=new RegExp(`${this.prefix}(.+?)${this.suffix}`,"g");this.regexpUnescape=new RegExp(`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`,"g");this.nestingRegexp=new RegExp(`${this.nestingPrefix}(.+?)${this.nestingSuffix}`,"g")}interpolate(e,t,n,r){let i,a,o;const s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function l(e){return e.replace(/\$/g,"$$$$")}const u=e=>{if(e.indexOf(this.formatSeparator)<0){const i=W(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}const i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(W(t,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp();const c=r&&r.missingInterpolationHandler||this.options.missingInterpolationHandler,d=r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>l(e)},{regex:this.regexp,safeValue:e=>l(this.escapeValue?this.escape(e):e)}].forEach((t=>{for(o=0;i=t.regex.exec(e);){const n=i[1].trim();if(a=u(n),void 0===a)if("function"==typeof c){const t=c(e,i,r);a="string"==typeof t?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,n))a="";else{if(d){a=i[0];continue}this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=""}else"string"==typeof a||this.useRawValueToEscape||(a=T(a));const s=t.safeValue(a);if(e=e.replace(i[0],s),d?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}})),e}nest(e,t){let n,r,i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function o(e,t){const n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;const r=e.split(new RegExp(`${n}[ ]*{`));let a=`{${r[1]}`;e=r[0],a=this.interpolate(a,i);const o=a.match(/'/g),s=a.match(/"/g);(o&&o.length%2==0&&!s||s.length%2!=0)&&(a=a.replace(/'/g,'"'));try{i=JSON.parse(a),t&&(i={...t,...i})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${a}`}return delete i.defaultValue,e}for(;n=this.nestingRegexp.exec(e);){let s=[];i={...a},i=i.replace&&"string"!=typeof i.replace?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;let l=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){const e=n[1].split(this.formatSeparator).map((e=>e.trim()));n[1]=e.shift(),s=e,l=!0}if(r=t(o.call(this,n[1].trim(),i),i),r&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=T(r)),r||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),r=""),l&&(r=s.reduce(((e,t)=>this.format(e,t,a.lng,{...a,interpolationkey:n[1].trim()})),r.trim())),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}function Y(e){const t={};return function(n,r,i){const a=r+JSON.stringify(i);let o=t[a];return o||(o=e(M(r),i),t[a]=o),o(n)}}class X{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=x.create("formatter"),this.options=e,this.formats={number:Y(((e,t)=>{const n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)})),currency:Y(((e,t)=>{const n=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>n.format(e)})),datetime:Y(((e,t)=>{const n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)})),relativetime:Y(((e,t)=>{const n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||"day")})),list:Y(((e,t)=>{const n=new Intl.ListFormat(e,{...t});return e=>n.format(e)}))},this.init(e)}init(e){const t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=Y(t)}format(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const i=t.split(this.formatSeparator).reduce(((e,t)=>{const{formatName:i,formatOptions:a}=function(e){let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);"currency"===t&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach((e=>{if(!e)return;const[t,...r]=e.split(":"),i=r.join(":").trim().replace(/^'+|'+$/g,"");n[t.trim()]||(n[t.trim()]=i),"false"===i&&(n[t.trim()]=!1),"true"===i&&(n[t.trim()]=!0),isNaN(i)||(n[t.trim()]=parseInt(i,10))}))}return{formatName:t,formatOptions:n}}(t);if(this.formats[i]){let t=e;try{const o=r&&r.formatParams&&r.formatParams[r.interpolationkey]||{};t=this.formats[i](e,o.locale||o.lng||r.locale||r.lng||n,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e}),e);return i}}class J extends E{constructor(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=x.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(n,r.backend,r)}queueLoad(e,t,n,r){const i={},a={},o={},s={};return e.forEach((e=>{let r=!0;t.forEach((t=>{const o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(1===this.state[o]?void 0===a[o]&&(a[o]=!0):(this.state[o]=1,r=!1,void 0===a[o]&&(a[o]=!0),void 0===i[o]&&(i[o]=!0),void 0===s[t]&&(s[t]=!0)))})),r||(o[e]=!0)})),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){const r=e.split("|"),i=r[0],a=r[1];t&&this.emit("failedLoading",i,a,t),n&&this.store.addResourceBundle(i,a,n),this.state[e]=t?-1:2;const o={};this.queue.forEach((n=>{!function(e,t,n,r){const{obj:i,k:a}=k(e,t,Object);i[a]=i[a]||[],r&&(i[a]=i[a].concat(n)),r||i[a].push(n)}(n.loaded,[i],a),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(n,e),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach((e=>{o[e]||(o[e]={});const t=n.loaded[e];t.length&&t.forEach((t=>{void 0===o[e][t]&&(o[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",o),this.queue=this.queue.filter((e=>!e.done))}read(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});this.readingCalls++;const o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){const e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}o&&s&&r<this.maxRetries?setTimeout((()=>{this.read.call(this,e,t,n,r+1,2*i,a)}),i):a(o,s)},s=this.backend[n].bind(this.backend);if(2!==s.length)return s(e,t,o);try{const n=s(e,t);n&&"function"==typeof n.then?n.then((e=>o(null,e))).catch(o):o(null,n)}catch(e){o(e)}}prepareLoading(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);const i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach((e=>{this.loadOne(e)}))}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const n=e.split("|"),r=n[0],i=n[1];this.read(r,i,"read",void 0,void 0,((n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)}))}saveMissing(e,t,n,r,i){let a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t))this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");else if(null!=n&&""!==n){if(this.backend&&this.backend.create){const s={...a,isUpdate:i},l=this.backend.create.bind(this.backend);if(l.length<6)try{let i;i=5===l.length?l(e,t,n,r,s):l(e,t,n,r),i&&"function"==typeof i.then?i.then((e=>o(null,e))).catch(o):o(null,i)}catch(e){o(e)}else l(e,t,n,r,o,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}}function Z(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){let t={};if("object"==typeof e[1]&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){const n=e[3]||e[2];Object.keys(n).forEach((e=>{t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:(e,t,n,r)=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function Q(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function ee(){}class te extends E{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;var n;if(super(),this.options=Q(e),this.services={},this.logger=x,this.modules={external:[]},n=this,Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach((e=>{"function"==typeof n[e]&&(n[e]=n[e].bind(n))})),t&&!this.isInitialized&&!e.isClone){if(!this.options.initImmediate)return this.init(e,t),this;setTimeout((()=>{this.init(e,t)}),0)}}init(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const r=Z();function i(e){return e?"function"==typeof e?new e:e:null}if(this.options={...r,...this.options,...Q(t)},"v1"!==this.options.compatibilityAPI&&(this.options.interpolation={...r.interpolation,...this.options.interpolation}),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){let t;x.init(this.modules.logger?i(this.modules.logger):null,this.options),this.modules.formatter?t=this.modules.formatter:"undefined"!=typeof Intl&&(t=X);const n=new $(this.options);this.store=new N(this.options.resources,this.options);const a=this.services;a.logger=x,a.resourceStore=this.store,a.languageUtils=n,a.pluralResolver=new V(n,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!t||this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format||(a.formatter=i(t),a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new K(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new J(i(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit(t,...r)})),this.modules.languageDetector&&(a.languageDetector=i(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=i(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new B(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit(t,...r)})),this.modules.external.forEach((e=>{e.init&&e.init(this)}))}if(this.format=this.options.interpolation.format,n||(n=ee),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((t=>{this[t]=function(){return e.store[t](...arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((t=>{this[t]=function(){return e.store[t](...arguments),e}}));const a=S(),o=()=>{const e=(e,t)=>{this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(t),n(e,t)};if(this.languages&&"v1"!==this.options.compatibilityAPI&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initImmediate?o():setTimeout(o,0),a}loadResources(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ee;const n="string"==typeof e?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(n&&"cimode"===n.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return t();const e=[],r=t=>{if(!t)return;if("cimode"===t)return;this.services.languageUtils.toResolveHierarchy(t).forEach((t=>{"cimode"!==t&&e.indexOf(t)<0&&e.push(t)}))};if(n)r(n);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e=>r(e)))}this.options.preload&&this.options.preload.forEach((e=>r(e))),this.services.backendConnector.load(e,this.options.ns,(e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),t(e)}))}else t(null)}reloadResources(e,t,n){const r=S();return e||(e=this.languages),t||(t=this.options.ns),n||(n=ee),this.services.backendConnector.reload(e,t,(e=>{r.resolve(),n(e)})),r}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&O.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(let e=0;e<this.languages.length;e++){const t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}}changeLanguage(e,t){var n=this;this.isLanguageChangingTo=e;const r=S();this.emit("languageChanging",e);const i=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(e,a)=>{a?(i(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit("languageChanged",a),this.logger.log("languageChanged",a)):this.isLanguageChangingTo=void 0,r.resolve((function(){return n.t(...arguments)})),t&&t(e,(function(){return n.t(...arguments)}))},o=t=>{e||t||!this.services.languageDetector||(t=[]);const n="string"==typeof t?t:this.services.languageUtils.getBestMatchFromCodes(t);n&&(this.language||i(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(n)),this.loadResources(n,(e=>{a(e,n)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),r}getFixedT(e,t,n){var r=this;const i=function(e,t){let a;if("object"!=typeof t){for(var o=arguments.length,s=new Array(o>2?o-2:0),l=2;l<o;l++)s[l-2]=arguments[l];a=r.options.overloadTranslationOptionHandler([e,t].concat(s))}else a={...t};a.lng=a.lng||i.lng,a.lngs=a.lngs||i.lngs,a.ns=a.ns||i.ns,a.keyPrefix=a.keyPrefix||n||i.keyPrefix;const u=r.options.keySeparator||".";let c;return c=a.keyPrefix&&Array.isArray(e)?e.map((e=>`${a.keyPrefix}${u}${e}`)):a.keyPrefix?`${a.keyPrefix}${u}${e}`:e,r.t(c,a)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const n=t.lng||this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;const a=(e,t)=>{const n=this.services.backendConnector.state[`${e}|${t}`];return-1===n||2===n};if(t.precheck){const e=t.precheck(this,a);if(void 0!==e)return e}return!!this.hasResourceBundle(n,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!a(n,e)||r&&!a(i,e)))}loadNamespaces(e,t){const n=S();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((e=>{this.options.ns.indexOf(e)<0&&this.options.ns.push(e)})),this.loadResources((e=>{n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){const n=S();"string"==typeof e&&(e=[e]);const r=this.options.preload||[],i=e.filter((e=>r.indexOf(e)<0));return i.length?(this.options.preload=r.concat(i),this.loadResources((e=>{n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";const t=this.services&&this.services.languageUtils||new $(Z());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){return new te(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}cloneInstance(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ee;const n=e.forkResourceStore;n&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},i=new te(r);void 0===e.debug&&void 0===e.prefix||(i.logger=i.logger.clone(e));return["store","services","language"].forEach((e=>{i[e]=this[e]})),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},n&&(i.store=new N(this.store.data,r),i.services.resourceStore=i.store),i.translator=new B(i.services,r),i.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];i.emit(e,...n)})),i.init(r,t),i.translator.options=r,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const ne=te.createInstance();ne.createInstance=te.createInstance;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function re(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ie(e,t){return e(t={exports:{}},t.exports),t.exports}const ae={};function oe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&ae[t[0]]||("string"==typeof t[0]&&(ae[t[0]]=new Date),function(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}(...t))}const se=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout((()=>{e.off("initialized",n)}),0),t()};e.on("initialized",n)}};function le(e,t,n){e.loadNamespaces(t,se(e,n))}function ue(e,t,n,r){"string"==typeof n&&(n=[n]),n.forEach((t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)})),e.loadLanguages(t,se(e,r))}const ce=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,de={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},he=e=>de[e];let fe,pe={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(ce,he)};const ge={type:"3rdParty",init(e){!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};pe={...pe,...e}}(e.options.react),function(e){fe=e}(e)}},me=n.createContext();class ve{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function ye(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:r}=t,{i18n:i,defaultNS:a}=n.useContext(me)||{},o=r||i||fe;if(o&&!o.reportNamespaces&&(o.reportNamespaces=new ve),!o){oe("You will need to pass in an i18next instance by using initReactI18next");const e=(e,t)=>"string"==typeof t?t:t&&"object"==typeof t&&"string"==typeof t.defaultValue?t.defaultValue:Array.isArray(e)?e[e.length-1]:e,t=[e,{},!1];return t.t=e,t.i18n={},t.ready=!1,t}o.options.react&&void 0!==o.options.react.wait&&oe("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const s={...pe,...o.options.react,...t},{useSuspense:l,keyPrefix:u}=s;let c=e||a||o.options&&o.options.defaultNS;c="string"==typeof c?[c]:c||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(c);const d=(o.isInitialized||o.initializedStoreOnce)&&c.every((e=>function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.languages&&t.languages.length?void 0!==t.options.ignoreJSONStructure?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}):function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=t.languages[0],i=!!t.options&&t.options.fallbackLng,a=t.languages[t.languages.length-1];if("cimode"===r.toLowerCase())return!0;const o=(e,n)=>{const r=t.services.backendConnector.state[`${e}|${n}`];return-1===r||2===r};return!(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!o(t.isLanguageChangingTo,e)||!t.hasResourceBundle(r,e)&&t.services.backendConnector.backend&&(!t.options.resources||t.options.partialBundledLanguages)&&(!o(r,e)||i&&!o(a,e)))}(e,t,n):(oe("i18n.languages were undefined or empty",t.languages),!0)}(e,o,s)));function h(){return o.getFixedT(t.lng||null,"fallback"===s.nsMode?c:c[0],u)}const[f,p]=n.useState(h);let g=c.join();t.lng&&(g=`${t.lng}${g}`);const m=((e,t)=>{const r=n.useRef();return n.useEffect((()=>{r.current=t?r.current:e}),[e,t]),r.current})(g),v=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=s;function r(){v.current&&p(h)}return v.current=!0,d||l||(t.lng?ue(o,t.lng,c,(()=>{v.current&&p(h)})):le(o,c,(()=>{v.current&&p(h)}))),d&&m&&m!==g&&v.current&&p(h),e&&o&&o.on(e,r),n&&o&&o.store.on(n,r),()=>{v.current=!1,e&&o&&e.split(" ").forEach((e=>o.off(e,r))),n&&o&&n.split(" ").forEach((e=>o.store.off(e,r)))}}),[o,g]);const y=n.useRef(!0);n.useEffect((()=>{v.current&&!y.current&&p(h),y.current=!1}),[o,u]);const b=[f,o,d];if(b.t=f,b.i18n=o,b.ready=d,d)return b;if(!d&&!l)return b;throw new Promise((e=>{t.lng?ue(o,t.lng,c,(()=>e())):le(o,c,(()=>e()))}))}function be(e){return be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},be(e)}function we(e){var t=function(e,t){if("object"!==be(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==be(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===be(t)?t:String(t)}function xe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,we(r.key),r)}}var Ee=[],Se=Ee.forEach,Te=Ee.slice;var ke=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Ce=function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+60*n*1e3)),r&&(i.domain=r),document.cookie=function(e,t,n){var r=n||{};r.path=r.path||"/";var i=encodeURIComponent(t),a="".concat(e,"=").concat(i);if(r.maxAge>0){var o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");a+="; Max-Age=".concat(Math.floor(o))}if(r.domain){if(!ke.test(r.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(r.domain)}if(r.path){if(!ke.test(r.path))throw new TypeError("option path is invalid");a+="; Path=".concat(r.path)}if(r.expires){if("function"!=typeof r.expires.toUTCString)throw new TypeError("option expires is invalid");a+="; Expires=".concat(r.expires.toUTCString())}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite)switch("string"==typeof r.sameSite?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return a}(e,encodeURIComponent(t),i)},Ae=function(e){for(var t="".concat(e,"="),n=document.cookie.split(";"),r=0;r<n.length;r++){for(var i=n[r];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return i.substring(t.length,i.length)}return null},Re={name:"cookie",lookup:function(e){var t;if(e.lookupCookie&&"undefined"!=typeof document){var n=Ae(e.lookupCookie);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupCookie&&"undefined"!=typeof document&&Ce(t.lookupCookie,e,t.cookieMinutes,t.cookieDomain,t.cookieOptions)}},_e={name:"querystring",lookup:function(e){var t;if("undefined"!=typeof window){var n=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(n=window.location.hash.substring(window.location.hash.indexOf("?")));for(var r=n.substring(1).split("&"),i=0;i<r.length;i++){var a=r[i].indexOf("=");if(a>0)r[i].substring(0,a)===e.lookupQuerystring&&(t=r[i].substring(a+1))}}return t}},Ie=null,De=function(){if(null!==Ie)return Ie;try{Ie="undefined"!==window&&null!==window.localStorage;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch(e){Ie=!1}return Ie},Fe={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&De()){var n=window.localStorage.getItem(e.lookupLocalStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&De()&&window.localStorage.setItem(t.lookupLocalStorage,e)}},Le=null,Me=function(){if(null!==Le)return Le;try{Le="undefined"!==window&&null!==window.sessionStorage;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch(e){Le=!1}return Le},Ne={name:"sessionStorage",lookup:function(e){var t;if(e.lookupSessionStorage&&Me()){var n=window.sessionStorage.getItem(e.lookupSessionStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&Me()&&window.sessionStorage.setItem(t.lookupSessionStorage,e)}},Oe={name:"navigator",lookup:function(e){var t=[];if("undefined"!=typeof navigator){if(navigator.languages)for(var n=0;n<navigator.languages.length;n++)t.push(navigator.languages[n]);navigator.userLanguage&&t.push(navigator.userLanguage),navigator.language&&t.push(navigator.language)}return t.length>0?t:void 0}},Pe={name:"htmlTag",lookup:function(e){var t,n=e.htmlTag||("undefined"!=typeof document?document.documentElement:null);return n&&"function"==typeof n.getAttribute&&(t=n.getAttribute("lang")),t}},Be={name:"path",lookup:function(e){var t;if("undefined"!=typeof window){var n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(n instanceof Array)if("number"==typeof e.lookupFromPathIndex){if("string"!=typeof n[e.lookupFromPathIndex])return;t=n[e.lookupFromPathIndex].replace("/","")}else t=n[0].replace("/","")}return t}},Ue={name:"subdomain",lookup:function(e){var t="number"==typeof e.lookupFromSubdomainIndex?e.lookupFromSubdomainIndex+1:1,n="undefined"!=typeof window&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(n)return n[t]}};var $e,je,Ge=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}var t,n,r;return t=e,n=[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=e||{languageUtils:{}},this.options=function(e){return Se.call(Te.call(arguments,1),(function(t){if(t)for(var n in t)void 0===e[n]&&(e[n]=t[n])})),e}(t,this.options||{},{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(e){return e}}),"string"==typeof this.options.convertDetectedLanguage&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(e){return e.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(Re),this.addDetector(_e),this.addDetector(Fe),this.addDetector(Ne),this.addDetector(Oe),this.addDetector(Pe),this.addDetector(Be),this.addDetector(Ue)}},{key:"addDetector",value:function(e){this.detectors[e.name]=e}},{key:"detect",value:function(e){var t=this;e||(e=this.options.order);var n=[];return e.forEach((function(e){if(t.detectors[e]){var r=t.detectors[e].lookup(t.options);r&&"string"==typeof r&&(r=[r]),r&&(n=n.concat(r))}})),n=n.map((function(e){return t.options.convertDetectedLanguage(e)})),this.services.languageUtils.getBestMatchFromCodes?n:n.length>0?n[0]:null}},{key:"cacheUserLanguage",value:function(e,t){var n=this;t||(t=this.options.caches),t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach((function(t){n.detectors[t]&&n.detectors[t].cacheUserLanguage(e,n.options)})))}}],n&&xe(t.prototype,n),r&&xe(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();Ge.type="languageDetector",function(e){e.NONE="NONE",e.ENROLL="ENROLL",e.IDENTIFY="IDENTIFY",e.VALIDATE="VALIDATE",e.VERIFY="VERIFY"}($e||($e={})),function(e){e.READY="READY",e.SUBMITTING="SUBMITTING",e.SUBMITTED="SUBMITTED",e.FAILED="FAILED"}(je||(je={}));var ze={prod:"https://api.idmission.com",demo:"https://apidemo.idmission.com"},qe=n.createContext({submit:function(){return g(void 0,void 0,void 0,(function(){return m(this,(function(e){return[2,null]}))}))},submissionStatus:je.READY,submissionRequest:null,submissionResponse:null,submissionEnvironment:"prod",idFrontImage:null,idBackImage:null,passportImage:null,selfieImage:null,signatureData:null,additionalDocuments:null,setIdFrontImage:function(){return null},setIdBackImage:function(){return null},setPassportImage:function(){return null},setSelfieImage:function(){return null},setSignatureData:function(){return null},setAdditionalDocuments:function(){return null},logIdFrontCaptureAttempt:function(){return null},logIdBackCaptureAttempt:function(){return null},logSelfieCaptureAttempt:function(){return null},checkLiveness:function(){return g(void 0,void 0,void 0,(function(){return m(this,(function(e){throw new Error("checkLiveness is not implemented")}))}))},retryLocationAccess:function(){return null}});function He(e,t){if(t)switch(function(e){var t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(window.atob(t).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""));return JSON.parse(n)}(t).iss){case"https://auth.idmission.com/auth/realms/identity":return ze.prod;case"https://demoauth.idmission.com/auth/realms/identity":return ze.demo}var n=ze[e];if(!n)throw new Error("unrecognized SubmissionEnvironment ".concat(e));return n}function Ve(e){var t={"Content-Type":"application/json",Origin:"*"};return e&&(t.Authorization="Bearer ".concat(e)),t}function We(e){return g(this,void 0,void 0,(function(){return m(this,(function(t){return[2,e.replace(/^data:image\/(png|jpeg);base64,/,"")]}))}))}function Ke(e){return e.replace(/^data:.*;base64,/,"")}function Ye(e){var t,n;return null!==(n=null===(t=e.match(/^(data:.*;base64),/))||void 0===t?void 0:t[1])&&void 0!==n?n:""}var Xe,Je=h.default.div(Xe||(Xe=y(["\n position: fixed;\n top: 0;\n left: 0;\n width: var(--app-width);\n height: calc(\n var(--app-height) - ","px\n );\n overflow-x: hidden;\n overflow-y: auto;\n font-family: Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,\n Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;\n\n &.flex {\n display: flex;\n }\n\n &.padded {\n box-sizing: border-box;\n padding: 16px 24px;\n }\n"],["\n position: fixed;\n top: 0;\n left: 0;\n width: var(--app-width);\n height: calc(\n var(--app-height) - ","px\n );\n overflow-x: hidden;\n overflow-y: auto;\n font-family: Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,\n Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;\n\n &.flex {\n display: flex;\n }\n\n &.padded {\n box-sizing: border-box;\n padding: 16px 24px;\n }\n"])),(function(e){var t=e.$heightOffset;return null!=t?t:0})),Ze=n.forwardRef((function(e,t){var r=e.children,i=e.className,a=e.heightOffset,o=void 0===a?0:a,s=e.style,l=e.onClick;return n.useEffect((function(){var e=function(){var e=document.documentElement;e.style.setProperty("--app-width","".concat(window.innerWidth,"px")),e.style.setProperty("--app-height","".concat(window.innerHeight,"px"))};return window.addEventListener("resize",e),e(),function(){window.removeEventListener("resize",e)}}),[]),u.default.createElement(Je,{ref:t,style:s,onClick:l,className:i,$heightOffset:o},r)}));Ze.displayName="PageContainer";var Qe,et,tt,nt,rt=h.default(Ze)(Qe||(Qe=y(["\n background: white;\n z-index: 10000;\n"],["\n background: white;\n z-index: 10000;\n"]))),it=h.default.div(et||(et=y(["\n text-align: center;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n padding: 25px;\n max-height: var(--app-height);\n height: 100%;\n box-sizing: border-box;\n"],["\n text-align: center;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n padding: 25px;\n max-height: var(--app-height);\n height: 100%;\n box-sizing: border-box;\n"]))),at=h.default.div(tt||(tt=y(["\n position: relative;\n display: flex;\n flex-grow: 1;\n padding-bottom: 25px;\n max-width: var(--app-width);\n max-height: var(--app-height);\n overflow: hidden;\n\n & > img {\n margin: 0 auto;\n width: max-content;\n max-width: 100%;\n max-height: 100%;\n aspect-ratio: initial;\n object-fit: contain;\n display: block;\n }\n"],["\n position: relative;\n display: flex;\n flex-grow: 1;\n padding-bottom: 25px;\n max-width: var(--app-width);\n max-height: var(--app-height);\n overflow: hidden;\n\n & > img {\n margin: 0 auto;\n width: max-content;\n max-width: 100%;\n max-height: 100%;\n aspect-ratio: initial;\n object-fit: contain;\n display: block;\n }\n"]))),ot=h.default.div(nt||(nt=y(["\n display: flex;\n margin: auto;\n\n & > div {\n max-height: calc(100vh - 320px);\n\n & > img {\n width: 100%;\n max-height: 100%;\n height: auto;\n object-fit: contain;\n }\n }\n"],["\n display: flex;\n margin: auto;\n\n & > div {\n max-height: calc(100vh - 320px);\n\n & > img {\n width: 100%;\n max-height: 100%;\n height: auto;\n object-fit: contain;\n }\n }\n"]))),st=function(){return st=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},st.apply(this,arguments)},lt={lines:12,length:7,width:5,radius:10,scale:1,corners:1,color:"#000",fadeColor:"transparent",animation:"spinner-line-fade-default",rotate:0,direction:1,speed:1,zIndex:2e9,className:"spinner",top:"50%",left:"50%",shadow:"0 0 1px transparent",position:"absolute"},ut=function(){function e(e){void 0===e&&(e={}),this.opts=st(st({},lt),e)}return e.prototype.spin=function(e){return this.stop(),this.el=document.createElement("div"),this.el.className=this.opts.className,this.el.setAttribute("role","progressbar"),ct(this.el,{position:this.opts.position,width:0,zIndex:this.opts.zIndex,left:this.opts.left,top:this.opts.top,transform:"scale("+this.opts.scale+")"}),e&&e.insertBefore(this.el,e.firstChild||null),function(e,t){var n=Math.round(t.corners*t.width*500)/1e3+"px",r="none";!0===t.shadow?r="0 2px 4px #000":"string"==typeof t.shadow&&(r=t.shadow);for(var i=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,n=[],r=0,i=e.split(",");r<i.length;r++){var a=i[r].match(t);if(null!==a){var o=+a[2],s=+a[5],l=a[4],u=a[7];0!==o||l||(l=u),0!==s||u||(u=l),l===u&&n.push({prefix:a[1]||"",x:o,y:s,xUnits:l,yUnits:u,end:a[8]})}}return n}(r),a=0;a<t.lines;a++){var o=~~(360/t.lines*a+t.rotate),s=ct(document.createElement("div"),{position:"absolute",top:-t.width/2+"px",width:t.length+t.width+"px",height:t.width+"px",background:dt(t.fadeColor,a),borderRadius:n,transformOrigin:"left",transform:"rotate("+o+"deg) translateX("+t.radius+"px)"}),l=a*t.direction/t.lines/t.speed;l-=1/t.speed;var u=ct(document.createElement("div"),{width:"100%",height:"100%",background:dt(t.color,a),borderRadius:n,boxShadow:ht(i,o),animation:1/t.speed+"s linear "+l+"s infinite "+t.animation});s.appendChild(u),e.appendChild(s)}}(this.el,this.opts),this},e.prototype.stop=function(){return this.el&&("undefined"!=typeof requestAnimationFrame?cancelAnimationFrame(this.animateId):clearTimeout(this.animateId),this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=void 0),this},e}();function ct(e,t){for(var n in t)e.style[n]=t[n];return e}function dt(e,t){return"string"==typeof e?e:e[t%e.length]}function ht(e,t){for(var n=[],r=0,i=e;r<i.length;r++){var a=i[r],o=ft(a.x,a.y,t);n.push(a.prefix+o[0]+a.xUnits+" "+o[1]+a.yUnits+a.end)}return n.join(", ")}function ft(e,t,n){var r=n*Math.PI/180,i=Math.sin(r),a=Math.cos(r);return[Math.round(1e3*(e*a+t*i))/1e3,Math.round(1e3*(-e*i+t*a))/1e3]}function pt(e){if(void 0!==e){if(e.classList.contains("ladda-button")||e.classList.add("ladda-button"),e.hasAttribute("data-style")||e.setAttribute("data-style","expand-right"),!e.querySelector(".ladda-label")){var t=document.createElement("span");t.className="ladda-label",function(e,t){var n=document.createRange();n.selectNodeContents(e),n.surroundContents(t),e.appendChild(t)}(e,t)}var n,r,i=e.querySelector(".ladda-spinner");i||((i=document.createElement("span")).className="ladda-spinner"),e.appendChild(i);var a={start:function(){return r||(r=function(e){var t,n,r=e.offsetHeight;0===r&&(r=parseFloat(window.getComputedStyle(e).height));r>32&&(r*=.8);e.hasAttribute("data-spinner-size")&&(r=parseInt(e.getAttribute("data-spinner-size"),10));e.hasAttribute("data-spinner-color")&&(t=e.getAttribute("data-spinner-color"));e.hasAttribute("data-spinner-lines")&&(n=parseInt(e.getAttribute("data-spinner-lines"),10));var i=.2*r;return new ut({color:t||"#fff",lines:n||12,radius:i,length:.6*i,width:i<7?2:3,animation:"ladda-spinner-line-fade",zIndex:"auto",top:"auto",left:"auto",className:""})}(e)),e.disabled=!0,e.setAttribute("data-loading",""),clearTimeout(n),r.spin(i),this.setProgress(0),this},startAfter:function(e){return clearTimeout(n),n=setTimeout((function(){a.start()}),e),this},stop:function(){return a.isLoading()&&(e.disabled=!1,e.removeAttribute("data-loading")),clearTimeout(n),r&&(n=setTimeout((function(){r.stop()}),1e3)),this},toggle:function(){return this.isLoading()?this.stop():this.start()},setProgress:function(t){t=Math.max(Math.min(t,1),0);var n=e.querySelector(".ladda-progress");0===t&&n&&n.parentNode?n.parentNode.removeChild(n):(n||((n=document.createElement("div")).className="ladda-progress",e.appendChild(n)),n.style.width=(t||0)*e.offsetWidth+"px")},isLoading:function(){return e.hasAttribute("data-loading")},remove:function(){clearTimeout(n),e.disabled=!1,e.removeAttribute("data-loading"),r&&(r.stop(),r=null)}};return a}console.warn("Ladda button target must be defined.")}var gt,mt,vt=function(e){var t=e.accessBlockedImageUrl,r=ye().t,i=n.useContext(qe).retryLocationAccess,a=n.useRef(null),o=n.useRef(null);return n.useEffect((function(){var e,t;if(a.current)return o.current=pt(a.current),null===(e=o.current)||void 0===e||e.start(),null===(t=o.current)||void 0===t||t.setProgress(100),o.current.stop(),function(){var e;null===(e=o.current)||void 0===e||e.remove()}}),[]),u.default.createElement(rt,null,u.default.createElement("div",{style:{display:"flex",height:"100%"}},u.default.createElement(it,{style:{maxWidth:500,height:"auto",margin:"auto"}},u.default.createElement(at,{style:{flexGrow:0}},u.default.createElement("img",{src:t,alt:""})),u.default.createElement("h3",null,r("Your location access is disabled")),u.default.createElement("p",{style:{lineHeight:1.5,marginBottom:50}},r("This application requires access to your location to continue. Please accept the permission once prompted by the browser. If the browser does not prompt for location permissions, you must go to settings and provide location access to the current browser.")),u.default.createElement("button",{ref:a,className:"ladda-button","data-style":"expand-right",disabled:!1,style:{width:200,marginLeft:"auto",marginRight:"auto"},onClick:function(){i()}},u.default.createElement("span",{className:"ladda-label"},r("Retry"))))))},yt=function(e){var t=e.action,r=e.children,i=e.url,a=e.environment,o=void 0===a?"prod":a,s=e.token,l=e.enrollmentId,c=e.geolocationEnabled,d=void 0===c||c,h=e.geolocationRequired,f=void 0!==h&&h,y=e.onBeforeSubmit,b=e.onResponseReceived,w=e.onRequestFailure,x=n.useState(je.READY),E=x[0],S=x[1],T=n.useState(null),k=T[0],C=T[1],A=n.useState(null),R=A[0],_=A[1],I=n.useState(null),D=I[0],F=I[1],L=n.useState(null),M=L[0],N=L[1],O=n.useState(null),P=O[0],B=O[1],U=n.useState(null),$=U[0],j=U[1],G=n.useState(null),z=G[0],q=G[1],H=n.useState(null),V=H[0],W=H[1],K=n.useState(null),Y=K[0],X=K[1],J=n.useState(0),Z=J[0],Q=J[1],ee=n.useState(!1),te=ee[0],ne=ee[1],re=n.useState([]),ie=re[0],ae=re[1],oe=n.useState([]),se=oe[0],le=oe[1],ue=n.useState([]),ce=ue[0],de=ue[1],he=n.useCallback((function(e){ae((function(t){return v(v([],t,!0),[e],!1)}))}),[]),fe=n.useCallback((function(e){le((function(t){return v(v([],t,!0),[e],!1)}))}),[]),pe=n.useCallback((function(e){de((function(t){return v(v([],t,!0),[e],!1)}))}),[]),ge=n.useCallback((function(){return g(void 0,void 0,void 0,(function(){var e,n,r,a,u,c,d,h,f;return m(this,(function(g){switch(g.label){case 0:if(t===$e.NONE)return e={status:{statusCode:"000"},resultData:{}},S(je.SUBMITTED),_(e),[2,e];S(je.SUBMITTING),g.label=1;case 1:return g.trys.push([1,6,,7]),n={securityData:{userName:"",password:"",merchantId:0},customerData:{idData:{idType:"NSP",idCountry:"NSP",idState:""}},additionalData:{uniqueRequestId:(new Date).getTime().toString(),manualReviewRequired:"N",bypassAgeValidation:"N",deDuplicationRequired:"N",bypassNameMatching:"Y",postDataAPIRequired:"N",sendInputImagesInPost:"N",sendProcessedImagesInPost:"N",needImmediateResponse:"N",deduplicationSynchronous:"N",verifyDataWithHost:"N",idBackImageRequired:"N",stripSpecialCharacters:"Y",idImageResolutionCheck:"Y"}},D&&(n.customerData.idData.idImageFront=D),M&&(n.customerData.idData.idImageBack=M),P&&(n.customerData.idData.idImageFront=P),$&&(t===$e.IDENTIFY?n.biometricData={selfie:$}:n.customerData.biometricData={selfie:$}),l&&(n.customerData.personalData={uniqueNumber:l}),z&&(n.customerData.signatureData={signatureImage:z.fileContent}),V&&(n.customerData.additionalDocuments=V.map((function(e){return p(p({},e),{additionalDocument:JSON.stringify(p(p({},e.additionalDocument),{uniqueId:n.additionalData.uniqueRequestId}))})}))),r={selfie:ce,front:ie,back:se,isRealIDCheckRequired:"false",sdkVersion:"WebSDK_9.5.13.2.0",Resolution:"".concat(window.innerWidth," x ").concat(window.innerHeight)},(a=window.platform)&&(r.os=a.os.family,r.osVersion=a.os.version,r.browserVersion="".concat(a.name," ").concat(a.version)),Y&&(r.GeoLocation=JSON.stringify(Y)),n.additionalData.metadata=JSON.stringify(r),y?[4,y(n)]:[3,3];case 2:(u=g.sent())&&(n=u),g.label=3;case 3:return c=i||He(o,s),d=function(e,t,n,r){var i=r?"v4":"v3";switch(e){case $e.ENROLL:return"/".concat(i,t?"/customer/enroll":"/customer/enroll-biometrics");case $e.IDENTIFY:return"/".concat(i,"/customer/identify");case $e.VALIDATE:return"/".concat(i,n?"/customer/validate-id-match-face":"/customer/validate-id");case $e.VERIFY:return"/".concat(i,"/customer/verify");default:throw new Error("unrecognized SubmissionAction ".concat(e))}}(t,!!(D||M||P),!!$,!!s),[4,fetch(c+d,{method:"POST",headers:Ve(s),body:JSON.stringify(n)})];case 4:return[4,g.sent().json()];case 5:return h=g.sent(),C(n),_(h),S(je.SUBMITTED),null==b||b(h),[2,h];case 6:return f=g.sent(),S(je.FAILED),null==w||w(f),[2,null];case 7:return[2]}}))}))}),[t,V,l,o,Y,se,M,ie,D,y,w,b,P,ce,$,z,s,i]),me=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a,l,u,c;return m(this,(function(d){switch(d.label){case 0:return l={securityData:{userName:"",password:"",merchantId:0}},u={},c={},[4,We(e)];case 1:return l.customerData=(u.biometricData=(c.selfie=d.sent(),c),u),l.additionalData={uniqueRequestId:(new Date).getTime().toString(),stripSpecialCharacters:"Y",estimateAge:"N",predictGender:"N"},t=l,n=i||He(o,s),r="/".concat(!!s?"v4":"v3","/customer/live-check"),[4,fetch(n+r,{method:"POST",headers:Ve(s),body:JSON.stringify(t)})];case 2:return[4,d.sent().json()];case 3:return a=d.sent(),_(a),[2,a]}}))}))}),[o,s,i]),ve=n.useCallback((function(){Q((function(e){return e+1}))}),[]);return n.useEffect((function(){d&&(console.log("making geolocation attempt",Z),navigator.geolocation.getCurrentPosition((function(e){X(e),ne(!1)}),(function(e){if(1!==e.code)throw new Error(e.message);ne(!0)})))}),[Z,d,f]),u.default.createElement(qe.Provider,{value:{submit:ge,submissionStatus:E,submissionRequest:k,submissionResponse:R,submissionEnvironment:o,idFrontImage:D,idBackImage:M,passportImage:P,selfieImage:$,signatureData:z,additionalDocuments:V,setIdFrontImage:F,setIdBackImage:N,setPassportImage:B,setSelfieImage:j,setSignatureData:q,setAdditionalDocuments:W,logIdFrontCaptureAttempt:he,logIdBackCaptureAttempt:fe,logSelfieCaptureAttempt:pe,checkLiveness:me,retryLocationAccess:ve}},f&&te?u.default.createElement(vt,null):r)};function bt(e){return g(this,void 0,void 0,(function(){var t,n,r,i,a,o;return m(this,(function(s){switch(s.label){case 0:return mt?[2,mt]:[4,f.loadGraphModel(e)];case 1:return mt=s.sent(),[4,f.ready()];case 2:return s.sent(),t=f.zeros([448,448,3]),n=f.cast(t,"int32"),r=f.tensor4d(Array.from(n.dataSync()),[1,448,448,3]),i=f.cast(r,"int32"),o=(a=f).dispose,[4,mt.executeAsync(i)];case 3:return o.apply(a,[s.sent()]),n.dispose(),i.dispose(),r.dispose(),f.dispose(t),[2,mt]}}))}))}!function(e){e.NONE="NONE",e.ID_CARD="ID_CARD",e.ID_CARD_FRONT="ID_CARD_FRONT",e.ID_CARD_BACK="ID_CARD_BACK",e.PASSPORT="PASSPORT"}(gt||(gt={}));var wt={1:"Document",2:"MRZ",3:"PDF417",4:"Primary face",5:"Secondary face",6:"Glare",7:"Punch Hole",8:"Passport Page"};function xt(e,t,n){return e[t]?e[t][0]?e[t][0][n]:e[t][n]:"contentBoxSize"===t?e.contentRect["inlineSize"===n?"width":"height"]:void 0}function Et(e){void 0===e&&(e={});var t=e.onResize,r=n.useRef(void 0);r.current=t;var i=e.round||Math.round,a=n.useRef(),o=n.useState({width:void 0,height:void 0}),s=o[0],l=o[1],u=n.useRef(!1);n.useEffect((function(){return u.current=!1,function(){u.current=!0}}),[]);var c=n.useRef({width:void 0,height:void 0}),d=function(e,t){var r=n.useRef(null),i=n.useRef(null);i.current=t;var a=n.useRef(null);n.useEffect((function(){o()}));var o=n.useCallback((function(){var t=i.current,n=a.current||(t?t instanceof Element?t:t.current:null);r.current&&r.current.element===n&&r.current.subscriber===e||(r.current&&r.current.cleanup&&r.current.cleanup(),r.current={element:n,subscriber:e,cleanup:n?e(n):void 0})}),[e]);return n.useEffect((function(){return function(){r.current&&r.current.cleanup&&(r.current.cleanup(),r.current=null)}}),[]),n.useCallback((function(e){a.current=e,o()}),[o])}(n.useCallback((function(t){return a.current&&a.current.box===e.box&&a.current.round===i||(a.current={box:e.box,round:i,instance:new ResizeObserver((function(t){var n=t[0],a="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",o=xt(n,a,"inlineSize"),s=xt(n,a,"blockSize"),d=o?i(o):void 0,h=s?i(s):void 0;if(c.current.width!==d||c.current.height!==h){var f={width:d,height:h};c.current.width=d,c.current.height=h,r.current?r.current(f):u.current||l(f)}}))}),a.current.instance.observe(t,{box:e.box}),function(){a.current&&a.current.instance.unobserve(t)}}),[e.box,i]),e.ref);return n.useMemo((function(){return{ref:d,width:s.width,height:s.height}}),[d,s.width,s.height])}window.OffscreenCanvas||(window.OffscreenCanvas=function(e,t){var n=this;return this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t,this.canvas.convertToBlob=function(){return new Promise((function(e){n.canvas.toBlob(e)}))},this.canvas});var St=n.createContext({orientation:"landscape",wrapperWidth:1,wrapperHeight:1,wrapperAspectRatio:0,imageAspectRatio:0,wrapperRef:null,setDimensions:function(){return null},onImageLoaded:function(){return null}});let Tt;function kt(e){if(void 0!==Tt)return Tt;if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){return e.userAgentData&&e.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}var Ct=function(e){var t=e.width,r=void 0===t?0:t,i=e.height,a=void 0===i?0:i,o=e.padding,s=void 0===o?kt()?0:50:o,l=e.borderWidth,c=void 0===l?4:l,d=e.borderColor,h=void 0===d?"white":d,f=e.isMirrored,g=void 0!==f&&f,m=e.instruction,v=void 0===m?"":m,y=e.portraitGuidesImageUrl,b=e.landscapeGuidesImageUrl,w=e.onClick,x=n.useContext(St),E=x.orientation,S=x.wrapperRef,T=x.wrapperWidth,k=x.wrapperHeight,C=x.imageAspectRatio,A=x.wrapperAspectRatio,R=x.onImageLoaded,_=x.setDimensions;0==r&&(r=T),0==a&&(a=k),n.useEffect((function(){_({width:r,height:a})}),[a,_,r]);var I={height:k-2*s-2*c};return C>=A&&(I={width:T-2*s-2*c}),u.default.createElement(Ze,{ref:S,onClick:w,style:{zIndex:1e3}},u.default.createElement("div",{style:{display:"flex",flexFlow:"column nowrap",height:"100%"}},u.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",flexGrow:1,textAlign:"center",color:"white",display:"flex",flexDirection:"column",justifyContent:"end"}},""!==v&&u.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12}},v)),u.default.createElement("div",{style:{position:"relative",display:"flex",flexFlow:"row nowrap",alignItems:"center",justifyItems:"center",maxWidth:"calc(100%)",maxHeight:"calc(100% - ".concat(2*s,"px - ").concat(2*c,"px)")}},u.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:s,flexGrow:1}}),u.default.createElement("div",{style:{transform:g?"scaleX(-1)":"",border:"".concat(c,"px solid ").concat(h),maxWidth:"calc(100% - ".concat(2*s,"px - ").concat(2*c,"px)"),maxHeight:a-2*s-2*c}},u.default.createElement("img",{src:"portrait"===E?y:b,alt:"",onLoad:R,style:p({},I)})),u.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:s,flexGrow:1}})),u.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",flexGrow:1,textAlign:"center",color:"white",display:"flex",flexDirection:"column",justifyContent:"end"}},""!==v&&u.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12,opacity:0}},v))))};function At(e){return g(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return"BarcodeDetector"in window?(t=new BarcodeDetector({formats:["pdf417"]}),console.log("this is a real native result!"),[4,t.detect(e)]):[2,[]];case 1:return[2,n.sent()]}}))}))}function Rt(e,t){return void 0===t&&(t=!1),g(this,void 0,void 0,(function(){var n,r,i,a,o,s,l,u,c;return m(this,(function(d){switch(d.label){case 0:return[4,new Promise((function(o){if(i=e.naturalWidth,a=e.naturalHeight,n=document.createElement("canvas"),!(r=n.getContext("2d")))return[];if(t){console.log("rotating!!"),n.width=a,n.height=i,r.setTransform(0,1,-1,0,n.width,0),r.drawImage(e,0,0,i,a);var s=new Image;s.width=n.width,s.height=n.height,s.onload=function(){o(s)},n.toBlob((function(e){e&&(s.src=URL.createObjectURL(e))}))}else r.drawImage(e,0,0,n.width,n.height),o(e)}))];case 1:return o=d.sent(),s=new ZXing.BitmapLuminanceSource(r,o),l=new ZXing.Common.HybridBinarizer(s),u=new ZXing.BinaryBitmap(l),c=ZXing.PDF417.PDF417Reader.decode(u,null,!1),r.clearRect(0,0,n.width,n.height),n.remove(),[2,c]}}))}))}function _t(){return"BarcodeDetector"in window}function It(e,t){var n=this;return new Promise((function(r){var i=new Image;i.onload=function(){return g(n,void 0,void 0,(function(){var e,n,a,o;return m(this,(function(s){switch(s.label){case 0:return _t()?[4,At(i)]:[3,2];case 1:return n=s.sent(),console.log("native result",n,"".concat(i.width,"x").concat(i.height)),r(n.length>0?p(p({},n[0]),{Source:"native"}):null),[3,4];case 2:return e=(null!==(a=null==t?void 0:t[2])&&void 0!==a?a:0)<(null!==(o=null==t?void 0:t[3])&&void 0!==o?o:0),[4,Rt(i,e)];case 3:n=s.sent(),console.log("zxing result",n),r(n.length>0?p(p({},n[0]),{Source:"zxing"}):null),s.label=4;case 4:return[2]}}))}))},i.src=URL.createObjectURL(e)}))}var Dt,Ft=n.createContext({videoRef:{current:null},videoLoaded:!1,cameraRef:{current:null},cameraReady:!1,cameraAccessDenied:!1,retryCameraAccess:function(){return null},releaseCameraAccess:function(){return null},iphoneContinuityCameraAvailable:!1,iphoneContinuityCameraAllowed:!0,setIphoneContinuityCameraAllowed:function(){return null},grabFrame:function(){return Promise.resolve(null)},takePhoto:function(){return Promise.resolve(null)},setVideoLoaded:function(){return null}});function Lt(e){return g(this,void 0,void 0,(function(){var t,n,r,i,a,o,s,l,u;return m(this,(function(c){switch(c.label){case 0:return Dt?[2,Dt]:[4,f.loadLayersModel(e)];case 1:return Dt=c.sent(),[4,f.ready()];case 2:return c.sent(),t=f.zeros([448,448,3]),n=f.cast(t,"int32"),a=(i=f).tensor4d,s=(o=Array).from,[4,n.data()];case 3:return r=a.apply(i,[s.apply(o,[c.sent()]),[1,448,448,3]]),l=f.cast(r,"int32"),[4,Dt.predict(l)];case 4:return[4,(u=c.sent()).data()];case 5:return c.sent(),f.dispose(u),n.dispose(),l.dispose(),r.dispose(),f.dispose(t),[2,Dt]}}))}))}class Mt{refCount(e){return Nt("refCount")}incRef(e){return Nt("incRef")}timerAvailable(){return!0}time(e){return Nt("time")}read(e){return Nt("read")}readSync(e){return Nt("readSync")}readToGPU(e,t){return Nt("readToGPU")}numDataIds(){return Nt("numDataIds")}disposeData(e,t){return Nt("disposeData")}write(e,t,n){return Nt("write")}move(e,t,n,r,i){return Nt("move")}createTensorFromGPUData(e,t,n){return Nt("createTensorFromGPUData")}memory(){return Nt("memory")}floatPrecision(){return Nt("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return Nt("dispose")}}function Nt(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}function Ot(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function Pt(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function Bt(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ut(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function $t(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error(`Unknown dtype ${e}`)}function jt(e){return"string"==typeof e||e instanceof String}function Gt(e){return Array.isArray(e)?Gt(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":"number"==typeof e?"float32":jt(e)?"string":function(e){return"boolean"==typeof e}(e)?"bool":"float32"}function zt(e){return!!(e&&e.constructor&&e.call&&e.apply)}function qt(e){const t=e.length;if(t<2)return[];const n=new Array(t-1);n[t-2]=e[t-1];for(let r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function Ht(e,t,n,r=!1){const i=new Array;if(1===t.length){const a=t[0]*(r?2:1);for(let t=0;t<a;t++)i[t]=n[e+t]}else{const a=t[0],o=t.slice(1),s=o.reduce(((e,t)=>e*t))*(r?2:1);for(let t=0;t<a;t++)i[t]=Ht(e+t*s,o,n,r)}return i}function Vt(e,t,n=!1){if(0===e.length)return t[0];const r=e.reduce(((e,t)=>e*t))*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return Ht(0,e,t,n)}function Wt(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error(`Unknown data type ${t}`)}function Kt(e){e.forEach((t=>{Ot(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function Yt(e){return e&&e.then&&"function"==typeof e.then}const Xt="tfjsflags";class Jt{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Zt,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&(Qt().getBool("IS_TEST")||Qt().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){const t=this.urlFlags[e];Qt().getBool("IS_TEST")||Qt().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if(Yt(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getString(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;const e=this.getQueryParams(this.global.location.search);if(Xt in e){e[Xt].split(",").forEach((e=>{const[t,n]=e.split(":");this.urlFlags[t]=function(e,t){const n=t.toLowerCase();return"true"===n||"false"===n?"true"===n:""+ +n===n?+n:t}(0,n)}))}}}function Zt(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("=")))),t}function Qt(){return tn}let en,tn=null;function nn(){if(null==en){let e;if("undefined"!=typeof window)e=window;else if("undefined"!=typeof global)e=global;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}en=e}return en}function rn(e,t){const n=function(){const e=nn();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const r=t();return n.set(e,r),n.get(e)}}const an="Add",on="Cast",sn="Identity";function ln(...e){Qt().getBool("IS_TEST")||Qt().getBool("PROD")||console.warn(...e)}const un=rn("kernelRegistry",(()=>new Map)),cn=rn("gradRegistry",(()=>new Map));function dn(e,t){const n=function(e,t){return`${t}_${e}`}(e,t);return un.get(n)}function hn(e){return cn.get(e)}function fn(e){const t=un.entries(),n=[];for(;;){const{done:r,value:i}=t.next();if(r)break;const[a,o]=i,[s]=a.split("_");s===e&&n.push(o)}return n}function pn(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}function gn(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=bn(e)),Qt().getBool("DEBUG")&&function(e,t){for(let n=0;n<e.length;n++){const r=e[n];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${t} being uploaded contains ${r}.`)}}(e,t),function(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){const t=new Uint8Array(e.length);for(let n=0;n<t.length;++n)0!==Math.round(e[n])&&(t[n]=1);return t}throw new Error(`Unknown data type ${t}`)}function mn(){return Qt().platform.now()}function vn(e,t="utf-8"){return t=t||"utf-8",Qt().platform.decode(e,t)}function yn(e){return null!=Qt().platform.isTypedArray?Qt().platform.isTypedArray(e):pn(e)}function bn(e,t=[],n=!1){if(null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||Yt(e)||null==e||yn(e)&&n)t.push(e);else if(Array.isArray(e)||yn(e))for(let r=0;r<e.length;++r)bn(e[r],t,n);else{let r=-1;for(const t of Object.keys(e))/^([1-9]+[0-9]*|0)$/.test(t)&&(r=Math.max(r,Number(t)));for(let i=0;i<=r;i++)bn(e[i],t,n)}return t}class wn{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new En)}profileKernel(e,t,n){let r;const i=()=>{r=n()};let a;const o=mn();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(i);else{i();for(const e of r)e.dataSync();a=Promise.resolve({kernelMs:mn()-o})}if(Qt().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<r.length;t++){const n=r[t];n.data().then((t=>{xn(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:a.then((e=>e.kernelMs)),extraInfo:a.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:i,extraInfo:a}=e;n.forEach((e=>{Promise.all([e.data(),r,a]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],i,n[2])}))}))}}function xn(e,t,n){if("float32"!==t)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(isNaN(r)||!isFinite(r))return console.warn(`Found ${r} in the result of '${n}'`),!0}return!1}class En{logKernelProfile(e,t,n,r,i,a){const o="number"==typeof r?Ut(`${r}ms`,9):r.error,s=Ut(e,25),l=t.rank,u=t.size,c=Ut(t.shape.toString(),14);let d="";for(const e in i){const n=i[e];if(null!=n){const r=n.shape||t.shape,i=r.length;d+=`${e}: ${i}D ${i>0?r:""} `}}console.log(`%c${s}\t%c${o}\t%c${l}D ${c}\t%c${u}\t%c${d}\t%c${a}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}const Sn=20,Tn=3,kn=7;function Cn(e,t,n,r){const i=qt(t),a=function(e,t,n,r){const i=Pt(t),a=r[r.length-1],o=new Array(a).fill(0),s=t.length,l="complex64"===n?In(e):e;if(s>1)for(let e=0;e<i/a;e++){const t=e*a;for(let e=0;e<a;e++)o[e]=Math.max(o[e],An(l[t+e],0,n).length)}return o}(e,t,n,i),o=t.length,s=_n(e,t,n,i,a),l=["Tensor"];return r&&(l.push(` dtype: ${n}`),l.push(` rank: ${o}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(s.map((e=>" "+e)).join("\n")),l.join("\n")}function An(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(kn))} + ${parseFloat(e[1].toFixed(kn))}j`:jt(e)?`'${e}'`:"bool"===n?Rn(e):parseFloat(e.toFixed(kn)).toString(),Ut(r,t)}function Rn(e){return 0===e?"false":"true"}function _n(e,t,n,r,i,a=!0){const o="complex64"===n?2:1,s=t[0],l=t.length;if(0===l){if("complex64"===n){return[An(In(e)[0],0,n)]}return"bool"===n?[Rn(e[0])]:[e[0].toString()]}if(1===l){if(s>Sn){let t=Array.from(e.slice(0,Tn*o)),r=Array.from(e.slice((s-Tn)*o,s*o));return"complex64"===n&&(t=In(t),r=In(r)),["["+t.map(((e,t)=>An(e,i[t],n))).join(", ")+", ..., "+r.map(((e,t)=>An(e,i[s-Tn+t],n))).join(", ")+"]"]}return["["+("complex64"===n?In(e):Array.from(e)).map(((e,t)=>An(e,i[t],n))).join(", ")+"]"]}const u=t.slice(1),c=r.slice(1),d=r[0]*o,h=[];if(s>Sn){for(let t=0;t<Tn;t++){const r=t*d;h.push(..._n(e.slice(r,r+d),u,n,c,i,!1))}h.push("...");for(let t=s-Tn;t<s;t++){const r=t*d;h.push(..._n(e.slice(r,r+d),u,n,c,i,t===s-1))}}else for(let t=0;t<s;t++){const r=t*d;h.push(..._n(e.slice(r,r+d),u,n,c,i,t===s-1))}const f=2===l?",":"";h[0]="["+(s>0?h[0]+f:"");for(let e=1;e<h.length-1;e++)h[e]=" "+h[e]+f;let p=",\n";for(let e=2;e<l;e++)p+="\n";return h[h.length-1]=" "+h[h.length-1]+"]"+(a?"":p),h}function In(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}class Dn{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=Pt(e),null!=n){const e=n.length;Ot(e===this.size,(()=>`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`))}if("complex64"===t)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||function(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}(t,this.size),this.strides=qt(e)}set(e,...t){0===t.length&&(t=[0]),Ot(t.length===this.rank,(()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`));const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t]){throw new Error(`Requested out of range element at ${e}. Buffer shape=${this.shape}`)}t++}let n=e[e.length-1];for(let t=0;t<e.length-1;++t)n+=this.strides[t]*e[t];return this.values[n]}locToIndex(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];let t=e[e.length-1];for(let n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t}indexToLoc(e){if(0===this.rank)return[];if(1===this.rank)return[e];const t=new Array(this.shape.length);for(let n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return Fn().makeTensor(this.values,this.shape,this.dtype)}}let Fn=null,Ln=null;class Mn{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=Pt(e),this.strides=qt(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const e=await this.data();return Ln.buffer(this.shape,this.dtype,e)}bufferSync(){return Ln.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return Vt(this.shape,e,"complex64"===this.dtype)}arraySync(){return Vt(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=Fn().read(this.dataId);if("string"===this.dtype){const t=await e;try{return t.map((e=>vn(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataToGPU(e){return this.throwIfDisposed(),Fn().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Fn().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>vn(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();const e=await Fn().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Fn().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Ln.print(this,e)}clone(){return this.throwIfDisposed(),Ln.clone(this)}toString(e=!1){return Cn(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Ln.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Fn().makeVariable(this,e,t,n)}}Object.defineProperty(Mn,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),rn("Tensor",(()=>Mn));class Nn extends Mn{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!Bt(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Fn().disposeTensor(this),this.dataId=e.dataId,Fn().incRef(this,null)}dispose(){Fn().disposeVariable(this),this.isDisposedInternal=!0}}var On,Pn,Bn,Un,$n;Object.defineProperty(Nn,Symbol.hasInstance,{value:e=>e instanceof Mn&&null!=e.assign&&e.assign instanceof Function}),function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"}(On||(On={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(Pn||(Pn={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(Bn||(Bn={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(Un||(Un={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}($n||($n={}));const jn={float32:Un,int32:Pn,bool:Bn,complex64:$n};function Gn(e){return null!=e&&"object"==typeof e&&"texture"in e&&e.texture instanceof WebGLTexture}function zn(e){return"undefined"!=typeof GPUBuffer&&null!=e&&"object"==typeof e&&"buffer"in e&&e.buffer instanceof GPUBuffer}function qn(e,t){if(e.dtype===t.dtype)return[e,t];const n=function(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return jn[e][t]}(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function Hn(e){const t=[];return Vn(e,t,new Set),t}function Vn(e,t,n){if(null==e)return;if(e instanceof Mn)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const i=e;for(const e in i){const r=i[e];n.has(r)||(n.add(r),Vn(r,t,n))}}function Wn(e){return null!=e.kernelName}class Kn{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((e=>e.name))))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class Yn{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Kn}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t];if(await this.initializeBackend(n).success)return void await this.setBackend(n)}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;{const{asyncInit:t}=this.initializeBackend(e);if(t)return null}}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,n=1){return e in this.registryFactory?(ln(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}async setBackend(e){if(null==this.registryFactory[e])throw new Error(`Backend name '${e}' not found in registry`);if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;const{success:t,asyncInit:n}=this.initializeBackend(e);if(!(n?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new wn(this.backendInstance),!0}setupRegisteredKernels(){fn(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){fn(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof Mt||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then((n=>!(t<this.pendingBackendInitId)&&(this.registry[e]=n,this.pendingBackendInit=null,!0))).catch((n=>(t<this.pendingBackendInitId||(this.pendingBackendInit=null,ln(`Initialization of backend ${e} failed`),ln(n.stack||n.message)),!1)));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(t){return ln(`Initialization of backend ${e} failed`),ln(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t],{success:r,asyncInit:i}=this.initializeBackend(n);if(i||r)return{name:n,asyncInit:i}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const n=this.state.tensorInfo.get(t),r=n.backend,i=this.readSync(t),a=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,i,n.shape,n.dtype,a),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n,r=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");r=e}return this.scopedRun((()=>this.startScope(r)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return Yn.nextTensorId++}nextVariableId(){return Yn.nextVariableId++}clone(e){const t=Jn.runKernel(sn,{x:e});return this.addTapeNode(this.state.activeScope.name,{x:e},[t],(e=>({x:()=>Jn.runKernel(on,{x:e},{dtype:"float32"})})),[],{}),t}runKernel(e,t,n){if(!(null!=dn(e,this.backendName)))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const r=this.backend.numDataIds();let i=0;n.forEach((e=>{i+="complex64"===e.dtype?3:1}));const a=r-t-i-this.state.numDataMovesStack[this.state.numDataMovesStack.length-1];if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),i=this.state.numBytes,a=this.state.numTensors;let o,s;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);const l=Wn(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(Wn(e)){const{kernelName:t,inputs:i,attrs:a}=e,l=dn(t,this.backendName);Ot(null!=l,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),o=()=>{const e=this.backend.numDataIds();s=l.kernelFunc({inputs:i,attrs:a,backend:this.backend});const o=Array.isArray(s)?s:[s];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,o);const u=o.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(r){const e=this.getTensorsForGradient(t,i,u);n=this.saveTensorsForBackwardMode(e)}return u}}else{const{forwardFunc:t}=e,i=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};o=()=>{const e=this.backend.numDataIds();s=this.tidy((()=>t(this.backend,i)));const n=Array.isArray(s)?s:[s];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,e,n),n}}const{inputs:u,attrs:c}=e,d=Wn(e)?null:e.backwardsFunc;let h;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(h=this.profiler.profileKernel(l,u,(()=>o())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(h),t=h.outputs):t=o()})),r&&this.addTapeNode(l,u,t,d,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-i,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-a,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map((e=>null!=u[e]?u[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:h.timeMs,extraInfo:h.extraInfo}),Array.isArray(s)?t:t[0]}saveTensorsForBackwardMode(e){return e.map((e=>this.keep(this.clone(e))))}getTensorsForGradient(e,t,n){const r=hn(e);if(null!=r){const e=r.inputsToSave||[],i=r.outputsToSave||[];let a;r.saveAllInputs?(Ot(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),a=Object.keys(t).map((e=>t[e]))):a=e.map((e=>t[e]));const o=n.filter(((e,t)=>i[t]));return a.concat(o)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");r=r||this.backend;let i=e;"string"===(n=n||"float32")&&jt(e[0])&&(i=e.map((e=>function(e,t="utf-8"){return t=t||"utf-8",Qt().platform.encode(e,t)}(e))));const a=r.write(i,t,n),o=new Mn(t,n,a,this.nextTensorId());if(this.trackTensor(o,r),"string"===n){const e=this.state.tensorInfo.get(a),t=function(e){if(null==e)return 0;let t=0;return e.forEach((e=>t+=e.length)),t}(i);this.state.numBytes+=t-e.bytes,e.bytes=t}return o}makeTensorFromDataId(e,t,n,r){return this.makeTensorFromTensorInfo({dataId:e,shape:t,dtype:n=n||"float32"},r)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:r,dtype:i}=e,a=new Mn(r,i,n,this.nextTensorId());return this.trackTensor(a,t),a}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const i=new Nn(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[i.name])throw new Error(`Variable with name ${i.name} was already registered`);return this.state.registeredVariables[i.name]=i,this.incRef(i,this.backend),i}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*$t(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof Nn||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*$t(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){this.disposeVariable(this.state.registeredVariables[e])}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,i,a){const o={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:i},s=hn(e);null!=s&&(r=s.gradFunc),null!=r&&(o.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=Wt(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],i,a))),this.state.activeTape.push(o)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=Hn(e),n=new Set(t.map((e=>e.id)));for(let e=0;e<this.state.activeScope.track.length;e++){const t=this.state.activeScope.track[e];t.kept||n.has(t.id)||t.dispose()}const r=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach((e=>{e.kept||e.scopeId!==r.id||this.track(e)}))}gradients(e,t,n,r=!1){if(Ot(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const i=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));Ot(i instanceof Mn,(()=>"The result y returned by f() must be a tensor."));const a=function(e,t,n){const r={},i={};for(let e=0;e<t.length;e++)r[t[e].id]=!0;for(let n=0;n<e.length;n++){const a=e[n],o=a.inputs;for(const e in o){const n=o[e];let s=!1;for(let e=0;e<t.length;e++)if(r[n.id]){a.outputs.forEach((e=>r[e.id]=!0)),s=!0,i[a.id]=!0;break}if(s)break}}const a={};a[n.id]=!0;const o={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e<n.outputs.length;e++)if(a[n.outputs[e].id]){for(const e in r)a[r[e].id]=!0,o[n.id]=!0;break}}const s=[];for(let t=0;t<e.length;t++){const n=e[t];if(i[n.id]&&o[n.id]){const e={};for(const t in n.inputs){const i=n.inputs[t];r[i.id]&&(e[t]=i)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,s.push(t)}}return s}(this.state.activeTape,t,i);if(!r&&0===a.length&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const e={};e[i.id]=null==n?function(e){const t=function(e,t){const n=Wt(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}(Pt(e),"float32");return Jn.makeTensor(t,e,"float32")}(i.shape):n,function(e,t,n,r){for(let i=t.length-1;i>=0;i--){const a=t[i],o=[];if(a.outputs.forEach((t=>{const n=e[t.id];o.push(null!=n?n:null)})),null==a.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);const s=a.gradient(o);for(const t in a.inputs){if(!(t in s))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(s)}.`);const i=n((()=>s[t]()));if("float32"!==i.dtype)throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${i.dtype}'`);const o=a.inputs[t];if(!Bt(i.shape,o.shape))throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${t}' has shape '${i.shape}', which does not match the shape of the input '${o.shape}'`);if(null==e[o.id])e[o.id]=i;else{const t=e[o.id];e[o.id]=r(t,i),t.dispose()}}}}(e,a,(e=>this.tidy(e)),Zn);const r=t.map((t=>e[t.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((e=>{for(const t of e.saved)t.dispose()})),this.state.activeTape=null),{value:i,grads:r}}))}customGrad(e){return Ot(zt(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;Ot(t.every((e=>e instanceof Mn)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const r={};t.forEach(((e,t)=>{r[t]=e}));return this.runKernelFunc({forwardFunc:(r,i)=>(n=e(...t,i),Ot(n.value instanceof Mn,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),Ot(zt(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(e,r)=>{const i=n.gradFunc(e,r),a=Array.isArray(i)?i:[i];Ot(a.length===t.length,(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")),Ot(a.every((e=>e instanceof Mn)),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."));const o={};return a.forEach(((e,t)=>{o[t]=()=>e})),o},inputs:r})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){const t=mn(),n=await this.backend.time(e);return n.wallMs=mn()-t,n}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new Kn;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function Xn(){const e=nn();if(null==e._tfengine){const t=new Jt(e);e._tfengine=new Yn(t)}return tn=e._tfengine.ENV,function(e){Fn=e}((()=>e._tfengine)),e._tfengine}Yn.nextTensorId=0,Yn.nextVariableId=0;const Jn=Xn();function Zn(e,t){return Jn.runKernel(an,{a:e,b:t})}const Qn=Qt();function er(e,t){let n=e;if(yn(e))return"string"===t?[]:[e.length];if(Gn(e)){return[e.height,e.width*(e.channels||"RGBA").length]}if(zn(e))return[e.buffer.size/(null==t?4:$t(t))];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||yn(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&Qt().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&tr(e,r,[]),r}function tr(e,t,n){if(n=n||[],!Array.isArray(e)&&!yn(e))return void Ot(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));Ot(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),Ot(e.length===t[0],(()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`));const r=t.slice(1);for(let t=0;t<e.length;++t)tr(e[t],r,n.concat(t))}function nr(e,t,n,r){if("string_or_numeric"!==e){if(null==e)throw new Error("Expected dtype cannot be null.");if("numeric"!==e&&e!==t||"numeric"===e&&"string"===t)throw new Error(`Argument '${n}' passed to '${r}' must be ${e} tensor, but got ${t} tensor`)}}function rr(e,t,n,r="numeric"){if(e instanceof Mn)return nr(r,e.dtype,t,n),e;let i=Gt(e);if("string"!==i&&["bool","int32","float32"].indexOf(r)>=0&&(i=r),nr(r,i,t,n),null==e||!yn(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${null==e?"null":e.constructor.name}'`)}const a=er(e,i);yn(e)||Array.isArray(e)||(e=[e]);const o="string"!==i?gn(e,i):bn(e,[],!0);return Jn.makeTensor(o,a,i)}Qn.registerFlag("DEBUG",(()=>!1),(e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),Qn.registerFlag("IS_BROWSER",(()=>"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope)),Qn.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),Qn.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),Qn.registerFlag("IS_SAFARI",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor))),Qn.registerFlag("PROD",(()=>!1)),Qn.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>Qn.getBool("DEBUG"))),Qn.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),Qn.registerFlag("IS_TEST",(()=>!1)),Qn.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>Qn.getBool("DEBUG"))),Qn.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),Qn.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(()=>!1)),Qn.registerFlag("USE_SETTIMEOUTCUSTOM",(()=>!1));function ir(e){const t=Object.keys(e);if(1!==t.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0];const r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+="__op";const i=(...e)=>{Jn.startScope(n);try{const t=r(...e);return Yt(t)&&console.error("Cannot return a Promise inside of tidy."),Jn.endScope(t),t}catch(e){throw Jn.endScope(null),e}};return Object.defineProperty(i,"name",{value:n,configurable:!0}),i}class ar{static join(e){return new ar(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,null==e)return;if(e instanceof Array||(e=[e]),0===(e=e.map((e=>yn(e)?e.buffer:e))).length)return;this.bufferUniformSize=e[0].byteLength;let t=0;for(let n=0;n<e.length;n++){const r=e[n];n!==e.length-1&&r.byteLength!==this.bufferUniformSize&&(this.bufferUniformSize=void 0);const i=t+r.byteLength;this.shards.push({buffer:r,start:t,end:i}),t=i}0===this.shards.length&&(this.byteLength=0),this.byteLength=this.shards[this.shards.length-1].end}slice(e=0,t=this.byteLength){if(0===this.shards.length)return new ArrayBuffer(0);if(e=isNaN(Number(e))?0:e,t=isNaN(Number(t))?0:t,e=Math.max(0,e),(t=Math.min(this.byteLength,t))<=e)return new ArrayBuffer(0);const n=this.findShardForByte(e);if(-1===n)throw new Error(`Could not find start shard for byte ${e}`);const r=new ArrayBuffer(t-e),i=new Uint8Array(r);let a=0;for(let r=n;r<this.shards.length;r++){const n=this.shards[r],o=e+a-n.start,s=a,l=Math.min(t,n.end),u=new Uint8Array(n.buffer,o,l-n.start-o);if(i.set(u,s),a+=u.length,t<n.end)break}return r}findShardForByte(e){if(0===this.shards.length||e<0||e>=this.byteLength)return-1;if(null!=this.bufferUniformSize)return this.previousShardIndex=Math.floor(e/this.bufferUniformSize),this.previousShardIndex;function t(t){return e<t.start?-1:e>=t.end?1:0}if(0===t(this.shards[this.previousShardIndex]))return this.previousShardIndex;const n=function(e,t){let n=0,r=e.length;for(;n<=r;){const i=Math.floor((r-n)/2)+n,a=t(e[i]);if(0===a)return i;a<0?r=i:n=i+1}return-1}(this.shards,t);return-1===n?-1:(this.previousShardIndex=n,this.previousShardIndex)}}const or="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function sr(e){return or?Buffer.byteLength(e,"utf8"):new Blob([e]).size}function lr(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:sr(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:sr(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:new ar(e.weightData).byteLength}}class ur{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==ur.instance&&(ur.instance=new ur),ur.instance}static registerSaveRouter(e){ur.getInstance().saveRouters.push(e)}static registerLoadRouter(e){ur.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return ur.getHandlers(e,"save")}static getLoadHandlers(e,t){return ur.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?ur.getInstance().loadRouters:ur.getInstance().saveRouters).forEach((t=>{const i=t(e,n);null!==i&&r.push(i)})),r}}const cr="tensorflowjs",dr="models_store",hr="model_info_store";function fr(){if(!Qt().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function pr(e){const t=e.result;t.createObjectStore(dr,{keyPath:"modelPath"}),t.createObjectStore(hr,{keyPath:"modelPath"})}class gr{constructor(e){if(this.indexedDB=fr(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise(((e,n)=>{const r=this.indexedDB.open(cr,1);r.onupgradeneeded=()=>pr(r),r.onsuccess=()=>{const i=r.result;if(null==t){const t=i.transaction(dr,"readonly"),r=t.objectStore(dr).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return i.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(i.close(),n(r.error)),t.oncomplete=()=>i.close()}else{const r=lr(t),a=i.transaction(hr,"readwrite");let o,s,l=a.objectStore(hr);try{o=l.put({modelPath:this.modelPath,modelArtifactsInfo:r})}catch(e){return n(e)}o.onsuccess=()=>{s=i.transaction(dr,"readwrite");const o=s.objectStore(dr);let u;try{u=o.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r})}catch(e){return n(e)}u.onsuccess=()=>e({modelArtifactsInfo:r}),u.onerror=e=>{l=a.objectStore(hr);const t=l.delete(this.modelPath);t.onsuccess=()=>(i.close(),n(u.error)),t.onerror=e=>(i.close(),n(u.error))}},o.onerror=e=>(i.close(),n(o.error)),a.oncomplete=()=>{null==s?i.close():s.oncomplete=()=>i.close()}}},r.onerror=e=>n(r.error)}))}}gr.URL_SCHEME="indexeddb://";const mr=e=>{return Qt().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(gr.URL_SCHEME)?(t=e.slice(gr.URL_SCHEME.length),new gr(t)):null;var t};ur.registerSaveRouter(mr),ur.registerLoadRouter(mr);class vr{constructor(){this.indexedDB=fr()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(cr,1);n.onupgradeneeded=()=>pr(n),n.onsuccess=()=>{const r=n.result,i=r.transaction(hr,"readonly"),a=i.objectStore(hr).getAll();a.onsuccess=()=>{const t={};for(const e of a.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},a.onerror=e=>(r.close(),t(a.error)),i.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(gr.URL_SCHEME)?t.slice(gr.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(cr,1);r.onupgradeneeded=()=>pr(r),r.onsuccess=()=>{const i=r.result,a=i.transaction(hr,"readwrite"),o=a.objectStore(hr),s=o.get(e);let l;s.onsuccess=()=>{if(null==s.result)return i.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=o.delete(e),a=()=>{l=i.transaction(dr,"readwrite");const r=l.objectStore(dr).delete(e);r.onsuccess=()=>t(s.result.modelArtifactsInfo),r.onerror=e=>n(s.error)};r.onsuccess=a,r.onerror=e=>(a(),i.close(),n(s.error))}},s.onerror=e=>(i.close(),n(s.error)),a.oncomplete=()=>{null==l?i.close():l.oncomplete=()=>i.close()}},r.onerror=e=>n(r.error)}))}}const yr="/",br="tensorflowjs_models",wr="info",xr="model_topology",Er="weight_specs",Sr="weight_data",Tr="model_metadata";function kr(e){return{info:[br,e,wr].join(yr),topology:[br,e,xr].join(yr),weightSpecs:[br,e,Er].join(yr),weightData:[br,e,Sr].join(yr),modelMetadata:[br,e,Tr].join(yr)}}function Cr(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function Ar(e){const t=e.split(yr);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(yr)}class Rr{constructor(e){if(!Qt().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=kr(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),r=lr(e),i=ar.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(e){if(or)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e<r;e++)n+=String.fromCharCode(t[e]);return btoa(n)}(i));return this.LS.setItem(this.keys.modelMetadata,JSON.stringify({format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:null!=e.signature?e.signature:void 0,userDefinedMetadata:null!=e.userDefinedMetadata?e.userDefinedMetadata:void 0,modelInitializer:null!=e.modelInitializer?e.modelInitializer:void 0,initializerSignature:null!=e.initializerSignature?e.initializerSignature:void 0,trainingConfig:null!=e.trainingConfig?e.trainingConfig:void 0})),{modelArtifactsInfo:r}}catch(e){throw Cr(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;const r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==r)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=r;const i=this.LS.getItem(this.keys.modelMetadata);if(null!=i){const e=JSON.parse(i);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(t.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(t.trainingConfig=e.trainingConfig)}const a=this.LS.getItem(this.keys.weightData);if(null==a)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=function(e){if(or){const t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}(a),t}}Rr.URL_SCHEME="localstorage://";const _r=e=>{return Qt().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Rr.URL_SCHEME)?(t=e.slice(Rr.URL_SCHEME.length),new Rr(t)):null;var t};ur.registerSaveRouter(_r),ur.registerLoadRouter(_r);class Ir{constructor(){Ot(Qt().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),Ot("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=br+yr,n=yr+wr;for(let r=0;r<this.LS.length;++r){const i=this.LS.key(r);if(i.startsWith(t)&&i.endsWith(n)){e[Ar(i)]=JSON.parse(this.LS.getItem(i))}}return e}async removeModel(e){var t;const n=kr(e=(t=e).startsWith(Rr.URL_SCHEME)?t.slice(Rr.URL_SCHEME.length):t);if(null==this.LS.getItem(n.info))throw new Error(`Cannot find model at path '${e}'`);const r=JSON.parse(this.LS.getItem(n.info));return Cr(n),r}}class Dr{constructor(){this.managers={}}static getInstance(){return null==Dr.instance&&(Dr.instance=new Dr),Dr.instance}static registerManager(e,t){Ot(null!=e,(()=>"scheme must not be undefined or null.")),e.endsWith("://")&&(e=e.slice(0,e.indexOf("://"))),Ot(e.length>0,(()=>"scheme must not be an empty string."));const n=Dr.getInstance();Ot(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=Dr.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(Dr.getInstance().managers)}}class Fr{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}setTimeoutCustom(e,t){"undefined"!=typeof window&&Qt().getBool("USE_SETTIMEOUTCUSTOM")?(this.functionRefs.push(e),setTimeout((()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")}),t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",(e=>{if(e.source===window&&e.data.name===this.messageName){e.stopPropagation();(0,this.functionRefs[e.data.index])(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}}),!0))):setTimeout(e,t)}isTypedArray(e){return pn(e)}}if(Qt().get("IS_BROWSER")){Qt().setPlatform("browser",new Fr);try{Dr.registerManager(Rr.URL_SCHEME,new Ir)}catch(e){}try{Dr.registerManager(gr.URL_SCHEME,new vr)}catch(e){}}const Lr=()=>require("node-fetch");let Mr;class Nr{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=Qt().global.fetch?Qt().global.fetch(e,t):(null==Mr&&(Mr=Lr()),Mr(e,t))}now(){const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}isTypedArray(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)}}Qt().get("IS_NODE")&&!Qt().get("IS_BROWSER")&&Qt().setPlatform("node",new Nr);const Or=ir({cast_:function(e,t){const n=rr(e,"x","cast");if(!function(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");return Jn.runKernel(on,{x:n},{dtype:t})}});const Pr=ir({clone_:function(e){const t=rr(e,"x","clone","string_or_numeric");return Jn.runKernel(sn,{x:t})}});Xn();const Br={buffer:function(e,t="float32",n){return t=t||"float32",Kt(e),new Dn(e,t,n)},cast:Or,clone:Pr,print:function(e,t=!1){console.log(e.toString(t))}};function Ur(e,t){return Jn.tidy(e,t)}function $r(e){Hn(e).forEach((e=>e.dispose()))}Ln=Br;const jr=ir({add_:function(e,t){let n=rr(e,"a","add"),r=rr(t,"b","add");return[n,r]=qn(n,r),Jn.runKernel(an,{a:n,b:r})}});const Gr=ir({floorDiv_:function(e,t){let n=rr(e,"a","floorDiv"),r=rr(t,"b","floorDiv");return[n,r]=qn(n,r),Jn.runKernel("FloorDiv",{a:n,b:r})}});const zr=ir({div_:function(e,t){let n=rr(e,"a","div"),r=rr(t,"b","div");return[n,r]=qn(n,r),"int32"===n.dtype&&"int32"===r.dtype?Gr(n,r):Jn.runKernel("RealDiv",{a:n,b:r},{})}});const qr=ir({mul_:function(e,t){let n=rr(e,"a","mul"),r=rr(t,"b","mul");return[n,r]=qn(n,r),Jn.runKernel("Multiply",{a:n,b:r})}});const Hr=ir({abs_:function(e){const t=rr(e,"x","abs");if("complex64"===t.dtype){return Jn.runKernel("ComplexAbs",{x:t})}return Jn.runKernel("Abs",{x:t})}});const Vr=ir({zerosLike_:function(e){const t=rr(e,"x","zerosLike");return Jn.runKernel("ZerosLike",{x:t})}});const Wr=ir({pow_:function(e,t){let n=rr(e,"base","pow"),r=rr(t,"exp","pow");return[n,r]=qn(n,r),Jn.runKernel("Pow",{a:n,b:r})}});function Kr(e,t){if((yn(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&yn(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return function(e,t,n,r){if(null==r)r=Gt(e);else if("complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(zn(e)||Gn(e)){if("float32"!==r&&"int32"!==r)throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${r}.`);return Jn.backend.createTensorFromGPUData(e,t||n,r)}if(!yn(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=t){Kt(t);const e=Pt(t),r=Pt(n);Ot(e===r,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`));for(let e=0;e<n.length;++e){const r=e!==n.length-1||n[e]!==Pt(t.slice(e));Ot(n[e]===t[e]||!r,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return yn(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?gn(e,r):bn(e,[],!0),Jn.makeTensor(e,t,r)}(e,[],[],t)}const Yr=ir({sqrt_:function(e){const t=rr(e,"x","sqrt","float32");return Jn.runKernel("Sqrt",{x:t})}});const Xr=ir({square_:function(e){const t=rr(e,"x","square");return Jn.runKernel("Square",{x:t},{})}});const Jr=ir({sub_:function(e,t){let n=rr(e,"a","sub"),r=rr(t,"b","sub");return[n,r]=qn(n,r),Jn.runKernel("Sub",{a:n,b:r})}});const Zr=ir({maximum_:function(e,t){let n=rr(e,"a","maximum"),r=rr(t,"b","maximum");return[n,r]=qn(n,r),"bool"===n.dtype&&(n=Or(n,"int32"),r=Or(r,"int32")),function(e,t){const n=Math.max(e.length,t.length),r=new Array(n);for(let i=0;i<n;i++){let a=e[e.length-i-1];null==a&&(a=1);let o=t[t.length-i-1];if(null==o&&(o=1),1===a)r[n-i-1]=o;else if(1===o)r[n-i-1]=a;else{if(a!==o)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);r[n-i-1]=a}}}(n.shape,r.shape),Jn.runKernel("Maximum",{a:n,b:r})}});class Qr{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class ei{constructor(){this.classNameMap={}}static getMap(){return null==ei.instance&&(ei.instance=new ei),ei.instance}static register(e){ei.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function ti(e){Ot(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),Ot("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),Ot(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),ei.register(e)}class ni extends Qr{minimize(e,t=!1,n){const{value:r,grads:i}=this.computeGradients(e,n);if(null!=n){const e=n.map((e=>({name:e.name,tensor:i[e.name]})));this.applyGradients(e)}else this.applyGradients(i);return $r(i),t?r:(r.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return function(e,t){Ot(zt(e),(()=>"The f passed in variableGrads(f) must be a function")),Ot(null==t||Array.isArray(t)&&t.every((e=>e instanceof Nn)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=t;if(!n){t=[];for(const e in Jn.registeredVariables)t.push(Jn.registeredVariables[e])}const r=n?t.filter((e=>!e.trainable)):null,i=t.length;Ot((t=t.filter((e=>e.trainable))).length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${i} variables is trainable.`));const{value:a,grads:o}=Jn.gradients(e,t,null,!0);Ot(o.some((e=>null!=e)),(()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize().")),Ot(0===a.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${a.rank} tensor`));const s={};return t.forEach(((e,t)=>{null!=o[t]&&(s[e.name]=o[t])})),null!=r&&r.forEach((e=>s[e.name]=null)),{value:a,grads:s}}(e,t)}dispose(){null!=this.iterations_&&$r(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:Kr(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}}Object.defineProperty(ni,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class ri extends ni{static get className(){return"SGD"}constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);t.forEach(((t,n)=>{const r=Array.isArray(e)?e[n].tensor:e[t];if(null==r)return;const i=Jn.registeredVariables[t];Ur((()=>{const e=jr(qr(this.c,r),i);i.assign(e)}))})),this.incrementIterations()}setLearningRate(e){var t;this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=(t=Kr(-e),Jn.keep(t))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(0!==(e=await this.extractIterations(e)).length)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}const ii=[class extends ni{static get className(){return"Adadelta"}constructor(e,t,n=null){super(),this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==n&&(this.epsilon=Jn.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Jn.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:Ur((()=>Vr(r).variable(false)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:Ur((()=>Vr(r).variable(false)))});const i=Array.isArray(e)?e[n].tensor:e[t];if(null==i)return;const a=this.accumulatedGrads[n].variable,o=this.accumulatedUpdates[n].variable;Ur((()=>{const e=jr(qr(a,this.rho),qr(Xr(i),1-this.rho)),t=qr(zr(Yr(jr(o,this.epsilon)),Yr(jr(a,this.epsilon))),i),n=jr(qr(o,this.rho),qr(Xr(t),1-this.rho));a.assign(e),o.assign(n);const s=jr(qr(t,-this.learningRate),r);r.assign(s)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&($r(this.accumulatedGrads.map((e=>e.variable))),$r(this.accumulatedUpdates.map((e=>e.variable))))}async getWeights(){const e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){const t=(e=await this.extractIterations(e)).length/2;this.accumulatedGrads=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(false)}))),this.accumulatedUpdates=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}},class extends ni{static get className(){return"Adagrad"}constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Jn.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:Ur((()=>function(e,t,n){return Kt(e),n=n||Gt(t),Jn.runKernel("Fill",{},{shape:e,value:t,dtype:n})}(r.shape,this.initialAccumulatorValue).variable(e)))}}const i=Array.isArray(e)?e[n].tensor:e[t];if(null==i)return;const a=this.accumulatedGrads[n].variable;Ur((()=>{const e=jr(a,Xr(i));a.assign(e);const t=jr(qr(zr(i,Yr(jr(e,Jn.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&$r(this.accumulatedGrads.map((e=>e.variable)))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e);this.accumulatedGrads=e.map((e=>({originalName:e.name,variable:e.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}},class extends ni{static get className(){return"Adam"}constructor(e,t,n,r=null){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],Ur((()=>{this.accBeta1=Kr(t).variable(),this.accBeta2=Kr(n).variable()})),null==r&&(this.epsilon=Jn.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);Ur((()=>{const n=Jr(1,this.accBeta1),r=Jr(1,this.accBeta2);t.forEach(((t,i)=>{const a=Jn.registeredVariables[t];null==this.accumulatedFirstMoment[i]&&(this.accumulatedFirstMoment[i]={originalName:`${t}/m`,variable:Ur((()=>Vr(a).variable(false)))}),null==this.accumulatedSecondMoment[i]&&(this.accumulatedSecondMoment[i]={originalName:`${t}/v`,variable:Ur((()=>Vr(a).variable(false)))});const o=Array.isArray(e)?e[i].tensor:e[t];if(null==o)return;const s=this.accumulatedFirstMoment[i].variable,l=this.accumulatedSecondMoment[i].variable,u=jr(qr(s,this.beta1),qr(o,1-this.beta1)),c=jr(qr(l,this.beta2),qr(Xr(o),1-this.beta2)),d=zr(u,n),h=zr(c,r);s.assign(u),l.assign(c);const f=jr(qr(zr(d,jr(Yr(h),this.epsilon)),-this.learningRate),a);a.assign(f)})),this.accBeta1.assign(qr(this.accBeta1,this.beta1)),this.accBeta2.assign(qr(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&$r(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&$r(this.accumulatedSecondMoment.map((e=>e.variable)))}async getWeights(){const e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),Ur((()=>{this.accBeta1.assign(Wr(this.beta1,this.iterations_+1)),this.accBeta2.assign(Wr(this.beta2,this.iterations_+1))}));const t=e.length/2;this.accumulatedFirstMoment=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(false)}))),this.accumulatedSecondMoment=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}},class extends ni{static get className(){return"Adamax"}constructor(e,t,n,r=null,i=0){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=i,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],Ur((()=>{this.iteration=Kr(0).variable(),this.accBeta1=Kr(t).variable()})),null==r&&(this.epsilon=Jn.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);Ur((()=>{const n=Jr(1,this.accBeta1),r=zr(-this.learningRate,jr(qr(this.iteration,this.decay),1));t.forEach(((t,i)=>{const a=Jn.registeredVariables[t];null==this.accumulatedFirstMoment[i]&&(this.accumulatedFirstMoment[i]={originalName:`${t}/m`,variable:Vr(a).variable(false)}),null==this.accumulatedWeightedInfNorm[i]&&(this.accumulatedWeightedInfNorm[i]={originalName:`${t}/v`,variable:Vr(a).variable(false)});const o=Array.isArray(e)?e[i].tensor:e[t];if(null==o)return;const s=this.accumulatedFirstMoment[i].variable,l=this.accumulatedWeightedInfNorm[i].variable,u=jr(qr(s,this.beta1),qr(o,1-this.beta1)),c=qr(l,this.beta2),d=Hr(o),h=Zr(c,d);s.assign(u),l.assign(h);const f=jr(qr(zr(r,n),zr(u,jr(h,this.epsilon))),a);a.assign(f)})),this.iteration.assign(jr(this.iteration,1)),this.accBeta1.assign(qr(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&$r(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&$r(this.accumulatedWeightedInfNorm.map((e=>e.variable)))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}},class extends ri{static get className(){return"Momentum"}constructor(e,t,n=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=Kr(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Jn.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:Ur((()=>Vr(r).variable(e)))}}const i=this.accumulations[n].variable,a=Array.isArray(e)?e[n].tensor:e[t];null!=a&&Ur((()=>{let e;const t=jr(qr(this.m,i),a);e=jr(qr(this.c,this.useNesterov?jr(a,qr(t,this.m)):t),r),i.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&$r(this.accumulations.map((e=>e.variable)))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e);this.accumulations=e.map((e=>({originalName:e.name,variable:e.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}},class extends ni{static get className(){return"RMSProp"}constructor(e,t=.9,n=0,r=null,i=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=i,null==r&&(this.epsilon=Jn.backend.epsilon()),null==e)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Jn.registeredVariables[t],i=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:Ur((()=>Vr(r).variable(i)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:Ur((()=>Vr(r).variable(i)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:Ur((()=>Vr(r).variable(i)))});const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const o=this.accumulatedMeanSquares[n].variable,s=this.accumulatedMoments[n].variable;Ur((()=>{const e=jr(qr(o,this.decay),qr(Xr(a),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,i=jr(qr(t,this.decay),qr(a,1-this.decay)),l=zr(qr(a,this.learningRate),Yr(Jr(e,jr(Xr(i),this.epsilon)))),u=jr(qr(s,this.momentum),l);o.assign(e),t.assign(i),s.assign(u);const c=Jr(r,u);r.assign(c)}else{const e=jr(qr(o,this.decay),qr(Xr(a),1-this.decay)),t=jr(qr(s,this.momentum),zr(qr(a,this.learningRate),Yr(jr(e,this.epsilon))));o.assign(e),s.assign(t);const n=Jr(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&$r(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&$r(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&$r(this.accumulatedMoments.map((e=>e.variable)))}async getWeights(){const e=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&e.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e);const t=this.centered?e.length/3:e.length/2,n=!1;this.accumulatedMeanSquares=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.accumulatedMoments=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.centered&&(this.accumulatedMeanGrads=e.slice(2*t,3*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}},ri];!function(){for(const e of ii)ti(e)}();const ai={},oi={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function si(e,t){if(!(e in ai)||null!=t){const n=function(e,t){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=null==t?function(e){if(Qt().getBool("IS_SAFARI")||"undefined"==typeof OffscreenCanvas||2!==e){if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}return new OffscreenCanvas(300,150)}(e):t;n.addEventListener("webglcontextlost",(t=>{t.preventDefault(),delete ai[e]}),!1),Qt().getBool("SOFTWARE_WEBGL_ENABLED")&&(oi.failIfMajorPerformanceCaveat=!1);if(1===e)return n.getContext("webgl",oi)||n.getContext("experimental-webgl",oi);return n.getContext("webgl2",oi)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;ai[e]=n}const n=ai[e];return null==n||n.isContextLost()?(delete ai[e],si(e)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),ai[e])}var li="https://websdk-cdn-dev.idmission.com/assets";function ui(e){var t=e.width,n=e.height;return e instanceof HTMLVideoElement&&(t=e.videoWidth,n=e.videoHeight),[t,n]}function ci(e,t){var n=document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("could not get 2d context");var i=t.box,a=i.width,o=.6*e.height-a,s=Math.max(0,i.xMin-o/2);return kt()?(n.width=e.width,n.height=e.height,r.drawImage(e,0,0,n.width,n.height)):(n.width=a+o,n.height=e.height,r.drawImage(e,s,0,n.width,n.height,0,0,n.width,n.height)),n.toDataURL("image/jpeg",.92)}var di={boxes:0,scores:7,labels:4},hi=n.createContext({ready:!1,working:{current:!1},thresholds:{},setThresholds:function(){return null},makePrediction:function(){return null},onPredictionMade:function(){return null},detectionTime:0,focusPredictionTime:0,getBestFrame:function(){return Promise.resolve(null)},resetBestFrame:function(){return null}}),fi="".concat(li,"/models/documentdetection448/model.json"),pi="".concat(li,"/models/focus/model.json"),gi=function(e){var t=e.children,r=e.documentDetectionModelUrl,i=e.focusModelUrl,o=n.useState(!1),s=o[0],l=o[1],c=n.useState(0),d=c[0],h=c[1],p=n.useState(0),v=p[0],y=p[1],b=n.useState(0),w=b[0],x=b[1],E=n.useState(0),S=E[0],T=E[1],k=n.useState(0),C=k[0],A=k[1],R=n.useRef(!1),_=n.useRef(),I=n.useRef(null),D=n.useState(0),F=D[0],L=D[1],M=n.useState(0),N=M[0],O=M[1];n.useEffect((function(){l(!1);var e=r||fi,t=i||pi;function n(){return g(this,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return f.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",52428800),[4,f.setBackend("webgl")];case 1:return n.sent(),[4,f.ready()];case 2:return n.sent(),[4,Promise.all([bt(e),Lt(t)])];case 3:return n.sent(),[2]}}))}))}function o(){return g(this,void 0,void 0,(function(){var r;return m(this,(function(i){switch(i.label){case 0:return l(!1),mt=null,Dt=null,delete ai[2],(r=document.createElement("canvas").getContext("webgl2"))&&e&&t?(a.setWebGLContext(2,r),function(){try{f.backend().dispose()}catch(e){console.error("failed to dispose backend",e)}}(),[4,n()]):[3,2];case 1:i.sent(),l(!0),i.label=2;case 2:return[2]}}))}))}n().then((function(){l(!0)}));var s=si(2).canvas;return s.addEventListener("webglcontextlost",o),function(){var e;null===(e=s.removeEventListener)||void 0===e||e.call(s,"webglcontextlost",o)}}),[r,i]);var P=n.useMemo((function(){return{document:d,passport:v,mrz:w,pdf417:S,focus:C}}),[d,C,w,v,S]),B=n.useCallback((function(e){e.document&&h(e.document),e.passport&&y(e.passport),e.mrz&&x(e.mrz),e.pdf417&&T(e.pdf417),e.focus&&A(e.focus)}),[]),U=n.useRef(null),$=n.useRef(0),j=n.useCallback((function(e){R.current=!0,g(void 0,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:return mt&&Dt&&I.current?[4,vi(e,I.current,P)]:[2];case 1:return t=r.sent(),L(t.detectionTime),O(t.focusPredictionTime),$.current<=t.focusScore&&($.current=t.focusScore,mi(U.current,e)),null===(n=_.current)||void 0===n||n.call(_,t),R.current=!1,[2]}}))}))}),[P]),G=n.useCallback((function(e){_.current=e}),[]),z=n.useCallback((function(){return g(void 0,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return U.current?(e=U.current.toDataURL("image/jpeg",.98),[4,fetch(e)]):[2,null];case 1:return[4,t.sent().blob()];case 2:return[2,t.sent()]}}))}))}),[]),q=n.useCallback((function(){$.current=0,function(e){if(!e)return;var t=e.getContext("2d");if(!t)return;t.clearRect(0,0,e.width,e.height)}(U.current)}),[]),H=n.useMemo((function(){return{ready:s,working:R,thresholds:P,setThresholds:B,makePrediction:j,onPredictionMade:G,detectionTime:F,focusPredictionTime:N,getBestFrame:z,resetBestFrame:q}}),[F,N,z,j,G,s,q,B,P]);return u.default.createElement(hi.Provider,{value:H},t,u.default.createElement(ki,{ref:I}),u.default.createElement(ki,{ref:U}))};function mi(e,t,n,r){if(e){var i=e.getContext("2d");if(i){if(!n||!r){var a=ui(t);n||(n=a[0]),r||(r=a[1])}e.width=n,e.height=r,i.drawImage(t,0,0,n,r)}}}function vi(e,t,n){var r,i,a,o,s,l,u,c,d,h;return g(this,void 0,void 0,(function(){var f,p,g,v,y,b,w,x,E,S,T,k,C,A,R,_,I,D,F,L,M,N,O,P,B,U,$;return m(this,(function(m){switch(m.label){case 0:return f=ui(e),p=f[0],g=f[1],mi(t,e),[4,yi(e)];case 1:return v=m.sent(),y=v.scores,b=v.labels,w=v.time,x=function(e){var t={};return e.forEach((function(e,n){e&&(t[e.label]||(t[e.label]=[0,-1]),e.score>t[e.label][0]&&(t[e.label]=[e.score,n]))})),Object.keys(t).map((function(n){return e[t[n][1]]})).filter((function(e){return!!e}))}(v.boxes.map((function(e,t){return function(e,t,n){var r=e[0],i=e[1];return{score:t,bbox:[i,r,e[3]-i,e[2]-r],label:wt[n]}}(e,y[t],b[t])}))),E=x.find((function(e){return"Document"===e.label})),S=x.find((function(e){return"Passport Page"===e.label})),T=null!==(r=null==E?void 0:E.score)&&void 0!==r?r:0,k=null!==(i=null==S?void 0:S.score)&&void 0!==i?i:0,C=k>=(null!==(a=n.passport)&&void 0!==a?a:0),A=T>k?E:S,_=(R=C?k:T)>=(null!==(o=n.document)&&void 0!==o?o:0),I=x.find((function(e){return"MRZ"===e.label})),D=null!==(s=null==I?void 0:I.score)&&void 0!==s?s:0,F=D>=(null!==(l=n.mrz)&&void 0!==l?l:0),L=x.find((function(e){return"PDF417"===e.label})),M=null!==(u=null==L?void 0:L.score)&&void 0!==u?u:0,N=M>=(null!==(c=n.pdf417)&&void 0!==c?c:0),O=null,P=0,B=0,U=!1,_?[4,bi(e,null==A?void 0:A.bbox)]:[3,3];case 2:$=m.sent(),P=$[1],B=null!==(d=null==(O=$[0])?void 0:O[1])&&void 0!==d?d:0,U=B>=(null!==(h=n.focus)&&void 0!==h?h:0),m.label=3;case 3:return[2,{detectedObjects:x,detectionScore:R,detectionThresholdMet:_,passportDetectionScore:k,passportDetectionThresholdMet:C,mrzDetectionScore:D,mrzDetectionThresholdMet:F,pdf417DetectionScore:M,pdf417DetectionThresholdMet:N,detectionTime:w,bestDocumentOrPassport:A,bestMrz:I,bestPdf417:L,focusScore:B,focusThresholdMet:U,focusPredictionTime:P,frameWidth:p,frameHeight:g}]}}))}))}function yi(e){return g(this,void 0,void 0,(function(){var t,n,r,i,a,o,s,l,u,c,d,h,p,g,v,y,b;return m(this,(function(m){switch(m.label){case 0:if(!mt)throw new Error("document detection model is not loaded");t=new Date,m.label=1;case 1:return m.trys.push([1,7,,8]),n=f.browser.fromPixels(e),r=f.image.resizeBilinear(n,[448,448]),n.dispose(),i=f.cast(r,"int32"),r.dispose(),s=(o=f).tensor4d,u=(l=Array).from,[4,i.data()];case 2:return a=s.apply(o,[u.apply(l,[m.sent()]),[1,448,448,3]]),i.dispose(),c=f.cast(a,"int32"),a.dispose(),[4,mt.executeAsync(c)];case 3:return d=m.sent(),c.dispose(),[4,(h=d)[di.boxes].array()];case 4:return p=m.sent()[0],[4,h[di.scores].array()];case 5:return g=m.sent()[0],[4,h[di.labels].array()];case 6:return v=(v=m.sent()[0]).map((function(e){return Math.round(e)})),f.dispose(d),y=(new Date).getTime()-t.getTime(),[2,{boxes:p,scores:g,labels:v,time:y}];case 7:return b=m.sent(),console.error("caught error in makeDocumentDetectionPredictions",b),[2,{boxes:[],scores:[],labels:[],time:0}];case 8:return[2]}}))}))}function bi(e,t){return g(this,void 0,void 0,(function(){var n,r,i,a,o,s,l,u,c,d,h,p,g;return m(this,(function(m){switch(m.label){case 0:if(!Dt)throw new Error("focus model is not loaded");n=new Date,m.label=1;case 1:return m.trys.push([1,5,,6]),r=void 0,r=f.browser.fromPixels(t?function(e,t){var n=document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("could not get 2d context");var i=ui(e),a=i[0],o=i[1],s=t[0],l=t[1],u=t[2],c=t[3];return n.width=u*a,n.height=c*o,r.drawImage(e,s*a,l*o,u*a,c*o,0,0,u*a,c*o),n}(e,t):e),i=f.image.resizeBilinear(r,[448,448]),r.dispose(),a=f.cast(i,"int32"),i.dispose(),l=(s=f).tensor4d,c=(u=Array).from,[4,a.data()];case 2:return o=l.apply(s,[c.apply(u,[m.sent()]),[1,448,448,3]]),a.dispose(),d=f.cast(o,"int32"),o.dispose(),[4,Dt.predict(d)];case 3:return h=m.sent(),d.dispose(),[4,h.array()];case 4:return p=m.sent()[0],f.dispose(h),g=(new Date).getTime()-n.getTime(),[2,[p,g]];case 5:return m.sent(),[2,[[0,0],0]];case 6:return[2]}}))}))}var wi,xi,Ei,Si,Ti,ki=h.default.canvas(wi||(wi=y(["\n display: none;\n"],["\n display: none;\n"]))),Ci=h.default.span(xi||(xi=y(["\n font-size: 16px;\n font-family: monospace;\n position: absolute;\n left: 20px;\n bottom: 20px;\n color: limegreen;\n background: rgba(0, 0, 0, 0.5);\n z-index: 1001;\n"],["\n font-size: 16px;\n font-family: monospace;\n position: absolute;\n left: 20px;\n bottom: 20px;\n color: limegreen;\n background: rgba(0, 0, 0, 0.5);\n z-index: 1001;\n"]))),Ai=h.default.div(Ei||(Ei=y(["\n position: absolute;\n z-index: 1001;\n width: 100%;\n height: 100%;\n max-width: 100%;\n max-height: 100%;\n overflow: hidden;\n ","\n"],["\n position: absolute;\n z-index: 1001;\n width: 100%;\n height: 100%;\n max-width: 100%;\n max-height: 100%;\n overflow: hidden;\n ","\n"])),(function(e){return e.$flipX?"transform: scaleX(-1);":""})),Ri=h.default.div(Si||(Si=y(["\n font: 10px monospace;\n position: absolute;\n top: ","px;\n left: ","px;\n width: ","px;\n height: ","px;\n border: 3px solid ",";\n color: ",";\n ","\n"],["\n font: 10px monospace;\n position: absolute;\n top: ","px;\n left: ","px;\n width: ","px;\n height: ","px;\n border: 3px solid ",";\n color: ",";\n ","\n"])),(function(e){return e.$top}),(function(e){return e.$left}),(function(e){return e.$width}),(function(e){return e.$height}),(function(e){var t=e.$color;return null!=t?t:"green"}),(function(e){var t=e.$color;return null!=t?t:"green"}),(function(e){return e.$flipX?"transform: scaleX(-1);":""})),_i=h.default.div(Ti||(Ti=y(["\n position: absolute;\n top: ","px;\n left: ","px;\n width: ","px;\n height: ","px;\n border: ","px solid\n ",";\n font: 10px monospace;\n color: ",";\n border-radius: 50%;\n ","\n"],["\n position: absolute;\n top: ","px;\n left: ","px;\n width: ","px;\n height: ","px;\n border: ","px solid\n ",";\n font: 10px monospace;\n color: ",";\n border-radius: 50%;\n ","\n"])),(function(e){return e.$top-e.$height/2}),(function(e){return e.$left-e.$width/2}),(function(e){return e.$width}),(function(e){return e.$height}),(function(e){return e.$width/2}),(function(e){var t=e.$color;return null!=t?t:"red"}),(function(e){var t=e.$color;return null!=t?t:"red"}),(function(e){return e.$flipX?"transform: scaleX(-1);":""}));function Ii(e){var t=e.enabled,r=void 0===t||t,i=e.pageWidth,a=e.pageHeight,o=e.videoWidth,s=e.videoHeight;return n.useMemo((function(){var e=!1,t=0,n=0,l=0,u=0;return r&&((e=i/a<o/s)?l=((t=o*(a/s))-i)/2:u=((n=s*(i/o))-a)/2),{horizontal:e,pageWidth:i,pageHeight:a,videoWidth:o,videoHeight:s,scaledWidth:t,scaledHeight:n,xOffset:l,yOffset:u}}),[r,a,i,s,o])}function Di(e){var t=e.obj,n=e.scaling,r=n.horizontal,i=n.pageWidth,a=n.pageHeight,o=n.scaledWidth,s=n.scaledHeight;return u.default.createElement(Ri,{$top:t.bbox[1]*(r?a:s-n.yOffset),$left:t.bbox[0]*(r?o-n.xOffset:i),$width:t.bbox[2]*(r?o:i),$height:t.bbox[3]*(r?a:s),$flipX:e.flipX},t.label," (",t.score.toFixed(3),")")}function Fi(e){var t,n,r,i,a=e.face,o=e.flipX,s=e.color,l=e.scaling,c=l.pageWidth,d=l.pageHeight,h=l.videoWidth,f=l.videoHeight,p=l.scaledWidth,g=l.scaledHeight;return l.horizontal?(t=a.box.yMin/f*d,n=a.box.xMin/h*p-l.xOffset,r=a.box.width/h*p,i=a.box.height/f*d):(t=a.box.yMin/f*g-l.yOffset,n=a.box.xMin/h*c,r=a.box.width/h*c,i=a.box.height/f*g),u.default.createElement(u.default.Fragment,null,u.default.createElement(Ri,{$top:t,$left:n,$width:r,$height:i,$flipX:o,$color:void 0===s?"green":s}),a.keypoints.map((function(e,t){return u.default.createElement(Li,{key:t,point:e,scaling:l,flipX:o})})))}function Li(e){var t,n,r=e.point,i=e.color,a=e.scaling,o=a.videoWidth,s=a.videoHeight;return a.horizontal?(t=r.x/o*a.scaledWidth-a.xOffset,n=r.y/s*a.pageHeight):(t=r.x/o*a.pageWidth,n=r.y/s*a.scaledHeight-a.yOffset),u.default.createElement(_i,{$top:n,$left:t,$width:4,$height:4,$flipX:e.flipX,$color:void 0===i?"red":i})}var Mi,Ni,Oi={videoWidth:0,videoHeight:0,captureStartedAt:null,detectedObjects:[],bestDocument:void 0,bestMrz:void 0,bestPdf417:void 0,documentType:gt.NONE,documentInBounds:!1,documentDetectionScore:0,documentDetectionThresholdMet:!1,passportPageDetectionScore:0,passportPageDetectionThresholdMet:!1,mrzDetectionScore:0,mrzDetectionThresholdMet:!1,pdf417DetectionScore:0,pdf417DetectionThresholdMet:!1,focusScore:0,focusThresholdMet:!1,barcodeScanningEnabled:!1,barcodeResult:null,waitingForBarcodeScan:!1,shouldScanBarcode:!1,autoCaptureBarcodeRequired:"mobile",barcodeScanFailedAttempts:0,maxBarcodeScanAttempts:10,isGoodFrame:!1,goodFramesCount:0,goodFramesThreshold:3,goodFramesThresholdMet:!1,lastFrameCapturedAt:null,frameCaptureRate:0,capturing:!1,captured:!1,captureFailed:!1},Pi=function(e,t){switch(t.type){case"configure":return p(p(p({},e),t.payload),{goodFramesCount:0,captureStartedAt:new Date,capturing:!1,captured:!1,captureFailed:!1});case"objectsDetected":var n=t.payload.prediction,r=n.detectedObjects,i=n.detectionScore,a=n.detectionThresholdMet,o=n.passportDetectionScore,s=n.passportDetectionThresholdMet,l=n.mrzDetectionScore,u=n.mrzDetectionThresholdMet,c=n.pdf417DetectionScore,d=n.pdf417DetectionThresholdMet,h=n.bestDocumentOrPassport,f=n.bestMrz,g=n.bestPdf417,m=n.focusScore,v=n.focusThresholdMet,y=n.frameWidth,b=n.frameHeight,w=new Date,x=0,E=e.goodFramesThreshold;e.lastFrameCapturedAt&&(x=1e3/(w.getTime()-e.lastFrameCapturedAt.getTime()))>0&&(E=Math.ceil(3*x));var S=gt.NONE;s?S=gt.PASSPORT:a&&(S=gt.ID_CARD);var T=!1;if(h){var k=h.bbox,C=k[0],A=k[1],R=k[2],_=k[3];C*=y,R*=y,T=(A*=b)>5&&A+(_*=b)+5<b&&(C>5||C<5&&C+R>.8*y)&&C+R+5<y}var I=!0===e.autoCaptureBarcodeRequired||"mobile"===e.autoCaptureBarcodeRequired&&kt(),D=e.barcodeScanningEnabled&&d&&I,F=D&&!e.barcodeResult,L=a&&T&&v,M=e.goodFramesCount;return L&&(M+=1),p(p({},e),{videoWidth:y,videoHeight:b,detectedObjects:r,bestDocument:h,bestMrz:f,bestPdf417:g,documentType:S,documentInBounds:T,documentDetectionScore:i,documentDetectionThresholdMet:a,mrzDetectionScore:l,mrzDetectionThresholdMet:u,pdf417DetectionScore:c,pdf417DetectionThresholdMet:d,passportPageDetectionScore:o,passportPageDetectionThresholdMet:s,focusScore:m,focusThresholdMet:v,shouldScanBarcode:D,waitingForBarcodeScan:F,isGoodFrame:L,goodFramesCount:M,goodFramesThreshold:E,goodFramesThresholdMet:M>=E,lastFrameCapturedAt:w,frameCaptureRate:x});case"barcodeScanned":return p(p({},e),{barcodeResult:t.payload.result,waitingForBarcodeScan:!1,autoCaptureBarcodeRequired:!1});case"barcodeScanFailed":var N=p(p({},e),{barcodeScanFailedAttempts:e.barcodeScanFailedAttempts+1});return N.barcodeScanFailedAttempts>=N.maxBarcodeScanAttempts&&(N.autoCaptureBarcodeRequired=!1,N.shouldScanBarcode=!1,N.waitingForBarcodeScan=!1),N;case"capturing":return p(p({},e),{capturing:!0,captured:!1,captureFailed:!1});case"captured":return p(p({},e),{capturing:!1,captured:!0,captureFailed:!1});case"captureFailed":return p(p({},e),{capturing:!1,captured:!1,captureFailed:!0});default:return e}},Bi=function(e){var t,r,i,a,o,s=e.requiredDocumentType,l=e.autoCaptureEnabled,c=void 0===l||l,d=e.autoCaptureScoreThreshold,h=void 0===d?.8:d,f=e.autoCaptureGoodFramesRequired,p=void 0===f?3:f,v=e.autoCaptureBarcodeRequired,y=void 0===v?"mobile":v,b=e.mrzDetectionScoreThreshold,w=void 0===b?.25:b,x=e.passportPageDetectionThreshold,E=void 0===x?.6:x,S=e.pdf417DetectionThreshold,T=void 0===S?.15:S,k=e.focusScoreThreshold,C=void 0===k?.3:k,A=e.barcodeScanningEnabled,R=void 0===A||A,_=e.maxBarcodeScanAttempts,I=void 0===_?10:_,D=e.onPrediction,F=e.onBarcodeScanned,L=e.onCapture,M=e.processingScreen,N=e.processingDelay,O=void 0===N?0:N,P=e.assets,B=void 0===P?{}:P,U=e.verbiage,$=void 0===U?{}:U,j=e.debugMode,G=void 0!==j&&j,z=Et(),q=z.ref,H=z.width,V=void 0===H?1:H,W=z.height,K=void 0===W?1:W,Y=n.useReducer(Pi,Oi),X=Y[0],J=Y[1],Z=n.useState(""),Q=Z[0],ee=Z[1],te=n.useState(!1),ne=te[0],re=te[1],ie=n.useContext(Ft),ae=ie.cameraRef,oe=ie.cameraReady,se=ie.takePhoto,le=ie.videoRef,ue=ie.videoLoaded,ce=ye().t,de=n.useRef(),he=n.useContext(hi),fe=he.ready,pe=he.working,ge=he.setThresholds,me=he.makePrediction,ve=he.onPredictionMade,be=he.detectionTime,we=he.focusPredictionTime,xe=he.getBestFrame,Ee=he.resetBestFrame;n.useEffect((function(){de.current=new Date}),[]),n.useEffect((function(){J({type:"configure",payload:{requiredDocumentType:s,goodFramesThreshold:p,autoCaptureBarcodeRequired:y,barcodeScanningEnabled:R,maxBarcodeScanAttempts:I}}),Ee(),ge({document:h,passport:E,mrz:w,pdf417:T,focus:C})}),[s,h,C,w,p,y,R,I,E,T,Ee,ge]);var Se=n.useRef(0),Te=n.useRef(!1);n.useEffect((function(){Te.current=ue&&oe&&fe&&!X.capturing&&!X.captured}),[oe,X.captured,X.capturing,fe,ue]);var ke=n.useState(null),Ce=ke[0],Ae=ke[1];n.useEffect((function(){if(fe&&oe&&ue)return Se.current=requestAnimationFrame((function e(){return g(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:if(!Te.current||pe.current)return[3,5];r.label=1;case 1:return r.trys.push([1,4,,5]),X.shouldScanBarcode?[4,se()]:[3,3];case 2:if(!(t=r.sent()))return Se.current=requestAnimationFrame(e),[2];Ae(t),r.label=3;case 3:return le.current&&me(le.current),[3,5];case 4:return n=r.sent(),console.error("error capturing frame",n),[3,5];case 5:return Se.current=requestAnimationFrame(e),[2]}}))}))})),function(){cancelAnimationFrame(Se.current)}}),[oe,me,fe,pe,X.shouldScanBarcode,se,ue,le]),n.useEffect((function(){ve((function(e){J({type:"objectsDetected",payload:{prediction:e}})}))}),[ve]),n.useEffect((function(){null==D||D({focusScore:X.focusScore,focusThresholdMet:X.focusThresholdMet,documentDetected:X.documentDetectionThresholdMet,documentType:X.documentType,documentScore:X.documentDetectionScore,mrzDetected:X.mrzDetectionThresholdMet,mrzScore:X.mrzDetectionScore})}),[D,X.bestPdf417,X.documentDetectionScore,X.documentDetectionThresholdMet,X.documentType,X.focusScore,X.focusThresholdMet,X.mrzDetectionScore,X.mrzDetectionThresholdMet]),n.useEffect((function(){g(void 0,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return X.shouldScanBarcode&&Ce?[4,It(Ce,null===(t=X.bestPdf417)||void 0===t?void 0:t.bbox)]:[3,2];case 1:(e=n.sent())?(J({type:"barcodeScanned",payload:{result:e}}),null==F||F(e)):J({type:"barcodeScanFailed"}),n.label=2;case 2:return[2]}}))}))}),[F,X.shouldScanBarcode,null===(t=X.bestPdf417)||void 0===t?void 0:t.bbox,se,Ce]);var Re=c&&X.goodFramesThresholdMet&&!X.capturing&&!X.captured&&!X.waitingForBarcodeScan&&Ui(X.captureStartedAt)>=3e3;n.useEffect((function(){g(void 0,void 0,void 0,(function(){var e,t,n,r,i,a,o,s,l;return m(this,(function(u){switch(u.label){case 0:return Re?(J({type:"capturing"}),[4,xe()]):[2];case 1:return(e=u.sent())?(re(!0),[4,(c=e,new Promise((function(e){var t=new Image;t.onload=function(){e([t.naturalWidth,t.naturalHeight])},t.src=URL.createObjectURL(c)})))]):(console.log("uh oh, i did not get a photo"),J({type:"captureFailed"}),[2]);case 2:return t=u.sent(),n=t[0],r=t[1],(i=document.createElement("canvas")).width=n,i.height=r,[4,createImageBitmap(e)];case 3:if(a=u.sent(),(n>1920&&r>1080||n>1080&&r>1920)&&X.barcodeResult){if(n>r?(i.width=1920,i.height=r*(1920/n)):(i.height=1920,i.width=n*(1920/r)),!(o=i.getContext("2d")))return[2];o.drawImage(a,0,0,i.width,i.height)}else{if(!(s=i.getContext("bitmaprenderer")))return[2];s.transferFromImageBitmap(a)}return l=i.toDataURL("image/jpeg",.92),ee(l),setTimeout((function(){var e,t=(new Date).getTime()-(null!==(e=de.current)&&void 0!==e?e:new Date).getTime();null==L||L(l,n,r,{autoCapture:"Y",captureTime:t}),J({type:"captured"}),re(!1)}),O),[2]}var c}))}))}),[xe,L,O,Re,X.barcodeResult]);var _e=Ii({enabled:G,pageWidth:V,pageHeight:K,videoWidth:X.videoWidth,videoHeight:X.videoHeight});return ne?M||u.default.createElement("div",null,"Processing..."):""!==Q?u.default.createElement("img",{src:Q,alt:"",style:{maxWidth:"100%",maxHeight:"100%"}}):($.instructionText=$.instructionText||ce("Scan the front of ID"),$.capturingText=$.capturingText||ce("Capturing..."),$.captureFailedText=$.captureFailedText||ce("Capture failed!"),u.default.createElement(Ze,{ref:q,className:"flex"},u.default.createElement(Ct,{width:V,height:K,instruction:X.captureFailed?$.captureFailedText:X.capturing?null==$?void 0:$.capturingText:$.instructionText,portraitGuidesImageUrl:B.portraitGuidesImageUrl,landscapeGuidesImageUrl:B.landscapeGuidesImageUrl,isMirrored:!(null===(r=ae.current)||void 0===r?void 0:r.isRearFacing),borderColor:X.isGoodFrame?"green":"white"}),G&&X.detectedObjects.length>0&&u.default.createElement(Ai,{$flipX:!(null===(i=ae.current)||void 0===i?void 0:i.isRearFacing)},X.detectedObjects.map((function(e,t){var n;return u.default.createElement(Di,{key:t,obj:e,scaling:_e,flipX:!(null===(n=ae.current)||void 0===n?void 0:n.isRearFacing)})}))),G&&u.default.createElement(Ci,null,ae.current?u.default.createElement(u.default.Fragment,null,"✅ Camera: ",null===(a=ae.current)||void 0===a?void 0:a.width,"x",null===(o=ae.current)||void 0===o?void 0:o.height):"❌ Camera not ready",u.default.createElement("br",null),X.frameCaptureRate>.75?"✅":"👎"," Frame Rate:"," ",Math.round(1e3*(X.frameCaptureRate+Number.EPSILON))/1e3," ","fps (",be,"ms doc detect, ",we,"ms focus)",u.default.createElement("br",null),fe?u.default.createElement(u.default.Fragment,null,X.documentDetectionThresholdMet?"✅":"❌"," Document Score: ",X.documentDetectionScore," (",X.documentType,")",u.default.createElement("br",null),X.documentInBounds?"✅":"❌"," Document In Bounds",u.default.createElement("br",null),X.focusThresholdMet?"✅":"❌"," Focus Score:"," ",X.focusScore,u.default.createElement("br",null),X.goodFramesThresholdMet?"✅":"❌"," Good Frame Count:"," ",X.goodFramesCount,"/",X.goodFramesThreshold,R&&X.autoCaptureBarcodeRequired?u.default.createElement(u.default.Fragment,null,u.default.createElement("br",null),X.barcodeResult?"✅":"❌"," Barcode Scanned (",_t()?"Native":"ZXing",","," ",X.barcodeScanFailedAttempts,"/",X.maxBarcodeScanAttempts," failed attempts)"):null):u.default.createElement(u.default.Fragment,null,"❌ Models not ready"))))},Ui=function(e){return e?Math.abs((new Date).getTime()-e.getTime()):0},$i=function(e){var t=e.accessBlockedImageUrl,r=void 0===t?li+"/camera-disable-icon.png":t,i=ye().t,a=n.useContext(Ft).retryCameraAccess,o=n.useRef(null),s=n.useRef(null);return n.useEffect((function(){var e,t;if(o.current)return s.current=pt(o.current),null===(e=s.current)||void 0===e||e.start(),null===(t=s.current)||void 0===t||t.setProgress(100),s.current.stop(),function(){var e;null===(e=s.current)||void 0===e||e.remove()}}),[]),u.default.createElement(rt,null,u.default.createElement("div",{style:{display:"flex",height:"100%"}},u.default.createElement(it,{style:{maxWidth:500,height:"auto",margin:"auto"}},u.default.createElement(at,{style:{flexGrow:0}},u.default.createElement("img",{src:r,alt:i("Camera access blocked")})),u.default.createElement("h3",null,i("Your camera permission is disabled")),u.default.createElement("p",{style:{lineHeight:1.5,marginBottom:50}},i("This application requires access to your camera to continue. Please accept the permission once prompted by the browser. If the browser does not prompt for camera permissions, you must go to settings and provide camera access to the current browser.")),u.default.createElement("button",{ref:o,className:"ladda-button","data-style":"expand-right",disabled:!1,style:{width:200,marginLeft:"auto",marginRight:"auto"},onClick:function(){a()}},u.default.createElement("span",{className:"ladda-label"},i("Retry"))))))},ji=function(e){var t=e.headingText,r=e.useContinuityCameraText,i=e.modelsWarmingUpText,a=e.cameraInitializingText,o=e.cameraAccessBlockedText,s=e.continueText,l=e.instructionImageUrl,c=void 0===l?li+"/WebSDK-Instruction-DL-Capture-3-Portrait.png":l,d=e.accessBlockedImageUrl,h=void 0===d?li+"/camera-disable-icon.png":d,f=e.onDismissed,p=ye().t,g=n.useRef(null),m=n.useRef(null),v=n.useContext(hi).ready,y=n.useContext(Ft),b=y.cameraReady,w=y.cameraAccessDenied,x=y.iphoneContinuityCameraAvailable,E=y.setIphoneContinuityCameraAllowed,S=n.useState(!1),T=S[0],k=S[1];return n.useEffect((function(){if(g.current){m.current=pt(g.current),m.current.start();var e=0,t=setInterval((function(){var t;e<.9&&(e+=.1),null===(t=m.current)||void 0===t||t.setProgress(e)}),250);return function(){var e;null===(e=m.current)||void 0===e||e.remove(),clearInterval(t)}}}),[]),n.useEffect((function(){var e;if(v&&b)return null===(e=m.current)||void 0===e||e.stop(),function(){return null};var t=setTimeout((function(){k(!1)}),500);return function(){clearTimeout(t)}}),[b,v]),T?u.default.createElement(u.default.Fragment,null):w?u.default.createElement($i,{accessBlockedImageUrl:h}):(t=t||p("Use your device camera to capture your ID"),r=r||p("Use your iPhone as a webcam"),i=i||p("Models warming up..."),a=a||p("Camera initializing..."),o=o||p("Camera access blocked"),s=s||p("Continue"),u.default.createElement(rt,null,u.default.createElement(it,null,u.default.createElement("h3",null,t),u.default.createElement(at,{style:{pointerEvents:"none"}},u.default.createElement("img",{alt:t,src:c})),u.default.createElement("div",{style:{paddingTop:26,height:48,marginTop:-48}},x&&u.default.createElement(u.default.Fragment,null,u.default.createElement("input",{id:"use-continuity-camera",type:"checkbox",defaultChecked:!0,onChange:function(e){E(e.target.checked)}}),u.default.createElement("label",{htmlFor:"use-continuity-camera"},r))),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"mint",disabled:!b||!v,ref:g,onClick:function(){k(!0),null==f||f()}},u.default.createElement("span",{className:"ladda-label"},w?o:b&&v?s:v?a:i)))))},Gi=function(e){var t,r=e.instructionText,i=e.frontPortraitGuidesImage,a=e.frontLandscapeGuidesImage,o=e.backPortraitGuidesImage,s=e.backLandscapeGuidesImage,l=ye().t,c=Et(),d=c.ref,h=c.width,f=void 0===h?1:h,g=c.height,m=void 0===g?1:g,v=n.useContext(Ft).cameraRef;r=r||l("Please flip your ID card...");var y=kt()?0:50,b=!(null===(t=v.current)||void 0===t?void 0:t.isRearFacing),w=n.useContext(St),x=w.orientation,E=w.wrapperRef,S=w.wrapperWidth,T=w.wrapperHeight,k=w.imageAspectRatio,C=w.wrapperAspectRatio,A=w.onImageLoaded,R=w.setDimensions;n.useEffect((function(){R({width:f,height:m})}),[m,R,f]);var _={height:T-2*y-8};k>=C&&(_={width:S-2*y-8});var I=n.useState(1),D=I[0],F=I[1],L=n.useState(0),M=L[0],N=L[1],O=["rotateY(".concat(M,"deg)")];b&&O.push("scaleX(-1)");var P=["rotateY(".concat(180-M,"deg)")];return b&&P.push("scaleX(-1)"),n.useEffect((function(){var e=function(){F(1),N(180),setTimeout((function(){F(0),N(0)}),1500)};setTimeout(e,250);var t=setInterval(e,2500);return function(){clearInterval(t)}}),[]),u.default.createElement(Ze,{ref:d,className:"flex"},u.default.createElement("div",{ref:E,style:{position:"absolute",zIndex:1e3,width:"100%",height:"100%"}},u.default.createElement("div",{style:{display:"flex",flexFlow:"column nowrap",height:"100%"}},u.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",flexGrow:1,textAlign:"center",color:"white",display:"flex",flexDirection:"column",justifyContent:"end"}},u.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12}},r)),u.default.createElement("div",{style:{position:"relative",display:"flex",flexFlow:"row nowrap",alignItems:"center",justifyItems:"center",maxWidth:"calc(100%)",maxHeight:"calc(100% - ".concat(2*y,"px - ").concat(8,"px)")}},u.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:y,flexGrow:1}}),u.default.createElement("div",{style:{maxWidth:"calc(100% - ".concat(2*y,"px - ").concat(8,"px)"),maxHeight:m-2*y-8}},u.default.createElement("div",{style:{position:"relative",border:"".concat(4,"px solid ").concat("white")}},u.default.createElement("img",{src:"portrait"===x?i:a,alt:"",onLoad:A,style:p({backfaceVisibility:"hidden",transition:"transform ".concat(D,"s"),transform:O.join(" "),transformStyle:"preserve-3d",position:"relative",top:0,left:0,display:"block"},_)}),u.default.createElement("img",{src:"portrait"===x?o:s,alt:"",style:p({backfaceVisibility:"hidden",transition:"transform ".concat(D,"s"),transform:P.join(" "),transformStyle:"preserve-3d",position:"absolute",top:0,left:0,display:"block"},_)}))),u.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:y,flexGrow:1}})),u.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",flexGrow:1,textAlign:"center",color:"white",display:"flex",flexDirection:"column",justifyContent:"end"}},u.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12,opacity:0}},r)))))},zi=function(e){var t=e.disabled,r=e.onClick,i=e.children,a=n.useRef(null),o=n.useRef(null),s=n.useRef(null);return n.useEffect((function(){if(a.current)return o.current=pt(a.current),function(){var e;null===(e=o.current)||void 0===e||e.remove()}}),[]),n.useEffect((function(){var e,n;if(o.current)if(t){o.current.start();var r=0;s.current=setInterval((function(){var e;r<.9&&(r+=.1),null===(e=o.current)||void 0===e||e.setProgress(r)}),1500)}else s.current&&(clearInterval(s.current),null===(e=o.current)||void 0===e||e.setProgress(1),null===(n=o.current)||void 0===n||n.stop())}),[t]),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"mint",disabled:t,ref:a,onClick:r},i)},qi=function(e){var t=e.capturedDocuments,r=e.onSubmitClick,i=e.onRetryClick,a=e.headingText,o=e.idCardFrontText,s=e.idCardBackText,l=e.passportText,c=e.instructionText,d=e.retryText,h=e.submittingText,f=e.submitText,p=n.useContext(qe).submissionStatus,g=ye().t,m=t.ID_CARD_FRONT,v=t.ID_CARD_BACK,y=t.PASSPORT;return a=a||g("ID Capture Successful"),o=o||g("ID Card Front"),s=s||g("ID Card Back"),l=l||g("Passport"),c=c||g("Verify the entire ID was captured clearly with no glare."),d=d||g("Retry"),h=h||g("Submitting..."),f=f||g("Done"),u.default.createElement(rt,null,u.default.createElement(it,null,u.default.createElement("h1",null,a),u.default.createElement(at,null,u.default.createElement(ot,{style:{paddingBottom:40}},m&&u.default.createElement("div",null,u.default.createElement("h3",null,o),u.default.createElement("img",{src:m.imageData,alt:o,width:m.width,height:m.height})),v&&u.default.createElement("div",null,u.default.createElement("h3",null,s),u.default.createElement("img",{src:v.imageData,alt:s,width:v.width,height:v.height})),y&&u.default.createElement("div",null,u.default.createElement("h3",null,l),u.default.createElement("img",{src:y.imageData,alt:l,width:y.width,height:y.height})))),u.default.createElement("p",{style:{fontSize:18}},c),u.default.createElement("div",{style:{paddingTop:15,textAlign:"center"}},u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"red",onClick:i,style:{marginRight:15}},u.default.createElement("span",{className:"ladda-label"},d)),u.default.createElement(zi,{onClick:r,disabled:p===je.SUBMITTING},p===je.SUBMITTING?h:f))))},Hi=function(){var e,t=n.useContext(Ft),r=t.videoRef,i=t.setVideoLoaded,a=t.cameraRef;n.useEffect((function(){i(!1)}),[i]),n.useEffect((function(){var e;r.current&&(null===(e=a.current)||void 0===e?void 0:e.stream)&&(r.current.srcObject=a.current.stream)}),[a,r]);var o=n.useCallback((function(){i(!0)}),[i]);return u.default.createElement(Vi,{autoPlay:!0,playsInline:!0,muted:!0,ref:r,onLoadedData:o,$isRearFacing:null===(e=a.current)||void 0===e?void 0:e.isRearFacing})},Vi=h.default.video(Mi||(Mi=y(["\n transform: ",";\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n object-fit: cover;\n"],["\n transform: ",";\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n object-fit: cover;\n"])),(function(e){return e.$isRearFacing?"":"scaleX(-1)"}));!function(e){e.CAPTURING="CAPTURING",e.COMPLETE="COMPLETE"}(Ni||(Ni={}));var Wi={captureState:Ni.CAPTURING,capturedDocuments:{},requestedDocumentType:gt.ID_CARD_FRONT,currentDocumentType:gt.NONE,differentDocumentTypeDetections:0,barcodeResult:null},Ki=function(e,t){var n;switch(t.type){case"predictionMade":var r=t.payload.prediction;return(i=p(p({},e),{currentDocumentType:r.documentType})).currentDocumentType===e.requestedDocumentType&&(i.differentDocumentTypeDetections=0),"PASSPORT"===r.documentType&&"PASSPORT"!==e.requestedDocumentType&&(i.requestedDocumentType=gt.PASSPORT),i;case"barcodeScanned":return p(p({},e),{barcodeResult:t.payload.result});case"imageCaptured":var i=p(p({},e),{capturedDocuments:p(p({},e.capturedDocuments),(n={},n[e.requestedDocumentType]=t.payload,n))});return"ID_CARD_FRONT"!==e.requestedDocumentType||e.capturedDocuments.ID_CARD_BACK?"ID_CARD_BACK"!==e.requestedDocumentType||e.capturedDocuments.ID_CARD_FRONT?i.captureState=Ni.COMPLETE:(console.log("moving back to the front!"),i.requestedDocumentType=gt.ID_CARD_FRONT):(console.log("moving on to back!"),i.requestedDocumentType=gt.ID_CARD_BACK),i;case"reset":return p({},Wi)}},Yi=function(e){var t=e.onSuccess,r=e.autoCaptureEnabled,i=void 0===r||r,a=e.autoCaptureGoodFramesRequired,o=void 0===a?3:a,s=e.autoCaptureBarcodeRequired,l=void 0===s?"mobile":s,c=e.barcodeScanningEnabled,d=void 0!==c&&c,h=e.idCardAutoCaptureScoreThreshold,f=void 0===h?.9:h,p=e.passportAutoCaptureScoreThreshold,v=void 0===p?.85:p,y=e.mrzDetectionScoreThreshold,b=void 0===y?.25:y,w=e.idCardFocusScoreThreshold,x=void 0===w?.3:w,E=e.passportFocusScoreThreshold,S=void 0===E?.3:E,T=e.assets,k=void 0===T?{}:T,C=e.verbiage,A=void 0===C?{}:C,R=e.debugMode,_=void 0!==R&&R,I=n.useReducer(Ki,Wi),D=I[0],F=I[1],L=n.useContext(Ft).releaseCameraAccess,M=n.useState(!1),N=M[0],O=M[1],P=n.useContext(qe),B=P.submissionStatus,U=P.submissionResponse,$=P.setIdFrontImage,j=P.setIdBackImage,G=P.setPassportImage,z=P.logIdFrontCaptureAttempt,q=P.logIdBackCaptureAttempt,H=ye().t,V=n.useRef();n.useEffect((function(){V.current=new Date}),[D.capturedDocuments.length]);var W=n.useCallback((function(e){var t;e.operationTime=(new Date).getTime()-(null!==(t=V.current)&&void 0!==t?t:new Date).getTime(),"ID_CARD_BACK"===D.requestedDocumentType?q(e):z(e)}),[q,z,D.requestedDocumentType]),K=n.useCallback((function(e){F({type:"predictionMade",payload:{prediction:e}})}),[]),Y=n.useCallback((function(e){F({type:"barcodeScanned",payload:{result:e}})}),[]),X=n.useCallback((function(e,t,n,r){W(r),F({type:"imageCaptured",payload:{imageData:e,width:t,height:n}})}),[W]),J=n.useCallback((function(){F({type:"reset"})}),[]);if(n.useEffect((function(){B!==je.READY&&L()}),[L,B]),U)return u.default.createElement(u.default.Fragment,null,u.default.createElement("h1",null,"Submission completed!"),u.default.createElement("pre",null,JSON.stringify(U,null,2)));k.idCardFrontPortraitGuidesImageUrl=k.idCardFrontPortraitGuidesImageUrl||"".concat(li,"/Shieldout-IDCard-Front-SVG-Portrait-2.svg"),k.idCardFrontLandscapeGuidesImageUrl=k.idCardFrontLandscapeGuidesImageUrl||"".concat(li,"/Shieldout-IDCard-Front-SVG-Landscape-2.svg"),k.idCardBackPortraitGuidesImageUrl=k.idCardBackPortraitGuidesImageUrl||"".concat(li,"/Shieldout-IDCard-Back-SVG-Portrait-2.svg"),k.idCardBackLandscapeGuidesImageUrl=k.idCardBackLandscapeGuidesImageUrl||"".concat(li,"/Shieldout-IDCard-Back-SVG-Landscape-2.svg"),k.passportPortraitGuidesImageUrl=k.passportPortraitGuidesImageUrl||"".concat(li,"/Shieldout-Passport-Front-SVG-Portrait-2.svg"),k.passportLandscapeGuidesImageUrl=k.passportLandscapeGuidesImageUrl||"".concat(li,"/Shieldout-Passport-Front-SVG-Landscape-2.svg"),k.loadingOverlayInstructionImageUrl=k.loadingOverlayInstructionImageUrl||"".concat(li,"/WebSDK-Instruction-DL-Capture-3-Portrait.png"),A.idCardFrontInstructionText=A.idCardFrontInstructionText||H("Scan the front of ID"),A.idCardBackInstructionText=A.idCardBackInstructionText||H("Scan the back of ID"),A.passportInstructionText=A.passportInstructionText||H("Scan the ID page of passport");var Z=u.default.createElement(Gi,{instructionText:A.flipIdInstructionText,frontPortraitGuidesImage:k.idCardFrontPortraitGuidesImageUrl,frontLandscapeGuidesImage:k.idCardFrontLandscapeGuidesImageUrl,backPortraitGuidesImage:k.idCardBackPortraitGuidesImageUrl,backLandscapeGuidesImage:k.idCardBackLandscapeGuidesImageUrl});return u.default.createElement(Ze,{className:"flex"},D.captureState!==Ni.COMPLETE&&u.default.createElement(Hi,null),N&&function(){switch(D.requestedDocumentType){case gt.ID_CARD_FRONT:return u.default.createElement(Bi,{key:Object.keys(D.capturedDocuments).length,requiredDocumentType:D.requestedDocumentType,autoCaptureEnabled:i,autoCaptureScoreThreshold:f,autoCaptureGoodFramesRequired:o,autoCaptureBarcodeRequired:l,barcodeScanningEnabled:!1,mrzDetectionScoreThreshold:b,focusScoreThreshold:x,onPrediction:K,onCapture:X,processingScreen:Z,processingDelay:3500,assets:{portraitGuidesImageUrl:k.idCardFrontPortraitGuidesImageUrl,landscapeGuidesImageUrl:k.idCardFrontLandscapeGuidesImageUrl},verbiage:{instructionText:A.idCardFrontInstructionText,capturingText:A.capturingText,captureFailedText:A.captureFailedText},debugMode:_});case gt.ID_CARD_BACK:return u.default.createElement(Bi,{key:Object.keys(D.capturedDocuments).length,requiredDocumentType:D.requestedDocumentType,autoCaptureEnabled:i,autoCaptureScoreThreshold:f,autoCaptureGoodFramesRequired:o,autoCaptureBarcodeRequired:l,barcodeScanningEnabled:d,mrzDetectionScoreThreshold:b,focusScoreThreshold:x,onPrediction:K,onBarcodeScanned:Y,onCapture:X,assets:{portraitGuidesImageUrl:k.idCardBackPortraitGuidesImageUrl,landscapeGuidesImageUrl:k.idCardBackLandscapeGuidesImageUrl},verbiage:{instructionText:A.idCardBackInstructionText,capturingText:A.capturingText,captureFailedText:A.captureFailedText},debugMode:_});case gt.PASSPORT:return u.default.createElement(Bi,{key:Object.keys(D.capturedDocuments).length,requiredDocumentType:D.requestedDocumentType,autoCaptureEnabled:i,autoCaptureScoreThreshold:v,mrzDetectionScoreThreshold:b,autoCaptureGoodFramesRequired:o,autoCaptureBarcodeRequired:l,barcodeScanningEnabled:!1,focusScoreThreshold:S,onPrediction:K,onBarcodeScanned:Y,onCapture:X,assets:{portraitGuidesImageUrl:k.passportPortraitGuidesImageUrl,landscapeGuidesImageUrl:k.passportLandscapeGuidesImageUrl},verbiage:{instructionText:A.passportInstructionText,capturingText:A.capturingText,captureFailedText:A.captureFailedText},debugMode:_});default:return null}}(),!N&&u.default.createElement(ji,{headingText:A.loadingOverlayHeadingText,useContinuityCameraText:A.loadingOverlayUseContinuityCameraText,modelsWarmingUpText:A.loadingOverlayModelsWarmingUpText,cameraInitializingText:A.loadingOverlayCameraInitializingText,cameraAccessBlockedText:A.loadingOverlayCameraAccessBlockedText,continueText:A.loadingOverlayContinueText,instructionImageUrl:k.loadingOverlayInstructionImageUrl,onDismissed:function(){O(!0)}}),D.captureState===Ni.COMPLETE&&u.default.createElement(qi,{capturedDocuments:D.capturedDocuments,barcodeResult:D.barcodeResult,onSubmitClick:function(){return g(void 0,void 0,void 0,(function(){var e,n,r,i,a,o,s,l,u;return m(this,(function(c){switch(c.label){case 0:return n=D.capturedDocuments.ID_CARD_BACK,r=D.capturedDocuments.PASSPORT,(a=e=D.capturedDocuments.ID_CARD_FRONT)?[4,We(e.imageData)]:[3,2];case 1:a=c.sent(),c.label=2;case 2:return i=a,(s=n)?[4,We(n.imageData)]:[3,4];case 3:s=c.sent(),c.label=4;case 4:return o=s,(u=r)?[4,We(r.imageData)]:[3,6];case 5:u=c.sent(),c.label=6;case 6:return l=u,$(i),j(o),G(l),L(),setTimeout((function(){null==t||t({idFrontImage:i,idBackImage:o,passportImage:l})}),0),[2]}}))}))},onRetryClick:J,headingText:A.successHeadingText,idCardFrontText:A.successIdCardFrontText,idCardBackText:A.successIdCardBackText,passportText:A.successPassportText,instructionText:A.successInstructionText,retryText:A.successRetryText,submittingText:A.successSubmittingText,submitText:A.successSubmitText}))},Xi=function(e){var t=e.borderWidth,n=e.borderColor;return u.default.createElement("div",{style:{position:"absolute",zIndex:1e3,width:"100%",height:"100%",display:"flex"}},u.default.createElement("div",{style:{borderWidth:void 0===t?3:t,borderColor:void 0===n?"white":n,borderStyle:"solid",borderRadius:"50%",aspectRatio:"1 / 1.618",height:"50%",margin:"auto"}}))},Ji=self;function Zi(e,t){e=e.split(".");var n,r=Ji;e[0]in r||void 0===r.execScript||r.execScript("var "+e[0]);for(;e.length&&(n=e.shift());)e.length||void 0===t?r=r[n]&&r[n]!==Object.prototype[n]?r[n]:r[n]={}:r[n]=t}function Qi(e){return e}function ea(){throw Error("Invalid UTF8")}function ta(e,t){return t=String.fromCharCode.apply(null,t),null==e?t:e+t}let na,ra;const ia="undefined"!=typeof TextDecoder;let aa;const oa="undefined"!=typeof TextEncoder;function sa(e){if(oa)e=(aa||=new TextEncoder).encode(e);else{let n=0;const r=new Uint8Array(3*e.length);for(let i=0;i<e.length;i++){var t=e.charCodeAt(i);if(128>t)r[n++]=t;else{if(2048>t)r[n++]=t>>6|192;else{if(55296<=t&&57343>=t){if(56319>=t&&i<e.length){const a=e.charCodeAt(++i);if(56320<=a&&57343>=a){r[n++]=(t=1024*(t-55296)+a-56320+65536)>>18|240,r[n++]=t>>12&63|128,r[n++]=t>>6&63|128,r[n++]=63&t|128;continue}i--}t=65533}r[n++]=t>>12|224,r[n++]=t>>6&63|128}r[n++]=63&t|128}}e=n===r.length?r:r.subarray(0,n)}return e}var la,ua;e:{for(var ca=["CLOSURE_FLAGS"],da=Ji,ha=0;ha<ca.length;ha++)if(null==(da=da[ca[ha]])){ua=null;break e}ua=da}var fa,pa=ua&&ua[610401301];la=null!=pa&&pa;const ga=Ji.navigator;function ma(e){return!!la&&!!fa&&fa.brands.some((({brand:t})=>t&&-1!=t.indexOf(e)))}function va(e){var t;return(t=Ji.navigator)&&(t=t.userAgent)||(t=""),-1!=t.indexOf(e)}function ya(){return!!la&&!!fa&&0<fa.brands.length}function ba(){return ya()?ma("Chromium"):(va("Chrome")||va("CriOS"))&&!(!ya()&&va("Edge"))||va("Silk")}fa=ga&&ga.userAgentData||null;var wa=!ya()&&(va("Trident")||va("MSIE"));!va("Android")||ba(),ba(),va("Safari")&&(ba()||!ya()&&va("Coast")||!ya()&&va("Opera")||!ya()&&va("Edge")||(ya()?ma("Microsoft Edge"):va("Edg/"))||ya()&&ma("Opera"));var xa={},Ea=null;function Sa(){if(!Ea){Ea={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=e.concat(t[n].split(""));xa[n]=r;for(var i=0;i<r.length;i++){var a=r[i];void 0===Ea[a]&&(Ea[a]=i)}}}}var Ta="undefined"!=typeof Uint8Array,ka=!wa&&"function"==typeof btoa;function Ca(e){if(!ka){var t;void 0===t&&(t=0),Sa(),t=xa[t];var n=Array(Math.floor(e.length/3)),r=t[64]||"";let l=0,u=0;for(;l<e.length-2;l+=3){var i=e[l],a=e[l+1],o=e[l+2],s=t[i>>2];n[u++]=s+(i=t[(3&i)<<4|a>>4])+(a=t[(15&a)<<2|o>>6])+(o=t[63&o])}switch(s=0,o=r,e.length-l){case 2:o=t[(15&(s=e[l+1]))<<2]||r;case 1:n[u]=t[(e=e[l])>>2]+t[(3&e)<<4|s>>4]+o+r}return n.join("")}for(t="",n=0,r=e.length-10240;n<r;)t+=String.fromCharCode.apply(null,e.subarray(n,n+=10240));return t+=String.fromCharCode.apply(null,n?e.subarray(n):e),btoa(t)}const Aa=/[-_.]/g,Ra={"-":"+",_:"/",".":"="};function _a(e){return Ra[e]||""}function Ia(e){if(!ka)return function(e){var t=e.length,n=3*t/4;n%3?n=Math.floor(n):-1!="=.".indexOf(e[t-1])&&(n=-1!="=.".indexOf(e[t-2])?n-2:n-1);var r=new Uint8Array(n),i=0;return function(e,t){function n(t){for(;r<e.length;){var n=e.charAt(r++),i=Ea[n];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return t}Sa();for(var r=0;;){var i=n(-1),a=n(0),o=n(64),s=n(64);if(64===s&&-1===i)break;t(i<<2|a>>4),64!=o&&(t(a<<4&240|o>>2),64!=s&&t(o<<6&192|s))}}(e,(function(e){r[i++]=e})),i!==n?r.subarray(0,i):r}(e);Aa.test(e)&&(e=e.replace(Aa,_a)),e=atob(e);const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function Da(e){return Ta&&null!=e&&e instanceof Uint8Array}let Fa;function La(){return Fa||=new Uint8Array(0)}var Ma={};let Na;function Oa(e){if(e!==Ma)throw Error("illegal external caller")}function Pa(){return Na||=new Ua(null,Ma)}function Ba(e){Oa(Ma);var t=e.L;return null==(t=null==t||Da(t)?t:"string"==typeof t?Ia(t):null)?t:e.L=t}var Ua=class{constructor(e,t){if(Oa(t),this.L=e,null!=e&&0===e.length)throw Error("ByteString should be constructed with non-empty values")}fa(){const e=Ba(this);return e?new Uint8Array(e):La()}};function $a(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function ja(){return Error("Failed to read varint, encoding is invalid.")}function Ga(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function za(e){return 0==e.length?Pa():new Ua(e,Ma)}function qa(e){if("string"==typeof e)return{buffer:Ia(e),G:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),G:!1};if(e.constructor===Uint8Array)return{buffer:e,G:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),G:!1};if(e.constructor===Ua)return{buffer:Ba(e)||La(),G:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),G:!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")}const Ha="function"==typeof Uint8Array.prototype.slice;let Va,Wa=0,Ka=0;function Ya(e){const t=0>e;let n=(e=Math.abs(e))>>>0;if(e=Math.floor((e-n)/4294967296),t){const[t,r]=eo(n,e);e=r,n=t}Wa=n>>>0,Ka=e>>>0}function Xa(e){const t=Va||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),Ka=0,Wa=t.getUint32(0,!0)}function Ja(e,t){return 4294967296*t+(e>>>0)}function Za(e,t){const n=2147483648&t;return n&&(t=~t>>>0,0==(e=1+~e>>>0)&&(t=t+1>>>0)),e=Ja(e,t),n?-e:e}function Qa(e){if(16>e.length)Ya(Number(e));else if("function"==typeof BigInt)e=BigInt(e),Wa=Number(e&BigInt(4294967295))>>>0,Ka=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+("-"===e[0]);Ka=Wa=0;const n=e.length;for(let r=t,i=(n-t)%6+t;i<=n;r=i,i+=6){const t=Number(e.slice(r,i));Ka*=1e6,Wa=1e6*Wa+t,4294967296<=Wa&&(Ka+=Math.trunc(Wa/4294967296),Ka>>>=0,Wa>>>=0)}if(t){const[e,t]=eo(Wa,Ka);Wa=e,Ka=t}}}function eo(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function to(e,t,{O:n=!1}={}){e.O=n,t&&(t=qa(t),e.h=t.buffer,e.s=t.G,e.v=0,e.l=e.h.length,e.g=e.v)}function no(e,t){if(e.g=t,t>e.l)throw Ga(e.l,t)}function ro(e,t){let n,r=0,i=0,a=0;const o=e.h;let s=e.g;do{n=o[s++],r|=(127&n)<<a,a+=7}while(32>a&&128&n);for(32<a&&(i|=(127&n)>>4),a=3;32>a&&128&n;a+=7)n=o[s++],i|=(127&n)<<a;if(no(e,s),128>n)return t(r>>>0,i>>>0);throw ja()}function io(e){let t=0,n=e.g;const r=n+10,i=e.h;for(;n<r;){const r=i[n++];if(t|=r,0==(128&r))return no(e,n),!!(127&t)}throw ja()}function ao(e){var t=e.h;const n=e.g,r=t[n],i=t[n+1],a=t[n+2];return t=t[n+3],no(e,e.g+4),(r<<0|i<<8|a<<16|t<<24)>>>0}function oo(e,t){if(0>t)throw Error(`Tried to read a negative byte length: ${t}`);const n=e.g,r=n+t;if(r>e.l)throw Ga(t,e.l-n);return e.g=r,n}function so(e,t){if(0==t)return Pa();var n=oo(e,t);return e.O&&e.s?n=e.h.subarray(n,n+t):(e=e.h,n=n===(t=n+t)?La():Ha?e.slice(n,t):new Uint8Array(e.subarray(n,t))),za(n)}var lo=class{constructor(e,t){this.h=null,this.s=!1,this.g=this.l=this.v=0,to(this,e,t)}m(){const e=this.h;let t=this.g,n=e[t++],r=127&n;if(128&n&&(n=e[t++],r|=(127&n)<<7,128&n&&(n=e[t++],r|=(127&n)<<14,128&n&&(n=e[t++],r|=(127&n)<<21,128&n&&(n=e[t++],r|=n<<28,128&n&&128&e[t++]&&128&e[t++]&&128&e[t++]&&128&e[t++]&&128&e[t++])))))throw ja();return no(this,t),r}j(){return this.m()>>>0}A(){var e=ao(this);const t=2*(e>>31)+1,n=e>>>23&255;return e&=8388607,255==n?e?NaN:1/0*t:0==n?t*Math.pow(2,-149)*e:t*Math.pow(2,n-150)*(e+Math.pow(2,23))}C(){return this.m()}},uo=[];function co(e){var t=e.g;if(t.g==t.l)return!1;e.l=e.g.g;var n=e.g.j();if(t=n>>>3,!(0<=(n&=7)&&5>=n))throw $a(n,e.l);if(1>t)throw Error(`Invalid field number: ${t} (at position ${e.l})`);return e.m=t,e.h=n,!0}function ho(e){switch(e.h){case 0:0!=e.h?ho(e):io(e.g);break;case 1:no(e=e.g,e.g+8);break;case 2:if(2!=e.h)ho(e);else{var t=e.g.j();no(e=e.g,e.g+t)}break;case 5:no(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!co(e))throw Error("Unmatched start-group tag: stream EOF");if(4==e.h){if(e.m!=t)throw Error("Unmatched end-group tag");break}ho(e)}break;default:throw $a(e.h,e.l)}}function fo(e,t,n){const r=e.g.l,i=e.g.j(),a=e.g.g+i;let o=a-r;if(0>=o&&(e.g.l=a,n(t,e,void 0,void 0,void 0),o=a-e.g.g),o)throw Error(`Message parsing ended unexpectedly. Expected to read ${i} bytes, instead read ${i-o} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=a,e.g.l=r,t}function po(e){var t=e.g.j(),n=oo(e=e.g,t);if(e=e.h,ia){var r,i=e;(r=ra)||(r=ra=new TextDecoder("utf-8",{fatal:!0})),e=n+t,i=0===n&&e===i.length?i:i.subarray(n,e);try{var a=r.decode(i)}catch(e){if(void 0===na){try{r.decode(new Uint8Array([128]))}catch(e){}try{r.decode(new Uint8Array([97])),na=!0}catch(e){na=!1}}throw!na&&(ra=void 0),e}}else{t=(a=n)+t,n=[];let s,l=null;for(;a<t;){var o=e[a++];128>o?n.push(o):224>o?a>=t?ea():(s=e[a++],194>o||128!=(192&s)?(a--,ea()):n.push((31&o)<<6|63&s)):240>o?a>=t-1?ea():(s=e[a++],128!=(192&s)||224===o&&160>s||237===o&&160<=s||128!=(192&(i=e[a++]))?(a--,ea()):n.push((15&o)<<12|(63&s)<<6|63&i)):244>=o?a>=t-2?ea():(s=e[a++],128!=(192&s)||0!=s-144+(o<<28)>>30||128!=(192&(i=e[a++]))||128!=(192&(r=e[a++]))?(a--,ea()):(o=(7&o)<<18|(63&s)<<12|(63&i)<<6|63&r,n.push(55296+((o-=65536)>>10&1023),56320+(1023&o)))):ea(),8192<=n.length&&(l=ta(l,n),n.length=0)}a=ta(l,n)}return a}function go(e){const t=e.g.j();return so(e.g,t)}function mo(e,t,n){var r=e.g.j();for(r=e.g.g+r;e.g.g<r;)n.push(t.call(e.g))}var vo=[];function yo(e){return e?/^\d+$/.test(e)?(Qa(e),new bo(Wa,Ka)):null:wo||=new bo(0,0)}var bo=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let wo;function xo(e){return e?/^-?\d+$/.test(e)?(Qa(e),new Eo(Wa,Ka)):null:So||=new Eo(0,0)}var Eo=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let So;function To(e,t,n){for(;0<n||127<t;)e.g.push(127&t|128),t=(t>>>7|n<<25)>>>0,n>>>=7;e.g.push(t)}function ko(e,t){for(;127<t;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function Co(e,t){if(0<=t)ko(e,t);else{for(let n=0;9>n;n++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function Ao(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function Ro(e,t){0!==t.length&&(e.l.push(t),e.h+=t.length)}function _o(e,t,n){ko(e.g,8*t+n)}function Io(e,t){return _o(e,t,2),t=e.g.end(),Ro(e,t),t.push(e.h),t}function Do(e,t){var n=t.pop();for(n=e.h+e.g.length()-n;127<n;)t.push(127&n|128),n>>>=7,e.h++;t.push(n),e.h++}function Fo(e,t,n){_o(e,t,2),ko(e.g,n.length),Ro(e,e.g.end()),Ro(e,n)}function Lo(e,t,n,r){null!=n&&(t=Io(e,t),r(n,e),Do(e,t))}class Mo{constructor(e,t,n){this.g=e,this.h=t,this.l=n}}function No(e){return Array.prototype.slice.call(e)}const Oo="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():void 0;var Po=Oo?(e,t)=>{e[Oo]|=t}:(e,t)=>{void 0!==e.g?e.g|=t:Object.defineProperties(e,{g:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function Bo(e){const t=$o(e);1!=(1&t)&&(Object.isFrozen(e)&&(e=No(e)),Go(e,1|t))}var Uo=Oo?(e,t)=>{e[Oo]&=~t}:(e,t)=>{void 0!==e.g&&(e.g&=~t)},$o=Oo?e=>0|e[Oo]:e=>0|e.g,jo=Oo?e=>e[Oo]:e=>e.g,Go=Oo?(e,t)=>{e[Oo]=t}:(e,t)=>{void 0!==e.g?e.g=t:Object.defineProperties(e,{g:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function zo(e){return Po(e,1),e}function qo(e){return Po(e,34),e}function Ho(e,t){Go(t,-255&(0|e))}function Vo(e,t){Go(t,-221&(34|e))}function Wo(e){return 0==(e=e>>11&1023)?536870912:e}var Ko,Yo={};function Xo(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&e.constructor===Object}function Jo(e,t,n){if(null!=e)if("string"==typeof e)e=e?new Ua(e,Ma):Pa();else if(e.constructor!==Ua)if(Da(e))e=n?za(e):e.length?new Ua(new Uint8Array(e),Ma):Pa();else{if(!t)throw Error();e=void 0}return e}const Zo=[];function Qo(e){if(2&e)throw Error()}Go(Zo,39),Ko=Object.freeze(Zo);class es{constructor(e,t,n){this.l=0,this.g=e,this.h=t,this.m=n}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 es(this.g,this.h,this.m)}}var ts={};let ns,rs;function is(e,t){(t=ns?t[ns]:void 0)&&(e[ns]=No(t))}function as(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function os(e){return null==e?e:"number"==typeof e||"NaN"===e||"Infinity"===e||"-Infinity"===e?Number(e):void 0}function ss(e){return null==e?e:"boolean"==typeof e||"number"==typeof e?!!e:void 0}function ls(e){return"number"==typeof e&&Number.isFinite(e)||!!e&&"string"==typeof e&&isFinite(e)}function us(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function cs(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function ds(e){if("string"!=typeof e)throw Error();return e}function hs(e){if(null!=e&&"string"!=typeof e)throw Error();return e}function fs(e){return null==e||"string"==typeof e?e:void 0}function ps(e,t,n,r){var i=!1;return null==e||"object"!=typeof e||(i=Array.isArray(e))||e.K!==Yo?i?(0===(i=n=$o(e))&&(i|=32&r),(i|=2&r)!==n&&Go(e,i),new t(e)):(n?2&r?(e=t[gs])?t=e:(qo((e=new t).u),t=t[gs]=e):t=new t:t=void 0,t):e}const gs="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():"di";function ms(e){return e}function vs(e,t,n){return"string"==typeof(e="number"==(t=typeof e)||"string"===t?e:n?0:void 0)&&(n=+e,Number.isSafeInteger(n))?n:e}let ys,bs;function ws(e){switch(typeof e){case"number":return 0<e?void 0:0===e?bs||=[0,void 0]:[-e,void 0];case"string":return[0,e];case"object":return e}}function xs(e,t){return Es(e,t[0],t[1])}function Es(e,t,n){if(null==e&&(e=ys),ys=void 0,null==e){var r=96;n?(e=[n],r|=512):e=[],t&&(r=-2095105&r|(1023&t)<<11)}else{if(!Array.isArray(e))throw Error();if(64&(r=$o(e)))return rs&&delete e[rs],e;if(r|=64,n&&(r|=512,n!==e[0]))throw Error();e:{var i=(n=e).length;if(i){const e=i-1;var a=n[e];if(Xo(a)){1024<=(i=e-(t=+!!(512&(r|=256))-1))&&(Ss(n,t,a),i=1023),r=-2095105&r|(1023&i)<<11;break e}}t&&(a=+!!(512&r)-1,1024<(t=Math.max(t,i-a))&&(Ss(n,a,{}),r|=256,t=1023),r=-2095105&r|(1023&t)<<11)}}return Go(e,r),e}function Ss(e,t,n){const r=1023+t,i=e.length;for(let a=r;a<i;a++){const r=e[a];null!=r&&r!==n&&(n[a-t]=r)}e.length=r+1,e[r]=n}function Ts(e){if(2&e.g)throw Error("Cannot mutate an immutable Map")}var ks=class extends Map{constructor(e,t,n=ms,r=ms){super();let i=$o(e);i|=64,Go(e,i),this.g=i,this.l=t,this.h=n||ms,this.j=this.l?Cs:r||ms;for(let a=0;a<e.length;a++){const o=e[a],s=n(o[0],!1,!0);let l=o[1];t?void 0===l&&(l=null):l=r(o[1],!1,!0,void 0,void 0,i),super.set(s,l)}}s(e=As){return this.m(e)}m(e=As){const t=[],n=super.entries();for(var r;!(r=n.next()).done;)(r=r.value)[0]=e(r[0]),r[1]=e(r[1]),t.push(r);return t}clear(){Ts(this),super.clear()}delete(e){return Ts(this),super.delete(this.h(e,!0,!1))}entries(){var e=this.A();return new es(e,Rs,this)}keys(){return this.C()}values(){var e=this.A();return new es(e,ks.prototype.get,this)}forEach(e,t){super.forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))}set(e,t){return Ts(this),null==(e=this.h(e,!0,!1))?this:null==t?(super.delete(e),this):super.set(e,this.j(t,!0,!0,this.l,!1,this.g))}H(e){const t=this.h(e[0],!1,!0);e=e[1],e=this.l?void 0===e?null:e:this.j(e,!1,!0,void 0,!1,this.g),super.set(t,e)}has(e){return super.has(this.h(e,!1,!1))}get(e){e=this.h(e,!1,!1);const t=super.get(e);if(void 0!==t){var n=this.l;return n?((n=this.j(t,!1,!0,n,this.v,this.g))!==t&&super.set(e,n),n):t}}A(){return Array.from(super.keys())}C(){return super.keys()}[Symbol.iterator](){return this.entries()}};function Cs(e,t,n,r,i,a){return e=ps(e,r,n,a),i&&(e=Os(e)),e}function As(e){return e}function Rs(e){return[e,this.get(e)]}function _s(e,t,n,r,i,a){if(null!=e){if(Array.isArray(e))e=i&&0==e.length&&1&$o(e)?void 0:a&&2&$o(e)?e:Is(e,t,n,void 0!==r,i,a);else if(Xo(e)){const o={};for(let s in e)o[s]=_s(e[s],t,n,r,i,a);e=o}else e=t(e,r);return e}}function Is(e,t,n,r,i,a){const o=r||n?$o(e):0;r=r?!!(32&o):void 0;const s=No(e);for(let e=0;e<s.length;e++)s[e]=_s(s[e],t,n,r,i,a);return n&&(is(s,e),n(o,s)),s}function Ds(e){return _s(e,Fs,void 0,void 0,!1,!1)}function Fs(e){return e.K===Yo?e.toJSON():e instanceof ks?e.s(Ds):function(e){switch(typeof e){case"number":return isFinite(e)?e:String(e);case"boolean":return e?1:0;case"object":if(e&&!Array.isArray(e)){if(Da(e))return Ca(e);if(e instanceof Ua){const t=e.L;return null==t?"":"string"==typeof t?t:e.L=Ca(t)}if(e instanceof ks)return e.s()}}return e}(e)}function Ls(e,t,n=Vo){if(null!=e){if(Ta&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){const r=$o(e);return 2&r?e:!t||68&r||!(32&r||0===r)?Is(e,Ls,4&r?Vo:n,!0,!1,!0):(Go(e,34|r),e)}return e.K===Yo?e=2&(n=jo(t=e.u))?e:Ms(e,t,n,!0):e instanceof ks&&(t=qo(e.m(Ls)),e=new ks(t,e.l,e.h,e.j)),e}}function Ms(e,t,n,r){return e=e.constructor,ys=t=Ns(t,n,r),t=new e(t),ys=void 0,t}function Ns(e,t,n){const r=n||2&t?Vo:Ho,i=!!(32&t);return e=function(e,t,n){const r=No(e);var i=r.length;const a=256&t?r[i-1]:void 0;for(i+=a?-1:0,t=512&t?1:0;t<i;t++)r[t]=n(r[t]);if(a){t=r[t]={};for(const e in a)t[e]=n(a[e])}return is(r,e),r}(e,t,(e=>Ls(e,i,r))),Po(e,32|(n?2:0)),e}function Os(e){const t=e.u,n=jo(t);return 2&n?Ms(e,t,n,!1):e}function Ps(e,t){return Bs(e=e.u,jo(e),t)}function Bs(e,t,n,r){if(-1===n)return null;if(n>=Wo(t)){if(256&t)return e[e.length-1][n]}else{var i=e.length;if(r&&256&t&&null!=(r=e[i-1][n]))return r;if((t=n+(+!!(512&t)-1))<i)return e[t]}}function Us(e,t,n,r){const i=e.u,a=jo(i);return Qo(a),$s(i,a,t,n,r),e}function $s(e,t,n,r,i){var a=Wo(t);if(n>=a||i){if(i=t,256&t)a=e[e.length-1];else{if(null==r)return;a=e[a+(+!!(512&t)-1)]={},i|=256}a[n]=r,i!==t&&Go(e,i)}else e[n+(+!!(512&t)-1)]=r,256&t&&n in(e=e[e.length-1])&&delete e[n]}function js(e,t,n,r,i){var a=2&t;let o=Bs(e,t,n,i);Array.isArray(o)||(o=Ko);const s=$o(o);if(1&s||zo(o),a)2&s||qo(o),1&r||Object.freeze(o);else{a=!(2&r);const l=2&s;1&r||!l?a&&32&s&&!l&&Uo(o,32):(o=zo(No(o)),$s(e,t,n,o,i))}return o}function Gs(e,t){const n=jo(e=e.u),r=Bs(e,n,t),i=os(r);return null!=i&&i!==r&&$s(e,n,t,i),i}function zs(e){const t=jo(e=e.u),n=Bs(e,t,1),r=Jo(n,!0,!!(34&t));return null!=r&&r!==n&&$s(e,t,1,r),r}function qs(e,t,n){const r=jo(e=e.u),i=2&r;let a=js(e,r,t,1),o=$o(a);if(!(4&o)){Object.isFrozen(a)&&(o=0,a=No(a),$s(e,r,t,a));let s=0,l=0;for(;s<a.length;s++){const e=n(a[s]);null!=e&&(a[l++]=e)}l<s&&(a.length=l),o|=5,i&&(o|=34),Go(a,o),2&o&&Object.freeze(a)}return!i&&(2&o||Object.isFrozen(a))&&(a=No(a),Po(a,5),$s(e,r,t,a)),a}let Hs;function Vs(){return Hs??=new ks(qo([]),void 0,void 0,void 0,ts)}function Ws(e){e=No(e);for(let t=0;t<e.length;t++){const n=e[t]=No(e[t]);Array.isArray(n[1])&&(n[1]=qo(n[1]))}return e}function Ks(e,t,n){{const r=jo(e=e.u);if(Qo(r),null==n)$s(e,r,t);else{if(!(4&$o(n))){Object.isFrozen(n)&&(n=No(n));for(let e=0;e<n.length;e++)n[e]=ds(n[e]);Go(n,5)}$s(e,r,t,n)}}}function Ys(e,t){return Xs(e=e.u,jo(e),Oc)===t?t:-1}function Xs(e,t,n){let r=0;for(let i=0;i<n.length;i++){const a=n[i];null!=Bs(e,t,a)&&(0!==r&&$s(e,t,r),r=a)}return r}function Js(e,t,n,r){const i=jo(e);Qo(i);const a=Bs(e,i,n,r);let o;if(null!=a&&a.K===Yo)return(t=Os(a))!==a&&$s(e,i,n,t,r),t.u;if(Array.isArray(a)){const e=$o(a);o=2&e?Ns(a,e,!1):a,o=xs(o,t)}else o=xs(void 0,t);return o!==a&&$s(e,i,n,o,r),o}function Zs(e,t,n,r){const i=jo(e=e.u),a=Bs(e,i,n,r);return(t=ps(a,t,!1,i))!==a&&null!=t&&$s(e,i,n,t,r),t}function Qs(e,t,n,r=!1){if(null==(t=Zs(e,t,n,r)))return t;const i=jo(e=e.u);if(!(2&i)){const a=Os(t);a!==t&&$s(e,i,n,t=a,r)}return t}function el(e,t,n,r,i){var a=!!(2&t),o=js(e,t,r,1);if(o===Ko||!(4&$o(o))){var s=o;o=!!(2&t);var l=!!(2&$o(s));a=s,!o&&l&&(s=No(s));var u=t|(l?2:0);l=l||void 0;let c=0,d=0;for(;c<s.length;c++){const e=ps(s[c],n,!1,u);void 0!==e&&(l=l||2&jo(e.u),s[d++]=e)}return d<c&&(s.length=d),u=5|(s=$o(n=s)),s!=(l=l?-9&u:8|u)&&(Object.isFrozen(n)&&(n=No(n)),Go(n,l)),a!==(s=n)&&$s(e,t,r,s),(o&&2!==i||1===i)&&Object.freeze(s),s}return 3===i||(a?2===i&&(i=$o(o),o=No(o),Go(o,i),$s(e,t,r,o)):(a=Object.isFrozen(o),1===i?a||Object.freeze(o):(n=-35&(i=$o(o)),a&&(i=0,$s(e,t,r,o=No(o))),i!==n&&Go(o,n)))),o}function tl(e,t,n){var r=e.u;const i=jo(r);if(t=el(r,i,t,n,(e=!!(2&i))?1:2),!(e||8&$o(t))){for(n=0;n<t.length;n++)(e=t[n])!==(r=Os(e))&&(t[n]=r);Po(t,8)}return t}function nl(e,t,n,r,i){return null==r&&(r=void 0),Us(e,n,r,i)}function rl(e,t,n,r){null==r&&(r=void 0);const i=jo(e=e.u);Qo(i),(n=Xs(e,i,n))&&n!==t&&null!=r&&$s(e,i,n),$s(e,i,t,r)}function il(e,t,n){const r=jo(e=e.u);Qo(r),e=el(e,r,t,1,2),t=null!=n?n:new t,e.push(t),t.G()&&Uo(e,8)}function al(e,t){return us(Ps(e,t))}function ol(e){return null==(e=Ps(e,2))||ls(e)?e:void 0}function sl(e,t){return fs(Ps(e,t))}function ll(e){return e??0}function ul(e,t){return ll(Gs(e,t))}function cl(e,t,n){if(null!=n){if("boolean"!=typeof n)throw e=typeof n,Error(`Expected boolean but got ${"object"!=e?e:n?Array.isArray(n)?"array":e:"null"}: ${n}`);n=!!n}Us(e,t,n)}function dl(e,t,n){if(null!=n){if("number"!=typeof n)throw as(e=Error(),"warning"),e;if(!Number.isFinite(n)){const e=Error();as(e,"incident"),function(e){Ji.setTimeout((()=>{throw e}),0)}(e)}}Us(e,t,n)}function hl(e,t,n){if(null!=n&&"number"!=typeof n)throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);Us(e,t,n)}function fl(e,t,n){n=ds(n);const r=jo(e=e.u);Qo(r),js(e,r,t,2).push(n)}function pl(e,t,n){t.g?t.m(e,t.g,t.h,n,!0):t.m(e,t.h,n,!0)}ks.prototype.toJSON=void 0;var gl=class{constructor(e,t){this.u=Es(e,t)}toJSON(){return ml(this,Is(this.u,Fs,void 0,void 0,!1,!1),!0)}l(){var e=Fd;return e.g?e.l(this,e.g,e.h,!0):e.l(this,e.h,e.defaultValue,!0)}clone(){const e=this.u;return Ms(this,e,jo(e),!1)}G(){return!!(2&$o(this.u))}};function ml(e,t,n){var r=e.constructor.B,i=Wo(jo(n?e.u:t)),a=!1;if(r){if(!n){var o;if((t=No(t)).length&&Xo(o=t[t.length-1]))for(a=0;a<r.length;a++)if(r[a]>=i){Object.assign(t[t.length-1]={},o);break}a=!0}var s;i=t,n=!n,e=Wo(o=jo(e.u)),o=+!!(512&o)-1;for(let t=0;t<r.length;t++){var l=r[t];if(l<e){var u=i[l+=o];null==u?i[l]=n?Ko:zo([]):n&&u!==Ko&&Bo(u)}else{if(!s){var c=void 0;i.length&&Xo(c=i[i.length-1])?s=c:i.push(s={})}u=s[l],null==s[l]?s[l]=n?Ko:zo([]):n&&u!==Ko&&Bo(u)}}}if(!(r=t.length))return t;let d,h;if(Xo(s=t[r-1])){e:{var f=s;c={},i=!1;for(let e in f)n=f[e],Array.isArray(n)&&n!=n&&(i=!0),null!=n?c[e]=n:i=!0;if(i){for(let e in c){f=c;break e}f=null}}f!=s&&(d=!0),r--}for(;0<r&&null==(s=t[r-1]);r--)h=!0;return d||h?(t=a?t:Array.prototype.slice.call(t,0,r),a&&(t.length=r),f&&t.push(f),t):t}function vl(e){return{aa:su,S:e}}function yl(e,t){if(Array.isArray(t)){var n=$o(t);if(4&n)return t;for(var r=0,i=0;r<t.length;r++){const n=e(t[r]);null!=n&&(t[i++]=n)}return i<r&&(t.length=i),Go(t,5|n),2&n&&Object.freeze(t),t}}gl.prototype.K=Yo,gl.prototype.toString=function(){return ml(this,this.u,!1).toString()};const bl=Symbol();function wl(e){let t=e[bl];if(!t){const n=Fl(e),r=n.m;t=r?(e,t)=>r(e,t,n):(e,t)=>{for(;co(t)&&4!=t.h;){var r=t.m,i=n[r];if(!i){var a=n.h;a&&(a=a[r])&&(i=n[r]=xl(a))}i&&i(t,e,r)||(r=(i=t).l,ho(i),i.Y?i=void 0:(a=i.g.g-r,i.g.g=r,i=so(i.g,a)),r=e,i&&(ns||=Symbol(),(a=r[ns])?a.push(i):r[ns]=[i]))}(t=n.l)&&(e[rs||=Symbol()]=t)},e[bl]=t}return t}function xl(e){const t=function(e){if(e=e.S)return wl(e)}(e),n=e.aa.g;if(t){const r=Fl(e.S).g;return(e,i,a)=>n(e,i,a,r,t)}return(e,t,r)=>n(e,t,r)}function El(e,t,n,r){t.g=ws(e[0]);let i=1;if(e.length>i&&!(e[i]instanceof Mo)){var a=e[i++];if(Array.isArray(a))return t.m=a[0],t.h=a[1],t;t.h=a}for(a=0;i<e.length;){const c=e[i++];var o=e[i];for("number"==typeof o?(i++,a+=o):a++,c.l&&((o=t.l)||(t.l=o=[]),o.push(a)),o=i;o<e.length&&!(e[o]instanceof Mo);)o++;if(o-=i){var s=e,l=i,u=s[l];if("function"==typeof u&&(u=u(),s[l]=u),(s=Array.isArray(u))&&!(s=_l in u||kl in u)&&(s=0<u.length)){const e=ws(l=(s=u)[0]);null!=e&&e!==l&&(s[0]=e),s=null!=e}(u=s?u:void 0)?(i++,t[a]=1===o?r(c,u):r(c,u,e[i++])):t[a]=n(c,e[i++])}else t[a]=n(c)}return t}const Sl=Symbol();function Tl(e){let t=e[Sl];if(!t){const n=Rl(e);t=(e,t)=>Ml(e,t,n),e[Sl]=t}return t}const kl=Symbol();function Cl(e){return e.h}function Al(e,t){let n,r;const i=e.h;return(e,a,o)=>i(e,a,o,r||=Rl(t).g,n||=Tl(t))}function Rl(e){let t=e[kl];return t||(t=El(e,e[kl]={},Cl,Al),_l in e&&kl in e&&(e.length=0),t)}const _l=Symbol();function Il(e,t){const n=e.g;return t?(e,r,i)=>n(e,r,i,t):n}function Dl(e,t,n){const r=e.g;let i,a;return(e,o,s)=>r(e,o,s,a||=Fl(t).g,i||=wl(t),n)}function Fl(e){let t=e[_l];return t||(t=El(e,e[_l]={},Il,Dl),_l in e&&kl in e&&(e.length=0),t)}function Ll(e,t){var n=e[t];if(n)return n;if((n=e.h)&&(n=n[t])){var r=n.S,i=n.aa.h;if(r){const e=Tl(r),t=Rl(r).g;n=(n,r,a)=>i(n,r,a,t,e)}else n=i;return e[t]=n}}function Ml(e,t,n){for(var r=jo(e),i=+!!(512&r)-1,a=e.length,o=512&r?1:0,s=a+(256&r?-1:0);o<s;o++){const r=e[o];if(null==r)continue;const a=o-i,s=Ll(n,a);s&&s(t,r,a)}if(256&r){r=e[a-1];for(let e in r)i=+e,Number.isNaN(i)||null!=(a=r[e])&&(s=Ll(n,i))&&s(t,a,i)}if(e=ns?e[ns]:void 0)for(Ro(t,t.g.end()),n=0;n<e.length;n++)Ro(t,Ba(e[n])||La())}function Nl(e,t){return new Mo(e,t,!1)}function Ol(e,t){return new Mo(e,t,!0)}function Pl(e,t,n){$s(e,jo(e),t,n)}var Bl=Nl((function(e,t,n,r,i){return 2===e.h&&(e=fo(e,xs([void 0,void 0],r),i),Qo(r=jo(t)),(i=Bs(t,r,n))instanceof ks?0!=(2&i.g)?((i=i.m()).push(e),$s(t,r,n,i)):i.H(e):Array.isArray(i)?(2&$o(i)&&$s(t,r,n,i=Ws(i)),i.push(e)):$s(t,r,n,[e]),!0)}),(function(e,t,n,r,i){if(t instanceof ks)t.forEach(((t,a)=>{Lo(e,n,xs([a,t],r),i)}));else if(Array.isArray(t))for(let a=0;a<t.length;a++){const o=t[a];Array.isArray(o)&&Lo(e,n,xs(o,r),i)}}));function Ul(e,t,n){e:if(null!=t){if(ls(t)){if("string"==typeof t)break e;if("number"==typeof t)break e}t=void 0}null!=t&&("string"==typeof t&&xo(t),null!=t&&(_o(e,n,0),"number"==typeof t?(e=e.g,Ya(t),To(e,Wa,Ka)):(n=xo(t),To(e.g,n.h,n.g))))}function $l(e,t,n){null!=(t=us(t))&&null!=t&&(_o(e,n,0),Co(e.g,t))}function jl(e,t,n){null!=(t=ss(t))&&(_o(e,n,0),e.g.g.push(t?1:0))}function Gl(e,t,n){null!=(t=fs(t))&&Fo(e,n,sa(t))}function zl(e,t,n,r,i){Lo(e,n,t instanceof gl?t.u:Array.isArray(t)?xs(t,r):void 0,i)}function ql(e,t,n){null!=(t=null==t||"string"==typeof t||Da(t)||t instanceof Ua?t:void 0)&&Fo(e,n,qa(t).buffer)}function Hl(e,t,n){return(5===e.h||2===e.h)&&(t=js(t,jo(t),n,2,!1),2==e.h?mo(e,lo.prototype.A,t):t.push(e.g.A()),!0)}var Vl=Nl((function(e,t,n){if(1!==e.h)return!1;var r=e.g;e=ao(r);const i=ao(r);r=2*(i>>31)+1;const a=i>>>20&2047;return e=4294967296*(1048575&i)+e,Pl(t,n,2047==a?e?NaN:1/0*r:0==a?r*Math.pow(2,-1074)*e:r*Math.pow(2,a-1075)*(e+4503599627370496)),!0}),(function(e,t,n){null!=(t=os(t))&&(_o(e,n,1),e=e.g,(n=Va||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),Wa=n.getUint32(0,!0),Ka=n.getUint32(4,!0),Ao(e,Wa),Ao(e,Ka))})),Wl=Nl((function(e,t,n){return 5===e.h&&(Pl(t,n,e.g.A()),!0)}),(function(e,t,n){null!=(t=os(t))&&(_o(e,n,5),e=e.g,Xa(t),Ao(e,Wa))})),Kl=Ol(Hl,(function(e,t,n){if(null!=(t=yl(os,t)))for(let a=0;a<t.length;a++){var r=e,i=t[a];null!=i&&(_o(r,n,5),r=r.g,Xa(i),Ao(r,Wa))}})),Yl=Ol(Hl,(function(e,t,n){if(null!=(t=yl(os,t))&&t.length){_o(e,n,2),ko(e.g,4*t.length);for(let r=0;r<t.length;r++)n=e.g,Xa(t[r]),Ao(n,Wa)}})),Xl=Nl((function(e,t,n){return 0===e.h&&(Pl(t,n,ro(e.g,Za)),!0)}),Ul),Jl=Nl((function(e,t,n){return 0===e.h&&(Pl(t,n,0===(e=ro(e.g,Za))?void 0:e),!0)}),Ul),Zl=Nl((function(e,t,n){return 0===e.h&&(Pl(t,n,ro(e.g,Ja)),!0)}),(function(e,t,n){e:if(null!=t){if(ls(t)){if("string"==typeof t)break e;if("number"==typeof t)break e}t=void 0}null!=t&&("string"==typeof t&&yo(t),null!=t&&(_o(e,n,0),"number"==typeof t?(e=e.g,Ya(t),To(e,Wa,Ka)):(n=yo(t),To(e.g,n.h,n.g))))})),Ql=Nl((function(e,t,n){return 0===e.h&&(Pl(t,n,e.g.m()),!0)}),$l),eu=Ol((function(e,t,n){return(0===e.h||2===e.h)&&(t=js(t,jo(t),n,2,!1),2==e.h?mo(e,lo.prototype.m,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=yl(us,t))&&t.length){n=Io(e,n);for(let n=0;n<t.length;n++)Co(e.g,t[n]);Do(e,n)}})),tu=Nl((function(e,t,n){return 0===e.h&&(Pl(t,n,0===(e=e.g.m())?void 0:e),!0)}),$l),nu=Nl((function(e,t,n){return 0===e.h&&(Pl(t,n,io(e.g)),!0)}),jl),ru=Nl((function(e,t,n){return 0===e.h&&(Pl(t,n,!1===(e=io(e.g))?void 0:e),!0)}),jl),iu=Ol((function(e,t,n){if(2!==e.h)return!1;e=po(e);const r=jo(t);return Qo(r),js(t,r,n,2).push(e),!0}),(function(e,t,n){if(null!=(t=yl(fs,t)))for(let i=0;i<t.length;i++){var r=t[i];null!=r&&Fo(e,n,sa(r))}})),au=Nl((function(e,t,n){return 2===e.h&&(Pl(t,n,""===(e=po(e))?void 0:e),!0)}),Gl),ou=Nl((function(e,t,n){return 2===e.h&&(Pl(t,n,po(e)),!0)}),Gl),su=Nl((function(e,t,n,r,i){return 2===e.h&&(fo(e,Js(t,r,n,!0),i),!0)}),zl),lu=Nl((function(e,t,n,r,i){return 2===e.h&&(fo(e,Js(t,r,n),i),!0)}),zl),uu=Ol((function(e,t,n,r,i){if(2!==e.h)return!1;r=xs(void 0,r);const a=jo(t);Qo(a);let o=js(t,a,n,3);return(Object.isFrozen(o)||4&$o(o))&&(o=No(o),$s(t,a,n,o)),o.push(r),fo(e,r,i),!0}),(function(e,t,n,r,i){if(Array.isArray(t))for(let a=0;a<t.length;a++)zl(e,t[a],n,r,i)})),cu=Nl((function(e,t,n,r,i,a){if(2!==e.h)return!1;const o=jo(t);return Qo(o),(a=Xs(t,o,a))&&n!==a&&$s(t,o,a),fo(e,t=Js(t,r,n),i),!0}),zl),du=Nl((function(e,t,n){return 2===e.h&&(Pl(t,n,go(e)),!0)}),ql),hu=Ol((function(e,t,n){return(0===e.h||2===e.h)&&(t=js(t,jo(t),n,2,!1),2==e.h?mo(e,lo.prototype.j,t):t.push(e.g.j()),!0)}),(function(e,t,n){if(null!=(t=yl(cs,t)))for(let a=0;a<t.length;a++){var r=e,i=t[a];null!=i&&(_o(r,n,0),ko(r.g,i))}})),fu=Nl((function(e,t,n){return 0===e.h&&(Pl(t,n,e.g.m()),!0)}),(function(e,t,n){null!=(t=us(t))&&(t=parseInt(t,10),_o(e,n,0),Co(e.g,t))})),pu=Ol((function(e,t,n){return(0===e.h||2===e.h)&&(t=js(t,jo(t),n,2,!1),2==e.h?mo(e,lo.prototype.C,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=yl(us,t))&&t.length){n=Io(e,n);for(let n=0;n<t.length;n++)Co(e.g,t[n]);Do(e,n)}}));class gu{constructor(e,t){this.h=e,this.g=t,this.l=Qs,this.m=nl,this.defaultValue=void 0}}function mu(e,t){return new gu(e,t)}function vu(e,t){return(n,r)=>{e:{if(vo.length){const e=vo.pop();e.o(r),to(e.g,n,r),n=e}else n=new class{constructor(e,t){if(uo.length){const n=uo.pop();to(n,e,t),e=n}else e=new lo(e,t);this.g=e,this.l=this.g.g,this.h=this.m=-1,this.o(t)}o({Y:e=!1}={}){this.Y=e}}(n,r);try{var i=new e;const r=i.u;wl(t)(r,n),rs&&delete r[rs];var a=i;break e}finally{(i=n.g).h=null,i.s=!1,i.v=0,i.l=0,i.g=0,i.O=!1,n.m=-1,n.h=-1,100>vo.length&&vo.push(n)}a=void 0}return a}}function yu(e){return function(){const t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const e=this.g;return this.g=[],e}}}};Ml(this.u,t,Rl(e)),Ro(t,t.g.end());const n=new Uint8Array(t.h),r=t.l,i=r.length;let a=0;for(let e=0;e<i;e++){const t=r[e];n.set(t,a),a+=t.length}return t.l=[n],n}}var bu,wu=[0,au,Nl((function(e,t,n){return 2===e.h&&(Pl(t,n,(e=go(e))===Pa()?void 0:e),!0)}),(function(e,t,n){if(null!=t){if(t instanceof gl){const r=t.Aa;return void(r&&(t=r(t),null!=t&&Fo(e,n,qa(t).buffer)))}if(Array.isArray(t))return}ql(e,t,n)}))];function xu(e){if(void 0===bu){var t=null,n=Ji.trustedTypes;if(n&&n.createPolicy){try{t=n.createPolicy("goog#html",{createHTML:Qi,createScript:Qi,createScriptURL:Qi})}catch(e){Ji.console&&Ji.console.error(e.message)}bu=t}else bu=t}return e=(t=bu)?t.createScriptURL(e):e,new class{constructor(e){this.g=e}toString(){return this.g+""}}(e)}var Eu=[0,ou],Su=[0,Ql,fu,nu,nu,eu,fu,fu],Tu=[0,nu,nu],ku=class extends gl{constructor(){super()}};ku.B=[6];var Cu=[0,nu,ou,nu,fu,fu,pu,ou,ou,lu,Tu,fu],Au=[0,ou,ou,ou],Ru=class extends gl{constructor(){super()}},_u=[0],Iu=[0,Ql],Du=[1,2,3,4,5],Fu=class extends gl{constructor(e){super(e,2)}},Lu={},Mu=[-2,Lu,nu];Lu[336783863]=vl([0,ou,nu,nu,Ql,lu,[0,cu,_u,Du,cu,Cu,Du,cu,Au,Du,cu,Iu,Du,cu,Su,Du],lu,Eu]);var Nu=[0,au,ru],Ou=[0,Jl,Jl,ru,ru,ru,ru,Jl,eu,au,tu,Jl,Jl,ru,tu,ru,ru,ru,au],Pu=[-1,{}],Bu=[0,ou,lu,2,Pu],Uu=[0,ou,iu,lu,Pu];function $u(e,t){t=hs(t);const n=jo(e=e.u);Qo(n),$s(e,n,2,""===t?void 0:t)}function ju(e,t){fl(e,3,t)}function Gu(e,t){fl(e,4,t)}var zu=class extends gl{constructor(e){super(e,500)}o(e){return nl(this,0,7,e)}};zu.B=[3,4,5,6,8,13,17,1005];var qu=[-500,au,au,iu,iu,iu,iu,lu,Mu,uu,wu,tu,tu,lu,Bu,lu,Uu,uu,Nu,au,lu,Ou,tu,iu,iu,988],Hu=[0,au,au,lu,Pu],Vu=[-500,ou,ou,lu,[-1,{}],ou,999],Wu=[-500,ou,iu,iu,lu,[-2,{},nu],iu,998,iu],Ku=[-500,ou,iu,lu,Pu,iu,999];function Yu(e,t){il(e,zu,t)}function Xu(e,t){fl(e,10,t)}function Ju(e,t){fl(e,15,t)}var Zu=class extends gl{constructor(e){super(e,500)}o(e){return nl(this,0,1001,e)}};Zu.B=[1,6,7,9,10,15,16,17,14,1002];var Qu=[-500,uu,qu,uu,5,Vu,uu,Wu,tu,uu,Ku,iu,tu,lu,Bu,lu,Uu,uu,Hu,iu,iu,iu,lu,Ou,au,au,ru,lu,980,Pu,uu,wu],ec=vu(Zu,Qu);Zu.prototype.g=yu(Qu);var tc=[0,uu,[0,Ql,Ql,Ql]],nc=class extends gl{constructor(e){super(e)}},rc=[0,Ql,Wl,ou,ou],ic=class extends gl{constructor(e){super(e)}g(){return tl(this,nc,1)}};ic.B=[1];var ac=[0,uu,rc],oc=vu(ic,ac),sc=[0,Ql,Wl],lc=[0,Ql,Ql,lu,tc],uc=class extends gl{constructor(e){super(e)}},cc=[0,Ql,Ql,Ql,Ql],dc=[0,Wl,Wl,Wl,Wl],hc=class extends gl{constructor(e){super(e)}},fc=[0,Wl,Wl,ou,Wl],pc=class extends gl{constructor(e){super(e)}h(){return Qs(this,uc,2)}g(){return tl(this,hc,5)}};pc.B=[5];var gc=[0,fu,lu,cc,lu,dc,lu,lc,uu,fc],mc=class extends gl{constructor(e){super(e)}};mc.B=[1,2,3,8,9];var vc=vu(mc,[0,iu,eu,Yl,lu,gc,ou,ou,Xl,uu,sc,iu,Xl]),yc=class extends gl{constructor(e){super(e)}},bc=[0,Wl,Wl,Wl,Wl,Wl],wc=class extends gl{constructor(e){super(e)}};wc.B=[1];var xc=vu(wc,[0,uu,bc]),Ec=class extends gl{constructor(e){super(e)}},Sc=[0,Wl,Wl,Wl,Wl,Wl],Tc=class extends gl{constructor(e){super(e)}};Tc.B=[1];var kc=vu(Tc,[0,uu,Sc]),Cc=class extends gl{constructor(e){super(e)}};Cc.B=[3];var Ac=[0,Ql,Ql,Yl,fu],Rc=class extends gl{constructor(){super()}};Rc.prototype.g=yu([0,Wl,Wl,Wl,Wl,Wl,Xl]);var _c=class extends gl{constructor(e){super(e)}},Ic=[0,Ql,2,ou,lu,ac],Dc=class extends gl{constructor(e){super(e)}};Dc.B=[1];var Fc=vu(Dc,[0,uu,Ic,Xl]),Lc=class extends gl{constructor(e){super(e)}};Lc.B=[1];var Mc=class extends gl{constructor(e){super(e)}da(){const e=zs(this);return null==e?Pa():e}},Nc=class extends gl{constructor(e){super(e)}},Oc=[1,2],Pc=[0,cu,[0,Yl],Oc,cu,[0,du],Oc,Ql,ou],Bc=class extends gl{constructor(e){super(e)}};Bc.B=[1];var Uc=vu(Bc,[0,uu,Pc,Xl]),$c=class extends gl{constructor(e){super(e)}};$c.B=[4,5];var jc=[0,ou,Ql,Wl,iu,iu],Gc=class extends gl{constructor(e){super(e)}},zc=[0,nu,nu],qc=class extends gl{constructor(e){super(e)}},Hc=[1,2,3,4,5],Vc=class extends gl{constructor(e){super(e)}g(){return null!=zs(this)}h(){return null!=sl(this,2)}},Wc=[0,du,ou,lu,[0,Ql,Xl,Xl],lu,[0,Zl,Xl]],Kc=class extends gl{constructor(e){super(e)}g(){return ss(Ps(this,2))??!1}},Yc=[0,lu,Wc,nu,lu,[0,cu,Iu,Hc,cu,Cu,Hc,cu,Su,Hc,cu,_u,Hc,cu,Au,Hc]],Xc=class extends gl{constructor(e){super(e)}},Jc=[0,lu,Yc,Wl,Wl,Ql],Zc=mu(502141897,Xc);Lu[502141897]=vl(Jc);var Qc=[0,lu,Wc];Lu[512499200]=vl(Qc);var ed=[0,lu,Qc];Lu[515723506]=vl(ed);var td=vu(class extends gl{constructor(e){super(e)}},[0,lu,[0,fu,fu,Kl,hu],lu,Ac]),nd=[0,lu,Yc];Lu[508981768]=vl(nd);var rd=class extends gl{constructor(e){super(e)}},id=[0,lu,Yc,Wl,lu,nd,nu],ad=class extends gl{constructor(e){super(e)}},od=[0,lu,Yc,lu,Jc,lu,id,Wl,lu,ed];Lu[508968149]=vl(id);var sd=mu(508968150,ad);Lu[508968150]=vl(od);var ld=class extends gl{constructor(e){super(e)}},ud=mu(513916220,ld);Lu[513916220]=vl([0,lu,Yc,lu,od,Ql]);var cd=class extends gl{constructor(e){super(e)}h(){return Qs(this,$c,2)}g(){Us(this,2)}},dd=[0,lu,Yc,lu,jc];Lu[478825465]=vl(dd);var hd=[0,lu,Yc];Lu[478825422]=vl(hd);var fd=class extends gl{constructor(e){super(e)}},pd=[0,lu,Yc,lu,hd,lu,dd,lu,dd],gd=class extends gl{constructor(e){super(e)}},md=[0,lu,Yc,Wl,Ql],vd=class extends gl{constructor(e){super(e)}},yd=[0,lu,Yc,Wl],bd=class extends gl{constructor(e){super(e)}},wd=[0,lu,Yc,lu,md,lu,yd,Wl],xd=class extends gl{constructor(e){super(e)}},Ed=[0,lu,Yc,lu,wd,lu,pd];Lu[463370452]=vl(pd),Lu[464864288]=vl(md),Lu[474472470]=vl(yd);var Sd=mu(462713202,bd);Lu[462713202]=vl(wd);var Td=mu(479097054,xd);Lu[479097054]=vl(Ed);var kd=class extends gl{constructor(e){super(e)}},Cd=mu(456383383,kd);Lu[456383383]=vl([0,lu,Yc,lu,jc]);var Ad=class extends gl{constructor(e){super(e)}},Rd=mu(476348187,Ad);Lu[476348187]=vl([0,lu,Yc,lu,zc]);var _d=class extends gl{constructor(e){super(e)}},Id=[0,fu,fu],Dd=class extends gl{constructor(e){super(e)}};Dd.B=[3];var Fd=mu(458105876,class extends gl{constructor(e){super(e)}g(){var e=this.u;const t=jo(e);var n=2&t;return e=function(e,t,n){var r=Dd;const i=2&t;let a=!1;if(null==n){if(i)return Vs();n=[]}else if(n.constructor===ks){if(0==(2&n.g)||i)return n;n=n.m()}else Array.isArray(n)?a=!!(2&$o(n)):n=[];if(i){if(!n.length)return Vs();a||(a=!0,qo(n))}else a&&(a=!1,n=Ws(n));return a||(64&$o(n)?Uo(n,32):32&t&&Po(n,32)),$s(e,t,2,r=new ks(n,r,vs,void 0),!1),r}(e,t,Bs(e,t,2)),null==e||!n&&Dd&&(e.v=!0),e}});Lu[458105876]=vl([0,lu,Id,Bl,[0,Xl,lu,[0,ou,ou,iu]]]);var Ld=class extends gl{constructor(e){super(e)}},Md=mu(458105758,Ld);Lu[458105758]=vl([0,lu,Yc,ou,lu,Id]);var Nd=class extends gl{constructor(e){super(e)}};Nd.B=[5,6];var Od=mu(443442058,Nd);Lu[443442058]=vl([0,lu,Yc,ou,Ql,Wl,iu,iu]);var Pd=class extends gl{constructor(e){super(e)}},Bd=[0,lu,Yc,Wl,Wl,Ql];Lu[514774813]=vl(Bd);var Ud=class extends gl{constructor(e){super(e)}},$d=[0,lu,Yc,Wl],jd=class extends gl{constructor(e){super(e)}},Gd=[0,lu,Yc,lu,Bd,lu,$d,Wl];Lu[518928384]=vl($d);var zd=mu(516587230,jd);function qd(e,t){return t=t?t.clone():new $c,void 0!==e.displayNamesLocale?Us(t,1,hs(e.displayNamesLocale)):void 0===e.displayNamesLocale&&Us(t,1),void 0!==e.maxResults?dl(t,2,e.maxResults):"maxResults"in e&&Us(t,2),void 0!==e.scoreThreshold?hl(t,3,e.scoreThreshold):"scoreThreshold"in e&&Us(t,3),void 0!==e.categoryAllowlist?Ks(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&Us(t,4),void 0!==e.categoryDenylist?Ks(t,5,e.categoryDenylist):"categoryDenylist"in e&&Us(t,5),t}function Hd(e,t=-1,n=""){return{categories:e.map((e=>({index:ll(al(e,1))??-1,score:ul(e,2)??0,categoryName:sl(e,3)??""??"",displayName:sl(e,4)??""??""}))),headIndex:t,headName:n}}function Vd(e){var t=qs(e,3,os),n=qs(e,2,us);const r=qs(e,1,fs),i=qs(e,9,fs),a={categories:[],keypoints:[]};for(let e=0;e<t.length;e++)a.categories.push({score:t[e],index:n[e]??-1,categoryName:r[e]??"",displayName:i[e]??""});if((t=Qs(e,pc,4)?.h())&&(a.boundingBox={originX:al(t,1)??0,originY:al(t,2)??0,width:al(t,3)??0,height:al(t,4)??0,angle:0}),Qs(e,pc,4)?.g().length)for(const t of Qs(e,pc,4).g())a.keypoints.push({x:Gs(t,1)??0,y:Gs(t,2)??0,score:Gs(t,4)??0,label:sl(t,3)??""});return a}function Wd(e){const t=[];for(const n of tl(e,Ec,1))t.push({x:ul(n,1)??0,y:ul(n,2)??0,z:ul(n,3)??0});return t}function Kd(e){const t=[];for(const n of tl(e,yc,1))t.push({x:ul(n,1)??0,y:ul(n,2)??0,z:ul(n,3)??0});return t}function Yd(e){return Array.from(e,(e=>127<e?e-256:e))}function Xd(e,t){if(e.length!==t.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${e.length} vs. ${t.length}).`);let n=0,r=0,i=0;for(let a=0;a<e.length;a++)n+=e[a]*t[a],r+=e[a]*e[a],i+=t[a]*t[a];if(0>=r||0>=i)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(r*i)}let Jd;Lu[516587230]=vl(Gd);const Zd=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 Qd(){if(void 0===Jd)try{await WebAssembly.instantiate(Zd),Jd=!0}catch{Jd=!1}return Jd}async function eh(e,t){const n=await Qd()?"wasm_internal":"wasm_nosimd_internal";return void 0!==t?{wasmLoaderPath:`${t}/${e}_${n}.js`,wasmBinaryPath:`${t}/${e}_${n}.wasm`}:{wasmLoaderPath:xu(`./${encodeURIComponent(e)}_${encodeURIComponent(n)}.js`),wasmBinaryPath:xu(`./${encodeURIComponent(e)}_${encodeURIComponent(n)}.wasm`)}}var th=class{};function nh(){const e=navigator.userAgent;return e.includes("Safari")&&!e.includes("Chrome")}async function rh(e){if("function"!=typeof importScripts){const t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise(((e,n)=>{t.addEventListener("load",(()=>{e()}),!1),t.addEventListener("error",(e=>{n(e)}),!1),document.body.appendChild(t)}))}importScripts(e.toString())}function ih(e,t,n){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function ah(e,t,n){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(n?e.i._bindTextureToStream(n):e.i._bindTextureToCanvas(),!(n=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");return e.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),t.videoWidth?(n=t.videoWidth,t=t.videoHeight):t.naturalWidth?(n=t.naturalWidth,t=t.naturalHeight):(n=t.width,t=t.height),!e.l||n===e.i.canvas.width&&t===e.i.canvas.height||(e.i.canvas.width=n,e.i.canvas.height=t),[n,t]}function oh(e,t,n){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const r=new Uint32Array(t.length);for(let n=0;n<t.length;n++)r[n]=e.i.stringToNewUTF8(t[n]);t=e.i._malloc(4*r.length),e.i.HEAPU32.set(r,t>>2),n(t);for(const t of r)e.i._free(t);e.i._free(t)}function sh(e,t,n){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=n}function lh(e,t,n){let r=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(e,t,i)=>{t?(n(r,i),r=[]):r.push(e)}}function uh(e,t){const n=Qs(e.baseOptions,Vc,1)||new Vc;"string"==typeof t?(Us(n,2,hs(t)),Us(n,1)):t instanceof Uint8Array&&(Us(n,1,Jo(t,!1,!1)),Us(n,2)),nl(e.baseOptions,0,1,n)}function ch(e){try{const t=e.I.length;if(1===t)throw Error(e.I[0].message);if(1<t)throw Error("Encountered multiple errors: "+e.I.map((e=>e.message)).join(", "))}finally{e.I=[]}}function dh(e,t){e.H=Math.max(e.H,t)}function hh(e,t){e.A=new zu,$u(e.A,"PassThroughCalculator"),ju(e.A,"free_memory"),Gu(e.A,"free_memory_unused_out"),Xu(t,"free_memory"),Yu(t,e.A)}function fh(e,t){ju(e.A,t),Gu(e.A,t+"_unused_out")}function ph(e){e.g.addBoolToStream(!0,"free_memory",e.H)}th.forVisionTasks=function(e=""){return eh("vision",e)},th.forTextTasks=function(e=""){return eh("text",e)},th.forAudioTasks=function(e=""){return eh("audio",e)},th.isSimdSupported=function(){return Qd()};var gh=class{constructor(e){this.g=e,this.I=[],this.H=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){if(t){const t=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(Qs(this.baseOptions,Vc,1)?.g()||Qs(this.baseOptions,Vc,1)?.h()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(e,t){let n=Qs(e.baseOptions,qc,3);if(!n){var r=n=new qc,i=new Ru;rl(r,4,Hc,i)}"delegate"in t&&("GPU"===t.delegate?(t=n,r=new ku,rl(t,2,Hc,r)):(t=n,r=new Ru,rl(t,4,Hc,r))),nl(e.baseOptions,0,3,n)}(this,t),t.modelAssetPath)return fetch(t.modelAssetPath.toString()).then((e=>{if(e.ok)return e.arrayBuffer();throw Error(`Failed to fetch model: ${t.modelAssetPath} (${e.status})`)})).then((e=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(e),!0,!1,!1),uh(this,"/model.dat"),this.m(),this.N()}));uh(this,t.modelAssetBuffer)}return this.m(),this.N(),Promise.resolve()}N(){}U(){let e;if(this.g.U((t=>{e=ec(t)})),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener(((e,t)=>{this.I.push(Error(t))})),this.g.xa(),this.g.setGraph(e,t),this.A=void 0,ch(this)}finishProcessing(){this.g.finishProcessing(),ch(this)}close(){this.A=void 0,this.g.closeGraph()}};function mh(e,t){if(null===e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}gh.prototype.close=gh.prototype.close;class vh{constructor(e,t,n,r){this.g=e,this.h=t,this.m=n,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 yh(e,t,n){const r=e.h;if(n=mh(r.createShader(n),"Failed to create WebGL shader"),r.shaderSource(n,t),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${r.getShaderInfoLog(n)}`);return r.attachShader(e.g,n),n}function bh(e,t){const n=e.h,r=mh(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(r);const i=mh(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,i),n.enableVertexAttribArray(e.s),n.vertexAttribPointer(e.s,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 a=mh(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,a),n.enableVertexAttribArray(e.A),n.vertexAttribPointer(e.A,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array(t?[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 vh(n,r,i,a)}function wh(e,t){if(e.h){if(t!==e.h)throw Error("Cannot change GL context once initialized")}else e.h=t}function xh(e,t,n,r){if(wh(e,t),!e.g){const t=e.h;if(e.g=mh(t.createProgram(),"Failed to create WebGL program"),e.C=yh(e,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",t.VERTEX_SHADER),e.v=yh(e,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D inputTexture;\n void main() {\n gl_FragColor = texture2D(inputTexture, vTex);\n }\n ",t.FRAGMENT_SHADER),t.linkProgram(e.g),!t.getProgramParameter(e.g,t.LINK_STATUS))throw Error(`Error during program linking: ${t.getProgramInfoLog(e.g)}`);e.s=t.getAttribLocation(e.g,"aVertex"),e.A=t.getAttribLocation(e.g,"aTex")}return n?(e.m||(e.m=bh(e,!0)),n=e.m):(e.j||(e.j=bh(e,!1)),n=e.j),t.useProgram(e.g),n.bind(),e=r(),n.g.bindVertexArray(null),e}function Eh(e,t,n){wh(e,t),e.l||(e.l=mh(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.l),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0)}function Sh(e){e.h?.bindFramebuffer(e.h.FRAMEBUFFER,null)}var Th=class{close(){if(this.g){const e=this.h;e.deleteProgram(this.g),e.deleteShader(this.C),e.deleteShader(this.v)}this.l&&this.h.deleteFramebuffer(this.l),this.j&&this.j.close(),this.m&&this.m.close()}};function kh(e,t){switch(t){case 0:return e.g.find((e=>e instanceof ImageData));case 1:return e.g.find((e=>"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap));case 2:return e.g.find((e=>"undefined"!=typeof WebGLTexture&&e instanceof WebGLTexture));default:throw Error(`Type is not supported: ${t}`)}}function Ch(e){var t=kh(e,0);if(!t){t=Rh(e);const n=_h(e),r=new Uint8Array(e.width*e.height*4);Eh(n,t,Ah(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,r),Sh(n),t=new ImageData(new Uint8ClampedArray(r.buffer),e.width,e.height),e.g.push(t)}return t}function Ah(e){let t=kh(e,2);if(!t){const n=Rh(e);t=Dh(e);const r=kh(e,1)||Ch(e);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,r),Fh(e)}return t}function Rh(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when iniitializing the image.");return e.h||(e.h=mh(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function _h(e){return e.l||(e.l=new Th),e.l}function Ih(e){(e=Rh(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,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR)}function Dh(e){const t=Rh(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=kh(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=mh(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),Ih(e)),n}function Fh(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Lh(e){const t=Rh(e);return xh(_h(e),t,!0,(()=>function(e,t){const n=e.canvas;if(n.width===e.width&&n.height===e.height)return t();const r=n.width,i=n.height;return n.width=e.width,n.height=e.height,e=t(),n.width=r,n.height=i,e}(e,(()=>{if(t.bindFramebuffer(t.FRAMEBUFFER,null),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),!(e.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return e.canvas.transferToImageBitmap()}))))}var Mh=class{constructor(e,t,n,r,i,a,o){this.g=e,this.j=t,this.m=n,this.canvas=r,this.l=i,this.width=a,this.height=o,(this.j||this.m)&&0==--Nh&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}ta(){return!!kh(this,0)}Z(){return!!kh(this,1)}J(){return!!kh(this,2)}pa(){return Ch(this)}oa(){var e=kh(this,1);return e||(Ah(this),Dh(this),e=Lh(this),Fh(this),this.g.push(e),this.j=!0),e}T(){return Ah(this)}clone(){const e=[];for(const t of this.g){let n;if(t instanceof ImageData)n=new ImageData(t.data,this.width,this.height);else if(t instanceof WebGLTexture){const e=Rh(this),t=_h(this);e.activeTexture(e.TEXTURE1),n=mh(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),Ih(this),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.width,this.height,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindTexture(e.TEXTURE_2D,null),Eh(t,e,n),xh(t,e,!1,(()=>{Dh(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),Fh(this)})),Sh(t),Fh(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);Ah(this),Dh(this),n=Lh(this),Fh(this)}e.push(n)}return new Mh(e,this.Z(),this.J(),this.canvas,this.l,this.width,this.height)}close(){this.j&&kh(this,1).close(),this.m&&Rh(this).deleteTexture(kh(this,2)),Nh=-1}};Mh.prototype.close=Mh.prototype.close,Mh.prototype.clone=Mh.prototype.clone,Mh.prototype.getAsWebGLTexture=Mh.prototype.T,Mh.prototype.getAsImageBitmap=Mh.prototype.oa,Mh.prototype.getAsImageData=Mh.prototype.pa,Mh.prototype.hasWebGLTexture=Mh.prototype.J,Mh.prototype.hasImageBitmap=Mh.prototype.Z,Mh.prototype.hasImageData=Mh.prototype.ta;var Nh=250;function Oh(e,t){switch(t){case 0:return e.g.find((e=>e instanceof Uint8Array));case 1:return e.g.find((e=>e instanceof Float32Array));case 2:return e.g.find((e=>"undefined"!=typeof WebGLTexture&&e instanceof WebGLTexture));default:throw Error(`Type is not supported: ${t}`)}}function Ph(e){var t=Oh(e,1);if(!t){if(t=Oh(e,0))t=new Float32Array(t).map((e=>e/255));else{t=new Float32Array(e.width*e.height);const r=Uh(e);var n=jh(e);if(Eh(n,r,Bh(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document){n=new Float32Array(e.width*e.height*4),r.readPixels(0,0,e.width,e.height,r.RGBA,r.FLOAT,n);for(let e=0,r=0;e<t.length;++e,r+=4)t[e]=n[r]}else r.readPixels(0,0,e.width,e.height,r.RED,r.FLOAT,t)}e.g.push(t)}return t}function Bh(e){let t=Oh(e,2);if(!t){const n=Uh(e);t=zh(e);const r=Ph(e),i=$h(e);n.texImage2D(n.TEXTURE_2D,0,i,e.width,e.height,0,n.RED,n.FLOAT,r),qh(e)}return t}function Uh(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return e.h||(e.h=mh(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function $h(e){if(e=Uh(e),!Hh)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Hh=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Hh=e.R16F}return Hh}function jh(e){return e.l||(e.l=new Th),e.l}function Gh(e){(e=Uh(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,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST)}function zh(e){const t=Uh(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=Oh(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=mh(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),Gh(e)),n}function qh(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Hh,Vh=class{constructor(e,t,n,r,i,a){this.g=e,this.m=t,this.canvas=n,this.l=r,this.width=i,this.height=a,this.m&&0==--Wh&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}ua(){return!!Oh(this,0)}sa(){return!!Oh(this,1)}J(){return!!Oh(this,2)}qa(){return(e=Oh(this,0))||(e=Ph(this),e=new Uint8Array(e.map((e=>255*e))),this.g.push(e)),e;var e}na(){return Ph(this)}T(){return Bh(this)}clone(){const e=[];for(const t of this.g){let n;if(t instanceof Uint8Array)n=new Uint8Array(t);else if(t instanceof Float32Array)n=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{const e=Uh(this),t=jh(this);e.activeTexture(e.TEXTURE1),n=mh(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),Gh(this);const r=$h(this);e.texImage2D(e.TEXTURE_2D,0,r,this.width,this.height,0,e.RED,e.FLOAT,null),e.bindTexture(e.TEXTURE_2D,null),Eh(t,e,n),xh(t,e,!1,(()=>{zh(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),qh(this)})),Sh(t),qh(this)}}e.push(n)}return new Vh(e,this.J(),this.canvas,this.l,this.width,this.height)}close(){this.m&&Uh(this).deleteTexture(Oh(this,2)),Wh=-1}};Vh.prototype.close=Vh.prototype.close,Vh.prototype.clone=Vh.prototype.clone,Vh.prototype.getAsWebGLTexture=Vh.prototype.T,Vh.prototype.getAsFloat32Array=Vh.prototype.na,Vh.prototype.getAsUint8Array=Vh.prototype.qa,Vh.prototype.hasWebGLTexture=Vh.prototype.J,Vh.prototype.hasFloat32Array=Vh.prototype.sa,Vh.prototype.hasUint8Array=Vh.prototype.ua;var Wh=250;function Kh(...e){return e.map((([e,t])=>({start:e,end:t})))}const Yh=function(e){return class extends e{xa(){this.i._registerModelResourcesGraphService()}}}((Xh=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m="function"==typeof this.i._addIntToInputStream,void 0!==t?this.i.canvas=t:"undefined"==typeof OffscreenCanvas||nh()?(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas")):this.i.canvas=new OffscreenCanvas(1,1)}async initializeGraph(e){const t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph((new TextEncoder).encode(e),!1)}setGraph(e,t){const n=e.length,r=this.i._malloc(n);this.i.HEAPU8.set(e,r),t?this.i._changeBinaryGraph(n,r):this.i._changeTextGraph(n,r),this.i._free(r)}configureAudio(e,t,n,r,i){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),ih(this,r||"input_audio",(r=>{ih(this,i=i||"audio_header",(i=>{this.i._configureAudio(r,i,e,t,n)}))}))}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}U(e){sh(this,"__graph_config__",(t=>{e(t)})),ih(this,"__graph_config__",(e=>{this.i._getGraphConfig(e,void 0)})),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,n){this.addAudioToStreamWithShape(e,0,0,t,n)}addAudioToStreamWithShape(e,t,n,r,i){const a=4*e.length;this.h!==a&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(a),this.h=a),this.i.HEAPF32.set(e,this.g/4),ih(this,r,(e=>{this.i._addAudioToInputStream(this.g,t,n,e,i)}))}addGpuBufferToStream(e,t,n){ih(this,t,(t=>{const[r,i]=ah(this,e,t);this.i._addBoundTextureToStream(t,r,i,n)}))}addBoolToStream(e,t,n){ih(this,t,(t=>{this.i._addBoolToInputStream(e,t,n)}))}addDoubleToStream(e,t,n){ih(this,t,(t=>{this.i._addDoubleToInputStream(e,t,n)}))}addFloatToStream(e,t,n){ih(this,t,(t=>{this.i._addFloatToInputStream(e,t,n)}))}addIntToStream(e,t,n){ih(this,t,(t=>{this.i._addIntToInputStream(e,t,n)}))}addStringToStream(e,t,n){ih(this,t,(t=>{ih(this,e,(e=>{this.i._addStringToInputStream(e,t,n)}))}))}addStringRecordToStream(e,t,n){ih(this,t,(t=>{oh(this,Object.keys(e),(r=>{oh(this,Object.values(e),(i=>{this.i._addFlatHashMapToInputStream(r,i,Object.keys(e).length,t,n)}))}))}))}addProtoToStream(e,t,n,r){ih(this,n,(n=>{ih(this,t,(t=>{const i=this.i._malloc(e.length);this.i.HEAPU8.set(e,i),this.i._addProtoToInputStream(i,e.length,t,n,r),this.i._free(i)}))}))}addEmptyPacketToStream(e,t){ih(this,e,(e=>{this.i._addEmptyPacketToInputStream(e,t)}))}addBoolToInputSidePacket(e,t){ih(this,t,(t=>{this.i._addBoolToInputSidePacket(e,t)}))}addDoubleToInputSidePacket(e,t){ih(this,t,(t=>{this.i._addDoubleToInputSidePacket(e,t)}))}addFloatToInputSidePacket(e,t){ih(this,t,(t=>{this.i._addFloatToInputSidePacket(e,t)}))}addIntToInputSidePacket(e,t){ih(this,t,(t=>{this.i._addIntToInputSidePacket(e,t)}))}addStringToInputSidePacket(e,t){ih(this,t,(t=>{ih(this,e,(e=>{this.i._addStringToInputSidePacket(e,t)}))}))}addProtoToInputSidePacket(e,t,n){ih(this,n,(n=>{ih(this,t,(t=>{const r=this.i._malloc(e.length);this.i.HEAPU8.set(e,r),this.i._addProtoToInputSidePacket(r,e.length,t,n),this.i._free(r)}))}))}attachBoolListener(e,t){sh(this,e,t),ih(this,e,(e=>{this.i._attachBoolListener(e)}))}attachBoolVectorListener(e,t){lh(this,e,t),ih(this,e,(e=>{this.i._attachBoolVectorListener(e)}))}attachIntListener(e,t){sh(this,e,t),ih(this,e,(e=>{this.i._attachIntListener(e)}))}attachIntVectorListener(e,t){lh(this,e,t),ih(this,e,(e=>{this.i._attachIntVectorListener(e)}))}attachDoubleListener(e,t){sh(this,e,t),ih(this,e,(e=>{this.i._attachDoubleListener(e)}))}attachDoubleVectorListener(e,t){lh(this,e,t),ih(this,e,(e=>{this.i._attachDoubleVectorListener(e)}))}attachFloatListener(e,t){sh(this,e,t),ih(this,e,(e=>{this.i._attachFloatListener(e)}))}attachFloatVectorListener(e,t){lh(this,e,t),ih(this,e,(e=>{this.i._attachFloatVectorListener(e)}))}attachStringListener(e,t){sh(this,e,t),ih(this,e,(e=>{this.i._attachStringListener(e)}))}attachStringVectorListener(e,t){lh(this,e,t),ih(this,e,(e=>{this.i._attachStringVectorListener(e)}))}attachProtoListener(e,t,n){sh(this,e,t),ih(this,e,(e=>{this.i._attachProtoListener(e,n||!1)}))}attachProtoVectorListener(e,t,n){lh(this,e,t),ih(this,e,(e=>{this.i._attachProtoVectorListener(e,n||!1)}))}attachAudioListener(e,t,n){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),sh(this,e,((e,n)=>{e=new Float32Array(e.buffer,e.byteOffset,e.length/4),t(e,n)})),ih(this,e,(e=>{this.i._attachAudioListener(e,n||!1)}))}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Xh{get W(){return this.i}ea(e,t,n){ih(this,t,(t=>{const[r,i]=ah(this,e,t);this.W._addBoundTextureAsImageToStream(t,r,i,n)}))}P(e,t){sh(this,e,t),ih(this,e,(e=>{this.W._attachImageListener(e)}))}R(e,t){lh(this,e,t),ih(this,e,(e=>{this.W._attachImageVectorListener(e)}))}}));var Xh,Jh=class extends Yh{};async function Zh(e,t,n){return async function(e,t,n,r){return async function(e,t,n,r){return e=await(async(e,t,n,r,i)=>{if(t&&await rh(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(n&&(await rh(n),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&i&&((t=self.Module).locateFile=i.locateFile,i.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=i.mainScriptUrlOrBlob)),i=await self.ModuleFactory(self.Module||i),self.ModuleFactory=self.Module=void 0,new e(i,r)})(e,n.wasmLoaderPath,n.assetLoaderPath,t,{locateFile(e){var t=n.wasmBinaryPath.toString();return t.includes(e)?t:(t=n.assetBinaryPath?.toString(),t?.includes(e)?t:e)}}),await e.o(r),e}(e,t,n,r)}(e,n.canvas??("undefined"==typeof OffscreenCanvas||nh()?document.createElement("canvas"):void 0),t,n)}function Qh(e,t,n,r){if(e.X){const a=new Rc;if(n?.regionOfInterest){if(!e.ca)throw Error("This task doesn't support region-of-interest.");var i=n.regionOfInterest;if(i.left>=i.right||i.top>=i.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(0>i.left||0>i.top||1<i.right||1<i.bottom)throw Error("Expected RectF values to be in [0,1].");hl(a,1,(i.left+i.right)/2),hl(a,2,(i.top+i.bottom)/2),hl(a,4,i.right-i.left),hl(a,3,i.bottom-i.top)}else hl(a,1,.5),hl(a,2,.5),hl(a,4,1),hl(a,3,1);if(n?.rotationDegrees){if(0!=n?.rotationDegrees%90)throw Error("Expected rotation to be a multiple of 90°.");if(hl(a,5,-Math.PI*n.rotationDegrees/180),0!=n?.rotationDegrees%180){const[e,r]=void 0!==t.videoWidth?[t.videoWidth,t.videoHeight]:void 0!==t.naturalWidth?[t.naturalWidth,t.naturalHeight]:[t.width,t.height];n=ul(a,3)*r/e,i=ul(a,4)*e/r,hl(a,4,n),hl(a,3,i)}}e.g.addProtoToStream(a.g(),"mediapipe.NormalizedRect",e.X,r)}e.g.ea(t,e.ba,r??performance.now()),e.finishProcessing()}function ef(e,t,n){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");Qh(e,t,n,e.H+1)}function tf(e,t,n,r){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");Qh(e,t,n,r)}function nf(e,t,n){var r=t.data;const i=t.width,a=i*(t=t.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==a)throw Error("Unsupported channel count: "+r.length/a);return e=new Vh([r],!1,e.g.i.canvas,e.M,i,t),n?e.clone():e}var rf=class extends gh{constructor(e,t,n,r){super(e),this.g=e,this.ba=t,this.X=n,this.ca=r,this.M=new Th}l(e,t=!0){if("runningMode"in e&&cl(this.baseOptions,2,!!e.runningMode&&"IMAGE"!==e.runningMode),void 0!==e.canvas&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.M.close(),super.close()}};rf.prototype.close=rf.prototype.close;var af=class extends rf{constructor(e,t){super(new Jh(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},this.h=new Xc,e=new Kc,nl(this.h,0,1,e),hl(this.h,2,.5),hl(this.h,3,.3)}get baseOptions(){return Qs(this.h,Kc,1)}set baseOptions(e){nl(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&hl(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&hl(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},ef(this,e,t),this.j}D(e,t,n){return this.j={detections:[]},tf(this,e,n,t),this.j}m(){var e=new Zu;Xu(e,"image_in"),Xu(e,"norm_rect_in"),Ju(e,"detections");const t=new Fu;pl(t,Zc,this.h);const n=new zu;$u(n,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),ju(n,"IMAGE:image_in"),ju(n,"NORM_RECT:norm_rect_in"),Gu(n,"DETECTIONS:detections"),n.o(t),Yu(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=vc(t),this.j.detections.push(Vd(e));dh(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{dh(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};af.prototype.detectForVideo=af.prototype.D,af.prototype.setOptions=af.prototype.o,af.createFromModelPath=async function(e,t){return Zh(af,e,{baseOptions:{modelAssetPath:t}})},af.createFromModelBuffer=function(e,t){return Zh(af,e,{baseOptions:{modelAssetBuffer:t}})},af.createFromOptions=function(e,t){return Zh(af,e,t)};var of=Kh([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]),sf=Kh([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]),lf=Kh([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),uf=Kh([474,475],[475,476],[476,477],[477,474]),cf=Kh([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]),df=Kh([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),hf=Kh([469,470],[470,471],[471,472],[472,469]),ff=Kh([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]),pf=[...of,...sf,...lf,...cf,...df,...ff],gf=Kh([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 mf(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var vf=class extends rf{constructor(e,t){super(new Jh(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,this.h=new ad,e=new Kc,nl(this.h,0,1,e),this.v=new rd,nl(this.h,0,3,this.v),this.s=new Xc,nl(this.h,0,2,this.s),dl(this.s,4,1),hl(this.s,2,.5),hl(this.v,2,.5),hl(this.h,4,.5)}get baseOptions(){return Qs(this.h,Kc,1)}set baseOptions(e){nl(this.h,0,1,e)}o(e){return"numFaces"in e&&dl(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&hl(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&hl(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&hl(this.v,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}F(e,t){return mf(this),ef(this,e,t),this.j}D(e,t,n){return mf(this),tf(this,e,n,t),this.j}m(){var e=new Zu;Xu(e,"image_in"),Xu(e,"norm_rect"),Ju(e,"face_landmarks");const t=new Fu;pl(t,sd,this.h);const n=new zu;$u(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),ju(n,"IMAGE:image_in"),ju(n,"NORM_RECT:norm_rect"),Gu(n,"NORM_LANDMARKS:face_landmarks"),n.o(t),Yu(e,n),this.g.attachProtoVectorListener("face_landmarks",((e,t)=>{for(const t of e)e=kc(t),this.j.faceLandmarks.push(Wd(e));dh(this,t)})),this.g.attachEmptyPacketListener("face_landmarks",(e=>{dh(this,e)})),this.outputFaceBlendshapes&&(Ju(e,"blendshapes"),Gu(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((e,t)=>{if(this.outputFaceBlendshapes)for(const t of e)e=oc(t),this.j.faceBlendshapes.push(Hd(e.g()??[]));dh(this,t)})),this.g.attachEmptyPacketListener("blendshapes",(e=>{dh(this,e)}))),this.outputFacialTransformationMatrixes&&(Ju(e,"face_geometry"),Gu(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((e,t)=>{if(this.outputFacialTransformationMatrixes)for(const t of e)(e=Qs(td(t),Cc,2))&&this.j.facialTransformationMatrixes.push({rows:ll(al(e,1))??0,columns:ll(al(e,2))??0,data:qs(e,3,os)??[]});dh(this,t)})),this.g.attachEmptyPacketListener("face_geometry",(e=>{dh(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};vf.prototype.detectForVideo=vf.prototype.D,vf.prototype.detect=vf.prototype.F,vf.prototype.setOptions=vf.prototype.o,vf.createFromModelPath=function(e,t){return Zh(vf,e,{baseOptions:{modelAssetPath:t}})},vf.createFromModelBuffer=function(e,t){return Zh(vf,e,{baseOptions:{modelAssetBuffer:t}})},vf.createFromOptions=function(e,t){return Zh(vf,e,t)},vf.FACE_LANDMARKS_LIPS=of,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LIPS",vf.FACE_LANDMARKS_LIPS),vf.FACE_LANDMARKS_LEFT_EYE=sf,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_EYE",vf.FACE_LANDMARKS_LEFT_EYE),vf.FACE_LANDMARKS_LEFT_EYEBROW=lf,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_EYEBROW",vf.FACE_LANDMARKS_LEFT_EYEBROW),vf.FACE_LANDMARKS_LEFT_IRIS=uf,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_IRIS",vf.FACE_LANDMARKS_LEFT_IRIS),vf.FACE_LANDMARKS_RIGHT_EYE=cf,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_EYE",vf.FACE_LANDMARKS_RIGHT_EYE),vf.FACE_LANDMARKS_RIGHT_EYEBROW=df,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_EYEBROW",vf.FACE_LANDMARKS_RIGHT_EYEBROW),vf.FACE_LANDMARKS_RIGHT_IRIS=hf,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_IRIS",vf.FACE_LANDMARKS_RIGHT_IRIS),vf.FACE_LANDMARKS_FACE_OVAL=ff,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_FACE_OVAL",vf.FACE_LANDMARKS_FACE_OVAL),vf.FACE_LANDMARKS_CONTOURS=pf,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_CONTOURS",vf.FACE_LANDMARKS_CONTOURS),vf.FACE_LANDMARKS_TESSELATION=gf,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_TESSELATION",vf.FACE_LANDMARKS_TESSELATION);var yf=class extends rf{constructor(e,t){super(new Jh(e,t),"image_in","norm_rect",!0),this.j=new ld,e=new Kc,nl(this.j,0,1,e)}get baseOptions(){return Qs(this.j,Kc,1)}set baseOptions(e){nl(this.j,0,1,e)}o(e){return super.l(e)}za(e,t,n){const r="function"!=typeof t?t:{};if(this.h="function"==typeof t?t:n,ef(this,e,r??{}),!this.h)return this.s}m(){var e=new Zu;Xu(e,"image_in"),Xu(e,"norm_rect"),Ju(e,"stylized_image");const t=new Fu;pl(t,ud,this.j);const n=new zu;$u(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),ju(n,"IMAGE:image_in"),ju(n,"NORM_RECT:norm_rect"),Gu(n,"STYLIZED_IMAGE:stylized_image"),n.o(t),Yu(e,n),this.g.P("stylized_image",((e,t)=>{var n=!this.h,r=e.data,i=e.width;const a=i*(e=e.height);if(r instanceof Uint8Array)if(r.length===3*a){const t=new Uint8ClampedArray(4*a);for(let e=0;e<a;++e)t[4*e]=r[3*e],t[4*e+1]=r[3*e+1],t[4*e+2]=r[3*e+2],t[4*e+3]=255;r=new ImageData(t,i,e)}else{if(r.length!==4*a)throw Error("Unsupported channel count: "+r.length/a);r=new ImageData(new Uint8ClampedArray(r.buffer,r.byteOffset,r.length),i,e)}else if(!(r instanceof WebGLTexture))throw Error(`Unsupported format: ${r.constructor.name}`);i=new Mh([r],!1,!1,this.g.i.canvas,this.M,i,e),this.s=n=n?i.clone():i,this.h&&this.h(n),dh(this,t)})),this.g.attachEmptyPacketListener("stylized_image",(e=>{this.s=null,this.h&&this.h(null),dh(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};yf.prototype.stylize=yf.prototype.za,yf.prototype.setOptions=yf.prototype.o,yf.createFromModelPath=function(e,t){return Zh(yf,e,{baseOptions:{modelAssetPath:t}})},yf.createFromModelBuffer=function(e,t){return Zh(yf,e,{baseOptions:{modelAssetBuffer:t}})},yf.createFromOptions=function(e,t){return Zh(yf,e,t)};var bf=Kh([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 wf(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function xf(e){return 0===e.gestures.length?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function Ef(e,t=!0){const n=[];for(const i of e){var r=oc(i);e=[];for(const n of r.g())r=t&&null!=al(n,1)?ll(al(n,1)):-1,e.push({score:ul(n,2)??0,index:r,categoryName:sl(n,3)??""??"",displayName:sl(n,4)??""??""});n.push(e)}return n}var Sf=class extends rf{constructor(e,t){super(new Jh(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.v=new xd,e=new Kc,nl(this.v,0,1,e),this.C=new bd,nl(this.v,0,2,this.C),this.s=new vd,nl(this.C,0,3,this.s),this.h=new gd,nl(this.C,0,2,this.h),this.j=new fd,nl(this.v,0,3,this.j),hl(this.h,2,.5),hl(this.C,4,.5),hl(this.s,2,.5)}get baseOptions(){return Qs(this.v,Kc,1)}set baseOptions(e){nl(this.v,0,1,e)}o(e){if(dl(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&hl(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&hl(this.C,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&hl(this.s,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new cd,n=qd(e.cannedGesturesClassifierOptions,Qs(this.j,cd,3)?.h());nl(t,0,2,n),nl(this.j,0,3,t)}else void 0===e.cannedGesturesClassifierOptions&&Qs(this.j,cd,3)?.g();return e.customGesturesClassifierOptions?(nl(t=new cd,0,2,n=qd(e.customGesturesClassifierOptions,Qs(this.j,cd,4)?.h())),nl(this.j,0,4,t)):void 0===e.customGesturesClassifierOptions&&Qs(this.j,cd,4)?.g(),this.l(e)}va(e,t){return wf(this),ef(this,e,t),xf(this)}wa(e,t,n){return wf(this),tf(this,e,n,t),xf(this)}m(){var e=new Zu;Xu(e,"image_in"),Xu(e,"norm_rect"),Ju(e,"hand_gestures"),Ju(e,"hand_landmarks"),Ju(e,"world_hand_landmarks"),Ju(e,"handedness");const t=new Fu;pl(t,Td,this.v);const n=new zu;$u(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),ju(n,"IMAGE:image_in"),ju(n,"NORM_RECT:norm_rect"),Gu(n,"HAND_GESTURES:hand_gestures"),Gu(n,"LANDMARKS:hand_landmarks"),Gu(n,"WORLD_LANDMARKS:world_hand_landmarks"),Gu(n,"HANDEDNESS:handedness"),n.o(t),Yu(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e){e=kc(t);const n=[];for(const t of tl(e,Ec,1))n.push({x:ul(t,1)??0,y:ul(t,2)??0,z:ul(t,3)??0});this.landmarks.push(n)}dh(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{dh(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e){e=xc(t);const n=[];for(const t of tl(e,yc,1))n.push({x:ul(t,1)??0,y:ul(t,2)??0,z:ul(t,3)??0});this.worldLandmarks.push(n)}dh(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{dh(this,e)})),this.g.attachProtoVectorListener("hand_gestures",((e,t)=>{this.gestures.push(...Ef(e,!1)),dh(this,t)})),this.g.attachEmptyPacketListener("hand_gestures",(e=>{dh(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{this.handedness.push(...Ef(e)),dh(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{dh(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Tf(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Sf.prototype.recognizeForVideo=Sf.prototype.wa,Sf.prototype.recognize=Sf.prototype.va,Sf.prototype.setOptions=Sf.prototype.o,Sf.createFromModelPath=function(e,t){return Zh(Sf,e,{baseOptions:{modelAssetPath:t}})},Sf.createFromModelBuffer=function(e,t){return Zh(Sf,e,{baseOptions:{modelAssetBuffer:t}})},Sf.createFromOptions=function(e,t){return Zh(Sf,e,t)},Sf.HAND_CONNECTIONS=bf,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$gesture_recognizer$gesture_recognizer.GestureRecognizer.HAND_CONNECTIONS",Sf.HAND_CONNECTIONS);var kf=class extends rf{constructor(e,t){super(new Jh(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.j=new bd,e=new Kc,nl(this.j,0,1,e),this.s=new vd,nl(this.j,0,3,this.s),this.h=new gd,nl(this.j,0,2,this.h),dl(this.h,3,1),hl(this.h,2,.5),hl(this.s,2,.5),hl(this.j,4,.5)}get baseOptions(){return Qs(this.j,Kc,1)}set baseOptions(e){nl(this.j,0,1,e)}o(e){return"numHands"in e&&dl(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&hl(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&hl(this.j,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&hl(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ef(this,e,t),Tf(this)}D(e,t,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],tf(this,e,n,t),Tf(this)}m(){var e=new Zu;Xu(e,"image_in"),Xu(e,"norm_rect"),Ju(e,"hand_landmarks"),Ju(e,"world_hand_landmarks"),Ju(e,"handedness");const t=new Fu;pl(t,Sd,this.j);const n=new zu;$u(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),ju(n,"IMAGE:image_in"),ju(n,"NORM_RECT:norm_rect"),Gu(n,"LANDMARKS:hand_landmarks"),Gu(n,"WORLD_LANDMARKS:world_hand_landmarks"),Gu(n,"HANDEDNESS:handedness"),n.o(t),Yu(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e)e=kc(t),this.landmarks.push(Wd(e));dh(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{dh(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e)e=xc(t),this.worldLandmarks.push(Kd(e));dh(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{dh(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{var n=this.handedness,r=n.push;const i=[];for(const t of e){e=oc(t);const n=[];for(const t of e.g())n.push({score:ul(t,2)??0,index:ll(al(t,1))??-1,categoryName:sl(t,3)??""??"",displayName:sl(t,4)??""??""});i.push(n)}r.call(n,...i),dh(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{dh(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};kf.prototype.detectForVideo=kf.prototype.D,kf.prototype.detect=kf.prototype.F,kf.prototype.setOptions=kf.prototype.o,kf.createFromModelPath=function(e,t){return Zh(kf,e,{baseOptions:{modelAssetPath:t}})},kf.createFromModelBuffer=function(e,t){return Zh(kf,e,{baseOptions:{modelAssetBuffer:t}})},kf.createFromOptions=function(e,t){return Zh(kf,e,t)},kf.HAND_CONNECTIONS=bf,Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$hand_landmarker$hand_landmarker.HandLandmarker.HAND_CONNECTIONS",kf.HAND_CONNECTIONS);var Cf=class extends rf{constructor(e,t){super(new Jh(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},this.h=new kd,e=new Kc,nl(this.h,0,1,e)}get baseOptions(){return Qs(this.h,Kc,1)}set baseOptions(e){nl(this.h,0,1,e)}o(e){var t=qd(e,Qs(this.h,$c,2));return nl(this.h,0,2,t),this.l(e)}ga(e,t){return this.j={classifications:[]},ef(this,e,t),this.j}ha(e,t,n){return this.j={classifications:[]},tf(this,e,n,t),this.j}m(){var e=new Zu;Xu(e,"input_image"),Xu(e,"norm_rect"),Ju(e,"classifications");const t=new Fu;pl(t,Cd,this.h);const n=new zu;$u(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),ju(n,"IMAGE:input_image"),ju(n,"NORM_RECT:norm_rect"),Gu(n,"CLASSIFICATIONS:classifications"),n.o(t),Yu(e,n),this.g.attachProtoListener("classifications",((e,t)=>{this.j=function(e){const t={classifications:tl(e,_c,1).map((e=>Hd(Qs(e,ic,4)?.g()??[],ll(al(e,2)),sl(e,3)??"")))};return null!=ol(e)&&(t.timestampMs=ll(ol(e))),t}(Fc(e)),dh(this,t)})),this.g.attachEmptyPacketListener("classifications",(e=>{dh(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Cf.prototype.classifyForVideo=Cf.prototype.ha,Cf.prototype.classify=Cf.prototype.ga,Cf.prototype.setOptions=Cf.prototype.o,Cf.createFromModelPath=function(e,t){return Zh(Cf,e,{baseOptions:{modelAssetPath:t}})},Cf.createFromModelBuffer=function(e,t){return Zh(Cf,e,{baseOptions:{modelAssetBuffer:t}})},Cf.createFromOptions=function(e,t){return Zh(Cf,e,t)};var Af=class extends rf{constructor(e,t){super(new Jh(e,t),"image_in","norm_rect",!0),this.h=new Ad,this.embeddings={embeddings:[]},e=new Kc,nl(this.h,0,1,e)}get baseOptions(){return Qs(this.h,Kc,1)}set baseOptions(e){nl(this.h,0,1,e)}o(e){var t=this.h,n=Qs(this.h,Gc,2);return n=n?n.clone():new Gc,void 0!==e.l2Normalize?cl(n,1,e.l2Normalize):"l2Normalize"in e&&Us(n,1),void 0!==e.quantize?cl(n,2,e.quantize):"quantize"in e&&Us(n,2),nl(t,0,2,n),this.l(e)}la(e,t){return ef(this,e,t),this.embeddings}ma(e,t,n){return tf(this,e,n,t),this.embeddings}m(){var e=new Zu;Xu(e,"image_in"),Xu(e,"norm_rect"),Ju(e,"embeddings_out");const t=new Fu;pl(t,Rd,this.h);const n=new zu;$u(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),ju(n,"IMAGE:image_in"),ju(n,"NORM_RECT:norm_rect"),Gu(n,"EMBEDDINGS:embeddings_out"),n.o(t),Yu(e,n),this.g.attachProtoListener("embeddings_out",((e,t)=>{e=Uc(e),this.embeddings=function(e){return{embeddings:tl(e,Nc,1).map((e=>{const t={headIndex:ll(al(e,3))??-1,headName:sl(e,4)??""??""};if(void 0!==Zs(e,Lc,Ys(e,1)))e=qs(e=Qs(e,Lc,Ys(e,1)),1,os),t.floatEmbedding=e;else{const n=new Uint8Array(0);t.quantizedEmbedding=Qs(e,Mc,Ys(e,2))?.da()?.fa()??n}return t})),timestampMs:ll(ol(e))}}(e),dh(this,t)})),this.g.attachEmptyPacketListener("embeddings_out",(e=>{dh(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Af.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Xd(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Xd(Yd(e.quantizedEmbedding),Yd(t.quantizedEmbedding))}return e},Af.prototype.embedForVideo=Af.prototype.ma,Af.prototype.embed=Af.prototype.la,Af.prototype.setOptions=Af.prototype.o,Af.createFromModelPath=function(e,t){return Zh(Af,e,{baseOptions:{modelAssetPath:t}})},Af.createFromModelBuffer=function(e,t){return Zh(Af,e,{baseOptions:{modelAssetBuffer:t}})},Af.createFromOptions=function(e,t){return Zh(Af,e,t)};var Rf=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){this.confidenceMasks?.forEach((e=>{e.close()})),this.categoryMask?.close()}};function _f(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function If(e){try{const t=new Rf(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{ph(e)}}Rf.prototype.close=Rf.prototype.close;var Df=class extends rf{constructor(e,t){super(new Jh(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Ld,this.v=new _d,nl(this.h,0,3,this.v),e=new Kc,nl(this.h,0,1,e)}get baseOptions(){return Qs(this.h,Kc,1)}set baseOptions(e){nl(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?Us(this.h,2,hs(e.displayNamesLocale)):"displayNamesLocale"in e&&Us(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}N(){!function(e){const t=tl(e.U(),zu,1).filter((e=>(sl(e,1)??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator")));if(e.s=[],1<t.length)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");1===t.length&&(Qs(t[0],Fu,7)?.l()?.g()??new Map).forEach(((t,n)=>{e.s[Number(n)]=sl(t,1)??""}))}(this)}V(e,t,n){const r="function"!=typeof t?t:{};return this.j="function"==typeof t?t:n,_f(this),ef(this,e,r),If(this)}ya(e,t,n,r){const i="function"!=typeof n?n:{};return this.j="function"==typeof n?n:r,_f(this),tf(this,e,i,t),If(this)}ra(){return this.s}m(){var e=new Zu;Xu(e,"image_in"),Xu(e,"norm_rect");const t=new Fu;pl(t,Md,this.h);const n=new zu;$u(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),ju(n,"IMAGE:image_in"),ju(n,"NORM_RECT:norm_rect"),n.o(t),Yu(e,n),hh(this,e),this.outputConfidenceMasks&&(Ju(e,"confidence_masks"),Gu(n,"CONFIDENCE_MASKS:confidence_masks"),fh(this,"confidence_masks"),this.g.R("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>nf(this,e,!this.j))),dh(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],dh(this,e)}))),this.outputCategoryMask&&(Ju(e,"category_mask"),Gu(n,"CATEGORY_MASK:category_mask"),fh(this,"category_mask"),this.g.P("category_mask",((e,t)=>{this.categoryMask=nf(this,e,!this.j),dh(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,dh(this,e)}))),Ju(e,"quality_scores"),Gu(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,dh(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,dh(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Df.prototype.getLabels=Df.prototype.ra,Df.prototype.segmentForVideo=Df.prototype.ya,Df.prototype.segment=Df.prototype.V,Df.prototype.setOptions=Df.prototype.o,Df.createFromModelPath=function(e,t){return Zh(Df,e,{baseOptions:{modelAssetPath:t}})},Df.createFromModelBuffer=function(e,t){return Zh(Df,e,{baseOptions:{modelAssetBuffer:t}})},Df.createFromOptions=function(e,t){return Zh(Df,e,t)};var Ff=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){this.confidenceMasks?.forEach((e=>{e.close()})),this.categoryMask?.close()}};Ff.prototype.close=Ff.prototype.close;var Lf=class extends gl{constructor(e){super(e)}},Mf=[0,Ql,Ql,Ql],Nf=[0,Vl,Vl,Vl,Vl,nu],Of=[0,Vl,Vl,Vl,Vl,nu,Vl,Vl],Pf=[0,lu,Of],Bf=[0,lu,Pf,lu,Mf],Uf=[0,lu,Of,lu,Mf],$f=[0,lu,Of,Ql,Ql],jf=[0,lu,$f,lu,Mf],Gf=[0,Vl,Vl,Vl,Vl,nu,lu,Mf,lu,Mf],zf=[0,Vl,Vl,Vl,Vl,nu,fu],qf=class extends gl{constructor(e){super(e)}},Hf=[0,Vl,Vl,nu],Vf=class extends gl{constructor(){super()}};Vf.B=[1];var Wf=class extends gl{constructor(e){super(e)}},Kf=[1,2,3,4,5,6,7,8,9,10,14,15],Yf=[0,cu,Of,Kf,cu,Uf,Kf,cu,Pf,Kf,cu,Bf,Kf,cu,Hf,Kf,cu,zf,Kf,cu,Nf,Kf,cu,[0,ou,Vl,Vl,Vl,nu,Ql,nu,nu,Vl,3,lu,Mf],Kf,cu,$f,Kf,cu,jf,Kf,Vl,lu,Mf,ou,cu,Gf,Kf,cu,[0,uu,Hf],Kf],Xf=[0,ou,Ql,Ql,nu],Jf=class extends gl{constructor(){super()}};Jf.B=[1],Jf.prototype.g=yu([0,uu,Yf,ou,lu,Xf]);var Zf=class extends rf{constructor(e,t){super(new Jh(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Ld,this.v=new _d,nl(this.h,0,3,this.v),e=new Kc,nl(this.h,0,1,e)}get baseOptions(){return Qs(this.h,Kc,1)}set baseOptions(e){nl(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}V(e,t,n,r){const i="function"!=typeof n?n:{};this.j="function"==typeof n?n:r,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.H+1,r=new Jf;const a=new Wf;var o=new Lf;if(dl(o,1,255),nl(a,0,12,o),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var s=new qf;cl(s,3,!0),hl(s,1,t.keypoint.x),hl(s,2,t.keypoint.y),rl(a,5,Kf,s)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(s of(o=new Vf,t.scribble))cl(t=new qf,3,!0),hl(t,1,s.x),hl(t,2,s.y),il(o,qf,t);rl(a,15,Kf,o)}il(r,Wf,a),this.g.addProtoToStream(r.g(),"drishti.RenderData","roi_in",n),ef(this,e,i);e:{try{const e=new Ff(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=e;break e}this.j(e)}finally{ph(this)}l=void 0}return l}m(){var e=new Zu;Xu(e,"image_in"),Xu(e,"roi_in"),Xu(e,"norm_rect_in");const t=new Fu;pl(t,Md,this.h);const n=new zu;$u(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),ju(n,"IMAGE:image_in"),ju(n,"ROI:roi_in"),ju(n,"NORM_RECT:norm_rect_in"),n.o(t),Yu(e,n),hh(this,e),this.outputConfidenceMasks&&(Ju(e,"confidence_masks"),Gu(n,"CONFIDENCE_MASKS:confidence_masks"),fh(this,"confidence_masks"),this.g.R("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>nf(this,e,!this.j))),dh(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],dh(this,e)}))),this.outputCategoryMask&&(Ju(e,"category_mask"),Gu(n,"CATEGORY_MASK:category_mask"),fh(this,"category_mask"),this.g.P("category_mask",((e,t)=>{this.categoryMask=nf(this,e,!this.j),dh(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,dh(this,e)}))),Ju(e,"quality_scores"),Gu(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,dh(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,dh(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Zf.prototype.segment=Zf.prototype.V,Zf.prototype.setOptions=Zf.prototype.o,Zf.createFromModelPath=function(e,t){return Zh(Zf,e,{baseOptions:{modelAssetPath:t}})},Zf.createFromModelBuffer=function(e,t){return Zh(Zf,e,{baseOptions:{modelAssetBuffer:t}})},Zf.createFromOptions=function(e,t){return Zh(Zf,e,t)};var Qf=class extends rf{constructor(e,t){super(new Jh(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},this.h=new Nd,e=new Kc,nl(this.h,0,1,e)}get baseOptions(){return Qs(this.h,Kc,1)}set baseOptions(e){nl(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?Us(this.h,2,hs(e.displayNamesLocale)):"displayNamesLocale"in e&&Us(this.h,2),void 0!==e.maxResults?dl(this.h,3,e.maxResults):"maxResults"in e&&Us(this.h,3),void 0!==e.scoreThreshold?hl(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&Us(this.h,4),void 0!==e.categoryAllowlist?Ks(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&Us(this.h,5),void 0!==e.categoryDenylist?Ks(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&Us(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},ef(this,e,t),this.j}D(e,t,n){return this.j={detections:[]},tf(this,e,n,t),this.j}m(){var e=new Zu;Xu(e,"input_frame_gpu"),Xu(e,"norm_rect"),Ju(e,"detections");const t=new Fu;pl(t,Od,this.h);const n=new zu;$u(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),ju(n,"IMAGE:input_frame_gpu"),ju(n,"NORM_RECT:norm_rect"),Gu(n,"DETECTIONS:detections"),n.o(t),Yu(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=vc(t),this.j.detections.push(Vd(e));dh(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{dh(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function ep(e){e.landmarks=[],e.worldLandmarks=[],e.v=void 0}function tp(e){try{const t=new class{constructor(e,t,n){this.landmarks=e,this.worldLandmarks=t,this.g=n}close(){this.g?.forEach((e=>{e.close()}))}}(e.landmarks,e.worldLandmarks,e.v);if(!e.s)return t;e.s(t)}finally{ph(e)}}Qf.prototype.detectForVideo=Qf.prototype.D,Qf.prototype.detect=Qf.prototype.F,Qf.prototype.setOptions=Qf.prototype.o,Qf.createFromModelPath=async function(e,t){return Zh(Qf,e,{baseOptions:{modelAssetPath:t}})},Qf.createFromModelBuffer=function(e,t){return Zh(Qf,e,{baseOptions:{modelAssetBuffer:t}})},Qf.createFromOptions=function(e,t){return Zh(Qf,e,t)};var np=class extends rf{constructor(e,t){super(new Jh(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,this.h=new jd,e=new Kc,nl(this.h,0,1,e),this.C=new Ud,nl(this.h,0,3,this.C),this.j=new Pd,nl(this.h,0,2,this.j),dl(this.j,4,1),hl(this.j,2,.5),hl(this.C,2,.5),hl(this.h,4,.5)}get baseOptions(){return Qs(this.h,Kc,1)}set baseOptions(e){nl(this.h,0,1,e)}o(e){return"numPoses"in e&&dl(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&hl(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&hl(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&hl(this.C,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}F(e,t,n){const r="function"!=typeof t?t:{};return this.s="function"==typeof t?t:n,ep(this),ef(this,e,r),tp(this)}D(e,t,n,r){const i="function"!=typeof n?n:{};return this.s="function"==typeof n?n:r,ep(this),tf(this,e,i,t),tp(this)}m(){var e=new Zu;Xu(e,"image_in"),Xu(e,"norm_rect"),Ju(e,"normalized_landmarks"),Ju(e,"world_landmarks"),Ju(e,"segmentation_masks");const t=new Fu;pl(t,zd,this.h);const n=new zu;$u(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),ju(n,"IMAGE:image_in"),ju(n,"NORM_RECT:norm_rect"),Gu(n,"NORM_LANDMARKS:normalized_landmarks"),Gu(n,"WORLD_LANDMARKS:world_landmarks"),n.o(t),Yu(e,n),hh(this,e),this.g.attachProtoVectorListener("normalized_landmarks",((e,t)=>{this.landmarks=[];for(const t of e)e=kc(t),this.landmarks.push(Wd(e));dh(this,t)})),this.g.attachEmptyPacketListener("normalized_landmarks",(e=>{this.landmarks=[],dh(this,e)})),this.g.attachProtoVectorListener("world_landmarks",((e,t)=>{this.worldLandmarks=[];for(const t of e)e=xc(t),this.worldLandmarks.push(Kd(e));dh(this,t)})),this.g.attachEmptyPacketListener("world_landmarks",(e=>{this.worldLandmarks=[],dh(this,e)})),this.outputSegmentationMasks&&(Gu(n,"SEGMENTATION_MASK:segmentation_masks"),fh(this,"segmentation_masks"),this.g.R("segmentation_masks",((e,t)=>{this.v=e.map((e=>nf(this,e,!this.s))),dh(this,t)})),this.g.attachEmptyPacketListener("segmentation_masks",(e=>{this.v=[],dh(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};np.prototype.detectForVideo=np.prototype.D,np.prototype.detect=np.prototype.F,np.prototype.setOptions=np.prototype.o,np.createFromModelPath=function(e,t){return Zh(np,e,{baseOptions:{modelAssetPath:t}})},np.createFromModelBuffer=function(e,t){return Zh(np,e,{baseOptions:{modelAssetBuffer:t}})},np.createFromOptions=function(e,t){return Zh(np,e,t)},np.POSE_CONNECTIONS=Kh([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]),Zi("module$exports$google3$third_party$mediapipe$tasks$web$vision$pose_landmarker$pose_landmarker.PoseLandmarker.POSE_CONNECTIONS",np.POSE_CONNECTIONS);var rp;function ip(e,t,n,r){t.forEach((function(t){var i=t.keypoints.map((function(e){return[e.x,e.y]}));if(n){e.strokeStyle="#FF2C35",e.lineWidth=1;var a=t.box;!function(e,t,n){var r=new Path2D;r.moveTo(t[0][0],t[0][1]);for(var i=1;i<t.length;i++){var a=t[i];r.lineTo(a[0],a[1])}n&&r.closePath(),e.stroke(r)}(e,[[a.xMin,a.yMin],[a.xMax,a.yMin],[a.xMax,a.yMax],[a.xMin,a.yMax]],!0)}if(r){e.fillStyle="#32EEDB";for(var o=0;o<6;o++){var s=i[o][0],l=i[o][1];e.beginPath(),e.arc(s,l,3,0,2*Math.PI),e.fill()}}}))}function ap(){return g(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return rp?[2,rp]:[4,th.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.6/wasm")];case 1:return e=t.sent(),[4,af.createFromOptions(e,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite",delegate:"GPU"},runningMode:"VIDEO"})];case 2:return[2,rp=t.sent()]}}))}))}var op=n.createContext({start:function(){return null},stop:function(){return null},onPredictionMade:function(){return null},canvasRef:{current:null},ready:!1}),sp=function(e){var t=e.autoStart,r=void 0===t||t,i=e.children,a=e.throttleMs,o=n.useContext(Ft),s=o.videoRef,l=o.videoLoaded,u=o.cameraReady,d=n.useRef(null),h=n.useRef(),f=n.useState(!1),v=f[0],y=f[1],b=n.useState(!1),w=b[0],x=b[1],E=n.useRef(null),S=n.useRef(0),T=n.useRef(0);n.useEffect((function(){g(void 0,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return y(!1),e=E,[4,ap()];case 1:return e.current=t.sent(),y(!0),[2]}}))}))}),[]),n.useEffect((function(){if(l&&u&&w&&v){var e;T.current+=1;var t=T.current;return g(void 0,void 0,void 0,(function(){var n,r,i,o;return m(this,(function(l){switch(l.label){case 0:return s.current&&E.current?(n=null===(r=d.current)||void 0===r?void 0:r.getContext("2d"),d.current&&(d.current.width=null===(i=s.current)||void 0===i?void 0:i.videoWidth,d.current.height=null===(o=s.current)||void 0===o?void 0:o.videoHeight,null==n||n.translate(s.current.videoWidth,0),null==n||n.scale(-1,1)),[4,function r(){var i;return g(this,void 0,void 0,(function(){var o,l,u,c,d;return m(this,(function(f){switch(f.label){case 0:return E.current&&s.current&&t===T.current?s.current.readyState<2?[4,new Promise((function(e){s.current&&(s.current.onloadeddata=function(){e([])})}))]:[3,2]:[2];case 1:f.sent(),f.label=2;case 2:o=s.current.videoWidth,l=s.current.videoHeight,null==n||n.drawImage(s.current,0,0,o,l),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,E.current.detectForVideo(s.current,performance.now())];case 4:return(u=f.sent())&&(c=u.detections.map((function(e){var t,n,r,i,a,s,u,c,d,h,f,g,m,v,y,b;return{keypoints:e.keypoints.map((function(e){var t;return p(p({},e),{x:e.x*o,y:e.y*l,name:null!==(t=e.label)&&void 0!==t?t:""})})),box:{xMin:null!==(n=null===(t=e.boundingBox)||void 0===t?void 0:t.originX)&&void 0!==n?n:0,xMax:(null!==(i=null===(r=e.boundingBox)||void 0===r?void 0:r.originX)&&void 0!==i?i:0)+(null!==(s=null===(a=e.boundingBox)||void 0===a?void 0:a.width)&&void 0!==s?s:0),yMin:null!==(c=null===(u=e.boundingBox)||void 0===u?void 0:u.originY)&&void 0!==c?c:0,yMax:(null!==(h=null===(d=e.boundingBox)||void 0===d?void 0:d.originY)&&void 0!==h?h:0)+(null!==(g=null===(f=e.boundingBox)||void 0===f?void 0:f.height)&&void 0!==g?g:0),width:null!==(v=null===(m=e.boundingBox)||void 0===m?void 0:m.width)&&void 0!==v?v:0,height:null!==(b=null===(y=e.boundingBox)||void 0===y?void 0:y.height)&&void 0!==b?b:0}}})),null===(i=h.current)||void 0===i||i.call(h,c),n&&ip(n,c,!0,!0)),[3,6];case 5:return d=f.sent(),console.error("caught face detection error",d),[3,6];case 6:return a?e=setTimeout((function(){S.current=requestAnimationFrame(r)}),a):S.current=requestAnimationFrame(r),[2]}}))}))}()]):[2];case 1:return l.sent(),[2]}}))})),function(){S.current&&cancelAnimationFrame(S.current),e&&clearTimeout(e)}}}),[u,v,w,a,l,s]);var k=n.useCallback((function(){x(!0)}),[]),C=n.useCallback((function(){x(!1)}),[]);n.useEffect((function(){return r&&k(),function(){C()}}),[r,k,C]);var A=n.useCallback((function(e){h.current=e}),[]),R=n.useMemo((function(){return{start:k,stop:C,ready:v,canvasRef:d,onPredictionMade:A}}),[A,v,k,C]);return c.createElement(op.Provider,{value:R},i)},lp={videoWidth:0,videoHeight:0,capturing:!1,captured:!1,captureFailed:!1,frame:null,faces:[],faceNotCentered:!1,faceLookingAway:!1,faceTooClose:!1,faceTooFar:!1,faceReady:!1,faceReadyAt:null,goodFramesCount:0,goodFramesThreshold:1,goodFramesThresholdMet:!1},up=function(e,t){switch(t.type){case"configure":return p(p({},e),{videoWidth:t.payload.videoWidth,videoHeight:t.payload.videoHeight});case"capturing":return p(p({},e),{capturing:!0,captured:!1,captureFailed:!1});case"captured":return p(p({},e),{capturing:!1,captured:!0,captureFailed:!1});case"captureFailed":return p(p({},e),{capturing:!1,captured:!1,captureFailed:!0});case"facesDetected":var n=t.payload.faces,r=n[0],i=!0,a=!1,o=!1,s=!1,l=e.faceReadyAt,u=e.goodFramesCount;if(r){var c=e.videoHeight/2,d=(r.box.xMin+r.box.xMax)/2,h=(r.box.yMin+r.box.yMax)/2,f=.125*e.videoWidth,g=.125*e.videoHeight,m=.2*r.box.width,v=.2*r.box.height,y=r.keypoints[2];y&&(i=Math.abs(e.videoWidth/2-d)>f||Math.abs(c+50-h)>g,a=Math.abs(d-y.x)>m||Math.abs(h-y.y)>v);var b=e.videoWidth<e.videoHeight;o=r.box.width>e.videoWidth/(b?2:4.5),s=r.box.width<e.videoWidth/(b?6:7)}var w=!(i||a||o||s);return w?e.faceReady||(l=new Date):(l=null,u=0),p(p({},e),{faces:n,faceNotCentered:i,faceLookingAway:a,faceTooClose:o,faceTooFar:s,faceReady:w,faceReadyAt:l,goodFramesCount:u})}},cp=function(e){var t,r,i,a=e.onGuidanceSatisfied,o=e.onGuidanceNotSatisfied,s=e.onSelfieCaptured,l=e.onTimeout,c=e.timeoutDurationMs,d=void 0===c?15e3:c,h=e.guidanceMessage,f=e.verbiage,p=void 0===f?{}:f,v=e.debugMode,y=ye().t,b=Et(),w=b.ref,x=b.width,E=void 0===x?1:x,S=b.height,T=void 0===S?1:S,k=n.useReducer(up,lp),C=k[0],A=k[1],R=n.useContext(Ft),_=R.cameraRef,I=R.cameraReady,D=R.takePhoto,F=R.videoRef,L=n.useContext(op).onPredictionMade;n.useEffect((function(){I&&F.current&&0!==F.current.videoWidth&&A({type:"configure",payload:{videoWidth:F.current.videoWidth,videoHeight:F.current.videoHeight}})}),[I,F]),n.useEffect((function(){L((function(e){A({type:"facesDetected",payload:{faces:e}})}))}),[L]);var M=n.useState(!1),N=M[0],O=M[1];n.useEffect((function(){var e;return C.faceReady?(null==a||a(),e=setTimeout((function(){O(!0)}),500)):null==o||o(),function(){e&&clearTimeout(e)}}),[o,a,C.faceReady]),n.useEffect((function(){g(void 0,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return N&&C.faces.length>0?[4,D()]:[3,5];case 1:return(e=n.sent())?null!=s?[3,2]:[3,4]:[3,5];case 2:return t=s,[4,createImageBitmap(e)];case 3:t.apply(void 0,[n.sent(),C.faces[0]]),n.label=4;case 4:n.label=5;case 5:return[2]}}))}))}),[N,s,C.faces,D]);var P=n.useState(),B=P[0],U=P[1],$=n.useState(!1),j=$[0],G=$[1];n.useEffect((function(){if(d){U(new Date);var e=setTimeout((function(){G(!0)}),d);return function(){e&&clearTimeout(e)}}}),[d]),n.useEffect((function(){j&&(null==l||l())}),[l,j]);var z=Ii({enabled:v,pageWidth:E,pageHeight:T,videoWidth:C.videoWidth,videoHeight:C.videoHeight});return h||(p.guidanceHoldStillText=p.guidanceHoldStillText||y("Hold still for a few seconds..."),p.guidanceLookStraightText=p.guidanceLookStraightText||y("Look straight into the camera..."),p.guidanceMoveBackText=p.guidanceMoveBackText||y("Move back..."),p.guidanceMoveForwardText=p.guidanceMoveForwardText||y("Move forward..."),p.guidanceMoveToCenterText=p.guidanceMoveToCenterText||y("Move to the center..."),h=C.faceReady?p.guidanceHoldStillText:C.faceLookingAway?p.guidanceLookStraightText:C.faceTooClose?p.guidanceMoveBackText:C.faceTooFar?p.guidanceMoveForwardText:C.faceNotCentered?p.guidanceMoveToCenterText:""),u.default.createElement(Ze,{ref:w,className:"flex"},u.default.createElement(Hi,null),u.default.createElement(Xi,{borderColor:C.faceReady?"green":"white"}),""!==h&&u.default.createElement("div",{style:{position:"absolute",top:"calc(10vh)",fontWeight:"bold",width:"100%",display:"flex"}},u.default.createElement("div",{style:{marginLeft:"auto",marginRight:"auto",background:C.faceReady?"green":"red",color:"white",padding:"10px 12px 8px",borderRadius:8}},h)),v&&C.faces.length>0&&u.default.createElement(Ai,{$flipX:!(null===(t=_.current)||void 0===t?void 0:t.isRearFacing)},C.faces.map((function(e,t){var n;return u.default.createElement(Fi,{key:t,face:e,scaling:z,flipX:!(null===(n=_.current)||void 0===n?void 0:n.isRearFacing),color:C.faceReady?"green":"red"})}))),v&&u.default.createElement(Ci,null,_.current?u.default.createElement(u.default.Fragment,null,"✅ Camera: ",null===(r=_.current)||void 0===r?void 0:r.width,"x",null===(i=_.current)||void 0===i?void 0:i.height):"❌ Camera not ready",u.default.createElement("br",null),C.faceNotCentered?"❌":"✅"," Face Centered",u.default.createElement("br",null),C.faceTooClose||C.faceTooFar?"❌":"✅"," Face"," ",C.faceTooClose?"Too Close":C.faceTooFar?"Too Far":"Distance Correct",u.default.createElement("br",null),C.faceLookingAway?"❌":"✅"," Face Looking Forward",u.default.createElement("br",null),C.goodFramesThresholdMet?"✅":"❌"," ",C.goodFramesCount," ","Good Frames",u.default.createElement("br",null),j?"❌":"✅"," Time Remaining:"," ",Math.max(0,d-((new Date).getTime()-(null!=B?B:new Date).getTime())),"ms"))},dp={frame:null,face:null,requestState:"NOT_READY",requestError:null,imageUrl:null,faceLive:!1,eyeCoveringDetected:!1,maskDetected:!1,headCoveringDetected:!1,phoneDetected:!1,timesLivenessCheckFailed:0},hp=function(e,t){switch(t.type){case"livenessReady":return["NOT_READY","FAILED","ERROR"].includes(e.requestState)?p(p({},e),{requestState:"READY",frame:t.payload.frame,face:t.payload.face}):e;case"livenessChecking":return p(p({},e),{requestState:"IN_PROGRESS"});case"livenessChecked":var n=t.payload.response,r=n.status,i=r.statusMessage,a=r.errorData,o=n.resultData;if("000"!==r.statusCode)return p(p({},e),{requestState:"ERROR",requestError:new Error("".concat(i,": ").concat(a))});var s="Live Face Detected"===o.verificationResult,l="true"===o.eyeCovering,u="true"===o.faceMask,c="true"===o.headCovering,d="true"===o.cellPhone,h=s&&!l&&!u&&!c,f=h?"PASSED":"FAILED",g=e.timesLivenessCheckFailed;return h?g=0:g+=1,p(p({},e),{frame:t.payload.frame,face:t.payload.face,imageUrl:t.payload.imageUrl,requestState:f,faceLive:s,eyeCoveringDetected:l,maskDetected:u,headCoveringDetected:c,phoneDetected:d,timesLivenessCheckFailed:g});case"livenessCheckFailed":return p(p({},e),{requestState:"ERROR",requestError:t.payload.error});default:return e}},fp=function(e){var t=e.onCapture,r=e.onSuccess,i=e.onTimeout,a=e.timeoutDurationMs,o=void 0===a?15e3:a,s=e.verbiage,l=void 0===s?{}:s,c=e.debugMode,d=ye().t,h=n.useContext(qe).checkLiveness,f=n.useReducer(hp,dp),p=f[0],v=f[1],y=n.useCallback((function(e,n){null==t||t(),v({type:"livenessReady",payload:{frame:e,face:n}})}),[t]),b=p.frame,w=p.face,x="READY"===p.requestState,E="PASSED"===p.requestState;return n.useEffect((function(){b&&w&&x&&(v({type:"livenessChecking"}),g(void 0,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),e=ci(b,w),n=h,[4,We(e)];case 1:return[4,n.apply(void 0,[i.sent()])];case 2:return t=i.sent(),v({type:"livenessChecked",payload:{frame:b,face:w,imageUrl:e,response:t}}),[3,4];case 3:return r=i.sent(),v({type:"livenessCheckFailed",payload:{error:r}}),[3,4];case 4:return[2]}}))})))}),[h,w,b,x]),n.useEffect((function(){E&&p.imageUrl&&(null==r||r(p.imageUrl))}),[r,p.imageUrl,E]),n.useEffect((function(){p.timesLivenessCheckFailed>=2&&(null==i||i())}),[i,p.timesLivenessCheckFailed]),l.guidanceRemoveEyeCoveringsText=l.guidanceRemoveEyeCoveringsText||d("Please remove your eye coverings (sunglasses, eye patch, etc.)..."),l.guidanceRemoveHeadCoveringsText=l.guidanceRemoveHeadCoveringsText||d("Please remove your head coverings (hat, scarf, etc.)..."),l.guidanceRemoveMaskText=l.guidanceRemoveMaskText||d("Please remove your mask..."),u.default.createElement(cp,{onSelfieCaptured:y,onTimeout:i,timeoutDurationMs:o,guidanceMessage:p.eyeCoveringDetected?l.guidanceRemoveEyeCoveringsText:p.headCoveringDetected?l.guidanceRemoveHeadCoveringsText:p.maskDetected?l.guidanceRemoveMaskText:void 0,verbiage:l,debugMode:c})},pp=function(e){var t=e.headingText,r=e.removeEyeCoveringsText,i=e.avoidExcessiveBacklightingText,a=e.continueText,o=e.cameraInitializingText,s=e.modelsWarmingUpText,l=e.instructionImageUrl,c=e.onDismissed,d=ye().t,h=n.useRef(null),f=n.useRef(null),p=n.useContext(Ft).cameraReady,g=n.useContext(op).ready,m=n.useState(!1),v=m[0],y=m[1];return n.useEffect((function(){if(h.current){f.current=pt(h.current),f.current.start();var e=0,t=setInterval((function(){var t;e<.9&&(e+=.1),null===(t=f.current)||void 0===t||t.setProgress(e)}),250);return function(){var e;null===(e=f.current)||void 0===e||e.remove(),clearInterval(t)}}}),[]),n.useEffect((function(){var e;g&&p&&(null===(e=f.current)||void 0===e||e.stop())}),[p,g]),v?u.default.createElement(u.default.Fragment,null):(l=l||"".concat(li,"/Selfie-Image-1.png"),t=t||d("Use your device camera to capture your face"),r=r||d("Remove Sunglasses & Hat"),i=i||d("Avoid Excessive Backlighting"),a=a||d("Continue"),o=o||d("Camera initializing..."),s=s||d("Models warming up..."),u.default.createElement(rt,null,u.default.createElement(it,null,u.default.createElement("div",{style:{flexGrow:0}},u.default.createElement("h3",{style:{marginBottom:18}},t),u.default.createElement("div",{style:{background:"#ccc",maxWidth:"280px",margin:"0 auto 12px",borderRadius:8,lineHeight:1.5,padding:"12px 24px"}},r,u.default.createElement("br",null),i)),u.default.createElement(at,null,u.default.createElement("img",{alt:t,src:l,style:{position:"relative",top:"5%"}})),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"mint",disabled:!p||!g,ref:h,onClick:function(){y(!0),null==c||c()}},u.default.createElement("span",{className:"ladda-label"},p&&g?a:g?o:s)),u.default.createElement("div",{style:{display:"none"}},u.default.createElement(Hi,null)))))},gp=function(e){var t=e.headingText,n=e.retryBtnText,r=e.doneBtnText,i=e.imageUrl,a=e.onDoneClick,o=e.onRetryClick,s=ye().t;return t=t||s("Face liveness has been verified!"),n=n||s("Retry"),r=r||s("Done"),u.default.createElement(rt,null,u.default.createElement(it,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(at,null,u.default.createElement("img",{alt:t,src:i})),u.default.createElement("div",null,u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"red",onClick:o},u.default.createElement("span",{className:"ladda-label"},n)),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"mint",onClick:a,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},r)))))},mp=function(e){var t=e.headingText,n=e.retryBtnText,r=e.exitBtnText,i=e.imageUrl,a=e.canRetry,o=void 0===a||a,s=e.onRetryClick,l=e.onExitClick,c=ye().t;return i=i||"".concat(li,"/manual_capture.png"),t=t||c("Live face not detected, please try again"),n=n||c("Retry"),r=r||c("Exit"),u.default.createElement(rt,null,u.default.createElement(it,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(at,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:i})),u.default.createElement("div",{style:{marginTop:24}},o&&u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"red",onClick:s,style:{marginRight:15}},u.default.createElement("span",{className:"ladda-label"},n)),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"black",onClick:l},u.default.createElement("span",{className:"ladda-label"},r)))))},vp=function(e){var t=e.onComplete,r=e.onSuccess,i=e.onTimeout,a=e.onExitAfterFailure,o=e.timeoutDurationMs,s=void 0===o?15e3:o,l=e.maxRetries,c=void 0===l?2:l,d=e.debugMode,h=void 0!==d&&d,f=e.verbiage,p=void 0===f?{}:f,v=e.assets,y=void 0===v?{}:v,b=n.useContext(qe),w=b.submissionResponse,x=b.setSelfieImage,E=b.logSelfieCaptureAttempt,S=n.useContext(Ft).releaseCameraAccess,T=n.useState(""),k=T[0],C=T[1],A=n.useState(0),R=A[0],_=A[1],I=n.useState("LOADING"),D=I[0],F=I[1],L=n.useRef(),M=n.useRef(),N=n.useRef();n.useEffect((function(){N.current=new Date}),[]),n.useEffect((function(){"CAPTURING"===D&&(L.current=new Date)}),[D]);var O=n.useCallback((function(){M.current=new Date}),[]),P=n.useCallback((function(){var e,t,n;E({autoCapture:"Y",captureTime:(null!==(e=M.current)&&void 0!==e?e:new Date).getTime()-(null!==(t=L.current)&&void 0!==t?t:new Date).getTime(),operationTime:(new Date).getTime()-(null!==(n=N.current)&&void 0!==n?n:new Date).getTime()}),N.current=new Date}),[E]),B=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return F("SUCCESS"),C(e),t=x,[4,We(e)];case 1:return t.apply(void 0,[n.sent()]),null==r||r(w),[2]}}))}))}),[r,x,w]),U=n.useCallback((function(){F("FAILED"),null==i||i(w)}),[i,w]);return u.default.createElement(u.default.Fragment,null,"LOADING"!==D&&function(){switch(D){case"CAPTURING":return u.default.createElement(fp,{key:"capture",onCapture:O,onSuccess:B,onTimeout:U,timeoutDurationMs:s,verbiage:p,debugMode:h});case"SUCCESS":return u.default.createElement(gp,{key:"success",headingText:p.successHeadingText,retryBtnText:p.successRetryBtnText,doneBtnText:p.successDoneBtnText,imageUrl:k,onDoneClick:function(){P(),S(),setTimeout((function(){null==t||t(w)}),0)},onRetryClick:function(){P(),F("CAPTURING")}});case"FAILED":return u.default.createElement(mp,{key:"failure",headingText:p.failureHeadingText,retryBtnText:p.failureRetryBtnText,exitBtnText:p.failureExitBtnText,imageUrl:y.failureImageUrl,canRetry:c>-1&&R<c,onRetryClick:function(){P(),_((function(e){return e+1})),F("CAPTURING")},onExitClick:function(){S(),setTimeout((function(){null==a||a(w)}),0)}});default:return null}}(),u.default.createElement(pp,{headingText:p.loadingOverlayHeadingText,removeEyeCoveringsText:p.loadingOverlayRemoveEyeCoveringsText,avoidExcessiveBacklightingText:p.loadingOverlayAvoidExcessiveBacklightingText,continueText:p.loadingOverlayContinueText,cameraInitializingText:p.loadingOverlayCameraInitializingText,modelsWarmingUpText:p.loadingOverlayModelsWarmingUpText,instructionImageUrl:y.instructionImageUrl,onDismissed:function(){F("CAPTURING")}}))};function yp(){if(!(["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document))return!1;var e=window.screen.width<window.screen.height?window.screen.width:window.screen.height,t=window.screen.width*window.devicePixelRatio,n=window.screen.height*window.devicePixelRatio;return 1179==t&&2556==n||1290==t&&2796==n&&(393==e||430==e)}var bp=[{label:"1080p(FHD)",width:1920,height:1080,ratio:"16:9"},{label:"UXGA",width:1600,height:1200,ratio:"4:3"},{label:"720p(HD)",width:1280,height:720,ratio:"16:9"},{label:"SVGA",width:800,height:600,ratio:"4:3"},{label:"VGA",width:640,height:480,ratio:"4:3"},{label:"360p(nHD)",width:640,height:360,ratio:"16:9"},{label:"CIF",width:352,height:288,ratio:"4:3"},{label:"QVGA",width:320,height:240,ratio:"4:3"},{label:"QCIF",width:176,height:144,ratio:"4:3"},{label:"QQVGA",width:160,height:120,ratio:"4:3"}],wp=function(e){return e.label.toLocaleLowerCase().split(" ").join("")},xp=function(e){var t=void 0===e?{preferFrontFacingCamera:!1,preferContinuityCamera:!0,requestMicrophoneAccess:!1}:e,r=t.preferFrontFacingCamera,i=t.preferContinuityCamera,a=t.requestMicrophoneAccess,o=n.useRef(null),s=n.useState(null),l=s[0],u=s[1],c=n.useRef(null),d=n.useState(!1),h=d[0],f=d[1],p=n.useState(null),v=p[0],y=p[1],b=n.useState(!1),w=b[0],x=b[1],E=n.useState(i),S=E[0],T=E[1],k=n.useState(!1),C=k[0],A=k[1],R=n.useState(!1),_=R[0],I=R[1];n.useEffect((function(){var e;console.log("iphone continuity camera allowed changed",S),null===(e=c.current)||void 0===e||e.release(),c.current=null,f(!1)}),[S]);var D=n.useCallback((function(){I(!1)}),[]);n.useEffect((function(){g(void 0,void 0,void 0,(function(){var e,t,n,i,a;return m(this,(function(o){switch(o.label){case 0:if(_)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({video:!0,audio:!1})];case 2:return e=o.sent(),[3,4];case 3:if("NotAllowedError"===(t=o.sent()).name)return console.error("caught the block!!",t),I(!0),[2];throw t;case 4:return[4,navigator.mediaDevices.enumerateDevices()];case 5:return n=o.sent().filter((function(e){return"videoinput"===e.kind})),C||(a=n.find((function(e){return wp(e).includes("iphonecamera")})),x(!!a),S&&(i=a)),r&&(i=n.find((function(e){return wp(e).includes("front")}))),i||(i=yp()?n.find((function(e){return wp(e).includes("backultrawidecamera")})):n.find((function(e){return wp(e).includes("back")&&!wp(e).includes("backultrawidecamera")}))),i||(i=n.find((function(e){return wp(e).includes("back")}))),i||(i=n[0]),u(i),e.getVideoTracks().forEach((function(e){e.stop()})),[2]}}))}))}),[_,S,C,r]),n.useEffect((function(){var e;if(l){var t=function(){var e;null===(e=c.current)||void 0===e||e.release(),c.current=null,f(!1)};if(!(null===(e=navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia))return t;console.log("loading camera!");var n=null;return g(void 0,void 0,void 0,(function(){var e,t;return m(this,(function(r){switch(r.label){case 0:e=0,r.label=1;case 1:if(e===bp.length)return[3,6];t={audio:a,video:{deviceId:{exact:l.deviceId},width:{exact:bp[e].width},height:{exact:bp[e].height}}},r.label=2;case 2:return r.trys.push([2,4,,5]),null==n||n.getVideoTracks().forEach((function(e){e.stop()})),[4,navigator.mediaDevices.getUserMedia(t)];case 3:return n=r.sent(),console.log("it can do",bp[e].label),[3,6];case 4:return"NotAllowedError"===r.sent().name?(S?(x(!1),A(!0)):I(!0),[2]):(console.log("well, it cant do",bp[e].label),[3,5]);case 5:return++e,[3,1];case 6:if(n)return[3,12];e=0,r.label=7;case 7:if(e===bp.length)return[3,12];t={audio:!1,video:{deviceId:{exact:l.deviceId},width:{ideal:bp[e].width},height:{ideal:bp[e].height}}},r.label=8;case 8:return r.trys.push([8,10,,11]),null==n||n.getVideoTracks().forEach((function(e){e.stop()})),[4,navigator.mediaDevices.getUserMedia(t)];case 9:return n=r.sent(),console.log("it can do",bp[e].label),[3,12];case 10:return r.sent(),console.log("well, it cant do",bp[e].label),[3,11];case 11:return++e,[3,7];case 12:if(n)return[3,16];r.label=13;case 13:return r.trys.push([13,15,,16]),[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 14:return n=r.sent(),console.log("opened stream with no width and height constraints"),[3,16];case 15:return r.sent(),console.log("cannot open stream at all"),[3,16];case 16:if(!n)throw new Error("failed to open camera");return n.getVideoTracks()[0].onended=function(){var e;w&&S?(console.log("someone unplugged the continuity camera"),x(!1),A(!0)):(console.log("someone unplugged the webcam"),null===(e=c.current)||void 0===e||e.release(),c.current=null,f(!1),I(!0),y(null))},c.current=function(e,t){var n=e.getVideoTracks()[0].getSettings(),r=n.width,i=n.height,a=t.toLocaleLowerCase().split(" ").join("");console.log("CAMERA LABEL",a);var o=a.includes("back")||a.includes("iphonecamera");return r||(r=0),i||(i=0),{stream:e,width:r,height:i,isRearFacing:o,release:function(){e.getTracks().forEach((function(e){e.stop()}))}}}(n,l.label),o.current&&(o.current.srcObject=n),[2]}}))})),t}}),[S,w,a,l,!!o.current]),n.useEffect((function(){y(null),h&&g(void 0,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(i){return(e=(null!==(r=null===(n=null===(t=c.current)||void 0===t?void 0:t.stream)||void 0===n?void 0:n.getVideoTracks())&&void 0!==r?r:[])[0])?(y(new ImageCapture(e)),[2]):[2]}))}))}),[h]);var F=n.useCallback((function(){return g(void 0,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return v?[4,v.grabFrame()]:[2,null];case 1:return[2,e.sent()]}}))}))}),[v]),L=n.useCallback((function(){return g(void 0,void 0,void 0,(function(){var e,t,n,r,i;return m(this,(function(a){switch(a.label){case 0:return e=document.createElement("canvas"),(t=e.getContext("2d"))&&c.current&&o.current?(e.width=null===(r=o.current)||void 0===r?void 0:r.videoWidth,e.height=null===(i=o.current)||void 0===i?void 0:i.videoHeight,t.drawImage(o.current,0,0,e.width,e.height),n=e.toDataURL("image/jpeg",.98),[4,fetch(n)]):[2,null];case 1:return[4,a.sent().blob()];case 2:return[2,a.sent()]}}))}))}),[]),M=n.useCallback((function(){var e,t;c.current&&(console.log("releasing camera access!"),null===(t=null===(e=c.current)||void 0===e?void 0:e.release)||void 0===t||t.call(e),c.current=null)}),[]);return{videoRef:o,videoDevice:l,videoLoaded:h,setVideoLoaded:f,cameraRef:c,cameraAccessDenied:_,retryCameraAccess:D,releaseCameraAccess:M,iphoneContinuityCameraAvailable:w,iphoneContinuityCameraAllowed:S,setIphoneContinuityCameraAllowed:T,captureDevice:v,grabFrame:F,takePhoto:L}},Ep=function(e){var t=e.children,r=e.preferFrontFacingCamera,i=e.preferContinuityCamera,a=e.requestMicrophoneAccess,o=xp({preferFrontFacingCamera:void 0!==r&&r,preferContinuityCamera:void 0===i||i,requestMicrophoneAccess:void 0!==a&&a}),s=o.videoRef,l=o.videoLoaded,c=o.setVideoLoaded,d=o.cameraRef,h=o.cameraAccessDenied,f=o.retryCameraAccess,p=o.releaseCameraAccess,g=o.iphoneContinuityCameraAvailable,m=o.iphoneContinuityCameraAllowed,v=o.setIphoneContinuityCameraAllowed,y=o.grabFrame,b=o.takePhoto,w=o.captureDevice,x=n.useState(!1),E=x[0],S=x[1];return n.useEffect((function(){S(!1),w&&(S(!0),b().then((function(){S(!0)})))}),[w,b]),n.useEffect((function(){return function(){p()}}),[p]),u.default.createElement(Ft.Provider,{value:{videoRef:s,videoLoaded:l,setVideoLoaded:c,cameraRef:d,cameraReady:E,cameraAccessDenied:h,releaseCameraAccess:p,retryCameraAccess:f,iphoneContinuityCameraAvailable:g,iphoneContinuityCameraAllowed:m,setIphoneContinuityCameraAllowed:v,grabFrame:y,takePhoto:b}},t)},Sp=function(e){var t=e.children,r=n.useState({width:1,height:1}),i=r[1],a=n.useState(1),o=a[0],s=a[1],l=Et(),c=l.ref,d=l.width,h=void 0===d?1:d,f=l.height,p=void 0===f?1:f,g=h/p,m=n.useCallback((function(e){var t=e.target;s(t.naturalWidth/t.naturalHeight)}),[]);return u.default.createElement(St.Provider,{value:{orientation:"landscape",wrapperWidth:h,wrapperHeight:p,wrapperAspectRatio:g,imageAspectRatio:o,setDimensions:i,wrapperRef:c,onImageLoaded:m}},t)},Tp=function(){var e=n.useContext(qe),t=e.submissionRequest,r=e.submissionResponse,i=n.useState(!1),a=i[0],o=i[1],s=n.useState(!0),l=s[0],c=s[1],d=n.useMemo((function(){var e,n,r,i,a,o,s=JSON.parse(JSON.stringify(t));return l&&((null===(n=null===(e=null==s?void 0:s.customerData)||void 0===e?void 0:e.idData)||void 0===n?void 0:n.idImageFront)&&(s.customerData.idData.idImageFront=kp(s.customerData.idData.idImageFront,200)),(null===(i=null===(r=null==s?void 0:s.customerData)||void 0===r?void 0:r.idData)||void 0===i?void 0:i.idImageBack)&&(s.customerData.idData.idImageBack=kp(s.customerData.idData.idImageBack,200)),(null===(o=null===(a=null==s?void 0:s.customerData)||void 0===a?void 0:a.biometricData)||void 0===o?void 0:o.selfie)&&(s.customerData.biometricData.selfie=kp(s.customerData.biometricData.selfie,200))),JSON.stringify(s,null,2)}),[t,l]);return u.default.createElement(u.default.Fragment,null,u.default.createElement("h3",null,"Submission completed!"),u.default.createElement("button",{onClick:function(){o(!a)}},a?"Hide":"Show"," request body"),a&&u.default.createElement(u.default.Fragment,null,u.default.createElement("button",{style:{marginLeft:8},onClick:function(){c(!l)}},l?"Display full images":"Truncate images"),u.default.createElement("h5",null,"Request Body"),u.default.createElement("pre",null,d)),u.default.createElement("h5",null,"Response Body"),u.default.createElement("pre",null,JSON.stringify(r,null,2)))};function kp(e,t){var n=e.split("").splice(0,t).join("");return n.length<e.length&&(n+="..."),n}var Cp,Ap=h.default.div(Cp||(Cp=y(["\n display: inline-block;\n width: 80px;\n height: 80px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #888;\n border-color: #888 transparent #888 transparent;\n animation: lds-dual-ring 1.2s linear infinite;\n }\n\n @keyframes lds-dual-ring {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n"],["\n display: inline-block;\n width: 80px;\n height: 80px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #888;\n border-color: #888 transparent #888 transparent;\n animation: lds-dual-ring 1.2s linear infinite;\n }\n\n @keyframes lds-dual-ring {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n"]))),Rp=function(e){var t=e.document,r=e.onComplete,i=e.headingText,a=e.nextBtnText,o=ye().t,s=n.useState(null),l=s[0],c=s[1];return i=i||o("Additional document capture"),a=a||o("Next"),u.default.createElement(rt,null,u.default.createElement(it,{style:{textAlign:"left"}},u.default.createElement("h3",{style:{margin:"0 0 8px"}},i,": ",t.name),t.description&&u.default.createElement("p",{style:{margin:"8px 0"}},t.description),u.default.createElement("p",{style:{margin:"8px 0"}},u.default.createElement("input",{type:"file",accept:"image/*,.pdf",onChange:function(e){var t,n=null===(t=e.target.files)||void 0===t?void 0:t[0];n&&c(n)}})),u.default.createElement("p",{style:{margin:"8px 0"}},u.default.createElement("button",{disabled:!l,onClick:function(e){if(e.preventDefault(),l){var n=new FileReader;n.onloadend=function(){if(n.result){var e=n.result.toString();null==r||r({documentName:t.name,additionalDocument:{name:l.name,fileContent:Ke(e),type:Ye(e),fileUploadType:"Y",isImageControlData:"N",fieldId:""}})}},n.readAsDataURL(l)}}},a))))},_p=function(e){var t=e.documents,r=e.onComplete,i=e.verbiage,a=void 0===i?{}:i,o=n.useState([]),s=o[0],l=o[1],c=s.length,d=t[c],h=c>=t.length;return n.useEffect((function(){(null==d?void 0:d.skip)&&g(void 0,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return[4,null===(e=d.skip)||void 0===e?void 0:e.call(d)];case 1:return t.sent()&&l((function(e){return v(v([],e,!0),[null],!1)})),[2]}}))}))}),[d]),n.useEffect((function(){h&&(null==r||r(s.filter((function(e){return!!e}))))}),[h,r,s]),h?u.default.createElement(u.default.Fragment,null,"Thanks, your documents have been received."):u.default.createElement(Rp,{key:c,headingText:a.headingText,nextBtnText:a.nextBtnText,document:d,onComplete:function(e){l((function(t){return v(v([],t,!0),[e],!1)}))}})},Ip="function"==typeof Symbol&&Symbol.for,Dp=Ip?Symbol.for("react.element"):60103,Fp=Ip?Symbol.for("react.portal"):60106,Lp=Ip?Symbol.for("react.fragment"):60107,Mp=Ip?Symbol.for("react.strict_mode"):60108,Np=Ip?Symbol.for("react.profiler"):60114,Op=Ip?Symbol.for("react.provider"):60109,Pp=Ip?Symbol.for("react.context"):60110,Bp=Ip?Symbol.for("react.async_mode"):60111,Up=Ip?Symbol.for("react.concurrent_mode"):60111,$p=Ip?Symbol.for("react.forward_ref"):60112,jp=Ip?Symbol.for("react.suspense"):60113,Gp=Ip?Symbol.for("react.suspense_list"):60120,zp=Ip?Symbol.for("react.memo"):60115,qp=Ip?Symbol.for("react.lazy"):60116,Hp=Ip?Symbol.for("react.block"):60121,Vp=Ip?Symbol.for("react.fundamental"):60117,Wp=Ip?Symbol.for("react.responder"):60118,Kp=Ip?Symbol.for("react.scope"):60119;function Yp(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case Dp:switch(e=e.type){case Bp:case Up:case Lp:case Np:case Mp:case jp:return e;default:switch(e=e&&e.$$typeof){case Pp:case $p:case qp:case zp:case Op:return e;default:return t}}case Fp:return t}}}function Xp(e){return Yp(e)===Up}var Jp={AsyncMode:Bp,ConcurrentMode:Up,ContextConsumer:Pp,ContextProvider:Op,Element:Dp,ForwardRef:$p,Fragment:Lp,Lazy:qp,Memo:zp,Portal:Fp,Profiler:Np,StrictMode:Mp,Suspense:jp,isAsyncMode:function(e){return Xp(e)||Yp(e)===Bp},isConcurrentMode:Xp,isContextConsumer:function(e){return Yp(e)===Pp},isContextProvider:function(e){return Yp(e)===Op},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===Dp},isForwardRef:function(e){return Yp(e)===$p},isFragment:function(e){return Yp(e)===Lp},isLazy:function(e){return Yp(e)===qp},isMemo:function(e){return Yp(e)===zp},isPortal:function(e){return Yp(e)===Fp},isProfiler:function(e){return Yp(e)===Np},isStrictMode:function(e){return Yp(e)===Mp},isSuspense:function(e){return Yp(e)===jp},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===Lp||e===Up||e===Np||e===Mp||e===jp||e===Gp||"object"==typeof e&&null!==e&&(e.$$typeof===qp||e.$$typeof===zp||e.$$typeof===Op||e.$$typeof===Pp||e.$$typeof===$p||e.$$typeof===Vp||e.$$typeof===Wp||e.$$typeof===Kp||e.$$typeof===Hp)},typeOf:Yp};ie((function(e,t){}));ie((function(e){e.exports=Jp}));function Zp(){}function Qp(){}Qp.resetWarningCache=Zp;var eg=ie((function(e){e.exports=function(){function e(e,t,n,r,i,a){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==a){var o=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw o.name="Invariant Violation",o}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:Qp,resetWarningCache:Zp};return n.PropTypes=n,n}()}));function tg(e,t,n){this.x=e,this.y=t,this.time=n||(new Date).getTime()}function ng(e,t,n,r){this.startPoint=e,this.control1=t,this.control2=n,this.endPoint=r}function rg(e,t){var n=this,r=t||{};this.velocityFilterWeight=r.velocityFilterWeight||.7,this.minWidth=r.minWidth||.5,this.maxWidth=r.maxWidth||2.5,this.throttle="throttle"in r?r.throttle:16,this.minDistance="minDistance"in r?r.minDistance:5,this._strokeMoveUpdate=this.throttle?function(e,t,n){var r,i,a,o=null,s=0;n||(n={});var l=function(){s=!1===n.leading?0:Date.now(),o=null,a=e.apply(r,i),o||(r=i=null)};return function(){var u=Date.now();s||!1!==n.leading||(s=u);var c=t-(u-s);return r=this,i=arguments,c<=0||c>t?(o&&(clearTimeout(o),o=null),s=u,a=e.apply(r,i),o||(r=i=null)):o||!1===n.trailing||(o=setTimeout(l,c)),a}}(rg.prototype._strokeUpdate,this.throttle):rg.prototype._strokeUpdate,this.dotSize=r.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=r.penColor||"black",this.backgroundColor=r.backgroundColor||"rgba(0,0,0,0)",this.onBegin=r.onBegin,this.onEnd=r.onEnd,this._canvas=e,this._ctx=e.getContext("2d"),this.clear(),this._handleMouseDown=function(e){1===e.which&&(n._mouseButtonDown=!0,n._strokeBegin(e))},this._handleMouseMove=function(e){n._mouseButtonDown&&n._strokeMoveUpdate(e)},this._handleMouseUp=function(e){1===e.which&&n._mouseButtonDown&&(n._mouseButtonDown=!1,n._strokeEnd(e))},this._handleTouchStart=function(e){1===e.targetTouches.length&&n._strokeBegin(e.changedTouches[0])},this._handleTouchMove=function(e){e.preventDefault(),n._strokeMoveUpdate(e.targetTouches[0])},this._handleTouchEnd=function(e){e.target===n._canvas&&(e.preventDefault(),n._strokeEnd(e))},this.on()}tg.prototype.velocityFrom=function(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):1},tg.prototype.distanceTo=function(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))},tg.prototype.equals=function(e){return this.x===e.x&&this.y===e.y&&this.time===e.time},ng.prototype.length=function(){for(var e=0,t=void 0,n=void 0,r=0;r<=10;r+=1){var i=r/10,a=this._point(i,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),o=this._point(i,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){var s=a-t,l=o-n;e+=Math.sqrt(s*s+l*l)}t=a,n=o}return e},ng.prototype._point=function(e,t,n,r,i){return t*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*r*(1-e)*e*e+i*e*e*e},rg.prototype.clear=function(){var e=this._ctx,t=this._canvas;e.fillStyle=this.backgroundColor,e.clearRect(0,0,t.width,t.height),e.fillRect(0,0,t.width,t.height),this._data=[],this._reset(),this._isEmpty=!0},rg.prototype.fromDataURL=function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new Image,i=n.ratio||window.devicePixelRatio||1,a=n.width||this._canvas.width/i,o=n.height||this._canvas.height/i;this._reset(),r.src=e,r.onload=function(){t._ctx.drawImage(r,0,0,a,o)},this._isEmpty=!1},rg.prototype.toDataURL=function(e){var t;if("image/svg+xml"===e)return this._toSVG();for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return(t=this._canvas).toDataURL.apply(t,[e].concat(r))},rg.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},rg.prototype.off=function(){this._canvas.removeEventListener("mousedown",this._handleMouseDown),this._canvas.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._canvas.removeEventListener("touchstart",this._handleTouchStart),this._canvas.removeEventListener("touchmove",this._handleTouchMove),this._canvas.removeEventListener("touchend",this._handleTouchEnd)},rg.prototype.isEmpty=function(){return this._isEmpty},rg.prototype._strokeBegin=function(e){this._data.push([]),this._reset(),this._strokeUpdate(e),"function"==typeof this.onBegin&&this.onBegin(e)},rg.prototype._strokeUpdate=function(e){var t=this._createPoint(e.clientX,e.clientY),n=this._data[this._data.length-1],r=n&&n[n.length-1],i=r&&t.distanceTo(r)<this.minDistance;if(!r||!i){var a=this._addPoint(t),o=a.curve,s=a.widths;o&&s&&this._drawCurve(o,s.start,s.end),this._data[this._data.length-1].push({x:t.x,y:t.y,time:t.time,color:this.penColor})}},rg.prototype._strokeEnd=function(e){var t=this.points[0];if(!(this.points.length>2)&&t&&this._drawDot(t),t){var n=this._data[this._data.length-1];t.equals(n[n.length-1])||n.push({x:t.x,y:t.y,time:t.time,color:this.penColor})}"function"==typeof this.onEnd&&this.onEnd(e)},rg.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)},rg.prototype._handleTouchEvents=function(){this._canvas.style.msTouchAction="none",this._canvas.style.touchAction="none",this._canvas.addEventListener("touchstart",this._handleTouchStart),this._canvas.addEventListener("touchmove",this._handleTouchMove),this._canvas.addEventListener("touchend",this._handleTouchEnd)},rg.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._ctx.fillStyle=this.penColor},rg.prototype._createPoint=function(e,t,n){var r=this._canvas.getBoundingClientRect();return new tg(e-r.left,t-r.top,n||(new Date).getTime())},rg.prototype._addPoint=function(e){var t=this.points,n=void 0;if(t.push(e),t.length>2){3===t.length&&t.unshift(t[0]);var r=(n=this._calculateCurveControlPoints(t[0],t[1],t[2])).c2;n=this._calculateCurveControlPoints(t[1],t[2],t[3]);var i=new ng(t[1],r,n.c1,t[2]),a=this._calculateCurveWidths(i);return t.shift(),{curve:i,widths:a}}return{}},rg.prototype._calculateCurveControlPoints=function(e,t,n){var r=e.x-t.x,i=e.y-t.y,a=t.x-n.x,o=t.y-n.y,s=(e.x+t.x)/2,l=(e.y+t.y)/2,u=(t.x+n.x)/2,c=(t.y+n.y)/2,d=Math.sqrt(r*r+i*i),h=Math.sqrt(a*a+o*o),f=h/(d+h),p=t.x-(u+(s-u)*f),g=t.y-(c+(l-c)*f);return{c1:new tg(s+p,l+g),c2:new tg(u+p,c+g)}},rg.prototype._calculateCurveWidths=function(e){var t={start:null,end:null},n=this.velocityFilterWeight*e.endPoint.velocityFrom(e.startPoint)+(1-this.velocityFilterWeight)*this._lastVelocity,r=this._strokeWidth(n);return t.start=this._lastWidth,t.end=r,this._lastVelocity=n,this._lastWidth=r,t},rg.prototype._strokeWidth=function(e){return Math.max(this.maxWidth/(e+1),this.minWidth)},rg.prototype._drawPoint=function(e,t,n){var r=this._ctx;r.moveTo(e,t),r.arc(e,t,n,0,2*Math.PI,!1),this._isEmpty=!1},rg.prototype._drawCurve=function(e,t,n){var r=this._ctx,i=n-t,a=Math.floor(e.length());r.beginPath();for(var o=0;o<a;o+=1){var s=o/a,l=s*s,u=l*s,c=1-s,d=c*c,h=d*c,f=h*e.startPoint.x;f+=3*d*s*e.control1.x,f+=3*c*l*e.control2.x;var p=h*e.startPoint.y;p+=3*d*s*e.control1.y,p+=3*c*l*e.control2.y,this._drawPoint(f+=u*e.endPoint.x,p+=u*e.endPoint.y,t+u*i)}r.closePath(),r.fill()},rg.prototype._drawDot=function(e){var t=this._ctx,n="function"==typeof this.dotSize?this.dotSize():this.dotSize;t.beginPath(),this._drawPoint(e.x,e.y,n),t.closePath(),t.fill()},rg.prototype._fromData=function(e,t,n){for(var r=0;r<e.length;r+=1){var i=e[r];if(i.length>1)for(var a=0;a<i.length;a+=1){var o=i[a],s=new tg(o.x,o.y,o.time),l=o.color;if(0===a)this.penColor=l,this._reset(),this._addPoint(s);else if(a!==i.length-1){var u=this._addPoint(s),c=u.curve,d=u.widths;c&&d&&t(c,d,l)}}else this._reset(),n(i[0])}},rg.prototype._toSVG=function(){var e=this,t=this._data,n=this._canvas,r=Math.max(window.devicePixelRatio||1,1),i=n.width/r,a=n.height/r,o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttributeNS(null,"width",n.width),o.setAttributeNS(null,"height",n.height),this._fromData(t,(function(e,t,n){var r=document.createElement("path");if(!(isNaN(e.control1.x)||isNaN(e.control1.y)||isNaN(e.control2.x)||isNaN(e.control2.y))){var i="M "+e.startPoint.x.toFixed(3)+","+e.startPoint.y.toFixed(3)+" C "+e.control1.x.toFixed(3)+","+e.control1.y.toFixed(3)+" "+e.control2.x.toFixed(3)+","+e.control2.y.toFixed(3)+" "+e.endPoint.x.toFixed(3)+","+e.endPoint.y.toFixed(3);r.setAttribute("d",i),r.setAttribute("stroke-width",(2.25*t.end).toFixed(3)),r.setAttribute("stroke",n),r.setAttribute("fill","none"),r.setAttribute("stroke-linecap","round"),o.appendChild(r)}}),(function(t){var n=document.createElement("circle"),r="function"==typeof e.dotSize?e.dotSize():e.dotSize;n.setAttribute("r",r),n.setAttribute("cx",t.x),n.setAttribute("cy",t.y),n.setAttribute("fill",t.color),o.appendChild(n)}));var s='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 '+i+" "+a+'" width="'+i+'" height="'+a+'">',l=o.innerHTML;if(void 0===l){var u=document.createElement("dummy"),c=o.childNodes;u.innerHTML="";for(var d=0;d<c.length;d+=1)u.appendChild(c[d].cloneNode(!0));l=u.innerHTML}return"data:image/svg+xml;base64,"+btoa(s+l+"</svg>")},rg.prototype.fromData=function(e){var t=this;this.clear(),this._fromData(e,(function(e,n){return t._drawCurve(e,n.start,n.end)}),(function(e){return t._drawDot(e)})),this._data=e},rg.prototype.toData=function(){return this._data};var ig=Object.freeze({__proto__:null,default:rg}),ag=ie((function(e,t){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){function n(e){var t=e.getContext("2d"),n=e.width,r=e.height,i=t.getImageData(0,0,n,r).data,s=a(!0,n,r,i),l=a(!1,n,r,i),u=o(!0,n,r,i),c=o(!1,n,r,i)-u+1,d=l-s+1,h=t.getImageData(u,s,c,d);return e.width=c,e.height=d,t.clearRect(0,0,c,d),t.putImageData(h,0,0),e}function r(e,t,n,r){return{red:r[4*(n*t+e)],green:r[4*(n*t+e)+1],blue:r[4*(n*t+e)+2],alpha:r[4*(n*t+e)+3]}}function i(e,t,n,i){return r(e,t,n,i).alpha}function a(e,t,n,r){for(var a=e?1:-1,o=e?0:n-1;e?o<n:o>-1;o+=a)for(var s=0;s<t;s++)if(i(s,o,t,r))return o;return null}function o(e,t,n,r){for(var a=e?1:-1,o=e?0:t-1;e?o<t:o>-1;o+=a)for(var s=0;s<n;s++)if(i(o,s,t,r))return o;return null}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n}])}));re(ag);var og=function(e){return e&&e.default||e}(ig),sg=ie((function(e,t){e.exports=function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=r(n(1)),d=n(2),h=r(d),f=r(n(3)),p=r(n(4)),g=function(e){function t(){var e,n,r;a(this,t);for(var s=arguments.length,l=Array(s),u=0;u<s;u++)l[u]=arguments[u];return n=r=o(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(l))),r._sigPad=null,r._excludeOurProps=function(){var e=r.props;return i(e,["canvasProps","clearOnResize"])},r.getCanvas=function(){return r._canvas},r.getTrimmedCanvas=function(){var e=document.createElement("canvas");return e.width=r._canvas.width,e.height=r._canvas.height,e.getContext("2d").drawImage(r._canvas,0,0),(0,p.default)(e)},r.getSignaturePad=function(){return r._sigPad},r._checkClearOnResize=function(){r.props.clearOnResize&&r._resizeCanvas()},r._resizeCanvas=function(){var e=r.props.canvasProps||{},t=e.width,n=e.height;if(!t||!n){var i=r._canvas,a=Math.max(window.devicePixelRatio||1,1);t||(i.width=i.offsetWidth*a),n||(i.height=i.offsetHeight*a),i.getContext("2d").scale(a,a),r.clear()}},r.on=function(){return window.addEventListener("resize",r._checkClearOnResize),r._sigPad.on()},r.off=function(){return window.removeEventListener("resize",r._checkClearOnResize),r._sigPad.off()},r.clear=function(){return r._sigPad.clear()},r.isEmpty=function(){return r._sigPad.isEmpty()},r.fromDataURL=function(e,t){return r._sigPad.fromDataURL(e,t)},r.toDataURL=function(e,t){return r._sigPad.toDataURL(e,t)},r.fromData=function(e){return r._sigPad.fromData(e)},r.toData=function(){return r._sigPad.toData()},o(r,n)}return s(t,e),u(t,[{key:"componentDidMount",value:function(){this._sigPad=new f.default(this._canvas,this._excludeOurProps()),this._resizeCanvas(),this.on()}},{key:"componentWillUnmount",value:function(){this.off()}},{key:"componentDidUpdate",value:function(){Object.assign(this._sigPad,this._excludeOurProps())}},{key:"render",value:function(){var e=this;return h.default.createElement("canvas",l({ref:function(t){e._canvas=t}},this.props.canvasProps))}}]),t}(d.Component);g.propTypes={velocityFilterWeight:c.default.number,minWidth:c.default.number,maxWidth:c.default.number,minDistance:c.default.number,dotSize:c.default.oneOfType([c.default.number,c.default.func]),penColor:c.default.string,throttle:c.default.number,onEnd:c.default.func,onBegin:c.default.func,canvasProps:c.default.object,clearOnResize:c.default.bool},g.defaultProps={clearOnResize:!0},t.default=g},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t){e.exports=r}])}(eg,u.default,og,ag)})),lg=re(sg);function ug(e){var t,n=null!==(t=e.toDataURL())&&void 0!==t?t:null,r={clickX_simple:[],clickY_simple:[],time_simple:[],pressure:"",fileContent:n?Ke(n):""};return e.toData().forEach((function(e){var t=[],n=[],i=[];e.forEach((function(e){t.push(e.x),n.push(e.y),i.push(new Date(e.time).toString())})),r.clickX_simple.push(t),r.clickY_simple.push(n),r.time_simple.push(i)})),r}var cg,dg,hg,fg,pg,gg,mg=h.default.div(cg||(cg=y(["\n position: absolute;\n top: 25%;\n left: 15%;\n width: 70%;\n height: 50%;\n\n @media (max-width: 800px) {\n top: 15%;\n left: 2%;\n width: 96%;\n height: 70%;\n }\n"],["\n position: absolute;\n top: 25%;\n left: 15%;\n width: 70%;\n height: 50%;\n\n @media (max-width: 800px) {\n top: 15%;\n left: 2%;\n width: 96%;\n height: 70%;\n }\n"]))),vg=h.default.div(dg||(dg=y(["\n position: relative;\n background: rgba(255, 255, 255, 0.5);\n border-radius: 16px;\n flex-grow: 1;\n z-index: 100;\n height: 100%;\n"],["\n position: relative;\n background: rgba(255, 255, 255, 0.5);\n border-radius: 16px;\n flex-grow: 1;\n z-index: 100;\n height: 100%;\n"]))),yg=h.default.div(hg||(hg=y(["\n flex-grow: 0;\n padding-top: 12px;\n display: flex;\n z-index: 1000;\n position: relative;\n"],["\n flex-grow: 0;\n padding-top: 12px;\n display: flex;\n z-index: 1000;\n position: relative;\n"]))),bg=h.default.div(fg||(fg=y(["\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background-color: #e5e5f7;\n opacity: 0.8;\n background-image: radial-gradient(#444cf7 0.5px, transparent 0.5px),\n radial-gradient(#444cf7 0.5px, #e5e5f7 0.5px);\n background-size: 20px 20px;\n background-position: 0 0, 10px 10px;\n"],["\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background-color: #e5e5f7;\n opacity: 0.8;\n background-image: radial-gradient(#444cf7 0.5px, transparent 0.5px),\n radial-gradient(#444cf7 0.5px, #e5e5f7 0.5px);\n background-size: 20px 20px;\n background-position: 0 0, 10px 10px;\n"]))),wg=h.default.div(pg||(pg=y(["\n position: absolute;\n top: calc(",");\n font-weight: bold;\n width: 100%;\n display: flex;\n"],["\n position: absolute;\n top: calc(",");\n font-weight: bold;\n width: 100%;\n display: flex;\n"])),(function(e){var t=e.$top;return null!=t?t:"10vh"})),xg=h.default.div(gg||(gg=y(["\n margin-left: auto;\n margin-right: auto;\n background: #ccc;\n padding: 10px 12px 8px;\n border-radius: 8px;\n"],["\n margin-left: auto;\n margin-right: auto;\n background: #ccc;\n padding: 10px 12px 8px;\n border-radius: 8px;\n"]))),Eg=function(e){var t=e.onAccept,r=e.verbiage,i=void 0===r?{}:r,a=ye().t,o=Et(),s=o.ref,l=o.width,c=o.height,d=n.useRef(null);return i.headingText=i.headingText||a("Please sign the box below"),i.acceptBtnText=i.acceptBtnText||a("Accept"),i.clearBtnText=i.clearBtnText||a("Clear"),u.default.createElement(Ze,null,u.default.createElement(bg,null,u.default.createElement(wg,{$top:"5vh"},u.default.createElement(xg,null,i.headingText)),u.default.createElement(mg,null,u.default.createElement(vg,{ref:s},u.default.createElement(lg,{ref:d,canvasProps:{width:l,height:c}})),u.default.createElement(yg,null,u.default.createElement("button",{onClick:function(e){var t;e.preventDefault(),null===(t=d.current)||void 0===t||t.clear()}},i.clearBtnText),u.default.createElement("button",{style:{marginLeft:"auto"},onClick:function(e){if(e.preventDefault(),d.current){var n=ug(d.current);null==t||t(n,d.current.toDataURL())}}},i.acceptBtnText)))))},Sg=function(e){var t,r,i=e.onComplete,a=e.onFaceNotDetected,o=e.verbiage,s=void 0===o?{}:o,l=ye().t,c=n.useContext(Ft),d=c.cameraRef,h=c.videoRef,f=Et(),p=f.ref,y=f.width,b=f.height,w=n.useRef(null),x=n.useRef(null),E=n.useRef([]),S=n.useState(null),T=S[0],k=S[1],C=n.useContext(op),A=C.start,R=C.stop,_=C.onPredictionMade,I=function(e){var t=n.useRef(null),r=n.useRef([]),i=n.useState(null),a=i[0],o=i[1],s=n.useState(!1),l=s[0],u=s[1],c=null==e?void 0:e.stream,d=n.useCallback((function(){c&&(r.current=[],u(!0),t.current=new MediaRecorder(c),t.current.ondataavailable=function(e){r.current.push(e.data)},t.current.onstop=function(){var t=new Blob(r.current,{type:"video/mp4"});r.current=[],o(URL.createObjectURL(t)),u(!1),null==e||e.release()},t.current.start())}),[e,c]),h=n.useCallback((function(){var e;null===(e=t.current)||void 0===e||e.stop()}),[]);return{isRecording:l,startRecording:d,stopRecording:h,videoUrl:a}}(d.current),D=I.isRecording,F=I.startRecording,L=I.stopRecording,M=I.videoUrl,N=n.useState(null),O=N[0],P=N[1],B=n.useState(null),U=B[0],$=B[1];s.acceptBtnText=s.acceptBtnText||l("Accept"),s.clearBtnText=s.clearBtnText||l("Clear");var j=n.useRef(null);n.useEffect((function(){return D&&a&&A(),function(){R()}}),[D,a,A,R]),n.useEffect((function(){if(!D&&!M&&j.current){F();var e=j.current.captureStream(25);x.current=new MediaRecorder(e,{}),x.current.start(),x.current.ondataavailable=function(e){var t;E.current.push(e.data),"recording"===(null===(t=x.current)||void 0===t?void 0:t.state)&&x.current.stop()},x.current.onstop=function(){var e=new Blob(E.current,{type:"video/mp4"}),t=URL.createObjectURL(e);k(t)}}}),[D,F,M]),n.useEffect((function(){T&&O&&U&&(null==i||i(O,U))}),[i,O,U,T]);var G=n.useRef(0);n.useEffect((function(){if(w.current&&h.current&&j.current&&d.current&&D){j.current.width=d.current.width,j.current.height=d.current.height;var e=j.current.getContext("2d");if(e)return G.current=requestAnimationFrame((function t(){return g(this,void 0,void 0,(function(){var n,r,i,a;return m(this,(function(o){return w.current&&h.current&&j.current?(n=window.innerWidth<=800,a=[(r=j.current.width)*(n?.02:.15),(i=j.current.height)*(n?.15:.25),r*(n?.96:.7),i*(n?.7:.5)],e.drawImage(h.current,0,0,r,i),e.beginPath(),e.fillStyle="rgba(255,255,255,0.5)",e.roundRect.apply(e,v(v([],a,!1),[16],!1)),e.fill(),e.drawImage.apply(e,v([w.current.getCanvas()],a,!1)),G.current=requestAnimationFrame(t),[2]):(cancelAnimationFrame(G.current),[2])}))}))})),function(){cancelAnimationFrame(G.current)}}}),[d,D,a,h]);var z=n.useState(0),q=z[0],H=z[1];if(n.useEffect((function(){_((function(e){H((function(t){return 0===e.length?t+1:0}))}))}),[_]),n.useEffect((function(){q>=2&&(null==a||a())}),[q,a]),!D&&M)return u.default.createElement(u.default.Fragment,null,T&&u.default.createElement("video",{src:T,controls:!0,width:"100%"}),U&&u.default.createElement("img",{src:U,alt:"signature"}),O&&u.default.createElement("textarea",{readOnly:!0,style:{width:"100%",height:500},value:JSON.stringify(O,null,2)}));var V=l("Please sign the box below");return u.default.createElement(Ze,{className:"flex"},u.default.createElement(Hi,null),""!==V&&u.default.createElement(wg,{$top:"5vh"},u.default.createElement(xg,null,V)),u.default.createElement(mg,null,u.default.createElement(vg,{ref:p},u.default.createElement(lg,{ref:w,canvasProps:{width:y,height:b}})),u.default.createElement(yg,null,u.default.createElement("button",{onClick:function(e){var t;e.preventDefault(),null===(t=w.current)||void 0===t||t.clear()}},s.clearBtnText),u.default.createElement("button",{style:{marginLeft:"auto"},onClick:function(e){var t;if(e.preventDefault(),w.current){var n=ug(w.current);P(n),$(w.current.toDataURL()),L(),null===(t=x.current)||void 0===t||t.stop()}}},s.acceptBtnText))),u.default.createElement("div",{style:{display:"none"}},u.default.createElement("canvas",{ref:j,style:{width:null===(t=h.current)||void 0===t?void 0:t.videoWidth,height:null===(r=h.current)||void 0===r?void 0:r.videoHeight}})))},Tg=function(e){return u.default.createElement(pp,{headingText:e.headingText,removeEyeCoveringsText:e.removeEyeCoveringsText,avoidExcessiveBacklightingText:e.avoidExcessiveBacklightingText,continueText:e.continueText,cameraInitializingText:e.cameraInitializingText,modelsWarmingUpText:e.modelsWarmingUpText,instructionImageUrl:e.instructionImageUrl,onDismissed:e.onDismissed})},kg=function(e){var t=e.onComplete,r=n.useContext(qe),i=r.selfieImage,a=r.setSelfieImage,o=r.setSignatureData,s=r.logSelfieCaptureAttempt,l=n.useContext(Ft).releaseCameraAccess,c=n.useState("LOADING"),d=c[0],h=c[1],f=n.useRef(),p=n.useRef(),v=n.useRef();n.useEffect((function(){return f.current=new Date,function(){l()}}),[l]),n.useEffect((function(){"CHECKING_LIVENESS"===d&&(p.current=new Date)}),[d]);var y=n.useCallback((function(){var e,t,n;s({autoCapture:"Y",captureTime:(null!==(e=v.current)&&void 0!==e?e:new Date).getTime()-(null!==(t=p.current)&&void 0!==t?t:new Date).getTime(),operationTime:(new Date).getTime()-(null!==(n=f.current)&&void 0!==n?n:new Date).getTime()}),f.current=new Date}),[s]),b=n.useCallback((function(){h("CHECKING_LIVENESS")}),[]),w=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return h("CAPTURING_SIGNATURE"),y(),i?[3,2]:(t=a,[4,We(e)]);case 1:t.apply(void 0,[n.sent()]),n.label=2;case 2:return[2]}}))}))}),[y,i,a]),x=n.useCallback((function(e){o(e),null==t||t()}),[t,o]),E=n.useCallback((function(){h("CHECKING_LIVENESS")}),[]);return u.default.createElement(sp,{throttleMs:"CAPTURING_SIGNATURE"===d?250:0},"LOADING"!==d&&function(){switch(d){case"CHECKING_LIVENESS":return u.default.createElement(fp,{onSuccess:w});case"CAPTURING_SIGNATURE":return u.default.createElement(Sg,{onComplete:x,onFaceNotDetected:E});default:return null}}(),u.default.createElement(Tg,{onDismissed:b}))},Cg=function(e){var t,r,i,a,o,s=e.checks,l=e.idCaptureProps,c=void 0===l?{}:l,d=e.faceLivenessProps,h=void 0===d?{}:d,f=e.signatureCaptureProps,g=void 0===f?{}:f,m=e.signatureKYCProps,y=void 0===m?{}:m,b=e.additionalDocumentCaptureProps,w=e.captureSignature,x=void 0!==w&&w,E=e.captureSignatureVideo,S=void 0!==E&&E,T=n.useContext(qe),k=T.submit,C=T.submissionStatus,A=T.setSignatureData,R=T.setAdditionalDocuments,_=n.useState(0),I=_[0],D=_[1],F=n.useMemo((function(){var e,t,n=v([],s,!0);if(x&&S)throw new Error("captureSignature and captureSignatureVideo cannot be used together");return x&&n.push("SignatureCapture"),S&&n.push("SignatureKYC"),null!==(t=null===(e=null==b?void 0:b.documents)||void 0===e?void 0:e.length)&&void 0!==t&&t&&n.push("AdditionalDocumentCapture"),n}),[null===(t=null==b?void 0:b.documents)||void 0===t?void 0:t.length,x,S,s]),L=F[I],M=I>=F.length;n.useEffect((function(){"SignatureCapture"===L&&"function"==typeof x?x().then((function(e){e||D((function(e){return e+1}))})):"SignatureKYC"===L&&"function"==typeof S&&S().then((function(e){e||D((function(e){return e+1}))}))}),[x,S,L]),n.useEffect((function(){M&&k()}),[M,k]);var N=c.onSuccess,O=n.useCallback((function(e){null==N||N(e),D((function(e){return e+1}))}),[N]),P=h.onComplete,B=n.useCallback((function(e){null==P||P(e),D((function(e){return e+1}))}),[P]),U=n.useCallback((function(e){A(e),D((function(e){return e+1}))}),[A]),$=y.onComplete,j=n.useCallback((function(){null==$||$(),D((function(e){return e+1}))}),[$]),G=null==b?void 0:b.onComplete,z=n.useCallback((function(e){R(e),null==G||G(e),D((function(e){return e+1}))}),[G,R]),q=n.useMemo((function(){var e;return null!==(e=null==b?void 0:b.documents)&&void 0!==e?e:[]}),[null==b?void 0:b.documents]);if(M)switch(C){case je.SUBMITTING:return u.default.createElement(Ze,{className:"flex"},u.default.createElement(Ap,null));case je.SUBMITTED:return u.default.createElement(Tp,null);case je.FAILED:return u.default.createElement(u.default.Fragment,null,"Submission failed!");default:return u.default.createElement(u.default.Fragment,null,"Complete!!")}return u.default.createElement(gi,{documentDetectionModelUrl:null!==(i=null===(r=c.assets)||void 0===r?void 0:r.documentDetectionModelUrl)&&void 0!==i?i:"",focusModelUrl:null!==(o=null===(a=c.assets)||void 0===a?void 0:a.focusModelUrl)&&void 0!==o?o:""},function(){switch(F[I]){case"IdCapture":return u.default.createElement(Ep,null,u.default.createElement(Sp,null,u.default.createElement(Yi,p({},c,{onSuccess:O}))));case"FaceLiveness":return u.default.createElement(Ep,{preferFrontFacingCamera:!0,preferContinuityCamera:!1},u.default.createElement(sp,null,u.default.createElement(vp,p({},h,{onComplete:B}))));case"SignatureCapture":return u.default.createElement(Eg,p({},g,{onAccept:U}));case"SignatureKYC":return u.default.createElement(Ep,{preferContinuityCamera:!1,preferFrontFacingCamera:!0,requestMicrophoneAccess:!0},u.default.createElement(kg,p({},y,{onComplete:j})));case"AdditionalDocumentCapture":return u.default.createElement(_p,p({},b,{documents:q,onComplete:z}));default:return u.default.createElement(u.default.Fragment,null)}}())},Ag={en:{translation:{}},es:{translation:{"Use your device camera to capture your ID":"Para capturar la identificación hay que utilizar la cámara del dispositivo.","Use your iPhone as a webcam":"Usar el iPhone como cámara web","Models warming up...":"Cargando modelos...","Camera initializing...":"Inicializando la cámara...","Camera access blocked":"Acceso bloqueado a la cámara","Location access blocked":"Acceso bloqueado a la localización",Continue:"Continuar","Your camera permission is disabled":"El permiso de la cámara está desactivado","This application requires access to your camera to continue. Please accept the permission once prompted by the browser. If the browser does not prompt for camera permissions, you must go to settings and provide camera access to the current browser.":"Esta aplicación requiere el acceso a la cámara para continuar. Hay que aceptar el permiso una vez que se muestre la ventana en el explorador. Si no aparece la ventana para otorgar permisos, entonces hay que dirigirse a Configuración y otorgar el permiso a la cámara en el explorador actual.","Your location permission is disabled":"El permiso de la localización está desactivado","This application requires access to your location to continue. Please accept the permission once prompted by the browser. If the browser does not prompt for location permissions, you must go to settings and provide location access to the current browser.":"Esta aplicación requiere el acceso a la localización para continuar. Hay que aceptar el permiso una vez que se muestre la ventana en el explorador. Si no aparece la ventana para otorgar permisos, entonces hay que dirigirse a Configuración y otorgar el permiso a la localización en el explorador actual.",Retry:"Reintentar","Scan the front of ID":"Escanear el frente de la ID","Scan the back of ID":"Escanear el reverso de la ID","Scan the ID page of passport":"Escanear la página de datos del pasaporte","ID Card Front":"Frente de la ID","ID Card Back":"Reverso de la ID",Passport:"Pasaporte","Capturing...":"Capturando...","Capture failed!":"Falló la captura","Please flip your ID card...":"Por favor voltea la identificación...","ID Capture Successful":"Captura Exitosa de ID","Verify the entire ID was captured clearly with no glare.":"Hay que verificar que toda la ID se vea completa y sin reflejos.",Submit:"Enviar","Submitting...":"Enviando...","Use your device camera to capture your face":"Hay que utilizar la cámara del dispositivo para capturar el rostro","Remove Sunglasses & Hat":"Hay que quitarse lentes y/o la gorra","Avoid Excessive Backlighting":"Hay que evitar demasiada luz en el fondo","Hold still for a few seconds...":"Hay que permanecer quieto por unos segundos...","Look straight into the camera...":"Hay que mirar directamente a la cámara...","Move back...":"Hay que hacerse hacia atrás..","Move forward...":"Hay que hacerse hacia adelante...","Move to the center...":"Hay que moverse hacia el centro...","Please remove your eye coverings (sunglasses, eye patch, etc.)...":"Hay que quitarse lo que cubre los ojos (lentes, parche, etc.)...","Please remove your head coverings (hat, scarf, etc.)...":"Hay que quitarse lo que cubre la cabeza (gorra, mascada, etc.)...","Please remove your mask...":"Hay que quitarse el cubrebocas...","Live face not detected, please try again":"Rostro vivo no detectado. Por favor hay que intentar de nuevo.",Exit:"Salir","Face liveness has been verified!":"Se ha verificado la Prueba de Vida en rostro!",Done:"Terminar","Customer has been identified!":"¡Se ha identificado al cliente!","Customer not found":"Cliente no encontrado","Additional document capture":"Captura de otro documento",Next:"Siguiente","Please sign the box below":"Por favor, hay que firmar en el recuadro de abajo",Accept:"Aceptar",Clear:"Borrar"}}},Rg=function(e){var t=ye().i18n;n.useEffect((function(){"auto"!==e?t.changeLanguage(e):t.changeLanguage()}),[t,e])},_g=function(e){var t=e.lang,r=e.submissionToken,i=e.submissionEnvironment,a=void 0===i?"prod":i,o=e.submissionUrl,s=e.idAutoCaptureEnabled,l=void 0===s||s,c=e.idCardAutoCaptureScoreThreshold,d=void 0===c?.8:c,h=e.passportAutoCaptureScoreThreshold,f=void 0===h?.8:h,p=e.idCardFocusScoreThreshold,g=void 0===p?.3:p,m=e.passportFocusScoreThreshold,v=void 0===m?.3:m,y=e.onBeforeSubmit,b=e.onComplete,w=e.onApproved,x=e.onDenied,E=e.assets,S=void 0===E?{}:E,T=e.verbiage,k=void 0===T?{}:T,C=e.captureSignature,A=void 0!==C&&C,R=e.captureSignatureVideo,_=void 0!==R&&R,I=e.captureAdditionalDocuments,D=void 0===I?[]:I,F=e.geolocationEnabled,L=void 0===F||F,M=e.geolocationRequired,N=void 0!==M&&M,O=e.debugMode,P=void 0!==O&&O;Rg(void 0===t?"auto":t);var B=n.useMemo((function(){return{autoCaptureEnabled:l,idCardAutoCaptureScoreThreshold:d,passportAutoCaptureScoreThreshold:f,mrzDetectionScoreThreshold:.5,idCardFocusScoreThreshold:g,passportFocusScoreThreshold:v,barcodeScanningEnabled:!1,assets:S,verbiage:k,debugMode:P}}),[S,P,l,d,g,f,v,k]),U=n.useMemo((function(){return{verbiage:{headingText:k.signatureCaptureHeadingText,acceptBtnText:k.signatureCaptureAcceptBtnText,clearBtnText:k.signatureCaptureClearBtnText}}}),[k.signatureCaptureAcceptBtnText,k.signatureCaptureClearBtnText,k.signatureCaptureHeadingText]),$=n.useMemo((function(){return{documents:D,verbiage:{headingText:k.additionalDocumentsHeadingText,nextBtnText:k.additionalDocumentsNextBtnText}}}),[D,k.additionalDocumentsHeadingText,k.additionalDocumentsNextBtnText]),j=n.useCallback((function(e){null==b||b(e),"Approved"===e.resultData.verificationResult?null==w||w(e):null==x||x(e)}),[w,b,x]);return u.default.createElement(yt,{action:$e.VALIDATE,environment:a,url:o,token:r,onBeforeSubmit:y,onResponseReceived:j,geolocationEnabled:L,geolocationRequired:N},u.default.createElement(Cg,{checks:n.useMemo((function(){return["IdCapture"]}),[]),idCaptureProps:B,signatureCaptureProps:U,additionalDocumentCaptureProps:$,captureSignature:A,captureSignatureVideo:_}))},Ig=function(e){var t=e.lang,r=e.submissionToken,i=e.submissionEnvironment,a=void 0===i?"prod":i,o=e.submissionUrl,s=e.timeoutDurationMs,l=void 0===s?15e3:s,c=e.onBeforeSubmit,d=e.onComplete,h=e.onApproved,f=e.onDenied,p=e.onExitAfterFailure,g=e.assets,m=e.verbiage,v=e.geolocationEnabled,y=void 0===v||v,b=e.geolocationRequired,w=void 0!==b&&b,x=e.debugMode,E=void 0!==x&&x;Rg(void 0===t?"auto":t);var S=n.useMemo((function(){return{timeoutDurationMs:l,onComplete:d,onSuccess:h,onTimeout:f,onExitAfterFailure:p,assets:g,verbiage:m,debugMode:E}}),[g,E,h,d,f,p,l,m]);return u.default.createElement(yt,{action:$e.NONE,environment:a,url:o,token:r,onBeforeSubmit:c,geolocationEnabled:y,geolocationRequired:w},u.default.createElement(Cg,{checks:n.useMemo((function(){return["FaceLiveness"]}),[]),idCaptureProps:{},faceLivenessProps:S}))},Dg=function(e){var t=e.lang,r=e.submissionToken,i=e.submissionEnvironment,a=void 0===i?"prod":i,o=e.submissionUrl,s=e.idAutoCaptureEnabled,l=void 0===s||s,c=e.idCardAutoCaptureScoreThreshold,d=void 0===c?.8:c,h=e.mrzDetectionScoreThreshold,f=void 0===h?.5:h,p=e.passportAutoCaptureScoreThreshold,g=void 0===p?.8:p,m=e.idCardFocusScoreThreshold,v=void 0===m?.3:m,y=e.passportFocusScoreThreshold,b=void 0===y?.3:y,w=e.idCaptureAssets,x=e.idCaptureVerbiage,E=e.faceLivenessTimeoutDurationMs,S=void 0===E?15e3:E,T=e.faceLivenessAssets,k=e.faceLivenessVerbiage,C=e.onBeforeSubmit,A=e.onComplete,R=e.onApproved,_=e.onDenied,I=e.onExitAfterFailure,D=e.captureSignature,F=void 0!==D&&D,L=e.captureSignatureVideo,M=void 0!==L&&L,N=e.captureAdditionalDocuments,O=void 0===N?[]:N,P=e.geolocationEnabled,B=void 0===P||P,U=e.geolocationRequired,$=void 0!==U&&U,j=e.debugMode,G=void 0!==j&&j;Rg(void 0===t?"auto":t);var z=n.useMemo((function(){return{assets:w,verbiage:x,autoCaptureEnabled:l,idCardAutoCaptureScoreThreshold:d,passportAutoCaptureScoreThreshold:g,mrzDetectionScoreThreshold:f,idCardFocusScoreThreshold:v,passportFocusScoreThreshold:b,debugMode:G}}),[G,l,w,x,d,v,f,g,b]),q=n.useMemo((function(){return{timeoutDurationMs:S,onTimeout:_,onExitAfterFailure:I,assets:T,verbiage:k,debugMode:G}}),[G,T,S,k,_,I]),H=n.useMemo((function(){return{verbiage:{headingText:null==x?void 0:x.signatureCaptureHeadingText,acceptBtnText:null==x?void 0:x.signatureCaptureAcceptBtnText,clearBtnText:null==x?void 0:x.signatureCaptureClearBtnText}}}),[null==x?void 0:x.signatureCaptureAcceptBtnText,null==x?void 0:x.signatureCaptureClearBtnText,null==x?void 0:x.signatureCaptureHeadingText]),V=n.useMemo((function(){return{documents:O,verbiage:{headingText:null==x?void 0:x.additionalDocumentsHeadingText,nextBtnText:null==x?void 0:x.additionalDocumentsNextBtnText}}}),[O,null==x?void 0:x.additionalDocumentsHeadingText,null==x?void 0:x.additionalDocumentsNextBtnText]),W=n.useCallback((function(e){null==A||A(e),"Approved"===e.resultData.verificationResult?null==R||R(e):null==_||_(e)}),[R,A,_]);return u.default.createElement(yt,{action:$e.VALIDATE,environment:a,url:o,token:r,onBeforeSubmit:C,onResponseReceived:W,geolocationEnabled:B,geolocationRequired:$},u.default.createElement(Cg,{checks:n.useMemo((function(){return["IdCapture","FaceLiveness"]}),[]),idCaptureProps:z,faceLivenessProps:q,signatureCaptureProps:H,additionalDocumentCaptureProps:V,captureSignature:F,captureSignatureVideo:M}))},Fg=function(e){var t=e.enrollmentId,r=e.lang,i=e.submissionToken,a=e.submissionEnvironment,o=void 0===a?"prod":a,s=e.submissionUrl,l=e.idAutoCaptureEnabled,c=void 0===l||l,d=e.idCardAutoCaptureScoreThreshold,h=void 0===d?.8:d,f=e.mrzDetectionScoreThreshold,p=void 0===f?.5:f,g=e.passportAutoCaptureScoreThreshold,m=void 0===g?.8:g,v=e.idCardFocusScoreThreshold,y=void 0===v?.3:v,b=e.passportFocusScoreThreshold,w=void 0===b?.3:b,x=e.idCaptureAssets,E=e.idCaptureVerbiage,S=e.faceLivenessTimeoutDurationMs,T=void 0===S?15e3:S,k=e.faceLivenessAssets,C=e.faceLivenessVerbiage,A=e.onBeforeSubmit,R=e.onComplete,_=e.onEnrolled,I=e.onDenied,D=e.onExitAfterFailure,F=e.captureSignature,L=void 0!==F&&F,M=e.captureSignatureVideo,N=void 0!==M&&M,O=e.captureAdditionalDocuments,P=void 0===O?[]:O,B=e.geolocationEnabled,U=void 0===B||B,$=e.geolocationRequired,j=void 0!==$&&$,G=e.debugMode,z=void 0!==G&&G;Rg(void 0===r?"auto":r);var q=n.useMemo((function(){return{assets:x,verbiage:E,autoCaptureEnabled:c,idCardAutoCaptureScoreThreshold:h,passportAutoCaptureScoreThreshold:m,mrzDetectionScoreThreshold:p,idCardFocusScoreThreshold:y,passportFocusScoreThreshold:w,debugMode:z}}),[z,c,x,E,h,y,p,m,w]),H=n.useMemo((function(){return{onExitAfterFailure:D,timeoutDurationMs:T,assets:k,verbiage:C,debugMode:z}}),[z,k,T,C,D]),V=n.useMemo((function(){return{verbiage:{headingText:null==E?void 0:E.signatureCaptureHeadingText,acceptBtnText:null==E?void 0:E.signatureCaptureAcceptBtnText,clearBtnText:null==E?void 0:E.signatureCaptureClearBtnText}}}),[null==E?void 0:E.signatureCaptureAcceptBtnText,null==E?void 0:E.signatureCaptureClearBtnText,null==E?void 0:E.signatureCaptureHeadingText]),W=n.useMemo((function(){return{documents:P,verbiage:{headingText:null==E?void 0:E.additionalDocumentsHeadingText,nextBtnText:null==E?void 0:E.additionalDocumentsNextBtnText}}}),[P,null==E?void 0:E.additionalDocumentsHeadingText,null==E?void 0:E.additionalDocumentsNextBtnText]),K=n.useCallback((function(e){null==R||R(e),"Customer Onboarded"===e.resultData.verificationResult?null==_||_(e):null==I||I(e)}),[_,R,I]);return u.default.createElement(yt,{action:$e.ENROLL,environment:o,url:s,token:i,enrollmentId:t,onBeforeSubmit:A,onResponseReceived:K,geolocationEnabled:U,geolocationRequired:j},u.default.createElement(Cg,{checks:n.useMemo((function(){return["IdCapture","FaceLiveness"]}),[]),idCaptureProps:q,faceLivenessProps:H,signatureCaptureProps:V,additionalDocumentCaptureProps:W,captureSignature:L,captureSignatureVideo:N}))},Lg={frame:null,face:null,imageUrl:null,requestState:"NOT_READY",requestError:null,unverifiedTimes:0},Mg=function(e,t){switch(t.type){case"verificationReady":return["NOT_READY","ERROR"].includes(e.requestState)?p(p({},e),{requestState:"READY",frame:t.payload.frame,face:t.payload.face}):e;case"verifying":return p(p({},e),{requestState:"IN_PROGRESS",imageUrl:t.payload.imageUrl});case"verificationCompleted":var n=t.payload.response,r=n.status,i=r.statusMessage,a=r.errorData,o=n.resultData;if("000"!==r.statusCode)return p(p({},e),{requestState:"ERROR",requestError:new Error("".concat(i,": ").concat(a))});var s=e.requestState,l=e.unverifiedTimes;return"46"===o.verificationResultCode?s="FOUND":l<2?(s="READY",l+=1):s="NOT_FOUND",p(p({},e),{requestState:s,unverifiedTimes:l});case"verificationFailed":return p(p({},e),{requestState:"ERROR",requestError:t.payload.error});default:return e}},Ng=function(e){var t=e.onCustomerMatched,r=e.onCustomerNotMatched,i=e.onCaptureGuidanceTimeout,a=e.captureGuidanceTimeoutDurationMs,o=e.verbiage,s=void 0===o?{}:o,l=e.debugMode,c=void 0!==l&&l,d=n.useReducer(Mg,Lg),h=d[0],f=d[1],p=h.frame,v=h.face,y=n.useContext(qe),b=y.submit,w=y.submissionResponse,x=y.selfieImage,E=y.setSelfieImage,S=n.useCallback((function(e,t){f({type:"verificationReady",payload:{frame:e,face:t}})}),[]),T="READY"===h.requestState;return n.useEffect((function(){p&&v&&We(ci(p,v)).then((function(e){console.log("setting selfie image",e),E(e)}))}),[v,p,E]),n.useEffect((function(){T&&x&&g(void 0,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),f({type:"verifying",payload:{imageUrl:x}}),[4,b()];case 1:if(!(e=n.sent()))throw new Error("submission failed!");return f({type:"verificationCompleted",payload:{response:e}}),[3,3];case 2:return t=n.sent(),f({type:"verificationFailed",payload:{error:t}}),[3,3];case 3:return[2]}}))}))}),[T,t,r,x,h.requestState,b]),n.useEffect((function(){w&&("FOUND"===h.requestState?null==t||t(w):"NOT_FOUND"===h.requestState&&(null==r||r(w)))}),[t,r,h.requestState,w]),u.default.createElement(cp,{onSelfieCaptured:S,onTimeout:i,timeoutDurationMs:a,verbiage:s,debugMode:c})},Og=function(e){var t=e.headingText,n=e.retryBtnText,r=e.doneBtnText,i=e.imageUrl,a=e.onDoneClick,o=e.onRetryClick,s=ye().t;return i=i||"".concat(li,"/Selfie-Image-1.png"),t=t||s("Customer has been verified!"),n=n||s("Retry"),r=r||s("Done"),u.default.createElement(rt,null,u.default.createElement(it,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(at,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:i})),u.default.createElement("div",{style:{marginTop:24}},u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"red",onClick:o},u.default.createElement("span",{className:"ladda-label"},n)),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"mint",onClick:a,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},r)))))},Pg=function(e){var t=e.headingText,n=e.retryBtnText,r=e.exitBtnText,i=e.imageUrl,a=e.canRetry,o=void 0===a||a,s=e.onRetryClick,l=e.onExitClick,c=ye().t;return i=i||"".concat(li,"/manual_capture.png"),t=t||c("Customer not verified"),n=n||c("Retry"),r=r||c("Exit"),u.default.createElement(rt,null,u.default.createElement(it,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(at,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:i})),u.default.createElement("div",{style:{marginTop:24}},o&&u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"red",onClick:s,style:{marginRight:15}},u.default.createElement("span",{className:"ladda-label"},n)),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"black",onClick:l},u.default.createElement("span",{className:"ladda-label"},r)))))},Bg=function(e){var t=e.onComplete,r=e.onCustomerMatched,i=e.onCustomerNotMatched,a=e.onExitAfterFailure,o=e.onCaptureGuidanceTimeout,s=e.captureGuidanceTimeoutDurationMs,l=e.assets,c=void 0===l?{}:l,d=e.verbiage,h=void 0===d?{}:d,f=e.debugMode,p=void 0!==f&&f,v=n.useContext(qe),y=v.submissionResponse,b=v.selfieImage,w=n.useContext(Ft).releaseCameraAccess,x=n.useState("LOADING"),E=x[0],S=x[1],T=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return S("MATCHED"),w(),setTimeout((function(){null==r||r(e)}),0),[2]}))}))}),[r,w]),k=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return S("NOT_MATCHED"),w(),setTimeout((function(){null==i||i(e)}),0),[2]}))}))}),[i,w]),C=n.useCallback((function(){S("FAILED"),w(),setTimeout((function(){null==o||o()}),0)}),[o,w]);return u.default.createElement(u.default.Fragment,null,"LOADING"!==E&&function(){switch(E){case"CAPTURING":return u.default.createElement(Ng,{onCustomerMatched:T,onCustomerNotMatched:k,onCaptureGuidanceTimeout:C,captureGuidanceTimeoutDurationMs:s,verbiage:h,debugMode:p});case"MATCHED":return u.default.createElement(Og,{headingText:h.successHeadingText,retryBtnText:h.successRetryBtnText,doneBtnText:h.successDoneBtnText,imageUrl:"data:image/png;base64, ".concat(b),onDoneClick:function(){y&&(null==t||t(y))},onRetryClick:function(){S("CAPTURING")}});case"NOT_MATCHED":return u.default.createElement(Pg,{headingText:h.failureHeadingText,retryBtnText:h.failureRetryBtnText,exitBtnText:null==h?void 0:h.failureExitBtnText,imageUrl:c.failureImageUrl,canRetry:!1,onExitClick:a});default:return null}}(),u.default.createElement(pp,{headingText:h.loadingOverlayHeadingText,removeEyeCoveringsText:h.loadingOverlayRemoveEyeCoveringsText,avoidExcessiveBacklightingText:h.loadingOverlayAvoidExcessiveBacklightingText,continueText:h.loadingOverlayContinueText,cameraInitializingText:h.loadingOverlayCameraInitializingText,modelsWarmingUpText:h.loadingOverlayModelsWarmingUpText,instructionImageUrl:c.instructionImageUrl,onDismissed:function(){S("CAPTURING")}}))},Ug=function(e){var t=e.lang,n=e.enrollmentId,r=e.submissionToken,i=e.submissionEnvironment,a=void 0===i?"prod":i,o=e.submissionUrl,s=e.timeoutDurationMs,l=void 0===s?15e3:s,c=e.assets,d=e.verbiage,h=e.onBeforeSubmit,f=e.onComplete,p=e.onCustomerMatched,g=e.onCustomerNotMatched,m=e.onExitAfterFailure,v=e.geolocationEnabled,y=void 0===v||v,b=e.geolocationRequired,w=void 0!==b&&b,x=e.debugMode,E=void 0!==x&&x;return Rg(void 0===t?"auto":t),u.default.createElement(yt,{action:$e.VERIFY,environment:a,url:o,token:r,enrollmentId:n,onBeforeSubmit:h,geolocationEnabled:y,geolocationRequired:w},u.default.createElement(sp,null,u.default.createElement(Ep,{preferFrontFacingCamera:!0},u.default.createElement(Bg,{onComplete:f,onCustomerMatched:p,onCustomerNotMatched:g,onExitAfterFailure:m,captureGuidanceTimeoutDurationMs:l,assets:c,verbiage:d,debugMode:E}))))},$g={frame:null,face:null,imageUrl:null,requestState:"NOT_READY",requestError:null,notFoundTimes:0},jg=function(e,t){switch(t.type){case"identificationReady":return["NOT_READY","ERROR"].includes(e.requestState)?p(p({},e),{requestState:"READY",frame:t.payload.frame,face:t.payload.face}):e;case"identifying":return p(p({},e),{requestState:"IN_PROGRESS",imageUrl:t.payload.imageUrl});case"identificationCompleted":var n=t.payload.response,r=n.status,i=r.statusMessage,a=r.errorData,o=n.resultData;if("000"!==r.statusCode)return p(p({},e),{requestState:"ERROR",requestError:new Error("".concat(i,": ").concat(a))});var s=e.requestState,l=e.notFoundTimes;return"46"===o.verificationResultCode?s="FOUND":l<2?(s="READY",l+=1):s="NOT_FOUND",p(p({},e),{requestState:s,notFoundTimes:l});case"identificationFailed":return p(p({},e),{requestState:"ERROR",requestError:t.payload.error});default:return e}},Gg=function(e){var t=e.onCustomerMatched,r=e.onCustomerNotMatched,i=e.onCaptureGuidanceTimeout,a=e.captureGuidanceTimeoutDurationMs,o=e.verbiage,s=void 0===o?{}:o,l=e.debugMode,c=void 0!==l&&l,d=n.useReducer(jg,$g),h=d[0],f=d[1],p=n.useContext(qe),v=p.submit,y=p.submissionResponse,b=p.selfieImage,w=p.setSelfieImage,x=n.useCallback((function(e,t){f({type:"identificationReady",payload:{frame:e,face:t}})}),[]),E=h.frame,S=h.face,T="READY"===h.requestState;return n.useEffect((function(){E&&S&&We(ci(E,S)).then((function(e){console.log("setting selfie image",e),w(e)}))}),[S,E,w]),n.useEffect((function(){T&&b&&g(void 0,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),f({type:"identifying",payload:{imageUrl:b}}),[4,v()];case 1:if(!(e=n.sent()))throw new Error("submission failed!");return f({type:"identificationCompleted",payload:{response:e}}),[3,3];case 2:return t=n.sent(),f({type:"identificationFailed",payload:{error:t}}),[3,3];case 3:return[2]}}))}))}),[T,t,r,b,h.requestState,v]),n.useEffect((function(){y&&("FOUND"===h.requestState?null==t||t(y):"NOT_FOUND"===h.requestState&&(null==r||r(y)))}),[t,r,h.requestState,y]),u.default.createElement(cp,{onSelfieCaptured:x,onTimeout:i,timeoutDurationMs:a,verbiage:s,debugMode:c})},zg=function(e){var t=e.headingText,n=e.retryBtnText,r=e.doneBtnText,i=e.imageUrl,a=e.onDoneClick,o=e.onRetryClick,s=ye().t;return i=i||"".concat(li,"/Selfie-Image-1.png"),t=t||s("Customer has been identified!"),n=n||s("Retry"),r=r||s("Done"),u.default.createElement(rt,null,u.default.createElement(it,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(at,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:i})),u.default.createElement("div",{style:{marginTop:24}},u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"red",onClick:o},u.default.createElement("span",{className:"ladda-label"},n)),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"mint",onClick:a,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},r)))))},qg=function(e){var t=e.headingText,n=e.retryBtnText,r=e.exitBtnText,i=e.imageUrl,a=e.canRetry,o=void 0===a||a,s=e.onRetryClick,l=e.onExitClick,c=ye().t;return i=i||"".concat(li,"/manual_capture.png"),t=t||c("Customer not found"),n=n||c("Retry"),r=r||c("Exit"),u.default.createElement(rt,null,u.default.createElement(it,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(at,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:i})),u.default.createElement("div",{style:{marginTop:24}},o&&u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"red",onClick:s,style:{marginRight:15}},u.default.createElement("span",{className:"ladda-label"},n)),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"black",onClick:l},u.default.createElement("span",{className:"ladda-label"},r)))))},Hg=function(e){var t=e.onComplete,r=e.onCustomerMatched,i=e.onCustomerNotMatched,a=e.onExitAfterFailure,o=e.onCaptureGuidanceTimeout,s=e.captureGuidanceTimeoutDurationMs,l=e.assets,c=void 0===l?{}:l,d=e.verbiage,h=void 0===d?{}:d,f=e.debugMode,p=void 0!==f&&f,v=n.useContext(qe),y=v.submissionResponse,b=v.selfieImage,w=n.useContext(Ft).releaseCameraAccess,x=n.useState("LOADING"),E=x[0],S=x[1],T=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return S("FOUND"),w(),setTimeout((function(){null==r||r(e)}),0),[2]}))}))}),[r,w]),k=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return S("NOT_FOUND"),w(),setTimeout((function(){null==i||i(e)}),0),[2]}))}))}),[i,w]),C=n.useCallback((function(){S("FAILED"),w(),setTimeout((function(){null==o||o()}),0)}),[o,w]);return u.default.createElement(u.default.Fragment,null,"LOADING"!==E&&function(){switch(E){case"CAPTURING":return u.default.createElement(Gg,{onCustomerMatched:T,onCustomerNotMatched:k,onCaptureGuidanceTimeout:C,captureGuidanceTimeoutDurationMs:s,verbiage:h,debugMode:p});case"FOUND":return u.default.createElement(zg,{headingText:h.successHeadingText,retryBtnText:h.successRetryBtnText,doneBtnText:h.successDoneBtnText,imageUrl:"data:image/png;base64, ".concat(b),onDoneClick:function(){y&&(null==t||t(y))},onRetryClick:function(){S("CAPTURING")}});case"NOT_FOUND":case"FAILED":return u.default.createElement(qg,{headingText:h.failureHeadingText,retryBtnText:h.failureRetryBtnText,exitBtnText:null==h?void 0:h.failureExitBtnText,imageUrl:c.failureImageUrl,canRetry:!1,onExitClick:a});default:return null}}(),u.default.createElement(pp,{headingText:h.loadingOverlayHeadingText,removeEyeCoveringsText:h.loadingOverlayRemoveEyeCoveringsText,avoidExcessiveBacklightingText:h.loadingOverlayAvoidExcessiveBacklightingText,continueText:h.loadingOverlayContinueText,cameraInitializingText:h.loadingOverlayCameraInitializingText,modelsWarmingUpText:h.loadingOverlayModelsWarmingUpText,instructionImageUrl:c.instructionImageUrl,onDismissed:function(){S("CAPTURING")}}))},Vg=function(e){var t=e.lang,n=e.submissionToken,r=e.submissionEnvironment,i=void 0===r?"prod":r,a=e.submissionUrl,o=e.timeoutDurationMs,s=void 0===o?15e3:o,l=e.onBeforeSubmit,c=e.onComplete,d=e.onCustomerMatched,h=e.onCustomerNotMatched,f=e.onCaptureGuidanceTimeout,p=e.onExitAfterFailure,g=e.assets,m=e.verbiage,v=e.geolocationEnabled,y=e.geolocationRequired,b=void 0!==y&&y,w=e.debugMode,x=void 0!==w&&w;return Rg(void 0===t?"auto":t),u.default.createElement(yt,{action:$e.IDENTIFY,environment:i,url:a,token:n,onBeforeSubmit:l,geolocationEnabled:v,geolocationRequired:b},u.default.createElement(Ep,{preferFrontFacingCamera:!0},u.default.createElement(sp,null,u.default.createElement(Hg,{onComplete:c,onCustomerMatched:d,onCustomerNotMatched:h,onExitAfterFailure:p,onCaptureGuidanceTimeout:f,captureGuidanceTimeoutDurationMs:s,assets:g,verbiage:m,debugMode:x}))))},Wg=function(e){var t=e.documentDetectionModel,n=void 0===t?"".concat(li,"/models/documentdetection448/model.json"):t,r=e.focusModel,i=void 0===r?"".concat(li,"/models/focus/model.json"):r,a=e.skipFaceDetectionModel,o=void 0!==a&&a;return g(void 0,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return n?[4,bt(n)]:[3,2];case 1:e.sent(),e.label=2;case 2:return i?[4,Lt(i)]:[3,4];case 3:e.sent(),e.label=4;case 4:return o?[3,6]:[4,ap()];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},Kg=function(e){var t=e.enrollmentId,r=e.lang,i=e.submissionToken,a=e.submissionEnvironment,o=void 0===a?"prod":a,s=e.submissionUrl,l=e.timeoutDurationMs,c=void 0===l?15e3:l,d=e.assets,h=e.verbiage,f=e.onBeforeSubmit,p=e.onComplete,g=e.onEnrolled,m=e.onDenied,v=e.onExitAfterFailure,y=e.captureSignature,b=void 0!==y&&y,w=e.captureSignatureVideo,x=void 0!==w&&w,E=e.captureAdditionalDocuments,S=void 0===E?[]:E,T=e.geolocationEnabled,k=void 0===T||T,C=e.geolocationRequired,A=void 0!==C&&C,R=e.debugMode,_=void 0!==R&&R;Rg(void 0===r?"auto":r);var I=n.useMemo((function(){return{onExitAfterFailure:v,timeoutDurationMs:c,assets:d,verbiage:h,debugMode:_}}),[d,_,v,c,h]),D=n.useMemo((function(){return{verbiage:{headingText:null==h?void 0:h.signatureCaptureHeadingText,acceptBtnText:null==h?void 0:h.signatureCaptureAcceptBtnText,clearBtnText:null==h?void 0:h.signatureCaptureClearBtnText}}}),[null==h?void 0:h.signatureCaptureAcceptBtnText,null==h?void 0:h.signatureCaptureClearBtnText,null==h?void 0:h.signatureCaptureHeadingText]),F=n.useMemo((function(){return{documents:S,verbiage:{headingText:null==h?void 0:h.additionalDocumentsHeadingText,nextBtnText:null==h?void 0:h.additionalDocumentsNextBtnText}}}),[S,null==h?void 0:h.additionalDocumentsHeadingText,null==h?void 0:h.additionalDocumentsNextBtnText]),L=n.useCallback((function(e){null==p||p(e),"Customer Onboarded"===e.resultData.verificationResult?null==g||g(e):null==m||m(e)}),[g,p,m]);return u.default.createElement(yt,{action:$e.ENROLL,environment:o,url:s,token:i,enrollmentId:t,onBeforeSubmit:f,onResponseReceived:L,geolocationEnabled:k,geolocationRequired:A},u.default.createElement(Cg,{checks:n.useMemo((function(){return["FaceLiveness"]}),[]),faceLivenessProps:I,signatureCaptureProps:D,additionalDocumentCaptureProps:F,captureSignature:b,captureSignatureVideo:x}))},Yg=function(e){return u.default.createElement(yt,{action:$e.NONE,environment:e.submissionEnvironment,url:e.submissionUrl,token:e.submissionToken,onBeforeSubmit:e.onBeforeSubmit,onResponseReceived:e.onComplete,geolocationEnabled:e.geolocationEnabled,geolocationRequired:e.geolocationRequired},u.default.createElement(Ep,{preferContinuityCamera:!1,preferFrontFacingCamera:!0,requestMicrophoneAccess:!0},u.default.createElement(kg,null)))};function Xg(e){return u.default.createElement(rt,null,e.children)}ne.use(Ge).use(ge).init({resources:Ag,detection:{caches:[]},fallbackLng:"en",debug:!1,interpolation:{escapeValue:!1}}),void 0!==d&&d.init&&d.init({dsn:"https://0a8e0e8df645473abe217b60b50fbcb1@o4505120557367296.ingest.sentry.io/4505120582008832",tracesSampleRate:1,debug:!0});var Jg=function(e,t,n){if(void 0===n&&(n=!0),"string"==typeof t){var r=document.querySelector(t);if(!r)throw new Error("targetElement ".concat(t," not found"));t=r}n&&(e=u.default.createElement(Xg,null,e)),l.default.render(e,t)},Zg=function(e,t,n){void 0===n&&(n=!0),Jg(u.default.createElement(_g,p({},t)),e,n)},Qg=function(e,t,n){void 0===n&&(n=!0),Jg(u.default.createElement(Ig,p({},t)),e,n)},em=function(e,t,n){void 0===n&&(n=!0),Jg(u.default.createElement(Dg,p({},t)),e,n)},tm=function(e,t,n){void 0===n&&(n=!0),Jg(u.default.createElement(Fg,p({},t)),e,n)},nm=function(e,t,n){void 0===n&&(n=!0),Jg(u.default.createElement(Kg,p({},t)),e,n)},rm=function(e,t,n){void 0===n&&(n=!0),Jg(u.default.createElement(Ug,p({},t)),e,n)},im=function(e,t,n){void 0===n&&(n=!0),Jg(u.default.createElement(Vg,p({},t)),e,n)},am=function(e,t,n){void 0===n&&(n=!0),Jg(u.default.createElement(Yg,p({},t)),e,n)};globalThis.IDmissionSDK={renderIdValidation:Zg,renderFaceValidation:Qg,renderIdAndFaceValidation:em,renderCustomerIdAndBiometricsEnrollment:tm,renderCustomerBiometricsEnrollment:nm,renderCustomerVerification:rm,renderCustomerIdentification:im,renderSignatureKYC:am,preloadModels:Wg,ready:!0},e.CustomerBiometricsEnrollment=Kg,e.CustomerIdAndBiometricsEnrollment=Fg,e.CustomerIdentification=Vg,e.CustomerVerification=Ug,e.FaceValidation=Ig,e.IdAndFaceValidation=Dg,e.IdValidation=_g,e.SignatureKYC=Yg,e.preloadModels=Wg,e.renderCustomerBiometricsEnrollment=nm,e.renderCustomerIdAndBiometricsEnrollment=tm,e.renderCustomerIdentification=im,e.renderCustomerVerification=rm,e.renderFaceValidation=Qg,e.renderIdAndFaceValidation=em,e.renderIdValidation=Zg,e.renderSignatureKYC=am,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
|
-
//# sourceMappingURL=sdk2.umd.production.js.map
|