@swan-admin/swan-web-component 1.0.98 → 1.0.100

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.
@@ -0,0 +1,18 @@
1
+ import{getBackend as t,env as e,expandDims as n,Tensor as r,tidy as i,tensor2d as o,zeros as a,cast as s,image as u,pad as l,mirrorPad as h,dispose as c,squeeze as f,reshape as p,sigmoid as d,browser as m,add as y,tensor1d as g,backend as v,engine as b,sub as w,square as x,minimum as k,mul as S,slice as T,div as M,concat as _,clipByValue as E,exp as A,util as F,scalar as P,argMax as O}from"@tensorflow/tfjs-core";import{loadGraphModel as R}from"@tensorflow/tfjs-converter";import{WebGPUBackend as I,webgpu_util as C}from"@tensorflow/tfjs-backend-webgpu";var L,j="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},N={};function B(){return L||(L=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 j&&j];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 i(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 o(t){return(t={next:t})[Symbol.iterator]=function(){return this},t}function a(t){var n="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return n?n.call(t):{next:e(t)}}function s(t){if(!(t instanceof Array)){t=a(t);for(var e,n=[];!(e=t.next()).done;)n.push(e.value);t=n}return t}i("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)}}),i("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(" "),a=0;a<i.length;a++){var s=r[i[a]];"function"==typeof s&&"function"!=typeof s.prototype[t]&&n(s.prototype,t,{configurable:!0,writable:!0,value:function(){return o(e(this))}})}return t});var u="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};i("Object.assign",function(t){return t||u});var l,h="function"==typeof Object.create?Object.create:function(t){function e(){}return e.prototype=t,new e};if("function"==typeof Object.setPrototypeOf)l=Object.setPrototypeOf;else{var c;t:{var f={};try{f.__proto__={a:!0},c=f.a;break t}catch(t){}c=!1}l=c?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null}var p=l;function d(t,e){if(t.prototype=h(e.prototype),t.prototype.constructor=t,p)p(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 m(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function y(t){if(t.m)throw new TypeError("Generator is already running");t.m=!0}function g(t,e){t.l={ma:e,na:!0},t.h=t.s||t.v}function v(t,e,n){return t.h=n,{value:e}}function b(t){this.h=new m,this.i=t}function w(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,g(t.h,e),x(t)}return t.h.j=null,r.call(t.h,o),x(t)}function x(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,g(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 k(t){this.next=function(e){return y(t.h),t.h.j?e=w(t,t.h.j.next,e,t.h.u):(t.h.u(e),e=x(t)),e},this.throw=function(e){return y(t.h),t.h.j?e=w(t,t.h.j.throw,e,t.h.u):(g(t.h,e),e=x(t)),e},this.return=function(e){return function(t,e){y(t.h);var n=t.h.j;return n?w(t,"return"in n?n.return:function(t){return{value:t,done:!0}},e,t.h.return):(t.h.return(e),x(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 k(new b(t)))}function T(t){return t||Array.prototype.fill}m.prototype.u=function(t){this.i=t},m.prototype.return=function(t){this.l={return:t},this.h=this.v},i("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)s.i(this.h[t]);this.h=null}};var s=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?s.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=a(t),o=r.next();!o.done;o=r.next())i(o.value).T(e,n)})},e.all=function(t){var n=a(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}),i("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})}}),i("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}}),i("Int8Array.prototype.fill",T),i("Uint8Array.prototype.fill",T),i("Uint8ClampedArray.prototype.fill",T),i("Int16Array.prototype.fill",T),i("Uint16Array.prototype.fill",T),i("Int32Array.prototype.fill",T),i("Uint32Array.prototype.fill",T),i("Float32Array.prototype.fill",T),i("Float64Array.prototype.fill",T),i("Object.is",function(t){return t||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}}),i("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}}),i("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 M=this||self;function _(t,e){t=t.split(".");var n,r=M;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 E(t){var e;return(e=M.navigator)&&(e=e.userAgent)||(e=""),-1!=e.indexOf(t)}var A=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},F={},P=null;function O(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=P[n];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}R();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 R(){if(!P){P={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=t.concat(e[n].split(""));F[n]=r;for(var i=0;i<r.length;i++){var o=r[i];void 0===P[o]&&(P[o]=i)}}}}var I="undefined"!=typeof Uint8Array,C=!(E("Trident")||E("MSIE"))&&"function"==typeof M.btoa;function L(t){if(!C){var e;void 0===e&&(e=0),R(),e=F[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,B=RegExp("[-_.]","g");function z(t){switch(t){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function D(t){if(!C)return O(t);B.test(t)&&(t=t.replace(B,z)),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 Y(t){var e=0>t,n=(t=Math.abs(t))>>>0;t=Math.floor((t-n)/4294967296),e&&(e=(n=a(q(n,t))).next().value,t=n.next().value,n=e),G=n>>>0,K=t>>>0}var X,W="function"==typeof BigInt;function q(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 X||(X=new Q(0,0));if(!/^-?\d+$/.test(t))return null;if(16>t.length)Y(Number(t));else if(W)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=a(q(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||I&&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 St(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 Tt(t){switch(t.i){case 0:if(0!=t.i)Tt(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?Tt(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(!St(t))throw Error("Unmatched start-group tag: stream EOF");if(4==t.i){if(t.l!=e)throw Error("Unmatched end-group tag");break}Tt(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 Bt,zt,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),Yt(t,e,n,r)}function Yt(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 Xt(t,e,n,r){var i=Gt(t,e);Array.isArray(i)||(i=Bt);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):Yt(t,e,i=It(Array.prototype.slice.call(i)))}return i}function Wt(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&&Yt(t,e,r),r}function qt(t,e,n,r,i){t.h||(t.h={});var o=t.h[n],a=Xt(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&&Yt(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=qt(t,e,n,r,r),t=Xt(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=qt(t,n,e,!1,!1);return n=null!=r?r:new n,t=Xt(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(Wt(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(I&&null!=t&&t instanceof Uint8Array)return L(t);if(t instanceof ht){var e=t.V;return null==e?"":"string"==typeof e?e:t.V=L(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(I&&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=A(t,se)),Object.freeze(o),r=o),Ut(e),a=null==r?Bt: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);Yt(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,zt=r,r=new o(r),zt=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=zt),zt=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]=Bt:(r||(r=Vt(this)),(i=r[s])?he(i,e):r[s]=Bt)}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),Bt=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 Se(t,e,n){t.push(e,n.W)}function Te(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,Se,Te,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(;St(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,Tt(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=Wt(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,Y(e),wt(t,G,K)):(n=J(e),wt(t.h,n.i,n.h))))}),Be=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)}}),ze=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)}d(Ve,le);var Ge=[Ve,1,Be,2,je,3,ze,4,ze];function Ke(t){le.call(this,t,-1,Ye)}Ve.prototype.l=He(Ge),d(Ke,le),Ke.prototype.addClassification=function(t,e){return Zt(this,1,Ve,t,e),this};var Ye=[1],Xe=Ue([Ke,1,De,Ge]);function We(t){le.call(this,t)}d(We,le);var qe=[We,1,je,2,je,3,je,4,je,5,je];function Qe(t){le.call(this,t,-1,Je)}We.prototype.l=He(qe),d(Qe,le);var Je=[1],Ze=Ue([Qe,1,De,qe]);function $e(t){le.call(this,t)}d($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!=Wt(t,4)?te(t,4):void 0}}function an(t){return Qt(Ze(t),We,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=a(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,u,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,v(p,S(function(t){switch(t.h){case 1:return t.s=2,v(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}),u=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(u.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,v(i,e(n),2);r.i=i.i,i.h=0})}),c=S(function(e){return t.h.graph&&t.h.graph.url?e=v(e,mn(t,t.h.graph.url),0):(e.h=0,e=void 0),e}),v(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,s(r)),i=t,v(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,s,u,l,h,c,f,p,d,m,y,g;return S(function(b){switch(b.h){case 1:if(!n)return b.return(e);for(r={},i=0,o=a(Object.keys(n)),s=o.next();!s.done;s=o.next())u=s.value,"string"!=typeof(l=n[u])&&"texture"===l.type&&void 0!==e[l.stream]&&++i;1<i&&(t.M=!1),h=a(Object.keys(n)),s=h.next();case 2:if(s.done){b.h=4;break}if(c=s.value,"string"==typeof(f=n[c]))return y=r,g=c,v(b,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(Xe(k.get(M)))},T.push(_)}w=T}else w=[];r[c]=w,b.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,b.h=7;break}if(void 0===p){b.h=3;break}if("float_list"===f.type){r[c]=p,b.h=7;break}if("proto"===f.type){r[c]=p,b.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),v(b,un(d,p,t.M),13);case 13:m=b.i,r[c]=m;case 7:f.transform&&r[c]&&(r[c]=f.transform(r[c])),b.h=3;break;case 14:y[g]=b.i;case 3:s=h.next(),b.h=2;break;case 4:return b.return(r)}})}function gn(t,e){for(var n=e.name||"$",r=[].concat(s(e.wants)),i=new t.i.StringList,o=a(e.wants),u=o.next();!u.done;u=o.next())i.push_back(u.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,v(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={},s=a(Object.keys(t)),u=s.next();!u.done;o={X:o.X,Y:o.Y},u=s.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 v(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?v(e,dn(t),2):3!=e.h?v(e,function(t){var e,n,r,i,o,s,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,v(h,mn(t,t.h.graph.url),3)):void(h.h=2));for(2!=h.h&&(e=h.i,t.j.loadGraph(e)),n=a(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=a(t.h.listeners),s=o.next();!s.done;s=o.next())u=s.value,gn(t,u);l=t.l,t.l={},t.setOptions(l),h.h=0})}(t),3):v(e,function(t){var e,n,r,i,o,s;return S(function(u){switch(u.h){case 1:if(!t.u)return u.return();if(!t.F){u.h=2;break}e=a(t.F),n=e.next();case 3:if(n.done){u.h=5;break}return v(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=a(t.H),o=i.next();!o.done;o=i.next())s=o.value,r.push_back(s);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,s,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),v(p,f.I,2)):p.return();case 2:return v(p,f.initialize(),3);case 3:for(r=new f.i.PacketDataList,i=a(Object.keys(t)),o=i.next();!o.done;o=i.next())if(s=o.value,u=f.h.inputs[s]){t:{var d=t[s];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 b=m.data,w=b.setBoundingBox,x=g,k=y.la,S=new $e;if(Jt(S,1,k.sa),Jt(S,2,k.ta),Jt(S,3,k.height),Jt(S,4,k.width),Jt(S,5,k.rotation),Kt(S,6,k.pa),k=S.l(),w.call(b,x,k),y.ea)for(b=0;b<y.ea.length;++b){S=y.ea[b],x=(w=m.data).addNormalizedLandmark,k=g,S=Object.assign({},S,{visibility:S.visibility?S.visibility:0});var T=new We;Jt(T,1,S.x),Jt(T,2,S.y),Jt(T,3,S.z),S.visibility&&Jt(T,4,S.visibility),S=T.l(),x.call(w,k,S)}if(y.ba)for(b=0;b<y.ba.length;++b)x=(w=m.data).addClassification,k=g,S=y.ba[b],Jt(T=new Ve,2,S.qa),S.index&&Kt(T,1,S.index),S.label&&Kt(T,3,S.label),S.displayName&&Kt(T,4,S.displayName),S=T.l(),x.call(w,k,S)}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),v(p,f.I,4);case 4:r.delete(),p.h=0}})},t.onResults=function(t,e){this.listeners[e||"$"]=t},_("Solution",pn),_("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 v(e,t.h.initialize(),0)})},t.send=function(t,e){var n=this;return S(function(r){return v(r,n.h.send(t,e),0)})},t.setOptions=function(t){this.h.setOptions(t)},_("Pose",bn),_("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]]),_("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}),_("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}),_("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}),_("POSE_LANDMARKS_NEUTRAL",{NOSE:0}),_("VERSION","0.5.1675469404")}.call(N)),N}var z=B(),D=function(t,e){return(D=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 U(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}D(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 V(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 G(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 K(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 Y=["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"],X=["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"],W={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]},q={left:[1,3,5,7,9,11,13,15],right:[2,4,6,8,10,12,14,16],middle:[0]},Q=[[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]],J=[[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 Z(t){return t instanceof SVGAnimatedLength?t.baseVal.value:t}function $(t){return V(this,0,void 0,function(){var e,n;return G(this,function(i){switch(i.label){case 0:return e=document.createElement("canvas"),t instanceof r?[4,m.toPixels(t,e)]:[3,2];case 1:return i.sent(),[3,3];case 2:e.width=Z(t.width),e.height=Z(t.height),n=e.getContext("2d"),t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0),i.label=3;case 3:return[2,e]}})})}function tt(t){return V(this,0,void 0,function(){var e,n,i,o,a,s;return G(this,function(u){switch(u.label){case 0:return t instanceof r?(e=t.shape.slice(0,2),n=e[0],i=e[1],o=ImageData.bind,[4,m.toPixels(t)]):[3,2];case 1:return[2,new(o.apply(ImageData,[void 0,u.sent(),i,n]))];case 2:return a=document.createElement("canvas"),s=a.getContext("2d"),a.width=Z(t.width),a.height=Z(t.height),s.drawImage(t,0,0),[2,s.getImageData(0,0,a.width,a.height)]}})})}function et(t){return V(this,0,void 0,function(){var e,n;return G(this,function(r){switch(r.label){case 0:return t instanceof SVGImageElement||t instanceof OffscreenCanvas?[4,$(t)]:[3,2];case 1:return n=r.sent(),[3,3];case 2:n=t,r.label=3;case 3:return e=n,[2,m.fromPixels(e,4)]}})})}function nt(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 rt={runtime:"mediapipe",enableSmoothing:!0,enableSegmentation:!1,smoothSegmentation:!0,modelType:"full"},it=function(){function t(t){this.mask=t}return t.prototype.toCanvasImageSource=function(){return V(this,0,void 0,function(){return G(this,function(t){return[2,this.mask]})})},t.prototype.toImageData=function(){return V(this,0,void 0,function(){return G(this,function(t){return[2,tt(this.mask)]})})},t.prototype.toTensor=function(){return V(this,0,void 0,function(){return G(this,function(t){return[2,et(this.mask)]})})},t.prototype.getUnderlyingType=function(){return"canvasimagesource"},t}();function ot(t){return nt(t),"person"}var at=function(){function t(t){var e,n=this;switch(this.width=0,this.height=0,this.selfieMode=!1,this.poseSolution=new z.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:ot,mask:new it(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:X[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:X[e]}})),r},t.prototype.estimatePoses=function(t,e,n){return V(this,0,void 0,function(){var i,o;return G(this,function(a){switch(a.label){case 0:return e&&e.flipHorizontal&&e.flipHorizontal!==this.selfieMode&&(this.selfieMode=e.flipHorizontal,this.poseSolution.setOptions({selfieMode:this.selfieMode})),t instanceof r?(o=ImageData.bind,[4,m.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},n)];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 st(t){return V(this,0,void 0,function(){var e,n;return G(this,function(r){switch(r.label){case 0:return e=function(t){if(null==t)return H({},rt);var e=H({},t);return e.runtime="mediapipe",null==e.enableSegmentation&&(e.enableSegmentation=rt.enableSegmentation),null==e.enableSmoothing&&(e.enableSmoothing=rt.enableSmoothing),null==e.smoothSegmentation&&(e.smoothSegmentation=rt.smoothSegmentation),null==e.modelType&&(e.modelType=rt.modelType),e}(t),[4,(n=new at(e)).initialize()];case 1:return r.sent(),[2,n]}})})}function ut(t){return t instanceof r?{height:t.shape[0],width:t.shape[1]}:{height:t.height,width:t.width}}function lt(t){return t-2*Math.PI*Math.floor((t+Math.PI)/(2*Math.PI))}function ht(t){return t instanceof r?t:m.fromPixels(t)}function ct(t,e,n){return ft(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 ft(t,e){F.assert(0!==t.width,function(){return"".concat(e," width cannot be 0.")}),F.assert(0!==t.height,function(){return"".concat(e," height cannot be 0.")})}function pt(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 lt(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 dt(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 mt(t,e,n,r,i,o,a){return t[e][i]*(t[n][o]*t[r][a]-t[n][a]*t[r][o])}function yt(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 mt(t,r,i,o,a,s,u)+mt(t,i,o,r,a,s,u)+mt(t,o,r,i,a,s,u)}function gt(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,h=Math.cos(l)*s-Math.sin(l)*u,c=Math.sin(l)*s+Math.cos(l)*u;h=h*e.width+e.xCenter,c=c*e.height+e.yCenter;var f=a.z*e.width,p=H({},a);p.x=h,p.y=c,p.z=f,r.push(p)}return r}function vt(t,e){var n=function(t,e,n,r){var i=(r-n)/255;return{scale:i,offset:n-0*i}}(0,0,e[0],e[1]);return i(function(){return y(S(t,n.scale),n.offset)})}function bt(t,e,r){var a,l,h,c,f,p,d,m,y,g,v,b,w=e.outputTensorSize,x=e.keepAspectRatio,k=e.borderMode,S=e.outputTensorFloatRange,T=ut(t),M=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}}(T,r),_=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;ft(e,"targetSize"),ft(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}}(M,w,x),E=(a=M,l=T.width,h=T.height,c=a.width,f=a.height,p=Math.cos(a.rotation),d=Math.sin(a.rotation),m=a.xCenter,y=a.yCenter,g=1/l,v=1/h,(b=new Array(16))[0]=c*p*1*g,b[1]=-f*d*g,b[2]=0,b[3]=(-.5*c*p*1+.5*f*d+m)*g,b[4]=c*d*1*v,b[5]=f*p*v,b[6]=0,b[7]=(-.5*f*p-.5*c*d*1+y)*v,b[8]=0,b[9]=0,b[10]=c*g,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,dt(b));return{imageTensor:i(function(){var e=ht(t),r=o(ct(E,T,w),[1,8]),i="zero"===k?"constant":"nearest",a=u.transform(n(s(e,"float32")),r,"bilinear",i,0,[w.height,w.width]);return null!=S?vt(a,S):a}),padding:_,transformationMatrix:E}}function wt(t,e,n,r){return 1===r?.5*(t+e):t+(e-t)*n/(r-1)}function xt(t){return null!=t&&null!=t.currentTime}function kt(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 St(t,e,n,r){return V(this,0,void 0,function(){var r,i,a,s,l;return G(this,function(h){switch(h.label){case 0:return t.sort(function(t,e){return Math.max.apply(Math,e.score)-Math.max.apply(Math,t.score)}),r=o(t.map(function(t){return[t.locationData.relativeBoundingBox.yMin,t.locationData.relativeBoundingBox.xMin,t.locationData.relativeBoundingBox.yMax,t.locationData.relativeBoundingBox.xMax]})),i=g(t.map(function(t){return t.score[0]})),[4,u.nonMaxSuppressionAsync(r,i,e,n)];case 1:return[4,(a=h.sent()).array()];case 2:return s=h.sent(),l=t.filter(function(t,e){return s.indexOf(e)>-1}),c([r,i,a]),[2,l]}})})}function Tt(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 Mt(t,e,n){return V(this,0,void 0,function(){var r,i,o,a,s,u,l,h,c,p,d,m,y,g,v,b,w,x,k,S,T,M,_,E;return G(this,function(A){switch(A.label){case 0:if(r=f(e,[0]),i=r.shape,o=i[0],a=i[1],s=i[2],t.length!==s)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(s));return u=[],[4,r.buffer()];case 1:for(l=A.sent(),h=0;h<t.length;h++)if(c=t[h],p=H({},c),u.push(p),d=Math.trunc(p.x*a),m=Math.trunc(p.y*o),!(d<0||d>=a||m<0||d>=o)){for(y=Math.trunc((n.kernelSize-1)/2),g=Math.max(0,d-y),v=Math.min(a,d+y+1),b=Math.max(0,m-y),w=Math.min(o,m+y+1),x=0,k=0,S=0,T=0,M=b;M<w;++M)for(_=g;_<v;++_)E=l.get(M,_,h),x+=E,T=Math.max(T,E),k+=_*E,S+=M*E;T>=n.minConfidenceToRefine&&x>0&&(p.x=k/a/x,p.y=S/o/x)}return r.dispose(),[2,u]}})})}function _t(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 Et(t,e,n){return V(this,0,void 0,function(){var r,o,a,s,u;return G(this,function(l){switch(l.label){case 0:return r=t[0],o=t[1],a=function(t,e,n){return i(function(){var r,i,o,a;n.reverseOutputOrder?(i=f(T(t,[0,n.boxCoordOffset+0],[-1,1])),r=f(T(t,[0,n.boxCoordOffset+1],[-1,1])),a=f(T(t,[0,n.boxCoordOffset+2],[-1,1])),o=f(T(t,[0,n.boxCoordOffset+3],[-1,1]))):(r=f(T(t,[0,n.boxCoordOffset+0],[-1,1])),i=f(T(t,[0,n.boxCoordOffset+1],[-1,1])),o=f(T(t,[0,n.boxCoordOffset+2],[-1,1])),a=f(T(t,[0,n.boxCoordOffset+3],[-1,1]))),i=y(S(M(i,n.xScale),e.w),e.x),r=y(S(M(r,n.yScale),e.h),e.y),n.applyExponentialOnBoxSize?(o=S(A(M(o,n.hScale)),e.h),a=S(A(M(a,n.wScale)),e.w)):(o=S(M(o,n.hScale),e.h),a=S(M(a,n.wScale),e.h));var s=w(r,M(o,2)),u=w(i,M(a,2)),l=y(r,M(o,2)),h=y(i,M(a,2)),c=_([p(s,[n.numBoxes,1]),p(u,[n.numBoxes,1]),p(l,[n.numBoxes,1]),p(h,[n.numBoxes,1])],1);if(n.numKeypoints)for(var d=0;d<n.numKeypoints;++d){var m=n.keypointCoordOffset+d*n.numValuesPerKeypoint,g=void 0,v=void 0;n.reverseOutputOrder?(g=f(T(t,[0,m],[-1,1])),v=f(T(t,[0,m+1],[-1,1]))):(v=f(T(t,[0,m],[-1,1])),g=f(T(t,[0,m+1],[-1,1])));var b=y(S(M(g,n.xScale),e.w),e.x),x=y(S(M(v,n.yScale),e.h),e.y);c=_([c,p(b,[n.numBoxes,1]),p(x,[n.numBoxes,1])],1)}return c})}(o,e,n),s=i(function(){var t=r;return n.sigmoidScore?(null!=n.scoreClippingThresh&&(t=E(r,-n.scoreClippingThresh,n.scoreClippingThresh)),t=d(t)):t}),[4,At(a,s,n)];case 1:return u=l.sent(),c([a,s]),[2,u]}})})}function At(t,e,n){return V(this,0,void 0,function(){var r,i,o,a,s,u,l,h,c,f,p,d;return G(this,function(m){switch(m.label){case 0:return r=[],[4,t.data()];case 1:return i=m.sent(),[4,e.data()];case 2:for(o=m.sent(),a=0;a<n.numBoxes;++a)if(!(null!=n.minScoreThresh&&o[a]<n.minScoreThresh||(s=a*n.numCoords,u=Ft(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,f=0;f<c;f+=n.numValuesPerKeypoint)p=s+n.keypointCoordOffset+f,d={x:i[p+0],y:n.flipVertically?1-i[p+1]:i[p+1]},h.relativeKeypoints.push(d);r.push(u)}return[2,r]}})})}function Ft(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 Pt(t,e){return"none"===t?e:function(t){return 1/(1+Math.exp(-t))}(e)}function Ot(t,e,n,r){return V(this,0,void 0,function(){var i,o,a,s,u,l,h,c;return G(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=Pt(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 Rt(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),lt(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 It(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 Ct=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}(),Lt=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 Ct(this.getAlpha(this.minCutOff)),this.dx=new Ct(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}(),jt=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 K([],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 Lt(e.config)}),this.yFilters=t.map(function(t){return new Lt(e.config)}),this.zFilters=t.map(function(t){return new Lt(e.config)}))},t}(),Nt=function(){function t(t){this.config=t,this.window=[],this.lowPassFilter=new Ct(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}(),Bt=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 K([],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 Nt(e.config)}),this.yFilters=t.map(function(t){return new Nt(e.config)}),this.zFilters=t.map(function(t){return new Nt(e.config)}))},t}(),zt=function(){function t(t){if(null!=t.velocityFilter)this.keypointsFilter=new Bt(t.velocityFilter);else{if(null==t.oneEuroFilter)throw new Error("Either configure velocityFilter or oneEuroFilter, but got "+"".concat(t,"."));this.keypointsFilter=new jt(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?Tt(t,n):t,s=this.keypointsFilter.apply(a,e,o);return r?It(s,n):s},t}(),Dt=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 Ct(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}(),Ut={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"},Vt={maxPoses:1,flipHorizontal:!1},Gt={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},Kt={shiftX:0,shiftY:0,scaleX:1.25,scaleY:1.25},Yt={outputTensorSize:{width:224,height:224},keepAspectRatio:!0,outputTensorFloatRange:[-1,1],borderMode:"zero"},Xt={outputTensorSize:{width:256,height:256},keepAspectRatio:!0,outputTensorFloatRange:[0,1],borderMode:"zero"},Wt={numLandmarks:39,inputImageWidth:256,inputImageHeight:256,visibilityActivation:"sigmoid",flipHorizontally:!1,flipVertically:!1},qt={numLandmarks:39,inputImageWidth:1,inputImageHeight:1,visibilityActivation:"sigmoid",flipHorizontally:!1,flipVertically:!1},Qt={kernelSize:7,minConfidenceToRefine:.5},Jt={alpha:.1},Zt={oneEuroFilter:{frequency:30,minCutOff:.05,beta:80,derivateCutOff:1,minAllowedObjectScale:1e-6}},$t={oneEuroFilter:{frequency:30,minCutOff:.01,beta:10,derivateCutOff:1,minAllowedObjectScale:1e-6}},te={oneEuroFilter:{frequency:30,minCutOff:.1,beta:40,derivateCutOff:1,minAllowedObjectScale:1e-6,disableValueScaling:!0}},ee={activation:"none"},ne={combineWithPreviousRatio:.7},re=function(){function t(t){this.mask=t}return t.prototype.toCanvasImageSource=function(){return V(this,0,void 0,function(){return G(this,function(t){return[2,$(this.mask)]})})},t.prototype.toImageData=function(){return V(this,0,void 0,function(){return G(this,function(t){return[2,tt(this.mask)]})})},t.prototype.toTensor=function(){return V(this,0,void 0,function(){return G(this,function(t){return[2,this.mask]})})},t.prototype.getUnderlyingType=function(){return"tensor"},t}();function ie(t){return nt(t),"person"}var oe=function(){function e(t,e,n,r,i,a){this.detectorModel=t,this.landmarkModel=e,this.enableSmoothing=n,this.enableSegmentation=r,this.smoothSegmentation=i,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=wt(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:wt(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}(Ut);var s=g(this.anchors.map(function(t){return t.width})),u=g(this.anchors.map(function(t){return t.height})),l=g(this.anchors.map(function(t){return t.xCenter})),h=g(this.anchors.map(function(t){return t.yCenter}));this.anchorTensor={x:l,y:h,w:s,h:u},this.prevFilteredSegmentationMask=this.enableSegmentation?o([],[0,0]):null}return e.prototype.estimatePoses=function(t,e,r){return V(this,0,void 0,function(){var o,a,u,f,p,d,m,y,g,v,b,w,x,k,S,T,M,_,E,A,F,P,O;return G(this,function(R){switch(R.label){case 0:return o=function(t){var e;if(null==(e=null==t?Vt: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}(e),null==t?(this.reset(),[2,[]]):(this.maxPoses=o.maxPoses,this.timestamp=null!=r?1e3*r:xt(t)?1e6*t.currentTime:null,a=ut(t),u=i(function(){return s(ht(t),"float32")}),null!=(f=this.regionOfInterest)?[3,2]:[4,this.detectPose(u)]);case 1:if(0===(p=R.sent()).length)return this.reset(),u.dispose(),[2,[]];d=p[0],f=this.poseDetectionToRoi(d,a),R.label=2;case 2:return[4,this.poseLandmarksByRoi(f,u)];case 3:return m=R.sent(),u.dispose(),null==m?(this.reset(),[2,[]]):(y=m.landmarks,g=m.auxiliaryLandmarks,v=m.poseScore,b=m.worldLandmarks,w=m.segmentationMask,x=this.poseLandmarkFiltering(y,g,b,a),k=x.actualLandmarksFiltered,S=x.auxiliaryLandmarksFiltered,T=x.actualWorldLandmarksFiltered,M=this.poseLandmarksToRoi(S,a),this.regionOfInterest=M,_=this.smoothSegmentation&&null!=w?this.poseSegmentationFiltering(w):w,null!=(E=null!=k?Tt(k,a):null)&&E.forEach(function(t,e){t.name=X[e]}),null!=(A=T)&&A.forEach(function(t,e){t.name=X[e]}),F={score:v,keypoints:E,keypoints3D:A},null!==_&&(P=i(function(){var t=n(_,2),e=l(t,[[0,0],[0,0],[0,1]]);return h(e,[[0,0],[0,0],[0,2]],"symmetric")}),this.smoothSegmentation||c(_),O={maskValueToLabel:ie,mask:new re(P)},F.segmentation=O),[2,[F]])}})})},e.prototype.poseSegmentationFiltering=function(e){var n=this.prevFilteredSegmentationMask;return 0===n.size?this.prevFilteredSegmentationMask=e:(this.prevFilteredSegmentationMask=function(e,n,r){return"webgl"===t()?function(t,e,n){var r=n.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(r,");\n\n setOutput(outputValue);\n }\n")},a=v();return i(function(){var n=a.compileAndRun(o,[t,e]);return b().makeTensorFromDataId(n.dataId,n.shape,n.dtype)})}(e,n,r):i(function(){var t=w(n,.5),i=x(t),o=w(1,k(1,S(i,y(5.68842,S(i,y(-.748699,S(i,y(-57.8051,S(i,y(291.309,S(i,-624.717)))))))))));return y(n,S(w(e,n),S(o,r.combineWithPreviousRatio)))})}(n,e,ne),c(e)),c(n),this.prevFilteredSegmentationMask},e.prototype.dispose=function(){this.detectorModel.dispose(),this.landmarkModel.dispose(),c([this.anchorTensor.x,this.anchorTensor.y,this.anchorTensor.w,this.anchorTensor.h,this.prevFilteredSegmentationMask])},e.prototype.reset=function(){this.regionOfInterest=null,this.enableSegmentation&&(c(this.prevFilteredSegmentationMask),this.prevFilteredSegmentationMask=o([],[0,0])),this.visibilitySmoothingFilterActual=null,this.visibilitySmoothingFilterAuxiliary=null,this.landmarksSmoothingFilterActual=null,this.landmarksSmoothingFilterAuxiliary=null},e.prototype.detectPose=function(t){return V(this,0,void 0,function(){var e,n,r,o,a,s,u,l,h,p;return G(this,function(d){switch(d.label){case 0:return e=bt(t,Yt),n=e.imageTensor,r=e.padding,o=this.detectorModel.predict(n),a=function(t){return i(function(){var e=function(t){return i(function(){return[T(t,[0,0,0],[1,-1,1]),T(t,[0,0,1],[1,-1,-1])]})}(t),n=e[0],r=e[1];return{boxes:f(r),logits:f(n)}})}(o),s=a.boxes,[4,Et([u=a.logits,s],this.anchorTensor,Gt)];case 1:return 0===(l=d.sent()).length?(c([n,o,u,s]),[2,l]):[4,St(l,this.maxPoses,.3)];case 2:return h=d.sent(),p=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,r),c([n,o,u,s]),[2,p]}})})},e.prototype.poseDetectionToRoi=function(t,e){return Rt(pt(t,e,{rotationVectorEndKeypointIndex:1,rotationVectorStartKeypointIndex:0,rotationVectorTargetAngleDegree:90}),e,Kt)},e.prototype.poseLandmarksByRoi=function(t,e){return V(this,0,void 0,function(){var n,r,i,o,a,s,u,l,h,f,p,d,m,y;return G(this,function(g){switch(g.label){case 0:if(n=ut(e),r=bt(e,Xt,t),i=r.imageTensor,o=r.padding,a=r.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 s=["ld_3d","output_poseflag","activation_heatmap","world_3d"],this.enableSegmentation&&s.push("activation_segmentation"),u=this.landmarkModel.execute(i,s),[4,this.tensorsToPoseLandmarksAndSegmentation(u)];case 1:return null==(l=g.sent())?(c(u),c(i),[2,null]):(h=l.landmarks,f=l.auxiliaryLandmarks,p=l.poseScore,d=l.worldLandmarks,m=l.segmentationMask,[4,this.poseLandmarksAndSegmentationInverseProjection(n,t,o,a,h,f,d,m)]);case 2:return y=g.sent(),c(u),c(i),[2,H({poseScore:p},y)]}})})},e.prototype.poseLandmarksAndSegmentationInverseProjection=function(t,e,n,r,a,s,l,h){return V(this,0,void 0,function(){var d,m,y,g,v,b;return G(this,function(w){return d=_t(a,n),m=_t(s,n),y=gt(d,e),g=gt(m,e),v=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,h=Math.sin(u)*a+Math.cos(u)*s,c=H({},o);c.x=l,c.y=h,n.push(c)}return n}(l,e),b=null,this.enableSegmentation&&(b=i(function(){var e=h.shape,n=e[0],i=e[1],a=function(t){var e=dt(new Array(16).fill(0));e[0][0]=yt(t,0,0),e[1][0]=-yt(t,0,1),e[2][0]=yt(t,0,2),e[3][0]=-yt(t,0,3),e[0][2]=yt(t,2,0),e[1][2]=-yt(t,2,1),e[2][2]=yt(t,2,2),e[3][2]=-yt(t,2,3),e[0][1]=-yt(t,1,0),e[1][1]=yt(t,1,1),e[2][1]=-yt(t,1,2),e[3][1]=yt(t,1,3),e[0][3]=-yt(t,3,0),e[1][3]=yt(t,3,1),e[2][3]=-yt(t,3,2),e[3][3]=yt(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}(r),s=o(ct(a,{width:i,height:n},t),[1,8]),l=[1,n,i,1];return f(u.transform(p(h,l),s,"bilinear","constant",0,[t.height,t.width]),[0,3])}),c(h)),[2,{landmarks:y,auxiliaryLandmarks:g,worldLandmarks:v,segmentationMask:b}]})})},e.prototype.tensorsToPoseLandmarksAndSegmentation=function(t){return V(this,0,void 0,function(){var e,n,r,o,a,s,u,l,h,c,p,m,y;return G(this,function(g){switch(g.label){case 0:return e=t[0],n=t[1],r=t[2],o=t[3],a=this.enableSegmentation?t[4]:null,[4,n.data()];case 1:return(s=g.sent()[0])<.5?[2,null]:[4,Ot(e,Wt)];case 2:return[4,Mt(g.sent(),r,Qt)];case 3:return u=g.sent(),l=u.slice(0,33),h=u.slice(33,35),[4,Ot(o,qt)];case 4:return c=g.sent(),p=c.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,p),y=this.enableSegmentation?function(t,e){return i(function(){var n=f(t,[0]),r=n.shape[2];if(1===r){var i=n;switch(e.activation){case"none":break;case"sigmoid":i=d(i);break;case"softmax":throw new Error("Softmax activation requires two channels.");default:throw new Error("Activation not supported (".concat(e.activation,")"))}return f(i,[2])}throw new Error("Unsupported number of tensor channels ".concat(r))})}(a,ee):null,[2,{landmarks:l,auxiliaryLandmarks:h,poseScore:s,worldLandmarks:m,segmentationMask:y}]}})})},e.prototype.poseLandmarksToRoi=function(t,e){return Rt(pt(kt(t),e,{rotationVectorStartKeypointIndex:0,rotationVectorEndKeypointIndex:1,rotationVectorTargetAngleDegree:90}),e,Kt)},e.prototype.poseLandmarkFiltering=function(t,e,n,r){var i,o,a;if(null!=this.timestamp&&this.enableSmoothing){var s=pt(kt(e),r,{rotationVectorEndKeypointIndex:0,rotationVectorStartKeypointIndex:1,rotationVectorTargetAngleDegree:90});null==this.visibilitySmoothingFilterActual&&(this.visibilitySmoothingFilterActual=new Dt(Jt)),i=this.visibilitySmoothingFilterActual.apply(t),null==this.visibilitySmoothingFilterAuxiliary&&(this.visibilitySmoothingFilterAuxiliary=new Dt(Jt)),o=this.visibilitySmoothingFilterAuxiliary.apply(e),a=this.visibilitySmoothingFilterActual.apply(n),null==this.landmarksSmoothingFilterActual&&(this.landmarksSmoothingFilterActual=new zt(Zt)),i=this.landmarksSmoothingFilterActual.apply(i,this.timestamp,r,!0,s),null==this.landmarksSmoothingFilterAuxiliary&&(this.landmarksSmoothingFilterAuxiliary=new zt($t)),o=this.landmarksSmoothingFilterAuxiliary.apply(o,this.timestamp,r,!0,s),null==this.worldLandmarksSmoothingFilterActual&&(this.worldLandmarksSmoothingFilterActual=new zt(te)),a=this.worldLandmarksSmoothingFilterActual.apply(n,this.timestamp)}else i=t,o=e,a=n;return{actualLandmarksFiltered:i,auxiliaryLandmarksFiltered:o,actualWorldLandmarksFiltered:a}},e}();function ae(t){return V(this,0,void 0,function(){var e,n,r,i,o,a;return G(this,function(s){switch(s.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),n="string"==typeof e.detectorModelUrl&&e.detectorModelUrl.indexOf("https://tfhub.dev")>-1,r="string"==typeof e.landmarkModelUrl&&e.landmarkModelUrl.indexOf("https://tfhub.dev")>-1,[4,Promise.all([R(e.detectorModelUrl,{fromTFHub:n}),R(e.landmarkModelUrl,{fromTFHub:r})])];case 1:return i=s.sent(),o=i[0],a=i[1],[2,new oe(o,a,e.enableSmoothing,e.enableSegmentation,e.smoothSegmentation,e.modelType)]}})})}var se,ue,le,he=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:K([],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}(),ce=function(t){function e(e){return t.call(this,e)||this}return U(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}(he),fe=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 U(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,K([1],n.map(function(t){return t.x}),!1)),i=Math.max.apply(Math,K([0],n.map(function(t){return t.x}),!1)),o=Math.min.apply(Math,K([1],n.map(function(t){return t.y}),!1));return(i-r)*(Math.max.apply(Math,K([0],n.map(function(t){return t.y}),!1))-o)},e}(he);function pe(t){switch(t){case ue.BlazePose:return X.reduce(function(t,e,n){return t[e]=n,t},{});case ue.PoseNet:case ue.MoveNet:return Y.reduce(function(t,e,n){return t[e]=n,t},{});default:throw new Error("Model ".concat(t," is not supported."))}}(le=se||(se={})).Keypoint="keypoint",le.BoundingBox="boundingBox",function(t){t.MoveNet="MoveNet",t.BlazePose="BlazePose",t.PoseNet="PoseNet"}(ue||(ue={}));var de=Object.freeze({__proto__:null,getKeypointIndexBySide:function(t){switch(t){case ue.BlazePose:return W;case ue.PoseNet:case ue.MoveNet:return q;default:throw new Error("Model ".concat(t," is not supported."))}},getAdjacentPairs:function(t){switch(t){case ue.BlazePose:return J;case ue.PoseNet:case ue.MoveNet:return Q;default:throw new Error("Model ".concat(t," is not supported."))}},getKeypointIndexByName:pe}),me=["SinglePose.Lightning","SinglePose.Thunder","MultiPose.Lightning"],ye={modelType:"SinglePose.Lightning",enableSmoothing:!0},ge={},ve={frequency:30,minCutOff:2.5,beta:300,derivateCutOff:2.5,thresholdCutOff:.5,thresholdBeta:5,disableValueScaling:!0},be={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}},we={maxTracks:18,maxAge:1e3,minSimilarity:.15,trackerParams:{}};function xe(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 ke(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 Se=function(){function e(t,e){this.moveNetModel=t,this.modelInputResolution={height:0,width:0},this.keypointIndexByName=pe(ue.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 jt(ve),this.cropRegionFilterYMin=new Ct(.9),this.cropRegionFilterXMin=new Ct(.9),this.cropRegionFilterYMax=new Ct(.9),this.cropRegionFilterXMax=new Ct(.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===se.Keypoint?this.tracker=new fe(e.trackerConfig):e.trackerType===se.BoundingBox&&(this.tracker=new ce(e.trackerConfig)),this.enableSmoothing&&(this.keypointFilterMap=new Map))}return e.prototype.runSinglePersonPoseModel=function(e){return V(this,0,void 0,function(){var n,r,i,o,a;return G(this,function(s){switch(s.label){case 0:if(4!==(n=this.moveNetModel.execute(e)).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"===t()?[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]}})})},e.prototype.runMultiPersonPoseModel=function(e){return V(this,0,void 0,function(){var n,r,i,o,a,s,u,l;return G(this,function(h){switch(h.label){case 0:if(3!==(n=this.moveNetModel.execute(e)).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"===t()?[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]}})})},e.prototype.estimatePoses=function(t,e,i){return void 0===e&&(e=ge),V(this,0,void 0,function(){var o,a,s,u,l,h;return G(this,function(c){switch(c.label){case 0:return e=function(t){return null==t?ge:H({},t)}(e),null==t?(this.reset(),[2,[]]):(null==i?xt(t)&&(i=1e6*t.currentTime):i*=1e3,o=ht(t),a=ut(o),s=n(o,0),t instanceof r||o.dispose(),u=[],this.multiPoseModel?[3,2]:[4,this.estimateSinglePose(s,a,i)]);case 1:return u=c.sent(),[3,4];case 2:return[4,this.estimateMultiplePoses(s,a,i)];case 3:u=c.sent(),c.label=4;case 4:for(l=0;l<u.length;++l)for(h=0;h<u[l].keypoints.length;++h)u[l].keypoints[h].name=Y[h],u[l].keypoints[h].y*=a.height,u[l].keypoints[h].x*=a.width;return[2,u]}})})},e.prototype.estimateSinglePose=function(t,e,n){return V(this,0,void 0,function(){var r,l,h,c,f=this;return G(this,function(p){switch(p.label){case 0:return this.cropRegion||(this.cropRegion=xe(null==this.cropRegion,e)),r=i(function(){var e=o([[f.cropRegion.yMin,f.cropRegion.xMin,f.cropRegion.yMax,f.cropRegion.xMax]]),n=a([1],"int32"),r=[f.modelInputResolution.height,f.modelInputResolution.width];return s(u.cropAndResize(t,e,n,r,"bilinear",0),"int32")}),t.dispose(),[4,this.runSinglePersonPoseModel(r)];case 1:if(l=p.sent(),r.dispose(),l.score<this.minPoseScore)return this.reset(),[2,[]];for(h=0;h<l.keypoints.length;++h)l.keypoints[h].y=this.cropRegion.yMin+l.keypoints[h].y*this.cropRegion.height,l.keypoints[h].x=this.cropRegion.xMin+l.keypoints[h].x*this.cropRegion.width;return null!=n&&this.enableSmoothing&&(l.keypoints=this.keypointFilter.apply(l.keypoints,n,1)),c=function(t,e,n,r){for(var i={},o=0,a=Y;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],d=h[3],m=Math.max(1.9*f,1.9*c,1.2*p,1.2*d),y=[u-(m=Math.min(m,Math.max(l,r.width-l,u,r.height-u))),l-m];if(m>Math.max(r.width,r.height)/2)return xe(null==t,r);var g=2*m;return{yMin:y[0]/r.height,xMin:y[1]/r.width,yMax:(y[0]+g)/r.height,xMax:(y[1]+g)/r.width,height:(y[0]+g)/r.height-y[0]/r.height,width:(y[1]+g)/r.width-y[1]/r.width}}return xe(null==t,r)}(this.cropRegion,l.keypoints,this.keypointIndexByName,e),this.cropRegion=this.filterCropRegion(c),[2,[l]]}})})},e.prototype.estimateMultiplePoses=function(t,e,n){return V(this,0,void 0,function(){var r,i,o,a,h,c,f,p,d,m,y,g=this;return G(this,function(v){switch(v.label){case 0:return e.width>e.height?(i=this.multiPoseMaxDimension,o=Math.round(this.multiPoseMaxDimension*e.height/e.width),r=u.resizeBilinear(t,[o,i]),h=i,c=32*Math.ceil(o/32),a=l(r,[[0,0],[0,c-o],[0,0],[0,0]])):(i=Math.round(this.multiPoseMaxDimension*e.width/e.height),o=this.multiPoseMaxDimension,r=u.resizeBilinear(t,[o,i]),h=32*Math.ceil(i/32),c=o,a=l(r,[[0,0],[0,0],[0,h-i],[0,0]])),r.dispose(),t.dispose(),f=s(a,"int32"),a.dispose(),[4,this.runMultiPersonPoseModel(f)];case 1:for(p=v.sent(),f.dispose(),p=p.filter(function(t){return t.score>=g.minPoseScore}),m=0;m<p.length;++m)for(d=0;d<p[m].keypoints.length;++d)p[m].keypoints[d].y*=c/o,p[m].keypoints[d].x*=h/i;if(this.enableTracking&&(this.tracker.apply(p,n),this.enableSmoothing)){for(m=0;m<p.length;++m)this.keypointFilterMap.has(p[m].id)||this.keypointFilterMap.set(p[m].id,new jt(ve)),p[m].keypoints=this.keypointFilterMap.get(p[m].id).apply(p[m].keypoints,n,1);y=this.tracker.getTrackIDs(),this.keypointFilterMap.forEach(function(t,e){y.has(e)||g.keypointFilterMap.delete(e)})}return[2,p]}})})},e.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},e.prototype.dispose=function(){this.moveNetModel.dispose()},e.prototype.reset=function(){this.cropRegion=null,this.resetFilters()},e.prototype.resetFilters=function(){this.keypointFilter.reset(),this.cropRegionFilterYMin.reset(),this.cropRegionFilterXMin.reset(),this.cropRegionFilterYMax.reset(),this.cropRegionFilterXMax.reset()},e}();function Te(n){return void 0===n&&(n=ye),V(this,0,void 0,function(){var r,i,o,a;return G(this,function(s){switch(s.label){case 0:return r=function(t){var e,n=null==t?ye:H({},t);if(null==n.modelType)n.modelType="SinglePose.Lightning";else if(me.indexOf(n.modelType)<0)throw new Error("Invalid architecture ".concat(n.modelType,". ")+"Should be one of ".concat(me));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=se.BoundingBox),n.trackerType===se.Keypoint)null!=n.trackerConfig?n.trackerConfig=function(t){var e=ke(be,t);return e.keypointTrackerParams=H({},be.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=be;else{if(n.trackerType!==se.BoundingBox)throw new Error("Tracker type not supported by MoveNet");null!=n.trackerConfig?n.trackerConfig=(e=n.trackerConfig,ke(we,e)):n.trackerConfig=we}return n}(n),o=!0,r.modelUrl?(o="string"==typeof r.modelUrl&&r.modelUrl.indexOf("https://tfhub.dev")>-1,[4,R(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,R(a,{fromTFHub:o})];case 3:i=s.sent(),s.label=4;case 4:return"webgl"===t()&&e().set("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",0),[2,new Se(i,r)]}})})}var Me={architecture:"MobileNetV1",outputStride:16,multiplier:.75,inputResolution:{height:257,width:257}},_e=["MobileNetV1","ResNet50"],Ee={MobileNetV1:[8,16],ResNet50:[16]},Ae=[8,16,32],Fe={MobileNetV1:[.5,.75,1],ResNet50:[1]},Pe=[1,2,4],Oe={maxPoses:1,flipHorizontal:!1},Re={maxPoses:5,flipHorizontal:!1,scoreThreshold:.5,nmsRadius:20},Ie=[-123.15,-115.9,-103.06];function Ce(t){return Math.floor(t/2)}var Le=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(Ce(t),t);)this.exchange(t,Ce(t)),t=Ce(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 je(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 Ne(t){return V(this,0,void 0,function(){return G(this,function(e){return[2,Promise.all(t.map(function(t){return t.buffer()}))]})})}function Be(t,e,n,r){return{y:r.get(t,e,n),x:r.get(t,e,n+17)}}function ze(t,e,n){var r=Be(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 De(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 Ue=Y.reduce(function(t,e,n){return t[e]=n,t},{}),He=[["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[Ue[e],Ue[n]]}),Ve=He.map(function(t){return t[1]}),Ge=He.map(function(t){return t[0]});function Ke(t,e,n){return t<e?e:t>n?n:t}function Ye(t,e,n,r){return{y:Ke(Math.round(t.y/e),0,n-1),x:Ke(Math.round(t.x/e),0,r-1)}}function Xe(t,e){return{x:t.x+e.x,y:t.y+e.y}}function We(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=Xe(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,Ye(c,o,l,h),a)),p=0;p<s;p++){var d=Ye(f,o,l,h),m=Be(d.y,d.x,n,i);f=Xe({x:d.x*o,y:d.y*o},{x:m.x,y:m.y})}var y=Ye(f,o,l,h),g=r.get(y.y,y.x,n);return{y:f.y,x:f.x,name:Y[n],score:g}}function qe(t,e,n,r,i,o){var a=e.shape[2],s=Ve.length,u=new Array(a),l=t.part,h=t.score,c=ze(l,r,n);u[l.id]={score:h,name:Y[l.id],y:c.y,x:c.x};for(var f=s-1;f>=0;--f){var p=Ve[f],d=Ge[f];u[p]&&!u[d]&&(u[d]=We(f,u[p],d,e,n,r,o))}for(f=0;f<s;++f)p=Ge[f],d=Ve[f],u[p]&&!u[d]&&(u[d]=We(f,u[p],d,e,n,r,i));return u}function Qe(t,e,n){return n.reduce(function(n,r,i){var o=r.y,a=r.x,s=r.score;return De(t,e,{y:o,x:a},i)||(n+=s),n},0)/n.length}function Je(t,e,n,r,i,o,a,s){return void 0===a&&(a=.5),void 0===s&&(s=20),V(this,0,void 0,function(){var u,l,h,c,f,p,d,m,y,g,v,b;return G(this,function(w){switch(w.label){case 0:return[4,Ne([t,e,n,r])];case 1:for(u=w.sent(),l=u[0],h=u[1],c=u[2],f=u[3],p=[],d=function(t,e,n){for(var r=n.shape,i=r[0],o=r[1],a=r[2],s=new Le(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||je(h,c,u,l,1,n)&&s.enqueue({score:c,part:{heatmapY:u,heatmapX:l,id:h}})}return s}(a,0,l),m=s*s;p.length<o&&!d.empty();)y=d.dequeue(),g=ze(y.part,i,h),De(p,m,g,y.part.id)||(v=qe(y,l,h,i,c,f),b=Qe(p,m,v),p.push({keypoints:v,score:b}));return[2,p]}})})}function Ze(){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 $e=function(){function t(t){this.variableNames=["A","B"],this.size=!0,this.workgroupSize=[32,1,1],this.outputShape=[t[0],1],this.dispatchLayout=C.flatDispatchLayout(this.outputShape),this.dispatch=C.computeDispatch(this.dispatchLayout,this.outputShape,this.workgroupSize),this.shaderKey="getpointsConfidenceOp"}return t.prototype.getUserCode=function(){return"\n ".concat(Ze("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 tn=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=C.flatDispatchLayout(e),this.dispatch=C.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(Ze("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 en(t){var e=t.shape,r=e[0],o=e[1],a=e[2];return i(function(){var e,s,u=p(t,[r*o,a]),l=O(u,0),h=n(M(l,P(o,"int32")),1),c=n((e=l,s=o,i(function(){var t=M(e,P(s,"int32"));return w(e,S(t,P(s,"int32")))})),1);return _([h,c],1)})}function nn(t,e,n){return i(function(){var r=function(t,e){for(var n=[],r=0;r<Y.length;r++){var i=rn(t.get(r,0).valueOf(),t.get(r,1).valueOf(),r,e),a=i.x,s=i.y;n.push(s),n.push(a)}return o(n,[Y.length,2])}(t,n);return y(s(S(t.toTensor(),P(e,"int32")),"float32"),r)})}function rn(t,e,n,r){return{y:r.get(t,e,n),x:r.get(t,e,n+Y.length)}}function on(t,e,n){return V(this,0,void 0,function(){var r,i,o,a,s,u,l,h,c,f;return G(this,function(p){switch(p.label){case 0:return r=0,i=en(t),[4,Promise.all([t.buffer(),e.buffer(),i.buffer()])];case 1:return o=p.sent(),a=o[0],s=o[1],u=o[2],[4,(l=nn(u,n,s)).buffer()];case 2:return h=p.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)),f=c.map(function(t,e){return r+=t,{y:h.get(e,0),x:h.get(e,1),score:t,name:Y[e]}}),i.dispose(),l.dispose(),[2,{keypoints:f,score:r/f.length}]}})})}function an(t,e,n){return V(this,0,void 0,function(){var r,o,a;return G(this,function(u){return r=en(t),o=function(t,e,n){return i(function(){var r=function(t,e){if(v()instanceof I)return function(t,e){var n=v(),r=new tn(t.shape),i=n.runWebGPUProgram(r,[t,e],"float32");return b().makeTensorFromTensorInfo(i)}(t,e);throw new Error("getOffsetVectorsGPU is not supported in this backend!")}(t,n);return y(s(S(t,P(e,"int32")),"float32"),r)})}(r,n,e),a=function(t,e){if(v()instanceof I)return function(t,e){var n=v(),r=new $e(e.shape),i=n.runWebGPUProgram(r,[t,e],"float32");return b().makeTensorFromTensorInfo(i)}(t,e);throw new Error("getPointsConfidenceWebGPU is not supported in this backend!")}(t,r),[2,[o,a]]})})}function sn(t,e){return(t-1)%e==0}var un="https://storage.googleapis.com/tfjs-models/savedmodel/posenet/mobilenet/",ln="https://storage.googleapis.com/tfjs-models/savedmodel/posenet/resnet50/";function hn(t,e){return function(t,e){return(t-1)%e==0}(t,e)?t:Math.floor(t/e)*e+1}var cn=function(){function t(t,e){this.posenetModel=t;var n=this.posenetModel.inputs[0].shape;F.assert(-1===n[1]&&-1===n[2],function(){return"Input shape [".concat(n[1],", ").concat(n[2],"] ")+"must both be equal to or -1"});var r,i,o=(r=e.inputResolution,i=e.outputStride,{height:hn(r.height,i),width:hn(r.width,i)});!function(t){F.assert(Ae.indexOf(t)>=0,function(){return"outputStride of ".concat(t," is invalid. ")+"It must be either 8 or 16."})}(e.outputStride),function(t,e){F.assert(sn(t.height,e),function(){return"height of ".concat(t.height," is invalid for output stride ")+"".concat(e,".")}),F.assert(sn(t.width,e),function(){return"width of ".concat(t.width," is invalid for output stride ")+"".concat(e,".")})}(o,e.outputStride),this.inputResolution=o,this.outputStride=e.outputStride,this.architecture=e.architecture}return t.prototype.estimatePoses=function(t,e){return void 0===e&&(e=Oe),V(this,0,void 0,function(){return G(this,function(n){return[2,this.estimatePosesGPU(t,e,!1)]})})},t.prototype.estimatePosesGPU=function(t,e,n){return void 0===e&&(e=Oe),void 0===n&&(n=!1),V(this,0,void 0,function(){var r,i,o,a,s,u,l,h,p,m,g,v,b,w,x,k,S,T;return G(this,function(M){switch(M.label){case 0:return r=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({},Re),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}(e),null==t?[2,n?[[],[]]:[]]:(this.maxPoses=r.maxPoses,i=bt(t,{outputTensorSize:this.inputResolution,keepAspectRatio:!0,borderMode:"replicate"}),o=i.imageTensor,a=i.padding,s="ResNet50"===this.architecture?y(o,Ie):vt(o,[-1,1]),u=this.posenetModel.predict(s),"ResNet50"===this.architecture?(l=f(u[2],[0]),h=f(u[3],[0]),p=f(u[0],[0]),m=f(u[1],[0])):(l=f(u[0],[0]),h=f(u[1],[0]),p=f(u[2],[0]),m=f(u[3],[0])),g=d(h),1!==this.maxPoses?[3,5]:n?[4,an(g,l,this.outputStride)]:[3,2]);case 1:return b=M.sent(),x=b[0],w=b[1],v=[x,w],[3,4];case 2:return[4,on(g,l,this.outputStride)];case 3:x=M.sent(),v=[x],M.label=4;case 4:return[3,7];case 5:if(n)throw new Error("GPU renderer only supports single pose!");return[4,Je(g,l,p,m,this.outputStride,this.maxPoses,r.scoreThreshold,r.nmsRadius)];case 6:v=M.sent(),M.label=7;case 7:if(n){if(!0===r.flipHorizontal)throw new Error("flipHorizontal is not supported!");k=this.getCanvasInfo(ut(t),this.inputResolution,a)}else T=ut(t),S=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}(v,T,this.inputResolution,a),r.flipHorizontal&&(S=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}(S,T));return o.dispose(),s.dispose(),c(u),l.dispose(),h.dispose(),p.dispose(),m.dispose(),g.dispose(),[2,n?[v,k]:S]}})})},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 fn(t){return void 0===t&&(t=Me),V(this,0,void 0,function(){var e,n,r,i,o;return G(this,function(a){switch(a.label){case 0:return"ResNet50"!==(e=function(t){var e=t||Me;if(null==e.architecture&&(e.architecture="MobileNetV1"),_e.indexOf(e.architecture)<0)throw new Error("Invalid architecture ".concat(e.architecture,". ")+"Should be one of ".concat(_e));if(null==e.inputResolution&&(e.inputResolution={height:257,width:257}),null==e.outputStride&&(e.outputStride=16),Ee[e.architecture].indexOf(e.outputStride)<0)throw new Error("Invalid outputStride ".concat(e.outputStride,". ")+"Should be one of ".concat(Ee[e.architecture]," ")+"for architecture ".concat(e.architecture,"."));if(null==e.multiplier&&(e.multiplier=1),Fe[e.architecture].indexOf(e.multiplier)<0)throw new Error("Invalid multiplier ".concat(e.multiplier,". ")+"Should be one of ".concat(Fe[e.architecture]," ")+"for architecture ".concat(e.architecture,"."));if(null==e.quantBytes&&(e.quantBytes=4),Pe.indexOf(e.quantBytes)<0)throw new Error("Invalid quantBytes ".concat(e.quantBytes,". ")+"Should be one of ".concat(Pe," ")+"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]:(s=e.outputStride,u=e.quantBytes,l="model-stride".concat(s,".json"),n=4===u?ln+"float/"+l:ln+"quant".concat(u,"/")+l,[4,R(e.modelUrl||n)]);case 1:return r=a.sent(),[2,new cn(r,e)];case 2:return i=function(t,e,n){var r={1:"100",.75:"075",.5:"050"},i="model-stride".concat(t,".json");return 4===n?un+"float/".concat(r[e],"/")+i:un+"quant".concat(n,"/").concat(r[e],"/")+i}(e.outputStride,e.multiplier,e.quantBytes),[4,R(e.modelUrl||i)];case 3:return o=a.sent(),[2,new cn(o,e)]}var s,u,l})})}function pn(t,e){return V(this,0,void 0,function(){var n,r;return G(this,function(i){switch(t){case ue.PoseNet:return[2,fn(e)];case ue.BlazePose:if(r=void 0,null!=(n=e)){if("tfjs"===n.runtime)return[2,ae(e)];if("mediapipe"===n.runtime)return[2,st(e)];r=n.runtime}throw new Error("Expect modelConfig.runtime to be either 'tfjs' "+"or 'mediapipe', but got ".concat(r));case ue.MoveNet:return[2,Te(e)];default:throw new Error("".concat(t," is not a supported model name."))}})})}var dn={keypointsToNormalizedKeypoints:It},mn={modelType:{SINGLEPOSE_LIGHTNING:"SinglePose.Lightning",SINGLEPOSE_THUNDER:"SinglePose.Thunder",MULTIPOSE_LIGHTNING:"MultiPose.Lightning"}};export{ue as SupportedModels,se as TrackerType,dn as calculators,pn as createDetector,mn as movenet,de as util};
18
+ //# sourceMappingURL=pose-detection.esm-ZdVkbzCQ.js.map