1import{Qi as Oi,Ri as _s}from"/dashboard-entry-qdyjqvbk.js";import{Am as bt,Bo as il,Eo as nl,Fo as sl,Hm as Qo,Hp as ut,Mn as si,Mp as ni,Np as De,Om as xe,On as el,Oo as on,Rm as an,Sn as As,Tm as hn,Tn as ai,Um as kt,cm as We,em as ze,gn as tl,lm as cn,mm as At,mq as Ee,nm as Ct,no as je,pm as rn,rm as ri,sq as li,um as Ye,xm as Ht,zm as Nt}from"/dashboard-entry-n53q24nr.js";import{rs as U,ss as Rt,ts as vt,us as k,vs as ft}from"/dashboard-entry-ardvmh01.js";import{$u as H,$v as $a,Av as en,Du as Zr,Eu as Xr,Fu as Mn,Fv as C,Gu as Ti,Hu as na,Iu as ta,Ju as ia,Ku as Pi,Lu as Vn,Lv as Fo,Mu as Pa,Nu as Wn,Ou as ba,Pu as Ta,Rv as Na,Sv as ka,Tv as Ka,Vu as qn,Wu as Fa,Wv as ls,Xu as Xn,Xv as Ja,Yu as _a,Yv as Ga,Zu as La,Zv as Ua,_u as ns,_v as Ba,av as bi,bv as yi,cv as Ei,dv as Li,ev as Mi,fv as Di,gv as wi,hv as Ii,iv as _i,jv as Ve,kv as Ai,lv as Fi,mv as Ci,nv as Sa,ov as va,pv as xa,qv as go,rv as hs,sv as V,tv as gs,uv as ss,vv as rs,wv as as,xv as os,yv as tn,zv as Ri}from"/dashboard-entry-qv5xe8rf.js";import{TA as nh,VA as ih,WA as Et}from"/dashboard-entry-7eswmxz0.js";var _o=ih(function(Mo){(function(){var e;function t(r){var u=0;return function(){return u<r.length?{done:!1,value:r[u++]}:{done:!0}}}var i=typeof Object.defineProperties=="function"?Object.defineProperty:function(r,u,h){if(r==Array.prototype||r==Object.prototype)return r;return r[u]=h.value,r};function s(r){r=[typeof globalThis=="object"&&globalThis,r,typeof window=="object"&&window,typeof self=="object"&&self,typeof global=="object"&&global];for(var u=0;u<r.length;++u){var h=r[u];if(h&&h.Math==Math)return h}throw Error("Cannot find global object")}var a=s(this);function o(r,u){if(u)t:{var h=a;r=r.split(".");for(var f=0;f<r.length-1;f++){var x=r[f];if(!(x in h))break t;h=h[x]}r=r[r.length-1],f=h[r],u=u(f),u!=f&&u!=null&&i(h,r,{configurable:!0,writable:!0,value:u})}}o("Symbol",function(r){function u(R){if(this instanceof u)throw TypeError("Symbol is not a constructor");return new h(f+(R||"")+"_"+x++,R)}function h(R,T){this.h=R,i(this,"description",{configurable:!0,writable:!0,value:T})}if(r)return r;h.prototype.toString=function(){return this.h};var f="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",x=0;return u}),o("Symbol.iterator",function(r){if(r)return r;r=Symbol("Symbol.iterator");for(var u="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),h=0;h<u.length;h++){var f=a[u[h]];typeof f==="function"&&typeof f.prototype[r]!="function"&&i(f.prototype,r,{configurable:!0,writable:!0,value:function(){return l(t(this))}})}return r});function l(r){return r={next:r},r[Symbol.iterator]=function(){return this},r}function c(r){var u=typeof Symbol<"u"&&Symbol.iterator&&r[Symbol.iterator];return u?u.call(r):{next:t(r)}}function p(r){if(!(r instanceof Array)){r=c(r);for(var u,h=[];!(u=r.next()).done;)h.push(u.value);r=h}return r}var m=typeof Object.assign=="function"?Object.assign:function(r,u){for(var h=1;h<arguments.length;h++){var f=arguments[h];if(f)for(var x in f)Object.prototype.hasOwnProperty.call(f,x)&&(r[x]=f[x])}return r};o("Object.assign",function(r){return r||m});var g=typeof Object.create=="function"?Object.create:function(r){function u(){}return u.prototype=r,new u},d;if(typeof Object.setPrototypeOf=="function")d=Object.setPrototypeOf;else{var S;t:{var v={a:!0},P={};try{P.__proto__=v,S=P.a;break t}catch(r){}S=!1}d=S?function(r,u){if(r.__proto__=u,r.__proto__!==u)throw TypeError(r+" is not extensible");return r}:null}var b=d;function D(r,u){if(r.prototype=g(u.prototype),r.prototype.constructor=r,b)b(r,u);else for(var h in u)if(h!="prototype")if(Object.defineProperties){var f=Object.getOwnPropertyDescriptor(u,h);f&&Object.defineProperty(r,h,f)}else r[h]=u[h];r.za=u.prototype}function A(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function I(r){if(r.m)throw TypeError("Generator is already running");r.m=!0}A.prototype.u=function(r){this.i=r};function F(r,u){r.l={ma:u,na:!0},r.h=r.s||r.v}A.prototype.return=function(r){this.l={return:r},this.h=this.v};function M(r,u,h){return r.h=h,{value:u}}function z(r){this.h=new A,this.i=r}function J(r,u){I(r.h);var h=r.h.j;if(h)return N(r,"return"in h?h.return:function(f){return{value:f,done:!0}},u,r.h.return);return r.h.return(u),W(r)}function N(r,u,h,f){try{var x=u.call(r.h.j,h);if(!(x instanceof Object))throw TypeError("Iterator result "+x+" is not an object");
1if(!x.done)return r.h.m=!1,x;var R=x.value}catch(T){return r.h.j=null,F(r.h,T),W(r)}return r.h.j=null,f.call(r.h,R),W(r)}function W(r){for(;r.h.h;)try{var u=r.i(r.h);if(u)return r.h.m=!1,{value:u.value,done:!1}}catch(h){r.h.i=void 0,F(r.h,h)}if(r.h.m=!1,r.h.l){if(u=r.h.l,r.h.l=null,u.na)throw u.ma;return{value:u.return,done:!0}}return{value:void 0,done:!0}}function K(r){this.next=function(u){return I(r.h),r.h.j?u=N(r,r.h.j.next,u,r.h.u):(r.h.u(u),u=W(r)),u},this.throw=function(u){return I(r.h),r.h.j?u=N(r,r.h.j.throw,u,r.h.u):(F(r.h,u),u=W(r)),u},this.return=function(u){return J(r,u)},this[Symbol.iterator]=function(){return this}}function j(r){function u(f){return r.next(f)}function h(f){return r.throw(f)}return new Promise(function(f,x){function R(T){T.done?f(T.value):Promise.resolve(T.value).then(u,h).then(R,x)}R(r.next())})}function Y(r){return j(new K(new z(r)))}o("Promise",function(r){function u(T){this.i=0,this.j=void 0,this.h=[],this.u=!1;var E=this.l();try{T(E.resolve,E.reject)}catch(L){E.reject(L)}}function h(){this.h=null}function f(T){return T instanceof u?T:new u(function(E){E(T)})}if(r)return r;h.prototype.i=function(T){if(this.h==null){this.h=[];var E=this;this.j(function(){E.m()})}this.h.push(T)};var x=a.setTimeout;h.prototype.j=function(T){x(T,0)},h.prototype.m=function(){for(;this.h&&this.h.length;){var T=this.h;this.h=[];for(var E=0;E<T.length;++E){var L=T[E];T[E]=null;try{L()}catch(_){this.l(_)}}}this.h=null},h.prototype.l=function(T){this.j(function(){throw T})},u.prototype.l=function(){function T(_){return function(O){L||(L=!0,_.call(E,O))}}var E=this,L=!1;return{resolve:T(this.I),reject:T(this.m)}},u.prototype.I=function(T){if(T===this)this.m(TypeError("A Promise cannot resolve to itself"));else if(T instanceof u)this.L(T);else{t:switch(typeof T){case"object":var E=T!=null;break t;case"function":E=!0;break t;default:E=!1}E?this.F(T):this.s(T)}},u.prototype.F=function(T){var E=void 0;try{E=T.then}catch(L){this.m(L);return}typeof E=="function"?this.M(E,T):this.s(T)},u.prototype.m=function(T){this.v(2,T)},u.prototype.s=function(T){this.v(1,T)},u.prototype.v=function(T,E){if(this.i!=0)throw Error("Cannot settle("+T+", "+E+"): Promise already settled in state"+this.i);this.i=T,this.j=E,this.i===2&&this.K(),this.H()},u.prototype.K=function(){var T=this;x(function(){if(T.D()){var E=a.console;typeof E<"u"&&E.error(T.j)}},1)},u.prototype.D=function(){if(this.u)return!1;var{CustomEvent:T,Event:E,dispatchEvent:L}=a;if(typeof L>"u")return!0;return typeof T==="function"?T=new T("unhandledrejection",{cancelable:!0}):typeof E==="function"?T=new E("unhandledrejection",{cancelable:!0}):(T=a.document.createEvent("CustomEvent"),T.initCustomEvent("unhandledrejection",!1,!0,T)),T.promise=this,T.reason=this.j,L(T)},u.prototype.H=function(){if(this.h!=null){for(var T=0;T<this.h.length;++T)R.i(this.h[T]);this.h=null}};var R=new h;return u.prototype.L=function(T){var E=this.l();T.T(E.resolve,E.reject)},u.prototype.M=function(T,E){var L=this.l();try{T.call(E,L.resolve,L.reject)}catch(_){L.reject(_)}},u.prototype.then=function(T,E){function L(q,G){return typeof q=="function"?function(tt){try{_(q(tt))}catch(nt){O(nt)}}:G}var _,O,Q=new u(function(q,G){_=q,O=G});return this.T(L(T,_),L(E,O)),Q},u.prototype.catch=function(T){return this.then(void 0,T)},u.prototype.T=function(T,E){function L(){switch(_.i){case 1:T(_.j);break;case 2:E(_.j);break;default:throw Error("Unexpected state: "+_.i)}}var _=this;this.h==null?R.i(L):this.h.push(L),this.u=!0},u.resolve=f,u.reject=function(T){return new u(function(E,L){L(T)})},u.race=function(T){return new u(function(E,L){for(var _=c(T),O=_.next();!O.done;O=_.next())f(O.value).T(E,L)})},u.all=function(T){var E=c(T),L=E.next();return L.done?f([]):new u(function(_,O){function Q(tt){return function(nt){q[tt]=nt,G--,G==0&&_(q)}}var q=[],G=0;do q.push(void 0),G++,f(L.value).T(Q(q.length-1),O),L=E.next();while(!L.done)})},u});function it(r,u){r instanceof String&&(r+="");var h=0,f=!1,x={next:function(){if(!f&&h<r.length){var R=h++;return{value:u(R,r[R]),done:!1}}return f=!0,{done:!0,value:void 0}}};return x[Symbol.iterator]=function(){return x},x}o("Array.prototype.keys",function(r){return r?r:function(){return it(this,function(u){return u})}}),o("Array.prototype.fill",function(r){return r?r:function(u,h,f){var x=this.length||0;if(0>h&&(h=Math.max(0,x+h)),f==null||f>x)f=x;f=Number(f),0>f&&(f=Math.max(0,x+f));for(h=Number(h||0);h<f;h++)this[h]=u;return this}});function Z(r){return r?r:Array.prototype.fill}o("Int8Array.prototype.fill",Z),o("Uint8Array.prototype.fill",Z),o("Uint8ClampedArray.prototype.fill",Z),o("Int16Array.prototype.fill",Z),o("Uint16Array.prototype.fill",Z),o("Int32Array.prototype.fill",Z),o("Uint32Array.prototype.fill",Z),o("Float32Array.prototype.fill",Z),o("Float64Array.prototype.fill",Z),o("Object.is",function(r){return r?r:function(u,h){return u===h?u!==0||1/u===1/h:u!==u&&h!==h}}),o("Array.prototype.includes",function(r){return r?r:function(u,h){var f=this;f instanceof String&&(f=String(f));var x=f.length;h=h||0;for(0>h&&(h=Math.max(h+x,0));h<x;h++){var R=f[h];if(R===u||Object.is(R,u))return!0}return!1}}),o("String.prototype.includes",function(r){return r?r:function(u,h){if(this==null)throw TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(u instanceof RegExp)throw TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(u,h||0)!==-1}});var st=this||self;function rt(r,u){r=r.split(".");var h=st;r[0]in h||typeof h.execScript>"u"||h.execScript("var "+r[0]);for(var f;r.length&&(f=r.shift());)r.length||u===void 0?h[f]&&h[f]!==Object.prototype[f]?h=h[f]:h=h[f]={}:h[f]=u}function pt(r){var u;t:{if(u=st.navigator){if(u=u.userAgent)break t}u=""}return u.indexOf(r)!=-1}var St=Array.prototype.map?function(r,u){return Array.prototype.map.call(r,u,void 0)}:function(r,u){for(var h=r.length,f=Array(h),x=typeof r==="string"?r.split(""):r,R=0;R<h;R++)R in x&&(f[R]=u.call(void 0,x[R],R,r));return f},Vt={},yt=null;function zt(r){var u=r.length,h=3*u/4;h%3?h=Math.floor(h):"=.".indexOf(r[u-1])!=-1&&(h="=.".indexOf(r[u-2])!=-1?h-2:h-1);var f=new Uint8Array(h),x=0;return qt(r,function(R){f[x++]=R}),x!==h?f.subarray(0,x):f}function qt(r,u){function h(L){for(;f<r.length;){var _=r.charAt(f++),O=yt[_];if(O!=null)return O;if(!/^[\s\xa0]*$/.test(_))throw Error("Unknown base64 encoding at char: "+_)}return L}de();for(var f=0;;){var x=h(-1),R=h(0),T=h(64),E=h(64);if(E===64&&x===-1)break;u(x<<2|R>>4),T!=64&&(u(R<<4&240|T>>2),E!=64&&u(T<<6&192|E))}}function de(){if(!yt){yt={};for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=["+/=","+/","-_=","-_.","-_"],h=0;5>h;h++){var f=r.concat(u[h].split(""));Vt[h]=f;for(var x=0;x<f.length;x++){var R=f[x];yt[R]===void 0&&(yt[R]=x)}}}}var Mt=typeof Uint8Array<"u",we=!(pt("Trident")||pt("MSIE"))&&typeof st.btoa==="function";function ne(r){if(!we){var u;u===void 0&&(u=0),de(),u=Vt[u];for(var h=Array(Math.floor(r.length/3)),f=u[64]||"",x=0,R=0;x<r.length-2;x+=3){var T=r[x],E=r[x+1],L=r[x+2],_=u[T>>2];T=u[(T&3)<<4|E>>4],E=u[(E&15)<<2|L>>6],L=u[L&63],h[R++]=_+T+E+L}switch(_=0,L=f,r.length-x){case 2:_=r[x+1],L=u[(_&15)<<2]||f;case 1:r=r[x],h[R]=u[r>>2]+u[(r&3)<<4|_>>4]+L+f}return h.join("")}for(u="";10240<r.length;)u+=String.fromCharCode.apply(null,r.subarray(0,10240)),r=r.subarray(10240);return u+=String.fromCharCode.apply(null,r),btoa(u)}var Xt=RegExp("[-_.]","g");function se(r){switch(r){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function xt(r){if(!we)return zt(r);Xt.test(r)&&(r=r.replace(Xt,se)),r=atob(r);for(var u=new Uint8Array(r.length),h=0;h<r.length;h++)u[h]=r.charCodeAt(h);return u}var re;function Kt(){return re||(re=new Uint8Array(0))}var Lt={},me=typeof Uint8Array.prototype.slice==="function",mt=0,ct=0;function fe(r){var u=0>r;r=Math.abs(r);var h=r>>>0;r=Math.floor((r-h)/4294967296),u&&(h=c(Te(h,r)),u=h.next().value,r=h.next().value,h=u),mt=h>>>0,ct=r>>>0}var qe=typeof BigInt==="function";function Te(r,u){return u=~u,r?r=~r+1:u+=1,[r,u]}function Zt(r,u){this.i=r>>>0,this.h=u>>>0}function Xe(r){if(!r)return Pe||(Pe=new Zt(0,0));if(!/^-?\d+$/.test(r))return null;if(16>r.length)fe(Number(r));else if(qe)r=BigInt(r),mt=Number(r&BigInt(4294967295))>>>0,ct=Number(r>>BigInt(32)&BigInt(4294967295));else{var u=+(r[0]==="-");ct=mt=0;for(var h=r.length,f=u,x=(h-u)%6+u;x<=h;f=x,x+=6)f=Number(r.slice(f,x)),ct*=1e6,mt=1e6*mt+f,4294967296<=mt&&(ct+=mt/4294967296|0,mt%=4294967296);u&&(u=c(Te(mt,ct)),r=u.next().value,u=u.next().value,mt=r,ct=u)}return new Zt(mt,ct)}var Pe;
1function Re(r,u){return Error("Invalid wire type: "+r+" (at position "+u+")")}function Qt(){return Error("Failed to read varint, encoding is invalid.")}function Ae(r,u){return Error("Tried to read past the end of the data "+u+" > "+r)}function Dt(){throw Error("Invalid UTF8")}function ae(r,u){return u=String.fromCharCode.apply(null,u),r==null?u:r+u}var Jt=void 0,oe,ge=typeof TextDecoder<"u",Ze,Qe=typeof TextEncoder<"u",ki;function Hs(r){if(r!==Lt)throw Error("illegal external caller")}function ui(r,u){if(Hs(u),this.V=r,r!=null&&r.length===0)throw Error("ByteString should be constructed with non-empty values")}function pn(){return ki||(ki=new ui(null,Lt))}function Os(r){Hs(Lt);var u=r.V;return u=u==null||Mt&&u!=null&&u instanceof Uint8Array?u:typeof u==="string"?xt(u):null,u==null?u:r.V=u}function Dl(r){if(typeof r==="string")return{buffer:xt(r),C:!1};if(Array.isArray(r))return{buffer:new Uint8Array(r),C:!1};if(r.constructor===Uint8Array)return{buffer:r,C:!1};if(r.constructor===ArrayBuffer)return{buffer:new Uint8Array(r),C:!1};if(r.constructor===ui)return{buffer:Os(r)||Kt(),C:!0};if(r instanceof Uint8Array)return{buffer:new Uint8Array(r.buffer,r.byteOffset,r.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")}function Ns(r,u){this.i=null,this.m=!1,this.h=this.j=this.l=0,dn(this,r,u)}function dn(r,u,h){h=h===void 0?{}:h,r.S=h.S===void 0?!1:h.S,u&&(u=Dl(u),r.i=u.buffer,r.m=u.C,r.l=0,r.j=r.i.length,r.h=r.l)}Ns.prototype.reset=function(){this.h=this.l};function Le(r,u){if(r.h=u,u>r.j)throw Ae(r.j,u)}function ci(r){var{i:u,h}=r,f=u[h++],x=f&127;if(f&128&&(f=u[h++],x|=(f&127)<<7,f&128&&(f=u[h++],x|=(f&127)<<14,f&128&&(f=u[h++],x|=(f&127)<<21,f&128&&(f=u[h++],x|=f<<28,f&128&&u[h++]&128&&u[h++]&128&&u[h++]&128&&u[h++]&128&&u[h++]&128)))))throw Qt();return Le(r,h),x}function ks(r,u){if(0>u)throw Error("Tried to read a negative byte length: "+u);var h=r.h,f=h+u;if(f>r.j)throw Ae(u,r.j-h);return r.h=f,h}var Ks=[];function mn(){this.h=[]}mn.prototype.length=function(){return this.h.length},mn.prototype.end=function(){var r=this.h;return this.h=[],r};function Js(r,u,h){for(;0<h||127<u;)r.h.push(u&127|128),u=(u>>>7|h<<25)>>>0,h>>>=7;r.h.push(u)}function Ie(r,u){for(;127<u;)r.h.push(u&127|128),u>>>=7;r.h.push(u)}function fn(r,u){if(Ks.length){var h=Ks.pop();dn(h,r,u),r=h}else r=new Ns(r,u);this.h=r,this.j=this.h.h,this.i=this.l=-1,this.setOptions(u)}fn.prototype.setOptions=function(r){r=r===void 0?{}:r,this.ca=r.ca===void 0?!1:r.ca},fn.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};function Gs(r){var u=r.h;if(u.h==u.j)return!1;r.j=r.h.h;var h=ci(r.h)>>>0;if(u=h>>>3,h&=7,!(0<=h&&5>=h))throw Re(h,r.j);if(1>u)throw Error("Invalid field number: "+u+" (at position "+r.j+")");return r.l=u,r.i=h,!0}function Ki(r){switch(r.i){case 0:if(r.i!=0)Ki(r);else t:{r=r.h;for(var u=r.h,h=u+10,f=r.i;u<h;)if((f[u++]&128)===0){Le(r,u);break t}throw Qt()}break;case 1:r=r.h,Le(r,r.h+8);break;case 2:r.i!=2?Ki(r):(u=ci(r.h)>>>0,r=r.h,Le(r,r.h+u));break;case 5:r=r.h,Le(r,r.h+4);break;case 3:u=r.l;do{if(!Gs(r))throw Error("Unmatched start-group tag: stream EOF");if(r.i==4){if(r.l!=u)throw Error("Unmatched end-group tag");break}Ki(r)}while(1);break;default:throw Re(r.i,r.j)}}var Ji=[];function El(){this.j=[],this.i=0,this.h=new mn}function ti(r,u){u.length!==0&&(r.j.push(u),r.i+=u.length)}function wl(r,u){if(u=u.R){ti(r,r.h.end());for(var h=0;h<u.length;h++)ti(r,Os(u[h])||Kt())}}var Se=typeof Symbol==="function"&&typeof Symbol()==="symbol"?Symbol():void 0;function Fe(r,u){if(Se)return r[Se]|=u;if(r.A!==void 0)return r.A|=u;return Object.defineProperties(r,{A:{value:u,configurable:!0,writable:!0,enumerable:!1}}),u}function Us(r,u){Se?r[Se]&&(r[Se]&=~u):r.A!==void 0&&(r.A&=~u)}function Tt(r){var u;return Se?u=r[Se]:u=r.A,u==null?0:u}function le(r,u){Se?r[Se]=u:r.A!==void 0?r.A=u:Object.defineProperties(r,{A:{value:u,configurable:!0,writable:!0,enumerable:!1}})}function gn(r){return Fe(r,1),r}function Al(r,u){le(u,(r|0)&-51)}function Gi(r,u){le(u,(r|18)&-41)}var Sn={};function Ui(r){return r!==null&&typeof r==="object"&&!Array.isArray(r)&&r.constructor===Object}var hi,Bs=[];le(Bs,23),hi=Object.freeze(Bs);function vn(r){if(Tt(r.o)&2)throw Error("Cannot mutate an immutable Message")}function xn(r){var u=r.length;(u=u?r[u-1]:void 0)&&Ui(u)?u.g=1:(u={},r.push((u.g=1,u)))}function Vs(r){var u=r.i+r.G;return r.B||(r.B=r.o[u]={})}function te(r,u){return u===-1?null:u>=r.i?r.B?r.B[u]:void 0:r.o[u+r.G]}function ue(r,u,h,f){vn(r),pi(r,u,h,f)}function pi(r,u,h,f){r.j&&(r.j=void 0),u>=r.i||f?Vs(r)[u]=h:(r.o[u+r.G]=h,(r=r.B)&&(u in r)&&delete r[u])}function Tn(r,u,h,f){var x=te(r,u);Array.isArray(x)||(x=hi);var R=Tt(x);if(R&1||gn(x),f)R&2||Fe(x,2),h&1||Object.freeze(x);else{f=!(h&2);var T=R&2;
1h&1||!T?f&&R&16&&!T&&Us(x,16):(x=gn(Array.prototype.slice.call(x)),pi(r,u,x))}return x}function Pn(r,u){var h=te(r,u),f=h==null?h:typeof h==="number"||h==="NaN"||h==="Infinity"||h==="-Infinity"?Number(h):void 0;return f!=null&&f!==h&&pi(r,u,f),f}function Ws(r,u,h,f,x){r.h||(r.h={});var R=r.h[h],T=Tn(r,h,3,x);if(!R){var E=T;R=[];var L=!!(Tt(r.o)&16);T=!!(Tt(E)&2);var _=E;!x&&T&&(E=Array.prototype.slice.call(E));for(var O=T,Q=0;Q<E.length;Q++){var q=E[Q],G=u,tt=!1;if(tt=tt===void 0?!1:tt,q=Array.isArray(q)?new G(q):tt?new G:void 0,q!==void 0){G=q.o;var nt=tt=Tt(G);T&&(nt|=2),L&&(nt|=16),nt!=tt&&le(G,nt),G=nt,O=O||!!(2&G),R.push(q)}}return r.h[h]=R,L=Tt(E),u=L|33,u=O?u&-9:u|8,L!=u&&(O=E,Object.isFrozen(O)&&(O=Array.prototype.slice.call(O)),le(O,u),E=O),_!==E&&pi(r,h,E),(x||f&&T)&&Fe(R,2),f&&Object.freeze(R),R}return x||(x=Object.isFrozen(R),f&&!x?Object.freeze(R):!f&&x&&(R=Array.prototype.slice.call(R),r.h[h]=R)),R}function Rn(r,u,h){var f=!!(Tt(r.o)&2);if(u=Ws(r,u,h,f,f),r=Tn(r,h,3,f),!(f||Tt(r)&8)){for(f=0;f<u.length;f++){if(h=u[f],Tt(h.o)&2){var x=Xs(h,!1);x.j=h}else x=h;h!==x&&(u[f]=x,r[f]=x.o)}Fe(r,8)}return u}function ce(r,u,h){if(h!=null&&typeof h!=="number")throw Error("Value of float/double field must be a number|null|undefined, found "+typeof h+": "+h);ue(r,u,h)}function $s(r,u,h,f,x){vn(r);var R=Ws(r,h,u,!1,!1);
1return h=f!=null?f:new h,r=Tn(r,u,2,!1),x!=null?(R.splice(x,0,h),r.splice(x,0,h.o)):(R.push(h),r.push(h.o)),h.C()&&Us(r,8),h}function Bi(r,u){return r==null?u:r}function he(r,u,h){return h=h===void 0?0:h,Bi(Pn(r,u),h)}var Vi;function Ll(r){switch(typeof r){case"number":return isFinite(r)?r:String(r);case"object":if(r)if(Array.isArray(r)){if((Tt(r)&128)!==0)return r=Array.prototype.slice.call(r),xn(r),r}else{if(Mt&&r!=null&&r instanceof Uint8Array)return ne(r);if(r instanceof ui){var u=r.V;return u==null?"":typeof u==="string"?u:r.V=ne(u)}}}return r}function js(r,u,h,f){if(r!=null){if(Array.isArray(r))r=bn(r,u,h,f!==void 0);else if(Ui(r)){var x={},R;for(R in r)x[R]=js(r[R],u,h,f);r=x}else r=u(r,f);return r}}function bn(r,u,h,f){var x=Tt(r);f=f?!!(x&16):void 0,r=Array.prototype.slice.call(r);for(var R=0;R<r.length;R++)r[R]=js(r[R],u,h,f);return h(x,r),r}function Il(r){return r.ja===Sn?r.toJSON():Ll(r)}function Fl(r,u){r&128&&xn(u)}function Ys(r,u,h){if(h=h===void 0?Gi:h,r!=null){if(Mt&&r instanceof Uint8Array)return r.length?new ui(new Uint8Array(r),Lt):pn();if(Array.isArray(r)){var f=Tt(r);if(f&2)return r;if(u&&!(f&32)&&(f&16||f===0))return le(r,f|2),r;return r=bn(r,Ys,f&4?Gi:h,!0),u=Tt(r),u&4&&u&2&&Object.freeze(r),r}return r.ja===Sn?qs(r):r}}function zs(r,u,h,f,x,R,T){if(r=r.h&&r.h[h]){if(f=Tt(r),f&2?f=r:(R=St(r,qs),Gi(f,R),Object.freeze(R),f=R),vn(u),T=f==null?hi:gn([]),f!=null){R=!!f.length;for(r=0;r<f.length;r++){var E=f[r];R=R&&!(Tt(E.o)&2),T[r]=E.o}R=(R?8:0)|1,r=Tt(T),(r&R)!==R&&(Object.isFrozen(T)&&(T=Array.prototype.slice.call(T)),le(T,r|R)),u.h||(u.h={}),u.h[h]=f}else u.h&&(u.h[h]=void 0);pi(u,h,T,x)}else ue(u,h,Ys(f,R,T),x)}function qs(r){if(Tt(r.o)&2)return r;return r=Xs(r,!0),Fe(r.o,2),r}function Xs(r,u){var h=r.o,f=[];Fe(f,16);var x=r.constructor.h;if(x&&f.push(x),x=r.B,x){f.length=h.length,f.fill(void 0,f.length,h.length);var R={};f[f.length-1]=R}(Tt(h)&128)!==0&&xn(f),u=u||r.C()?Gi:Al,R=r.constructor,Vi=f,f=new R(f),Vi=void 0,r.R&&(f.R=r.R.slice()),R=!!(Tt(h)&16);for(var T=x?h.length-1:h.length,E=0;E<T;E++)zs(r,f,E-r.G,h[E],!1,R,u);if(x)for(var L in x)zs(r,f,+L,x[L],!0,R,u);return f}function Gt(r,u,h){r==null&&(r=Vi),Vi=void 0;var f=this.constructor.i||0,x=0<f,R=this.constructor.h,T=!1;if(r==null){r=R?[R]:[];var E=48,L=!0;x&&(f=0,E|=128),le(r,E)}else{if(!Array.isArray(r))throw Error();if(R&&R!==r[0])throw Error();var _=E=Fe(r,0);if(L=(16&_)!==0)(T=(32&_)!==0)||(_|=32);if(x){if(128&_)f=0;else if(0<r.length){var O=r[r.length-1];if(Ui(O)&&"g"in O){f=0,_|=128,delete O.g;var Q=!0,q;for(q in O){Q=!1;break}Q&&r.pop()}}}else if(128&_)throw Error();E!==_&&le(r,_)}this.G=(R?0:-1)-f,this.h=void 0,this.o=r;t:{if(R=this.o.length,f=R-1,R&&(R=this.o[f],Ui(R))){this.B=R,this.i=f-this.G;break t}u!==void 0&&-1<u?(this.i=Math.max(u,f+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE}if(!x&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(h){u=L&&!T&&!0,x=this.i;var G;for(L=0;L<h.length;L++)T=h[L],T<x?(T+=this.G,(f=r[T])?Zs(f,u):r[T]=hi):(G||(G=Vs(this)),(f=G[T])?Zs(f,u):G[T]=hi)}}Gt.prototype.toJSON=function(){return bn(this.o,Il,Fl)},Gt.prototype.C=function(){return!!(Tt(this.o)&2)};function Zs(r,u){if(Array.isArray(r)){var h=Tt(r),f=1;!u||h&2||(f|=16),(h&f)!==f&&le(r,h|f)}}Gt.prototype.ja=Sn,Gt.prototype.toString=function(){return this.o.toString()};function Qs(r,u,h){if(h){var f={},x;for(x in h){var R=h[x],T=R.ra;T||(f.J=R.xa||R.oa.W,R.ia?(f.aa=sr(R.ia),T=function(E){return function(L,_,O){return E.J(L,_,O,E.aa)}}(f)):R.ka?(f.Z=rr(R.da.P,R.ka),T=function(E){return function(L,_,O){return E.J(L,_,O,E.Z)}}(f)):T=f.J,R.ra=T),T(u,r,R.da),f={J:f.J,aa:f.aa,Z:f.Z}}}wl(u,r)}var Wi=Symbol();function tr(r,u,h){return r[Wi]||(r[Wi]=function(f,x){return u(f,x,h)})}function er(r){var u=r[Wi];if(!u){var h=Dn(r);u=function(f,x){return ar(f,x,h)},r[Wi]=u}return u}function Ml(r){var u=r.ia;if(u)return er(u);
1if(u=r.wa)return tr(r.da.P,u,r.ka)}function _l(r){var u=Ml(r),h=r.da,f=r.oa.U;return u?function(x,R){return f(x,R,h,u)}:function(x,R){return f(x,R,h)}}function ir(r,u){var h=r[u];return typeof h=="function"&&h.length===0&&(h=h(),r[u]=h),Array.isArray(h)&&((mi in h)||(di in h)||0<h.length&&typeof h[0]=="function")?h:void 0}function nr(r,u,h,f,x,R){u.P=r[0];var T=1;if(r.length>T&&typeof r[T]!=="number"){var E=r[T++];h(u,E)}for(;T<r.length;){h=r[T++];for(var L=T+1;L<r.length&&typeof r[L]!=="number";)L++;switch(E=r[T++],L-=T,L){case 0:f(u,h,E);break;case 1:(L=ir(r,T))?(T++,x(u,h,E,L)):f(u,h,E,r[T++]);break;case 2:L=T++,L=ir(r,L),x(u,h,E,L,r[T++]);break;case 3:R(u,h,E,r[T++],r[T++],r[T++]);break;case 4:R(u,h,E,r[T++],r[T++],r[T++],r[T++]);break;default:throw Error("unexpected number of binary field arguments: "+L)}}return u}var $i=Symbol();function sr(r){var u=r[$i];if(!u){var h=yn(r);u=function(f,x){return or(f,x,h)},r[$i]=u}return u}function rr(r,u){var h=r[$i];return h||(h=function(f,x){return Qs(f,x,u)},r[$i]=h),h}var di=Symbol();function Cl(r,u){r.push(u)}function Hl(r,u,h){r.push(u,h.W)}function Ol(r,u,h,f){var x=sr(f),R=yn(f).P,T=h.W;r.push(u,function(E,L,_){return T(E,L,_,R,x)})}function Nl(r,u,h,f,x,R){var T=rr(f,R),E=h.W;r.push(u,function(L,_,O){return E(L,_,O,f,T)})}function yn(r){var u=r[di];if(u)return u;return u=nr(r,r[di]=[],Cl,Hl,Ol,Nl),mi in r&&di in r&&(r.length=0),u}var mi=Symbol();function kl(r,u){r[0]=u}function Kl(r,u,h,f){var x=h.U;r[u]=f?function(R,T,E){return x(R,T,E,f)}:x}function Jl(r,u,h,f,x){var R=h.U,T=er(f),E=Dn(f).P;r[u]=function(L,_,O){return R(L,_,O,E,T,x)}}function Gl(r,u,h,f,x,R,T){var E=h.U,L=tr(f,x,R);r[u]=function(_,O,Q){return E(_,O,Q,f,L,T)}}function Dn(r){var u=r[mi];if(u)return u;return u=nr(r,r[mi]={},kl,Kl,Jl,Gl),mi in r&&di in r&&(r.length=0),u}function ar(r,u,h){for(;Gs(u)&&u.i!=4;){var f=u.l,x=h[f];if(!x){var R=h[0];R&&(R=R[f])&&(x=h[f]=_l(R))}if(!x||!x(u,r,f)){x=u,f=r,R=x.j,Ki(x);var T=x;if(!T.ca){if(x=T.h.h-R,T.h.h=R,T=T.h,x==0)x=pn();else{if(R=ks(T,x),T.S&&T.m)x=T.i.subarray(R,R+x);else{T=T.i;var E=R;x=R+x,x=E===x?Kt():me?T.slice(E,x):new Uint8Array(T.subarray(E,x))}x=x.length==0?pn():new ui(x,Lt)}(R=f.R)?R.push(x):f.R=[x]}}}return r}function or(r,u,h){for(var f=h.length,x=f%2==1,R=x?1:0;R<f;R+=2)(0,h[R+1])(u,r,h[R]);Qs(r,u,x?h[0]:void 0)}function fi(r,u){return{U:r,W:u}}var ee=fi(function(r,u,h){if(r.i!==5)return!1;r=r.h;var{i:f,h:x}=r,R=f[x],T=f[x+1],E=f[x+2];return f=f[x+3],Le(r,r.h+4),T=(R<<0|T<<8|E<<16|f<<24)>>>0,r=2*(T>>31)+1,R=T>>>23&255,T&=8388607,ue(u,h,R==255?T?NaN:1/0*r:R==0?r*Math.pow(2,-149)*T:r*Math.pow(2,R-150)*(T+Math.pow(2,23))),!0},function(r,u,h){if(u=Pn(u,h),u!=null){Ie(r.h,8*h+5),r=r.h;var f=+u;f===0?0<1/f?mt=ct=0:(ct=0,mt=2147483648):isNaN(f)?(ct=0,mt=2147483647):(f=(h=0>f?-2147483648:0)?-f:f,340282346638528860000000000000000000000<f?(ct=0,mt=(h|2139095040)>>>0):0.000000000000000000000000000000000000011754943508222875>f?(f=Math.round(f/Math.pow(2,-149)),ct=0,mt=(h|f)>>>0):(u=Math.floor(Math.log(f)/Math.LN2),f*=Math.pow(2,-u),f=Math.round(8388608*f),16777216<=f&&++u,ct=0,mt=(h|u+127<<23|f&8388607)>>>0)),h=mt,r.h.push(h>>>0&255),r.h.push(h>>>8&255),r.h.push(h>>>16&255),r.h.push(h>>>24&255)}}),Ul=fi(function(r,u,h){if(r.i!==0)return!1;var f=r.h,x=0,R=r=0,T=f.i,E=f.h;do{var L=T[E++];x|=(L&127)<<R,R+=7}while(32>R&&L&128);32<R&&(r|=(L&127)>>4);for(R=3;32>R&&L&128;R+=7)L=T[E++],r|=(L&127)<<R;if(Le(f,E),128>L){if(f=x>>>0,L=r>>>0,r=L&2147483648)f=~f+1>>>0,L=~L>>>0,f==0&&(L=L+1>>>0);f=4294967296*L+(f>>>0)}else throw Qt();return ue(u,h,r?-f:f),!0},function(r,u,h){u=te(u,h),u!=null&&(typeof u==="string"&&Xe(u),u!=null&&(Ie(r.h,8*h),typeof u==="number"?(r=r.h,fe(u),Js(r,mt,ct)):(h=Xe(u),Js(r.h,h.i,h.h))))}),Bl=fi(function(r,u,h){if(r.i!==0)return!1;return ue(u,h,ci(r.h)),!0},function(r,u,h){if(u=te(u,h),u!=null&&u!=null)if(Ie(r.h,8*h),r=r.h,h=u,0<=h)Ie(r,h);else{for(u=0;9>u;u++)r.h.push(h&127|128),h>>=7;r.h.push(1)}}),lr=fi(function(r,u,h){if(r.i!==2)return!1;var f=ci(r.h)>>>0;r=r.h;var x=ks(r,f);if(r=r.i,ge){var R=r,T;(T=oe)||(T=oe=new TextDecoder("utf-8",{fatal:!0})),r=x+f,R=x===0&&r===R.length?R:R.subarray(x,r);try{var E=T.decode(R)}catch(Q){if(Jt===void 0){try{T.decode(new Uint8Array([128]))}catch(q){}try{T.decode(new Uint8Array([97])),Jt=!0}catch(q){Jt=!1}}throw!Jt&&(oe=void 0),Q}}else{E=x,f=E+f,x=[];for(var L=null,_,O;E<f;)_=r[E++],128>_?x.push(_):224>_?E>=f?Dt():(O=r[E++],194>_||(O&192)!==128?(E--,Dt()):x.push((_&31)<<6|O&63)):240>_?E>=f-1?Dt():(O=r[E++],(O&192)!==128||_===224&&160>O||_===237&&160<=O||((R=r[E++])&192)!==128?(E--,Dt()):x.push((_&15)<<12|(O&63)<<6|R&63)):244>=_?E>=f-2?Dt():(O=r[E++],(O&192)!==128||(_<<28)+(O-144)>>30!==0||((R=r[E++])&192)!==128||((T=r[E++])&192)!==128?(E--,Dt()):(_=(_&7)<<18|(O&63)<<12|(R&63)<<6|T&63,_-=65536,x.push((_>>10&1023)+55296,(_&1023)+56320))):Dt(),8192<=x.length&&(L=ae(L,x),x.length=0);E=ae(L,x)}return ue(u,h,E),!0},function(r,u,h){if(u=te(u,h),u!=null){var f=!1;if(f=f===void 0?!1:f,Qe){if(f&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(u))throw Error("Found an unpaired surrogate");u=(Ze||(Ze=new TextEncoder)).encode(u)}else{for(var x=0,R=new Uint8Array(3*u.length),T=0;T<u.length;T++){var E=u.charCodeAt(T);if(128>E)R[x++]=E;else{if(2048>E)R[x++]=E>>6|192;else{if(55296<=E&&57343>=E){if(56319>=E&&T<u.length){var L=u.charCodeAt(++T);if(56320<=L&&57343>=L){E=1024*(E-55296)+L-56320+65536,R[x++]=E>>18|240,R[x++]=E>>12&63|128,R[x++]=E>>6&63|128,R[x++]=E&63|128;continue}else T--}if(f)throw Error("Found an unpaired surrogate");E=65533}R[x++]=E>>12|224,R[x++]=E>>6&63|128}R[x++]=E&63|128}}u=x===R.length?R:R.subarray(0,x)}Ie(r.h,8*h+2),Ie(r.h,u.length),ti(r,r.h.end()),ti(r,u)}}),ur=fi(function(r,u,h,f,x){if(r.i!==2)return!1;u=$s(u,h,f),h=r.h.j,f=ci(r.h)>>>0;var R=r.h.h+f,T=R-h;if(0>=T&&(r.h.j=R,x(u,r,void 0,void 0,void 0),T=R-r.h.h),T)throw Error("Message parsing ended unexpectedly. Expected to read "+(f+" bytes, instead read "+(f-T)+" bytes, either the data ended unexpectedly or the message misreported its own length"));return r.h.h=R,r.h.j=h,!0},function(r,u,h,f,x){if(u=Rn(u,f,h),u!=null)for(f=0;f<u.length;f++){var R=r;Ie(R.h,8*h+2);var T=R.h.end();ti(R,T),T.push(R.i),R=T,x(u[f],r),T=r;var E=R.pop();for(E=T.i+T.h.length()-E;127<E;)R.push(E&127|128),E>>>=7,T.i++;R.push(E),T.i++}});function En(r){return function(u,h){t:{if(Ji.length){var f=Ji.pop();f.setOptions(h),dn(f.h,u,h),u=f}else u=new fn(u,h);try{var x=Dn(r),R=ar(new x.P,u,x);break t}finally{x=u.h,x.i=null,x.m=!1,x.l=0,x.j=0,x.h=0,x.S=!1,u.l=-1,u.i=-1,100>Ji.length&&Ji.push(u)}R=void 0}return R}}function wn(r){return function(){var u=new El;or(this,u,yn(r)),ti(u,u.h.end());for(var h=new Uint8Array(u.i),f=u.j,x=f.length,R=0,T=0;T<x;T++){var E=f[T];h.set(E,R),R+=E.length}return u.j=[h],h}}function ei(r){Gt.call(this,r)}D(ei,Gt);var cr=[ei,1,Bl,2,ee,3,lr,4,lr];ei.prototype.l=wn(cr);function An(r){Gt.call(this,r,-1,Vl)}D(An,Gt),An.prototype.addClassification=function(r,u){return $s(this,1,ei,r,u),this};
1var Vl=[1],Wl=En([An,1,ur,cr]);function gi(r){Gt.call(this,r)}D(gi,Gt);var hr=[gi,1,ee,2,ee,3,ee,4,ee,5,ee];gi.prototype.l=wn(hr);function pr(r){Gt.call(this,r,-1,$l)}D(pr,Gt);var $l=[1],jl=En([pr,1,ur,hr]);function ji(r){Gt.call(this,r)}D(ji,Gt);var dr=[ji,1,ee,2,ee,3,ee,4,ee,5,ee,6,Ul],Yl=En(dr);ji.prototype.l=wn(dr);function mr(r,u,h){if(h=r.createShader(h===0?r.VERTEX_SHADER:r.FRAGMENT_SHADER),r.shaderSource(h,u),r.compileShader(h),!r.getShaderParameter(h,r.COMPILE_STATUS))throw Error(`Could not compile WebGL shader. 2 3`+r.getShaderInfoLog(h));return h}function zl(r){return Rn(r,ei,1).map(function(u){var h=te(u,1);return{index:h==null?0:h,qa:he(u,2),label:te(u,3)!=null?Bi(te(u,3),""):void 0,displayName:te(u,4)!=null?Bi(te(u,4),""):void 0}})}function ql(r){return{x:he(r,1),y:he(r,2),z:he(r,3),visibility:Pn(r,4)!=null?he(r,4):void 0}}function Ln(r){return Rn(jl(r),gi,1).map(ql)}function In(r,u){this.i=r,this.h=u,this.m=0}function fr(r,u,h){if(Xl(r,u),typeof r.h.canvas.transferToImageBitmap==="function")return Promise.resolve(r.h.canvas.transferToImageBitmap());if(h)return Promise.resolve(r.h.canvas);if(typeof createImageBitmap==="function")return createImageBitmap(r.h.canvas);return r.j===void 0&&(r.j=document.createElement("canvas")),new Promise(function(f){r.j.height=r.h.canvas.height,r.j.width=r.h.canvas.width,r.j.getContext("2d",{}).drawImage(r.h.canvas,0,0,r.h.canvas.width,r.h.canvas.height),f(r.j)})}function Xl(r,u){var h=r.h;if(r.s===void 0){var f=mr(h,` 4 attribute vec2 aVertex; 5 attribute vec2 aTex; 6 varying vec2 vTex; 7 void main(void) { 8 gl_Position = vec4(aVertex, 0.0, 1.0); 9 vTex = aTex; 10 }`,0),x=mr(h,` 11 precision mediump float; 12 varying vec2 vTex; 13 uniform sampler2D sampler0; 14 void main(){ 15 gl_FragColor = texture2D(sampler0, vTex); 16 }`,1),R=h.createProgram();if(h.attachShader(R,f),h.attachShader(R,x),h.linkProgram(R),!h.getProgramParameter(R,h.LINK_STATUS))throw Error(`Could not compile WebGL program. 17 18`+h.getProgramInfoLog(R));f=r.s=R,h.useProgram(f),x=h.getUniformLocation(f,"sampler0"),r.l={O:h.getAttribLocation(f,"aVertex"),N:h.getAttribLocation(f,"aTex"),ya:x},r.v=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,r.v),h.enableVertexAttribArray(r.l.O),h.vertexAttribPointer(r.l.O,2,h.FLOAT,!1,0,0),h.bufferData(h.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),h.STATIC_DRAW),h.bindBuffer(h.ARRAY_BUFFER,null),r.u=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,r.u),h.enableVertexAttribArray(r.l.N),h.vertexAttribPointer(r.l.N,2,h.FLOAT,!1,0,0),h.bufferData(h.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),h.STATIC_DRAW),h.bindBuffer(h.ARRAY_BUFFER,null),h.uniform1i(x,0)}f=r.l,h.useProgram(r.s),h.canvas.width=u.width,h.canvas.height=u.height,h.viewport(0,0,u.width,u.height),h.activeTexture(h.TEXTURE0),r.i.bindTexture2d(u.glName),h.enableVertexAttribArray(f.O),h.bindBuffer(h.ARRAY_BUFFER,r.v),h.vertexAttribPointer(f.O,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(f.N),h.bindBuffer(h.ARRAY_BUFFER,r.u),h.vertexAttribPointer(f.N,2,h.FLOAT,!1,0,0),h.bindFramebuffer(h.DRAW_FRAMEBUFFER?h.DRAW_FRAMEBUFFER:h.FRAMEBUFFER,null),h.clearColor(0,0,0,0),h.clear(h.COLOR_BUFFER_BIT),h.colorMask(!0,!0,!0,!0),h.drawArrays(h.TRIANGLE_FAN,0,4),h.disableVertexAttribArray(f.O),h.disableVertexAttribArray(f.N),h.bindBuffer(h.ARRAY_BUFFER,null),r.i.bindTexture2d(0)}function Zl(r){this.h=r}var Ql=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 tu(r,u){return u+r}function gr(r,u){window[r]=u}function eu(r){var u=document.createElement("script");return u.setAttribute("src",r),u.setAttribute("crossorigin","anonymous"),new Promise(function(h){u.addEventListener("load",function(){h()},!1),u.addEventListener("error",function(){h()},!1),document.body.appendChild(u)})}function iu(){return Y(function(r){switch(r.h){case 1:return r.s=2,M(r,WebAssembly.instantiate(Ql),4);case 4:r.h=3,r.s=0;break;case 2:return r.s=0,r.l=null,r.return(!1);case 3:return r.return(!0)}})}function Fn(r){if(this.h=r,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=r&&r.locateFile||tu,typeof window==="object")var u=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")u=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/";else throw Error("solutions can only be loaded on a web page or in a web worker");if(this.ha=u,r.options){u=c(Object.keys(r.options));for(var h=u.next();!h.done;h=u.next()){h=h.value;var f=r.options[h].default;f!==void 0&&(this.l[h]=typeof f==="function"?f():f)}}}e=Fn.prototype,e.close=function(){return this.j&&this.j.delete(),Promise.resolve()};function nu(r){var u,h,f,x,R,T,E,L,_,O,Q;return Y(function(q){switch(q.h){case 1:if(!r.ga)return q.return();return u=r.h.files===void 0?[]:typeof r.h.files==="function"?r.h.files(r.l):r.h.files,M(q,iu(),2);case 2:if(h=q.i,typeof window==="object")return gr("createMediapipeSolutionsWasm",{locateFile:r.locateFile}
18),gr("createMediapipeSolutionsPackedAssets",{locateFile:r.locateFile}),T=u.filter(function(G){return G.data!==void 0}),E=u.filter(function(G){return G.data===void 0}),L=Promise.all(T.map(function(G){var tt=Yi(r,G.url);if(G.path!==void 0){var nt=G.path;tt=tt.then(function(dt){return r.overrideFile(nt,dt),Promise.resolve(dt)})}return tt})),_=Promise.all(E.map(function(G){return G.simd===void 0||G.simd&&h||!G.simd&&!h?eu(r.locateFile(G.url,r.ha)):Promise.resolve()})).then(function(){var G,tt,nt;return Y(function(dt){if(dt.h==1)return G=window.createMediapipeSolutionsWasm,tt=window.createMediapipeSolutionsPackedAssets,nt=r,M(dt,G(tt),2);nt.i=dt.i,dt.h=0})}),O=function(){return Y(function(G){return r.h.graph&&r.h.graph.url?G=M(G,Yi(r,r.h.graph.url),0):(G.h=0,G=void 0),G})}(),M(q,Promise.all([_,L,O]),7);if(typeof importScripts!=="function")throw Error("solutions can only be loaded on a web page or in a web worker");return f=u.filter(function(G){return G.simd===void 0||G.simd&&h||!G.simd&&!h}).map(function(G){return r.locateFile(G.url,r.ha)}),importScripts.apply(null,p(f)),x=r,M(q,createMediapipeSolutionsWasm(Module),6);case 6:x.i=q.i,r.m=new OffscreenCanvas(1,1),r.i.canvas=r.m,R=r.i.GL.createContext(r.m,{antialias:!1,alpha:!1,va:typeof WebGL2RenderingContext<"u"?2:1}),r.i.GL.makeContextCurrent(R),q.h=4;break;case 7:if(r.m=document.createElement("canvas"),Q=r.m.getContext("webgl2",{}),!Q&&(Q=r.m.getContext("webgl",{}),!Q))return alert("Failed to create WebGL canvas context when passing video frame."),q.return();r.K=Q,r.i.canvas=r.m,r.i.createContext(r.m,!0,!0,{});case 4:r.j=new r.i.SolutionWasm,r.ga=!1,q.h=0}})}function su(r){var u,h,f,x,R,T,E,L;return Y(function(_){if(_.h==1){if(r.h.graph&&r.h.graph.url&&r.fa===r.h.graph.url)return _.return();if(r.u=!0,!r.h.graph||!r.h.graph.url){_.h=2;return}return r.fa=r.h.graph.url,M(_,Yi(r,r.h.graph.url),3)}_.h!=2&&(u=_.i,r.j.loadGraph(u)),h=c(Object.keys(r.D));for(f=h.next();!f.done;f=h.next())x=f.value,r.j.overrideFile(x,r.D[x]);if(r.D={},r.h.listeners)for(R=c(r.h.listeners),T=R.next();!T.done;T=R.next())E=T.value,lu(r,E);L=r.l,r.l={},r.setOptions(L),_.h=0})}e.reset=function(){var r=this;return Y(function(u){r.j&&(r.j.reset(),r.s={},r.v={}),u.h=0})},e.setOptions=function(r,u){var h=this;if(u=u||this.h.options){for(var f=[],x=[],R={},T=c(Object.keys(r)),E=T.next();!E.done;R={X:R.X,Y:R.Y},E=T.next())if(E=E.value,!((E in this.l)&&this.l[E]===r[E])){this.l[E]=r[E];var L=u[E];L!==void 0&&(L.onChange&&(R.X=L.onChange,R.Y=r[E],f.push(function(_){return function(){var O;return Y(function(Q){if(Q.h==1)return M(Q,_.X(_.Y),2);O=Q.i,O===!0&&(h.u=!0),Q.h=0})}}(R))),L.graphOptionXref&&(E=Object.assign({},{calculatorName:"",calculatorIndex:0},L.graphOptionXref,{valueNumber:L.type===1?r[E]:0,valueBoolean:L.type===0?r[E]:!1,valueString:L.type===2?r[E]:""}),x.push(E)))}if(f.length!==0||x.length!==0)this.u=!0,this.H=(this.H===void 0?[]:this.H).concat(x),this.F=(this.F===void 0?[]:this.F).concat(f)}};function ru(r){var u,h,f,x,R,T,E;return Y(function(L){switch(L.h){case 1:if(!r.u)return L.return();if(!r.F){L.h=2;break}u=c(r.F),h=u.next();case 3:if(h.done){L.h=5;break}return f=h.value,M(L,f(),4);case 4:h=u.next(),L.h=3;break;case 5:r.F=void 0;case 2:if(r.H){x=new r.i.GraphOptionChangeRequestList,R=c(r.H);for(T=R.next();!T.done;T=R.next())E=T.value,x.push_back(E);r.j.changeOptions(x),x.delete(),r.H=void 0}r.u=!1,L.h=0}})}e.initialize=function(){var r=this;return Y(function(u){return u.h==1?M(u,nu(r),2):u.h!=3?M(u,su(r),3):M(u,ru(r),0)})};function Yi(r,u){var h,f;return Y(function(x){if(u in r.L)return x.return(r.L[u]);return h=r.locateFile(u,""),f=fetch(h).then(function(R){return R.arrayBuffer()}),r.L[u]=f,x.return(f)})}e.overrideFile=function(r,u){this.j?this.j.overrideFile(r,u):this.D[r]=u},e.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},e.send=function(r,u){var h=this,f,x,R,T,E,L,_,O,Q;return Y(function(q){switch(q.h){case 1:if(!h.h.inputs)return q.return();return f=1000*(u===void 0||u===null?performance.now():u),M(q,h.I,2);case 2:return M(q,h.initialize(),3);case 3:x=new h.i.PacketDataList,R=c(Object.keys(r));for(T=R.next();!T.done;T=R.next())if(E=T.value,L=h.h.inputs[E]){t:{var G=r[E];switch(L.type){case"video":var tt=h.s[L.stream];if(tt||(tt=new In(h.i,h.K),h.s[L.stream]=tt),tt.m===0&&(tt.m=tt.i.createTexture()),typeof HTMLVideoElement<"u"&&G instanceof HTMLVideoElement)var{videoWidth:nt,videoHeight:dt}=G;
18else typeof HTMLImageElement<"u"&&G instanceof HTMLImageElement?(nt=G.naturalWidth,dt=G.naturalHeight):(nt=G.width,dt=G.height);dt={glName:tt.m,width:nt,height:dt},nt=tt.h,nt.canvas.width=dt.width,nt.canvas.height=dt.height,nt.activeTexture(nt.TEXTURE0),tt.i.bindTexture2d(tt.m),nt.texImage2D(nt.TEXTURE_2D,0,nt.RGBA,nt.RGBA,nt.UNSIGNED_BYTE,G),tt.i.bindTexture2d(0),tt=dt;break t;case"detections":tt=h.s[L.stream],tt||(tt=new Zl(h.i),h.s[L.stream]=tt),tt.data||(tt.data=new tt.h.DetectionListData),tt.data.reset(G.length);for(dt=0;dt<G.length;++dt){nt=G[dt];var ht=tt.data,It=ht.setBoundingBox,$t=dt,Ut=nt.la,at=new ji;if(ce(at,1,Ut.sa),ce(at,2,Ut.ta),ce(at,3,Ut.height),ce(at,4,Ut.width),ce(at,5,Ut.rotation),ue(at,6,Ut.pa),Ut=at.l(),It.call(ht,$t,Ut),nt.ea)for(ht=0;ht<nt.ea.length;++ht){at=nt.ea[ht],It=tt.data,$t=It.addNormalizedLandmark,Ut=dt,at=Object.assign({},at,{visibility:at.visibility?at.visibility:0});var Ft=new gi;ce(Ft,1,at.x),ce(Ft,2,at.y),ce(Ft,3,at.z),at.visibility&&ce(Ft,4,at.visibility),at=Ft.l(),$t.call(It,Ut,at)}if(nt.ba)for(ht=0;ht<nt.ba.length;++ht)It=tt.data,$t=It.addClassification,Ut=dt,at=nt.ba[ht],Ft=new ei,ce(Ft,2,at.qa),at.index&&ue(Ft,1,at.index),at.label&&ue(Ft,3,at.label),at.displayName&&ue(Ft,4,at.displayName),at=Ft.l(),$t.call(It,Ut,at)}tt=tt.data;break t;default:tt={}}}switch(_=tt,O=L.stream,L.type){case"video":x.pushTexture2d(Object.assign({},_,{stream:O,timestamp:f}));break;case"detections":Q=_,Q.stream=O,Q.timestamp=f,x.pushDetectionList(Q);break;default:throw Error("Unknown input config type: '"+L.type+"'")}}return h.j.send(x),M(q,h.I,4);case 4:x.delete(),q.h=0}})};function au(r,u,h){var f,x,R,T,E,L,_,O,Q,q,G,tt,nt,dt;return Y(function(ht){switch(ht.h){case 1:if(!h)return ht.return(u);f={},x=0,R=c(Object.keys(h));for(T=R.next();!T.done;T=R.next())E=T.value,L=h[E],typeof L!=="string"&&L.type==="texture"&&u[L.stream]!==void 0&&++x;1<x&&(r.M=!1),_=c(Object.keys(h)),T=_.next();case 2:if(T.done){ht.h=4;break}if(O=T.value,Q=h[O],typeof Q==="string")return nt=f,dt=O,M(ht,ou(r,O,u[Q]),14);if(q=u[Q.stream],Q.type==="detection_list"){if(q){var It=q.getRectList();for(var $t=q.getLandmarksList(),Ut=q.getClassificationsList(),at=[],Ft=0;Ft<It.size();++Ft){var be=Yl(It.get(Ft)),uu=he(be,1),cu=he(be,2),hu=he(be,3),pu=he(be,4),du=he(be,5,0),zi=void 0;zi=zi===void 0?0:zi,be={la:{sa:uu,ta:cu,height:hu,width:pu,rotation:du,pa:Bi(te(be,6),zi)},ea:Ln($t.get(Ft)),ba:zl(Wl(Ut.get(Ft)))},at.push(be)}It=at}else It=[];f[O]=It,ht.h=7;break}if(Q.type==="proto_list"){if(q){It=Array(q.size());for($t=0;$t<q.size();$t++)It[$t]=q.get($t);q.delete()}else It=[];f[O]=It,ht.h=7;break}if(q===void 0){ht.h=3;break}if(Q.type==="float_list"){f[O]=q,ht.h=7;break}if(Q.type==="proto"){f[O]=q,ht.h=7;break}if(Q.type!=="texture")throw Error("Unknown output config type: '"+Q.type+"'");return G=r.v[O],G||(G=new In(r.i,r.K),r.v[O]=G),M(ht,fr(G,q,r.M),13);case 13:tt=ht.i,f[O]=tt;case 7:Q.transform&&f[O]&&(f[O]=Q.transform(f[O])),ht.h=3;break;case 14:nt[dt]=ht.i;case 3:T=_.next(),ht.h=2;break;case 4:return ht.return(f)}})}function ou(r,u,h){var f;return Y(function(x){return typeof h==="number"||h instanceof Uint8Array||h instanceof r.i.Uint8BlobList?x.return(h):h instanceof r.i.Texture2dDataOut?(f=r.v[u],f||(f=new In(r.i,r.K),r.v[u]=f),x.return(fr(f,h,r.M))):x.return(void 0)})}function lu(r,u){for(var h=u.name||"$",f=[].concat(p(u.wants)),x=new r.i.StringList,R=c(u.wants),T=R.next();!T.done;T=R.next())x.push_back(T.value);R=r.i.PacketListener.implement({onResults:function(E){for(var L={},_=0;_<u.wants.length;++_)L[f[_]]=E.get(_);var O=r.listeners[h];O&&(r.I=au(r,L,u.outs).then(function(Q){Q=O(Q);for(var q=0;q<u.wants.length;++q){var G=L[f[q]];typeof G==="object"&&G.hasOwnProperty&&G.hasOwnProperty("delete")&&G.delete()}Q&&(r.I=Q)}))}}),r.j.attachMultiListener(x,R),x.delete()}e.onResults=function(r,u){this.listeners[u||"$"]=r},rt("Solution",Fn),rt("OptionType",{BOOL:0,NUMBER:1,ua:2,0:"BOOL",1:"NUMBER",2:"STRING"});function Sr(r){switch(r===void 0&&(r=0),r){case 1:return"pose_landmark_full.tflite";case 2:return"pose_landmark_heavy.tflite";default:return"pose_landmark_lite.tflite"}}function vr(r){var u=this;r=r||{},this.h=new Fn({locateFile:r.locateFile,files:function(h){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:Sr(h.modelComplexity)}]},graph:{url:"pose_web.binarypb"},listeners:[{wants:["pose_landmarks","world_landmarks","segmentation_mask","image_transformed"],outs:{image:{type:"texture",stream:"image_transformed"}
18,poseLandmarks:{type:"proto",stream:"pose_landmarks",transform:Ln},poseWorldLandmarks:{type:"proto",stream:"world_landmarks",transform:Ln},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:typeof window!=="object"||window.navigator===void 0?!1:"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(h){var f,x,R;return Y(function(T){if(T.h==1)return f=Sr(h),x="third_party/mediapipe/modules/pose_landmark/"+f,M(T,Yi(u.h,f),2);return R=T.i,u.h.overrideFile(x,R),T.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"}}}})}e=vr.prototype,e.reset=function(){this.h.reset()},e.close=function(){return this.h.close(),Promise.resolve()},e.onResults=function(r){this.h.onResults(r)},e.initialize=function(){var r=this;return Y(function(u){return M(u,r.h.initialize(),0)})},e.send=function(r,u){var h=this;return Y(function(f){return M(f,h.h.send(r,u),0)})},e.setOptions=function(r){this.h.setOptions(r)},rt("Pose",vr),rt("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]]),rt("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}),rt("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}),rt("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}),rt("POSE_LANDMARKS_NEUTRAL",{NOSE:0}),rt("VERSION","0.5.1675469404")}).call(Mo)});var xi={};Et(xi,{BalanceController:()=>Rr,CaptureStatus:()=>Pr,programs:()=>Kn});var xr=`<div class="bottom-controller-container space-x-1"> 19 <div class="grow min-w-[1px]"></div> 20 <div id="leftSLBalanceData" class="min-w-[410px] grid grid-cols-12 gap-3 bg-white rounded-md shadow-sm p-4 items-center border-4 border-white"> 21 <h3 class="col-span-6 font-bold text-lg">Left Side</h3> 22 <div class="col-span-6 text-end"> 23 <button id="leftReset" class="hidden data-results-reset">
24 <span>Reset</span> 25 </button> 26 </div> 27 <div class="col-span-4 text-sm">Balance time</div> 28 <div class="col-span-2 text-sm value balanceTime">--</div> 29 <div class="col-span-4 text-sm">Avg. back sway</div> 30 <div class="col-span-2 text-sm value avgBackFlexion">--</div> 31 <div class="col-span-4 text-sm">Avg. pelvic tilt</div> 32 <div class="col-span-2 text-sm value avgPelvicDrop">--</div> 33 </div> 34 <div class="grow"></div> 35 <div id="rightSLBalanceData" class="min-w-[410px] grid grid-cols-12 gap-3 bg-white rounded-md shadow-sm p-4 items-center border-4 border-white"> 36 <h3 class="col-span-6 font-bold text-lg">Right Side</h3> 37 <div class="col-span-6 text-end"> 38 <button id="rightReset" class="hidden data-results-reset"> 39 <span>Reset</span> 40 </button> 41 </div> 42 <div class="col-span-4 text-sm">Balance time</div> 43 <div class="col-span-2 text-sm value balanceTime">--</div> 44 <div class="col-span-4 text-sm">Avg. back sway</div> 45 <div class="col-span-2 text-sm value avgBackFlexion">--</div> 46 <div class="col-span-4 text-sm">Avg. pelvic tilt</div> 47 <div class="col-span-2 text-sm value avgPelvicDrop">--</div> 48 </div> 49 <div class="grow min-w-[1px]"></div> 50</div> 51`;var Tr=`<div class="top-controller-container"> 52 <div id="slBalanceCaptureContainer" class="capture-bar w-1/2"> 53 <button id="slBalanceCapture" class="capture-bar-cta bg-green-400 hover:bg-green-500 text-green-900"> 54 <span>Start</span> 55 </button> 56 <button id="slBalanceReset" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 57 <span>Reset Both</span> 58 </button> 59 <button id="slBalanceStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 60 <span>Stop</span> 61 </button> 62 <div class="min-w-6"></div> 63 <div class="flex flex-col"> 64 <span id="slBalanceCaptureTypeHeader" class="text-xs mb-[-4px] pt-1">Capture Type</span> 65 <span id="slBalanceCaptureTypeSubheader" class="font-bold text-lg">Auto-detection</span> 66 </div> 67 <div class="grow"></div> 68 </div> 69</div> 70`;var Pr;((a)=>{a[a.NOTSTARTED=0]="NOTSTARTED";a[a.WAITING=1]="WAITING";a[a.BALANCING=2]="BALANCING";a[a.CAPTURED=3]="CAPTURED"})(Pr||={});class Rr{vision;threshold=0.95;timer=null;record=new Mn;uiState=ft({currentSide:0,elapsedTime:0,captureStatus:0,patientSide:null},()=>{this.updateState()});constructor(e){this.vision=e,e.getRecord((t)=>{this.record=t,this.updateState()})}showControls(e,t){$(e).html(Tr),$(t).html(xr),k("#slBalanceCapture",()=>{this.uiState.captureStatus=1}),k("#slBalanceStop",()=>{this.reset()}),k("#slBalanceReset",()=>{this.reset()}),k("#leftReset",()=>{this.resetLeftSide()}),k("#rightReset",()=>{this.resetRightSide()})}async process(e,t){t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels);let{leftFootUp:i,rightFootUp:s}=this.getFootPositions(e);await this.processCapture(e,i,s)}getFootPositions(e){let t=e.leftFootHeight??0,i=e.rightFootHeight??0,s=i<t*this.threshold,a=t<i*this.threshold;return{leftFootHeight:t,rightFootHeight:i,leftFootUp:s,rightFootUp:a}}async processCapture(e,t,i){let s=this.uiState.captureStatus===1,a=this.uiState.captureStatus===2,o=this.uiState.currentSide===2,l=this.uiState.currentSide===1,c=null;if(e.backLateralFlexion&&e.pelvicDrop)c={timestamp:Date.now(),backLateralFlex:e.backLateralFlexion,pelvicDrop:e.pelvicDrop};if(s&&!o&&i)this.uiState.currentSide=2,this.capture();else if(s&&!l&&t)this.uiState.currentSide=1,this.capture();if(a&&o&&this.record.rightData&&c)this.record.rightData.push(c);if(a&&l&&this.record.leftData&&c)this.record.leftData.push(c);if(a&&!i&&!t&&(l||o))await this.stopCapture()}capture(){if(this.stopTimer(),this.uiState.currentSide===2)this.record.rightBalanceTime=null,this.record.rightData=[];else if(this.uiState.currentSide===1)this.record.leftBalanceTime=null,this.record.leftData=[];let e=Date.now();this.uiState.captureStatus=2,this.timer=setInterval(()=>{let t=Date.now()-e;this.uiState.elapsedTime=t/1000},50)}async reset(){this.record=new Mn,await this.vision.clearRecord(),this.uiState.captureStatus=0}async resetLeftSide(){this.record.leftData=null,this.record.leftBalanceTime=null,this.record.updateMaxAvg(),await this.vision.setRecord(this.record),this.uiState.captureStatus=0}async resetRightSide(){this.record.rightData=null,this.record.rightBalanceTime=null,this.record.updateMaxAvg(),await this.vision.setRecord(this.record),this.uiState.captureStatus=0}stopTimer(){if(this.timer)clearInterval(this.timer),this.timer=null}async stopCapture(){if(this.stopTimer(),this.uiState.currentSide===1)this.record.leftBalanceTime=this.uiState.elapsedTime;else if(this.uiState.currentSide===2)this.record.rightBalanceTime=this.uiState.elapsedTime;this.record.updateMaxAvg(),await this.vision.setRecord(this.record);let e=!!this.record.leftBalanceTime,t=!!this.record.rightBalanceTime;this.uiState.captureStatus=e&&t?3:0,this.uiState.currentSide=0,this.uiState.patientSide=null}updateState(){U("#slBalanceCapture",this.uiState.captureStatus!==0),U("#slBalanceStop",this.uiState.captureStatus!==2&&this.uiState.captureStatus!==1),U("#slBalanceReset",this.uiState.captureStatus!==3),U("#leftReset",!this.record.leftData),U("#rightReset",!this.record.rightData),vt("#leftSLBalanceData","border-blue-500","border-white",this.uiState.currentSide===1),vt("#rightSLBalanceData","border-blue-500","border-white",this.uiState.currentSide===2);let e=(l,c)=>{let p="",m=0;if(c!==null)if(c>=60)m=c/60,p="min";else m=c,p="sec.";$(l).text(c!==null?`${m.toFixed(2)} ${p}`:"--")},t=(l,c)=>{$(l).text(c?`${c.toFixed(1)}°`:"--")};switch(this.uiState.captureStatus){case 0:$("#slBalanceCaptureTypeHeader").text("Capture Type"),$("#slBalanceCaptureTypeSubheader").text("Auto-detection");break;case 1:$("#slBalanceCaptureTypeHeader").text("Capture Status"),$("#slBalanceCaptureTypeSubheader").text("Waiting for balance");break;case 2:$("#slBalanceCaptureTypeHeader").text("Balancing..."),e("#slBalanceCaptureTypeSubheader",this.uiState.elapsedTime);break;case 3:$("#slBalanceCaptureTypeHeader").text("Captured");break}let i=null,s=null;if(this.record.leftBalanceTime)i=this.record.getAverages("left","pelvicDrop"),s=this.record.getAverages("left","backLateralFlex");let a=null,o=null;if(this.record.rightBalanceTime)a=this.record.getAverages("right","pelvicDrop"),o=this.record.getAverages("right","backLateralFlex");e("#leftSLBalanceData .balanceTime",this.record.leftBalanceTime),t("#leftSLBalanceData .avgBackFlexion",s?.avg),t("#leftSLBalanceData .avgPelvicDrop",i?.avg),e("#rightSLBalanceData .balanceTime",this.record.rightBalanceTime),t("#rightSLBalanceData .avgBackFlexion",o?.avg),t("#rightSLBalanceData .avgPelvicDrop",a?.avg)}patientSetup(e,t){this.uiState.patientSide=e??null,this.uiState.captureStatus=1}async patientProcess(e,t){t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels);
70let{leftFootUp:i,rightFootUp:s}=this.getFootPositions(e);if(this.uiState.patientSide){if(i&&this.uiState.patientSide==="right"||s&&this.uiState.patientSide==="left")return}await this.processCapture(e,i,s)}patientPause(){this.record.leftData=null,this.record.leftBalanceTime=null,this.record.rightData=null,this.record.rightBalanceTime=null,this.record.updateMaxAvg(),this.stopTimer()}patientData(e){if(e==="step")if(this.uiState.captureStatus!==2)return 0;else return 1;else if(e==="timer")return this.uiState.elapsedTime;else return 0}}var Kn={};Et(Kn,{SingleLegBalance:()=>Qr});var n={};Et(n,{calculateAngle:()=>Pu,calculateSlope:()=>Ru,determinePoseDirection:()=>Dr,endPointForSlopeAndDist:()=>Du,getArcMidpoint:()=>wu,getJointPosition:()=>Me,getMiddlePoint:()=>bu,makeArcPath:()=>Au,makeLinePath:()=>Lu,pointDistance:()=>yu,resolveProgramDirection:()=>Eu,runWithProgramDirection:()=>Cn,showSkeleton:()=>Iu});var br=[11,12,23,24],gu={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,mouth_left:9,mouth_right: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};function Su(e,t,i){let s=Array(33).fill(0).map(()=>[NaN,NaN,NaN,0]);for(let a of e){let o=gu[a.name??""]??-1;if(o<0)continue;let l=a.x/t,c=a.y/i,p=a.z??0,m=a.score??0;s[o]=[l,c,p,m]}return s}function vu(e){let t=e.map((d)=>[d[0],d[1]]),i=e.map((d)=>[d[0],d[1],d[2]]),s=(d)=>Number.isFinite(d[0])&&Number.isFinite(d[1]),a=(d,S)=>[(d[0]+S[0])/2,(d[1]+S[1])/2],o;if(s(t[23])&&s(t[24]))o=a(t[23],t[24]);else if(s(t[11])&&s(t[12]))o=a(t[11],t[12]);else{let d=br.map((v)=>t[v]).filter(s),S=d.reduce((v,P)=>[v[0]+P[0],v[1]+P[1]],[0,0]);o=[S[0]/d.length,S[1]/d.length]}let l=(d,S)=>{let v=i[d],P=i[S];return Math.hypot(v[0]-P[0],v[1]-P[1],v[2]-P[2])},c=[];if(s(i[11])&&s(i[23]))c.push(l(11,23));if(s(i[12])&&s(i[24]))c.push(l(12,24));if([11,12,23,24].every((d)=>s(i[d]))){let d=[(i[11][0]+i[12][0])/2,(i[11][1]+i[12][1])/2,(i[11][2]+i[12][2])/2],S=[(i[23][0]+i[24][0])/2,(i[23][1]+i[24][1])/2,(i[23][2]+i[24][2])/2];c.push(Math.hypot(d[0]-S[0],d[1]-S[1],d[2]-S[2]))}if(!c.length){let d=br.map((S)=>t[S][1]).filter(Number.isFinite);c.push(Math.max(...d)-Math.min(...d))}let m=c.sort((d,S)=>d-S)[Math.floor(c.length/2)]||0.001;if(!Number.isFinite(m)||m<=0.000001)m=0.001;let g=[];for(let d=0;d<33;d++){let S=(i[d][0]-o[0])/m,v=(i[d][1]-o[1])/m,P=i[d][2]/m;g.push(S,v,P)}return new Float32Array(g)}function xu(e,t,i){let s=new Float32Array(e.length);for(let a=0;a<e.length;a++){let o=i[a]!==0?i[a]:1;s[a]=(e[a]-t[a])/o}return s}function Tu(e){let t=-1/0;for(let a of e)if(a>t)t=a;let i=e.map((a)=>Math.exp(a-t)),s=i.reduce((a,o)=>a+o,0);return new Float32Array(i.map((a)=>a/s))}class yr{W;b;mean;scale;classes;constructor(e){this.classes=e.classes,this.W=new Float32Array(e.coef.flat()),this.b=new Float32Array(e.intercept),this.mean=e.scaler_mean,this.scale=e.scaler_scale}predictProba(e,t,i){let s=Su(e,t,i),a=vu(s),o=xu(a,this.mean,this.scale),l=o.length,c=this.b.length,p=new Float32Array(c);for(let m=0;m<c;m++){let g=this.b[m],d=m*l;for(let S=0;S<l;S++)g+=this.W[d+S]*o[S];p[m]=g}return Tu(p)}}class qi{window;enter;exit;win=[];idx=0;constructor(e=7,t=0.6,i=0.5){this.window=e;this.enter=t;this.exit=i}update(e,t,i){if(this.win.length<this.window)this.win.push(e);else this.win[this.idx=(this.idx+1)%this.window]=e;let s=new Float32Array(e.length);for(let c of this.win)for(let p=0;p<e.length;p++)s[p]+=c[p];for(let c=0;c<e.length;c++)s[c]/=this.win.length;let a=0;for(let c=1;c<s.length;c++)if(s[c]>s[a])a=c;let o=s[a];return{label:o>=this.enter?t[a]:i&&o<this.exit?i:"unknown",conf:o,avg:s}}}async function _n(e){let i=await(await fetch(e)).json();return new yr(i)}class Si{static instance=null;videoWidth;videoHeight;isLoading=!1;loadPromise=null;directionHead=null;directionSmoother=new qi(7,0.6,0.5);lastDirectionLabel=null;constructor(e,t){this.videoWidth=e,this.videoHeight=t}static getInstance(e,t){if(!this.instance){if(!e||!t)throw Error("Width and height required for first initialization");this.instance=new Si(e,t)}return this.instance}async ensureLoaded(){if(this.directionHead)return;if(this.isLoading&&this.loadPromise)return this.loadPromise;this.isLoading=!0,this.loadPromise=this.loadModel(),await this.loadPromise,this.isLoading=!1}async loadModel(){try{this.directionHead=await _n("assets/models/direction_model_web_3.json")}catch(e){throw console.error("Failed to load pose direction model:",e),e}}classifyPoseDirection(e){if(!this.directionHead||!e.length)return"unknown";let t=this.directionHead.predictProba(e,this.videoWidth,this.videoHeight),i=this.directionHead.classes,s=this.directionSmoother.update(t,i,this.lastDirectionLabel),a=s.label!=="unknown"?s.label:this.lastDirectionLabel;if(a&&a!=="unknown")this.lastDirectionLabel=a;if(a==="left")return"leftSide";else if(a==="right")return"rightSide";else if(a==="front")return"front";else return"unknown"}isModelLoaded(){return this.directionHead!==null}}var vi=null;function Me(e,t){let i=e.find((s)=>s.name?.toLowerCase()===t.toLowerCase());if(!i)return{x:0,y:0,z:0};return{x:i.x,y:i.y,z:i.z}}function Pu(e,t,i,s=!1){let a=(Math.atan2(t.y-e.y,t.x-e.x)-Math.atan2(i.y-e.y,i.x-e.x))*(180/Math.PI);if(a<0)a+=360;return s?360-a:a}function Ru(e,t){return Math.atan2(e.y-t.y,e.x-t.x)*(180/Math.PI)}function bu(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function yu(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Du(e,t,i){let s=i*(Math.PI/180);return{x:Math.cos(s)*t+e.x,y:Math.sin(s)*t+e.y}}function Dr(e){if(vi)return vi;try{let t=Si.getInstance();if(t.isModelLoaded())return t.classifyPoseDirection(e)}catch(t){console.log("Error determining position",t)}return"unknown"}function Eu(e){return e.direction??Dr(e.keypoints)}function Cn(e,t){let i=vi;vi=e;try{return t()}finally{vi=i}}function wu(e,t,i,s,a){let o=s-i;if(a&&o>0)o-=360;else if(!a&&o<0)o+=360;let c=(i+o/2)*Math.PI/180,p=e.x+t*Math.cos(c),m=e.y+t*Math.sin(c);return{x:p,y:m}}function Au(e,t,i,s,a,o,l,c,p){return{midJoint:e,joint1:t,joint2:i,radius:s,startAngle:a,endAngle:o,anticlockwise:l,color:p,side:c}}function Lu(e,t,i,s,a){if(!s)return{from:e,to:t,color:a,side:i};let o=Math.atan2(t.y-e.y,t.x-e.x),l={x:e.x-Math.cos(o)*s,y:e.y-Math.sin(o)*s},c={x:t.x+Math.cos(o)*s,y:t.y+Math.sin(o)*s};return{from:l,to:c,color:a,side:i}}function Iu(e){let t=[],i={head:"yellow",torso:"orange",arms:"blue",hands:"purple",legs:"green",feet:"red"};return["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"].forEach((m)=>{let g=Me(e,m);if(g.x!==0||g.y!==0){let d=m.includes("left")?"left":m.includes("right")?"right":void 0;t.push({...g,side:d,color:i.head})}}),[{name:"left_shoulder",side:"left"},{name:"right_shoulder",side:"right"},{name:"left_hip",side:"left"},{name:"right_hip",side:"right"}
70].forEach(({name:m,side:g})=>{let d=Me(e,m);if(d.x!==0||d.y!==0)t.push({...d,side:g,color:i.torso})}),[{name:"left_elbow",side:"left"},{name:"right_elbow",side:"right"},{name:"left_wrist",side:"left"},{name:"right_wrist",side:"right"}].forEach(({name:m,side:g})=>{let d=Me(e,m);if(d.x!==0||d.y!==0)t.push({...d,side:g,color:i.arms})}),[{name:"left_pinky",side:"left"},{name:"right_pinky",side:"right"},{name:"left_index",side:"left"},{name:"right_index",side:"right"},{name:"left_thumb",side:"left"},{name:"right_thumb",side:"right"}].forEach(({name:m,side:g})=>{let d=Me(e,m);if(d.x!==0||d.y!==0)t.push({...d,side:g,color:i.hands})}),[{name:"left_knee",side:"left"},{name:"right_knee",side:"right"},{name:"left_ankle",side:"left"},{name:"right_ankle",side:"right"}].forEach(({name:m,side:g})=>{let d=Me(e,m);if(d.x!==0||d.y!==0)t.push({...d,side:g,color:i.legs})}),[{name:"left_heel",side:"left"},{name:"right_heel",side:"right"},{name:"left_foot_index",side:"left"},{name:"right_foot_index",side:"right"}].forEach(({name:m,side:g})=>{let d=Me(e,m);if(d.x!==0||d.y!==0)t.push({...d,side:g,color:i.feet})}),t}var w={};Et(w,{EPSILON_3D:()=>Fu,add:()=>_u,average:()=>ku,clampToUnitRange:()=>Ku,cross:()=>Ou,dot:()=>Hu,getPointByName:()=>Mu,magnitude:()=>wr,normalize:()=>Nu,normalizeName:()=>Hn,scale:()=>Er,subtract:()=>Cu});var Fu=0.000001,Hn=(e)=>e.trim().toLowerCase(),Mu=(e,t)=>{let i=Hn(t),s=e.find((a)=>Hn(a.name)===i);if(!s)return null;return{x:s.x,y:s.y,z:s.z}},_u=(e,t)=>({x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}),Cu=(e,t)=>({x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}),Er=(e,t)=>
70({x:e.x*t,y:e.y*t,z:e.z*t}),Hu=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,Ou=(e,t)=>({x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}),wr=(e)=>Math.hypot(e.x,e.y,e.z),Nu=(e,t=0.000001)=>{let i=wr(e);if(i<=t)return null;return Er(e,1/i)},ku=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2,z:(e.z+t.z)/2}),Ku=(e)=>Math.min(1,Math.max(-1,e));var On={};Et(On,{AnkleDorsiFlexion:()=>jt,AnklePlantarFlexion:()=>Ar,BackExtension:()=>Lr,BackFlexion:()=>Ir,BackLateralFlexion:()=>ii,ElbowExtension:()=>Fr,ElbowFlexion:()=>Xi,HipAbduction:()=>Mr,HipAdduction:()=>_r,HipExtension:()=>Cr,HipExternalRotation:()=>Nr,HipFlexion:()=>Or,HipInternalRotation:()=>Hr,KneeExtension:()=>kr,KneeFlexion:()=>Kr,NeckExtension:()=>Jr,NeckFlexion:()=>Gr,NeckLateralFlexion:()=>Ur,ShoulderAbduction:()=>Zi,ShoulderAdduction:()=>Vr,ShoulderExtension:()=>Wr,ShoulderExternalRotation:()=>$r,ShoulderFlexion:()=>jr,ShoulderInternalRotation:()=>Yr,StraightLegRaise:()=>zr,ThoracicRotation:()=>qr});class jt{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_knee"),s=n.getJointPosition(e,"left_heel"),a=n.getJointPosition(e,"left_foot_index"),o=n.getJointPosition(e,"right_knee"),l=n.getJointPosition(e,"right_heel"),c=n.getJointPosition(e,"right_foot_index"),p=n.pointDistance(s,a),m=n.calculateSlope(i,s),g=n.calculateSlope(a,s),d=n.endPointForSlopeAndDist(s,p,m),S=n.pointDistance(l,c),v=n.calculateSlope(o,l),P=n.calculateSlope(c,l),b=n.endPointForSlopeAndDist(l,S,v),D=90-n.calculateAngle(s,i,a,!1),A=90-n.calculateAngle(l,c,o,!1);if(t.isAligned&&t.direction==="leftSide"){if(D>=0&&D<=200)t.leftData=D,t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...a,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...d,side:"left"}),t.paths.push(n.makeArcPath(s,a,d,p,m,g,!0,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(A>=0&&A<=200)t.rightData=A,t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...c,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...b,side:"right"}),t.paths.push(n.makeArcPath(l,c,b,S,v,P,!1,"right"))}return t}}class Ar{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_knee"),s=n.getJointPosition(e,"left_heel"),a=n.getJointPosition(e,"left_foot_index"),o=n.getJointPosition(e,"right_knee"),l=n.getJointPosition(e,"right_heel"),c=n.getJointPosition(e,"right_foot_index"),p=n.pointDistance(s,a),m=n.calculateSlope(i,s),g=n.calculateSlope(a,s),d=n.endPointForSlopeAndDist(s,p,m),S=n.pointDistance(l,c),v=n.calculateSlope(o,l),P=n.calculateSlope(c,l),b=n.endPointForSlopeAndDist(l,S,v),D=n.calculateAngle(s,i,a,!1)-90,A=n.calculateAngle(l,c,o,!1)-90;if(t.isAligned&&t.direction==="leftSide"){if(D>=0&&D<=200)t.leftData=D,t.labels.push({position:n.getArcMidpoint(s,p,m,g,!0),value:t.leftData,side:"left",offset:{x:-100,y:0}}),t.points.push({...a,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...d,side:"left"}),t.paths.push(n.makeArcPath(s,a,d,p,m,g,!0,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(A>=0&&A<=200)t.rightData=A,t.labels.push({position:n.getArcMidpoint(l,S,v,P,!1),value:t.rightData,side:"right",offset:{x:100,y:0}}),t.points.push({...c,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...b,side:"right"}),t.paths.push(n.makeArcPath(l,c,b,S,v,P,!1,"right"))}return t}}class Lr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_shoulder"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"right_hip"),l=n.getJointPosition(e,"right_shoulder"),c=n.getJointPosition(e,"right_knee"),p=n.getMiddlePoint(a,c),m=n.getMiddlePoint(i,o),g=n.calculateSlope(m,p),d=n.pointDistance(i,s),S=n.endPointForSlopeAndDist(i,d,g),v=n.calculateSlope(s,i),P=n.calculateSlope(S,i),b=n.pointDistance(o,l),D=n.endPointForSlopeAndDist(o,b,g),A=n.calculateSlope(l,o),I=n.calculateSlope(D,o),F=n.calculateAngle(i,s,S,!1),M=n.calculateAngle(o,D,l,!1);if(t.isAligned&&t.direction==="leftSide"){if(F>=-20&&F<=220)t.leftData=F,t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...i,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(i,S,s,d,v,P,!0,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(M>=-20&&M<=220)t.rightData=M,t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...o,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...D,side:"right"}),t.paths.push(n.makeArcPath(o,D,l,b,A,I,!1,"right"))}return t}}class Ir{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_shoulder"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"right_hip"),l=n.getJointPosition(e,"right_shoulder"),c=n.getJointPosition(e,"right_knee"),p=n.getMiddlePoint(a,c),m=n.getMiddlePoint(i,o),g=n.calculateSlope(m,p),d=n.pointDistance(i,s),S=n.endPointForSlopeAndDist(i,d,g),v=n.calculateSlope(s,i),P=n.calculateSlope(S,i),b=n.pointDistance(o,l),D=n.endPointForSlopeAndDist(o,b,g),A=n.calculateSlope(l,o),I=n.calculateSlope(D,o),F=n.calculateAngle(i,s,S,!0),M=n.calculateAngle(o,D,l,!0);if(t.isAligned&&t.direction==="leftSide"){if(F>=-20&&F<=220)t.leftData=F,t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:-100,y:0}}),t.points.push({...i,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(i,S,s,d,v,P,!1,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(M>=-20&&M<=220)t.rightData=M,t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:100,y:0}}),t.points.push({...o,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...D,side:"right"}),t.paths.push(n.makeArcPath(o,D,l,b,A,I,!0,"right"))}return t}}class ii{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_hip"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_hip"),c=n.getJointPosition(e,"right_knee"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(s,l),g=n.getMiddlePoint(a,c),d=n.calculateSlope(m,g),S=n.pointDistance(m,p),v=n.endPointForSlopeAndDist(m,S,d),P=n.calculateSlope(v,m),b=n.calculateSlope(p,m),D=n.calculateAngle(m,v,p,!0);if(t.isAligned)if(t.points.push(m),t.points.push(p),t.points.push(v),D>0&&D<=100)t.leftData=D,t.labels.push({position:p,value:t.leftData,side:"left",offset:{x:150,y:0}}),t.paths.push(n.makeArcPath(m,p,v,S,P,b,!1));else t.rightData=360-D,t.labels.push({position:p,value:t.rightData,side:"right",offset:{x:-150,y:0}}),t.paths.push(n.makeArcPath(m,p,v,S,P,b,!0));return t}}class Fr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_elbow"),a=n.getJointPosition(e,"left_wrist"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_elbow"),c=n.getJointPosition(e,"right_wrist"),p=Math.min(n.pointDistance(i,s),n.pointDistance(s,a)),m=n.calculateSlope(i,s),g=n.calculateSlope(a,s),d=n.endPointForSlopeAndDist(s,p,m),S=n.endPointForSlopeAndDist(s,p,g),v=180-n.calculateAngle(s,a,i,!0),P=Math.min(n.pointDistance(o,l),n.pointDistance(l,c)),b=n.calculateSlope(o,l),D=n.calculateSlope(c,l),A=n.endPointForSlopeAndDist(l,P,b),I=n.endPointForSlopeAndDist(l,P,D),F=180-n.calculateAngle(l,o,c,!0);if(t.isAligned&&t.direction==="leftSide"){if(v>=-20&&v<=220)t.leftData=v,t.labels.push({position:n.getArcMidpoint(s,p,m,g,!0),value:t.leftData,side:"left",offset:{x:-100,y:0}}),t.points.push({...d,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(s,S,d,p,m,g,!0,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(F>=-20&&F<=220)t.rightData=F,t.labels.push({position:n.getArcMidpoint(l,P,b,D,!1),value:t.rightData,side:"right",offset:{x:100,y:0}}),t.points.push({...A,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...I,side:"right"}),t.paths.push(n.makeArcPath(l,I,A,P,b,D,!1,"right"))}return t}}class Xi{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_elbow"),a=n.getJointPosition(e,"left_wrist"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_elbow"),c=n.getJointPosition(e,"right_wrist"),p=Math.min(n.pointDistance(i,s),n.pointDistance(s,a)),m=n.calculateSlope(i,s),g=n.calculateSlope(a,s),d=n.endPointForSlopeAndDist(s,p,m),S=n.endPointForSlopeAndDist(s,p,g),v=180-n.calculateAngle(s,a,i,!0),P=Math.min(n.pointDistance(o,l),n.pointDistance(l,c)),b=n.calculateSlope(o,l),D=n.calculateSlope(c,l),A=n.endPointForSlopeAndDist(l,P,b),I=n.endPointForSlopeAndDist(l,P,D),F=180-n.calculateAngle(l,o,c,!0);if(t.isAligned&&t.direction==="leftSide"){if(v>=-20&&v<=220)t.leftData=v,t.labels.push({position:n.getArcMidpoint(s,p,m,g,!0),value:t.leftData,side:"left",offset:{x:-100,y:0}}),t.points.push({...d,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(s,S,d,p,m,g,!0,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(F>=-20&&F<=220)t.rightData=F,t.labels.push({position:n.getArcMidpoint(l,P,b,D,!1),value:t.rightData,side:"right",offset:{x:100,y:0}}),t.points.push({...A,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...I,side:"right"}),t.paths.push(n.makeArcPath(l,I,A,P,b,D,!1,"right"))}return t}}class Mr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_hip"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_hip"),c=n.getJointPosition(e,"right_knee"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(s,l),g=n.calculateSlope(m,p),d=n.pointDistance(s,a),S=n.endPointForSlopeAndDist(s,d,g),v=n.calculateSlope(S,s),P=n.calculateSlope(a,s),b=n.pointDistance(l,c),D=n.endPointForSlopeAndDist(l,b,g),A=n.calculateSlope(D,l),I=n.calculateSlope(c,l),F=n.calculateAngle(s,S,a,!1),M=n.calculateAngle(l,c,D,!1);if(t.isAligned){if(F>=0&&F<=200)t.leftData=F,t.labels.push({position:a,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...s,side:"left"}),t.points.push({...a,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(s,a,S,d,v,P,!0,"left"));if(M>=0&&M<=200)t.rightData=M,t.labels.push({position:c,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...l,side:"right"}),t.points.push({...c,side:"right"}),t.points.push({...D,side:"right"}),t.paths.push(n.makeArcPath(l,c,D,b,A,I,!1,"right"))}return t}}class _r{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_hip"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_hip"),c=n.getJointPosition(e,"right_knee"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(s,l),g=n.calculateSlope(m,p),d=n.pointDistance(s,a),S=n.endPointForSlopeAndDist(s,d,g),v=n.calculateSlope(S,s),P=n.calculateSlope(a,s),b=n.pointDistance(l,c),D=n.endPointForSlopeAndDist(l,b,g),A=n.calculateSlope(D,l),I=n.calculateSlope(c,l),F=n.calculateAngle(s,S,a,!0),M=n.calculateAngle(l,c,D,!0);if(t.isAligned){if(F>=0&&F<=200)t.leftData=F,t.labels.push({position:S,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...s,side:"left"}),t.points.push({...a,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(s,a,S,d,v,P,!1,"left"));if(M>=0&&M<=200)t.rightData=M,t.labels.push({position:D,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...l,side:"right"}),t.points.push({...c,side:"right"}),t.points.push({...D,side:"right"}),t.paths.push(n.makeArcPath(l,c,D,b,A,I,!0,"right"))}return t}}class Cr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_hip"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_hip"),c=n.getJointPosition(e,"right_knee"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(s,l),g=n.calculateSlope(m,p),d=n.pointDistance(s,a),S=n.endPointForSlopeAndDist(s,d,g),v=n.calculateSlope(a,s),P=n.calculateSlope(S,s),b=n.pointDistance(l,c),D=n.endPointForSlopeAndDist(l,b,g),A=n.calculateSlope(c,l),I=n.calculateSlope(D,l),F=n.calculateAngle(s,a,S,!0),M=n.calculateAngle(l,D,c,!0);if(t.isAligned&&t.direction==="leftSide"){if(F>=-10&&F<=200)t.leftData=F,t.labels.push({position:n.getArcMidpoint(s,d,v,P,!1),value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...s,side:"left"}),t.points.push({...a,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(s,S,a,d,v,P,!1,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(M>=-10&&M<=200)t.rightData=M,t.labels.push({position:n.getArcMidpoint(l,b,A,I,!0),value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...l,side:"right"}),t.points.push({...c,side:"right"}),t.points.push({...D,side:"right"}),t.paths.push(n.makeArcPath(l,D,c,b,A,I,!0,"right"))}return t}}class Hr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_knee"),s=n.getJointPosition(e,"left_ankle"),a=n.getJointPosition(e,"right_knee"),o=n.getJointPosition(e,"right_ankle"),l=n.pointDistance(i,s),c={x:i.x,y:i.y+l},p=n.calculateSlope(s,i),m=n.calculateSlope(c,i),g=n.pointDistance(a,o),d={x:a.x,y:a.y+g},S=n.calculateSlope(o,a),v=n.calculateSlope(d,a),P=n.calculateAngle(i,c,s,!1),b=n.calculateAngle(a,o,d,!1);if(P<5||P>200)P=0;if(b<5||b>200)b=0;
70if(t.isAligned){if(P>0&&P>b)t.leftData=P,t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...i,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...c,side:"left"}),t.paths.push(n.makeArcPath(i,c,s,l,p,m,!1,"left"));if(b>0&&b>P)t.rightData=b,t.labels.push({position:o,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...a,side:"right"}),t.points.push({...o,side:"right"}),t.points.push({...d,side:"right"}),t.paths.push(n.makeArcPath(a,d,o,g,S,v,!0,"right"))}return t}}class Or{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_hip"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_hip"),c=n.getJointPosition(e,"right_knee"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(s,l),g=n.calculateSlope(m,p),d=n.pointDistance(s,a),S=n.endPointForSlopeAndDist(s,d,g),v=n.calculateSlope(a,s),P=n.calculateSlope(S,s),b=n.pointDistance(l,c),D=n.endPointForSlopeAndDist(l,b,g),A=n.calculateSlope(c,l),I=n.calculateSlope(D,l),F=n.calculateAngle(s,a,S,!1),M=n.calculateAngle(l,D,c,!1);if(t.isAligned&&t.direction==="leftSide"){if(F>=-10&&F<=200)t.leftData=F,t.labels.push({position:n.getArcMidpoint(s,d,v,P,!0),value:t.leftData,side:"left",offset:{x:-100,y:0}}),t.points.push({...s,side:"left"}),t.points.push({...a,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(s,S,a,d,v,P,!0,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(M>=-10&&M<=200)t.rightData=M,t.labels.push({position:n.getArcMidpoint(l,b,A,I,!1),value:t.rightData,side:"right",offset:{x:100,y:0}}),t.points.push({...l,side:"right"}),t.points.push({...c,side:"right"}),t.points.push({...D,side:"right"}),t.paths.push(n.makeArcPath(l,D,c,b,A,I,!1,"right"))}return t}}class Nr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_knee"),s=n.getJointPosition(e,"left_ankle"),a=n.getJointPosition(e,"right_knee"),o=n.getJointPosition(e,"right_ankle"),l=n.pointDistance(i,s),c={x:i.x,y:i.y+l},p=n.calculateSlope(s,i),m=n.calculateSlope(c,i),g=n.pointDistance(a,o),d={x:a.x,y:a.y+g},S=n.calculateSlope(o,a),v=n.calculateSlope(d,a),P=n.calculateAngle(i,c,s,!0),b=n.calculateAngle(a,o,d,!0);if(P<5||P>200)P=0;if(b<5||b>200)b=0;if(t.isAligned){if(P>0&&P>b)t.leftData=P,t.labels.push({position:c,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...i,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...c,side:"left"}),t.paths.push(n.makeArcPath(i,c,s,l,p,m,!0,"left"));if(b>0&&b>P)t.rightData=b,t.labels.push({position:d,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...a,side:"right"}),t.points.push({...o,side:"right"}),t.points.push({...d,side:"right"}),t.paths.push(n.makeArcPath(a,d,o,g,S,v,!1,"right"))}return t}}class kr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_knee"),a=n.getJointPosition(e,"left_ankle"),o=n.getJointPosition(e,"right_hip"),l=n.getJointPosition(e,"right_knee"),c=n.getJointPosition(e,"right_ankle"),p=Math.min(n.pointDistance(i,s),n.pointDistance(s,a)),m=n.calculateSlope(i,s),g=n.calculateSlope(a,s),d=n.endPointForSlopeAndDist(s,p,m),S=n.endPointForSlopeAndDist(s,p,g),v=n.calculateAngle(s,i,a,!1)-180,P=Math.min(n.pointDistance(o,l),n.pointDistance(l,c)),b=n.calculateSlope(o,l),D=n.calculateSlope(c,l),A=n.endPointForSlopeAndDist(l,P,b),I=n.endPointForSlopeAndDist(l,P,D),F=n.calculateAngle(l,o,c,!0)-180;if(t.isAligned&&t.direction==="leftSide"){if(v>=-20&&v<=220)t.leftData=v,t.labels.push({position:n.getArcMidpoint(s,p,m,g,!1),value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...d,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(s,S,d,p,m,g,!1,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(F>=-20&&F<=220)t.rightData=F,t.labels.push({position:n.getArcMidpoint(l,P,b,D,!0),value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...A,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...I,side:"right"}),t.paths.push(n.makeArcPath(l,I,A,P,b,D,!0,"right"))}return t}}class Kr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_knee"),a=n.getJointPosition(e,"left_ankle"),o=n.getJointPosition(e,"right_hip"),l=n.getJointPosition(e,"right_knee"),c=n.getJointPosition(e,"right_ankle"),p=Math.min(n.pointDistance(i,s),n.pointDistance(s,a)),m=n.calculateSlope(i,s),g=n.calculateSlope(a,s),d=n.endPointForSlopeAndDist(s,p,m),S=n.endPointForSlopeAndDist(s,p,g),v=180-n.calculateAngle(s,i,a,!0),P=Math.min(n.pointDistance(o,l),n.pointDistance(l,c)),b=n.calculateSlope(o,l),D=n.calculateSlope(c,l),A=n.endPointForSlopeAndDist(l,P,b),I=n.endPointForSlopeAndDist(l,P,D),F=180-n.calculateAngle(l,o,c,!1);if(t.isAligned&&t.direction==="leftSide"){if(v>=-10&&v<=200)t.leftData=v,t.labels.push({position:n.getArcMidpoint(s,p,m,g,!1),value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...d,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(s,S,d,p,m,g,!1,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(F>=-10&&F<=200)t.rightData=F,t.labels.push({position:n.getArcMidpoint(l,P,b,D,!0),value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...A,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...I,side:"right"}),t.paths.push(n.makeArcPath(l,I,A,P,b,D,!0,"right"))}return t}}class Jr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"nose"),s=n.getJointPosition(e,"left_eye_outer"),a=n.getJointPosition(e,"left_ear"),o=n.getMiddlePoint(i,s),l=n.getJointPosition(e,"right_eye_outer"),c=n.getJointPosition(e,"right_ear"),p=n.getMiddlePoint(i,l),m=n.pointDistance(a,o),g={x:a.x,y:a.y-m},d=n.calculateSlope(o,a),S=n.calculateSlope(g,a),v=n.pointDistance(c,p),P={x:c.x,y:c.y-v},b=n.calculateSlope(p,c),D=n.calculateSlope(P,c),A=90-n.calculateAngle(a,g,o,!1),I=90-n.calculateAngle(c,P,p,!0);if(t.isAligned&&t.direction==="leftSide"){if(A>=-20&&A<=120)t.leftData=A,t.labels.push({position:a,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...a,side:"left"}),t.points.push({...o,side:"left"}),t.points.push({...g,side:"left"}),t.paths.push(n.makeArcPath(a,o,g,m,S,d,!0,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(I>
70=-20&&I<=120)t.rightData=I,t.labels.push({position:c,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...c,side:"right"}),t.points.push({...p,side:"right"}),t.points.push({...P,side:"right"}),t.paths.push(n.makeArcPath(c,p,P,v,D,b,!1,"right"))}return t}}class Gr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"nose"),s=n.getJointPosition(e,"left_ear"),a=n.getJointPosition(e,"right_ear"),o=n.pointDistance(s,i),l={x:s.x,y:s.y-o},c=n.calculateSlope(i,s),p=n.calculateSlope(l,s),m=n.pointDistance(a,i),g={x:a.x,y:a.y-m},d=n.calculateSlope(i,a),S=n.calculateSlope(g,a),v=n.calculateAngle(s,l,i,!1)-90,P=n.calculateAngle(a,g,i,!0)-90;if(t.isAligned&&t.direction==="leftSide"){if(v>=-20&&v<=220)t.leftData=v,t.labels.push({position:i,value:t.leftData,side:"left",offset:{x:-100,y:0}}),t.points.push({...s,side:"left"}),t.points.push({...i,side:"left"}),t.points.push({...l,side:"left"}),t.paths.push(n.makeArcPath(s,i,l,o,p,c,!0,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(P>=-20&&P<=220)t.rightData=P,t.labels.push({position:i,value:t.rightData,side:"right",offset:{x:100,y:0}}),t.points.push({...a,side:"right"}),t.points.push({...i,side:"right"}),t.points.push({...g,side:"right"}),t.paths.push(n.makeArcPath(a,i,g,m,S,d,!1,"right"))}return t}}class Ur{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"nose"),s=n.getJointPosition(e,"left_shoulder"),a=n.getJointPosition(e,"left_hip"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_hip"),c=n.getMiddlePoint(s,o),p=n.getMiddlePoint(a,l),m=n.calculateSlope(p,c),g=n.pointDistance(c,i)*1.5,d=n.endPointForSlopeAndDist(c,-g,m),S=n.calculateSlope(d,c),v=n.calculateSlope(i,c),P=n.endPointForSlopeAndDist(c,g,v),b=n.calculateAngle(c,d,i,!0);if(t.isAligned)if(b>0&&b<90)t.leftData=b,t.labels.push({position:P,value:t.leftData,offset:{x:100,y:0}}),t.points.push({...c,side:"left"}),t.points.push({...d,side:"left"}),t.points.push({...P,side:"left"}),t.paths.push(n.makeArcPath(c,P,d,g,S,v,!1,"left"));else t.rightData=360-b,t.labels.push({position:P,value:t.rightData,offset:{x:-100,y:0}}),t.points.push({...c,side:"right"}),t.points.push({...d,side:"right"}),t.points.push({...P,side:"right"}),t.paths.push(n.makeArcPath(c,P,d,g,S,v,!0,"right"));return t}}var Ju=180/Math.PI,Gu=0.05,Uu=0.85,Bu=0.12,Vu=0.05,Wu=0.02,$u=0.75,ju=0.25,Yu=-0.1,zu=140;class Zi{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_elbow"),a=n.getJointPosition(e,"left_hip"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_elbow"),c=n.getJointPosition(e,"right_hip"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(a,c),g=n.calculateSlope(m,p),d=n.pointDistance(i,s),S=n.endPointForSlopeAndDist(i,d,g),v=n.calculateSlope(S,i),P=n.calculateSlope(s,i),b=n.calculateAngle(i,s,S,!0),D=n.pointDistance(o,l),A=n.endPointForSlopeAndDist(o,D,g),I=n.calculateSlope(A,o),F=n.calculateSlope(l,o),M=n.calculateAngle(o,A,l,!0);if(t.isAligned){if(b>=0&&b<=200)t.leftData=b,t.labels.push({position:n.getArcMidpoint(i,d,v,P,!0),value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...i,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(i,s,S,d,v,P,!0,"left"));if(M>=0&&M<=200)t.rightData=M,t.labels.push({position:n.getArcMidpoint(o,D,I,F,!1),value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...o,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...A,side:"right"}),t.paths.push(n.makeArcPath(o,l,A,D,I,F,!1,"right"))}return t}runProgram3d(e){let t=new H,i=[],s=w.EPSILON_3D,a=e.variantId?.trim().toLowerCase(),o=a==="left"||a==="right"?a:null;if(!o)return{results:t,overlay3d:i};let l=w.getPointByName(e.rigPoints,"c_spine0"),c=w.getPointByName(e.rigPoints,"c_spine1"),p=w.getPointByName(e.rigPoints,"c_spine2"),m=w.getPointByName(e.rigPoints,"c_spine3"),g=w.getPointByName(e.rigPoints,"l_clavicle"),d=w.getPointByName(e.rigPoints,"r_clavicle"),S=w.getPointByName(e.bodyPoints,"left_acromion"),v=w.getPointByName(e.bodyPoints,"right_acromion"),P=w.getPointByName(e.bodyPoints,"left_olecranon"),b=w.getPointByName(e.bodyPoints,"right_olecranon"),D=w.getPointByName(e.bodyPoints,"left_cubital_fossa"),A=w.getPointByName(e.bodyPoints,"right_cubital_fossa"),I=w.getPointByName(e.bodyPoints,"left_elbow"),F=w.getPointByName(e.bodyPoints,"right_elbow");if(!l||!c||!p||!m||!g||!d||!S||!v||!P||!b||!D||!A||!I||!F)return{results:t,overlay3d:i};let M=w.subtract(c,l),z=w.subtract(p,c),J=w.subtract(m,p),N=w.normalize(M),W=w.normalize(z),K=w.normalize(J);if(!N||!W||!K)return{results:t,overlay3d:i};
70let j=w.normalize(w.add(w.add(N,W),K));if(!j)return{results:t,overlay3d:i};let Y=w.normalize(w.subtract(d,g));if(!Y)return{results:t,overlay3d:i};let it=w.scale(j,w.dot(Y,j)),Z=w.normalize(w.subtract(Y,it));if(!Z)return{results:t,overlay3d:i};let st=w.normalize(w.cross(j,Z));if(!st)return{results:t,overlay3d:i};let rt=w.normalize(w.cross(st,j));if(!rt)return{results:t,overlay3d:i};let pt=w.normalize(w.cross(rt,st));if(!pt)return{results:t,overlay3d:i};let St=w.scale(pt,-1),Vt=w.scale(st,-1),yt=o==="left"?S:v,zt=o==="left"?g:d,qt=o==="left"?P:b,de=o==="left"?D:A,Mt=o==="left"?I:F,we=w.average(qt,de),ne=w.add(w.scale(we,$u),w.scale(Mt,ju)),Xt=w.normalize(w.subtract(zt,yt));if(!Xt)return{results:t,overlay3d:i};let se=w.magnitude(w.subtract(ne,yt));if(se<=s)return{results:t,overlay3d:i};let xt=w.add(w.add(w.add(yt,w.scale(Xt,Bu*se)),w.scale(St,Vu*se)),w.scale(Vt,Wu*se)),re=w.subtract(ne,xt),Kt=w.magnitude(re);if(Kt<=s)return{results:t,overlay3d:i};let Lt=w.normalize(re);if(!Lt)return{results:t,overlay3d:i};let me=w.subtract(Lt,w.scale(st,w.dot(Lt,st)));if(w.magnitude(me)<Uu)return{results:t,overlay3d:i};let ct=w.normalize(me);if(!ct)return{results:t,overlay3d:i};let fe=o==="right"?rt:w.scale(rt,-1),qe=w.clampToUnitRange(w.dot(ct,St)),Te=w.magnitude(w.cross(St,ct)),Zt=Math.atan2(Te,qe)*Ju;if(!Number.isFinite(Zt))return{results:t,overlay3d:i};if(w.dot(ct,fe)<Yu&&Zt<zu)return{results:t,overlay3d:i};let Pe=Math.min(180,Math.max(0,Zt)),Re=Math.max(Kt,Gu),Qt=St,Ae=w.add(xt,w.scale(Qt,Re)),Dt=w.add(xt,w.scale(ct,Re)),ae=st,Jt=w.normalize(w.cross(Qt,ct));if(Jt&&w.dot(Jt,ae)<0)ae=w.scale(ae,-1);let oe=Re,ge=w.normalize(w.add(Qt,ct))??ct,Ze=w.add(xt,w.scale(ge,oe*0.75)),Qe=o==="left"?"#ff6b6b":"#4dd0e1",ki="#ffd166";if(o==="left")t.leftData=Pe;else t.rightData=Pe;return t.isAligned=!0,t.direction="front",t.points.push({...xt,side:o}),t.points.push({...ne,side:o}),t.points.push({...Ae,side:o}),t.points.push({...Dt,side:o}),t.labels.push({position:Ze,value:Pe,side:o}),i.push({kind:"line",from:xt,to:Dt,side:o,color:Qe}),i.push({kind:"line",from:xt,to:ne,side:o,color:"#9ca3af"}),i.push({kind:"line",from:xt,to:Ae,side:o,color:ki}),i.push({kind:"arc",center:xt,startDirection:Qt,endDirection:ct,normal:ae,radius:oe,segments:36,side:o,color:Qe}),{results:t,overlay3d:i}}}var Br=180/Math.PI,qu=0.05,Xu=0.7,Zu=0.12,Qu=0.05,tc=0.02,ec=0.75,ic=0.25,nc=0.02;class Vr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_elbow"),a=n.getJointPosition(e,"left_hip"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_elbow"),c=n.getJointPosition(e,"right_hip"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(a,c),g=n.calculateSlope(m,p),d=n.pointDistance(i,s),S=n.endPointForSlopeAndDist(i,d,g),v=n.calculateSlope(S,i),P=n.calculateSlope(s,i),b=n.calculateAngle(i,s,S,!1),D=n.pointDistance(o,l),A=n.endPointForSlopeAndDist(o,D,g),I=n.calculateSlope(A,o),F=n.calculateSlope(l,o),M=n.calculateAngle(o,A,l,!1);if(t.isAligned){if(b>=0&&b<=200)t.leftData=b,t.labels.push({position:i,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...i,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(i,s,S,d,v,P,!1,"left"));if(M>=0&&M<=200)t.rightData=M,t.labels.push({position:o,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...o,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...A,side:"right"}),t.paths.push(n.makeArcPath(o,l,A,D,I,F,!0,"right"))}return t}runProgram3d(e){let t=new H,i=[],s=w.EPSILON_3D,a=e.variantId?.trim().toLowerCase()==="left"||e.variantId?.trim().toLowerCase()==="right"?e.variantId.trim().toLowerCase():null;if(!a)return{results:t,overlay3d:i};let o=w.getPointByName(e.rigPoints,"c_spine0"),l=w.getPointByName(e.rigPoints,"c_spine1"),c=w.getPointByName(e.rigPoints,"c_spine2"),p=w.getPointByName(e.rigPoints,"c_spine3"),m=w.getPointByName(e.rigPoints,"l_clavicle"),g=w.getPointByName(e.rigPoints,"r_clavicle"),d=w.getPointByName(e.bodyPoints,"left_acromion"),S=w.getPointByName(e.bodyPoints,"right_acromion"),v=w.getPointByName(e.bodyPoints,"left_olecranon"),P=w.getPointByName(e.bodyPoints,"right_olecranon"),b=w.getPointByName(e.bodyPoints,"left_cubital_fossa"),D=w.getPointByName(e.bodyPoints,"right_cubital_fossa"),A=w.getPointByName(e.bodyPoints,"left_elbow"),I=w.getPointByName(e.bodyPoints,"right_elbow");if(!o||!l||!c||!p||!m||!g||!d||!S||!v||!P||!b||!D||!A||!I)return{results:t,overlay3d:i};let F=w.normalize(w.subtract(l,o)),M=w.normalize(w.subtract(c,l)),z=w.normalize(w.subtract(p,c));if(!F||!M||!z)return{results:t,overlay3d:i};let J=w.normalize(w.add(w.add(F,M),z));if(!J)return{results:t,overlay3d:i};let N=w.normalize(w.subtract(g,m));if(!N)return{results:t,overlay3d:i};let W=w.normalize(w.subtract(N,w.scale(J,w.dot(N,J))));if(!W)return{results:t,overlay3d:i};let K=w.normalize(w.cross(J,W));if(!K)return{results:t,overlay3d:i};let j=w.normalize(w.cross(K,J));if(!j)return{results:t,overlay3d:i};
70let Y=w.normalize(w.cross(j,K));if(!Y)return{results:t,overlay3d:i};let it=w.scale(Y,-1),Z=w.scale(K,-1),st=a==="left"?d:S,rt=a==="left"?m:g,pt=a==="left"?v:P,St=a==="left"?b:D,Vt=a==="left"?A:I,yt=w.average(pt,St),zt=w.add(w.scale(yt,ec),w.scale(Vt,ic)),qt=w.normalize(w.subtract(rt,st));if(!qt)return{results:t,overlay3d:i};let de=w.magnitude(w.subtract(zt,st));if(de<=s)return{results:t,overlay3d:i};let Mt=w.add(w.add(w.add(st,w.scale(qt,Zu*de)),w.scale(it,Qu*de)),w.scale(Z,tc*de)),we=w.subtract(zt,Mt),ne=w.magnitude(we);if(ne<=s)return{results:t,overlay3d:i};let Xt=w.normalize(we);if(!Xt)return{results:t,overlay3d:i};let se=a==="right"?j:w.scale(j,-1),xt=null,re=null,Kt=null,Lt=null,me=null,mt=w.subtract(Xt,w.scale(K,w.dot(Xt,K)));if(w.magnitude(mt)>=Xu){let Dt=w.normalize(mt);if(Dt){let ae=w.clampToUnitRange(w.dot(Dt,it)),Jt=w.magnitude(w.cross(it,Dt)),oe=Math.atan2(Jt,ae)*Br;if(Number.isFinite(oe)){let ge=w.dot(Dt,se),Ze=Math.abs(ge)<nc?0:ge>0?1:-1,Qe=oe*Ze;xt=Dt,re=K,Kt=it,Lt=Math.min(200,Math.max(0,-Qe)),me="Coronal"}}}if(!xt||!re||Lt===null||!me){let Dt=w.subtract(Xt,w.scale(Y,w.dot(Xt,Y)));if(w.magnitude(Dt)<=s)return{results:t,overlay3d:i};let Jt=w.normalize(Dt);if(!Jt)return{results:t,overlay3d:i};if(w.dot(Jt,K)<=0)return{results:t,overlay3d:i};let ge=Math.acos(w.clampToUnitRange(w.dot(Jt,se)))*Br;if(!Number.isFinite(ge))return{results:t,overlay3d:i};xt=Jt,re=Y,Kt=se,Lt=Math.min(200,Math.max(0,ge)),me="Transverse"}if(!Kt)return{results:t,overlay3d:i};let fe=Math.max(ne,qu),qe=w.add(Mt,w.scale(Kt,fe)),Te=w.add(Mt,w.scale(xt,fe)),Zt=re,Xe=w.normalize(w.cross(Kt,xt));if(Xe&&w.dot(Xe,Zt)<0)Zt=w.scale(Zt,-1);let Pe=w.normalize(w.add(Kt,xt))??xt,Re=w.add(Mt,w.scale(Pe,fe*0.75)),Qt=a==="left"?"#ff6b6b":"#4dd0e1",Ae="#ffd166";if(a==="left")t.leftData=Lt;else t.rightData=Lt;if(t.isAligned=!0,t.direction="front",t.points.push({...Mt,side:a}),t.points.push({...zt,side:a}),t.points.push({...qe,side:a}),t.points.push({...Te,side:a}),t.labels.push({position:Re,value:Lt,side:a}),i.push({kind:"line",from:Mt,to:qe,side:a,color:Ae}),i.push({kind:"line",from:Mt,to:zt,side:a,color:"#9ca3af"}),Lt>0)i.push({kind:"line",from:Mt,to:Te,side:a,color:Qt}),i.push({kind:"arc",center:Mt,startDirection:Kt,endDirection:xt,normal:Zt,radius:fe,segments:36,side:a,color:Qt});else i.push({kind:"line",from:Mt,to:Te,side:a,color:"#6b7280"});return{results:t,overlay3d:i,hud:{context:me}}}}class Wr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_elbow"),a=n.getJointPosition(e,"left_hip"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_elbow"),c=n.getJointPosition(e,"right_hip"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(a,c),g=n.calculateSlope(m,p),d=n.pointDistance(i,s),S=n.endPointForSlopeAndDist(i,d,g),v=n.calculateSlope(S,i),P=n.calculateSlope(s,i),b=n.calculateAngle(i,S,s,!1),D=n.pointDistance(o,l),A=n.endPointForSlopeAndDist(o,D,g),I=n.calculateSlope(A,o),F=n.calculateSlope(l,o),M=n.calculateAngle(o,A,l,!0);if(t.isAligned&&t.direction==="leftSide"){if(b>=0&&b<=200)t.leftData=b,t.labels.push({position:n.getArcMidpoint(i,d,v,P,!0),value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...i,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(i,s,S,d,v,P,!0,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(M>=0&&M<=200)t.rightData=M,t.labels.push({position:n.getArcMidpoint(o,D,I,F,!1),value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...o,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...A,side:"right"}),t.paths.push(n.makeArcPath(o,l,A,D,I,F,!1,"right"))}return t}}class $r{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_wrist"),a=n.getJointPosition(e,"left_hip"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_wrist"),c=n.getJointPosition(e,"right_hip"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(a,c),g=n.calculateSlope(m,p),d=n.pointDistance(i,s),S=n.endPointForSlopeAndDist(i,d,g),v=n.calculateSlope(S,i),P=n.calculateSlope(s,i),b=n.calculateAngle(i,s,S,!1)-90,D=n.pointDistance(o,l),A=n.endPointForSlopeAndDist(o,D,g),I=n.calculateSlope(A,o),F=n.calculateSlope(l,o),M=n.calculateAngle(o,A,l,!1)-90;if(t.isAligned&&t.direction==="leftSide"){if(b>=0&&b<=200){if(b>0)t.leftData=b,t.labels.push({position:n.getArcMidpoint(i,d,v,P,!1),value:t.leftData,side:"left",offset:{x:-100,y:0}});t.points.push({...i,side:"left"}),t.points.push({...S,side:"left"}),t.points.push({...s,side:"left"}),t.paths.push(n.makeArcPath(i,s,S,d,v,P,!1,"left"))}}else if(t.isAligned&&t.direction==="rightSide"){if(M>
70=0&&M<=200){if(M>0)t.rightData=M,t.labels.push({position:n.getArcMidpoint(o,D,I,F,!0),value:t.rightData,side:"right",offset:{x:100,y:0}});t.points.push({...o,side:"right"}),t.points.push({...A,side:"right"}),t.points.push({...l,side:"right"}),t.paths.push(n.makeArcPath(o,l,A,D,I,F,!0,"right"))}}return t}}class jr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_elbow"),a=n.getJointPosition(e,"left_hip"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_elbow"),c=n.getJointPosition(e,"right_hip"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(a,c),g=n.calculateSlope(m,p),d=n.pointDistance(i,s),S=n.endPointForSlopeAndDist(i,d,g),v=n.calculateSlope(S,i),P=n.calculateSlope(s,i),b=n.calculateAngle(i,S,s,!0),D=n.pointDistance(o,l),A=n.endPointForSlopeAndDist(o,D,g),I=n.calculateSlope(A,o),F=n.calculateSlope(l,o),M=n.calculateAngle(o,A,l,!1);if(t.isAligned&&t.direction==="leftSide"){if(b>=0&&b<=200)t.leftData=b,t.labels.push({position:n.getArcMidpoint(i,d,v,P,!1),value:t.leftData,side:"left",offset:{x:-100,y:0}}),t.points.push({...i,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.paths.push(n.makeArcPath(i,s,S,d,v,P,!1,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(M>=0&&M<=200)t.rightData=M,t.labels.push({position:n.getArcMidpoint(o,D,I,F,!0),value:t.rightData,side:"right",offset:{x:100,y:0}}),t.points.push({...o,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...A,side:"right"}),t.paths.push(n.makeArcPath(o,l,A,D,I,F,!0,"right"))}return t}}class Yr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_wrist"),a=n.getJointPosition(e,"left_hip"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_wrist"),c=n.getJointPosition(e,"right_hip"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(a,c),g=n.calculateSlope(m,p),d=n.pointDistance(i,s),S=n.endPointForSlopeAndDist(i,d,g+90),v=n.calculateSlope(S,i),P=n.calculateSlope(s,i),b=n.calculateAngle(i,s,S,!0),D=n.pointDistance(o,l),A=n.endPointForSlopeAndDist(o,D,g-90),I=n.calculateSlope(A,o),F=n.calculateSlope(l,o),M=n.calculateAngle(o,A,l,!0);if(t.isAligned&&t.direction==="leftSide"){if(b>=0&&b<=200){if(b>0)t.leftData=b,t.labels.push({position:n.getArcMidpoint(i,d,v,P,!0),value:t.leftData,side:"left",offset:{x:-100,y:0}});t.points.push({...i,side:"left"}),t.points.push({...S,side:"left"}),t.points.push({...s,side:"left"}),t.paths.push(n.makeArcPath(i,s,S,d,v,P,!0,"left"))}}else if(t.isAligned&&t.direction==="rightSide"){if(M>
70=0&&M<=200){if(M>0)t.rightData=M,t.labels.push({position:n.getArcMidpoint(o,D,I,F,!1),value:t.rightData,side:"right",offset:{x:100,y:0}});t.points.push({...o,side:"right"}),t.points.push({...A,side:"right"}),t.points.push({...l,side:"right"}),t.paths.push(n.makeArcPath(o,l,A,D,I,F,!1,"right"))}}return t}}class zr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_ankle"),a=n.getJointPosition(e,"right_hip"),o=n.getJointPosition(e,"right_ankle"),l=n.pointDistance(i,s),c=n.endPointForSlopeAndDist(i,l,180),p=n.calculateSlope(c,i),m=n.calculateSlope(s,i),g=n.calculateAngle(i,s,c,!1),d=n.pointDistance(a,o),S=n.endPointForSlopeAndDist(a,d,0),v=n.calculateSlope(S,a),P=n.calculateSlope(o,a),b=n.calculateAngle(a,S,o,!1);if(t.isAligned&&t.direction==="leftSide"){if(g>=0&&g<=250)t.leftData=g,t.labels.push({position:n.getArcMidpoint(i,l,p,m,!1),value:t.leftData,side:"left",offset:{x:-100,y:0}}),t.points.push({...i,side:"left"}),t.points.push({...c,side:"left"}),t.points.push({...s,side:"left"}),t.paths.push(n.makeArcPath(i,s,c,l,p,m,!1,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(b>=0&&b<=250)t.rightData=b,t.labels.push({position:n.getArcMidpoint(a,d,v,P,!0),value:t.rightData,side:"right",offset:{x:100,y:0}}),t.points.push({...a,side:"right"}),t.points.push({...S,side:"right"}),t.points.push({...o,side:"right"}),t.paths.push(n.makeArcPath(a,o,S,d,v,P,!0,"right"))}return t}}class qr{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"right_shoulder"),a=n.pointDistance(s,i),o=n.endPointForSlopeAndDist(s,a,0),l=n.calculateSlope(o,s),c=n.calculateSlope(i,s),p=n.pointDistance(i,s),m=n.endPointForSlopeAndDist(i,p,180),g=n.calculateSlope(m,i),d=n.calculateSlope(s,i),S=n.calculateAngle(s,i,o,!0),v=n.calculateAngle(i,s,m,!1);if(S>=0&&S<=200)t.leftData=S,t.labels.push({position:n.getArcMidpoint(s,a,l,c,!0),value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...s}),t.points.push({...i,side:"left"}),t.points.push({...o,side:"left"}),t.paths.push(n.makeArcPath(s,i,o,a,l,c,!0,"left"));if(v>=0&&v<=200)t.rightData=v,t.labels.push({position:n.getArcMidpoint(i,p,g,d,!1),value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...i}),t.points.push({...s,side:"right"}),t.points.push({...m,side:"right"}),t.paths.push(n.makeArcPath(i,s,m,p,g,d,!1,"right"));return t}}class Nn{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_elbow"),a=n.getJointPosition(e,"left_wrist"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_elbow"),c=n.getJointPosition(e,"right_wrist"),p=Math.min(n.pointDistance(i,s),n.pointDistance(s,a)),m=n.calculateSlope(i,s),g=n.calculateSlope(a,s),d=n.endPointForSlopeAndDist(s,p,m),S=n.endPointForSlopeAndDist(s,p,g),v=180-n.calculateAngle(s,a,i,!0),P=Math.min(n.pointDistance(o,l),n.pointDistance(l,c)),b=n.calculateSlope(o,l),D=n.calculateSlope(c,l),A=n.endPointForSlopeAndDist(l,P,b),I=n.endPointForSlopeAndDist(l,P,D),F=180-n.calculateAngle(l,o,c,!0);if(t.isAligned)t.points.push({...d,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.leftData=v,t.points.push({...A,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...I,side:"right"}),t.rightData=F;return t}}class kn{runProgram(e){let t=new Xr;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.getJointPosition(e,"left_foot_index"),o=n.getJointPosition(e,"left_ankle"),l=n.getJointPosition(e,"left_knee"),c=n.getJointPosition(e,"right_foot_index"),p=n.getJointPosition(e,"right_ankle"),m=n.getJointPosition(e,"right_knee"),g=n.pointDistance(i,s),d={x:i.x-g,y:i.y},S=n.calculateSlope(d,i),v=n.calculateSlope(s,i),P=n.calculateAngle(i,s,d,!0)-360,b=n.pointDistance(s,i),D={x:s.x+b,y:s.y},A=n.calculateSlope(D,s),I=n.calculateSlope(i,s),F=n.calculateAngle(s,D,i,!0)-360;if(t.isAligned){if(t.points.push(l),t.points.push(a),t.points.push(o),t.points.push(i),t.points.push(m),t.points.push(c),t.points.push(p),t.points.push(s),v>0)t.points.push(d),t.paths.push(n.makeArcPath(i,s,d,g,S,v,!0)),t.rightPelvicDrop=Math.abs(F),t.labels.push({position:i,value:t.rightPelvicDrop,offset:{x:100,y:0}});if(I>0)t.points.push(D),t.paths.push(n.makeArcPath(s,i,D,b,A,I,!1)),t.leftPelvicDrop=Math.abs(P),t.labels.push({position:s,value:t.leftPelvicDrop,offset:{x:-100,y:0}})}return t}}class Qr{runProgram(e){let t=new Zr;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_foot_index"),s=n.getJointPosition(e,"right_foot_index"),a=n.getJointPosition(e,"left_hip"),o=n.getJointPosition(e,"right_hip"),l=n.getMiddlePoint(a,o),c=new kn().runProgram(e),p=new Nn().runProgram(e),m=new ii().runProgram(e);if(t.isAligned)t.points=[...c.points,...m.points],t.paths=[...c.paths,...m.paths],t.labels=[...c.labels,...m.labels],t.midHipY=l.y,t.armsCrossed=(p.leftData??0)>=100&&(p.rightData??0)>=100,t.pelvicDrop=c.leftPelvicDrop?-c.leftPelvicDrop:c.rightPelvicDrop,t.backLateralFlexion=m.leftData?-m.leftData:m.rightData,t.leftFootHeight=i.y,t.rightFootHeight=s.y;return t}}var _e={};Et(_e,{CaptureStatus:()=>ua,JumpController:()=>ca,programs:()=>Bn});var Bn={};Et(Bn,{VerticalJump:()=>sa});class Jn{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_elbow"),a=n.getJointPosition(e,"left_wrist"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_elbow"),c=n.getJointPosition(e,"right_wrist"),p=Math.min(n.pointDistance(i,s),n.pointDistance(s,a)),m=n.calculateSlope(i,s),g=n.calculateSlope(a,s),d=n.endPointForSlopeAndDist(s,p,m),S=n.endPointForSlopeAndDist(s,p,g),v=180-n.calculateAngle(s,a,i,!0),P=Math.min(n.pointDistance(o,l),n.pointDistance(l,c)),b=n.calculateSlope(o,l),D=n.calculateSlope(c,l),A=n.endPointForSlopeAndDist(l,P,b),I=n.endPointForSlopeAndDist(l,P,D),F=180-n.calculateAngle(l,o,c,!0);if(t.isAligned)t.points.push({...d,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...S,side:"left"}),t.leftData=v,t.points.push({...A,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...I,side:"right"}),t.rightData=F;return t}}class Gn{runProgram(e){let t=new ta;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_ankle"),s=n.getJointPosition(e,"left_knee"),a=n.getJointPosition(e,"left_foot_index"),o=n.getJointPosition(e,"right_ankle"),l=n.getJointPosition(e,"right_knee"),c=n.getJointPosition(e,"right_foot_index"),p=n.pointDistance(i,s),m={x:i.x,y:i.y-p},g=n.calculateSlope(m,i),d=n.calculateSlope(s,i),S=n.pointDistance(o,l),v={x:o.x,y:o.y-S},P=n.calculateSlope(v,o),b=n.calculateSlope(l,o);if(t.isAligned){if(t.points.push({...i,side:"left"}),t.points.push({...s,side:"left"}),t.points.push({...m,side:"left"}),t.points.push({...a,side:"left"}),t.paths.push(n.makeArcPath(i,s,m,p,g,d,d<g,"left")),t.points.push({...o,side:"right"}),t.points.push({...l,side:"right"}),t.points.push({...v,side:"right"}),t.points.push({...c,side:"right"}),t.paths.push(n.makeArcPath(o,l,v,S,P,b,b<P,"right")),t.leftData.kneeValue=Math.abs(g-d),Math.abs(g-d)<=5)t.leftData.kneeAlignment="neutral";else if(d<g)t.leftData.kneeAlignment="valgus";else if(d>g)t.leftData.kneeAlignment="varus";if(t.rightData.kneeValue=Math.abs(P-b),Math.abs(P-b)<=5)t.rightData.kneeAlignment="neutral";else if(b<P)t.rightData.kneeAlignment="varus";else if(b>P)t.rightData.kneeAlignment="valgus";t.labels.push({position:s,value:`${t.leftData.kneeValue.toFixed(1)}° ${t.leftData.kneeAlignment}`,side:"left",offset:{x:150,y:0}}),t.labels.push({position:l,value:`${t.rightData.kneeValue.toFixed(1)}° ${t.rightData.kneeAlignment}`,side:"right",offset:{x:-150,y:0}})}return t}}class Un{runProgram(e){let t=new ia;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.pointDistance(i,s),o={x:i.x-a,y:i.y},l=n.calculateSlope(o,i),c=n.calculateSlope(s,i),p=n.calculateAngle(i,s,o,!0)-360,m=n.pointDistance(s,i),g={x:s.x+m,y:s.y},d=n.calculateSlope(g,s),S=n.calculateSlope(i,s),v=n.calculateAngle(s,g,i,!0)-360;if(t.isAligned){if(t.points.push(i),t.points.push(s),c>0)t.points.push(o),t.paths.push(n.makeArcPath(i,s,o,a,l,c,!0)),t.rightPelvicDrop=Math.abs(v),t.labels.push({position:i,value:t.rightPelvicDrop,offset:{x:100,y:0}});if(S>0)t.points.push(g),t.paths.push(n.makeArcPath(s,i,g,m,d,S,!1)),t.leftPelvicDrop=Math.abs(p),t.labels.push({position:s,value:t.leftPelvicDrop,offset:{x:-100,y:0}})}return t}}class sa{runProgram(e){let t=new na;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.getMiddlePoint(i,s),o=this.calculateTopOfHead(e),l=n.getJointPosition(e,"left_foot_index"),c=n.getJointPosition(e,"right_foot_index"),p=n.getMiddlePoint(l,c),m=new Un().runProgram(e),g=new Gn().runProgram(e),d=new Jn().runProgram(e),S=new ii().runProgram(e);if(t.isAligned)t.points=[...m.points,...g.points,...S.points,o],t.paths=[...m.paths,...g.paths,...S.paths],t.labels=[...m.labels,...g.labels,...S.labels],t.midHipY=a.y,t.topOfHeadY=o.y,t.midFeetY=p.y,t.armsCrossed=(d.leftData??0)>=100&&(d.rightData??0)>=100,t.pelvicDrop=m.leftPelvicDrop?-m.leftPelvicDrop:m.rightPelvicDrop,t.backLateralFlexion=S.leftData?-S.leftData:S.rightData,t.leftData={footHeight:l.y,...g.leftData},t.rightData={footHeight:c.y,...g.rightData};return t}calculateTopOfHead(e){let t=n.getJointPosition(e,"left_eye_inner"),i=n.getJointPosition(e,"right_eye_inner"),s=n.getMiddlePoint(t,i),a=n.getJointPosition(e,"left_eye_outer"),o=n.getJointPosition(e,"right_eye_outer"),l=n.pointDistance(a,o);return{x:s.x,y:s.y-l}}}var ra=`<div class="bottom-controller-container space-x-1"> 71 <div class="grow min-w-[1px]"></div> 72 <div id="leftSLVertJumpData" class="min-w-[435px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-3 items-center border-4 border-white"> 73 <h3 class="col-span-6 font-bold text-lg">Left Side</h3> 74 <div class="col-span-6 text-end"> 75 <button id="leftReset" class="hidden data-results-reset">
76 <span>Reset</span> 77 </button> 78 </div> 79 <div class="col-span-3 text-sm">Height</div> 80 <div class="col-span-3 text-sm value vertHeight">--</div> 81 <div class="col-span-3 text-sm">Knee takeoff</div> 82 <div class="col-span-3 text-sm value takeoff">--</div> 83 <div class="col-span-3 text-sm">Hang time</div> 84 <div class="col-span-3 text-sm value hangTime">--</div> 85 <div class="col-span-3 text-sm">Knee landing</div> 86 <div class="col-span-3 text-sm value landing">--</div> 87 </div> 88 <div class="grow"></div> 89 <div id="rightSLVertJumpData" class="min-w-[435px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-3 items-center border-4 border-white"> 90 <h3 class="col-span-6 font-bold text-lg">Right Side</h3> 91 <div class="col-span-6 text-end"> 92 <button id="rightReset" class="hidden data-results-reset"> 93 <span>Reset</span> 94 </button> 95 </div> 96 <div class="col-span-3 text-sm">Height</div> 97 <div class="col-span-3 text-sm value vertHeight">--</div> 98 <div class="col-span-3 text-sm">Knee takeoff</div> 99 <div class="col-span-3 text-sm value takeoff">--</div> 100 <div class="col-span-3 text-sm">Hang time</div> 101 <div class="col-span-3 text-sm value hangTime">--</div> 102 <div class="col-span-3 text-sm">Knee landing</div> 103 <div class="col-span-3 text-sm value landing">--</div> 104 </div> 105 <div class="grow min-w-[1px]"></div> 106</div> 107`;var aa=`<div class="top-controller-container"> 108 <div id="slVertJumpCaptureContainer" class="capture-bar"> 109 <button id="setLeft" class="capture-bar-cta border-2 border-green-500 hover:bg-green-500 text-black mr-1"> 110 <span>Capture Left</span> 111 </button> 112 <button id="setRight" class="capture-bar-cta border-2 border-blue-500 hover:bg-blue-500 text-black ml-1"> 113 <span>Capture Right</span> 114 </button> 115 <button id="vertJumpCalibrate" class="capture-bar-cta bg-yellow-400 hover:bg-yellow-500 text-yellow-900"> 116 <span>Calibrate</span> 117 </button> 118 <button id="vertJumpReset" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 119 <span>Reset Both</span> 120 </button> 121 <button id="vertJumpStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 122 <span>Stop</span> 123 </button> 124 <div class="min-w-6"></div> 125 <div class="flex flex-col"> 126 <span id="vertJumpCaptureTypeHeader" class="text-xs mb-[-4px] pt-1"></span> 127 <span id="vertJumpCaptureTypeSubheader" class="font-bold text-lg"></span> 128 </div> 129 <div class="min-w-6"></div> 130 <button id="vertJumpCaptureConfig" class="settings-button"> 131 <i class="fas fa-gear text-2xl p-2 text-gray-500"></i> 132 </button> 133 </div> 134</div> 135<div id="vertJumpDismissModal" class="fade-out absolute left-0 top-0 right-0 bottom-0"></div> 136<div 137 id="vertJumpCaptureModal" 138 class="fade-out absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 p-4 transition-opacity duration-500 ease-in-out" 139> 140 <div class="w-96 bg-gray-100 rounded-xl p-6 shadow-lg"> 141 142 <!-- Header + Toggle --> 143 <div class="flex flex-col items-center justify-between mb-4"> 144 <h2 class="text-lg font-semibold text-gray-800 w-full text-center mb-4"> 145 Calibration Settings 146 </h2> 147 <div class="flex flex-row w-full"> 148 <div class="grow"></div> 149 <button 150 id="measurementToggle" 151 class="text-sm font-medium text-blue-600 hover:text-blue-800 ml-2" 152 > 153 Switch to Metric 154 </button> 155 </div> 156 </div> 157 158 <!-- Imperial Inputs --> 159 <div id="imperialContainer"> 160 <!-- Height (Feet/Inches) --> 161 <div class="flex justify-between items-center mb-4"> 162 <div> 163 <p class="text-sm font-medium text-gray-900">Height</p> 164 </div> 165 <div class="flex items-center"> 166 <input 167 class="bg-white p-2 rounded-xl w-24 text-center mr-2" 168 placeholder="ft" 169 type="number" 170 id="feetInput" 171 min="0" 172 max="9" 173 step="1" 174 />
175 <span class="mr-3">ft</span> 176 <input 177 class="bg-white p-2 rounded-xl w-24 text-center mr-2" 178 placeholder="in" 179 type="number" 180 id="inchesInput" 181 min="0" 182 max="12" 183 step="1" 184 /> 185 <span>in</span> 186 </div> 187 </div> 188 189 <!-- Weight (lbs) --> 190 <div class="flex justify-between items-center mb-4"> 191 <div> 192 <p class="text-sm font-medium text-gray-900">Weight</p> 193 </div> 194 <div class="flex items-center"> 195 <input 196 class="bg-white p-2 rounded-xl w-24 text-center mr-2" 197 placeholder="lbs" 198 type="number" 199 id="poundsInput" 200 min="0" 201 max="999" 202 step="1" 203 /> 204 <span>lbs</span> 205 </div> 206 </div> 207 </div> 208 209 <!-- Metric Inputs --> 210 <!-- Hide this container by default (e.g., via 'hidden') --> 211 <div id="metricContainer" class="hidden"> 212 <!-- Height (cm) --> 213 <div class="flex justify-between items-center mb-4"> 214 <div> 215 <p class="text-sm font-medium text-gray-900">Height</p> 216 </div> 217 <div class="flex items-center"> 218 <input 219 class="bg-white p-2 rounded-xl w-24 text-center mr-2" 220 placeholder="cm" 221 type="number" 222 id="centimetersInput" 223 min="0" 224 step="1" 225 /> 226 <span>cm</span> 227 </div> 228 </div> 229 230 <!-- Weight (kg) --> 231 <div class="flex justify-between items-center mb-4"> 232 <div> 233 <p class="text-sm font-medium text-gray-900">Weight</p> 234 </div> 235 <div class="flex items-center"> 236 <input 237 class="bg-white p-2 rounded-xl w-24 text-center mr-2" 238 placeholder="kg" 239 type="number" 240 id="kilogramsInput" 241 min="0" 242 max="999" 243 step="1" 244 /> 245 <span>kg</span> 246 </div> 247 </div> 248 </div> 249 <div id="modalWarning" class="hidden flex flex-start font-medium text-red-500 mb-4 mt-4"> 250 Please set a height and weight to continue. 251 </div> 252 <div class="flex flex-col items-center justify-between mt-6 mb-4"> 253 <button 254 id="submitHeightWeight" 255 class="text-md bg-blue-500 font-medium text-white hover:bg-blue-600 p-3 w-24 rounded-xl" 256 > 257 Save 258 </button> 259 </div> 260 </div> 261</div> 262`;var oa=`<div class="bottom-controller-container space-x-1"> 263 <div class="grow min-w-[1px]"></div> 264 <div id="leftData" class="min-w-[300px] grid grid-cols-12 gap-y-2 gap-x-1 bg-white rounded-md shadow-sm p-3 items-center border-4 border-white"> 265 <h3 class="col-span-12 font-bold text-lg">Left Results</h3> 266 <div class="col-span-6 text-sm">Knee takeoff</div> 267 <div class="col-span-6 text-sm value leftTakeoff">--</div> 268 <div class="col-span-6 text-sm">Knee landing</div> 269 <div class="col-span-6 text-sm value leftLanding">--</div> 270 </div> 271 <div class="grow"></div> 272 <div id="vertJumpData" class="min-w-[300px] grid grid-cols-12 gap-2 bg-white rounded-md shadow-sm p-3 items-center border-4 border-white"> 273 <h3 class="col-span-12 font-bold text-lg">Jump Results</h3> 274 <div class="col-span-6 text-sm">Height</div> 275 <div class="col-span-6 text-sm value vertHeight">--</div> 276 <div class="col-span-6 text-sm">Hang time</div> 277 <div class="col-span-6 text-sm value hangTime">--</div> 278 </div> 279 <div class="grow"></div> 280 <div id="rightData" class="min-w-[300px] grid grid-cols-12 gap-2 bg-white rounded-md shadow-sm p-3 items-center border-4 border-white"> 281 <h3 class="col-span-12 font-bold text-lg">Right Results</h3> 282 <div class="col-span-6 text-sm">Knee takeoff</div> 283 <div class="col-span-6 text-sm value rightTakeoff">--</div> 284 <div class="col-span-6 text-sm">Knee landing</div> 285 <div class="col-span-6 text-sm value rightLanding">--</div> 286 </div> 287 <div class="grow min-w-[1px]"></div> 288</div> 289`;var la=`<div class="top-controller-container"> 290 <div id="vertJumpCaptureContainer" class="capture-bar"> 291 <button id="vertJumpCalibrate" class="capture-bar-cta bg-yellow-400 hover:bg-yellow-500 text-yellow-900">
292 <span>Calibrate</span> 293 </button> 294 <button id="vertJumpReset" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 295 <span>Reset</span> 296 </button> 297 <button id="vertJumpStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 298 <span>Stop</span> 299 </button> 300 <div class="min-w-6"></div> 301 <div class="flex flex-col"> 302 <span id="vertJumpCaptureTypeHeader" class="text-xs mb-[-4px] pt-1">Capture Status</span> 303 <span id="vertJumpCaptureTypeSubheader" class="font-bold text-lg">Please calibrate</span> 304 </div> 305 <div class="min-w-6"></div> 306 <button id="vertJumpCaptureConfig" class="settings-button"> 307 <i class="fas fa-gear text-2xl p-2 text-gray-500"></i> 308 </button> 309 </div> 310</div> 311<div id="vertJumpDismissModal" class="fade-out absolute left-0 top-0 right-0 bottom-0"></div> 312<div 313 id="vertJumpCaptureModal" 314 class="fade-out absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 p-4 transition-opacity duration-500 ease-in-out" 315> 316 <div class="w-96 bg-gray-100 rounded-xl p-6 shadow-lg"> 317 318 <!-- Header + Toggle --> 319 <div class="flex flex-col items-center justify-between mb-4"> 320 <h2 class="text-lg font-semibold text-gray-800 w-full text-center mb-4"> 321 Calibration Settings 322 </h2> 323 <div class="flex flex-row w-full"> 324 <div class="grow"></div> 325 <button 326 id="measurementToggle" 327 class="text-sm font-medium text-blue-600 hover:text-blue-800 ml-2" 328 > 329 Switch to Metric 330 </button> 331 </div> 332 </div> 333 334 <!-- Imperial Inputs --> 335 <div id="imperialContainer"> 336 <!-- Height (Feet/Inches) --> 337 <div class="flex justify-between items-center mb-4"> 338 <div> 339 <p class="text-sm font-medium text-gray-900">Height</p> 340 </div> 341 <div class="flex items-center"> 342 <input 343 class="bg-white p-2 rounded-xl w-24 text-center mr-2" 344 placeholder="ft" 345 type="number" 346 id="feetInput" 347 min="0" 348 max="9" 349 step="1" 350 /> 351 <span class="mr-3">ft</span> 352 <input 353 class="bg-white p-2 rounded-xl w-24 text-center mr-2" 354 placeholder="in" 355 type="number" 356 id="inchesInput" 357 min="0" 358 max="12" 359 step="1" 360 /> 361 <span>in</span> 362 </div> 363 </div> 364 365 <!-- Weight (lbs) --> 366 <div class="flex justify-between items-center mb-4"> 367 <div> 368 <p class="text-sm font-medium text-gray-900">Weight</p> 369 </div> 370 <div class="flex items-center"> 371 <input 372 class="bg-white p-2 rounded-xl w-24 text-center mr-2" 373 placeholder="lbs" 374 type="number" 375 id="poundsInput" 376 min="0" 377 max="999" 378 step="1" 379 /> 380 <span>lbs</span> 381 </div> 382 </div> 383 </div> 384 385 <!-- Metric Inputs --> 386 <!-- Hide this container by default (e.g., via 'hidden') --> 387 <div id="metricContainer" class="hidden"> 388 <!-- Height (cm) --> 389 <div class="flex justify-between items-center mb-4"> 390 <div> 391 <p class="text-sm font-medium text-gray-900">Height</p> 392 </div> 393 <div class="flex items-center"> 394 <input 395 class="bg-white p-2 rounded-xl w-24 text-center mr-2" 396 placeholder="cm" 397 type="number" 398 id="centimetersInput" 399 min="0" 400 step="1" 401 /> 402 <span>cm</span> 403 </div> 404 </div> 405 406 <!-- Weight (kg) --> 407 <div class="flex justify-between items-center mb-4"> 408 <div> 409 <p class="text-sm font-medium text-gray-900">Weight</p> 410 </div> 411 <div class="flex items-center"> 412 <input 413 class="bg-white p-2 rounded-xl w-24 text-center mr-2" 414 placeholder="kg" 415 type="number" 416 id="kilogramsInput" 417 min="0" 418 max="999" 419 step="1" 420 />
421 <span>kg</span> 422 </div> 423 </div> 424 </div> 425 <div id="modalWarning" class="hidden flex flex-start font-medium text-red-500 mb-4 mt-4"> 426 Please set a height and weight to continue. 427 </div> 428 <div class="flex flex-col items-center justify-between mt-6 mb-4"> 429 <button 430 id="submitHeightWeight" 431 class="text-md bg-blue-500 font-medium text-white hover:bg-blue-600 p-3 w-24 rounded-xl" 432 > 433 Save 434 </button> 435 </div> 436 </div> 437</div> 438`;var ua;((a)=>{a[a.SETSIDE=0]="SETSIDE";a[a.CALIBRATE=1]="CALIBRATE";a[a.ANALYZING=2]="ANALYZING";a[a.CAPTURED=3]="CAPTURED"})(ua||={});class ca{vision;mode;record;stopwatch=null;landingTimeout=null;userHeight=null;userWeight=null;isMetric=!1;isBelowThreshold=!1;isCalibrationRequested=!1;pixelsToInches=0;initialFootHeight=0;maxFootHeight=Number.POSITIVE_INFINITY;singleLegTimeData=[];singleLegTakeoffLanding=[];takeoffKnee=null;landingKnee=null;doubleLegTimeData=[];doubleLegTakeoffLanding=[];doubleLegLeftTakeoff=null;doubleLegRightTakeoff=null;doubleLegLeftLanding=null;doubleLegRightLanding=null;isPatientCalibrationTimerStarted=!1;patientCalibrationTimer=null;uiState=ft({elapsedTime:0,verticalJumpHeight:0,showingCalibrateModal:!1,captureStatus:0,currentSide:3,jumpStatus:0,patientSide:null},()=>{this.updateState()});constructor(e,t){if(this.vision=e,this.mode=t,this.mode==="doubleleg")this.record=new Ti,e.getRecord((i)=>{if(this.record=i,this.record.leftData&&this.record.rightData)this.uiState.captureStatus=3;this.updateState()}),this.uiState.captureStatus=1,this.uiState.currentSide=2;else this.record=new Pi,e.getRecord((i)=>{if(this.record=i,this.record.leftData&&this.record.rightData)this.uiState.captureStatus=3;this.updateState()}),this.uiState.currentSide=3}showControls(e,t){$(e).html(this.mode==="doubleleg"?la:aa),$(t).html(this.mode==="doubleleg"?oa:ra),k("#vertJumpCalibrate",()=>{this.isCalibrationRequested=!0}),k("#vertJumpStop",()=>{this.reset()}),k("#vertJumpReset",()=>{this.reset()}),k("#vertJumpCaptureConfig",()=>{this.uiState.showingCalibrateModal=!0}),k("#vertJumpDismissModal",()=>{this.saveHeightWeight()}),k("#submitHeightWeight",()=>{this.saveHeightWeight()}),k("#leftReset",()=>{this.resetLeft()}),k("#rightReset",()=>{this.resetRight()}),k("#setLeft",()=>{this.uiState.currentSide=0,this.uiState.captureStatus=1}),k("#setRight",()=>{this.uiState.currentSide=1,this.uiState.captureStatus=1}),k("#measurementToggle",()=>{this.isMetric=!this.isMetric,$("#imperialContainer").toggleClass("hidden",this.isMetric),$("#metricContainer").toggleClass("hidden",!this.isMetric),$("#measurementToggle").text(this.isMetric?"Switch to Imperial":"Switch to Metric")}),setTimeout(()=>{this.uiState.showingCalibrateModal=!0},500)}process(e,t){let i=this.uiState.currentSide,s=e.topOfHeadY,a=e.midFeetY;if(i===0)t.drawPaths(e.paths,"left"),t.drawPoints(e.points,"left"),t.drawLabels(e.labels,"left");else if(i===1)t.drawPaths(e.paths,"right"),t.drawPoints(e.points,"right"),t.drawLabels(e.labels,"right");else t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels);if(this.isCalibrationRequested&&this.userHeight!==null&&s!==null&&a!==null){let o=Math.abs(s-a);if(this.pixelsToInches=this.userHeight/o,i===0)this.initialFootHeight=e.leftData?.footHeight??0;else if(i===1)this.initialFootHeight=e.rightData?.footHeight??0;else this.initialFootHeight=e.midFeetY??0;this.isCalibrationRequested=!1,this.uiState.captureStatus=2}if(this.uiState.captureStatus===2)this.processCapture(e,i)}processCapture(e,t){let i=0;if(this.mode==="doubleleg"){if(e.leftData&&e.rightData){i=e.midFeetY??0;let s={timestamp:Date.now(),footHeight:Math.abs(i-this.initialFootHeight)*this.pixelsToInches,midHipY:e.midHipY??0,backLateralFlex:e.backLateralFlexion??0,pelvicDrop:e.pelvicDrop??0,leftKnee:{kneeAlignment:e.leftData.kneeAlignment,kneeValue:e.leftData.kneeValue}
438,rightKnee:{kneeAlignment:e.rightData.kneeAlignment,kneeValue:e.rightData.kneeValue}};this.doubleLegTimeData.push(s),this.doubleLegTakeoffLanding.push(s)}}else{let s=t===0?e.leftData:e.rightData;if(s){i=s.footHeight??0;let a={timestamp:Date.now(),footHeight:Math.abs(i-this.initialFootHeight)*this.pixelsToInches,backLateralFlex:e.backLateralFlexion??0,pelvicDrop:e.pelvicDrop??0,midHipY:e.midHipY??0,knee:{kneeAlignment:s.kneeAlignment,kneeValue:s.kneeValue}};this.singleLegTimeData.push(a),this.singleLegTakeoffLanding.push(a)}}if(this.uiState.jumpStatus===0){let s=this.initialFootHeight*0.95;if(i<=s&&!this.isBelowThreshold)this.startStopwatch(),this.calculateTakeoffLanding("takeoff",this.mode==="doubleleg"?this.doubleLegTakeoffLanding:this.singleLegTakeoffLanding),this.maxFootHeight=Number.POSITIVE_INFINITY,this.uiState.jumpStatus=1,this.isBelowThreshold=!0}if(this.uiState.jumpStatus===1){if(i<this.maxFootHeight)this.maxFootHeight=i;if(i>=this.initialFootHeight)this.uiState.jumpStatus=2}if(this.uiState.jumpStatus===2){if(this.stopStopwatch(),!this.landingTimeout)this.startLandingTimer()}}saveHeightWeight(){let e,t;if(this.isMetric){let i=Number($("#centimetersInput").val())||0,s=Number($("#kilogramsInput").val())||0;if(i<=0||s<=0)return $("#modalWarning").removeClass("hidden"),!1;$("#modalWarning").addClass("hidden"),e=i*0.393701,t=s*2.20462}else{let i=Number($("#feetInput").val())||0,s=Number($("#inchesInput").val())||0,a=Number($("#poundsInput").val())||0;if(e=i*12+s,t=a,e<=0||t<=0)return $("#modalWarning").removeClass("hidden"),!1;$("#modalWarning").addClass("hidden")}return this.userHeight=e,this.userWeight=t,this.uiState.showingCalibrateModal=!1,!0}startLandingTimer(){if(this.landingTimeout)clearTimeout(this.landingTimeout);this.landingTimeout=setTimeout(()=>{this.calculateTakeoffLanding("landing",this.mode==="doubleleg"?this.doubleLegTakeoffLanding:this.singleLegTakeoffLanding),this.stopCapture(),this.landingTimeout=null},1500)}calculateTakeoffLanding(e,t){let i=null,s=Number.NEGATIVE_INFINITY;for(let a of t)if(a.midHipY>s)s=a.midHipY,i=a;if(i&&this.mode==="doubleleg"){let a=i;if(e==="takeoff")this.doubleLegLeftTakeoff={kneeAlignment:a.leftKnee.kneeAlignment,kneeValue:a.leftKnee.kneeValue},this.doubleLegRightTakeoff={kneeAlignment:a.rightKnee.kneeAlignment,kneeValue:a.rightKnee.kneeValue};else this.doubleLegLeftLanding={kneeAlignment:a.leftKnee.kneeAlignment,kneeValue:a.leftKnee.kneeValue},this.doubleLegRightLanding={kneeAlignment:a.rightKnee.kneeAlignment,kneeValue:a.rightKnee.kneeValue}}else if(i&&this.mode==="singleleg"){let a=i;if(e==="takeoff")this.takeoffKnee={kneeAlignment:a.knee.kneeAlignment,kneeValue:a.knee.kneeValue};else this.landingKnee={kneeAlignment:a.knee.kneeAlignment,kneeValue:a.knee.kneeValue}}this.doubleLegTakeoffLanding=[],this.singleLegTakeoffLanding=[]}async stopCapture(){if(this.uiState.verticalJumpHeight=(this.initialFootHeight-this.maxFootHeight)*this.pixelsToInches,this.record.userHeight=this.userHeight,this.record.userWeight=this.userWeight,this.record instanceof Ti)this.record.jumpHeight=this.uiState.verticalJumpHeight,this.record.hangTime=this.uiState.elapsedTime,this.record.timeData=this.doubleLegTimeData,this.record.leftData={kneeTakeoff:this.doubleLegLeftTakeoff??null,kneeLanding:this.doubleLegLeftLanding??null},this.record.rightData={kneeTakeoff:this.doubleLegRightTakeoff??null,kneeLanding:this.doubleLegRightLanding??null},this.uiState.captureStatus=3;else if(this.record instanceof Pi){let e={jumpHeight:this.uiState.verticalJumpHeight,hangTime:this.uiState.elapsedTime,kneeTakeoff:{kneeAlignment:this.takeoffKnee?.kneeAlignment??null,kneeValue:this.takeoffKnee?.kneeValue??null},kneeLanding:{kneeAlignment:this.landingKnee?.kneeAlignment??null,kneeValue:this.landingKnee?.kneeValue??null},timeData:this.singleLegTimeData};if(this.uiState.currentSide===0)this.record.leftData=e;else if(this.uiState.currentSide===1)this.record.rightData=e;let t=!!(this.record.leftData&&this.record.rightData);this.uiState.captureStatus=t?3:0}await this.vision.setRecord(this.record),this.resetVariables()}resetVariables(){this.uiState.elapsedTime=0,this.uiState.verticalJumpHeight=0,this.pixelsToInches=0,this.initialFootHeight=0,this.isBelowThreshold=!1,this.isCalibrationRequested=!1,this.singleLegTimeData=[],this.singleLegTakeoffLanding=[],this.takeoffKnee=null,this.landingKnee=null,this.doubleLegTimeData=[],this.doubleLegTakeoffLanding=[],this.doubleLegLeftTakeoff=null,this.doubleLegRightTakeoff=null,this.doubleLegLeftLanding=null,this.doubleLegRightLanding=null,this.maxFootHeight=Number.POSITIVE_INFINITY,this.uiState.currentSide=this.mode==="doubleleg"?2:3,this.uiState.jumpStatus=0}async reset(){this.record=this.mode==="doubleleg"?new Ti:new Pi,await this.vision.clearRecord(),this.resetVariables(),this.uiState.captureStatus=this.mode==="doubleleg"?1:0}async resetLeft(){this.record.leftData=null,this.resetVariables(),await this.vision.setRecord(this.record),this.uiState.captureStatus=0}async resetRight(){this.record.rightData=null,this.resetVariables(),await this.vision.setRecord(this.record),this.uiState.captureStatus=0}startStopwatch(){if(this.stopwatch)return;let e=Date.now();this.stopwatch=setInterval(()=>{let t=Date.now()-e;this.uiState.elapsedTime=t/1000},50)}stopStopwatch(){if(this.stopwatch)clearInterval(this.stopwatch),this.stopwatch=null}updateState(){switch(U("#setLeft",this.uiState.currentSide!==3||!!this.record.leftData),U("#setRight",this.uiState.currentSide!==3||!!this.record.rightData),U("#vertJumpCalibrate",this.uiState.captureStatus!==1),U("#vertJumpStop",this.uiState.captureStatus!==2),U("#vertJumpReset",this.uiState.captureStatus!==3),U("#leftReset",!this.record.leftData),U("#rightReset",!this.record.rightData),vt("#leftSLVertJumpData","border-blue-500","border-white",this.uiState.currentSide===0),vt("#rightSLVertJumpData","border-blue-500","border-white",this.uiState.currentSide===1),Rt("#vertJumpCaptureContainer","partial-fade",this.uiState.showingCalibrateModal),Rt("#vertJumpCaptureMod
438al","fade-out",!this.uiState.showingCalibrateModal),Rt("#vertJumpDismissModal","fade-out",!this.uiState.showingCalibrateModal),this.uiState.captureStatus){case 0:$("#vertJumpCaptureTypeHeader").text(""),$("#vertJumpCaptureTypeSubheader").text("");break;case 1:$("#vertJumpCaptureTypeHeader").text("Capture Status"),$("#vertJumpCaptureTypeSubheader").text("Please calibrate");break;case 2:$("#vertJumpCaptureTypeHeader").text("Capture Status"),$("#vertJumpCaptureTypeSubheader").text("Analyzing...");break;case 3:$("#vertJumpCaptureTypeHeader").text("Capture Status"),$("#vertJumpCaptureTypeSubheader").text("Analysis complete!");break}let e=(i,s,a,o)=>{$(i).text(s?`${s.toFixed(o)}${a}`:"--")},t=(i,s,a)=>{if(s&&a){let o=`${a.toFixed(1)}° ${s}`;$(i).text(o)}else $(i).text("--")};if(this.record instanceof Pi)e("#leftSLVertJumpData .vertHeight",this.record.leftData?.jumpHeight," inches",2),e("#leftSLVertJumpData .hangTime",this.record.leftData?.hangTime," sec.",2),t("#leftSLVertJumpData .takeoff",this.record.leftData?.kneeTakeoff.kneeAlignment,this.record.leftData?.kneeTakeoff.kneeValue),t("#leftSLVertJumpData .landing",this.record.leftData?.kneeLanding.kneeAlignment,this.record.leftData?.kneeLanding.kneeValue),e("#rightSLVertJumpData .vertHeight",this.record.rightData?.jumpHeight," inches",2),e("#rightSLVertJumpData .hangTime",this.record.rightData?.hangTime," sec.",2),t("#rightSLVertJumpData .takeoff",this.record.rightData?.kneeTakeoff.kneeAlignment,this.record.rightData?.kneeTakeoff.kneeValue),t("#rightSLVertJumpData .landing",this.record.rightData?.kneeLanding.kneeAlignment,this.record.rightData?.kneeLanding.kneeValue);if(this.record instanceof Ti)e("#vertJumpData .vertHeight",this.record.jumpHeight," inches",2),e("#vertJumpData .hangTime",this.record.hangTime," sec.",2),t("#leftData .leftTakeoff",this.record.leftData?.kneeTakeoff?.kneeAlignment,this.record.leftData?.kneeTakeoff?.kneeValue),t("#leftData .leftLanding",this.record.leftData?.kneeLanding?.kneeAlignment,this.record.leftData?.kneeLanding?.kneeValue),t("#rightData .rightTakeoff",this.record.rightData?.kneeTakeoff?.kneeAlignment,this.record.rightData?.kneeTakeoff?.kneeValue),t("#rightData .rightLanding",this.record.rightData?.kneeLanding?.kneeAlignment,this.record.rightData?.kneeLanding?.kneeValue)}patientSetup(e,t){if(e)this.uiState.currentSide=e==="left"?0:1;else this.uiState.currentSide=2}patientSetHeightWeight(e,t){this.userHeight=e,this.userWeight=t,this.uiState.captureStatus=1}patientProcess(e,t){let i=this.uiState.currentSide,s=e.topOfHeadY,a=e.midFeetY;if(i===0)t.drawPaths(e.paths,"left"),t.drawPoints(e.points,"left"),t.drawLabels(e.labels,"left");else if(i===1)t.drawPaths(e.paths,"right"),t.drawPoints(e.points,"right"),t.drawLabels(e.labels,"right");else t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels);if(!this.isPatientCalibrationTimerStarted)this.startPatientCalibrationTimer(),this.isPatientCalibrationTimerStarted=!0;if(this.calibratePatient(e,i,s,a),this.uiState.captureStatus===2)this.processCapture(e,i)}startPatientCalibrationTimer(){let e=5;this.patientCalibrationTimer=setInterval(()=>{if(e--,e<=0){if(this.patientCalibrationTimer)clearInterval(this.patientCalibrationTimer),this.patientCalibrationTimer=null;this.isCalibrationRequested=!0}},1000)}calibratePatient(e,t,i,s){if(this.isCalibrationRequested&&this.userHeight!==null&&i!==null&&s!==null){let a=Math.abs(i-s);if(this.pixelsToInches=this.userHeight/a,t===0)this.initialFootHeight=e.leftData?.footHeight??0;else if(t===1)this.initialFootHeight=e.rightData?.footHeight??0;else this.initialFootHeight=e.midFeetY??0;this.isCalibrationRequested=!1,this.uiState.captureStatus=2}}patientPause(){if(this.patientCalibrationTimer)clearInterval(this.patientCalibrationTimer),this.patientCalibrationTimer=null;this.uiState.elapsedTime=0,this.uiState.verticalJumpHeight=0,this.pixelsToInches=0,this.initialFootHeight=0,this.isBelowThreshold=!1,this.isCalibrationRequested=!1,this.maxFootHeight=Number.POSITIVE_INFINITY,this.singleLegTimeData=[],this.singleLegTakeoffLanding=[],this.takeoffKnee=null,this.landingKnee=null,this.doubleLegTimeData=[],this.doubleLegTakeoffLanding=[],this.doubleLegLeftTakeoff=null,this.doubleLegRightTakeoff=null,this.doubleLegLeftLanding=null,this.doubleLegRightLanding=null,this.uiState.jumpStatus=0,this.uiState.captureStatus=1,this.isPatientCalibrationTimerStarted=!1}patientData(e){if(e==="step")if(this.uiState.captureStatus===1)return 0;else return 1;else return 0}}var ie={};Et(ie,{AnteriorLungeController:()=>da,SagittalLungeController:()=>ga,programs:()=>zn});var ha=`<div class="bottom-controller-container"> 439 <div class="grow min-w-[1px]"></div> 440 <div id="leftLungeData" class="min-w-[320px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center border-4 border-white"> 441 <h3 class="col-span-6 font-bold text-lg">Left Lead</h3> 442 <div class="col-span-6 text-end"> 443 <button id="leftReset" class="hidden data-results-reset">
444 <span>Reset</span> 445 </button> 446 </div> 447 <div class="col-span-4 text-sm">Trunk lateral</div> 448 <div class="col-span-2 text-sm value trunkLateralFlexion">--</div> 449 <div class="col-span-4 text-sm">Knee align</div> 450 <div class="col-span-2 text-sm value kneeAlignment">--</div> 451 <div class="col-span-4 text-sm">Toe align</div> 452 <div class="col-span-2 text-sm value toeAlignment">--</div> 453 </div> 454 <div class="grow"></div> 455 <div id="rightLungeData" class="min-w-[320px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center border-4 border-white"> 456 <h3 class="col-span-6 font-bold text-lg">Right Lead</h3> 457 <div class="col-span-6 text-end"> 458 <button id="rightReset" class="hidden data-results-reset"> 459 <span>Reset</span> 460 </button> 461 </div> 462 <div class="col-span-4 text-sm">Trunk lateral</div> 463 <div class="col-span-2 text-sm value trunkLateralFlexion">--</div> 464 <div class="col-span-4 text-sm">Knee align</div> 465 <div class="col-span-2 text-sm value kneeAlignment">--</div> 466 <div class="col-span-4 text-sm">Toe align</div> 467 <div class="col-span-2 text-sm value toeAlignment">--</div> 468 </div> 469 <div class="grow min-w-[1px]"></div> 470</div>`;var pa=`<div class="top-controller-container"> 471 <div id="anteriorLungeCaptureContainer" class="capture-bar"> 472 <button id="anteriorLungeCapture" class="capture-bar-cta bg-green-400 hover:bg-green-500 text-green-900"> 473 <span>Start</span> 474 </button> 475 <button id="anteriorLungeReset" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 476 <span>Reset Both</span> 477 </button> 478 <button id="anteriorLungeStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 479 <span>Stop</span> 480 </button> 481 <div class="min-w-6"></div> 482 <div class="flex flex-col"> 483 <span id="anteriorLungeCaptureTypeHeader" class="text-xs mb-[-4px] pt-1">Capture Type</span> 484 <span id="anteriorLungeCaptureTypeSubheader" class="font-bold text-lg">Auto-capture</span> 485 </div> 486 <div class="min-w-6"></div> 487 </div> 488</div>`;class da{vision;uiState=ft({captureStatus:0,currentView:0,patientSide:null},()=>{this.updateState()});record=new Vn;baselineResults={};maxResults=null;maxSnapshot=null;maxLeadSide=null;maxDepth=Number.NEGATIVE_INFINITY;riseCount=0;riseThreshold=5;maxImageCanvas=document.createElement("canvas");maxPreviewCanvas=document.createElement("canvas");constructor(e){this.vision=e,e.getRecord((t)=>{this.record=t,this.updateState()})}showControls(e,t){$(e).html(pa),$(t).html(ha),k("#anteriorLungeCapture",()=>{this.uiState.captureStatus=1}),k("#anteriorLungeStop",()=>{this.resetVariables()}),k("#anteriorLungeReset",()=>{this.reset()}),k("#leftReset",()=>{this.resetLeftSide()}),k("#rightReset",()=>{this.resetRightSide()})}async process(e,t){if(this.drawResults(e,t),e.direction!=="front"&&this.uiState.currentView!==1)this.resetVariables(),this.uiState.currentView=1;else if(e.direction==="front"&&this.uiState.currentView!==0)this.resetVariables(),this.uiState.currentView=0;await this.processCapture(e)}async processCapture(e){if(this.uiState.captureStatus!==1)return;if(e.direction!=="front"||!e.isAligned)return;this.ensureBaseline(e);let t=this.inferLeadSide(e),i=this.maxLeadSide??this.uiState.patientSide??t;if(!i)return;if(!this.maxLeadSide&&(!t||this.uiState.patientSide&&t!==this.uiState.patientSide))return;if(i==="left"&&this.record.leftData||i==="right"&&this.record.rightData)return;let s=this.baselineResults[i],a=this.getSideData(e,i);if(!s||!a)return;if(!this.hasAnteriorMeasurement(a))return;let o=this.calculateDepth(e,s,i);if(o<this.minimumDepth(e,s))return;if(o>this.maxDepth){let l=this.captureMaxSnapshot();if(!l)return;this.maxDepth=o,this.maxResults=e,this.maxLeadSide=i,this.maxSnapshot=l,this.riseCount=0}else if(this.maxLeadSide===i&&o<=this.maxDepth*0.85&&this.maxResults){if(this.riseCount++,this.riseCount>=this.riseThreshold)await this.capture()}else this.riseCount=0}ensureBaseline(e){if(this.uiState.patientSide){this.ensureSideBaseline(e,this.uiState.patientSide);return}this.ensureSideBaseline(e,"left"),this.ensureSideBaseline(e,"right")}ensureSideBaseline(e,t){if(this.baselineResults[t])return;if(!this.getSideData(e,t))return;this.baselineResults[t]=e}inferLeadSide(e){let{leftKneeY:t,rightKneeY:i}=e;if(typeof t!=="number"||typeof i!=="number")return null;return t<=i?"left":"right"}calculateDepth(e,t,i){let s=(e.midHipY??0)-(t.midHipY??0),a=this.oppositeSide(i),o=a==="left"?e.leftKneeY:e.rightKneeY,l=a==="left"?t.leftKneeY:t.rightKneeY,c=(o??0)-(l??0);return Math.max(s,c)}oppositeSide(e){return e==="left"?"right":"left"}minimumDepth(e,t){return Math.max(e.bodyHeight??0,t.bodyHeight??0,1)*0.04}
488captureMaxSnapshot(){return this.vision.captureCurrentFrameSnapshot({includeDisplayFrame:!0,recordCanvas:this.maxImageCanvas,displayCanvas:this.maxPreviewCanvas})}async getMaxImageBlob(){if(!this.maxSnapshot)return null;return await this.vision.encodeCaptureSnapshotImage(this.maxSnapshot,{setPreviewAsLastCapture:!0})}async capture(){if(!this.maxResults||!this.maxLeadSide)return;let e=this.maxLeadSide,t=this.baselineResults[e],i=this.getSideData(this.maxResults,e);if(!t||!i)return;let s=await this.getMaxImageBlob();if(e==="left"){if(this.record.leftData=i,s)this.record.leftImage=s,this.setPoseFrame("left")}else if(this.record.rightData=i,s)this.record.rightImage=s,this.setPoseFrame("right");await this.vision.setRecord(this.record);let a=!!(this.record.leftData&&this.record.rightData);this.uiState.captureStatus=a?2:0,this.resetCaptureTracking()}setPoseFrame(e){let t=e==="left"?"leftImage":"rightImage";if(this.maxSnapshot)this.record.setPoseFrame(this.maxSnapshot.getPoseFrame({imageKey:t,side:e}))}getSideData(e,t){return t==="left"?e.leftData:e.rightData}hasAnteriorMeasurement(e){return typeof e.trunkLateralFlexion==="number"}drawResults(e,t){let i=this.maxLeadSide??this.uiState.patientSide??this.inferLeadSide(e);if(i){t.drawLabels(e.labels,i),t.drawPaths(e.paths,i),t.drawPoints(e.points,i);return}t.drawLabels(this.unscopedOverlays(e.labels)),t.drawPaths(this.unscopedOverlays(e.paths)),t.drawPoints(this.unscopedOverlays(e.points))}unscopedOverlays(e){return e.filter((t)=>!t.side)}resetVariables(){this.uiState.captureStatus=0,this.resetCaptureTracking()}resetCaptureTracking(){this.maxResults=null,this.maxSnapshot=null,this.maxLeadSide=null,this.maxDepth=Number.NEGATIVE_INFINITY,this.riseCount=0,this.baselineResults={}}async reset(){this.record=new Vn,await this.vision.clearRecord(),this.resetVariables()}async resetLeftSide(){this.record.leftData=null,this.record.leftImage=null,this.record.clearRecord("left"),await this.vision.setRecord(this.record),this.resetVariables()}async resetRightSide(){this.record.rightData=null,this.record.rightImage=null,this.record.clearRecord("right"),await this.vision.setRecord(this.record),this.resetVariables()}updateState(){switch(U("#anteriorLungeCapture",this.uiState.captureStatus!==0),U("#anteriorLungeStop",this.uiState.captureStatus!==1),U("#anteriorLungeReset",this.uiState.captureStatus!==2),U("#leftReset",!this.record.leftData),U("#rightReset",!this.record.rightData),vt("#leftLungeData","border-blue-500","border-white",this.maxLeadSide==="left"),vt("#rightLungeData","border-blue-500","border-white",this.maxLeadSide==="right"),this.uiState.captureStatus){case 0:$("#anteriorLungeCaptureTypeHeader").text("Capture Type"),$("#anteriorLungeCaptureTypeSubheader").text("Auto-capture");break;case 1:$("#anteriorLungeCaptureTypeHeader").text("Capture Status"),$("#anteriorLungeCaptureTypeSubheader").text("Analyzing...");break;case 2:$("#anteriorLungeCaptureTypeSubheader").text("Captured!");break}this.updateSideDisplay("#leftLungeData",this.record.leftData),this.updateSideDisplay("#rightLungeData",this.record.rightData)}updateSideDisplay(e,t){this.formatDegrees(`${e} .trunkLateralFlexion`,t?.trunkLateralFlexion),this.formatAlignment(`${e} .kneeAlignment`,t?.kneeAlignment,t?.kneeValue),this.formatAlignment(`${e} .toeAlignment`,t?.toeAlignment,t?.toeValue)}formatDegrees(e,t){$(e).text(typeof t==="number"?`${Math.abs(t).toFixed(1)}°`:"--")}formatAlignment(e,t,i){$(e).text(t&&typeof i==="number"?`${i.toFixed(1)}° ${t}`:"--")}patientSetup(e){this.uiState.patientSide=e??null,this.uiState.captureStatus=1}async patientProcess(e,t){this.drawResults(e,t),await this.processCapture(e)}patientPause(){this.resetVariables(),this.uiState.captureStatus=1}patientData(e){if(e==="step")return 0;return 0}}var ma=`<div class="bottom-controller-container"> 489 <div class="grow min-w-[1px]"></div> 490 <div id="sagittalLeftLungeData" class="min-w-[455px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center border-4 border-white"> 491 <h3 class="col-span-6 font-bold text-lg">Left Lead</h3> 492 <div class="col-span-6 text-end"> 493 <button id="leftReset" class="hidden data-results-reset">
494 <span>Reset</span> 495 </button> 496 </div> 497 <div class="col-span-4 text-sm">Knee flexion</div> 498 <div class="col-span-2 text-sm value leadKneeFlexion">--</div> 499 <div class="col-span-4 text-sm">Hip flexion</div> 500 <div class="col-span-2 text-sm value leadHipFlexion">--</div> 501 <div class="col-span-4 text-sm">Ankle dorsiflexion</div> 502 <div class="col-span-2 text-sm value leadAnkleDorsiFlexion">--</div> 503 <div class="col-span-4 text-sm">Trunk lean</div> 504 <div class="col-span-2 text-sm value trunkForwardLean">--</div> 505 <div class="col-span-4 text-sm">Rear hip deficit</div> 506 <div class="col-span-2 text-sm value rearHipExtensionDeficit">--</div> 507 <div class="col-span-4 text-sm">Step length</div> 508 <div class="col-span-2 text-sm value stepLengthRatio">--</div> 509 </div> 510 <div class="grow"></div> 511 <div id="sagittalRightLungeData" class="min-w-[455px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center border-4 border-white"> 512 <h3 class="col-span-6 font-bold text-lg">Right Lead</h3> 513 <div class="col-span-6 text-end"> 514 <button id="rightReset" class="hidden data-results-reset"> 515 <span>Reset</span> 516 </button> 517 </div> 518 <div class="col-span-4 text-sm">Knee flexion</div> 519 <div class="col-span-2 text-sm value leadKneeFlexion">--</div> 520 <div class="col-span-4 text-sm">Hip flexion</div> 521 <div class="col-span-2 text-sm value leadHipFlexion">--</div> 522 <div class="col-span-4 text-sm">Ankle dorsiflexion</div> 523 <div class="col-span-2 text-sm value leadAnkleDorsiFlexion">--</div> 524 <div class="col-span-4 text-sm">Trunk lean</div> 525 <div class="col-span-2 text-sm value trunkForwardLean">--</div> 526 <div class="col-span-4 text-sm">Rear hip deficit</div> 527 <div class="col-span-2 text-sm value rearHipExtensionDeficit">--</div> 528 <div class="col-span-4 text-sm">Step length</div> 529 <div class="col-span-2 text-sm value stepLengthRatio">--</div> 530 </div> 531 <div class="grow min-w-[1px]"></div> 532</div>`;var fa=`<div class="top-controller-container"> 533 <div id="sagittalLungeCaptureContainer" class="capture-bar"> 534 <button id="sagittalLungeCapture" class="capture-bar-cta bg-green-400 hover:bg-green-500 text-green-900"> 535 <span>Start</span> 536 </button> 537 <button id="sagittalLungeReset" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 538 <span>Reset Both</span> 539 </button> 540 <button id="sagittalLungeStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 541 <span>Stop</span> 542 </button> 543 <div class="min-w-6"></div> 544 <div class="flex flex-col"> 545 <span id="sagittalLungeCaptureTypeHeader" class="text-xs mb-[-4px] pt-1">Capture Type</span> 546 <span id="sagittalLungeCaptureTypeSubheader" class="font-bold text-lg">Auto-capture</span> 547 </div> 548 <div class="min-w-6"></div> 549 </div> 550</div>`;class ga{vision;uiState=ft({captureStatus:0,currentSide:null,patientSide:null},()=>{this.updateState()});record=new Wn;baselineResults={};maxResults=null;maxSnapshot=null;maxLeadSide=null;maxDepthScore=Number.NEGATIVE_INFINITY;extensionCount=0;extensionThreshold=5;depthScoreImprovementThreshold=2;maxImageCanvas=document.createElement("canvas");maxPreviewCanvas=document.createElement("canvas");constructor(e){this.vision=e,e.getRecord((t)=>{this.record=t,this.updateState()})}showControls(e,t){$(e).html(fa),$(t).html(ma),k("#sagittalLungeCapture",()=>{this.uiState.captureStatus=1}),k("#sagittalLungeStop",()=>{this.resetVariables()}),k("#sagittalLungeReset",()=>{this.reset()}),k("#leftReset",()=>{this.resetLeftSide()}),k("#rightReset",()=>{this.resetRightSide()})}async process(e,t){t.drawLabels(e.labels),t.drawPaths(e.paths),t.drawPoints(e.points);let i=this.visibleSide(e);if(i&&i!==this.uiState.currentSide){if(this.uiState.currentSide)this.resetVariables();this.uiState.currentSide=i}await this.processCapture(e)}async processCapture(e){if(this.uiState.captureStatus!==1)return;if(!e.isAligned)return;let t=this.visibleSide(e);if(!t)return;if(this.uiState.patientSide&&t!==this.uiState.patientSide)return;if(t==="left"&&this.record.leftData||t==="right"&&this.record.rightData)return;this.ensureBaseline(e,t);let i=this.baselineResults[t],s=this.getSideData(e,t);if(!i||!s)return;let a=this.calculateDepthScore(e,i,s);if(this.isBottomCandidate(e,i,s)&&this.isMeaningfullyDeeper(a)){let o=this.captureMaxSnapsh
550ot();if(!o)return;this.maxDepthScore=a,this.maxResults=e,this.maxLeadSide=t,this.maxSnapshot=o,this.extensionCount=0}else if(this.maxLeadSide===t&&a<=this.maxDepthScore*0.85&&this.maxResults){if(this.extensionCount++,this.extensionCount>=this.extensionThreshold)await this.capture()}else this.extensionCount=0}isMeaningfullyDeeper(e){return!this.maxSnapshot||e>=this.maxDepthScore+this.depthScoreImprovementThreshold}visibleSide(e){if(e.direction==="leftSide")return"left";if(e.direction==="rightSide")return"right";return null}ensureBaseline(e,t){if(this.baselineResults[t])return;this.baselineResults[t]=e}isBottomCandidate(e,t,i){let{leadKneeFlexion:s,stepLengthRatio:a}=i;if(typeof s!=="number"||typeof a!=="number")return!1;if(s<70||s>135)return!1;if(a<0.35)return!1;let o=Math.max(e.bodyHeight??0,t.bodyHeight??0,1),l=this.calculateHipDepth(e,t),c=this.getRearKneeFloorClearanceRatio(e,this.visibleSide(e));return l>=o*0.04||typeof c==="number"&&c<=0.35}calculateDepthScore(e,t,i){let s=Math.max(e.bodyHeight??0,t.bodyHeight??0,1),a=Math.max(0,this.calculateHipDepth(e,t)/s),o=typeof i.leadKneeFlexion==="number"?i.leadKneeFlexion:0,l=this.getRearKneeFloorClearanceRatio(e,this.visibleSide(e)),c=typeof l==="number"?Math.max(0,0.4-l)*100:0;return o+a*100+c}getRearKneeFloorClearanceRatio(e,t){if(t==="left")return e.leftRearKneeFloorClearanceRatio;if(t==="right")return e.rightRearKneeFloorClearanceRatio;return null}calculateHipDepth(e,t){return(e.midHipY??0)-(t.midHipY??0)}captureMaxSnapshot(){return this.vision.captureCurrentFrameSnapshot({includeDisplayFrame:!0,recordCanvas:this.maxImageCanvas,displayCanvas:this.maxPreviewCanvas})}async getMaxImageBlob(){if(!this.maxSnapshot)return null;return await this.vision.encodeCaptureSnapshotImage(this.maxSnapshot,{setPreviewAsLastCapture:!0})}async capture(){if(!this.maxResults||!this.maxLeadSide)return;let e=this.maxLeadSide,t=this.getSideData(this.maxResults,e);if(!t)return;let i=await this.getMaxImageBlob();if(e==="left"){if(this.record.leftData=t,i)this.record.leftImage=i,this.setPoseFrame("left")}else if(this.record.rightData=t,i)this.record.rightImage=i,this.setPoseFrame("right");await this.vision.setRecord(this.record);let s=!!(this.record.leftData&&this.record.rightData);this.uiState.captureStatus=s?2:0,this.resetCaptureTracking()}setPoseFrame(e){let t=e==="left"?"leftImage":"rightImage";if(this.maxSnapshot)this.record.setPoseFrame(this.maxSnapshot.getPoseFrame({imageKey:t,side:e}))}getSideData(e,t){return t==="left"?e.leftData:e.rightData}resetVariables(){this.uiState.captureStatus=0,this.resetCaptureTracking()}resetCaptureTracking(){this.maxResults=null,this.maxSnapshot=null,this.maxLeadSide=null,this.maxDepthScore=Number.NEGATIVE_INFINITY,this.extensionCount=0,this.baselineResults={}}async reset(){this.record=new Wn,await this.vision.clearRecord(),this.resetVariables()}async resetLeftSide(){this.record.leftData=null,this.record.leftImage=null,this.record.clearRecord("left"),await this.vision.setRecord(this.record),this.resetVariables()}async resetRightSide(){this.record.rightData=null,this.record.rightImage=null,this.record.clearRecord("right"),await this.vision.setRecord(this.record),this.resetVariables()}updateState(){switch(U("#sagittalLungeCapture",this.uiState.captureStatus!==0),U("#sagittalLungeStop",this.uiState.captureStatus!==1),U("#sagittalLungeReset",this.uiState.captureStatus!==2),U("#leftReset",!this.record.leftData),U("#rightReset",!this.record.rightData),vt("#sagittalLeftLungeData","border-blue-500","border-white",this.uiState.currentSide==="left"),vt("#sagittalRightLungeData","border-blue-500","border-white",this.uiState.currentSide==="right"),this.uiState.captureStatus){case 0:$("#sagittalLungeCaptureTypeHeader").text("Capture Type"),$("#sagittalLungeCaptureTypeSubheader").text("Auto-capture");break;case 1:$("#sagittalLungeCaptureTypeHeader").text("Capture Status"),$("#sagittalLungeCaptureTypeSubheader").text("Analyzing...");break;case 2:$("#sagittalLungeCaptureTypeSubheader").text("Captured!");break}this.updateSideDisplay("#sagittalLeftLungeData",this.record.leftData),this.updateSideDisplay("#sagittalRightLungeData",this.record.rightData)}updateSideDisplay(e,t){this.formatDegrees(`${e} .leadKneeFlexion`,t?.leadKneeFlexion),this.formatDegrees(`${e} .leadHipFlexion`,t?.leadHipFlexion),this.formatDegrees(`${e} .leadAnkleDorsiFlexion`,t?.leadAnkleDorsiFlexion),this.formatDegrees(`${e} .trunkForwardLean`,t?.trunkForwardLean),this.formatDegrees(`${e} .rearHipExtensionDeficit`,t?.rearHipExtensionDeficit),this.formatStepLength(`${e} .stepLengthRatio`,t?.stepLengthRatio)}formatDegrees(e,t){$(e).text(typeof t==="number"?`${t.toFixed(1)}°`:"--")}formatStepLength(e,t){$(e).text(typeof t==="number"?`${t.toFixed(2)}x leg length`:"--")}patientSetup(e){this.uiState.patientSide=e??null,this.uiState.currentSide=e??null,this.uiState.captureStatus=1}async patientProcess(e,t){t.drawLabels(e.labels),t.drawPaths(e.paths),t.drawPoints(e.points),await this.processCapture(e)}patientPause(){this.resetVariables(),this.uiState.captureStatus=1}patientData(e){if(e==="step")return 0;return 0}}var zn={};Et(zn,{AnteriorLunge:()=>Ra,SagittalLunge:()=>ya});class Ce{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_hip"),a=n.getJointPosition(e,"right_shoulder"),o=n.getJointPosition(e,"right_hip"),l=n.getMiddlePoint(i,a),c=n.getMiddlePoint(s,o),p=n.pointDistance(c,l),m={x:c.x,y:c.y-p},g=n.calculateSlope(m,c),d=n.calculateSlope(l,c),S=n.calculateAngle(c,m,l,!0);if(t.isAligned)if(t.points.push(c),t.points.push(l),t.points.push(m),S>0&&S<=100)t.leftData=S,t.labels.push({position:l,value:t.leftData,side:"left",offset:{x:150,y:0}}),t.paths.push(n.makeArcPath(c,l,m,p,g,d,!1));else t.rightData=360-S,t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:-150,y:0}}),t.paths.push(n.makeArcPath(c,l,m,p,g,d,!0));return t}}class He{runProgram(e){let t=new Sa;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_ankle"),s=n.getJointPosition(e,"left_knee"),a=n.getJointPosition(e,"right_ankle"),o=n.getJointPosition(e,"right_knee"),l=n.pointDistance(i,s),c={x:i.x,y:i.y-l},p=n.calculateSlope(c,i),m=n.calculateSlope(s,i),g=n.pointDistance(a,o),d={x:a.x,y:a.y-g},S=n.calculateSlope(d,a),v=n.calculateSlope(o,a);if(t.isAligned){if(t.points.push({...i,color:C.blue,side:"left"}),t.points.push({...s,color:C.blue,side:"left"}),t.points.push({...c,color:C.blue,side:"left"}),t.paths.push(n.makeArcPath(i,s,c,l,p,m,m<p,"left",C.blue)),t.points.push({...a,color:C.blue,side:"right"}),t.points.push({...o,color:C.blue,side:"right"}),t.points.push({...d,color:C.blue,side:"right"}),t.paths.push(n.makeArcPath(a,o,d,g,S,v,v<S,"right",C.blue)),t.leftData.kneeValue=Math.abs(p-m),Math.abs(p-m)<=5)t.leftData.kneeAlignment="neutral";else if(m<p)t.leftData.kneeAlignment="valgus";else if(m>p)t.leftData.kneeAlignment="varus";if(t.rightData.kneeValue=Math.abs(S-v),Math.abs(S-v)<=5)t.rightData.kneeAlignment="neutral";else if(v<S)t.rightData.kneeAlignment="varus";else if(v>S)t.rightData.kneeAlignment="valgus";t.labels.push({position:s,value:`${t.leftData.kneeValue.toFixed(1)}° ${t.leftData.kneeAlignment}`,side:"left",offset:{x:150,y:0},color:C.blue}),t.labels.push({position:o,value:`${t.rightData.kneeValue.toFixed(1)}° ${t.rightData.kneeAlignment}`,side:"right",offset:{x:-150,y:0},color:C.blue})}return t}}class Oe{runProgram(e){let t=new va;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.pointDistance(i,s),o={x:i.x-a,y:i.y},l=n.calculateSlope(o,i),c=n.calculateSlope(s,i),p=n.calculateAngle(i,s,o,!0)-360,m=n.pointDistance(s,i),g={x:s.x+m,y:s.y},d=n.calculateSlope(g,s),S=n.calculateSlope(i,s),v=n.calculateAngle(s,g,i,!0)-360;if(t.isAligned){if(t.points.push({...i,color:C.orange}),t.points.push({...s,color:C.orange}),c>0)t.points.push({...o,color:C.orange}),t.paths.push(n.makeArcPath(i,s,o,a,l,c,!0,void 0,C.orange)),t.rightPelvicDrop=Math.abs(v),t.labels.push({position:i,value:t.rightPelvicDrop,offset:{x:100,y:0},color:C.orange});if(S>0)t.points.push({...g,color:C.orange}),t.paths.push(n.makeArcPath(s,i,g,m,d,S,!1,void 0,C.orange)),t.leftPelvicDrop=Math.abs(p),t.labels.push({position:s,value:t.leftPelvicDrop,offset:{x:-100,y:0},color:C.orange})}return t}}class ve{runProgram(e){let t=new xa;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_ankle"),s=n.getJointPosition(e,"left_foot_index"),a=n.calculateSlope(i,s),o=n.getJointPosition(e,"right_ankle"),l=n.getJointPosition(e,"right_foot_index"),c=n.calculateSlope(o,l);if(t.isAligned){if(t.points.push({...i,color:C.purple,side:"left"}),t.points.push({...s,color:C.purple,side:"left"}),t.paths.push(n.makeLinePath(i,s,"left",void 0,C.purple)),t.points.push({...o,color:C.purple,side:"right"}),t.points.push({...l,color:C.purple,side:"right"}),t.paths.push(n.makeLinePath(o,l,"right",void 0,C.purple)),t.leftData.toeValue=Math.abs(a+90),Math.abs(a+90)<=5)t.leftData.toeAlignment="neutral";else if(a+90>5)t.leftData.toeAlignment="inward";else if(a+90<-5)t.leftData.toeAlignment="outward";if(t.rightData.toeValue=Math.abs(c+90),Math.abs(c+90)<=5)t.rightData.toeAlignment="neutral";else if(c+90>5)t.rightData.toeAlignment="outward";else if(c+90<-5)t.rightData.toeAlignment="inward";t.labels.push({position:s,value:`${t.leftData.toeValue.toFixed(1)}° ${t.leftData.toeAlignment}`,side:"left",offset:{x:150,y:0},color:C.purple}),t.labels.push({position:l,value:`${t.rightData.toeValue.toFixed(1)}° ${t.rightData.toeAlignment}`,side:"right",offset:{x:-150,y:0},color:C.purple})}return t}}class $n{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_elbow"),a=n.getJointPosition(e,"left_wrist"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_elbow"),c=n.getJointPosition(e,"right_wrist"),p=Math.min(n.pointDistance(i,s),n.pointDistance(s,a)),m=n.calculateSlope(i,s),g=n.calculateSlope(a,s),d=n.endPointForSlopeAndDist(s,p,m),S=n.endPointForSlopeAndDist(s,p,g),v=180-n.calculateAngle(s,a,i,!0),P=Math.min(n.pointDistance(o,l),n.pointDistance(l,c)),b=n.calculateSlope(o,l),D=n.calculateSlope(c,l),A=n.endPointForSlopeAndDist(l,P,b),I=n.endPointForSlopeAndDist(l,P,D),F=180-n.calculateAngle(l,o,c,!0);if(t.isAligned)t.points.push(d),t.points.push(s),t.points.push(S),t.leftData=v,t.points.push(A),t.points.push(l),t.points.push(I),t.rightData=F;return t}}class Ne{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_hip"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_hip"),c=n.getJointPosition(e,"right_knee"),p=n.getMiddlePoint(i,s),m=n.getMiddlePoint(o,l),g=n.pointDistance(s,p),d=n.calculateSlope(p,s),S=n.calculateSlope(a,s),v=n.calculateAngle(s,a,p,!1)-180,P=n.pointDistance(l,m),b=n.calculateSlope(m,l),D=n.calculateSlope(c,l),A=n.calculateAngle(l,m,c,!1)-180;if(t.isAligned&&t.direction==="leftSide"){if(v>0)t.leftData=v,t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:100,y:0},color:C.orange});t.points.push({...s,color:C.orange,side:"left"}),t.points.push({...p,color:C.red,side:"left"}),t.paths.push(n.makeArcPath(s,a,p,g*0.5,d,S,!0,"left",C.orange))}else if(t.isAligned&&t.direction==="rightSide"){if(A>0)t.rightData=A,t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:-100,y:0},color:C.orange});t.points.push({...l,color:C.orange,side:"right"}),t.points.push({...m,color:C.red,side:"right"}),t.paths.push(n.makeArcPath(l,c,m,P*0.5,b,D,!1,"right",C.orange))}return t}}class ke{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_knee"),a=n.getJointPosition(e,"left_ankle"),o=n.getJointPosition(e,"right_hip"),l=n.getJointPosition(e,"right_knee"),c=n.getJointPosition(e,"right_ankle"),p=Math.min(n.pointDistance(i,s),n.pointDistance(s,a)),m={x:s.x,y:s.y+p},g=n.calculateSlope(i,s),d=n.calculateSlope(m,s),S=n.endPointForSlopeAndDist(s,p,g),v=180-n.calculateAngle(s,m,i,!1),P=Math.min(n.pointDistance(o,l),n.pointDistance(l,c)),b={x:l.x,y:l.y+P},D=n.calculateSlope(o,l),A=n.calculateSlope(b,l),I=n.endPointForSlopeAndDist(l,P,D),F=180-n.calculateAngle(l,b,o,!0);if(t.isAligned&&t.direction==="leftSide"){if(v>=-20&&v<=200){if(v>0)t.leftData=v,t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:-100,y:0},color:C.blue});t.points.push({...s,color:C.blue,side:"left"}),t.points.push({...m,color:C.blue,side:"left"}),t.paths.push(n.makeArcPath(s,m,S,p*0.4,g,d,!1,"left",C.blue))}}else if(t.isAligned&&t.direction==="rightSide"){if(F>
550=-20&&F<=200){if(F>0)t.rightData=F,t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:100,y:0},color:C.blue});t.points.push({...l,color:C.blue,side:"right"}),t.points.push({...b,color:C.blue,side:"right"}),t.paths.push(n.makeArcPath(l,b,I,P*0.4,D,A,!0,"right",C.blue))}}return t}}class jn{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_elbow"),a=n.getJointPosition(e,"left_hip"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_elbow"),c=n.getJointPosition(e,"right_hip"),p=n.getMiddlePoint(i,o),m=n.getMiddlePoint(a,c),g=n.calculateSlope(m,p),d=n.pointDistance(i,s),S=n.endPointForSlopeAndDist(i,d,g),v=n.calculateSlope(S,i),P=n.calculateSlope(s,i),b=n.calculateAngle(i,S,s,!0),D=n.pointDistance(o,l),A=n.endPointForSlopeAndDist(o,D,g),I=n.calculateSlope(A,o),F=n.calculateSlope(l,o),M=n.calculateAngle(o,A,l,!1);if(t.isAligned&&t.direction==="leftSide"){if(b>=0&&b<=200){if(b>0)t.leftData=b,t.labels.push({position:n.getArcMidpoint(i,d*0.5,v,P,!1),value:t.leftData,side:"right",offset:{x:-100,y:0},color:C.purple});t.points.push({...s,color:C.purple,side:"left"}),t.paths.push(n.makeArcPath(i,s,S,d*0.5,v,P,!1,"left",C.purple))}}else if(t.isAligned&&t.direction==="rightSide"){if(M>
550=0&&M<=200){if(M>0)t.rightData=M,t.labels.push({position:n.getArcMidpoint(o,D*0.5,I,F,!0),value:t.rightData,side:"left",offset:{x:100,y:0},color:C.purple});t.points.push({...l,color:C.purple,side:"right"}),t.paths.push(n.makeArcPath(o,l,A,D*0.5,I,F,!0,"right",C.purple))}}return t}}class Ke{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_shoulder"),a=n.getJointPosition(e,"right_hip"),o=n.getJointPosition(e,"right_shoulder"),l=n.pointDistance(i,s),c={x:i.x,y:i.y-l},p=n.calculateAngle(i,s,c,!0),m=n.pointDistance(a,o),g={x:a.x,y:a.y-m},d=n.calculateAngle(a,g,o,!0),S=n.getMiddlePoint(i,s),v=n.getMiddlePoint(a,o);if(t.isAligned&&t.direction==="leftSide"){if(p>=0&&p<=200)t.leftData=p,t.labels.push({position:S,value:t.leftData,side:"left",offset:{x:100,y:0},color:C.red});t.points.push({...s,color:C.purple,side:"left"})}else if(t.isAligned&&t.direction==="rightSide"){if(d>=0&&d<=200)t.rightData=d,t.labels.push({position:v,value:t.rightData,side:"right",offset:{x:-100,y:0},color:C.red});t.points.push({...o,color:C.purple,side:"right"})}return t}}var mc=5;class Yn{runProgram(e){let t=new Ta;if(t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front",!t.isAligned)return t;let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_knee"),a=n.getJointPosition(e,"left_ankle"),o=n.getJointPosition(e,"right_hip"),l=n.getJointPosition(e,"right_knee"),c=n.getJointPosition(e,"right_ankle");return this.addSide(t,"left",i,s,a),this.addSide(t,"right",o,l,c),t}addSide(e,t,i,s,a){let o=this.signedDeviation(i,s,a,t);if(o===null)return;let l=Math.abs(o),c=this.classify(l,o),p={kneeAlignment:c,kneeValue:l};if(t==="left")e.leftData=p;else e.rightData=p;e.points.push({...i,color:C.blue,side:t},{...s,color:C.blue,side:t},{...a,color:C.blue,side:t}),e.paths.push(n.makeLinePath(i,s,t,void 0,C.blue),n.makeLinePath(s,a,t,void 0,C.blue)),this.addArc(e,t,i,s,a),e.labels.push({position:s,value:`${l.toFixed(1)}° ${c}`,side:t,offset:t==="left"?{x:150,y:0}:{x:-150,y:0},color:C.blue})}signedDeviation(e,t,i,s){let a=this.hipKneeAnkleDeviation(e,t,i),o=this.signedKneeOffset(e,t,i,s);if(a===null||o===null)return null;return a*Math.sign(o||1)}hipKneeAnkleDeviation(e,t,i){let s=n.pointDistance(e,t),a=n.pointDistance(t,i);if(s===0||a===0)return null;let o=n.calculateAngle(t,e,i),l=o>180?360-o:o;return Math.abs(180-l)}signedKneeOffset(e,t,i,s){if(n.pointDistance(e,i)===0)return null;let a=this.projectPointToLine(t,e,i),o=s==="left"?-1:1;return(t.x-a.x)*o}classify(e,t){if(e<=mc)return"neutral";return t>0?"valgus":"varus"}addArc(e,t,i,s,a){let o=Math.min(n.pointDistance(i,s),n.pointDistance(a,s))*0.24;if(o<=0)return;let l=n.calculateSlope(i,s),c=n.calculateSlope(a,s),p=n.endPointForSlopeAndDist(s,o,l),m=n.endPointForSlopeAndDist(s,o,c);e.paths.push(n.makeArcPath(s,p,m,o,l,c,this.smallArcIsAnticlockwise(l,c),t,C.blue))}projectPointToLine(e,t,i){let s=i.x-t.x,a=i.y-t.y,o=s*s+a*a;if(o===0)return t;let l=((e.x-t.x)*s+(e.y-t.y)*a)/o;return{x:t.x+l*s,y:t.y+l*a}}smallArcIsAnticlockwise(e,t){return Math.abs(this.arcRange(e,t,!0))<Math.abs(this.arcRange(e,t,!1))}arcRange(e,t,i){let s=t-e;if(i&&s>0)s-=360;else if(!i&&s<0)s+=360;return s}}class Ra{runProgram(e){let t=new Pa;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_hip"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"left_ankle"),l=n.getJointPosition(e,"right_shoulder"),c=n.getJointPosition(e,"right_hip"),p=n.getJointPosition(e,"right_knee"),m=n.getJointPosition(e,"right_ankle"),g=n.getMiddlePoint(s,c),d=n.getMiddlePoint(i,l),S=n.getMiddlePoint(o,m);if(t.midHipY=g.y,t.bodyHeight=Math.max(n.pointDistance(d,S),1),t.leftKneeY=a.y,t.rightKneeY=p.y,t.leftAnkleX=o.x,t.rightAnkleX=m.x,!t.isAligned)return t;let v=new Yn().runProgram(e),P=new ve().runProgram(e);return t.leftData={...v.leftData,...P.leftData,trunkLateralFlexion:this.trunkLateralFlexion(s,c,g,d)},t.rightData={...v.rightData,...P.rightData,trunkLateralFlexion:this.trunkLateralFlexion(c,s,g,d)},t.points.push({...i,color:C.red},{...l,color:C.red},{...s,color:C.orange},{...c,color:C.orange},{...g,color:C.red},{...d,color:C.red},...v.points,...P.points),t.paths.push(n.makeLinePath(i,l,void 0,void 0,C.red),n.makeLinePath(s,c,void 0,void 0,C.orange),n.makeLinePath(g,d,void 0,void 0,C.red),...v.paths,...P.paths),this.addTrunkLabel(t,"left",g,t.leftData.trunkLateralFlexion),this.addTrunkLabel(t,"right",g,t.rightData.trunkLateralFlexion),t.labels.push(...v.labels,...P.labels),t}trunkLateralFlexion(e,t,i,s){if(n.pointDistance(i,s)===0)return null;let o=Math.sign(e.x-t.x)||1,l=(s.x-i.x)*o;return Math.atan2(l,Math.abs(i.y-s.y))*(180/Math.PI)}addTrunkLabel(e,t,i,s){if(typeof s!=="number")return;let a=t==="left"?{x:130,y:0}:{x:-130,y:0};e.labels.push({position:{x:i.x,y:i.y-70},value:Math.abs(s),side:t,offset:a,color:C.red})}}class ya{runProgram(e){let t=new ba;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=this.getJoints(e,"left"),s=this.getJoints(e,"right"),a=n.getMiddlePoint(i.hip,s.hip),o=n.getMiddlePoint(i.shoulder,s.shoulder),l=n.getMiddlePoint(i.ankle,s.ankle);if(t.midHipY=a.y,t.bodyHeight=Math.max(n.pointDistance(o,l),1),t.leftKneeY=i.knee.y,t.rightKneeY=s.knee.y,t.leftAnkleX=i.ankle.x,t.rightAnkleX=s.ankle.x,!t.isAligned)return t;let c=new jt().runProgram(e);if(t.direction==="leftSide")t.leftData=this.calculateSideData(i,s,c.leftData),t.leftRearKneeFloorClearanceRatio=this.rearKneeFloorClearanceRatio(s,i,t.bodyHeight),this.drawSide(t,"left",i,s,t.leftData);else if(t.direction==="rightSide")t.rightData=this.calculateSideData(s,i,c.rightData),t.rightRearKneeFloorClearanceRatio=this.rearKneeFloorClearanceRatio(i,s,t.bodyHeight),this.drawSide(t,"right",s,i,t.rightData);return t}getJoints(e,t){let i=t==="left"?"LEFT":"RIGHT";return{shoulder:n.getJointPosition(e,V[`${i}_SHOULDER`]),hip:n.getJointPosition(e,V[`${i}
550_HIP`]),knee:n.getJointPosition(e,V[`${i}_KNEE`]),ankle:n.getJointPosition(e,V[`${i}_ANKLE`]),heel:n.getJointPosition(e,V[`${i}_HEEL`]),toe:n.getJointPosition(e,V[`${i}_FOOT_INDEX`])}}calculateSideData(e,t,i){let s=this.legLength(e);return{leadKneeFlexion:this.flexionAngle(e.hip,e.knee,e.ankle),leadHipFlexion:this.flexionAngle(e.shoulder,e.hip,e.knee),leadAnkleDorsiFlexion:i,trunkForwardLean:this.trunkForwardLean(e),rearHipExtensionDeficit:this.rearHipExtensionDeficit(t),rearKneeFlexion:this.flexionAngle(t.hip,t.knee,t.ankle),stepLengthRatio:s>0?Math.abs(e.heel.x-t.toe.x)/s:null,leadShinAngle:this.shinAngle(e)}}flexionAngle(e,t,i){let s=n.pointDistance(t,e),a=n.pointDistance(t,i);if(s===0||a===0)return null;let o=n.calculateAngle(t,e,i),c=180-(o>180?360-o:o);return c>=-20&&c<=200?c:null}trunkForwardLean(e){if(n.pointDistance(e.hip,e.shoulder)===0)return null;return Math.abs(Math.atan2(e.shoulder.x-e.hip.x,e.hip.y-e.shoulder.y)*(180/Math.PI))}rearHipExtensionDeficit(e){let t=n.pointDistance(e.shoulder,e.hip),i=n.pointDistance(e.hip,e.knee);if(t===0||i===0)return null;let s=n.calculateAngle(e.hip,e.shoulder,e.knee),a=s>180?360-s:s;return Math.abs(180-a)}rearKneeFloorClearanceRatio(e,t,i){if(!i||i===0)return null;let s=Math.max(t.heel.y,t.toe.y,e.heel.y,e.toe.y);return Math.max(0,s-e.knee.y)/i}legLength(e){return n.pointDistance(e.hip,e.knee)+n.pointDistance(e.knee,e.ankle)}shinAngle(e){if(n.pointDistance(e.knee,e.ankle)===0)return null;return Math.abs(Math.atan2(e.knee.x-e.ankle.x,e.ankle.y-e.knee.y)*(180/Math.PI))}drawSide(e,t,i,s,a){this.drawSkeletonRig(e,i,s),this.drawStepLengthOverlay(e,t,i,s,a),this.drawAngleOverlays(e,t,i,s,a)}drawSkeletonRig(e,t,i){let s=C.primaryPath;e.points.push({...t.shoulder,color:s},{...i.shoulder,color:s},{...t.hip,color:s},{...i.hip,color:s},{...t.knee,color:s},{...t.ankle,color:s},{...t.heel,color:s},{...t.toe,color:s},{...i.knee,color:s},{...i.ankle,color:s},{...i.heel,color:s},{...i.toe,color:s}),e.paths.push(n.makeLinePath(t.shoulder,i.shoulder,void 0,void 0,s),n.makeLinePath(t.shoulder,t.hip,void 0,void 0,s),n.makeLinePath(i.shoulder,i.hip,void 0,void 0,s),n.makeLinePath(t.hip,i.hip,void 0,void 0,s),n.makeLinePath(t.hip,t.knee,void 0,void 0,s),n.makeLinePath(t.knee,t.ankle,void 0,void 0,s),n.makeLinePath(t.ankle,t.heel,void 0,void 0,s),n.makeLinePath(t.heel,t.toe,void 0,void 0,s),n.makeLinePath(i.hip,i.knee,void 0,void 0,s),n.makeLinePath(i.knee,i.ankle,void 0,void 0,s),n.makeLinePath(i.ankle,i.heel,void 0,void 0,s),n.makeLinePath(i.heel,i.toe,void 0,void 0,s))}drawAngleOverlays(e,t,i,s,a){if(!a)return;let o=t==="left"?-120:120,l=-o,c=n.getMiddlePoint(i.shoulder,i.hip),p=this.verticalReference(c,i.shoulder);this.addAngle(e,{value:a.trunkForwardLean,side:t,midJoint:c,joint1:i.shoulder,joint2:p,offset:{x:o,y:-40}}),this.addKneeFlexionAngle(e,{value:a.leadKneeFlexion,displaySide:t,kneeSide:t,hip:i.hip,knee:i.knee,ankle:i.ankle,offset:{x:o,y:-34}}),this.addFloatingValue(e,{value:a.leadAnkleDorsiFlexion,side:t,position:i.ankle,offset:{x:o*0.85,y:-8}}),this.addKneeFlexionAngle(e,{value:a.rearKneeFlexion,displaySide:t,kneeSide:t,hip:s.hip,knee:s.knee,ankle:s.ankle,offset:{x:l*0.58,y:-54}}),this.addFloatingValue(e,{value:a.leadShinAngle,side:t,position:this.pointBetween(i.knee,i.ankle,0.58),offset:{x:o*0.82,y:-12}})}drawStepLengthOverlay(e,t,i,s,a){if(typeof a?.stepLengthRatio!=="number")return;let o=Math.max(i.heel.y,i.toe.y,s.heel.y,s.toe.y),l=this.legLength(i)*0.08,c=o+l,p={x:i.heel.x,y:c},m={x:s.toe.x,y:c},g=n.getMiddlePoint(p,m);e.paths.push(n.makeLinePath(p,m,void 0,void 0,C.red)),this.addFloatingValue(e,{value:a.stepLengthRatio,format:"ratio",side:t,position:g,offset:{x:0,y:20}})}pointBetween(e,t,i){return{x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}}verticalReference(e,t){return{x:e.x,y:e.y-n.pointDistance(e,t)}}addAngle(e,t){if(typeof t.value!=="number")return;let i=n.pointDistance(t.midJoint,t.joint1),s=n.pointDistance(t.midJoint,t.joint2),a=Math.min(i,s)*0.2;if(a<=0)return;let o=n.calculateSlope(t.joint1,t.midJoint),l=n.calculateSlope(t.joint2,t.midJoint),c=this.smallArcIsAnticlockwise(o,l),p=n.endPointForSlopeAndDist(t.midJoint,a,o),m=n.endPointForSlopeAndDist(t.midJoint,a,l);e.paths.push(n.makeArcPath(t.midJoint,p,m,a,o,l,c,t.side,C.primaryPath)),e.labels.push({position:t.midJoint,value:t.value,side:t.side,offset:t.offset,color:C.primaryPath})}addKneeFlexionAngle(e,t){if(typeof t.value!=="number")return;let i=Math.min(n.pointDistance(t.hip,t.knee),n.pointDistance(t.knee,t.ankle))*0.2;if(i<=0)return;let s=n.calculateSlope(t.hip,t.knee),a=n.calculateSlope(t.ankle,t.knee),o=n.endPointForSlopeAndDist(t.knee,i,s),l=n.endPointForSlopeAndDist(t.knee,i,a);e.paths.push(n.makeArcPath(t.knee,l,o,i,s,a,this.kneeFlexionArcIsAnticlockwise(t.kneeSide),t.displaySide,C.primaryPath)),e.labels.push({position:t.knee,value:t.value,side:t.displaySide,offset:t.offset,color:C.primaryPath})}addFloatingValue(e,t){if(typeof t.value!=="number")return;let i=t.format==="ratio"?`${t.value.toFixed(2)}x`:t.value;e.labels.push({position:t.position,value:i,side:t.side,offset:t.offset,color:C.primaryPath})}smallArcIsAnticlockwise(e,t){return Math.abs(this.arcRange(e,t,!0))<Math.abs(this.arcRange(e,t,!1))}kneeFlexionArcIsAnticlockwise(e){return e==="right"}arcRange(e,t,i){let s=t-e;if(i&&s>0)s-=360;else if(!i&&s<0)s+=360;return s}}var Ue={};Et(Ue,{PostureAnteriorController:()=>Ea,PostureSagittalController:()=>Aa,programs:()=>is});var Da=`<div class="bottom-controller-container"> 551 <div class="grow min-w-[1px]"></div> 552 <div id="anteriorPostureData" class="min-w-[585px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center"> 553 <h3 class="col-span-12 font-bold text-lg">Anterior Results</h3> 554 <div class="col-span-3 text-sm">Head tilt</div> 555 <div class="col-span-1 text-sm value antHeadTilt">--</div> 556 <div class="col-span-3 text-sm">Shoulder alignment</div> 557 <div class="col-span-1 text-sm value antShoulderAlignment">--</div> 558 <div class="col-span-3 text-sm">Hip alignment</div> 559 <div class="col-span-1 text-sm value antHipAlignment">--</div> 560 <div class="col-span-3 text-sm">Knee alignment</div> 561 <div class="col-span-1 text-sm value antKneeAlignment">--</div> 562 <div class="col-span-3 text-sm">Ankle alignment</div> 563 <div class="col-span-1 text-sm value antAnkleAlignment">--</div> 564 </div> 565 <div class="grow min-w-[1px]"></div> 566</div> 567`;var Qi=`<div class="top-controller-container"> 568 <div id="postureCaptureContainer" class="capture-bar"> 569 <button id="postureCapture" class="capture-bar-cta bg-green-400 hover:bg-green-500 text-green-900">
570 <span>Capture</span> 571 </button> 572 <button id="postureReset" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 573 <span>Reset</span> 574 </button> 575 <button id="postureStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 576 <span>Stop</span> 577 </button> 578 <div class="min-w-6"></div> 579 <div class="flex flex-col"> 580 <span id="postureCaptureTypeHeader" class="text-xs mb-[-4px] pt-1">Capture Type</span> 581 <span id="postureCaptureTypeSubheader" class="font-bold text-lg">Countdown (5s)</span> 582 </div> 583 </div> 584</div> 585`;class Ea{vision;timer=null;record=new qn;capturedResults=null;uiState=ft({countdown:5,captureStatus:0,lastResults:null},()=>{this.updateState()});constructor(e){this.vision=e,e.getRecord((t)=>{this.record=t,this.updateState()})}showControls(e,t){$(e).html(Qi),$(t).html(Da),k("#postureCapture",()=>{this.startCountdown()}),k("#postureStop",()=>{this.reset()}),k("#postureReset",()=>{this.reset()})}process(e,t){if(this.uiState.lastResults=e,t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels),e.isAligned&&this.uiState.captureStatus===2)this.startCountdown();else if(!e.isAligned&&this.uiState.captureStatus===1)this.pauseCountdown()}startCountdown(){this.stopTimer(),this.uiState.captureStatus=1,this.timer=setInterval(()=>{if(this.uiState.countdown>0)this.uiState.countdown--;else this.stopTimer(),this.capturedResults=this.uiState.lastResults,this.capture()},1000)}pauseCountdown(){this.stopTimer(),this.uiState.captureStatus=2}async reset(){this.stopTimer(),this.uiState.captureStatus=0,this.record=new qn,this.capturedResults=null,await this.vision.clearRecord()}stopTimer(){if(this.timer)clearInterval(this.timer),this.timer=null}async capture(){this.stopTimer();let e=this.capturedResults,t=this.vision.captureCurrentFrameSnapshot({includeDisplayFrame:!0});if(!e||!t){this.capturedResults=null,this.uiState.captureStatus=0,this.uiState.countdown=5;return}let i=await this.vision.encodeCaptureSnapshotImage(t);this.record.headTilt=e.headTilt,this.record.shoulderAlignment=e.shoulderAlignment,this.record.hipAlignment=e.hipAlignment,this.record.kneeAlignment=e.kneeAlignment,this.record.ankleAlignment=e.ankleAlignment,this.record.image=i,this.record.setPoseFrame(t.getPoseFrame({imageKey:"image"})),await this.vision.setRecord(this.record),this.uiState.captureStatus=3,this.uiState.countdown=5,this.capturedResults=null}updateState(){switch(U("#postureStop",this.uiState.captureStatus!==1),U("#postureCapture",this.uiState.captureStatus!==0),U("#postureReset",this.uiState.captureStatus!==3),this.uiState.captureStatus){case 0:$("#postureCaptureTypeHeader").text("Capture Type"),$("#postureCaptureTypeSubheader").text("Countdown (5s)");break;case 1:$("#postureCaptureTypeHeader").text("Capture Status"),$("#postureCaptureTypeSubheader").text(`Capturing in ${this.uiState.countdown}...`);break;case 2:$("#postureCaptureTypeSubheader").text("Paused");break;case 3:$("#postureCaptureTypeSubheader").text("Captured!");break;default:break}let e=(t,i)=>{$(t).text(i?`${i.toFixed(2)}°`:"--")};e(".antHeadTilt",this.record.headTilt),e(".antShoulderAlignment",this.record.shoulderAlignment),e(".antHipAlignment",this.record.hipAlignment),e(".antKneeAlignment",this.record.kneeAlignment),e(".antAnkleAlignment",this.record.ankleAlignment)}patientSetup(e,t){this.uiState.captureStatus=2}patientProcess(e,t){if(this.uiState.lastResults=e,t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels),e.isAligned&&this.uiState.captureStatus===2)this.startCountdown()}patientPause(){this.stopTimer(),this.uiState.captureStatus=2}patientData(e){if(e==="step")return 0;else if(e==="timer")return this.uiState.countdown;else return 0}}var wa=`<div class="bottom-controller-container"> 586 <div class="grow min-w-[1px]"></div> 587 <div id="leftPostureData" class="min-w-[450px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center border-4 border-white"> 588 <h3 class="col-span-6 font-bold text-lg">Left Side</h3> 589 <div class="col-span-6 text-end"> 590 <button id="leftReset" class="hidden data-results-reset">
591 <span>Reset</span> 592 </button> 593 </div> 594 <div class="col-span-4 text-sm">Forward head tilt</div> 595 <div class="col-span-2 text-sm value sagHeadLean">--</div> 596 <div class="col-span-4 text-sm">Shoulder alignment</div> 597 <div class="col-span-2 text-sm value sagShoulderAlignment">--</div> 598 <div class="col-span-4 text-sm">Hip alignment</div> 599 <div class="col-span-2 text-sm value sagHipAlignment">--</div> 600 <div class="col-span-4 text-sm">Knee alignment</div> 601 <div class="col-span-2 text-sm value sagKneeAlignment">--</div> 602 </div> 603 <div class="grow"></div> 604 <div id="rightPostureData" class="min-w-[450px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center border-4 border-white"> 605 <h3 class="col-span-6 font-bold text-lg">Right Side</h3> 606 <div class="col-span-6 text-end"> 607 <button id="rightReset" class="hidden data-results-reset"> 608 <span>Reset</span> 609 </button> 610 </div> 611 <div class="col-span-4 text-sm">Forward head tilt</div> 612 <div class="col-span-2 text-sm value sagHeadLean">--</div> 613 <div class="col-span-4 text-sm">Shoulder alignment</div> 614 <div class="col-span-2 text-sm value sagShoulderAlignment">--</div> 615 <div class="col-span-4 text-sm">Hip alignment</div> 616 <div class="col-span-2 text-sm value sagHipAlignment">--</div> 617 <div class="col-span-4 text-sm">Knee alignment</div> 618 <div class="col-span-2 text-sm value sagKneeAlignment">--</div> 619 </div> 620 <div class="grow min-w-[1px]"></div> 621</div> 622`;class Aa{vision;timer=null;record=new Xn;capturedResults=null;uiState=ft({countdown:5,currentSide:0,captureStatus:0,lastResults:null},()=>{this.updateState()});constructor(e){this.vision=e,e.getRecord((t)=>{this.record=t,this.updateState()})}showControls(e,t){$(e).html(Qi),$(t).html(wa),k("#postureCapture",()=>{this.startCountdown()}),k("#postureStop",()=>{this.reset()}),k("#postureReset",()=>{this.reset()}),k("#leftReset",()=>{this.resetLeftSide()}),k("#rightReset",()=>{this.resetRightSide()})}process(e,t){if(this.uiState.lastResults=e,e.direction==="leftSide")this.uiState.currentSide=1;else if(e.direction==="rightSide")this.uiState.currentSide=2;else this.uiState.currentSide=0;if(t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels),e.isAligned&&this.uiState.captureStatus===2)this.startCountdown();else if(!e.isAligned&&this.uiState.captureStatus===1)this.pauseCountdown()}startCountdown(){this.stopTimer(),this.uiState.captureStatus=1,this.timer=setInterval(()=>{if(this.uiState.countdown>0)this.uiState.countdown--;else this.stopTimer(),this.capturedResults=this.uiState.lastResults,this.capture()},1000)}pauseCountdown(){this.stopTimer(),this.uiState.captureStatus=2}async reset(){this.stopTimer(),this.uiState.captureStatus=0,this.record=new Xn,this.capturedResults=null,await this.vision.clearRecord()}async resetLeftSide(){this.record.leftData=null,this.record.leftImage=null,this.record.clearPoseFrame("left"),await this.vision.setRecord(this.record),this.uiState.captureStatus=0,this.capturedResults=null}async resetRightSide(){this.record.rightData=null,this.record.rightImage=null,this.record.clearPoseFrame("right"),await this.vision.setRecord(this.record),this.uiState.captureStatus=0,this.capturedResults=null}stopTimer(){if(this.timer)clearInterval(this.timer),this.timer=null}async capture(){this.stopTimer();let e=this.capturedResults,t=this.vision.captureCurrentFrameSnapshot({includeDisplayFrame:!0});if(!e||!t){this.capturedResults=null,this.uiState.captureStatus=0,this.uiState.countdown=5;return}let i=await this.vision.encodeCaptureSnapshotImage(t);if(e.leftData&&!this.record.leftData)this.record.leftData=e.leftData,this.record.leftImage=i,this.record.setPoseFrame(t.getPoseFrame({imageKey:"leftImage",side:"left"}));if(e.rightData&&!this.record.rightData)this.record.rightData=e.rightData,this.record.rightImage=i,this.record.setPoseFrame(t.getPoseFrame({imageKey:"rightImage",side:"right"}));await this.vision.setRecord(this.record),this.uiState.captureStatus=!this.record.leftData||!this.record.rightData?0:3,this.uiState.countdown=5,this.capturedResults=null}updateState(){switch(U("#postureStop",this.uiState.captureStatus!==1),U("#postureCapture",this.uiState.captureStatus!==0),U("#postureReset",this.uiState.captureStatus!==3),U("#leftReset",!this.record.leftData),U("#rightReset",!this.record.rightData),vt("#leftPostureData","border-blue-500","border-white",this.uiState.currentSide===1),vt("#rightPostureData","border-blue-500","border-white",this.uiState.currentSide===2),this.uiState.captureStatus){case 0:$("#postureCaptureTypeHeader").text("Capture Type"),$("#postureCaptureTypeSubheader").text("Countdown (5s)");break;case 1:$("#postureCaptureTypeHeader").text("Capture Status"),$("#postureCaptureTypeSubheader").text(`Capturing in ${this.uiState.countdown}...`);break;case 2:$("#postureCaptureTypeSubheader").text("Paused");break;case 3:$("#postureCaptureTypeSubheader").text("Captured!"),$("#postureReset").text("Reset Both");break;default:break}let e=(t,i)=>{$(t).text(i?`${i.toFixed(2)}°`:"--")};e("#leftPostureData .sagHeadLean",this.record.leftData?.forwardHeadLean),e("#leftPostureData .sagShoulderAlignment",this.record.leftData?.shoulderAlignment),e("#leftPostureData .sagHipAlignment",this.record.leftData?.hipAlignment),e("#leftPostureData .sagKneeAlignment",this.record.leftData?.kneeAlignment),e("#rightPostureData .sagHeadLean",this.record.rightData?.forwardHeadLean),e("#rightPostureData .sagShoulderAlignment",this.record.rightData?.shoulderAlignment),e("#rightPostureData .sagHipAlignment",this.record.rightData?.hipAlignment),e("#rightPostureData .sagKneeAlignment",this.record.rightData?.kneeAlignment)}patientSetup(e,t){this.uiState.captureStatus=2}patientProcess(e,t){if(this.uiState.lastResults=e,t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels),this.uiState.captureStatus===2)this.startCountdown()}patientPause(){this.stopTimer(),this.uiState.captureStatus=2}patientData(e){if(e==="step")return 0;else if(e==="timer")return this.uiState.countdown;else return 0}}var is={};Et(is,{AnteriorPosture:()=>Ma,SagittalPosture:()=>Ca});class Ge{joint1;joint2;constructor(e,t){this.joint1=e,this.joint2=t}runProgram(e){let t=new La;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,this.joint1),s=n.getJointPosition(e,this.joint2),a=Math.abs(n.calculateSlope(i,s));if(t.isAligned)t.points.push(i),t.points.push(s),t.paths.push(n.makeLinePath(i,s)),t.alignment=a,t.labels.push({position:i,value:t.alignment,offset:{x:100,y:0}});return t}}class Zn{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_ear"),s=n.getJointPosition(e,"left_shoulder"),a=n.getJointPosition(e,"right_ear"),o=n.getJointPosition(e,"right_shoulder"),l=n.pointDistance(s,i),c={x:s.x,y:s.y-l},p=n.calculateAngle(s,i,c,!0),m=n.pointDistance(o,a),g={x:o.x,y:o.y-m},d=n.calculateAngle(o,g,a,!0);if(t.isAligned&&t.direction==="leftSide")t.leftData=Math.abs(p>200?p-360:p),t.labels.push({position:c,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...i,side:"left"}),t.points.push({...c,side:"left"}),t.paths.push(n.makeLinePath(s,i,"left")),t.paths.push(n.makeLinePath(s,c,"left"));else if(t.isAligned&&t.direction==="rightSide")t.rightData=Math.abs(d>200?d-360:d),t.labels.push({position:g,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...a,side:"right"}),t.points.push({...g,side:"right"}),t.paths.push(n.makeLinePath(o,a,"right")),t.paths.push(n.makeLinePath(o,g,"right"));return t}}class Qn{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_shoulder"),a=n.getJointPosition(e,"left_ear"),o=n.getJointPosition(e,"right_hip"),l=n.getJointPosition(e,"right_shoulder"),c=n.getJointPosition(e,"right_ear"),p=180-n.calculateAngle(s,a,i,!1),m=180-n.calculateAngle(l,o,c,!1);if(t.isAligned&&t.direction==="leftSide")t.leftData=Math.abs(p),t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...s,side:"left"}),t.paths.push(n.makeLinePath(i,s,"left")),t.paths.push(n.makeLinePath(s,a,"left"));else if(t.isAligned&&t.direction==="rightSide")t.rightData=Math.abs(m),t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...l,side:"right"}),t.paths.push(n.makeLinePath(o,l,"right")),t.paths.push(n.makeLinePath(l,c,"right"));return t}}class ts{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_hip"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_hip"),c=n.getJointPosition(e,"right_knee"),p=n.calculateAngle(s,a,i,!1)-180,m=n.calculateAngle(l,o,c,!1)-180,g=n.getJointPosition(e,"left_ankle"),d=n.getJointPosition(e,"right_ankle"),S=n.getJointPosition(e,"left_ear"),v=n.getJointPosition(e,"right_ear"),P=n.pointDistance(g,S),b=n.pointDistance(d,v);if(t.isAligned&&t.direction==="leftSide")t.leftData=Math.abs(p),t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...s,side:"left"}),t.paths.push(n.makeLinePath(s,i,"left")),t.paths.push(n.makeLinePath(s,a,"left")),t.paths.push(n.makeLinePath(g,{x:g.x,y:g.y+10},void 0,P+200,C.red));else if(t.isAligned&&t.direction==="rightSide")t.rightData=Math.abs(m),t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...l,side:"right"}),t.paths.push(n.makeLinePath(l,o,"right")),t.paths.push(n.makeLinePath(l,c,"right")),t.paths.push(n.makeLinePath(d,{x:d.x,y:d.y+10},void 0,b+200,C.red));return t}}class es{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_knee"),a=n.getJointPosition(e,"left_ankle"),o=n.getJointPosition(e,"right_hip"),l=n.getJointPosition(e,"right_knee"),c=n.getJointPosition(e,"right_ankle"),p=Math.min(n.pointDistance(i,s),n.pointDistance(s,a)),m=n.calculateSlope(a,s),g=n.endPointForSlopeAndDist(s,p,m),d=180-n.calculateAngle(s,a,i,!1),S=Math.min(n.pointDistance(o,l),n.pointDistance(l,c)),v=n.calculateSlope(c,l),P=n.endPointForSlopeAndDist(l,S,v),b=180-n.calculateAngle(l,o,c,!1);if(t.isAligned&&t.direction==="leftSide")t.leftData=Math.abs(d),t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:100,y:0}}),t.points.push({...s,side:"left"}),t.points.push({...g,side:"left"}),t.paths.push(n.makeLinePath(s,i,"left")),t.paths.push(n.makeLinePath(s,g,"left"));else if(t.isAligned&&t.direction==="rightSide")t.rightData=Math.abs(b),t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:-100,y:0}}),t.points.push({...l,side:"right"}),t.points.push({...P,side:"right"}),t.paths.push(n.makeLinePath(l,o,"right")),t.paths.push(n.makeLinePath(l,P,"right"));return t}}class Ma{runProgram(e){let t=new Fa;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=new Ge("left_eye","right_eye").runProgram(e),s=new Ge("left_shoulder","right_shoulder").runProgram(e),a=new Ge("left_hip","right_hip").runProgram(e),o=new Ge("left_knee","right_knee").runProgram(e),l=new Ge("left_ankle","right_ankle").runProgram(e),c=n.getJointPosition(e,"left_hip"),p=n.getJointPosition(e,"right_hip"),m=n.getMiddlePoint(c,p),g=n.getJointPosition(e,"left_foot_index"),d=n.getJointPosition(e,"right_foot_index"),S=n.getMiddlePoint(g,d),v=n.getJointPosition(e,"nose"),P=n.pointDistance(S,v),b=n.makeLinePath(m,{x:m.x,y:m.
622y+10},void 0,P+100,C.red);if(t.isAligned)t.points=[...i.points,...s.points,...a.points,...o.points,...l.points],t.paths=[...i.paths,...s.paths,...a.paths,...o.paths,...l.paths,b],t.labels=[...i.labels,...s.labels,...a.labels,...o.labels,...l.labels],t.headTilt=i.alignment,t.shoulderAlignment=s.alignment,t.hipAlignment=a.alignment,t.kneeAlignment=o.alignment,t.ankleAlignment=l.alignment;return t}}class Ca{runProgram(e){let t=new _a;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=new Zn().runProgram(e),s=new Qn().runProgram(e),a=new ts().runProgram(e),o=new es().runProgram(e);if(t.isAligned)t.points=[...i.points,...s.points,...a.points,...o.points],t.paths=[...i.paths,...s.paths,...a.paths,...o.paths],t.labels=[...i.labels,...s.labels,...a.labels,...o.labels];if(t.isAligned&&t.direction==="leftSide")t.leftData={forwardHeadLean:i.leftData,hipAlignment:a.leftData,kneeAlignment:o.leftData,shoulderAlignment:s.leftData};else if(t.isAligned&&t.direction==="rightSide")t.rightData={forwardHeadLean:i.rightData,hipAlignment:a.rightData,kneeAlignment:o.rightData,shoulderAlignment:s.rightData};return t}}var Be={};Et(Be,{CaptureStatus:()=>Va,PushUpController:()=>Bt,PushUpPhase:()=>Wa,programs:()=>us});var Ha=`<div class="bottom-controller-container items-end"> 623 <div class="grow min-w-[1px]"></div> 624 <div id="pushUpData" class="self-end w-[220px] min-w-[220px] grid grid-cols-4 gap-x-2 gap-y-1 bg-white/95 rounded-md shadow-sm p-2 items-center border-2 border-white text-xs leading-tight whitespace-normal"> 625 <h3 class="col-span-4 font-bold text-sm">Results</h3> 626 <div id="pushUpNoResult" class="col-span-4 text-xs text-gray-500">No result captured</div> 627 <div class="pushUpResultRow hidden col-span-2 text-xs">Target</div> 628 <div id="pushUpResultTarget" class="pushUpResultRow hidden col-span-2 text-xs value text-right truncate">--</div> 629 <div class="pushUpResultRow hidden col-span-2 text-xs">Reps</div> 630 <div id="pushUpResultReps" class="pushUpResultRow hidden col-span-2 text-xs value text-right truncate">--</div> 631 <div class="pushUpResultRow hidden col-span-2 text-xs">Elapsed</div> 632 <div id="pushUpResultElapsed" class="pushUpResultRow hidden col-span-2 text-xs value text-right truncate">--</div> 633 </div> 634 <div class="grow min-w-[1px]"></div> 635</div>`;var Oa=`<div class="top-controller-container"> 636 <div id="pushUpCaptureContainer" class="capture-bar"> 637 <button id="pushUpCapture" class="capture-bar-cta bg-green-400 hover:bg-green-500 text-green-900"> 638 <span>Start</span> 639 </button> 640 <button id="pushUpReset" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 641 <span>Reset</span> 642 </button> 643 <button id="pushUpStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 644 <span>Stop</span> 645 </button> 646 <div class="min-w-6"></div> 647 <div class="flex flex-col"> 648 <span id="pushUpCaptureTypeHeader" class="text-xs mb-[-4px] pt-1">Capture Type</span> 649 <span id="pushUpCaptureTypeSubheader" class="font-bold text-lg">Timed 30 sec</span> 650 </div> 651 <div class="min-w-6"></div> 652 <div class="flex flex-col rounded-xl h-10 w-10 items-center justify-center mb-1"> 653 <span id="activePushUpReps" class="text-lg mb-[-4px]">0</span> 654 <span id="pushUpRepLabel" class="font-bold text-sm">Reps</span> 655 </div> 656 <div class="min-w-6"></div> 657 <div class="flex flex-col rounded-xl h-10 min-w-16 items-center justify-center mb-1"> 658 <span id="activePushUpTimer" class="text-lg mb-[-4px]">30.0</span> 659 <span id="pushUpTimerLabel" class="font-bold text-sm">Left</span> 660 </div> 661 <div class="min-w-6"></div> 662 <button id="pushUpCaptureConfig" class="settings-button"> 663 <i class="fas fa-gear text-2xl p-2 text-gray-500"></i> 664 </button> 665 </div> 666</div> 667<div id="pushUpDismissModal" class="fade-out absolute left-0 top-0 right-0 bottom-0"></div>
668<div id="pushUpCaptureModal" class="fade-out absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 p-4 transition-opacity duration-500 ease-in-out"> 669 <div class="w-96 bg-gray-100 rounded-xl p-6 shadow-lg"> 670 <h2 class="text-lg font-semibold text-gray-800 mb-4 text-center">Capture Settings</h2> 671 672 <div id="pushUpTimedSettings"> 673 <p class="text-sm font-medium text-gray-900">Timed Push-Up Test</p> 674 <p class="text-xs text-gray-600 mb-4">Count completed push-ups in the selected time window.</p> 675 <label class="block text-xs font-medium text-gray-700 mb-1" for="pushUpTimedDuration">Duration</label> 676 <div class="flex items-center gap-2"> 677 <input id="pushUpTimedDuration" type="number" min="10" max="60" step="1" value="30" class="w-24 rounded-md border border-gray-300 px-2 py-1 text-sm" /> 678 <span class="text-xs text-gray-600">seconds</span> 679 </div> 680 </div> 681 682 <div id="pushUpRepsSettings"> 683 <p class="text-sm font-medium text-gray-900">Repetition Push-Up Test</p> 684 <p class="text-xs text-gray-600 mb-4">Time how long it takes to complete the target reps.</p> 685 <label class="block text-xs font-medium text-gray-700 mb-1" for="pushUpTargetReps">Target</label> 686 <div class="flex items-center gap-2"> 687 <input id="pushUpTargetReps" type="number" min="1" max="20" step="1" value="10" class="w-24 rounded-md border border-gray-300 px-2 py-1 text-sm" /> 688 <span class="text-xs text-gray-600">reps</span> 689 </div> 690 </div> 691 </div> 692</div>`;var Va;((a)=>{a[a.NOTSTARTED=0]="NOTSTARTED";a[a.WAITING_FOR_TOP=1]="WAITING_FOR_TOP";a[a.ANALYZING=2]="ANALYZING";a[a.CAPTURED=3]="CAPTURED"})(Va||={});var Wa;((a)=>{a[a.TOP=0]="TOP";a[a.LOWERING=1]="LOWERING";a[a.BOTTOM=2]="BOTTOM";a[a.RISING=3]="RISING"})(Wa||={});class Bt{static ATTEMPT_START_ELBOW_DELTA_MIN=12;static ATTEMPT_BOTTOM_ELBOW_DELTA_MIN=20;static ATTEMPT_RETURN_ELBOW_DELTA_MIN=8;static ATTEMPT_START_SHOULDER_DROP_MIN=0.02;static ATTEMPT_BOTTOM_SHOULDER_DROP_MIN=0.04;static ATTEMPT_RETURN_SHOULDER_DROP_MIN=0.02;static ATTEMPT_RETURN_RATIO_MIN=0.45;vision;testMode;timer=null;record=new ns;
692topStableFrames=0;currentRepStartedAtMs=null;bottomReachedAtMs=null;activeStartedAtMs=null;elapsedBeforePauseMs=0;isFinalizing=!1;repCapturedCuePending=!1;activeRepMetric=null;topReferenceElbowFlexion=null;topReferenceShoulderY=null;topReferenceShoulderAnkleDistance=null;maxAttemptShoulderDrop=0;uiState;constructor(e,t){this.vision=e,this.testMode=t,this.uiState=ft({elapsedTimeSec:0,remainingTimeSec:t==="timed"?Ri:tn,repsCompleted:0,showingCaptureModal:!1,captureStatus:0,phase:0,testMode:t,targetDurationSec:Ri,targetReps:en},()=>{this.updateState()}),e.getRecord((i)=>{this.record=i,this.updateState()})}showControls(e,t){$(e).html(Oa),$(t).html(Ha),k("#pushUpCapture",()=>{this.startCapture()}),k("#pushUpStop",()=>{this.stopCapture()}),k("#pushUpReset",()=>{this.reset()}),k("#pushUpCaptureConfig",()=>{this.uiState.showingCaptureModal=!0}),k("#pushUpDismissModal",()=>{this.uiState.showingCaptureModal=!1}),$("#pushUpTimedDuration").on("input",()=>{this.updateTimedDurationFromInput()}),$("#pushUpTargetReps").on("input",()=>{this.updateTargetRepsFromInput()})}async process(e,t){await this.processResults(e),t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels)}patientSetup(e,t){if(this.testMode==="timed")this.uiState.targetDurationSec=this.readIntegerValue(t,ss,rs,Ri);else this.uiState.targetReps=this.readIntegerValue(t,as,os,en);this.startCapture()}async patientProcess(e,t){await this.process(e,t)}patientPause(){this.pauseCapture()}patientData(e){if(e==="step")return this.uiState.captureStatus===2?1:0;if(e==="timer")return this.testMode==="timed"?this.uiState.remainingTimeSec.toFixed(1):this.uiState.elapsedTimeSec.toFixed(1);if(e==="reps")return this.uiState.repsCompleted;return 0}consumeRepCapturedCue(){let e=this.repCapturedCuePending;return this.repCapturedCuePending=!1,e}updateState(){let e=!this.record.isEmpty(),t=this.uiState.captureStatus===1||this.uiState.captureStatus===2;switch(U("#pushUpCapture",t),U("#pushUpStop",!t),U("#pushUpReset",!e&&this.uiState.captureStatus!==3),U("#pushUpCaptureConfig",t),vt("#pushUpData","border-blue-500","border-white",t),Rt("#pushUpCaptureContainer","partial-fade",this.uiState.showingCaptureModal),Rt("#pushUpCaptureMod
692al","fade-out",!this.uiState.showingCaptureModal),Rt("#pushUpDismissModal","fade-out",!this.uiState.showingCaptureModal),this.vision.toggleBlur(this.uiState.showingCaptureModal),U("#pushUpTimedSettings",this.testMode!=="timed"),U("#pushUpRepsSettings",this.testMode!=="reps"),$("#pushUpTimedDuration").val(this.uiState.targetDurationSec),$("#pushUpTargetReps").val(this.uiState.targetReps),$("#activePushUpReps").text(this.uiState.repsCompleted),$("#pushUpRepLabel").text(this.uiState.repsCompleted===1?"Rep":"Reps"),$("#activePushUpTimer").text((this.testMode==="timed"?this.uiState.remainingTimeSec:this.uiState.elapsedTimeSec).toFixed(1)),$("#pushUpTimerLabel").text(this.testMode==="timed"?"Left":"Time"),this.uiState.captureStatus){case 0:$("#pushUpCapture").text(e?"Restart":"Start"),$("#pushUpCaptureTypeHeader").text("Capture Type"),$("#pushUpCaptureTypeSubheader").text(this.targetLabel());break;case 1:$("#pushUpCaptureTypeHeader").text("Capture Status"),$("#pushUpCaptureTypeSubheader").text("Waiting for top");break;case 2:$("#pushUpCaptureTypeHeader").text("Analyzing..."),$("#pushUpCaptureTypeSubheader").text(this.phaseLabel());break;case 3:$("#pushUpCapture").text("Restart"),$("#pushUpCaptureTypeHeader").text("Capture Status"),$("#pushUpCaptureTypeSubheader").text("Captured");break}this.renderResult()}async processResults(e){let t=e.leftData??e.rightData;if(!t){if(this.uiState.captureStatus===2)this.pauseCapture();return}if(this.uiState.captureStatus===1){this.processWaitingForTop(t);return}if(this.uiState.captureStatus===2)await this.processActiveCapture(t)}pauseCapture(){if(this.uiState.captureStatus!==1&&this.uiState.captureStatus!==2)return;this.pauseTimer(),this.uiState.captureStatus=1,this.uiState.phase=0,this.topStableFrames=0,this.currentRepStartedAtMs=null,this.bottomReachedAtMs=null,this.repCapturedCuePending=!1,this.resetTopReference(),this.resetAttemptExtremes(),this.discardActiveRepMetric()}processWaitingForTop(e){if(this.hasCountableFrame(e))this.topStableFrames+=1,this.setTopReference(e);else this.topStableFrames=0;if(this.topStableFrames<Na)return;this.topStableFrames=0,this.uiState.phase=0,this.uiState.captureStatus=2,this.startTimer()}async processActiveCapture(e){if(e.elbowFlexion===null)return;if(!this.hasTopReference()){this.setTopReference(e);return}switch(this.uiState.phase){case 0:if(this.hasAttemptStarted(e)){if(this.uiState.phase=1,this.currentRepStartedAtMs=Date.now(),this.bottomReachedAtMs=null,this.maxAttemptShoulderDrop=Math.max(0,this.shoulderDropFromTop(e)??0),this.startRepMetric(e),this.hasAttemptBottom(e))this.uiState.phase=2,this.bottomReachedAtMs=Date.now()}else this.refineTopReference(e);break;case 1:if(this.sampleActiveRepMetric(e),this.updateAttemptExtremes(e),this.hasAttemptBottom(e))this.uiState.phase=2,this.bottomReachedAtMs=Date.now();else if(this.hasReturnedToReference(e))this.uiState.phase=0,this.currentRepStartedAtMs=null,this.resetAttemptExtremes(),this.discardActiveRepMetric();break;case 2:if(this.sampleActiveRepMetric(e),this.updateAttemptExtremes(e),this.hasAttemptReturnStarted(e))this.uiState.phase=3;break;case 3:if(this.sampleActiveRepMetric(e),this.updateAttemptExtremes(e),this.hasAttemptCompleted(e))this.completeRep(e);else if(this.hasAttemptBottom(e))this.uiState.phase=2;break}await this.finishIfCaptureComplete()}startRepMetric(e){let t=this.topReferenceElbowFlexion;this.activeRepMetric={startTimeSec:this.roundSeconds(Math.min(this.currentElapsedSec(),this.currentCaptureDurationSec())),maxElbowFlexion:t,minElbowFlexion:t,bodyLineAngleDeviationSum:0,bodyLineAngleDeviationCount:0,bodyLineDirectionCounts:Ja()},this.sampleActiveRepMetric(e)}sampleActiveRepMetric(e){if(!this.activeRepMetric)return;let t=e.elbowFlexion;if(this.isFiniteNumber(t))this.activeRepMetric.maxElbowFlexion=this.activeRepMetric.maxElbowFlexion===null?t:Math.max(this.activeRepMetric.maxElbowFlexion,t),this.activeRepMetric.minElbowFlexion=this.activeRepMetric.minElbowFlexion===null?t:Math.min(this.activeRepMetric.minElbowFlexion,t);let i=e.bodyLineAngleDeviation;if(this.isFiniteNumber(i))this.activeRepMetric.bodyLineAngleDeviationSum+=i,this.activeRepMetric.bodyLineAngleDeviationCount+=1;Ga(this.activeRepMetric.bodyLineDirectionCounts,e.bodyLineDirection)}buildCompletedRepMetric(){let e=this.activeRepMetric;if(!e)return null;let t=this.roundSeconds(Math.min(this.currentElapsedSec(),this.currentCaptureDurationSec())
692);return{index:this.record.reps.length+1,startTimeSec:e.startTimeSec,endTimeSec:t,durationSec:this.roundSeconds(Math.max(0,t-e.startTimeSec)),maxElbowFlexion:e.maxElbowFlexion,minElbowFlexion:e.minElbowFlexion,avgBodyLineAngleDeviation:e.bodyLineAngleDeviationCount>0?this.roundMetric(e.bodyLineAngleDeviationSum/e.bodyLineAngleDeviationCount):null,bodyLineDirection:Ua(e.bodyLineDirectionCounts)}}discardActiveRepMetric(){this.activeRepMetric=null}completeRep(e){let t=Date.now(),i=this.currentRepStartedAtMs?t-this.currentRepStartedAtMs:0,s=this.bottomReachedAtMs!==null,a=i>=ka&&i<=Ka;if(s&&a){let o=this.buildCompletedRepMetric();if(o)this.record.reps.push(o);if(this.uiState.repsCompleted+=1,this.shouldQueueRepCapturedCue())this.repCapturedCuePending=!0}this.uiState.phase=0,this.currentRepStartedAtMs=null,this.bottomReachedAtMs=null,this.setTopReference(e),this.resetAttemptExtremes(),this.discardActiveRepMetric()}shouldQueueRepCapturedCue(){if(this.testMode==="reps")return this.uiState.repsCompleted<this.uiState.targetReps;return!0}hasCountableFrame(e){return this.isFiniteNumber(e.elbowFlexion)}hasTopReference(){return this.topReferenceElbowFlexion!==null}setTopReference(e){if(!this.isFiniteNumber(e.elbowFlexion))return;this.topReferenceElbowFlexion=e.elbowFlexion,this.topReferenceShoulderY=this.isFiniteNumber(e.shoulderY)?e.shoulderY:null,this.topReferenceShoulderAnkleDistance=this.isFiniteNumber(e.shoulderAnkleDistance)&&e.shoulderAnkleDistance>0?e.shoulderAnkleDistance:null}refineTopReference(e){if(!this.isFiniteNumber(e.elbowFlexion))return;if(this.topReferenceElbowFlexion===null||e.elbowFlexion<this.topReferenceElbowFlexion)this.setTopReference(e)}resetTopReference(){this.topReferenceElbowFlexion=null,this.topReferenceShoulderY=null,this.topReferenceShoulderAnkleDistance=null}hasAttemptStarted(e){let t=this.elbowDeltaFromTop(e),i=this.shoulderDropFromTop(e);return t!==null&&t>=Bt.ATTEMPT_START_ELBOW_DELTA_MIN||i!==null&&i>=Bt.ATTEMPT_START_SHOULDER_DROP_MIN}hasAttemptBottom(e){let t=this.elbowDeltaFromTop(e),i=this.shoulderDropFromTop(e);return t!==null&&t>=Bt.ATTEMPT_BOTTOM_ELBOW_DELTA_MIN||i!==null&&i>=Bt.ATTEMPT_BOTTOM_SHOULDER_DROP_MIN}hasAttemptReturnStarted(e){let t=this.elbowReturnFromMax(e),i=this.shoulderReturnFromMax(e);return t!==null&&t>=Bt.ATTEMPT_RETURN_ELBOW_DELTA_MIN||i!==null&&i>=Bt.ATTEMPT_RETURN_SHOULDER_DROP_MIN}hasAttemptCompleted(e){let t=this.maxElbowExcursion(),i=this.elbowReturnFromMax(e),s=this.shoulderReturnFromMax(e),a=t!==null&&i!==null&&i>=Math.max(Bt.ATTEMPT_RETURN_ELBOW_DELTA_MIN,t*Bt.ATTEMPT_RETURN_RATIO_MIN),o=s!==null&&s>=Math.max(Bt.ATTEMPT_RETURN_SHOULDER_DROP_MIN,this.maxAttemptShoulderDrop*Bt.ATTEMPT_RETURN_RATIO_MIN);return a||o}hasReturnedToReference(e){let t=this.elbowDeltaFromTop(e),i=this.shoulderDropFromTop(e),s=t!==null&&t<=Bt.ATTEMPT_START_ELBOW_DELTA_MIN/2,a=i!==null&&i<=Bt.ATTEMPT_START_SHOULDER_DROP_MIN/2;return s||a}updateAttemptExtremes(e){let t=this.shoulderDropFromTop(e);if(t!==null)this.maxAttemptShoulderDrop=Math.max(this.maxAttemptShoulderDrop,t)}resetAttemptExtremes(){this.maxAttemptShoulderDrop=0}elbowDeltaFromTop(e){if(!this.isFiniteNumber(e.elbowFlexion)||this.topReferenceElbowFlexion===null)return null;return e.elbowFlexion-this.topReferenceElbowFlexion}shoulderDropFromTop(e){let t=this.topReferenceShoulderY,i=this.topReferenceShoulderAnkleDistance;if(!this.isFiniteNumber(e.shoulderY)||t===null||i===null||i<=0)return null;return(e.shoulderY-t)/i}maxElbowExcursion(){let e=this.activeRepMetric?.maxElbowFlexion;if(e===null||e===void 0||this.topReferenceElbowFlexion===null)return null;return e-this.topReferenceElbowFlexion}elbowReturnFromMax(e){let t=this.activeRepMetric?.maxElbowFlexion;if(t===null||t===void 0||!this.isFiniteNumber(e.elbowFlexion))return null;return t-e.elbowFlexion}shoulderReturnFromMax(e){let t=this.shoulderDropFromTop(e);if(t===null)return null;return this.maxAttemptShoulderDrop-t}startCapture(){this.stopTimer(),this.record.clearRecord(),this.topStableFrames=0,this.currentRepStartedAtMs=null,this.bottomReachedAtMs=null,this.activeStartedAtMs=null,this.elapsedBeforePauseMs=0,this.isFinalizing=!1,this.repCapturedCuePending=!1,this.resetTopReference(),this.resetAttemptExtremes(),this.discardActiveRepMetric(),this.uiState.elapsedTimeSec=0,this.uiState.remainingTimeSec=this.currentCaptureDurationSec(),this.uiState.repsCompleted=0,this.uiState.phase=0,this.uiState.captureStatus=1}stopCapture(){this.stopTimer(),this.uiState.captureStatus=0,this.uiState.phase=0,this.topStableFrames=0,this.currentRepStartedAtMs=null,this.bottomReachedAtMs=null,this.resetTopReference(),this.resetAttemptExtremes(),this.discardActiveRepMetric()}async reset(){this.stopTimer(),this.record=new ns,await this.vision.clearRecord(),this.uiState.elapsedTimeSec=0,this.uiState.remainingTimeSec=this.currentCaptureDurationSec(),this.uiState.repsCompleted=0,this.uiState.phase=0,this.uiState.captureStatus=0,this.topStableFrames=0,this.currentRepStartedAtMs=null,this.bottomReachedAtMs=null,this.isFinalizing=!1,this.repCapturedCuePending=!1,this.resetTopReference(),this.resetAttemptExtremes(),this.discardActiveRepMetric()}startTimer(){if(this.timer)return;this.activeStartedAtMs=Date.now(),this.timer=setInterval(()=>{this.updateTimerState(),this.finishIfCaptureComplete()},100),this.updateTimerState()}pauseTimer(){if(this.activeStartedAtMs!==null)this.elapsedBeforePauseMs+=Date.now()-this.activeStartedAtMs,this.activeStartedAtMs=null;this.stopTimer(),this.updateTimerState()}stopTimer(){if(this.timer)clearInterval(this.timer),this.timer=null}updateTimerState(){let e=this.currentElapsedSec();this.uiState.elapsedTimeSec=e,this.uiState.remainingTimeSec=Math.max(0,this.currentCaptureDurationSec()-e)}currentElapsedSec(){let e=this.activeStartedAtMs!==null?Date.now()-this.activeStartedAtMs:0;return(this.elapsedBeforePauseMs+e)/1000}async finishIfCaptureComplete(){if(this.uiState.captureStatus!==2||this.isFinalizing)return;if(this.testMode==="timed"){if(this.uiState.remainingTimeSec<=0)await this.finishCapture();return}if(this.uiState.repsCompleted>=this.uiState.targetReps||this.uiState.elapsedTimeSec>=tn)await this.finishCapture()}async finishCapture(){if(this.isFinalizing)return;this.isFinalizing=!0,this.updateTimerState(),this.stopTimer();let e=Math.min(this.uiState.elapsedTimeSec,this.currentCaptureDurationSec());this.record.targetDurationSec=this.testMode==="timed"?this.uiState.targetDurationSec:null,this.record.targetReps=this.testMode==="reps"?this.uiState.targetReps:null,this.record.repsCompleted=this.uiState.repsCompleted,this.record.elapsedTimeSec=Number(e.toFixed(2)),this.record.summary=Ba(this.record.reps),this.resetAttemptExtremes(),this.discardActiveRepMetric(),this.uiState.elapsedTimeSec=e,this.uiState.remainingTimeSec=Math.max(0,this.currentCaptureDurationSec()-e),this.uiState.captureStatus=3,await this.vision.setRecord(this.record),this.isFinalizing=!1}updateTimedDurationFromInput(){this.uiState.targetDurationSec=this.readIntegerInput("#pushUpTimedDuration",ss,rs,Ri),this.uiState.remainingTimeSec=this.currentCaptureDurationSec()}updateTargetRepsFromInput(){this.uiState.targetReps=this.readIntegerInput("#pushUpTargetReps",as,os,en)}readIntegerInput(e,t,i,s){return this.readIntegerValue($(e).val(),t,i,s)}readIntegerValue(e,t,i,s){let a=Number(e);if(!Number.isFinite(a))return s;return Math.min(i,Math.max(t,Math.round(a)))}roundSeconds(e){return Number(e.toFixed(2))}roundMetric(e){return Number(e.toFixed(3))}isFiniteNumber(e){return typeof e==="number"&&Number.isFinite(e)}currentCaptureDurationSec(){return this.testMode==="timed"?this.uiState.targetDurationSec:tn}targetLabel(){if(this.testMode==="timed")return`Timed ${this.uiState.targetDurationSec} sec`;return`${this.uiState.targetReps} ${this.uiState.targetReps===1?"rep":"reps"}`}phaseLabel(){switch(this.uiState.phase){case 0:return"Top";case 1:return"Lowering";case 2:return"Bottom";case 3:return"Rising"}}
692renderResult(){if(this.record.isEmpty()){U("#pushUpNoResult",!1),U(".pushUpResultRow",!0),$("#pushUpResultTarget").text("--"),$("#pushUpResultReps").text("--"),$("#pushUpResultElapsed").text("--");return}U("#pushUpNoResult",!0),U(".pushUpResultRow",!1);let e=this.record.targetDurationSec??this.uiState.targetDurationSec,t=this.record.targetReps??this.uiState.targetReps,i=this.testMode==="timed"?`Timed ${e} sec`:`${t} ${t===1?"rep":"reps"}`,s=this.record.repsCompleted??0,a=(this.record.elapsedTimeSec??0).toFixed(1);$("#pushUpResultTarget").text(i),$("#pushUpResultReps").text(`${s} ${s===1?"rep":"reps"}`),$("#pushUpResultElapsed").text(`${a} sec`)}}var us={};Et(us,{PushUp:()=>ja});var Pc={left:{shoulder:"left_shoulder",hip:"left_hip",ankle:"left_ankle"},right:{shoulder:"right_shoulder",hip:"right_hip",ankle:"right_ankle"}};class ja{runProgram(e){let t=new $a,i=new Xi().runProgram(e);if(t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide",!t.isAligned)return t;if(t.points=[...i.points],t.paths=[...i.paths],t.labels=[],t.direction==="leftSide")this.setSideData(t,e,"left",i.leftData);else if(t.direction==="rightSide")this.setSideData(t,e,"right",i.rightData);return t}setSideData(e,t,i,s){let a=Pc[i],o=n.getJointPosition(t,a.shoulder),l=n.getJointPosition(t,a.hip),c=n.getJointPosition(t,a.ankle),p=Rc(c,l,o),m=n.pointDistance(o,c),g={elbowFlexion:s,bodyLineAngleDeviation:p?.deviation??null,bodyLineDirection:p?.direction??null,shoulderY:o.y,shoulderAnkleDistance:m>0?m:null};if(i==="left")e.leftData=g;else e.rightData=g;if(p){let d=yc(p.direction);e.paths.push(n.makeLinePath(o,l,i,void 0,d)),e.paths.push(n.makeLinePath(l,c,i,void 0,d)),e.points.push({...o,side:i,color:d}),e.points.push({...l,side:i,color:d}),e.points.push({...c,side:i,color:d})}}}function Rc(e,t,i){let s={x:e.x-t.x,y:e.y-t.y},a={x:i.x-t.x,y:i.y-t.y},o=Math.hypot(s.x,s.y),l=Math.hypot(a.x,a.y);if(o<=0||l<=0)return null;let c=Ec((s.x*a.x+s.y*a.y)/(o*l),-1,1),p=Math.acos(c)*(180/Math.PI),m=Math.max(0,180-p),g=bc(t,i,e),d=Math.sign(t.y-g.y)||1;return{deviation:m,direction:Dc(m*d)}}function bc(e,t,i){let s=i.x-t.x,a=i.y-t.y,o=s*s+a*a,l=o>0?((e.x-t.x)*s+(e.y-t.y)*a)/o:0;return{x:t.x+l*s,y:t.y+l*a}}function yc(e){return e==="neutral"?C.primaryPath:C.red}function Dc(e){if(e>ls)return"hip_sag";if(e<-ls)return"hip_pike";return"neutral"}function Ec(e,t,i){return Math.min(i,Math.max(t,e))}var X={};Et(X,{ROMController:()=>Xa,programs:()=>On});var Ya=`<div class="bottom-controller-container"> 693 <div class="grow min-w-[1px]"></div> 694 <div id="leftRomBox" class="w-1/4 min-w-[230px] grid grid-cols-6 gap-4 bg-white rounded-md shadow-sm p-4"> 695 <h3 class="col-span-3 font-bold text-lg">Left Side</h3> 696 <div class="col-span-3 text-end"> 697 <button id="leftReset" class="hidden data-results-reset"> 698 <span>Reset</span> 699 </button> 700 </div> 701 <div id="leftRomValue" class="col-span-3 text-4xl">0°</div> 702 <div class="col-span-3 captured-indicator fade-out flex items-center space-x-1 transition-opacity duration-200 ease-in-out"> 703 <span class="checkmark">✓</span> 704 <span class="captured-label">Captured</span> 705 </div> 706 </div> 707 <div class="grow"></div> 708 <div id="rightRomBox" class="w-1/4 min-w-[230px] grid grid-cols-6 gap-4 bg-white rounded-md shadow-sm p-4"> 709 <h3 class="col-span-3 font-bold text-lg">Right Side</h3> 710 <div class="col-span-3 text-end"> 711 <button id="rightReset" class="hidden data-results-reset"> 712 <span>Reset</span> 713 </button> 714 </div> 715 <div id="rightRomValue" class="col-span-3 text-4xl">0°</div> 716 <div class="col-span-3 captured-indicator fade-out flex items-center space-x-1 transition-opacity duration-200 ease-in-out"> 717 <span class="checkmark">✓</span> 718 <span class="captured-label">Captured</span> 719 </div> 720 </div> 721 <div class="grow min-w-[1px]"></div> 722</div> 723`;var za=`<div class="top-controller-container"> 724 <div id="romCaptureContainer" class="capture-bar"> 725 <button id="romCapture" class="capture-bar-cta bg-green-400 hover:bg-green-500 text-green-900">
726 <span>Capture</span> 727 </button> 728 <button id="romStabilityStart" class="hidden capture-bar-cta bg-green-400 hover:bg-green-500 text-green-900"> 729 <span>Start</span> 730 </button> 731 <button id="romStabilityStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 732 <span>Stop</span> 733 </button> 734 <button id="resetBoth" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 735 <span>Reset Both</span> 736 </button> 737 <button id="romResetMax" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 738 <span>Reset</span> 739 </button> 740 <div class="min-w-6"></div> 741 <div class="flex flex-col"> 742 <span class="text-xs mb-[-4px] pt-1">Capture Type</span> 743 <span id="romCaptureType" class="font-bold text-lg">Manual Capture</span> 744 </div> 745 <div class="min-w-6"></div> 746 <button id="romCaptureConfig" class="settings-button"> 747 <i class="fas fa-gear text-2xl p-2 text-gray-500"></i> 748 </button> 749 </div> 750</div> 751<div id="romDismissModal" class="fade-out absolute left-0 top-0 right-0 bottom-0"></div> 752<div id="romCaptureModal" class="fade-out absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 p-4 transition-opacity duration-500 ease-in-out"> 753 <div class="w-96 bg-gray-100 rounded-xl p-6 shadow-lg"> 754 <h2 class="text-lg font-semibold text-gray-800 mb-4 text-center">Capture Settings</h2> 755 756 <!-- Manual Capture --> 757 <div class="flex justify-between items-center mb-4"> 758 <div> 759 <p class="text-sm font-medium text-gray-900">Manual Capture</p> 760 <p class="text-xs text-gray-600"> 761 Manually trigger the capture once the individual reaches maximum ROM. 762 </p> 763 </div> 764 <button class="controller-modal-button active-button" data-capture-method="manual"></button> 765 </div> 766 767 <!-- Stable Capture --> 768 <div class="flex justify-between items-center mb-4"> 769 <div> 770 <p class="text-sm font-medium text-gray-900">Stability Capture</p> 771 <p class="text-xs text-gray-600"> 772 Captures once the individual maintains stability in the movement for 3 seconds. 773 </p> 774 </div> 775 <button class="controller-modal-button select-button" data-capture-method="stability"></button> 776 </div> 777 778 <!-- Max Capture --> 779 <div class="flex justify-between items-center"> 780 <div> 781 <p class="text-sm font-medium text-gray-900">Maximum ROM Capture</p> 782 <p class="text-xs text-gray-600"> 783 Captures the maximum ROM throughout the duration of the assessment. 784 </p> 785 </div> 786 <button class="controller-modal-button select-button" data-capture-method="maximum"></button> 787 </div> 788 </div> 789</div>`;var qa;((s)=>{s.MANUAL="manual";s.STABILITY="stability";s.MAXIMUM="maximum"})(qa||={});var Lc=500;class Xa{vision;record=new bi;maxImageCanvasLeft=document.createElement("canvas");maxImageCanvasRight=document.createElement("canvas");maxPreviewCanvas=document.createElement("canvas");maxSnapshotLeft=null;maxSnapshotRight=null;maxPreviewSnapshot=null;persistingMaxSnapshotLeft=null;persistingMaxSnapshotRight=null;persistingPreviewSnapshot=null;maxImageVersionLeft=0;maxImageVersionRight=0;persistedImageVersionLeft=0;persistedImageVersionRight=0;maxPreviewVersion=0;persistedPreviewVersion=0;maximumPersistInFlight=!1;maximumPersistDirty=!1;maximumPersistTimeout=null;maximumLastPersistAt=0;stabilityDiscardSeconds=3;stabilityCaptureWindowSec=0.5;stabilityTriggerDurationMs=500;stabilityAngleTolerance=2;lastStableTimeLeft=0;lastStableTimeRight=0;stabilityStartTime=null;stabilityLeftValues=[];stabilityRightValues=[];lastMedianLeft=0;lastMedianRight=0;patientDelayStarted=!1;patientTimer=null;patientDelayFinished=!1;uiState=ft({capturing:!1,resetting:!1,showingCaptureModal:!1,captureMethod:"manual",lastResults:new H,patientSide:null},(...e)=>{this.updateState(...e)});constructor(e){this.vision=e;let t=this.getCookie("romCaptureMethod");if(t&&Object.values(qa).includes(t))this.uiState.captureMethod=t;e.getRecord((i)=>{if(this.record=i,this.uiState.captureMethod==="maximum")this.syncMaximumImageTrackingFromRecord();this.updateState()})}showControls(e,t){$(e).html(za),$(t).html(Ya),k("#romCapture",()=>{this.capture()}),k("#romStabilityStart",()=>{this.resetStabilityTracking()}),k("#romStabilityStop",()=>{this.stabilityStartTime=null}),k("#romCaptureConfig",()=>
789{this.uiState.showingCaptureModal=!0}),k("#romDismissModal",()=>{this.uiState.showingCaptureModal=!1}),k("#romResetMax",()=>{this.resetMax()}),k("#leftReset",()=>{this.resetLeft()}),k("#rightReset",()=>{this.resetRight()}),k("#resetBoth",()=>{this.resetBoth()}),k("#romCaptureModal .controller-modal-button",(i)=>{this.selectCaptureMethod(i)})}async process(e,t){if(this.uiState.lastResults=e,t.drawLabels(this.normalizeOverlayLabels(e.labels)),t.drawPaths(e.paths),t.drawPoints(e.points),this.uiState.captureMethod==="maximum")this.processMaximumROM();else if(this.uiState.captureMethod==="stability")await this.processStabilityROM()}updateState(e,t,i){let s=(c,p,m)=>{if(p)$(`#${c}RomValue`).html(`${Math.floor(p)}°`);else if(m)$(`#${c}RomValue`).html(`${Math.floor(m)}°`);else $(`#${c}RomValue`).html("0°");Rt(`#${c}RomBox > div.captured-indicator`,"fade-out",!p)};s("left",this.record.leftData,this.uiState.lastResults.leftData),s("right",this.record.rightData,this.uiState.lastResults.rightData),Rt("#romCapture","loading",this.uiState.capturing),Rt("#romResetMax","loading",this.uiState.resetting),Rt("#romCaptureContainer","partial-fade",this.uiState.showingCaptureModal),Rt("#romCaptureModal","fade-out",!this.uiState.showingCaptureModal),Rt("#romDismissModal","fade-out",!this.uiState.showingCaptureModal),this.vision.toggleBlur(this.uiState.showingCaptureModal),$("#romCaptureType").text(this.captureMethodName());let a=!!(this.record.leftData&&this.record.rightData);U("#romCapture",this.uiState.captureMethod!=="manual"||a),U("#romStabilityStart",this.uiState.captureMethod!=="stability"||this.stabilityStartTime!==null||a),U("#romStabilityStop",this.uiState.captureMethod!=="stability"||this.stabilityStartTime===null),U("#resetBoth",this.uiState.captureMethod==="maximum"||!a),U("#romResetMax",this.uiState.captureMethod!=="maximum"),U("#leftReset",!this.record.leftData),U("#rightReset",!this.record.rightData);let o=$(`#romCaptureModal .controller-modal-button[data-capture-method='${this.uiState.captureMethod}']`),l=$(`#romCaptureModal .controller-modal-button:not([data-capture-method='${this.uiState.captureMethod}'])`);if(o.addClass("active-button").removeClass("select-button"),l.addClass("select-button").removeClass("active-button"),t==="captureMethod")this.setCookie("romCaptureMethod",this.uiState.captureMethod,30)}setCookie(e,t,i){let s=new Date;s.setTime(s.getTime()+i*24*60*60*1000);let a=`expires=${s.toUTCString()}`;document.cookie=`${e}=${t};${a};path=/`}getCookie(e){let t=`${e}=`,i=document.cookie.split(";");for(let s of i){let a=s.trim();if(a.startsWith(t))return a.substring(t.length,a.length)}return null}selectCaptureMethod(e){let i=$(e.target).data("capture-method");if(this.uiState.captureMethod==="maximum"&&i!=="maximum")this.flushMaximumRecordPersist();if(this.uiState.captureMethod=i,this.uiState.showingCaptureModal=!1,i==="maximum")this.syncMaximumImageTrackingFromRecord()}captureMethodName(){switch(this.uiState.captureMethod){case"manual":return"Manual Capture";case"stability":return"Stability Capture";case"maximum":return"Maximum ROM"}}normalizeOverlayLabels(e){return e.map((t)=>{if(typeof t.value!=="number")return t;let i=this.record.normalizePoseFrameEditResultValue(t.value);return typeof i==="number"||typeof i==="string"?{...t,value:i}:t})}async capture(){if(this.uiState.capturing)return;this.uiState.capturing=!0;try{let e=!this.record.leftData&&this.uiState.lastResults.leftData?Math.floor(this.uiState.lastResults.leftData):null,t=!this.record.rightData&&this.uiState.lastResults.rightData?Math.floor(this.uiState.lastResults.rightData):null;if(e===null&&t===null)return;let i=this.vision.captureCurrentFrameSnapshot({includeDisplayFrame:!0});if(!i)return;let s=await this.vision.encodeCaptureSnapshotImage(i);if(e!==null)this.record.leftData=e,this.record.leftImage=s,this.record.setPoseFrame(i.getPoseFrame({imageKey:"leftImage",side:"left"}));if(t!==null)this.record.rightData=t,this.record.rightImage=s,this.record.setPoseFrame(i.getPoseFrame({imageKey:"rightImage",side:"right"}));await this.vision.setRecord(this.record)}catch(e){console.error("Error capturing manual ROM image:",e)}finally{this.uiState.capturing=!1}}async processStabilityROM(){if(!this.stabilityStartTime)return;let e=Date.now();if((e-this.stabilityStartTime)/1000<this.stabilityDiscardSeconds)return;let i=this.uiState.lastResults.leftData??null,s=this.uiState.lastResults.rightData??null;if(i)this.stabilityLeftValues.push({timestamp:e,value:Math.round(i)});if(s)this.stabilityRightValues.push({timestamp:e,value:Math.round(s)});let a=e-this.stabilityCaptureWindowSec*1000;this.stabilityLeftValues=this.stabilityLeftValues.filter((m)=>m.timestamp>=a),this.stabilityRightValues=this.stabilityRightValues.filter((m)=>m.timestamp>=a);let o=this.computeMedian(this.stabilityLeftValues.map((m)=>m.value)),l=this.computeMedian(this.stabilityRightValues.map((m)=>m.value)),c=!1;if(o!==null)if(Math.abs(o-this.lastMedianLeft)<=this.stabilityAngleTolerance){if(this.lastStableTimeLeft===0)this.lastStableTimeLeft=e;else if(e-this.lastStableTimeLeft>=this.stabilityTriggerDurationMs)c=!0,this.lastStableTimeLeft=0,this.lastMedianLeft=0,this.stabilityLeftValues=[]}else this.lastMedianLeft=o,this.lastStableTimeLeft=0;let p=!1;if(l!==null)if(Math.abs(l-this.lastMedianRight)<=this.stabilityAngleTolerance){if(this.lastStableTimeRight===0)this.lastStableTimeRight=e;else if(e-this.lastStableTimeRight>=this.stabilityTriggerDurationMs)p=!0,this.lastStableTimeRight=0,this.lastMedianRight=0,this.stabilityRightValues=[]}else this.lastMedianRight=l,this.lastStableTimeRight=0;if(c||p){if(this.uiState.patientSide)c=this.uiState.patientSide==="left"&&c,p=this.uiState.patientSide==="right"&&p;if(c||p)await this.handleStabilityCapture(c,p)}}computeMedian(e){if(!e.length)return null;let t=[...e].sort((s,a)=>s-a),i=Math.floor(t.length/2);return t[i]}async handleStabilityCapture(e,t){if(this.record.leftData&&this.record.rightData)return;try{let s=e&&this.uiState.lastResults.leftData!==null&&!this.record.leftData?Math.floor(this.uiState.lastResults.leftData):null,a=t&&this.uiState.lastResults.rightData!==null&&!this.record.rightData?Math.floor(this.uiState.lastResults.rightData):null;if(s===null&&a===null)return;let o=this.vision.captureCurrentFrameSnapshot({includeDisplayFrame:!0});if(!o)return;let l=await this.vision.encodeCaptureSnapshotImage(o);if(s!==null)this.record.leftData=s,this.record.leftImage=l,this.record.setPoseFrame
789(o.getPoseFrame({imageKey:"leftImage",side:"left"}));if(a!==null)this.record.rightData=a,this.record.rightImage=l,this.record.setPoseFrame(o.getPoseFrame({imageKey:"rightImage",side:"right"}));await this.vision.setRecord(this.record)}catch(s){console.error("Error capturing stability ROM image:",s)}if(!!(this.record.leftData&&this.record.rightData))this.stabilityStartTime=null,this.updateState()}syncMaximumImageTrackingFromRecord(){this.maxSnapshotLeft=null,this.maxSnapshotRight=null,this.maxPreviewSnapshot=null,this.persistingMaxSnapshotLeft=null,this.persistingMaxSnapshotRight=null,this.persistingPreviewSnapshot=null,this.maxImageVersionLeft=this.record.leftImage?1:0,this.maxImageVersionRight=this.record.rightImage?1:0,this.persistedImageVersionLeft=this.maxImageVersionLeft,this.persistedImageVersionRight=this.maxImageVersionRight,this.maxPreviewVersion=this.record.leftImage||this.record.rightImage?1:0,this.persistedPreviewVersion=this.maxPreviewVersion}queueMaximumPersist(){if(this.maximumPersistDirty=!0,this.maximumPersistInFlight||this.maximumPersistTimeout)return;let e=Date.now()-this.maximumLastPersistAt,t=Math.max(0,Lc-e);this.maximumPersistTimeout=setTimeout(()=>{this.maximumPersistTimeout=null,this.persistMaximumRecord()},t)}async waitForMaximumPersistInFlight(){while(this.maximumPersistInFlight)await new Promise((e)=>{setTimeout(e,5)})}async flushMaximumRecordPersist(){if(this.maximumPersistTimeout)clearTimeout(this.maximumPersistTimeout),this.maximumPersistTimeout=null;await this.waitForMaximumPersistInFlight(),this.maximumPersistDirty=!0,await this.persistMaximumRecord()}resetMaximumImageTracking(){if(this.maximumPersistTimeout)clearTimeout(this.maximumPersistTimeout),this.maximumPersistTimeout=null;this.maximumPersistDirty=!1,this.maximumLastPersistAt=0,this.maxImageVersionLeft=0,this.maxImageVersionRight=0,this.maxSnapshotLeft=null,this.maxSnapshotRight=null,this.maxPreviewSnapshot=null,this.persistingMaxSnapshotLeft=null,this.persistingMaxSnapshotRight=null,this.persistingPreviewSnapshot=null,this.persistedImageVersionLeft=0,this.persistedImageVersionRight=0,this.maxPreviewVersion=0,this.persistedPreviewVersion=0}getMaximumRecordCanvas(e){let t=e==="left"?this.maxSnapshotLeft:this.maxSnapshotRight,i=e==="left"?this.persistingMaxSnapshotLeft:this.persistingMaxSnapshotRight;if(t&&t===i)return document.createElement("canvas");return e==="left"?this.maxImageCanvasLeft:this.maxImageCanvasRight}getMaximumPreviewCanvas(){if(this.maxPreviewSnapshot&&this.maxPreviewSnapshot===this.persistingPreviewSnapshot)return document.createElement("canvas");return this.maxPreviewCanvas}captureMaximumSnapshot(e,t){let i=this.vision.captureCurrentFrameSnapshot({includeDisplayFrame:!0,recordCanvas:this.getMaximumRecordCanvas(e),displayCanvas:this.getMaximumPreviewCanvas()});if(!i)return!1;if(e==="left")this.maxImageVersionLeft+=1,this.maxSnapshotLeft={value:t,version:this.maxImageVersionLeft,snapshot:i};else this.maxImageVersionRight+=1,this.maxSnapshotRight={value:t,version:this.maxImageVersionRight,snapshot:i};if(i.displayCanvas)this.maxPreviewVersion+=1,this.maxPreviewSnapshot={version:this.maxPreviewVersion,snapshot:i};return!0}async persistMaximumRecord(){if(this.maximumPersistInFlight||!this.maximumPersistDirty)return;this.maximumPersistInFlight=!0,this.maximumPersistDirty=!1;try{let e=this.maxSnapshotLeft,t=this.maxSnapshotRight,i=this.maxPreviewSnapshot;this.persistingMaxSnapshotLeft=e,this.persistingMaxSnapshotRight=t,this.persistingPreviewSnapshot=i;let s=new bi;if(s.leftData=e?.value??this.record.leftData,s.rightData=t?.value??this.record.rightData,s.leftImage=this.record.leftImage,s.rightImage=this.record.rightImage,this.record.poseFrames)s.poseFrames={...this.record.poseFrames};if(e&&e.version>this.persistedImageVersionLeft){let a=await this.vision.encodeCaptureSnapshotImage(e.snapshot,{setPreviewAsLastCapture:!1}),o=e.snapshot.getPoseFrame({imageKey:"leftImage",side:"left"});if(s.leftData=e.value,s.leftImage=a,s.setPoseFrame(o),e===this.maxSnapshotLeft)this.record.leftData=e.value,this.record.leftImage=a,this.record.setPoseFrame
789(o),this.persistedImageVersionLeft=e.version;else this.maximumPersistDirty=!0}if(t&&t.version>this.persistedImageVersionRight){let a=await this.vision.encodeCaptureSnapshotImage(t.snapshot,{setPreviewAsLastCapture:!1}),o=t.snapshot.getPoseFrame({imageKey:"rightImage",side:"right"});if(s.rightData=t.value,s.rightImage=a,s.setPoseFrame(o),t===this.maxSnapshotRight)this.record.rightData=t.value,this.record.rightImage=a,this.record.setPoseFrame(o),this.persistedImageVersionRight=t.version;else this.maximumPersistDirty=!0}if(i&&i.version>this.persistedPreviewVersion&&i.snapshot.displayCanvas)if(await this.vision.encodeRecordImage(i.snapshot.displayCanvas,{setAsLastCapture:!0}),i===this.maxPreviewSnapshot)this.persistedPreviewVersion=i.version;else this.maximumPersistDirty=!0;if(!s.isEmpty())await this.vision.setRecord(s);this.maximumLastPersistAt=Date.now()}catch(e){console.error("Error persisting maximum ROM:",e),this.maximumPersistDirty=!0}finally{if(this.persistingMaxSnapshotLeft=null,this.persistingMaxSnapshotRight=null,this.persistingPreviewSnapshot=null,this.maximumPersistInFlight=!1,this.maximumPersistDirty)this.queueMaximumPersist()}}processMaximumROM(){let e=!1;if(this.uiState.lastResults.leftData){let t=Math.floor(this.uiState.lastResults.leftData);if((!this.record.leftData||t>Math.floor(this.record.leftData))&&this.captureMaximumSnapshot("left",t))this.record.leftData=t,e=!0}if(this.uiState.lastResults.rightData){let t=Math.floor(this.uiState.lastResults.rightData);if((!this.record.rightData||t>Math.floor(this.record.rightData))&&this.captureMaximumSnapshot("right",t))this.record.rightData=t,e=!0}if(e)this.queueMaximumPersist()}resetStabilityTracking(){this.stabilityStartTime=Date.now(),this.stabilityLeftValues=[],this.stabilityRightValues=[],this.lastMedianLeft=0,this.lastMedianRight=0,this.lastStableTimeLeft=0,this.lastStableTimeRight=0}async resetMax(){if(this.uiState.resetting=!0,this.uiState.captureMethod==="maximum")await this.flushMaximumRecordPersist();await this.vision.clearRecord(),this.record=new bi,this.resetMaximumImageTracking(),setTimeout(()=>{this.uiState.resetting=!1},1000)}async resetBoth(){if(this.uiState.resetting=!0,this.uiState.captureMethod==="maximum")await this.flushMaximumRecordPersist();await this.vision.clearRecord(),this.record=new bi,this.resetMaximumImageTracking(),setTimeout(()=>{this.uiState.resetting=!1},1000)}async resetLeft(){if(this.uiState.captureMethod==="maximum")await this.flushMaximumRecordPersist();this.record.leftData=null,this.record.leftImage=null,this.record.clearPoseFrame("left"),await this.vision.setRecord(this.record),this.maxImageVersionLeft=0,this.maxSnapshotLeft=null,this.persistingMaxSnapshotLeft=null,this.persistedImageVersionLeft=0}async resetRight(){if(this.uiState.captureMethod==="maximum")await this.flushMaximumRecordPersist();this.record.rightData=null,this.record.rightImage=null,this.record.clearPoseFrame("right"),await this.vision.setRecord(this.record),this.maxImageVersionRight=0,this.maxSnapshotRight=null,this.persistingMaxSnapshotRight=null,this.persistedImageVersionRight=0}patientSetup(e,t){this.uiState.patientSide=e??null,this.uiState.captureMethod="stability"}async patientProcess(e,t){if(!this.uiState.patientSide)return;if(this.uiState.lastResults=e,t.drawLabels(this.normalizeOverlayLabels(e.labels),this.uiState.patientSide),t.drawPaths(e.paths,this.uiState.patientSide),t.drawPoints(e.points,this.uiState.patientSide),!this.patientDelayStarted)this.startPatientDelay(),this.patientDelayStarted=!0;if(this.patientDelayFinished)await this.processStabilityROM()}startPatientDelay(){let e=3;this.patientTimer=setInterval(()=>{if(e--,e<=0){if(this.patientTimer)clearInterval(this.patientTimer),this.patientTimer=null,this.stabilityStartTime=Date.now();this.patientDelayFinished=!0}},1000)}patientPause(){if(this.uiState.captureMethod==="maximum")this.flushMaximumRecordPersist();if(this.patientTimer)clearInterval(this.patientTimer),this.patientTimer=null;this.stabilityStartTime=null,this.stabilityLeftValues=[],this.stabilityRightValues=[],this.lastMedianLeft=0,this.lastMedianRight=0,this.lastStableTimeLeft=0,this.lastStableTimeRight=0,this.patientDelayStarted=!1,this.patientDelayFinished=!1}patientData(e){if(e==="step")return 0;else return 0}}var Ot={};Et(Ot,{AnteriorSquatController:()=>eo,SagittalSquatController:()=>so,programs:()=>cs});var Za=`<div class="bottom-controller-container"> 790 <div class="grow min-w-[1px]"></div>
791 <div id="leftData" class="min-w-[455px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center"> 792 <h3 class="col-span-6 font-bold text-lg">Left Side</h3> 793 <div class="col-span-6 text-end"> 794 <button id="leftReset" class="hidden data-results-reset"> 795 <span>Reset</span> 796 </button> 797 </div> 798 <div class="col-span-4 text-sm">Knee alignment</div> 799 <div class="col-span-3 text-sm value kneeAlignment">--</div> 800 <div class="col-span-3 text-sm">Torso tilt</div> 801 <div class="col-span-2 text-sm value backLateralFlexion">--</div> 802 <div class="col-span-4 text-sm">Foot alignment</div> 803 <div class="col-span-3 text-sm value toeAlignment">--</div> 804 <div class="col-span-3 text-sm">Pelvic drop</div> 805 <div class="col-span-2 text-sm value pelvicDrop">--</div> 806 </div> 807 <div class="grow"></div> 808 <div id="rightData" class="min-w-[455px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center"> 809 <h3 class="col-span-6 font-bold text-lg">Right Side</h3> 810 <div class="col-span-6 text-end"> 811 <button id="rightReset" class="hidden data-results-reset"> 812 <span>Reset</span> 813 </button> 814 </div> 815 <div class="col-span-4 text-sm">Knee alignment</div> 816 <div class="col-span-3 text-sm value kneeAlignment">--</div> 817 <div class="col-span-3 text-sm">Torso tilt</div> 818 <div class="col-span-2 text-sm value backLateralFlexion">--</div> 819 <div class="col-span-4 text-sm">Foot alignment</div> 820 <div class="col-span-3 text-sm value toeAlignment">--</div> 821 <div class="col-span-3 text-sm">Pelvic drop</div> 822 <div class="col-span-2 text-sm value pelvicDrop">--</div> 823 </div> 824 <div class="grow min-w-[1px]"></div> 825</div>`;var Qa=`<div class="bottom-controller-container"> 826 <div class="grow min-w-px"></div> 827 <div id="leftData" class="min-w-[285px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center"> 828 <h3 class="col-span-12 font-bold text-lg">Left Side</h3> 829 <div class="col-span-7 text-sm">Knee alignment</div> 830 <div class="col-span-5 text-sm value kneeAlignment">--</div> 831 <div class="col-span-7 text-sm">Foot alignment</div> 832 <div class="col-span-5 text-sm value toeAlignment">--</div> 833 </div> 834 <div class="grow"></div> 835 <div id="stabilityData" class="min-w-[285px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center"> 836 <h3 class="col-span-12 font-bold text-lg">Stability</h3> 837 <div class="col-span-7 text-sm">Back lateral flexion</div> 838 <div class="col-span-5 text-sm value backLateralFlexion">--</div> 839 <div class="col-span-7 text-sm">Pelvic drop</div> 840 <div class="col-span-5 text-sm value pelvicDrop">--</div> 841 </div> 842 <div class="grow"></div> 843 <div id="rightData" class="min-w-[285px] grid grid-cols-12 gap-4 bg-white rounded-md shadow-sm p-4 items-center"> 844 <h3 class="col-span-12 font-bold text-lg">Right Side</h3> 845 <div class="col-span-7 text-sm">Knee alignment</div> 846 <div class="col-span-5 text-sm value kneeAlignment">--</div> 847 <div class="col-span-7 text-sm">Foot alignment</div> 848 <div class="col-span-5 text-sm value toeAlignment">--</div> 849 </div> 850 <div class="grow min-w-px"></div> 851</div>`;var to=`<div class="top-controller-container"> 852 <div id="anteriorSquatCaptureContainer" class="capture-bar"> 853 <button id="anteriorSquatCapture" class="capture-bar-cta bg-green-400 hover:bg-green-500 text-green-900"> 854 <span>Start</span> 855 </button> 856 <button id="anteriorSquatReset" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 857 <span>Reset</span> 858 </button> 859 <button id="anteriorSquatStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 860 <span>Stop</span> 861 </button> 862 <div class="min-w-6"></div> 863 <div class="flex flex-col">
864 <span id="anteriorSquatCaptureTypeHeader" class="text-xs mb-[-4px] pt-1">Capture Type</span> 865 <span id="anteriorSquatCaptureTypeSubheader" class="font-bold text-lg">Auto-capture</span> 866 </div> 867 <div class="min-w-6"></div> 868 </div> 869</div>`;class eo{vision;mode;uiState=ft({captureStatus:0,currentSide:1,patientSide:null},()=>{this.updateState()});record;maxResults=null;maxMidHipY=Number.NEGATIVE_INFINITY;maxImageCanvas=document.createElement("canvas");maxPreviewCanvas=document.createElement("canvas");maxSnapshot=null;constructor(e,t){if(this.vision=e,this.mode=t,this.mode==="overhead")this.record=new Di,e.getRecord((i)=>{this.record=i,this.updateState()});else if(this.mode==="regular")this.record=new yi,e.getRecord((i)=>{this.record=i,this.updateState()});else this.record=new Ve,e.getRecord((i)=>{this.record=i,this.updateState()})}showControls(e,t){$(e).html(to),$(t).html(this.mode==="overhead"||this.mode==="regular"?Qa:Za),k("#anteriorSquatCapture",()=>{this.uiState.captureStatus=1}),k("#anteriorSquatStop",()=>{this.reset()}),k("#anteriorSquatReset",()=>{this.reset()}),k("#leftReset",()=>{this.resetLeftSide()}),k("#rightReset",()=>{this.resetRightSide()})}async process(e,t){if(this.mode==="overhead"||this.mode==="regular")t.drawLabels(e.labels),t.drawPaths(e.paths),t.drawPoints(e.points);else if(e.leftData)t.drawLabels(e.labels,"left"),t.drawPaths(e.paths,"left"),t.drawPoints(e.points,"left");else t.drawLabels(e.labels,"right"),t.drawPaths(e.paths,"right"),t.drawPoints(e.points,"right");if(e.direction!=="front"&&this.uiState.currentSide!==0)this.resetVariables(),this.uiState.currentSide=0;else if(e.direction==="front"&&this.uiState.currentSide!==1)this.resetVariables(),this.uiState.currentSide=1;await this.processCapture(e)}captureMaxSnapshot(){return this.vision.captureCurrentFrameSnapshot({includeDisplayFrame:!0,recordCanvas:this.maxImageCanvas,displayCanvas:this.maxPreviewCanvas})}async processCapture(e){if(this.uiState.captureStatus===1){let t=e.midHipY??0;if(this.mode==="regular"&&e instanceof Ei){if(t>=this.maxMidHipY){let i=this.captureMaxSnapshot();if(!i)return;this.maxResults=e,this.maxMidHipY=t,this.maxSnapshot=i}else if(t<=0.9*this.maxMidHipY&&this.maxResults)await this.capture()}else if(this.mode==="overhead"&&e instanceof wi){if((e.avgShoulderAbduction??0)>=100&&t>=this.maxMidHipY){let s=this.captureMaxSnapshot();if(!s)return;this.maxResults=e,this.maxMidHipY=t,this.maxSnapshot=s}else if(t<=0.9*this.maxMidHipY&&this.maxResults)await this.capture()}else if(this.mode==="singleleg"&&e instanceof Ai){if(this.uiState.patientSide){if(e.leftData&&this.uiState.patientSide==="right"||e.rightData&&this.uiState.patientSide==="left")return}if(e.armsCrossed&&t>=this.maxMidHipY){let s=this.captureMaxSnapshot();if(!s)return;this.maxResults=e,this.maxMidHipY=t,this.maxSnapshot=s}else if(t<=0.9*this.maxMidHipY&&this.maxResults)await this.capture()}}}async getMaxImageBlob(){if(!this.maxSnapshot)return null;return await this.vision.encodeCaptureSnapshotImage(this.maxSnapshot,{setPreviewAsLastCapture:!0})}resetVariables(){this.uiState.captureStatus=0,this.uiState.currentSide=1,this.maxResults=null,this.maxMidHipY=Number.NEGATIVE_INFINITY,this.maxSnapshot=null}async reset(){if(this.mode==="overhead")this.record=new Di;else if(this.mode==="regular")this.record=new yi;else this.record=new Ve;await this.vision.clearRecord(),this.resetVariables()}async resetLeftSide(){if(this.record instanceof Ve)this.record.leftData=null,this.record.leftImage=null,this.record.clearPoseFrame("left"),await this.vision.setRecord(this.record),this.resetVariables()}async resetRightSide(){if(this.record instanceof Ve)this.record.rightData=null,this.record.rightImage=null,this.record.clearPoseFrame("right"),await this.vision.setRecord(this.record),this.resetVariables()}async capture(){let e=this.maxSnapshot,t=await this.getMaxImageBlob();if(this.maxResults){if(this.record instanceof Di&&this.maxResults instanceof wi||this.record instanceof yi&&this.maxResults instanceof Ei){if(this.record.backLateralFlexion=this.maxResults.backLateralFlexion,this.record.pelvicDrop=this.maxResults.pelvicDrop,this.record.leftData=this.maxResults.leftData,this.record.rightData=this.maxResults.rightData,t)this.record.image=t;
869if(t&&e)this.record.setPoseFrame(e.getPoseFrame({imageKey:"image"}))}else if(this.record instanceof Ve&&this.maxResults instanceof Ai){if(this.maxResults.leftData&&!this.record.leftData){if(this.record.leftData={backLateralFlexion:this.maxResults.backLateralFlexion,pelvicDrop:this.maxResults.pelvicDrop,...this.maxResults.leftData},t){if(this.record.leftImage=t,e)this.record.setPoseFrame(e.getPoseFrame({imageKey:"leftImage",side:"left"}))}}if(this.maxResults.rightData&&!this.record.rightData){if(this.record.rightData={backLateralFlexion:this.maxResults.backLateralFlexion,pelvicDrop:this.maxResults.pelvicDrop,...this.maxResults.rightData},t){if(this.record.rightImage=t,e)this.record.setPoseFrame(e.getPoseFrame({imageKey:"rightImage",side:"right"}))}}}}let i=!!(this.record.leftData??this.record.rightData),s=!!(this.record.leftData&&this.record.rightData);if(i)await this.vision.setRecord(this.record);this.uiState.captureStatus=s?2:0,this.resetVariables()}updateState(){switch(U("#anteriorSquatCapture",this.uiState.captureStatus!==0),U("#anteriorSquatStop",this.uiState.captureStatus!==1),U("#anteriorSquatReset",this.uiState.captureStatus!==2),U("#leftReset",!this.record.leftData),U("#rightReset",!this.record.rightData),this.uiState.captureStatus){case 0:$("#anteriorSquatCaptureTypeHeader").text("Capture Type"),$("#anteriorSquatCaptureTypeSubheader").text("Automatic");break;case 1:$("#anteriorSquatCaptureTypeHeader").text("Capture Status"),$("#anteriorSquatCaptureTypeSubheader").text("Analyzing...");break;case 2:$("#anteriorSquatCaptureTypeSubheader").text("Captured!"),$("#anteriorSquatReset").text(this.mode==="overhead"||this.mode==="regular"?"Reset":"Reset Both");break;default:break}let e=(i,s)=>{$(i).text(s?`${s.toFixed(1)}°`:"--")},t=(i,s,a)=>{if(s&&a){let o=`${a.toFixed(1)}° ${s}`;$(i).text(o)}else $(i).text("--")};if(this.record instanceof Di||this.record instanceof yi)t("#leftData .kneeAlignment",this.record.leftData?.kneeAlignment,this.record.leftData?.kneeValue),t("#leftData .toeAlignment",this.record.leftData?.toeAlignment,this.record.leftData?.toeValue),t("#rightData .kneeAlignment",this.record.rightData?.kneeAlignment,this.record.rightData?.kneeValue),t("#rightData .toeAlignment",this.record.rightData?.toeAlignment,this.record.rightData?.toeValue),e("#stabilityData .backLateralFlexion",this.record.backLateralFlexion),e("#stabilityData .pelvicDrop",this.record.pelvicDrop);if(this.record instanceof Ve)t("#leftData .kneeAlignment",this.record.leftData?.kneeAlignment,this.record.leftData?.kneeValue),t("#leftData .toeAlignment",this.record.leftData?.toeAlignment,this.record.leftData?.toeValue),e("#leftData .backLateralFlexion",this.record.leftData?.backLateralFlexion),e("#leftData .pelvicDrop",this.record.leftData?.pelvicDrop),t("#rightData .kneeAlignment",this.record.rightData?.kneeAlignment,this.record.rightData?.kneeValue),t("#rightData .toeAlignment",this.record.rightData?.toeAlignment,this.record.rightData?.toeValue),e("#rightData .backLateralFlexion",this.record.rightData?.backLateralFlexion),e("#rightData .pelvicDrop",this.record.rightData?.pelvicDrop)}patientSetup(e,t){this.uiState.patientSide=e??null,this.uiState.captureStatus=1}async patientProcess(e,t){if(this.mode==="overhead"||this.mode==="regular")t.drawLabels(e.labels),t.drawPaths(e.paths),t.drawPoints(e.points);else if(this.uiState.patientSide!==null)t.drawLabels(e.labels,this.uiState.patientSide),t.drawPaths(e.paths,this.uiState.patientSide),t.drawPoints(e.points,this.uiState.patientSide);await this.processCapture(e)}patientPause(){this.uiState.captureStatus=1,this.maxResults=null,this.maxMidHipY=Number.NEGATIVE_INFINITY,this.maxSnapshot=null}patientData(e){if(e==="step")return 0;else return 0}}var io=`<div class="bottom-controller-container"> 870 <div class="grow min-w-[1px]"></div> 871 <div id="sagittalLeftSquatData" class="min-w-[420px] grid grid-cols-12 gap-x-1 gap-y-4 bg-white rounded-md shadow-sm p-4 items-center border-4 border-white"> 872 <h3 class="col-span-6 font-bold text-lg">Left Side</h3> 873 <div class="col-span-6 text-end"> 874 <button id="leftReset" class="hidden data-results-reset">
875 <span>Reset</span> 876 </button> 877 </div> 878 <div class="col-span-2 text-sm">Depth</div> 879 <div class="col-span-1 text-sm value kneeFlexion">--</div> 880 <div class="col-span-3 text-sm text-center">Trunk lean</div> 881 <div class="col-span-2 text-sm value trunkLean text-center">--</div> 882 <div class="col-span-3 text-sm">Hip flexion</div> 883 <div class="col-span-1 text-sm value hipFlexion">--</div> 884 <div class="col-span-4 text-sm shoulderFlexionContainer">Shoulder flexion</div> 885 <div class="col-span-2 text-sm value shoulderFlexion shoulderFlexionContainer">--</div> 886 <div class="col-span-4 text-sm">Ankle dorsiflexion</div> 887 <div class="col-span-2 text-sm value ankleDorsiFlexion">--</div> 888 </div> 889 <div class="grow"></div> 890 <div id="sagittalRightSquatData" class="min-w-[420px] grid grid-cols-12 gap-x-1 gap-y-4 bg-white rounded-md shadow-sm p-4 items-center border-4 border-white"> 891 <h3 class="col-span-6 font-bold text-lg">Right Side</h3> 892 <div class="col-span-6 text-end"> 893 <button id="rightReset" class="hidden data-results-reset"> 894 <span>Reset</span> 895 </button> 896 </div> 897 <div class="col-span-2 text-sm">Depth</div> 898 <div class="col-span-1 text-sm value kneeFlexion">--</div> 899 <div class="col-span-3 text-sm text-center">Trunk lean</div> 900 <div class="col-span-2 text-sm value trunkLean text-center">--</div> 901 <div class="col-span-3 text-sm">Hip flexion</div> 902 <div class="col-span-1 text-sm value hipFlexion">--</div> 903 <div class="col-span-4 text-sm shoulderFlexionContainer">Shoulder flexion</div> 904 <div class="col-span-2 text-sm value shoulderFlexion shoulderFlexionContainer">--</div> 905 <div class="col-span-4 text-sm">Ankle dorsi-flexion</div> 906 <div class="col-span-2 text-sm value ankleDorsiFlexion">--</div> 907 </div> 908 <div class="grow min-w-[1px]"></div> 909</div> 910`;var no=`<div class="top-controller-container"> 911 <div id="sagittalSquatCaptureContainer" class="capture-bar"> 912 <button id="sagittalSquatCapture" class="capture-bar-cta bg-green-400 hover:bg-green-500 text-green-900"> 913 <span>Start</span> 914 </button> 915 <button id="sagittalSquatReset" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 916 <span>Reset Both</span> 917 </button> 918 <button id="sagittalSquatStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 919 <span>Stop</span> 920 </button> 921 <div class="min-w-6"></div> 922 <div class="flex flex-col"> 923 <span id="sagittalSquatCaptureTypeHeader" class="text-xs mb-[-4px] pt-1">Capture Type</span> 924 <span id="sagittalSquatCaptureTypeSubheader" class="font-bold text-lg">Auto-capture</span> 925 </div> 926 <div class="min-w-6"></div> 927 </div> 928</div> 929`;class so{vision;mode;uiState=ft({captureStatus:0,currentSide:2},()=>{this.updateState()});record;maxResults=null;maxKneeFlexion=Number.NEGATIVE_INFINITY;minKneeFlexion=Number.MAX_VALUE;flipCount=0;threshold=5;maxImageCanvas=document.createElement("canvas");maxPreviewCanvas=document.createElement("canvas");maxSnapshot=null;constructor(e,t){if(this.vision=e,this.mode=t,this.mode==="overhead")this.record=new Ii,e.getRecord((i)=>{this.record=i,this.updateState()});else if(this.mode==="regular")this.record=new Li,e.getRecord((i)=>{this.record=i,this.updateState()});else this.record=new Fi,e.getRecord((i)=>{this.record=i,this.updateState()})}showControls(e,t){$(e).html(no),$(t).html(io),k("#sagittalSquatCapture",()=>{this.uiState.captureStatus=1}),k("#sagittalSquatStop",()=>{this.reset()}),k("#sagittalSquatReset",()=>{this.reset()}),k("#leftReset",()=>{this.resetLeftSide()}),k("#rightReset",()=>{this.resetRightSide()})}async process(e,t){if(t.drawLabels(e.labels),t.drawPaths(e.paths),t.drawPoints(e.points),e.direction==="leftSide"&&this.uiState.currentSide!==0)this.resetVariables(),this.uiState.currentSide=0;else if(e.direction==="rightSide"&&this.uiState.currentSide!==1)this.resetVariables(),this.uiState.currentSide=1;let i=0;if(this.uiState.currentSide===0)i=e.leftData?.kneeFlexion??0;else if(this.uiState.currentSide===1)i=e.rightData?.kneeFlexion??0;await this.processCaptureStatus(e,i)}
929captureMaxSnapshot(){return this.vision.captureCurrentFrameSnapshot({includeDisplayFrame:!0,recordCanvas:this.maxImageCanvas,displayCanvas:this.maxPreviewCanvas})}async processCaptureStatus(e,t){switch(this.uiState.captureStatus){case 1:if(t>=40&&t<=130&&t>this.maxKneeFlexion){let i=this.captureMaxSnapshot();if(!i)return;this.maxKneeFlexion=t,this.maxResults=e,this.flipCount=0,this.maxSnapshot=i}else if(t<=0.85*this.maxKneeFlexion){if(this.flipCount+=1,this.flipCount>=this.threshold)this.uiState.captureStatus=2,this.maxKneeFlexion=Number.NEGATIVE_INFINITY,this.flipCount=0,await this.capture()}else this.flipCount=0;break;case 2:if(t>=40&&t<=130&&t<this.minKneeFlexion)this.minKneeFlexion=t,this.flipCount=0;else if(t>=1.15*this.minKneeFlexion){if(this.flipCount+=1,this.flipCount>=this.threshold)this.uiState.captureStatus=1,this.minKneeFlexion=Number.MAX_VALUE}else this.flipCount=0;break}}async getMaxImageBlob(){if(!this.maxSnapshot)return null;return await this.vision.encodeCaptureSnapshotImage(this.maxSnapshot,{setPreviewAsLastCapture:!0})}resetVariables(){this.uiState.captureStatus=0,this.uiState.currentSide=2,this.maxResults=null,this.maxSnapshot=null,this.maxKneeFlexion=Number.NEGATIVE_INFINITY,this.minKneeFlexion=Number.MAX_VALUE,this.flipCount=0}async reset(){if(this.mode==="overhead")this.record=new Ii;else if(this.mode==="regular")this.record=new Li;else this.record=new Fi;await this.vision.clearRecord(),this.resetVariables()}async resetLeftSide(){this.record.leftData=null,this.record.leftImage=null,this.record.clearPoseFrame("left"),await this.vision.setRecord(this.record),this.resetVariables()}async resetRightSide(){this.record.rightData=null,this.record.rightImage=null,this.record.clearPoseFrame("right"),await this.vision.setRecord(this.record),this.resetVariables()}async capture(){let e=this.maxSnapshot,t=await this.getMaxImageBlob();if(this.maxResults?.leftData&&!this.record.leftData){if(this.record instanceof Ii&&this.maxResults instanceof _i)this.record.leftData=this.maxResults.leftData;else if(this.record instanceof Li&&this.maxResults instanceof Mi)this.record.leftData=this.maxResults.leftData;else if(this.record instanceof Fi&&this.maxResults instanceof Ci)this.record.leftData=this.maxResults.leftData;if(t){if(this.record.leftImage=t,e)this.record.setPoseFrame(e.getPoseFrame({imageKey:"leftImage",side:"left"}))}}if(this.maxResults?.rightData&&!this.record.rightData){if(this.record instanceof Ii&&this.maxResults instanceof _i)this.record.rightData=this.maxResults.rightData;else if(this.record instanceof Li&&this.maxResults instanceof Mi)this.record.rightData=this.maxResults.rightData;else if(this.record instanceof Fi&&this.maxResults instanceof Ci)this.record.rightData=this.maxResults.rightData;if(t){if(this.record.rightImage=t,e)this.record.setPoseFrame(e.getPoseFrame({imageKey:"rightImage",side:"right"}))}}let i=!!(this.record.leftData??this.record.rightData),s=!!(this.record.leftData&&this.record.rightData);if(i)await this.vision.setRecord(this.record);this.uiState.captureStatus=s?3:0}updateState(){switch(U("#sagittalSquatCapture",this.uiState.captureStatus!==0),U("#sagittalSquatStop",this.uiState.captureStatus!==1&&this.uiState.captureStatus!==2),U("#sagittalSquatReset",this.uiState.captureStatus!==3),U(".shoulderFlexionContainer",this.mode==="singleleg"||this.mode==="regular"),U("#leftReset",!this.record.leftData),U("#rightReset",!this.record.rightData),vt("#sagittalLeftSquatData","border-blue-500","border-white",this.uiState.currentSide===0),vt("#sagittalRightSquatData","border-blue-500","border-white",this.uiState.currentSide===1),this.uiState.captureStatus){case 0:$("#postureCaptureTypeHeader").text("Capture Type"),$("#postureCaptureTypeSubheader").text("Automatic");break;case 1:$("#postureCaptureTypeHeader").text("Capture Status"),$("#postureCaptureTypeSubheader").text("Analyzing...");break;case 3:$("#postureCaptureTypeSubheader").text("Captured!");break;default:break}let e=(t,i)=>{$(t).text(i?`${i.toFixed(1)}°`:"--")};if(e("#sagittalLeftSquatData .kneeFlexion",this.record.leftData?.kneeFlexion),e("#sagittalLeftSquatData .trunkLean",this.record.leftData?.trunkLean),e("#sagittalLeftSquatData .ankleDorsiFlexion",this.record.leftData?.ankleDorsiFlexion),e("#sagittalLeftSquatData .hipFlexion",this.record.leftData?.hipFlexion),this.record.leftData&&"shoulderFlexion"in this.record.leftData)e("#sagittalLeftSquatData .shoulderFlexion",this.record.leftData.shoulderFlexion);if(e("#sagittalRightSquatData .kneeFlexion",this.record.rightData?.kneeFlexion),e("#sagittalRightSquatData .trunkLean",this.record.rightData?.trunkLean),e("#sagittalRightSquatData .ankleDorsiFlexion",this.record.rightData?.ankleDorsiFlexion),e("#sagittalRightSquatData .hipFlexion",this.record.rightData?.hipFlexion),this.record.rightData&&"shoulderFlexion"in this.record.rightData)e("#sagittalRightSquatData .shoulderFlexion",this.record.rightData.shoulderFlexion)}patientSetup(e,t){this.uiState.currentSide=e==="left"?0:1,this.uiState.captureStatus=1}async patientProcess(e,t){t.drawLabels(e.labels),t.drawPaths(e.paths),t.drawPoints(e.points);let i=this.uiState.currentSide===0?e.leftData?.kneeFlexion??0:e.rightData?.kneeFlexion??0;await this.processCaptureStatus(e,i)}patientPause(){this.uiState.captureStatus=1,this.maxResults=null,this.maxSnapshot=null,this.maxKneeFlexion=Number.NEGATIVE_INFINITY,this.minKneeFlexion=Number.MAX_VALUE,this.flipCount=0}patientData(e){if(e==="step")return 0;else return 0}}var cs={};Et(cs,{AnteriorSquat:()=>ro,OverheadAnteriorSquat:()=>oo,OverheadSagittalSquat:()=>lo,SagittalSquat:()=>ao,SingleLegAnteriorSquat:()=>uo,SingleLegSagittalSquat:()=>co});class ro{runProgram(e){let t=new Ei;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.getMiddlePoint(i,s),o=new Oe().runProgram(e),l=new He().runProgram(e),c=new ve().runProgram(e),p=new Ce().runProgram(e);if(t.isAligned)t.points=[...o.points,...p.points,...l.points,...c.points],t.paths=[...o.paths,...p.paths,...l.paths,...c.paths],t.labels=[...p.labels,...l.labels,...c.labels,...o.labels],t.midHipY=a.y,t.pelvicDrop=o.leftPelvicDrop?-o.leftPelvicDrop:o.rightPelvicDrop,t.backLateralFlexion=p.leftData?-p.leftData:p.rightData,t.leftData={...l.leftData,...c.leftData},t.rightData={...l.rightData,...c.rightData};return t}}class ao{runProgram(e){let t=new Mi;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.getMiddlePoint(i,s),o=new jt().runProgram(e),l=new Ne().runProgram(e),c=new ke().runProgram(e),p=new Ke().runProgram(e);if(t.isAligned)t.points=[...o.points,...l.points,...c.points,...p.points],t.paths=[...l.paths,...c.paths,...o.paths],t.labels=[...l.labels,...c.labels,...p.labels,...o.labels],t.midHipY=a.y;if(t.isAligned&&t.direction==="leftSide")t.leftData={ankleDorsiFlexion:o.leftData,hipFlexion:l.leftData,kneeFlexion:c.leftData,trunkLean:
929p.leftData};else if(t.isAligned&&t.direction==="rightSide")t.rightData={ankleDorsiFlexion:o.rightData,hipFlexion:l.rightData,kneeFlexion:c.rightData,trunkLean:p.rightData};return t}}class oo{runProgram(e){let t=new wi;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.getMiddlePoint(i,s),o=new Oe().runProgram(e),l=new He().runProgram(e),c=new ve().runProgram(e),p=new Ce().runProgram(e),m=new Zi().runProgram(e);if(t.isAligned)t.points=[...o.points,...p.points,...l.points,...c.points],t.paths=[...o.paths,...p.paths,...l.paths,...c.paths],t.labels=[...p.labels,...l.labels,...c.labels,...o.labels],t.midHipY=a.y,t.pelvicDrop=o.leftPelvicDrop?-o.leftPelvicDrop:o.rightPelvicDrop,t.backLateralFlexion=p.leftData?-p.leftData:p.rightData,t.avgShoulderAbduction=this.averageShoulderAbduction(m.leftData,m.rightData),t.leftData={...l.leftData,...c.leftData},t.rightData={...l.rightData,...c.rightData};return t}averageShoulderAbduction(e,t){return e&&t?(e+t)/2:e??t}}class lo{runProgram(e){let t=new _i;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.getMiddlePoint(i,s),o=new jt().runProgram(e),l=new jn().runProgram(e),c=new Ne().runProgram(e),p=new ke().runProgram(e),m=new Ke().runProgram(e);if(t.isAligned)t.points=[...o.points,...l.points,...c.points,...p.points,...m.points],t.paths=[...c.paths,...p.paths,...o.paths,...l.paths],t.labels=[...l.labels,...c.labels,...p.labels,...m.labels,...o.labels],t.midHipY=a.y;if(t.isAligned&&t.direction==="leftSide")t.leftData={ankleDorsiFlexion:o.leftData,hipFlexion:c.leftData,kneeFlexion:p.leftData,shoulderFlexion:l.leftData,trunkLean:m.leftData};else if(t.isAligned&&t.direction==="rightSide")t.rightData={ankleDorsiFlexion:o.rightData,hipFlexion:c.rightData,kneeFlexion:p.rightData,shoulderFlexion:l.rightData,trunkLean:m.rightData};return t}}class uo{runProgram(e){let t=new Ai;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="front";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.getMiddlePoint(i,s),o=this.determineSquatLeg(e),l=new Oe().runProgram(e),c=new He().runProgram(e),p=new ve().runProgram(e),m=new $n().runProgram(e),g=new Ce().runProgram(e);if(t.isAligned){if(t.points=[...l.points,...g.points,...c.points,...p.points],t.paths=[...l.paths,...g.paths,...c.paths,...p.paths],t.labels=[...g.labels,...c.labels,...p.labels,...l.labels],t.midHipY=a.y,t.armsCrossed=(m.leftData??0)>=100&&(m.rightData??0)>=100,t.pelvicDrop=l.leftPelvicDrop?-l.leftPelvicDrop:l.rightPelvicDrop,t.backLateralFlexion=g.leftData?-g.leftData:g.rightData,o==="left")t.leftData={...c.leftData,...p.leftData};else if(o==="right")t.rightData={...c.rightData,...p.rightData}}return t}determineSquatLeg(e){let t=n.getJointPosition(e,"left_heel"),i=n.getJointPosition(e,"right_heel");if(t.y<i.y)return"right";else if(i.y<t.y)return"left";return null}}class co{runProgram(e){let t=new Ci;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.getMiddlePoint(i,s),o=new jt().runProgram(e),l=new Ne().runProgram(e),c=new ke().runProgram(e),p=new Ke().runProgram(e);if(t.isAligned)t.points=[...o.points,...l.points,...c.points,...p.points],t.paths=[...l.paths,...c.paths,...o.paths],t.labels=[...l.labels,...c.labels,...p.labels,...o.labels],t.midHipY=a.y;if(t.isAligned&&t.direction==="leftSide")t.leftData={ankleDorsiFlexion:o.leftData,hipFlexion:l.leftData,kneeFlexion:c.leftData,trunkLean:p.leftData};else if(t.isAligned&&t.direction==="rightSide")t.rightData={ankleDorsiFlexion:o.rightData,hipFlexion:l.rightData,kneeFlexion:c.rightData,trunkLean:p.rightData};return t}}var Hi={};Et(Hi,{CaptureStatus:()=>mo,SitStandStatus:()=>fo,SitToStandController:()=>Pt,programs:()=>fs});var ho=`<div class="bottom-controller-container"> 930 <div class="grow min-w-[1px]"></div> 931 <div id="stsData" class="w-1/3 min-w-[275px] grid grid-cols-6 gap-2 bg-white rounded-md shadow-sm p-3 items-center border-4 border-white"> 932 <h3 class="col-span-6 font-bold text-lg">Results</h3> 933 <div class="col-span-3 text-sm">5 Rep Time</div> 934 <div class="col-span-3 text-sm value elapsedTime">--</div> 935 <div class="col-span-3 text-sm">30 Second Reps</div> 936 <div class="col-span-3 text-sm value reps">--</div> 937 </div> 938 <div class="grow min-w-[1px]"></div> 939</div> 940`;var po=`<div class="top-controller-container"> 941 <div id="stsCaptureContainer" class="capture-bar"> 942 <button id="stsCapture" class="capture-bar-cta bg-green-400 hover:bg-green-500 text-green-900">
943 <span>Start</span> 944 </button> 945 <button id="stsReset" class="hidden capture-bar-cta bg-orange-600 hover:bg-orange-700 text-white"> 946 <span>Reset</span> 947 </button> 948 <button id="stsStop" class="hidden capture-bar-cta bg-red-600 hover:bg-red-700 text-white"> 949 <span>Stop</span> 950 </button> 951 <div class="min-w-6"></div> 952 <div class="flex flex-col"> 953 <span id="stsCaptureTypeHeader" class="text-xs mb-[-4px] pt-1">Capture Type</span> 954 <span id="stsCaptureTypeSubheader" class="font-bold text-lg">5 Repitition</span> 955 </div> 956 <div class="min-w-6"></div> 957 <div class="flex flex-col rounded-xl h-10 w-10 items-center justify-center mb-1"> 958 <span id="activeReps" class="text-lg mb-[-4px]">0</span> 959 <span id="repLabel" class="font-bold text-sm">Reps</span> 960 </div> 961 <div class="min-w-6"></div> 962 <button id="stsCaptureConfig" class="settings-button"> 963 <i class="fas fa-gear text-2xl p-2 text-gray-500"></i> 964 </button> 965 </div> 966</div> 967<div id="stsDismissModal" class="fade-out absolute left-0 top-0 right-0 bottom-0"></div> 968<div id="stsCaptureModal" class="fade-out absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 p-4 transition-opacity duration-500 ease-in-out"> 969 <div class="w-96 bg-gray-100 rounded-xl p-6 shadow-lg"> 970 <h2 class="text-lg font-semibold text-gray-800 mb-4 text-center">Capture Settings</h2> 971 972 <!-- Five-rep Capture --> 973 <div class="flex justify-between items-center mb-4"> 974 <div> 975 <p class="text-sm font-medium text-gray-900">5 Rep Test</p> 976 <p class="text-xs text-gray-600"> 977 See how fast you can stand up and sit back down 5 times. 978 </p> 979 </div> 980 <button class="controller-modal-button active-button" data-capture-method="five-rep"></button> 981 </div> 982 983 <!-- Thirty-second Capture --> 984 <div class="flex justify-between items-center mb-4"> 985 <div> 986 <p class="text-sm font-medium text-gray-900">30 Second Test</p> 987 <p class="text-xs text-gray-600"> 988 See how many times you can stand up and sit back down in 30 seconds. 989 </p> 990 </div> 991 <button class="controller-modal-button select-button" data-capture-method="thirty-second"></button> 992 </div> 993 </div> 994</div>`;var mo;((i)=>{i[i.NOTSTARTED=0]="NOTSTARTED";i[i.ANALYZING=1]="ANALYZING"})(mo||={});var fo;((i)=>{i[i.SITTING=0]="SITTING";i[i.STANDING=1]="STANDING"})(fo||={});class Pt{static STANDING_THRESHOLD_LOW=-10;static STANDING_THRESHOLD_HIGH=30;static FALLBACK_SEATED_THRESHOLD_LOW=60;static FALLBACK_SEATED_THRESHOLD_HIGH=120;static CALIBRATION_WINDOW_MS=500;static MIN_CALIBRATION_SAMPLES=8;static MAX_CALIBRATION_SPREAD=20;static MIN_SEATED_MEDIAN=55;static MAX_SEATED_MEDIAN=140;static ADAPTIVE_SEATED_OFFSET=20;static ADAPTIVE_SEATED_LOW_MIN=60;static ADAPTIVE_SEATED_LOW_MAX=95;vision;timer=null;isPaused=!1;record=new hs;kneeFlexion=null;captureStartedAtMs=null;seatedCalibrationResolved=!1;calibrationKneeSamples=[];seatedThresholdLow=Pt.FALLBACK_SEATED_THRESHOLD_LOW;seatedThresholdHigh=Pt.FALLBACK_SEATED_THRESHOLD_HIGH;repCapturedCuePending=!1;uiState=ft({elapsedTime:0,repCount:0,showingCaptureModal:!1,captureStatus:0,sitStandStatus:0,captureMethod:"five-rep",patientCalibrate:!1,patientStartedSeated:!1,patientSeatedTime:5},()=>{this.updateState()});constructor(e){this.vision=e,e.getRecord((t)=>{this.record=t,this.updateState()})}showControls(e,t){$(e).html(po),$(t).html(ho),k("#stsCapture",()=>{this.startTimer()}),k("#stsStop",()=>{this.stopTimer()}),k("#stsReset",()=>{this.reset()}),k("#stsCaptureConfig",()=>{this.uiState.showingCaptureModal=!0}),k("#stsDismissModal",()=>{this.uiState.showingCaptureModal=!1}),k("#stsCaptureModal .controller-modal-button",(i)=>{this.selectCaptureMethod(i)})}async process(e,t){t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels);let i=this.processDirection(e);if(i===null)return;if(this.uiState.captureStatus===1)await this.processCapture(i)}processDirection(e){if(e.direction==="leftSide"){if(this.isPaused)this.resume();this.kneeFlexion=e.leftData?.kneeFlexion??null}else if(e.direction==="rightSide"){if(this.isPaused)this.resume();this.kneeFlexion=e.rightData?.kneeFlexion??null}else{if(!this.isPaused)this.pause();return null}return this.kneeFlexion}async processCapture(e){if(!this.resolveSeatedCalibration(e))return;let t=!1;switch(this.uiState.sitStandStatus){case 0:if(e>=Pt.STANDING_THRESHOLD_LOW&&e<=Pt.STANDING_THRESHOLD_HIGH)this.uiState.sitStandStatus=1;break;case 1:if(e>=this.seatedThresholdLow&&e<=this.seatedThresholdHigh)this.uiState.sitStandStatus=0,this.uiState.repCount+=1,t=!0;break}if(t&&this.shouldQueueRepCapturedCue())this.repCapturedCuePending=!0;if(this.uiState.captureMethod==="five-rep"&&this.uiState.repCount>
994=5)this.stopTimer(),await this.capture();else if(this.uiState.captureMethod==="thirty-second"&&this.uiState.elapsedTime<=0)this.stopTimer(),await this.capture()}pause(){if(this.isPaused=!0,this.timer)clearInterval(this.timer),this.timer=null}resume(){if(this.timer)return;if(this.isPaused=!1,this.uiState.captureMethod==="five-rep"){let e=this.uiState.elapsedTime*1000,t=Date.now()-e;this.timer=setInterval(()=>{let i=Date.now()-t;this.uiState.elapsedTime=i/1000},50)}else this.timer=setInterval(()=>{if(this.uiState.elapsedTime>0)this.uiState.elapsedTime--},1000)}startTimer(){if(this.stopTimer(),this.initializeSeatedCalibration(),this.uiState.elapsedTime=this.getInitialElapsedTime(this.uiState.captureMethod),this.uiState.repCount=0,this.isPaused=!1,this.repCapturedCuePending=!1,this.uiState.captureMethod==="five-rep"){this.record.fiveRepTime=null;let e=Date.now();this.timer=setInterval(()=>{let t=Date.now()-e;this.uiState.elapsedTime=t/1000},50)}else this.record.thirtySecReps=null,this.timer=setInterval(()=>{if(this.uiState.elapsedTime>0)this.uiState.elapsedTime--},1000);this.uiState.captureStatus=1}async reset(){this.record=new hs,await this.vision.clearRecord(),this.uiState.elapsedTime=this.getInitialElapsedTime(this.uiState.captureMethod),this.uiState.repCount=0,this.uiState.sitStandStatus=0,this.uiState.captureStatus=0,this.repCapturedCuePending=!1,this.clearSeatedCalibration()}stopTimer(){if(this.timer)clearInterval(this.timer),this.timer=null;this.uiState.captureStatus=0,this.repCapturedCuePending=!1,this.clearSeatedCalibration()}shouldQueueRepCapturedCue(){if(this.uiState.captureMethod==="five-rep")return this.uiState.repCount<5;return this.uiState.elapsedTime>0}initializeSeatedCalibration(){this.seatedCalibrationResolved=!1,this.calibrationKneeSamples=[],this.captureStartedAtMs=Date.now(),this.seatedThresholdLow=Pt.FALLBACK_SEATED_THRESHOLD_LOW,this.seatedThresholdHigh=Pt.FALLBACK_SEATED_THRESHOLD_HIGH}clearSeatedCalibration(){this.seatedCalibrationResolved=!1,this.calibrationKneeSamples=[],this.captureStartedAtMs=null,this.seatedThresholdLow=Pt.FALLBACK_SEATED_THRESHOLD_LOW,this.seatedThresholdHigh=Pt.FALLBACK_SEATED_THRESHOLD_HIGH}resolveSeatedCalibration(e){if(this.seatedCalibrationResolved)return!0;if(this.captureStartedAtMs??=Date.now(),this.isValidCalibrationSample(e))this.calibrationKneeSamples.push(e);if(Date.now()-this.captureStartedAtMs<Pt.CALIBRATION_WINDOW_MS)return!1;return this.finalizeSeatedCalibration(),!0}isValidCalibrationSample(e){return Number.isFinite(e)&&e>0&&e<=180}finalizeSeatedCalibration(){if(this.seatedCalibrationResolved)return;let e=[...this.calibrationKneeSamples].sort((m,g)=>m-g),t=e.length,i=t>0?this.percentile(e,0.5):null,s=t>0?this.percentile(e,0.1):null,a=t>0?this.percentile(e,0.9):null,o=s!==null&&a!==null?a-s:null,l=t>=Pt.MIN_CALIBRATION_SAMPLES,c=o!==null&&o<=Pt.MAX_CALIBRATION_SPREAD,p=i!==null&&i>=Pt.MIN_SEATED_MEDIAN&&i<=Pt.MAX_SEATED_MEDIAN;if(l&&c&&p){this.seatedThresholdLow=this.clamp(i-Pt.ADAPTIVE_SEATED_OFFSET,Pt.ADAPTIVE_SEATED_LOW_MIN,Pt.ADAPTIVE_SEATED_LOW_MAX),this.seatedThresholdHigh=Pt.FALLBACK_SEATED_THRESHOLD_HIGH,this.seatedCalibrationResolved=!0;return}this.seatedThresholdLow=Pt.FALLBACK_SEATED_THRESHOLD_LOW,this.seatedThresholdHigh=Pt.FALLBACK_SEATED_THRESHOLD_HIGH,this.seatedCalibrationResolved=!0}percentile(e,t){if(e.length===0)return 0;let i=(e.length-1)*t,s=Math.floor(i),a=Math.ceil(i);if(s===a)return e[s];let o=i-s;return e[s]*(1-o)+e[a]*o}clamp(e,t,i){return Math.min(i,Math.max(t,e))}async capture(){if(this.uiState.captureMethod==="five-rep")this.record.fiveRepTime=this.uiState.elapsedTime;else this.record.thirtySecReps=this.uiState.repCount;this.uiState.captureStatus=0,await this.vision.setRecord(this.record)}updateState(){U("#stsCapture",this.uiState.captureStatus!==0),U("#stsStop",this.uiState.captureStatus!==1),vt("#stsData","border-blue-500","border-white",this.uiState.captureStatus===1),Rt("#stsCaptureContainer","partial-fade",this.uiState.showingCaptureModal),Rt("#stsCaptureModal","fade-out",!this.uiState.showingCaptureModal),Rt("#stsDismissModal","fade-out",!this.uiState.showingCaptureMod
994al),this.vision.toggleBlur(this.uiState.showingCaptureModal);let e=$(`#stsCaptureModal .controller-modal-button[data-capture-method='${this.uiState.captureMethod}']`),t=$(`#stsCaptureModal .controller-modal-button:not([data-capture-method='${this.uiState.captureMethod}'])`);switch(e.addClass("active-button").removeClass("select-button"),t.addClass("select-button").removeClass("active-button"),this.uiState.captureStatus){case 0:if($("#stsCaptureTypeHeader").text("Capture Type"),$("#stsCaptureTypeSubheader").text(this.captureMethodName()),$("#activeReps").text(this.uiState.repCount),$("#repLabel").text(this.uiState.repCount===1?"Rep":"Reps"),this.uiState.captureMethod==="five-rep"&&this.record.fiveRepTime||this.uiState.captureMethod==="thirty-second"&&this.record.thirtySecReps)$("#stsCapture").text("Restart");else $("#stsCapture").text("Start");break;case 1:$("#stsCaptureTypeHeader").text("Analyzing..."),$("#activeReps").text(this.uiState.repCount),$("#repLabel").text(this.uiState.repCount===1?"Rep":"Reps"),$("#stsCaptureTypeSubheader").text(this.uiState.elapsedTime.toFixed(this.uiState.captureMethod==="five-rep"?2:0));break}let i=(s,a,o,l)=>{$(s).text(a?`${a.toFixed(l?2:0)} ${o?"sec.":""}`:"Not captured")};i(".elapsedTime",this.record.fiveRepTime,!0,!0),i(".reps",this.record.thirtySecReps,!1,!1)}selectCaptureMethod(e){let t=$(e.target);this.uiState.captureMethod=t.data("capture-method"),this.uiState.elapsedTime=this.getInitialElapsedTime(this.uiState.captureMethod),this.uiState.repCount=0,this.uiState.showingCaptureModal=!1,this.stopTimer()}captureMethodName(){switch(this.uiState.captureMethod){case"five-rep":return"5 Rep Test";case"thirty-second":return"30s Test"}}getInitialElapsedTime(e){return e==="five-rep"?0:30}patientSetup(e,t){this.uiState.captureMethod=t==="5 rep"?"five-rep":"thirty-second",this.repCapturedCuePending=!1}async patientProcess(e,t){t.drawPaths(e.paths),t.drawPoints(e.points),t.drawLabels(e.labels);let i=this.processDirection(e);if(i===null)return;if(!this.uiState.patientCalibrate)this.uiState.patientCalibrate=!0,this.startTimer();if(this.uiState.captureStatus===1)await this.processCapture(i)}patientPause(){if(this.isPaused=!0,this.timer)clearInterval(this.timer),this.timer=null}patientData(e){if(e==="step")return 0;else if(e==="countdown")return this.uiState.patientSeatedTime;else if(e==="timer")return this.uiState.elapsedTime.toFixed(1);else if(e==="reps")return this.uiState.repCount;else return 0}consumeRepCapturedCue(){let e=this.repCapturedCuePending;return this.repCapturedCuePending=!1,e}}var fs={};Et(fs,{SitToStand:()=>So});class ps{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_shoulder"),s=n.getJointPosition(e,"left_hip"),a=n.getJointPosition(e,"left_knee"),o=n.getJointPosition(e,"right_shoulder"),l=n.getJointPosition(e,"right_hip"),c=n.getJointPosition(e,"right_knee"),p=n.getMiddlePoint(i,s),m=n.getMiddlePoint(o,l),g=n.pointDistance(s,p),d=n.calculateSlope(p,s),S=n.calculateSlope(a,s),v=n.calculateAngle(s,a,p,!1)-180,P=n.pointDistance(l,m),b=n.calculateSlope(m,l),D=n.calculateSlope(c,l),A=n.calculateAngle(l,m,c,!1)-180;if(t.isAligned&&t.direction==="leftSide"){if(v>0)t.leftData=v,t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:100,y:0}});t.points.push({...s,side:"left"}),t.points.push({...p,side:"left"}),t.paths.push(n.makeArcPath(s,a,p,g*0.5,d,S,!0,"left"))}else if(t.isAligned&&t.direction==="rightSide"){if(A>0)t.rightData=A,t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:-100,y:0}});t.points.push({...l,side:"right"}),t.points.push({...m,side:"right"}),t.paths.push(n.makeArcPath(l,c,m,P*0.5,b,D,!1,"right"))}return t}}class ds{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_knee"),a=n.getJointPosition(e,"left_ankle"),o=n.getJointPosition(e,"right_hip"),l=n.getJointPosition(e,"right_knee"),c=n.getJointPosition(e,"right_ankle"),p=Math.min(n.pointDistance(i,s),n.pointDistance(s,a)),m={x:s.x,y:s.y+p},g=n.calculateSlope(i,s),d=n.calculateSlope(m,s),S=n.endPointForSlopeAndDist(s,p,g),v=180-n.calculateAngle(s,m,i,!1),P=Math.min(n.pointDistance(o,l),n.pointDistance(l,c)),b={x:l.x,y:l.y+P},D=n.calculateSlope(o,l),A=n.calculateSlope(b,l),I=n.endPointForSlopeAndDist(l,P,D),F=180-n.calculateAngle(l,b,o,!0);if(t.isAligned&&t.direction==="leftSide"){if(v>=-8&&v<=200){if(v>0)t.leftData=v,t.labels.push({position:s,value:t.leftData,side:"left",offset:{x:-100,y:0}});t.points.push({...s,side:"left"}),t.points.push({...m,side:"left"}),t.paths.push(n.makeArcPath(s,m,S,p*0.4,g,d,!1,"left"))}}else if(t.isAligned&&t.direction==="rightSide"){if(F>
994=-8&&F<=200){if(F>0)t.rightData=F,t.labels.push({position:l,value:t.rightData,side:"right",offset:{x:100,y:0}});t.points.push({...l,side:"right"}),t.points.push({...b,side:"right"}),t.paths.push(n.makeArcPath(l,b,I,P*0.4,D,A,!0,"right"))}}return t}}class ms{runProgram(e){let t=new H;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"left_shoulder"),a=n.getMiddlePoint(s,i),o=n.getJointPosition(e,"right_hip"),l=n.getJointPosition(e,"right_shoulder"),c=n.getMiddlePoint(l,o),p=n.pointDistance(i,s),m={x:i.x,y:i.y-p},g=n.calculateAngle(i,s,m,!0),d=n.pointDistance(o,l),S={x:o.x,y:o.y-d},v=n.calculateAngle(o,S,l,!0);if(t.isAligned&&t.direction==="leftSide"){if(g>=0&&g<=200)t.leftData=g,t.labels.push({position:a,value:t.leftData,side:"left",offset:{x:100,y:0}})}else if(t.isAligned&&t.direction==="rightSide"){if(v>=0&&v<=200)t.rightData=v,t.labels.push({position:c,value:t.rightData,side:"right",offset:{x:-100,y:0}})}return t}}class So{runProgram(e){let t=new go;t.direction=n.determinePoseDirection(e),t.isAligned=t.direction==="leftSide"||t.direction==="rightSide";let i=n.getJointPosition(e,"left_hip"),s=n.getJointPosition(e,"right_hip"),a=n.getMiddlePoint(i,s),o=new jt().runProgram(e),l=new ps().runProgram(e),c=new ms().runProgram(e),p=new ds().runProgram(e);if(t.isAligned)t.points=[...l.points,...c.points,...p.points],t.paths=[...l.paths,...p.paths],t.labels=[...l.labels,...c.labels,...p.labels],t.midHipY=a.y;if(t.isAligned&&t.direction==="leftSide")t.leftData={ankleDorsiFlexion:o.leftData,hipFlexion:l.leftData,kneeFlexion:p.leftData,trunkLean:c.leftData};else if(t.isAligned&&t.direction==="rightSide")t.rightData={ankleDorsiFlexion:o.rightData,hipFlexion:l.rightData,kneeFlexion:p.rightData,trunkLean:c.rightData};return t}}function et(e,t,i){let s=gs.findAssessment(e);if(!s)throw Error(`Assessment definition not found for id: ${e}`);return{...s,program:t,controller:i}}var Kc=[et("shoulderAbduction",()=>new X.programs.ShoulderAbduction,(e)=>new X.ROMController(e)),et("shoulderAdduction",()=>new X.programs.ShoulderAdduction,(e)=>new X.ROMController(e)),et("shoulderFlexion",()=>new X.programs.ShoulderFlexion,(e)=>new X.ROMController(e)),et("shoulderExtension",()=>new X.programs.ShoulderExtension,(e)=>new X.ROMController(e)),et("shoulderExternalRotation",()=>new X.programs.ShoulderExternalRotation,(e)=>new X.ROMController(e)),et("shoulderInternalRotation",()=>new X.programs.ShoulderInternalRotation,(e)=>new X.ROMController(e)),et("backFlexion",()=>new X.programs.BackFlexion,(e)=>new X.ROMController(e)),et("backExtension",()=>new X.programs.BackExtension,(e)=>new X.ROMController(e)),et("backLateralFlexion",()=>new X.programs.BackLateralFlexion,(e)=>new X.ROMController(e)),et("kneeFlexion",()=>new X.programs.KneeFlexion,(e)=>new X.ROMController(e)),et("kneeExtension",()=>new X.programs.KneeExtension,(e)=>new X.ROMController(e)),et("hipFlexion",()=>new X.programs.HipFlexion,(e)=>new X.ROMController(e)),et("hipExtension",()=>new X.programs.HipExtension,(e)=>new X.ROMController(e)),et("hipAbduction",()=>new X.programs.HipAbduction,(e)=>new X.ROMController(e)),et("hipAdduction",()=>new X.programs.HipAdduction,(e)=>new X.ROMController(e)),et("hipExternalRotation",()=>new X.programs.HipExternalRotation,(e)=>new X.ROMController(e)),et("hipInternalRotation",()=>new X.programs.HipInternalRotation,(e)=>new X.ROMController(e)),et("ankleDorsiFlexion",()=>new X.programs.AnkleDorsiFlexion,(e)=>new X.ROMController(e)),et("anklePlantarFlexion",()=>new X.programs.AnklePlantarFlexion,(e)=>new X.ROMController(e)),et("neckFlexion",()=>new X.programs.NeckFlexion,(e)=>new X.ROMController(e)),et("neckExtension",()=>new X.programs.NeckExtension,(e)=>new X.ROMController(e)),et("neckLateralFlexion",()=>new X.programs.NeckLateralFlexion,(e)=>new X.ROMController(e)),et("elbowFlexion",()=>new X.programs.ElbowFlexion,(e)=>new X.ROMController(e)),et("elbowExtension",()=>new X.programs.ElbowExtension,(e)=>new X.ROMController(e)),et("straightLegRaise",()=>new X.programs.StraightLegRaise,(e)=>new X.ROMController(e)),et("thoracicRotation",()=>new X.programs.ThoracicRotation,(e)=>new X.ROMController(e)),et("anteriorSquat",()=>new Ot.programs.AnteriorSquat,(e)=>new Ot.AnteriorSquatController(e,"regular")),et("sagittalSquat",()=>new Ot.programs.SagittalSquat,(e)=>
994new Ot.SagittalSquatController(e,"regular")),et("overheadSagittalSquat",()=>new Ot.programs.OverheadSagittalSquat,(e)=>new Ot.SagittalSquatController(e,"overhead")),et("overheadAnteriorSquat",()=>new Ot.programs.OverheadAnteriorSquat,(e)=>new Ot.AnteriorSquatController(e,"overhead")),et("singleLegSagittalSquat",()=>new Ot.programs.SingleLegSagittalSquat,(e)=>new Ot.SagittalSquatController(e,"singleleg")),et("singleLegAnteriorSquat",()=>new Ot.programs.SingleLegAnteriorSquat,(e)=>new Ot.AnteriorSquatController(e,"singleleg")),et("anteriorForwardLunge",()=>new ie.programs.AnteriorLunge,(e)=>new ie.AnteriorLungeController(e)),et("sagittalForwardLunge",()=>new ie.programs.SagittalLunge,(e)=>new ie.SagittalLungeController(e)),et("anteriorReverseLunge",()=>new ie.programs.AnteriorLunge,(e)=>new ie.AnteriorLungeController(e)),et("sagittalReverseLunge",()=>new ie.programs.SagittalLunge,(e)=>new ie.SagittalLungeController(e)),et("anteriorPosture",()=>new Ue.programs.AnteriorPosture,(e)=>new Ue.PostureAnteriorController(e)),et("sagittalPosture",()=>new Ue.programs.SagittalPosture,(e)=>new Ue.PostureSagittalController(e)),et("singleLegBalance",()=>new xi.programs.SingleLegBalance,(e)=>new xi.BalanceController(e)),et("verticalJump",()=>new _e.programs.VerticalJump,(e)=>new _e.JumpController(e,"doubleleg")),et("singleLegVerticalJump",()=>new _e.programs.VerticalJump,(e)=>new _e.JumpController(e,"singleleg")),et("sitToStand",()=>new Hi.programs.SitToStand,(e)=>new Hi.SitToStandController(e)),et("pushUpTimed",()=>new Be.programs.PushUp,(e)=>
994new Be.PushUpController(e,"timed")),et("pushUpReps",()=>new Be.programs.PushUp,(e)=>new Be.PushUpController(e,"reps"))],Ss=Kc;function Jc(e){return Ss.filter((t)=>t.category===e)}function Gc(e){let t=Ss.filter((i)=>i.id===e);if(t.length>0)return t[0];else return null}var vs={list:Ss,assessmentsForCategory:Jc,findAssessment:Gc};var y=V,xs=(e)=>Array.from(new Set(e)),Yt=(e,t)=>({sourceKeypoints:xs(e),...t?{sourceKeypointsBySide:{left:t.left?xs(t.left):void 0,right:t.right?xs(t.right):void 0}}:{}}),wt=(e,t)=>Yt([...e,...t],{left:e,right:t}),nn=wt([y.LEFT_SHOULDER,y.LEFT_ELBOW,y.LEFT_HIP,y.RIGHT_SHOULDER,y.RIGHT_HIP],[y.RIGHT_SHOULDER,y.RIGHT_ELBOW,y.RIGHT_HIP,y.LEFT_SHOULDER,y.LEFT_HIP]),To=wt([y.LEFT_SHOULDER,y.LEFT_WRIST,y.LEFT_HIP,y.RIGHT_SHOULDER,y.RIGHT_HIP],[y.RIGHT_SHOULDER,y.RIGHT_WRIST,y.RIGHT_HIP,y.LEFT_SHOULDER,y.LEFT_HIP]),Po=wt([y.LEFT_SHOULDER,y.LEFT_ELBOW,y.LEFT_WRIST],[y.RIGHT_SHOULDER,y.RIGHT_ELBOW,y.RIGHT_WRIST]),Ro=wt([y.LEFT_HIP,y.LEFT_KNEE,y.LEFT_ANKLE],[y.RIGHT_HIP,y.RIGHT_KNEE,y.RIGHT_ANKLE]),bo=wt([y.LEFT_KNEE,y.LEFT_HEEL,y.LEFT_FOOT_INDEX],[y.RIGHT_KNEE,y.RIGHT_HEEL,y.RIGHT_FOOT_INDEX]),sn=wt([y.LEFT_KNEE,y.LEFT_SHOULDER,y.LEFT_HIP,y.RIGHT_SHOULDER,y.RIGHT_HIP],[y.RIGHT_KNEE,y.RIGHT_SHOULDER,y.RIGHT_HIP,y.LEFT_SHOULDER,y.LEFT_HIP]),yo=wt([y.LEFT_SHOULDER,y.LEFT_HIP,y.LEFT_KNEE,y.RIGHT_HIP,y.RIGHT_KNEE],[y.RIGHT_SHOULDER,y.RIGHT_HIP,y.RIGHT_KNEE,y.LEFT_HIP,y.LEFT_KNEE]),Bc=Yt([y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP,y.LEFT_KNEE,y.RIGHT_KNEE]),Do=[y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP,y.LEFT_KNEE,y.RIGHT_KNEE,y.LEFT_ANKLE,y.RIGHT_ANKLE,y.LEFT_FOOT_INDEX,y.RIGHT_FOOT_INDEX],Vc=wt([y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP,y.LEFT_KNEE,y.LEFT_ANKLE,y.LEFT_FOOT_INDEX],[y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP,y.RIGHT_KNEE,y.RIGHT_ANKLE,y.RIGHT_FOOT_INDEX]),Eo=wt([y.LEFT_SHOULDER,y.LEFT_HIP,y.LEFT_KNEE,y.LEFT_ANKLE,y.LEFT_HEEL,y.LEFT_FOOT_INDEX],[y.RIGHT_SHOULDER,y.RIGHT_HIP,y.RIGHT_KNEE,y.RIGHT_ANKLE,y.RIGHT_HEEL,y.RIGHT_FOOT_INDEX]),Wc=wt([y.LEFT_SHOULDER,y.LEFT_ELBOW,y.LEFT_HIP,y.LEFT_KNEE,y.LEFT_ANKLE,y.LEFT_HEEL,y.LEFT_FOOT_INDEX,y.RIGHT_SHOULDER,y.RIGHT_HIP],[y.RIGHT_SHOULDER,y.RIGHT_ELBOW,y.RIGHT_HIP,y.RIGHT_KNEE,y.RIGHT_ANKLE,y.RIGHT_HEEL,y.RIGHT_FOOT_INDEX,y.LEFT_SHOULDER,y.LEFT_HIP]),wo=wt([y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP,y.LEFT_KNEE,y.LEFT_ANKLE,y.LEFT_FOOT_INDEX],[y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP,y.RIGHT_KNEE,y.RIGHT_ANKLE,y.RIGHT_FOOT_INDEX]),Ao=[y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP,y.LEFT_KNEE,y.RIGHT_KNEE,y.LEFT_ANKLE,y.RIGHT_ANKLE,y.LEFT_HEEL,y.RIGHT_HEEL,y.LEFT_FOOT_INDEX,y.RIGHT_FOOT_INDEX],$c=[y.LEFT_EYE,y.RIGHT_EYE,y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP,y.LEFT_KNEE,y.RIGHT_KNEE,y.LEFT_ANKLE,y.RIGHT_ANKLE],jc=wt([y.LEFT_EAR,y.LEFT_SHOULDER,y.LEFT_HIP,y.LEFT_KNEE,y.LEFT_ANKLE],[y.RIGHT_EAR,y.RIGHT_SHOULDER,y.RIGHT_HIP,y.RIGHT_KNEE,y.RIGHT_ANKLE]),Lo=[y.LEFT_EYE_INNER,y.RIGHT_EYE_INNER,y.LEFT_EYE_OUTER,y.RIGHT_EYE_OUTER,y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP,y.LEFT_KNEE,y.RIGHT_KNEE,y.LEFT_ANKLE,y.RIGHT_ANKLE,y.LEFT_FOOT_INDEX,y.RIGHT_FOOT_INDEX],Yc=[y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP,y.LEFT_KNEE,y.RIGHT_KNEE,y.LEFT_ANKLE,y.RIGHT_ANKLE,y.LEFT_FOOT_INDEX,y.RIGHT_FOOT_INDEX],zc=wt([y.LEFT_SHOULDER,y.LEFT_HIP,y.LEFT_KNEE,y.LEFT_ANKLE,y.LEFT_HEEL,y.LEFT_FOOT_INDEX],[y.RIGHT_SHOULDER,y.RIGHT_HIP,y.RIGHT_KNEE,y.RIGHT_ANKLE,y.RIGHT_HEEL,y.RIGHT_FOOT_INDEX]),qc={shoulderAbduction:nn,shoulderAdduction:nn,shoulderFlexion:nn,shoulderExtension:nn,shoulderExternalRotation:To,shoulderInternalRotation:To,backFlexion:yo,backExtension:yo,backLateralFlexion:Bc,kneeFlexion:Ro,kneeExtension:Ro,hipFlexion:sn,hipExtension:sn,hipAbduction:sn,hipAdduction:sn,hipExternalRotation:wt([y.LEFT_KNEE,y.LEFT_ANKLE],[y.RIGHT_KNEE,y.RIGHT_ANKLE]),hipInternalRotation:wt([y.LEFT_KNEE,y.LEFT_ANKLE],[y.RIGHT_KNEE,y.RIGHT_ANKLE]),ankleDorsiFlexion:bo,anklePlantarFlexion:bo,neckFlexion:wt([y.NOSE,y.LEFT_EAR],[y.NOSE,y.RIGHT_EAR]),neckExtension:wt([y.NOSE,y.LEFT_EYE_OUTER,y.LEFT_EAR],[y.NOSE,y.RIGHT_EYE_OUTER,y.RIGHT_EAR]),neckLateralFlexion:Yt([y.NOSE,y.LEFT_SHOULDER,y.RIGHT_SHOULDER,y.LEFT_HIP,y.RIGHT_HIP]),elbowFlexion:Po,elbowExtension:Po,straightLegRaise:wt([y.LEFT_HIP,y.LEFT_ANKLE],[y.RIGHT_HIP,y.RIGHT_ANKLE]),thoracicRotation:Yt([y.LEFT_SHOULDER,y.RIGHT_SHOULDER]),anteriorSquat:Yt(Do),overheadAnteriorSquat:Yt(Do),singleLegAnteriorSquat:Vc,sagittalSquat:Eo,overheadSagittalSquat:Wc,singleLegSagittalSquat:Eo,anteriorForwardLunge:wo,anteriorRever
994seLunge:wo,sagittalForwardLunge:Yt(Ao),sagittalReverseLunge:Yt(Ao),anteriorPosture:Yt($c),sagittalPosture:jc,singleLegBalance:Yt(Yc),verticalJump:Yt(Lo),singleLegVerticalJump:Yt(Lo),sitToStand:zc},Xc=(e,t,i)=>{let s=qc[t.assessmentId];if(!s)return;e.sourceKeypoints=s.sourceKeypoints,e.sourceKeypointsBySide=s.sourceKeypointsBySide,th(e,t,i,s)},Zc=(e,t)=>{if(e.side&&t.sourceKeypointsBySide?.[e.side])return t.sourceKeypointsBySide[e.side]??t.sourceKeypoints;return t.sourceKeypoints},Qc=(e,t)=>Math.abs(e.x-t.x)<=0.001&&Math.abs(e.y-t.y)<=0.001,th=(e,t,i,s)=>{let a=new Set(Zc(t,s)),o=i.filter((l)=>typeof l.name==="string"&&a.has(l.name));if(o.length===0)return;e.points=e.points.map((l)=>{if(l.role||o.some((c)=>Qc(l,c)))return l;return{...l,role:"reference"}})};function eh(e,t){let i=vs.findAssessment(e.assessmentId);if(!i)return null;let s=i.program(),a=t?Fo(e.keypoints,t.keypoints):e.keypoints;if(s.replayCapture)return Io(s.replayCapture({poseFrame:e,poseFrameEdit:t}),e,a);let o=Cn(e.direction,()=>s.runProgram(a,{directionOverride:e.direction}));return Io({results:o,recordPatch:{}},e,a)}var Io=(e,t,i)=>(Xc(e.results,t,i),e);var rl=nh(_o(),1);var al=function(e,t){return(al=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,s){i.__proto__=s}||function(i,s){for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(i[a]=s[a])})(e,t)};function ol(e,t){if(typeof t!="function"&&t!==null)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}al(e,t),e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}var gt=function(){return(gt=Object.assign||function(e){for(var t,i=1,s=arguments.length;i<s;i++)for(var a in t=arguments[i])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function ot(e,t,i,s){return new(i||(i=Promise))(function(a,o){function l(m){try{p(s.next(m))}catch(g){o(g)}}function c(m){try{p(s.throw(m))}catch(g){o(g)}}function p(m){var g;m.done?a(m.value):(g=m.value,g instanceof i?g:new i(function(d){d(g)})).then(l,c)}p((s=s.apply(e,t||[])).next())})}function lt(e,t){var i,s,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(p){return function(m){return function(g){if(i)throw TypeError("Generator is already executing.");for(;l;)try{if(i=1,s&&(a=2&g[0]?s.return:g[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,g[1])).done)return a;switch(s=0,a&&(g=[2&g[0],a.value]),g[0]){case 0:case 1:a=g;break;case 4:return l.label++,{value:g[1],done:!1};case 5:l.label++,s=g[1],g=[0];continue;case 7:g=l.ops.pop(),l.trys.pop();continue;default:if(a=l.trys,!((a=a.length>0&&a[a.length-1])||g[0]!==6&&g[0]!==2)){l=0;continue}if(g[0]===3&&(!a||g[1]>a[0]&&g[1]<a[3])){l.label=g[1];break}if(g[0]===6&&l.label<a[1]){l.label=a[1],a=g;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(g);break}a[2]&&l.ops.pop(),l.trys.pop();continue}g=t.call(e,l)}catch(d){g=[6,d],s=0}finally{i=a=0}if(5&g[0])throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}([p,m])}}}function $e(e,t,i){if(i||arguments.length===2)for(var s,a=0,o=t.length;a<o;a++)!s&&a in t||(s||(s=Array.prototype.slice.call(t,0,a)),s[a]=t[a]);return e.concat(s||Array.prototype.slice.call(t))}var pe=["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"],Ni=["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"],sh={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]},rh={left:[1,3,5,7,9,11,13,15],right:[2,4,6,8,10,12,14,16],middle:[0]},ah=[[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]],oh=[[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
994],[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 ln(e){return e instanceof SVGAnimatedLength?e.baseVal.value:e}function ll(e){return ot(this,void 0,void 0,function(){var t,i;return lt(this,function(s){switch(s.label){case 0:return t=document.createElement("canvas"),e instanceof ze?[4,li.toPixels(e,t)]:[3,2];case 1:return s.sent(),[3,3];case 2:t.width=ln(e.width),t.height=ln(e.height),i=t.getContext("2d"),e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0),s.label=3;case 3:return[2,t]}})})}function ul(e){return ot(this,void 0,void 0,function(){var t,i,s,a,o,l;return lt(this,function(c){switch(c.label){case 0:return e instanceof ze?(t=e.shape.slice(0,2),i=t[0],s=t[1],a=ImageData.bind,[4,li.toPixels(e)]):[3,2];case 1:return[2,new(a.apply(ImageData,[void 0,c.sent(),s,i]))];case 2:return o=document.createElement("canvas"),l=o.getContext("2d"),o.width=ln(e.width),o.height=ln(e.height),l.drawImage(e,0,0),[2,l.getImageData(0,0,o.width,o.height)]}})})}function lh(e){return ot(this,void 0,void 0,function(){var t,i;return lt(this,function(s){switch(s.label){case 0:return e instanceof SVGImageElement||e instanceof OffscreenCanvas?[4,ll(e)]:[3,2];case 1:return i=s.sent(),[3,3];case 2:i=e,s.label=3;case 3:return t=i,[2,li.fromPixels(t,4)]}})})}function cl(e){if(e<0||e>=256)throw Error("Mask value must be in range [0, 255] but got ".concat(e));if(!Number.isInteger(e))throw Error("Mask value must be an integer but got ".concat(e))}var uh=function(){function e(t){this.mask=t}return e.prototype.toCanvasImageSource=function(){return ot(this,void 0,void 0,function(){return lt(this,function(t){return[2,this.mask]})})},e.prototype.toImageData=function(){return ot(this,void 0,void 0,function(){return lt(this,function(t){return[2,ul(this.mask)]})})},e.prototype.toTensor=function(){return ot(this,void 0,void 0,function(){return lt(this,function(t){return[2,lh(this.mask)]})})},e.prototype.getUnderlyingType=function(){return"canvasimagesource"},e}();function ch(e){return cl(e),"person"}var av=function(){function e(t){var i,s=this;switch(this.width=0,this.height=0,this.selfieMode=!1,this.poseSolution=new rl.Pose({locateFile:function(a,o){if(t.solutionPath){var l=t.solutionPath.replace(/\/+$/,"");return"".concat(l,"/").concat(a)}return"".concat(o,"/").concat(a)}}),t.modelType){case"lite":i=0;break;case"heavy":i=2;break;case"full":default:i=1}this.poseSolution.setOptions({modelComplexity:i,smoothLandmarks:t.enableSmoothing,enableSegmentation:t.enableSegmentation,smoothSegmentation:t.smoothSegmentation,selfieMode:this.selfieMode}),this.poseSolution.onResults(function(a){if(s.height=a.image.height,s.width=a.image.width,a.poseLandmarks==null)s.poses=[];else{var o=s.translateOutput(a.poseLandmarks,a.poseWorldLandmarks);a.segmentationMask&&(o.segmentation={maskValueToLabel:ch,mask:new uh(a.segmentationMask)}),s.poses=[o]}})}return e.prototype.translateOutput=function(t,i){var s=this,a={keypoints:t.map(function(o,l){return{x:o.x*s.width,y:o.y*s.height,z:o.z,score:o.visibility,name:Ni[l]}})};return i!=null&&(a.keypoints3D=i.map(function(o,l){return{x:o.x,y:o.y,z:o.z,score:o.visibility,name:Ni[l]}})),a},e.prototype.estimatePoses=function(t,i,s){return ot(this,void 0,void 0,function(){var a,o;return lt(this,function(l){switch(l.label){case 0:return i&&i.flipHorizontal&&i.flipHorizontal!==this.selfieMode&&(this.selfieMode=i.flipHorizontal,this.poseSolution.setOptions({selfieMode:this.selfieMode})),t instanceof ze?(o=ImageData.bind,[4,li.toPixels(t)]):[3,2];case 1:return a=new(o.apply(ImageData,[void 0,l.sent(),t.shape[1],t.shape[0]])),[3,3];case 2:a=t,l.label=3;case 3:return t=a,[4,this.poseSolution.send({image:t},s)];case 4:return l.sent(),[2,this.poses]}})})},e.prototype.dispose=function(){this.poseSolution.close()},e.prototype.reset=function(){this.poseSolution.reset()},e.prototype.initialize=function(){return this.poseSolution.initialize()},e}();function oi(e){return e instanceof ze?{height:e.shape[0],width:e.shape[1]}:{height:e.height,width:e.width}}function hl(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function Cs(e){return e instanceof ze?e:li.fromPixels(e)}function pl(e,t,i){return Ls(i,"inputResolution"),[1/i.width*e[0][0]*t.width,1/i.height*e[0][1]*t.width,e[0][3]*t.width,1/i.width*e[1][0]*t.height,1/i.height*e[1][1]*t.height,e[1][3]*t.height,0,0]}function Ls(e,t){We.assert(e.width!==0,function(){return"".concat(t," width cannot be 0.")}),We.assert(e.height!==0,function(){return"".concat(t," height cannot be 0.")})}function Ts(e,t,i){var{rotationVectorStartKeypointIndex:s,rotationVectorEndKeypointIndex:a}=i,o=e.locationData,l=o.relativeKeypoints[s].x*t.width,c=o.relativeKeypoints[s].y*t.height,p=o.relativeKeypoints[a].x*t.width,m=o.relativeKeypoints[a].y*t.height,g=2*Math.sqrt((p-l)*(p-l)+(m-c)*(m-c)),d=function(S,v,P){var b,D=S.locationData,A=P.rotationVectorStartKeypointIndex,I=P.rotationVectorEndKeypointIndex;b=P.rotationVectorTargetAngle?P.rotationVectorTargetAngle:Math.PI*P.rotationVectorTargetAngleDegree/180;var F=D.relativeKeypoints[A].x*v.width,M=D.relativeKeypoints[A].y*v.height,z=D.relativeKeypoints[I].x*v.width,J=D.relativeKeypoints[I].y*v.height;return hl(b-Math.atan2(-(J-M),z-F))}(e,t,i);return{xCenter:l/t.width,yCenter:c/t.height,width:g/t.width,height:g/t.height,rotation:d}}function dl(e){if(e.length!==16)throw Error("Array length must be 16 but got ".concat(e.length));return[[e[0],e[1],e[2],e[3]],[e[4],e[5],e[6],e[7]],[e[8],e[9],e[10],e[11]],[e[12],e[13],e[14],e[15]]]}function Ps(e,t,i,s,a,o,l){return e[t][a]*(e[i][o]*e[s][l]-e[i][l]*e[s][o])}function _t(e,t,i){var s=(t+1)%4,a=(t+2)%4,o=(t+3)%4,l=(i+1)%4,c=(i+2)%4,p=(i+3)%4;return Ps(e,s,a,o,l,c,p)+Ps(e,a,o,s,l,c,p)+Ps(e,o,s,a,l,c,p)}function Co(e,t,i){i===void 0&&(i={ignoreRotation:!1});for(var s=[],a=0,o=e;a<o.length;a++){var l=o[a],c=l.x-0.5,p=l.y-0.5,m=i.ignoreRotation?0:t.rotation,g=Math.cos(m)*c-Math.sin(m)*p,d=Math.sin(m)*c+Math.cos(m)*p;
994g=g*t.width+t.xCenter,d=d*t.height+t.yCenter;var S=l.z*t.width,v=gt({},l);v.x=g,v.y=d,v.z=S,s.push(v)}return s}function ml(e,t){var i=function(s,a,o,l){var c=a-s,p=l-o;if(c===0)throw Error("Original min and max are both ".concat(s,", range cannot be 0."));var m=p/c;return{scale:m,offset:o-s*m}}(0,255,t[0],t[1]);return At(function(){return Ht(bt(e,i.scale),i.offset)})}function Is(e,t,i){var s,a,o,l,c,p,m,g,d,S,v,P,b,D,A=t.outputTensorSize,I=t.keepAspectRatio,F=t.borderMode,M=t.outputTensorFloatRange,z=oi(e),J=function(K,j){return j?{xCenter:j.xCenter*K.width,yCenter:j.yCenter*K.height,width:j.width*K.width,height:j.height*K.height,rotation:j.rotation}:{xCenter:0.5*K.width,yCenter:0.5*K.height,width:K.width,height:K.height,rotation:0}}(z,i),N=function(K,j,Y){if(Y===void 0&&(Y=!1),!Y)return{top:0,left:0,right:0,bottom:0};var{height:it,width:Z}=j;Ls(j,"targetSize"),Ls(K,"roi");var st,rt,pt=it/Z,St=K.height/K.width,Vt=0,yt=0;return pt>St?(st=K.width,rt=K.width*pt,yt=(1-St/pt)/2):(st=K.height/pt,rt=K.height,Vt=(1-pt/St)/2),K.width=st,K.height=rt,{top:yt,left:Vt,right:Vt,bottom:yt}}(J,A,I),W=(s=J,a=z.width,o=z.height,l=!1,c=s.width,p=s.height,m=l?-1:1,g=Math.cos(s.rotation),d=Math.sin(s.rotation),S=s.xCenter,v=s.yCenter,P=1/a,b=1/o,(D=Array(16))[0]=c*g*m*P,D[1]=-p*d*P,D[2]=0,D[3]=(-0.5*c*g*m+0.5*p*d+S)*P,D[4]=c*d*m*b,D[5]=p*g*b,D[6]=0,D[7]=(-0.5*p*g-0.5*c*d*m+v)*b,D[8]=0,D[9]=0,D[10]=c*P,D[11]=0,D[12]=0,D[13]=0,D[14]=0,D[15]=1,dl(D));return{imageTensor:At(function(){var K=Cs(e),j=De(pl(W,z,A),[1,8]),Y=F==="zero"?"constant":"nearest",it=Ee.transform(ai(Ye(K,"float32")),j,"bilinear",Y,0,[A.height,A.width]);return M!=null?ml(it,M):it}),padding:N,transformationMatrix:W}}function Ho(e,t,i,s){return s===1?0.5*(e+t):e+(t-e)*i/(s-1)}function hh(e){return At(function(){var t=function(a){return At(function(){return[kt(a,[0,0,0],[1,-1,1]),kt(a,[0,0,1],[1,-1,-1])]})}(e),i=t[0],s=t[1];return{boxes:ut(s),logits:ut(i)}})}function fl(e){return e!=null&&e.currentTime!=null}function Oo(e){for(var t={locationData:{relativeKeypoints:[]}},i=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER,l=0;l<e.length;++l){var c=e[l];i=Math.min(i,c.x),s=Math.max(s,c.x),a=Math.min(a,c.y),o=Math.max(o,c.y),t.locationData.relativeKeypoints.push({x:c.x,y:c.y})}return t.locationData.relativeBoundingBox={xMin:i,yMin:a,xMax:s,yMax:o,width:s-i,height:o-a},t}function ph(e,t,i,s){return ot(this,void 0,void 0,function(){var a,o,l,c,p;return lt(this,function(m){switch(m.label){case 0:return e.sort(function(g,d){return Math.max.apply(Math,d.score)-Math.max.apply(Math,g.score)}),a=De(e.map(function(g){return[g.locationData.relativeBoundingBox.yMin,g.locationData.relativeBoundingBox.xMin,g.locationData.relativeBoundingBox.yMax,g.locationData.relativeBoundingBox.xMax]})),o=ni(e.map(function(g){return g.score[0]})),[4,Ee.nonMaxSuppressionAsync(a,o,t,i)];case 1:return[4,(l=m.sent()).array()];case 2:return c=m.sent(),p=e.filter(function(g,d){return c.indexOf(d)>-1}),Ct([a,o,l]),[2,p]}})})}function gl(e,t){return e.map(function(i){var s=gt(gt({},i),{x:i.x*t.width,y:i.y*t.height});return i.z!=null&&(s.z=i.z*t.width),s})}function dh(e,t,i){return ot(this,void 0,void 0,function(){var s,a,o,l,c,p,m,g,d,S,v,P,b,D,A,I,F,M,z,J,N,W,K,j;return lt(this,function(Y){switch(Y.label){case 0:if(s=ut(t,[0]),a=s.shape,o=a[0],l=a[1],c=a[2],e.length!==c)throw Error("Expected heatmap to have same number of channels as the number of landmarks. But got landmarks length: "+"".concat(e.length,", heatmap length: ").concat(c));return p=[],[4,s.buffer()];case 1:for(m=Y.sent(),g=0;g<e.length;g++)if(d=e[g],S=gt({},d),p.push(S),v=Math.trunc(S.x*l),P=Math.trunc(S.y*o),!(v<0||v>=l||P<0||v>=o)){for(b=Math.trunc((i.kernelSize-1)/2),D=Math.max(0,v-b),A=Math.min(l,v+b+1),I=Math.max(0,P-b),F=Math.min(o,P+b+1),M=0,z=0,J=0,N=0,W=I;W<F;++W)for(K=D;K<A;++K)j=m.get(W,K,g),M+=j,N=Math.max(N,j),z+=K*j,J+=W*j;N>=i.minConfidenceToRefine&&M>0&&(S.x=z/l/M,S.y=J/o/M)}return s.dispose(),[2,p]}})})}function No(e,t){var{left:i,top:s}=t,a=t.left+t.right,o=t.top+t.bottom;return e.map(function(l){return gt(gt({},l),{x:(l.x-i)/(1-a),y:(l.y-s)/(1-o),z:l.z/(1-a)})})}function mh(e,t,i){return rn()==="webgl"?function(s,a,o){var l=o.combineWithPreviousRatio.toFixed(2),c={variableNames:["prevMask","newMask"],outputShape:s.shape,userCode:` 995 void main() { 996 ivec2 coords = getOutputCoords(); 997 int height = coords[0]; 998 int width = coords[1]; 999 1000 float prevMaskValue = getPrevMask(height, width); 1001 float newMaskValue = getNewMask(height, width); 1002 1003 /* 1004 * Assume p := newMaskValue 1005 * H(p) := 1 + (p * log(p) + (1-p) * log(1-p)) / log(2) 1006 * uncertainty alpha(p) =
1007 * Clamp(1 - (1 - H(p)) * (1 - H(p)), 0, 1) [squaring the 1008 * uncertainty] 1009 * 1010 * The following polynomial approximates uncertainty alpha as a 1011 * function of (p + 0.5): 1012 */ 1013 const float c1 = 5.68842; 1014 const float c2 = -0.748699; 1015 const float c3 = -57.8051; 1016 const float c4 = 291.309; 1017 const float c5 = -624.717; 1018 float t = newMaskValue - 0.5; 1019 float x = t * t; 1020 1021 float uncertainty = 1022 1.0 - min(1.0, x * (c1 + x * (c2 + x * (c3 + x * (c4 + x * c5))))); 1023 1024 float outputValue = newMaskValue + (prevMaskValue - newMaskValue) * 1025 (uncertainty * `.concat(l,`); 1026 1027 setOutput(outputValue); 1028 } 1029`)},p=ri();return At(function(){var m=p.compileAndRun(c,[s,a]);return cn().makeTensorFromDataId(m.dataId,m.shape,m.dtype)})}(e,t,i):At(function(){var s=je(t,0.5),a=el(s),o=je(1,nl(1,bt(a,Ht(5.68842,bt(a,Ht(-0.748699,bt(a,Ht(-57.8051,bt(a,Ht(291.309,bt(a,-624.717)))))))))));return Ht(t,bt(je(e,t),bt(o,i.combineWithPreviousRatio)))})}function fh(e,t,i){return ot(this,void 0,void 0,function(){var s,a,o,l,c;return lt(this,function(p){switch(p.label){case 0:return s=e[0],a=e[1],o=function(m,g,d){return At(function(){var S,v,P,b;d.reverseOutputOrder?(v=ut(kt(m,[0,d.boxCoordOffset+0],[-1,1])),S=ut(kt(m,[0,d.boxCoordOffset+1],[-1,1])),b=ut(kt(m,[0,d.boxCoordOffset+2],[-1,1])),P=ut(kt(m,[0,d.boxCoordOffset+3],[-1,1]))):(S=ut(kt(m,[0,d.boxCoordOffset+0],[-1,1])),v=ut(kt(m,[0,d.boxCoordOffset+1],[-1,1])),P=ut(kt(m,[0,d.boxCoordOffset+2],[-1,1])),b=ut(kt(m,[0,d.boxCoordOffset+3],[-1,1]))),v=Ht(bt(Nt(v,d.xScale),g.w),g.x),S=Ht(bt(Nt(S,d.yScale),g.h),g.y),d.applyExponentialOnBoxSize?(P=bt(As(Nt(P,d.hScale)),g.h),b=bt(As(Nt(b,d.wScale)),g.w)):(P=bt(Nt(P,d.hScale),g.h),b=bt(Nt(b,d.wScale),g.h));var D=je(S,Nt(P,2)),A=je(v,Nt(b,2)),I=Ht(S,Nt(P,2)),F=Ht(v,Nt(b,2)),M=an([xe(D,[d.numBoxes,1]),xe(A,[d.numBoxes,1]),xe(I,[d.numBoxes,1]),xe(F,[d.numBoxes,1])],1);if(d.numKeypoints)for(var z=0;z<d.numKeypoints;++z){var J=d.keypointCoordOffset+z*d.numValuesPerKeypoint,N=void 0,W=void 0;d.reverseOutputOrder?(N=ut(kt(m,[0,J],[-1,1])),W=ut(kt(m,[0,J+1],[-1,1]))):(W=ut(kt(m,[0,J],[-1,1])),N=ut(kt(m,[0,J+1],[-1,1])));var K=Ht(bt(Nt(N,d.xScale),g.w),g.x),j=Ht(bt(Nt(W,d.yScale),g.h),g.y);M=an([M,xe(K,[d.numBoxes,1]),xe(j,[d.numBoxes,1])],1)}return M})}(a,t,i),l=At(function(){var m=s;return i.sigmoidScore?(i.scoreClippingThresh!=null&&(m=tl(s,-i.scoreClippingThresh,i.scoreClippingThresh)),m=hn(m)):m}),[4,gh(o,l,i)];case 1:return c=p.sent(),Ct([o,l]),[2,c]}})})}function gh(e,t,i){return ot(this,void 0,void 0,function(){var s,a,o,l,c,p,m,g,d,S,v,P;return lt(this,function(b){switch(b.label){case 0:return s=[],[4,e.data()];case 1:return a=b.sent(),[4,t.data()];case 2:for(o=b.sent(),l=0;l<i.numBoxes;++l)if(!(i.minScoreThresh!=null&&o[l]<i.minScoreThresh||(c=l*i.numCoords,p=Sh(a[c+0],a[c+1],a[c+2],a[c+3],o[l],i.flipVertically,l),(m=p.locationData.relativeBoundingBox).width<0||m.height<0))){if(i.numKeypoints>0)for((g=p.locationData).relativeKeypoints=[],d=i.numKeypoints*i.numValuesPerKeypoint,S=0;S<d;S+=i.numValuesPerKeypoint)v=c+i.keypointCoordOffset+S,P={x:a[v+0],y:i.flipVertically?1-a[v+1]:a[v+1]},g.relativeKeypoints.push(P);s.push(p)}return[2,s]}})})}function Sh(e,t,i,s,a,o,l){return{score:[a],ind:l,locationData:{relativeBoundingBox:{xMin:t,yMin:o?1-i:e,xMax:s,yMax:o?1-e:i,width:s-t,height:i-e}}}}function vh(e,t){return e==="none"?t:function(i){return 1/(1+Math.exp(-i))}(t)}function ko(e,t,i,s){return ot(this,void 0,void 0,function(){var a,o,l,c,p,m,g,d;return lt(this,function(S){switch(S.label){case 0:return i=i||t.flipHorizontally||!1,s=s||t.flipVertically||!1,a=e.size,o=a/t.numLandmarks,[4,e.data()];case 1:for(l=S.sent(),c=[],p=0;p<t.numLandmarks;++p)m=p*o,(d={x:0,y:0}).x=i?t.inputImageWidth-l[m]:l[m],o>1&&(d.y=s?t.inputImageHeight-l[m+1]:l[m+1]),o>2&&(d.z=l[m+2]),o>3&&(d.score=vh(t.visibilityActivation,l[m+3])),c.push(d);for(g=0;g<c.length;++g)(d=c[g]).x=d.x/t.inputImageWidth,d.y=d.y/t.inputImageHeight,d.z=d.z/t.inputImageWidth/(t.normalizeZ||1);return[2,c]}})})}function Ko(e,t,i){var{width:s,height:a,rotation:o}=e;if(i.rotation==null&&i.rotationDegree==null||(o=function(g,d){return d.rotation!=null?g+=d.rotation:d.rotationDegree!=null&&(g+=Math.PI*d.rotationDegree/180),hl(g)}(o,i)),o===0)e.xCenter=e.xCenter+s*i.shiftX,e.yCenter=e.yCenter+a*i.shiftY;else{var l=(t.width*s*i.shiftX*Math.cos(o)-t.height*a*i.shiftY*Math.sin(o))/t.width,c=(t.width*s*i.shiftX*Math.sin(o)+t.height*a*i.shiftY*Math.cos(o))/t.height;e.xCenter=e.xCenter+l,e.yCenter=e.yCenter+c}if(i.squareLong){var p=Math.max(s*t.width,a*t.height);s=p/t.width,a=p/t.height}else if(i.squareShort){var m=Math.min(s*t.width,a*t.height);s=m/t.width,a=m/t.height}return e.width=s*i.scaleX,e.height=a*i.scaleY,e}function xh(e,t){return e.map(function(i){var s=gt(gt({},i),{x:i.x/t.width,y:i.y/t.height});return i.z!=null&&(i.z=i.z/t.width),s})}var ye=function(){function e(t){this.alpha=t,this.initialized=!1}return e.prototype.apply=function(t,i){var s;return this.initialized?s=i==null?this.storedValue+this.alpha*(t-this.storedValue):this.storedValue+this.alpha*i*Math.asinh((t-this.storedValue)/i):(s=t,this.initialized=!0),this.rawValue=t,this.storedValue=s,s},e.prototype.applyWithAlpha=function(t,i,s){return this.alpha=i,this.apply(t,s)},e.prototype.hasLastRawValue=function(){return this.initialized},e.prototype.lastRawValue=function(){return this.rawValue},e.prototype.reset=function(){this.initialized=!1},e}(),Rs=function(){function e(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 ye(this.getAlpha(this.minCutOff)),this.dx=new ye(this.getAlpha(this.derivateCutOff)),this.lastTimestamp=0}return e.prototype.apply=function(t,i,s){if(t==null)return t;var a=Math.trunc(i);if(this.lastTimestamp>=a)return t;this.lastTimestamp!==0&&a!==0&&(this.frequency=1/(0.000001*(a-this.lastTimestamp))),this.lastTimestamp=a;var o=this.x.hasLastRawValue()?(t-this.x.lastRawValue())*s*this.frequency:0,l=this.dx.applyWithAlpha(o,this.getAlpha(this.derivateCutOff)),c=this.minCutOff+this.beta*Math.abs(l),p=this.thresholdCutOff!=null?this.thresholdCutOff+this.thresholdBeta*Math.abs(l):null;return this.x.applyWithAlpha(t,this.getAlpha(c),p)},e.prototype.getAlpha=function(t){return 1/(1+this.frequency/(2*Math.PI*t))},e}(),Fs=function(){function e(t){this.config=t}return e.prototype.apply=function(t,i,s){var a=this;if(t==null)return this.reset(),null;this.initializeFiltersIfEmpty(t);var o=1;if(!this.config.disableValueScaling){if(s<this.config.minAllowedObjectScale)return $e([],t,!0);o=1/s}return t.map(function(l,c){var p=gt(gt({},l),{x:a.xFilters[c].apply(l.x,i,o),y:a.yFilters[c].apply(l.y,i,o)});return l.z!=null&&(p.z=a.zFilters[c].apply(l.z,i,o)),p})},e.prototype.reset=function(){this.xFilters=null,this.yFilters=null,this.zFilters=null},e.prototype.initializeFiltersIfEmpty=function(t){var i=this;this.xFilters!=null&&this.xFilters.length===t.length||(this.xFilters=t.map(function(s){return new Rs(i.config)}),this.yFilters=t.map(function(s){return new Rs(i.config)}),this.zFilters=t.map(function(s){return new Rs(i.config)}))},e}(),bs=function(){function e(t){this.config=t,this.window=[],this.lowPassFilter=new ye(1),this.lastValue=0,this.lastValueScale=1,this.lastTimestamp=-1}return e.prototype.apply=function(t,i,s){if(t==null)return t;var a,o=Math.trunc(i);if(this.lastTimestamp>=o)return t;if(this.lastTimestamp===-1)a=1;else{for(var l=t*s-this.lastValue*this.lastValueScale,c=o-this.lastTimestamp,p=l,m=c,g=(1+this.window.length)*33333.333333333336,d=0,S=this.window;d<S.length;d++){var v=S[d];if(m+v.duration>g)break;p+=v.distance,m+=v.duration}var P=p/(0.000001*m);a=1-1/(1+this.config.velocityScale*Math.abs(P)),this.window.unshift({distance:l,duration:c}),this.window.length>this.config.windowSize&&this.window.pop()}return this.lastValue=t,this.lastValueScale=s,this.lastTimestamp=o,this.lowPassFilter.applyWithAlpha(t,a)},e}(),Th=function(){function e(t){this.config=t}return e.prototype.apply=function(t,i,s){var a=this;if(t==null)return this.reset(),null;var o=1;if(!this.config.disableValueScaling){if(s<this.config.minAllowedObjectScale)return $e([],t,!0);o=1/s}return this.initializeFiltersIfEmpty(t),t.map(function(l,c){var p=gt(gt({},l),{x:a.xFilters[c].apply(l.x,i,o),y:a.yFilters[c].apply(l.y,i,o)});return l.z!=null&&(p.z=a.zFilters[c].apply(l.z,i,o)),p})},e.prototype.reset=function(){this.xFilters=null,this.yFilters=null,this.zFilters=null},e.prototype.initializeFiltersIfEmpty=function(t){var i=this;this.xFilters!=null&&this.xFilters.length===t.length||(this.xFilters=t.map(function(s){return new bs(i.config)}),this.yFilters=t.map(function(s){return new bs(i.config)}),this.zFilters=t.map(function(s){return new bs(i.config)}))},e}(),ys=function(){function e(t){if(t.velocityFilter!=null)this.keypointsFilter=new Th(t.velocityFilter);else{if(t.oneEuroFilter==null)throw Error("Either configure velocityFilter or oneEuroFilter, but got "+"".concat(t,"."));this.keypointsFilter=new Fs(t.oneEuroFilter)}}return e.prototype.apply=function(t,i,s,a,o){if(a===void 0&&(a=!1),t==null)return this.keypointsFilter.reset(),null;var l=o!=null?function(m,g){return(m.width*g.width+m.height*g.height)/2}(o,s):1,c=a?gl(t,s):t,p=this.keypointsFilter.apply(c,i,l);return a?xh(p,s):p},e}(),Jo=function(){function e(t){this.alpha=t.alpha}return e.prototype.apply=function(t){var i=this;if(t==null)return this.visibilityFilters=null,null;this.visibilityFilters!=null&&this.visibilityFilters.length===t.length||(this.visibilityFilters=t.map(function(c){return new ye(i.alpha)}));for(var s=[],a=0;a<t.length;++a){var o=t[a],l=gt({},o);l.score=this.visibilityFilters[a].apply(o.score),s.push(l)}return s},e}(),Ph={reduceBoxesInLowestlayer:!1,interpolatedScaleAspectRatio:1,featureMapHeight:[],featureMapWidth:[],numLayers:5,minScale:0.1484375,maxScale:0.75,inputSizeHeight:224,inputSizeWidth:224,anchorOffsetX:0.5,anch
1029orOffsetY:0.5,strides:[8,16,32,32,32],aspectRatios:[1],fixedAnchorSize:!0};var Rh={maxPoses:1,flipHorizontal:!1},bh={applyExponentialOnBoxSize:!1,flipVertically:!1,ignoreClasses:[],numClasses: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:0.5},yh=0.3,Go={shiftX:0,shiftY:0,scaleX:1.25,scaleY:1.25,squareLong:!0},Dh={outputTensorSize:{width:224,height:224},keepAspectRatio:!0,outputTensorFloatRange:[-1,1],borderMode:"zero"},Eh={outputTensorSize:{width:256,height:256},keepAspectRatio:!0,outputTensorFloatRange:[0,1],borderMode:"zero"},wh={numLandmarks:39,inputImageWidth:256,inputImageHeight:256,visibilityActivation:"sigmoid",flipHorizontally:!1,flipVertically:!1},Ah={numLandmarks:39,inputImageWidth:1,inputImageHeight:1,visibilityActivation:"sigmoid",flipHorizontally:!1,flipVertically:!1},Lh={kernelSize:7,minConfidenceToRefine:0.5},Uo={alpha:0.1},Ih={oneEuroFilter:{frequency:30,minCutOff:0.05,beta:80,derivateCutOff:1,minAllowedObjectScale:0.000001}},Fh={oneEuroFilter:{frequency:30,minCutOff:0.01,beta:10,derivateCutOff:1,minAllowedObjectScale:0.000001}},Mh={oneEuroFilter:{frequency:30,minCutOff:0.1,beta:40,derivateCutOff:1,minAllowedObjectScale:0.000001,disableValueScaling:!0}},_h={activation:"none"},Ch={combineWithPreviousRatio:0.7},Hh=function(){function e(t){this.mask=t}return e.prototype.toCanvasImageSource=function(){return ot(this,void 0,void 0,function(){return lt(this,function(t){return[2,ll(this.mask)]})})},e.prototype.toImageData=function(){return ot(this,void 0,void 0,function(){return lt(this,function(t){return[2,ul(this.mask)]})})},e.prototype.toTensor=function(){return ot(this,void 0,void 0,function(){return lt(this,function(t){return[2,this.mask]})})},e.prototype.getUnderlyingType=function(){return"tensor"},e}();function Oh(e){return cl(e),"person"}var ov=function(){function e(t,i,s,a,o,l){this.detectorModel=t,this.landmarkModel=i,this.enableSmoothing=s,this.enableSegmentation=a,this.smoothSegmentation=o,this.modelType=l,this.regionOfInterest=null,this.prevFilteredSegmentationMask=null,this.anchors=function(d){d.reduceBoxesInLowestLayer==null&&(d.reduceBoxesInLowestLayer=!1),d.interpolatedScaleAspectRatio==null&&(d.interpolatedScaleAspectRatio=1),d.fixedAnchorSize==null&&(d.fixedAnchorSize=!1);for(var S=[],v=0;v<d.numLayers;){for(var P=[],b=[],D=[],A=[],I=v;I<d.strides.length&&d.strides[I]===d.strides[v];){var F=Ho(d.minScale,d.maxScale,I,d.strides.length);if(I===0&&d.reduceBoxesInLowestLayer)D.push(1),D.push(2),D.push(0.5),A.push(0.1),A.push(F),A.push(F);else{for(var M=0;M<d.aspectRatios.length;++M)D.push(d.aspectRatios[M]),A.push(F);if(d.interpolatedScaleAspectRatio>0){var z=I===d.strides.length-1?1:Ho(d.minScale,d.maxScale,I+1,d.strides.length);A.push(Math.sqrt(F*z)),D.push(d.interpolatedScaleAspectRatio)}}I++}for(var J=0;J<D.length;++J){var N=Math.sqrt(D[J]);P.push(A[J]/N),b.push(A[J]*N)}var W=0,K=0;if(d.featureMapHeight.length>0)W=d.featureMapHeight[v],K=d.featureMapWidth[v];else{var j=d.strides[v];W=Math.ceil(d.inputSizeHeight/j),K=Math.ceil(d.inputSizeWidth/j)}for(var Y=0;Y<W;++Y)for(var it=0;
1029it<K;++it)for(var Z=0;Z<P.length;++Z){var st={xCenter:(it+d.anchorOffsetX)/K,yCenter:(Y+d.anchorOffsetY)/W,width:0,height:0};d.fixedAnchorSize?(st.width=1,st.height=1):(st.width=b[Z],st.height=P[Z]),S.push(st)}v=I}return S}(Ph);var c=ni(this.anchors.map(function(d){return d.width})),p=ni(this.anchors.map(function(d){return d.height})),m=ni(this.anchors.map(function(d){return d.xCenter})),g=ni(this.anchors.map(function(d){return d.yCenter}));this.anchorTensor={x:m,y:g,w:c,h:p},this.prevFilteredSegmentationMask=this.enableSegmentation?De([],[0,0]):null}return e.prototype.estimatePoses=function(t,i,s){return ot(this,void 0,void 0,function(){var a,o,l,c,p,m,g,d,S,v,P,b,D,A,I,F,M,z,J,N,W,K,j;return lt(this,function(Y){switch(Y.label){case 0:return a=function(it){var Z;if((Z=it==null?Rh:gt({},it)).maxPoses==null&&(Z.maxPoses=1),Z.maxPoses<=0)throw Error("Invalid maxPoses ".concat(Z.maxPoses,". Should be > 0."));if(Z.maxPoses>1)throw Error("Multi-pose detection is not implemented yet. Please set maxPoses to 1.");return Z}(i),t==null?(this.reset(),[2,[]]):(this.maxPoses=a.maxPoses,this.timestamp=s!=null?1000*s:fl(t)?1e6*t.currentTime:null,o=oi(t),l=At(function(){return Ye(Cs(t),"float32")}),(c=this.regionOfInterest)!=null?[3,2]:[4,this.detectPose(l)]);case 1:if((p=Y.sent()).length===0)return this.reset(),l.dispose(),[2,[]];m=p[0],c=this.poseDetectionToRoi(m,o),Y.label=2;case 2:return[4,this.poseLandmarksByRoi(c,l)];case 3:return g=Y.sent(),l.dispose(),g==null?(this.reset(),[2,[]]):(d=g.landmarks,S=g.auxiliaryLandmarks,v=g.poseScore,P=g.worldLandmarks,b=g.segmentationMask,D=this.poseLandmarkFiltering(d,S,P,o),A=D.actualLandmarksFiltered,I=D.auxiliaryLandmarksFiltered,F=D.actualWorldLandmarksFiltered,M=this.poseLandmarksToRoi(I,o),this.regionOfInterest=M,z=this.smoothSegmentation&&b!=null?this.poseSegmentationFiltering(b):b,(J=A!=null?gl(A,o):null)!=null&&J.forEach(function(it,Z){it.name=Ni[Z]}),(N=F)!=null&&N.forEach(function(it,Z){it.name=Ni[Z]}),W={score:v,keypoints:J,keypoints3D:N},z!==null&&(K=At(function(){var it=ai(z,2),Z=on(it,[[0,0],[0,0],[0,1]]);return sl(Z,[[0,0],[0,0],[0,2]],"symmetric")}),this.smoothSegmentation||Ct(z),j={maskValueToLabel:Oh,mask:new Hh(K)},W.segmentation=j),[2,[W]])}})})},e.prototype.poseSegmentationFiltering=function(t){var i=this.prevFilteredSegmentationMask;return i.size===0?this.prevFilteredSegmentationMask=t:(this.prevFilteredSegmentationMask=mh(i,t,Ch),Ct(t)),Ct(i),this.prevFilteredSegmentationMask},e.prototype.dispose=function(){this.detectorModel.dispose(),this.landmarkModel.dispose(),Ct([this.anchorTensor.x,this.anchorTensor.y,this.anchorTensor.
1029w,this.anchorTensor.h,this.prevFilteredSegmentationMask])},e.prototype.reset=function(){this.regionOfInterest=null,this.enableSegmentation&&(Ct(this.prevFilteredSegmentationMask),this.prevFilteredSegmentationMask=De([],[0,0])),this.visibilitySmoothingFilterActual=null,this.visibilitySmoothingFilterAuxiliary=null,this.landmarksSmoothingFilterActual=null,this.landmarksSmoothingFilterAuxiliary=null},e.prototype.detectPose=function(t){return ot(this,void 0,void 0,function(){var i,s,a,o,l,c,p,m,g,d;return lt(this,function(S){switch(S.label){case 0:return i=Is(t,Dh),s=i.imageTensor,a=i.padding,o=this.detectorModel.predict(s),l=hh(o),c=l.boxes,[4,fh([p=l.logits,c],this.anchorTensor,bh)];case 1:return(m=S.sent()).length===0?(Ct([s,o,p,c]),[2,m]):[4,ph(m,this.maxPoses,yh)];case 2:return g=S.sent(),d=function(v,P){v===void 0&&(v=[]);for(var{left:b,top:D}=P,A=P.left+P.right,I=P.top+P.bottom,F=0;F<v.length;F++){var M=v[F],z=M.locationData.relativeBoundingBox,J=(z.xMin-b)/(1-A),N=(z.yMin-D)/(1-I),W=z.width/(1-A),K=z.height/(1-I);z.xMin=J,z.yMin=N,z.width=W,z.height=K,z.xMax=J+W,z.yMax=N+K;var j=M.locationData.relativeKeypoints;j&&j.forEach(function(Y){var it=(Y.x-b)/(1-A),Z=(Y.y-D)/(1-I);Y.x=it,Y.y=Z})}return v}(g,a),Ct([s,o,p,c]),[2,d]}})})},e.prototype.poseDetectionToRoi=function(t,i){return Ko(Ts(t,i,{rotationVectorEndKeypointIndex:1,rotationVectorStartKeypointIndex:0,rotationVectorTargetAngleDegree:90}),i,Go)},e.prototype.poseLandmarksByRoi=function(t,i){return ot(this,void 0,void 0,function(){var s,a,o,l,c,p,m,g,d,S,v,P,b,D;return lt(this,function(A){switch(A.label){case 0:if(s=oi(i),a=Is(i,Eh,t),o=a.imageTensor,l=a.padding,c=a.transformationMatrix,this.modelType!=="lite"&&this.modelType!=="full"&&this.modelType!=="heavy")throw Error("Model type must be one of lite, full or heavy,"+"but got ".concat(this.modelType));return p=["ld_3d","output_poseflag","activation_heatmap","world_3d"],this.enableSegmentation&&p.push("activation_segmentation"),m=this.landmarkModel.execute(o,p),[4,this.tensorsToPoseLandmarksAndSegmentation(m)];case 1:return(g=A.sent())==null?(Ct(m),Ct(o),[2,null]):(d=g.landmarks,S=g.auxiliaryLandmarks,v=g.poseScore,P=g.worldLandmarks,b=g.segmentationMask,[4,this.poseLandmarksAndSegmentationInverseProjection(s,t,l,c,d,S,P,b)]);case 2:return D=A.sent(),Ct(m),Ct(o),[2,gt({poseScore:v},D)]}})})},e.prototype.poseLandmarksAndSegmentationInverseProjection=function(t,i,s,a,o,l,c,p){return ot(this,void 0,void 0,function(){var m,g,d,S,v,P;return lt(this,function(b){return m=No(o,s),g=No(l,s),d=Co(m,i),S=Co(g,i),v=function(D,A){for(var I=[],F=0,M=D;F<M.length;F++){var z=M[F],J=z.x,N=z.y,W=A.rotation,K=Math.cos(W)*J-Math.sin(W)*N,j=Math.sin(W)*J+Math.cos(W)*N,Y=gt({},z);Y.x=K,Y.y=j,I.push(Y)}return I}(c,i),P=null,this.enableSegmentation&&(P=At(function(){var D=p.shape,A=D[0],I=D[1],F=function(J){var N=dl(Array(16).fill(0));N[0][0]=_t(J,0,0),N[1][0]=-_t(J,0,1),N[2][0]=_t(J,0,2),N[3][0]=-_t(J,0,3),N[0][2]=_t(J,2,0),N[1][2]=-_t(J,2,1),N[2][2]=_t(J,2,2),N[3][2]=-_t(J,2,3),N[0][1]=-_t(J,1,0),N[1][1]=_t(J,1,1),N[2][1]=-_t(J,1,2),N[3][1]=_t(J,1,3),N[0][3]=-_t(J,3,0),N[1][3]=_t(J,3,1),N[2][3]=-_t(J,3,2),N[3][3]=_t(J,3,3);for(var W=J[0][0]*N[0][0]+J[1][0]*N[0][1]+J[2][0]*N[0][2]+J[3][0]*N[0][3],K=0;K<N.length;K++)for(var j=0;j<N.length;j++)N[K][j]/=W;return N}(a),M=De(pl(F,{width:I,height:A},t),[1,8]),z=[1,A,I,1];return ut(Ee.transform(xe(p,z),M,"bilinear","constant",0,[t.height,t.width]),[0,3])}),Ct(p)),[2,{landmarks:d,auxiliaryLandmarks:S,worldLandmarks:v,segmentationMask:P}]})})},e.prototype.tensorsToPoseLandmarksAndSegmentation=function(t){return ot(this,void 0,void 0,function(){var i,s,a,o,l,c,p,m,g,d,S,v,P;return lt(this,function(b){switch(b.label){case 0:return i=t[0],s=t[1],a=t[2],o=t[3],l=this.enableSegmentation?t[4]:null,[4,s.data()];case 1:return(c=b.sent()[0])<0.5?[2,null]:[4,ko(i,wh)];case 2:return[4,dh(b.sent(),a,Lh)];case 3:return p=b.sent(),m=p.slice(0,33),g=p.slice(33,35),[4,ko(o,Ah)];case 4:return d=b.sent(),S=d.slice(0,33),v=function(D,A,I){I===void 0&&(I=!0);for(var F=[],M=0;M<D.length;M++){var z=gt({},A[M]);I&&(z.score=D[M].score),F.push(z)}return F}(m,S,!0),P=this.enableSegmentation?function(D,A,I){return At(function(){var F=ut(D,[0]),M=F.shape[2];if(M===1){var z=F;switch(A.activation){case"none":break;case"sigmoid":z=hn(z);break;case"softmax":throw Error("Softmax activation requires two channels.");default:throw Error("Activation not supported (".concat(A.activation,")"))}var J=I?Ee.resizeBilinear(z,[I.height,I.width]):z;return ut(J,[2])}throw Error("Unsupported number of tensor channels ".concat(M))})}(l,_h):null,[2,{landmarks:m,auxiliaryLandmarks:g,poseScore:c,worldLandmarks:v,segmentationMask:P}]}})})},e.prototype.poseLandmarksToRoi=function(t,i){return Ko(Ts(Oo(t),i,{rotationVectorStartKeypointIndex:0,rotationVectorEndKeypointIndex:1,rotationVectorTargetAngleDegree:90}),i,Go)},e.prototype.poseLandmarkFiltering=function(t,i,s,a){var o,l,c;if(this.timestamp!=null&&this.enableSmoothing){var p=Ts(Oo(i),a,{rotationVectorEndKeypointIndex:0,rotationVectorStartKeypointIndex:1,rotationVectorTargetAngleDegree:90});this.visibilitySmoothingFilterActual==null&&(this.visibilitySmoothingFilterActual=new Jo(Uo)),o=this.visibilitySmoothingFilterActual.apply(t),this.visibilitySmoothingFilterAuxiliary==null&&(this.visibilitySmoothingFilterAuxiliary=new Jo(Uo)),l=this.visibilitySmoothingFilterAuxiliary.apply(i),c=this.visibilitySmoothingFilterActual.apply(s),this.landmarksSmoothingFilterActual==null&&(this.landmarksSmoothingFilterActual=new ys(Ih)),o=this.landmarksSmoothingFilterActual.apply(o,this.timestamp,a,!0,p),this.landmarksSmoothingFilterAuxiliary==null&&(this.landmarksSmoothingFilterAuxiliary=new ys(Fh)),l=this.landmarksSmoothingFilterAuxiliary.apply(l,this.timestamp,a,!0,p),this.worldLandmarksSmoothingFilterActual==null&&(this.worldLandmarksSmoothingFilterActual=new ys(Mh)),c=this.worldLandmarksSmoothingFilterActual.apply(s,this.timestamp)}else o=t,l=i,c=s;return{actualLandmarksFiltered:o,auxiliaryLandmarksFiltered:l,actualWorldLandmarksFiltered:c}},e}();var un,Wt,Sl=function(){function e(t){(function(i){if(i.maxTracks<1)throw Error("Mu
1029st specify 'maxTracks' to be at least 1, but "+"encountered ".concat(i.maxTracks));if(i.maxAge<=0)throw Error("Must specify 'maxAge' to be positive, but "+"encountered ".concat(i.maxAge));if(i.keypointTrackerParams!==void 0){if(i.keypointTrackerParams.keypointConfidenceThreshold<0||i.keypointTrackerParams.keypointConfidenceThreshold>1)throw Error("Must specify 'keypointConfidenceThreshold' to be in the range [0, 1], but encountered "+"".concat(i.keypointTrackerParams.keypointConfidenceThreshold));if(i.keypointTrackerParams.minNumberOfKeypoints<1)throw Error("Must specify 'minNumberOfKeypoints' to be at least 1, but "+"encountered ".concat(i.keypointTrackerParams.minNumberOfKeypoints));for(var s=0,a=i.keypointTrackerParams.keypointFalloff;s<a.length;s++){var o=a[s];if(o<=0)throw Error("Must specify each keypoint falloff parameterto be positive "+"but encountered ".concat(o))}}})(t),this.tracks=[],this.maxTracks=t.maxTracks,this.maxAge=1000*t.maxAge,this.minSimilarity=t.minSimilarity,this.nextID=1}return e.prototype.apply=function(t,i){this.filterOldTracks(i);var s=this.computeSimilarity(t);return this.assignTracks(t,s,i),this.updateTracks(i),t},e.prototype.getTracks=function(){return this.tracks.slice()},e.prototype.getTrackIDs=function(){return new Set(this.tracks.map(function(t){return t.id}))},e.prototype.filterOldTracks=function(t){var i=this;this.tracks=this.tracks.filter(function(s){return t-s.lastTimestamp<=i.maxAge})},e.prototype.assignTracks=function(t,i,s){for(var a=Array.from(Array(i[0].length).keys()),o=[],l=0,c=Array.from(Array(t.length).keys());l<c.length;l++){var p=c[l];if(a.length!==0){for(var m=-1,g=-1,d=0,S=a;d<S.length;d++){var v=S[d],P=i[p][v];P>=this.minSimilarity&&P>g&&(m=v,g=P)}if(m>=0){var b=this.tracks[m];b=Object.assign(b,this.createTrack(t[p],s,b.id)),t[p].id=b.id;var D=a.indexOf(m);a.splice(D,1)}else o.push(p)}else o.push(p)}for(var A=0,I=o;A<I.length;A++){p=I[A];var F=this.createTrack(t[p],s);this.tracks.push(F),t[p].id=F.id}},e.prototype.updateTracks=function(t){this.tracks.sort(function(i,s){return s.lastTimestamp-i.lastTimestamp}),this.tracks=this.tracks.slice(0,this.maxTracks)},e.prototype.createTrack=function(t,i,s){var a={id:s||this.nextTrackID(),lastTimestamp:i,keypoints:$e([],t.keypoints,!0).map(function(o){return gt({},o)})};return t.box!==void 0&&(a.box=gt({},t.box)),a},e.prototype.nextTrackID=function(){var t=this.nextID;return this.nextID+=1,t},e.prototype.remove=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];this.tracks=this.tracks.filter(function(s){return!t.includes(s.id)})},e.prototype.reset=function(){this.tracks=[]},e}(),Nh=function(e){function t(i){return e.call(this,i)||this}return ol(t,e),t.prototype.computeSimilarity=function(i){var s=this;return i.length===0||this.tracks.length===0?[[]]:i.map(function(a){return s.tracks.map(function(o){return s.iou(a,o)})})},t.prototype.iou=function(i,s){var a=Math.max(i.box.xMin,s.box.xMin),o=Math.max(i.box.yMin,s.box.yMin),l=Math.min(i.box.xMax,s.box.xMax),c=Math.min(i.box.yMax,s.box.yMax);if(a>=l||o>=c)return 0;var p=(l-a)*(c-o);return p/(i.box.width*i.box.height+s.box.width*s.box.height-p)},t}(Sl),kh=function(e){function t(i){var s=e.call(this,i)||this;return s.keypointThreshold=i.keypointTrackerParams.keypointConfidenceThreshold,s.keypointFalloff=i.keypointTrackerParams.keypointFalloff,s.minNumKeyoints=i.keypointTrackerParams.minNumberOfKeypoints,s}return ol(t,e),t.prototype.computeSimilarity=function(i){if(i.length===0||this.tracks.length===0)return[[]];for(var s=[],a=0,o=i;a<o.length;a++){for(var l=o[a],c=[],p=0,m=this.tracks;p<m.length;p++){var g=m[p];c.push(this.oks(l,g))}s.push(c)}return s},t.prototype.oks=function(i,s){for(var a=this.area(s.keypoints)+0.000001,o=0,l=0,c=0;c<i.keypoints.length;++c){var p=i.keypoints[c],m=s.keypoints[c];if(!(p.score<this.keypointThreshold||m.score<this.keypointThreshold)){l+=1;var g=Math.pow(p.x-m.x,2)+Math.pow(p.y-m.y,2),d=2*this.keypointFalloff[c];o+=Math.exp(-1*g/(2*a*Math.pow(d,2)))}}return l<this.minNumKeyoints?0:o/l},t.prototype.area=function(i){var s=this,a=i.filter(function(p){return p.score>s.keypointThreshold}),o=Math.min.apply(Math,$e([1],a.map(function(p){return p.x}),!1)),l=Math.max.apply(Math,$e([0],a.map(function(p){return p.x}),!1)),c=Math.min.apply(Math,$e([1],a.map(function(p){return p.y}),!1));return(l-o)*(Math.max.apply(Math,$e([0],a.map(function(p){return p.y}),!1))-c)},t}(Sl);function vl(e){switch(e){case Wt.BlazePose:return Ni.reduce(function(t,i,s){return t[i]=s,t},{});case Wt.PoseNet:case Wt.MoveNet:return pe.reduce(function(t,i,s){return t[i]=s,t},{});default:throw Error("Model ".concat(e," is not supported."))}}(function(e){e.Keypoint="keypoint",e.BoundingBox="boundingBox"})(un||(un={})),function(e){e.MoveNet="MoveNet",e.BlazePose="BlazePose",e.PoseNet="PoseNet"}(Wt||(Wt={}));var lv=Object.freeze({__proto__:null,getKeypointIndexBySide:function(e){switch(e){case Wt.BlazePose:return sh;case Wt.PoseNet:case Wt.MoveNet:return rh;default:throw Error("Model ".concat(e," is not supported."))}},getAdjacentPairs:function(e){switch(e){case Wt.BlazePose:return oh;case Wt.PoseNet:case Wt.MoveNet:return ah;default:throw Error("Model ".concat(e," is not supported."))}},getKeypointIndexByName:vl});var Bo={},Vo={frequency:30,minCutOff:2.5,beta:300,derivateCutOff:2.5,thresholdCutOff:0.5,thresholdBeta:5,disableValueScaling:!0};function Kh(e,t,i,s){for(var a={},o=0,l=pe;o<l.length;o++){var c=l[o];a[c]=[t[i[c]].y*s.height,t[i[c]].x*s.width]}if(function(I,F){return(I[F.left_hip].score>0.2||I[F.right_hip].score>0.2)&&(I[F.left_shoulder].score>0.2||I[F.right_shoulder].score>0.2)}(t,i)){var p=(a.left_hip[0]+a.right_hip[0])/2,m=(a.left_hip[1]+a.right_hip[1])/2,g=function(I,F,M,z,J){for(var N=["left_shoulder","right_shoulder","left_hip","right_hip"],W=0,K=0,j=0;j<N.length;j++)(rt=Math.abs(z-M[N[j]][0]))>W&&(W=rt),(pt=Math.abs(J-M[N[j]][1]))>K&&(K=pt);for(var Y=0,it=0,Z=0,st=Object.keys(M);Z<st.length;Z++){var rt,pt,St=st[Z];if(!(I[F[St]].score<0.2))(rt=Math.abs(z-M[St][0]))>Y&&(Y=rt),(pt=Math.abs(J-M[St][1]))>it&&(it=pt)}return[W,K,Y,it]}(t,i,a,p,m),d=g[0],S=g[1],v=g[2],P=g[3],b=Math.max(1.9*S,1.9*d,1.2*v,1.2*P),D=[p-(b=Math.min(b,Math.max(m,s.width-m,p,s.height-p))),m-b];if(b>
1029Math.max(s.width,s.height)/2)return Ms(e==null,s);var A=2*b;return{yMin:D[0]/s.height,xMin:D[1]/s.width,yMax:(D[0]+A)/s.height,xMax:(D[1]+A)/s.width,height:(D[0]+A)/s.height-D[0]/s.height,width:(D[1]+A)/s.width-D[1]/s.width}}return Ms(e==null,s)}function Ms(e,t){var i,s,a,o;return e?t.width>t.height?(i=1,s=t.height/t.width,a=0,o=(t.width/2-t.height/2)/t.width):(i=t.width/t.height,s=1,a=(t.height/2-t.width/2)/t.height,o=0):t.width>t.height?(i=t.width/t.height,s=1,a=(t.height/2-t.width/2)/t.height,o=0):(i=1,s=t.height/t.width,a=0,o=(t.width/2-t.height/2)/t.width),{yMin:a,xMin:o,yMax:a+i,xMax:o+s,height:i,width:s}}var uv=function(){function e(t,i){this.moveNetModel=t,this.modelInputResolution={height:0,width:0},this.keypointIndexByName=vl(Wt.MoveNet),i.modelType==="SinglePose.Lightning"?(this.modelInputResolution.width=192,this.modelInputResolution.height=192):i.modelType==="SinglePose.Thunder"&&(this.modelInputResolution.width=256,this.modelInputResolution.height=256),this.multiPoseModel=i.modelType==="MultiPose.Lightning",this.multiPoseModel||(this.keypointFilter=new Fs(Vo),this.cropRegionFilterYMin=new ye(0.9),this.cropRegionFilterXMin=new ye(0.9),this.cropRegionFilterYMax=new ye(0.9),this.cropRegionFilterXMax=new ye(0.9)),this.enableSmoothing=i.enableSmoothing,i.minPoseScore?this.minPoseScore=i.minPoseScore:this.minPoseScore=0.25,i.multiPoseMaxDimension?this.multiPoseMaxDimension=i.multiPoseMaxDimension:this.multiPoseMaxDimension=256,this.enableTracking=i.enableTracking,this.multiPoseModel&&this.enableTracking&&(i.trackerType===un.Keypoint?this.tracker=new kh(i.trackerConfig):i.trackerType===un.BoundingBox&&(this.tracker=new Nh(i.trackerConfig)),this.enableSmoothing&&(this.keypointFilterMap=new Map))}return e.prototype.runSinglePersonPoseModel=function(t){return ot(this,void 0,void 0,function(){var i,s,a,o,l;return lt(this,function(c){switch(c.label){case 0:if((i=this.moveNetModel.execute(t)).shape.length!==4||i.shape[0]!==1||i.shape[1]!==1||i.shape[2]!==17||i.shape[3]!==3)throw i.dispose(),Error("Unexpected output shape from model: [".concat(i.shape,"]"));return rn()==="webgpu"?[3,1]:(s=i.dataSync(),[3,3]);case 1:return[4,i.data()];case 2:s=c.sent(),c.label=3;case 3:for(i.dispose(),a={keypoints:[],score:0},o=0,l=0;l<17;++l)a.keypoints[l]={y:s[3*l],x:s[3*l+1],score:s[3*l+2]},a.keypoints[l].score>0.2&&(++o,a.score+=a.keypoints[l].score);return o>0&&(a.score/=o),[2,a]}})})},e.prototype.runMultiPersonPoseModel=function(t){return ot(this,void 0,void 0,function(){var i,s,a,o,l,c,p,m;return lt(this,function(g){switch(g.label){case 0:if((i=this.moveNetModel.execute(t)).shape.length!==3||i.shape[0]!==1||i.shape[2]!==56)throw i.dispose(),Error("Unexpected output shape from model: [".concat(i.shape,"]"));return rn()==="webgpu"?[3,1]:(s=i.dataSync(),[3,3]);case 1:return[4,i.data()];case 2:s=g.sent(),g.label=3;case 3:for(i.dispose(),a=[],o=s.length/56,l=0;l<o;++l)for(a[l]={keypoints:[]},c=56*l+51,a[l].box={yMin:s[c],xMin:s[c+1],yMax:s[c+2],xMax:s[c+3],width:s[c+3]-s[c+1],height:s[c+2]-s[c]},p=56*l+55,a[l].score=s[p],a[l].keypoints=[],m=0;m<17;++m)a[l].keypoints[m]={y:s[56*l+3*m],x:s[56*l+3*m+1],score:s[56*l+3*m+2]};return[2,a]}})})},e.prototype.estimatePoses=function(t,i,s){return i===void 0&&(i=Bo),ot(this,void 0,void 0,function(){var a,o,l,c,p,m;return lt(this,function(g){switch(g.label){case 0:return i=function(d){return d==null?Bo:gt({},d)}(i),t==null?(this.reset(),[2,[]]):(s==null?fl(t)&&(s=1e6*t.currentTime):s*=1000,a=Cs(t),o=oi(a),l=ai(a,0),t instanceof ze||a.dispose(),c=[],this.multiPoseModel?[3,2]:[4,this.estimateSinglePose(l,o,s)]);case 1:return c=g.sent(),[3,4];case 2:return[4,this.estimateMultiplePoses(l,o,s)];case 3:c=g.sent(),g.label=4;case 4:for(p=0;p<c.length;++p)for(m=0;m<c[p].keypoints.length;++m)c[p].keypoints[m].name=pe[m],c[p].keypoints[m].y*=o.height,c[p].keypoints[m].x*=o.width;return[2,c]}})})},e.prototype.estimateSinglePose=function(t,i,s){return ot(this,void 0,void 0,function(){var a,o,l,c,p=this;return lt(this,function(m){switch(m.label){case 0:return this.cropRegion||(this.cropRegion=Ms(this.cropRegion==null,i)),a=At(function(){var g=De([[p.cropRegion.yMin,p.
1029cropRegion.xMin,p.cropRegion.yMax,p.cropRegion.xMax]]),d=il([1],"int32"),S=[p.modelInputResolution.height,p.modelInputResolution.width];return Ye(Ee.cropAndResize(t,g,d,S,"bilinear",0),"int32")}),t.dispose(),[4,this.runSinglePersonPoseModel(a)];case 1:if(o=m.sent(),a.dispose(),o.score<this.minPoseScore)return this.reset(),[2,[]];for(l=0;l<o.keypoints.length;++l)o.keypoints[l].y=this.cropRegion.yMin+o.keypoints[l].y*this.cropRegion.height,o.keypoints[l].x=this.cropRegion.xMin+o.keypoints[l].x*this.cropRegion.width;return s!=null&&this.enableSmoothing&&(o.keypoints=this.keypointFilter.apply(o.keypoints,s,1)),c=Kh(this.cropRegion,o.keypoints,this.keypointIndexByName,i),this.cropRegion=this.filterCropRegion(c),[2,[o]]}})})},e.prototype.estimateMultiplePoses=function(t,i,s){return ot(this,void 0,void 0,function(){var a,o,l,c,p,m,g,d,S,v,P,b=this;return lt(this,function(D){switch(D.label){case 0:return i.width>i.height?(o=this.multiPoseMaxDimension,l=Math.round(this.multiPoseMaxDimension*i.height/i.width),a=Ee.resizeBilinear(t,[l,o]),p=o,m=32*Math.ceil(l/32),c=on(a,[[0,0],[0,m-l],[0,0],[0,0]])):(o=Math.round(this.multiPoseMaxDimension*i.width/i.height),l=this.multiPoseMaxDimension,a=Ee.resizeBilinear(t,[l,o]),p=32*Math.ceil(o/32),m=l,c=on(a,[[0,0],[0,0],[0,p-o],[0,0]])),a.dispose(),t.dispose(),g=Ye(c,"int32"),c.dispose(),[4,this.runMultiPersonPoseModel(g)];case 1:for(d=D.sent(),g.dispose(),d=d.filter(function(A){return A.score>=b.minPoseScore}),v=0;v<d.length;++v)for(S=0;S<d[v].keypoints.length;++S)d[v].keypoints[S].y*=m/l,d[v].keypoints[S].x*=p/o;if(this.enableTracking&&(this.tracker.apply(d,s),this.enableSmoothing)){for(v=0;v<d.length;++v)this.keypointFilterMap.has(d[v].id)||this.keypointFilterMap.set(d[v].id,new Fs(Vo)),d[v].keypoints=this.keypointFilterMap.get(d[v].id).apply(d[v].keypoints,s,1);P=this.tracker.getTrackIDs(),this.keypointFilterMap.forEach(function(A,I){P.has(I)||b.keypointFilterMap.delete(I)})}return[2,d]}})})},e.prototype.filterCropRegion=function(t){if(t){var i=this.cropRegionFilterYMin.apply(t.yMin),s=this.cropRegionFilterXMin.apply(t.xMin),a=this.cropRegionFilterYMax.apply(t.yMax),o=this.cropRegionFilterXMax.apply(t.xMax);return{yMin:i,xMin:s,yMax:a,xMax:o,height:a-i,width:o-s}}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}();var Jh=[8,16,32];var Wo={maxPoses:1,flipHorizontal:!1},Gh={maxPoses:5,flipHorizontal:!1,scoreThreshold:0.5,nmsRadius:20},Uh=[-123.15,-115.9,-103.06];function Ds(e){return Math.floor(e/2)}var Bh=function(){function e(t,i){this.priorityQueue=Array(t),this.numberOfElements=-1,this.getElementValue=i}return e.prototype.enqueue=function(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)},e.prototype.dequeue=function(){var t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t},e.prototype.empty=function(){return this.numberOfElements===-1},e.prototype.size=function(){return this.numberOfElements+1},e.prototype.all=function(){return this.priorityQueue.slice(0,this.numberOfElements+1)},e.prototype.max=function(){return this.priorityQueue[0]},e.prototype.swim=function(t){for(;t>0&&this.less(Ds(t),t);)this.exchange(t,Ds(t)),t=Ds(t)},e.prototype.sink=function(t){for(;2*t<=this.numberOfElements;){var i=2*t;if(i<this.numberOfElements&&this.less(i,i+1)&&i++,!this.less(t,i))break;this.exchange(t,i),t=i}},e.prototype.getValueAt=function(t){return this.getElementValue(this.priorityQueue[t])},e.prototype.less=function(t,i){return this.getValueAt(t)<this.getValueAt(i)},e.prototype.exchange=function(t,i){var s=this.priorityQueue[t];this.priorityQueue[t]=this.priorityQueue[i],this.priorityQueue[i]=s},e}();function Vh(e,t,i,s,a,o){for(var l=o.shape,c=l[0],p=l[1],m=!0,g=Math.max(i-a,0),d=Math.min(i+a+1,c),S=g;S<d;++S){for(var v=Math.max(s-a,0),P=Math.min(s+a+1,p),b=v;b<P;++b)if(o.get(S,b,e)>t){m=!1;break}if(!m)break}return m}function Wh(e){return ot(this,void 0,void 0,function(){return lt(this,function(t){return[2,Promise.all(e.map(function(i){return i.buffer()}))]})})}function xl(e,t,i,s){return{y:s.get(e,t,i),x:s.get(e,t,i+17)}}function Tl(e,t,i){var s=xl(e.heatmapY,e.heatmapX,e.id,i),a=s.y,o=s.x;return{x:e.heatmapX*t+o,y:e.heatmapY*t+a}}function Pl(e,t,i,s){var{x:a,y:o}=i;return e.some(function(l){var c,p,m,g,d,S,v=l.keypoints;return c=o,p=a,m=v[s].y,g=v[s].x,(d=m-c)*d+(S=g-p)*S<=t})}var $o=pe.reduce(function(e,t,i){return e[t]=i,e},{}),Rl=[["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(e){var t=e[0],i=e[1];return[$o[t],$o[i]]}),Es=Rl.map(function(e){return e[1]}),jo=Rl.map(function(e){return e[0]});function Yo(e,t,i){return e<t?t:e>i?i:e}
1029function ws(e,t,i,s){return{y:Yo(Math.round(e.y/t),0,i-1),x:Yo(Math.round(e.x/t),0,s-1)}}function zo(e,t){return{x:e.x+t.x,y:e.y+t.y}}function qo(e,t,i,s,a,o,l,c){c===void 0&&(c=2);for(var p=s.shape,m=p[0],g=p[1],d={y:t.y,x:t.x},S=zo(d,function(I,F,M){var z=M.shape[2]/2;return{y:M.get(F.y,F.x,I),x:M.get(F.y,F.x,z+I)}}(e,ws(d,o,m,g),l)),v=0;v<c;v++){var P=ws(S,o,m,g),b=xl(P.y,P.x,i,a);S=zo({x:P.x*o,y:P.y*o},{x:b.x,y:b.y})}var D=ws(S,o,m,g),A=s.get(D.y,D.x,i);return{y:S.y,x:S.x,name:pe[i],score:A}}function $h(e,t,i,s,a,o){var l=t.shape[2],c=Es.length,p=Array(l),m=e.part,g=e.score,d=Tl(m,s,i);p[m.id]={score:g,name:pe[m.id],y:d.y,x:d.x};for(var S=c-1;S>=0;--S){var v=Es[S],P=jo[S];p[v]&&!p[P]&&(p[P]=qo(S,p[v],P,t,i,s,o))}for(S=0;S<c;++S)v=jo[S],P=Es[S],p[v]&&!p[P]&&(p[P]=qo(S,p[v],P,t,i,s,a));return p}function jh(e,t,i){return i.reduce(function(s,a,o){var{y:l,x:c,score:p}=a;return Pl(e,t,{y:l,x:c},o)||(s+=p),s},0)/i.length}function Yh(e,t,i,s,a,o,l,c){return l===void 0&&(l=0.5),c===void 0&&(c=20),ot(this,void 0,void 0,function(){var p,m,g,d,S,v,P,b,D,A,I,F;return lt(this,function(M){switch(M.label){case 0:return[4,Wh([e,t,i,s])];case 1:for(p=M.sent(),m=p[0],g=p[1],d=p[2],S=p[3],v=[],P=function(z,J,N){for(var W=N.shape,K=W[0],j=W[1],Y=W[2],it=new Bh(K*j*Y,function(St){return St.score}),Z=0;Z<K;++Z)for(var st=0;st<j;++st)for(var rt=0;rt<Y;++rt){var pt=N.get(Z,st,rt);pt<z||Vh(rt,pt,Z,st,J,N)&&it.enqueue({score:pt,part:{heatmapY:Z,heatmapX:st,id:rt}})}return it}(l,1,m),b=c*c;v.length<o&&!P.empty();)D=P.dequeue(),A=Tl(D.part,a,g),Pl(v,b,A,D.part.id)||(I=$h(D,m,g,a,d,S),F=jh(v,b,I),v.push({keypoints:I,score:F}));return[2,v]}})})}function bl(){for(var e,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];switch(t.length){case 0:e="fn main() ";break;case 1:e="fn main(".concat(t[0]," : i32)");break;default:throw Error("Unreachable")}return e}var zh=function(){function e(t){this.variableNames=["A","B"],this.size=!0,this.workgroupSize=[32,1,1],this.outputShape=[t[0],1],this.dispatchLayout=Oi.flatDispatchLayout(this.outputShape),this.dispatch=Oi.computeDispatch(this.dispatchLayout,this.outputShape,this.workgroupSize),this.shaderKey="getpointsConfidenceOp"}return e.prototype.getUserCode=function(){return` 1030 `.concat(bl("index"),` { 1031 if (index < uniforms.size) { 1032 let y = B[index * 2]; 1033 let x = B[index * 2 + 1]; 1034 let outIndex = y * uniforms.aShape.x * uniforms.aShape.z + x * uniforms.aShape.z + index; 1035 result[index] = A[outIndex]; 1036 } 1037 } 1038 `)},e}();function qh(e,t){if(ri()instanceof _s)return function(i,s){var a=ri(),o=new zh(s.shape),l=a.runWebGPUProgram(o,[i,s],"float32");return cn().makeTensorFromTensorInfo(l)}(e,t);throw Error("getPointsConfidenceWebGPU is not supported in this backend!")}var Xh=function(){function e(t){if(this.variableNames=["A","B"],this.size=!0,this.supportedLastDimension=2,t.length!==2||t[1]!==this.supportedLastDimension)throw 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 i=[t[0],1];this.dispatchLayout=Oi.flatDispatchLayout(i),this.dispatch=Oi.computeDispatch(this.dispatchLayout,i,this.workgroupSize),this.shaderKey="GetOffsetVectors"}return e.prototype.getUserCode=function(){return` 1039 fn getOffsetPoint(y: i32, x: i32, index: i32) -> vec2<i32> { 1040 let outIndexY = y * uniforms.bShape.x * uniforms.bShape.y + x * uniforms.bShape.y + index; 1041 let outIndexX = outIndexY + uniforms.bShape.z; 1042 let outY = i32(B[outIndexY]); 1043 let outX = i32(B[outIndexX]); 1044 return vec2<i32>(outY, outX); 1045 } 1046 1047 `.concat(bl("index"),` { 1048 if (index < uniforms.size) { 1049 let indexY = index * `).concat(this.supportedLastDimension,`; 1050 let indexX = indexY + 1; 1051 let heatmapY = A[indexY]; 1052 let heatmapX = A[indexX]; 1053 let out = getOffsetPoint(i32(heatmapY), i32(heatmapX), index); 1054 result[indexY] = f32(out[0]); 1055 result[indexX] = f32(out[1]); 1056 } 1057 } 1058 `)},e}();function Zh(e,t){if(ri()instanceof _s)return function(i,s){var a=ri(),o=new Xh(i.shape),l=a.runWebGPUProgram(o,[i,s],"float32");return cn().makeTensorFromTensorInfo(l)}(e,t);throw Error("getOffsetVectorsGPU is not supported in this backend!")}function yl(e){var t=e.shape,i=t[0],s=t[1],a=t[2];return At(function(){var o,l,c=xe(e,[i*s,a]),p=Qo(c,0),m=ai(Nt(p,si(s,"int32")),1),g=ai((o=p,l=s,At(function(){var d=Nt(o,si(l,"int32"));return je(o,bt(d,si(l,"int32")))})),1);return an([m,g],1)})}function Qh(e,t,i){return At(function(){var s=function(a,o){for(var l=[],c=0;c<pe.length;c++){var p=a.get(c,0).valueOf(),m=a.get(c,1).valueOf(),g=tp(p,m,c,o),d=g.x,S=g.y;l.push(S),l.push(d)}return De(l,[pe.length,2])}(e,i);return Ht(Ye(bt(e.toTensor(),si(t,"int32")),"float32"),s)})}function tp(e,t,i,s){return{y:s.get(e,t,i),x:s.get(e,t,i+pe.length)}}function ep(e,t,i){return ot(this,void 0,void 0,function(){var s,a,o,l,c,p,m,g,d,S;return lt(this,function(v){switch(v.label){case 0:return s=0,a=yl(e),[4,Promise.all([e.buffer(),t.buffer(),a.buffer()])];case 1:return o=v.sent(),l=o[0],c=o[1],p=o[2],[4,(m=Qh(p,i,c)).buffer()];case 2:return g=v.sent(),d=Array.from(function(P,b){for(var D=b.shape[0],A=new Float32Array(D),I=0;I<D;I++){var F=b.get(I,0),M=b.get(I,1);A[I]=P.get(F,M,I)}return A}(l,p)),S=d.map(function(P,b){return s+=P,{y:g.get(b,0),x:g.get(b,1),score:P,name:pe[b]}}),a.dispose(),m.dispose(),[2,{keypoints:S,score:s/S.length}]}})})}function ip(e,t,i){return ot(this,void 0,void 0,function(){var s,a,o;return lt(this,function(l){return s=yl(e),a=function(c,p,m){return At(function(){var g=Zh(c,m);return Ht(Ye(bt(c,si(p,"int32")),"float32"),g)})}(s,i,t),o=qh(e,s),[2,[a,o]]})})}function Xo(e,t){return(e-1)%t==0}function Zo(e,t){return function(i,s){return(i-1)%s==0}(e,t)?e:Math.floor(e/t)*t+1}var cv=function(){function e(t,i){this.posenetModel=t;var s=this.posenetModel.inputs[0].shape;We.assert(s[1]===-1&&s[2]===-1,function(){return"Input shape [".concat(s[1],", ").concat(s[2],"] ")+"must both be equal to or -1"});var a,o,l=(a=i.inputResolution,o=i.outputStride,{height:Zo(a.height,o),width:Zo(a.width,o)});(function(c){We.assert(Jh.indexOf(c)>
1058=0,function(){return"outputStride of ".concat(c," is invalid. ")+"It must be either 8 or 16."})})(i.outputStride),function(c,p){We.assert(Xo(c.height,p),function(){return"height of ".concat(c.height," is invalid for output stride ")+"".concat(p,".")}),We.assert(Xo(c.width,p),function(){return"width of ".concat(c.width," is invalid for output stride ")+"".concat(p,".")})}(l,i.outputStride),this.inputResolution=l,this.outputStride=i.outputStride,this.architecture=i.architecture}return e.prototype.estimatePoses=function(t,i){return i===void 0&&(i=Wo),ot(this,void 0,void 0,function(){return lt(this,function(s){return[2,this.estimatePosesGPU(t,i,!1)]})})},e.prototype.estimatePosesGPU=function(t,i,s){return i===void 0&&(i=Wo),s===void 0&&(s=!1),ot(this,void 0,void 0,function(){var a,o,l,c,p,m,g,d,S,v,P,b,D,A,I,F,M,z;return lt(this,function(J){switch(J.label){case 0:return a=function(N){var W=N;if(W.maxPoses==null&&(W.maxPoses=1),W.maxPoses<=0)throw Error("Invalid maxPoses ".concat(W.maxPoses,". Should be > 0."));if(W.maxPoses>1){if((W=gt(gt({},Gh),W)).scoreThreshold<0||W.scoreThreshold>1)throw Error("Invalid scoreThreshold ".concat(W.scoreThreshold,". ")+"Should be in range [0.0, 1.0]");if(W.nmsRadius<=0)throw Error("Invalid nmsRadius ".concat(W.nmsRadius,"."))}return W}(i),t==null?[2,s?[[],[]]:[]]:(this.maxPoses=a.maxPoses,o=Is(t,{outputTensorSize:this.inputResolution,keepAspectRatio:!0,borderMode:"replicate"}),l=o.imageTensor,c=o.padding,p=this.architecture==="ResNet50"?Ht(l,Uh):ml(l,[-1,1]),m=this.posenetModel.predict(p),this.architecture==="ResNet50"?(g=ut(m[2],[0]),d=ut(m[3],[0]),S=ut(m[0],[0]),v=ut(m[1],[0])):(g=ut(m[0],[0]),d=ut(m[1],[0]),S=ut(m[2],[0]),v=ut(m[3],[0])),P=hn(d),this.maxPoses!==1?[3,5]:s?[4,ip(P,g,this.outputStride)]:[3,2]);case 1:return D=J.sent(),I=D[0],A=D[1],b=[I,A],[3,4];case 2:return[4,ep(P,g,this.outputStride)];case 3:I=J.sent(),b=[I],J.label=4;case 4:return[3,7];case 5:if(s)throw Error("GPU renderer only supports single pose!");return[4,Yh(P,g,S,v,this.outputStride,this.maxPoses,a.scoreThreshold,a.nmsRadius)];case 6:b=J.sent(),J.label=7;case 7:if(s){if(a.flipHorizontal===!0)throw Error("flipHorizontal is not supported!");F=this.getCanvasInfo(oi(t),this.inputResolution,c)}else z=oi(t),M=function(N,W,K,j){var{height:Y,width:it}=W,Z=Y/(K.height*(1-j.top-j.bottom)),st=it/(K.width*(1-j.left-j.r
1058ight)),rt=-j.top*K.height,pt=-j.left*K.width;if(st===1&&Z===1&&rt===0&&pt===0)return N;for(var St=0,Vt=N;St<Vt.length;St++)for(var yt=0,zt=Vt[St].keypoints;yt<zt.length;yt++){var qt=zt[yt];qt.x=(qt.x+pt)*st,qt.y=(qt.y+rt)*Z}return N}(b,z,this.inputResolution,c),a.flipHorizontal&&(M=function(N,W){for(var K=0,j=N;K<j.length;K++)for(var Y=0,it=j[K].keypoints;Y<it.length;Y++){var Z=it[Y];Z.x=W.width-1-Z.x}return N}(M,z));return l.dispose(),p.dispose(),Ct(m),g.dispose(),d.dispose(),S.dispose(),v.dispose(),P.dispose(),[2,s?[b,F]:M]}})})},e.prototype.getCanvasInfo=function(t,i,s){var{height:a,width:o}=t,l=a/(i.height*(1-s.top-s.bottom)),c=o/(i.width*(1-s.left-s.right)),p=-s.top*i.height;return[-s.left*i.width,p,c,l,t.width,t.height]},e.prototype.dispose=function(){this.posenetModel.dispose()},e.prototype.reset=function(){},e}();export{vs as Oi,eh as Pi};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.