@swan-admin/swan-web-component 1.0.104 → 1.0.106
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/BodyScan-BJqddH9l.js +2 -0
- package/dist/BodyScan-BJqddH9l.js.map +1 -0
- package/dist/BodyScan-BMSwRF8g.js +2 -0
- package/dist/BodyScan-BMSwRF8g.js.map +1 -0
- package/dist/BodyScan-DDmIfJlM.js +2 -0
- package/dist/BodyScan-DDmIfJlM.js.map +1 -0
- package/dist/BodyScan-DWQjUKtI.js +2 -0
- package/dist/BodyScan-DWQjUKtI.js.map +1 -0
- package/dist/FaceScan-Bilx5Uxm.js +2 -0
- package/dist/FaceScan-Bilx5Uxm.js.map +1 -0
- package/dist/FaceScan-CgKhy7Fv.js +2 -0
- package/dist/FaceScan-CgKhy7Fv.js.map +1 -0
- package/dist/FaceScan-DN3l89L6.js +2 -0
- package/dist/FaceScan-DN3l89L6.js.map +1 -0
- package/dist/FaceScan-DoDQIfoL.js +2 -0
- package/dist/FaceScan-DoDQIfoL.js.map +1 -0
- package/dist/LoadingScreen-B1o5ki-1.js +2 -0
- package/dist/LoadingScreen-B1o5ki-1.js.map +1 -0
- package/dist/LoadingScreen-DjGezkFs.js +2 -0
- package/dist/LoadingScreen-DjGezkFs.js.map +1 -0
- package/dist/LoadingScreen-dw8GNGG0.js +2 -0
- package/dist/LoadingScreen-dw8GNGG0.js.map +1 -0
- package/dist/LoadingScreen-rSXW_5Vv.js +2 -0
- package/dist/LoadingScreen-rSXW_5Vv.js.map +1 -0
- package/dist/bodyScan.js +1 -1
- package/dist/bodyScan.mjs +1 -1
- package/dist/faceScan.js +1 -1
- package/dist/faceScan.mjs +1 -1
- package/dist/index.css +1 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/pose-detection.esm-Dtxn0TmC.js +18 -0
- package/dist/pose-detection.esm-Dtxn0TmC.js.map +1 -0
- package/dist/pose-detection.esm-qPaFsqLN.js +18 -0
- package/dist/pose-detection.esm-qPaFsqLN.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";var t,e=require("@tensorflow/tfjs-core"),n=require("@tensorflow/tfjs-converter"),r=require("@tensorflow/tfjs-backend-webgpu"),i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o={};function a(){return t||(t=1,function(){var t;function e(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}var n="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,n){return t==Array.prototype||t==Object.prototype||(t[e]=n.value),t};var r=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof i&&i];for(var e=0;e<t.length;++e){var n=t[e];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")}(this);function o(t,e){if(e)t:{var i=r;t=t.split(".");for(var o=0;o<t.length-1;o++){var a=t[o];if(!(a in i))break t;i=i[a]}(e=e(o=i[t=t[t.length-1]]))!=o&&null!=e&&n(i,t,{configurable:!0,writable:!0,value:e})}}function a(t){return(t={next:t})[Symbol.iterator]=function(){return this},t}function s(t){var n="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return n?n.call(t):{next:e(t)}}function u(t){if(!(t instanceof Array)){t=s(t);for(var e,n=[];!(e=t.next()).done;)n.push(e.value);t=n}return t}o("Symbol",function(t){function e(t,e){this.h=t,n(this,"description",{configurable:!0,writable:!0,value:e})}if(t)return t;e.prototype.toString=function(){return this.h};var r="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",i=0;return function t(n){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new e(r+(n||"")+"_"+i++,n)}}),o("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var i="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),o=0;o<i.length;o++){var s=r[i[o]];"function"==typeof s&&"function"!=typeof s.prototype[t]&&n(s.prototype,t,{configurable:!0,writable:!0,value:function(){return a(e(this))}})}return t});var l="function"==typeof Object.assign?Object.assign:function(t,e){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(r)for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t};o("Object.assign",function(t){return t||l});var h,c="function"==typeof Object.create?Object.create:function(t){function e(){}return e.prototype=t,new e};if("function"==typeof Object.setPrototypeOf)h=Object.setPrototypeOf;else{var f;t:{var p={};try{p.__proto__={a:!0},f=p.a;break t}catch(t){}f=!1}h=f?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null}var d=h;function m(t,e){if(t.prototype=c(e.prototype),t.prototype.constructor=t,d)d(t,e);else for(var n in e)if("prototype"!=n)if(Object.defineProperties){var r=Object.getOwnPropertyDescriptor(e,n);r&&Object.defineProperty(t,n,r)}else t[n]=e[n];t.za=e.prototype}function y(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function g(t){if(t.m)throw new TypeError("Generator is already running");t.m=!0}function v(t,e){t.l={ma:e,na:!0},t.h=t.s||t.v}function b(t,e,n){return t.h=n,{value:e}}function w(t){this.h=new y,this.i=t}function x(t,e,n,r){try{var i=e.call(t.h.j,n);if(!(i instanceof Object))throw new TypeError("Iterator result "+i+" is not an object");if(!i.done)return t.h.m=!1,i;var o=i.value}catch(e){return t.h.j=null,v(t.h,e),k(t)}return t.h.j=null,r.call(t.h,o),k(t)}function k(t){for(;t.h.h;)try{var e=t.i(t.h);if(e)return t.h.m=!1,{value:e.value,done:!1}}catch(e){t.h.i=void 0,v(t.h,e)}if(t.h.m=!1,t.h.l){if(e=t.h.l,t.h.l=null,e.na)throw e.ma;return{value:e.return,done:!0}}return{value:void 0,done:!0}}function T(t){this.next=function(e){return g(t.h),t.h.j?e=x(t,t.h.j.next,e,t.h.u):(t.h.u(e),e=k(t)),e},this.throw=function(e){return g(t.h),t.h.j?e=x(t,t.h.j.throw,e,t.h.u):(v(t.h,e),e=k(t)),e},this.return=function(e){return function(t,e){g(t.h);var n=t.h.j;return n?x(t,"return"in n?n.return:function(t){return{value:t,done:!0}},e,t.h.return):(t.h.return(e),k(t))}(t,e)},this[Symbol.iterator]=function(){return this}}function S(t){return function(t){function e(e){return t.next(e)}function n(e){return t.throw(e)}return new Promise(function(r,i){!function t(o){o.done?r(o.value):Promise.resolve(o.value).then(e,n).then(t,i)}(t.next())})}(new T(new w(t)))}function M(t){return t||Array.prototype.fill}y.prototype.u=function(t){this.i=t},y.prototype.return=function(t){this.l={return:t},this.h=this.v},o("Promise",function(t){function e(t){this.i=0,this.j=void 0,this.h=[],this.u=!1;var e=this.l();try{t(e.resolve,e.reject)}catch(t){e.reject(t)}}function n(){this.h=null}function i(t){return t instanceof e?t:new e(function(e){e(t)})}if(t)return t;n.prototype.i=function(t){if(null==this.h){this.h=[];var e=this;this.j(function(){e.m()})}this.h.push(t)};var o=r.setTimeout;n.prototype.j=function(t){o(t,0)},n.prototype.m=function(){for(;this.h&&this.h.length;){var t=this.h;this.h=[];for(var e=0;e<t.length;++e){var n=t[e];t[e]=null;try{n()}catch(t){this.l(t)}}}this.h=null},n.prototype.l=function(t){this.j(function(){throw t})},e.prototype.l=function(){function t(t){return function(r){n||(n=!0,t.call(e,r))}}var e=this,n=!1;return{resolve:t(this.I),reject:t(this.m)}},e.prototype.I=function(t){if(t===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof e)this.L(t);else{t:switch(typeof t){case"object":var n=null!=t;break t;case"function":n=!0;break t;default:n=!1}n?this.F(t):this.s(t)}},e.prototype.F=function(t){var e=void 0;try{e=t.then}catch(t){return void this.m(t)}"function"==typeof e?this.M(e,t):this.s(t)},e.prototype.m=function(t){this.v(2,t)},e.prototype.s=function(t){this.v(1,t)},e.prototype.v=function(t,e){if(0!=this.i)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.i);this.i=t,this.j=e,2===this.i&&this.K(),this.H()},e.prototype.K=function(){var t=this;o(function(){if(t.D()){var e=r.console;void 0!==e&&e.error(t.j)}},1)},e.prototype.D=function(){if(this.u)return!1;var t=r.CustomEvent,e=r.Event,n=r.dispatchEvent;return void 0===n||("function"==typeof t?t=new t("unhandledrejection",{cancelable:!0}):"function"==typeof e?t=new e("unhandledrejection",{cancelable:!0}):(t=r.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,t),t.promise=this,t.reason=this.j,n(t))},e.prototype.H=function(){if(null!=this.h){for(var t=0;t<this.h.length;++t)a.i(this.h[t]);this.h=null}};var a=new n;return e.prototype.L=function(t){var e=this.l();t.T(e.resolve,e.reject)},e.prototype.M=function(t,e){var n=this.l();try{t.call(e,n.resolve,n.reject)}catch(t){n.reject(t)}},e.prototype.then=function(t,n){function r(t,e){return"function"==typeof t?function(e){try{i(t(e))}catch(t){o(t)}}:e}var i,o,a=new e(function(t,e){i=t,o=e});return this.T(r(t,i),r(n,o)),a},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype.T=function(t,e){function n(){switch(r.i){case 1:t(r.j);break;case 2:e(r.j);break;default:throw Error("Unexpected state: "+r.i)}}var r=this;null==this.h?a.i(n):this.h.push(n),this.u=!0},e.resolve=i,e.reject=function(t){return new e(function(e,n){n(t)})},e.race=function(t){return new e(function(e,n){for(var r=s(t),o=r.next();!o.done;o=r.next())i(o.value).T(e,n)})},e.all=function(t){var n=s(t),r=n.next();return r.done?i([]):new e(function(t,e){function o(e){return function(n){a[e]=n,0==--s&&t(a)}}var a=[],s=0;do{a.push(void 0),s++,i(r.value).T(o(a.length-1),e),r=n.next()}while(!r.done)})},e}),o("Array.prototype.keys",function(t){return t||function(){return function(t,e){t instanceof String&&(t+="");var n=0,r=!1,i={next:function(){if(!r&&n<t.length){var i=n++;return{value:e(i,t[i]),done:!1}}return r=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,function(t){return t})}}),o("Array.prototype.fill",function(t){return t||function(t,e,n){var r=this.length||0;for(0>e&&(e=Math.max(0,r+e)),(null==n||n>r)&&(n=r),0>(n=Number(n))&&(n=Math.max(0,r+n)),e=Number(e||0);e<n;e++)this[e]=t;return this}}),o("Int8Array.prototype.fill",M),o("Uint8Array.prototype.fill",M),o("Uint8ClampedArray.prototype.fill",M),o("Int16Array.prototype.fill",M),o("Uint16Array.prototype.fill",M),o("Int32Array.prototype.fill",M),o("Uint32Array.prototype.fill",M),o("Float32Array.prototype.fill",M),o("Float64Array.prototype.fill",M),o("Object.is",function(t){return t||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}}),o("Array.prototype.includes",function(t){return t||function(t,e){var n=this;n instanceof String&&(n=String(n));var r=n.length;for(0>(e=e||0)&&(e=Math.max(e+r,0));e<r;e++){var i=n[e];if(i===t||Object.is(i,t))return!0}return!1}}),o("String.prototype.includes",function(t){return t||function(t,e){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(t instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(t,e||0)}});var _=this||self;function E(t,e){t=t.split(".");var n,r=_;t[0]in r||void 0===r.execScript||r.execScript("var "+t[0]);for(;t.length&&(n=t.shift());)t.length||void 0===e?r=r[n]&&r[n]!==Object.prototype[n]?r[n]:r[n]={}:r[n]=e}function A(t){var e;return(e=_.navigator)&&(e=e.userAgent)||(e=""),-1!=e.indexOf(t)}var F=Array.prototype.map?function(t,e){return Array.prototype.map.call(t,e,void 0)}:function(t,e){for(var n=t.length,r=Array(n),i="string"==typeof t?t.split(""):t,o=0;o<n;o++)o in i&&(r[o]=e.call(void 0,i[o],o,t));return r},P={},O=null;function R(t){var e=t.length,n=3*e/4;n%3?n=Math.floor(n):-1!="=.".indexOf(t[e-1])&&(n=-1!="=.".indexOf(t[e-2])?n-2:n-1);var r=new Uint8Array(n),i=0;return function(t,e){function n(e){for(;r<t.length;){var n=t.charAt(r++),i=O[n];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}I();for(var r=0;;){var i=n(-1),o=n(0),a=n(64),s=n(64);if(64===s&&-1===i)break;e(i<<2|o>>4),64!=a&&(e(o<<4&240|a>>2),64!=s&&e(a<<6&192|s))}}(t,function(t){r[i++]=t}),i!==n?r.subarray(0,i):r}function I(){if(!O){O={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=t.concat(e[n].split(""));P[n]=r;for(var i=0;i<r.length;i++){var o=r[i];void 0===O[o]&&(O[o]=i)}}}}var C="undefined"!=typeof Uint8Array,L=!(A("Trident")||A("MSIE"))&&"function"==typeof _.btoa;function j(t){if(!L){var e;void 0===e&&(e=0),I(),e=P[e];for(var n=Array(Math.floor(t.length/3)),r=e[64]||"",i=0,o=0;i<t.length-2;i+=3){var a=t[i],s=t[i+1],u=t[i+2],l=e[a>>2];a=e[(3&a)<<4|s>>4],s=e[(15&s)<<2|u>>6],u=e[63&u],n[o++]=l+a+s+u}switch(l=0,u=r,t.length-i){case 2:u=e[(15&(l=t[i+1]))<<2]||r;case 1:t=t[i],n[o]=e[t>>2]+e[(3&t)<<4|l>>4]+u+r}return n.join("")}for(e="";10240<t.length;)e+=String.fromCharCode.apply(null,t.subarray(0,10240)),t=t.subarray(10240);return e+=String.fromCharCode.apply(null,t),btoa(e)}var N,z=RegExp("[-_.]","g");function B(t){switch(t){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function D(t){if(!L)return R(t);z.test(t)&&(t=t.replace(z,B)),t=atob(t);for(var e=new Uint8Array(t.length),n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}function U(){return N||(N=new Uint8Array(0))}var H={},V="function"==typeof Uint8Array.prototype.slice,G=0,K=0;function q(t){var e=0>t,n=(t=Math.abs(t))>>>0;t=Math.floor((t-n)/4294967296),e&&(e=(n=s(W(n,t))).next().value,t=n.next().value,n=e),G=n>>>0,K=t>>>0}var Y,X="function"==typeof BigInt;function W(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}function Q(t,e){this.i=t>>>0,this.h=e>>>0}function J(t){if(!t)return Y||(Y=new Q(0,0));if(!/^-?\d+$/.test(t))return null;if(16>t.length)q(Number(t));else if(X)t=BigInt(t),G=Number(t&BigInt(4294967295))>>>0,K=Number(t>>BigInt(32)&BigInt(4294967295));else{var e=+("-"===t[0]);K=G=0;for(var n=t.length,r=e,i=(n-e)%6+e;i<=n;r=i,i+=6)r=Number(t.slice(r,i)),K*=1e6,4294967296<=(G=1e6*G+r)&&(K+=G/4294967296|0,G%=4294967296);e&&(t=(e=s(W(G,K))).next().value,e=e.next().value,G=t,K=e)}return new Q(G,K)}function Z(t,e){return Error("Invalid wire type: "+t+" (at position "+e+")")}function $(){return Error("Failed to read varint, encoding is invalid.")}function tt(t,e){return Error("Tried to read past the end of the data "+e+" > "+t)}function et(){throw Error("Invalid UTF8")}function nt(t,e){return e=String.fromCharCode.apply(null,e),null==t?e:t+e}var rt,it,ot,at=void 0,st="undefined"!=typeof TextDecoder,ut="undefined"!=typeof TextEncoder;function lt(t){if(t!==H)throw Error("illegal external caller")}function ht(t,e){if(lt(e),this.V=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}function ct(){return ot||(ot=new ht(null,H))}function ft(t){lt(H);var e=t.V;return null==(e=null==e||C&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?D(e):null)?e:t.V=e}function pt(t,e){this.i=null,this.m=!1,this.h=this.j=this.l=0,dt(this,t,e)}function dt(t,e,n){n=void 0===n?{}:n,t.S=void 0!==n.S&&n.S,e&&(e=function(t){if("string"==typeof t)return{buffer:D(t),C:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),C:!1};if(t.constructor===Uint8Array)return{buffer:t,C:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),C:!1};if(t.constructor===ht)return{buffer:ft(t)||U(),C:!0};if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),C:!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")}(e),t.i=e.buffer,t.m=e.C,t.l=0,t.j=t.i.length,t.h=t.l)}function mt(t,e){if(t.h=e,e>t.j)throw tt(t.j,e)}function yt(t){var e=t.i,n=t.h,r=e[n++],i=127&r;if(128&r&&(i|=(127&(r=e[n++]))<<7,128&r&&(i|=(127&(r=e[n++]))<<14,128&r&&(i|=(127&(r=e[n++]))<<21,128&r&&(i|=(r=e[n++])<<28,128&r&&128&e[n++]&&128&e[n++]&&128&e[n++]&&128&e[n++]&&128&e[n++])))))throw $();return mt(t,n),i}function gt(t,e){if(0>e)throw Error("Tried to read a negative byte length: "+e);var n=t.h,r=n+e;if(r>t.j)throw tt(e,t.j-n);return t.h=r,n}pt.prototype.reset=function(){this.h=this.l};var vt=[];function bt(){this.h=[]}function wt(t,e,n){for(;0<n||127<e;)t.h.push(127&e|128),e=(e>>>7|n<<25)>>>0,n>>>=7;t.h.push(e)}function xt(t,e){for(;127<e;)t.h.push(127&e|128),e>>>=7;t.h.push(e)}function kt(t,e){if(vt.length){var n=vt.pop();dt(n,t,e),t=n}else t=new pt(t,e);this.h=t,this.j=this.h.h,this.i=this.l=-1,this.setOptions(e)}function Tt(t){var e=t.h;if(e.h==e.j)return!1;t.j=t.h.h;var n=yt(t.h)>>>0;if(e=n>>>3,!(0<=(n&=7)&&5>=n))throw Z(n,t.j);if(1>e)throw Error("Invalid field number: "+e+" (at position "+t.j+")");return t.l=e,t.i=n,!0}function St(t){switch(t.i){case 0:if(0!=t.i)St(t);else t:{for(var e=(t=t.h).h,n=e+10,r=t.i;e<n;)if(!(128&r[e++])){mt(t,e);break t}throw $()}break;case 1:mt(t=t.h,t.h+8);break;case 2:2!=t.i?St(t):(e=yt(t.h)>>>0,mt(t=t.h,t.h+e));break;case 5:mt(t=t.h,t.h+4);break;case 3:for(e=t.l;;){if(!Tt(t))throw Error("Unmatched start-group tag: stream EOF");if(4==t.i){if(t.l!=e)throw Error("Unmatched end-group tag");break}St(t)}break;default:throw Z(t.i,t.j)}}bt.prototype.length=function(){return this.h.length},bt.prototype.end=function(){var t=this.h;return this.h=[],t},kt.prototype.setOptions=function(t){t=void 0===t?{}:t,this.ca=void 0!==t.ca&&t.ca},kt.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};var Mt=[];function _t(){this.j=[],this.i=0,this.h=new bt}function Et(t,e){0!==e.length&&(t.j.push(e),t.i+=e.length)}var At="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():void 0;function Ft(t,e){return At?t[At]|=e:void 0!==t.A?t.A|=e:(Object.defineProperties(t,{A:{value:e,configurable:!0,writable:!0,enumerable:!1}}),e)}function Pt(t,e){At?t[At]&&(t[At]&=~e):void 0!==t.A&&(t.A&=~e)}function Ot(t){var e;return null==(e=At?t[At]:t.A)?0:e}function Rt(t,e){At?t[At]=e:void 0!==t.A?t.A=e:Object.defineProperties(t,{A:{value:e,configurable:!0,writable:!0,enumerable:!1}})}function It(t){return Ft(t,1),t}function Ct(t,e){Rt(e,-51&t)}function Lt(t,e){Rt(e,-41&t|18)}var jt={};function Nt(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}var zt,Bt,Dt=[];function Ut(t){if(2&Ot(t.o))throw Error("Cannot mutate an immutable Message")}function Ht(t){var e=t.length;(e=e?t[e-1]:void 0)&&Nt(e)?e.g=1:(e={},t.push((e.g=1,e)))}function Vt(t){var e=t.i+t.G;return t.B||(t.B=t.o[e]={})}function Gt(t,e){return-1===e?null:e>=t.i?t.B?t.B[e]:void 0:t.o[e+t.G]}function Kt(t,e,n,r){Ut(t),qt(t,e,n,r)}function qt(t,e,n,r){t.j&&(t.j=void 0),e>=t.i||r?Vt(t)[e]=n:(t.o[e+t.G]=n,(t=t.B)&&e in t&&delete t[e])}function Yt(t,e,n,r){var i=Gt(t,e);Array.isArray(i)||(i=zt);var o=Ot(i);if(1&o||It(i),r)2&o||Ft(i,2),1&n||Object.freeze(i);else{r=!(2&n);var a=2&o;1&n||!a?r&&16&o&&!a&&Pt(i,16):qt(t,e,i=It(Array.prototype.slice.call(i)))}return i}function Xt(t,e){var n=Gt(t,e),r=null==n?n:"number"==typeof n||"NaN"===n||"Infinity"===n||"-Infinity"===n?Number(n):void 0;return null!=r&&r!==n&&qt(t,e,r),r}function Wt(t,e,n,r,i){t.h||(t.h={});var o=t.h[n],a=Yt(t,n,3,i);if(!o){var s=a;o=[];var u=!!(16&Ot(t.o));a=!!(2&Ot(s));var l=s;!i&&a&&(s=Array.prototype.slice.call(s));for(var h=a,c=0;c<s.length;c++){var f=s[c],p=e,d=!1;if(d=void 0!==d&&d,void 0!==(f=Array.isArray(f)?new p(f):d?new p:void 0)){var m=d=Ot(p=f.o);a&&(m|=2),u&&(m|=16),m!=d&&Rt(p,m),p=m,h=h||!!(2&p),o.push(f)}}return t.h[n]=o,e=33|(u=Ot(s)),u!=(e=h?-9&e:8|e)&&(h=s,Object.isFrozen(h)&&(h=Array.prototype.slice.call(h)),Rt(h,e),s=h),l!==s&&qt(t,n,s),(i||r&&a)&&Ft(o,2),r&&Object.freeze(o),o}return i||(i=Object.isFrozen(o),r&&!i?Object.freeze(o):!r&&i&&(o=Array.prototype.slice.call(o),t.h[n]=o)),o}function Qt(t,e,n){var r=!!(2&Ot(t.o));if(e=Wt(t,e,n,r,r),t=Yt(t,n,3,r),!(r||8&Ot(t))){for(r=0;r<e.length;r++){if(2&Ot((n=e[r]).o)){var i=ue(n,!1);i.j=n}else i=n;n!==i&&(e[r]=i,t[r]=i.o)}Ft(t,8)}return e}function Jt(t,e,n){if(null!=n&&"number"!=typeof n)throw Error("Value of float/double field must be a number|null|undefined, found "+typeof n+": "+n);Kt(t,e,n)}function Zt(t,e,n,r,i){Ut(t);var o=Wt(t,n,e,!1,!1);return n=null!=r?r:new n,t=Yt(t,e,2,!1),null!=i?(o.splice(i,0,n),t.splice(i,0,n.o)):(o.push(n),t.push(n.o)),n.C()&&Pt(t,8),n}function $t(t,e){return null==t?e:t}function te(t,e,n){return n=void 0===n?0:n,$t(Xt(t,e),n)}function ee(t,e,n,r){if(null!=t){if(Array.isArray(t))t=ne(t,e,n,void 0!==r);else if(Nt(t)){var i,o={};for(i in t)o[i]=ee(t[i],e,n,r);t=o}else t=e(t,r);return t}}function ne(t,e,n,r){var i=Ot(t);r=r?!!(16&i):void 0,t=Array.prototype.slice.call(t);for(var o=0;o<t.length;o++)t[o]=ee(t[o],e,n,r);return n(i,t),t}function re(t){return t.ja===jt?t.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"object":if(t)if(Array.isArray(t)){if(128&Ot(t))return Ht(t=Array.prototype.slice.call(t)),t}else{if(C&&null!=t&&t instanceof Uint8Array)return j(t);if(t instanceof ht){var e=t.V;return null==e?"":"string"==typeof e?e:t.V=j(e)}}}return t}(t)}function ie(t,e){128&t&&Ht(e)}function oe(t,e,n){if(n=void 0===n?Lt:n,null!=t){if(C&&t instanceof Uint8Array)return t.length?new ht(new Uint8Array(t),H):ct();if(Array.isArray(t)){var r=Ot(t);return 2&r?t:!e||32&r||!(16&r||0===r)?(4&(e=Ot(t=ne(t,oe,4&r?Lt:n,!0)))&&2&e&&Object.freeze(t),t):(Rt(t,2|r),t)}return t.ja===jt?se(t):t}}function ae(t,e,n,r,i,o,a){if(t=t.h&&t.h[n]){if(2&(r=Ot(t))?r=t:(Lt(r,o=F(t,se)),Object.freeze(o),r=o),Ut(e),a=null==r?zt:It([]),null!=r){for(o=!!r.length,t=0;t<r.length;t++){var s=r[t];o=o&&!(2&Ot(s.o)),a[t]=s.o}o=1|(o?8:0),((t=Ot(a))&o)!==o&&(Object.isFrozen(a)&&(a=Array.prototype.slice.call(a)),Rt(a,t|o)),e.h||(e.h={}),e.h[n]=r}else e.h&&(e.h[n]=void 0);qt(e,n,a,i)}else Kt(e,n,oe(r,o,a),i)}function se(t){return 2&Ot(t.o)||Ft((t=ue(t,!0)).o,2),t}function ue(t,e){var n=t.o,r=[];Ft(r,16);var i=t.constructor.h;if(i&&r.push(i),i=t.B){r.length=n.length,r.fill(void 0,r.length,n.length);var o={};r[r.length-1]=o}128&Ot(n)&&Ht(r),e=e||t.C()?Lt:Ct,o=t.constructor,Bt=r,r=new o(r),Bt=void 0,t.R&&(r.R=t.R.slice()),o=!!(16&Ot(n));for(var a=i?n.length-1:n.length,s=0;s<a;s++)ae(t,r,s-t.G,n[s],!1,o,e);if(i)for(var u in i)ae(t,r,+u,i[u],!0,o,e);return r}function le(t,e,n){null==t&&(t=Bt),Bt=void 0;var r,i=this.constructor.i||0,o=0<i,a=this.constructor.h,s=!1;if(null==t){var u=48,l=!0;o&&(i=0,u|=128),Rt(t=a?[a]:[],u)}else{if(!Array.isArray(t))throw Error();if(a&&a!==t[0])throw Error();var h=u=Ft(t,0);if((l=!!(16&h))&&((s=!!(32&h))||(h|=32)),o){if(128&h)i=0;else if(0<t.length){var c=t[t.length-1];if(Nt(c)&&"g"in c){i=0,h|=128,delete c.g;var f,p=!0;for(f in c){p=!1;break}p&&t.pop()}}}else if(128&h)throw Error();u!==h&&Rt(t,h)}if(this.G=(a?0:-1)-i,this.h=void 0,this.o=t,i=(a=this.o.length)-1,a&&Nt(a=this.o[i])?(this.B=a,this.i=i-this.G):void 0!==e&&-1<e?(this.i=Math.max(e,i+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE,!o&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(n)for(e=l&&!s&&!0,o=this.i,l=0;l<n.length;l++)(s=n[l])<o?(i=t[s+=this.G])?he(i,e):t[s]=zt:(r||(r=Vt(this)),(i=r[s])?he(i,e):r[s]=zt)}function he(t,e){if(Array.isArray(t)){var n=Ot(t),r=1;!e||2&n||(r|=16),(n&r)!==r&&Rt(t,n|r)}}function ce(t,e,n){if(n){var r,i={};for(r in n){var o=n[r],a=o.ra;a||(i.J=o.xa||o.oa.W,o.ia?(i.aa=be(o.ia),a=function(t){return function(e,n,r){return t.J(e,n,r,t.aa)}}(i)):o.ka?(i.Z=we(o.da.P,o.ka),a=function(t){return function(e,n,r){return t.J(e,n,r,t.Z)}}(i)):a=i.J,o.ra=a),a(e,t,o.da),i={J:i.J,aa:i.aa,Z:i.Z}}}!function(t,e){if(e=e.R){Et(t,t.h.end());for(var n=0;n<e.length;n++)Et(t,ft(e[n])||U())}}(e,t)}Rt(Dt,23),zt=Object.freeze(Dt),le.prototype.toJSON=function(){return ne(this.o,re,ie)},le.prototype.C=function(){return!!(2&Ot(this.o))},le.prototype.ja=jt,le.prototype.toString=function(){return this.o.toString()};var fe=Symbol();function pe(t,e,n){return t[fe]||(t[fe]=function(t,r){return e(t,r,n)})}function de(t){var e=t[fe];if(!e){var n=Re(t);e=function(t,e){return Ie(t,e,n)},t[fe]=e}return e}function me(t){var e=function(t){var e=t.ia;return e?de(e):(e=t.wa)?pe(t.da.P,e,t.ka):void 0}(t),n=t.da,r=t.oa.U;return e?function(t,i){return r(t,i,n,e)}:function(t,e){return r(t,e,n)}}function ye(t,e){var n=t[e];return"function"==typeof n&&0===n.length&&(n=n(),t[e]=n),Array.isArray(n)&&(Ee in n||xe in n||0<n.length&&"function"==typeof n[0])?n:void 0}function ge(t,e,n,r,i,o){e.P=t[0];var a=1;if(t.length>a&&"number"!=typeof t[a]){var s=t[a++];n(e,s)}for(;a<t.length;){n=t[a++];for(var u=a+1;u<t.length&&"number"!=typeof t[u];)u++;switch(s=t[a++],u-=a){case 0:r(e,n,s);break;case 1:(u=ye(t,a))?(a++,i(e,n,s,u)):r(e,n,s,t[a++]);break;case 2:i(e,n,s,u=ye(t,u=a++),t[a++]);break;case 3:o(e,n,s,t[a++],t[a++],t[a++]);break;case 4:o(e,n,s,t[a++],t[a++],t[a++],t[a++]);break;default:throw Error("unexpected number of binary field arguments: "+u)}}return e}var ve=Symbol();function be(t){var e=t[ve];if(!e){var n=_e(t);e=function(t,e){return Ce(t,e,n)},t[ve]=e}return e}function we(t,e){var n=t[ve];return n||(n=function(t,n){return ce(t,n,e)},t[ve]=n),n}var xe=Symbol();function ke(t,e){t.push(e)}function Te(t,e,n){t.push(e,n.W)}function Se(t,e,n,r){var i=be(r),o=_e(r).P,a=n.W;t.push(e,function(t,e,n){return a(t,e,n,o,i)})}function Me(t,e,n,r,i,o){var a=we(r,o),s=n.W;t.push(e,function(t,e,n){return s(t,e,n,r,a)})}function _e(t){var e=t[xe];return e||(e=ge(t,t[xe]=[],ke,Te,Se,Me),Ee in t&&xe in t&&(t.length=0),e)}var Ee=Symbol();function Ae(t,e){t[0]=e}function Fe(t,e,n,r){var i=n.U;t[e]=r?function(t,e,n){return i(t,e,n,r)}:i}function Pe(t,e,n,r,i){var o=n.U,a=de(r),s=Re(r).P;t[e]=function(t,e,n){return o(t,e,n,s,a,i)}}function Oe(t,e,n,r,i,o,a){var s=n.U,u=pe(r,i,o);t[e]=function(t,e,n){return s(t,e,n,r,u,a)}}function Re(t){var e=t[Ee];return e||(e=ge(t,t[Ee]={},Ae,Fe,Pe,Oe),Ee in t&&xe in t&&(t.length=0),e)}function Ie(t,e,n){for(;Tt(e)&&4!=e.i;){var r=e.l,i=n[r];if(!i){var o=n[0];o&&(o=o[r])&&(i=n[r]=me(o))}if(!i||!i(e,t,r)){r=t,o=(i=e).j,St(i);var a=i;if(!a.ca){if(i=a.h.h-o,a.h.h=o,a=a.h,0==i)i=ct();else{if(o=gt(a,i),a.S&&a.m)i=a.i.subarray(o,o+i);else{a=a.i;var s=o;i=s===(i=o+i)?U():V?a.slice(s,i):new Uint8Array(a.subarray(s,i))}i=0==i.length?ct():new ht(i,H)}(o=r.R)?o.push(i):r.R=[i]}}}return t}function Ce(t,e,n){for(var r=n.length,i=1==r%2,o=i?1:0;o<r;o+=2)(0,n[o+1])(e,t,n[o]);ce(t,e,i?n[0]:void 0)}function Le(t,e){return{U:t,W:e}}var je=Le(function(t,e,n){if(5!==t.i)return!1;var r=(t=t.h).i,i=t.h,o=r[i],a=r[i+1],s=r[i+2];return r=r[i+3],mt(t,t.h+4),t=2*((a=(o|a<<8|s<<16|r<<24)>>>0)>>31)+1,o=a>>>23&255,a&=8388607,Kt(e,n,255==o?a?NaN:1/0*t:0==o?t*Math.pow(2,-149)*a:t*Math.pow(2,o-150)*(a+Math.pow(2,23))),!0},function(t,e,n){if(null!=(e=Xt(e,n))){xt(t.h,8*n+5),t=t.h;var r=+e;0===r?0<1/r?G=K=0:(K=0,G=2147483648):isNaN(r)?(K=0,G=2147483647):34028234663852886e22<(r=(n=0>r?-2147483648:0)?-r:r)?(K=0,G=(2139095040|n)>>>0):11754943508222875e-54>r?(r=Math.round(r/Math.pow(2,-149)),K=0,G=(n|r)>>>0):(e=Math.floor(Math.log(r)/Math.LN2),r*=Math.pow(2,-e),16777216<=(r=Math.round(8388608*r))&&++e,K=0,G=(n|e+127<<23|8388607&r)>>>0),n=G,t.h.push(n>>>0&255),t.h.push(n>>>8&255),t.h.push(n>>>16&255),t.h.push(n>>>24&255)}}),Ne=Le(function(t,e,n){if(0!==t.i)return!1;var r=t.h,i=0,o=t=0,a=r.i,s=r.h;do{var u=a[s++];i|=(127&u)<<o,o+=7}while(32>o&&128&u);for(32<o&&(t|=(127&u)>>4),o=3;32>o&&128&u;o+=7)t|=(127&(u=a[s++]))<<o;if(mt(r,s),!(128>u))throw $();return r=i>>>0,(t=2147483648&(u=t>>>0))&&(u=~u>>>0,0==(r=1+~r>>>0)&&(u=u+1>>>0)),r=4294967296*u+(r>>>0),Kt(e,n,t?-r:r),!0},function(t,e,n){null!=(e=Gt(e,n))&&("string"==typeof e&&J(e),null!=e&&(xt(t.h,8*n),"number"==typeof e?(t=t.h,q(e),wt(t,G,K)):(n=J(e),wt(t.h,n.i,n.h))))}),ze=Le(function(t,e,n){return 0===t.i&&(Kt(e,n,yt(t.h)),!0)},function(t,e,n){if(null!=(e=Gt(e,n))&&null!=e)if(xt(t.h,8*n),t=t.h,0<=(n=e))xt(t,n);else{for(e=0;9>e;e++)t.h.push(127&n|128),n>>=7;t.h.push(1)}}),Be=Le(function(t,e,n){if(2!==t.i)return!1;var r=yt(t.h)>>>0,i=gt(t=t.h,r);if(t=t.i,st){var o,a=t;(o=rt)||(o=rt=new TextDecoder("utf-8",{fatal:!0})),t=i+r,a=0===i&&t===a.length?a:a.subarray(i,t);try{var s=o.decode(a)}catch(t){if(void 0===at){try{o.decode(new Uint8Array([128]))}catch(t){}try{o.decode(new Uint8Array([97])),at=!0}catch(t){at=!1}}throw!at&&(rt=void 0),t}}else{r=(s=i)+r,i=[];for(var u,l,h=null;s<r;)128>(u=t[s++])?i.push(u):224>u?s>=r?et():(l=t[s++],194>u||128!=(192&l)?(s--,et()):i.push((31&u)<<6|63&l)):240>u?s>=r-1?et():128!=(192&(l=t[s++]))||224===u&&160>l||237===u&&160<=l||128!=(192&(a=t[s++]))?(s--,et()):i.push((15&u)<<12|(63&l)<<6|63&a):244>=u?s>=r-2?et():128!=(192&(l=t[s++]))||l-144+(u<<28)>>30||128!=(192&(a=t[s++]))||128!=(192&(o=t[s++]))?(s--,et()):(u=(7&u)<<18|(63&l)<<12|(63&a)<<6|63&o,u-=65536,i.push(55296+(u>>10&1023),56320+(1023&u))):et(),8192<=i.length&&(h=nt(h,i),i.length=0);s=nt(h,i)}return Kt(e,n,s),!0},function(t,e,n){if(null!=(e=Gt(e,n))){var r=!1;if(r=void 0!==r&&r,ut){if(r&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(e))throw Error("Found an unpaired surrogate");e=(it||(it=new TextEncoder)).encode(e)}else{for(var i=0,o=new Uint8Array(3*e.length),a=0;a<e.length;a++){var s=e.charCodeAt(a);if(128>s)o[i++]=s;else{if(2048>s)o[i++]=s>>6|192;else{if(55296<=s&&57343>=s){if(56319>=s&&a<e.length){var u=e.charCodeAt(++a);if(56320<=u&&57343>=u){s=1024*(s-55296)+u-56320+65536,o[i++]=s>>18|240,o[i++]=s>>12&63|128,o[i++]=s>>6&63|128,o[i++]=63&s|128;continue}a--}if(r)throw Error("Found an unpaired surrogate");s=65533}o[i++]=s>>12|224,o[i++]=s>>6&63|128}o[i++]=63&s|128}}e=i===o.length?o:o.subarray(0,i)}xt(t.h,8*n+2),xt(t.h,e.length),Et(t,t.h.end()),Et(t,e)}}),De=Le(function(t,e,n,r,i){if(2!==t.i)return!1;e=Zt(e,n,r),n=t.h.j,r=yt(t.h)>>>0;var o=t.h.h+r,a=o-n;if(0>=a&&(t.h.j=o,i(e,t,void 0,void 0,void 0),a=o-t.h.h),a)throw Error("Message parsing ended unexpectedly. Expected to read "+r+" bytes, instead read "+(r-a)+" bytes, either the data ended unexpectedly or the message misreported its own length");return t.h.h=o,t.h.j=n,!0},function(t,e,n,r,i){if(null!=(e=Qt(e,r,n)))for(r=0;r<e.length;r++){var o=t;xt(o.h,8*n+2);var a=o.h.end();Et(o,a),a.push(o.i),o=a,i(e[r],t),a=t;var s=o.pop();for(s=a.i+a.h.length()-s;127<s;)o.push(127&s|128),s>>>=7,a.i++;o.push(s),a.i++}});function Ue(t){return function(e,n){t:{if(Mt.length){var r=Mt.pop();r.setOptions(n),dt(r.h,e,n),e=r}else e=new kt(e,n);try{var i=Re(t),o=Ie(new i.P,e,i);break t}finally{(i=e.h).i=null,i.m=!1,i.l=0,i.j=0,i.h=0,i.S=!1,e.l=-1,e.i=-1,100>Mt.length&&Mt.push(e)}o=void 0}return o}}function He(t){return function(){var e=new _t;Ce(this,e,_e(t)),Et(e,e.h.end());for(var n=new Uint8Array(e.i),r=e.j,i=r.length,o=0,a=0;a<i;a++){var s=r[a];n.set(s,o),o+=s.length}return e.j=[n],n}}function Ve(t){le.call(this,t)}m(Ve,le);var Ge=[Ve,1,ze,2,je,3,Be,4,Be];function Ke(t){le.call(this,t,-1,qe)}Ve.prototype.l=He(Ge),m(Ke,le),Ke.prototype.addClassification=function(t,e){return Zt(this,1,Ve,t,e),this};var qe=[1],Ye=Ue([Ke,1,De,Ge]);function Xe(t){le.call(this,t)}m(Xe,le);var We=[Xe,1,je,2,je,3,je,4,je,5,je];function Qe(t){le.call(this,t,-1,Je)}Xe.prototype.l=He(We),m(Qe,le);var Je=[1],Ze=Ue([Qe,1,De,We]);function $e(t){le.call(this,t)}m($e,le);var tn=[$e,1,je,2,je,3,je,4,je,5,je,6,Ne],en=Ue(tn);function nn(t,e,n){if(n=t.createShader(0===n?t.VERTEX_SHADER:t.FRAGMENT_SHADER),t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw Error("Could not compile WebGL shader.\n\n"+t.getShaderInfoLog(n));return n}function rn(t){return Qt(t,Ve,1).map(function(t){var e=Gt(t,1);return{index:null==e?0:e,qa:te(t,2),label:null!=Gt(t,3)?$t(Gt(t,3),""):void 0,displayName:null!=Gt(t,4)?$t(Gt(t,4),""):void 0}})}function on(t){return{x:te(t,1),y:te(t,2),z:te(t,3),visibility:null!=Xt(t,4)?te(t,4):void 0}}function an(t){return Qt(Ze(t),Xe,1).map(on)}function sn(t,e){this.i=t,this.h=e,this.m=0}function un(t,e,n){return function(t,e){var n=t.h;if(void 0===t.s){var r=nn(n,"\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 }",0),i=nn(n,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }",1),o=n.createProgram();if(n.attachShader(o,r),n.attachShader(o,i),n.linkProgram(o),!n.getProgramParameter(o,n.LINK_STATUS))throw Error("Could not compile WebGL program.\n\n"+n.getProgramInfoLog(o));r=t.s=o,n.useProgram(r),i=n.getUniformLocation(r,"sampler0"),t.l={O:n.getAttribLocation(r,"aVertex"),N:n.getAttribLocation(r,"aTex"),ya:i},t.v=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,t.v),n.enableVertexAttribArray(t.l.O),n.vertexAttribPointer(t.l.O,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),t.u=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,t.u),n.enableVertexAttribArray(t.l.N),n.vertexAttribPointer(t.l.N,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.uniform1i(i,0)}r=t.l,n.useProgram(t.s),n.canvas.width=e.width,n.canvas.height=e.height,n.viewport(0,0,e.width,e.height),n.activeTexture(n.TEXTURE0),t.i.bindTexture2d(e.glName),n.enableVertexAttribArray(r.O),n.bindBuffer(n.ARRAY_BUFFER,t.v),n.vertexAttribPointer(r.O,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(r.N),n.bindBuffer(n.ARRAY_BUFFER,t.u),n.vertexAttribPointer(r.N,2,n.FLOAT,!1,0,0),n.bindFramebuffer(n.DRAW_FRAMEBUFFER?n.DRAW_FRAMEBUFFER:n.FRAMEBUFFER,null),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.colorMask(!0,!0,!0,!0),n.drawArrays(n.TRIANGLE_FAN,0,4),n.disableVertexAttribArray(r.O),n.disableVertexAttribArray(r.N),n.bindBuffer(n.ARRAY_BUFFER,null),t.i.bindTexture2d(0)}(t,e),"function"==typeof t.h.canvas.transferToImageBitmap?Promise.resolve(t.h.canvas.transferToImageBitmap()):n?Promise.resolve(t.h.canvas):"function"==typeof createImageBitmap?createImageBitmap(t.h.canvas):(void 0===t.j&&(t.j=document.createElement("canvas")),new Promise(function(e){t.j.height=t.h.canvas.height,t.j.width=t.h.canvas.width,t.j.getContext("2d",{}).drawImage(t.h.canvas,0,0,t.h.canvas.width,t.h.canvas.height),e(t.j)}))}function ln(t){this.h=t}$e.prototype.l=He(tn);var hn=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function cn(t,e){return e+t}function fn(t,e){window[t]=e}function pn(t){if(this.h=t,this.listeners={},this.l={},this.L={},this.s={},this.v={},this.M=this.u=this.ga=!0,this.I=Promise.resolve(),this.fa="",this.D={},this.locateFile=t&&t.locateFile||cn,"object"==typeof window)var e=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if("undefined"==typeof location)throw Error("solutions can only be loaded on a web page or in a web worker");e=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.ha=e,t.options)for(var n=(e=s(Object.keys(t.options))).next();!n.done;n=e.next()){n=n.value;var r=t.options[n].default;void 0!==r&&(this.l[n]="function"==typeof r?r():r)}}function dn(t){var e,n,r,i,o,a,s,l,h,c,f;return S(function(p){switch(p.h){case 1:return t.ga?(e=void 0===t.h.files?[]:"function"==typeof t.h.files?t.h.files(t.l):t.h.files,b(p,S(function(t){switch(t.h){case 1:return t.s=2,b(t,WebAssembly.instantiate(hn),4);case 4:t.h=3,t.s=0;break;case 2:return t.s=0,t.l=null,t.return(!1);case 3:return t.return(!0)}}),2)):p.return();case 2:if(n=p.i,"object"==typeof window)return fn("createMediapipeSolutionsWasm",{locateFile:t.locateFile}),fn("createMediapipeSolutionsPackedAssets",{locateFile:t.locateFile}),a=e.filter(function(t){return void 0!==t.data}),s=e.filter(function(t){return void 0===t.data}),l=Promise.all(a.map(function(e){var n=mn(t,e.url);if(void 0!==e.path){var r=e.path;n=n.then(function(e){return t.overrideFile(r,e),Promise.resolve(e)})}return n})),h=Promise.all(s.map(function(e){return void 0===e.simd||e.simd&&n||!e.simd&&!n?function(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(t){e.addEventListener("load",function(){t()},!1),e.addEventListener("error",function(){t()},!1),document.body.appendChild(e)})}(t.locateFile(e.url,t.ha)):Promise.resolve()})).then(function(){var e,n,r;return S(function(i){if(1==i.h)return e=window.createMediapipeSolutionsWasm,n=window.createMediapipeSolutionsPackedAssets,r=t,b(i,e(n),2);r.i=i.i,i.h=0})}),c=S(function(e){return t.h.graph&&t.h.graph.url?e=b(e,mn(t,t.h.graph.url),0):(e.h=0,e=void 0),e}),b(p,Promise.all([h,l,c]),7);if("function"!=typeof importScripts)throw Error("solutions can only be loaded on a web page or in a web worker");return r=e.filter(function(t){return void 0===t.simd||t.simd&&n||!t.simd&&!n}).map(function(e){return t.locateFile(e.url,t.ha)}),importScripts.apply(null,u(r)),i=t,b(p,createMediapipeSolutionsWasm(Module),6);case 6:i.i=p.i,t.m=new OffscreenCanvas(1,1),t.i.canvas=t.m,o=t.i.GL.createContext(t.m,{antialias:!1,alpha:!1,va:"undefined"!=typeof WebGL2RenderingContext?2:1}),t.i.GL.makeContextCurrent(o),p.h=4;break;case 7:if(t.m=document.createElement("canvas"),!(f=t.m.getContext("webgl2",{}))&&!(f=t.m.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),p.return();t.K=f,t.i.canvas=t.m,t.i.createContext(t.m,!0,!0,{});case 4:t.j=new t.i.SolutionWasm,t.ga=!1,p.h=0}})}function mn(t,e){var n,r;return S(function(i){return e in t.L?i.return(t.L[e]):(n=t.locateFile(e,""),r=fetch(n).then(function(t){return t.arrayBuffer()}),t.L[e]=r,i.return(r))})}function yn(t,e,n){var r,i,o,a,u,l,h,c,f,p,d,m,y,g;return S(function(v){switch(v.h){case 1:if(!n)return v.return(e);for(r={},i=0,o=s(Object.keys(n)),a=o.next();!a.done;a=o.next())u=a.value,"string"!=typeof(l=n[u])&&"texture"===l.type&&void 0!==e[l.stream]&&++i;1<i&&(t.M=!1),h=s(Object.keys(n)),a=h.next();case 2:if(a.done){v.h=4;break}if(c=a.value,"string"==typeof(f=n[c]))return y=r,g=c,b(v,function(t,e,n){var r;return S(function(i){return"number"==typeof n||n instanceof Uint8Array||n instanceof t.i.Uint8BlobList?i.return(n):n instanceof t.i.Texture2dDataOut?((r=t.v[e])||(r=new sn(t.i,t.K),t.v[e]=r),i.return(un(r,n,t.M))):i.return(void 0)})}(t,c,e[f]),14);if(p=e[f.stream],"detection_list"===f.type){if(p){for(var w=p.getRectList(),x=p.getLandmarksList(),k=p.getClassificationsList(),T=[],M=0;M<w.size();++M){var _=en(w.get(M)),E=void 0;E=void 0===E?0:E,_={la:{sa:te(_,1),ta:te(_,2),height:te(_,3),width:te(_,4),rotation:te(_,5,0),pa:$t(Gt(_,6),E)},ea:an(x.get(M)),ba:rn(Ye(k.get(M)))},T.push(_)}w=T}else w=[];r[c]=w,v.h=7;break}if("proto_list"===f.type){if(p){for(w=Array(p.size()),x=0;x<p.size();x++)w[x]=p.get(x);p.delete()}else w=[];r[c]=w,v.h=7;break}if(void 0===p){v.h=3;break}if("float_list"===f.type){r[c]=p,v.h=7;break}if("proto"===f.type){r[c]=p,v.h=7;break}if("texture"!==f.type)throw Error("Unknown output config type: '"+f.type+"'");return(d=t.v[c])||(d=new sn(t.i,t.K),t.v[c]=d),b(v,un(d,p,t.M),13);case 13:m=v.i,r[c]=m;case 7:f.transform&&r[c]&&(r[c]=f.transform(r[c])),v.h=3;break;case 14:y[g]=v.i;case 3:a=h.next(),v.h=2;break;case 4:return v.return(r)}})}function gn(t,e){for(var n=e.name||"$",r=[].concat(u(e.wants)),i=new t.i.StringList,o=s(e.wants),a=o.next();!a.done;a=o.next())i.push_back(a.value);o=t.i.PacketListener.implement({onResults:function(i){for(var o={},a=0;a<e.wants.length;++a)o[r[a]]=i.get(a);var s=t.listeners[n];s&&(t.I=yn(t,o,e.outs).then(function(n){n=s(n);for(var i=0;i<e.wants.length;++i){var a=o[r[i]];"object"==typeof a&&a.hasOwnProperty&&a.hasOwnProperty("delete")&&a.delete()}n&&(t.I=n)}))}}),t.j.attachMultiListener(i,o),i.delete()}function vn(t){switch(void 0===t&&(t=0),t){case 1:return"pose_landmark_full.tflite";case 2:return"pose_landmark_heavy.tflite";default:return"pose_landmark_lite.tflite"}}function bn(t){var e=this;t=t||{},this.h=new pn({locateFile:t.locateFile,files:function(t){return[{url:"pose_solution_packed_assets_loader.js"},{simd:!1,url:"pose_solution_wasm_bin.js"},{simd:!0,url:"pose_solution_simd_wasm_bin.js"},{data:!0,url:vn(t.modelComplexity)}]},graph:{url:"pose_web.binarypb"},listeners:[{wants:["pose_landmarks","world_landmarks","segmentation_mask","image_transformed"],outs:{image:{type:"texture",stream:"image_transformed"},poseLandmarks:{type:"proto",stream:"pose_landmarks",transform:an},poseWorldLandmarks:{type:"proto",stream:"world_landmarks",transform:an},segmentationMask:{type:"texture",stream:"segmentation_mask"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"object"==typeof window&&void 0!==window.navigator&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},modelComplexity:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelComplexity",fieldName:"int_value"},onChange:function(t){var n,r,i;return S(function(o){return 1==o.h?(n=vn(t),r="third_party/mediapipe/modules/pose_landmark/"+n,b(o,mn(e.h,n),2)):(i=o.i,e.h.overrideFile(r,i),o.return(!0))})}},smoothLandmarks:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorSmoothLandmarks",fieldName:"bool_value"}},enableSegmentation:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorEnableSegmentation",fieldName:"bool_value"}},smoothSegmentation:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorSmoothSegmentation",fieldName:"bool_value"}},minDetectionConfidence:{type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"poselandmarkgpu__posedetectiongpu__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}},minTrackingConfidence:{type:1,graphOptionXref:{calculatorType:"ThresholdingCalculator",calculatorName:"poselandmarkgpu__poselandmarkbyroigpu__tensorstoposelandmarksandsegmentation__ThresholdingCalculator",fieldName:"threshold"}}}})}(t=pn.prototype).close=function(){return this.j&&this.j.delete(),Promise.resolve()},t.reset=function(){var t=this;return S(function(e){t.j&&(t.j.reset(),t.s={},t.v={}),e.h=0})},t.setOptions=function(t,e){var n=this;if(e=e||this.h.options){for(var r=[],i=[],o={},a=s(Object.keys(t)),u=a.next();!u.done;o={X:o.X,Y:o.Y},u=a.next())if(!((u=u.value)in this.l)||this.l[u]!==t[u]){this.l[u]=t[u];var l=e[u];void 0!==l&&(l.onChange&&(o.X=l.onChange,o.Y=t[u],r.push(function(t){return function(){return S(function(e){if(1==e.h)return b(e,t.X(t.Y),2);!0===e.i&&(n.u=!0),e.h=0})}}(o))),l.graphOptionXref&&(u=Object.assign({},{calculatorName:"",calculatorIndex:0},l.graphOptionXref,{valueNumber:1===l.type?t[u]:0,valueBoolean:0===l.type&&t[u],valueString:2===l.type?t[u]:""}),i.push(u)))}0===r.length&&0===i.length||(this.u=!0,this.H=(void 0===this.H?[]:this.H).concat(i),this.F=(void 0===this.F?[]:this.F).concat(r))}},t.initialize=function(){var t=this;return S(function(e){return 1==e.h?b(e,dn(t),2):3!=e.h?b(e,function(t){var e,n,r,i,o,a,u,l;return S(function(h){if(1==h.h)return t.h.graph&&t.h.graph.url&&t.fa===t.h.graph.url?h.return():(t.u=!0,t.h.graph&&t.h.graph.url?(t.fa=t.h.graph.url,b(h,mn(t,t.h.graph.url),3)):void(h.h=2));for(2!=h.h&&(e=h.i,t.j.loadGraph(e)),n=s(Object.keys(t.D)),r=n.next();!r.done;r=n.next())i=r.value,t.j.overrideFile(i,t.D[i]);if(t.D={},t.h.listeners)for(o=s(t.h.listeners),a=o.next();!a.done;a=o.next())u=a.value,gn(t,u);l=t.l,t.l={},t.setOptions(l),h.h=0})}(t),3):b(e,function(t){var e,n,r,i,o,a;return S(function(u){switch(u.h){case 1:if(!t.u)return u.return();if(!t.F){u.h=2;break}e=s(t.F),n=e.next();case 3:if(n.done){u.h=5;break}return b(u,(0,n.value)(),4);case 4:n=e.next(),u.h=3;break;case 5:t.F=void 0;case 2:if(t.H){for(r=new t.i.GraphOptionChangeRequestList,i=s(t.H),o=i.next();!o.done;o=i.next())a=o.value,r.push_back(a);t.j.changeOptions(r),r.delete(),t.H=void 0}t.u=!1,u.h=0}})}(t),0)})},t.overrideFile=function(t,e){this.j?this.j.overrideFile(t,e):this.D[t]=e},t.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},t.send=function(t,e){var n,r,i,o,a,u,l,h,c,f=this;return S(function(p){switch(p.h){case 1:return f.h.inputs?(n=1e3*(null==e?performance.now():e),b(p,f.I,2)):p.return();case 2:return b(p,f.initialize(),3);case 3:for(r=new f.i.PacketDataList,i=s(Object.keys(t)),o=i.next();!o.done;o=i.next())if(a=o.value,u=f.h.inputs[a]){t:{var d=t[a];switch(u.type){case"video":var m=f.s[u.stream];if(m||(m=new sn(f.i,f.K),f.s[u.stream]=m),0===m.m&&(m.m=m.i.createTexture()),"undefined"!=typeof HTMLVideoElement&&d instanceof HTMLVideoElement)var y=d.videoWidth,g=d.videoHeight;else"undefined"!=typeof HTMLImageElement&&d instanceof HTMLImageElement?(y=d.naturalWidth,g=d.naturalHeight):(y=d.width,g=d.height);g={glName:m.m,width:y,height:g},(y=m.h).canvas.width=g.width,y.canvas.height=g.height,y.activeTexture(y.TEXTURE0),m.i.bindTexture2d(m.m),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,y.RGBA,y.UNSIGNED_BYTE,d),m.i.bindTexture2d(0),m=g;break t;case"detections":for((m=f.s[u.stream])||(m=new ln(f.i),f.s[u.stream]=m),m.data||(m.data=new m.h.DetectionListData),m.data.reset(d.length),g=0;g<d.length;++g){y=d[g];var v=m.data,w=v.setBoundingBox,x=g,k=y.la,T=new $e;if(Jt(T,1,k.sa),Jt(T,2,k.ta),Jt(T,3,k.height),Jt(T,4,k.width),Jt(T,5,k.rotation),Kt(T,6,k.pa),k=T.l(),w.call(v,x,k),y.ea)for(v=0;v<y.ea.length;++v){T=y.ea[v],x=(w=m.data).addNormalizedLandmark,k=g,T=Object.assign({},T,{visibility:T.visibility?T.visibility:0});var S=new Xe;Jt(S,1,T.x),Jt(S,2,T.y),Jt(S,3,T.z),T.visibility&&Jt(S,4,T.visibility),T=S.l(),x.call(w,k,T)}if(y.ba)for(v=0;v<y.ba.length;++v)x=(w=m.data).addClassification,k=g,T=y.ba[v],Jt(S=new Ve,2,T.qa),T.index&&Kt(S,1,T.index),T.label&&Kt(S,3,T.label),T.displayName&&Kt(S,4,T.displayName),T=S.l(),x.call(w,k,T)}m=m.data;break t;default:m={}}}switch(l=m,h=u.stream,u.type){case"video":r.pushTexture2d(Object.assign({},l,{stream:h,timestamp:n}));break;case"detections":(c=l).stream=h,c.timestamp=n,r.pushDetectionList(c);break;default:throw Error("Unknown input config type: '"+u.type+"'")}}return f.j.send(r),b(p,f.I,4);case 4:r.delete(),p.h=0}})},t.onResults=function(t,e){this.listeners[e||"$"]=t},E("Solution",pn),E("OptionType",{BOOL:0,NUMBER:1,ua:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(t=bn.prototype).reset=function(){this.h.reset()},t.close=function(){return this.h.close(),Promise.resolve()},t.onResults=function(t){this.h.onResults(t)},t.initialize=function(){var t=this;return S(function(e){return b(e,t.h.initialize(),0)})},t.send=function(t,e){var n=this;return S(function(r){return b(r,n.h.send(t,e),0)})},t.setOptions=function(t){this.h.setOptions(t)},E("Pose",bn),E("POSE_CONNECTIONS",[[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]]),E("POSE_LANDMARKS",{NOSE:0,LEFT_EYE_INNER:1,LEFT_EYE:2,LEFT_EYE_OUTER:3,RIGHT_EYE_INNER:4,RIGHT_EYE:5,RIGHT_EYE_OUTER:6,LEFT_EAR:7,RIGHT_EAR:8,LEFT_RIGHT:9,RIGHT_LEFT:10,LEFT_SHOULDER:11,RIGHT_SHOULDER:12,LEFT_ELBOW:13,RIGHT_ELBOW:14,LEFT_WRIST:15,RIGHT_WRIST:16,LEFT_PINKY:17,RIGHT_PINKY:18,LEFT_INDEX:19,RIGHT_INDEX:20,LEFT_THUMB:21,RIGHT_THUMB:22,LEFT_HIP:23,RIGHT_HIP:24,LEFT_KNEE:25,RIGHT_KNEE:26,LEFT_ANKLE:27,RIGHT_ANKLE:28,LEFT_HEEL:29,RIGHT_HEEL:30,LEFT_FOOT_INDEX:31,RIGHT_FOOT_INDEX:32}),E("POSE_LANDMARKS_LEFT",{LEFT_EYE_INNER:1,LEFT_EYE:2,LEFT_EYE_OUTER:3,LEFT_EAR:7,LEFT_RIGHT:9,LEFT_SHOULDER:11,LEFT_ELBOW:13,LEFT_WRIST:15,LEFT_PINKY:17,LEFT_INDEX:19,LEFT_THUMB:21,LEFT_HIP:23,LEFT_KNEE:25,LEFT_ANKLE:27,LEFT_HEEL:29,LEFT_FOOT_INDEX:31}),E("POSE_LANDMARKS_RIGHT",{RIGHT_EYE_INNER:4,RIGHT_EYE:5,RIGHT_EYE_OUTER:6,RIGHT_EAR:8,RIGHT_LEFT:10,RIGHT_SHOULDER:12,RIGHT_ELBOW:14,RIGHT_WRIST:16,RIGHT_PINKY:18,RIGHT_INDEX:20,RIGHT_THUMB:22,RIGHT_HIP:24,RIGHT_KNEE:26,RIGHT_ANKLE:28,RIGHT_HEEL:30,RIGHT_FOOT_INDEX:32}),E("POSE_LANDMARKS_NEUTRAL",{NOSE:0}),E("VERSION","0.5.1675469404")}.call(o)),o}var s=a(),u=function(t,e){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2023 Google LLC. All Rights Reserved.
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
* =============================================================================
|
|
17
|
+
*/function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}u(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var h=function(){return(h=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function c(t,e,n,r){return new(n||(n=Promise))(function(e,i){function o(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n(function(t){t(r)})).then(o,a)}s((r=r.apply(t,[])).next())})}function f(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function p(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}var d=["nose","left_eye","right_eye","left_ear","right_ear","left_shoulder","right_shoulder","left_elbow","right_elbow","left_wrist","right_wrist","left_hip","right_hip","left_knee","right_knee","left_ankle","right_ankle"],m=["nose","left_eye_inner","left_eye","left_eye_outer","right_eye_inner","right_eye","right_eye_outer","left_ear","right_ear","mouth_left","mouth_right","left_shoulder","right_shoulder","left_elbow","right_elbow","left_wrist","right_wrist","left_pinky","right_pinky","left_index","right_index","left_thumb","right_thumb","left_hip","right_hip","left_knee","right_knee","left_ankle","right_ankle","left_heel","right_heel","left_foot_index","right_foot_index"],y={left:[1,2,3,7,9,11,13,15,17,19,21,23,25,27,29,31],right:[4,5,6,8,10,12,14,16,18,20,22,24,26,28,30,32],middle:[0]},g={left:[1,3,5,7,9,11,13,15],right:[2,4,6,8,10,12,14,16],middle:[0]},v=[[0,1],[0,2],[1,3],[2,4],[5,6],[5,7],[5,11],[6,8],[6,12],[7,9],[8,10],[11,12],[11,13],[12,14],[13,15],[14,16]],b=[[0,1],[0,4],[1,2],[2,3],[3,7],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[11,23],[12,14],[14,16],[12,24],[13,15],[15,17],[16,18],[16,20],[15,17],[15,19],[15,21],[16,22],[17,19],[18,20],[23,25],[23,24],[24,26],[25,27],[26,28],[27,29],[28,30],[27,31],[28,32],[29,31],[30,32]];function w(t){return t instanceof SVGAnimatedLength?t.baseVal.value:t}function x(t){return c(this,0,void 0,function(){var n,r;return f(this,function(i){switch(i.label){case 0:return n=document.createElement("canvas"),t instanceof e.Tensor?[4,e.browser.toPixels(t,n)]:[3,2];case 1:return i.sent(),[3,3];case 2:n.width=w(t.width),n.height=w(t.height),r=n.getContext("2d"),t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0),i.label=3;case 3:return[2,n]}})})}function k(t){return c(this,0,void 0,function(){var n,r,i,o,a,s;return f(this,function(u){switch(u.label){case 0:return t instanceof e.Tensor?(n=t.shape.slice(0,2),r=n[0],i=n[1],o=ImageData.bind,[4,e.browser.toPixels(t)]):[3,2];case 1:return[2,new(o.apply(ImageData,[void 0,u.sent(),i,r]))];case 2:return a=document.createElement("canvas"),s=a.getContext("2d"),a.width=w(t.width),a.height=w(t.height),s.drawImage(t,0,0),[2,s.getImageData(0,0,a.width,a.height)]}})})}function T(t){return c(this,0,void 0,function(){var n,r;return f(this,function(i){switch(i.label){case 0:return t instanceof SVGImageElement||t instanceof OffscreenCanvas?[4,x(t)]:[3,2];case 1:return r=i.sent(),[3,3];case 2:r=t,i.label=3;case 3:return n=r,[2,e.browser.fromPixels(n,4)]}})})}function S(t){if(t<0||t>=256)throw new Error("Mask value must be in range [0, 255] but got ".concat(t));if(!Number.isInteger(t))throw new Error("Mask value must be an integer but got ".concat(t))}var M={runtime:"mediapipe",enableSmoothing:!0,enableSegmentation:!1,smoothSegmentation:!0,modelType:"full"},_=function(){function t(t){this.mask=t}return t.prototype.toCanvasImageSource=function(){return c(this,0,void 0,function(){return f(this,function(t){return[2,this.mask]})})},t.prototype.toImageData=function(){return c(this,0,void 0,function(){return f(this,function(t){return[2,k(this.mask)]})})},t.prototype.toTensor=function(){return c(this,0,void 0,function(){return f(this,function(t){return[2,T(this.mask)]})})},t.prototype.getUnderlyingType=function(){return"canvasimagesource"},t}();function E(t){return S(t),"person"}var A=function(){function t(t){var e,n=this;switch(this.width=0,this.height=0,this.selfieMode=!1,this.poseSolution=new s.Pose({locateFile:function(e,n){if(t.solutionPath){var r=t.solutionPath.replace(/\/+$/,"");return"".concat(r,"/").concat(e)}return"".concat(n,"/").concat(e)}}),t.modelType){case"lite":e=0;break;case"heavy":e=2;break;default:e=1}this.poseSolution.setOptions({modelComplexity:e,smoothLandmarks:t.enableSmoothing,enableSegmentation:t.enableSegmentation,smoothSegmentation:t.smoothSegmentation,selfieMode:this.selfieMode}),this.poseSolution.onResults(function(t){if(n.height=t.image.height,n.width=t.image.width,null==t.poseLandmarks)n.poses=[];else{var e=n.translateOutput(t.poseLandmarks,t.poseWorldLandmarks);t.segmentationMask&&(e.segmentation={maskValueToLabel:E,mask:new _(t.segmentationMask)}),n.poses=[e]}})}return t.prototype.translateOutput=function(t,e){var n=this,r={keypoints:t.map(function(t,e){return{x:t.x*n.width,y:t.y*n.height,z:t.z,score:t.visibility,name:m[e]}})};return null!=e&&(r.keypoints3D=e.map(function(t,e){return{x:t.x,y:t.y,z:t.z,score:t.visibility,name:m[e]}})),r},t.prototype.estimatePoses=function(t,n,r){return c(this,0,void 0,function(){var i,o;return f(this,function(a){switch(a.label){case 0:return n&&n.flipHorizontal&&n.flipHorizontal!==this.selfieMode&&(this.selfieMode=n.flipHorizontal,this.poseSolution.setOptions({selfieMode:this.selfieMode})),t instanceof e.Tensor?(o=ImageData.bind,[4,e.browser.toPixels(t)]):[3,2];case 1:return i=new(o.apply(ImageData,[void 0,a.sent(),t.shape[1],t.shape[0]])),[3,3];case 2:i=t,a.label=3;case 3:return t=i,[4,this.poseSolution.send({image:t},r)];case 4:return a.sent(),[2,this.poses]}})})},t.prototype.dispose=function(){this.poseSolution.close()},t.prototype.reset=function(){this.poseSolution.reset()},t.prototype.initialize=function(){return this.poseSolution.initialize()},t}();function F(t){return c(this,0,void 0,function(){var e,n;return f(this,function(r){switch(r.label){case 0:return e=function(t){if(null==t)return h({},M);var e=h({},t);return e.runtime="mediapipe",null==e.enableSegmentation&&(e.enableSegmentation=M.enableSegmentation),null==e.enableSmoothing&&(e.enableSmoothing=M.enableSmoothing),null==e.smoothSegmentation&&(e.smoothSegmentation=M.smoothSegmentation),null==e.modelType&&(e.modelType=M.modelType),e}(t),[4,(n=new A(e)).initialize()];case 1:return r.sent(),[2,n]}})})}function P(t){return t instanceof e.Tensor?{height:t.shape[0],width:t.shape[1]}:{height:t.height,width:t.width}}function O(t){return t-2*Math.PI*Math.floor((t+Math.PI)/(2*Math.PI))}function R(t){return t instanceof e.Tensor?t:e.browser.fromPixels(t)}function I(t,e,n){return C(n,"inputResolution"),[1/n.width*t[0][0]*e.width,1/n.height*t[0][1]*e.width,t[0][3]*e.width,1/n.width*t[1][0]*e.height,1/n.height*t[1][1]*e.height,t[1][3]*e.height,0,0]}function C(t,n){e.util.assert(0!==t.width,function(){return"".concat(n," width cannot be 0.")}),e.util.assert(0!==t.height,function(){return"".concat(n," height cannot be 0.")})}function L(t,e,n){var r=n.rotationVectorStartKeypointIndex,i=n.rotationVectorEndKeypointIndex,o=t.locationData,a=o.relativeKeypoints[r].x*e.width,s=o.relativeKeypoints[r].y*e.height,u=o.relativeKeypoints[i].x*e.width,l=o.relativeKeypoints[i].y*e.height,h=2*Math.sqrt((u-a)*(u-a)+(l-s)*(l-s)),c=function(t,e,n){var r,i=t.locationData,o=n.rotationVectorStartKeypointIndex,a=n.rotationVectorEndKeypointIndex;r=n.rotationVectorTargetAngle?n.rotationVectorTargetAngle:Math.PI*n.rotationVectorTargetAngleDegree/180;var s=i.relativeKeypoints[o].x*e.width,u=i.relativeKeypoints[o].y*e.height,l=i.relativeKeypoints[a].x*e.width,h=i.relativeKeypoints[a].y*e.height;return O(r-Math.atan2(-(h-u),l-s))}(t,e,n);return{xCenter:a/e.width,yCenter:s/e.height,width:h/e.width,height:h/e.height,rotation:c}}function j(t){if(16!==t.length)throw new Error("Array length must be 16 but got ".concat(t.length));return[[t[0],t[1],t[2],t[3]],[t[4],t[5],t[6],t[7]],[t[8],t[9],t[10],t[11]],[t[12],t[13],t[14],t[15]]]}function N(t,e,n,r,i,o,a){return t[e][i]*(t[n][o]*t[r][a]-t[n][a]*t[r][o])}function z(t,e,n){var r=(e+1)%4,i=(e+2)%4,o=(e+3)%4,a=(n+1)%4,s=(n+2)%4,u=(n+3)%4;return N(t,r,i,o,a,s,u)+N(t,i,o,r,a,s,u)+N(t,o,r,i,a,s,u)}function B(t,e,n){void 0===n&&(n={ignoreRotation:!1});for(var r=[],i=0,o=t;i<o.length;i++){var a=o[i],s=a.x-.5,u=a.y-.5,l=n.ignoreRotation?0:e.rotation,c=Math.cos(l)*s-Math.sin(l)*u,f=Math.sin(l)*s+Math.cos(l)*u;c=c*e.width+e.xCenter,f=f*e.height+e.yCenter;var p=a.z*e.width,d=h({},a);d.x=c,d.y=f,d.z=p,r.push(d)}return r}function D(t,n){var r=function(t,e,n,r){var i=(r-n)/255;return{scale:i,offset:n-0*i}}(0,0,n[0],n[1]);return e.tidy(function(){return e.add(e.mul(t,r.scale),r.offset)})}function U(t,n,r){var i,o,a,s,u,l,h,c,f,p,d,m,y=n.outputTensorSize,g=n.keepAspectRatio,v=n.borderMode,b=n.outputTensorFloatRange,w=P(t),x=function(t,e){return e?{xCenter:e.xCenter*t.width,yCenter:e.yCenter*t.height,width:e.width*t.width,height:e.height*t.height,rotation:e.rotation}:{xCenter:.5*t.width,yCenter:.5*t.height,width:t.width,height:t.height,rotation:0}}(w,r),k=function(t,e,n){if(void 0===n&&(n=!1),!n)return{top:0,left:0,right:0,bottom:0};var r=e.height,i=e.width;C(e,"targetSize"),C(t,"roi");var o,a,s=r/i,u=t.height/t.width,l=0,h=0;return s>u?(o=t.width,a=t.width*s,h=(1-u/s)/2):(o=t.height/s,a=t.height,l=(1-s/u)/2),t.width=o,t.height=a,{top:h,left:l,right:l,bottom:h}}(x,y,g),T=(i=x,o=w.width,a=w.height,s=i.width,u=i.height,l=Math.cos(i.rotation),h=Math.sin(i.rotation),c=i.xCenter,f=i.yCenter,p=1/o,d=1/a,(m=new Array(16))[0]=s*l*1*p,m[1]=-u*h*p,m[2]=0,m[3]=(-.5*s*l*1+.5*u*h+c)*p,m[4]=s*h*1*d,m[5]=u*l*d,m[6]=0,m[7]=(-.5*u*l-.5*s*h*1+f)*d,m[8]=0,m[9]=0,m[10]=s*p,m[11]=0,m[12]=0,m[13]=0,m[14]=0,m[15]=1,j(m));return{imageTensor:e.tidy(function(){var n=R(t),r=e.tensor2d(I(T,w,y),[1,8]),i="zero"===v?"constant":"nearest",o=e.image.transform(e.expandDims(e.cast(n,"float32")),r,"bilinear",i,0,[y.height,y.width]);return null!=b?D(o,b):o}),padding:k,transformationMatrix:T}}function H(t,e,n,r){return 1===r?.5*(t+e):t+(e-t)*n/(r-1)}function V(t){return null!=t&&null!=t.currentTime}function G(t){for(var e={locationData:{relativeKeypoints:[]}},n=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER,a=0;a<t.length;++a){var s=t[a];n=Math.min(n,s.x),r=Math.max(r,s.x),i=Math.min(i,s.y),o=Math.max(o,s.y),e.locationData.relativeKeypoints.push({x:s.x,y:s.y})}return e.locationData.relativeBoundingBox={xMin:n,yMin:i,xMax:r,yMax:o,width:r-n,height:o-i},e}function K(t,n,r,i){return c(this,0,void 0,function(){var i,o,a,s,u;return f(this,function(l){switch(l.label){case 0:return t.sort(function(t,e){return Math.max.apply(Math,e.score)-Math.max.apply(Math,t.score)}),i=e.tensor2d(t.map(function(t){return[t.locationData.relativeBoundingBox.yMin,t.locationData.relativeBoundingBox.xMin,t.locationData.relativeBoundingBox.yMax,t.locationData.relativeBoundingBox.xMax]})),o=e.tensor1d(t.map(function(t){return t.score[0]})),[4,e.image.nonMaxSuppressionAsync(i,o,n,r)];case 1:return[4,(a=l.sent()).array()];case 2:return s=l.sent(),u=t.filter(function(t,e){return s.indexOf(e)>-1}),e.dispose([i,o,a]),[2,u]}})})}function q(t,e){return t.map(function(t){var n=h(h({},t),{x:t.x*e.width,y:t.y*e.height});return null!=t.z&&(n.z=t.z*e.width),n})}function Y(t,n,r){return c(this,0,void 0,function(){var i,o,a,s,u,l,c,p,d,m,y,g,v,b,w,x,k,T,S,M,_,E,A,F;return f(this,function(f){switch(f.label){case 0:if(i=e.squeeze(n,[0]),o=i.shape,a=o[0],s=o[1],u=o[2],t.length!==u)throw new Error("Expected heatmap to have same number of channels as the number of landmarks. But got landmarks length: "+"".concat(t.length,", heatmap length: ").concat(u));return l=[],[4,i.buffer()];case 1:for(c=f.sent(),p=0;p<t.length;p++)if(d=t[p],m=h({},d),l.push(m),y=Math.trunc(m.x*s),g=Math.trunc(m.y*a),!(y<0||y>=s||g<0||y>=a)){for(v=Math.trunc((r.kernelSize-1)/2),b=Math.max(0,y-v),w=Math.min(s,y+v+1),x=Math.max(0,g-v),k=Math.min(a,g+v+1),T=0,S=0,M=0,_=0,E=x;E<k;++E)for(A=b;A<w;++A)F=c.get(E,A,p),T+=F,_=Math.max(_,F),S+=A*F,M+=E*F;_>=r.minConfidenceToRefine&&T>0&&(m.x=S/s/T,m.y=M/a/T)}return i.dispose(),[2,l]}})})}function X(t,e){var n=e.left,r=e.top,i=e.left+e.right,o=e.top+e.bottom;return t.map(function(t){return h(h({},t),{x:(t.x-n)/(1-i),y:(t.y-r)/(1-o),z:t.z/(1-i)})})}function W(t,n,r){return c(this,0,void 0,function(){var i,o,a,s,u;return f(this,function(l){switch(l.label){case 0:return i=t[0],o=t[1],a=function(t,n,r){return e.tidy(function(){var i,o,a,s;r.reverseOutputOrder?(o=e.squeeze(e.slice(t,[0,r.boxCoordOffset+0],[-1,1])),i=e.squeeze(e.slice(t,[0,r.boxCoordOffset+1],[-1,1])),s=e.squeeze(e.slice(t,[0,r.boxCoordOffset+2],[-1,1])),a=e.squeeze(e.slice(t,[0,r.boxCoordOffset+3],[-1,1]))):(i=e.squeeze(e.slice(t,[0,r.boxCoordOffset+0],[-1,1])),o=e.squeeze(e.slice(t,[0,r.boxCoordOffset+1],[-1,1])),a=e.squeeze(e.slice(t,[0,r.boxCoordOffset+2],[-1,1])),s=e.squeeze(e.slice(t,[0,r.boxCoordOffset+3],[-1,1]))),o=e.add(e.mul(e.div(o,r.xScale),n.w),n.x),i=e.add(e.mul(e.div(i,r.yScale),n.h),n.y),r.applyExponentialOnBoxSize?(a=e.mul(e.exp(e.div(a,r.hScale)),n.h),s=e.mul(e.exp(e.div(s,r.wScale)),n.w)):(a=e.mul(e.div(a,r.hScale),n.h),s=e.mul(e.div(s,r.wScale),n.h));var u=e.sub(i,e.div(a,2)),l=e.sub(o,e.div(s,2)),h=e.add(i,e.div(a,2)),c=e.add(o,e.div(s,2)),f=e.concat([e.reshape(u,[r.numBoxes,1]),e.reshape(l,[r.numBoxes,1]),e.reshape(h,[r.numBoxes,1]),e.reshape(c,[r.numBoxes,1])],1);if(r.numKeypoints)for(var p=0;p<r.numKeypoints;++p){var d=r.keypointCoordOffset+p*r.numValuesPerKeypoint,m=void 0,y=void 0;r.reverseOutputOrder?(m=e.squeeze(e.slice(t,[0,d],[-1,1])),y=e.squeeze(e.slice(t,[0,d+1],[-1,1]))):(y=e.squeeze(e.slice(t,[0,d],[-1,1])),m=e.squeeze(e.slice(t,[0,d+1],[-1,1])));var g=e.add(e.mul(e.div(m,r.xScale),n.w),n.x),v=e.add(e.mul(e.div(y,r.yScale),n.h),n.y);f=e.concat([f,e.reshape(g,[r.numBoxes,1]),e.reshape(v,[r.numBoxes,1])],1)}return f})}(o,n,r),s=e.tidy(function(){var t=i;return r.sigmoidScore?(null!=r.scoreClippingThresh&&(t=e.clipByValue(i,-r.scoreClippingThresh,r.scoreClippingThresh)),t=e.sigmoid(t)):t}),[4,Q(a,s,r)];case 1:return u=l.sent(),e.dispose([a,s]),[2,u]}})})}function Q(t,e,n){return c(this,0,void 0,function(){var r,i,o,a,s,u,l,h,c,p,d,m;return f(this,function(f){switch(f.label){case 0:return r=[],[4,t.data()];case 1:return i=f.sent(),[4,e.data()];case 2:for(o=f.sent(),a=0;a<n.numBoxes;++a)if(!(null!=n.minScoreThresh&&o[a]<n.minScoreThresh||(s=a*n.numCoords,u=J(i[s+0],i[s+1],i[s+2],i[s+3],o[a],n.flipVertically,a),(l=u.locationData.relativeBoundingBox).width<0||l.height<0))){if(n.numKeypoints>0)for((h=u.locationData).relativeKeypoints=[],c=n.numKeypoints*n.numValuesPerKeypoint,p=0;p<c;p+=n.numValuesPerKeypoint)d=s+n.keypointCoordOffset+p,m={x:i[d+0],y:n.flipVertically?1-i[d+1]:i[d+1]},h.relativeKeypoints.push(m);r.push(u)}return[2,r]}})})}function J(t,e,n,r,i,o,a){return{score:[i],ind:a,locationData:{relativeBoundingBox:{xMin:e,yMin:o?1-n:t,xMax:r,yMax:o?1-t:n,width:r-e,height:n-t}}}}function Z(t,e){return"none"===t?e:function(t){return 1/(1+Math.exp(-t))}(e)}function $(t,e,n,r){return c(this,0,void 0,function(){var i,o,a,s,u,l,h,c;return f(this,function(f){switch(f.label){case 0:return n=n||e.flipHorizontally||!1,r=r||e.flipVertically||!1,i=t.size,o=i/e.numLandmarks,[4,t.data()];case 1:for(a=f.sent(),s=[],u=0;u<e.numLandmarks;++u)l=u*o,(c={x:0,y:0}).x=n?e.inputImageWidth-a[l]:a[l],o>1&&(c.y=r?e.inputImageHeight-a[l+1]:a[l+1]),o>2&&(c.z=a[l+2]),o>3&&(c.score=Z(e.visibilityActivation,a[l+3])),s.push(c);for(h=0;h<s.length;++h)(c=s[h]).x=c.x/e.inputImageWidth,c.y=c.y/e.inputImageHeight,c.z=c.z/e.inputImageWidth/(e.normalizeZ||1);return[2,s]}})})}function tt(t,e,n){var r=t.width,i=t.height,o=t.rotation;if(null==n.rotation&&null==n.rotationDegree||(o=function(t,e){return null!=e.rotation?t+=e.rotation:null!=e.rotationDegree&&(t+=Math.PI*e.rotationDegree/180),O(t)}(o,n)),0===o)t.xCenter=t.xCenter+r*n.shiftX,t.yCenter=t.yCenter+i*n.shiftY;else{var a=(e.width*r*n.shiftX*Math.cos(o)-e.height*i*n.shiftY*Math.sin(o))/e.width,s=(e.width*r*n.shiftX*Math.sin(o)+e.height*i*n.shiftY*Math.cos(o))/e.height;t.xCenter=t.xCenter+a,t.yCenter=t.yCenter+s}var u=Math.max(r*e.width,i*e.height);return r=u/e.width,i=u/e.height,t.width=r*n.scaleX,t.height=i*n.scaleY,t}function et(t,e){return t.map(function(t){var n=h(h({},t),{x:t.x/e.width,y:t.y/e.height});return null!=t.z&&(t.z=t.z/e.width),n})}var nt=function(){function t(t){this.alpha=t,this.initialized=!1}return t.prototype.apply=function(t,e){var n;return this.initialized?n=null==e?this.storedValue+this.alpha*(t-this.storedValue):this.storedValue+this.alpha*e*Math.asinh((t-this.storedValue)/e):(n=t,this.initialized=!0),this.rawValue=t,this.storedValue=n,n},t.prototype.applyWithAlpha=function(t,e,n){return this.alpha=e,this.apply(t,n)},t.prototype.hasLastRawValue=function(){return this.initialized},t.prototype.lastRawValue=function(){return this.rawValue},t.prototype.reset=function(){this.initialized=!1},t}(),rt=function(){function t(t){this.frequency=t.frequency,this.minCutOff=t.minCutOff,this.beta=t.beta,this.thresholdCutOff=t.thresholdCutOff,this.thresholdBeta=t.thresholdBeta,this.derivateCutOff=t.derivateCutOff,this.x=new nt(this.getAlpha(this.minCutOff)),this.dx=new nt(this.getAlpha(this.derivateCutOff)),this.lastTimestamp=0}return t.prototype.apply=function(t,e,n){if(null==t)return t;var r=Math.trunc(e);if(this.lastTimestamp>=r)return t;0!==this.lastTimestamp&&0!==r&&(this.frequency=1/(1e-6*(r-this.lastTimestamp))),this.lastTimestamp=r;var i=this.x.hasLastRawValue()?(t-this.x.lastRawValue())*n*this.frequency:0,o=this.dx.applyWithAlpha(i,this.getAlpha(this.derivateCutOff)),a=this.minCutOff+this.beta*Math.abs(o),s=null!=this.thresholdCutOff?this.thresholdCutOff+this.thresholdBeta*Math.abs(o):null;return this.x.applyWithAlpha(t,this.getAlpha(a),s)},t.prototype.getAlpha=function(t){return 1/(1+this.frequency/(2*Math.PI*t))},t}(),it=function(){function t(t){this.config=t}return t.prototype.apply=function(t,e,n){var r=this;if(null==t)return this.reset(),null;this.initializeFiltersIfEmpty(t);var i=1;if(!this.config.disableValueScaling){if(n<this.config.minAllowedObjectScale)return p([],t,!0);i=1/n}return t.map(function(t,n){var o=h(h({},t),{x:r.xFilters[n].apply(t.x,e,i),y:r.yFilters[n].apply(t.y,e,i)});return null!=t.z&&(o.z=r.zFilters[n].apply(t.z,e,i)),o})},t.prototype.reset=function(){this.xFilters=null,this.yFilters=null,this.zFilters=null},t.prototype.initializeFiltersIfEmpty=function(t){var e=this;null!=this.xFilters&&this.xFilters.length===t.length||(this.xFilters=t.map(function(t){return new rt(e.config)}),this.yFilters=t.map(function(t){return new rt(e.config)}),this.zFilters=t.map(function(t){return new rt(e.config)}))},t}(),ot=function(){function t(t){this.config=t,this.window=[],this.lowPassFilter=new nt(1),this.lastValue=0,this.lastValueScale=1,this.lastTimestamp=-1}return t.prototype.apply=function(t,e,n){if(null==t)return t;var r,i=Math.trunc(e);if(this.lastTimestamp>=i)return t;if(-1===this.lastTimestamp)r=1;else{for(var o=t*n-this.lastValue*this.lastValueScale,a=i-this.lastTimestamp,s=o,u=a,l=(1+this.window.length)*(1e6/30),h=0,c=this.window;h<c.length;h++){var f=c[h];if(u+f.duration>l)break;s+=f.distance,u+=f.duration}var p=s/(1e-6*u);r=1-1/(1+this.config.velocityScale*Math.abs(p)),this.window.unshift({distance:o,duration:a}),this.window.length>this.config.windowSize&&this.window.pop()}return this.lastValue=t,this.lastValueScale=n,this.lastTimestamp=i,this.lowPassFilter.applyWithAlpha(t,r)},t}(),at=function(){function t(t){this.config=t}return t.prototype.apply=function(t,e,n){var r=this;if(null==t)return this.reset(),null;var i=1;if(!this.config.disableValueScaling){if(n<this.config.minAllowedObjectScale)return p([],t,!0);i=1/n}return this.initializeFiltersIfEmpty(t),t.map(function(t,n){var o=h(h({},t),{x:r.xFilters[n].apply(t.x,e,i),y:r.yFilters[n].apply(t.y,e,i)});return null!=t.z&&(o.z=r.zFilters[n].apply(t.z,e,i)),o})},t.prototype.reset=function(){this.xFilters=null,this.yFilters=null,this.zFilters=null},t.prototype.initializeFiltersIfEmpty=function(t){var e=this;null!=this.xFilters&&this.xFilters.length===t.length||(this.xFilters=t.map(function(t){return new ot(e.config)}),this.yFilters=t.map(function(t){return new ot(e.config)}),this.zFilters=t.map(function(t){return new ot(e.config)}))},t}(),st=function(){function t(t){if(null!=t.velocityFilter)this.keypointsFilter=new at(t.velocityFilter);else{if(null==t.oneEuroFilter)throw new Error("Either configure velocityFilter or oneEuroFilter, but got "+"".concat(t,"."));this.keypointsFilter=new it(t.oneEuroFilter)}}return t.prototype.apply=function(t,e,n,r,i){if(void 0===r&&(r=!1),null==t)return this.keypointsFilter.reset(),null;var o=null!=i?function(t,e){return(t.width*e.width+t.height*e.height)/2}(i,n):1,a=r?q(t,n):t,s=this.keypointsFilter.apply(a,e,o);return r?et(s,n):s},t}(),ut=function(){function t(t){this.alpha=t.alpha}return t.prototype.apply=function(t){var e=this;if(null==t)return this.visibilityFilters=null,null;null!=this.visibilityFilters&&this.visibilityFilters.length===t.length||(this.visibilityFilters=t.map(function(t){return new nt(e.alpha)}));for(var n=[],r=0;r<t.length;++r){var i=t[r],o=h({},i);o.score=this.visibilityFilters[r].apply(i.score),n.push(o)}return n},t}(),lt={interpolatedScaleAspectRatio:1,featureMapHeight:[],featureMapWidth:[],numLayers:5,minScale:.1484375,maxScale:.75,inputSizeHeight:224,inputSizeWidth:224,anchorOffsetX:.5,anchorOffsetY:.5,strides:[8,16,32,32,32],aspectRatios:[1],fixedAnchorSize:!0},ht={runtime:"tfjs",modelType:"full",enableSmoothing:!0,enableSegmentation:!1,smoothSegmentation:!0,detectorModelUrl:"https://tfhub.dev/mediapipe/tfjs-model/blazepose_3d/detector/1",landmarkModelUrl:"https://tfhub.dev/mediapipe/tfjs-model/blazepose_3d/landmark/full/2"},ct={maxPoses:1,flipHorizontal:!1},ft={applyExponentialOnBoxSize:!1,flipVertically:!1,numBoxes:2254,numCoords:12,boxCoordOffset:0,keypointCoordOffset:4,numKeypoints:4,numValuesPerKeypoint:2,sigmoidScore:!0,scoreClippingThresh:100,reverseOutputOrder:!0,xScale:224,yScale:224,hScale:224,wScale:224,minScoreThresh:.5},pt={shiftX:0,shiftY:0,scaleX:1.25,scaleY:1.25},dt={outputTensorSize:{width:224,height:224},keepAspectRatio:!0,outputTensorFloatRange:[-1,1],borderMode:"zero"},mt={outputTensorSize:{width:256,height:256},keepAspectRatio:!0,outputTensorFloatRange:[0,1],borderMode:"zero"},yt={numLandmarks:39,inputImageWidth:256,inputImageHeight:256,visibilityActivation:"sigmoid",flipHorizontally:!1,flipVertically:!1},gt={numLandmarks:39,inputImageWidth:1,inputImageHeight:1,visibilityActivation:"sigmoid",flipHorizontally:!1,flipVertically:!1},vt={kernelSize:7,minConfidenceToRefine:.5},bt={alpha:.1},wt={oneEuroFilter:{frequency:30,minCutOff:.05,beta:80,derivateCutOff:1,minAllowedObjectScale:1e-6}},xt={oneEuroFilter:{frequency:30,minCutOff:.01,beta:10,derivateCutOff:1,minAllowedObjectScale:1e-6}},kt={oneEuroFilter:{frequency:30,minCutOff:.1,beta:40,derivateCutOff:1,minAllowedObjectScale:1e-6,disableValueScaling:!0}},Tt={activation:"none"},St={combineWithPreviousRatio:.7},Mt=function(){function t(t){this.mask=t}return t.prototype.toCanvasImageSource=function(){return c(this,0,void 0,function(){return f(this,function(t){return[2,x(this.mask)]})})},t.prototype.toImageData=function(){return c(this,0,void 0,function(){return f(this,function(t){return[2,k(this.mask)]})})},t.prototype.toTensor=function(){return c(this,0,void 0,function(){return f(this,function(t){return[2,this.mask]})})},t.prototype.getUnderlyingType=function(){return"tensor"},t}();function _t(t){return S(t),"person"}var Et=function(){function t(t,n,r,i,o,a){this.detectorModel=t,this.landmarkModel=n,this.enableSmoothing=r,this.enableSegmentation=i,this.smoothSegmentation=o,this.modelType=a,this.regionOfInterest=null,this.prevFilteredSegmentationMask=null,this.anchors=function(t){null==t.reduceBoxesInLowestLayer&&(t.reduceBoxesInLowestLayer=!1),null==t.interpolatedScaleAspectRatio&&(t.interpolatedScaleAspectRatio=1),null==t.fixedAnchorSize&&(t.fixedAnchorSize=!1);for(var e=[],n=0;n<t.numLayers;){for(var r=[],i=[],o=[],a=[],s=n;s<t.strides.length&&t.strides[s]===t.strides[n];){var u=H(t.minScale,t.maxScale,s,t.strides.length);if(0===s&&t.reduceBoxesInLowestLayer)o.push(1),o.push(2),o.push(.5),a.push(.1),a.push(u),a.push(u);else{for(var l=0;l<t.aspectRatios.length;++l)o.push(t.aspectRatios[l]),a.push(u);if(t.interpolatedScaleAspectRatio>0){var h=s===t.strides.length-1?1:H(t.minScale,t.maxScale,s+1,t.strides.length);a.push(Math.sqrt(u*h)),o.push(t.interpolatedScaleAspectRatio)}}s++}for(var c=0;c<o.length;++c){var f=Math.sqrt(o[c]);r.push(a[c]/f),i.push(a[c]*f)}var p=0,d=0;if(t.featureMapHeight.length>0)p=t.featureMapHeight[n],d=t.featureMapWidth[n];else{var m=t.strides[n];p=Math.ceil(t.inputSizeHeight/m),d=Math.ceil(t.inputSizeWidth/m)}for(var y=0;y<p;++y)for(var g=0;g<d;++g)for(var v=0;v<r.length;++v){var b={xCenter:(g+t.anchorOffsetX)/d,yCenter:(y+t.anchorOffsetY)/p,width:0,height:0};t.fixedAnchorSize?(b.width=1,b.height=1):(b.width=i[v],b.height=r[v]),e.push(b)}n=s}return e}(lt);var s=e.tensor1d(this.anchors.map(function(t){return t.width})),u=e.tensor1d(this.anchors.map(function(t){return t.height})),l=e.tensor1d(this.anchors.map(function(t){return t.xCenter})),h=e.tensor1d(this.anchors.map(function(t){return t.yCenter}));this.anchorTensor={x:l,y:h,w:s,h:u},this.prevFilteredSegmentationMask=this.enableSegmentation?e.tensor2d([],[0,0]):null}return t.prototype.estimatePoses=function(t,n,r){return c(this,0,void 0,function(){var i,o,a,s,u,l,c,p,d,y,g,v,b,w,x,k,T,S,M,_,E,A,F;return f(this,function(f){switch(f.label){case 0:return i=function(t){var e;if(null==(e=null==t?ct:h({},t)).maxPoses&&(e.maxPoses=1),e.maxPoses<=0)throw new Error("Invalid maxPoses ".concat(e.maxPoses,". Should be > 0."));if(e.maxPoses>1)throw new Error("Multi-pose detection is not implemented yet. Please set maxPoses to 1.");return e}(n),null==t?(this.reset(),[2,[]]):(this.maxPoses=i.maxPoses,this.timestamp=null!=r?1e3*r:V(t)?1e6*t.currentTime:null,o=P(t),a=e.tidy(function(){return e.cast(R(t),"float32")}),null!=(s=this.regionOfInterest)?[3,2]:[4,this.detectPose(a)]);case 1:if(0===(u=f.sent()).length)return this.reset(),a.dispose(),[2,[]];l=u[0],s=this.poseDetectionToRoi(l,o),f.label=2;case 2:return[4,this.poseLandmarksByRoi(s,a)];case 3:return c=f.sent(),a.dispose(),null==c?(this.reset(),[2,[]]):(p=c.landmarks,d=c.auxiliaryLandmarks,y=c.poseScore,g=c.worldLandmarks,v=c.segmentationMask,b=this.poseLandmarkFiltering(p,d,g,o),w=b.actualLandmarksFiltered,x=b.auxiliaryLandmarksFiltered,k=b.actualWorldLandmarksFiltered,T=this.poseLandmarksToRoi(x,o),this.regionOfInterest=T,S=this.smoothSegmentation&&null!=v?this.poseSegmentationFiltering(v):v,null!=(M=null!=w?q(w,o):null)&&M.forEach(function(t,e){t.name=m[e]}),null!=(_=k)&&_.forEach(function(t,e){t.name=m[e]}),E={score:y,keypoints:M,keypoints3D:_},null!==S&&(A=e.tidy(function(){var t=e.expandDims(S,2),n=e.pad(t,[[0,0],[0,0],[0,1]]);return e.mirrorPad(n,[[0,0],[0,0],[0,2]],"symmetric")}),this.smoothSegmentation||e.dispose(S),F={maskValueToLabel:_t,mask:new Mt(A)},E.segmentation=F),[2,[E]])}})})},t.prototype.poseSegmentationFiltering=function(t){var n=this.prevFilteredSegmentationMask;return 0===n.size?this.prevFilteredSegmentationMask=t:(this.prevFilteredSegmentationMask=function(t,n,r){return"webgl"===e.getBackend()?function(t,n,r){var i=r.combineWithPreviousRatio.toFixed(2),o={variableNames:["prevMask","newMask"],outputShape:t.shape,userCode:"\n void main() {\n ivec2 coords = getOutputCoords();\n int height = coords[0];\n int width = coords[1];\n\n float prevMaskValue = getPrevMask(height, width);\n float newMaskValue = getNewMask(height, width);\n\n /*\n * Assume p := newMaskValue\n * H(p) := 1 + (p * log(p) + (1-p) * log(1-p)) / log(2)\n * uncertainty alpha(p) =\n * Clamp(1 - (1 - H(p)) * (1 - H(p)), 0, 1) [squaring the\n * uncertainty]\n *\n * The following polynomial approximates uncertainty alpha as a\n * function of (p + 0.5):\n */\n const float c1 = 5.68842;\n const float c2 = -0.748699;\n const float c3 = -57.8051;\n const float c4 = 291.309;\n const float c5 = -624.717;\n float t = newMaskValue - 0.5;\n float x = t * t;\n\n float uncertainty =\n 1.0 - min(1.0, x * (c1 + x * (c2 + x * (c3 + x * (c4 + x * c5)))));\n\n float outputValue = newMaskValue + (prevMaskValue - newMaskValue) *\n (uncertainty * ".concat(i,");\n\n setOutput(outputValue);\n }\n")},a=e.backend();return e.tidy(function(){var r=a.compileAndRun(o,[t,n]);return e.engine().makeTensorFromDataId(r.dataId,r.shape,r.dtype)})}(t,n,r):e.tidy(function(){var i=e.sub(n,.5),o=e.square(i),a=e.sub(1,e.minimum(1,e.mul(o,e.add(5.68842,e.mul(o,e.add(-.748699,e.mul(o,e.add(-57.8051,e.mul(o,e.add(291.309,e.mul(o,-624.717)))))))))));return e.add(n,e.mul(e.sub(t,n),e.mul(a,r.combineWithPreviousRatio)))})}(n,t,St),e.dispose(t)),e.dispose(n),this.prevFilteredSegmentationMask},t.prototype.dispose=function(){this.detectorModel.dispose(),this.landmarkModel.dispose(),e.dispose([this.anchorTensor.x,this.anchorTensor.y,this.anchorTensor.w,this.anchorTensor.h,this.prevFilteredSegmentationMask])},t.prototype.reset=function(){this.regionOfInterest=null,this.enableSegmentation&&(e.dispose(this.prevFilteredSegmentationMask),this.prevFilteredSegmentationMask=e.tensor2d([],[0,0])),this.visibilitySmoothingFilterActual=null,this.visibilitySmoothingFilterAuxiliary=null,this.landmarksSmoothingFilterActual=null,this.landmarksSmoothingFilterAuxiliary=null},t.prototype.detectPose=function(t){return c(this,0,void 0,function(){var n,r,i,o,a,s,u,l,h,c;return f(this,function(f){switch(f.label){case 0:return n=U(t,dt),r=n.imageTensor,i=n.padding,o=this.detectorModel.predict(r),a=function(t){return e.tidy(function(){var n=function(t){return e.tidy(function(){return[e.slice(t,[0,0,0],[1,-1,1]),e.slice(t,[0,0,1],[1,-1,-1])]})}(t),r=n[0],i=n[1];return{boxes:e.squeeze(i),logits:e.squeeze(r)}})}(o),s=a.boxes,[4,W([u=a.logits,s],this.anchorTensor,ft)];case 1:return 0===(l=f.sent()).length?(e.dispose([r,o,u,s]),[2,l]):[4,K(l,this.maxPoses,.3)];case 2:return h=f.sent(),c=function(t,e){void 0===t&&(t=[]);for(var n=e.left,r=e.top,i=e.left+e.right,o=e.top+e.bottom,a=0;a<t.length;a++){var s=t[a],u=s.locationData.relativeBoundingBox,l=(u.xMin-n)/(1-i),h=(u.yMin-r)/(1-o),c=u.width/(1-i),f=u.height/(1-o);u.xMin=l,u.yMin=h,u.width=c,u.height=f,u.xMax=l+c,u.yMax=h+f;var p=s.locationData.relativeKeypoints;p&&p.forEach(function(t){var e=(t.x-n)/(1-i),a=(t.y-r)/(1-o);t.x=e,t.y=a})}return t}(h,i),e.dispose([r,o,u,s]),[2,c]}})})},t.prototype.poseDetectionToRoi=function(t,e){return tt(L(t,e,{rotationVectorEndKeypointIndex:1,rotationVectorStartKeypointIndex:0,rotationVectorTargetAngleDegree:90}),e,pt)},t.prototype.poseLandmarksByRoi=function(t,n){return c(this,0,void 0,function(){var r,i,o,a,s,u,l,c,p,d,m,y,g,v;return f(this,function(f){switch(f.label){case 0:if(r=P(n),i=U(n,mt,t),o=i.imageTensor,a=i.padding,s=i.transformationMatrix,"lite"!==this.modelType&&"full"!==this.modelType&&"heavy"!==this.modelType)throw new Error("Model type must be one of lite, full or heavy,"+"but got ".concat(this.modelType));return u=["ld_3d","output_poseflag","activation_heatmap","world_3d"],this.enableSegmentation&&u.push("activation_segmentation"),l=this.landmarkModel.execute(o,u),[4,this.tensorsToPoseLandmarksAndSegmentation(l)];case 1:return null==(c=f.sent())?(e.dispose(l),e.dispose(o),[2,null]):(p=c.landmarks,d=c.auxiliaryLandmarks,m=c.poseScore,y=c.worldLandmarks,g=c.segmentationMask,[4,this.poseLandmarksAndSegmentationInverseProjection(r,t,a,s,p,d,y,g)]);case 2:return v=f.sent(),e.dispose(l),e.dispose(o),[2,h({poseScore:m},v)]}})})},t.prototype.poseLandmarksAndSegmentationInverseProjection=function(t,n,r,i,o,a,s,u){return c(this,0,void 0,function(){var l,c,p,d,m,y;return f(this,function(f){return l=X(o,r),c=X(a,r),p=B(l,n),d=B(c,n),m=function(t,e){for(var n=[],r=0,i=t;r<i.length;r++){var o=i[r],a=o.x,s=o.y,u=e.rotation,l=Math.cos(u)*a-Math.sin(u)*s,c=Math.sin(u)*a+Math.cos(u)*s,f=h({},o);f.x=l,f.y=c,n.push(f)}return n}(s,n),y=null,this.enableSegmentation&&(y=e.tidy(function(){var n=u.shape,r=n[0],o=n[1],a=function(t){var e=j(new Array(16).fill(0));e[0][0]=z(t,0,0),e[1][0]=-z(t,0,1),e[2][0]=z(t,0,2),e[3][0]=-z(t,0,3),e[0][2]=z(t,2,0),e[1][2]=-z(t,2,1),e[2][2]=z(t,2,2),e[3][2]=-z(t,2,3),e[0][1]=-z(t,1,0),e[1][1]=z(t,1,1),e[2][1]=-z(t,1,2),e[3][1]=z(t,1,3),e[0][3]=-z(t,3,0),e[1][3]=z(t,3,1),e[2][3]=-z(t,3,2),e[3][3]=z(t,3,3);for(var n=t[0][0]*e[0][0]+t[1][0]*e[0][1]+t[2][0]*e[0][2]+t[3][0]*e[0][3],r=0;r<e.length;r++)for(var i=0;i<e.length;i++)e[r][i]/=n;return e}(i),s=e.tensor2d(I(a,{width:o,height:r},t),[1,8]),l=[1,r,o,1];return e.squeeze(e.image.transform(e.reshape(u,l),s,"bilinear","constant",0,[t.height,t.width]),[0,3])}),e.dispose(u)),[2,{landmarks:p,auxiliaryLandmarks:d,worldLandmarks:m,segmentationMask:y}]})})},t.prototype.tensorsToPoseLandmarksAndSegmentation=function(t){return c(this,0,void 0,function(){var n,r,i,o,a,s,u,l,c,p,d,m,y;return f(this,function(f){switch(f.label){case 0:return n=t[0],r=t[1],i=t[2],o=t[3],a=this.enableSegmentation?t[4]:null,[4,r.data()];case 1:return(s=f.sent()[0])<.5?[2,null]:[4,$(n,yt)];case 2:return[4,Y(f.sent(),i,vt)];case 3:return u=f.sent(),l=u.slice(0,33),c=u.slice(33,35),[4,$(o,gt)];case 4:return p=f.sent(),d=p.slice(0,33),m=function(t,e){for(var n=[],r=0;r<t.length;r++){var i=h({},e[r]);i.score=t[r].score,n.push(i)}return n}(l,d),y=this.enableSegmentation?function(t,n){return e.tidy(function(){var r=e.squeeze(t,[0]),i=r.shape[2];if(1===i){var o=r;switch(n.activation){case"none":break;case"sigmoid":o=e.sigmoid(o);break;case"softmax":throw new Error("Softmax activation requires two channels.");default:throw new Error("Activation not supported (".concat(n.activation,")"))}var a=o;return e.squeeze(a,[2])}throw new Error("Unsupported number of tensor channels ".concat(i))})}(a,Tt):null,[2,{landmarks:l,auxiliaryLandmarks:c,poseScore:s,worldLandmarks:m,segmentationMask:y}]}})})},t.prototype.poseLandmarksToRoi=function(t,e){return tt(L(G(t),e,{rotationVectorStartKeypointIndex:0,rotationVectorEndKeypointIndex:1,rotationVectorTargetAngleDegree:90}),e,pt)},t.prototype.poseLandmarkFiltering=function(t,e,n,r){var i,o,a;if(null!=this.timestamp&&this.enableSmoothing){var s=L(G(e),r,{rotationVectorEndKeypointIndex:0,rotationVectorStartKeypointIndex:1,rotationVectorTargetAngleDegree:90});null==this.visibilitySmoothingFilterActual&&(this.visibilitySmoothingFilterActual=new ut(bt)),i=this.visibilitySmoothingFilterActual.apply(t),null==this.visibilitySmoothingFilterAuxiliary&&(this.visibilitySmoothingFilterAuxiliary=new ut(bt)),o=this.visibilitySmoothingFilterAuxiliary.apply(e),a=this.visibilitySmoothingFilterActual.apply(n),null==this.landmarksSmoothingFilterActual&&(this.landmarksSmoothingFilterActual=new st(wt)),i=this.landmarksSmoothingFilterActual.apply(i,this.timestamp,r,!0,s),null==this.landmarksSmoothingFilterAuxiliary&&(this.landmarksSmoothingFilterAuxiliary=new st(xt)),o=this.landmarksSmoothingFilterAuxiliary.apply(o,this.timestamp,r,!0,s),null==this.worldLandmarksSmoothingFilterActual&&(this.worldLandmarksSmoothingFilterActual=new st(kt)),a=this.worldLandmarksSmoothingFilterActual.apply(n,this.timestamp)}else i=t,o=e,a=n;return{actualLandmarksFiltered:i,auxiliaryLandmarksFiltered:o,actualWorldLandmarksFiltered:a}},t}();function At(t){return c(this,0,void 0,function(){var e,r,i,o,a,s;return f(this,function(u){switch(u.label){case 0:return e=function(t){var e=h({},null==t?ht:t);if(null==e.enableSmoothing&&(e.enableSmoothing=ht.enableSmoothing),null==e.enableSegmentation&&(e.enableSegmentation=ht.enableSegmentation),null==e.smoothSegmentation&&(e.smoothSegmentation=ht.smoothSegmentation),null==e.modelType&&(e.modelType=ht.modelType),null==e.detectorModelUrl&&(e.detectorModelUrl=ht.detectorModelUrl),null==e.landmarkModelUrl)switch(e.modelType){case"lite":e.landmarkModelUrl="https://tfhub.dev/mediapipe/tfjs-model/blazepose_3d/landmark/lite/2";break;case"heavy":e.landmarkModelUrl="https://tfhub.dev/mediapipe/tfjs-model/blazepose_3d/landmark/heavy/2";break;default:e.landmarkModelUrl="https://tfhub.dev/mediapipe/tfjs-model/blazepose_3d/landmark/full/2"}return e}(t),r="string"==typeof e.detectorModelUrl&&e.detectorModelUrl.indexOf("https://tfhub.dev")>-1,i="string"==typeof e.landmarkModelUrl&&e.landmarkModelUrl.indexOf("https://tfhub.dev")>-1,[4,Promise.all([n.loadGraphModel(e.detectorModelUrl,{fromTFHub:r}),n.loadGraphModel(e.landmarkModelUrl,{fromTFHub:i})])];case 1:return o=u.sent(),a=o[0],s=o[1],[2,new Et(a,s,e.enableSmoothing,e.enableSegmentation,e.smoothSegmentation,e.modelType)]}})})}exports.TrackerType=void 0,exports.SupportedModels=void 0;var Ft,Pt=function(){function t(t){!function(t){if(t.maxTracks<1)throw new Error("Must specify 'maxTracks' to be at least 1, but "+"encountered ".concat(t.maxTracks));if(t.maxAge<=0)throw new Error("Must specify 'maxAge' to be positive, but "+"encountered ".concat(t.maxAge));if(void 0!==t.keypointTrackerParams){if(t.keypointTrackerParams.keypointConfidenceThreshold<0||t.keypointTrackerParams.keypointConfidenceThreshold>1)throw new Error("Must specify 'keypointConfidenceThreshold' to be in the range [0, 1], but encountered "+"".concat(t.keypointTrackerParams.keypointConfidenceThreshold));if(t.keypointTrackerParams.minNumberOfKeypoints<1)throw new Error("Must specify 'minNumberOfKeypoints' to be at least 1, but "+"encountered ".concat(t.keypointTrackerParams.minNumberOfKeypoints));for(var e=0,n=t.keypointTrackerParams.keypointFalloff;e<n.length;e++){var r=n[e];if(r<=0)throw new Error("Must specify each keypoint falloff parameterto be positive "+"but encountered ".concat(r))}}}(t),this.tracks=[],this.maxTracks=t.maxTracks,this.maxAge=1e3*t.maxAge,this.minSimilarity=t.minSimilarity,this.nextID=1}return t.prototype.apply=function(t,e){this.filterOldTracks(e);var n=this.computeSimilarity(t);return this.assignTracks(t,n,e),this.updateTracks(e),t},t.prototype.getTracks=function(){return this.tracks.slice()},t.prototype.getTrackIDs=function(){return new Set(this.tracks.map(function(t){return t.id}))},t.prototype.filterOldTracks=function(t){var e=this;this.tracks=this.tracks.filter(function(n){return t-n.lastTimestamp<=e.maxAge})},t.prototype.assignTracks=function(t,e,n){for(var r=Array.from(Array(e[0].length).keys()),i=[],o=0,a=Array.from(Array(t.length).keys());o<a.length;o++){var s=a[o];if(0!==r.length){for(var u=-1,l=-1,h=0,c=r;h<c.length;h++){var f=c[h],p=e[s][f];p>=this.minSimilarity&&p>l&&(u=f,l=p)}if(u>=0){var d=this.tracks[u];d=Object.assign(d,this.createTrack(t[s],n,d.id)),t[s].id=d.id;var m=r.indexOf(u);r.splice(m,1)}else i.push(s)}else i.push(s)}for(var y=0,g=i;y<g.length;y++){s=g[y];var v=this.createTrack(t[s],n);this.tracks.push(v),t[s].id=v.id}},t.prototype.updateTracks=function(t){this.tracks.sort(function(t,e){return e.lastTimestamp-t.lastTimestamp}),this.tracks=this.tracks.slice(0,this.maxTracks)},t.prototype.createTrack=function(t,e,n){var r={id:n||this.nextTrackID(),lastTimestamp:e,keypoints:p([],t.keypoints,!0).map(function(t){return h({},t)})};return void 0!==t.box&&(r.box=h({},t.box)),r},t.prototype.nextTrackID=function(){var t=this.nextID;return this.nextID+=1,t},t.prototype.remove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.tracks=this.tracks.filter(function(e){return!t.includes(e.id)})},t.prototype.reset=function(){this.tracks=[]},t}(),Ot=function(t){function e(e){return t.call(this,e)||this}return l(e,t),e.prototype.computeSimilarity=function(t){var e=this;return 0===t.length||0===this.tracks.length?[[]]:t.map(function(t){return e.tracks.map(function(n){return e.iou(t,n)})})},e.prototype.iou=function(t,e){var n=Math.max(t.box.xMin,e.box.xMin),r=Math.max(t.box.yMin,e.box.yMin),i=Math.min(t.box.xMax,e.box.xMax),o=Math.min(t.box.yMax,e.box.yMax);if(n>=i||r>=o)return 0;var a=(i-n)*(o-r);return a/(t.box.width*t.box.height+e.box.width*e.box.height-a)},e}(Pt),Rt=function(t){function e(e){var n=t.call(this,e)||this;return n.keypointThreshold=e.keypointTrackerParams.keypointConfidenceThreshold,n.keypointFalloff=e.keypointTrackerParams.keypointFalloff,n.minNumKeyoints=e.keypointTrackerParams.minNumberOfKeypoints,n}return l(e,t),e.prototype.computeSimilarity=function(t){if(0===t.length||0===this.tracks.length)return[[]];for(var e=[],n=0,r=t;n<r.length;n++){for(var i=r[n],o=[],a=0,s=this.tracks;a<s.length;a++){var u=s[a];o.push(this.oks(i,u))}e.push(o)}return e},e.prototype.oks=function(t,e){for(var n=this.area(e.keypoints)+1e-6,r=0,i=0,o=0;o<t.keypoints.length;++o){var a=t.keypoints[o],s=e.keypoints[o];if(!(a.score<this.keypointThreshold||s.score<this.keypointThreshold)){i+=1;var u=Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2),l=2*this.keypointFalloff[o];r+=Math.exp(-1*u/(2*n*Math.pow(l,2)))}}return i<this.minNumKeyoints?0:r/i},e.prototype.area=function(t){var e=this,n=t.filter(function(t){return t.score>e.keypointThreshold}),r=Math.min.apply(Math,p([1],n.map(function(t){return t.x}),!1)),i=Math.max.apply(Math,p([0],n.map(function(t){return t.x}),!1)),o=Math.min.apply(Math,p([1],n.map(function(t){return t.y}),!1));return(i-r)*(Math.max.apply(Math,p([0],n.map(function(t){return t.y}),!1))-o)},e}(Pt);function It(t){switch(t){case exports.SupportedModels.BlazePose:return m.reduce(function(t,e,n){return t[e]=n,t},{});case exports.SupportedModels.PoseNet:case exports.SupportedModels.MoveNet:return d.reduce(function(t,e,n){return t[e]=n,t},{});default:throw new Error("Model ".concat(t," is not supported."))}}(Ft=exports.TrackerType||(exports.TrackerType={})).Keypoint="keypoint",Ft.BoundingBox="boundingBox",function(t){t.MoveNet="MoveNet",t.BlazePose="BlazePose",t.PoseNet="PoseNet"}(exports.SupportedModels||(exports.SupportedModels={}));var Ct=Object.freeze({__proto__:null,getKeypointIndexBySide:function(t){switch(t){case exports.SupportedModels.BlazePose:return y;case exports.SupportedModels.PoseNet:case exports.SupportedModels.MoveNet:return g;default:throw new Error("Model ".concat(t," is not supported."))}},getAdjacentPairs:function(t){switch(t){case exports.SupportedModels.BlazePose:return b;case exports.SupportedModels.PoseNet:case exports.SupportedModels.MoveNet:return v;default:throw new Error("Model ".concat(t," is not supported."))}},getKeypointIndexByName:It}),Lt=["SinglePose.Lightning","SinglePose.Thunder","MultiPose.Lightning"],jt={modelType:"SinglePose.Lightning",enableSmoothing:!0},Nt={},zt={frequency:30,minCutOff:2.5,beta:300,derivateCutOff:2.5,thresholdCutOff:.5,thresholdBeta:5,disableValueScaling:!0},Bt={maxTracks:18,maxAge:1e3,minSimilarity:.2,keypointTrackerParams:{keypointConfidenceThreshold:.3,keypointFalloff:[.026,.025,.025,.035,.035,.079,.079,.072,.072,.062,.062,.107,.107,.087,.087,.089,.089],minNumberOfKeypoints:4}},Dt={maxTracks:18,maxAge:1e3,minSimilarity:.15,trackerParams:{}};function Ut(t,e){var n,r,i,o;return t?e.width>e.height?(n=1,r=e.height/e.width,i=0,o=(e.width/2-e.height/2)/e.width):(n=e.width/e.height,r=1,i=(e.height/2-e.width/2)/e.height,o=0):e.width>e.height?(n=e.width/e.height,r=1,i=(e.height/2-e.width/2)/e.height,o=0):(n=1,r=e.height/e.width,i=0,o=(e.width/2-e.height/2)/e.width),{yMin:i,xMin:o,yMax:i+n,xMax:o+r,height:n,width:r}}function Ht(t,e){var n={maxTracks:t.maxTracks,maxAge:t.maxAge,minSimilarity:t.minSimilarity};return null!=e.maxTracks&&(n.maxTracks=e.maxTracks),null!=e.maxAge&&(n.maxAge=e.maxAge),null!=e.minSimilarity&&(n.minSimilarity=e.minSimilarity),n}var Vt=function(){function t(t,e){this.moveNetModel=t,this.modelInputResolution={height:0,width:0},this.keypointIndexByName=It(exports.SupportedModels.MoveNet),"SinglePose.Lightning"===e.modelType?(this.modelInputResolution.width=192,this.modelInputResolution.height=192):"SinglePose.Thunder"===e.modelType&&(this.modelInputResolution.width=256,this.modelInputResolution.height=256),this.multiPoseModel="MultiPose.Lightning"===e.modelType,this.multiPoseModel||(this.keypointFilter=new it(zt),this.cropRegionFilterYMin=new nt(.9),this.cropRegionFilterXMin=new nt(.9),this.cropRegionFilterYMax=new nt(.9),this.cropRegionFilterXMax=new nt(.9)),this.enableSmoothing=e.enableSmoothing,e.minPoseScore?this.minPoseScore=e.minPoseScore:this.minPoseScore=.25,e.multiPoseMaxDimension?this.multiPoseMaxDimension=e.multiPoseMaxDimension:this.multiPoseMaxDimension=256,this.enableTracking=e.enableTracking,this.multiPoseModel&&this.enableTracking&&(e.trackerType===exports.TrackerType.Keypoint?this.tracker=new Rt(e.trackerConfig):e.trackerType===exports.TrackerType.BoundingBox&&(this.tracker=new Ot(e.trackerConfig)),this.enableSmoothing&&(this.keypointFilterMap=new Map))}return t.prototype.runSinglePersonPoseModel=function(t){return c(this,0,void 0,function(){var n,r,i,o,a;return f(this,function(s){switch(s.label){case 0:if(4!==(n=this.moveNetModel.execute(t)).shape.length||1!==n.shape[0]||1!==n.shape[1]||17!==n.shape[2]||3!==n.shape[3])throw n.dispose(),new Error("Unexpected output shape from model: [".concat(n.shape,"]"));return"webgpu"===e.getBackend()?[3,1]:(r=n.dataSync(),[3,3]);case 1:return[4,n.data()];case 2:r=s.sent(),s.label=3;case 3:for(n.dispose(),i={keypoints:[],score:0},o=0,a=0;a<17;++a)i.keypoints[a]={y:r[3*a],x:r[3*a+1],score:r[3*a+2]},i.keypoints[a].score>.2&&(++o,i.score+=i.keypoints[a].score);return o>0&&(i.score/=o),[2,i]}})})},t.prototype.runMultiPersonPoseModel=function(t){return c(this,0,void 0,function(){var n,r,i,o,a,s,u,l;return f(this,function(h){switch(h.label){case 0:if(3!==(n=this.moveNetModel.execute(t)).shape.length||1!==n.shape[0]||56!==n.shape[2])throw n.dispose(),new Error("Unexpected output shape from model: [".concat(n.shape,"]"));return"webgpu"===e.getBackend()?[3,1]:(r=n.dataSync(),[3,3]);case 1:return[4,n.data()];case 2:r=h.sent(),h.label=3;case 3:for(n.dispose(),i=[],o=r.length/56,a=0;a<o;++a)for(i[a]={keypoints:[]},s=56*a+51,i[a].box={yMin:r[s],xMin:r[s+1],yMax:r[s+2],xMax:r[s+3],width:r[s+3]-r[s+1],height:r[s+2]-r[s]},u=56*a+55,i[a].score=r[u],i[a].keypoints=[],l=0;l<17;++l)i[a].keypoints[l]={y:r[56*a+3*l],x:r[56*a+3*l+1],score:r[56*a+3*l+2]};return[2,i]}})})},t.prototype.estimatePoses=function(t,n,r){return void 0===n&&(n=Nt),c(this,0,void 0,function(){var i,o,a,s,u,l;return f(this,function(c){switch(c.label){case 0:return n=function(t){return null==t?Nt:h({},t)}(n),null==t?(this.reset(),[2,[]]):(null==r?V(t)&&(r=1e6*t.currentTime):r*=1e3,i=R(t),o=P(i),a=e.expandDims(i,0),t instanceof e.Tensor||i.dispose(),s=[],this.multiPoseModel?[3,2]:[4,this.estimateSinglePose(a,o,r)]);case 1:return s=c.sent(),[3,4];case 2:return[4,this.estimateMultiplePoses(a,o,r)];case 3:s=c.sent(),c.label=4;case 4:for(u=0;u<s.length;++u)for(l=0;l<s[u].keypoints.length;++l)s[u].keypoints[l].name=d[l],s[u].keypoints[l].y*=o.height,s[u].keypoints[l].x*=o.width;return[2,s]}})})},t.prototype.estimateSinglePose=function(t,n,r){return c(this,0,void 0,function(){var i,o,a,s,u=this;return f(this,function(l){switch(l.label){case 0:return this.cropRegion||(this.cropRegion=Ut(null==this.cropRegion,n)),i=e.tidy(function(){var n=e.tensor2d([[u.cropRegion.yMin,u.cropRegion.xMin,u.cropRegion.yMax,u.cropRegion.xMax]]),r=e.zeros([1],"int32"),i=[u.modelInputResolution.height,u.modelInputResolution.width];return e.cast(e.image.cropAndResize(t,n,r,i,"bilinear",0),"int32")}),t.dispose(),[4,this.runSinglePersonPoseModel(i)];case 1:if(o=l.sent(),i.dispose(),o.score<this.minPoseScore)return this.reset(),[2,[]];for(a=0;a<o.keypoints.length;++a)o.keypoints[a].y=this.cropRegion.yMin+o.keypoints[a].y*this.cropRegion.height,o.keypoints[a].x=this.cropRegion.xMin+o.keypoints[a].x*this.cropRegion.width;return null!=r&&this.enableSmoothing&&(o.keypoints=this.keypointFilter.apply(o.keypoints,r,1)),s=function(t,e,n,r){for(var i={},o=0,a=d;o<a.length;o++){var s=a[o];i[s]=[e[n[s]].y*r.height,e[n[s]].x*r.width]}if(function(t,e){return(t[e.left_hip].score>.2||t[e.right_hip].score>.2)&&(t[e.left_shoulder].score>.2||t[e.right_shoulder].score>.2)}(e,n)){var u=(i.left_hip[0]+i.right_hip[0])/2,l=(i.left_hip[1]+i.right_hip[1])/2,h=function(t,e,n,r,i){for(var o=["left_shoulder","right_shoulder","left_hip","right_hip"],a=0,s=0,u=0;u<o.length;u++)(p=Math.abs(r-n[o[u]][0]))>a&&(a=p),(d=Math.abs(i-n[o[u]][1]))>s&&(s=d);for(var l=0,h=0,c=0,f=Object.keys(n);c<f.length;c++){var p,d,m=f[c];t[e[m]].score<.2||((p=Math.abs(r-n[m][0]))>l&&(l=p),(d=Math.abs(i-n[m][1]))>h&&(h=d))}return[a,s,l,h]}(e,n,i,u,l),c=h[0],f=h[1],p=h[2],m=h[3],y=Math.max(1.9*f,1.9*c,1.2*p,1.2*m),g=[u-(y=Math.min(y,Math.max(l,r.width-l,u,r.height-u))),l-y];if(y>Math.max(r.width,r.height)/2)return Ut(null==t,r);var v=2*y;return{yMin:g[0]/r.height,xMin:g[1]/r.width,yMax:(g[0]+v)/r.height,xMax:(g[1]+v)/r.width,height:(g[0]+v)/r.height-g[0]/r.height,width:(g[1]+v)/r.width-g[1]/r.width}}return Ut(null==t,r)}(this.cropRegion,o.keypoints,this.keypointIndexByName,n),this.cropRegion=this.filterCropRegion(s),[2,[o]]}})})},t.prototype.estimateMultiplePoses=function(t,n,r){return c(this,0,void 0,function(){var i,o,a,s,u,l,h,c,p,d,m,y=this;return f(this,function(f){switch(f.label){case 0:return n.width>n.height?(o=this.multiPoseMaxDimension,a=Math.round(this.multiPoseMaxDimension*n.height/n.width),i=e.image.resizeBilinear(t,[a,o]),u=o,l=32*Math.ceil(a/32),s=e.pad(i,[[0,0],[0,l-a],[0,0],[0,0]])):(o=Math.round(this.multiPoseMaxDimension*n.width/n.height),a=this.multiPoseMaxDimension,i=e.image.resizeBilinear(t,[a,o]),u=32*Math.ceil(o/32),l=a,s=e.pad(i,[[0,0],[0,0],[0,u-o],[0,0]])),i.dispose(),t.dispose(),h=e.cast(s,"int32"),s.dispose(),[4,this.runMultiPersonPoseModel(h)];case 1:for(c=f.sent(),h.dispose(),c=c.filter(function(t){return t.score>=y.minPoseScore}),d=0;d<c.length;++d)for(p=0;p<c[d].keypoints.length;++p)c[d].keypoints[p].y*=l/a,c[d].keypoints[p].x*=u/o;if(this.enableTracking&&(this.tracker.apply(c,r),this.enableSmoothing)){for(d=0;d<c.length;++d)this.keypointFilterMap.has(c[d].id)||this.keypointFilterMap.set(c[d].id,new it(zt)),c[d].keypoints=this.keypointFilterMap.get(c[d].id).apply(c[d].keypoints,r,1);m=this.tracker.getTrackIDs(),this.keypointFilterMap.forEach(function(t,e){m.has(e)||y.keypointFilterMap.delete(e)})}return[2,c]}})})},t.prototype.filterCropRegion=function(t){if(t){var e=this.cropRegionFilterYMin.apply(t.yMin),n=this.cropRegionFilterXMin.apply(t.xMin),r=this.cropRegionFilterYMax.apply(t.yMax),i=this.cropRegionFilterXMax.apply(t.xMax);return{yMin:e,xMin:n,yMax:r,xMax:i,height:r-e,width:i-n}}return this.cropRegionFilterYMin.reset(),this.cropRegionFilterXMin.reset(),this.cropRegionFilterYMax.reset(),this.cropRegionFilterXMax.reset(),null},t.prototype.dispose=function(){this.moveNetModel.dispose()},t.prototype.reset=function(){this.cropRegion=null,this.resetFilters()},t.prototype.resetFilters=function(){this.keypointFilter.reset(),this.cropRegionFilterYMin.reset(),this.cropRegionFilterXMin.reset(),this.cropRegionFilterYMax.reset(),this.cropRegionFilterXMax.reset()},t}();function Gt(t){return void 0===t&&(t=jt),c(this,0,void 0,function(){var r,i,o,a;return f(this,function(s){switch(s.label){case 0:return r=function(t){var e,n=null==t?jt:h({},t);if(null==n.modelType)n.modelType="SinglePose.Lightning";else if(Lt.indexOf(n.modelType)<0)throw new Error("Invalid architecture ".concat(n.modelType,". ")+"Should be one of ".concat(Lt));if(null==n.enableSmoothing&&(n.enableSmoothing=!0),null!=n.minPoseScore&&(n.minPoseScore<0||n.minPoseScore>1))throw new Error("minPoseScore should be between 0.0 and 1.0");if(null!=n.multiPoseMaxDimension&&(n.multiPoseMaxDimension%32!=0||n.multiPoseMaxDimension<32))throw new Error("multiPoseMaxDimension must be a multiple of 32 and higher than 0");if("MultiPose.Lightning"===n.modelType&&null==n.enableTracking&&(n.enableTracking=!0),"MultiPose.Lightning"===n.modelType&&!0===n.enableTracking)if(null==n.trackerType&&(n.trackerType=exports.TrackerType.BoundingBox),n.trackerType===exports.TrackerType.Keypoint)null!=n.trackerConfig?n.trackerConfig=function(t){var e=Ht(Bt,t);return e.keypointTrackerParams=h({},Bt.keypointTrackerParams),null!=t.keypointTrackerParams&&(null!=t.keypointTrackerParams.keypointConfidenceThreshold&&(e.keypointTrackerParams.keypointConfidenceThreshold=t.keypointTrackerParams.keypointConfidenceThreshold),null!=t.keypointTrackerParams.keypointFalloff&&(e.keypointTrackerParams.keypointFalloff=t.keypointTrackerParams.keypointFalloff),null!=t.keypointTrackerParams.minNumberOfKeypoints&&(e.keypointTrackerParams.minNumberOfKeypoints=t.keypointTrackerParams.minNumberOfKeypoints)),e}(n.trackerConfig):n.trackerConfig=Bt;else{if(n.trackerType!==exports.TrackerType.BoundingBox)throw new Error("Tracker type not supported by MoveNet");null!=n.trackerConfig?n.trackerConfig=(e=n.trackerConfig,Ht(Dt,e)):n.trackerConfig=Dt}return n}(t),o=!0,r.modelUrl?(o="string"==typeof r.modelUrl&&r.modelUrl.indexOf("https://tfhub.dev")>-1,[4,n.loadGraphModel(r.modelUrl,{fromTFHub:o})]):[3,2];case 1:return i=s.sent(),[3,4];case 2:return a=void 0,"SinglePose.Lightning"===r.modelType?a="https://tfhub.dev/google/tfjs-model/movenet/singlepose/lightning/4":"SinglePose.Thunder"===r.modelType?a="https://tfhub.dev/google/tfjs-model/movenet/singlepose/thunder/4":"MultiPose.Lightning"===r.modelType&&(a="https://tfhub.dev/google/tfjs-model/movenet/multipose/lightning/1"),[4,n.loadGraphModel(a,{fromTFHub:o})];case 3:i=s.sent(),s.label=4;case 4:return"webgl"===e.getBackend()&&e.env().set("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",0),[2,new Vt(i,r)]}})})}var Kt={architecture:"MobileNetV1",outputStride:16,multiplier:.75,inputResolution:{height:257,width:257}},qt=["MobileNetV1","ResNet50"],Yt={MobileNetV1:[8,16],ResNet50:[16]},Xt=[8,16,32],Wt={MobileNetV1:[.5,.75,1],ResNet50:[1]},Qt=[1,2,4],Jt={maxPoses:1,flipHorizontal:!1},Zt={maxPoses:5,flipHorizontal:!1,scoreThreshold:.5,nmsRadius:20},$t=[-123.15,-115.9,-103.06];function te(t){return Math.floor(t/2)}var ee=function(){function t(t,e){this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=e}return t.prototype.enqueue=function(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)},t.prototype.dequeue=function(){var t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t},t.prototype.empty=function(){return-1===this.numberOfElements},t.prototype.size=function(){return this.numberOfElements+1},t.prototype.all=function(){return this.priorityQueue.slice(0,this.numberOfElements+1)},t.prototype.max=function(){return this.priorityQueue[0]},t.prototype.swim=function(t){for(;t>0&&this.less(te(t),t);)this.exchange(t,te(t)),t=te(t)},t.prototype.sink=function(t){for(;2*t<=this.numberOfElements;){var e=2*t;if(e<this.numberOfElements&&this.less(e,e+1)&&e++,!this.less(t,e))break;this.exchange(t,e),t=e}},t.prototype.getValueAt=function(t){return this.getElementValue(this.priorityQueue[t])},t.prototype.less=function(t,e){return this.getValueAt(t)<this.getValueAt(e)},t.prototype.exchange=function(t,e){var n=this.priorityQueue[t];this.priorityQueue[t]=this.priorityQueue[e],this.priorityQueue[e]=n},t}();function ne(t,e,n,r,i,o){for(var a=o.shape,s=a[0],u=a[1],l=!0,h=Math.max(n-i,0),c=Math.min(n+i+1,s),f=h;f<c;++f){for(var p=Math.max(r-i,0),d=Math.min(r+i+1,u),m=p;m<d;++m)if(o.get(f,m,t)>e){l=!1;break}if(!l)break}return l}function re(t){return c(this,0,void 0,function(){return f(this,function(e){return[2,Promise.all(t.map(function(t){return t.buffer()}))]})})}function ie(t,e,n,r){return{y:r.get(t,e,n),x:r.get(t,e,n+17)}}function oe(t,e,n){var r=ie(t.heatmapY,t.heatmapX,t.id,n),i=r.y,o=r.x;return{x:t.heatmapX*e+o,y:t.heatmapY*e+i}}function ae(t,e,n,r){var i=n.x,o=n.y;return t.some(function(t){var n,a,s,u,l=t.keypoints;return n=o,a=i,(s=l[r].y-n)*s+(u=l[r].x-a)*u<=e})}var se=d.reduce(function(t,e,n){return t[e]=n,t},{}),ue=[["nose","left_eye"],["left_eye","left_ear"],["nose","right_eye"],["right_eye","right_ear"],["nose","left_shoulder"],["left_shoulder","left_elbow"],["left_elbow","left_wrist"],["left_shoulder","left_hip"],["left_hip","left_knee"],["left_knee","left_ankle"],["nose","right_shoulder"],["right_shoulder","right_elbow"],["right_elbow","right_wrist"],["right_shoulder","right_hip"],["right_hip","right_knee"],["right_knee","right_ankle"]].map(function(t){var e=t[0],n=t[1];return[se[e],se[n]]}),le=ue.map(function(t){return t[1]}),he=ue.map(function(t){return t[0]});function ce(t,e,n){return t<e?e:t>n?n:t}function fe(t,e,n,r){return{y:ce(Math.round(t.y/e),0,n-1),x:ce(Math.round(t.x/e),0,r-1)}}function pe(t,e){return{x:t.x+e.x,y:t.y+e.y}}function de(t,e,n,r,i,o,a,s){void 0===s&&(s=2);for(var u=r.shape,l=u[0],h=u[1],c={y:e.y,x:e.x},f=pe(c,function(t,e,n){var r=n.shape[2]/2;return{y:n.get(e.y,e.x,t),x:n.get(e.y,e.x,r+t)}}(t,fe(c,o,l,h),a)),p=0;p<s;p++){var m=fe(f,o,l,h),y=ie(m.y,m.x,n,i);f=pe({x:m.x*o,y:m.y*o},{x:y.x,y:y.y})}var g=fe(f,o,l,h),v=r.get(g.y,g.x,n);return{y:f.y,x:f.x,name:d[n],score:v}}function me(t,e,n,r,i,o){var a=e.shape[2],s=le.length,u=new Array(a),l=t.part,h=t.score,c=oe(l,r,n);u[l.id]={score:h,name:d[l.id],y:c.y,x:c.x};for(var f=s-1;f>=0;--f){var p=le[f],m=he[f];u[p]&&!u[m]&&(u[m]=de(f,u[p],m,e,n,r,o))}for(f=0;f<s;++f)p=he[f],m=le[f],u[p]&&!u[m]&&(u[m]=de(f,u[p],m,e,n,r,i));return u}function ye(t,e,n){return n.reduce(function(n,r,i){var o=r.y,a=r.x,s=r.score;return ae(t,e,{y:o,x:a},i)||(n+=s),n},0)/n.length}function ge(t,e,n,r,i,o,a,s){return void 0===a&&(a=.5),void 0===s&&(s=20),c(this,0,void 0,function(){var u,l,h,c,p,d,m,y,g,v,b,w;return f(this,function(f){switch(f.label){case 0:return[4,re([t,e,n,r])];case 1:for(u=f.sent(),l=u[0],h=u[1],c=u[2],p=u[3],d=[],m=function(t,e,n){for(var r=n.shape,i=r[0],o=r[1],a=r[2],s=new ee(i*o*a,function(t){return t.score}),u=0;u<i;++u)for(var l=0;l<o;++l)for(var h=0;h<a;++h){var c=n.get(u,l,h);c<t||ne(h,c,u,l,1,n)&&s.enqueue({score:c,part:{heatmapY:u,heatmapX:l,id:h}})}return s}(a,0,l),y=s*s;d.length<o&&!m.empty();)g=m.dequeue(),v=oe(g.part,i,h),ae(d,y,v,g.part.id)||(b=me(g,l,h,i,c,p),w=ye(d,y,b),d.push({keypoints:b,score:w}));return[2,d]}})})}function ve(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];switch(e.length){case 0:t="fn main() ";break;case 1:t="fn main(".concat(e[0]," : i32)");break;default:throw Error("Unreachable")}return t}var be=function(){function t(t){this.variableNames=["A","B"],this.size=!0,this.workgroupSize=[32,1,1],this.outputShape=[t[0],1],this.dispatchLayout=r.webgpu_util.flatDispatchLayout(this.outputShape),this.dispatch=r.webgpu_util.computeDispatch(this.dispatchLayout,this.outputShape,this.workgroupSize),this.shaderKey="getpointsConfidenceOp"}return t.prototype.getUserCode=function(){return"\n ".concat(ve("index")," {\n if (index < uniforms.size) {\n let y = B[index * 2];\n let x = B[index * 2 + 1];\n let outIndex = y * uniforms.aShape.x * uniforms.aShape.z + x * uniforms.aShape.z + index;\n result[index] = A[outIndex];\n }\n }\n ")},t}();var we=function(){function t(t){if(this.variableNames=["A","B"],this.size=!0,this.supportedLastDimension=2,2!==t.length||t[1]!==this.supportedLastDimension)throw new Error("GetOffsetVectorsProgram only supports shape of [x, ".concat(this.supportedLastDimension,"], but current shape is ").concat(t));this.workgroupSize=[32,1,1],this.outputShape=t;var e=[t[0],1];this.dispatchLayout=r.webgpu_util.flatDispatchLayout(e),this.dispatch=r.webgpu_util.computeDispatch(this.dispatchLayout,e,this.workgroupSize),this.shaderKey="GetOffsetVectors"}return t.prototype.getUserCode=function(){return"\n fn getOffsetPoint(y: i32, x: i32, index: i32) -> vec2<i32> {\n let outIndexY = y * uniforms.bShape.x * uniforms.bShape.y + x * uniforms.bShape.y + index;\n let outIndexX = outIndexY + uniforms.bShape.z;\n let outY = i32(B[outIndexY]);\n let outX = i32(B[outIndexX]);\n return vec2<i32>(outY, outX);\n }\n\n ".concat(ve("index")," {\n if (index < uniforms.size) {\n let indexY = index * ").concat(this.supportedLastDimension,";\n let indexX = indexY + 1;\n let heatmapY = A[indexY];\n let heatmapX = A[indexX];\n let out = getOffsetPoint(i32(heatmapY), i32(heatmapX), index);\n result[indexY] = f32(out[0]);\n result[indexX] = f32(out[1]);\n }\n }\n ")},t}();function xe(t){var n=t.shape,r=n[0],i=n[1],o=n[2];return e.tidy(function(){var n,a,s=e.reshape(t,[r*i,o]),u=e.argMax(s,0),l=e.expandDims(e.div(u,e.scalar(i,"int32")),1),h=e.expandDims((n=u,a=i,e.tidy(function(){var t=e.div(n,e.scalar(a,"int32"));return e.sub(n,e.mul(t,e.scalar(a,"int32")))})),1);return e.concat([l,h],1)})}function ke(t,n,r){return e.tidy(function(){var i=function(t,n){for(var r=[],i=0;i<d.length;i++){var o=Te(t.get(i,0).valueOf(),t.get(i,1).valueOf(),i,n),a=o.x,s=o.y;r.push(s),r.push(a)}return e.tensor2d(r,[d.length,2])}(t,r);return e.add(e.cast(e.mul(t.toTensor(),e.scalar(n,"int32")),"float32"),i)})}function Te(t,e,n,r){return{y:r.get(t,e,n),x:r.get(t,e,n+d.length)}}function Se(t,e,n){return c(this,0,void 0,function(){var r,i,o,a,s,u,l,h,c,p;return f(this,function(f){switch(f.label){case 0:return r=0,i=xe(t),[4,Promise.all([t.buffer(),e.buffer(),i.buffer()])];case 1:return o=f.sent(),a=o[0],s=o[1],u=o[2],[4,(l=ke(u,n,s)).buffer()];case 2:return h=f.sent(),c=Array.from(function(t,e){for(var n=e.shape[0],r=new Float32Array(n),i=0;i<n;i++){var o=e.get(i,0),a=e.get(i,1);r[i]=t.get(o,a,i)}return r}(a,u)),p=c.map(function(t,e){return r+=t,{y:h.get(e,0),x:h.get(e,1),score:t,name:d[e]}}),i.dispose(),l.dispose(),[2,{keypoints:p,score:r/p.length}]}})})}function Me(t,n,i){return c(this,0,void 0,function(){var o,a,s;return f(this,function(u){return o=xe(t),a=function(t,n,i){return e.tidy(function(){var o=function(t,n){if(e.backend()instanceof r.WebGPUBackend)return function(t,n){var r=e.backend(),i=new we(t.shape),o=r.runWebGPUProgram(i,[t,n],"float32");return e.engine().makeTensorFromTensorInfo(o)}(t,n);throw new Error("getOffsetVectorsGPU is not supported in this backend!")}(t,i);return e.add(e.cast(e.mul(t,e.scalar(n,"int32")),"float32"),o)})}(o,i,n),s=function(t,n){if(e.backend()instanceof r.WebGPUBackend)return function(t,n){var r=e.backend(),i=new be(n.shape),o=r.runWebGPUProgram(i,[t,n],"float32");return e.engine().makeTensorFromTensorInfo(o)}(t,n);throw new Error("getPointsConfidenceWebGPU is not supported in this backend!")}(t,o),[2,[a,s]]})})}function _e(t,e){return(t-1)%e==0}var Ee="https://storage.googleapis.com/tfjs-models/savedmodel/posenet/mobilenet/",Ae="https://storage.googleapis.com/tfjs-models/savedmodel/posenet/resnet50/";function Fe(t,e){return function(t,e){return(t-1)%e==0}(t,e)?t:Math.floor(t/e)*e+1}var Pe=function(){function t(t,n){this.posenetModel=t;var r=this.posenetModel.inputs[0].shape;e.util.assert(-1===r[1]&&-1===r[2],function(){return"Input shape [".concat(r[1],", ").concat(r[2],"] ")+"must both be equal to or -1"});var i,o,a=(i=n.inputResolution,o=n.outputStride,{height:Fe(i.height,o),width:Fe(i.width,o)});!function(t){e.util.assert(Xt.indexOf(t)>=0,function(){return"outputStride of ".concat(t," is invalid. ")+"It must be either 8 or 16."})}(n.outputStride),function(t,n){e.util.assert(_e(t.height,n),function(){return"height of ".concat(t.height," is invalid for output stride ")+"".concat(n,".")}),e.util.assert(_e(t.width,n),function(){return"width of ".concat(t.width," is invalid for output stride ")+"".concat(n,".")})}(a,n.outputStride),this.inputResolution=a,this.outputStride=n.outputStride,this.architecture=n.architecture}return t.prototype.estimatePoses=function(t,e){return void 0===e&&(e=Jt),c(this,0,void 0,function(){return f(this,function(n){return[2,this.estimatePosesGPU(t,e,!1)]})})},t.prototype.estimatePosesGPU=function(t,n,r){return void 0===n&&(n=Jt),void 0===r&&(r=!1),c(this,0,void 0,function(){var i,o,a,s,u,l,c,p,d,m,y,g,v,b,w,x,k,T;return f(this,function(f){switch(f.label){case 0:return i=function(t){var e=t;if(null==e.maxPoses&&(e.maxPoses=1),e.maxPoses<=0)throw new Error("Invalid maxPoses ".concat(e.maxPoses,". Should be > 0."));if(e.maxPoses>1){if((e=h(h({},Zt),e)).scoreThreshold<0||e.scoreThreshold>1)throw new Error("Invalid scoreThreshold ".concat(e.scoreThreshold,". ")+"Should be in range [0.0, 1.0]");if(e.nmsRadius<=0)throw new Error("Invalid nmsRadius ".concat(e.nmsRadius,"."))}return e}(n),null==t?[2,r?[[],[]]:[]]:(this.maxPoses=i.maxPoses,o=U(t,{outputTensorSize:this.inputResolution,keepAspectRatio:!0,borderMode:"replicate"}),a=o.imageTensor,s=o.padding,u="ResNet50"===this.architecture?e.add(a,$t):D(a,[-1,1]),l=this.posenetModel.predict(u),"ResNet50"===this.architecture?(c=e.squeeze(l[2],[0]),p=e.squeeze(l[3],[0]),d=e.squeeze(l[0],[0]),m=e.squeeze(l[1],[0])):(c=e.squeeze(l[0],[0]),p=e.squeeze(l[1],[0]),d=e.squeeze(l[2],[0]),m=e.squeeze(l[3],[0])),y=e.sigmoid(p),1!==this.maxPoses?[3,5]:r?[4,Me(y,c,this.outputStride)]:[3,2]);case 1:return v=f.sent(),w=v[0],b=v[1],g=[w,b],[3,4];case 2:return[4,Se(y,c,this.outputStride)];case 3:w=f.sent(),g=[w],f.label=4;case 4:return[3,7];case 5:if(r)throw new Error("GPU renderer only supports single pose!");return[4,ge(y,c,d,m,this.outputStride,this.maxPoses,i.scoreThreshold,i.nmsRadius)];case 6:g=f.sent(),f.label=7;case 7:if(r){if(!0===i.flipHorizontal)throw new Error("flipHorizontal is not supported!");x=this.getCanvasInfo(P(t),this.inputResolution,s)}else T=P(t),k=function(t,e,n,r){var i=e.height,o=e.width,a=i/(n.height*(1-r.top-r.bottom)),s=o/(n.width*(1-r.left-r.right)),u=-r.top*n.height,l=-r.left*n.width;if(1===s&&1===a&&0===u&&0===l)return t;for(var h=0,c=t;h<c.length;h++)for(var f=0,p=c[h].keypoints;f<p.length;f++){var d=p[f];d.x=(d.x+l)*s,d.y=(d.y+u)*a}return t}(g,T,this.inputResolution,s),i.flipHorizontal&&(k=function(t,e){for(var n=0,r=t;n<r.length;n++)for(var i=0,o=r[n].keypoints;i<o.length;i++){var a=o[i];a.x=e.width-1-a.x}return t}(k,T));return a.dispose(),u.dispose(),e.dispose(l),c.dispose(),p.dispose(),d.dispose(),m.dispose(),y.dispose(),[2,r?[g,x]:k]}})})},t.prototype.getCanvasInfo=function(t,e,n){var r=t.height,i=t.width,o=r/(e.height*(1-n.top-n.bottom)),a=i/(e.width*(1-n.left-n.right)),s=-n.top*e.height;return[-n.left*e.width,s,a,o,t.width,t.height]},t.prototype.dispose=function(){this.posenetModel.dispose()},t.prototype.reset=function(){},t}();function Oe(t){return void 0===t&&(t=Kt),c(this,0,void 0,function(){var e,r,i,o,a;return f(this,function(s){switch(s.label){case 0:return"ResNet50"!==(e=function(t){var e=t||Kt;if(null==e.architecture&&(e.architecture="MobileNetV1"),qt.indexOf(e.architecture)<0)throw new Error("Invalid architecture ".concat(e.architecture,". ")+"Should be one of ".concat(qt));if(null==e.inputResolution&&(e.inputResolution={height:257,width:257}),null==e.outputStride&&(e.outputStride=16),Yt[e.architecture].indexOf(e.outputStride)<0)throw new Error("Invalid outputStride ".concat(e.outputStride,". ")+"Should be one of ".concat(Yt[e.architecture]," ")+"for architecture ".concat(e.architecture,"."));if(null==e.multiplier&&(e.multiplier=1),Wt[e.architecture].indexOf(e.multiplier)<0)throw new Error("Invalid multiplier ".concat(e.multiplier,". ")+"Should be one of ".concat(Wt[e.architecture]," ")+"for architecture ".concat(e.architecture,"."));if(null==e.quantBytes&&(e.quantBytes=4),Qt.indexOf(e.quantBytes)<0)throw new Error("Invalid quantBytes ".concat(e.quantBytes,". ")+"Should be one of ".concat(Qt," ")+"for architecture ".concat(e.architecture,"."));if("MobileNetV1"===e.architecture&&32===e.outputStride&&1!==e.multiplier)throw new Error("When using an output stride of 32, you must select 1 as the multiplier.");return e}(t)).architecture?[3,2]:(u=e.outputStride,l=e.quantBytes,h="model-stride".concat(u,".json"),r=4===l?Ae+"float/"+h:Ae+"quant".concat(l,"/")+h,[4,n.loadGraphModel(e.modelUrl||r)]);case 1:return i=s.sent(),[2,new Pe(i,e)];case 2:return o=function(t,e,n){var r={1:"100",.75:"075",.5:"050"},i="model-stride".concat(t,".json");return 4===n?Ee+"float/".concat(r[e],"/")+i:Ee+"quant".concat(n,"/").concat(r[e],"/")+i}(e.outputStride,e.multiplier,e.quantBytes),[4,n.loadGraphModel(e.modelUrl||o)];case 3:return a=s.sent(),[2,new Pe(a,e)]}var u,l,h})})}var Re={keypointsToNormalizedKeypoints:et};exports.calculators=Re,exports.createDetector=function(t,e){return c(this,0,void 0,function(){var n,r;return f(this,function(i){switch(t){case exports.SupportedModels.PoseNet:return[2,Oe(e)];case exports.SupportedModels.BlazePose:if(r=void 0,null!=(n=e)){if("tfjs"===n.runtime)return[2,At(e)];if("mediapipe"===n.runtime)return[2,F(e)];r=n.runtime}throw new Error("Expect modelConfig.runtime to be either 'tfjs' "+"or 'mediapipe', but got ".concat(r));case exports.SupportedModels.MoveNet:return[2,Gt(e)];default:throw new Error("".concat(t," is not a supported model name."))}})})},exports.movenet={modelType:{SINGLEPOSE_LIGHTNING:"SinglePose.Lightning",SINGLEPOSE_THUNDER:"SinglePose.Thunder",MULTIPOSE_LIGHTNING:"MultiPose.Lightning"}},exports.util=Ct;
|
|
18
|
+
//# sourceMappingURL=pose-detection.esm-Dtxn0TmC.js.map
|