shared-ritm 1.3.118 → 1.3.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37419,7 +37419,7 @@ function $M(e, t = []) {
37419
37419
  type: "checkbox",
37420
37420
  model: [...n.value],
37421
37421
  items: e.map((i) => ({
37422
- label: i.label,
37422
+ label: i.checkboxLabel ?? i.label,
37423
37423
  value: i.name,
37424
37424
  disable: t.includes(i.name)
37425
37425
  }))
@@ -3831,4 +3831,4 @@ Manifest JSON has weights with names: `+t.join(", ")+".");return n=C.reduce(func
3831
3831
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3832
3832
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3833
3833
  PERFORMANCE OF THIS SOFTWARE.
3834
- ***************************************************************************** */var an=function(A,B){return an=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,Q){g.__proto__=Q}||function(g,Q){for(var w in Q)Q.hasOwnProperty(w)&&(g[w]=Q[w])},an(A,B)};function LA(A,B){an(A,B);function g(){this.constructor=A}A.prototype=B===null?Object.create(B):(g.prototype=B.prototype,new g)}var ng=function(){return ng=Object.assign||function(B){for(var g,Q=1,w=arguments.length;Q<w;Q++){g=arguments[Q];for(var C in g)Object.prototype.hasOwnProperty.call(g,C)&&(B[C]=g[C])}return B},ng.apply(this,arguments)};function JA(A,B,g,Q){function w(C){return C instanceof g?C:new g(function(E){E(C)})}return new(g||(g=Promise))(function(C,E){function e(n){try{I(Q.next(n))}catch(i){E(i)}}function t(n){try{I(Q.throw(n))}catch(i){E(i)}}function I(n){n.done?C(n.value):w(n.value).then(e,t)}I((Q=Q.apply(A,[])).next())})}function mA(A,B){var g={label:0,sent:function(){if(C[0]&1)throw C[1];return C[1]},trys:[],ops:[]},Q,w,C,E;return E={next:e(0),throw:e(1),return:e(2)},typeof Symbol=="function"&&(E[Symbol.iterator]=function(){return this}),E;function e(I){return function(n){return t([I,n])}}function t(I){if(Q)throw new TypeError("Generator is already executing.");for(;g;)try{if(Q=1,w&&(C=I[0]&2?w.return:I[0]?w.throw||((C=w.return)&&C.call(w),0):w.next)&&!(C=C.call(w,I[1])).done)return C;switch(w=0,C&&(I=[I[0]&2,C.value]),I[0]){case 0:case 1:C=I;break;case 4:return g.label++,{value:I[1],done:!1};case 5:g.label++,w=I[1],I=[0];continue;case 7:I=g.ops.pop(),g.trys.pop();continue;default:if(C=g.trys,!(C=C.length>0&&C[C.length-1])&&(I[0]===6||I[0]===2)){g=0;continue}if(I[0]===3&&(!C||I[1]>C[0]&&I[1]<C[3])){g.label=I[1];break}if(I[0]===6&&g.label<C[1]){g.label=C[1],C=I;break}if(C&&g.label<C[2]){g.label=C[2],g.ops.push(I);break}C[2]&&g.ops.pop(),g.trys.pop();continue}I=B.call(A,g)}catch(n){I=[6,n],w=0}finally{Q=C=0}if(I[0]&5)throw I[1];return{value:I[0]?I[1]:void 0,done:!0}}}function gE(){for(var A=0,B=0,g=arguments.length;B<g;B++)A+=arguments[B].length;for(var Q=Array(A),w=0,B=0;B<g;B++)for(var C=arguments[B],E=0,e=C.length;E<e;E++,w++)Q[w]=C[E];return Q}var Dw=function(){function A(B,g){if(!aw(B)||!aw(g))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:B,height:g}));this._width=B,this._height=g}return Object.defineProperty(A.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),A.prototype.reverse=function(){return new A(1/this.width,1/this.height)},A}();function Le(A,B){return A instanceof HB&&A.shape.length===B}function ZP(A){return Le(A,2)}function Ve(A){return Le(A,3)}function yQ(A){return Le(A,4)}function qP(A){return A%1!==0}function HD(A){return A%2===0}function fD(A,B){B===void 0&&(B=2);var g=Math.pow(10,B);return Math.floor(A*g)/g}function JD(A){return A&&A.width&&A.height}function _P(A,B){var g=A.width,Q=A.height,w=B/Math.max(Q,g);return new Dw(Math.round(g*w),Math.round(Q*w))}function Fn(A){return A.reduce(function(B,g){return B.add(g)},new iB(0,0)).div(new iB(A.length,A.length))}function QE(A,B,g){return Array(A).fill(0).map(function(Q,w){return B+w*g})}function aw(A){return!!A&&A!==1/0&&A!==-1/0&&!isNaN(A)||A===0}function mD(A){return aw(A)&&0<=A&&A<=1}var iB=function(){function A(B,g){this._x=B,this._y=g}return Object.defineProperty(A.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),A.prototype.add=function(B){return new A(this.x+B.x,this.y+B.y)},A.prototype.sub=function(B){return new A(this.x-B.x,this.y-B.y)},A.prototype.mul=function(B){return new A(this.x*B.x,this.y*B.y)},A.prototype.div=function(B){return new A(this.x/B.x,this.y/B.y)},A.prototype.abs=function(){return new A(Math.abs(this.x),Math.abs(this.y))},A.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},A.prototype.floor=function(){return new A(Math.floor(this.x),Math.floor(this.y))},A}(),CQ=function(){function A(B,g){g===void 0&&(g=!0);var Q=B||{},w=[Q.left,Q.top,Q.right,Q.bottom].every(aw),C=[Q.x,Q.y,Q.width,Q.height].every(aw);if(!C&&!w)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify(Q));var E=C?[Q.x,Q.y,Q.width,Q.height]:[Q.left,Q.top,Q.right-Q.left,Q.bottom-Q.top],e=E[0],t=E[1],I=E[2],n=E[3];A.assertIsValidBox({x:e,y:t,width:I,height:n},"Box.constructor",g),this._x=e,this._y=t,this._width=I,this._height=n}return A.isRect=function(B){return!!B&&[B.x,B.y,B.width,B.height].every(aw)},A.assertIsValidBox=function(B,g,Q){if(Q===void 0&&(Q=!1),!A.isRect(B))throw new Error(g+" - invalid box: "+JSON.stringify(B)+", expected object with properties x, y, width, height");if(!Q&&(B.width<0||B.height<0))throw new Error(g+" - width ("+B.width+") and height ("+B.height+") must be positive numbers")},Object.defineProperty(A.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"topLeft",{get:function(){return new iB(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"topRight",{get:function(){return new iB(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"bottomLeft",{get:function(){return new iB(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"bottomRight",{get:function(){return new iB(this.right,this.bottom)},enumerable:!0,configurable:!0}),A.prototype.round=function(){var B=[this.x,this.y,this.width,this.height].map(function(E){return Math.round(E)}),g=B[0],Q=B[1],w=B[2],C=B[3];return new A({x:g,y:Q,width:w,height:C})},A.prototype.floor=function(){var B=[this.x,this.y,this.width,this.height].map(function(E){return Math.floor(E)}),g=B[0],Q=B[1],w=B[2],C=B[3];return new A({x:g,y:Q,width:w,height:C})},A.prototype.toSquare=function(){var B=this,g=B.x,Q=B.y,w=B.width,C=B.height,E=Math.abs(w-C);return w<C&&(g-=E/2,w+=E),C<w&&(Q-=E/2,C+=E),new A({x:g,y:Q,width:w,height:C})},A.prototype.rescale=function(B){var g=JD(B)?B.width:B,Q=JD(B)?B.height:B;return new A({x:this.x*g,y:this.y*Q,width:this.width*g,height:this.height*Q})},A.prototype.pad=function(B,g){var Q=[this.x-B/2,this.y-g/2,this.width+B,this.height+g],w=Q[0],C=Q[1],E=Q[2],e=Q[3];return new A({x:w,y:C,width:E,height:e})},A.prototype.clipAtImageBorders=function(B,g){var Q=this,w=Q.x,C=Q.y,E=Q.right,e=Q.bottom,t=Math.max(w,0),I=Math.max(C,0),n=E-t,i=e-I,c=Math.min(n,B-t),Y=Math.min(i,g-I);return new A({x:t,y:I,width:c,height:Y}).floor()},A.prototype.shift=function(B,g){var Q=this,w=Q.width,C=Q.height,E=this.x+B,e=this.y+g;return new A({x:E,y:e,width:w,height:C})},A.prototype.padAtBorders=function(B,g){var Q=this.width+1,w=this.height+1,C=1,E=1,e=Q,t=w,I=this.left,n=this.top,i=this.right,c=this.bottom;return i>g&&(e=-i+g+Q,i=g),c>B&&(t=-c+B+w,c=B),I<1&&(t=2-I,I=1),n<1&&(t=2-n,n=1),{dy:E,edy:t,dx:C,edx:e,y:n,ey:c,x:I,ex:i,w:Q,h:w}},A.prototype.calibrate=function(B){return new A({left:this.left+B.left*this.width,top:this.top+B.top*this.height,right:this.right+B.right*this.width,bottom:this.bottom+B.bottom*this.height}).toSquare().round()},A}(),Ke=function(A){LA(B,A);function B(g,Q,w,C,E){return E===void 0&&(E=!1),A.call(this,{left:g,top:Q,right:w,bottom:C},E)||this}return B}(CQ),ND=function(){function A(B,g,Q,w,C){this._imageDims=new Dw(C.width,C.height),this._score=B,this._classScore=g,this._className=Q,this._box=new CQ(w).rescale(this._imageDims)}return Object.defineProperty(A.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"relativeBox",{get:function(){return new CQ(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),A.prototype.forSize=function(B,g){return new A(this.score,this.classScore,this.className,this.relativeBox,{width:B,height:g})},A}(),Ng=function(A){LA(B,A);function B(g,Q,w){return A.call(this,g,g,"",Q,w)||this}return B.prototype.forSize=function(g,Q){var w=A.prototype.forSize.call(this,g,Q),C=w.score,E=w.relativeBox,e=w.imageDims;return new B(C,E,e)},B}(ND);function $P(A,B,g){g===void 0&&(g=!0);var Q=Math.max(0,Math.min(A.right,B.right)-Math.max(A.left,B.left)),w=Math.max(0,Math.min(A.bottom,B.bottom)-Math.max(A.top,B.top)),C=Q*w;return g?C/(A.area+B.area-C):C/Math.min(A.area,B.area)}function Av(A){var B=A.map(function(e){return e.x}),g=A.map(function(e){return e.y}),Q=B.reduce(function(e,t){return t<e?t:e},1/0),w=g.reduce(function(e,t){return t<e?t:e},1/0),C=B.reduce(function(e,t){return e<t?t:e},0),E=g.reduce(function(e,t){return e<t?t:e},0);return new Ke(Q,w,C,E)}function wE(A,B,g,Q){Q===void 0&&(Q=!0);for(var w=B.map(function(e,t){return{score:e,boxIndex:t}}).sort(function(e,t){return e.score-t.score}).map(function(e){return e.boxIndex}),C=[],E=function(){var e=w.pop();C.push(e);for(var t=w,I=[],n=0;n<t.length;n++){var i=t[n],c=A[e],Y=A[i];I.push($P(c,Y,Q))}w=w.filter(function(M,D){return I[D]<=g})};w.length>0;)E();return C}function CE(A,B){return FA(function(){var g=B[0],Q=B[1],w=B[2],C=QQ(gE(A.shape.slice(0,3),[1]),g),E=QQ(gE(A.shape.slice(0,3),[1]),Q),e=QQ(gE(A.shape.slice(0,3),[1]),w),t=bB([C,E,e],3);return VB(A,t)})}function Bv(A,B){return B===void 0&&(B=!1),FA(function(){var g=A.shape.slice(1),Q=g[0],w=g[1];if(Q===w)return A;var C=Math.abs(Q-w),E=Math.round(C*(B?.5:1)),e=Q>w?2:1,t=function(Y){var M=A.shape.slice();return M[e]=Y,QQ(M,0)},I=t(E),n=C-I.shape[e],i=B&&n?t(n):null,c=[i,A,I].filter(function(Y){return!!Y}).map(function(Y){return Y.toFloat()});return bB(c,e)})}function sn(A){return 1/(1+Math.exp(-A))}var xe=function(A){LA(B,A);function B(g,Q,w,C,E){return E===void 0&&(E=!1),A.call(this,{x:g,y:Q,width:w,height:C},E)||this}return B}(CQ),gv=.5,Qv=.43,wv=.45,oC=function(){function A(B,g,Q){Q===void 0&&(Q=new iB(0,0));var w=g.width,C=g.height;this._imgDims=new Dw(w,C),this._shift=Q,this._positions=B.map(function(E){return E.mul(new iB(w,C)).add(Q)})}return Object.defineProperty(A.prototype,"shift",{get:function(){return new iB(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"relativePositions",{get:function(){var B=this;return this._positions.map(function(g){return g.sub(B._shift).div(new iB(B.imageWidth,B.imageHeight))})},enumerable:!0,configurable:!0}),A.prototype.forSize=function(B,g){return new this.constructor(this.relativePositions,{width:B,height:g})},A.prototype.shiftBy=function(B,g){return new this.constructor(this.relativePositions,this._imgDims,new iB(B,g))},A.prototype.shiftByPoint=function(B){return this.shiftBy(B.x,B.y)},A.prototype.align=function(B,g){if(g===void 0&&(g={}),B){var Q=B instanceof Ng?B.box.floor():new CQ(B);return this.shiftBy(Q.x,Q.y).align(null,g)}var w=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},g),C=w.useDlibAlignment,E=w.minBoxPadding;return C?this.alignDlib():this.alignMinBbox(E)},A.prototype.alignDlib=function(){var B=this.getRefPointsForAlignment(),g=B[0],Q=B[1],w=B[2],C=function(i){return w.sub(i).magnitude()},E=(C(g)+C(Q))/2,e=Math.floor(E/wv),t=Fn(B),I=Math.floor(Math.max(0,t.x-gv*e)),n=Math.floor(Math.max(0,t.y-Qv*e));return new xe(I,n,Math.min(e,this.imageWidth+I),Math.min(e,this.imageHeight+n))},A.prototype.alignMinBbox=function(B){var g=Av(this.positions);return g.pad(g.width*B,g.height*B)},A.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},A}(),Cv=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.getRefPointsForAlignment=function(){var g=this.positions;return[g[0],g[1],Fn([g[3],g[4]])]},B}(oC),RD=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.getJawOutline=function(){return this.positions.slice(0,17)},B.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},B.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},B.prototype.getNose=function(){return this.positions.slice(27,36)},B.prototype.getLeftEye=function(){return this.positions.slice(36,42)},B.prototype.getRightEye=function(){return this.positions.slice(42,48)},B.prototype.getMouth=function(){return this.positions.slice(48,68)},B.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Fn)},B}(oC),PD=function(){function A(B,g){this._label=B,this._distance=g}return Object.defineProperty(A.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),A.prototype.toString=function(B){return B===void 0&&(B=!0),""+this.label+(B?" ("+fD(this.distance)+")":"")},A}(),vD=function(A){LA(B,A);function B(g,Q){var w=A.call(this,g)||this;return w._label=Q,w}return B.assertIsValidLabeledBox=function(g,Q){if(CQ.assertIsValidBox(g,Q),!aw(g.label))throw new Error(Q+" - expected property label ("+g.label+") to be a number")},Object.defineProperty(B.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),B}(CQ),Xe=function(){function A(B,g){if(typeof B!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(g)||g.some(function(Q){return!(Q instanceof Float32Array)}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=B,this._descriptors=g}return Object.defineProperty(A.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),A.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map(function(B){return Array.from(B)})}},A.fromJSON=function(B){var g=B.descriptors.map(function(Q){return new Float32Array(Q)});return new A(B.label,g)},A}();(function(A){LA(B,A);function B(g,Q,w,C){var E=A.call(this,g,Q)||this;return E._score=w,E._classScore=C,E}return B.assertIsValidPredictedBox=function(g,Q){if(vD.assertIsValidLabeledBox(g,Q),!mD(g.score)||!mD(g.classScore))throw new Error(Q+" - expected properties score ("+g.score+") and ("+g.classScore+") to be a number between [0, 1]")},Object.defineProperty(B.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(B.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),B})(vD);function Oe(A){return A.detection instanceof Ng}function EE(A,B){var g={detection:B};return Object.assign({},A,g)}function kD(){var A=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")},B=function(){throw new Error("readFile - filesystem not available for browser environment")};return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D,Image:HTMLImageElement,ImageData,Video:HTMLVideoElement,createCanvasElement:function(){return document.createElement("canvas")},createImageElement:function(){return document.createElement("img")},fetch:A,readFile:B}}function TD(A){var B="";if(!A)try{A=require("fs")}catch(Q){B=Q.toString()}var g=A?function(Q){return new Promise(function(w,C){A.readFile(Q,function(E,e){return E?C(E):w(e)})})}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+B)};return{readFile:g}}function jD(){var A=global.Canvas||global.HTMLCanvasElement,B=global.Image||global.HTMLImageElement,g=function(){if(A)return new A;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},Q=function(){if(B)return new B;throw new Error("createImageElement - missing Image implementation for nodejs environment")},w=global.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},C=TD();return ng({Canvas:A||function(){function E(){}return E}(),CanvasRenderingContext2D:global.CanvasRenderingContext2D||function(){function E(){}return E}(),Image:B||function(){function E(){}return E}(),ImageData:global.ImageData||function(){function E(){}return E}(),Video:global.HTMLVideoElement||function(){function E(){}return E}(),createCanvasElement:g,createImageElement:Q,fetch:w},C)}function yD(){return typeof window=="object"&&typeof document<"u"&&typeof HTMLImageElement<"u"&&typeof HTMLCanvasElement<"u"&&typeof HTMLVideoElement<"u"&&typeof ImageData<"u"&&typeof CanvasRenderingContext2D<"u"}function pD(){return typeof global=="object"&&typeof require=="function"&&typeof module<"u"&&typeof process<"u"&&!!process.version}var KB;function Ev(){if(!KB)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return KB}function un(A){KB=A}function ln(){yD()&&un(kD()),pD()&&un(jD())}function ev(A){if(KB||ln(),!KB)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var B=A.Canvas,g=B===void 0?KB.Canvas:B,Q=A.Image,w=Q===void 0?KB.Image:Q;KB.Canvas=g,KB.Image=w,KB.createCanvasElement=A.createCanvasElement||function(){return new g},KB.createImageElement=A.createImageElement||function(){return new w},KB.ImageData=A.ImageData||KB.ImageData,KB.Video=A.Video||KB.Video,KB.fetch=A.fetch||KB.fetch,KB.readFile=A.readFile||KB.readFile}var ig={getEnv:Ev,setEnv:un,initialize:ln,createBrowserEnv:kD,createFileSystem:TD,createNodejsEnv:jD,monkeyPatch:ev,isBrowser:yD,isNodejs:pD};ln();function Un(A){return!ig.isNodejs()&&typeof A=="string"?document.getElementById(A):A}function EQ(A){var B=ig.getEnv(),g=B.Canvas,Q=B.CanvasRenderingContext2D;if(A instanceof Q)return A;var w=Un(A);if(!(w instanceof g))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var C=w.getContext("2d");if(!C)throw new Error("resolveContext2d - canvas 2d context is null");return C}var pQ;(function(A){A.TOP_LEFT="TOP_LEFT",A.TOP_RIGHT="TOP_RIGHT",A.BOTTOM_LEFT="BOTTOM_LEFT",A.BOTTOM_RIGHT="BOTTOM_RIGHT"})(pQ||(pQ={}));var zD=function(){function A(B){B===void 0&&(B={});var g=B.anchorPosition,Q=B.backgroundColor,w=B.fontColor,C=B.fontSize,E=B.fontStyle,e=B.padding;this.anchorPosition=g||pQ.TOP_LEFT,this.backgroundColor=Q||"rgba(0, 0, 0, 0.5)",this.fontColor=w||"rgba(255, 255, 255, 1)",this.fontSize=C||14,this.fontStyle=E||"Georgia",this.padding=e||4}return A}(),tv=function(){function A(B,g,Q){Q===void 0&&(Q={}),this.text=typeof B=="string"?[B]:B instanceof A?B.text:B,this.anchor=g,this.options=new zD(Q)}return A.prototype.measureWidth=function(B){var g=this.options.padding;return this.text.map(function(Q){return B.measureText(Q).width}).reduce(function(Q,w){return Q<w?w:Q},0)+2*g},A.prototype.measureHeight=function(){var B=this.options,g=B.fontSize,Q=B.padding;return this.text.length*g+2*Q},A.prototype.getUpperLeft=function(B,g){var Q=this.options.anchorPosition,w=Q===pQ.BOTTOM_RIGHT||Q===pQ.TOP_RIGHT,C=Q===pQ.BOTTOM_LEFT||Q===pQ.BOTTOM_RIGHT,E=this.measureWidth(B),e=this.measureHeight(),t=w?this.anchor.x-E:this.anchor.x,I=C?this.anchor.y-e:this.anchor.y;if(g){var n=g.width,i=g.height,c=Math.max(Math.min(t,n-E),0),Y=Math.max(Math.min(I,i-e),0);return{x:c,y:Y}}return{x:t,y:I}},A.prototype.draw=function(B){var g=Un(B),Q=EQ(g),w=this.options,C=w.backgroundColor,E=w.fontColor,e=w.fontSize,t=w.fontStyle,I=w.padding;Q.font=e+"px "+t;var n=this.measureWidth(Q),i=this.measureHeight();Q.fillStyle=C;var c=this.getUpperLeft(Q,g);Q.fillRect(c.x,c.y,n,i),Q.fillStyle=E,this.text.forEach(function(Y,M){var D=I+c.x,r=I+c.y+(M+1)*e;Q.fillText(Y,D,r)})},A}(),ov=function(){function A(B){B===void 0&&(B={});var g=B.boxColor,Q=B.lineWidth,w=B.label,C=B.drawLabelOptions;this.boxColor=g||"rgba(0, 0, 255, 1)",this.lineWidth=Q||2,this.label=w;var E={anchorPosition:pQ.BOTTOM_LEFT,backgroundColor:this.boxColor};this.drawLabelOptions=new zD(Object.assign({},E,C))}return A}(),Iv=function(){function A(B,g){g===void 0&&(g={}),this.box=new CQ(B),this.options=new ov(g)}return A.prototype.draw=function(B){var g=EQ(B),Q=this.options,w=Q.boxColor,C=Q.lineWidth,E=this.box,e=E.x,t=E.y,I=E.width,n=E.height;g.strokeStyle=w,g.lineWidth=C,g.strokeRect(e,t,I,n);var i=this.options.label;i&&new tv([i],{x:e-C/2,y:t},this.options.drawLabelOptions).draw(B)},A}();function nv(A,B){var g=Array.isArray(B)?B:[B];g.forEach(function(Q){var w=Q instanceof Ng?Q.score:Oe(Q)?Q.detection.score:void 0,C=Q instanceof Ng?Q.box:Oe(Q)?Q.detection.box:new CQ(Q),E=w?""+fD(w):void 0;new Iv(C,{label:E}).draw(A)})}function WD(A){var B=ig.getEnv(),g=B.Image,Q=B.Video;return A instanceof g&&A.complete||A instanceof Q&&A.readyState>=3}function iv(A){return new Promise(function(B,g){if(A instanceof ig.getEnv().Canvas||WD(A))return B();function Q(C){C.currentTarget&&(C.currentTarget.removeEventListener("load",Q),C.currentTarget.removeEventListener("error",w),B(C))}function w(C){C.currentTarget&&(C.currentTarget.removeEventListener("load",Q),C.currentTarget.removeEventListener("error",w),g(C))}A.addEventListener("load",Q),A.addEventListener("error",w)})}function hn(A){var B=ig.getEnv(),g=B.Image,Q=B.Video;return A instanceof g?new Dw(A.naturalWidth,A.naturalHeight):A instanceof Q?new Dw(A.videoWidth,A.videoHeight):new Dw(A.width,A.height)}function Ze(A){var B=A.width,g=A.height,Q=ig.getEnv().createCanvasElement,w=Q();return w.width=B,w.height=g,w}function qe(A,B){var g=ig.getEnv().ImageData;if(!(A instanceof g)&&!WD(A))throw new Error("createCanvasFromMedia - media has not finished loading yet");var Q=hn(A),w=Q.width,C=Q.height,E=Ze({width:w,height:C});return A instanceof g?EQ(E).putImageData(A,0,0):EQ(E).drawImage(A,0,0,w,C),E}function cv(A,B){return JA(this,void 0,void 0,function(){var g,Q,w,C,E,e;return mA(this,function(t){switch(t.label){case 0:return g=ig.getEnv().createCanvasElement(),Q=A.shape.slice(yQ(A)?1:0),w=Q[0],C=Q[1],E=Q[2],e=FA(function(){return A.as3D(w,C,E).toInt()}),[4,Dn.toPixels(e,g)];case 1:return t.sent(),e.dispose(),[2,g]}})})}function bD(A){var B=ig.getEnv(),g=B.Image,Q=B.Canvas,w=B.Video;return A instanceof g||A instanceof Q||A instanceof w}function Yv(A,B,g){g===void 0&&(g=!1);var Q=ig.getEnv(),w=Q.Image,C=Q.Canvas;if(!(A instanceof w||A instanceof C))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var E=hn(A),e=B/Math.max(E.height,E.width),t=e*E.width,I=e*E.height,n=Ze({width:B,height:B}),i=A instanceof C?A:qe(A),c=Math.abs(t-I)/2,Y=g&&t<I?c:0,M=g&&I<t?c:0;return EQ(n).drawImage(i,Y,M,t,I),n}var _e=function(){function A(B,g){var Q=this;if(g===void 0&&(g=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(B))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+B);this._treatAsBatchInput=g,this._batchSize=B.length,B.forEach(function(w,C){if(Ve(w)){Q._imageTensors[C]=w,Q._inputDimensions[C]=w.shape;return}if(yQ(w)){var E=w.shape[0];if(E!==1)throw new Error("NetInput - tf.Tensor4D with batchSize "+E+" passed, but not supported in input array");Q._imageTensors[C]=w,Q._inputDimensions[C]=w.shape.slice(1);return}var e=w instanceof ig.getEnv().Canvas?w:qe(w);Q._canvases[C]=e,Q._inputDimensions[C]=[e.height,e.width,3]})}return Object.defineProperty(A.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"reshapedInputDimensions",{get:function(){var B=this;return QE(this.batchSize,0,1).map(function(g,Q){return B.getReshapedInputDimensions(Q)})},enumerable:!0,configurable:!0}),A.prototype.getInput=function(B){return this.canvases[B]||this.imageTensors[B]},A.prototype.getInputDimensions=function(B){return this._inputDimensions[B]},A.prototype.getInputHeight=function(B){return this._inputDimensions[B][0]},A.prototype.getInputWidth=function(B){return this._inputDimensions[B][1]},A.prototype.getReshapedInputDimensions=function(B){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");var g=this.getInputWidth(B),Q=this.getInputHeight(B);return _P({width:g,height:Q},this.inputSize)},A.prototype.toBatchTensor=function(B,g){var Q=this;return g===void 0&&(g=!0),this._inputSize=B,FA(function(){var w=QE(Q.batchSize,0,1).map(function(E){var e=Q.getInput(E);if(e instanceof HB){var t=yQ(e)?e:e.expandDims();return t=Bv(t,g),(t.shape[1]!==B||t.shape[2]!==B)&&(t=_I.resizeBilinear(t,[B,B])),t.as3D(B,B,3)}if(e instanceof ig.getEnv().Canvas)return Dn.fromPixels(Yv(e,B,g));throw new Error("toBatchTensor - at batchIdx "+E+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+e)}),C=Jg(w.map(function(E){return E.toFloat()})).as4D(Q.batchSize,B,B,3);return C})},A}();function qB(A){return JA(this,void 0,void 0,function(){var B,g,Q;return mA(this,function(w){switch(w.label){case 0:if(A instanceof _e)return[2,A];if(B=Array.isArray(A)?A:[A],!B.length)throw new Error("toNetInput - empty array passed as input");return g=function(C){return Array.isArray(A)?" at input index "+C+":":""},Q=B.map(Un),Q.forEach(function(C,E){if(!bD(C)&&!Ve(C)&&!yQ(C))throw typeof B[E]=="string"?new Error("toNetInput -"+g(E)+" string passed, but could not resolve HTMLElement for element id "+B[E]):new Error("toNetInput -"+g(E)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");if(yQ(C)){var e=C.shape[0];if(e!==1)throw new Error("toNetInput -"+g(E)+" tf.Tensor4D with batchSize "+e+" passed, but not supported in input array")}}),[4,Promise.all(Q.map(function(C){return bD(C)&&iv(C)}))];case 1:return w.sent(),[2,new _e(Q,Array.isArray(A))]}})})}function $e(A,B){return JA(this,void 0,void 0,function(){var g,Q,w,C,E,e,t;return mA(this,function(I){switch(I.label){case 0:return g=ig.getEnv().Canvas,Q=A,A instanceof g?[3,5]:[4,qB(A)];case 1:if(w=I.sent(),w.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return C=w.getInput(0),C instanceof g?(E=C,[3,4]):[3,2];case 2:return[4,cv(C)];case 3:E=I.sent(),I.label=4;case 4:Q=E,I.label=5;case 5:return e=EQ(Q),t=B.map(function(n){return n instanceof Ng?n.forSize(Q.width,Q.height).box.floor():n}).map(function(n){return n.clipAtImageBorders(Q.width,Q.height)}),[2,t.map(function(n){var i=n.x,c=n.y,Y=n.width,M=n.height,D=Ze({width:Y,height:M});return EQ(D).putImageData(e.getImageData(i,c,Y,M),0,0),D})]}})})}function Gn(A,B){return JA(this,void 0,void 0,function(){return mA(this,function(g){if(!Ve(A)&&!yQ(A))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(yQ(A)&&A.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,FA(function(){var Q=A.shape.slice(yQ(A)?1:0),w=Q[0],C=Q[1],E=Q[2],e=B.map(function(I){return I instanceof Ng?I.forSize(C,w).box:I}).map(function(I){return I.clipAtImageBorders(C,w)}),t=e.map(function(I){var n=I.x,i=I.y,c=I.width,Y=I.height;return Or(A.as3D(w,C,E),[i,n,0],[Y,c,E])});return t})]})})}function Mv(A,B){return JA(this,void 0,void 0,function(){var g,Q;return mA(this,function(w){switch(w.label){case 0:return g=ig.getEnv().fetch,[4,g(A,B)];case 1:if(Q=w.sent(),!(Q.status<400))throw new Error("failed to fetch: ("+Q.status+") "+Q.statusText+", from url: "+Q.url);return[2,Q]}})})}function rv(A){return JA(this,void 0,void 0,function(){return mA(this,function(B){switch(B.label){case 0:return[4,Mv(A)];case 1:return[2,B.sent().json()]}})})}function SD(A,B){var g=B+"-weights_manifest.json";if(!A)return{modelBaseUri:"",manifestUri:g};if(A==="/")return{modelBaseUri:"/",manifestUri:"/"+g};var Q=A.startsWith("http://")?"http://":A.startsWith("https://")?"https://":"";A=A.replace(Q,"");var w=A.split("/").filter(function(e){return e}),C=A.endsWith(".json")?w[w.length-1]:g,E=Q+(A.endsWith(".json")?w.slice(0,w.length-1):w).join("/");return E=A.startsWith("/")?"/"+E:E,{modelBaseUri:E,manifestUri:E==="/"?"/"+C:E+"/"+C}}function Dv(A,B){return JA(this,void 0,void 0,function(){var g,Q,w,C;return mA(this,function(E){switch(E.label){case 0:return g=SD(A,B),Q=g.manifestUri,w=g.modelBaseUri,[4,rv(Q)];case 1:return C=E.sent(),[2,GD.loadWeights(C,w)]}})})}function av(A,B,g){g===void 0&&(g=!1);var Q=g?hn(B):B,w=Q.width,C=Q.height;return A.width=w,A.height=C,{width:w,height:C}}var lQ=function(){function A(B){this._name=B,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(A.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),A.prototype.getParamFromPath=function(B){var g=this.traversePropertyPath(B),Q=g.obj,w=g.objProp;return Q[w]},A.prototype.reassignParamFromPath=function(B,g){var Q=this.traversePropertyPath(B),w=Q.obj,C=Q.objProp;w[C].dispose(),w[C]=g},A.prototype.getParamList=function(){var B=this;return this._paramMappings.map(function(g){var Q=g.paramPath;return{path:Q,tensor:B.getParamFromPath(Q)}})},A.prototype.getTrainableParams=function(){return this.getParamList().filter(function(B){return B.tensor instanceof xw})},A.prototype.getFrozenParams=function(){return this.getParamList().filter(function(B){return!(B.tensor instanceof xw)})},A.prototype.variable=function(){var B=this;this.getFrozenParams().forEach(function(g){var Q=g.path,w=g.tensor;B.reassignParamFromPath(Q,w.variable())})},A.prototype.freeze=function(){var B=this;this.getTrainableParams().forEach(function(g){var Q=g.path,w=g.tensor,C=wg(w.dataSync());w.dispose(),B.reassignParamFromPath(Q,C)})},A.prototype.dispose=function(B){B===void 0&&(B=!0),this.getParamList().forEach(function(g){if(B&&g.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+g.path);g.tensor.dispose()}),this._params=void 0},A.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(B){var g=B.tensor;return Array.from(g.dataSync())}).reduce(function(B,g){return B.concat(g)}))},A.prototype.load=function(B){return JA(this,void 0,void 0,function(){return mA(this,function(g){switch(g.label){case 0:return B instanceof Float32Array?(this.extractWeights(B),[2]):[4,this.loadFromUri(B)];case 1:return g.sent(),[2]}})})},A.prototype.loadFromUri=function(B){return JA(this,void 0,void 0,function(){var g;return mA(this,function(Q){switch(Q.label){case 0:if(B&&typeof B!="string")throw new Error(this._name+".loadFromUri - expected model uri");return[4,Dv(B,this.getDefaultModelName())];case 1:return g=Q.sent(),this.loadFromWeightMap(g),[2]}})})},A.prototype.loadFromDisk=function(B){return JA(this,void 0,void 0,function(){var g,Q,w,C,E,e,t,I,n,i;return mA(this,function(c){switch(c.label){case 0:if(B&&typeof B!="string")throw new Error(this._name+".loadFromDisk - expected model file path");return g=ig.getEnv().readFile,Q=SD(B,this.getDefaultModelName()),w=Q.manifestUri,C=Q.modelBaseUri,E=function(Y){return Promise.all(Y.map(function(M){return g(M).then(function(D){return D.buffer})}))},e=GD.weightsLoaderFactory(E),n=(I=JSON).parse,[4,g(w)];case 1:return t=n.apply(I,[c.sent().toString()]),[4,e(t,C)];case 2:return i=c.sent(),this.loadFromWeightMap(i),[2]}})})},A.prototype.loadFromWeightMap=function(B){var g=this.extractParamsFromWeigthMap(B),Q=g.paramMappings,w=g.params;this._paramMappings=Q,this._params=w},A.prototype.extractWeights=function(B){var g=this.extractParams(B),Q=g.paramMappings,w=g.params;this._paramMappings=Q,this._params=w},A.prototype.traversePropertyPath=function(B){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var g=B.split("/").reduce(function(C,E){if(!C.nextObj.hasOwnProperty(E))throw new Error("traversePropertyPath - object does not have property "+E+", for path "+B);return{obj:C.nextObj,objProp:E,nextObj:C.nextObj[E]}},{nextObj:this.params}),Q=g.obj,w=g.objProp;if(!Q||!w||!(Q[w]instanceof HB))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+B);return{obj:Q,objProp:w}},A}();function Rg(A,B,g){return FA(function(){var Q=xI(A,B.depthwise_filter,B.pointwise_filter,g,"same");return Q=BB(Q,B.bias),Q})}function dn(A,B,g){return g===void 0&&(g=!1),FA(function(){var Q=JB(g?BB(jg(A,B.conv0.filters,[2,2],"same"),B.conv0.bias):Rg(A,B.conv0,[2,2])),w=Rg(Q,B.conv1,[1,1]),C=JB(BB(Q,w)),E=Rg(C,B.conv2,[1,1]);return JB(BB(Q,BB(w,E)))})}function At(A,B,g,Q){return g===void 0&&(g=!1),Q===void 0&&(Q=!0),FA(function(){var w=JB(g?BB(jg(A,B.conv0.filters,Q?[2,2]:[1,1],"same"),B.conv0.bias):Rg(A,B.conv0,Q?[2,2]:[1,1])),C=Rg(w,B.conv1,[1,1]),E=JB(BB(w,C)),e=Rg(E,B.conv2,[1,1]),t=JB(BB(w,BB(C,e))),I=Rg(t,B.conv3,[1,1]);return JB(BB(w,BB(C,BB(e,I))))})}function Vg(A,B,g,Q){return g===void 0&&(g="same"),Q===void 0&&(Q=!1),FA(function(){var w=BB(jg(A,B.filters,[1,1],g),B.bias);return Q?JB(w):w})}function UQ(A,B){Object.keys(A).forEach(function(g){B.some(function(Q){return Q.originalPath===g})||A[g].dispose()})}function Bt(A,B){return function(g,Q,w,C){var E=sg(A(g*Q*w*w),[w,w,g,Q]),e=yB(A(Q));return B.push({paramPath:C+"/filters"},{paramPath:C+"/bias"}),{filters:E,bias:e}}}function Hn(A,B){return function(g,Q,w){var C=PQ(A(g*Q),[g,Q]),E=yB(A(Q));return B.push({paramPath:w+"/weights"},{paramPath:w+"/bias"}),{weights:C,bias:E}}}var LD=function(){function A(B,g,Q){this.depthwise_filter=B,this.pointwise_filter=g,this.bias=Q}return A}();function fn(A,B){return function(g,Q,w){var C=sg(A(9*g),[3,3,g,1]),E=sg(A(g*Q),[1,1,g,Q]),e=yB(A(Q));return B.push({paramPath:w+"/depthwise_filter"},{paramPath:w+"/pointwise_filter"},{paramPath:w+"/bias"}),new LD(C,E,e)}}function Jn(A){return function(B){var g=A(B+"/depthwise_filter",4),Q=A(B+"/pointwise_filter",4),w=A(B+"/bias",1);return new LD(g,Q,w)}}function zQ(A,B){return function(g,Q,w){var C=A[g];if(!Le(C,Q))throw new Error("expected weightMap["+g+"] to be a Tensor"+Q+"D, instead have "+C);return B.push({originalPath:g,paramPath:w||g}),C}}function hQ(A){var B=A;function g(w){var C=B.slice(0,w);return B=B.slice(w),C}function Q(){return B}return{extractWeights:g,getRemainingWeights:Q}}function VD(A,B){var g=Bt(A,B),Q=fn(A,B);function w(E,e,t,I){I===void 0&&(I=!1);var n=I?g(E,e,3,t+"/conv0"):Q(E,e,t+"/conv0"),i=Q(e,e,t+"/conv1"),c=Q(e,e,t+"/conv2");return{conv0:n,conv1:i,conv2:c}}function C(E,e,t,I){I===void 0&&(I=!1);var n=w(E,e,t,I),i=n.conv0,c=n.conv1,Y=n.conv2,M=Q(e,e,t+"/conv3");return{conv0:i,conv1:c,conv2:Y,conv3:M}}return{extractDenseBlock3Params:w,extractDenseBlock4Params:C}}function Fv(A){var B=[],g=hQ(A),Q=g.extractWeights,w=g.getRemainingWeights,C=VD(Q,B).extractDenseBlock4Params,E=C(3,32,"dense0",!0),e=C(32,64,"dense1"),t=C(64,128,"dense2"),I=C(128,256,"dense3");if(w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{paramMappings:B,params:{dense0:E,dense1:e,dense2:t,dense3:I}}}function KD(A){return function(B){var g=A(B+"/filters",4),Q=A(B+"/bias",1);return{filters:g,bias:Q}}}function xD(A,B){var g=zQ(A,B),Q=KD(g),w=Jn(g);function C(e,t){t===void 0&&(t=!1);var I=t?Q(e+"/conv0"):w(e+"/conv0"),n=w(e+"/conv1"),i=w(e+"/conv2");return{conv0:I,conv1:n,conv2:i}}function E(e,t){t===void 0&&(t=!1);var I=t?Q(e+"/conv0"):w(e+"/conv0"),n=w(e+"/conv1"),i=w(e+"/conv2"),c=w(e+"/conv3");return{conv0:I,conv1:n,conv2:i,conv3:c}}return{extractDenseBlock3Params:C,extractDenseBlock4Params:E}}function sv(A){var B=[],g=xD(A,B).extractDenseBlock4Params,Q={dense0:g("dense0",!0),dense1:g("dense1"),dense2:g("dense2"),dense3:g("dense3")};return UQ(A,B),{params:Q,paramMappings:B}}var XD=function(A){LA(B,A);function B(){return A.call(this,"FaceFeatureExtractor")||this}return B.prototype.forwardInput=function(g){var Q=this.params;if(!Q)throw new Error("FaceFeatureExtractor - load model before inference");return FA(function(){var w=g.toBatchTensor(112,!0),C=[122.782,117.001,104.298],E=CE(w,C).div(YA(255)),e=At(E,Q.dense0,!0);return e=At(e,Q.dense1),e=At(e,Q.dense2),e=At(e,Q.dense3),e=AE(e,[7,7],[2,2],"valid"),e})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},B.prototype.extractParamsFromWeigthMap=function(g){return sv(g)},B.prototype.extractParams=function(g){return Fv(g)},B}(lQ);function eQ(A,B){return FA(function(){return BB(ye(A,B.weights),B.bias)})}function uv(A,B,g){var Q=[],w=hQ(A),C=w.extractWeights,E=w.getRemainingWeights,e=Hn(C,Q),t=e(B,g,"fc");if(E().length!==0)throw new Error("weights remaing after extract: "+E().length);return{paramMappings:Q,params:{fc:t}}}function lv(A){var B=[],g=zQ(A,B);function Q(C){var E=g(C+"/weights",2),e=g(C+"/bias",1);return{weights:E,bias:e}}var w={fc:Q("fc")};return UQ(A,B),{params:w,paramMappings:B}}function OD(A){var B={},g={};return Object.keys(A).forEach(function(Q){var w=Q.startsWith("fc")?g:B;w[Q]=A[Q]}),{featureExtractorMap:B,classifierMap:g}}var ZD=function(A){LA(B,A);function B(g,Q){var w=A.call(this,g)||this;return w._faceFeatureExtractor=Q,w}return Object.defineProperty(B.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),B.prototype.runNet=function(g){var Q=this,w=this.params;if(!w)throw new Error(this._name+" - load model before inference");return FA(function(){var C=g instanceof _e?Q.faceFeatureExtractor.forwardInput(g):g;return eQ(C.as2D(C.shape[0],-1),w.fc)})},B.prototype.dispose=function(g){g===void 0&&(g=!0),this.faceFeatureExtractor.dispose(g),A.prototype.dispose.call(this,g)},B.prototype.loadClassifierParams=function(g){var Q=this.extractClassifierParams(g),w=Q.params,C=Q.paramMappings;this._params=w,this._paramMappings=C},B.prototype.extractClassifierParams=function(g){return uv(g,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},B.prototype.extractParamsFromWeigthMap=function(g){var Q=OD(g),w=Q.featureExtractorMap,C=Q.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(w),lv(C)},B.prototype.extractParams=function(g){var Q=this.getClassifierChannelsIn(),w=this.getClassifierChannelsOut(),C=w*Q+w,E=g.slice(0,g.length-C),e=g.slice(g.length-C);return this.faceFeatureExtractor.extractWeights(E),this.extractClassifierParams(e)},B}(lQ),qD=["neutral","happy","sad","angry","fearful","disgusted","surprised"],Uv=function(){function A(B){var g=this;if(B.length!==7)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+B.length);qD.forEach(function(Q,w){g[Q]=B[w]})}return A.prototype.asSortedArray=function(){var B=this;return qD.map(function(g){return{expression:g,probability:B[g]}}).sort(function(g,Q){return Q.probability-g.probability})},A}(),hv=function(A){LA(B,A);function B(g){return g===void 0&&(g=new XD),A.call(this,"FaceExpressionNet",g)||this}return B.prototype.forwardInput=function(g){var Q=this;return FA(function(){return aQ(Q.runNet(g))})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.predictExpressions=function(g){return JA(this,void 0,void 0,function(){var Q,w,C,E,e=this;return mA(this,function(t){switch(t.label){case 0:return[4,qB(g)];case 1:return Q=t.sent(),[4,this.forwardInput(Q)];case 2:return w=t.sent(),[4,Promise.all(SB(w).map(function(I){return JA(e,void 0,void 0,function(){var n;return mA(this,function(i){switch(i.label){case 0:return[4,I.data()];case 1:return n=i.sent(),I.dispose(),[2,n]}})})}))];case 3:return C=t.sent(),w.dispose(),E=C.map(function(I){return new Uv(I)}),[2,Q.isBatchInput?E:E[0]]}})})},B.prototype.getDefaultModelName=function(){return"face_expression_model"},B.prototype.getClassifierChannelsIn=function(){return 256},B.prototype.getClassifierChannelsOut=function(){return 7},B}(ZD);function _D(A,B){var g={expressions:B};return Object.assign({},A,g)}function mn(A){return Oe(A)&&A.landmarks instanceof oC&&A.unshiftedLandmarks instanceof oC&&A.alignedRect instanceof Ng}function gt(A,B){var g=A.detection.box,Q=B.shiftBy(g.x,g.y),w=Q.align(),C=A.detection.imageDims,E=new Ng(A.detection.score,w.rescale(C.reverse()),C),e={landmarks:Q,unshiftedLandmarks:B,alignedRect:E};return Object.assign({},A,e)}var Gv=function(){function A(B){B===void 0&&(B={});var g=B.drawLines,Q=g===void 0?!0:g,w=B.drawPoints,C=w===void 0?!0:w,E=B.lineWidth,e=B.lineColor,t=B.pointSize,I=B.pointColor;this.drawLines=Q,this.drawPoints=C,this.lineWidth=E||1,this.pointSize=t||2,this.lineColor=e||"rgba(0, 255, 255, 1)",this.pointColor=I||"rgba(255, 0, 255, 1)"}return A}(),dv=function(){function A(B,g){g===void 0&&(g={}),this.faceLandmarks=B,this.options=new Gv(g)}return A.prototype.draw=function(B){var g=EQ(B),Q=this.options,w=Q.drawLines,C=Q.drawPoints,E=Q.lineWidth,e=Q.lineColor,t=Q.pointSize,I=Q.pointColor;if(w&&this.faceLandmarks instanceof RD&&(g.strokeStyle=e,g.lineWidth=E,rw(g,this.faceLandmarks.getJawOutline()),rw(g,this.faceLandmarks.getLeftEyeBrow()),rw(g,this.faceLandmarks.getRightEyeBrow()),rw(g,this.faceLandmarks.getNose()),rw(g,this.faceLandmarks.getLeftEye(),!0),rw(g,this.faceLandmarks.getRightEye(),!0),rw(g,this.faceLandmarks.getMouth(),!0)),C){g.strokeStyle=I,g.fillStyle=I;var n=function(i){g.beginPath(),g.arc(i.x,i.y,t,0,2*Math.PI),g.fill()};this.faceLandmarks.positions.forEach(n)}},A}();function Hv(A,B){var g=Array.isArray(B)?B:[B];g.forEach(function(Q){var w=Q instanceof oC?Q:mn(Q)?Q.landmarks:void 0;if(!w)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>> or array thereof");new dv(w).draw(A)})}function fv(A,B){var g=Bt(A,B),Q=fn(A,B);function w(E,e,t){var I=Q(E,e,t+"/separable_conv0"),n=Q(e,e,t+"/separable_conv1"),i=g(E,e,1,t+"/expansion_conv");return{separable_conv0:I,separable_conv1:n,expansion_conv:i}}function C(E,e){var t=Q(E,E,e+"/separable_conv0"),I=Q(E,E,e+"/separable_conv1"),n=Q(E,E,e+"/separable_conv2");return{separable_conv0:t,separable_conv1:I,separable_conv2:n}}return{extractConvParams:g,extractSeparableConvParams:Q,extractReductionBlockParams:w,extractMainBlockParams:C}}function Jv(A,B){var g=[],Q=hQ(A),w=Q.extractWeights,C=Q.getRemainingWeights,E=fv(w,g),e=E.extractConvParams,t=E.extractSeparableConvParams,I=E.extractReductionBlockParams,n=E.extractMainBlockParams,i=e(3,32,3,"entry_flow/conv_in"),c=I(32,64,"entry_flow/reduction_block_0"),Y=I(64,128,"entry_flow/reduction_block_1"),M={conv_in:i,reduction_block_0:c,reduction_block_1:Y},D={};QE(B,0,1).forEach(function(s){D["main_block_"+s]=n(128,"middle_flow/main_block_"+s)});var r=I(128,256,"exit_flow/reduction_block"),F=t(256,512,"exit_flow/separable_conv"),u={reduction_block:r,separable_conv:F};if(C().length!==0)throw new Error("weights remaing after extract: "+C().length);return{paramMappings:g,params:{entry_flow:M,middle_flow:D,exit_flow:u}}}function mv(A,B){var g=zQ(A,B),Q=KD(g),w=Jn(g);function C(e){var t=w(e+"/separable_conv0"),I=w(e+"/separable_conv1"),n=Q(e+"/expansion_conv");return{separable_conv0:t,separable_conv1:I,expansion_conv:n}}function E(e){var t=w(e+"/separable_conv0"),I=w(e+"/separable_conv1"),n=w(e+"/separable_conv2");return{separable_conv0:t,separable_conv1:I,separable_conv2:n}}return{extractConvParams:Q,extractSeparableConvParams:w,extractReductionBlockParams:C,extractMainBlockParams:E}}function Nv(A,B){var g=[],Q=mv(A,g),w=Q.extractConvParams,C=Q.extractSeparableConvParams,E=Q.extractReductionBlockParams,e=Q.extractMainBlockParams,t=w("entry_flow/conv_in"),I=E("entry_flow/reduction_block_0"),n=E("entry_flow/reduction_block_1"),i={conv_in:t,reduction_block_0:I,reduction_block_1:n},c={};QE(B,0,1).forEach(function(r){c["main_block_"+r]=e("middle_flow/main_block_"+r)});var Y=E("exit_flow/reduction_block"),M=C("exit_flow/separable_conv"),D={reduction_block:Y,separable_conv:M};return UQ(A,g),{params:{entry_flow:i,middle_flow:c,exit_flow:D},paramMappings:g}}function $D(A,B,g){return BB(jg(A,B.filters,g,"same"),B.bias)}function Nn(A,B,g){g===void 0&&(g=!0);var Q=g?JB(A):A;return Q=Rg(Q,B.separable_conv0,[1,1]),Q=Rg(JB(Q),B.separable_conv1,[1,1]),Q=ZB(Q,[3,3],[2,2],"same"),Q=BB(Q,$D(A,B.expansion_conv,[2,2])),Q}function Rv(A,B){var g=Rg(JB(A),B.separable_conv0,[1,1]);return g=Rg(JB(g),B.separable_conv1,[1,1]),g=Rg(JB(g),B.separable_conv2,[1,1]),g=BB(g,A),g}var Pv=function(A){LA(B,A);function B(g){var Q=A.call(this,"TinyXception")||this;return Q._numMainBlocks=g,Q}return B.prototype.forwardInput=function(g){var Q=this,w=this.params;if(!w)throw new Error("TinyXception - load model before inference");return FA(function(){var C=g.toBatchTensor(112,!0),E=[122.782,117.001,104.298],e=CE(C,E).div(YA(256)),t=JB($D(e,w.entry_flow.conv_in,[2,2]));return t=Nn(t,w.entry_flow.reduction_block_0,!1),t=Nn(t,w.entry_flow.reduction_block_1),QE(Q._numMainBlocks,0,1).forEach(function(I){t=Rv(t,w.middle_flow["main_block_"+I])}),t=Nn(t,w.exit_flow.reduction_block),t=JB(Rg(t,w.exit_flow.separable_conv,[1,1])),t})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.getDefaultModelName=function(){return"tiny_xception_model"},B.prototype.extractParamsFromWeigthMap=function(g){return Nv(g,this._numMainBlocks)},B.prototype.extractParams=function(g){return Jv(g,this._numMainBlocks)},B}(lQ);function vv(A){var B=[],g=hQ(A),Q=g.extractWeights,w=g.getRemainingWeights,C=Hn(Q,B),E=C(512,1,"fc/age"),e=C(512,2,"fc/gender");if(w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{paramMappings:B,params:{fc:{age:E,gender:e}}}}function kv(A){var B=[],g=zQ(A,B);function Q(C){var E=g(C+"/weights",2),e=g(C+"/bias",1);return{weights:E,bias:e}}var w={fc:{age:Q("fc/age"),gender:Q("fc/gender")}};return UQ(A,B),{params:w,paramMappings:B}}var Qt;(function(A){A.FEMALE="female",A.MALE="male"})(Qt||(Qt={}));var Tv=function(A){LA(B,A);function B(g){g===void 0&&(g=new Pv(2));var Q=A.call(this,"AgeGenderNet")||this;return Q._faceFeatureExtractor=g,Q}return Object.defineProperty(B.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),B.prototype.runNet=function(g){var Q=this,w=this.params;if(!w)throw new Error(this._name+" - load model before inference");return FA(function(){var C=g instanceof _e?Q.faceFeatureExtractor.forwardInput(g):g,E=AE(C,[7,7],[2,2],"valid").as2D(C.shape[0],-1),e=eQ(E,w.fc.age).as1D(),t=eQ(E,w.fc.gender);return{age:e,gender:t}})},B.prototype.forwardInput=function(g){var Q=this;return FA(function(){var w=Q.runNet(g),C=w.age,E=w.gender;return{age:C,gender:aQ(E)}})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.predictAgeAndGender=function(g){return JA(this,void 0,void 0,function(){var Q,w,C,E,e,t,I=this;return mA(this,function(n){switch(n.label){case 0:return[4,qB(g)];case 1:return Q=n.sent(),[4,this.forwardInput(Q)];case 2:return w=n.sent(),C=SB(w.age),E=SB(w.gender),e=C.map(function(i,c){return{ageTensor:i,genderTensor:E[c]}}),[4,Promise.all(e.map(function(i){var c=i.ageTensor,Y=i.genderTensor;return JA(I,void 0,void 0,function(){var M,D,r,F,u;return mA(this,function(s){switch(s.label){case 0:return[4,c.data()];case 1:return M=s.sent()[0],[4,Y.data()];case 2:return D=s.sent()[0],r=D>.5,F=r?Qt.MALE:Qt.FEMALE,u=r?D:1-D,c.dispose(),Y.dispose(),[2,{age:M,gender:F,genderProbability:u}]}})})}))];case 3:return t=n.sent(),w.age.dispose(),w.gender.dispose(),[2,Q.isBatchInput?t:t[0]]}})})},B.prototype.getDefaultModelName=function(){return"age_gender_model"},B.prototype.dispose=function(g){g===void 0&&(g=!0),this.faceFeatureExtractor.dispose(g),A.prototype.dispose.call(this,g)},B.prototype.loadClassifierParams=function(g){var Q=this.extractClassifierParams(g),w=Q.params,C=Q.paramMappings;this._params=w,this._paramMappings=C},B.prototype.extractClassifierParams=function(g){return vv(g)},B.prototype.extractParamsFromWeigthMap=function(g){var Q=OD(g),w=Q.featureExtractorMap,C=Q.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(w),kv(C)},B.prototype.extractParams=function(g){var Q=1539,w=g.slice(0,g.length-Q),C=g.slice(g.length-Q);return this.faceFeatureExtractor.extractWeights(w),this.extractClassifierParams(C)},B}(lQ),Aa=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.postProcess=function(g,Q,w){var C=w.map(function(e){var t=e.width,I=e.height,n=Q/Math.max(I,t);return{width:t*n,height:I*n}}),E=C.length;return FA(function(){var e=function(c,Y){return Jg([QQ([68],c),QQ([68],Y)],1).as2D(1,136).as1D()},t=function(c,Y){var M=C[c],D=M.width,r=M.height;return Y(D,r)?Math.abs(D-r)/2:0},I=function(c){return t(c,function(Y,M){return Y<M})},n=function(c){return t(c,function(Y,M){return M<Y})},i=g.mul(QQ([E,136],Q)).sub(Jg(Array.from(Array(E),function(c,Y){return e(I(Y),n(Y))}))).div(Jg(Array.from(Array(E),function(c,Y){return e(C[Y].width,C[Y].height)})));return i})},B.prototype.forwardInput=function(g){var Q=this;return FA(function(){var w=Q.runNet(g);return Q.postProcess(w,g.inputSize,g.inputDimensions.map(function(C){var E=C[0],e=C[1];return{height:E,width:e}}))})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.detectLandmarks=function(g){return JA(this,void 0,void 0,function(){var Q,w,C,E=this;return mA(this,function(e){switch(e.label){case 0:return[4,qB(g)];case 1:return Q=e.sent(),w=FA(function(){return SB(E.forwardInput(Q))}),[4,Promise.all(w.map(function(t,I){return JA(E,void 0,void 0,function(){var n,i,c,Y,M;return mA(this,function(D){switch(D.label){case 0:return c=(i=Array).from,[4,t.data()];case 1:return n=c.apply(i,[D.sent()]),Y=n.filter(function(r,F){return HD(F)}),M=n.filter(function(r,F){return!HD(F)}),[2,new RD(Array(68).fill(0).map(function(r,F){return new iB(Y[F],M[F])}),{height:Q.getInputHeight(I),width:Q.getInputWidth(I)})]}})})}))];case 2:return C=e.sent(),w.forEach(function(t){return t.dispose()}),[2,Q.isBatchInput?C:C[0]]}})})},B.prototype.getClassifierChannelsOut=function(){return 136},B}(ZD),Ba=function(A){LA(B,A);function B(g){return g===void 0&&(g=new XD),A.call(this,"FaceLandmark68Net",g)||this}return B.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},B.prototype.getClassifierChannelsIn=function(){return 256},B}(Aa);function jv(A){var B=[],g=xD(A,B).extractDenseBlock3Params,Q={dense0:g("dense0",!0),dense1:g("dense1"),dense2:g("dense2")};return UQ(A,B),{params:Q,paramMappings:B}}function yv(A){var B=[],g=hQ(A),Q=g.extractWeights,w=g.getRemainingWeights,C=VD(Q,B).extractDenseBlock3Params,E=C(3,32,"dense0",!0),e=C(32,64,"dense1"),t=C(64,128,"dense2");if(w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{paramMappings:B,params:{dense0:E,dense1:e,dense2:t}}}var pv=function(A){LA(B,A);function B(){return A.call(this,"TinyFaceFeatureExtractor")||this}return B.prototype.forwardInput=function(g){var Q=this.params;if(!Q)throw new Error("TinyFaceFeatureExtractor - load model before inference");return FA(function(){var w=g.toBatchTensor(112,!0),C=[122.782,117.001,104.298],E=CE(w,C).div(YA(255)),e=dn(E,Q.dense0,!0);return e=dn(e,Q.dense1),e=dn(e,Q.dense2),e=AE(e,[14,14],[2,2],"valid"),e})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},B.prototype.extractParamsFromWeigthMap=function(g){return jv(g)},B.prototype.extractParams=function(g){return yv(g)},B}(lQ),zv=function(A){LA(B,A);function B(g){return g===void 0&&(g=new pv),A.call(this,"FaceLandmark68TinyNet",g)||this}return B.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},B.prototype.getClassifierChannelsIn=function(){return 128},B}(Aa);(function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B})(Ba);function Wv(A,B){return BB(og(A,B.weights),B.biases)}function Rn(A,B,g,Q,w){w===void 0&&(w="same");var C=B.conv,E=C.filters,e=C.bias,t=jg(A,E,g,w);return t=BB(t,e),t=Wv(t,B.scale),Q?JB(t):t}function bv(A,B){return Rn(A,B,[1,1],!0)}function ga(A,B){return Rn(A,B,[1,1],!1)}function Qa(A,B){return Rn(A,B,[2,2],!0,"valid")}function Sv(A,B){function g(e,t,I){var n=A(e),i=n.length/(t*I*I);if(qP(i))throw new Error("depth has to be an integer: "+i+", weights.length: "+n.length+", numFilters: "+t+", filterSize: "+I);return FA(function(){return kQ(sg(n,[t,i,I,I]),[2,3,1,0])})}function Q(e,t,I,n){var i=g(e,t,I),c=yB(A(t));return B.push({paramPath:n+"/filters"},{paramPath:n+"/bias"}),{filters:i,bias:c}}function w(e,t){var I=yB(A(e)),n=yB(A(e));return B.push({paramPath:t+"/weights"},{paramPath:t+"/biases"}),{weights:I,biases:n}}function C(e,t,I,n){var i=Q(e,t,I,n+"/conv"),c=w(t,n+"/scale");return{conv:i,scale:c}}function E(e,t,I,n,i){i===void 0&&(i=!1);var c=C((i?.5:1)*e,t,I,n+"/conv1"),Y=C(e,t,I,n+"/conv2");return{conv1:c,conv2:Y}}return{extractConvLayerParams:C,extractResidualLayerParams:E}}function Lv(A){var B=hQ(A),g=B.extractWeights,Q=B.getRemainingWeights,w=[],C=Sv(g,w),E=C.extractConvLayerParams,e=C.extractResidualLayerParams,t=E(4704,32,7,"conv32_down"),I=e(9216,32,3,"conv32_1"),n=e(9216,32,3,"conv32_2"),i=e(9216,32,3,"conv32_3"),c=e(36864,64,3,"conv64_down",!0),Y=e(36864,64,3,"conv64_1"),M=e(36864,64,3,"conv64_2"),D=e(36864,64,3,"conv64_3"),r=e(147456,128,3,"conv128_down",!0),F=e(147456,128,3,"conv128_1"),u=e(147456,128,3,"conv128_2"),s=e(589824,256,3,"conv256_down",!0),a=e(589824,256,3,"conv256_1"),l=e(589824,256,3,"conv256_2"),U=e(589824,256,3,"conv256_down_out"),G=FA(function(){return kQ(PQ(g(256*128),[128,256]),[1,0])});if(w.push({paramPath:"fc"}),Q().length!==0)throw new Error("weights remaing after extract: "+Q().length);var d={conv32_down:t,conv32_1:I,conv32_2:n,conv32_3:i,conv64_down:c,conv64_1:Y,conv64_2:M,conv64_3:D,conv128_down:r,conv128_1:F,conv128_2:u,conv256_down:s,conv256_1:a,conv256_2:l,conv256_down_out:U,fc:G};return{params:d,paramMappings:w}}function Vv(A,B){var g=zQ(A,B);function Q(E){var e=g(E+"/scale/weights",1),t=g(E+"/scale/biases",1);return{weights:e,biases:t}}function w(E){var e=g(E+"/conv/filters",4),t=g(E+"/conv/bias",1),I=Q(E);return{conv:{filters:e,bias:t},scale:I}}function C(E){return{conv1:w(E+"/conv1"),conv2:w(E+"/conv2")}}return{extractConvLayerParams:w,extractResidualLayerParams:C}}function Kv(A){var B=[],g=Vv(A,B),Q=g.extractConvLayerParams,w=g.extractResidualLayerParams,C=Q("conv32_down"),E=w("conv32_1"),e=w("conv32_2"),t=w("conv32_3"),I=w("conv64_down"),n=w("conv64_1"),i=w("conv64_2"),c=w("conv64_3"),Y=w("conv128_down"),M=w("conv128_1"),D=w("conv128_2"),r=w("conv256_down"),F=w("conv256_1"),u=w("conv256_2"),s=w("conv256_down_out"),a=A.fc;if(B.push({originalPath:"fc",paramPath:"fc"}),!ZP(a))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+a);var l={conv32_down:C,conv32_1:E,conv32_2:e,conv32_3:t,conv64_down:I,conv64_1:n,conv64_2:i,conv64_3:c,conv128_down:Y,conv128_1:M,conv128_2:D,conv256_down:r,conv256_1:F,conv256_2:u,conv256_down_out:s,fc:a};return UQ(A,B),{params:l,paramMappings:B}}function tQ(A,B){var g=bv(A,B.conv1);return g=ga(g,B.conv2),g=BB(g,A),g=JB(g),g}function wt(A,B){var g=Qa(A,B.conv1);g=ga(g,B.conv2);var Q=AE(A,2,2,"valid"),w=GB(Q.shape),C=Q.shape[3]!==g.shape[3],E=Q.shape[1]!==g.shape[1]||Q.shape[2]!==g.shape[2];if(E){var e=gE(g.shape);e[1]=1;var t=GB(e);g=bB([g,t],1);var I=gE(g.shape);I[2]=1;var n=GB(I);g=bB([g,n],2)}return Q=C?bB([Q,w],3):Q,g=BB(Q,g),g=JB(g),g}var xv=function(A){LA(B,A);function B(){return A.call(this,"FaceRecognitionNet")||this}return B.prototype.forwardInput=function(g){var Q=this.params;if(!Q)throw new Error("FaceRecognitionNet - load model before inference");return FA(function(){var w=g.toBatchTensor(150,!0).toFloat(),C=[122.782,117.001,104.298],E=CE(w,C).div(YA(256)),e=Qa(E,Q.conv32_down);e=ZB(e,3,2,"valid"),e=tQ(e,Q.conv32_1),e=tQ(e,Q.conv32_2),e=tQ(e,Q.conv32_3),e=wt(e,Q.conv64_down),e=tQ(e,Q.conv64_1),e=tQ(e,Q.conv64_2),e=tQ(e,Q.conv64_3),e=wt(e,Q.conv128_down),e=tQ(e,Q.conv128_1),e=tQ(e,Q.conv128_2),e=wt(e,Q.conv256_down),e=tQ(e,Q.conv256_1),e=tQ(e,Q.conv256_2),e=wt(e,Q.conv256_down_out);var t=e.mean([1,2]),I=ye(t,Q.fc);return I})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.computeFaceDescriptor=function(g){return JA(this,void 0,void 0,function(){var Q,w,C,E=this;return mA(this,function(e){switch(e.label){case 0:return[4,qB(g)];case 1:return Q=e.sent(),w=FA(function(){return SB(E.forwardInput(Q))}),[4,Promise.all(w.map(function(t){return t.data()}))];case 2:return C=e.sent(),w.forEach(function(t){return t.dispose()}),[2,Q.isBatchInput?C:C[0]]}})})},B.prototype.getDefaultModelName=function(){return"face_recognition_model"},B.prototype.extractParamsFromWeigthMap=function(g){return Kv(g)},B.prototype.extractParams=function(g){return Lv(g)},B}(lQ);function wa(A,B){var g={descriptor:B};return Object.assign({},A,g)}function Ca(A,B){var g={age:B};return Object.assign({},A,g)}function Ea(A,B,g){var Q={gender:B,genderProbability:g};return Object.assign({},A,Q)}var ea=function(){function A(B){var g=B===void 0?{}:B,Q=g.minFaceSize,w=g.scaleFactor,C=g.maxNumScales,E=g.scoreThresholds,e=g.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=Q||20,this._scaleFactor=w||.709,this._maxNumScales=C||10,this._scoreThresholds=E||[.6,.7,.7],this._scaleSteps=e,typeof this._minFaceSize!="number"||this._minFaceSize<0)throw new Error(this._name+" - expected minFaceSize to be a number > 0");if(typeof this._scaleFactor!="number"||this._scaleFactor<=0||this._scaleFactor>=1)throw new Error(this._name+" - expected scaleFactor to be a number between 0 and 1");if(typeof this._maxNumScales!="number"||this._maxNumScales<0)throw new Error(this._name+" - expected maxNumScales to be a number > 0");if(!Array.isArray(this._scoreThresholds)||this._scoreThresholds.length!==3||this._scoreThresholds.some(function(t){return typeof t!="number"}))throw new Error(this._name+" - expected scoreThresholds to be an array of numbers of length 3");if(this._scaleSteps&&(!Array.isArray(this._scaleSteps)||this._scaleSteps.some(function(t){return typeof t!="number"})))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(A.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),A}();function Xv(A,B){function g(t,I){var n=sg(A(9*t),[3,3,t,1]),i=yB(A(t)),c=yB(A(t)),Y=yB(A(t)),M=yB(A(t));return B.push({paramPath:I+"/filters"},{paramPath:I+"/batch_norm_scale"},{paramPath:I+"/batch_norm_offset"},{paramPath:I+"/batch_norm_mean"},{paramPath:I+"/batch_norm_variance"}),{filters:n,batch_norm_scale:i,batch_norm_offset:c,batch_norm_mean:Y,batch_norm_variance:M}}function Q(t,I,n,i,c){var Y=sg(A(t*I*n*n),[n,n,t,I]),M=yB(A(I));return B.push({paramPath:i+"/filters"},{paramPath:i+"/"+(c?"batch_norm_offset":"bias")}),{filters:Y,bias:M}}function w(t,I,n,i){var c=Q(t,I,n,i,!0),Y=c.filters,M=c.bias;return{filters:Y,batch_norm_offset:M}}function C(t,I,n){var i=g(t,n+"/depthwise_conv"),c=w(t,I,1,n+"/pointwise_conv");return{depthwise_conv:i,pointwise_conv:c}}function E(){var t=w(3,32,3,"mobilenetv1/conv_0"),I=C(32,64,"mobilenetv1/conv_1"),n=C(64,128,"mobilenetv1/conv_2"),i=C(128,128,"mobilenetv1/conv_3"),c=C(128,256,"mobilenetv1/conv_4"),Y=C(256,256,"mobilenetv1/conv_5"),M=C(256,512,"mobilenetv1/conv_6"),D=C(512,512,"mobilenetv1/conv_7"),r=C(512,512,"mobilenetv1/conv_8"),F=C(512,512,"mobilenetv1/conv_9"),u=C(512,512,"mobilenetv1/conv_10"),s=C(512,512,"mobilenetv1/conv_11"),a=C(512,1024,"mobilenetv1/conv_12"),l=C(1024,1024,"mobilenetv1/conv_13");return{conv_0:t,conv_1:I,conv_2:n,conv_3:i,conv_4:c,conv_5:Y,conv_6:M,conv_7:D,conv_8:r,conv_9:F,conv_10:u,conv_11:s,conv_12:a,conv_13:l}}function e(){var t=w(1024,256,1,"prediction_layer/conv_0"),I=w(256,512,3,"prediction_layer/conv_1"),n=w(512,128,1,"prediction_layer/conv_2"),i=w(128,256,3,"prediction_layer/conv_3"),c=w(256,128,1,"prediction_layer/conv_4"),Y=w(128,256,3,"prediction_layer/conv_5"),M=w(256,64,1,"prediction_layer/conv_6"),D=w(64,128,3,"prediction_layer/conv_7"),r=Q(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),F=Q(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),u=Q(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),s=Q(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),a=Q(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),l=Q(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),U=Q(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),G=Q(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),d=Q(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),H=Q(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),h=Q(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),f=Q(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),J={box_encoding_predictor:r,class_predictor:F},y={box_encoding_predictor:u,class_predictor:s},m={box_encoding_predictor:a,class_predictor:l},k={box_encoding_predictor:U,class_predictor:G},z={box_encoding_predictor:d,class_predictor:H},R={box_encoding_predictor:h,class_predictor:f};return{conv_0:t,conv_1:I,conv_2:n,conv_3:i,conv_4:c,conv_5:Y,conv_6:M,conv_7:D,box_predictor_0:J,box_predictor_1:y,box_predictor_2:m,box_predictor_3:k,box_predictor_4:z,box_predictor_5:R}}return{extractMobilenetV1Params:E,extractPredictionLayerParams:e}}function Ov(A){var B=[],g=hQ(A),Q=g.extractWeights,w=g.getRemainingWeights,C=Xv(Q,B),E=C.extractMobilenetV1Params,e=C.extractPredictionLayerParams,t=E(),I=e(),n=FI(Q(5118*4),[1,5118,4]),i={extra_dim:n};if(B.push({paramPath:"output_layer/extra_dim"}),w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{params:{mobilenetv1:t,prediction_layer:I,output_layer:i},paramMappings:B}}function Zv(A,B){var g=zQ(A,B);function Q(I,n,i){var c=g(I+"/Conv2d_"+n+"_pointwise/weights",4,i+"/filters"),Y=g(I+"/Conv2d_"+n+"_pointwise/convolution_bn_offset",1,i+"/batch_norm_offset");return{filters:c,batch_norm_offset:Y}}function w(I){var n="mobilenetv1/conv_"+I,i="MobilenetV1/Conv2d_"+I+"_depthwise",c=n+"/depthwise_conv",Y=n+"/pointwise_conv",M=g(i+"/depthwise_weights",4,c+"/filters"),D=g(i+"/BatchNorm/gamma",1,c+"/batch_norm_scale"),r=g(i+"/BatchNorm/beta",1,c+"/batch_norm_offset"),F=g(i+"/BatchNorm/moving_mean",1,c+"/batch_norm_mean"),u=g(i+"/BatchNorm/moving_variance",1,c+"/batch_norm_variance");return{depthwise_conv:{filters:M,batch_norm_scale:D,batch_norm_offset:r,batch_norm_mean:F,batch_norm_variance:u},pointwise_conv:Q("MobilenetV1",I,Y)}}function C(){return{conv_0:Q("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:w(1),conv_2:w(2),conv_3:w(3),conv_4:w(4),conv_5:w(5),conv_6:w(6),conv_7:w(7),conv_8:w(8),conv_9:w(9),conv_10:w(10),conv_11:w(11),conv_12:w(12),conv_13:w(13)}}function E(I,n){var i=g(I+"/weights",4,n+"/filters"),c=g(I+"/biases",1,n+"/bias");return{filters:i,bias:c}}function e(I){var n=E("Prediction/BoxPredictor_"+I+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+I+"/box_encoding_predictor"),i=E("Prediction/BoxPredictor_"+I+"/ClassPredictor","prediction_layer/box_predictor_"+I+"/class_predictor");return{box_encoding_predictor:n,class_predictor:i}}function t(){return{conv_0:Q("Prediction",0,"prediction_layer/conv_0"),conv_1:Q("Prediction",1,"prediction_layer/conv_1"),conv_2:Q("Prediction",2,"prediction_layer/conv_2"),conv_3:Q("Prediction",3,"prediction_layer/conv_3"),conv_4:Q("Prediction",4,"prediction_layer/conv_4"),conv_5:Q("Prediction",5,"prediction_layer/conv_5"),conv_6:Q("Prediction",6,"prediction_layer/conv_6"),conv_7:Q("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:e(0),box_predictor_1:e(1),box_predictor_2:e(2),box_predictor_3:e(3),box_predictor_4:e(4),box_predictor_5:e(5)}}return{extractMobilenetV1Params:C,extractPredictionLayerParams:t}}function qv(A){var B=[],g=Zv(A,B),Q=g.extractMobilenetV1Params,w=g.extractPredictionLayerParams,C=A["Output/extra_dim"];if(B.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!Ve(C))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+C);var E={mobilenetv1:Q(),prediction_layer:w(),output_layer:{extra_dim:C}};return UQ(A,B),{params:E,paramMappings:B}}function oQ(A,B,g){return FA(function(){var Q=jg(A,B.filters,g,"same");return Q=BB(Q,B.batch_norm_offset),WI(Q,0,6)})}var _v=.0010000000474974513;function $v(A,B,g){return FA(function(){var Q=je(A,B.filters,g,"same");return Q=Rr(Q,B.batch_norm_mean,B.batch_norm_variance,B.batch_norm_offset,B.batch_norm_scale,_v),WI(Q,0,6)})}function A4(A){return[2,4,6,12].some(function(B){return B===A})?[2,2]:[1,1]}function B4(A,B){return FA(function(){var g=null,Q=oQ(A,B.conv_0,[2,2]),w=[B.conv_1,B.conv_2,B.conv_3,B.conv_4,B.conv_5,B.conv_6,B.conv_7,B.conv_8,B.conv_9,B.conv_10,B.conv_11,B.conv_12,B.conv_13];if(w.forEach(function(C,E){var e=E+1,t=A4(e);Q=$v(Q,C.depthwise_conv,t),Q=oQ(Q,C.pointwise_conv,[1,1]),e===11&&(g=Q)}),g===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:Q,conv11:g}})}function g4(A,B,g,Q,w){var C=A.shape[0],E=Math.min(g,C),e=B.map(function(n,i){return{score:n,boxIndex:i}}).filter(function(n){return n.score>w}).sort(function(n,i){return i.score-n.score}),t=function(n){return n<=Q?1:0},I=[];return e.forEach(function(n){if(!(I.length>=E)){for(var i=n.score,c=I.length-1;c>=0;--c){var Y=Q4(A,n.boxIndex,I[c]);if(Y!==0&&(n.score*=t(Y),n.score<=w))break}i===n.score&&I.push(n.boxIndex)}}),I}function Q4(A,B,g){var Q=A.arraySync(),w=Math.min(Q[B][0],Q[B][2]),C=Math.min(Q[B][1],Q[B][3]),E=Math.max(Q[B][0],Q[B][2]),e=Math.max(Q[B][1],Q[B][3]),t=Math.min(Q[g][0],Q[g][2]),I=Math.min(Q[g][1],Q[g][3]),n=Math.max(Q[g][0],Q[g][2]),i=Math.max(Q[g][1],Q[g][3]),c=(E-w)*(e-C),Y=(n-t)*(i-I);if(c<=0||Y<=0)return 0;var M=Math.max(w,t),D=Math.max(C,I),r=Math.min(E,n),F=Math.min(e,i),u=Math.max(r-M,0)*Math.max(F-D,0);return u/(c+Y-u)}function w4(A){var B=SB(kQ(A,[1,0])),g=[VB(B[2],B[0]),VB(B[3],B[1])],Q=[BB(B[0],Lg(g[0],YA(2))),BB(B[1],Lg(g[1],YA(2)))];return{sizes:g,centers:Q}}function C4(A,B){var g=w4(A),Q=g.sizes,w=g.centers,C=SB(kQ(B,[1,0])),E=Lg(og(bI(Lg(C[2],YA(5))),Q[0]),YA(2)),e=BB(og(Lg(C[0],YA(10)),Q[0]),w[0]),t=Lg(og(bI(Lg(C[3],YA(5))),Q[1]),YA(2)),I=BB(og(Lg(C[1],YA(10)),Q[1]),w[1]);return kQ(Jg([VB(e,E),VB(I,t),BB(e,E),BB(I,t)]),[1,0])}function E4(A,B,g){return FA(function(){var Q=A.shape[0],w=C4(bg(Zw(g.extra_dim,[Q,1,1]),[-1,4]),bg(A,[-1,4]));w=bg(w,[Q,w.shape[0]/Q,4]);var C=fr(wQ(B,[0,0,1],[-1,-1,-1])),E=wQ(C,[0,0,0],[-1,-1,1]);E=bg(E,[Q,E.shape[1]]);var e=SB(w),t=SB(E);return{boxes:e,scores:t}})}function IC(A,B){return FA(function(){var g=A.shape[0],Q=bg(Vg(A,B.box_encoding_predictor),[g,-1,1,4]),w=bg(Vg(A,B.class_predictor),[g,-1,3]);return{boxPredictionEncoding:Q,classPrediction:w}})}function e4(A,B,g){return FA(function(){var Q=oQ(A,g.conv_0,[1,1]),w=oQ(Q,g.conv_1,[2,2]),C=oQ(w,g.conv_2,[1,1]),E=oQ(C,g.conv_3,[2,2]),e=oQ(E,g.conv_4,[1,1]),t=oQ(e,g.conv_5,[2,2]),I=oQ(t,g.conv_6,[1,1]),n=oQ(I,g.conv_7,[2,2]),i=IC(B,g.box_predictor_0),c=IC(A,g.box_predictor_1),Y=IC(w,g.box_predictor_2),M=IC(E,g.box_predictor_3),D=IC(t,g.box_predictor_4),r=IC(n,g.box_predictor_5),F=bB([i.boxPredictionEncoding,c.boxPredictionEncoding,Y.boxPredictionEncoding,M.boxPredictionEncoding,D.boxPredictionEncoding,r.boxPredictionEncoding],1),u=bB([i.classPrediction,c.classPrediction,Y.classPrediction,M.classPrediction,D.classPrediction,r.classPrediction],1);return{boxPredictions:F,classPredictions:u}})}var Ct=function(){function A(B){var g=B===void 0?{}:B,Q=g.minConfidence,w=g.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=Q||.5,this._maxResults=w||100,typeof this._minConfidence!="number"||this._minConfidence<=0||this._minConfidence>=1)throw new Error(this._name+" - expected minConfidence to be a number between 0 and 1");if(typeof this._maxResults!="number")throw new Error(this._name+" - expected maxResults to be a number")}return Object.defineProperty(A.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),A}(),ta=function(A){LA(B,A);function B(){return A.call(this,"SsdMobilenetv1")||this}return B.prototype.forwardInput=function(g){var Q=this.params;if(!Q)throw new Error("SsdMobilenetv1 - load model before inference");return FA(function(){var w=g.toBatchTensor(512,!1).toFloat(),C=VB(og(w,YA(.007843137718737125)),YA(1)),E=B4(C,Q.mobilenetv1),e=e4(E.out,E.conv11,Q.prediction_layer),t=e.boxPredictions,I=e.classPredictions;return E4(t,I,Q.output_layer)})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.locateFaces=function(g,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,t,I,n,i,c,Y,M,D,r,F,u,s,a,l,U,G,d;return mA(this,function(H){switch(H.label){case 0:return w=new Ct(Q),C=w.maxResults,E=w.minConfidence,[4,qB(g)];case 1:for(e=H.sent(),t=this.forwardInput(e),I=t.boxes,n=t.scores,i=I[0],c=n[0],Y=1;Y<I.length;Y++)I[Y].dispose(),n[Y].dispose();return r=(D=Array).from,[4,c.data()];case 2:return M=r.apply(D,[H.sent()]),F=.5,u=g4(i,M,C,F,E),s=e.getReshapedInputDimensions(0),a=e.inputSize,l=a/s.width,U=a/s.height,G=i.arraySync(),d=u.map(function(h){var f=[Math.max(0,G[h][0]),Math.min(1,G[h][2])].map(function(R){return R*U}),J=f[0],y=f[1],m=[Math.max(0,G[h][1]),Math.min(1,G[h][3])].map(function(R){return R*l}),k=m[0],z=m[1];return new Ng(M[h],new xe(k,J,z-k,y-J),{height:e.getInputHeight(0),width:e.getInputWidth(0)})}),i.dispose(),c.dispose(),[2,d]}})})},B.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},B.prototype.extractParamsFromWeigthMap=function(g){return qv(g)},B.prototype.extractParams=function(g){return Ov(g)},B}(lQ);(function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B})(ta);var t4=.4,o4=[new iB(.738768,.874946),new iB(2.42204,2.65704),new iB(4.30971,7.04493),new iB(10.246,4.59428),new iB(12.6868,11.8741)],I4=[new iB(1.603231,2.094468),new iB(6.041143,7.080126),new iB(2.882459,3.518061),new iB(4.266906,5.178857),new iB(9.041765,10.66308)],n4=[117.001,114.697,97.404],i4="tiny_yolov2_model",c4="tiny_yolov2_separable_conv_model",Et=function(A){return typeof A=="number"};function Y4(A){if(!A)throw new Error("invalid config: "+A);if(typeof A.withSeparableConvs!="boolean")throw new Error("config.withSeparableConvs has to be a boolean, have: "+A.withSeparableConvs);if(!Et(A.iouThreshold)||A.iouThreshold<0||A.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+A.iouThreshold);if(!Array.isArray(A.classes)||!A.classes.length||!A.classes.every(function(B){return typeof B=="string"}))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(A.classes));if(!Array.isArray(A.anchors)||!A.anchors.length||!A.anchors.map(function(B){return B||{}}).every(function(B){return Et(B.x)&&Et(B.y)}))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(A.anchors));if(A.meanRgb&&(!Array.isArray(A.meanRgb)||A.meanRgb.length!==3||!A.meanRgb.every(Et)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(A.meanRgb))}function Pn(A){return FA(function(){var B=og(A,YA(.10000000149011612));return BB(JB(VB(A,B)),B)})}function WQ(A,B){return FA(function(){var g=tw(A,[[0,0],[1,1],[1,1],[0,0]]);return g=jg(g,B.conv.filters,[1,1],"valid"),g=VB(g,B.bn.sub),g=og(g,B.bn.truediv),g=BB(g,B.conv.bias),Pn(g)})}function bQ(A,B){return FA(function(){var g=tw(A,[[0,0],[1,1],[1,1],[0,0]]);return g=xI(g,B.depthwise_filter,B.pointwise_filter,[1,1],"valid"),g=BB(g,B.bias),Pn(g)})}function M4(A,B){var g=Bt(A,B);function Q(E,e){var t=yB(A(E)),I=yB(A(E));return B.push({paramPath:e+"/sub"},{paramPath:e+"/truediv"}),{sub:t,truediv:I}}function w(E,e,t){var I=g(E,e,3,t+"/conv"),n=Q(e,t+"/bn");return{conv:I,bn:n}}var C=fn(A,B);return{extractConvParams:g,extractConvWithBatchNormParams:w,extractSeparableConvParams:C}}function r4(A,B,g,Q){var w=hQ(A),C=w.extractWeights,E=w.getRemainingWeights,e=[],t=M4(C,e),I=t.extractConvParams,n=t.extractConvWithBatchNormParams,i=t.extractSeparableConvParams,c;if(B.withSeparableConvs){var Y=Q[0],M=Q[1],D=Q[2],r=Q[3],F=Q[4],u=Q[5],s=Q[6],a=Q[7],l=Q[8],U=B.isFirstLayerConv2d?I(Y,M,3,"conv0"):i(Y,M,"conv0"),G=i(M,D,"conv1"),d=i(D,r,"conv2"),H=i(r,F,"conv3"),h=i(F,u,"conv4"),f=i(u,s,"conv5"),J=a?i(s,a,"conv6"):void 0,y=l?i(a,l,"conv7"):void 0,m=I(l||a||s,5*g,1,"conv8");c={conv0:U,conv1:G,conv2:d,conv3:H,conv4:h,conv5:f,conv6:J,conv7:y,conv8:m}}else{var Y=Q[0],M=Q[1],D=Q[2],r=Q[3],F=Q[4],u=Q[5],s=Q[6],a=Q[7],l=Q[8],U=n(Y,M,"conv0"),G=n(M,D,"conv1"),d=n(D,r,"conv2"),H=n(r,F,"conv3"),h=n(F,u,"conv4"),f=n(u,s,"conv5"),J=n(s,a,"conv6"),y=n(a,l,"conv7"),m=I(l,5*g,1,"conv8");c={conv0:U,conv1:G,conv2:d,conv3:H,conv4:h,conv5:f,conv6:J,conv7:y,conv8:m}}if(E().length!==0)throw new Error("weights remaing after extract: "+E().length);return{params:c,paramMappings:e}}function D4(A,B){var g=zQ(A,B);function Q(e){var t=g(e+"/sub",1),I=g(e+"/truediv",1);return{sub:t,truediv:I}}function w(e){var t=g(e+"/filters",4),I=g(e+"/bias",1);return{filters:t,bias:I}}function C(e){var t=w(e+"/conv"),I=Q(e+"/bn");return{conv:t,bn:I}}var E=Jn(g);return{extractConvParams:w,extractConvWithBatchNormParams:C,extractSeparableConvParams:E}}function a4(A,B){var g=[],Q=D4(A,g),w=Q.extractConvParams,C=Q.extractConvWithBatchNormParams,E=Q.extractSeparableConvParams,e;if(B.withSeparableConvs){var t=B.filterSizes&&B.filterSizes.length||9;e={conv0:B.isFirstLayerConv2d?w("conv0"):E("conv0"),conv1:E("conv1"),conv2:E("conv2"),conv3:E("conv3"),conv4:E("conv4"),conv5:E("conv5"),conv6:t>7?E("conv6"):void 0,conv7:t>8?E("conv7"):void 0,conv8:w("conv8")}}else e={conv0:C("conv0"),conv1:C("conv1"),conv2:C("conv2"),conv3:C("conv3"),conv4:C("conv4"),conv5:C("conv5"),conv6:C("conv6"),conv7:C("conv7"),conv8:w("conv8")};return UQ(A,g),{params:e,paramMappings:g}}var oa;(function(A){A[A.XS=224]="XS",A[A.SM=320]="SM",A[A.MD=416]="MD",A[A.LG=608]="LG"})(oa||(oa={}));var vn=function(){function A(B){var g=B===void 0?{}:B,Q=g.inputSize,w=g.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=Q||416,this._scoreThreshold=w||.5,typeof this._inputSize!="number"||this._inputSize%32!==0)throw new Error(this._name+" - expected inputSize to be a number divisible by 32");if(typeof this._scoreThreshold!="number"||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(this._name+" - expected scoreThreshold to be a number between 0 and 1")}return Object.defineProperty(A.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),A}(),Ia=function(A){LA(B,A);function B(g){var Q=A.call(this,"TinyYolov2")||this;return Y4(g),Q._config=g,Q}return Object.defineProperty(B.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(B.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(B.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),B.prototype.runTinyYolov2=function(g,Q){var w=WQ(g,Q.conv0);return w=ZB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv1),w=ZB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv2),w=ZB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv3),w=ZB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv4),w=ZB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv5),w=ZB(w,[2,2],[1,1],"same"),w=WQ(w,Q.conv6),w=WQ(w,Q.conv7),Vg(w,Q.conv8,"valid",!1)},B.prototype.runMobilenet=function(g,Q){var w=this.config.isFirstLayerConv2d?Pn(Vg(g,Q.conv0,"valid",!1)):bQ(g,Q.conv0);return w=ZB(w,[2,2],[2,2],"same"),w=bQ(w,Q.conv1),w=ZB(w,[2,2],[2,2],"same"),w=bQ(w,Q.conv2),w=ZB(w,[2,2],[2,2],"same"),w=bQ(w,Q.conv3),w=ZB(w,[2,2],[2,2],"same"),w=bQ(w,Q.conv4),w=ZB(w,[2,2],[2,2],"same"),w=bQ(w,Q.conv5),w=ZB(w,[2,2],[1,1],"same"),w=Q.conv6?bQ(w,Q.conv6):w,w=Q.conv7?bQ(w,Q.conv7):w,Vg(w,Q.conv8,"valid",!1)},B.prototype.forwardInput=function(g,Q){var w=this,C=this.params;if(!C)throw new Error("TinyYolov2 - load model before inference");return FA(function(){var E=g.toBatchTensor(Q,!1).toFloat();return E=w.config.meanRgb?CE(E,w.config.meanRgb):E,E=E.div(YA(256)),w.config.withSeparableConvs?w.runMobilenet(E,C):w.runTinyYolov2(E,C)})},B.prototype.forward=function(g,Q){return JA(this,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return w=this.forwardInput,[4,qB(g)];case 1:return[4,w.apply(this,[C.sent(),Q])];case 2:return[2,C.sent()]}})})},B.prototype.detect=function(g,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,t,I,n,i,c,Y,M,D,r,F,u=this;return mA(this,function(s){switch(s.label){case 0:return w=new vn(Q),C=w.inputSize,E=w.scoreThreshold,[4,qB(g)];case 1:return e=s.sent(),[4,this.forwardInput(e,C)];case 2:return t=s.sent(),I=FA(function(){return SB(t)[0].expandDims()}),n={width:e.getInputWidth(0),height:e.getInputHeight(0)},[4,this.extractBoxes(I,e.getReshapedInputDimensions(0),E)];case 3:return i=s.sent(),t.dispose(),I.dispose(),c=i.map(function(a){return a.box}),Y=i.map(function(a){return a.score}),M=i.map(function(a){return a.classScore}),D=i.map(function(a){return u.config.classes[a.label]}),r=wE(c.map(function(a){return a.rescale(C)}),Y,this.config.iouThreshold,!0),F=r.map(function(a){return new ND(Y[a],M[a],D[a],c[a],n)}),[2,F]}})})},B.prototype.getDefaultModelName=function(){return""},B.prototype.extractParamsFromWeigthMap=function(g){return a4(g,this.config)},B.prototype.extractParams=function(g){var Q=this.config.filterSizes||B.DEFAULT_FILTER_SIZES,w=Q?Q.length:void 0;if(w!==7&&w!==8&&w!==9)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+w+" filterSizes in config");return r4(g,this.config,this.boxEncodingSize,Q)},B.prototype.extractBoxes=function(g,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,t,I,n,i,c,Y,M,D,r,F,u,s,a,l,U,G,d,H,h,f,J,y,m,k,z,R,v=this;return mA(this,function(S){switch(S.label){case 0:return C=Q.width,E=Q.height,e=Math.max(C,E),t=e/C,I=e/E,n=g.shape[1],i=this.config.anchors.length,c=FA(function(){var x=g.reshape([n,n,i,v.boxEncodingSize]),j=x.slice([0,0,0,0],[n,n,i,4]),p=x.slice([0,0,0,4],[n,n,i,1]),K=v.withClassScores?aQ(x.slice([0,0,0,5],[n,n,i,v.config.classes.length]),3):YA(0);return[j,p,K]}),Y=c[0],M=c[1],D=c[2],r=[],[4,M.array()];case 1:return F=S.sent(),[4,Y.array()];case 2:u=S.sent(),s=0,S.label=3;case 3:if(!(s<n))return[3,12];a=0,S.label=4;case 4:if(!(a<n))return[3,11];l=0,S.label=5;case 5:return l<i?(U=sn(F[s][a][l][0]),!w||U>w?(G=(a+sn(u[s][a][l][0]))/n*t,d=(s+sn(u[s][a][l][1]))/n*I,H=Math.exp(u[s][a][l][2])*this.config.anchors[l].x/n*t,h=Math.exp(u[s][a][l][3])*this.config.anchors[l].y/n*I,f=G-H/2,J=d-h/2,y={row:s,col:a,anchor:l},this.withClassScores?[4,this.extractPredictedClass(D,y)]:[3,7]):[3,9]):[3,10];case 6:return R=S.sent(),[3,8];case 7:R={classScore:1,label:0},S.label=8;case 8:m=R,k=m.classScore,z=m.label,r.push(ng({box:new Ke(f,J,f+H,J+h),score:U,classScore:U*k,label:z},y)),S.label=9;case 9:return l++,[3,5];case 10:return a++,[3,4];case 11:return s++,[3,3];case 12:return Y.dispose(),M.dispose(),D.dispose(),[2,r]}})})},B.prototype.extractPredictedClass=function(g,Q){return JA(this,void 0,void 0,function(){var w,C,E,e;return mA(this,function(t){switch(t.label){case 0:return w=Q.row,C=Q.col,E=Q.anchor,[4,g.array()];case 1:return e=t.sent(),[2,Array(this.config.classes.length).fill(0).map(function(I,n){return e[w][C][E][n]}).map(function(I,n){return{classScore:I,label:n}}).reduce(function(I,n){return I.classScore>n.classScore?I:n})]}})})},B.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],B}(lQ),F4=function(A){LA(B,A);function B(g){g===void 0&&(g=!0);var Q=this,w=Object.assign({},{withSeparableConvs:g,iouThreshold:t4,classes:["face"]},g?{anchors:I4,meanRgb:n4}:{anchors:o4,withClassScores:!0});return Q=A.call(this,w)||this,Q}return Object.defineProperty(B.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(B.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),B.prototype.locateFaces=function(g,Q){return JA(this,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return[4,this.detect(g,Q)];case 1:return w=C.sent(),[2,w.map(function(E){return new Ng(E.score,E.relativeBox,{width:E.imageWidth,height:E.imageHeight})})]}})})},B.prototype.getDefaultModelName=function(){return this.withSeparableConvs?c4:i4},B.prototype.extractParamsFromWeigthMap=function(g){return A.prototype.extractParamsFromWeigthMap.call(this,g)},B}(Ia),na=function(A){LA(B,A);function B(){var g=A!==null&&A.apply(this,arguments)||this;return g._name="TinyFaceDetectorOptions",g}return B}(vn),eE=function(){function A(){}return A.prototype.then=function(B){return JA(this,void 0,void 0,function(){var g;return mA(this,function(Q){switch(Q.label){case 0:return g=B,[4,this.run()];case 1:return[2,g.apply(void 0,[Q.sent()])]}})})},A.prototype.run=function(){return JA(this,void 0,void 0,function(){return mA(this,function(B){throw new Error("ComposableTask - run is not implemented")})})},A}();function et(A,B,g,Q,w){return w===void 0&&(w=function(C){var E=C.alignedRect;return E}),JA(this,void 0,void 0,function(){var C,E,e,t,I;return mA(this,function(n){switch(n.label){case 0:return C=A.map(function(i){return mn(i)?w(i):i.detection}),e=Q,e?[3,5]:B instanceof HB?[4,Gn(B,C)]:[3,2];case 1:return t=n.sent(),[3,4];case 2:return[4,$e(B,C)];case 3:t=n.sent(),n.label=4;case 4:e=t,n.label=5;case 5:return E=e,[4,g(E)];case 6:return I=n.sent(),E.forEach(function(i){return i instanceof HB&&i.dispose()}),[2,I]}})})}function kn(A,B,g,Q,w){return JA(this,void 0,void 0,function(){var C=this;return mA(this,function(E){return[2,et([A],B,function(e){return JA(C,void 0,void 0,function(){return mA(this,function(t){return[2,g(e[0])]})})},Q,w)]})})}function s4(A){return FA(function(){return Jg(SB(A,3).reverse(),3)})}var tt=2,ot=12;function u4(A,B){var g=Bt(A,B),Q=Hn(A,B);function w(I,n){var i=yB(A(I));return B.push({paramPath:n}),i}function C(I,n,i){i===void 0&&(i=!1);var c=g(I[0],I[1],3,n+"/conv1"),Y=w(I[1],n+"/prelu1_alpha"),M=g(I[1],I[2],3,n+"/conv2"),D=w(I[2],n+"/prelu2_alpha"),r=g(I[2],I[3],i?2:3,n+"/conv3"),F=w(I[3],n+"/prelu3_alpha");return{conv1:c,prelu1_alpha:Y,conv2:M,prelu2_alpha:D,conv3:r,prelu3_alpha:F}}function E(){var I=C([3,10,16,32],"pnet"),n=g(32,2,1,"pnet/conv4_1"),i=g(32,4,1,"pnet/conv4_2");return ng(ng({},I),{conv4_1:n,conv4_2:i})}function e(){var I=C([3,28,48,64],"rnet",!0),n=Q(576,128,"rnet/fc1"),i=w(128,"rnet/prelu4_alpha"),c=Q(128,2,"rnet/fc2_1"),Y=Q(128,4,"rnet/fc2_2");return ng(ng({},I),{fc1:n,prelu4_alpha:i,fc2_1:c,fc2_2:Y})}function t(){var I=C([3,32,64,64],"onet"),n=g(64,128,2,"onet/conv4"),i=w(128,"onet/prelu4_alpha"),c=Q(1152,256,"onet/fc1"),Y=w(256,"onet/prelu5_alpha"),M=Q(256,2,"onet/fc2_1"),D=Q(256,4,"onet/fc2_2"),r=Q(256,10,"onet/fc2_3");return ng(ng({},I),{conv4:n,prelu4_alpha:i,fc1:c,prelu5_alpha:Y,fc2_1:M,fc2_2:D,fc2_3:r})}return{extractPNetParams:E,extractRNetParams:e,extractONetParams:t}}function l4(A){var B=hQ(A),g=B.extractWeights,Q=B.getRemainingWeights,w=[],C=u4(g,w),E=C.extractPNetParams,e=C.extractRNetParams,t=C.extractONetParams,I=E(),n=e(),i=t();if(Q().length!==0)throw new Error("weights remaing after extract: "+Q().length);return{params:{pnet:I,rnet:n,onet:i},paramMappings:w}}function U4(A,B){var g=zQ(A,B);function Q(n){var i=g(n+"/weights",4,n+"/filters"),c=g(n+"/bias",1);return{filters:i,bias:c}}function w(n){var i=g(n+"/weights",2),c=g(n+"/bias",1);return{weights:i,bias:c}}function C(n){return g(n,1)}function E(n){var i=Q(n+"/conv1"),c=C(n+"/prelu1_alpha"),Y=Q(n+"/conv2"),M=C(n+"/prelu2_alpha"),D=Q(n+"/conv3"),r=C(n+"/prelu3_alpha");return{conv1:i,prelu1_alpha:c,conv2:Y,prelu2_alpha:M,conv3:D,prelu3_alpha:r}}function e(){var n=E("pnet"),i=Q("pnet/conv4_1"),c=Q("pnet/conv4_2");return ng(ng({},n),{conv4_1:i,conv4_2:c})}function t(){var n=E("rnet"),i=w("rnet/fc1"),c=C("rnet/prelu4_alpha"),Y=w("rnet/fc2_1"),M=w("rnet/fc2_2");return ng(ng({},n),{fc1:i,prelu4_alpha:c,fc2_1:Y,fc2_2:M})}function I(){var n=E("onet"),i=Q("onet/conv4"),c=C("onet/prelu4_alpha"),Y=w("onet/fc1"),M=C("onet/prelu5_alpha"),D=w("onet/fc2_1"),r=w("onet/fc2_2"),F=w("onet/fc2_3");return ng(ng({},n),{conv4:i,prelu4_alpha:c,fc1:Y,prelu5_alpha:M,fc2_1:D,fc2_2:r,fc2_3:F})}return{extractPNetParams:e,extractRNetParams:t,extractONetParams:I}}function h4(A){var B=[],g=U4(A,B),Q=g.extractPNetParams,w=g.extractRNetParams,C=g.extractONetParams,E=Q(),e=w(),t=C();return UQ(A,B),{params:{pnet:E,rnet:e,onet:t},paramMappings:B}}function Tn(A,B){var g=B[0],Q=B[1];return{height:Math.floor(g*A),width:Math.floor(Q*A)}}function G4(A,B,g){for(var Q=g[0],w=g[1],C=ot/A,E=[],e=Math.min(Q,w)*C,t=0;e>=12;)E.push(C*Math.pow(B,t)),e=e*B,t+=1;return E}var jn=function(A){LA(B,A);function B(g,Q,w,C){return A.call(this,{left:g,top:Q,right:w,bottom:C},!0)||this}return B}(CQ);function ia(A){return FA(function(){return og(VB(A,YA(127.5)),YA(.0078125))})}function nC(A,B){return FA(function(){return BB(JB(A),og(B,Re(JB(Re(A)))))})}function yn(A,B,g){return g===void 0&&(g=!1),FA(function(){var Q=Vg(A,B.conv1,"valid");return Q=nC(Q,B.prelu1_alpha),Q=ZB(Q,g?[2,2]:[3,3],[2,2],"same"),Q=Vg(Q,B.conv2,"valid"),Q=nC(Q,B.prelu2_alpha),Q=g?Q:ZB(Q,[3,3],[2,2],"valid"),Q=Vg(Q,B.conv3,"valid"),Q=nC(Q,B.prelu3_alpha),Q})}function d4(A,B){return FA(function(){var g=yn(A,B,!0),Q=Vg(g,B.conv4_1,"valid"),w=Tg(pe(Q,3),3),C=aQ(VB(Q,w),3),E=Vg(g,B.conv4_2,"valid");return{prob:C,regions:E}})}function H4(A,B){return FA(function(){var g=Tn(B,A.shape.slice(1)),Q=g.height,w=g.width,C=_I.resizeBilinear(A,[Q,w]),E=ia(C);return kQ(E,[0,2,1,3])})}function f4(A,B,g,Q){for(var w=[],C=A.arraySync(),E=0;E<A.shape[0];E++)for(var e=0;e<A.shape[1];e++)C[E][e]>=Q&&w.push(new iB(e,E));var t=w.map(function(I){var n=new Ke(Math.round((I.y*tt+1)/g),Math.round((I.x*tt+1)/g),Math.round((I.y*tt+ot)/g),Math.round((I.x*tt+ot)/g)),i=C[I.y][I.x],c=B.arraySync(),Y=new jn(c[I.y][I.x][0],c[I.y][I.x][1],c[I.y][I.x][2],c[I.y][I.x][3]);return{cell:n,score:i,region:Y}});return t}function J4(A,B,g,Q,w){w.stage1=[];var C=B.map(function(c){return FA(function(){var Y={scale:c},M=H4(A,c),D=Date.now(),r=d4(M,Q),F=r.prob,u=r.regions;Y.pnet=Date.now()-D;var s=SB(SB(F,3)[1])[0],a=SB(u)[0];return{scoresTensor:s,regionsTensor:a,scale:c,statsForScale:Y}})}),E=C.map(function(c){var Y=c.scoresTensor,M=c.regionsTensor,D=c.scale,r=c.statsForScale,F=f4(Y,M,D,g);if(Y.dispose(),M.dispose(),!F.length)return w.stage1.push(r),[];var u=Date.now(),s=wE(F.map(function(a){return a.cell}),F.map(function(a){return a.score}),.5);return r.nms=Date.now()-u,r.numBoxes=s.length,w.stage1.push(r),s.map(function(a){return F[a]})}),e=E.reduce(function(c,Y){return c.concat(Y)},[]),t=[],I=[];if(e.length>0){var n=Date.now(),i=wE(e.map(function(c){return c.cell}),e.map(function(c){return c.score}),.7);w.stage1_nms=Date.now()-n,I=i.map(function(c){return e[c].score}),t=i.map(function(c){return e[c]}).map(function(c){var Y=c.cell,M=c.region;return new Ke(Y.left+M.left*Y.width,Y.top+M.top*Y.height,Y.right+M.right*Y.width,Y.bottom+M.bottom*Y.height).toSquare().round()})}return{boxes:t,scores:I}}function ca(A,B,g){var Q=g.width,w=g.height;return JA(this,void 0,void 0,function(){var C,E,e,t=this;return mA(this,function(I){switch(I.label){case 0:return C=EQ(A),[4,Promise.all(B.map(function(n){return JA(t,void 0,void 0,function(){var i,c,Y,M,D,r,F,u;return mA(this,function(s){return i=n.padAtBorders(A.height,A.width),c=i.y,Y=i.ey,M=i.x,D=i.ex,r=M-1,F=c-1,u=C.getImageData(r,F,D-r,Y-F),[2,ig.isNodejs()?qe(u):createImageBitmap(u)]})})}))];case 1:return E=I.sent(),e=[],E.forEach(function(n){var i=Ze({width:Q,height:w}),c=EQ(i);c.drawImage(n,0,0,Q,w);for(var Y=c.getImageData(0,0,Q,w).data,M=[],D=0;D<Y.length;D+=4)M.push(Y[D+2]),M.push(Y[D+1]),M.push(Y[D]);e.push(M)}),[2,e.map(function(n){var i=FA(function(){var c=kQ(sg(n,[1,Q,w,3]),[0,2,1,3]).toFloat();return ia(c)});return i})]}})})}function m4(A,B){return FA(function(){var g=yn(A,B),Q=bg(g,[g.shape[0],B.fc1.weights.shape[0]]),w=eQ(Q,B.fc1),C=nC(w,B.prelu4_alpha),E=eQ(C,B.fc2_1),e=Tg(pe(E,1),1),t=aQ(VB(E,e),1),I=eQ(C,B.fc2_2),n=SB(t,1)[1];return{scores:n,regions:I}})}function N4(A,B,g,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,t,I,n,i,c,Y,M,D,r,F,u;return mA(this,function(s){switch(s.label){case 0:return C=Date.now(),[4,ca(A,B,{width:24,height:24})];case 1:return E=s.sent(),w.stage2_extractImagePatches=Date.now()-C,C=Date.now(),e=E.map(function(a){var l=m4(a,Q);return a.dispose(),l}),w.stage2_rnet=Date.now()-C,t=e.length>1?bB(e.map(function(a){return a.scores})):e[0].scores,i=(n=Array).from,[4,t.data()];case 2:return I=i.apply(n,[s.sent()]),t.dispose(),c=I.map(function(a,l){return{score:a,idx:l}}).filter(function(a){return a.score>g}).map(function(a){var l=a.idx;return l}),Y=c.map(function(a){return B[a]}),M=c.map(function(a){return I[a]}),D=[],r=[],Y.length>0&&(C=Date.now(),F=wE(Y,M,.7),w.stage2_nms=Date.now()-C,u=F.map(function(a){var l=e[c[a]].regions.arraySync();return new jn(l[0][0],l[0][1],l[0][2],l[0][3])}),r=F.map(function(a){return M[a]}),D=F.map(function(a,l){return Y[a].calibrate(u[l])})),e.forEach(function(a){a.regions.dispose(),a.scores.dispose()}),[2,{boxes:D,scores:r}]}})})}function R4(A,B){return FA(function(){var g=yn(A,B);g=ZB(g,[2,2],[2,2],"same"),g=Vg(g,B.conv4,"valid"),g=nC(g,B.prelu4_alpha);var Q=bg(g,[g.shape[0],B.fc1.weights.shape[0]]),w=eQ(Q,B.fc1),C=nC(w,B.prelu5_alpha),E=eQ(C,B.fc2_1),e=Tg(pe(E,1),1),t=aQ(VB(E,e),1),I=eQ(C,B.fc2_2),n=eQ(C,B.fc2_3),i=SB(t,1)[1];return{scores:i,regions:I,points:n}})}function P4(A,B,g,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,t,I,n,i,c,Y,M,D,r,F,u,s;return mA(this,function(a){switch(a.label){case 0:return C=Date.now(),[4,ca(A,B,{width:48,height:48})];case 1:return E=a.sent(),w.stage3_extractImagePatches=Date.now()-C,C=Date.now(),e=E.map(function(l){var U=R4(l,Q);return l.dispose(),U}),w.stage3_onet=Date.now()-C,t=e.length>1?bB(e.map(function(l){return l.scores})):e[0].scores,i=(n=Array).from,[4,t.data()];case 2:return I=i.apply(n,[a.sent()]),t.dispose(),c=I.map(function(l,U){return{score:l,idx:U}}).filter(function(l){return l.score>g}).map(function(l){var U=l.idx;return U}),Y=c.map(function(l){var U=e[l].regions.arraySync();return new jn(U[0][0],U[0][1],U[0][2],U[0][3])}),M=c.map(function(l,U){return B[l].calibrate(Y[U])}),D=c.map(function(l){return I[l]}),r=[],F=[],u=[],M.length>0&&(C=Date.now(),s=wE(M,D,.7,!1),w.stage3_nms=Date.now()-C,r=s.map(function(l){return M[l]}),F=s.map(function(l){return D[l]}),u=s.map(function(l,U){return Array(5).fill(0).map(function(G,d){var H=e[l].points.arraySync();return new iB(H[0][d]*(r[U].width+1)+r[U].left,H[0][d+5]*(r[U].height+1)+r[U].top)})})),e.forEach(function(l){l.regions.dispose(),l.scores.dispose(),l.points.dispose()}),[2,{boxes:r,scores:F,points:u}]}})})}var v4=function(A){LA(B,A);function B(){return A.call(this,"Mtcnn")||this}return B.prototype.load=function(g){return JA(this,void 0,void 0,function(){return mA(this,function(Q){return console.warn("mtcnn is deprecated and will be removed soon"),[2,A.prototype.load.call(this,g)]})})},B.prototype.loadFromDisk=function(g){return JA(this,void 0,void 0,function(){return mA(this,function(Q){return console.warn("mtcnn is deprecated and will be removed soon"),[2,A.prototype.loadFromDisk.call(this,g)]})})},B.prototype.forwardInput=function(g,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,t,I,n,i,c,Y,M,D,r,F,u,s,a,l,U,G,d;return mA(this,function(H){switch(H.label){case 0:if(w=this.params,!w)throw new Error("Mtcnn - load model before inference");if(C=g.canvases[0],!C)throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return E={},e=Date.now(),t=FA(function(){return s4(Tg(Dn.fromPixels(C)).toFloat())}),I=function(h){return t.dispose(),E.total=Date.now()-e,h},n=t.shape.slice(1),i=n[0],c=n[1],Y=new ea(Q),M=Y.minFaceSize,D=Y.scaleFactor,r=Y.maxNumScales,F=Y.scoreThresholds,u=Y.scaleSteps,s=(u||G4(M,D,[i,c])).filter(function(h){var f=Tn(h,[i,c]);return Math.min(f.width,f.height)>ot}).slice(0,r),E.scales=s,E.pyramid=s.map(function(h){return Tn(h,[i,c])}),a=Date.now(),[4,J4(t,s,F[0],w.pnet,E)];case 1:return l=H.sent(),E.total_stage1=Date.now()-a,l.boxes.length?(E.stage2_numInputBoxes=l.boxes.length,a=Date.now(),[4,N4(C,l.boxes,F[1],w.rnet,E)]):[2,I({results:[],stats:E})];case 2:return U=H.sent(),E.total_stage2=Date.now()-a,U.boxes.length?(E.stage3_numInputBoxes=U.boxes.length,a=Date.now(),[4,P4(C,U.boxes,F[2],w.onet,E)]):[2,I({results:[],stats:E})];case 3:return G=H.sent(),E.total_stage3=Date.now()-a,d=G.boxes.map(function(h,f){return gt(EE({},new Ng(G.scores[f],new xe(h.left/c,h.top/i,h.width/c,h.height/i),{height:i,width:c})),new Cv(G.points[f].map(function(J){return J.sub(new iB(h.left,h.top)).div(new iB(h.width,h.height))}),{width:h.width,height:h.height}))}),[2,I({results:d,stats:E})]}})})},B.prototype.forward=function(g,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return w=this.forwardInput,[4,qB(g)];case 1:return[4,w.apply(this,[C.sent(),Q])];case 2:return[2,C.sent().results]}})})},B.prototype.forwardWithStats=function(g,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return w=this.forwardInput,[4,qB(g)];case 1:return[2,w.apply(this,[C.sent(),Q])]}})})},B.prototype.getDefaultModelName=function(){return"mtcnn_model"},B.prototype.extractParamsFromWeigthMap=function(g){return h4(g)},B.prototype.extractParams=function(g){return l4(g)},B}(lQ),k4=.4,T4=[new iB(1.603231,2.094468),new iB(6.041143,7.080126),new iB(2.882459,3.518061),new iB(4.266906,5.178857),new iB(9.041765,10.66308)],j4=[117.001,114.697,97.404],y4=function(A){LA(B,A);function B(){var g=this,Q={withSeparableConvs:!0,iouThreshold:k4,classes:["face"],anchors:T4,meanRgb:j4,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return g=A.call(this,Q)||this,g}return Object.defineProperty(B.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),B.prototype.locateFaces=function(g,Q){return JA(this,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return[4,this.detect(g,Q)];case 1:return w=C.sent(),[2,w.map(function(E){return new Ng(E.score,E.relativeBox,{width:E.imageWidth,height:E.imageHeight})})]}})})},B.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},B.prototype.extractParamsFromWeigthMap=function(g){return A.prototype.extractParamsFromWeigthMap.call(this,g)},B}(Ia),Ug={ssdMobilenetv1:new ta,tinyFaceDetector:new y4,tinyYolov2:new F4,mtcnn:new v4,faceLandmark68Net:new Ba,faceLandmark68TinyNet:new zv,faceRecognitionNet:new xv,faceExpressionNet:new hv,ageGenderNet:new Tv},Ya=function(A){LA(B,A);function B(g,Q,w){var C=A.call(this)||this;return C.parentTask=g,C.input=Q,C.extractedFaces=w,C}return B}(eE),pn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w=this;return mA(this,function(C){switch(C.label){case 0:return[4,this.parentTask];case 1:return g=C.sent(),[4,et(g,this.input,function(E){return JA(w,void 0,void 0,function(){return mA(this,function(e){switch(e.label){case 0:return[4,Promise.all(E.map(function(t){return Ug.faceExpressionNet.predictExpressions(t)}))];case 1:return[2,e.sent()]}})})},this.extractedFaces)];case 2:return Q=C.sent(),[2,g.map(function(E,e){return _D(E,Q[e])})]}})})},B.prototype.withAgeAndGender=function(){return new Sn(this,this.input)},B}(Ya),zn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return g=w.sent(),g?[4,kn(g,this.input,function(C){return Ug.faceExpressionNet.predictExpressions(C)},this.extractedFaces)]:[2];case 2:return Q=w.sent(),[2,_D(g,Q)]}})})},B.prototype.withAgeAndGender=function(){return new Ln(this,this.input)},B}(Ya),Wn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.withAgeAndGender=function(){return new Vn(this,this.input)},B.prototype.withFaceDescriptors=function(){return new xn(this,this.input)},B}(pn),bn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.withAgeAndGender=function(){return new Kn(this,this.input)},B.prototype.withFaceDescriptor=function(){return new Xn(this,this.input)},B}(zn),Ma=function(A){LA(B,A);function B(g,Q,w){var C=A.call(this)||this;return C.parentTask=g,C.input=Q,C.extractedFaces=w,C}return B}(eE),Sn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w=this;return mA(this,function(C){switch(C.label){case 0:return[4,this.parentTask];case 1:return g=C.sent(),[4,et(g,this.input,function(E){return JA(w,void 0,void 0,function(){return mA(this,function(e){switch(e.label){case 0:return[4,Promise.all(E.map(function(t){return Ug.ageGenderNet.predictAgeAndGender(t)}))];case 1:return[2,e.sent()]}})})},this.extractedFaces)];case 2:return Q=C.sent(),[2,g.map(function(E,e){var t=Q[e],I=t.age,n=t.gender,i=t.genderProbability;return Ca(Ea(E,n,i),I)})]}})})},B.prototype.withFaceExpressions=function(){return new pn(this,this.input)},B}(Ma),Ln=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w,C,E;return mA(this,function(e){switch(e.label){case 0:return[4,this.parentTask];case 1:return g=e.sent(),g?[4,kn(g,this.input,function(t){return Ug.ageGenderNet.predictAgeAndGender(t)},this.extractedFaces)]:[2];case 2:return Q=e.sent(),w=Q.age,C=Q.gender,E=Q.genderProbability,[2,Ca(Ea(g,C,E),w)]}})})},B.prototype.withFaceExpressions=function(){return new zn(this,this.input)},B}(Ma),Vn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.withFaceExpressions=function(){return new Wn(this,this.input)},B.prototype.withFaceDescriptors=function(){return new xn(this,this.input)},B}(Sn),Kn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.withFaceExpressions=function(){return new bn(this,this.input)},B.prototype.withFaceDescriptor=function(){return new Xn(this,this.input)},B}(Ln),ra=function(A){LA(B,A);function B(g,Q){var w=A.call(this)||this;return w.parentTask=g,w.input=Q,w}return B}(eE),xn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return g=w.sent(),[4,et(g,this.input,function(C){return Promise.all(C.map(function(E){return Ug.faceRecognitionNet.computeFaceDescriptor(E)}))},null,function(C){return C.landmarks.align(null,{useDlibAlignment:!0})})];case 2:return Q=w.sent(),[2,Q.map(function(C,E){return wa(g[E],C)})]}})})},B.prototype.withFaceExpressions=function(){return new Wn(this,this.input)},B.prototype.withAgeAndGender=function(){return new Vn(this,this.input)},B}(ra),Xn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return g=w.sent(),g?[4,kn(g,this.input,function(C){return Ug.faceRecognitionNet.computeFaceDescriptor(C)},null,function(C){return C.landmarks.align(null,{useDlibAlignment:!0})})]:[2];case 2:return Q=w.sent(),[2,wa(g,Q)]}})})},B.prototype.withFaceExpressions=function(){return new bn(this,this.input)},B.prototype.withAgeAndGender=function(){return new Kn(this,this.input)},B}(ra),Da=function(A){LA(B,A);function B(g,Q,w){var C=A.call(this)||this;return C.parentTask=g,C.input=Q,C.useTinyLandmarkNet=w,C}return Object.defineProperty(B.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?Ug.faceLandmark68TinyNet:Ug.faceLandmark68Net},enumerable:!0,configurable:!0}),B}(eE),p4=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w,C,E,e=this;return mA(this,function(t){switch(t.label){case 0:return[4,this.parentTask];case 1:return g=t.sent(),Q=g.map(function(I){return I.detection}),this.input instanceof HB?[4,Gn(this.input,Q)]:[3,3];case 2:return C=t.sent(),[3,5];case 3:return[4,$e(this.input,Q)];case 4:C=t.sent(),t.label=5;case 5:return w=C,[4,Promise.all(w.map(function(I){return e.landmarkNet.detectLandmarks(I)}))];case 6:return E=t.sent(),w.forEach(function(I){return I instanceof HB&&I.dispose()}),[2,g.map(function(I,n){return gt(I,E[n])})]}})})},B.prototype.withFaceExpressions=function(){return new Wn(this,this.input)},B.prototype.withAgeAndGender=function(){return new Vn(this,this.input)},B.prototype.withFaceDescriptors=function(){return new xn(this,this.input)},B}(Da),z4=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w,C,E;return mA(this,function(e){switch(e.label){case 0:return[4,this.parentTask];case 1:return g=e.sent(),g?(Q=g.detection,this.input instanceof HB?[4,Gn(this.input,[Q])]:[3,3]):[2];case 2:return C=e.sent(),[3,5];case 3:return[4,$e(this.input,[Q])];case 4:C=e.sent(),e.label=5;case 5:return w=C,[4,this.landmarkNet.detectLandmarks(w[0])];case 6:return E=e.sent(),w.forEach(function(t){return t instanceof HB&&t.dispose()}),[2,gt(g,E)]}})})},B.prototype.withFaceExpressions=function(){return new bn(this,this.input)},B.prototype.withAgeAndGender=function(){return new Kn(this,this.input)},B.prototype.withFaceDescriptor=function(){return new Xn(this,this.input)},B}(Da),aa=function(A){LA(B,A);function B(g,Q){Q===void 0&&(Q=new Ct);var w=A.call(this)||this;return w.input=g,w.options=Q,w}return B}(eE),W4=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w,C;return mA(this,function(E){switch(E.label){case 0:return g=this,Q=g.input,w=g.options,w instanceof ea?[4,Ug.mtcnn.forward(Q,w)]:[3,2];case 1:return[2,E.sent().map(function(e){return e.detection})];case 2:if(C=w instanceof na?function(e){return Ug.tinyFaceDetector.locateFaces(e,w)}:w instanceof Ct?function(e){return Ug.ssdMobilenetv1.locateFaces(e,w)}:w instanceof vn?function(e){return Ug.tinyYolov2.locateFaces(e,w)}:null,!C)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,C(Q)]}})})},B.prototype.runAndExtendWithFaceDetections=function(){var g=this;return new Promise(function(Q){return JA(g,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return[4,this.run()];case 1:return w=C.sent(),[2,Q(w.map(function(E){return EE({},E)}))]}})})})},B.prototype.withFaceLandmarks=function(g){return g===void 0&&(g=!1),new p4(this.runAndExtendWithFaceDetections(),this.input,g)},B.prototype.withFaceExpressions=function(){return new pn(this.runAndExtendWithFaceDetections(),this.input)},B.prototype.withAgeAndGender=function(){return new Sn(this.runAndExtendWithFaceDetections(),this.input)},B}(aa),b4=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q;return mA(this,function(w){switch(w.label){case 0:return[4,new W4(this.input,this.options)];case 1:return g=w.sent(),Q=g[0],g.forEach(function(C){C.score>Q.score&&(Q=C)}),[2,Q]}})})},B.prototype.runAndExtendWithFaceDetection=function(){var g=this;return new Promise(function(Q){return JA(g,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return[4,this.run()];case 1:return w=C.sent(),[2,Q(w?EE({},w):void 0)]}})})})},B.prototype.withFaceLandmarks=function(g){return g===void 0&&(g=!1),new z4(this.runAndExtendWithFaceDetection(),this.input,g)},B.prototype.withFaceExpressions=function(){return new zn(this.runAndExtendWithFaceDetection(),this.input)},B.prototype.withAgeAndGender=function(){return new Ln(this.runAndExtendWithFaceDetection(),this.input)},B}(aa);function S4(A,B){return B===void 0&&(B=new Ct),new b4(A,B)}function L4(A,B){if(A.length!==B.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var g=Array.from(A),Q=Array.from(B);return Math.sqrt(g.map(function(w,C){return w-Q[C]}).reduce(function(w,C){return w+Math.pow(C,2)},0))}(function(){function A(B,g){g===void 0&&(g=.6),this._distanceThreshold=g;var Q=Array.isArray(B)?B:[B];if(!Q.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var w=1,C=function(){return"person "+w++};this._labeledDescriptors=Q.map(function(E){if(E instanceof Xe)return E;if(E instanceof Float32Array)return new Xe(C(),[E]);if(E.descriptor&&E.descriptor instanceof Float32Array)return new Xe(C(),[E.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")})}return Object.defineProperty(A.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),A.prototype.computeMeanDistance=function(B,g){return g.map(function(Q){return L4(Q,B)}).reduce(function(Q,w){return Q+w},0)/(g.length||1)},A.prototype.matchDescriptor=function(B){var g=this;return this.labeledDescriptors.map(function(Q){var w=Q.descriptors,C=Q.label;return new PD(C,g.computeMeanDistance(B,w))}).reduce(function(Q,w){return Q.distance<w.distance?Q:w})},A.prototype.findBestMatch=function(B){var g=this.matchDescriptor(B);return g.distance<this.distanceThreshold?g:new PD("unknown",g.distance)},A.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(B){return B.toJSON()})}},A.fromJSON=function(B){var g=B.labeledDescriptors.map(function(Q){return Xe.fromJSON(Q)});return new A(g,B.distanceThreshold)},A})();function Fa(A,B){var g=new Dw(B.width,B.height),Q=g.width,w=g.height;if(Q<=0||w<=0)throw new Error("resizeResults - invalid dimensions: "+JSON.stringify({width:Q,height:w}));if(Array.isArray(A))return A.map(function(e){return Fa(e,{width:Q,height:w})});if(mn(A)){var C=A.detection.forSize(Q,w),E=A.unshiftedLandmarks.forSize(C.box.width,C.box.height);return gt(EE(A,C),E)}return Oe(A)?EE(A,A.detection.forSize(Q,w)):A instanceof oC||A instanceof Ng?A.forSize(Q,w):A}class V4{getVideoStreamConfig(B,g){return{audio:!1,video:{width:{min:B,ideal:B},height:{min:g,ideal:g},facingMode:"environment"}}}getContourCoordinate(B,g){return{x:B*.25,y:g*.05,width:B*.5,height:g*.9}}getBoxData(B){return B?{x:B.x,y:B.y,width:B.width,height:B.height}:null}setStylesForCanvas(B){B.width="100%",B.height="100%",B.style.position="absolute",B.style.top="0",B.style.left="0"}checkFaceInclusion(B,g){if(!B||!g||g.width>B.width||g.height>B.height)return!1;const Q=g.x,w=g.x+g.width,C=g.y,E=g.y+g.height,e=B.x,t=B.x+B.width,I=B.y,n=B.y+B.height;return Q>=e&&w<=t&&C>=I&&E<=n}async getFaceDetections(B,g){if(!B)return[];const Q=new na({inputSize:g});return S4(B,Q).withFaceLandmarks(!0)}getCanvas(B){return qe(B)}getResizedAndDetection(B,g,Q,w,C){av(B,{width:w,height:C});const E=Fa(g,{width:w,height:C});Q.clearRect(0,0,w,C),nv(B,E),Hv(B,E)}async getFaceSnapshot(B,g){const Q=[new xe(g.x,g.y,g.width,g.height)],w=await $e(B,Q);return w.length?w[0].toDataURL("image/jpeg").replace(/^data:image\/\w+;base64,/,""):null}async initModels(){let B=new Date;console.log(B);try{await Promise.all([Ug.tinyFaceDetector.loadFromUri("/models"),Ug.faceLandmark68TinyNet.loadFromUri("/models")])}catch(g){console.error(g)}B=new Date,console.log(B)}}let On;function K4(){return On||(On=new V4),On}function x4(A){const B=o.ref(""),g=o.ref(1),Q=async(E="",e=1)=>{await A.initialize({search:E,page:e})},w=async E=>{B.value=E,g.value=1,await Q(E,g.value)},C=async E=>{g.value=E,await Q(B.value,E)};return o.watch(()=>A.columnFilters.value,async()=>{g.value=1,await Q(B.value,g.value)},{deep:!0}),o.onMounted(()=>Q(B.value,g.value)),{search:B,currentPage:g,loading:A.loading,handleSearch:w,handlePageChange:C,loadTable:Q}}const X4=A=>{const B=o.ref({}),g=o.ref({});A.columns.forEach(({name:t,filterType:I})=>{I&&(B.value[t]=I==="multi"?[]:void 0,g.value[t]=!1)});const Q=o.computed(()=>Array.isArray(A.rows)?A.rows:A.rows.value),w=(t,I)=>{const n=A.columns.find(i=>i.name===t);if((n==null?void 0:n.filterType)==="multi"){const i=B.value[t],c=i.indexOf(I);c>-1?i.splice(c,1):i.push(I),B.value[t]=[...i]}else B.value[t]=I,g.value[t]=!1},C=o.computed(()=>{var I;const t={};for(const n of A.columns){const i=B.value[n.name],c=((I=A.filtersOptions)==null?void 0:I.value[n.name])||[];if(i){let Y=[];Array.isArray(i)?Y=c.filter(M=>i.includes(M.name)).map(M=>M.id):Y=c.filter(M=>M.name===i).map(M=>M.id),t[n.name]=Array.from(new Set(Y))}}return t}),E=t=>{const I=A.columns.find(n=>n.name===t);B.value[t]=(I==null?void 0:I.filterType)==="multi"?[]:void 0},e=(t,I)=>{g.value[t]=I};return{rows:Q,columns:o.computed(()=>A.columns),columnFilters:B,filterMenus:g,toggleFilterValue:w,clearFilter:E,openFilterMenu:e,selectedFilters:C}};function O4(A,B=[]){const g=o.ref([...new Set([...B,...A.map(C=>C.name)])]),Q=o.computed(()=>A.filter(C=>g.value.includes(C.name)));function w(C){C.dialog({title:"Выберите колонки",options:{type:"checkbox",model:[...g.value],items:A.map(E=>({label:E.label,value:E.name,disable:B.includes(E.name)}))},cancel:{label:"Отмена","data-test":"cancel-button"},ok:{label:"Ок","data-test":"ok-button"},persistent:!0}).onOk(E=>{g.value=Array.from(new Set([...E,...B]))})}return{selectedColumnNames:g,visibleColumns:Q,openColumnSelectorDialog:w}}function Z4(A){if(!A)return"";const B=A.startsWith("/uploads")?"":"/uploads";return process.env.VUE_APP_BACKEND_BASE+B+A}async function q4(A){if(A)try{const B=document.createElement("a");B.href=A,B.setAttribute("target","_blank"),B.click()}catch(B){console.error(B)}}const _4=(A,B)=>{try{const g=document.createElement("a"),Q=window.URL.createObjectURL(A);g.href=Q,g.download=B,document.body.appendChild(g),g.click(),setTimeout(function(){document.body.removeChild(g),window.URL.revokeObjectURL(Q)},0)}catch(g){console.error("Ошибка при загрузке файла:",g)}};aA.ApiService=zB,aA.AppButton=UE,aA.AppCheckbox=mF,aA.AppConfirmDialog=bh,aA.AppDatePicker=as,aA.AppDatepicker=Ks,aA.AppDropdown=xh,aA.AppFile=nd,aA.AppInput=xs,aA.AppInputNew=Tc,aA.AppInputSearch=Xs,aA.AppLayout=$s,aA.AppLayoutHeader=pU,aA.AppLayoutPage=SU,aA.AppLoader=Wc,aA.AppModal=Ed,aA.AppModalSelect=wY,aA.AppSelect=ZU,aA.AppSheet=wh,aA.AppSheetNew=Fh,aA.AppSidebar=dh,aA.AppTable=MY,aA.AppTableLayout=Qd,aA.AppTableModal=tG,aA.AppTablePagination=BY,aA.AppTableSearch=gY,aA.AppToggle=Hh,aA.AppWrapper=Nh,aA.base64ToBlob=Ws,aA.getFileFullPath=Z4,aA.isEqual=GC,aA.normalizeValue=Tw,aA.notificationSettings=Eo,aA.openFile=q4,aA.saveBlobAsFile=_4,aA.useAuthService=KH,aA.useBaseTable=x4,aA.useBrigadesService=cf,aA.useColumnSelector=O4,aA.useCommentsService=tf,aA.useControlsService=gf,aA.useEquipmentService=If,aA.useFaceApiHelper=K4,aA.useFileService=XH,aA.useGanttService=TH,aA.useInstrumentsService=Af,aA.useMetricsService=yH,aA.useModulesService=Ef,aA.useProjectsService=zH,aA.useRepairsService=bH,aA.useScheduleService=Mf,aA.useSearchService=wf,aA.useTableModel=X4,aA.useTasksService=LH,aA.useUserIssueService=Df,aA.useUserService=_H,aA.useVideoService=ZH,aA.uuidv4=Co,Object.defineProperty(aA,Symbol.toStringTag,{value:"Module"})});
3834
+ ***************************************************************************** */var an=function(A,B){return an=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,Q){g.__proto__=Q}||function(g,Q){for(var w in Q)Q.hasOwnProperty(w)&&(g[w]=Q[w])},an(A,B)};function LA(A,B){an(A,B);function g(){this.constructor=A}A.prototype=B===null?Object.create(B):(g.prototype=B.prototype,new g)}var ng=function(){return ng=Object.assign||function(B){for(var g,Q=1,w=arguments.length;Q<w;Q++){g=arguments[Q];for(var C in g)Object.prototype.hasOwnProperty.call(g,C)&&(B[C]=g[C])}return B},ng.apply(this,arguments)};function JA(A,B,g,Q){function w(C){return C instanceof g?C:new g(function(E){E(C)})}return new(g||(g=Promise))(function(C,E){function e(n){try{I(Q.next(n))}catch(i){E(i)}}function t(n){try{I(Q.throw(n))}catch(i){E(i)}}function I(n){n.done?C(n.value):w(n.value).then(e,t)}I((Q=Q.apply(A,[])).next())})}function mA(A,B){var g={label:0,sent:function(){if(C[0]&1)throw C[1];return C[1]},trys:[],ops:[]},Q,w,C,E;return E={next:e(0),throw:e(1),return:e(2)},typeof Symbol=="function"&&(E[Symbol.iterator]=function(){return this}),E;function e(I){return function(n){return t([I,n])}}function t(I){if(Q)throw new TypeError("Generator is already executing.");for(;g;)try{if(Q=1,w&&(C=I[0]&2?w.return:I[0]?w.throw||((C=w.return)&&C.call(w),0):w.next)&&!(C=C.call(w,I[1])).done)return C;switch(w=0,C&&(I=[I[0]&2,C.value]),I[0]){case 0:case 1:C=I;break;case 4:return g.label++,{value:I[1],done:!1};case 5:g.label++,w=I[1],I=[0];continue;case 7:I=g.ops.pop(),g.trys.pop();continue;default:if(C=g.trys,!(C=C.length>0&&C[C.length-1])&&(I[0]===6||I[0]===2)){g=0;continue}if(I[0]===3&&(!C||I[1]>C[0]&&I[1]<C[3])){g.label=I[1];break}if(I[0]===6&&g.label<C[1]){g.label=C[1],C=I;break}if(C&&g.label<C[2]){g.label=C[2],g.ops.push(I);break}C[2]&&g.ops.pop(),g.trys.pop();continue}I=B.call(A,g)}catch(n){I=[6,n],w=0}finally{Q=C=0}if(I[0]&5)throw I[1];return{value:I[0]?I[1]:void 0,done:!0}}}function gE(){for(var A=0,B=0,g=arguments.length;B<g;B++)A+=arguments[B].length;for(var Q=Array(A),w=0,B=0;B<g;B++)for(var C=arguments[B],E=0,e=C.length;E<e;E++,w++)Q[w]=C[E];return Q}var Dw=function(){function A(B,g){if(!aw(B)||!aw(g))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:B,height:g}));this._width=B,this._height=g}return Object.defineProperty(A.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),A.prototype.reverse=function(){return new A(1/this.width,1/this.height)},A}();function Le(A,B){return A instanceof HB&&A.shape.length===B}function ZP(A){return Le(A,2)}function Ve(A){return Le(A,3)}function yQ(A){return Le(A,4)}function qP(A){return A%1!==0}function HD(A){return A%2===0}function fD(A,B){B===void 0&&(B=2);var g=Math.pow(10,B);return Math.floor(A*g)/g}function JD(A){return A&&A.width&&A.height}function _P(A,B){var g=A.width,Q=A.height,w=B/Math.max(Q,g);return new Dw(Math.round(g*w),Math.round(Q*w))}function Fn(A){return A.reduce(function(B,g){return B.add(g)},new iB(0,0)).div(new iB(A.length,A.length))}function QE(A,B,g){return Array(A).fill(0).map(function(Q,w){return B+w*g})}function aw(A){return!!A&&A!==1/0&&A!==-1/0&&!isNaN(A)||A===0}function mD(A){return aw(A)&&0<=A&&A<=1}var iB=function(){function A(B,g){this._x=B,this._y=g}return Object.defineProperty(A.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),A.prototype.add=function(B){return new A(this.x+B.x,this.y+B.y)},A.prototype.sub=function(B){return new A(this.x-B.x,this.y-B.y)},A.prototype.mul=function(B){return new A(this.x*B.x,this.y*B.y)},A.prototype.div=function(B){return new A(this.x/B.x,this.y/B.y)},A.prototype.abs=function(){return new A(Math.abs(this.x),Math.abs(this.y))},A.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},A.prototype.floor=function(){return new A(Math.floor(this.x),Math.floor(this.y))},A}(),CQ=function(){function A(B,g){g===void 0&&(g=!0);var Q=B||{},w=[Q.left,Q.top,Q.right,Q.bottom].every(aw),C=[Q.x,Q.y,Q.width,Q.height].every(aw);if(!C&&!w)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify(Q));var E=C?[Q.x,Q.y,Q.width,Q.height]:[Q.left,Q.top,Q.right-Q.left,Q.bottom-Q.top],e=E[0],t=E[1],I=E[2],n=E[3];A.assertIsValidBox({x:e,y:t,width:I,height:n},"Box.constructor",g),this._x=e,this._y=t,this._width=I,this._height=n}return A.isRect=function(B){return!!B&&[B.x,B.y,B.width,B.height].every(aw)},A.assertIsValidBox=function(B,g,Q){if(Q===void 0&&(Q=!1),!A.isRect(B))throw new Error(g+" - invalid box: "+JSON.stringify(B)+", expected object with properties x, y, width, height");if(!Q&&(B.width<0||B.height<0))throw new Error(g+" - width ("+B.width+") and height ("+B.height+") must be positive numbers")},Object.defineProperty(A.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"topLeft",{get:function(){return new iB(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"topRight",{get:function(){return new iB(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"bottomLeft",{get:function(){return new iB(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"bottomRight",{get:function(){return new iB(this.right,this.bottom)},enumerable:!0,configurable:!0}),A.prototype.round=function(){var B=[this.x,this.y,this.width,this.height].map(function(E){return Math.round(E)}),g=B[0],Q=B[1],w=B[2],C=B[3];return new A({x:g,y:Q,width:w,height:C})},A.prototype.floor=function(){var B=[this.x,this.y,this.width,this.height].map(function(E){return Math.floor(E)}),g=B[0],Q=B[1],w=B[2],C=B[3];return new A({x:g,y:Q,width:w,height:C})},A.prototype.toSquare=function(){var B=this,g=B.x,Q=B.y,w=B.width,C=B.height,E=Math.abs(w-C);return w<C&&(g-=E/2,w+=E),C<w&&(Q-=E/2,C+=E),new A({x:g,y:Q,width:w,height:C})},A.prototype.rescale=function(B){var g=JD(B)?B.width:B,Q=JD(B)?B.height:B;return new A({x:this.x*g,y:this.y*Q,width:this.width*g,height:this.height*Q})},A.prototype.pad=function(B,g){var Q=[this.x-B/2,this.y-g/2,this.width+B,this.height+g],w=Q[0],C=Q[1],E=Q[2],e=Q[3];return new A({x:w,y:C,width:E,height:e})},A.prototype.clipAtImageBorders=function(B,g){var Q=this,w=Q.x,C=Q.y,E=Q.right,e=Q.bottom,t=Math.max(w,0),I=Math.max(C,0),n=E-t,i=e-I,c=Math.min(n,B-t),Y=Math.min(i,g-I);return new A({x:t,y:I,width:c,height:Y}).floor()},A.prototype.shift=function(B,g){var Q=this,w=Q.width,C=Q.height,E=this.x+B,e=this.y+g;return new A({x:E,y:e,width:w,height:C})},A.prototype.padAtBorders=function(B,g){var Q=this.width+1,w=this.height+1,C=1,E=1,e=Q,t=w,I=this.left,n=this.top,i=this.right,c=this.bottom;return i>g&&(e=-i+g+Q,i=g),c>B&&(t=-c+B+w,c=B),I<1&&(t=2-I,I=1),n<1&&(t=2-n,n=1),{dy:E,edy:t,dx:C,edx:e,y:n,ey:c,x:I,ex:i,w:Q,h:w}},A.prototype.calibrate=function(B){return new A({left:this.left+B.left*this.width,top:this.top+B.top*this.height,right:this.right+B.right*this.width,bottom:this.bottom+B.bottom*this.height}).toSquare().round()},A}(),Ke=function(A){LA(B,A);function B(g,Q,w,C,E){return E===void 0&&(E=!1),A.call(this,{left:g,top:Q,right:w,bottom:C},E)||this}return B}(CQ),ND=function(){function A(B,g,Q,w,C){this._imageDims=new Dw(C.width,C.height),this._score=B,this._classScore=g,this._className=Q,this._box=new CQ(w).rescale(this._imageDims)}return Object.defineProperty(A.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"relativeBox",{get:function(){return new CQ(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),A.prototype.forSize=function(B,g){return new A(this.score,this.classScore,this.className,this.relativeBox,{width:B,height:g})},A}(),Ng=function(A){LA(B,A);function B(g,Q,w){return A.call(this,g,g,"",Q,w)||this}return B.prototype.forSize=function(g,Q){var w=A.prototype.forSize.call(this,g,Q),C=w.score,E=w.relativeBox,e=w.imageDims;return new B(C,E,e)},B}(ND);function $P(A,B,g){g===void 0&&(g=!0);var Q=Math.max(0,Math.min(A.right,B.right)-Math.max(A.left,B.left)),w=Math.max(0,Math.min(A.bottom,B.bottom)-Math.max(A.top,B.top)),C=Q*w;return g?C/(A.area+B.area-C):C/Math.min(A.area,B.area)}function Av(A){var B=A.map(function(e){return e.x}),g=A.map(function(e){return e.y}),Q=B.reduce(function(e,t){return t<e?t:e},1/0),w=g.reduce(function(e,t){return t<e?t:e},1/0),C=B.reduce(function(e,t){return e<t?t:e},0),E=g.reduce(function(e,t){return e<t?t:e},0);return new Ke(Q,w,C,E)}function wE(A,B,g,Q){Q===void 0&&(Q=!0);for(var w=B.map(function(e,t){return{score:e,boxIndex:t}}).sort(function(e,t){return e.score-t.score}).map(function(e){return e.boxIndex}),C=[],E=function(){var e=w.pop();C.push(e);for(var t=w,I=[],n=0;n<t.length;n++){var i=t[n],c=A[e],Y=A[i];I.push($P(c,Y,Q))}w=w.filter(function(M,D){return I[D]<=g})};w.length>0;)E();return C}function CE(A,B){return FA(function(){var g=B[0],Q=B[1],w=B[2],C=QQ(gE(A.shape.slice(0,3),[1]),g),E=QQ(gE(A.shape.slice(0,3),[1]),Q),e=QQ(gE(A.shape.slice(0,3),[1]),w),t=bB([C,E,e],3);return VB(A,t)})}function Bv(A,B){return B===void 0&&(B=!1),FA(function(){var g=A.shape.slice(1),Q=g[0],w=g[1];if(Q===w)return A;var C=Math.abs(Q-w),E=Math.round(C*(B?.5:1)),e=Q>w?2:1,t=function(Y){var M=A.shape.slice();return M[e]=Y,QQ(M,0)},I=t(E),n=C-I.shape[e],i=B&&n?t(n):null,c=[i,A,I].filter(function(Y){return!!Y}).map(function(Y){return Y.toFloat()});return bB(c,e)})}function sn(A){return 1/(1+Math.exp(-A))}var xe=function(A){LA(B,A);function B(g,Q,w,C,E){return E===void 0&&(E=!1),A.call(this,{x:g,y:Q,width:w,height:C},E)||this}return B}(CQ),gv=.5,Qv=.43,wv=.45,oC=function(){function A(B,g,Q){Q===void 0&&(Q=new iB(0,0));var w=g.width,C=g.height;this._imgDims=new Dw(w,C),this._shift=Q,this._positions=B.map(function(E){return E.mul(new iB(w,C)).add(Q)})}return Object.defineProperty(A.prototype,"shift",{get:function(){return new iB(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"relativePositions",{get:function(){var B=this;return this._positions.map(function(g){return g.sub(B._shift).div(new iB(B.imageWidth,B.imageHeight))})},enumerable:!0,configurable:!0}),A.prototype.forSize=function(B,g){return new this.constructor(this.relativePositions,{width:B,height:g})},A.prototype.shiftBy=function(B,g){return new this.constructor(this.relativePositions,this._imgDims,new iB(B,g))},A.prototype.shiftByPoint=function(B){return this.shiftBy(B.x,B.y)},A.prototype.align=function(B,g){if(g===void 0&&(g={}),B){var Q=B instanceof Ng?B.box.floor():new CQ(B);return this.shiftBy(Q.x,Q.y).align(null,g)}var w=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},g),C=w.useDlibAlignment,E=w.minBoxPadding;return C?this.alignDlib():this.alignMinBbox(E)},A.prototype.alignDlib=function(){var B=this.getRefPointsForAlignment(),g=B[0],Q=B[1],w=B[2],C=function(i){return w.sub(i).magnitude()},E=(C(g)+C(Q))/2,e=Math.floor(E/wv),t=Fn(B),I=Math.floor(Math.max(0,t.x-gv*e)),n=Math.floor(Math.max(0,t.y-Qv*e));return new xe(I,n,Math.min(e,this.imageWidth+I),Math.min(e,this.imageHeight+n))},A.prototype.alignMinBbox=function(B){var g=Av(this.positions);return g.pad(g.width*B,g.height*B)},A.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},A}(),Cv=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.getRefPointsForAlignment=function(){var g=this.positions;return[g[0],g[1],Fn([g[3],g[4]])]},B}(oC),RD=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.getJawOutline=function(){return this.positions.slice(0,17)},B.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},B.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},B.prototype.getNose=function(){return this.positions.slice(27,36)},B.prototype.getLeftEye=function(){return this.positions.slice(36,42)},B.prototype.getRightEye=function(){return this.positions.slice(42,48)},B.prototype.getMouth=function(){return this.positions.slice(48,68)},B.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Fn)},B}(oC),PD=function(){function A(B,g){this._label=B,this._distance=g}return Object.defineProperty(A.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),A.prototype.toString=function(B){return B===void 0&&(B=!0),""+this.label+(B?" ("+fD(this.distance)+")":"")},A}(),vD=function(A){LA(B,A);function B(g,Q){var w=A.call(this,g)||this;return w._label=Q,w}return B.assertIsValidLabeledBox=function(g,Q){if(CQ.assertIsValidBox(g,Q),!aw(g.label))throw new Error(Q+" - expected property label ("+g.label+") to be a number")},Object.defineProperty(B.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),B}(CQ),Xe=function(){function A(B,g){if(typeof B!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(g)||g.some(function(Q){return!(Q instanceof Float32Array)}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=B,this._descriptors=g}return Object.defineProperty(A.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),A.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map(function(B){return Array.from(B)})}},A.fromJSON=function(B){var g=B.descriptors.map(function(Q){return new Float32Array(Q)});return new A(B.label,g)},A}();(function(A){LA(B,A);function B(g,Q,w,C){var E=A.call(this,g,Q)||this;return E._score=w,E._classScore=C,E}return B.assertIsValidPredictedBox=function(g,Q){if(vD.assertIsValidLabeledBox(g,Q),!mD(g.score)||!mD(g.classScore))throw new Error(Q+" - expected properties score ("+g.score+") and ("+g.classScore+") to be a number between [0, 1]")},Object.defineProperty(B.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(B.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),B})(vD);function Oe(A){return A.detection instanceof Ng}function EE(A,B){var g={detection:B};return Object.assign({},A,g)}function kD(){var A=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")},B=function(){throw new Error("readFile - filesystem not available for browser environment")};return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D,Image:HTMLImageElement,ImageData,Video:HTMLVideoElement,createCanvasElement:function(){return document.createElement("canvas")},createImageElement:function(){return document.createElement("img")},fetch:A,readFile:B}}function TD(A){var B="";if(!A)try{A=require("fs")}catch(Q){B=Q.toString()}var g=A?function(Q){return new Promise(function(w,C){A.readFile(Q,function(E,e){return E?C(E):w(e)})})}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+B)};return{readFile:g}}function jD(){var A=global.Canvas||global.HTMLCanvasElement,B=global.Image||global.HTMLImageElement,g=function(){if(A)return new A;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},Q=function(){if(B)return new B;throw new Error("createImageElement - missing Image implementation for nodejs environment")},w=global.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},C=TD();return ng({Canvas:A||function(){function E(){}return E}(),CanvasRenderingContext2D:global.CanvasRenderingContext2D||function(){function E(){}return E}(),Image:B||function(){function E(){}return E}(),ImageData:global.ImageData||function(){function E(){}return E}(),Video:global.HTMLVideoElement||function(){function E(){}return E}(),createCanvasElement:g,createImageElement:Q,fetch:w},C)}function yD(){return typeof window=="object"&&typeof document<"u"&&typeof HTMLImageElement<"u"&&typeof HTMLCanvasElement<"u"&&typeof HTMLVideoElement<"u"&&typeof ImageData<"u"&&typeof CanvasRenderingContext2D<"u"}function pD(){return typeof global=="object"&&typeof require=="function"&&typeof module<"u"&&typeof process<"u"&&!!process.version}var KB;function Ev(){if(!KB)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return KB}function un(A){KB=A}function ln(){yD()&&un(kD()),pD()&&un(jD())}function ev(A){if(KB||ln(),!KB)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var B=A.Canvas,g=B===void 0?KB.Canvas:B,Q=A.Image,w=Q===void 0?KB.Image:Q;KB.Canvas=g,KB.Image=w,KB.createCanvasElement=A.createCanvasElement||function(){return new g},KB.createImageElement=A.createImageElement||function(){return new w},KB.ImageData=A.ImageData||KB.ImageData,KB.Video=A.Video||KB.Video,KB.fetch=A.fetch||KB.fetch,KB.readFile=A.readFile||KB.readFile}var ig={getEnv:Ev,setEnv:un,initialize:ln,createBrowserEnv:kD,createFileSystem:TD,createNodejsEnv:jD,monkeyPatch:ev,isBrowser:yD,isNodejs:pD};ln();function Un(A){return!ig.isNodejs()&&typeof A=="string"?document.getElementById(A):A}function EQ(A){var B=ig.getEnv(),g=B.Canvas,Q=B.CanvasRenderingContext2D;if(A instanceof Q)return A;var w=Un(A);if(!(w instanceof g))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var C=w.getContext("2d");if(!C)throw new Error("resolveContext2d - canvas 2d context is null");return C}var pQ;(function(A){A.TOP_LEFT="TOP_LEFT",A.TOP_RIGHT="TOP_RIGHT",A.BOTTOM_LEFT="BOTTOM_LEFT",A.BOTTOM_RIGHT="BOTTOM_RIGHT"})(pQ||(pQ={}));var zD=function(){function A(B){B===void 0&&(B={});var g=B.anchorPosition,Q=B.backgroundColor,w=B.fontColor,C=B.fontSize,E=B.fontStyle,e=B.padding;this.anchorPosition=g||pQ.TOP_LEFT,this.backgroundColor=Q||"rgba(0, 0, 0, 0.5)",this.fontColor=w||"rgba(255, 255, 255, 1)",this.fontSize=C||14,this.fontStyle=E||"Georgia",this.padding=e||4}return A}(),tv=function(){function A(B,g,Q){Q===void 0&&(Q={}),this.text=typeof B=="string"?[B]:B instanceof A?B.text:B,this.anchor=g,this.options=new zD(Q)}return A.prototype.measureWidth=function(B){var g=this.options.padding;return this.text.map(function(Q){return B.measureText(Q).width}).reduce(function(Q,w){return Q<w?w:Q},0)+2*g},A.prototype.measureHeight=function(){var B=this.options,g=B.fontSize,Q=B.padding;return this.text.length*g+2*Q},A.prototype.getUpperLeft=function(B,g){var Q=this.options.anchorPosition,w=Q===pQ.BOTTOM_RIGHT||Q===pQ.TOP_RIGHT,C=Q===pQ.BOTTOM_LEFT||Q===pQ.BOTTOM_RIGHT,E=this.measureWidth(B),e=this.measureHeight(),t=w?this.anchor.x-E:this.anchor.x,I=C?this.anchor.y-e:this.anchor.y;if(g){var n=g.width,i=g.height,c=Math.max(Math.min(t,n-E),0),Y=Math.max(Math.min(I,i-e),0);return{x:c,y:Y}}return{x:t,y:I}},A.prototype.draw=function(B){var g=Un(B),Q=EQ(g),w=this.options,C=w.backgroundColor,E=w.fontColor,e=w.fontSize,t=w.fontStyle,I=w.padding;Q.font=e+"px "+t;var n=this.measureWidth(Q),i=this.measureHeight();Q.fillStyle=C;var c=this.getUpperLeft(Q,g);Q.fillRect(c.x,c.y,n,i),Q.fillStyle=E,this.text.forEach(function(Y,M){var D=I+c.x,r=I+c.y+(M+1)*e;Q.fillText(Y,D,r)})},A}(),ov=function(){function A(B){B===void 0&&(B={});var g=B.boxColor,Q=B.lineWidth,w=B.label,C=B.drawLabelOptions;this.boxColor=g||"rgba(0, 0, 255, 1)",this.lineWidth=Q||2,this.label=w;var E={anchorPosition:pQ.BOTTOM_LEFT,backgroundColor:this.boxColor};this.drawLabelOptions=new zD(Object.assign({},E,C))}return A}(),Iv=function(){function A(B,g){g===void 0&&(g={}),this.box=new CQ(B),this.options=new ov(g)}return A.prototype.draw=function(B){var g=EQ(B),Q=this.options,w=Q.boxColor,C=Q.lineWidth,E=this.box,e=E.x,t=E.y,I=E.width,n=E.height;g.strokeStyle=w,g.lineWidth=C,g.strokeRect(e,t,I,n);var i=this.options.label;i&&new tv([i],{x:e-C/2,y:t},this.options.drawLabelOptions).draw(B)},A}();function nv(A,B){var g=Array.isArray(B)?B:[B];g.forEach(function(Q){var w=Q instanceof Ng?Q.score:Oe(Q)?Q.detection.score:void 0,C=Q instanceof Ng?Q.box:Oe(Q)?Q.detection.box:new CQ(Q),E=w?""+fD(w):void 0;new Iv(C,{label:E}).draw(A)})}function WD(A){var B=ig.getEnv(),g=B.Image,Q=B.Video;return A instanceof g&&A.complete||A instanceof Q&&A.readyState>=3}function iv(A){return new Promise(function(B,g){if(A instanceof ig.getEnv().Canvas||WD(A))return B();function Q(C){C.currentTarget&&(C.currentTarget.removeEventListener("load",Q),C.currentTarget.removeEventListener("error",w),B(C))}function w(C){C.currentTarget&&(C.currentTarget.removeEventListener("load",Q),C.currentTarget.removeEventListener("error",w),g(C))}A.addEventListener("load",Q),A.addEventListener("error",w)})}function hn(A){var B=ig.getEnv(),g=B.Image,Q=B.Video;return A instanceof g?new Dw(A.naturalWidth,A.naturalHeight):A instanceof Q?new Dw(A.videoWidth,A.videoHeight):new Dw(A.width,A.height)}function Ze(A){var B=A.width,g=A.height,Q=ig.getEnv().createCanvasElement,w=Q();return w.width=B,w.height=g,w}function qe(A,B){var g=ig.getEnv().ImageData;if(!(A instanceof g)&&!WD(A))throw new Error("createCanvasFromMedia - media has not finished loading yet");var Q=hn(A),w=Q.width,C=Q.height,E=Ze({width:w,height:C});return A instanceof g?EQ(E).putImageData(A,0,0):EQ(E).drawImage(A,0,0,w,C),E}function cv(A,B){return JA(this,void 0,void 0,function(){var g,Q,w,C,E,e;return mA(this,function(t){switch(t.label){case 0:return g=ig.getEnv().createCanvasElement(),Q=A.shape.slice(yQ(A)?1:0),w=Q[0],C=Q[1],E=Q[2],e=FA(function(){return A.as3D(w,C,E).toInt()}),[4,Dn.toPixels(e,g)];case 1:return t.sent(),e.dispose(),[2,g]}})})}function bD(A){var B=ig.getEnv(),g=B.Image,Q=B.Canvas,w=B.Video;return A instanceof g||A instanceof Q||A instanceof w}function Yv(A,B,g){g===void 0&&(g=!1);var Q=ig.getEnv(),w=Q.Image,C=Q.Canvas;if(!(A instanceof w||A instanceof C))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var E=hn(A),e=B/Math.max(E.height,E.width),t=e*E.width,I=e*E.height,n=Ze({width:B,height:B}),i=A instanceof C?A:qe(A),c=Math.abs(t-I)/2,Y=g&&t<I?c:0,M=g&&I<t?c:0;return EQ(n).drawImage(i,Y,M,t,I),n}var _e=function(){function A(B,g){var Q=this;if(g===void 0&&(g=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(B))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+B);this._treatAsBatchInput=g,this._batchSize=B.length,B.forEach(function(w,C){if(Ve(w)){Q._imageTensors[C]=w,Q._inputDimensions[C]=w.shape;return}if(yQ(w)){var E=w.shape[0];if(E!==1)throw new Error("NetInput - tf.Tensor4D with batchSize "+E+" passed, but not supported in input array");Q._imageTensors[C]=w,Q._inputDimensions[C]=w.shape.slice(1);return}var e=w instanceof ig.getEnv().Canvas?w:qe(w);Q._canvases[C]=e,Q._inputDimensions[C]=[e.height,e.width,3]})}return Object.defineProperty(A.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"reshapedInputDimensions",{get:function(){var B=this;return QE(this.batchSize,0,1).map(function(g,Q){return B.getReshapedInputDimensions(Q)})},enumerable:!0,configurable:!0}),A.prototype.getInput=function(B){return this.canvases[B]||this.imageTensors[B]},A.prototype.getInputDimensions=function(B){return this._inputDimensions[B]},A.prototype.getInputHeight=function(B){return this._inputDimensions[B][0]},A.prototype.getInputWidth=function(B){return this._inputDimensions[B][1]},A.prototype.getReshapedInputDimensions=function(B){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");var g=this.getInputWidth(B),Q=this.getInputHeight(B);return _P({width:g,height:Q},this.inputSize)},A.prototype.toBatchTensor=function(B,g){var Q=this;return g===void 0&&(g=!0),this._inputSize=B,FA(function(){var w=QE(Q.batchSize,0,1).map(function(E){var e=Q.getInput(E);if(e instanceof HB){var t=yQ(e)?e:e.expandDims();return t=Bv(t,g),(t.shape[1]!==B||t.shape[2]!==B)&&(t=_I.resizeBilinear(t,[B,B])),t.as3D(B,B,3)}if(e instanceof ig.getEnv().Canvas)return Dn.fromPixels(Yv(e,B,g));throw new Error("toBatchTensor - at batchIdx "+E+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+e)}),C=Jg(w.map(function(E){return E.toFloat()})).as4D(Q.batchSize,B,B,3);return C})},A}();function qB(A){return JA(this,void 0,void 0,function(){var B,g,Q;return mA(this,function(w){switch(w.label){case 0:if(A instanceof _e)return[2,A];if(B=Array.isArray(A)?A:[A],!B.length)throw new Error("toNetInput - empty array passed as input");return g=function(C){return Array.isArray(A)?" at input index "+C+":":""},Q=B.map(Un),Q.forEach(function(C,E){if(!bD(C)&&!Ve(C)&&!yQ(C))throw typeof B[E]=="string"?new Error("toNetInput -"+g(E)+" string passed, but could not resolve HTMLElement for element id "+B[E]):new Error("toNetInput -"+g(E)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");if(yQ(C)){var e=C.shape[0];if(e!==1)throw new Error("toNetInput -"+g(E)+" tf.Tensor4D with batchSize "+e+" passed, but not supported in input array")}}),[4,Promise.all(Q.map(function(C){return bD(C)&&iv(C)}))];case 1:return w.sent(),[2,new _e(Q,Array.isArray(A))]}})})}function $e(A,B){return JA(this,void 0,void 0,function(){var g,Q,w,C,E,e,t;return mA(this,function(I){switch(I.label){case 0:return g=ig.getEnv().Canvas,Q=A,A instanceof g?[3,5]:[4,qB(A)];case 1:if(w=I.sent(),w.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return C=w.getInput(0),C instanceof g?(E=C,[3,4]):[3,2];case 2:return[4,cv(C)];case 3:E=I.sent(),I.label=4;case 4:Q=E,I.label=5;case 5:return e=EQ(Q),t=B.map(function(n){return n instanceof Ng?n.forSize(Q.width,Q.height).box.floor():n}).map(function(n){return n.clipAtImageBorders(Q.width,Q.height)}),[2,t.map(function(n){var i=n.x,c=n.y,Y=n.width,M=n.height,D=Ze({width:Y,height:M});return EQ(D).putImageData(e.getImageData(i,c,Y,M),0,0),D})]}})})}function Gn(A,B){return JA(this,void 0,void 0,function(){return mA(this,function(g){if(!Ve(A)&&!yQ(A))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(yQ(A)&&A.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,FA(function(){var Q=A.shape.slice(yQ(A)?1:0),w=Q[0],C=Q[1],E=Q[2],e=B.map(function(I){return I instanceof Ng?I.forSize(C,w).box:I}).map(function(I){return I.clipAtImageBorders(C,w)}),t=e.map(function(I){var n=I.x,i=I.y,c=I.width,Y=I.height;return Or(A.as3D(w,C,E),[i,n,0],[Y,c,E])});return t})]})})}function Mv(A,B){return JA(this,void 0,void 0,function(){var g,Q;return mA(this,function(w){switch(w.label){case 0:return g=ig.getEnv().fetch,[4,g(A,B)];case 1:if(Q=w.sent(),!(Q.status<400))throw new Error("failed to fetch: ("+Q.status+") "+Q.statusText+", from url: "+Q.url);return[2,Q]}})})}function rv(A){return JA(this,void 0,void 0,function(){return mA(this,function(B){switch(B.label){case 0:return[4,Mv(A)];case 1:return[2,B.sent().json()]}})})}function SD(A,B){var g=B+"-weights_manifest.json";if(!A)return{modelBaseUri:"",manifestUri:g};if(A==="/")return{modelBaseUri:"/",manifestUri:"/"+g};var Q=A.startsWith("http://")?"http://":A.startsWith("https://")?"https://":"";A=A.replace(Q,"");var w=A.split("/").filter(function(e){return e}),C=A.endsWith(".json")?w[w.length-1]:g,E=Q+(A.endsWith(".json")?w.slice(0,w.length-1):w).join("/");return E=A.startsWith("/")?"/"+E:E,{modelBaseUri:E,manifestUri:E==="/"?"/"+C:E+"/"+C}}function Dv(A,B){return JA(this,void 0,void 0,function(){var g,Q,w,C;return mA(this,function(E){switch(E.label){case 0:return g=SD(A,B),Q=g.manifestUri,w=g.modelBaseUri,[4,rv(Q)];case 1:return C=E.sent(),[2,GD.loadWeights(C,w)]}})})}function av(A,B,g){g===void 0&&(g=!1);var Q=g?hn(B):B,w=Q.width,C=Q.height;return A.width=w,A.height=C,{width:w,height:C}}var lQ=function(){function A(B){this._name=B,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(A.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),A.prototype.getParamFromPath=function(B){var g=this.traversePropertyPath(B),Q=g.obj,w=g.objProp;return Q[w]},A.prototype.reassignParamFromPath=function(B,g){var Q=this.traversePropertyPath(B),w=Q.obj,C=Q.objProp;w[C].dispose(),w[C]=g},A.prototype.getParamList=function(){var B=this;return this._paramMappings.map(function(g){var Q=g.paramPath;return{path:Q,tensor:B.getParamFromPath(Q)}})},A.prototype.getTrainableParams=function(){return this.getParamList().filter(function(B){return B.tensor instanceof xw})},A.prototype.getFrozenParams=function(){return this.getParamList().filter(function(B){return!(B.tensor instanceof xw)})},A.prototype.variable=function(){var B=this;this.getFrozenParams().forEach(function(g){var Q=g.path,w=g.tensor;B.reassignParamFromPath(Q,w.variable())})},A.prototype.freeze=function(){var B=this;this.getTrainableParams().forEach(function(g){var Q=g.path,w=g.tensor,C=wg(w.dataSync());w.dispose(),B.reassignParamFromPath(Q,C)})},A.prototype.dispose=function(B){B===void 0&&(B=!0),this.getParamList().forEach(function(g){if(B&&g.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+g.path);g.tensor.dispose()}),this._params=void 0},A.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(B){var g=B.tensor;return Array.from(g.dataSync())}).reduce(function(B,g){return B.concat(g)}))},A.prototype.load=function(B){return JA(this,void 0,void 0,function(){return mA(this,function(g){switch(g.label){case 0:return B instanceof Float32Array?(this.extractWeights(B),[2]):[4,this.loadFromUri(B)];case 1:return g.sent(),[2]}})})},A.prototype.loadFromUri=function(B){return JA(this,void 0,void 0,function(){var g;return mA(this,function(Q){switch(Q.label){case 0:if(B&&typeof B!="string")throw new Error(this._name+".loadFromUri - expected model uri");return[4,Dv(B,this.getDefaultModelName())];case 1:return g=Q.sent(),this.loadFromWeightMap(g),[2]}})})},A.prototype.loadFromDisk=function(B){return JA(this,void 0,void 0,function(){var g,Q,w,C,E,e,t,I,n,i;return mA(this,function(c){switch(c.label){case 0:if(B&&typeof B!="string")throw new Error(this._name+".loadFromDisk - expected model file path");return g=ig.getEnv().readFile,Q=SD(B,this.getDefaultModelName()),w=Q.manifestUri,C=Q.modelBaseUri,E=function(Y){return Promise.all(Y.map(function(M){return g(M).then(function(D){return D.buffer})}))},e=GD.weightsLoaderFactory(E),n=(I=JSON).parse,[4,g(w)];case 1:return t=n.apply(I,[c.sent().toString()]),[4,e(t,C)];case 2:return i=c.sent(),this.loadFromWeightMap(i),[2]}})})},A.prototype.loadFromWeightMap=function(B){var g=this.extractParamsFromWeigthMap(B),Q=g.paramMappings,w=g.params;this._paramMappings=Q,this._params=w},A.prototype.extractWeights=function(B){var g=this.extractParams(B),Q=g.paramMappings,w=g.params;this._paramMappings=Q,this._params=w},A.prototype.traversePropertyPath=function(B){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var g=B.split("/").reduce(function(C,E){if(!C.nextObj.hasOwnProperty(E))throw new Error("traversePropertyPath - object does not have property "+E+", for path "+B);return{obj:C.nextObj,objProp:E,nextObj:C.nextObj[E]}},{nextObj:this.params}),Q=g.obj,w=g.objProp;if(!Q||!w||!(Q[w]instanceof HB))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+B);return{obj:Q,objProp:w}},A}();function Rg(A,B,g){return FA(function(){var Q=xI(A,B.depthwise_filter,B.pointwise_filter,g,"same");return Q=BB(Q,B.bias),Q})}function dn(A,B,g){return g===void 0&&(g=!1),FA(function(){var Q=JB(g?BB(jg(A,B.conv0.filters,[2,2],"same"),B.conv0.bias):Rg(A,B.conv0,[2,2])),w=Rg(Q,B.conv1,[1,1]),C=JB(BB(Q,w)),E=Rg(C,B.conv2,[1,1]);return JB(BB(Q,BB(w,E)))})}function At(A,B,g,Q){return g===void 0&&(g=!1),Q===void 0&&(Q=!0),FA(function(){var w=JB(g?BB(jg(A,B.conv0.filters,Q?[2,2]:[1,1],"same"),B.conv0.bias):Rg(A,B.conv0,Q?[2,2]:[1,1])),C=Rg(w,B.conv1,[1,1]),E=JB(BB(w,C)),e=Rg(E,B.conv2,[1,1]),t=JB(BB(w,BB(C,e))),I=Rg(t,B.conv3,[1,1]);return JB(BB(w,BB(C,BB(e,I))))})}function Vg(A,B,g,Q){return g===void 0&&(g="same"),Q===void 0&&(Q=!1),FA(function(){var w=BB(jg(A,B.filters,[1,1],g),B.bias);return Q?JB(w):w})}function UQ(A,B){Object.keys(A).forEach(function(g){B.some(function(Q){return Q.originalPath===g})||A[g].dispose()})}function Bt(A,B){return function(g,Q,w,C){var E=sg(A(g*Q*w*w),[w,w,g,Q]),e=yB(A(Q));return B.push({paramPath:C+"/filters"},{paramPath:C+"/bias"}),{filters:E,bias:e}}}function Hn(A,B){return function(g,Q,w){var C=PQ(A(g*Q),[g,Q]),E=yB(A(Q));return B.push({paramPath:w+"/weights"},{paramPath:w+"/bias"}),{weights:C,bias:E}}}var LD=function(){function A(B,g,Q){this.depthwise_filter=B,this.pointwise_filter=g,this.bias=Q}return A}();function fn(A,B){return function(g,Q,w){var C=sg(A(9*g),[3,3,g,1]),E=sg(A(g*Q),[1,1,g,Q]),e=yB(A(Q));return B.push({paramPath:w+"/depthwise_filter"},{paramPath:w+"/pointwise_filter"},{paramPath:w+"/bias"}),new LD(C,E,e)}}function Jn(A){return function(B){var g=A(B+"/depthwise_filter",4),Q=A(B+"/pointwise_filter",4),w=A(B+"/bias",1);return new LD(g,Q,w)}}function zQ(A,B){return function(g,Q,w){var C=A[g];if(!Le(C,Q))throw new Error("expected weightMap["+g+"] to be a Tensor"+Q+"D, instead have "+C);return B.push({originalPath:g,paramPath:w||g}),C}}function hQ(A){var B=A;function g(w){var C=B.slice(0,w);return B=B.slice(w),C}function Q(){return B}return{extractWeights:g,getRemainingWeights:Q}}function VD(A,B){var g=Bt(A,B),Q=fn(A,B);function w(E,e,t,I){I===void 0&&(I=!1);var n=I?g(E,e,3,t+"/conv0"):Q(E,e,t+"/conv0"),i=Q(e,e,t+"/conv1"),c=Q(e,e,t+"/conv2");return{conv0:n,conv1:i,conv2:c}}function C(E,e,t,I){I===void 0&&(I=!1);var n=w(E,e,t,I),i=n.conv0,c=n.conv1,Y=n.conv2,M=Q(e,e,t+"/conv3");return{conv0:i,conv1:c,conv2:Y,conv3:M}}return{extractDenseBlock3Params:w,extractDenseBlock4Params:C}}function Fv(A){var B=[],g=hQ(A),Q=g.extractWeights,w=g.getRemainingWeights,C=VD(Q,B).extractDenseBlock4Params,E=C(3,32,"dense0",!0),e=C(32,64,"dense1"),t=C(64,128,"dense2"),I=C(128,256,"dense3");if(w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{paramMappings:B,params:{dense0:E,dense1:e,dense2:t,dense3:I}}}function KD(A){return function(B){var g=A(B+"/filters",4),Q=A(B+"/bias",1);return{filters:g,bias:Q}}}function xD(A,B){var g=zQ(A,B),Q=KD(g),w=Jn(g);function C(e,t){t===void 0&&(t=!1);var I=t?Q(e+"/conv0"):w(e+"/conv0"),n=w(e+"/conv1"),i=w(e+"/conv2");return{conv0:I,conv1:n,conv2:i}}function E(e,t){t===void 0&&(t=!1);var I=t?Q(e+"/conv0"):w(e+"/conv0"),n=w(e+"/conv1"),i=w(e+"/conv2"),c=w(e+"/conv3");return{conv0:I,conv1:n,conv2:i,conv3:c}}return{extractDenseBlock3Params:C,extractDenseBlock4Params:E}}function sv(A){var B=[],g=xD(A,B).extractDenseBlock4Params,Q={dense0:g("dense0",!0),dense1:g("dense1"),dense2:g("dense2"),dense3:g("dense3")};return UQ(A,B),{params:Q,paramMappings:B}}var XD=function(A){LA(B,A);function B(){return A.call(this,"FaceFeatureExtractor")||this}return B.prototype.forwardInput=function(g){var Q=this.params;if(!Q)throw new Error("FaceFeatureExtractor - load model before inference");return FA(function(){var w=g.toBatchTensor(112,!0),C=[122.782,117.001,104.298],E=CE(w,C).div(YA(255)),e=At(E,Q.dense0,!0);return e=At(e,Q.dense1),e=At(e,Q.dense2),e=At(e,Q.dense3),e=AE(e,[7,7],[2,2],"valid"),e})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},B.prototype.extractParamsFromWeigthMap=function(g){return sv(g)},B.prototype.extractParams=function(g){return Fv(g)},B}(lQ);function eQ(A,B){return FA(function(){return BB(ye(A,B.weights),B.bias)})}function uv(A,B,g){var Q=[],w=hQ(A),C=w.extractWeights,E=w.getRemainingWeights,e=Hn(C,Q),t=e(B,g,"fc");if(E().length!==0)throw new Error("weights remaing after extract: "+E().length);return{paramMappings:Q,params:{fc:t}}}function lv(A){var B=[],g=zQ(A,B);function Q(C){var E=g(C+"/weights",2),e=g(C+"/bias",1);return{weights:E,bias:e}}var w={fc:Q("fc")};return UQ(A,B),{params:w,paramMappings:B}}function OD(A){var B={},g={};return Object.keys(A).forEach(function(Q){var w=Q.startsWith("fc")?g:B;w[Q]=A[Q]}),{featureExtractorMap:B,classifierMap:g}}var ZD=function(A){LA(B,A);function B(g,Q){var w=A.call(this,g)||this;return w._faceFeatureExtractor=Q,w}return Object.defineProperty(B.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),B.prototype.runNet=function(g){var Q=this,w=this.params;if(!w)throw new Error(this._name+" - load model before inference");return FA(function(){var C=g instanceof _e?Q.faceFeatureExtractor.forwardInput(g):g;return eQ(C.as2D(C.shape[0],-1),w.fc)})},B.prototype.dispose=function(g){g===void 0&&(g=!0),this.faceFeatureExtractor.dispose(g),A.prototype.dispose.call(this,g)},B.prototype.loadClassifierParams=function(g){var Q=this.extractClassifierParams(g),w=Q.params,C=Q.paramMappings;this._params=w,this._paramMappings=C},B.prototype.extractClassifierParams=function(g){return uv(g,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},B.prototype.extractParamsFromWeigthMap=function(g){var Q=OD(g),w=Q.featureExtractorMap,C=Q.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(w),lv(C)},B.prototype.extractParams=function(g){var Q=this.getClassifierChannelsIn(),w=this.getClassifierChannelsOut(),C=w*Q+w,E=g.slice(0,g.length-C),e=g.slice(g.length-C);return this.faceFeatureExtractor.extractWeights(E),this.extractClassifierParams(e)},B}(lQ),qD=["neutral","happy","sad","angry","fearful","disgusted","surprised"],Uv=function(){function A(B){var g=this;if(B.length!==7)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+B.length);qD.forEach(function(Q,w){g[Q]=B[w]})}return A.prototype.asSortedArray=function(){var B=this;return qD.map(function(g){return{expression:g,probability:B[g]}}).sort(function(g,Q){return Q.probability-g.probability})},A}(),hv=function(A){LA(B,A);function B(g){return g===void 0&&(g=new XD),A.call(this,"FaceExpressionNet",g)||this}return B.prototype.forwardInput=function(g){var Q=this;return FA(function(){return aQ(Q.runNet(g))})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.predictExpressions=function(g){return JA(this,void 0,void 0,function(){var Q,w,C,E,e=this;return mA(this,function(t){switch(t.label){case 0:return[4,qB(g)];case 1:return Q=t.sent(),[4,this.forwardInput(Q)];case 2:return w=t.sent(),[4,Promise.all(SB(w).map(function(I){return JA(e,void 0,void 0,function(){var n;return mA(this,function(i){switch(i.label){case 0:return[4,I.data()];case 1:return n=i.sent(),I.dispose(),[2,n]}})})}))];case 3:return C=t.sent(),w.dispose(),E=C.map(function(I){return new Uv(I)}),[2,Q.isBatchInput?E:E[0]]}})})},B.prototype.getDefaultModelName=function(){return"face_expression_model"},B.prototype.getClassifierChannelsIn=function(){return 256},B.prototype.getClassifierChannelsOut=function(){return 7},B}(ZD);function _D(A,B){var g={expressions:B};return Object.assign({},A,g)}function mn(A){return Oe(A)&&A.landmarks instanceof oC&&A.unshiftedLandmarks instanceof oC&&A.alignedRect instanceof Ng}function gt(A,B){var g=A.detection.box,Q=B.shiftBy(g.x,g.y),w=Q.align(),C=A.detection.imageDims,E=new Ng(A.detection.score,w.rescale(C.reverse()),C),e={landmarks:Q,unshiftedLandmarks:B,alignedRect:E};return Object.assign({},A,e)}var Gv=function(){function A(B){B===void 0&&(B={});var g=B.drawLines,Q=g===void 0?!0:g,w=B.drawPoints,C=w===void 0?!0:w,E=B.lineWidth,e=B.lineColor,t=B.pointSize,I=B.pointColor;this.drawLines=Q,this.drawPoints=C,this.lineWidth=E||1,this.pointSize=t||2,this.lineColor=e||"rgba(0, 255, 255, 1)",this.pointColor=I||"rgba(255, 0, 255, 1)"}return A}(),dv=function(){function A(B,g){g===void 0&&(g={}),this.faceLandmarks=B,this.options=new Gv(g)}return A.prototype.draw=function(B){var g=EQ(B),Q=this.options,w=Q.drawLines,C=Q.drawPoints,E=Q.lineWidth,e=Q.lineColor,t=Q.pointSize,I=Q.pointColor;if(w&&this.faceLandmarks instanceof RD&&(g.strokeStyle=e,g.lineWidth=E,rw(g,this.faceLandmarks.getJawOutline()),rw(g,this.faceLandmarks.getLeftEyeBrow()),rw(g,this.faceLandmarks.getRightEyeBrow()),rw(g,this.faceLandmarks.getNose()),rw(g,this.faceLandmarks.getLeftEye(),!0),rw(g,this.faceLandmarks.getRightEye(),!0),rw(g,this.faceLandmarks.getMouth(),!0)),C){g.strokeStyle=I,g.fillStyle=I;var n=function(i){g.beginPath(),g.arc(i.x,i.y,t,0,2*Math.PI),g.fill()};this.faceLandmarks.positions.forEach(n)}},A}();function Hv(A,B){var g=Array.isArray(B)?B:[B];g.forEach(function(Q){var w=Q instanceof oC?Q:mn(Q)?Q.landmarks:void 0;if(!w)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>> or array thereof");new dv(w).draw(A)})}function fv(A,B){var g=Bt(A,B),Q=fn(A,B);function w(E,e,t){var I=Q(E,e,t+"/separable_conv0"),n=Q(e,e,t+"/separable_conv1"),i=g(E,e,1,t+"/expansion_conv");return{separable_conv0:I,separable_conv1:n,expansion_conv:i}}function C(E,e){var t=Q(E,E,e+"/separable_conv0"),I=Q(E,E,e+"/separable_conv1"),n=Q(E,E,e+"/separable_conv2");return{separable_conv0:t,separable_conv1:I,separable_conv2:n}}return{extractConvParams:g,extractSeparableConvParams:Q,extractReductionBlockParams:w,extractMainBlockParams:C}}function Jv(A,B){var g=[],Q=hQ(A),w=Q.extractWeights,C=Q.getRemainingWeights,E=fv(w,g),e=E.extractConvParams,t=E.extractSeparableConvParams,I=E.extractReductionBlockParams,n=E.extractMainBlockParams,i=e(3,32,3,"entry_flow/conv_in"),c=I(32,64,"entry_flow/reduction_block_0"),Y=I(64,128,"entry_flow/reduction_block_1"),M={conv_in:i,reduction_block_0:c,reduction_block_1:Y},D={};QE(B,0,1).forEach(function(s){D["main_block_"+s]=n(128,"middle_flow/main_block_"+s)});var r=I(128,256,"exit_flow/reduction_block"),F=t(256,512,"exit_flow/separable_conv"),u={reduction_block:r,separable_conv:F};if(C().length!==0)throw new Error("weights remaing after extract: "+C().length);return{paramMappings:g,params:{entry_flow:M,middle_flow:D,exit_flow:u}}}function mv(A,B){var g=zQ(A,B),Q=KD(g),w=Jn(g);function C(e){var t=w(e+"/separable_conv0"),I=w(e+"/separable_conv1"),n=Q(e+"/expansion_conv");return{separable_conv0:t,separable_conv1:I,expansion_conv:n}}function E(e){var t=w(e+"/separable_conv0"),I=w(e+"/separable_conv1"),n=w(e+"/separable_conv2");return{separable_conv0:t,separable_conv1:I,separable_conv2:n}}return{extractConvParams:Q,extractSeparableConvParams:w,extractReductionBlockParams:C,extractMainBlockParams:E}}function Nv(A,B){var g=[],Q=mv(A,g),w=Q.extractConvParams,C=Q.extractSeparableConvParams,E=Q.extractReductionBlockParams,e=Q.extractMainBlockParams,t=w("entry_flow/conv_in"),I=E("entry_flow/reduction_block_0"),n=E("entry_flow/reduction_block_1"),i={conv_in:t,reduction_block_0:I,reduction_block_1:n},c={};QE(B,0,1).forEach(function(r){c["main_block_"+r]=e("middle_flow/main_block_"+r)});var Y=E("exit_flow/reduction_block"),M=C("exit_flow/separable_conv"),D={reduction_block:Y,separable_conv:M};return UQ(A,g),{params:{entry_flow:i,middle_flow:c,exit_flow:D},paramMappings:g}}function $D(A,B,g){return BB(jg(A,B.filters,g,"same"),B.bias)}function Nn(A,B,g){g===void 0&&(g=!0);var Q=g?JB(A):A;return Q=Rg(Q,B.separable_conv0,[1,1]),Q=Rg(JB(Q),B.separable_conv1,[1,1]),Q=ZB(Q,[3,3],[2,2],"same"),Q=BB(Q,$D(A,B.expansion_conv,[2,2])),Q}function Rv(A,B){var g=Rg(JB(A),B.separable_conv0,[1,1]);return g=Rg(JB(g),B.separable_conv1,[1,1]),g=Rg(JB(g),B.separable_conv2,[1,1]),g=BB(g,A),g}var Pv=function(A){LA(B,A);function B(g){var Q=A.call(this,"TinyXception")||this;return Q._numMainBlocks=g,Q}return B.prototype.forwardInput=function(g){var Q=this,w=this.params;if(!w)throw new Error("TinyXception - load model before inference");return FA(function(){var C=g.toBatchTensor(112,!0),E=[122.782,117.001,104.298],e=CE(C,E).div(YA(256)),t=JB($D(e,w.entry_flow.conv_in,[2,2]));return t=Nn(t,w.entry_flow.reduction_block_0,!1),t=Nn(t,w.entry_flow.reduction_block_1),QE(Q._numMainBlocks,0,1).forEach(function(I){t=Rv(t,w.middle_flow["main_block_"+I])}),t=Nn(t,w.exit_flow.reduction_block),t=JB(Rg(t,w.exit_flow.separable_conv,[1,1])),t})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.getDefaultModelName=function(){return"tiny_xception_model"},B.prototype.extractParamsFromWeigthMap=function(g){return Nv(g,this._numMainBlocks)},B.prototype.extractParams=function(g){return Jv(g,this._numMainBlocks)},B}(lQ);function vv(A){var B=[],g=hQ(A),Q=g.extractWeights,w=g.getRemainingWeights,C=Hn(Q,B),E=C(512,1,"fc/age"),e=C(512,2,"fc/gender");if(w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{paramMappings:B,params:{fc:{age:E,gender:e}}}}function kv(A){var B=[],g=zQ(A,B);function Q(C){var E=g(C+"/weights",2),e=g(C+"/bias",1);return{weights:E,bias:e}}var w={fc:{age:Q("fc/age"),gender:Q("fc/gender")}};return UQ(A,B),{params:w,paramMappings:B}}var Qt;(function(A){A.FEMALE="female",A.MALE="male"})(Qt||(Qt={}));var Tv=function(A){LA(B,A);function B(g){g===void 0&&(g=new Pv(2));var Q=A.call(this,"AgeGenderNet")||this;return Q._faceFeatureExtractor=g,Q}return Object.defineProperty(B.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),B.prototype.runNet=function(g){var Q=this,w=this.params;if(!w)throw new Error(this._name+" - load model before inference");return FA(function(){var C=g instanceof _e?Q.faceFeatureExtractor.forwardInput(g):g,E=AE(C,[7,7],[2,2],"valid").as2D(C.shape[0],-1),e=eQ(E,w.fc.age).as1D(),t=eQ(E,w.fc.gender);return{age:e,gender:t}})},B.prototype.forwardInput=function(g){var Q=this;return FA(function(){var w=Q.runNet(g),C=w.age,E=w.gender;return{age:C,gender:aQ(E)}})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.predictAgeAndGender=function(g){return JA(this,void 0,void 0,function(){var Q,w,C,E,e,t,I=this;return mA(this,function(n){switch(n.label){case 0:return[4,qB(g)];case 1:return Q=n.sent(),[4,this.forwardInput(Q)];case 2:return w=n.sent(),C=SB(w.age),E=SB(w.gender),e=C.map(function(i,c){return{ageTensor:i,genderTensor:E[c]}}),[4,Promise.all(e.map(function(i){var c=i.ageTensor,Y=i.genderTensor;return JA(I,void 0,void 0,function(){var M,D,r,F,u;return mA(this,function(s){switch(s.label){case 0:return[4,c.data()];case 1:return M=s.sent()[0],[4,Y.data()];case 2:return D=s.sent()[0],r=D>.5,F=r?Qt.MALE:Qt.FEMALE,u=r?D:1-D,c.dispose(),Y.dispose(),[2,{age:M,gender:F,genderProbability:u}]}})})}))];case 3:return t=n.sent(),w.age.dispose(),w.gender.dispose(),[2,Q.isBatchInput?t:t[0]]}})})},B.prototype.getDefaultModelName=function(){return"age_gender_model"},B.prototype.dispose=function(g){g===void 0&&(g=!0),this.faceFeatureExtractor.dispose(g),A.prototype.dispose.call(this,g)},B.prototype.loadClassifierParams=function(g){var Q=this.extractClassifierParams(g),w=Q.params,C=Q.paramMappings;this._params=w,this._paramMappings=C},B.prototype.extractClassifierParams=function(g){return vv(g)},B.prototype.extractParamsFromWeigthMap=function(g){var Q=OD(g),w=Q.featureExtractorMap,C=Q.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(w),kv(C)},B.prototype.extractParams=function(g){var Q=1539,w=g.slice(0,g.length-Q),C=g.slice(g.length-Q);return this.faceFeatureExtractor.extractWeights(w),this.extractClassifierParams(C)},B}(lQ),Aa=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.postProcess=function(g,Q,w){var C=w.map(function(e){var t=e.width,I=e.height,n=Q/Math.max(I,t);return{width:t*n,height:I*n}}),E=C.length;return FA(function(){var e=function(c,Y){return Jg([QQ([68],c),QQ([68],Y)],1).as2D(1,136).as1D()},t=function(c,Y){var M=C[c],D=M.width,r=M.height;return Y(D,r)?Math.abs(D-r)/2:0},I=function(c){return t(c,function(Y,M){return Y<M})},n=function(c){return t(c,function(Y,M){return M<Y})},i=g.mul(QQ([E,136],Q)).sub(Jg(Array.from(Array(E),function(c,Y){return e(I(Y),n(Y))}))).div(Jg(Array.from(Array(E),function(c,Y){return e(C[Y].width,C[Y].height)})));return i})},B.prototype.forwardInput=function(g){var Q=this;return FA(function(){var w=Q.runNet(g);return Q.postProcess(w,g.inputSize,g.inputDimensions.map(function(C){var E=C[0],e=C[1];return{height:E,width:e}}))})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.detectLandmarks=function(g){return JA(this,void 0,void 0,function(){var Q,w,C,E=this;return mA(this,function(e){switch(e.label){case 0:return[4,qB(g)];case 1:return Q=e.sent(),w=FA(function(){return SB(E.forwardInput(Q))}),[4,Promise.all(w.map(function(t,I){return JA(E,void 0,void 0,function(){var n,i,c,Y,M;return mA(this,function(D){switch(D.label){case 0:return c=(i=Array).from,[4,t.data()];case 1:return n=c.apply(i,[D.sent()]),Y=n.filter(function(r,F){return HD(F)}),M=n.filter(function(r,F){return!HD(F)}),[2,new RD(Array(68).fill(0).map(function(r,F){return new iB(Y[F],M[F])}),{height:Q.getInputHeight(I),width:Q.getInputWidth(I)})]}})})}))];case 2:return C=e.sent(),w.forEach(function(t){return t.dispose()}),[2,Q.isBatchInput?C:C[0]]}})})},B.prototype.getClassifierChannelsOut=function(){return 136},B}(ZD),Ba=function(A){LA(B,A);function B(g){return g===void 0&&(g=new XD),A.call(this,"FaceLandmark68Net",g)||this}return B.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},B.prototype.getClassifierChannelsIn=function(){return 256},B}(Aa);function jv(A){var B=[],g=xD(A,B).extractDenseBlock3Params,Q={dense0:g("dense0",!0),dense1:g("dense1"),dense2:g("dense2")};return UQ(A,B),{params:Q,paramMappings:B}}function yv(A){var B=[],g=hQ(A),Q=g.extractWeights,w=g.getRemainingWeights,C=VD(Q,B).extractDenseBlock3Params,E=C(3,32,"dense0",!0),e=C(32,64,"dense1"),t=C(64,128,"dense2");if(w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{paramMappings:B,params:{dense0:E,dense1:e,dense2:t}}}var pv=function(A){LA(B,A);function B(){return A.call(this,"TinyFaceFeatureExtractor")||this}return B.prototype.forwardInput=function(g){var Q=this.params;if(!Q)throw new Error("TinyFaceFeatureExtractor - load model before inference");return FA(function(){var w=g.toBatchTensor(112,!0),C=[122.782,117.001,104.298],E=CE(w,C).div(YA(255)),e=dn(E,Q.dense0,!0);return e=dn(e,Q.dense1),e=dn(e,Q.dense2),e=AE(e,[14,14],[2,2],"valid"),e})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},B.prototype.extractParamsFromWeigthMap=function(g){return jv(g)},B.prototype.extractParams=function(g){return yv(g)},B}(lQ),zv=function(A){LA(B,A);function B(g){return g===void 0&&(g=new pv),A.call(this,"FaceLandmark68TinyNet",g)||this}return B.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},B.prototype.getClassifierChannelsIn=function(){return 128},B}(Aa);(function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B})(Ba);function Wv(A,B){return BB(og(A,B.weights),B.biases)}function Rn(A,B,g,Q,w){w===void 0&&(w="same");var C=B.conv,E=C.filters,e=C.bias,t=jg(A,E,g,w);return t=BB(t,e),t=Wv(t,B.scale),Q?JB(t):t}function bv(A,B){return Rn(A,B,[1,1],!0)}function ga(A,B){return Rn(A,B,[1,1],!1)}function Qa(A,B){return Rn(A,B,[2,2],!0,"valid")}function Sv(A,B){function g(e,t,I){var n=A(e),i=n.length/(t*I*I);if(qP(i))throw new Error("depth has to be an integer: "+i+", weights.length: "+n.length+", numFilters: "+t+", filterSize: "+I);return FA(function(){return kQ(sg(n,[t,i,I,I]),[2,3,1,0])})}function Q(e,t,I,n){var i=g(e,t,I),c=yB(A(t));return B.push({paramPath:n+"/filters"},{paramPath:n+"/bias"}),{filters:i,bias:c}}function w(e,t){var I=yB(A(e)),n=yB(A(e));return B.push({paramPath:t+"/weights"},{paramPath:t+"/biases"}),{weights:I,biases:n}}function C(e,t,I,n){var i=Q(e,t,I,n+"/conv"),c=w(t,n+"/scale");return{conv:i,scale:c}}function E(e,t,I,n,i){i===void 0&&(i=!1);var c=C((i?.5:1)*e,t,I,n+"/conv1"),Y=C(e,t,I,n+"/conv2");return{conv1:c,conv2:Y}}return{extractConvLayerParams:C,extractResidualLayerParams:E}}function Lv(A){var B=hQ(A),g=B.extractWeights,Q=B.getRemainingWeights,w=[],C=Sv(g,w),E=C.extractConvLayerParams,e=C.extractResidualLayerParams,t=E(4704,32,7,"conv32_down"),I=e(9216,32,3,"conv32_1"),n=e(9216,32,3,"conv32_2"),i=e(9216,32,3,"conv32_3"),c=e(36864,64,3,"conv64_down",!0),Y=e(36864,64,3,"conv64_1"),M=e(36864,64,3,"conv64_2"),D=e(36864,64,3,"conv64_3"),r=e(147456,128,3,"conv128_down",!0),F=e(147456,128,3,"conv128_1"),u=e(147456,128,3,"conv128_2"),s=e(589824,256,3,"conv256_down",!0),a=e(589824,256,3,"conv256_1"),l=e(589824,256,3,"conv256_2"),U=e(589824,256,3,"conv256_down_out"),G=FA(function(){return kQ(PQ(g(256*128),[128,256]),[1,0])});if(w.push({paramPath:"fc"}),Q().length!==0)throw new Error("weights remaing after extract: "+Q().length);var d={conv32_down:t,conv32_1:I,conv32_2:n,conv32_3:i,conv64_down:c,conv64_1:Y,conv64_2:M,conv64_3:D,conv128_down:r,conv128_1:F,conv128_2:u,conv256_down:s,conv256_1:a,conv256_2:l,conv256_down_out:U,fc:G};return{params:d,paramMappings:w}}function Vv(A,B){var g=zQ(A,B);function Q(E){var e=g(E+"/scale/weights",1),t=g(E+"/scale/biases",1);return{weights:e,biases:t}}function w(E){var e=g(E+"/conv/filters",4),t=g(E+"/conv/bias",1),I=Q(E);return{conv:{filters:e,bias:t},scale:I}}function C(E){return{conv1:w(E+"/conv1"),conv2:w(E+"/conv2")}}return{extractConvLayerParams:w,extractResidualLayerParams:C}}function Kv(A){var B=[],g=Vv(A,B),Q=g.extractConvLayerParams,w=g.extractResidualLayerParams,C=Q("conv32_down"),E=w("conv32_1"),e=w("conv32_2"),t=w("conv32_3"),I=w("conv64_down"),n=w("conv64_1"),i=w("conv64_2"),c=w("conv64_3"),Y=w("conv128_down"),M=w("conv128_1"),D=w("conv128_2"),r=w("conv256_down"),F=w("conv256_1"),u=w("conv256_2"),s=w("conv256_down_out"),a=A.fc;if(B.push({originalPath:"fc",paramPath:"fc"}),!ZP(a))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+a);var l={conv32_down:C,conv32_1:E,conv32_2:e,conv32_3:t,conv64_down:I,conv64_1:n,conv64_2:i,conv64_3:c,conv128_down:Y,conv128_1:M,conv128_2:D,conv256_down:r,conv256_1:F,conv256_2:u,conv256_down_out:s,fc:a};return UQ(A,B),{params:l,paramMappings:B}}function tQ(A,B){var g=bv(A,B.conv1);return g=ga(g,B.conv2),g=BB(g,A),g=JB(g),g}function wt(A,B){var g=Qa(A,B.conv1);g=ga(g,B.conv2);var Q=AE(A,2,2,"valid"),w=GB(Q.shape),C=Q.shape[3]!==g.shape[3],E=Q.shape[1]!==g.shape[1]||Q.shape[2]!==g.shape[2];if(E){var e=gE(g.shape);e[1]=1;var t=GB(e);g=bB([g,t],1);var I=gE(g.shape);I[2]=1;var n=GB(I);g=bB([g,n],2)}return Q=C?bB([Q,w],3):Q,g=BB(Q,g),g=JB(g),g}var xv=function(A){LA(B,A);function B(){return A.call(this,"FaceRecognitionNet")||this}return B.prototype.forwardInput=function(g){var Q=this.params;if(!Q)throw new Error("FaceRecognitionNet - load model before inference");return FA(function(){var w=g.toBatchTensor(150,!0).toFloat(),C=[122.782,117.001,104.298],E=CE(w,C).div(YA(256)),e=Qa(E,Q.conv32_down);e=ZB(e,3,2,"valid"),e=tQ(e,Q.conv32_1),e=tQ(e,Q.conv32_2),e=tQ(e,Q.conv32_3),e=wt(e,Q.conv64_down),e=tQ(e,Q.conv64_1),e=tQ(e,Q.conv64_2),e=tQ(e,Q.conv64_3),e=wt(e,Q.conv128_down),e=tQ(e,Q.conv128_1),e=tQ(e,Q.conv128_2),e=wt(e,Q.conv256_down),e=tQ(e,Q.conv256_1),e=tQ(e,Q.conv256_2),e=wt(e,Q.conv256_down_out);var t=e.mean([1,2]),I=ye(t,Q.fc);return I})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.computeFaceDescriptor=function(g){return JA(this,void 0,void 0,function(){var Q,w,C,E=this;return mA(this,function(e){switch(e.label){case 0:return[4,qB(g)];case 1:return Q=e.sent(),w=FA(function(){return SB(E.forwardInput(Q))}),[4,Promise.all(w.map(function(t){return t.data()}))];case 2:return C=e.sent(),w.forEach(function(t){return t.dispose()}),[2,Q.isBatchInput?C:C[0]]}})})},B.prototype.getDefaultModelName=function(){return"face_recognition_model"},B.prototype.extractParamsFromWeigthMap=function(g){return Kv(g)},B.prototype.extractParams=function(g){return Lv(g)},B}(lQ);function wa(A,B){var g={descriptor:B};return Object.assign({},A,g)}function Ca(A,B){var g={age:B};return Object.assign({},A,g)}function Ea(A,B,g){var Q={gender:B,genderProbability:g};return Object.assign({},A,Q)}var ea=function(){function A(B){var g=B===void 0?{}:B,Q=g.minFaceSize,w=g.scaleFactor,C=g.maxNumScales,E=g.scoreThresholds,e=g.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=Q||20,this._scaleFactor=w||.709,this._maxNumScales=C||10,this._scoreThresholds=E||[.6,.7,.7],this._scaleSteps=e,typeof this._minFaceSize!="number"||this._minFaceSize<0)throw new Error(this._name+" - expected minFaceSize to be a number > 0");if(typeof this._scaleFactor!="number"||this._scaleFactor<=0||this._scaleFactor>=1)throw new Error(this._name+" - expected scaleFactor to be a number between 0 and 1");if(typeof this._maxNumScales!="number"||this._maxNumScales<0)throw new Error(this._name+" - expected maxNumScales to be a number > 0");if(!Array.isArray(this._scoreThresholds)||this._scoreThresholds.length!==3||this._scoreThresholds.some(function(t){return typeof t!="number"}))throw new Error(this._name+" - expected scoreThresholds to be an array of numbers of length 3");if(this._scaleSteps&&(!Array.isArray(this._scaleSteps)||this._scaleSteps.some(function(t){return typeof t!="number"})))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(A.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),A}();function Xv(A,B){function g(t,I){var n=sg(A(9*t),[3,3,t,1]),i=yB(A(t)),c=yB(A(t)),Y=yB(A(t)),M=yB(A(t));return B.push({paramPath:I+"/filters"},{paramPath:I+"/batch_norm_scale"},{paramPath:I+"/batch_norm_offset"},{paramPath:I+"/batch_norm_mean"},{paramPath:I+"/batch_norm_variance"}),{filters:n,batch_norm_scale:i,batch_norm_offset:c,batch_norm_mean:Y,batch_norm_variance:M}}function Q(t,I,n,i,c){var Y=sg(A(t*I*n*n),[n,n,t,I]),M=yB(A(I));return B.push({paramPath:i+"/filters"},{paramPath:i+"/"+(c?"batch_norm_offset":"bias")}),{filters:Y,bias:M}}function w(t,I,n,i){var c=Q(t,I,n,i,!0),Y=c.filters,M=c.bias;return{filters:Y,batch_norm_offset:M}}function C(t,I,n){var i=g(t,n+"/depthwise_conv"),c=w(t,I,1,n+"/pointwise_conv");return{depthwise_conv:i,pointwise_conv:c}}function E(){var t=w(3,32,3,"mobilenetv1/conv_0"),I=C(32,64,"mobilenetv1/conv_1"),n=C(64,128,"mobilenetv1/conv_2"),i=C(128,128,"mobilenetv1/conv_3"),c=C(128,256,"mobilenetv1/conv_4"),Y=C(256,256,"mobilenetv1/conv_5"),M=C(256,512,"mobilenetv1/conv_6"),D=C(512,512,"mobilenetv1/conv_7"),r=C(512,512,"mobilenetv1/conv_8"),F=C(512,512,"mobilenetv1/conv_9"),u=C(512,512,"mobilenetv1/conv_10"),s=C(512,512,"mobilenetv1/conv_11"),a=C(512,1024,"mobilenetv1/conv_12"),l=C(1024,1024,"mobilenetv1/conv_13");return{conv_0:t,conv_1:I,conv_2:n,conv_3:i,conv_4:c,conv_5:Y,conv_6:M,conv_7:D,conv_8:r,conv_9:F,conv_10:u,conv_11:s,conv_12:a,conv_13:l}}function e(){var t=w(1024,256,1,"prediction_layer/conv_0"),I=w(256,512,3,"prediction_layer/conv_1"),n=w(512,128,1,"prediction_layer/conv_2"),i=w(128,256,3,"prediction_layer/conv_3"),c=w(256,128,1,"prediction_layer/conv_4"),Y=w(128,256,3,"prediction_layer/conv_5"),M=w(256,64,1,"prediction_layer/conv_6"),D=w(64,128,3,"prediction_layer/conv_7"),r=Q(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),F=Q(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),u=Q(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),s=Q(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),a=Q(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),l=Q(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),U=Q(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),G=Q(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),d=Q(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),H=Q(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),h=Q(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),f=Q(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),J={box_encoding_predictor:r,class_predictor:F},y={box_encoding_predictor:u,class_predictor:s},m={box_encoding_predictor:a,class_predictor:l},k={box_encoding_predictor:U,class_predictor:G},z={box_encoding_predictor:d,class_predictor:H},R={box_encoding_predictor:h,class_predictor:f};return{conv_0:t,conv_1:I,conv_2:n,conv_3:i,conv_4:c,conv_5:Y,conv_6:M,conv_7:D,box_predictor_0:J,box_predictor_1:y,box_predictor_2:m,box_predictor_3:k,box_predictor_4:z,box_predictor_5:R}}return{extractMobilenetV1Params:E,extractPredictionLayerParams:e}}function Ov(A){var B=[],g=hQ(A),Q=g.extractWeights,w=g.getRemainingWeights,C=Xv(Q,B),E=C.extractMobilenetV1Params,e=C.extractPredictionLayerParams,t=E(),I=e(),n=FI(Q(5118*4),[1,5118,4]),i={extra_dim:n};if(B.push({paramPath:"output_layer/extra_dim"}),w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{params:{mobilenetv1:t,prediction_layer:I,output_layer:i},paramMappings:B}}function Zv(A,B){var g=zQ(A,B);function Q(I,n,i){var c=g(I+"/Conv2d_"+n+"_pointwise/weights",4,i+"/filters"),Y=g(I+"/Conv2d_"+n+"_pointwise/convolution_bn_offset",1,i+"/batch_norm_offset");return{filters:c,batch_norm_offset:Y}}function w(I){var n="mobilenetv1/conv_"+I,i="MobilenetV1/Conv2d_"+I+"_depthwise",c=n+"/depthwise_conv",Y=n+"/pointwise_conv",M=g(i+"/depthwise_weights",4,c+"/filters"),D=g(i+"/BatchNorm/gamma",1,c+"/batch_norm_scale"),r=g(i+"/BatchNorm/beta",1,c+"/batch_norm_offset"),F=g(i+"/BatchNorm/moving_mean",1,c+"/batch_norm_mean"),u=g(i+"/BatchNorm/moving_variance",1,c+"/batch_norm_variance");return{depthwise_conv:{filters:M,batch_norm_scale:D,batch_norm_offset:r,batch_norm_mean:F,batch_norm_variance:u},pointwise_conv:Q("MobilenetV1",I,Y)}}function C(){return{conv_0:Q("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:w(1),conv_2:w(2),conv_3:w(3),conv_4:w(4),conv_5:w(5),conv_6:w(6),conv_7:w(7),conv_8:w(8),conv_9:w(9),conv_10:w(10),conv_11:w(11),conv_12:w(12),conv_13:w(13)}}function E(I,n){var i=g(I+"/weights",4,n+"/filters"),c=g(I+"/biases",1,n+"/bias");return{filters:i,bias:c}}function e(I){var n=E("Prediction/BoxPredictor_"+I+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+I+"/box_encoding_predictor"),i=E("Prediction/BoxPredictor_"+I+"/ClassPredictor","prediction_layer/box_predictor_"+I+"/class_predictor");return{box_encoding_predictor:n,class_predictor:i}}function t(){return{conv_0:Q("Prediction",0,"prediction_layer/conv_0"),conv_1:Q("Prediction",1,"prediction_layer/conv_1"),conv_2:Q("Prediction",2,"prediction_layer/conv_2"),conv_3:Q("Prediction",3,"prediction_layer/conv_3"),conv_4:Q("Prediction",4,"prediction_layer/conv_4"),conv_5:Q("Prediction",5,"prediction_layer/conv_5"),conv_6:Q("Prediction",6,"prediction_layer/conv_6"),conv_7:Q("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:e(0),box_predictor_1:e(1),box_predictor_2:e(2),box_predictor_3:e(3),box_predictor_4:e(4),box_predictor_5:e(5)}}return{extractMobilenetV1Params:C,extractPredictionLayerParams:t}}function qv(A){var B=[],g=Zv(A,B),Q=g.extractMobilenetV1Params,w=g.extractPredictionLayerParams,C=A["Output/extra_dim"];if(B.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!Ve(C))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+C);var E={mobilenetv1:Q(),prediction_layer:w(),output_layer:{extra_dim:C}};return UQ(A,B),{params:E,paramMappings:B}}function oQ(A,B,g){return FA(function(){var Q=jg(A,B.filters,g,"same");return Q=BB(Q,B.batch_norm_offset),WI(Q,0,6)})}var _v=.0010000000474974513;function $v(A,B,g){return FA(function(){var Q=je(A,B.filters,g,"same");return Q=Rr(Q,B.batch_norm_mean,B.batch_norm_variance,B.batch_norm_offset,B.batch_norm_scale,_v),WI(Q,0,6)})}function A4(A){return[2,4,6,12].some(function(B){return B===A})?[2,2]:[1,1]}function B4(A,B){return FA(function(){var g=null,Q=oQ(A,B.conv_0,[2,2]),w=[B.conv_1,B.conv_2,B.conv_3,B.conv_4,B.conv_5,B.conv_6,B.conv_7,B.conv_8,B.conv_9,B.conv_10,B.conv_11,B.conv_12,B.conv_13];if(w.forEach(function(C,E){var e=E+1,t=A4(e);Q=$v(Q,C.depthwise_conv,t),Q=oQ(Q,C.pointwise_conv,[1,1]),e===11&&(g=Q)}),g===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:Q,conv11:g}})}function g4(A,B,g,Q,w){var C=A.shape[0],E=Math.min(g,C),e=B.map(function(n,i){return{score:n,boxIndex:i}}).filter(function(n){return n.score>w}).sort(function(n,i){return i.score-n.score}),t=function(n){return n<=Q?1:0},I=[];return e.forEach(function(n){if(!(I.length>=E)){for(var i=n.score,c=I.length-1;c>=0;--c){var Y=Q4(A,n.boxIndex,I[c]);if(Y!==0&&(n.score*=t(Y),n.score<=w))break}i===n.score&&I.push(n.boxIndex)}}),I}function Q4(A,B,g){var Q=A.arraySync(),w=Math.min(Q[B][0],Q[B][2]),C=Math.min(Q[B][1],Q[B][3]),E=Math.max(Q[B][0],Q[B][2]),e=Math.max(Q[B][1],Q[B][3]),t=Math.min(Q[g][0],Q[g][2]),I=Math.min(Q[g][1],Q[g][3]),n=Math.max(Q[g][0],Q[g][2]),i=Math.max(Q[g][1],Q[g][3]),c=(E-w)*(e-C),Y=(n-t)*(i-I);if(c<=0||Y<=0)return 0;var M=Math.max(w,t),D=Math.max(C,I),r=Math.min(E,n),F=Math.min(e,i),u=Math.max(r-M,0)*Math.max(F-D,0);return u/(c+Y-u)}function w4(A){var B=SB(kQ(A,[1,0])),g=[VB(B[2],B[0]),VB(B[3],B[1])],Q=[BB(B[0],Lg(g[0],YA(2))),BB(B[1],Lg(g[1],YA(2)))];return{sizes:g,centers:Q}}function C4(A,B){var g=w4(A),Q=g.sizes,w=g.centers,C=SB(kQ(B,[1,0])),E=Lg(og(bI(Lg(C[2],YA(5))),Q[0]),YA(2)),e=BB(og(Lg(C[0],YA(10)),Q[0]),w[0]),t=Lg(og(bI(Lg(C[3],YA(5))),Q[1]),YA(2)),I=BB(og(Lg(C[1],YA(10)),Q[1]),w[1]);return kQ(Jg([VB(e,E),VB(I,t),BB(e,E),BB(I,t)]),[1,0])}function E4(A,B,g){return FA(function(){var Q=A.shape[0],w=C4(bg(Zw(g.extra_dim,[Q,1,1]),[-1,4]),bg(A,[-1,4]));w=bg(w,[Q,w.shape[0]/Q,4]);var C=fr(wQ(B,[0,0,1],[-1,-1,-1])),E=wQ(C,[0,0,0],[-1,-1,1]);E=bg(E,[Q,E.shape[1]]);var e=SB(w),t=SB(E);return{boxes:e,scores:t}})}function IC(A,B){return FA(function(){var g=A.shape[0],Q=bg(Vg(A,B.box_encoding_predictor),[g,-1,1,4]),w=bg(Vg(A,B.class_predictor),[g,-1,3]);return{boxPredictionEncoding:Q,classPrediction:w}})}function e4(A,B,g){return FA(function(){var Q=oQ(A,g.conv_0,[1,1]),w=oQ(Q,g.conv_1,[2,2]),C=oQ(w,g.conv_2,[1,1]),E=oQ(C,g.conv_3,[2,2]),e=oQ(E,g.conv_4,[1,1]),t=oQ(e,g.conv_5,[2,2]),I=oQ(t,g.conv_6,[1,1]),n=oQ(I,g.conv_7,[2,2]),i=IC(B,g.box_predictor_0),c=IC(A,g.box_predictor_1),Y=IC(w,g.box_predictor_2),M=IC(E,g.box_predictor_3),D=IC(t,g.box_predictor_4),r=IC(n,g.box_predictor_5),F=bB([i.boxPredictionEncoding,c.boxPredictionEncoding,Y.boxPredictionEncoding,M.boxPredictionEncoding,D.boxPredictionEncoding,r.boxPredictionEncoding],1),u=bB([i.classPrediction,c.classPrediction,Y.classPrediction,M.classPrediction,D.classPrediction,r.classPrediction],1);return{boxPredictions:F,classPredictions:u}})}var Ct=function(){function A(B){var g=B===void 0?{}:B,Q=g.minConfidence,w=g.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=Q||.5,this._maxResults=w||100,typeof this._minConfidence!="number"||this._minConfidence<=0||this._minConfidence>=1)throw new Error(this._name+" - expected minConfidence to be a number between 0 and 1");if(typeof this._maxResults!="number")throw new Error(this._name+" - expected maxResults to be a number")}return Object.defineProperty(A.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),A}(),ta=function(A){LA(B,A);function B(){return A.call(this,"SsdMobilenetv1")||this}return B.prototype.forwardInput=function(g){var Q=this.params;if(!Q)throw new Error("SsdMobilenetv1 - load model before inference");return FA(function(){var w=g.toBatchTensor(512,!1).toFloat(),C=VB(og(w,YA(.007843137718737125)),YA(1)),E=B4(C,Q.mobilenetv1),e=e4(E.out,E.conv11,Q.prediction_layer),t=e.boxPredictions,I=e.classPredictions;return E4(t,I,Q.output_layer)})},B.prototype.forward=function(g){return JA(this,void 0,void 0,function(){var Q;return mA(this,function(w){switch(w.label){case 0:return Q=this.forwardInput,[4,qB(g)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},B.prototype.locateFaces=function(g,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,t,I,n,i,c,Y,M,D,r,F,u,s,a,l,U,G,d;return mA(this,function(H){switch(H.label){case 0:return w=new Ct(Q),C=w.maxResults,E=w.minConfidence,[4,qB(g)];case 1:for(e=H.sent(),t=this.forwardInput(e),I=t.boxes,n=t.scores,i=I[0],c=n[0],Y=1;Y<I.length;Y++)I[Y].dispose(),n[Y].dispose();return r=(D=Array).from,[4,c.data()];case 2:return M=r.apply(D,[H.sent()]),F=.5,u=g4(i,M,C,F,E),s=e.getReshapedInputDimensions(0),a=e.inputSize,l=a/s.width,U=a/s.height,G=i.arraySync(),d=u.map(function(h){var f=[Math.max(0,G[h][0]),Math.min(1,G[h][2])].map(function(R){return R*U}),J=f[0],y=f[1],m=[Math.max(0,G[h][1]),Math.min(1,G[h][3])].map(function(R){return R*l}),k=m[0],z=m[1];return new Ng(M[h],new xe(k,J,z-k,y-J),{height:e.getInputHeight(0),width:e.getInputWidth(0)})}),i.dispose(),c.dispose(),[2,d]}})})},B.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},B.prototype.extractParamsFromWeigthMap=function(g){return qv(g)},B.prototype.extractParams=function(g){return Ov(g)},B}(lQ);(function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B})(ta);var t4=.4,o4=[new iB(.738768,.874946),new iB(2.42204,2.65704),new iB(4.30971,7.04493),new iB(10.246,4.59428),new iB(12.6868,11.8741)],I4=[new iB(1.603231,2.094468),new iB(6.041143,7.080126),new iB(2.882459,3.518061),new iB(4.266906,5.178857),new iB(9.041765,10.66308)],n4=[117.001,114.697,97.404],i4="tiny_yolov2_model",c4="tiny_yolov2_separable_conv_model",Et=function(A){return typeof A=="number"};function Y4(A){if(!A)throw new Error("invalid config: "+A);if(typeof A.withSeparableConvs!="boolean")throw new Error("config.withSeparableConvs has to be a boolean, have: "+A.withSeparableConvs);if(!Et(A.iouThreshold)||A.iouThreshold<0||A.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+A.iouThreshold);if(!Array.isArray(A.classes)||!A.classes.length||!A.classes.every(function(B){return typeof B=="string"}))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(A.classes));if(!Array.isArray(A.anchors)||!A.anchors.length||!A.anchors.map(function(B){return B||{}}).every(function(B){return Et(B.x)&&Et(B.y)}))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(A.anchors));if(A.meanRgb&&(!Array.isArray(A.meanRgb)||A.meanRgb.length!==3||!A.meanRgb.every(Et)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(A.meanRgb))}function Pn(A){return FA(function(){var B=og(A,YA(.10000000149011612));return BB(JB(VB(A,B)),B)})}function WQ(A,B){return FA(function(){var g=tw(A,[[0,0],[1,1],[1,1],[0,0]]);return g=jg(g,B.conv.filters,[1,1],"valid"),g=VB(g,B.bn.sub),g=og(g,B.bn.truediv),g=BB(g,B.conv.bias),Pn(g)})}function bQ(A,B){return FA(function(){var g=tw(A,[[0,0],[1,1],[1,1],[0,0]]);return g=xI(g,B.depthwise_filter,B.pointwise_filter,[1,1],"valid"),g=BB(g,B.bias),Pn(g)})}function M4(A,B){var g=Bt(A,B);function Q(E,e){var t=yB(A(E)),I=yB(A(E));return B.push({paramPath:e+"/sub"},{paramPath:e+"/truediv"}),{sub:t,truediv:I}}function w(E,e,t){var I=g(E,e,3,t+"/conv"),n=Q(e,t+"/bn");return{conv:I,bn:n}}var C=fn(A,B);return{extractConvParams:g,extractConvWithBatchNormParams:w,extractSeparableConvParams:C}}function r4(A,B,g,Q){var w=hQ(A),C=w.extractWeights,E=w.getRemainingWeights,e=[],t=M4(C,e),I=t.extractConvParams,n=t.extractConvWithBatchNormParams,i=t.extractSeparableConvParams,c;if(B.withSeparableConvs){var Y=Q[0],M=Q[1],D=Q[2],r=Q[3],F=Q[4],u=Q[5],s=Q[6],a=Q[7],l=Q[8],U=B.isFirstLayerConv2d?I(Y,M,3,"conv0"):i(Y,M,"conv0"),G=i(M,D,"conv1"),d=i(D,r,"conv2"),H=i(r,F,"conv3"),h=i(F,u,"conv4"),f=i(u,s,"conv5"),J=a?i(s,a,"conv6"):void 0,y=l?i(a,l,"conv7"):void 0,m=I(l||a||s,5*g,1,"conv8");c={conv0:U,conv1:G,conv2:d,conv3:H,conv4:h,conv5:f,conv6:J,conv7:y,conv8:m}}else{var Y=Q[0],M=Q[1],D=Q[2],r=Q[3],F=Q[4],u=Q[5],s=Q[6],a=Q[7],l=Q[8],U=n(Y,M,"conv0"),G=n(M,D,"conv1"),d=n(D,r,"conv2"),H=n(r,F,"conv3"),h=n(F,u,"conv4"),f=n(u,s,"conv5"),J=n(s,a,"conv6"),y=n(a,l,"conv7"),m=I(l,5*g,1,"conv8");c={conv0:U,conv1:G,conv2:d,conv3:H,conv4:h,conv5:f,conv6:J,conv7:y,conv8:m}}if(E().length!==0)throw new Error("weights remaing after extract: "+E().length);return{params:c,paramMappings:e}}function D4(A,B){var g=zQ(A,B);function Q(e){var t=g(e+"/sub",1),I=g(e+"/truediv",1);return{sub:t,truediv:I}}function w(e){var t=g(e+"/filters",4),I=g(e+"/bias",1);return{filters:t,bias:I}}function C(e){var t=w(e+"/conv"),I=Q(e+"/bn");return{conv:t,bn:I}}var E=Jn(g);return{extractConvParams:w,extractConvWithBatchNormParams:C,extractSeparableConvParams:E}}function a4(A,B){var g=[],Q=D4(A,g),w=Q.extractConvParams,C=Q.extractConvWithBatchNormParams,E=Q.extractSeparableConvParams,e;if(B.withSeparableConvs){var t=B.filterSizes&&B.filterSizes.length||9;e={conv0:B.isFirstLayerConv2d?w("conv0"):E("conv0"),conv1:E("conv1"),conv2:E("conv2"),conv3:E("conv3"),conv4:E("conv4"),conv5:E("conv5"),conv6:t>7?E("conv6"):void 0,conv7:t>8?E("conv7"):void 0,conv8:w("conv8")}}else e={conv0:C("conv0"),conv1:C("conv1"),conv2:C("conv2"),conv3:C("conv3"),conv4:C("conv4"),conv5:C("conv5"),conv6:C("conv6"),conv7:C("conv7"),conv8:w("conv8")};return UQ(A,g),{params:e,paramMappings:g}}var oa;(function(A){A[A.XS=224]="XS",A[A.SM=320]="SM",A[A.MD=416]="MD",A[A.LG=608]="LG"})(oa||(oa={}));var vn=function(){function A(B){var g=B===void 0?{}:B,Q=g.inputSize,w=g.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=Q||416,this._scoreThreshold=w||.5,typeof this._inputSize!="number"||this._inputSize%32!==0)throw new Error(this._name+" - expected inputSize to be a number divisible by 32");if(typeof this._scoreThreshold!="number"||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(this._name+" - expected scoreThreshold to be a number between 0 and 1")}return Object.defineProperty(A.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),A}(),Ia=function(A){LA(B,A);function B(g){var Q=A.call(this,"TinyYolov2")||this;return Y4(g),Q._config=g,Q}return Object.defineProperty(B.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(B.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(B.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),B.prototype.runTinyYolov2=function(g,Q){var w=WQ(g,Q.conv0);return w=ZB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv1),w=ZB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv2),w=ZB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv3),w=ZB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv4),w=ZB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv5),w=ZB(w,[2,2],[1,1],"same"),w=WQ(w,Q.conv6),w=WQ(w,Q.conv7),Vg(w,Q.conv8,"valid",!1)},B.prototype.runMobilenet=function(g,Q){var w=this.config.isFirstLayerConv2d?Pn(Vg(g,Q.conv0,"valid",!1)):bQ(g,Q.conv0);return w=ZB(w,[2,2],[2,2],"same"),w=bQ(w,Q.conv1),w=ZB(w,[2,2],[2,2],"same"),w=bQ(w,Q.conv2),w=ZB(w,[2,2],[2,2],"same"),w=bQ(w,Q.conv3),w=ZB(w,[2,2],[2,2],"same"),w=bQ(w,Q.conv4),w=ZB(w,[2,2],[2,2],"same"),w=bQ(w,Q.conv5),w=ZB(w,[2,2],[1,1],"same"),w=Q.conv6?bQ(w,Q.conv6):w,w=Q.conv7?bQ(w,Q.conv7):w,Vg(w,Q.conv8,"valid",!1)},B.prototype.forwardInput=function(g,Q){var w=this,C=this.params;if(!C)throw new Error("TinyYolov2 - load model before inference");return FA(function(){var E=g.toBatchTensor(Q,!1).toFloat();return E=w.config.meanRgb?CE(E,w.config.meanRgb):E,E=E.div(YA(256)),w.config.withSeparableConvs?w.runMobilenet(E,C):w.runTinyYolov2(E,C)})},B.prototype.forward=function(g,Q){return JA(this,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return w=this.forwardInput,[4,qB(g)];case 1:return[4,w.apply(this,[C.sent(),Q])];case 2:return[2,C.sent()]}})})},B.prototype.detect=function(g,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,t,I,n,i,c,Y,M,D,r,F,u=this;return mA(this,function(s){switch(s.label){case 0:return w=new vn(Q),C=w.inputSize,E=w.scoreThreshold,[4,qB(g)];case 1:return e=s.sent(),[4,this.forwardInput(e,C)];case 2:return t=s.sent(),I=FA(function(){return SB(t)[0].expandDims()}),n={width:e.getInputWidth(0),height:e.getInputHeight(0)},[4,this.extractBoxes(I,e.getReshapedInputDimensions(0),E)];case 3:return i=s.sent(),t.dispose(),I.dispose(),c=i.map(function(a){return a.box}),Y=i.map(function(a){return a.score}),M=i.map(function(a){return a.classScore}),D=i.map(function(a){return u.config.classes[a.label]}),r=wE(c.map(function(a){return a.rescale(C)}),Y,this.config.iouThreshold,!0),F=r.map(function(a){return new ND(Y[a],M[a],D[a],c[a],n)}),[2,F]}})})},B.prototype.getDefaultModelName=function(){return""},B.prototype.extractParamsFromWeigthMap=function(g){return a4(g,this.config)},B.prototype.extractParams=function(g){var Q=this.config.filterSizes||B.DEFAULT_FILTER_SIZES,w=Q?Q.length:void 0;if(w!==7&&w!==8&&w!==9)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+w+" filterSizes in config");return r4(g,this.config,this.boxEncodingSize,Q)},B.prototype.extractBoxes=function(g,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,t,I,n,i,c,Y,M,D,r,F,u,s,a,l,U,G,d,H,h,f,J,y,m,k,z,R,v=this;return mA(this,function(S){switch(S.label){case 0:return C=Q.width,E=Q.height,e=Math.max(C,E),t=e/C,I=e/E,n=g.shape[1],i=this.config.anchors.length,c=FA(function(){var x=g.reshape([n,n,i,v.boxEncodingSize]),j=x.slice([0,0,0,0],[n,n,i,4]),p=x.slice([0,0,0,4],[n,n,i,1]),K=v.withClassScores?aQ(x.slice([0,0,0,5],[n,n,i,v.config.classes.length]),3):YA(0);return[j,p,K]}),Y=c[0],M=c[1],D=c[2],r=[],[4,M.array()];case 1:return F=S.sent(),[4,Y.array()];case 2:u=S.sent(),s=0,S.label=3;case 3:if(!(s<n))return[3,12];a=0,S.label=4;case 4:if(!(a<n))return[3,11];l=0,S.label=5;case 5:return l<i?(U=sn(F[s][a][l][0]),!w||U>w?(G=(a+sn(u[s][a][l][0]))/n*t,d=(s+sn(u[s][a][l][1]))/n*I,H=Math.exp(u[s][a][l][2])*this.config.anchors[l].x/n*t,h=Math.exp(u[s][a][l][3])*this.config.anchors[l].y/n*I,f=G-H/2,J=d-h/2,y={row:s,col:a,anchor:l},this.withClassScores?[4,this.extractPredictedClass(D,y)]:[3,7]):[3,9]):[3,10];case 6:return R=S.sent(),[3,8];case 7:R={classScore:1,label:0},S.label=8;case 8:m=R,k=m.classScore,z=m.label,r.push(ng({box:new Ke(f,J,f+H,J+h),score:U,classScore:U*k,label:z},y)),S.label=9;case 9:return l++,[3,5];case 10:return a++,[3,4];case 11:return s++,[3,3];case 12:return Y.dispose(),M.dispose(),D.dispose(),[2,r]}})})},B.prototype.extractPredictedClass=function(g,Q){return JA(this,void 0,void 0,function(){var w,C,E,e;return mA(this,function(t){switch(t.label){case 0:return w=Q.row,C=Q.col,E=Q.anchor,[4,g.array()];case 1:return e=t.sent(),[2,Array(this.config.classes.length).fill(0).map(function(I,n){return e[w][C][E][n]}).map(function(I,n){return{classScore:I,label:n}}).reduce(function(I,n){return I.classScore>n.classScore?I:n})]}})})},B.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],B}(lQ),F4=function(A){LA(B,A);function B(g){g===void 0&&(g=!0);var Q=this,w=Object.assign({},{withSeparableConvs:g,iouThreshold:t4,classes:["face"]},g?{anchors:I4,meanRgb:n4}:{anchors:o4,withClassScores:!0});return Q=A.call(this,w)||this,Q}return Object.defineProperty(B.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(B.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),B.prototype.locateFaces=function(g,Q){return JA(this,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return[4,this.detect(g,Q)];case 1:return w=C.sent(),[2,w.map(function(E){return new Ng(E.score,E.relativeBox,{width:E.imageWidth,height:E.imageHeight})})]}})})},B.prototype.getDefaultModelName=function(){return this.withSeparableConvs?c4:i4},B.prototype.extractParamsFromWeigthMap=function(g){return A.prototype.extractParamsFromWeigthMap.call(this,g)},B}(Ia),na=function(A){LA(B,A);function B(){var g=A!==null&&A.apply(this,arguments)||this;return g._name="TinyFaceDetectorOptions",g}return B}(vn),eE=function(){function A(){}return A.prototype.then=function(B){return JA(this,void 0,void 0,function(){var g;return mA(this,function(Q){switch(Q.label){case 0:return g=B,[4,this.run()];case 1:return[2,g.apply(void 0,[Q.sent()])]}})})},A.prototype.run=function(){return JA(this,void 0,void 0,function(){return mA(this,function(B){throw new Error("ComposableTask - run is not implemented")})})},A}();function et(A,B,g,Q,w){return w===void 0&&(w=function(C){var E=C.alignedRect;return E}),JA(this,void 0,void 0,function(){var C,E,e,t,I;return mA(this,function(n){switch(n.label){case 0:return C=A.map(function(i){return mn(i)?w(i):i.detection}),e=Q,e?[3,5]:B instanceof HB?[4,Gn(B,C)]:[3,2];case 1:return t=n.sent(),[3,4];case 2:return[4,$e(B,C)];case 3:t=n.sent(),n.label=4;case 4:e=t,n.label=5;case 5:return E=e,[4,g(E)];case 6:return I=n.sent(),E.forEach(function(i){return i instanceof HB&&i.dispose()}),[2,I]}})})}function kn(A,B,g,Q,w){return JA(this,void 0,void 0,function(){var C=this;return mA(this,function(E){return[2,et([A],B,function(e){return JA(C,void 0,void 0,function(){return mA(this,function(t){return[2,g(e[0])]})})},Q,w)]})})}function s4(A){return FA(function(){return Jg(SB(A,3).reverse(),3)})}var tt=2,ot=12;function u4(A,B){var g=Bt(A,B),Q=Hn(A,B);function w(I,n){var i=yB(A(I));return B.push({paramPath:n}),i}function C(I,n,i){i===void 0&&(i=!1);var c=g(I[0],I[1],3,n+"/conv1"),Y=w(I[1],n+"/prelu1_alpha"),M=g(I[1],I[2],3,n+"/conv2"),D=w(I[2],n+"/prelu2_alpha"),r=g(I[2],I[3],i?2:3,n+"/conv3"),F=w(I[3],n+"/prelu3_alpha");return{conv1:c,prelu1_alpha:Y,conv2:M,prelu2_alpha:D,conv3:r,prelu3_alpha:F}}function E(){var I=C([3,10,16,32],"pnet"),n=g(32,2,1,"pnet/conv4_1"),i=g(32,4,1,"pnet/conv4_2");return ng(ng({},I),{conv4_1:n,conv4_2:i})}function e(){var I=C([3,28,48,64],"rnet",!0),n=Q(576,128,"rnet/fc1"),i=w(128,"rnet/prelu4_alpha"),c=Q(128,2,"rnet/fc2_1"),Y=Q(128,4,"rnet/fc2_2");return ng(ng({},I),{fc1:n,prelu4_alpha:i,fc2_1:c,fc2_2:Y})}function t(){var I=C([3,32,64,64],"onet"),n=g(64,128,2,"onet/conv4"),i=w(128,"onet/prelu4_alpha"),c=Q(1152,256,"onet/fc1"),Y=w(256,"onet/prelu5_alpha"),M=Q(256,2,"onet/fc2_1"),D=Q(256,4,"onet/fc2_2"),r=Q(256,10,"onet/fc2_3");return ng(ng({},I),{conv4:n,prelu4_alpha:i,fc1:c,prelu5_alpha:Y,fc2_1:M,fc2_2:D,fc2_3:r})}return{extractPNetParams:E,extractRNetParams:e,extractONetParams:t}}function l4(A){var B=hQ(A),g=B.extractWeights,Q=B.getRemainingWeights,w=[],C=u4(g,w),E=C.extractPNetParams,e=C.extractRNetParams,t=C.extractONetParams,I=E(),n=e(),i=t();if(Q().length!==0)throw new Error("weights remaing after extract: "+Q().length);return{params:{pnet:I,rnet:n,onet:i},paramMappings:w}}function U4(A,B){var g=zQ(A,B);function Q(n){var i=g(n+"/weights",4,n+"/filters"),c=g(n+"/bias",1);return{filters:i,bias:c}}function w(n){var i=g(n+"/weights",2),c=g(n+"/bias",1);return{weights:i,bias:c}}function C(n){return g(n,1)}function E(n){var i=Q(n+"/conv1"),c=C(n+"/prelu1_alpha"),Y=Q(n+"/conv2"),M=C(n+"/prelu2_alpha"),D=Q(n+"/conv3"),r=C(n+"/prelu3_alpha");return{conv1:i,prelu1_alpha:c,conv2:Y,prelu2_alpha:M,conv3:D,prelu3_alpha:r}}function e(){var n=E("pnet"),i=Q("pnet/conv4_1"),c=Q("pnet/conv4_2");return ng(ng({},n),{conv4_1:i,conv4_2:c})}function t(){var n=E("rnet"),i=w("rnet/fc1"),c=C("rnet/prelu4_alpha"),Y=w("rnet/fc2_1"),M=w("rnet/fc2_2");return ng(ng({},n),{fc1:i,prelu4_alpha:c,fc2_1:Y,fc2_2:M})}function I(){var n=E("onet"),i=Q("onet/conv4"),c=C("onet/prelu4_alpha"),Y=w("onet/fc1"),M=C("onet/prelu5_alpha"),D=w("onet/fc2_1"),r=w("onet/fc2_2"),F=w("onet/fc2_3");return ng(ng({},n),{conv4:i,prelu4_alpha:c,fc1:Y,prelu5_alpha:M,fc2_1:D,fc2_2:r,fc2_3:F})}return{extractPNetParams:e,extractRNetParams:t,extractONetParams:I}}function h4(A){var B=[],g=U4(A,B),Q=g.extractPNetParams,w=g.extractRNetParams,C=g.extractONetParams,E=Q(),e=w(),t=C();return UQ(A,B),{params:{pnet:E,rnet:e,onet:t},paramMappings:B}}function Tn(A,B){var g=B[0],Q=B[1];return{height:Math.floor(g*A),width:Math.floor(Q*A)}}function G4(A,B,g){for(var Q=g[0],w=g[1],C=ot/A,E=[],e=Math.min(Q,w)*C,t=0;e>=12;)E.push(C*Math.pow(B,t)),e=e*B,t+=1;return E}var jn=function(A){LA(B,A);function B(g,Q,w,C){return A.call(this,{left:g,top:Q,right:w,bottom:C},!0)||this}return B}(CQ);function ia(A){return FA(function(){return og(VB(A,YA(127.5)),YA(.0078125))})}function nC(A,B){return FA(function(){return BB(JB(A),og(B,Re(JB(Re(A)))))})}function yn(A,B,g){return g===void 0&&(g=!1),FA(function(){var Q=Vg(A,B.conv1,"valid");return Q=nC(Q,B.prelu1_alpha),Q=ZB(Q,g?[2,2]:[3,3],[2,2],"same"),Q=Vg(Q,B.conv2,"valid"),Q=nC(Q,B.prelu2_alpha),Q=g?Q:ZB(Q,[3,3],[2,2],"valid"),Q=Vg(Q,B.conv3,"valid"),Q=nC(Q,B.prelu3_alpha),Q})}function d4(A,B){return FA(function(){var g=yn(A,B,!0),Q=Vg(g,B.conv4_1,"valid"),w=Tg(pe(Q,3),3),C=aQ(VB(Q,w),3),E=Vg(g,B.conv4_2,"valid");return{prob:C,regions:E}})}function H4(A,B){return FA(function(){var g=Tn(B,A.shape.slice(1)),Q=g.height,w=g.width,C=_I.resizeBilinear(A,[Q,w]),E=ia(C);return kQ(E,[0,2,1,3])})}function f4(A,B,g,Q){for(var w=[],C=A.arraySync(),E=0;E<A.shape[0];E++)for(var e=0;e<A.shape[1];e++)C[E][e]>=Q&&w.push(new iB(e,E));var t=w.map(function(I){var n=new Ke(Math.round((I.y*tt+1)/g),Math.round((I.x*tt+1)/g),Math.round((I.y*tt+ot)/g),Math.round((I.x*tt+ot)/g)),i=C[I.y][I.x],c=B.arraySync(),Y=new jn(c[I.y][I.x][0],c[I.y][I.x][1],c[I.y][I.x][2],c[I.y][I.x][3]);return{cell:n,score:i,region:Y}});return t}function J4(A,B,g,Q,w){w.stage1=[];var C=B.map(function(c){return FA(function(){var Y={scale:c},M=H4(A,c),D=Date.now(),r=d4(M,Q),F=r.prob,u=r.regions;Y.pnet=Date.now()-D;var s=SB(SB(F,3)[1])[0],a=SB(u)[0];return{scoresTensor:s,regionsTensor:a,scale:c,statsForScale:Y}})}),E=C.map(function(c){var Y=c.scoresTensor,M=c.regionsTensor,D=c.scale,r=c.statsForScale,F=f4(Y,M,D,g);if(Y.dispose(),M.dispose(),!F.length)return w.stage1.push(r),[];var u=Date.now(),s=wE(F.map(function(a){return a.cell}),F.map(function(a){return a.score}),.5);return r.nms=Date.now()-u,r.numBoxes=s.length,w.stage1.push(r),s.map(function(a){return F[a]})}),e=E.reduce(function(c,Y){return c.concat(Y)},[]),t=[],I=[];if(e.length>0){var n=Date.now(),i=wE(e.map(function(c){return c.cell}),e.map(function(c){return c.score}),.7);w.stage1_nms=Date.now()-n,I=i.map(function(c){return e[c].score}),t=i.map(function(c){return e[c]}).map(function(c){var Y=c.cell,M=c.region;return new Ke(Y.left+M.left*Y.width,Y.top+M.top*Y.height,Y.right+M.right*Y.width,Y.bottom+M.bottom*Y.height).toSquare().round()})}return{boxes:t,scores:I}}function ca(A,B,g){var Q=g.width,w=g.height;return JA(this,void 0,void 0,function(){var C,E,e,t=this;return mA(this,function(I){switch(I.label){case 0:return C=EQ(A),[4,Promise.all(B.map(function(n){return JA(t,void 0,void 0,function(){var i,c,Y,M,D,r,F,u;return mA(this,function(s){return i=n.padAtBorders(A.height,A.width),c=i.y,Y=i.ey,M=i.x,D=i.ex,r=M-1,F=c-1,u=C.getImageData(r,F,D-r,Y-F),[2,ig.isNodejs()?qe(u):createImageBitmap(u)]})})}))];case 1:return E=I.sent(),e=[],E.forEach(function(n){var i=Ze({width:Q,height:w}),c=EQ(i);c.drawImage(n,0,0,Q,w);for(var Y=c.getImageData(0,0,Q,w).data,M=[],D=0;D<Y.length;D+=4)M.push(Y[D+2]),M.push(Y[D+1]),M.push(Y[D]);e.push(M)}),[2,e.map(function(n){var i=FA(function(){var c=kQ(sg(n,[1,Q,w,3]),[0,2,1,3]).toFloat();return ia(c)});return i})]}})})}function m4(A,B){return FA(function(){var g=yn(A,B),Q=bg(g,[g.shape[0],B.fc1.weights.shape[0]]),w=eQ(Q,B.fc1),C=nC(w,B.prelu4_alpha),E=eQ(C,B.fc2_1),e=Tg(pe(E,1),1),t=aQ(VB(E,e),1),I=eQ(C,B.fc2_2),n=SB(t,1)[1];return{scores:n,regions:I}})}function N4(A,B,g,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,t,I,n,i,c,Y,M,D,r,F,u;return mA(this,function(s){switch(s.label){case 0:return C=Date.now(),[4,ca(A,B,{width:24,height:24})];case 1:return E=s.sent(),w.stage2_extractImagePatches=Date.now()-C,C=Date.now(),e=E.map(function(a){var l=m4(a,Q);return a.dispose(),l}),w.stage2_rnet=Date.now()-C,t=e.length>1?bB(e.map(function(a){return a.scores})):e[0].scores,i=(n=Array).from,[4,t.data()];case 2:return I=i.apply(n,[s.sent()]),t.dispose(),c=I.map(function(a,l){return{score:a,idx:l}}).filter(function(a){return a.score>g}).map(function(a){var l=a.idx;return l}),Y=c.map(function(a){return B[a]}),M=c.map(function(a){return I[a]}),D=[],r=[],Y.length>0&&(C=Date.now(),F=wE(Y,M,.7),w.stage2_nms=Date.now()-C,u=F.map(function(a){var l=e[c[a]].regions.arraySync();return new jn(l[0][0],l[0][1],l[0][2],l[0][3])}),r=F.map(function(a){return M[a]}),D=F.map(function(a,l){return Y[a].calibrate(u[l])})),e.forEach(function(a){a.regions.dispose(),a.scores.dispose()}),[2,{boxes:D,scores:r}]}})})}function R4(A,B){return FA(function(){var g=yn(A,B);g=ZB(g,[2,2],[2,2],"same"),g=Vg(g,B.conv4,"valid"),g=nC(g,B.prelu4_alpha);var Q=bg(g,[g.shape[0],B.fc1.weights.shape[0]]),w=eQ(Q,B.fc1),C=nC(w,B.prelu5_alpha),E=eQ(C,B.fc2_1),e=Tg(pe(E,1),1),t=aQ(VB(E,e),1),I=eQ(C,B.fc2_2),n=eQ(C,B.fc2_3),i=SB(t,1)[1];return{scores:i,regions:I,points:n}})}function P4(A,B,g,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,t,I,n,i,c,Y,M,D,r,F,u,s;return mA(this,function(a){switch(a.label){case 0:return C=Date.now(),[4,ca(A,B,{width:48,height:48})];case 1:return E=a.sent(),w.stage3_extractImagePatches=Date.now()-C,C=Date.now(),e=E.map(function(l){var U=R4(l,Q);return l.dispose(),U}),w.stage3_onet=Date.now()-C,t=e.length>1?bB(e.map(function(l){return l.scores})):e[0].scores,i=(n=Array).from,[4,t.data()];case 2:return I=i.apply(n,[a.sent()]),t.dispose(),c=I.map(function(l,U){return{score:l,idx:U}}).filter(function(l){return l.score>g}).map(function(l){var U=l.idx;return U}),Y=c.map(function(l){var U=e[l].regions.arraySync();return new jn(U[0][0],U[0][1],U[0][2],U[0][3])}),M=c.map(function(l,U){return B[l].calibrate(Y[U])}),D=c.map(function(l){return I[l]}),r=[],F=[],u=[],M.length>0&&(C=Date.now(),s=wE(M,D,.7,!1),w.stage3_nms=Date.now()-C,r=s.map(function(l){return M[l]}),F=s.map(function(l){return D[l]}),u=s.map(function(l,U){return Array(5).fill(0).map(function(G,d){var H=e[l].points.arraySync();return new iB(H[0][d]*(r[U].width+1)+r[U].left,H[0][d+5]*(r[U].height+1)+r[U].top)})})),e.forEach(function(l){l.regions.dispose(),l.scores.dispose(),l.points.dispose()}),[2,{boxes:r,scores:F,points:u}]}})})}var v4=function(A){LA(B,A);function B(){return A.call(this,"Mtcnn")||this}return B.prototype.load=function(g){return JA(this,void 0,void 0,function(){return mA(this,function(Q){return console.warn("mtcnn is deprecated and will be removed soon"),[2,A.prototype.load.call(this,g)]})})},B.prototype.loadFromDisk=function(g){return JA(this,void 0,void 0,function(){return mA(this,function(Q){return console.warn("mtcnn is deprecated and will be removed soon"),[2,A.prototype.loadFromDisk.call(this,g)]})})},B.prototype.forwardInput=function(g,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,t,I,n,i,c,Y,M,D,r,F,u,s,a,l,U,G,d;return mA(this,function(H){switch(H.label){case 0:if(w=this.params,!w)throw new Error("Mtcnn - load model before inference");if(C=g.canvases[0],!C)throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return E={},e=Date.now(),t=FA(function(){return s4(Tg(Dn.fromPixels(C)).toFloat())}),I=function(h){return t.dispose(),E.total=Date.now()-e,h},n=t.shape.slice(1),i=n[0],c=n[1],Y=new ea(Q),M=Y.minFaceSize,D=Y.scaleFactor,r=Y.maxNumScales,F=Y.scoreThresholds,u=Y.scaleSteps,s=(u||G4(M,D,[i,c])).filter(function(h){var f=Tn(h,[i,c]);return Math.min(f.width,f.height)>ot}).slice(0,r),E.scales=s,E.pyramid=s.map(function(h){return Tn(h,[i,c])}),a=Date.now(),[4,J4(t,s,F[0],w.pnet,E)];case 1:return l=H.sent(),E.total_stage1=Date.now()-a,l.boxes.length?(E.stage2_numInputBoxes=l.boxes.length,a=Date.now(),[4,N4(C,l.boxes,F[1],w.rnet,E)]):[2,I({results:[],stats:E})];case 2:return U=H.sent(),E.total_stage2=Date.now()-a,U.boxes.length?(E.stage3_numInputBoxes=U.boxes.length,a=Date.now(),[4,P4(C,U.boxes,F[2],w.onet,E)]):[2,I({results:[],stats:E})];case 3:return G=H.sent(),E.total_stage3=Date.now()-a,d=G.boxes.map(function(h,f){return gt(EE({},new Ng(G.scores[f],new xe(h.left/c,h.top/i,h.width/c,h.height/i),{height:i,width:c})),new Cv(G.points[f].map(function(J){return J.sub(new iB(h.left,h.top)).div(new iB(h.width,h.height))}),{width:h.width,height:h.height}))}),[2,I({results:d,stats:E})]}})})},B.prototype.forward=function(g,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return w=this.forwardInput,[4,qB(g)];case 1:return[4,w.apply(this,[C.sent(),Q])];case 2:return[2,C.sent().results]}})})},B.prototype.forwardWithStats=function(g,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return w=this.forwardInput,[4,qB(g)];case 1:return[2,w.apply(this,[C.sent(),Q])]}})})},B.prototype.getDefaultModelName=function(){return"mtcnn_model"},B.prototype.extractParamsFromWeigthMap=function(g){return h4(g)},B.prototype.extractParams=function(g){return l4(g)},B}(lQ),k4=.4,T4=[new iB(1.603231,2.094468),new iB(6.041143,7.080126),new iB(2.882459,3.518061),new iB(4.266906,5.178857),new iB(9.041765,10.66308)],j4=[117.001,114.697,97.404],y4=function(A){LA(B,A);function B(){var g=this,Q={withSeparableConvs:!0,iouThreshold:k4,classes:["face"],anchors:T4,meanRgb:j4,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return g=A.call(this,Q)||this,g}return Object.defineProperty(B.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),B.prototype.locateFaces=function(g,Q){return JA(this,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return[4,this.detect(g,Q)];case 1:return w=C.sent(),[2,w.map(function(E){return new Ng(E.score,E.relativeBox,{width:E.imageWidth,height:E.imageHeight})})]}})})},B.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},B.prototype.extractParamsFromWeigthMap=function(g){return A.prototype.extractParamsFromWeigthMap.call(this,g)},B}(Ia),Ug={ssdMobilenetv1:new ta,tinyFaceDetector:new y4,tinyYolov2:new F4,mtcnn:new v4,faceLandmark68Net:new Ba,faceLandmark68TinyNet:new zv,faceRecognitionNet:new xv,faceExpressionNet:new hv,ageGenderNet:new Tv},Ya=function(A){LA(B,A);function B(g,Q,w){var C=A.call(this)||this;return C.parentTask=g,C.input=Q,C.extractedFaces=w,C}return B}(eE),pn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w=this;return mA(this,function(C){switch(C.label){case 0:return[4,this.parentTask];case 1:return g=C.sent(),[4,et(g,this.input,function(E){return JA(w,void 0,void 0,function(){return mA(this,function(e){switch(e.label){case 0:return[4,Promise.all(E.map(function(t){return Ug.faceExpressionNet.predictExpressions(t)}))];case 1:return[2,e.sent()]}})})},this.extractedFaces)];case 2:return Q=C.sent(),[2,g.map(function(E,e){return _D(E,Q[e])})]}})})},B.prototype.withAgeAndGender=function(){return new Sn(this,this.input)},B}(Ya),zn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return g=w.sent(),g?[4,kn(g,this.input,function(C){return Ug.faceExpressionNet.predictExpressions(C)},this.extractedFaces)]:[2];case 2:return Q=w.sent(),[2,_D(g,Q)]}})})},B.prototype.withAgeAndGender=function(){return new Ln(this,this.input)},B}(Ya),Wn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.withAgeAndGender=function(){return new Vn(this,this.input)},B.prototype.withFaceDescriptors=function(){return new xn(this,this.input)},B}(pn),bn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.withAgeAndGender=function(){return new Kn(this,this.input)},B.prototype.withFaceDescriptor=function(){return new Xn(this,this.input)},B}(zn),Ma=function(A){LA(B,A);function B(g,Q,w){var C=A.call(this)||this;return C.parentTask=g,C.input=Q,C.extractedFaces=w,C}return B}(eE),Sn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w=this;return mA(this,function(C){switch(C.label){case 0:return[4,this.parentTask];case 1:return g=C.sent(),[4,et(g,this.input,function(E){return JA(w,void 0,void 0,function(){return mA(this,function(e){switch(e.label){case 0:return[4,Promise.all(E.map(function(t){return Ug.ageGenderNet.predictAgeAndGender(t)}))];case 1:return[2,e.sent()]}})})},this.extractedFaces)];case 2:return Q=C.sent(),[2,g.map(function(E,e){var t=Q[e],I=t.age,n=t.gender,i=t.genderProbability;return Ca(Ea(E,n,i),I)})]}})})},B.prototype.withFaceExpressions=function(){return new pn(this,this.input)},B}(Ma),Ln=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w,C,E;return mA(this,function(e){switch(e.label){case 0:return[4,this.parentTask];case 1:return g=e.sent(),g?[4,kn(g,this.input,function(t){return Ug.ageGenderNet.predictAgeAndGender(t)},this.extractedFaces)]:[2];case 2:return Q=e.sent(),w=Q.age,C=Q.gender,E=Q.genderProbability,[2,Ca(Ea(g,C,E),w)]}})})},B.prototype.withFaceExpressions=function(){return new zn(this,this.input)},B}(Ma),Vn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.withFaceExpressions=function(){return new Wn(this,this.input)},B.prototype.withFaceDescriptors=function(){return new xn(this,this.input)},B}(Sn),Kn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.withFaceExpressions=function(){return new bn(this,this.input)},B.prototype.withFaceDescriptor=function(){return new Xn(this,this.input)},B}(Ln),ra=function(A){LA(B,A);function B(g,Q){var w=A.call(this)||this;return w.parentTask=g,w.input=Q,w}return B}(eE),xn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return g=w.sent(),[4,et(g,this.input,function(C){return Promise.all(C.map(function(E){return Ug.faceRecognitionNet.computeFaceDescriptor(E)}))},null,function(C){return C.landmarks.align(null,{useDlibAlignment:!0})})];case 2:return Q=w.sent(),[2,Q.map(function(C,E){return wa(g[E],C)})]}})})},B.prototype.withFaceExpressions=function(){return new Wn(this,this.input)},B.prototype.withAgeAndGender=function(){return new Vn(this,this.input)},B}(ra),Xn=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return g=w.sent(),g?[4,kn(g,this.input,function(C){return Ug.faceRecognitionNet.computeFaceDescriptor(C)},null,function(C){return C.landmarks.align(null,{useDlibAlignment:!0})})]:[2];case 2:return Q=w.sent(),[2,wa(g,Q)]}})})},B.prototype.withFaceExpressions=function(){return new bn(this,this.input)},B.prototype.withAgeAndGender=function(){return new Kn(this,this.input)},B}(ra),Da=function(A){LA(B,A);function B(g,Q,w){var C=A.call(this)||this;return C.parentTask=g,C.input=Q,C.useTinyLandmarkNet=w,C}return Object.defineProperty(B.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?Ug.faceLandmark68TinyNet:Ug.faceLandmark68Net},enumerable:!0,configurable:!0}),B}(eE),p4=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w,C,E,e=this;return mA(this,function(t){switch(t.label){case 0:return[4,this.parentTask];case 1:return g=t.sent(),Q=g.map(function(I){return I.detection}),this.input instanceof HB?[4,Gn(this.input,Q)]:[3,3];case 2:return C=t.sent(),[3,5];case 3:return[4,$e(this.input,Q)];case 4:C=t.sent(),t.label=5;case 5:return w=C,[4,Promise.all(w.map(function(I){return e.landmarkNet.detectLandmarks(I)}))];case 6:return E=t.sent(),w.forEach(function(I){return I instanceof HB&&I.dispose()}),[2,g.map(function(I,n){return gt(I,E[n])})]}})})},B.prototype.withFaceExpressions=function(){return new Wn(this,this.input)},B.prototype.withAgeAndGender=function(){return new Vn(this,this.input)},B.prototype.withFaceDescriptors=function(){return new xn(this,this.input)},B}(Da),z4=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w,C,E;return mA(this,function(e){switch(e.label){case 0:return[4,this.parentTask];case 1:return g=e.sent(),g?(Q=g.detection,this.input instanceof HB?[4,Gn(this.input,[Q])]:[3,3]):[2];case 2:return C=e.sent(),[3,5];case 3:return[4,$e(this.input,[Q])];case 4:C=e.sent(),e.label=5;case 5:return w=C,[4,this.landmarkNet.detectLandmarks(w[0])];case 6:return E=e.sent(),w.forEach(function(t){return t instanceof HB&&t.dispose()}),[2,gt(g,E)]}})})},B.prototype.withFaceExpressions=function(){return new bn(this,this.input)},B.prototype.withAgeAndGender=function(){return new Kn(this,this.input)},B.prototype.withFaceDescriptor=function(){return new Xn(this,this.input)},B}(Da),aa=function(A){LA(B,A);function B(g,Q){Q===void 0&&(Q=new Ct);var w=A.call(this)||this;return w.input=g,w.options=Q,w}return B}(eE),W4=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q,w,C;return mA(this,function(E){switch(E.label){case 0:return g=this,Q=g.input,w=g.options,w instanceof ea?[4,Ug.mtcnn.forward(Q,w)]:[3,2];case 1:return[2,E.sent().map(function(e){return e.detection})];case 2:if(C=w instanceof na?function(e){return Ug.tinyFaceDetector.locateFaces(e,w)}:w instanceof Ct?function(e){return Ug.ssdMobilenetv1.locateFaces(e,w)}:w instanceof vn?function(e){return Ug.tinyYolov2.locateFaces(e,w)}:null,!C)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,C(Q)]}})})},B.prototype.runAndExtendWithFaceDetections=function(){var g=this;return new Promise(function(Q){return JA(g,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return[4,this.run()];case 1:return w=C.sent(),[2,Q(w.map(function(E){return EE({},E)}))]}})})})},B.prototype.withFaceLandmarks=function(g){return g===void 0&&(g=!1),new p4(this.runAndExtendWithFaceDetections(),this.input,g)},B.prototype.withFaceExpressions=function(){return new pn(this.runAndExtendWithFaceDetections(),this.input)},B.prototype.withAgeAndGender=function(){return new Sn(this.runAndExtendWithFaceDetections(),this.input)},B}(aa),b4=function(A){LA(B,A);function B(){return A!==null&&A.apply(this,arguments)||this}return B.prototype.run=function(){return JA(this,void 0,void 0,function(){var g,Q;return mA(this,function(w){switch(w.label){case 0:return[4,new W4(this.input,this.options)];case 1:return g=w.sent(),Q=g[0],g.forEach(function(C){C.score>Q.score&&(Q=C)}),[2,Q]}})})},B.prototype.runAndExtendWithFaceDetection=function(){var g=this;return new Promise(function(Q){return JA(g,void 0,void 0,function(){var w;return mA(this,function(C){switch(C.label){case 0:return[4,this.run()];case 1:return w=C.sent(),[2,Q(w?EE({},w):void 0)]}})})})},B.prototype.withFaceLandmarks=function(g){return g===void 0&&(g=!1),new z4(this.runAndExtendWithFaceDetection(),this.input,g)},B.prototype.withFaceExpressions=function(){return new zn(this.runAndExtendWithFaceDetection(),this.input)},B.prototype.withAgeAndGender=function(){return new Ln(this.runAndExtendWithFaceDetection(),this.input)},B}(aa);function S4(A,B){return B===void 0&&(B=new Ct),new b4(A,B)}function L4(A,B){if(A.length!==B.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var g=Array.from(A),Q=Array.from(B);return Math.sqrt(g.map(function(w,C){return w-Q[C]}).reduce(function(w,C){return w+Math.pow(C,2)},0))}(function(){function A(B,g){g===void 0&&(g=.6),this._distanceThreshold=g;var Q=Array.isArray(B)?B:[B];if(!Q.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var w=1,C=function(){return"person "+w++};this._labeledDescriptors=Q.map(function(E){if(E instanceof Xe)return E;if(E instanceof Float32Array)return new Xe(C(),[E]);if(E.descriptor&&E.descriptor instanceof Float32Array)return new Xe(C(),[E.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")})}return Object.defineProperty(A.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),A.prototype.computeMeanDistance=function(B,g){return g.map(function(Q){return L4(Q,B)}).reduce(function(Q,w){return Q+w},0)/(g.length||1)},A.prototype.matchDescriptor=function(B){var g=this;return this.labeledDescriptors.map(function(Q){var w=Q.descriptors,C=Q.label;return new PD(C,g.computeMeanDistance(B,w))}).reduce(function(Q,w){return Q.distance<w.distance?Q:w})},A.prototype.findBestMatch=function(B){var g=this.matchDescriptor(B);return g.distance<this.distanceThreshold?g:new PD("unknown",g.distance)},A.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(B){return B.toJSON()})}},A.fromJSON=function(B){var g=B.labeledDescriptors.map(function(Q){return Xe.fromJSON(Q)});return new A(g,B.distanceThreshold)},A})();function Fa(A,B){var g=new Dw(B.width,B.height),Q=g.width,w=g.height;if(Q<=0||w<=0)throw new Error("resizeResults - invalid dimensions: "+JSON.stringify({width:Q,height:w}));if(Array.isArray(A))return A.map(function(e){return Fa(e,{width:Q,height:w})});if(mn(A)){var C=A.detection.forSize(Q,w),E=A.unshiftedLandmarks.forSize(C.box.width,C.box.height);return gt(EE(A,C),E)}return Oe(A)?EE(A,A.detection.forSize(Q,w)):A instanceof oC||A instanceof Ng?A.forSize(Q,w):A}class V4{getVideoStreamConfig(B,g){return{audio:!1,video:{width:{min:B,ideal:B},height:{min:g,ideal:g},facingMode:"environment"}}}getContourCoordinate(B,g){return{x:B*.25,y:g*.05,width:B*.5,height:g*.9}}getBoxData(B){return B?{x:B.x,y:B.y,width:B.width,height:B.height}:null}setStylesForCanvas(B){B.width="100%",B.height="100%",B.style.position="absolute",B.style.top="0",B.style.left="0"}checkFaceInclusion(B,g){if(!B||!g||g.width>B.width||g.height>B.height)return!1;const Q=g.x,w=g.x+g.width,C=g.y,E=g.y+g.height,e=B.x,t=B.x+B.width,I=B.y,n=B.y+B.height;return Q>=e&&w<=t&&C>=I&&E<=n}async getFaceDetections(B,g){if(!B)return[];const Q=new na({inputSize:g});return S4(B,Q).withFaceLandmarks(!0)}getCanvas(B){return qe(B)}getResizedAndDetection(B,g,Q,w,C){av(B,{width:w,height:C});const E=Fa(g,{width:w,height:C});Q.clearRect(0,0,w,C),nv(B,E),Hv(B,E)}async getFaceSnapshot(B,g){const Q=[new xe(g.x,g.y,g.width,g.height)],w=await $e(B,Q);return w.length?w[0].toDataURL("image/jpeg").replace(/^data:image\/\w+;base64,/,""):null}async initModels(){let B=new Date;console.log(B);try{await Promise.all([Ug.tinyFaceDetector.loadFromUri("/models"),Ug.faceLandmark68TinyNet.loadFromUri("/models")])}catch(g){console.error(g)}B=new Date,console.log(B)}}let On;function K4(){return On||(On=new V4),On}function x4(A){const B=o.ref(""),g=o.ref(1),Q=async(E="",e=1)=>{await A.initialize({search:E,page:e})},w=async E=>{B.value=E,g.value=1,await Q(E,g.value)},C=async E=>{g.value=E,await Q(B.value,E)};return o.watch(()=>A.columnFilters.value,async()=>{g.value=1,await Q(B.value,g.value)},{deep:!0}),o.onMounted(()=>Q(B.value,g.value)),{search:B,currentPage:g,loading:A.loading,handleSearch:w,handlePageChange:C,loadTable:Q}}const X4=A=>{const B=o.ref({}),g=o.ref({});A.columns.forEach(({name:t,filterType:I})=>{I&&(B.value[t]=I==="multi"?[]:void 0,g.value[t]=!1)});const Q=o.computed(()=>Array.isArray(A.rows)?A.rows:A.rows.value),w=(t,I)=>{const n=A.columns.find(i=>i.name===t);if((n==null?void 0:n.filterType)==="multi"){const i=B.value[t],c=i.indexOf(I);c>-1?i.splice(c,1):i.push(I),B.value[t]=[...i]}else B.value[t]=I,g.value[t]=!1},C=o.computed(()=>{var I;const t={};for(const n of A.columns){const i=B.value[n.name],c=((I=A.filtersOptions)==null?void 0:I.value[n.name])||[];if(i){let Y=[];Array.isArray(i)?Y=c.filter(M=>i.includes(M.name)).map(M=>M.id):Y=c.filter(M=>M.name===i).map(M=>M.id),t[n.name]=Array.from(new Set(Y))}}return t}),E=t=>{const I=A.columns.find(n=>n.name===t);B.value[t]=(I==null?void 0:I.filterType)==="multi"?[]:void 0},e=(t,I)=>{g.value[t]=I};return{rows:Q,columns:o.computed(()=>A.columns),columnFilters:B,filterMenus:g,toggleFilterValue:w,clearFilter:E,openFilterMenu:e,selectedFilters:C}};function O4(A,B=[]){const g=o.ref([...new Set([...B,...A.map(C=>C.name)])]),Q=o.computed(()=>A.filter(C=>g.value.includes(C.name)));function w(C){C.dialog({title:"Выберите колонки",options:{type:"checkbox",model:[...g.value],items:A.map(E=>({label:E.checkboxLabel??E.label,value:E.name,disable:B.includes(E.name)}))},cancel:{label:"Отмена","data-test":"cancel-button"},ok:{label:"Ок","data-test":"ok-button"},persistent:!0}).onOk(E=>{g.value=Array.from(new Set([...E,...B]))})}return{selectedColumnNames:g,visibleColumns:Q,openColumnSelectorDialog:w}}function Z4(A){if(!A)return"";const B=A.startsWith("/uploads")?"":"/uploads";return process.env.VUE_APP_BACKEND_BASE+B+A}async function q4(A){if(A)try{const B=document.createElement("a");B.href=A,B.setAttribute("target","_blank"),B.click()}catch(B){console.error(B)}}const _4=(A,B)=>{try{const g=document.createElement("a"),Q=window.URL.createObjectURL(A);g.href=Q,g.download=B,document.body.appendChild(g),g.click(),setTimeout(function(){document.body.removeChild(g),window.URL.revokeObjectURL(Q)},0)}catch(g){console.error("Ошибка при загрузке файла:",g)}};aA.ApiService=zB,aA.AppButton=UE,aA.AppCheckbox=mF,aA.AppConfirmDialog=bh,aA.AppDatePicker=as,aA.AppDatepicker=Ks,aA.AppDropdown=xh,aA.AppFile=nd,aA.AppInput=xs,aA.AppInputNew=Tc,aA.AppInputSearch=Xs,aA.AppLayout=$s,aA.AppLayoutHeader=pU,aA.AppLayoutPage=SU,aA.AppLoader=Wc,aA.AppModal=Ed,aA.AppModalSelect=wY,aA.AppSelect=ZU,aA.AppSheet=wh,aA.AppSheetNew=Fh,aA.AppSidebar=dh,aA.AppTable=MY,aA.AppTableLayout=Qd,aA.AppTableModal=tG,aA.AppTablePagination=BY,aA.AppTableSearch=gY,aA.AppToggle=Hh,aA.AppWrapper=Nh,aA.base64ToBlob=Ws,aA.getFileFullPath=Z4,aA.isEqual=GC,aA.normalizeValue=Tw,aA.notificationSettings=Eo,aA.openFile=q4,aA.saveBlobAsFile=_4,aA.useAuthService=KH,aA.useBaseTable=x4,aA.useBrigadesService=cf,aA.useColumnSelector=O4,aA.useCommentsService=tf,aA.useControlsService=gf,aA.useEquipmentService=If,aA.useFaceApiHelper=K4,aA.useFileService=XH,aA.useGanttService=TH,aA.useInstrumentsService=Af,aA.useMetricsService=yH,aA.useModulesService=Ef,aA.useProjectsService=zH,aA.useRepairsService=bH,aA.useScheduleService=Mf,aA.useSearchService=wf,aA.useTableModel=X4,aA.useTasksService=LH,aA.useUserIssueService=Df,aA.useUserService=_H,aA.useVideoService=ZH,aA.uuidv4=Co,Object.defineProperty(aA,Symbol.toStringTag,{value:"Module"})});
@@ -16,6 +16,7 @@ export interface TableColumn {
16
16
  };
17
17
  format?: (val: any) => any;
18
18
  html?: boolean;
19
+ checkboxLabel?: string;
19
20
  }
20
21
  export interface FilterOption {
21
22
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shared-ritm",
3
- "version": "1.3.118",
3
+ "version": "1.3.119",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",
@@ -18,7 +18,7 @@ export function useColumnSelector(allColumns: ColumnConfig[], fixedColumnNames:
18
18
  type: 'checkbox',
19
19
  model: [...selectedColumnNames.value],
20
20
  items: allColumns.map(col => ({
21
- label: col.label,
21
+ label: col.checkboxLabel ?? col.label,
22
22
  value: col.name,
23
23
  disable: fixedColumnNames.includes(col.name),
24
24
  })),
@@ -17,6 +17,7 @@ export interface TableColumn {
17
17
  }
18
18
  format?: (val: any) => any
19
19
  html?: boolean
20
+ checkboxLabel?: string
20
21
  }
21
22
 
22
23
  export interface FilterOption {