shared-ritm 1.2.123 → 1.2.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/shared-ritm.es.js
CHANGED
|
@@ -36181,7 +36181,10 @@ const TD = (e) => {
|
|
|
36181
36181
|
const u = {};
|
|
36182
36182
|
for (const c of e.columns) {
|
|
36183
36183
|
const d = n.value[c.name], f = ((l = e.filtersOptions) == null ? void 0 : l.value[c.name]) || [];
|
|
36184
|
-
|
|
36184
|
+
if (d) {
|
|
36185
|
+
let h = [];
|
|
36186
|
+
Array.isArray(d) ? h = f.filter((p) => d.includes(p.name)).map((p) => p.id) : h = f.filter((p) => p.name === d).map((p) => p.id), u[c.name] = Array.from(new Set(h));
|
|
36187
|
+
}
|
|
36185
36188
|
}
|
|
36186
36189
|
return u;
|
|
36187
36190
|
}), i = (u) => {
|
package/dist/shared-ritm.umd.js
CHANGED
|
@@ -3831,4 +3831,4 @@ Manifest JSON has weights with names: `+I.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 wn=function(A,g){return wn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(B,Q){B.__proto__=Q}||function(B,Q){for(var w in Q)Q.hasOwnProperty(w)&&(B[w]=Q[w])},wn(A,g)};function LA(A,g){wn(A,g);function B(){this.constructor=A}A.prototype=g===null?Object.create(g):(B.prototype=g.prototype,new B)}var tg=function(){return tg=Object.assign||function(g){for(var B,Q=1,w=arguments.length;Q<w;Q++){B=arguments[Q];for(var C in B)Object.prototype.hasOwnProperty.call(B,C)&&(g[C]=B[C])}return g},tg.apply(this,arguments)};function JA(A,g,B,Q){function w(C){return C instanceof B?C:new B(function(E){E(C)})}return new(B||(B=Promise))(function(C,E){function e(n){try{t(Q.next(n))}catch(i){E(i)}}function I(n){try{t(Q.throw(n))}catch(i){E(i)}}function t(n){n.done?C(n.value):w(n.value).then(e,I)}t((Q=Q.apply(A,[])).next())})}function mA(A,g){var B={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(t){return function(n){return I([t,n])}}function I(t){if(Q)throw new TypeError("Generator is already executing.");for(;B;)try{if(Q=1,w&&(C=t[0]&2?w.return:t[0]?w.throw||((C=w.return)&&C.call(w),0):w.next)&&!(C=C.call(w,t[1])).done)return C;switch(w=0,C&&(t=[t[0]&2,C.value]),t[0]){case 0:case 1:C=t;break;case 4:return B.label++,{value:t[1],done:!1};case 5:B.label++,w=t[1],t=[0];continue;case 7:t=B.ops.pop(),B.trys.pop();continue;default:if(C=B.trys,!(C=C.length>0&&C[C.length-1])&&(t[0]===6||t[0]===2)){B=0;continue}if(t[0]===3&&(!C||t[1]>C[0]&&t[1]<C[3])){B.label=t[1];break}if(t[0]===6&&B.label<C[1]){B.label=C[1],C=t;break}if(C&&B.label<C[2]){B.label=C[2],B.ops.push(t);break}C[2]&&B.ops.pop(),B.trys.pop();continue}t=g.call(A,B)}catch(n){t=[6,n],w=0}finally{Q=C=0}if(t[0]&5)throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}function ZC(){for(var A=0,g=0,B=arguments.length;g<B;g++)A+=arguments[g].length;for(var Q=Array(A),w=0,g=0;g<B;g++)for(var C=arguments[g],E=0,e=C.length;E<e;E++,w++)Q[w]=C[E];return Q}var cw=function(){function A(g,B){if(!Yw(g)||!Yw(B))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:g,height:B}));this._width=g,this._height=B}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 Re(A,g){return A instanceof HB&&A.shape.length===g}function yR(A){return Re(A,2)}function Pe(A){return Re(A,3)}function jQ(A){return Re(A,4)}function zR(A){return A%1!==0}function eD(A){return A%2===0}function ID(A,g){g===void 0&&(g=2);var B=Math.pow(10,g);return Math.floor(A*B)/B}function oD(A){return A&&A.width&&A.height}function WR(A,g){var B=A.width,Q=A.height,w=g/Math.max(Q,B);return new cw(Math.round(B*w),Math.round(Q*w))}function Cn(A){return A.reduce(function(g,B){return g.add(B)},new cB(0,0)).div(new cB(A.length,A.length))}function qC(A,g,B){return Array(A).fill(0).map(function(Q,w){return g+w*B})}function Yw(A){return!!A&&A!==1/0&&A!==-1/0&&!isNaN(A)||A===0}function tD(A){return Yw(A)&&0<=A&&A<=1}var cB=function(){function A(g,B){this._x=g,this._y=B}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(g){return new A(this.x+g.x,this.y+g.y)},A.prototype.sub=function(g){return new A(this.x-g.x,this.y-g.y)},A.prototype.mul=function(g){return new A(this.x*g.x,this.y*g.y)},A.prototype.div=function(g){return new A(this.x/g.x,this.y/g.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}(),wQ=function(){function A(g,B){B===void 0&&(B=!0);var Q=g||{},w=[Q.left,Q.top,Q.right,Q.bottom].every(Yw),C=[Q.x,Q.y,Q.width,Q.height].every(Yw);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],I=E[1],t=E[2],n=E[3];A.assertIsValidBox({x:e,y:I,width:t,height:n},"Box.constructor",B),this._x=e,this._y=I,this._width=t,this._height=n}return A.isRect=function(g){return!!g&&[g.x,g.y,g.width,g.height].every(Yw)},A.assertIsValidBox=function(g,B,Q){if(Q===void 0&&(Q=!1),!A.isRect(g))throw new Error(B+" - invalid box: "+JSON.stringify(g)+", expected object with properties x, y, width, height");if(!Q&&(g.width<0||g.height<0))throw new Error(B+" - width ("+g.width+") and height ("+g.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 cB(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"topRight",{get:function(){return new cB(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"bottomLeft",{get:function(){return new cB(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"bottomRight",{get:function(){return new cB(this.right,this.bottom)},enumerable:!0,configurable:!0}),A.prototype.round=function(){var g=[this.x,this.y,this.width,this.height].map(function(E){return Math.round(E)}),B=g[0],Q=g[1],w=g[2],C=g[3];return new A({x:B,y:Q,width:w,height:C})},A.prototype.floor=function(){var g=[this.x,this.y,this.width,this.height].map(function(E){return Math.floor(E)}),B=g[0],Q=g[1],w=g[2],C=g[3];return new A({x:B,y:Q,width:w,height:C})},A.prototype.toSquare=function(){var g=this,B=g.x,Q=g.y,w=g.width,C=g.height,E=Math.abs(w-C);return w<C&&(B-=E/2,w+=E),C<w&&(Q-=E/2,C+=E),new A({x:B,y:Q,width:w,height:C})},A.prototype.rescale=function(g){var B=oD(g)?g.width:g,Q=oD(g)?g.height:g;return new A({x:this.x*B,y:this.y*Q,width:this.width*B,height:this.height*Q})},A.prototype.pad=function(g,B){var Q=[this.x-g/2,this.y-B/2,this.width+g,this.height+B],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(g,B){var Q=this,w=Q.x,C=Q.y,E=Q.right,e=Q.bottom,I=Math.max(w,0),t=Math.max(C,0),n=E-I,i=e-t,c=Math.min(n,g-I),Y=Math.min(i,B-t);return new A({x:I,y:t,width:c,height:Y}).floor()},A.prototype.shift=function(g,B){var Q=this,w=Q.width,C=Q.height,E=this.x+g,e=this.y+B;return new A({x:E,y:e,width:w,height:C})},A.prototype.padAtBorders=function(g,B){var Q=this.width+1,w=this.height+1,C=1,E=1,e=Q,I=w,t=this.left,n=this.top,i=this.right,c=this.bottom;return i>B&&(e=-i+B+Q,i=B),c>g&&(I=-c+g+w,c=g),t<1&&(I=2-t,t=1),n<1&&(I=2-n,n=1),{dy:E,edy:I,dx:C,edx:e,y:n,ey:c,x:t,ex:i,w:Q,h:w}},A.prototype.calibrate=function(g){return new A({left:this.left+g.left*this.width,top:this.top+g.top*this.height,right:this.right+g.right*this.width,bottom:this.bottom+g.bottom*this.height}).toSquare().round()},A}(),ve=function(A){LA(g,A);function g(B,Q,w,C,E){return E===void 0&&(E=!1),A.call(this,{left:B,top:Q,right:w,bottom:C},E)||this}return g}(wQ),nD=function(){function A(g,B,Q,w,C){this._imageDims=new cw(C.width,C.height),this._score=g,this._classScore=B,this._className=Q,this._box=new wQ(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 wQ(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),A.prototype.forSize=function(g,B){return new A(this.score,this.classScore,this.className,this.relativeBox,{width:g,height:B})},A}(),mg=function(A){LA(g,A);function g(B,Q,w){return A.call(this,B,B,"",Q,w)||this}return g.prototype.forSize=function(B,Q){var w=A.prototype.forSize.call(this,B,Q),C=w.score,E=w.relativeBox,e=w.imageDims;return new g(C,E,e)},g}(nD);function bR(A,g,B){B===void 0&&(B=!0);var Q=Math.max(0,Math.min(A.right,g.right)-Math.max(A.left,g.left)),w=Math.max(0,Math.min(A.bottom,g.bottom)-Math.max(A.top,g.top)),C=Q*w;return B?C/(A.area+g.area-C):C/Math.min(A.area,g.area)}function SR(A){var g=A.map(function(e){return e.x}),B=A.map(function(e){return e.y}),Q=g.reduce(function(e,I){return I<e?I:e},1/0),w=B.reduce(function(e,I){return I<e?I:e},1/0),C=g.reduce(function(e,I){return e<I?I:e},0),E=B.reduce(function(e,I){return e<I?I:e},0);return new ve(Q,w,C,E)}function _C(A,g,B,Q){Q===void 0&&(Q=!0);for(var w=g.map(function(e,I){return{score:e,boxIndex:I}}).sort(function(e,I){return e.score-I.score}).map(function(e){return e.boxIndex}),C=[],E=function(){var e=w.pop();C.push(e);for(var I=w,t=[],n=0;n<I.length;n++){var i=I[n],c=A[e],Y=A[i];t.push(bR(c,Y,Q))}w=w.filter(function(M,D){return t[D]<=B})};w.length>0;)E();return C}function $C(A,g){return FA(function(){var B=g[0],Q=g[1],w=g[2],C=gQ(ZC(A.shape.slice(0,3),[1]),B),E=gQ(ZC(A.shape.slice(0,3),[1]),Q),e=gQ(ZC(A.shape.slice(0,3),[1]),w),I=zB([C,E,e],3);return SB(A,I)})}function LR(A,g){return g===void 0&&(g=!1),FA(function(){var B=A.shape.slice(1),Q=B[0],w=B[1];if(Q===w)return A;var C=Math.abs(Q-w),E=Math.round(C*(g?.5:1)),e=Q>w?2:1,I=function(Y){var M=A.shape.slice();return M[e]=Y,gQ(M,0)},t=I(E),n=C-t.shape[e],i=g&&n?I(n):null,c=[i,A,t].filter(function(Y){return!!Y}).map(function(Y){return Y.toFloat()});return zB(c,e)})}function En(A){return 1/(1+Math.exp(-A))}var ke=function(A){LA(g,A);function g(B,Q,w,C,E){return E===void 0&&(E=!1),A.call(this,{x:B,y:Q,width:w,height:C},E)||this}return g}(wQ),VR=.5,KR=.43,xR=.45,wC=function(){function A(g,B,Q){Q===void 0&&(Q=new cB(0,0));var w=B.width,C=B.height;this._imgDims=new cw(w,C),this._shift=Q,this._positions=g.map(function(E){return E.mul(new cB(w,C)).add(Q)})}return Object.defineProperty(A.prototype,"shift",{get:function(){return new cB(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 g=this;return this._positions.map(function(B){return B.sub(g._shift).div(new cB(g.imageWidth,g.imageHeight))})},enumerable:!0,configurable:!0}),A.prototype.forSize=function(g,B){return new this.constructor(this.relativePositions,{width:g,height:B})},A.prototype.shiftBy=function(g,B){return new this.constructor(this.relativePositions,this._imgDims,new cB(g,B))},A.prototype.shiftByPoint=function(g){return this.shiftBy(g.x,g.y)},A.prototype.align=function(g,B){if(B===void 0&&(B={}),g){var Q=g instanceof mg?g.box.floor():new wQ(g);return this.shiftBy(Q.x,Q.y).align(null,B)}var w=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},B),C=w.useDlibAlignment,E=w.minBoxPadding;return C?this.alignDlib():this.alignMinBbox(E)},A.prototype.alignDlib=function(){var g=this.getRefPointsForAlignment(),B=g[0],Q=g[1],w=g[2],C=function(i){return w.sub(i).magnitude()},E=(C(B)+C(Q))/2,e=Math.floor(E/xR),I=Cn(g),t=Math.floor(Math.max(0,I.x-VR*e)),n=Math.floor(Math.max(0,I.y-KR*e));return new ke(t,n,Math.min(e,this.imageWidth+t),Math.min(e,this.imageHeight+n))},A.prototype.alignMinBbox=function(g){var B=SR(this.positions);return B.pad(B.width*g,B.height*g)},A.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},A}(),XR=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.getRefPointsForAlignment=function(){var B=this.positions;return[B[0],B[1],Cn([B[3],B[4]])]},g}(wC),iD=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.getJawOutline=function(){return this.positions.slice(0,17)},g.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},g.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},g.prototype.getNose=function(){return this.positions.slice(27,36)},g.prototype.getLeftEye=function(){return this.positions.slice(36,42)},g.prototype.getRightEye=function(){return this.positions.slice(42,48)},g.prototype.getMouth=function(){return this.positions.slice(48,68)},g.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Cn)},g}(wC),cD=function(){function A(g,B){this._label=g,this._distance=B}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(g){return g===void 0&&(g=!0),""+this.label+(g?" ("+ID(this.distance)+")":"")},A}(),YD=function(A){LA(g,A);function g(B,Q){var w=A.call(this,B)||this;return w._label=Q,w}return g.assertIsValidLabeledBox=function(B,Q){if(wQ.assertIsValidBox(B,Q),!Yw(B.label))throw new Error(Q+" - expected property label ("+B.label+") to be a number")},Object.defineProperty(g.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),g}(wQ),Te=function(){function A(g,B){if(typeof g!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(B)||B.some(function(Q){return!(Q instanceof Float32Array)}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=g,this._descriptors=B}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(g){return Array.from(g)})}},A.fromJSON=function(g){var B=g.descriptors.map(function(Q){return new Float32Array(Q)});return new A(g.label,B)},A}();(function(A){LA(g,A);function g(B,Q,w,C){var E=A.call(this,B,Q)||this;return E._score=w,E._classScore=C,E}return g.assertIsValidPredictedBox=function(B,Q){if(YD.assertIsValidLabeledBox(B,Q),!tD(B.score)||!tD(B.classScore))throw new Error(Q+" - expected properties score ("+B.score+") and ("+B.classScore+") to be a number between [0, 1]")},Object.defineProperty(g.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),g})(YD);function je(A){return A.detection instanceof mg}function AE(A,g){var B={detection:g};return Object.assign({},A,B)}function MD(){var A=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")},g=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:g}}function rD(A){var g="";if(!A)try{A=require("fs")}catch(Q){g=Q.toString()}var B=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: "+g)};return{readFile:B}}function DD(){var A=global.Canvas||global.HTMLCanvasElement,g=global.Image||global.HTMLImageElement,B=function(){if(A)return new A;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},Q=function(){if(g)return new g;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=rD();return tg({Canvas:A||function(){function E(){}return E}(),CanvasRenderingContext2D:global.CanvasRenderingContext2D||function(){function E(){}return E}(),Image:g||function(){function E(){}return E}(),ImageData:global.ImageData||function(){function E(){}return E}(),Video:global.HTMLVideoElement||function(){function E(){}return E}(),createCanvasElement:B,createImageElement:Q,fetch:w},C)}function FD(){return typeof window=="object"&&typeof document<"u"&&typeof HTMLImageElement<"u"&&typeof HTMLCanvasElement<"u"&&typeof HTMLVideoElement<"u"&&typeof ImageData<"u"&&typeof CanvasRenderingContext2D<"u"}function aD(){return typeof global=="object"&&typeof require=="function"&&typeof module<"u"&&typeof process<"u"&&!!process.version}var LB;function OR(){if(!LB)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return LB}function en(A){LB=A}function In(){FD()&&en(MD()),aD()&&en(DD())}function ZR(A){if(LB||In(),!LB)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var g=A.Canvas,B=g===void 0?LB.Canvas:g,Q=A.Image,w=Q===void 0?LB.Image:Q;LB.Canvas=B,LB.Image=w,LB.createCanvasElement=A.createCanvasElement||function(){return new B},LB.createImageElement=A.createImageElement||function(){return new w},LB.ImageData=A.ImageData||LB.ImageData,LB.Video=A.Video||LB.Video,LB.fetch=A.fetch||LB.fetch,LB.readFile=A.readFile||LB.readFile}var ng={getEnv:OR,setEnv:en,initialize:In,createBrowserEnv:MD,createFileSystem:rD,createNodejsEnv:DD,monkeyPatch:ZR,isBrowser:FD,isNodejs:aD};In();function on(A){return!ng.isNodejs()&&typeof A=="string"?document.getElementById(A):A}function CQ(A){var g=ng.getEnv(),B=g.Canvas,Q=g.CanvasRenderingContext2D;if(A instanceof Q)return A;var w=on(A);if(!(w instanceof B))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 sD=function(){function A(g){g===void 0&&(g={});var B=g.anchorPosition,Q=g.backgroundColor,w=g.fontColor,C=g.fontSize,E=g.fontStyle,e=g.padding;this.anchorPosition=B||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}(),qR=function(){function A(g,B,Q){Q===void 0&&(Q={}),this.text=typeof g=="string"?[g]:g instanceof A?g.text:g,this.anchor=B,this.options=new sD(Q)}return A.prototype.measureWidth=function(g){var B=this.options.padding;return this.text.map(function(Q){return g.measureText(Q).width}).reduce(function(Q,w){return Q<w?w:Q},0)+2*B},A.prototype.measureHeight=function(){var g=this.options,B=g.fontSize,Q=g.padding;return this.text.length*B+2*Q},A.prototype.getUpperLeft=function(g,B){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(g),e=this.measureHeight(),I=w?this.anchor.x-E:this.anchor.x,t=C?this.anchor.y-e:this.anchor.y;if(B){var n=B.width,i=B.height,c=Math.max(Math.min(I,n-E),0),Y=Math.max(Math.min(t,i-e),0);return{x:c,y:Y}}return{x:I,y:t}},A.prototype.draw=function(g){var B=on(g),Q=CQ(B),w=this.options,C=w.backgroundColor,E=w.fontColor,e=w.fontSize,I=w.fontStyle,t=w.padding;Q.font=e+"px "+I;var n=this.measureWidth(Q),i=this.measureHeight();Q.fillStyle=C;var c=this.getUpperLeft(Q,B);Q.fillRect(c.x,c.y,n,i),Q.fillStyle=E,this.text.forEach(function(Y,M){var D=t+c.x,r=t+c.y+(M+1)*e;Q.fillText(Y,D,r)})},A}(),_R=function(){function A(g){g===void 0&&(g={});var B=g.boxColor,Q=g.lineWidth,w=g.label,C=g.drawLabelOptions;this.boxColor=B||"rgba(0, 0, 255, 1)",this.lineWidth=Q||2,this.label=w;var E={anchorPosition:pQ.BOTTOM_LEFT,backgroundColor:this.boxColor};this.drawLabelOptions=new sD(Object.assign({},E,C))}return A}(),$R=function(){function A(g,B){B===void 0&&(B={}),this.box=new wQ(g),this.options=new _R(B)}return A.prototype.draw=function(g){var B=CQ(g),Q=this.options,w=Q.boxColor,C=Q.lineWidth,E=this.box,e=E.x,I=E.y,t=E.width,n=E.height;B.strokeStyle=w,B.lineWidth=C,B.strokeRect(e,I,t,n);var i=this.options.label;i&&new qR([i],{x:e-C/2,y:I},this.options.drawLabelOptions).draw(g)},A}();function AP(A,g){var B=Array.isArray(g)?g:[g];B.forEach(function(Q){var w=Q instanceof mg?Q.score:je(Q)?Q.detection.score:void 0,C=Q instanceof mg?Q.box:je(Q)?Q.detection.box:new wQ(Q),E=w?""+ID(w):void 0;new $R(C,{label:E}).draw(A)})}function uD(A){var g=ng.getEnv(),B=g.Image,Q=g.Video;return A instanceof B&&A.complete||A instanceof Q&&A.readyState>=3}function BP(A){return new Promise(function(g,B){if(A instanceof ng.getEnv().Canvas||uD(A))return g();function Q(C){C.currentTarget&&(C.currentTarget.removeEventListener("load",Q),C.currentTarget.removeEventListener("error",w),g(C))}function w(C){C.currentTarget&&(C.currentTarget.removeEventListener("load",Q),C.currentTarget.removeEventListener("error",w),B(C))}A.addEventListener("load",Q),A.addEventListener("error",w)})}function tn(A){var g=ng.getEnv(),B=g.Image,Q=g.Video;return A instanceof B?new cw(A.naturalWidth,A.naturalHeight):A instanceof Q?new cw(A.videoWidth,A.videoHeight):new cw(A.width,A.height)}function pe(A){var g=A.width,B=A.height,Q=ng.getEnv().createCanvasElement,w=Q();return w.width=g,w.height=B,w}function ye(A,g){var B=ng.getEnv().ImageData;if(!(A instanceof B)&&!uD(A))throw new Error("createCanvasFromMedia - media has not finished loading yet");var Q=tn(A),w=Q.width,C=Q.height,E=pe({width:w,height:C});return A instanceof B?CQ(E).putImageData(A,0,0):CQ(E).drawImage(A,0,0,w,C),E}function gP(A,g){return JA(this,void 0,void 0,function(){var B,Q,w,C,E,e;return mA(this,function(I){switch(I.label){case 0:return B=ng.getEnv().createCanvasElement(),Q=A.shape.slice(jQ(A)?1:0),w=Q[0],C=Q[1],E=Q[2],e=FA(function(){return A.as3D(w,C,E).toInt()}),[4,Qn.toPixels(e,B)];case 1:return I.sent(),e.dispose(),[2,B]}})})}function UD(A){var g=ng.getEnv(),B=g.Image,Q=g.Canvas,w=g.Video;return A instanceof B||A instanceof Q||A instanceof w}function QP(A,g,B){B===void 0&&(B=!1);var Q=ng.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=tn(A),e=g/Math.max(E.height,E.width),I=e*E.width,t=e*E.height,n=pe({width:g,height:g}),i=A instanceof C?A:ye(A),c=Math.abs(I-t)/2,Y=B&&I<t?c:0,M=B&&t<I?c:0;return CQ(n).drawImage(i,Y,M,I,t),n}var ze=function(){function A(g,B){var Q=this;if(B===void 0&&(B=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(g))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+g);this._treatAsBatchInput=B,this._batchSize=g.length,g.forEach(function(w,C){if(Pe(w)){Q._imageTensors[C]=w,Q._inputDimensions[C]=w.shape;return}if(jQ(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 ng.getEnv().Canvas?w:ye(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 g=this;return qC(this.batchSize,0,1).map(function(B,Q){return g.getReshapedInputDimensions(Q)})},enumerable:!0,configurable:!0}),A.prototype.getInput=function(g){return this.canvases[g]||this.imageTensors[g]},A.prototype.getInputDimensions=function(g){return this._inputDimensions[g]},A.prototype.getInputHeight=function(g){return this._inputDimensions[g][0]},A.prototype.getInputWidth=function(g){return this._inputDimensions[g][1]},A.prototype.getReshapedInputDimensions=function(g){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");var B=this.getInputWidth(g),Q=this.getInputHeight(g);return WR({width:B,height:Q},this.inputSize)},A.prototype.toBatchTensor=function(g,B){var Q=this;return B===void 0&&(B=!0),this._inputSize=g,FA(function(){var w=qC(Q.batchSize,0,1).map(function(E){var e=Q.getInput(E);if(e instanceof HB){var I=jQ(e)?e:e.expandDims();return I=LR(I,B),(I.shape[1]!==g||I.shape[2]!==g)&&(I=yt.resizeBilinear(I,[g,g])),I.as3D(g,g,3)}if(e instanceof ng.getEnv().Canvas)return Qn.fromPixels(QP(e,g,B));throw new Error("toBatchTensor - at batchIdx "+E+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+e)}),C=fg(w.map(function(E){return E.toFloat()})).as4D(Q.batchSize,g,g,3);return C})},A}();function ZB(A){return JA(this,void 0,void 0,function(){var g,B,Q;return mA(this,function(w){switch(w.label){case 0:if(A instanceof ze)return[2,A];if(g=Array.isArray(A)?A:[A],!g.length)throw new Error("toNetInput - empty array passed as input");return B=function(C){return Array.isArray(A)?" at input index "+C+":":""},Q=g.map(on),Q.forEach(function(C,E){if(!UD(C)&&!Pe(C)&&!jQ(C))throw typeof g[E]=="string"?new Error("toNetInput -"+B(E)+" string passed, but could not resolve HTMLElement for element id "+g[E]):new Error("toNetInput -"+B(E)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");if(jQ(C)){var e=C.shape[0];if(e!==1)throw new Error("toNetInput -"+B(E)+" tf.Tensor4D with batchSize "+e+" passed, but not supported in input array")}}),[4,Promise.all(Q.map(function(C){return UD(C)&&BP(C)}))];case 1:return w.sent(),[2,new ze(Q,Array.isArray(A))]}})})}function We(A,g){return JA(this,void 0,void 0,function(){var B,Q,w,C,E,e,I;return mA(this,function(t){switch(t.label){case 0:return B=ng.getEnv().Canvas,Q=A,A instanceof B?[3,5]:[4,ZB(A)];case 1:if(w=t.sent(),w.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return C=w.getInput(0),C instanceof B?(E=C,[3,4]):[3,2];case 2:return[4,gP(C)];case 3:E=t.sent(),t.label=4;case 4:Q=E,t.label=5;case 5:return e=CQ(Q),I=g.map(function(n){return n instanceof mg?n.forSize(Q.width,Q.height).box.floor():n}).map(function(n){return n.clipAtImageBorders(Q.width,Q.height)}),[2,I.map(function(n){var i=n.x,c=n.y,Y=n.width,M=n.height,D=pe({width:Y,height:M});return CQ(D).putImageData(e.getImageData(i,c,Y,M),0,0),D})]}})})}function nn(A,g){return JA(this,void 0,void 0,function(){return mA(this,function(B){if(!Pe(A)&&!jQ(A))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(jQ(A)&&A.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,FA(function(){var Q=A.shape.slice(jQ(A)?1:0),w=Q[0],C=Q[1],E=Q[2],e=g.map(function(t){return t instanceof mg?t.forSize(C,w).box:t}).map(function(t){return t.clipAtImageBorders(C,w)}),I=e.map(function(t){var n=t.x,i=t.y,c=t.width,Y=t.height;return Jr(A.as3D(w,C,E),[i,n,0],[Y,c,E])});return I})]})})}function wP(A,g){return JA(this,void 0,void 0,function(){var B,Q;return mA(this,function(w){switch(w.label){case 0:return B=ng.getEnv().fetch,[4,B(A,g)];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 CP(A){return JA(this,void 0,void 0,function(){return mA(this,function(g){switch(g.label){case 0:return[4,wP(A)];case 1:return[2,g.sent().json()]}})})}function lD(A,g){var B=g+"-weights_manifest.json";if(!A)return{modelBaseUri:"",manifestUri:B};if(A==="/")return{modelBaseUri:"/",manifestUri:"/"+B};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]:B,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 EP(A,g){return JA(this,void 0,void 0,function(){var B,Q,w,C;return mA(this,function(E){switch(E.label){case 0:return B=lD(A,g),Q=B.manifestUri,w=B.modelBaseUri,[4,CP(Q)];case 1:return C=E.sent(),[2,CD.loadWeights(C,w)]}})})}function eP(A,g,B){B===void 0&&(B=!1);var Q=B?tn(g):g,w=Q.width,C=Q.height;return A.width=w,A.height=C,{width:w,height:C}}var UQ=function(){function A(g){this._name=g,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(g){var B=this.traversePropertyPath(g),Q=B.obj,w=B.objProp;return Q[w]},A.prototype.reassignParamFromPath=function(g,B){var Q=this.traversePropertyPath(g),w=Q.obj,C=Q.objProp;w[C].dispose(),w[C]=B},A.prototype.getParamList=function(){var g=this;return this._paramMappings.map(function(B){var Q=B.paramPath;return{path:Q,tensor:g.getParamFromPath(Q)}})},A.prototype.getTrainableParams=function(){return this.getParamList().filter(function(g){return g.tensor instanceof bw})},A.prototype.getFrozenParams=function(){return this.getParamList().filter(function(g){return!(g.tensor instanceof bw)})},A.prototype.variable=function(){var g=this;this.getFrozenParams().forEach(function(B){var Q=B.path,w=B.tensor;g.reassignParamFromPath(Q,w.variable())})},A.prototype.freeze=function(){var g=this;this.getTrainableParams().forEach(function(B){var Q=B.path,w=B.tensor,C=wg(w.dataSync());w.dispose(),g.reassignParamFromPath(Q,C)})},A.prototype.dispose=function(g){g===void 0&&(g=!0),this.getParamList().forEach(function(B){if(g&&B.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+B.path);B.tensor.dispose()}),this._params=void 0},A.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(g){var B=g.tensor;return Array.from(B.dataSync())}).reduce(function(g,B){return g.concat(B)}))},A.prototype.load=function(g){return JA(this,void 0,void 0,function(){return mA(this,function(B){switch(B.label){case 0:return g instanceof Float32Array?(this.extractWeights(g),[2]):[4,this.loadFromUri(g)];case 1:return B.sent(),[2]}})})},A.prototype.loadFromUri=function(g){return JA(this,void 0,void 0,function(){var B;return mA(this,function(Q){switch(Q.label){case 0:if(g&&typeof g!="string")throw new Error(this._name+".loadFromUri - expected model uri");return[4,EP(g,this.getDefaultModelName())];case 1:return B=Q.sent(),this.loadFromWeightMap(B),[2]}})})},A.prototype.loadFromDisk=function(g){return JA(this,void 0,void 0,function(){var B,Q,w,C,E,e,I,t,n,i;return mA(this,function(c){switch(c.label){case 0:if(g&&typeof g!="string")throw new Error(this._name+".loadFromDisk - expected model file path");return B=ng.getEnv().readFile,Q=lD(g,this.getDefaultModelName()),w=Q.manifestUri,C=Q.modelBaseUri,E=function(Y){return Promise.all(Y.map(function(M){return B(M).then(function(D){return D.buffer})}))},e=CD.weightsLoaderFactory(E),n=(t=JSON).parse,[4,B(w)];case 1:return I=n.apply(t,[c.sent().toString()]),[4,e(I,C)];case 2:return i=c.sent(),this.loadFromWeightMap(i),[2]}})})},A.prototype.loadFromWeightMap=function(g){var B=this.extractParamsFromWeigthMap(g),Q=B.paramMappings,w=B.params;this._paramMappings=Q,this._params=w},A.prototype.extractWeights=function(g){var B=this.extractParams(g),Q=B.paramMappings,w=B.params;this._paramMappings=Q,this._params=w},A.prototype.traversePropertyPath=function(g){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var B=g.split("/").reduce(function(C,E){if(!C.nextObj.hasOwnProperty(E))throw new Error("traversePropertyPath - object does not have property "+E+", for path "+g);return{obj:C.nextObj,objProp:E,nextObj:C.nextObj[E]}},{nextObj:this.params}),Q=B.obj,w=B.objProp;if(!Q||!w||!(Q[w]instanceof HB))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+g);return{obj:Q,objProp:w}},A}();function Ng(A,g,B){return FA(function(){var Q=vt(A,g.depthwise_filter,g.pointwise_filter,B,"same");return Q=BB(Q,g.bias),Q})}function cn(A,g,B){return B===void 0&&(B=!1),FA(function(){var Q=JB(B?BB(jg(A,g.conv0.filters,[2,2],"same"),g.conv0.bias):Ng(A,g.conv0,[2,2])),w=Ng(Q,g.conv1,[1,1]),C=JB(BB(Q,w)),E=Ng(C,g.conv2,[1,1]);return JB(BB(Q,BB(w,E)))})}function be(A,g,B,Q){return B===void 0&&(B=!1),Q===void 0&&(Q=!0),FA(function(){var w=JB(B?BB(jg(A,g.conv0.filters,Q?[2,2]:[1,1],"same"),g.conv0.bias):Ng(A,g.conv0,Q?[2,2]:[1,1])),C=Ng(w,g.conv1,[1,1]),E=JB(BB(w,C)),e=Ng(E,g.conv2,[1,1]),I=JB(BB(w,BB(C,e))),t=Ng(I,g.conv3,[1,1]);return JB(BB(w,BB(C,BB(e,t))))})}function Vg(A,g,B,Q){return B===void 0&&(B="same"),Q===void 0&&(Q=!1),FA(function(){var w=BB(jg(A,g.filters,[1,1],B),g.bias);return Q?JB(w):w})}function lQ(A,g){Object.keys(A).forEach(function(B){g.some(function(Q){return Q.originalPath===B})||A[B].dispose()})}function Se(A,g){return function(B,Q,w,C){var E=ag(A(B*Q*w*w),[w,w,B,Q]),e=pB(A(Q));return g.push({paramPath:C+"/filters"},{paramPath:C+"/bias"}),{filters:E,bias:e}}}function Yn(A,g){return function(B,Q,w){var C=RQ(A(B*Q),[B,Q]),E=pB(A(Q));return g.push({paramPath:w+"/weights"},{paramPath:w+"/bias"}),{weights:C,bias:E}}}var hD=function(){function A(g,B,Q){this.depthwise_filter=g,this.pointwise_filter=B,this.bias=Q}return A}();function Mn(A,g){return function(B,Q,w){var C=ag(A(9*B),[3,3,B,1]),E=ag(A(B*Q),[1,1,B,Q]),e=pB(A(Q));return g.push({paramPath:w+"/depthwise_filter"},{paramPath:w+"/pointwise_filter"},{paramPath:w+"/bias"}),new hD(C,E,e)}}function rn(A){return function(g){var B=A(g+"/depthwise_filter",4),Q=A(g+"/pointwise_filter",4),w=A(g+"/bias",1);return new hD(B,Q,w)}}function yQ(A,g){return function(B,Q,w){var C=A[B];if(!Re(C,Q))throw new Error("expected weightMap["+B+"] to be a Tensor"+Q+"D, instead have "+C);return g.push({originalPath:B,paramPath:w||B}),C}}function hQ(A){var g=A;function B(w){var C=g.slice(0,w);return g=g.slice(w),C}function Q(){return g}return{extractWeights:B,getRemainingWeights:Q}}function GD(A,g){var B=Se(A,g),Q=Mn(A,g);function w(E,e,I,t){t===void 0&&(t=!1);var n=t?B(E,e,3,I+"/conv0"):Q(E,e,I+"/conv0"),i=Q(e,e,I+"/conv1"),c=Q(e,e,I+"/conv2");return{conv0:n,conv1:i,conv2:c}}function C(E,e,I,t){t===void 0&&(t=!1);var n=w(E,e,I,t),i=n.conv0,c=n.conv1,Y=n.conv2,M=Q(e,e,I+"/conv3");return{conv0:i,conv1:c,conv2:Y,conv3:M}}return{extractDenseBlock3Params:w,extractDenseBlock4Params:C}}function IP(A){var g=[],B=hQ(A),Q=B.extractWeights,w=B.getRemainingWeights,C=GD(Q,g).extractDenseBlock4Params,E=C(3,32,"dense0",!0),e=C(32,64,"dense1"),I=C(64,128,"dense2"),t=C(128,256,"dense3");if(w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{paramMappings:g,params:{dense0:E,dense1:e,dense2:I,dense3:t}}}function dD(A){return function(g){var B=A(g+"/filters",4),Q=A(g+"/bias",1);return{filters:B,bias:Q}}}function HD(A,g){var B=yQ(A,g),Q=dD(B),w=rn(B);function C(e,I){I===void 0&&(I=!1);var t=I?Q(e+"/conv0"):w(e+"/conv0"),n=w(e+"/conv1"),i=w(e+"/conv2");return{conv0:t,conv1:n,conv2:i}}function E(e,I){I===void 0&&(I=!1);var t=I?Q(e+"/conv0"):w(e+"/conv0"),n=w(e+"/conv1"),i=w(e+"/conv2"),c=w(e+"/conv3");return{conv0:t,conv1:n,conv2:i,conv3:c}}return{extractDenseBlock3Params:C,extractDenseBlock4Params:E}}function oP(A){var g=[],B=HD(A,g).extractDenseBlock4Params,Q={dense0:B("dense0",!0),dense1:B("dense1"),dense2:B("dense2"),dense3:B("dense3")};return lQ(A,g),{params:Q,paramMappings:g}}var fD=function(A){LA(g,A);function g(){return A.call(this,"FaceFeatureExtractor")||this}return g.prototype.forwardInput=function(B){var Q=this.params;if(!Q)throw new Error("FaceFeatureExtractor - load model before inference");return FA(function(){var w=B.toBatchTensor(112,!0),C=[122.782,117.001,104.298],E=$C(w,C).div(cA(255)),e=be(E,Q.dense0,!0);return e=be(e,Q.dense1),e=be(e,Q.dense2),e=be(e,Q.dense3),e=XC(e,[7,7],[2,2],"valid"),e})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},g.prototype.extractParamsFromWeigthMap=function(B){return oP(B)},g.prototype.extractParams=function(B){return IP(B)},g}(UQ);function EQ(A,g){return FA(function(){return BB(de(A,g.weights),g.bias)})}function tP(A,g,B){var Q=[],w=hQ(A),C=w.extractWeights,E=w.getRemainingWeights,e=Yn(C,Q),I=e(g,B,"fc");if(E().length!==0)throw new Error("weights remaing after extract: "+E().length);return{paramMappings:Q,params:{fc:I}}}function nP(A){var g=[],B=yQ(A,g);function Q(C){var E=B(C+"/weights",2),e=B(C+"/bias",1);return{weights:E,bias:e}}var w={fc:Q("fc")};return lQ(A,g),{params:w,paramMappings:g}}function JD(A){var g={},B={};return Object.keys(A).forEach(function(Q){var w=Q.startsWith("fc")?B:g;w[Q]=A[Q]}),{featureExtractorMap:g,classifierMap:B}}var mD=function(A){LA(g,A);function g(B,Q){var w=A.call(this,B)||this;return w._faceFeatureExtractor=Q,w}return Object.defineProperty(g.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),g.prototype.runNet=function(B){var Q=this,w=this.params;if(!w)throw new Error(this._name+" - load model before inference");return FA(function(){var C=B instanceof ze?Q.faceFeatureExtractor.forwardInput(B):B;return EQ(C.as2D(C.shape[0],-1),w.fc)})},g.prototype.dispose=function(B){B===void 0&&(B=!0),this.faceFeatureExtractor.dispose(B),A.prototype.dispose.call(this,B)},g.prototype.loadClassifierParams=function(B){var Q=this.extractClassifierParams(B),w=Q.params,C=Q.paramMappings;this._params=w,this._paramMappings=C},g.prototype.extractClassifierParams=function(B){return tP(B,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},g.prototype.extractParamsFromWeigthMap=function(B){var Q=JD(B),w=Q.featureExtractorMap,C=Q.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(w),nP(C)},g.prototype.extractParams=function(B){var Q=this.getClassifierChannelsIn(),w=this.getClassifierChannelsOut(),C=w*Q+w,E=B.slice(0,B.length-C),e=B.slice(B.length-C);return this.faceFeatureExtractor.extractWeights(E),this.extractClassifierParams(e)},g}(UQ),ND=["neutral","happy","sad","angry","fearful","disgusted","surprised"],iP=function(){function A(g){var B=this;if(g.length!==7)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+g.length);ND.forEach(function(Q,w){B[Q]=g[w]})}return A.prototype.asSortedArray=function(){var g=this;return ND.map(function(B){return{expression:B,probability:g[B]}}).sort(function(B,Q){return Q.probability-B.probability})},A}(),cP=function(A){LA(g,A);function g(B){return B===void 0&&(B=new fD),A.call(this,"FaceExpressionNet",B)||this}return g.prototype.forwardInput=function(B){var Q=this;return FA(function(){return FQ(Q.runNet(B))})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.predictExpressions=function(B){return JA(this,void 0,void 0,function(){var Q,w,C,E,e=this;return mA(this,function(I){switch(I.label){case 0:return[4,ZB(B)];case 1:return Q=I.sent(),[4,this.forwardInput(Q)];case 2:return w=I.sent(),[4,Promise.all(WB(w).map(function(t){return JA(e,void 0,void 0,function(){var n;return mA(this,function(i){switch(i.label){case 0:return[4,t.data()];case 1:return n=i.sent(),t.dispose(),[2,n]}})})}))];case 3:return C=I.sent(),w.dispose(),E=C.map(function(t){return new iP(t)}),[2,Q.isBatchInput?E:E[0]]}})})},g.prototype.getDefaultModelName=function(){return"face_expression_model"},g.prototype.getClassifierChannelsIn=function(){return 256},g.prototype.getClassifierChannelsOut=function(){return 7},g}(mD);function RD(A,g){var B={expressions:g};return Object.assign({},A,B)}function Dn(A){return je(A)&&A.landmarks instanceof wC&&A.unshiftedLandmarks instanceof wC&&A.alignedRect instanceof mg}function Le(A,g){var B=A.detection.box,Q=g.shiftBy(B.x,B.y),w=Q.align(),C=A.detection.imageDims,E=new mg(A.detection.score,w.rescale(C.reverse()),C),e={landmarks:Q,unshiftedLandmarks:g,alignedRect:E};return Object.assign({},A,e)}var YP=function(){function A(g){g===void 0&&(g={});var B=g.drawLines,Q=B===void 0?!0:B,w=g.drawPoints,C=w===void 0?!0:w,E=g.lineWidth,e=g.lineColor,I=g.pointSize,t=g.pointColor;this.drawLines=Q,this.drawPoints=C,this.lineWidth=E||1,this.pointSize=I||2,this.lineColor=e||"rgba(0, 255, 255, 1)",this.pointColor=t||"rgba(255, 0, 255, 1)"}return A}(),MP=function(){function A(g,B){B===void 0&&(B={}),this.faceLandmarks=g,this.options=new YP(B)}return A.prototype.draw=function(g){var B=CQ(g),Q=this.options,w=Q.drawLines,C=Q.drawPoints,E=Q.lineWidth,e=Q.lineColor,I=Q.pointSize,t=Q.pointColor;if(w&&this.faceLandmarks instanceof iD&&(B.strokeStyle=e,B.lineWidth=E,iw(B,this.faceLandmarks.getJawOutline()),iw(B,this.faceLandmarks.getLeftEyeBrow()),iw(B,this.faceLandmarks.getRightEyeBrow()),iw(B,this.faceLandmarks.getNose()),iw(B,this.faceLandmarks.getLeftEye(),!0),iw(B,this.faceLandmarks.getRightEye(),!0),iw(B,this.faceLandmarks.getMouth(),!0)),C){B.strokeStyle=t,B.fillStyle=t;var n=function(i){B.beginPath(),B.arc(i.x,i.y,I,0,2*Math.PI),B.fill()};this.faceLandmarks.positions.forEach(n)}},A}();function rP(A,g){var B=Array.isArray(g)?g:[g];B.forEach(function(Q){var w=Q instanceof wC?Q:Dn(Q)?Q.landmarks:void 0;if(!w)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>> or array thereof");new MP(w).draw(A)})}function DP(A,g){var B=Se(A,g),Q=Mn(A,g);function w(E,e,I){var t=Q(E,e,I+"/separable_conv0"),n=Q(e,e,I+"/separable_conv1"),i=B(E,e,1,I+"/expansion_conv");return{separable_conv0:t,separable_conv1:n,expansion_conv:i}}function C(E,e){var I=Q(E,E,e+"/separable_conv0"),t=Q(E,E,e+"/separable_conv1"),n=Q(E,E,e+"/separable_conv2");return{separable_conv0:I,separable_conv1:t,separable_conv2:n}}return{extractConvParams:B,extractSeparableConvParams:Q,extractReductionBlockParams:w,extractMainBlockParams:C}}function FP(A,g){var B=[],Q=hQ(A),w=Q.extractWeights,C=Q.getRemainingWeights,E=DP(w,B),e=E.extractConvParams,I=E.extractSeparableConvParams,t=E.extractReductionBlockParams,n=E.extractMainBlockParams,i=e(3,32,3,"entry_flow/conv_in"),c=t(32,64,"entry_flow/reduction_block_0"),Y=t(64,128,"entry_flow/reduction_block_1"),M={conv_in:i,reduction_block_0:c,reduction_block_1:Y},D={};qC(g,0,1).forEach(function(u){D["main_block_"+u]=n(128,"middle_flow/main_block_"+u)});var r=t(128,256,"exit_flow/reduction_block"),a=I(256,512,"exit_flow/separable_conv"),s={reduction_block:r,separable_conv:a};if(C().length!==0)throw new Error("weights remaing after extract: "+C().length);return{paramMappings:B,params:{entry_flow:M,middle_flow:D,exit_flow:s}}}function aP(A,g){var B=yQ(A,g),Q=dD(B),w=rn(B);function C(e){var I=w(e+"/separable_conv0"),t=w(e+"/separable_conv1"),n=Q(e+"/expansion_conv");return{separable_conv0:I,separable_conv1:t,expansion_conv:n}}function E(e){var I=w(e+"/separable_conv0"),t=w(e+"/separable_conv1"),n=w(e+"/separable_conv2");return{separable_conv0:I,separable_conv1:t,separable_conv2:n}}return{extractConvParams:Q,extractSeparableConvParams:w,extractReductionBlockParams:C,extractMainBlockParams:E}}function sP(A,g){var B=[],Q=aP(A,B),w=Q.extractConvParams,C=Q.extractSeparableConvParams,E=Q.extractReductionBlockParams,e=Q.extractMainBlockParams,I=w("entry_flow/conv_in"),t=E("entry_flow/reduction_block_0"),n=E("entry_flow/reduction_block_1"),i={conv_in:I,reduction_block_0:t,reduction_block_1:n},c={};qC(g,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 lQ(A,B),{params:{entry_flow:i,middle_flow:c,exit_flow:D},paramMappings:B}}function PD(A,g,B){return BB(jg(A,g.filters,B,"same"),g.bias)}function Fn(A,g,B){B===void 0&&(B=!0);var Q=B?JB(A):A;return Q=Ng(Q,g.separable_conv0,[1,1]),Q=Ng(JB(Q),g.separable_conv1,[1,1]),Q=OB(Q,[3,3],[2,2],"same"),Q=BB(Q,PD(A,g.expansion_conv,[2,2])),Q}function uP(A,g){var B=Ng(JB(A),g.separable_conv0,[1,1]);return B=Ng(JB(B),g.separable_conv1,[1,1]),B=Ng(JB(B),g.separable_conv2,[1,1]),B=BB(B,A),B}var UP=function(A){LA(g,A);function g(B){var Q=A.call(this,"TinyXception")||this;return Q._numMainBlocks=B,Q}return g.prototype.forwardInput=function(B){var Q=this,w=this.params;if(!w)throw new Error("TinyXception - load model before inference");return FA(function(){var C=B.toBatchTensor(112,!0),E=[122.782,117.001,104.298],e=$C(C,E).div(cA(256)),I=JB(PD(e,w.entry_flow.conv_in,[2,2]));return I=Fn(I,w.entry_flow.reduction_block_0,!1),I=Fn(I,w.entry_flow.reduction_block_1),qC(Q._numMainBlocks,0,1).forEach(function(t){I=uP(I,w.middle_flow["main_block_"+t])}),I=Fn(I,w.exit_flow.reduction_block),I=JB(Ng(I,w.exit_flow.separable_conv,[1,1])),I})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.getDefaultModelName=function(){return"tiny_xception_model"},g.prototype.extractParamsFromWeigthMap=function(B){return sP(B,this._numMainBlocks)},g.prototype.extractParams=function(B){return FP(B,this._numMainBlocks)},g}(UQ);function lP(A){var g=[],B=hQ(A),Q=B.extractWeights,w=B.getRemainingWeights,C=Yn(Q,g),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:g,params:{fc:{age:E,gender:e}}}}function hP(A){var g=[],B=yQ(A,g);function Q(C){var E=B(C+"/weights",2),e=B(C+"/bias",1);return{weights:E,bias:e}}var w={fc:{age:Q("fc/age"),gender:Q("fc/gender")}};return lQ(A,g),{params:w,paramMappings:g}}var Ve;(function(A){A.FEMALE="female",A.MALE="male"})(Ve||(Ve={}));var GP=function(A){LA(g,A);function g(B){B===void 0&&(B=new UP(2));var Q=A.call(this,"AgeGenderNet")||this;return Q._faceFeatureExtractor=B,Q}return Object.defineProperty(g.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),g.prototype.runNet=function(B){var Q=this,w=this.params;if(!w)throw new Error(this._name+" - load model before inference");return FA(function(){var C=B instanceof ze?Q.faceFeatureExtractor.forwardInput(B):B,E=XC(C,[7,7],[2,2],"valid").as2D(C.shape[0],-1),e=EQ(E,w.fc.age).as1D(),I=EQ(E,w.fc.gender);return{age:e,gender:I}})},g.prototype.forwardInput=function(B){var Q=this;return FA(function(){var w=Q.runNet(B),C=w.age,E=w.gender;return{age:C,gender:FQ(E)}})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.predictAgeAndGender=function(B){return JA(this,void 0,void 0,function(){var Q,w,C,E,e,I,t=this;return mA(this,function(n){switch(n.label){case 0:return[4,ZB(B)];case 1:return Q=n.sent(),[4,this.forwardInput(Q)];case 2:return w=n.sent(),C=WB(w.age),E=WB(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(t,void 0,void 0,function(){var M,D,r,a,s;return mA(this,function(u){switch(u.label){case 0:return[4,c.data()];case 1:return M=u.sent()[0],[4,Y.data()];case 2:return D=u.sent()[0],r=D>.5,a=r?Ve.MALE:Ve.FEMALE,s=r?D:1-D,c.dispose(),Y.dispose(),[2,{age:M,gender:a,genderProbability:s}]}})})}))];case 3:return I=n.sent(),w.age.dispose(),w.gender.dispose(),[2,Q.isBatchInput?I:I[0]]}})})},g.prototype.getDefaultModelName=function(){return"age_gender_model"},g.prototype.dispose=function(B){B===void 0&&(B=!0),this.faceFeatureExtractor.dispose(B),A.prototype.dispose.call(this,B)},g.prototype.loadClassifierParams=function(B){var Q=this.extractClassifierParams(B),w=Q.params,C=Q.paramMappings;this._params=w,this._paramMappings=C},g.prototype.extractClassifierParams=function(B){return lP(B)},g.prototype.extractParamsFromWeigthMap=function(B){var Q=JD(B),w=Q.featureExtractorMap,C=Q.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(w),hP(C)},g.prototype.extractParams=function(B){var Q=1539,w=B.slice(0,B.length-Q),C=B.slice(B.length-Q);return this.faceFeatureExtractor.extractWeights(w),this.extractClassifierParams(C)},g}(UQ),vD=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.postProcess=function(B,Q,w){var C=w.map(function(e){var I=e.width,t=e.height,n=Q/Math.max(t,I);return{width:I*n,height:t*n}}),E=C.length;return FA(function(){var e=function(c,Y){return fg([gQ([68],c),gQ([68],Y)],1).as2D(1,136).as1D()},I=function(c,Y){var M=C[c],D=M.width,r=M.height;return Y(D,r)?Math.abs(D-r)/2:0},t=function(c){return I(c,function(Y,M){return Y<M})},n=function(c){return I(c,function(Y,M){return M<Y})},i=B.mul(gQ([E,136],Q)).sub(fg(Array.from(Array(E),function(c,Y){return e(t(Y),n(Y))}))).div(fg(Array.from(Array(E),function(c,Y){return e(C[Y].width,C[Y].height)})));return i})},g.prototype.forwardInput=function(B){var Q=this;return FA(function(){var w=Q.runNet(B);return Q.postProcess(w,B.inputSize,B.inputDimensions.map(function(C){var E=C[0],e=C[1];return{height:E,width:e}}))})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.detectLandmarks=function(B){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,ZB(B)];case 1:return Q=e.sent(),w=FA(function(){return WB(E.forwardInput(Q))}),[4,Promise.all(w.map(function(I,t){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,I.data()];case 1:return n=c.apply(i,[D.sent()]),Y=n.filter(function(r,a){return eD(a)}),M=n.filter(function(r,a){return!eD(a)}),[2,new iD(Array(68).fill(0).map(function(r,a){return new cB(Y[a],M[a])}),{height:Q.getInputHeight(t),width:Q.getInputWidth(t)})]}})})}))];case 2:return C=e.sent(),w.forEach(function(I){return I.dispose()}),[2,Q.isBatchInput?C:C[0]]}})})},g.prototype.getClassifierChannelsOut=function(){return 136},g}(mD),kD=function(A){LA(g,A);function g(B){return B===void 0&&(B=new fD),A.call(this,"FaceLandmark68Net",B)||this}return g.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},g.prototype.getClassifierChannelsIn=function(){return 256},g}(vD);function dP(A){var g=[],B=HD(A,g).extractDenseBlock3Params,Q={dense0:B("dense0",!0),dense1:B("dense1"),dense2:B("dense2")};return lQ(A,g),{params:Q,paramMappings:g}}function HP(A){var g=[],B=hQ(A),Q=B.extractWeights,w=B.getRemainingWeights,C=GD(Q,g).extractDenseBlock3Params,E=C(3,32,"dense0",!0),e=C(32,64,"dense1"),I=C(64,128,"dense2");if(w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{paramMappings:g,params:{dense0:E,dense1:e,dense2:I}}}var fP=function(A){LA(g,A);function g(){return A.call(this,"TinyFaceFeatureExtractor")||this}return g.prototype.forwardInput=function(B){var Q=this.params;if(!Q)throw new Error("TinyFaceFeatureExtractor - load model before inference");return FA(function(){var w=B.toBatchTensor(112,!0),C=[122.782,117.001,104.298],E=$C(w,C).div(cA(255)),e=cn(E,Q.dense0,!0);return e=cn(e,Q.dense1),e=cn(e,Q.dense2),e=XC(e,[14,14],[2,2],"valid"),e})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},g.prototype.extractParamsFromWeigthMap=function(B){return dP(B)},g.prototype.extractParams=function(B){return HP(B)},g}(UQ),JP=function(A){LA(g,A);function g(B){return B===void 0&&(B=new fP),A.call(this,"FaceLandmark68TinyNet",B)||this}return g.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},g.prototype.getClassifierChannelsIn=function(){return 128},g}(vD);(function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g})(kD);function mP(A,g){return BB(Ig(A,g.weights),g.biases)}function an(A,g,B,Q,w){w===void 0&&(w="same");var C=g.conv,E=C.filters,e=C.bias,I=jg(A,E,B,w);return I=BB(I,e),I=mP(I,g.scale),Q?JB(I):I}function NP(A,g){return an(A,g,[1,1],!0)}function TD(A,g){return an(A,g,[1,1],!1)}function jD(A,g){return an(A,g,[2,2],!0,"valid")}function RP(A,g){function B(e,I,t){var n=A(e),i=n.length/(I*t*t);if(zR(i))throw new Error("depth has to be an integer: "+i+", weights.length: "+n.length+", numFilters: "+I+", filterSize: "+t);return FA(function(){return vQ(ag(n,[I,i,t,t]),[2,3,1,0])})}function Q(e,I,t,n){var i=B(e,I,t),c=pB(A(I));return g.push({paramPath:n+"/filters"},{paramPath:n+"/bias"}),{filters:i,bias:c}}function w(e,I){var t=pB(A(e)),n=pB(A(e));return g.push({paramPath:I+"/weights"},{paramPath:I+"/biases"}),{weights:t,biases:n}}function C(e,I,t,n){var i=Q(e,I,t,n+"/conv"),c=w(I,n+"/scale");return{conv:i,scale:c}}function E(e,I,t,n,i){i===void 0&&(i=!1);var c=C((i?.5:1)*e,I,t,n+"/conv1"),Y=C(e,I,t,n+"/conv2");return{conv1:c,conv2:Y}}return{extractConvLayerParams:C,extractResidualLayerParams:E}}function PP(A){var g=hQ(A),B=g.extractWeights,Q=g.getRemainingWeights,w=[],C=RP(B,w),E=C.extractConvLayerParams,e=C.extractResidualLayerParams,I=E(4704,32,7,"conv32_down"),t=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),a=e(147456,128,3,"conv128_1"),s=e(147456,128,3,"conv128_2"),u=e(589824,256,3,"conv256_down",!0),F=e(589824,256,3,"conv256_1"),U=e(589824,256,3,"conv256_2"),l=e(589824,256,3,"conv256_down_out"),d=FA(function(){return vQ(RQ(B(256*128),[128,256]),[1,0])});if(w.push({paramPath:"fc"}),Q().length!==0)throw new Error("weights remaing after extract: "+Q().length);var H={conv32_down:I,conv32_1:t,conv32_2:n,conv32_3:i,conv64_down:c,conv64_1:Y,conv64_2:M,conv64_3:D,conv128_down:r,conv128_1:a,conv128_2:s,conv256_down:u,conv256_1:F,conv256_2:U,conv256_down_out:l,fc:d};return{params:H,paramMappings:w}}function vP(A,g){var B=yQ(A,g);function Q(E){var e=B(E+"/scale/weights",1),I=B(E+"/scale/biases",1);return{weights:e,biases:I}}function w(E){var e=B(E+"/conv/filters",4),I=B(E+"/conv/bias",1),t=Q(E);return{conv:{filters:e,bias:I},scale:t}}function C(E){return{conv1:w(E+"/conv1"),conv2:w(E+"/conv2")}}return{extractConvLayerParams:w,extractResidualLayerParams:C}}function kP(A){var g=[],B=vP(A,g),Q=B.extractConvLayerParams,w=B.extractResidualLayerParams,C=Q("conv32_down"),E=w("conv32_1"),e=w("conv32_2"),I=w("conv32_3"),t=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"),a=w("conv256_1"),s=w("conv256_2"),u=w("conv256_down_out"),F=A.fc;if(g.push({originalPath:"fc",paramPath:"fc"}),!yR(F))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+F);var U={conv32_down:C,conv32_1:E,conv32_2:e,conv32_3:I,conv64_down:t,conv64_1:n,conv64_2:i,conv64_3:c,conv128_down:Y,conv128_1:M,conv128_2:D,conv256_down:r,conv256_1:a,conv256_2:s,conv256_down_out:u,fc:F};return lQ(A,g),{params:U,paramMappings:g}}function eQ(A,g){var B=NP(A,g.conv1);return B=TD(B,g.conv2),B=BB(B,A),B=JB(B),B}function Ke(A,g){var B=jD(A,g.conv1);B=TD(B,g.conv2);var Q=XC(A,2,2,"valid"),w=GB(Q.shape),C=Q.shape[3]!==B.shape[3],E=Q.shape[1]!==B.shape[1]||Q.shape[2]!==B.shape[2];if(E){var e=ZC(B.shape);e[1]=1;var I=GB(e);B=zB([B,I],1);var t=ZC(B.shape);t[2]=1;var n=GB(t);B=zB([B,n],2)}return Q=C?zB([Q,w],3):Q,B=BB(Q,B),B=JB(B),B}var TP=function(A){LA(g,A);function g(){return A.call(this,"FaceRecognitionNet")||this}return g.prototype.forwardInput=function(B){var Q=this.params;if(!Q)throw new Error("FaceRecognitionNet - load model before inference");return FA(function(){var w=B.toBatchTensor(150,!0).toFloat(),C=[122.782,117.001,104.298],E=$C(w,C).div(cA(256)),e=jD(E,Q.conv32_down);e=OB(e,3,2,"valid"),e=eQ(e,Q.conv32_1),e=eQ(e,Q.conv32_2),e=eQ(e,Q.conv32_3),e=Ke(e,Q.conv64_down),e=eQ(e,Q.conv64_1),e=eQ(e,Q.conv64_2),e=eQ(e,Q.conv64_3),e=Ke(e,Q.conv128_down),e=eQ(e,Q.conv128_1),e=eQ(e,Q.conv128_2),e=Ke(e,Q.conv256_down),e=eQ(e,Q.conv256_1),e=eQ(e,Q.conv256_2),e=Ke(e,Q.conv256_down_out);var I=e.mean([1,2]),t=de(I,Q.fc);return t})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.computeFaceDescriptor=function(B){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,ZB(B)];case 1:return Q=e.sent(),w=FA(function(){return WB(E.forwardInput(Q))}),[4,Promise.all(w.map(function(I){return I.data()}))];case 2:return C=e.sent(),w.forEach(function(I){return I.dispose()}),[2,Q.isBatchInput?C:C[0]]}})})},g.prototype.getDefaultModelName=function(){return"face_recognition_model"},g.prototype.extractParamsFromWeigthMap=function(B){return kP(B)},g.prototype.extractParams=function(B){return PP(B)},g}(UQ);function pD(A,g){var B={descriptor:g};return Object.assign({},A,B)}function yD(A,g){var B={age:g};return Object.assign({},A,B)}function zD(A,g,B){var Q={gender:g,genderProbability:B};return Object.assign({},A,Q)}var WD=function(){function A(g){var B=g===void 0?{}:g,Q=B.minFaceSize,w=B.scaleFactor,C=B.maxNumScales,E=B.scoreThresholds,e=B.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(I){return typeof I!="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(I){return typeof I!="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 jP(A,g){function B(I,t){var n=ag(A(9*I),[3,3,I,1]),i=pB(A(I)),c=pB(A(I)),Y=pB(A(I)),M=pB(A(I));return g.push({paramPath:t+"/filters"},{paramPath:t+"/batch_norm_scale"},{paramPath:t+"/batch_norm_offset"},{paramPath:t+"/batch_norm_mean"},{paramPath:t+"/batch_norm_variance"}),{filters:n,batch_norm_scale:i,batch_norm_offset:c,batch_norm_mean:Y,batch_norm_variance:M}}function Q(I,t,n,i,c){var Y=ag(A(I*t*n*n),[n,n,I,t]),M=pB(A(t));return g.push({paramPath:i+"/filters"},{paramPath:i+"/"+(c?"batch_norm_offset":"bias")}),{filters:Y,bias:M}}function w(I,t,n,i){var c=Q(I,t,n,i,!0),Y=c.filters,M=c.bias;return{filters:Y,batch_norm_offset:M}}function C(I,t,n){var i=B(I,n+"/depthwise_conv"),c=w(I,t,1,n+"/pointwise_conv");return{depthwise_conv:i,pointwise_conv:c}}function E(){var I=w(3,32,3,"mobilenetv1/conv_0"),t=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"),a=C(512,512,"mobilenetv1/conv_9"),s=C(512,512,"mobilenetv1/conv_10"),u=C(512,512,"mobilenetv1/conv_11"),F=C(512,1024,"mobilenetv1/conv_12"),U=C(1024,1024,"mobilenetv1/conv_13");return{conv_0:I,conv_1:t,conv_2:n,conv_3:i,conv_4:c,conv_5:Y,conv_6:M,conv_7:D,conv_8:r,conv_9:a,conv_10:s,conv_11:u,conv_12:F,conv_13:U}}function e(){var I=w(1024,256,1,"prediction_layer/conv_0"),t=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"),a=Q(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),s=Q(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),u=Q(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),F=Q(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),U=Q(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),l=Q(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),d=Q(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),H=Q(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),h=Q(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),G=Q(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),N=Q(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),f={box_encoding_predictor:r,class_predictor:a},W={box_encoding_predictor:s,class_predictor:u},m={box_encoding_predictor:F,class_predictor:U},v={box_encoding_predictor:l,class_predictor:d},y={box_encoding_predictor:H,class_predictor:h},j={box_encoding_predictor:G,class_predictor:N};return{conv_0:I,conv_1:t,conv_2:n,conv_3:i,conv_4:c,conv_5:Y,conv_6:M,conv_7:D,box_predictor_0:f,box_predictor_1:W,box_predictor_2:m,box_predictor_3:v,box_predictor_4:y,box_predictor_5:j}}return{extractMobilenetV1Params:E,extractPredictionLayerParams:e}}function pP(A){var g=[],B=hQ(A),Q=B.extractWeights,w=B.getRemainingWeights,C=jP(Q,g),E=C.extractMobilenetV1Params,e=C.extractPredictionLayerParams,I=E(),t=e(),n=Et(Q(5118*4),[1,5118,4]),i={extra_dim:n};if(g.push({paramPath:"output_layer/extra_dim"}),w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{params:{mobilenetv1:I,prediction_layer:t,output_layer:i},paramMappings:g}}function yP(A,g){var B=yQ(A,g);function Q(t,n,i){var c=B(t+"/Conv2d_"+n+"_pointwise/weights",4,i+"/filters"),Y=B(t+"/Conv2d_"+n+"_pointwise/convolution_bn_offset",1,i+"/batch_norm_offset");return{filters:c,batch_norm_offset:Y}}function w(t){var n="mobilenetv1/conv_"+t,i="MobilenetV1/Conv2d_"+t+"_depthwise",c=n+"/depthwise_conv",Y=n+"/pointwise_conv",M=B(i+"/depthwise_weights",4,c+"/filters"),D=B(i+"/BatchNorm/gamma",1,c+"/batch_norm_scale"),r=B(i+"/BatchNorm/beta",1,c+"/batch_norm_offset"),a=B(i+"/BatchNorm/moving_mean",1,c+"/batch_norm_mean"),s=B(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:a,batch_norm_variance:s},pointwise_conv:Q("MobilenetV1",t,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(t,n){var i=B(t+"/weights",4,n+"/filters"),c=B(t+"/biases",1,n+"/bias");return{filters:i,bias:c}}function e(t){var n=E("Prediction/BoxPredictor_"+t+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+t+"/box_encoding_predictor"),i=E("Prediction/BoxPredictor_"+t+"/ClassPredictor","prediction_layer/box_predictor_"+t+"/class_predictor");return{box_encoding_predictor:n,class_predictor:i}}function I(){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:I}}function zP(A){var g=[],B=yP(A,g),Q=B.extractMobilenetV1Params,w=B.extractPredictionLayerParams,C=A["Output/extra_dim"];if(g.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!Pe(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 lQ(A,g),{params:E,paramMappings:g}}function IQ(A,g,B){return FA(function(){var Q=jg(A,g.filters,B,"same");return Q=BB(Q,g.batch_norm_offset),ft(Q,0,6)})}var WP=.0010000000474974513;function bP(A,g,B){return FA(function(){var Q=Ge(A,g.filters,B,"same");return Q=ir(Q,g.batch_norm_mean,g.batch_norm_variance,g.batch_norm_offset,g.batch_norm_scale,WP),ft(Q,0,6)})}function SP(A){return[2,4,6,12].some(function(g){return g===A})?[2,2]:[1,1]}function LP(A,g){return FA(function(){var B=null,Q=IQ(A,g.conv_0,[2,2]),w=[g.conv_1,g.conv_2,g.conv_3,g.conv_4,g.conv_5,g.conv_6,g.conv_7,g.conv_8,g.conv_9,g.conv_10,g.conv_11,g.conv_12,g.conv_13];if(w.forEach(function(C,E){var e=E+1,I=SP(e);Q=bP(Q,C.depthwise_conv,I),Q=IQ(Q,C.pointwise_conv,[1,1]),e===11&&(B=Q)}),B===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:Q,conv11:B}})}function VP(A,g,B,Q,w){var C=A.shape[0],E=Math.min(B,C),e=g.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}),I=function(n){return n<=Q?1:0},t=[];return e.forEach(function(n){if(!(t.length>=E)){for(var i=n.score,c=t.length-1;c>=0;--c){var Y=KP(A,n.boxIndex,t[c]);if(Y!==0&&(n.score*=I(Y),n.score<=w))break}i===n.score&&t.push(n.boxIndex)}}),t}function KP(A,g,B){var Q=A.arraySync(),w=Math.min(Q[g][0],Q[g][2]),C=Math.min(Q[g][1],Q[g][3]),E=Math.max(Q[g][0],Q[g][2]),e=Math.max(Q[g][1],Q[g][3]),I=Math.min(Q[B][0],Q[B][2]),t=Math.min(Q[B][1],Q[B][3]),n=Math.max(Q[B][0],Q[B][2]),i=Math.max(Q[B][1],Q[B][3]),c=(E-w)*(e-C),Y=(n-I)*(i-t);if(c<=0||Y<=0)return 0;var M=Math.max(w,I),D=Math.max(C,t),r=Math.min(E,n),a=Math.min(e,i),s=Math.max(r-M,0)*Math.max(a-D,0);return s/(c+Y-s)}function xP(A){var g=WB(vQ(A,[1,0])),B=[SB(g[2],g[0]),SB(g[3],g[1])],Q=[BB(g[0],Lg(B[0],cA(2))),BB(g[1],Lg(B[1],cA(2)))];return{sizes:B,centers:Q}}function XP(A,g){var B=xP(A),Q=B.sizes,w=B.centers,C=WB(vQ(g,[1,0])),E=Lg(Ig(Jt(Lg(C[2],cA(5))),Q[0]),cA(2)),e=BB(Ig(Lg(C[0],cA(10)),Q[0]),w[0]),I=Lg(Ig(Jt(Lg(C[3],cA(5))),Q[1]),cA(2)),t=BB(Ig(Lg(C[1],cA(10)),Q[1]),w[1]);return vQ(fg([SB(e,E),SB(t,I),BB(e,E),BB(t,I)]),[1,0])}function OP(A,g,B){return FA(function(){var Q=A.shape[0],w=XP(bg(Vw(B.extra_dim,[Q,1,1]),[-1,4]),bg(A,[-1,4]));w=bg(w,[Q,w.shape[0]/Q,4]);var C=Ir(QQ(g,[0,0,1],[-1,-1,-1])),E=QQ(C,[0,0,0],[-1,-1,1]);E=bg(E,[Q,E.shape[1]]);var e=WB(w),I=WB(E);return{boxes:e,scores:I}})}function CC(A,g){return FA(function(){var B=A.shape[0],Q=bg(Vg(A,g.box_encoding_predictor),[B,-1,1,4]),w=bg(Vg(A,g.class_predictor),[B,-1,3]);return{boxPredictionEncoding:Q,classPrediction:w}})}function ZP(A,g,B){return FA(function(){var Q=IQ(A,B.conv_0,[1,1]),w=IQ(Q,B.conv_1,[2,2]),C=IQ(w,B.conv_2,[1,1]),E=IQ(C,B.conv_3,[2,2]),e=IQ(E,B.conv_4,[1,1]),I=IQ(e,B.conv_5,[2,2]),t=IQ(I,B.conv_6,[1,1]),n=IQ(t,B.conv_7,[2,2]),i=CC(g,B.box_predictor_0),c=CC(A,B.box_predictor_1),Y=CC(w,B.box_predictor_2),M=CC(E,B.box_predictor_3),D=CC(I,B.box_predictor_4),r=CC(n,B.box_predictor_5),a=zB([i.boxPredictionEncoding,c.boxPredictionEncoding,Y.boxPredictionEncoding,M.boxPredictionEncoding,D.boxPredictionEncoding,r.boxPredictionEncoding],1),s=zB([i.classPrediction,c.classPrediction,Y.classPrediction,M.classPrediction,D.classPrediction,r.classPrediction],1);return{boxPredictions:a,classPredictions:s}})}var xe=function(){function A(g){var B=g===void 0?{}:g,Q=B.minConfidence,w=B.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}(),bD=function(A){LA(g,A);function g(){return A.call(this,"SsdMobilenetv1")||this}return g.prototype.forwardInput=function(B){var Q=this.params;if(!Q)throw new Error("SsdMobilenetv1 - load model before inference");return FA(function(){var w=B.toBatchTensor(512,!1).toFloat(),C=SB(Ig(w,cA(.007843137718737125)),cA(1)),E=LP(C,Q.mobilenetv1),e=ZP(E.out,E.conv11,Q.prediction_layer),I=e.boxPredictions,t=e.classPredictions;return OP(I,t,Q.output_layer)})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.locateFaces=function(B,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,I,t,n,i,c,Y,M,D,r,a,s,u,F,U,l,d,H;return mA(this,function(h){switch(h.label){case 0:return w=new xe(Q),C=w.maxResults,E=w.minConfidence,[4,ZB(B)];case 1:for(e=h.sent(),I=this.forwardInput(e),t=I.boxes,n=I.scores,i=t[0],c=n[0],Y=1;Y<t.length;Y++)t[Y].dispose(),n[Y].dispose();return r=(D=Array).from,[4,c.data()];case 2:return M=r.apply(D,[h.sent()]),a=.5,s=VP(i,M,C,a,E),u=e.getReshapedInputDimensions(0),F=e.inputSize,U=F/u.width,l=F/u.height,d=i.arraySync(),H=s.map(function(G){var N=[Math.max(0,d[G][0]),Math.min(1,d[G][2])].map(function(j){return j*l}),f=N[0],W=N[1],m=[Math.max(0,d[G][1]),Math.min(1,d[G][3])].map(function(j){return j*U}),v=m[0],y=m[1];return new mg(M[G],new ke(v,f,y-v,W-f),{height:e.getInputHeight(0),width:e.getInputWidth(0)})}),i.dispose(),c.dispose(),[2,H]}})})},g.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},g.prototype.extractParamsFromWeigthMap=function(B){return zP(B)},g.prototype.extractParams=function(B){return pP(B)},g}(UQ);(function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g})(bD);var qP=.4,_P=[new cB(.738768,.874946),new cB(2.42204,2.65704),new cB(4.30971,7.04493),new cB(10.246,4.59428),new cB(12.6868,11.8741)],$P=[new cB(1.603231,2.094468),new cB(6.041143,7.080126),new cB(2.882459,3.518061),new cB(4.266906,5.178857),new cB(9.041765,10.66308)],Av=[117.001,114.697,97.404],Bv="tiny_yolov2_model",gv="tiny_yolov2_separable_conv_model",Xe=function(A){return typeof A=="number"};function Qv(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(!Xe(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(g){return typeof g=="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(g){return g||{}}).every(function(g){return Xe(g.x)&&Xe(g.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(Xe)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(A.meanRgb))}function sn(A){return FA(function(){var g=Ig(A,cA(.10000000149011612));return BB(JB(SB(A,g)),g)})}function zQ(A,g){return FA(function(){var B=ww(A,[[0,0],[1,1],[1,1],[0,0]]);return B=jg(B,g.conv.filters,[1,1],"valid"),B=SB(B,g.bn.sub),B=Ig(B,g.bn.truediv),B=BB(B,g.conv.bias),sn(B)})}function WQ(A,g){return FA(function(){var B=ww(A,[[0,0],[1,1],[1,1],[0,0]]);return B=vt(B,g.depthwise_filter,g.pointwise_filter,[1,1],"valid"),B=BB(B,g.bias),sn(B)})}function wv(A,g){var B=Se(A,g);function Q(E,e){var I=pB(A(E)),t=pB(A(E));return g.push({paramPath:e+"/sub"},{paramPath:e+"/truediv"}),{sub:I,truediv:t}}function w(E,e,I){var t=B(E,e,3,I+"/conv"),n=Q(e,I+"/bn");return{conv:t,bn:n}}var C=Mn(A,g);return{extractConvParams:B,extractConvWithBatchNormParams:w,extractSeparableConvParams:C}}function Cv(A,g,B,Q){var w=hQ(A),C=w.extractWeights,E=w.getRemainingWeights,e=[],I=wv(C,e),t=I.extractConvParams,n=I.extractConvWithBatchNormParams,i=I.extractSeparableConvParams,c;if(g.withSeparableConvs){var Y=Q[0],M=Q[1],D=Q[2],r=Q[3],a=Q[4],s=Q[5],u=Q[6],F=Q[7],U=Q[8],l=g.isFirstLayerConv2d?t(Y,M,3,"conv0"):i(Y,M,"conv0"),d=i(M,D,"conv1"),H=i(D,r,"conv2"),h=i(r,a,"conv3"),G=i(a,s,"conv4"),N=i(s,u,"conv5"),f=F?i(u,F,"conv6"):void 0,W=U?i(F,U,"conv7"):void 0,m=t(U||F||u,5*B,1,"conv8");c={conv0:l,conv1:d,conv2:H,conv3:h,conv4:G,conv5:N,conv6:f,conv7:W,conv8:m}}else{var Y=Q[0],M=Q[1],D=Q[2],r=Q[3],a=Q[4],s=Q[5],u=Q[6],F=Q[7],U=Q[8],l=n(Y,M,"conv0"),d=n(M,D,"conv1"),H=n(D,r,"conv2"),h=n(r,a,"conv3"),G=n(a,s,"conv4"),N=n(s,u,"conv5"),f=n(u,F,"conv6"),W=n(F,U,"conv7"),m=t(U,5*B,1,"conv8");c={conv0:l,conv1:d,conv2:H,conv3:h,conv4:G,conv5:N,conv6:f,conv7:W,conv8:m}}if(E().length!==0)throw new Error("weights remaing after extract: "+E().length);return{params:c,paramMappings:e}}function Ev(A,g){var B=yQ(A,g);function Q(e){var I=B(e+"/sub",1),t=B(e+"/truediv",1);return{sub:I,truediv:t}}function w(e){var I=B(e+"/filters",4),t=B(e+"/bias",1);return{filters:I,bias:t}}function C(e){var I=w(e+"/conv"),t=Q(e+"/bn");return{conv:I,bn:t}}var E=rn(B);return{extractConvParams:w,extractConvWithBatchNormParams:C,extractSeparableConvParams:E}}function ev(A,g){var B=[],Q=Ev(A,B),w=Q.extractConvParams,C=Q.extractConvWithBatchNormParams,E=Q.extractSeparableConvParams,e;if(g.withSeparableConvs){var I=g.filterSizes&&g.filterSizes.length||9;e={conv0:g.isFirstLayerConv2d?w("conv0"):E("conv0"),conv1:E("conv1"),conv2:E("conv2"),conv3:E("conv3"),conv4:E("conv4"),conv5:E("conv5"),conv6:I>7?E("conv6"):void 0,conv7:I>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 lQ(A,B),{params:e,paramMappings:B}}var SD;(function(A){A[A.XS=224]="XS",A[A.SM=320]="SM",A[A.MD=416]="MD",A[A.LG=608]="LG"})(SD||(SD={}));var un=function(){function A(g){var B=g===void 0?{}:g,Q=B.inputSize,w=B.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}(),LD=function(A){LA(g,A);function g(B){var Q=A.call(this,"TinyYolov2")||this;return Qv(B),Q._config=B,Q}return Object.defineProperty(g.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),g.prototype.runTinyYolov2=function(B,Q){var w=zQ(B,Q.conv0);return w=OB(w,[2,2],[2,2],"same"),w=zQ(w,Q.conv1),w=OB(w,[2,2],[2,2],"same"),w=zQ(w,Q.conv2),w=OB(w,[2,2],[2,2],"same"),w=zQ(w,Q.conv3),w=OB(w,[2,2],[2,2],"same"),w=zQ(w,Q.conv4),w=OB(w,[2,2],[2,2],"same"),w=zQ(w,Q.conv5),w=OB(w,[2,2],[1,1],"same"),w=zQ(w,Q.conv6),w=zQ(w,Q.conv7),Vg(w,Q.conv8,"valid",!1)},g.prototype.runMobilenet=function(B,Q){var w=this.config.isFirstLayerConv2d?sn(Vg(B,Q.conv0,"valid",!1)):WQ(B,Q.conv0);return w=OB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv1),w=OB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv2),w=OB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv3),w=OB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv4),w=OB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv5),w=OB(w,[2,2],[1,1],"same"),w=Q.conv6?WQ(w,Q.conv6):w,w=Q.conv7?WQ(w,Q.conv7):w,Vg(w,Q.conv8,"valid",!1)},g.prototype.forwardInput=function(B,Q){var w=this,C=this.params;if(!C)throw new Error("TinyYolov2 - load model before inference");return FA(function(){var E=B.toBatchTensor(Q,!1).toFloat();return E=w.config.meanRgb?$C(E,w.config.meanRgb):E,E=E.div(cA(256)),w.config.withSeparableConvs?w.runMobilenet(E,C):w.runTinyYolov2(E,C)})},g.prototype.forward=function(B,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,ZB(B)];case 1:return[4,w.apply(this,[C.sent(),Q])];case 2:return[2,C.sent()]}})})},g.prototype.detect=function(B,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,I,t,n,i,c,Y,M,D,r,a,s=this;return mA(this,function(u){switch(u.label){case 0:return w=new un(Q),C=w.inputSize,E=w.scoreThreshold,[4,ZB(B)];case 1:return e=u.sent(),[4,this.forwardInput(e,C)];case 2:return I=u.sent(),t=FA(function(){return WB(I)[0].expandDims()}),n={width:e.getInputWidth(0),height:e.getInputHeight(0)},[4,this.extractBoxes(t,e.getReshapedInputDimensions(0),E)];case 3:return i=u.sent(),I.dispose(),t.dispose(),c=i.map(function(F){return F.box}),Y=i.map(function(F){return F.score}),M=i.map(function(F){return F.classScore}),D=i.map(function(F){return s.config.classes[F.label]}),r=_C(c.map(function(F){return F.rescale(C)}),Y,this.config.iouThreshold,!0),a=r.map(function(F){return new nD(Y[F],M[F],D[F],c[F],n)}),[2,a]}})})},g.prototype.getDefaultModelName=function(){return""},g.prototype.extractParamsFromWeigthMap=function(B){return ev(B,this.config)},g.prototype.extractParams=function(B){var Q=this.config.filterSizes||g.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 Cv(B,this.config,this.boxEncodingSize,Q)},g.prototype.extractBoxes=function(B,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,I,t,n,i,c,Y,M,D,r,a,s,u,F,U,l,d,H,h,G,N,f,W,m,v,y,j,p=this;return mA(this,function(V){switch(V.label){case 0:return C=Q.width,E=Q.height,e=Math.max(C,E),I=e/C,t=e/E,n=B.shape[1],i=this.config.anchors.length,c=FA(function(){var K=B.reshape([n,n,i,p.boxEncodingSize]),k=K.slice([0,0,0,0],[n,n,i,4]),T=K.slice([0,0,0,4],[n,n,i,1]),X=p.withClassScores?FQ(K.slice([0,0,0,5],[n,n,i,p.config.classes.length]),3):cA(0);return[k,T,X]}),Y=c[0],M=c[1],D=c[2],r=[],[4,M.array()];case 1:return a=V.sent(),[4,Y.array()];case 2:s=V.sent(),u=0,V.label=3;case 3:if(!(u<n))return[3,12];F=0,V.label=4;case 4:if(!(F<n))return[3,11];U=0,V.label=5;case 5:return U<i?(l=En(a[u][F][U][0]),!w||l>w?(d=(F+En(s[u][F][U][0]))/n*I,H=(u+En(s[u][F][U][1]))/n*t,h=Math.exp(s[u][F][U][2])*this.config.anchors[U].x/n*I,G=Math.exp(s[u][F][U][3])*this.config.anchors[U].y/n*t,N=d-h/2,f=H-G/2,W={row:u,col:F,anchor:U},this.withClassScores?[4,this.extractPredictedClass(D,W)]:[3,7]):[3,9]):[3,10];case 6:return j=V.sent(),[3,8];case 7:j={classScore:1,label:0},V.label=8;case 8:m=j,v=m.classScore,y=m.label,r.push(tg({box:new ve(N,f,N+h,f+G),score:l,classScore:l*v,label:y},W)),V.label=9;case 9:return U++,[3,5];case 10:return F++,[3,4];case 11:return u++,[3,3];case 12:return Y.dispose(),M.dispose(),D.dispose(),[2,r]}})})},g.prototype.extractPredictedClass=function(B,Q){return JA(this,void 0,void 0,function(){var w,C,E,e;return mA(this,function(I){switch(I.label){case 0:return w=Q.row,C=Q.col,E=Q.anchor,[4,B.array()];case 1:return e=I.sent(),[2,Array(this.config.classes.length).fill(0).map(function(t,n){return e[w][C][E][n]}).map(function(t,n){return{classScore:t,label:n}}).reduce(function(t,n){return t.classScore>n.classScore?t:n})]}})})},g.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],g}(UQ),Iv=function(A){LA(g,A);function g(B){B===void 0&&(B=!0);var Q=this,w=Object.assign({},{withSeparableConvs:B,iouThreshold:qP,classes:["face"]},B?{anchors:$P,meanRgb:Av}:{anchors:_P,withClassScores:!0});return Q=A.call(this,w)||this,Q}return Object.defineProperty(g.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),g.prototype.locateFaces=function(B,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(B,Q)];case 1:return w=C.sent(),[2,w.map(function(E){return new mg(E.score,E.relativeBox,{width:E.imageWidth,height:E.imageHeight})})]}})})},g.prototype.getDefaultModelName=function(){return this.withSeparableConvs?gv:Bv},g.prototype.extractParamsFromWeigthMap=function(B){return A.prototype.extractParamsFromWeigthMap.call(this,B)},g}(LD),VD=function(A){LA(g,A);function g(){var B=A!==null&&A.apply(this,arguments)||this;return B._name="TinyFaceDetectorOptions",B}return g}(un),BE=function(){function A(){}return A.prototype.then=function(g){return JA(this,void 0,void 0,function(){var B;return mA(this,function(Q){switch(Q.label){case 0:return B=g,[4,this.run()];case 1:return[2,B.apply(void 0,[Q.sent()])]}})})},A.prototype.run=function(){return JA(this,void 0,void 0,function(){return mA(this,function(g){throw new Error("ComposableTask - run is not implemented")})})},A}();function Oe(A,g,B,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,I,t;return mA(this,function(n){switch(n.label){case 0:return C=A.map(function(i){return Dn(i)?w(i):i.detection}),e=Q,e?[3,5]:g instanceof HB?[4,nn(g,C)]:[3,2];case 1:return I=n.sent(),[3,4];case 2:return[4,We(g,C)];case 3:I=n.sent(),n.label=4;case 4:e=I,n.label=5;case 5:return E=e,[4,B(E)];case 6:return t=n.sent(),E.forEach(function(i){return i instanceof HB&&i.dispose()}),[2,t]}})})}function Un(A,g,B,Q,w){return JA(this,void 0,void 0,function(){var C=this;return mA(this,function(E){return[2,Oe([A],g,function(e){return JA(C,void 0,void 0,function(){return mA(this,function(I){return[2,B(e[0])]})})},Q,w)]})})}function ov(A){return FA(function(){return fg(WB(A,3).reverse(),3)})}var Ze=2,qe=12;function tv(A,g){var B=Se(A,g),Q=Yn(A,g);function w(t,n){var i=pB(A(t));return g.push({paramPath:n}),i}function C(t,n,i){i===void 0&&(i=!1);var c=B(t[0],t[1],3,n+"/conv1"),Y=w(t[1],n+"/prelu1_alpha"),M=B(t[1],t[2],3,n+"/conv2"),D=w(t[2],n+"/prelu2_alpha"),r=B(t[2],t[3],i?2:3,n+"/conv3"),a=w(t[3],n+"/prelu3_alpha");return{conv1:c,prelu1_alpha:Y,conv2:M,prelu2_alpha:D,conv3:r,prelu3_alpha:a}}function E(){var t=C([3,10,16,32],"pnet"),n=B(32,2,1,"pnet/conv4_1"),i=B(32,4,1,"pnet/conv4_2");return tg(tg({},t),{conv4_1:n,conv4_2:i})}function e(){var t=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 tg(tg({},t),{fc1:n,prelu4_alpha:i,fc2_1:c,fc2_2:Y})}function I(){var t=C([3,32,64,64],"onet"),n=B(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 tg(tg({},t),{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:I}}function nv(A){var g=hQ(A),B=g.extractWeights,Q=g.getRemainingWeights,w=[],C=tv(B,w),E=C.extractPNetParams,e=C.extractRNetParams,I=C.extractONetParams,t=E(),n=e(),i=I();if(Q().length!==0)throw new Error("weights remaing after extract: "+Q().length);return{params:{pnet:t,rnet:n,onet:i},paramMappings:w}}function iv(A,g){var B=yQ(A,g);function Q(n){var i=B(n+"/weights",4,n+"/filters"),c=B(n+"/bias",1);return{filters:i,bias:c}}function w(n){var i=B(n+"/weights",2),c=B(n+"/bias",1);return{weights:i,bias:c}}function C(n){return B(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 tg(tg({},n),{conv4_1:i,conv4_2:c})}function I(){var n=E("rnet"),i=w("rnet/fc1"),c=C("rnet/prelu4_alpha"),Y=w("rnet/fc2_1"),M=w("rnet/fc2_2");return tg(tg({},n),{fc1:i,prelu4_alpha:c,fc2_1:Y,fc2_2:M})}function t(){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"),a=w("onet/fc2_3");return tg(tg({},n),{conv4:i,prelu4_alpha:c,fc1:Y,prelu5_alpha:M,fc2_1:D,fc2_2:r,fc2_3:a})}return{extractPNetParams:e,extractRNetParams:I,extractONetParams:t}}function cv(A){var g=[],B=iv(A,g),Q=B.extractPNetParams,w=B.extractRNetParams,C=B.extractONetParams,E=Q(),e=w(),I=C();return lQ(A,g),{params:{pnet:E,rnet:e,onet:I},paramMappings:g}}function ln(A,g){var B=g[0],Q=g[1];return{height:Math.floor(B*A),width:Math.floor(Q*A)}}function Yv(A,g,B){for(var Q=B[0],w=B[1],C=qe/A,E=[],e=Math.min(Q,w)*C,I=0;e>=12;)E.push(C*Math.pow(g,I)),e=e*g,I+=1;return E}var hn=function(A){LA(g,A);function g(B,Q,w,C){return A.call(this,{left:B,top:Q,right:w,bottom:C},!0)||this}return g}(wQ);function KD(A){return FA(function(){return Ig(SB(A,cA(127.5)),cA(.0078125))})}function EC(A,g){return FA(function(){return BB(JB(A),Ig(g,se(JB(se(A)))))})}function Gn(A,g,B){return B===void 0&&(B=!1),FA(function(){var Q=Vg(A,g.conv1,"valid");return Q=EC(Q,g.prelu1_alpha),Q=OB(Q,B?[2,2]:[3,3],[2,2],"same"),Q=Vg(Q,g.conv2,"valid"),Q=EC(Q,g.prelu2_alpha),Q=B?Q:OB(Q,[3,3],[2,2],"valid"),Q=Vg(Q,g.conv3,"valid"),Q=EC(Q,g.prelu3_alpha),Q})}function Mv(A,g){return FA(function(){var B=Gn(A,g,!0),Q=Vg(B,g.conv4_1,"valid"),w=Tg(He(Q,3),3),C=FQ(SB(Q,w),3),E=Vg(B,g.conv4_2,"valid");return{prob:C,regions:E}})}function rv(A,g){return FA(function(){var B=ln(g,A.shape.slice(1)),Q=B.height,w=B.width,C=yt.resizeBilinear(A,[Q,w]),E=KD(C);return vQ(E,[0,2,1,3])})}function Dv(A,g,B,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 cB(e,E));var I=w.map(function(t){var n=new ve(Math.round((t.y*Ze+1)/B),Math.round((t.x*Ze+1)/B),Math.round((t.y*Ze+qe)/B),Math.round((t.x*Ze+qe)/B)),i=C[t.y][t.x],c=g.arraySync(),Y=new hn(c[t.y][t.x][0],c[t.y][t.x][1],c[t.y][t.x][2],c[t.y][t.x][3]);return{cell:n,score:i,region:Y}});return I}function Fv(A,g,B,Q,w){w.stage1=[];var C=g.map(function(c){return FA(function(){var Y={scale:c},M=rv(A,c),D=Date.now(),r=Mv(M,Q),a=r.prob,s=r.regions;Y.pnet=Date.now()-D;var u=WB(WB(a,3)[1])[0],F=WB(s)[0];return{scoresTensor:u,regionsTensor:F,scale:c,statsForScale:Y}})}),E=C.map(function(c){var Y=c.scoresTensor,M=c.regionsTensor,D=c.scale,r=c.statsForScale,a=Dv(Y,M,D,B);if(Y.dispose(),M.dispose(),!a.length)return w.stage1.push(r),[];var s=Date.now(),u=_C(a.map(function(F){return F.cell}),a.map(function(F){return F.score}),.5);return r.nms=Date.now()-s,r.numBoxes=u.length,w.stage1.push(r),u.map(function(F){return a[F]})}),e=E.reduce(function(c,Y){return c.concat(Y)},[]),I=[],t=[];if(e.length>0){var n=Date.now(),i=_C(e.map(function(c){return c.cell}),e.map(function(c){return c.score}),.7);w.stage1_nms=Date.now()-n,t=i.map(function(c){return e[c].score}),I=i.map(function(c){return e[c]}).map(function(c){var Y=c.cell,M=c.region;return new ve(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:I,scores:t}}function xD(A,g,B){var Q=B.width,w=B.height;return JA(this,void 0,void 0,function(){var C,E,e,I=this;return mA(this,function(t){switch(t.label){case 0:return C=CQ(A),[4,Promise.all(g.map(function(n){return JA(I,void 0,void 0,function(){var i,c,Y,M,D,r,a,s;return mA(this,function(u){return i=n.padAtBorders(A.height,A.width),c=i.y,Y=i.ey,M=i.x,D=i.ex,r=M-1,a=c-1,s=C.getImageData(r,a,D-r,Y-a),[2,ng.isNodejs()?ye(s):createImageBitmap(s)]})})}))];case 1:return E=t.sent(),e=[],E.forEach(function(n){var i=pe({width:Q,height:w}),c=CQ(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=vQ(ag(n,[1,Q,w,3]),[0,2,1,3]).toFloat();return KD(c)});return i})]}})})}function av(A,g){return FA(function(){var B=Gn(A,g),Q=bg(B,[B.shape[0],g.fc1.weights.shape[0]]),w=EQ(Q,g.fc1),C=EC(w,g.prelu4_alpha),E=EQ(C,g.fc2_1),e=Tg(He(E,1),1),I=FQ(SB(E,e),1),t=EQ(C,g.fc2_2),n=WB(I,1)[1];return{scores:n,regions:t}})}function sv(A,g,B,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,I,t,n,i,c,Y,M,D,r,a,s;return mA(this,function(u){switch(u.label){case 0:return C=Date.now(),[4,xD(A,g,{width:24,height:24})];case 1:return E=u.sent(),w.stage2_extractImagePatches=Date.now()-C,C=Date.now(),e=E.map(function(F){var U=av(F,Q);return F.dispose(),U}),w.stage2_rnet=Date.now()-C,I=e.length>1?zB(e.map(function(F){return F.scores})):e[0].scores,i=(n=Array).from,[4,I.data()];case 2:return t=i.apply(n,[u.sent()]),I.dispose(),c=t.map(function(F,U){return{score:F,idx:U}}).filter(function(F){return F.score>B}).map(function(F){var U=F.idx;return U}),Y=c.map(function(F){return g[F]}),M=c.map(function(F){return t[F]}),D=[],r=[],Y.length>0&&(C=Date.now(),a=_C(Y,M,.7),w.stage2_nms=Date.now()-C,s=a.map(function(F){var U=e[c[F]].regions.arraySync();return new hn(U[0][0],U[0][1],U[0][2],U[0][3])}),r=a.map(function(F){return M[F]}),D=a.map(function(F,U){return Y[F].calibrate(s[U])})),e.forEach(function(F){F.regions.dispose(),F.scores.dispose()}),[2,{boxes:D,scores:r}]}})})}function uv(A,g){return FA(function(){var B=Gn(A,g);B=OB(B,[2,2],[2,2],"same"),B=Vg(B,g.conv4,"valid"),B=EC(B,g.prelu4_alpha);var Q=bg(B,[B.shape[0],g.fc1.weights.shape[0]]),w=EQ(Q,g.fc1),C=EC(w,g.prelu5_alpha),E=EQ(C,g.fc2_1),e=Tg(He(E,1),1),I=FQ(SB(E,e),1),t=EQ(C,g.fc2_2),n=EQ(C,g.fc2_3),i=WB(I,1)[1];return{scores:i,regions:t,points:n}})}function Uv(A,g,B,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,I,t,n,i,c,Y,M,D,r,a,s,u;return mA(this,function(F){switch(F.label){case 0:return C=Date.now(),[4,xD(A,g,{width:48,height:48})];case 1:return E=F.sent(),w.stage3_extractImagePatches=Date.now()-C,C=Date.now(),e=E.map(function(U){var l=uv(U,Q);return U.dispose(),l}),w.stage3_onet=Date.now()-C,I=e.length>1?zB(e.map(function(U){return U.scores})):e[0].scores,i=(n=Array).from,[4,I.data()];case 2:return t=i.apply(n,[F.sent()]),I.dispose(),c=t.map(function(U,l){return{score:U,idx:l}}).filter(function(U){return U.score>B}).map(function(U){var l=U.idx;return l}),Y=c.map(function(U){var l=e[U].regions.arraySync();return new hn(l[0][0],l[0][1],l[0][2],l[0][3])}),M=c.map(function(U,l){return g[U].calibrate(Y[l])}),D=c.map(function(U){return t[U]}),r=[],a=[],s=[],M.length>0&&(C=Date.now(),u=_C(M,D,.7,!1),w.stage3_nms=Date.now()-C,r=u.map(function(U){return M[U]}),a=u.map(function(U){return D[U]}),s=u.map(function(U,l){return Array(5).fill(0).map(function(d,H){var h=e[U].points.arraySync();return new cB(h[0][H]*(r[l].width+1)+r[l].left,h[0][H+5]*(r[l].height+1)+r[l].top)})})),e.forEach(function(U){U.regions.dispose(),U.scores.dispose(),U.points.dispose()}),[2,{boxes:r,scores:a,points:s}]}})})}var lv=function(A){LA(g,A);function g(){return A.call(this,"Mtcnn")||this}return g.prototype.load=function(B){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,B)]})})},g.prototype.loadFromDisk=function(B){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,B)]})})},g.prototype.forwardInput=function(B,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,I,t,n,i,c,Y,M,D,r,a,s,u,F,U,l,d,H;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=B.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(),I=FA(function(){return ov(Tg(Qn.fromPixels(C)).toFloat())}),t=function(G){return I.dispose(),E.total=Date.now()-e,G},n=I.shape.slice(1),i=n[0],c=n[1],Y=new WD(Q),M=Y.minFaceSize,D=Y.scaleFactor,r=Y.maxNumScales,a=Y.scoreThresholds,s=Y.scaleSteps,u=(s||Yv(M,D,[i,c])).filter(function(G){var N=ln(G,[i,c]);return Math.min(N.width,N.height)>qe}).slice(0,r),E.scales=u,E.pyramid=u.map(function(G){return ln(G,[i,c])}),F=Date.now(),[4,Fv(I,u,a[0],w.pnet,E)];case 1:return U=h.sent(),E.total_stage1=Date.now()-F,U.boxes.length?(E.stage2_numInputBoxes=U.boxes.length,F=Date.now(),[4,sv(C,U.boxes,a[1],w.rnet,E)]):[2,t({results:[],stats:E})];case 2:return l=h.sent(),E.total_stage2=Date.now()-F,l.boxes.length?(E.stage3_numInputBoxes=l.boxes.length,F=Date.now(),[4,Uv(C,l.boxes,a[2],w.onet,E)]):[2,t({results:[],stats:E})];case 3:return d=h.sent(),E.total_stage3=Date.now()-F,H=d.boxes.map(function(G,N){return Le(AE({},new mg(d.scores[N],new ke(G.left/c,G.top/i,G.width/c,G.height/i),{height:i,width:c})),new XR(d.points[N].map(function(f){return f.sub(new cB(G.left,G.top)).div(new cB(G.width,G.height))}),{width:G.width,height:G.height}))}),[2,t({results:H,stats:E})]}})})},g.prototype.forward=function(B,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,ZB(B)];case 1:return[4,w.apply(this,[C.sent(),Q])];case 2:return[2,C.sent().results]}})})},g.prototype.forwardWithStats=function(B,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,ZB(B)];case 1:return[2,w.apply(this,[C.sent(),Q])]}})})},g.prototype.getDefaultModelName=function(){return"mtcnn_model"},g.prototype.extractParamsFromWeigthMap=function(B){return cv(B)},g.prototype.extractParams=function(B){return nv(B)},g}(UQ),hv=.4,Gv=[new cB(1.603231,2.094468),new cB(6.041143,7.080126),new cB(2.882459,3.518061),new cB(4.266906,5.178857),new cB(9.041765,10.66308)],dv=[117.001,114.697,97.404],Hv=function(A){LA(g,A);function g(){var B=this,Q={withSeparableConvs:!0,iouThreshold:hv,classes:["face"],anchors:Gv,meanRgb:dv,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return B=A.call(this,Q)||this,B}return Object.defineProperty(g.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),g.prototype.locateFaces=function(B,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(B,Q)];case 1:return w=C.sent(),[2,w.map(function(E){return new mg(E.score,E.relativeBox,{width:E.imageWidth,height:E.imageHeight})})]}})})},g.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},g.prototype.extractParamsFromWeigthMap=function(B){return A.prototype.extractParamsFromWeigthMap.call(this,B)},g}(LD),Ug={ssdMobilenetv1:new bD,tinyFaceDetector:new Hv,tinyYolov2:new Iv,mtcnn:new lv,faceLandmark68Net:new kD,faceLandmark68TinyNet:new JP,faceRecognitionNet:new TP,faceExpressionNet:new cP,ageGenderNet:new GP},XD=function(A){LA(g,A);function g(B,Q,w){var C=A.call(this)||this;return C.parentTask=B,C.input=Q,C.extractedFaces=w,C}return g}(BE),dn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w=this;return mA(this,function(C){switch(C.label){case 0:return[4,this.parentTask];case 1:return B=C.sent(),[4,Oe(B,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(I){return Ug.faceExpressionNet.predictExpressions(I)}))];case 1:return[2,e.sent()]}})})},this.extractedFaces)];case 2:return Q=C.sent(),[2,B.map(function(E,e){return RD(E,Q[e])})]}})})},g.prototype.withAgeAndGender=function(){return new mn(this,this.input)},g}(XD),Hn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return B=w.sent(),B?[4,Un(B,this.input,function(C){return Ug.faceExpressionNet.predictExpressions(C)},this.extractedFaces)]:[2];case 2:return Q=w.sent(),[2,RD(B,Q)]}})})},g.prototype.withAgeAndGender=function(){return new Nn(this,this.input)},g}(XD),fn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.withAgeAndGender=function(){return new Rn(this,this.input)},g.prototype.withFaceDescriptors=function(){return new vn(this,this.input)},g}(dn),Jn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.withAgeAndGender=function(){return new Pn(this,this.input)},g.prototype.withFaceDescriptor=function(){return new kn(this,this.input)},g}(Hn),OD=function(A){LA(g,A);function g(B,Q,w){var C=A.call(this)||this;return C.parentTask=B,C.input=Q,C.extractedFaces=w,C}return g}(BE),mn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w=this;return mA(this,function(C){switch(C.label){case 0:return[4,this.parentTask];case 1:return B=C.sent(),[4,Oe(B,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(I){return Ug.ageGenderNet.predictAgeAndGender(I)}))];case 1:return[2,e.sent()]}})})},this.extractedFaces)];case 2:return Q=C.sent(),[2,B.map(function(E,e){var I=Q[e],t=I.age,n=I.gender,i=I.genderProbability;return yD(zD(E,n,i),t)})]}})})},g.prototype.withFaceExpressions=function(){return new dn(this,this.input)},g}(OD),Nn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w,C,E;return mA(this,function(e){switch(e.label){case 0:return[4,this.parentTask];case 1:return B=e.sent(),B?[4,Un(B,this.input,function(I){return Ug.ageGenderNet.predictAgeAndGender(I)},this.extractedFaces)]:[2];case 2:return Q=e.sent(),w=Q.age,C=Q.gender,E=Q.genderProbability,[2,yD(zD(B,C,E),w)]}})})},g.prototype.withFaceExpressions=function(){return new Hn(this,this.input)},g}(OD),Rn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.withFaceExpressions=function(){return new fn(this,this.input)},g.prototype.withFaceDescriptors=function(){return new vn(this,this.input)},g}(mn),Pn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.withFaceExpressions=function(){return new Jn(this,this.input)},g.prototype.withFaceDescriptor=function(){return new kn(this,this.input)},g}(Nn),ZD=function(A){LA(g,A);function g(B,Q){var w=A.call(this)||this;return w.parentTask=B,w.input=Q,w}return g}(BE),vn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return B=w.sent(),[4,Oe(B,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 pD(B[E],C)})]}})})},g.prototype.withFaceExpressions=function(){return new fn(this,this.input)},g.prototype.withAgeAndGender=function(){return new Rn(this,this.input)},g}(ZD),kn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return B=w.sent(),B?[4,Un(B,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,pD(B,Q)]}})})},g.prototype.withFaceExpressions=function(){return new Jn(this,this.input)},g.prototype.withAgeAndGender=function(){return new Pn(this,this.input)},g}(ZD),qD=function(A){LA(g,A);function g(B,Q,w){var C=A.call(this)||this;return C.parentTask=B,C.input=Q,C.useTinyLandmarkNet=w,C}return Object.defineProperty(g.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?Ug.faceLandmark68TinyNet:Ug.faceLandmark68Net},enumerable:!0,configurable:!0}),g}(BE),fv=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w,C,E,e=this;return mA(this,function(I){switch(I.label){case 0:return[4,this.parentTask];case 1:return B=I.sent(),Q=B.map(function(t){return t.detection}),this.input instanceof HB?[4,nn(this.input,Q)]:[3,3];case 2:return C=I.sent(),[3,5];case 3:return[4,We(this.input,Q)];case 4:C=I.sent(),I.label=5;case 5:return w=C,[4,Promise.all(w.map(function(t){return e.landmarkNet.detectLandmarks(t)}))];case 6:return E=I.sent(),w.forEach(function(t){return t instanceof HB&&t.dispose()}),[2,B.map(function(t,n){return Le(t,E[n])})]}})})},g.prototype.withFaceExpressions=function(){return new fn(this,this.input)},g.prototype.withAgeAndGender=function(){return new Rn(this,this.input)},g.prototype.withFaceDescriptors=function(){return new vn(this,this.input)},g}(qD),Jv=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w,C,E;return mA(this,function(e){switch(e.label){case 0:return[4,this.parentTask];case 1:return B=e.sent(),B?(Q=B.detection,this.input instanceof HB?[4,nn(this.input,[Q])]:[3,3]):[2];case 2:return C=e.sent(),[3,5];case 3:return[4,We(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(I){return I instanceof HB&&I.dispose()}),[2,Le(B,E)]}})})},g.prototype.withFaceExpressions=function(){return new Jn(this,this.input)},g.prototype.withAgeAndGender=function(){return new Pn(this,this.input)},g.prototype.withFaceDescriptor=function(){return new kn(this,this.input)},g}(qD),_D=function(A){LA(g,A);function g(B,Q){Q===void 0&&(Q=new xe);var w=A.call(this)||this;return w.input=B,w.options=Q,w}return g}(BE),mv=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w,C;return mA(this,function(E){switch(E.label){case 0:return B=this,Q=B.input,w=B.options,w instanceof WD?[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 VD?function(e){return Ug.tinyFaceDetector.locateFaces(e,w)}:w instanceof xe?function(e){return Ug.ssdMobilenetv1.locateFaces(e,w)}:w instanceof un?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)]}})})},g.prototype.runAndExtendWithFaceDetections=function(){var B=this;return new Promise(function(Q){return JA(B,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 AE({},E)}))]}})})})},g.prototype.withFaceLandmarks=function(B){return B===void 0&&(B=!1),new fv(this.runAndExtendWithFaceDetections(),this.input,B)},g.prototype.withFaceExpressions=function(){return new dn(this.runAndExtendWithFaceDetections(),this.input)},g.prototype.withAgeAndGender=function(){return new mn(this.runAndExtendWithFaceDetections(),this.input)},g}(_D),Nv=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q;return mA(this,function(w){switch(w.label){case 0:return[4,new mv(this.input,this.options)];case 1:return B=w.sent(),Q=B[0],B.forEach(function(C){C.score>Q.score&&(Q=C)}),[2,Q]}})})},g.prototype.runAndExtendWithFaceDetection=function(){var B=this;return new Promise(function(Q){return JA(B,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?AE({},w):void 0)]}})})})},g.prototype.withFaceLandmarks=function(B){return B===void 0&&(B=!1),new Jv(this.runAndExtendWithFaceDetection(),this.input,B)},g.prototype.withFaceExpressions=function(){return new Hn(this.runAndExtendWithFaceDetection(),this.input)},g.prototype.withAgeAndGender=function(){return new Nn(this.runAndExtendWithFaceDetection(),this.input)},g}(_D);function Rv(A,g){return g===void 0&&(g=new xe),new Nv(A,g)}function Pv(A,g){if(A.length!==g.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var B=Array.from(A),Q=Array.from(g);return Math.sqrt(B.map(function(w,C){return w-Q[C]}).reduce(function(w,C){return w+Math.pow(C,2)},0))}(function(){function A(g,B){B===void 0&&(B=.6),this._distanceThreshold=B;var Q=Array.isArray(g)?g:[g];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 Te)return E;if(E instanceof Float32Array)return new Te(C(),[E]);if(E.descriptor&&E.descriptor instanceof Float32Array)return new Te(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(g,B){return B.map(function(Q){return Pv(Q,g)}).reduce(function(Q,w){return Q+w},0)/(B.length||1)},A.prototype.matchDescriptor=function(g){var B=this;return this.labeledDescriptors.map(function(Q){var w=Q.descriptors,C=Q.label;return new cD(C,B.computeMeanDistance(g,w))}).reduce(function(Q,w){return Q.distance<w.distance?Q:w})},A.prototype.findBestMatch=function(g){var B=this.matchDescriptor(g);return B.distance<this.distanceThreshold?B:new cD("unknown",B.distance)},A.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(g){return g.toJSON()})}},A.fromJSON=function(g){var B=g.labeledDescriptors.map(function(Q){return Te.fromJSON(Q)});return new A(B,g.distanceThreshold)},A})();function $D(A,g){var B=new cw(g.width,g.height),Q=B.width,w=B.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 $D(e,{width:Q,height:w})});if(Dn(A)){var C=A.detection.forSize(Q,w),E=A.unshiftedLandmarks.forSize(C.box.width,C.box.height);return Le(AE(A,C),E)}return je(A)?AE(A,A.detection.forSize(Q,w)):A instanceof wC||A instanceof mg?A.forSize(Q,w):A}class vv{getVideoStreamConfig(g,B){return{audio:!1,video:{width:{min:g,ideal:g},height:{min:B,ideal:B},facingMode:"environment"}}}getContourCoordinate(g,B){return{x:g*.25,y:B*.05,width:g*.5,height:B*.9}}getBoxData(g){return g?{x:g.x,y:g.y,width:g.width,height:g.height}:null}setStylesForCanvas(g){g.width="100%",g.height="100%",g.style.position="absolute",g.style.top="0",g.style.left="0"}checkFaceInclusion(g,B){if(!g||!B||B.width>g.width||B.height>g.height)return!1;const Q=B.x,w=B.x+B.width,C=B.y,E=B.y+B.height,e=g.x,I=g.x+g.width,t=g.y,n=g.y+g.height;return Q>=e&&w<=I&&C>=t&&E<=n}async getFaceDetections(g,B){if(!g)return[];const Q=new VD({inputSize:B});return Rv(g,Q).withFaceLandmarks(!0)}getCanvas(g){return ye(g)}getResizedAndDetection(g,B,Q,w,C){eP(g,{width:w,height:C});const E=$D(B,{width:w,height:C});Q.clearRect(0,0,w,C),AP(g,E),rP(g,E)}async getFaceSnapshot(g,B){const Q=[new ke(B.x,B.y,B.width,B.height)],w=await We(g,Q);return w.length?w[0].toDataURL("image/jpeg").replace(/^data:image\/\w+;base64,/,""):null}async initModels(){let g=new Date;console.log(g);try{await Promise.all([Ug.tinyFaceDetector.loadFromUri("/models"),Ug.faceLandmark68TinyNet.loadFromUri("/models")])}catch(B){console.error(B)}g=new Date,console.log(g)}}let Tn;function kv(){return Tn||(Tn=new vv),Tn}function Tv(A){const g=o.ref(""),B=o.ref(1),Q=async(E="",e=1)=>{await A.initialize({search:E,page:e})},w=async E=>{g.value=E,B.value=1,await Q(E,B.value)},C=async E=>{B.value=E,await Q(g.value,E)};return o.watch(()=>A.columnFilters.value,async()=>{B.value=1,await Q(g.value,B.value)},{deep:!0}),o.onMounted(()=>Q(g.value,B.value)),{search:g,currentPage:B,loading:A.loading,handleSearch:w,handlePageChange:C,loadTable:Q}}const jv=A=>{const g=o.ref({}),B=o.ref({});A.columns.forEach(({name:I,filterType:t})=>{t&&(g.value[I]=t==="multi"?[]:void 0,B.value[I]=!1)});const Q=o.computed(()=>Array.isArray(A.rows)?A.rows:A.rows.value),w=(I,t)=>{const n=A.columns.find(i=>i.name===I);if((n==null?void 0:n.filterType)==="multi"){const i=g.value[I],c=i.indexOf(t);c>-1?i.splice(c,1):i.push(t),g.value[I]=[...i]}else g.value[I]=t,B.value[I]=!1},C=o.computed(()=>{var t;const I={};for(const n of A.columns){const i=g.value[n.name],c=((t=A.filtersOptions)==null?void 0:t.value[n.name])||[];i&&(I[n.name]=Array.isArray(i)?c.filter(Y=>i.includes(Y.name)).map(Y=>Y.id):c.filter(Y=>Y.name===i).map(Y=>Y.id))}return I}),E=I=>{const t=A.columns.find(n=>n.name===I);g.value[I]=(t==null?void 0:t.filterType)==="multi"?[]:void 0},e=(I,t)=>{B.value[I]=t};return{rows:Q,columns:o.computed(()=>A.columns),columnFilters:g,filterMenus:B,toggleFilterValue:w,clearFilter:E,openFilterMenu:e,selectedFilters:C}};function pv(A,g=[]){const B=o.ref([...new Set([...g,...A.map(C=>C.name)])]),Q=o.computed(()=>A.filter(C=>B.value.includes(C.name)));function w(C){C.dialog({title:"Выберите колонки",options:{type:"checkbox",model:[...B.value],items:A.map(E=>({label:E.label,value:E.name,disable:g.includes(E.name)}))},cancel:!0,persistent:!0}).onOk(E=>{B.value=Array.from(new Set([...E,...g]))})}return{selectedColumnNames:B,visibleColumns:Q,openColumnSelectorDialog:w}}hA.ApiService=Bg,hA.AppButton=DE,hA.AppCheckbox=Aa,hA.AppConfirmDialog=bl,hA.AppDatePicker=Ua,hA.AppDatepicker=Za,hA.AppDropdown=xl,hA.AppInput=qa,hA.AppInputNew=ac,hA.AppInputSearch=_a,hA.AppLayout=Qs,hA.AppLayoutHeader=yU,hA.AppLayoutPage=SU,hA.AppLoader=hc,hA.AppModalSelect=zc,hA.AppSelect=ZU,hA.AppSheet=wl,hA.AppSheetNew=al,hA.AppSidebar=dl,hA.AppTable=qc,hA.AppTableLayout=wG,hA.AppTableModal=oh,hA.AppTablePagination=pc,hA.AppTableSearch=yc,hA.AppToggle=Hl,hA.AppWrapper=Nl,hA.base64ToBlob=Va,hA.isEqual=UC,hA.normalizeValue=Pw,hA.notificationSettings=xI,hA.useAuthService=yd,hA.useBaseTable=Tv,hA.useBrigadesService=CH,hA.useColumnSelector=pv,hA.useCommentsService=BH,hA.useControlsService=Od,hA.useEquipmentService=QH,hA.useFaceApiHelper=kv,hA.useFileService=Wd,hA.useGanttService=Jd,hA.useInstrumentsService=xd,hA.useMetricsService=Nd,hA.useModulesService=$d,hA.useProjectsService=Pd,hA.useRepairsService=kd,hA.useSearchService=qd,hA.useTableModel=jv,hA.useTasksService=jd,hA.useUserService=Vd,hA.useVideoService=Sd,hA.uuidv4=KI,Object.defineProperty(hA,Symbol.toStringTag,{value:"Module"})});
|
|
3834
|
+
***************************************************************************** */var wn=function(A,g){return wn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(B,Q){B.__proto__=Q}||function(B,Q){for(var w in Q)Q.hasOwnProperty(w)&&(B[w]=Q[w])},wn(A,g)};function LA(A,g){wn(A,g);function B(){this.constructor=A}A.prototype=g===null?Object.create(g):(B.prototype=g.prototype,new B)}var tg=function(){return tg=Object.assign||function(g){for(var B,Q=1,w=arguments.length;Q<w;Q++){B=arguments[Q];for(var C in B)Object.prototype.hasOwnProperty.call(B,C)&&(g[C]=B[C])}return g},tg.apply(this,arguments)};function JA(A,g,B,Q){function w(C){return C instanceof B?C:new B(function(E){E(C)})}return new(B||(B=Promise))(function(C,E){function e(n){try{t(Q.next(n))}catch(i){E(i)}}function I(n){try{t(Q.throw(n))}catch(i){E(i)}}function t(n){n.done?C(n.value):w(n.value).then(e,I)}t((Q=Q.apply(A,[])).next())})}function mA(A,g){var B={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(t){return function(n){return I([t,n])}}function I(t){if(Q)throw new TypeError("Generator is already executing.");for(;B;)try{if(Q=1,w&&(C=t[0]&2?w.return:t[0]?w.throw||((C=w.return)&&C.call(w),0):w.next)&&!(C=C.call(w,t[1])).done)return C;switch(w=0,C&&(t=[t[0]&2,C.value]),t[0]){case 0:case 1:C=t;break;case 4:return B.label++,{value:t[1],done:!1};case 5:B.label++,w=t[1],t=[0];continue;case 7:t=B.ops.pop(),B.trys.pop();continue;default:if(C=B.trys,!(C=C.length>0&&C[C.length-1])&&(t[0]===6||t[0]===2)){B=0;continue}if(t[0]===3&&(!C||t[1]>C[0]&&t[1]<C[3])){B.label=t[1];break}if(t[0]===6&&B.label<C[1]){B.label=C[1],C=t;break}if(C&&B.label<C[2]){B.label=C[2],B.ops.push(t);break}C[2]&&B.ops.pop(),B.trys.pop();continue}t=g.call(A,B)}catch(n){t=[6,n],w=0}finally{Q=C=0}if(t[0]&5)throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}function ZC(){for(var A=0,g=0,B=arguments.length;g<B;g++)A+=arguments[g].length;for(var Q=Array(A),w=0,g=0;g<B;g++)for(var C=arguments[g],E=0,e=C.length;E<e;E++,w++)Q[w]=C[E];return Q}var cw=function(){function A(g,B){if(!Yw(g)||!Yw(B))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:g,height:B}));this._width=g,this._height=B}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 Re(A,g){return A instanceof HB&&A.shape.length===g}function yR(A){return Re(A,2)}function Pe(A){return Re(A,3)}function jQ(A){return Re(A,4)}function zR(A){return A%1!==0}function eD(A){return A%2===0}function ID(A,g){g===void 0&&(g=2);var B=Math.pow(10,g);return Math.floor(A*B)/B}function oD(A){return A&&A.width&&A.height}function WR(A,g){var B=A.width,Q=A.height,w=g/Math.max(Q,B);return new cw(Math.round(B*w),Math.round(Q*w))}function Cn(A){return A.reduce(function(g,B){return g.add(B)},new cB(0,0)).div(new cB(A.length,A.length))}function qC(A,g,B){return Array(A).fill(0).map(function(Q,w){return g+w*B})}function Yw(A){return!!A&&A!==1/0&&A!==-1/0&&!isNaN(A)||A===0}function tD(A){return Yw(A)&&0<=A&&A<=1}var cB=function(){function A(g,B){this._x=g,this._y=B}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(g){return new A(this.x+g.x,this.y+g.y)},A.prototype.sub=function(g){return new A(this.x-g.x,this.y-g.y)},A.prototype.mul=function(g){return new A(this.x*g.x,this.y*g.y)},A.prototype.div=function(g){return new A(this.x/g.x,this.y/g.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}(),wQ=function(){function A(g,B){B===void 0&&(B=!0);var Q=g||{},w=[Q.left,Q.top,Q.right,Q.bottom].every(Yw),C=[Q.x,Q.y,Q.width,Q.height].every(Yw);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],I=E[1],t=E[2],n=E[3];A.assertIsValidBox({x:e,y:I,width:t,height:n},"Box.constructor",B),this._x=e,this._y=I,this._width=t,this._height=n}return A.isRect=function(g){return!!g&&[g.x,g.y,g.width,g.height].every(Yw)},A.assertIsValidBox=function(g,B,Q){if(Q===void 0&&(Q=!1),!A.isRect(g))throw new Error(B+" - invalid box: "+JSON.stringify(g)+", expected object with properties x, y, width, height");if(!Q&&(g.width<0||g.height<0))throw new Error(B+" - width ("+g.width+") and height ("+g.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 cB(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"topRight",{get:function(){return new cB(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"bottomLeft",{get:function(){return new cB(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(A.prototype,"bottomRight",{get:function(){return new cB(this.right,this.bottom)},enumerable:!0,configurable:!0}),A.prototype.round=function(){var g=[this.x,this.y,this.width,this.height].map(function(E){return Math.round(E)}),B=g[0],Q=g[1],w=g[2],C=g[3];return new A({x:B,y:Q,width:w,height:C})},A.prototype.floor=function(){var g=[this.x,this.y,this.width,this.height].map(function(E){return Math.floor(E)}),B=g[0],Q=g[1],w=g[2],C=g[3];return new A({x:B,y:Q,width:w,height:C})},A.prototype.toSquare=function(){var g=this,B=g.x,Q=g.y,w=g.width,C=g.height,E=Math.abs(w-C);return w<C&&(B-=E/2,w+=E),C<w&&(Q-=E/2,C+=E),new A({x:B,y:Q,width:w,height:C})},A.prototype.rescale=function(g){var B=oD(g)?g.width:g,Q=oD(g)?g.height:g;return new A({x:this.x*B,y:this.y*Q,width:this.width*B,height:this.height*Q})},A.prototype.pad=function(g,B){var Q=[this.x-g/2,this.y-B/2,this.width+g,this.height+B],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(g,B){var Q=this,w=Q.x,C=Q.y,E=Q.right,e=Q.bottom,I=Math.max(w,0),t=Math.max(C,0),n=E-I,i=e-t,c=Math.min(n,g-I),Y=Math.min(i,B-t);return new A({x:I,y:t,width:c,height:Y}).floor()},A.prototype.shift=function(g,B){var Q=this,w=Q.width,C=Q.height,E=this.x+g,e=this.y+B;return new A({x:E,y:e,width:w,height:C})},A.prototype.padAtBorders=function(g,B){var Q=this.width+1,w=this.height+1,C=1,E=1,e=Q,I=w,t=this.left,n=this.top,i=this.right,c=this.bottom;return i>B&&(e=-i+B+Q,i=B),c>g&&(I=-c+g+w,c=g),t<1&&(I=2-t,t=1),n<1&&(I=2-n,n=1),{dy:E,edy:I,dx:C,edx:e,y:n,ey:c,x:t,ex:i,w:Q,h:w}},A.prototype.calibrate=function(g){return new A({left:this.left+g.left*this.width,top:this.top+g.top*this.height,right:this.right+g.right*this.width,bottom:this.bottom+g.bottom*this.height}).toSquare().round()},A}(),ve=function(A){LA(g,A);function g(B,Q,w,C,E){return E===void 0&&(E=!1),A.call(this,{left:B,top:Q,right:w,bottom:C},E)||this}return g}(wQ),nD=function(){function A(g,B,Q,w,C){this._imageDims=new cw(C.width,C.height),this._score=g,this._classScore=B,this._className=Q,this._box=new wQ(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 wQ(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),A.prototype.forSize=function(g,B){return new A(this.score,this.classScore,this.className,this.relativeBox,{width:g,height:B})},A}(),mg=function(A){LA(g,A);function g(B,Q,w){return A.call(this,B,B,"",Q,w)||this}return g.prototype.forSize=function(B,Q){var w=A.prototype.forSize.call(this,B,Q),C=w.score,E=w.relativeBox,e=w.imageDims;return new g(C,E,e)},g}(nD);function bR(A,g,B){B===void 0&&(B=!0);var Q=Math.max(0,Math.min(A.right,g.right)-Math.max(A.left,g.left)),w=Math.max(0,Math.min(A.bottom,g.bottom)-Math.max(A.top,g.top)),C=Q*w;return B?C/(A.area+g.area-C):C/Math.min(A.area,g.area)}function SR(A){var g=A.map(function(e){return e.x}),B=A.map(function(e){return e.y}),Q=g.reduce(function(e,I){return I<e?I:e},1/0),w=B.reduce(function(e,I){return I<e?I:e},1/0),C=g.reduce(function(e,I){return e<I?I:e},0),E=B.reduce(function(e,I){return e<I?I:e},0);return new ve(Q,w,C,E)}function _C(A,g,B,Q){Q===void 0&&(Q=!0);for(var w=g.map(function(e,I){return{score:e,boxIndex:I}}).sort(function(e,I){return e.score-I.score}).map(function(e){return e.boxIndex}),C=[],E=function(){var e=w.pop();C.push(e);for(var I=w,t=[],n=0;n<I.length;n++){var i=I[n],c=A[e],Y=A[i];t.push(bR(c,Y,Q))}w=w.filter(function(M,D){return t[D]<=B})};w.length>0;)E();return C}function $C(A,g){return FA(function(){var B=g[0],Q=g[1],w=g[2],C=gQ(ZC(A.shape.slice(0,3),[1]),B),E=gQ(ZC(A.shape.slice(0,3),[1]),Q),e=gQ(ZC(A.shape.slice(0,3),[1]),w),I=zB([C,E,e],3);return SB(A,I)})}function LR(A,g){return g===void 0&&(g=!1),FA(function(){var B=A.shape.slice(1),Q=B[0],w=B[1];if(Q===w)return A;var C=Math.abs(Q-w),E=Math.round(C*(g?.5:1)),e=Q>w?2:1,I=function(Y){var M=A.shape.slice();return M[e]=Y,gQ(M,0)},t=I(E),n=C-t.shape[e],i=g&&n?I(n):null,c=[i,A,t].filter(function(Y){return!!Y}).map(function(Y){return Y.toFloat()});return zB(c,e)})}function En(A){return 1/(1+Math.exp(-A))}var ke=function(A){LA(g,A);function g(B,Q,w,C,E){return E===void 0&&(E=!1),A.call(this,{x:B,y:Q,width:w,height:C},E)||this}return g}(wQ),VR=.5,KR=.43,xR=.45,wC=function(){function A(g,B,Q){Q===void 0&&(Q=new cB(0,0));var w=B.width,C=B.height;this._imgDims=new cw(w,C),this._shift=Q,this._positions=g.map(function(E){return E.mul(new cB(w,C)).add(Q)})}return Object.defineProperty(A.prototype,"shift",{get:function(){return new cB(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 g=this;return this._positions.map(function(B){return B.sub(g._shift).div(new cB(g.imageWidth,g.imageHeight))})},enumerable:!0,configurable:!0}),A.prototype.forSize=function(g,B){return new this.constructor(this.relativePositions,{width:g,height:B})},A.prototype.shiftBy=function(g,B){return new this.constructor(this.relativePositions,this._imgDims,new cB(g,B))},A.prototype.shiftByPoint=function(g){return this.shiftBy(g.x,g.y)},A.prototype.align=function(g,B){if(B===void 0&&(B={}),g){var Q=g instanceof mg?g.box.floor():new wQ(g);return this.shiftBy(Q.x,Q.y).align(null,B)}var w=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},B),C=w.useDlibAlignment,E=w.minBoxPadding;return C?this.alignDlib():this.alignMinBbox(E)},A.prototype.alignDlib=function(){var g=this.getRefPointsForAlignment(),B=g[0],Q=g[1],w=g[2],C=function(i){return w.sub(i).magnitude()},E=(C(B)+C(Q))/2,e=Math.floor(E/xR),I=Cn(g),t=Math.floor(Math.max(0,I.x-VR*e)),n=Math.floor(Math.max(0,I.y-KR*e));return new ke(t,n,Math.min(e,this.imageWidth+t),Math.min(e,this.imageHeight+n))},A.prototype.alignMinBbox=function(g){var B=SR(this.positions);return B.pad(B.width*g,B.height*g)},A.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},A}(),XR=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.getRefPointsForAlignment=function(){var B=this.positions;return[B[0],B[1],Cn([B[3],B[4]])]},g}(wC),iD=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.getJawOutline=function(){return this.positions.slice(0,17)},g.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},g.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},g.prototype.getNose=function(){return this.positions.slice(27,36)},g.prototype.getLeftEye=function(){return this.positions.slice(36,42)},g.prototype.getRightEye=function(){return this.positions.slice(42,48)},g.prototype.getMouth=function(){return this.positions.slice(48,68)},g.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Cn)},g}(wC),cD=function(){function A(g,B){this._label=g,this._distance=B}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(g){return g===void 0&&(g=!0),""+this.label+(g?" ("+ID(this.distance)+")":"")},A}(),YD=function(A){LA(g,A);function g(B,Q){var w=A.call(this,B)||this;return w._label=Q,w}return g.assertIsValidLabeledBox=function(B,Q){if(wQ.assertIsValidBox(B,Q),!Yw(B.label))throw new Error(Q+" - expected property label ("+B.label+") to be a number")},Object.defineProperty(g.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),g}(wQ),Te=function(){function A(g,B){if(typeof g!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(B)||B.some(function(Q){return!(Q instanceof Float32Array)}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=g,this._descriptors=B}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(g){return Array.from(g)})}},A.fromJSON=function(g){var B=g.descriptors.map(function(Q){return new Float32Array(Q)});return new A(g.label,B)},A}();(function(A){LA(g,A);function g(B,Q,w,C){var E=A.call(this,B,Q)||this;return E._score=w,E._classScore=C,E}return g.assertIsValidPredictedBox=function(B,Q){if(YD.assertIsValidLabeledBox(B,Q),!tD(B.score)||!tD(B.classScore))throw new Error(Q+" - expected properties score ("+B.score+") and ("+B.classScore+") to be a number between [0, 1]")},Object.defineProperty(g.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),g})(YD);function je(A){return A.detection instanceof mg}function AE(A,g){var B={detection:g};return Object.assign({},A,B)}function MD(){var A=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")},g=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:g}}function rD(A){var g="";if(!A)try{A=require("fs")}catch(Q){g=Q.toString()}var B=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: "+g)};return{readFile:B}}function DD(){var A=global.Canvas||global.HTMLCanvasElement,g=global.Image||global.HTMLImageElement,B=function(){if(A)return new A;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},Q=function(){if(g)return new g;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=rD();return tg({Canvas:A||function(){function E(){}return E}(),CanvasRenderingContext2D:global.CanvasRenderingContext2D||function(){function E(){}return E}(),Image:g||function(){function E(){}return E}(),ImageData:global.ImageData||function(){function E(){}return E}(),Video:global.HTMLVideoElement||function(){function E(){}return E}(),createCanvasElement:B,createImageElement:Q,fetch:w},C)}function FD(){return typeof window=="object"&&typeof document<"u"&&typeof HTMLImageElement<"u"&&typeof HTMLCanvasElement<"u"&&typeof HTMLVideoElement<"u"&&typeof ImageData<"u"&&typeof CanvasRenderingContext2D<"u"}function aD(){return typeof global=="object"&&typeof require=="function"&&typeof module<"u"&&typeof process<"u"&&!!process.version}var LB;function OR(){if(!LB)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return LB}function en(A){LB=A}function In(){FD()&&en(MD()),aD()&&en(DD())}function ZR(A){if(LB||In(),!LB)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var g=A.Canvas,B=g===void 0?LB.Canvas:g,Q=A.Image,w=Q===void 0?LB.Image:Q;LB.Canvas=B,LB.Image=w,LB.createCanvasElement=A.createCanvasElement||function(){return new B},LB.createImageElement=A.createImageElement||function(){return new w},LB.ImageData=A.ImageData||LB.ImageData,LB.Video=A.Video||LB.Video,LB.fetch=A.fetch||LB.fetch,LB.readFile=A.readFile||LB.readFile}var ng={getEnv:OR,setEnv:en,initialize:In,createBrowserEnv:MD,createFileSystem:rD,createNodejsEnv:DD,monkeyPatch:ZR,isBrowser:FD,isNodejs:aD};In();function on(A){return!ng.isNodejs()&&typeof A=="string"?document.getElementById(A):A}function CQ(A){var g=ng.getEnv(),B=g.Canvas,Q=g.CanvasRenderingContext2D;if(A instanceof Q)return A;var w=on(A);if(!(w instanceof B))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 sD=function(){function A(g){g===void 0&&(g={});var B=g.anchorPosition,Q=g.backgroundColor,w=g.fontColor,C=g.fontSize,E=g.fontStyle,e=g.padding;this.anchorPosition=B||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}(),qR=function(){function A(g,B,Q){Q===void 0&&(Q={}),this.text=typeof g=="string"?[g]:g instanceof A?g.text:g,this.anchor=B,this.options=new sD(Q)}return A.prototype.measureWidth=function(g){var B=this.options.padding;return this.text.map(function(Q){return g.measureText(Q).width}).reduce(function(Q,w){return Q<w?w:Q},0)+2*B},A.prototype.measureHeight=function(){var g=this.options,B=g.fontSize,Q=g.padding;return this.text.length*B+2*Q},A.prototype.getUpperLeft=function(g,B){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(g),e=this.measureHeight(),I=w?this.anchor.x-E:this.anchor.x,t=C?this.anchor.y-e:this.anchor.y;if(B){var n=B.width,i=B.height,c=Math.max(Math.min(I,n-E),0),Y=Math.max(Math.min(t,i-e),0);return{x:c,y:Y}}return{x:I,y:t}},A.prototype.draw=function(g){var B=on(g),Q=CQ(B),w=this.options,C=w.backgroundColor,E=w.fontColor,e=w.fontSize,I=w.fontStyle,t=w.padding;Q.font=e+"px "+I;var n=this.measureWidth(Q),i=this.measureHeight();Q.fillStyle=C;var c=this.getUpperLeft(Q,B);Q.fillRect(c.x,c.y,n,i),Q.fillStyle=E,this.text.forEach(function(Y,M){var D=t+c.x,r=t+c.y+(M+1)*e;Q.fillText(Y,D,r)})},A}(),_R=function(){function A(g){g===void 0&&(g={});var B=g.boxColor,Q=g.lineWidth,w=g.label,C=g.drawLabelOptions;this.boxColor=B||"rgba(0, 0, 255, 1)",this.lineWidth=Q||2,this.label=w;var E={anchorPosition:pQ.BOTTOM_LEFT,backgroundColor:this.boxColor};this.drawLabelOptions=new sD(Object.assign({},E,C))}return A}(),$R=function(){function A(g,B){B===void 0&&(B={}),this.box=new wQ(g),this.options=new _R(B)}return A.prototype.draw=function(g){var B=CQ(g),Q=this.options,w=Q.boxColor,C=Q.lineWidth,E=this.box,e=E.x,I=E.y,t=E.width,n=E.height;B.strokeStyle=w,B.lineWidth=C,B.strokeRect(e,I,t,n);var i=this.options.label;i&&new qR([i],{x:e-C/2,y:I},this.options.drawLabelOptions).draw(g)},A}();function AP(A,g){var B=Array.isArray(g)?g:[g];B.forEach(function(Q){var w=Q instanceof mg?Q.score:je(Q)?Q.detection.score:void 0,C=Q instanceof mg?Q.box:je(Q)?Q.detection.box:new wQ(Q),E=w?""+ID(w):void 0;new $R(C,{label:E}).draw(A)})}function uD(A){var g=ng.getEnv(),B=g.Image,Q=g.Video;return A instanceof B&&A.complete||A instanceof Q&&A.readyState>=3}function BP(A){return new Promise(function(g,B){if(A instanceof ng.getEnv().Canvas||uD(A))return g();function Q(C){C.currentTarget&&(C.currentTarget.removeEventListener("load",Q),C.currentTarget.removeEventListener("error",w),g(C))}function w(C){C.currentTarget&&(C.currentTarget.removeEventListener("load",Q),C.currentTarget.removeEventListener("error",w),B(C))}A.addEventListener("load",Q),A.addEventListener("error",w)})}function tn(A){var g=ng.getEnv(),B=g.Image,Q=g.Video;return A instanceof B?new cw(A.naturalWidth,A.naturalHeight):A instanceof Q?new cw(A.videoWidth,A.videoHeight):new cw(A.width,A.height)}function pe(A){var g=A.width,B=A.height,Q=ng.getEnv().createCanvasElement,w=Q();return w.width=g,w.height=B,w}function ye(A,g){var B=ng.getEnv().ImageData;if(!(A instanceof B)&&!uD(A))throw new Error("createCanvasFromMedia - media has not finished loading yet");var Q=tn(A),w=Q.width,C=Q.height,E=pe({width:w,height:C});return A instanceof B?CQ(E).putImageData(A,0,0):CQ(E).drawImage(A,0,0,w,C),E}function gP(A,g){return JA(this,void 0,void 0,function(){var B,Q,w,C,E,e;return mA(this,function(I){switch(I.label){case 0:return B=ng.getEnv().createCanvasElement(),Q=A.shape.slice(jQ(A)?1:0),w=Q[0],C=Q[1],E=Q[2],e=FA(function(){return A.as3D(w,C,E).toInt()}),[4,Qn.toPixels(e,B)];case 1:return I.sent(),e.dispose(),[2,B]}})})}function UD(A){var g=ng.getEnv(),B=g.Image,Q=g.Canvas,w=g.Video;return A instanceof B||A instanceof Q||A instanceof w}function QP(A,g,B){B===void 0&&(B=!1);var Q=ng.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=tn(A),e=g/Math.max(E.height,E.width),I=e*E.width,t=e*E.height,n=pe({width:g,height:g}),i=A instanceof C?A:ye(A),c=Math.abs(I-t)/2,Y=B&&I<t?c:0,M=B&&t<I?c:0;return CQ(n).drawImage(i,Y,M,I,t),n}var ze=function(){function A(g,B){var Q=this;if(B===void 0&&(B=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(g))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+g);this._treatAsBatchInput=B,this._batchSize=g.length,g.forEach(function(w,C){if(Pe(w)){Q._imageTensors[C]=w,Q._inputDimensions[C]=w.shape;return}if(jQ(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 ng.getEnv().Canvas?w:ye(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 g=this;return qC(this.batchSize,0,1).map(function(B,Q){return g.getReshapedInputDimensions(Q)})},enumerable:!0,configurable:!0}),A.prototype.getInput=function(g){return this.canvases[g]||this.imageTensors[g]},A.prototype.getInputDimensions=function(g){return this._inputDimensions[g]},A.prototype.getInputHeight=function(g){return this._inputDimensions[g][0]},A.prototype.getInputWidth=function(g){return this._inputDimensions[g][1]},A.prototype.getReshapedInputDimensions=function(g){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");var B=this.getInputWidth(g),Q=this.getInputHeight(g);return WR({width:B,height:Q},this.inputSize)},A.prototype.toBatchTensor=function(g,B){var Q=this;return B===void 0&&(B=!0),this._inputSize=g,FA(function(){var w=qC(Q.batchSize,0,1).map(function(E){var e=Q.getInput(E);if(e instanceof HB){var I=jQ(e)?e:e.expandDims();return I=LR(I,B),(I.shape[1]!==g||I.shape[2]!==g)&&(I=yt.resizeBilinear(I,[g,g])),I.as3D(g,g,3)}if(e instanceof ng.getEnv().Canvas)return Qn.fromPixels(QP(e,g,B));throw new Error("toBatchTensor - at batchIdx "+E+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+e)}),C=fg(w.map(function(E){return E.toFloat()})).as4D(Q.batchSize,g,g,3);return C})},A}();function ZB(A){return JA(this,void 0,void 0,function(){var g,B,Q;return mA(this,function(w){switch(w.label){case 0:if(A instanceof ze)return[2,A];if(g=Array.isArray(A)?A:[A],!g.length)throw new Error("toNetInput - empty array passed as input");return B=function(C){return Array.isArray(A)?" at input index "+C+":":""},Q=g.map(on),Q.forEach(function(C,E){if(!UD(C)&&!Pe(C)&&!jQ(C))throw typeof g[E]=="string"?new Error("toNetInput -"+B(E)+" string passed, but could not resolve HTMLElement for element id "+g[E]):new Error("toNetInput -"+B(E)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");if(jQ(C)){var e=C.shape[0];if(e!==1)throw new Error("toNetInput -"+B(E)+" tf.Tensor4D with batchSize "+e+" passed, but not supported in input array")}}),[4,Promise.all(Q.map(function(C){return UD(C)&&BP(C)}))];case 1:return w.sent(),[2,new ze(Q,Array.isArray(A))]}})})}function We(A,g){return JA(this,void 0,void 0,function(){var B,Q,w,C,E,e,I;return mA(this,function(t){switch(t.label){case 0:return B=ng.getEnv().Canvas,Q=A,A instanceof B?[3,5]:[4,ZB(A)];case 1:if(w=t.sent(),w.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return C=w.getInput(0),C instanceof B?(E=C,[3,4]):[3,2];case 2:return[4,gP(C)];case 3:E=t.sent(),t.label=4;case 4:Q=E,t.label=5;case 5:return e=CQ(Q),I=g.map(function(n){return n instanceof mg?n.forSize(Q.width,Q.height).box.floor():n}).map(function(n){return n.clipAtImageBorders(Q.width,Q.height)}),[2,I.map(function(n){var i=n.x,c=n.y,Y=n.width,M=n.height,D=pe({width:Y,height:M});return CQ(D).putImageData(e.getImageData(i,c,Y,M),0,0),D})]}})})}function nn(A,g){return JA(this,void 0,void 0,function(){return mA(this,function(B){if(!Pe(A)&&!jQ(A))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(jQ(A)&&A.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,FA(function(){var Q=A.shape.slice(jQ(A)?1:0),w=Q[0],C=Q[1],E=Q[2],e=g.map(function(t){return t instanceof mg?t.forSize(C,w).box:t}).map(function(t){return t.clipAtImageBorders(C,w)}),I=e.map(function(t){var n=t.x,i=t.y,c=t.width,Y=t.height;return Jr(A.as3D(w,C,E),[i,n,0],[Y,c,E])});return I})]})})}function wP(A,g){return JA(this,void 0,void 0,function(){var B,Q;return mA(this,function(w){switch(w.label){case 0:return B=ng.getEnv().fetch,[4,B(A,g)];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 CP(A){return JA(this,void 0,void 0,function(){return mA(this,function(g){switch(g.label){case 0:return[4,wP(A)];case 1:return[2,g.sent().json()]}})})}function lD(A,g){var B=g+"-weights_manifest.json";if(!A)return{modelBaseUri:"",manifestUri:B};if(A==="/")return{modelBaseUri:"/",manifestUri:"/"+B};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]:B,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 EP(A,g){return JA(this,void 0,void 0,function(){var B,Q,w,C;return mA(this,function(E){switch(E.label){case 0:return B=lD(A,g),Q=B.manifestUri,w=B.modelBaseUri,[4,CP(Q)];case 1:return C=E.sent(),[2,CD.loadWeights(C,w)]}})})}function eP(A,g,B){B===void 0&&(B=!1);var Q=B?tn(g):g,w=Q.width,C=Q.height;return A.width=w,A.height=C,{width:w,height:C}}var UQ=function(){function A(g){this._name=g,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(g){var B=this.traversePropertyPath(g),Q=B.obj,w=B.objProp;return Q[w]},A.prototype.reassignParamFromPath=function(g,B){var Q=this.traversePropertyPath(g),w=Q.obj,C=Q.objProp;w[C].dispose(),w[C]=B},A.prototype.getParamList=function(){var g=this;return this._paramMappings.map(function(B){var Q=B.paramPath;return{path:Q,tensor:g.getParamFromPath(Q)}})},A.prototype.getTrainableParams=function(){return this.getParamList().filter(function(g){return g.tensor instanceof bw})},A.prototype.getFrozenParams=function(){return this.getParamList().filter(function(g){return!(g.tensor instanceof bw)})},A.prototype.variable=function(){var g=this;this.getFrozenParams().forEach(function(B){var Q=B.path,w=B.tensor;g.reassignParamFromPath(Q,w.variable())})},A.prototype.freeze=function(){var g=this;this.getTrainableParams().forEach(function(B){var Q=B.path,w=B.tensor,C=wg(w.dataSync());w.dispose(),g.reassignParamFromPath(Q,C)})},A.prototype.dispose=function(g){g===void 0&&(g=!0),this.getParamList().forEach(function(B){if(g&&B.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+B.path);B.tensor.dispose()}),this._params=void 0},A.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(g){var B=g.tensor;return Array.from(B.dataSync())}).reduce(function(g,B){return g.concat(B)}))},A.prototype.load=function(g){return JA(this,void 0,void 0,function(){return mA(this,function(B){switch(B.label){case 0:return g instanceof Float32Array?(this.extractWeights(g),[2]):[4,this.loadFromUri(g)];case 1:return B.sent(),[2]}})})},A.prototype.loadFromUri=function(g){return JA(this,void 0,void 0,function(){var B;return mA(this,function(Q){switch(Q.label){case 0:if(g&&typeof g!="string")throw new Error(this._name+".loadFromUri - expected model uri");return[4,EP(g,this.getDefaultModelName())];case 1:return B=Q.sent(),this.loadFromWeightMap(B),[2]}})})},A.prototype.loadFromDisk=function(g){return JA(this,void 0,void 0,function(){var B,Q,w,C,E,e,I,t,n,i;return mA(this,function(c){switch(c.label){case 0:if(g&&typeof g!="string")throw new Error(this._name+".loadFromDisk - expected model file path");return B=ng.getEnv().readFile,Q=lD(g,this.getDefaultModelName()),w=Q.manifestUri,C=Q.modelBaseUri,E=function(Y){return Promise.all(Y.map(function(M){return B(M).then(function(D){return D.buffer})}))},e=CD.weightsLoaderFactory(E),n=(t=JSON).parse,[4,B(w)];case 1:return I=n.apply(t,[c.sent().toString()]),[4,e(I,C)];case 2:return i=c.sent(),this.loadFromWeightMap(i),[2]}})})},A.prototype.loadFromWeightMap=function(g){var B=this.extractParamsFromWeigthMap(g),Q=B.paramMappings,w=B.params;this._paramMappings=Q,this._params=w},A.prototype.extractWeights=function(g){var B=this.extractParams(g),Q=B.paramMappings,w=B.params;this._paramMappings=Q,this._params=w},A.prototype.traversePropertyPath=function(g){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var B=g.split("/").reduce(function(C,E){if(!C.nextObj.hasOwnProperty(E))throw new Error("traversePropertyPath - object does not have property "+E+", for path "+g);return{obj:C.nextObj,objProp:E,nextObj:C.nextObj[E]}},{nextObj:this.params}),Q=B.obj,w=B.objProp;if(!Q||!w||!(Q[w]instanceof HB))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+g);return{obj:Q,objProp:w}},A}();function Ng(A,g,B){return FA(function(){var Q=vt(A,g.depthwise_filter,g.pointwise_filter,B,"same");return Q=BB(Q,g.bias),Q})}function cn(A,g,B){return B===void 0&&(B=!1),FA(function(){var Q=JB(B?BB(jg(A,g.conv0.filters,[2,2],"same"),g.conv0.bias):Ng(A,g.conv0,[2,2])),w=Ng(Q,g.conv1,[1,1]),C=JB(BB(Q,w)),E=Ng(C,g.conv2,[1,1]);return JB(BB(Q,BB(w,E)))})}function be(A,g,B,Q){return B===void 0&&(B=!1),Q===void 0&&(Q=!0),FA(function(){var w=JB(B?BB(jg(A,g.conv0.filters,Q?[2,2]:[1,1],"same"),g.conv0.bias):Ng(A,g.conv0,Q?[2,2]:[1,1])),C=Ng(w,g.conv1,[1,1]),E=JB(BB(w,C)),e=Ng(E,g.conv2,[1,1]),I=JB(BB(w,BB(C,e))),t=Ng(I,g.conv3,[1,1]);return JB(BB(w,BB(C,BB(e,t))))})}function Vg(A,g,B,Q){return B===void 0&&(B="same"),Q===void 0&&(Q=!1),FA(function(){var w=BB(jg(A,g.filters,[1,1],B),g.bias);return Q?JB(w):w})}function lQ(A,g){Object.keys(A).forEach(function(B){g.some(function(Q){return Q.originalPath===B})||A[B].dispose()})}function Se(A,g){return function(B,Q,w,C){var E=ag(A(B*Q*w*w),[w,w,B,Q]),e=pB(A(Q));return g.push({paramPath:C+"/filters"},{paramPath:C+"/bias"}),{filters:E,bias:e}}}function Yn(A,g){return function(B,Q,w){var C=RQ(A(B*Q),[B,Q]),E=pB(A(Q));return g.push({paramPath:w+"/weights"},{paramPath:w+"/bias"}),{weights:C,bias:E}}}var hD=function(){function A(g,B,Q){this.depthwise_filter=g,this.pointwise_filter=B,this.bias=Q}return A}();function Mn(A,g){return function(B,Q,w){var C=ag(A(9*B),[3,3,B,1]),E=ag(A(B*Q),[1,1,B,Q]),e=pB(A(Q));return g.push({paramPath:w+"/depthwise_filter"},{paramPath:w+"/pointwise_filter"},{paramPath:w+"/bias"}),new hD(C,E,e)}}function rn(A){return function(g){var B=A(g+"/depthwise_filter",4),Q=A(g+"/pointwise_filter",4),w=A(g+"/bias",1);return new hD(B,Q,w)}}function yQ(A,g){return function(B,Q,w){var C=A[B];if(!Re(C,Q))throw new Error("expected weightMap["+B+"] to be a Tensor"+Q+"D, instead have "+C);return g.push({originalPath:B,paramPath:w||B}),C}}function hQ(A){var g=A;function B(w){var C=g.slice(0,w);return g=g.slice(w),C}function Q(){return g}return{extractWeights:B,getRemainingWeights:Q}}function GD(A,g){var B=Se(A,g),Q=Mn(A,g);function w(E,e,I,t){t===void 0&&(t=!1);var n=t?B(E,e,3,I+"/conv0"):Q(E,e,I+"/conv0"),i=Q(e,e,I+"/conv1"),c=Q(e,e,I+"/conv2");return{conv0:n,conv1:i,conv2:c}}function C(E,e,I,t){t===void 0&&(t=!1);var n=w(E,e,I,t),i=n.conv0,c=n.conv1,Y=n.conv2,M=Q(e,e,I+"/conv3");return{conv0:i,conv1:c,conv2:Y,conv3:M}}return{extractDenseBlock3Params:w,extractDenseBlock4Params:C}}function IP(A){var g=[],B=hQ(A),Q=B.extractWeights,w=B.getRemainingWeights,C=GD(Q,g).extractDenseBlock4Params,E=C(3,32,"dense0",!0),e=C(32,64,"dense1"),I=C(64,128,"dense2"),t=C(128,256,"dense3");if(w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{paramMappings:g,params:{dense0:E,dense1:e,dense2:I,dense3:t}}}function dD(A){return function(g){var B=A(g+"/filters",4),Q=A(g+"/bias",1);return{filters:B,bias:Q}}}function HD(A,g){var B=yQ(A,g),Q=dD(B),w=rn(B);function C(e,I){I===void 0&&(I=!1);var t=I?Q(e+"/conv0"):w(e+"/conv0"),n=w(e+"/conv1"),i=w(e+"/conv2");return{conv0:t,conv1:n,conv2:i}}function E(e,I){I===void 0&&(I=!1);var t=I?Q(e+"/conv0"):w(e+"/conv0"),n=w(e+"/conv1"),i=w(e+"/conv2"),c=w(e+"/conv3");return{conv0:t,conv1:n,conv2:i,conv3:c}}return{extractDenseBlock3Params:C,extractDenseBlock4Params:E}}function oP(A){var g=[],B=HD(A,g).extractDenseBlock4Params,Q={dense0:B("dense0",!0),dense1:B("dense1"),dense2:B("dense2"),dense3:B("dense3")};return lQ(A,g),{params:Q,paramMappings:g}}var fD=function(A){LA(g,A);function g(){return A.call(this,"FaceFeatureExtractor")||this}return g.prototype.forwardInput=function(B){var Q=this.params;if(!Q)throw new Error("FaceFeatureExtractor - load model before inference");return FA(function(){var w=B.toBatchTensor(112,!0),C=[122.782,117.001,104.298],E=$C(w,C).div(cA(255)),e=be(E,Q.dense0,!0);return e=be(e,Q.dense1),e=be(e,Q.dense2),e=be(e,Q.dense3),e=XC(e,[7,7],[2,2],"valid"),e})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},g.prototype.extractParamsFromWeigthMap=function(B){return oP(B)},g.prototype.extractParams=function(B){return IP(B)},g}(UQ);function EQ(A,g){return FA(function(){return BB(de(A,g.weights),g.bias)})}function tP(A,g,B){var Q=[],w=hQ(A),C=w.extractWeights,E=w.getRemainingWeights,e=Yn(C,Q),I=e(g,B,"fc");if(E().length!==0)throw new Error("weights remaing after extract: "+E().length);return{paramMappings:Q,params:{fc:I}}}function nP(A){var g=[],B=yQ(A,g);function Q(C){var E=B(C+"/weights",2),e=B(C+"/bias",1);return{weights:E,bias:e}}var w={fc:Q("fc")};return lQ(A,g),{params:w,paramMappings:g}}function JD(A){var g={},B={};return Object.keys(A).forEach(function(Q){var w=Q.startsWith("fc")?B:g;w[Q]=A[Q]}),{featureExtractorMap:g,classifierMap:B}}var mD=function(A){LA(g,A);function g(B,Q){var w=A.call(this,B)||this;return w._faceFeatureExtractor=Q,w}return Object.defineProperty(g.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),g.prototype.runNet=function(B){var Q=this,w=this.params;if(!w)throw new Error(this._name+" - load model before inference");return FA(function(){var C=B instanceof ze?Q.faceFeatureExtractor.forwardInput(B):B;return EQ(C.as2D(C.shape[0],-1),w.fc)})},g.prototype.dispose=function(B){B===void 0&&(B=!0),this.faceFeatureExtractor.dispose(B),A.prototype.dispose.call(this,B)},g.prototype.loadClassifierParams=function(B){var Q=this.extractClassifierParams(B),w=Q.params,C=Q.paramMappings;this._params=w,this._paramMappings=C},g.prototype.extractClassifierParams=function(B){return tP(B,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},g.prototype.extractParamsFromWeigthMap=function(B){var Q=JD(B),w=Q.featureExtractorMap,C=Q.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(w),nP(C)},g.prototype.extractParams=function(B){var Q=this.getClassifierChannelsIn(),w=this.getClassifierChannelsOut(),C=w*Q+w,E=B.slice(0,B.length-C),e=B.slice(B.length-C);return this.faceFeatureExtractor.extractWeights(E),this.extractClassifierParams(e)},g}(UQ),ND=["neutral","happy","sad","angry","fearful","disgusted","surprised"],iP=function(){function A(g){var B=this;if(g.length!==7)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+g.length);ND.forEach(function(Q,w){B[Q]=g[w]})}return A.prototype.asSortedArray=function(){var g=this;return ND.map(function(B){return{expression:B,probability:g[B]}}).sort(function(B,Q){return Q.probability-B.probability})},A}(),cP=function(A){LA(g,A);function g(B){return B===void 0&&(B=new fD),A.call(this,"FaceExpressionNet",B)||this}return g.prototype.forwardInput=function(B){var Q=this;return FA(function(){return FQ(Q.runNet(B))})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.predictExpressions=function(B){return JA(this,void 0,void 0,function(){var Q,w,C,E,e=this;return mA(this,function(I){switch(I.label){case 0:return[4,ZB(B)];case 1:return Q=I.sent(),[4,this.forwardInput(Q)];case 2:return w=I.sent(),[4,Promise.all(WB(w).map(function(t){return JA(e,void 0,void 0,function(){var n;return mA(this,function(i){switch(i.label){case 0:return[4,t.data()];case 1:return n=i.sent(),t.dispose(),[2,n]}})})}))];case 3:return C=I.sent(),w.dispose(),E=C.map(function(t){return new iP(t)}),[2,Q.isBatchInput?E:E[0]]}})})},g.prototype.getDefaultModelName=function(){return"face_expression_model"},g.prototype.getClassifierChannelsIn=function(){return 256},g.prototype.getClassifierChannelsOut=function(){return 7},g}(mD);function RD(A,g){var B={expressions:g};return Object.assign({},A,B)}function Dn(A){return je(A)&&A.landmarks instanceof wC&&A.unshiftedLandmarks instanceof wC&&A.alignedRect instanceof mg}function Le(A,g){var B=A.detection.box,Q=g.shiftBy(B.x,B.y),w=Q.align(),C=A.detection.imageDims,E=new mg(A.detection.score,w.rescale(C.reverse()),C),e={landmarks:Q,unshiftedLandmarks:g,alignedRect:E};return Object.assign({},A,e)}var YP=function(){function A(g){g===void 0&&(g={});var B=g.drawLines,Q=B===void 0?!0:B,w=g.drawPoints,C=w===void 0?!0:w,E=g.lineWidth,e=g.lineColor,I=g.pointSize,t=g.pointColor;this.drawLines=Q,this.drawPoints=C,this.lineWidth=E||1,this.pointSize=I||2,this.lineColor=e||"rgba(0, 255, 255, 1)",this.pointColor=t||"rgba(255, 0, 255, 1)"}return A}(),MP=function(){function A(g,B){B===void 0&&(B={}),this.faceLandmarks=g,this.options=new YP(B)}return A.prototype.draw=function(g){var B=CQ(g),Q=this.options,w=Q.drawLines,C=Q.drawPoints,E=Q.lineWidth,e=Q.lineColor,I=Q.pointSize,t=Q.pointColor;if(w&&this.faceLandmarks instanceof iD&&(B.strokeStyle=e,B.lineWidth=E,iw(B,this.faceLandmarks.getJawOutline()),iw(B,this.faceLandmarks.getLeftEyeBrow()),iw(B,this.faceLandmarks.getRightEyeBrow()),iw(B,this.faceLandmarks.getNose()),iw(B,this.faceLandmarks.getLeftEye(),!0),iw(B,this.faceLandmarks.getRightEye(),!0),iw(B,this.faceLandmarks.getMouth(),!0)),C){B.strokeStyle=t,B.fillStyle=t;var n=function(i){B.beginPath(),B.arc(i.x,i.y,I,0,2*Math.PI),B.fill()};this.faceLandmarks.positions.forEach(n)}},A}();function rP(A,g){var B=Array.isArray(g)?g:[g];B.forEach(function(Q){var w=Q instanceof wC?Q:Dn(Q)?Q.landmarks:void 0;if(!w)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>> or array thereof");new MP(w).draw(A)})}function DP(A,g){var B=Se(A,g),Q=Mn(A,g);function w(E,e,I){var t=Q(E,e,I+"/separable_conv0"),n=Q(e,e,I+"/separable_conv1"),i=B(E,e,1,I+"/expansion_conv");return{separable_conv0:t,separable_conv1:n,expansion_conv:i}}function C(E,e){var I=Q(E,E,e+"/separable_conv0"),t=Q(E,E,e+"/separable_conv1"),n=Q(E,E,e+"/separable_conv2");return{separable_conv0:I,separable_conv1:t,separable_conv2:n}}return{extractConvParams:B,extractSeparableConvParams:Q,extractReductionBlockParams:w,extractMainBlockParams:C}}function FP(A,g){var B=[],Q=hQ(A),w=Q.extractWeights,C=Q.getRemainingWeights,E=DP(w,B),e=E.extractConvParams,I=E.extractSeparableConvParams,t=E.extractReductionBlockParams,n=E.extractMainBlockParams,i=e(3,32,3,"entry_flow/conv_in"),c=t(32,64,"entry_flow/reduction_block_0"),Y=t(64,128,"entry_flow/reduction_block_1"),M={conv_in:i,reduction_block_0:c,reduction_block_1:Y},D={};qC(g,0,1).forEach(function(u){D["main_block_"+u]=n(128,"middle_flow/main_block_"+u)});var r=t(128,256,"exit_flow/reduction_block"),a=I(256,512,"exit_flow/separable_conv"),s={reduction_block:r,separable_conv:a};if(C().length!==0)throw new Error("weights remaing after extract: "+C().length);return{paramMappings:B,params:{entry_flow:M,middle_flow:D,exit_flow:s}}}function aP(A,g){var B=yQ(A,g),Q=dD(B),w=rn(B);function C(e){var I=w(e+"/separable_conv0"),t=w(e+"/separable_conv1"),n=Q(e+"/expansion_conv");return{separable_conv0:I,separable_conv1:t,expansion_conv:n}}function E(e){var I=w(e+"/separable_conv0"),t=w(e+"/separable_conv1"),n=w(e+"/separable_conv2");return{separable_conv0:I,separable_conv1:t,separable_conv2:n}}return{extractConvParams:Q,extractSeparableConvParams:w,extractReductionBlockParams:C,extractMainBlockParams:E}}function sP(A,g){var B=[],Q=aP(A,B),w=Q.extractConvParams,C=Q.extractSeparableConvParams,E=Q.extractReductionBlockParams,e=Q.extractMainBlockParams,I=w("entry_flow/conv_in"),t=E("entry_flow/reduction_block_0"),n=E("entry_flow/reduction_block_1"),i={conv_in:I,reduction_block_0:t,reduction_block_1:n},c={};qC(g,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 lQ(A,B),{params:{entry_flow:i,middle_flow:c,exit_flow:D},paramMappings:B}}function PD(A,g,B){return BB(jg(A,g.filters,B,"same"),g.bias)}function Fn(A,g,B){B===void 0&&(B=!0);var Q=B?JB(A):A;return Q=Ng(Q,g.separable_conv0,[1,1]),Q=Ng(JB(Q),g.separable_conv1,[1,1]),Q=OB(Q,[3,3],[2,2],"same"),Q=BB(Q,PD(A,g.expansion_conv,[2,2])),Q}function uP(A,g){var B=Ng(JB(A),g.separable_conv0,[1,1]);return B=Ng(JB(B),g.separable_conv1,[1,1]),B=Ng(JB(B),g.separable_conv2,[1,1]),B=BB(B,A),B}var UP=function(A){LA(g,A);function g(B){var Q=A.call(this,"TinyXception")||this;return Q._numMainBlocks=B,Q}return g.prototype.forwardInput=function(B){var Q=this,w=this.params;if(!w)throw new Error("TinyXception - load model before inference");return FA(function(){var C=B.toBatchTensor(112,!0),E=[122.782,117.001,104.298],e=$C(C,E).div(cA(256)),I=JB(PD(e,w.entry_flow.conv_in,[2,2]));return I=Fn(I,w.entry_flow.reduction_block_0,!1),I=Fn(I,w.entry_flow.reduction_block_1),qC(Q._numMainBlocks,0,1).forEach(function(t){I=uP(I,w.middle_flow["main_block_"+t])}),I=Fn(I,w.exit_flow.reduction_block),I=JB(Ng(I,w.exit_flow.separable_conv,[1,1])),I})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.getDefaultModelName=function(){return"tiny_xception_model"},g.prototype.extractParamsFromWeigthMap=function(B){return sP(B,this._numMainBlocks)},g.prototype.extractParams=function(B){return FP(B,this._numMainBlocks)},g}(UQ);function lP(A){var g=[],B=hQ(A),Q=B.extractWeights,w=B.getRemainingWeights,C=Yn(Q,g),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:g,params:{fc:{age:E,gender:e}}}}function hP(A){var g=[],B=yQ(A,g);function Q(C){var E=B(C+"/weights",2),e=B(C+"/bias",1);return{weights:E,bias:e}}var w={fc:{age:Q("fc/age"),gender:Q("fc/gender")}};return lQ(A,g),{params:w,paramMappings:g}}var Ve;(function(A){A.FEMALE="female",A.MALE="male"})(Ve||(Ve={}));var GP=function(A){LA(g,A);function g(B){B===void 0&&(B=new UP(2));var Q=A.call(this,"AgeGenderNet")||this;return Q._faceFeatureExtractor=B,Q}return Object.defineProperty(g.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),g.prototype.runNet=function(B){var Q=this,w=this.params;if(!w)throw new Error(this._name+" - load model before inference");return FA(function(){var C=B instanceof ze?Q.faceFeatureExtractor.forwardInput(B):B,E=XC(C,[7,7],[2,2],"valid").as2D(C.shape[0],-1),e=EQ(E,w.fc.age).as1D(),I=EQ(E,w.fc.gender);return{age:e,gender:I}})},g.prototype.forwardInput=function(B){var Q=this;return FA(function(){var w=Q.runNet(B),C=w.age,E=w.gender;return{age:C,gender:FQ(E)}})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.predictAgeAndGender=function(B){return JA(this,void 0,void 0,function(){var Q,w,C,E,e,I,t=this;return mA(this,function(n){switch(n.label){case 0:return[4,ZB(B)];case 1:return Q=n.sent(),[4,this.forwardInput(Q)];case 2:return w=n.sent(),C=WB(w.age),E=WB(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(t,void 0,void 0,function(){var M,D,r,a,s;return mA(this,function(u){switch(u.label){case 0:return[4,c.data()];case 1:return M=u.sent()[0],[4,Y.data()];case 2:return D=u.sent()[0],r=D>.5,a=r?Ve.MALE:Ve.FEMALE,s=r?D:1-D,c.dispose(),Y.dispose(),[2,{age:M,gender:a,genderProbability:s}]}})})}))];case 3:return I=n.sent(),w.age.dispose(),w.gender.dispose(),[2,Q.isBatchInput?I:I[0]]}})})},g.prototype.getDefaultModelName=function(){return"age_gender_model"},g.prototype.dispose=function(B){B===void 0&&(B=!0),this.faceFeatureExtractor.dispose(B),A.prototype.dispose.call(this,B)},g.prototype.loadClassifierParams=function(B){var Q=this.extractClassifierParams(B),w=Q.params,C=Q.paramMappings;this._params=w,this._paramMappings=C},g.prototype.extractClassifierParams=function(B){return lP(B)},g.prototype.extractParamsFromWeigthMap=function(B){var Q=JD(B),w=Q.featureExtractorMap,C=Q.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(w),hP(C)},g.prototype.extractParams=function(B){var Q=1539,w=B.slice(0,B.length-Q),C=B.slice(B.length-Q);return this.faceFeatureExtractor.extractWeights(w),this.extractClassifierParams(C)},g}(UQ),vD=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.postProcess=function(B,Q,w){var C=w.map(function(e){var I=e.width,t=e.height,n=Q/Math.max(t,I);return{width:I*n,height:t*n}}),E=C.length;return FA(function(){var e=function(c,Y){return fg([gQ([68],c),gQ([68],Y)],1).as2D(1,136).as1D()},I=function(c,Y){var M=C[c],D=M.width,r=M.height;return Y(D,r)?Math.abs(D-r)/2:0},t=function(c){return I(c,function(Y,M){return Y<M})},n=function(c){return I(c,function(Y,M){return M<Y})},i=B.mul(gQ([E,136],Q)).sub(fg(Array.from(Array(E),function(c,Y){return e(t(Y),n(Y))}))).div(fg(Array.from(Array(E),function(c,Y){return e(C[Y].width,C[Y].height)})));return i})},g.prototype.forwardInput=function(B){var Q=this;return FA(function(){var w=Q.runNet(B);return Q.postProcess(w,B.inputSize,B.inputDimensions.map(function(C){var E=C[0],e=C[1];return{height:E,width:e}}))})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.detectLandmarks=function(B){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,ZB(B)];case 1:return Q=e.sent(),w=FA(function(){return WB(E.forwardInput(Q))}),[4,Promise.all(w.map(function(I,t){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,I.data()];case 1:return n=c.apply(i,[D.sent()]),Y=n.filter(function(r,a){return eD(a)}),M=n.filter(function(r,a){return!eD(a)}),[2,new iD(Array(68).fill(0).map(function(r,a){return new cB(Y[a],M[a])}),{height:Q.getInputHeight(t),width:Q.getInputWidth(t)})]}})})}))];case 2:return C=e.sent(),w.forEach(function(I){return I.dispose()}),[2,Q.isBatchInput?C:C[0]]}})})},g.prototype.getClassifierChannelsOut=function(){return 136},g}(mD),kD=function(A){LA(g,A);function g(B){return B===void 0&&(B=new fD),A.call(this,"FaceLandmark68Net",B)||this}return g.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},g.prototype.getClassifierChannelsIn=function(){return 256},g}(vD);function dP(A){var g=[],B=HD(A,g).extractDenseBlock3Params,Q={dense0:B("dense0",!0),dense1:B("dense1"),dense2:B("dense2")};return lQ(A,g),{params:Q,paramMappings:g}}function HP(A){var g=[],B=hQ(A),Q=B.extractWeights,w=B.getRemainingWeights,C=GD(Q,g).extractDenseBlock3Params,E=C(3,32,"dense0",!0),e=C(32,64,"dense1"),I=C(64,128,"dense2");if(w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{paramMappings:g,params:{dense0:E,dense1:e,dense2:I}}}var fP=function(A){LA(g,A);function g(){return A.call(this,"TinyFaceFeatureExtractor")||this}return g.prototype.forwardInput=function(B){var Q=this.params;if(!Q)throw new Error("TinyFaceFeatureExtractor - load model before inference");return FA(function(){var w=B.toBatchTensor(112,!0),C=[122.782,117.001,104.298],E=$C(w,C).div(cA(255)),e=cn(E,Q.dense0,!0);return e=cn(e,Q.dense1),e=cn(e,Q.dense2),e=XC(e,[14,14],[2,2],"valid"),e})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},g.prototype.extractParamsFromWeigthMap=function(B){return dP(B)},g.prototype.extractParams=function(B){return HP(B)},g}(UQ),JP=function(A){LA(g,A);function g(B){return B===void 0&&(B=new fP),A.call(this,"FaceLandmark68TinyNet",B)||this}return g.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},g.prototype.getClassifierChannelsIn=function(){return 128},g}(vD);(function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g})(kD);function mP(A,g){return BB(Ig(A,g.weights),g.biases)}function an(A,g,B,Q,w){w===void 0&&(w="same");var C=g.conv,E=C.filters,e=C.bias,I=jg(A,E,B,w);return I=BB(I,e),I=mP(I,g.scale),Q?JB(I):I}function NP(A,g){return an(A,g,[1,1],!0)}function TD(A,g){return an(A,g,[1,1],!1)}function jD(A,g){return an(A,g,[2,2],!0,"valid")}function RP(A,g){function B(e,I,t){var n=A(e),i=n.length/(I*t*t);if(zR(i))throw new Error("depth has to be an integer: "+i+", weights.length: "+n.length+", numFilters: "+I+", filterSize: "+t);return FA(function(){return vQ(ag(n,[I,i,t,t]),[2,3,1,0])})}function Q(e,I,t,n){var i=B(e,I,t),c=pB(A(I));return g.push({paramPath:n+"/filters"},{paramPath:n+"/bias"}),{filters:i,bias:c}}function w(e,I){var t=pB(A(e)),n=pB(A(e));return g.push({paramPath:I+"/weights"},{paramPath:I+"/biases"}),{weights:t,biases:n}}function C(e,I,t,n){var i=Q(e,I,t,n+"/conv"),c=w(I,n+"/scale");return{conv:i,scale:c}}function E(e,I,t,n,i){i===void 0&&(i=!1);var c=C((i?.5:1)*e,I,t,n+"/conv1"),Y=C(e,I,t,n+"/conv2");return{conv1:c,conv2:Y}}return{extractConvLayerParams:C,extractResidualLayerParams:E}}function PP(A){var g=hQ(A),B=g.extractWeights,Q=g.getRemainingWeights,w=[],C=RP(B,w),E=C.extractConvLayerParams,e=C.extractResidualLayerParams,I=E(4704,32,7,"conv32_down"),t=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),a=e(147456,128,3,"conv128_1"),s=e(147456,128,3,"conv128_2"),u=e(589824,256,3,"conv256_down",!0),F=e(589824,256,3,"conv256_1"),U=e(589824,256,3,"conv256_2"),l=e(589824,256,3,"conv256_down_out"),d=FA(function(){return vQ(RQ(B(256*128),[128,256]),[1,0])});if(w.push({paramPath:"fc"}),Q().length!==0)throw new Error("weights remaing after extract: "+Q().length);var H={conv32_down:I,conv32_1:t,conv32_2:n,conv32_3:i,conv64_down:c,conv64_1:Y,conv64_2:M,conv64_3:D,conv128_down:r,conv128_1:a,conv128_2:s,conv256_down:u,conv256_1:F,conv256_2:U,conv256_down_out:l,fc:d};return{params:H,paramMappings:w}}function vP(A,g){var B=yQ(A,g);function Q(E){var e=B(E+"/scale/weights",1),I=B(E+"/scale/biases",1);return{weights:e,biases:I}}function w(E){var e=B(E+"/conv/filters",4),I=B(E+"/conv/bias",1),t=Q(E);return{conv:{filters:e,bias:I},scale:t}}function C(E){return{conv1:w(E+"/conv1"),conv2:w(E+"/conv2")}}return{extractConvLayerParams:w,extractResidualLayerParams:C}}function kP(A){var g=[],B=vP(A,g),Q=B.extractConvLayerParams,w=B.extractResidualLayerParams,C=Q("conv32_down"),E=w("conv32_1"),e=w("conv32_2"),I=w("conv32_3"),t=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"),a=w("conv256_1"),s=w("conv256_2"),u=w("conv256_down_out"),F=A.fc;if(g.push({originalPath:"fc",paramPath:"fc"}),!yR(F))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+F);var U={conv32_down:C,conv32_1:E,conv32_2:e,conv32_3:I,conv64_down:t,conv64_1:n,conv64_2:i,conv64_3:c,conv128_down:Y,conv128_1:M,conv128_2:D,conv256_down:r,conv256_1:a,conv256_2:s,conv256_down_out:u,fc:F};return lQ(A,g),{params:U,paramMappings:g}}function eQ(A,g){var B=NP(A,g.conv1);return B=TD(B,g.conv2),B=BB(B,A),B=JB(B),B}function Ke(A,g){var B=jD(A,g.conv1);B=TD(B,g.conv2);var Q=XC(A,2,2,"valid"),w=GB(Q.shape),C=Q.shape[3]!==B.shape[3],E=Q.shape[1]!==B.shape[1]||Q.shape[2]!==B.shape[2];if(E){var e=ZC(B.shape);e[1]=1;var I=GB(e);B=zB([B,I],1);var t=ZC(B.shape);t[2]=1;var n=GB(t);B=zB([B,n],2)}return Q=C?zB([Q,w],3):Q,B=BB(Q,B),B=JB(B),B}var TP=function(A){LA(g,A);function g(){return A.call(this,"FaceRecognitionNet")||this}return g.prototype.forwardInput=function(B){var Q=this.params;if(!Q)throw new Error("FaceRecognitionNet - load model before inference");return FA(function(){var w=B.toBatchTensor(150,!0).toFloat(),C=[122.782,117.001,104.298],E=$C(w,C).div(cA(256)),e=jD(E,Q.conv32_down);e=OB(e,3,2,"valid"),e=eQ(e,Q.conv32_1),e=eQ(e,Q.conv32_2),e=eQ(e,Q.conv32_3),e=Ke(e,Q.conv64_down),e=eQ(e,Q.conv64_1),e=eQ(e,Q.conv64_2),e=eQ(e,Q.conv64_3),e=Ke(e,Q.conv128_down),e=eQ(e,Q.conv128_1),e=eQ(e,Q.conv128_2),e=Ke(e,Q.conv256_down),e=eQ(e,Q.conv256_1),e=eQ(e,Q.conv256_2),e=Ke(e,Q.conv256_down_out);var I=e.mean([1,2]),t=de(I,Q.fc);return t})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.computeFaceDescriptor=function(B){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,ZB(B)];case 1:return Q=e.sent(),w=FA(function(){return WB(E.forwardInput(Q))}),[4,Promise.all(w.map(function(I){return I.data()}))];case 2:return C=e.sent(),w.forEach(function(I){return I.dispose()}),[2,Q.isBatchInput?C:C[0]]}})})},g.prototype.getDefaultModelName=function(){return"face_recognition_model"},g.prototype.extractParamsFromWeigthMap=function(B){return kP(B)},g.prototype.extractParams=function(B){return PP(B)},g}(UQ);function pD(A,g){var B={descriptor:g};return Object.assign({},A,B)}function yD(A,g){var B={age:g};return Object.assign({},A,B)}function zD(A,g,B){var Q={gender:g,genderProbability:B};return Object.assign({},A,Q)}var WD=function(){function A(g){var B=g===void 0?{}:g,Q=B.minFaceSize,w=B.scaleFactor,C=B.maxNumScales,E=B.scoreThresholds,e=B.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(I){return typeof I!="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(I){return typeof I!="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 jP(A,g){function B(I,t){var n=ag(A(9*I),[3,3,I,1]),i=pB(A(I)),c=pB(A(I)),Y=pB(A(I)),M=pB(A(I));return g.push({paramPath:t+"/filters"},{paramPath:t+"/batch_norm_scale"},{paramPath:t+"/batch_norm_offset"},{paramPath:t+"/batch_norm_mean"},{paramPath:t+"/batch_norm_variance"}),{filters:n,batch_norm_scale:i,batch_norm_offset:c,batch_norm_mean:Y,batch_norm_variance:M}}function Q(I,t,n,i,c){var Y=ag(A(I*t*n*n),[n,n,I,t]),M=pB(A(t));return g.push({paramPath:i+"/filters"},{paramPath:i+"/"+(c?"batch_norm_offset":"bias")}),{filters:Y,bias:M}}function w(I,t,n,i){var c=Q(I,t,n,i,!0),Y=c.filters,M=c.bias;return{filters:Y,batch_norm_offset:M}}function C(I,t,n){var i=B(I,n+"/depthwise_conv"),c=w(I,t,1,n+"/pointwise_conv");return{depthwise_conv:i,pointwise_conv:c}}function E(){var I=w(3,32,3,"mobilenetv1/conv_0"),t=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"),a=C(512,512,"mobilenetv1/conv_9"),s=C(512,512,"mobilenetv1/conv_10"),u=C(512,512,"mobilenetv1/conv_11"),F=C(512,1024,"mobilenetv1/conv_12"),U=C(1024,1024,"mobilenetv1/conv_13");return{conv_0:I,conv_1:t,conv_2:n,conv_3:i,conv_4:c,conv_5:Y,conv_6:M,conv_7:D,conv_8:r,conv_9:a,conv_10:s,conv_11:u,conv_12:F,conv_13:U}}function e(){var I=w(1024,256,1,"prediction_layer/conv_0"),t=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"),a=Q(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),s=Q(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),u=Q(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),F=Q(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),U=Q(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),l=Q(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),d=Q(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),H=Q(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),h=Q(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),G=Q(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),N=Q(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),f={box_encoding_predictor:r,class_predictor:a},W={box_encoding_predictor:s,class_predictor:u},m={box_encoding_predictor:F,class_predictor:U},v={box_encoding_predictor:l,class_predictor:d},y={box_encoding_predictor:H,class_predictor:h},j={box_encoding_predictor:G,class_predictor:N};return{conv_0:I,conv_1:t,conv_2:n,conv_3:i,conv_4:c,conv_5:Y,conv_6:M,conv_7:D,box_predictor_0:f,box_predictor_1:W,box_predictor_2:m,box_predictor_3:v,box_predictor_4:y,box_predictor_5:j}}return{extractMobilenetV1Params:E,extractPredictionLayerParams:e}}function pP(A){var g=[],B=hQ(A),Q=B.extractWeights,w=B.getRemainingWeights,C=jP(Q,g),E=C.extractMobilenetV1Params,e=C.extractPredictionLayerParams,I=E(),t=e(),n=Et(Q(5118*4),[1,5118,4]),i={extra_dim:n};if(g.push({paramPath:"output_layer/extra_dim"}),w().length!==0)throw new Error("weights remaing after extract: "+w().length);return{params:{mobilenetv1:I,prediction_layer:t,output_layer:i},paramMappings:g}}function yP(A,g){var B=yQ(A,g);function Q(t,n,i){var c=B(t+"/Conv2d_"+n+"_pointwise/weights",4,i+"/filters"),Y=B(t+"/Conv2d_"+n+"_pointwise/convolution_bn_offset",1,i+"/batch_norm_offset");return{filters:c,batch_norm_offset:Y}}function w(t){var n="mobilenetv1/conv_"+t,i="MobilenetV1/Conv2d_"+t+"_depthwise",c=n+"/depthwise_conv",Y=n+"/pointwise_conv",M=B(i+"/depthwise_weights",4,c+"/filters"),D=B(i+"/BatchNorm/gamma",1,c+"/batch_norm_scale"),r=B(i+"/BatchNorm/beta",1,c+"/batch_norm_offset"),a=B(i+"/BatchNorm/moving_mean",1,c+"/batch_norm_mean"),s=B(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:a,batch_norm_variance:s},pointwise_conv:Q("MobilenetV1",t,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(t,n){var i=B(t+"/weights",4,n+"/filters"),c=B(t+"/biases",1,n+"/bias");return{filters:i,bias:c}}function e(t){var n=E("Prediction/BoxPredictor_"+t+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+t+"/box_encoding_predictor"),i=E("Prediction/BoxPredictor_"+t+"/ClassPredictor","prediction_layer/box_predictor_"+t+"/class_predictor");return{box_encoding_predictor:n,class_predictor:i}}function I(){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:I}}function zP(A){var g=[],B=yP(A,g),Q=B.extractMobilenetV1Params,w=B.extractPredictionLayerParams,C=A["Output/extra_dim"];if(g.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!Pe(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 lQ(A,g),{params:E,paramMappings:g}}function IQ(A,g,B){return FA(function(){var Q=jg(A,g.filters,B,"same");return Q=BB(Q,g.batch_norm_offset),ft(Q,0,6)})}var WP=.0010000000474974513;function bP(A,g,B){return FA(function(){var Q=Ge(A,g.filters,B,"same");return Q=ir(Q,g.batch_norm_mean,g.batch_norm_variance,g.batch_norm_offset,g.batch_norm_scale,WP),ft(Q,0,6)})}function SP(A){return[2,4,6,12].some(function(g){return g===A})?[2,2]:[1,1]}function LP(A,g){return FA(function(){var B=null,Q=IQ(A,g.conv_0,[2,2]),w=[g.conv_1,g.conv_2,g.conv_3,g.conv_4,g.conv_5,g.conv_6,g.conv_7,g.conv_8,g.conv_9,g.conv_10,g.conv_11,g.conv_12,g.conv_13];if(w.forEach(function(C,E){var e=E+1,I=SP(e);Q=bP(Q,C.depthwise_conv,I),Q=IQ(Q,C.pointwise_conv,[1,1]),e===11&&(B=Q)}),B===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:Q,conv11:B}})}function VP(A,g,B,Q,w){var C=A.shape[0],E=Math.min(B,C),e=g.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}),I=function(n){return n<=Q?1:0},t=[];return e.forEach(function(n){if(!(t.length>=E)){for(var i=n.score,c=t.length-1;c>=0;--c){var Y=KP(A,n.boxIndex,t[c]);if(Y!==0&&(n.score*=I(Y),n.score<=w))break}i===n.score&&t.push(n.boxIndex)}}),t}function KP(A,g,B){var Q=A.arraySync(),w=Math.min(Q[g][0],Q[g][2]),C=Math.min(Q[g][1],Q[g][3]),E=Math.max(Q[g][0],Q[g][2]),e=Math.max(Q[g][1],Q[g][3]),I=Math.min(Q[B][0],Q[B][2]),t=Math.min(Q[B][1],Q[B][3]),n=Math.max(Q[B][0],Q[B][2]),i=Math.max(Q[B][1],Q[B][3]),c=(E-w)*(e-C),Y=(n-I)*(i-t);if(c<=0||Y<=0)return 0;var M=Math.max(w,I),D=Math.max(C,t),r=Math.min(E,n),a=Math.min(e,i),s=Math.max(r-M,0)*Math.max(a-D,0);return s/(c+Y-s)}function xP(A){var g=WB(vQ(A,[1,0])),B=[SB(g[2],g[0]),SB(g[3],g[1])],Q=[BB(g[0],Lg(B[0],cA(2))),BB(g[1],Lg(B[1],cA(2)))];return{sizes:B,centers:Q}}function XP(A,g){var B=xP(A),Q=B.sizes,w=B.centers,C=WB(vQ(g,[1,0])),E=Lg(Ig(Jt(Lg(C[2],cA(5))),Q[0]),cA(2)),e=BB(Ig(Lg(C[0],cA(10)),Q[0]),w[0]),I=Lg(Ig(Jt(Lg(C[3],cA(5))),Q[1]),cA(2)),t=BB(Ig(Lg(C[1],cA(10)),Q[1]),w[1]);return vQ(fg([SB(e,E),SB(t,I),BB(e,E),BB(t,I)]),[1,0])}function OP(A,g,B){return FA(function(){var Q=A.shape[0],w=XP(bg(Vw(B.extra_dim,[Q,1,1]),[-1,4]),bg(A,[-1,4]));w=bg(w,[Q,w.shape[0]/Q,4]);var C=Ir(QQ(g,[0,0,1],[-1,-1,-1])),E=QQ(C,[0,0,0],[-1,-1,1]);E=bg(E,[Q,E.shape[1]]);var e=WB(w),I=WB(E);return{boxes:e,scores:I}})}function CC(A,g){return FA(function(){var B=A.shape[0],Q=bg(Vg(A,g.box_encoding_predictor),[B,-1,1,4]),w=bg(Vg(A,g.class_predictor),[B,-1,3]);return{boxPredictionEncoding:Q,classPrediction:w}})}function ZP(A,g,B){return FA(function(){var Q=IQ(A,B.conv_0,[1,1]),w=IQ(Q,B.conv_1,[2,2]),C=IQ(w,B.conv_2,[1,1]),E=IQ(C,B.conv_3,[2,2]),e=IQ(E,B.conv_4,[1,1]),I=IQ(e,B.conv_5,[2,2]),t=IQ(I,B.conv_6,[1,1]),n=IQ(t,B.conv_7,[2,2]),i=CC(g,B.box_predictor_0),c=CC(A,B.box_predictor_1),Y=CC(w,B.box_predictor_2),M=CC(E,B.box_predictor_3),D=CC(I,B.box_predictor_4),r=CC(n,B.box_predictor_5),a=zB([i.boxPredictionEncoding,c.boxPredictionEncoding,Y.boxPredictionEncoding,M.boxPredictionEncoding,D.boxPredictionEncoding,r.boxPredictionEncoding],1),s=zB([i.classPrediction,c.classPrediction,Y.classPrediction,M.classPrediction,D.classPrediction,r.classPrediction],1);return{boxPredictions:a,classPredictions:s}})}var xe=function(){function A(g){var B=g===void 0?{}:g,Q=B.minConfidence,w=B.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}(),bD=function(A){LA(g,A);function g(){return A.call(this,"SsdMobilenetv1")||this}return g.prototype.forwardInput=function(B){var Q=this.params;if(!Q)throw new Error("SsdMobilenetv1 - load model before inference");return FA(function(){var w=B.toBatchTensor(512,!1).toFloat(),C=SB(Ig(w,cA(.007843137718737125)),cA(1)),E=LP(C,Q.mobilenetv1),e=ZP(E.out,E.conv11,Q.prediction_layer),I=e.boxPredictions,t=e.classPredictions;return OP(I,t,Q.output_layer)})},g.prototype.forward=function(B){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,ZB(B)];case 1:return[2,Q.apply(this,[w.sent()])]}})})},g.prototype.locateFaces=function(B,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,I,t,n,i,c,Y,M,D,r,a,s,u,F,U,l,d,H;return mA(this,function(h){switch(h.label){case 0:return w=new xe(Q),C=w.maxResults,E=w.minConfidence,[4,ZB(B)];case 1:for(e=h.sent(),I=this.forwardInput(e),t=I.boxes,n=I.scores,i=t[0],c=n[0],Y=1;Y<t.length;Y++)t[Y].dispose(),n[Y].dispose();return r=(D=Array).from,[4,c.data()];case 2:return M=r.apply(D,[h.sent()]),a=.5,s=VP(i,M,C,a,E),u=e.getReshapedInputDimensions(0),F=e.inputSize,U=F/u.width,l=F/u.height,d=i.arraySync(),H=s.map(function(G){var N=[Math.max(0,d[G][0]),Math.min(1,d[G][2])].map(function(j){return j*l}),f=N[0],W=N[1],m=[Math.max(0,d[G][1]),Math.min(1,d[G][3])].map(function(j){return j*U}),v=m[0],y=m[1];return new mg(M[G],new ke(v,f,y-v,W-f),{height:e.getInputHeight(0),width:e.getInputWidth(0)})}),i.dispose(),c.dispose(),[2,H]}})})},g.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},g.prototype.extractParamsFromWeigthMap=function(B){return zP(B)},g.prototype.extractParams=function(B){return pP(B)},g}(UQ);(function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g})(bD);var qP=.4,_P=[new cB(.738768,.874946),new cB(2.42204,2.65704),new cB(4.30971,7.04493),new cB(10.246,4.59428),new cB(12.6868,11.8741)],$P=[new cB(1.603231,2.094468),new cB(6.041143,7.080126),new cB(2.882459,3.518061),new cB(4.266906,5.178857),new cB(9.041765,10.66308)],Av=[117.001,114.697,97.404],Bv="tiny_yolov2_model",gv="tiny_yolov2_separable_conv_model",Xe=function(A){return typeof A=="number"};function Qv(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(!Xe(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(g){return typeof g=="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(g){return g||{}}).every(function(g){return Xe(g.x)&&Xe(g.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(Xe)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(A.meanRgb))}function sn(A){return FA(function(){var g=Ig(A,cA(.10000000149011612));return BB(JB(SB(A,g)),g)})}function zQ(A,g){return FA(function(){var B=ww(A,[[0,0],[1,1],[1,1],[0,0]]);return B=jg(B,g.conv.filters,[1,1],"valid"),B=SB(B,g.bn.sub),B=Ig(B,g.bn.truediv),B=BB(B,g.conv.bias),sn(B)})}function WQ(A,g){return FA(function(){var B=ww(A,[[0,0],[1,1],[1,1],[0,0]]);return B=vt(B,g.depthwise_filter,g.pointwise_filter,[1,1],"valid"),B=BB(B,g.bias),sn(B)})}function wv(A,g){var B=Se(A,g);function Q(E,e){var I=pB(A(E)),t=pB(A(E));return g.push({paramPath:e+"/sub"},{paramPath:e+"/truediv"}),{sub:I,truediv:t}}function w(E,e,I){var t=B(E,e,3,I+"/conv"),n=Q(e,I+"/bn");return{conv:t,bn:n}}var C=Mn(A,g);return{extractConvParams:B,extractConvWithBatchNormParams:w,extractSeparableConvParams:C}}function Cv(A,g,B,Q){var w=hQ(A),C=w.extractWeights,E=w.getRemainingWeights,e=[],I=wv(C,e),t=I.extractConvParams,n=I.extractConvWithBatchNormParams,i=I.extractSeparableConvParams,c;if(g.withSeparableConvs){var Y=Q[0],M=Q[1],D=Q[2],r=Q[3],a=Q[4],s=Q[5],u=Q[6],F=Q[7],U=Q[8],l=g.isFirstLayerConv2d?t(Y,M,3,"conv0"):i(Y,M,"conv0"),d=i(M,D,"conv1"),H=i(D,r,"conv2"),h=i(r,a,"conv3"),G=i(a,s,"conv4"),N=i(s,u,"conv5"),f=F?i(u,F,"conv6"):void 0,W=U?i(F,U,"conv7"):void 0,m=t(U||F||u,5*B,1,"conv8");c={conv0:l,conv1:d,conv2:H,conv3:h,conv4:G,conv5:N,conv6:f,conv7:W,conv8:m}}else{var Y=Q[0],M=Q[1],D=Q[2],r=Q[3],a=Q[4],s=Q[5],u=Q[6],F=Q[7],U=Q[8],l=n(Y,M,"conv0"),d=n(M,D,"conv1"),H=n(D,r,"conv2"),h=n(r,a,"conv3"),G=n(a,s,"conv4"),N=n(s,u,"conv5"),f=n(u,F,"conv6"),W=n(F,U,"conv7"),m=t(U,5*B,1,"conv8");c={conv0:l,conv1:d,conv2:H,conv3:h,conv4:G,conv5:N,conv6:f,conv7:W,conv8:m}}if(E().length!==0)throw new Error("weights remaing after extract: "+E().length);return{params:c,paramMappings:e}}function Ev(A,g){var B=yQ(A,g);function Q(e){var I=B(e+"/sub",1),t=B(e+"/truediv",1);return{sub:I,truediv:t}}function w(e){var I=B(e+"/filters",4),t=B(e+"/bias",1);return{filters:I,bias:t}}function C(e){var I=w(e+"/conv"),t=Q(e+"/bn");return{conv:I,bn:t}}var E=rn(B);return{extractConvParams:w,extractConvWithBatchNormParams:C,extractSeparableConvParams:E}}function ev(A,g){var B=[],Q=Ev(A,B),w=Q.extractConvParams,C=Q.extractConvWithBatchNormParams,E=Q.extractSeparableConvParams,e;if(g.withSeparableConvs){var I=g.filterSizes&&g.filterSizes.length||9;e={conv0:g.isFirstLayerConv2d?w("conv0"):E("conv0"),conv1:E("conv1"),conv2:E("conv2"),conv3:E("conv3"),conv4:E("conv4"),conv5:E("conv5"),conv6:I>7?E("conv6"):void 0,conv7:I>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 lQ(A,B),{params:e,paramMappings:B}}var SD;(function(A){A[A.XS=224]="XS",A[A.SM=320]="SM",A[A.MD=416]="MD",A[A.LG=608]="LG"})(SD||(SD={}));var un=function(){function A(g){var B=g===void 0?{}:g,Q=B.inputSize,w=B.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}(),LD=function(A){LA(g,A);function g(B){var Q=A.call(this,"TinyYolov2")||this;return Qv(B),Q._config=B,Q}return Object.defineProperty(g.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),g.prototype.runTinyYolov2=function(B,Q){var w=zQ(B,Q.conv0);return w=OB(w,[2,2],[2,2],"same"),w=zQ(w,Q.conv1),w=OB(w,[2,2],[2,2],"same"),w=zQ(w,Q.conv2),w=OB(w,[2,2],[2,2],"same"),w=zQ(w,Q.conv3),w=OB(w,[2,2],[2,2],"same"),w=zQ(w,Q.conv4),w=OB(w,[2,2],[2,2],"same"),w=zQ(w,Q.conv5),w=OB(w,[2,2],[1,1],"same"),w=zQ(w,Q.conv6),w=zQ(w,Q.conv7),Vg(w,Q.conv8,"valid",!1)},g.prototype.runMobilenet=function(B,Q){var w=this.config.isFirstLayerConv2d?sn(Vg(B,Q.conv0,"valid",!1)):WQ(B,Q.conv0);return w=OB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv1),w=OB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv2),w=OB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv3),w=OB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv4),w=OB(w,[2,2],[2,2],"same"),w=WQ(w,Q.conv5),w=OB(w,[2,2],[1,1],"same"),w=Q.conv6?WQ(w,Q.conv6):w,w=Q.conv7?WQ(w,Q.conv7):w,Vg(w,Q.conv8,"valid",!1)},g.prototype.forwardInput=function(B,Q){var w=this,C=this.params;if(!C)throw new Error("TinyYolov2 - load model before inference");return FA(function(){var E=B.toBatchTensor(Q,!1).toFloat();return E=w.config.meanRgb?$C(E,w.config.meanRgb):E,E=E.div(cA(256)),w.config.withSeparableConvs?w.runMobilenet(E,C):w.runTinyYolov2(E,C)})},g.prototype.forward=function(B,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,ZB(B)];case 1:return[4,w.apply(this,[C.sent(),Q])];case 2:return[2,C.sent()]}})})},g.prototype.detect=function(B,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,I,t,n,i,c,Y,M,D,r,a,s=this;return mA(this,function(u){switch(u.label){case 0:return w=new un(Q),C=w.inputSize,E=w.scoreThreshold,[4,ZB(B)];case 1:return e=u.sent(),[4,this.forwardInput(e,C)];case 2:return I=u.sent(),t=FA(function(){return WB(I)[0].expandDims()}),n={width:e.getInputWidth(0),height:e.getInputHeight(0)},[4,this.extractBoxes(t,e.getReshapedInputDimensions(0),E)];case 3:return i=u.sent(),I.dispose(),t.dispose(),c=i.map(function(F){return F.box}),Y=i.map(function(F){return F.score}),M=i.map(function(F){return F.classScore}),D=i.map(function(F){return s.config.classes[F.label]}),r=_C(c.map(function(F){return F.rescale(C)}),Y,this.config.iouThreshold,!0),a=r.map(function(F){return new nD(Y[F],M[F],D[F],c[F],n)}),[2,a]}})})},g.prototype.getDefaultModelName=function(){return""},g.prototype.extractParamsFromWeigthMap=function(B){return ev(B,this.config)},g.prototype.extractParams=function(B){var Q=this.config.filterSizes||g.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 Cv(B,this.config,this.boxEncodingSize,Q)},g.prototype.extractBoxes=function(B,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,I,t,n,i,c,Y,M,D,r,a,s,u,F,U,l,d,H,h,G,N,f,W,m,v,y,j,p=this;return mA(this,function(V){switch(V.label){case 0:return C=Q.width,E=Q.height,e=Math.max(C,E),I=e/C,t=e/E,n=B.shape[1],i=this.config.anchors.length,c=FA(function(){var K=B.reshape([n,n,i,p.boxEncodingSize]),k=K.slice([0,0,0,0],[n,n,i,4]),T=K.slice([0,0,0,4],[n,n,i,1]),X=p.withClassScores?FQ(K.slice([0,0,0,5],[n,n,i,p.config.classes.length]),3):cA(0);return[k,T,X]}),Y=c[0],M=c[1],D=c[2],r=[],[4,M.array()];case 1:return a=V.sent(),[4,Y.array()];case 2:s=V.sent(),u=0,V.label=3;case 3:if(!(u<n))return[3,12];F=0,V.label=4;case 4:if(!(F<n))return[3,11];U=0,V.label=5;case 5:return U<i?(l=En(a[u][F][U][0]),!w||l>w?(d=(F+En(s[u][F][U][0]))/n*I,H=(u+En(s[u][F][U][1]))/n*t,h=Math.exp(s[u][F][U][2])*this.config.anchors[U].x/n*I,G=Math.exp(s[u][F][U][3])*this.config.anchors[U].y/n*t,N=d-h/2,f=H-G/2,W={row:u,col:F,anchor:U},this.withClassScores?[4,this.extractPredictedClass(D,W)]:[3,7]):[3,9]):[3,10];case 6:return j=V.sent(),[3,8];case 7:j={classScore:1,label:0},V.label=8;case 8:m=j,v=m.classScore,y=m.label,r.push(tg({box:new ve(N,f,N+h,f+G),score:l,classScore:l*v,label:y},W)),V.label=9;case 9:return U++,[3,5];case 10:return F++,[3,4];case 11:return u++,[3,3];case 12:return Y.dispose(),M.dispose(),D.dispose(),[2,r]}})})},g.prototype.extractPredictedClass=function(B,Q){return JA(this,void 0,void 0,function(){var w,C,E,e;return mA(this,function(I){switch(I.label){case 0:return w=Q.row,C=Q.col,E=Q.anchor,[4,B.array()];case 1:return e=I.sent(),[2,Array(this.config.classes.length).fill(0).map(function(t,n){return e[w][C][E][n]}).map(function(t,n){return{classScore:t,label:n}}).reduce(function(t,n){return t.classScore>n.classScore?t:n})]}})})},g.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],g}(UQ),Iv=function(A){LA(g,A);function g(B){B===void 0&&(B=!0);var Q=this,w=Object.assign({},{withSeparableConvs:B,iouThreshold:qP,classes:["face"]},B?{anchors:$P,meanRgb:Av}:{anchors:_P,withClassScores:!0});return Q=A.call(this,w)||this,Q}return Object.defineProperty(g.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),g.prototype.locateFaces=function(B,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(B,Q)];case 1:return w=C.sent(),[2,w.map(function(E){return new mg(E.score,E.relativeBox,{width:E.imageWidth,height:E.imageHeight})})]}})})},g.prototype.getDefaultModelName=function(){return this.withSeparableConvs?gv:Bv},g.prototype.extractParamsFromWeigthMap=function(B){return A.prototype.extractParamsFromWeigthMap.call(this,B)},g}(LD),VD=function(A){LA(g,A);function g(){var B=A!==null&&A.apply(this,arguments)||this;return B._name="TinyFaceDetectorOptions",B}return g}(un),BE=function(){function A(){}return A.prototype.then=function(g){return JA(this,void 0,void 0,function(){var B;return mA(this,function(Q){switch(Q.label){case 0:return B=g,[4,this.run()];case 1:return[2,B.apply(void 0,[Q.sent()])]}})})},A.prototype.run=function(){return JA(this,void 0,void 0,function(){return mA(this,function(g){throw new Error("ComposableTask - run is not implemented")})})},A}();function Oe(A,g,B,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,I,t;return mA(this,function(n){switch(n.label){case 0:return C=A.map(function(i){return Dn(i)?w(i):i.detection}),e=Q,e?[3,5]:g instanceof HB?[4,nn(g,C)]:[3,2];case 1:return I=n.sent(),[3,4];case 2:return[4,We(g,C)];case 3:I=n.sent(),n.label=4;case 4:e=I,n.label=5;case 5:return E=e,[4,B(E)];case 6:return t=n.sent(),E.forEach(function(i){return i instanceof HB&&i.dispose()}),[2,t]}})})}function Un(A,g,B,Q,w){return JA(this,void 0,void 0,function(){var C=this;return mA(this,function(E){return[2,Oe([A],g,function(e){return JA(C,void 0,void 0,function(){return mA(this,function(I){return[2,B(e[0])]})})},Q,w)]})})}function ov(A){return FA(function(){return fg(WB(A,3).reverse(),3)})}var Ze=2,qe=12;function tv(A,g){var B=Se(A,g),Q=Yn(A,g);function w(t,n){var i=pB(A(t));return g.push({paramPath:n}),i}function C(t,n,i){i===void 0&&(i=!1);var c=B(t[0],t[1],3,n+"/conv1"),Y=w(t[1],n+"/prelu1_alpha"),M=B(t[1],t[2],3,n+"/conv2"),D=w(t[2],n+"/prelu2_alpha"),r=B(t[2],t[3],i?2:3,n+"/conv3"),a=w(t[3],n+"/prelu3_alpha");return{conv1:c,prelu1_alpha:Y,conv2:M,prelu2_alpha:D,conv3:r,prelu3_alpha:a}}function E(){var t=C([3,10,16,32],"pnet"),n=B(32,2,1,"pnet/conv4_1"),i=B(32,4,1,"pnet/conv4_2");return tg(tg({},t),{conv4_1:n,conv4_2:i})}function e(){var t=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 tg(tg({},t),{fc1:n,prelu4_alpha:i,fc2_1:c,fc2_2:Y})}function I(){var t=C([3,32,64,64],"onet"),n=B(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 tg(tg({},t),{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:I}}function nv(A){var g=hQ(A),B=g.extractWeights,Q=g.getRemainingWeights,w=[],C=tv(B,w),E=C.extractPNetParams,e=C.extractRNetParams,I=C.extractONetParams,t=E(),n=e(),i=I();if(Q().length!==0)throw new Error("weights remaing after extract: "+Q().length);return{params:{pnet:t,rnet:n,onet:i},paramMappings:w}}function iv(A,g){var B=yQ(A,g);function Q(n){var i=B(n+"/weights",4,n+"/filters"),c=B(n+"/bias",1);return{filters:i,bias:c}}function w(n){var i=B(n+"/weights",2),c=B(n+"/bias",1);return{weights:i,bias:c}}function C(n){return B(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 tg(tg({},n),{conv4_1:i,conv4_2:c})}function I(){var n=E("rnet"),i=w("rnet/fc1"),c=C("rnet/prelu4_alpha"),Y=w("rnet/fc2_1"),M=w("rnet/fc2_2");return tg(tg({},n),{fc1:i,prelu4_alpha:c,fc2_1:Y,fc2_2:M})}function t(){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"),a=w("onet/fc2_3");return tg(tg({},n),{conv4:i,prelu4_alpha:c,fc1:Y,prelu5_alpha:M,fc2_1:D,fc2_2:r,fc2_3:a})}return{extractPNetParams:e,extractRNetParams:I,extractONetParams:t}}function cv(A){var g=[],B=iv(A,g),Q=B.extractPNetParams,w=B.extractRNetParams,C=B.extractONetParams,E=Q(),e=w(),I=C();return lQ(A,g),{params:{pnet:E,rnet:e,onet:I},paramMappings:g}}function ln(A,g){var B=g[0],Q=g[1];return{height:Math.floor(B*A),width:Math.floor(Q*A)}}function Yv(A,g,B){for(var Q=B[0],w=B[1],C=qe/A,E=[],e=Math.min(Q,w)*C,I=0;e>=12;)E.push(C*Math.pow(g,I)),e=e*g,I+=1;return E}var hn=function(A){LA(g,A);function g(B,Q,w,C){return A.call(this,{left:B,top:Q,right:w,bottom:C},!0)||this}return g}(wQ);function KD(A){return FA(function(){return Ig(SB(A,cA(127.5)),cA(.0078125))})}function EC(A,g){return FA(function(){return BB(JB(A),Ig(g,se(JB(se(A)))))})}function Gn(A,g,B){return B===void 0&&(B=!1),FA(function(){var Q=Vg(A,g.conv1,"valid");return Q=EC(Q,g.prelu1_alpha),Q=OB(Q,B?[2,2]:[3,3],[2,2],"same"),Q=Vg(Q,g.conv2,"valid"),Q=EC(Q,g.prelu2_alpha),Q=B?Q:OB(Q,[3,3],[2,2],"valid"),Q=Vg(Q,g.conv3,"valid"),Q=EC(Q,g.prelu3_alpha),Q})}function Mv(A,g){return FA(function(){var B=Gn(A,g,!0),Q=Vg(B,g.conv4_1,"valid"),w=Tg(He(Q,3),3),C=FQ(SB(Q,w),3),E=Vg(B,g.conv4_2,"valid");return{prob:C,regions:E}})}function rv(A,g){return FA(function(){var B=ln(g,A.shape.slice(1)),Q=B.height,w=B.width,C=yt.resizeBilinear(A,[Q,w]),E=KD(C);return vQ(E,[0,2,1,3])})}function Dv(A,g,B,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 cB(e,E));var I=w.map(function(t){var n=new ve(Math.round((t.y*Ze+1)/B),Math.round((t.x*Ze+1)/B),Math.round((t.y*Ze+qe)/B),Math.round((t.x*Ze+qe)/B)),i=C[t.y][t.x],c=g.arraySync(),Y=new hn(c[t.y][t.x][0],c[t.y][t.x][1],c[t.y][t.x][2],c[t.y][t.x][3]);return{cell:n,score:i,region:Y}});return I}function Fv(A,g,B,Q,w){w.stage1=[];var C=g.map(function(c){return FA(function(){var Y={scale:c},M=rv(A,c),D=Date.now(),r=Mv(M,Q),a=r.prob,s=r.regions;Y.pnet=Date.now()-D;var u=WB(WB(a,3)[1])[0],F=WB(s)[0];return{scoresTensor:u,regionsTensor:F,scale:c,statsForScale:Y}})}),E=C.map(function(c){var Y=c.scoresTensor,M=c.regionsTensor,D=c.scale,r=c.statsForScale,a=Dv(Y,M,D,B);if(Y.dispose(),M.dispose(),!a.length)return w.stage1.push(r),[];var s=Date.now(),u=_C(a.map(function(F){return F.cell}),a.map(function(F){return F.score}),.5);return r.nms=Date.now()-s,r.numBoxes=u.length,w.stage1.push(r),u.map(function(F){return a[F]})}),e=E.reduce(function(c,Y){return c.concat(Y)},[]),I=[],t=[];if(e.length>0){var n=Date.now(),i=_C(e.map(function(c){return c.cell}),e.map(function(c){return c.score}),.7);w.stage1_nms=Date.now()-n,t=i.map(function(c){return e[c].score}),I=i.map(function(c){return e[c]}).map(function(c){var Y=c.cell,M=c.region;return new ve(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:I,scores:t}}function xD(A,g,B){var Q=B.width,w=B.height;return JA(this,void 0,void 0,function(){var C,E,e,I=this;return mA(this,function(t){switch(t.label){case 0:return C=CQ(A),[4,Promise.all(g.map(function(n){return JA(I,void 0,void 0,function(){var i,c,Y,M,D,r,a,s;return mA(this,function(u){return i=n.padAtBorders(A.height,A.width),c=i.y,Y=i.ey,M=i.x,D=i.ex,r=M-1,a=c-1,s=C.getImageData(r,a,D-r,Y-a),[2,ng.isNodejs()?ye(s):createImageBitmap(s)]})})}))];case 1:return E=t.sent(),e=[],E.forEach(function(n){var i=pe({width:Q,height:w}),c=CQ(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=vQ(ag(n,[1,Q,w,3]),[0,2,1,3]).toFloat();return KD(c)});return i})]}})})}function av(A,g){return FA(function(){var B=Gn(A,g),Q=bg(B,[B.shape[0],g.fc1.weights.shape[0]]),w=EQ(Q,g.fc1),C=EC(w,g.prelu4_alpha),E=EQ(C,g.fc2_1),e=Tg(He(E,1),1),I=FQ(SB(E,e),1),t=EQ(C,g.fc2_2),n=WB(I,1)[1];return{scores:n,regions:t}})}function sv(A,g,B,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,I,t,n,i,c,Y,M,D,r,a,s;return mA(this,function(u){switch(u.label){case 0:return C=Date.now(),[4,xD(A,g,{width:24,height:24})];case 1:return E=u.sent(),w.stage2_extractImagePatches=Date.now()-C,C=Date.now(),e=E.map(function(F){var U=av(F,Q);return F.dispose(),U}),w.stage2_rnet=Date.now()-C,I=e.length>1?zB(e.map(function(F){return F.scores})):e[0].scores,i=(n=Array).from,[4,I.data()];case 2:return t=i.apply(n,[u.sent()]),I.dispose(),c=t.map(function(F,U){return{score:F,idx:U}}).filter(function(F){return F.score>B}).map(function(F){var U=F.idx;return U}),Y=c.map(function(F){return g[F]}),M=c.map(function(F){return t[F]}),D=[],r=[],Y.length>0&&(C=Date.now(),a=_C(Y,M,.7),w.stage2_nms=Date.now()-C,s=a.map(function(F){var U=e[c[F]].regions.arraySync();return new hn(U[0][0],U[0][1],U[0][2],U[0][3])}),r=a.map(function(F){return M[F]}),D=a.map(function(F,U){return Y[F].calibrate(s[U])})),e.forEach(function(F){F.regions.dispose(),F.scores.dispose()}),[2,{boxes:D,scores:r}]}})})}function uv(A,g){return FA(function(){var B=Gn(A,g);B=OB(B,[2,2],[2,2],"same"),B=Vg(B,g.conv4,"valid"),B=EC(B,g.prelu4_alpha);var Q=bg(B,[B.shape[0],g.fc1.weights.shape[0]]),w=EQ(Q,g.fc1),C=EC(w,g.prelu5_alpha),E=EQ(C,g.fc2_1),e=Tg(He(E,1),1),I=FQ(SB(E,e),1),t=EQ(C,g.fc2_2),n=EQ(C,g.fc2_3),i=WB(I,1)[1];return{scores:i,regions:t,points:n}})}function Uv(A,g,B,Q,w){return JA(this,void 0,void 0,function(){var C,E,e,I,t,n,i,c,Y,M,D,r,a,s,u;return mA(this,function(F){switch(F.label){case 0:return C=Date.now(),[4,xD(A,g,{width:48,height:48})];case 1:return E=F.sent(),w.stage3_extractImagePatches=Date.now()-C,C=Date.now(),e=E.map(function(U){var l=uv(U,Q);return U.dispose(),l}),w.stage3_onet=Date.now()-C,I=e.length>1?zB(e.map(function(U){return U.scores})):e[0].scores,i=(n=Array).from,[4,I.data()];case 2:return t=i.apply(n,[F.sent()]),I.dispose(),c=t.map(function(U,l){return{score:U,idx:l}}).filter(function(U){return U.score>B}).map(function(U){var l=U.idx;return l}),Y=c.map(function(U){var l=e[U].regions.arraySync();return new hn(l[0][0],l[0][1],l[0][2],l[0][3])}),M=c.map(function(U,l){return g[U].calibrate(Y[l])}),D=c.map(function(U){return t[U]}),r=[],a=[],s=[],M.length>0&&(C=Date.now(),u=_C(M,D,.7,!1),w.stage3_nms=Date.now()-C,r=u.map(function(U){return M[U]}),a=u.map(function(U){return D[U]}),s=u.map(function(U,l){return Array(5).fill(0).map(function(d,H){var h=e[U].points.arraySync();return new cB(h[0][H]*(r[l].width+1)+r[l].left,h[0][H+5]*(r[l].height+1)+r[l].top)})})),e.forEach(function(U){U.regions.dispose(),U.scores.dispose(),U.points.dispose()}),[2,{boxes:r,scores:a,points:s}]}})})}var lv=function(A){LA(g,A);function g(){return A.call(this,"Mtcnn")||this}return g.prototype.load=function(B){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,B)]})})},g.prototype.loadFromDisk=function(B){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,B)]})})},g.prototype.forwardInput=function(B,Q){return Q===void 0&&(Q={}),JA(this,void 0,void 0,function(){var w,C,E,e,I,t,n,i,c,Y,M,D,r,a,s,u,F,U,l,d,H;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=B.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(),I=FA(function(){return ov(Tg(Qn.fromPixels(C)).toFloat())}),t=function(G){return I.dispose(),E.total=Date.now()-e,G},n=I.shape.slice(1),i=n[0],c=n[1],Y=new WD(Q),M=Y.minFaceSize,D=Y.scaleFactor,r=Y.maxNumScales,a=Y.scoreThresholds,s=Y.scaleSteps,u=(s||Yv(M,D,[i,c])).filter(function(G){var N=ln(G,[i,c]);return Math.min(N.width,N.height)>qe}).slice(0,r),E.scales=u,E.pyramid=u.map(function(G){return ln(G,[i,c])}),F=Date.now(),[4,Fv(I,u,a[0],w.pnet,E)];case 1:return U=h.sent(),E.total_stage1=Date.now()-F,U.boxes.length?(E.stage2_numInputBoxes=U.boxes.length,F=Date.now(),[4,sv(C,U.boxes,a[1],w.rnet,E)]):[2,t({results:[],stats:E})];case 2:return l=h.sent(),E.total_stage2=Date.now()-F,l.boxes.length?(E.stage3_numInputBoxes=l.boxes.length,F=Date.now(),[4,Uv(C,l.boxes,a[2],w.onet,E)]):[2,t({results:[],stats:E})];case 3:return d=h.sent(),E.total_stage3=Date.now()-F,H=d.boxes.map(function(G,N){return Le(AE({},new mg(d.scores[N],new ke(G.left/c,G.top/i,G.width/c,G.height/i),{height:i,width:c})),new XR(d.points[N].map(function(f){return f.sub(new cB(G.left,G.top)).div(new cB(G.width,G.height))}),{width:G.width,height:G.height}))}),[2,t({results:H,stats:E})]}})})},g.prototype.forward=function(B,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,ZB(B)];case 1:return[4,w.apply(this,[C.sent(),Q])];case 2:return[2,C.sent().results]}})})},g.prototype.forwardWithStats=function(B,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,ZB(B)];case 1:return[2,w.apply(this,[C.sent(),Q])]}})})},g.prototype.getDefaultModelName=function(){return"mtcnn_model"},g.prototype.extractParamsFromWeigthMap=function(B){return cv(B)},g.prototype.extractParams=function(B){return nv(B)},g}(UQ),hv=.4,Gv=[new cB(1.603231,2.094468),new cB(6.041143,7.080126),new cB(2.882459,3.518061),new cB(4.266906,5.178857),new cB(9.041765,10.66308)],dv=[117.001,114.697,97.404],Hv=function(A){LA(g,A);function g(){var B=this,Q={withSeparableConvs:!0,iouThreshold:hv,classes:["face"],anchors:Gv,meanRgb:dv,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return B=A.call(this,Q)||this,B}return Object.defineProperty(g.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),g.prototype.locateFaces=function(B,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(B,Q)];case 1:return w=C.sent(),[2,w.map(function(E){return new mg(E.score,E.relativeBox,{width:E.imageWidth,height:E.imageHeight})})]}})})},g.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},g.prototype.extractParamsFromWeigthMap=function(B){return A.prototype.extractParamsFromWeigthMap.call(this,B)},g}(LD),Ug={ssdMobilenetv1:new bD,tinyFaceDetector:new Hv,tinyYolov2:new Iv,mtcnn:new lv,faceLandmark68Net:new kD,faceLandmark68TinyNet:new JP,faceRecognitionNet:new TP,faceExpressionNet:new cP,ageGenderNet:new GP},XD=function(A){LA(g,A);function g(B,Q,w){var C=A.call(this)||this;return C.parentTask=B,C.input=Q,C.extractedFaces=w,C}return g}(BE),dn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w=this;return mA(this,function(C){switch(C.label){case 0:return[4,this.parentTask];case 1:return B=C.sent(),[4,Oe(B,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(I){return Ug.faceExpressionNet.predictExpressions(I)}))];case 1:return[2,e.sent()]}})})},this.extractedFaces)];case 2:return Q=C.sent(),[2,B.map(function(E,e){return RD(E,Q[e])})]}})})},g.prototype.withAgeAndGender=function(){return new mn(this,this.input)},g}(XD),Hn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return B=w.sent(),B?[4,Un(B,this.input,function(C){return Ug.faceExpressionNet.predictExpressions(C)},this.extractedFaces)]:[2];case 2:return Q=w.sent(),[2,RD(B,Q)]}})})},g.prototype.withAgeAndGender=function(){return new Nn(this,this.input)},g}(XD),fn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.withAgeAndGender=function(){return new Rn(this,this.input)},g.prototype.withFaceDescriptors=function(){return new vn(this,this.input)},g}(dn),Jn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.withAgeAndGender=function(){return new Pn(this,this.input)},g.prototype.withFaceDescriptor=function(){return new kn(this,this.input)},g}(Hn),OD=function(A){LA(g,A);function g(B,Q,w){var C=A.call(this)||this;return C.parentTask=B,C.input=Q,C.extractedFaces=w,C}return g}(BE),mn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w=this;return mA(this,function(C){switch(C.label){case 0:return[4,this.parentTask];case 1:return B=C.sent(),[4,Oe(B,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(I){return Ug.ageGenderNet.predictAgeAndGender(I)}))];case 1:return[2,e.sent()]}})})},this.extractedFaces)];case 2:return Q=C.sent(),[2,B.map(function(E,e){var I=Q[e],t=I.age,n=I.gender,i=I.genderProbability;return yD(zD(E,n,i),t)})]}})})},g.prototype.withFaceExpressions=function(){return new dn(this,this.input)},g}(OD),Nn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w,C,E;return mA(this,function(e){switch(e.label){case 0:return[4,this.parentTask];case 1:return B=e.sent(),B?[4,Un(B,this.input,function(I){return Ug.ageGenderNet.predictAgeAndGender(I)},this.extractedFaces)]:[2];case 2:return Q=e.sent(),w=Q.age,C=Q.gender,E=Q.genderProbability,[2,yD(zD(B,C,E),w)]}})})},g.prototype.withFaceExpressions=function(){return new Hn(this,this.input)},g}(OD),Rn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.withFaceExpressions=function(){return new fn(this,this.input)},g.prototype.withFaceDescriptors=function(){return new vn(this,this.input)},g}(mn),Pn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.withFaceExpressions=function(){return new Jn(this,this.input)},g.prototype.withFaceDescriptor=function(){return new kn(this,this.input)},g}(Nn),ZD=function(A){LA(g,A);function g(B,Q){var w=A.call(this)||this;return w.parentTask=B,w.input=Q,w}return g}(BE),vn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return B=w.sent(),[4,Oe(B,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 pD(B[E],C)})]}})})},g.prototype.withFaceExpressions=function(){return new fn(this,this.input)},g.prototype.withAgeAndGender=function(){return new Rn(this,this.input)},g}(ZD),kn=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q;return mA(this,function(w){switch(w.label){case 0:return[4,this.parentTask];case 1:return B=w.sent(),B?[4,Un(B,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,pD(B,Q)]}})})},g.prototype.withFaceExpressions=function(){return new Jn(this,this.input)},g.prototype.withAgeAndGender=function(){return new Pn(this,this.input)},g}(ZD),qD=function(A){LA(g,A);function g(B,Q,w){var C=A.call(this)||this;return C.parentTask=B,C.input=Q,C.useTinyLandmarkNet=w,C}return Object.defineProperty(g.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?Ug.faceLandmark68TinyNet:Ug.faceLandmark68Net},enumerable:!0,configurable:!0}),g}(BE),fv=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w,C,E,e=this;return mA(this,function(I){switch(I.label){case 0:return[4,this.parentTask];case 1:return B=I.sent(),Q=B.map(function(t){return t.detection}),this.input instanceof HB?[4,nn(this.input,Q)]:[3,3];case 2:return C=I.sent(),[3,5];case 3:return[4,We(this.input,Q)];case 4:C=I.sent(),I.label=5;case 5:return w=C,[4,Promise.all(w.map(function(t){return e.landmarkNet.detectLandmarks(t)}))];case 6:return E=I.sent(),w.forEach(function(t){return t instanceof HB&&t.dispose()}),[2,B.map(function(t,n){return Le(t,E[n])})]}})})},g.prototype.withFaceExpressions=function(){return new fn(this,this.input)},g.prototype.withAgeAndGender=function(){return new Rn(this,this.input)},g.prototype.withFaceDescriptors=function(){return new vn(this,this.input)},g}(qD),Jv=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w,C,E;return mA(this,function(e){switch(e.label){case 0:return[4,this.parentTask];case 1:return B=e.sent(),B?(Q=B.detection,this.input instanceof HB?[4,nn(this.input,[Q])]:[3,3]):[2];case 2:return C=e.sent(),[3,5];case 3:return[4,We(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(I){return I instanceof HB&&I.dispose()}),[2,Le(B,E)]}})})},g.prototype.withFaceExpressions=function(){return new Jn(this,this.input)},g.prototype.withAgeAndGender=function(){return new Pn(this,this.input)},g.prototype.withFaceDescriptor=function(){return new kn(this,this.input)},g}(qD),_D=function(A){LA(g,A);function g(B,Q){Q===void 0&&(Q=new xe);var w=A.call(this)||this;return w.input=B,w.options=Q,w}return g}(BE),mv=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q,w,C;return mA(this,function(E){switch(E.label){case 0:return B=this,Q=B.input,w=B.options,w instanceof WD?[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 VD?function(e){return Ug.tinyFaceDetector.locateFaces(e,w)}:w instanceof xe?function(e){return Ug.ssdMobilenetv1.locateFaces(e,w)}:w instanceof un?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)]}})})},g.prototype.runAndExtendWithFaceDetections=function(){var B=this;return new Promise(function(Q){return JA(B,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 AE({},E)}))]}})})})},g.prototype.withFaceLandmarks=function(B){return B===void 0&&(B=!1),new fv(this.runAndExtendWithFaceDetections(),this.input,B)},g.prototype.withFaceExpressions=function(){return new dn(this.runAndExtendWithFaceDetections(),this.input)},g.prototype.withAgeAndGender=function(){return new mn(this.runAndExtendWithFaceDetections(),this.input)},g}(_D),Nv=function(A){LA(g,A);function g(){return A!==null&&A.apply(this,arguments)||this}return g.prototype.run=function(){return JA(this,void 0,void 0,function(){var B,Q;return mA(this,function(w){switch(w.label){case 0:return[4,new mv(this.input,this.options)];case 1:return B=w.sent(),Q=B[0],B.forEach(function(C){C.score>Q.score&&(Q=C)}),[2,Q]}})})},g.prototype.runAndExtendWithFaceDetection=function(){var B=this;return new Promise(function(Q){return JA(B,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?AE({},w):void 0)]}})})})},g.prototype.withFaceLandmarks=function(B){return B===void 0&&(B=!1),new Jv(this.runAndExtendWithFaceDetection(),this.input,B)},g.prototype.withFaceExpressions=function(){return new Hn(this.runAndExtendWithFaceDetection(),this.input)},g.prototype.withAgeAndGender=function(){return new Nn(this.runAndExtendWithFaceDetection(),this.input)},g}(_D);function Rv(A,g){return g===void 0&&(g=new xe),new Nv(A,g)}function Pv(A,g){if(A.length!==g.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var B=Array.from(A),Q=Array.from(g);return Math.sqrt(B.map(function(w,C){return w-Q[C]}).reduce(function(w,C){return w+Math.pow(C,2)},0))}(function(){function A(g,B){B===void 0&&(B=.6),this._distanceThreshold=B;var Q=Array.isArray(g)?g:[g];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 Te)return E;if(E instanceof Float32Array)return new Te(C(),[E]);if(E.descriptor&&E.descriptor instanceof Float32Array)return new Te(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(g,B){return B.map(function(Q){return Pv(Q,g)}).reduce(function(Q,w){return Q+w},0)/(B.length||1)},A.prototype.matchDescriptor=function(g){var B=this;return this.labeledDescriptors.map(function(Q){var w=Q.descriptors,C=Q.label;return new cD(C,B.computeMeanDistance(g,w))}).reduce(function(Q,w){return Q.distance<w.distance?Q:w})},A.prototype.findBestMatch=function(g){var B=this.matchDescriptor(g);return B.distance<this.distanceThreshold?B:new cD("unknown",B.distance)},A.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(g){return g.toJSON()})}},A.fromJSON=function(g){var B=g.labeledDescriptors.map(function(Q){return Te.fromJSON(Q)});return new A(B,g.distanceThreshold)},A})();function $D(A,g){var B=new cw(g.width,g.height),Q=B.width,w=B.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 $D(e,{width:Q,height:w})});if(Dn(A)){var C=A.detection.forSize(Q,w),E=A.unshiftedLandmarks.forSize(C.box.width,C.box.height);return Le(AE(A,C),E)}return je(A)?AE(A,A.detection.forSize(Q,w)):A instanceof wC||A instanceof mg?A.forSize(Q,w):A}class vv{getVideoStreamConfig(g,B){return{audio:!1,video:{width:{min:g,ideal:g},height:{min:B,ideal:B},facingMode:"environment"}}}getContourCoordinate(g,B){return{x:g*.25,y:B*.05,width:g*.5,height:B*.9}}getBoxData(g){return g?{x:g.x,y:g.y,width:g.width,height:g.height}:null}setStylesForCanvas(g){g.width="100%",g.height="100%",g.style.position="absolute",g.style.top="0",g.style.left="0"}checkFaceInclusion(g,B){if(!g||!B||B.width>g.width||B.height>g.height)return!1;const Q=B.x,w=B.x+B.width,C=B.y,E=B.y+B.height,e=g.x,I=g.x+g.width,t=g.y,n=g.y+g.height;return Q>=e&&w<=I&&C>=t&&E<=n}async getFaceDetections(g,B){if(!g)return[];const Q=new VD({inputSize:B});return Rv(g,Q).withFaceLandmarks(!0)}getCanvas(g){return ye(g)}getResizedAndDetection(g,B,Q,w,C){eP(g,{width:w,height:C});const E=$D(B,{width:w,height:C});Q.clearRect(0,0,w,C),AP(g,E),rP(g,E)}async getFaceSnapshot(g,B){const Q=[new ke(B.x,B.y,B.width,B.height)],w=await We(g,Q);return w.length?w[0].toDataURL("image/jpeg").replace(/^data:image\/\w+;base64,/,""):null}async initModels(){let g=new Date;console.log(g);try{await Promise.all([Ug.tinyFaceDetector.loadFromUri("/models"),Ug.faceLandmark68TinyNet.loadFromUri("/models")])}catch(B){console.error(B)}g=new Date,console.log(g)}}let Tn;function kv(){return Tn||(Tn=new vv),Tn}function Tv(A){const g=o.ref(""),B=o.ref(1),Q=async(E="",e=1)=>{await A.initialize({search:E,page:e})},w=async E=>{g.value=E,B.value=1,await Q(E,B.value)},C=async E=>{B.value=E,await Q(g.value,E)};return o.watch(()=>A.columnFilters.value,async()=>{B.value=1,await Q(g.value,B.value)},{deep:!0}),o.onMounted(()=>Q(g.value,B.value)),{search:g,currentPage:B,loading:A.loading,handleSearch:w,handlePageChange:C,loadTable:Q}}const jv=A=>{const g=o.ref({}),B=o.ref({});A.columns.forEach(({name:I,filterType:t})=>{t&&(g.value[I]=t==="multi"?[]:void 0,B.value[I]=!1)});const Q=o.computed(()=>Array.isArray(A.rows)?A.rows:A.rows.value),w=(I,t)=>{const n=A.columns.find(i=>i.name===I);if((n==null?void 0:n.filterType)==="multi"){const i=g.value[I],c=i.indexOf(t);c>-1?i.splice(c,1):i.push(t),g.value[I]=[...i]}else g.value[I]=t,B.value[I]=!1},C=o.computed(()=>{var t;const I={};for(const n of A.columns){const i=g.value[n.name],c=((t=A.filtersOptions)==null?void 0:t.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),I[n.name]=Array.from(new Set(Y))}}return I}),E=I=>{const t=A.columns.find(n=>n.name===I);g.value[I]=(t==null?void 0:t.filterType)==="multi"?[]:void 0},e=(I,t)=>{B.value[I]=t};return{rows:Q,columns:o.computed(()=>A.columns),columnFilters:g,filterMenus:B,toggleFilterValue:w,clearFilter:E,openFilterMenu:e,selectedFilters:C}};function pv(A,g=[]){const B=o.ref([...new Set([...g,...A.map(C=>C.name)])]),Q=o.computed(()=>A.filter(C=>B.value.includes(C.name)));function w(C){C.dialog({title:"Выберите колонки",options:{type:"checkbox",model:[...B.value],items:A.map(E=>({label:E.label,value:E.name,disable:g.includes(E.name)}))},cancel:!0,persistent:!0}).onOk(E=>{B.value=Array.from(new Set([...E,...g]))})}return{selectedColumnNames:B,visibleColumns:Q,openColumnSelectorDialog:w}}hA.ApiService=Bg,hA.AppButton=DE,hA.AppCheckbox=Aa,hA.AppConfirmDialog=bl,hA.AppDatePicker=Ua,hA.AppDatepicker=Za,hA.AppDropdown=xl,hA.AppInput=qa,hA.AppInputNew=ac,hA.AppInputSearch=_a,hA.AppLayout=Qs,hA.AppLayoutHeader=yU,hA.AppLayoutPage=SU,hA.AppLoader=hc,hA.AppModalSelect=zc,hA.AppSelect=ZU,hA.AppSheet=wl,hA.AppSheetNew=al,hA.AppSidebar=dl,hA.AppTable=qc,hA.AppTableLayout=wG,hA.AppTableModal=oh,hA.AppTablePagination=pc,hA.AppTableSearch=yc,hA.AppToggle=Hl,hA.AppWrapper=Nl,hA.base64ToBlob=Va,hA.isEqual=UC,hA.normalizeValue=Pw,hA.notificationSettings=xI,hA.useAuthService=yd,hA.useBaseTable=Tv,hA.useBrigadesService=CH,hA.useColumnSelector=pv,hA.useCommentsService=BH,hA.useControlsService=Od,hA.useEquipmentService=QH,hA.useFaceApiHelper=kv,hA.useFileService=Wd,hA.useGanttService=Jd,hA.useInstrumentsService=xd,hA.useMetricsService=Nd,hA.useModulesService=$d,hA.useProjectsService=Pd,hA.useRepairsService=kd,hA.useSearchService=qd,hA.useTableModel=jv,hA.useTasksService=jd,hA.useUserService=Vd,hA.useVideoService=Sd,hA.uuidv4=KI,Object.defineProperty(hA,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -63,14 +63,23 @@ export const useTableModel = <T = any>(model: TableModel<T>) => {
|
|
|
63
63
|
const options = model.filtersOptions?.value[col.name] || []
|
|
64
64
|
|
|
65
65
|
if (filter) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
let selectedIds: string[] = []
|
|
67
|
+
if (Array.isArray(filter)) {
|
|
68
|
+
selectedIds = options
|
|
69
|
+
.filter(opt => filter.includes(opt.name))
|
|
70
|
+
.map(opt => opt.id)
|
|
71
|
+
} else {
|
|
72
|
+
selectedIds = options
|
|
73
|
+
.filter(opt => opt.name === filter)
|
|
74
|
+
.map(opt => opt.id)
|
|
75
|
+
}
|
|
76
|
+
result[col.name] = Array.from(new Set(selectedIds))
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
79
|
return result
|
|
72
80
|
})
|
|
73
81
|
|
|
82
|
+
|
|
74
83
|
const clearFilter = (colName: string) => {
|
|
75
84
|
const col = model.columns.find(c => c.name === colName)
|
|
76
85
|
columnFilters.value[colName] = col?.filterType === 'multi' ? [] : undefined
|