idmission-web-sdk 0.0.48 → 0.0.49
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 +26 -0
- package/dist/components/id_capture/IdCaptureLoadingOverlay.d.ts +4 -1
- package/dist/components/id_capture/IdCaptureWizard.d.ts +10 -1
- package/dist/sdk2.cjs.development.js +25 -14
- package/dist/sdk2.cjs.development.js.map +1 -1
- package/dist/sdk2.cjs.production.js +1 -1
- package/dist/sdk2.cjs.production.js.map +1 -1
- package/dist/sdk2.esm.js +25 -14
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +25 -14
- package/dist/sdk2.umd.development.js.map +1 -1
- package/dist/sdk2.umd.production.js +1 -1
- package/dist/sdk2.umd.production.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
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,a,i){"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(a),f=s(i),p=function(){return p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},p.apply(this,arguments)};function g(e,t,n,r){return new(n||(n=Promise))((function(a,i){function o(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(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,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=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(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=a=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,a=0,i=t.length;a<i;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);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 k(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));return n.resolve=e,n.reject=t,n}function S(e){return null==e?"":""+e}function C(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function a(){return!e||"string"==typeof e}const i="string"!=typeof t?[].concat(t):t.split(".");for(;i.length>1;){if(a())return{};const t=r(i.shift());!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}return a()?{}:{obj:e,k:r(i.shift())}}function T(e,t,n){const{obj:r,k:a}=C(e,t,Object);r[a]=n}function A(e,t){const{obj:n,k:r}=C(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 I(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var _={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function D(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(e=>_[e])):e}const F=[" ",",","?","!",";"];function M(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 a=e;for(let e=0;e<r.length;++e){if(!a)return;if("string"==typeof a[r[e]]&&e+1<r.length)return;if(void 0===a[r[e]]){let i=2,o=r.slice(e,e+i).join(n),s=a[o];for(;void 0===s&&r.length>e+i;)i++,o=r.slice(e,e+i).join(n),s=a[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+i).join(n);return l?M(s,l,n):void 0}a=a[r[e]]}return a}function L(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 a=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,i=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(a?n.split(a):n)),e.indexOf(".")>-1&&(o=e.split("."));const s=A(this.data,o);return s||!i||"string"!=typeof n?s:M(this.data&&this.data[e]&&this.data[e][t],n,a)}addResource(e,t,n,r){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const i=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator;let o=[e,t];n&&(o=o.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(o=e.split("."),r=t,t=o[1]),this.addNamespaces(t),T(this.data,o,r),a.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,a){let i=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,a):s={...s,...n},T(this.data,o,s),i.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,a){return e.forEach((e=>{this.processors[e]&&(t=this.processors[e].process(t,n,r,a))})),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 a=t.ns||this.options.defaultNS||[];const i=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 a=new RegExp(`(${r.map((e=>"?"===e?"\\?":e)).join("|")})`);let i=!a.test(e);if(!i){const t=e.indexOf(n);t>0&&!a.test(e.substring(0,t))&&(i=!0)}return i}(e,n,r));if(i&&!o){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:a};const i=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(i[0])>-1)&&(a=i.shift()),e=i.join(r)}return"string"==typeof a&&(a=[a]),{key:e,namespaces:a}}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,a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,{key:i,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}${i}`,usedKey:i,exactUsedKey:i,usedLng:l,usedNS:s}:`${s}${e}${i}`}return r?{res:i,usedKey:i,exactUsedKey:i,usedLng:l,usedNS:s}:i}const c=this.resolve(e,t);let d=c&&c.res;const h=c&&c.usedKey||i,f=c&&c.exactUsedKey||i,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 '${i} (${this.language})' returned an object instead of string.`;return r?(c.res=e,c):e}if(a){const e="[object Array]"===p,n=e?[]:{},r=e?f:h;for(const e in d)if(Object.prototype.hasOwnProperty.call(d,e)){const i=`${r}${a}${e}`;n[e]=this.translate(i,{...t,joinArrays:!1,ns:o}),n[e]===i&&(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=i);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,i,v?g:d),a){const e=this.resolve(i,{...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 a=h&&r!==d?r:m;this.options.missingKeyHandler?this.options.missingKeyHandler(e,s,n,a,v,t):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(e,s,n,a,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],i+n,t[`defaultValue${n}`]||g)}))})):r(e,i,g))}d=this.extendTranslation(d,e,t,c,n),o&&d===i&&this.options.appendNamespaceToMissingKey&&(d=`${s}:${i}`),(o||r)&&this.options.parseMissingKeyHandler&&(d="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${s}:${i}`:i,r?d:void 0):this.options.parseMissingKeyHandler(d))}return r?(c.res=d,c):d}extendTranslation(e,t,n,r,a){var i=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 a&&a[0]===r[0]&&!n.context?(i.logger.warn(`It seems you are nesting recursively key: ${r[0]} in key: ${t[0]}`),null):i.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,a,i,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)||(i=e,!P[`${f[0]}-${e}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(i)&&(P[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${n}" for languages "${f.join(", ")}" won't get resolved as namespace "${i}" 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;a=n;const i=[l];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(i,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&&(i.push(l+e),o.ordinal&&0===e.indexOf(r)&&i.push(l+e.replace(r,this.options.pluralSeparator)),d&&i.push(l+t)),h){const n=`${l}${this.options.contextSeparator}${o.context}`;i.push(n),c&&(i.push(n+e),o.ordinal&&0===e.indexOf(r)&&i.push(n+e.replace(r,this.options.pluralSeparator)),d&&i.push(n+t))}}let s;for(;s=i.pop();)this.isValidLookup(t)||(r=s,t=this.getResource(n,e,s,o))})))}))})),{res:t,usedKey:n,exactUsedKey:r,usedLng:a,usedNS:i}}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=L(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=L(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=[],a=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&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):"string"==typeof e&&a(this.formatLanguageCode(e)),n.forEach((e=>{r.indexOf(e)<0&&a(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(L(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 a=()=>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()}`:a():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?a():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]:".",a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=function(e,t,n){const r=A(e,n);return void 0!==r?r:A(t,n)}(e,t,n);return!i&&a&&"string"==typeof n&&(i=M(e,n,r),void 0===i&&(i=M(t,n,r))),i}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?I(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?I(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?I(t.nestingPrefix):t.nestingPrefixEscaped||I("$t("),this.nestingSuffix=t.nestingSuffix?I(t.nestingSuffix):t.nestingSuffixEscaped||I(")"),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 a,i,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 a=W(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(a,void 0,n,{...r,...t,interpolationkey:e}):a}const a=e.split(this.formatSeparator),i=a.shift().trim(),o=a.join(this.formatSeparator).trim();return this.format(W(t,s,i,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:i})};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;a=t.regex.exec(e);){const n=a[1].trim();if(i=u(n),void 0===i)if("function"==typeof c){const t=c(e,a,r);i="string"==typeof t?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,n))i="";else{if(d){i=a[0];continue}this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),i=""}else"string"==typeof i||this.useRawValueToEscape||(i=S(i));const s=t.safeValue(i);if(e=e.replace(a[0],s),d?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=a[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}})),e}nest(e,t){let n,r,a,i=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 i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);const o=i.match(/'/g),s=i.match(/"/g);(o&&o.length%2==0&&!s||s.length%2!=0)&&(i=i.replace(/'/g,'"'));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return delete a.defaultValue,e}for(;n=this.nestingRegexp.exec(e);){let s=[];a={...i},a=a.replace&&"string"!=typeof a.replace?a.replace:a,a.applyPostProcessor=!1,delete a.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(),a),a),r&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=S(r)),r||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),r=""),l&&(r=s.reduce(((e,t)=>this.format(e,t,i.lng,{...i,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,a){const i=r+JSON.stringify(a);let o=t[i];return o||(o=e(L(r),a),t[i]=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 a=t.split(this.formatSeparator).reduce(((e,t)=>{const{formatName:a,formatOptions:i}=function(e){let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const a=r[1].substring(0,r[1].length-1);"currency"===t&&a.indexOf(":")<0?n.currency||(n.currency=a.trim()):"relativetime"===t&&a.indexOf(":")<0?n.range||(n.range=a.trim()):a.split(";").forEach((e=>{if(!e)return;const[t,...r]=e.split(":"),a=r.join(":").trim().replace(/^'+|'+$/g,"");n[t.trim()]||(n[t.trim()]=a),"false"===a&&(n[t.trim()]=!1),"true"===a&&(n[t.trim()]=!0),isNaN(a)||(n[t.trim()]=parseInt(a,10))}))}return{formatName:t,formatOptions:n}}(t);if(this.formats[a]){let t=e;try{const o=r&&r.formatParams&&r.formatParams[r.interpolationkey]||{};t=this.formats[a](e,o.locale||o.lng||r.locale||r.lng||n,{...i,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${a}`),e}),e);return a}}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 a={},i={},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===i[o]&&(i[o]=!0):(this.state[o]=1,r=!1,void 0===i[o]&&(i[o]=!0),void 0===a[o]&&(a[o]=!0),void 0===s[t]&&(s[t]=!0)))})),r||(o[e]=!0)})),(Object.keys(a).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(a),pending:Object.keys(i),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){const r=e.split("|"),a=r[0],i=r[1];t&&this.emit("failedLoading",a,i,t),n&&this.store.addResourceBundle(a,i,n),this.state[e]=t?-1:2;const o={};this.queue.forEach((n=>{!function(e,t,n,r){const{obj:a,k:i}=C(e,t,Object);a[i]=a[i]||[],r&&(a[i]=a[i].concat(n)),r||a[i].push(n)}(n.loaded,[a],i),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,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,i=arguments.length>5?arguments[5]:void 0;if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:a,callback:i});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*a,i)}),a):i(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 a=this.queueLoad(e,t,n,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.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],a=n[1];this.read(r,a,"read",void 0,void 0,((n,i)=>{n&&this.logger.warn(`${t}loading namespace ${a} for language ${r} failed`,n),!n&&i&&this.logger.log(`${t}loaded namespace ${a} for language ${r}`,i),this.loaded(e,n,i)}))}saveMissing(e,t,n,r,a){let i=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={...i,isUpdate:a},l=this.backend.create.bind(this.backend);if(l.length<6)try{let a;a=5===l.length?l(e,t,n,r,s):l(e,t,n,r),a&&"function"==typeof a.then?a.then((e=>o(null,e))).catch(o):o(null,a)}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 a(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?a(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 i=this.services;i.logger=x,i.resourceStore=this.store,i.languageUtils=n,i.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||(i.formatter=a(t),i.formatter.init(i,this.options),this.options.interpolation.format=i.formatter.format.bind(i.formatter)),i.interpolator=new K(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new J(a(this.modules.backend),i.resourceStore,i,this.options),i.backendConnector.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];e.emit(t,...r)})),this.modules.languageDetector&&(i.languageDetector=a(this.modules.languageDetector),i.languageDetector.init&&i.languageDetector.init(i,this.options.detection,this.options)),this.modules.i18nFormat&&(i.i18nFormat=a(this.modules.i18nFormat),i.i18nFormat.init&&i.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),a=1;a<n;a++)r[a-1]=arguments[a];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 i=k(),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),i.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),i}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=k();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=k();this.emit("languageChanging",e);const a=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(e,i)=>{i?(a(i),this.translator.changeLanguage(i),this.isLanguageChangingTo=void 0,this.emit("languageChanged",i),this.logger.log("languageChanged",i)):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||a(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(n)),this.loadResources(n,(e=>{i(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 a=function(e,t){let i;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];i=r.options.overloadTranslationOptionHandler([e,t].concat(s))}else i={...t};i.lng=i.lng||a.lng,i.lngs=i.lngs||a.lngs,i.ns=i.ns||a.ns,i.keyPrefix=i.keyPrefix||n||a.keyPrefix;const u=r.options.keySeparator||".";let c;return c=i.keyPrefix&&Array.isArray(e)?e.map((e=>`${i.keyPrefix}${u}${e}`)):i.keyPrefix?`${i.keyPrefix}${u}${e}`:e,r.t(c,i)};return"string"==typeof e?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=n,a}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,a=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;const i=(e,t)=>{const n=this.services.backendConnector.state[`${e}|${t}`];return-1===n||2===n};if(t.precheck){const e=t.precheck(this,i);if(void 0!==e)return e}return!!this.hasResourceBundle(n,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!i(n,e)||r&&!i(a,e)))}loadNamespaces(e,t){const n=k();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=k();"string"==typeof e&&(e=[e]);const r=this.options.preload||[],a=e.filter((e=>r.indexOf(e)<0));return a.length?(this.options.preload=r.concat(a),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},a=new te(r);void 0===e.debug&&void 0===e.prefix||(a.logger=a.logger.clone(e));return["store","services","language"].forEach((e=>{a[e]=this[e]})),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},n&&(a.store=new N(this.store.data,r),a.services.resourceStore=a.store),a.translator=new B(a.services,r),a.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];a.emit(e,...n)})),a.init(r,t),a.translator.options=r,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}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 ae(e,t){return e(t={exports:{}},t.exports),t.exports}const ie={};function oe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&ie[t[0]]||("string"==typeof t[0]&&(ie[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:a,defaultNS:i}=n.useContext(me)||{},o=r||a||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||i||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],a=!!t.options&&t.options.fallbackLng,i=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)||a&&!o(i,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=[],ke=Ee.forEach,Se=Ee.slice;var Ce=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Te=function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};n&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+60*n*1e3)),r&&(a.domain=r),document.cookie=function(e,t,n){var r=n||{};r.path=r.path||"/";var a=encodeURIComponent(t),i="".concat(e,"=").concat(a);if(r.maxAge>0){var o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");i+="; Max-Age=".concat(Math.floor(o))}if(r.domain){if(!Ce.test(r.domain))throw new TypeError("option domain is invalid");i+="; Domain=".concat(r.domain)}if(r.path){if(!Ce.test(r.path))throw new TypeError("option path is invalid");i+="; Path=".concat(r.path)}if(r.expires){if("function"!=typeof r.expires.toUTCString)throw new TypeError("option expires is invalid");i+="; Expires=".concat(r.expires.toUTCString())}if(r.httpOnly&&(i+="; HttpOnly"),r.secure&&(i+="; Secure"),r.sameSite)switch("string"==typeof r.sameSite?r.sameSite.toLowerCase():r.sameSite){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i}(e,encodeURIComponent(t),a)},Ae=function(e){for(var t="".concat(e,"="),n=document.cookie.split(";"),r=0;r<n.length;r++){for(var a=n[r];" "===a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(t))return a.substring(t.length,a.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&&Te(t.lookupCookie,e,t.cookieMinutes,t.cookieDomain,t.cookieOptions)}},Ie={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("&"),a=0;a<r.length;a++){var i=r[a].indexOf("=");if(i>0)r[a].substring(0,i)===e.lookupQuerystring&&(t=r[a].substring(i+1))}}return t}},_e=null,De=function(){if(null!==_e)return _e;try{_e="undefined"!==window&&null!==window.localStorage;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch(e){_e=!1}return _e},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)}},Me=null,Le=function(){if(null!==Me)return Me;try{Me="undefined"!==window&&null!==window.sessionStorage;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch(e){Me=!1}return Me},Ne={name:"sessionStorage",lookup:function(e){var t;if(e.lookupSessionStorage&&Le()){var n=window.sessionStorage.getItem(e.lookupSessionStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&Le()&&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 ke.call(Se.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(Ie),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,signatureVideo:null,additionalDocuments:null,setIdFrontImage:function(){return null},setIdBackImage:function(){return null},setPassportImage:function(){return null},setSelfieImage:function(){return null},setSignatureData:function(){return null},setSignatureVideo: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:\n Inter,\n -apple-system,\n BlinkMacSystemFont,\n Segoe UI,\n Roboto,\n Oxygen,\n Ubuntu,\n Cantarell,\n Fira Sans,\n Droid Sans,\n Helvetica Neue,\n 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:\n Inter,\n -apple-system,\n BlinkMacSystemFont,\n Segoe UI,\n Roboto,\n Oxygen,\n Ubuntu,\n Cantarell,\n Fira Sans,\n Droid Sans,\n Helvetica Neue,\n 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,a=e.className,i=e.heightOffset,o=void 0===i?0:i,s=e.style,l=e.onClick,c=n.useState(!1),d=c[0],h=c[1];return n.useEffect((function(){h(!1);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(),h(!0),function(){window.removeEventListener("resize",e)}}),[]),u.default.createElement(Je,{ref:t,style:s,onClick:l,className:a,$heightOffset:o},d&&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"]))),at=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"]))),it=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 a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);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 a=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,n=[],r=0,a=e.split(",");r<a.length;r++){var i=a[r].match(t);if(null!==i){var o=+i[2],s=+i[5],l=i[4],u=i[7];0!==o||l||(l=u),0!==s||u||(u=l),l===u&&n.push({prefix:i[1]||"",x:o,y:s,xUnits:l,yUnits:u,end:i[8]})}}return n}(r),i=0;i<t.lines;i++){var o=~~(360/t.lines*i+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,i),borderRadius:n,transformOrigin:"left",transform:"rotate("+o+"deg) translateX("+t.radius+"px)"}),l=i*t.direction/t.lines/t.speed;l-=1/t.speed;var u=ct(document.createElement("div"),{width:"100%",height:"100%",background:dt(t.color,i),borderRadius:n,boxShadow:ht(a,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,a=e;r<a.length;r++){var i=a[r],o=ft(i.x,i.y,t);n.push(i.prefix+o[0]+i.xUnits+" "+o[1]+i.yUnits+i.end)}return n.join(", ")}function ft(e,t,n){var r=n*Math.PI/180,a=Math.sin(r),i=Math.cos(r);return[Math.round(1e3*(e*i+t*a))/1e3,Math.round(1e3*(-e*a+t*i))/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,a=e.querySelector(".ladda-spinner");a||((a=document.createElement("span")).className="ladda-spinner"),e.appendChild(a);var i={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 a=.2*r;return new ut({color:t||"#fff",lines:n||12,radius:a,length:.6*a,width:a<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(a),this.setProgress(0),this},startAfter:function(e){return clearTimeout(n),n=setTimeout((function(){i.start()}),e),this},stop:function(){return i.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 i}console.warn("Ladda button target must be defined.")}var gt=function(e){var t=e.accessBlockedImageUrl,r=ye().t,a=n.useContext(qe).retryLocationAccess,i=n.useRef(null),o=n.useRef(null);return n.useEffect((function(){var e,t;if(i.current)return o.current=pt(i.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(at,{style:{maxWidth:500,height:"auto",margin:"auto"}},u.default.createElement(it,{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:i,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"},r("Retry"))))))};function mt(){return window.platform}var vt,yt,bt=function(e){var t=e.action,r=e.children,a=e.url,i=e.environment,o=void 0===i?"prod":i,s=e.token,l=e.companyId,c=e.enrollmentId,d=e.personalData,h=e.cardData,f=e.manualReviewRequired,y=void 0!==f&&f,b=e.verifyIdWithExternalDatabases,w=void 0!==b&&b,x=e.deduplicationEnabled,E=void 0!==x&&x,k=e.deduplicationSynchronous,S=void 0!==k&&k,C=e.geolocationEnabled,T=void 0===C||C,A=e.geolocationRequired,R=void 0!==A&&A,I=e.webhooksEnabled,_=void 0!==I&&I,D=e.webhooksClientTraceId,F=e.webhooksStripSpecialCharacters,M=void 0===F||F,L=e.onBeforeSubmit,N=e.onResponseReceived,O=e.onRequestFailure,P=n.useState(je.READY),B=P[0],U=P[1],$=n.useState(null),j=$[0],G=$[1],z=n.useState(null),q=z[0],H=z[1],V=n.useState(null),W=V[0],K=V[1],Y=n.useState(null),X=Y[0],J=Y[1],Z=n.useState(null),Q=Z[0],ee=Z[1],te=n.useState(null),ne=te[0],re=te[1],ae=n.useState(null),ie=ae[0],oe=ae[1],se=n.useState(null),le=se[0],ue=se[1],ce=n.useState(null),de=ce[0],he=ce[1],fe=n.useState(null),pe=fe[0],ge=fe[1],me=n.useState(0),ve=me[0],ye=me[1],be=n.useState(!1),we=be[0],xe=be[1],Ee=n.useState([]),ke=Ee[0],Se=Ee[1],Ce=n.useState([]),Te=Ce[0],Ae=Ce[1],Re=n.useState([]),Ie=Re[0],_e=Re[1],De=n.useCallback((function(e){Se((function(t){return v(v([],t,!0),[e],!1)}))}),[]),Fe=n.useCallback((function(e){Ae((function(t){return v(v([],t,!0),[e],!1)}))}),[]),Me=n.useCallback((function(e){_e((function(t){return v(v([],t,!0),[e],!1)}))}),[]),Le=n.useCallback((function(){return g(void 0,void 0,void 0,(function(){var e,n,r,i,u,f,g,v,b,x;return m(this,(function(m){switch(m.label){case 0:if(t===$e.NONE)return e={status:{statusCode:"000"},resultData:{}},U(je.SUBMITTED),H(e),[2,e];U(je.SUBMITTING),m.label=1;case 1:return m.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:y?"Y":"N",bypassAgeValidation:"N",deDuplicationRequired:E?"Y":"N",bypassNameMatching:"Y",postDataAPIRequired:_?"Y":"N",sendInputImagesInPost:"N",sendProcessedImagesInPost:"N",needImmediateResponse:"N",deduplicationSynchronous:S?"Y":"N",verifyDataWithHost:w?"Y":"N",idBackImageRequired:"N",stripSpecialCharacters:M?"Y":"N",idImageResolutionCheck:"Y"}},W&&(n.customerData.idData.idImageFront=W),X&&(n.customerData.idData.idImageBack=X),Q&&(n.customerData.idData.idImageFront=Q),ne&&(t===$e.IDENTIFY?n.biometricData={selfie:ne}:n.customerData.biometricData={selfie:ne}),l&&(n.employee={companyId:l}),d&&(n.customerData.personalData=d),h&&(n.customerData.cardData=h),c&&((x=n.customerData).personalData||(x.personalData={}),n.customerData.personalData.uniqueNumber=c),D&&(n.additionalData.clientTraceId=D),ie&&(n.customerData.signatureData={signatureImage:JSON.stringify(ie)}),de&&(n.customerData.additionalDocuments=de.map((function(e){return p(p({},e),{additionalDocument:JSON.stringify(p(p({},e.additionalDocument),{uniqueId:n.additionalData.uniqueRequestId}))})}))),r={selfie:Ie,front:ke,back:Te,isRealIDCheckRequired:"false",sdkVersion:"WebSDK_9.5.13.2.0",Resolution:"".concat(window.innerWidth," x ").concat(window.innerHeight)},(i=mt())&&(r.os=i.os.family,r.osVersion=i.os.version,r.browserVersion="".concat(i.name," ").concat(i.version)),pe&&(r.GeoLocation=JSON.stringify(pe)),n.additionalData.metadata=JSON.stringify(r),L?[4,L(n)]:[3,3];case 2:(u=m.sent())&&(n=u),m.label=3;case 3:return f=a||He(o,s),g=function(e,t,n,r){var a=r?"v4":"v3";switch(e){case $e.ENROLL:return"/".concat(a,t?"/customer/enroll":"/customer/enroll-biometrics");case $e.IDENTIFY:return"/".concat(a,"/customer/identify");case $e.VALIDATE:return"/".concat(a,n?"/customer/validate-id-match-face":"/customer/validate-id");case $e.VERIFY:return"/".concat(a,"/customer/verify");default:throw new Error("unrecognized SubmissionAction ".concat(e))}}(t,!!(W||X||Q),!!ne,!!s),[4,fetch(f+g,{method:"POST",headers:Ve(s),body:JSON.stringify(n)})];case 4:return[4,m.sent().json()];case 5:return v=m.sent(),G(n),H(v),U(je.SUBMITTED),null==N||N(v),[2,v];case 6:return b=m.sent(),U(je.FAILED),null==O||O(b),[2,null];case 7:return[2]}}))}))}),[t,de,c,o,pe,Te,X,ke,W,L,O,N,Q,Ie,ne,ie,s,a]),Ne=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,i,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=a||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 i=d.sent(),H(i),[2,i]}}))}))}),[o,s,a]),Oe=n.useCallback((function(){ye((function(e){return e+1}))}),[]);return n.useEffect((function(){T&&(console.log("making geolocation attempt",ve),navigator.geolocation.getCurrentPosition((function(e){ge(e),xe(!1)}),(function(e){if(1!==e.code)throw new Error(e.message);xe(!0)})))}),[ve,T,R]),u.default.createElement(qe.Provider,{value:{submit:Le,submissionStatus:B,submissionRequest:j,submissionResponse:q,submissionEnvironment:o,idFrontImage:W,idBackImage:X,passportImage:Q,selfieImage:ne,signatureData:ie,signatureVideo:le,additionalDocuments:de,setIdFrontImage:K,setIdBackImage:J,setPassportImage:ee,setSelfieImage:re,setSignatureData:oe,setSignatureVideo:ue,setAdditionalDocuments:he,logIdFrontCaptureAttempt:De,logIdBackCaptureAttempt:Fe,logSelfieCaptureAttempt:Me,checkLiveness:Ne,retryLocationAccess:Oe}},R&&we?u.default.createElement(gt,null):r)};function wt(e){return g(this,void 0,void 0,(function(){var t,n,r,a,i,o;return m(this,(function(s){switch(s.label){case 0:return yt?[2,yt]:[4,f.loadGraphModel(e)];case 1:return yt=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]),a=f.cast(r,"int32"),o=(i=f).dispose,[4,yt.executeAsync(a)];case 3:return o.apply(i,[s.sent()]),n.dispose(),a.dispose(),r.dispose(),f.dispose(t),[2,yt]}}))}))}!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"}(vt||(vt={}));var xt={1:"Document",2:"MRZ",3:"PDF417",4:"Primary face",5:"Secondary face",6:"Glare",7:"Punch Hole",8:"Passport Page"};function Et(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 kt(e){void 0===e&&(e={});var t=e.onResize,r=n.useRef(void 0);r.current=t;var a=e.round||Math.round,i=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),a=n.useRef(null);a.current=t;var i=n.useRef(null);n.useEffect((function(){o()}));var o=n.useCallback((function(){var t=a.current,n=i.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){i.current=e,o()}),[o])}(n.useCallback((function(t){return i.current&&i.current.box===e.box&&i.current.round===a||(i.current={box:e.box,round:a,instance:new ResizeObserver((function(t){var n=t[0],i="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",o=Et(n,i,"inlineSize"),s=Et(n,i,"blockSize"),d=o?a(o):void 0,h=s?a(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)}}))}),i.current.instance.observe(t,{box:e.box}),function(){i.current&&i.current.instance.unobserve(t)}}),[e.box,a]),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 Ct;function Tt(e){if(void 0!==Ct)return Ct;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 At=function(e){var t=e.width,r=void 0===t?0:t,a=e.height,i=void 0===a?0:a,o=e.padding,s=void 0===o?Tt()?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,k=x.wrapperRef,S=x.wrapperWidth,C=x.wrapperHeight,T=x.imageAspectRatio,A=x.wrapperAspectRatio,R=x.onImageLoaded,I=x.setDimensions;0==r&&(r=S),0==i&&(i=C),n.useEffect((function(){I({width:r,height:i})}),[i,I,r]);var _={height:C-2*s-2*c};return T>=A&&(_={width:S-2*s-2*c}),u.default.createElement(Ze,{ref:k,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:i-2*s-2*c}},u.default.createElement("img",{src:"portrait"===E?y:b,alt:"",onLoad:R,style:p({},_)})),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 Rt(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 It(e,t){return void 0===t&&(t=!1),g(this,void 0,void 0,(function(){var n,r,a,i,o,s,l,u,c;return m(this,(function(d){switch(d.label){case 0:return[4,new Promise((function(o){if(a=e.naturalWidth,i=e.naturalHeight,n=document.createElement("canvas"),!(r=n.getContext("2d")))return[];if(t){console.log("rotating!!"),n.width=i,n.height=a,r.setTransform(0,1,-1,0,n.width,0),r.drawImage(e,0,0,a,i);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 Dt(e,t){var n=this;return new Promise((function(r){var a=new Image;a.onload=function(){return g(n,void 0,void 0,(function(){var e,n,i,o;return m(this,(function(s){switch(s.label){case 0:return _t()?[4,Rt(a)]:[3,2];case 1:return n=s.sent(),console.log("native result",n,"".concat(a.width,"x").concat(a.height)),r(n.length>0?p(p({},n[0]),{Source:"native"}):null),[3,4];case 2:return e=(null!==(i=null==t?void 0:t[2])&&void 0!==i?i:0)<(null!==(o=null==t?void 0:t[3])&&void 0!==o?o:0),[4,It(a,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]}}))}))},a.src=URL.createObjectURL(e)}))}var Ft,Mt=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,a,i,o,s,l,u;return m(this,(function(c){switch(c.label){case 0:return Ft?[2,Ft]:[4,f.loadLayersModel(e)];case 1:return Ft=c.sent(),[4,f.ready()];case 2:return c.sent(),t=f.zeros([448,448,3]),n=f.cast(t,"int32"),i=(a=f).tensor4d,s=(o=Array).from,[4,n.data()];case 3:return r=i.apply(a,[s.apply(o,[c.sent()]),[1,448,448,3]]),l=f.cast(r,"int32"),[4,Ft.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,Ft]}}))}))}class Nt{refCount(e){return Ot("refCount")}incRef(e){return Ot("incRef")}timerAvailable(){return!0}time(e){return Ot("time")}read(e){return Ot("read")}readSync(e){return Ot("readSync")}readToGPU(e,t){return Ot("readToGPU")}numDataIds(){return Ot("numDataIds")}disposeData(e,t){return Ot("disposeData")}write(e,t,n){return Ot("write")}move(e,t,n,r,a){return Ot("move")}createTensorFromGPUData(e,t,n){return Ot("createTensorFromGPUData")}memory(){return Ot("memory")}floatPrecision(){return Ot("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return Ot("dispose")}}function Ot(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 Pt(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function Bt(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 Ut(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 $t(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function jt(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 Gt(e){return"string"==typeof e||e instanceof String}function zt(e){return Array.isArray(e)?zt(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":"number"==typeof e?"float32":Gt(e)?"string":function(e){return"boolean"==typeof e}(e)?"bool":"float32"}function qt(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Ht(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 Vt(e,t,n,r=!1){const a=new Array;if(1===t.length){const i=t[0]*(r?2:1);for(let t=0;t<i;t++)a[t]=n[e+t]}else{const i=t[0],o=t.slice(1),s=o.reduce(((e,t)=>e*t))*(r?2:1);for(let t=0;t<i;t++)a[t]=Vt(e+t*s,o,n,r)}return a}function Wt(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 Vt(0,e,t,n)}function Kt(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 Yt(e){e.forEach((t=>{Pt(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function Xt(e){return e&&e.then&&"function"==typeof e.then}const Jt="tfjsflags";class Zt{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Qt,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&(en().getBool("IS_TEST")||en().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];en().getBool("IS_TEST")||en().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(Xt(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(Jt in e){e[Jt].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 Qt(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 en(){return nn}let tn,nn=null;function rn(){if(null==tn){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}tn=e}return tn}function an(e,t){const n=function(){const e=rn();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 on="Add",sn="Cast",ln="Identity";function un(...e){en().getBool("IS_TEST")||en().getBool("PROD")||console.warn(...e)}const cn=an("kernelRegistry",(()=>new Map)),dn=an("gradRegistry",(()=>new Map));function hn(e,t){const n=function(e,t){return`${t}_${e}`}(e,t);return cn.get(n)}function fn(e){return dn.get(e)}function pn(e){const t=cn.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[i,o]=a,[s]=i.split("_");s===e&&n.push(o)}return n}function gn(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}function mn(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=wn(e)),en().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 vn(){return en().platform.now()}function yn(e,t="utf-8"){return t=t||"utf-8",en().platform.decode(e,t)}function bn(e){return null!=en().platform.isTypedArray?en().platform.isTypedArray(e):gn(e)}function wn(e,t=[],n=!1){if(null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||Xt(e)||null==e||bn(e)&&n)t.push(e);else if(Array.isArray(e)||bn(e))for(let r=0;r<e.length;++r)wn(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 a=0;a<=r;a++)wn(e[a],t,n)}return t}class xn{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new kn)}profileKernel(e,t,n){let r;const a=()=>{r=n()};let i;const o=vn();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(a);else{a();for(const e of r)e.dataSync();i=Promise.resolve({kernelMs:vn()-o})}if(en().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<r.length;t++){const n=r[t];n.data().then((t=>{En(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:i.then((e=>e.kernelMs)),extraInfo:i.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:i}=e;n.forEach((e=>{Promise.all([e.data(),r,i]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])}))}))}}function En(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 kn{logKernelProfile(e,t,n,r,a,i){const o="number"==typeof r?$t(`${r}ms`,9):r.error,s=$t(e,25),l=t.rank,u=t.size,c=$t(t.shape.toString(),14);let d="";for(const e in a){const n=a[e];if(null!=n){const r=n.shape||t.shape,a=r.length;d+=`${e}: ${a}D ${a>0?r:""} `}}console.log(`%c${s}\t%c${o}\t%c${l}D ${c}\t%c${u}\t%c${d}\t%c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}const Sn=20,Cn=3,Tn=7;function An(e,t,n,r){const a=Ht(t),i=function(e,t,n,r){const a=Bt(t),i=r[r.length-1],o=new Array(i).fill(0),s=t.length,l="complex64"===n?Dn(e):e;if(s>1)for(let e=0;e<a/i;e++){const t=e*i;for(let e=0;e<i;e++)o[e]=Math.max(o[e],Rn(l[t+e],0,n).length)}return o}(e,t,n,a),o=t.length,s=_n(e,t,n,a,i),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 Rn(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(Tn))} + ${parseFloat(e[1].toFixed(Tn))}j`:Gt(e)?`'${e}'`:"bool"===n?In(e):parseFloat(e.toFixed(Tn)).toString(),$t(r,t)}function In(e){return 0===e?"false":"true"}function _n(e,t,n,r,a,i=!0){const o="complex64"===n?2:1,s=t[0],l=t.length;if(0===l){if("complex64"===n){return[Rn(Dn(e)[0],0,n)]}return"bool"===n?[In(e[0])]:[e[0].toString()]}if(1===l){if(s>Sn){let t=Array.from(e.slice(0,Cn*o)),r=Array.from(e.slice((s-Cn)*o,s*o));return"complex64"===n&&(t=Dn(t),r=Dn(r)),["["+t.map(((e,t)=>Rn(e,a[t],n))).join(", ")+", ..., "+r.map(((e,t)=>Rn(e,a[s-Cn+t],n))).join(", ")+"]"]}return["["+("complex64"===n?Dn(e):Array.from(e)).map(((e,t)=>Rn(e,a[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<Cn;t++){const r=t*d;h.push(..._n(e.slice(r,r+d),u,n,c,a,!1))}h.push("...");for(let t=s-Cn;t<s;t++){const r=t*d;h.push(..._n(e.slice(r,r+d),u,n,c,a,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,a,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]+"]"+(i?"":p),h}function Dn(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}class Fn{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=Bt(e),null!=n){const e=n.length;Pt(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=Ht(e)}set(e,...t){0===t.length&&(t=[0]),Pt(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 Mn().makeTensor(this.values,this.shape,this.dtype)}}let Mn=null,Ln=null;class Nn{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=Bt(e),this.strides=Ht(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 Wt(this.shape,e,"complex64"===this.dtype)}arraySync(){return Wt(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=Mn().read(this.dataId);if("string"===this.dtype){const t=await e;try{return t.map((e=>yn(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(),Mn().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Mn().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>yn(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 Mn().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Mn().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 An(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Ln.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Mn().makeVariable(this,e,t,n)}}Object.defineProperty(Nn,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),an("Tensor",(()=>Nn));class On extends Nn{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(!Ut(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Mn().disposeTensor(this),this.dataId=e.dataId,Mn().incRef(this,null)}dispose(){Mn().disposeVariable(this),this.isDisposedInternal=!0}}var Pn,Bn,Un,$n,jn;Object.defineProperty(On,Symbol.hasInstance,{value:e=>e instanceof Nn&&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"}(Pn||(Pn={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(Bn||(Bn={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(Un||(Un={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}($n||($n={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(jn||(jn={}));const Gn={float32:$n,int32:Bn,bool:Un,complex64:jn};function zn(e){return null!=e&&"object"==typeof e&&"texture"in e&&e.texture instanceof WebGLTexture}function qn(e){return"undefined"!=typeof GPUBuffer&&null!=e&&"object"==typeof e&&"buffer"in e&&e.buffer instanceof GPUBuffer}function Hn(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 Gn[e][t]}(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function Vn(e){const t=[];return Wn(e,t,new Set),t}function Wn(e,t,n){if(null==e)return;if(e instanceof Nn)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const a=e;for(const e in a){const r=a[e];n.has(r)||(n.add(r),Wn(r,t,n))}}function Kn(e){return null!=e.kernelName}class Yn{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 Xn{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Yn}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?(un(`${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 xn(this.backendInstance),!0}setupRegisteredKernels(){pn(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){pn(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 Nt||"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,un(`Initialization of backend ${e} failed`),un(n.stack||n.message)),!1)));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(t){return un(`Initialization of backend ${e} failed`),un(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:a}=this.initializeBackend(n);if(a||r)return{name:n,asyncInit:a}}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,a=this.readSync(t),i=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,a,n.shape,n.dtype,i),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 Xn.nextTensorId++}nextVariableId(){return Xn.nextVariableId++}clone(e){const t=Zn.runKernel(ln,{x:e});return this.addTapeNode(this.state.activeScope.name,{x:e},[t],(e=>({x:()=>Zn.runKernel(sn,{x:e},{dtype:"float32"})})),[],{}),t}runKernel(e,t,n){if(!(null!=hn(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 a=0;n.forEach((e=>{a+="complex64"===e.dtype?3:1}));const i=r-t-a-this.state.numDataMovesStack[this.state.numDataMovesStack.length-1];if(i>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,i=this.state.numTensors;let o,s;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);const l=Kn(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(Kn(e)){const{kernelName:t,inputs:a,attrs:i}=e,l=hn(t,this.backendName);Pt(null!=l,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),o=()=>{const e=this.backend.numDataIds();s=l.kernelFunc({inputs:a,attrs:i,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,a,u);n=this.saveTensorsForBackwardMode(e)}return u}}else{const{forwardFunc:t}=e,a=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};o=()=>{const e=this.backend.numDataIds();s=this.tidy((()=>t(this.backend,a)));const n=Array.isArray(s)?s:[s];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,e,n),n}}const{inputs:u,attrs:c}=e,d=Kn(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-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,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=fn(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let i;r.saveAllInputs?(Pt(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),i=Object.keys(t).map((e=>t[e]))):i=e.map((e=>t[e]));const o=n.filter(((e,t)=>a[t]));return i.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 a=e;"string"===(n=n||"float32")&&Gt(e[0])&&(a=e.map((e=>function(e,t="utf-8"){return t=t||"utf-8",en().platform.encode(e,t)}(e))));const i=r.write(a,t,n),o=new Nn(t,n,i,this.nextTensorId());if(this.trackTensor(o,r),"string"===n){const e=this.state.tensorInfo.get(i),t=function(e){if(null==e)return 0;let t=0;return e.forEach((e=>t+=e.length)),t}(a);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:a}=e,i=new Nn(r,a,n,this.nextTensorId());return this.trackTensor(i,t),i}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new On(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*jt(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 On||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*jt(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,a,i){const o={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},s=fn(e);null!=s&&(r=s.gradFunc),null!=r&&(o.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=Kt(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],a,i))),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=Vn(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(Pt(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 a=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));Pt(a instanceof Nn,(()=>"The result y returned by f() must be a tensor."));const i=function(e,t,n){const r={},a={};for(let e=0;e<t.length;e++)r[t[e].id]=!0;for(let n=0;n<e.length;n++){const i=e[n],o=i.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]){i.outputs.forEach((e=>r[e.id]=!0)),s=!0,a[i.id]=!0;break}if(s)break}}const i={};i[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(i[n.outputs[e].id]){for(const e in r)i[r[e].id]=!0,o[n.id]=!0;break}}const s=[];for(let t=0;t<e.length;t++){const n=e[t];if(a[n.id]&&o[n.id]){const e={};for(const t in n.inputs){const a=n.inputs[t];r[a.id]&&(e[t]=a)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,s.push(t)}}return s}(this.state.activeTape,t,a);if(!r&&0===i.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[a.id]=null==n?function(e){const t=function(e,t){const n=Kt(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}(Bt(e),"float32");return Zn.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const i=t[a],o=[];if(i.outputs.forEach((t=>{const n=e[t.id];o.push(null!=n?n:null)})),null==i.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${i.kernelName}.`);const s=i.gradient(o);for(const t in i.inputs){if(!(t in s))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(s)}.`);const a=n((()=>s[t]()));if("float32"!==a.dtype)throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const o=i.inputs[t];if(!Ut(a.shape,o.shape))throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${o.shape}'`);if(null==e[o.id])e[o.id]=a;else{const t=e[o.id];e[o.id]=r(t,a),t.dispose()}}}}(e,i,(e=>this.tidy(e)),Qn);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:a,grads:r}}))}customGrad(e){return Pt(qt(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;Pt(t.every((e=>e instanceof Nn)),(()=>"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,a)=>(n=e(...t,a),Pt(n.value instanceof Nn,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),Pt(qt(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 a=n.gradFunc(e,r),i=Array.isArray(a)?a:[a];Pt(i.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(...).")),Pt(i.every((e=>e instanceof Nn)),(()=>"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 i.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=vn(),n=await this.backend.time(e);return n.wallMs=vn()-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 Yn;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 Jn(){const e=rn();if(null==e._tfengine){const t=new Zt(e);e._tfengine=new Xn(t)}return nn=e._tfengine.ENV,function(e){Mn=e}((()=>e._tfengine)),e._tfengine}Xn.nextTensorId=0,Xn.nextVariableId=0;const Zn=Jn();function Qn(e,t){return Zn.runKernel(on,{a:e,b:t})}const er=en();function tr(e,t){let n=e;if(bn(e))return"string"===t?[]:[e.length];if(zn(e)){return[e.height,e.width*(e.channels||"RGBA").length]}if(qn(e))return[e.buffer.size/(null==t?4:jt(t))];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||bn(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&en().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&nr(e,r,[]),r}function nr(e,t,n){if(n=n||[],!Array.isArray(e)&&!bn(e))return void Pt(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));Pt(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),Pt(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)nr(e[t],r,n.concat(t))}function rr(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 ar(e,t,n,r="numeric"){if(e instanceof Nn)return rr(r,e.dtype,t,n),e;let a=zt(e);if("string"!==a&&["bool","int32","float32"].indexOf(r)>=0&&(a=r),rr(r,a,t,n),null==e||!bn(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 i=tr(e,a);bn(e)||Array.isArray(e)||(e=[e]);const o="string"!==a?mn(e,a):wn(e,[],!0);return Zn.makeTensor(o,i,a)}er.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.")})),er.registerFlag("IS_BROWSER",(()=>"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope)),er.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),er.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),er.registerFlag("IS_SAFARI",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor))),er.registerFlag("PROD",(()=>!1)),er.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>er.getBool("DEBUG"))),er.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),er.registerFlag("IS_TEST",(()=>!1)),er.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>er.getBool("DEBUG"))),er.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),er.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(()=>!1)),er.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 a=(...e)=>{Zn.startScope(n);try{const t=r(...e);return Xt(t)&&console.error("Cannot return a Promise inside of tidy."),Zn.endScope(t),t}catch(e){throw Zn.endScope(null),e}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}class or{static join(e){return new or(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,null==e)return;if(e instanceof Array||(e=[e]),0===(e=e.map((e=>bn(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 a=t+r.byteLength;this.shards.push({buffer:r,start:t,end:a}),t=a}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),a=new Uint8Array(r);let i=0;for(let r=n;r<this.shards.length;r++){const n=this.shards[r],o=e+i-n.start,s=i,l=Math.min(t,n.end),u=new Uint8Array(n.buffer,o,l-n.start-o);if(a.set(u,s),i+=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 a=Math.floor((r-n)/2)+n,i=t(e[a]);if(0===i)return a;i<0?r=a:n=a+1}return-1}(this.shards,t);return-1===n?-1:(this.previousShardIndex=n,this.previousShardIndex)}}const sr="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function lr(e){return sr?Buffer.byteLength(e,"utf8"):new Blob([e]).size}function ur(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:lr(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:lr(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:new or(e.weightData).byteLength}}class cr{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==cr.instance&&(cr.instance=new cr),cr.instance}static registerSaveRouter(e){cr.getInstance().saveRouters.push(e)}static registerLoadRouter(e){cr.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return cr.getHandlers(e,"save")}static getLoadHandlers(e,t){return cr.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?cr.getInstance().loadRouters:cr.getInstance().saveRouters).forEach((t=>{const a=t(e,n);null!==a&&r.push(a)})),r}}const dr="tensorflowjs",hr="models_store",fr="model_info_store";function pr(){if(!en().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 gr(e){const t=e.result;t.createObjectStore(hr,{keyPath:"modelPath"}),t.createObjectStore(fr,{keyPath:"modelPath"})}class mr{constructor(e){if(this.indexedDB=pr(),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(dr,1);r.onupgradeneeded=()=>gr(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(hr,"readonly"),r=t.objectStore(hr).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=ur(t),i=a.transaction(fr,"readwrite");let o,s,l=i.objectStore(fr);try{o=l.put({modelPath:this.modelPath,modelArtifactsInfo:r})}catch(e){return n(e)}o.onsuccess=()=>{s=a.transaction(hr,"readwrite");const o=s.objectStore(hr);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=i.objectStore(fr);const t=l.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(u.error)),t.onerror=e=>(a.close(),n(u.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==s?a.close():s.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)}))}}mr.URL_SCHEME="indexeddb://";const vr=e=>{return en().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(mr.URL_SCHEME)?(t=e.slice(mr.URL_SCHEME.length),new mr(t)):null;var t};cr.registerSaveRouter(vr),cr.registerLoadRouter(vr);class yr{constructor(){this.indexedDB=pr()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(dr,1);n.onupgradeneeded=()=>gr(n),n.onsuccess=()=>{const r=n.result,a=r.transaction(fr,"readonly"),i=a.objectStore(fr).getAll();i.onsuccess=()=>{const t={};for(const e of i.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},i.onerror=e=>(r.close(),t(i.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(mr.URL_SCHEME)?t.slice(mr.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(dr,1);r.onupgradeneeded=()=>gr(r),r.onsuccess=()=>{const a=r.result,i=a.transaction(fr,"readwrite"),o=i.objectStore(fr),s=o.get(e);let l;s.onsuccess=()=>{if(null==s.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=o.delete(e),i=()=>{l=a.transaction(hr,"readwrite");const r=l.objectStore(hr).delete(e);r.onsuccess=()=>t(s.result.modelArtifactsInfo),r.onerror=e=>n(s.error)};r.onsuccess=i,r.onerror=e=>(i(),a.close(),n(s.error))}},s.onerror=e=>(a.close(),n(s.error)),i.oncomplete=()=>{null==l?a.close():l.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)}))}}const br="/",wr="tensorflowjs_models",xr="info",Er="model_topology",kr="weight_specs",Sr="weight_data",Cr="model_metadata";function Tr(e){return{info:[wr,e,xr].join(br),topology:[wr,e,Er].join(br),weightSpecs:[wr,e,kr].join(br),weightData:[wr,e,Sr].join(br),modelMetadata:[wr,e,Cr].join(br)}}function Ar(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function Rr(e){const t=e.split(br);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(br)}class Ir{constructor(e){if(!en().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=Tr(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=ur(e),a=or.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(sr)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)}(a));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 Ar(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 a=this.LS.getItem(this.keys.modelMetadata);if(null!=a){const e=JSON.parse(a);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 i=this.LS.getItem(this.keys.weightData);if(null==i)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=function(e){if(sr){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}(i),t}}Ir.URL_SCHEME="localstorage://";const _r=e=>{return en().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ir.URL_SCHEME)?(t=e.slice(Ir.URL_SCHEME.length),new Ir(t)):null;var t};cr.registerSaveRouter(_r),cr.registerLoadRouter(_r);class Dr{constructor(){Pt(en().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),Pt("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=wr+br,n=br+xr;for(let r=0;r<this.LS.length;++r){const a=this.LS.key(r);if(a.startsWith(t)&&a.endsWith(n)){e[Rr(a)]=JSON.parse(this.LS.getItem(a))}}return e}async removeModel(e){var t;const n=Tr(e=(t=e).startsWith(Ir.URL_SCHEME)?t.slice(Ir.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 Ar(n),r}}class Fr{constructor(){this.managers={}}static getInstance(){return null==Fr.instance&&(Fr.instance=new Fr),Fr.instance}static registerManager(e,t){Pt(null!=e,(()=>"scheme must not be undefined or null.")),e.endsWith("://")&&(e=e.slice(0,e.indexOf("://"))),Pt(e.length>0,(()=>"scheme must not be an empty string."));const n=Fr.getInstance();Pt(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=Fr.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(Fr.getInstance().managers)}}class Mr{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&&en().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 gn(e)}}if(en().get("IS_BROWSER")){en().setPlatform("browser",new Mr);try{Fr.registerManager(Ir.URL_SCHEME,new Dr)}catch(e){}try{Fr.registerManager(mr.URL_SCHEME,new yr)}catch(e){}}const Lr=()=>require("node-fetch");let Nr;class Or{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=en().global.fetch?en().global.fetch(e,t):(null==Nr&&(Nr=Lr()),Nr(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)}}en().get("IS_NODE")&&!en().get("IS_BROWSER")&&en().setPlatform("node",new Or);const Pr=ir({cast_:function(e,t){const n=ar(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 Zn.runKernel(sn,{x:n},{dtype:t})}});const Br=ir({clone_:function(e){const t=ar(e,"x","clone","string_or_numeric");return Zn.runKernel(ln,{x:t})}});Jn();const Ur={buffer:function(e,t="float32",n){return t=t||"float32",Yt(e),new Fn(e,t,n)},cast:Pr,clone:Br,print:function(e,t=!1){console.log(e.toString(t))}};function $r(e,t){return Zn.tidy(e,t)}function jr(e){Vn(e).forEach((e=>e.dispose()))}Ln=Ur;const Gr=ir({add_:function(e,t){let n=ar(e,"a","add"),r=ar(t,"b","add");return[n,r]=Hn(n,r),Zn.runKernel(on,{a:n,b:r})}});const zr=ir({floorDiv_:function(e,t){let n=ar(e,"a","floorDiv"),r=ar(t,"b","floorDiv");return[n,r]=Hn(n,r),Zn.runKernel("FloorDiv",{a:n,b:r})}});const qr=ir({div_:function(e,t){let n=ar(e,"a","div"),r=ar(t,"b","div");return[n,r]=Hn(n,r),"int32"===n.dtype&&"int32"===r.dtype?zr(n,r):Zn.runKernel("RealDiv",{a:n,b:r},{})}});const Hr=ir({mul_:function(e,t){let n=ar(e,"a","mul"),r=ar(t,"b","mul");return[n,r]=Hn(n,r),Zn.runKernel("Multiply",{a:n,b:r})}});const Vr=ir({abs_:function(e){const t=ar(e,"x","abs");if("complex64"===t.dtype){return Zn.runKernel("ComplexAbs",{x:t})}return Zn.runKernel("Abs",{x:t})}});const Wr=ir({zerosLike_:function(e){const t=ar(e,"x","zerosLike");return Zn.runKernel("ZerosLike",{x:t})}});const Kr=ir({pow_:function(e,t){let n=ar(e,"base","pow"),r=ar(t,"exp","pow");return[n,r]=Hn(n,r),Zn.runKernel("Pow",{a:n,b:r})}});function Yr(e,t){if((bn(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&&bn(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=zt(e);else if("complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(qn(e)||zn(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 Zn.backend.createTensorFromGPUData(e,t||n,r)}if(!bn(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){Yt(t);const e=Bt(t),r=Bt(n);Pt(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]!==Bt(t.slice(e));Pt(n[e]===t[e]||!r,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return bn(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?mn(e,r):wn(e,[],!0),Zn.makeTensor(e,t,r)}(e,[],[],t)}const Xr=ir({sqrt_:function(e){const t=ar(e,"x","sqrt","float32");return Zn.runKernel("Sqrt",{x:t})}});const Jr=ir({square_:function(e){const t=ar(e,"x","square");return Zn.runKernel("Square",{x:t},{})}});const Zr=ir({sub_:function(e,t){let n=ar(e,"a","sub"),r=ar(t,"b","sub");return[n,r]=Hn(n,r),Zn.runKernel("Sub",{a:n,b:r})}});const Qr=ir({maximum_:function(e,t){let n=ar(e,"a","maximum"),r=ar(t,"b","maximum");return[n,r]=Hn(n,r),"bool"===n.dtype&&(n=Pr(n,"int32"),r=Pr(r,"int32")),function(e,t){const n=Math.max(e.length,t.length),r=new Array(n);for(let a=0;a<n;a++){let i=e[e.length-a-1];null==i&&(i=1);let o=t[t.length-a-1];if(null==o&&(o=1),1===i)r[n-a-1]=o;else if(1===o)r[n-a-1]=i;else{if(i!==o)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);r[n-a-1]=i}}}(n.shape,r.shape),Zn.runKernel("Maximum",{a:n,b:r})}});class ea{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class ta{constructor(){this.classNameMap={}}static getMap(){return null==ta.instance&&(ta.instance=new ta),ta.instance}static register(e){ta.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function na(e){Pt(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),Pt("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),Pt(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),ta.register(e)}class ra extends ea{minimize(e,t=!1,n){const{value:r,grads:a}=this.computeGradients(e,n);if(null!=n){const e=n.map((e=>({name:e.name,tensor:a[e.name]})));this.applyGradients(e)}else this.applyGradients(a);return jr(a),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){Pt(qt(e),(()=>"The f passed in variableGrads(f) must be a function")),Pt(null==t||Array.isArray(t)&&t.every((e=>e instanceof On)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=t;if(!n){t=[];for(const e in Zn.registeredVariables)t.push(Zn.registeredVariables[e])}const r=n?t.filter((e=>!e.trainable)):null,a=t.length;Pt((t=t.filter((e=>e.trainable))).length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${a} variables is trainable.`));const{value:i,grads:o}=Zn.gradients(e,t,null,!0);Pt(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().")),Pt(0===i.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.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:i,grads:s}}(e,t)}dispose(){null!=this.iterations_&&jr(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:Yr(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(ra,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class aa extends ra{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 a=Zn.registeredVariables[t];$r((()=>{const e=Gr(Hr(this.c,r),a);a.assign(e)}))})),this.incrementIterations()}setLearningRate(e){var t;this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=(t=Yr(-e),Zn.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 ia=[class extends ra{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=Zn.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Zn.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:$r((()=>Wr(r).variable(false)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:$r((()=>Wr(r).variable(false)))});const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable,o=this.accumulatedUpdates[n].variable;$r((()=>{const e=Gr(Hr(i,this.rho),Hr(Jr(a),1-this.rho)),t=Hr(qr(Xr(Gr(o,this.epsilon)),Xr(Gr(i,this.epsilon))),a),n=Gr(Hr(o,this.rho),Hr(Jr(t),1-this.rho));i.assign(e),o.assign(n);const s=Gr(Hr(t,-this.learningRate),r);r.assign(s)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(jr(this.accumulatedGrads.map((e=>e.variable))),jr(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 ra{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=Zn.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:$r((()=>function(e,t,n){return Yt(e),n=n||zt(t),Zn.runKernel("Fill",{},{shape:e,value:t,dtype:n})}(r.shape,this.initialAccumulatorValue).variable(e)))}}const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable;$r((()=>{const e=Gr(i,Jr(a));i.assign(e);const t=Gr(Hr(qr(a,Xr(Gr(e,Zn.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&jr(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 ra{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=[],$r((()=>{this.accBeta1=Yr(t).variable(),this.accBeta2=Yr(n).variable()})),null==r&&(this.epsilon=Zn.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);$r((()=>{const n=Zr(1,this.accBeta1),r=Zr(1,this.accBeta2);t.forEach(((t,a)=>{const i=Zn.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:$r((()=>Wr(i).variable(false)))}),null==this.accumulatedSecondMoment[a]&&(this.accumulatedSecondMoment[a]={originalName:`${t}/v`,variable:$r((()=>Wr(i).variable(false)))});const o=Array.isArray(e)?e[a].tensor:e[t];if(null==o)return;const s=this.accumulatedFirstMoment[a].variable,l=this.accumulatedSecondMoment[a].variable,u=Gr(Hr(s,this.beta1),Hr(o,1-this.beta1)),c=Gr(Hr(l,this.beta2),Hr(Jr(o),1-this.beta2)),d=qr(u,n),h=qr(c,r);s.assign(u),l.assign(c);const f=Gr(Hr(qr(d,Gr(Xr(h),this.epsilon)),-this.learningRate),i);i.assign(f)})),this.accBeta1.assign(Hr(this.accBeta1,this.beta1)),this.accBeta2.assign(Hr(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&jr(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&jr(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),$r((()=>{this.accBeta1.assign(Kr(this.beta1,this.iterations_+1)),this.accBeta2.assign(Kr(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 ra{static get className(){return"Adamax"}constructor(e,t,n,r=null,a=0){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=a,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],$r((()=>{this.iteration=Yr(0).variable(),this.accBeta1=Yr(t).variable()})),null==r&&(this.epsilon=Zn.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);$r((()=>{const n=Zr(1,this.accBeta1),r=qr(-this.learningRate,Gr(Hr(this.iteration,this.decay),1));t.forEach(((t,a)=>{const i=Zn.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:Wr(i).variable(false)}),null==this.accumulatedWeightedInfNorm[a]&&(this.accumulatedWeightedInfNorm[a]={originalName:`${t}/v`,variable:Wr(i).variable(false)});const o=Array.isArray(e)?e[a].tensor:e[t];if(null==o)return;const s=this.accumulatedFirstMoment[a].variable,l=this.accumulatedWeightedInfNorm[a].variable,u=Gr(Hr(s,this.beta1),Hr(o,1-this.beta1)),c=Hr(l,this.beta2),d=Vr(o),h=Qr(c,d);s.assign(u),l.assign(h);const f=Gr(Hr(qr(r,n),qr(u,Gr(h,this.epsilon))),i);i.assign(f)})),this.iteration.assign(Gr(this.iteration,1)),this.accBeta1.assign(Hr(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&jr(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&jr(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 aa{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=Yr(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Zn.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:$r((()=>Wr(r).variable(e)))}}const a=this.accumulations[n].variable,i=Array.isArray(e)?e[n].tensor:e[t];null!=i&&$r((()=>{let e;const t=Gr(Hr(this.m,a),i);e=Gr(Hr(this.c,this.useNesterov?Gr(i,Hr(t,this.m)):t),r),a.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&jr(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 ra{static get className(){return"RMSProp"}constructor(e,t=.9,n=0,r=null,a=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=a,null==r&&(this.epsilon=Zn.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=Zn.registeredVariables[t],a=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:$r((()=>Wr(r).variable(a)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:$r((()=>Wr(r).variable(a)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:$r((()=>Wr(r).variable(a)))});const i=Array.isArray(e)?e[n].tensor:e[t];if(null==i)return;const o=this.accumulatedMeanSquares[n].variable,s=this.accumulatedMoments[n].variable;$r((()=>{const e=Gr(Hr(o,this.decay),Hr(Jr(i),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,a=Gr(Hr(t,this.decay),Hr(i,1-this.decay)),l=qr(Hr(i,this.learningRate),Xr(Zr(e,Gr(Jr(a),this.epsilon)))),u=Gr(Hr(s,this.momentum),l);o.assign(e),t.assign(a),s.assign(u);const c=Zr(r,u);r.assign(c)}else{const e=Gr(Hr(o,this.decay),Hr(Jr(i),1-this.decay)),t=Gr(Hr(s,this.momentum),qr(Hr(i,this.learningRate),Xr(Gr(e,this.epsilon))));o.assign(e),s.assign(t);const n=Zr(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&jr(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&jr(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&jr(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)}},aa];!function(){for(const e of ia)na(e)}();const oa={},sa={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function la(e,t){if(!(e in oa)||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(en().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 oa[e]}),!1),en().getBool("SOFTWARE_WEBGL_ENABLED")&&(sa.failIfMajorPerformanceCaveat=!1);if(1===e)return n.getContext("webgl",sa)||n.getContext("experimental-webgl",sa);return n.getContext("webgl2",sa)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;oa[e]=n}const n=oa[e];return null==n||n.isContextLost()?(delete oa[e],la(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),oa[e])}var ua="https://websdk-cdn-dev.idmission.com/assets";function ca(e){var t=e.width,n=e.height;return e instanceof HTMLVideoElement&&(t=e.videoWidth,n=e.videoHeight),[t,n]}function da(e,t){var n=document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("could not get 2d context");var a=t.box,i=a.width,o=.6*e.height-i,s=Math.max(0,a.xMin-o/2);return Tt()?(n.width=e.width,n.height=e.height,r.drawImage(e,0,0,n.width,n.height)):(n.width=i+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 ha={boxes:0,scores:7,labels:4},fa=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}}),pa="".concat(ua,"/models/documentdetection448/model.json"),ga="".concat(ua,"/models/focus/model.json"),ma=function(e){var t=e.children,r=e.documentDetectionModelUrl,a=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),k=E[0],S=E[1],C=n.useState(0),T=C[0],A=C[1],R=n.useRef(!1),I=n.useRef(),_=n.useRef(null),D=n.useState(0),F=D[0],M=D[1],L=n.useState(0),N=L[0],O=L[1];n.useEffect((function(){l(!1);var e=r||pa,t=a||ga;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([wt(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(a){switch(a.label){case 0:return l(!1),yt=null,Ft=null,delete oa[2],(r=document.createElement("canvas").getContext("webgl2"))&&e&&t?(i.setWebGLContext(2,r),function(){try{f.backend().dispose()}catch(e){console.error("failed to dispose backend",e)}}(),[4,n()]):[3,2];case 1:a.sent(),l(!0),a.label=2;case 2:return[2]}}))}))}n().then((function(){l(!0)}));var s=la(2).canvas;return s.addEventListener("webglcontextlost",o),function(){var e;null===(e=s.removeEventListener)||void 0===e||e.call(s,"webglcontextlost",o)}}),[r,a]);var P=n.useMemo((function(){return{document:d,passport:v,mrz:w,pdf417:k,focus:T}}),[d,T,w,v,k]),B=n.useCallback((function(e){e.document&&h(e.document),e.passport&&y(e.passport),e.mrz&&x(e.mrz),e.pdf417&&S(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 yt&&Ft&&_.current?[4,ya(e,_.current,P)]:[2];case 1:return t=r.sent(),M(t.detectionTime),O(t.focusPredictionTime),$.current<=t.focusScore&&($.current=t.focusScore,va(U.current,e)),null===(n=I.current)||void 0===n||n.call(I,t),R.current=!1,[2]}}))}))}),[P]),G=n.useCallback((function(e){I.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(fa.Provider,{value:H},t,u.default.createElement(Ta,{ref:_}),u.default.createElement(Ta,{ref:U}))};function va(e,t,n,r){if(e){var a=e.getContext("2d");if(a){if(!n||!r){var i=ca(t);n||(n=i[0]),r||(r=i[1])}e.width=n,e.height=r,a.drawImage(t,0,0,n,r)}}}function ya(e,t,n){var r,a,i,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,k,S,C,T,A,R,I,_,D,F,M,L,N,O,P,B,U,$,j;return m(this,(function(m){switch(m.label){case 0:return f=ca(e),p=f[0],g=f[1],va(t,e),[4,ba(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],a=e[1];return{score:t,bbox:[a,r,e[3]-a,e[2]-r],label:xt[n]}}(e,y[t],b[t])}))),E=x.find((function(e){return"Document"===e.label})),k=x.find((function(e){return"Passport Page"===e.label})),S=null!==(r=null==E?void 0:E.score)&&void 0!==r?r:0,C=null!==(a=null==k?void 0:k.score)&&void 0!==a?a:0,T=C>=(null!==(i=n.passport)&&void 0!==i?i:0),A=S>C?E:k,I=(R=T?C:S)>=(null!==(o=n.document)&&void 0!==o?o:0),_=vt.NONE,T?_=vt.PASSPORT:I&&(_=vt.ID_CARD),D=x.find((function(e){return"MRZ"===e.label})),F=null!==(s=null==D?void 0:D.score)&&void 0!==s?s:0,M=F>=(null!==(l=n.mrz)&&void 0!==l?l:0),L=x.find((function(e){return"PDF417"===e.label})),N=null!==(u=null==L?void 0:L.score)&&void 0!==u?u:0,O=N>=(null!==(c=n.pdf417)&&void 0!==c?c:0),P=null,B=0,U=0,$=!1,I?[4,wa(e,null==A?void 0:A.bbox)]:[3,3];case 2:j=m.sent(),B=j[1],U=null!==(d=null==(P=j[0])?void 0:P[1])&&void 0!==d?d:0,$=U>=(null!==(h=n.focus)&&void 0!==h?h:0),m.label=3;case 3:return[2,{detectedObjects:x,detectionScore:R,detectionTime:w,detectionThresholdMet:I,detectedDocumentType:_,passportDetectionScore:C,passportDetectionThresholdMet:T,mrzDetectionScore:F,mrzDetectionThresholdMet:M,pdf417DetectionScore:N,pdf417DetectionThresholdMet:O,bestDocumentOrPassport:A,bestMrz:D,bestPdf417:L,focusScore:U,focusThresholdMet:$,focusPredictionTime:B,frameWidth:p,frameHeight:g}]}}))}))}function ba(e){return g(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,l,u,c,d,h,p,g,v,y,b;return m(this,(function(m){switch(m.label){case 0:if(!yt)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(),a=f.cast(r,"int32"),r.dispose(),s=(o=f).tensor4d,u=(l=Array).from,[4,a.data()];case 2:return i=s.apply(o,[u.apply(l,[m.sent()]),[1,448,448,3]]),a.dispose(),c=f.cast(i,"int32"),i.dispose(),[4,yt.executeAsync(c)];case 3:return d=m.sent(),c.dispose(),[4,(h=d)[ha.boxes].array()];case 4:return p=m.sent()[0],[4,h[ha.scores].array()];case 5:return g=m.sent()[0],[4,h[ha.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 wa(e,t){return g(this,void 0,void 0,(function(){var n,r,a,i,o,s,l,u,c,d,h,p,g;return m(this,(function(m){switch(m.label){case 0:if(!Ft)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 a=ca(e),i=a[0],o=a[1],s=t[0],l=t[1],u=t[2],c=t[3];return n.width=u*i,n.height=c*o,r.drawImage(e,s*i,l*o,u*i,c*o,0,0,u*i,c*o),n}(e,t):e),a=f.image.resizeBilinear(r,[448,448]),r.dispose(),i=f.cast(a,"int32"),a.dispose(),l=(s=f).tensor4d,c=(u=Array).from,[4,i.data()];case 2:return o=l.apply(s,[c.apply(u,[m.sent()]),[1,448,448,3]]),i.dispose(),d=f.cast(o,"int32"),o.dispose(),[4,Ft.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 xa,Ea,ka,Sa,Ca,Ta=h.default.canvas(xa||(xa=y(["\n display: none;\n"],["\n display: none;\n"]))),Aa=h.default.span(Ea||(Ea=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"]))),Ra=h.default.div(ka||(ka=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);":""})),Ia=h.default.div(Sa||(Sa=y(["\n font: 10px monospace;\n position: absolute;\n border: 3px solid ",";\n color: ",";\n ","\n"],["\n font: 10px monospace;\n position: absolute;\n border: 3px solid ",";\n color: ",";\n ","\n"])),(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);":""})),_a=h.default.div(Ca||(Ca=y(["\n position: absolute;\n width: 4px;\n height: 4px;\n border: 2px solid ",";\n font: 10px monospace;\n color: ",";\n border-radius: 50%;\n ","\n"],["\n position: absolute;\n width: 4px;\n height: 4px;\n border: 2px solid ",";\n font: 10px monospace;\n color: ",";\n border-radius: 50%;\n ","\n"])),(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 Da(e){var t=e.enabled,r=void 0===t||t,a=e.pageWidth,i=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=a/i<o/s)?l=((t=o*(i/s))-a)/2:u=((n=s*(a/o))-i)/2),{horizontal:e,pageWidth:a,pageHeight:i,videoWidth:o,videoHeight:s,scaledWidth:t,scaledHeight:n,xOffset:l,yOffset:u}}),[r,i,a,s,o])}function Fa(e){var t=e.obj,n=e.scaling,r=n.horizontal,a=n.pageWidth,i=n.pageHeight,o=n.scaledWidth,s=n.scaledHeight;return u.default.createElement(Ia,{$flipX:e.flipX,style:{top:t.bbox[1]*(r?i:s-n.yOffset),left:t.bbox[0]*(r?o-n.xOffset:a),width:t.bbox[2]*(r?o:a),height:t.bbox[3]*(r?i:s)}},t.label," (",t.score.toFixed(3),")")}function Ma(e){var t,n,r,a,i=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=i.box.yMin/f*d,n=i.box.xMin/h*p-l.xOffset,r=i.box.width/h*p,a=i.box.height/f*d):(t=i.box.yMin/f*g-l.yOffset,n=i.box.xMin/h*c,r=i.box.width/h*c,a=i.box.height/f*g),u.default.createElement(u.default.Fragment,null,u.default.createElement(Ia,{$flipX:o,$color:void 0===s?"green":s,style:{top:t,left:n,width:r,height:a}}),i.keypoints.map((function(e,t){return u.default.createElement(La,{key:t,point:e,scaling:l,flipX:o})})))}function La(e){var t,n,r=e.point,a=e.color,i=e.scaling,o=i.videoWidth,s=i.videoHeight;return i.horizontal?(t=r.x/o*i.scaledWidth-i.xOffset,n=r.y/s*i.pageHeight):(t=r.x/o*i.pageWidth,n=r.y/s*i.scaledHeight-i.yOffset),u.default.createElement(_a,{$flipX:e.flipX,$color:void 0===a?"red":a,style:{top:n-=2,left:t-=2}})}var Na,Oa,Pa,Ba=h.default.button(Na||(Na=y(["\n position: absolute;\n top: 12px;\n right: 12px;\n font-size: 20px;\n width: 32px;\n height: 32px;\n font-family: monospace;\n z-index: 1002;\n border: none;\n border-radius: 4px;\n background: #ccc;\n cursor: pointer;\n\n &:hover {\n background: #ddd;\n }\n"],["\n position: absolute;\n top: 12px;\n right: 12px;\n font-size: 20px;\n width: 32px;\n height: 32px;\n font-family: monospace;\n z-index: 1002;\n border: none;\n border-radius: 4px;\n background: #ccc;\n cursor: pointer;\n\n &:hover {\n background: #ddd;\n }\n"]))),Ua={videoWidth:0,videoHeight:0,captureStartedAt:null,detectedObjects:[],bestDocument:void 0,bestMrz:void 0,bestPdf417:void 0,documentType:vt.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},$a=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,a=n.detectionScore,i=n.detectionThresholdMet,o=n.detectedDocumentType,s=n.passportDetectionScore,l=n.passportDetectionThresholdMet,u=n.mrzDetectionScore,c=n.mrzDetectionThresholdMet,d=n.pdf417DetectionScore,h=n.pdf417DetectionThresholdMet,f=n.bestDocumentOrPassport,g=n.bestMrz,m=n.bestPdf417,v=n.focusScore,y=n.focusThresholdMet,b=n.frameWidth,w=n.frameHeight,x=new Date,E=0,k=e.goodFramesThreshold;e.lastFrameCapturedAt&&(E=1e3/(x.getTime()-e.lastFrameCapturedAt.getTime()))>0&&(k=Math.ceil(3*E));var S=!1;if(f){var C=f.bbox,T=C[0],A=C[1],R=C[2],I=C[3];T*=b,R*=b,S=(A*=w)>5&&A+(I*=w)+5<w&&(T>5||T<5&&T+R>.8*b)&&T+R+5<b}var _=!0===e.autoCaptureBarcodeRequired||"mobile"===e.autoCaptureBarcodeRequired&&Tt(),D=e.barcodeScanningEnabled&&h&&_,F=D&&!e.barcodeResult,M=i&&S&&y,L=e.goodFramesCount;return M&&(L+=1),p(p({},e),{videoWidth:b,videoHeight:w,detectedObjects:r,bestDocument:f,bestMrz:g,bestPdf417:m,documentType:o,documentInBounds:S,documentDetectionScore:a,documentDetectionThresholdMet:i,mrzDetectionScore:u,mrzDetectionThresholdMet:c,pdf417DetectionScore:d,pdf417DetectionThresholdMet:h,passportPageDetectionScore:s,passportPageDetectionThresholdMet:l,focusScore:v,focusThresholdMet:y,shouldScanBarcode:D,waitingForBarcodeScan:F,isGoodFrame:M,goodFramesCount:L,goodFramesThreshold:k,goodFramesThresholdMet:L>=k,lastFrameCapturedAt:x,frameCaptureRate:E});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}},ja=function(e){var t,r,a,i,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,k=e.pdf417DetectionThreshold,S=void 0===k?.15:k,C=e.focusScoreThreshold,T=void 0===C?.3:C,A=e.barcodeScanningEnabled,R=void 0===A||A,I=e.maxBarcodeScanAttempts,_=void 0===I?10:I,D=e.onPrediction,F=e.onBarcodeScanned,M=e.onCapture,L=e.onExit,N=e.processingScreen,O=e.processingDelay,P=void 0===O?0:O,B=e.assets,U=void 0===B?{}:B,$=e.colors,j=void 0===$?{}:$,G=e.verbiage,z=void 0===G?{}:G,q=e.debugMode,H=void 0!==q&&q,V=kt(),W=V.ref,K=V.width,Y=void 0===K?1:K,X=V.height,J=void 0===X?1:X,Z=n.useReducer($a,Ua),Q=Z[0],ee=Z[1],te=n.useState(""),ne=te[0],re=te[1],ae=n.useState(!1),ie=ae[0],oe=ae[1],se=n.useContext(Mt),le=se.cameraRef,ue=se.cameraReady,ce=se.takePhoto,de=se.videoRef,he=se.videoLoaded,fe=ye().t,pe=n.useRef(),ge=n.useContext(fa),me=ge.ready,ve=ge.working,be=ge.setThresholds,we=ge.makePrediction,xe=ge.onPredictionMade,Ee=ge.detectionTime,ke=ge.focusPredictionTime,Se=ge.getBestFrame,Ce=ge.resetBestFrame;n.useEffect((function(){pe.current=new Date}),[]),n.useEffect((function(){ee({type:"configure",payload:{requiredDocumentType:s,goodFramesThreshold:p,autoCaptureBarcodeRequired:y,barcodeScanningEnabled:R,maxBarcodeScanAttempts:_}}),Ce(),be({document:h,passport:E,mrz:w,pdf417:S,focus:T})}),[s,h,T,w,p,y,R,_,E,S,Ce,be]);var Te=n.useRef(0),Ae=n.useRef(!1);n.useEffect((function(){Ae.current=he&&ue&&me&&!Q.capturing&&!Q.captured}),[ue,Q.captured,Q.capturing,me,he]);var Re=n.useState(null),Ie=Re[0],_e=Re[1];n.useEffect((function(){if(me&&ue&&he)return Te.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(!Ae.current||ve.current)return[3,5];r.label=1;case 1:return r.trys.push([1,4,,5]),Q.shouldScanBarcode?[4,ce()]:[3,3];case 2:if(!(t=r.sent()))return Te.current=requestAnimationFrame(e),[2];_e(t),r.label=3;case 3:return de.current&&we(de.current),[3,5];case 4:return n=r.sent(),console.error("error capturing frame",n),[3,5];case 5:return Te.current=requestAnimationFrame(e),[2]}}))}))})),function(){cancelAnimationFrame(Te.current)}}),[ue,we,me,ve,Q.shouldScanBarcode,ce,he,de]),n.useEffect((function(){xe((function(e){ee({type:"objectsDetected",payload:{prediction:e}}),null==D||D(e)}))}),[D,xe]),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 Q.shouldScanBarcode&&Ie?[4,Dt(Ie,null===(t=Q.bestPdf417)||void 0===t?void 0:t.bbox)]:[3,2];case 1:(e=n.sent())?(ee({type:"barcodeScanned",payload:{result:e}}),null==F||F(e)):ee({type:"barcodeScanFailed"}),n.label=2;case 2:return[2]}}))}))}),[F,Q.shouldScanBarcode,null===(t=Q.bestPdf417)||void 0===t?void 0:t.bbox,ce,Ie]);var De=c&&Q.goodFramesThresholdMet&&!Q.capturing&&!Q.captured&&!Q.waitingForBarcodeScan&&Ga(Q.captureStartedAt)>=3e3;n.useEffect((function(){g(void 0,void 0,void 0,(function(){var e,t,n,r,a,i,o,s,l;return m(this,(function(u){switch(u.label){case 0:return De?(ee({type:"capturing"}),[4,Se()]):[2];case 1:return(e=u.sent())?(oe(!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"),ee({type:"captureFailed"}),[2]);case 2:return t=u.sent(),n=t[0],r=t[1],(a=document.createElement("canvas")).width=n,a.height=r,[4,createImageBitmap(e)];case 3:if(i=u.sent(),(n>1920&&r>1080||n>1080&&r>1920)&&Q.barcodeResult){if(n>r?(a.width=1920,a.height=r*(1920/n)):(a.height=1920,a.width=n*(1920/r)),!(o=a.getContext("2d")))return[2];o.drawImage(i,0,0,a.width,a.height)}else{if(!(s=a.getContext("bitmaprenderer")))return[2];s.transferFromImageBitmap(i)}return l=a.toDataURL("image/jpeg",.92),re(l),setTimeout((function(){var e,t=(new Date).getTime()-(null!==(e=pe.current)&&void 0!==e?e:new Date).getTime();null==M||M(l,n,r,{autoCapture:"Y",captureTime:t}),ee({type:"captured"}),oe(!1)}),P),[2]}var c}))}))}),[Se,M,P,De,Q.barcodeResult]);var Fe=Da({enabled:H,pageWidth:Y,pageHeight:J,videoWidth:Q.videoWidth,videoHeight:Q.videoHeight});return ie?N||u.default.createElement("div",null,"Processing..."):""!==ne?u.default.createElement("img",{src:ne,alt:"",style:{maxWidth:"100%",maxHeight:"100%"}}):(j.guideBoxUnsatisfiedColor||(j.guideBoxUnsatisfiedColor="white"),j.guideBoxSatisfiedColor||(j.guideBoxSatisfiedColor="green"),z.instructionText||(z.instructionText=fe("Scan the front of ID")),z.capturingText||(z.capturingText=fe("Capturing...")),z.captureFailedText||(z.captureFailedText=fe("Capture failed!")),u.default.createElement(Ze,{ref:W,className:"flex"},u.default.createElement(At,{width:Y,height:J,instruction:Q.captureFailed?z.captureFailedText:Q.capturing?null==z?void 0:z.capturingText:z.instructionText,portraitGuidesImageUrl:U.portraitGuidesImageUrl,landscapeGuidesImageUrl:U.landscapeGuidesImageUrl,isMirrored:!(null===(r=le.current)||void 0===r?void 0:r.isRearFacing),borderColor:Q.isGoodFrame?j.guideBoxSatisfiedColor:j.guideBoxUnsatisfiedColor}),H&&Q.detectedObjects.length>0&&u.default.createElement(Ra,{$flipX:!(null===(a=le.current)||void 0===a?void 0:a.isRearFacing)},Q.detectedObjects.map((function(e,t){var n;return u.default.createElement(Fa,{key:t,obj:e,scaling:Fe,flipX:!(null===(n=le.current)||void 0===n?void 0:n.isRearFacing)})}))),H&&u.default.createElement(Aa,null,le.current?u.default.createElement(u.default.Fragment,null,"✅ Camera: ",null===(i=le.current)||void 0===i?void 0:i.width,"x",null===(o=le.current)||void 0===o?void 0:o.height):"❌ Camera not ready",u.default.createElement("br",null),Q.frameCaptureRate>.75?"✅":"👎"," Frame Rate:"," ",Math.round(1e3*(Q.frameCaptureRate+Number.EPSILON))/1e3," ","fps (",Ee,"ms doc detect, ",ke,"ms focus)",u.default.createElement("br",null),me?u.default.createElement(u.default.Fragment,null,Q.documentDetectionThresholdMet?"✅":"❌"," Document Score: ",Q.documentDetectionScore," (",Q.documentType,")",u.default.createElement("br",null),Q.documentInBounds?"✅":"❌"," Document In Bounds",u.default.createElement("br",null),Q.focusThresholdMet?"✅":"❌"," Focus Score:"," ",Q.focusScore,u.default.createElement("br",null),Q.goodFramesThresholdMet?"✅":"❌"," Good Frame Count:"," ",Q.goodFramesCount,"/",Q.goodFramesThreshold,R&&Q.autoCaptureBarcodeRequired?u.default.createElement(u.default.Fragment,null,u.default.createElement("br",null),Q.barcodeResult?"✅":"❌"," Barcode Scanned (",_t()?"Native":"ZXing",","," ",Q.barcodeScanFailedAttempts,"/",Q.maxBarcodeScanAttempts," failed attempts)"):null):u.default.createElement(u.default.Fragment,null,"❌ Models not ready")),u.default.createElement(Ba,{onClick:L},"×")))},Ga=function(e){return e?Math.abs((new Date).getTime()-e.getTime()):0},za=function(e){var t=e.accessBlockedImageUrl,r=void 0===t?ua+"/camera-disable-icon.png":t,a=ye().t,i=n.useContext(Mt).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(at,{style:{maxWidth:500,height:"auto",margin:"auto"}},u.default.createElement(it,{style:{flexGrow:0}},u.default.createElement("img",{src:r,alt:a("Camera access blocked")})),u.default.createElement("h3",null,a("Your camera permission is disabled")),u.default.createElement("p",{style:{lineHeight:1.5,marginBottom:50}},a("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(){i()}},u.default.createElement("span",{className:"ladda-label"},a("Retry"))))))},qa=function(e){var t=e.headingText,r=e.useContinuityCameraText,a=e.modelsWarmingUpText,i=e.cameraInitializingText,o=e.cameraAccessBlockedText,s=e.continueText,l=e.instructionImageUrl,c=void 0===l?ua+"/WebSDK-Instruction-DL-Capture-3-Portrait.png":l,d=e.accessBlockedImageUrl,h=void 0===d?ua+"/camera-disable-icon.png":d,f=e.onDismissed,p=ye().t,g=n.useRef(null),m=n.useRef(null),v=n.useContext(fa).ready,y=n.useContext(Mt),b=y.cameraReady,w=y.cameraAccessDenied,x=y.iphoneContinuityCameraAvailable,E=y.setIphoneContinuityCameraAllowed,k=n.useState(!1),S=k[0],C=k[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(){C(!1)}),500);return function(){clearTimeout(t)}}),[b,v]),S?u.default.createElement(u.default.Fragment,null):w?u.default.createElement(za,{accessBlockedImageUrl:h}):(t=t||p("Use your device camera to capture your ID"),r=r||p("Use your iPhone as a webcam"),a=a||p("Models warming up..."),i=i||p("Camera initializing..."),o=o||p("Camera access blocked"),s=s||p("Continue"),u.default.createElement(rt,null,u.default.createElement(at,null,u.default.createElement("h3",null,t),u.default.createElement(it,{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(){C(!0),null==f||f()}},u.default.createElement("span",{className:"ladda-label"},w?o:b&&v?s:v?i:a)))))},Ha=function(e){var t,r=e.instructionText,a=e.frontPortraitGuidesImage,i=e.frontLandscapeGuidesImage,o=e.backPortraitGuidesImage,s=e.backLandscapeGuidesImage,l=ye().t,c=kt(),d=c.ref,h=c.width,f=void 0===h?1:h,g=c.height,m=void 0===g?1:g,v=n.useContext(Mt).cameraRef;r=r||l("Please flip your ID card...");var y=Tt()?0:50,b=!(null===(t=v.current)||void 0===t?void 0:t.isRearFacing),w=n.useContext(St),x=w.orientation,E=w.wrapperRef,k=w.wrapperWidth,S=w.wrapperHeight,C=w.imageAspectRatio,T=w.wrapperAspectRatio,A=w.onImageLoaded,R=w.setDimensions;n.useEffect((function(){R({width:f,height:m})}),[m,R,f]);var I={height:S-2*y-8};C>=T&&(I={width:k-2*y-8});var _=n.useState(1),D=_[0],F=_[1],M=n.useState(0),L=M[0],N=M[1],O=["rotateY(".concat(L,"deg)")];b&&O.push("scaleX(-1)");var P=["rotateY(".concat(180-L,"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?a:i,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"},I)}),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"},I)}))),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)))))},Va=function(e){var t=e.disabled,r=e.onClick,a=e.children,i=n.useRef(null),o=n.useRef(null),s=n.useRef(null);return n.useEffect((function(){if(i.current)return o.current=pt(i.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:i,onClick:r},a)},Wa=function(e){var t=e.capturedDocuments,r=e.onSubmitClick,a=e.onRetryClick,i=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 i=i||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(at,null,u.default.createElement("h1",null,i),u.default.createElement(it,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:a,style:{marginRight:15}},u.default.createElement("span",{className:"ladda-label"},d)),u.default.createElement(Va,{onClick:r,disabled:p===je.SUBMITTING},p===je.SUBMITTING?h:f))))},Ka=function(){var e,t=n.useContext(Mt),r=t.videoRef,a=t.setVideoLoaded,i=t.cameraRef;n.useEffect((function(){a(!1)}),[a]),n.useEffect((function(){var e;r.current&&(null===(e=i.current)||void 0===e?void 0:e.stream)&&(r.current.srcObject=i.current.stream)}),[i,r]);var o=n.useCallback((function(){a(!0)}),[a]);return u.default.createElement(Ya,{autoPlay:!0,playsInline:!0,muted:!0,ref:r,onLoadedData:o,$isRearFacing:null===(e=i.current)||void 0===e?void 0:e.isRearFacing})},Ya=h.default.video(Oa||(Oa=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"}(Pa||(Pa={}));var Xa={captureState:Pa.CAPTURING,capturedDocuments:{},requestedDocumentType:vt.ID_CARD_FRONT,currentDocumentType:vt.NONE,differentDocumentTypeDetections:0,barcodeResult:null},Ja=function(e,t){var n;switch(t.type){case"predictionMade":var r=t.payload.prediction;return(a=p(p({},e),{currentDocumentType:r.detectedDocumentType})).currentDocumentType===e.requestedDocumentType&&(a.differentDocumentTypeDetections=0),"PASSPORT"===r.detectedDocumentType&&"PASSPORT"!==e.requestedDocumentType&&(a.requestedDocumentType=vt.PASSPORT),"PASSPORT"===e.requestedDocumentType&&r.passportDetectionScore<.3&&(a.requestedDocumentType=vt.ID_CARD_FRONT),a;case"barcodeScanned":return p(p({},e),{barcodeResult:t.payload.result});case"imageCaptured":var a=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?a.captureState=Pa.COMPLETE:(console.log("moving back to the front!"),a.requestedDocumentType=vt.ID_CARD_FRONT):(console.log("moving on to back!"),a.requestedDocumentType=vt.ID_CARD_BACK),a;case"reset":return p({},Xa)}},Za=function(e){var t=e.onSuccess,r=e.autoCaptureEnabled,a=void 0===r||r,i=e.autoCaptureGoodFramesRequired,o=void 0===i?3:i,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,k=void 0===E?.3:E,S=e.assets,C=void 0===S?{}:S,T=e.colors,A=void 0===T?{}:T,R=e.verbiage,I=void 0===R?{}:R,_=e.debugMode,D=void 0!==_&&_,F=n.useReducer(Ja,Xa),M=F[0],L=F[1],N=n.useContext(Mt).releaseCameraAccess,O=n.useState(!1),P=O[0],B=O[1],U=n.useContext(qe),$=U.submissionStatus,j=U.submissionResponse,G=U.setIdFrontImage,z=U.setIdBackImage,q=U.setPassportImage,H=U.logIdFrontCaptureAttempt,V=U.logIdBackCaptureAttempt,W=ye().t,K=n.useRef();n.useEffect((function(){K.current=new Date}),[M.capturedDocuments.length]);var Y=n.useCallback((function(e){var t;e.operationTime=(new Date).getTime()-(null!==(t=K.current)&&void 0!==t?t:new Date).getTime(),"ID_CARD_BACK"===M.requestedDocumentType?V(e):H(e)}),[V,H,M.requestedDocumentType]),X=n.useCallback((function(e){L({type:"predictionMade",payload:{prediction:e}})}),[]),J=n.useCallback((function(e){L({type:"barcodeScanned",payload:{result:e}})}),[]),Z=n.useCallback((function(e,t,n,r){Y(r),L({type:"imageCaptured",payload:{imageData:e,width:t,height:n}})}),[Y]),Q=n.useCallback((function(){L({type:"reset"})}),[]),ee=n.useState(0),te=ee[0],ne=ee[1],re=n.useCallback((function(){B(!1),ne((function(e){return e+1})),L({type:"reset"})}),[]);n.useEffect((function(){$!==je.READY&&N()}),[N,$]),C.idCardFrontPortraitGuidesImageUrl||(C.idCardFrontPortraitGuidesImageUrl="".concat(ua,"/Shieldout-IDCard-Front-SVG-Portrait-2.svg")),C.idCardFrontLandscapeGuidesImageUrl||(C.idCardFrontLandscapeGuidesImageUrl="".concat(ua,"/Shieldout-IDCard-Front-SVG-Landscape-2.svg")),C.idCardBackPortraitGuidesImageUrl||(C.idCardBackPortraitGuidesImageUrl="".concat(ua,"/Shieldout-IDCard-Back-SVG-Portrait-2.svg")),C.idCardBackLandscapeGuidesImageUrl||(C.idCardBackLandscapeGuidesImageUrl="".concat(ua,"/Shieldout-IDCard-Back-SVG-Landscape-2.svg")),C.passportPortraitGuidesImageUrl||(C.passportPortraitGuidesImageUrl="".concat(ua,"/Shieldout-Passport-Front-SVG-Portrait-2.svg")),C.passportLandscapeGuidesImageUrl||(C.passportLandscapeGuidesImageUrl="".concat(ua,"/Shieldout-Passport-Front-SVG-Landscape-2.svg")),C.loadingOverlayInstructionImageUrl||(C.loadingOverlayInstructionImageUrl="".concat(ua,"/WebSDK-Instruction-DL-Capture-3-Portrait.png")),I.idCardFrontInstructionText||(I.idCardFrontInstructionText=W("Scan the front of ID")),I.idCardBackInstructionText||(I.idCardBackInstructionText=W("Scan the back of ID")),I.passportInstructionText||(I.passportInstructionText=W("Scan the ID page of passport"));var ae=n.useMemo((function(){return{portraitGuidesImageUrl:C.idCardFrontPortraitGuidesImageUrl,landscapeGuidesImageUrl:C.idCardFrontLandscapeGuidesImageUrl}}),[C.idCardFrontLandscapeGuidesImageUrl,C.idCardFrontPortraitGuidesImageUrl]),ie=n.useMemo((function(){return{instructionText:I.idCardFrontInstructionText,capturingText:I.capturingText,captureFailedText:I.captureFailedText}}),[I.captureFailedText,I.capturingText,I.idCardFrontInstructionText]),oe=n.useMemo((function(){return{portraitGuidesImageUrl:C.idCardBackPortraitGuidesImageUrl,landscapeGuidesImageUrl:C.idCardBackLandscapeGuidesImageUrl}}),[C.idCardBackLandscapeGuidesImageUrl,C.idCardBackPortraitGuidesImageUrl]),se=n.useMemo((function(){return{instructionText:I.idCardBackInstructionText,capturingText:I.capturingText,captureFailedText:I.captureFailedText}}),[I.captureFailedText,I.capturingText,I.idCardBackInstructionText]),le=n.useMemo((function(){return{portraitGuidesImageUrl:C.passportPortraitGuidesImageUrl,landscapeGuidesImageUrl:C.passportLandscapeGuidesImageUrl}}),[C.passportLandscapeGuidesImageUrl,C.passportPortraitGuidesImageUrl]),ue=n.useMemo((function(){return{instructionText:I.passportInstructionText,capturingText:I.capturingText,captureFailedText:I.captureFailedText}}),[I.captureFailedText,I.capturingText,I.passportInstructionText]);if(j)return u.default.createElement(Ze,null,u.default.createElement("h1",null,"Submission completed!"),u.default.createElement("pre",null,JSON.stringify(j,null,2)));var ce=u.default.createElement(Ha,{instructionText:I.flipIdInstructionText,frontPortraitGuidesImage:C.idCardFrontPortraitGuidesImageUrl,frontLandscapeGuidesImage:C.idCardFrontLandscapeGuidesImageUrl,backPortraitGuidesImage:C.idCardBackPortraitGuidesImageUrl,backLandscapeGuidesImage:C.idCardBackLandscapeGuidesImageUrl});return u.default.createElement(Ze,{className:"flex"},M.captureState!==Pa.COMPLETE&&u.default.createElement(Ka,null),P&&function(){switch(M.requestedDocumentType){case vt.ID_CARD_FRONT:return u.default.createElement(ja,{key:Object.keys(M.capturedDocuments).length,requiredDocumentType:M.requestedDocumentType,autoCaptureEnabled:a,autoCaptureScoreThreshold:f,autoCaptureGoodFramesRequired:o,autoCaptureBarcodeRequired:l,barcodeScanningEnabled:!1,mrzDetectionScoreThreshold:b,focusScoreThreshold:x,onPrediction:X,onCapture:Z,onExit:re,processingScreen:ce,processingDelay:3500,assets:ae,colors:A,verbiage:ie,debugMode:D});case vt.ID_CARD_BACK:return u.default.createElement(ja,{key:Object.keys(M.capturedDocuments).length,requiredDocumentType:M.requestedDocumentType,autoCaptureEnabled:a,autoCaptureScoreThreshold:f,autoCaptureGoodFramesRequired:o,autoCaptureBarcodeRequired:l,barcodeScanningEnabled:d,mrzDetectionScoreThreshold:b,focusScoreThreshold:x,onPrediction:X,onBarcodeScanned:J,onCapture:Z,onExit:re,assets:oe,colors:A,verbiage:se,debugMode:D});case vt.PASSPORT:return u.default.createElement(ja,{key:Object.keys(M.capturedDocuments).length,requiredDocumentType:M.requestedDocumentType,autoCaptureEnabled:a,autoCaptureScoreThreshold:v,mrzDetectionScoreThreshold:b,autoCaptureGoodFramesRequired:o,autoCaptureBarcodeRequired:l,barcodeScanningEnabled:!1,focusScoreThreshold:k,onPrediction:X,onBarcodeScanned:J,onCapture:Z,onExit:re,assets:le,colors:A,verbiage:ue,debugMode:D});default:return null}}(),!P&&u.default.createElement(qa,{key:te,headingText:I.loadingOverlayHeadingText,useContinuityCameraText:I.loadingOverlayUseContinuityCameraText,modelsWarmingUpText:I.loadingOverlayModelsWarmingUpText,cameraInitializingText:I.loadingOverlayCameraInitializingText,cameraAccessBlockedText:I.loadingOverlayCameraAccessBlockedText,continueText:I.loadingOverlayContinueText,instructionImageUrl:C.loadingOverlayInstructionImageUrl,onDismissed:function(){B(!0)}}),M.captureState===Pa.COMPLETE&&u.default.createElement(Wa,{capturedDocuments:M.capturedDocuments,barcodeResult:M.barcodeResult,onSubmitClick:function(){return g(void 0,void 0,void 0,(function(){var e,n,r,a,i,o,s,l,u;return m(this,(function(c){switch(c.label){case 0:return n=M.capturedDocuments.ID_CARD_BACK,r=M.capturedDocuments.PASSPORT,(i=e=M.capturedDocuments.ID_CARD_FRONT)?[4,We(e.imageData)]:[3,2];case 1:i=c.sent(),c.label=2;case 2:return a=i,(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,G(a),z(o),q(l),N(),setTimeout((function(){null==t||t({idFrontImage:a,idBackImage:o,passportImage:l})}),0),[2]}}))}))},onRetryClick:Q,headingText:I.successHeadingText,idCardFrontText:I.successIdCardFrontText,idCardBackText:I.successIdCardBackText,passportText:I.successPassportText,instructionText:I.successInstructionText,retryText:I.successRetryText,submittingText:I.successSubmittingText,submitText:I.successSubmitText}))},Qa=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"}}))},ei=self;function ti(e,t){e=e.split(".");var n,r=ei;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 ni(e){return e}function ri(){throw Error("Invalid UTF8")}function ai(e,t){return t=String.fromCharCode.apply(null,t),null==e?t:e+t}let ii,oi;const si="undefined"!=typeof TextDecoder;let li;const ui="undefined"!=typeof TextEncoder;function ci(e){if(ui)e=(li||=new TextEncoder).encode(e);else{let n=0;const r=new Uint8Array(3*e.length);for(let a=0;a<e.length;a++){var t=e.charCodeAt(a);if(128>t)r[n++]=t;else{if(2048>t)r[n++]=t>>6|192;else{if(55296<=t&&57343>=t){if(56319>=t&&a<e.length){const i=e.charCodeAt(++a);if(56320<=i&&57343>=i){r[n++]=(t=1024*(t-55296)+i-56320+65536)>>18|240,r[n++]=t>>12&63|128,r[n++]=t>>6&63|128,r[n++]=63&t|128;continue}a--}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 di,hi;e:{for(var fi=["CLOSURE_FLAGS"],pi=ei,gi=0;gi<fi.length;gi++)if(null==(pi=pi[fi[gi]])){hi=null;break e}hi=pi}var mi,vi=hi&&hi[610401301];di=null!=vi&&vi;const yi=ei.navigator;function bi(e){return!!di&&!!mi&&mi.brands.some((({brand:t})=>t&&-1!=t.indexOf(e)))}function wi(e){var t;return(t=ei.navigator)&&(t=t.userAgent)||(t=""),-1!=t.indexOf(e)}function xi(){return!!di&&!!mi&&0<mi.brands.length}function Ei(){return xi()?bi("Chromium"):(wi("Chrome")||wi("CriOS"))&&!(!xi()&&wi("Edge"))||wi("Silk")}mi=yi&&yi.userAgentData||null;var ki=!xi()&&(wi("Trident")||wi("MSIE"));!wi("Android")||Ei(),Ei(),wi("Safari")&&(Ei()||!xi()&&wi("Coast")||!xi()&&wi("Opera")||!xi()&&wi("Edge")||(xi()?bi("Microsoft Edge"):wi("Edg/"))||xi()&&bi("Opera"));var Si={},Ci=null;function Ti(){if(!Ci){Ci={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=e.concat(t[n].split(""));Si[n]=r;for(var a=0;a<r.length;a++){var i=r[a];void 0===Ci[i]&&(Ci[i]=a)}}}}var Ai="undefined"!=typeof Uint8Array,Ri=!ki&&"function"==typeof btoa;function Ii(e){if(!Ri){var t;void 0===t&&(t=0),Ti(),t=Si[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 a=e[l],i=e[l+1],o=e[l+2],s=t[a>>2];n[u++]=s+(a=t[(3&a)<<4|i>>4])+(i=t[(15&i)<<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 _i=/[-_.]/g,Di={"-":"+",_:"/",".":"="};function Fi(e){return Di[e]||""}function Mi(e){if(!Ri)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),a=0;return function(e,t){function n(t){for(;r<e.length;){var n=e.charAt(r++),a=Ci[n];if(null!=a)return a;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return t}Ti();for(var r=0;;){var a=n(-1),i=n(0),o=n(64),s=n(64);if(64===s&&-1===a)break;t(a<<2|i>>4),64!=o&&(t(i<<4&240|o>>2),64!=s&&t(o<<6&192|s))}}(e,(function(e){r[a++]=e})),a!==n?r.subarray(0,a):r}(e);_i.test(e)&&(e=e.replace(_i,Fi)),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 Li(e){return Ai&&null!=e&&e instanceof Uint8Array}let Ni;function Oi(){return Ni||=new Uint8Array(0)}var Pi={};let Bi;function Ui(e){if(e!==Pi)throw Error("illegal external caller")}function $i(){return Bi||=new Gi(null,Pi)}function ji(e){Ui(Pi);var t=e.L;return null==(t=null==t||Li(t)?t:"string"==typeof t?Mi(t):null)?t:e.L=t}var Gi=class{constructor(e,t){if(Ui(t),this.L=e,null!=e&&0===e.length)throw Error("ByteString should be constructed with non-empty values")}fa(){const e=ji(this);return e?new Uint8Array(e):Oi()}};function zi(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function qi(){return Error("Failed to read varint, encoding is invalid.")}function Hi(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function Vi(e){return 0==e.length?$i():new Gi(e,Pi)}function Wi(e){if("string"==typeof e)return{buffer:Mi(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===Gi)return{buffer:ji(e)||Oi(),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 Ki="function"==typeof Uint8Array.prototype.slice;let Yi,Xi=0,Ji=0;function Zi(e){const t=0>e;let n=(e=Math.abs(e))>>>0;if(e=Math.floor((e-n)/4294967296),t){const[t,r]=ro(n,e);e=r,n=t}Xi=n>>>0,Ji=e>>>0}function Qi(e){const t=Yi||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),Ji=0,Xi=t.getUint32(0,!0)}function eo(e,t){return 4294967296*t+(e>>>0)}function to(e,t){const n=2147483648&t;return n&&(t=~t>>>0,0==(e=1+~e>>>0)&&(t=t+1>>>0)),e=eo(e,t),n?-e:e}function no(e){if(16>e.length)Zi(Number(e));else if("function"==typeof BigInt)e=BigInt(e),Xi=Number(e&BigInt(4294967295))>>>0,Ji=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+("-"===e[0]);Ji=Xi=0;const n=e.length;for(let r=t,a=(n-t)%6+t;a<=n;r=a,a+=6){const t=Number(e.slice(r,a));Ji*=1e6,Xi=1e6*Xi+t,4294967296<=Xi&&(Ji+=Math.trunc(Xi/4294967296),Ji>>>=0,Xi>>>=0)}if(t){const[e,t]=ro(Xi,Ji);Xi=e,Ji=t}}}function ro(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function ao(e,t,{O:n=!1}={}){e.O=n,t&&(t=Wi(t),e.h=t.buffer,e.s=t.G,e.v=0,e.l=e.h.length,e.g=e.v)}function io(e,t){if(e.g=t,t>e.l)throw Hi(e.l,t)}function oo(e,t){let n,r=0,a=0,i=0;const o=e.h;let s=e.g;do{n=o[s++],r|=(127&n)<<i,i+=7}while(32>i&&128&n);for(32<i&&(a|=(127&n)>>4),i=3;32>i&&128&n;i+=7)n=o[s++],a|=(127&n)<<i;if(io(e,s),128>n)return t(r>>>0,a>>>0);throw qi()}function so(e){let t=0,n=e.g;const r=n+10,a=e.h;for(;n<r;){const r=a[n++];if(t|=r,0==(128&r))return io(e,n),!!(127&t)}throw qi()}function lo(e){var t=e.h;const n=e.g,r=t[n],a=t[n+1],i=t[n+2];return t=t[n+3],io(e,e.g+4),(r<<0|a<<8|i<<16|t<<24)>>>0}function uo(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 Hi(t,e.l-n);return e.g=r,n}function co(e,t){if(0==t)return $i();var n=uo(e,t);return e.O&&e.s?n=e.h.subarray(n,n+t):(e=e.h,n=n===(t=n+t)?Oi():Ki?e.slice(n,t):new Uint8Array(e.subarray(n,t))),Vi(n)}var ho=class{constructor(e,t){this.h=null,this.s=!1,this.g=this.l=this.v=0,ao(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 qi();return io(this,t),r}j(){return this.m()>>>0}A(){var e=lo(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()}},fo=[];function po(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 zi(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 go(e){switch(e.h){case 0:0!=e.h?go(e):so(e.g);break;case 1:io(e=e.g,e.g+8);break;case 2:if(2!=e.h)go(e);else{var t=e.g.j();io(e=e.g,e.g+t)}break;case 5:io(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!po(e))throw Error("Unmatched start-group tag: stream EOF");if(4==e.h){if(e.m!=t)throw Error("Unmatched end-group tag");break}go(e)}break;default:throw zi(e.h,e.l)}}function mo(e,t,n){const r=e.g.l,a=e.g.j(),i=e.g.g+a;let o=i-r;if(0>=o&&(e.g.l=i,n(t,e,void 0,void 0,void 0),o=i-e.g.g),o)throw Error(`Message parsing ended unexpectedly. Expected to read ${a} bytes, instead read ${a-o} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=i,e.g.l=r,t}function vo(e){var t=e.g.j(),n=uo(e=e.g,t);if(e=e.h,si){var r,a=e;(r=oi)||(r=oi=new TextDecoder("utf-8",{fatal:!0})),e=n+t,a=0===n&&e===a.length?a:a.subarray(n,e);try{var i=r.decode(a)}catch(e){if(void 0===ii){try{r.decode(new Uint8Array([128]))}catch(e){}try{r.decode(new Uint8Array([97])),ii=!0}catch(e){ii=!1}}throw!ii&&(oi=void 0),e}}else{t=(i=n)+t,n=[];let s,l=null;for(;i<t;){var o=e[i++];128>o?n.push(o):224>o?i>=t?ri():(s=e[i++],194>o||128!=(192&s)?(i--,ri()):n.push((31&o)<<6|63&s)):240>o?i>=t-1?ri():(s=e[i++],128!=(192&s)||224===o&&160>s||237===o&&160<=s||128!=(192&(a=e[i++]))?(i--,ri()):n.push((15&o)<<12|(63&s)<<6|63&a)):244>=o?i>=t-2?ri():(s=e[i++],128!=(192&s)||0!=s-144+(o<<28)>>30||128!=(192&(a=e[i++]))||128!=(192&(r=e[i++]))?(i--,ri()):(o=(7&o)<<18|(63&s)<<12|(63&a)<<6|63&r,n.push(55296+((o-=65536)>>10&1023),56320+(1023&o)))):ri(),8192<=n.length&&(l=ai(l,n),n.length=0)}i=ai(l,n)}return i}function yo(e){const t=e.g.j();return co(e.g,t)}function bo(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 wo=[];function xo(e){return e?/^\d+$/.test(e)?(no(e),new Eo(Xi,Ji)):null:ko||=new Eo(0,0)}var Eo=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let ko;function So(e){return e?/^-?\d+$/.test(e)?(no(e),new Co(Xi,Ji)):null:To||=new Co(0,0)}var Co=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let To;function Ao(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 Ro(e,t){for(;127<t;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function Io(e,t){if(0<=t)Ro(e,t);else{for(let n=0;9>n;n++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function _o(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 Do(e,t){0!==t.length&&(e.l.push(t),e.h+=t.length)}function Fo(e,t,n){Ro(e.g,8*t+n)}function Mo(e,t){return Fo(e,t,2),t=e.g.end(),Do(e,t),t.push(e.h),t}function Lo(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 No(e,t,n){Fo(e,t,2),Ro(e.g,n.length),Do(e,e.g.end()),Do(e,n)}function Oo(e,t,n,r){null!=n&&(t=Mo(e,t),r(n,e),Lo(e,t))}class Po{constructor(e,t,n){this.g=e,this.h=t,this.l=n}}function Bo(e){return Array.prototype.slice.call(e)}const Uo="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():void 0;var $o=Uo?(e,t)=>{e[Uo]|=t}:(e,t)=>{void 0!==e.g?e.g|=t:Object.defineProperties(e,{g:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function jo(e){const t=zo(e);1!=(1&t)&&(Object.isFrozen(e)&&(e=Bo(e)),Ho(e,1|t))}var Go=Uo?(e,t)=>{e[Uo]&=~t}:(e,t)=>{void 0!==e.g&&(e.g&=~t)},zo=Uo?e=>0|e[Uo]:e=>0|e.g,qo=Uo?e=>e[Uo]:e=>e.g,Ho=Uo?(e,t)=>{e[Uo]=t}:(e,t)=>{void 0!==e.g?e.g=t:Object.defineProperties(e,{g:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function Vo(e){return $o(e,1),e}function Wo(e){return $o(e,34),e}function Ko(e,t){Ho(t,-255&(0|e))}function Yo(e,t){Ho(t,-221&(34|e))}function Xo(e){return 0==(e=e>>11&1023)?536870912:e}var Jo,Zo={};function Qo(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&e.constructor===Object}function es(e,t,n){if(null!=e)if("string"==typeof e)e=e?new Gi(e,Pi):$i();else if(e.constructor!==Gi)if(Li(e))e=n?Vi(e):e.length?new Gi(new Uint8Array(e),Pi):$i();else{if(!t)throw Error();e=void 0}return e}const ts=[];function ns(e){if(2&e)throw Error()}Ho(ts,39),Jo=Object.freeze(ts);class rs{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 rs(this.g,this.h,this.m)}}var as={};let is,os;function ss(e,t){(t=is?t[is]:void 0)&&(e[is]=Bo(t))}function ls(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function us(e){return null==e?e:"number"==typeof e||"NaN"===e||"Infinity"===e||"-Infinity"===e?Number(e):void 0}function cs(e){return null==e?e:"boolean"==typeof e||"number"==typeof e?!!e:void 0}function ds(e){return"number"==typeof e&&Number.isFinite(e)||!!e&&"string"==typeof e&&isFinite(e)}function hs(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function fs(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function ps(e){if("string"!=typeof e)throw Error();return e}function gs(e){if(null!=e&&"string"!=typeof e)throw Error();return e}function ms(e){return null==e||"string"==typeof e?e:void 0}function vs(e,t,n,r){var a=!1;return null==e||"object"!=typeof e||(a=Array.isArray(e))||e.K!==Zo?a?(0===(a=n=zo(e))&&(a|=32&r),(a|=2&r)!==n&&Ho(e,a),new t(e)):(n?2&r?(e=t[ys])?t=e:(Wo((e=new t).u),t=t[ys]=e):t=new t:t=void 0,t):e}const ys="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():"di";function bs(e){return e}function ws(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 xs,Es;function ks(e){switch(typeof e){case"number":return 0<e?void 0:0===e?Es||=[0,void 0]:[-e,void 0];case"string":return[0,e];case"object":return e}}function Ss(e,t){return Cs(e,t[0],t[1])}function Cs(e,t,n){if(null==e&&(e=xs),xs=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=zo(e)))return os&&delete e[os],e;if(r|=64,n&&(r|=512,n!==e[0]))throw Error();e:{var a=(n=e).length;if(a){const e=a-1;var i=n[e];if(Qo(i)){1024<=(a=e-(t=+!!(512&(r|=256))-1))&&(Ts(n,t,i),a=1023),r=-2095105&r|(1023&a)<<11;break e}}t&&(i=+!!(512&r)-1,1024<(t=Math.max(t,a-i))&&(Ts(n,i,{}),r|=256,t=1023),r=-2095105&r|(1023&t)<<11)}}return Ho(e,r),e}function Ts(e,t,n){const r=1023+t,a=e.length;for(let i=r;i<a;i++){const r=e[i];null!=r&&r!==n&&(n[i-t]=r)}e.length=r+1,e[r]=n}function As(e){if(2&e.g)throw Error("Cannot mutate an immutable Map")}var Rs=class extends Map{constructor(e,t,n=bs,r=bs){super();let a=zo(e);a|=64,Ho(e,a),this.g=a,this.l=t,this.h=n||bs,this.j=this.l?Is:r||bs;for(let i=0;i<e.length;i++){const o=e[i],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,a),super.set(s,l)}}s(e=_s){return this.m(e)}m(e=_s){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(){As(this),super.clear()}delete(e){return As(this),super.delete(this.h(e,!0,!1))}entries(){var e=this.A();return new rs(e,Ds,this)}keys(){return this.C()}values(){var e=this.A();return new rs(e,Rs.prototype.get,this)}forEach(e,t){super.forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))}set(e,t){return As(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 Is(e,t,n,r,a,i){return e=vs(e,r,n,i),a&&(e=Us(e)),e}function _s(e){return e}function Ds(e){return[e,this.get(e)]}function Fs(e,t,n,r,a,i){if(null!=e){if(Array.isArray(e))e=a&&0==e.length&&1&zo(e)?void 0:i&&2&zo(e)?e:Ms(e,t,n,void 0!==r,a,i);else if(Qo(e)){const o={};for(let s in e)o[s]=Fs(e[s],t,n,r,a,i);e=o}else e=t(e,r);return e}}function Ms(e,t,n,r,a,i){const o=r||n?zo(e):0;r=r?!!(32&o):void 0;const s=Bo(e);for(let e=0;e<s.length;e++)s[e]=Fs(s[e],t,n,r,a,i);return n&&(ss(s,e),n(o,s)),s}function Ls(e){return Fs(e,Ns,void 0,void 0,!1,!1)}function Ns(e){return e.K===Zo?e.toJSON():e instanceof Rs?e.s(Ls):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(Li(e))return Ii(e);if(e instanceof Gi){const t=e.L;return null==t?"":"string"==typeof t?t:e.L=Ii(t)}if(e instanceof Rs)return e.s()}}return e}(e)}function Os(e,t,n=Yo){if(null!=e){if(Ai&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){const r=zo(e);return 2&r?e:!t||68&r||!(32&r||0===r)?Ms(e,Os,4&r?Yo:n,!0,!1,!0):(Ho(e,34|r),e)}return e.K===Zo?e=2&(n=qo(t=e.u))?e:Ps(e,t,n,!0):e instanceof Rs&&(t=Wo(e.m(Os)),e=new Rs(t,e.l,e.h,e.j)),e}}function Ps(e,t,n,r){return e=e.constructor,xs=t=Bs(t,n,r),t=new e(t),xs=void 0,t}function Bs(e,t,n){const r=n||2&t?Yo:Ko,a=!!(32&t);return e=function(e,t,n){const r=Bo(e);var a=r.length;const i=256&t?r[a-1]:void 0;for(a+=i?-1:0,t=512&t?1:0;t<a;t++)r[t]=n(r[t]);if(i){t=r[t]={};for(const e in i)t[e]=n(i[e])}return ss(r,e),r}(e,t,(e=>Os(e,a,r))),$o(e,32|(n?2:0)),e}function Us(e){const t=e.u,n=qo(t);return 2&n?Ps(e,t,n,!1):e}function $s(e,t){return js(e=e.u,qo(e),t)}function js(e,t,n,r){if(-1===n)return null;if(n>=Xo(t)){if(256&t)return e[e.length-1][n]}else{var a=e.length;if(r&&256&t&&null!=(r=e[a-1][n]))return r;if((t=n+(+!!(512&t)-1))<a)return e[t]}}function Gs(e,t,n,r){const a=e.u,i=qo(a);return ns(i),zs(a,i,t,n,r),e}function zs(e,t,n,r,a){var i=Xo(t);if(n>=i||a){if(a=t,256&t)i=e[e.length-1];else{if(null==r)return;i=e[i+(+!!(512&t)-1)]={},a|=256}i[n]=r,a!==t&&Ho(e,a)}else e[n+(+!!(512&t)-1)]=r,256&t&&n in(e=e[e.length-1])&&delete e[n]}function qs(e,t,n,r,a){var i=2&t;let o=js(e,t,n,a);Array.isArray(o)||(o=Jo);const s=zo(o);if(1&s||Vo(o),i)2&s||Wo(o),1&r||Object.freeze(o);else{i=!(2&r);const l=2&s;1&r||!l?i&&32&s&&!l&&Go(o,32):(o=Vo(Bo(o)),zs(e,t,n,o,a))}return o}function Hs(e,t){const n=qo(e=e.u),r=js(e,n,t),a=us(r);return null!=a&&a!==r&&zs(e,n,t,a),a}function Vs(e){const t=qo(e=e.u),n=js(e,t,1),r=es(n,!0,!!(34&t));return null!=r&&r!==n&&zs(e,t,1,r),r}function Ws(e,t,n){const r=qo(e=e.u),a=2&r;let i=qs(e,r,t,1),o=zo(i);if(!(4&o)){Object.isFrozen(i)&&(o=0,i=Bo(i),zs(e,r,t,i));let s=0,l=0;for(;s<i.length;s++){const e=n(i[s]);null!=e&&(i[l++]=e)}l<s&&(i.length=l),o|=5,a&&(o|=34),Ho(i,o),2&o&&Object.freeze(i)}return!a&&(2&o||Object.isFrozen(i))&&(i=Bo(i),$o(i,5),zs(e,r,t,i)),i}let Ks;function Ys(){return Ks??=new Rs(Wo([]),void 0,void 0,void 0,as)}function Xs(e){e=Bo(e);for(let t=0;t<e.length;t++){const n=e[t]=Bo(e[t]);Array.isArray(n[1])&&(n[1]=Wo(n[1]))}return e}function Js(e,t,n){{const r=qo(e=e.u);if(ns(r),null==n)zs(e,r,t);else{if(!(4&zo(n))){Object.isFrozen(n)&&(n=Bo(n));for(let e=0;e<n.length;e++)n[e]=ps(n[e]);Ho(n,5)}zs(e,r,t,n)}}}function Zs(e,t){return Qs(e=e.u,qo(e),Uc)===t?t:-1}function Qs(e,t,n){let r=0;for(let a=0;a<n.length;a++){const i=n[a];null!=js(e,t,i)&&(0!==r&&zs(e,t,r),r=i)}return r}function el(e,t,n,r){const a=qo(e);ns(a);const i=js(e,a,n,r);let o;if(null!=i&&i.K===Zo)return(t=Us(i))!==i&&zs(e,a,n,t,r),t.u;if(Array.isArray(i)){const e=zo(i);o=2&e?Bs(i,e,!1):i,o=Ss(o,t)}else o=Ss(void 0,t);return o!==i&&zs(e,a,n,o,r),o}function tl(e,t,n,r){const a=qo(e=e.u),i=js(e,a,n,r);return(t=vs(i,t,!1,a))!==i&&null!=t&&zs(e,a,n,t,r),t}function nl(e,t,n,r=!1){if(null==(t=tl(e,t,n,r)))return t;const a=qo(e=e.u);if(!(2&a)){const i=Us(t);i!==t&&zs(e,a,n,t=i,r)}return t}function rl(e,t,n,r,a){var i=!!(2&t),o=qs(e,t,r,1);if(o===Jo||!(4&zo(o))){var s=o;o=!!(2&t);var l=!!(2&zo(s));i=s,!o&&l&&(s=Bo(s));var u=t|(l?2:0);l=l||void 0;let c=0,d=0;for(;c<s.length;c++){const e=vs(s[c],n,!1,u);void 0!==e&&(l=l||2&qo(e.u),s[d++]=e)}return d<c&&(s.length=d),u=5|(s=zo(n=s)),s!=(l=l?-9&u:8|u)&&(Object.isFrozen(n)&&(n=Bo(n)),Ho(n,l)),i!==(s=n)&&zs(e,t,r,s),(o&&2!==a||1===a)&&Object.freeze(s),s}return 3===a||(i?2===a&&(a=zo(o),o=Bo(o),Ho(o,a),zs(e,t,r,o)):(i=Object.isFrozen(o),1===a?i||Object.freeze(o):(n=-35&(a=zo(o)),i&&(a=0,zs(e,t,r,o=Bo(o))),a!==n&&Ho(o,n)))),o}function al(e,t,n){var r=e.u;const a=qo(r);if(t=rl(r,a,t,n,(e=!!(2&a))?1:2),!(e||8&zo(t))){for(n=0;n<t.length;n++)(e=t[n])!==(r=Us(e))&&(t[n]=r);$o(t,8)}return t}function il(e,t,n,r,a){return null==r&&(r=void 0),Gs(e,n,r,a)}function ol(e,t,n,r){null==r&&(r=void 0);const a=qo(e=e.u);ns(a),(n=Qs(e,a,n))&&n!==t&&null!=r&&zs(e,a,n),zs(e,a,t,r)}function sl(e,t,n){const r=qo(e=e.u);ns(r),e=rl(e,r,t,1,2),t=null!=n?n:new t,e.push(t),t.G()&&Go(e,8)}function ll(e,t){return hs($s(e,t))}function ul(e){return null==(e=$s(e,2))||ds(e)?e:void 0}function cl(e,t){return ms($s(e,t))}function dl(e){return e??0}function hl(e,t){return dl(Hs(e,t))}function fl(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}Gs(e,t,n)}function pl(e,t,n){if(null!=n){if("number"!=typeof n)throw ls(e=Error(),"warning"),e;if(!Number.isFinite(n)){const e=Error();ls(e,"incident"),function(e){ei.setTimeout((()=>{throw e}),0)}(e)}}Gs(e,t,n)}function gl(e,t,n){if(null!=n&&"number"!=typeof n)throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);Gs(e,t,n)}function ml(e,t,n){n=ps(n);const r=qo(e=e.u);ns(r),qs(e,r,t,2).push(n)}function vl(e,t,n){t.g?t.m(e,t.g,t.h,n,!0):t.m(e,t.h,n,!0)}Rs.prototype.toJSON=void 0;var yl=class{constructor(e,t){this.u=Cs(e,t)}toJSON(){return bl(this,Ms(this.u,Ns,void 0,void 0,!1,!1),!0)}l(){var e=Nd;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 Ps(this,e,qo(e),!1)}G(){return!!(2&zo(this.u))}};function bl(e,t,n){var r=e.constructor.B,a=Xo(qo(n?e.u:t)),i=!1;if(r){if(!n){var o;if((t=Bo(t)).length&&Qo(o=t[t.length-1]))for(i=0;i<r.length;i++)if(r[i]>=a){Object.assign(t[t.length-1]={},o);break}i=!0}var s;a=t,n=!n,e=Xo(o=qo(e.u)),o=+!!(512&o)-1;for(let t=0;t<r.length;t++){var l=r[t];if(l<e){var u=a[l+=o];null==u?a[l]=n?Jo:Vo([]):n&&u!==Jo&&jo(u)}else{if(!s){var c=void 0;a.length&&Qo(c=a[a.length-1])?s=c:a.push(s={})}u=s[l],null==s[l]?s[l]=n?Jo:Vo([]):n&&u!==Jo&&jo(u)}}}if(!(r=t.length))return t;let d,h;if(Qo(s=t[r-1])){e:{var f=s;c={},a=!1;for(let e in f)n=f[e],Array.isArray(n)&&n!=n&&(a=!0),null!=n?c[e]=n:a=!0;if(a){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=i?t:Array.prototype.slice.call(t,0,r),i&&(t.length=r),f&&t.push(f),t):t}function wl(e){return{aa:cu,S:e}}function xl(e,t){if(Array.isArray(t)){var n=zo(t);if(4&n)return t;for(var r=0,a=0;r<t.length;r++){const n=e(t[r]);null!=n&&(t[a++]=n)}return a<r&&(t.length=a),Ho(t,5|n),2&n&&Object.freeze(t),t}}yl.prototype.K=Zo,yl.prototype.toString=function(){return bl(this,this.u,!1).toString()};const El=Symbol();function kl(e){let t=e[El];if(!t){const n=Nl(e),r=n.m;t=r?(e,t)=>r(e,t,n):(e,t)=>{for(;po(t)&&4!=t.h;){var r=t.m,a=n[r];if(!a){var i=n.h;i&&(i=i[r])&&(a=n[r]=Sl(i))}a&&a(t,e,r)||(r=(a=t).l,go(a),a.Y?a=void 0:(i=a.g.g-r,a.g.g=r,a=co(a.g,i)),r=e,a&&(is||=Symbol(),(i=r[is])?i.push(a):r[is]=[a]))}(t=n.l)&&(e[os||=Symbol()]=t)},e[El]=t}return t}function Sl(e){const t=function(e){if(e=e.S)return kl(e)}(e),n=e.aa.g;if(t){const r=Nl(e.S).g;return(e,a,i)=>n(e,a,i,r,t)}return(e,t,r)=>n(e,t,r)}function Cl(e,t,n,r){t.g=ks(e[0]);let a=1;if(e.length>a&&!(e[a]instanceof Po)){var i=e[a++];if(Array.isArray(i))return t.m=i[0],t.h=i[1],t;t.h=i}for(i=0;a<e.length;){const c=e[a++];var o=e[a];for("number"==typeof o?(a++,i+=o):i++,c.l&&((o=t.l)||(t.l=o=[]),o.push(i)),o=a;o<e.length&&!(e[o]instanceof Po);)o++;if(o-=a){var s=e,l=a,u=s[l];if("function"==typeof u&&(u=u(),s[l]=u),(s=Array.isArray(u))&&!(s=Fl in u||Rl in u)&&(s=0<u.length)){const e=ks(l=(s=u)[0]);null!=e&&e!==l&&(s[0]=e),s=null!=e}(u=s?u:void 0)?(a++,t[i]=1===o?r(c,u):r(c,u,e[a++])):t[i]=n(c,e[a++])}else t[i]=n(c)}return t}const Tl=Symbol();function Al(e){let t=e[Tl];if(!t){const n=Dl(e);t=(e,t)=>Pl(e,t,n),e[Tl]=t}return t}const Rl=Symbol();function Il(e){return e.h}function _l(e,t){let n,r;const a=e.h;return(e,i,o)=>a(e,i,o,r||=Dl(t).g,n||=Al(t))}function Dl(e){let t=e[Rl];return t||(t=Cl(e,e[Rl]={},Il,_l),Fl in e&&Rl in e&&(e.length=0),t)}const Fl=Symbol();function Ml(e,t){const n=e.g;return t?(e,r,a)=>n(e,r,a,t):n}function Ll(e,t,n){const r=e.g;let a,i;return(e,o,s)=>r(e,o,s,i||=Nl(t).g,a||=kl(t),n)}function Nl(e){let t=e[Fl];return t||(t=Cl(e,e[Fl]={},Ml,Ll),Fl in e&&Rl in e&&(e.length=0),t)}function Ol(e,t){var n=e[t];if(n)return n;if((n=e.h)&&(n=n[t])){var r=n.S,a=n.aa.h;if(r){const e=Al(r),t=Dl(r).g;n=(n,r,i)=>a(n,r,i,t,e)}else n=a;return e[t]=n}}function Pl(e,t,n){for(var r=qo(e),a=+!!(512&r)-1,i=e.length,o=512&r?1:0,s=i+(256&r?-1:0);o<s;o++){const r=e[o];if(null==r)continue;const i=o-a,s=Ol(n,i);s&&s(t,r,i)}if(256&r){r=e[i-1];for(let e in r)a=+e,Number.isNaN(a)||null!=(i=r[e])&&(s=Ol(n,a))&&s(t,i,a)}if(e=is?e[is]:void 0)for(Do(t,t.g.end()),n=0;n<e.length;n++)Do(t,ji(e[n])||Oi())}function Bl(e,t){return new Po(e,t,!1)}function Ul(e,t){return new Po(e,t,!0)}function $l(e,t,n){zs(e,qo(e),t,n)}var jl=Bl((function(e,t,n,r,a){return 2===e.h&&(e=mo(e,Ss([void 0,void 0],r),a),ns(r=qo(t)),(a=js(t,r,n))instanceof Rs?0!=(2&a.g)?((a=a.m()).push(e),zs(t,r,n,a)):a.H(e):Array.isArray(a)?(2&zo(a)&&zs(t,r,n,a=Xs(a)),a.push(e)):zs(t,r,n,[e]),!0)}),(function(e,t,n,r,a){if(t instanceof Rs)t.forEach(((t,i)=>{Oo(e,n,Ss([i,t],r),a)}));else if(Array.isArray(t))for(let i=0;i<t.length;i++){const o=t[i];Array.isArray(o)&&Oo(e,n,Ss(o,r),a)}}));function Gl(e,t,n){e:if(null!=t){if(ds(t)){if("string"==typeof t)break e;if("number"==typeof t)break e}t=void 0}null!=t&&("string"==typeof t&&So(t),null!=t&&(Fo(e,n,0),"number"==typeof t?(e=e.g,Zi(t),Ao(e,Xi,Ji)):(n=So(t),Ao(e.g,n.h,n.g))))}function zl(e,t,n){null!=(t=hs(t))&&null!=t&&(Fo(e,n,0),Io(e.g,t))}function ql(e,t,n){null!=(t=cs(t))&&(Fo(e,n,0),e.g.g.push(t?1:0))}function Hl(e,t,n){null!=(t=ms(t))&&No(e,n,ci(t))}function Vl(e,t,n,r,a){Oo(e,n,t instanceof yl?t.u:Array.isArray(t)?Ss(t,r):void 0,a)}function Wl(e,t,n){null!=(t=null==t||"string"==typeof t||Li(t)||t instanceof Gi?t:void 0)&&No(e,n,Wi(t).buffer)}function Kl(e,t,n){return(5===e.h||2===e.h)&&(t=qs(t,qo(t),n,2,!1),2==e.h?bo(e,ho.prototype.A,t):t.push(e.g.A()),!0)}var Yl=Bl((function(e,t,n){if(1!==e.h)return!1;var r=e.g;e=lo(r);const a=lo(r);r=2*(a>>31)+1;const i=a>>>20&2047;return e=4294967296*(1048575&a)+e,$l(t,n,2047==i?e?NaN:1/0*r:0==i?r*Math.pow(2,-1074)*e:r*Math.pow(2,i-1075)*(e+4503599627370496)),!0}),(function(e,t,n){null!=(t=us(t))&&(Fo(e,n,1),e=e.g,(n=Yi||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),Xi=n.getUint32(0,!0),Ji=n.getUint32(4,!0),_o(e,Xi),_o(e,Ji))})),Xl=Bl((function(e,t,n){return 5===e.h&&($l(t,n,e.g.A()),!0)}),(function(e,t,n){null!=(t=us(t))&&(Fo(e,n,5),e=e.g,Qi(t),_o(e,Xi))})),Jl=Ul(Kl,(function(e,t,n){if(null!=(t=xl(us,t)))for(let i=0;i<t.length;i++){var r=e,a=t[i];null!=a&&(Fo(r,n,5),r=r.g,Qi(a),_o(r,Xi))}})),Zl=Ul(Kl,(function(e,t,n){if(null!=(t=xl(us,t))&&t.length){Fo(e,n,2),Ro(e.g,4*t.length);for(let r=0;r<t.length;r++)n=e.g,Qi(t[r]),_o(n,Xi)}})),Ql=Bl((function(e,t,n){return 0===e.h&&($l(t,n,oo(e.g,to)),!0)}),Gl),eu=Bl((function(e,t,n){return 0===e.h&&($l(t,n,0===(e=oo(e.g,to))?void 0:e),!0)}),Gl),tu=Bl((function(e,t,n){return 0===e.h&&($l(t,n,oo(e.g,eo)),!0)}),(function(e,t,n){e:if(null!=t){if(ds(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&&(Fo(e,n,0),"number"==typeof t?(e=e.g,Zi(t),Ao(e,Xi,Ji)):(n=xo(t),Ao(e.g,n.h,n.g))))})),nu=Bl((function(e,t,n){return 0===e.h&&($l(t,n,e.g.m()),!0)}),zl),ru=Ul((function(e,t,n){return(0===e.h||2===e.h)&&(t=qs(t,qo(t),n,2,!1),2==e.h?bo(e,ho.prototype.m,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=xl(hs,t))&&t.length){n=Mo(e,n);for(let n=0;n<t.length;n++)Io(e.g,t[n]);Lo(e,n)}})),au=Bl((function(e,t,n){return 0===e.h&&($l(t,n,0===(e=e.g.m())?void 0:e),!0)}),zl),iu=Bl((function(e,t,n){return 0===e.h&&($l(t,n,so(e.g)),!0)}),ql),ou=Bl((function(e,t,n){return 0===e.h&&($l(t,n,!1===(e=so(e.g))?void 0:e),!0)}),ql),su=Ul((function(e,t,n){if(2!==e.h)return!1;e=vo(e);const r=qo(t);return ns(r),qs(t,r,n,2).push(e),!0}),(function(e,t,n){if(null!=(t=xl(ms,t)))for(let a=0;a<t.length;a++){var r=t[a];null!=r&&No(e,n,ci(r))}})),lu=Bl((function(e,t,n){return 2===e.h&&($l(t,n,""===(e=vo(e))?void 0:e),!0)}),Hl),uu=Bl((function(e,t,n){return 2===e.h&&($l(t,n,vo(e)),!0)}),Hl),cu=Bl((function(e,t,n,r,a){return 2===e.h&&(mo(e,el(t,r,n,!0),a),!0)}),Vl),du=Bl((function(e,t,n,r,a){return 2===e.h&&(mo(e,el(t,r,n),a),!0)}),Vl),hu=Ul((function(e,t,n,r,a){if(2!==e.h)return!1;r=Ss(void 0,r);const i=qo(t);ns(i);let o=qs(t,i,n,3);return(Object.isFrozen(o)||4&zo(o))&&(o=Bo(o),zs(t,i,n,o)),o.push(r),mo(e,r,a),!0}),(function(e,t,n,r,a){if(Array.isArray(t))for(let i=0;i<t.length;i++)Vl(e,t[i],n,r,a)})),fu=Bl((function(e,t,n,r,a,i){if(2!==e.h)return!1;const o=qo(t);return ns(o),(i=Qs(t,o,i))&&n!==i&&zs(t,o,i),mo(e,t=el(t,r,n),a),!0}),Vl),pu=Bl((function(e,t,n){return 2===e.h&&($l(t,n,yo(e)),!0)}),Wl),gu=Ul((function(e,t,n){return(0===e.h||2===e.h)&&(t=qs(t,qo(t),n,2,!1),2==e.h?bo(e,ho.prototype.j,t):t.push(e.g.j()),!0)}),(function(e,t,n){if(null!=(t=xl(fs,t)))for(let i=0;i<t.length;i++){var r=e,a=t[i];null!=a&&(Fo(r,n,0),Ro(r.g,a))}})),mu=Bl((function(e,t,n){return 0===e.h&&($l(t,n,e.g.m()),!0)}),(function(e,t,n){null!=(t=hs(t))&&(t=parseInt(t,10),Fo(e,n,0),Io(e.g,t))})),vu=Ul((function(e,t,n){return(0===e.h||2===e.h)&&(t=qs(t,qo(t),n,2,!1),2==e.h?bo(e,ho.prototype.C,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=xl(hs,t))&&t.length){n=Mo(e,n);for(let n=0;n<t.length;n++)Io(e.g,t[n]);Lo(e,n)}}));class yu{constructor(e,t){this.h=e,this.g=t,this.l=nl,this.m=il,this.defaultValue=void 0}}function bu(e,t){return new yu(e,t)}function wu(e,t){return(n,r)=>{e:{if(wo.length){const e=wo.pop();e.o(r),ao(e.g,n,r),n=e}else n=new class{constructor(e,t){if(fo.length){const n=fo.pop();ao(n,e,t),e=n}else e=new ho(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 a=new e;const r=a.u;kl(t)(r,n),os&&delete r[os];var i=a;break e}finally{(a=n.g).h=null,a.s=!1,a.v=0,a.l=0,a.g=0,a.O=!1,n.m=-1,n.h=-1,100>wo.length&&wo.push(n)}i=void 0}return i}}function xu(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}}}};Pl(this.u,t,Dl(e)),Do(t,t.g.end());const n=new Uint8Array(t.h),r=t.l,a=r.length;let i=0;for(let e=0;e<a;e++){const t=r[e];n.set(t,i),i+=t.length}return t.l=[n],n}}var Eu,ku=[0,lu,Bl((function(e,t,n){return 2===e.h&&($l(t,n,(e=yo(e))===$i()?void 0:e),!0)}),(function(e,t,n){if(null!=t){if(t instanceof yl){const r=t.Aa;return void(r&&(t=r(t),null!=t&&No(e,n,Wi(t).buffer)))}if(Array.isArray(t))return}Wl(e,t,n)}))];function Su(e){if(void 0===Eu){var t=null,n=ei.trustedTypes;if(n&&n.createPolicy){try{t=n.createPolicy("goog#html",{createHTML:ni,createScript:ni,createScriptURL:ni})}catch(e){ei.console&&ei.console.error(e.message)}Eu=t}else Eu=t}return e=(t=Eu)?t.createScriptURL(e):e,new class{constructor(e){this.g=e}toString(){return this.g+""}}(e)}var Cu=[0,uu],Tu=[0,nu,mu,iu,iu,ru,mu,mu],Au=[0,iu,iu],Ru=class extends yl{constructor(){super()}};Ru.B=[6];var Iu=[0,iu,uu,iu,mu,mu,vu,uu,uu,du,Au,mu],_u=[0,uu,uu,uu],Du=class extends yl{constructor(){super()}},Fu=[0],Mu=[0,nu],Lu=[1,2,3,4,5],Nu=class extends yl{constructor(e){super(e,2)}},Ou={},Pu=[-2,Ou,iu];Ou[336783863]=wl([0,uu,iu,iu,nu,du,[0,fu,Fu,Lu,fu,Iu,Lu,fu,_u,Lu,fu,Mu,Lu,fu,Tu,Lu],du,Cu]);var Bu=[0,lu,ou],Uu=[0,eu,eu,ou,ou,ou,ou,eu,ru,lu,au,eu,eu,ou,au,ou,ou,ou,lu],$u=[-1,{}],ju=[0,uu,du,2,$u],Gu=[0,uu,su,du,$u];function zu(e,t){t=gs(t);const n=qo(e=e.u);ns(n),zs(e,n,2,""===t?void 0:t)}function qu(e,t){ml(e,3,t)}function Hu(e,t){ml(e,4,t)}var Vu=class extends yl{constructor(e){super(e,500)}o(e){return il(this,0,7,e)}};Vu.B=[3,4,5,6,8,13,17,1005];var Wu=[-500,lu,lu,su,su,su,su,du,Pu,hu,ku,au,au,du,ju,du,Gu,hu,Bu,lu,du,Uu,au,su,su,988],Ku=[0,lu,lu,du,$u],Yu=[-500,uu,uu,du,[-1,{}],uu,999],Xu=[-500,uu,su,su,du,[-2,{},iu],su,998,su],Ju=[-500,uu,su,du,$u,su,999];function Zu(e,t){sl(e,Vu,t)}function Qu(e,t){ml(e,10,t)}function ec(e,t){ml(e,15,t)}var tc=class extends yl{constructor(e){super(e,500)}o(e){return il(this,0,1001,e)}};tc.B=[1,6,7,9,10,15,16,17,14,1002];var nc=[-500,hu,Wu,hu,5,Yu,hu,Xu,au,hu,Ju,su,au,du,ju,du,Gu,hu,Ku,su,su,su,du,Uu,lu,lu,ou,du,980,$u,hu,ku],rc=wu(tc,nc);tc.prototype.g=xu(nc);var ac=[0,hu,[0,nu,nu,nu]],ic=class extends yl{constructor(e){super(e)}},oc=[0,nu,Xl,uu,uu],sc=class extends yl{constructor(e){super(e)}g(){return al(this,ic,1)}};sc.B=[1];var lc=[0,hu,oc],uc=wu(sc,lc),cc=[0,nu,Xl],dc=[0,nu,nu,du,ac],hc=class extends yl{constructor(e){super(e)}},fc=[0,nu,nu,nu,nu],pc=[0,Xl,Xl,Xl,Xl],gc=class extends yl{constructor(e){super(e)}},mc=[0,Xl,Xl,uu,Xl],vc=class extends yl{constructor(e){super(e)}h(){return nl(this,hc,2)}g(){return al(this,gc,5)}};vc.B=[5];var yc=[0,mu,du,fc,du,pc,du,dc,hu,mc],bc=class extends yl{constructor(e){super(e)}};bc.B=[1,2,3,8,9];var wc=wu(bc,[0,su,ru,Zl,du,yc,uu,uu,Ql,hu,cc,su,Ql]),xc=class extends yl{constructor(e){super(e)}},Ec=[0,Xl,Xl,Xl,Xl,Xl],kc=class extends yl{constructor(e){super(e)}};kc.B=[1];var Sc=wu(kc,[0,hu,Ec]),Cc=class extends yl{constructor(e){super(e)}},Tc=[0,Xl,Xl,Xl,Xl,Xl],Ac=class extends yl{constructor(e){super(e)}};Ac.B=[1];var Rc=wu(Ac,[0,hu,Tc]),Ic=class extends yl{constructor(e){super(e)}};Ic.B=[3];var _c=[0,nu,nu,Zl,mu],Dc=class extends yl{constructor(){super()}};Dc.prototype.g=xu([0,Xl,Xl,Xl,Xl,Xl,Ql]);var Fc=class extends yl{constructor(e){super(e)}},Mc=[0,nu,2,uu,du,lc],Lc=class extends yl{constructor(e){super(e)}};Lc.B=[1];var Nc=wu(Lc,[0,hu,Mc,Ql]),Oc=class extends yl{constructor(e){super(e)}};Oc.B=[1];var Pc=class extends yl{constructor(e){super(e)}da(){const e=Vs(this);return null==e?$i():e}},Bc=class extends yl{constructor(e){super(e)}},Uc=[1,2],$c=[0,fu,[0,Zl],Uc,fu,[0,pu],Uc,nu,uu],jc=class extends yl{constructor(e){super(e)}};jc.B=[1];var Gc=wu(jc,[0,hu,$c,Ql]),zc=class extends yl{constructor(e){super(e)}};zc.B=[4,5];var qc=[0,uu,nu,Xl,su,su],Hc=class extends yl{constructor(e){super(e)}},Vc=[0,iu,iu],Wc=class extends yl{constructor(e){super(e)}},Kc=[1,2,3,4,5],Yc=class extends yl{constructor(e){super(e)}g(){return null!=Vs(this)}h(){return null!=cl(this,2)}},Xc=[0,pu,uu,du,[0,nu,Ql,Ql],du,[0,tu,Ql]],Jc=class extends yl{constructor(e){super(e)}g(){return cs($s(this,2))??!1}},Zc=[0,du,Xc,iu,du,[0,fu,Mu,Kc,fu,Iu,Kc,fu,Tu,Kc,fu,Fu,Kc,fu,_u,Kc]],Qc=class extends yl{constructor(e){super(e)}},ed=[0,du,Zc,Xl,Xl,nu],td=bu(502141897,Qc);Ou[502141897]=wl(ed);var nd=[0,du,Xc];Ou[512499200]=wl(nd);var rd=[0,du,nd];Ou[515723506]=wl(rd);var ad=wu(class extends yl{constructor(e){super(e)}},[0,du,[0,mu,mu,Jl,gu],du,_c]),id=[0,du,Zc];Ou[508981768]=wl(id);var od=class extends yl{constructor(e){super(e)}},sd=[0,du,Zc,Xl,du,id,iu],ld=class extends yl{constructor(e){super(e)}},ud=[0,du,Zc,du,ed,du,sd,Xl,du,rd];Ou[508968149]=wl(sd);var cd=bu(508968150,ld);Ou[508968150]=wl(ud);var dd=class extends yl{constructor(e){super(e)}},hd=bu(513916220,dd);Ou[513916220]=wl([0,du,Zc,du,ud,nu]);var fd=class extends yl{constructor(e){super(e)}h(){return nl(this,zc,2)}g(){Gs(this,2)}},pd=[0,du,Zc,du,qc];Ou[478825465]=wl(pd);var gd=[0,du,Zc];Ou[478825422]=wl(gd);var md=class extends yl{constructor(e){super(e)}},vd=[0,du,Zc,du,gd,du,pd,du,pd],yd=class extends yl{constructor(e){super(e)}},bd=[0,du,Zc,Xl,nu],wd=class extends yl{constructor(e){super(e)}},xd=[0,du,Zc,Xl],Ed=class extends yl{constructor(e){super(e)}},kd=[0,du,Zc,du,bd,du,xd,Xl],Sd=class extends yl{constructor(e){super(e)}},Cd=[0,du,Zc,du,kd,du,vd];Ou[463370452]=wl(vd),Ou[464864288]=wl(bd),Ou[474472470]=wl(xd);var Td=bu(462713202,Ed);Ou[462713202]=wl(kd);var Ad=bu(479097054,Sd);Ou[479097054]=wl(Cd);var Rd=class extends yl{constructor(e){super(e)}},Id=bu(456383383,Rd);Ou[456383383]=wl([0,du,Zc,du,qc]);var _d=class extends yl{constructor(e){super(e)}},Dd=bu(476348187,_d);Ou[476348187]=wl([0,du,Zc,du,Vc]);var Fd=class extends yl{constructor(e){super(e)}},Md=[0,mu,mu],Ld=class extends yl{constructor(e){super(e)}};Ld.B=[3];var Nd=bu(458105876,class extends yl{constructor(e){super(e)}g(){var e=this.u;const t=qo(e);var n=2&t;return e=function(e,t,n){var r=Ld;const a=2&t;let i=!1;if(null==n){if(a)return Ys();n=[]}else if(n.constructor===Rs){if(0==(2&n.g)||a)return n;n=n.m()}else Array.isArray(n)?i=!!(2&zo(n)):n=[];if(a){if(!n.length)return Ys();i||(i=!0,Wo(n))}else i&&(i=!1,n=Xs(n));return i||(64&zo(n)?Go(n,32):32&t&&$o(n,32)),zs(e,t,2,r=new Rs(n,r,ws,void 0),!1),r}(e,t,js(e,t,2)),null==e||!n&&Ld&&(e.v=!0),e}});Ou[458105876]=wl([0,du,Md,jl,[0,Ql,du,[0,uu,uu,su]]]);var Od=class extends yl{constructor(e){super(e)}},Pd=bu(458105758,Od);Ou[458105758]=wl([0,du,Zc,uu,du,Md]);var Bd=class extends yl{constructor(e){super(e)}};Bd.B=[5,6];var Ud=bu(443442058,Bd);Ou[443442058]=wl([0,du,Zc,uu,nu,Xl,su,su]);var $d=class extends yl{constructor(e){super(e)}},jd=[0,du,Zc,Xl,Xl,nu];Ou[514774813]=wl(jd);var Gd=class extends yl{constructor(e){super(e)}},zd=[0,du,Zc,Xl],qd=class extends yl{constructor(e){super(e)}},Hd=[0,du,Zc,du,jd,du,zd,Xl];Ou[518928384]=wl(zd);var Vd=bu(516587230,qd);function Wd(e,t){return t=t?t.clone():new zc,void 0!==e.displayNamesLocale?Gs(t,1,gs(e.displayNamesLocale)):void 0===e.displayNamesLocale&&Gs(t,1),void 0!==e.maxResults?pl(t,2,e.maxResults):"maxResults"in e&&Gs(t,2),void 0!==e.scoreThreshold?gl(t,3,e.scoreThreshold):"scoreThreshold"in e&&Gs(t,3),void 0!==e.categoryAllowlist?Js(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&Gs(t,4),void 0!==e.categoryDenylist?Js(t,5,e.categoryDenylist):"categoryDenylist"in e&&Gs(t,5),t}function Kd(e,t=-1,n=""){return{categories:e.map((e=>({index:dl(ll(e,1))??-1,score:hl(e,2)??0,categoryName:cl(e,3)??""??"",displayName:cl(e,4)??""??""}))),headIndex:t,headName:n}}function Yd(e){var t=Ws(e,3,us),n=Ws(e,2,hs);const r=Ws(e,1,ms),a=Ws(e,9,ms),i={categories:[],keypoints:[]};for(let e=0;e<t.length;e++)i.categories.push({score:t[e],index:n[e]??-1,categoryName:r[e]??"",displayName:a[e]??""});if((t=nl(e,vc,4)?.h())&&(i.boundingBox={originX:ll(t,1)??0,originY:ll(t,2)??0,width:ll(t,3)??0,height:ll(t,4)??0,angle:0}),nl(e,vc,4)?.g().length)for(const t of nl(e,vc,4).g())i.keypoints.push({x:Hs(t,1)??0,y:Hs(t,2)??0,score:Hs(t,4)??0,label:cl(t,3)??""});return i}function Xd(e){const t=[];for(const n of al(e,Cc,1))t.push({x:hl(n,1)??0,y:hl(n,2)??0,z:hl(n,3)??0});return t}function Jd(e){const t=[];for(const n of al(e,xc,1))t.push({x:hl(n,1)??0,y:hl(n,2)??0,z:hl(n,3)??0});return t}function Zd(e){return Array.from(e,(e=>127<e?e-256:e))}function Qd(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,a=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i],r+=e[i]*e[i],a+=t[i]*t[i];if(0>=r||0>=a)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(r*a)}let eh;Ou[516587230]=wl(Hd);const th=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 nh(){if(void 0===eh)try{await WebAssembly.instantiate(th),eh=!0}catch{eh=!1}return eh}async function rh(e,t){const n=await nh()?"wasm_internal":"wasm_nosimd_internal";return void 0!==t?{wasmLoaderPath:`${t}/${e}_${n}.js`,wasmBinaryPath:`${t}/${e}_${n}.wasm`}:{wasmLoaderPath:Su(`./${encodeURIComponent(e)}_${encodeURIComponent(n)}.js`),wasmBinaryPath:Su(`./${encodeURIComponent(e)}_${encodeURIComponent(n)}.wasm`)}}var ah=class{};function ih(){const e=navigator.userAgent;return e.includes("Safari")&&!e.includes("Chrome")}async function oh(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 sh(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 lh(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 uh(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 ch(e,t,n){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=n}function dh(e,t,n){let r=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(e,t,a)=>{t?(n(r,a),r=[]):r.push(e)}}function hh(e,t){const n=nl(e.baseOptions,Yc,1)||new Yc;"string"==typeof t?(Gs(n,2,gs(t)),Gs(n,1)):t instanceof Uint8Array&&(Gs(n,1,es(t,!1,!1)),Gs(n,2)),il(e.baseOptions,0,1,n)}function fh(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 ph(e,t){e.H=Math.max(e.H,t)}function gh(e,t){e.A=new Vu,zu(e.A,"PassThroughCalculator"),qu(e.A,"free_memory"),Hu(e.A,"free_memory_unused_out"),Qu(t,"free_memory"),Zu(t,e.A)}function mh(e,t){qu(e.A,t),Hu(e.A,t+"_unused_out")}function vh(e){e.g.addBoolToStream(!0,"free_memory",e.H)}ah.forVisionTasks=function(e=""){return rh("vision",e)},ah.forTextTasks=function(e=""){return rh("text",e)},ah.forAudioTasks=function(e=""){return rh("audio",e)},ah.isSimdSupported=function(){return nh()};var yh=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(!(nl(this.baseOptions,Yc,1)?.g()||nl(this.baseOptions,Yc,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=nl(e.baseOptions,Wc,3);if(!n){var r=n=new Wc,a=new Du;ol(r,4,Kc,a)}"delegate"in t&&("GPU"===t.delegate?(t=n,r=new Ru,ol(t,2,Kc,r)):(t=n,r=new Du,ol(t,4,Kc,r))),il(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),hh(this,"/model.dat"),this.m(),this.N()}));hh(this,t.modelAssetBuffer)}return this.m(),this.N(),Promise.resolve()}N(){}U(){let e;if(this.g.U((t=>{e=rc(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,fh(this)}finishProcessing(){this.g.finishProcessing(),fh(this)}close(){this.A=void 0,this.g.closeGraph()}};function bh(e,t){if(null===e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}yh.prototype.close=yh.prototype.close;class wh{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 xh(e,t,n){const r=e.h;if(n=bh(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 Eh(e,t){const n=e.h,r=bh(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(r);const a=bh(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,a),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 i=bh(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,i),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 wh(n,r,a,i)}function kh(e,t){if(e.h){if(t!==e.h)throw Error("Cannot change GL context once initialized")}else e.h=t}function Sh(e,t,n,r){if(kh(e,t),!e.g){const t=e.h;if(e.g=bh(t.createProgram(),"Failed to create WebGL program"),e.C=xh(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=xh(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=Eh(e,!0)),n=e.m):(e.j||(e.j=Eh(e,!1)),n=e.j),t.useProgram(e.g),n.bind(),e=r(),n.g.bindVertexArray(null),e}function Ch(e,t,n){kh(e,t),e.l||(e.l=bh(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 Th(e){e.h?.bindFramebuffer(e.h.FRAMEBUFFER,null)}var Ah=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 Rh(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 Ih(e){var t=Rh(e,0);if(!t){t=Dh(e);const n=Fh(e),r=new Uint8Array(e.width*e.height*4);Ch(n,t,_h(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,r),Th(n),t=new ImageData(new Uint8ClampedArray(r.buffer),e.width,e.height),e.g.push(t)}return t}function _h(e){let t=Rh(e,2);if(!t){const n=Dh(e);t=Lh(e);const r=Rh(e,1)||Ih(e);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,r),Nh(e)}return t}function Dh(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=bh(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Fh(e){return e.l||(e.l=new Ah),e.l}function Mh(e){(e=Dh(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 Lh(e){const t=Dh(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=Rh(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=bh(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),Mh(e)),n}function Nh(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Oh(e){const t=Dh(e);return Sh(Fh(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,a=n.height;return n.width=e.width,n.height=e.height,e=t(),n.width=r,n.height=a,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 Ph=class{constructor(e,t,n,r,a,i,o){this.g=e,this.j=t,this.m=n,this.canvas=r,this.l=a,this.width=i,this.height=o,(this.j||this.m)&&0==--Bh&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}ta(){return!!Rh(this,0)}Z(){return!!Rh(this,1)}J(){return!!Rh(this,2)}pa(){return Ih(this)}oa(){var e=Rh(this,1);return e||(_h(this),Lh(this),e=Oh(this),Nh(this),this.g.push(e),this.j=!0),e}T(){return _h(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=Dh(this),t=Fh(this);e.activeTexture(e.TEXTURE1),n=bh(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),Mh(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),Ch(t,e,n),Sh(t,e,!1,(()=>{Lh(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),Nh(this)})),Th(t),Nh(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);_h(this),Lh(this),n=Oh(this),Nh(this)}e.push(n)}return new Ph(e,this.Z(),this.J(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Rh(this,1).close(),this.m&&Dh(this).deleteTexture(Rh(this,2)),Bh=-1}};Ph.prototype.close=Ph.prototype.close,Ph.prototype.clone=Ph.prototype.clone,Ph.prototype.getAsWebGLTexture=Ph.prototype.T,Ph.prototype.getAsImageBitmap=Ph.prototype.oa,Ph.prototype.getAsImageData=Ph.prototype.pa,Ph.prototype.hasWebGLTexture=Ph.prototype.J,Ph.prototype.hasImageBitmap=Ph.prototype.Z,Ph.prototype.hasImageData=Ph.prototype.ta;var Bh=250;function Uh(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 $h(e){var t=Uh(e,1);if(!t){if(t=Uh(e,0))t=new Float32Array(t).map((e=>e/255));else{t=new Float32Array(e.width*e.height);const r=Gh(e);var n=qh(e);if(Ch(n,r,jh(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 jh(e){let t=Uh(e,2);if(!t){const n=Gh(e);t=Vh(e);const r=$h(e),a=zh(e);n.texImage2D(n.TEXTURE_2D,0,a,e.width,e.height,0,n.RED,n.FLOAT,r),Wh(e)}return t}function Gh(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=bh(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function zh(e){if(e=Gh(e),!Kh)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Kh=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Kh=e.R16F}return Kh}function qh(e){return e.l||(e.l=new Ah),e.l}function Hh(e){(e=Gh(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 Vh(e){const t=Gh(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=Uh(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=bh(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),Hh(e)),n}function Wh(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Kh,Yh=class{constructor(e,t,n,r,a,i){this.g=e,this.m=t,this.canvas=n,this.l=r,this.width=a,this.height=i,this.m&&0==--Xh&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}ua(){return!!Uh(this,0)}sa(){return!!Uh(this,1)}J(){return!!Uh(this,2)}qa(){return(e=Uh(this,0))||(e=$h(this),e=new Uint8Array(e.map((e=>255*e))),this.g.push(e)),e;var e}na(){return $h(this)}T(){return jh(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=Gh(this),t=qh(this);e.activeTexture(e.TEXTURE1),n=bh(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),Hh(this);const r=zh(this);e.texImage2D(e.TEXTURE_2D,0,r,this.width,this.height,0,e.RED,e.FLOAT,null),e.bindTexture(e.TEXTURE_2D,null),Ch(t,e,n),Sh(t,e,!1,(()=>{Vh(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),Wh(this)})),Th(t),Wh(this)}}e.push(n)}return new Yh(e,this.J(),this.canvas,this.l,this.width,this.height)}close(){this.m&&Gh(this).deleteTexture(Uh(this,2)),Xh=-1}};Yh.prototype.close=Yh.prototype.close,Yh.prototype.clone=Yh.prototype.clone,Yh.prototype.getAsWebGLTexture=Yh.prototype.T,Yh.prototype.getAsFloat32Array=Yh.prototype.na,Yh.prototype.getAsUint8Array=Yh.prototype.qa,Yh.prototype.hasWebGLTexture=Yh.prototype.J,Yh.prototype.hasFloat32Array=Yh.prototype.sa,Yh.prototype.hasUint8Array=Yh.prototype.ua;var Xh=250;function Jh(...e){return e.map((([e,t])=>({start:e,end:t})))}const Zh=function(e){return class extends e{xa(){this.i._registerModelResourcesGraphService()}}}((Qh=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||ih()?(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,a){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),sh(this,r||"input_audio",(r=>{sh(this,a=a||"audio_header",(a=>{this.i._configureAudio(r,a,e,t,n)}))}))}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}U(e){ch(this,"__graph_config__",(t=>{e(t)})),sh(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,a){const i=4*e.length;this.h!==i&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(i),this.h=i),this.i.HEAPF32.set(e,this.g/4),sh(this,r,(e=>{this.i._addAudioToInputStream(this.g,t,n,e,a)}))}addGpuBufferToStream(e,t,n){sh(this,t,(t=>{const[r,a]=lh(this,e,t);this.i._addBoundTextureToStream(t,r,a,n)}))}addBoolToStream(e,t,n){sh(this,t,(t=>{this.i._addBoolToInputStream(e,t,n)}))}addDoubleToStream(e,t,n){sh(this,t,(t=>{this.i._addDoubleToInputStream(e,t,n)}))}addFloatToStream(e,t,n){sh(this,t,(t=>{this.i._addFloatToInputStream(e,t,n)}))}addIntToStream(e,t,n){sh(this,t,(t=>{this.i._addIntToInputStream(e,t,n)}))}addStringToStream(e,t,n){sh(this,t,(t=>{sh(this,e,(e=>{this.i._addStringToInputStream(e,t,n)}))}))}addStringRecordToStream(e,t,n){sh(this,t,(t=>{uh(this,Object.keys(e),(r=>{uh(this,Object.values(e),(a=>{this.i._addFlatHashMapToInputStream(r,a,Object.keys(e).length,t,n)}))}))}))}addProtoToStream(e,t,n,r){sh(this,n,(n=>{sh(this,t,(t=>{const a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,t,n,r),this.i._free(a)}))}))}addEmptyPacketToStream(e,t){sh(this,e,(e=>{this.i._addEmptyPacketToInputStream(e,t)}))}addBoolToInputSidePacket(e,t){sh(this,t,(t=>{this.i._addBoolToInputSidePacket(e,t)}))}addDoubleToInputSidePacket(e,t){sh(this,t,(t=>{this.i._addDoubleToInputSidePacket(e,t)}))}addFloatToInputSidePacket(e,t){sh(this,t,(t=>{this.i._addFloatToInputSidePacket(e,t)}))}addIntToInputSidePacket(e,t){sh(this,t,(t=>{this.i._addIntToInputSidePacket(e,t)}))}addStringToInputSidePacket(e,t){sh(this,t,(t=>{sh(this,e,(e=>{this.i._addStringToInputSidePacket(e,t)}))}))}addProtoToInputSidePacket(e,t,n){sh(this,n,(n=>{sh(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){ch(this,e,t),sh(this,e,(e=>{this.i._attachBoolListener(e)}))}attachBoolVectorListener(e,t){dh(this,e,t),sh(this,e,(e=>{this.i._attachBoolVectorListener(e)}))}attachIntListener(e,t){ch(this,e,t),sh(this,e,(e=>{this.i._attachIntListener(e)}))}attachIntVectorListener(e,t){dh(this,e,t),sh(this,e,(e=>{this.i._attachIntVectorListener(e)}))}attachDoubleListener(e,t){ch(this,e,t),sh(this,e,(e=>{this.i._attachDoubleListener(e)}))}attachDoubleVectorListener(e,t){dh(this,e,t),sh(this,e,(e=>{this.i._attachDoubleVectorListener(e)}))}attachFloatListener(e,t){ch(this,e,t),sh(this,e,(e=>{this.i._attachFloatListener(e)}))}attachFloatVectorListener(e,t){dh(this,e,t),sh(this,e,(e=>{this.i._attachFloatVectorListener(e)}))}attachStringListener(e,t){ch(this,e,t),sh(this,e,(e=>{this.i._attachStringListener(e)}))}attachStringVectorListener(e,t){dh(this,e,t),sh(this,e,(e=>{this.i._attachStringVectorListener(e)}))}attachProtoListener(e,t,n){ch(this,e,t),sh(this,e,(e=>{this.i._attachProtoListener(e,n||!1)}))}attachProtoVectorListener(e,t,n){dh(this,e,t),sh(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?'),ch(this,e,((e,n)=>{e=new Float32Array(e.buffer,e.byteOffset,e.length/4),t(e,n)})),sh(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 Qh{get W(){return this.i}ea(e,t,n){sh(this,t,(t=>{const[r,a]=lh(this,e,t);this.W._addBoundTextureAsImageToStream(t,r,a,n)}))}P(e,t){ch(this,e,t),sh(this,e,(e=>{this.W._attachImageListener(e)}))}R(e,t){dh(this,e,t),sh(this,e,(e=>{this.W._attachImageVectorListener(e)}))}}));var Qh,ef=class extends Zh{};async function tf(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,a)=>{if(t&&await oh(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(n&&(await oh(n),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&a&&((t=self.Module).locateFile=a.locateFile,a.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=a.mainScriptUrlOrBlob)),a=await self.ModuleFactory(self.Module||a),self.ModuleFactory=self.Module=void 0,new e(a,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||ih()?document.createElement("canvas"):void 0),t,n)}function nf(e,t,n,r){if(e.X){const i=new Dc;if(n?.regionOfInterest){if(!e.ca)throw Error("This task doesn't support region-of-interest.");var a=n.regionOfInterest;if(a.left>=a.right||a.top>=a.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(0>a.left||0>a.top||1<a.right||1<a.bottom)throw Error("Expected RectF values to be in [0,1].");gl(i,1,(a.left+a.right)/2),gl(i,2,(a.top+a.bottom)/2),gl(i,4,a.right-a.left),gl(i,3,a.bottom-a.top)}else gl(i,1,.5),gl(i,2,.5),gl(i,4,1),gl(i,3,1);if(n?.rotationDegrees){if(0!=n?.rotationDegrees%90)throw Error("Expected rotation to be a multiple of 90°.");if(gl(i,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=hl(i,3)*r/e,a=hl(i,4)*e/r,gl(i,4,n),gl(i,3,a)}}e.g.addProtoToStream(i.g(),"mediapipe.NormalizedRect",e.X,r)}e.g.ea(t,e.ba,r??performance.now()),e.finishProcessing()}function rf(e,t,n){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");nf(e,t,n,e.H+1)}function af(e,t,n,r){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");nf(e,t,n,r)}function of(e,t,n){var r=t.data;const a=t.width,i=a*(t=t.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==i)throw Error("Unsupported channel count: "+r.length/i);return e=new Yh([r],!1,e.g.i.canvas,e.M,a,t),n?e.clone():e}var sf=class extends yh{constructor(e,t,n,r){super(e),this.g=e,this.ba=t,this.X=n,this.ca=r,this.M=new Ah}l(e,t=!0){if("runningMode"in e&&fl(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()}};sf.prototype.close=sf.prototype.close;var lf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},this.h=new Qc,e=new Jc,il(this.h,0,1,e),gl(this.h,2,.5),gl(this.h,3,.3)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&gl(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&gl(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},rf(this,e,t),this.j}D(e,t,n){return this.j={detections:[]},af(this,e,n,t),this.j}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect_in"),ec(e,"detections");const t=new Nu;vl(t,td,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect_in"),Hu(n,"DETECTIONS:detections"),n.o(t),Zu(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=wc(t),this.j.detections.push(Yd(e));ph(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};lf.prototype.detectForVideo=lf.prototype.D,lf.prototype.setOptions=lf.prototype.o,lf.createFromModelPath=async function(e,t){return tf(lf,e,{baseOptions:{modelAssetPath:t}})},lf.createFromModelBuffer=function(e,t){return tf(lf,e,{baseOptions:{modelAssetBuffer:t}})},lf.createFromOptions=function(e,t){return tf(lf,e,t)};var uf=Jh([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]),cf=Jh([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]),df=Jh([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),hf=Jh([474,475],[475,476],[476,477],[477,474]),ff=Jh([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]),pf=Jh([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),gf=Jh([469,470],[470,471],[471,472],[472,469]),mf=Jh([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]),vf=[...uf,...cf,...df,...ff,...pf,...mf],yf=Jh([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 bf(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var wf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,this.h=new ld,e=new Jc,il(this.h,0,1,e),this.v=new od,il(this.h,0,3,this.v),this.s=new Qc,il(this.h,0,2,this.s),pl(this.s,4,1),gl(this.s,2,.5),gl(this.v,2,.5),gl(this.h,4,.5)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){return"numFaces"in e&&pl(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&gl(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&gl(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&gl(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 bf(this),rf(this,e,t),this.j}D(e,t,n){return bf(this),af(this,e,n,t),this.j}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"face_landmarks");const t=new Nu;vl(t,cd,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"NORM_LANDMARKS:face_landmarks"),n.o(t),Zu(e,n),this.g.attachProtoVectorListener("face_landmarks",((e,t)=>{for(const t of e)e=Rc(t),this.j.faceLandmarks.push(Xd(e));ph(this,t)})),this.g.attachEmptyPacketListener("face_landmarks",(e=>{ph(this,e)})),this.outputFaceBlendshapes&&(ec(e,"blendshapes"),Hu(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((e,t)=>{if(this.outputFaceBlendshapes)for(const t of e)e=uc(t),this.j.faceBlendshapes.push(Kd(e.g()??[]));ph(this,t)})),this.g.attachEmptyPacketListener("blendshapes",(e=>{ph(this,e)}))),this.outputFacialTransformationMatrixes&&(ec(e,"face_geometry"),Hu(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((e,t)=>{if(this.outputFacialTransformationMatrixes)for(const t of e)(e=nl(ad(t),Ic,2))&&this.j.facialTransformationMatrixes.push({rows:dl(ll(e,1))??0,columns:dl(ll(e,2))??0,data:Ws(e,3,us)??[]});ph(this,t)})),this.g.attachEmptyPacketListener("face_geometry",(e=>{ph(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};wf.prototype.detectForVideo=wf.prototype.D,wf.prototype.detect=wf.prototype.F,wf.prototype.setOptions=wf.prototype.o,wf.createFromModelPath=function(e,t){return tf(wf,e,{baseOptions:{modelAssetPath:t}})},wf.createFromModelBuffer=function(e,t){return tf(wf,e,{baseOptions:{modelAssetBuffer:t}})},wf.createFromOptions=function(e,t){return tf(wf,e,t)},wf.FACE_LANDMARKS_LIPS=uf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LIPS",wf.FACE_LANDMARKS_LIPS),wf.FACE_LANDMARKS_LEFT_EYE=cf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_EYE",wf.FACE_LANDMARKS_LEFT_EYE),wf.FACE_LANDMARKS_LEFT_EYEBROW=df,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_EYEBROW",wf.FACE_LANDMARKS_LEFT_EYEBROW),wf.FACE_LANDMARKS_LEFT_IRIS=hf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_IRIS",wf.FACE_LANDMARKS_LEFT_IRIS),wf.FACE_LANDMARKS_RIGHT_EYE=ff,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_EYE",wf.FACE_LANDMARKS_RIGHT_EYE),wf.FACE_LANDMARKS_RIGHT_EYEBROW=pf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_EYEBROW",wf.FACE_LANDMARKS_RIGHT_EYEBROW),wf.FACE_LANDMARKS_RIGHT_IRIS=gf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_IRIS",wf.FACE_LANDMARKS_RIGHT_IRIS),wf.FACE_LANDMARKS_FACE_OVAL=mf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_FACE_OVAL",wf.FACE_LANDMARKS_FACE_OVAL),wf.FACE_LANDMARKS_CONTOURS=vf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_CONTOURS",wf.FACE_LANDMARKS_CONTOURS),wf.FACE_LANDMARKS_TESSELATION=yf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_TESSELATION",wf.FACE_LANDMARKS_TESSELATION);var xf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!0),this.j=new dd,e=new Jc,il(this.j,0,1,e)}get baseOptions(){return nl(this.j,Jc,1)}set baseOptions(e){il(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,rf(this,e,r??{}),!this.h)return this.s}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"stylized_image");const t=new Nu;vl(t,hd,this.j);const n=new Vu;zu(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"STYLIZED_IMAGE:stylized_image"),n.o(t),Zu(e,n),this.g.P("stylized_image",((e,t)=>{var n=!this.h,r=e.data,a=e.width;const i=a*(e=e.height);if(r instanceof Uint8Array)if(r.length===3*i){const t=new Uint8ClampedArray(4*i);for(let e=0;e<i;++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,a,e)}else{if(r.length!==4*i)throw Error("Unsupported channel count: "+r.length/i);r=new ImageData(new Uint8ClampedArray(r.buffer,r.byteOffset,r.length),a,e)}else if(!(r instanceof WebGLTexture))throw Error(`Unsupported format: ${r.constructor.name}`);a=new Ph([r],!1,!1,this.g.i.canvas,this.M,a,e),this.s=n=n?a.clone():a,this.h&&this.h(n),ph(this,t)})),this.g.attachEmptyPacketListener("stylized_image",(e=>{this.s=null,this.h&&this.h(null),ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};xf.prototype.stylize=xf.prototype.za,xf.prototype.setOptions=xf.prototype.o,xf.createFromModelPath=function(e,t){return tf(xf,e,{baseOptions:{modelAssetPath:t}})},xf.createFromModelBuffer=function(e,t){return tf(xf,e,{baseOptions:{modelAssetBuffer:t}})},xf.createFromOptions=function(e,t){return tf(xf,e,t)};var Ef=Jh([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 kf(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function Sf(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 Cf(e,t=!0){const n=[];for(const a of e){var r=uc(a);e=[];for(const n of r.g())r=t&&null!=ll(n,1)?dl(ll(n,1)):-1,e.push({score:hl(n,2)??0,index:r,categoryName:cl(n,3)??""??"",displayName:cl(n,4)??""??""});n.push(e)}return n}var Tf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.v=new Sd,e=new Jc,il(this.v,0,1,e),this.C=new Ed,il(this.v,0,2,this.C),this.s=new wd,il(this.C,0,3,this.s),this.h=new yd,il(this.C,0,2,this.h),this.j=new md,il(this.v,0,3,this.j),gl(this.h,2,.5),gl(this.C,4,.5),gl(this.s,2,.5)}get baseOptions(){return nl(this.v,Jc,1)}set baseOptions(e){il(this.v,0,1,e)}o(e){if(pl(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&gl(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&gl(this.C,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&gl(this.s,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new fd,n=Wd(e.cannedGesturesClassifierOptions,nl(this.j,fd,3)?.h());il(t,0,2,n),il(this.j,0,3,t)}else void 0===e.cannedGesturesClassifierOptions&&nl(this.j,fd,3)?.g();return e.customGesturesClassifierOptions?(il(t=new fd,0,2,n=Wd(e.customGesturesClassifierOptions,nl(this.j,fd,4)?.h())),il(this.j,0,4,t)):void 0===e.customGesturesClassifierOptions&&nl(this.j,fd,4)?.g(),this.l(e)}va(e,t){return kf(this),rf(this,e,t),Sf(this)}wa(e,t,n){return kf(this),af(this,e,n,t),Sf(this)}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"hand_gestures"),ec(e,"hand_landmarks"),ec(e,"world_hand_landmarks"),ec(e,"handedness");const t=new Nu;vl(t,Ad,this.v);const n=new Vu;zu(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"HAND_GESTURES:hand_gestures"),Hu(n,"LANDMARKS:hand_landmarks"),Hu(n,"WORLD_LANDMARKS:world_hand_landmarks"),Hu(n,"HANDEDNESS:handedness"),n.o(t),Zu(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e){e=Rc(t);const n=[];for(const t of al(e,Cc,1))n.push({x:hl(t,1)??0,y:hl(t,2)??0,z:hl(t,3)??0});this.landmarks.push(n)}ph(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{ph(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e){e=Sc(t);const n=[];for(const t of al(e,xc,1))n.push({x:hl(t,1)??0,y:hl(t,2)??0,z:hl(t,3)??0});this.worldLandmarks.push(n)}ph(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{ph(this,e)})),this.g.attachProtoVectorListener("hand_gestures",((e,t)=>{this.gestures.push(...Cf(e,!1)),ph(this,t)})),this.g.attachEmptyPacketListener("hand_gestures",(e=>{ph(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{this.handedness.push(...Cf(e)),ph(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Af(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Tf.prototype.recognizeForVideo=Tf.prototype.wa,Tf.prototype.recognize=Tf.prototype.va,Tf.prototype.setOptions=Tf.prototype.o,Tf.createFromModelPath=function(e,t){return tf(Tf,e,{baseOptions:{modelAssetPath:t}})},Tf.createFromModelBuffer=function(e,t){return tf(Tf,e,{baseOptions:{modelAssetBuffer:t}})},Tf.createFromOptions=function(e,t){return tf(Tf,e,t)},Tf.HAND_CONNECTIONS=Ef,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$gesture_recognizer$gesture_recognizer.GestureRecognizer.HAND_CONNECTIONS",Tf.HAND_CONNECTIONS);var Rf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.j=new Ed,e=new Jc,il(this.j,0,1,e),this.s=new wd,il(this.j,0,3,this.s),this.h=new yd,il(this.j,0,2,this.h),pl(this.h,3,1),gl(this.h,2,.5),gl(this.s,2,.5),gl(this.j,4,.5)}get baseOptions(){return nl(this.j,Jc,1)}set baseOptions(e){il(this.j,0,1,e)}o(e){return"numHands"in e&&pl(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&gl(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&gl(this.j,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&gl(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],rf(this,e,t),Af(this)}D(e,t,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],af(this,e,n,t),Af(this)}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"hand_landmarks"),ec(e,"world_hand_landmarks"),ec(e,"handedness");const t=new Nu;vl(t,Td,this.j);const n=new Vu;zu(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"LANDMARKS:hand_landmarks"),Hu(n,"WORLD_LANDMARKS:world_hand_landmarks"),Hu(n,"HANDEDNESS:handedness"),n.o(t),Zu(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e)e=Rc(t),this.landmarks.push(Xd(e));ph(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{ph(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e)e=Sc(t),this.worldLandmarks.push(Jd(e));ph(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{ph(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{var n=this.handedness,r=n.push;const a=[];for(const t of e){e=uc(t);const n=[];for(const t of e.g())n.push({score:hl(t,2)??0,index:dl(ll(t,1))??-1,categoryName:cl(t,3)??""??"",displayName:cl(t,4)??""??""});a.push(n)}r.call(n,...a),ph(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Rf.prototype.detectForVideo=Rf.prototype.D,Rf.prototype.detect=Rf.prototype.F,Rf.prototype.setOptions=Rf.prototype.o,Rf.createFromModelPath=function(e,t){return tf(Rf,e,{baseOptions:{modelAssetPath:t}})},Rf.createFromModelBuffer=function(e,t){return tf(Rf,e,{baseOptions:{modelAssetBuffer:t}})},Rf.createFromOptions=function(e,t){return tf(Rf,e,t)},Rf.HAND_CONNECTIONS=Ef,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$hand_landmarker$hand_landmarker.HandLandmarker.HAND_CONNECTIONS",Rf.HAND_CONNECTIONS);var If=class extends sf{constructor(e,t){super(new ef(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},this.h=new Rd,e=new Jc,il(this.h,0,1,e)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){var t=Wd(e,nl(this.h,zc,2));return il(this.h,0,2,t),this.l(e)}ga(e,t){return this.j={classifications:[]},rf(this,e,t),this.j}ha(e,t,n){return this.j={classifications:[]},af(this,e,n,t),this.j}m(){var e=new tc;Qu(e,"input_image"),Qu(e,"norm_rect"),ec(e,"classifications");const t=new Nu;vl(t,Id,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),qu(n,"IMAGE:input_image"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"CLASSIFICATIONS:classifications"),n.o(t),Zu(e,n),this.g.attachProtoListener("classifications",((e,t)=>{this.j=function(e){const t={classifications:al(e,Fc,1).map((e=>Kd(nl(e,sc,4)?.g()??[],dl(ll(e,2)),cl(e,3)??"")))};return null!=ul(e)&&(t.timestampMs=dl(ul(e))),t}(Nc(e)),ph(this,t)})),this.g.attachEmptyPacketListener("classifications",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};If.prototype.classifyForVideo=If.prototype.ha,If.prototype.classify=If.prototype.ga,If.prototype.setOptions=If.prototype.o,If.createFromModelPath=function(e,t){return tf(If,e,{baseOptions:{modelAssetPath:t}})},If.createFromModelBuffer=function(e,t){return tf(If,e,{baseOptions:{modelAssetBuffer:t}})},If.createFromOptions=function(e,t){return tf(If,e,t)};var _f=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!0),this.h=new _d,this.embeddings={embeddings:[]},e=new Jc,il(this.h,0,1,e)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){var t=this.h,n=nl(this.h,Hc,2);return n=n?n.clone():new Hc,void 0!==e.l2Normalize?fl(n,1,e.l2Normalize):"l2Normalize"in e&&Gs(n,1),void 0!==e.quantize?fl(n,2,e.quantize):"quantize"in e&&Gs(n,2),il(t,0,2,n),this.l(e)}la(e,t){return rf(this,e,t),this.embeddings}ma(e,t,n){return af(this,e,n,t),this.embeddings}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"embeddings_out");const t=new Nu;vl(t,Dd,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"EMBEDDINGS:embeddings_out"),n.o(t),Zu(e,n),this.g.attachProtoListener("embeddings_out",((e,t)=>{e=Gc(e),this.embeddings=function(e){return{embeddings:al(e,Bc,1).map((e=>{const t={headIndex:dl(ll(e,3))??-1,headName:cl(e,4)??""??""};if(void 0!==tl(e,Oc,Zs(e,1)))e=Ws(e=nl(e,Oc,Zs(e,1)),1,us),t.floatEmbedding=e;else{const n=new Uint8Array(0);t.quantizedEmbedding=nl(e,Pc,Zs(e,2))?.da()?.fa()??n}return t})),timestampMs:dl(ul(e))}}(e),ph(this,t)})),this.g.attachEmptyPacketListener("embeddings_out",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};_f.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Qd(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Qd(Zd(e.quantizedEmbedding),Zd(t.quantizedEmbedding))}return e},_f.prototype.embedForVideo=_f.prototype.ma,_f.prototype.embed=_f.prototype.la,_f.prototype.setOptions=_f.prototype.o,_f.createFromModelPath=function(e,t){return tf(_f,e,{baseOptions:{modelAssetPath:t}})},_f.createFromModelBuffer=function(e,t){return tf(_f,e,{baseOptions:{modelAssetBuffer:t}})},_f.createFromOptions=function(e,t){return tf(_f,e,t)};var Df=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 Ff(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function Mf(e){try{const t=new Df(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{vh(e)}}Df.prototype.close=Df.prototype.close;var Lf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Od,this.v=new Fd,il(this.h,0,3,this.v),e=new Jc,il(this.h,0,1,e)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?Gs(this.h,2,gs(e.displayNamesLocale)):"displayNamesLocale"in e&&Gs(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=al(e.U(),Vu,1).filter((e=>(cl(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&&(nl(t[0],Nu,7)?.l()?.g()??new Map).forEach(((t,n)=>{e.s[Number(n)]=cl(t,1)??""}))}(this)}V(e,t,n){const r="function"!=typeof t?t:{};return this.j="function"==typeof t?t:n,Ff(this),rf(this,e,r),Mf(this)}ya(e,t,n,r){const a="function"!=typeof n?n:{};return this.j="function"==typeof n?n:r,Ff(this),af(this,e,a,t),Mf(this)}ra(){return this.s}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect");const t=new Nu;vl(t,Pd,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),n.o(t),Zu(e,n),gh(this,e),this.outputConfidenceMasks&&(ec(e,"confidence_masks"),Hu(n,"CONFIDENCE_MASKS:confidence_masks"),mh(this,"confidence_masks"),this.g.R("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>of(this,e,!this.j))),ph(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],ph(this,e)}))),this.outputCategoryMask&&(ec(e,"category_mask"),Hu(n,"CATEGORY_MASK:category_mask"),mh(this,"category_mask"),this.g.P("category_mask",((e,t)=>{this.categoryMask=of(this,e,!this.j),ph(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,ph(this,e)}))),ec(e,"quality_scores"),Hu(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,ph(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Lf.prototype.getLabels=Lf.prototype.ra,Lf.prototype.segmentForVideo=Lf.prototype.ya,Lf.prototype.segment=Lf.prototype.V,Lf.prototype.setOptions=Lf.prototype.o,Lf.createFromModelPath=function(e,t){return tf(Lf,e,{baseOptions:{modelAssetPath:t}})},Lf.createFromModelBuffer=function(e,t){return tf(Lf,e,{baseOptions:{modelAssetBuffer:t}})},Lf.createFromOptions=function(e,t){return tf(Lf,e,t)};var Nf=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){this.confidenceMasks?.forEach((e=>{e.close()})),this.categoryMask?.close()}};Nf.prototype.close=Nf.prototype.close;var Of=class extends yl{constructor(e){super(e)}},Pf=[0,nu,nu,nu],Bf=[0,Yl,Yl,Yl,Yl,iu],Uf=[0,Yl,Yl,Yl,Yl,iu,Yl,Yl],$f=[0,du,Uf],jf=[0,du,$f,du,Pf],Gf=[0,du,Uf,du,Pf],zf=[0,du,Uf,nu,nu],qf=[0,du,zf,du,Pf],Hf=[0,Yl,Yl,Yl,Yl,iu,du,Pf,du,Pf],Vf=[0,Yl,Yl,Yl,Yl,iu,mu],Wf=class extends yl{constructor(e){super(e)}},Kf=[0,Yl,Yl,iu],Yf=class extends yl{constructor(){super()}};Yf.B=[1];var Xf=class extends yl{constructor(e){super(e)}},Jf=[1,2,3,4,5,6,7,8,9,10,14,15],Zf=[0,fu,Uf,Jf,fu,Gf,Jf,fu,$f,Jf,fu,jf,Jf,fu,Kf,Jf,fu,Vf,Jf,fu,Bf,Jf,fu,[0,uu,Yl,Yl,Yl,iu,nu,iu,iu,Yl,3,du,Pf],Jf,fu,zf,Jf,fu,qf,Jf,Yl,du,Pf,uu,fu,Hf,Jf,fu,[0,hu,Kf],Jf],Qf=[0,uu,nu,nu,iu],ep=class extends yl{constructor(){super()}};ep.B=[1],ep.prototype.g=xu([0,hu,Zf,uu,du,Qf]);var tp=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Od,this.v=new Fd,il(this.h,0,3,this.v),e=new Jc,il(this.h,0,1,e)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(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 a="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 ep;const i=new Xf;var o=new Of;if(pl(o,1,255),il(i,0,12,o),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var s=new Wf;fl(s,3,!0),gl(s,1,t.keypoint.x),gl(s,2,t.keypoint.y),ol(i,5,Jf,s)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(s of(o=new Yf,t.scribble))fl(t=new Wf,3,!0),gl(t,1,s.x),gl(t,2,s.y),sl(o,Wf,t);ol(i,15,Jf,o)}sl(r,Xf,i),this.g.addProtoToStream(r.g(),"drishti.RenderData","roi_in",n),rf(this,e,a);e:{try{const e=new Nf(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=e;break e}this.j(e)}finally{vh(this)}l=void 0}return l}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"roi_in"),Qu(e,"norm_rect_in");const t=new Nu;vl(t,Pd,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),qu(n,"IMAGE:image_in"),qu(n,"ROI:roi_in"),qu(n,"NORM_RECT:norm_rect_in"),n.o(t),Zu(e,n),gh(this,e),this.outputConfidenceMasks&&(ec(e,"confidence_masks"),Hu(n,"CONFIDENCE_MASKS:confidence_masks"),mh(this,"confidence_masks"),this.g.R("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>of(this,e,!this.j))),ph(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],ph(this,e)}))),this.outputCategoryMask&&(ec(e,"category_mask"),Hu(n,"CATEGORY_MASK:category_mask"),mh(this,"category_mask"),this.g.P("category_mask",((e,t)=>{this.categoryMask=of(this,e,!this.j),ph(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,ph(this,e)}))),ec(e,"quality_scores"),Hu(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,ph(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};tp.prototype.segment=tp.prototype.V,tp.prototype.setOptions=tp.prototype.o,tp.createFromModelPath=function(e,t){return tf(tp,e,{baseOptions:{modelAssetPath:t}})},tp.createFromModelBuffer=function(e,t){return tf(tp,e,{baseOptions:{modelAssetBuffer:t}})},tp.createFromOptions=function(e,t){return tf(tp,e,t)};var np=class extends sf{constructor(e,t){super(new ef(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},this.h=new Bd,e=new Jc,il(this.h,0,1,e)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?Gs(this.h,2,gs(e.displayNamesLocale)):"displayNamesLocale"in e&&Gs(this.h,2),void 0!==e.maxResults?pl(this.h,3,e.maxResults):"maxResults"in e&&Gs(this.h,3),void 0!==e.scoreThreshold?gl(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&Gs(this.h,4),void 0!==e.categoryAllowlist?Js(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&Gs(this.h,5),void 0!==e.categoryDenylist?Js(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&Gs(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},rf(this,e,t),this.j}D(e,t,n){return this.j={detections:[]},af(this,e,n,t),this.j}m(){var e=new tc;Qu(e,"input_frame_gpu"),Qu(e,"norm_rect"),ec(e,"detections");const t=new Nu;vl(t,Ud,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),qu(n,"IMAGE:input_frame_gpu"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"DETECTIONS:detections"),n.o(t),Zu(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=wc(t),this.j.detections.push(Yd(e));ph(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function rp(e){e.landmarks=[],e.worldLandmarks=[],e.v=void 0}function ap(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{vh(e)}}np.prototype.detectForVideo=np.prototype.D,np.prototype.detect=np.prototype.F,np.prototype.setOptions=np.prototype.o,np.createFromModelPath=async function(e,t){return tf(np,e,{baseOptions:{modelAssetPath:t}})},np.createFromModelBuffer=function(e,t){return tf(np,e,{baseOptions:{modelAssetBuffer:t}})},np.createFromOptions=function(e,t){return tf(np,e,t)};var ip=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,this.h=new qd,e=new Jc,il(this.h,0,1,e),this.C=new Gd,il(this.h,0,3,this.C),this.j=new $d,il(this.h,0,2,this.j),pl(this.j,4,1),gl(this.j,2,.5),gl(this.C,2,.5),gl(this.h,4,.5)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){return"numPoses"in e&&pl(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&gl(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&gl(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&gl(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,rp(this),rf(this,e,r),ap(this)}D(e,t,n,r){const a="function"!=typeof n?n:{};return this.s="function"==typeof n?n:r,rp(this),af(this,e,a,t),ap(this)}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"normalized_landmarks"),ec(e,"world_landmarks"),ec(e,"segmentation_masks");const t=new Nu;vl(t,Vd,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"NORM_LANDMARKS:normalized_landmarks"),Hu(n,"WORLD_LANDMARKS:world_landmarks"),n.o(t),Zu(e,n),gh(this,e),this.g.attachProtoVectorListener("normalized_landmarks",((e,t)=>{this.landmarks=[];for(const t of e)e=Rc(t),this.landmarks.push(Xd(e));ph(this,t)})),this.g.attachEmptyPacketListener("normalized_landmarks",(e=>{this.landmarks=[],ph(this,e)})),this.g.attachProtoVectorListener("world_landmarks",((e,t)=>{this.worldLandmarks=[];for(const t of e)e=Sc(t),this.worldLandmarks.push(Jd(e));ph(this,t)})),this.g.attachEmptyPacketListener("world_landmarks",(e=>{this.worldLandmarks=[],ph(this,e)})),this.outputSegmentationMasks&&(Hu(n,"SEGMENTATION_MASK:segmentation_masks"),mh(this,"segmentation_masks"),this.g.R("segmentation_masks",((e,t)=>{this.v=e.map((e=>of(this,e,!this.s))),ph(this,t)})),this.g.attachEmptyPacketListener("segmentation_masks",(e=>{this.v=[],ph(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ip.prototype.detectForVideo=ip.prototype.D,ip.prototype.detect=ip.prototype.F,ip.prototype.setOptions=ip.prototype.o,ip.createFromModelPath=function(e,t){return tf(ip,e,{baseOptions:{modelAssetPath:t}})},ip.createFromModelBuffer=function(e,t){return tf(ip,e,{baseOptions:{modelAssetBuffer:t}})},ip.createFromOptions=function(e,t){return tf(ip,e,t)},ip.POSE_CONNECTIONS=Jh([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]),ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$pose_landmarker$pose_landmarker.PoseLandmarker.POSE_CONNECTIONS",ip.POSE_CONNECTIONS);var op;function sp(e,t,n,r){t.forEach((function(t){var a=t.keypoints.map((function(e){return[e.x,e.y]}));if(n){e.strokeStyle="#FF2C35",e.lineWidth=1;var i=t.box;!function(e,t,n){var r=new Path2D;r.moveTo(t[0][0],t[0][1]);for(var a=1;a<t.length;a++){var i=t[a];r.lineTo(i[0],i[1])}n&&r.closePath(),e.stroke(r)}(e,[[i.xMin,i.yMin],[i.xMax,i.yMin],[i.xMax,i.yMax],[i.xMin,i.yMax]],!0)}if(r){e.fillStyle="#32EEDB";for(var o=0;o<6;o++){var s=a[o][0],l=a[o][1];e.beginPath(),e.arc(s,l,3,0,2*Math.PI),e.fill()}}}))}function lp(){return g(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return op?[2,op]:[4,ah.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.6/wasm")];case 1:return e=t.sent(),[4,lf.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,op=t.sent()]}}))}))}var up,cp,dp,hp,fp,pp,gp=n.createContext({start:function(){return null},stop:function(){return null},onPredictionMade:function(){return null},canvasRef:{current:null},ready:!1}),mp=function(e){var t=e.autoStart,r=void 0===t||t,a=e.children,i=e.throttleMs,o=n.useContext(Mt),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),k=n.useRef(0),S=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,lp()];case 1:return e.current=t.sent(),y(!0),[2]}}))}))}),[]),n.useEffect((function(){if(l&&u&&w&&v){var e;S.current+=1;var t=S.current;return g(void 0,void 0,void 0,(function(){var n,r,a,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===(a=s.current)||void 0===a?void 0:a.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 a;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===S.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,a,i,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!==(a=null===(r=e.boundingBox)||void 0===r?void 0:r.originX)&&void 0!==a?a:0)+(null!==(s=null===(i=e.boundingBox)||void 0===i?void 0:i.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===(a=h.current)||void 0===a||a.call(h,c),n&&sp(n,c,!0,!0)),[3,6];case 5:return d=f.sent(),console.error("caught face detection error",d),[3,6];case 6:return i?e=setTimeout((function(){k.current=requestAnimationFrame(r)}),i):k.current=requestAnimationFrame(r),[2]}}))}))}()]):[2];case 1:return l.sent(),[2]}}))})),function(){k.current&&cancelAnimationFrame(k.current),e&&clearTimeout(e)}}}),[u,v,w,i,l,s]);var C=n.useCallback((function(){x(!0)}),[]),T=n.useCallback((function(){x(!1)}),[]);n.useEffect((function(){return r&&C(),function(){T()}}),[r,C,T]);var A=n.useCallback((function(e){h.current=e}),[]),R=n.useMemo((function(){return{start:C,stop:T,ready:v,canvasRef:d,onPredictionMade:A}}),[A,v,C,T]);return c.createElement(gp.Provider,{value:R},a)},vp=h.default.div(up||(up=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"})),yp=h.default.div(cp||(cp=y(["\n margin-left: auto;\n margin-right: auto;\n background: ",";\n color: ",";\n padding: 10px 12px 8px;\n border-radius: 8px;\n"],["\n margin-left: auto;\n margin-right: auto;\n background: ",";\n color: ",";\n padding: 10px 12px 8px;\n border-radius: 8px;\n"])),(function(e){var t=e.$background;return null!=t?t:"#ccc"}),(function(e){var t=e.$textColor;return null!=t?t:"black"})),bp={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},wp=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],a=!0,i=!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&&(a=Math.abs(e.videoWidth/2-d)>f||Math.abs(c+50-h)>g,i=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=!(a||i||o||s);return w?e.faceReady||(l=new Date):(l=null,u=0),p(p({},e),{faces:n,faceNotCentered:a,faceLookingAway:i,faceTooClose:o,faceTooFar:s,faceReady:w,faceReadyAt:l,goodFramesCount:u})}},xp=function(e){var t,r,a,i=e.onGuidanceSatisfied,o=e.onGuidanceNotSatisfied,s=e.onSelfieCaptured,l=e.onTimeout,c=e.onExit,d=e.timeoutDurationMs,h=void 0===d?15e3:d,f=e.guidanceMessage,p=e.colors,v=void 0===p?{}:p,y=e.verbiage,b=void 0===y?{}:y,w=e.debugMode,x=ye().t,E=kt(),k=E.ref,S=E.width,C=void 0===S?1:S,T=E.height,A=void 0===T?1:T,R=n.useReducer(wp,bp),I=R[0],_=R[1],D=n.useContext(Mt),F=D.cameraRef,M=D.cameraReady,L=D.takePhoto,N=D.videoRef,O=n.useContext(gp).onPredictionMade;n.useEffect((function(){M&&N.current&&0!==N.current.videoWidth&&_({type:"configure",payload:{videoWidth:N.current.videoWidth,videoHeight:N.current.videoHeight}})}),[M,N]),n.useEffect((function(){O((function(e){_({type:"facesDetected",payload:{faces:e}})}))}),[O]);var P=n.useState(!1),B=P[0],U=P[1];n.useEffect((function(){var e;return I.faceReady?(null==i||i(),e=setTimeout((function(){U(!0)}),500)):null==o||o(),function(){e&&clearTimeout(e)}}),[o,i,I.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 B&&I.faces.length>0?[4,L()]:[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(),I.faces[0]]),n.label=4;case 4:n.label=5;case 5:return[2]}}))}))}),[B,s,I.faces,L]);var $=n.useState(),j=$[0],G=$[1],z=n.useState(!1),q=z[0],H=z[1];n.useEffect((function(){if(h){G(new Date);var e=setTimeout((function(){H(!0)}),h);return function(){e&&clearTimeout(e)}}}),[h]),n.useEffect((function(){q&&(null==l||l())}),[l,q]);var V=Da({enabled:w,pageWidth:C,pageHeight:A,videoWidth:I.videoWidth,videoHeight:I.videoHeight});return v.guidesUnsatisfiedColor||(v.guidesUnsatisfiedColor="white"),v.guidesSatisfiedColor||(v.guidesSatisfiedColor="green"),v.guidanceMessagesUnsatisfiedBackgroundColor||(v.guidanceMessagesUnsatisfiedBackgroundColor="red"),v.guidanceMessagesSatisfiedBackgroundColor||(v.guidanceMessagesSatisfiedBackgroundColor="green"),v.guidanceMessagesUnsatisfiedTextColor||(v.guidanceMessagesUnsatisfiedTextColor="white"),v.guidanceMessagesSatisfiedTextColor||(v.guidanceMessagesSatisfiedTextColor="white"),f||(b.guidanceHoldStillText||(b.guidanceHoldStillText=x("Hold still for a few seconds...")),b.guidanceLookStraightText||(b.guidanceLookStraightText=x("Look straight into the camera...")),b.guidanceMoveBackText||(b.guidanceMoveBackText=x("Move back...")),b.guidanceMoveForwardText||(b.guidanceMoveForwardText=x("Move forward...")),b.guidanceMoveToCenterText||(b.guidanceMoveToCenterText=x("Move to the center...")),f=I.faceReady?b.guidanceHoldStillText:I.faceLookingAway?b.guidanceLookStraightText:I.faceTooClose?b.guidanceMoveBackText:I.faceTooFar?b.guidanceMoveForwardText:I.faceNotCentered?b.guidanceMoveToCenterText:""),u.default.createElement(Ze,{ref:k,className:"flex"},u.default.createElement(Ka,null),u.default.createElement(Qa,{borderColor:I.faceReady?v.guidesSatisfiedColor:v.guidesUnsatisfiedColor}),""!==f&&u.default.createElement(vp,null,u.default.createElement(yp,{$background:I.faceReady?v.guidanceMessagesSatisfiedBackgroundColor:v.guidanceMessagesUnsatisfiedBackgroundColor,$textColor:I.faceReady?v.guidanceMessagesSatisfiedTextColor:v.guidanceMessagesUnsatisfiedTextColor},f)),w&&I.faces.length>0&&u.default.createElement(Ra,{$flipX:!(null===(t=F.current)||void 0===t?void 0:t.isRearFacing)},I.faces.map((function(e,t){var n;return u.default.createElement(Ma,{key:t,face:e,scaling:V,flipX:!(null===(n=F.current)||void 0===n?void 0:n.isRearFacing),color:I.faceReady?"green":"red"})}))),w&&u.default.createElement(Aa,null,F.current?u.default.createElement(u.default.Fragment,null,"✅ Camera: ",null===(r=F.current)||void 0===r?void 0:r.width,"x",null===(a=F.current)||void 0===a?void 0:a.height):"❌ Camera not ready",u.default.createElement("br",null),I.faceNotCentered?"❌":"✅"," Face Centered",u.default.createElement("br",null),I.faceTooClose||I.faceTooFar?"❌":"✅"," Face"," ",I.faceTooClose?"Too Close":I.faceTooFar?"Too Far":"Distance Correct",u.default.createElement("br",null),I.faceLookingAway?"❌":"✅"," Face Looking Forward",u.default.createElement("br",null),I.goodFramesThresholdMet?"✅":"❌"," ",I.goodFramesCount," ","Good Frames",u.default.createElement("br",null),q?"❌":"✅"," Time Remaining:"," ",Math.max(0,h-((new Date).getTime()-(null!=j?j:new Date).getTime())),"ms"),u.default.createElement(Ba,{onClick:c},"×"))},Ep=h.default.div(dp||(dp=y(["\n display: inline-block;\n width: ","px;\n height: ","px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: ","px;\n height: ","px;\n margin: 8px;\n border-radius: 50%;\n border: ","px solid\n ",";\n border-color: "," transparent\n "," transparent;\n animation: lds-dual-ring 1.2s linear infinite;\n box-sizing: content-box;\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: ","px;\n height: ","px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: ","px;\n height: ","px;\n margin: 8px;\n border-radius: 50%;\n border: ","px solid\n ",";\n border-color: "," transparent\n "," transparent;\n animation: lds-dual-ring 1.2s linear infinite;\n box-sizing: content-box;\n }\n\n @keyframes lds-dual-ring {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n"])),(function(e){var t=e.$size;return null!=t?t:80}),(function(e){var t=e.$size;return null!=t?t:80}),(function(e){var t=e.$size;return(null!=t?t:80)-16}),(function(e){var t=e.$size;return(null!=t?t:80)-16}),(function(e){var t=e.$thickness;return null!=t?t:6}),(function(e){var t=e.$color;return null!=t?t:"#888"}),(function(e){var t=e.$color;return null!=t?t:"#888"}),(function(e){var t=e.$color;return null!=t?t:"#888"})),kp={frame:null,face:null,requestState:"NOT_READY",requestError:null,imageUrl:null,faceLive:!1,eyeCoveringDetected:!1,maskDetected:!1,headCoveringDetected:!1,phoneDetected:!1,timesLivenessCheckFailed:0},Sp=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,a=r.statusMessage,i=r.errorData,o=n.resultData;if("000"!==r.statusCode)return p(p({},e),{requestState:"ERROR",requestError:new Error("".concat(a,": ").concat(i))});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}},Cp=function(e){var t=e.onCapture,r=e.onSuccess,a=e.onTimeout,i=e.onExit,o=e.timeoutDurationMs,s=void 0===o?15e3:o,l=e.colors,c=void 0===l?{}:l,d=e.verbiage,h=void 0===d?{}:d,f=e.debugMode,p=ye().t,v=n.useContext(qe).checkLiveness,y=n.useReducer(Sp,kp),b=y[0],w=y[1],x=n.useState(null),E=x[0],k=x[1],S=n.useCallback((function(e,n){null==t||t(),w({type:"livenessReady",payload:{frame:e,face:n}})}),[t]),C=b.frame,T=b.face,A="READY"===b.requestState,R="PASSED"===b.requestState;n.useEffect((function(){C&&T&&A&&(w({type:"livenessChecking"}),g(void 0,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),e=da(C,T),k(e),n=v,[4,We(e)];case 1:return[4,n.apply(void 0,[a.sent()])];case 2:return t=a.sent(),w({type:"livenessChecked",payload:{frame:C,face:T,imageUrl:e,response:t}}),[3,4];case 3:return r=a.sent(),w({type:"livenessCheckFailed",payload:{error:r}}),[3,4];case 4:return[2]}}))})))}),[v,T,C,A]),n.useEffect((function(){R&&b.imageUrl&&(null==r||r(b.imageUrl))}),[r,b.imageUrl,R]),n.useEffect((function(){b.timesLivenessCheckFailed>=2&&(null==a||a())}),[a,b.timesLivenessCheckFailed]);var I=n.useState(!1),_=I[0],D=I[1];return n.useEffect((function(){if(s){var e=setTimeout((function(){D(!0)}),s);return function(){e&&clearTimeout(e)}}}),[s]),n.useEffect((function(){if(_&&"PASSED"!==b.requestState){if("IN_PROGRESS"===b.requestState){var e=setTimeout((function(){null==a||a()}),1e4);return function(){clearTimeout(e)}}null==a||a()}}),[a,b.requestState,_]),h.guidanceRemoveEyeCoveringsText||(h.guidanceRemoveEyeCoveringsText=p("Please remove your eye coverings (sunglasses, eye patch, etc.)...")),h.guidanceRemoveHeadCoveringsText||(h.guidanceRemoveHeadCoveringsText=p("Please remove your head coverings (hat, scarf, etc.)...")),h.guidanceRemoveMaskText||(h.guidanceRemoveMaskText=p("Please remove your mask...")),u.default.createElement(u.default.Fragment,null,u.default.createElement(xp,{onSelfieCaptured:S,onExit:i,timeoutDurationMs:s,guidanceMessage:b.eyeCoveringDetected?h.guidanceRemoveEyeCoveringsText:b.headCoveringDetected?h.guidanceRemoveHeadCoveringsText:b.maskDetected?h.guidanceRemoveMaskText:void 0,colors:c,verbiage:h,debugMode:f}),E&&u.default.createElement(Tp,{imageUrl:E}))},Tp=function(e){var t=e.imageUrl;return u.default.createElement(Ap,null,u.default.createElement(Rp,null,u.default.createElement(Ep,{$size:24,$color:"white",$thickness:3,style:{position:"relative",top:4,left:-3,margin:"0 3px 0 -12px"}}),"Processing..."),u.default.createElement(Ip,null,u.default.createElement("img",{src:t,alt:""})))},Ap=h.default.div(hp||(hp=y(["\n position: absolute;\n display: flex;\n flex-direction: column;\n height: 33%;\n bottom: 12px;\n right: 12px;\n"],["\n position: absolute;\n display: flex;\n flex-direction: column;\n height: 33%;\n bottom: 12px;\n right: 12px;\n"]))),Rp=h.default.div(fp||(fp=y(["\n display: block;\n position: absolute;\n top: -32px;\n font:\n 14px -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n Helvetica,\n Arial,\n sans-serif,\n 'Apple Color Emoji',\n 'Segoe UI Emoji',\n 'Segoe UI Symbol';\n color: white;\n text-align: center;\n margin: 0 auto;\n width: 100%;\n"],["\n display: block;\n position: absolute;\n top: -32px;\n font:\n 14px -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n Helvetica,\n Arial,\n sans-serif,\n 'Apple Color Emoji',\n 'Segoe UI Emoji',\n 'Segoe UI Symbol';\n color: white;\n text-align: center;\n margin: 0 auto;\n width: 100%;\n"]))),Ip=h.default.div(pp||(pp=y(["\n position: relative;\n height: calc(100% - 8px);\n padding: 4px;\n border-radius: 4px;\n background: white;\n\n & > img {\n border-radius: 4px;\n width: auto;\n max-height: 100%;\n }\n"],["\n position: relative;\n height: calc(100% - 8px);\n padding: 4px;\n border-radius: 4px;\n background: white;\n\n & > img {\n border-radius: 4px;\n width: auto;\n max-height: 100%;\n }\n"]))),_p=function(e){var t=e.headingText,r=e.removeEyeCoveringsText,a=e.avoidExcessiveBacklightingText,i=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(Mt).cameraReady,g=n.useContext(gp).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(ua,"/Selfie-Image-1.png"),t=t||d("Use your device camera to capture your face"),r=r||d("Remove Sunglasses & Hat"),a=a||d("Avoid Excessive Backlighting"),i=i||d("Continue"),o=o||d("Camera initializing..."),s=s||d("Models warming up..."),u.default.createElement(rt,null,u.default.createElement(at,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),a)),u.default.createElement(it,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?i:g?o:s)),u.default.createElement("div",{style:{display:"none"}},u.default.createElement(Ka,null)))))},Dp=function(e){var t=e.headingText,n=e.retryBtnText,r=e.doneBtnText,a=e.imageUrl,i=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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,null,u.default.createElement("img",{alt:t,src:a})),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:i,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},r)))))},Fp=function(e){var t=e.headingText,n=e.retryBtnText,r=e.exitBtnText,a=e.imageUrl,i=e.canRetry,o=void 0===i||i,s=e.onRetryClick,l=e.onExitClick,c=ye().t;return a=a||"".concat(ua,"/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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:a})),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)))))},Mp=function(e){var t=e.onComplete,r=e.onSuccess,a=e.onTimeout,i=e.onExitAfterFailure,o=e.timeoutDurationMs,s=void 0===o?15e3:o,l=e.maxRetries,c=void 0===l?2:l,d=e.assets,h=void 0===d?{}:d,f=e.colors,p=void 0===f?{}:f,v=e.verbiage,y=void 0===v?{}:v,b=e.debugMode,w=void 0!==b&&b,x=n.useContext(qe),E=x.submissionResponse,k=x.setSelfieImage,S=x.logSelfieCaptureAttempt,C=n.useContext(Mt).releaseCameraAccess,T=n.useState(""),A=T[0],R=T[1],I=n.useState(0),_=I[0],D=I[1],F=n.useState("LOADING"),M=F[0],L=F[1],N=n.useRef(),O=n.useRef(),P=n.useRef();n.useEffect((function(){P.current=new Date}),[]),n.useEffect((function(){"CAPTURING"===M&&(N.current=new Date)}),[M]);var B=n.useCallback((function(){O.current=new Date}),[]),U=n.useCallback((function(){var e,t,n;S({autoCapture:"Y",captureTime:(null!==(e=O.current)&&void 0!==e?e:new Date).getTime()-(null!==(t=N.current)&&void 0!==t?t:new Date).getTime(),operationTime:(new Date).getTime()-(null!==(n=P.current)&&void 0!==n?n:new Date).getTime()}),P.current=new Date}),[S]),$=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 L("SUCCESS"),R(e),t=k,[4,We(e)];case 1:return t.apply(void 0,[n.sent()]),null==r||r(E),[2]}}))}))}),[r,k,E]),j=n.useCallback((function(){L("FAILED"),null==a||a(E)}),[a,E]),G=n.useState(0),z=G[0],q=G[1],H=n.useCallback((function(){q((function(e){return e+1})),L("LOADING")}),[]);return u.default.createElement(u.default.Fragment,null,"LOADING"!==M&&function(){switch(M){case"CAPTURING":return u.default.createElement(Cp,{key:"capture",onCapture:B,onSuccess:$,onTimeout:j,onExit:H,timeoutDurationMs:s,colors:p,verbiage:y,debugMode:w});case"SUCCESS":return u.default.createElement(Dp,{key:"success",headingText:y.successHeadingText,retryBtnText:y.successRetryBtnText,doneBtnText:y.successDoneBtnText,imageUrl:A,onDoneClick:function(){U(),C(),setTimeout((function(){null==t||t(E)}),0)},onRetryClick:function(){U(),L("CAPTURING")}});case"FAILED":return u.default.createElement(Fp,{key:"failure",headingText:y.failureHeadingText,retryBtnText:y.failureRetryBtnText,exitBtnText:y.failureExitBtnText,imageUrl:h.failureImageUrl,canRetry:c>-1&&_<c,onRetryClick:function(){U(),D((function(e){return e+1})),L("CAPTURING")},onExitClick:function(){C(),setTimeout((function(){null==i||i(E)}),0)}});default:return null}}(),u.default.createElement(_p,{key:z,headingText:y.loadingOverlayHeadingText,removeEyeCoveringsText:y.loadingOverlayRemoveEyeCoveringsText,avoidExcessiveBacklightingText:y.loadingOverlayAvoidExcessiveBacklightingText,continueText:y.loadingOverlayContinueText,cameraInitializingText:y.loadingOverlayCameraInitializingText,modelsWarmingUpText:y.loadingOverlayModelsWarmingUpText,instructionImageUrl:h.instructionImageUrl,onDismissed:function(){L("CAPTURING")}}))};function Lp(){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 Np,Op=["front","avant","anteriore","cameraaanvoorzijde","kamerapåframsidan","forsidekamera","kamerapåforsiden","aparatprzedni","etukamera","kameradepan","ÖnKamera","cameramặttrước","camerăfață","prednákamera","prednjakamera","előlapikamera","přednífotoaparát","μπροστινήκάμερα","переднякамера","передняякамера","преднакамера","алдыңғыкамера","מצלמה קדמית","الكاميرا الأمامية","फ़्रंटकैमरा","前置相机","前置鏡頭","前面カメラ","전면카메라","กล้องด้านหน้า"].map((function(e){return e.toLocaleLowerCase().split(" ").join("")})),Pp=["back","rear","posterior","trasera","traseira","arrière","rückkamera","fotocamera(posteriore)","cameraaanachterzijde","kamerapåbaksidan","kamerapåbaksiden","bagsidekamera","aparattylny","takakamera","arkakamera","kamerabelakang","cameramặtsau","camerăspate","stražnjakamera","zadnákamera","hátoldalikamera","zadnífotoaparát","πίσωκάμερα","заднякамера","Задняякамера","заднакамера","артқыкамера","מצלמה אחורית","الكاميرا الخلفية","बैककैमरा","后置相机","後置鏡頭","背面カメラ","후면카메라","กล้องด้านหลัง"].map((function(e){return e.toLocaleLowerCase().split(" ").join("")})),Bp=["backultrawidecamera","ultraampliaposterior","ultra-angulartraseira","ultragrandeangulartraseira","ultragrandangle","ultragranangular","ultra-weitwinkelkamera","ultra-grandangolo","ultrabredecameraaanachterzijde","ultravidvinkelkamerapåbaksidan","ultravidvinkelkameraetpåbagsiden","ultravidvinkelkamerabak","ultragenişkameraarkayüzü","ultralaajakulmainentakakamera","tylnyaparatultraszerokokątny","cameracựcrộngmặtsau","camerăcuobiectivultra‑superangularspate","ultraszéleslátószögűkamera","kameraultralebarbelakang","stražnjaultraširokakamera","zadníultraširokoúhlýfotoaparát","ultraširokouhlá","πίσωυπερευρείακάμερα","заднянадширококутнакамера","Задняясверхширокоугольнаякамера","Задна свръх широкоъгълна камера","артқыультракеңбұрыштыкамера","מצלמה אולטרה רחבה אחורית","كاميرا خلفية عريضة جدًا","बैकअल्ट्रावाइडकैमरा","后置超广角相机","後置超廣角鏡頭相機","背面超広角カメラ","후면울트라와이드카메라","กล้องด้านหลังอัลตร้าไวด์"].map((function(e){return e.toLocaleLowerCase().split(" ").join("")})),Up=function(e,t){var n=e instanceof MediaDeviceInfo?$p(e):e;return("string"==typeof t?[t]:t).some((function(e){return n.includes(e)}))},$p=function(e){return e.label.toLocaleLowerCase().split(" ").join("")};function jp(){Np&&(console.log("releasing camera access..."),Np.release(),Np=void 0)}var Gp=function(e){var t=void 0===e?{preferFrontFacingCamera:!1,preferContinuityCamera:!0,requestMicrophoneAccess:!1}:e,r=t.preferFrontFacingCamera,a=void 0!==r&&r,i=t.preferContinuityCamera,o=void 0===i||i,s=t.requestMicrophoneAccess,l=void 0!==s&&s,u=n.useRef(null),c=n.useRef(null),d=n.useState(null),h=d[0],f=d[1],p=n.useState(!1),y=p[0],b=p[1],w=n.useState(null),x=w[0],E=w[1],k=n.useState(!1),S=k[0],C=k[1],T=n.useState(o),A=T[0],R=T[1],I=n.useState(!1),_=I[0],D=I[1],F=n.useState(!1),M=F[0],L=F[1];n.useEffect((function(){console.log("iphone continuity camera allowed changed",A),jp(),c.current=null,b(!1)}),[A]);var N=n.useCallback((function(){L(!1)}),[]);n.useEffect((function(){M||function(e){return g(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,navigator.mediaDevices.getUserMedia({video:{facingMode:{exact:e}},audio:!1})];case 1:return t=r.sent(),[3,3];case 2:return r.sent(),[2,[]];case 3:return[4,navigator.mediaDevices.enumerateDevices()];case 4:return n=r.sent().filter((function(e){return"videoinput"===e.kind})),t.getVideoTracks().forEach((function(e){e.enabled=!1,e.stop()})),t=null,[2,n]}}))}))}().then((function(e){var t,n=mt();if(!(_||n&&"OS X"!==n.os.family)){var r=e.find((function(e){return Up(e,"iphone")}));C(!!r),r&&A&&(t=r)}a&&(t||(t=e.find((function(e){return Up(e,Op)})))),Lp()?t||(t=e.find((function(e){return Up(e,Bp)}))):t||(t=e.find((function(e){return Up(e,Pp)&&!Up(e,Bp)}))),t||(t=e.find((function(e){return Up(e,Pp)}))),!a&&"iOS"===(null==n?void 0:n.os.family)&&e.length>0&&(t||(t=e[1])),t||(t=e[0]),f(t)})).catch((function(e){if("NotAllowedError"!==e.name)throw e;console.error("camera access has been blocked by the user",e),L(!0)}))}),[M,A,_,a]),n.useEffect((function(){var e;if(h){var t=function(){jp(),c.current=null,b(!1)};return(null===(e=navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia)?(g(void 0,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:l,video:{deviceId:{exact:h.deviceId},width:{ideal:1920},aspectRatio:1.777777778}})];case 2:return e=t.sent(),[3,4];case 3:return"NotAllowedError"===t.sent().name?(A?(C(!1),D(!0)):L(!0),[2]):[3,4];case 4:if(e)return[3,8];t.label=5;case 5:return t.trys.push([5,7,,8]),[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 6:return e=t.sent(),console.log("opened stream with no width and height constraints"),[3,8];case 7:return t.sent(),console.log("cannot open stream at all"),[3,8];case 8:if(!e)throw new Error("failed to open camera");return e.getVideoTracks()[0].onended=function(){var e;S&&A?(console.log("someone unplugged the continuity camera"),C(!1),D(!0)):(console.log("someone unplugged the webcam"),null===(e=c.current)||void 0===e||e.release(),c.current=null,b(!1),L(!0),E(null))},c.current=function(e,t,n){jp(),console.log("obtaining camera access...");var r=e.getVideoTracks()[0].getSettings(),a=r.width,i=r.height,o=t.toLocaleLowerCase().split(" ").join(""),s=Up(o,v(v(v([],Pp,!0),Bp,!0),["iphone"],!1));return a||(a=0),i||(i=0),Np={stream:e,width:a,height:i,isRearFacing:s,release:function(){e.getTracks().forEach((function(e){e.enabled=!1,e.stop()})),n&&(n.pause(),n.srcObject=null,n.src="")}},n&&(n.srcObject=e),Np}(e,h.label,u.current),[2]}}))})),t):t}}),[A,S,l,h]),n.useEffect((function(){E(null),y&&g(void 0,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(a){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])?(E(new ImageCapture(e)),[2]):[2]}))}))}),[y]);var O=n.useCallback((function(){return g(void 0,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return x?[4,x.grabFrame()]:[2,null];case 1:return[2,e.sent()]}}))}))}),[x]),P=n.useCallback((function(){return g(void 0,void 0,void 0,(function(){var e,t,n,r,a;return m(this,(function(i){switch(i.label){case 0:return e=document.createElement("canvas"),(t=e.getContext("2d"))&&c.current&&u.current?(e.width=null===(r=u.current)||void 0===r?void 0:r.videoWidth,e.height=null===(a=u.current)||void 0===a?void 0:a.videoHeight,t.drawImage(u.current,0,0,e.width,e.height),n=e.toDataURL("image/jpeg",.98),[4,fetch(n)]):[2,null];case 1:return[4,i.sent().blob()];case 2:return[2,i.sent()]}}))}))}),[]);return{videoRef:u,videoDevice:h,videoLoaded:y,setVideoLoaded:b,cameraRef:c,cameraAccessDenied:M,retryCameraAccess:N,releaseCameraAccess:jp,iphoneContinuityCameraAvailable:S,iphoneContinuityCameraAllowed:A,setIphoneContinuityCameraAllowed:R,captureDevice:x,grabFrame:O,takePhoto:P}},zp=function(e){var t=e.children,r=e.preferFrontFacingCamera,a=e.preferContinuityCamera,i=e.requestMicrophoneAccess,o=Gp({preferFrontFacingCamera:void 0!==r&&r,preferContinuityCamera:void 0===a||a,requestMicrophoneAccess:void 0!==i&&i}),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],k=x[1];return n.useEffect((function(){k(!1),w&&k(!0)}),[w]),n.useEffect((function(){return function(){p()}}),[p]),u.default.createElement(Mt.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)},qp=function(e){var t=e.children,r=n.useState({width:1,height:1}),a=r[1],i=n.useState(1),o=i[0],s=i[1],l=kt(),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:a,wrapperRef:c,onImageLoaded:m}},t)},Hp=function(){var e=n.useContext(qe),t=e.submissionRequest,r=e.submissionResponse,a=n.useState(!1),i=a[0],o=a[1],s=n.useState(!0),l=s[0],c=s[1],d=n.useMemo((function(){var e,n,r,a,i,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=Vp(s.customerData.idData.idImageFront,200)),(null===(a=null===(r=null==s?void 0:s.customerData)||void 0===r?void 0:r.idData)||void 0===a?void 0:a.idImageBack)&&(s.customerData.idData.idImageBack=Vp(s.customerData.idData.idImageBack,200)),(null===(o=null===(i=null==s?void 0:s.customerData)||void 0===i?void 0:i.biometricData)||void 0===o?void 0:o.selfie)&&(s.customerData.biometricData.selfie=Vp(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(!i)}},i?"Hide":"Show"," request body"),i&&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 Vp(e,t){var n=e.split("").splice(0,t).join("");return n.length<e.length&&(n+="..."),n}var Wp=function(e){var t=e.document,r=e.onComplete,a=e.headingText,i=e.nextBtnText,o=ye().t,s=n.useState(null),l=s[0],c=s[1];return a=a||o("Additional document capture"),i=i||o("Next"),u.default.createElement(rt,null,u.default.createElement(at,{style:{textAlign:"left"}},u.default.createElement("h3",{style:{margin:"0 0 8px"}},a,": ",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)}}},i))))},Kp=function(e){var t=e.documents,r=e.onComplete,a=e.verbiage,i=void 0===a?{}:a,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(Wp,{key:c,headingText:i.headingText,nextBtnText:i.nextBtnText,document:d,onComplete:function(e){l((function(t){return v(v([],t,!0),[e],!1)}))}})},Yp="function"==typeof Symbol&&Symbol.for,Xp=Yp?Symbol.for("react.element"):60103,Jp=Yp?Symbol.for("react.portal"):60106,Zp=Yp?Symbol.for("react.fragment"):60107,Qp=Yp?Symbol.for("react.strict_mode"):60108,eg=Yp?Symbol.for("react.profiler"):60114,tg=Yp?Symbol.for("react.provider"):60109,ng=Yp?Symbol.for("react.context"):60110,rg=Yp?Symbol.for("react.async_mode"):60111,ag=Yp?Symbol.for("react.concurrent_mode"):60111,ig=Yp?Symbol.for("react.forward_ref"):60112,og=Yp?Symbol.for("react.suspense"):60113,sg=Yp?Symbol.for("react.suspense_list"):60120,lg=Yp?Symbol.for("react.memo"):60115,ug=Yp?Symbol.for("react.lazy"):60116,cg=Yp?Symbol.for("react.block"):60121,dg=Yp?Symbol.for("react.fundamental"):60117,hg=Yp?Symbol.for("react.responder"):60118,fg=Yp?Symbol.for("react.scope"):60119;function pg(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case Xp:switch(e=e.type){case rg:case ag:case Zp:case eg:case Qp:case og:return e;default:switch(e=e&&e.$$typeof){case ng:case ig:case ug:case lg:case tg:return e;default:return t}}case Jp:return t}}}function gg(e){return pg(e)===ag}var mg={AsyncMode:rg,ConcurrentMode:ag,ContextConsumer:ng,ContextProvider:tg,Element:Xp,ForwardRef:ig,Fragment:Zp,Lazy:ug,Memo:lg,Portal:Jp,Profiler:eg,StrictMode:Qp,Suspense:og,isAsyncMode:function(e){return gg(e)||pg(e)===rg},isConcurrentMode:gg,isContextConsumer:function(e){return pg(e)===ng},isContextProvider:function(e){return pg(e)===tg},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===Xp},isForwardRef:function(e){return pg(e)===ig},isFragment:function(e){return pg(e)===Zp},isLazy:function(e){return pg(e)===ug},isMemo:function(e){return pg(e)===lg},isPortal:function(e){return pg(e)===Jp},isProfiler:function(e){return pg(e)===eg},isStrictMode:function(e){return pg(e)===Qp},isSuspense:function(e){return pg(e)===og},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===Zp||e===ag||e===eg||e===Qp||e===og||e===sg||"object"==typeof e&&null!==e&&(e.$$typeof===ug||e.$$typeof===lg||e.$$typeof===tg||e.$$typeof===ng||e.$$typeof===ig||e.$$typeof===dg||e.$$typeof===hg||e.$$typeof===fg||e.$$typeof===cg)},typeOf:pg};ae((function(e,t){}));ae((function(e){e.exports=mg}));function vg(){}function yg(){}yg.resetWarningCache=vg;var bg=ae((function(e){e.exports=function(){function e(e,t,n,r,a,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){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:yg,resetWarningCache:vg};return n.PropTypes=n,n}()}));function wg(e,t,n){this.x=e,this.y=t,this.time=n||(new Date).getTime()}function xg(e,t,n,r){this.startPoint=e,this.control1=t,this.control2=n,this.endPoint=r}function Eg(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,a,i,o=null,s=0;n||(n={});var l=function(){s=!1===n.leading?0:Date.now(),o=null,i=e.apply(r,a),o||(r=a=null)};return function(){var u=Date.now();s||!1!==n.leading||(s=u);var c=t-(u-s);return r=this,a=arguments,c<=0||c>t?(o&&(clearTimeout(o),o=null),s=u,i=e.apply(r,a),o||(r=a=null)):o||!1===n.trailing||(o=setTimeout(l,c)),i}}(Eg.prototype._strokeUpdate,this.throttle):Eg.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()}wg.prototype.velocityFrom=function(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):1},wg.prototype.distanceTo=function(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))},wg.prototype.equals=function(e){return this.x===e.x&&this.y===e.y&&this.time===e.time},xg.prototype.length=function(){for(var e=0,t=void 0,n=void 0,r=0;r<=10;r+=1){var a=r/10,i=this._point(a,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),o=this._point(a,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){var s=i-t,l=o-n;e+=Math.sqrt(s*s+l*l)}t=i,n=o}return e},xg.prototype._point=function(e,t,n,r,a){return t*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*r*(1-e)*e*e+a*e*e*e},Eg.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},Eg.prototype.fromDataURL=function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new Image,a=n.ratio||window.devicePixelRatio||1,i=n.width||this._canvas.width/a,o=n.height||this._canvas.height/a;this._reset(),r.src=e,r.onload=function(){t._ctx.drawImage(r,0,0,i,o)},this._isEmpty=!1},Eg.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),a=1;a<n;a++)r[a-1]=arguments[a];return(t=this._canvas).toDataURL.apply(t,[e].concat(r))},Eg.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},Eg.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)},Eg.prototype.isEmpty=function(){return this._isEmpty},Eg.prototype._strokeBegin=function(e){this._data.push([]),this._reset(),this._strokeUpdate(e),"function"==typeof this.onBegin&&this.onBegin(e)},Eg.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],a=r&&t.distanceTo(r)<this.minDistance;if(!r||!a){var i=this._addPoint(t),o=i.curve,s=i.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})}},Eg.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)},Eg.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)},Eg.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)},Eg.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._ctx.fillStyle=this.penColor},Eg.prototype._createPoint=function(e,t,n){var r=this._canvas.getBoundingClientRect();return new wg(e-r.left,t-r.top,n||(new Date).getTime())},Eg.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 a=new xg(t[1],r,n.c1,t[2]),i=this._calculateCurveWidths(a);return t.shift(),{curve:a,widths:i}}return{}},Eg.prototype._calculateCurveControlPoints=function(e,t,n){var r=e.x-t.x,a=e.y-t.y,i=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+a*a),h=Math.sqrt(i*i+o*o),f=h/(d+h),p=t.x-(u+(s-u)*f),g=t.y-(c+(l-c)*f);return{c1:new wg(s+p,l+g),c2:new wg(u+p,c+g)}},Eg.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},Eg.prototype._strokeWidth=function(e){return Math.max(this.maxWidth/(e+1),this.minWidth)},Eg.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},Eg.prototype._drawCurve=function(e,t,n){var r=this._ctx,a=n-t,i=Math.floor(e.length());r.beginPath();for(var o=0;o<i;o+=1){var s=o/i,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*a)}r.closePath(),r.fill()},Eg.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()},Eg.prototype._fromData=function(e,t,n){for(var r=0;r<e.length;r+=1){var a=e[r];if(a.length>1)for(var i=0;i<a.length;i+=1){var o=a[i],s=new wg(o.x,o.y,o.time),l=o.color;if(0===i)this.penColor=l,this._reset(),this._addPoint(s);else if(i!==a.length-1){var u=this._addPoint(s),c=u.curve,d=u.widths;c&&d&&t(c,d,l)}}else this._reset(),n(a[0])}},Eg.prototype._toSVG=function(){var e=this,t=this._data,n=this._canvas,r=Math.max(window.devicePixelRatio||1,1),a=n.width/r,i=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 a="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",a),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 '+a+" "+i+'" width="'+a+'" height="'+i+'">',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>")},Eg.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},Eg.prototype.toData=function(){return this._data};var kg=Object.freeze({__proto__:null,default:Eg}),Sg=ae((function(e,t){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,t),a.loaded=!0,a.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,a=t.getImageData(0,0,n,r).data,s=i(!0,n,r,a),l=i(!1,n,r,a),u=o(!0,n,r,a),c=o(!1,n,r,a)-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 a(e,t,n,a){return r(e,t,n,a).alpha}function i(e,t,n,r){for(var i=e?1:-1,o=e?0:n-1;e?o<n:o>-1;o+=i)for(var s=0;s<t;s++)if(a(s,o,t,r))return o;return null}function o(e,t,n,r){for(var i=e?1:-1,o=e?0:t-1;e?o<t:o>-1;o+=i)for(var s=0;s<n;s++)if(a(o,s,t,r))return o;return null}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n}])}));re(Sg);var Cg=function(e){return e&&e.default||e}(kg),Tg=ae((function(e,t){e.exports=function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,t),a.loaded=!0,a.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 a(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 i(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;i(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 a(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 a=r._canvas,i=Math.max(window.devicePixelRatio||1,1);t||(a.width=a.offsetWidth*i),n||(a.height=a.offsetHeight*i),a.getContext("2d").scale(i,i),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}])}(bg,u.default,Cg,Sg)})),Ag=re(Tg);function Rg(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=[],a=[];e.forEach((function(e){t.push(e.x),n.push(e.y),a.push(new Date(e.time).toString())})),r.clickX_simple.push(t),r.clickY_simple.push(n),r.time_simple.push(a)})),r}var Ig,_g,Dg,Fg,Mg,Lg=h.default.div(Ig||(Ig=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"]))),Ng=h.default.div(_g||(_g=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"]))),Og=h.default.div(Dg||(Dg=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"]))),Pg=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"]))),Bg=function(e){var t=e.onAccept,r=e.verbiage,a=void 0===r?{}:r,i=ye().t,o=kt(),s=o.ref,l=o.width,c=o.height,d=n.useRef(null);return a.headingText=a.headingText||i("Please sign the box below"),a.acceptBtnText=a.acceptBtnText||i("Accept"),a.clearBtnText=a.clearBtnText||i("Clear"),u.default.createElement(Ze,null,u.default.createElement(Pg,null,u.default.createElement(vp,{$top:"5vh"},u.default.createElement(yp,null,a.headingText)),u.default.createElement(Lg,null,u.default.createElement(Ng,{ref:s},u.default.createElement(Ag,{ref:d,canvasProps:{width:l,height:c}})),u.default.createElement(Og,null,u.default.createElement("button",{onClick:function(e){var t;e.preventDefault(),null===(t=d.current)||void 0===t||t.clear()}},a.clearBtnText),u.default.createElement("button",{style:{marginLeft:"auto"},onClick:function(e){if(e.preventDefault(),d.current){var n=Rg(d.current);null==t||t(n,d.current.toDataURL())}}},a.acceptBtnText)))))},Ug=function(e){var t,r,a=e.onComplete,i=e.onFaceNotDetected,o=e.onExit,s=e.colors,l=void 0===s?{}:s,c=e.verbiage,d=void 0===c?{}:c,h=e.debugMode,f=void 0!==h&&h,p=ye().t,y=n.useContext(Mt),b=y.cameraRef,w=y.videoRef,x=kt(),E=x.ref,k=x.width,S=x.height,C=n.useRef(null),T=n.useRef(null),A=n.useRef([]),R=n.useState(null),I=R[0],_=R[1],D=n.useContext(gp).onPredictionMade,F=function(e){var t=n.useRef(null),r=n.useRef([]),a=n.useState(null),i=a[0],o=a[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:i}}(b.current),M=F.isRecording,L=F.startRecording,N=F.stopRecording,O=F.videoUrl,P=n.useState(null),B=P[0],U=P[1],$=n.useState(null),j=$[0],G=$[1],z=n.useState(null),q=z[0],H=z[1];l.guidanceMessageBackgroundColor||(l.guidanceMessageBackgroundColor="#ccc"),l.guidanceMessageTextColor||(l.guidanceMessageTextColor="black"),d.guidanceMessageText||(d.guidanceMessageText=p("Please sign the box below")),d.acceptBtnText||(d.acceptBtnText=p("Accept")),d.clearBtnText||(d.clearBtnText=p("Clear"));var V=n.useRef(null);n.useEffect((function(){setTimeout((function(){if(!M&&!O&&V.current){L();var e=V.current.captureStream(25);T.current=new MediaRecorder(e,{}),T.current.start(),T.current.ondataavailable=function(e){var t;A.current.push(e.data),"recording"===(null===(t=T.current)||void 0===t?void 0:t.state)&&T.current.stop()},T.current.onstop=function(){var e=new Blob(A.current,{type:"video/mp4"});H(e);var t=URL.createObjectURL(e);_(t)}}}),100)}),[M,L,O]),n.useEffect((function(){q&&B&&j&&(null==a||a(B,j,q))}),[a,B,j,q]);var W=n.useRef(0);n.useEffect((function(){var e;if(C.current&&w.current&&V.current&&b.current&&M){var t=[b.current.width,b.current.height],n=t[0],r=t[1],a=window.innerWidth<window.innerHeight;a&&n>r&&(n=(e=[r,n])[0],r=e[1]),V.current.width=n,V.current.height=r;var i=V.current.getContext("2d");if(i)return W.current=requestAnimationFrame((function e(){return g(this,void 0,void 0,(function(){var t;return m(this,(function(o){return C.current&&w.current&&V.current?(t=[n*(a?.02:.15),r*(a?.15:.25),n*(a?.96:.7),r*(a?.7:.5)],i.drawImage(w.current,0,0,n,r),i.beginPath(),i.fillStyle="rgba(255,255,255,0.5)",i.roundRect.apply(i,v(v([],t,!1),[16],!1)),i.fill(),i.drawImage.apply(i,v([C.current.getCanvas()],t,!1)),W.current=requestAnimationFrame(e),[2]):(cancelAnimationFrame(W.current),[2])}))}))})),function(){cancelAnimationFrame(W.current)}}}),[b,M,i,w]);var K=n.useState(0),Y=K[0],X=K[1];return n.useEffect((function(){D((function(e){X((function(t){return 0===e.length?t+1:0}))}))}),[D]),n.useEffect((function(){Y>=2&&(null==i||i())}),[Y,i]),!M&&O?u.default.createElement(u.default.Fragment,null,I&&u.default.createElement("video",{src:I,controls:!0,width:"100%"}),j&&u.default.createElement("img",{src:j,alt:"signature"}),B&&u.default.createElement("textarea",{readOnly:!0,style:{width:"100%",height:500},value:JSON.stringify(B,null,2)})):u.default.createElement(Ze,{className:"flex"},u.default.createElement(Ka,null),d.guidanceMessageText&&u.default.createElement(vp,{$top:"5vh"},u.default.createElement(yp,{$background:l.guidanceMessageBackgroundColor,$textColor:l.guidanceMessageTextColor},d.guidanceMessageText)),u.default.createElement(Lg,null,u.default.createElement(Ng,{ref:E},u.default.createElement(Ag,{ref:C,canvasProps:{width:k,height:S}})),u.default.createElement(Og,null,u.default.createElement("button",{onClick:function(e){var t;e.preventDefault(),null===(t=C.current)||void 0===t||t.clear()}},d.clearBtnText),u.default.createElement("button",{style:{marginLeft:"auto"},onClick:function(e){var t;if(e.preventDefault(),C.current){var n=Rg(C.current);U(n),G(C.current.toDataURL()),N(),null===(t=T.current)||void 0===t||t.stop()}}},d.acceptBtnText))),f&&u.default.createElement(Aa,null,"Video: ",null===(t=b.current)||void 0===t?void 0:t.width,"x",null===(r=b.current)||void 0===r?void 0:r.height),u.default.createElement(Ba,{onClick:o},"×"),u.default.createElement("div",{style:{display:"none"}},u.default.createElement("canvas",{ref:V})))},$g=function(e){return u.default.createElement(_p,{headingText:e.headingText,removeEyeCoveringsText:e.removeEyeCoveringsText,avoidExcessiveBacklightingText:e.avoidExcessiveBacklightingText,continueText:e.continueText,cameraInitializingText:e.cameraInitializingText,modelsWarmingUpText:e.modelsWarmingUpText,instructionImageUrl:e.instructionImageUrl,onDismissed:e.onDismissed})},jg=function(e){var t=e.videoUrl,n=e.headingText,r=e.retryBtnText,a=e.doneBtnText,i=e.onDoneClick,o=e.onRetryClick,s=ye().t;return n||(n=s("Signature KYC Successful")),r||(r=s("Retry")),a||(a=s("Done")),u.default.createElement(rt,null,u.default.createElement(at,null,u.default.createElement("h1",null,n),u.default.createElement(it,null,u.default.createElement(Gg,{src:t,poster:t+"#t=0.1",controls:!0,preload:"metadata",autoPlay:!0})),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"},r)),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"mint",onClick:i,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},a)))))},Gg=h.default.video(Mg||(Mg=y(["\n margin-left: auto;\n margin-right: auto;\n max-width: 100%;\n"],["\n margin-left: auto;\n margin-right: auto;\n max-width: 100%;\n"]))),zg=function(e){var t=e.onComplete,r=e.onRetryClicked,a=e.colors,i=void 0===a?{}:a,o=e.verbiage,s=void 0===o?{}:o,l=e.debugMode,c=void 0!==l&&l,d=n.useContext(qe),h=d.submit,f=d.selfieImage,p=d.signatureVideo,v=d.setSelfieImage,y=d.setSignatureData,b=d.setSignatureVideo,w=d.logSelfieCaptureAttempt,x=n.useState("LOADING"),E=x[0],k=x[1],S=n.useRef(),C=n.useRef(),T=n.useRef();n.useEffect((function(){S.current=new Date}),[]),n.useEffect((function(){"CHECKING_LIVENESS"===E&&(C.current=new Date)}),[E]);var A=n.useCallback((function(){var e,t,n;w({autoCapture:"Y",captureTime:(null!==(e=T.current)&&void 0!==e?e:new Date).getTime()-(null!==(t=C.current)&&void 0!==t?t:new Date).getTime(),operationTime:(new Date).getTime()-(null!==(n=S.current)&&void 0!==n?n:new Date).getTime()}),S.current=new Date}),[w]),R=n.useCallback((function(){k("CHECKING_LIVENESS")}),[]),I=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 k("CAPTURING_SIGNATURE"),A(),f?[3,2]:(t=v,[4,We(e)]);case 1:t.apply(void 0,[n.sent()]),n.label=2;case 2:return[2]}}))}))}),[A,f,v]),_=n.useCallback((function(e,n,r){y(e),b(URL.createObjectURL(r)),k("SUCCESS"),null==t||t()}),[t,y,b]),D=n.useCallback((function(){k("CHECKING_LIVENESS")}),[]),F=n.useState(0),M=F[0],L=F[1],N=n.useCallback((function(){L((function(e){return e+1})),k("LOADING")}),[]);return u.default.createElement(mp,{throttleMs:"CAPTURING_SIGNATURE"===E?250:0},"LOADING"!==E&&function(){var e,t,n;switch(E){case"CHECKING_LIVENESS":return u.default.createElement(Cp,{onSuccess:I,onExit:N,colors:i.faceLiveness,verbiage:s.faceLiveness,debugMode:c});case"CAPTURING_SIGNATURE":return u.default.createElement(Ug,{onComplete:_,onFaceNotDetected:D,onExit:N,colors:i.videoSignatureCapture,verbiage:s.videoSignatureCapture,debugMode:c});case"SUCCESS":return u.default.createElement(jg,{videoUrl:null!=p?p:"",onDoneClick:h,onRetryClick:r,headingText:null===(e=s.success)||void 0===e?void 0:e.headingText,retryBtnText:null===(t=s.success)||void 0===t?void 0:t.retryBtnText,doneBtnText:null===(n=s.success)||void 0===n?void 0:n.doneBtnText});default:return null}}(),u.default.createElement($g,{key:M,onDismissed:R}))},qg=function(e){var t,r,a,i,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,k=void 0!==E&&E,S=n.useContext(qe),C=S.submit,T=S.submissionStatus,A=S.setSignatureData,R=S.setAdditionalDocuments,I=n.useState(0),_=I[0],D=I[1],F=n.useMemo((function(){var e,t,n=v([],s,!0);if(x&&k)throw new Error("captureSignature and captureSignatureVideo cannot be used together");return x&&n.push("SignatureCapture"),k&&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,k,s]),M=F[_],L=_>=F.length;n.useEffect((function(){"SignatureCapture"===M&&"function"==typeof x?x().then((function(e){e||D((function(e){return e+1}))})):"SignatureKYC"===M&&"function"==typeof k&&k().then((function(e){e||D((function(e){return e+1}))}))}),[x,k,M]),n.useEffect((function(){L&&C()}),[L,C]);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(L)switch(T){case je.SUBMITTING:return u.default.createElement(Ze,{className:"flex"},u.default.createElement(Ep,null));case je.SUBMITTED:return u.default.createElement(Hp,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(ma,{documentDetectionModelUrl:null!==(a=null===(r=c.assets)||void 0===r?void 0:r.documentDetectionModelUrl)&&void 0!==a?a:"",focusModelUrl:null!==(o=null===(i=c.assets)||void 0===i?void 0:i.focusModelUrl)&&void 0!==o?o:""},function(){switch(F[_]){case"IdCapture":return u.default.createElement(zp,{key:"IdCaptureCamera"},u.default.createElement(qp,null,u.default.createElement(Za,p({},c,{onSuccess:O}))));case"FaceLiveness":return u.default.createElement(zp,{key:"FaceLivenessCamera",preferFrontFacingCamera:!0,preferContinuityCamera:!1},u.default.createElement(mp,null,u.default.createElement(Mp,p({},h,{onComplete:B}))));case"SignatureCapture":return u.default.createElement(Bg,p({},g,{onAccept:U}));case"SignatureKYC":return u.default.createElement(zp,{key:"SignatureKycCamera",preferContinuityCamera:!1,preferFrontFacingCamera:!0,requestMicrophoneAccess:!0},u.default.createElement(zg,p({},y,{onComplete:j})));case"AdditionalDocumentCapture":return u.default.createElement(Kp,p({},b,{documents:q,onComplete:z}));default:return u.default.createElement(u.default.Fragment,null)}}())},Hg={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","Signature KYC Successful":"Captura de Video Firma exitosa"}}},Vg=function(e){var t=ye().i18n;n.useEffect((function(){"auto"!==e?t.changeLanguage(e):t.changeLanguage()}),[t,e])},Wg=function(e){var t=e.lang,r=e.submissionToken,a=e.submissionEnvironment,i=void 0===a?"prod":a,o=e.submissionUrl,s=e.companyId,l=e.manualReviewRequired,c=e.verifyIdWithExternalDatabases,d=e.personalData,h=e.cardData,f=e.webhooksEnabled,p=e.webhooksClientTraceId,g=e.webhooksStripSpecialCharacters,m=e.idAutoCaptureEnabled,v=void 0===m||m,y=e.idCardAutoCaptureScoreThreshold,b=void 0===y?.8:y,w=e.passportAutoCaptureScoreThreshold,x=void 0===w?.8:w,E=e.idCardFocusScoreThreshold,k=void 0===E?.3:E,S=e.passportFocusScoreThreshold,C=void 0===S?.3:S,T=e.onBeforeSubmit,A=e.onComplete,R=e.onApproved,I=e.onDenied,_=e.assets,D=void 0===_?{}:_,F=e.colors,M=void 0===F?{}:F,L=e.verbiage,N=void 0===L?{}:L,O=e.captureSignature,P=void 0!==O&&O,B=e.captureSignatureVideo,U=void 0!==B&&B,$=e.captureAdditionalDocuments,j=void 0===$?[]:$,G=e.geolocationEnabled,z=void 0===G||G,q=e.geolocationRequired,H=void 0!==q&&q,V=e.debugMode,W=void 0!==V&&V;Vg(void 0===t?"auto":t);var K=n.useMemo((function(){return{autoCaptureEnabled:v,idCardAutoCaptureScoreThreshold:b,passportAutoCaptureScoreThreshold:x,mrzDetectionScoreThreshold:.5,idCardFocusScoreThreshold:k,passportFocusScoreThreshold:C,barcodeScanningEnabled:!1,assets:D,colors:M,verbiage:N,debugMode:W}}),[D,M,W,v,b,k,x,C,N]),Y=n.useMemo((function(){return{verbiage:{headingText:N.signatureCaptureHeadingText,acceptBtnText:N.signatureCaptureAcceptBtnText,clearBtnText:N.signatureCaptureClearBtnText}}}),[N.signatureCaptureAcceptBtnText,N.signatureCaptureClearBtnText,N.signatureCaptureHeadingText]),X=n.useMemo((function(){return{documents:j,verbiage:{headingText:N.additionalDocumentsHeadingText,nextBtnText:N.additionalDocumentsNextBtnText}}}),[j,N.additionalDocumentsHeadingText,N.additionalDocumentsNextBtnText]),J=n.useCallback((function(e){null==A||A(e),"Approved"===e.resultData.verificationResult?null==R||R(e):null==I||I(e)}),[R,A,I]);return u.default.createElement(bt,{action:$e.VALIDATE,environment:i,url:o,token:r,companyId:s,manualReviewRequired:l,verifyIdWithExternalDatabases:c,personalData:d,cardData:h,webhooksEnabled:f,webhooksClientTraceId:p,webhooksStripSpecialCharacters:g,onBeforeSubmit:T,onResponseReceived:J,geolocationEnabled:z,geolocationRequired:H},u.default.createElement(qg,{checks:n.useMemo((function(){return["IdCapture"]}),[]),idCaptureProps:K,signatureCaptureProps:Y,additionalDocumentCaptureProps:X,captureSignature:P,captureSignatureVideo:U}))},Kg=function(e){var t=e.lang,r=e.submissionToken,a=e.submissionEnvironment,i=void 0===a?"prod":a,o=e.submissionUrl,s=e.companyId,l=e.webhooksEnabled,c=e.webhooksClientTraceId,d=e.webhooksStripSpecialCharacters,h=e.timeoutDurationMs,f=void 0===h?15e3:h,p=e.onBeforeSubmit,g=e.onComplete,m=e.onApproved,v=e.onDenied,y=e.onExitAfterFailure,b=e.assets,w=e.colors,x=e.verbiage,E=e.geolocationEnabled,k=void 0===E||E,S=e.geolocationRequired,C=void 0!==S&&S,T=e.debugMode,A=void 0!==T&&T;Vg(void 0===t?"auto":t);var R=n.useMemo((function(){return{timeoutDurationMs:f,onComplete:g,onSuccess:m,onTimeout:v,onExitAfterFailure:y,assets:b,colors:w,verbiage:x,debugMode:A}}),[b,w,A,m,g,v,y,f,x]);return u.default.createElement(bt,{action:$e.NONE,environment:i,url:o,token:r,companyId:s,webhooksEnabled:l,webhooksClientTraceId:c,webhooksStripSpecialCharacters:d,onBeforeSubmit:p,geolocationEnabled:k,geolocationRequired:C},u.default.createElement(qg,{checks:n.useMemo((function(){return["FaceLiveness"]}),[]),idCaptureProps:{},faceLivenessProps:R}))},Yg=function(e){var t=e.lang,r=e.submissionToken,a=e.submissionEnvironment,i=void 0===a?"prod":a,o=e.submissionUrl,s=e.companyId,l=e.manualReviewRequired,c=e.verifyIdWithExternalDatabases,d=e.personalData,h=e.cardData,f=e.webhooksEnabled,p=e.webhooksClientTraceId,g=e.webhooksStripSpecialCharacters,m=e.idAutoCaptureEnabled,v=void 0===m||m,y=e.idCardAutoCaptureScoreThreshold,b=void 0===y?.8:y,w=e.mrzDetectionScoreThreshold,x=void 0===w?.5:w,E=e.passportAutoCaptureScoreThreshold,k=void 0===E?.8:E,S=e.idCardFocusScoreThreshold,C=void 0===S?.3:S,T=e.passportFocusScoreThreshold,A=void 0===T?.3:T,R=e.idCaptureAssets,I=e.idCaptureColors,_=e.idCaptureVerbiage,D=e.faceLivenessTimeoutDurationMs,F=void 0===D?15e3:D,M=e.faceLivenessAssets,L=e.faceLivenessColors,N=e.faceLivenessVerbiage,O=e.onBeforeSubmit,P=e.onComplete,B=e.onApproved,U=e.onDenied,$=e.onExitAfterFailure,j=e.captureSignature,G=void 0!==j&&j,z=e.captureSignatureVideo,q=void 0!==z&&z,H=e.captureAdditionalDocuments,V=void 0===H?[]:H,W=e.geolocationEnabled,K=void 0===W||W,Y=e.geolocationRequired,X=void 0!==Y&&Y,J=e.debugMode,Z=void 0!==J&&J;Vg(void 0===t?"auto":t);var Q=n.useMemo((function(){return{assets:R,colors:I,verbiage:_,autoCaptureEnabled:v,idCardAutoCaptureScoreThreshold:b,passportAutoCaptureScoreThreshold:k,mrzDetectionScoreThreshold:x,idCardFocusScoreThreshold:C,passportFocusScoreThreshold:A,debugMode:Z}}),[Z,v,R,I,_,b,C,x,k,A]),ee=n.useMemo((function(){return{timeoutDurationMs:F,onTimeout:U,onExitAfterFailure:$,assets:M,colors:L,verbiage:N,debugMode:Z}}),[Z,M,L,F,N,U,$]),te=n.useMemo((function(){return{verbiage:{headingText:null==_?void 0:_.signatureCaptureHeadingText,acceptBtnText:null==_?void 0:_.signatureCaptureAcceptBtnText,clearBtnText:null==_?void 0:_.signatureCaptureClearBtnText}}}),[null==_?void 0:_.signatureCaptureAcceptBtnText,null==_?void 0:_.signatureCaptureClearBtnText,null==_?void 0:_.signatureCaptureHeadingText]),ne=n.useMemo((function(){return{documents:V,verbiage:{headingText:null==_?void 0:_.additionalDocumentsHeadingText,nextBtnText:null==_?void 0:_.additionalDocumentsNextBtnText}}}),[V,null==_?void 0:_.additionalDocumentsHeadingText,null==_?void 0:_.additionalDocumentsNextBtnText]),re=n.useCallback((function(e){null==P||P(e),"Approved"===e.resultData.verificationResult?null==B||B(e):null==U||U(e)}),[B,P,U]);return u.default.createElement(bt,{action:$e.VALIDATE,environment:i,url:o,token:r,companyId:s,manualReviewRequired:l,verifyIdWithExternalDatabases:c,personalData:d,cardData:h,webhooksEnabled:f,webhooksClientTraceId:p,webhooksStripSpecialCharacters:g,onBeforeSubmit:O,onResponseReceived:re,geolocationEnabled:K,geolocationRequired:X},u.default.createElement(qg,{checks:n.useMemo((function(){return["IdCapture","FaceLiveness"]}),[]),idCaptureProps:Q,faceLivenessProps:ee,signatureCaptureProps:te,additionalDocumentCaptureProps:ne,captureSignature:G,captureSignatureVideo:q}))},Xg=function(e){var t=e.enrollmentId,r=e.lang,a=e.submissionToken,i=e.submissionEnvironment,o=void 0===i?"prod":i,s=e.submissionUrl,l=e.companyId,c=e.manualReviewRequired,d=e.verifyIdWithExternalDatabases,h=e.personalData,f=e.cardData,p=e.deduplicationEnabled,g=e.deduplicationSynchronous,m=e.webhooksEnabled,v=e.webhooksClientTraceId,y=e.webhooksStripSpecialCharacters,b=e.idAutoCaptureEnabled,w=void 0===b||b,x=e.idCardAutoCaptureScoreThreshold,E=void 0===x?.8:x,k=e.mrzDetectionScoreThreshold,S=void 0===k?.5:k,C=e.passportAutoCaptureScoreThreshold,T=void 0===C?.8:C,A=e.idCardFocusScoreThreshold,R=void 0===A?.3:A,I=e.passportFocusScoreThreshold,_=void 0===I?.3:I,D=e.idCaptureAssets,F=e.idCaptureColors,M=e.idCaptureVerbiage,L=e.faceLivenessTimeoutDurationMs,N=void 0===L?15e3:L,O=e.faceLivenessAssets,P=e.faceLivenessColors,B=e.faceLivenessVerbiage,U=e.onBeforeSubmit,$=e.onComplete,j=e.onEnrolled,G=e.onDenied,z=e.onExitAfterFailure,q=e.captureSignature,H=void 0!==q&&q,V=e.captureSignatureVideo,W=void 0!==V&&V,K=e.captureAdditionalDocuments,Y=void 0===K?[]:K,X=e.geolocationEnabled,J=void 0===X||X,Z=e.geolocationRequired,Q=void 0!==Z&&Z,ee=e.debugMode,te=void 0!==ee&ⅇVg(void 0===r?"auto":r);var ne=n.useMemo((function(){return{assets:D,colors:F,verbiage:M,autoCaptureEnabled:w,idCardAutoCaptureScoreThreshold:E,passportAutoCaptureScoreThreshold:T,mrzDetectionScoreThreshold:S,idCardFocusScoreThreshold:R,passportFocusScoreThreshold:_,debugMode:te}}),[te,w,D,F,M,E,R,S,T,_]),re=n.useMemo((function(){return{onExitAfterFailure:z,timeoutDurationMs:N,assets:O,colors:P,verbiage:B,debugMode:te}}),[te,O,P,N,B,z]),ae=n.useMemo((function(){return{verbiage:{headingText:null==M?void 0:M.signatureCaptureHeadingText,acceptBtnText:null==M?void 0:M.signatureCaptureAcceptBtnText,clearBtnText:null==M?void 0:M.signatureCaptureClearBtnText}}}),[null==M?void 0:M.signatureCaptureAcceptBtnText,null==M?void 0:M.signatureCaptureClearBtnText,null==M?void 0:M.signatureCaptureHeadingText]),ie=n.useMemo((function(){return{documents:Y,verbiage:{headingText:null==M?void 0:M.additionalDocumentsHeadingText,nextBtnText:null==M?void 0:M.additionalDocumentsNextBtnText}}}),[Y,null==M?void 0:M.additionalDocumentsHeadingText,null==M?void 0:M.additionalDocumentsNextBtnText]),oe=n.useCallback((function(e){null==$||$(e),"Customer Onboarded"===e.resultData.verificationResult?null==j||j(e):null==G||G(e)}),[j,$,G]);return u.default.createElement(bt,{action:$e.ENROLL,environment:o,url:s,token:a,companyId:l,enrollmentId:t,manualReviewRequired:c,verifyIdWithExternalDatabases:d,personalData:h,cardData:f,deduplicationEnabled:p,deduplicationSynchronous:g,webhooksEnabled:m,webhooksClientTraceId:v,webhooksStripSpecialCharacters:y,onBeforeSubmit:U,onResponseReceived:oe,geolocationEnabled:J,geolocationRequired:Q},u.default.createElement(qg,{checks:n.useMemo((function(){return["IdCapture","FaceLiveness"]}),[]),idCaptureProps:ne,faceLivenessProps:re,signatureCaptureProps:ae,additionalDocumentCaptureProps:ie,captureSignature:H,captureSignatureVideo:W}))},Jg={frame:null,face:null,imageUrl:null,requestState:"NOT_READY",requestError:null,unverifiedTimes:0},Zg=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,a=r.statusMessage,i=r.errorData,o=n.resultData;if("000"!==r.statusCode)return p(p({},e),{requestState:"ERROR",requestError:new Error("".concat(a,": ").concat(i))});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}},Qg=function(e){var t=e.onCustomerMatched,r=e.onCustomerNotMatched,a=e.onCaptureGuidanceTimeout,i=e.onExit,o=e.captureGuidanceTimeoutDurationMs,s=e.colors,l=void 0===s?{}:s,c=e.verbiage,d=void 0===c?{}:c,h=e.debugMode,f=void 0!==h&&h,p=n.useReducer(Zg,Jg),v=p[0],y=p[1],b=v.frame,w=v.face,x=n.useContext(qe),E=x.submit,k=x.submissionResponse,S=x.selfieImage,C=x.setSelfieImage,T=n.useCallback((function(e,t){y({type:"verificationReady",payload:{frame:e,face:t}})}),[]),A="READY"===v.requestState;return n.useEffect((function(){b&&w&&We(da(b,w)).then((function(e){console.log("setting selfie image",e),C(e)}))}),[w,b,C]),n.useEffect((function(){A&&S&&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]),y({type:"verifying",payload:{imageUrl:S}}),[4,E()];case 1:if(!(e=n.sent()))throw new Error("submission failed!");return y({type:"verificationCompleted",payload:{response:e}}),[3,3];case 2:return t=n.sent(),y({type:"verificationFailed",payload:{error:t}}),[3,3];case 3:return[2]}}))}))}),[A,t,r,S,v.requestState,E]),n.useEffect((function(){k&&("FOUND"===v.requestState?null==t||t(k):"NOT_FOUND"===v.requestState&&(null==r||r(k)))}),[t,r,v.requestState,k]),u.default.createElement(xp,{onSelfieCaptured:T,onTimeout:a,onExit:i,timeoutDurationMs:o,colors:l,verbiage:d,debugMode:f})},em=function(e){var t=e.headingText,n=e.retryBtnText,r=e.doneBtnText,a=e.imageUrl,i=e.onDoneClick,o=e.onRetryClick,s=ye().t;return a=a||"".concat(ua,"/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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:a})),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:i,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},r)))))},tm=function(e){var t=e.headingText,n=e.retryBtnText,r=e.exitBtnText,a=e.imageUrl,i=e.canRetry,o=void 0===i||i,s=e.onRetryClick,l=e.onExitClick,c=ye().t;return a=a||"".concat(ua,"/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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:a})),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)))))},nm=function(e){var t=e.onComplete,r=e.onCustomerMatched,a=e.onCustomerNotMatched,i=e.onExitAfterFailure,o=e.onCaptureGuidanceTimeout,s=e.captureGuidanceTimeoutDurationMs,l=e.assets,c=void 0===l?{}:l,d=e.colors,h=void 0===d?{}:d,f=e.verbiage,p=void 0===f?{}:f,v=e.debugMode,y=void 0!==v&&v,b=n.useContext(qe),w=b.submissionResponse,x=b.selfieImage,E=n.useContext(Mt).releaseCameraAccess,k=n.useState("LOADING"),S=k[0],C=k[1],T=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return C("MATCHED"),E(),setTimeout((function(){null==r||r(e)}),0),[2]}))}))}),[r,E]),A=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return C("NOT_MATCHED"),E(),setTimeout((function(){null==a||a(e)}),0),[2]}))}))}),[a,E]),R=n.useCallback((function(){C("FAILED"),E(),setTimeout((function(){null==o||o()}),0)}),[o,E]),I=n.useState(0),_=I[0],D=I[1],F=n.useCallback((function(){D((function(e){return e+1})),C("LOADING")}),[]);return u.default.createElement(u.default.Fragment,null,"LOADING"!==S&&function(){switch(S){case"CAPTURING":return u.default.createElement(Qg,{onCustomerMatched:T,onCustomerNotMatched:A,onCaptureGuidanceTimeout:R,onExit:F,captureGuidanceTimeoutDurationMs:s,colors:h,verbiage:p,debugMode:y});case"MATCHED":return u.default.createElement(em,{headingText:p.successHeadingText,retryBtnText:p.successRetryBtnText,doneBtnText:p.successDoneBtnText,imageUrl:"data:image/png;base64, ".concat(x),onDoneClick:function(){w&&(null==t||t(w))},onRetryClick:function(){C("CAPTURING")}});case"NOT_MATCHED":return u.default.createElement(tm,{headingText:p.failureHeadingText,retryBtnText:p.failureRetryBtnText,exitBtnText:null==p?void 0:p.failureExitBtnText,imageUrl:c.failureImageUrl,canRetry:!1,onExitClick:i});default:return null}}(),u.default.createElement(_p,{key:_,headingText:p.loadingOverlayHeadingText,removeEyeCoveringsText:p.loadingOverlayRemoveEyeCoveringsText,avoidExcessiveBacklightingText:p.loadingOverlayAvoidExcessiveBacklightingText,continueText:p.loadingOverlayContinueText,cameraInitializingText:p.loadingOverlayCameraInitializingText,modelsWarmingUpText:p.loadingOverlayModelsWarmingUpText,instructionImageUrl:c.instructionImageUrl,onDismissed:function(){C("CAPTURING")}}))},rm=function(e){var t=e.lang,n=e.enrollmentId,r=e.submissionToken,a=e.submissionEnvironment,i=void 0===a?"prod":a,o=e.submissionUrl,s=e.companyId,l=e.webhooksEnabled,c=e.webhooksClientTraceId,d=e.webhooksStripSpecialCharacters,h=e.timeoutDurationMs,f=void 0===h?15e3:h,p=e.assets,g=e.colors,m=e.verbiage,v=e.onBeforeSubmit,y=e.onComplete,b=e.onCustomerMatched,w=e.onCustomerNotMatched,x=e.onExitAfterFailure,E=e.geolocationEnabled,k=void 0===E||E,S=e.geolocationRequired,C=void 0!==S&&S,T=e.debugMode,A=void 0!==T&&T;return Vg(void 0===t?"auto":t),u.default.createElement(bt,{action:$e.VERIFY,environment:i,url:o,token:r,companyId:s,enrollmentId:n,webhooksEnabled:l,webhooksClientTraceId:c,webhooksStripSpecialCharacters:d,onBeforeSubmit:v,geolocationEnabled:k,geolocationRequired:C},u.default.createElement(mp,null,u.default.createElement(zp,{preferFrontFacingCamera:!0},u.default.createElement(nm,{onComplete:y,onCustomerMatched:b,onCustomerNotMatched:w,onExitAfterFailure:x,captureGuidanceTimeoutDurationMs:f,assets:p,colors:g,verbiage:m,debugMode:A}))))},am={frame:null,face:null,imageUrl:null,requestState:"NOT_READY",requestError:null,notFoundTimes:0},im=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,a=r.statusMessage,i=r.errorData,o=n.resultData;if("000"!==r.statusCode)return p(p({},e),{requestState:"ERROR",requestError:new Error("".concat(a,": ").concat(i))});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}},om=function(e){var t=e.onCustomerMatched,r=e.onCustomerNotMatched,a=e.onCaptureGuidanceTimeout,i=e.onExit,o=e.captureGuidanceTimeoutDurationMs,s=e.colors,l=void 0===s?{}:s,c=e.verbiage,d=void 0===c?{}:c,h=e.debugMode,f=void 0!==h&&h,p=n.useReducer(im,am),v=p[0],y=p[1],b=n.useContext(qe),w=b.submit,x=b.submissionResponse,E=b.selfieImage,k=b.setSelfieImage,S=n.useCallback((function(e,t){y({type:"identificationReady",payload:{frame:e,face:t}})}),[]),C=v.frame,T=v.face,A="READY"===v.requestState;return n.useEffect((function(){C&&T&&We(da(C,T)).then((function(e){console.log("setting selfie image",e),k(e)}))}),[T,C,k]),n.useEffect((function(){A&&E&&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]),y({type:"identifying",payload:{imageUrl:E}}),[4,w()];case 1:if(!(e=n.sent()))throw new Error("submission failed!");return y({type:"identificationCompleted",payload:{response:e}}),[3,3];case 2:return t=n.sent(),y({type:"identificationFailed",payload:{error:t}}),[3,3];case 3:return[2]}}))}))}),[A,t,r,E,v.requestState,w]),n.useEffect((function(){x&&("FOUND"===v.requestState?null==t||t(x):"NOT_FOUND"===v.requestState&&(null==r||r(x)))}),[t,r,v.requestState,x]),u.default.createElement(xp,{onSelfieCaptured:S,onTimeout:a,onExit:i,timeoutDurationMs:o,colors:l,verbiage:d,debugMode:f})},sm=function(e){var t=e.headingText,n=e.retryBtnText,r=e.doneBtnText,a=e.imageUrl,i=e.onDoneClick,o=e.onRetryClick,s=ye().t;return a=a||"".concat(ua,"/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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:a})),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:i,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},r)))))},lm=function(e){var t=e.headingText,n=e.retryBtnText,r=e.exitBtnText,a=e.imageUrl,i=e.canRetry,o=void 0===i||i,s=e.onRetryClick,l=e.onExitClick,c=ye().t;return a=a||"".concat(ua,"/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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:a})),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)))))},um=function(e){var t=e.onComplete,r=e.onCustomerMatched,a=e.onCustomerNotMatched,i=e.onExitAfterFailure,o=e.onCaptureGuidanceTimeout,s=e.captureGuidanceTimeoutDurationMs,l=e.assets,c=void 0===l?{}:l,d=e.colors,h=void 0===d?{}:d,f=e.verbiage,p=void 0===f?{}:f,v=e.debugMode,y=void 0!==v&&v,b=n.useContext(qe),w=b.submissionResponse,x=b.selfieImage,E=n.useContext(Mt).releaseCameraAccess,k=n.useState("LOADING"),S=k[0],C=k[1],T=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return C("FOUND"),E(),setTimeout((function(){null==r||r(e)}),0),[2]}))}))}),[r,E]),A=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return C("NOT_FOUND"),E(),setTimeout((function(){null==a||a(e)}),0),[2]}))}))}),[a,E]),R=n.useCallback((function(){C("FAILED"),E(),setTimeout((function(){null==o||o()}),0)}),[o,E]),I=n.useState(0),_=I[0],D=I[1],F=n.useCallback((function(){D((function(e){return e+1})),C("LOADING")}),[]);return u.default.createElement(u.default.Fragment,null,"LOADING"!==S&&function(){switch(S){case"CAPTURING":return u.default.createElement(om,{onCustomerMatched:T,onCustomerNotMatched:A,onCaptureGuidanceTimeout:R,onExit:F,captureGuidanceTimeoutDurationMs:s,colors:h,verbiage:p,debugMode:y});case"FOUND":return u.default.createElement(sm,{headingText:p.successHeadingText,retryBtnText:p.successRetryBtnText,doneBtnText:p.successDoneBtnText,imageUrl:"data:image/png;base64, ".concat(x),onDoneClick:function(){w&&(null==t||t(w))},onRetryClick:function(){C("CAPTURING")}});case"NOT_FOUND":case"FAILED":return u.default.createElement(lm,{headingText:p.failureHeadingText,retryBtnText:p.failureRetryBtnText,exitBtnText:null==p?void 0:p.failureExitBtnText,imageUrl:c.failureImageUrl,canRetry:!1,onExitClick:i});default:return null}}(),u.default.createElement(_p,{key:_,headingText:p.loadingOverlayHeadingText,removeEyeCoveringsText:p.loadingOverlayRemoveEyeCoveringsText,avoidExcessiveBacklightingText:p.loadingOverlayAvoidExcessiveBacklightingText,continueText:p.loadingOverlayContinueText,cameraInitializingText:p.loadingOverlayCameraInitializingText,modelsWarmingUpText:p.loadingOverlayModelsWarmingUpText,instructionImageUrl:c.instructionImageUrl,onDismissed:function(){C("CAPTURING")}}))},cm=function(e){var t=e.lang,n=e.submissionToken,r=e.submissionEnvironment,a=void 0===r?"prod":r,i=e.submissionUrl,o=e.companyId,s=e.webhooksEnabled,l=e.webhooksClientTraceId,c=e.webhooksStripSpecialCharacters,d=e.timeoutDurationMs,h=void 0===d?15e3:d,f=e.onBeforeSubmit,p=e.onComplete,g=e.onCustomerMatched,m=e.onCustomerNotMatched,v=e.onCaptureGuidanceTimeout,y=e.onExitAfterFailure,b=e.assets,w=e.colors,x=e.verbiage,E=e.geolocationEnabled,k=e.geolocationRequired,S=void 0!==k&&k,C=e.debugMode,T=void 0!==C&&C;return Vg(void 0===t?"auto":t),u.default.createElement(bt,{action:$e.IDENTIFY,environment:a,url:i,token:n,companyId:o,webhooksEnabled:s,webhooksClientTraceId:l,webhooksStripSpecialCharacters:c,onBeforeSubmit:f,geolocationEnabled:E,geolocationRequired:S},u.default.createElement(zp,{preferFrontFacingCamera:!0},u.default.createElement(mp,null,u.default.createElement(um,{onComplete:p,onCustomerMatched:g,onCustomerNotMatched:m,onExitAfterFailure:y,onCaptureGuidanceTimeout:v,captureGuidanceTimeoutDurationMs:h,assets:b,colors:w,verbiage:x,debugMode:T}))))},dm=function(e){var t=e.documentDetectionModel,n=void 0===t?"".concat(ua,"/models/documentdetection448/model.json"):t,r=e.focusModel,a=void 0===r?"".concat(ua,"/models/focus/model.json"):r,i=e.skipFaceDetectionModel,o=void 0!==i&&i;return g(void 0,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return n?[4,wt(n)]:[3,2];case 1:e.sent(),e.label=2;case 2:return a?[4,Lt(a)]:[3,4];case 3:e.sent(),e.label=4;case 4:return o?[3,6]:[4,lp()];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},hm=function(e){var t=e.enrollmentId,r=e.lang,a=e.submissionToken,i=e.submissionEnvironment,o=void 0===i?"prod":i,s=e.submissionUrl,l=e.companyId,c=e.deduplicationEnabled,d=e.deduplicationSynchronous,h=e.webhooksEnabled,f=e.webhooksClientTraceId,p=e.webhooksStripSpecialCharacters,g=e.timeoutDurationMs,m=void 0===g?15e3:g,v=e.assets,y=e.colors,b=e.verbiage,w=e.onBeforeSubmit,x=e.onComplete,E=e.onEnrolled,k=e.onDenied,S=e.onExitAfterFailure,C=e.captureSignature,T=void 0!==C&&C,A=e.captureSignatureVideo,R=void 0!==A&&A,I=e.captureAdditionalDocuments,_=void 0===I?[]:I,D=e.geolocationEnabled,F=void 0===D||D,M=e.geolocationRequired,L=void 0!==M&&M,N=e.debugMode,O=void 0!==N&&N;Vg(void 0===r?"auto":r);var P=n.useMemo((function(){return{onExitAfterFailure:S,timeoutDurationMs:m,assets:v,colors:y,verbiage:b,debugMode:O}}),[v,y,O,S,m,b]),B=n.useMemo((function(){return{verbiage:{headingText:null==b?void 0:b.signatureCaptureHeadingText,acceptBtnText:null==b?void 0:b.signatureCaptureAcceptBtnText,clearBtnText:null==b?void 0:b.signatureCaptureClearBtnText}}}),[null==b?void 0:b.signatureCaptureAcceptBtnText,null==b?void 0:b.signatureCaptureClearBtnText,null==b?void 0:b.signatureCaptureHeadingText]),U=n.useMemo((function(){return{documents:_,verbiage:{headingText:null==b?void 0:b.additionalDocumentsHeadingText,nextBtnText:null==b?void 0:b.additionalDocumentsNextBtnText}}}),[_,null==b?void 0:b.additionalDocumentsHeadingText,null==b?void 0:b.additionalDocumentsNextBtnText]),$=n.useCallback((function(e){null==x||x(e),"Customer Onboarded"===e.resultData.verificationResult?null==E||E(e):null==k||k(e)}),[E,x,k]);return u.default.createElement(bt,{action:$e.ENROLL,environment:o,url:s,token:a,companyId:l,enrollmentId:t,deduplicationEnabled:c,deduplicationSynchronous:d,webhooksEnabled:h,webhooksClientTraceId:f,webhooksStripSpecialCharacters:p,onBeforeSubmit:w,onResponseReceived:$,geolocationEnabled:F,geolocationRequired:L},u.default.createElement(qg,{checks:n.useMemo((function(){return["FaceLiveness"]}),[]),faceLivenessProps:P,signatureCaptureProps:B,additionalDocumentCaptureProps:U,captureSignature:T,captureSignatureVideo:R}))},fm=function(e){var t=e.submissionToken,r=e.submissionEnvironment,a=e.submissionUrl,i=e.onBeforeSubmit,o=e.onComplete,s=e.colors,l=e.verbiage,c=e.geolocationEnabled,d=e.geolocationRequired,h=e.debugMode,f=n.useState(0),p=f[1];return u.default.createElement(bt,{action:$e.NONE,environment:r,url:a,token:t,onBeforeSubmit:i,onResponseReceived:o,geolocationEnabled:c,geolocationRequired:d},u.default.createElement(zp,{key:f[0],preferContinuityCamera:!1,preferFrontFacingCamera:!0,requestMicrophoneAccess:!0},u.default.createElement(zg,{colors:s,debugMode:h,verbiage:l,onRetryClicked:function(){p((function(e){return e+1}))}})))};function pm(e){return u.default.createElement(rt,null,e.children)}ne.use(Ge).use(ge).init({resources:Hg,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 gm=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(pm,null,e)),l.default.render(e,t)},mm=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(Wg,p({},t)),e,n)},vm=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(Kg,p({},t)),e,n)},ym=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(Yg,p({},t)),e,n)},bm=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(Xg,p({},t)),e,n)},wm=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(hm,p({},t)),e,n)},xm=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(rm,p({},t)),e,n)},Em=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(cm,p({},t)),e,n)},km=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(fm,p({},t)),e,n)};globalThis.IDmissionSDK={renderIdValidation:mm,renderFaceValidation:vm,renderIdAndFaceValidation:ym,renderCustomerIdAndBiometricsEnrollment:bm,renderCustomerBiometricsEnrollment:wm,renderCustomerVerification:xm,renderCustomerIdentification:Em,renderSignatureKYC:km,preloadModels:dm,ready:!0},e.CustomerBiometricsEnrollment=hm,e.CustomerIdAndBiometricsEnrollment=Xg,e.CustomerIdentification=cm,e.CustomerVerification=rm,e.FaceValidation=Kg,e.IdAndFaceValidation=Yg,e.IdValidation=Wg,e.SignatureKYC=fm,e.preloadModels=dm,e.renderCustomerBiometricsEnrollment=wm,e.renderCustomerIdAndBiometricsEnrollment=bm,e.renderCustomerIdentification=Em,e.renderCustomerVerification=xm,e.renderFaceValidation=vm,e.renderIdAndFaceValidation=ym,e.renderIdValidation=mm,e.renderSignatureKYC=km,Object.defineProperty(e,"__esModule",{value:!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,a,i){"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(a),f=s(i),p=function(){return p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},p.apply(this,arguments)};function g(e,t,n,r){return new(n||(n=Promise))((function(a,i){function o(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(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,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=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(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=a=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,a=0,i=t.length;a<i;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);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 k(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));return n.resolve=e,n.reject=t,n}function S(e){return null==e?"":""+e}function C(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function a(){return!e||"string"==typeof e}const i="string"!=typeof t?[].concat(t):t.split(".");for(;i.length>1;){if(a())return{};const t=r(i.shift());!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}return a()?{}:{obj:e,k:r(i.shift())}}function T(e,t,n){const{obj:r,k:a}=C(e,t,Object);r[a]=n}function A(e,t){const{obj:n,k:r}=C(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 I(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var _={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function D(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(e=>_[e])):e}const F=[" ",",","?","!",";"];function M(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 a=e;for(let e=0;e<r.length;++e){if(!a)return;if("string"==typeof a[r[e]]&&e+1<r.length)return;if(void 0===a[r[e]]){let i=2,o=r.slice(e,e+i).join(n),s=a[o];for(;void 0===s&&r.length>e+i;)i++,o=r.slice(e,e+i).join(n),s=a[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+i).join(n);return l?M(s,l,n):void 0}a=a[r[e]]}return a}function L(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 a=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,i=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(a?n.split(a):n)),e.indexOf(".")>-1&&(o=e.split("."));const s=A(this.data,o);return s||!i||"string"!=typeof n?s:M(this.data&&this.data[e]&&this.data[e][t],n,a)}addResource(e,t,n,r){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const i=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator;let o=[e,t];n&&(o=o.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(o=e.split("."),r=t,t=o[1]),this.addNamespaces(t),T(this.data,o,r),a.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,a){let i=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,a):s={...s,...n},T(this.data,o,s),i.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,a){return e.forEach((e=>{this.processors[e]&&(t=this.processors[e].process(t,n,r,a))})),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 a=t.ns||this.options.defaultNS||[];const i=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 a=new RegExp(`(${r.map((e=>"?"===e?"\\?":e)).join("|")})`);let i=!a.test(e);if(!i){const t=e.indexOf(n);t>0&&!a.test(e.substring(0,t))&&(i=!0)}return i}(e,n,r));if(i&&!o){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:a};const i=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(i[0])>-1)&&(a=i.shift()),e=i.join(r)}return"string"==typeof a&&(a=[a]),{key:e,namespaces:a}}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,a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,{key:i,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}${i}`,usedKey:i,exactUsedKey:i,usedLng:l,usedNS:s}:`${s}${e}${i}`}return r?{res:i,usedKey:i,exactUsedKey:i,usedLng:l,usedNS:s}:i}const c=this.resolve(e,t);let d=c&&c.res;const h=c&&c.usedKey||i,f=c&&c.exactUsedKey||i,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 '${i} (${this.language})' returned an object instead of string.`;return r?(c.res=e,c):e}if(a){const e="[object Array]"===p,n=e?[]:{},r=e?f:h;for(const e in d)if(Object.prototype.hasOwnProperty.call(d,e)){const i=`${r}${a}${e}`;n[e]=this.translate(i,{...t,joinArrays:!1,ns:o}),n[e]===i&&(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=i);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,i,v?g:d),a){const e=this.resolve(i,{...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 a=h&&r!==d?r:m;this.options.missingKeyHandler?this.options.missingKeyHandler(e,s,n,a,v,t):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(e,s,n,a,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],i+n,t[`defaultValue${n}`]||g)}))})):r(e,i,g))}d=this.extendTranslation(d,e,t,c,n),o&&d===i&&this.options.appendNamespaceToMissingKey&&(d=`${s}:${i}`),(o||r)&&this.options.parseMissingKeyHandler&&(d="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${s}:${i}`:i,r?d:void 0):this.options.parseMissingKeyHandler(d))}return r?(c.res=d,c):d}extendTranslation(e,t,n,r,a){var i=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 a&&a[0]===r[0]&&!n.context?(i.logger.warn(`It seems you are nesting recursively key: ${r[0]} in key: ${t[0]}`),null):i.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,a,i,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)||(i=e,!P[`${f[0]}-${e}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(i)&&(P[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${n}" for languages "${f.join(", ")}" won't get resolved as namespace "${i}" 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;a=n;const i=[l];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(i,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&&(i.push(l+e),o.ordinal&&0===e.indexOf(r)&&i.push(l+e.replace(r,this.options.pluralSeparator)),d&&i.push(l+t)),h){const n=`${l}${this.options.contextSeparator}${o.context}`;i.push(n),c&&(i.push(n+e),o.ordinal&&0===e.indexOf(r)&&i.push(n+e.replace(r,this.options.pluralSeparator)),d&&i.push(n+t))}}let s;for(;s=i.pop();)this.isValidLookup(t)||(r=s,t=this.getResource(n,e,s,o))})))}))})),{res:t,usedKey:n,exactUsedKey:r,usedLng:a,usedNS:i}}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=L(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=L(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=[],a=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&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):"string"==typeof e&&a(this.formatLanguageCode(e)),n.forEach((e=>{r.indexOf(e)<0&&a(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(L(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 a=()=>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()}`:a():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?a():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]:".",a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=function(e,t,n){const r=A(e,n);return void 0!==r?r:A(t,n)}(e,t,n);return!i&&a&&"string"==typeof n&&(i=M(e,n,r),void 0===i&&(i=M(t,n,r))),i}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?I(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?I(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?I(t.nestingPrefix):t.nestingPrefixEscaped||I("$t("),this.nestingSuffix=t.nestingSuffix?I(t.nestingSuffix):t.nestingSuffixEscaped||I(")"),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 a,i,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 a=W(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(a,void 0,n,{...r,...t,interpolationkey:e}):a}const a=e.split(this.formatSeparator),i=a.shift().trim(),o=a.join(this.formatSeparator).trim();return this.format(W(t,s,i,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:i})};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;a=t.regex.exec(e);){const n=a[1].trim();if(i=u(n),void 0===i)if("function"==typeof c){const t=c(e,a,r);i="string"==typeof t?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,n))i="";else{if(d){i=a[0];continue}this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),i=""}else"string"==typeof i||this.useRawValueToEscape||(i=S(i));const s=t.safeValue(i);if(e=e.replace(a[0],s),d?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=a[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}})),e}nest(e,t){let n,r,a,i=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 i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);const o=i.match(/'/g),s=i.match(/"/g);(o&&o.length%2==0&&!s||s.length%2!=0)&&(i=i.replace(/'/g,'"'));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return delete a.defaultValue,e}for(;n=this.nestingRegexp.exec(e);){let s=[];a={...i},a=a.replace&&"string"!=typeof a.replace?a.replace:a,a.applyPostProcessor=!1,delete a.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(),a),a),r&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=S(r)),r||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),r=""),l&&(r=s.reduce(((e,t)=>this.format(e,t,i.lng,{...i,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,a){const i=r+JSON.stringify(a);let o=t[i];return o||(o=e(L(r),a),t[i]=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 a=t.split(this.formatSeparator).reduce(((e,t)=>{const{formatName:a,formatOptions:i}=function(e){let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const a=r[1].substring(0,r[1].length-1);"currency"===t&&a.indexOf(":")<0?n.currency||(n.currency=a.trim()):"relativetime"===t&&a.indexOf(":")<0?n.range||(n.range=a.trim()):a.split(";").forEach((e=>{if(!e)return;const[t,...r]=e.split(":"),a=r.join(":").trim().replace(/^'+|'+$/g,"");n[t.trim()]||(n[t.trim()]=a),"false"===a&&(n[t.trim()]=!1),"true"===a&&(n[t.trim()]=!0),isNaN(a)||(n[t.trim()]=parseInt(a,10))}))}return{formatName:t,formatOptions:n}}(t);if(this.formats[a]){let t=e;try{const o=r&&r.formatParams&&r.formatParams[r.interpolationkey]||{};t=this.formats[a](e,o.locale||o.lng||r.locale||r.lng||n,{...i,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${a}`),e}),e);return a}}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 a={},i={},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===i[o]&&(i[o]=!0):(this.state[o]=1,r=!1,void 0===i[o]&&(i[o]=!0),void 0===a[o]&&(a[o]=!0),void 0===s[t]&&(s[t]=!0)))})),r||(o[e]=!0)})),(Object.keys(a).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(a),pending:Object.keys(i),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){const r=e.split("|"),a=r[0],i=r[1];t&&this.emit("failedLoading",a,i,t),n&&this.store.addResourceBundle(a,i,n),this.state[e]=t?-1:2;const o={};this.queue.forEach((n=>{!function(e,t,n,r){const{obj:a,k:i}=C(e,t,Object);a[i]=a[i]||[],r&&(a[i]=a[i].concat(n)),r||a[i].push(n)}(n.loaded,[a],i),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,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,i=arguments.length>5?arguments[5]:void 0;if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:a,callback:i});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*a,i)}),a):i(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 a=this.queueLoad(e,t,n,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.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],a=n[1];this.read(r,a,"read",void 0,void 0,((n,i)=>{n&&this.logger.warn(`${t}loading namespace ${a} for language ${r} failed`,n),!n&&i&&this.logger.log(`${t}loaded namespace ${a} for language ${r}`,i),this.loaded(e,n,i)}))}saveMissing(e,t,n,r,a){let i=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={...i,isUpdate:a},l=this.backend.create.bind(this.backend);if(l.length<6)try{let a;a=5===l.length?l(e,t,n,r,s):l(e,t,n,r),a&&"function"==typeof a.then?a.then((e=>o(null,e))).catch(o):o(null,a)}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 a(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?a(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 i=this.services;i.logger=x,i.resourceStore=this.store,i.languageUtils=n,i.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||(i.formatter=a(t),i.formatter.init(i,this.options),this.options.interpolation.format=i.formatter.format.bind(i.formatter)),i.interpolator=new K(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new J(a(this.modules.backend),i.resourceStore,i,this.options),i.backendConnector.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];e.emit(t,...r)})),this.modules.languageDetector&&(i.languageDetector=a(this.modules.languageDetector),i.languageDetector.init&&i.languageDetector.init(i,this.options.detection,this.options)),this.modules.i18nFormat&&(i.i18nFormat=a(this.modules.i18nFormat),i.i18nFormat.init&&i.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),a=1;a<n;a++)r[a-1]=arguments[a];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 i=k(),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),i.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),i}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=k();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=k();this.emit("languageChanging",e);const a=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(e,i)=>{i?(a(i),this.translator.changeLanguage(i),this.isLanguageChangingTo=void 0,this.emit("languageChanged",i),this.logger.log("languageChanged",i)):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||a(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(n)),this.loadResources(n,(e=>{i(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 a=function(e,t){let i;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];i=r.options.overloadTranslationOptionHandler([e,t].concat(s))}else i={...t};i.lng=i.lng||a.lng,i.lngs=i.lngs||a.lngs,i.ns=i.ns||a.ns,i.keyPrefix=i.keyPrefix||n||a.keyPrefix;const u=r.options.keySeparator||".";let c;return c=i.keyPrefix&&Array.isArray(e)?e.map((e=>`${i.keyPrefix}${u}${e}`)):i.keyPrefix?`${i.keyPrefix}${u}${e}`:e,r.t(c,i)};return"string"==typeof e?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=n,a}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,a=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;const i=(e,t)=>{const n=this.services.backendConnector.state[`${e}|${t}`];return-1===n||2===n};if(t.precheck){const e=t.precheck(this,i);if(void 0!==e)return e}return!!this.hasResourceBundle(n,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!i(n,e)||r&&!i(a,e)))}loadNamespaces(e,t){const n=k();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=k();"string"==typeof e&&(e=[e]);const r=this.options.preload||[],a=e.filter((e=>r.indexOf(e)<0));return a.length?(this.options.preload=r.concat(a),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},a=new te(r);void 0===e.debug&&void 0===e.prefix||(a.logger=a.logger.clone(e));return["store","services","language"].forEach((e=>{a[e]=this[e]})),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},n&&(a.store=new N(this.store.data,r),a.services.resourceStore=a.store),a.translator=new B(a.services,r),a.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];a.emit(e,...n)})),a.init(r,t),a.translator.options=r,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}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 ae(e,t){return e(t={exports:{}},t.exports),t.exports}const ie={};function oe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&ie[t[0]]||("string"==typeof t[0]&&(ie[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:a,defaultNS:i}=n.useContext(me)||{},o=r||a||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||i||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],a=!!t.options&&t.options.fallbackLng,i=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)||a&&!o(i,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=[],ke=Ee.forEach,Se=Ee.slice;var Ce=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Te=function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};n&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+60*n*1e3)),r&&(a.domain=r),document.cookie=function(e,t,n){var r=n||{};r.path=r.path||"/";var a=encodeURIComponent(t),i="".concat(e,"=").concat(a);if(r.maxAge>0){var o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");i+="; Max-Age=".concat(Math.floor(o))}if(r.domain){if(!Ce.test(r.domain))throw new TypeError("option domain is invalid");i+="; Domain=".concat(r.domain)}if(r.path){if(!Ce.test(r.path))throw new TypeError("option path is invalid");i+="; Path=".concat(r.path)}if(r.expires){if("function"!=typeof r.expires.toUTCString)throw new TypeError("option expires is invalid");i+="; Expires=".concat(r.expires.toUTCString())}if(r.httpOnly&&(i+="; HttpOnly"),r.secure&&(i+="; Secure"),r.sameSite)switch("string"==typeof r.sameSite?r.sameSite.toLowerCase():r.sameSite){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i}(e,encodeURIComponent(t),a)},Ae=function(e){for(var t="".concat(e,"="),n=document.cookie.split(";"),r=0;r<n.length;r++){for(var a=n[r];" "===a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(t))return a.substring(t.length,a.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&&Te(t.lookupCookie,e,t.cookieMinutes,t.cookieDomain,t.cookieOptions)}},Ie={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("&"),a=0;a<r.length;a++){var i=r[a].indexOf("=");if(i>0)r[a].substring(0,i)===e.lookupQuerystring&&(t=r[a].substring(i+1))}}return t}},_e=null,De=function(){if(null!==_e)return _e;try{_e="undefined"!==window&&null!==window.localStorage;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch(e){_e=!1}return _e},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)}},Me=null,Le=function(){if(null!==Me)return Me;try{Me="undefined"!==window&&null!==window.sessionStorage;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch(e){Me=!1}return Me},Ne={name:"sessionStorage",lookup:function(e){var t;if(e.lookupSessionStorage&&Le()){var n=window.sessionStorage.getItem(e.lookupSessionStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&Le()&&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 ke.call(Se.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(Ie),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,signatureVideo:null,additionalDocuments:null,setIdFrontImage:function(){return null},setIdBackImage:function(){return null},setPassportImage:function(){return null},setSelfieImage:function(){return null},setSignatureData:function(){return null},setSignatureVideo: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:\n Inter,\n -apple-system,\n BlinkMacSystemFont,\n Segoe UI,\n Roboto,\n Oxygen,\n Ubuntu,\n Cantarell,\n Fira Sans,\n Droid Sans,\n Helvetica Neue,\n 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:\n Inter,\n -apple-system,\n BlinkMacSystemFont,\n Segoe UI,\n Roboto,\n Oxygen,\n Ubuntu,\n Cantarell,\n Fira Sans,\n Droid Sans,\n Helvetica Neue,\n 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,a=e.className,i=e.heightOffset,o=void 0===i?0:i,s=e.style,l=e.onClick,c=n.useState(!1),d=c[0],h=c[1];return n.useEffect((function(){h(!1);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(),h(!0),function(){window.removeEventListener("resize",e)}}),[]),u.default.createElement(Je,{ref:t,style:s,onClick:l,className:a,$heightOffset:o},d&&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"]))),at=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"]))),it=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 a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);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 a=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,n=[],r=0,a=e.split(",");r<a.length;r++){var i=a[r].match(t);if(null!==i){var o=+i[2],s=+i[5],l=i[4],u=i[7];0!==o||l||(l=u),0!==s||u||(u=l),l===u&&n.push({prefix:i[1]||"",x:o,y:s,xUnits:l,yUnits:u,end:i[8]})}}return n}(r),i=0;i<t.lines;i++){var o=~~(360/t.lines*i+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,i),borderRadius:n,transformOrigin:"left",transform:"rotate("+o+"deg) translateX("+t.radius+"px)"}),l=i*t.direction/t.lines/t.speed;l-=1/t.speed;var u=ct(document.createElement("div"),{width:"100%",height:"100%",background:dt(t.color,i),borderRadius:n,boxShadow:ht(a,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,a=e;r<a.length;r++){var i=a[r],o=ft(i.x,i.y,t);n.push(i.prefix+o[0]+i.xUnits+" "+o[1]+i.yUnits+i.end)}return n.join(", ")}function ft(e,t,n){var r=n*Math.PI/180,a=Math.sin(r),i=Math.cos(r);return[Math.round(1e3*(e*i+t*a))/1e3,Math.round(1e3*(-e*a+t*i))/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,a=e.querySelector(".ladda-spinner");a||((a=document.createElement("span")).className="ladda-spinner"),e.appendChild(a);var i={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 a=.2*r;return new ut({color:t||"#fff",lines:n||12,radius:a,length:.6*a,width:a<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(a),this.setProgress(0),this},startAfter:function(e){return clearTimeout(n),n=setTimeout((function(){i.start()}),e),this},stop:function(){return i.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 i}console.warn("Ladda button target must be defined.")}var gt=function(e){var t=e.accessBlockedImageUrl,r=ye().t,a=n.useContext(qe).retryLocationAccess,i=n.useRef(null),o=n.useRef(null);return n.useEffect((function(){var e,t;if(i.current)return o.current=pt(i.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(at,{style:{maxWidth:500,height:"auto",margin:"auto"}},u.default.createElement(it,{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:i,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"},r("Retry"))))))};function mt(){return window.platform}var vt,yt,bt=function(e){var t=e.action,r=e.children,a=e.url,i=e.environment,o=void 0===i?"prod":i,s=e.token,l=e.companyId,c=e.enrollmentId,d=e.personalData,h=e.cardData,f=e.manualReviewRequired,y=void 0!==f&&f,b=e.verifyIdWithExternalDatabases,w=void 0!==b&&b,x=e.deduplicationEnabled,E=void 0!==x&&x,k=e.deduplicationSynchronous,S=void 0!==k&&k,C=e.geolocationEnabled,T=void 0===C||C,A=e.geolocationRequired,R=void 0!==A&&A,I=e.webhooksEnabled,_=void 0!==I&&I,D=e.webhooksClientTraceId,F=e.webhooksStripSpecialCharacters,M=void 0===F||F,L=e.onBeforeSubmit,N=e.onResponseReceived,O=e.onRequestFailure,P=n.useState(je.READY),B=P[0],U=P[1],$=n.useState(null),j=$[0],G=$[1],z=n.useState(null),q=z[0],H=z[1],V=n.useState(null),W=V[0],K=V[1],Y=n.useState(null),X=Y[0],J=Y[1],Z=n.useState(null),Q=Z[0],ee=Z[1],te=n.useState(null),ne=te[0],re=te[1],ae=n.useState(null),ie=ae[0],oe=ae[1],se=n.useState(null),le=se[0],ue=se[1],ce=n.useState(null),de=ce[0],he=ce[1],fe=n.useState(null),pe=fe[0],ge=fe[1],me=n.useState(0),ve=me[0],ye=me[1],be=n.useState(!1),we=be[0],xe=be[1],Ee=n.useState([]),ke=Ee[0],Se=Ee[1],Ce=n.useState([]),Te=Ce[0],Ae=Ce[1],Re=n.useState([]),Ie=Re[0],_e=Re[1],De=n.useCallback((function(e){Se((function(t){return v(v([],t,!0),[e],!1)}))}),[]),Fe=n.useCallback((function(e){Ae((function(t){return v(v([],t,!0),[e],!1)}))}),[]),Me=n.useCallback((function(e){_e((function(t){return v(v([],t,!0),[e],!1)}))}),[]),Le=n.useCallback((function(){return g(void 0,void 0,void 0,(function(){var e,n,r,i,u,f,g,v,b,x;return m(this,(function(m){switch(m.label){case 0:if(t===$e.NONE)return e={status:{statusCode:"000"},resultData:{}},U(je.SUBMITTED),H(e),[2,e];U(je.SUBMITTING),m.label=1;case 1:return m.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:y?"Y":"N",bypassAgeValidation:"N",deDuplicationRequired:E?"Y":"N",bypassNameMatching:"Y",postDataAPIRequired:_?"Y":"N",sendInputImagesInPost:"N",sendProcessedImagesInPost:"N",needImmediateResponse:"N",deduplicationSynchronous:S?"Y":"N",verifyDataWithHost:w?"Y":"N",idBackImageRequired:"N",stripSpecialCharacters:M?"Y":"N",idImageResolutionCheck:"Y"}},W&&(n.customerData.idData.idImageFront=W),X&&(n.customerData.idData.idImageBack=X),Q&&(n.customerData.idData.idImageFront=Q),ne&&(t===$e.IDENTIFY?n.biometricData={selfie:ne}:n.customerData.biometricData={selfie:ne}),l&&(n.employee={companyId:l}),d&&(n.customerData.personalData=d),h&&(n.customerData.cardData=h),c&&((x=n.customerData).personalData||(x.personalData={}),n.customerData.personalData.uniqueNumber=c),D&&(n.additionalData.clientTraceId=D),ie&&(n.customerData.signatureData={signatureImage:JSON.stringify(ie)}),de&&(n.customerData.additionalDocuments=de.map((function(e){return p(p({},e),{additionalDocument:JSON.stringify(p(p({},e.additionalDocument),{uniqueId:n.additionalData.uniqueRequestId}))})}))),r={selfie:Ie,front:ke,back:Te,isRealIDCheckRequired:"false",sdkVersion:"WebSDK_9.5.13.2.0",Resolution:"".concat(window.innerWidth," x ").concat(window.innerHeight)},(i=mt())&&(r.os=i.os.family,r.osVersion=i.os.version,r.browserVersion="".concat(i.name," ").concat(i.version)),pe&&(r.GeoLocation=JSON.stringify(pe)),n.additionalData.metadata=JSON.stringify(r),L?[4,L(n)]:[3,3];case 2:(u=m.sent())&&(n=u),m.label=3;case 3:return f=a||He(o,s),g=function(e,t,n,r){var a=r?"v4":"v3";switch(e){case $e.ENROLL:return"/".concat(a,t?"/customer/enroll":"/customer/enroll-biometrics");case $e.IDENTIFY:return"/".concat(a,"/customer/identify");case $e.VALIDATE:return"/".concat(a,n?"/customer/validate-id-match-face":"/customer/validate-id");case $e.VERIFY:return"/".concat(a,"/customer/verify");default:throw new Error("unrecognized SubmissionAction ".concat(e))}}(t,!!(W||X||Q),!!ne,!!s),[4,fetch(f+g,{method:"POST",headers:Ve(s),body:JSON.stringify(n)})];case 4:return[4,m.sent().json()];case 5:return v=m.sent(),G(n),H(v),U(je.SUBMITTED),null==N||N(v),[2,v];case 6:return b=m.sent(),U(je.FAILED),null==O||O(b),[2,null];case 7:return[2]}}))}))}),[t,de,c,o,pe,Te,X,ke,W,L,O,N,Q,Ie,ne,ie,s,a]),Ne=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,i,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=a||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 i=d.sent(),H(i),[2,i]}}))}))}),[o,s,a]),Oe=n.useCallback((function(){ye((function(e){return e+1}))}),[]);return n.useEffect((function(){T&&(console.log("making geolocation attempt",ve),navigator.geolocation.getCurrentPosition((function(e){ge(e),xe(!1)}),(function(e){if(1!==e.code)throw new Error(e.message);xe(!0)})))}),[ve,T,R]),u.default.createElement(qe.Provider,{value:{submit:Le,submissionStatus:B,submissionRequest:j,submissionResponse:q,submissionEnvironment:o,idFrontImage:W,idBackImage:X,passportImage:Q,selfieImage:ne,signatureData:ie,signatureVideo:le,additionalDocuments:de,setIdFrontImage:K,setIdBackImage:J,setPassportImage:ee,setSelfieImage:re,setSignatureData:oe,setSignatureVideo:ue,setAdditionalDocuments:he,logIdFrontCaptureAttempt:De,logIdBackCaptureAttempt:Fe,logSelfieCaptureAttempt:Me,checkLiveness:Ne,retryLocationAccess:Oe}},R&&we?u.default.createElement(gt,null):r)};function wt(e){return g(this,void 0,void 0,(function(){var t,n,r,a,i,o;return m(this,(function(s){switch(s.label){case 0:return yt?[2,yt]:[4,f.loadGraphModel(e)];case 1:return yt=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]),a=f.cast(r,"int32"),o=(i=f).dispose,[4,yt.executeAsync(a)];case 3:return o.apply(i,[s.sent()]),n.dispose(),a.dispose(),r.dispose(),f.dispose(t),[2,yt]}}))}))}!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"}(vt||(vt={}));var xt={1:"Document",2:"MRZ",3:"PDF417",4:"Primary face",5:"Secondary face",6:"Glare",7:"Punch Hole",8:"Passport Page"};function Et(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 kt(e){void 0===e&&(e={});var t=e.onResize,r=n.useRef(void 0);r.current=t;var a=e.round||Math.round,i=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),a=n.useRef(null);a.current=t;var i=n.useRef(null);n.useEffect((function(){o()}));var o=n.useCallback((function(){var t=a.current,n=i.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){i.current=e,o()}),[o])}(n.useCallback((function(t){return i.current&&i.current.box===e.box&&i.current.round===a||(i.current={box:e.box,round:a,instance:new ResizeObserver((function(t){var n=t[0],i="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",o=Et(n,i,"inlineSize"),s=Et(n,i,"blockSize"),d=o?a(o):void 0,h=s?a(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)}}))}),i.current.instance.observe(t,{box:e.box}),function(){i.current&&i.current.instance.unobserve(t)}}),[e.box,a]),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 Ct;function Tt(e){if(void 0!==Ct)return Ct;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 At=function(e){var t=e.width,r=void 0===t?0:t,a=e.height,i=void 0===a?0:a,o=e.padding,s=void 0===o?Tt()?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,k=x.wrapperRef,S=x.wrapperWidth,C=x.wrapperHeight,T=x.imageAspectRatio,A=x.wrapperAspectRatio,R=x.onImageLoaded,I=x.setDimensions;0==r&&(r=S),0==i&&(i=C),n.useEffect((function(){I({width:r,height:i})}),[i,I,r]);var _={height:C-2*s-2*c};return T>=A&&(_={width:S-2*s-2*c}),u.default.createElement(Ze,{ref:k,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:i-2*s-2*c}},u.default.createElement("img",{src:"portrait"===E?y:b,alt:"",onLoad:R,style:p({},_)})),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 Rt(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 It(e,t){return void 0===t&&(t=!1),g(this,void 0,void 0,(function(){var n,r,a,i,o,s,l,u,c;return m(this,(function(d){switch(d.label){case 0:return[4,new Promise((function(o){if(a=e.naturalWidth,i=e.naturalHeight,n=document.createElement("canvas"),!(r=n.getContext("2d")))return[];if(t){console.log("rotating!!"),n.width=i,n.height=a,r.setTransform(0,1,-1,0,n.width,0),r.drawImage(e,0,0,a,i);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 Dt(e,t){var n=this;return new Promise((function(r){var a=new Image;a.onload=function(){return g(n,void 0,void 0,(function(){var e,n,i,o;return m(this,(function(s){switch(s.label){case 0:return _t()?[4,Rt(a)]:[3,2];case 1:return n=s.sent(),console.log("native result",n,"".concat(a.width,"x").concat(a.height)),r(n.length>0?p(p({},n[0]),{Source:"native"}):null),[3,4];case 2:return e=(null!==(i=null==t?void 0:t[2])&&void 0!==i?i:0)<(null!==(o=null==t?void 0:t[3])&&void 0!==o?o:0),[4,It(a,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]}}))}))},a.src=URL.createObjectURL(e)}))}var Ft,Mt=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,a,i,o,s,l,u;return m(this,(function(c){switch(c.label){case 0:return Ft?[2,Ft]:[4,f.loadLayersModel(e)];case 1:return Ft=c.sent(),[4,f.ready()];case 2:return c.sent(),t=f.zeros([448,448,3]),n=f.cast(t,"int32"),i=(a=f).tensor4d,s=(o=Array).from,[4,n.data()];case 3:return r=i.apply(a,[s.apply(o,[c.sent()]),[1,448,448,3]]),l=f.cast(r,"int32"),[4,Ft.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,Ft]}}))}))}class Nt{refCount(e){return Ot("refCount")}incRef(e){return Ot("incRef")}timerAvailable(){return!0}time(e){return Ot("time")}read(e){return Ot("read")}readSync(e){return Ot("readSync")}readToGPU(e,t){return Ot("readToGPU")}numDataIds(){return Ot("numDataIds")}disposeData(e,t){return Ot("disposeData")}write(e,t,n){return Ot("write")}move(e,t,n,r,a){return Ot("move")}createTensorFromGPUData(e,t,n){return Ot("createTensorFromGPUData")}memory(){return Ot("memory")}floatPrecision(){return Ot("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return Ot("dispose")}}function Ot(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 Pt(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function Bt(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 Ut(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 $t(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function jt(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 Gt(e){return"string"==typeof e||e instanceof String}function zt(e){return Array.isArray(e)?zt(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":"number"==typeof e?"float32":Gt(e)?"string":function(e){return"boolean"==typeof e}(e)?"bool":"float32"}function qt(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Ht(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 Vt(e,t,n,r=!1){const a=new Array;if(1===t.length){const i=t[0]*(r?2:1);for(let t=0;t<i;t++)a[t]=n[e+t]}else{const i=t[0],o=t.slice(1),s=o.reduce(((e,t)=>e*t))*(r?2:1);for(let t=0;t<i;t++)a[t]=Vt(e+t*s,o,n,r)}return a}function Wt(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 Vt(0,e,t,n)}function Kt(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 Yt(e){e.forEach((t=>{Pt(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function Xt(e){return e&&e.then&&"function"==typeof e.then}const Jt="tfjsflags";class Zt{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Qt,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&(en().getBool("IS_TEST")||en().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];en().getBool("IS_TEST")||en().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(Xt(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(Jt in e){e[Jt].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 Qt(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 en(){return nn}let tn,nn=null;function rn(){if(null==tn){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}tn=e}return tn}function an(e,t){const n=function(){const e=rn();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 on="Add",sn="Cast",ln="Identity";function un(...e){en().getBool("IS_TEST")||en().getBool("PROD")||console.warn(...e)}const cn=an("kernelRegistry",(()=>new Map)),dn=an("gradRegistry",(()=>new Map));function hn(e,t){const n=function(e,t){return`${t}_${e}`}(e,t);return cn.get(n)}function fn(e){return dn.get(e)}function pn(e){const t=cn.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[i,o]=a,[s]=i.split("_");s===e&&n.push(o)}return n}function gn(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}function mn(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=wn(e)),en().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 vn(){return en().platform.now()}function yn(e,t="utf-8"){return t=t||"utf-8",en().platform.decode(e,t)}function bn(e){return null!=en().platform.isTypedArray?en().platform.isTypedArray(e):gn(e)}function wn(e,t=[],n=!1){if(null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||Xt(e)||null==e||bn(e)&&n)t.push(e);else if(Array.isArray(e)||bn(e))for(let r=0;r<e.length;++r)wn(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 a=0;a<=r;a++)wn(e[a],t,n)}return t}class xn{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new kn)}profileKernel(e,t,n){let r;const a=()=>{r=n()};let i;const o=vn();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(a);else{a();for(const e of r)e.dataSync();i=Promise.resolve({kernelMs:vn()-o})}if(en().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<r.length;t++){const n=r[t];n.data().then((t=>{En(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:i.then((e=>e.kernelMs)),extraInfo:i.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:i}=e;n.forEach((e=>{Promise.all([e.data(),r,i]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])}))}))}}function En(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 kn{logKernelProfile(e,t,n,r,a,i){const o="number"==typeof r?$t(`${r}ms`,9):r.error,s=$t(e,25),l=t.rank,u=t.size,c=$t(t.shape.toString(),14);let d="";for(const e in a){const n=a[e];if(null!=n){const r=n.shape||t.shape,a=r.length;d+=`${e}: ${a}D ${a>0?r:""} `}}console.log(`%c${s}\t%c${o}\t%c${l}D ${c}\t%c${u}\t%c${d}\t%c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}const Sn=20,Cn=3,Tn=7;function An(e,t,n,r){const a=Ht(t),i=function(e,t,n,r){const a=Bt(t),i=r[r.length-1],o=new Array(i).fill(0),s=t.length,l="complex64"===n?Dn(e):e;if(s>1)for(let e=0;e<a/i;e++){const t=e*i;for(let e=0;e<i;e++)o[e]=Math.max(o[e],Rn(l[t+e],0,n).length)}return o}(e,t,n,a),o=t.length,s=_n(e,t,n,a,i),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 Rn(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(Tn))} + ${parseFloat(e[1].toFixed(Tn))}j`:Gt(e)?`'${e}'`:"bool"===n?In(e):parseFloat(e.toFixed(Tn)).toString(),$t(r,t)}function In(e){return 0===e?"false":"true"}function _n(e,t,n,r,a,i=!0){const o="complex64"===n?2:1,s=t[0],l=t.length;if(0===l){if("complex64"===n){return[Rn(Dn(e)[0],0,n)]}return"bool"===n?[In(e[0])]:[e[0].toString()]}if(1===l){if(s>Sn){let t=Array.from(e.slice(0,Cn*o)),r=Array.from(e.slice((s-Cn)*o,s*o));return"complex64"===n&&(t=Dn(t),r=Dn(r)),["["+t.map(((e,t)=>Rn(e,a[t],n))).join(", ")+", ..., "+r.map(((e,t)=>Rn(e,a[s-Cn+t],n))).join(", ")+"]"]}return["["+("complex64"===n?Dn(e):Array.from(e)).map(((e,t)=>Rn(e,a[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<Cn;t++){const r=t*d;h.push(..._n(e.slice(r,r+d),u,n,c,a,!1))}h.push("...");for(let t=s-Cn;t<s;t++){const r=t*d;h.push(..._n(e.slice(r,r+d),u,n,c,a,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,a,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]+"]"+(i?"":p),h}function Dn(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}class Fn{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=Bt(e),null!=n){const e=n.length;Pt(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=Ht(e)}set(e,...t){0===t.length&&(t=[0]),Pt(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 Mn().makeTensor(this.values,this.shape,this.dtype)}}let Mn=null,Ln=null;class Nn{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=Bt(e),this.strides=Ht(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 Wt(this.shape,e,"complex64"===this.dtype)}arraySync(){return Wt(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=Mn().read(this.dataId);if("string"===this.dtype){const t=await e;try{return t.map((e=>yn(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(),Mn().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Mn().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>yn(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 Mn().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Mn().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 An(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Ln.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Mn().makeVariable(this,e,t,n)}}Object.defineProperty(Nn,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),an("Tensor",(()=>Nn));class On extends Nn{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(!Ut(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Mn().disposeTensor(this),this.dataId=e.dataId,Mn().incRef(this,null)}dispose(){Mn().disposeVariable(this),this.isDisposedInternal=!0}}var Pn,Bn,Un,$n,jn;Object.defineProperty(On,Symbol.hasInstance,{value:e=>e instanceof Nn&&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"}(Pn||(Pn={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(Bn||(Bn={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(Un||(Un={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}($n||($n={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(jn||(jn={}));const Gn={float32:$n,int32:Bn,bool:Un,complex64:jn};function zn(e){return null!=e&&"object"==typeof e&&"texture"in e&&e.texture instanceof WebGLTexture}function qn(e){return"undefined"!=typeof GPUBuffer&&null!=e&&"object"==typeof e&&"buffer"in e&&e.buffer instanceof GPUBuffer}function Hn(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 Gn[e][t]}(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function Vn(e){const t=[];return Wn(e,t,new Set),t}function Wn(e,t,n){if(null==e)return;if(e instanceof Nn)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const a=e;for(const e in a){const r=a[e];n.has(r)||(n.add(r),Wn(r,t,n))}}function Kn(e){return null!=e.kernelName}class Yn{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 Xn{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Yn}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?(un(`${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 xn(this.backendInstance),!0}setupRegisteredKernels(){pn(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){pn(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 Nt||"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,un(`Initialization of backend ${e} failed`),un(n.stack||n.message)),!1)));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(t){return un(`Initialization of backend ${e} failed`),un(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:a}=this.initializeBackend(n);if(a||r)return{name:n,asyncInit:a}}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,a=this.readSync(t),i=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,a,n.shape,n.dtype,i),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 Xn.nextTensorId++}nextVariableId(){return Xn.nextVariableId++}clone(e){const t=Zn.runKernel(ln,{x:e});return this.addTapeNode(this.state.activeScope.name,{x:e},[t],(e=>({x:()=>Zn.runKernel(sn,{x:e},{dtype:"float32"})})),[],{}),t}runKernel(e,t,n){if(!(null!=hn(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 a=0;n.forEach((e=>{a+="complex64"===e.dtype?3:1}));const i=r-t-a-this.state.numDataMovesStack[this.state.numDataMovesStack.length-1];if(i>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,i=this.state.numTensors;let o,s;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);const l=Kn(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(Kn(e)){const{kernelName:t,inputs:a,attrs:i}=e,l=hn(t,this.backendName);Pt(null!=l,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),o=()=>{const e=this.backend.numDataIds();s=l.kernelFunc({inputs:a,attrs:i,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,a,u);n=this.saveTensorsForBackwardMode(e)}return u}}else{const{forwardFunc:t}=e,a=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};o=()=>{const e=this.backend.numDataIds();s=this.tidy((()=>t(this.backend,a)));const n=Array.isArray(s)?s:[s];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,e,n),n}}const{inputs:u,attrs:c}=e,d=Kn(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-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,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=fn(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let i;r.saveAllInputs?(Pt(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),i=Object.keys(t).map((e=>t[e]))):i=e.map((e=>t[e]));const o=n.filter(((e,t)=>a[t]));return i.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 a=e;"string"===(n=n||"float32")&&Gt(e[0])&&(a=e.map((e=>function(e,t="utf-8"){return t=t||"utf-8",en().platform.encode(e,t)}(e))));const i=r.write(a,t,n),o=new Nn(t,n,i,this.nextTensorId());if(this.trackTensor(o,r),"string"===n){const e=this.state.tensorInfo.get(i),t=function(e){if(null==e)return 0;let t=0;return e.forEach((e=>t+=e.length)),t}(a);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:a}=e,i=new Nn(r,a,n,this.nextTensorId());return this.trackTensor(i,t),i}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new On(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*jt(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 On||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*jt(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,a,i){const o={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},s=fn(e);null!=s&&(r=s.gradFunc),null!=r&&(o.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=Kt(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],a,i))),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=Vn(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(Pt(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 a=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));Pt(a instanceof Nn,(()=>"The result y returned by f() must be a tensor."));const i=function(e,t,n){const r={},a={};for(let e=0;e<t.length;e++)r[t[e].id]=!0;for(let n=0;n<e.length;n++){const i=e[n],o=i.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]){i.outputs.forEach((e=>r[e.id]=!0)),s=!0,a[i.id]=!0;break}if(s)break}}const i={};i[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(i[n.outputs[e].id]){for(const e in r)i[r[e].id]=!0,o[n.id]=!0;break}}const s=[];for(let t=0;t<e.length;t++){const n=e[t];if(a[n.id]&&o[n.id]){const e={};for(const t in n.inputs){const a=n.inputs[t];r[a.id]&&(e[t]=a)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,s.push(t)}}return s}(this.state.activeTape,t,a);if(!r&&0===i.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[a.id]=null==n?function(e){const t=function(e,t){const n=Kt(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}(Bt(e),"float32");return Zn.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const i=t[a],o=[];if(i.outputs.forEach((t=>{const n=e[t.id];o.push(null!=n?n:null)})),null==i.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${i.kernelName}.`);const s=i.gradient(o);for(const t in i.inputs){if(!(t in s))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(s)}.`);const a=n((()=>s[t]()));if("float32"!==a.dtype)throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const o=i.inputs[t];if(!Ut(a.shape,o.shape))throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${o.shape}'`);if(null==e[o.id])e[o.id]=a;else{const t=e[o.id];e[o.id]=r(t,a),t.dispose()}}}}(e,i,(e=>this.tidy(e)),Qn);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:a,grads:r}}))}customGrad(e){return Pt(qt(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;Pt(t.every((e=>e instanceof Nn)),(()=>"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,a)=>(n=e(...t,a),Pt(n.value instanceof Nn,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),Pt(qt(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 a=n.gradFunc(e,r),i=Array.isArray(a)?a:[a];Pt(i.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(...).")),Pt(i.every((e=>e instanceof Nn)),(()=>"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 i.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=vn(),n=await this.backend.time(e);return n.wallMs=vn()-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 Yn;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 Jn(){const e=rn();if(null==e._tfengine){const t=new Zt(e);e._tfengine=new Xn(t)}return nn=e._tfengine.ENV,function(e){Mn=e}((()=>e._tfengine)),e._tfengine}Xn.nextTensorId=0,Xn.nextVariableId=0;const Zn=Jn();function Qn(e,t){return Zn.runKernel(on,{a:e,b:t})}const er=en();function tr(e,t){let n=e;if(bn(e))return"string"===t?[]:[e.length];if(zn(e)){return[e.height,e.width*(e.channels||"RGBA").length]}if(qn(e))return[e.buffer.size/(null==t?4:jt(t))];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||bn(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&en().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&nr(e,r,[]),r}function nr(e,t,n){if(n=n||[],!Array.isArray(e)&&!bn(e))return void Pt(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));Pt(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),Pt(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)nr(e[t],r,n.concat(t))}function rr(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 ar(e,t,n,r="numeric"){if(e instanceof Nn)return rr(r,e.dtype,t,n),e;let a=zt(e);if("string"!==a&&["bool","int32","float32"].indexOf(r)>=0&&(a=r),rr(r,a,t,n),null==e||!bn(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 i=tr(e,a);bn(e)||Array.isArray(e)||(e=[e]);const o="string"!==a?mn(e,a):wn(e,[],!0);return Zn.makeTensor(o,i,a)}er.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.")})),er.registerFlag("IS_BROWSER",(()=>"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope)),er.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),er.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),er.registerFlag("IS_SAFARI",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor))),er.registerFlag("PROD",(()=>!1)),er.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>er.getBool("DEBUG"))),er.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),er.registerFlag("IS_TEST",(()=>!1)),er.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>er.getBool("DEBUG"))),er.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),er.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(()=>!1)),er.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 a=(...e)=>{Zn.startScope(n);try{const t=r(...e);return Xt(t)&&console.error("Cannot return a Promise inside of tidy."),Zn.endScope(t),t}catch(e){throw Zn.endScope(null),e}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}class or{static join(e){return new or(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,null==e)return;if(e instanceof Array||(e=[e]),0===(e=e.map((e=>bn(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 a=t+r.byteLength;this.shards.push({buffer:r,start:t,end:a}),t=a}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),a=new Uint8Array(r);let i=0;for(let r=n;r<this.shards.length;r++){const n=this.shards[r],o=e+i-n.start,s=i,l=Math.min(t,n.end),u=new Uint8Array(n.buffer,o,l-n.start-o);if(a.set(u,s),i+=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 a=Math.floor((r-n)/2)+n,i=t(e[a]);if(0===i)return a;i<0?r=a:n=a+1}return-1}(this.shards,t);return-1===n?-1:(this.previousShardIndex=n,this.previousShardIndex)}}const sr="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function lr(e){return sr?Buffer.byteLength(e,"utf8"):new Blob([e]).size}function ur(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:lr(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:lr(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:new or(e.weightData).byteLength}}class cr{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==cr.instance&&(cr.instance=new cr),cr.instance}static registerSaveRouter(e){cr.getInstance().saveRouters.push(e)}static registerLoadRouter(e){cr.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return cr.getHandlers(e,"save")}static getLoadHandlers(e,t){return cr.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?cr.getInstance().loadRouters:cr.getInstance().saveRouters).forEach((t=>{const a=t(e,n);null!==a&&r.push(a)})),r}}const dr="tensorflowjs",hr="models_store",fr="model_info_store";function pr(){if(!en().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 gr(e){const t=e.result;t.createObjectStore(hr,{keyPath:"modelPath"}),t.createObjectStore(fr,{keyPath:"modelPath"})}class mr{constructor(e){if(this.indexedDB=pr(),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(dr,1);r.onupgradeneeded=()=>gr(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(hr,"readonly"),r=t.objectStore(hr).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=ur(t),i=a.transaction(fr,"readwrite");let o,s,l=i.objectStore(fr);try{o=l.put({modelPath:this.modelPath,modelArtifactsInfo:r})}catch(e){return n(e)}o.onsuccess=()=>{s=a.transaction(hr,"readwrite");const o=s.objectStore(hr);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=i.objectStore(fr);const t=l.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(u.error)),t.onerror=e=>(a.close(),n(u.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==s?a.close():s.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)}))}}mr.URL_SCHEME="indexeddb://";const vr=e=>{return en().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(mr.URL_SCHEME)?(t=e.slice(mr.URL_SCHEME.length),new mr(t)):null;var t};cr.registerSaveRouter(vr),cr.registerLoadRouter(vr);class yr{constructor(){this.indexedDB=pr()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(dr,1);n.onupgradeneeded=()=>gr(n),n.onsuccess=()=>{const r=n.result,a=r.transaction(fr,"readonly"),i=a.objectStore(fr).getAll();i.onsuccess=()=>{const t={};for(const e of i.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},i.onerror=e=>(r.close(),t(i.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(mr.URL_SCHEME)?t.slice(mr.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(dr,1);r.onupgradeneeded=()=>gr(r),r.onsuccess=()=>{const a=r.result,i=a.transaction(fr,"readwrite"),o=i.objectStore(fr),s=o.get(e);let l;s.onsuccess=()=>{if(null==s.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=o.delete(e),i=()=>{l=a.transaction(hr,"readwrite");const r=l.objectStore(hr).delete(e);r.onsuccess=()=>t(s.result.modelArtifactsInfo),r.onerror=e=>n(s.error)};r.onsuccess=i,r.onerror=e=>(i(),a.close(),n(s.error))}},s.onerror=e=>(a.close(),n(s.error)),i.oncomplete=()=>{null==l?a.close():l.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)}))}}const br="/",wr="tensorflowjs_models",xr="info",Er="model_topology",kr="weight_specs",Sr="weight_data",Cr="model_metadata";function Tr(e){return{info:[wr,e,xr].join(br),topology:[wr,e,Er].join(br),weightSpecs:[wr,e,kr].join(br),weightData:[wr,e,Sr].join(br),modelMetadata:[wr,e,Cr].join(br)}}function Ar(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function Rr(e){const t=e.split(br);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(br)}class Ir{constructor(e){if(!en().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=Tr(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=ur(e),a=or.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(sr)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)}(a));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 Ar(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 a=this.LS.getItem(this.keys.modelMetadata);if(null!=a){const e=JSON.parse(a);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 i=this.LS.getItem(this.keys.weightData);if(null==i)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=function(e){if(sr){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}(i),t}}Ir.URL_SCHEME="localstorage://";const _r=e=>{return en().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ir.URL_SCHEME)?(t=e.slice(Ir.URL_SCHEME.length),new Ir(t)):null;var t};cr.registerSaveRouter(_r),cr.registerLoadRouter(_r);class Dr{constructor(){Pt(en().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),Pt("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=wr+br,n=br+xr;for(let r=0;r<this.LS.length;++r){const a=this.LS.key(r);if(a.startsWith(t)&&a.endsWith(n)){e[Rr(a)]=JSON.parse(this.LS.getItem(a))}}return e}async removeModel(e){var t;const n=Tr(e=(t=e).startsWith(Ir.URL_SCHEME)?t.slice(Ir.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 Ar(n),r}}class Fr{constructor(){this.managers={}}static getInstance(){return null==Fr.instance&&(Fr.instance=new Fr),Fr.instance}static registerManager(e,t){Pt(null!=e,(()=>"scheme must not be undefined or null.")),e.endsWith("://")&&(e=e.slice(0,e.indexOf("://"))),Pt(e.length>0,(()=>"scheme must not be an empty string."));const n=Fr.getInstance();Pt(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=Fr.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(Fr.getInstance().managers)}}class Mr{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&&en().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 gn(e)}}if(en().get("IS_BROWSER")){en().setPlatform("browser",new Mr);try{Fr.registerManager(Ir.URL_SCHEME,new Dr)}catch(e){}try{Fr.registerManager(mr.URL_SCHEME,new yr)}catch(e){}}const Lr=()=>require("node-fetch");let Nr;class Or{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=en().global.fetch?en().global.fetch(e,t):(null==Nr&&(Nr=Lr()),Nr(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)}}en().get("IS_NODE")&&!en().get("IS_BROWSER")&&en().setPlatform("node",new Or);const Pr=ir({cast_:function(e,t){const n=ar(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 Zn.runKernel(sn,{x:n},{dtype:t})}});const Br=ir({clone_:function(e){const t=ar(e,"x","clone","string_or_numeric");return Zn.runKernel(ln,{x:t})}});Jn();const Ur={buffer:function(e,t="float32",n){return t=t||"float32",Yt(e),new Fn(e,t,n)},cast:Pr,clone:Br,print:function(e,t=!1){console.log(e.toString(t))}};function $r(e,t){return Zn.tidy(e,t)}function jr(e){Vn(e).forEach((e=>e.dispose()))}Ln=Ur;const Gr=ir({add_:function(e,t){let n=ar(e,"a","add"),r=ar(t,"b","add");return[n,r]=Hn(n,r),Zn.runKernel(on,{a:n,b:r})}});const zr=ir({floorDiv_:function(e,t){let n=ar(e,"a","floorDiv"),r=ar(t,"b","floorDiv");return[n,r]=Hn(n,r),Zn.runKernel("FloorDiv",{a:n,b:r})}});const qr=ir({div_:function(e,t){let n=ar(e,"a","div"),r=ar(t,"b","div");return[n,r]=Hn(n,r),"int32"===n.dtype&&"int32"===r.dtype?zr(n,r):Zn.runKernel("RealDiv",{a:n,b:r},{})}});const Hr=ir({mul_:function(e,t){let n=ar(e,"a","mul"),r=ar(t,"b","mul");return[n,r]=Hn(n,r),Zn.runKernel("Multiply",{a:n,b:r})}});const Vr=ir({abs_:function(e){const t=ar(e,"x","abs");if("complex64"===t.dtype){return Zn.runKernel("ComplexAbs",{x:t})}return Zn.runKernel("Abs",{x:t})}});const Wr=ir({zerosLike_:function(e){const t=ar(e,"x","zerosLike");return Zn.runKernel("ZerosLike",{x:t})}});const Kr=ir({pow_:function(e,t){let n=ar(e,"base","pow"),r=ar(t,"exp","pow");return[n,r]=Hn(n,r),Zn.runKernel("Pow",{a:n,b:r})}});function Yr(e,t){if((bn(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&&bn(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=zt(e);else if("complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(qn(e)||zn(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 Zn.backend.createTensorFromGPUData(e,t||n,r)}if(!bn(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){Yt(t);const e=Bt(t),r=Bt(n);Pt(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]!==Bt(t.slice(e));Pt(n[e]===t[e]||!r,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return bn(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?mn(e,r):wn(e,[],!0),Zn.makeTensor(e,t,r)}(e,[],[],t)}const Xr=ir({sqrt_:function(e){const t=ar(e,"x","sqrt","float32");return Zn.runKernel("Sqrt",{x:t})}});const Jr=ir({square_:function(e){const t=ar(e,"x","square");return Zn.runKernel("Square",{x:t},{})}});const Zr=ir({sub_:function(e,t){let n=ar(e,"a","sub"),r=ar(t,"b","sub");return[n,r]=Hn(n,r),Zn.runKernel("Sub",{a:n,b:r})}});const Qr=ir({maximum_:function(e,t){let n=ar(e,"a","maximum"),r=ar(t,"b","maximum");return[n,r]=Hn(n,r),"bool"===n.dtype&&(n=Pr(n,"int32"),r=Pr(r,"int32")),function(e,t){const n=Math.max(e.length,t.length),r=new Array(n);for(let a=0;a<n;a++){let i=e[e.length-a-1];null==i&&(i=1);let o=t[t.length-a-1];if(null==o&&(o=1),1===i)r[n-a-1]=o;else if(1===o)r[n-a-1]=i;else{if(i!==o)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);r[n-a-1]=i}}}(n.shape,r.shape),Zn.runKernel("Maximum",{a:n,b:r})}});class ea{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class ta{constructor(){this.classNameMap={}}static getMap(){return null==ta.instance&&(ta.instance=new ta),ta.instance}static register(e){ta.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function na(e){Pt(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),Pt("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),Pt(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),ta.register(e)}class ra extends ea{minimize(e,t=!1,n){const{value:r,grads:a}=this.computeGradients(e,n);if(null!=n){const e=n.map((e=>({name:e.name,tensor:a[e.name]})));this.applyGradients(e)}else this.applyGradients(a);return jr(a),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){Pt(qt(e),(()=>"The f passed in variableGrads(f) must be a function")),Pt(null==t||Array.isArray(t)&&t.every((e=>e instanceof On)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=t;if(!n){t=[];for(const e in Zn.registeredVariables)t.push(Zn.registeredVariables[e])}const r=n?t.filter((e=>!e.trainable)):null,a=t.length;Pt((t=t.filter((e=>e.trainable))).length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${a} variables is trainable.`));const{value:i,grads:o}=Zn.gradients(e,t,null,!0);Pt(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().")),Pt(0===i.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.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:i,grads:s}}(e,t)}dispose(){null!=this.iterations_&&jr(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:Yr(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(ra,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class aa extends ra{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 a=Zn.registeredVariables[t];$r((()=>{const e=Gr(Hr(this.c,r),a);a.assign(e)}))})),this.incrementIterations()}setLearningRate(e){var t;this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=(t=Yr(-e),Zn.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 ia=[class extends ra{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=Zn.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Zn.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:$r((()=>Wr(r).variable(false)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:$r((()=>Wr(r).variable(false)))});const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable,o=this.accumulatedUpdates[n].variable;$r((()=>{const e=Gr(Hr(i,this.rho),Hr(Jr(a),1-this.rho)),t=Hr(qr(Xr(Gr(o,this.epsilon)),Xr(Gr(i,this.epsilon))),a),n=Gr(Hr(o,this.rho),Hr(Jr(t),1-this.rho));i.assign(e),o.assign(n);const s=Gr(Hr(t,-this.learningRate),r);r.assign(s)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(jr(this.accumulatedGrads.map((e=>e.variable))),jr(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 ra{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=Zn.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:$r((()=>function(e,t,n){return Yt(e),n=n||zt(t),Zn.runKernel("Fill",{},{shape:e,value:t,dtype:n})}(r.shape,this.initialAccumulatorValue).variable(e)))}}const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable;$r((()=>{const e=Gr(i,Jr(a));i.assign(e);const t=Gr(Hr(qr(a,Xr(Gr(e,Zn.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&jr(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 ra{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=[],$r((()=>{this.accBeta1=Yr(t).variable(),this.accBeta2=Yr(n).variable()})),null==r&&(this.epsilon=Zn.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);$r((()=>{const n=Zr(1,this.accBeta1),r=Zr(1,this.accBeta2);t.forEach(((t,a)=>{const i=Zn.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:$r((()=>Wr(i).variable(false)))}),null==this.accumulatedSecondMoment[a]&&(this.accumulatedSecondMoment[a]={originalName:`${t}/v`,variable:$r((()=>Wr(i).variable(false)))});const o=Array.isArray(e)?e[a].tensor:e[t];if(null==o)return;const s=this.accumulatedFirstMoment[a].variable,l=this.accumulatedSecondMoment[a].variable,u=Gr(Hr(s,this.beta1),Hr(o,1-this.beta1)),c=Gr(Hr(l,this.beta2),Hr(Jr(o),1-this.beta2)),d=qr(u,n),h=qr(c,r);s.assign(u),l.assign(c);const f=Gr(Hr(qr(d,Gr(Xr(h),this.epsilon)),-this.learningRate),i);i.assign(f)})),this.accBeta1.assign(Hr(this.accBeta1,this.beta1)),this.accBeta2.assign(Hr(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&jr(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&jr(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),$r((()=>{this.accBeta1.assign(Kr(this.beta1,this.iterations_+1)),this.accBeta2.assign(Kr(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 ra{static get className(){return"Adamax"}constructor(e,t,n,r=null,a=0){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=a,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],$r((()=>{this.iteration=Yr(0).variable(),this.accBeta1=Yr(t).variable()})),null==r&&(this.epsilon=Zn.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);$r((()=>{const n=Zr(1,this.accBeta1),r=qr(-this.learningRate,Gr(Hr(this.iteration,this.decay),1));t.forEach(((t,a)=>{const i=Zn.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:Wr(i).variable(false)}),null==this.accumulatedWeightedInfNorm[a]&&(this.accumulatedWeightedInfNorm[a]={originalName:`${t}/v`,variable:Wr(i).variable(false)});const o=Array.isArray(e)?e[a].tensor:e[t];if(null==o)return;const s=this.accumulatedFirstMoment[a].variable,l=this.accumulatedWeightedInfNorm[a].variable,u=Gr(Hr(s,this.beta1),Hr(o,1-this.beta1)),c=Hr(l,this.beta2),d=Vr(o),h=Qr(c,d);s.assign(u),l.assign(h);const f=Gr(Hr(qr(r,n),qr(u,Gr(h,this.epsilon))),i);i.assign(f)})),this.iteration.assign(Gr(this.iteration,1)),this.accBeta1.assign(Hr(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&jr(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&jr(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 aa{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=Yr(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Zn.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:$r((()=>Wr(r).variable(e)))}}const a=this.accumulations[n].variable,i=Array.isArray(e)?e[n].tensor:e[t];null!=i&&$r((()=>{let e;const t=Gr(Hr(this.m,a),i);e=Gr(Hr(this.c,this.useNesterov?Gr(i,Hr(t,this.m)):t),r),a.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&jr(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 ra{static get className(){return"RMSProp"}constructor(e,t=.9,n=0,r=null,a=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=a,null==r&&(this.epsilon=Zn.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=Zn.registeredVariables[t],a=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:$r((()=>Wr(r).variable(a)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:$r((()=>Wr(r).variable(a)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:$r((()=>Wr(r).variable(a)))});const i=Array.isArray(e)?e[n].tensor:e[t];if(null==i)return;const o=this.accumulatedMeanSquares[n].variable,s=this.accumulatedMoments[n].variable;$r((()=>{const e=Gr(Hr(o,this.decay),Hr(Jr(i),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,a=Gr(Hr(t,this.decay),Hr(i,1-this.decay)),l=qr(Hr(i,this.learningRate),Xr(Zr(e,Gr(Jr(a),this.epsilon)))),u=Gr(Hr(s,this.momentum),l);o.assign(e),t.assign(a),s.assign(u);const c=Zr(r,u);r.assign(c)}else{const e=Gr(Hr(o,this.decay),Hr(Jr(i),1-this.decay)),t=Gr(Hr(s,this.momentum),qr(Hr(i,this.learningRate),Xr(Gr(e,this.epsilon))));o.assign(e),s.assign(t);const n=Zr(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&jr(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&jr(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&jr(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)}},aa];!function(){for(const e of ia)na(e)}();const oa={},sa={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function la(e,t){if(!(e in oa)||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(en().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 oa[e]}),!1),en().getBool("SOFTWARE_WEBGL_ENABLED")&&(sa.failIfMajorPerformanceCaveat=!1);if(1===e)return n.getContext("webgl",sa)||n.getContext("experimental-webgl",sa);return n.getContext("webgl2",sa)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;oa[e]=n}const n=oa[e];return null==n||n.isContextLost()?(delete oa[e],la(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),oa[e])}var ua="https://websdk-cdn-dev.idmission.com/assets";function ca(e){var t=e.width,n=e.height;return e instanceof HTMLVideoElement&&(t=e.videoWidth,n=e.videoHeight),[t,n]}function da(e,t){var n=document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("could not get 2d context");var a=t.box,i=a.width,o=.6*e.height-i,s=Math.max(0,a.xMin-o/2);return Tt()?(n.width=e.width,n.height=e.height,r.drawImage(e,0,0,n.width,n.height)):(n.width=i+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 ha={boxes:0,scores:7,labels:4},fa=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}}),pa="".concat(ua,"/models/documentdetection448/model.json"),ga="".concat(ua,"/models/focus/model.json"),ma=function(e){var t=e.children,r=e.documentDetectionModelUrl,a=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),k=E[0],S=E[1],C=n.useState(0),T=C[0],A=C[1],R=n.useRef(!1),I=n.useRef(),_=n.useRef(null),D=n.useState(0),F=D[0],M=D[1],L=n.useState(0),N=L[0],O=L[1];n.useEffect((function(){l(!1);var e=r||pa,t=a||ga;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([wt(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(a){switch(a.label){case 0:return l(!1),yt=null,Ft=null,delete oa[2],(r=document.createElement("canvas").getContext("webgl2"))&&e&&t?(i.setWebGLContext(2,r),function(){try{f.backend().dispose()}catch(e){console.error("failed to dispose backend",e)}}(),[4,n()]):[3,2];case 1:a.sent(),l(!0),a.label=2;case 2:return[2]}}))}))}n().then((function(){l(!0)}));var s=la(2).canvas;return s.addEventListener("webglcontextlost",o),function(){var e;null===(e=s.removeEventListener)||void 0===e||e.call(s,"webglcontextlost",o)}}),[r,a]);var P=n.useMemo((function(){return{document:d,passport:v,mrz:w,pdf417:k,focus:T}}),[d,T,w,v,k]),B=n.useCallback((function(e){e.document&&h(e.document),e.passport&&y(e.passport),e.mrz&&x(e.mrz),e.pdf417&&S(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 yt&&Ft&&_.current?[4,ya(e,_.current,P)]:[2];case 1:return t=r.sent(),M(t.detectionTime),O(t.focusPredictionTime),$.current<=t.focusScore&&($.current=t.focusScore,va(U.current,e)),null===(n=I.current)||void 0===n||n.call(I,t),R.current=!1,[2]}}))}))}),[P]),G=n.useCallback((function(e){I.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(fa.Provider,{value:H},t,u.default.createElement(Ta,{ref:_}),u.default.createElement(Ta,{ref:U}))};function va(e,t,n,r){if(e){var a=e.getContext("2d");if(a){if(!n||!r){var i=ca(t);n||(n=i[0]),r||(r=i[1])}e.width=n,e.height=r,a.drawImage(t,0,0,n,r)}}}function ya(e,t,n){var r,a,i,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,k,S,C,T,A,R,I,_,D,F,M,L,N,O,P,B,U,$,j;return m(this,(function(m){switch(m.label){case 0:return f=ca(e),p=f[0],g=f[1],va(t,e),[4,ba(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],a=e[1];return{score:t,bbox:[a,r,e[3]-a,e[2]-r],label:xt[n]}}(e,y[t],b[t])}))),E=x.find((function(e){return"Document"===e.label})),k=x.find((function(e){return"Passport Page"===e.label})),S=null!==(r=null==E?void 0:E.score)&&void 0!==r?r:0,C=null!==(a=null==k?void 0:k.score)&&void 0!==a?a:0,T=C>=(null!==(i=n.passport)&&void 0!==i?i:0),A=S>C?E:k,I=(R=T?C:S)>=(null!==(o=n.document)&&void 0!==o?o:0),_=vt.NONE,T?_=vt.PASSPORT:I&&(_=vt.ID_CARD),D=x.find((function(e){return"MRZ"===e.label})),F=null!==(s=null==D?void 0:D.score)&&void 0!==s?s:0,M=F>=(null!==(l=n.mrz)&&void 0!==l?l:0),L=x.find((function(e){return"PDF417"===e.label})),N=null!==(u=null==L?void 0:L.score)&&void 0!==u?u:0,O=N>=(null!==(c=n.pdf417)&&void 0!==c?c:0),P=null,B=0,U=0,$=!1,I?[4,wa(e,null==A?void 0:A.bbox)]:[3,3];case 2:j=m.sent(),B=j[1],U=null!==(d=null==(P=j[0])?void 0:P[1])&&void 0!==d?d:0,$=U>=(null!==(h=n.focus)&&void 0!==h?h:0),m.label=3;case 3:return[2,{detectedObjects:x,detectionScore:R,detectionTime:w,detectionThresholdMet:I,detectedDocumentType:_,passportDetectionScore:C,passportDetectionThresholdMet:T,mrzDetectionScore:F,mrzDetectionThresholdMet:M,pdf417DetectionScore:N,pdf417DetectionThresholdMet:O,bestDocumentOrPassport:A,bestMrz:D,bestPdf417:L,focusScore:U,focusThresholdMet:$,focusPredictionTime:B,frameWidth:p,frameHeight:g}]}}))}))}function ba(e){return g(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,l,u,c,d,h,p,g,v,y,b;return m(this,(function(m){switch(m.label){case 0:if(!yt)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(),a=f.cast(r,"int32"),r.dispose(),s=(o=f).tensor4d,u=(l=Array).from,[4,a.data()];case 2:return i=s.apply(o,[u.apply(l,[m.sent()]),[1,448,448,3]]),a.dispose(),c=f.cast(i,"int32"),i.dispose(),[4,yt.executeAsync(c)];case 3:return d=m.sent(),c.dispose(),[4,(h=d)[ha.boxes].array()];case 4:return p=m.sent()[0],[4,h[ha.scores].array()];case 5:return g=m.sent()[0],[4,h[ha.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 wa(e,t){return g(this,void 0,void 0,(function(){var n,r,a,i,o,s,l,u,c,d,h,p,g;return m(this,(function(m){switch(m.label){case 0:if(!Ft)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 a=ca(e),i=a[0],o=a[1],s=t[0],l=t[1],u=t[2],c=t[3];return n.width=u*i,n.height=c*o,r.drawImage(e,s*i,l*o,u*i,c*o,0,0,u*i,c*o),n}(e,t):e),a=f.image.resizeBilinear(r,[448,448]),r.dispose(),i=f.cast(a,"int32"),a.dispose(),l=(s=f).tensor4d,c=(u=Array).from,[4,i.data()];case 2:return o=l.apply(s,[c.apply(u,[m.sent()]),[1,448,448,3]]),i.dispose(),d=f.cast(o,"int32"),o.dispose(),[4,Ft.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 xa,Ea,ka,Sa,Ca,Ta=h.default.canvas(xa||(xa=y(["\n display: none;\n"],["\n display: none;\n"]))),Aa=h.default.span(Ea||(Ea=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"]))),Ra=h.default.div(ka||(ka=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);":""})),Ia=h.default.div(Sa||(Sa=y(["\n font: 10px monospace;\n position: absolute;\n border: 3px solid ",";\n color: ",";\n ","\n"],["\n font: 10px monospace;\n position: absolute;\n border: 3px solid ",";\n color: ",";\n ","\n"])),(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);":""})),_a=h.default.div(Ca||(Ca=y(["\n position: absolute;\n width: 4px;\n height: 4px;\n border: 2px solid ",";\n font: 10px monospace;\n color: ",";\n border-radius: 50%;\n ","\n"],["\n position: absolute;\n width: 4px;\n height: 4px;\n border: 2px solid ",";\n font: 10px monospace;\n color: ",";\n border-radius: 50%;\n ","\n"])),(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 Da(e){var t=e.enabled,r=void 0===t||t,a=e.pageWidth,i=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=a/i<o/s)?l=((t=o*(i/s))-a)/2:u=((n=s*(a/o))-i)/2),{horizontal:e,pageWidth:a,pageHeight:i,videoWidth:o,videoHeight:s,scaledWidth:t,scaledHeight:n,xOffset:l,yOffset:u}}),[r,i,a,s,o])}function Fa(e){var t=e.obj,n=e.scaling,r=n.horizontal,a=n.pageWidth,i=n.pageHeight,o=n.scaledWidth,s=n.scaledHeight;return u.default.createElement(Ia,{$flipX:e.flipX,style:{top:t.bbox[1]*(r?i:s-n.yOffset),left:t.bbox[0]*(r?o-n.xOffset:a),width:t.bbox[2]*(r?o:a),height:t.bbox[3]*(r?i:s)}},t.label," (",t.score.toFixed(3),")")}function Ma(e){var t,n,r,a,i=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=i.box.yMin/f*d,n=i.box.xMin/h*p-l.xOffset,r=i.box.width/h*p,a=i.box.height/f*d):(t=i.box.yMin/f*g-l.yOffset,n=i.box.xMin/h*c,r=i.box.width/h*c,a=i.box.height/f*g),u.default.createElement(u.default.Fragment,null,u.default.createElement(Ia,{$flipX:o,$color:void 0===s?"green":s,style:{top:t,left:n,width:r,height:a}}),i.keypoints.map((function(e,t){return u.default.createElement(La,{key:t,point:e,scaling:l,flipX:o})})))}function La(e){var t,n,r=e.point,a=e.color,i=e.scaling,o=i.videoWidth,s=i.videoHeight;return i.horizontal?(t=r.x/o*i.scaledWidth-i.xOffset,n=r.y/s*i.pageHeight):(t=r.x/o*i.pageWidth,n=r.y/s*i.scaledHeight-i.yOffset),u.default.createElement(_a,{$flipX:e.flipX,$color:void 0===a?"red":a,style:{top:n-=2,left:t-=2}})}var Na,Oa,Pa,Ba=h.default.button(Na||(Na=y(["\n position: absolute;\n top: 12px;\n right: 12px;\n font-size: 20px;\n width: 32px;\n height: 32px;\n font-family: monospace;\n z-index: 1002;\n border: none;\n border-radius: 4px;\n background: #ccc;\n cursor: pointer;\n\n &:hover {\n background: #ddd;\n }\n"],["\n position: absolute;\n top: 12px;\n right: 12px;\n font-size: 20px;\n width: 32px;\n height: 32px;\n font-family: monospace;\n z-index: 1002;\n border: none;\n border-radius: 4px;\n background: #ccc;\n cursor: pointer;\n\n &:hover {\n background: #ddd;\n }\n"]))),Ua={videoWidth:0,videoHeight:0,captureStartedAt:null,detectedObjects:[],bestDocument:void 0,bestMrz:void 0,bestPdf417:void 0,documentType:vt.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},$a=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,a=n.detectionScore,i=n.detectionThresholdMet,o=n.detectedDocumentType,s=n.passportDetectionScore,l=n.passportDetectionThresholdMet,u=n.mrzDetectionScore,c=n.mrzDetectionThresholdMet,d=n.pdf417DetectionScore,h=n.pdf417DetectionThresholdMet,f=n.bestDocumentOrPassport,g=n.bestMrz,m=n.bestPdf417,v=n.focusScore,y=n.focusThresholdMet,b=n.frameWidth,w=n.frameHeight,x=new Date,E=0,k=e.goodFramesThreshold;e.lastFrameCapturedAt&&(E=1e3/(x.getTime()-e.lastFrameCapturedAt.getTime()))>0&&(k=Math.ceil(3*E));var S=!1;if(f){var C=f.bbox,T=C[0],A=C[1],R=C[2],I=C[3];T*=b,R*=b,S=(A*=w)>5&&A+(I*=w)+5<w&&(T>5||T<5&&T+R>.8*b)&&T+R+5<b}var _=!0===e.autoCaptureBarcodeRequired||"mobile"===e.autoCaptureBarcodeRequired&&Tt(),D=e.barcodeScanningEnabled&&h&&_,F=D&&!e.barcodeResult,M=i&&S&&y,L=e.goodFramesCount;return M&&(L+=1),p(p({},e),{videoWidth:b,videoHeight:w,detectedObjects:r,bestDocument:f,bestMrz:g,bestPdf417:m,documentType:o,documentInBounds:S,documentDetectionScore:a,documentDetectionThresholdMet:i,mrzDetectionScore:u,mrzDetectionThresholdMet:c,pdf417DetectionScore:d,pdf417DetectionThresholdMet:h,passportPageDetectionScore:s,passportPageDetectionThresholdMet:l,focusScore:v,focusThresholdMet:y,shouldScanBarcode:D,waitingForBarcodeScan:F,isGoodFrame:M,goodFramesCount:L,goodFramesThreshold:k,goodFramesThresholdMet:L>=k,lastFrameCapturedAt:x,frameCaptureRate:E});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}},ja=function(e){var t,r,a,i,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,k=e.pdf417DetectionThreshold,S=void 0===k?.15:k,C=e.focusScoreThreshold,T=void 0===C?.3:C,A=e.barcodeScanningEnabled,R=void 0===A||A,I=e.maxBarcodeScanAttempts,_=void 0===I?10:I,D=e.onPrediction,F=e.onBarcodeScanned,M=e.onCapture,L=e.onExit,N=e.processingScreen,O=e.processingDelay,P=void 0===O?0:O,B=e.assets,U=void 0===B?{}:B,$=e.colors,j=void 0===$?{}:$,G=e.verbiage,z=void 0===G?{}:G,q=e.debugMode,H=void 0!==q&&q,V=kt(),W=V.ref,K=V.width,Y=void 0===K?1:K,X=V.height,J=void 0===X?1:X,Z=n.useReducer($a,Ua),Q=Z[0],ee=Z[1],te=n.useState(""),ne=te[0],re=te[1],ae=n.useState(!1),ie=ae[0],oe=ae[1],se=n.useContext(Mt),le=se.cameraRef,ue=se.cameraReady,ce=se.takePhoto,de=se.videoRef,he=se.videoLoaded,fe=ye().t,pe=n.useRef(),ge=n.useContext(fa),me=ge.ready,ve=ge.working,be=ge.setThresholds,we=ge.makePrediction,xe=ge.onPredictionMade,Ee=ge.detectionTime,ke=ge.focusPredictionTime,Se=ge.getBestFrame,Ce=ge.resetBestFrame;n.useEffect((function(){pe.current=new Date}),[]),n.useEffect((function(){ee({type:"configure",payload:{requiredDocumentType:s,goodFramesThreshold:p,autoCaptureBarcodeRequired:y,barcodeScanningEnabled:R,maxBarcodeScanAttempts:_}}),Ce(),be({document:h,passport:E,mrz:w,pdf417:S,focus:T})}),[s,h,T,w,p,y,R,_,E,S,Ce,be]);var Te=n.useRef(0),Ae=n.useRef(!1);n.useEffect((function(){Ae.current=he&&ue&&me&&!Q.capturing&&!Q.captured}),[ue,Q.captured,Q.capturing,me,he]);var Re=n.useState(null),Ie=Re[0],_e=Re[1];n.useEffect((function(){if(me&&ue&&he)return Te.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(!Ae.current||ve.current)return[3,5];r.label=1;case 1:return r.trys.push([1,4,,5]),Q.shouldScanBarcode?[4,ce()]:[3,3];case 2:if(!(t=r.sent()))return Te.current=requestAnimationFrame(e),[2];_e(t),r.label=3;case 3:return de.current&&we(de.current),[3,5];case 4:return n=r.sent(),console.error("error capturing frame",n),[3,5];case 5:return Te.current=requestAnimationFrame(e),[2]}}))}))})),function(){cancelAnimationFrame(Te.current)}}),[ue,we,me,ve,Q.shouldScanBarcode,ce,he,de]),n.useEffect((function(){xe((function(e){ee({type:"objectsDetected",payload:{prediction:e}}),null==D||D(e)}))}),[D,xe]),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 Q.shouldScanBarcode&&Ie?[4,Dt(Ie,null===(t=Q.bestPdf417)||void 0===t?void 0:t.bbox)]:[3,2];case 1:(e=n.sent())?(ee({type:"barcodeScanned",payload:{result:e}}),null==F||F(e)):ee({type:"barcodeScanFailed"}),n.label=2;case 2:return[2]}}))}))}),[F,Q.shouldScanBarcode,null===(t=Q.bestPdf417)||void 0===t?void 0:t.bbox,ce,Ie]);var De=c&&Q.goodFramesThresholdMet&&!Q.capturing&&!Q.captured&&!Q.waitingForBarcodeScan&&Ga(Q.captureStartedAt)>=3e3;n.useEffect((function(){g(void 0,void 0,void 0,(function(){var e,t,n,r,a,i,o,s,l;return m(this,(function(u){switch(u.label){case 0:return De?(ee({type:"capturing"}),[4,Se()]):[2];case 1:return(e=u.sent())?(oe(!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"),ee({type:"captureFailed"}),[2]);case 2:return t=u.sent(),n=t[0],r=t[1],(a=document.createElement("canvas")).width=n,a.height=r,[4,createImageBitmap(e)];case 3:if(i=u.sent(),(n>1920&&r>1080||n>1080&&r>1920)&&Q.barcodeResult){if(n>r?(a.width=1920,a.height=r*(1920/n)):(a.height=1920,a.width=n*(1920/r)),!(o=a.getContext("2d")))return[2];o.drawImage(i,0,0,a.width,a.height)}else{if(!(s=a.getContext("bitmaprenderer")))return[2];s.transferFromImageBitmap(i)}return l=a.toDataURL("image/jpeg",.92),re(l),setTimeout((function(){var e,t=(new Date).getTime()-(null!==(e=pe.current)&&void 0!==e?e:new Date).getTime();null==M||M(l,n,r,{autoCapture:"Y",captureTime:t}),ee({type:"captured"}),oe(!1)}),P),[2]}var c}))}))}),[Se,M,P,De,Q.barcodeResult]);var Fe=Da({enabled:H,pageWidth:Y,pageHeight:J,videoWidth:Q.videoWidth,videoHeight:Q.videoHeight});return ie?N||u.default.createElement("div",null,"Processing..."):""!==ne?u.default.createElement("img",{src:ne,alt:"",style:{maxWidth:"100%",maxHeight:"100%"}}):(j.guideBoxUnsatisfiedColor||(j.guideBoxUnsatisfiedColor="white"),j.guideBoxSatisfiedColor||(j.guideBoxSatisfiedColor="green"),z.instructionText||(z.instructionText=fe("Scan the front of ID")),z.capturingText||(z.capturingText=fe("Capturing...")),z.captureFailedText||(z.captureFailedText=fe("Capture failed!")),u.default.createElement(Ze,{ref:W,className:"flex"},u.default.createElement(At,{width:Y,height:J,instruction:Q.captureFailed?z.captureFailedText:Q.capturing?null==z?void 0:z.capturingText:z.instructionText,portraitGuidesImageUrl:U.portraitGuidesImageUrl,landscapeGuidesImageUrl:U.landscapeGuidesImageUrl,isMirrored:!(null===(r=le.current)||void 0===r?void 0:r.isRearFacing),borderColor:Q.isGoodFrame?j.guideBoxSatisfiedColor:j.guideBoxUnsatisfiedColor}),H&&Q.detectedObjects.length>0&&u.default.createElement(Ra,{$flipX:!(null===(a=le.current)||void 0===a?void 0:a.isRearFacing)},Q.detectedObjects.map((function(e,t){var n;return u.default.createElement(Fa,{key:t,obj:e,scaling:Fe,flipX:!(null===(n=le.current)||void 0===n?void 0:n.isRearFacing)})}))),H&&u.default.createElement(Aa,null,le.current?u.default.createElement(u.default.Fragment,null,"✅ Camera: ",null===(i=le.current)||void 0===i?void 0:i.width,"x",null===(o=le.current)||void 0===o?void 0:o.height):"❌ Camera not ready",u.default.createElement("br",null),Q.frameCaptureRate>.75?"✅":"👎"," Frame Rate:"," ",Math.round(1e3*(Q.frameCaptureRate+Number.EPSILON))/1e3," ","fps (",Ee,"ms doc detect, ",ke,"ms focus)",u.default.createElement("br",null),me?u.default.createElement(u.default.Fragment,null,Q.documentDetectionThresholdMet?"✅":"❌"," Document Score: ",Q.documentDetectionScore," (",Q.documentType,")",u.default.createElement("br",null),Q.documentInBounds?"✅":"❌"," Document In Bounds",u.default.createElement("br",null),Q.focusThresholdMet?"✅":"❌"," Focus Score:"," ",Q.focusScore,u.default.createElement("br",null),Q.goodFramesThresholdMet?"✅":"❌"," Good Frame Count:"," ",Q.goodFramesCount,"/",Q.goodFramesThreshold,R&&Q.autoCaptureBarcodeRequired?u.default.createElement(u.default.Fragment,null,u.default.createElement("br",null),Q.barcodeResult?"✅":"❌"," Barcode Scanned (",_t()?"Native":"ZXing",","," ",Q.barcodeScanFailedAttempts,"/",Q.maxBarcodeScanAttempts," failed attempts)"):null):u.default.createElement(u.default.Fragment,null,"❌ Models not ready")),u.default.createElement(Ba,{onClick:L},"×")))},Ga=function(e){return e?Math.abs((new Date).getTime()-e.getTime()):0},za=function(e){var t=e.accessBlockedImageUrl,r=void 0===t?ua+"/camera-disable-icon.png":t,a=ye().t,i=n.useContext(Mt).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(at,{style:{maxWidth:500,height:"auto",margin:"auto"}},u.default.createElement(it,{style:{flexGrow:0}},u.default.createElement("img",{src:r,alt:a("Camera access blocked")})),u.default.createElement("h3",null,a("Your camera permission is disabled")),u.default.createElement("p",{style:{lineHeight:1.5,marginBottom:50}},a("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(){i()}},u.default.createElement("span",{className:"ladda-label"},a("Retry"))))))},qa=function(e){var t=e.headingText,r=e.useContinuityCameraText,a=e.modelsWarmingUpText,i=e.cameraInitializingText,o=e.cameraAccessBlockedText,s=e.continueText,l=e.continueBtnDisabledBackgroundColor,c=e.continueBtnBackgroundColor,d=e.continueBtnTextColor,h=e.instructionImageUrl,f=void 0===h?ua+"/WebSDK-Instruction-DL-Capture-3-Portrait.png":h,p=e.accessBlockedImageUrl,g=void 0===p?ua+"/camera-disable-icon.png":p,m=e.onDismissed,v=ye().t,y=n.useRef(null),b=n.useRef(null),w=n.useContext(fa).ready,x=n.useContext(Mt),E=x.cameraReady,k=x.cameraAccessDenied,S=x.iphoneContinuityCameraAvailable,C=x.setIphoneContinuityCameraAllowed,T=n.useState(!1),A=T[0],R=T[1];return t||(t=v("Use your device camera to capture your ID")),r||(r=v("Use your iPhone as a webcam")),a||(a=v("Models warming up...")),i||(i=v("Camera initializing...")),o||(o=v("Camera access blocked")),s||(s=v("Continue")),l||(l="gray"),c||(c="mint"),d||(d="white"),n.useEffect((function(){if(y.current){b.current=pt(y.current),b.current.start();var e=0,t=setInterval((function(){var t;e<.9&&(e+=.1),null===(t=b.current)||void 0===t||t.setProgress(e)}),250);return function(){var e;null===(e=b.current)||void 0===e||e.remove(),clearInterval(t)}}}),[]),n.useEffect((function(){var e;if(w&&E)return null===(e=b.current)||void 0===e||e.stop(),function(){return null};var t=setTimeout((function(){R(!1)}),500);return function(){clearTimeout(t)}}),[E,w]),A?u.default.createElement(u.default.Fragment,null):k?u.default.createElement(za,{accessBlockedImageUrl:g}):u.default.createElement(rt,null,u.default.createElement(at,null,u.default.createElement("h3",null,t),u.default.createElement(it,{style:{pointerEvents:"none"}},u.default.createElement("img",{alt:t,src:f})),u.default.createElement("div",{style:{paddingTop:26,height:48,marginTop:-48}},S&&u.default.createElement(u.default.Fragment,null,u.default.createElement("input",{id:"use-continuity-camera",type:"checkbox",defaultChecked:!0,onChange:function(e){C(e.target.checked)}}),u.default.createElement("label",{htmlFor:"use-continuity-camera"},r))),u.default.createElement("button",{ref:y,className:"ladda-button","data-style":"expand-right",disabled:!E||!w,style:{color:d,backgroundColor:E&&w?c:l},onClick:function(){R(!0),null==m||m()}},u.default.createElement("span",{className:"ladda-label"},k?o:E&&w?s:w?i:a))))},Ha=function(e){var t,r=e.instructionText,a=e.frontPortraitGuidesImage,i=e.frontLandscapeGuidesImage,o=e.backPortraitGuidesImage,s=e.backLandscapeGuidesImage,l=ye().t,c=kt(),d=c.ref,h=c.width,f=void 0===h?1:h,g=c.height,m=void 0===g?1:g,v=n.useContext(Mt).cameraRef;r=r||l("Please flip your ID card...");var y=Tt()?0:50,b=!(null===(t=v.current)||void 0===t?void 0:t.isRearFacing),w=n.useContext(St),x=w.orientation,E=w.wrapperRef,k=w.wrapperWidth,S=w.wrapperHeight,C=w.imageAspectRatio,T=w.wrapperAspectRatio,A=w.onImageLoaded,R=w.setDimensions;n.useEffect((function(){R({width:f,height:m})}),[m,R,f]);var I={height:S-2*y-8};C>=T&&(I={width:k-2*y-8});var _=n.useState(1),D=_[0],F=_[1],M=n.useState(0),L=M[0],N=M[1],O=["rotateY(".concat(L,"deg)")];b&&O.push("scaleX(-1)");var P=["rotateY(".concat(180-L,"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?a:i,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"},I)}),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"},I)}))),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)))))},Va=function(e){var t=e.disabled,r=e.onClick,a=e.children,i=n.useRef(null),o=n.useRef(null),s=n.useRef(null);return n.useEffect((function(){if(i.current)return o.current=pt(i.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:i,onClick:r},a)},Wa=function(e){var t=e.capturedDocuments,r=e.onSubmitClick,a=e.onRetryClick,i=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 i=i||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(at,null,u.default.createElement("h1",null,i),u.default.createElement(it,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:a,style:{marginRight:15}},u.default.createElement("span",{className:"ladda-label"},d)),u.default.createElement(Va,{onClick:r,disabled:p===je.SUBMITTING},p===je.SUBMITTING?h:f))))},Ka=function(){var e,t=n.useContext(Mt),r=t.videoRef,a=t.setVideoLoaded,i=t.cameraRef;n.useEffect((function(){a(!1)}),[a]),n.useEffect((function(){var e;r.current&&(null===(e=i.current)||void 0===e?void 0:e.stream)&&(r.current.srcObject=i.current.stream)}),[i,r]);var o=n.useCallback((function(){a(!0)}),[a]);return u.default.createElement(Ya,{autoPlay:!0,playsInline:!0,muted:!0,ref:r,onLoadedData:o,$isRearFacing:null===(e=i.current)||void 0===e?void 0:e.isRearFacing})},Ya=h.default.video(Oa||(Oa=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"}(Pa||(Pa={}));var Xa={captureState:Pa.CAPTURING,capturedDocuments:{},requestedDocumentType:vt.ID_CARD_FRONT,currentDocumentType:vt.NONE,differentDocumentTypeDetections:0,barcodeResult:null},Ja=function(e,t){var n;switch(t.type){case"predictionMade":var r=t.payload.prediction;return(a=p(p({},e),{currentDocumentType:r.detectedDocumentType})).currentDocumentType===e.requestedDocumentType&&(a.differentDocumentTypeDetections=0),"PASSPORT"===r.detectedDocumentType&&"PASSPORT"!==e.requestedDocumentType&&(a.requestedDocumentType=vt.PASSPORT),"PASSPORT"===e.requestedDocumentType&&r.passportDetectionScore<.3&&(a.requestedDocumentType=vt.ID_CARD_FRONT),a;case"barcodeScanned":return p(p({},e),{barcodeResult:t.payload.result});case"imageCaptured":var a=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?a.captureState=Pa.COMPLETE:(console.log("moving back to the front!"),a.requestedDocumentType=vt.ID_CARD_FRONT):(console.log("moving on to back!"),a.requestedDocumentType=vt.ID_CARD_BACK),a;case"reset":return p({},Xa)}},Za=function(e){var t=e.onSuccess,r=e.autoCaptureEnabled,a=void 0===r||r,i=e.autoCaptureGoodFramesRequired,o=void 0===i?3:i,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,k=void 0===E?.3:E,S=e.assets,C=void 0===S?{}:S,T=e.colors,A=void 0===T?{}:T,R=e.verbiage,I=void 0===R?{}:R,_=e.debugMode,D=void 0!==_&&_,F=n.useReducer(Ja,Xa),M=F[0],L=F[1],N=n.useContext(Mt).releaseCameraAccess,O=n.useState(!1),P=O[0],B=O[1],U=n.useContext(qe),$=U.submissionStatus,j=U.submissionResponse,G=U.setIdFrontImage,z=U.setIdBackImage,q=U.setPassportImage,H=U.logIdFrontCaptureAttempt,V=U.logIdBackCaptureAttempt,W=ye().t,K=n.useRef();n.useEffect((function(){K.current=new Date}),[M.capturedDocuments.length]);var Y=n.useCallback((function(e){var t;e.operationTime=(new Date).getTime()-(null!==(t=K.current)&&void 0!==t?t:new Date).getTime(),"ID_CARD_BACK"===M.requestedDocumentType?V(e):H(e)}),[V,H,M.requestedDocumentType]),X=n.useCallback((function(e){L({type:"predictionMade",payload:{prediction:e}})}),[]),J=n.useCallback((function(e){L({type:"barcodeScanned",payload:{result:e}})}),[]),Z=n.useCallback((function(e,t,n,r){Y(r),L({type:"imageCaptured",payload:{imageData:e,width:t,height:n}})}),[Y]),Q=n.useCallback((function(){L({type:"reset"})}),[]),ee=n.useState(0),te=ee[0],ne=ee[1],re=n.useCallback((function(){B(!1),ne((function(e){return e+1})),L({type:"reset"})}),[]);n.useEffect((function(){$!==je.READY&&N()}),[N,$]),C.idCardFrontPortraitGuidesImageUrl||(C.idCardFrontPortraitGuidesImageUrl="".concat(ua,"/Shieldout-IDCard-Front-SVG-Portrait-2.svg")),C.idCardFrontLandscapeGuidesImageUrl||(C.idCardFrontLandscapeGuidesImageUrl="".concat(ua,"/Shieldout-IDCard-Front-SVG-Landscape-2.svg")),C.idCardBackPortraitGuidesImageUrl||(C.idCardBackPortraitGuidesImageUrl="".concat(ua,"/Shieldout-IDCard-Back-SVG-Portrait-2.svg")),C.idCardBackLandscapeGuidesImageUrl||(C.idCardBackLandscapeGuidesImageUrl="".concat(ua,"/Shieldout-IDCard-Back-SVG-Landscape-2.svg")),C.passportPortraitGuidesImageUrl||(C.passportPortraitGuidesImageUrl="".concat(ua,"/Shieldout-Passport-Front-SVG-Portrait-2.svg")),C.passportLandscapeGuidesImageUrl||(C.passportLandscapeGuidesImageUrl="".concat(ua,"/Shieldout-Passport-Front-SVG-Landscape-2.svg")),C.loadingOverlayInstructionImageUrl||(C.loadingOverlayInstructionImageUrl="".concat(ua,"/WebSDK-Instruction-DL-Capture-3-Portrait.png")),I.idCardFrontInstructionText||(I.idCardFrontInstructionText=W("Scan the front of ID")),I.idCardBackInstructionText||(I.idCardBackInstructionText=W("Scan the back of ID")),I.passportInstructionText||(I.passportInstructionText=W("Scan the ID page of passport"));var ae=n.useMemo((function(){return{portraitGuidesImageUrl:C.idCardFrontPortraitGuidesImageUrl,landscapeGuidesImageUrl:C.idCardFrontLandscapeGuidesImageUrl}}),[C.idCardFrontLandscapeGuidesImageUrl,C.idCardFrontPortraitGuidesImageUrl]),ie=n.useMemo((function(){return{instructionText:I.idCardFrontInstructionText,capturingText:I.capturingText,captureFailedText:I.captureFailedText}}),[I.captureFailedText,I.capturingText,I.idCardFrontInstructionText]),oe=n.useMemo((function(){return{portraitGuidesImageUrl:C.idCardBackPortraitGuidesImageUrl,landscapeGuidesImageUrl:C.idCardBackLandscapeGuidesImageUrl}}),[C.idCardBackLandscapeGuidesImageUrl,C.idCardBackPortraitGuidesImageUrl]),se=n.useMemo((function(){return{instructionText:I.idCardBackInstructionText,capturingText:I.capturingText,captureFailedText:I.captureFailedText}}),[I.captureFailedText,I.capturingText,I.idCardBackInstructionText]),le=n.useMemo((function(){return{portraitGuidesImageUrl:C.passportPortraitGuidesImageUrl,landscapeGuidesImageUrl:C.passportLandscapeGuidesImageUrl}}),[C.passportLandscapeGuidesImageUrl,C.passportPortraitGuidesImageUrl]),ue=n.useMemo((function(){return{instructionText:I.passportInstructionText,capturingText:I.capturingText,captureFailedText:I.captureFailedText}}),[I.captureFailedText,I.capturingText,I.passportInstructionText]);if(j)return u.default.createElement(Ze,null,u.default.createElement("h1",null,"Submission completed!"),u.default.createElement("pre",null,JSON.stringify(j,null,2)));var ce=u.default.createElement(Ha,{instructionText:I.flipIdInstructionText,frontPortraitGuidesImage:C.idCardFrontPortraitGuidesImageUrl,frontLandscapeGuidesImage:C.idCardFrontLandscapeGuidesImageUrl,backPortraitGuidesImage:C.idCardBackPortraitGuidesImageUrl,backLandscapeGuidesImage:C.idCardBackLandscapeGuidesImageUrl});return u.default.createElement(Ze,{className:"flex"},M.captureState!==Pa.COMPLETE&&u.default.createElement(Ka,null),P&&function(){switch(M.requestedDocumentType){case vt.ID_CARD_FRONT:return u.default.createElement(ja,{key:Object.keys(M.capturedDocuments).length,requiredDocumentType:M.requestedDocumentType,autoCaptureEnabled:a,autoCaptureScoreThreshold:f,autoCaptureGoodFramesRequired:o,autoCaptureBarcodeRequired:l,barcodeScanningEnabled:!1,mrzDetectionScoreThreshold:b,focusScoreThreshold:x,onPrediction:X,onCapture:Z,onExit:re,processingScreen:ce,processingDelay:3500,assets:ae,colors:A,verbiage:ie,debugMode:D});case vt.ID_CARD_BACK:return u.default.createElement(ja,{key:Object.keys(M.capturedDocuments).length,requiredDocumentType:M.requestedDocumentType,autoCaptureEnabled:a,autoCaptureScoreThreshold:f,autoCaptureGoodFramesRequired:o,autoCaptureBarcodeRequired:l,barcodeScanningEnabled:d,mrzDetectionScoreThreshold:b,focusScoreThreshold:x,onPrediction:X,onBarcodeScanned:J,onCapture:Z,onExit:re,assets:oe,colors:A,verbiage:se,debugMode:D});case vt.PASSPORT:return u.default.createElement(ja,{key:Object.keys(M.capturedDocuments).length,requiredDocumentType:M.requestedDocumentType,autoCaptureEnabled:a,autoCaptureScoreThreshold:v,mrzDetectionScoreThreshold:b,autoCaptureGoodFramesRequired:o,autoCaptureBarcodeRequired:l,barcodeScanningEnabled:!1,focusScoreThreshold:k,onPrediction:X,onBarcodeScanned:J,onCapture:Z,onExit:re,assets:le,colors:A,verbiage:ue,debugMode:D});default:return null}}(),!P&&u.default.createElement(qa,{key:te,headingText:I.loadingOverlayHeadingText,useContinuityCameraText:I.loadingOverlayUseContinuityCameraText,modelsWarmingUpText:I.loadingOverlayModelsWarmingUpText,cameraInitializingText:I.loadingOverlayCameraInitializingText,cameraAccessBlockedText:I.loadingOverlayCameraAccessBlockedText,continueText:I.loadingOverlayContinueText,continueBtnBackgroundColor:A.loadingContinueBtnBackgroundColor,continueBtnTextColor:A.loadingContinueBtnTextColor,instructionImageUrl:C.loadingOverlayInstructionImageUrl,onDismissed:function(){B(!0)}}),M.captureState===Pa.COMPLETE&&u.default.createElement(Wa,{capturedDocuments:M.capturedDocuments,barcodeResult:M.barcodeResult,onSubmitClick:function(){return g(void 0,void 0,void 0,(function(){var e,n,r,a,i,o,s,l,u;return m(this,(function(c){switch(c.label){case 0:return n=M.capturedDocuments.ID_CARD_BACK,r=M.capturedDocuments.PASSPORT,(i=e=M.capturedDocuments.ID_CARD_FRONT)?[4,We(e.imageData)]:[3,2];case 1:i=c.sent(),c.label=2;case 2:return a=i,(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,G(a),z(o),q(l),N(),setTimeout((function(){null==t||t({idFrontImage:a,idBackImage:o,passportImage:l})}),0),[2]}}))}))},onRetryClick:Q,headingText:I.successHeadingText,idCardFrontText:I.successIdCardFrontText,idCardBackText:I.successIdCardBackText,passportText:I.successPassportText,instructionText:I.successInstructionText,retryText:I.successRetryText,submittingText:I.successSubmittingText,submitText:I.successSubmitText}))},Qa=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"}}))},ei=self;function ti(e,t){e=e.split(".");var n,r=ei;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 ni(e){return e}function ri(){throw Error("Invalid UTF8")}function ai(e,t){return t=String.fromCharCode.apply(null,t),null==e?t:e+t}let ii,oi;const si="undefined"!=typeof TextDecoder;let li;const ui="undefined"!=typeof TextEncoder;function ci(e){if(ui)e=(li||=new TextEncoder).encode(e);else{let n=0;const r=new Uint8Array(3*e.length);for(let a=0;a<e.length;a++){var t=e.charCodeAt(a);if(128>t)r[n++]=t;else{if(2048>t)r[n++]=t>>6|192;else{if(55296<=t&&57343>=t){if(56319>=t&&a<e.length){const i=e.charCodeAt(++a);if(56320<=i&&57343>=i){r[n++]=(t=1024*(t-55296)+i-56320+65536)>>18|240,r[n++]=t>>12&63|128,r[n++]=t>>6&63|128,r[n++]=63&t|128;continue}a--}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 di,hi;e:{for(var fi=["CLOSURE_FLAGS"],pi=ei,gi=0;gi<fi.length;gi++)if(null==(pi=pi[fi[gi]])){hi=null;break e}hi=pi}var mi,vi=hi&&hi[610401301];di=null!=vi&&vi;const yi=ei.navigator;function bi(e){return!!di&&!!mi&&mi.brands.some((({brand:t})=>t&&-1!=t.indexOf(e)))}function wi(e){var t;return(t=ei.navigator)&&(t=t.userAgent)||(t=""),-1!=t.indexOf(e)}function xi(){return!!di&&!!mi&&0<mi.brands.length}function Ei(){return xi()?bi("Chromium"):(wi("Chrome")||wi("CriOS"))&&!(!xi()&&wi("Edge"))||wi("Silk")}mi=yi&&yi.userAgentData||null;var ki=!xi()&&(wi("Trident")||wi("MSIE"));!wi("Android")||Ei(),Ei(),wi("Safari")&&(Ei()||!xi()&&wi("Coast")||!xi()&&wi("Opera")||!xi()&&wi("Edge")||(xi()?bi("Microsoft Edge"):wi("Edg/"))||xi()&&bi("Opera"));var Si={},Ci=null;function Ti(){if(!Ci){Ci={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=e.concat(t[n].split(""));Si[n]=r;for(var a=0;a<r.length;a++){var i=r[a];void 0===Ci[i]&&(Ci[i]=a)}}}}var Ai="undefined"!=typeof Uint8Array,Ri=!ki&&"function"==typeof btoa;function Ii(e){if(!Ri){var t;void 0===t&&(t=0),Ti(),t=Si[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 a=e[l],i=e[l+1],o=e[l+2],s=t[a>>2];n[u++]=s+(a=t[(3&a)<<4|i>>4])+(i=t[(15&i)<<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 _i=/[-_.]/g,Di={"-":"+",_:"/",".":"="};function Fi(e){return Di[e]||""}function Mi(e){if(!Ri)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),a=0;return function(e,t){function n(t){for(;r<e.length;){var n=e.charAt(r++),a=Ci[n];if(null!=a)return a;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return t}Ti();for(var r=0;;){var a=n(-1),i=n(0),o=n(64),s=n(64);if(64===s&&-1===a)break;t(a<<2|i>>4),64!=o&&(t(i<<4&240|o>>2),64!=s&&t(o<<6&192|s))}}(e,(function(e){r[a++]=e})),a!==n?r.subarray(0,a):r}(e);_i.test(e)&&(e=e.replace(_i,Fi)),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 Li(e){return Ai&&null!=e&&e instanceof Uint8Array}let Ni;function Oi(){return Ni||=new Uint8Array(0)}var Pi={};let Bi;function Ui(e){if(e!==Pi)throw Error("illegal external caller")}function $i(){return Bi||=new Gi(null,Pi)}function ji(e){Ui(Pi);var t=e.L;return null==(t=null==t||Li(t)?t:"string"==typeof t?Mi(t):null)?t:e.L=t}var Gi=class{constructor(e,t){if(Ui(t),this.L=e,null!=e&&0===e.length)throw Error("ByteString should be constructed with non-empty values")}fa(){const e=ji(this);return e?new Uint8Array(e):Oi()}};function zi(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function qi(){return Error("Failed to read varint, encoding is invalid.")}function Hi(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function Vi(e){return 0==e.length?$i():new Gi(e,Pi)}function Wi(e){if("string"==typeof e)return{buffer:Mi(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===Gi)return{buffer:ji(e)||Oi(),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 Ki="function"==typeof Uint8Array.prototype.slice;let Yi,Xi=0,Ji=0;function Zi(e){const t=0>e;let n=(e=Math.abs(e))>>>0;if(e=Math.floor((e-n)/4294967296),t){const[t,r]=ro(n,e);e=r,n=t}Xi=n>>>0,Ji=e>>>0}function Qi(e){const t=Yi||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),Ji=0,Xi=t.getUint32(0,!0)}function eo(e,t){return 4294967296*t+(e>>>0)}function to(e,t){const n=2147483648&t;return n&&(t=~t>>>0,0==(e=1+~e>>>0)&&(t=t+1>>>0)),e=eo(e,t),n?-e:e}function no(e){if(16>e.length)Zi(Number(e));else if("function"==typeof BigInt)e=BigInt(e),Xi=Number(e&BigInt(4294967295))>>>0,Ji=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+("-"===e[0]);Ji=Xi=0;const n=e.length;for(let r=t,a=(n-t)%6+t;a<=n;r=a,a+=6){const t=Number(e.slice(r,a));Ji*=1e6,Xi=1e6*Xi+t,4294967296<=Xi&&(Ji+=Math.trunc(Xi/4294967296),Ji>>>=0,Xi>>>=0)}if(t){const[e,t]=ro(Xi,Ji);Xi=e,Ji=t}}}function ro(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function ao(e,t,{O:n=!1}={}){e.O=n,t&&(t=Wi(t),e.h=t.buffer,e.s=t.G,e.v=0,e.l=e.h.length,e.g=e.v)}function io(e,t){if(e.g=t,t>e.l)throw Hi(e.l,t)}function oo(e,t){let n,r=0,a=0,i=0;const o=e.h;let s=e.g;do{n=o[s++],r|=(127&n)<<i,i+=7}while(32>i&&128&n);for(32<i&&(a|=(127&n)>>4),i=3;32>i&&128&n;i+=7)n=o[s++],a|=(127&n)<<i;if(io(e,s),128>n)return t(r>>>0,a>>>0);throw qi()}function so(e){let t=0,n=e.g;const r=n+10,a=e.h;for(;n<r;){const r=a[n++];if(t|=r,0==(128&r))return io(e,n),!!(127&t)}throw qi()}function lo(e){var t=e.h;const n=e.g,r=t[n],a=t[n+1],i=t[n+2];return t=t[n+3],io(e,e.g+4),(r<<0|a<<8|i<<16|t<<24)>>>0}function uo(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 Hi(t,e.l-n);return e.g=r,n}function co(e,t){if(0==t)return $i();var n=uo(e,t);return e.O&&e.s?n=e.h.subarray(n,n+t):(e=e.h,n=n===(t=n+t)?Oi():Ki?e.slice(n,t):new Uint8Array(e.subarray(n,t))),Vi(n)}var ho=class{constructor(e,t){this.h=null,this.s=!1,this.g=this.l=this.v=0,ao(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 qi();return io(this,t),r}j(){return this.m()>>>0}A(){var e=lo(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()}},fo=[];function po(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 zi(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 go(e){switch(e.h){case 0:0!=e.h?go(e):so(e.g);break;case 1:io(e=e.g,e.g+8);break;case 2:if(2!=e.h)go(e);else{var t=e.g.j();io(e=e.g,e.g+t)}break;case 5:io(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!po(e))throw Error("Unmatched start-group tag: stream EOF");if(4==e.h){if(e.m!=t)throw Error("Unmatched end-group tag");break}go(e)}break;default:throw zi(e.h,e.l)}}function mo(e,t,n){const r=e.g.l,a=e.g.j(),i=e.g.g+a;let o=i-r;if(0>=o&&(e.g.l=i,n(t,e,void 0,void 0,void 0),o=i-e.g.g),o)throw Error(`Message parsing ended unexpectedly. Expected to read ${a} bytes, instead read ${a-o} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=i,e.g.l=r,t}function vo(e){var t=e.g.j(),n=uo(e=e.g,t);if(e=e.h,si){var r,a=e;(r=oi)||(r=oi=new TextDecoder("utf-8",{fatal:!0})),e=n+t,a=0===n&&e===a.length?a:a.subarray(n,e);try{var i=r.decode(a)}catch(e){if(void 0===ii){try{r.decode(new Uint8Array([128]))}catch(e){}try{r.decode(new Uint8Array([97])),ii=!0}catch(e){ii=!1}}throw!ii&&(oi=void 0),e}}else{t=(i=n)+t,n=[];let s,l=null;for(;i<t;){var o=e[i++];128>o?n.push(o):224>o?i>=t?ri():(s=e[i++],194>o||128!=(192&s)?(i--,ri()):n.push((31&o)<<6|63&s)):240>o?i>=t-1?ri():(s=e[i++],128!=(192&s)||224===o&&160>s||237===o&&160<=s||128!=(192&(a=e[i++]))?(i--,ri()):n.push((15&o)<<12|(63&s)<<6|63&a)):244>=o?i>=t-2?ri():(s=e[i++],128!=(192&s)||0!=s-144+(o<<28)>>30||128!=(192&(a=e[i++]))||128!=(192&(r=e[i++]))?(i--,ri()):(o=(7&o)<<18|(63&s)<<12|(63&a)<<6|63&r,n.push(55296+((o-=65536)>>10&1023),56320+(1023&o)))):ri(),8192<=n.length&&(l=ai(l,n),n.length=0)}i=ai(l,n)}return i}function yo(e){const t=e.g.j();return co(e.g,t)}function bo(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 wo=[];function xo(e){return e?/^\d+$/.test(e)?(no(e),new Eo(Xi,Ji)):null:ko||=new Eo(0,0)}var Eo=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let ko;function So(e){return e?/^-?\d+$/.test(e)?(no(e),new Co(Xi,Ji)):null:To||=new Co(0,0)}var Co=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let To;function Ao(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 Ro(e,t){for(;127<t;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function Io(e,t){if(0<=t)Ro(e,t);else{for(let n=0;9>n;n++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function _o(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 Do(e,t){0!==t.length&&(e.l.push(t),e.h+=t.length)}function Fo(e,t,n){Ro(e.g,8*t+n)}function Mo(e,t){return Fo(e,t,2),t=e.g.end(),Do(e,t),t.push(e.h),t}function Lo(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 No(e,t,n){Fo(e,t,2),Ro(e.g,n.length),Do(e,e.g.end()),Do(e,n)}function Oo(e,t,n,r){null!=n&&(t=Mo(e,t),r(n,e),Lo(e,t))}class Po{constructor(e,t,n){this.g=e,this.h=t,this.l=n}}function Bo(e){return Array.prototype.slice.call(e)}const Uo="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():void 0;var $o=Uo?(e,t)=>{e[Uo]|=t}:(e,t)=>{void 0!==e.g?e.g|=t:Object.defineProperties(e,{g:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function jo(e){const t=zo(e);1!=(1&t)&&(Object.isFrozen(e)&&(e=Bo(e)),Ho(e,1|t))}var Go=Uo?(e,t)=>{e[Uo]&=~t}:(e,t)=>{void 0!==e.g&&(e.g&=~t)},zo=Uo?e=>0|e[Uo]:e=>0|e.g,qo=Uo?e=>e[Uo]:e=>e.g,Ho=Uo?(e,t)=>{e[Uo]=t}:(e,t)=>{void 0!==e.g?e.g=t:Object.defineProperties(e,{g:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function Vo(e){return $o(e,1),e}function Wo(e){return $o(e,34),e}function Ko(e,t){Ho(t,-255&(0|e))}function Yo(e,t){Ho(t,-221&(34|e))}function Xo(e){return 0==(e=e>>11&1023)?536870912:e}var Jo,Zo={};function Qo(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&e.constructor===Object}function es(e,t,n){if(null!=e)if("string"==typeof e)e=e?new Gi(e,Pi):$i();else if(e.constructor!==Gi)if(Li(e))e=n?Vi(e):e.length?new Gi(new Uint8Array(e),Pi):$i();else{if(!t)throw Error();e=void 0}return e}const ts=[];function ns(e){if(2&e)throw Error()}Ho(ts,39),Jo=Object.freeze(ts);class rs{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 rs(this.g,this.h,this.m)}}var as={};let is,os;function ss(e,t){(t=is?t[is]:void 0)&&(e[is]=Bo(t))}function ls(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function us(e){return null==e?e:"number"==typeof e||"NaN"===e||"Infinity"===e||"-Infinity"===e?Number(e):void 0}function cs(e){return null==e?e:"boolean"==typeof e||"number"==typeof e?!!e:void 0}function ds(e){return"number"==typeof e&&Number.isFinite(e)||!!e&&"string"==typeof e&&isFinite(e)}function hs(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function fs(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function ps(e){if("string"!=typeof e)throw Error();return e}function gs(e){if(null!=e&&"string"!=typeof e)throw Error();return e}function ms(e){return null==e||"string"==typeof e?e:void 0}function vs(e,t,n,r){var a=!1;return null==e||"object"!=typeof e||(a=Array.isArray(e))||e.K!==Zo?a?(0===(a=n=zo(e))&&(a|=32&r),(a|=2&r)!==n&&Ho(e,a),new t(e)):(n?2&r?(e=t[ys])?t=e:(Wo((e=new t).u),t=t[ys]=e):t=new t:t=void 0,t):e}const ys="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():"di";function bs(e){return e}function ws(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 xs,Es;function ks(e){switch(typeof e){case"number":return 0<e?void 0:0===e?Es||=[0,void 0]:[-e,void 0];case"string":return[0,e];case"object":return e}}function Ss(e,t){return Cs(e,t[0],t[1])}function Cs(e,t,n){if(null==e&&(e=xs),xs=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=zo(e)))return os&&delete e[os],e;if(r|=64,n&&(r|=512,n!==e[0]))throw Error();e:{var a=(n=e).length;if(a){const e=a-1;var i=n[e];if(Qo(i)){1024<=(a=e-(t=+!!(512&(r|=256))-1))&&(Ts(n,t,i),a=1023),r=-2095105&r|(1023&a)<<11;break e}}t&&(i=+!!(512&r)-1,1024<(t=Math.max(t,a-i))&&(Ts(n,i,{}),r|=256,t=1023),r=-2095105&r|(1023&t)<<11)}}return Ho(e,r),e}function Ts(e,t,n){const r=1023+t,a=e.length;for(let i=r;i<a;i++){const r=e[i];null!=r&&r!==n&&(n[i-t]=r)}e.length=r+1,e[r]=n}function As(e){if(2&e.g)throw Error("Cannot mutate an immutable Map")}var Rs=class extends Map{constructor(e,t,n=bs,r=bs){super();let a=zo(e);a|=64,Ho(e,a),this.g=a,this.l=t,this.h=n||bs,this.j=this.l?Is:r||bs;for(let i=0;i<e.length;i++){const o=e[i],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,a),super.set(s,l)}}s(e=_s){return this.m(e)}m(e=_s){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(){As(this),super.clear()}delete(e){return As(this),super.delete(this.h(e,!0,!1))}entries(){var e=this.A();return new rs(e,Ds,this)}keys(){return this.C()}values(){var e=this.A();return new rs(e,Rs.prototype.get,this)}forEach(e,t){super.forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))}set(e,t){return As(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 Is(e,t,n,r,a,i){return e=vs(e,r,n,i),a&&(e=Us(e)),e}function _s(e){return e}function Ds(e){return[e,this.get(e)]}function Fs(e,t,n,r,a,i){if(null!=e){if(Array.isArray(e))e=a&&0==e.length&&1&zo(e)?void 0:i&&2&zo(e)?e:Ms(e,t,n,void 0!==r,a,i);else if(Qo(e)){const o={};for(let s in e)o[s]=Fs(e[s],t,n,r,a,i);e=o}else e=t(e,r);return e}}function Ms(e,t,n,r,a,i){const o=r||n?zo(e):0;r=r?!!(32&o):void 0;const s=Bo(e);for(let e=0;e<s.length;e++)s[e]=Fs(s[e],t,n,r,a,i);return n&&(ss(s,e),n(o,s)),s}function Ls(e){return Fs(e,Ns,void 0,void 0,!1,!1)}function Ns(e){return e.K===Zo?e.toJSON():e instanceof Rs?e.s(Ls):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(Li(e))return Ii(e);if(e instanceof Gi){const t=e.L;return null==t?"":"string"==typeof t?t:e.L=Ii(t)}if(e instanceof Rs)return e.s()}}return e}(e)}function Os(e,t,n=Yo){if(null!=e){if(Ai&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){const r=zo(e);return 2&r?e:!t||68&r||!(32&r||0===r)?Ms(e,Os,4&r?Yo:n,!0,!1,!0):(Ho(e,34|r),e)}return e.K===Zo?e=2&(n=qo(t=e.u))?e:Ps(e,t,n,!0):e instanceof Rs&&(t=Wo(e.m(Os)),e=new Rs(t,e.l,e.h,e.j)),e}}function Ps(e,t,n,r){return e=e.constructor,xs=t=Bs(t,n,r),t=new e(t),xs=void 0,t}function Bs(e,t,n){const r=n||2&t?Yo:Ko,a=!!(32&t);return e=function(e,t,n){const r=Bo(e);var a=r.length;const i=256&t?r[a-1]:void 0;for(a+=i?-1:0,t=512&t?1:0;t<a;t++)r[t]=n(r[t]);if(i){t=r[t]={};for(const e in i)t[e]=n(i[e])}return ss(r,e),r}(e,t,(e=>Os(e,a,r))),$o(e,32|(n?2:0)),e}function Us(e){const t=e.u,n=qo(t);return 2&n?Ps(e,t,n,!1):e}function $s(e,t){return js(e=e.u,qo(e),t)}function js(e,t,n,r){if(-1===n)return null;if(n>=Xo(t)){if(256&t)return e[e.length-1][n]}else{var a=e.length;if(r&&256&t&&null!=(r=e[a-1][n]))return r;if((t=n+(+!!(512&t)-1))<a)return e[t]}}function Gs(e,t,n,r){const a=e.u,i=qo(a);return ns(i),zs(a,i,t,n,r),e}function zs(e,t,n,r,a){var i=Xo(t);if(n>=i||a){if(a=t,256&t)i=e[e.length-1];else{if(null==r)return;i=e[i+(+!!(512&t)-1)]={},a|=256}i[n]=r,a!==t&&Ho(e,a)}else e[n+(+!!(512&t)-1)]=r,256&t&&n in(e=e[e.length-1])&&delete e[n]}function qs(e,t,n,r,a){var i=2&t;let o=js(e,t,n,a);Array.isArray(o)||(o=Jo);const s=zo(o);if(1&s||Vo(o),i)2&s||Wo(o),1&r||Object.freeze(o);else{i=!(2&r);const l=2&s;1&r||!l?i&&32&s&&!l&&Go(o,32):(o=Vo(Bo(o)),zs(e,t,n,o,a))}return o}function Hs(e,t){const n=qo(e=e.u),r=js(e,n,t),a=us(r);return null!=a&&a!==r&&zs(e,n,t,a),a}function Vs(e){const t=qo(e=e.u),n=js(e,t,1),r=es(n,!0,!!(34&t));return null!=r&&r!==n&&zs(e,t,1,r),r}function Ws(e,t,n){const r=qo(e=e.u),a=2&r;let i=qs(e,r,t,1),o=zo(i);if(!(4&o)){Object.isFrozen(i)&&(o=0,i=Bo(i),zs(e,r,t,i));let s=0,l=0;for(;s<i.length;s++){const e=n(i[s]);null!=e&&(i[l++]=e)}l<s&&(i.length=l),o|=5,a&&(o|=34),Ho(i,o),2&o&&Object.freeze(i)}return!a&&(2&o||Object.isFrozen(i))&&(i=Bo(i),$o(i,5),zs(e,r,t,i)),i}let Ks;function Ys(){return Ks??=new Rs(Wo([]),void 0,void 0,void 0,as)}function Xs(e){e=Bo(e);for(let t=0;t<e.length;t++){const n=e[t]=Bo(e[t]);Array.isArray(n[1])&&(n[1]=Wo(n[1]))}return e}function Js(e,t,n){{const r=qo(e=e.u);if(ns(r),null==n)zs(e,r,t);else{if(!(4&zo(n))){Object.isFrozen(n)&&(n=Bo(n));for(let e=0;e<n.length;e++)n[e]=ps(n[e]);Ho(n,5)}zs(e,r,t,n)}}}function Zs(e,t){return Qs(e=e.u,qo(e),Uc)===t?t:-1}function Qs(e,t,n){let r=0;for(let a=0;a<n.length;a++){const i=n[a];null!=js(e,t,i)&&(0!==r&&zs(e,t,r),r=i)}return r}function el(e,t,n,r){const a=qo(e);ns(a);const i=js(e,a,n,r);let o;if(null!=i&&i.K===Zo)return(t=Us(i))!==i&&zs(e,a,n,t,r),t.u;if(Array.isArray(i)){const e=zo(i);o=2&e?Bs(i,e,!1):i,o=Ss(o,t)}else o=Ss(void 0,t);return o!==i&&zs(e,a,n,o,r),o}function tl(e,t,n,r){const a=qo(e=e.u),i=js(e,a,n,r);return(t=vs(i,t,!1,a))!==i&&null!=t&&zs(e,a,n,t,r),t}function nl(e,t,n,r=!1){if(null==(t=tl(e,t,n,r)))return t;const a=qo(e=e.u);if(!(2&a)){const i=Us(t);i!==t&&zs(e,a,n,t=i,r)}return t}function rl(e,t,n,r,a){var i=!!(2&t),o=qs(e,t,r,1);if(o===Jo||!(4&zo(o))){var s=o;o=!!(2&t);var l=!!(2&zo(s));i=s,!o&&l&&(s=Bo(s));var u=t|(l?2:0);l=l||void 0;let c=0,d=0;for(;c<s.length;c++){const e=vs(s[c],n,!1,u);void 0!==e&&(l=l||2&qo(e.u),s[d++]=e)}return d<c&&(s.length=d),u=5|(s=zo(n=s)),s!=(l=l?-9&u:8|u)&&(Object.isFrozen(n)&&(n=Bo(n)),Ho(n,l)),i!==(s=n)&&zs(e,t,r,s),(o&&2!==a||1===a)&&Object.freeze(s),s}return 3===a||(i?2===a&&(a=zo(o),o=Bo(o),Ho(o,a),zs(e,t,r,o)):(i=Object.isFrozen(o),1===a?i||Object.freeze(o):(n=-35&(a=zo(o)),i&&(a=0,zs(e,t,r,o=Bo(o))),a!==n&&Ho(o,n)))),o}function al(e,t,n){var r=e.u;const a=qo(r);if(t=rl(r,a,t,n,(e=!!(2&a))?1:2),!(e||8&zo(t))){for(n=0;n<t.length;n++)(e=t[n])!==(r=Us(e))&&(t[n]=r);$o(t,8)}return t}function il(e,t,n,r,a){return null==r&&(r=void 0),Gs(e,n,r,a)}function ol(e,t,n,r){null==r&&(r=void 0);const a=qo(e=e.u);ns(a),(n=Qs(e,a,n))&&n!==t&&null!=r&&zs(e,a,n),zs(e,a,t,r)}function sl(e,t,n){const r=qo(e=e.u);ns(r),e=rl(e,r,t,1,2),t=null!=n?n:new t,e.push(t),t.G()&&Go(e,8)}function ll(e,t){return hs($s(e,t))}function ul(e){return null==(e=$s(e,2))||ds(e)?e:void 0}function cl(e,t){return ms($s(e,t))}function dl(e){return e??0}function hl(e,t){return dl(Hs(e,t))}function fl(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}Gs(e,t,n)}function pl(e,t,n){if(null!=n){if("number"!=typeof n)throw ls(e=Error(),"warning"),e;if(!Number.isFinite(n)){const e=Error();ls(e,"incident"),function(e){ei.setTimeout((()=>{throw e}),0)}(e)}}Gs(e,t,n)}function gl(e,t,n){if(null!=n&&"number"!=typeof n)throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);Gs(e,t,n)}function ml(e,t,n){n=ps(n);const r=qo(e=e.u);ns(r),qs(e,r,t,2).push(n)}function vl(e,t,n){t.g?t.m(e,t.g,t.h,n,!0):t.m(e,t.h,n,!0)}Rs.prototype.toJSON=void 0;var yl=class{constructor(e,t){this.u=Cs(e,t)}toJSON(){return bl(this,Ms(this.u,Ns,void 0,void 0,!1,!1),!0)}l(){var e=Nd;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 Ps(this,e,qo(e),!1)}G(){return!!(2&zo(this.u))}};function bl(e,t,n){var r=e.constructor.B,a=Xo(qo(n?e.u:t)),i=!1;if(r){if(!n){var o;if((t=Bo(t)).length&&Qo(o=t[t.length-1]))for(i=0;i<r.length;i++)if(r[i]>=a){Object.assign(t[t.length-1]={},o);break}i=!0}var s;a=t,n=!n,e=Xo(o=qo(e.u)),o=+!!(512&o)-1;for(let t=0;t<r.length;t++){var l=r[t];if(l<e){var u=a[l+=o];null==u?a[l]=n?Jo:Vo([]):n&&u!==Jo&&jo(u)}else{if(!s){var c=void 0;a.length&&Qo(c=a[a.length-1])?s=c:a.push(s={})}u=s[l],null==s[l]?s[l]=n?Jo:Vo([]):n&&u!==Jo&&jo(u)}}}if(!(r=t.length))return t;let d,h;if(Qo(s=t[r-1])){e:{var f=s;c={},a=!1;for(let e in f)n=f[e],Array.isArray(n)&&n!=n&&(a=!0),null!=n?c[e]=n:a=!0;if(a){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=i?t:Array.prototype.slice.call(t,0,r),i&&(t.length=r),f&&t.push(f),t):t}function wl(e){return{aa:cu,S:e}}function xl(e,t){if(Array.isArray(t)){var n=zo(t);if(4&n)return t;for(var r=0,a=0;r<t.length;r++){const n=e(t[r]);null!=n&&(t[a++]=n)}return a<r&&(t.length=a),Ho(t,5|n),2&n&&Object.freeze(t),t}}yl.prototype.K=Zo,yl.prototype.toString=function(){return bl(this,this.u,!1).toString()};const El=Symbol();function kl(e){let t=e[El];if(!t){const n=Nl(e),r=n.m;t=r?(e,t)=>r(e,t,n):(e,t)=>{for(;po(t)&&4!=t.h;){var r=t.m,a=n[r];if(!a){var i=n.h;i&&(i=i[r])&&(a=n[r]=Sl(i))}a&&a(t,e,r)||(r=(a=t).l,go(a),a.Y?a=void 0:(i=a.g.g-r,a.g.g=r,a=co(a.g,i)),r=e,a&&(is||=Symbol(),(i=r[is])?i.push(a):r[is]=[a]))}(t=n.l)&&(e[os||=Symbol()]=t)},e[El]=t}return t}function Sl(e){const t=function(e){if(e=e.S)return kl(e)}(e),n=e.aa.g;if(t){const r=Nl(e.S).g;return(e,a,i)=>n(e,a,i,r,t)}return(e,t,r)=>n(e,t,r)}function Cl(e,t,n,r){t.g=ks(e[0]);let a=1;if(e.length>a&&!(e[a]instanceof Po)){var i=e[a++];if(Array.isArray(i))return t.m=i[0],t.h=i[1],t;t.h=i}for(i=0;a<e.length;){const c=e[a++];var o=e[a];for("number"==typeof o?(a++,i+=o):i++,c.l&&((o=t.l)||(t.l=o=[]),o.push(i)),o=a;o<e.length&&!(e[o]instanceof Po);)o++;if(o-=a){var s=e,l=a,u=s[l];if("function"==typeof u&&(u=u(),s[l]=u),(s=Array.isArray(u))&&!(s=Fl in u||Rl in u)&&(s=0<u.length)){const e=ks(l=(s=u)[0]);null!=e&&e!==l&&(s[0]=e),s=null!=e}(u=s?u:void 0)?(a++,t[i]=1===o?r(c,u):r(c,u,e[a++])):t[i]=n(c,e[a++])}else t[i]=n(c)}return t}const Tl=Symbol();function Al(e){let t=e[Tl];if(!t){const n=Dl(e);t=(e,t)=>Pl(e,t,n),e[Tl]=t}return t}const Rl=Symbol();function Il(e){return e.h}function _l(e,t){let n,r;const a=e.h;return(e,i,o)=>a(e,i,o,r||=Dl(t).g,n||=Al(t))}function Dl(e){let t=e[Rl];return t||(t=Cl(e,e[Rl]={},Il,_l),Fl in e&&Rl in e&&(e.length=0),t)}const Fl=Symbol();function Ml(e,t){const n=e.g;return t?(e,r,a)=>n(e,r,a,t):n}function Ll(e,t,n){const r=e.g;let a,i;return(e,o,s)=>r(e,o,s,i||=Nl(t).g,a||=kl(t),n)}function Nl(e){let t=e[Fl];return t||(t=Cl(e,e[Fl]={},Ml,Ll),Fl in e&&Rl in e&&(e.length=0),t)}function Ol(e,t){var n=e[t];if(n)return n;if((n=e.h)&&(n=n[t])){var r=n.S,a=n.aa.h;if(r){const e=Al(r),t=Dl(r).g;n=(n,r,i)=>a(n,r,i,t,e)}else n=a;return e[t]=n}}function Pl(e,t,n){for(var r=qo(e),a=+!!(512&r)-1,i=e.length,o=512&r?1:0,s=i+(256&r?-1:0);o<s;o++){const r=e[o];if(null==r)continue;const i=o-a,s=Ol(n,i);s&&s(t,r,i)}if(256&r){r=e[i-1];for(let e in r)a=+e,Number.isNaN(a)||null!=(i=r[e])&&(s=Ol(n,a))&&s(t,i,a)}if(e=is?e[is]:void 0)for(Do(t,t.g.end()),n=0;n<e.length;n++)Do(t,ji(e[n])||Oi())}function Bl(e,t){return new Po(e,t,!1)}function Ul(e,t){return new Po(e,t,!0)}function $l(e,t,n){zs(e,qo(e),t,n)}var jl=Bl((function(e,t,n,r,a){return 2===e.h&&(e=mo(e,Ss([void 0,void 0],r),a),ns(r=qo(t)),(a=js(t,r,n))instanceof Rs?0!=(2&a.g)?((a=a.m()).push(e),zs(t,r,n,a)):a.H(e):Array.isArray(a)?(2&zo(a)&&zs(t,r,n,a=Xs(a)),a.push(e)):zs(t,r,n,[e]),!0)}),(function(e,t,n,r,a){if(t instanceof Rs)t.forEach(((t,i)=>{Oo(e,n,Ss([i,t],r),a)}));else if(Array.isArray(t))for(let i=0;i<t.length;i++){const o=t[i];Array.isArray(o)&&Oo(e,n,Ss(o,r),a)}}));function Gl(e,t,n){e:if(null!=t){if(ds(t)){if("string"==typeof t)break e;if("number"==typeof t)break e}t=void 0}null!=t&&("string"==typeof t&&So(t),null!=t&&(Fo(e,n,0),"number"==typeof t?(e=e.g,Zi(t),Ao(e,Xi,Ji)):(n=So(t),Ao(e.g,n.h,n.g))))}function zl(e,t,n){null!=(t=hs(t))&&null!=t&&(Fo(e,n,0),Io(e.g,t))}function ql(e,t,n){null!=(t=cs(t))&&(Fo(e,n,0),e.g.g.push(t?1:0))}function Hl(e,t,n){null!=(t=ms(t))&&No(e,n,ci(t))}function Vl(e,t,n,r,a){Oo(e,n,t instanceof yl?t.u:Array.isArray(t)?Ss(t,r):void 0,a)}function Wl(e,t,n){null!=(t=null==t||"string"==typeof t||Li(t)||t instanceof Gi?t:void 0)&&No(e,n,Wi(t).buffer)}function Kl(e,t,n){return(5===e.h||2===e.h)&&(t=qs(t,qo(t),n,2,!1),2==e.h?bo(e,ho.prototype.A,t):t.push(e.g.A()),!0)}var Yl=Bl((function(e,t,n){if(1!==e.h)return!1;var r=e.g;e=lo(r);const a=lo(r);r=2*(a>>31)+1;const i=a>>>20&2047;return e=4294967296*(1048575&a)+e,$l(t,n,2047==i?e?NaN:1/0*r:0==i?r*Math.pow(2,-1074)*e:r*Math.pow(2,i-1075)*(e+4503599627370496)),!0}),(function(e,t,n){null!=(t=us(t))&&(Fo(e,n,1),e=e.g,(n=Yi||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),Xi=n.getUint32(0,!0),Ji=n.getUint32(4,!0),_o(e,Xi),_o(e,Ji))})),Xl=Bl((function(e,t,n){return 5===e.h&&($l(t,n,e.g.A()),!0)}),(function(e,t,n){null!=(t=us(t))&&(Fo(e,n,5),e=e.g,Qi(t),_o(e,Xi))})),Jl=Ul(Kl,(function(e,t,n){if(null!=(t=xl(us,t)))for(let i=0;i<t.length;i++){var r=e,a=t[i];null!=a&&(Fo(r,n,5),r=r.g,Qi(a),_o(r,Xi))}})),Zl=Ul(Kl,(function(e,t,n){if(null!=(t=xl(us,t))&&t.length){Fo(e,n,2),Ro(e.g,4*t.length);for(let r=0;r<t.length;r++)n=e.g,Qi(t[r]),_o(n,Xi)}})),Ql=Bl((function(e,t,n){return 0===e.h&&($l(t,n,oo(e.g,to)),!0)}),Gl),eu=Bl((function(e,t,n){return 0===e.h&&($l(t,n,0===(e=oo(e.g,to))?void 0:e),!0)}),Gl),tu=Bl((function(e,t,n){return 0===e.h&&($l(t,n,oo(e.g,eo)),!0)}),(function(e,t,n){e:if(null!=t){if(ds(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&&(Fo(e,n,0),"number"==typeof t?(e=e.g,Zi(t),Ao(e,Xi,Ji)):(n=xo(t),Ao(e.g,n.h,n.g))))})),nu=Bl((function(e,t,n){return 0===e.h&&($l(t,n,e.g.m()),!0)}),zl),ru=Ul((function(e,t,n){return(0===e.h||2===e.h)&&(t=qs(t,qo(t),n,2,!1),2==e.h?bo(e,ho.prototype.m,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=xl(hs,t))&&t.length){n=Mo(e,n);for(let n=0;n<t.length;n++)Io(e.g,t[n]);Lo(e,n)}})),au=Bl((function(e,t,n){return 0===e.h&&($l(t,n,0===(e=e.g.m())?void 0:e),!0)}),zl),iu=Bl((function(e,t,n){return 0===e.h&&($l(t,n,so(e.g)),!0)}),ql),ou=Bl((function(e,t,n){return 0===e.h&&($l(t,n,!1===(e=so(e.g))?void 0:e),!0)}),ql),su=Ul((function(e,t,n){if(2!==e.h)return!1;e=vo(e);const r=qo(t);return ns(r),qs(t,r,n,2).push(e),!0}),(function(e,t,n){if(null!=(t=xl(ms,t)))for(let a=0;a<t.length;a++){var r=t[a];null!=r&&No(e,n,ci(r))}})),lu=Bl((function(e,t,n){return 2===e.h&&($l(t,n,""===(e=vo(e))?void 0:e),!0)}),Hl),uu=Bl((function(e,t,n){return 2===e.h&&($l(t,n,vo(e)),!0)}),Hl),cu=Bl((function(e,t,n,r,a){return 2===e.h&&(mo(e,el(t,r,n,!0),a),!0)}),Vl),du=Bl((function(e,t,n,r,a){return 2===e.h&&(mo(e,el(t,r,n),a),!0)}),Vl),hu=Ul((function(e,t,n,r,a){if(2!==e.h)return!1;r=Ss(void 0,r);const i=qo(t);ns(i);let o=qs(t,i,n,3);return(Object.isFrozen(o)||4&zo(o))&&(o=Bo(o),zs(t,i,n,o)),o.push(r),mo(e,r,a),!0}),(function(e,t,n,r,a){if(Array.isArray(t))for(let i=0;i<t.length;i++)Vl(e,t[i],n,r,a)})),fu=Bl((function(e,t,n,r,a,i){if(2!==e.h)return!1;const o=qo(t);return ns(o),(i=Qs(t,o,i))&&n!==i&&zs(t,o,i),mo(e,t=el(t,r,n),a),!0}),Vl),pu=Bl((function(e,t,n){return 2===e.h&&($l(t,n,yo(e)),!0)}),Wl),gu=Ul((function(e,t,n){return(0===e.h||2===e.h)&&(t=qs(t,qo(t),n,2,!1),2==e.h?bo(e,ho.prototype.j,t):t.push(e.g.j()),!0)}),(function(e,t,n){if(null!=(t=xl(fs,t)))for(let i=0;i<t.length;i++){var r=e,a=t[i];null!=a&&(Fo(r,n,0),Ro(r.g,a))}})),mu=Bl((function(e,t,n){return 0===e.h&&($l(t,n,e.g.m()),!0)}),(function(e,t,n){null!=(t=hs(t))&&(t=parseInt(t,10),Fo(e,n,0),Io(e.g,t))})),vu=Ul((function(e,t,n){return(0===e.h||2===e.h)&&(t=qs(t,qo(t),n,2,!1),2==e.h?bo(e,ho.prototype.C,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=xl(hs,t))&&t.length){n=Mo(e,n);for(let n=0;n<t.length;n++)Io(e.g,t[n]);Lo(e,n)}}));class yu{constructor(e,t){this.h=e,this.g=t,this.l=nl,this.m=il,this.defaultValue=void 0}}function bu(e,t){return new yu(e,t)}function wu(e,t){return(n,r)=>{e:{if(wo.length){const e=wo.pop();e.o(r),ao(e.g,n,r),n=e}else n=new class{constructor(e,t){if(fo.length){const n=fo.pop();ao(n,e,t),e=n}else e=new ho(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 a=new e;const r=a.u;kl(t)(r,n),os&&delete r[os];var i=a;break e}finally{(a=n.g).h=null,a.s=!1,a.v=0,a.l=0,a.g=0,a.O=!1,n.m=-1,n.h=-1,100>wo.length&&wo.push(n)}i=void 0}return i}}function xu(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}}}};Pl(this.u,t,Dl(e)),Do(t,t.g.end());const n=new Uint8Array(t.h),r=t.l,a=r.length;let i=0;for(let e=0;e<a;e++){const t=r[e];n.set(t,i),i+=t.length}return t.l=[n],n}}var Eu,ku=[0,lu,Bl((function(e,t,n){return 2===e.h&&($l(t,n,(e=yo(e))===$i()?void 0:e),!0)}),(function(e,t,n){if(null!=t){if(t instanceof yl){const r=t.Aa;return void(r&&(t=r(t),null!=t&&No(e,n,Wi(t).buffer)))}if(Array.isArray(t))return}Wl(e,t,n)}))];function Su(e){if(void 0===Eu){var t=null,n=ei.trustedTypes;if(n&&n.createPolicy){try{t=n.createPolicy("goog#html",{createHTML:ni,createScript:ni,createScriptURL:ni})}catch(e){ei.console&&ei.console.error(e.message)}Eu=t}else Eu=t}return e=(t=Eu)?t.createScriptURL(e):e,new class{constructor(e){this.g=e}toString(){return this.g+""}}(e)}var Cu=[0,uu],Tu=[0,nu,mu,iu,iu,ru,mu,mu],Au=[0,iu,iu],Ru=class extends yl{constructor(){super()}};Ru.B=[6];var Iu=[0,iu,uu,iu,mu,mu,vu,uu,uu,du,Au,mu],_u=[0,uu,uu,uu],Du=class extends yl{constructor(){super()}},Fu=[0],Mu=[0,nu],Lu=[1,2,3,4,5],Nu=class extends yl{constructor(e){super(e,2)}},Ou={},Pu=[-2,Ou,iu];Ou[336783863]=wl([0,uu,iu,iu,nu,du,[0,fu,Fu,Lu,fu,Iu,Lu,fu,_u,Lu,fu,Mu,Lu,fu,Tu,Lu],du,Cu]);var Bu=[0,lu,ou],Uu=[0,eu,eu,ou,ou,ou,ou,eu,ru,lu,au,eu,eu,ou,au,ou,ou,ou,lu],$u=[-1,{}],ju=[0,uu,du,2,$u],Gu=[0,uu,su,du,$u];function zu(e,t){t=gs(t);const n=qo(e=e.u);ns(n),zs(e,n,2,""===t?void 0:t)}function qu(e,t){ml(e,3,t)}function Hu(e,t){ml(e,4,t)}var Vu=class extends yl{constructor(e){super(e,500)}o(e){return il(this,0,7,e)}};Vu.B=[3,4,5,6,8,13,17,1005];var Wu=[-500,lu,lu,su,su,su,su,du,Pu,hu,ku,au,au,du,ju,du,Gu,hu,Bu,lu,du,Uu,au,su,su,988],Ku=[0,lu,lu,du,$u],Yu=[-500,uu,uu,du,[-1,{}],uu,999],Xu=[-500,uu,su,su,du,[-2,{},iu],su,998,su],Ju=[-500,uu,su,du,$u,su,999];function Zu(e,t){sl(e,Vu,t)}function Qu(e,t){ml(e,10,t)}function ec(e,t){ml(e,15,t)}var tc=class extends yl{constructor(e){super(e,500)}o(e){return il(this,0,1001,e)}};tc.B=[1,6,7,9,10,15,16,17,14,1002];var nc=[-500,hu,Wu,hu,5,Yu,hu,Xu,au,hu,Ju,su,au,du,ju,du,Gu,hu,Ku,su,su,su,du,Uu,lu,lu,ou,du,980,$u,hu,ku],rc=wu(tc,nc);tc.prototype.g=xu(nc);var ac=[0,hu,[0,nu,nu,nu]],ic=class extends yl{constructor(e){super(e)}},oc=[0,nu,Xl,uu,uu],sc=class extends yl{constructor(e){super(e)}g(){return al(this,ic,1)}};sc.B=[1];var lc=[0,hu,oc],uc=wu(sc,lc),cc=[0,nu,Xl],dc=[0,nu,nu,du,ac],hc=class extends yl{constructor(e){super(e)}},fc=[0,nu,nu,nu,nu],pc=[0,Xl,Xl,Xl,Xl],gc=class extends yl{constructor(e){super(e)}},mc=[0,Xl,Xl,uu,Xl],vc=class extends yl{constructor(e){super(e)}h(){return nl(this,hc,2)}g(){return al(this,gc,5)}};vc.B=[5];var yc=[0,mu,du,fc,du,pc,du,dc,hu,mc],bc=class extends yl{constructor(e){super(e)}};bc.B=[1,2,3,8,9];var wc=wu(bc,[0,su,ru,Zl,du,yc,uu,uu,Ql,hu,cc,su,Ql]),xc=class extends yl{constructor(e){super(e)}},Ec=[0,Xl,Xl,Xl,Xl,Xl],kc=class extends yl{constructor(e){super(e)}};kc.B=[1];var Sc=wu(kc,[0,hu,Ec]),Cc=class extends yl{constructor(e){super(e)}},Tc=[0,Xl,Xl,Xl,Xl,Xl],Ac=class extends yl{constructor(e){super(e)}};Ac.B=[1];var Rc=wu(Ac,[0,hu,Tc]),Ic=class extends yl{constructor(e){super(e)}};Ic.B=[3];var _c=[0,nu,nu,Zl,mu],Dc=class extends yl{constructor(){super()}};Dc.prototype.g=xu([0,Xl,Xl,Xl,Xl,Xl,Ql]);var Fc=class extends yl{constructor(e){super(e)}},Mc=[0,nu,2,uu,du,lc],Lc=class extends yl{constructor(e){super(e)}};Lc.B=[1];var Nc=wu(Lc,[0,hu,Mc,Ql]),Oc=class extends yl{constructor(e){super(e)}};Oc.B=[1];var Pc=class extends yl{constructor(e){super(e)}da(){const e=Vs(this);return null==e?$i():e}},Bc=class extends yl{constructor(e){super(e)}},Uc=[1,2],$c=[0,fu,[0,Zl],Uc,fu,[0,pu],Uc,nu,uu],jc=class extends yl{constructor(e){super(e)}};jc.B=[1];var Gc=wu(jc,[0,hu,$c,Ql]),zc=class extends yl{constructor(e){super(e)}};zc.B=[4,5];var qc=[0,uu,nu,Xl,su,su],Hc=class extends yl{constructor(e){super(e)}},Vc=[0,iu,iu],Wc=class extends yl{constructor(e){super(e)}},Kc=[1,2,3,4,5],Yc=class extends yl{constructor(e){super(e)}g(){return null!=Vs(this)}h(){return null!=cl(this,2)}},Xc=[0,pu,uu,du,[0,nu,Ql,Ql],du,[0,tu,Ql]],Jc=class extends yl{constructor(e){super(e)}g(){return cs($s(this,2))??!1}},Zc=[0,du,Xc,iu,du,[0,fu,Mu,Kc,fu,Iu,Kc,fu,Tu,Kc,fu,Fu,Kc,fu,_u,Kc]],Qc=class extends yl{constructor(e){super(e)}},ed=[0,du,Zc,Xl,Xl,nu],td=bu(502141897,Qc);Ou[502141897]=wl(ed);var nd=[0,du,Xc];Ou[512499200]=wl(nd);var rd=[0,du,nd];Ou[515723506]=wl(rd);var ad=wu(class extends yl{constructor(e){super(e)}},[0,du,[0,mu,mu,Jl,gu],du,_c]),id=[0,du,Zc];Ou[508981768]=wl(id);var od=class extends yl{constructor(e){super(e)}},sd=[0,du,Zc,Xl,du,id,iu],ld=class extends yl{constructor(e){super(e)}},ud=[0,du,Zc,du,ed,du,sd,Xl,du,rd];Ou[508968149]=wl(sd);var cd=bu(508968150,ld);Ou[508968150]=wl(ud);var dd=class extends yl{constructor(e){super(e)}},hd=bu(513916220,dd);Ou[513916220]=wl([0,du,Zc,du,ud,nu]);var fd=class extends yl{constructor(e){super(e)}h(){return nl(this,zc,2)}g(){Gs(this,2)}},pd=[0,du,Zc,du,qc];Ou[478825465]=wl(pd);var gd=[0,du,Zc];Ou[478825422]=wl(gd);var md=class extends yl{constructor(e){super(e)}},vd=[0,du,Zc,du,gd,du,pd,du,pd],yd=class extends yl{constructor(e){super(e)}},bd=[0,du,Zc,Xl,nu],wd=class extends yl{constructor(e){super(e)}},xd=[0,du,Zc,Xl],Ed=class extends yl{constructor(e){super(e)}},kd=[0,du,Zc,du,bd,du,xd,Xl],Sd=class extends yl{constructor(e){super(e)}},Cd=[0,du,Zc,du,kd,du,vd];Ou[463370452]=wl(vd),Ou[464864288]=wl(bd),Ou[474472470]=wl(xd);var Td=bu(462713202,Ed);Ou[462713202]=wl(kd);var Ad=bu(479097054,Sd);Ou[479097054]=wl(Cd);var Rd=class extends yl{constructor(e){super(e)}},Id=bu(456383383,Rd);Ou[456383383]=wl([0,du,Zc,du,qc]);var _d=class extends yl{constructor(e){super(e)}},Dd=bu(476348187,_d);Ou[476348187]=wl([0,du,Zc,du,Vc]);var Fd=class extends yl{constructor(e){super(e)}},Md=[0,mu,mu],Ld=class extends yl{constructor(e){super(e)}};Ld.B=[3];var Nd=bu(458105876,class extends yl{constructor(e){super(e)}g(){var e=this.u;const t=qo(e);var n=2&t;return e=function(e,t,n){var r=Ld;const a=2&t;let i=!1;if(null==n){if(a)return Ys();n=[]}else if(n.constructor===Rs){if(0==(2&n.g)||a)return n;n=n.m()}else Array.isArray(n)?i=!!(2&zo(n)):n=[];if(a){if(!n.length)return Ys();i||(i=!0,Wo(n))}else i&&(i=!1,n=Xs(n));return i||(64&zo(n)?Go(n,32):32&t&&$o(n,32)),zs(e,t,2,r=new Rs(n,r,ws,void 0),!1),r}(e,t,js(e,t,2)),null==e||!n&&Ld&&(e.v=!0),e}});Ou[458105876]=wl([0,du,Md,jl,[0,Ql,du,[0,uu,uu,su]]]);var Od=class extends yl{constructor(e){super(e)}},Pd=bu(458105758,Od);Ou[458105758]=wl([0,du,Zc,uu,du,Md]);var Bd=class extends yl{constructor(e){super(e)}};Bd.B=[5,6];var Ud=bu(443442058,Bd);Ou[443442058]=wl([0,du,Zc,uu,nu,Xl,su,su]);var $d=class extends yl{constructor(e){super(e)}},jd=[0,du,Zc,Xl,Xl,nu];Ou[514774813]=wl(jd);var Gd=class extends yl{constructor(e){super(e)}},zd=[0,du,Zc,Xl],qd=class extends yl{constructor(e){super(e)}},Hd=[0,du,Zc,du,jd,du,zd,Xl];Ou[518928384]=wl(zd);var Vd=bu(516587230,qd);function Wd(e,t){return t=t?t.clone():new zc,void 0!==e.displayNamesLocale?Gs(t,1,gs(e.displayNamesLocale)):void 0===e.displayNamesLocale&&Gs(t,1),void 0!==e.maxResults?pl(t,2,e.maxResults):"maxResults"in e&&Gs(t,2),void 0!==e.scoreThreshold?gl(t,3,e.scoreThreshold):"scoreThreshold"in e&&Gs(t,3),void 0!==e.categoryAllowlist?Js(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&Gs(t,4),void 0!==e.categoryDenylist?Js(t,5,e.categoryDenylist):"categoryDenylist"in e&&Gs(t,5),t}function Kd(e,t=-1,n=""){return{categories:e.map((e=>({index:dl(ll(e,1))??-1,score:hl(e,2)??0,categoryName:cl(e,3)??""??"",displayName:cl(e,4)??""??""}))),headIndex:t,headName:n}}function Yd(e){var t=Ws(e,3,us),n=Ws(e,2,hs);const r=Ws(e,1,ms),a=Ws(e,9,ms),i={categories:[],keypoints:[]};for(let e=0;e<t.length;e++)i.categories.push({score:t[e],index:n[e]??-1,categoryName:r[e]??"",displayName:a[e]??""});if((t=nl(e,vc,4)?.h())&&(i.boundingBox={originX:ll(t,1)??0,originY:ll(t,2)??0,width:ll(t,3)??0,height:ll(t,4)??0,angle:0}),nl(e,vc,4)?.g().length)for(const t of nl(e,vc,4).g())i.keypoints.push({x:Hs(t,1)??0,y:Hs(t,2)??0,score:Hs(t,4)??0,label:cl(t,3)??""});return i}function Xd(e){const t=[];for(const n of al(e,Cc,1))t.push({x:hl(n,1)??0,y:hl(n,2)??0,z:hl(n,3)??0});return t}function Jd(e){const t=[];for(const n of al(e,xc,1))t.push({x:hl(n,1)??0,y:hl(n,2)??0,z:hl(n,3)??0});return t}function Zd(e){return Array.from(e,(e=>127<e?e-256:e))}function Qd(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,a=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i],r+=e[i]*e[i],a+=t[i]*t[i];if(0>=r||0>=a)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(r*a)}let eh;Ou[516587230]=wl(Hd);const th=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 nh(){if(void 0===eh)try{await WebAssembly.instantiate(th),eh=!0}catch{eh=!1}return eh}async function rh(e,t){const n=await nh()?"wasm_internal":"wasm_nosimd_internal";return void 0!==t?{wasmLoaderPath:`${t}/${e}_${n}.js`,wasmBinaryPath:`${t}/${e}_${n}.wasm`}:{wasmLoaderPath:Su(`./${encodeURIComponent(e)}_${encodeURIComponent(n)}.js`),wasmBinaryPath:Su(`./${encodeURIComponent(e)}_${encodeURIComponent(n)}.wasm`)}}var ah=class{};function ih(){const e=navigator.userAgent;return e.includes("Safari")&&!e.includes("Chrome")}async function oh(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 sh(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 lh(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 uh(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 ch(e,t,n){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=n}function dh(e,t,n){let r=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(e,t,a)=>{t?(n(r,a),r=[]):r.push(e)}}function hh(e,t){const n=nl(e.baseOptions,Yc,1)||new Yc;"string"==typeof t?(Gs(n,2,gs(t)),Gs(n,1)):t instanceof Uint8Array&&(Gs(n,1,es(t,!1,!1)),Gs(n,2)),il(e.baseOptions,0,1,n)}function fh(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 ph(e,t){e.H=Math.max(e.H,t)}function gh(e,t){e.A=new Vu,zu(e.A,"PassThroughCalculator"),qu(e.A,"free_memory"),Hu(e.A,"free_memory_unused_out"),Qu(t,"free_memory"),Zu(t,e.A)}function mh(e,t){qu(e.A,t),Hu(e.A,t+"_unused_out")}function vh(e){e.g.addBoolToStream(!0,"free_memory",e.H)}ah.forVisionTasks=function(e=""){return rh("vision",e)},ah.forTextTasks=function(e=""){return rh("text",e)},ah.forAudioTasks=function(e=""){return rh("audio",e)},ah.isSimdSupported=function(){return nh()};var yh=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(!(nl(this.baseOptions,Yc,1)?.g()||nl(this.baseOptions,Yc,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=nl(e.baseOptions,Wc,3);if(!n){var r=n=new Wc,a=new Du;ol(r,4,Kc,a)}"delegate"in t&&("GPU"===t.delegate?(t=n,r=new Ru,ol(t,2,Kc,r)):(t=n,r=new Du,ol(t,4,Kc,r))),il(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),hh(this,"/model.dat"),this.m(),this.N()}));hh(this,t.modelAssetBuffer)}return this.m(),this.N(),Promise.resolve()}N(){}U(){let e;if(this.g.U((t=>{e=rc(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,fh(this)}finishProcessing(){this.g.finishProcessing(),fh(this)}close(){this.A=void 0,this.g.closeGraph()}};function bh(e,t){if(null===e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}yh.prototype.close=yh.prototype.close;class wh{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 xh(e,t,n){const r=e.h;if(n=bh(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 Eh(e,t){const n=e.h,r=bh(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(r);const a=bh(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,a),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 i=bh(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,i),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 wh(n,r,a,i)}function kh(e,t){if(e.h){if(t!==e.h)throw Error("Cannot change GL context once initialized")}else e.h=t}function Sh(e,t,n,r){if(kh(e,t),!e.g){const t=e.h;if(e.g=bh(t.createProgram(),"Failed to create WebGL program"),e.C=xh(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=xh(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=Eh(e,!0)),n=e.m):(e.j||(e.j=Eh(e,!1)),n=e.j),t.useProgram(e.g),n.bind(),e=r(),n.g.bindVertexArray(null),e}function Ch(e,t,n){kh(e,t),e.l||(e.l=bh(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 Th(e){e.h?.bindFramebuffer(e.h.FRAMEBUFFER,null)}var Ah=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 Rh(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 Ih(e){var t=Rh(e,0);if(!t){t=Dh(e);const n=Fh(e),r=new Uint8Array(e.width*e.height*4);Ch(n,t,_h(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,r),Th(n),t=new ImageData(new Uint8ClampedArray(r.buffer),e.width,e.height),e.g.push(t)}return t}function _h(e){let t=Rh(e,2);if(!t){const n=Dh(e);t=Lh(e);const r=Rh(e,1)||Ih(e);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,r),Nh(e)}return t}function Dh(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=bh(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Fh(e){return e.l||(e.l=new Ah),e.l}function Mh(e){(e=Dh(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 Lh(e){const t=Dh(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=Rh(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=bh(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),Mh(e)),n}function Nh(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Oh(e){const t=Dh(e);return Sh(Fh(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,a=n.height;return n.width=e.width,n.height=e.height,e=t(),n.width=r,n.height=a,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 Ph=class{constructor(e,t,n,r,a,i,o){this.g=e,this.j=t,this.m=n,this.canvas=r,this.l=a,this.width=i,this.height=o,(this.j||this.m)&&0==--Bh&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}ta(){return!!Rh(this,0)}Z(){return!!Rh(this,1)}J(){return!!Rh(this,2)}pa(){return Ih(this)}oa(){var e=Rh(this,1);return e||(_h(this),Lh(this),e=Oh(this),Nh(this),this.g.push(e),this.j=!0),e}T(){return _h(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=Dh(this),t=Fh(this);e.activeTexture(e.TEXTURE1),n=bh(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),Mh(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),Ch(t,e,n),Sh(t,e,!1,(()=>{Lh(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),Nh(this)})),Th(t),Nh(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);_h(this),Lh(this),n=Oh(this),Nh(this)}e.push(n)}return new Ph(e,this.Z(),this.J(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Rh(this,1).close(),this.m&&Dh(this).deleteTexture(Rh(this,2)),Bh=-1}};Ph.prototype.close=Ph.prototype.close,Ph.prototype.clone=Ph.prototype.clone,Ph.prototype.getAsWebGLTexture=Ph.prototype.T,Ph.prototype.getAsImageBitmap=Ph.prototype.oa,Ph.prototype.getAsImageData=Ph.prototype.pa,Ph.prototype.hasWebGLTexture=Ph.prototype.J,Ph.prototype.hasImageBitmap=Ph.prototype.Z,Ph.prototype.hasImageData=Ph.prototype.ta;var Bh=250;function Uh(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 $h(e){var t=Uh(e,1);if(!t){if(t=Uh(e,0))t=new Float32Array(t).map((e=>e/255));else{t=new Float32Array(e.width*e.height);const r=Gh(e);var n=qh(e);if(Ch(n,r,jh(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 jh(e){let t=Uh(e,2);if(!t){const n=Gh(e);t=Vh(e);const r=$h(e),a=zh(e);n.texImage2D(n.TEXTURE_2D,0,a,e.width,e.height,0,n.RED,n.FLOAT,r),Wh(e)}return t}function Gh(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=bh(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function zh(e){if(e=Gh(e),!Kh)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Kh=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Kh=e.R16F}return Kh}function qh(e){return e.l||(e.l=new Ah),e.l}function Hh(e){(e=Gh(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 Vh(e){const t=Gh(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=Uh(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=bh(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),Hh(e)),n}function Wh(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Kh,Yh=class{constructor(e,t,n,r,a,i){this.g=e,this.m=t,this.canvas=n,this.l=r,this.width=a,this.height=i,this.m&&0==--Xh&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}ua(){return!!Uh(this,0)}sa(){return!!Uh(this,1)}J(){return!!Uh(this,2)}qa(){return(e=Uh(this,0))||(e=$h(this),e=new Uint8Array(e.map((e=>255*e))),this.g.push(e)),e;var e}na(){return $h(this)}T(){return jh(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=Gh(this),t=qh(this);e.activeTexture(e.TEXTURE1),n=bh(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),Hh(this);const r=zh(this);e.texImage2D(e.TEXTURE_2D,0,r,this.width,this.height,0,e.RED,e.FLOAT,null),e.bindTexture(e.TEXTURE_2D,null),Ch(t,e,n),Sh(t,e,!1,(()=>{Vh(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),Wh(this)})),Th(t),Wh(this)}}e.push(n)}return new Yh(e,this.J(),this.canvas,this.l,this.width,this.height)}close(){this.m&&Gh(this).deleteTexture(Uh(this,2)),Xh=-1}};Yh.prototype.close=Yh.prototype.close,Yh.prototype.clone=Yh.prototype.clone,Yh.prototype.getAsWebGLTexture=Yh.prototype.T,Yh.prototype.getAsFloat32Array=Yh.prototype.na,Yh.prototype.getAsUint8Array=Yh.prototype.qa,Yh.prototype.hasWebGLTexture=Yh.prototype.J,Yh.prototype.hasFloat32Array=Yh.prototype.sa,Yh.prototype.hasUint8Array=Yh.prototype.ua;var Xh=250;function Jh(...e){return e.map((([e,t])=>({start:e,end:t})))}const Zh=function(e){return class extends e{xa(){this.i._registerModelResourcesGraphService()}}}((Qh=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||ih()?(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,a){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),sh(this,r||"input_audio",(r=>{sh(this,a=a||"audio_header",(a=>{this.i._configureAudio(r,a,e,t,n)}))}))}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}U(e){ch(this,"__graph_config__",(t=>{e(t)})),sh(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,a){const i=4*e.length;this.h!==i&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(i),this.h=i),this.i.HEAPF32.set(e,this.g/4),sh(this,r,(e=>{this.i._addAudioToInputStream(this.g,t,n,e,a)}))}addGpuBufferToStream(e,t,n){sh(this,t,(t=>{const[r,a]=lh(this,e,t);this.i._addBoundTextureToStream(t,r,a,n)}))}addBoolToStream(e,t,n){sh(this,t,(t=>{this.i._addBoolToInputStream(e,t,n)}))}addDoubleToStream(e,t,n){sh(this,t,(t=>{this.i._addDoubleToInputStream(e,t,n)}))}addFloatToStream(e,t,n){sh(this,t,(t=>{this.i._addFloatToInputStream(e,t,n)}))}addIntToStream(e,t,n){sh(this,t,(t=>{this.i._addIntToInputStream(e,t,n)}))}addStringToStream(e,t,n){sh(this,t,(t=>{sh(this,e,(e=>{this.i._addStringToInputStream(e,t,n)}))}))}addStringRecordToStream(e,t,n){sh(this,t,(t=>{uh(this,Object.keys(e),(r=>{uh(this,Object.values(e),(a=>{this.i._addFlatHashMapToInputStream(r,a,Object.keys(e).length,t,n)}))}))}))}addProtoToStream(e,t,n,r){sh(this,n,(n=>{sh(this,t,(t=>{const a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,t,n,r),this.i._free(a)}))}))}addEmptyPacketToStream(e,t){sh(this,e,(e=>{this.i._addEmptyPacketToInputStream(e,t)}))}addBoolToInputSidePacket(e,t){sh(this,t,(t=>{this.i._addBoolToInputSidePacket(e,t)}))}addDoubleToInputSidePacket(e,t){sh(this,t,(t=>{this.i._addDoubleToInputSidePacket(e,t)}))}addFloatToInputSidePacket(e,t){sh(this,t,(t=>{this.i._addFloatToInputSidePacket(e,t)}))}addIntToInputSidePacket(e,t){sh(this,t,(t=>{this.i._addIntToInputSidePacket(e,t)}))}addStringToInputSidePacket(e,t){sh(this,t,(t=>{sh(this,e,(e=>{this.i._addStringToInputSidePacket(e,t)}))}))}addProtoToInputSidePacket(e,t,n){sh(this,n,(n=>{sh(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){ch(this,e,t),sh(this,e,(e=>{this.i._attachBoolListener(e)}))}attachBoolVectorListener(e,t){dh(this,e,t),sh(this,e,(e=>{this.i._attachBoolVectorListener(e)}))}attachIntListener(e,t){ch(this,e,t),sh(this,e,(e=>{this.i._attachIntListener(e)}))}attachIntVectorListener(e,t){dh(this,e,t),sh(this,e,(e=>{this.i._attachIntVectorListener(e)}))}attachDoubleListener(e,t){ch(this,e,t),sh(this,e,(e=>{this.i._attachDoubleListener(e)}))}attachDoubleVectorListener(e,t){dh(this,e,t),sh(this,e,(e=>{this.i._attachDoubleVectorListener(e)}))}attachFloatListener(e,t){ch(this,e,t),sh(this,e,(e=>{this.i._attachFloatListener(e)}))}attachFloatVectorListener(e,t){dh(this,e,t),sh(this,e,(e=>{this.i._attachFloatVectorListener(e)}))}attachStringListener(e,t){ch(this,e,t),sh(this,e,(e=>{this.i._attachStringListener(e)}))}attachStringVectorListener(e,t){dh(this,e,t),sh(this,e,(e=>{this.i._attachStringVectorListener(e)}))}attachProtoListener(e,t,n){ch(this,e,t),sh(this,e,(e=>{this.i._attachProtoListener(e,n||!1)}))}attachProtoVectorListener(e,t,n){dh(this,e,t),sh(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?'),ch(this,e,((e,n)=>{e=new Float32Array(e.buffer,e.byteOffset,e.length/4),t(e,n)})),sh(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 Qh{get W(){return this.i}ea(e,t,n){sh(this,t,(t=>{const[r,a]=lh(this,e,t);this.W._addBoundTextureAsImageToStream(t,r,a,n)}))}P(e,t){ch(this,e,t),sh(this,e,(e=>{this.W._attachImageListener(e)}))}R(e,t){dh(this,e,t),sh(this,e,(e=>{this.W._attachImageVectorListener(e)}))}}));var Qh,ef=class extends Zh{};async function tf(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,a)=>{if(t&&await oh(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(n&&(await oh(n),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&a&&((t=self.Module).locateFile=a.locateFile,a.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=a.mainScriptUrlOrBlob)),a=await self.ModuleFactory(self.Module||a),self.ModuleFactory=self.Module=void 0,new e(a,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||ih()?document.createElement("canvas"):void 0),t,n)}function nf(e,t,n,r){if(e.X){const i=new Dc;if(n?.regionOfInterest){if(!e.ca)throw Error("This task doesn't support region-of-interest.");var a=n.regionOfInterest;if(a.left>=a.right||a.top>=a.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(0>a.left||0>a.top||1<a.right||1<a.bottom)throw Error("Expected RectF values to be in [0,1].");gl(i,1,(a.left+a.right)/2),gl(i,2,(a.top+a.bottom)/2),gl(i,4,a.right-a.left),gl(i,3,a.bottom-a.top)}else gl(i,1,.5),gl(i,2,.5),gl(i,4,1),gl(i,3,1);if(n?.rotationDegrees){if(0!=n?.rotationDegrees%90)throw Error("Expected rotation to be a multiple of 90°.");if(gl(i,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=hl(i,3)*r/e,a=hl(i,4)*e/r,gl(i,4,n),gl(i,3,a)}}e.g.addProtoToStream(i.g(),"mediapipe.NormalizedRect",e.X,r)}e.g.ea(t,e.ba,r??performance.now()),e.finishProcessing()}function rf(e,t,n){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");nf(e,t,n,e.H+1)}function af(e,t,n,r){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");nf(e,t,n,r)}function of(e,t,n){var r=t.data;const a=t.width,i=a*(t=t.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==i)throw Error("Unsupported channel count: "+r.length/i);return e=new Yh([r],!1,e.g.i.canvas,e.M,a,t),n?e.clone():e}var sf=class extends yh{constructor(e,t,n,r){super(e),this.g=e,this.ba=t,this.X=n,this.ca=r,this.M=new Ah}l(e,t=!0){if("runningMode"in e&&fl(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()}};sf.prototype.close=sf.prototype.close;var lf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},this.h=new Qc,e=new Jc,il(this.h,0,1,e),gl(this.h,2,.5),gl(this.h,3,.3)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&gl(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&gl(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},rf(this,e,t),this.j}D(e,t,n){return this.j={detections:[]},af(this,e,n,t),this.j}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect_in"),ec(e,"detections");const t=new Nu;vl(t,td,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect_in"),Hu(n,"DETECTIONS:detections"),n.o(t),Zu(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=wc(t),this.j.detections.push(Yd(e));ph(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};lf.prototype.detectForVideo=lf.prototype.D,lf.prototype.setOptions=lf.prototype.o,lf.createFromModelPath=async function(e,t){return tf(lf,e,{baseOptions:{modelAssetPath:t}})},lf.createFromModelBuffer=function(e,t){return tf(lf,e,{baseOptions:{modelAssetBuffer:t}})},lf.createFromOptions=function(e,t){return tf(lf,e,t)};var uf=Jh([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]),cf=Jh([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]),df=Jh([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),hf=Jh([474,475],[475,476],[476,477],[477,474]),ff=Jh([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]),pf=Jh([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),gf=Jh([469,470],[470,471],[471,472],[472,469]),mf=Jh([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]),vf=[...uf,...cf,...df,...ff,...pf,...mf],yf=Jh([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 bf(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var wf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,this.h=new ld,e=new Jc,il(this.h,0,1,e),this.v=new od,il(this.h,0,3,this.v),this.s=new Qc,il(this.h,0,2,this.s),pl(this.s,4,1),gl(this.s,2,.5),gl(this.v,2,.5),gl(this.h,4,.5)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){return"numFaces"in e&&pl(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&gl(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&gl(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&gl(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 bf(this),rf(this,e,t),this.j}D(e,t,n){return bf(this),af(this,e,n,t),this.j}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"face_landmarks");const t=new Nu;vl(t,cd,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"NORM_LANDMARKS:face_landmarks"),n.o(t),Zu(e,n),this.g.attachProtoVectorListener("face_landmarks",((e,t)=>{for(const t of e)e=Rc(t),this.j.faceLandmarks.push(Xd(e));ph(this,t)})),this.g.attachEmptyPacketListener("face_landmarks",(e=>{ph(this,e)})),this.outputFaceBlendshapes&&(ec(e,"blendshapes"),Hu(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((e,t)=>{if(this.outputFaceBlendshapes)for(const t of e)e=uc(t),this.j.faceBlendshapes.push(Kd(e.g()??[]));ph(this,t)})),this.g.attachEmptyPacketListener("blendshapes",(e=>{ph(this,e)}))),this.outputFacialTransformationMatrixes&&(ec(e,"face_geometry"),Hu(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((e,t)=>{if(this.outputFacialTransformationMatrixes)for(const t of e)(e=nl(ad(t),Ic,2))&&this.j.facialTransformationMatrixes.push({rows:dl(ll(e,1))??0,columns:dl(ll(e,2))??0,data:Ws(e,3,us)??[]});ph(this,t)})),this.g.attachEmptyPacketListener("face_geometry",(e=>{ph(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};wf.prototype.detectForVideo=wf.prototype.D,wf.prototype.detect=wf.prototype.F,wf.prototype.setOptions=wf.prototype.o,wf.createFromModelPath=function(e,t){return tf(wf,e,{baseOptions:{modelAssetPath:t}})},wf.createFromModelBuffer=function(e,t){return tf(wf,e,{baseOptions:{modelAssetBuffer:t}})},wf.createFromOptions=function(e,t){return tf(wf,e,t)},wf.FACE_LANDMARKS_LIPS=uf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LIPS",wf.FACE_LANDMARKS_LIPS),wf.FACE_LANDMARKS_LEFT_EYE=cf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_EYE",wf.FACE_LANDMARKS_LEFT_EYE),wf.FACE_LANDMARKS_LEFT_EYEBROW=df,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_EYEBROW",wf.FACE_LANDMARKS_LEFT_EYEBROW),wf.FACE_LANDMARKS_LEFT_IRIS=hf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_IRIS",wf.FACE_LANDMARKS_LEFT_IRIS),wf.FACE_LANDMARKS_RIGHT_EYE=ff,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_EYE",wf.FACE_LANDMARKS_RIGHT_EYE),wf.FACE_LANDMARKS_RIGHT_EYEBROW=pf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_EYEBROW",wf.FACE_LANDMARKS_RIGHT_EYEBROW),wf.FACE_LANDMARKS_RIGHT_IRIS=gf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_IRIS",wf.FACE_LANDMARKS_RIGHT_IRIS),wf.FACE_LANDMARKS_FACE_OVAL=mf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_FACE_OVAL",wf.FACE_LANDMARKS_FACE_OVAL),wf.FACE_LANDMARKS_CONTOURS=vf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_CONTOURS",wf.FACE_LANDMARKS_CONTOURS),wf.FACE_LANDMARKS_TESSELATION=yf,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_TESSELATION",wf.FACE_LANDMARKS_TESSELATION);var xf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!0),this.j=new dd,e=new Jc,il(this.j,0,1,e)}get baseOptions(){return nl(this.j,Jc,1)}set baseOptions(e){il(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,rf(this,e,r??{}),!this.h)return this.s}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"stylized_image");const t=new Nu;vl(t,hd,this.j);const n=new Vu;zu(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"STYLIZED_IMAGE:stylized_image"),n.o(t),Zu(e,n),this.g.P("stylized_image",((e,t)=>{var n=!this.h,r=e.data,a=e.width;const i=a*(e=e.height);if(r instanceof Uint8Array)if(r.length===3*i){const t=new Uint8ClampedArray(4*i);for(let e=0;e<i;++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,a,e)}else{if(r.length!==4*i)throw Error("Unsupported channel count: "+r.length/i);r=new ImageData(new Uint8ClampedArray(r.buffer,r.byteOffset,r.length),a,e)}else if(!(r instanceof WebGLTexture))throw Error(`Unsupported format: ${r.constructor.name}`);a=new Ph([r],!1,!1,this.g.i.canvas,this.M,a,e),this.s=n=n?a.clone():a,this.h&&this.h(n),ph(this,t)})),this.g.attachEmptyPacketListener("stylized_image",(e=>{this.s=null,this.h&&this.h(null),ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};xf.prototype.stylize=xf.prototype.za,xf.prototype.setOptions=xf.prototype.o,xf.createFromModelPath=function(e,t){return tf(xf,e,{baseOptions:{modelAssetPath:t}})},xf.createFromModelBuffer=function(e,t){return tf(xf,e,{baseOptions:{modelAssetBuffer:t}})},xf.createFromOptions=function(e,t){return tf(xf,e,t)};var Ef=Jh([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 kf(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function Sf(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 Cf(e,t=!0){const n=[];for(const a of e){var r=uc(a);e=[];for(const n of r.g())r=t&&null!=ll(n,1)?dl(ll(n,1)):-1,e.push({score:hl(n,2)??0,index:r,categoryName:cl(n,3)??""??"",displayName:cl(n,4)??""??""});n.push(e)}return n}var Tf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.v=new Sd,e=new Jc,il(this.v,0,1,e),this.C=new Ed,il(this.v,0,2,this.C),this.s=new wd,il(this.C,0,3,this.s),this.h=new yd,il(this.C,0,2,this.h),this.j=new md,il(this.v,0,3,this.j),gl(this.h,2,.5),gl(this.C,4,.5),gl(this.s,2,.5)}get baseOptions(){return nl(this.v,Jc,1)}set baseOptions(e){il(this.v,0,1,e)}o(e){if(pl(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&gl(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&gl(this.C,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&gl(this.s,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new fd,n=Wd(e.cannedGesturesClassifierOptions,nl(this.j,fd,3)?.h());il(t,0,2,n),il(this.j,0,3,t)}else void 0===e.cannedGesturesClassifierOptions&&nl(this.j,fd,3)?.g();return e.customGesturesClassifierOptions?(il(t=new fd,0,2,n=Wd(e.customGesturesClassifierOptions,nl(this.j,fd,4)?.h())),il(this.j,0,4,t)):void 0===e.customGesturesClassifierOptions&&nl(this.j,fd,4)?.g(),this.l(e)}va(e,t){return kf(this),rf(this,e,t),Sf(this)}wa(e,t,n){return kf(this),af(this,e,n,t),Sf(this)}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"hand_gestures"),ec(e,"hand_landmarks"),ec(e,"world_hand_landmarks"),ec(e,"handedness");const t=new Nu;vl(t,Ad,this.v);const n=new Vu;zu(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"HAND_GESTURES:hand_gestures"),Hu(n,"LANDMARKS:hand_landmarks"),Hu(n,"WORLD_LANDMARKS:world_hand_landmarks"),Hu(n,"HANDEDNESS:handedness"),n.o(t),Zu(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e){e=Rc(t);const n=[];for(const t of al(e,Cc,1))n.push({x:hl(t,1)??0,y:hl(t,2)??0,z:hl(t,3)??0});this.landmarks.push(n)}ph(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{ph(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e){e=Sc(t);const n=[];for(const t of al(e,xc,1))n.push({x:hl(t,1)??0,y:hl(t,2)??0,z:hl(t,3)??0});this.worldLandmarks.push(n)}ph(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{ph(this,e)})),this.g.attachProtoVectorListener("hand_gestures",((e,t)=>{this.gestures.push(...Cf(e,!1)),ph(this,t)})),this.g.attachEmptyPacketListener("hand_gestures",(e=>{ph(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{this.handedness.push(...Cf(e)),ph(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Af(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Tf.prototype.recognizeForVideo=Tf.prototype.wa,Tf.prototype.recognize=Tf.prototype.va,Tf.prototype.setOptions=Tf.prototype.o,Tf.createFromModelPath=function(e,t){return tf(Tf,e,{baseOptions:{modelAssetPath:t}})},Tf.createFromModelBuffer=function(e,t){return tf(Tf,e,{baseOptions:{modelAssetBuffer:t}})},Tf.createFromOptions=function(e,t){return tf(Tf,e,t)},Tf.HAND_CONNECTIONS=Ef,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$gesture_recognizer$gesture_recognizer.GestureRecognizer.HAND_CONNECTIONS",Tf.HAND_CONNECTIONS);var Rf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.j=new Ed,e=new Jc,il(this.j,0,1,e),this.s=new wd,il(this.j,0,3,this.s),this.h=new yd,il(this.j,0,2,this.h),pl(this.h,3,1),gl(this.h,2,.5),gl(this.s,2,.5),gl(this.j,4,.5)}get baseOptions(){return nl(this.j,Jc,1)}set baseOptions(e){il(this.j,0,1,e)}o(e){return"numHands"in e&&pl(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&gl(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&gl(this.j,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&gl(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],rf(this,e,t),Af(this)}D(e,t,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],af(this,e,n,t),Af(this)}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"hand_landmarks"),ec(e,"world_hand_landmarks"),ec(e,"handedness");const t=new Nu;vl(t,Td,this.j);const n=new Vu;zu(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"LANDMARKS:hand_landmarks"),Hu(n,"WORLD_LANDMARKS:world_hand_landmarks"),Hu(n,"HANDEDNESS:handedness"),n.o(t),Zu(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e)e=Rc(t),this.landmarks.push(Xd(e));ph(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{ph(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e)e=Sc(t),this.worldLandmarks.push(Jd(e));ph(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{ph(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{var n=this.handedness,r=n.push;const a=[];for(const t of e){e=uc(t);const n=[];for(const t of e.g())n.push({score:hl(t,2)??0,index:dl(ll(t,1))??-1,categoryName:cl(t,3)??""??"",displayName:cl(t,4)??""??""});a.push(n)}r.call(n,...a),ph(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Rf.prototype.detectForVideo=Rf.prototype.D,Rf.prototype.detect=Rf.prototype.F,Rf.prototype.setOptions=Rf.prototype.o,Rf.createFromModelPath=function(e,t){return tf(Rf,e,{baseOptions:{modelAssetPath:t}})},Rf.createFromModelBuffer=function(e,t){return tf(Rf,e,{baseOptions:{modelAssetBuffer:t}})},Rf.createFromOptions=function(e,t){return tf(Rf,e,t)},Rf.HAND_CONNECTIONS=Ef,ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$hand_landmarker$hand_landmarker.HandLandmarker.HAND_CONNECTIONS",Rf.HAND_CONNECTIONS);var If=class extends sf{constructor(e,t){super(new ef(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},this.h=new Rd,e=new Jc,il(this.h,0,1,e)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){var t=Wd(e,nl(this.h,zc,2));return il(this.h,0,2,t),this.l(e)}ga(e,t){return this.j={classifications:[]},rf(this,e,t),this.j}ha(e,t,n){return this.j={classifications:[]},af(this,e,n,t),this.j}m(){var e=new tc;Qu(e,"input_image"),Qu(e,"norm_rect"),ec(e,"classifications");const t=new Nu;vl(t,Id,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),qu(n,"IMAGE:input_image"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"CLASSIFICATIONS:classifications"),n.o(t),Zu(e,n),this.g.attachProtoListener("classifications",((e,t)=>{this.j=function(e){const t={classifications:al(e,Fc,1).map((e=>Kd(nl(e,sc,4)?.g()??[],dl(ll(e,2)),cl(e,3)??"")))};return null!=ul(e)&&(t.timestampMs=dl(ul(e))),t}(Nc(e)),ph(this,t)})),this.g.attachEmptyPacketListener("classifications",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};If.prototype.classifyForVideo=If.prototype.ha,If.prototype.classify=If.prototype.ga,If.prototype.setOptions=If.prototype.o,If.createFromModelPath=function(e,t){return tf(If,e,{baseOptions:{modelAssetPath:t}})},If.createFromModelBuffer=function(e,t){return tf(If,e,{baseOptions:{modelAssetBuffer:t}})},If.createFromOptions=function(e,t){return tf(If,e,t)};var _f=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!0),this.h=new _d,this.embeddings={embeddings:[]},e=new Jc,il(this.h,0,1,e)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){var t=this.h,n=nl(this.h,Hc,2);return n=n?n.clone():new Hc,void 0!==e.l2Normalize?fl(n,1,e.l2Normalize):"l2Normalize"in e&&Gs(n,1),void 0!==e.quantize?fl(n,2,e.quantize):"quantize"in e&&Gs(n,2),il(t,0,2,n),this.l(e)}la(e,t){return rf(this,e,t),this.embeddings}ma(e,t,n){return af(this,e,n,t),this.embeddings}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"embeddings_out");const t=new Nu;vl(t,Dd,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"EMBEDDINGS:embeddings_out"),n.o(t),Zu(e,n),this.g.attachProtoListener("embeddings_out",((e,t)=>{e=Gc(e),this.embeddings=function(e){return{embeddings:al(e,Bc,1).map((e=>{const t={headIndex:dl(ll(e,3))??-1,headName:cl(e,4)??""??""};if(void 0!==tl(e,Oc,Zs(e,1)))e=Ws(e=nl(e,Oc,Zs(e,1)),1,us),t.floatEmbedding=e;else{const n=new Uint8Array(0);t.quantizedEmbedding=nl(e,Pc,Zs(e,2))?.da()?.fa()??n}return t})),timestampMs:dl(ul(e))}}(e),ph(this,t)})),this.g.attachEmptyPacketListener("embeddings_out",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};_f.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Qd(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Qd(Zd(e.quantizedEmbedding),Zd(t.quantizedEmbedding))}return e},_f.prototype.embedForVideo=_f.prototype.ma,_f.prototype.embed=_f.prototype.la,_f.prototype.setOptions=_f.prototype.o,_f.createFromModelPath=function(e,t){return tf(_f,e,{baseOptions:{modelAssetPath:t}})},_f.createFromModelBuffer=function(e,t){return tf(_f,e,{baseOptions:{modelAssetBuffer:t}})},_f.createFromOptions=function(e,t){return tf(_f,e,t)};var Df=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 Ff(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function Mf(e){try{const t=new Df(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{vh(e)}}Df.prototype.close=Df.prototype.close;var Lf=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Od,this.v=new Fd,il(this.h,0,3,this.v),e=new Jc,il(this.h,0,1,e)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?Gs(this.h,2,gs(e.displayNamesLocale)):"displayNamesLocale"in e&&Gs(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=al(e.U(),Vu,1).filter((e=>(cl(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&&(nl(t[0],Nu,7)?.l()?.g()??new Map).forEach(((t,n)=>{e.s[Number(n)]=cl(t,1)??""}))}(this)}V(e,t,n){const r="function"!=typeof t?t:{};return this.j="function"==typeof t?t:n,Ff(this),rf(this,e,r),Mf(this)}ya(e,t,n,r){const a="function"!=typeof n?n:{};return this.j="function"==typeof n?n:r,Ff(this),af(this,e,a,t),Mf(this)}ra(){return this.s}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect");const t=new Nu;vl(t,Pd,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),n.o(t),Zu(e,n),gh(this,e),this.outputConfidenceMasks&&(ec(e,"confidence_masks"),Hu(n,"CONFIDENCE_MASKS:confidence_masks"),mh(this,"confidence_masks"),this.g.R("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>of(this,e,!this.j))),ph(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],ph(this,e)}))),this.outputCategoryMask&&(ec(e,"category_mask"),Hu(n,"CATEGORY_MASK:category_mask"),mh(this,"category_mask"),this.g.P("category_mask",((e,t)=>{this.categoryMask=of(this,e,!this.j),ph(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,ph(this,e)}))),ec(e,"quality_scores"),Hu(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,ph(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Lf.prototype.getLabels=Lf.prototype.ra,Lf.prototype.segmentForVideo=Lf.prototype.ya,Lf.prototype.segment=Lf.prototype.V,Lf.prototype.setOptions=Lf.prototype.o,Lf.createFromModelPath=function(e,t){return tf(Lf,e,{baseOptions:{modelAssetPath:t}})},Lf.createFromModelBuffer=function(e,t){return tf(Lf,e,{baseOptions:{modelAssetBuffer:t}})},Lf.createFromOptions=function(e,t){return tf(Lf,e,t)};var Nf=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){this.confidenceMasks?.forEach((e=>{e.close()})),this.categoryMask?.close()}};Nf.prototype.close=Nf.prototype.close;var Of=class extends yl{constructor(e){super(e)}},Pf=[0,nu,nu,nu],Bf=[0,Yl,Yl,Yl,Yl,iu],Uf=[0,Yl,Yl,Yl,Yl,iu,Yl,Yl],$f=[0,du,Uf],jf=[0,du,$f,du,Pf],Gf=[0,du,Uf,du,Pf],zf=[0,du,Uf,nu,nu],qf=[0,du,zf,du,Pf],Hf=[0,Yl,Yl,Yl,Yl,iu,du,Pf,du,Pf],Vf=[0,Yl,Yl,Yl,Yl,iu,mu],Wf=class extends yl{constructor(e){super(e)}},Kf=[0,Yl,Yl,iu],Yf=class extends yl{constructor(){super()}};Yf.B=[1];var Xf=class extends yl{constructor(e){super(e)}},Jf=[1,2,3,4,5,6,7,8,9,10,14,15],Zf=[0,fu,Uf,Jf,fu,Gf,Jf,fu,$f,Jf,fu,jf,Jf,fu,Kf,Jf,fu,Vf,Jf,fu,Bf,Jf,fu,[0,uu,Yl,Yl,Yl,iu,nu,iu,iu,Yl,3,du,Pf],Jf,fu,zf,Jf,fu,qf,Jf,Yl,du,Pf,uu,fu,Hf,Jf,fu,[0,hu,Kf],Jf],Qf=[0,uu,nu,nu,iu],ep=class extends yl{constructor(){super()}};ep.B=[1],ep.prototype.g=xu([0,hu,Zf,uu,du,Qf]);var tp=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Od,this.v=new Fd,il(this.h,0,3,this.v),e=new Jc,il(this.h,0,1,e)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(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 a="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 ep;const i=new Xf;var o=new Of;if(pl(o,1,255),il(i,0,12,o),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var s=new Wf;fl(s,3,!0),gl(s,1,t.keypoint.x),gl(s,2,t.keypoint.y),ol(i,5,Jf,s)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(s of(o=new Yf,t.scribble))fl(t=new Wf,3,!0),gl(t,1,s.x),gl(t,2,s.y),sl(o,Wf,t);ol(i,15,Jf,o)}sl(r,Xf,i),this.g.addProtoToStream(r.g(),"drishti.RenderData","roi_in",n),rf(this,e,a);e:{try{const e=new Nf(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=e;break e}this.j(e)}finally{vh(this)}l=void 0}return l}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"roi_in"),Qu(e,"norm_rect_in");const t=new Nu;vl(t,Pd,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),qu(n,"IMAGE:image_in"),qu(n,"ROI:roi_in"),qu(n,"NORM_RECT:norm_rect_in"),n.o(t),Zu(e,n),gh(this,e),this.outputConfidenceMasks&&(ec(e,"confidence_masks"),Hu(n,"CONFIDENCE_MASKS:confidence_masks"),mh(this,"confidence_masks"),this.g.R("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>of(this,e,!this.j))),ph(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],ph(this,e)}))),this.outputCategoryMask&&(ec(e,"category_mask"),Hu(n,"CATEGORY_MASK:category_mask"),mh(this,"category_mask"),this.g.P("category_mask",((e,t)=>{this.categoryMask=of(this,e,!this.j),ph(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,ph(this,e)}))),ec(e,"quality_scores"),Hu(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,ph(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};tp.prototype.segment=tp.prototype.V,tp.prototype.setOptions=tp.prototype.o,tp.createFromModelPath=function(e,t){return tf(tp,e,{baseOptions:{modelAssetPath:t}})},tp.createFromModelBuffer=function(e,t){return tf(tp,e,{baseOptions:{modelAssetBuffer:t}})},tp.createFromOptions=function(e,t){return tf(tp,e,t)};var np=class extends sf{constructor(e,t){super(new ef(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},this.h=new Bd,e=new Jc,il(this.h,0,1,e)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?Gs(this.h,2,gs(e.displayNamesLocale)):"displayNamesLocale"in e&&Gs(this.h,2),void 0!==e.maxResults?pl(this.h,3,e.maxResults):"maxResults"in e&&Gs(this.h,3),void 0!==e.scoreThreshold?gl(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&Gs(this.h,4),void 0!==e.categoryAllowlist?Js(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&Gs(this.h,5),void 0!==e.categoryDenylist?Js(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&Gs(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},rf(this,e,t),this.j}D(e,t,n){return this.j={detections:[]},af(this,e,n,t),this.j}m(){var e=new tc;Qu(e,"input_frame_gpu"),Qu(e,"norm_rect"),ec(e,"detections");const t=new Nu;vl(t,Ud,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),qu(n,"IMAGE:input_frame_gpu"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"DETECTIONS:detections"),n.o(t),Zu(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=wc(t),this.j.detections.push(Yd(e));ph(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{ph(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function rp(e){e.landmarks=[],e.worldLandmarks=[],e.v=void 0}function ap(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{vh(e)}}np.prototype.detectForVideo=np.prototype.D,np.prototype.detect=np.prototype.F,np.prototype.setOptions=np.prototype.o,np.createFromModelPath=async function(e,t){return tf(np,e,{baseOptions:{modelAssetPath:t}})},np.createFromModelBuffer=function(e,t){return tf(np,e,{baseOptions:{modelAssetBuffer:t}})},np.createFromOptions=function(e,t){return tf(np,e,t)};var ip=class extends sf{constructor(e,t){super(new ef(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,this.h=new qd,e=new Jc,il(this.h,0,1,e),this.C=new Gd,il(this.h,0,3,this.C),this.j=new $d,il(this.h,0,2,this.j),pl(this.j,4,1),gl(this.j,2,.5),gl(this.C,2,.5),gl(this.h,4,.5)}get baseOptions(){return nl(this.h,Jc,1)}set baseOptions(e){il(this.h,0,1,e)}o(e){return"numPoses"in e&&pl(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&gl(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&gl(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&gl(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,rp(this),rf(this,e,r),ap(this)}D(e,t,n,r){const a="function"!=typeof n?n:{};return this.s="function"==typeof n?n:r,rp(this),af(this,e,a,t),ap(this)}m(){var e=new tc;Qu(e,"image_in"),Qu(e,"norm_rect"),ec(e,"normalized_landmarks"),ec(e,"world_landmarks"),ec(e,"segmentation_masks");const t=new Nu;vl(t,Vd,this.h);const n=new Vu;zu(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),qu(n,"IMAGE:image_in"),qu(n,"NORM_RECT:norm_rect"),Hu(n,"NORM_LANDMARKS:normalized_landmarks"),Hu(n,"WORLD_LANDMARKS:world_landmarks"),n.o(t),Zu(e,n),gh(this,e),this.g.attachProtoVectorListener("normalized_landmarks",((e,t)=>{this.landmarks=[];for(const t of e)e=Rc(t),this.landmarks.push(Xd(e));ph(this,t)})),this.g.attachEmptyPacketListener("normalized_landmarks",(e=>{this.landmarks=[],ph(this,e)})),this.g.attachProtoVectorListener("world_landmarks",((e,t)=>{this.worldLandmarks=[];for(const t of e)e=Sc(t),this.worldLandmarks.push(Jd(e));ph(this,t)})),this.g.attachEmptyPacketListener("world_landmarks",(e=>{this.worldLandmarks=[],ph(this,e)})),this.outputSegmentationMasks&&(Hu(n,"SEGMENTATION_MASK:segmentation_masks"),mh(this,"segmentation_masks"),this.g.R("segmentation_masks",((e,t)=>{this.v=e.map((e=>of(this,e,!this.s))),ph(this,t)})),this.g.attachEmptyPacketListener("segmentation_masks",(e=>{this.v=[],ph(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ip.prototype.detectForVideo=ip.prototype.D,ip.prototype.detect=ip.prototype.F,ip.prototype.setOptions=ip.prototype.o,ip.createFromModelPath=function(e,t){return tf(ip,e,{baseOptions:{modelAssetPath:t}})},ip.createFromModelBuffer=function(e,t){return tf(ip,e,{baseOptions:{modelAssetBuffer:t}})},ip.createFromOptions=function(e,t){return tf(ip,e,t)},ip.POSE_CONNECTIONS=Jh([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]),ti("module$exports$google3$third_party$mediapipe$tasks$web$vision$pose_landmarker$pose_landmarker.PoseLandmarker.POSE_CONNECTIONS",ip.POSE_CONNECTIONS);var op;function sp(e,t,n,r){t.forEach((function(t){var a=t.keypoints.map((function(e){return[e.x,e.y]}));if(n){e.strokeStyle="#FF2C35",e.lineWidth=1;var i=t.box;!function(e,t,n){var r=new Path2D;r.moveTo(t[0][0],t[0][1]);for(var a=1;a<t.length;a++){var i=t[a];r.lineTo(i[0],i[1])}n&&r.closePath(),e.stroke(r)}(e,[[i.xMin,i.yMin],[i.xMax,i.yMin],[i.xMax,i.yMax],[i.xMin,i.yMax]],!0)}if(r){e.fillStyle="#32EEDB";for(var o=0;o<6;o++){var s=a[o][0],l=a[o][1];e.beginPath(),e.arc(s,l,3,0,2*Math.PI),e.fill()}}}))}function lp(){return g(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return op?[2,op]:[4,ah.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.6/wasm")];case 1:return e=t.sent(),[4,lf.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,op=t.sent()]}}))}))}var up,cp,dp,hp,fp,pp,gp=n.createContext({start:function(){return null},stop:function(){return null},onPredictionMade:function(){return null},canvasRef:{current:null},ready:!1}),mp=function(e){var t=e.autoStart,r=void 0===t||t,a=e.children,i=e.throttleMs,o=n.useContext(Mt),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),k=n.useRef(0),S=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,lp()];case 1:return e.current=t.sent(),y(!0),[2]}}))}))}),[]),n.useEffect((function(){if(l&&u&&w&&v){var e;S.current+=1;var t=S.current;return g(void 0,void 0,void 0,(function(){var n,r,a,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===(a=s.current)||void 0===a?void 0:a.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 a;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===S.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,a,i,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!==(a=null===(r=e.boundingBox)||void 0===r?void 0:r.originX)&&void 0!==a?a:0)+(null!==(s=null===(i=e.boundingBox)||void 0===i?void 0:i.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===(a=h.current)||void 0===a||a.call(h,c),n&&sp(n,c,!0,!0)),[3,6];case 5:return d=f.sent(),console.error("caught face detection error",d),[3,6];case 6:return i?e=setTimeout((function(){k.current=requestAnimationFrame(r)}),i):k.current=requestAnimationFrame(r),[2]}}))}))}()]):[2];case 1:return l.sent(),[2]}}))})),function(){k.current&&cancelAnimationFrame(k.current),e&&clearTimeout(e)}}}),[u,v,w,i,l,s]);var C=n.useCallback((function(){x(!0)}),[]),T=n.useCallback((function(){x(!1)}),[]);n.useEffect((function(){return r&&C(),function(){T()}}),[r,C,T]);var A=n.useCallback((function(e){h.current=e}),[]),R=n.useMemo((function(){return{start:C,stop:T,ready:v,canvasRef:d,onPredictionMade:A}}),[A,v,C,T]);return c.createElement(gp.Provider,{value:R},a)},vp=h.default.div(up||(up=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"})),yp=h.default.div(cp||(cp=y(["\n margin-left: auto;\n margin-right: auto;\n background: ",";\n color: ",";\n padding: 10px 12px 8px;\n border-radius: 8px;\n"],["\n margin-left: auto;\n margin-right: auto;\n background: ",";\n color: ",";\n padding: 10px 12px 8px;\n border-radius: 8px;\n"])),(function(e){var t=e.$background;return null!=t?t:"#ccc"}),(function(e){var t=e.$textColor;return null!=t?t:"black"})),bp={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},wp=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],a=!0,i=!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&&(a=Math.abs(e.videoWidth/2-d)>f||Math.abs(c+50-h)>g,i=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=!(a||i||o||s);return w?e.faceReady||(l=new Date):(l=null,u=0),p(p({},e),{faces:n,faceNotCentered:a,faceLookingAway:i,faceTooClose:o,faceTooFar:s,faceReady:w,faceReadyAt:l,goodFramesCount:u})}},xp=function(e){var t,r,a,i=e.onGuidanceSatisfied,o=e.onGuidanceNotSatisfied,s=e.onSelfieCaptured,l=e.onTimeout,c=e.onExit,d=e.timeoutDurationMs,h=void 0===d?15e3:d,f=e.guidanceMessage,p=e.colors,v=void 0===p?{}:p,y=e.verbiage,b=void 0===y?{}:y,w=e.debugMode,x=ye().t,E=kt(),k=E.ref,S=E.width,C=void 0===S?1:S,T=E.height,A=void 0===T?1:T,R=n.useReducer(wp,bp),I=R[0],_=R[1],D=n.useContext(Mt),F=D.cameraRef,M=D.cameraReady,L=D.takePhoto,N=D.videoRef,O=n.useContext(gp).onPredictionMade;n.useEffect((function(){M&&N.current&&0!==N.current.videoWidth&&_({type:"configure",payload:{videoWidth:N.current.videoWidth,videoHeight:N.current.videoHeight}})}),[M,N]),n.useEffect((function(){O((function(e){_({type:"facesDetected",payload:{faces:e}})}))}),[O]);var P=n.useState(!1),B=P[0],U=P[1];n.useEffect((function(){var e;return I.faceReady?(null==i||i(),e=setTimeout((function(){U(!0)}),500)):null==o||o(),function(){e&&clearTimeout(e)}}),[o,i,I.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 B&&I.faces.length>0?[4,L()]:[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(),I.faces[0]]),n.label=4;case 4:n.label=5;case 5:return[2]}}))}))}),[B,s,I.faces,L]);var $=n.useState(),j=$[0],G=$[1],z=n.useState(!1),q=z[0],H=z[1];n.useEffect((function(){if(h){G(new Date);var e=setTimeout((function(){H(!0)}),h);return function(){e&&clearTimeout(e)}}}),[h]),n.useEffect((function(){q&&(null==l||l())}),[l,q]);var V=Da({enabled:w,pageWidth:C,pageHeight:A,videoWidth:I.videoWidth,videoHeight:I.videoHeight});return v.guidesUnsatisfiedColor||(v.guidesUnsatisfiedColor="white"),v.guidesSatisfiedColor||(v.guidesSatisfiedColor="green"),v.guidanceMessagesUnsatisfiedBackgroundColor||(v.guidanceMessagesUnsatisfiedBackgroundColor="red"),v.guidanceMessagesSatisfiedBackgroundColor||(v.guidanceMessagesSatisfiedBackgroundColor="green"),v.guidanceMessagesUnsatisfiedTextColor||(v.guidanceMessagesUnsatisfiedTextColor="white"),v.guidanceMessagesSatisfiedTextColor||(v.guidanceMessagesSatisfiedTextColor="white"),f||(b.guidanceHoldStillText||(b.guidanceHoldStillText=x("Hold still for a few seconds...")),b.guidanceLookStraightText||(b.guidanceLookStraightText=x("Look straight into the camera...")),b.guidanceMoveBackText||(b.guidanceMoveBackText=x("Move back...")),b.guidanceMoveForwardText||(b.guidanceMoveForwardText=x("Move forward...")),b.guidanceMoveToCenterText||(b.guidanceMoveToCenterText=x("Move to the center...")),f=I.faceReady?b.guidanceHoldStillText:I.faceLookingAway?b.guidanceLookStraightText:I.faceTooClose?b.guidanceMoveBackText:I.faceTooFar?b.guidanceMoveForwardText:I.faceNotCentered?b.guidanceMoveToCenterText:""),u.default.createElement(Ze,{ref:k,className:"flex"},u.default.createElement(Ka,null),u.default.createElement(Qa,{borderColor:I.faceReady?v.guidesSatisfiedColor:v.guidesUnsatisfiedColor}),""!==f&&u.default.createElement(vp,null,u.default.createElement(yp,{$background:I.faceReady?v.guidanceMessagesSatisfiedBackgroundColor:v.guidanceMessagesUnsatisfiedBackgroundColor,$textColor:I.faceReady?v.guidanceMessagesSatisfiedTextColor:v.guidanceMessagesUnsatisfiedTextColor},f)),w&&I.faces.length>0&&u.default.createElement(Ra,{$flipX:!(null===(t=F.current)||void 0===t?void 0:t.isRearFacing)},I.faces.map((function(e,t){var n;return u.default.createElement(Ma,{key:t,face:e,scaling:V,flipX:!(null===(n=F.current)||void 0===n?void 0:n.isRearFacing),color:I.faceReady?"green":"red"})}))),w&&u.default.createElement(Aa,null,F.current?u.default.createElement(u.default.Fragment,null,"✅ Camera: ",null===(r=F.current)||void 0===r?void 0:r.width,"x",null===(a=F.current)||void 0===a?void 0:a.height):"❌ Camera not ready",u.default.createElement("br",null),I.faceNotCentered?"❌":"✅"," Face Centered",u.default.createElement("br",null),I.faceTooClose||I.faceTooFar?"❌":"✅"," Face"," ",I.faceTooClose?"Too Close":I.faceTooFar?"Too Far":"Distance Correct",u.default.createElement("br",null),I.faceLookingAway?"❌":"✅"," Face Looking Forward",u.default.createElement("br",null),I.goodFramesThresholdMet?"✅":"❌"," ",I.goodFramesCount," ","Good Frames",u.default.createElement("br",null),q?"❌":"✅"," Time Remaining:"," ",Math.max(0,h-((new Date).getTime()-(null!=j?j:new Date).getTime())),"ms"),u.default.createElement(Ba,{onClick:c},"×"))},Ep=h.default.div(dp||(dp=y(["\n display: inline-block;\n width: ","px;\n height: ","px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: ","px;\n height: ","px;\n margin: 8px;\n border-radius: 50%;\n border: ","px solid\n ",";\n border-color: "," transparent\n "," transparent;\n animation: lds-dual-ring 1.2s linear infinite;\n box-sizing: content-box;\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: ","px;\n height: ","px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: ","px;\n height: ","px;\n margin: 8px;\n border-radius: 50%;\n border: ","px solid\n ",";\n border-color: "," transparent\n "," transparent;\n animation: lds-dual-ring 1.2s linear infinite;\n box-sizing: content-box;\n }\n\n @keyframes lds-dual-ring {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n"])),(function(e){var t=e.$size;return null!=t?t:80}),(function(e){var t=e.$size;return null!=t?t:80}),(function(e){var t=e.$size;return(null!=t?t:80)-16}),(function(e){var t=e.$size;return(null!=t?t:80)-16}),(function(e){var t=e.$thickness;return null!=t?t:6}),(function(e){var t=e.$color;return null!=t?t:"#888"}),(function(e){var t=e.$color;return null!=t?t:"#888"}),(function(e){var t=e.$color;return null!=t?t:"#888"})),kp={frame:null,face:null,requestState:"NOT_READY",requestError:null,imageUrl:null,faceLive:!1,eyeCoveringDetected:!1,maskDetected:!1,headCoveringDetected:!1,phoneDetected:!1,timesLivenessCheckFailed:0},Sp=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,a=r.statusMessage,i=r.errorData,o=n.resultData;if("000"!==r.statusCode)return p(p({},e),{requestState:"ERROR",requestError:new Error("".concat(a,": ").concat(i))});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}},Cp=function(e){var t=e.onCapture,r=e.onSuccess,a=e.onTimeout,i=e.onExit,o=e.timeoutDurationMs,s=void 0===o?15e3:o,l=e.colors,c=void 0===l?{}:l,d=e.verbiage,h=void 0===d?{}:d,f=e.debugMode,p=ye().t,v=n.useContext(qe).checkLiveness,y=n.useReducer(Sp,kp),b=y[0],w=y[1],x=n.useState(null),E=x[0],k=x[1],S=n.useCallback((function(e,n){null==t||t(),w({type:"livenessReady",payload:{frame:e,face:n}})}),[t]),C=b.frame,T=b.face,A="READY"===b.requestState,R="PASSED"===b.requestState;n.useEffect((function(){C&&T&&A&&(w({type:"livenessChecking"}),g(void 0,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),e=da(C,T),k(e),n=v,[4,We(e)];case 1:return[4,n.apply(void 0,[a.sent()])];case 2:return t=a.sent(),w({type:"livenessChecked",payload:{frame:C,face:T,imageUrl:e,response:t}}),[3,4];case 3:return r=a.sent(),w({type:"livenessCheckFailed",payload:{error:r}}),[3,4];case 4:return[2]}}))})))}),[v,T,C,A]),n.useEffect((function(){R&&b.imageUrl&&(null==r||r(b.imageUrl))}),[r,b.imageUrl,R]),n.useEffect((function(){b.timesLivenessCheckFailed>=2&&(null==a||a())}),[a,b.timesLivenessCheckFailed]);var I=n.useState(!1),_=I[0],D=I[1];return n.useEffect((function(){if(s){var e=setTimeout((function(){D(!0)}),s);return function(){e&&clearTimeout(e)}}}),[s]),n.useEffect((function(){if(_&&"PASSED"!==b.requestState){if("IN_PROGRESS"===b.requestState){var e=setTimeout((function(){null==a||a()}),1e4);return function(){clearTimeout(e)}}null==a||a()}}),[a,b.requestState,_]),h.guidanceRemoveEyeCoveringsText||(h.guidanceRemoveEyeCoveringsText=p("Please remove your eye coverings (sunglasses, eye patch, etc.)...")),h.guidanceRemoveHeadCoveringsText||(h.guidanceRemoveHeadCoveringsText=p("Please remove your head coverings (hat, scarf, etc.)...")),h.guidanceRemoveMaskText||(h.guidanceRemoveMaskText=p("Please remove your mask...")),u.default.createElement(u.default.Fragment,null,u.default.createElement(xp,{onSelfieCaptured:S,onExit:i,timeoutDurationMs:s,guidanceMessage:b.eyeCoveringDetected?h.guidanceRemoveEyeCoveringsText:b.headCoveringDetected?h.guidanceRemoveHeadCoveringsText:b.maskDetected?h.guidanceRemoveMaskText:void 0,colors:c,verbiage:h,debugMode:f}),E&&u.default.createElement(Tp,{imageUrl:E}))},Tp=function(e){var t=e.imageUrl;return u.default.createElement(Ap,null,u.default.createElement(Rp,null,u.default.createElement(Ep,{$size:24,$color:"white",$thickness:3,style:{position:"relative",top:4,left:-3,margin:"0 3px 0 -12px"}}),"Processing..."),u.default.createElement(Ip,null,u.default.createElement("img",{src:t,alt:""})))},Ap=h.default.div(hp||(hp=y(["\n position: absolute;\n display: flex;\n flex-direction: column;\n height: 33%;\n bottom: 12px;\n right: 12px;\n"],["\n position: absolute;\n display: flex;\n flex-direction: column;\n height: 33%;\n bottom: 12px;\n right: 12px;\n"]))),Rp=h.default.div(fp||(fp=y(["\n display: block;\n position: absolute;\n top: -32px;\n font:\n 14px -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n Helvetica,\n Arial,\n sans-serif,\n 'Apple Color Emoji',\n 'Segoe UI Emoji',\n 'Segoe UI Symbol';\n color: white;\n text-align: center;\n margin: 0 auto;\n width: 100%;\n"],["\n display: block;\n position: absolute;\n top: -32px;\n font:\n 14px -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n Helvetica,\n Arial,\n sans-serif,\n 'Apple Color Emoji',\n 'Segoe UI Emoji',\n 'Segoe UI Symbol';\n color: white;\n text-align: center;\n margin: 0 auto;\n width: 100%;\n"]))),Ip=h.default.div(pp||(pp=y(["\n position: relative;\n height: calc(100% - 8px);\n padding: 4px;\n border-radius: 4px;\n background: white;\n\n & > img {\n border-radius: 4px;\n width: auto;\n max-height: 100%;\n }\n"],["\n position: relative;\n height: calc(100% - 8px);\n padding: 4px;\n border-radius: 4px;\n background: white;\n\n & > img {\n border-radius: 4px;\n width: auto;\n max-height: 100%;\n }\n"]))),_p=function(e){var t=e.headingText,r=e.removeEyeCoveringsText,a=e.avoidExcessiveBacklightingText,i=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(Mt).cameraReady,g=n.useContext(gp).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(ua,"/Selfie-Image-1.png"),t=t||d("Use your device camera to capture your face"),r=r||d("Remove Sunglasses & Hat"),a=a||d("Avoid Excessive Backlighting"),i=i||d("Continue"),o=o||d("Camera initializing..."),s=s||d("Models warming up..."),u.default.createElement(rt,null,u.default.createElement(at,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),a)),u.default.createElement(it,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?i:g?o:s)),u.default.createElement("div",{style:{display:"none"}},u.default.createElement(Ka,null)))))},Dp=function(e){var t=e.headingText,n=e.retryBtnText,r=e.doneBtnText,a=e.imageUrl,i=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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,null,u.default.createElement("img",{alt:t,src:a})),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:i,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},r)))))},Fp=function(e){var t=e.headingText,n=e.retryBtnText,r=e.exitBtnText,a=e.imageUrl,i=e.canRetry,o=void 0===i||i,s=e.onRetryClick,l=e.onExitClick,c=ye().t;return a=a||"".concat(ua,"/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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:a})),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)))))},Mp=function(e){var t=e.onComplete,r=e.onSuccess,a=e.onTimeout,i=e.onExitAfterFailure,o=e.timeoutDurationMs,s=void 0===o?15e3:o,l=e.maxRetries,c=void 0===l?2:l,d=e.assets,h=void 0===d?{}:d,f=e.colors,p=void 0===f?{}:f,v=e.verbiage,y=void 0===v?{}:v,b=e.debugMode,w=void 0!==b&&b,x=n.useContext(qe),E=x.submissionResponse,k=x.setSelfieImage,S=x.logSelfieCaptureAttempt,C=n.useContext(Mt).releaseCameraAccess,T=n.useState(""),A=T[0],R=T[1],I=n.useState(0),_=I[0],D=I[1],F=n.useState("LOADING"),M=F[0],L=F[1],N=n.useRef(),O=n.useRef(),P=n.useRef();n.useEffect((function(){P.current=new Date}),[]),n.useEffect((function(){"CAPTURING"===M&&(N.current=new Date)}),[M]);var B=n.useCallback((function(){O.current=new Date}),[]),U=n.useCallback((function(){var e,t,n;S({autoCapture:"Y",captureTime:(null!==(e=O.current)&&void 0!==e?e:new Date).getTime()-(null!==(t=N.current)&&void 0!==t?t:new Date).getTime(),operationTime:(new Date).getTime()-(null!==(n=P.current)&&void 0!==n?n:new Date).getTime()}),P.current=new Date}),[S]),$=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 L("SUCCESS"),R(e),t=k,[4,We(e)];case 1:return t.apply(void 0,[n.sent()]),null==r||r(E),[2]}}))}))}),[r,k,E]),j=n.useCallback((function(){L("FAILED"),null==a||a(E)}),[a,E]),G=n.useState(0),z=G[0],q=G[1],H=n.useCallback((function(){q((function(e){return e+1})),L("LOADING")}),[]);return u.default.createElement(u.default.Fragment,null,"LOADING"!==M&&function(){switch(M){case"CAPTURING":return u.default.createElement(Cp,{key:"capture",onCapture:B,onSuccess:$,onTimeout:j,onExit:H,timeoutDurationMs:s,colors:p,verbiage:y,debugMode:w});case"SUCCESS":return u.default.createElement(Dp,{key:"success",headingText:y.successHeadingText,retryBtnText:y.successRetryBtnText,doneBtnText:y.successDoneBtnText,imageUrl:A,onDoneClick:function(){U(),C(),setTimeout((function(){null==t||t(E)}),0)},onRetryClick:function(){U(),L("CAPTURING")}});case"FAILED":return u.default.createElement(Fp,{key:"failure",headingText:y.failureHeadingText,retryBtnText:y.failureRetryBtnText,exitBtnText:y.failureExitBtnText,imageUrl:h.failureImageUrl,canRetry:c>-1&&_<c,onRetryClick:function(){U(),D((function(e){return e+1})),L("CAPTURING")},onExitClick:function(){C(),setTimeout((function(){null==i||i(E)}),0)}});default:return null}}(),u.default.createElement(_p,{key:z,headingText:y.loadingOverlayHeadingText,removeEyeCoveringsText:y.loadingOverlayRemoveEyeCoveringsText,avoidExcessiveBacklightingText:y.loadingOverlayAvoidExcessiveBacklightingText,continueText:y.loadingOverlayContinueText,cameraInitializingText:y.loadingOverlayCameraInitializingText,modelsWarmingUpText:y.loadingOverlayModelsWarmingUpText,instructionImageUrl:h.instructionImageUrl,onDismissed:function(){L("CAPTURING")}}))};function Lp(){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 Np,Op=["front","avant","anteriore","cameraaanvoorzijde","kamerapåframsidan","forsidekamera","kamerapåforsiden","aparatprzedni","etukamera","kameradepan","ÖnKamera","cameramặttrước","camerăfață","prednákamera","prednjakamera","előlapikamera","přednífotoaparát","μπροστινήκάμερα","переднякамера","передняякамера","преднакамера","алдыңғыкамера","מצלמה קדמית","الكاميرا الأمامية","फ़्रंटकैमरा","前置相机","前置鏡頭","前面カメラ","전면카메라","กล้องด้านหน้า"].map((function(e){return e.toLocaleLowerCase().split(" ").join("")})),Pp=["back","rear","posterior","trasera","traseira","arrière","rückkamera","fotocamera(posteriore)","cameraaanachterzijde","kamerapåbaksidan","kamerapåbaksiden","bagsidekamera","aparattylny","takakamera","arkakamera","kamerabelakang","cameramặtsau","camerăspate","stražnjakamera","zadnákamera","hátoldalikamera","zadnífotoaparát","πίσωκάμερα","заднякамера","Задняякамера","заднакамера","артқыкамера","מצלמה אחורית","الكاميرا الخلفية","बैककैमरा","后置相机","後置鏡頭","背面カメラ","후면카메라","กล้องด้านหลัง"].map((function(e){return e.toLocaleLowerCase().split(" ").join("")})),Bp=["backultrawidecamera","ultraampliaposterior","ultra-angulartraseira","ultragrandeangulartraseira","ultragrandangle","ultragranangular","ultra-weitwinkelkamera","ultra-grandangolo","ultrabredecameraaanachterzijde","ultravidvinkelkamerapåbaksidan","ultravidvinkelkameraetpåbagsiden","ultravidvinkelkamerabak","ultragenişkameraarkayüzü","ultralaajakulmainentakakamera","tylnyaparatultraszerokokątny","cameracựcrộngmặtsau","camerăcuobiectivultra‑superangularspate","ultraszéleslátószögűkamera","kameraultralebarbelakang","stražnjaultraširokakamera","zadníultraširokoúhlýfotoaparát","ultraširokouhlá","πίσωυπερευρείακάμερα","заднянадширококутнакамера","Задняясверхширокоугольнаякамера","Задна свръх широкоъгълна камера","артқыультракеңбұрыштыкамера","מצלמה אולטרה רחבה אחורית","كاميرا خلفية عريضة جدًا","बैकअल्ट्रावाइडकैमरा","后置超广角相机","後置超廣角鏡頭相機","背面超広角カメラ","후면울트라와이드카메라","กล้องด้านหลังอัลตร้าไวด์"].map((function(e){return e.toLocaleLowerCase().split(" ").join("")})),Up=function(e,t){var n=e instanceof MediaDeviceInfo?$p(e):e;return("string"==typeof t?[t]:t).some((function(e){return n.includes(e)}))},$p=function(e){return e.label.toLocaleLowerCase().split(" ").join("")};function jp(){Np&&(console.log("releasing camera access..."),Np.release(),Np=void 0)}var Gp=function(e){var t=void 0===e?{preferFrontFacingCamera:!1,preferContinuityCamera:!0,requestMicrophoneAccess:!1}:e,r=t.preferFrontFacingCamera,a=void 0!==r&&r,i=t.preferContinuityCamera,o=void 0===i||i,s=t.requestMicrophoneAccess,l=void 0!==s&&s,u=n.useRef(null),c=n.useRef(null),d=n.useState(null),h=d[0],f=d[1],p=n.useState(!1),y=p[0],b=p[1],w=n.useState(null),x=w[0],E=w[1],k=n.useState(!1),S=k[0],C=k[1],T=n.useState(o),A=T[0],R=T[1],I=n.useState(!1),_=I[0],D=I[1],F=n.useState(!1),M=F[0],L=F[1];n.useEffect((function(){console.log("iphone continuity camera allowed changed",A),jp(),c.current=null,b(!1)}),[A]);var N=n.useCallback((function(){L(!1)}),[]);n.useEffect((function(){M||function(e){return g(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,navigator.mediaDevices.getUserMedia({video:{facingMode:{exact:e}},audio:!1})];case 1:return t=r.sent(),[3,3];case 2:return r.sent(),[2,[]];case 3:return[4,navigator.mediaDevices.enumerateDevices()];case 4:return n=r.sent().filter((function(e){return"videoinput"===e.kind})),t.getVideoTracks().forEach((function(e){e.enabled=!1,e.stop()})),t=null,[2,n]}}))}))}().then((function(e){var t;a&&(t=e.find((function(e){return Up(e,Op)})));var n=mt();if(!(_||n&&"OS X"!==n.os.family)){var r=e.find((function(e){return Up(e,"iphone")}));C(!!r),r&&A&&(t||(t=r))}Lp()?t||(t=e.find((function(e){return Up(e,Bp)}))):t||(t=e.find((function(e){return Up(e,Pp)&&!Up(e,Bp)}))),t||(t=e.find((function(e){return Up(e,Pp)}))),!a&&"iOS"===(null==n?void 0:n.os.family)&&e.length>0&&(t||(t=e[1])),t||(t=e[0]),f(t)})).catch((function(e){if("NotAllowedError"!==e.name)throw e;console.error("camera access has been blocked by the user",e),L(!0)}))}),[M,A,_,a]),n.useEffect((function(){var e;if(h){var t=function(){jp(),c.current=null,b(!1)};return(null===(e=navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia)?(g(void 0,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:l,video:{deviceId:{exact:h.deviceId},width:{ideal:1920},aspectRatio:1.777777778}})];case 2:return e=t.sent(),[3,4];case 3:return"NotAllowedError"===t.sent().name?(A?(C(!1),D(!0)):L(!0),[2]):[3,4];case 4:if(e)return[3,8];t.label=5;case 5:return t.trys.push([5,7,,8]),[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 6:return e=t.sent(),console.log("opened stream with no width and height constraints"),[3,8];case 7:return t.sent(),console.log("cannot open stream at all"),[3,8];case 8:if(!e)throw new Error("failed to open camera");return e.getVideoTracks()[0].onended=function(){var e;S&&A?(console.log("someone unplugged the continuity camera"),C(!1),D(!0)):(console.log("someone unplugged the webcam"),null===(e=c.current)||void 0===e||e.release(),c.current=null,b(!1),L(!0),E(null))},c.current=function(e,t,n){jp(),console.log("obtaining camera access...");var r=e.getVideoTracks()[0].getSettings(),a=r.width,i=r.height,o=t.toLocaleLowerCase().split(" ").join(""),s=Up(o,v(v(v([],Pp,!0),Bp,!0),["iphone"],!1));return a||(a=0),i||(i=0),Np={stream:e,width:a,height:i,isRearFacing:s,release:function(){e.getTracks().forEach((function(e){e.enabled=!1,e.stop()})),n&&(n.pause(),n.srcObject=null,n.src="")}},n&&(n.srcObject=e),Np}(e,h.label,u.current),[2]}}))})),t):t}}),[A,S,l,h]),n.useEffect((function(){E(null),y&&g(void 0,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(a){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])?(E(new ImageCapture(e)),[2]):[2]}))}))}),[y]);var O=n.useCallback((function(){return g(void 0,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return x?[4,x.grabFrame()]:[2,null];case 1:return[2,e.sent()]}}))}))}),[x]),P=n.useCallback((function(){return g(void 0,void 0,void 0,(function(){var e,t,n,r,a;return m(this,(function(i){switch(i.label){case 0:return e=document.createElement("canvas"),(t=e.getContext("2d"))&&c.current&&u.current?(e.width=null===(r=u.current)||void 0===r?void 0:r.videoWidth,e.height=null===(a=u.current)||void 0===a?void 0:a.videoHeight,t.drawImage(u.current,0,0,e.width,e.height),n=e.toDataURL("image/jpeg",.98),[4,fetch(n)]):[2,null];case 1:return[4,i.sent().blob()];case 2:return[2,i.sent()]}}))}))}),[]);return{videoRef:u,videoDevice:h,videoLoaded:y,setVideoLoaded:b,cameraRef:c,cameraAccessDenied:M,retryCameraAccess:N,releaseCameraAccess:jp,iphoneContinuityCameraAvailable:S,iphoneContinuityCameraAllowed:A,setIphoneContinuityCameraAllowed:R,captureDevice:x,grabFrame:O,takePhoto:P}},zp=function(e){var t=e.children,r=e.preferFrontFacingCamera,a=e.preferContinuityCamera,i=e.requestMicrophoneAccess,o=Gp({preferFrontFacingCamera:void 0!==r&&r,preferContinuityCamera:void 0===a||a,requestMicrophoneAccess:void 0!==i&&i}),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],k=x[1];return n.useEffect((function(){k(!1),w&&k(!0)}),[w]),n.useEffect((function(){return function(){p()}}),[p]),u.default.createElement(Mt.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)},qp=function(e){var t=e.children,r=n.useState({width:1,height:1}),a=r[1],i=n.useState(1),o=i[0],s=i[1],l=kt(),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:a,wrapperRef:c,onImageLoaded:m}},t)},Hp=function(){var e=n.useContext(qe),t=e.submissionRequest,r=e.submissionResponse,a=n.useState(!1),i=a[0],o=a[1],s=n.useState(!0),l=s[0],c=s[1],d=n.useMemo((function(){var e,n,r,a,i,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=Vp(s.customerData.idData.idImageFront,200)),(null===(a=null===(r=null==s?void 0:s.customerData)||void 0===r?void 0:r.idData)||void 0===a?void 0:a.idImageBack)&&(s.customerData.idData.idImageBack=Vp(s.customerData.idData.idImageBack,200)),(null===(o=null===(i=null==s?void 0:s.customerData)||void 0===i?void 0:i.biometricData)||void 0===o?void 0:o.selfie)&&(s.customerData.biometricData.selfie=Vp(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(!i)}},i?"Hide":"Show"," request body"),i&&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 Vp(e,t){var n=e.split("").splice(0,t).join("");return n.length<e.length&&(n+="..."),n}var Wp=function(e){var t=e.document,r=e.onComplete,a=e.headingText,i=e.nextBtnText,o=ye().t,s=n.useState(null),l=s[0],c=s[1];return a=a||o("Additional document capture"),i=i||o("Next"),u.default.createElement(rt,null,u.default.createElement(at,{style:{textAlign:"left"}},u.default.createElement("h3",{style:{margin:"0 0 8px"}},a,": ",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)}}},i))))},Kp=function(e){var t=e.documents,r=e.onComplete,a=e.verbiage,i=void 0===a?{}:a,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(Wp,{key:c,headingText:i.headingText,nextBtnText:i.nextBtnText,document:d,onComplete:function(e){l((function(t){return v(v([],t,!0),[e],!1)}))}})},Yp="function"==typeof Symbol&&Symbol.for,Xp=Yp?Symbol.for("react.element"):60103,Jp=Yp?Symbol.for("react.portal"):60106,Zp=Yp?Symbol.for("react.fragment"):60107,Qp=Yp?Symbol.for("react.strict_mode"):60108,eg=Yp?Symbol.for("react.profiler"):60114,tg=Yp?Symbol.for("react.provider"):60109,ng=Yp?Symbol.for("react.context"):60110,rg=Yp?Symbol.for("react.async_mode"):60111,ag=Yp?Symbol.for("react.concurrent_mode"):60111,ig=Yp?Symbol.for("react.forward_ref"):60112,og=Yp?Symbol.for("react.suspense"):60113,sg=Yp?Symbol.for("react.suspense_list"):60120,lg=Yp?Symbol.for("react.memo"):60115,ug=Yp?Symbol.for("react.lazy"):60116,cg=Yp?Symbol.for("react.block"):60121,dg=Yp?Symbol.for("react.fundamental"):60117,hg=Yp?Symbol.for("react.responder"):60118,fg=Yp?Symbol.for("react.scope"):60119;function pg(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case Xp:switch(e=e.type){case rg:case ag:case Zp:case eg:case Qp:case og:return e;default:switch(e=e&&e.$$typeof){case ng:case ig:case ug:case lg:case tg:return e;default:return t}}case Jp:return t}}}function gg(e){return pg(e)===ag}var mg={AsyncMode:rg,ConcurrentMode:ag,ContextConsumer:ng,ContextProvider:tg,Element:Xp,ForwardRef:ig,Fragment:Zp,Lazy:ug,Memo:lg,Portal:Jp,Profiler:eg,StrictMode:Qp,Suspense:og,isAsyncMode:function(e){return gg(e)||pg(e)===rg},isConcurrentMode:gg,isContextConsumer:function(e){return pg(e)===ng},isContextProvider:function(e){return pg(e)===tg},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===Xp},isForwardRef:function(e){return pg(e)===ig},isFragment:function(e){return pg(e)===Zp},isLazy:function(e){return pg(e)===ug},isMemo:function(e){return pg(e)===lg},isPortal:function(e){return pg(e)===Jp},isProfiler:function(e){return pg(e)===eg},isStrictMode:function(e){return pg(e)===Qp},isSuspense:function(e){return pg(e)===og},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===Zp||e===ag||e===eg||e===Qp||e===og||e===sg||"object"==typeof e&&null!==e&&(e.$$typeof===ug||e.$$typeof===lg||e.$$typeof===tg||e.$$typeof===ng||e.$$typeof===ig||e.$$typeof===dg||e.$$typeof===hg||e.$$typeof===fg||e.$$typeof===cg)},typeOf:pg};ae((function(e,t){}));ae((function(e){e.exports=mg}));function vg(){}function yg(){}yg.resetWarningCache=vg;var bg=ae((function(e){e.exports=function(){function e(e,t,n,r,a,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){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:yg,resetWarningCache:vg};return n.PropTypes=n,n}()}));function wg(e,t,n){this.x=e,this.y=t,this.time=n||(new Date).getTime()}function xg(e,t,n,r){this.startPoint=e,this.control1=t,this.control2=n,this.endPoint=r}function Eg(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,a,i,o=null,s=0;n||(n={});var l=function(){s=!1===n.leading?0:Date.now(),o=null,i=e.apply(r,a),o||(r=a=null)};return function(){var u=Date.now();s||!1!==n.leading||(s=u);var c=t-(u-s);return r=this,a=arguments,c<=0||c>t?(o&&(clearTimeout(o),o=null),s=u,i=e.apply(r,a),o||(r=a=null)):o||!1===n.trailing||(o=setTimeout(l,c)),i}}(Eg.prototype._strokeUpdate,this.throttle):Eg.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()}wg.prototype.velocityFrom=function(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):1},wg.prototype.distanceTo=function(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))},wg.prototype.equals=function(e){return this.x===e.x&&this.y===e.y&&this.time===e.time},xg.prototype.length=function(){for(var e=0,t=void 0,n=void 0,r=0;r<=10;r+=1){var a=r/10,i=this._point(a,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),o=this._point(a,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){var s=i-t,l=o-n;e+=Math.sqrt(s*s+l*l)}t=i,n=o}return e},xg.prototype._point=function(e,t,n,r,a){return t*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*r*(1-e)*e*e+a*e*e*e},Eg.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},Eg.prototype.fromDataURL=function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new Image,a=n.ratio||window.devicePixelRatio||1,i=n.width||this._canvas.width/a,o=n.height||this._canvas.height/a;this._reset(),r.src=e,r.onload=function(){t._ctx.drawImage(r,0,0,i,o)},this._isEmpty=!1},Eg.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),a=1;a<n;a++)r[a-1]=arguments[a];return(t=this._canvas).toDataURL.apply(t,[e].concat(r))},Eg.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},Eg.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)},Eg.prototype.isEmpty=function(){return this._isEmpty},Eg.prototype._strokeBegin=function(e){this._data.push([]),this._reset(),this._strokeUpdate(e),"function"==typeof this.onBegin&&this.onBegin(e)},Eg.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],a=r&&t.distanceTo(r)<this.minDistance;if(!r||!a){var i=this._addPoint(t),o=i.curve,s=i.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})}},Eg.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)},Eg.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)},Eg.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)},Eg.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._ctx.fillStyle=this.penColor},Eg.prototype._createPoint=function(e,t,n){var r=this._canvas.getBoundingClientRect();return new wg(e-r.left,t-r.top,n||(new Date).getTime())},Eg.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 a=new xg(t[1],r,n.c1,t[2]),i=this._calculateCurveWidths(a);return t.shift(),{curve:a,widths:i}}return{}},Eg.prototype._calculateCurveControlPoints=function(e,t,n){var r=e.x-t.x,a=e.y-t.y,i=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+a*a),h=Math.sqrt(i*i+o*o),f=h/(d+h),p=t.x-(u+(s-u)*f),g=t.y-(c+(l-c)*f);return{c1:new wg(s+p,l+g),c2:new wg(u+p,c+g)}},Eg.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},Eg.prototype._strokeWidth=function(e){return Math.max(this.maxWidth/(e+1),this.minWidth)},Eg.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},Eg.prototype._drawCurve=function(e,t,n){var r=this._ctx,a=n-t,i=Math.floor(e.length());r.beginPath();for(var o=0;o<i;o+=1){var s=o/i,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*a)}r.closePath(),r.fill()},Eg.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()},Eg.prototype._fromData=function(e,t,n){for(var r=0;r<e.length;r+=1){var a=e[r];if(a.length>1)for(var i=0;i<a.length;i+=1){var o=a[i],s=new wg(o.x,o.y,o.time),l=o.color;if(0===i)this.penColor=l,this._reset(),this._addPoint(s);else if(i!==a.length-1){var u=this._addPoint(s),c=u.curve,d=u.widths;c&&d&&t(c,d,l)}}else this._reset(),n(a[0])}},Eg.prototype._toSVG=function(){var e=this,t=this._data,n=this._canvas,r=Math.max(window.devicePixelRatio||1,1),a=n.width/r,i=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 a="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",a),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 '+a+" "+i+'" width="'+a+'" height="'+i+'">',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>")},Eg.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},Eg.prototype.toData=function(){return this._data};var kg=Object.freeze({__proto__:null,default:Eg}),Sg=ae((function(e,t){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,t),a.loaded=!0,a.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,a=t.getImageData(0,0,n,r).data,s=i(!0,n,r,a),l=i(!1,n,r,a),u=o(!0,n,r,a),c=o(!1,n,r,a)-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 a(e,t,n,a){return r(e,t,n,a).alpha}function i(e,t,n,r){for(var i=e?1:-1,o=e?0:n-1;e?o<n:o>-1;o+=i)for(var s=0;s<t;s++)if(a(s,o,t,r))return o;return null}function o(e,t,n,r){for(var i=e?1:-1,o=e?0:t-1;e?o<t:o>-1;o+=i)for(var s=0;s<n;s++)if(a(o,s,t,r))return o;return null}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n}])}));re(Sg);var Cg=function(e){return e&&e.default||e}(kg),Tg=ae((function(e,t){e.exports=function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,t),a.loaded=!0,a.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 a(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 i(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;i(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 a(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 a=r._canvas,i=Math.max(window.devicePixelRatio||1,1);t||(a.width=a.offsetWidth*i),n||(a.height=a.offsetHeight*i),a.getContext("2d").scale(i,i),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}])}(bg,u.default,Cg,Sg)})),Ag=re(Tg);function Rg(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=[],a=[];e.forEach((function(e){t.push(e.x),n.push(e.y),a.push(new Date(e.time).toString())})),r.clickX_simple.push(t),r.clickY_simple.push(n),r.time_simple.push(a)})),r}var Ig,_g,Dg,Fg,Mg,Lg=h.default.div(Ig||(Ig=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"]))),Ng=h.default.div(_g||(_g=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"]))),Og=h.default.div(Dg||(Dg=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"]))),Pg=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"]))),Bg=function(e){var t=e.onAccept,r=e.verbiage,a=void 0===r?{}:r,i=ye().t,o=kt(),s=o.ref,l=o.width,c=o.height,d=n.useRef(null);return a.headingText=a.headingText||i("Please sign the box below"),a.acceptBtnText=a.acceptBtnText||i("Accept"),a.clearBtnText=a.clearBtnText||i("Clear"),u.default.createElement(Ze,null,u.default.createElement(Pg,null,u.default.createElement(vp,{$top:"5vh"},u.default.createElement(yp,null,a.headingText)),u.default.createElement(Lg,null,u.default.createElement(Ng,{ref:s},u.default.createElement(Ag,{ref:d,canvasProps:{width:l,height:c}})),u.default.createElement(Og,null,u.default.createElement("button",{onClick:function(e){var t;e.preventDefault(),null===(t=d.current)||void 0===t||t.clear()}},a.clearBtnText),u.default.createElement("button",{style:{marginLeft:"auto"},onClick:function(e){if(e.preventDefault(),d.current){var n=Rg(d.current);null==t||t(n,d.current.toDataURL())}}},a.acceptBtnText)))))},Ug=function(e){var t,r,a=e.onComplete,i=e.onFaceNotDetected,o=e.onExit,s=e.colors,l=void 0===s?{}:s,c=e.verbiage,d=void 0===c?{}:c,h=e.debugMode,f=void 0!==h&&h,p=ye().t,y=n.useContext(Mt),b=y.cameraRef,w=y.videoRef,x=kt(),E=x.ref,k=x.width,S=x.height,C=n.useRef(null),T=n.useRef(null),A=n.useRef([]),R=n.useState(null),I=R[0],_=R[1],D=n.useContext(gp).onPredictionMade,F=function(e){var t=n.useRef(null),r=n.useRef([]),a=n.useState(null),i=a[0],o=a[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:i}}(b.current),M=F.isRecording,L=F.startRecording,N=F.stopRecording,O=F.videoUrl,P=n.useState(null),B=P[0],U=P[1],$=n.useState(null),j=$[0],G=$[1],z=n.useState(null),q=z[0],H=z[1];l.guidanceMessageBackgroundColor||(l.guidanceMessageBackgroundColor="#ccc"),l.guidanceMessageTextColor||(l.guidanceMessageTextColor="black"),d.guidanceMessageText||(d.guidanceMessageText=p("Please sign the box below")),d.acceptBtnText||(d.acceptBtnText=p("Accept")),d.clearBtnText||(d.clearBtnText=p("Clear"));var V=n.useRef(null);n.useEffect((function(){setTimeout((function(){if(!M&&!O&&V.current){L();var e=V.current.captureStream(25);T.current=new MediaRecorder(e,{}),T.current.start(),T.current.ondataavailable=function(e){var t;A.current.push(e.data),"recording"===(null===(t=T.current)||void 0===t?void 0:t.state)&&T.current.stop()},T.current.onstop=function(){var e=new Blob(A.current,{type:"video/mp4"});H(e);var t=URL.createObjectURL(e);_(t)}}}),100)}),[M,L,O]),n.useEffect((function(){q&&B&&j&&(null==a||a(B,j,q))}),[a,B,j,q]);var W=n.useRef(0);n.useEffect((function(){var e;if(C.current&&w.current&&V.current&&b.current&&M){var t=[b.current.width,b.current.height],n=t[0],r=t[1],a=window.innerWidth<window.innerHeight;a&&n>r&&(n=(e=[r,n])[0],r=e[1]),V.current.width=n,V.current.height=r;var i=V.current.getContext("2d");if(i)return W.current=requestAnimationFrame((function e(){return g(this,void 0,void 0,(function(){var t;return m(this,(function(o){return C.current&&w.current&&V.current?(t=[n*(a?.02:.15),r*(a?.15:.25),n*(a?.96:.7),r*(a?.7:.5)],i.drawImage(w.current,0,0,n,r),i.beginPath(),i.fillStyle="rgba(255,255,255,0.5)",i.roundRect.apply(i,v(v([],t,!1),[16],!1)),i.fill(),i.drawImage.apply(i,v([C.current.getCanvas()],t,!1)),W.current=requestAnimationFrame(e),[2]):(cancelAnimationFrame(W.current),[2])}))}))})),function(){cancelAnimationFrame(W.current)}}}),[b,M,i,w]);var K=n.useState(0),Y=K[0],X=K[1];return n.useEffect((function(){D((function(e){X((function(t){return 0===e.length?t+1:0}))}))}),[D]),n.useEffect((function(){Y>=2&&(null==i||i())}),[Y,i]),!M&&O?u.default.createElement(u.default.Fragment,null,I&&u.default.createElement("video",{src:I,controls:!0,width:"100%"}),j&&u.default.createElement("img",{src:j,alt:"signature"}),B&&u.default.createElement("textarea",{readOnly:!0,style:{width:"100%",height:500},value:JSON.stringify(B,null,2)})):u.default.createElement(Ze,{className:"flex"},u.default.createElement(Ka,null),d.guidanceMessageText&&u.default.createElement(vp,{$top:"5vh"},u.default.createElement(yp,{$background:l.guidanceMessageBackgroundColor,$textColor:l.guidanceMessageTextColor},d.guidanceMessageText)),u.default.createElement(Lg,null,u.default.createElement(Ng,{ref:E},u.default.createElement(Ag,{ref:C,canvasProps:{width:k,height:S}})),u.default.createElement(Og,null,u.default.createElement("button",{onClick:function(e){var t;e.preventDefault(),null===(t=C.current)||void 0===t||t.clear()}},d.clearBtnText),u.default.createElement("button",{style:{marginLeft:"auto"},onClick:function(e){var t;if(e.preventDefault(),C.current){var n=Rg(C.current);U(n),G(C.current.toDataURL()),N(),null===(t=T.current)||void 0===t||t.stop()}}},d.acceptBtnText))),f&&u.default.createElement(Aa,null,"Video: ",null===(t=b.current)||void 0===t?void 0:t.width,"x",null===(r=b.current)||void 0===r?void 0:r.height),u.default.createElement(Ba,{onClick:o},"×"),u.default.createElement("div",{style:{display:"none"}},u.default.createElement("canvas",{ref:V})))},$g=function(e){return u.default.createElement(_p,{headingText:e.headingText,removeEyeCoveringsText:e.removeEyeCoveringsText,avoidExcessiveBacklightingText:e.avoidExcessiveBacklightingText,continueText:e.continueText,cameraInitializingText:e.cameraInitializingText,modelsWarmingUpText:e.modelsWarmingUpText,instructionImageUrl:e.instructionImageUrl,onDismissed:e.onDismissed})},jg=function(e){var t=e.videoUrl,n=e.headingText,r=e.retryBtnText,a=e.doneBtnText,i=e.onDoneClick,o=e.onRetryClick,s=ye().t;return n||(n=s("Signature KYC Successful")),r||(r=s("Retry")),a||(a=s("Done")),u.default.createElement(rt,null,u.default.createElement(at,null,u.default.createElement("h1",null,n),u.default.createElement(it,null,u.default.createElement(Gg,{src:t,poster:t+"#t=0.1",controls:!0,preload:"metadata",autoPlay:!0})),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"},r)),u.default.createElement("button",{className:"ladda-button","data-style":"expand-right","data-color":"mint",onClick:i,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},a)))))},Gg=h.default.video(Mg||(Mg=y(["\n margin-left: auto;\n margin-right: auto;\n max-width: 100%;\n"],["\n margin-left: auto;\n margin-right: auto;\n max-width: 100%;\n"]))),zg=function(e){var t=e.onComplete,r=e.onRetryClicked,a=e.colors,i=void 0===a?{}:a,o=e.verbiage,s=void 0===o?{}:o,l=e.debugMode,c=void 0!==l&&l,d=n.useContext(qe),h=d.submit,f=d.selfieImage,p=d.signatureVideo,v=d.setSelfieImage,y=d.setSignatureData,b=d.setSignatureVideo,w=d.logSelfieCaptureAttempt,x=n.useState("LOADING"),E=x[0],k=x[1],S=n.useRef(),C=n.useRef(),T=n.useRef();n.useEffect((function(){S.current=new Date}),[]),n.useEffect((function(){"CHECKING_LIVENESS"===E&&(C.current=new Date)}),[E]);var A=n.useCallback((function(){var e,t,n;w({autoCapture:"Y",captureTime:(null!==(e=T.current)&&void 0!==e?e:new Date).getTime()-(null!==(t=C.current)&&void 0!==t?t:new Date).getTime(),operationTime:(new Date).getTime()-(null!==(n=S.current)&&void 0!==n?n:new Date).getTime()}),S.current=new Date}),[w]),R=n.useCallback((function(){k("CHECKING_LIVENESS")}),[]),I=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 k("CAPTURING_SIGNATURE"),A(),f?[3,2]:(t=v,[4,We(e)]);case 1:t.apply(void 0,[n.sent()]),n.label=2;case 2:return[2]}}))}))}),[A,f,v]),_=n.useCallback((function(e,n,r){y(e),b(URL.createObjectURL(r)),k("SUCCESS"),null==t||t()}),[t,y,b]),D=n.useCallback((function(){k("CHECKING_LIVENESS")}),[]),F=n.useState(0),M=F[0],L=F[1],N=n.useCallback((function(){L((function(e){return e+1})),k("LOADING")}),[]);return u.default.createElement(mp,{throttleMs:"CAPTURING_SIGNATURE"===E?250:0},"LOADING"!==E&&function(){var e,t,n;switch(E){case"CHECKING_LIVENESS":return u.default.createElement(Cp,{onSuccess:I,onExit:N,colors:i.faceLiveness,verbiage:s.faceLiveness,debugMode:c});case"CAPTURING_SIGNATURE":return u.default.createElement(Ug,{onComplete:_,onFaceNotDetected:D,onExit:N,colors:i.videoSignatureCapture,verbiage:s.videoSignatureCapture,debugMode:c});case"SUCCESS":return u.default.createElement(jg,{videoUrl:null!=p?p:"",onDoneClick:h,onRetryClick:r,headingText:null===(e=s.success)||void 0===e?void 0:e.headingText,retryBtnText:null===(t=s.success)||void 0===t?void 0:t.retryBtnText,doneBtnText:null===(n=s.success)||void 0===n?void 0:n.doneBtnText});default:return null}}(),u.default.createElement($g,{key:M,onDismissed:R}))},qg=function(e){var t,r,a,i,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,k=void 0!==E&&E,S=n.useContext(qe),C=S.submit,T=S.submissionStatus,A=S.setSignatureData,R=S.setAdditionalDocuments,I=n.useState(0),_=I[0],D=I[1],F=n.useMemo((function(){var e,t,n=v([],s,!0);if(x&&k)throw new Error("captureSignature and captureSignatureVideo cannot be used together");return x&&n.push("SignatureCapture"),k&&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,k,s]),M=F[_],L=_>=F.length;n.useEffect((function(){"SignatureCapture"===M&&"function"==typeof x?x().then((function(e){e||D((function(e){return e+1}))})):"SignatureKYC"===M&&"function"==typeof k&&k().then((function(e){e||D((function(e){return e+1}))}))}),[x,k,M]),n.useEffect((function(){L&&C()}),[L,C]);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(L)switch(T){case je.SUBMITTING:return u.default.createElement(Ze,{className:"flex"},u.default.createElement(Ep,null));case je.SUBMITTED:return u.default.createElement(Hp,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(ma,{documentDetectionModelUrl:null!==(a=null===(r=c.assets)||void 0===r?void 0:r.documentDetectionModelUrl)&&void 0!==a?a:"",focusModelUrl:null!==(o=null===(i=c.assets)||void 0===i?void 0:i.focusModelUrl)&&void 0!==o?o:""},function(){switch(F[_]){case"IdCapture":return u.default.createElement(zp,{key:"IdCaptureCamera"},u.default.createElement(qp,null,u.default.createElement(Za,p({},c,{onSuccess:O}))));case"FaceLiveness":return u.default.createElement(zp,{key:"FaceLivenessCamera",preferFrontFacingCamera:!0,preferContinuityCamera:!1},u.default.createElement(mp,null,u.default.createElement(Mp,p({},h,{onComplete:B}))));case"SignatureCapture":return u.default.createElement(Bg,p({},g,{onAccept:U}));case"SignatureKYC":return u.default.createElement(zp,{key:"SignatureKycCamera",preferContinuityCamera:!1,preferFrontFacingCamera:!0,requestMicrophoneAccess:!0},u.default.createElement(zg,p({},y,{onComplete:j})));case"AdditionalDocumentCapture":return u.default.createElement(Kp,p({},b,{documents:q,onComplete:z}));default:return u.default.createElement(u.default.Fragment,null)}}())},Hg={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","Signature KYC Successful":"Captura de Video Firma exitosa"}}},Vg=function(e){var t=ye().i18n;n.useEffect((function(){"auto"!==e?t.changeLanguage(e):t.changeLanguage()}),[t,e])},Wg=function(e){var t=e.lang,r=e.submissionToken,a=e.submissionEnvironment,i=void 0===a?"prod":a,o=e.submissionUrl,s=e.companyId,l=e.manualReviewRequired,c=e.verifyIdWithExternalDatabases,d=e.personalData,h=e.cardData,f=e.webhooksEnabled,p=e.webhooksClientTraceId,g=e.webhooksStripSpecialCharacters,m=e.idAutoCaptureEnabled,v=void 0===m||m,y=e.idCardAutoCaptureScoreThreshold,b=void 0===y?.8:y,w=e.passportAutoCaptureScoreThreshold,x=void 0===w?.8:w,E=e.idCardFocusScoreThreshold,k=void 0===E?.3:E,S=e.passportFocusScoreThreshold,C=void 0===S?.3:S,T=e.onBeforeSubmit,A=e.onComplete,R=e.onApproved,I=e.onDenied,_=e.assets,D=void 0===_?{}:_,F=e.colors,M=void 0===F?{}:F,L=e.verbiage,N=void 0===L?{}:L,O=e.captureSignature,P=void 0!==O&&O,B=e.captureSignatureVideo,U=void 0!==B&&B,$=e.captureAdditionalDocuments,j=void 0===$?[]:$,G=e.geolocationEnabled,z=void 0===G||G,q=e.geolocationRequired,H=void 0!==q&&q,V=e.debugMode,W=void 0!==V&&V;Vg(void 0===t?"auto":t);var K=n.useMemo((function(){return{autoCaptureEnabled:v,idCardAutoCaptureScoreThreshold:b,passportAutoCaptureScoreThreshold:x,mrzDetectionScoreThreshold:.5,idCardFocusScoreThreshold:k,passportFocusScoreThreshold:C,barcodeScanningEnabled:!1,assets:D,colors:M,verbiage:N,debugMode:W}}),[D,M,W,v,b,k,x,C,N]),Y=n.useMemo((function(){return{verbiage:{headingText:N.signatureCaptureHeadingText,acceptBtnText:N.signatureCaptureAcceptBtnText,clearBtnText:N.signatureCaptureClearBtnText}}}),[N.signatureCaptureAcceptBtnText,N.signatureCaptureClearBtnText,N.signatureCaptureHeadingText]),X=n.useMemo((function(){return{documents:j,verbiage:{headingText:N.additionalDocumentsHeadingText,nextBtnText:N.additionalDocumentsNextBtnText}}}),[j,N.additionalDocumentsHeadingText,N.additionalDocumentsNextBtnText]),J=n.useCallback((function(e){null==A||A(e),"Approved"===e.resultData.verificationResult?null==R||R(e):null==I||I(e)}),[R,A,I]);return u.default.createElement(bt,{action:$e.VALIDATE,environment:i,url:o,token:r,companyId:s,manualReviewRequired:l,verifyIdWithExternalDatabases:c,personalData:d,cardData:h,webhooksEnabled:f,webhooksClientTraceId:p,webhooksStripSpecialCharacters:g,onBeforeSubmit:T,onResponseReceived:J,geolocationEnabled:z,geolocationRequired:H},u.default.createElement(qg,{checks:n.useMemo((function(){return["IdCapture"]}),[]),idCaptureProps:K,signatureCaptureProps:Y,additionalDocumentCaptureProps:X,captureSignature:P,captureSignatureVideo:U}))},Kg=function(e){var t=e.lang,r=e.submissionToken,a=e.submissionEnvironment,i=void 0===a?"prod":a,o=e.submissionUrl,s=e.companyId,l=e.webhooksEnabled,c=e.webhooksClientTraceId,d=e.webhooksStripSpecialCharacters,h=e.timeoutDurationMs,f=void 0===h?15e3:h,p=e.onBeforeSubmit,g=e.onComplete,m=e.onApproved,v=e.onDenied,y=e.onExitAfterFailure,b=e.assets,w=e.colors,x=e.verbiage,E=e.geolocationEnabled,k=void 0===E||E,S=e.geolocationRequired,C=void 0!==S&&S,T=e.debugMode,A=void 0!==T&&T;Vg(void 0===t?"auto":t);var R=n.useMemo((function(){return{timeoutDurationMs:f,onComplete:g,onSuccess:m,onTimeout:v,onExitAfterFailure:y,assets:b,colors:w,verbiage:x,debugMode:A}}),[b,w,A,m,g,v,y,f,x]);return u.default.createElement(bt,{action:$e.NONE,environment:i,url:o,token:r,companyId:s,webhooksEnabled:l,webhooksClientTraceId:c,webhooksStripSpecialCharacters:d,onBeforeSubmit:p,geolocationEnabled:k,geolocationRequired:C},u.default.createElement(qg,{checks:n.useMemo((function(){return["FaceLiveness"]}),[]),idCaptureProps:{},faceLivenessProps:R}))},Yg=function(e){var t=e.lang,r=e.submissionToken,a=e.submissionEnvironment,i=void 0===a?"prod":a,o=e.submissionUrl,s=e.companyId,l=e.manualReviewRequired,c=e.verifyIdWithExternalDatabases,d=e.personalData,h=e.cardData,f=e.webhooksEnabled,p=e.webhooksClientTraceId,g=e.webhooksStripSpecialCharacters,m=e.idAutoCaptureEnabled,v=void 0===m||m,y=e.idCardAutoCaptureScoreThreshold,b=void 0===y?.8:y,w=e.mrzDetectionScoreThreshold,x=void 0===w?.5:w,E=e.passportAutoCaptureScoreThreshold,k=void 0===E?.8:E,S=e.idCardFocusScoreThreshold,C=void 0===S?.3:S,T=e.passportFocusScoreThreshold,A=void 0===T?.3:T,R=e.idCaptureAssets,I=e.idCaptureColors,_=e.idCaptureVerbiage,D=e.faceLivenessTimeoutDurationMs,F=void 0===D?15e3:D,M=e.faceLivenessAssets,L=e.faceLivenessColors,N=e.faceLivenessVerbiage,O=e.onBeforeSubmit,P=e.onComplete,B=e.onApproved,U=e.onDenied,$=e.onExitAfterFailure,j=e.captureSignature,G=void 0!==j&&j,z=e.captureSignatureVideo,q=void 0!==z&&z,H=e.captureAdditionalDocuments,V=void 0===H?[]:H,W=e.geolocationEnabled,K=void 0===W||W,Y=e.geolocationRequired,X=void 0!==Y&&Y,J=e.debugMode,Z=void 0!==J&&J;Vg(void 0===t?"auto":t);var Q=n.useMemo((function(){return{assets:R,colors:I,verbiage:_,autoCaptureEnabled:v,idCardAutoCaptureScoreThreshold:b,passportAutoCaptureScoreThreshold:k,mrzDetectionScoreThreshold:x,idCardFocusScoreThreshold:C,passportFocusScoreThreshold:A,debugMode:Z}}),[Z,v,R,I,_,b,C,x,k,A]),ee=n.useMemo((function(){return{timeoutDurationMs:F,onTimeout:U,onExitAfterFailure:$,assets:M,colors:L,verbiage:N,debugMode:Z}}),[Z,M,L,F,N,U,$]),te=n.useMemo((function(){return{verbiage:{headingText:null==_?void 0:_.signatureCaptureHeadingText,acceptBtnText:null==_?void 0:_.signatureCaptureAcceptBtnText,clearBtnText:null==_?void 0:_.signatureCaptureClearBtnText}}}),[null==_?void 0:_.signatureCaptureAcceptBtnText,null==_?void 0:_.signatureCaptureClearBtnText,null==_?void 0:_.signatureCaptureHeadingText]),ne=n.useMemo((function(){return{documents:V,verbiage:{headingText:null==_?void 0:_.additionalDocumentsHeadingText,nextBtnText:null==_?void 0:_.additionalDocumentsNextBtnText}}}),[V,null==_?void 0:_.additionalDocumentsHeadingText,null==_?void 0:_.additionalDocumentsNextBtnText]),re=n.useCallback((function(e){null==P||P(e),"Approved"===e.resultData.verificationResult?null==B||B(e):null==U||U(e)}),[B,P,U]);return u.default.createElement(bt,{action:$e.VALIDATE,environment:i,url:o,token:r,companyId:s,manualReviewRequired:l,verifyIdWithExternalDatabases:c,personalData:d,cardData:h,webhooksEnabled:f,webhooksClientTraceId:p,webhooksStripSpecialCharacters:g,onBeforeSubmit:O,onResponseReceived:re,geolocationEnabled:K,geolocationRequired:X},u.default.createElement(qg,{checks:n.useMemo((function(){return["IdCapture","FaceLiveness"]}),[]),idCaptureProps:Q,faceLivenessProps:ee,signatureCaptureProps:te,additionalDocumentCaptureProps:ne,captureSignature:G,captureSignatureVideo:q}))},Xg=function(e){var t=e.enrollmentId,r=e.lang,a=e.submissionToken,i=e.submissionEnvironment,o=void 0===i?"prod":i,s=e.submissionUrl,l=e.companyId,c=e.manualReviewRequired,d=e.verifyIdWithExternalDatabases,h=e.personalData,f=e.cardData,p=e.deduplicationEnabled,g=e.deduplicationSynchronous,m=e.webhooksEnabled,v=e.webhooksClientTraceId,y=e.webhooksStripSpecialCharacters,b=e.idAutoCaptureEnabled,w=void 0===b||b,x=e.idCardAutoCaptureScoreThreshold,E=void 0===x?.8:x,k=e.mrzDetectionScoreThreshold,S=void 0===k?.5:k,C=e.passportAutoCaptureScoreThreshold,T=void 0===C?.8:C,A=e.idCardFocusScoreThreshold,R=void 0===A?.3:A,I=e.passportFocusScoreThreshold,_=void 0===I?.3:I,D=e.idCaptureAssets,F=e.idCaptureColors,M=e.idCaptureVerbiage,L=e.faceLivenessTimeoutDurationMs,N=void 0===L?15e3:L,O=e.faceLivenessAssets,P=e.faceLivenessColors,B=e.faceLivenessVerbiage,U=e.onBeforeSubmit,$=e.onComplete,j=e.onEnrolled,G=e.onDenied,z=e.onExitAfterFailure,q=e.captureSignature,H=void 0!==q&&q,V=e.captureSignatureVideo,W=void 0!==V&&V,K=e.captureAdditionalDocuments,Y=void 0===K?[]:K,X=e.geolocationEnabled,J=void 0===X||X,Z=e.geolocationRequired,Q=void 0!==Z&&Z,ee=e.debugMode,te=void 0!==ee&ⅇVg(void 0===r?"auto":r);var ne=n.useMemo((function(){return{assets:D,colors:F,verbiage:M,autoCaptureEnabled:w,idCardAutoCaptureScoreThreshold:E,passportAutoCaptureScoreThreshold:T,mrzDetectionScoreThreshold:S,idCardFocusScoreThreshold:R,passportFocusScoreThreshold:_,debugMode:te}}),[te,w,D,F,M,E,R,S,T,_]),re=n.useMemo((function(){return{onExitAfterFailure:z,timeoutDurationMs:N,assets:O,colors:P,verbiage:B,debugMode:te}}),[te,O,P,N,B,z]),ae=n.useMemo((function(){return{verbiage:{headingText:null==M?void 0:M.signatureCaptureHeadingText,acceptBtnText:null==M?void 0:M.signatureCaptureAcceptBtnText,clearBtnText:null==M?void 0:M.signatureCaptureClearBtnText}}}),[null==M?void 0:M.signatureCaptureAcceptBtnText,null==M?void 0:M.signatureCaptureClearBtnText,null==M?void 0:M.signatureCaptureHeadingText]),ie=n.useMemo((function(){return{documents:Y,verbiage:{headingText:null==M?void 0:M.additionalDocumentsHeadingText,nextBtnText:null==M?void 0:M.additionalDocumentsNextBtnText}}}),[Y,null==M?void 0:M.additionalDocumentsHeadingText,null==M?void 0:M.additionalDocumentsNextBtnText]),oe=n.useCallback((function(e){null==$||$(e),"Customer Onboarded"===e.resultData.verificationResult?null==j||j(e):null==G||G(e)}),[j,$,G]);return u.default.createElement(bt,{action:$e.ENROLL,environment:o,url:s,token:a,companyId:l,enrollmentId:t,manualReviewRequired:c,verifyIdWithExternalDatabases:d,personalData:h,cardData:f,deduplicationEnabled:p,deduplicationSynchronous:g,webhooksEnabled:m,webhooksClientTraceId:v,webhooksStripSpecialCharacters:y,onBeforeSubmit:U,onResponseReceived:oe,geolocationEnabled:J,geolocationRequired:Q},u.default.createElement(qg,{checks:n.useMemo((function(){return["IdCapture","FaceLiveness"]}),[]),idCaptureProps:ne,faceLivenessProps:re,signatureCaptureProps:ae,additionalDocumentCaptureProps:ie,captureSignature:H,captureSignatureVideo:W}))},Jg={frame:null,face:null,imageUrl:null,requestState:"NOT_READY",requestError:null,unverifiedTimes:0},Zg=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,a=r.statusMessage,i=r.errorData,o=n.resultData;if("000"!==r.statusCode)return p(p({},e),{requestState:"ERROR",requestError:new Error("".concat(a,": ").concat(i))});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}},Qg=function(e){var t=e.onCustomerMatched,r=e.onCustomerNotMatched,a=e.onCaptureGuidanceTimeout,i=e.onExit,o=e.captureGuidanceTimeoutDurationMs,s=e.colors,l=void 0===s?{}:s,c=e.verbiage,d=void 0===c?{}:c,h=e.debugMode,f=void 0!==h&&h,p=n.useReducer(Zg,Jg),v=p[0],y=p[1],b=v.frame,w=v.face,x=n.useContext(qe),E=x.submit,k=x.submissionResponse,S=x.selfieImage,C=x.setSelfieImage,T=n.useCallback((function(e,t){y({type:"verificationReady",payload:{frame:e,face:t}})}),[]),A="READY"===v.requestState;return n.useEffect((function(){b&&w&&We(da(b,w)).then((function(e){console.log("setting selfie image",e),C(e)}))}),[w,b,C]),n.useEffect((function(){A&&S&&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]),y({type:"verifying",payload:{imageUrl:S}}),[4,E()];case 1:if(!(e=n.sent()))throw new Error("submission failed!");return y({type:"verificationCompleted",payload:{response:e}}),[3,3];case 2:return t=n.sent(),y({type:"verificationFailed",payload:{error:t}}),[3,3];case 3:return[2]}}))}))}),[A,t,r,S,v.requestState,E]),n.useEffect((function(){k&&("FOUND"===v.requestState?null==t||t(k):"NOT_FOUND"===v.requestState&&(null==r||r(k)))}),[t,r,v.requestState,k]),u.default.createElement(xp,{onSelfieCaptured:T,onTimeout:a,onExit:i,timeoutDurationMs:o,colors:l,verbiage:d,debugMode:f})},em=function(e){var t=e.headingText,n=e.retryBtnText,r=e.doneBtnText,a=e.imageUrl,i=e.onDoneClick,o=e.onRetryClick,s=ye().t;return a=a||"".concat(ua,"/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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:a})),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:i,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},r)))))},tm=function(e){var t=e.headingText,n=e.retryBtnText,r=e.exitBtnText,a=e.imageUrl,i=e.canRetry,o=void 0===i||i,s=e.onRetryClick,l=e.onExitClick,c=ye().t;return a=a||"".concat(ua,"/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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:a})),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)))))},nm=function(e){var t=e.onComplete,r=e.onCustomerMatched,a=e.onCustomerNotMatched,i=e.onExitAfterFailure,o=e.onCaptureGuidanceTimeout,s=e.captureGuidanceTimeoutDurationMs,l=e.assets,c=void 0===l?{}:l,d=e.colors,h=void 0===d?{}:d,f=e.verbiage,p=void 0===f?{}:f,v=e.debugMode,y=void 0!==v&&v,b=n.useContext(qe),w=b.submissionResponse,x=b.selfieImage,E=n.useContext(Mt).releaseCameraAccess,k=n.useState("LOADING"),S=k[0],C=k[1],T=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return C("MATCHED"),E(),setTimeout((function(){null==r||r(e)}),0),[2]}))}))}),[r,E]),A=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return C("NOT_MATCHED"),E(),setTimeout((function(){null==a||a(e)}),0),[2]}))}))}),[a,E]),R=n.useCallback((function(){C("FAILED"),E(),setTimeout((function(){null==o||o()}),0)}),[o,E]),I=n.useState(0),_=I[0],D=I[1],F=n.useCallback((function(){D((function(e){return e+1})),C("LOADING")}),[]);return u.default.createElement(u.default.Fragment,null,"LOADING"!==S&&function(){switch(S){case"CAPTURING":return u.default.createElement(Qg,{onCustomerMatched:T,onCustomerNotMatched:A,onCaptureGuidanceTimeout:R,onExit:F,captureGuidanceTimeoutDurationMs:s,colors:h,verbiage:p,debugMode:y});case"MATCHED":return u.default.createElement(em,{headingText:p.successHeadingText,retryBtnText:p.successRetryBtnText,doneBtnText:p.successDoneBtnText,imageUrl:"data:image/png;base64, ".concat(x),onDoneClick:function(){w&&(null==t||t(w))},onRetryClick:function(){C("CAPTURING")}});case"NOT_MATCHED":return u.default.createElement(tm,{headingText:p.failureHeadingText,retryBtnText:p.failureRetryBtnText,exitBtnText:null==p?void 0:p.failureExitBtnText,imageUrl:c.failureImageUrl,canRetry:!1,onExitClick:i});default:return null}}(),u.default.createElement(_p,{key:_,headingText:p.loadingOverlayHeadingText,removeEyeCoveringsText:p.loadingOverlayRemoveEyeCoveringsText,avoidExcessiveBacklightingText:p.loadingOverlayAvoidExcessiveBacklightingText,continueText:p.loadingOverlayContinueText,cameraInitializingText:p.loadingOverlayCameraInitializingText,modelsWarmingUpText:p.loadingOverlayModelsWarmingUpText,instructionImageUrl:c.instructionImageUrl,onDismissed:function(){C("CAPTURING")}}))},rm=function(e){var t=e.lang,n=e.enrollmentId,r=e.submissionToken,a=e.submissionEnvironment,i=void 0===a?"prod":a,o=e.submissionUrl,s=e.companyId,l=e.webhooksEnabled,c=e.webhooksClientTraceId,d=e.webhooksStripSpecialCharacters,h=e.timeoutDurationMs,f=void 0===h?15e3:h,p=e.assets,g=e.colors,m=e.verbiage,v=e.onBeforeSubmit,y=e.onComplete,b=e.onCustomerMatched,w=e.onCustomerNotMatched,x=e.onExitAfterFailure,E=e.geolocationEnabled,k=void 0===E||E,S=e.geolocationRequired,C=void 0!==S&&S,T=e.debugMode,A=void 0!==T&&T;return Vg(void 0===t?"auto":t),u.default.createElement(bt,{action:$e.VERIFY,environment:i,url:o,token:r,companyId:s,enrollmentId:n,webhooksEnabled:l,webhooksClientTraceId:c,webhooksStripSpecialCharacters:d,onBeforeSubmit:v,geolocationEnabled:k,geolocationRequired:C},u.default.createElement(mp,null,u.default.createElement(zp,{preferFrontFacingCamera:!0},u.default.createElement(nm,{onComplete:y,onCustomerMatched:b,onCustomerNotMatched:w,onExitAfterFailure:x,captureGuidanceTimeoutDurationMs:f,assets:p,colors:g,verbiage:m,debugMode:A}))))},am={frame:null,face:null,imageUrl:null,requestState:"NOT_READY",requestError:null,notFoundTimes:0},im=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,a=r.statusMessage,i=r.errorData,o=n.resultData;if("000"!==r.statusCode)return p(p({},e),{requestState:"ERROR",requestError:new Error("".concat(a,": ").concat(i))});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}},om=function(e){var t=e.onCustomerMatched,r=e.onCustomerNotMatched,a=e.onCaptureGuidanceTimeout,i=e.onExit,o=e.captureGuidanceTimeoutDurationMs,s=e.colors,l=void 0===s?{}:s,c=e.verbiage,d=void 0===c?{}:c,h=e.debugMode,f=void 0!==h&&h,p=n.useReducer(im,am),v=p[0],y=p[1],b=n.useContext(qe),w=b.submit,x=b.submissionResponse,E=b.selfieImage,k=b.setSelfieImage,S=n.useCallback((function(e,t){y({type:"identificationReady",payload:{frame:e,face:t}})}),[]),C=v.frame,T=v.face,A="READY"===v.requestState;return n.useEffect((function(){C&&T&&We(da(C,T)).then((function(e){console.log("setting selfie image",e),k(e)}))}),[T,C,k]),n.useEffect((function(){A&&E&&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]),y({type:"identifying",payload:{imageUrl:E}}),[4,w()];case 1:if(!(e=n.sent()))throw new Error("submission failed!");return y({type:"identificationCompleted",payload:{response:e}}),[3,3];case 2:return t=n.sent(),y({type:"identificationFailed",payload:{error:t}}),[3,3];case 3:return[2]}}))}))}),[A,t,r,E,v.requestState,w]),n.useEffect((function(){x&&("FOUND"===v.requestState?null==t||t(x):"NOT_FOUND"===v.requestState&&(null==r||r(x)))}),[t,r,v.requestState,x]),u.default.createElement(xp,{onSelfieCaptured:S,onTimeout:a,onExit:i,timeoutDurationMs:o,colors:l,verbiage:d,debugMode:f})},sm=function(e){var t=e.headingText,n=e.retryBtnText,r=e.doneBtnText,a=e.imageUrl,i=e.onDoneClick,o=e.onRetryClick,s=ye().t;return a=a||"".concat(ua,"/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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:a})),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:i,style:{marginLeft:15}},u.default.createElement("span",{className:"ladda-label"},r)))))},lm=function(e){var t=e.headingText,n=e.retryBtnText,r=e.exitBtnText,a=e.imageUrl,i=e.canRetry,o=void 0===i||i,s=e.onRetryClick,l=e.onExitClick,c=ye().t;return a=a||"".concat(ua,"/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(at,null,u.default.createElement("h3",{style:{marginBottom:24}},t),u.default.createElement(it,{style:{maxHeight:"calc(100vh - 185px)"}},u.default.createElement("img",{alt:t,src:a})),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)))))},um=function(e){var t=e.onComplete,r=e.onCustomerMatched,a=e.onCustomerNotMatched,i=e.onExitAfterFailure,o=e.onCaptureGuidanceTimeout,s=e.captureGuidanceTimeoutDurationMs,l=e.assets,c=void 0===l?{}:l,d=e.colors,h=void 0===d?{}:d,f=e.verbiage,p=void 0===f?{}:f,v=e.debugMode,y=void 0!==v&&v,b=n.useContext(qe),w=b.submissionResponse,x=b.selfieImage,E=n.useContext(Mt).releaseCameraAccess,k=n.useState("LOADING"),S=k[0],C=k[1],T=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return C("FOUND"),E(),setTimeout((function(){null==r||r(e)}),0),[2]}))}))}),[r,E]),A=n.useCallback((function(e){return g(void 0,void 0,void 0,(function(){return m(this,(function(t){return C("NOT_FOUND"),E(),setTimeout((function(){null==a||a(e)}),0),[2]}))}))}),[a,E]),R=n.useCallback((function(){C("FAILED"),E(),setTimeout((function(){null==o||o()}),0)}),[o,E]),I=n.useState(0),_=I[0],D=I[1],F=n.useCallback((function(){D((function(e){return e+1})),C("LOADING")}),[]);return u.default.createElement(u.default.Fragment,null,"LOADING"!==S&&function(){switch(S){case"CAPTURING":return u.default.createElement(om,{onCustomerMatched:T,onCustomerNotMatched:A,onCaptureGuidanceTimeout:R,onExit:F,captureGuidanceTimeoutDurationMs:s,colors:h,verbiage:p,debugMode:y});case"FOUND":return u.default.createElement(sm,{headingText:p.successHeadingText,retryBtnText:p.successRetryBtnText,doneBtnText:p.successDoneBtnText,imageUrl:"data:image/png;base64, ".concat(x),onDoneClick:function(){w&&(null==t||t(w))},onRetryClick:function(){C("CAPTURING")}});case"NOT_FOUND":case"FAILED":return u.default.createElement(lm,{headingText:p.failureHeadingText,retryBtnText:p.failureRetryBtnText,exitBtnText:null==p?void 0:p.failureExitBtnText,imageUrl:c.failureImageUrl,canRetry:!1,onExitClick:i});default:return null}}(),u.default.createElement(_p,{key:_,headingText:p.loadingOverlayHeadingText,removeEyeCoveringsText:p.loadingOverlayRemoveEyeCoveringsText,avoidExcessiveBacklightingText:p.loadingOverlayAvoidExcessiveBacklightingText,continueText:p.loadingOverlayContinueText,cameraInitializingText:p.loadingOverlayCameraInitializingText,modelsWarmingUpText:p.loadingOverlayModelsWarmingUpText,instructionImageUrl:c.instructionImageUrl,onDismissed:function(){C("CAPTURING")}}))},cm=function(e){var t=e.lang,n=e.submissionToken,r=e.submissionEnvironment,a=void 0===r?"prod":r,i=e.submissionUrl,o=e.companyId,s=e.webhooksEnabled,l=e.webhooksClientTraceId,c=e.webhooksStripSpecialCharacters,d=e.timeoutDurationMs,h=void 0===d?15e3:d,f=e.onBeforeSubmit,p=e.onComplete,g=e.onCustomerMatched,m=e.onCustomerNotMatched,v=e.onCaptureGuidanceTimeout,y=e.onExitAfterFailure,b=e.assets,w=e.colors,x=e.verbiage,E=e.geolocationEnabled,k=e.geolocationRequired,S=void 0!==k&&k,C=e.debugMode,T=void 0!==C&&C;return Vg(void 0===t?"auto":t),u.default.createElement(bt,{action:$e.IDENTIFY,environment:a,url:i,token:n,companyId:o,webhooksEnabled:s,webhooksClientTraceId:l,webhooksStripSpecialCharacters:c,onBeforeSubmit:f,geolocationEnabled:E,geolocationRequired:S},u.default.createElement(zp,{preferFrontFacingCamera:!0},u.default.createElement(mp,null,u.default.createElement(um,{onComplete:p,onCustomerMatched:g,onCustomerNotMatched:m,onExitAfterFailure:y,onCaptureGuidanceTimeout:v,captureGuidanceTimeoutDurationMs:h,assets:b,colors:w,verbiage:x,debugMode:T}))))},dm=function(e){var t=e.documentDetectionModel,n=void 0===t?"".concat(ua,"/models/documentdetection448/model.json"):t,r=e.focusModel,a=void 0===r?"".concat(ua,"/models/focus/model.json"):r,i=e.skipFaceDetectionModel,o=void 0!==i&&i;return g(void 0,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return n?[4,wt(n)]:[3,2];case 1:e.sent(),e.label=2;case 2:return a?[4,Lt(a)]:[3,4];case 3:e.sent(),e.label=4;case 4:return o?[3,6]:[4,lp()];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},hm=function(e){var t=e.enrollmentId,r=e.lang,a=e.submissionToken,i=e.submissionEnvironment,o=void 0===i?"prod":i,s=e.submissionUrl,l=e.companyId,c=e.deduplicationEnabled,d=e.deduplicationSynchronous,h=e.webhooksEnabled,f=e.webhooksClientTraceId,p=e.webhooksStripSpecialCharacters,g=e.timeoutDurationMs,m=void 0===g?15e3:g,v=e.assets,y=e.colors,b=e.verbiage,w=e.onBeforeSubmit,x=e.onComplete,E=e.onEnrolled,k=e.onDenied,S=e.onExitAfterFailure,C=e.captureSignature,T=void 0!==C&&C,A=e.captureSignatureVideo,R=void 0!==A&&A,I=e.captureAdditionalDocuments,_=void 0===I?[]:I,D=e.geolocationEnabled,F=void 0===D||D,M=e.geolocationRequired,L=void 0!==M&&M,N=e.debugMode,O=void 0!==N&&N;Vg(void 0===r?"auto":r);var P=n.useMemo((function(){return{onExitAfterFailure:S,timeoutDurationMs:m,assets:v,colors:y,verbiage:b,debugMode:O}}),[v,y,O,S,m,b]),B=n.useMemo((function(){return{verbiage:{headingText:null==b?void 0:b.signatureCaptureHeadingText,acceptBtnText:null==b?void 0:b.signatureCaptureAcceptBtnText,clearBtnText:null==b?void 0:b.signatureCaptureClearBtnText}}}),[null==b?void 0:b.signatureCaptureAcceptBtnText,null==b?void 0:b.signatureCaptureClearBtnText,null==b?void 0:b.signatureCaptureHeadingText]),U=n.useMemo((function(){return{documents:_,verbiage:{headingText:null==b?void 0:b.additionalDocumentsHeadingText,nextBtnText:null==b?void 0:b.additionalDocumentsNextBtnText}}}),[_,null==b?void 0:b.additionalDocumentsHeadingText,null==b?void 0:b.additionalDocumentsNextBtnText]),$=n.useCallback((function(e){null==x||x(e),"Customer Onboarded"===e.resultData.verificationResult?null==E||E(e):null==k||k(e)}),[E,x,k]);return u.default.createElement(bt,{action:$e.ENROLL,environment:o,url:s,token:a,companyId:l,enrollmentId:t,deduplicationEnabled:c,deduplicationSynchronous:d,webhooksEnabled:h,webhooksClientTraceId:f,webhooksStripSpecialCharacters:p,onBeforeSubmit:w,onResponseReceived:$,geolocationEnabled:F,geolocationRequired:L},u.default.createElement(qg,{checks:n.useMemo((function(){return["FaceLiveness"]}),[]),faceLivenessProps:P,signatureCaptureProps:B,additionalDocumentCaptureProps:U,captureSignature:T,captureSignatureVideo:R}))},fm=function(e){var t=e.submissionToken,r=e.submissionEnvironment,a=e.submissionUrl,i=e.onBeforeSubmit,o=e.onComplete,s=e.colors,l=e.verbiage,c=e.geolocationEnabled,d=e.geolocationRequired,h=e.debugMode,f=n.useState(0),p=f[1];return u.default.createElement(bt,{action:$e.NONE,environment:r,url:a,token:t,onBeforeSubmit:i,onResponseReceived:o,geolocationEnabled:c,geolocationRequired:d},u.default.createElement(zp,{key:f[0],preferContinuityCamera:!1,preferFrontFacingCamera:!0,requestMicrophoneAccess:!0},u.default.createElement(zg,{colors:s,debugMode:h,verbiage:l,onRetryClicked:function(){p((function(e){return e+1}))}})))};function pm(e){return u.default.createElement(rt,null,e.children)}ne.use(Ge).use(ge).init({resources:Hg,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 gm=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(pm,null,e)),l.default.render(e,t)},mm=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(Wg,p({},t)),e,n)},vm=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(Kg,p({},t)),e,n)},ym=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(Yg,p({},t)),e,n)},bm=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(Xg,p({},t)),e,n)},wm=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(hm,p({},t)),e,n)},xm=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(rm,p({},t)),e,n)},Em=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(cm,p({},t)),e,n)},km=function(e,t,n){void 0===n&&(n=!0),gm(u.default.createElement(fm,p({},t)),e,n)};globalThis.IDmissionSDK={renderIdValidation:mm,renderFaceValidation:vm,renderIdAndFaceValidation:ym,renderCustomerIdAndBiometricsEnrollment:bm,renderCustomerBiometricsEnrollment:wm,renderCustomerVerification:xm,renderCustomerIdentification:Em,renderSignatureKYC:km,preloadModels:dm,ready:!0},e.CustomerBiometricsEnrollment=hm,e.CustomerIdAndBiometricsEnrollment=Xg,e.CustomerIdentification=cm,e.CustomerVerification=rm,e.FaceValidation=Kg,e.IdAndFaceValidation=Yg,e.IdValidation=Wg,e.SignatureKYC=fm,e.preloadModels=dm,e.renderCustomerBiometricsEnrollment=wm,e.renderCustomerIdAndBiometricsEnrollment=bm,e.renderCustomerIdentification=Em,e.renderCustomerVerification=xm,e.renderFaceValidation=vm,e.renderIdAndFaceValidation=ym,e.renderIdValidation=mm,e.renderSignatureKYC=km,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=sdk2.umd.production.js.map
|