idmission-web-sdk 1.0.2 → 1.0.3
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/dist/sdk2.cjs.development.js +1 -1
- package/dist/sdk2.cjs.development.js.map +1 -1
- package/dist/sdk2.cjs.production.js +1 -1
- package/dist/sdk2.esm.js +1 -1
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +1 -1
- 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/dist/stories/PlatformDetectionTool.stories.d.ts +7 -0
- package/dist/version.d.ts +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"),require("@sentry/react"),require("styled-components"),require("@tensorflow/tfjs"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","@sentry/react","styled-components","@tensorflow/tfjs","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Sdk2={},e.React,e.Sentry,e.styled,e.tf,e.ReactDOM)}(this,(function(e,t,n,r,o,i){"use strict";function a(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=a(t),c=s(t),u=s(n),d=a(r),h=s(o),f=a(i),p=function(e,t){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},p(e,t)};function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var m=function(){return m=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},m.apply(this,arguments)};function v(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(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?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function b(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function y(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function w(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}const x={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 E{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||x,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 E(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new E(this.logger,e)}}var S=new E;class k{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 C(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));return n.resolve=e,n.reject=t,n}function T(e){return null==e?"":""+e}function A(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function o(){return!e||"string"==typeof e}const i="string"!=typeof t?[].concat(t):t.split(".");for(;i.length>1;){if(o())return{};const t=r(i.shift());!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}return o()?{}:{obj:e,k:r(i.shift())}}function I(e,t,n){const{obj:r,k:o}=A(e,t,Object);r[o]=n}function R(e,t){const{obj:n,k:r}=A(e,t);if(n)return n[r]}function D(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]):D(e[r],t[r],n):e[r]=t[r]);return e}function _(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var F={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function M(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(e=>F[e])):e}const L=[" ",",","?","!",";"];function P(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 o=e;for(let e=0;e<r.length;++e){if(!o)return;if("string"==typeof o[r[e]]&&e+1<r.length)return;if(void 0===o[r[e]]){let i=2,a=r.slice(e,e+i).join(n),s=o[a];for(;void 0===s&&r.length>e+i;)i++,a=r.slice(e,e+i).join(n),s=o[a];if(void 0===s)return;if(null===s)return null;if(t.endsWith(a)){if("string"==typeof s)return s;if(a&&"string"==typeof s[a])return s[a]}const l=r.slice(e+i).join(n);return l?P(s,l,n):void 0}o=o[r[e]]}return o}function B(e){return e&&e.indexOf("_")>0?e.replace("_","-"):e}class O extends k{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 o=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,i=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let a=[e,t];n&&"string"!=typeof n&&(a=a.concat(n)),n&&"string"==typeof n&&(a=a.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(a=e.split("."));const s=R(this.data,a);return s||!i||"string"!=typeof n?s:P(this.data&&this.data[e]&&this.data[e][t],n,o)}addResource(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const i=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator;let a=[e,t];n&&(a=a.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(a=e.split("."),r=t,t=a[1]),this.addNamespaces(t),I(this.data,a,r),o.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,o){let i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),r=n,n=t,t=a[1]),this.addNamespaces(t);let s=R(this.data,a)||{};r?D(s,n,o):s={...s,...n},I(this.data,a,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 N={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,o){return e.forEach((e=>{this.processors[e]&&(t=this.processors[e].process(t,n,r,o))})),t}};const U={};class j extends k{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=S.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 o=t.ns||this.options.defaultNS||[];const i=n&&e.indexOf(n)>-1,a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||"",n=n||"";const r=L.filter((e=>t.indexOf(e)<0&&n.indexOf(e)<0));if(0===r.length)return!0;const o=new RegExp(`(${r.map((e=>"?"===e?"\\?":e)).join("|")})`);let i=!o.test(e);if(!i){const t=e.indexOf(n);t>0&&!o.test(e.substring(0,t))&&(i=!0)}return i}(e,n,r));if(i&&!a){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:o};const i=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(i[0])>-1)&&(o=i.shift()),e=i.join(r)}return"string"==typeof o&&(o=[o]),{key:e,namespaces:o}}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,o=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,{key:i,namespaces:a}=this.extractFromKey(e[e.length-1],t),s=a[a.length-1],l=t.lng||this.language,c=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(c){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 u=this.resolve(e,t);let d=u&&u.res;const h=u&&u.usedKey||i,f=u&&u.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:a}):`key '${i} (${this.language})' returned an object instead of string.`;return r?(u.res=e,u):e}if(o){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}${o}${e}`;n[e]=this.translate(i,{...t,joinArrays:!1,ns:a}),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,a=!1;const c=void 0!==t.count&&"string"!=typeof t.count,h=j.hasDefaultValue(t),f=c?this.pluralResolver.getSuffix(l,t.count,t):"",p=t.ordinal&&c?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)||(a=!0,d=i);const m=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:d,v=h&&g!==d&&this.options.updateMissing;if(a||r||v){if(this.logger.log(v?"updateKey":"missingKey",l,s,i,v?g:d),o){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 o=h&&r!==d?r:m;this.options.missingKeyHandler?this.options.missingKeyHandler(e,s,n,o,v,t):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(e,s,n,o,v,t),this.emit("missingKey",e,s,n,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&c?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,u,n),a&&d===i&&this.options.appendNamespaceToMissingKey&&(d=`${s}:${i}`),(a||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?(u.res=d,u):d}extendTranslation(e,t,n,r,o){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 a="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let s;if(a){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),a){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),a=0;a<e;a++)r[a]=arguments[a];return o&&o[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 a=n.postProcess||this.options.postProcess,s="string"==typeof a?[a]:a;return null!=e&&s&&s.length&&!1!==n.applyPostProcessor&&(e=N.handle(s,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:r,...n}:n,this)),e}resolve(e){let t,n,r,o,i,a=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,a),l=s.key;n=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));const u=void 0!==a.count&&"string"!=typeof a.count,d=u&&!a.ordinal&&0===a.count&&this.pluralResolver.shouldUseIntlApi(),h=void 0!==a.context&&("string"==typeof a.context||"number"==typeof a.context)&&""!==a.context,f=a.lngs?a.lngs:this.languageUtils.toResolveHierarchy(a.lng||this.language,a.fallbackLng);c.forEach((e=>{this.isValidLookup(t)||(i=e,!U[`${f[0]}-${e}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(i)&&(U[`${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;o=n;const i=[l];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(i,l,n,e,a);else{let e;u&&(e=this.pluralResolver.getSuffix(n,a.count,a));const t=`${this.options.pluralSeparator}zero`,r=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(i.push(l+e),a.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}${a.context}`;i.push(n),u&&(i.push(n+e),a.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,a))})))}))})),{res:t,usedKey:n,exactUsedKey:r,usedLng:o,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 G(e){return e.charAt(0).toUpperCase()+e.slice(1)}class ${constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=S.create("languageUtils")}getScriptPartFromCode(e){if(!(e=B(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=B(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]=G(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]=G(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=G(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=[],o=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&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):"string"==typeof e&&o(this.formatLanguageCode(e)),n.forEach((e=>{r.indexOf(e)<0&&o(this.formatLanguageCode(e))})),r}}let z=[{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}],q={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 V=["v1","v2","v3"],W=["v4"],H={zero:0,one:1,two:2,few:3,many:4,other:5};class K{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.languageUtils=e,this.options=t,this.logger=S.create("pluralResolver"),this.options.compatibilityJSON&&!W.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 z.forEach((t=>{t.lngs.forEach((n=>{e[n]={numbers:t.nr,plurals:q[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(B(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 o=()=>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()}`:o():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?o():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}shouldUseIntlApi(){return!V.includes(this.options.compatibilityJSON)}}function Y(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=function(e,t,n){const r=R(e,n);return void 0!==r?r:R(t,n)}(e,t,n);return!i&&o&&"string"==typeof n&&(i=P(e,n,r),void 0===i&&(i=P(t,n,r))),i}class X{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=S.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:M,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?_(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?_(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?_(t.nestingPrefix):t.nestingPrefixEscaped||_("$t("),this.nestingSuffix=t.nestingSuffix?_(t.nestingSuffix):t.nestingSuffixEscaped||_(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){this.regexp=new RegExp(`${this.prefix}(.+?)${this.suffix}`,"g");this.regexpUnescape=new RegExp(`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`,"g");this.nestingRegexp=new RegExp(`${this.nestingPrefix}(.+?)${this.nestingSuffix}`,"g")}interpolate(e,t,n,r){let o,i,a;const s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function l(e){return e.replace(/\$/g,"$$$$")}const c=e=>{if(e.indexOf(this.formatSeparator)<0){const o=Y(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(o,void 0,n,{...r,...t,interpolationkey:e}):o}const o=e.split(this.formatSeparator),i=o.shift().trim(),a=o.join(this.formatSeparator).trim();return this.format(Y(t,s,i,this.options.keySeparator,this.options.ignoreJSONStructure),a,n,{...r,...t,interpolationkey:i})};this.resetRegExp();const u=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(a=0;o=t.regex.exec(e);){const n=o[1].trim();if(i=c(n),void 0===i)if("function"==typeof u){const t=u(e,o,r);i="string"==typeof t?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,n))i="";else{if(d){i=o[0];continue}this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),i=""}else"string"==typeof i||this.useRawValueToEscape||(i=T(i));const s=t.safeValue(i);if(e=e.replace(o[0],s),d?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=o[0].length):t.regex.lastIndex=0,a++,a>=this.maxReplaces)break}})),e}nest(e,t){let n,r,o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function a(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,o);const a=i.match(/'/g),s=i.match(/"/g);(a&&a.length%2==0&&!s||s.length%2!=0)&&(i=i.replace(/'/g,'"'));try{o=JSON.parse(i),t&&(o={...t,...o})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return delete o.defaultValue,e}for(;n=this.nestingRegexp.exec(e);){let s=[];o={...i},o=o.replace&&"string"!=typeof o.replace?o.replace:o,o.applyPostProcessor=!1,delete o.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(a.call(this,n[1].trim(),o),o),r&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=T(r)),r||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),r=""),l&&(r=s.reduce(((e,t)=>this.format(e,t,i.lng,{...i,interpolationkey:n[1].trim()})),r.trim())),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}function J(e){const t={};return function(n,r,o){const i=r+JSON.stringify(o);let a=t[i];return a||(a=e(B(r),o),t[i]=a),a(n)}}class Z{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=S.create("formatter"),this.options=e,this.formats={number:J(((e,t)=>{const n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)})),currency:J(((e,t)=>{const n=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>n.format(e)})),datetime:J(((e,t)=>{const n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)})),relativetime:J(((e,t)=>{const n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||"day")})),list:J(((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()]=J(t)}format(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o=t.split(this.formatSeparator).reduce(((e,t)=>{const{formatName:o,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 o=r[1].substring(0,r[1].length-1);"currency"===t&&o.indexOf(":")<0?n.currency||(n.currency=o.trim()):"relativetime"===t&&o.indexOf(":")<0?n.range||(n.range=o.trim()):o.split(";").forEach((e=>{if(!e)return;const[t,...r]=e.split(":"),o=r.join(":").trim().replace(/^'+|'+$/g,"");n[t.trim()]||(n[t.trim()]=o),"false"===o&&(n[t.trim()]=!1),"true"===o&&(n[t.trim()]=!0),isNaN(o)||(n[t.trim()]=parseInt(o,10))}))}return{formatName:t,formatOptions:n}}(t);if(this.formats[o]){let t=e;try{const a=r&&r.formatParams&&r.formatParams[r.interpolationkey]||{};t=this.formats[o](e,a.locale||a.lng||r.locale||r.lng||n,{...i,...r,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${o}`),e}),e);return o}}class Q extends k{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=S.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 o={},i={},a={},s={};return e.forEach((e=>{let r=!0;t.forEach((t=>{const a=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===i[a]&&(i[a]=!0):(this.state[a]=1,r=!1,void 0===i[a]&&(i[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===s[t]&&(s[t]=!0)))})),r||(a[e]=!0)})),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){const r=e.split("|"),o=r[0],i=r[1];t&&this.emit("failedLoading",o,i,t),n&&this.store.addResourceBundle(o,i,n),this.state[e]=t?-1:2;const a={};this.queue.forEach((n=>{!function(e,t,n,r){const{obj:o,k:i}=A(e,t,Object);o[i]=o[i]||[],r&&(o[i]=o[i].concat(n)),r||o[i].push(n)}(n.loaded,[o],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=>{a[e]||(a[e]={});const t=n.loaded[e];t.length&&t.forEach((t=>{void 0===a[e][t]&&(a[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",a),this.queue=this.queue.filter((e=>!e.done))}read(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=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:o,callback:i});this.readingCalls++;const a=(a,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)}a&&s&&r<this.maxRetries?setTimeout((()=>{this.read.call(this,e,t,n,r+1,2*o,i)}),o):i(a,s)},s=this.backend[n].bind(this.backend);if(2!==s.length)return s(e,t,a);try{const n=s(e,t);n&&"function"==typeof n.then?n.then((e=>a(null,e))).catch(a):a(null,n)}catch(e){a(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 o=this.queueLoad(e,t,n,r);if(!o.toLoad.length)return o.pending.length||r(),null;o.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],o=n[1];this.read(r,o,"read",void 0,void 0,((n,i)=>{n&&this.logger.warn(`${t}loading namespace ${o} for language ${r} failed`,n),!n&&i&&this.logger.log(`${t}loaded namespace ${o} for language ${r}`,i),this.loaded(e,n,i)}))}saveMissing(e,t,n,r,o){let i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=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:o},l=this.backend.create.bind(this.backend);if(l.length<6)try{let o;o=5===l.length?l(e,t,n,r,s):l(e,t,n,r),o&&"function"==typeof o.then?o.then((e=>a(null,e))).catch(a):a(null,o)}catch(e){a(e)}else l(e,t,n,r,a,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}}function ee(){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 te(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 ne(){}class re extends k{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=te(e),this.services={},this.logger=S,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=ee();function o(e){return e?"function"==typeof e?new e:e:null}if(this.options={...r,...this.options,...te(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;S.init(this.modules.logger?o(this.modules.logger):null,this.options),this.modules.formatter?t=this.modules.formatter:"undefined"!=typeof Intl&&(t=Z);const n=new $(this.options);this.store=new O(this.options.resources,this.options);const i=this.services;i.logger=S,i.resourceStore=this.store,i.languageUtils=n,i.pluralResolver=new K(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=o(t),i.formatter.init(i,this.options),this.options.interpolation.format=i.formatter.format.bind(i.formatter)),i.interpolator=new X(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new Q(o(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),o=1;o<n;o++)r[o-1]=arguments[o];e.emit(t,...r)})),this.modules.languageDetector&&(i.languageDetector=o(this.modules.languageDetector),i.languageDetector.init&&i.languageDetector.init(i,this.options.detection,this.options)),this.modules.i18nFormat&&(i.i18nFormat=o(this.modules.i18nFormat),i.i18nFormat.init&&i.i18nFormat.init(this)),this.translator=new j(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];e.emit(t,...r)})),this.modules.external.forEach((e=>{e.init&&e.init(this)}))}if(this.format=this.options.interpolation.format,n||(n=ne),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=C(),a=()=>{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?a():setTimeout(a,0),i}loadResources(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ne;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=C();return e||(e=this.languages),t||(t=this.options.ns),n||(n=ne),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&&N.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=C();this.emit("languageChanging",e);const o=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(e,i)=>{i?(o(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)}))},a=t=>{e||t||!this.services.languageDetector||(t=[]);const n="string"==typeof t?t:this.services.languageUtils.getBestMatchFromCodes(t);n&&(this.language||o(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(a):this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),r}getFixedT(e,t,n){var r=this;const o=function(e,t){let i;if("object"!=typeof t){for(var a=arguments.length,s=new Array(a>2?a-2:0),l=2;l<a;l++)s[l-2]=arguments[l];i=r.options.overloadTranslationOptionHandler([e,t].concat(s))}else i={...t};i.lng=i.lng||o.lng,i.lngs=i.lngs||o.lngs,i.ns=i.ns||o.ns,i.keyPrefix=i.keyPrefix||n||o.keyPrefix;const c=r.options.keySeparator||".";let u;return u=i.keyPrefix&&Array.isArray(e)?e.map((e=>`${i.keyPrefix}${c}${e}`)):i.keyPrefix?`${i.keyPrefix}${c}${e}`:e,r.t(u,i)};return"string"==typeof e?o.lng=e:o.lngs=e,o.ns=t,o.keyPrefix=n,o}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,o=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(o,e)))}loadNamespaces(e,t){const n=C();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=C();"string"==typeof e&&(e=[e]);const r=this.options.preload||[],o=e.filter((e=>r.indexOf(e)<0));return o.length?(this.options.preload=r.concat(o),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 $(ee());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 re(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]:ne;const n=e.forkResourceStore;n&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},o=new re(r);void 0===e.debug&&void 0===e.prefix||(o.logger=o.logger.clone(e));return["store","services","language"].forEach((e=>{o[e]=this[e]})),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},n&&(o.store=new O(this.store.data,r),o.services.resourceStore=o.store),o.translator=new j(o.services,r),o.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];o.emit(e,...n)})),o.init(r,t),o.translator.options=r,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const oe=re.createInstance();oe.createInstance=re.createInstance;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function ie(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 se={};function le(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&se[t[0]]||("string"==typeof t[0]&&(se[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 ce=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout((()=>{e.off("initialized",n)}),0),t()};e.on("initialized",n)}};function ue(e,t,n){e.loadNamespaces(t,ce(e,n))}function de(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,ce(e,r))}const he=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,fe={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},pe=e=>fe[e];let ge,me={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(he,pe)};const ve={type:"3rdParty",init(e){!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};me={...me,...e}}(e.options.react),function(e){ge=e}(e)}},be=t.createContext();class ye{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const we=(e,n)=>{const r=t.useRef();return t.useEffect((()=>{r.current=n?r.current:e}),[e,n]),r.current};function xe(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:r}=n,{i18n:o,defaultNS:i}=t.useContext(be)||{},a=r||o||ge;if(a&&!a.reportNamespaces&&(a.reportNamespaces=new ye),!a){le("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}a.options.react&&void 0!==a.options.react.wait&&le("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const s={...me,...a.options.react,...n},{useSuspense:l,keyPrefix:c}=s;let u=e||i||a.options&&a.options.defaultNS;u="string"==typeof u?[u]:u||["translation"],a.reportNamespaces.addUsedNamespaces&&a.reportNamespaces.addUsedNamespaces(u);const d=(a.isInitialized||a.initializedStoreOnce)&&u.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],o=!!t.options&&t.options.fallbackLng,i=t.languages[t.languages.length-1];if("cimode"===r.toLowerCase())return!0;const a=(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&&!a(t.isLanguageChangingTo,e)||!t.hasResourceBundle(r,e)&&t.services.backendConnector.backend&&(!t.options.resources||t.options.partialBundledLanguages)&&(!a(r,e)||o&&!a(i,e)))}(e,t,n):(le("i18n.languages were undefined or empty",t.languages),!0)}(e,a,s)));function h(){return a.getFixedT(n.lng||null,"fallback"===s.nsMode?u:u[0],c)}const[f,p]=t.useState(h);let g=u.join();n.lng&&(g=`${n.lng}${g}`);const m=we(g),v=t.useRef(!0);t.useEffect((()=>{const{bindI18n:e,bindI18nStore:t}=s;function r(){v.current&&p(h)}return v.current=!0,d||l||(n.lng?de(a,n.lng,u,(()=>{v.current&&p(h)})):ue(a,u,(()=>{v.current&&p(h)}))),d&&m&&m!==g&&v.current&&p(h),e&&a&&a.on(e,r),t&&a&&a.store.on(t,r),()=>{v.current=!1,e&&a&&e.split(" ").forEach((e=>a.off(e,r))),t&&a&&t.split(" ").forEach((e=>a.store.off(e,r)))}}),[a,g]);const b=t.useRef(!0);t.useEffect((()=>{v.current&&!b.current&&p(h),b.current=!1}),[a,c]);const y=[f,a,d];if(y.t=f,y.i18n=a,y.ready=d,d)return y;if(!d&&!l)return y;throw new Promise((e=>{n.lng?de(a,n.lng,u,(()=>e())):ue(a,u,(()=>e()))}))}function Ee(e){return Ee="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},Ee(e)}function Se(e){var t=function(e,t){if("object"!==Ee(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==Ee(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Ee(t)?t:String(t)}function ke(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,Se(r.key),r)}}var Ce=[],Te=Ce.forEach,Ae=Ce.slice;var Ie=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Re=function(e,t,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};n&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+60*n*1e3)),r&&(o.domain=r),document.cookie=function(e,t,n){var r=n||{};r.path=r.path||"/";var o=encodeURIComponent(t),i="".concat(e,"=").concat(o);if(r.maxAge>0){var a=r.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");i+="; Max-Age=".concat(Math.floor(a))}if(r.domain){if(!Ie.test(r.domain))throw new TypeError("option domain is invalid");i+="; Domain=".concat(r.domain)}if(r.path){if(!Ie.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),o)},De=function(e){for(var t="".concat(e,"="),n=document.cookie.split(";"),r=0;r<n.length;r++){for(var o=n[r];" "===o.charAt(0);)o=o.substring(1,o.length);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return null},_e={name:"cookie",lookup:function(e){var t;if(e.lookupCookie&&"undefined"!=typeof document){var n=De(e.lookupCookie);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupCookie&&"undefined"!=typeof document&&Re(t.lookupCookie,e,t.cookieMinutes,t.cookieDomain,t.cookieOptions)}},Fe={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("&"),o=0;o<r.length;o++){var i=r[o].indexOf("=");if(i>0)r[o].substring(0,i)===e.lookupQuerystring&&(t=r[o].substring(i+1))}}return t}},Me=null,Le=function(){if(null!==Me)return Me;try{Me="undefined"!==window&&null!==window.localStorage;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch(e){Me=!1}return Me},Pe={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&Le()){var n=window.localStorage.getItem(e.lookupLocalStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&Le()&&window.localStorage.setItem(t.lookupLocalStorage,e)}},Be=null,Oe=function(){if(null!==Be)return Be;try{Be="undefined"!==window&&null!==window.sessionStorage;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch(e){Be=!1}return Be},Ne={name:"sessionStorage",lookup:function(e){var t;if(e.lookupSessionStorage&&Oe()){var n=window.sessionStorage.getItem(e.lookupSessionStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&Oe()&&window.sessionStorage.setItem(t.lookupSessionStorage,e)}},Ue={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}},je={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}},Ge={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}},$e={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 ze=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 Te.call(Ae.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(_e),this.addDetector(Fe),this.addDetector(Pe),this.addDetector(Ne),this.addDetector(Ue),this.addDetector(je),this.addDetector(Ge),this.addDetector($e)}},{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&&ke(t.prototype,n),r&&ke(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();ze.type="languageDetector";var qe,Ve,We="1.0.2";function He(){return window.platform}!function(e){e.NONE="NONE",e.ENROLL="ENROLL",e.IDENTIFY="IDENTIFY",e.VALIDATE="VALIDATE",e.VERIFY="VERIFY"}(qe||(qe={})),function(e){e.READY="READY",e.SUBMITTING="SUBMITTING",e.SUBMITTED="SUBMITTED",e.FAILED="FAILED"}(Ve||(Ve={}));var Ke={prod:"https://api.idmission.com",demo:"https://apidemo.idmission.com"},Ye=t.createContext({submit:function(){return v(void 0,void 0,void 0,(function(){return b(this,(function(e){return[2,null]}))}))},submissionStatus:Ve.READY,submissionRequest:null,submissionResponse:null,submissionError: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 v(void 0,void 0,void 0,(function(){return b(this,(function(e){throw new Error("checkLiveness is not implemented")}))}))},retryLocationAccess:function(){return null}});function Xe(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 Ke.prod;case"https://demoauth.idmission.com/auth/realms/identity":return Ke.demo}var n=Ke[e];if(!n)throw new Error("unrecognized SubmissionEnvironment ".concat(e));return n}function Je(e){var t={"Content-Type":"application/json",Origin:"*"};return e&&(t.Authorization="Bearer ".concat(e)),t}function Ze(e,t){var n=t.geolocationResult,r={selfie:t.selfieCaptureAttempts,front:t.idFrontCaptureAttempts,back:t.idBackCaptureAttempts,isRealIDCheckRequired:"false",sdkVersion:"WebSDK_".concat(We),Resolution:"".concat(window.innerWidth," x ").concat(window.innerHeight)},o=He();o&&(r.os=o.os.family,r.osVersion=o.os.version,r.browserVersion="".concat(o.name," ").concat(o.version)),n&&(r.GeoLocation=JSON.stringify(n)),e.additionalData.metadata=JSON.stringify(r)}function Qe(e){return v(this,void 0,void 0,(function(){return b(this,(function(t){return[2,e.replace(/^data:image\/(png|jpeg);base64,/,"")]}))}))}function et(e){return e.replace(/^data:.*;base64,/,"")}function tt(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 nt,rt=d.default.div(nt||(nt=w(["\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})),ot=t.forwardRef((function(e,n){var r=e.children,o=e.className,i=e.heightOffset,a=void 0===i?0:i,s=e.style,c=e.onClick,u=t.useState(!1),d=u[0],h=u[1];return t.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)}}),[]),l.default.createElement(rt,{ref:n,style:s,onClick:c,className:o,$heightOffset:a},d&&r)}));ot.displayName="PageContainer";var it,at,st,lt,ct=d.default(ot)(it||(it=w(["\n background: white;\n z-index: 10000;\n"],["\n background: white;\n z-index: 10000;\n"]))),ut=d.default.div(at||(at=w(["\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"]))),dt=d.default.div(st||(st=w(["\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"]))),ht=d.default.div(lt||(lt=w(["\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"]))),ft=function(){return ft=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ft.apply(this,arguments)},pt={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"},gt=function(){function e(e){void 0===e&&(e={}),this.opts=ft(ft({},pt),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"),mt(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 o=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,n=[],r=0,o=e.split(",");r<o.length;r++){var i=o[r].match(t);if(null!==i){var a=+i[2],s=+i[5],l=i[4],c=i[7];0!==a||l||(l=c),0!==s||c||(c=l),l===c&&n.push({prefix:i[1]||"",x:a,y:s,xUnits:l,yUnits:c,end:i[8]})}}return n}(r),i=0;i<t.lines;i++){var a=~~(360/t.lines*i+t.rotate),s=mt(document.createElement("div"),{position:"absolute",top:-t.width/2+"px",width:t.length+t.width+"px",height:t.width+"px",background:vt(t.fadeColor,i),borderRadius:n,transformOrigin:"left",transform:"rotate("+a+"deg) translateX("+t.radius+"px)"}),l=i*t.direction/t.lines/t.speed;l-=1/t.speed;var c=mt(document.createElement("div"),{width:"100%",height:"100%",background:vt(t.color,i),borderRadius:n,boxShadow:bt(o,a),animation:1/t.speed+"s linear "+l+"s infinite "+t.animation});s.appendChild(c),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 mt(e,t){for(var n in t)e.style[n]=t[n];return e}function vt(e,t){return"string"==typeof e?e:e[t%e.length]}function bt(e,t){for(var n=[],r=0,o=e;r<o.length;r++){var i=o[r],a=yt(i.x,i.y,t);n.push(i.prefix+a[0]+i.xUnits+" "+a[1]+i.yUnits+i.end)}return n.join(", ")}function yt(e,t,n){var r=n*Math.PI/180,o=Math.sin(r),i=Math.cos(r);return[Math.round(1e3*(e*i+t*o))/1e3,Math.round(1e3*(-e*o+t*i))/1e3]}function wt(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,o=e.querySelector(".ladda-spinner");o||((o=document.createElement("span")).className="ladda-spinner"),e.appendChild(o);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 o=.2*r;return new gt({color:t||"#fff",lines:n||12,radius:o,length:.6*o,width:o<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(o),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 xt,Et,St,kt=function(e){var n=e.children,r=e.colors,o=void 0===r?{}:r,i=e.disabled,a=e.finished,s=e.onClick,c=e.style,u=t.useRef(null),d=t.useRef(null);return o.backgroundColor||(o.backgroundColor="#16a085"),o.textColor||(o.textColor="white"),o.loadingBackgroundColor||(o.loadingBackgroundColor="gray"),o.loadingTextColor||(o.loadingTextColor="white"),t.useEffect((function(){if(u.current){d.current=wt(u.current),d.current.start();var e=0,t=setInterval((function(){var t;e<.9&&(e+=.1),null===(t=d.current)||void 0===t||t.setProgress(e)}),250);return function(){var e;null===(e=d.current)||void 0===e||e.remove(),clearInterval(t)}}}),[]),t.useEffect((function(){var e;a&&(null===(e=d.current)||void 0===e||e.stop())}),[a]),l.default.createElement(Ct,{className:"ladda-button","data-style":"expand-right",disabled:i,ref:u,onClick:s,$backgroundColor:o.backgroundColor,$textColor:o.textColor,$disabledBackgroundColor:o.loadingBackgroundColor,$disabledTextColor:o.loadingTextColor,style:c},l.default.createElement("span",{className:"ladda-label"},n))},Ct=d.default.button(xt||(xt=w(["\n border-radius: 0;\n margin: 0;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n text-transform: none;\n -webkit-appearance: button;\n\n &:not(:disabled),\n &[type='button']:not(:disabled),\n &[type='reset']:not(:disabled),\n &[type='submit']:not(:disabled) {\n cursor: pointer;\n }\n\n &:focus:not(:focus-visible) {\n outline: 0;\n }\n\n --bs-btn-padding-x: 0.75rem;\n --bs-btn-padding-y: 0.375rem;\n --bs-btn-font-family: ;\n --bs-btn-font-size: 1rem;\n --bs-btn-font-weight: 400;\n --bs-btn-line-height: 1.5;\n --bs-btn-color: var(--bs-body-color);\n --bs-btn-bg: transparent;\n --bs-btn-border-width: var(--bs-border-width);\n --bs-btn-border-color: transparent;\n --bs-btn-border-radius: var(--bs-border-radius);\n --bs-btn-hover-border-color: transparent;\n --bs-btn-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15),\n 0 1px 1px rgba(0, 0, 0, 0.075);\n --bs-btn-disabled-opacity: 0.65;\n --bs-btn-focus-box-shadow: 0 0 0 0.25rem\n rgba(var(--bs-btn-focus-shadow-rgb), 0.5);\n display: inline-block;\n padding: var(--bs-btn-padding-y) var(--bs-btn-padding-x);\n font-family: var(--bs-btn-font-family);\n font-size: var(--bs-btn-font-size);\n font-weight: var(--bs-btn-font-weight);\n line-height: var(--bs-btn-line-height);\n color: var(--bs-btn-color);\n text-align: center;\n text-decoration: none;\n vertical-align: middle;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n border: var(--bs-btn-border-width) solid var(--bs-btn-border-color);\n border-radius: var(--bs-btn-border-radius);\n background-color: var(--bs-btn-bg);\n transition:\n color 0.15s ease-in-out,\n background-color 0.15s ease-in-out,\n border-color 0.15s ease-in-out,\n box-shadow 0.15s ease-in-out;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n &:hover {\n filter: brightness(1.15);\n }\n\n &:focus-visible {\n color: var(--bs-btn-hover-color);\n background-color: var(--bs-btn-hover-bg);\n border-color: var(--bs-btn-hover-border-color);\n outline: 0;\n box-shadow: var(--bs-btn-focus-box-shadow);\n }\n\n &:disabled,\n &.disabled,\n fieldset:disabled & {\n color: var(--bs-btn-disabled-color);\n pointer-events: none;\n background-color: var(--bs-btn-disabled-bg);\n border-color: var(--bs-btn-disabled-border-color);\n opacity: var(--bs-btn-disabled-opacity);\n }\n\n --bs-btn-color: ",";\n --bs-btn-bg: ",";\n --bs-btn-border-color: ",";\n --bs-btn-focus-shadow-rgb: 49, 132, 253;\n --bs-btn-active-color: #fff;\n --bs-btn-active-bg: #0a58ca;\n --bs-btn-active-border-color: #0a53be;\n --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);\n --bs-btn-disabled-color: ",";\n --bs-btn-disabled-bg: ",";\n --bs-btn-disabled-border-color: ",";\n\n --bs-btn-padding-y: 14px;\n --bs-btn-padding-x: 1rem;\n --bs-btn-font-size: 18px;\n --bs-btn-border-radius: 4px;\n"],["\n border-radius: 0;\n margin: 0;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n text-transform: none;\n -webkit-appearance: button;\n\n &:not(:disabled),\n &[type='button']:not(:disabled),\n &[type='reset']:not(:disabled),\n &[type='submit']:not(:disabled) {\n cursor: pointer;\n }\n\n &:focus:not(:focus-visible) {\n outline: 0;\n }\n\n --bs-btn-padding-x: 0.75rem;\n --bs-btn-padding-y: 0.375rem;\n --bs-btn-font-family: ;\n --bs-btn-font-size: 1rem;\n --bs-btn-font-weight: 400;\n --bs-btn-line-height: 1.5;\n --bs-btn-color: var(--bs-body-color);\n --bs-btn-bg: transparent;\n --bs-btn-border-width: var(--bs-border-width);\n --bs-btn-border-color: transparent;\n --bs-btn-border-radius: var(--bs-border-radius);\n --bs-btn-hover-border-color: transparent;\n --bs-btn-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15),\n 0 1px 1px rgba(0, 0, 0, 0.075);\n --bs-btn-disabled-opacity: 0.65;\n --bs-btn-focus-box-shadow: 0 0 0 0.25rem\n rgba(var(--bs-btn-focus-shadow-rgb), 0.5);\n display: inline-block;\n padding: var(--bs-btn-padding-y) var(--bs-btn-padding-x);\n font-family: var(--bs-btn-font-family);\n font-size: var(--bs-btn-font-size);\n font-weight: var(--bs-btn-font-weight);\n line-height: var(--bs-btn-line-height);\n color: var(--bs-btn-color);\n text-align: center;\n text-decoration: none;\n vertical-align: middle;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n border: var(--bs-btn-border-width) solid var(--bs-btn-border-color);\n border-radius: var(--bs-btn-border-radius);\n background-color: var(--bs-btn-bg);\n transition:\n color 0.15s ease-in-out,\n background-color 0.15s ease-in-out,\n border-color 0.15s ease-in-out,\n box-shadow 0.15s ease-in-out;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n &:hover {\n filter: brightness(1.15);\n }\n\n &:focus-visible {\n color: var(--bs-btn-hover-color);\n background-color: var(--bs-btn-hover-bg);\n border-color: var(--bs-btn-hover-border-color);\n outline: 0;\n box-shadow: var(--bs-btn-focus-box-shadow);\n }\n\n &:disabled,\n &.disabled,\n fieldset:disabled & {\n color: var(--bs-btn-disabled-color);\n pointer-events: none;\n background-color: var(--bs-btn-disabled-bg);\n border-color: var(--bs-btn-disabled-border-color);\n opacity: var(--bs-btn-disabled-opacity);\n }\n\n --bs-btn-color: ",";\n --bs-btn-bg: ",";\n --bs-btn-border-color: ",";\n --bs-btn-focus-shadow-rgb: 49, 132, 253;\n --bs-btn-active-color: #fff;\n --bs-btn-active-bg: #0a58ca;\n --bs-btn-active-border-color: #0a53be;\n --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);\n --bs-btn-disabled-color: ",";\n --bs-btn-disabled-bg: ",";\n --bs-btn-disabled-border-color: ",";\n\n --bs-btn-padding-y: 14px;\n --bs-btn-padding-x: 1rem;\n --bs-btn-font-size: 18px;\n --bs-btn-border-radius: 4px;\n"])),(function(e){var t=e.$textColor;return null!=t?t:"#fff"}),(function(e){var t=e.$backgroundColor;return null!=t?t:"#0d6efd"}),(function(e){var t=e.$backgroundColor;return null!=t?t:"#0d6efd"}),(function(e){var t=e.$disabledTextColor;return null!=t?t:"#fff"}),(function(e){var t=e.$disabledBackgroundColor;return null!=t?t:"#0d6efd"}),(function(e){var t=e.$disabledBackgroundColor;return null!=t?t:"#0d6efd"})),Tt=function(e){var n=e.accessBlockedImageUrl,r=xe().t,o=t.useContext(Ye).retryLocationAccess;return l.default.createElement(ct,null,l.default.createElement("div",{style:{display:"flex",height:"100%"}},l.default.createElement(ut,{style:{maxWidth:500,height:"auto",margin:"auto"}},l.default.createElement(dt,{style:{flexGrow:0}},l.default.createElement("img",{src:n,alt:""})),l.default.createElement("h3",null,r("Your location access is disabled")),l.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.")),l.default.createElement(kt,{onClick:o,style:{width:200,marginLeft:"auto",marginRight:"auto"},finished:!0},r("Retry")))))},At=function(e){function t(t){var n=e.call(this,t.statusMessage)||this;return n.status=t,n}return g(t,e),t}(Error),It=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return g(t,e),t}(Error),Rt=function(e){var t=e.error;return l.default.createElement(ct,null,l.default.createElement(ut,{style:{justifyContent:"center"}},t instanceof It?l.default.createElement(_t,{error:t,onRetry:e.onRetry}):l.default.createElement(Dt,{error:t})))},Dt=function(e){var t=e.error,n=(0,xe().t)("We're sorry, an unexpected error has occurred.");return l.default.createElement(l.default.Fragment,null,l.default.createElement("h3",{style:{marginBottom:8}},n),t.status.statusCode&&l.default.createElement("p",{style:{marginBottom:0}},l.default.createElement("code",null,"Status: ",t.status.statusCode)),l.default.createElement("p",{style:{marginBottom:0}},l.default.createElement("code",null,t.message)),t.status.errorData&&l.default.createElement("p",{style:{marginBottom:0}},l.default.createElement("code",null,t.status.errorData)))},_t=function(e){var t=e.onRetry,n=xe().t,r=n("Network unreachable"),o=n("We're having trouble reaching our services, please check your connection and try again."),i=n("Retry");return l.default.createElement(l.default.Fragment,null,l.default.createElement("h3",{style:{marginBottom:8}},r),l.default.createElement("p",{style:{marginBottom:0}},o),t&&l.default.createElement("div",{style:{marginTop:32}},l.default.createElement(kt,{colors:{backgroundColor:"#ea8557"},finished:!0,onClick:t},i)))},Ft=function(e){var n=e.action,r=e.children,o=e.url,i=e.environment,a=void 0===i?"prod":i,s=e.token,c=e.companyId,u=e.enrollmentId,d=e.personalData,h=e.cardData,f=e.manualReviewRequired,p=void 0!==f&&f,g=e.verifyIdWithExternalDatabases,w=void 0!==g&&g,x=e.deduplicationEnabled,E=void 0!==x&&x,S=e.deduplicationSynchronous,k=void 0!==S&&S,C=e.geolocationEnabled,T=void 0===C||C,A=e.geolocationRequired,I=void 0!==A&&A,R=e.webhooksEnabled,D=void 0!==R&&R,_=e.webhooksClientTraceId,F=e.webhooksStripSpecialCharacters,M=void 0===F||F,L=e.onBeforeSubmit,P=e.onResponseReceived,B=e.onRequestFailure,O=t.useState(Ve.READY),N=O[0],U=O[1],j=t.useState(null),G=j[0],$=j[1],z=t.useState(null),q=z[0],V=z[1],W=t.useState(null),H=W[0],K=W[1],Y=t.useState(null),X=Y[0],J=Y[1],Z=t.useState(null),Q=Z[0],ee=Z[1],te=t.useState(null),ne=te[0],re=te[1],oe=t.useState(null),ie=oe[0],ae=oe[1],se=t.useState(null),le=se[0],ce=se[1],ue=t.useState(null),de=ue[0],he=ue[1],fe=t.useState(null),pe=fe[0],ge=fe[1],me=t.useState(null),ve=me[0],be=me[1],ye=t.useState(null),we=ye[0],xe=ye[1],Ee=t.useState(0),Se=Ee[0],ke=Ee[1],Ce=t.useState(!1),Te=Ce[0],Ae=Ce[1],Ie=t.useState([]),Re=Ie[0],De=Ie[1],_e=t.useState([]),Fe=_e[0],Me=_e[1],Le=t.useState([]),Pe=Le[0],Be=Le[1],Oe=t.useCallback((function(e){De((function(t){return y(y([],t,!0),[e],!1)}))}),[]),Ne=t.useCallback((function(e){Me((function(t){return y(y([],t,!0),[e],!1)}))}),[]),Ue=t.useCallback((function(e){Be((function(t){return y(y([],t,!0),[e],!1)}))}),[]),je=t.useCallback((function(){return v(void 0,void 0,void 0,(function(){var e,t,r,i,l,f,g,v,y,x,S,C;return b(this,(function(b){switch(b.label){case 0:if(n===qe.NONE)return e={status:{statusCode:"000"},resultData:{}},U(Ve.SUBMITTED),V(e),[2,e];U(Ve.SUBMITTING),b.label=1;case 1:return b.trys.push([1,8,,9]),t={securityData:{userName:"",password:"",merchantId:0},customerData:{idData:{idType:"NSP",idCountry:"NSP",idState:""}},additionalData:{uniqueRequestId:(new Date).getTime().toString(),manualReviewRequired:p?"Y":"N",bypassAgeValidation:"N",deDuplicationRequired:E?"Y":"N",bypassNameMatching:"Y",postDataAPIRequired:D?"Y":"N",sendInputImagesInPost:"N",sendProcessedImagesInPost:"N",needImmediateResponse:"N",deduplicationSynchronous:k?"Y":"N",verifyDataWithHost:w?"Y":"N",idBackImageRequired:"N",stripSpecialCharacters:M?"Y":"N",idImageResolutionCheck:"Y"}},Q&&(t.customerData.idData.idImageFront=Q),ne&&(t.customerData.idData.idImageBack=ne),ie&&(t.customerData.idData.idImageFront=ie),le&&(n===qe.IDENTIFY?t.biometricData={selfie:le}:t.customerData.biometricData={selfie:le}),c&&(t.employee={companyId:c}),d&&(t.customerData.personalData=d),h&&(t.customerData.cardData=h),u&&((C=t.customerData).personalData||(C.personalData={}),t.customerData.personalData.uniqueNumber=u),_&&(t.additionalData.clientTraceId=_),de&&(t.customerData.signatureData={signatureImage:JSON.stringify(de)}),ve&&(t.customerData.additionalDocuments=ve.map((function(e){return m(m({},e),{additionalDocument:JSON.stringify(m(m({},e.additionalDocument),{uniqueId:t.additionalData.uniqueRequestId}))})}))),Ze(t,{selfieCaptureAttempts:Pe,idFrontCaptureAttempts:Re,idBackCaptureAttempts:Fe,geolocationResult:we}),L?[4,L(t)]:[3,3];case 2:(r=b.sent())&&(t=r),b.label=3;case 3:return i=o||Xe(a,s),l=function(e,t,n,r){var o=r?"v4":"v3";switch(e){case qe.ENROLL:return"/".concat(o,t?"/customer/enroll":"/customer/enroll-biometrics");case qe.IDENTIFY:return"/".concat(o,"/customer/identify");case qe.VALIDATE:return"/".concat(o,n?"/customer/validate-id-match-face":"/customer/validate-id");case qe.VERIFY:return"/".concat(o,"/customer/verify");default:throw new Error("unrecognized SubmissionAction ".concat(e))}}(n,!!(Q||ne||ie),!!le,!!s),[4,fetch(i+l,{method:"POST",headers:Je(s),body:JSON.stringify(t)}).catch((function(e){throw new It(e.message)}))];case 4:return(f=b.sent())&&f.ok?[3,6]:[4,null==f?void 0:f.text()];case 5:if(!(g=b.sent())||"Load failed"===g)throw new It(g);throw new At({statusCode:null!==(S=null==f?void 0:f.statusText)&&void 0!==S?S:"???",statusMessage:g});case 6:return[4,f.json()];case 7:if("000"!==(v=b.sent()).status.statusCode)throw new At(v.status);return $(t),V(v),U(Ve.SUBMITTED),null==P||P(v),[2,v];case 8:throw y=b.sent(),x=y,U(Ve.FAILED),K(y instanceof At||y instanceof It?y:new At({statusCode:"",statusMessage:x.message})),J((function(){return["VERIFY","IDENTIFY"].includes(n)?function(){return null}:je})),null==B||B(x),x;case 9:return[2]}}))}))}),[n,ve,h,c,E,k,u,a,we,Fe,ne,Re,Q,p,L,B,P,ie,d,Pe,le,de,s,o,w,_,D,M]),Ge=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){var t,n,r,i,l,c,u,d,h,f,p;return b(this,(function(g){switch(g.label){case 0:return g.trys.push([0,6,,7]),h={securityData:{userName:"",password:"",merchantId:0}},f={},p={},[4,Qe(e)];case 1:return h.customerData=(f.biometricData=(p.selfie=g.sent(),p),f),h.additionalData={uniqueRequestId:(new Date).getTime().toString(),stripSpecialCharacters:"Y",estimateAge:"N",predictGender:"N"},Ze(t=h,{selfieCaptureAttempts:Pe,idFrontCaptureAttempts:Re,idBackCaptureAttempts:Fe,geolocationResult:we}),n=o||Xe(a,s),r="/".concat(!!s?"v4":"v3","/customer/live-check"),[4,fetch(n+r,{method:"POST",headers:Je(s),body:JSON.stringify(t)}).catch((function(e){throw new It(e.message)}))];case 2:return(i=g.sent()).ok?[3,4]:[4,i.text()];case 3:if(!(l=g.sent())||"Load failed"===l)throw new It(l);throw new At({statusCode:i.statusText,statusMessage:l});case 4:return[4,i.json()];case 5:if("000"!==(c=g.sent()).status.statusCode)throw new At(c.status);return V(c),[2,c];case 6:throw u=g.sent(),d=u,U(Ve.FAILED),K(u instanceof At||u instanceof It?u:new At({statusCode:"",statusMessage:d.message})),J((function(){return function(){return null}})),null==B||B(d),d;case 7:return[2]}}))}))}),[a,we,Fe,Re,B,Pe,s,o]),$e=t.useCallback((function(){ke((function(e){return e+1}))}),[]);t.useEffect((function(){T&&(console.log("making geolocation attempt",Se),navigator.geolocation.getCurrentPosition((function(e){xe(e),Ae(!1)}),(function(e){if(1!==e.code)throw new Error(e.message);Ae(!0)})))}),[Se,T,I]);var ze=t.useCallback((function(){X&&(K(null),U(Ve.READY),X())}),[X]);return l.default.createElement(Ye.Provider,{value:{submit:je,submissionStatus:N,submissionRequest:G,submissionResponse:q,submissionError:H,submissionEnvironment:a,idFrontImage:Q,idBackImage:ne,passportImage:ie,selfieImage:le,signatureData:de,signatureVideo:pe,additionalDocuments:ve,setIdFrontImage:ee,setIdBackImage:re,setPassportImage:ae,setSelfieImage:ce,setSignatureData:he,setSignatureVideo:ge,setAdditionalDocuments:be,logIdFrontCaptureAttempt:Oe,logIdBackCaptureAttempt:Ne,logSelfieCaptureAttempt:Ue,checkLiveness:Ge,retryLocationAccess:$e}},I&&Te?l.default.createElement(Tt,null):r,H&&l.default.createElement(Rt,{error:H,onRetry:ze}))};function Mt(e){return v(this,void 0,void 0,(function(){var t,n,r,o,i,a;return b(this,(function(s){switch(s.label){case 0:return St?[2,St]:[4,h.loadGraphModel(e)];case 1:return St=s.sent(),[4,h.ready()];case 2:return s.sent(),t=h.zeros([448,448,3]),n=h.cast(t,"int32"),r=h.tensor4d(Array.from(n.dataSync()),[1,448,448,3]),o=h.cast(r,"int32"),a=(i=h).dispose,[4,St.executeAsync(o)];case 3:return a.apply(i,[s.sent()]),n.dispose(),o.dispose(),r.dispose(),h.dispose(t),[2,St]}}))}))}!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"}(Et||(Et={}));var Lt={1:"Document",2:"MRZ",3:"PDF417",4:"Primary face",5:"Secondary face",6:"Glare",7:"Punch Hole",8:"Passport Page"};function Pt(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 Bt(e){void 0===e&&(e={});var n=e.onResize,r=t.useRef(void 0);r.current=n;var o=e.round||Math.round,i=t.useRef(),a=t.useState({width:void 0,height:void 0}),s=a[0],l=a[1],c=t.useRef(!1);t.useEffect((function(){return c.current=!1,function(){c.current=!0}}),[]);var u=t.useRef({width:void 0,height:void 0}),d=function(e,n){var r=t.useRef(null),o=t.useRef(null);o.current=n;var i=t.useRef(null);t.useEffect((function(){a()}));var a=t.useCallback((function(){var t=o.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 t.useEffect((function(){return function(){r.current&&r.current.cleanup&&(r.current.cleanup(),r.current=null)}}),[]),t.useCallback((function(e){i.current=e,a()}),[a])}(t.useCallback((function(t){return i.current&&i.current.box===e.box&&i.current.round===o||(i.current={box:e.box,round:o,instance:new ResizeObserver((function(t){var n=t[0],i="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",a=Pt(n,i,"inlineSize"),s=Pt(n,i,"blockSize"),d=a?o(a):void 0,h=s?o(s):void 0;if(u.current.width!==d||u.current.height!==h){var f={width:d,height:h};u.current.width=d,u.current.height=h,r.current?r.current(f):c.current||l(f)}}))}),i.current.instance.observe(t,{box:e.box}),function(){i.current&&i.current.instance.unobserve(t)}}),[e.box,o]),e.ref);return t.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 Ot=t.createContext({orientation:"landscape",wrapperWidth:1,wrapperHeight:1,wrapperAspectRatio:0,imageAspectRatio:0,wrapperRef:null,setDimensions:function(){return null},onImageLoaded:function(){return null}});let Nt;function Ut(e){if(void 0!==Nt)return Nt;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 jt=function(e){var n=e.width,r=void 0===n?0:n,o=e.height,i=void 0===o?0:o,a=e.padding,s=void 0===a?Ut()?0:50:a,c=e.borderWidth,u=void 0===c?4:c,d=e.borderColor,h=void 0===d?"white":d,f=e.isMirrored,p=void 0!==f&&f,g=e.instruction,v=void 0===g?"":g,b=e.portraitGuidesImageUrl,y=e.landscapeGuidesImageUrl,w=e.onClick,x=t.useContext(Ot),E=x.orientation,S=x.wrapperRef,k=x.wrapperWidth,C=x.wrapperHeight,T=x.imageAspectRatio,A=x.wrapperAspectRatio,I=x.onImageLoaded,R=x.setDimensions;0==r&&(r=k),0==i&&(i=C),t.useEffect((function(){R({width:r,height:i})}),[i,R,r]);var D={height:C-2*s-2*u};return T>=A&&(D={width:k-2*s-2*u}),l.default.createElement(ot,{ref:S,onClick:w,style:{zIndex:1e3}},l.default.createElement("div",{style:{display:"flex",flexFlow:"column nowrap",height:"100%"}},l.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&&l.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12}},v)),l.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*u,"px)")}},l.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:s,flexGrow:1}}),l.default.createElement("div",{style:{transform:p?"scaleX(-1)":"",border:"".concat(u,"px solid ").concat(h),maxWidth:"calc(100% - ".concat(2*s,"px - ").concat(2*u,"px)"),maxHeight:i-2*s-2*u}},l.default.createElement("img",{src:"portrait"===E?b:y,alt:"",onLoad:I,style:m({},D)})),l.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:s,flexGrow:1}})),l.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&&l.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12,opacity:0}},v))))};function Gt(e){return v(this,void 0,void 0,(function(){var t;return b(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 $t(e,t){return void 0===t&&(t=!1),v(this,void 0,void 0,(function(){var n,r,o,i,a,s,l,c,u;return b(this,(function(d){switch(d.label){case 0:return[4,new Promise((function(a){if(o=e.naturalWidth,i=e.naturalHeight,n=document.createElement("canvas"),!(r=n.getContext("2d")))return[];if(t){console.log("rotating!!"),n.width=i,n.height=o,r.setTransform(0,1,-1,0,n.width,0),r.drawImage(e,0,0,o,i);var s=new Image;s.width=n.width,s.height=n.height,s.onload=function(){a(s)},n.toBlob((function(e){e&&(s.src=URL.createObjectURL(e))}))}else r.drawImage(e,0,0,n.width,n.height),a(e)}))];case 1:return a=d.sent(),s=new ZXing.BitmapLuminanceSource(r,a),l=new ZXing.Common.HybridBinarizer(s),c=new ZXing.BinaryBitmap(l),u=ZXing.PDF417.PDF417Reader.decode(c,null,!1),r.clearRect(0,0,n.width,n.height),n.remove(),[2,u]}}))}))}function zt(){return"BarcodeDetector"in window}function qt(e,t){var n=this;return new Promise((function(r){var o=new Image;o.onload=function(){return v(n,void 0,void 0,(function(){var e,n,i,a;return b(this,(function(s){switch(s.label){case 0:return zt()?[4,Gt(o)]:[3,2];case 1:return n=s.sent(),console.log("native result",n,"".concat(o.width,"x").concat(o.height)),r(n.length>0?m(m({},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!==(a=null==t?void 0:t[3])&&void 0!==a?a:0),[4,$t(o,e)];case 3:n=s.sent(),console.log("zxing result",n),r(n.length>0?m(m({},n[0]),{Source:"zxing"}):null),s.label=4;case 4:return[2]}}))}))},o.src=URL.createObjectURL(e)}))}function Vt(){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 Wt,Ht=["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("")})),Kt=["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("")})),Yt=["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("")})),Xt=function(e,t){var n=e instanceof MediaDeviceInfo?Jt(e):e;return("string"==typeof t?[t]:t).some((function(e){return n.includes(e)}))},Jt=function(e){return e.label.toLocaleLowerCase().split(" ").join("")};function Zt(){Wt&&(console.log("releasing camera access..."),Wt.release(),Wt=void 0)}var Qt,en=function(e){var n=void 0===e?{preferFrontFacingCamera:!1,preferContinuityCamera:!0,requestMicrophoneAccess:!1}:e,r=n.preferFrontFacingCamera,o=void 0!==r&&r,i=n.preferContinuityCamera,a=void 0===i||i,s=n.requestMicrophoneAccess,l=void 0!==s&&s,c=t.useRef(null),u=t.useRef(null),d=t.useState(null),h=d[0],f=d[1],p=t.useState(!1),g=p[0],m=p[1],w=t.useState(null),x=w[0],E=w[1],S=t.useState(!1),k=S[0],C=S[1],T=t.useState(a),A=T[0],I=T[1],R=t.useState(!1),D=R[0],_=R[1],F=t.useState(!1),M=F[0],L=F[1];t.useEffect((function(){console.log("iphone continuity camera allowed changed",A),Zt(),u.current=null,m(!1)}),[A]);var P=t.useCallback((function(){L(!1)}),[]);t.useEffect((function(){M||function(e){return v(this,void 0,void 0,(function(){var t,n;return b(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=He();if(!(D||n&&"OS X"!==n.os.family)){var r=e.find((function(e){return Xt(e,"iphone")}));C(!!r),r&&A&&(t=r)}o&&(t=e.find((function(e){return Xt(e,Ht)}))),Vt()?t||(t=e.find((function(e){return Xt(e,Yt)}))):t||(t=e.find((function(e){return Xt(e,Kt)&&!Xt(e,Yt)}))),t||(t=e.find((function(e){return Xt(e,Kt)}))),!o&&"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,D,o]),t.useEffect((function(){var e;if(h){var t=function(){Zt(),u.current=null,m(!1)};return(null===(e=navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia)?(v(void 0,void 0,void 0,(function(){var e,t,n;return b(this,(function(r){switch(r.label){case 0:e=null,r.label=1;case 1:return r.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=r.sent(),[3,4];case 3:return"NotAllowedError"===r.sent().name?(A?(C(!1),_(!0)):L(!0),[2]):[3,4];case 4:if(e)return[3,8];r.label=5;case 5:return r.trys.push([5,7,,8]),[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 6:return e=r.sent(),console.log("opened stream with no width and height constraints"),[3,8];case 7:return r.sent(),console.log("cannot open stream at all"),[3,8];case 8:if(!e)throw new Error("failed to open camera");return t=function(){k&&A?(console.log("someone unplugged the continuity camera"),Zt(),u.current=null,C(!1),_(!0),E(null),f(null)):(console.log("someone unplugged the webcam"),Zt(),u.current=null,m(!1),L(!0),E(null))},null===(n=c.current)||void 0===n||n.addEventListener("ended",t),e.getVideoTracks().forEach((function(e){e.onended=t})),u.current=function(e,t,n){Zt(),console.log("obtaining camera access...");var r=e.getVideoTracks()[0].getSettings(),o=r.width,i=r.height,a=t.toLocaleLowerCase().split(" ").join(""),s=Xt(a,y(y(y([],Kt,!0),Yt,!0),["iphone"],!1));return o||(o=0),i||(i=0),Wt={label:t,stream:e,width:o,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),Wt}(e,h.label,c.current),[2]}}))})),t):t}}),[A,k,l,h]),t.useEffect((function(){E(null),g&&v(void 0,void 0,void 0,(function(){var e,t,n,r;return b(this,(function(o){return(e=(null!==(r=null===(n=null===(t=u.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]}))}))}),[g]);var B=t.useCallback((function(){return v(void 0,void 0,void 0,(function(){return b(this,(function(e){switch(e.label){case 0:return x?[4,x.grabFrame()]:[2,null];case 1:return[2,e.sent()]}}))}))}),[x]),O=t.useCallback((function(){return v(void 0,void 0,void 0,(function(){var e,t,n,r,o;return b(this,(function(i){switch(i.label){case 0:return e=document.createElement("canvas"),(t=e.getContext("2d"))&&u.current&&c.current?(e.width=null===(r=c.current)||void 0===r?void 0:r.videoWidth,e.height=null===(o=c.current)||void 0===o?void 0:o.videoHeight,t.drawImage(c.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:c,videoDevice:h,videoLoaded:g,setVideoLoaded:m,cameraRef:u,cameraAccessDenied:M,retryCameraAccess:P,releaseCameraAccess:Zt,iphoneContinuityCameraAvailable:k,iphoneContinuityCameraAllowed:A,setIphoneContinuityCameraAllowed:I,captureDevice:x,grabFrame:B,takePhoto:O}},tn=t.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}}),nn=function(e){var n=e.children,r=e.preferFrontFacingCamera,o=e.preferContinuityCamera,i=e.requestMicrophoneAccess,a=en({preferFrontFacingCamera:void 0!==r&&r,preferContinuityCamera:void 0===o||o,requestMicrophoneAccess:void 0!==i&&i}),s=a.videoRef,c=a.videoLoaded,u=a.setVideoLoaded,d=a.cameraRef,h=a.cameraAccessDenied,f=a.retryCameraAccess,p=a.releaseCameraAccess,g=a.iphoneContinuityCameraAvailable,m=a.iphoneContinuityCameraAllowed,v=a.setIphoneContinuityCameraAllowed,b=a.grabFrame,y=a.takePhoto,w=a.captureDevice,x=t.useState(!1),E=x[0],S=x[1];return t.useEffect((function(){S(!1),w&&S(!0)}),[w]),t.useEffect((function(){return function(){p()}}),[p]),l.default.createElement(tn.Provider,{value:{videoRef:s,videoLoaded:c,setVideoLoaded:u,cameraRef:d,cameraReady:E,cameraAccessDenied:h,releaseCameraAccess:p,retryCameraAccess:f,iphoneContinuityCameraAvailable:g,iphoneContinuityCameraAllowed:m,setIphoneContinuityCameraAllowed:v,grabFrame:b,takePhoto:y}},n)};function rn(e){return v(this,void 0,void 0,(function(){var t,n,r,o,i,a,s,l,c;return b(this,(function(u){switch(u.label){case 0:return Qt?[2,Qt]:[4,h.loadLayersModel(e)];case 1:return Qt=u.sent(),[4,h.ready()];case 2:return u.sent(),t=h.zeros([448,448,3]),n=h.cast(t,"int32"),i=(o=h).tensor4d,s=(a=Array).from,[4,n.data()];case 3:return r=i.apply(o,[s.apply(a,[u.sent()]),[1,448,448,3]]),l=h.cast(r,"int32"),[4,Qt.predict(l)];case 4:return[4,(c=u.sent()).data()];case 5:return u.sent(),h.dispose(c),n.dispose(),l.dispose(),r.dispose(),h.dispose(t),[2,Qt]}}))}))}class on{refCount(e){return an("refCount")}incRef(e){return an("incRef")}timerAvailable(){return!0}time(e){return an("time")}read(e){return an("read")}readSync(e){return an("readSync")}readToGPU(e,t){return an("readToGPU")}numDataIds(){return an("numDataIds")}disposeData(e,t){return an("disposeData")}write(e,t,n){return an("write")}move(e,t,n,r,o){return an("move")}createTensorFromGPUData(e,t,n){return an("createTensorFromGPUData")}memory(){return an("memory")}floatPrecision(){return an("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return an("dispose")}}function an(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 sn(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function ln(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 cn(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 un(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function dn(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 hn(e){return"string"==typeof e||e instanceof String}function fn(e){return Array.isArray(e)?fn(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":"number"==typeof e?"float32":hn(e)?"string":function(e){return"boolean"==typeof e}(e)?"bool":"float32"}function pn(e){return!!(e&&e.constructor&&e.call&&e.apply)}function gn(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 mn(e,t,n,r=!1){const o=new Array;if(1===t.length){const i=t[0]*(r?2:1);for(let t=0;t<i;t++)o[t]=n[e+t]}else{const i=t[0],a=t.slice(1),s=a.reduce(((e,t)=>e*t))*(r?2:1);for(let t=0;t<i;t++)o[t]=mn(e+t*s,a,n,r)}return o}function vn(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 mn(0,e,t,n)}function bn(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 yn(e){e.forEach((t=>{sn(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function wn(e){return e&&e.then&&"function"==typeof e.then}const xn="tfjsflags";class En{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Sn,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&(kn().getBool("IS_TEST")||kn().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];kn().getBool("IS_TEST")||kn().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(wn(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(xn in e){e[xn].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 Sn(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 kn(){return Tn}let Cn,Tn=null;function An(){if(null==Cn){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}Cn=e}return Cn}function In(e,t){const n=function(){const e=An();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 Rn="Add",Dn="Cast",_n="Identity";function Fn(...e){kn().getBool("IS_TEST")||kn().getBool("PROD")||console.warn(...e)}const Mn=In("kernelRegistry",(()=>new Map)),Ln=In("gradRegistry",(()=>new Map));function Pn(e,t){const n=function(e,t){return`${t}_${e}`}(e,t);return Mn.get(n)}function Bn(e){return Ln.get(e)}function On(e){const t=Mn.entries(),n=[];for(;;){const{done:r,value:o}=t.next();if(r)break;const[i,a]=o,[s]=i.split("_");s===e&&n.push(a)}return n}function Nn(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}function Un(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=zn(e)),kn().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 jn(){return kn().platform.now()}function Gn(e,t="utf-8"){return t=t||"utf-8",kn().platform.decode(e,t)}function $n(e){return null!=kn().platform.isTypedArray?kn().platform.isTypedArray(e):Nn(e)}function zn(e,t=[],n=!1){if(null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||wn(e)||null==e||$n(e)&&n)t.push(e);else if(Array.isArray(e)||$n(e))for(let r=0;r<e.length;++r)zn(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 o=0;o<=r;o++)zn(e[o],t,n)}return t}class qn{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new Wn)}profileKernel(e,t,n){let r;const o=()=>{r=n()};let i;const a=jn();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(o);else{o();for(const e of r)e.dataSync();i=Promise.resolve({kernelMs:jn()-a})}if(kn().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<r.length;t++){const n=r[t];n.data().then((t=>{Vn(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:o,extraInfo:i}=e;n.forEach((e=>{Promise.all([e.data(),r,i]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],o,n[2])}))}))}}function Vn(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 Wn{logKernelProfile(e,t,n,r,o,i){const a="number"==typeof r?un(`${r}ms`,9):r.error,s=un(e,25),l=t.rank,c=t.size,u=un(t.shape.toString(),14);let d="";for(const e in o){const n=o[e];if(null!=n){const r=n.shape||t.shape,o=r.length;d+=`${e}: ${o}D ${o>0?r:""} `}}console.log(`%c${s}\t%c${a}\t%c${l}D ${u}\t%c${c}\t%c${d}\t%c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}const Hn=20,Kn=3,Yn=7;function Xn(e,t,n,r){const o=gn(t),i=function(e,t,n,r){const o=ln(t),i=r[r.length-1],a=new Array(i).fill(0),s=t.length,l="complex64"===n?er(e):e;if(s>1)for(let e=0;e<o/i;e++){const t=e*i;for(let e=0;e<i;e++)a[e]=Math.max(a[e],Jn(l[t+e],0,n).length)}return a}(e,t,n,o),a=t.length,s=Qn(e,t,n,o,i),l=["Tensor"];return r&&(l.push(` dtype: ${n}`),l.push(` rank: ${a}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(s.map((e=>" "+e)).join("\n")),l.join("\n")}function Jn(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(Yn))} + ${parseFloat(e[1].toFixed(Yn))}j`:hn(e)?`'${e}'`:"bool"===n?Zn(e):parseFloat(e.toFixed(Yn)).toString(),un(r,t)}function Zn(e){return 0===e?"false":"true"}function Qn(e,t,n,r,o,i=!0){const a="complex64"===n?2:1,s=t[0],l=t.length;if(0===l){if("complex64"===n){return[Jn(er(e)[0],0,n)]}return"bool"===n?[Zn(e[0])]:[e[0].toString()]}if(1===l){if(s>Hn){let t=Array.from(e.slice(0,Kn*a)),r=Array.from(e.slice((s-Kn)*a,s*a));return"complex64"===n&&(t=er(t),r=er(r)),["["+t.map(((e,t)=>Jn(e,o[t],n))).join(", ")+", ..., "+r.map(((e,t)=>Jn(e,o[s-Kn+t],n))).join(", ")+"]"]}return["["+("complex64"===n?er(e):Array.from(e)).map(((e,t)=>Jn(e,o[t],n))).join(", ")+"]"]}const c=t.slice(1),u=r.slice(1),d=r[0]*a,h=[];if(s>Hn){for(let t=0;t<Kn;t++){const r=t*d;h.push(...Qn(e.slice(r,r+d),c,n,u,o,!1))}h.push("...");for(let t=s-Kn;t<s;t++){const r=t*d;h.push(...Qn(e.slice(r,r+d),c,n,u,o,t===s-1))}}else for(let t=0;t<s;t++){const r=t*d;h.push(...Qn(e.slice(r,r+d),c,n,u,o,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 er(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}class tr{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=ln(e),null!=n){const e=n.length;sn(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=gn(e)}set(e,...t){0===t.length&&(t=[0]),sn(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 nr().makeTensor(this.values,this.shape,this.dtype)}}let nr=null,rr=null;class or{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=ln(e),this.strides=gn(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 rr.buffer(this.shape,this.dtype,e)}bufferSync(){return rr.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return vn(this.shape,e,"complex64"===this.dtype)}arraySync(){return vn(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=nr().read(this.dataId);if("string"===this.dtype){const t=await e;try{return t.map((e=>Gn(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(),nr().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=nr().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>Gn(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 nr().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(nr().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return rr.print(this,e)}clone(){return this.throwIfDisposed(),rr.clone(this)}toString(e=!1){return Xn(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),rr.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),nr().makeVariable(this,e,t,n)}}Object.defineProperty(or,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),In("Tensor",(()=>or));class ir extends or{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(!cn(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);nr().disposeTensor(this),this.dataId=e.dataId,nr().incRef(this,null)}dispose(){nr().disposeVariable(this),this.isDisposedInternal=!0}}var ar,sr,lr,cr,ur;Object.defineProperty(ir,Symbol.hasInstance,{value:e=>e instanceof or&&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"}(ar||(ar={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(sr||(sr={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(lr||(lr={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(cr||(cr={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(ur||(ur={}));const dr={float32:cr,int32:sr,bool:lr,complex64:ur};function hr(e){return null!=e&&"object"==typeof e&&"texture"in e&&e.texture instanceof WebGLTexture}function fr(e){return"undefined"!=typeof GPUBuffer&&null!=e&&"object"==typeof e&&"buffer"in e&&e.buffer instanceof GPUBuffer}function pr(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 dr[e][t]}(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function gr(e){const t=[];return mr(e,t,new Set),t}function mr(e,t,n){if(null==e)return;if(e instanceof or)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const o=e;for(const e in o){const r=o[e];n.has(r)||(n.add(r),mr(r,t,n))}}function vr(e){return null!=e.kernelName}class br{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 yr{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new br}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?(Fn(`${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 qn(this.backendInstance),!0}setupRegisteredKernels(){On(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){On(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 on||"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,Fn(`Initialization of backend ${e} failed`),Fn(n.stack||n.message)),!1)));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(t){return Fn(`Initialization of backend ${e} failed`),Fn(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:o}=this.initializeBackend(n);if(o||r)return{name:n,asyncInit:o}}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,o=this.readSync(t),i=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,o,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 yr.nextTensorId++}nextVariableId(){return yr.nextVariableId++}clone(e){const t=xr.runKernel(_n,{x:e});return this.addTapeNode(this.state.activeScope.name,{x:e},[t],(e=>({x:()=>xr.runKernel(Dn,{x:e},{dtype:"float32"})})),[],{}),t}runKernel(e,t,n){if(!(null!=Pn(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 o=0;n.forEach((e=>{o+="complex64"===e.dtype?3:1}));const i=r-t-o-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(),o=this.state.numBytes,i=this.state.numTensors;let a,s;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);const l=vr(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(vr(e)){const{kernelName:t,inputs:o,attrs:i}=e,l=Pn(t,this.backendName);sn(null!=l,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),a=()=>{const e=this.backend.numDataIds();s=l.kernelFunc({inputs:o,attrs:i,backend:this.backend});const a=Array.isArray(s)?s:[s];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,a);const c=a.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(r){const e=this.getTensorsForGradient(t,o,c);n=this.saveTensorsForBackwardMode(e)}return c}}else{const{forwardFunc:t}=e,o=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};a=()=>{const e=this.backend.numDataIds();s=this.tidy((()=>t(this.backend,o)));const n=Array.isArray(s)?s:[s];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,e,n),n}}const{inputs:c,attrs:u}=e,d=vr(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,c,(()=>a())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(h),t=h.outputs):t=a()})),r&&this.addTapeNode(l,c,t,d,n,u),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-o,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(c).map((e=>null!=c[e]?c[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=Bn(e);if(null!=r){const e=r.inputsToSave||[],o=r.outputsToSave||[];let i;r.saveAllInputs?(sn(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 a=n.filter(((e,t)=>o[t]));return i.concat(a)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");r=r||this.backend;let o=e;"string"===(n=n||"float32")&&hn(e[0])&&(o=e.map((e=>function(e,t="utf-8"){return t=t||"utf-8",kn().platform.encode(e,t)}(e))));const i=r.write(o,t,n),a=new or(t,n,i,this.nextTensorId());if(this.trackTensor(a,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}(o);this.state.numBytes+=t-e.bytes,e.bytes=t}return a}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:o}=e,i=new or(r,o,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 o=new ir(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[o.name])throw new Error(`Variable with name ${o.name} was already registered`);return this.state.registeredVariables[o.name]=o,this.incRef(o,this.backend),o}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*dn(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 ir||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*dn(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,o,i){const a={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:o},s=Bn(e);null!=s&&(r=s.gradFunc),null!=r&&(a.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=bn(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],o,i))),this.state.activeTape.push(a)}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=gr(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(sn(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 o=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));sn(o instanceof or,(()=>"The result y returned by f() must be a tensor."));const i=function(e,t,n){const r={},o={};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],a=i.inputs;for(const e in a){const n=a[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,o[i.id]=!0;break}if(s)break}}const i={};i[n.id]=!0;const a={};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,a[n.id]=!0;break}}const s=[];for(let t=0;t<e.length;t++){const n=e[t];if(o[n.id]&&a[n.id]){const e={};for(const t in n.inputs){const o=n.inputs[t];r[o.id]&&(e[t]=o)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,s.push(t)}}return s}(this.state.activeTape,t,o);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[o.id]=null==n?function(e){const t=function(e,t){const n=bn(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}(ln(e),"float32");return xr.makeTensor(t,e,"float32")}(o.shape):n,function(e,t,n,r){for(let o=t.length-1;o>=0;o--){const i=t[o],a=[];if(i.outputs.forEach((t=>{const n=e[t.id];a.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(a);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 o=n((()=>s[t]()));if("float32"!==o.dtype)throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${o.dtype}'`);const a=i.inputs[t];if(!cn(o.shape,a.shape))throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input '${t}' has shape '${o.shape}', which does not match the shape of the input '${a.shape}'`);if(null==e[a.id])e[a.id]=o;else{const t=e[a.id];e[a.id]=r(t,o),t.dispose()}}}}(e,i,(e=>this.tidy(e)),Er);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:o,grads:r}}))}customGrad(e){return sn(pn(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;sn(t.every((e=>e instanceof or)),(()=>"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,o)=>(n=e(...t,o),sn(n.value instanceof or,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),sn(pn(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 o=n.gradFunc(e,r),i=Array.isArray(o)?o:[o];sn(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(...).")),sn(i.every((e=>e instanceof or)),(()=>"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 a={};return i.forEach(((e,t)=>{a[t]=()=>e})),a},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=jn(),n=await this.backend.time(e);return n.wallMs=jn()-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 br;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 wr(){const e=An();if(null==e._tfengine){const t=new En(e);e._tfengine=new yr(t)}return Tn=e._tfengine.ENV,function(e){nr=e}((()=>e._tfengine)),e._tfengine}yr.nextTensorId=0,yr.nextVariableId=0;const xr=wr();function Er(e,t){return xr.runKernel(Rn,{a:e,b:t})}const Sr=kn();function kr(e,t){let n=e;if($n(e))return"string"===t?[]:[e.length];if(hr(e)){return[e.height,e.width*(e.channels||"RGBA").length]}if(fr(e))return[e.buffer.size/(null==t?4:dn(t))];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||$n(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&kn().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Cr(e,r,[]),r}function Cr(e,t,n){if(n=n||[],!Array.isArray(e)&&!$n(e))return void sn(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));sn(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),sn(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)Cr(e[t],r,n.concat(t))}function Tr(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 or)return Tr(r,e.dtype,t,n),e;let o=fn(e);if("string"!==o&&["bool","int32","float32"].indexOf(r)>=0&&(o=r),Tr(r,o,t,n),null==e||!$n(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=kr(e,o);$n(e)||Array.isArray(e)||(e=[e]);const a="string"!==o?Un(e,o):zn(e,[],!0);return xr.makeTensor(a,i,o)}Sr.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.")})),Sr.registerFlag("IS_BROWSER",(()=>"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope)),Sr.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),Sr.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),Sr.registerFlag("IS_SAFARI",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor))),Sr.registerFlag("PROD",(()=>!1)),Sr.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>Sr.getBool("DEBUG"))),Sr.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),Sr.registerFlag("IS_TEST",(()=>!1)),Sr.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>Sr.getBool("DEBUG"))),Sr.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),Sr.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(()=>!1)),Sr.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 o=(...e)=>{xr.startScope(n);try{const t=r(...e);return wn(t)&&console.error("Cannot return a Promise inside of tidy."),xr.endScope(t),t}catch(e){throw xr.endScope(null),e}};return Object.defineProperty(o,"name",{value:n,configurable:!0}),o}class Rr{static join(e){return new Rr(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,null==e)return;if(e instanceof Array||(e=[e]),0===(e=e.map((e=>$n(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 o=t+r.byteLength;this.shards.push({buffer:r,start:t,end:o}),t=o}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),o=new Uint8Array(r);let i=0;for(let r=n;r<this.shards.length;r++){const n=this.shards[r],a=e+i-n.start,s=i,l=Math.min(t,n.end),c=new Uint8Array(n.buffer,a,l-n.start-a);if(o.set(c,s),i+=c.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 o=Math.floor((r-n)/2)+n,i=t(e[o]);if(0===i)return o;i<0?r=o:n=o+1}return-1}(this.shards,t);return-1===n?-1:(this.previousShardIndex=n,this.previousShardIndex)}}const Dr="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function _r(e){return Dr?Buffer.byteLength(e,"utf8"):new Blob([e]).size}function Fr(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:_r(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:_r(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:new Rr(e.weightData).byteLength}}class Mr{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==Mr.instance&&(Mr.instance=new Mr),Mr.instance}static registerSaveRouter(e){Mr.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Mr.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Mr.getHandlers(e,"save")}static getLoadHandlers(e,t){return Mr.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?Mr.getInstance().loadRouters:Mr.getInstance().saveRouters).forEach((t=>{const o=t(e,n);null!==o&&r.push(o)})),r}}const Lr="tensorflowjs",Pr="models_store",Br="model_info_store";function Or(){if(!kn().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 Nr(e){const t=e.result;t.createObjectStore(Pr,{keyPath:"modelPath"}),t.createObjectStore(Br,{keyPath:"modelPath"})}class Ur{constructor(e){if(this.indexedDB=Or(),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(Lr,1);r.onupgradeneeded=()=>Nr(r),r.onsuccess=()=>{const o=r.result;if(null==t){const t=o.transaction(Pr,"readonly"),r=t.objectStore(Pr).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return o.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(o.close(),n(r.error)),t.oncomplete=()=>o.close()}else{const r=Fr(t),i=o.transaction(Br,"readwrite");let a,s,l=i.objectStore(Br);try{a=l.put({modelPath:this.modelPath,modelArtifactsInfo:r})}catch(e){return n(e)}a.onsuccess=()=>{s=o.transaction(Pr,"readwrite");const a=s.objectStore(Pr);let c;try{c=a.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r})}catch(e){return n(e)}c.onsuccess=()=>e({modelArtifactsInfo:r}),c.onerror=e=>{l=i.objectStore(Br);const t=l.delete(this.modelPath);t.onsuccess=()=>(o.close(),n(c.error)),t.onerror=e=>(o.close(),n(c.error))}},a.onerror=e=>(o.close(),n(a.error)),i.oncomplete=()=>{null==s?o.close():s.oncomplete=()=>o.close()}}},r.onerror=e=>n(r.error)}))}}Ur.URL_SCHEME="indexeddb://";const jr=e=>{return kn().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ur.URL_SCHEME)?(t=e.slice(Ur.URL_SCHEME.length),new Ur(t)):null;var t};Mr.registerSaveRouter(jr),Mr.registerLoadRouter(jr);class Gr{constructor(){this.indexedDB=Or()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(Lr,1);n.onupgradeneeded=()=>Nr(n),n.onsuccess=()=>{const r=n.result,o=r.transaction(Br,"readonly"),i=o.objectStore(Br).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)),o.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(Ur.URL_SCHEME)?t.slice(Ur.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(Lr,1);r.onupgradeneeded=()=>Nr(r),r.onsuccess=()=>{const o=r.result,i=o.transaction(Br,"readwrite"),a=i.objectStore(Br),s=a.get(e);let l;s.onsuccess=()=>{if(null==s.result)return o.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=a.delete(e),i=()=>{l=o.transaction(Pr,"readwrite");const r=l.objectStore(Pr).delete(e);r.onsuccess=()=>t(s.result.modelArtifactsInfo),r.onerror=e=>n(s.error)};r.onsuccess=i,r.onerror=e=>(i(),o.close(),n(s.error))}},s.onerror=e=>(o.close(),n(s.error)),i.oncomplete=()=>{null==l?o.close():l.oncomplete=()=>o.close()}},r.onerror=e=>n(r.error)}))}}const $r="/",zr="tensorflowjs_models",qr="info",Vr="model_topology",Wr="weight_specs",Hr="weight_data",Kr="model_metadata";function Yr(e){return{info:[zr,e,qr].join($r),topology:[zr,e,Vr].join($r),weightSpecs:[zr,e,Wr].join($r),weightData:[zr,e,Hr].join($r),modelMetadata:[zr,e,Kr].join($r)}}function Xr(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function Jr(e){const t=e.split($r);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join($r)}class Zr{constructor(e){if(!kn().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=Yr(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=Fr(e),o=Rr.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(Dr)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)}(o));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 Xr(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 o=this.LS.getItem(this.keys.modelMetadata);if(null!=o){const e=JSON.parse(o);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(Dr){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}}Zr.URL_SCHEME="localstorage://";const Qr=e=>{return kn().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Zr.URL_SCHEME)?(t=e.slice(Zr.URL_SCHEME.length),new Zr(t)):null;var t};Mr.registerSaveRouter(Qr),Mr.registerLoadRouter(Qr);class eo{constructor(){sn(kn().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),sn("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=zr+$r,n=$r+qr;for(let r=0;r<this.LS.length;++r){const o=this.LS.key(r);if(o.startsWith(t)&&o.endsWith(n)){e[Jr(o)]=JSON.parse(this.LS.getItem(o))}}return e}async removeModel(e){var t;const n=Yr(e=(t=e).startsWith(Zr.URL_SCHEME)?t.slice(Zr.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 Xr(n),r}}class to{constructor(){this.managers={}}static getInstance(){return null==to.instance&&(to.instance=new to),to.instance}static registerManager(e,t){sn(null!=e,(()=>"scheme must not be undefined or null.")),e.endsWith("://")&&(e=e.slice(0,e.indexOf("://"))),sn(e.length>0,(()=>"scheme must not be an empty string."));const n=to.getInstance();sn(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=to.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(to.getInstance().managers)}}class no{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&&kn().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 Nn(e)}}if(kn().get("IS_BROWSER")){kn().setPlatform("browser",new no);try{to.registerManager(Zr.URL_SCHEME,new eo)}catch(e){}try{to.registerManager(Ur.URL_SCHEME,new Gr)}catch(e){}}const ro=()=>require("node-fetch");let oo;class io{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=kn().global.fetch?kn().global.fetch(e,t):(null==oo&&(oo=ro()),oo(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)}}kn().get("IS_NODE")&&!kn().get("IS_BROWSER")&&kn().setPlatform("node",new io);const ao=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 xr.runKernel(Dn,{x:n},{dtype:t})}});const so=Ir({clone_:function(e){const t=Ar(e,"x","clone","string_or_numeric");return xr.runKernel(_n,{x:t})}});wr();const lo={buffer:function(e,t="float32",n){return t=t||"float32",yn(e),new tr(e,t,n)},cast:ao,clone:so,print:function(e,t=!1){console.log(e.toString(t))}};function co(e,t){return xr.tidy(e,t)}function uo(e){gr(e).forEach((e=>e.dispose()))}rr=lo;const ho=Ir({add_:function(e,t){let n=Ar(e,"a","add"),r=Ar(t,"b","add");return[n,r]=pr(n,r),xr.runKernel(Rn,{a:n,b:r})}});const fo=Ir({floorDiv_:function(e,t){let n=Ar(e,"a","floorDiv"),r=Ar(t,"b","floorDiv");return[n,r]=pr(n,r),xr.runKernel("FloorDiv",{a:n,b:r})}});const po=Ir({div_:function(e,t){let n=Ar(e,"a","div"),r=Ar(t,"b","div");return[n,r]=pr(n,r),"int32"===n.dtype&&"int32"===r.dtype?fo(n,r):xr.runKernel("RealDiv",{a:n,b:r},{})}});const go=Ir({mul_:function(e,t){let n=Ar(e,"a","mul"),r=Ar(t,"b","mul");return[n,r]=pr(n,r),xr.runKernel("Multiply",{a:n,b:r})}});const mo=Ir({abs_:function(e){const t=Ar(e,"x","abs");if("complex64"===t.dtype){return xr.runKernel("ComplexAbs",{x:t})}return xr.runKernel("Abs",{x:t})}});const vo=Ir({zerosLike_:function(e){const t=Ar(e,"x","zerosLike");return xr.runKernel("ZerosLike",{x:t})}});const bo=Ir({pow_:function(e,t){let n=Ar(e,"base","pow"),r=Ar(t,"exp","pow");return[n,r]=pr(n,r),xr.runKernel("Pow",{a:n,b:r})}});function yo(e,t){if(($n(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&&$n(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=fn(e);else if("complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(fr(e)||hr(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 xr.backend.createTensorFromGPUData(e,t||n,r)}if(!$n(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){yn(t);const e=ln(t),r=ln(n);sn(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]!==ln(t.slice(e));sn(n[e]===t[e]||!r,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return $n(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?Un(e,r):zn(e,[],!0),xr.makeTensor(e,t,r)}(e,[],[],t)}const wo=Ir({sqrt_:function(e){const t=Ar(e,"x","sqrt","float32");return xr.runKernel("Sqrt",{x:t})}});const xo=Ir({square_:function(e){const t=Ar(e,"x","square");return xr.runKernel("Square",{x:t},{})}});const Eo=Ir({sub_:function(e,t){let n=Ar(e,"a","sub"),r=Ar(t,"b","sub");return[n,r]=pr(n,r),xr.runKernel("Sub",{a:n,b:r})}});const So=Ir({maximum_:function(e,t){let n=Ar(e,"a","maximum"),r=Ar(t,"b","maximum");return[n,r]=pr(n,r),"bool"===n.dtype&&(n=ao(n,"int32"),r=ao(r,"int32")),function(e,t){const n=Math.max(e.length,t.length),r=new Array(n);for(let o=0;o<n;o++){let i=e[e.length-o-1];null==i&&(i=1);let a=t[t.length-o-1];if(null==a&&(a=1),1===i)r[n-o-1]=a;else if(1===a)r[n-o-1]=i;else{if(i!==a)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);r[n-o-1]=i}}}(n.shape,r.shape),xr.runKernel("Maximum",{a:n,b:r})}});class ko{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class Co{constructor(){this.classNameMap={}}static getMap(){return null==Co.instance&&(Co.instance=new Co),Co.instance}static register(e){Co.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function To(e){sn(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),sn("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),sn(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),Co.register(e)}class Ao extends ko{minimize(e,t=!1,n){const{value:r,grads:o}=this.computeGradients(e,n);if(null!=n){const e=n.map((e=>({name:e.name,tensor:o[e.name]})));this.applyGradients(e)}else this.applyGradients(o);return uo(o),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){sn(pn(e),(()=>"The f passed in variableGrads(f) must be a function")),sn(null==t||Array.isArray(t)&&t.every((e=>e instanceof ir)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=t;if(!n){t=[];for(const e in xr.registeredVariables)t.push(xr.registeredVariables[e])}const r=n?t.filter((e=>!e.trainable)):null,o=t.length;sn((t=t.filter((e=>e.trainable))).length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${o} variables is trainable.`));const{value:i,grads:a}=xr.gradients(e,t,null,!0);sn(a.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().")),sn(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!=a[t]&&(s[e.name]=a[t])})),null!=r&&r.forEach((e=>s[e.name]=null)),{value:i,grads:s}}(e,t)}dispose(){null!=this.iterations_&&uo(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:yo(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(Ao,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class Io extends Ao{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 o=xr.registeredVariables[t];co((()=>{const e=ho(go(this.c,r),o);o.assign(e)}))})),this.incrementIterations()}setLearningRate(e){var t;this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=(t=yo(-e),xr.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 Ro=[class extends Ao{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=xr.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=xr.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:co((()=>vo(r).variable(false)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:co((()=>vo(r).variable(false)))});const o=Array.isArray(e)?e[n].tensor:e[t];if(null==o)return;const i=this.accumulatedGrads[n].variable,a=this.accumulatedUpdates[n].variable;co((()=>{const e=ho(go(i,this.rho),go(xo(o),1-this.rho)),t=go(po(wo(ho(a,this.epsilon)),wo(ho(i,this.epsilon))),o),n=ho(go(a,this.rho),go(xo(t),1-this.rho));i.assign(e),a.assign(n);const s=ho(go(t,-this.learningRate),r);r.assign(s)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(uo(this.accumulatedGrads.map((e=>e.variable))),uo(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 Ao{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=xr.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:co((()=>function(e,t,n){return yn(e),n=n||fn(t),xr.runKernel("Fill",{},{shape:e,value:t,dtype:n})}(r.shape,this.initialAccumulatorValue).variable(e)))}}const o=Array.isArray(e)?e[n].tensor:e[t];if(null==o)return;const i=this.accumulatedGrads[n].variable;co((()=>{const e=ho(i,xo(o));i.assign(e);const t=ho(go(po(o,wo(ho(e,xr.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&uo(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 Ao{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=[],co((()=>{this.accBeta1=yo(t).variable(),this.accBeta2=yo(n).variable()})),null==r&&(this.epsilon=xr.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);co((()=>{const n=Eo(1,this.accBeta1),r=Eo(1,this.accBeta2);t.forEach(((t,o)=>{const i=xr.registeredVariables[t];null==this.accumulatedFirstMoment[o]&&(this.accumulatedFirstMoment[o]={originalName:`${t}/m`,variable:co((()=>vo(i).variable(false)))}),null==this.accumulatedSecondMoment[o]&&(this.accumulatedSecondMoment[o]={originalName:`${t}/v`,variable:co((()=>vo(i).variable(false)))});const a=Array.isArray(e)?e[o].tensor:e[t];if(null==a)return;const s=this.accumulatedFirstMoment[o].variable,l=this.accumulatedSecondMoment[o].variable,c=ho(go(s,this.beta1),go(a,1-this.beta1)),u=ho(go(l,this.beta2),go(xo(a),1-this.beta2)),d=po(c,n),h=po(u,r);s.assign(c),l.assign(u);const f=ho(go(po(d,ho(wo(h),this.epsilon)),-this.learningRate),i);i.assign(f)})),this.accBeta1.assign(go(this.accBeta1,this.beta1)),this.accBeta2.assign(go(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&uo(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&uo(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),co((()=>{this.accBeta1.assign(bo(this.beta1,this.iterations_+1)),this.accBeta2.assign(bo(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 Ao{static get className(){return"Adamax"}constructor(e,t,n,r=null,o=0){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=o,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],co((()=>{this.iteration=yo(0).variable(),this.accBeta1=yo(t).variable()})),null==r&&(this.epsilon=xr.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);co((()=>{const n=Eo(1,this.accBeta1),r=po(-this.learningRate,ho(go(this.iteration,this.decay),1));t.forEach(((t,o)=>{const i=xr.registeredVariables[t];null==this.accumulatedFirstMoment[o]&&(this.accumulatedFirstMoment[o]={originalName:`${t}/m`,variable:vo(i).variable(false)}),null==this.accumulatedWeightedInfNorm[o]&&(this.accumulatedWeightedInfNorm[o]={originalName:`${t}/v`,variable:vo(i).variable(false)});const a=Array.isArray(e)?e[o].tensor:e[t];if(null==a)return;const s=this.accumulatedFirstMoment[o].variable,l=this.accumulatedWeightedInfNorm[o].variable,c=ho(go(s,this.beta1),go(a,1-this.beta1)),u=go(l,this.beta2),d=mo(a),h=So(u,d);s.assign(c),l.assign(h);const f=ho(go(po(r,n),po(c,ho(h,this.epsilon))),i);i.assign(f)})),this.iteration.assign(ho(this.iteration,1)),this.accBeta1.assign(go(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&uo(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&uo(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 Io{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=yo(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=xr.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:co((()=>vo(r).variable(e)))}}const o=this.accumulations[n].variable,i=Array.isArray(e)?e[n].tensor:e[t];null!=i&&co((()=>{let e;const t=ho(go(this.m,o),i);e=ho(go(this.c,this.useNesterov?ho(i,go(t,this.m)):t),r),o.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&uo(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 Ao{static get className(){return"RMSProp"}constructor(e,t=.9,n=0,r=null,o=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=o,null==r&&(this.epsilon=xr.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=xr.registeredVariables[t],o=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:co((()=>vo(r).variable(o)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:co((()=>vo(r).variable(o)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:co((()=>vo(r).variable(o)))});const i=Array.isArray(e)?e[n].tensor:e[t];if(null==i)return;const a=this.accumulatedMeanSquares[n].variable,s=this.accumulatedMoments[n].variable;co((()=>{const e=ho(go(a,this.decay),go(xo(i),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,o=ho(go(t,this.decay),go(i,1-this.decay)),l=po(go(i,this.learningRate),wo(Eo(e,ho(xo(o),this.epsilon)))),c=ho(go(s,this.momentum),l);a.assign(e),t.assign(o),s.assign(c);const u=Eo(r,c);r.assign(u)}else{const e=ho(go(a,this.decay),go(xo(i),1-this.decay)),t=ho(go(s,this.momentum),po(go(i,this.learningRate),wo(ho(e,this.epsilon))));a.assign(e),s.assign(t);const n=Eo(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&uo(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&uo(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&uo(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)}},Io];!function(){for(const e of Ro)To(e)}();const Do={},_o={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Fo(e,t){if(!(e in Do)||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(kn().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 Do[e]}),!1),kn().getBool("SOFTWARE_WEBGL_ENABLED")&&(_o.failIfMajorPerformanceCaveat=!1);if(1===e)return n.getContext("webgl",_o)||n.getContext("experimental-webgl",_o);return n.getContext("webgl2",_o)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;Do[e]=n}const n=Do[e];return null==n||n.isContextLost()?(delete Do[e],Fo(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),Do[e])}var Mo="https://websdk-cdn-dev.idmission.com/assets";function Lo(e){var t=e.width,n=e.height;return e instanceof HTMLVideoElement&&(t=e.videoWidth,n=e.videoHeight),[t,n]}function Po(e,t){var n=document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("could not get 2d context");var o=t.box,i=o.width,a=.6*e.height-i,s=Math.max(0,o.xMin-a/2);return Ut()?(n.width=e.width,n.height=e.height,r.drawImage(e,0,0,n.width,n.height)):(n.width=i+a,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 Bo=function(e){var t=e.error;return l.default.createElement(ct,null,l.default.createElement(ut,{style:{justifyContent:"center"}},l.default.createElement("h3",{style:{marginBottom:8}},"We're sorry, an unexpected error has occurred."),l.default.createElement("p",{style:{marginBottom:0}},l.default.createElement("code",null,t.message))))},Oo={boxes:1,scores:4,labels:2},No=t.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}}),Uo="".concat(Mo,"/models/docdetectuint8/model.json"),jo="".concat(Mo,"/models/focus/model.json"),Go=function(e){var n=e.children,r=e.documentDetectionModelUrl,i=e.focusModelUrl,a=e.logPredictions,s=void 0!==a&&a,c=t.useState(!1),u=c[0],d=c[1],f=t.useState(0),p=f[0],g=f[1],m=t.useState(0),y=m[0],w=m[1],x=t.useState(0),E=x[0],S=x[1],k=t.useState(0),C=k[0],T=k[1],A=t.useState(0),I=A[0],R=A[1],D=t.useRef(!1),_=t.useRef(),F=t.useRef(null),M=t.useState(0),L=M[0],P=M[1],B=t.useState(0),O=B[0],N=B[1],U=t.useState(null),j=U[0],G=U[1];t.useEffect((function(){d(!1);var e=r||Uo,t=i||jo;function n(){return v(this,void 0,void 0,(function(){return b(this,(function(n){switch(n.label){case 0:return h.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",52428800),[4,h.setBackend("webgl")];case 1:return n.sent(),[4,h.ready()];case 2:return n.sent(),[4,Promise.all([Mt(e),rn(t)])];case 3:return n.sent(),[2]}}))}))}function a(){return v(this,void 0,void 0,(function(){var r;return b(this,(function(i){switch(i.label){case 0:return d(!1),St=null,Qt=null,delete Do[2],(r=document.createElement("canvas").getContext("webgl2"))&&e&&t?(o.setWebGLContext(2,r),function(){try{h.backend().dispose()}catch(e){console.error("failed to dispose backend",e)}}(),[4,n()]):[3,2];case 1:i.sent(),d(!0),i.label=2;case 2:return[2]}}))}))}try{n().then((function(){d(!0)}))}catch(e){G(e)}var s=Fo(2).canvas;return s.addEventListener("webglcontextlost",a),function(){var e;null===(e=s.removeEventListener)||void 0===e||e.call(s,"webglcontextlost",a)}}),[r,i]);var $=t.useMemo((function(){return{document:p,passport:y,mrz:E,pdf417:C,focus:I}}),[p,I,E,y,C]),z=t.useCallback((function(e){e.document&&g(e.document),e.passport&&w(e.passport),e.mrz&&S(e.mrz),e.pdf417&&T(e.pdf417),e.focus&&R(e.focus)}),[]),q=t.useRef(null),V=t.useRef(0),W=t.useCallback((function(e){D.current=!0,v(void 0,void 0,void 0,(function(){var t,n;return b(this,(function(r){switch(r.label){case 0:return St&&Qt&&F.current?[4,zo(e,F.current,$,s)]:[2];case 1:return t=r.sent(),P(t.detectionTime),N(t.focusPredictionTime),V.current<=t.focusScore&&(V.current=t.focusScore,$o(q.current,e)),null===(n=_.current)||void 0===n||n.call(_,t),D.current=!1,[2]}}))}))}),[s,$]),H=t.useCallback((function(e){_.current=e}),[]),K=t.useCallback((function(){return v(void 0,void 0,void 0,(function(){var e;return b(this,(function(t){switch(t.label){case 0:return q.current?(e=q.current.toDataURL("image/jpeg",.98),[4,fetch(e)]):[2,null];case 1:return[4,t.sent().blob()];case 2:return[2,t.sent()]}}))}))}),[]),Y=t.useCallback((function(){V.current=0,function(e){if(!e)return;var t=e.getContext("2d");if(!t)return;t.clearRect(0,0,e.width,e.height)}(q.current)}),[]),X=t.useMemo((function(){return{ready:u,working:D,thresholds:$,setThresholds:z,makePrediction:W,onPredictionMade:H,detectionTime:L,focusPredictionTime:O,getBestFrame:K,resetBestFrame:Y}}),[L,O,K,W,H,u,Y,z,$]);return l.default.createElement(No.Provider,{value:X},j?l.default.createElement(Bo,{error:j}):n,l.default.createElement(Jo,{ref:F}),l.default.createElement(Jo,{ref:q}))};function $o(e,t,n,r){if(e){var o=e.getContext("2d");if(o){if(!n||!r){var i=Lo(t);n||(n=i[0]),r||(r=i[1])}e.width=n,e.height=r,o.drawImage(t,0,0,n,r)}}}function zo(e,t,n,r){var o,i,a,s,l,c,u,d,h,f;return void 0===r&&(r=!1),v(this,void 0,void 0,(function(){var p,g,m,v,y,w,x,E,S,k,C,T,A,I,R,D,_,F,M,L,P,B,O,N,U,j,G,$;return b(this,(function(b){switch(b.label){case 0:return p=Lo(e),g=p[0],m=p[1],$o(t,e),[4,qo(e,r)];case 1:return v=b.sent(),y=v.scores,w=v.labels,x=v.time,E=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],o=e[1];return{score:t,bbox:[o,r,e[3]-o,e[2]-r],label:Lt[n]}}(e,y[t],w[t])}))),S=E.find((function(e){return"Document"===e.label})),k=E.find((function(e){return"Passport Page"===e.label})),C=null!==(o=null==S?void 0:S.score)&&void 0!==o?o:0,T=null!==(i=null==k?void 0:k.score)&&void 0!==i?i:0,A=T>=(null!==(a=n.passport)&&void 0!==a?a:0),I=C>T?S:k,D=(R=A?T:C)>=(null!==(s=n.document)&&void 0!==s?s:0),_=Et.NONE,A?_=Et.PASSPORT:D&&(_=Et.ID_CARD),F=E.find((function(e){return"MRZ"===e.label})),M=null!==(l=null==F?void 0:F.score)&&void 0!==l?l:0,L=M>=(null!==(c=n.mrz)&&void 0!==c?c:0),P=E.find((function(e){return"PDF417"===e.label})),B=null!==(u=null==P?void 0:P.score)&&void 0!==u?u:0,O=B>=(null!==(d=n.pdf417)&&void 0!==d?d:0),N=null,U=0,j=0,G=!1,D?[4,Vo(e,null==I?void 0:I.bbox,r)]:[3,3];case 2:$=b.sent(),U=$[1],j=null!==(h=null==(N=$[0])?void 0:N[1])&&void 0!==h?h:0,G=j>=(null!==(f=n.focus)&&void 0!==f?f:0),b.label=3;case 3:return[2,{detectedObjects:E,detectionScore:R,detectionTime:x,detectionThresholdMet:D,detectedDocumentType:_,passportDetectionScore:T,passportDetectionThresholdMet:A,mrzDetectionScore:M,mrzDetectionThresholdMet:L,pdf417DetectionScore:B,pdf417DetectionThresholdMet:O,bestDocumentOrPassport:I,bestMrz:F,bestPdf417:P,focusScore:j,focusThresholdMet:G,focusPredictionTime:U,frameWidth:g,frameHeight:m}]}}))}))}function qo(e,t){return void 0===t&&(t=!1),v(this,void 0,void 0,(function(){var n,r,o,i,a,s,l,c,u,d,f,p,g,m,v,y,w;return b(this,(function(b){switch(b.label){case 0:if(!St)throw new Error("document detection model is not loaded");n=new Date,b.label=1;case 1:return b.trys.push([1,7,,8]),r=h.browser.fromPixels(e),t&&console.time("resize"),o=h.image.resizeBilinear(r,[320,320]),t&&console.timeEnd("resize"),r.dispose(),t&&console.time("convert to int32"),i=h.cast(o,"int32"),o.dispose(),l=(s=h).tensor4d,u=(c=Array).from,[4,i.data()];case 2:return a=l.apply(s,[u.apply(c,[b.sent()]),[1,320,320,3]]),i.dispose(),d=h.cast(a,"int32"),t&&console.timeEnd("convert to int32"),a.dispose(),t&&console.time("predictions"),[4,St.executeAsync(d)];case 3:return f=b.sent(),t&&console.timeEnd("predictions"),d.dispose(),p=f,t&&console.log("predictions made!",p.map((function(e){return e.arraySync()}))),[4,p[Oo.boxes].array()];case 4:return g=b.sent()[0],[4,p[Oo.scores].array()];case 5:return m=b.sent()[0],[4,p[Oo.labels].array()];case 6:return v=(v=b.sent()[0]).map((function(e){return Math.round(e)})),h.dispose(f),y=(new Date).getTime()-n.getTime(),[2,{boxes:g,scores:m,labels:v,time:y}];case 7:return w=b.sent(),console.error("caught error in makeDocumentDetectionPredictions",w),[2,{boxes:[],scores:[],labels:[],time:0}];case 8:return[2]}}))}))}function Vo(e,t,n){return void 0===n&&(n=!1),v(this,void 0,void 0,(function(){var r,o,i,a,s,l,c,u,d,f,p,g,m;return b(this,(function(v){switch(v.label){case 0:if(!Qt)throw new Error("focus model is not loaded");r=new Date,v.label=1;case 1:return v.trys.push([1,5,,6]),o=void 0,o=h.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 o=Lo(e),i=o[0],a=o[1],s=t[0],l=t[1],c=t[2],u=t[3];return n.width=c*i,n.height=u*a,r.drawImage(e,s*i,l*a,c*i,u*a,0,0,c*i,u*a),n}(e,t):e),i=h.image.resizeBilinear(o,[448,448]),o.dispose(),a=h.cast(i,"int32"),i.dispose(),c=(l=h).tensor4d,d=(u=Array).from,[4,a.data()];case 2:return s=c.apply(l,[d.apply(u,[v.sent()]),[1,448,448,3]]),a.dispose(),f=h.cast(s,"int32"),s.dispose(),n&&console.time("focus prediction"),[4,Qt.predict(f)];case 3:return p=v.sent(),f.dispose(),[4,p.array()];case 4:return g=v.sent()[0],n&&console.timeEnd("focus prediction"),h.dispose(p),m=(new Date).getTime()-r.getTime(),[2,[g,m]];case 5:return v.sent(),[2,[[0,0],0]];case 6:return[2]}}))}))}var Wo,Ho,Ko,Yo,Xo,Jo=d.default.canvas(Wo||(Wo=w(["\n display: none;\n"],["\n display: none;\n"]))),Zo=d.default.span(Ho||(Ho=w(["\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"]))),Qo=d.default.div(Ko||(Ko=w(["\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);":""})),ei=d.default.div(Yo||(Yo=w(["\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);":""})),ti=d.default.div(Xo||(Xo=w(["\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 ni(e){var n=e.enabled,r=void 0===n||n,o=e.pageWidth,i=e.pageHeight,a=e.videoWidth,s=e.videoHeight;return t.useMemo((function(){var e=!1,t=0,n=0,l=0,c=0;return r&&((e=o/i<a/s)?l=((t=a*(i/s))-o)/2:c=((n=s*(o/a))-i)/2),{horizontal:e,pageWidth:o,pageHeight:i,videoWidth:a,videoHeight:s,scaledWidth:t,scaledHeight:n,xOffset:l,yOffset:c}}),[r,i,o,s,a])}function ri(e){var t=e.obj,n=e.scaling,r=n.horizontal,o=n.pageWidth,i=n.pageHeight,a=n.scaledWidth,s=n.scaledHeight;return l.default.createElement(ei,{$flipX:e.flipX,style:{top:t.bbox[1]*(r?i:s-n.yOffset),left:t.bbox[0]*(r?a-n.xOffset:o),width:t.bbox[2]*(r?a:o),height:t.bbox[3]*(r?i:s)}},t.label," (",t.score.toFixed(3),")")}function oi(e){var t,n,r,o,i=e.face,a=e.flipX,s=e.color,c=e.scaling,u=c.pageWidth,d=c.pageHeight,h=c.videoWidth,f=c.videoHeight,p=c.scaledWidth,g=c.scaledHeight;return c.horizontal?(t=i.box.yMin/f*d,n=i.box.xMin/h*p-c.xOffset,r=i.box.width/h*p,o=i.box.height/f*d):(t=i.box.yMin/f*g-c.yOffset,n=i.box.xMin/h*u,r=i.box.width/h*u,o=i.box.height/f*g),l.default.createElement(l.default.Fragment,null,l.default.createElement(ei,{$flipX:a,$color:void 0===s?"green":s,style:{top:t,left:n,width:r,height:o}}),i.keypoints.map((function(e,t){return l.default.createElement(ii,{key:t,point:e,scaling:c,flipX:a})})))}function ii(e){var t,n,r=e.point,o=e.color,i=e.scaling,a=i.videoWidth,s=i.videoHeight;return i.horizontal?(t=r.x/a*i.scaledWidth-i.xOffset,n=r.y/s*i.pageHeight):(t=r.x/a*i.pageWidth,n=r.y/s*i.scaledHeight-i.yOffset),l.default.createElement(ti,{$flipX:e.flipX,$color:void 0===o?"red":o,style:{top:n-=2,left:t-=2}})}var ai,si,li,ci,ui,di=d.default.button(ai||(ai=w(["\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"]))),hi=d.default.div(si||(si=w(["\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"})),fi=function(e){var t=e.text,n=e.imageUrl;return l.default.createElement(gi,null,t&&l.default.createElement(mi,null,t),l.default.createElement(vi,null,l.default.createElement("img",{src:n,alt:""})))},pi=function(e){var t=e.imageUrl;return l.default.createElement(gi,null,l.default.createElement(mi,null,l.default.createElement(hi,{$size:24,$color:"white",$thickness:3,style:{position:"relative",top:4,left:-3,margin:"0 3px 0 -12px"}}),"Processing..."),l.default.createElement(vi,null,l.default.createElement("img",{src:t,alt:""})))},gi=d.default.div(li||(li=w(["\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"]))),mi=d.default.div(ci||(ci=w(["\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"]))),vi=d.default.div(ui||(ui=w(["\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"]))),bi={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 card front captured.":"Se ha capturado el frente de 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","Video signature has been successfully captured!":"La video firma ha sido exitosa.","Network unreachable":"No hay conexión a internet.","We're having trouble reaching our services, please check your connection and try again.":"Estamos teniendo problemas para alcanzar nuestros servicios, por favor verificar la conexión a internet e intentar de nuevo.","We're sorry, an unexpected error has occurred.":"Lo sentimos, se ha producido un error inesperado."}}},yi=function(e){var n=xe().i18n;t.useEffect((function(){"auto"!==e?n.changeLanguage(e):n.changeLanguage()}),[n,e])};function wi(e,t,n,r){if("string"==typeof n)return n;if("object"==typeof n){var o=n;if(o[t])return o[t];var i=t.split("-")[0];if(o[i])return o[i]}return e(r)}function xi(e,n){var r=xe(),o=r.t,i=r.i18n;return t.useMemo((function(){return m(m({},e),Object.keys(n).reduce((function(t,r){var a;return m(m({},t),((a={})[r]=wi(o,i.language,null==e?void 0:e[r],n[r]),a))}),{}))}),[n,i.language,o,e])}var Ei,Si,ki={videoWidth:0,videoHeight:0,captureStartedAt:null,detectedObjects:[],bestDocument:void 0,bestMrz:void 0,bestPdf417:void 0,documentType:Et.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},Ci=function(e,t){switch(t.type){case"configure":return m(m(m({},e),t.payload),{goodFramesCount:0,captureStartedAt:new Date,capturing:!1,captured:!1,captureFailed:!1});case"objectsDetected":var n=t.payload.prediction,r=n.detectedObjects,o=n.detectionScore,i=n.detectionThresholdMet,a=n.detectedDocumentType,s=n.passportDetectionScore,l=n.passportDetectionThresholdMet,c=n.mrzDetectionScore,u=n.mrzDetectionThresholdMet,d=n.pdf417DetectionScore,h=n.pdf417DetectionThresholdMet,f=n.bestDocumentOrPassport,p=n.bestMrz,g=n.bestPdf417,v=n.focusScore,b=n.focusThresholdMet,y=n.frameWidth,w=n.frameHeight,x=new Date,E=0,S=e.goodFramesThreshold;e.lastFrameCapturedAt&&(E=1e3/(x.getTime()-e.lastFrameCapturedAt.getTime()))>0&&(S=Math.ceil(3*E));var k=!1;if(f){var C=f.bbox,T=C[0],A=C[1],I=C[2],R=C[3];T*=y,I*=y,k=(A*=w)>5&&A+(R*=w)+5<w&&(T>5||T<5&&T+I>.8*y)&&T+I+5<y}var D=!0===e.autoCaptureBarcodeRequired||"mobile"===e.autoCaptureBarcodeRequired&&Ut(),_=e.barcodeScanningEnabled&&h&&D,F=_&&!e.barcodeResult,M=i&&k&&b,L=e.goodFramesCount;return M&&(L+=1),m(m({},e),{videoWidth:y,videoHeight:w,detectedObjects:r,bestDocument:f,bestMrz:p,bestPdf417:g,documentType:a,documentInBounds:k,documentDetectionScore:o,documentDetectionThresholdMet:i,mrzDetectionScore:c,mrzDetectionThresholdMet:u,pdf417DetectionScore:d,pdf417DetectionThresholdMet:h,passportPageDetectionScore:s,passportPageDetectionThresholdMet:l,focusScore:v,focusThresholdMet:b,shouldScanBarcode:_,waitingForBarcodeScan:F,isGoodFrame:M,goodFramesCount:L,goodFramesThreshold:S,goodFramesThresholdMet:L>=S,lastFrameCapturedAt:x,frameCaptureRate:E});case"barcodeScanned":return m(m({},e),{barcodeResult:t.payload.result,waitingForBarcodeScan:!1,autoCaptureBarcodeRequired:!1});case"barcodeScanFailed":var P=m(m({},e),{barcodeScanFailedAttempts:e.barcodeScanFailedAttempts+1});return P.barcodeScanFailedAttempts>=P.maxBarcodeScanAttempts&&(P.autoCaptureBarcodeRequired=!1,P.shouldScanBarcode=!1,P.waitingForBarcodeScan=!1),P;case"capturing":return m(m({},e),{capturing:!0,captured:!1,captureFailed:!1});case"captured":return m(m({},e),{capturing:!1,captured:!0,captureFailed:!1});case"captureFailed":return m(m({},e),{capturing:!1,captured:!1,captureFailed:!0});default:return e}},Ti=function(e){var n,r,o,i=e.requiredDocumentType,a=e.autoCaptureEnabled,s=void 0===a||a,c=e.autoCaptureScoreThreshold,u=void 0===c?.8:c,d=e.autoCaptureGoodFramesRequired,h=void 0===d?3:d,f=e.autoCaptureBarcodeRequired,p=void 0===f?"mobile":f,g=e.mrzDetectionScoreThreshold,m=void 0===g?.25:g,y=e.passportPageDetectionThreshold,w=void 0===y?.6:y,x=e.pdf417DetectionThreshold,E=void 0===x?.15:x,S=e.focusScoreThreshold,k=void 0===S?.3:S,C=e.barcodeScanningEnabled,T=void 0===C||C,A=e.maxBarcodeScanAttempts,I=void 0===A?10:A,R=e.onPrediction,D=e.onBarcodeScanned,_=e.onCapture,F=e.onExit,M=e.processingScreen,L=e.processingDelay,P=void 0===L?0:L,B=e.assets,O=void 0===B?{}:B,N=e.colors,U=void 0===N?{}:N,j=e.verbiage,G=void 0===j?{}:j,$=e.debugMode,z=void 0!==$&&$,q=Bt(),V=q.ref,W=q.width,H=void 0===W?1:W,K=q.height,Y=void 0===K?1:K,X=t.useReducer(Ci,ki),J=X[0],Z=X[1],Q=t.useState(""),ee=Q[0],te=Q[1],ne=t.useState(!1),re=ne[0],oe=ne[1],ie=t.useContext(tn),ae=ie.cameraRef,se=ie.cameraReady,le=ie.takePhoto,ce=ie.videoRef,ue=ie.videoLoaded,de=t.useRef(),he=t.useContext(No),fe=he.ready,pe=he.working,ge=he.setThresholds,me=he.makePrediction,ve=he.onPredictionMade,be=he.detectionTime,ye=he.focusPredictionTime,we=he.getBestFrame,xe=he.resetBestFrame;t.useEffect((function(){de.current=new Date}),[]),t.useEffect((function(){Z({type:"configure",payload:{requiredDocumentType:i,goodFramesThreshold:h,autoCaptureBarcodeRequired:p,barcodeScanningEnabled:T,maxBarcodeScanAttempts:I}}),xe(),ge({document:u,passport:w,mrz:m,pdf417:E,focus:k})}),[i,u,k,m,h,p,T,I,w,E,xe,ge]);var Ee=t.useRef(0),Se=t.useRef(!1);t.useEffect((function(){Se.current=ue&&se&&fe&&!J.capturing&&!J.captured}),[se,J.captured,J.capturing,fe,ue]);var ke=t.useState(null),Ce=ke[0],Te=ke[1];t.useEffect((function(){if(fe&&se&&ue)return Ee.current=requestAnimationFrame((function e(){return v(this,void 0,void 0,(function(){var t,n;return b(this,(function(r){switch(r.label){case 0:if(!Se.current||pe.current)return[3,5];r.label=1;case 1:return r.trys.push([1,4,,5]),J.shouldScanBarcode?[4,le()]:[3,3];case 2:if(!(t=r.sent()))return Ee.current=requestAnimationFrame(e),[2];Te(t),r.label=3;case 3:return ce.current&&me(ce.current),[3,5];case 4:return n=r.sent(),console.error("error capturing frame",n),[3,5];case 5:return Ee.current=requestAnimationFrame(e),[2]}}))}))})),function(){cancelAnimationFrame(Ee.current)}}),[se,me,fe,pe,J.shouldScanBarcode,le,ue,ce]),t.useEffect((function(){ve((function(e){Z({type:"objectsDetected",payload:{prediction:e}}),null==R||R(e)}))}),[R,ve]),t.useEffect((function(){v(void 0,void 0,void 0,(function(){var e,t;return b(this,(function(n){switch(n.label){case 0:return J.shouldScanBarcode&&Ce?[4,qt(Ce,null===(t=J.bestPdf417)||void 0===t?void 0:t.bbox)]:[3,2];case 1:(e=n.sent())?(Z({type:"barcodeScanned",payload:{result:e}}),null==D||D(e)):Z({type:"barcodeScanFailed"}),n.label=2;case 2:return[2]}}))}))}),[D,J.shouldScanBarcode,null===(n=J.bestPdf417)||void 0===n?void 0:n.bbox,le,Ce]);var Ae=s&&J.goodFramesThresholdMet&&!J.capturing&&!J.captured&&!J.waitingForBarcodeScan&&Ai(J.captureStartedAt)>=3e3;t.useEffect((function(){v(void 0,void 0,void 0,(function(){var e,t,n,r,o,i,a,s,l;return b(this,(function(c){switch(c.label){case 0:return Ae?(Z({type:"capturing"}),[4,we()]):[2];case 1:return(e=c.sent())?(oe(!0),[4,(u=e,new Promise((function(e){var t=new Image;t.onload=function(){e([t.naturalWidth,t.naturalHeight])},t.src=URL.createObjectURL(u)})))]):(console.log("uh oh, i did not get a photo"),Z({type:"captureFailed"}),[2]);case 2:return t=c.sent(),n=t[0],r=t[1],(o=document.createElement("canvas")).width=n,o.height=r,[4,createImageBitmap(e)];case 3:if(i=c.sent(),(n>1920&&r>1080||n>1080&&r>1920)&&J.barcodeResult){if(n>r?(o.width=1920,o.height=r*(1920/n)):(o.height=1920,o.width=n*(1920/r)),!(a=o.getContext("2d")))return[2];a.drawImage(i,0,0,o.width,o.height)}else{if(!(s=o.getContext("bitmaprenderer")))return[2];s.transferFromImageBitmap(i)}return l=o.toDataURL("image/jpeg",.92),te(l),setTimeout((function(){var e,t=(new Date).getTime()-(null!==(e=de.current)&&void 0!==e?e:new Date).getTime();null==_||_(l,n,r,{autoCapture:"Y",captureTime:t}),Z({type:"captured"}),oe(!1)}),P),[2]}var u}))}))}),[we,_,P,Ae,J.barcodeResult]),U.guideBoxUnsatisfiedColor||(U.guideBoxUnsatisfiedColor="white"),U.guideBoxSatisfiedColor||(U.guideBoxSatisfiedColor="green");var Ie=xi(G,{instructionText:"Scan the front of ID",processingIdCardText:"ID card front captured.",capturingText:"Capturing...",captureFailedText:"Capture failed!"}),Re=ni({enabled:z,pageWidth:H,pageHeight:Y,videoWidth:J.videoWidth,videoHeight:J.videoHeight});return re?l.default.createElement(l.default.Fragment,null,M,ee&&l.default.createElement(fi,{text:Ie.processingIdCardText,imageUrl:ee})):""!==ee?l.default.createElement("img",{src:ee,alt:"",style:{maxWidth:"100%",maxHeight:"100%"}}):l.default.createElement(ot,{ref:V,className:"flex"},l.default.createElement(jt,{width:H,height:Y,instruction:J.captureFailed?Ie.captureFailedText:J.capturing?null==Ie?void 0:Ie.capturingText:Ie.instructionText,portraitGuidesImageUrl:O.portraitGuidesImageUrl,landscapeGuidesImageUrl:O.landscapeGuidesImageUrl,isMirrored:!(null===(r=ae.current)||void 0===r?void 0:r.isRearFacing),borderColor:J.isGoodFrame?U.guideBoxSatisfiedColor:U.guideBoxUnsatisfiedColor}),z&&J.detectedObjects.length>0&&l.default.createElement(Qo,{$flipX:!(null===(o=ae.current)||void 0===o?void 0:o.isRearFacing)},J.detectedObjects.map((function(e,t){var n;return l.default.createElement(ri,{key:t,obj:e,scaling:Re,flipX:!(null===(n=ae.current)||void 0===n?void 0:n.isRearFacing)})}))),z&&l.default.createElement(Zo,null,ae.current?l.default.createElement(l.default.Fragment,null,"✅ Camera: ",ae.current.label," (",ae.current.width,"x",ae.current.height,")"):"❌ Camera not ready",l.default.createElement("br",null),J.frameCaptureRate>.75?"✅":"👎"," Frame Rate:"," ",Math.round(1e3*(J.frameCaptureRate+Number.EPSILON))/1e3," ","fps (",be,"ms doc detect, ",ye,"ms focus)",l.default.createElement("br",null),fe?l.default.createElement(l.default.Fragment,null,J.documentDetectionThresholdMet?"✅":"❌"," Document Score: ",J.documentDetectionScore," (",J.documentType,")",l.default.createElement("br",null),J.documentInBounds?"✅":"❌"," Document In Bounds",l.default.createElement("br",null),J.focusThresholdMet?"✅":"❌"," Focus Score:"," ",J.focusScore,l.default.createElement("br",null),J.goodFramesThresholdMet?"✅":"❌"," Good Frame Count:"," ",J.goodFramesCount,"/",J.goodFramesThreshold,T&&J.autoCaptureBarcodeRequired?l.default.createElement(l.default.Fragment,null,l.default.createElement("br",null),J.barcodeResult?"✅":"❌"," Barcode Scanned (",zt()?"Native":"ZXing",","," ",J.barcodeScanFailedAttempts,"/",J.maxBarcodeScanAttempts," failed attempts)"):null):l.default.createElement(l.default.Fragment,null,"❌ Models not ready")),l.default.createElement(di,{onClick:F},"×"))},Ai=function(e){return e?Math.abs((new Date).getTime()-e.getTime()):0},Ii=function(e){var n,r,o=e.assets,i=void 0===o?{}:o,a=e.colors,s=void 0===a?{}:a,c=e.verbiage,u=void 0===c?{}:c,d=t.useContext(tn).retryCameraAccess;i.imageUrl||(i.imageUrl=Mo+"/camera-disable-icon.png"),s.retryBtn||(s.retryBtn={}),(n=s.retryBtn).backgroundColor||(n.backgroundColor="#ea8557"),(r=s.retryBtn).textColor||(r.textColor="white");var h=xi(u,{headingText:"Your camera permission is disabled",descriptionText:"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.",retryBtnText:"Retry"});return l.default.createElement(ct,null,l.default.createElement("div",{style:{display:"flex",height:"100%"}},l.default.createElement(ut,{style:{maxWidth:500,height:"auto",margin:"auto"}},l.default.createElement(dt,{style:{flexGrow:0}},l.default.createElement("img",{src:i.imageUrl,alt:""})),l.default.createElement("h3",null,h.headingText),l.default.createElement("p",{style:{lineHeight:1.5,marginBottom:50}},h.descriptionText),l.default.createElement(kt,{onClick:d,colors:s.retryBtn,style:{width:200,marginLeft:"auto",marginRight:"auto"},finished:!0},h.retryBtnText))))},Ri=function(e){var n=e.onDismissed,r=e.assets,o=void 0===r?{}:r,i=e.colors,a=void 0===i?{}:i,s=e.verbiage,c=void 0===s?{}:s,u=t.useContext(No).ready,d=t.useContext(tn),h=d.cameraReady,f=d.cameraAccessDenied,p=d.iphoneContinuityCameraAvailable,g=d.setIphoneContinuityCameraAllowed,m=t.useState(!1),v=m[0],b=m[1];o.instructionImageUrl||(o.instructionImageUrl="".concat(Mo,"/WebSDK-Instruction-DL-Capture-3-Portrait.png"));var y=xi(c,{headingText:"Use your device camera to capture your ID",useContinuityCameraText:"Use your iPhone as a webcam",modelsWarmingUpText:"Models warming up...",cameraInitializingText:"Camera initializing...",continueText:"Continue"});return t.useEffect((function(){if(u&&h)return function(){return null};var e=setTimeout((function(){b(!1)}),500);return function(){clearTimeout(e)}}),[h,u]),v?l.default.createElement(l.default.Fragment,null):f?l.default.createElement(Ii,{assets:o.cameraAccessDenied,colors:a.cameraAccessDenied,verbiage:c.cameraAccessDenied}):l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",null,y.headingText),l.default.createElement(dt,{style:{pointerEvents:"none"}},l.default.createElement("img",{alt:y.headingText,src:o.instructionImageUrl})),l.default.createElement("div",{style:{paddingTop:26,height:48,marginTop:-48}},p&&l.default.createElement(l.default.Fragment,null,l.default.createElement("input",{id:"use-continuity-camera",type:"checkbox",defaultChecked:!0,style:{marginRight:8},onChange:function(e){g(e.target.checked)}}),l.default.createElement("label",{htmlFor:"use-continuity-camera"},y.useContinuityCameraText))),l.default.createElement(kt,{disabled:!h||!u,finished:u&&h,colors:a.continueBtn,style:{marginTop:8},onClick:function(){b(!0),null==n||n()}},h&&u?y.continueText:u?y.cameraInitializingText:y.modelsWarmingUpText)))},Di=function(e){var n,r=e.assets,o=void 0===r?{}:r,i=e.verbiage,a=void 0===i?{}:i,s=Bt(),c=s.ref,u=s.width,d=void 0===u?1:u,h=s.height,f=void 0===h?1:h,p=t.useContext(tn).cameraRef;o.frontPortraitGuidesImageUrl||(o.frontPortraitGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Front-SVG-Portrait-2.svg")),o.frontLandscapeGuidesImageUrl||(o.frontLandscapeGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Front-SVG-Landscape-2.svg")),o.backPortraitGuidesImageUrl||(o.backPortraitGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Back-SVG-Portrait-2.svg")),o.backLandscapeGuidesImageUrl||(o.backLandscapeGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Back-SVG-Landscape-2.svg"));var g=function(e,n){var r=xe(),o=r.t,i=r.i18n;return t.useMemo((function(){return wi(o,i.language,e,n)}),[n,i.language,o,e])}(a.instructionText,"Please flip your ID card..."),v=Ut()?0:50,b=!(null===(n=p.current)||void 0===n?void 0:n.isRearFacing),y=t.useContext(Ot),w=y.orientation,x=y.wrapperRef,E=y.wrapperWidth,S=y.wrapperHeight,k=y.imageAspectRatio,C=y.wrapperAspectRatio,T=y.onImageLoaded,A=y.setDimensions;t.useEffect((function(){A({width:d,height:f})}),[f,A,d]);var I={height:S-2*v-8};k>=C&&(I={width:E-2*v-8});var R=t.useState(1),D=R[0],_=R[1],F=t.useState(0),M=F[0],L=F[1],P=["rotateY(".concat(M,"deg)")];b&&P.push("scaleX(-1)");var B=["rotateY(".concat(180-M,"deg)")];return b&&B.push("scaleX(-1)"),t.useEffect((function(){var e=function(){_(1),L(180),setTimeout((function(){_(0),L(0)}),1500)};setTimeout(e,250);var t=setInterval(e,2500);return function(){clearInterval(t)}}),[]),l.default.createElement(ot,{ref:c,className:"flex"},l.default.createElement("div",{ref:x,style:{position:"absolute",zIndex:1e3,width:"100%",height:"100%"}},l.default.createElement("div",{style:{display:"flex",flexFlow:"column nowrap",height:"100%"}},l.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"}},l.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12}},g)),l.default.createElement("div",{style:{position:"relative",display:"flex",flexFlow:"row nowrap",alignItems:"center",justifyItems:"center",maxWidth:"calc(100%)",maxHeight:"calc(100% - ".concat(2*v,"px - ").concat(8,"px)")}},l.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:v,flexGrow:1}}),l.default.createElement("div",{style:{maxWidth:"calc(100% - ".concat(2*v,"px - ").concat(8,"px)"),maxHeight:f-2*v-8}},l.default.createElement("div",{style:{position:"relative",border:"".concat(4,"px solid ").concat("white")}},l.default.createElement("img",{src:"portrait"===w?o.frontPortraitGuidesImageUrl:o.frontLandscapeGuidesImageUrl,alt:"",onLoad:T,style:m({backfaceVisibility:"hidden",transition:"transform ".concat(D,"s"),transform:P.join(" "),transformStyle:"preserve-3d",position:"relative",top:0,left:0,display:"block"},I)}),l.default.createElement("img",{src:"portrait"===w?o.backPortraitGuidesImageUrl:o.backLandscapeGuidesImageUrl,alt:"",style:m({backfaceVisibility:"hidden",transition:"transform ".concat(D,"s"),transform:B.join(" "),transformStyle:"preserve-3d",position:"absolute",top:0,left:0,display:"block"},I)}))),l.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:v,flexGrow:1}})),l.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"}},l.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12,opacity:0}},g)))))},_i=function(e){var n,r,o=e.capturedDocuments,i=e.onSubmitClick,a=e.onRetryClick,s=e.colors,c=void 0===s?{}:s,u=e.verbiage,d=void 0===u?{}:u,h=t.useContext(Ye).submissionStatus,f=o.ID_CARD_FRONT,p=o.ID_CARD_BACK,g=o.PASSPORT;c.retryBtn||(c.retryBtn={}),(n=c.retryBtn).backgroundColor||(n.backgroundColor="#ea8557"),(r=c.retryBtn).textColor||(r.textColor="white");var m=xi(d,{headingText:"ID Capture Successful",idCardFrontText:"ID Card Front",idCardBackText:"ID Card Back",passportText:"Passport",instructionText:"Verify the entire ID was captured clearly with no glare.",retryText:"Retry",submittingText:"Submitting...",submitText:"Done"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h1",null,m.headingText),l.default.createElement(dt,null,l.default.createElement(ht,{style:{paddingBottom:40}},f&&l.default.createElement("div",null,l.default.createElement("h3",null,m.idCardFrontText),l.default.createElement("img",{src:f.imageData,alt:m.idCardFrontText,width:f.width,height:f.height})),p&&l.default.createElement("div",null,l.default.createElement("h3",null,m.idCardBackText),l.default.createElement("img",{src:p.imageData,alt:m.idCardBackText,width:p.width,height:p.height})),g&&l.default.createElement("div",null,l.default.createElement("h3",null,m.passportText),l.default.createElement("img",{src:g.imageData,alt:m.passportText,width:g.width,height:g.height})))),l.default.createElement("p",{style:{fontSize:18}},m.instructionText),l.default.createElement("div",{style:{paddingTop:15,textAlign:"center"}},l.default.createElement(kt,{onClick:a,colors:c.retryBtn,style:{marginRight:15},finished:!0},m.retryText),l.default.createElement(kt,{onClick:i,disabled:h===Ve.SUBMITTING,colors:c.doneBtn,finished:!0},h===Ve.SUBMITTING?m.submittingText:m.submitText))))},Fi=function(){var e,n=t.useContext(tn),r=n.videoRef,o=n.setVideoLoaded,i=n.cameraRef;t.useEffect((function(){o(!1)}),[o]),t.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 a=t.useCallback((function(){o(!0)}),[o]);return l.default.createElement(Mi,{autoPlay:!0,playsInline:!0,muted:!0,ref:r,onLoadedData:a,$isRearFacing:null===(e=i.current)||void 0===e?void 0:e.isRearFacing})},Mi=d.default.video(Ei||(Ei=w(["\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 Li(e,n,r){var o=this,i=t.useState(!1),a=i[0],s=i[1];return t.useEffect((function(){n&&e&&("function"==typeof e?v(o,void 0,void 0,(function(){return b(this,(function(t){switch(t.label){case 0:return[4,e()];case 1:return t.sent()?null==r||r():s(!0),[2]}}))})):null==r||r())}),[n,r,e]),!e||a}!function(e){e.CAPTURING="CAPTURING",e.COMPLETE="COMPLETE"}(Si||(Si={}));var Pi={captureState:Si.CAPTURING,capturedDocuments:{},requestedDocumentType:Et.ID_CARD_FRONT,currentDocumentType:Et.NONE,differentDocumentTypeDetections:0,barcodeResult:null},Bi=function(e,t){var n;switch(t.type){case"predictionMade":var r=t.payload.prediction;return(o=m(m({},e),{currentDocumentType:r.detectedDocumentType})).currentDocumentType===e.requestedDocumentType&&(o.differentDocumentTypeDetections=0),"PASSPORT"===r.detectedDocumentType&&"PASSPORT"!==e.requestedDocumentType&&(o.requestedDocumentType=Et.PASSPORT),"PASSPORT"===e.requestedDocumentType&&r.passportDetectionScore<.3&&(o.requestedDocumentType=Et.ID_CARD_FRONT),o;case"barcodeScanned":return m(m({},e),{barcodeResult:t.payload.result});case"imageCaptured":var o=m(m({},e),{capturedDocuments:m(m({},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?o.captureState=Si.COMPLETE:o.requestedDocumentType=Et.ID_CARD_FRONT:o.requestedDocumentType=Et.ID_CARD_BACK,o;case"reset":return m({},Pi)}},Oi=function(e){var n,r,o,i,a,s,c,u,d,h,f=e.onSuccess,p=e.autoCaptureEnabled,g=void 0===p||p,m=e.autoCaptureGoodFramesRequired,y=void 0===m?3:m,w=e.autoCaptureBarcodeRequired,x=void 0===w?"mobile":w,E=e.barcodeScanningEnabled,S=void 0!==E&&E,k=e.idCardAutoCaptureScoreThreshold,C=void 0===k?.8:k,T=e.passportAutoCaptureScoreThreshold,A=void 0===T?.75:T,I=e.mrzDetectionScoreThreshold,R=void 0===I?.25:I,D=e.idCardFocusScoreThreshold,_=void 0===D?.3:D,F=e.passportFocusScoreThreshold,M=void 0===F?.3:F,L=e.skipSuccessScreen,P=void 0!==L&&L,B=e.assets,O=void 0===B?{}:B,N=e.colors,U=void 0===N?{}:N,j=e.verbiage,G=void 0===j?{}:j,$=e.debugMode,z=void 0!==$&&$,q=t.useReducer(Bi,Pi),V=q[0],W=q[1],H=t.useContext(tn).releaseCameraAccess,K=t.useState(!1),Y=K[0],X=K[1],J=t.useContext(Ye),Z=J.submissionStatus,Q=J.submissionResponse,ee=J.setIdFrontImage,te=J.setIdBackImage,ne=J.setPassportImage,re=J.logIdFrontCaptureAttempt,oe=J.logIdBackCaptureAttempt,ie=t.useRef();t.useEffect((function(){ie.current=new Date}),[V.capturedDocuments.length]);var ae=t.useCallback((function(e){var t;e.operationTime=(new Date).getTime()-(null!==(t=ie.current)&&void 0!==t?t:new Date).getTime(),"ID_CARD_BACK"===V.requestedDocumentType?oe(e):re(e)}),[oe,re,V.requestedDocumentType]),se=t.useCallback((function(e){W({type:"predictionMade",payload:{prediction:e}})}),[]),le=t.useCallback((function(e){W({type:"barcodeScanned",payload:{result:e}})}),[]),ce=t.useCallback((function(e,t,n,r){ae(r),W({type:"imageCaptured",payload:{imageData:e,width:t,height:n}})}),[ae]),ue=t.useCallback((function(){return v(void 0,void 0,void 0,(function(){var e,t,n,r,o,i,a,s,l;return b(this,(function(c){switch(c.label){case 0:return t=V.capturedDocuments.ID_CARD_BACK,n=V.capturedDocuments.PASSPORT,(o=e=V.capturedDocuments.ID_CARD_FRONT)?[4,Qe(e.imageData)]:[3,2];case 1:o=c.sent(),c.label=2;case 2:return r=o,(a=t)?[4,Qe(t.imageData)]:[3,4];case 3:a=c.sent(),c.label=4;case 4:return i=a,(l=n)?[4,Qe(n.imageData)]:[3,6];case 5:l=c.sent(),c.label=6;case 6:return s=l,ee(r),te(i),ne(s),H(),setTimeout((function(){null==f||f({idFrontImage:r,idBackImage:i,passportImage:s})}),0),[2]}}))}))}),[f,H,te,ee,ne,V.capturedDocuments]),de=Li(P,V.captureState===Si.COMPLETE,ue),he=t.useCallback((function(){W({type:"reset"})}),[]),fe=t.useState(0),pe=fe[0],ge=fe[1],me=t.useCallback((function(){X(!1),ge((function(e){return e+1})),W({type:"reset"})}),[]);t.useEffect((function(){Z!==Ve.READY&&H()}),[H,Z]),O.idCardFront||(O.idCardFront={}),(n=O.idCardFront).portraitGuidesImageUrl||(n.portraitGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Front-SVG-Portrait-2.svg")),(r=O.idCardFront).landscapeGuidesImageUrl||(r.landscapeGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Front-SVG-Landscape-2.svg")),O.idCardBack||(O.idCardBack={}),(o=O.idCardBack).portraitGuidesImageUrl||(o.portraitGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Back-SVG-Portrait-2.svg")),(i=O.idCardBack).landscapeGuidesImageUrl||(i.landscapeGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Back-SVG-Landscape-2.svg")),O.passport||(O.passport={}),(a=O.passport).portraitGuidesImageUrl||(a.portraitGuidesImageUrl="".concat(Mo,"/Shieldout-Passport-Front-SVG-Portrait-2.svg")),(s=O.passport).landscapeGuidesImageUrl||(s.landscapeGuidesImageUrl="".concat(Mo,"/Shieldout-Passport-Front-SVG-Landscape-2.svg")),O.flipIdPrompt||(O.flipIdPrompt={}),(c=O.flipIdPrompt).frontPortraitGuidesImageUrl||(c.frontPortraitGuidesImageUrl=O.idCardFront.portraitGuidesImageUrl),(u=O.flipIdPrompt).frontLandscapeGuidesImageUrl||(u.frontLandscapeGuidesImageUrl=O.idCardFront.landscapeGuidesImageUrl),(d=O.flipIdPrompt).backPortraitGuidesImageUrl||(d.backPortraitGuidesImageUrl=O.idCardBack.portraitGuidesImageUrl),(h=O.flipIdPrompt).backLandscapeGuidesImageUrl||(h.backLandscapeGuidesImageUrl=O.idCardBack.landscapeGuidesImageUrl);var ve=xi(G.idCardFront,{instructionText:"Scan the front of ID",processingIdCardText:"ID card front captured."}),be=xi(G.idCardBack,{instructionText:"Scan the back of ID"}),ye=xi(G.idCardBack,{instructionText:"Scan the ID page of passport"});return Q?l.default.createElement(ot,{className:"padded"},l.default.createElement("h1",null,"Submission completed!"),l.default.createElement("pre",null,JSON.stringify(Q,null,2))):l.default.createElement(ot,{className:"flex"},V.captureState!==Si.COMPLETE&&l.default.createElement(Fi,null),Y&&function(){var e=Object.keys(V.capturedDocuments).length;switch(V.requestedDocumentType){case Et.ID_CARD_FRONT:return l.default.createElement(Ti,{key:"capture".concat(e),requiredDocumentType:V.requestedDocumentType,autoCaptureEnabled:g,autoCaptureScoreThreshold:C,autoCaptureGoodFramesRequired:y,autoCaptureBarcodeRequired:x,barcodeScanningEnabled:!1,mrzDetectionScoreThreshold:R,focusScoreThreshold:_,onPrediction:se,onCapture:ce,onExit:me,processingDelay:3500,assets:O.idCardFront,colors:U,verbiage:ve,debugMode:z,processingScreen:l.default.createElement(Di,{assets:O.flipIdPrompt,verbiage:G.flipIdPrompt})});case Et.ID_CARD_BACK:return l.default.createElement(Ti,{key:"capture".concat(e),requiredDocumentType:V.requestedDocumentType,autoCaptureEnabled:g,autoCaptureScoreThreshold:C,autoCaptureGoodFramesRequired:y,autoCaptureBarcodeRequired:x,barcodeScanningEnabled:S,mrzDetectionScoreThreshold:R,focusScoreThreshold:_,onPrediction:se,onBarcodeScanned:le,onCapture:ce,onExit:me,assets:O.idCardBack,colors:U,verbiage:be,debugMode:z});case Et.PASSPORT:return l.default.createElement(Ti,{key:"capture".concat(e),requiredDocumentType:V.requestedDocumentType,autoCaptureEnabled:g,autoCaptureScoreThreshold:A,mrzDetectionScoreThreshold:R,autoCaptureGoodFramesRequired:y,autoCaptureBarcodeRequired:x,barcodeScanningEnabled:!1,focusScoreThreshold:M,onPrediction:se,onBarcodeScanned:le,onCapture:ce,onExit:me,assets:O.passport,colors:U,verbiage:ye,debugMode:z});default:return null}}(),!Y&&l.default.createElement(Ri,{key:pe,assets:O.loadingOverlay,colors:U.loadingOverlay,verbiage:G.loadingOverlay,onDismissed:function(){X(!0)}}),V.captureState===Si.COMPLETE&&de&&l.default.createElement(_i,{capturedDocuments:V.capturedDocuments,barcodeResult:V.barcodeResult,onSubmitClick:ue,onRetryClick:he,colors:U.success,verbiage:G.success}))},Ni=function(e){var t=e.borderWidth,n=e.borderColor;return l.default.createElement("div",{style:{position:"absolute",zIndex:1e3,width:"100%",height:"100%",display:"flex"}},l.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"}}))},Ui=self;function ji(){throw Error("Invalid UTF8")}function Gi(e,t){return t=String.fromCharCode.apply(null,t),null==e?t:e+t}let $i,zi;const qi="undefined"!=typeof TextDecoder;let Vi;const Wi="undefined"!=typeof TextEncoder;function Hi(e){if(Wi)e=(Vi||=new TextEncoder).encode(e);else{let n=0;const r=new Uint8Array(3*e.length);for(let o=0;o<e.length;o++){var t=e.charCodeAt(o);if(128>t)r[n++]=t;else{if(2048>t)r[n++]=t>>6|192;else{if(55296<=t&&57343>=t){if(56319>=t&&o<e.length){const i=e.charCodeAt(++o);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}o--}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 Ki,Yi;e:{for(var Xi=["CLOSURE_FLAGS"],Ji=Ui,Zi=0;Zi<Xi.length;Zi++)if(null==(Ji=Ji[Xi[Zi]])){Yi=null;break e}Yi=Ji}var Qi,ea=Yi&&Yi[610401301];Ki=null!=ea&&ea;const ta=Ui.navigator;function na(e){return!!Ki&&!!Qi&&Qi.brands.some((({brand:t})=>t&&-1!=t.indexOf(e)))}function ra(e){var t;return(t=Ui.navigator)&&(t=t.userAgent)||(t=""),-1!=t.indexOf(e)}function oa(){return!!Ki&&!!Qi&&0<Qi.brands.length}function ia(){return oa()?na("Chromium"):(ra("Chrome")||ra("CriOS"))&&!(!oa()&&ra("Edge"))||ra("Silk")}Qi=ta&&ta.userAgentData||null;var aa=!oa()&&(ra("Trident")||ra("MSIE"));!ra("Android")||ia(),ia(),ra("Safari")&&(ia()||!oa()&&ra("Coast")||!oa()&&ra("Opera")||!oa()&&ra("Edge")||(oa()?na("Microsoft Edge"):ra("Edg/"))||oa()&&na("Opera"));var sa={},la=null;function ca(){if(!la){la={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=e.concat(t[n].split(""));sa[n]=r;for(var o=0;o<r.length;o++){var i=r[o];void 0===la[i]&&(la[i]=o)}}}}var ua="undefined"!=typeof Uint8Array,da=!aa&&"function"==typeof btoa;function ha(e){if(!da){var t;void 0===t&&(t=0),ca(),t=sa[t];var n=Array(Math.floor(e.length/3)),r=t[64]||"";let l=0,c=0;for(;l<e.length-2;l+=3){var o=e[l],i=e[l+1],a=e[l+2],s=t[o>>2];n[c++]=s+(o=t[(3&o)<<4|i>>4])+(i=t[(15&i)<<2|a>>6])+(a=t[63&a])}switch(s=0,a=r,e.length-l){case 2:a=t[(15&(s=e[l+1]))<<2]||r;case 1:n[c]=t[(e=e[l])>>2]+t[(3&e)<<4|s>>4]+a+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 fa=/[-_.]/g,pa={"-":"+",_:"/",".":"="};function ga(e){return pa[e]||""}function ma(e){if(!da)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),o=0;return function(e,t){function n(t){for(;r<e.length;){var n=e.charAt(r++),o=la[n];if(null!=o)return o;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return t}ca();for(var r=0;;){var o=n(-1),i=n(0),a=n(64),s=n(64);if(64===s&&-1===o)break;t(o<<2|i>>4),64!=a&&(t(i<<4&240|a>>2),64!=s&&t(a<<6&192|s))}}(e,(function(e){r[o++]=e})),o!==n?r.subarray(0,o):r}(e);fa.test(e)&&(e=e.replace(fa,ga)),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 va(e){return ua&&null!=e&&e instanceof Uint8Array}let ba;function ya(){return ba||=new Uint8Array(0)}var wa={};let xa;function Ea(e){if(e!==wa)throw Error("illegal external caller")}function Sa(){return xa||=new Ca(null,wa)}function ka(e){Ea(wa);var t=e.N;return null==(t=null==t||va(t)?t:"string"==typeof t?ma(t):null)?t:e.N=t}var Ca=class{constructor(e,t){if(Ea(t),this.N=e,null!=e&&0===e.length)throw Error("ByteString should be constructed with non-empty values")}ha(){const e=ka(this);return e?new Uint8Array(e):ya()}};function Ta(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function Aa(){return Error("Failed to read varint, encoding is invalid.")}function Ia(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function Ra(e){return 0==e.length?Sa():new Ca(e,wa)}function Da(e){if("string"==typeof e)return{buffer:ma(e),H:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),H:!1};if(e.constructor===Uint8Array)return{buffer:e,H:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),H:!1};if(e.constructor===Ca)return{buffer:ka(e)||ya(),H:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),H:!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 _a="function"==typeof Uint8Array.prototype.slice;let Fa,Ma=0,La=0;function Pa(e){const t=0>e;let n=(e=Math.abs(e))>>>0;if(e=Math.floor((e-n)/4294967296),t){const[t,r]=ja(n,e);e=r,n=t}Ma=n>>>0,La=e>>>0}function Ba(e){const t=Fa||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),La=0,Ma=t.getUint32(0,!0)}function Oa(e,t){return 4294967296*t+(e>>>0)}function Na(e,t){const n=2147483648&t;return n&&(t=~t>>>0,0==(e=1+~e>>>0)&&(t=t+1>>>0)),e=Oa(e,t),n?-e:e}function Ua(e){if(16>e.length)Pa(Number(e));else if("function"==typeof BigInt)e=BigInt(e),Ma=Number(e&BigInt(4294967295))>>>0,La=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+("-"===e[0]);La=Ma=0;const n=e.length;for(let r=t,o=(n-t)%6+t;o<=n;r=o,o+=6){const t=Number(e.slice(r,o));La*=1e6,Ma=1e6*Ma+t,4294967296<=Ma&&(La+=Math.trunc(Ma/4294967296),La>>>=0,Ma>>>=0)}if(t){const[e,t]=ja(Ma,La);Ma=e,La=t}}}function ja(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function Ga(e,t,{R:n=!1}={}){e.R=n,t&&(t=Da(t),e.h=t.buffer,e.s=t.H,e.v=0,e.l=e.h.length,e.g=e.v)}function $a(e,t){if(e.g=t,t>e.l)throw Ia(e.l,t)}function za(e,t){let n,r=0,o=0,i=0;const a=e.h;let s=e.g;do{n=a[s++],r|=(127&n)<<i,i+=7}while(32>i&&128&n);for(32<i&&(o|=(127&n)>>4),i=3;32>i&&128&n;i+=7)n=a[s++],o|=(127&n)<<i;if($a(e,s),128>n)return t(r>>>0,o>>>0);throw Aa()}function qa(e){let t=0,n=e.g;const r=n+10,o=e.h;for(;n<r;){const r=o[n++];if(t|=r,0==(128&r))return $a(e,n),!!(127&t)}throw Aa()}function Va(e){var t=e.h;const n=e.g,r=t[n],o=t[n+1],i=t[n+2];return t=t[n+3],$a(e,e.g+4),(r<<0|o<<8|i<<16|t<<24)>>>0}function Wa(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 Ia(t,e.l-n);return e.g=r,n}function Ha(e,t){if(0==t)return Sa();var n=Wa(e,t);return e.R&&e.s?n=e.h.subarray(n,n+t):(e=e.h,n=n===(t=n+t)?ya():_a?e.slice(n,t):new Uint8Array(e.subarray(n,t))),Ra(n)}var Ka=class{constructor(e,t){this.h=null,this.s=!1,this.g=this.l=this.v=0,Ga(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 Aa();return $a(this,t),r}j(){return this.m()>>>0}A(){var e=Va(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()}},Ya=[];function Xa(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 Ta(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 Ja(e){switch(e.h){case 0:0!=e.h?Ja(e):qa(e.g);break;case 1:$a(e=e.g,e.g+8);break;case 2:if(2!=e.h)Ja(e);else{var t=e.g.j();$a(e=e.g,e.g+t)}break;case 5:$a(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!Xa(e))throw Error("Unmatched start-group tag: stream EOF");if(4==e.h){if(e.m!=t)throw Error("Unmatched end-group tag");break}Ja(e)}break;default:throw Ta(e.h,e.l)}}function Za(e,t,n){const r=e.g.l,o=e.g.j(),i=e.g.g+o;let a=i-r;if(0>=a&&(e.g.l=i,n(t,e,void 0,void 0,void 0),a=i-e.g.g),a)throw Error(`Message parsing ended unexpectedly. Expected to read ${o} bytes, instead read ${o-a} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=i,e.g.l=r,t}function Qa(e){var t=e.g.j(),n=Wa(e=e.g,t);if(e=e.h,qi){var r,o=e;(r=zi)||(r=zi=new TextDecoder("utf-8",{fatal:!0})),e=n+t,o=0===n&&e===o.length?o:o.subarray(n,e);try{var i=r.decode(o)}catch(e){if(void 0===$i){try{r.decode(new Uint8Array([128]))}catch(e){}try{r.decode(new Uint8Array([97])),$i=!0}catch(e){$i=!1}}throw!$i&&(zi=void 0),e}}else{t=(i=n)+t,n=[];let s,l=null;for(;i<t;){var a=e[i++];128>a?n.push(a):224>a?i>=t?ji():(s=e[i++],194>a||128!=(192&s)?(i--,ji()):n.push((31&a)<<6|63&s)):240>a?i>=t-1?ji():(s=e[i++],128!=(192&s)||224===a&&160>s||237===a&&160<=s||128!=(192&(o=e[i++]))?(i--,ji()):n.push((15&a)<<12|(63&s)<<6|63&o)):244>=a?i>=t-2?ji():(s=e[i++],128!=(192&s)||0!=s-144+(a<<28)>>30||128!=(192&(o=e[i++]))||128!=(192&(r=e[i++]))?(i--,ji()):(a=(7&a)<<18|(63&s)<<12|(63&o)<<6|63&r,n.push(55296+((a-=65536)>>10&1023),56320+(1023&a)))):ji(),8192<=n.length&&(l=Gi(l,n),n.length=0)}i=Gi(l,n)}return i}function es(e){const t=e.g.j();return Ha(e.g,t)}function ts(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 ns=[];function rs(e){return e?/^\d+$/.test(e)?(Ua(e),new os(Ma,La)):null:is||=new os(0,0)}var os=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let is;function as(e){return e?/^-?\d+$/.test(e)?(Ua(e),new ss(Ma,La)):null:ls||=new ss(0,0)}var ss=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let ls;function cs(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 us(e,t){for(;127<t;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function ds(e,t){if(0<=t)us(e,t);else{for(let n=0;9>n;n++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function hs(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 fs(e,t){0!==t.length&&(e.l.push(t),e.h+=t.length)}function ps(e,t,n){us(e.g,8*t+n)}function gs(e,t){return ps(e,t,2),t=e.g.end(),fs(e,t),t.push(e.h),t}function ms(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 vs(e,t,n){ps(e,t,2),us(e.g,n.length),fs(e,e.g.end()),fs(e,n)}function bs(e,t,n,r){null!=n&&(t=gs(e,t),r(n,e),ms(e,t))}class ys{constructor(e,t,n){this.g=e,this.h=t,this.l=n}}function ws(e){return Array.prototype.slice.call(e)}const xs="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():void 0;var Es=xs?(e,t)=>{e[xs]|=t}:(e,t)=>{void 0!==e.D?e.D|=t:Object.defineProperties(e,{D:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function Ss(e){const t=Cs(e);1!=(1&t)&&(Object.isFrozen(e)&&(e=ws(e)),As(e,1|t))}var ks=xs?(e,t)=>{e[xs]&=~t}:(e,t)=>{void 0!==e.D&&(e.D&=~t)},Cs=xs?e=>0|e[xs]:e=>0|e.D,Ts=xs?e=>e[xs]:e=>e.D,As=xs?(e,t)=>{e[xs]=t}:(e,t)=>{void 0!==e.D?e.D=t:Object.defineProperties(e,{D:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function Is(){var e=[];return Es(e,1),e}function Rs(e){return Es(e,34),e}function Ds(e,t){As(t,-255&(0|e))}function _s(e,t){As(t,-221&(34|e))}function Fs(e){return 0==(e=e>>11&1023)?536870912:e}var Ms,Ls={};function Ps(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&e.constructor===Object}function Bs(e,t,n){if(null!=e)if("string"==typeof e)e=e?new Ca(e,wa):Sa();else if(e.constructor!==Ca)if(va(e))e=n?Ra(e):e.length?new Ca(new Uint8Array(e),wa):Sa();else{if(!t)throw Error();e=void 0}return e}const Os=[];function Ns(e){if(2&e)throw Error()}As(Os,55),Ms=Object.freeze(Os);class Us{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 Us(this.g,this.h,this.m)}}var js={};let Gs,$s;function zs(e,t){(t=Gs?t[Gs]:void 0)&&(e[Gs]=ws(t))}function qs(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function Vs(e){return null==e?e:"number"==typeof e||"NaN"===e||"Infinity"===e||"-Infinity"===e?Number(e):void 0}function Ws(e){return null==e?e:"boolean"==typeof e||"number"==typeof e?!!e:void 0}function Hs(e){return"number"==typeof e&&Number.isFinite(e)||!!e&&"string"==typeof e&&isFinite(e)}function Ks(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function Ys(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function Xs(e){if("string"!=typeof e)throw Error();return e}function Js(e){if(null!=e&&"string"!=typeof e)throw Error();return e}function Zs(e){return null==e||"string"==typeof e?e:void 0}function Qs(e,t,n,r){var o=!1;return null==e||"object"!=typeof e||(o=Array.isArray(e))||e.M!==Ls?o?(0===(o=n=Cs(e))&&(o|=32&r),(o|=2&r)!==n&&As(e,o),new t(e)):(n?2&r?(e=t[el])?t=e:(Rs((e=new t).u),t=t[el]=e):t=new t:t=void 0,t):e}const el="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():"di";function tl(e){return e}function nl(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 rl,ol,il;function al(e){switch(typeof e){case"boolean":return ol||=[0,void 0,!0];case"number":return 0<e?void 0:0===e?il||=[0,void 0]:[-e,void 0];case"string":return[0,e];case"object":return e}}function sl(e,t){return ll(e,t[0],t[1])}function ll(e,t,n){if(null==e&&(e=rl),rl=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=Cs(e)))return $s&&delete e[$s],e;if(r|=64,n&&(r|=512,n!==e[0]))throw Error();e:{var o=(n=e).length;if(o){const e=o-1;var i=n[e];if(Ps(i)){1024<=(o=e-(t=+!!(512&(r|=256))-1))&&(cl(n,t,i),o=1023),r=-2095105&r|(1023&o)<<11;break e}}t&&(i=+!!(512&r)-1,1024<(t=Math.max(t,o-i))&&(cl(n,i,{}),r|=256,t=1023),r=-2095105&r|(1023&t)<<11)}}return As(e,r),e}function cl(e,t,n){const r=1023+t,o=e.length;for(let i=r;i<o;i++){const r=e[i];null!=r&&r!==n&&(n[i-t]=r)}e.length=r+1,e[r]=n}function ul(e){if(2&e.g)throw Error("Cannot mutate an immutable Map")}var dl=class extends Map{constructor(e,t,n=tl,r=tl){super();let o=Cs(e);o|=64,As(e,o),this.g=o,this.l=t,this.h=n||tl,this.j=this.l?hl:r||tl;for(let i=0;i<e.length;i++){const a=e[i],s=n(a[0],!1,!0);let l=a[1];t?void 0===l&&(l=null):l=r(a[1],!1,!0,void 0,void 0,o),super.set(s,l)}}s(e=fl){return this.m(e)}m(e=fl){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(){ul(this),super.clear()}delete(e){return ul(this),super.delete(this.h(e,!0,!1))}entries(){var e=this.A();return new Us(e,pl,this)}keys(){return this.C()}values(){var e=this.A();return new Us(e,dl.prototype.get,this)}forEach(e,t){super.forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))}set(e,t){return ul(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))}I(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 hl(e,t,n,r,o,i){return e=Qs(e,r,n,i),o&&(e=El(e)),e}function fl(e){return e}function pl(e){return[e,this.get(e)]}function gl(e,t,n,r,o,i){if(null!=e){if(Array.isArray(e))e=o&&0==e.length&&1&Cs(e)?void 0:i&&2&Cs(e)?e:ml(e,t,n,void 0!==r,o,i);else if(Ps(e)){const a={};for(let s in e)a[s]=gl(e[s],t,n,r,o,i);e=a}else e=t(e,r);return e}}function ml(e,t,n,r,o,i){const a=r||n?Cs(e):0;r=r?!!(32&a):void 0;const s=ws(e);for(let e=0;e<s.length;e++)s[e]=gl(s[e],t,n,r,o,i);return n&&(zs(s,e),n(a,s)),s}function vl(e){return gl(e,bl,void 0,void 0,!1,!1)}function bl(e){return e.M===Ls?e.toJSON():e instanceof dl?e.s(vl):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(va(e))return ha(e);if(e instanceof Ca){const t=e.N;return null==t?"":"string"==typeof t?t:e.N=ha(t)}if(e instanceof dl)return e.s()}}return e}(e)}function yl(e,t,n=_s){if(null!=e){if(ua&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var r=Cs(e);return 2&r?e:(t&&=0===r||!!(32&r)&&!(64&r||!(16&r)),t?(As(e,34|r),4&r&&Object.freeze(e),e):ml(e,yl,4&r?_s:n,!0,!1,!0))}return e.M===Ls?e=2&(r=Ts(n=e.u))?e:wl(e,n,r,!0):e instanceof dl&&(n=Rs(e.m(yl)),e=new dl(n,e.l,e.h,e.j)),e}}function wl(e,t,n,r){return e=e.constructor,rl=t=xl(t,n,r),t=new e(t),rl=void 0,t}function xl(e,t,n){const r=n||2&t?_s:Ds,o=!!(32&t);return e=function(e,t,n){const r=ws(e);var o=r.length;const i=256&t?r[o-1]:void 0;for(o+=i?-1:0,t=512&t?1:0;t<o;t++)r[t]=n(r[t]);if(i){t=r[t]={};for(const e in i)t[e]=n(i[e])}return zs(r,e),r}(e,t,(e=>yl(e,o,r))),Es(e,32|(n?2:0)),e}function El(e){const t=e.u,n=Ts(t);return 2&n?wl(e,t,n,!1):e}function Sl(e,t){return kl(e=e.u,Ts(e),t)}function kl(e,t,n,r){if(-1===n)return null;if(n>=Fs(t)){if(256&t)return e[e.length-1][n]}else{var o=e.length;if(r&&256&t&&null!=(r=e[o-1][n]))return r;if((t=n+(+!!(512&t)-1))<o)return e[t]}}function Cl(e,t,n,r){const o=e.u,i=Ts(o);return Ns(i),Tl(o,i,t,n,r),e}function Tl(e,t,n,r,o){var i=Fs(t);if(n>=i||o){if(o=t,256&t)i=e[e.length-1];else{if(null==r)return;i=e[i+(+!!(512&t)-1)]={},o|=256}i[n]=r,o!==t&&As(e,o)}else e[n+(+!!(512&t)-1)]=r,256&t&&n in(e=e[e.length-1])&&delete e[n]}function Al(e,t,n,r,o){var i=2&t;let a=kl(e,t,n,o);Array.isArray(a)||(a=Ms);const s=!(2&r),l=!(1&r);r=!!(32&t);let c=Cs(a);return 0!==c||!r||i||s?1&c||(c|=1,As(a,c)):(c|=33,As(a,c)),i?(2&c||Rs(a),l&&Object.freeze(a)):(i=2&c,l&&i?(a=ws(a),i=1,r&&!s&&(i|=32),As(a,i),Tl(e,t,n,a,o)):s&&32&c&&!i&&ks(a,32)),a}function Il(e,t){const n=Ts(e=e.u),r=kl(e,n,t),o=Vs(r);return null!=o&&o!==r&&Tl(e,n,t,o),o}function Rl(e){const t=Ts(e=e.u),n=kl(e,t,1),r=Bs(n,!0,!!(34&t));return null!=r&&r!==n&&Tl(e,t,1,r),r}function Dl(e,t,n){const r=Ts(e=e.u),o=2&r;let i=Al(e,r,t,1),a=Cs(i);if(!(4&a)){Object.isFrozen(i)&&(i=ws(i),As(i,a=-3&a|32),Tl(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),a|=21,o?a|=34:a&=-33,As(i,a),2&a&&Object.freeze(i)}return!o&&(2&a||Object.isFrozen(i))&&(i=ws(i),As(i,-35&a),Tl(e,r,t,i)),i}let _l;function Fl(){return _l??=new dl(Rs([]),void 0,void 0,void 0,js)}function Ml(e){e=ws(e);for(let t=0;t<e.length;t++){const n=e[t]=ws(e[t]);Array.isArray(n[1])&&(n[1]=Rs(n[1]))}return e}function Ll(e,t,n){{const r=Ts(e=e.u);if(Ns(r),null==n)Tl(e,r,t);else{if(!(4&Cs(n))){Object.isFrozen(n)&&(n=ws(n));for(let e=0;e<n.length;e++)n[e]=Xs(n[e]);As(n,5)}Tl(e,r,t,n)}}}function Pl(e,t){return Bl(e=e.u,Ts(e),Cd)===t?t:-1}function Bl(e,t,n){let r=0;for(let o=0;o<n.length;o++){const i=n[o];null!=kl(e,t,i)&&(0!==r&&Tl(e,t,r),r=i)}return r}function Ol(e,t,n,r){const o=Ts(e);Ns(o);const i=kl(e,o,n,r);let a;if(null!=i&&i.M===Ls)return(t=El(i))!==i&&Tl(e,o,n,t,r),t.u;if(Array.isArray(i)){const e=Cs(i);a=2&e?xl(i,e,!1):i,a=sl(a,t)}else a=sl(void 0,t);return a!==i&&Tl(e,o,n,a,r),a}function Nl(e,t,n,r){const o=Ts(e=e.u),i=kl(e,o,n,r);return(t=Qs(i,t,!1,o))!==i&&null!=t&&Tl(e,o,n,t,r),t}function Ul(e,t,n,r=!1){if(null==(t=Nl(e,t,n,r)))return t;const o=Ts(e=e.u);if(!(2&o)){const i=El(t);i!==t&&Tl(e,o,n,t=i,r)}return t}function jl(e,t,n,r,o){var i=!!(2&t),a=Al(e,t,r,1),s=a===Ms;if(s&&2!==o)return a;if(s||!(4&Cs(a))){var l=a;a=!!(2&t),s=!!(2&Cs(l)),i=l,!a&&s&&(l=ws(l));var c=t|((s=s||void 0)?2:0),u=s;s=!1;let d=0,h=0;for(;d<l.length;d++){const e=Qs(l[d],n,!1,c);if(null==e)continue;const t=!!(2&Cs(e.u));u=u||t,s=s||!t,l[h++]=e}return h<d&&(l.length=h),c=5|(l=Cs(n=l)),u=u?-9&c:8|c,l!=(u=s?-17&u:16|u)&&(Object.isFrozen(n)&&(n=ws(n)),As(n,u)),i!==(l=n)&&Tl(e,t,r,l),(a&&2!==o||1===o)&&Object.freeze(l),l}return 3===o||(i?2===o&&(o=Cs(a),a=ws(a),As(a,o),Tl(e,t,r,a)):(i=Object.isFrozen(a),1===o?i||Object.freeze(a):(n=-33&(o=Cs(a)),i||2&o?(a=ws(a),As(a,-3&n),Tl(e,t,r,a)):o!==n&&As(a,n)))),a}function Gl(e,t,n){var r=e.u;const o=Ts(r);if(t=jl(r,o,t,n,(e=!!(2&o))?1:2),!(e||8&Cs(t))){for(n=0;n<t.length;n++)(e=t[n])!==(r=El(e))&&(t[n]=r);Es(t,8)}return t}function $l(e,t,n,r,o){return null==r&&(r=void 0),Cl(e,n,r,o)}function zl(e,t,n,r){null==r&&(r=void 0);const o=Ts(e=e.u);Ns(o),(n=Bl(e,o,n))&&n!==t&&null!=r&&Tl(e,o,n),Tl(e,o,t,r)}function ql(e,t,n){const r=Ts(e=e.u);Ns(r),e=jl(e,r,t,1,2),t=null!=n?n:new t,e.push(t),2&Cs(t.u)?ks(e,8):ks(e,16)}function Vl(e,t){return Ks(Sl(e,t))}function Wl(e){return null==(e=Sl(e,2))||Hs(e)?e:void 0}function Hl(e,t){return Zs(Sl(e,t))}function Kl(e){return e??0}function Yl(e,t){return Kl(Il(e,t))}function Xl(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}Cl(e,t,n)}function Jl(e,t,n){if(null!=n){if("number"!=typeof n)throw qs(e=Error(),"warning"),e;if(!Number.isFinite(n)){const e=Error();qs(e,"incident"),function(e){Ui.setTimeout((()=>{throw e}),0)}(e)}}Cl(e,t,n)}function Zl(e,t,n){if(null!=n&&"number"!=typeof n)throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);Cl(e,t,n)}function Ql(e,t,n){n=Xs(n);const r=Ts(e=e.u);Ns(r),Al(e,r,t,2).push(n)}function ec(e,t,n){t.g?t.m(e,t.g,t.h,n,!0):t.m(e,t.h,n,!0)}dl.prototype.toJSON=void 0;var tc=class{constructor(e,t){this.u=ll(e,t)}toJSON(){return nc(this,ml(this.u,bl,void 0,void 0,!1,!1),!0)}l(){var e=xh;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 wl(this,e,Ts(e),!1)}H(){return!!(2&Cs(this.u))}};function nc(e,t,n){var r=e.constructor.B,o=Fs(Ts(n?e.u:t)),i=!1;if(r){if(!n){var a;if((t=ws(t)).length&&Ps(a=t[t.length-1]))for(i=0;i<r.length;i++)if(r[i]>=o){Object.assign(t[t.length-1]={},a);break}i=!0}var s;o=t,n=!n,e=Fs(a=Ts(e.u)),a=+!!(512&a)-1;for(let t=0;t<r.length;t++){var l=r[t];if(l<e){var c=o[l+=a];null==c?o[l]=n?Ms:Is():n&&c!==Ms&&Ss(c)}else{if(!s){var u=void 0;o.length&&Ps(u=o[o.length-1])?s=u:o.push(s={})}c=s[l],null==s[l]?s[l]=n?Ms:Is():n&&c!==Ms&&Ss(c)}}}if(!(r=t.length))return t;let d,h;if(Ps(s=t[r-1])){e:{var f=s;u={},o=!1;for(let e in f)n=f[e],Array.isArray(n)&&n!=n&&(o=!0),null!=n?u[e]=n:o=!0;if(o){for(let e in u){f=u;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 rc(e){return{ca:Zc,U:e}}function oc(e,t){if(Array.isArray(t)){var n=Cs(t);if(4&n)return t;for(var r=0,o=0;r<t.length;r++){const n=e(t[r]);null!=n&&(t[o++]=n)}return o<r&&(t.length=o),As(t,5|n),2&n&&Object.freeze(t),t}}tc.prototype.M=Ls,tc.prototype.toString=function(){return nc(this,this.u,!1).toString()};const ic=Symbol();function ac(e){let t=e[ic];if(!t){const n=hc(e),r=Sc(e),o=r.h;t=o?(e,t)=>o(e,t,r):(e,t)=>{for(;Xa(t)&&4!=t.h;){var o=t.m,i=r[o];if(!i){var a=r.g;a&&(a=a[o])&&(i=r[o]=sc(a))}i&&i(t,e,o)||(o=(i=t).l,Ja(i),i.aa?i=void 0:(a=i.g.g-o,i.g.g=o,i=Ha(i.g,a)),o=e,i&&(Gs||=Symbol(),(a=o[Gs])?a.push(i):o[Gs]=[i]))}for(const t in n){e[$s||=Symbol()]=n;break}},e[ic]=t}return t}function sc(e){const t=function(e){if(e=e.U)return ac(e)}(e),n=e.ca.g;if(t){const r=Sc(e.U).L;return(e,o,i)=>n(e,o,i,r,t)}return(e,t,r)=>n(e,t,r)}const lc=Symbol();function cc(e,t,n,r){let o;if(r){const t=r[lc];o=t?t.L:al(r[0]),n[e]=t??r}o&&o===ol?((t=n.xa)||(n.xa=t=[]),t.push(e)):t.l&&((t=n.Ba)||(n.Ba=t=[]),t.push(e))}function uc(e,t,n,r){cc(e,t,r)}function dc(e,t,n,r,o){cc(e,t,o,n)}function hc(e){let t=e[lc];return t||(t=e[lc]={},fc(e,t,uc,dc,t))}function fc(e,t,n,r,o){t.L=al(e[0]);let i=1;if(e.length>i&&!(e[i]instanceof ys)){var a=e[i++];if(Array.isArray(a))return t.h=a[0],t.g=a[1],t;t.g=a}for(a=0;i<e.length;){var s=e[i++],l=e[i];for("number"==typeof l?(i++,a+=l):a++,l=i;l<e.length&&!(e[l]instanceof ys);)l++;if(l-=i){var c=e,u=i,d=c[u];if("function"==typeof d&&(d=d(),c[u]=d),(c=Array.isArray(d))&&!(c=wc in d||mc in d)&&(c=0<d.length)){const e=al(u=(c=d)[0]);null!=e&&e!==u&&(c[0]=e),c=null!=e}(d=c?d:void 0)?(i++,1===l?void 0!==(s=r(a,s,d,void 0,o))&&(t[a]=s):void 0!==(s=r(a,s,d,e[i++],o))&&(t[a]=s)):void 0!==(s=n(a,s,e[i++],o))&&(t[a]=s)}else void 0!==(s=n(a,s,void 0,o))&&(t[a]=s)}return t}const pc=Symbol();function gc(e){let t=e[pc];if(!t){const n=yc(e);t=(e,t)=>Cc(e,t,n),e[pc]=t}return t}const mc=Symbol();function vc(e,t){return t.h}function bc(e,t,n){let r,o;const i=t.h;return(e,t,a)=>i(e,t,a,o||=yc(n).L,r||=gc(n))}function yc(e){let t=e[mc];return t||(t=fc(e,e[mc]={},vc,bc),wc in e&&mc in e&&(e.length=0),t)}const wc=Symbol();function xc(e,t,n){const r=t.g;return n?(e,t,o)=>r(e,t,o,n):r}function Ec(e,t,n,r){const o=t.g;let i,a;return(e,t,s)=>o(e,t,s,a||=Sc(n).L,i||=ac(n),r)}function Sc(e){let t=e[wc];return t||(hc(e),t=fc(e,e[wc]={},xc,Ec),wc in e&&mc in e&&(e.length=0),t)}function kc(e,t){var n=e[t];if(n)return n;if((n=e.g)&&(n=n[t])){var r=n.U,o=n.ca.h;if(r){const e=gc(r),t=yc(r).L;n=(n,r,i)=>o(n,r,i,t,e)}else n=o;return e[t]=n}}function Cc(e,t,n){for(var r=Ts(e),o=+!!(512&r)-1,i=e.length,a=512&r?1:0,s=i+(256&r?-1:0);a<s;a++){const r=e[a];if(null==r)continue;const i=a-o,s=kc(n,i);s&&s(t,r,i)}if(256&r){r=e[i-1];for(let e in r)o=+e,Number.isNaN(o)||null!=(i=r[e])&&(s=kc(n,o))&&s(t,i,o)}if(e=Gs?e[Gs]:void 0)for(fs(t,t.g.end()),n=0;n<e.length;n++)fs(t,ka(e[n])||ya())}function Tc(e,t){return new ys(e,t,!1)}function Ac(e,t){return new ys(e,t,!0)}function Ic(e,t,n){Tl(e,Ts(e),t,n)}var Rc=Tc((function(e,t,n,r,o){return 2===e.h&&(e=Za(e,sl([void 0,void 0],r),o),Ns(r=Ts(t)),(o=kl(t,r,n))instanceof dl?0!=(2&o.g)?((o=o.m()).push(e),Tl(t,r,n,o)):o.I(e):Array.isArray(o)?(2&Cs(o)&&Tl(t,r,n,o=Ml(o)),o.push(e)):Tl(t,r,n,[e]),!0)}),(function(e,t,n,r,o){if(t instanceof dl)t.forEach(((t,i)=>{bs(e,n,sl([i,t],r),o)}));else if(Array.isArray(t))for(let i=0;i<t.length;i++){const a=t[i];Array.isArray(a)&&bs(e,n,sl(a,r),o)}}));function Dc(e,t,n){e:if(null!=t){if(Hs(t)){if("string"==typeof t)break e;if("number"==typeof t)break e}t=void 0}null!=t&&("string"==typeof t&&as(t),null!=t&&(ps(e,n,0),"number"==typeof t?(e=e.g,Pa(t),cs(e,Ma,La)):(n=as(t),cs(e.g,n.h,n.g))))}function _c(e,t,n){null!=(t=Ks(t))&&null!=t&&(ps(e,n,0),ds(e.g,t))}function Fc(e,t,n){null!=(t=Ws(t))&&(ps(e,n,0),e.g.g.push(t?1:0))}function Mc(e,t,n){null!=(t=Zs(t))&&vs(e,n,Hi(t))}function Lc(e,t,n,r,o){bs(e,n,t instanceof tc?t.u:Array.isArray(t)?sl(t,r):void 0,o)}function Pc(e,t,n){null!=(t=null==t||"string"==typeof t||va(t)||t instanceof Ca?t:void 0)&&vs(e,n,Da(t).buffer)}function Bc(e,t,n){return(5===e.h||2===e.h)&&(t=Al(t,Ts(t),n,2,!1),2==e.h?ts(e,Ka.prototype.A,t):t.push(e.g.A()),!0)}var Oc=Tc((function(e,t,n){if(1!==e.h)return!1;var r=e.g;e=Va(r);const o=Va(r);r=2*(o>>31)+1;const i=o>>>20&2047;return e=4294967296*(1048575&o)+e,Ic(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=Vs(t))&&(ps(e,n,1),e=e.g,(n=Fa||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),Ma=n.getUint32(0,!0),La=n.getUint32(4,!0),hs(e,Ma),hs(e,La))})),Nc=Tc((function(e,t,n){return 5===e.h&&(Ic(t,n,e.g.A()),!0)}),(function(e,t,n){null!=(t=Vs(t))&&(ps(e,n,5),e=e.g,Ba(t),hs(e,Ma))})),Uc=Ac(Bc,(function(e,t,n){if(null!=(t=oc(Vs,t)))for(let i=0;i<t.length;i++){var r=e,o=t[i];null!=o&&(ps(r,n,5),r=r.g,Ba(o),hs(r,Ma))}})),jc=Ac(Bc,(function(e,t,n){if(null!=(t=oc(Vs,t))&&t.length){ps(e,n,2),us(e.g,4*t.length);for(let r=0;r<t.length;r++)n=e.g,Ba(t[r]),hs(n,Ma)}})),Gc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,za(e.g,Na)),!0)}),Dc),$c=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,0===(e=za(e.g,Na))?void 0:e),!0)}),Dc),zc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,za(e.g,Oa)),!0)}),(function(e,t,n){e:if(null!=t){if(Hs(t)){if("string"==typeof t)break e;if("number"==typeof t)break e}t=void 0}null!=t&&("string"==typeof t&&rs(t),null!=t&&(ps(e,n,0),"number"==typeof t?(e=e.g,Pa(t),cs(e,Ma,La)):(n=rs(t),cs(e.g,n.h,n.g))))})),qc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,e.g.m()),!0)}),_c),Vc=Ac((function(e,t,n){return(0===e.h||2===e.h)&&(t=Al(t,Ts(t),n,2,!1),2==e.h?ts(e,Ka.prototype.m,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=oc(Ks,t))&&t.length){n=gs(e,n);for(let n=0;n<t.length;n++)ds(e.g,t[n]);ms(e,n)}})),Wc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,0===(e=e.g.m())?void 0:e),!0)}),_c),Hc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,qa(e.g)),!0)}),Fc),Kc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,!1===(e=qa(e.g))?void 0:e),!0)}),Fc),Yc=Ac((function(e,t,n){if(2!==e.h)return!1;e=Qa(e);const r=Ts(t);return Ns(r),Al(t,r,n,2).push(e),!0}),(function(e,t,n){if(null!=(t=oc(Zs,t)))for(let o=0;o<t.length;o++){var r=t[o];null!=r&&vs(e,n,Hi(r))}})),Xc=Tc((function(e,t,n){return 2===e.h&&(Ic(t,n,""===(e=Qa(e))?void 0:e),!0)}),Mc),Jc=Tc((function(e,t,n){return 2===e.h&&(Ic(t,n,Qa(e)),!0)}),Mc),Zc=Tc((function(e,t,n,r,o){return 2===e.h&&(Za(e,Ol(t,r,n,!0),o),!0)}),Lc),Qc=Tc((function(e,t,n,r,o){return 2===e.h&&(Za(e,Ol(t,r,n),o),!0)}),Lc),eu=Ac((function(e,t,n,r,o){if(2!==e.h)return!1;r=sl(void 0,r);const i=Ts(t);Ns(i);let a=Al(t,i,n,3);return(Object.isFrozen(a)||4&Cs(a))&&(a=ws(a),Tl(t,i,n,a)),a.push(r),Za(e,r,o),!0}),(function(e,t,n,r,o){if(Array.isArray(t))for(let i=0;i<t.length;i++)Lc(e,t[i],n,r,o)})),tu=Tc((function(e,t,n,r,o,i){if(2!==e.h)return!1;const a=Ts(t);return Ns(a),(i=Bl(t,a,i))&&n!==i&&Tl(t,a,i),Za(e,t=Ol(t,r,n),o),!0}),Lc),nu=Tc((function(e,t,n){return 2===e.h&&(Ic(t,n,es(e)),!0)}),Pc),ru=Ac((function(e,t,n){return(0===e.h||2===e.h)&&(t=Al(t,Ts(t),n,2,!1),2==e.h?ts(e,Ka.prototype.j,t):t.push(e.g.j()),!0)}),(function(e,t,n){if(null!=(t=oc(Ys,t)))for(let i=0;i<t.length;i++){var r=e,o=t[i];null!=o&&(ps(r,n,0),us(r.g,o))}})),ou=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,e.g.m()),!0)}),(function(e,t,n){null!=(t=Ks(t))&&(t=parseInt(t,10),ps(e,n,0),ds(e.g,t))})),iu=Ac((function(e,t,n){return(0===e.h||2===e.h)&&(t=Al(t,Ts(t),n,2,!1),2==e.h?ts(e,Ka.prototype.C,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=oc(Ks,t))&&t.length){n=gs(e,n);for(let n=0;n<t.length;n++)ds(e.g,t[n]);ms(e,n)}}));class au{constructor(e,t){this.h=e,this.g=t,this.l=Ul,this.m=$l,this.defaultValue=void 0}}function su(e,t){return new au(e,t)}function lu(e,t){return(n,r)=>{e:{if(ns.length){const e=ns.pop();e.o(r),Ga(e.g,n,r),n=e}else n=new class{constructor(e,t){if(Ya.length){const n=Ya.pop();Ga(n,e,t),e=n}else e=new Ka(e,t);this.g=e,this.l=this.g.g,this.h=this.m=-1,this.o(t)}o({aa:e=!1}={}){this.aa=e}}(n,r);try{var o=new e;const r=o.u;ac(t)(r,n),$s&&delete r[$s];var i=o;break e}finally{(o=n.g).h=null,o.s=!1,o.v=0,o.l=0,o.g=0,o.R=!1,n.m=-1,n.h=-1,100>ns.length&&ns.push(n)}i=void 0}return i}}function cu(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}}}};Cc(this.u,t,yc(e)),fs(t,t.g.end());const n=new Uint8Array(t.h),r=t.l,o=r.length;let i=0;for(let e=0;e<o;e++){const t=r[e];n.set(t,i),i+=t.length}return t.l=[n],n}}var uu=[0,Xc,Tc((function(e,t,n){return 2===e.h&&(Ic(t,n,(e=es(e))===Sa()?void 0:e),!0)}),(function(e,t,n){if(null!=t){if(t instanceof tc){const r=t.Ea;return void(r&&(t=r(t),null!=t&&vs(e,n,Da(t).buffer)))}if(Array.isArray(t))return}Pc(e,t,n)}))],du=[0,Jc],hu=[0,qc,ou,Hc,Hc,Vc,ou,ou],fu=[0,Hc,Hc],pu=class extends tc{constructor(){super()}};pu.B=[6];var gu=[0,Hc,Jc,Hc,ou,ou,iu,Jc,Jc,Qc,fu,ou],mu=[0,Jc,Jc,Jc],vu=class extends tc{constructor(){super()}},bu=[0],yu=[0,qc],wu=[1,2,3,4,5],xu=class extends tc{constructor(e){super(e,2)}},Eu={},Su=[-2,Eu,Hc];Eu[336783863]=rc([0,Jc,Hc,Hc,qc,Qc,[0,tu,bu,wu,tu,gu,wu,tu,mu,wu,tu,yu,wu,tu,hu,wu],Qc,du]);var ku=[0,Xc,Kc],Cu=[0,$c,$c,Kc,Kc,Kc,Kc,$c,Vc,Xc,Wc,$c,$c,Kc,Wc,Kc,Kc,Kc,Xc],Tu=[-1,{}],Au=[0,Jc,Qc,2,Tu],Iu=[0,Jc,Yc,Qc,Tu];function Ru(e,t){t=Js(t);const n=Ts(e=e.u);Ns(n),Tl(e,n,2,""===t?void 0:t)}function Du(e,t){Ql(e,3,t)}function _u(e,t){Ql(e,4,t)}var Fu=class extends tc{constructor(e){super(e,500)}o(e){return $l(this,0,7,e)}};Fu.B=[3,4,5,6,8,13,17,1005];var Mu=[-500,Xc,Xc,Yc,Yc,Yc,Yc,Qc,Su,eu,uu,Wc,Wc,Qc,Au,Qc,Iu,eu,ku,Xc,Qc,Cu,Wc,Yc,Yc,988],Lu=[0,Xc,Xc,Qc,Tu],Pu=[-500,Jc,Jc,Qc,[-1,{}],Jc,999],Bu=[-500,Jc,Yc,Yc,Qc,[-2,{},Hc],Yc,998,Yc],Ou=[-500,Jc,Yc,Qc,Tu,Yc,999];function Nu(e,t){ql(e,Fu,t)}function Uu(e,t){Ql(e,10,t)}function ju(e,t){Ql(e,15,t)}var Gu=class extends tc{constructor(e){super(e,500)}o(e){return $l(this,0,1001,e)}};Gu.B=[1,6,7,9,10,15,16,17,14,1002];var $u=[-500,eu,Mu,eu,5,Pu,eu,Bu,Wc,eu,Ou,Yc,Wc,Qc,Au,Qc,Iu,eu,Lu,Yc,Yc,Yc,Qc,Cu,Xc,Xc,Kc,Qc,980,Tu,eu,uu],zu=lu(Gu,$u);Gu.prototype.g=cu($u);var qu=[0,eu,[0,qc,qc,qc]],Vu=class extends tc{constructor(e){super(e)}},Wu=[0,qc,Nc,Jc,Jc],Hu=class extends tc{constructor(e){super(e)}g(){return Gl(this,Vu,1)}};Hu.B=[1];var Ku=[0,eu,Wu],Yu=lu(Hu,Ku),Xu=[0,qc,Nc],Ju=[0,qc,qc,Qc,qu],Zu=class extends tc{constructor(e){super(e)}},Qu=[0,qc,qc,qc,qc],ed=[0,Nc,Nc,Nc,Nc],td=class extends tc{constructor(e){super(e)}},nd=[0,Nc,Nc,Jc,Nc],rd=class extends tc{constructor(e){super(e)}h(){return Ul(this,Zu,2)}g(){return Gl(this,td,5)}};rd.B=[5];var od=[0,ou,Qc,Qu,Qc,ed,Qc,Ju,eu,nd],id=class extends tc{constructor(e){super(e)}};id.B=[1,2,3,8,9];var ad=lu(id,[0,Yc,Vc,jc,Qc,od,Jc,Jc,Gc,eu,Xu,Yc,Gc]),sd=class extends tc{constructor(e){super(e)}},ld=[0,Nc,Nc,Nc,Nc,Nc],cd=class extends tc{constructor(e){super(e)}};cd.B=[1];var ud=lu(cd,[0,eu,ld]),dd=class extends tc{constructor(e){super(e)}},hd=[0,Nc,Nc,Nc,Nc,Nc],fd=class extends tc{constructor(e){super(e)}};fd.B=[1];var pd=lu(fd,[0,eu,hd]),gd=class extends tc{constructor(e){super(e)}};gd.B=[3];var md=[0,qc,qc,jc,ou],vd=class extends tc{constructor(){super()}};vd.prototype.g=cu([0,Nc,Nc,Nc,Nc,Nc,Gc]);var bd=class extends tc{constructor(e){super(e)}},yd=[0,qc,2,Jc,Qc,Ku],wd=class extends tc{constructor(e){super(e)}};wd.B=[1];var xd=lu(wd,[0,eu,yd,Gc]),Ed=class extends tc{constructor(e){super(e)}};Ed.B=[1];var Sd=class extends tc{constructor(e){super(e)}fa(){const e=Rl(this);return null==e?Sa():e}},kd=class extends tc{constructor(e){super(e)}},Cd=[1,2],Td=[0,tu,[0,jc],Cd,tu,[0,nu],Cd,qc,Jc],Ad=class extends tc{constructor(e){super(e)}};Ad.B=[1];var Id=lu(Ad,[0,eu,Td,Gc]),Rd=class extends tc{constructor(e){super(e)}};Rd.B=[4,5];var Dd=[0,Jc,qc,Nc,Yc,Yc],_d=class extends tc{constructor(e){super(e)}},Fd=[0,Hc,Hc],Md=class extends tc{constructor(e){super(e)}},Ld=[1,2,3,4,5],Pd=class extends tc{constructor(e){super(e)}g(){return null!=Rl(this)}h(){return null!=Hl(this,2)}},Bd=[0,nu,Jc,Qc,[0,qc,Gc,Gc],Qc,[0,zc,Gc]],Od=class extends tc{constructor(e){super(e)}g(){return Ws(Sl(this,2))??!1}},Nd=[0,Qc,Bd,Hc,Qc,[0,tu,yu,Ld,tu,gu,Ld,tu,hu,Ld,tu,bu,Ld,tu,mu,Ld]],Ud=class extends tc{constructor(e){super(e)}},jd=[0,Qc,Nd,Nc,Nc,qc],Gd=su(502141897,Ud);Eu[502141897]=rc(jd);var $d=[0,Qc,Bd];Eu[512499200]=rc($d);var zd=[0,Qc,$d];Eu[515723506]=rc(zd);var qd=lu(class extends tc{constructor(e){super(e)}},[0,Qc,[0,ou,ou,Uc,ru],Qc,md]),Vd=[0,Qc,Nd];Eu[508981768]=rc(Vd);var Wd=class extends tc{constructor(e){super(e)}},Hd=[0,Qc,Nd,Nc,Qc,Vd,Hc],Kd=class extends tc{constructor(e){super(e)}},Yd=[0,Qc,Nd,Qc,jd,Qc,Hd,Nc,Qc,zd];Eu[508968149]=rc(Hd);var Xd=su(508968150,Kd);Eu[508968150]=rc(Yd);var Jd=class extends tc{constructor(e){super(e)}},Zd=su(513916220,Jd);Eu[513916220]=rc([0,Qc,Nd,Qc,Yd,qc]);var Qd=class extends tc{constructor(e){super(e)}h(){return Ul(this,Rd,2)}g(){Cl(this,2)}},eh=[0,Qc,Nd,Qc,Dd];Eu[478825465]=rc(eh);var th=[0,Qc,Nd];Eu[478825422]=rc(th);var nh=class extends tc{constructor(e){super(e)}},rh=[0,Qc,Nd,Qc,th,Qc,eh,Qc,eh],oh=class extends tc{constructor(e){super(e)}},ih=[0,Qc,Nd,Nc,qc],ah=class extends tc{constructor(e){super(e)}},sh=[0,Qc,Nd,Nc],lh=class extends tc{constructor(e){super(e)}},ch=[0,Qc,Nd,Qc,ih,Qc,sh,Nc],uh=class extends tc{constructor(e){super(e)}},dh=[0,Qc,Nd,Qc,ch,Qc,rh];Eu[463370452]=rc(rh),Eu[464864288]=rc(ih),Eu[474472470]=rc(sh);var hh=su(462713202,lh);Eu[462713202]=rc(ch);var fh=su(479097054,uh);Eu[479097054]=rc(dh);var ph=class extends tc{constructor(e){super(e)}},gh=su(456383383,ph);Eu[456383383]=rc([0,Qc,Nd,Qc,Dd]);var mh=class extends tc{constructor(e){super(e)}},vh=su(476348187,mh);Eu[476348187]=rc([0,Qc,Nd,Qc,Fd]);var bh=class extends tc{constructor(e){super(e)}},yh=[0,ou,ou],wh=class extends tc{constructor(e){super(e)}};wh.B=[3];var xh=su(458105876,class extends tc{constructor(e){super(e)}g(){var e=this.u;const t=Ts(e);var n=2&t;return e=function(e,t,n){var r=wh;const o=2&t;let i=!1;if(null==n){if(o)return Fl();n=[]}else if(n.constructor===dl){if(0==(2&n.g)||o)return n;n=n.m()}else Array.isArray(n)?i=!!(2&Cs(n)):n=[];if(o){if(!n.length)return Fl();i||(i=!0,Rs(n))}else i&&(i=!1,n=Ml(n));return i||(64&Cs(n)?ks(n,32):32&t&&Es(n,32)),Tl(e,t,2,r=new dl(n,r,nl,void 0),!1),r}(e,t,kl(e,t,2)),null==e||!n&&wh&&(e.v=!0),e}});Eu[458105876]=rc([0,Qc,yh,Rc,[!0,Gc,Qc,[0,Jc,Jc,Yc]]]);var Eh=class extends tc{constructor(e){super(e)}},Sh=su(458105758,Eh);Eu[458105758]=rc([0,Qc,Nd,Jc,Qc,yh]);var kh=class extends tc{constructor(e){super(e)}};kh.B=[5,6];var Ch=su(443442058,kh);Eu[443442058]=rc([0,Qc,Nd,Jc,qc,Nc,Yc,Yc]);var Th=class extends tc{constructor(e){super(e)}},Ah=[0,Qc,Nd,Nc,Nc,qc];Eu[514774813]=rc(Ah);var Ih=class extends tc{constructor(e){super(e)}},Rh=[0,Qc,Nd,Nc,Hc],Dh=class extends tc{constructor(e){super(e)}},_h=[0,Qc,Nd,Qc,Ah,Qc,Rh,Nc];Eu[518928384]=rc(Rh);var Fh=su(516587230,Dh);function Mh(e,t){return t=t?t.clone():new Rd,void 0!==e.displayNamesLocale?Cl(t,1,Js(e.displayNamesLocale)):void 0===e.displayNamesLocale&&Cl(t,1),void 0!==e.maxResults?Jl(t,2,e.maxResults):"maxResults"in e&&Cl(t,2),void 0!==e.scoreThreshold?Zl(t,3,e.scoreThreshold):"scoreThreshold"in e&&Cl(t,3),void 0!==e.categoryAllowlist?Ll(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&Cl(t,4),void 0!==e.categoryDenylist?Ll(t,5,e.categoryDenylist):"categoryDenylist"in e&&Cl(t,5),t}function Lh(e,t=-1,n=""){return{categories:e.map((e=>({index:Kl(Vl(e,1))??-1,score:Yl(e,2)??0,categoryName:Hl(e,3)??""??"",displayName:Hl(e,4)??""??""}))),headIndex:t,headName:n}}function Ph(e){var t=Dl(e,3,Vs),n=Dl(e,2,Ks);const r=Dl(e,1,Zs),o=Dl(e,9,Zs),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:o[e]??""});if((t=Ul(e,rd,4)?.h())&&(i.boundingBox={originX:Vl(t,1)??0,originY:Vl(t,2)??0,width:Vl(t,3)??0,height:Vl(t,4)??0,angle:0}),Ul(e,rd,4)?.g().length)for(const t of Ul(e,rd,4).g())i.keypoints.push({x:Il(t,1)??0,y:Il(t,2)??0,score:Il(t,4)??0,label:Hl(t,3)??""});return i}function Bh(e){const t=[];for(const n of Gl(e,dd,1))t.push({x:Yl(n,1)??0,y:Yl(n,2)??0,z:Yl(n,3)??0});return t}function Oh(e){const t=[];for(const n of Gl(e,sd,1))t.push({x:Yl(n,1)??0,y:Yl(n,2)??0,z:Yl(n,3)??0});return t}function Nh(e){return Array.from(e,(e=>127<e?e-256:e))}function Uh(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,o=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i],r+=e[i]*e[i],o+=t[i]*t[i];if(0>=r||0>=o)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(r*o)}let jh;Eu[516587230]=rc(_h);const Gh=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 $h(){if(void 0===jh)try{await WebAssembly.instantiate(Gh),jh=!0}catch{jh=!1}return jh}async function zh(e,t=""){const n=await $h()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${n}.js`,wasmBinaryPath:`${t}/${e}_${n}.wasm`}}var qh=class{};function Vh(){const e=navigator.userAgent;return e.includes("Safari")&&!e.includes("Chrome")}async function Wh(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 Hh(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 Kh(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 Yh(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 Xh(e,t,n){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=n}function Jh(e,t,n){let r=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(e,t,o)=>{t?(n(r,o),r=[]):r.push(e)}}function Zh(e,t){const n=Ul(e.baseOptions,Pd,1)||new Pd;"string"==typeof t?(Cl(n,2,Js(t)),Cl(n,1)):t instanceof Uint8Array&&(Cl(n,1,Bs(t,!1,!1)),Cl(n,2)),$l(e.baseOptions,0,1,n)}function Qh(e){try{const t=e.J.length;if(1===t)throw Error(e.J[0].message);if(1<t)throw Error("Encountered multiple errors: "+e.J.map((e=>e.message)).join(", "))}finally{e.J=[]}}function ef(e,t){e.I=Math.max(e.I,t)}function tf(e,t){e.A=new Fu,Ru(e.A,"PassThroughCalculator"),Du(e.A,"free_memory"),_u(e.A,"free_memory_unused_out"),Uu(t,"free_memory"),Nu(t,e.A)}function nf(e,t){Du(e.A,t),_u(e.A,t+"_unused_out")}function rf(e){e.g.addBoolToStream(!0,"free_memory",e.I)}qh.forVisionTasks=function(e){return zh("vision",e)},qh.forTextTasks=function(e){return zh("text",e)},qh.forAudioTasks=function(e){return zh("audio",e)},qh.isSimdSupported=function(){return $h()};var of=class{constructor(e){this.g=e,this.J=[],this.I=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(!(Ul(this.baseOptions,Pd,1)?.g()||Ul(this.baseOptions,Pd,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=Ul(e.baseOptions,Md,3);if(!n){var r=n=new Md,o=new vu;zl(r,4,Ld,o)}"delegate"in t&&("GPU"===t.delegate?(t=n,r=new pu,zl(t,2,Ld,r)):(t=n,r=new vu,zl(t,4,Ld,r))),$l(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),Zh(this,"/model.dat"),this.m(),this.P()}));Zh(this,t.modelAssetBuffer)}return this.m(),this.P(),Promise.resolve()}P(){}W(){let e;if(this.g.W((t=>{e=zu(t)})),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener(((e,t)=>{this.J.push(Error(t))})),this.g.Aa(),this.g.setGraph(e,t),this.A=void 0,Qh(this)}finishProcessing(){this.g.finishProcessing(),Qh(this)}close(){this.A=void 0,this.g.closeGraph()}};function af(e,t){if(null===e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}of.prototype.close=of.prototype.close;class sf{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 lf(e,t,n){const r=e.h;if(n=af(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 cf(e,t){const n=e.h,r=af(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(r);const o=af(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,o),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=af(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 sf(n,r,o,i)}function uf(e,t){if(e.h){if(t!==e.h)throw Error("Cannot change GL context once initialized")}else e.h=t}function df(e,t,n,r){if(uf(e,t),!e.g){const t=e.h;if(e.g=af(t.createProgram(),"Failed to create WebGL program"),e.C=lf(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=lf(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=cf(e,!0)),n=e.m):(e.j||(e.j=cf(e,!1)),n=e.j),t.useProgram(e.g),n.bind(),e=r(),n.g.bindVertexArray(null),e}function hf(e,t,n){uf(e,t),e.l||(e.l=af(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 ff(e){e.h?.bindFramebuffer(e.h.FRAMEBUFFER,null)}var pf=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 gf(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 mf(e){var t=gf(e,0);if(!t){t=bf(e);const n=yf(e),r=new Uint8Array(e.width*e.height*4);hf(n,t,vf(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,r),ff(n),t=new ImageData(new Uint8ClampedArray(r.buffer),e.width,e.height),e.g.push(t)}return t}function vf(e){let t=gf(e,2);if(!t){const n=bf(e);t=xf(e);const r=gf(e,1)||mf(e);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,r),Ef(e)}return t}function bf(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=af(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function yf(e){return e.l||(e.l=new pf),e.l}function wf(e){(e=bf(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 xf(e){const t=bf(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=gf(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=af(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),wf(e)),n}function Ef(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Sf(e){const t=bf(e);return df(yf(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,o=n.height;return n.width=e.width,n.height=e.height,e=t(),n.width=r,n.height=o,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 kf=class{constructor(e,t,n,r,o,i,a){this.g=e,this.j=t,this.m=n,this.canvas=r,this.l=o,this.width=i,this.height=a,(this.j||this.m)&&0==--Cf&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}va(){return!!gf(this,0)}ba(){return!!gf(this,1)}K(){return!!gf(this,2)}ra(){return mf(this)}qa(){var e=gf(this,1);return e||(vf(this),xf(this),e=Sf(this),Ef(this),this.g.push(e),this.j=!0),e}V(){return vf(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=bf(this),t=yf(this);e.activeTexture(e.TEXTURE1),n=af(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),wf(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),hf(t,e,n),df(t,e,!1,(()=>{xf(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),Ef(this)})),ff(t),Ef(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);vf(this),xf(this),n=Sf(this),Ef(this)}e.push(n)}return new kf(e,this.ba(),this.K(),this.canvas,this.l,this.width,this.height)}close(){this.j&&gf(this,1).close(),this.m&&bf(this).deleteTexture(gf(this,2)),Cf=-1}};kf.prototype.close=kf.prototype.close,kf.prototype.clone=kf.prototype.clone,kf.prototype.getAsWebGLTexture=kf.prototype.V,kf.prototype.getAsImageBitmap=kf.prototype.qa,kf.prototype.getAsImageData=kf.prototype.ra,kf.prototype.hasWebGLTexture=kf.prototype.K,kf.prototype.hasImageBitmap=kf.prototype.ba,kf.prototype.hasImageData=kf.prototype.va;var Cf=250;function Tf(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 Af(e){var t=Tf(e,1);if(!t){if(t=Tf(e,0))t=new Float32Array(t).map((e=>e/255));else{t=new Float32Array(e.width*e.height);const r=Rf(e);var n=_f(e);if(hf(n,r,If(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 If(e){let t=Tf(e,2);if(!t){const n=Rf(e);t=Mf(e);const r=Af(e),o=Df(e);n.texImage2D(n.TEXTURE_2D,0,o,e.width,e.height,0,n.RED,n.FLOAT,r),Lf(e)}return t}function Rf(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=af(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Df(e){if(e=Rf(e),!Pf)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Pf=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Pf=e.R16F}return Pf}function _f(e){return e.l||(e.l=new pf),e.l}function Ff(e){(e=Rf(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 Mf(e){const t=Rf(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=Tf(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=af(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),Ff(e)),n}function Lf(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Pf,Bf=class{constructor(e,t,n,r,o,i){this.g=e,this.m=t,this.canvas=n,this.l=r,this.width=o,this.height=i,this.m&&0==--Of&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}wa(){return!!Tf(this,0)}ua(){return!!Tf(this,1)}K(){return!!Tf(this,2)}sa(){return(e=Tf(this,0))||(e=Af(this),e=new Uint8Array(e.map((e=>255*e))),this.g.push(e)),e;var e}pa(){return Af(this)}V(){return If(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=Rf(this),t=_f(this);e.activeTexture(e.TEXTURE1),n=af(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),Ff(this);const r=Df(this);e.texImage2D(e.TEXTURE_2D,0,r,this.width,this.height,0,e.RED,e.FLOAT,null),e.bindTexture(e.TEXTURE_2D,null),hf(t,e,n),df(t,e,!1,(()=>{Mf(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),Lf(this)})),ff(t),Lf(this)}}e.push(n)}return new Bf(e,this.K(),this.canvas,this.l,this.width,this.height)}close(){this.m&&Rf(this).deleteTexture(Tf(this,2)),Of=-1}};Bf.prototype.close=Bf.prototype.close,Bf.prototype.clone=Bf.prototype.clone,Bf.prototype.getAsWebGLTexture=Bf.prototype.V,Bf.prototype.getAsFloat32Array=Bf.prototype.pa,Bf.prototype.getAsUint8Array=Bf.prototype.sa,Bf.prototype.hasWebGLTexture=Bf.prototype.K,Bf.prototype.hasFloat32Array=Bf.prototype.ua,Bf.prototype.hasUint8Array=Bf.prototype.wa;var Of=250;function Nf(...e){return e.map((([e,t])=>({start:e,end:t})))}const Uf=function(e){return class extends e{Aa(){this.i._registerModelResourcesGraphService()}}}((jf=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||Vh()?(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,o){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Hh(this,r||"input_audio",(r=>{Hh(this,o=o||"audio_header",(o=>{this.i._configureAudio(r,o,e,t,n)}))}))}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}W(e){Xh(this,"__graph_config__",(t=>{e(t)})),Hh(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,o){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),Hh(this,r,(e=>{this.i._addAudioToInputStream(this.g,t,n,e,o)}))}addGpuBufferToStream(e,t,n){Hh(this,t,(t=>{const[r,o]=Kh(this,e,t);this.i._addBoundTextureToStream(t,r,o,n)}))}addBoolToStream(e,t,n){Hh(this,t,(t=>{this.i._addBoolToInputStream(e,t,n)}))}addDoubleToStream(e,t,n){Hh(this,t,(t=>{this.i._addDoubleToInputStream(e,t,n)}))}addFloatToStream(e,t,n){Hh(this,t,(t=>{this.i._addFloatToInputStream(e,t,n)}))}addIntToStream(e,t,n){Hh(this,t,(t=>{this.i._addIntToInputStream(e,t,n)}))}addStringToStream(e,t,n){Hh(this,t,(t=>{Hh(this,e,(e=>{this.i._addStringToInputStream(e,t,n)}))}))}addStringRecordToStream(e,t,n){Hh(this,t,(t=>{Yh(this,Object.keys(e),(r=>{Yh(this,Object.values(e),(o=>{this.i._addFlatHashMapToInputStream(r,o,Object.keys(e).length,t,n)}))}))}))}addProtoToStream(e,t,n,r){Hh(this,n,(n=>{Hh(this,t,(t=>{const o=this.i._malloc(e.length);this.i.HEAPU8.set(e,o),this.i._addProtoToInputStream(o,e.length,t,n,r),this.i._free(o)}))}))}addEmptyPacketToStream(e,t){Hh(this,e,(e=>{this.i._addEmptyPacketToInputStream(e,t)}))}addBoolToInputSidePacket(e,t){Hh(this,t,(t=>{this.i._addBoolToInputSidePacket(e,t)}))}addDoubleToInputSidePacket(e,t){Hh(this,t,(t=>{this.i._addDoubleToInputSidePacket(e,t)}))}addFloatToInputSidePacket(e,t){Hh(this,t,(t=>{this.i._addFloatToInputSidePacket(e,t)}))}addIntToInputSidePacket(e,t){Hh(this,t,(t=>{this.i._addIntToInputSidePacket(e,t)}))}addStringToInputSidePacket(e,t){Hh(this,t,(t=>{Hh(this,e,(e=>{this.i._addStringToInputSidePacket(e,t)}))}))}addProtoToInputSidePacket(e,t,n){Hh(this,n,(n=>{Hh(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){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachBoolListener(e)}))}attachBoolVectorListener(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.i._attachBoolVectorListener(e)}))}attachIntListener(e,t){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachIntListener(e)}))}attachIntVectorListener(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.i._attachIntVectorListener(e)}))}attachDoubleListener(e,t){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachDoubleListener(e)}))}attachDoubleVectorListener(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.i._attachDoubleVectorListener(e)}))}attachFloatListener(e,t){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachFloatListener(e)}))}attachFloatVectorListener(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.i._attachFloatVectorListener(e)}))}attachStringListener(e,t){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachStringListener(e)}))}attachStringVectorListener(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.i._attachStringVectorListener(e)}))}attachProtoListener(e,t,n){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachProtoListener(e,n||!1)}))}attachProtoVectorListener(e,t,n){Jh(this,e,t),Hh(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?'),Xh(this,e,((e,n)=>{e=new Float32Array(e.buffer,e.byteOffset,e.length/4),t(e,n)})),Hh(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 jf{get Y(){return this.i}ga(e,t,n){Hh(this,t,(t=>{const[r,o]=Kh(this,e,t);this.Y._addBoundTextureAsImageToStream(t,r,o,n)}))}S(e,t){Xh(this,e,t),Hh(this,e,(e=>{this.Y._attachImageListener(e)}))}T(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.Y._attachImageVectorListener(e)}))}}));var jf,Gf=class extends Uf{};async function $f(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,o)=>{if(t&&await Wh(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(n&&(await Wh(n),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&o&&((t=self.Module).locateFile=o.locateFile,o.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=o.mainScriptUrlOrBlob)),o=await self.ModuleFactory(self.Module||o),self.ModuleFactory=self.Module=void 0,new e(o,r)})(e,n.wasmLoaderPath,n.assetLoaderPath,t,{locateFile:e=>e.endsWith(".wasm")?n.wasmBinaryPath.toString():n.assetBinaryPath&&e.endsWith(".data")?n.assetBinaryPath.toString():e}),await e.o(r),e}(e,t,n,r)}(e,n.canvas??("undefined"==typeof OffscreenCanvas||Vh()?document.createElement("canvas"):void 0),t,n)}function zf(e,t,n,r){if(e.Z){const i=new vd;if(n?.regionOfInterest){if(!e.ea)throw Error("This task doesn't support region-of-interest.");var o=n.regionOfInterest;if(o.left>=o.right||o.top>=o.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(0>o.left||0>o.top||1<o.right||1<o.bottom)throw Error("Expected RectF values to be in [0,1].");Zl(i,1,(o.left+o.right)/2),Zl(i,2,(o.top+o.bottom)/2),Zl(i,4,o.right-o.left),Zl(i,3,o.bottom-o.top)}else Zl(i,1,.5),Zl(i,2,.5),Zl(i,4,1),Zl(i,3,1);if(n?.rotationDegrees){if(0!=n?.rotationDegrees%90)throw Error("Expected rotation to be a multiple of 90°.");if(Zl(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=Yl(i,3)*r/e,o=Yl(i,4)*e/r,Zl(i,4,n),Zl(i,3,o)}}e.g.addProtoToStream(i.g(),"mediapipe.NormalizedRect",e.Z,r)}e.g.ga(t,e.da,r??performance.now()),e.finishProcessing()}function qf(e,t,n){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");zf(e,t,n,e.I+1)}function Vf(e,t,n,r){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");zf(e,t,n,r)}function Wf(e,t,n){var r=t.data;const o=t.width,i=o*(t=t.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==i)throw Error("Unsupported channel count: "+r.length/i);return e=new Bf([r],!1,e.g.i.canvas,e.O,o,t),n?e.clone():e}var Hf=class extends of{constructor(e,t,n,r){super(e),this.g=e,this.da=t,this.Z=n,this.ea=r,this.O=new pf}l(e,t=!0){if("runningMode"in e&&Xl(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.O.close(),super.close()}};Hf.prototype.close=Hf.prototype.close;var Kf=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},this.h=new Ud,e=new Od,$l(this.h,0,1,e),Zl(this.h,2,.5),Zl(this.h,3,.3)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&Zl(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&Zl(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},qf(this,e,t),this.j}G(e,t,n){return this.j={detections:[]},Vf(this,e,n,t),this.j}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect_in"),ju(e,"detections");const t=new xu;ec(t,Gd,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect_in"),_u(n,"DETECTIONS:detections"),n.o(t),Nu(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=ad(t),this.j.detections.push(Ph(e));ef(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Kf.prototype.detectForVideo=Kf.prototype.G,Kf.prototype.detect=Kf.prototype.F,Kf.prototype.setOptions=Kf.prototype.o,Kf.createFromModelPath=async function(e,t){return $f(Kf,e,{baseOptions:{modelAssetPath:t}})},Kf.createFromModelBuffer=function(e,t){return $f(Kf,e,{baseOptions:{modelAssetBuffer:t}})},Kf.createFromOptions=function(e,t){return $f(Kf,e,t)};var Yf=Nf([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]),Xf=Nf([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]),Jf=Nf([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Zf=Nf([474,475],[475,476],[476,477],[477,474]),Qf=Nf([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]),ep=Nf([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),tp=Nf([469,470],[470,471],[471,472],[472,469]),np=Nf([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]),rp=[...Yf,...Xf,...Jf,...Qf,...ep,...np],op=Nf([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 ip(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var ap=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,this.h=new Kd,e=new Od,$l(this.h,0,1,e),this.v=new Wd,$l(this.h,0,3,this.v),this.s=new Ud,$l(this.h,0,2,this.s),Jl(this.s,4,1),Zl(this.s,2,.5),Zl(this.v,2,.5),Zl(this.h,4,.5)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){return"numFaces"in e&&Jl(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&Zl(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&Zl(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&Zl(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 ip(this),qf(this,e,t),this.j}G(e,t,n){return ip(this),Vf(this,e,n,t),this.j}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"face_landmarks");const t=new xu;ec(t,Xd,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"NORM_LANDMARKS:face_landmarks"),n.o(t),Nu(e,n),this.g.attachProtoVectorListener("face_landmarks",((e,t)=>{for(const t of e)e=pd(t),this.j.faceLandmarks.push(Bh(e));ef(this,t)})),this.g.attachEmptyPacketListener("face_landmarks",(e=>{ef(this,e)})),this.outputFaceBlendshapes&&(ju(e,"blendshapes"),_u(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((e,t)=>{if(this.outputFaceBlendshapes)for(const t of e)e=Yu(t),this.j.faceBlendshapes.push(Lh(e.g()??[]));ef(this,t)})),this.g.attachEmptyPacketListener("blendshapes",(e=>{ef(this,e)}))),this.outputFacialTransformationMatrixes&&(ju(e,"face_geometry"),_u(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((e,t)=>{if(this.outputFacialTransformationMatrixes)for(const t of e)(e=Ul(qd(t),gd,2))&&this.j.facialTransformationMatrixes.push({rows:Kl(Vl(e,1))??0,columns:Kl(Vl(e,2))??0,data:Dl(e,3,Vs)??[]});ef(this,t)})),this.g.attachEmptyPacketListener("face_geometry",(e=>{ef(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ap.prototype.detectForVideo=ap.prototype.G,ap.prototype.detect=ap.prototype.F,ap.prototype.setOptions=ap.prototype.o,ap.createFromModelPath=function(e,t){return $f(ap,e,{baseOptions:{modelAssetPath:t}})},ap.createFromModelBuffer=function(e,t){return $f(ap,e,{baseOptions:{modelAssetBuffer:t}})},ap.createFromOptions=function(e,t){return $f(ap,e,t)},ap.FACE_LANDMARKS_LIPS=Yf,ap.FACE_LANDMARKS_LEFT_EYE=Xf,ap.FACE_LANDMARKS_LEFT_EYEBROW=Jf,ap.FACE_LANDMARKS_LEFT_IRIS=Zf,ap.FACE_LANDMARKS_RIGHT_EYE=Qf,ap.FACE_LANDMARKS_RIGHT_EYEBROW=ep,ap.FACE_LANDMARKS_RIGHT_IRIS=tp,ap.FACE_LANDMARKS_FACE_OVAL=np,ap.FACE_LANDMARKS_CONTOURS=rp,ap.FACE_LANDMARKS_TESSELATION=op;var sp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!0),this.j=new Jd,e=new Od,$l(this.j,0,1,e)}get baseOptions(){return Ul(this.j,Od,1)}set baseOptions(e){$l(this.j,0,1,e)}o(e){return super.l(e)}Da(e,t,n){const r="function"!=typeof t?t:{};if(this.h="function"==typeof t?t:n,qf(this,e,r??{}),!this.h)return this.s}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"stylized_image");const t=new xu;ec(t,Zd,this.j);const n=new Fu;Ru(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"STYLIZED_IMAGE:stylized_image"),n.o(t),Nu(e,n),this.g.S("stylized_image",((e,t)=>{var n=!this.h,r=e.data,o=e.width;const i=o*(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,o,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),o,e)}else if(!(r instanceof WebGLTexture))throw Error(`Unsupported format: ${r.constructor.name}`);o=new kf([r],!1,!1,this.g.i.canvas,this.O,o,e),this.s=n=n?o.clone():o,this.h&&this.h(n),ef(this,t)})),this.g.attachEmptyPacketListener("stylized_image",(e=>{this.s=null,this.h&&this.h(null),ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};sp.prototype.stylize=sp.prototype.Da,sp.prototype.setOptions=sp.prototype.o,sp.createFromModelPath=function(e,t){return $f(sp,e,{baseOptions:{modelAssetPath:t}})},sp.createFromModelBuffer=function(e,t){return $f(sp,e,{baseOptions:{modelAssetBuffer:t}})},sp.createFromOptions=function(e,t){return $f(sp,e,t)};var lp=Nf([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 cp(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function up(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 dp(e,t=!0){const n=[];for(const o of e){var r=Yu(o);e=[];for(const n of r.g())r=t&&null!=Vl(n,1)?Kl(Vl(n,1)):-1,e.push({score:Yl(n,2)??0,index:r,categoryName:Hl(n,3)??""??"",displayName:Hl(n,4)??""??""});n.push(e)}return n}var hp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.v=new uh,e=new Od,$l(this.v,0,1,e),this.C=new lh,$l(this.v,0,2,this.C),this.s=new ah,$l(this.C,0,3,this.s),this.h=new oh,$l(this.C,0,2,this.h),this.j=new nh,$l(this.v,0,3,this.j),Zl(this.h,2,.5),Zl(this.C,4,.5),Zl(this.s,2,.5)}get baseOptions(){return Ul(this.v,Od,1)}set baseOptions(e){$l(this.v,0,1,e)}o(e){if(Jl(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&Zl(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&Zl(this.C,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&Zl(this.s,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Qd,n=Mh(e.cannedGesturesClassifierOptions,Ul(this.j,Qd,3)?.h());$l(t,0,2,n),$l(this.j,0,3,t)}else void 0===e.cannedGesturesClassifierOptions&&Ul(this.j,Qd,3)?.g();return e.customGesturesClassifierOptions?($l(t=new Qd,0,2,n=Mh(e.customGesturesClassifierOptions,Ul(this.j,Qd,4)?.h())),$l(this.j,0,4,t)):void 0===e.customGesturesClassifierOptions&&Ul(this.j,Qd,4)?.g(),this.l(e)}ya(e,t){return cp(this),qf(this,e,t),up(this)}za(e,t,n){return cp(this),Vf(this,e,n,t),up(this)}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"hand_gestures"),ju(e,"hand_landmarks"),ju(e,"world_hand_landmarks"),ju(e,"handedness");const t=new xu;ec(t,fh,this.v);const n=new Fu;Ru(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"HAND_GESTURES:hand_gestures"),_u(n,"LANDMARKS:hand_landmarks"),_u(n,"WORLD_LANDMARKS:world_hand_landmarks"),_u(n,"HANDEDNESS:handedness"),n.o(t),Nu(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e){e=pd(t);const n=[];for(const t of Gl(e,dd,1))n.push({x:Yl(t,1)??0,y:Yl(t,2)??0,z:Yl(t,3)??0});this.landmarks.push(n)}ef(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{ef(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e){e=ud(t);const n=[];for(const t of Gl(e,sd,1))n.push({x:Yl(t,1)??0,y:Yl(t,2)??0,z:Yl(t,3)??0});this.worldLandmarks.push(n)}ef(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{ef(this,e)})),this.g.attachProtoVectorListener("hand_gestures",((e,t)=>{this.gestures.push(...dp(e,!1)),ef(this,t)})),this.g.attachEmptyPacketListener("hand_gestures",(e=>{ef(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{this.handedness.push(...dp(e)),ef(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function fp(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}hp.prototype.recognizeForVideo=hp.prototype.za,hp.prototype.recognize=hp.prototype.ya,hp.prototype.setOptions=hp.prototype.o,hp.createFromModelPath=function(e,t){return $f(hp,e,{baseOptions:{modelAssetPath:t}})},hp.createFromModelBuffer=function(e,t){return $f(hp,e,{baseOptions:{modelAssetBuffer:t}})},hp.createFromOptions=function(e,t){return $f(hp,e,t)},hp.HAND_CONNECTIONS=lp;var pp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.j=new lh,e=new Od,$l(this.j,0,1,e),this.s=new ah,$l(this.j,0,3,this.s),this.h=new oh,$l(this.j,0,2,this.h),Jl(this.h,3,1),Zl(this.h,2,.5),Zl(this.s,2,.5),Zl(this.j,4,.5)}get baseOptions(){return Ul(this.j,Od,1)}set baseOptions(e){$l(this.j,0,1,e)}o(e){return"numHands"in e&&Jl(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&Zl(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&Zl(this.j,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&Zl(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],qf(this,e,t),fp(this)}G(e,t,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Vf(this,e,n,t),fp(this)}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"hand_landmarks"),ju(e,"world_hand_landmarks"),ju(e,"handedness");const t=new xu;ec(t,hh,this.j);const n=new Fu;Ru(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"LANDMARKS:hand_landmarks"),_u(n,"WORLD_LANDMARKS:world_hand_landmarks"),_u(n,"HANDEDNESS:handedness"),n.o(t),Nu(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e)e=pd(t),this.landmarks.push(Bh(e));ef(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{ef(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e)e=ud(t),this.worldLandmarks.push(Oh(e));ef(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{ef(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{var n=this.handedness,r=n.push;const o=[];for(const t of e){e=Yu(t);const n=[];for(const t of e.g())n.push({score:Yl(t,2)??0,index:Kl(Vl(t,1))??-1,categoryName:Hl(t,3)??""??"",displayName:Hl(t,4)??""??""});o.push(n)}r.call(n,...o),ef(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};pp.prototype.detectForVideo=pp.prototype.G,pp.prototype.detect=pp.prototype.F,pp.prototype.setOptions=pp.prototype.o,pp.createFromModelPath=function(e,t){return $f(pp,e,{baseOptions:{modelAssetPath:t}})},pp.createFromModelBuffer=function(e,t){return $f(pp,e,{baseOptions:{modelAssetBuffer:t}})},pp.createFromOptions=function(e,t){return $f(pp,e,t)},pp.HAND_CONNECTIONS=lp;var gp=class extends Hf{constructor(e,t){super(new Gf(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},this.h=new ph,e=new Od,$l(this.h,0,1,e)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){var t=Mh(e,Ul(this.h,Rd,2));return $l(this.h,0,2,t),this.l(e)}ia(e,t){return this.j={classifications:[]},qf(this,e,t),this.j}ja(e,t,n){return this.j={classifications:[]},Vf(this,e,n,t),this.j}m(){var e=new Gu;Uu(e,"input_image"),Uu(e,"norm_rect"),ju(e,"classifications");const t=new xu;ec(t,gh,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Du(n,"IMAGE:input_image"),Du(n,"NORM_RECT:norm_rect"),_u(n,"CLASSIFICATIONS:classifications"),n.o(t),Nu(e,n),this.g.attachProtoListener("classifications",((e,t)=>{this.j=function(e){const t={classifications:Gl(e,bd,1).map((e=>Lh(Ul(e,Hu,4)?.g()??[],Kl(Vl(e,2)),Hl(e,3)??"")))};return null!=Wl(e)&&(t.timestampMs=Kl(Wl(e))),t}(xd(e)),ef(this,t)})),this.g.attachEmptyPacketListener("classifications",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};gp.prototype.classifyForVideo=gp.prototype.ja,gp.prototype.classify=gp.prototype.ia,gp.prototype.setOptions=gp.prototype.o,gp.createFromModelPath=function(e,t){return $f(gp,e,{baseOptions:{modelAssetPath:t}})},gp.createFromModelBuffer=function(e,t){return $f(gp,e,{baseOptions:{modelAssetBuffer:t}})},gp.createFromOptions=function(e,t){return $f(gp,e,t)};var mp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!0),this.h=new mh,this.embeddings={embeddings:[]},e=new Od,$l(this.h,0,1,e)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){var t=this.h,n=Ul(this.h,_d,2);return n=n?n.clone():new _d,void 0!==e.l2Normalize?Xl(n,1,e.l2Normalize):"l2Normalize"in e&&Cl(n,1),void 0!==e.quantize?Xl(n,2,e.quantize):"quantize"in e&&Cl(n,2),$l(t,0,2,n),this.l(e)}na(e,t){return qf(this,e,t),this.embeddings}oa(e,t,n){return Vf(this,e,n,t),this.embeddings}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"embeddings_out");const t=new xu;ec(t,vh,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"EMBEDDINGS:embeddings_out"),n.o(t),Nu(e,n),this.g.attachProtoListener("embeddings_out",((e,t)=>{e=Id(e),this.embeddings=function(e){return{embeddings:Gl(e,kd,1).map((e=>{const t={headIndex:Kl(Vl(e,3))??-1,headName:Hl(e,4)??""??""};if(void 0!==Nl(e,Ed,Pl(e,1)))e=Dl(e=Ul(e,Ed,Pl(e,1)),1,Vs),t.floatEmbedding=e;else{const n=new Uint8Array(0);t.quantizedEmbedding=Ul(e,Sd,Pl(e,2))?.fa()?.ha()??n}return t})),timestampMs:Kl(Wl(e))}}(e),ef(this,t)})),this.g.attachEmptyPacketListener("embeddings_out",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};mp.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Uh(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Uh(Nh(e.quantizedEmbedding),Nh(t.quantizedEmbedding))}return e},mp.prototype.embedForVideo=mp.prototype.oa,mp.prototype.embed=mp.prototype.na,mp.prototype.setOptions=mp.prototype.o,mp.createFromModelPath=function(e,t){return $f(mp,e,{baseOptions:{modelAssetPath:t}})},mp.createFromModelBuffer=function(e,t){return $f(mp,e,{baseOptions:{modelAssetBuffer:t}})},mp.createFromOptions=function(e,t){return $f(mp,e,t)};var vp=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 bp(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function yp(e){try{const t=new vp(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{rf(e)}}vp.prototype.close=vp.prototype.close;var wp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Eh,this.v=new bh,$l(this.h,0,3,this.v),e=new Od,$l(this.h,0,1,e)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?Cl(this.h,2,Js(e.displayNamesLocale)):"displayNamesLocale"in e&&Cl(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}P(){!function(e){const t=Gl(e.W(),Fu,1).filter((e=>(Hl(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&&(Ul(t[0],xu,7)?.l()?.g()??new Map).forEach(((t,n)=>{e.s[Number(n)]=Hl(t,1)??""}))}(this)}X(e,t,n){const r="function"!=typeof t?t:{};return this.j="function"==typeof t?t:n,bp(this),qf(this,e,r),yp(this)}Ca(e,t,n,r){const o="function"!=typeof n?n:{};return this.j="function"==typeof n?n:r,bp(this),Vf(this,e,o,t),yp(this)}ta(){return this.s}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect");const t=new xu;ec(t,Sh,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),n.o(t),Nu(e,n),tf(this,e),this.outputConfidenceMasks&&(ju(e,"confidence_masks"),_u(n,"CONFIDENCE_MASKS:confidence_masks"),nf(this,"confidence_masks"),this.g.T("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>Wf(this,e,!this.j))),ef(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],ef(this,e)}))),this.outputCategoryMask&&(ju(e,"category_mask"),_u(n,"CATEGORY_MASK:category_mask"),nf(this,"category_mask"),this.g.S("category_mask",((e,t)=>{this.categoryMask=Wf(this,e,!this.j),ef(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,ef(this,e)}))),ju(e,"quality_scores"),_u(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,ef(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};wp.prototype.getLabels=wp.prototype.ta,wp.prototype.segmentForVideo=wp.prototype.Ca,wp.prototype.segment=wp.prototype.X,wp.prototype.setOptions=wp.prototype.o,wp.createFromModelPath=function(e,t){return $f(wp,e,{baseOptions:{modelAssetPath:t}})},wp.createFromModelBuffer=function(e,t){return $f(wp,e,{baseOptions:{modelAssetBuffer:t}})},wp.createFromOptions=function(e,t){return $f(wp,e,t)};var xp=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){this.confidenceMasks?.forEach((e=>{e.close()})),this.categoryMask?.close()}};xp.prototype.close=xp.prototype.close;var Ep=class extends tc{constructor(e){super(e)}},Sp=[0,qc,qc,qc],kp=[0,Oc,Oc,Oc,Oc,Hc],Cp=[0,Oc,Oc,Oc,Oc,Hc,Oc,Oc],Tp=[0,Qc,Cp],Ap=[0,Qc,Tp,Qc,Sp],Ip=[0,Qc,Cp,Qc,Sp],Rp=[0,Qc,Cp,qc,qc],Dp=[0,Qc,Rp,Qc,Sp],_p=[0,Oc,Oc,Oc,Oc,Hc,Qc,Sp,Qc,Sp],Fp=[0,Oc,Oc,Oc,Oc,Hc,ou],Mp=class extends tc{constructor(e){super(e)}},Lp=[0,Oc,Oc,Hc],Pp=class extends tc{constructor(){super()}};Pp.B=[1];var Bp=class extends tc{constructor(e){super(e)}},Op=[1,2,3,4,5,6,7,8,9,10,14,15],Np=[0,tu,Cp,Op,tu,Ip,Op,tu,Tp,Op,tu,Ap,Op,tu,Lp,Op,tu,Fp,Op,tu,kp,Op,tu,[0,Jc,Oc,Oc,Oc,Hc,qc,Hc,Hc,Oc,3,Qc,Sp],Op,tu,Rp,Op,tu,Dp,Op,Oc,Qc,Sp,Jc,tu,_p,Op,tu,[0,eu,Lp],Op],Up=[0,Jc,qc,qc,Hc],jp=class extends tc{constructor(){super()}};jp.B=[1],jp.prototype.g=cu([0,eu,Np,Jc,Qc,Up]);var Gp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Eh,this.v=new bh,$l(this.h,0,3,this.v),e=new Od,$l(this.h,0,1,e)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(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)}X(e,t,n,r){const o="function"!=typeof n?n:{};this.j="function"==typeof n?n:r,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.I+1,r=new jp;const i=new Bp;var a=new Ep;if(Jl(a,1,255),$l(i,0,12,a),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var s=new Mp;Xl(s,3,!0),Zl(s,1,t.keypoint.x),Zl(s,2,t.keypoint.y),zl(i,5,Op,s)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(s of(a=new Pp,t.scribble))Xl(t=new Mp,3,!0),Zl(t,1,s.x),Zl(t,2,s.y),ql(a,Mp,t);zl(i,15,Op,a)}ql(r,Bp,i),this.g.addProtoToStream(r.g(),"drishti.RenderData","roi_in",n),qf(this,e,o);e:{try{const e=new xp(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=e;break e}this.j(e)}finally{rf(this)}l=void 0}return l}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"roi_in"),Uu(e,"norm_rect_in");const t=new xu;ec(t,Sh,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),Du(n,"IMAGE:image_in"),Du(n,"ROI:roi_in"),Du(n,"NORM_RECT:norm_rect_in"),n.o(t),Nu(e,n),tf(this,e),this.outputConfidenceMasks&&(ju(e,"confidence_masks"),_u(n,"CONFIDENCE_MASKS:confidence_masks"),nf(this,"confidence_masks"),this.g.T("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>Wf(this,e,!this.j))),ef(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],ef(this,e)}))),this.outputCategoryMask&&(ju(e,"category_mask"),_u(n,"CATEGORY_MASK:category_mask"),nf(this,"category_mask"),this.g.S("category_mask",((e,t)=>{this.categoryMask=Wf(this,e,!this.j),ef(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,ef(this,e)}))),ju(e,"quality_scores"),_u(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,ef(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Gp.prototype.segment=Gp.prototype.X,Gp.prototype.setOptions=Gp.prototype.o,Gp.createFromModelPath=function(e,t){return $f(Gp,e,{baseOptions:{modelAssetPath:t}})},Gp.createFromModelBuffer=function(e,t){return $f(Gp,e,{baseOptions:{modelAssetBuffer:t}})},Gp.createFromOptions=function(e,t){return $f(Gp,e,t)};var $p=class extends Hf{constructor(e,t){super(new Gf(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},this.h=new kh,e=new Od,$l(this.h,0,1,e)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?Cl(this.h,2,Js(e.displayNamesLocale)):"displayNamesLocale"in e&&Cl(this.h,2),void 0!==e.maxResults?Jl(this.h,3,e.maxResults):"maxResults"in e&&Cl(this.h,3),void 0!==e.scoreThreshold?Zl(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&Cl(this.h,4),void 0!==e.categoryAllowlist?Ll(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&Cl(this.h,5),void 0!==e.categoryDenylist?Ll(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&Cl(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},qf(this,e,t),this.j}G(e,t,n){return this.j={detections:[]},Vf(this,e,n,t),this.j}m(){var e=new Gu;Uu(e,"input_frame_gpu"),Uu(e,"norm_rect"),ju(e,"detections");const t=new xu;ec(t,Ch,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),Du(n,"IMAGE:input_frame_gpu"),Du(n,"NORM_RECT:norm_rect"),_u(n,"DETECTIONS:detections"),n.o(t),Nu(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=ad(t),this.j.detections.push(Ph(e));ef(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function zp(e){e.landmarks=[],e.worldLandmarks=[],e.v=void 0}function qp(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{rf(e)}}$p.prototype.detectForVideo=$p.prototype.G,$p.prototype.detect=$p.prototype.F,$p.prototype.setOptions=$p.prototype.o,$p.createFromModelPath=async function(e,t){return $f($p,e,{baseOptions:{modelAssetPath:t}})},$p.createFromModelBuffer=function(e,t){return $f($p,e,{baseOptions:{modelAssetBuffer:t}})},$p.createFromOptions=function(e,t){return $f($p,e,t)};var Vp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,this.h=new Dh,e=new Od,$l(this.h,0,1,e),this.C=new Ih,$l(this.h,0,3,this.C),this.j=new Th,$l(this.h,0,2,this.j),Jl(this.j,4,1),Zl(this.j,2,.5),Zl(this.C,2,.5),Zl(this.h,4,.5)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){return"numPoses"in e&&Jl(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&Zl(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&Zl(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&Zl(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,zp(this),qf(this,e,r),qp(this)}G(e,t,n,r){const o="function"!=typeof n?n:{};return this.s="function"==typeof n?n:r,zp(this),Vf(this,e,o,t),qp(this)}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"normalized_landmarks"),ju(e,"world_landmarks"),ju(e,"segmentation_masks");const t=new xu;ec(t,Fh,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"NORM_LANDMARKS:normalized_landmarks"),_u(n,"WORLD_LANDMARKS:world_landmarks"),n.o(t),Nu(e,n),tf(this,e),this.g.attachProtoVectorListener("normalized_landmarks",((e,t)=>{this.landmarks=[];for(const t of e)e=pd(t),this.landmarks.push(Bh(e));ef(this,t)})),this.g.attachEmptyPacketListener("normalized_landmarks",(e=>{this.landmarks=[],ef(this,e)})),this.g.attachProtoVectorListener("world_landmarks",((e,t)=>{this.worldLandmarks=[];for(const t of e)e=ud(t),this.worldLandmarks.push(Oh(e));ef(this,t)})),this.g.attachEmptyPacketListener("world_landmarks",(e=>{this.worldLandmarks=[],ef(this,e)})),this.outputSegmentationMasks&&(_u(n,"SEGMENTATION_MASK:segmentation_masks"),nf(this,"segmentation_masks"),this.g.T("segmentation_masks",((e,t)=>{this.v=e.map((e=>Wf(this,e,!this.s))),ef(this,t)})),this.g.attachEmptyPacketListener("segmentation_masks",(e=>{this.v=[],ef(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Vp.prototype.detectForVideo=Vp.prototype.G,Vp.prototype.detect=Vp.prototype.F,Vp.prototype.setOptions=Vp.prototype.o,Vp.createFromModelPath=function(e,t){return $f(Vp,e,{baseOptions:{modelAssetPath:t}})},Vp.createFromModelBuffer=function(e,t){return $f(Vp,e,{baseOptions:{modelAssetBuffer:t}})},Vp.createFromOptions=function(e,t){return $f(Vp,e,t)},Vp.POSE_CONNECTIONS=Nf([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]);var Wp;function Hp(e,t,n,r){t.forEach((function(t){var o=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 o=1;o<t.length;o++){var i=t[o];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 a=0;a<6;a++){var s=o[a][0],l=o[a][1];e.beginPath(),e.arc(s,l,3,0,2*Math.PI),e.fill()}}}))}function Kp(){return v(this,void 0,void 0,(function(){var e;return b(this,(function(t){switch(t.label){case 0:return Wp?[2,Wp]:[4,qh.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.7/wasm")];case 1:return e=t.sent(),[4,Kf.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,Wp=t.sent()]}}))}))}var Yp,Xp,Jp=t.createContext({start:function(){return null},stop:function(){return null},onPredictionMade:function(){return null},canvasRef:{current:null},ready:!1}),Zp=function(e){var n=e.autoStart,r=void 0===n||n,o=e.children,i=e.throttleMs,a=t.useContext(tn),s=a.videoRef,l=a.videoLoaded,u=a.cameraReady,d=t.useRef(null),h=t.useRef(),f=t.useState(!1),p=f[0],g=f[1],y=t.useState(!1),w=y[0],x=y[1],E=t.useRef(null),S=t.useRef(0),k=t.useRef(0),C=t.useState(null),T=C[0],A=C[1];t.useEffect((function(){v(void 0,void 0,void 0,(function(){var e,t;return b(this,(function(n){switch(n.label){case 0:g(!1),n.label=1;case 1:return n.trys.push([1,3,,4]),e=E,[4,Kp()];case 2:return e.current=n.sent(),[3,4];case 3:return t=n.sent(),A(t),[3,4];case 4:return g(!0),[2]}}))}))}),[]),t.useEffect((function(){if(l&&u&&w&&p){var e;k.current+=1;var t=k.current;return v(void 0,void 0,void 0,(function(){var n,r,o,a;return b(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===(o=s.current)||void 0===o?void 0:o.videoWidth,d.current.height=null===(a=s.current)||void 0===a?void 0:a.videoHeight,null==n||n.translate(s.current.videoWidth,0),null==n||n.scale(-1,1)),[4,function r(){var o;return v(this,void 0,void 0,(function(){var a,l,c,u,d;return b(this,(function(f){switch(f.label){case 0:return E.current&&s.current&&t===k.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:a=s.current.videoWidth,l=s.current.videoHeight,null==n||n.drawImage(s.current,0,0,a,l),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,E.current.detectForVideo(s.current,performance.now())];case 4:return(c=f.sent())&&(u=c.detections.map((function(e){var t,n,r,o,i,s,c,u,d,h,f,p,g,v,b,y;return{keypoints:e.keypoints.map((function(e){var t;return m(m({},e),{x:e.x*a,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!==(o=null===(r=e.boundingBox)||void 0===r?void 0:r.originX)&&void 0!==o?o:0)+(null!==(s=null===(i=e.boundingBox)||void 0===i?void 0:i.width)&&void 0!==s?s:0),yMin:null!==(u=null===(c=e.boundingBox)||void 0===c?void 0:c.originY)&&void 0!==u?u:0,yMax:(null!==(h=null===(d=e.boundingBox)||void 0===d?void 0:d.originY)&&void 0!==h?h:0)+(null!==(p=null===(f=e.boundingBox)||void 0===f?void 0:f.height)&&void 0!==p?p:0),width:null!==(v=null===(g=e.boundingBox)||void 0===g?void 0:g.width)&&void 0!==v?v:0,height:null!==(y=null===(b=e.boundingBox)||void 0===b?void 0:b.height)&&void 0!==y?y:0}}})),null===(o=h.current)||void 0===o||o.call(h,u),n&&Hp(n,u,!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(){S.current=requestAnimationFrame(r)}),i):S.current=requestAnimationFrame(r),[2]}}))}))}()]):[2];case 1:return l.sent(),[2]}}))})),function(){S.current&&cancelAnimationFrame(S.current),e&&clearTimeout(e)}}}),[u,p,w,i,l,s]);var I=t.useCallback((function(){x(!0)}),[]),R=t.useCallback((function(){x(!1)}),[]);t.useEffect((function(){return r&&I(),function(){R()}}),[r,I,R]);var D=t.useCallback((function(e){h.current=e}),[]),_=t.useMemo((function(){return{start:I,stop:R,ready:p,canvasRef:d,onPredictionMade:D}}),[D,p,I,R]);return c.createElement(Jp.Provider,{value:_},T?c.createElement(Bo,{error:T}):o)},Qp=d.default.div(Yp||(Yp=w(["\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"})),eg=d.default.div(Xp||(Xp=w(["\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"})),tg=function(e,n,r,o){var i=t.useState(!1),a=i[0],s=i[1],l=t.useState(),c=l[0],u=l[1];return t.useEffect((function(){if(e){u(new Date);var t=setTimeout((function(){s(!0)}),e);return function(){t&&clearTimeout(t)}}}),[e]),t.useEffect((function(){if(a&&!r){if(o){var e=setTimeout((function(){null==n||n()}),1e4);return function(){clearTimeout(e)}}null==n||n()}}),[n,o,a,r]),{timedOut:a,timeoutStartedAt:c}},ng={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},rg=function(e,t){switch(t.type){case"configure":return m(m({},e),{videoWidth:t.payload.videoWidth,videoHeight:t.payload.videoHeight});case"capturing":return m(m({},e),{capturing:!0,captured:!1,captureFailed:!1});case"captured":return m(m({},e),{capturing:!1,captured:!0,captureFailed:!1});case"captureFailed":return m(m({},e),{capturing:!1,captured:!1,captureFailed:!0});case"facesDetected":var n=t.payload.faces,r=n[0],o=!0,i=!1,a=!1,s=!1,l=e.faceReadyAt,c=e.goodFramesCount;if(r){var u=e.videoHeight/2,d=(r.box.xMin+r.box.xMax)/2,h=(r.box.yMin+r.box.yMax)/2,f=.125*e.videoWidth,p=.125*e.videoHeight,g=.2*r.box.width,v=.2*r.box.height,b=r.keypoints[2];b&&(o=Math.abs(e.videoWidth/2-d)>f||Math.abs(u+50-h)>p,i=Math.abs(d-b.x)>g||Math.abs(h-b.y)>v);var y=e.videoWidth<e.videoHeight;a=r.box.width>e.videoWidth/(y?2:4.5),s=r.box.width<e.videoWidth/(y?6:7)}var w=!(o||i||a||s);return w?e.faceReady||(l=new Date):(l=null,c=0),m(m({},e),{faces:n,faceNotCentered:o,faceLookingAway:i,faceTooClose:a,faceTooFar:s,faceReady:w,faceReadyAt:l,goodFramesCount:c})}},og=function(e){var n,r=e.onGuidanceSatisfied,o=e.onGuidanceNotSatisfied,i=e.onSelfieCaptured,a=e.onTimeout,s=e.onExit,c=e.timeoutDurationMs,u=void 0===c?15e3:c,d=e.guidanceMessage,h=e.guidanceSatisfied,f=e.colors,p=void 0===f?{}:f,g=e.verbiage,m=void 0===g?{}:g,y=e.debugMode,w=void 0!==y&&y,x=Bt(),E=x.ref,S=x.width,k=void 0===S?1:S,C=x.height,T=void 0===C?1:C,A=t.useReducer(rg,ng),I=A[0],R=A[1],D=t.useContext(tn),_=D.cameraRef,F=D.cameraReady,M=D.takePhoto,L=D.videoRef,P=t.useContext(Jp).onPredictionMade;t.useEffect((function(){F&&L.current&&0!==L.current.videoWidth&&R({type:"configure",payload:{videoWidth:L.current.videoWidth,videoHeight:L.current.videoHeight}})}),[F,L]),t.useEffect((function(){P((function(e){R({type:"facesDetected",payload:{faces:e}})}))}),[P]);var B=t.useState(!1),O=B[0],N=B[1];t.useEffect((function(){var e;return I.faceReady?(null==r||r(),e=setTimeout((function(){N(!0)}),1e3)):null==o||o(),function(){e&&clearTimeout(e)}}),[o,r,I.faceReady]),t.useEffect((function(){v(void 0,void 0,void 0,(function(){var e,t;return b(this,(function(n){switch(n.label){case 0:return O&&I.faces.length>0?[4,M()]:[3,5];case 1:return(e=n.sent())?null!=i?[3,2]:[3,4]:[3,5];case 2:return t=i,[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]}}))}))}),[O,i,I.faces,M]);var U=tg(u,a),j=U.timedOut,G=U.timeoutStartedAt,$=ni({enabled:w,pageWidth:k,pageHeight:T,videoWidth:I.videoWidth,videoHeight:I.videoHeight});p.guidesUnsatisfiedColor||(p.guidesUnsatisfiedColor="white"),p.guidesSatisfiedColor||(p.guidesSatisfiedColor="green"),p.guidanceMessagesUnsatisfiedBackgroundColor||(p.guidanceMessagesUnsatisfiedBackgroundColor="red"),p.guidanceMessagesSatisfiedBackgroundColor||(p.guidanceMessagesSatisfiedBackgroundColor="green"),p.guidanceMessagesUnsatisfiedTextColor||(p.guidanceMessagesUnsatisfiedTextColor="white"),p.guidanceMessagesSatisfiedTextColor||(p.guidanceMessagesSatisfiedTextColor="white");var z=xi(m,{guidanceHoldStillText:"Hold still for a few seconds...",guidanceLookStraightText:"Look straight into the camera...",guidanceMoveBackText:"Move back...",guidanceMoveForwardText:"Move forward...",guidanceMoveToCenterText:"Move to the center..."});d||(d=I.faceReady?z.guidanceHoldStillText:I.faceLookingAway?z.guidanceLookStraightText:I.faceTooClose?z.guidanceMoveBackText:I.faceTooFar?z.guidanceMoveForwardText:I.faceNotCentered?z.guidanceMoveToCenterText:"");var q=I.faceReady;return"boolean"==typeof h&&(q=h),l.default.createElement(ot,{ref:E,className:"flex"},l.default.createElement(Fi,null),l.default.createElement(Ni,{borderColor:q?p.guidesSatisfiedColor:p.guidesUnsatisfiedColor}),""!==d&&l.default.createElement(Qp,null,l.default.createElement(eg,{$background:q?p.guidanceMessagesSatisfiedBackgroundColor:p.guidanceMessagesUnsatisfiedBackgroundColor,$textColor:q?p.guidanceMessagesSatisfiedTextColor:p.guidanceMessagesUnsatisfiedTextColor},d)),w&&I.faces.length>0&&l.default.createElement(Qo,{$flipX:!(null===(n=_.current)||void 0===n?void 0:n.isRearFacing)},I.faces.map((function(e,t){var n;return l.default.createElement(oi,{key:t,face:e,scaling:$,flipX:!(null===(n=_.current)||void 0===n?void 0:n.isRearFacing),color:q?"green":"red"})}))),w&&l.default.createElement(Zo,null,_.current?l.default.createElement(l.default.Fragment,null,"✅ Camera: ",_.current.label," (",_.current.width,"x",_.current.height,")"):"❌ Camera not ready",l.default.createElement("br",null),I.faceNotCentered?"❌":"✅"," Face Centered",l.default.createElement("br",null),I.faceTooClose||I.faceTooFar?"❌":"✅"," Face"," ",I.faceTooClose?"Too Close":I.faceTooFar?"Too Far":"Distance Correct",l.default.createElement("br",null),I.faceLookingAway?"❌":"✅"," Face Looking Forward",l.default.createElement("br",null),I.goodFramesThresholdMet?"✅":"❌"," ",I.goodFramesCount," ","Good Frames",l.default.createElement("br",null),j?"❌":"✅"," Time Remaining:"," ",Math.max(0,u-((new Date).getTime()-(null!=G?G:new Date).getTime())),"ms"),l.default.createElement(di,{onClick:s},"×"))},ig={frame:null,face:null,requestState:"CAPTURING",requestError:null,imageUrl:null,faceLive:!1,eyeCoveringDetected:!1,maskDetected:!1,headCoveringDetected:!1,phoneDetected:!1,timesLivenessCheckFailed:0},ag=function(e,t){switch(t.type){case"livenessReady":return["CAPTURING","FAILED","ERROR"].includes(e.requestState)?m(m({},e),{requestState:"CAPTURED",frame:t.payload.frame,face:t.payload.face}):e;case"livenessChecking":return m(m({},e),{requestState:"IN_PROGRESS"});case"livenessChecked":var n=t.payload.response,r=n.status,o=r.statusMessage,i=r.errorData,a=n.resultData;if("000"!==r.statusCode)return m(m({},e),{requestState:"ERROR",requestError:new Error("".concat(o,": ").concat(i))});var s="Live Face Detected"===a.verificationResult,l="true"===a.eyeCovering,c="true"===a.faceMask,u="true"===a.headCovering,d="true"===a.cellPhone,h=s&&!l&&!c&&!u,f=h?"PASSED":"FAILED",p=e.timesLivenessCheckFailed;return h?p=0:p+=1,m(m({},e),{frame:t.payload.frame,face:t.payload.face,imageUrl:t.payload.imageUrl,requestState:f,faceLive:s,eyeCoveringDetected:l,maskDetected:c,headCoveringDetected:u,phoneDetected:d,timesLivenessCheckFailed:p});case"livenessCheckFailed":return m(m({},e),{requestState:"ERROR",requestError:t.payload.error});default:return e}},sg=function(e){var n=e.onCapture,r=e.onSuccess,o=e.onTimeout,i=e.onExit,a=e.timeoutDurationMs,s=void 0===a?15e3:a,c=e.colors,u=void 0===c?{}:c,d=e.verbiage,h=void 0===d?{}:d,f=e.debugMode,p=t.useContext(Ye),g=p.checkLiveness,m=p.submissionError,y=t.useReducer(ag,ig),w=y[0],x=y[1],E=t.useState(null),S=E[0],k=E[1],C=t.useCallback((function(e,t){null==n||n(),x({type:"livenessReady",payload:{frame:e,face:t}})}),[n]),T=w.frame,A=w.face,I="CAPTURED"===w.requestState,R="PASSED"===w.requestState;t.useEffect((function(){T&&A&&I&&!m&&(x({type:"livenessChecking"}),v(void 0,void 0,void 0,(function(){var e,t,n,r;return b(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),e=Po(T,A),k(e),n=g,[4,Qe(e)];case 1:return[4,n.apply(void 0,[o.sent()])];case 2:return t=o.sent(),x({type:"livenessChecked",payload:{frame:T,face:A,imageUrl:e,response:t}}),[3,4];case 3:return r=o.sent(),x({type:"livenessCheckFailed",payload:{error:r}}),[3,4];case 4:return[2]}}))})))}),[g,A,T,I,m]),t.useEffect((function(){R&&w.imageUrl&&(null==r||r(w.imageUrl))}),[r,w.imageUrl,R]),t.useEffect((function(){w.timesLivenessCheckFailed>=2&&(null==o||o())}),[o,w.timesLivenessCheckFailed]),tg(s,o,"PASSED"===w.requestState,"IN_PROGRESS"===w.requestState);var D=xi(h,{guidanceRemoveEyeCoveringsText:"Please remove your eye coverings (sunglasses, eye patch, etc.)...",guidanceRemoveHeadCoveringsText:"Please remove your head coverings (hat, scarf, etc.)...",guidanceRemoveMaskText:"Please remove your mask..."}),_=w.eyeCoveringDetected?D.guidanceRemoveEyeCoveringsText:w.headCoveringDetected?D.guidanceRemoveHeadCoveringsText:w.maskDetected?D.guidanceRemoveMaskText:void 0;return l.default.createElement(l.default.Fragment,null,l.default.createElement(og,{onSelfieCaptured:C,onExit:i,timeoutDurationMs:s,guidanceMessage:_,guidanceSatisfied:!_&&void 0,colors:u,verbiage:D,debugMode:f}),S&&l.default.createElement(pi,{imageUrl:S}))},lg=function(e){var n=e.onDismissed,r=e.assets,o=void 0===r?{}:r,i=e.colors,a=void 0===i?{}:i,s=e.verbiage,c=void 0===s?{}:s,u=t.useContext(tn),d=u.cameraReady,h=u.cameraAccessDenied,f=t.useContext(Jp).ready;o.instructionImageUrl||(o.instructionImageUrl="".concat(Mo,"/Selfie-Image-1.png"));var p=xi(c,{headingText:"Use your device camera to capture your face",removeEyeCoveringsText:"Remove Sunglasses & Hat",avoidExcessiveBacklightingText:"Avoid Excessive Backlighting",continueText:"Continue",cameraInitializingText:"Camera initializing...",modelsWarmingUpText:"Models warming up..."}),g=t.useState(!1),m=g[1];return g[0]?l.default.createElement(l.default.Fragment,null):h?l.default.createElement(Ii,{assets:o.cameraAccessDenied,colors:a.cameraAccessDenied,verbiage:c.cameraAccessDenied}):l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("div",{style:{flexGrow:0}},l.default.createElement("h3",{style:{marginBottom:18}},p.headingText),l.default.createElement("div",{style:{background:"#ccc",maxWidth:"280px",margin:"0 auto 12px",borderRadius:8,lineHeight:1.5,padding:"12px 24px"}},p.removeEyeCoveringsText,l.default.createElement("br",null),p.avoidExcessiveBacklightingText)),l.default.createElement(dt,null,l.default.createElement("img",{alt:p.headingText,src:o.instructionImageUrl,style:{position:"relative",top:"5%"}})),l.default.createElement(kt,{disabled:!d||!f,finished:d&&f,colors:a.continueBtn,onClick:function(){m(!0),null==n||n()}},d&&f?p.continueText:f?p.cameraInitializingText:p.modelsWarmingUpText),l.default.createElement("div",{style:{display:"none"}},l.default.createElement(Fi,null))))},cg=function(e){var t,n,r=e.imageUrl,o=e.onDoneClick,i=e.onRetryClick,a=e.colors,s=void 0===a?{}:a,c=e.verbiage,u=void 0===c?{}:c;s.retryBtn||(s.retryBtn={}),(t=s.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=s.retryBtn).textColor||(n.textColor="white");var d=xi(u,{headingText:"Face liveness has been verified!",retryBtnText:"Retry",doneBtnText:"Done"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},d.headingText),l.default.createElement(dt,null,l.default.createElement("img",{alt:d.headingText,src:r})),l.default.createElement("div",null,l.default.createElement(kt,{onClick:i,colors:s.retryBtn,finished:!0},d.retryBtnText),l.default.createElement(kt,{onClick:o,colors:s.doneBtn,style:{marginLeft:15},finished:!0},d.doneBtnText))))},ug=function(e){var t,n,r,o,i=e.canRetry,a=void 0===i||i,s=e.onRetryClick,c=e.onExitClick,u=e.assets,d=void 0===u?{}:u,h=e.colors,f=void 0===h?{}:h,p=e.verbiage,g=void 0===p?{}:p;d.imageUrl||(d.imageUrl="".concat(Mo,"/manual_capture.png")),f.retryBtn||(f.retryBtn={}),(t=f.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=f.retryBtn).textColor||(n.textColor="white"),f.exitBtn||(f.exitBtn={}),(r=f.exitBtn).backgroundColor||(r.backgroundColor="#666"),(o=f.exitBtn).textColor||(o.textColor="white");var m=xi(g,{headingText:"Live face not detected, please try again",retryBtnText:"Retry",exitBtnText:"Exit"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},m.headingText),l.default.createElement(dt,{style:{maxHeight:"calc(100vh - 185px)"}},l.default.createElement("img",{alt:m.headingText,src:d.imageUrl})),l.default.createElement("div",{style:{marginTop:24}},a&&l.default.createElement(kt,{onClick:s,colors:f.retryBtn,style:{marginRight:15},finished:!0},m.retryBtnText),l.default.createElement(kt,{onClick:c,colors:f.exitBtn,finished:!0},m.exitBtnText))))},dg=function(e){var n=e.onComplete,r=e.onSuccess,o=e.onTimeout,i=e.onExitAfterFailure,a=e.timeoutDurationMs,s=void 0===a?15e3:a,c=e.maxRetries,u=void 0===c?2:c,d=e.skipSuccessScreen,h=void 0!==d&&d,f=e.assets,p=void 0===f?{}:f,g=e.colors,m=void 0===g?{}:g,y=e.verbiage,w=void 0===y?{}:y,x=e.debugMode,E=void 0!==x&&x,S=t.useContext(Ye),k=S.submissionResponse,C=S.setSelfieImage,T=S.logSelfieCaptureAttempt,A=t.useContext(tn).releaseCameraAccess,I=t.useState(""),R=I[0],D=I[1],_=t.useState(0),F=_[0],M=_[1],L=t.useState("LOADING"),P=L[0],B=L[1],O=t.useRef(),N=t.useRef(),U=t.useRef();t.useEffect((function(){U.current=new Date}),[]),t.useEffect((function(){"CAPTURING"===P&&(O.current=new Date)}),[P]);var j=t.useCallback((function(){N.current=new Date}),[]),G=t.useCallback((function(){var e,t,n;T({autoCapture:"Y",captureTime:(null!==(e=N.current)&&void 0!==e?e:new Date).getTime()-(null!==(t=O.current)&&void 0!==t?t:new Date).getTime(),operationTime:(new Date).getTime()-(null!==(n=U.current)&&void 0!==n?n:new Date).getTime()}),U.current=new Date}),[T]),$=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){var t;return b(this,(function(n){switch(n.label){case 0:return B("SUCCESS"),D(e),t=C,[4,Qe(e)];case 1:return t.apply(void 0,[n.sent()]),null==r||r(k),[2]}}))}))}),[r,C,k]),z=t.useCallback((function(){B("FAILED"),null==o||o(k)}),[o,k]),q=t.useState(0),V=q[0],W=q[1],H=t.useCallback((function(){W((function(e){return e+1})),B("LOADING")}),[]),K=t.useCallback((function(){G(),A(),setTimeout((function(){null==n||n(k)}),0)}),[G,n,A,k]),Y=Li(h,"SUCCESS"===P,K);return l.default.createElement(l.default.Fragment,null,"LOADING"!==P&&function(){switch(P){case"CAPTURING":return l.default.createElement(sg,{key:"capture".concat(V),onCapture:j,onSuccess:$,onTimeout:z,onExit:H,timeoutDurationMs:s,colors:m,verbiage:w,debugMode:E});case"SUCCESS":return Y?l.default.createElement(cg,{key:"success",imageUrl:R,colors:m.success,verbiage:w.success,onDoneClick:K,onRetryClick:function(){G(),B("CAPTURING")}}):null;case"FAILED":return l.default.createElement(ug,{key:"failure",assets:p.failure,colors:m.failure,verbiage:w.failure,canRetry:u>-1&&F<u,onRetryClick:function(){G(),M((function(e){return e+1})),B("CAPTURING")},onExitClick:function(){A(),setTimeout((function(){null==i||i(k)}),0)}});default:return null}}(),l.default.createElement(lg,{key:V,assets:p.loadingOverlay,colors:m.loadingOverlay,verbiage:w.loadingOverlay,onDismissed:function(){B("CAPTURING")}}))},hg=function(e){var n=e.children,r=t.useState({width:1,height:1}),o=r[1],i=t.useState(1),a=i[0],s=i[1],c=Bt(),u=c.ref,d=c.width,h=void 0===d?1:d,f=c.height,p=void 0===f?1:f,g=h/p,m=t.useCallback((function(e){var t=e.target;s(t.naturalWidth/t.naturalHeight)}),[]);return l.default.createElement(Ot.Provider,{value:{orientation:"landscape",wrapperWidth:h,wrapperHeight:p,wrapperAspectRatio:g,imageAspectRatio:a,setDimensions:o,wrapperRef:u,onImageLoaded:m}},n)},fg=function(){var e=t.useContext(Ye),n=e.submissionRequest,r=e.submissionResponse,o=t.useState(!1),i=o[0],a=o[1],s=t.useState(!0),c=s[0],u=s[1],d=t.useMemo((function(){var e,t,r,o,i,a,s=JSON.parse(JSON.stringify(n));return c&&((null===(t=null===(e=null==s?void 0:s.customerData)||void 0===e?void 0:e.idData)||void 0===t?void 0:t.idImageFront)&&(s.customerData.idData.idImageFront=pg(s.customerData.idData.idImageFront,200)),(null===(o=null===(r=null==s?void 0:s.customerData)||void 0===r?void 0:r.idData)||void 0===o?void 0:o.idImageBack)&&(s.customerData.idData.idImageBack=pg(s.customerData.idData.idImageBack,200)),(null===(a=null===(i=null==s?void 0:s.customerData)||void 0===i?void 0:i.biometricData)||void 0===a?void 0:a.selfie)&&(s.customerData.biometricData.selfie=pg(s.customerData.biometricData.selfie,200))),JSON.stringify(s,null,2)}),[n,c]);return l.default.createElement(l.default.Fragment,null,l.default.createElement("h3",null,"Submission completed!"),l.default.createElement("button",{onClick:function(){a(!i)}},i?"Hide":"Show"," request body"),i&&l.default.createElement(l.default.Fragment,null,l.default.createElement("button",{style:{marginLeft:8},onClick:function(){u(!c)}},c?"Display full images":"Truncate images"),l.default.createElement("h5",null,"Request Body"),l.default.createElement("pre",null,d)),l.default.createElement("h5",null,"Response Body"),l.default.createElement("pre",null,JSON.stringify(r,null,2)))};function pg(e,t){var n=e.split("").splice(0,t).join("");return n.length<e.length&&(n+="..."),n}var gg=function(e){var n=e.document,r=e.onComplete,o=e.verbiage,i=void 0===o?{}:o,a=t.useState(null),s=a[0],c=a[1],u=xi(i,{headingText:"Additional document capture",nextBtnText:"Next"});return l.default.createElement(ct,null,l.default.createElement(ut,{style:{textAlign:"left"}},l.default.createElement("h3",{style:{margin:"0 0 8px"}},u.headingText,": ",n.name),n.description&&l.default.createElement("p",{style:{margin:"8px 0"}},n.description),l.default.createElement("p",{style:{margin:"8px 0"}},l.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)}})),l.default.createElement("p",{style:{margin:"8px 0"}},l.default.createElement("button",{disabled:!s,onClick:function(e){if(e.preventDefault(),s){var t=new FileReader;t.onloadend=function(){if(t.result){var e=t.result.toString();null==r||r({documentName:n.name,additionalDocument:{name:s.name,fileContent:et(e),type:tt(e),fileUploadType:"Y",isImageControlData:"N",fieldId:""}})}},t.readAsDataURL(s)}}},u.nextBtnText))))},mg=function(e){var n=e.documents,r=e.onComplete,o=e.verbiage,i=void 0===o?{}:o,a=t.useState([]),s=a[0],c=a[1],u=s.length,d=n[u],h=u>=n.length;return t.useEffect((function(){(null==d?void 0:d.skip)&&v(void 0,void 0,void 0,(function(){var e;return b(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()&&c((function(e){return y(y([],e,!0),[null],!1)})),[2]}}))}))}),[d]),t.useEffect((function(){h&&(null==r||r(s.filter((function(e){return!!e}))))}),[h,r,s]),h?l.default.createElement(l.default.Fragment,null,"Thanks, your documents have been received."):l.default.createElement(gg,{key:u,document:d,verbiage:i,onComplete:function(e){c((function(t){return y(y([],t,!0),[e],!1)}))}})},vg="function"==typeof Symbol&&Symbol.for,bg=vg?Symbol.for("react.element"):60103,yg=vg?Symbol.for("react.portal"):60106,wg=vg?Symbol.for("react.fragment"):60107,xg=vg?Symbol.for("react.strict_mode"):60108,Eg=vg?Symbol.for("react.profiler"):60114,Sg=vg?Symbol.for("react.provider"):60109,kg=vg?Symbol.for("react.context"):60110,Cg=vg?Symbol.for("react.async_mode"):60111,Tg=vg?Symbol.for("react.concurrent_mode"):60111,Ag=vg?Symbol.for("react.forward_ref"):60112,Ig=vg?Symbol.for("react.suspense"):60113,Rg=vg?Symbol.for("react.suspense_list"):60120,Dg=vg?Symbol.for("react.memo"):60115,_g=vg?Symbol.for("react.lazy"):60116,Fg=vg?Symbol.for("react.block"):60121,Mg=vg?Symbol.for("react.fundamental"):60117,Lg=vg?Symbol.for("react.responder"):60118,Pg=vg?Symbol.for("react.scope"):60119;function Bg(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case bg:switch(e=e.type){case Cg:case Tg:case wg:case Eg:case xg:case Ig:return e;default:switch(e=e&&e.$$typeof){case kg:case Ag:case _g:case Dg:case Sg:return e;default:return t}}case yg:return t}}}function Og(e){return Bg(e)===Tg}var Ng={AsyncMode:Cg,ConcurrentMode:Tg,ContextConsumer:kg,ContextProvider:Sg,Element:bg,ForwardRef:Ag,Fragment:wg,Lazy:_g,Memo:Dg,Portal:yg,Profiler:Eg,StrictMode:xg,Suspense:Ig,isAsyncMode:function(e){return Og(e)||Bg(e)===Cg},isConcurrentMode:Og,isContextConsumer:function(e){return Bg(e)===kg},isContextProvider:function(e){return Bg(e)===Sg},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===bg},isForwardRef:function(e){return Bg(e)===Ag},isFragment:function(e){return Bg(e)===wg},isLazy:function(e){return Bg(e)===_g},isMemo:function(e){return Bg(e)===Dg},isPortal:function(e){return Bg(e)===yg},isProfiler:function(e){return Bg(e)===Eg},isStrictMode:function(e){return Bg(e)===xg},isSuspense:function(e){return Bg(e)===Ig},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===wg||e===Tg||e===Eg||e===xg||e===Ig||e===Rg||"object"==typeof e&&null!==e&&(e.$$typeof===_g||e.$$typeof===Dg||e.$$typeof===Sg||e.$$typeof===kg||e.$$typeof===Ag||e.$$typeof===Mg||e.$$typeof===Lg||e.$$typeof===Pg||e.$$typeof===Fg)},typeOf:Bg};ae((function(e,t){}));ae((function(e){e.exports=Ng}));function Ug(){}function jg(){}jg.resetWarningCache=Ug;var Gg=ae((function(e){e.exports=function(){function e(e,t,n,r,o,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var a=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 a.name="Invariant Violation",a}}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:jg,resetWarningCache:Ug};return n.PropTypes=n,n}()}));function $g(e,t,n){this.x=e,this.y=t,this.time=n||(new Date).getTime()}function zg(e,t,n,r){this.startPoint=e,this.control1=t,this.control2=n,this.endPoint=r}function qg(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,o,i,a=null,s=0;n||(n={});var l=function(){s=!1===n.leading?0:Date.now(),a=null,i=e.apply(r,o),a||(r=o=null)};return function(){var c=Date.now();s||!1!==n.leading||(s=c);var u=t-(c-s);return r=this,o=arguments,u<=0||u>t?(a&&(clearTimeout(a),a=null),s=c,i=e.apply(r,o),a||(r=o=null)):a||!1===n.trailing||(a=setTimeout(l,u)),i}}(qg.prototype._strokeUpdate,this.throttle):qg.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()}$g.prototype.velocityFrom=function(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):1},$g.prototype.distanceTo=function(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))},$g.prototype.equals=function(e){return this.x===e.x&&this.y===e.y&&this.time===e.time},zg.prototype.length=function(){for(var e=0,t=void 0,n=void 0,r=0;r<=10;r+=1){var o=r/10,i=this._point(o,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),a=this._point(o,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){var s=i-t,l=a-n;e+=Math.sqrt(s*s+l*l)}t=i,n=a}return e},zg.prototype._point=function(e,t,n,r,o){return t*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*r*(1-e)*e*e+o*e*e*e},qg.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},qg.prototype.fromDataURL=function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new Image,o=n.ratio||window.devicePixelRatio||1,i=n.width||this._canvas.width/o,a=n.height||this._canvas.height/o;this._reset(),r.src=e,r.onload=function(){t._ctx.drawImage(r,0,0,i,a)},this._isEmpty=!1},qg.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),o=1;o<n;o++)r[o-1]=arguments[o];return(t=this._canvas).toDataURL.apply(t,[e].concat(r))},qg.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},qg.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)},qg.prototype.isEmpty=function(){return this._isEmpty},qg.prototype._strokeBegin=function(e){this._data.push([]),this._reset(),this._strokeUpdate(e),"function"==typeof this.onBegin&&this.onBegin(e)},qg.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],o=r&&t.distanceTo(r)<this.minDistance;if(!r||!o){var i=this._addPoint(t),a=i.curve,s=i.widths;a&&s&&this._drawCurve(a,s.start,s.end),this._data[this._data.length-1].push({x:t.x,y:t.y,time:t.time,color:this.penColor})}},qg.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)},qg.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)},qg.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)},qg.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._ctx.fillStyle=this.penColor},qg.prototype._createPoint=function(e,t,n){var r=this._canvas.getBoundingClientRect();return new $g(e-r.left,t-r.top,n||(new Date).getTime())},qg.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 o=new zg(t[1],r,n.c1,t[2]),i=this._calculateCurveWidths(o);return t.shift(),{curve:o,widths:i}}return{}},qg.prototype._calculateCurveControlPoints=function(e,t,n){var r=e.x-t.x,o=e.y-t.y,i=t.x-n.x,a=t.y-n.y,s=(e.x+t.x)/2,l=(e.y+t.y)/2,c=(t.x+n.x)/2,u=(t.y+n.y)/2,d=Math.sqrt(r*r+o*o),h=Math.sqrt(i*i+a*a),f=h/(d+h),p=t.x-(c+(s-c)*f),g=t.y-(u+(l-u)*f);return{c1:new $g(s+p,l+g),c2:new $g(c+p,u+g)}},qg.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},qg.prototype._strokeWidth=function(e){return Math.max(this.maxWidth/(e+1),this.minWidth)},qg.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},qg.prototype._drawCurve=function(e,t,n){var r=this._ctx,o=n-t,i=Math.floor(e.length());r.beginPath();for(var a=0;a<i;a+=1){var s=a/i,l=s*s,c=l*s,u=1-s,d=u*u,h=d*u,f=h*e.startPoint.x;f+=3*d*s*e.control1.x,f+=3*u*l*e.control2.x;var p=h*e.startPoint.y;p+=3*d*s*e.control1.y,p+=3*u*l*e.control2.y,this._drawPoint(f+=c*e.endPoint.x,p+=c*e.endPoint.y,t+c*o)}r.closePath(),r.fill()},qg.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()},qg.prototype._fromData=function(e,t,n){for(var r=0;r<e.length;r+=1){var o=e[r];if(o.length>1)for(var i=0;i<o.length;i+=1){var a=o[i],s=new $g(a.x,a.y,a.time),l=a.color;if(0===i)this.penColor=l,this._reset(),this._addPoint(s);else if(i!==o.length-1){var c=this._addPoint(s),u=c.curve,d=c.widths;u&&d&&t(u,d,l)}}else this._reset(),n(o[0])}},qg.prototype._toSVG=function(){var e=this,t=this._data,n=this._canvas,r=Math.max(window.devicePixelRatio||1,1),o=n.width/r,i=n.height/r,a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttributeNS(null,"width",n.width),a.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 o="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",o),r.setAttribute("stroke-width",(2.25*t.end).toFixed(3)),r.setAttribute("stroke",n),r.setAttribute("fill","none"),r.setAttribute("stroke-linecap","round"),a.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),a.appendChild(n)}));var s='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 '+o+" "+i+'" width="'+o+'" height="'+i+'">',l=a.innerHTML;if(void 0===l){var c=document.createElement("dummy"),u=a.childNodes;c.innerHTML="";for(var d=0;d<u.length;d+=1)c.appendChild(u[d].cloneNode(!0));l=c.innerHTML}return"data:image/svg+xml;base64,"+btoa(s+l+"</svg>")},qg.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},qg.prototype.toData=function(){return this._data};var Vg=Object.freeze({__proto__:null,default:qg}),Wg=ae((function(e,t){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.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,o=t.getImageData(0,0,n,r).data,s=i(!0,n,r,o),l=i(!1,n,r,o),c=a(!0,n,r,o),u=a(!1,n,r,o)-c+1,d=l-s+1,h=t.getImageData(c,s,u,d);return e.width=u,e.height=d,t.clearRect(0,0,u,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 o(e,t,n,o){return r(e,t,n,o).alpha}function i(e,t,n,r){for(var i=e?1:-1,a=e?0:n-1;e?a<n:a>-1;a+=i)for(var s=0;s<t;s++)if(o(s,a,t,r))return a;return null}function a(e,t,n,r){for(var i=e?1:-1,a=e?0:t-1;e?a<t:a>-1;a+=i)for(var s=0;s<n;s++)if(o(a,s,t,r))return a;return null}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n}])}));ie(Wg);var Hg=function(e){return e&&e.default||e}(Vg),Kg=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 o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.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 o(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 a(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},c=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}}(),u=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),c=0;c<s;c++)l[c]=arguments[c];return n=r=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(l))),r._sigPad=null,r._excludeOurProps=function(){var e=r.props;return o(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 o=r._canvas,i=Math.max(window.devicePixelRatio||1,1);t||(o.width=o.offsetWidth*i),n||(o.height=o.offsetHeight*i),o.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()},a(r,n)}return s(t,e),c(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:u.default.number,minWidth:u.default.number,maxWidth:u.default.number,minDistance:u.default.number,dotSize:u.default.oneOfType([u.default.number,u.default.func]),penColor:u.default.string,throttle:u.default.number,onEnd:u.default.func,onBegin:u.default.func,canvasProps:u.default.object,clearOnResize:u.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}])}(Gg,l.default,Hg,Wg)})),Yg=ie(Kg);function Xg(e){var t,n=null!==(t=e.toDataURL())&&void 0!==t?t:null,r={clickX_simple:[],clickY_simple:[],time_simple:[],pressure:"",fileContent:n?et(n):""};return e.toData().forEach((function(e){var t=[],n=[],o=[];e.forEach((function(e){t.push(e.x),n.push(e.y),o.push(new Date(e.time).toString())})),r.clickX_simple.push(t),r.clickY_simple.push(n),r.time_simple.push(o)})),r}var Jg,Zg,Qg,em,tm,nm=d.default.div(Jg||(Jg=w(["\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"]))),rm=d.default.div(Zg||(Zg=w(["\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"]))),om=d.default.div(Qg||(Qg=w(["\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"]))),im=d.default.div(em||(em=w(["\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"]))),am=function(e){var n=e.onAccept,r=e.verbiage,o=void 0===r?{}:r,i=Bt(),a=i.ref,s=i.width,c=i.height,u=t.useRef(null),d=xi(o,{headingText:"Please sign the box below",acceptBtnText:"Accept",clearBtnText:"Clear"});return l.default.createElement(ot,null,l.default.createElement(im,null,l.default.createElement(Qp,{$top:"5vh"},l.default.createElement(eg,null,d.headingText)),l.default.createElement(nm,null,l.default.createElement(rm,{ref:a},l.default.createElement(Yg,{ref:u,canvasProps:{width:s,height:c}})),l.default.createElement(om,null,l.default.createElement("button",{onClick:function(e){var t;e.preventDefault(),null===(t=u.current)||void 0===t||t.clear()}},d.clearBtnText),l.default.createElement("button",{style:{marginLeft:"auto"},onClick:function(e){if(e.preventDefault(),u.current){var t=Xg(u.current);null==n||n(t,u.current.toDataURL())}}},d.acceptBtnText)))))},sm=function(e){var n,r,o=e.onVideoCaptured,i=e.onFaceNotDetected,a=e.onExit,s=e.colors,c=void 0===s?{}:s,u=e.verbiage,d=void 0===u?{}:u,h=e.debugMode,f=void 0!==h&&h,p=t.useContext(tn),g=p.cameraRef,m=p.videoRef,w=Bt(),x=w.ref,E=w.width,S=w.height,k=t.useRef(null),C=t.useRef(null),T=t.useRef([]),A=t.useState(null),I=A[0],R=A[1],D=t.useContext(Jp).onPredictionMade,_=function(e){var n=t.useRef(null),r=t.useRef([]),o=t.useState(null),i=o[0],a=o[1],s=t.useState(!1),l=s[0],c=s[1],u=null==e?void 0:e.stream,d=t.useCallback((function(){u&&(r.current=[],c(!0),n.current=new MediaRecorder(u),n.current.ondataavailable=function(e){r.current.push(e.data)},n.current.onstop=function(){var t=new Blob(r.current,{type:"video/mp4"});r.current=[],a(URL.createObjectURL(t)),c(!1),null==e||e.release()},n.current.start())}),[e,u]),h=t.useCallback((function(){var e;null===(e=n.current)||void 0===e||e.stop()}),[]);return{isRecording:l,startRecording:d,stopRecording:h,videoUrl:i}}(g.current),F=_.isRecording,M=_.startRecording,L=_.stopRecording,P=_.videoUrl,B=t.useState(null),O=B[0],N=B[1],U=t.useState(null),j=U[0],G=U[1],$=t.useState(null),z=$[0],q=$[1];c.guidanceMessageBackgroundColor||(c.guidanceMessageBackgroundColor="#ccc"),c.guidanceMessageTextColor||(c.guidanceMessageTextColor="black");var V=xi(d,{guidanceMessageText:"Please sign the box below",acceptBtnText:"Accept",clearBtnText:"Clear"}),W=t.useRef(null);t.useEffect((function(){setTimeout((function(){if(!F&&!P&&W.current){M();var e=W.current.captureStream(25);C.current=new MediaRecorder(e,{}),C.current.start(),C.current.ondataavailable=function(e){var t;T.current.push(e.data),"recording"===(null===(t=C.current)||void 0===t?void 0:t.state)&&C.current.stop()},C.current.onstop=function(){var e=new Blob(T.current,{type:"video/mp4"});q(e);var t=URL.createObjectURL(e);R(t)}}}),100)}),[F,M,P]),t.useEffect((function(){z&&O&&j&&(null==o||o(z,O,j))}),[o,O,j,z]);var H=t.useRef(0);t.useEffect((function(){var e;if(k.current&&m.current&&W.current&&g.current&&F){var t=[g.current.width,g.current.height],n=t[0],r=t[1],o=window.innerWidth<window.innerHeight;o&&n>r&&(n=(e=[r,n])[0],r=e[1]),W.current.width=n,W.current.height=r;var i=W.current.getContext("2d");if(i)return H.current=requestAnimationFrame((function e(){return v(this,void 0,void 0,(function(){var t;return b(this,(function(a){return k.current&&m.current&&W.current?(t=[n*(o?.02:.15),r*(o?.15:.25),n*(o?.96:.7),r*(o?.7:.5)],i.drawImage(m.current,0,0,n,r),i.beginPath(),i.fillStyle="rgba(255,255,255,0.5)",i.roundRect.apply(i,y(y([],t,!1),[16],!1)),i.fill(),i.drawImage.apply(i,y([k.current.getCanvas()],t,!1)),H.current=requestAnimationFrame(e),[2]):(cancelAnimationFrame(H.current),[2])}))}))})),function(){cancelAnimationFrame(H.current)}}}),[g,F,i,m]);var K=t.useState(0),Y=K[0],X=K[1];return t.useEffect((function(){D((function(e){X((function(t){return 0===e.length?t+1:0}))}))}),[D]),t.useEffect((function(){Y>=2&&(null==i||i())}),[Y,i]),!F&&P?l.default.createElement(l.default.Fragment,null,I&&l.default.createElement("video",{src:I,controls:!0,width:"100%"}),j&&l.default.createElement("img",{src:j,alt:"signature"}),O&&l.default.createElement("textarea",{readOnly:!0,style:{width:"100%",height:500},value:JSON.stringify(O,null,2)})):l.default.createElement(ot,{className:"flex"},l.default.createElement(Fi,null),V.guidanceMessageText&&l.default.createElement(Qp,{$top:"5vh"},l.default.createElement(eg,{$background:c.guidanceMessageBackgroundColor,$textColor:c.guidanceMessageTextColor},V.guidanceMessageText)),l.default.createElement(nm,null,l.default.createElement(rm,{ref:x},l.default.createElement(Yg,{ref:k,canvasProps:{width:E,height:S}})),l.default.createElement(om,null,l.default.createElement("button",{onClick:function(e){var t;e.preventDefault(),null===(t=k.current)||void 0===t||t.clear()}},V.clearBtnText),l.default.createElement("button",{style:{marginLeft:"auto"},onClick:function(e){var t;if(e.preventDefault(),k.current){var n=Xg(k.current);N(n),G(k.current.toDataURL()),L(),null===(t=C.current)||void 0===t||t.stop()}}},V.acceptBtnText))),f&&l.default.createElement(Zo,null,"Video: ",null===(n=g.current)||void 0===n?void 0:n.width,"x",null===(r=g.current)||void 0===r?void 0:r.height),l.default.createElement(di,{onClick:a},"×"),l.default.createElement("div",{style:{display:"none"}},l.default.createElement("canvas",{ref:W})))},lm=function(e){var t=e.assets,n=e.verbiage;return l.default.createElement(lg,{assets:void 0===t?{}:t,verbiage:void 0===n?{}:n,onDismissed:e.onDismissed})},cm=function(e){var t,n,r=e.videoUrl,o=e.onDoneClick,i=e.onRetryClick,a=e.colors,s=void 0===a?{}:a,c=e.verbiage,u=void 0===c?{}:c;s.retryBtn||(s.retryBtn={}),(t=s.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=s.retryBtn).textColor||(n.textColor="white");var d=xi(u,{headingText:"Video signature has been successfully captured!",retryBtnText:"Retry",doneBtnText:"Done"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h1",null,d.headingText),l.default.createElement(dt,null,l.default.createElement(um,{src:r,poster:r+"#t=0.1",controls:!0,preload:"metadata",autoPlay:!0})),l.default.createElement("div",null,l.default.createElement(kt,{onClick:i,colors:s.retryBtn,finished:!0},d.retryBtnText),l.default.createElement(kt,{onClick:o,colors:s.doneBtn,style:{marginLeft:15},finished:!0},d.doneBtnText))))},um=d.default.video(tm||(tm=w(["\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"]))),dm=function(e){var n=e.onComplete,r=e.onVideoCaptured,o=e.onRetryClicked,i=e.skipSuccessScreen,a=void 0!==i&&i,s=e.assets,c=void 0===s?{}:s,u=e.colors,d=void 0===u?{}:u,h=e.verbiage,f=void 0===h?{}:h,p=e.debugMode,g=void 0!==p&&p,m=t.useContext(Ye),y=m.selfieImage,w=m.signatureVideo,x=m.setSelfieImage,E=m.setSignatureData,S=m.setSignatureVideo,k=m.logSelfieCaptureAttempt,C=t.useState("LOADING"),T=C[0],A=C[1],I=t.useRef(),R=t.useRef(),D=t.useRef();t.useEffect((function(){I.current=new Date}),[]),t.useEffect((function(){"CHECKING_LIVENESS"===T&&(R.current=new Date)}),[T]);var _=t.useCallback((function(){var e,t,n;k({autoCapture:"Y",captureTime:(null!==(e=D.current)&&void 0!==e?e:new Date).getTime()-(null!==(t=R.current)&&void 0!==t?t:new Date).getTime(),operationTime:(new Date).getTime()-(null!==(n=I.current)&&void 0!==n?n:new Date).getTime()}),I.current=new Date}),[k]),F=t.useCallback((function(){A("CHECKING_LIVENESS")}),[]),M=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){var t;return b(this,(function(n){switch(n.label){case 0:return A("CAPTURING_SIGNATURE"),_(),y?[3,2]:(t=x,[4,Qe(e)]);case 1:t.apply(void 0,[n.sent()]),n.label=2;case 2:return[2]}}))}))}),[_,y,x]),L=t.useCallback((function(e,t,n){E(t),S(URL.createObjectURL(e)),A("SUCCESS"),null==r||r(e,t,n)}),[r,E,S]),P=t.useCallback((function(){A("CHECKING_LIVENESS")}),[]),B=t.useState(0),O=B[0],N=B[1],U=t.useCallback((function(){N((function(e){return e+1})),A("LOADING")}),[]),j=t.useCallback((function(){null==o||o(),U()}),[U,o]),G=Li(a,"SUCCESS"===T,n);return l.default.createElement(Zp,{throttleMs:"CAPTURING_SIGNATURE"===T?250:0},"LOADING"!==T&&function(){switch(T){case"CHECKING_LIVENESS":return l.default.createElement(sg,{onSuccess:M,onExit:U,colors:d.faceLiveness,verbiage:f.faceLiveness,debugMode:g});case"CAPTURING_SIGNATURE":return l.default.createElement(sm,{onVideoCaptured:L,onFaceNotDetected:P,onExit:U,colors:d,verbiage:f,debugMode:g});case"SUCCESS":if(!G)return;return l.default.createElement(cm,{videoUrl:null!=w?w:"",onDoneClick:n,onRetryClick:j,colors:d.success,verbiage:f.success});default:return null}}(),l.default.createElement(lm,{key:O,onDismissed:F,assets:c.loadingOverlay,verbiage:f.loadingOverlay}))},hm=function(e){var n,r,o,i,a,s=e.checks,c=e.idCaptureProps,u=void 0===c?{}:c,d=e.faceLivenessProps,h=void 0===d?{}:d,f=e.signatureCaptureProps,p=void 0===f?{}:f,g=e.videoSignatureCaptureProps,v=void 0===g?{}:g,b=e.additionalDocumentCaptureProps,w=e.captureSignature,x=void 0!==w&&w,E=e.captureSignatureVideo,S=void 0!==E&&E,k=e.debugMode,C=void 0!==k&&k,T=t.useContext(Ye),A=T.submit,I=T.submissionStatus,R=T.setSignatureData,D=T.setAdditionalDocuments,_=t.useState(0),F=_[0],M=_[1],L=t.useMemo((function(){var e,t,n=y([],s,!0);if(x&&S)throw new Error("captureSignature and captureSignatureVideo cannot be used together");return x&&n.push("SignatureCapture"),S&&(n.push("VideoSignatureCapture"),n.includes("FaceLiveness")&&n.splice(n.indexOf("FaceLiveness"),1)),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===(n=null==b?void 0:b.documents)||void 0===n?void 0:n.length,x,S,s]),P=L[F],B=F>=L.length;t.useEffect((function(){"SignatureCapture"===P&&"function"==typeof x?x().then((function(e){e||M((function(e){return e+1}))})):"VideoSignatureCapture"===P&&"function"==typeof S&&S().then((function(e){e||M((function(e){return e+1}))}))}),[x,S,P]),t.useEffect((function(){B&&A()}),[B,A]);var O=u.onSuccess,N=t.useCallback((function(e){null==O||O(e),M((function(e){return e+1}))}),[O]),U=h.onComplete,j=t.useCallback((function(e){null==U||U(e),M((function(e){return e+1}))}),[U]),G=t.useCallback((function(e){R(e),M((function(e){return e+1}))}),[R]),$=v.onComplete,z=t.useCallback((function(){null==$||$(),M((function(e){return e+1}))}),[$]),q=t.useState(0),V=q[0],W=q[1],H=v.onRetryClicked,K=t.useCallback((function(){null==H||H(),W((function(e){return e+1}))}),[H]),Y=null==b?void 0:b.onComplete,X=t.useCallback((function(e){D(e),null==Y||Y(e),M((function(e){return e+1}))}),[Y,D]),J=t.useMemo((function(){var e;return null!==(e=null==b?void 0:b.documents)&&void 0!==e?e:[]}),[null==b?void 0:b.documents]);if(B)switch(I){case Ve.SUBMITTING:return l.default.createElement(ot,{className:"flex"},l.default.createElement(hi,null));case Ve.SUBMITTED:return l.default.createElement(fg,null);case Ve.FAILED:return l.default.createElement(l.default.Fragment,null,"Submission failed!");default:return l.default.createElement(l.default.Fragment,null,"Complete!!")}switch(L[F]){case"IdCapture":return l.default.createElement(Go,{documentDetectionModelUrl:null!==(o=null===(r=u.assets)||void 0===r?void 0:r.documentDetectionModelUrl)&&void 0!==o?o:"",focusModelUrl:null!==(a=null===(i=u.assets)||void 0===i?void 0:i.focusModelUrl)&&void 0!==a?a:"",logPredictions:C},l.default.createElement(nn,{key:"IdCaptureCamera"},l.default.createElement(hg,null,l.default.createElement(Oi,m({},u,{onSuccess:N})))));case"FaceLiveness":return l.default.createElement(nn,{key:"FaceLivenessCamera",preferFrontFacingCamera:!0,preferContinuityCamera:!1},l.default.createElement(Zp,null,l.default.createElement(dg,m({},h,{onComplete:j}))));case"SignatureCapture":return l.default.createElement(am,m({},p,{onAccept:G}));case"VideoSignatureCapture":return l.default.createElement(nn,{key:"SignatureKycCamera-".concat(V),preferContinuityCamera:!1,preferFrontFacingCamera:!0},l.default.createElement(dm,m({},v,{onComplete:z,onRetryClicked:K})));case"AdditionalDocumentCapture":return l.default.createElement(mg,m({},b,{documents:J,onComplete:X}));default:return l.default.createElement(l.default.Fragment,null)}},fm=function(e){var n=e.lang,r=e.submissionToken,o=e.submissionEnvironment,i=void 0===o?"prod":o,a=e.submissionUrl,s=e.companyId,c=e.manualReviewRequired,u=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,b=e.idCardAutoCaptureScoreThreshold,y=void 0===b?.8:b,w=e.passportAutoCaptureScoreThreshold,x=void 0===w?.75:w,E=e.idCardFocusScoreThreshold,S=void 0===E?.3:E,k=e.passportFocusScoreThreshold,C=void 0===k?.3:k,T=e.skipSuccessScreen,A=void 0!==T&&T,I=e.onBeforeSubmit,R=e.onComplete,D=e.onApproved,_=e.onDenied,F=e.assets,M=void 0===F?{}:F,L=e.colors,P=void 0===L?{}:L,B=e.verbiage,O=void 0===B?{}:B,N=e.captureSignature,U=void 0!==N&&N,j=e.captureSignatureVideo,G=void 0!==j&&j,$=e.captureAdditionalDocuments,z=void 0===$?[]:$,q=e.geolocationEnabled,V=void 0===q||q,W=e.geolocationRequired,H=void 0!==W&&W,K=e.debugMode,Y=void 0!==K&&K;yi(void 0===n?"auto":n);var X=t.useMemo((function(){return{autoCaptureEnabled:v,idCardAutoCaptureScoreThreshold:y,passportAutoCaptureScoreThreshold:x,mrzDetectionScoreThreshold:.5,idCardFocusScoreThreshold:S,passportFocusScoreThreshold:C,barcodeScanningEnabled:!1,skipSuccessScreen:A,assets:M,colors:P,verbiage:O,debugMode:Y}}),[M,P,Y,v,y,S,x,C,A,O]),J=t.useMemo((function(){return{documents:z,verbiage:null==O?void 0:O.additionalDocumentCapture}}),[z,null==O?void 0:O.additionalDocumentCapture]),Z=t.useMemo((function(){return{verbiage:null==O?void 0:O.signatureCapture}}),[null==O?void 0:O.signatureCapture]),Q=t.useMemo((function(){return{skipSuccessScreen:A,colors:null==P?void 0:P.videoSignatureCapture,verbiage:null==O?void 0:O.videoSignatureCapture,debugMode:Y}}),[null==P?void 0:P.videoSignatureCapture,Y,A,null==O?void 0:O.videoSignatureCapture]),ee=t.useCallback((function(e){null==R||R(e),"Approved"===e.resultData.verificationResult?null==D||D(e):null==_||_(e)}),[D,R,_]);return l.default.createElement(Ft,{action:qe.VALIDATE,environment:i,url:a,token:r,companyId:s,manualReviewRequired:c,verifyIdWithExternalDatabases:u,personalData:d,cardData:h,webhooksEnabled:f,webhooksClientTraceId:p,webhooksStripSpecialCharacters:g,onBeforeSubmit:I,onResponseReceived:ee,geolocationEnabled:V,geolocationRequired:H},l.default.createElement(hm,{checks:t.useMemo((function(){return["IdCapture"]}),[]),idCaptureProps:X,signatureCaptureProps:Z,videoSignatureCaptureProps:Q,additionalDocumentCaptureProps:J,captureSignature:U,captureSignatureVideo:G,debugMode:Y}))},pm=function(e){var n=e.lang,r=e.submissionToken,o=e.submissionEnvironment,i=void 0===o?"prod":o,a=e.submissionUrl,s=e.companyId,c=e.webhooksEnabled,u=e.webhooksClientTraceId,d=e.webhooksStripSpecialCharacters,h=e.timeoutDurationMs,f=void 0===h?15e3:h,p=e.skipSuccessScreen,g=void 0!==p&&p,m=e.onBeforeSubmit,v=e.onComplete,b=e.onApproved,y=e.onDenied,w=e.onExitAfterFailure,x=e.assets,E=e.colors,S=e.verbiage,k=e.geolocationEnabled,C=void 0===k||k,T=e.geolocationRequired,A=void 0!==T&&T,I=e.debugMode,R=void 0!==I&&I;yi(void 0===n?"auto":n);var D=t.useMemo((function(){return{timeoutDurationMs:f,skipSuccessScreen:g,onComplete:v,onSuccess:b,onTimeout:y,onExitAfterFailure:w,assets:x,colors:E,verbiage:S,debugMode:R}}),[x,E,R,b,v,y,w,g,f,S]);return l.default.createElement(Ft,{action:qe.NONE,environment:i,url:a,token:r,companyId:s,webhooksEnabled:c,webhooksClientTraceId:u,webhooksStripSpecialCharacters:d,onBeforeSubmit:m,geolocationEnabled:C,geolocationRequired:A},l.default.createElement(hm,{checks:t.useMemo((function(){return["FaceLiveness"]}),[]),faceLivenessProps:D,debugMode:R}))},gm=function(e){var n=e.lang,r=e.submissionToken,o=e.submissionEnvironment,i=void 0===o?"prod":o,a=e.submissionUrl,s=e.companyId,c=e.manualReviewRequired,u=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,b=e.idCardAutoCaptureScoreThreshold,y=void 0===b?.8:b,w=e.mrzDetectionScoreThreshold,x=void 0===w?.5:w,E=e.passportAutoCaptureScoreThreshold,S=void 0===E?.75:E,k=e.idCardFocusScoreThreshold,C=void 0===k?.3:k,T=e.passportFocusScoreThreshold,A=void 0===T?.3:T,I=e.faceLivenessTimeoutDurationMs,R=void 0===I?15e3:I,D=e.skipSuccessScreen,_=void 0!==D&&D,F=e.onBeforeSubmit,M=e.onComplete,L=e.onApproved,P=e.onDenied,B=e.onExitAfterFailure,O=e.captureSignature,N=void 0!==O&&O,U=e.captureSignatureVideo,j=void 0!==U&&U,G=e.captureAdditionalDocuments,$=void 0===G?[]:G,z=e.assets,q=void 0===z?{}:z,V=e.colors,W=void 0===V?{}:V,H=e.verbiage,K=void 0===H?{}:H,Y=e.geolocationEnabled,X=void 0===Y||Y,J=e.geolocationRequired,Z=void 0!==J&&J,Q=e.debugMode,ee=void 0!==Q&&Q;yi(void 0===n?"auto":n);var te=t.useMemo((function(){return{assets:q.idCapture,colors:W.idCapture,verbiage:K.idCapture,autoCaptureEnabled:v,idCardAutoCaptureScoreThreshold:y,passportAutoCaptureScoreThreshold:S,mrzDetectionScoreThreshold:x,idCardFocusScoreThreshold:C,passportFocusScoreThreshold:A,skipSuccessScreen:_,debugMode:ee}}),[q.idCapture,W.idCapture,ee,v,y,C,x,S,A,_,K.idCapture]),ne=t.useMemo((function(){return{timeoutDurationMs:R,onTimeout:P,onExitAfterFailure:B,skipSuccessScreen:_,assets:q.faceLiveness,colors:W.faceLiveness,verbiage:K.faceLiveness,debugMode:ee}}),[q.faceLiveness,W.faceLiveness,ee,R,P,B,_,K.faceLiveness]),re=t.useMemo((function(){return{verbiage:K.signatureCapture}}),[null==K?void 0:K.signatureCapture]),oe=t.useMemo((function(){return{skipSuccessScreen:_,colors:null==W?void 0:W.videoSignatureCapture,verbiage:null==K?void 0:K.videoSignatureCapture,debugMode:ee}}),[null==W?void 0:W.videoSignatureCapture,ee,_,null==K?void 0:K.videoSignatureCapture]),ie=t.useMemo((function(){return{documents:$,verbiage:null==K?void 0:K.additionalDocumentCapture}}),[$,null==K?void 0:K.additionalDocumentCapture]),ae=t.useCallback((function(e){null==M||M(e),"Approved"===e.resultData.verificationResult?null==L||L(e):null==P||P(e)}),[L,M,P]);return l.default.createElement(Ft,{action:qe.VALIDATE,environment:i,url:a,token:r,companyId:s,manualReviewRequired:c,verifyIdWithExternalDatabases:u,personalData:d,cardData:h,webhooksEnabled:f,webhooksClientTraceId:p,webhooksStripSpecialCharacters:g,onBeforeSubmit:F,onResponseReceived:ae,geolocationEnabled:X,geolocationRequired:Z},l.default.createElement(hm,{checks:t.useMemo((function(){return["IdCapture","FaceLiveness"]}),[]),idCaptureProps:te,faceLivenessProps:ne,signatureCaptureProps:re,videoSignatureCaptureProps:oe,additionalDocumentCaptureProps:ie,captureSignature:N,captureSignatureVideo:j,debugMode:ee}))},mm=function(e){var n=e.enrollmentId,r=e.lang,o=e.submissionToken,i=e.submissionEnvironment,a=void 0===i?"prod":i,s=e.submissionUrl,c=e.companyId,u=e.manualReviewRequired,d=e.verifyIdWithExternalDatabases,h=e.personalData,f=e.cardData,p=e.deduplicationEnabled,g=e.deduplicationSynchronous,m=e.webhooksEnabled,v=e.webhooksClientTraceId,b=e.webhooksStripSpecialCharacters,y=e.idAutoCaptureEnabled,w=void 0===y||y,x=e.idCardAutoCaptureScoreThreshold,E=void 0===x?.8:x,S=e.mrzDetectionScoreThreshold,k=void 0===S?.5:S,C=e.passportAutoCaptureScoreThreshold,T=void 0===C?.75:C,A=e.idCardFocusScoreThreshold,I=void 0===A?.3:A,R=e.passportFocusScoreThreshold,D=void 0===R?.3:R,_=e.faceLivenessTimeoutDurationMs,F=void 0===_?15e3:_,M=e.skipSuccessScreen,L=void 0!==M&&M,P=e.onBeforeSubmit,B=e.onComplete,O=e.onEnrolled,N=e.onDenied,U=e.onExitAfterFailure,j=e.captureAdditionalDocuments,G=void 0===j?[]:j,$=e.captureSignature,z=void 0!==$&&$,q=e.captureSignatureVideo,V=void 0!==q&&q,W=e.assets,H=void 0===W?{}:W,K=e.colors,Y=void 0===K?{}:K,X=e.verbiage,J=void 0===X?{}:X,Z=e.geolocationEnabled,Q=void 0===Z||Z,ee=e.geolocationRequired,te=void 0!==ee&&ee,ne=e.debugMode,re=void 0!==ne&≠yi(void 0===r?"auto":r);var oe=t.useMemo((function(){return{assets:H.idCapture,colors:Y.idCapture,verbiage:J.idCapture,autoCaptureEnabled:w,idCardAutoCaptureScoreThreshold:E,passportAutoCaptureScoreThreshold:T,mrzDetectionScoreThreshold:k,idCardFocusScoreThreshold:I,passportFocusScoreThreshold:D,skipSuccessScreen:L,debugMode:re}}),[H.idCapture,Y.idCapture,re,w,E,I,k,T,D,L,J.idCapture]),ie=t.useMemo((function(){return{onExitAfterFailure:U,timeoutDurationMs:F,skipSuccessScreen:L,assets:H.faceLiveness,colors:Y.faceLiveness,verbiage:J.faceLiveness,debugMode:re}}),[H.faceLiveness,Y.faceLiveness,re,F,U,L,J.faceLiveness]),ae=t.useMemo((function(){return{documents:G,verbiage:J.additionalDocumentCapture}}),[G,J.additionalDocumentCapture]),se=t.useMemo((function(){return{verbiage:null==J?void 0:J.signatureCapture}}),[null==J?void 0:J.signatureCapture]),le=t.useMemo((function(){return{skipSuccessScreen:L,colors:null==Y?void 0:Y.videoSignatureCapture,verbiage:null==J?void 0:J.videoSignatureCapture,debugMode:re}}),[null==Y?void 0:Y.videoSignatureCapture,re,L,null==J?void 0:J.videoSignatureCapture]),ce=t.useCallback((function(e){null==B||B(e),"Customer Onboarded"===e.resultData.verificationResult?null==O||O(e):null==N||N(e)}),[O,B,N]);return l.default.createElement(Ft,{action:qe.ENROLL,environment:a,url:s,token:o,companyId:c,enrollmentId:n,manualReviewRequired:u,verifyIdWithExternalDatabases:d,personalData:h,cardData:f,deduplicationEnabled:p,deduplicationSynchronous:g,webhooksEnabled:m,webhooksClientTraceId:v,webhooksStripSpecialCharacters:b,onBeforeSubmit:P,onResponseReceived:ce,geolocationEnabled:Q,geolocationRequired:te},l.default.createElement(hm,{checks:t.useMemo((function(){return["IdCapture","FaceLiveness"]}),[]),idCaptureProps:oe,faceLivenessProps:ie,additionalDocumentCaptureProps:ae,signatureCaptureProps:se,videoSignatureCaptureProps:le,captureSignature:z,captureSignatureVideo:V,debugMode:re}))},vm={frame:null,face:null,imageUrl:null,requestState:"CAPTURING",requestError:null,unverifiedTimes:0},bm=function(e,t){switch(t.type){case"verificationReady":return["CAPTURING","ERROR"].includes(e.requestState)?m(m({},e),{requestState:"CAPTURED",frame:t.payload.frame,face:t.payload.face}):e;case"verifying":return m(m({},e),{requestState:"VERIFYING",imageUrl:t.payload.imageUrl});case"verificationCompleted":var n=t.payload.response,r=n.status,o=r.statusMessage,i=r.errorData,a=n.resultData;if("000"!==r.statusCode)return m(m({},e),{requestState:"ERROR",requestError:new Error("".concat(o,": ").concat(i))});var s=e.requestState,l=e.unverifiedTimes;return"00"===a.verificationResultCode?s="VERIFIED":l<0?(s="CAPTURING",l+=1):s="REJECTED",m(m({},e),{requestState:s,unverifiedTimes:l});case"verificationFailed":return m(m({},e),{requestState:"ERROR",requestError:t.payload.error});default:return e}},ym=function(e){var n=e.onCustomerMatched,r=e.onCustomerNotMatched,o=e.onCaptureGuidanceTimeout,i=e.onExit,a=e.captureGuidanceTimeoutDurationMs,s=e.colors,c=void 0===s?{}:s,u=e.verbiage,d=void 0===u?{}:u,h=e.debugMode,f=void 0!==h&&h,p=t.useReducer(bm,vm),g=p[0],m=p[1],y=g.frame,w=g.face,x=t.useContext(Ye),E=x.submit,S=x.submissionResponse,k=x.submissionError,C=x.selfieImage,T=x.setSelfieImage,A=t.useState(null),I=A[0],R=A[1],D=t.useCallback((function(e,t){m({type:"verificationReady",payload:{frame:e,face:t}})}),[]),_="CAPTURED"===g.requestState;return t.useEffect((function(){if(y&&w&&!k){var e=Po(y,w);R(e),Qe(e).then((function(e){T(e)}))}}),[w,y,T,k]),t.useEffect((function(){_&&C&&!k&&v(void 0,void 0,void 0,(function(){var e,t;return b(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),m({type:"verifying",payload:{imageUrl:C}}),[4,E()];case 1:if(!(e=n.sent()))throw new Error("submission failed!");return m({type:"verificationCompleted",payload:{response:e}}),[3,3];case 2:return t=n.sent(),m({type:"verificationFailed",payload:{error:t}}),[3,3];case 3:return[2]}}))}))}),[_,n,r,C,g.requestState,k,E]),t.useEffect((function(){S&&("VERIFIED"===g.requestState?null==n||n(S):"REJECTED"===g.requestState&&(null==r||r(S)))}),[n,r,g.requestState,S]),tg(a,o,["VERIFIED","REJECTED"].includes(g.requestState),"VERIFYING"===g.requestState),l.default.createElement(l.default.Fragment,null,l.default.createElement(og,{onSelfieCaptured:D,onExit:i,timeoutDurationMs:a,colors:c,verbiage:d,debugMode:f}),I&&l.default.createElement(pi,{imageUrl:I}))},wm=function(e){var t,n,r=e.imageUrl,o=e.onDoneClick,i=e.onRetryClick,a=e.colors,s=void 0===a?{}:a,c=e.verbiage,u=void 0===c?{}:c;r||(r="".concat(Mo,"/Selfie-Image-1.png")),s.retryBtn||(s.retryBtn={}),(t=s.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=s.retryBtn).textColor||(n.textColor="white");var d=xi(u,{headingText:"Customer has been verified!",retryBtnText:"Retry",doneBtnText:"Done"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},d.headingText),l.default.createElement(dt,{style:{maxHeight:"calc(100vh - 185px)"}},l.default.createElement("img",{alt:d.headingText,src:r})),l.default.createElement("div",{style:{marginTop:24}},l.default.createElement(kt,{onClick:i,colors:s.retryBtn,finished:!0},d.retryBtnText),l.default.createElement(kt,{onClick:o,colors:s.doneBtn,style:{marginLeft:15},finished:!0},d.doneBtnText))))},xm=function(e){var t,n,r,o,i=e.canRetry,a=void 0===i||i,s=e.onRetryClick,c=e.onExitClick,u=e.assets,d=void 0===u?{}:u,h=e.colors,f=void 0===h?{}:h,p=e.verbiage,g=void 0===p?{}:p;d.imageUrl||(d.imageUrl="".concat(Mo,"/manual_capture.png")),f.retryBtn||(f.retryBtn={}),(t=f.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=f.retryBtn).textColor||(n.textColor="white"),f.exitBtn||(f.exitBtn={}),(r=f.exitBtn).backgroundColor||(r.backgroundColor="#666"),(o=f.exitBtn).textColor||(o.textColor="white");var m=xi(g,{headingText:"Customer not verified",retryBtnText:"Retry",exitBtnText:"Exit"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},m.headingText),l.default.createElement(dt,{style:{maxHeight:"calc(100vh - 185px)"}},l.default.createElement("img",{alt:m.headingText,src:d.imageUrl})),l.default.createElement("div",{style:{marginTop:24}},a&&l.default.createElement(kt,{onClick:s,colors:f.retryBtn,style:{marginRight:15},finished:!0},m.retryBtnText),l.default.createElement(kt,{onClick:c,colors:f.exitBtn,finished:!0},m.exitBtnText))))},Em=function(e){var n=e.onComplete,r=e.onCustomerMatched,o=e.onCustomerNotMatched,i=e.onExitAfterFailure,a=e.onCaptureGuidanceTimeout,s=e.captureGuidanceTimeoutDurationMs,c=e.skipSuccessScreen,u=void 0!==c&&c,d=e.assets,h=void 0===d?{}:d,f=e.colors,p=void 0===f?{}:f,g=e.verbiage,m=void 0===g?{}:g,y=e.debugMode,w=void 0!==y&&y,x=t.useContext(Ye),E=x.submissionResponse,S=x.selfieImage,k=t.useState("LOADING"),C=k[0],T=k[1],A=t.useContext(tn).releaseCameraAccess,I=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){return b(this,(function(t){return T("MATCHED"),null==r||r(e),[2]}))}))}),[r]),R=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){return b(this,(function(t){return T("NOT_MATCHED"),null==o||o(e),[2]}))}))}),[o]),D=t.useCallback((function(){T("FAILED"),null==a||a()}),[a]),_=t.useState(0),F=_[0],M=_[1],L=t.useCallback((function(){M((function(e){return e+1})),T("LOADING")}),[]),P=t.useCallback((function(){A(),E&&(null==n||n(E))}),[n,A,E]),B=Li(u,"MATCHED"===C,P);return l.default.createElement(l.default.Fragment,null,"LOADING"!==C&&function(){switch(C){case"CAPTURING":return l.default.createElement(ym,{key:"capture".concat(F),onCustomerMatched:I,onCustomerNotMatched:R,onCaptureGuidanceTimeout:D,onExit:L,captureGuidanceTimeoutDurationMs:s,colors:p,verbiage:m,debugMode:w});case"MATCHED":if(!B)return;return l.default.createElement(wm,{imageUrl:"data:image/png;base64, ".concat(S),colors:p.success,verbiage:m.success,onDoneClick:P,onRetryClick:function(){T("CAPTURING"),M(0)}});case"NOT_MATCHED":case"FAILED":return l.default.createElement(xm,{assets:h.failure,colors:p.failure,verbiage:m.failure,canRetry:F<2,onExitClick:function(){A(),null==i||i()},onRetryClick:function(){M((function(e){return e+1}))}});default:return null}}(),l.default.createElement(lg,{key:F,assets:h.loadingOverlay,colors:p.loadingOverlay,verbiage:m.loadingOverlay,onDismissed:function(){T("CAPTURING")}}))},Sm=function(e){var t=e.lang,n=e.enrollmentId,r=e.submissionToken,o=e.submissionEnvironment,i=void 0===o?"prod":o,a=e.submissionUrl,s=e.companyId,c=e.webhooksEnabled,u=e.webhooksClientTraceId,d=e.webhooksStripSpecialCharacters,h=e.timeoutDurationMs,f=void 0===h?15e3:h,p=e.skipSuccessScreen,g=void 0!==p&&p,m=e.assets,v=e.colors,b=e.verbiage,y=e.onBeforeSubmit,w=e.onComplete,x=e.onCustomerMatched,E=e.onCustomerNotMatched,S=e.onExitAfterFailure,k=e.geolocationEnabled,C=void 0===k||k,T=e.geolocationRequired,A=void 0!==T&&T,I=e.debugMode,R=void 0!==I&&I;return yi(void 0===t?"auto":t),l.default.createElement(Ft,{action:qe.VERIFY,environment:i,url:a,token:r,companyId:s,enrollmentId:n,webhooksEnabled:c,webhooksClientTraceId:u,webhooksStripSpecialCharacters:d,onBeforeSubmit:y,geolocationEnabled:C,geolocationRequired:A},l.default.createElement(nn,{preferFrontFacingCamera:!0},l.default.createElement(Zp,null,l.default.createElement(Em,{onComplete:w,onCustomerMatched:x,onCustomerNotMatched:E,onExitAfterFailure:S,captureGuidanceTimeoutDurationMs:f,skipSuccessScreen:g,assets:m,colors:v,verbiage:b,debugMode:R}))))},km={frame:null,face:null,imageUrl:null,requestState:"CAPTURING",requestError:null,notFoundTimes:0},Cm=function(e,t){switch(t.type){case"identificationReady":return["CAPTURING","ERROR"].includes(e.requestState)?m(m({},e),{requestState:"CAPTURED",frame:t.payload.frame,face:t.payload.face}):e;case"identifying":return m(m({},e),{requestState:"IDENTIFYING",imageUrl:t.payload.imageUrl});case"identificationCompleted":var n=t.payload.response,r=n.status,o=r.statusMessage,i=r.errorData,a=n.resultData;if("000"!==r.statusCode)return m(m({},e),{requestState:"ERROR",requestError:new Error("".concat(o,": ").concat(i))});var s=e.requestState,l=e.notFoundTimes;return"46"===a.verificationResultCode?s="FOUND":l<0?(s="CAPTURING",l+=1):s="NOT_FOUND",m(m({},e),{requestState:s,notFoundTimes:l});case"identificationFailed":return m(m({},e),{requestState:"ERROR",requestError:t.payload.error});default:return e}},Tm=function(e){var n=e.onCustomerMatched,r=e.onCustomerNotMatched,o=e.onCaptureGuidanceTimeout,i=e.onExit,a=e.captureGuidanceTimeoutDurationMs,s=e.colors,c=void 0===s?{}:s,u=e.verbiage,d=void 0===u?{}:u,h=e.debugMode,f=void 0!==h&&h,p=t.useReducer(Cm,km),g=p[0],m=p[1],y=t.useContext(Ye),w=y.submit,x=y.submissionResponse,E=y.submissionError,S=y.selfieImage,k=y.setSelfieImage,C=t.useState(null),T=C[0],A=C[1],I=t.useCallback((function(e,t){m({type:"identificationReady",payload:{frame:e,face:t}})}),[]),R=g.frame,D=g.face,_="CAPTURED"===g.requestState;return t.useEffect((function(){if(R&&D&&!E){var e=Po(R,D);A(e),Qe(e).then((function(e){k(e)}))}}),[D,R,k,E]),t.useEffect((function(){_&&S&&!E&&v(void 0,void 0,void 0,(function(){var e,t;return b(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),m({type:"identifying",payload:{imageUrl:S}}),[4,w()];case 1:if(!(e=n.sent()))throw new Error("submission failed!");return m({type:"identificationCompleted",payload:{response:e}}),[3,3];case 2:return t=n.sent(),m({type:"identificationFailed",payload:{error:t}}),[3,3];case 3:return[2]}}))}))}),[_,n,r,S,g.requestState,E,w]),t.useEffect((function(){x&&("FOUND"===g.requestState?null==n||n(x):"NOT_FOUND"===g.requestState&&(null==r||r(x)))}),[n,r,g.requestState,x]),tg(a,o,["FOUND","NOT_FOUND"].includes(g.requestState),"IDENTIFYING"===g.requestState),l.default.createElement(l.default.Fragment,null,l.default.createElement(og,{onSelfieCaptured:I,onExit:i,timeoutDurationMs:a,colors:c,verbiage:d,debugMode:f}),T&&l.default.createElement(pi,{imageUrl:T}))},Am=function(e){var t,n,r=e.imageUrl,o=e.onDoneClick,i=e.onRetryClick,a=e.colors,s=void 0===a?{}:a,c=e.verbiage,u=void 0===c?{}:c;r||(r="".concat(Mo,"/Selfie-Image-1.png")),s.retryBtn||(s.retryBtn={}),(t=s.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=s.retryBtn).textColor||(n.textColor="white");var d=xi(u,{headingText:"Customer has been identified!",retryBtnText:"Retry",doneBtnText:"Done"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},d.headingText),l.default.createElement(dt,{style:{maxHeight:"calc(100vh - 185px)"}},l.default.createElement("img",{alt:d.headingText,src:r})),l.default.createElement("div",{style:{marginTop:24}},l.default.createElement(kt,{onClick:i,colors:s.retryBtn,finished:!0},d.retryBtnText),l.default.createElement(kt,{onClick:o,colors:s.doneBtn,style:{marginLeft:15},finished:!0},d.doneBtnText))))},Im=function(e){var t,n,r,o,i=e.canRetry,a=void 0===i||i,s=e.onRetryClick,c=e.onExitClick,u=e.assets,d=void 0===u?{}:u,h=e.colors,f=void 0===h?{}:h,p=e.verbiage,g=void 0===p?{}:p;d.imageUrl||(d.imageUrl="".concat(Mo,"/manual_capture.png")),f.retryBtn||(f.retryBtn={}),(t=f.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=f.retryBtn).textColor||(n.textColor="white"),f.exitBtn||(f.exitBtn={}),(r=f.exitBtn).backgroundColor||(r.backgroundColor="#666"),(o=f.exitBtn).textColor||(o.textColor="white");var m=xi(g,{headingText:"Customer not found",retryBtnText:"Retry",exitBtnText:"Exit"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},m.headingText),l.default.createElement(dt,{style:{maxHeight:"calc(100vh - 185px)"}},l.default.createElement("img",{alt:m.headingText,src:d.imageUrl})),l.default.createElement("div",{style:{marginTop:24}},a&&l.default.createElement(kt,{onClick:s,colors:f.retryBtn,style:{marginRight:15},finished:!0},m.retryBtnText),l.default.createElement(kt,{onClick:c,colors:f.exitBtn,finished:!0},m.exitBtnText))))},Rm=function(e){var n=e.onComplete,r=e.onCustomerMatched,o=e.onCustomerNotMatched,i=e.onExitAfterFailure,a=e.onCaptureGuidanceTimeout,s=e.captureGuidanceTimeoutDurationMs,c=e.skipSuccessScreen,u=void 0!==c&&c,d=e.assets,h=void 0===d?{}:d,f=e.colors,p=void 0===f?{}:f,g=e.verbiage,m=void 0===g?{}:g,y=e.debugMode,w=void 0!==y&&y,x=t.useContext(Ye),E=x.submissionResponse,S=x.selfieImage,k=t.useState("LOADING"),C=k[0],T=k[1],A=t.useContext(tn).releaseCameraAccess,I=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){return b(this,(function(t){return T("FOUND"),null==r||r(e),[2]}))}))}),[r]),R=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){return b(this,(function(t){return T("NOT_FOUND"),null==o||o(e),[2]}))}))}),[o]),D=t.useCallback((function(){T("FAILED"),null==a||a()}),[a]),_=t.useState(0),F=_[0],M=_[1],L=t.useCallback((function(){M((function(e){return e+1})),T("LOADING")}),[]),P=t.useCallback((function(){A(),E&&(null==n||n(E))}),[n,A,E]),B=Li(u,"FOUND"===C,P);return l.default.createElement(l.default.Fragment,null,"LOADING"!==C&&function(){switch(C){case"CAPTURING":return l.default.createElement(Tm,{key:"capture".concat(F),onCustomerMatched:I,onCustomerNotMatched:R,onCaptureGuidanceTimeout:D,onExit:L,captureGuidanceTimeoutDurationMs:s,colors:p,verbiage:m,debugMode:w});case"FOUND":if(!B)return;return l.default.createElement(Am,{imageUrl:"data:image/png;base64, ".concat(S),colors:p.success,verbiage:m.success,onDoneClick:P,onRetryClick:function(){T("CAPTURING"),M(0)}});case"NOT_FOUND":case"FAILED":return l.default.createElement(Im,{assets:h.failure,colors:p.failure,verbiage:m.failure,canRetry:F<2,onExitClick:function(){A(),null==i||i()},onRetryClick:function(){M((function(e){return e+1}))}});default:return null}}(),l.default.createElement(lg,{key:F,assets:h.loadingOverlay,colors:p.loadingOverlay,verbiage:m.loadingOverlay,onDismissed:function(){T("CAPTURING")}}))},Dm=function(e){var t=e.lang,n=e.submissionToken,r=e.submissionEnvironment,o=void 0===r?"prod":r,i=e.submissionUrl,a=e.companyId,s=e.webhooksEnabled,c=e.webhooksClientTraceId,u=e.webhooksStripSpecialCharacters,d=e.timeoutDurationMs,h=void 0===d?15e3:d,f=e.skipSuccessScreen,p=void 0!==f&&f,g=e.onBeforeSubmit,m=e.onComplete,v=e.onCustomerMatched,b=e.onCustomerNotMatched,y=e.onCaptureGuidanceTimeout,w=e.onExitAfterFailure,x=e.assets,E=e.colors,S=e.verbiage,k=e.geolocationEnabled,C=e.geolocationRequired,T=void 0!==C&&C,A=e.debugMode,I=void 0!==A&&A;return yi(void 0===t?"auto":t),l.default.createElement(Ft,{action:qe.IDENTIFY,environment:o,url:i,token:n,companyId:a,webhooksEnabled:s,webhooksClientTraceId:c,webhooksStripSpecialCharacters:u,onBeforeSubmit:g,geolocationEnabled:k,geolocationRequired:T},l.default.createElement(nn,{preferFrontFacingCamera:!0},l.default.createElement(Zp,null,l.default.createElement(Rm,{onComplete:m,onCustomerMatched:v,onCustomerNotMatched:b,onExitAfterFailure:w,onCaptureGuidanceTimeout:y,captureGuidanceTimeoutDurationMs:h,skipSuccessScreen:p,assets:x,colors:E,verbiage:S,debugMode:I}))))},_m=function(e){var t=e.documentDetectionModel,n=void 0===t?"".concat(Mo,"/models/documentdetection448/model.json"):t,r=e.focusModel,o=void 0===r?"".concat(Mo,"/models/focus/model.json"):r,i=e.skipFaceDetectionModel,a=void 0!==i&&i;return v(void 0,void 0,void 0,(function(){return b(this,(function(e){switch(e.label){case 0:return n?[4,Mt(n)]:[3,2];case 1:e.sent(),e.label=2;case 2:return o?[4,rn(o)]:[3,4];case 3:e.sent(),e.label=4;case 4:return a?[3,6]:[4,Kp()];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},Fm=function(e){var n=e.enrollmentId,r=e.lang,o=e.submissionToken,i=e.submissionEnvironment,a=void 0===i?"prod":i,s=e.submissionUrl,c=e.companyId,u=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.skipSuccessScreen,b=void 0!==v&&v,y=e.onBeforeSubmit,w=e.onComplete,x=e.onEnrolled,E=e.onDenied,S=e.onExitAfterFailure,k=e.captureAdditionalDocuments,C=void 0===k?[]:k,T=e.captureSignature,A=void 0!==T&&T,I=e.captureSignatureVideo,R=void 0!==I&&I,D=e.assets,_=void 0===D?{}:D,F=e.colors,M=void 0===F?{}:F,L=e.verbiage,P=void 0===L?{}:L,B=e.geolocationEnabled,O=void 0===B||B,N=e.geolocationRequired,U=void 0!==N&&N,j=e.debugMode,G=void 0!==j&&j;yi(void 0===r?"auto":r);var $=t.useMemo((function(){return{onExitAfterFailure:S,timeoutDurationMs:m,skipSuccessScreen:b,assets:_.faceLiveness,colors:M.faceLiveness,verbiage:P.faceLiveness,debugMode:G}}),[_.faceLiveness,M.faceLiveness,G,S,b,m,P.faceLiveness]),z=t.useMemo((function(){return{documents:C,verbiage:P.additionalDocumentCapture}}),[C,P.additionalDocumentCapture]),q=t.useMemo((function(){return{verbiage:P.signatureCapture}}),[P.signatureCapture]),V=t.useMemo((function(){return{skipSuccessScreen:b,colors:null==M?void 0:M.videoSignatureCapture,verbiage:null==P?void 0:P.videoSignatureCapture,debugMode:G}}),[null==M?void 0:M.videoSignatureCapture,G,b,null==P?void 0:P.videoSignatureCapture]),W=t.useCallback((function(e){null==w||w(e),"Customer Onboarded"===e.resultData.verificationResult?null==x||x(e):null==E||E(e)}),[x,w,E]);return l.default.createElement(Ft,{action:qe.ENROLL,environment:a,url:s,token:o,companyId:c,enrollmentId:n,deduplicationEnabled:u,deduplicationSynchronous:d,webhooksEnabled:h,webhooksClientTraceId:f,webhooksStripSpecialCharacters:p,onBeforeSubmit:y,onResponseReceived:W,geolocationEnabled:O,geolocationRequired:U},l.default.createElement(hm,{checks:t.useMemo((function(){return["FaceLiveness"]}),[]),faceLivenessProps:$,additionalDocumentCaptureProps:z,signatureCaptureProps:q,videoSignatureCaptureProps:V,captureSignature:A,captureSignatureVideo:R,debugMode:G}))},Mm=function(e){var n=e.submissionToken,r=e.submissionEnvironment,o=e.submissionUrl,i=e.onBeforeSubmit,a=e.onComplete,s=e.skipSuccessScreen,c=void 0!==s&&s,u=e.colors,d=e.verbiage,h=e.geolocationEnabled,f=e.geolocationRequired,p=e.debugMode,g=t.useState(0),m=g[1];return l.default.createElement(Ft,{action:qe.NONE,environment:r,url:o,token:n,onBeforeSubmit:i,onResponseReceived:a,geolocationEnabled:h,geolocationRequired:f},l.default.createElement(nn,{key:g[0],preferContinuityCamera:!1,preferFrontFacingCamera:!0},l.default.createElement(dm,{skipSuccessScreen:c,colors:u,debugMode:p,verbiage:d,onRetryClicked:function(){m((function(e){return e+1}))}})))};oe.use(ze).use(ve).init({resources:bi,detection:{caches:[]},fallbackLng:"en",debug:!1,interpolation:{escapeValue:!1}}),void 0!==u&&u.init&&u.init({dsn:"https://0a8e0e8df645473abe217b60b50fbcb1@o4505120557367296.ingest.sentry.io/4505120582008832",tracesSampleRate:1,debug:!0});var Lm=function(e,t){if("string"==typeof t){var n=document.querySelector(t);if(!n)throw new Error("targetElement ".concat(t," not found"));t=n}var r=i.createPortal(l.default.createElement(ct,null,e),document.body);f.default.render(r,t),new MutationObserver((function(e,n){document.body.contains(t)||(n.disconnect(),f.default.unmountComponentAtNode(t))})).observe(document.body,{childList:!0})},Pm=function(e,t){Lm(l.default.createElement(fm,m({},t)),e)},Bm=function(e,t){Lm(l.default.createElement(pm,m({},t)),e)},Om=function(e,t){Lm(l.default.createElement(gm,m({},t)),e)},Nm=function(e,t){Lm(l.default.createElement(mm,m({},t)),e)},Um=function(e,t){Lm(l.default.createElement(Fm,m({},t)),e)},jm=function(e,t){Lm(l.default.createElement(Sm,m({},t)),e)},Gm=function(e,t){Lm(l.default.createElement(Dm,m({},t)),e)},$m=function(e,t){Lm(l.default.createElement(Mm,m({},t)),e)};globalThis.IDmissionSDK={renderIdValidation:Pm,renderFaceValidation:Bm,renderIdAndFaceValidation:Om,renderCustomerIdAndBiometricsEnrollment:Nm,renderCustomerBiometricsEnrollment:Um,renderCustomerVerification:jm,renderCustomerIdentification:Gm,renderSignatureKYC:$m,preloadModels:_m,version:We,ready:!0},e.CustomerBiometricsEnrollment=Fm,e.CustomerIdAndBiometricsEnrollment=mm,e.CustomerIdentification=Dm,e.CustomerVerification=Sm,e.FaceValidation=pm,e.IdAndFaceValidation=gm,e.IdValidation=fm,e.SignatureKYC=Mm,e.preloadModels=_m,e.renderCustomerBiometricsEnrollment=Um,e.renderCustomerIdAndBiometricsEnrollment=Nm,e.renderCustomerIdentification=Gm,e.renderCustomerVerification=jm,e.renderFaceValidation=Bm,e.renderIdAndFaceValidation=Om,e.renderIdValidation=Pm,e.renderSignatureKYC=$m,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@sentry/react"),require("styled-components"),require("@tensorflow/tfjs"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","@sentry/react","styled-components","@tensorflow/tfjs","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Sdk2={},e.React,e.Sentry,e.styled,e.tf,e.ReactDOM)}(this,(function(e,t,n,r,o,i){"use strict";function a(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=a(t),c=s(t),u=s(n),d=a(r),h=s(o),f=a(i),p=function(e,t){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},p(e,t)};function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var m=function(){return m=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},m.apply(this,arguments)};function v(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(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?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function b(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function y(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function w(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}const x={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 E{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||x,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 E(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new E(this.logger,e)}}var S=new E;class k{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 C(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));return n.resolve=e,n.reject=t,n}function T(e){return null==e?"":""+e}function A(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function o(){return!e||"string"==typeof e}const i="string"!=typeof t?[].concat(t):t.split(".");for(;i.length>1;){if(o())return{};const t=r(i.shift());!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}return o()?{}:{obj:e,k:r(i.shift())}}function I(e,t,n){const{obj:r,k:o}=A(e,t,Object);r[o]=n}function R(e,t){const{obj:n,k:r}=A(e,t);if(n)return n[r]}function D(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]):D(e[r],t[r],n):e[r]=t[r]);return e}function _(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var F={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function M(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(e=>F[e])):e}const L=[" ",",","?","!",";"];function P(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 o=e;for(let e=0;e<r.length;++e){if(!o)return;if("string"==typeof o[r[e]]&&e+1<r.length)return;if(void 0===o[r[e]]){let i=2,a=r.slice(e,e+i).join(n),s=o[a];for(;void 0===s&&r.length>e+i;)i++,a=r.slice(e,e+i).join(n),s=o[a];if(void 0===s)return;if(null===s)return null;if(t.endsWith(a)){if("string"==typeof s)return s;if(a&&"string"==typeof s[a])return s[a]}const l=r.slice(e+i).join(n);return l?P(s,l,n):void 0}o=o[r[e]]}return o}function B(e){return e&&e.indexOf("_")>0?e.replace("_","-"):e}class O extends k{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 o=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,i=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let a=[e,t];n&&"string"!=typeof n&&(a=a.concat(n)),n&&"string"==typeof n&&(a=a.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(a=e.split("."));const s=R(this.data,a);return s||!i||"string"!=typeof n?s:P(this.data&&this.data[e]&&this.data[e][t],n,o)}addResource(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const i=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator;let a=[e,t];n&&(a=a.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(a=e.split("."),r=t,t=a[1]),this.addNamespaces(t),I(this.data,a,r),o.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,o){let i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),r=n,n=t,t=a[1]),this.addNamespaces(t);let s=R(this.data,a)||{};r?D(s,n,o):s={...s,...n},I(this.data,a,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 N={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,o){return e.forEach((e=>{this.processors[e]&&(t=this.processors[e].process(t,n,r,o))})),t}};const U={};class j extends k{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=S.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 o=t.ns||this.options.defaultNS||[];const i=n&&e.indexOf(n)>-1,a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||"",n=n||"";const r=L.filter((e=>t.indexOf(e)<0&&n.indexOf(e)<0));if(0===r.length)return!0;const o=new RegExp(`(${r.map((e=>"?"===e?"\\?":e)).join("|")})`);let i=!o.test(e);if(!i){const t=e.indexOf(n);t>0&&!o.test(e.substring(0,t))&&(i=!0)}return i}(e,n,r));if(i&&!a){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:o};const i=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(i[0])>-1)&&(o=i.shift()),e=i.join(r)}return"string"==typeof o&&(o=[o]),{key:e,namespaces:o}}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,o=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,{key:i,namespaces:a}=this.extractFromKey(e[e.length-1],t),s=a[a.length-1],l=t.lng||this.language,c=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(c){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 u=this.resolve(e,t);let d=u&&u.res;const h=u&&u.usedKey||i,f=u&&u.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:a}):`key '${i} (${this.language})' returned an object instead of string.`;return r?(u.res=e,u):e}if(o){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}${o}${e}`;n[e]=this.translate(i,{...t,joinArrays:!1,ns:a}),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,a=!1;const c=void 0!==t.count&&"string"!=typeof t.count,h=j.hasDefaultValue(t),f=c?this.pluralResolver.getSuffix(l,t.count,t):"",p=t.ordinal&&c?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)||(a=!0,d=i);const m=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:d,v=h&&g!==d&&this.options.updateMissing;if(a||r||v){if(this.logger.log(v?"updateKey":"missingKey",l,s,i,v?g:d),o){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 o=h&&r!==d?r:m;this.options.missingKeyHandler?this.options.missingKeyHandler(e,s,n,o,v,t):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(e,s,n,o,v,t),this.emit("missingKey",e,s,n,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&c?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,u,n),a&&d===i&&this.options.appendNamespaceToMissingKey&&(d=`${s}:${i}`),(a||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?(u.res=d,u):d}extendTranslation(e,t,n,r,o){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 a="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let s;if(a){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),a){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),a=0;a<e;a++)r[a]=arguments[a];return o&&o[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 a=n.postProcess||this.options.postProcess,s="string"==typeof a?[a]:a;return null!=e&&s&&s.length&&!1!==n.applyPostProcessor&&(e=N.handle(s,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:r,...n}:n,this)),e}resolve(e){let t,n,r,o,i,a=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,a),l=s.key;n=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));const u=void 0!==a.count&&"string"!=typeof a.count,d=u&&!a.ordinal&&0===a.count&&this.pluralResolver.shouldUseIntlApi(),h=void 0!==a.context&&("string"==typeof a.context||"number"==typeof a.context)&&""!==a.context,f=a.lngs?a.lngs:this.languageUtils.toResolveHierarchy(a.lng||this.language,a.fallbackLng);c.forEach((e=>{this.isValidLookup(t)||(i=e,!U[`${f[0]}-${e}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(i)&&(U[`${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;o=n;const i=[l];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(i,l,n,e,a);else{let e;u&&(e=this.pluralResolver.getSuffix(n,a.count,a));const t=`${this.options.pluralSeparator}zero`,r=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(i.push(l+e),a.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}${a.context}`;i.push(n),u&&(i.push(n+e),a.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,a))})))}))})),{res:t,usedKey:n,exactUsedKey:r,usedLng:o,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 G(e){return e.charAt(0).toUpperCase()+e.slice(1)}class ${constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=S.create("languageUtils")}getScriptPartFromCode(e){if(!(e=B(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=B(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]=G(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]=G(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=G(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=[],o=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&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):"string"==typeof e&&o(this.formatLanguageCode(e)),n.forEach((e=>{r.indexOf(e)<0&&o(this.formatLanguageCode(e))})),r}}let z=[{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}],q={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 V=["v1","v2","v3"],W=["v4"],H={zero:0,one:1,two:2,few:3,many:4,other:5};class K{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.languageUtils=e,this.options=t,this.logger=S.create("pluralResolver"),this.options.compatibilityJSON&&!W.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 z.forEach((t=>{t.lngs.forEach((n=>{e[n]={numbers:t.nr,plurals:q[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(B(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 o=()=>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()}`:o():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?o():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}shouldUseIntlApi(){return!V.includes(this.options.compatibilityJSON)}}function Y(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=function(e,t,n){const r=R(e,n);return void 0!==r?r:R(t,n)}(e,t,n);return!i&&o&&"string"==typeof n&&(i=P(e,n,r),void 0===i&&(i=P(t,n,r))),i}class X{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=S.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:M,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?_(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?_(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?_(t.nestingPrefix):t.nestingPrefixEscaped||_("$t("),this.nestingSuffix=t.nestingSuffix?_(t.nestingSuffix):t.nestingSuffixEscaped||_(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){this.regexp=new RegExp(`${this.prefix}(.+?)${this.suffix}`,"g");this.regexpUnescape=new RegExp(`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`,"g");this.nestingRegexp=new RegExp(`${this.nestingPrefix}(.+?)${this.nestingSuffix}`,"g")}interpolate(e,t,n,r){let o,i,a;const s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function l(e){return e.replace(/\$/g,"$$$$")}const c=e=>{if(e.indexOf(this.formatSeparator)<0){const o=Y(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(o,void 0,n,{...r,...t,interpolationkey:e}):o}const o=e.split(this.formatSeparator),i=o.shift().trim(),a=o.join(this.formatSeparator).trim();return this.format(Y(t,s,i,this.options.keySeparator,this.options.ignoreJSONStructure),a,n,{...r,...t,interpolationkey:i})};this.resetRegExp();const u=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(a=0;o=t.regex.exec(e);){const n=o[1].trim();if(i=c(n),void 0===i)if("function"==typeof u){const t=u(e,o,r);i="string"==typeof t?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,n))i="";else{if(d){i=o[0];continue}this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),i=""}else"string"==typeof i||this.useRawValueToEscape||(i=T(i));const s=t.safeValue(i);if(e=e.replace(o[0],s),d?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=o[0].length):t.regex.lastIndex=0,a++,a>=this.maxReplaces)break}})),e}nest(e,t){let n,r,o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function a(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,o);const a=i.match(/'/g),s=i.match(/"/g);(a&&a.length%2==0&&!s||s.length%2!=0)&&(i=i.replace(/'/g,'"'));try{o=JSON.parse(i),t&&(o={...t,...o})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return delete o.defaultValue,e}for(;n=this.nestingRegexp.exec(e);){let s=[];o={...i},o=o.replace&&"string"!=typeof o.replace?o.replace:o,o.applyPostProcessor=!1,delete o.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(a.call(this,n[1].trim(),o),o),r&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=T(r)),r||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),r=""),l&&(r=s.reduce(((e,t)=>this.format(e,t,i.lng,{...i,interpolationkey:n[1].trim()})),r.trim())),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}function J(e){const t={};return function(n,r,o){const i=r+JSON.stringify(o);let a=t[i];return a||(a=e(B(r),o),t[i]=a),a(n)}}class Z{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=S.create("formatter"),this.options=e,this.formats={number:J(((e,t)=>{const n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)})),currency:J(((e,t)=>{const n=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>n.format(e)})),datetime:J(((e,t)=>{const n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)})),relativetime:J(((e,t)=>{const n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||"day")})),list:J(((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()]=J(t)}format(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o=t.split(this.formatSeparator).reduce(((e,t)=>{const{formatName:o,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 o=r[1].substring(0,r[1].length-1);"currency"===t&&o.indexOf(":")<0?n.currency||(n.currency=o.trim()):"relativetime"===t&&o.indexOf(":")<0?n.range||(n.range=o.trim()):o.split(";").forEach((e=>{if(!e)return;const[t,...r]=e.split(":"),o=r.join(":").trim().replace(/^'+|'+$/g,"");n[t.trim()]||(n[t.trim()]=o),"false"===o&&(n[t.trim()]=!1),"true"===o&&(n[t.trim()]=!0),isNaN(o)||(n[t.trim()]=parseInt(o,10))}))}return{formatName:t,formatOptions:n}}(t);if(this.formats[o]){let t=e;try{const a=r&&r.formatParams&&r.formatParams[r.interpolationkey]||{};t=this.formats[o](e,a.locale||a.lng||r.locale||r.lng||n,{...i,...r,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${o}`),e}),e);return o}}class Q extends k{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=S.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 o={},i={},a={},s={};return e.forEach((e=>{let r=!0;t.forEach((t=>{const a=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===i[a]&&(i[a]=!0):(this.state[a]=1,r=!1,void 0===i[a]&&(i[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===s[t]&&(s[t]=!0)))})),r||(a[e]=!0)})),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){const r=e.split("|"),o=r[0],i=r[1];t&&this.emit("failedLoading",o,i,t),n&&this.store.addResourceBundle(o,i,n),this.state[e]=t?-1:2;const a={};this.queue.forEach((n=>{!function(e,t,n,r){const{obj:o,k:i}=A(e,t,Object);o[i]=o[i]||[],r&&(o[i]=o[i].concat(n)),r||o[i].push(n)}(n.loaded,[o],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=>{a[e]||(a[e]={});const t=n.loaded[e];t.length&&t.forEach((t=>{void 0===a[e][t]&&(a[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",a),this.queue=this.queue.filter((e=>!e.done))}read(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=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:o,callback:i});this.readingCalls++;const a=(a,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)}a&&s&&r<this.maxRetries?setTimeout((()=>{this.read.call(this,e,t,n,r+1,2*o,i)}),o):i(a,s)},s=this.backend[n].bind(this.backend);if(2!==s.length)return s(e,t,a);try{const n=s(e,t);n&&"function"==typeof n.then?n.then((e=>a(null,e))).catch(a):a(null,n)}catch(e){a(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 o=this.queueLoad(e,t,n,r);if(!o.toLoad.length)return o.pending.length||r(),null;o.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],o=n[1];this.read(r,o,"read",void 0,void 0,((n,i)=>{n&&this.logger.warn(`${t}loading namespace ${o} for language ${r} failed`,n),!n&&i&&this.logger.log(`${t}loaded namespace ${o} for language ${r}`,i),this.loaded(e,n,i)}))}saveMissing(e,t,n,r,o){let i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=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:o},l=this.backend.create.bind(this.backend);if(l.length<6)try{let o;o=5===l.length?l(e,t,n,r,s):l(e,t,n,r),o&&"function"==typeof o.then?o.then((e=>a(null,e))).catch(a):a(null,o)}catch(e){a(e)}else l(e,t,n,r,a,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}}function ee(){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 te(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 ne(){}class re extends k{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=te(e),this.services={},this.logger=S,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=ee();function o(e){return e?"function"==typeof e?new e:e:null}if(this.options={...r,...this.options,...te(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;S.init(this.modules.logger?o(this.modules.logger):null,this.options),this.modules.formatter?t=this.modules.formatter:"undefined"!=typeof Intl&&(t=Z);const n=new $(this.options);this.store=new O(this.options.resources,this.options);const i=this.services;i.logger=S,i.resourceStore=this.store,i.languageUtils=n,i.pluralResolver=new K(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=o(t),i.formatter.init(i,this.options),this.options.interpolation.format=i.formatter.format.bind(i.formatter)),i.interpolator=new X(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new Q(o(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),o=1;o<n;o++)r[o-1]=arguments[o];e.emit(t,...r)})),this.modules.languageDetector&&(i.languageDetector=o(this.modules.languageDetector),i.languageDetector.init&&i.languageDetector.init(i,this.options.detection,this.options)),this.modules.i18nFormat&&(i.i18nFormat=o(this.modules.i18nFormat),i.i18nFormat.init&&i.i18nFormat.init(this)),this.translator=new j(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];e.emit(t,...r)})),this.modules.external.forEach((e=>{e.init&&e.init(this)}))}if(this.format=this.options.interpolation.format,n||(n=ne),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=C(),a=()=>{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?a():setTimeout(a,0),i}loadResources(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ne;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=C();return e||(e=this.languages),t||(t=this.options.ns),n||(n=ne),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&&N.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=C();this.emit("languageChanging",e);const o=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(e,i)=>{i?(o(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)}))},a=t=>{e||t||!this.services.languageDetector||(t=[]);const n="string"==typeof t?t:this.services.languageUtils.getBestMatchFromCodes(t);n&&(this.language||o(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(a):this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),r}getFixedT(e,t,n){var r=this;const o=function(e,t){let i;if("object"!=typeof t){for(var a=arguments.length,s=new Array(a>2?a-2:0),l=2;l<a;l++)s[l-2]=arguments[l];i=r.options.overloadTranslationOptionHandler([e,t].concat(s))}else i={...t};i.lng=i.lng||o.lng,i.lngs=i.lngs||o.lngs,i.ns=i.ns||o.ns,i.keyPrefix=i.keyPrefix||n||o.keyPrefix;const c=r.options.keySeparator||".";let u;return u=i.keyPrefix&&Array.isArray(e)?e.map((e=>`${i.keyPrefix}${c}${e}`)):i.keyPrefix?`${i.keyPrefix}${c}${e}`:e,r.t(u,i)};return"string"==typeof e?o.lng=e:o.lngs=e,o.ns=t,o.keyPrefix=n,o}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,o=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(o,e)))}loadNamespaces(e,t){const n=C();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=C();"string"==typeof e&&(e=[e]);const r=this.options.preload||[],o=e.filter((e=>r.indexOf(e)<0));return o.length?(this.options.preload=r.concat(o),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 $(ee());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 re(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]:ne;const n=e.forkResourceStore;n&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},o=new re(r);void 0===e.debug&&void 0===e.prefix||(o.logger=o.logger.clone(e));return["store","services","language"].forEach((e=>{o[e]=this[e]})),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},n&&(o.store=new O(this.store.data,r),o.services.resourceStore=o.store),o.translator=new j(o.services,r),o.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];o.emit(e,...n)})),o.init(r,t),o.translator.options=r,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const oe=re.createInstance();oe.createInstance=re.createInstance;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function ie(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 se={};function le(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&se[t[0]]||("string"==typeof t[0]&&(se[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 ce=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout((()=>{e.off("initialized",n)}),0),t()};e.on("initialized",n)}};function ue(e,t,n){e.loadNamespaces(t,ce(e,n))}function de(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,ce(e,r))}const he=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,fe={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},pe=e=>fe[e];let ge,me={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(he,pe)};const ve={type:"3rdParty",init(e){!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};me={...me,...e}}(e.options.react),function(e){ge=e}(e)}},be=t.createContext();class ye{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const we=(e,n)=>{const r=t.useRef();return t.useEffect((()=>{r.current=n?r.current:e}),[e,n]),r.current};function xe(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:r}=n,{i18n:o,defaultNS:i}=t.useContext(be)||{},a=r||o||ge;if(a&&!a.reportNamespaces&&(a.reportNamespaces=new ye),!a){le("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}a.options.react&&void 0!==a.options.react.wait&&le("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const s={...me,...a.options.react,...n},{useSuspense:l,keyPrefix:c}=s;let u=e||i||a.options&&a.options.defaultNS;u="string"==typeof u?[u]:u||["translation"],a.reportNamespaces.addUsedNamespaces&&a.reportNamespaces.addUsedNamespaces(u);const d=(a.isInitialized||a.initializedStoreOnce)&&u.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],o=!!t.options&&t.options.fallbackLng,i=t.languages[t.languages.length-1];if("cimode"===r.toLowerCase())return!0;const a=(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&&!a(t.isLanguageChangingTo,e)||!t.hasResourceBundle(r,e)&&t.services.backendConnector.backend&&(!t.options.resources||t.options.partialBundledLanguages)&&(!a(r,e)||o&&!a(i,e)))}(e,t,n):(le("i18n.languages were undefined or empty",t.languages),!0)}(e,a,s)));function h(){return a.getFixedT(n.lng||null,"fallback"===s.nsMode?u:u[0],c)}const[f,p]=t.useState(h);let g=u.join();n.lng&&(g=`${n.lng}${g}`);const m=we(g),v=t.useRef(!0);t.useEffect((()=>{const{bindI18n:e,bindI18nStore:t}=s;function r(){v.current&&p(h)}return v.current=!0,d||l||(n.lng?de(a,n.lng,u,(()=>{v.current&&p(h)})):ue(a,u,(()=>{v.current&&p(h)}))),d&&m&&m!==g&&v.current&&p(h),e&&a&&a.on(e,r),t&&a&&a.store.on(t,r),()=>{v.current=!1,e&&a&&e.split(" ").forEach((e=>a.off(e,r))),t&&a&&t.split(" ").forEach((e=>a.store.off(e,r)))}}),[a,g]);const b=t.useRef(!0);t.useEffect((()=>{v.current&&!b.current&&p(h),b.current=!1}),[a,c]);const y=[f,a,d];if(y.t=f,y.i18n=a,y.ready=d,d)return y;if(!d&&!l)return y;throw new Promise((e=>{n.lng?de(a,n.lng,u,(()=>e())):ue(a,u,(()=>e()))}))}function Ee(e){return Ee="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},Ee(e)}function Se(e){var t=function(e,t){if("object"!==Ee(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==Ee(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Ee(t)?t:String(t)}function ke(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,Se(r.key),r)}}var Ce=[],Te=Ce.forEach,Ae=Ce.slice;var Ie=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Re=function(e,t,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};n&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+60*n*1e3)),r&&(o.domain=r),document.cookie=function(e,t,n){var r=n||{};r.path=r.path||"/";var o=encodeURIComponent(t),i="".concat(e,"=").concat(o);if(r.maxAge>0){var a=r.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");i+="; Max-Age=".concat(Math.floor(a))}if(r.domain){if(!Ie.test(r.domain))throw new TypeError("option domain is invalid");i+="; Domain=".concat(r.domain)}if(r.path){if(!Ie.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),o)},De=function(e){for(var t="".concat(e,"="),n=document.cookie.split(";"),r=0;r<n.length;r++){for(var o=n[r];" "===o.charAt(0);)o=o.substring(1,o.length);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return null},_e={name:"cookie",lookup:function(e){var t;if(e.lookupCookie&&"undefined"!=typeof document){var n=De(e.lookupCookie);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupCookie&&"undefined"!=typeof document&&Re(t.lookupCookie,e,t.cookieMinutes,t.cookieDomain,t.cookieOptions)}},Fe={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("&"),o=0;o<r.length;o++){var i=r[o].indexOf("=");if(i>0)r[o].substring(0,i)===e.lookupQuerystring&&(t=r[o].substring(i+1))}}return t}},Me=null,Le=function(){if(null!==Me)return Me;try{Me="undefined"!==window&&null!==window.localStorage;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch(e){Me=!1}return Me},Pe={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&Le()){var n=window.localStorage.getItem(e.lookupLocalStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&Le()&&window.localStorage.setItem(t.lookupLocalStorage,e)}},Be=null,Oe=function(){if(null!==Be)return Be;try{Be="undefined"!==window&&null!==window.sessionStorage;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch(e){Be=!1}return Be},Ne={name:"sessionStorage",lookup:function(e){var t;if(e.lookupSessionStorage&&Oe()){var n=window.sessionStorage.getItem(e.lookupSessionStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&Oe()&&window.sessionStorage.setItem(t.lookupSessionStorage,e)}},Ue={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}},je={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}},Ge={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}},$e={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 ze=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 Te.call(Ae.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(_e),this.addDetector(Fe),this.addDetector(Pe),this.addDetector(Ne),this.addDetector(Ue),this.addDetector(je),this.addDetector(Ge),this.addDetector($e)}},{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&&ke(t.prototype,n),r&&ke(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();ze.type="languageDetector";var qe,Ve,We="1.0.3";function He(){return window.platform}!function(e){e.NONE="NONE",e.ENROLL="ENROLL",e.IDENTIFY="IDENTIFY",e.VALIDATE="VALIDATE",e.VERIFY="VERIFY"}(qe||(qe={})),function(e){e.READY="READY",e.SUBMITTING="SUBMITTING",e.SUBMITTED="SUBMITTED",e.FAILED="FAILED"}(Ve||(Ve={}));var Ke={prod:"https://api.idmission.com",demo:"https://apidemo.idmission.com"},Ye=t.createContext({submit:function(){return v(void 0,void 0,void 0,(function(){return b(this,(function(e){return[2,null]}))}))},submissionStatus:Ve.READY,submissionRequest:null,submissionResponse:null,submissionError: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 v(void 0,void 0,void 0,(function(){return b(this,(function(e){throw new Error("checkLiveness is not implemented")}))}))},retryLocationAccess:function(){return null}});function Xe(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 Ke.prod;case"https://demoauth.idmission.com/auth/realms/identity":return Ke.demo}var n=Ke[e];if(!n)throw new Error("unrecognized SubmissionEnvironment ".concat(e));return n}function Je(e){var t={"Content-Type":"application/json",Origin:"*"};return e&&(t.Authorization="Bearer ".concat(e)),t}function Ze(e,t){var n=t.geolocationResult,r={selfie:t.selfieCaptureAttempts,front:t.idFrontCaptureAttempts,back:t.idBackCaptureAttempts,isRealIDCheckRequired:"false",sdkVersion:"WebSDK_".concat(We),Resolution:"".concat(window.innerWidth," x ").concat(window.innerHeight)},o=He();o&&(r.os=o.os.family,r.osVersion=o.os.version,r.browserVersion="".concat(o.name," ").concat(o.version)),n&&(r.GeoLocation=JSON.stringify(n)),e.additionalData.metadata=JSON.stringify(r)}function Qe(e){return v(this,void 0,void 0,(function(){return b(this,(function(t){return[2,e.replace(/^data:image\/(png|jpeg);base64,/,"")]}))}))}function et(e){return e.replace(/^data:.*;base64,/,"")}function tt(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 nt,rt=d.default.div(nt||(nt=w(["\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})),ot=t.forwardRef((function(e,n){var r=e.children,o=e.className,i=e.heightOffset,a=void 0===i?0:i,s=e.style,c=e.onClick,u=t.useState(!1),d=u[0],h=u[1];return t.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)}}),[]),l.default.createElement(rt,{ref:n,style:s,onClick:c,className:o,$heightOffset:a},d&&r)}));ot.displayName="PageContainer";var it,at,st,lt,ct=d.default(ot)(it||(it=w(["\n background: white;\n z-index: 10000;\n"],["\n background: white;\n z-index: 10000;\n"]))),ut=d.default.div(at||(at=w(["\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"]))),dt=d.default.div(st||(st=w(["\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"]))),ht=d.default.div(lt||(lt=w(["\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"]))),ft=function(){return ft=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ft.apply(this,arguments)},pt={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"},gt=function(){function e(e){void 0===e&&(e={}),this.opts=ft(ft({},pt),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"),mt(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 o=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,n=[],r=0,o=e.split(",");r<o.length;r++){var i=o[r].match(t);if(null!==i){var a=+i[2],s=+i[5],l=i[4],c=i[7];0!==a||l||(l=c),0!==s||c||(c=l),l===c&&n.push({prefix:i[1]||"",x:a,y:s,xUnits:l,yUnits:c,end:i[8]})}}return n}(r),i=0;i<t.lines;i++){var a=~~(360/t.lines*i+t.rotate),s=mt(document.createElement("div"),{position:"absolute",top:-t.width/2+"px",width:t.length+t.width+"px",height:t.width+"px",background:vt(t.fadeColor,i),borderRadius:n,transformOrigin:"left",transform:"rotate("+a+"deg) translateX("+t.radius+"px)"}),l=i*t.direction/t.lines/t.speed;l-=1/t.speed;var c=mt(document.createElement("div"),{width:"100%",height:"100%",background:vt(t.color,i),borderRadius:n,boxShadow:bt(o,a),animation:1/t.speed+"s linear "+l+"s infinite "+t.animation});s.appendChild(c),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 mt(e,t){for(var n in t)e.style[n]=t[n];return e}function vt(e,t){return"string"==typeof e?e:e[t%e.length]}function bt(e,t){for(var n=[],r=0,o=e;r<o.length;r++){var i=o[r],a=yt(i.x,i.y,t);n.push(i.prefix+a[0]+i.xUnits+" "+a[1]+i.yUnits+i.end)}return n.join(", ")}function yt(e,t,n){var r=n*Math.PI/180,o=Math.sin(r),i=Math.cos(r);return[Math.round(1e3*(e*i+t*o))/1e3,Math.round(1e3*(-e*o+t*i))/1e3]}function wt(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,o=e.querySelector(".ladda-spinner");o||((o=document.createElement("span")).className="ladda-spinner"),e.appendChild(o);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 o=.2*r;return new gt({color:t||"#fff",lines:n||12,radius:o,length:.6*o,width:o<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(o),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 xt,Et,St,kt=function(e){var n=e.children,r=e.colors,o=void 0===r?{}:r,i=e.disabled,a=e.finished,s=e.onClick,c=e.style,u=t.useRef(null),d=t.useRef(null);return o.backgroundColor||(o.backgroundColor="#16a085"),o.textColor||(o.textColor="white"),o.loadingBackgroundColor||(o.loadingBackgroundColor="gray"),o.loadingTextColor||(o.loadingTextColor="white"),t.useEffect((function(){if(u.current){d.current=wt(u.current),d.current.start();var e=0,t=setInterval((function(){var t;e<.9&&(e+=.1),null===(t=d.current)||void 0===t||t.setProgress(e)}),250);return function(){var e;null===(e=d.current)||void 0===e||e.remove(),clearInterval(t)}}}),[]),t.useEffect((function(){var e;a&&(null===(e=d.current)||void 0===e||e.stop())}),[a]),l.default.createElement(Ct,{className:"ladda-button","data-style":"expand-right",disabled:i,ref:u,onClick:s,$backgroundColor:o.backgroundColor,$textColor:o.textColor,$disabledBackgroundColor:o.loadingBackgroundColor,$disabledTextColor:o.loadingTextColor,style:c},l.default.createElement("span",{className:"ladda-label"},n))},Ct=d.default.button(xt||(xt=w(["\n border-radius: 0;\n margin: 0;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n text-transform: none;\n -webkit-appearance: button;\n\n &:not(:disabled),\n &[type='button']:not(:disabled),\n &[type='reset']:not(:disabled),\n &[type='submit']:not(:disabled) {\n cursor: pointer;\n }\n\n &:focus:not(:focus-visible) {\n outline: 0;\n }\n\n --bs-btn-padding-x: 0.75rem;\n --bs-btn-padding-y: 0.375rem;\n --bs-btn-font-family: ;\n --bs-btn-font-size: 1rem;\n --bs-btn-font-weight: 400;\n --bs-btn-line-height: 1.5;\n --bs-btn-color: var(--bs-body-color);\n --bs-btn-bg: transparent;\n --bs-btn-border-width: var(--bs-border-width);\n --bs-btn-border-color: transparent;\n --bs-btn-border-radius: var(--bs-border-radius);\n --bs-btn-hover-border-color: transparent;\n --bs-btn-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15),\n 0 1px 1px rgba(0, 0, 0, 0.075);\n --bs-btn-disabled-opacity: 0.65;\n --bs-btn-focus-box-shadow: 0 0 0 0.25rem\n rgba(var(--bs-btn-focus-shadow-rgb), 0.5);\n display: inline-block;\n padding: var(--bs-btn-padding-y) var(--bs-btn-padding-x);\n font-family: var(--bs-btn-font-family);\n font-size: var(--bs-btn-font-size);\n font-weight: var(--bs-btn-font-weight);\n line-height: var(--bs-btn-line-height);\n color: var(--bs-btn-color);\n text-align: center;\n text-decoration: none;\n vertical-align: middle;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n border: var(--bs-btn-border-width) solid var(--bs-btn-border-color);\n border-radius: var(--bs-btn-border-radius);\n background-color: var(--bs-btn-bg);\n transition:\n color 0.15s ease-in-out,\n background-color 0.15s ease-in-out,\n border-color 0.15s ease-in-out,\n box-shadow 0.15s ease-in-out;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n &:hover {\n filter: brightness(1.15);\n }\n\n &:focus-visible {\n color: var(--bs-btn-hover-color);\n background-color: var(--bs-btn-hover-bg);\n border-color: var(--bs-btn-hover-border-color);\n outline: 0;\n box-shadow: var(--bs-btn-focus-box-shadow);\n }\n\n &:disabled,\n &.disabled,\n fieldset:disabled & {\n color: var(--bs-btn-disabled-color);\n pointer-events: none;\n background-color: var(--bs-btn-disabled-bg);\n border-color: var(--bs-btn-disabled-border-color);\n opacity: var(--bs-btn-disabled-opacity);\n }\n\n --bs-btn-color: ",";\n --bs-btn-bg: ",";\n --bs-btn-border-color: ",";\n --bs-btn-focus-shadow-rgb: 49, 132, 253;\n --bs-btn-active-color: #fff;\n --bs-btn-active-bg: #0a58ca;\n --bs-btn-active-border-color: #0a53be;\n --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);\n --bs-btn-disabled-color: ",";\n --bs-btn-disabled-bg: ",";\n --bs-btn-disabled-border-color: ",";\n\n --bs-btn-padding-y: 14px;\n --bs-btn-padding-x: 1rem;\n --bs-btn-font-size: 18px;\n --bs-btn-border-radius: 4px;\n"],["\n border-radius: 0;\n margin: 0;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n text-transform: none;\n -webkit-appearance: button;\n\n &:not(:disabled),\n &[type='button']:not(:disabled),\n &[type='reset']:not(:disabled),\n &[type='submit']:not(:disabled) {\n cursor: pointer;\n }\n\n &:focus:not(:focus-visible) {\n outline: 0;\n }\n\n --bs-btn-padding-x: 0.75rem;\n --bs-btn-padding-y: 0.375rem;\n --bs-btn-font-family: ;\n --bs-btn-font-size: 1rem;\n --bs-btn-font-weight: 400;\n --bs-btn-line-height: 1.5;\n --bs-btn-color: var(--bs-body-color);\n --bs-btn-bg: transparent;\n --bs-btn-border-width: var(--bs-border-width);\n --bs-btn-border-color: transparent;\n --bs-btn-border-radius: var(--bs-border-radius);\n --bs-btn-hover-border-color: transparent;\n --bs-btn-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15),\n 0 1px 1px rgba(0, 0, 0, 0.075);\n --bs-btn-disabled-opacity: 0.65;\n --bs-btn-focus-box-shadow: 0 0 0 0.25rem\n rgba(var(--bs-btn-focus-shadow-rgb), 0.5);\n display: inline-block;\n padding: var(--bs-btn-padding-y) var(--bs-btn-padding-x);\n font-family: var(--bs-btn-font-family);\n font-size: var(--bs-btn-font-size);\n font-weight: var(--bs-btn-font-weight);\n line-height: var(--bs-btn-line-height);\n color: var(--bs-btn-color);\n text-align: center;\n text-decoration: none;\n vertical-align: middle;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n border: var(--bs-btn-border-width) solid var(--bs-btn-border-color);\n border-radius: var(--bs-btn-border-radius);\n background-color: var(--bs-btn-bg);\n transition:\n color 0.15s ease-in-out,\n background-color 0.15s ease-in-out,\n border-color 0.15s ease-in-out,\n box-shadow 0.15s ease-in-out;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n &:hover {\n filter: brightness(1.15);\n }\n\n &:focus-visible {\n color: var(--bs-btn-hover-color);\n background-color: var(--bs-btn-hover-bg);\n border-color: var(--bs-btn-hover-border-color);\n outline: 0;\n box-shadow: var(--bs-btn-focus-box-shadow);\n }\n\n &:disabled,\n &.disabled,\n fieldset:disabled & {\n color: var(--bs-btn-disabled-color);\n pointer-events: none;\n background-color: var(--bs-btn-disabled-bg);\n border-color: var(--bs-btn-disabled-border-color);\n opacity: var(--bs-btn-disabled-opacity);\n }\n\n --bs-btn-color: ",";\n --bs-btn-bg: ",";\n --bs-btn-border-color: ",";\n --bs-btn-focus-shadow-rgb: 49, 132, 253;\n --bs-btn-active-color: #fff;\n --bs-btn-active-bg: #0a58ca;\n --bs-btn-active-border-color: #0a53be;\n --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);\n --bs-btn-disabled-color: ",";\n --bs-btn-disabled-bg: ",";\n --bs-btn-disabled-border-color: ",";\n\n --bs-btn-padding-y: 14px;\n --bs-btn-padding-x: 1rem;\n --bs-btn-font-size: 18px;\n --bs-btn-border-radius: 4px;\n"])),(function(e){var t=e.$textColor;return null!=t?t:"#fff"}),(function(e){var t=e.$backgroundColor;return null!=t?t:"#0d6efd"}),(function(e){var t=e.$backgroundColor;return null!=t?t:"#0d6efd"}),(function(e){var t=e.$disabledTextColor;return null!=t?t:"#fff"}),(function(e){var t=e.$disabledBackgroundColor;return null!=t?t:"#0d6efd"}),(function(e){var t=e.$disabledBackgroundColor;return null!=t?t:"#0d6efd"})),Tt=function(e){var n=e.accessBlockedImageUrl,r=xe().t,o=t.useContext(Ye).retryLocationAccess;return l.default.createElement(ct,null,l.default.createElement("div",{style:{display:"flex",height:"100%"}},l.default.createElement(ut,{style:{maxWidth:500,height:"auto",margin:"auto"}},l.default.createElement(dt,{style:{flexGrow:0}},l.default.createElement("img",{src:n,alt:""})),l.default.createElement("h3",null,r("Your location access is disabled")),l.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.")),l.default.createElement(kt,{onClick:o,style:{width:200,marginLeft:"auto",marginRight:"auto"},finished:!0},r("Retry")))))},At=function(e){function t(t){var n=e.call(this,t.statusMessage)||this;return n.status=t,n}return g(t,e),t}(Error),It=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return g(t,e),t}(Error),Rt=function(e){var t=e.error;return l.default.createElement(ct,null,l.default.createElement(ut,{style:{justifyContent:"center"}},t instanceof It?l.default.createElement(_t,{error:t,onRetry:e.onRetry}):l.default.createElement(Dt,{error:t})))},Dt=function(e){var t=e.error,n=(0,xe().t)("We're sorry, an unexpected error has occurred.");return l.default.createElement(l.default.Fragment,null,l.default.createElement("h3",{style:{marginBottom:8}},n),t.status.statusCode&&l.default.createElement("p",{style:{marginBottom:0}},l.default.createElement("code",null,"Status: ",t.status.statusCode)),l.default.createElement("p",{style:{marginBottom:0}},l.default.createElement("code",null,t.message)),t.status.errorData&&l.default.createElement("p",{style:{marginBottom:0}},l.default.createElement("code",null,t.status.errorData)))},_t=function(e){var t=e.onRetry,n=xe().t,r=n("Network unreachable"),o=n("We're having trouble reaching our services, please check your connection and try again."),i=n("Retry");return l.default.createElement(l.default.Fragment,null,l.default.createElement("h3",{style:{marginBottom:8}},r),l.default.createElement("p",{style:{marginBottom:0}},o),t&&l.default.createElement("div",{style:{marginTop:32}},l.default.createElement(kt,{colors:{backgroundColor:"#ea8557"},finished:!0,onClick:t},i)))},Ft=function(e){var n=e.action,r=e.children,o=e.url,i=e.environment,a=void 0===i?"prod":i,s=e.token,c=e.companyId,u=e.enrollmentId,d=e.personalData,h=e.cardData,f=e.manualReviewRequired,p=void 0!==f&&f,g=e.verifyIdWithExternalDatabases,w=void 0!==g&&g,x=e.deduplicationEnabled,E=void 0!==x&&x,S=e.deduplicationSynchronous,k=void 0!==S&&S,C=e.geolocationEnabled,T=void 0===C||C,A=e.geolocationRequired,I=void 0!==A&&A,R=e.webhooksEnabled,D=void 0!==R&&R,_=e.webhooksClientTraceId,F=e.webhooksStripSpecialCharacters,M=void 0===F||F,L=e.onBeforeSubmit,P=e.onResponseReceived,B=e.onRequestFailure,O=t.useState(Ve.READY),N=O[0],U=O[1],j=t.useState(null),G=j[0],$=j[1],z=t.useState(null),q=z[0],V=z[1],W=t.useState(null),H=W[0],K=W[1],Y=t.useState(null),X=Y[0],J=Y[1],Z=t.useState(null),Q=Z[0],ee=Z[1],te=t.useState(null),ne=te[0],re=te[1],oe=t.useState(null),ie=oe[0],ae=oe[1],se=t.useState(null),le=se[0],ce=se[1],ue=t.useState(null),de=ue[0],he=ue[1],fe=t.useState(null),pe=fe[0],ge=fe[1],me=t.useState(null),ve=me[0],be=me[1],ye=t.useState(null),we=ye[0],xe=ye[1],Ee=t.useState(0),Se=Ee[0],ke=Ee[1],Ce=t.useState(!1),Te=Ce[0],Ae=Ce[1],Ie=t.useState([]),Re=Ie[0],De=Ie[1],_e=t.useState([]),Fe=_e[0],Me=_e[1],Le=t.useState([]),Pe=Le[0],Be=Le[1],Oe=t.useCallback((function(e){De((function(t){return y(y([],t,!0),[e],!1)}))}),[]),Ne=t.useCallback((function(e){Me((function(t){return y(y([],t,!0),[e],!1)}))}),[]),Ue=t.useCallback((function(e){Be((function(t){return y(y([],t,!0),[e],!1)}))}),[]),je=t.useCallback((function(){return v(void 0,void 0,void 0,(function(){var e,t,r,i,l,f,g,v,y,x,S,C;return b(this,(function(b){switch(b.label){case 0:if(n===qe.NONE)return e={status:{statusCode:"000"},resultData:{}},U(Ve.SUBMITTED),V(e),[2,e];U(Ve.SUBMITTING),b.label=1;case 1:return b.trys.push([1,8,,9]),t={securityData:{userName:"",password:"",merchantId:0},customerData:{idData:{idType:"NSP",idCountry:"NSP",idState:""}},additionalData:{uniqueRequestId:(new Date).getTime().toString(),manualReviewRequired:p?"Y":"N",bypassAgeValidation:"N",deDuplicationRequired:E?"Y":"N",bypassNameMatching:"Y",postDataAPIRequired:D?"Y":"N",sendInputImagesInPost:"N",sendProcessedImagesInPost:"N",needImmediateResponse:"N",deduplicationSynchronous:k?"Y":"N",verifyDataWithHost:w?"Y":"N",idBackImageRequired:"N",stripSpecialCharacters:M?"Y":"N",idImageResolutionCheck:"Y"}},Q&&(t.customerData.idData.idImageFront=Q),ne&&(t.customerData.idData.idImageBack=ne),ie&&(t.customerData.idData.idImageFront=ie),le&&(n===qe.IDENTIFY?t.biometricData={selfie:le}:t.customerData.biometricData={selfie:le}),c&&(t.employee={companyId:c}),d&&(t.customerData.personalData=d),h&&(t.customerData.cardData=h),u&&((C=t.customerData).personalData||(C.personalData={}),t.customerData.personalData.uniqueNumber=u),_&&(t.additionalData.clientTraceId=_),de&&(t.customerData.signatureData={signatureImage:JSON.stringify(de)}),ve&&(t.customerData.additionalDocuments=ve.map((function(e){return m(m({},e),{additionalDocument:JSON.stringify(m(m({},e.additionalDocument),{uniqueId:t.additionalData.uniqueRequestId}))})}))),Ze(t,{selfieCaptureAttempts:Pe,idFrontCaptureAttempts:Re,idBackCaptureAttempts:Fe,geolocationResult:we}),L?[4,L(t)]:[3,3];case 2:(r=b.sent())&&(t=r),b.label=3;case 3:return i=o||Xe(a,s),l=function(e,t,n,r){var o=r?"v4":"v3";switch(e){case qe.ENROLL:return"/".concat(o,t?"/customer/enroll":"/customer/enroll-biometrics");case qe.IDENTIFY:return"/".concat(o,"/customer/identify");case qe.VALIDATE:return"/".concat(o,n?"/customer/validate-id-match-face":"/customer/validate-id");case qe.VERIFY:return"/".concat(o,"/customer/verify");default:throw new Error("unrecognized SubmissionAction ".concat(e))}}(n,!!(Q||ne||ie),!!le,!!s),[4,fetch(i+l,{method:"POST",headers:Je(s),body:JSON.stringify(t)}).catch((function(e){throw new It(e.message)}))];case 4:return(f=b.sent())&&f.ok?[3,6]:[4,null==f?void 0:f.text()];case 5:if(!(g=b.sent())||"Load failed"===g)throw new It(g);throw new At({statusCode:null!==(S=null==f?void 0:f.statusText)&&void 0!==S?S:"???",statusMessage:g});case 6:return[4,f.json()];case 7:if("000"!==(v=b.sent()).status.statusCode)throw new At(v.status);return $(t),V(v),U(Ve.SUBMITTED),null==P||P(v),[2,v];case 8:throw y=b.sent(),x=y,U(Ve.FAILED),K(y instanceof At||y instanceof It?y:new At({statusCode:"",statusMessage:x.message})),J((function(){return["VERIFY","IDENTIFY"].includes(n)?function(){return null}:je})),null==B||B(x),x;case 9:return[2]}}))}))}),[n,ve,h,c,E,k,u,a,we,Fe,ne,Re,Q,p,L,B,P,ie,d,Pe,le,de,s,o,w,_,D,M]),Ge=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){var t,n,r,i,l,c,u,d,h,f,p;return b(this,(function(g){switch(g.label){case 0:return g.trys.push([0,6,,7]),h={securityData:{userName:"",password:"",merchantId:0}},f={},p={},[4,Qe(e)];case 1:return h.customerData=(f.biometricData=(p.selfie=g.sent(),p),f),h.additionalData={uniqueRequestId:(new Date).getTime().toString(),stripSpecialCharacters:"Y",estimateAge:"N",predictGender:"N"},Ze(t=h,{selfieCaptureAttempts:Pe,idFrontCaptureAttempts:Re,idBackCaptureAttempts:Fe,geolocationResult:we}),n=o||Xe(a,s),r="/".concat(!!s?"v4":"v3","/customer/live-check"),[4,fetch(n+r,{method:"POST",headers:Je(s),body:JSON.stringify(t)}).catch((function(e){throw new It(e.message)}))];case 2:return(i=g.sent()).ok?[3,4]:[4,i.text()];case 3:if(!(l=g.sent())||"Load failed"===l)throw new It(l);throw new At({statusCode:i.statusText,statusMessage:l});case 4:return[4,i.json()];case 5:if("000"!==(c=g.sent()).status.statusCode)throw new At(c.status);return V(c),[2,c];case 6:throw u=g.sent(),d=u,U(Ve.FAILED),K(u instanceof At||u instanceof It?u:new At({statusCode:"",statusMessage:d.message})),J((function(){return function(){return null}})),null==B||B(d),d;case 7:return[2]}}))}))}),[a,we,Fe,Re,B,Pe,s,o]),$e=t.useCallback((function(){ke((function(e){return e+1}))}),[]);t.useEffect((function(){T&&(console.log("making geolocation attempt",Se),navigator.geolocation.getCurrentPosition((function(e){xe(e),Ae(!1)}),(function(e){if(1!==e.code)throw new Error(e.message);Ae(!0)})))}),[Se,T,I]);var ze=t.useCallback((function(){X&&(K(null),U(Ve.READY),X())}),[X]);return l.default.createElement(Ye.Provider,{value:{submit:je,submissionStatus:N,submissionRequest:G,submissionResponse:q,submissionError:H,submissionEnvironment:a,idFrontImage:Q,idBackImage:ne,passportImage:ie,selfieImage:le,signatureData:de,signatureVideo:pe,additionalDocuments:ve,setIdFrontImage:ee,setIdBackImage:re,setPassportImage:ae,setSelfieImage:ce,setSignatureData:he,setSignatureVideo:ge,setAdditionalDocuments:be,logIdFrontCaptureAttempt:Oe,logIdBackCaptureAttempt:Ne,logSelfieCaptureAttempt:Ue,checkLiveness:Ge,retryLocationAccess:$e}},I&&Te?l.default.createElement(Tt,null):r,H&&l.default.createElement(Rt,{error:H,onRetry:ze}))};function Mt(e){return v(this,void 0,void 0,(function(){var t,n,r,o,i,a;return b(this,(function(s){switch(s.label){case 0:return St?[2,St]:[4,h.loadGraphModel(e)];case 1:return St=s.sent(),[4,h.ready()];case 2:return s.sent(),t=h.zeros([448,448,3]),n=h.cast(t,"int32"),r=h.tensor4d(Array.from(n.dataSync()),[1,448,448,3]),o=h.cast(r,"int32"),a=(i=h).dispose,[4,St.executeAsync(o)];case 3:return a.apply(i,[s.sent()]),n.dispose(),o.dispose(),r.dispose(),h.dispose(t),[2,St]}}))}))}!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"}(Et||(Et={}));var Lt={1:"Document",2:"MRZ",3:"PDF417",4:"Primary face",5:"Secondary face",6:"Glare",7:"Punch Hole",8:"Passport Page"};function Pt(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 Bt(e){void 0===e&&(e={});var n=e.onResize,r=t.useRef(void 0);r.current=n;var o=e.round||Math.round,i=t.useRef(),a=t.useState({width:void 0,height:void 0}),s=a[0],l=a[1],c=t.useRef(!1);t.useEffect((function(){return c.current=!1,function(){c.current=!0}}),[]);var u=t.useRef({width:void 0,height:void 0}),d=function(e,n){var r=t.useRef(null),o=t.useRef(null);o.current=n;var i=t.useRef(null);t.useEffect((function(){a()}));var a=t.useCallback((function(){var t=o.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 t.useEffect((function(){return function(){r.current&&r.current.cleanup&&(r.current.cleanup(),r.current=null)}}),[]),t.useCallback((function(e){i.current=e,a()}),[a])}(t.useCallback((function(t){return i.current&&i.current.box===e.box&&i.current.round===o||(i.current={box:e.box,round:o,instance:new ResizeObserver((function(t){var n=t[0],i="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",a=Pt(n,i,"inlineSize"),s=Pt(n,i,"blockSize"),d=a?o(a):void 0,h=s?o(s):void 0;if(u.current.width!==d||u.current.height!==h){var f={width:d,height:h};u.current.width=d,u.current.height=h,r.current?r.current(f):c.current||l(f)}}))}),i.current.instance.observe(t,{box:e.box}),function(){i.current&&i.current.instance.unobserve(t)}}),[e.box,o]),e.ref);return t.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 Ot=t.createContext({orientation:"landscape",wrapperWidth:1,wrapperHeight:1,wrapperAspectRatio:0,imageAspectRatio:0,wrapperRef:null,setDimensions:function(){return null},onImageLoaded:function(){return null}});let Nt;function Ut(e){if(void 0!==Nt)return Nt;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 jt=function(e){var n=e.width,r=void 0===n?0:n,o=e.height,i=void 0===o?0:o,a=e.padding,s=void 0===a?Ut()?0:50:a,c=e.borderWidth,u=void 0===c?4:c,d=e.borderColor,h=void 0===d?"white":d,f=e.isMirrored,p=void 0!==f&&f,g=e.instruction,v=void 0===g?"":g,b=e.portraitGuidesImageUrl,y=e.landscapeGuidesImageUrl,w=e.onClick,x=t.useContext(Ot),E=x.orientation,S=x.wrapperRef,k=x.wrapperWidth,C=x.wrapperHeight,T=x.imageAspectRatio,A=x.wrapperAspectRatio,I=x.onImageLoaded,R=x.setDimensions;0==r&&(r=k),0==i&&(i=C),t.useEffect((function(){R({width:r,height:i})}),[i,R,r]);var D={height:C-2*s-2*u};return T>=A&&(D={width:k-2*s-2*u}),l.default.createElement(ot,{ref:S,onClick:w,style:{zIndex:1e3}},l.default.createElement("div",{style:{display:"flex",flexFlow:"column nowrap",height:"100%"}},l.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&&l.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12}},v)),l.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*u,"px)")}},l.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:s,flexGrow:1}}),l.default.createElement("div",{style:{transform:p?"scaleX(-1)":"",border:"".concat(u,"px solid ").concat(h),maxWidth:"calc(100% - ".concat(2*s,"px - ").concat(2*u,"px)"),maxHeight:i-2*s-2*u}},l.default.createElement("img",{src:"portrait"===E?b:y,alt:"",onLoad:I,style:m({},D)})),l.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:s,flexGrow:1}})),l.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&&l.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12,opacity:0}},v))))};function Gt(e){return v(this,void 0,void 0,(function(){var t;return b(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 $t(e,t){return void 0===t&&(t=!1),v(this,void 0,void 0,(function(){var n,r,o,i,a,s,l,c,u;return b(this,(function(d){switch(d.label){case 0:return[4,new Promise((function(a){if(o=e.naturalWidth,i=e.naturalHeight,n=document.createElement("canvas"),!(r=n.getContext("2d")))return[];if(t){console.log("rotating!!"),n.width=i,n.height=o,r.setTransform(0,1,-1,0,n.width,0),r.drawImage(e,0,0,o,i);var s=new Image;s.width=n.width,s.height=n.height,s.onload=function(){a(s)},n.toBlob((function(e){e&&(s.src=URL.createObjectURL(e))}))}else r.drawImage(e,0,0,n.width,n.height),a(e)}))];case 1:return a=d.sent(),s=new ZXing.BitmapLuminanceSource(r,a),l=new ZXing.Common.HybridBinarizer(s),c=new ZXing.BinaryBitmap(l),u=ZXing.PDF417.PDF417Reader.decode(c,null,!1),r.clearRect(0,0,n.width,n.height),n.remove(),[2,u]}}))}))}function zt(){return"BarcodeDetector"in window}function qt(e,t){var n=this;return new Promise((function(r){var o=new Image;o.onload=function(){return v(n,void 0,void 0,(function(){var e,n,i,a;return b(this,(function(s){switch(s.label){case 0:return zt()?[4,Gt(o)]:[3,2];case 1:return n=s.sent(),console.log("native result",n,"".concat(o.width,"x").concat(o.height)),r(n.length>0?m(m({},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!==(a=null==t?void 0:t[3])&&void 0!==a?a:0),[4,$t(o,e)];case 3:n=s.sent(),console.log("zxing result",n),r(n.length>0?m(m({},n[0]),{Source:"zxing"}):null),s.label=4;case 4:return[2]}}))}))},o.src=URL.createObjectURL(e)}))}function Vt(){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 Wt,Ht=["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("")})),Kt=["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("")})),Yt=["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("")})),Xt=function(e,t){var n=e instanceof MediaDeviceInfo?Jt(e):e;return("string"==typeof t?[t]:t).some((function(e){return n.includes(e)}))},Jt=function(e){return e.label.toLocaleLowerCase().split(" ").join("")};function Zt(){Wt&&(console.log("releasing camera access..."),Wt.release(),Wt=void 0)}var Qt,en=function(e){var n=void 0===e?{preferFrontFacingCamera:!1,preferContinuityCamera:!0,requestMicrophoneAccess:!1}:e,r=n.preferFrontFacingCamera,o=void 0!==r&&r,i=n.preferContinuityCamera,a=void 0===i||i,s=n.requestMicrophoneAccess,l=void 0!==s&&s,c=t.useRef(null),u=t.useRef(null),d=t.useState(null),h=d[0],f=d[1],p=t.useState(!1),g=p[0],m=p[1],w=t.useState(null),x=w[0],E=w[1],S=t.useState(!1),k=S[0],C=S[1],T=t.useState(a),A=T[0],I=T[1],R=t.useState(!1),D=R[0],_=R[1],F=t.useState(!1),M=F[0],L=F[1];t.useEffect((function(){console.log("iphone continuity camera allowed changed",A),Zt(),u.current=null,m(!1)}),[A]);var P=t.useCallback((function(){L(!1)}),[]);t.useEffect((function(){M||function(e){return v(this,void 0,void 0,(function(){var t,n;return b(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=He();if(!(D||n&&"OS X"!==n.os.family)){var r=e.find((function(e){return Xt(e,"iphone")}));C(!!r),r&&A&&(t=r)}o&&(t=e.find((function(e){return Xt(e,Ht)}))),Vt()?t||(t=e.find((function(e){return Xt(e,Yt)}))):t||(t=e.find((function(e){return Xt(e,Kt)&&!Xt(e,Yt)}))),t||(t=e.find((function(e){return Xt(e,Kt)}))),!o&&"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,D,o]),t.useEffect((function(){var e;if(h){var t=function(){Zt(),u.current=null,m(!1)};return(null===(e=navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia)?(v(void 0,void 0,void 0,(function(){var e,t,n;return b(this,(function(r){switch(r.label){case 0:e=null,r.label=1;case 1:return r.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=r.sent(),[3,4];case 3:return"NotAllowedError"===r.sent().name?(A?(C(!1),_(!0)):L(!0),[2]):[3,4];case 4:if(e)return[3,8];r.label=5;case 5:return r.trys.push([5,7,,8]),[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 6:return e=r.sent(),console.log("opened stream with no width and height constraints"),[3,8];case 7:return r.sent(),console.log("cannot open stream at all"),[3,8];case 8:if(!e)throw new Error("failed to open camera");return t=function(){k&&A?(console.log("someone unplugged the continuity camera"),Zt(),u.current=null,C(!1),_(!0),E(null),f(null)):(console.log("someone unplugged the webcam"),Zt(),u.current=null,m(!1),L(!0),E(null))},null===(n=c.current)||void 0===n||n.addEventListener("ended",t),e.getVideoTracks().forEach((function(e){e.onended=t})),u.current=function(e,t,n){Zt(),console.log("obtaining camera access...");var r=e.getVideoTracks()[0].getSettings(),o=r.width,i=r.height,a=t.toLocaleLowerCase().split(" ").join(""),s=Xt(a,y(y(y([],Kt,!0),Yt,!0),["iphone"],!1));return o||(o=0),i||(i=0),Wt={label:t,stream:e,width:o,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),Wt}(e,h.label,c.current),[2]}}))})),t):t}}),[A,k,l,h]),t.useEffect((function(){E(null),g&&v(void 0,void 0,void 0,(function(){var e,t,n,r;return b(this,(function(o){return(e=(null!==(r=null===(n=null===(t=u.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]}))}))}),[g]);var B=t.useCallback((function(){return v(void 0,void 0,void 0,(function(){return b(this,(function(e){switch(e.label){case 0:return x?[4,x.grabFrame()]:[2,null];case 1:return[2,e.sent()]}}))}))}),[x]),O=t.useCallback((function(){return v(void 0,void 0,void 0,(function(){var e,t,n,r,o;return b(this,(function(i){switch(i.label){case 0:return e=document.createElement("canvas"),(t=e.getContext("2d"))&&u.current&&c.current?(e.width=null===(r=c.current)||void 0===r?void 0:r.videoWidth,e.height=null===(o=c.current)||void 0===o?void 0:o.videoHeight,t.drawImage(c.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:c,videoDevice:h,videoLoaded:g,setVideoLoaded:m,cameraRef:u,cameraAccessDenied:M,retryCameraAccess:P,releaseCameraAccess:Zt,iphoneContinuityCameraAvailable:k,iphoneContinuityCameraAllowed:A,setIphoneContinuityCameraAllowed:I,captureDevice:x,grabFrame:B,takePhoto:O}},tn=t.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}}),nn=function(e){var n=e.children,r=e.preferFrontFacingCamera,o=e.preferContinuityCamera,i=e.requestMicrophoneAccess,a=en({preferFrontFacingCamera:void 0!==r&&r,preferContinuityCamera:void 0===o||o,requestMicrophoneAccess:void 0!==i&&i}),s=a.videoRef,c=a.videoLoaded,u=a.setVideoLoaded,d=a.cameraRef,h=a.cameraAccessDenied,f=a.retryCameraAccess,p=a.releaseCameraAccess,g=a.iphoneContinuityCameraAvailable,m=a.iphoneContinuityCameraAllowed,v=a.setIphoneContinuityCameraAllowed,b=a.grabFrame,y=a.takePhoto,w=a.captureDevice,x=t.useState(!1),E=x[0],S=x[1];return t.useEffect((function(){S(!1),w&&S(!0)}),[w]),t.useEffect((function(){return function(){p()}}),[p]),l.default.createElement(tn.Provider,{value:{videoRef:s,videoLoaded:c,setVideoLoaded:u,cameraRef:d,cameraReady:E,cameraAccessDenied:h,releaseCameraAccess:p,retryCameraAccess:f,iphoneContinuityCameraAvailable:g,iphoneContinuityCameraAllowed:m,setIphoneContinuityCameraAllowed:v,grabFrame:b,takePhoto:y}},n)};function rn(e){return v(this,void 0,void 0,(function(){var t,n,r,o,i,a,s,l,c;return b(this,(function(u){switch(u.label){case 0:return Qt?[2,Qt]:[4,h.loadLayersModel(e)];case 1:return Qt=u.sent(),[4,h.ready()];case 2:return u.sent(),t=h.zeros([448,448,3]),n=h.cast(t,"int32"),i=(o=h).tensor4d,s=(a=Array).from,[4,n.data()];case 3:return r=i.apply(o,[s.apply(a,[u.sent()]),[1,448,448,3]]),l=h.cast(r,"int32"),[4,Qt.predict(l)];case 4:return[4,(c=u.sent()).data()];case 5:return u.sent(),h.dispose(c),n.dispose(),l.dispose(),r.dispose(),h.dispose(t),[2,Qt]}}))}))}class on{refCount(e){return an("refCount")}incRef(e){return an("incRef")}timerAvailable(){return!0}time(e){return an("time")}read(e){return an("read")}readSync(e){return an("readSync")}readToGPU(e,t){return an("readToGPU")}numDataIds(){return an("numDataIds")}disposeData(e,t){return an("disposeData")}write(e,t,n){return an("write")}move(e,t,n,r,o){return an("move")}createTensorFromGPUData(e,t,n){return an("createTensorFromGPUData")}memory(){return an("memory")}floatPrecision(){return an("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return an("dispose")}}function an(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 sn(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function ln(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 cn(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 un(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function dn(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 hn(e){return"string"==typeof e||e instanceof String}function fn(e){return Array.isArray(e)?fn(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":"number"==typeof e?"float32":hn(e)?"string":function(e){return"boolean"==typeof e}(e)?"bool":"float32"}function pn(e){return!!(e&&e.constructor&&e.call&&e.apply)}function gn(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 mn(e,t,n,r=!1){const o=new Array;if(1===t.length){const i=t[0]*(r?2:1);for(let t=0;t<i;t++)o[t]=n[e+t]}else{const i=t[0],a=t.slice(1),s=a.reduce(((e,t)=>e*t))*(r?2:1);for(let t=0;t<i;t++)o[t]=mn(e+t*s,a,n,r)}return o}function vn(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 mn(0,e,t,n)}function bn(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 yn(e){e.forEach((t=>{sn(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function wn(e){return e&&e.then&&"function"==typeof e.then}const xn="tfjsflags";class En{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Sn,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&(kn().getBool("IS_TEST")||kn().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];kn().getBool("IS_TEST")||kn().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(wn(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(xn in e){e[xn].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 Sn(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 kn(){return Tn}let Cn,Tn=null;function An(){if(null==Cn){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}Cn=e}return Cn}function In(e,t){const n=function(){const e=An();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 Rn="Add",Dn="Cast",_n="Identity";function Fn(...e){kn().getBool("IS_TEST")||kn().getBool("PROD")||console.warn(...e)}const Mn=In("kernelRegistry",(()=>new Map)),Ln=In("gradRegistry",(()=>new Map));function Pn(e,t){const n=function(e,t){return`${t}_${e}`}(e,t);return Mn.get(n)}function Bn(e){return Ln.get(e)}function On(e){const t=Mn.entries(),n=[];for(;;){const{done:r,value:o}=t.next();if(r)break;const[i,a]=o,[s]=i.split("_");s===e&&n.push(a)}return n}function Nn(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}function Un(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=zn(e)),kn().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 jn(){return kn().platform.now()}function Gn(e,t="utf-8"){return t=t||"utf-8",kn().platform.decode(e,t)}function $n(e){return null!=kn().platform.isTypedArray?kn().platform.isTypedArray(e):Nn(e)}function zn(e,t=[],n=!1){if(null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||wn(e)||null==e||$n(e)&&n)t.push(e);else if(Array.isArray(e)||$n(e))for(let r=0;r<e.length;++r)zn(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 o=0;o<=r;o++)zn(e[o],t,n)}return t}class qn{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new Wn)}profileKernel(e,t,n){let r;const o=()=>{r=n()};let i;const a=jn();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(o);else{o();for(const e of r)e.dataSync();i=Promise.resolve({kernelMs:jn()-a})}if(kn().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<r.length;t++){const n=r[t];n.data().then((t=>{Vn(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:o,extraInfo:i}=e;n.forEach((e=>{Promise.all([e.data(),r,i]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],o,n[2])}))}))}}function Vn(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 Wn{logKernelProfile(e,t,n,r,o,i){const a="number"==typeof r?un(`${r}ms`,9):r.error,s=un(e,25),l=t.rank,c=t.size,u=un(t.shape.toString(),14);let d="";for(const e in o){const n=o[e];if(null!=n){const r=n.shape||t.shape,o=r.length;d+=`${e}: ${o}D ${o>0?r:""} `}}console.log(`%c${s}\t%c${a}\t%c${l}D ${u}\t%c${c}\t%c${d}\t%c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}const Hn=20,Kn=3,Yn=7;function Xn(e,t,n,r){const o=gn(t),i=function(e,t,n,r){const o=ln(t),i=r[r.length-1],a=new Array(i).fill(0),s=t.length,l="complex64"===n?er(e):e;if(s>1)for(let e=0;e<o/i;e++){const t=e*i;for(let e=0;e<i;e++)a[e]=Math.max(a[e],Jn(l[t+e],0,n).length)}return a}(e,t,n,o),a=t.length,s=Qn(e,t,n,o,i),l=["Tensor"];return r&&(l.push(` dtype: ${n}`),l.push(` rank: ${a}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(s.map((e=>" "+e)).join("\n")),l.join("\n")}function Jn(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(Yn))} + ${parseFloat(e[1].toFixed(Yn))}j`:hn(e)?`'${e}'`:"bool"===n?Zn(e):parseFloat(e.toFixed(Yn)).toString(),un(r,t)}function Zn(e){return 0===e?"false":"true"}function Qn(e,t,n,r,o,i=!0){const a="complex64"===n?2:1,s=t[0],l=t.length;if(0===l){if("complex64"===n){return[Jn(er(e)[0],0,n)]}return"bool"===n?[Zn(e[0])]:[e[0].toString()]}if(1===l){if(s>Hn){let t=Array.from(e.slice(0,Kn*a)),r=Array.from(e.slice((s-Kn)*a,s*a));return"complex64"===n&&(t=er(t),r=er(r)),["["+t.map(((e,t)=>Jn(e,o[t],n))).join(", ")+", ..., "+r.map(((e,t)=>Jn(e,o[s-Kn+t],n))).join(", ")+"]"]}return["["+("complex64"===n?er(e):Array.from(e)).map(((e,t)=>Jn(e,o[t],n))).join(", ")+"]"]}const c=t.slice(1),u=r.slice(1),d=r[0]*a,h=[];if(s>Hn){for(let t=0;t<Kn;t++){const r=t*d;h.push(...Qn(e.slice(r,r+d),c,n,u,o,!1))}h.push("...");for(let t=s-Kn;t<s;t++){const r=t*d;h.push(...Qn(e.slice(r,r+d),c,n,u,o,t===s-1))}}else for(let t=0;t<s;t++){const r=t*d;h.push(...Qn(e.slice(r,r+d),c,n,u,o,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 er(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}class tr{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=ln(e),null!=n){const e=n.length;sn(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=gn(e)}set(e,...t){0===t.length&&(t=[0]),sn(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 nr().makeTensor(this.values,this.shape,this.dtype)}}let nr=null,rr=null;class or{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=ln(e),this.strides=gn(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 rr.buffer(this.shape,this.dtype,e)}bufferSync(){return rr.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return vn(this.shape,e,"complex64"===this.dtype)}arraySync(){return vn(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=nr().read(this.dataId);if("string"===this.dtype){const t=await e;try{return t.map((e=>Gn(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(),nr().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=nr().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>Gn(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 nr().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(nr().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return rr.print(this,e)}clone(){return this.throwIfDisposed(),rr.clone(this)}toString(e=!1){return Xn(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),rr.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),nr().makeVariable(this,e,t,n)}}Object.defineProperty(or,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),In("Tensor",(()=>or));class ir extends or{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(!cn(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);nr().disposeTensor(this),this.dataId=e.dataId,nr().incRef(this,null)}dispose(){nr().disposeVariable(this),this.isDisposedInternal=!0}}var ar,sr,lr,cr,ur;Object.defineProperty(ir,Symbol.hasInstance,{value:e=>e instanceof or&&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"}(ar||(ar={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(sr||(sr={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(lr||(lr={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(cr||(cr={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(ur||(ur={}));const dr={float32:cr,int32:sr,bool:lr,complex64:ur};function hr(e){return null!=e&&"object"==typeof e&&"texture"in e&&e.texture instanceof WebGLTexture}function fr(e){return"undefined"!=typeof GPUBuffer&&null!=e&&"object"==typeof e&&"buffer"in e&&e.buffer instanceof GPUBuffer}function pr(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 dr[e][t]}(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function gr(e){const t=[];return mr(e,t,new Set),t}function mr(e,t,n){if(null==e)return;if(e instanceof or)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const o=e;for(const e in o){const r=o[e];n.has(r)||(n.add(r),mr(r,t,n))}}function vr(e){return null!=e.kernelName}class br{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 yr{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new br}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?(Fn(`${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 qn(this.backendInstance),!0}setupRegisteredKernels(){On(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){On(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 on||"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,Fn(`Initialization of backend ${e} failed`),Fn(n.stack||n.message)),!1)));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(t){return Fn(`Initialization of backend ${e} failed`),Fn(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:o}=this.initializeBackend(n);if(o||r)return{name:n,asyncInit:o}}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,o=this.readSync(t),i=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,o,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 yr.nextTensorId++}nextVariableId(){return yr.nextVariableId++}clone(e){const t=xr.runKernel(_n,{x:e});return this.addTapeNode(this.state.activeScope.name,{x:e},[t],(e=>({x:()=>xr.runKernel(Dn,{x:e},{dtype:"float32"})})),[],{}),t}runKernel(e,t,n){if(!(null!=Pn(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 o=0;n.forEach((e=>{o+="complex64"===e.dtype?3:1}));const i=r-t-o-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(),o=this.state.numBytes,i=this.state.numTensors;let a,s;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);const l=vr(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(vr(e)){const{kernelName:t,inputs:o,attrs:i}=e,l=Pn(t,this.backendName);sn(null!=l,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),a=()=>{const e=this.backend.numDataIds();s=l.kernelFunc({inputs:o,attrs:i,backend:this.backend});const a=Array.isArray(s)?s:[s];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,a);const c=a.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(r){const e=this.getTensorsForGradient(t,o,c);n=this.saveTensorsForBackwardMode(e)}return c}}else{const{forwardFunc:t}=e,o=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};a=()=>{const e=this.backend.numDataIds();s=this.tidy((()=>t(this.backend,o)));const n=Array.isArray(s)?s:[s];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,e,n),n}}const{inputs:c,attrs:u}=e,d=vr(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,c,(()=>a())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(h),t=h.outputs):t=a()})),r&&this.addTapeNode(l,c,t,d,n,u),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-o,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(c).map((e=>null!=c[e]?c[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=Bn(e);if(null!=r){const e=r.inputsToSave||[],o=r.outputsToSave||[];let i;r.saveAllInputs?(sn(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 a=n.filter(((e,t)=>o[t]));return i.concat(a)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");r=r||this.backend;let o=e;"string"===(n=n||"float32")&&hn(e[0])&&(o=e.map((e=>function(e,t="utf-8"){return t=t||"utf-8",kn().platform.encode(e,t)}(e))));const i=r.write(o,t,n),a=new or(t,n,i,this.nextTensorId());if(this.trackTensor(a,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}(o);this.state.numBytes+=t-e.bytes,e.bytes=t}return a}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:o}=e,i=new or(r,o,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 o=new ir(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[o.name])throw new Error(`Variable with name ${o.name} was already registered`);return this.state.registeredVariables[o.name]=o,this.incRef(o,this.backend),o}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*dn(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 ir||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*dn(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,o,i){const a={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:o},s=Bn(e);null!=s&&(r=s.gradFunc),null!=r&&(a.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=bn(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],o,i))),this.state.activeTape.push(a)}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=gr(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(sn(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 o=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));sn(o instanceof or,(()=>"The result y returned by f() must be a tensor."));const i=function(e,t,n){const r={},o={};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],a=i.inputs;for(const e in a){const n=a[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,o[i.id]=!0;break}if(s)break}}const i={};i[n.id]=!0;const a={};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,a[n.id]=!0;break}}const s=[];for(let t=0;t<e.length;t++){const n=e[t];if(o[n.id]&&a[n.id]){const e={};for(const t in n.inputs){const o=n.inputs[t];r[o.id]&&(e[t]=o)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,s.push(t)}}return s}(this.state.activeTape,t,o);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[o.id]=null==n?function(e){const t=function(e,t){const n=bn(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}(ln(e),"float32");return xr.makeTensor(t,e,"float32")}(o.shape):n,function(e,t,n,r){for(let o=t.length-1;o>=0;o--){const i=t[o],a=[];if(i.outputs.forEach((t=>{const n=e[t.id];a.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(a);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 o=n((()=>s[t]()));if("float32"!==o.dtype)throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${o.dtype}'`);const a=i.inputs[t];if(!cn(o.shape,a.shape))throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input '${t}' has shape '${o.shape}', which does not match the shape of the input '${a.shape}'`);if(null==e[a.id])e[a.id]=o;else{const t=e[a.id];e[a.id]=r(t,o),t.dispose()}}}}(e,i,(e=>this.tidy(e)),Er);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:o,grads:r}}))}customGrad(e){return sn(pn(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;sn(t.every((e=>e instanceof or)),(()=>"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,o)=>(n=e(...t,o),sn(n.value instanceof or,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),sn(pn(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 o=n.gradFunc(e,r),i=Array.isArray(o)?o:[o];sn(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(...).")),sn(i.every((e=>e instanceof or)),(()=>"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 a={};return i.forEach(((e,t)=>{a[t]=()=>e})),a},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=jn(),n=await this.backend.time(e);return n.wallMs=jn()-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 br;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 wr(){const e=An();if(null==e._tfengine){const t=new En(e);e._tfengine=new yr(t)}return Tn=e._tfengine.ENV,function(e){nr=e}((()=>e._tfengine)),e._tfengine}yr.nextTensorId=0,yr.nextVariableId=0;const xr=wr();function Er(e,t){return xr.runKernel(Rn,{a:e,b:t})}const Sr=kn();function kr(e,t){let n=e;if($n(e))return"string"===t?[]:[e.length];if(hr(e)){return[e.height,e.width*(e.channels||"RGBA").length]}if(fr(e))return[e.buffer.size/(null==t?4:dn(t))];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||$n(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&kn().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Cr(e,r,[]),r}function Cr(e,t,n){if(n=n||[],!Array.isArray(e)&&!$n(e))return void sn(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));sn(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),sn(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)Cr(e[t],r,n.concat(t))}function Tr(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 or)return Tr(r,e.dtype,t,n),e;let o=fn(e);if("string"!==o&&["bool","int32","float32"].indexOf(r)>=0&&(o=r),Tr(r,o,t,n),null==e||!$n(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=kr(e,o);$n(e)||Array.isArray(e)||(e=[e]);const a="string"!==o?Un(e,o):zn(e,[],!0);return xr.makeTensor(a,i,o)}Sr.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.")})),Sr.registerFlag("IS_BROWSER",(()=>"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope)),Sr.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),Sr.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),Sr.registerFlag("IS_SAFARI",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor))),Sr.registerFlag("PROD",(()=>!1)),Sr.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>Sr.getBool("DEBUG"))),Sr.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),Sr.registerFlag("IS_TEST",(()=>!1)),Sr.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>Sr.getBool("DEBUG"))),Sr.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),Sr.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(()=>!1)),Sr.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 o=(...e)=>{xr.startScope(n);try{const t=r(...e);return wn(t)&&console.error("Cannot return a Promise inside of tidy."),xr.endScope(t),t}catch(e){throw xr.endScope(null),e}};return Object.defineProperty(o,"name",{value:n,configurable:!0}),o}class Rr{static join(e){return new Rr(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,null==e)return;if(e instanceof Array||(e=[e]),0===(e=e.map((e=>$n(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 o=t+r.byteLength;this.shards.push({buffer:r,start:t,end:o}),t=o}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),o=new Uint8Array(r);let i=0;for(let r=n;r<this.shards.length;r++){const n=this.shards[r],a=e+i-n.start,s=i,l=Math.min(t,n.end),c=new Uint8Array(n.buffer,a,l-n.start-a);if(o.set(c,s),i+=c.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 o=Math.floor((r-n)/2)+n,i=t(e[o]);if(0===i)return o;i<0?r=o:n=o+1}return-1}(this.shards,t);return-1===n?-1:(this.previousShardIndex=n,this.previousShardIndex)}}const Dr="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function _r(e){return Dr?Buffer.byteLength(e,"utf8"):new Blob([e]).size}function Fr(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:_r(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:_r(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:new Rr(e.weightData).byteLength}}class Mr{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==Mr.instance&&(Mr.instance=new Mr),Mr.instance}static registerSaveRouter(e){Mr.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Mr.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Mr.getHandlers(e,"save")}static getLoadHandlers(e,t){return Mr.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?Mr.getInstance().loadRouters:Mr.getInstance().saveRouters).forEach((t=>{const o=t(e,n);null!==o&&r.push(o)})),r}}const Lr="tensorflowjs",Pr="models_store",Br="model_info_store";function Or(){if(!kn().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 Nr(e){const t=e.result;t.createObjectStore(Pr,{keyPath:"modelPath"}),t.createObjectStore(Br,{keyPath:"modelPath"})}class Ur{constructor(e){if(this.indexedDB=Or(),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(Lr,1);r.onupgradeneeded=()=>Nr(r),r.onsuccess=()=>{const o=r.result;if(null==t){const t=o.transaction(Pr,"readonly"),r=t.objectStore(Pr).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return o.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(o.close(),n(r.error)),t.oncomplete=()=>o.close()}else{const r=Fr(t),i=o.transaction(Br,"readwrite");let a,s,l=i.objectStore(Br);try{a=l.put({modelPath:this.modelPath,modelArtifactsInfo:r})}catch(e){return n(e)}a.onsuccess=()=>{s=o.transaction(Pr,"readwrite");const a=s.objectStore(Pr);let c;try{c=a.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r})}catch(e){return n(e)}c.onsuccess=()=>e({modelArtifactsInfo:r}),c.onerror=e=>{l=i.objectStore(Br);const t=l.delete(this.modelPath);t.onsuccess=()=>(o.close(),n(c.error)),t.onerror=e=>(o.close(),n(c.error))}},a.onerror=e=>(o.close(),n(a.error)),i.oncomplete=()=>{null==s?o.close():s.oncomplete=()=>o.close()}}},r.onerror=e=>n(r.error)}))}}Ur.URL_SCHEME="indexeddb://";const jr=e=>{return kn().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ur.URL_SCHEME)?(t=e.slice(Ur.URL_SCHEME.length),new Ur(t)):null;var t};Mr.registerSaveRouter(jr),Mr.registerLoadRouter(jr);class Gr{constructor(){this.indexedDB=Or()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(Lr,1);n.onupgradeneeded=()=>Nr(n),n.onsuccess=()=>{const r=n.result,o=r.transaction(Br,"readonly"),i=o.objectStore(Br).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)),o.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(Ur.URL_SCHEME)?t.slice(Ur.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(Lr,1);r.onupgradeneeded=()=>Nr(r),r.onsuccess=()=>{const o=r.result,i=o.transaction(Br,"readwrite"),a=i.objectStore(Br),s=a.get(e);let l;s.onsuccess=()=>{if(null==s.result)return o.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=a.delete(e),i=()=>{l=o.transaction(Pr,"readwrite");const r=l.objectStore(Pr).delete(e);r.onsuccess=()=>t(s.result.modelArtifactsInfo),r.onerror=e=>n(s.error)};r.onsuccess=i,r.onerror=e=>(i(),o.close(),n(s.error))}},s.onerror=e=>(o.close(),n(s.error)),i.oncomplete=()=>{null==l?o.close():l.oncomplete=()=>o.close()}},r.onerror=e=>n(r.error)}))}}const $r="/",zr="tensorflowjs_models",qr="info",Vr="model_topology",Wr="weight_specs",Hr="weight_data",Kr="model_metadata";function Yr(e){return{info:[zr,e,qr].join($r),topology:[zr,e,Vr].join($r),weightSpecs:[zr,e,Wr].join($r),weightData:[zr,e,Hr].join($r),modelMetadata:[zr,e,Kr].join($r)}}function Xr(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function Jr(e){const t=e.split($r);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join($r)}class Zr{constructor(e){if(!kn().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=Yr(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=Fr(e),o=Rr.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(Dr)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)}(o));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 Xr(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 o=this.LS.getItem(this.keys.modelMetadata);if(null!=o){const e=JSON.parse(o);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(Dr){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}}Zr.URL_SCHEME="localstorage://";const Qr=e=>{return kn().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Zr.URL_SCHEME)?(t=e.slice(Zr.URL_SCHEME.length),new Zr(t)):null;var t};Mr.registerSaveRouter(Qr),Mr.registerLoadRouter(Qr);class eo{constructor(){sn(kn().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),sn("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=zr+$r,n=$r+qr;for(let r=0;r<this.LS.length;++r){const o=this.LS.key(r);if(o.startsWith(t)&&o.endsWith(n)){e[Jr(o)]=JSON.parse(this.LS.getItem(o))}}return e}async removeModel(e){var t;const n=Yr(e=(t=e).startsWith(Zr.URL_SCHEME)?t.slice(Zr.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 Xr(n),r}}class to{constructor(){this.managers={}}static getInstance(){return null==to.instance&&(to.instance=new to),to.instance}static registerManager(e,t){sn(null!=e,(()=>"scheme must not be undefined or null.")),e.endsWith("://")&&(e=e.slice(0,e.indexOf("://"))),sn(e.length>0,(()=>"scheme must not be an empty string."));const n=to.getInstance();sn(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=to.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(to.getInstance().managers)}}class no{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&&kn().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 Nn(e)}}if(kn().get("IS_BROWSER")){kn().setPlatform("browser",new no);try{to.registerManager(Zr.URL_SCHEME,new eo)}catch(e){}try{to.registerManager(Ur.URL_SCHEME,new Gr)}catch(e){}}const ro=()=>require("node-fetch");let oo;class io{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=kn().global.fetch?kn().global.fetch(e,t):(null==oo&&(oo=ro()),oo(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)}}kn().get("IS_NODE")&&!kn().get("IS_BROWSER")&&kn().setPlatform("node",new io);const ao=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 xr.runKernel(Dn,{x:n},{dtype:t})}});const so=Ir({clone_:function(e){const t=Ar(e,"x","clone","string_or_numeric");return xr.runKernel(_n,{x:t})}});wr();const lo={buffer:function(e,t="float32",n){return t=t||"float32",yn(e),new tr(e,t,n)},cast:ao,clone:so,print:function(e,t=!1){console.log(e.toString(t))}};function co(e,t){return xr.tidy(e,t)}function uo(e){gr(e).forEach((e=>e.dispose()))}rr=lo;const ho=Ir({add_:function(e,t){let n=Ar(e,"a","add"),r=Ar(t,"b","add");return[n,r]=pr(n,r),xr.runKernel(Rn,{a:n,b:r})}});const fo=Ir({floorDiv_:function(e,t){let n=Ar(e,"a","floorDiv"),r=Ar(t,"b","floorDiv");return[n,r]=pr(n,r),xr.runKernel("FloorDiv",{a:n,b:r})}});const po=Ir({div_:function(e,t){let n=Ar(e,"a","div"),r=Ar(t,"b","div");return[n,r]=pr(n,r),"int32"===n.dtype&&"int32"===r.dtype?fo(n,r):xr.runKernel("RealDiv",{a:n,b:r},{})}});const go=Ir({mul_:function(e,t){let n=Ar(e,"a","mul"),r=Ar(t,"b","mul");return[n,r]=pr(n,r),xr.runKernel("Multiply",{a:n,b:r})}});const mo=Ir({abs_:function(e){const t=Ar(e,"x","abs");if("complex64"===t.dtype){return xr.runKernel("ComplexAbs",{x:t})}return xr.runKernel("Abs",{x:t})}});const vo=Ir({zerosLike_:function(e){const t=Ar(e,"x","zerosLike");return xr.runKernel("ZerosLike",{x:t})}});const bo=Ir({pow_:function(e,t){let n=Ar(e,"base","pow"),r=Ar(t,"exp","pow");return[n,r]=pr(n,r),xr.runKernel("Pow",{a:n,b:r})}});function yo(e,t){if(($n(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&&$n(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=fn(e);else if("complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(fr(e)||hr(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 xr.backend.createTensorFromGPUData(e,t||n,r)}if(!$n(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){yn(t);const e=ln(t),r=ln(n);sn(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]!==ln(t.slice(e));sn(n[e]===t[e]||!r,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return $n(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?Un(e,r):zn(e,[],!0),xr.makeTensor(e,t,r)}(e,[],[],t)}const wo=Ir({sqrt_:function(e){const t=Ar(e,"x","sqrt","float32");return xr.runKernel("Sqrt",{x:t})}});const xo=Ir({square_:function(e){const t=Ar(e,"x","square");return xr.runKernel("Square",{x:t},{})}});const Eo=Ir({sub_:function(e,t){let n=Ar(e,"a","sub"),r=Ar(t,"b","sub");return[n,r]=pr(n,r),xr.runKernel("Sub",{a:n,b:r})}});const So=Ir({maximum_:function(e,t){let n=Ar(e,"a","maximum"),r=Ar(t,"b","maximum");return[n,r]=pr(n,r),"bool"===n.dtype&&(n=ao(n,"int32"),r=ao(r,"int32")),function(e,t){const n=Math.max(e.length,t.length),r=new Array(n);for(let o=0;o<n;o++){let i=e[e.length-o-1];null==i&&(i=1);let a=t[t.length-o-1];if(null==a&&(a=1),1===i)r[n-o-1]=a;else if(1===a)r[n-o-1]=i;else{if(i!==a)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);r[n-o-1]=i}}}(n.shape,r.shape),xr.runKernel("Maximum",{a:n,b:r})}});class ko{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class Co{constructor(){this.classNameMap={}}static getMap(){return null==Co.instance&&(Co.instance=new Co),Co.instance}static register(e){Co.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function To(e){sn(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),sn("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),sn(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),Co.register(e)}class Ao extends ko{minimize(e,t=!1,n){const{value:r,grads:o}=this.computeGradients(e,n);if(null!=n){const e=n.map((e=>({name:e.name,tensor:o[e.name]})));this.applyGradients(e)}else this.applyGradients(o);return uo(o),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){sn(pn(e),(()=>"The f passed in variableGrads(f) must be a function")),sn(null==t||Array.isArray(t)&&t.every((e=>e instanceof ir)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=t;if(!n){t=[];for(const e in xr.registeredVariables)t.push(xr.registeredVariables[e])}const r=n?t.filter((e=>!e.trainable)):null,o=t.length;sn((t=t.filter((e=>e.trainable))).length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${o} variables is trainable.`));const{value:i,grads:a}=xr.gradients(e,t,null,!0);sn(a.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().")),sn(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!=a[t]&&(s[e.name]=a[t])})),null!=r&&r.forEach((e=>s[e.name]=null)),{value:i,grads:s}}(e,t)}dispose(){null!=this.iterations_&&uo(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:yo(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(Ao,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class Io extends Ao{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 o=xr.registeredVariables[t];co((()=>{const e=ho(go(this.c,r),o);o.assign(e)}))})),this.incrementIterations()}setLearningRate(e){var t;this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=(t=yo(-e),xr.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 Ro=[class extends Ao{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=xr.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=xr.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:co((()=>vo(r).variable(false)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:co((()=>vo(r).variable(false)))});const o=Array.isArray(e)?e[n].tensor:e[t];if(null==o)return;const i=this.accumulatedGrads[n].variable,a=this.accumulatedUpdates[n].variable;co((()=>{const e=ho(go(i,this.rho),go(xo(o),1-this.rho)),t=go(po(wo(ho(a,this.epsilon)),wo(ho(i,this.epsilon))),o),n=ho(go(a,this.rho),go(xo(t),1-this.rho));i.assign(e),a.assign(n);const s=ho(go(t,-this.learningRate),r);r.assign(s)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(uo(this.accumulatedGrads.map((e=>e.variable))),uo(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 Ao{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=xr.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:co((()=>function(e,t,n){return yn(e),n=n||fn(t),xr.runKernel("Fill",{},{shape:e,value:t,dtype:n})}(r.shape,this.initialAccumulatorValue).variable(e)))}}const o=Array.isArray(e)?e[n].tensor:e[t];if(null==o)return;const i=this.accumulatedGrads[n].variable;co((()=>{const e=ho(i,xo(o));i.assign(e);const t=ho(go(po(o,wo(ho(e,xr.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&uo(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 Ao{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=[],co((()=>{this.accBeta1=yo(t).variable(),this.accBeta2=yo(n).variable()})),null==r&&(this.epsilon=xr.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);co((()=>{const n=Eo(1,this.accBeta1),r=Eo(1,this.accBeta2);t.forEach(((t,o)=>{const i=xr.registeredVariables[t];null==this.accumulatedFirstMoment[o]&&(this.accumulatedFirstMoment[o]={originalName:`${t}/m`,variable:co((()=>vo(i).variable(false)))}),null==this.accumulatedSecondMoment[o]&&(this.accumulatedSecondMoment[o]={originalName:`${t}/v`,variable:co((()=>vo(i).variable(false)))});const a=Array.isArray(e)?e[o].tensor:e[t];if(null==a)return;const s=this.accumulatedFirstMoment[o].variable,l=this.accumulatedSecondMoment[o].variable,c=ho(go(s,this.beta1),go(a,1-this.beta1)),u=ho(go(l,this.beta2),go(xo(a),1-this.beta2)),d=po(c,n),h=po(u,r);s.assign(c),l.assign(u);const f=ho(go(po(d,ho(wo(h),this.epsilon)),-this.learningRate),i);i.assign(f)})),this.accBeta1.assign(go(this.accBeta1,this.beta1)),this.accBeta2.assign(go(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&uo(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&uo(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),co((()=>{this.accBeta1.assign(bo(this.beta1,this.iterations_+1)),this.accBeta2.assign(bo(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 Ao{static get className(){return"Adamax"}constructor(e,t,n,r=null,o=0){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=o,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],co((()=>{this.iteration=yo(0).variable(),this.accBeta1=yo(t).variable()})),null==r&&(this.epsilon=xr.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);co((()=>{const n=Eo(1,this.accBeta1),r=po(-this.learningRate,ho(go(this.iteration,this.decay),1));t.forEach(((t,o)=>{const i=xr.registeredVariables[t];null==this.accumulatedFirstMoment[o]&&(this.accumulatedFirstMoment[o]={originalName:`${t}/m`,variable:vo(i).variable(false)}),null==this.accumulatedWeightedInfNorm[o]&&(this.accumulatedWeightedInfNorm[o]={originalName:`${t}/v`,variable:vo(i).variable(false)});const a=Array.isArray(e)?e[o].tensor:e[t];if(null==a)return;const s=this.accumulatedFirstMoment[o].variable,l=this.accumulatedWeightedInfNorm[o].variable,c=ho(go(s,this.beta1),go(a,1-this.beta1)),u=go(l,this.beta2),d=mo(a),h=So(u,d);s.assign(c),l.assign(h);const f=ho(go(po(r,n),po(c,ho(h,this.epsilon))),i);i.assign(f)})),this.iteration.assign(ho(this.iteration,1)),this.accBeta1.assign(go(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&uo(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&uo(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 Io{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=yo(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=xr.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:co((()=>vo(r).variable(e)))}}const o=this.accumulations[n].variable,i=Array.isArray(e)?e[n].tensor:e[t];null!=i&&co((()=>{let e;const t=ho(go(this.m,o),i);e=ho(go(this.c,this.useNesterov?ho(i,go(t,this.m)):t),r),o.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&uo(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 Ao{static get className(){return"RMSProp"}constructor(e,t=.9,n=0,r=null,o=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=o,null==r&&(this.epsilon=xr.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=xr.registeredVariables[t],o=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:co((()=>vo(r).variable(o)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:co((()=>vo(r).variable(o)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:co((()=>vo(r).variable(o)))});const i=Array.isArray(e)?e[n].tensor:e[t];if(null==i)return;const a=this.accumulatedMeanSquares[n].variable,s=this.accumulatedMoments[n].variable;co((()=>{const e=ho(go(a,this.decay),go(xo(i),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,o=ho(go(t,this.decay),go(i,1-this.decay)),l=po(go(i,this.learningRate),wo(Eo(e,ho(xo(o),this.epsilon)))),c=ho(go(s,this.momentum),l);a.assign(e),t.assign(o),s.assign(c);const u=Eo(r,c);r.assign(u)}else{const e=ho(go(a,this.decay),go(xo(i),1-this.decay)),t=ho(go(s,this.momentum),po(go(i,this.learningRate),wo(ho(e,this.epsilon))));a.assign(e),s.assign(t);const n=Eo(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&uo(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&uo(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&uo(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)}},Io];!function(){for(const e of Ro)To(e)}();const Do={},_o={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Fo(e,t){if(!(e in Do)||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(kn().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 Do[e]}),!1),kn().getBool("SOFTWARE_WEBGL_ENABLED")&&(_o.failIfMajorPerformanceCaveat=!1);if(1===e)return n.getContext("webgl",_o)||n.getContext("experimental-webgl",_o);return n.getContext("webgl2",_o)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;Do[e]=n}const n=Do[e];return null==n||n.isContextLost()?(delete Do[e],Fo(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),Do[e])}var Mo="https://websdk-cdn-dev.idmission.com/assets";function Lo(e){var t=e.width,n=e.height;return e instanceof HTMLVideoElement&&(t=e.videoWidth,n=e.videoHeight),[t,n]}function Po(e,t){var n=document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("could not get 2d context");var o=t.box,i=o.width,a=.6*e.height-i,s=Math.max(0,o.xMin-a/2);return Ut()?(n.width=e.width,n.height=e.height,r.drawImage(e,0,0,n.width,n.height)):(n.width=i+a,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 Bo=function(e){var t=e.error;return l.default.createElement(ct,null,l.default.createElement(ut,{style:{justifyContent:"center"}},l.default.createElement("h3",{style:{marginBottom:8}},"We're sorry, an unexpected error has occurred."),l.default.createElement("p",{style:{marginBottom:0}},l.default.createElement("code",null,t.message))))},Oo={boxes:1,scores:4,labels:2},No=t.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}}),Uo="".concat(Mo,"/models/docdetectuint8/model.json"),jo="".concat(Mo,"/models/focus/model.json"),Go=function(e){var n=e.children,r=e.documentDetectionModelUrl,i=e.focusModelUrl,a=e.logPredictions,s=void 0!==a&&a,c=t.useState(!1),u=c[0],d=c[1],f=t.useState(0),p=f[0],g=f[1],m=t.useState(0),y=m[0],w=m[1],x=t.useState(0),E=x[0],S=x[1],k=t.useState(0),C=k[0],T=k[1],A=t.useState(0),I=A[0],R=A[1],D=t.useRef(!1),_=t.useRef(),F=t.useRef(null),M=t.useState(0),L=M[0],P=M[1],B=t.useState(0),O=B[0],N=B[1],U=t.useState(null),j=U[0],G=U[1];t.useEffect((function(){d(!1);var e=r||Uo,t=i||jo;function n(){return v(this,void 0,void 0,(function(){return b(this,(function(n){switch(n.label){case 0:return h.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",52428800),[4,h.setBackend("webgl")];case 1:return n.sent(),[4,h.ready()];case 2:return n.sent(),[4,Promise.all([Mt(e),rn(t)])];case 3:return n.sent(),[2]}}))}))}function a(){return v(this,void 0,void 0,(function(){var r;return b(this,(function(i){switch(i.label){case 0:return d(!1),St=null,Qt=null,delete Do[2],(r=document.createElement("canvas").getContext("webgl2"))&&e&&t?(o.setWebGLContext(2,r),function(){try{h.backend().dispose()}catch(e){console.error("failed to dispose backend",e)}}(),[4,n()]):[3,2];case 1:i.sent(),d(!0),i.label=2;case 2:return[2]}}))}))}try{n().then((function(){d(!0)}))}catch(e){G(e)}var s=Fo(2).canvas;return s.addEventListener("webglcontextlost",a),function(){var e;null===(e=s.removeEventListener)||void 0===e||e.call(s,"webglcontextlost",a)}}),[r,i]);var $=t.useMemo((function(){return{document:p,passport:y,mrz:E,pdf417:C,focus:I}}),[p,I,E,y,C]),z=t.useCallback((function(e){e.document&&g(e.document),e.passport&&w(e.passport),e.mrz&&S(e.mrz),e.pdf417&&T(e.pdf417),e.focus&&R(e.focus)}),[]),q=t.useRef(null),V=t.useRef(0),W=t.useCallback((function(e){D.current=!0,v(void 0,void 0,void 0,(function(){var t,n;return b(this,(function(r){switch(r.label){case 0:return St&&Qt&&F.current?[4,zo(e,F.current,$,s)]:[2];case 1:return t=r.sent(),P(t.detectionTime),N(t.focusPredictionTime),V.current<=t.focusScore&&(V.current=t.focusScore,$o(q.current,e)),null===(n=_.current)||void 0===n||n.call(_,t),D.current=!1,[2]}}))}))}),[s,$]),H=t.useCallback((function(e){_.current=e}),[]),K=t.useCallback((function(){return v(void 0,void 0,void 0,(function(){var e;return b(this,(function(t){switch(t.label){case 0:return q.current?(e=q.current.toDataURL("image/jpeg",.98),[4,fetch(e)]):[2,null];case 1:return[4,t.sent().blob()];case 2:return[2,t.sent()]}}))}))}),[]),Y=t.useCallback((function(){V.current=0,function(e){if(!e)return;var t=e.getContext("2d");if(!t)return;t.clearRect(0,0,e.width,e.height)}(q.current)}),[]),X=t.useMemo((function(){return{ready:u,working:D,thresholds:$,setThresholds:z,makePrediction:W,onPredictionMade:H,detectionTime:L,focusPredictionTime:O,getBestFrame:K,resetBestFrame:Y}}),[L,O,K,W,H,u,Y,z,$]);return l.default.createElement(No.Provider,{value:X},j?l.default.createElement(Bo,{error:j}):n,l.default.createElement(Jo,{ref:F}),l.default.createElement(Jo,{ref:q}))};function $o(e,t,n,r){if(e){var o=e.getContext("2d");if(o){if(!n||!r){var i=Lo(t);n||(n=i[0]),r||(r=i[1])}e.width=n,e.height=r,o.drawImage(t,0,0,n,r)}}}function zo(e,t,n,r){var o,i,a,s,l,c,u,d,h,f;return void 0===r&&(r=!1),v(this,void 0,void 0,(function(){var p,g,m,v,y,w,x,E,S,k,C,T,A,I,R,D,_,F,M,L,P,B,O,N,U,j,G,$;return b(this,(function(b){switch(b.label){case 0:return p=Lo(e),g=p[0],m=p[1],$o(t,e),[4,qo(e,r)];case 1:return v=b.sent(),y=v.scores,w=v.labels,x=v.time,E=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],o=e[1];return{score:t,bbox:[o,r,e[3]-o,e[2]-r],label:Lt[n]}}(e,y[t],w[t])}))),S=E.find((function(e){return"Document"===e.label})),k=E.find((function(e){return"Passport Page"===e.label})),C=null!==(o=null==S?void 0:S.score)&&void 0!==o?o:0,T=null!==(i=null==k?void 0:k.score)&&void 0!==i?i:0,A=T>=(null!==(a=n.passport)&&void 0!==a?a:0),I=C>T?S:k,D=(R=A?T:C)>=(null!==(s=n.document)&&void 0!==s?s:0),_=Et.NONE,A?_=Et.PASSPORT:D&&(_=Et.ID_CARD),F=E.find((function(e){return"MRZ"===e.label})),M=null!==(l=null==F?void 0:F.score)&&void 0!==l?l:0,L=M>=(null!==(c=n.mrz)&&void 0!==c?c:0),P=E.find((function(e){return"PDF417"===e.label})),B=null!==(u=null==P?void 0:P.score)&&void 0!==u?u:0,O=B>=(null!==(d=n.pdf417)&&void 0!==d?d:0),N=null,U=0,j=0,G=!1,D?[4,Vo(e,null==I?void 0:I.bbox,r)]:[3,3];case 2:$=b.sent(),U=$[1],j=null!==(h=null==(N=$[0])?void 0:N[1])&&void 0!==h?h:0,G=j>=(null!==(f=n.focus)&&void 0!==f?f:0),b.label=3;case 3:return[2,{detectedObjects:E,detectionScore:R,detectionTime:x,detectionThresholdMet:D,detectedDocumentType:_,passportDetectionScore:T,passportDetectionThresholdMet:A,mrzDetectionScore:M,mrzDetectionThresholdMet:L,pdf417DetectionScore:B,pdf417DetectionThresholdMet:O,bestDocumentOrPassport:I,bestMrz:F,bestPdf417:P,focusScore:j,focusThresholdMet:G,focusPredictionTime:U,frameWidth:g,frameHeight:m}]}}))}))}function qo(e,t){return void 0===t&&(t=!1),v(this,void 0,void 0,(function(){var n,r,o,i,a,s,l,c,u,d,f,p,g,m,v,y,w;return b(this,(function(b){switch(b.label){case 0:if(!St)throw new Error("document detection model is not loaded");n=new Date,b.label=1;case 1:return b.trys.push([1,7,,8]),r=h.browser.fromPixels(e),t&&console.time("resize"),o=h.image.resizeBilinear(r,[320,320]),t&&console.timeEnd("resize"),r.dispose(),t&&console.time("convert to int32"),i=h.cast(o,"int32"),o.dispose(),l=(s=h).tensor4d,u=(c=Array).from,[4,i.data()];case 2:return a=l.apply(s,[u.apply(c,[b.sent()]),[1,320,320,3]]),i.dispose(),d=h.cast(a,"int32"),t&&console.timeEnd("convert to int32"),a.dispose(),t&&console.time("predictions"),[4,St.executeAsync(d)];case 3:return f=b.sent(),t&&console.timeEnd("predictions"),d.dispose(),p=f,t&&console.log("predictions made!",p.map((function(e){return e.arraySync()}))),[4,p[Oo.boxes].array()];case 4:return g=b.sent()[0],[4,p[Oo.scores].array()];case 5:return m=b.sent()[0],[4,p[Oo.labels].array()];case 6:return v=(v=b.sent()[0]).map((function(e){return Math.round(e)})),h.dispose(f),y=(new Date).getTime()-n.getTime(),[2,{boxes:g,scores:m,labels:v,time:y}];case 7:return w=b.sent(),console.error("caught error in makeDocumentDetectionPredictions",w),[2,{boxes:[],scores:[],labels:[],time:0}];case 8:return[2]}}))}))}function Vo(e,t,n){return void 0===n&&(n=!1),v(this,void 0,void 0,(function(){var r,o,i,a,s,l,c,u,d,f,p,g,m;return b(this,(function(v){switch(v.label){case 0:if(!Qt)throw new Error("focus model is not loaded");r=new Date,v.label=1;case 1:return v.trys.push([1,5,,6]),o=void 0,o=h.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 o=Lo(e),i=o[0],a=o[1],s=t[0],l=t[1],c=t[2],u=t[3];return n.width=c*i,n.height=u*a,r.drawImage(e,s*i,l*a,c*i,u*a,0,0,c*i,u*a),n}(e,t):e),i=h.image.resizeBilinear(o,[448,448]),o.dispose(),a=h.cast(i,"int32"),i.dispose(),c=(l=h).tensor4d,d=(u=Array).from,[4,a.data()];case 2:return s=c.apply(l,[d.apply(u,[v.sent()]),[1,448,448,3]]),a.dispose(),f=h.cast(s,"int32"),s.dispose(),n&&console.time("focus prediction"),[4,Qt.predict(f)];case 3:return p=v.sent(),f.dispose(),[4,p.array()];case 4:return g=v.sent()[0],n&&console.timeEnd("focus prediction"),h.dispose(p),m=(new Date).getTime()-r.getTime(),[2,[g,m]];case 5:return v.sent(),[2,[[0,0],0]];case 6:return[2]}}))}))}var Wo,Ho,Ko,Yo,Xo,Jo=d.default.canvas(Wo||(Wo=w(["\n display: none;\n"],["\n display: none;\n"]))),Zo=d.default.span(Ho||(Ho=w(["\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"]))),Qo=d.default.div(Ko||(Ko=w(["\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);":""})),ei=d.default.div(Yo||(Yo=w(["\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);":""})),ti=d.default.div(Xo||(Xo=w(["\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 ni(e){var n=e.enabled,r=void 0===n||n,o=e.pageWidth,i=e.pageHeight,a=e.videoWidth,s=e.videoHeight;return t.useMemo((function(){var e=!1,t=0,n=0,l=0,c=0;return r&&((e=o/i<a/s)?l=((t=a*(i/s))-o)/2:c=((n=s*(o/a))-i)/2),{horizontal:e,pageWidth:o,pageHeight:i,videoWidth:a,videoHeight:s,scaledWidth:t,scaledHeight:n,xOffset:l,yOffset:c}}),[r,i,o,s,a])}function ri(e){var t=e.obj,n=e.scaling,r=n.horizontal,o=n.pageWidth,i=n.pageHeight,a=n.scaledWidth,s=n.scaledHeight;return l.default.createElement(ei,{$flipX:e.flipX,style:{top:t.bbox[1]*(r?i:s-n.yOffset),left:t.bbox[0]*(r?a-n.xOffset:o),width:t.bbox[2]*(r?a:o),height:t.bbox[3]*(r?i:s)}},t.label," (",t.score.toFixed(3),")")}function oi(e){var t,n,r,o,i=e.face,a=e.flipX,s=e.color,c=e.scaling,u=c.pageWidth,d=c.pageHeight,h=c.videoWidth,f=c.videoHeight,p=c.scaledWidth,g=c.scaledHeight;return c.horizontal?(t=i.box.yMin/f*d,n=i.box.xMin/h*p-c.xOffset,r=i.box.width/h*p,o=i.box.height/f*d):(t=i.box.yMin/f*g-c.yOffset,n=i.box.xMin/h*u,r=i.box.width/h*u,o=i.box.height/f*g),l.default.createElement(l.default.Fragment,null,l.default.createElement(ei,{$flipX:a,$color:void 0===s?"green":s,style:{top:t,left:n,width:r,height:o}}),i.keypoints.map((function(e,t){return l.default.createElement(ii,{key:t,point:e,scaling:c,flipX:a})})))}function ii(e){var t,n,r=e.point,o=e.color,i=e.scaling,a=i.videoWidth,s=i.videoHeight;return i.horizontal?(t=r.x/a*i.scaledWidth-i.xOffset,n=r.y/s*i.pageHeight):(t=r.x/a*i.pageWidth,n=r.y/s*i.scaledHeight-i.yOffset),l.default.createElement(ti,{$flipX:e.flipX,$color:void 0===o?"red":o,style:{top:n-=2,left:t-=2}})}var ai,si,li,ci,ui,di=d.default.button(ai||(ai=w(["\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"]))),hi=d.default.div(si||(si=w(["\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"})),fi=function(e){var t=e.text,n=e.imageUrl;return l.default.createElement(gi,null,t&&l.default.createElement(mi,null,t),l.default.createElement(vi,null,l.default.createElement("img",{src:n,alt:""})))},pi=function(e){var t=e.imageUrl;return l.default.createElement(gi,null,l.default.createElement(mi,null,l.default.createElement(hi,{$size:24,$color:"white",$thickness:3,style:{position:"relative",top:4,left:-3,margin:"0 3px 0 -12px"}}),"Processing..."),l.default.createElement(vi,null,l.default.createElement("img",{src:t,alt:""})))},gi=d.default.div(li||(li=w(["\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"]))),mi=d.default.div(ci||(ci=w(["\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"]))),vi=d.default.div(ui||(ui=w(["\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"]))),bi={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 card front captured.":"Se ha capturado el frente de 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","Video signature has been successfully captured!":"La video firma ha sido exitosa.","Network unreachable":"No hay conexión a internet.","We're having trouble reaching our services, please check your connection and try again.":"Estamos teniendo problemas para alcanzar nuestros servicios, por favor verificar la conexión a internet e intentar de nuevo.","We're sorry, an unexpected error has occurred.":"Lo sentimos, se ha producido un error inesperado."}}},yi=function(e){var n=xe().i18n;t.useEffect((function(){"auto"!==e?n.changeLanguage(e):n.changeLanguage()}),[n,e])};function wi(e,t,n,r){if("string"==typeof n)return n;if("object"==typeof n){var o=n;if(o[t])return o[t];var i=t.split("-")[0];if(o[i])return o[i]}return e(r)}function xi(e,n){var r=xe(),o=r.t,i=r.i18n;return t.useMemo((function(){return m(m({},e),Object.keys(n).reduce((function(t,r){var a;return m(m({},t),((a={})[r]=wi(o,i.language,null==e?void 0:e[r],n[r]),a))}),{}))}),[n,i.language,o,e])}var Ei,Si,ki={videoWidth:0,videoHeight:0,captureStartedAt:null,detectedObjects:[],bestDocument:void 0,bestMrz:void 0,bestPdf417:void 0,documentType:Et.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},Ci=function(e,t){switch(t.type){case"configure":return m(m(m({},e),t.payload),{goodFramesCount:0,captureStartedAt:new Date,capturing:!1,captured:!1,captureFailed:!1});case"objectsDetected":var n=t.payload.prediction,r=n.detectedObjects,o=n.detectionScore,i=n.detectionThresholdMet,a=n.detectedDocumentType,s=n.passportDetectionScore,l=n.passportDetectionThresholdMet,c=n.mrzDetectionScore,u=n.mrzDetectionThresholdMet,d=n.pdf417DetectionScore,h=n.pdf417DetectionThresholdMet,f=n.bestDocumentOrPassport,p=n.bestMrz,g=n.bestPdf417,v=n.focusScore,b=n.focusThresholdMet,y=n.frameWidth,w=n.frameHeight,x=new Date,E=0,S=e.goodFramesThreshold;e.lastFrameCapturedAt&&(E=1e3/(x.getTime()-e.lastFrameCapturedAt.getTime()))>0&&(S=Math.ceil(3*E));var k=!1;if(f){var C=f.bbox,T=C[0],A=C[1],I=C[2],R=C[3];T*=y,I*=y,k=(A*=w)>5&&A+(R*=w)+5<w&&(T>5||T<5&&T+I>.8*y)&&T+I+5<y}var D=!0===e.autoCaptureBarcodeRequired||"mobile"===e.autoCaptureBarcodeRequired&&Ut(),_=e.barcodeScanningEnabled&&h&&D,F=_&&!e.barcodeResult,M=i&&k&&b,L=e.goodFramesCount;return M&&(L+=1),m(m({},e),{videoWidth:y,videoHeight:w,detectedObjects:r,bestDocument:f,bestMrz:p,bestPdf417:g,documentType:a,documentInBounds:k,documentDetectionScore:o,documentDetectionThresholdMet:i,mrzDetectionScore:c,mrzDetectionThresholdMet:u,pdf417DetectionScore:d,pdf417DetectionThresholdMet:h,passportPageDetectionScore:s,passportPageDetectionThresholdMet:l,focusScore:v,focusThresholdMet:b,shouldScanBarcode:_,waitingForBarcodeScan:F,isGoodFrame:M,goodFramesCount:L,goodFramesThreshold:S,goodFramesThresholdMet:L>=S,lastFrameCapturedAt:x,frameCaptureRate:E});case"barcodeScanned":return m(m({},e),{barcodeResult:t.payload.result,waitingForBarcodeScan:!1,autoCaptureBarcodeRequired:!1});case"barcodeScanFailed":var P=m(m({},e),{barcodeScanFailedAttempts:e.barcodeScanFailedAttempts+1});return P.barcodeScanFailedAttempts>=P.maxBarcodeScanAttempts&&(P.autoCaptureBarcodeRequired=!1,P.shouldScanBarcode=!1,P.waitingForBarcodeScan=!1),P;case"capturing":return m(m({},e),{capturing:!0,captured:!1,captureFailed:!1});case"captured":return m(m({},e),{capturing:!1,captured:!0,captureFailed:!1});case"captureFailed":return m(m({},e),{capturing:!1,captured:!1,captureFailed:!0});default:return e}},Ti=function(e){var n,r,o,i=e.requiredDocumentType,a=e.autoCaptureEnabled,s=void 0===a||a,c=e.autoCaptureScoreThreshold,u=void 0===c?.8:c,d=e.autoCaptureGoodFramesRequired,h=void 0===d?3:d,f=e.autoCaptureBarcodeRequired,p=void 0===f?"mobile":f,g=e.mrzDetectionScoreThreshold,m=void 0===g?.25:g,y=e.passportPageDetectionThreshold,w=void 0===y?.6:y,x=e.pdf417DetectionThreshold,E=void 0===x?.15:x,S=e.focusScoreThreshold,k=void 0===S?.3:S,C=e.barcodeScanningEnabled,T=void 0===C||C,A=e.maxBarcodeScanAttempts,I=void 0===A?10:A,R=e.onPrediction,D=e.onBarcodeScanned,_=e.onCapture,F=e.onExit,M=e.processingScreen,L=e.processingDelay,P=void 0===L?0:L,B=e.assets,O=void 0===B?{}:B,N=e.colors,U=void 0===N?{}:N,j=e.verbiage,G=void 0===j?{}:j,$=e.debugMode,z=void 0!==$&&$,q=Bt(),V=q.ref,W=q.width,H=void 0===W?1:W,K=q.height,Y=void 0===K?1:K,X=t.useReducer(Ci,ki),J=X[0],Z=X[1],Q=t.useState(""),ee=Q[0],te=Q[1],ne=t.useState(!1),re=ne[0],oe=ne[1],ie=t.useContext(tn),ae=ie.cameraRef,se=ie.cameraReady,le=ie.takePhoto,ce=ie.videoRef,ue=ie.videoLoaded,de=t.useRef(),he=t.useContext(No),fe=he.ready,pe=he.working,ge=he.setThresholds,me=he.makePrediction,ve=he.onPredictionMade,be=he.detectionTime,ye=he.focusPredictionTime,we=he.getBestFrame,xe=he.resetBestFrame;t.useEffect((function(){de.current=new Date}),[]),t.useEffect((function(){Z({type:"configure",payload:{requiredDocumentType:i,goodFramesThreshold:h,autoCaptureBarcodeRequired:p,barcodeScanningEnabled:T,maxBarcodeScanAttempts:I}}),xe(),ge({document:u,passport:w,mrz:m,pdf417:E,focus:k})}),[i,u,k,m,h,p,T,I,w,E,xe,ge]);var Ee=t.useRef(0),Se=t.useRef(!1);t.useEffect((function(){Se.current=ue&&se&&fe&&!J.capturing&&!J.captured}),[se,J.captured,J.capturing,fe,ue]);var ke=t.useState(null),Ce=ke[0],Te=ke[1];t.useEffect((function(){if(fe&&se&&ue)return Ee.current=requestAnimationFrame((function e(){return v(this,void 0,void 0,(function(){var t,n;return b(this,(function(r){switch(r.label){case 0:if(!Se.current||pe.current)return[3,5];r.label=1;case 1:return r.trys.push([1,4,,5]),J.shouldScanBarcode?[4,le()]:[3,3];case 2:if(!(t=r.sent()))return Ee.current=requestAnimationFrame(e),[2];Te(t),r.label=3;case 3:return ce.current&&me(ce.current),[3,5];case 4:return n=r.sent(),console.error("error capturing frame",n),[3,5];case 5:return Ee.current=requestAnimationFrame(e),[2]}}))}))})),function(){cancelAnimationFrame(Ee.current)}}),[se,me,fe,pe,J.shouldScanBarcode,le,ue,ce]),t.useEffect((function(){ve((function(e){Z({type:"objectsDetected",payload:{prediction:e}}),null==R||R(e)}))}),[R,ve]),t.useEffect((function(){v(void 0,void 0,void 0,(function(){var e,t;return b(this,(function(n){switch(n.label){case 0:return J.shouldScanBarcode&&Ce?[4,qt(Ce,null===(t=J.bestPdf417)||void 0===t?void 0:t.bbox)]:[3,2];case 1:(e=n.sent())?(Z({type:"barcodeScanned",payload:{result:e}}),null==D||D(e)):Z({type:"barcodeScanFailed"}),n.label=2;case 2:return[2]}}))}))}),[D,J.shouldScanBarcode,null===(n=J.bestPdf417)||void 0===n?void 0:n.bbox,le,Ce]);var Ae=s&&J.goodFramesThresholdMet&&!J.capturing&&!J.captured&&!J.waitingForBarcodeScan&&Ai(J.captureStartedAt)>=3e3;t.useEffect((function(){v(void 0,void 0,void 0,(function(){var e,t,n,r,o,i,a,s,l;return b(this,(function(c){switch(c.label){case 0:return Ae?(Z({type:"capturing"}),[4,we()]):[2];case 1:return(e=c.sent())?(oe(!0),[4,(u=e,new Promise((function(e){var t=new Image;t.onload=function(){e([t.naturalWidth,t.naturalHeight])},t.src=URL.createObjectURL(u)})))]):(console.log("uh oh, i did not get a photo"),Z({type:"captureFailed"}),[2]);case 2:return t=c.sent(),n=t[0],r=t[1],(o=document.createElement("canvas")).width=n,o.height=r,[4,createImageBitmap(e)];case 3:if(i=c.sent(),(n>1920&&r>1080||n>1080&&r>1920)&&J.barcodeResult){if(n>r?(o.width=1920,o.height=r*(1920/n)):(o.height=1920,o.width=n*(1920/r)),!(a=o.getContext("2d")))return[2];a.drawImage(i,0,0,o.width,o.height)}else{if(!(s=o.getContext("bitmaprenderer")))return[2];s.transferFromImageBitmap(i)}return l=o.toDataURL("image/jpeg",.92),te(l),setTimeout((function(){var e,t=(new Date).getTime()-(null!==(e=de.current)&&void 0!==e?e:new Date).getTime();null==_||_(l,n,r,{autoCapture:"Y",captureTime:t}),Z({type:"captured"}),oe(!1)}),P),[2]}var u}))}))}),[we,_,P,Ae,J.barcodeResult]),U.guideBoxUnsatisfiedColor||(U.guideBoxUnsatisfiedColor="white"),U.guideBoxSatisfiedColor||(U.guideBoxSatisfiedColor="green");var Ie=xi(G,{instructionText:"Scan the front of ID",processingIdCardText:"ID card front captured.",capturingText:"Capturing...",captureFailedText:"Capture failed!"}),Re=ni({enabled:z,pageWidth:H,pageHeight:Y,videoWidth:J.videoWidth,videoHeight:J.videoHeight});return re?l.default.createElement(l.default.Fragment,null,M,ee&&l.default.createElement(fi,{text:Ie.processingIdCardText,imageUrl:ee})):""!==ee?l.default.createElement("img",{src:ee,alt:"",style:{maxWidth:"100%",maxHeight:"100%"}}):l.default.createElement(ot,{ref:V,className:"flex"},l.default.createElement(jt,{width:H,height:Y,instruction:J.captureFailed?Ie.captureFailedText:J.capturing?null==Ie?void 0:Ie.capturingText:Ie.instructionText,portraitGuidesImageUrl:O.portraitGuidesImageUrl,landscapeGuidesImageUrl:O.landscapeGuidesImageUrl,isMirrored:!(null===(r=ae.current)||void 0===r?void 0:r.isRearFacing),borderColor:J.isGoodFrame?U.guideBoxSatisfiedColor:U.guideBoxUnsatisfiedColor}),z&&J.detectedObjects.length>0&&l.default.createElement(Qo,{$flipX:!(null===(o=ae.current)||void 0===o?void 0:o.isRearFacing)},J.detectedObjects.map((function(e,t){var n;return l.default.createElement(ri,{key:t,obj:e,scaling:Re,flipX:!(null===(n=ae.current)||void 0===n?void 0:n.isRearFacing)})}))),z&&l.default.createElement(Zo,null,ae.current?l.default.createElement(l.default.Fragment,null,"✅ Camera: ",ae.current.label," (",ae.current.width,"x",ae.current.height,")"):"❌ Camera not ready",l.default.createElement("br",null),J.frameCaptureRate>.75?"✅":"👎"," Frame Rate:"," ",Math.round(1e3*(J.frameCaptureRate+Number.EPSILON))/1e3," ","fps (",be,"ms doc detect, ",ye,"ms focus)",l.default.createElement("br",null),fe?l.default.createElement(l.default.Fragment,null,J.documentDetectionThresholdMet?"✅":"❌"," Document Score: ",J.documentDetectionScore," (",J.documentType,")",l.default.createElement("br",null),J.documentInBounds?"✅":"❌"," Document In Bounds",l.default.createElement("br",null),J.focusThresholdMet?"✅":"❌"," Focus Score:"," ",J.focusScore,l.default.createElement("br",null),J.goodFramesThresholdMet?"✅":"❌"," Good Frame Count:"," ",J.goodFramesCount,"/",J.goodFramesThreshold,T&&J.autoCaptureBarcodeRequired?l.default.createElement(l.default.Fragment,null,l.default.createElement("br",null),J.barcodeResult?"✅":"❌"," Barcode Scanned (",zt()?"Native":"ZXing",","," ",J.barcodeScanFailedAttempts,"/",J.maxBarcodeScanAttempts," failed attempts)"):null):l.default.createElement(l.default.Fragment,null,"❌ Models not ready")),l.default.createElement(di,{onClick:F},"×"))},Ai=function(e){return e?Math.abs((new Date).getTime()-e.getTime()):0},Ii=function(e){var n,r,o=e.assets,i=void 0===o?{}:o,a=e.colors,s=void 0===a?{}:a,c=e.verbiage,u=void 0===c?{}:c,d=t.useContext(tn).retryCameraAccess;i.imageUrl||(i.imageUrl=Mo+"/camera-disable-icon.png"),s.retryBtn||(s.retryBtn={}),(n=s.retryBtn).backgroundColor||(n.backgroundColor="#ea8557"),(r=s.retryBtn).textColor||(r.textColor="white");var h=xi(u,{headingText:"Your camera permission is disabled",descriptionText:"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.",retryBtnText:"Retry"});return l.default.createElement(ct,null,l.default.createElement("div",{style:{display:"flex",height:"100%"}},l.default.createElement(ut,{style:{maxWidth:500,height:"auto",margin:"auto"}},l.default.createElement(dt,{style:{flexGrow:0}},l.default.createElement("img",{src:i.imageUrl,alt:""})),l.default.createElement("h3",null,h.headingText),l.default.createElement("p",{style:{lineHeight:1.5,marginBottom:50}},h.descriptionText),l.default.createElement(kt,{onClick:d,colors:s.retryBtn,style:{width:200,marginLeft:"auto",marginRight:"auto"},finished:!0},h.retryBtnText))))},Ri=function(e){var n=e.onDismissed,r=e.assets,o=void 0===r?{}:r,i=e.colors,a=void 0===i?{}:i,s=e.verbiage,c=void 0===s?{}:s,u=t.useContext(No).ready,d=t.useContext(tn),h=d.cameraReady,f=d.cameraAccessDenied,p=d.iphoneContinuityCameraAvailable,g=d.setIphoneContinuityCameraAllowed,m=t.useState(!1),v=m[0],b=m[1];o.instructionImageUrl||(o.instructionImageUrl="".concat(Mo,"/WebSDK-Instruction-DL-Capture-3-Portrait.png"));var y=xi(c,{headingText:"Use your device camera to capture your ID",useContinuityCameraText:"Use your iPhone as a webcam",modelsWarmingUpText:"Models warming up...",cameraInitializingText:"Camera initializing...",continueText:"Continue"});return t.useEffect((function(){if(u&&h)return function(){return null};var e=setTimeout((function(){b(!1)}),500);return function(){clearTimeout(e)}}),[h,u]),v?l.default.createElement(l.default.Fragment,null):f?l.default.createElement(Ii,{assets:o.cameraAccessDenied,colors:a.cameraAccessDenied,verbiage:c.cameraAccessDenied}):l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",null,y.headingText),l.default.createElement(dt,{style:{pointerEvents:"none"}},l.default.createElement("img",{alt:y.headingText,src:o.instructionImageUrl})),l.default.createElement("div",{style:{paddingTop:26,height:48,marginTop:-48}},p&&l.default.createElement(l.default.Fragment,null,l.default.createElement("input",{id:"use-continuity-camera",type:"checkbox",defaultChecked:!0,style:{marginRight:8},onChange:function(e){g(e.target.checked)}}),l.default.createElement("label",{htmlFor:"use-continuity-camera"},y.useContinuityCameraText))),l.default.createElement(kt,{disabled:!h||!u,finished:u&&h,colors:a.continueBtn,style:{marginTop:8},onClick:function(){b(!0),null==n||n()}},h&&u?y.continueText:u?y.cameraInitializingText:y.modelsWarmingUpText)))},Di=function(e){var n,r=e.assets,o=void 0===r?{}:r,i=e.verbiage,a=void 0===i?{}:i,s=Bt(),c=s.ref,u=s.width,d=void 0===u?1:u,h=s.height,f=void 0===h?1:h,p=t.useContext(tn).cameraRef;o.frontPortraitGuidesImageUrl||(o.frontPortraitGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Front-SVG-Portrait-2.svg")),o.frontLandscapeGuidesImageUrl||(o.frontLandscapeGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Front-SVG-Landscape-2.svg")),o.backPortraitGuidesImageUrl||(o.backPortraitGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Back-SVG-Portrait-2.svg")),o.backLandscapeGuidesImageUrl||(o.backLandscapeGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Back-SVG-Landscape-2.svg"));var g=function(e,n){var r=xe(),o=r.t,i=r.i18n;return t.useMemo((function(){return wi(o,i.language,e,n)}),[n,i.language,o,e])}(a.instructionText,"Please flip your ID card..."),v=Ut()?0:50,b=!(null===(n=p.current)||void 0===n?void 0:n.isRearFacing),y=t.useContext(Ot),w=y.orientation,x=y.wrapperRef,E=y.wrapperWidth,S=y.wrapperHeight,k=y.imageAspectRatio,C=y.wrapperAspectRatio,T=y.onImageLoaded,A=y.setDimensions;t.useEffect((function(){A({width:d,height:f})}),[f,A,d]);var I={height:S-2*v-8};k>=C&&(I={width:E-2*v-8});var R=t.useState(1),D=R[0],_=R[1],F=t.useState(0),M=F[0],L=F[1],P=["rotateY(".concat(M,"deg)")];b&&P.push("scaleX(-1)");var B=["rotateY(".concat(180-M,"deg)")];return b&&B.push("scaleX(-1)"),t.useEffect((function(){var e=function(){_(1),L(180),setTimeout((function(){_(0),L(0)}),1500)};setTimeout(e,250);var t=setInterval(e,2500);return function(){clearInterval(t)}}),[]),l.default.createElement(ot,{ref:c,className:"flex"},l.default.createElement("div",{ref:x,style:{position:"absolute",zIndex:1e3,width:"100%",height:"100%"}},l.default.createElement("div",{style:{display:"flex",flexFlow:"column nowrap",height:"100%"}},l.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"}},l.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12}},g)),l.default.createElement("div",{style:{position:"relative",display:"flex",flexFlow:"row nowrap",alignItems:"center",justifyItems:"center",maxWidth:"calc(100%)",maxHeight:"calc(100% - ".concat(2*v,"px - ").concat(8,"px)")}},l.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:v,flexGrow:1}}),l.default.createElement("div",{style:{maxWidth:"calc(100% - ".concat(2*v,"px - ").concat(8,"px)"),maxHeight:f-2*v-8}},l.default.createElement("div",{style:{position:"relative",border:"".concat(4,"px solid ").concat("white")}},l.default.createElement("img",{src:"portrait"===w?o.frontPortraitGuidesImageUrl:o.frontLandscapeGuidesImageUrl,alt:"",onLoad:T,style:m({backfaceVisibility:"hidden",transition:"transform ".concat(D,"s"),transform:P.join(" "),transformStyle:"preserve-3d",position:"relative",top:0,left:0,display:"block"},I)}),l.default.createElement("img",{src:"portrait"===w?o.backPortraitGuidesImageUrl:o.backLandscapeGuidesImageUrl,alt:"",style:m({backfaceVisibility:"hidden",transition:"transform ".concat(D,"s"),transform:B.join(" "),transformStyle:"preserve-3d",position:"absolute",top:0,left:0,display:"block"},I)}))),l.default.createElement("div",{style:{background:"rgba(0,0,0,0.5)",width:"100%",height:"100%",minWidth:v,flexGrow:1}})),l.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"}},l.default.createElement("span",{style:{alignContent:"center",marginTop:12,marginBottom:12,opacity:0}},g)))))},_i=function(e){var n,r,o=e.capturedDocuments,i=e.onSubmitClick,a=e.onRetryClick,s=e.colors,c=void 0===s?{}:s,u=e.verbiage,d=void 0===u?{}:u,h=t.useContext(Ye).submissionStatus,f=o.ID_CARD_FRONT,p=o.ID_CARD_BACK,g=o.PASSPORT;c.retryBtn||(c.retryBtn={}),(n=c.retryBtn).backgroundColor||(n.backgroundColor="#ea8557"),(r=c.retryBtn).textColor||(r.textColor="white");var m=xi(d,{headingText:"ID Capture Successful",idCardFrontText:"ID Card Front",idCardBackText:"ID Card Back",passportText:"Passport",instructionText:"Verify the entire ID was captured clearly with no glare.",retryText:"Retry",submittingText:"Submitting...",submitText:"Done"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h1",null,m.headingText),l.default.createElement(dt,null,l.default.createElement(ht,{style:{paddingBottom:40}},f&&l.default.createElement("div",null,l.default.createElement("h3",null,m.idCardFrontText),l.default.createElement("img",{src:f.imageData,alt:m.idCardFrontText,width:f.width,height:f.height})),p&&l.default.createElement("div",null,l.default.createElement("h3",null,m.idCardBackText),l.default.createElement("img",{src:p.imageData,alt:m.idCardBackText,width:p.width,height:p.height})),g&&l.default.createElement("div",null,l.default.createElement("h3",null,m.passportText),l.default.createElement("img",{src:g.imageData,alt:m.passportText,width:g.width,height:g.height})))),l.default.createElement("p",{style:{fontSize:18}},m.instructionText),l.default.createElement("div",{style:{paddingTop:15,textAlign:"center"}},l.default.createElement(kt,{onClick:a,colors:c.retryBtn,style:{marginRight:15},finished:!0},m.retryText),l.default.createElement(kt,{onClick:i,disabled:h===Ve.SUBMITTING,colors:c.doneBtn,finished:!0},h===Ve.SUBMITTING?m.submittingText:m.submitText))))},Fi=function(){var e,n=t.useContext(tn),r=n.videoRef,o=n.setVideoLoaded,i=n.cameraRef;t.useEffect((function(){o(!1)}),[o]),t.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 a=t.useCallback((function(){o(!0)}),[o]);return l.default.createElement(Mi,{autoPlay:!0,playsInline:!0,muted:!0,ref:r,onLoadedData:a,$isRearFacing:null===(e=i.current)||void 0===e?void 0:e.isRearFacing})},Mi=d.default.video(Ei||(Ei=w(["\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 Li(e,n,r){var o=this,i=t.useState(!1),a=i[0],s=i[1];return t.useEffect((function(){n&&e&&("function"==typeof e?v(o,void 0,void 0,(function(){return b(this,(function(t){switch(t.label){case 0:return[4,e()];case 1:return t.sent()?null==r||r():s(!0),[2]}}))})):null==r||r())}),[n,r,e]),!e||a}!function(e){e.CAPTURING="CAPTURING",e.COMPLETE="COMPLETE"}(Si||(Si={}));var Pi={captureState:Si.CAPTURING,capturedDocuments:{},requestedDocumentType:Et.ID_CARD_FRONT,currentDocumentType:Et.NONE,differentDocumentTypeDetections:0,barcodeResult:null},Bi=function(e,t){var n;switch(t.type){case"predictionMade":var r=t.payload.prediction;return(o=m(m({},e),{currentDocumentType:r.detectedDocumentType})).currentDocumentType===e.requestedDocumentType&&(o.differentDocumentTypeDetections=0),"PASSPORT"===r.detectedDocumentType&&"PASSPORT"!==e.requestedDocumentType&&(o.requestedDocumentType=Et.PASSPORT),"PASSPORT"===e.requestedDocumentType&&r.passportDetectionScore<.3&&(o.requestedDocumentType=Et.ID_CARD_FRONT),o;case"barcodeScanned":return m(m({},e),{barcodeResult:t.payload.result});case"imageCaptured":var o=m(m({},e),{capturedDocuments:m(m({},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?o.captureState=Si.COMPLETE:o.requestedDocumentType=Et.ID_CARD_FRONT:o.requestedDocumentType=Et.ID_CARD_BACK,o;case"reset":return m({},Pi)}},Oi=function(e){var n,r,o,i,a,s,c,u,d,h,f=e.onSuccess,p=e.autoCaptureEnabled,g=void 0===p||p,m=e.autoCaptureGoodFramesRequired,y=void 0===m?3:m,w=e.autoCaptureBarcodeRequired,x=void 0===w?"mobile":w,E=e.barcodeScanningEnabled,S=void 0!==E&&E,k=e.idCardAutoCaptureScoreThreshold,C=void 0===k?.8:k,T=e.passportAutoCaptureScoreThreshold,A=void 0===T?.75:T,I=e.mrzDetectionScoreThreshold,R=void 0===I?.25:I,D=e.idCardFocusScoreThreshold,_=void 0===D?.3:D,F=e.passportFocusScoreThreshold,M=void 0===F?.3:F,L=e.skipSuccessScreen,P=void 0!==L&&L,B=e.assets,O=void 0===B?{}:B,N=e.colors,U=void 0===N?{}:N,j=e.verbiage,G=void 0===j?{}:j,$=e.debugMode,z=void 0!==$&&$,q=t.useReducer(Bi,Pi),V=q[0],W=q[1],H=t.useContext(tn).releaseCameraAccess,K=t.useState(!1),Y=K[0],X=K[1],J=t.useContext(Ye),Z=J.submissionStatus,Q=J.submissionResponse,ee=J.setIdFrontImage,te=J.setIdBackImage,ne=J.setPassportImage,re=J.logIdFrontCaptureAttempt,oe=J.logIdBackCaptureAttempt,ie=t.useRef();t.useEffect((function(){ie.current=new Date}),[V.capturedDocuments.length]);var ae=t.useCallback((function(e){var t;e.operationTime=(new Date).getTime()-(null!==(t=ie.current)&&void 0!==t?t:new Date).getTime(),"ID_CARD_BACK"===V.requestedDocumentType?oe(e):re(e)}),[oe,re,V.requestedDocumentType]),se=t.useCallback((function(e){W({type:"predictionMade",payload:{prediction:e}})}),[]),le=t.useCallback((function(e){W({type:"barcodeScanned",payload:{result:e}})}),[]),ce=t.useCallback((function(e,t,n,r){ae(r),W({type:"imageCaptured",payload:{imageData:e,width:t,height:n}})}),[ae]),ue=t.useCallback((function(){return v(void 0,void 0,void 0,(function(){var e,t,n,r,o,i,a,s,l;return b(this,(function(c){switch(c.label){case 0:return t=V.capturedDocuments.ID_CARD_BACK,n=V.capturedDocuments.PASSPORT,(o=e=V.capturedDocuments.ID_CARD_FRONT)?[4,Qe(e.imageData)]:[3,2];case 1:o=c.sent(),c.label=2;case 2:return r=o,(a=t)?[4,Qe(t.imageData)]:[3,4];case 3:a=c.sent(),c.label=4;case 4:return i=a,(l=n)?[4,Qe(n.imageData)]:[3,6];case 5:l=c.sent(),c.label=6;case 6:return s=l,ee(r),te(i),ne(s),H(),setTimeout((function(){null==f||f({idFrontImage:r,idBackImage:i,passportImage:s})}),0),[2]}}))}))}),[f,H,te,ee,ne,V.capturedDocuments]),de=Li(P,V.captureState===Si.COMPLETE,ue),he=t.useCallback((function(){W({type:"reset"})}),[]),fe=t.useState(0),pe=fe[0],ge=fe[1],me=t.useCallback((function(){X(!1),ge((function(e){return e+1})),W({type:"reset"})}),[]);t.useEffect((function(){Z!==Ve.READY&&H()}),[H,Z]),O.idCardFront||(O.idCardFront={}),(n=O.idCardFront).portraitGuidesImageUrl||(n.portraitGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Front-SVG-Portrait-2.svg")),(r=O.idCardFront).landscapeGuidesImageUrl||(r.landscapeGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Front-SVG-Landscape-2.svg")),O.idCardBack||(O.idCardBack={}),(o=O.idCardBack).portraitGuidesImageUrl||(o.portraitGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Back-SVG-Portrait-2.svg")),(i=O.idCardBack).landscapeGuidesImageUrl||(i.landscapeGuidesImageUrl="".concat(Mo,"/Shieldout-IDCard-Back-SVG-Landscape-2.svg")),O.passport||(O.passport={}),(a=O.passport).portraitGuidesImageUrl||(a.portraitGuidesImageUrl="".concat(Mo,"/Shieldout-Passport-Front-SVG-Portrait-2.svg")),(s=O.passport).landscapeGuidesImageUrl||(s.landscapeGuidesImageUrl="".concat(Mo,"/Shieldout-Passport-Front-SVG-Landscape-2.svg")),O.flipIdPrompt||(O.flipIdPrompt={}),(c=O.flipIdPrompt).frontPortraitGuidesImageUrl||(c.frontPortraitGuidesImageUrl=O.idCardFront.portraitGuidesImageUrl),(u=O.flipIdPrompt).frontLandscapeGuidesImageUrl||(u.frontLandscapeGuidesImageUrl=O.idCardFront.landscapeGuidesImageUrl),(d=O.flipIdPrompt).backPortraitGuidesImageUrl||(d.backPortraitGuidesImageUrl=O.idCardBack.portraitGuidesImageUrl),(h=O.flipIdPrompt).backLandscapeGuidesImageUrl||(h.backLandscapeGuidesImageUrl=O.idCardBack.landscapeGuidesImageUrl);var ve=xi(G.idCardFront,{instructionText:"Scan the front of ID",processingIdCardText:"ID card front captured."}),be=xi(G.idCardBack,{instructionText:"Scan the back of ID"}),ye=xi(G.idCardBack,{instructionText:"Scan the ID page of passport"});return Q?l.default.createElement(ot,{className:"padded"},l.default.createElement("h1",null,"Submission completed!"),l.default.createElement("pre",null,JSON.stringify(Q,null,2))):l.default.createElement(ot,{className:"flex"},V.captureState!==Si.COMPLETE&&l.default.createElement(Fi,null),Y&&function(){var e=Object.keys(V.capturedDocuments).length;switch(V.requestedDocumentType){case Et.ID_CARD_FRONT:return l.default.createElement(Ti,{key:"capture".concat(e),requiredDocumentType:V.requestedDocumentType,autoCaptureEnabled:g,autoCaptureScoreThreshold:C,autoCaptureGoodFramesRequired:y,autoCaptureBarcodeRequired:x,barcodeScanningEnabled:!1,mrzDetectionScoreThreshold:R,focusScoreThreshold:_,onPrediction:se,onCapture:ce,onExit:me,processingDelay:3500,assets:O.idCardFront,colors:U,verbiage:ve,debugMode:z,processingScreen:l.default.createElement(Di,{assets:O.flipIdPrompt,verbiage:G.flipIdPrompt})});case Et.ID_CARD_BACK:return l.default.createElement(Ti,{key:"capture".concat(e),requiredDocumentType:V.requestedDocumentType,autoCaptureEnabled:g,autoCaptureScoreThreshold:C,autoCaptureGoodFramesRequired:y,autoCaptureBarcodeRequired:x,barcodeScanningEnabled:S,mrzDetectionScoreThreshold:R,focusScoreThreshold:_,onPrediction:se,onBarcodeScanned:le,onCapture:ce,onExit:me,assets:O.idCardBack,colors:U,verbiage:be,debugMode:z});case Et.PASSPORT:return l.default.createElement(Ti,{key:"capture".concat(e),requiredDocumentType:V.requestedDocumentType,autoCaptureEnabled:g,autoCaptureScoreThreshold:A,mrzDetectionScoreThreshold:R,autoCaptureGoodFramesRequired:y,autoCaptureBarcodeRequired:x,barcodeScanningEnabled:!1,focusScoreThreshold:M,onPrediction:se,onBarcodeScanned:le,onCapture:ce,onExit:me,assets:O.passport,colors:U,verbiage:ye,debugMode:z});default:return null}}(),!Y&&l.default.createElement(Ri,{key:pe,assets:O.loadingOverlay,colors:U.loadingOverlay,verbiage:G.loadingOverlay,onDismissed:function(){X(!0)}}),V.captureState===Si.COMPLETE&&de&&l.default.createElement(_i,{capturedDocuments:V.capturedDocuments,barcodeResult:V.barcodeResult,onSubmitClick:ue,onRetryClick:he,colors:U.success,verbiage:G.success}))},Ni=function(e){var t=e.borderWidth,n=e.borderColor;return l.default.createElement("div",{style:{position:"absolute",zIndex:1e3,width:"100%",height:"100%",display:"flex"}},l.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"}}))},Ui=self;function ji(){throw Error("Invalid UTF8")}function Gi(e,t){return t=String.fromCharCode.apply(null,t),null==e?t:e+t}let $i,zi;const qi="undefined"!=typeof TextDecoder;let Vi;const Wi="undefined"!=typeof TextEncoder;function Hi(e){if(Wi)e=(Vi||=new TextEncoder).encode(e);else{let n=0;const r=new Uint8Array(3*e.length);for(let o=0;o<e.length;o++){var t=e.charCodeAt(o);if(128>t)r[n++]=t;else{if(2048>t)r[n++]=t>>6|192;else{if(55296<=t&&57343>=t){if(56319>=t&&o<e.length){const i=e.charCodeAt(++o);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}o--}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 Ki,Yi;e:{for(var Xi=["CLOSURE_FLAGS"],Ji=Ui,Zi=0;Zi<Xi.length;Zi++)if(null==(Ji=Ji[Xi[Zi]])){Yi=null;break e}Yi=Ji}var Qi,ea=Yi&&Yi[610401301];Ki=null!=ea&&ea;const ta=Ui.navigator;function na(e){return!!Ki&&!!Qi&&Qi.brands.some((({brand:t})=>t&&-1!=t.indexOf(e)))}function ra(e){var t;return(t=Ui.navigator)&&(t=t.userAgent)||(t=""),-1!=t.indexOf(e)}function oa(){return!!Ki&&!!Qi&&0<Qi.brands.length}function ia(){return oa()?na("Chromium"):(ra("Chrome")||ra("CriOS"))&&!(!oa()&&ra("Edge"))||ra("Silk")}Qi=ta&&ta.userAgentData||null;var aa=!oa()&&(ra("Trident")||ra("MSIE"));!ra("Android")||ia(),ia(),ra("Safari")&&(ia()||!oa()&&ra("Coast")||!oa()&&ra("Opera")||!oa()&&ra("Edge")||(oa()?na("Microsoft Edge"):ra("Edg/"))||oa()&&na("Opera"));var sa={},la=null;function ca(){if(!la){la={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=e.concat(t[n].split(""));sa[n]=r;for(var o=0;o<r.length;o++){var i=r[o];void 0===la[i]&&(la[i]=o)}}}}var ua="undefined"!=typeof Uint8Array,da=!aa&&"function"==typeof btoa;function ha(e){if(!da){var t;void 0===t&&(t=0),ca(),t=sa[t];var n=Array(Math.floor(e.length/3)),r=t[64]||"";let l=0,c=0;for(;l<e.length-2;l+=3){var o=e[l],i=e[l+1],a=e[l+2],s=t[o>>2];n[c++]=s+(o=t[(3&o)<<4|i>>4])+(i=t[(15&i)<<2|a>>6])+(a=t[63&a])}switch(s=0,a=r,e.length-l){case 2:a=t[(15&(s=e[l+1]))<<2]||r;case 1:n[c]=t[(e=e[l])>>2]+t[(3&e)<<4|s>>4]+a+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 fa=/[-_.]/g,pa={"-":"+",_:"/",".":"="};function ga(e){return pa[e]||""}function ma(e){if(!da)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),o=0;return function(e,t){function n(t){for(;r<e.length;){var n=e.charAt(r++),o=la[n];if(null!=o)return o;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return t}ca();for(var r=0;;){var o=n(-1),i=n(0),a=n(64),s=n(64);if(64===s&&-1===o)break;t(o<<2|i>>4),64!=a&&(t(i<<4&240|a>>2),64!=s&&t(a<<6&192|s))}}(e,(function(e){r[o++]=e})),o!==n?r.subarray(0,o):r}(e);fa.test(e)&&(e=e.replace(fa,ga)),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 va(e){return ua&&null!=e&&e instanceof Uint8Array}let ba;function ya(){return ba||=new Uint8Array(0)}var wa={};let xa;function Ea(e){if(e!==wa)throw Error("illegal external caller")}function Sa(){return xa||=new Ca(null,wa)}function ka(e){Ea(wa);var t=e.N;return null==(t=null==t||va(t)?t:"string"==typeof t?ma(t):null)?t:e.N=t}var Ca=class{constructor(e,t){if(Ea(t),this.N=e,null!=e&&0===e.length)throw Error("ByteString should be constructed with non-empty values")}ha(){const e=ka(this);return e?new Uint8Array(e):ya()}};function Ta(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function Aa(){return Error("Failed to read varint, encoding is invalid.")}function Ia(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function Ra(e){return 0==e.length?Sa():new Ca(e,wa)}function Da(e){if("string"==typeof e)return{buffer:ma(e),H:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),H:!1};if(e.constructor===Uint8Array)return{buffer:e,H:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),H:!1};if(e.constructor===Ca)return{buffer:ka(e)||ya(),H:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),H:!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 _a="function"==typeof Uint8Array.prototype.slice;let Fa,Ma=0,La=0;function Pa(e){const t=0>e;let n=(e=Math.abs(e))>>>0;if(e=Math.floor((e-n)/4294967296),t){const[t,r]=ja(n,e);e=r,n=t}Ma=n>>>0,La=e>>>0}function Ba(e){const t=Fa||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),La=0,Ma=t.getUint32(0,!0)}function Oa(e,t){return 4294967296*t+(e>>>0)}function Na(e,t){const n=2147483648&t;return n&&(t=~t>>>0,0==(e=1+~e>>>0)&&(t=t+1>>>0)),e=Oa(e,t),n?-e:e}function Ua(e){if(16>e.length)Pa(Number(e));else if("function"==typeof BigInt)e=BigInt(e),Ma=Number(e&BigInt(4294967295))>>>0,La=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+("-"===e[0]);La=Ma=0;const n=e.length;for(let r=t,o=(n-t)%6+t;o<=n;r=o,o+=6){const t=Number(e.slice(r,o));La*=1e6,Ma=1e6*Ma+t,4294967296<=Ma&&(La+=Math.trunc(Ma/4294967296),La>>>=0,Ma>>>=0)}if(t){const[e,t]=ja(Ma,La);Ma=e,La=t}}}function ja(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function Ga(e,t,{R:n=!1}={}){e.R=n,t&&(t=Da(t),e.h=t.buffer,e.s=t.H,e.v=0,e.l=e.h.length,e.g=e.v)}function $a(e,t){if(e.g=t,t>e.l)throw Ia(e.l,t)}function za(e,t){let n,r=0,o=0,i=0;const a=e.h;let s=e.g;do{n=a[s++],r|=(127&n)<<i,i+=7}while(32>i&&128&n);for(32<i&&(o|=(127&n)>>4),i=3;32>i&&128&n;i+=7)n=a[s++],o|=(127&n)<<i;if($a(e,s),128>n)return t(r>>>0,o>>>0);throw Aa()}function qa(e){let t=0,n=e.g;const r=n+10,o=e.h;for(;n<r;){const r=o[n++];if(t|=r,0==(128&r))return $a(e,n),!!(127&t)}throw Aa()}function Va(e){var t=e.h;const n=e.g,r=t[n],o=t[n+1],i=t[n+2];return t=t[n+3],$a(e,e.g+4),(r<<0|o<<8|i<<16|t<<24)>>>0}function Wa(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 Ia(t,e.l-n);return e.g=r,n}function Ha(e,t){if(0==t)return Sa();var n=Wa(e,t);return e.R&&e.s?n=e.h.subarray(n,n+t):(e=e.h,n=n===(t=n+t)?ya():_a?e.slice(n,t):new Uint8Array(e.subarray(n,t))),Ra(n)}var Ka=class{constructor(e,t){this.h=null,this.s=!1,this.g=this.l=this.v=0,Ga(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 Aa();return $a(this,t),r}j(){return this.m()>>>0}A(){var e=Va(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()}},Ya=[];function Xa(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 Ta(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 Ja(e){switch(e.h){case 0:0!=e.h?Ja(e):qa(e.g);break;case 1:$a(e=e.g,e.g+8);break;case 2:if(2!=e.h)Ja(e);else{var t=e.g.j();$a(e=e.g,e.g+t)}break;case 5:$a(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!Xa(e))throw Error("Unmatched start-group tag: stream EOF");if(4==e.h){if(e.m!=t)throw Error("Unmatched end-group tag");break}Ja(e)}break;default:throw Ta(e.h,e.l)}}function Za(e,t,n){const r=e.g.l,o=e.g.j(),i=e.g.g+o;let a=i-r;if(0>=a&&(e.g.l=i,n(t,e,void 0,void 0,void 0),a=i-e.g.g),a)throw Error(`Message parsing ended unexpectedly. Expected to read ${o} bytes, instead read ${o-a} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=i,e.g.l=r,t}function Qa(e){var t=e.g.j(),n=Wa(e=e.g,t);if(e=e.h,qi){var r,o=e;(r=zi)||(r=zi=new TextDecoder("utf-8",{fatal:!0})),e=n+t,o=0===n&&e===o.length?o:o.subarray(n,e);try{var i=r.decode(o)}catch(e){if(void 0===$i){try{r.decode(new Uint8Array([128]))}catch(e){}try{r.decode(new Uint8Array([97])),$i=!0}catch(e){$i=!1}}throw!$i&&(zi=void 0),e}}else{t=(i=n)+t,n=[];let s,l=null;for(;i<t;){var a=e[i++];128>a?n.push(a):224>a?i>=t?ji():(s=e[i++],194>a||128!=(192&s)?(i--,ji()):n.push((31&a)<<6|63&s)):240>a?i>=t-1?ji():(s=e[i++],128!=(192&s)||224===a&&160>s||237===a&&160<=s||128!=(192&(o=e[i++]))?(i--,ji()):n.push((15&a)<<12|(63&s)<<6|63&o)):244>=a?i>=t-2?ji():(s=e[i++],128!=(192&s)||0!=s-144+(a<<28)>>30||128!=(192&(o=e[i++]))||128!=(192&(r=e[i++]))?(i--,ji()):(a=(7&a)<<18|(63&s)<<12|(63&o)<<6|63&r,n.push(55296+((a-=65536)>>10&1023),56320+(1023&a)))):ji(),8192<=n.length&&(l=Gi(l,n),n.length=0)}i=Gi(l,n)}return i}function es(e){const t=e.g.j();return Ha(e.g,t)}function ts(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 ns=[];function rs(e){return e?/^\d+$/.test(e)?(Ua(e),new os(Ma,La)):null:is||=new os(0,0)}var os=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let is;function as(e){return e?/^-?\d+$/.test(e)?(Ua(e),new ss(Ma,La)):null:ls||=new ss(0,0)}var ss=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let ls;function cs(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 us(e,t){for(;127<t;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function ds(e,t){if(0<=t)us(e,t);else{for(let n=0;9>n;n++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function hs(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 fs(e,t){0!==t.length&&(e.l.push(t),e.h+=t.length)}function ps(e,t,n){us(e.g,8*t+n)}function gs(e,t){return ps(e,t,2),t=e.g.end(),fs(e,t),t.push(e.h),t}function ms(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 vs(e,t,n){ps(e,t,2),us(e.g,n.length),fs(e,e.g.end()),fs(e,n)}function bs(e,t,n,r){null!=n&&(t=gs(e,t),r(n,e),ms(e,t))}class ys{constructor(e,t,n){this.g=e,this.h=t,this.l=n}}function ws(e){return Array.prototype.slice.call(e)}const xs="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():void 0;var Es=xs?(e,t)=>{e[xs]|=t}:(e,t)=>{void 0!==e.D?e.D|=t:Object.defineProperties(e,{D:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function Ss(e){const t=Cs(e);1!=(1&t)&&(Object.isFrozen(e)&&(e=ws(e)),As(e,1|t))}var ks=xs?(e,t)=>{e[xs]&=~t}:(e,t)=>{void 0!==e.D&&(e.D&=~t)},Cs=xs?e=>0|e[xs]:e=>0|e.D,Ts=xs?e=>e[xs]:e=>e.D,As=xs?(e,t)=>{e[xs]=t}:(e,t)=>{void 0!==e.D?e.D=t:Object.defineProperties(e,{D:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function Is(){var e=[];return Es(e,1),e}function Rs(e){return Es(e,34),e}function Ds(e,t){As(t,-255&(0|e))}function _s(e,t){As(t,-221&(34|e))}function Fs(e){return 0==(e=e>>11&1023)?536870912:e}var Ms,Ls={};function Ps(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&e.constructor===Object}function Bs(e,t,n){if(null!=e)if("string"==typeof e)e=e?new Ca(e,wa):Sa();else if(e.constructor!==Ca)if(va(e))e=n?Ra(e):e.length?new Ca(new Uint8Array(e),wa):Sa();else{if(!t)throw Error();e=void 0}return e}const Os=[];function Ns(e){if(2&e)throw Error()}As(Os,55),Ms=Object.freeze(Os);class Us{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 Us(this.g,this.h,this.m)}}var js={};let Gs,$s;function zs(e,t){(t=Gs?t[Gs]:void 0)&&(e[Gs]=ws(t))}function qs(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function Vs(e){return null==e?e:"number"==typeof e||"NaN"===e||"Infinity"===e||"-Infinity"===e?Number(e):void 0}function Ws(e){return null==e?e:"boolean"==typeof e||"number"==typeof e?!!e:void 0}function Hs(e){return"number"==typeof e&&Number.isFinite(e)||!!e&&"string"==typeof e&&isFinite(e)}function Ks(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function Ys(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function Xs(e){if("string"!=typeof e)throw Error();return e}function Js(e){if(null!=e&&"string"!=typeof e)throw Error();return e}function Zs(e){return null==e||"string"==typeof e?e:void 0}function Qs(e,t,n,r){var o=!1;return null==e||"object"!=typeof e||(o=Array.isArray(e))||e.M!==Ls?o?(0===(o=n=Cs(e))&&(o|=32&r),(o|=2&r)!==n&&As(e,o),new t(e)):(n?2&r?(e=t[el])?t=e:(Rs((e=new t).u),t=t[el]=e):t=new t:t=void 0,t):e}const el="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():"di";function tl(e){return e}function nl(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 rl,ol,il;function al(e){switch(typeof e){case"boolean":return ol||=[0,void 0,!0];case"number":return 0<e?void 0:0===e?il||=[0,void 0]:[-e,void 0];case"string":return[0,e];case"object":return e}}function sl(e,t){return ll(e,t[0],t[1])}function ll(e,t,n){if(null==e&&(e=rl),rl=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=Cs(e)))return $s&&delete e[$s],e;if(r|=64,n&&(r|=512,n!==e[0]))throw Error();e:{var o=(n=e).length;if(o){const e=o-1;var i=n[e];if(Ps(i)){1024<=(o=e-(t=+!!(512&(r|=256))-1))&&(cl(n,t,i),o=1023),r=-2095105&r|(1023&o)<<11;break e}}t&&(i=+!!(512&r)-1,1024<(t=Math.max(t,o-i))&&(cl(n,i,{}),r|=256,t=1023),r=-2095105&r|(1023&t)<<11)}}return As(e,r),e}function cl(e,t,n){const r=1023+t,o=e.length;for(let i=r;i<o;i++){const r=e[i];null!=r&&r!==n&&(n[i-t]=r)}e.length=r+1,e[r]=n}function ul(e){if(2&e.g)throw Error("Cannot mutate an immutable Map")}var dl=class extends Map{constructor(e,t,n=tl,r=tl){super();let o=Cs(e);o|=64,As(e,o),this.g=o,this.l=t,this.h=n||tl,this.j=this.l?hl:r||tl;for(let i=0;i<e.length;i++){const a=e[i],s=n(a[0],!1,!0);let l=a[1];t?void 0===l&&(l=null):l=r(a[1],!1,!0,void 0,void 0,o),super.set(s,l)}}s(e=fl){return this.m(e)}m(e=fl){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(){ul(this),super.clear()}delete(e){return ul(this),super.delete(this.h(e,!0,!1))}entries(){var e=this.A();return new Us(e,pl,this)}keys(){return this.C()}values(){var e=this.A();return new Us(e,dl.prototype.get,this)}forEach(e,t){super.forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))}set(e,t){return ul(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))}I(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 hl(e,t,n,r,o,i){return e=Qs(e,r,n,i),o&&(e=El(e)),e}function fl(e){return e}function pl(e){return[e,this.get(e)]}function gl(e,t,n,r,o,i){if(null!=e){if(Array.isArray(e))e=o&&0==e.length&&1&Cs(e)?void 0:i&&2&Cs(e)?e:ml(e,t,n,void 0!==r,o,i);else if(Ps(e)){const a={};for(let s in e)a[s]=gl(e[s],t,n,r,o,i);e=a}else e=t(e,r);return e}}function ml(e,t,n,r,o,i){const a=r||n?Cs(e):0;r=r?!!(32&a):void 0;const s=ws(e);for(let e=0;e<s.length;e++)s[e]=gl(s[e],t,n,r,o,i);return n&&(zs(s,e),n(a,s)),s}function vl(e){return gl(e,bl,void 0,void 0,!1,!1)}function bl(e){return e.M===Ls?e.toJSON():e instanceof dl?e.s(vl):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(va(e))return ha(e);if(e instanceof Ca){const t=e.N;return null==t?"":"string"==typeof t?t:e.N=ha(t)}if(e instanceof dl)return e.s()}}return e}(e)}function yl(e,t,n=_s){if(null!=e){if(ua&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var r=Cs(e);return 2&r?e:(t&&=0===r||!!(32&r)&&!(64&r||!(16&r)),t?(As(e,34|r),4&r&&Object.freeze(e),e):ml(e,yl,4&r?_s:n,!0,!1,!0))}return e.M===Ls?e=2&(r=Ts(n=e.u))?e:wl(e,n,r,!0):e instanceof dl&&(n=Rs(e.m(yl)),e=new dl(n,e.l,e.h,e.j)),e}}function wl(e,t,n,r){return e=e.constructor,rl=t=xl(t,n,r),t=new e(t),rl=void 0,t}function xl(e,t,n){const r=n||2&t?_s:Ds,o=!!(32&t);return e=function(e,t,n){const r=ws(e);var o=r.length;const i=256&t?r[o-1]:void 0;for(o+=i?-1:0,t=512&t?1:0;t<o;t++)r[t]=n(r[t]);if(i){t=r[t]={};for(const e in i)t[e]=n(i[e])}return zs(r,e),r}(e,t,(e=>yl(e,o,r))),Es(e,32|(n?2:0)),e}function El(e){const t=e.u,n=Ts(t);return 2&n?wl(e,t,n,!1):e}function Sl(e,t){return kl(e=e.u,Ts(e),t)}function kl(e,t,n,r){if(-1===n)return null;if(n>=Fs(t)){if(256&t)return e[e.length-1][n]}else{var o=e.length;if(r&&256&t&&null!=(r=e[o-1][n]))return r;if((t=n+(+!!(512&t)-1))<o)return e[t]}}function Cl(e,t,n,r){const o=e.u,i=Ts(o);return Ns(i),Tl(o,i,t,n,r),e}function Tl(e,t,n,r,o){var i=Fs(t);if(n>=i||o){if(o=t,256&t)i=e[e.length-1];else{if(null==r)return;i=e[i+(+!!(512&t)-1)]={},o|=256}i[n]=r,o!==t&&As(e,o)}else e[n+(+!!(512&t)-1)]=r,256&t&&n in(e=e[e.length-1])&&delete e[n]}function Al(e,t,n,r,o){var i=2&t;let a=kl(e,t,n,o);Array.isArray(a)||(a=Ms);const s=!(2&r),l=!(1&r);r=!!(32&t);let c=Cs(a);return 0!==c||!r||i||s?1&c||(c|=1,As(a,c)):(c|=33,As(a,c)),i?(2&c||Rs(a),l&&Object.freeze(a)):(i=2&c,l&&i?(a=ws(a),i=1,r&&!s&&(i|=32),As(a,i),Tl(e,t,n,a,o)):s&&32&c&&!i&&ks(a,32)),a}function Il(e,t){const n=Ts(e=e.u),r=kl(e,n,t),o=Vs(r);return null!=o&&o!==r&&Tl(e,n,t,o),o}function Rl(e){const t=Ts(e=e.u),n=kl(e,t,1),r=Bs(n,!0,!!(34&t));return null!=r&&r!==n&&Tl(e,t,1,r),r}function Dl(e,t,n){const r=Ts(e=e.u),o=2&r;let i=Al(e,r,t,1),a=Cs(i);if(!(4&a)){Object.isFrozen(i)&&(i=ws(i),As(i,a=-3&a|32),Tl(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),a|=21,o?a|=34:a&=-33,As(i,a),2&a&&Object.freeze(i)}return!o&&(2&a||Object.isFrozen(i))&&(i=ws(i),As(i,-35&a),Tl(e,r,t,i)),i}let _l;function Fl(){return _l??=new dl(Rs([]),void 0,void 0,void 0,js)}function Ml(e){e=ws(e);for(let t=0;t<e.length;t++){const n=e[t]=ws(e[t]);Array.isArray(n[1])&&(n[1]=Rs(n[1]))}return e}function Ll(e,t,n){{const r=Ts(e=e.u);if(Ns(r),null==n)Tl(e,r,t);else{if(!(4&Cs(n))){Object.isFrozen(n)&&(n=ws(n));for(let e=0;e<n.length;e++)n[e]=Xs(n[e]);As(n,5)}Tl(e,r,t,n)}}}function Pl(e,t){return Bl(e=e.u,Ts(e),Cd)===t?t:-1}function Bl(e,t,n){let r=0;for(let o=0;o<n.length;o++){const i=n[o];null!=kl(e,t,i)&&(0!==r&&Tl(e,t,r),r=i)}return r}function Ol(e,t,n,r){const o=Ts(e);Ns(o);const i=kl(e,o,n,r);let a;if(null!=i&&i.M===Ls)return(t=El(i))!==i&&Tl(e,o,n,t,r),t.u;if(Array.isArray(i)){const e=Cs(i);a=2&e?xl(i,e,!1):i,a=sl(a,t)}else a=sl(void 0,t);return a!==i&&Tl(e,o,n,a,r),a}function Nl(e,t,n,r){const o=Ts(e=e.u),i=kl(e,o,n,r);return(t=Qs(i,t,!1,o))!==i&&null!=t&&Tl(e,o,n,t,r),t}function Ul(e,t,n,r=!1){if(null==(t=Nl(e,t,n,r)))return t;const o=Ts(e=e.u);if(!(2&o)){const i=El(t);i!==t&&Tl(e,o,n,t=i,r)}return t}function jl(e,t,n,r,o){var i=!!(2&t),a=Al(e,t,r,1),s=a===Ms;if(s&&2!==o)return a;if(s||!(4&Cs(a))){var l=a;a=!!(2&t),s=!!(2&Cs(l)),i=l,!a&&s&&(l=ws(l));var c=t|((s=s||void 0)?2:0),u=s;s=!1;let d=0,h=0;for(;d<l.length;d++){const e=Qs(l[d],n,!1,c);if(null==e)continue;const t=!!(2&Cs(e.u));u=u||t,s=s||!t,l[h++]=e}return h<d&&(l.length=h),c=5|(l=Cs(n=l)),u=u?-9&c:8|c,l!=(u=s?-17&u:16|u)&&(Object.isFrozen(n)&&(n=ws(n)),As(n,u)),i!==(l=n)&&Tl(e,t,r,l),(a&&2!==o||1===o)&&Object.freeze(l),l}return 3===o||(i?2===o&&(o=Cs(a),a=ws(a),As(a,o),Tl(e,t,r,a)):(i=Object.isFrozen(a),1===o?i||Object.freeze(a):(n=-33&(o=Cs(a)),i||2&o?(a=ws(a),As(a,-3&n),Tl(e,t,r,a)):o!==n&&As(a,n)))),a}function Gl(e,t,n){var r=e.u;const o=Ts(r);if(t=jl(r,o,t,n,(e=!!(2&o))?1:2),!(e||8&Cs(t))){for(n=0;n<t.length;n++)(e=t[n])!==(r=El(e))&&(t[n]=r);Es(t,8)}return t}function $l(e,t,n,r,o){return null==r&&(r=void 0),Cl(e,n,r,o)}function zl(e,t,n,r){null==r&&(r=void 0);const o=Ts(e=e.u);Ns(o),(n=Bl(e,o,n))&&n!==t&&null!=r&&Tl(e,o,n),Tl(e,o,t,r)}function ql(e,t,n){const r=Ts(e=e.u);Ns(r),e=jl(e,r,t,1,2),t=null!=n?n:new t,e.push(t),2&Cs(t.u)?ks(e,8):ks(e,16)}function Vl(e,t){return Ks(Sl(e,t))}function Wl(e){return null==(e=Sl(e,2))||Hs(e)?e:void 0}function Hl(e,t){return Zs(Sl(e,t))}function Kl(e){return e??0}function Yl(e,t){return Kl(Il(e,t))}function Xl(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}Cl(e,t,n)}function Jl(e,t,n){if(null!=n){if("number"!=typeof n)throw qs(e=Error(),"warning"),e;if(!Number.isFinite(n)){const e=Error();qs(e,"incident"),function(e){Ui.setTimeout((()=>{throw e}),0)}(e)}}Cl(e,t,n)}function Zl(e,t,n){if(null!=n&&"number"!=typeof n)throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);Cl(e,t,n)}function Ql(e,t,n){n=Xs(n);const r=Ts(e=e.u);Ns(r),Al(e,r,t,2).push(n)}function ec(e,t,n){t.g?t.m(e,t.g,t.h,n,!0):t.m(e,t.h,n,!0)}dl.prototype.toJSON=void 0;var tc=class{constructor(e,t){this.u=ll(e,t)}toJSON(){return nc(this,ml(this.u,bl,void 0,void 0,!1,!1),!0)}l(){var e=xh;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 wl(this,e,Ts(e),!1)}H(){return!!(2&Cs(this.u))}};function nc(e,t,n){var r=e.constructor.B,o=Fs(Ts(n?e.u:t)),i=!1;if(r){if(!n){var a;if((t=ws(t)).length&&Ps(a=t[t.length-1]))for(i=0;i<r.length;i++)if(r[i]>=o){Object.assign(t[t.length-1]={},a);break}i=!0}var s;o=t,n=!n,e=Fs(a=Ts(e.u)),a=+!!(512&a)-1;for(let t=0;t<r.length;t++){var l=r[t];if(l<e){var c=o[l+=a];null==c?o[l]=n?Ms:Is():n&&c!==Ms&&Ss(c)}else{if(!s){var u=void 0;o.length&&Ps(u=o[o.length-1])?s=u:o.push(s={})}c=s[l],null==s[l]?s[l]=n?Ms:Is():n&&c!==Ms&&Ss(c)}}}if(!(r=t.length))return t;let d,h;if(Ps(s=t[r-1])){e:{var f=s;u={},o=!1;for(let e in f)n=f[e],Array.isArray(n)&&n!=n&&(o=!0),null!=n?u[e]=n:o=!0;if(o){for(let e in u){f=u;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 rc(e){return{ca:Zc,U:e}}function oc(e,t){if(Array.isArray(t)){var n=Cs(t);if(4&n)return t;for(var r=0,o=0;r<t.length;r++){const n=e(t[r]);null!=n&&(t[o++]=n)}return o<r&&(t.length=o),As(t,5|n),2&n&&Object.freeze(t),t}}tc.prototype.M=Ls,tc.prototype.toString=function(){return nc(this,this.u,!1).toString()};const ic=Symbol();function ac(e){let t=e[ic];if(!t){const n=hc(e),r=Sc(e),o=r.h;t=o?(e,t)=>o(e,t,r):(e,t)=>{for(;Xa(t)&&4!=t.h;){var o=t.m,i=r[o];if(!i){var a=r.g;a&&(a=a[o])&&(i=r[o]=sc(a))}i&&i(t,e,o)||(o=(i=t).l,Ja(i),i.aa?i=void 0:(a=i.g.g-o,i.g.g=o,i=Ha(i.g,a)),o=e,i&&(Gs||=Symbol(),(a=o[Gs])?a.push(i):o[Gs]=[i]))}for(const t in n){e[$s||=Symbol()]=n;break}},e[ic]=t}return t}function sc(e){const t=function(e){if(e=e.U)return ac(e)}(e),n=e.ca.g;if(t){const r=Sc(e.U).L;return(e,o,i)=>n(e,o,i,r,t)}return(e,t,r)=>n(e,t,r)}const lc=Symbol();function cc(e,t,n,r){let o;if(r){const t=r[lc];o=t?t.L:al(r[0]),n[e]=t??r}o&&o===ol?((t=n.xa)||(n.xa=t=[]),t.push(e)):t.l&&((t=n.Ba)||(n.Ba=t=[]),t.push(e))}function uc(e,t,n,r){cc(e,t,r)}function dc(e,t,n,r,o){cc(e,t,o,n)}function hc(e){let t=e[lc];return t||(t=e[lc]={},fc(e,t,uc,dc,t))}function fc(e,t,n,r,o){t.L=al(e[0]);let i=1;if(e.length>i&&!(e[i]instanceof ys)){var a=e[i++];if(Array.isArray(a))return t.h=a[0],t.g=a[1],t;t.g=a}for(a=0;i<e.length;){var s=e[i++],l=e[i];for("number"==typeof l?(i++,a+=l):a++,l=i;l<e.length&&!(e[l]instanceof ys);)l++;if(l-=i){var c=e,u=i,d=c[u];if("function"==typeof d&&(d=d(),c[u]=d),(c=Array.isArray(d))&&!(c=wc in d||mc in d)&&(c=0<d.length)){const e=al(u=(c=d)[0]);null!=e&&e!==u&&(c[0]=e),c=null!=e}(d=c?d:void 0)?(i++,1===l?void 0!==(s=r(a,s,d,void 0,o))&&(t[a]=s):void 0!==(s=r(a,s,d,e[i++],o))&&(t[a]=s)):void 0!==(s=n(a,s,e[i++],o))&&(t[a]=s)}else void 0!==(s=n(a,s,void 0,o))&&(t[a]=s)}return t}const pc=Symbol();function gc(e){let t=e[pc];if(!t){const n=yc(e);t=(e,t)=>Cc(e,t,n),e[pc]=t}return t}const mc=Symbol();function vc(e,t){return t.h}function bc(e,t,n){let r,o;const i=t.h;return(e,t,a)=>i(e,t,a,o||=yc(n).L,r||=gc(n))}function yc(e){let t=e[mc];return t||(t=fc(e,e[mc]={},vc,bc),wc in e&&mc in e&&(e.length=0),t)}const wc=Symbol();function xc(e,t,n){const r=t.g;return n?(e,t,o)=>r(e,t,o,n):r}function Ec(e,t,n,r){const o=t.g;let i,a;return(e,t,s)=>o(e,t,s,a||=Sc(n).L,i||=ac(n),r)}function Sc(e){let t=e[wc];return t||(hc(e),t=fc(e,e[wc]={},xc,Ec),wc in e&&mc in e&&(e.length=0),t)}function kc(e,t){var n=e[t];if(n)return n;if((n=e.g)&&(n=n[t])){var r=n.U,o=n.ca.h;if(r){const e=gc(r),t=yc(r).L;n=(n,r,i)=>o(n,r,i,t,e)}else n=o;return e[t]=n}}function Cc(e,t,n){for(var r=Ts(e),o=+!!(512&r)-1,i=e.length,a=512&r?1:0,s=i+(256&r?-1:0);a<s;a++){const r=e[a];if(null==r)continue;const i=a-o,s=kc(n,i);s&&s(t,r,i)}if(256&r){r=e[i-1];for(let e in r)o=+e,Number.isNaN(o)||null!=(i=r[e])&&(s=kc(n,o))&&s(t,i,o)}if(e=Gs?e[Gs]:void 0)for(fs(t,t.g.end()),n=0;n<e.length;n++)fs(t,ka(e[n])||ya())}function Tc(e,t){return new ys(e,t,!1)}function Ac(e,t){return new ys(e,t,!0)}function Ic(e,t,n){Tl(e,Ts(e),t,n)}var Rc=Tc((function(e,t,n,r,o){return 2===e.h&&(e=Za(e,sl([void 0,void 0],r),o),Ns(r=Ts(t)),(o=kl(t,r,n))instanceof dl?0!=(2&o.g)?((o=o.m()).push(e),Tl(t,r,n,o)):o.I(e):Array.isArray(o)?(2&Cs(o)&&Tl(t,r,n,o=Ml(o)),o.push(e)):Tl(t,r,n,[e]),!0)}),(function(e,t,n,r,o){if(t instanceof dl)t.forEach(((t,i)=>{bs(e,n,sl([i,t],r),o)}));else if(Array.isArray(t))for(let i=0;i<t.length;i++){const a=t[i];Array.isArray(a)&&bs(e,n,sl(a,r),o)}}));function Dc(e,t,n){e:if(null!=t){if(Hs(t)){if("string"==typeof t)break e;if("number"==typeof t)break e}t=void 0}null!=t&&("string"==typeof t&&as(t),null!=t&&(ps(e,n,0),"number"==typeof t?(e=e.g,Pa(t),cs(e,Ma,La)):(n=as(t),cs(e.g,n.h,n.g))))}function _c(e,t,n){null!=(t=Ks(t))&&null!=t&&(ps(e,n,0),ds(e.g,t))}function Fc(e,t,n){null!=(t=Ws(t))&&(ps(e,n,0),e.g.g.push(t?1:0))}function Mc(e,t,n){null!=(t=Zs(t))&&vs(e,n,Hi(t))}function Lc(e,t,n,r,o){bs(e,n,t instanceof tc?t.u:Array.isArray(t)?sl(t,r):void 0,o)}function Pc(e,t,n){null!=(t=null==t||"string"==typeof t||va(t)||t instanceof Ca?t:void 0)&&vs(e,n,Da(t).buffer)}function Bc(e,t,n){return(5===e.h||2===e.h)&&(t=Al(t,Ts(t),n,2,!1),2==e.h?ts(e,Ka.prototype.A,t):t.push(e.g.A()),!0)}var Oc=Tc((function(e,t,n){if(1!==e.h)return!1;var r=e.g;e=Va(r);const o=Va(r);r=2*(o>>31)+1;const i=o>>>20&2047;return e=4294967296*(1048575&o)+e,Ic(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=Vs(t))&&(ps(e,n,1),e=e.g,(n=Fa||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),Ma=n.getUint32(0,!0),La=n.getUint32(4,!0),hs(e,Ma),hs(e,La))})),Nc=Tc((function(e,t,n){return 5===e.h&&(Ic(t,n,e.g.A()),!0)}),(function(e,t,n){null!=(t=Vs(t))&&(ps(e,n,5),e=e.g,Ba(t),hs(e,Ma))})),Uc=Ac(Bc,(function(e,t,n){if(null!=(t=oc(Vs,t)))for(let i=0;i<t.length;i++){var r=e,o=t[i];null!=o&&(ps(r,n,5),r=r.g,Ba(o),hs(r,Ma))}})),jc=Ac(Bc,(function(e,t,n){if(null!=(t=oc(Vs,t))&&t.length){ps(e,n,2),us(e.g,4*t.length);for(let r=0;r<t.length;r++)n=e.g,Ba(t[r]),hs(n,Ma)}})),Gc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,za(e.g,Na)),!0)}),Dc),$c=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,0===(e=za(e.g,Na))?void 0:e),!0)}),Dc),zc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,za(e.g,Oa)),!0)}),(function(e,t,n){e:if(null!=t){if(Hs(t)){if("string"==typeof t)break e;if("number"==typeof t)break e}t=void 0}null!=t&&("string"==typeof t&&rs(t),null!=t&&(ps(e,n,0),"number"==typeof t?(e=e.g,Pa(t),cs(e,Ma,La)):(n=rs(t),cs(e.g,n.h,n.g))))})),qc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,e.g.m()),!0)}),_c),Vc=Ac((function(e,t,n){return(0===e.h||2===e.h)&&(t=Al(t,Ts(t),n,2,!1),2==e.h?ts(e,Ka.prototype.m,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=oc(Ks,t))&&t.length){n=gs(e,n);for(let n=0;n<t.length;n++)ds(e.g,t[n]);ms(e,n)}})),Wc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,0===(e=e.g.m())?void 0:e),!0)}),_c),Hc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,qa(e.g)),!0)}),Fc),Kc=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,!1===(e=qa(e.g))?void 0:e),!0)}),Fc),Yc=Ac((function(e,t,n){if(2!==e.h)return!1;e=Qa(e);const r=Ts(t);return Ns(r),Al(t,r,n,2).push(e),!0}),(function(e,t,n){if(null!=(t=oc(Zs,t)))for(let o=0;o<t.length;o++){var r=t[o];null!=r&&vs(e,n,Hi(r))}})),Xc=Tc((function(e,t,n){return 2===e.h&&(Ic(t,n,""===(e=Qa(e))?void 0:e),!0)}),Mc),Jc=Tc((function(e,t,n){return 2===e.h&&(Ic(t,n,Qa(e)),!0)}),Mc),Zc=Tc((function(e,t,n,r,o){return 2===e.h&&(Za(e,Ol(t,r,n,!0),o),!0)}),Lc),Qc=Tc((function(e,t,n,r,o){return 2===e.h&&(Za(e,Ol(t,r,n),o),!0)}),Lc),eu=Ac((function(e,t,n,r,o){if(2!==e.h)return!1;r=sl(void 0,r);const i=Ts(t);Ns(i);let a=Al(t,i,n,3);return(Object.isFrozen(a)||4&Cs(a))&&(a=ws(a),Tl(t,i,n,a)),a.push(r),Za(e,r,o),!0}),(function(e,t,n,r,o){if(Array.isArray(t))for(let i=0;i<t.length;i++)Lc(e,t[i],n,r,o)})),tu=Tc((function(e,t,n,r,o,i){if(2!==e.h)return!1;const a=Ts(t);return Ns(a),(i=Bl(t,a,i))&&n!==i&&Tl(t,a,i),Za(e,t=Ol(t,r,n),o),!0}),Lc),nu=Tc((function(e,t,n){return 2===e.h&&(Ic(t,n,es(e)),!0)}),Pc),ru=Ac((function(e,t,n){return(0===e.h||2===e.h)&&(t=Al(t,Ts(t),n,2,!1),2==e.h?ts(e,Ka.prototype.j,t):t.push(e.g.j()),!0)}),(function(e,t,n){if(null!=(t=oc(Ys,t)))for(let i=0;i<t.length;i++){var r=e,o=t[i];null!=o&&(ps(r,n,0),us(r.g,o))}})),ou=Tc((function(e,t,n){return 0===e.h&&(Ic(t,n,e.g.m()),!0)}),(function(e,t,n){null!=(t=Ks(t))&&(t=parseInt(t,10),ps(e,n,0),ds(e.g,t))})),iu=Ac((function(e,t,n){return(0===e.h||2===e.h)&&(t=Al(t,Ts(t),n,2,!1),2==e.h?ts(e,Ka.prototype.C,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=oc(Ks,t))&&t.length){n=gs(e,n);for(let n=0;n<t.length;n++)ds(e.g,t[n]);ms(e,n)}}));class au{constructor(e,t){this.h=e,this.g=t,this.l=Ul,this.m=$l,this.defaultValue=void 0}}function su(e,t){return new au(e,t)}function lu(e,t){return(n,r)=>{e:{if(ns.length){const e=ns.pop();e.o(r),Ga(e.g,n,r),n=e}else n=new class{constructor(e,t){if(Ya.length){const n=Ya.pop();Ga(n,e,t),e=n}else e=new Ka(e,t);this.g=e,this.l=this.g.g,this.h=this.m=-1,this.o(t)}o({aa:e=!1}={}){this.aa=e}}(n,r);try{var o=new e;const r=o.u;ac(t)(r,n),$s&&delete r[$s];var i=o;break e}finally{(o=n.g).h=null,o.s=!1,o.v=0,o.l=0,o.g=0,o.R=!1,n.m=-1,n.h=-1,100>ns.length&&ns.push(n)}i=void 0}return i}}function cu(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}}}};Cc(this.u,t,yc(e)),fs(t,t.g.end());const n=new Uint8Array(t.h),r=t.l,o=r.length;let i=0;for(let e=0;e<o;e++){const t=r[e];n.set(t,i),i+=t.length}return t.l=[n],n}}var uu=[0,Xc,Tc((function(e,t,n){return 2===e.h&&(Ic(t,n,(e=es(e))===Sa()?void 0:e),!0)}),(function(e,t,n){if(null!=t){if(t instanceof tc){const r=t.Ea;return void(r&&(t=r(t),null!=t&&vs(e,n,Da(t).buffer)))}if(Array.isArray(t))return}Pc(e,t,n)}))],du=[0,Jc],hu=[0,qc,ou,Hc,Hc,Vc,ou,ou],fu=[0,Hc,Hc],pu=class extends tc{constructor(){super()}};pu.B=[6];var gu=[0,Hc,Jc,Hc,ou,ou,iu,Jc,Jc,Qc,fu,ou],mu=[0,Jc,Jc,Jc],vu=class extends tc{constructor(){super()}},bu=[0],yu=[0,qc],wu=[1,2,3,4,5],xu=class extends tc{constructor(e){super(e,2)}},Eu={},Su=[-2,Eu,Hc];Eu[336783863]=rc([0,Jc,Hc,Hc,qc,Qc,[0,tu,bu,wu,tu,gu,wu,tu,mu,wu,tu,yu,wu,tu,hu,wu],Qc,du]);var ku=[0,Xc,Kc],Cu=[0,$c,$c,Kc,Kc,Kc,Kc,$c,Vc,Xc,Wc,$c,$c,Kc,Wc,Kc,Kc,Kc,Xc],Tu=[-1,{}],Au=[0,Jc,Qc,2,Tu],Iu=[0,Jc,Yc,Qc,Tu];function Ru(e,t){t=Js(t);const n=Ts(e=e.u);Ns(n),Tl(e,n,2,""===t?void 0:t)}function Du(e,t){Ql(e,3,t)}function _u(e,t){Ql(e,4,t)}var Fu=class extends tc{constructor(e){super(e,500)}o(e){return $l(this,0,7,e)}};Fu.B=[3,4,5,6,8,13,17,1005];var Mu=[-500,Xc,Xc,Yc,Yc,Yc,Yc,Qc,Su,eu,uu,Wc,Wc,Qc,Au,Qc,Iu,eu,ku,Xc,Qc,Cu,Wc,Yc,Yc,988],Lu=[0,Xc,Xc,Qc,Tu],Pu=[-500,Jc,Jc,Qc,[-1,{}],Jc,999],Bu=[-500,Jc,Yc,Yc,Qc,[-2,{},Hc],Yc,998,Yc],Ou=[-500,Jc,Yc,Qc,Tu,Yc,999];function Nu(e,t){ql(e,Fu,t)}function Uu(e,t){Ql(e,10,t)}function ju(e,t){Ql(e,15,t)}var Gu=class extends tc{constructor(e){super(e,500)}o(e){return $l(this,0,1001,e)}};Gu.B=[1,6,7,9,10,15,16,17,14,1002];var $u=[-500,eu,Mu,eu,5,Pu,eu,Bu,Wc,eu,Ou,Yc,Wc,Qc,Au,Qc,Iu,eu,Lu,Yc,Yc,Yc,Qc,Cu,Xc,Xc,Kc,Qc,980,Tu,eu,uu],zu=lu(Gu,$u);Gu.prototype.g=cu($u);var qu=[0,eu,[0,qc,qc,qc]],Vu=class extends tc{constructor(e){super(e)}},Wu=[0,qc,Nc,Jc,Jc],Hu=class extends tc{constructor(e){super(e)}g(){return Gl(this,Vu,1)}};Hu.B=[1];var Ku=[0,eu,Wu],Yu=lu(Hu,Ku),Xu=[0,qc,Nc],Ju=[0,qc,qc,Qc,qu],Zu=class extends tc{constructor(e){super(e)}},Qu=[0,qc,qc,qc,qc],ed=[0,Nc,Nc,Nc,Nc],td=class extends tc{constructor(e){super(e)}},nd=[0,Nc,Nc,Jc,Nc],rd=class extends tc{constructor(e){super(e)}h(){return Ul(this,Zu,2)}g(){return Gl(this,td,5)}};rd.B=[5];var od=[0,ou,Qc,Qu,Qc,ed,Qc,Ju,eu,nd],id=class extends tc{constructor(e){super(e)}};id.B=[1,2,3,8,9];var ad=lu(id,[0,Yc,Vc,jc,Qc,od,Jc,Jc,Gc,eu,Xu,Yc,Gc]),sd=class extends tc{constructor(e){super(e)}},ld=[0,Nc,Nc,Nc,Nc,Nc],cd=class extends tc{constructor(e){super(e)}};cd.B=[1];var ud=lu(cd,[0,eu,ld]),dd=class extends tc{constructor(e){super(e)}},hd=[0,Nc,Nc,Nc,Nc,Nc],fd=class extends tc{constructor(e){super(e)}};fd.B=[1];var pd=lu(fd,[0,eu,hd]),gd=class extends tc{constructor(e){super(e)}};gd.B=[3];var md=[0,qc,qc,jc,ou],vd=class extends tc{constructor(){super()}};vd.prototype.g=cu([0,Nc,Nc,Nc,Nc,Nc,Gc]);var bd=class extends tc{constructor(e){super(e)}},yd=[0,qc,2,Jc,Qc,Ku],wd=class extends tc{constructor(e){super(e)}};wd.B=[1];var xd=lu(wd,[0,eu,yd,Gc]),Ed=class extends tc{constructor(e){super(e)}};Ed.B=[1];var Sd=class extends tc{constructor(e){super(e)}fa(){const e=Rl(this);return null==e?Sa():e}},kd=class extends tc{constructor(e){super(e)}},Cd=[1,2],Td=[0,tu,[0,jc],Cd,tu,[0,nu],Cd,qc,Jc],Ad=class extends tc{constructor(e){super(e)}};Ad.B=[1];var Id=lu(Ad,[0,eu,Td,Gc]),Rd=class extends tc{constructor(e){super(e)}};Rd.B=[4,5];var Dd=[0,Jc,qc,Nc,Yc,Yc],_d=class extends tc{constructor(e){super(e)}},Fd=[0,Hc,Hc],Md=class extends tc{constructor(e){super(e)}},Ld=[1,2,3,4,5],Pd=class extends tc{constructor(e){super(e)}g(){return null!=Rl(this)}h(){return null!=Hl(this,2)}},Bd=[0,nu,Jc,Qc,[0,qc,Gc,Gc],Qc,[0,zc,Gc]],Od=class extends tc{constructor(e){super(e)}g(){return Ws(Sl(this,2))??!1}},Nd=[0,Qc,Bd,Hc,Qc,[0,tu,yu,Ld,tu,gu,Ld,tu,hu,Ld,tu,bu,Ld,tu,mu,Ld]],Ud=class extends tc{constructor(e){super(e)}},jd=[0,Qc,Nd,Nc,Nc,qc],Gd=su(502141897,Ud);Eu[502141897]=rc(jd);var $d=[0,Qc,Bd];Eu[512499200]=rc($d);var zd=[0,Qc,$d];Eu[515723506]=rc(zd);var qd=lu(class extends tc{constructor(e){super(e)}},[0,Qc,[0,ou,ou,Uc,ru],Qc,md]),Vd=[0,Qc,Nd];Eu[508981768]=rc(Vd);var Wd=class extends tc{constructor(e){super(e)}},Hd=[0,Qc,Nd,Nc,Qc,Vd,Hc],Kd=class extends tc{constructor(e){super(e)}},Yd=[0,Qc,Nd,Qc,jd,Qc,Hd,Nc,Qc,zd];Eu[508968149]=rc(Hd);var Xd=su(508968150,Kd);Eu[508968150]=rc(Yd);var Jd=class extends tc{constructor(e){super(e)}},Zd=su(513916220,Jd);Eu[513916220]=rc([0,Qc,Nd,Qc,Yd,qc]);var Qd=class extends tc{constructor(e){super(e)}h(){return Ul(this,Rd,2)}g(){Cl(this,2)}},eh=[0,Qc,Nd,Qc,Dd];Eu[478825465]=rc(eh);var th=[0,Qc,Nd];Eu[478825422]=rc(th);var nh=class extends tc{constructor(e){super(e)}},rh=[0,Qc,Nd,Qc,th,Qc,eh,Qc,eh],oh=class extends tc{constructor(e){super(e)}},ih=[0,Qc,Nd,Nc,qc],ah=class extends tc{constructor(e){super(e)}},sh=[0,Qc,Nd,Nc],lh=class extends tc{constructor(e){super(e)}},ch=[0,Qc,Nd,Qc,ih,Qc,sh,Nc],uh=class extends tc{constructor(e){super(e)}},dh=[0,Qc,Nd,Qc,ch,Qc,rh];Eu[463370452]=rc(rh),Eu[464864288]=rc(ih),Eu[474472470]=rc(sh);var hh=su(462713202,lh);Eu[462713202]=rc(ch);var fh=su(479097054,uh);Eu[479097054]=rc(dh);var ph=class extends tc{constructor(e){super(e)}},gh=su(456383383,ph);Eu[456383383]=rc([0,Qc,Nd,Qc,Dd]);var mh=class extends tc{constructor(e){super(e)}},vh=su(476348187,mh);Eu[476348187]=rc([0,Qc,Nd,Qc,Fd]);var bh=class extends tc{constructor(e){super(e)}},yh=[0,ou,ou],wh=class extends tc{constructor(e){super(e)}};wh.B=[3];var xh=su(458105876,class extends tc{constructor(e){super(e)}g(){var e=this.u;const t=Ts(e);var n=2&t;return e=function(e,t,n){var r=wh;const o=2&t;let i=!1;if(null==n){if(o)return Fl();n=[]}else if(n.constructor===dl){if(0==(2&n.g)||o)return n;n=n.m()}else Array.isArray(n)?i=!!(2&Cs(n)):n=[];if(o){if(!n.length)return Fl();i||(i=!0,Rs(n))}else i&&(i=!1,n=Ml(n));return i||(64&Cs(n)?ks(n,32):32&t&&Es(n,32)),Tl(e,t,2,r=new dl(n,r,nl,void 0),!1),r}(e,t,kl(e,t,2)),null==e||!n&&wh&&(e.v=!0),e}});Eu[458105876]=rc([0,Qc,yh,Rc,[!0,Gc,Qc,[0,Jc,Jc,Yc]]]);var Eh=class extends tc{constructor(e){super(e)}},Sh=su(458105758,Eh);Eu[458105758]=rc([0,Qc,Nd,Jc,Qc,yh]);var kh=class extends tc{constructor(e){super(e)}};kh.B=[5,6];var Ch=su(443442058,kh);Eu[443442058]=rc([0,Qc,Nd,Jc,qc,Nc,Yc,Yc]);var Th=class extends tc{constructor(e){super(e)}},Ah=[0,Qc,Nd,Nc,Nc,qc];Eu[514774813]=rc(Ah);var Ih=class extends tc{constructor(e){super(e)}},Rh=[0,Qc,Nd,Nc,Hc],Dh=class extends tc{constructor(e){super(e)}},_h=[0,Qc,Nd,Qc,Ah,Qc,Rh,Nc];Eu[518928384]=rc(Rh);var Fh=su(516587230,Dh);function Mh(e,t){return t=t?t.clone():new Rd,void 0!==e.displayNamesLocale?Cl(t,1,Js(e.displayNamesLocale)):void 0===e.displayNamesLocale&&Cl(t,1),void 0!==e.maxResults?Jl(t,2,e.maxResults):"maxResults"in e&&Cl(t,2),void 0!==e.scoreThreshold?Zl(t,3,e.scoreThreshold):"scoreThreshold"in e&&Cl(t,3),void 0!==e.categoryAllowlist?Ll(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&Cl(t,4),void 0!==e.categoryDenylist?Ll(t,5,e.categoryDenylist):"categoryDenylist"in e&&Cl(t,5),t}function Lh(e,t=-1,n=""){return{categories:e.map((e=>({index:Kl(Vl(e,1))??-1,score:Yl(e,2)??0,categoryName:Hl(e,3)??""??"",displayName:Hl(e,4)??""??""}))),headIndex:t,headName:n}}function Ph(e){var t=Dl(e,3,Vs),n=Dl(e,2,Ks);const r=Dl(e,1,Zs),o=Dl(e,9,Zs),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:o[e]??""});if((t=Ul(e,rd,4)?.h())&&(i.boundingBox={originX:Vl(t,1)??0,originY:Vl(t,2)??0,width:Vl(t,3)??0,height:Vl(t,4)??0,angle:0}),Ul(e,rd,4)?.g().length)for(const t of Ul(e,rd,4).g())i.keypoints.push({x:Il(t,1)??0,y:Il(t,2)??0,score:Il(t,4)??0,label:Hl(t,3)??""});return i}function Bh(e){const t=[];for(const n of Gl(e,dd,1))t.push({x:Yl(n,1)??0,y:Yl(n,2)??0,z:Yl(n,3)??0});return t}function Oh(e){const t=[];for(const n of Gl(e,sd,1))t.push({x:Yl(n,1)??0,y:Yl(n,2)??0,z:Yl(n,3)??0});return t}function Nh(e){return Array.from(e,(e=>127<e?e-256:e))}function Uh(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,o=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i],r+=e[i]*e[i],o+=t[i]*t[i];if(0>=r||0>=o)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(r*o)}let jh;Eu[516587230]=rc(_h);const Gh=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 $h(){if(void 0===jh)try{await WebAssembly.instantiate(Gh),jh=!0}catch{jh=!1}return jh}async function zh(e,t=""){const n=await $h()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${n}.js`,wasmBinaryPath:`${t}/${e}_${n}.wasm`}}var qh=class{};function Vh(){const e=navigator.userAgent;return e.includes("Safari")&&!e.includes("Chrome")}async function Wh(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 Hh(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 Kh(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 Yh(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 Xh(e,t,n){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=n}function Jh(e,t,n){let r=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(e,t,o)=>{t?(n(r,o),r=[]):r.push(e)}}function Zh(e,t){const n=Ul(e.baseOptions,Pd,1)||new Pd;"string"==typeof t?(Cl(n,2,Js(t)),Cl(n,1)):t instanceof Uint8Array&&(Cl(n,1,Bs(t,!1,!1)),Cl(n,2)),$l(e.baseOptions,0,1,n)}function Qh(e){try{const t=e.J.length;if(1===t)throw Error(e.J[0].message);if(1<t)throw Error("Encountered multiple errors: "+e.J.map((e=>e.message)).join(", "))}finally{e.J=[]}}function ef(e,t){e.I=Math.max(e.I,t)}function tf(e,t){e.A=new Fu,Ru(e.A,"PassThroughCalculator"),Du(e.A,"free_memory"),_u(e.A,"free_memory_unused_out"),Uu(t,"free_memory"),Nu(t,e.A)}function nf(e,t){Du(e.A,t),_u(e.A,t+"_unused_out")}function rf(e){e.g.addBoolToStream(!0,"free_memory",e.I)}qh.forVisionTasks=function(e){return zh("vision",e)},qh.forTextTasks=function(e){return zh("text",e)},qh.forAudioTasks=function(e){return zh("audio",e)},qh.isSimdSupported=function(){return $h()};var of=class{constructor(e){this.g=e,this.J=[],this.I=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(!(Ul(this.baseOptions,Pd,1)?.g()||Ul(this.baseOptions,Pd,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=Ul(e.baseOptions,Md,3);if(!n){var r=n=new Md,o=new vu;zl(r,4,Ld,o)}"delegate"in t&&("GPU"===t.delegate?(t=n,r=new pu,zl(t,2,Ld,r)):(t=n,r=new vu,zl(t,4,Ld,r))),$l(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),Zh(this,"/model.dat"),this.m(),this.P()}));Zh(this,t.modelAssetBuffer)}return this.m(),this.P(),Promise.resolve()}P(){}W(){let e;if(this.g.W((t=>{e=zu(t)})),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener(((e,t)=>{this.J.push(Error(t))})),this.g.Aa(),this.g.setGraph(e,t),this.A=void 0,Qh(this)}finishProcessing(){this.g.finishProcessing(),Qh(this)}close(){this.A=void 0,this.g.closeGraph()}};function af(e,t){if(null===e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}of.prototype.close=of.prototype.close;class sf{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 lf(e,t,n){const r=e.h;if(n=af(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 cf(e,t){const n=e.h,r=af(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(r);const o=af(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,o),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=af(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 sf(n,r,o,i)}function uf(e,t){if(e.h){if(t!==e.h)throw Error("Cannot change GL context once initialized")}else e.h=t}function df(e,t,n,r){if(uf(e,t),!e.g){const t=e.h;if(e.g=af(t.createProgram(),"Failed to create WebGL program"),e.C=lf(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=lf(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=cf(e,!0)),n=e.m):(e.j||(e.j=cf(e,!1)),n=e.j),t.useProgram(e.g),n.bind(),e=r(),n.g.bindVertexArray(null),e}function hf(e,t,n){uf(e,t),e.l||(e.l=af(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 ff(e){e.h?.bindFramebuffer(e.h.FRAMEBUFFER,null)}var pf=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 gf(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 mf(e){var t=gf(e,0);if(!t){t=bf(e);const n=yf(e),r=new Uint8Array(e.width*e.height*4);hf(n,t,vf(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,r),ff(n),t=new ImageData(new Uint8ClampedArray(r.buffer),e.width,e.height),e.g.push(t)}return t}function vf(e){let t=gf(e,2);if(!t){const n=bf(e);t=xf(e);const r=gf(e,1)||mf(e);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,r),Ef(e)}return t}function bf(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=af(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function yf(e){return e.l||(e.l=new pf),e.l}function wf(e){(e=bf(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 xf(e){const t=bf(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=gf(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=af(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),wf(e)),n}function Ef(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Sf(e){const t=bf(e);return df(yf(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,o=n.height;return n.width=e.width,n.height=e.height,e=t(),n.width=r,n.height=o,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 kf=class{constructor(e,t,n,r,o,i,a){this.g=e,this.j=t,this.m=n,this.canvas=r,this.l=o,this.width=i,this.height=a,(this.j||this.m)&&0==--Cf&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}va(){return!!gf(this,0)}ba(){return!!gf(this,1)}K(){return!!gf(this,2)}ra(){return mf(this)}qa(){var e=gf(this,1);return e||(vf(this),xf(this),e=Sf(this),Ef(this),this.g.push(e),this.j=!0),e}V(){return vf(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=bf(this),t=yf(this);e.activeTexture(e.TEXTURE1),n=af(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),wf(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),hf(t,e,n),df(t,e,!1,(()=>{xf(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),Ef(this)})),ff(t),Ef(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);vf(this),xf(this),n=Sf(this),Ef(this)}e.push(n)}return new kf(e,this.ba(),this.K(),this.canvas,this.l,this.width,this.height)}close(){this.j&&gf(this,1).close(),this.m&&bf(this).deleteTexture(gf(this,2)),Cf=-1}};kf.prototype.close=kf.prototype.close,kf.prototype.clone=kf.prototype.clone,kf.prototype.getAsWebGLTexture=kf.prototype.V,kf.prototype.getAsImageBitmap=kf.prototype.qa,kf.prototype.getAsImageData=kf.prototype.ra,kf.prototype.hasWebGLTexture=kf.prototype.K,kf.prototype.hasImageBitmap=kf.prototype.ba,kf.prototype.hasImageData=kf.prototype.va;var Cf=250;function Tf(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 Af(e){var t=Tf(e,1);if(!t){if(t=Tf(e,0))t=new Float32Array(t).map((e=>e/255));else{t=new Float32Array(e.width*e.height);const r=Rf(e);var n=_f(e);if(hf(n,r,If(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 If(e){let t=Tf(e,2);if(!t){const n=Rf(e);t=Mf(e);const r=Af(e),o=Df(e);n.texImage2D(n.TEXTURE_2D,0,o,e.width,e.height,0,n.RED,n.FLOAT,r),Lf(e)}return t}function Rf(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=af(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Df(e){if(e=Rf(e),!Pf)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Pf=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Pf=e.R16F}return Pf}function _f(e){return e.l||(e.l=new pf),e.l}function Ff(e){(e=Rf(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 Mf(e){const t=Rf(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=Tf(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=af(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),Ff(e)),n}function Lf(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Pf,Bf=class{constructor(e,t,n,r,o,i){this.g=e,this.m=t,this.canvas=n,this.l=r,this.width=o,this.height=i,this.m&&0==--Of&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}wa(){return!!Tf(this,0)}ua(){return!!Tf(this,1)}K(){return!!Tf(this,2)}sa(){return(e=Tf(this,0))||(e=Af(this),e=new Uint8Array(e.map((e=>255*e))),this.g.push(e)),e;var e}pa(){return Af(this)}V(){return If(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=Rf(this),t=_f(this);e.activeTexture(e.TEXTURE1),n=af(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),Ff(this);const r=Df(this);e.texImage2D(e.TEXTURE_2D,0,r,this.width,this.height,0,e.RED,e.FLOAT,null),e.bindTexture(e.TEXTURE_2D,null),hf(t,e,n),df(t,e,!1,(()=>{Mf(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),Lf(this)})),ff(t),Lf(this)}}e.push(n)}return new Bf(e,this.K(),this.canvas,this.l,this.width,this.height)}close(){this.m&&Rf(this).deleteTexture(Tf(this,2)),Of=-1}};Bf.prototype.close=Bf.prototype.close,Bf.prototype.clone=Bf.prototype.clone,Bf.prototype.getAsWebGLTexture=Bf.prototype.V,Bf.prototype.getAsFloat32Array=Bf.prototype.pa,Bf.prototype.getAsUint8Array=Bf.prototype.sa,Bf.prototype.hasWebGLTexture=Bf.prototype.K,Bf.prototype.hasFloat32Array=Bf.prototype.ua,Bf.prototype.hasUint8Array=Bf.prototype.wa;var Of=250;function Nf(...e){return e.map((([e,t])=>({start:e,end:t})))}const Uf=function(e){return class extends e{Aa(){this.i._registerModelResourcesGraphService()}}}((jf=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||Vh()?(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,o){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Hh(this,r||"input_audio",(r=>{Hh(this,o=o||"audio_header",(o=>{this.i._configureAudio(r,o,e,t,n)}))}))}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}W(e){Xh(this,"__graph_config__",(t=>{e(t)})),Hh(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,o){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),Hh(this,r,(e=>{this.i._addAudioToInputStream(this.g,t,n,e,o)}))}addGpuBufferToStream(e,t,n){Hh(this,t,(t=>{const[r,o]=Kh(this,e,t);this.i._addBoundTextureToStream(t,r,o,n)}))}addBoolToStream(e,t,n){Hh(this,t,(t=>{this.i._addBoolToInputStream(e,t,n)}))}addDoubleToStream(e,t,n){Hh(this,t,(t=>{this.i._addDoubleToInputStream(e,t,n)}))}addFloatToStream(e,t,n){Hh(this,t,(t=>{this.i._addFloatToInputStream(e,t,n)}))}addIntToStream(e,t,n){Hh(this,t,(t=>{this.i._addIntToInputStream(e,t,n)}))}addStringToStream(e,t,n){Hh(this,t,(t=>{Hh(this,e,(e=>{this.i._addStringToInputStream(e,t,n)}))}))}addStringRecordToStream(e,t,n){Hh(this,t,(t=>{Yh(this,Object.keys(e),(r=>{Yh(this,Object.values(e),(o=>{this.i._addFlatHashMapToInputStream(r,o,Object.keys(e).length,t,n)}))}))}))}addProtoToStream(e,t,n,r){Hh(this,n,(n=>{Hh(this,t,(t=>{const o=this.i._malloc(e.length);this.i.HEAPU8.set(e,o),this.i._addProtoToInputStream(o,e.length,t,n,r),this.i._free(o)}))}))}addEmptyPacketToStream(e,t){Hh(this,e,(e=>{this.i._addEmptyPacketToInputStream(e,t)}))}addBoolToInputSidePacket(e,t){Hh(this,t,(t=>{this.i._addBoolToInputSidePacket(e,t)}))}addDoubleToInputSidePacket(e,t){Hh(this,t,(t=>{this.i._addDoubleToInputSidePacket(e,t)}))}addFloatToInputSidePacket(e,t){Hh(this,t,(t=>{this.i._addFloatToInputSidePacket(e,t)}))}addIntToInputSidePacket(e,t){Hh(this,t,(t=>{this.i._addIntToInputSidePacket(e,t)}))}addStringToInputSidePacket(e,t){Hh(this,t,(t=>{Hh(this,e,(e=>{this.i._addStringToInputSidePacket(e,t)}))}))}addProtoToInputSidePacket(e,t,n){Hh(this,n,(n=>{Hh(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){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachBoolListener(e)}))}attachBoolVectorListener(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.i._attachBoolVectorListener(e)}))}attachIntListener(e,t){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachIntListener(e)}))}attachIntVectorListener(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.i._attachIntVectorListener(e)}))}attachDoubleListener(e,t){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachDoubleListener(e)}))}attachDoubleVectorListener(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.i._attachDoubleVectorListener(e)}))}attachFloatListener(e,t){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachFloatListener(e)}))}attachFloatVectorListener(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.i._attachFloatVectorListener(e)}))}attachStringListener(e,t){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachStringListener(e)}))}attachStringVectorListener(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.i._attachStringVectorListener(e)}))}attachProtoListener(e,t,n){Xh(this,e,t),Hh(this,e,(e=>{this.i._attachProtoListener(e,n||!1)}))}attachProtoVectorListener(e,t,n){Jh(this,e,t),Hh(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?'),Xh(this,e,((e,n)=>{e=new Float32Array(e.buffer,e.byteOffset,e.length/4),t(e,n)})),Hh(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 jf{get Y(){return this.i}ga(e,t,n){Hh(this,t,(t=>{const[r,o]=Kh(this,e,t);this.Y._addBoundTextureAsImageToStream(t,r,o,n)}))}S(e,t){Xh(this,e,t),Hh(this,e,(e=>{this.Y._attachImageListener(e)}))}T(e,t){Jh(this,e,t),Hh(this,e,(e=>{this.Y._attachImageVectorListener(e)}))}}));var jf,Gf=class extends Uf{};async function $f(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,o)=>{if(t&&await Wh(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(n&&(await Wh(n),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&o&&((t=self.Module).locateFile=o.locateFile,o.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=o.mainScriptUrlOrBlob)),o=await self.ModuleFactory(self.Module||o),self.ModuleFactory=self.Module=void 0,new e(o,r)})(e,n.wasmLoaderPath,n.assetLoaderPath,t,{locateFile:e=>e.endsWith(".wasm")?n.wasmBinaryPath.toString():n.assetBinaryPath&&e.endsWith(".data")?n.assetBinaryPath.toString():e}),await e.o(r),e}(e,t,n,r)}(e,n.canvas??("undefined"==typeof OffscreenCanvas||Vh()?document.createElement("canvas"):void 0),t,n)}function zf(e,t,n,r){if(e.Z){const i=new vd;if(n?.regionOfInterest){if(!e.ea)throw Error("This task doesn't support region-of-interest.");var o=n.regionOfInterest;if(o.left>=o.right||o.top>=o.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(0>o.left||0>o.top||1<o.right||1<o.bottom)throw Error("Expected RectF values to be in [0,1].");Zl(i,1,(o.left+o.right)/2),Zl(i,2,(o.top+o.bottom)/2),Zl(i,4,o.right-o.left),Zl(i,3,o.bottom-o.top)}else Zl(i,1,.5),Zl(i,2,.5),Zl(i,4,1),Zl(i,3,1);if(n?.rotationDegrees){if(0!=n?.rotationDegrees%90)throw Error("Expected rotation to be a multiple of 90°.");if(Zl(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=Yl(i,3)*r/e,o=Yl(i,4)*e/r,Zl(i,4,n),Zl(i,3,o)}}e.g.addProtoToStream(i.g(),"mediapipe.NormalizedRect",e.Z,r)}e.g.ga(t,e.da,r??performance.now()),e.finishProcessing()}function qf(e,t,n){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");zf(e,t,n,e.I+1)}function Vf(e,t,n,r){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");zf(e,t,n,r)}function Wf(e,t,n){var r=t.data;const o=t.width,i=o*(t=t.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==i)throw Error("Unsupported channel count: "+r.length/i);return e=new Bf([r],!1,e.g.i.canvas,e.O,o,t),n?e.clone():e}var Hf=class extends of{constructor(e,t,n,r){super(e),this.g=e,this.da=t,this.Z=n,this.ea=r,this.O=new pf}l(e,t=!0){if("runningMode"in e&&Xl(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.O.close(),super.close()}};Hf.prototype.close=Hf.prototype.close;var Kf=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},this.h=new Ud,e=new Od,$l(this.h,0,1,e),Zl(this.h,2,.5),Zl(this.h,3,.3)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&Zl(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&Zl(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},qf(this,e,t),this.j}G(e,t,n){return this.j={detections:[]},Vf(this,e,n,t),this.j}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect_in"),ju(e,"detections");const t=new xu;ec(t,Gd,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect_in"),_u(n,"DETECTIONS:detections"),n.o(t),Nu(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=ad(t),this.j.detections.push(Ph(e));ef(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Kf.prototype.detectForVideo=Kf.prototype.G,Kf.prototype.detect=Kf.prototype.F,Kf.prototype.setOptions=Kf.prototype.o,Kf.createFromModelPath=async function(e,t){return $f(Kf,e,{baseOptions:{modelAssetPath:t}})},Kf.createFromModelBuffer=function(e,t){return $f(Kf,e,{baseOptions:{modelAssetBuffer:t}})},Kf.createFromOptions=function(e,t){return $f(Kf,e,t)};var Yf=Nf([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]),Xf=Nf([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]),Jf=Nf([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Zf=Nf([474,475],[475,476],[476,477],[477,474]),Qf=Nf([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]),ep=Nf([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),tp=Nf([469,470],[470,471],[471,472],[472,469]),np=Nf([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]),rp=[...Yf,...Xf,...Jf,...Qf,...ep,...np],op=Nf([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 ip(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var ap=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,this.h=new Kd,e=new Od,$l(this.h,0,1,e),this.v=new Wd,$l(this.h,0,3,this.v),this.s=new Ud,$l(this.h,0,2,this.s),Jl(this.s,4,1),Zl(this.s,2,.5),Zl(this.v,2,.5),Zl(this.h,4,.5)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){return"numFaces"in e&&Jl(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&Zl(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&Zl(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&Zl(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 ip(this),qf(this,e,t),this.j}G(e,t,n){return ip(this),Vf(this,e,n,t),this.j}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"face_landmarks");const t=new xu;ec(t,Xd,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"NORM_LANDMARKS:face_landmarks"),n.o(t),Nu(e,n),this.g.attachProtoVectorListener("face_landmarks",((e,t)=>{for(const t of e)e=pd(t),this.j.faceLandmarks.push(Bh(e));ef(this,t)})),this.g.attachEmptyPacketListener("face_landmarks",(e=>{ef(this,e)})),this.outputFaceBlendshapes&&(ju(e,"blendshapes"),_u(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((e,t)=>{if(this.outputFaceBlendshapes)for(const t of e)e=Yu(t),this.j.faceBlendshapes.push(Lh(e.g()??[]));ef(this,t)})),this.g.attachEmptyPacketListener("blendshapes",(e=>{ef(this,e)}))),this.outputFacialTransformationMatrixes&&(ju(e,"face_geometry"),_u(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((e,t)=>{if(this.outputFacialTransformationMatrixes)for(const t of e)(e=Ul(qd(t),gd,2))&&this.j.facialTransformationMatrixes.push({rows:Kl(Vl(e,1))??0,columns:Kl(Vl(e,2))??0,data:Dl(e,3,Vs)??[]});ef(this,t)})),this.g.attachEmptyPacketListener("face_geometry",(e=>{ef(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ap.prototype.detectForVideo=ap.prototype.G,ap.prototype.detect=ap.prototype.F,ap.prototype.setOptions=ap.prototype.o,ap.createFromModelPath=function(e,t){return $f(ap,e,{baseOptions:{modelAssetPath:t}})},ap.createFromModelBuffer=function(e,t){return $f(ap,e,{baseOptions:{modelAssetBuffer:t}})},ap.createFromOptions=function(e,t){return $f(ap,e,t)},ap.FACE_LANDMARKS_LIPS=Yf,ap.FACE_LANDMARKS_LEFT_EYE=Xf,ap.FACE_LANDMARKS_LEFT_EYEBROW=Jf,ap.FACE_LANDMARKS_LEFT_IRIS=Zf,ap.FACE_LANDMARKS_RIGHT_EYE=Qf,ap.FACE_LANDMARKS_RIGHT_EYEBROW=ep,ap.FACE_LANDMARKS_RIGHT_IRIS=tp,ap.FACE_LANDMARKS_FACE_OVAL=np,ap.FACE_LANDMARKS_CONTOURS=rp,ap.FACE_LANDMARKS_TESSELATION=op;var sp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!0),this.j=new Jd,e=new Od,$l(this.j,0,1,e)}get baseOptions(){return Ul(this.j,Od,1)}set baseOptions(e){$l(this.j,0,1,e)}o(e){return super.l(e)}Da(e,t,n){const r="function"!=typeof t?t:{};if(this.h="function"==typeof t?t:n,qf(this,e,r??{}),!this.h)return this.s}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"stylized_image");const t=new xu;ec(t,Zd,this.j);const n=new Fu;Ru(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"STYLIZED_IMAGE:stylized_image"),n.o(t),Nu(e,n),this.g.S("stylized_image",((e,t)=>{var n=!this.h,r=e.data,o=e.width;const i=o*(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,o,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),o,e)}else if(!(r instanceof WebGLTexture))throw Error(`Unsupported format: ${r.constructor.name}`);o=new kf([r],!1,!1,this.g.i.canvas,this.O,o,e),this.s=n=n?o.clone():o,this.h&&this.h(n),ef(this,t)})),this.g.attachEmptyPacketListener("stylized_image",(e=>{this.s=null,this.h&&this.h(null),ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};sp.prototype.stylize=sp.prototype.Da,sp.prototype.setOptions=sp.prototype.o,sp.createFromModelPath=function(e,t){return $f(sp,e,{baseOptions:{modelAssetPath:t}})},sp.createFromModelBuffer=function(e,t){return $f(sp,e,{baseOptions:{modelAssetBuffer:t}})},sp.createFromOptions=function(e,t){return $f(sp,e,t)};var lp=Nf([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 cp(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function up(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 dp(e,t=!0){const n=[];for(const o of e){var r=Yu(o);e=[];for(const n of r.g())r=t&&null!=Vl(n,1)?Kl(Vl(n,1)):-1,e.push({score:Yl(n,2)??0,index:r,categoryName:Hl(n,3)??""??"",displayName:Hl(n,4)??""??""});n.push(e)}return n}var hp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.v=new uh,e=new Od,$l(this.v,0,1,e),this.C=new lh,$l(this.v,0,2,this.C),this.s=new ah,$l(this.C,0,3,this.s),this.h=new oh,$l(this.C,0,2,this.h),this.j=new nh,$l(this.v,0,3,this.j),Zl(this.h,2,.5),Zl(this.C,4,.5),Zl(this.s,2,.5)}get baseOptions(){return Ul(this.v,Od,1)}set baseOptions(e){$l(this.v,0,1,e)}o(e){if(Jl(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&Zl(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&Zl(this.C,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&Zl(this.s,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Qd,n=Mh(e.cannedGesturesClassifierOptions,Ul(this.j,Qd,3)?.h());$l(t,0,2,n),$l(this.j,0,3,t)}else void 0===e.cannedGesturesClassifierOptions&&Ul(this.j,Qd,3)?.g();return e.customGesturesClassifierOptions?($l(t=new Qd,0,2,n=Mh(e.customGesturesClassifierOptions,Ul(this.j,Qd,4)?.h())),$l(this.j,0,4,t)):void 0===e.customGesturesClassifierOptions&&Ul(this.j,Qd,4)?.g(),this.l(e)}ya(e,t){return cp(this),qf(this,e,t),up(this)}za(e,t,n){return cp(this),Vf(this,e,n,t),up(this)}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"hand_gestures"),ju(e,"hand_landmarks"),ju(e,"world_hand_landmarks"),ju(e,"handedness");const t=new xu;ec(t,fh,this.v);const n=new Fu;Ru(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"HAND_GESTURES:hand_gestures"),_u(n,"LANDMARKS:hand_landmarks"),_u(n,"WORLD_LANDMARKS:world_hand_landmarks"),_u(n,"HANDEDNESS:handedness"),n.o(t),Nu(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e){e=pd(t);const n=[];for(const t of Gl(e,dd,1))n.push({x:Yl(t,1)??0,y:Yl(t,2)??0,z:Yl(t,3)??0});this.landmarks.push(n)}ef(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{ef(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e){e=ud(t);const n=[];for(const t of Gl(e,sd,1))n.push({x:Yl(t,1)??0,y:Yl(t,2)??0,z:Yl(t,3)??0});this.worldLandmarks.push(n)}ef(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{ef(this,e)})),this.g.attachProtoVectorListener("hand_gestures",((e,t)=>{this.gestures.push(...dp(e,!1)),ef(this,t)})),this.g.attachEmptyPacketListener("hand_gestures",(e=>{ef(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{this.handedness.push(...dp(e)),ef(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function fp(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}hp.prototype.recognizeForVideo=hp.prototype.za,hp.prototype.recognize=hp.prototype.ya,hp.prototype.setOptions=hp.prototype.o,hp.createFromModelPath=function(e,t){return $f(hp,e,{baseOptions:{modelAssetPath:t}})},hp.createFromModelBuffer=function(e,t){return $f(hp,e,{baseOptions:{modelAssetBuffer:t}})},hp.createFromOptions=function(e,t){return $f(hp,e,t)},hp.HAND_CONNECTIONS=lp;var pp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.j=new lh,e=new Od,$l(this.j,0,1,e),this.s=new ah,$l(this.j,0,3,this.s),this.h=new oh,$l(this.j,0,2,this.h),Jl(this.h,3,1),Zl(this.h,2,.5),Zl(this.s,2,.5),Zl(this.j,4,.5)}get baseOptions(){return Ul(this.j,Od,1)}set baseOptions(e){$l(this.j,0,1,e)}o(e){return"numHands"in e&&Jl(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&Zl(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&Zl(this.j,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&Zl(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],qf(this,e,t),fp(this)}G(e,t,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Vf(this,e,n,t),fp(this)}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"hand_landmarks"),ju(e,"world_hand_landmarks"),ju(e,"handedness");const t=new xu;ec(t,hh,this.j);const n=new Fu;Ru(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"LANDMARKS:hand_landmarks"),_u(n,"WORLD_LANDMARKS:world_hand_landmarks"),_u(n,"HANDEDNESS:handedness"),n.o(t),Nu(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e)e=pd(t),this.landmarks.push(Bh(e));ef(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{ef(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e)e=ud(t),this.worldLandmarks.push(Oh(e));ef(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{ef(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{var n=this.handedness,r=n.push;const o=[];for(const t of e){e=Yu(t);const n=[];for(const t of e.g())n.push({score:Yl(t,2)??0,index:Kl(Vl(t,1))??-1,categoryName:Hl(t,3)??""??"",displayName:Hl(t,4)??""??""});o.push(n)}r.call(n,...o),ef(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};pp.prototype.detectForVideo=pp.prototype.G,pp.prototype.detect=pp.prototype.F,pp.prototype.setOptions=pp.prototype.o,pp.createFromModelPath=function(e,t){return $f(pp,e,{baseOptions:{modelAssetPath:t}})},pp.createFromModelBuffer=function(e,t){return $f(pp,e,{baseOptions:{modelAssetBuffer:t}})},pp.createFromOptions=function(e,t){return $f(pp,e,t)},pp.HAND_CONNECTIONS=lp;var gp=class extends Hf{constructor(e,t){super(new Gf(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},this.h=new ph,e=new Od,$l(this.h,0,1,e)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){var t=Mh(e,Ul(this.h,Rd,2));return $l(this.h,0,2,t),this.l(e)}ia(e,t){return this.j={classifications:[]},qf(this,e,t),this.j}ja(e,t,n){return this.j={classifications:[]},Vf(this,e,n,t),this.j}m(){var e=new Gu;Uu(e,"input_image"),Uu(e,"norm_rect"),ju(e,"classifications");const t=new xu;ec(t,gh,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Du(n,"IMAGE:input_image"),Du(n,"NORM_RECT:norm_rect"),_u(n,"CLASSIFICATIONS:classifications"),n.o(t),Nu(e,n),this.g.attachProtoListener("classifications",((e,t)=>{this.j=function(e){const t={classifications:Gl(e,bd,1).map((e=>Lh(Ul(e,Hu,4)?.g()??[],Kl(Vl(e,2)),Hl(e,3)??"")))};return null!=Wl(e)&&(t.timestampMs=Kl(Wl(e))),t}(xd(e)),ef(this,t)})),this.g.attachEmptyPacketListener("classifications",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};gp.prototype.classifyForVideo=gp.prototype.ja,gp.prototype.classify=gp.prototype.ia,gp.prototype.setOptions=gp.prototype.o,gp.createFromModelPath=function(e,t){return $f(gp,e,{baseOptions:{modelAssetPath:t}})},gp.createFromModelBuffer=function(e,t){return $f(gp,e,{baseOptions:{modelAssetBuffer:t}})},gp.createFromOptions=function(e,t){return $f(gp,e,t)};var mp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!0),this.h=new mh,this.embeddings={embeddings:[]},e=new Od,$l(this.h,0,1,e)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){var t=this.h,n=Ul(this.h,_d,2);return n=n?n.clone():new _d,void 0!==e.l2Normalize?Xl(n,1,e.l2Normalize):"l2Normalize"in e&&Cl(n,1),void 0!==e.quantize?Xl(n,2,e.quantize):"quantize"in e&&Cl(n,2),$l(t,0,2,n),this.l(e)}na(e,t){return qf(this,e,t),this.embeddings}oa(e,t,n){return Vf(this,e,n,t),this.embeddings}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"embeddings_out");const t=new xu;ec(t,vh,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"EMBEDDINGS:embeddings_out"),n.o(t),Nu(e,n),this.g.attachProtoListener("embeddings_out",((e,t)=>{e=Id(e),this.embeddings=function(e){return{embeddings:Gl(e,kd,1).map((e=>{const t={headIndex:Kl(Vl(e,3))??-1,headName:Hl(e,4)??""??""};if(void 0!==Nl(e,Ed,Pl(e,1)))e=Dl(e=Ul(e,Ed,Pl(e,1)),1,Vs),t.floatEmbedding=e;else{const n=new Uint8Array(0);t.quantizedEmbedding=Ul(e,Sd,Pl(e,2))?.fa()?.ha()??n}return t})),timestampMs:Kl(Wl(e))}}(e),ef(this,t)})),this.g.attachEmptyPacketListener("embeddings_out",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};mp.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Uh(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Uh(Nh(e.quantizedEmbedding),Nh(t.quantizedEmbedding))}return e},mp.prototype.embedForVideo=mp.prototype.oa,mp.prototype.embed=mp.prototype.na,mp.prototype.setOptions=mp.prototype.o,mp.createFromModelPath=function(e,t){return $f(mp,e,{baseOptions:{modelAssetPath:t}})},mp.createFromModelBuffer=function(e,t){return $f(mp,e,{baseOptions:{modelAssetBuffer:t}})},mp.createFromOptions=function(e,t){return $f(mp,e,t)};var vp=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 bp(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function yp(e){try{const t=new vp(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{rf(e)}}vp.prototype.close=vp.prototype.close;var wp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Eh,this.v=new bh,$l(this.h,0,3,this.v),e=new Od,$l(this.h,0,1,e)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?Cl(this.h,2,Js(e.displayNamesLocale)):"displayNamesLocale"in e&&Cl(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}P(){!function(e){const t=Gl(e.W(),Fu,1).filter((e=>(Hl(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&&(Ul(t[0],xu,7)?.l()?.g()??new Map).forEach(((t,n)=>{e.s[Number(n)]=Hl(t,1)??""}))}(this)}X(e,t,n){const r="function"!=typeof t?t:{};return this.j="function"==typeof t?t:n,bp(this),qf(this,e,r),yp(this)}Ca(e,t,n,r){const o="function"!=typeof n?n:{};return this.j="function"==typeof n?n:r,bp(this),Vf(this,e,o,t),yp(this)}ta(){return this.s}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect");const t=new xu;ec(t,Sh,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),n.o(t),Nu(e,n),tf(this,e),this.outputConfidenceMasks&&(ju(e,"confidence_masks"),_u(n,"CONFIDENCE_MASKS:confidence_masks"),nf(this,"confidence_masks"),this.g.T("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>Wf(this,e,!this.j))),ef(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],ef(this,e)}))),this.outputCategoryMask&&(ju(e,"category_mask"),_u(n,"CATEGORY_MASK:category_mask"),nf(this,"category_mask"),this.g.S("category_mask",((e,t)=>{this.categoryMask=Wf(this,e,!this.j),ef(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,ef(this,e)}))),ju(e,"quality_scores"),_u(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,ef(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};wp.prototype.getLabels=wp.prototype.ta,wp.prototype.segmentForVideo=wp.prototype.Ca,wp.prototype.segment=wp.prototype.X,wp.prototype.setOptions=wp.prototype.o,wp.createFromModelPath=function(e,t){return $f(wp,e,{baseOptions:{modelAssetPath:t}})},wp.createFromModelBuffer=function(e,t){return $f(wp,e,{baseOptions:{modelAssetBuffer:t}})},wp.createFromOptions=function(e,t){return $f(wp,e,t)};var xp=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){this.confidenceMasks?.forEach((e=>{e.close()})),this.categoryMask?.close()}};xp.prototype.close=xp.prototype.close;var Ep=class extends tc{constructor(e){super(e)}},Sp=[0,qc,qc,qc],kp=[0,Oc,Oc,Oc,Oc,Hc],Cp=[0,Oc,Oc,Oc,Oc,Hc,Oc,Oc],Tp=[0,Qc,Cp],Ap=[0,Qc,Tp,Qc,Sp],Ip=[0,Qc,Cp,Qc,Sp],Rp=[0,Qc,Cp,qc,qc],Dp=[0,Qc,Rp,Qc,Sp],_p=[0,Oc,Oc,Oc,Oc,Hc,Qc,Sp,Qc,Sp],Fp=[0,Oc,Oc,Oc,Oc,Hc,ou],Mp=class extends tc{constructor(e){super(e)}},Lp=[0,Oc,Oc,Hc],Pp=class extends tc{constructor(){super()}};Pp.B=[1];var Bp=class extends tc{constructor(e){super(e)}},Op=[1,2,3,4,5,6,7,8,9,10,14,15],Np=[0,tu,Cp,Op,tu,Ip,Op,tu,Tp,Op,tu,Ap,Op,tu,Lp,Op,tu,Fp,Op,tu,kp,Op,tu,[0,Jc,Oc,Oc,Oc,Hc,qc,Hc,Hc,Oc,3,Qc,Sp],Op,tu,Rp,Op,tu,Dp,Op,Oc,Qc,Sp,Jc,tu,_p,Op,tu,[0,eu,Lp],Op],Up=[0,Jc,qc,qc,Hc],jp=class extends tc{constructor(){super()}};jp.B=[1],jp.prototype.g=cu([0,eu,Np,Jc,Qc,Up]);var Gp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Eh,this.v=new bh,$l(this.h,0,3,this.v),e=new Od,$l(this.h,0,1,e)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(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)}X(e,t,n,r){const o="function"!=typeof n?n:{};this.j="function"==typeof n?n:r,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.I+1,r=new jp;const i=new Bp;var a=new Ep;if(Jl(a,1,255),$l(i,0,12,a),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var s=new Mp;Xl(s,3,!0),Zl(s,1,t.keypoint.x),Zl(s,2,t.keypoint.y),zl(i,5,Op,s)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(s of(a=new Pp,t.scribble))Xl(t=new Mp,3,!0),Zl(t,1,s.x),Zl(t,2,s.y),ql(a,Mp,t);zl(i,15,Op,a)}ql(r,Bp,i),this.g.addProtoToStream(r.g(),"drishti.RenderData","roi_in",n),qf(this,e,o);e:{try{const e=new xp(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=e;break e}this.j(e)}finally{rf(this)}l=void 0}return l}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"roi_in"),Uu(e,"norm_rect_in");const t=new xu;ec(t,Sh,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),Du(n,"IMAGE:image_in"),Du(n,"ROI:roi_in"),Du(n,"NORM_RECT:norm_rect_in"),n.o(t),Nu(e,n),tf(this,e),this.outputConfidenceMasks&&(ju(e,"confidence_masks"),_u(n,"CONFIDENCE_MASKS:confidence_masks"),nf(this,"confidence_masks"),this.g.T("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>Wf(this,e,!this.j))),ef(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],ef(this,e)}))),this.outputCategoryMask&&(ju(e,"category_mask"),_u(n,"CATEGORY_MASK:category_mask"),nf(this,"category_mask"),this.g.S("category_mask",((e,t)=>{this.categoryMask=Wf(this,e,!this.j),ef(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,ef(this,e)}))),ju(e,"quality_scores"),_u(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,ef(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Gp.prototype.segment=Gp.prototype.X,Gp.prototype.setOptions=Gp.prototype.o,Gp.createFromModelPath=function(e,t){return $f(Gp,e,{baseOptions:{modelAssetPath:t}})},Gp.createFromModelBuffer=function(e,t){return $f(Gp,e,{baseOptions:{modelAssetBuffer:t}})},Gp.createFromOptions=function(e,t){return $f(Gp,e,t)};var $p=class extends Hf{constructor(e,t){super(new Gf(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},this.h=new kh,e=new Od,$l(this.h,0,1,e)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?Cl(this.h,2,Js(e.displayNamesLocale)):"displayNamesLocale"in e&&Cl(this.h,2),void 0!==e.maxResults?Jl(this.h,3,e.maxResults):"maxResults"in e&&Cl(this.h,3),void 0!==e.scoreThreshold?Zl(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&Cl(this.h,4),void 0!==e.categoryAllowlist?Ll(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&Cl(this.h,5),void 0!==e.categoryDenylist?Ll(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&Cl(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},qf(this,e,t),this.j}G(e,t,n){return this.j={detections:[]},Vf(this,e,n,t),this.j}m(){var e=new Gu;Uu(e,"input_frame_gpu"),Uu(e,"norm_rect"),ju(e,"detections");const t=new xu;ec(t,Ch,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),Du(n,"IMAGE:input_frame_gpu"),Du(n,"NORM_RECT:norm_rect"),_u(n,"DETECTIONS:detections"),n.o(t),Nu(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=ad(t),this.j.detections.push(Ph(e));ef(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{ef(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function zp(e){e.landmarks=[],e.worldLandmarks=[],e.v=void 0}function qp(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{rf(e)}}$p.prototype.detectForVideo=$p.prototype.G,$p.prototype.detect=$p.prototype.F,$p.prototype.setOptions=$p.prototype.o,$p.createFromModelPath=async function(e,t){return $f($p,e,{baseOptions:{modelAssetPath:t}})},$p.createFromModelBuffer=function(e,t){return $f($p,e,{baseOptions:{modelAssetBuffer:t}})},$p.createFromOptions=function(e,t){return $f($p,e,t)};var Vp=class extends Hf{constructor(e,t){super(new Gf(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,this.h=new Dh,e=new Od,$l(this.h,0,1,e),this.C=new Ih,$l(this.h,0,3,this.C),this.j=new Th,$l(this.h,0,2,this.j),Jl(this.j,4,1),Zl(this.j,2,.5),Zl(this.C,2,.5),Zl(this.h,4,.5)}get baseOptions(){return Ul(this.h,Od,1)}set baseOptions(e){$l(this.h,0,1,e)}o(e){return"numPoses"in e&&Jl(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&Zl(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&Zl(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&Zl(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,zp(this),qf(this,e,r),qp(this)}G(e,t,n,r){const o="function"!=typeof n?n:{};return this.s="function"==typeof n?n:r,zp(this),Vf(this,e,o,t),qp(this)}m(){var e=new Gu;Uu(e,"image_in"),Uu(e,"norm_rect"),ju(e,"normalized_landmarks"),ju(e,"world_landmarks"),ju(e,"segmentation_masks");const t=new xu;ec(t,Fh,this.h);const n=new Fu;Ru(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Du(n,"IMAGE:image_in"),Du(n,"NORM_RECT:norm_rect"),_u(n,"NORM_LANDMARKS:normalized_landmarks"),_u(n,"WORLD_LANDMARKS:world_landmarks"),n.o(t),Nu(e,n),tf(this,e),this.g.attachProtoVectorListener("normalized_landmarks",((e,t)=>{this.landmarks=[];for(const t of e)e=pd(t),this.landmarks.push(Bh(e));ef(this,t)})),this.g.attachEmptyPacketListener("normalized_landmarks",(e=>{this.landmarks=[],ef(this,e)})),this.g.attachProtoVectorListener("world_landmarks",((e,t)=>{this.worldLandmarks=[];for(const t of e)e=ud(t),this.worldLandmarks.push(Oh(e));ef(this,t)})),this.g.attachEmptyPacketListener("world_landmarks",(e=>{this.worldLandmarks=[],ef(this,e)})),this.outputSegmentationMasks&&(_u(n,"SEGMENTATION_MASK:segmentation_masks"),nf(this,"segmentation_masks"),this.g.T("segmentation_masks",((e,t)=>{this.v=e.map((e=>Wf(this,e,!this.s))),ef(this,t)})),this.g.attachEmptyPacketListener("segmentation_masks",(e=>{this.v=[],ef(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Vp.prototype.detectForVideo=Vp.prototype.G,Vp.prototype.detect=Vp.prototype.F,Vp.prototype.setOptions=Vp.prototype.o,Vp.createFromModelPath=function(e,t){return $f(Vp,e,{baseOptions:{modelAssetPath:t}})},Vp.createFromModelBuffer=function(e,t){return $f(Vp,e,{baseOptions:{modelAssetBuffer:t}})},Vp.createFromOptions=function(e,t){return $f(Vp,e,t)},Vp.POSE_CONNECTIONS=Nf([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]);var Wp;function Hp(e,t,n,r){t.forEach((function(t){var o=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 o=1;o<t.length;o++){var i=t[o];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 a=0;a<6;a++){var s=o[a][0],l=o[a][1];e.beginPath(),e.arc(s,l,3,0,2*Math.PI),e.fill()}}}))}function Kp(){return v(this,void 0,void 0,(function(){var e;return b(this,(function(t){switch(t.label){case 0:return Wp?[2,Wp]:[4,qh.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.7/wasm")];case 1:return e=t.sent(),[4,Kf.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,Wp=t.sent()]}}))}))}var Yp,Xp,Jp=t.createContext({start:function(){return null},stop:function(){return null},onPredictionMade:function(){return null},canvasRef:{current:null},ready:!1}),Zp=function(e){var n=e.autoStart,r=void 0===n||n,o=e.children,i=e.throttleMs,a=t.useContext(tn),s=a.videoRef,l=a.videoLoaded,u=a.cameraReady,d=t.useRef(null),h=t.useRef(),f=t.useState(!1),p=f[0],g=f[1],y=t.useState(!1),w=y[0],x=y[1],E=t.useRef(null),S=t.useRef(0),k=t.useRef(0),C=t.useState(null),T=C[0],A=C[1];t.useEffect((function(){v(void 0,void 0,void 0,(function(){var e,t;return b(this,(function(n){switch(n.label){case 0:g(!1),n.label=1;case 1:return n.trys.push([1,3,,4]),e=E,[4,Kp()];case 2:return e.current=n.sent(),[3,4];case 3:return t=n.sent(),A(t),[3,4];case 4:return g(!0),[2]}}))}))}),[]),t.useEffect((function(){if(l&&u&&w&&p){var e;k.current+=1;var t=k.current;return v(void 0,void 0,void 0,(function(){var n,r,o,a;return b(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===(o=s.current)||void 0===o?void 0:o.videoWidth,d.current.height=null===(a=s.current)||void 0===a?void 0:a.videoHeight,null==n||n.translate(s.current.videoWidth,0),null==n||n.scale(-1,1)),[4,function r(){var o;return v(this,void 0,void 0,(function(){var a,l,c,u,d;return b(this,(function(f){switch(f.label){case 0:return E.current&&s.current&&t===k.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:a=s.current.videoWidth,l=s.current.videoHeight,null==n||n.drawImage(s.current,0,0,a,l),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,E.current.detectForVideo(s.current,performance.now())];case 4:return(c=f.sent())&&(u=c.detections.map((function(e){var t,n,r,o,i,s,c,u,d,h,f,p,g,v,b,y;return{keypoints:e.keypoints.map((function(e){var t;return m(m({},e),{x:e.x*a,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!==(o=null===(r=e.boundingBox)||void 0===r?void 0:r.originX)&&void 0!==o?o:0)+(null!==(s=null===(i=e.boundingBox)||void 0===i?void 0:i.width)&&void 0!==s?s:0),yMin:null!==(u=null===(c=e.boundingBox)||void 0===c?void 0:c.originY)&&void 0!==u?u:0,yMax:(null!==(h=null===(d=e.boundingBox)||void 0===d?void 0:d.originY)&&void 0!==h?h:0)+(null!==(p=null===(f=e.boundingBox)||void 0===f?void 0:f.height)&&void 0!==p?p:0),width:null!==(v=null===(g=e.boundingBox)||void 0===g?void 0:g.width)&&void 0!==v?v:0,height:null!==(y=null===(b=e.boundingBox)||void 0===b?void 0:b.height)&&void 0!==y?y:0}}})),null===(o=h.current)||void 0===o||o.call(h,u),n&&Hp(n,u,!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(){S.current=requestAnimationFrame(r)}),i):S.current=requestAnimationFrame(r),[2]}}))}))}()]):[2];case 1:return l.sent(),[2]}}))})),function(){S.current&&cancelAnimationFrame(S.current),e&&clearTimeout(e)}}}),[u,p,w,i,l,s]);var I=t.useCallback((function(){x(!0)}),[]),R=t.useCallback((function(){x(!1)}),[]);t.useEffect((function(){return r&&I(),function(){R()}}),[r,I,R]);var D=t.useCallback((function(e){h.current=e}),[]),_=t.useMemo((function(){return{start:I,stop:R,ready:p,canvasRef:d,onPredictionMade:D}}),[D,p,I,R]);return c.createElement(Jp.Provider,{value:_},T?c.createElement(Bo,{error:T}):o)},Qp=d.default.div(Yp||(Yp=w(["\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"})),eg=d.default.div(Xp||(Xp=w(["\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"})),tg=function(e,n,r,o){var i=t.useState(!1),a=i[0],s=i[1],l=t.useState(),c=l[0],u=l[1];return t.useEffect((function(){if(e){u(new Date);var t=setTimeout((function(){s(!0)}),e);return function(){t&&clearTimeout(t)}}}),[e]),t.useEffect((function(){if(a&&!r){if(o){var e=setTimeout((function(){null==n||n()}),1e4);return function(){clearTimeout(e)}}null==n||n()}}),[n,o,a,r]),{timedOut:a,timeoutStartedAt:c}},ng={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},rg=function(e,t){switch(t.type){case"configure":return m(m({},e),{videoWidth:t.payload.videoWidth,videoHeight:t.payload.videoHeight});case"capturing":return m(m({},e),{capturing:!0,captured:!1,captureFailed:!1});case"captured":return m(m({},e),{capturing:!1,captured:!0,captureFailed:!1});case"captureFailed":return m(m({},e),{capturing:!1,captured:!1,captureFailed:!0});case"facesDetected":var n=t.payload.faces,r=n[0],o=!0,i=!1,a=!1,s=!1,l=e.faceReadyAt,c=e.goodFramesCount;if(r){var u=e.videoHeight/2,d=(r.box.xMin+r.box.xMax)/2,h=(r.box.yMin+r.box.yMax)/2,f=.125*e.videoWidth,p=.125*e.videoHeight,g=.2*r.box.width,v=.2*r.box.height,b=r.keypoints[2];b&&(o=Math.abs(e.videoWidth/2-d)>f||Math.abs(u+50-h)>p,i=Math.abs(d-b.x)>g||Math.abs(h-b.y)>v);var y=e.videoWidth<e.videoHeight;a=r.box.width>e.videoWidth/(y?2:4.5),s=r.box.width<e.videoWidth/(y?6:7)}var w=!(o||i||a||s);return w?e.faceReady||(l=new Date):(l=null,c=0),m(m({},e),{faces:n,faceNotCentered:o,faceLookingAway:i,faceTooClose:a,faceTooFar:s,faceReady:w,faceReadyAt:l,goodFramesCount:c})}},og=function(e){var n,r=e.onGuidanceSatisfied,o=e.onGuidanceNotSatisfied,i=e.onSelfieCaptured,a=e.onTimeout,s=e.onExit,c=e.timeoutDurationMs,u=void 0===c?15e3:c,d=e.guidanceMessage,h=e.guidanceSatisfied,f=e.colors,p=void 0===f?{}:f,g=e.verbiage,m=void 0===g?{}:g,y=e.debugMode,w=void 0!==y&&y,x=Bt(),E=x.ref,S=x.width,k=void 0===S?1:S,C=x.height,T=void 0===C?1:C,A=t.useReducer(rg,ng),I=A[0],R=A[1],D=t.useContext(tn),_=D.cameraRef,F=D.cameraReady,M=D.takePhoto,L=D.videoRef,P=t.useContext(Jp).onPredictionMade;t.useEffect((function(){F&&L.current&&0!==L.current.videoWidth&&R({type:"configure",payload:{videoWidth:L.current.videoWidth,videoHeight:L.current.videoHeight}})}),[F,L]),t.useEffect((function(){P((function(e){R({type:"facesDetected",payload:{faces:e}})}))}),[P]);var B=t.useState(!1),O=B[0],N=B[1];t.useEffect((function(){var e;return I.faceReady?(null==r||r(),e=setTimeout((function(){N(!0)}),1e3)):null==o||o(),function(){e&&clearTimeout(e)}}),[o,r,I.faceReady]),t.useEffect((function(){v(void 0,void 0,void 0,(function(){var e,t;return b(this,(function(n){switch(n.label){case 0:return O&&I.faces.length>0?[4,M()]:[3,5];case 1:return(e=n.sent())?null!=i?[3,2]:[3,4]:[3,5];case 2:return t=i,[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]}}))}))}),[O,i,I.faces,M]);var U=tg(u,a),j=U.timedOut,G=U.timeoutStartedAt,$=ni({enabled:w,pageWidth:k,pageHeight:T,videoWidth:I.videoWidth,videoHeight:I.videoHeight});p.guidesUnsatisfiedColor||(p.guidesUnsatisfiedColor="white"),p.guidesSatisfiedColor||(p.guidesSatisfiedColor="green"),p.guidanceMessagesUnsatisfiedBackgroundColor||(p.guidanceMessagesUnsatisfiedBackgroundColor="red"),p.guidanceMessagesSatisfiedBackgroundColor||(p.guidanceMessagesSatisfiedBackgroundColor="green"),p.guidanceMessagesUnsatisfiedTextColor||(p.guidanceMessagesUnsatisfiedTextColor="white"),p.guidanceMessagesSatisfiedTextColor||(p.guidanceMessagesSatisfiedTextColor="white");var z=xi(m,{guidanceHoldStillText:"Hold still for a few seconds...",guidanceLookStraightText:"Look straight into the camera...",guidanceMoveBackText:"Move back...",guidanceMoveForwardText:"Move forward...",guidanceMoveToCenterText:"Move to the center..."});d||(d=I.faceReady?z.guidanceHoldStillText:I.faceLookingAway?z.guidanceLookStraightText:I.faceTooClose?z.guidanceMoveBackText:I.faceTooFar?z.guidanceMoveForwardText:I.faceNotCentered?z.guidanceMoveToCenterText:"");var q=I.faceReady;return"boolean"==typeof h&&(q=h),l.default.createElement(ot,{ref:E,className:"flex"},l.default.createElement(Fi,null),l.default.createElement(Ni,{borderColor:q?p.guidesSatisfiedColor:p.guidesUnsatisfiedColor}),""!==d&&l.default.createElement(Qp,null,l.default.createElement(eg,{$background:q?p.guidanceMessagesSatisfiedBackgroundColor:p.guidanceMessagesUnsatisfiedBackgroundColor,$textColor:q?p.guidanceMessagesSatisfiedTextColor:p.guidanceMessagesUnsatisfiedTextColor},d)),w&&I.faces.length>0&&l.default.createElement(Qo,{$flipX:!(null===(n=_.current)||void 0===n?void 0:n.isRearFacing)},I.faces.map((function(e,t){var n;return l.default.createElement(oi,{key:t,face:e,scaling:$,flipX:!(null===(n=_.current)||void 0===n?void 0:n.isRearFacing),color:q?"green":"red"})}))),w&&l.default.createElement(Zo,null,_.current?l.default.createElement(l.default.Fragment,null,"✅ Camera: ",_.current.label," (",_.current.width,"x",_.current.height,")"):"❌ Camera not ready",l.default.createElement("br",null),I.faceNotCentered?"❌":"✅"," Face Centered",l.default.createElement("br",null),I.faceTooClose||I.faceTooFar?"❌":"✅"," Face"," ",I.faceTooClose?"Too Close":I.faceTooFar?"Too Far":"Distance Correct",l.default.createElement("br",null),I.faceLookingAway?"❌":"✅"," Face Looking Forward",l.default.createElement("br",null),I.goodFramesThresholdMet?"✅":"❌"," ",I.goodFramesCount," ","Good Frames",l.default.createElement("br",null),j?"❌":"✅"," Time Remaining:"," ",Math.max(0,u-((new Date).getTime()-(null!=G?G:new Date).getTime())),"ms"),l.default.createElement(di,{onClick:s},"×"))},ig={frame:null,face:null,requestState:"CAPTURING",requestError:null,imageUrl:null,faceLive:!1,eyeCoveringDetected:!1,maskDetected:!1,headCoveringDetected:!1,phoneDetected:!1,timesLivenessCheckFailed:0},ag=function(e,t){switch(t.type){case"livenessReady":return["CAPTURING","FAILED","ERROR"].includes(e.requestState)?m(m({},e),{requestState:"CAPTURED",frame:t.payload.frame,face:t.payload.face}):e;case"livenessChecking":return m(m({},e),{requestState:"IN_PROGRESS"});case"livenessChecked":var n=t.payload.response,r=n.status,o=r.statusMessage,i=r.errorData,a=n.resultData;if("000"!==r.statusCode)return m(m({},e),{requestState:"ERROR",requestError:new Error("".concat(o,": ").concat(i))});var s="Live Face Detected"===a.verificationResult,l="true"===a.eyeCovering,c="true"===a.faceMask,u="true"===a.headCovering,d="true"===a.cellPhone,h=s&&!l&&!c&&!u,f=h?"PASSED":"FAILED",p=e.timesLivenessCheckFailed;return h?p=0:p+=1,m(m({},e),{frame:t.payload.frame,face:t.payload.face,imageUrl:t.payload.imageUrl,requestState:f,faceLive:s,eyeCoveringDetected:l,maskDetected:c,headCoveringDetected:u,phoneDetected:d,timesLivenessCheckFailed:p});case"livenessCheckFailed":return m(m({},e),{requestState:"ERROR",requestError:t.payload.error});default:return e}},sg=function(e){var n=e.onCapture,r=e.onSuccess,o=e.onTimeout,i=e.onExit,a=e.timeoutDurationMs,s=void 0===a?15e3:a,c=e.colors,u=void 0===c?{}:c,d=e.verbiage,h=void 0===d?{}:d,f=e.debugMode,p=t.useContext(Ye),g=p.checkLiveness,m=p.submissionError,y=t.useReducer(ag,ig),w=y[0],x=y[1],E=t.useState(null),S=E[0],k=E[1],C=t.useCallback((function(e,t){null==n||n(),x({type:"livenessReady",payload:{frame:e,face:t}})}),[n]),T=w.frame,A=w.face,I="CAPTURED"===w.requestState,R="PASSED"===w.requestState;t.useEffect((function(){T&&A&&I&&!m&&(x({type:"livenessChecking"}),v(void 0,void 0,void 0,(function(){var e,t,n,r;return b(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),e=Po(T,A),k(e),n=g,[4,Qe(e)];case 1:return[4,n.apply(void 0,[o.sent()])];case 2:return t=o.sent(),x({type:"livenessChecked",payload:{frame:T,face:A,imageUrl:e,response:t}}),[3,4];case 3:return r=o.sent(),x({type:"livenessCheckFailed",payload:{error:r}}),[3,4];case 4:return[2]}}))})))}),[g,A,T,I,m]),t.useEffect((function(){R&&w.imageUrl&&(null==r||r(w.imageUrl))}),[r,w.imageUrl,R]),t.useEffect((function(){w.timesLivenessCheckFailed>=2&&(null==o||o())}),[o,w.timesLivenessCheckFailed]),tg(s,o,"PASSED"===w.requestState,"IN_PROGRESS"===w.requestState);var D=xi(h,{guidanceRemoveEyeCoveringsText:"Please remove your eye coverings (sunglasses, eye patch, etc.)...",guidanceRemoveHeadCoveringsText:"Please remove your head coverings (hat, scarf, etc.)...",guidanceRemoveMaskText:"Please remove your mask..."}),_=w.eyeCoveringDetected?D.guidanceRemoveEyeCoveringsText:w.headCoveringDetected?D.guidanceRemoveHeadCoveringsText:w.maskDetected?D.guidanceRemoveMaskText:void 0;return l.default.createElement(l.default.Fragment,null,l.default.createElement(og,{onSelfieCaptured:C,onExit:i,timeoutDurationMs:s,guidanceMessage:_,guidanceSatisfied:!_&&void 0,colors:u,verbiage:D,debugMode:f}),S&&l.default.createElement(pi,{imageUrl:S}))},lg=function(e){var n=e.onDismissed,r=e.assets,o=void 0===r?{}:r,i=e.colors,a=void 0===i?{}:i,s=e.verbiage,c=void 0===s?{}:s,u=t.useContext(tn),d=u.cameraReady,h=u.cameraAccessDenied,f=t.useContext(Jp).ready;o.instructionImageUrl||(o.instructionImageUrl="".concat(Mo,"/Selfie-Image-1.png"));var p=xi(c,{headingText:"Use your device camera to capture your face",removeEyeCoveringsText:"Remove Sunglasses & Hat",avoidExcessiveBacklightingText:"Avoid Excessive Backlighting",continueText:"Continue",cameraInitializingText:"Camera initializing...",modelsWarmingUpText:"Models warming up..."}),g=t.useState(!1),m=g[1];return g[0]?l.default.createElement(l.default.Fragment,null):h?l.default.createElement(Ii,{assets:o.cameraAccessDenied,colors:a.cameraAccessDenied,verbiage:c.cameraAccessDenied}):l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("div",{style:{flexGrow:0}},l.default.createElement("h3",{style:{marginBottom:18}},p.headingText),l.default.createElement("div",{style:{background:"#ccc",maxWidth:"280px",margin:"0 auto 12px",borderRadius:8,lineHeight:1.5,padding:"12px 24px"}},p.removeEyeCoveringsText,l.default.createElement("br",null),p.avoidExcessiveBacklightingText)),l.default.createElement(dt,null,l.default.createElement("img",{alt:p.headingText,src:o.instructionImageUrl,style:{position:"relative",top:"5%"}})),l.default.createElement(kt,{disabled:!d||!f,finished:d&&f,colors:a.continueBtn,onClick:function(){m(!0),null==n||n()}},d&&f?p.continueText:f?p.cameraInitializingText:p.modelsWarmingUpText),l.default.createElement("div",{style:{display:"none"}},l.default.createElement(Fi,null))))},cg=function(e){var t,n,r=e.imageUrl,o=e.onDoneClick,i=e.onRetryClick,a=e.colors,s=void 0===a?{}:a,c=e.verbiage,u=void 0===c?{}:c;s.retryBtn||(s.retryBtn={}),(t=s.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=s.retryBtn).textColor||(n.textColor="white");var d=xi(u,{headingText:"Face liveness has been verified!",retryBtnText:"Retry",doneBtnText:"Done"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},d.headingText),l.default.createElement(dt,null,l.default.createElement("img",{alt:d.headingText,src:r})),l.default.createElement("div",null,l.default.createElement(kt,{onClick:i,colors:s.retryBtn,finished:!0},d.retryBtnText),l.default.createElement(kt,{onClick:o,colors:s.doneBtn,style:{marginLeft:15},finished:!0},d.doneBtnText))))},ug=function(e){var t,n,r,o,i=e.canRetry,a=void 0===i||i,s=e.onRetryClick,c=e.onExitClick,u=e.assets,d=void 0===u?{}:u,h=e.colors,f=void 0===h?{}:h,p=e.verbiage,g=void 0===p?{}:p;d.imageUrl||(d.imageUrl="".concat(Mo,"/manual_capture.png")),f.retryBtn||(f.retryBtn={}),(t=f.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=f.retryBtn).textColor||(n.textColor="white"),f.exitBtn||(f.exitBtn={}),(r=f.exitBtn).backgroundColor||(r.backgroundColor="#666"),(o=f.exitBtn).textColor||(o.textColor="white");var m=xi(g,{headingText:"Live face not detected, please try again",retryBtnText:"Retry",exitBtnText:"Exit"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},m.headingText),l.default.createElement(dt,{style:{maxHeight:"calc(100vh - 185px)"}},l.default.createElement("img",{alt:m.headingText,src:d.imageUrl})),l.default.createElement("div",{style:{marginTop:24}},a&&l.default.createElement(kt,{onClick:s,colors:f.retryBtn,style:{marginRight:15},finished:!0},m.retryBtnText),l.default.createElement(kt,{onClick:c,colors:f.exitBtn,finished:!0},m.exitBtnText))))},dg=function(e){var n=e.onComplete,r=e.onSuccess,o=e.onTimeout,i=e.onExitAfterFailure,a=e.timeoutDurationMs,s=void 0===a?15e3:a,c=e.maxRetries,u=void 0===c?2:c,d=e.skipSuccessScreen,h=void 0!==d&&d,f=e.assets,p=void 0===f?{}:f,g=e.colors,m=void 0===g?{}:g,y=e.verbiage,w=void 0===y?{}:y,x=e.debugMode,E=void 0!==x&&x,S=t.useContext(Ye),k=S.submissionResponse,C=S.setSelfieImage,T=S.logSelfieCaptureAttempt,A=t.useContext(tn).releaseCameraAccess,I=t.useState(""),R=I[0],D=I[1],_=t.useState(0),F=_[0],M=_[1],L=t.useState("LOADING"),P=L[0],B=L[1],O=t.useRef(),N=t.useRef(),U=t.useRef();t.useEffect((function(){U.current=new Date}),[]),t.useEffect((function(){"CAPTURING"===P&&(O.current=new Date)}),[P]);var j=t.useCallback((function(){N.current=new Date}),[]),G=t.useCallback((function(){var e,t,n;T({autoCapture:"Y",captureTime:(null!==(e=N.current)&&void 0!==e?e:new Date).getTime()-(null!==(t=O.current)&&void 0!==t?t:new Date).getTime(),operationTime:(new Date).getTime()-(null!==(n=U.current)&&void 0!==n?n:new Date).getTime()}),U.current=new Date}),[T]),$=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){var t;return b(this,(function(n){switch(n.label){case 0:return B("SUCCESS"),D(e),t=C,[4,Qe(e)];case 1:return t.apply(void 0,[n.sent()]),null==r||r(k),[2]}}))}))}),[r,C,k]),z=t.useCallback((function(){B("FAILED"),null==o||o(k)}),[o,k]),q=t.useState(0),V=q[0],W=q[1],H=t.useCallback((function(){W((function(e){return e+1})),B("LOADING")}),[]),K=t.useCallback((function(){G(),A(),setTimeout((function(){null==n||n(k)}),0)}),[G,n,A,k]),Y=Li(h,"SUCCESS"===P,K);return l.default.createElement(l.default.Fragment,null,"LOADING"!==P&&function(){switch(P){case"CAPTURING":return l.default.createElement(sg,{key:"capture".concat(V),onCapture:j,onSuccess:$,onTimeout:z,onExit:H,timeoutDurationMs:s,colors:m,verbiage:w,debugMode:E});case"SUCCESS":return Y?l.default.createElement(cg,{key:"success",imageUrl:R,colors:m.success,verbiage:w.success,onDoneClick:K,onRetryClick:function(){G(),B("CAPTURING")}}):null;case"FAILED":return l.default.createElement(ug,{key:"failure",assets:p.failure,colors:m.failure,verbiage:w.failure,canRetry:u>-1&&F<u,onRetryClick:function(){G(),M((function(e){return e+1})),B("CAPTURING")},onExitClick:function(){A(),setTimeout((function(){null==i||i(k)}),0)}});default:return null}}(),l.default.createElement(lg,{key:V,assets:p.loadingOverlay,colors:m.loadingOverlay,verbiage:w.loadingOverlay,onDismissed:function(){B("CAPTURING")}}))},hg=function(e){var n=e.children,r=t.useState({width:1,height:1}),o=r[1],i=t.useState(1),a=i[0],s=i[1],c=Bt(),u=c.ref,d=c.width,h=void 0===d?1:d,f=c.height,p=void 0===f?1:f,g=h/p,m=t.useCallback((function(e){var t=e.target;s(t.naturalWidth/t.naturalHeight)}),[]);return l.default.createElement(Ot.Provider,{value:{orientation:"landscape",wrapperWidth:h,wrapperHeight:p,wrapperAspectRatio:g,imageAspectRatio:a,setDimensions:o,wrapperRef:u,onImageLoaded:m}},n)},fg=function(){var e=t.useContext(Ye),n=e.submissionRequest,r=e.submissionResponse,o=t.useState(!1),i=o[0],a=o[1],s=t.useState(!0),c=s[0],u=s[1],d=t.useMemo((function(){var e,t,r,o,i,a,s=JSON.parse(JSON.stringify(n));return c&&((null===(t=null===(e=null==s?void 0:s.customerData)||void 0===e?void 0:e.idData)||void 0===t?void 0:t.idImageFront)&&(s.customerData.idData.idImageFront=pg(s.customerData.idData.idImageFront,200)),(null===(o=null===(r=null==s?void 0:s.customerData)||void 0===r?void 0:r.idData)||void 0===o?void 0:o.idImageBack)&&(s.customerData.idData.idImageBack=pg(s.customerData.idData.idImageBack,200)),(null===(a=null===(i=null==s?void 0:s.customerData)||void 0===i?void 0:i.biometricData)||void 0===a?void 0:a.selfie)&&(s.customerData.biometricData.selfie=pg(s.customerData.biometricData.selfie,200))),JSON.stringify(s,null,2)}),[n,c]);return l.default.createElement(l.default.Fragment,null,l.default.createElement("h3",null,"Submission completed!"),l.default.createElement("button",{onClick:function(){a(!i)}},i?"Hide":"Show"," request body"),i&&l.default.createElement(l.default.Fragment,null,l.default.createElement("button",{style:{marginLeft:8},onClick:function(){u(!c)}},c?"Display full images":"Truncate images"),l.default.createElement("h5",null,"Request Body"),l.default.createElement("pre",null,d)),l.default.createElement("h5",null,"Response Body"),l.default.createElement("pre",null,JSON.stringify(r,null,2)))};function pg(e,t){var n=e.split("").splice(0,t).join("");return n.length<e.length&&(n+="..."),n}var gg=function(e){var n=e.document,r=e.onComplete,o=e.verbiage,i=void 0===o?{}:o,a=t.useState(null),s=a[0],c=a[1],u=xi(i,{headingText:"Additional document capture",nextBtnText:"Next"});return l.default.createElement(ct,null,l.default.createElement(ut,{style:{textAlign:"left"}},l.default.createElement("h3",{style:{margin:"0 0 8px"}},u.headingText,": ",n.name),n.description&&l.default.createElement("p",{style:{margin:"8px 0"}},n.description),l.default.createElement("p",{style:{margin:"8px 0"}},l.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)}})),l.default.createElement("p",{style:{margin:"8px 0"}},l.default.createElement("button",{disabled:!s,onClick:function(e){if(e.preventDefault(),s){var t=new FileReader;t.onloadend=function(){if(t.result){var e=t.result.toString();null==r||r({documentName:n.name,additionalDocument:{name:s.name,fileContent:et(e),type:tt(e),fileUploadType:"Y",isImageControlData:"N",fieldId:""}})}},t.readAsDataURL(s)}}},u.nextBtnText))))},mg=function(e){var n=e.documents,r=e.onComplete,o=e.verbiage,i=void 0===o?{}:o,a=t.useState([]),s=a[0],c=a[1],u=s.length,d=n[u],h=u>=n.length;return t.useEffect((function(){(null==d?void 0:d.skip)&&v(void 0,void 0,void 0,(function(){var e;return b(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()&&c((function(e){return y(y([],e,!0),[null],!1)})),[2]}}))}))}),[d]),t.useEffect((function(){h&&(null==r||r(s.filter((function(e){return!!e}))))}),[h,r,s]),h?l.default.createElement(l.default.Fragment,null,"Thanks, your documents have been received."):l.default.createElement(gg,{key:u,document:d,verbiage:i,onComplete:function(e){c((function(t){return y(y([],t,!0),[e],!1)}))}})},vg="function"==typeof Symbol&&Symbol.for,bg=vg?Symbol.for("react.element"):60103,yg=vg?Symbol.for("react.portal"):60106,wg=vg?Symbol.for("react.fragment"):60107,xg=vg?Symbol.for("react.strict_mode"):60108,Eg=vg?Symbol.for("react.profiler"):60114,Sg=vg?Symbol.for("react.provider"):60109,kg=vg?Symbol.for("react.context"):60110,Cg=vg?Symbol.for("react.async_mode"):60111,Tg=vg?Symbol.for("react.concurrent_mode"):60111,Ag=vg?Symbol.for("react.forward_ref"):60112,Ig=vg?Symbol.for("react.suspense"):60113,Rg=vg?Symbol.for("react.suspense_list"):60120,Dg=vg?Symbol.for("react.memo"):60115,_g=vg?Symbol.for("react.lazy"):60116,Fg=vg?Symbol.for("react.block"):60121,Mg=vg?Symbol.for("react.fundamental"):60117,Lg=vg?Symbol.for("react.responder"):60118,Pg=vg?Symbol.for("react.scope"):60119;function Bg(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case bg:switch(e=e.type){case Cg:case Tg:case wg:case Eg:case xg:case Ig:return e;default:switch(e=e&&e.$$typeof){case kg:case Ag:case _g:case Dg:case Sg:return e;default:return t}}case yg:return t}}}function Og(e){return Bg(e)===Tg}var Ng={AsyncMode:Cg,ConcurrentMode:Tg,ContextConsumer:kg,ContextProvider:Sg,Element:bg,ForwardRef:Ag,Fragment:wg,Lazy:_g,Memo:Dg,Portal:yg,Profiler:Eg,StrictMode:xg,Suspense:Ig,isAsyncMode:function(e){return Og(e)||Bg(e)===Cg},isConcurrentMode:Og,isContextConsumer:function(e){return Bg(e)===kg},isContextProvider:function(e){return Bg(e)===Sg},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===bg},isForwardRef:function(e){return Bg(e)===Ag},isFragment:function(e){return Bg(e)===wg},isLazy:function(e){return Bg(e)===_g},isMemo:function(e){return Bg(e)===Dg},isPortal:function(e){return Bg(e)===yg},isProfiler:function(e){return Bg(e)===Eg},isStrictMode:function(e){return Bg(e)===xg},isSuspense:function(e){return Bg(e)===Ig},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===wg||e===Tg||e===Eg||e===xg||e===Ig||e===Rg||"object"==typeof e&&null!==e&&(e.$$typeof===_g||e.$$typeof===Dg||e.$$typeof===Sg||e.$$typeof===kg||e.$$typeof===Ag||e.$$typeof===Mg||e.$$typeof===Lg||e.$$typeof===Pg||e.$$typeof===Fg)},typeOf:Bg};ae((function(e,t){}));ae((function(e){e.exports=Ng}));function Ug(){}function jg(){}jg.resetWarningCache=Ug;var Gg=ae((function(e){e.exports=function(){function e(e,t,n,r,o,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var a=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 a.name="Invariant Violation",a}}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:jg,resetWarningCache:Ug};return n.PropTypes=n,n}()}));function $g(e,t,n){this.x=e,this.y=t,this.time=n||(new Date).getTime()}function zg(e,t,n,r){this.startPoint=e,this.control1=t,this.control2=n,this.endPoint=r}function qg(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,o,i,a=null,s=0;n||(n={});var l=function(){s=!1===n.leading?0:Date.now(),a=null,i=e.apply(r,o),a||(r=o=null)};return function(){var c=Date.now();s||!1!==n.leading||(s=c);var u=t-(c-s);return r=this,o=arguments,u<=0||u>t?(a&&(clearTimeout(a),a=null),s=c,i=e.apply(r,o),a||(r=o=null)):a||!1===n.trailing||(a=setTimeout(l,u)),i}}(qg.prototype._strokeUpdate,this.throttle):qg.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()}$g.prototype.velocityFrom=function(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):1},$g.prototype.distanceTo=function(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))},$g.prototype.equals=function(e){return this.x===e.x&&this.y===e.y&&this.time===e.time},zg.prototype.length=function(){for(var e=0,t=void 0,n=void 0,r=0;r<=10;r+=1){var o=r/10,i=this._point(o,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),a=this._point(o,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){var s=i-t,l=a-n;e+=Math.sqrt(s*s+l*l)}t=i,n=a}return e},zg.prototype._point=function(e,t,n,r,o){return t*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*r*(1-e)*e*e+o*e*e*e},qg.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},qg.prototype.fromDataURL=function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new Image,o=n.ratio||window.devicePixelRatio||1,i=n.width||this._canvas.width/o,a=n.height||this._canvas.height/o;this._reset(),r.src=e,r.onload=function(){t._ctx.drawImage(r,0,0,i,a)},this._isEmpty=!1},qg.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),o=1;o<n;o++)r[o-1]=arguments[o];return(t=this._canvas).toDataURL.apply(t,[e].concat(r))},qg.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},qg.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)},qg.prototype.isEmpty=function(){return this._isEmpty},qg.prototype._strokeBegin=function(e){this._data.push([]),this._reset(),this._strokeUpdate(e),"function"==typeof this.onBegin&&this.onBegin(e)},qg.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],o=r&&t.distanceTo(r)<this.minDistance;if(!r||!o){var i=this._addPoint(t),a=i.curve,s=i.widths;a&&s&&this._drawCurve(a,s.start,s.end),this._data[this._data.length-1].push({x:t.x,y:t.y,time:t.time,color:this.penColor})}},qg.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)},qg.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)},qg.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)},qg.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._ctx.fillStyle=this.penColor},qg.prototype._createPoint=function(e,t,n){var r=this._canvas.getBoundingClientRect();return new $g(e-r.left,t-r.top,n||(new Date).getTime())},qg.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 o=new zg(t[1],r,n.c1,t[2]),i=this._calculateCurveWidths(o);return t.shift(),{curve:o,widths:i}}return{}},qg.prototype._calculateCurveControlPoints=function(e,t,n){var r=e.x-t.x,o=e.y-t.y,i=t.x-n.x,a=t.y-n.y,s=(e.x+t.x)/2,l=(e.y+t.y)/2,c=(t.x+n.x)/2,u=(t.y+n.y)/2,d=Math.sqrt(r*r+o*o),h=Math.sqrt(i*i+a*a),f=h/(d+h),p=t.x-(c+(s-c)*f),g=t.y-(u+(l-u)*f);return{c1:new $g(s+p,l+g),c2:new $g(c+p,u+g)}},qg.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},qg.prototype._strokeWidth=function(e){return Math.max(this.maxWidth/(e+1),this.minWidth)},qg.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},qg.prototype._drawCurve=function(e,t,n){var r=this._ctx,o=n-t,i=Math.floor(e.length());r.beginPath();for(var a=0;a<i;a+=1){var s=a/i,l=s*s,c=l*s,u=1-s,d=u*u,h=d*u,f=h*e.startPoint.x;f+=3*d*s*e.control1.x,f+=3*u*l*e.control2.x;var p=h*e.startPoint.y;p+=3*d*s*e.control1.y,p+=3*u*l*e.control2.y,this._drawPoint(f+=c*e.endPoint.x,p+=c*e.endPoint.y,t+c*o)}r.closePath(),r.fill()},qg.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()},qg.prototype._fromData=function(e,t,n){for(var r=0;r<e.length;r+=1){var o=e[r];if(o.length>1)for(var i=0;i<o.length;i+=1){var a=o[i],s=new $g(a.x,a.y,a.time),l=a.color;if(0===i)this.penColor=l,this._reset(),this._addPoint(s);else if(i!==o.length-1){var c=this._addPoint(s),u=c.curve,d=c.widths;u&&d&&t(u,d,l)}}else this._reset(),n(o[0])}},qg.prototype._toSVG=function(){var e=this,t=this._data,n=this._canvas,r=Math.max(window.devicePixelRatio||1,1),o=n.width/r,i=n.height/r,a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttributeNS(null,"width",n.width),a.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 o="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",o),r.setAttribute("stroke-width",(2.25*t.end).toFixed(3)),r.setAttribute("stroke",n),r.setAttribute("fill","none"),r.setAttribute("stroke-linecap","round"),a.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),a.appendChild(n)}));var s='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 '+o+" "+i+'" width="'+o+'" height="'+i+'">',l=a.innerHTML;if(void 0===l){var c=document.createElement("dummy"),u=a.childNodes;c.innerHTML="";for(var d=0;d<u.length;d+=1)c.appendChild(u[d].cloneNode(!0));l=c.innerHTML}return"data:image/svg+xml;base64,"+btoa(s+l+"</svg>")},qg.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},qg.prototype.toData=function(){return this._data};var Vg=Object.freeze({__proto__:null,default:qg}),Wg=ae((function(e,t){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.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,o=t.getImageData(0,0,n,r).data,s=i(!0,n,r,o),l=i(!1,n,r,o),c=a(!0,n,r,o),u=a(!1,n,r,o)-c+1,d=l-s+1,h=t.getImageData(c,s,u,d);return e.width=u,e.height=d,t.clearRect(0,0,u,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 o(e,t,n,o){return r(e,t,n,o).alpha}function i(e,t,n,r){for(var i=e?1:-1,a=e?0:n-1;e?a<n:a>-1;a+=i)for(var s=0;s<t;s++)if(o(s,a,t,r))return a;return null}function a(e,t,n,r){for(var i=e?1:-1,a=e?0:t-1;e?a<t:a>-1;a+=i)for(var s=0;s<n;s++)if(o(a,s,t,r))return a;return null}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n}])}));ie(Wg);var Hg=function(e){return e&&e.default||e}(Vg),Kg=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 o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.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 o(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 a(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},c=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}}(),u=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),c=0;c<s;c++)l[c]=arguments[c];return n=r=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(l))),r._sigPad=null,r._excludeOurProps=function(){var e=r.props;return o(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 o=r._canvas,i=Math.max(window.devicePixelRatio||1,1);t||(o.width=o.offsetWidth*i),n||(o.height=o.offsetHeight*i),o.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()},a(r,n)}return s(t,e),c(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:u.default.number,minWidth:u.default.number,maxWidth:u.default.number,minDistance:u.default.number,dotSize:u.default.oneOfType([u.default.number,u.default.func]),penColor:u.default.string,throttle:u.default.number,onEnd:u.default.func,onBegin:u.default.func,canvasProps:u.default.object,clearOnResize:u.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}])}(Gg,l.default,Hg,Wg)})),Yg=ie(Kg);function Xg(e){var t,n=null!==(t=e.toDataURL())&&void 0!==t?t:null,r={clickX_simple:[],clickY_simple:[],time_simple:[],pressure:"",fileContent:n?et(n):""};return e.toData().forEach((function(e){var t=[],n=[],o=[];e.forEach((function(e){t.push(e.x),n.push(e.y),o.push(new Date(e.time).toString())})),r.clickX_simple.push(t),r.clickY_simple.push(n),r.time_simple.push(o)})),r}var Jg,Zg,Qg,em,tm,nm=d.default.div(Jg||(Jg=w(["\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"]))),rm=d.default.div(Zg||(Zg=w(["\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"]))),om=d.default.div(Qg||(Qg=w(["\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"]))),im=d.default.div(em||(em=w(["\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"]))),am=function(e){var n=e.onAccept,r=e.verbiage,o=void 0===r?{}:r,i=Bt(),a=i.ref,s=i.width,c=i.height,u=t.useRef(null),d=xi(o,{headingText:"Please sign the box below",acceptBtnText:"Accept",clearBtnText:"Clear"});return l.default.createElement(ot,null,l.default.createElement(im,null,l.default.createElement(Qp,{$top:"5vh"},l.default.createElement(eg,null,d.headingText)),l.default.createElement(nm,null,l.default.createElement(rm,{ref:a},l.default.createElement(Yg,{ref:u,canvasProps:{width:s,height:c}})),l.default.createElement(om,null,l.default.createElement("button",{onClick:function(e){var t;e.preventDefault(),null===(t=u.current)||void 0===t||t.clear()}},d.clearBtnText),l.default.createElement("button",{style:{marginLeft:"auto"},onClick:function(e){if(e.preventDefault(),u.current){var t=Xg(u.current);null==n||n(t,u.current.toDataURL())}}},d.acceptBtnText)))))},sm=function(e){var n,r,o=e.onVideoCaptured,i=e.onFaceNotDetected,a=e.onExit,s=e.colors,c=void 0===s?{}:s,u=e.verbiage,d=void 0===u?{}:u,h=e.debugMode,f=void 0!==h&&h,p=t.useContext(tn),g=p.cameraRef,m=p.videoRef,w=Bt(),x=w.ref,E=w.width,S=w.height,k=t.useRef(null),C=t.useRef(null),T=t.useRef([]),A=t.useState(null),I=A[0],R=A[1],D=t.useContext(Jp).onPredictionMade,_=function(e){var n=t.useRef(null),r=t.useRef([]),o=t.useState(null),i=o[0],a=o[1],s=t.useState(!1),l=s[0],c=s[1],u=null==e?void 0:e.stream,d=t.useCallback((function(){u&&(r.current=[],c(!0),n.current=new MediaRecorder(u),n.current.ondataavailable=function(e){r.current.push(e.data)},n.current.onstop=function(){var t=new Blob(r.current,{type:"video/mp4"});r.current=[],a(URL.createObjectURL(t)),c(!1),null==e||e.release()},n.current.start())}),[e,u]),h=t.useCallback((function(){var e;null===(e=n.current)||void 0===e||e.stop()}),[]);return{isRecording:l,startRecording:d,stopRecording:h,videoUrl:i}}(g.current),F=_.isRecording,M=_.startRecording,L=_.stopRecording,P=_.videoUrl,B=t.useState(null),O=B[0],N=B[1],U=t.useState(null),j=U[0],G=U[1],$=t.useState(null),z=$[0],q=$[1];c.guidanceMessageBackgroundColor||(c.guidanceMessageBackgroundColor="#ccc"),c.guidanceMessageTextColor||(c.guidanceMessageTextColor="black");var V=xi(d,{guidanceMessageText:"Please sign the box below",acceptBtnText:"Accept",clearBtnText:"Clear"}),W=t.useRef(null);t.useEffect((function(){setTimeout((function(){if(!F&&!P&&W.current){M();var e=W.current.captureStream(25);C.current=new MediaRecorder(e,{}),C.current.start(),C.current.ondataavailable=function(e){var t;T.current.push(e.data),"recording"===(null===(t=C.current)||void 0===t?void 0:t.state)&&C.current.stop()},C.current.onstop=function(){var e=new Blob(T.current,{type:"video/mp4"});q(e);var t=URL.createObjectURL(e);R(t)}}}),100)}),[F,M,P]),t.useEffect((function(){z&&O&&j&&(null==o||o(z,O,j))}),[o,O,j,z]);var H=t.useRef(0);t.useEffect((function(){var e;if(k.current&&m.current&&W.current&&g.current&&F){var t=[g.current.width,g.current.height],n=t[0],r=t[1],o=window.innerWidth<window.innerHeight;o&&n>r&&(n=(e=[r,n])[0],r=e[1]),W.current.width=n,W.current.height=r;var i=W.current.getContext("2d");if(i)return H.current=requestAnimationFrame((function e(){return v(this,void 0,void 0,(function(){var t;return b(this,(function(a){return k.current&&m.current&&W.current?(t=[n*(o?.02:.15),r*(o?.15:.25),n*(o?.96:.7),r*(o?.7:.5)],i.drawImage(m.current,0,0,n,r),i.beginPath(),i.fillStyle="rgba(255,255,255,0.5)",i.roundRect.apply(i,y(y([],t,!1),[16],!1)),i.fill(),i.drawImage.apply(i,y([k.current.getCanvas()],t,!1)),H.current=requestAnimationFrame(e),[2]):(cancelAnimationFrame(H.current),[2])}))}))})),function(){cancelAnimationFrame(H.current)}}}),[g,F,i,m]);var K=t.useState(0),Y=K[0],X=K[1];return t.useEffect((function(){D((function(e){X((function(t){return 0===e.length?t+1:0}))}))}),[D]),t.useEffect((function(){Y>=2&&(null==i||i())}),[Y,i]),!F&&P?l.default.createElement(l.default.Fragment,null,I&&l.default.createElement("video",{src:I,controls:!0,width:"100%"}),j&&l.default.createElement("img",{src:j,alt:"signature"}),O&&l.default.createElement("textarea",{readOnly:!0,style:{width:"100%",height:500},value:JSON.stringify(O,null,2)})):l.default.createElement(ot,{className:"flex"},l.default.createElement(Fi,null),V.guidanceMessageText&&l.default.createElement(Qp,{$top:"5vh"},l.default.createElement(eg,{$background:c.guidanceMessageBackgroundColor,$textColor:c.guidanceMessageTextColor},V.guidanceMessageText)),l.default.createElement(nm,null,l.default.createElement(rm,{ref:x},l.default.createElement(Yg,{ref:k,canvasProps:{width:E,height:S}})),l.default.createElement(om,null,l.default.createElement("button",{onClick:function(e){var t;e.preventDefault(),null===(t=k.current)||void 0===t||t.clear()}},V.clearBtnText),l.default.createElement("button",{style:{marginLeft:"auto"},onClick:function(e){var t;if(e.preventDefault(),k.current){var n=Xg(k.current);N(n),G(k.current.toDataURL()),L(),null===(t=C.current)||void 0===t||t.stop()}}},V.acceptBtnText))),f&&l.default.createElement(Zo,null,"Video: ",null===(n=g.current)||void 0===n?void 0:n.width,"x",null===(r=g.current)||void 0===r?void 0:r.height),l.default.createElement(di,{onClick:a},"×"),l.default.createElement("div",{style:{display:"none"}},l.default.createElement("canvas",{ref:W})))},lm=function(e){var t=e.assets,n=e.verbiage;return l.default.createElement(lg,{assets:void 0===t?{}:t,verbiage:void 0===n?{}:n,onDismissed:e.onDismissed})},cm=function(e){var t,n,r=e.videoUrl,o=e.onDoneClick,i=e.onRetryClick,a=e.colors,s=void 0===a?{}:a,c=e.verbiage,u=void 0===c?{}:c;s.retryBtn||(s.retryBtn={}),(t=s.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=s.retryBtn).textColor||(n.textColor="white");var d=xi(u,{headingText:"Video signature has been successfully captured!",retryBtnText:"Retry",doneBtnText:"Done"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h1",null,d.headingText),l.default.createElement(dt,null,l.default.createElement(um,{src:r,poster:r+"#t=0.1",controls:!0,preload:"metadata",autoPlay:!0})),l.default.createElement("div",null,l.default.createElement(kt,{onClick:i,colors:s.retryBtn,finished:!0},d.retryBtnText),l.default.createElement(kt,{onClick:o,colors:s.doneBtn,style:{marginLeft:15},finished:!0},d.doneBtnText))))},um=d.default.video(tm||(tm=w(["\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"]))),dm=function(e){var n=e.onComplete,r=e.onVideoCaptured,o=e.onRetryClicked,i=e.skipSuccessScreen,a=void 0!==i&&i,s=e.assets,c=void 0===s?{}:s,u=e.colors,d=void 0===u?{}:u,h=e.verbiage,f=void 0===h?{}:h,p=e.debugMode,g=void 0!==p&&p,m=t.useContext(Ye),y=m.selfieImage,w=m.signatureVideo,x=m.setSelfieImage,E=m.setSignatureData,S=m.setSignatureVideo,k=m.logSelfieCaptureAttempt,C=t.useState("LOADING"),T=C[0],A=C[1],I=t.useRef(),R=t.useRef(),D=t.useRef();t.useEffect((function(){I.current=new Date}),[]),t.useEffect((function(){"CHECKING_LIVENESS"===T&&(R.current=new Date)}),[T]);var _=t.useCallback((function(){var e,t,n;k({autoCapture:"Y",captureTime:(null!==(e=D.current)&&void 0!==e?e:new Date).getTime()-(null!==(t=R.current)&&void 0!==t?t:new Date).getTime(),operationTime:(new Date).getTime()-(null!==(n=I.current)&&void 0!==n?n:new Date).getTime()}),I.current=new Date}),[k]),F=t.useCallback((function(){A("CHECKING_LIVENESS")}),[]),M=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){var t;return b(this,(function(n){switch(n.label){case 0:return A("CAPTURING_SIGNATURE"),_(),y?[3,2]:(t=x,[4,Qe(e)]);case 1:t.apply(void 0,[n.sent()]),n.label=2;case 2:return[2]}}))}))}),[_,y,x]),L=t.useCallback((function(e,t,n){E(t),S(URL.createObjectURL(e)),A("SUCCESS"),null==r||r(e,t,n)}),[r,E,S]),P=t.useCallback((function(){A("CHECKING_LIVENESS")}),[]),B=t.useState(0),O=B[0],N=B[1],U=t.useCallback((function(){N((function(e){return e+1})),A("LOADING")}),[]),j=t.useCallback((function(){null==o||o(),U()}),[U,o]),G=Li(a,"SUCCESS"===T,n);return l.default.createElement(Zp,{throttleMs:"CAPTURING_SIGNATURE"===T?250:0},"LOADING"!==T&&function(){switch(T){case"CHECKING_LIVENESS":return l.default.createElement(sg,{onSuccess:M,onExit:U,colors:d.faceLiveness,verbiage:f.faceLiveness,debugMode:g});case"CAPTURING_SIGNATURE":return l.default.createElement(sm,{onVideoCaptured:L,onFaceNotDetected:P,onExit:U,colors:d,verbiage:f,debugMode:g});case"SUCCESS":if(!G)return;return l.default.createElement(cm,{videoUrl:null!=w?w:"",onDoneClick:n,onRetryClick:j,colors:d.success,verbiage:f.success});default:return null}}(),l.default.createElement(lm,{key:O,onDismissed:F,assets:c.loadingOverlay,verbiage:f.loadingOverlay}))},hm=function(e){var n,r,o,i,a,s=e.checks,c=e.idCaptureProps,u=void 0===c?{}:c,d=e.faceLivenessProps,h=void 0===d?{}:d,f=e.signatureCaptureProps,p=void 0===f?{}:f,g=e.videoSignatureCaptureProps,v=void 0===g?{}:g,b=e.additionalDocumentCaptureProps,w=e.captureSignature,x=void 0!==w&&w,E=e.captureSignatureVideo,S=void 0!==E&&E,k=e.debugMode,C=void 0!==k&&k,T=t.useContext(Ye),A=T.submit,I=T.submissionStatus,R=T.setSignatureData,D=T.setAdditionalDocuments,_=t.useState(0),F=_[0],M=_[1],L=t.useMemo((function(){var e,t,n=y([],s,!0);if(x&&S)throw new Error("captureSignature and captureSignatureVideo cannot be used together");return x&&n.push("SignatureCapture"),S&&(n.push("VideoSignatureCapture"),n.includes("FaceLiveness")&&n.splice(n.indexOf("FaceLiveness"),1)),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===(n=null==b?void 0:b.documents)||void 0===n?void 0:n.length,x,S,s]),P=L[F],B=F>=L.length;t.useEffect((function(){"SignatureCapture"===P&&"function"==typeof x?x().then((function(e){e||M((function(e){return e+1}))})):"VideoSignatureCapture"===P&&"function"==typeof S&&S().then((function(e){e||M((function(e){return e+1}))}))}),[x,S,P]),t.useEffect((function(){B&&A()}),[B,A]);var O=u.onSuccess,N=t.useCallback((function(e){null==O||O(e),M((function(e){return e+1}))}),[O]),U=h.onComplete,j=t.useCallback((function(e){null==U||U(e),M((function(e){return e+1}))}),[U]),G=t.useCallback((function(e){R(e),M((function(e){return e+1}))}),[R]),$=v.onComplete,z=t.useCallback((function(){null==$||$(),M((function(e){return e+1}))}),[$]),q=t.useState(0),V=q[0],W=q[1],H=v.onRetryClicked,K=t.useCallback((function(){null==H||H(),W((function(e){return e+1}))}),[H]),Y=null==b?void 0:b.onComplete,X=t.useCallback((function(e){D(e),null==Y||Y(e),M((function(e){return e+1}))}),[Y,D]),J=t.useMemo((function(){var e;return null!==(e=null==b?void 0:b.documents)&&void 0!==e?e:[]}),[null==b?void 0:b.documents]);if(B)switch(I){case Ve.SUBMITTING:return l.default.createElement(ot,{className:"flex"},l.default.createElement(hi,null));case Ve.SUBMITTED:return l.default.createElement(fg,null);case Ve.FAILED:return l.default.createElement(l.default.Fragment,null,"Submission failed!");default:return l.default.createElement(l.default.Fragment,null,"Complete!!")}switch(L[F]){case"IdCapture":return l.default.createElement(Go,{documentDetectionModelUrl:null!==(o=null===(r=u.assets)||void 0===r?void 0:r.documentDetectionModelUrl)&&void 0!==o?o:"",focusModelUrl:null!==(a=null===(i=u.assets)||void 0===i?void 0:i.focusModelUrl)&&void 0!==a?a:"",logPredictions:C},l.default.createElement(nn,{key:"IdCaptureCamera"},l.default.createElement(hg,null,l.default.createElement(Oi,m({},u,{onSuccess:N})))));case"FaceLiveness":return l.default.createElement(nn,{key:"FaceLivenessCamera",preferFrontFacingCamera:!0,preferContinuityCamera:!1},l.default.createElement(Zp,null,l.default.createElement(dg,m({},h,{onComplete:j}))));case"SignatureCapture":return l.default.createElement(am,m({},p,{onAccept:G}));case"VideoSignatureCapture":return l.default.createElement(nn,{key:"SignatureKycCamera-".concat(V),preferContinuityCamera:!1,preferFrontFacingCamera:!0},l.default.createElement(dm,m({},v,{onComplete:z,onRetryClicked:K})));case"AdditionalDocumentCapture":return l.default.createElement(mg,m({},b,{documents:J,onComplete:X}));default:return l.default.createElement(l.default.Fragment,null)}},fm=function(e){var n=e.lang,r=e.submissionToken,o=e.submissionEnvironment,i=void 0===o?"prod":o,a=e.submissionUrl,s=e.companyId,c=e.manualReviewRequired,u=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,b=e.idCardAutoCaptureScoreThreshold,y=void 0===b?.8:b,w=e.passportAutoCaptureScoreThreshold,x=void 0===w?.75:w,E=e.idCardFocusScoreThreshold,S=void 0===E?.3:E,k=e.passportFocusScoreThreshold,C=void 0===k?.3:k,T=e.skipSuccessScreen,A=void 0!==T&&T,I=e.onBeforeSubmit,R=e.onComplete,D=e.onApproved,_=e.onDenied,F=e.assets,M=void 0===F?{}:F,L=e.colors,P=void 0===L?{}:L,B=e.verbiage,O=void 0===B?{}:B,N=e.captureSignature,U=void 0!==N&&N,j=e.captureSignatureVideo,G=void 0!==j&&j,$=e.captureAdditionalDocuments,z=void 0===$?[]:$,q=e.geolocationEnabled,V=void 0===q||q,W=e.geolocationRequired,H=void 0!==W&&W,K=e.debugMode,Y=void 0!==K&&K;yi(void 0===n?"auto":n);var X=t.useMemo((function(){return{autoCaptureEnabled:v,idCardAutoCaptureScoreThreshold:y,passportAutoCaptureScoreThreshold:x,mrzDetectionScoreThreshold:.5,idCardFocusScoreThreshold:S,passportFocusScoreThreshold:C,barcodeScanningEnabled:!1,skipSuccessScreen:A,assets:M,colors:P,verbiage:O,debugMode:Y}}),[M,P,Y,v,y,S,x,C,A,O]),J=t.useMemo((function(){return{documents:z,verbiage:null==O?void 0:O.additionalDocumentCapture}}),[z,null==O?void 0:O.additionalDocumentCapture]),Z=t.useMemo((function(){return{verbiage:null==O?void 0:O.signatureCapture}}),[null==O?void 0:O.signatureCapture]),Q=t.useMemo((function(){return{skipSuccessScreen:A,colors:null==P?void 0:P.videoSignatureCapture,verbiage:null==O?void 0:O.videoSignatureCapture,debugMode:Y}}),[null==P?void 0:P.videoSignatureCapture,Y,A,null==O?void 0:O.videoSignatureCapture]),ee=t.useCallback((function(e){null==R||R(e),"Approved"===e.resultData.verificationResult?null==D||D(e):null==_||_(e)}),[D,R,_]);return l.default.createElement(Ft,{action:qe.VALIDATE,environment:i,url:a,token:r,companyId:s,manualReviewRequired:c,verifyIdWithExternalDatabases:u,personalData:d,cardData:h,webhooksEnabled:f,webhooksClientTraceId:p,webhooksStripSpecialCharacters:g,onBeforeSubmit:I,onResponseReceived:ee,geolocationEnabled:V,geolocationRequired:H},l.default.createElement(hm,{checks:t.useMemo((function(){return["IdCapture"]}),[]),idCaptureProps:X,signatureCaptureProps:Z,videoSignatureCaptureProps:Q,additionalDocumentCaptureProps:J,captureSignature:U,captureSignatureVideo:G,debugMode:Y}))},pm=function(e){var n=e.lang,r=e.submissionToken,o=e.submissionEnvironment,i=void 0===o?"prod":o,a=e.submissionUrl,s=e.companyId,c=e.webhooksEnabled,u=e.webhooksClientTraceId,d=e.webhooksStripSpecialCharacters,h=e.timeoutDurationMs,f=void 0===h?15e3:h,p=e.skipSuccessScreen,g=void 0!==p&&p,m=e.onBeforeSubmit,v=e.onComplete,b=e.onApproved,y=e.onDenied,w=e.onExitAfterFailure,x=e.assets,E=e.colors,S=e.verbiage,k=e.geolocationEnabled,C=void 0===k||k,T=e.geolocationRequired,A=void 0!==T&&T,I=e.debugMode,R=void 0!==I&&I;yi(void 0===n?"auto":n);var D=t.useMemo((function(){return{timeoutDurationMs:f,skipSuccessScreen:g,onComplete:v,onSuccess:b,onTimeout:y,onExitAfterFailure:w,assets:x,colors:E,verbiage:S,debugMode:R}}),[x,E,R,b,v,y,w,g,f,S]);return l.default.createElement(Ft,{action:qe.NONE,environment:i,url:a,token:r,companyId:s,webhooksEnabled:c,webhooksClientTraceId:u,webhooksStripSpecialCharacters:d,onBeforeSubmit:m,geolocationEnabled:C,geolocationRequired:A},l.default.createElement(hm,{checks:t.useMemo((function(){return["FaceLiveness"]}),[]),faceLivenessProps:D,debugMode:R}))},gm=function(e){var n=e.lang,r=e.submissionToken,o=e.submissionEnvironment,i=void 0===o?"prod":o,a=e.submissionUrl,s=e.companyId,c=e.manualReviewRequired,u=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,b=e.idCardAutoCaptureScoreThreshold,y=void 0===b?.8:b,w=e.mrzDetectionScoreThreshold,x=void 0===w?.5:w,E=e.passportAutoCaptureScoreThreshold,S=void 0===E?.75:E,k=e.idCardFocusScoreThreshold,C=void 0===k?.3:k,T=e.passportFocusScoreThreshold,A=void 0===T?.3:T,I=e.faceLivenessTimeoutDurationMs,R=void 0===I?15e3:I,D=e.skipSuccessScreen,_=void 0!==D&&D,F=e.onBeforeSubmit,M=e.onComplete,L=e.onApproved,P=e.onDenied,B=e.onExitAfterFailure,O=e.captureSignature,N=void 0!==O&&O,U=e.captureSignatureVideo,j=void 0!==U&&U,G=e.captureAdditionalDocuments,$=void 0===G?[]:G,z=e.assets,q=void 0===z?{}:z,V=e.colors,W=void 0===V?{}:V,H=e.verbiage,K=void 0===H?{}:H,Y=e.geolocationEnabled,X=void 0===Y||Y,J=e.geolocationRequired,Z=void 0!==J&&J,Q=e.debugMode,ee=void 0!==Q&&Q;yi(void 0===n?"auto":n);var te=t.useMemo((function(){return{assets:q.idCapture,colors:W.idCapture,verbiage:K.idCapture,autoCaptureEnabled:v,idCardAutoCaptureScoreThreshold:y,passportAutoCaptureScoreThreshold:S,mrzDetectionScoreThreshold:x,idCardFocusScoreThreshold:C,passportFocusScoreThreshold:A,skipSuccessScreen:_,debugMode:ee}}),[q.idCapture,W.idCapture,ee,v,y,C,x,S,A,_,K.idCapture]),ne=t.useMemo((function(){return{timeoutDurationMs:R,onTimeout:P,onExitAfterFailure:B,skipSuccessScreen:_,assets:q.faceLiveness,colors:W.faceLiveness,verbiage:K.faceLiveness,debugMode:ee}}),[q.faceLiveness,W.faceLiveness,ee,R,P,B,_,K.faceLiveness]),re=t.useMemo((function(){return{verbiage:K.signatureCapture}}),[null==K?void 0:K.signatureCapture]),oe=t.useMemo((function(){return{skipSuccessScreen:_,colors:null==W?void 0:W.videoSignatureCapture,verbiage:null==K?void 0:K.videoSignatureCapture,debugMode:ee}}),[null==W?void 0:W.videoSignatureCapture,ee,_,null==K?void 0:K.videoSignatureCapture]),ie=t.useMemo((function(){return{documents:$,verbiage:null==K?void 0:K.additionalDocumentCapture}}),[$,null==K?void 0:K.additionalDocumentCapture]),ae=t.useCallback((function(e){null==M||M(e),"Approved"===e.resultData.verificationResult?null==L||L(e):null==P||P(e)}),[L,M,P]);return l.default.createElement(Ft,{action:qe.VALIDATE,environment:i,url:a,token:r,companyId:s,manualReviewRequired:c,verifyIdWithExternalDatabases:u,personalData:d,cardData:h,webhooksEnabled:f,webhooksClientTraceId:p,webhooksStripSpecialCharacters:g,onBeforeSubmit:F,onResponseReceived:ae,geolocationEnabled:X,geolocationRequired:Z},l.default.createElement(hm,{checks:t.useMemo((function(){return["IdCapture","FaceLiveness"]}),[]),idCaptureProps:te,faceLivenessProps:ne,signatureCaptureProps:re,videoSignatureCaptureProps:oe,additionalDocumentCaptureProps:ie,captureSignature:N,captureSignatureVideo:j,debugMode:ee}))},mm=function(e){var n=e.enrollmentId,r=e.lang,o=e.submissionToken,i=e.submissionEnvironment,a=void 0===i?"prod":i,s=e.submissionUrl,c=e.companyId,u=e.manualReviewRequired,d=e.verifyIdWithExternalDatabases,h=e.personalData,f=e.cardData,p=e.deduplicationEnabled,g=e.deduplicationSynchronous,m=e.webhooksEnabled,v=e.webhooksClientTraceId,b=e.webhooksStripSpecialCharacters,y=e.idAutoCaptureEnabled,w=void 0===y||y,x=e.idCardAutoCaptureScoreThreshold,E=void 0===x?.8:x,S=e.mrzDetectionScoreThreshold,k=void 0===S?.5:S,C=e.passportAutoCaptureScoreThreshold,T=void 0===C?.75:C,A=e.idCardFocusScoreThreshold,I=void 0===A?.3:A,R=e.passportFocusScoreThreshold,D=void 0===R?.3:R,_=e.faceLivenessTimeoutDurationMs,F=void 0===_?15e3:_,M=e.skipSuccessScreen,L=void 0!==M&&M,P=e.onBeforeSubmit,B=e.onComplete,O=e.onEnrolled,N=e.onDenied,U=e.onExitAfterFailure,j=e.captureAdditionalDocuments,G=void 0===j?[]:j,$=e.captureSignature,z=void 0!==$&&$,q=e.captureSignatureVideo,V=void 0!==q&&q,W=e.assets,H=void 0===W?{}:W,K=e.colors,Y=void 0===K?{}:K,X=e.verbiage,J=void 0===X?{}:X,Z=e.geolocationEnabled,Q=void 0===Z||Z,ee=e.geolocationRequired,te=void 0!==ee&&ee,ne=e.debugMode,re=void 0!==ne&≠yi(void 0===r?"auto":r);var oe=t.useMemo((function(){return{assets:H.idCapture,colors:Y.idCapture,verbiage:J.idCapture,autoCaptureEnabled:w,idCardAutoCaptureScoreThreshold:E,passportAutoCaptureScoreThreshold:T,mrzDetectionScoreThreshold:k,idCardFocusScoreThreshold:I,passportFocusScoreThreshold:D,skipSuccessScreen:L,debugMode:re}}),[H.idCapture,Y.idCapture,re,w,E,I,k,T,D,L,J.idCapture]),ie=t.useMemo((function(){return{onExitAfterFailure:U,timeoutDurationMs:F,skipSuccessScreen:L,assets:H.faceLiveness,colors:Y.faceLiveness,verbiage:J.faceLiveness,debugMode:re}}),[H.faceLiveness,Y.faceLiveness,re,F,U,L,J.faceLiveness]),ae=t.useMemo((function(){return{documents:G,verbiage:J.additionalDocumentCapture}}),[G,J.additionalDocumentCapture]),se=t.useMemo((function(){return{verbiage:null==J?void 0:J.signatureCapture}}),[null==J?void 0:J.signatureCapture]),le=t.useMemo((function(){return{skipSuccessScreen:L,colors:null==Y?void 0:Y.videoSignatureCapture,verbiage:null==J?void 0:J.videoSignatureCapture,debugMode:re}}),[null==Y?void 0:Y.videoSignatureCapture,re,L,null==J?void 0:J.videoSignatureCapture]),ce=t.useCallback((function(e){null==B||B(e),"Customer Onboarded"===e.resultData.verificationResult?null==O||O(e):null==N||N(e)}),[O,B,N]);return l.default.createElement(Ft,{action:qe.ENROLL,environment:a,url:s,token:o,companyId:c,enrollmentId:n,manualReviewRequired:u,verifyIdWithExternalDatabases:d,personalData:h,cardData:f,deduplicationEnabled:p,deduplicationSynchronous:g,webhooksEnabled:m,webhooksClientTraceId:v,webhooksStripSpecialCharacters:b,onBeforeSubmit:P,onResponseReceived:ce,geolocationEnabled:Q,geolocationRequired:te},l.default.createElement(hm,{checks:t.useMemo((function(){return["IdCapture","FaceLiveness"]}),[]),idCaptureProps:oe,faceLivenessProps:ie,additionalDocumentCaptureProps:ae,signatureCaptureProps:se,videoSignatureCaptureProps:le,captureSignature:z,captureSignatureVideo:V,debugMode:re}))},vm={frame:null,face:null,imageUrl:null,requestState:"CAPTURING",requestError:null,unverifiedTimes:0},bm=function(e,t){switch(t.type){case"verificationReady":return["CAPTURING","ERROR"].includes(e.requestState)?m(m({},e),{requestState:"CAPTURED",frame:t.payload.frame,face:t.payload.face}):e;case"verifying":return m(m({},e),{requestState:"VERIFYING",imageUrl:t.payload.imageUrl});case"verificationCompleted":var n=t.payload.response,r=n.status,o=r.statusMessage,i=r.errorData,a=n.resultData;if("000"!==r.statusCode)return m(m({},e),{requestState:"ERROR",requestError:new Error("".concat(o,": ").concat(i))});var s=e.requestState,l=e.unverifiedTimes;return"00"===a.verificationResultCode?s="VERIFIED":l<0?(s="CAPTURING",l+=1):s="REJECTED",m(m({},e),{requestState:s,unverifiedTimes:l});case"verificationFailed":return m(m({},e),{requestState:"ERROR",requestError:t.payload.error});default:return e}},ym=function(e){var n=e.onCustomerMatched,r=e.onCustomerNotMatched,o=e.onCaptureGuidanceTimeout,i=e.onExit,a=e.captureGuidanceTimeoutDurationMs,s=e.colors,c=void 0===s?{}:s,u=e.verbiage,d=void 0===u?{}:u,h=e.debugMode,f=void 0!==h&&h,p=t.useReducer(bm,vm),g=p[0],m=p[1],y=g.frame,w=g.face,x=t.useContext(Ye),E=x.submit,S=x.submissionResponse,k=x.submissionError,C=x.selfieImage,T=x.setSelfieImage,A=t.useState(null),I=A[0],R=A[1],D=t.useCallback((function(e,t){m({type:"verificationReady",payload:{frame:e,face:t}})}),[]),_="CAPTURED"===g.requestState;return t.useEffect((function(){if(y&&w&&!k){var e=Po(y,w);R(e),Qe(e).then((function(e){T(e)}))}}),[w,y,T,k]),t.useEffect((function(){_&&C&&!k&&v(void 0,void 0,void 0,(function(){var e,t;return b(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),m({type:"verifying",payload:{imageUrl:C}}),[4,E()];case 1:if(!(e=n.sent()))throw new Error("submission failed!");return m({type:"verificationCompleted",payload:{response:e}}),[3,3];case 2:return t=n.sent(),m({type:"verificationFailed",payload:{error:t}}),[3,3];case 3:return[2]}}))}))}),[_,n,r,C,g.requestState,k,E]),t.useEffect((function(){S&&("VERIFIED"===g.requestState?null==n||n(S):"REJECTED"===g.requestState&&(null==r||r(S)))}),[n,r,g.requestState,S]),tg(a,o,["VERIFIED","REJECTED"].includes(g.requestState),"VERIFYING"===g.requestState),l.default.createElement(l.default.Fragment,null,l.default.createElement(og,{onSelfieCaptured:D,onExit:i,timeoutDurationMs:a,colors:c,verbiage:d,debugMode:f}),I&&l.default.createElement(pi,{imageUrl:I}))},wm=function(e){var t,n,r=e.imageUrl,o=e.onDoneClick,i=e.onRetryClick,a=e.colors,s=void 0===a?{}:a,c=e.verbiage,u=void 0===c?{}:c;r||(r="".concat(Mo,"/Selfie-Image-1.png")),s.retryBtn||(s.retryBtn={}),(t=s.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=s.retryBtn).textColor||(n.textColor="white");var d=xi(u,{headingText:"Customer has been verified!",retryBtnText:"Retry",doneBtnText:"Done"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},d.headingText),l.default.createElement(dt,{style:{maxHeight:"calc(100vh - 185px)"}},l.default.createElement("img",{alt:d.headingText,src:r})),l.default.createElement("div",{style:{marginTop:24}},l.default.createElement(kt,{onClick:i,colors:s.retryBtn,finished:!0},d.retryBtnText),l.default.createElement(kt,{onClick:o,colors:s.doneBtn,style:{marginLeft:15},finished:!0},d.doneBtnText))))},xm=function(e){var t,n,r,o,i=e.canRetry,a=void 0===i||i,s=e.onRetryClick,c=e.onExitClick,u=e.assets,d=void 0===u?{}:u,h=e.colors,f=void 0===h?{}:h,p=e.verbiage,g=void 0===p?{}:p;d.imageUrl||(d.imageUrl="".concat(Mo,"/manual_capture.png")),f.retryBtn||(f.retryBtn={}),(t=f.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=f.retryBtn).textColor||(n.textColor="white"),f.exitBtn||(f.exitBtn={}),(r=f.exitBtn).backgroundColor||(r.backgroundColor="#666"),(o=f.exitBtn).textColor||(o.textColor="white");var m=xi(g,{headingText:"Customer not verified",retryBtnText:"Retry",exitBtnText:"Exit"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},m.headingText),l.default.createElement(dt,{style:{maxHeight:"calc(100vh - 185px)"}},l.default.createElement("img",{alt:m.headingText,src:d.imageUrl})),l.default.createElement("div",{style:{marginTop:24}},a&&l.default.createElement(kt,{onClick:s,colors:f.retryBtn,style:{marginRight:15},finished:!0},m.retryBtnText),l.default.createElement(kt,{onClick:c,colors:f.exitBtn,finished:!0},m.exitBtnText))))},Em=function(e){var n=e.onComplete,r=e.onCustomerMatched,o=e.onCustomerNotMatched,i=e.onExitAfterFailure,a=e.onCaptureGuidanceTimeout,s=e.captureGuidanceTimeoutDurationMs,c=e.skipSuccessScreen,u=void 0!==c&&c,d=e.assets,h=void 0===d?{}:d,f=e.colors,p=void 0===f?{}:f,g=e.verbiage,m=void 0===g?{}:g,y=e.debugMode,w=void 0!==y&&y,x=t.useContext(Ye),E=x.submissionResponse,S=x.selfieImage,k=t.useState("LOADING"),C=k[0],T=k[1],A=t.useContext(tn).releaseCameraAccess,I=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){return b(this,(function(t){return T("MATCHED"),null==r||r(e),[2]}))}))}),[r]),R=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){return b(this,(function(t){return T("NOT_MATCHED"),null==o||o(e),[2]}))}))}),[o]),D=t.useCallback((function(){T("FAILED"),null==a||a()}),[a]),_=t.useState(0),F=_[0],M=_[1],L=t.useCallback((function(){M((function(e){return e+1})),T("LOADING")}),[]),P=t.useCallback((function(){A(),E&&(null==n||n(E))}),[n,A,E]),B=Li(u,"MATCHED"===C,P);return l.default.createElement(l.default.Fragment,null,"LOADING"!==C&&function(){switch(C){case"CAPTURING":return l.default.createElement(ym,{key:"capture".concat(F),onCustomerMatched:I,onCustomerNotMatched:R,onCaptureGuidanceTimeout:D,onExit:L,captureGuidanceTimeoutDurationMs:s,colors:p,verbiage:m,debugMode:w});case"MATCHED":if(!B)return;return l.default.createElement(wm,{imageUrl:"data:image/png;base64, ".concat(S),colors:p.success,verbiage:m.success,onDoneClick:P,onRetryClick:function(){T("CAPTURING"),M(0)}});case"NOT_MATCHED":case"FAILED":return l.default.createElement(xm,{assets:h.failure,colors:p.failure,verbiage:m.failure,canRetry:F<2,onExitClick:function(){A(),null==i||i()},onRetryClick:function(){M((function(e){return e+1}))}});default:return null}}(),l.default.createElement(lg,{key:F,assets:h.loadingOverlay,colors:p.loadingOverlay,verbiage:m.loadingOverlay,onDismissed:function(){T("CAPTURING")}}))},Sm=function(e){var t=e.lang,n=e.enrollmentId,r=e.submissionToken,o=e.submissionEnvironment,i=void 0===o?"prod":o,a=e.submissionUrl,s=e.companyId,c=e.webhooksEnabled,u=e.webhooksClientTraceId,d=e.webhooksStripSpecialCharacters,h=e.timeoutDurationMs,f=void 0===h?15e3:h,p=e.skipSuccessScreen,g=void 0!==p&&p,m=e.assets,v=e.colors,b=e.verbiage,y=e.onBeforeSubmit,w=e.onComplete,x=e.onCustomerMatched,E=e.onCustomerNotMatched,S=e.onExitAfterFailure,k=e.geolocationEnabled,C=void 0===k||k,T=e.geolocationRequired,A=void 0!==T&&T,I=e.debugMode,R=void 0!==I&&I;return yi(void 0===t?"auto":t),l.default.createElement(Ft,{action:qe.VERIFY,environment:i,url:a,token:r,companyId:s,enrollmentId:n,webhooksEnabled:c,webhooksClientTraceId:u,webhooksStripSpecialCharacters:d,onBeforeSubmit:y,geolocationEnabled:C,geolocationRequired:A},l.default.createElement(nn,{preferFrontFacingCamera:!0},l.default.createElement(Zp,null,l.default.createElement(Em,{onComplete:w,onCustomerMatched:x,onCustomerNotMatched:E,onExitAfterFailure:S,captureGuidanceTimeoutDurationMs:f,skipSuccessScreen:g,assets:m,colors:v,verbiage:b,debugMode:R}))))},km={frame:null,face:null,imageUrl:null,requestState:"CAPTURING",requestError:null,notFoundTimes:0},Cm=function(e,t){switch(t.type){case"identificationReady":return["CAPTURING","ERROR"].includes(e.requestState)?m(m({},e),{requestState:"CAPTURED",frame:t.payload.frame,face:t.payload.face}):e;case"identifying":return m(m({},e),{requestState:"IDENTIFYING",imageUrl:t.payload.imageUrl});case"identificationCompleted":var n=t.payload.response,r=n.status,o=r.statusMessage,i=r.errorData,a=n.resultData;if("000"!==r.statusCode)return m(m({},e),{requestState:"ERROR",requestError:new Error("".concat(o,": ").concat(i))});var s=e.requestState,l=e.notFoundTimes;return"46"===a.verificationResultCode?s="FOUND":l<0?(s="CAPTURING",l+=1):s="NOT_FOUND",m(m({},e),{requestState:s,notFoundTimes:l});case"identificationFailed":return m(m({},e),{requestState:"ERROR",requestError:t.payload.error});default:return e}},Tm=function(e){var n=e.onCustomerMatched,r=e.onCustomerNotMatched,o=e.onCaptureGuidanceTimeout,i=e.onExit,a=e.captureGuidanceTimeoutDurationMs,s=e.colors,c=void 0===s?{}:s,u=e.verbiage,d=void 0===u?{}:u,h=e.debugMode,f=void 0!==h&&h,p=t.useReducer(Cm,km),g=p[0],m=p[1],y=t.useContext(Ye),w=y.submit,x=y.submissionResponse,E=y.submissionError,S=y.selfieImage,k=y.setSelfieImage,C=t.useState(null),T=C[0],A=C[1],I=t.useCallback((function(e,t){m({type:"identificationReady",payload:{frame:e,face:t}})}),[]),R=g.frame,D=g.face,_="CAPTURED"===g.requestState;return t.useEffect((function(){if(R&&D&&!E){var e=Po(R,D);A(e),Qe(e).then((function(e){k(e)}))}}),[D,R,k,E]),t.useEffect((function(){_&&S&&!E&&v(void 0,void 0,void 0,(function(){var e,t;return b(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),m({type:"identifying",payload:{imageUrl:S}}),[4,w()];case 1:if(!(e=n.sent()))throw new Error("submission failed!");return m({type:"identificationCompleted",payload:{response:e}}),[3,3];case 2:return t=n.sent(),m({type:"identificationFailed",payload:{error:t}}),[3,3];case 3:return[2]}}))}))}),[_,n,r,S,g.requestState,E,w]),t.useEffect((function(){x&&("FOUND"===g.requestState?null==n||n(x):"NOT_FOUND"===g.requestState&&(null==r||r(x)))}),[n,r,g.requestState,x]),tg(a,o,["FOUND","NOT_FOUND"].includes(g.requestState),"IDENTIFYING"===g.requestState),l.default.createElement(l.default.Fragment,null,l.default.createElement(og,{onSelfieCaptured:I,onExit:i,timeoutDurationMs:a,colors:c,verbiage:d,debugMode:f}),T&&l.default.createElement(pi,{imageUrl:T}))},Am=function(e){var t,n,r=e.imageUrl,o=e.onDoneClick,i=e.onRetryClick,a=e.colors,s=void 0===a?{}:a,c=e.verbiage,u=void 0===c?{}:c;r||(r="".concat(Mo,"/Selfie-Image-1.png")),s.retryBtn||(s.retryBtn={}),(t=s.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=s.retryBtn).textColor||(n.textColor="white");var d=xi(u,{headingText:"Customer has been identified!",retryBtnText:"Retry",doneBtnText:"Done"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},d.headingText),l.default.createElement(dt,{style:{maxHeight:"calc(100vh - 185px)"}},l.default.createElement("img",{alt:d.headingText,src:r})),l.default.createElement("div",{style:{marginTop:24}},l.default.createElement(kt,{onClick:i,colors:s.retryBtn,finished:!0},d.retryBtnText),l.default.createElement(kt,{onClick:o,colors:s.doneBtn,style:{marginLeft:15},finished:!0},d.doneBtnText))))},Im=function(e){var t,n,r,o,i=e.canRetry,a=void 0===i||i,s=e.onRetryClick,c=e.onExitClick,u=e.assets,d=void 0===u?{}:u,h=e.colors,f=void 0===h?{}:h,p=e.verbiage,g=void 0===p?{}:p;d.imageUrl||(d.imageUrl="".concat(Mo,"/manual_capture.png")),f.retryBtn||(f.retryBtn={}),(t=f.retryBtn).backgroundColor||(t.backgroundColor="#ea8557"),(n=f.retryBtn).textColor||(n.textColor="white"),f.exitBtn||(f.exitBtn={}),(r=f.exitBtn).backgroundColor||(r.backgroundColor="#666"),(o=f.exitBtn).textColor||(o.textColor="white");var m=xi(g,{headingText:"Customer not found",retryBtnText:"Retry",exitBtnText:"Exit"});return l.default.createElement(ct,null,l.default.createElement(ut,null,l.default.createElement("h3",{style:{marginBottom:24}},m.headingText),l.default.createElement(dt,{style:{maxHeight:"calc(100vh - 185px)"}},l.default.createElement("img",{alt:m.headingText,src:d.imageUrl})),l.default.createElement("div",{style:{marginTop:24}},a&&l.default.createElement(kt,{onClick:s,colors:f.retryBtn,style:{marginRight:15},finished:!0},m.retryBtnText),l.default.createElement(kt,{onClick:c,colors:f.exitBtn,finished:!0},m.exitBtnText))))},Rm=function(e){var n=e.onComplete,r=e.onCustomerMatched,o=e.onCustomerNotMatched,i=e.onExitAfterFailure,a=e.onCaptureGuidanceTimeout,s=e.captureGuidanceTimeoutDurationMs,c=e.skipSuccessScreen,u=void 0!==c&&c,d=e.assets,h=void 0===d?{}:d,f=e.colors,p=void 0===f?{}:f,g=e.verbiage,m=void 0===g?{}:g,y=e.debugMode,w=void 0!==y&&y,x=t.useContext(Ye),E=x.submissionResponse,S=x.selfieImage,k=t.useState("LOADING"),C=k[0],T=k[1],A=t.useContext(tn).releaseCameraAccess,I=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){return b(this,(function(t){return T("FOUND"),null==r||r(e),[2]}))}))}),[r]),R=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){return b(this,(function(t){return T("NOT_FOUND"),null==o||o(e),[2]}))}))}),[o]),D=t.useCallback((function(){T("FAILED"),null==a||a()}),[a]),_=t.useState(0),F=_[0],M=_[1],L=t.useCallback((function(){M((function(e){return e+1})),T("LOADING")}),[]),P=t.useCallback((function(){A(),E&&(null==n||n(E))}),[n,A,E]),B=Li(u,"FOUND"===C,P);return l.default.createElement(l.default.Fragment,null,"LOADING"!==C&&function(){switch(C){case"CAPTURING":return l.default.createElement(Tm,{key:"capture".concat(F),onCustomerMatched:I,onCustomerNotMatched:R,onCaptureGuidanceTimeout:D,onExit:L,captureGuidanceTimeoutDurationMs:s,colors:p,verbiage:m,debugMode:w});case"FOUND":if(!B)return;return l.default.createElement(Am,{imageUrl:"data:image/png;base64, ".concat(S),colors:p.success,verbiage:m.success,onDoneClick:P,onRetryClick:function(){T("CAPTURING"),M(0)}});case"NOT_FOUND":case"FAILED":return l.default.createElement(Im,{assets:h.failure,colors:p.failure,verbiage:m.failure,canRetry:F<2,onExitClick:function(){A(),null==i||i()},onRetryClick:function(){M((function(e){return e+1}))}});default:return null}}(),l.default.createElement(lg,{key:F,assets:h.loadingOverlay,colors:p.loadingOverlay,verbiage:m.loadingOverlay,onDismissed:function(){T("CAPTURING")}}))},Dm=function(e){var t=e.lang,n=e.submissionToken,r=e.submissionEnvironment,o=void 0===r?"prod":r,i=e.submissionUrl,a=e.companyId,s=e.webhooksEnabled,c=e.webhooksClientTraceId,u=e.webhooksStripSpecialCharacters,d=e.timeoutDurationMs,h=void 0===d?15e3:d,f=e.skipSuccessScreen,p=void 0!==f&&f,g=e.onBeforeSubmit,m=e.onComplete,v=e.onCustomerMatched,b=e.onCustomerNotMatched,y=e.onCaptureGuidanceTimeout,w=e.onExitAfterFailure,x=e.assets,E=e.colors,S=e.verbiage,k=e.geolocationEnabled,C=e.geolocationRequired,T=void 0!==C&&C,A=e.debugMode,I=void 0!==A&&A;return yi(void 0===t?"auto":t),l.default.createElement(Ft,{action:qe.IDENTIFY,environment:o,url:i,token:n,companyId:a,webhooksEnabled:s,webhooksClientTraceId:c,webhooksStripSpecialCharacters:u,onBeforeSubmit:g,geolocationEnabled:k,geolocationRequired:T},l.default.createElement(nn,{preferFrontFacingCamera:!0},l.default.createElement(Zp,null,l.default.createElement(Rm,{onComplete:m,onCustomerMatched:v,onCustomerNotMatched:b,onExitAfterFailure:w,onCaptureGuidanceTimeout:y,captureGuidanceTimeoutDurationMs:h,skipSuccessScreen:p,assets:x,colors:E,verbiage:S,debugMode:I}))))},_m=function(e){var t=e.documentDetectionModel,n=void 0===t?"".concat(Mo,"/models/documentdetection448/model.json"):t,r=e.focusModel,o=void 0===r?"".concat(Mo,"/models/focus/model.json"):r,i=e.skipFaceDetectionModel,a=void 0!==i&&i;return v(void 0,void 0,void 0,(function(){return b(this,(function(e){switch(e.label){case 0:return n?[4,Mt(n)]:[3,2];case 1:e.sent(),e.label=2;case 2:return o?[4,rn(o)]:[3,4];case 3:e.sent(),e.label=4;case 4:return a?[3,6]:[4,Kp()];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},Fm=function(e){var n=e.enrollmentId,r=e.lang,o=e.submissionToken,i=e.submissionEnvironment,a=void 0===i?"prod":i,s=e.submissionUrl,c=e.companyId,u=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.skipSuccessScreen,b=void 0!==v&&v,y=e.onBeforeSubmit,w=e.onComplete,x=e.onEnrolled,E=e.onDenied,S=e.onExitAfterFailure,k=e.captureAdditionalDocuments,C=void 0===k?[]:k,T=e.captureSignature,A=void 0!==T&&T,I=e.captureSignatureVideo,R=void 0!==I&&I,D=e.assets,_=void 0===D?{}:D,F=e.colors,M=void 0===F?{}:F,L=e.verbiage,P=void 0===L?{}:L,B=e.geolocationEnabled,O=void 0===B||B,N=e.geolocationRequired,U=void 0!==N&&N,j=e.debugMode,G=void 0!==j&&j;yi(void 0===r?"auto":r);var $=t.useMemo((function(){return{onExitAfterFailure:S,timeoutDurationMs:m,skipSuccessScreen:b,assets:_.faceLiveness,colors:M.faceLiveness,verbiage:P.faceLiveness,debugMode:G}}),[_.faceLiveness,M.faceLiveness,G,S,b,m,P.faceLiveness]),z=t.useMemo((function(){return{documents:C,verbiage:P.additionalDocumentCapture}}),[C,P.additionalDocumentCapture]),q=t.useMemo((function(){return{verbiage:P.signatureCapture}}),[P.signatureCapture]),V=t.useMemo((function(){return{skipSuccessScreen:b,colors:null==M?void 0:M.videoSignatureCapture,verbiage:null==P?void 0:P.videoSignatureCapture,debugMode:G}}),[null==M?void 0:M.videoSignatureCapture,G,b,null==P?void 0:P.videoSignatureCapture]),W=t.useCallback((function(e){null==w||w(e),"Customer Onboarded"===e.resultData.verificationResult?null==x||x(e):null==E||E(e)}),[x,w,E]);return l.default.createElement(Ft,{action:qe.ENROLL,environment:a,url:s,token:o,companyId:c,enrollmentId:n,deduplicationEnabled:u,deduplicationSynchronous:d,webhooksEnabled:h,webhooksClientTraceId:f,webhooksStripSpecialCharacters:p,onBeforeSubmit:y,onResponseReceived:W,geolocationEnabled:O,geolocationRequired:U},l.default.createElement(hm,{checks:t.useMemo((function(){return["FaceLiveness"]}),[]),faceLivenessProps:$,additionalDocumentCaptureProps:z,signatureCaptureProps:q,videoSignatureCaptureProps:V,captureSignature:A,captureSignatureVideo:R,debugMode:G}))},Mm=function(e){var n=e.submissionToken,r=e.submissionEnvironment,o=e.submissionUrl,i=e.onBeforeSubmit,a=e.onComplete,s=e.skipSuccessScreen,c=void 0!==s&&s,u=e.colors,d=e.verbiage,h=e.geolocationEnabled,f=e.geolocationRequired,p=e.debugMode,g=t.useState(0),m=g[1];return l.default.createElement(Ft,{action:qe.NONE,environment:r,url:o,token:n,onBeforeSubmit:i,onResponseReceived:a,geolocationEnabled:h,geolocationRequired:f},l.default.createElement(nn,{key:g[0],preferContinuityCamera:!1,preferFrontFacingCamera:!0},l.default.createElement(dm,{skipSuccessScreen:c,colors:u,debugMode:p,verbiage:d,onRetryClicked:function(){m((function(e){return e+1}))}})))};oe.use(ze).use(ve).init({resources:bi,detection:{caches:[]},fallbackLng:"en",debug:!1,interpolation:{escapeValue:!1}}),void 0!==u&&u.init&&u.init({dsn:"https://0a8e0e8df645473abe217b60b50fbcb1@o4505120557367296.ingest.sentry.io/4505120582008832",tracesSampleRate:1,debug:!0});var Lm=function(e,t){if("string"==typeof t){var n=document.querySelector(t);if(!n)throw new Error("targetElement ".concat(t," not found"));t=n}var r=i.createPortal(l.default.createElement(ct,null,e),document.body);f.default.render(r,t),new MutationObserver((function(e,n){document.body.contains(t)||(n.disconnect(),f.default.unmountComponentAtNode(t))})).observe(document.body,{childList:!0})},Pm=function(e,t){Lm(l.default.createElement(fm,m({},t)),e)},Bm=function(e,t){Lm(l.default.createElement(pm,m({},t)),e)},Om=function(e,t){Lm(l.default.createElement(gm,m({},t)),e)},Nm=function(e,t){Lm(l.default.createElement(mm,m({},t)),e)},Um=function(e,t){Lm(l.default.createElement(Fm,m({},t)),e)},jm=function(e,t){Lm(l.default.createElement(Sm,m({},t)),e)},Gm=function(e,t){Lm(l.default.createElement(Dm,m({},t)),e)},$m=function(e,t){Lm(l.default.createElement(Mm,m({},t)),e)};globalThis.IDmissionSDK={renderIdValidation:Pm,renderFaceValidation:Bm,renderIdAndFaceValidation:Om,renderCustomerIdAndBiometricsEnrollment:Nm,renderCustomerBiometricsEnrollment:Um,renderCustomerVerification:jm,renderCustomerIdentification:Gm,renderSignatureKYC:$m,preloadModels:_m,version:We,ready:!0},e.CustomerBiometricsEnrollment=Fm,e.CustomerIdAndBiometricsEnrollment=mm,e.CustomerIdentification=Dm,e.CustomerVerification=Sm,e.FaceValidation=pm,e.IdAndFaceValidation=gm,e.IdValidation=fm,e.SignatureKYC=Mm,e.preloadModels=_m,e.renderCustomerBiometricsEnrollment=Um,e.renderCustomerIdAndBiometricsEnrollment=Nm,e.renderCustomerIdentification=Gm,e.renderCustomerVerification=jm,e.renderFaceValidation=Bm,e.renderIdAndFaceValidation=Om,e.renderIdValidation=Pm,e.renderSignatureKYC=$m,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=sdk2.umd.production.js.map
|