sy-form-designer 1.0.40 → 1.0.42
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/{designer-XAwduzCu.js → designer-Cw_MG8GV.js} +1 -1
- package/{index-CfdfXSEs.js → index-Cadt3iGE.js} +3 -3
- package/{index-BTOl7UhI.js → index-DsH4RZwg.js} +1 -1
- package/{index-B6tYXIor.js → index-DvIP0lLx.js} +1 -1
- package/{index-DkNX9gXh.js → index-IeR0F5G0.js} +1 -1
- package/index.js +1 -1
- package/index.umd.cjs +1 -1
- package/{ossHook-DLvN1mVd.js → ossHook-BGpFtZIi.js} +3 -3
- package/package.json +1 -2
- package/{render-C0ldmEAc.js → render-DePV8fxO.js} +2 -2
- package/{settings-DwGUyK66.js → settings-DXzHXi7_.js} +1 -1
- package/{widgets-BnkKCmxu.js → widgets-CznMzlHI.js} +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeModels as Q, useModel as X, ref as a, computed as Y, onMounted as Z, provide as S, resolveComponent as n, createElementBlock as U, openBlock as _, createVNode as o, withCtx as l, createElementVNode as c, createTextVNode as s, createBlock as J, createCommentVNode as h, Fragment as ee, renderList as oe } from "vue";
|
|
2
|
-
import le from "./settings-
|
|
2
|
+
import le from "./settings-DXzHXi7_.js";
|
|
3
3
|
import { _ as te } from "./index-DYcISXeA.js";
|
|
4
4
|
const ne = { class: "form-designer" }, ae = { class: "toolbar-container" }, de = {
|
|
5
5
|
class: "right-toolbar",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useAttrs as ae, ref as x, computed as re, inject as de, watch as I, resolveComponent as B, createElementBlock as c, openBlock as r, createElementVNode as f, createCommentVNode as h, createBlock as N, createVNode as v, mergeProps as ue, unref as y, withCtx as O, normalizeStyle as E, normalizeClass as ce, Fragment as m, renderList as fe, createTextVNode as p, toDisplayString as k, withDirectives as U, withModifiers as j, vShow as C } from "vue";
|
|
2
|
-
import { u as he } from "./ossHook-
|
|
3
|
-
import { p as ge } from "./index-
|
|
2
|
+
import { u as he } from "./ossHook-BGpFtZIi.js";
|
|
3
|
+
import { p as ge } from "./index-IeR0F5G0.js";
|
|
4
4
|
import { _ as ve } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
5
|
-
import { E as L } from "./index-
|
|
5
|
+
import { E as L } from "./index-DvIP0lLx.js";
|
|
6
6
|
const me = { class: "component-upload-image" }, pe = { style: { display: "flex", width: "100%" } }, ye = {
|
|
7
7
|
key: 0,
|
|
8
8
|
class: "relative rounded overflow-hidden flex justify-center items-center",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useAttrs as N, ref as c, computed as j, inject as L, watch as M, resolveComponent as m, createElementBlock as f, openBlock as u, createVNode as U, mergeProps as z, unref as o, withCtx as y, createCommentVNode as g, createTextVNode as d, Fragment as b, createElementVNode as p, toDisplayString as h, renderSlot as A, createBlock as O } from "vue";
|
|
2
|
-
import { u as _ } from "./ossHook-
|
|
2
|
+
import { u as _ } from "./ossHook-BGpFtZIi.js";
|
|
3
3
|
const C = { class: "w-full" }, D = { class: "flex justify-center" }, E = {
|
|
4
4
|
key: 0,
|
|
5
5
|
class: "el-upload__tip font-bold"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getCurrentInstance as B, inject as z, ref as O, computed as d, unref as l, watch as W, isRef as ct, warn as ut, provide as dt, defineComponent as $, createElementBlock as U, openBlock as T, mergeProps as pt, renderSlot as L, normalizeClass as I, createVNode as se, Transition as je, withCtx as H, withDirectives as Me, createElementVNode as re, normalizeStyle as De, createTextVNode as ft, toDisplayString as Fe, vShow as Ae, shallowReactive as gt, onMounted as mt, createBlock as F, createCommentVNode as R, resolveDynamicComponent as yt, Fragment as ht, withModifiers as vt, isVNode as Be, render as ge } from "vue";
|
|
2
|
-
import { i as bt, n as _t, r as Le, t as ke, d as Y, e as Ct, f as Ot, g as Z, h as N, j as Ve, k as me, l as J, m as wt, o as St, q as Tt, s as It, w as xt, v as Nt, x as Et, y as $t, z as Pt, A as ye } from "./index-
|
|
2
|
+
import { i as bt, n as _t, r as Le, t as ke, d as Y, e as Ct, f as Ot, g as Z, h as N, j as Ve, k as me, l as J, m as wt, o as St, q as Tt, s as It, w as xt, v as Nt, x as Et, y as $t, z as Pt, A as ye } from "./index-IeR0F5G0.js";
|
|
3
3
|
const Ke = Symbol(), G = "el", zt = "is-", x = (e, n, t, o, r) => {
|
|
4
4
|
let s = `${e}-${n}`;
|
|
5
5
|
return t && (s += `-${t}`), o && (s += `__${o}`), r && (s += `--${r}`), s;
|
|
@@ -4502,7 +4502,7 @@ function po(e, t) {
|
|
|
4502
4502
|
getFieldInfo: u
|
|
4503
4503
|
};
|
|
4504
4504
|
}
|
|
4505
|
-
const Eo = /* @__PURE__ */ Object.assign({ "./libs/panels/render.jsx": () => import("./render-
|
|
4505
|
+
const Eo = /* @__PURE__ */ Object.assign({ "./libs/panels/render.jsx": () => import("./render-DePV8fxO.js"), "./libs/panels/settings.vue": () => import("./settings-DXzHXi7_.js"), "./libs/panels/widgets.vue": () => import("./widgets-CznMzlHI.js") }), Er = /* @__PURE__ */ Object.assign({ "./libs/designer.vue": () => import("./designer-Cw_MG8GV.js") }), go = /* @__PURE__ */ Object.assign({ "./libs/extensions/file-upload/index.vue": () => import("./index-DsH4RZwg.js"), "./libs/extensions/image-view/index.vue": () => import("./index-DWYaW2hS.js"), "./libs/extensions/picture-upload/index.vue": () => import("./index-Cadt3iGE.js"), "./libs/extensions/svg-icon/index.vue": () => import("./index-BFhlK9cb.js"), "./libs/extensions/tooth-selector/index.vue": () => import("./index-BoOIQKIO.js") }), ho = /* @__PURE__ */ Object.assign({ "./libs/condition-editor/index.vue": () => import("./index-DmjTLesN.js") }), vo = (e) => {
|
|
4506
4506
|
for (const [t, n] of Object.entries(Eo)) {
|
|
4507
4507
|
const r = t.slice(t.lastIndexOf("/") + 1, t.lastIndexOf("."));
|
|
4508
4508
|
e.component("sy-" + r, ze(n));
|
package/index.js
CHANGED
package/index.umd.cjs
CHANGED
|
@@ -4967,4 +4967,4 @@ Manifest JSON has weights with names: `+Ke.join(", ")+".");return Je=Ge.reduce(f
|
|
|
4967
4967
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
4968
4968
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
4969
4969
|
PERFORMANCE OF THIS SOFTWARE.
|
|
4970
|
-
***************************************************************************** */var extendStatics=function(m,y){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,$e){v.__proto__=$e}||function(v,$e){for(var je in $e)$e.hasOwnProperty(je)&&(v[je]=$e[je])},extendStatics(m,y)};function __extends(m,y){extendStatics(m,y);function v(){this.constructor=m}m.prototype=y===null?Object.create(y):(v.prototype=y.prototype,new v)}var __assign=function(){return __assign=Object.assign||function(y){for(var v,$e=1,je=arguments.length;$e<je;$e++){v=arguments[$e];for(var Ge in v)Object.prototype.hasOwnProperty.call(v,Ge)&&(y[Ge]=v[Ge])}return y},__assign.apply(this,arguments)};function __awaiter(m,y,v,$e){function je(Ge){return Ge instanceof v?Ge:new v(function(Ye){Ye(Ge)})}return new(v||(v=Promise))(function(Ge,Ye){function qe(Je){try{Qe($e.next(Je))}catch(st){Ye(st)}}function Ke(Je){try{Qe($e.throw(Je))}catch(st){Ye(st)}}function Qe(Je){Je.done?Ge(Je.value):je(Je.value).then(qe,Ke)}Qe(($e=$e.apply(m,[])).next())})}function __generator(m,y){var v={label:0,sent:function(){if(Ge[0]&1)throw Ge[1];return Ge[1]},trys:[],ops:[]},$e,je,Ge,Ye;return Ye={next:qe(0),throw:qe(1),return:qe(2)},typeof Symbol=="function"&&(Ye[Symbol.iterator]=function(){return this}),Ye;function qe(Qe){return function(Je){return Ke([Qe,Je])}}function Ke(Qe){if($e)throw new TypeError("Generator is already executing.");for(;v;)try{if($e=1,je&&(Ge=Qe[0]&2?je.return:Qe[0]?je.throw||((Ge=je.return)&&Ge.call(je),0):je.next)&&!(Ge=Ge.call(je,Qe[1])).done)return Ge;switch(je=0,Ge&&(Qe=[Qe[0]&2,Ge.value]),Qe[0]){case 0:case 1:Ge=Qe;break;case 4:return v.label++,{value:Qe[1],done:!1};case 5:v.label++,je=Qe[1],Qe=[0];continue;case 7:Qe=v.ops.pop(),v.trys.pop();continue;default:if(Ge=v.trys,!(Ge=Ge.length>0&&Ge[Ge.length-1])&&(Qe[0]===6||Qe[0]===2)){v=0;continue}if(Qe[0]===3&&(!Ge||Qe[1]>Ge[0]&&Qe[1]<Ge[3])){v.label=Qe[1];break}if(Qe[0]===6&&v.label<Ge[1]){v.label=Ge[1],Ge=Qe;break}if(Ge&&v.label<Ge[2]){v.label=Ge[2],v.ops.push(Qe);break}Ge[2]&&v.ops.pop(),v.trys.pop();continue}Qe=y.call(m,v)}catch(Je){Qe=[6,Je],je=0}finally{$e=Ge=0}if(Qe[0]&5)throw Qe[1];return{value:Qe[0]?Qe[1]:void 0,done:!0}}}function __spreadArrays(){for(var m=0,y=0,v=arguments.length;y<v;y++)m+=arguments[y].length;for(var $e=Array(m),je=0,y=0;y<v;y++)for(var Ge=arguments[y],Ye=0,qe=Ge.length;Ye<qe;Ye++,je++)$e[je]=Ge[Ye];return $e}var Dimensions=function(){function m(y,v){if(!isValidNumber(y)||!isValidNumber(v))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:y,height:v}));this._width=y,this._height=v}return Object.defineProperty(m.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),m.prototype.reverse=function(){return new m(1/this.width,1/this.height)},m}();function isTensor(m,y){return m instanceof wt&&m.shape.length===y}function isTensor2D(m){return isTensor(m,2)}function isTensor3D(m){return isTensor(m,3)}function isTensor4D(m){return isTensor(m,4)}function isFloat(m){return m%1!==0}function isEven(m){return m%2===0}function round(m,y){y===void 0&&(y=2);var v=Math.pow(10,y);return Math.floor(m*v)/v}function isDimensions(m){return m&&m.width&&m.height}function computeReshapedDimensions(m,y){var v=m.width,$e=m.height,je=y/Math.max($e,v);return new Dimensions(Math.round(v*je),Math.round($e*je))}function getCenterPoint(m){return m.reduce(function(y,v){return y.add(v)},new Point(0,0)).div(new Point(m.length,m.length))}function range(m,y,v){return Array(m).fill(0).map(function($e,je){return y+je*v})}function isValidNumber(m){return!!m&&m!==1/0&&m!==-1/0&&!isNaN(m)||m===0}function isValidProbablitiy(m){return isValidNumber(m)&&0<=m&&m<=1}var Point=function(){function m(y,v){this._x=y,this._y=v}return Object.defineProperty(m.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),m.prototype.add=function(y){return new m(this.x+y.x,this.y+y.y)},m.prototype.sub=function(y){return new m(this.x-y.x,this.y-y.y)},m.prototype.mul=function(y){return new m(this.x*y.x,this.y*y.y)},m.prototype.div=function(y){return new m(this.x/y.x,this.y/y.y)},m.prototype.abs=function(){return new m(Math.abs(this.x),Math.abs(this.y))},m.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},m.prototype.floor=function(){return new m(Math.floor(this.x),Math.floor(this.y))},m}(),Box=function(){function m(y,v){v===void 0&&(v=!0);var $e=y||{},je=[$e.left,$e.top,$e.right,$e.bottom].every(isValidNumber),Ge=[$e.x,$e.y,$e.width,$e.height].every(isValidNumber);if(!Ge&&!je)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify($e));var Ye=Ge?[$e.x,$e.y,$e.width,$e.height]:[$e.left,$e.top,$e.right-$e.left,$e.bottom-$e.top],qe=Ye[0],Ke=Ye[1],Qe=Ye[2],Je=Ye[3];m.assertIsValidBox({x:qe,y:Ke,width:Qe,height:Je},"Box.constructor",v),this._x=qe,this._y=Ke,this._width=Qe,this._height=Je}return m.isRect=function(y){return!!y&&[y.x,y.y,y.width,y.height].every(isValidNumber)},m.assertIsValidBox=function(y,v,$e){if($e===void 0&&($e=!1),!m.isRect(y))throw new Error(v+" - invalid box: "+JSON.stringify(y)+", expected object with properties x, y, width, height");if(!$e&&(y.width<0||y.height<0))throw new Error(v+" - width ("+y.width+") and height ("+y.height+") must be positive numbers")},Object.defineProperty(m.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"topLeft",{get:function(){return new Point(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"topRight",{get:function(){return new Point(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"bottomLeft",{get:function(){return new Point(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"bottomRight",{get:function(){return new Point(this.right,this.bottom)},enumerable:!0,configurable:!0}),m.prototype.round=function(){var y=[this.x,this.y,this.width,this.height].map(function(Ye){return Math.round(Ye)}),v=y[0],$e=y[1],je=y[2],Ge=y[3];return new m({x:v,y:$e,width:je,height:Ge})},m.prototype.floor=function(){var y=[this.x,this.y,this.width,this.height].map(function(Ye){return Math.floor(Ye)}),v=y[0],$e=y[1],je=y[2],Ge=y[3];return new m({x:v,y:$e,width:je,height:Ge})},m.prototype.toSquare=function(){var y=this,v=y.x,$e=y.y,je=y.width,Ge=y.height,Ye=Math.abs(je-Ge);return je<Ge&&(v-=Ye/2,je+=Ye),Ge<je&&($e-=Ye/2,Ge+=Ye),new m({x:v,y:$e,width:je,height:Ge})},m.prototype.rescale=function(y){var v=isDimensions(y)?y.width:y,$e=isDimensions(y)?y.height:y;return new m({x:this.x*v,y:this.y*$e,width:this.width*v,height:this.height*$e})},m.prototype.pad=function(y,v){var $e=[this.x-y/2,this.y-v/2,this.width+y,this.height+v],je=$e[0],Ge=$e[1],Ye=$e[2],qe=$e[3];return new m({x:je,y:Ge,width:Ye,height:qe})},m.prototype.clipAtImageBorders=function(y,v){var $e=this,je=$e.x,Ge=$e.y,Ye=$e.right,qe=$e.bottom,Ke=Math.max(je,0),Qe=Math.max(Ge,0),Je=Ye-Ke,st=qe-Qe,Mt=Math.min(Je,y-Ke),nn=Math.min(st,v-Qe);return new m({x:Ke,y:Qe,width:Mt,height:nn}).floor()},m.prototype.shift=function(y,v){var $e=this,je=$e.width,Ge=$e.height,Ye=this.x+y,qe=this.y+v;return new m({x:Ye,y:qe,width:je,height:Ge})},m.prototype.padAtBorders=function(y,v){var $e=this.width+1,je=this.height+1,Ge=1,Ye=1,qe=$e,Ke=je,Qe=this.left,Je=this.top,st=this.right,Mt=this.bottom;return st>v&&(qe=-st+v+$e,st=v),Mt>y&&(Ke=-Mt+y+je,Mt=y),Qe<1&&(Ke=2-Qe,Qe=1),Je<1&&(Ke=2-Je,Je=1),{dy:Ye,edy:Ke,dx:Ge,edx:qe,y:Je,ey:Mt,x:Qe,ex:st,w:$e,h:je}},m.prototype.calibrate=function(y){return new m({left:this.left+y.left*this.width,top:this.top+y.top*this.height,right:this.right+y.right*this.width,bottom:this.bottom+y.bottom*this.height}).toSquare().round()},m}(),BoundingBox=function(m){__extends(y,m);function y(v,$e,je,Ge,Ye){return Ye===void 0&&(Ye=!1),m.call(this,{left:v,top:$e,right:je,bottom:Ge},Ye)||this}return y}(Box),ObjectDetection=function(){function m(y,v,$e,je,Ge){this._imageDims=new Dimensions(Ge.width,Ge.height),this._score=y,this._classScore=v,this._className=$e,this._box=new Box(je).rescale(this._imageDims)}return Object.defineProperty(m.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"relativeBox",{get:function(){return new Box(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),m.prototype.forSize=function(y,v){return new m(this.score,this.classScore,this.className,this.relativeBox,{width:y,height:v})},m}(),FaceDetection=function(m){__extends(y,m);function y(v,$e,je){return m.call(this,v,v,"",$e,je)||this}return y.prototype.forSize=function(v,$e){var je=m.prototype.forSize.call(this,v,$e),Ge=je.score,Ye=je.relativeBox,qe=je.imageDims;return new y(Ge,Ye,qe)},y}(ObjectDetection);function iou(m,y,v){v===void 0&&(v=!0);var $e=Math.max(0,Math.min(m.right,y.right)-Math.max(m.left,y.left)),je=Math.max(0,Math.min(m.bottom,y.bottom)-Math.max(m.top,y.top)),Ge=$e*je;return v?Ge/(m.area+y.area-Ge):Ge/Math.min(m.area,y.area)}function minBbox(m){var y=m.map(function(qe){return qe.x}),v=m.map(function(qe){return qe.y}),$e=y.reduce(function(qe,Ke){return Ke<qe?Ke:qe},1/0),je=v.reduce(function(qe,Ke){return Ke<qe?Ke:qe},1/0),Ge=y.reduce(function(qe,Ke){return qe<Ke?Ke:qe},0),Ye=v.reduce(function(qe,Ke){return qe<Ke?Ke:qe},0);return new BoundingBox($e,je,Ge,Ye)}function nonMaxSuppression$1(m,y,v,$e){$e===void 0&&($e=!0);for(var je=y.map(function(qe,Ke){return{score:qe,boxIndex:Ke}}).sort(function(qe,Ke){return qe.score-Ke.score}).map(function(qe){return qe.boxIndex}),Ge=[],Ye=function(){var qe=je.pop();Ge.push(qe);for(var Ke=je,Qe=[],Je=0;Je<Ke.length;Je++){var st=Ke[Je],Mt=m[qe],nn=m[st];Qe.push(iou(Mt,nn,$e))}je=je.filter(function(rn,on){return Qe[on]<=v})};je.length>0;)Ye();return Ge}function normalize$1(m,y){return Ze(function(){var v=y[0],$e=y[1],je=y[2],Ge=Hn(__spreadArrays(m.shape.slice(0,3),[1]),v),Ye=Hn(__spreadArrays(m.shape.slice(0,3),[1]),$e),qe=Hn(__spreadArrays(m.shape.slice(0,3),[1]),je),Ke=Yn([Ge,Ye,qe],3);return Cc(m,Ke)})}function padToSquare(m,y){return y===void 0&&(y=!1),Ze(function(){var v=m.shape.slice(1),$e=v[0],je=v[1];if($e===je)return m;var Ge=Math.abs($e-je),Ye=Math.round(Ge*(y?.5:1)),qe=$e>je?2:1,Ke=function(nn){var rn=m.shape.slice();return rn[qe]=nn,Hn(rn,0)},Qe=Ke(Ye),Je=Ge-Qe.shape[qe],st=y&&Je?Ke(Je):null,Mt=[st,m,Qe].filter(function(nn){return!!nn}).map(function(nn){return nn.toFloat()});return Yn(Mt,qe)})}function sigmoid(m){return 1/(1+Math.exp(-m))}var Rect=function(m){__extends(y,m);function y(v,$e,je,Ge,Ye){return Ye===void 0&&(Ye=!1),m.call(this,{x:v,y:$e,width:je,height:Ge},Ye)||this}return y}(Box),relX=.5,relY=.43,relScale=.45,FaceLandmarks=function(){function m(y,v,$e){$e===void 0&&($e=new Point(0,0));var je=v.width,Ge=v.height;this._imgDims=new Dimensions(je,Ge),this._shift=$e,this._positions=y.map(function(Ye){return Ye.mul(new Point(je,Ge)).add($e)})}return Object.defineProperty(m.prototype,"shift",{get:function(){return new Point(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"relativePositions",{get:function(){var y=this;return this._positions.map(function(v){return v.sub(y._shift).div(new Point(y.imageWidth,y.imageHeight))})},enumerable:!0,configurable:!0}),m.prototype.forSize=function(y,v){return new this.constructor(this.relativePositions,{width:y,height:v})},m.prototype.shiftBy=function(y,v){return new this.constructor(this.relativePositions,this._imgDims,new Point(y,v))},m.prototype.shiftByPoint=function(y){return this.shiftBy(y.x,y.y)},m.prototype.align=function(y,v){if(v===void 0&&(v={}),y){var $e=y instanceof FaceDetection?y.box.floor():new Box(y);return this.shiftBy($e.x,$e.y).align(null,v)}var je=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},v),Ge=je.useDlibAlignment,Ye=je.minBoxPadding;return Ge?this.alignDlib():this.alignMinBbox(Ye)},m.prototype.alignDlib=function(){var y=this.getRefPointsForAlignment(),v=y[0],$e=y[1],je=y[2],Ge=function(st){return je.sub(st).magnitude()},Ye=(Ge(v)+Ge($e))/2,qe=Math.floor(Ye/relScale),Ke=getCenterPoint(y),Qe=Math.floor(Math.max(0,Ke.x-relX*qe)),Je=Math.floor(Math.max(0,Ke.y-relY*qe));return new Rect(Qe,Je,Math.min(qe,this.imageWidth+Qe),Math.min(qe,this.imageHeight+Je))},m.prototype.alignMinBbox=function(y){var v=minBbox(this.positions);return v.pad(v.width*y,v.height*y)},m.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},m}(),FaceLandmarks5=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.getRefPointsForAlignment=function(){var v=this.positions;return[v[0],v[1],getCenterPoint([v[3],v[4]])]},y}(FaceLandmarks),FaceLandmarks68=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.getJawOutline=function(){return this.positions.slice(0,17)},y.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},y.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},y.prototype.getNose=function(){return this.positions.slice(27,36)},y.prototype.getLeftEye=function(){return this.positions.slice(36,42)},y.prototype.getRightEye=function(){return this.positions.slice(42,48)},y.prototype.getMouth=function(){return this.positions.slice(48,68)},y.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(getCenterPoint)},y}(FaceLandmarks),FaceMatch=function(){function m(y,v){this._label=y,this._distance=v}return Object.defineProperty(m.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),m.prototype.toString=function(y){return y===void 0&&(y=!0),""+this.label+(y?" ("+round(this.distance)+")":"")},m}(),LabeledBox=function(m){__extends(y,m);function y(v,$e){var je=m.call(this,v)||this;return je._label=$e,je}return y.assertIsValidLabeledBox=function(v,$e){if(Box.assertIsValidBox(v,$e),!isValidNumber(v.label))throw new Error($e+" - expected property label ("+v.label+") to be a number")},Object.defineProperty(y.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),y}(Box),LabeledFaceDescriptors=function(){function m(y,v){if(typeof y!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(v)||v.some(function($e){return!($e instanceof Float32Array)}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=y,this._descriptors=v}return Object.defineProperty(m.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),m.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map(function(y){return Array.from(y)})}},m.fromJSON=function(y){var v=y.descriptors.map(function($e){return new Float32Array($e)});return new m(y.label,v)},m}();(function(m){__extends(y,m);function y(v,$e,je,Ge){var Ye=m.call(this,v,$e)||this;return Ye._score=je,Ye._classScore=Ge,Ye}return y.assertIsValidPredictedBox=function(v,$e){if(LabeledBox.assertIsValidLabeledBox(v,$e),!isValidProbablitiy(v.score)||!isValidProbablitiy(v.classScore))throw new Error($e+" - expected properties score ("+v.score+") and ("+v.classScore+") to be a number between [0, 1]")},Object.defineProperty(y.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),y})(LabeledBox);function isWithFaceDetection(m){return m.detection instanceof FaceDetection}function extendWithFaceDetection(m,y){var v={detection:y};return Object.assign({},m,v)}function createBrowserEnv(){var m=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")},y=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:m,readFile:y}}function createFileSystem(m){var y="";if(!m)try{m=require("fs")}catch($e){y=$e.toString()}var v=m?function($e){return new Promise(function(je,Ge){m.readFile($e,function(Ye,qe){return Ye?Ge(Ye):je(qe)})})}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+y)};return{readFile:v}}function createNodejsEnv(){var m=global.Canvas||global.HTMLCanvasElement,y=global.Image||global.HTMLImageElement,v=function(){if(m)return new m;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},$e=function(){if(y)return new y;throw new Error("createImageElement - missing Image implementation for nodejs environment")},je=global.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},Ge=createFileSystem();return __assign({Canvas:m||function(){function Ye(){}return Ye}(),CanvasRenderingContext2D:global.CanvasRenderingContext2D||function(){function Ye(){}return Ye}(),Image:y||function(){function Ye(){}return Ye}(),ImageData:global.ImageData||function(){function Ye(){}return Ye}(),Video:global.HTMLVideoElement||function(){function Ye(){}return Ye}(),createCanvasElement:v,createImageElement:$e,fetch:je},Ge)}function isBrowser(){return typeof window=="object"&&typeof document<"u"&&typeof HTMLImageElement<"u"&&typeof HTMLCanvasElement<"u"&&typeof HTMLVideoElement<"u"&&typeof ImageData<"u"&&typeof CanvasRenderingContext2D<"u"}function isNodejs(){return typeof global=="object"&&typeof require=="function"&&typeof module<"u"&&typeof process<"u"&&!!process.version}var environment;function getEnv(){if(!environment)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return environment}function setEnv(m){environment=m}function initialize(){isBrowser()&&setEnv(createBrowserEnv()),isNodejs()&&setEnv(createNodejsEnv())}function monkeyPatch(m){if(environment||initialize(),!environment)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var y=m.Canvas,v=y===void 0?environment.Canvas:y,$e=m.Image,je=$e===void 0?environment.Image:$e;environment.Canvas=v,environment.Image=je,environment.createCanvasElement=m.createCanvasElement||function(){return new v},environment.createImageElement=m.createImageElement||function(){return new je},environment.ImageData=m.ImageData||environment.ImageData,environment.Video=m.Video||environment.Video,environment.fetch=m.fetch||environment.fetch,environment.readFile=m.readFile||environment.readFile}var env={getEnv,setEnv,initialize,createBrowserEnv,createFileSystem,createNodejsEnv,monkeyPatch,isBrowser,isNodejs};initialize();function resolveInput(m){return!env.isNodejs()&&typeof m=="string"?document.getElementById(m):m}function getContext2dOrThrow(m){var y=env.getEnv(),v=y.Canvas,$e=y.CanvasRenderingContext2D;if(m instanceof $e)return m;var je=resolveInput(m);if(!(je instanceof v))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var Ge=je.getContext("2d");if(!Ge)throw new Error("resolveContext2d - canvas 2d context is null");return Ge}var AnchorPosition;(function(m){m.TOP_LEFT="TOP_LEFT",m.TOP_RIGHT="TOP_RIGHT",m.BOTTOM_LEFT="BOTTOM_LEFT",m.BOTTOM_RIGHT="BOTTOM_RIGHT"})(AnchorPosition||(AnchorPosition={}));function isMediaLoaded(m){var y=env.getEnv(),v=y.Image,$e=y.Video;return m instanceof v&&m.complete||m instanceof $e&&m.readyState>=3}function awaitMediaLoaded(m){return new Promise(function(y,v){if(m instanceof env.getEnv().Canvas||isMediaLoaded(m))return y();function $e(Ge){Ge.currentTarget&&(Ge.currentTarget.removeEventListener("load",$e),Ge.currentTarget.removeEventListener("error",je),y(Ge))}function je(Ge){Ge.currentTarget&&(Ge.currentTarget.removeEventListener("load",$e),Ge.currentTarget.removeEventListener("error",je),v(Ge))}m.addEventListener("load",$e),m.addEventListener("error",je)})}function getMediaDimensions(m){var y=env.getEnv(),v=y.Image,$e=y.Video;return m instanceof v?new Dimensions(m.naturalWidth,m.naturalHeight):m instanceof $e?new Dimensions(m.videoWidth,m.videoHeight):new Dimensions(m.width,m.height)}function createCanvas(m){var y=m.width,v=m.height,$e=env.getEnv().createCanvasElement,je=$e();return je.width=y,je.height=v,je}function createCanvasFromMedia(m,y){var v=env.getEnv().ImageData;if(!(m instanceof v)&&!isMediaLoaded(m))throw new Error("createCanvasFromMedia - media has not finished loading yet");var $e=getMediaDimensions(m),je=$e.width,Ge=$e.height,Ye=createCanvas({width:je,height:Ge});return m instanceof v?getContext2dOrThrow(Ye).putImageData(m,0,0):getContext2dOrThrow(Ye).drawImage(m,0,0,je,Ge),Ye}function imageTensorToCanvas(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye,qe;return __generator(this,function(Ke){switch(Ke.label){case 0:return v=env.getEnv().createCanvasElement(),$e=m.shape.slice(isTensor4D(m)?1:0),je=$e[0],Ge=$e[1],Ye=$e[2],qe=Ze(function(){return m.as3D(je,Ge,Ye).toInt()}),[4,id.toPixels(qe,v)];case 1:return Ke.sent(),qe.dispose(),[2,v]}})})}function isMediaElement(m){var y=env.getEnv(),v=y.Image,$e=y.Canvas,je=y.Video;return m instanceof v||m instanceof $e||m instanceof je}function imageToSquare(m,y,v){v===void 0&&(v=!1);var $e=env.getEnv(),je=$e.Image,Ge=$e.Canvas;if(!(m instanceof je||m instanceof Ge))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var Ye=getMediaDimensions(m),qe=y/Math.max(Ye.height,Ye.width),Ke=qe*Ye.width,Qe=qe*Ye.height,Je=createCanvas({width:y,height:y}),st=m instanceof Ge?m:createCanvasFromMedia(m),Mt=Math.abs(Ke-Qe)/2,nn=v&&Ke<Qe?Mt:0,rn=v&&Qe<Ke?Mt:0;return getContext2dOrThrow(Je).drawImage(st,nn,rn,Ke,Qe),Je}var NetInput=function(){function m(y,v){var $e=this;if(v===void 0&&(v=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(y))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+y);this._treatAsBatchInput=v,this._batchSize=y.length,y.forEach(function(je,Ge){if(isTensor3D(je)){$e._imageTensors[Ge]=je,$e._inputDimensions[Ge]=je.shape;return}if(isTensor4D(je)){var Ye=je.shape[0];if(Ye!==1)throw new Error("NetInput - tf.Tensor4D with batchSize "+Ye+" passed, but not supported in input array");$e._imageTensors[Ge]=je,$e._inputDimensions[Ge]=je.shape.slice(1);return}var qe=je instanceof env.getEnv().Canvas?je:createCanvasFromMedia(je);$e._canvases[Ge]=qe,$e._inputDimensions[Ge]=[qe.height,qe.width,3]})}return Object.defineProperty(m.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"reshapedInputDimensions",{get:function(){var y=this;return range(this.batchSize,0,1).map(function(v,$e){return y.getReshapedInputDimensions($e)})},enumerable:!0,configurable:!0}),m.prototype.getInput=function(y){return this.canvases[y]||this.imageTensors[y]},m.prototype.getInputDimensions=function(y){return this._inputDimensions[y]},m.prototype.getInputHeight=function(y){return this._inputDimensions[y][0]},m.prototype.getInputWidth=function(y){return this._inputDimensions[y][1]},m.prototype.getReshapedInputDimensions=function(y){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");var v=this.getInputWidth(y),$e=this.getInputHeight(y);return computeReshapedDimensions({width:v,height:$e},this.inputSize)},m.prototype.toBatchTensor=function(y,v){var $e=this;return v===void 0&&(v=!0),this._inputSize=y,Ze(function(){var je=range($e.batchSize,0,1).map(function(Ye){var qe=$e.getInput(Ye);if(qe instanceof wt){var Ke=isTensor4D(qe)?qe:qe.expandDims();return Ke=padToSquare(Ke,v),(Ke.shape[1]!==y||Ke.shape[2]!==y)&&(Ke=Oh.resizeBilinear(Ke,[y,y])),Ke.as3D(y,y,3)}if(qe instanceof env.getEnv().Canvas)return id.fromPixels(imageToSquare(qe,y,v));throw new Error("toBatchTensor - at batchIdx "+Ye+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+qe)}),Ge=Pr(je.map(function(Ye){return Ye.toFloat()})).as4D($e.batchSize,y,y,3);return Ge})},m}();function toNetInput(m){return __awaiter(this,void 0,void 0,function(){var y,v,$e;return __generator(this,function(je){switch(je.label){case 0:if(m instanceof NetInput)return[2,m];if(y=Array.isArray(m)?m:[m],!y.length)throw new Error("toNetInput - empty array passed as input");return v=function(Ge){return Array.isArray(m)?" at input index "+Ge+":":""},$e=y.map(resolveInput),$e.forEach(function(Ge,Ye){if(!isMediaElement(Ge)&&!isTensor3D(Ge)&&!isTensor4D(Ge))throw typeof y[Ye]=="string"?new Error("toNetInput -"+v(Ye)+" string passed, but could not resolve HTMLElement for element id "+y[Ye]):new Error("toNetInput -"+v(Ye)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");if(isTensor4D(Ge)){var qe=Ge.shape[0];if(qe!==1)throw new Error("toNetInput -"+v(Ye)+" tf.Tensor4D with batchSize "+qe+" passed, but not supported in input array")}}),[4,Promise.all($e.map(function(Ge){return isMediaElement(Ge)&&awaitMediaLoaded(Ge)}))];case 1:return je.sent(),[2,new NetInput($e,Array.isArray(m))]}})})}function extractFaces(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye,qe,Ke;return __generator(this,function(Qe){switch(Qe.label){case 0:return v=env.getEnv().Canvas,$e=m,m instanceof v?[3,5]:[4,toNetInput(m)];case 1:if(je=Qe.sent(),je.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return Ge=je.getInput(0),Ge instanceof v?(Ye=Ge,[3,4]):[3,2];case 2:return[4,imageTensorToCanvas(Ge)];case 3:Ye=Qe.sent(),Qe.label=4;case 4:$e=Ye,Qe.label=5;case 5:return qe=getContext2dOrThrow($e),Ke=y.map(function(Je){return Je instanceof FaceDetection?Je.forSize($e.width,$e.height).box.floor():Je}).map(function(Je){return Je.clipAtImageBorders($e.width,$e.height)}),[2,Ke.map(function(Je){var st=Je.x,Mt=Je.y,nn=Je.width,rn=Je.height,on=createCanvas({width:nn,height:rn});return getContext2dOrThrow(on).putImageData(qe.getImageData(st,Mt,nn,rn),0,0),on})]}})})}function extractFaceTensors(m,y){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(v){if(!isTensor3D(m)&&!isTensor4D(m))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(isTensor4D(m)&&m.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,Ze(function(){var $e=m.shape.slice(isTensor4D(m)?1:0),je=$e[0],Ge=$e[1],Ye=$e[2],qe=y.map(function(Qe){return Qe instanceof FaceDetection?Qe.forSize(Ge,je).box:Qe}).map(function(Qe){return Qe.clipAtImageBorders(Ge,je)}),Ke=qe.map(function(Qe){var Je=Qe.x,st=Qe.y,Mt=Qe.width,nn=Qe.height;return xl(m.as3D(je,Ge,Ye),[st,Je,0],[nn,Mt,Ye])});return Ke})]})})}function fetchOrThrow(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e;return __generator(this,function(je){switch(je.label){case 0:return v=env.getEnv().fetch,[4,v(m,y)];case 1:if($e=je.sent(),!($e.status<400))throw new Error("failed to fetch: ("+$e.status+") "+$e.statusText+", from url: "+$e.url);return[2,$e]}})})}function fetchJson(m){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(y){switch(y.label){case 0:return[4,fetchOrThrow(m)];case 1:return[2,y.sent().json()]}})})}function getModelUris(m,y){var v=y+"-weights_manifest.json";if(!m)return{modelBaseUri:"",manifestUri:v};if(m==="/")return{modelBaseUri:"/",manifestUri:"/"+v};var $e=m.startsWith("http://")?"http://":m.startsWith("https://")?"https://":"";m=m.replace($e,"");var je=m.split("/").filter(function(qe){return qe}),Ge=m.endsWith(".json")?je[je.length-1]:v,Ye=$e+(m.endsWith(".json")?je.slice(0,je.length-1):je).join("/");return Ye=m.startsWith("/")?"/"+Ye:Ye,{modelBaseUri:Ye,manifestUri:Ye==="/"?"/"+Ge:Ye+"/"+Ge}}function loadWeightMap(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge;return __generator(this,function(Ye){switch(Ye.label){case 0:return v=getModelUris(m,y),$e=v.manifestUri,je=v.modelBaseUri,[4,fetchJson($e)];case 1:return Ge=Ye.sent(),[2,ed.loadWeights(Ge,je)]}})})}var NeuralNetwork=function(){function m(y){this._name=y,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(m.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),m.prototype.getParamFromPath=function(y){var v=this.traversePropertyPath(y),$e=v.obj,je=v.objProp;return $e[je]},m.prototype.reassignParamFromPath=function(y,v){var $e=this.traversePropertyPath(y),je=$e.obj,Ge=$e.objProp;je[Ge].dispose(),je[Ge]=v},m.prototype.getParamList=function(){var y=this;return this._paramMappings.map(function(v){var $e=v.paramPath;return{path:$e,tensor:y.getParamFromPath($e)}})},m.prototype.getTrainableParams=function(){return this.getParamList().filter(function(y){return y.tensor instanceof St})},m.prototype.getFrozenParams=function(){return this.getParamList().filter(function(y){return!(y.tensor instanceof St)})},m.prototype.variable=function(){var y=this;this.getFrozenParams().forEach(function(v){var $e=v.path,je=v.tensor;y.reassignParamFromPath($e,je.variable())})},m.prototype.freeze=function(){var y=this;this.getTrainableParams().forEach(function(v){var $e=v.path,je=v.tensor,Ge=Fn(je.dataSync());je.dispose(),y.reassignParamFromPath($e,Ge)})},m.prototype.dispose=function(y){y===void 0&&(y=!0),this.getParamList().forEach(function(v){if(y&&v.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+v.path);v.tensor.dispose()}),this._params=void 0},m.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(y){var v=y.tensor;return Array.from(v.dataSync())}).reduce(function(y,v){return y.concat(v)}))},m.prototype.load=function(y){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(v){switch(v.label){case 0:return y instanceof Float32Array?(this.extractWeights(y),[2]):[4,this.loadFromUri(y)];case 1:return v.sent(),[2]}})})},m.prototype.loadFromUri=function(y){return __awaiter(this,void 0,void 0,function(){var v;return __generator(this,function($e){switch($e.label){case 0:if(y&&typeof y!="string")throw new Error(this._name+".loadFromUri - expected model uri");return[4,loadWeightMap(y,this.getDefaultModelName())];case 1:return v=$e.sent(),this.loadFromWeightMap(v),[2]}})})},m.prototype.loadFromDisk=function(y){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye,qe,Ke,Qe,Je,st;return __generator(this,function(Mt){switch(Mt.label){case 0:if(y&&typeof y!="string")throw new Error(this._name+".loadFromDisk - expected model file path");return v=env.getEnv().readFile,$e=getModelUris(y,this.getDefaultModelName()),je=$e.manifestUri,Ge=$e.modelBaseUri,Ye=function(nn){return Promise.all(nn.map(function(rn){return v(rn).then(function(on){return on.buffer})}))},qe=ed.weightsLoaderFactory(Ye),Je=(Qe=JSON).parse,[4,v(je)];case 1:return Ke=Je.apply(Qe,[Mt.sent().toString()]),[4,qe(Ke,Ge)];case 2:return st=Mt.sent(),this.loadFromWeightMap(st),[2]}})})},m.prototype.loadFromWeightMap=function(y){var v=this.extractParamsFromWeigthMap(y),$e=v.paramMappings,je=v.params;this._paramMappings=$e,this._params=je},m.prototype.extractWeights=function(y){var v=this.extractParams(y),$e=v.paramMappings,je=v.params;this._paramMappings=$e,this._params=je},m.prototype.traversePropertyPath=function(y){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var v=y.split("/").reduce(function(Ge,Ye){if(!Ge.nextObj.hasOwnProperty(Ye))throw new Error("traversePropertyPath - object does not have property "+Ye+", for path "+y);return{obj:Ge.nextObj,objProp:Ye,nextObj:Ge.nextObj[Ye]}},{nextObj:this.params}),$e=v.obj,je=v.objProp;if(!$e||!je||!($e[je]instanceof wt))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+y);return{obj:$e,objProp:je}},m}();function depthwiseSeparableConv$1(m,y,v){return Ze(function(){var $e=Jc(m,y.depthwise_filter,y.pointwise_filter,v,"same");return $e=rc($e,y.bias),$e})}function denseBlock3(m,y,v){return v===void 0&&(v=!1),Ze(function(){var $e=Bl(v?rc(qc(m,y.conv0.filters,[2,2],"same"),y.conv0.bias):depthwiseSeparableConv$1(m,y.conv0,[2,2])),je=depthwiseSeparableConv$1($e,y.conv1,[1,1]),Ge=Bl(rc($e,je)),Ye=depthwiseSeparableConv$1(Ge,y.conv2,[1,1]);return Bl(rc($e,rc(je,Ye)))})}function denseBlock4(m,y,v,$e){return v===void 0&&(v=!1),$e===void 0&&($e=!0),Ze(function(){var je=Bl(v?rc(qc(m,y.conv0.filters,$e?[2,2]:[1,1],"same"),y.conv0.bias):depthwiseSeparableConv$1(m,y.conv0,$e?[2,2]:[1,1])),Ge=depthwiseSeparableConv$1(je,y.conv1,[1,1]),Ye=Bl(rc(je,Ge)),qe=depthwiseSeparableConv$1(Ye,y.conv2,[1,1]),Ke=Bl(rc(je,rc(Ge,qe))),Qe=depthwiseSeparableConv$1(Ke,y.conv3,[1,1]);return Bl(rc(je,rc(Ge,rc(qe,Qe))))})}function convLayer$1(m,y,v,$e){return v===void 0&&(v="same"),$e===void 0&&($e=!1),Ze(function(){var je=rc(qc(m,y.filters,[1,1],v),y.bias);return $e?Bl(je):je})}function disposeUnusedWeightTensors(m,y){Object.keys(m).forEach(function(v){y.some(function($e){return $e.originalPath===v})||m[v].dispose()})}function extractConvParamsFactory(m,y){return function(v,$e,je,Ge){var Ye=Ln(m(v*$e*je*je),[je,je,v,$e]),qe=Mn(m($e));return y.push({paramPath:Ge+"/filters"},{paramPath:Ge+"/bias"}),{filters:Ye,bias:qe}}}function extractFCParamsFactory(m,y){return function(v,$e,je){var Ge=Bn(m(v*$e),[v,$e]),Ye=Mn(m($e));return y.push({paramPath:je+"/weights"},{paramPath:je+"/bias"}),{weights:Ge,bias:Ye}}}var SeparableConvParams=function(){function m(y,v,$e){this.depthwise_filter=y,this.pointwise_filter=v,this.bias=$e}return m}();function extractSeparableConvParamsFactory(m,y){return function(v,$e,je){var Ge=Ln(m(9*v),[3,3,v,1]),Ye=Ln(m(v*$e),[1,1,v,$e]),qe=Mn(m($e));return y.push({paramPath:je+"/depthwise_filter"},{paramPath:je+"/pointwise_filter"},{paramPath:je+"/bias"}),new SeparableConvParams(Ge,Ye,qe)}}function loadSeparableConvParamsFactory(m){return function(y){var v=m(y+"/depthwise_filter",4),$e=m(y+"/pointwise_filter",4),je=m(y+"/bias",1);return new SeparableConvParams(v,$e,je)}}function extractWeightEntryFactory(m,y){return function(v,$e,je){var Ge=m[v];if(!isTensor(Ge,$e))throw new Error("expected weightMap["+v+"] to be a Tensor"+$e+"D, instead have "+Ge);return y.push({originalPath:v,paramPath:je||v}),Ge}}function extractWeightsFactory(m){var y=m;function v(je){var Ge=y.slice(0,je);return y=y.slice(je),Ge}function $e(){return y}return{extractWeights:v,getRemainingWeights:$e}}function extractorsFactory$9(m,y){var v=extractConvParamsFactory(m,y),$e=extractSeparableConvParamsFactory(m,y);function je(Ye,qe,Ke,Qe){Qe===void 0&&(Qe=!1);var Je=Qe?v(Ye,qe,3,Ke+"/conv0"):$e(Ye,qe,Ke+"/conv0"),st=$e(qe,qe,Ke+"/conv1"),Mt=$e(qe,qe,Ke+"/conv2");return{conv0:Je,conv1:st,conv2:Mt}}function Ge(Ye,qe,Ke,Qe){Qe===void 0&&(Qe=!1);var Je=je(Ye,qe,Ke,Qe),st=Je.conv0,Mt=Je.conv1,nn=Je.conv2,rn=$e(qe,qe,Ke+"/conv3");return{conv0:st,conv1:Mt,conv2:nn,conv3:rn}}return{extractDenseBlock3Params:je,extractDenseBlock4Params:Ge}}function extractParams$7(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,je=v.getRemainingWeights,Ge=extractorsFactory$9($e,y).extractDenseBlock4Params,Ye=Ge(3,32,"dense0",!0),qe=Ge(32,64,"dense1"),Ke=Ge(64,128,"dense2"),Qe=Ge(128,256,"dense3");if(je().length!==0)throw new Error("weights remaing after extract: "+je().length);return{paramMappings:y,params:{dense0:Ye,dense1:qe,dense2:Ke,dense3:Qe}}}function loadConvParamsFactory(m){return function(y){var v=m(y+"/filters",4),$e=m(y+"/bias",1);return{filters:v,bias:$e}}}function loadParamsFactory$1(m,y){var v=extractWeightEntryFactory(m,y),$e=loadConvParamsFactory(v),je=loadSeparableConvParamsFactory(v);function Ge(qe,Ke){Ke===void 0&&(Ke=!1);var Qe=Ke?$e(qe+"/conv0"):je(qe+"/conv0"),Je=je(qe+"/conv1"),st=je(qe+"/conv2");return{conv0:Qe,conv1:Je,conv2:st}}function Ye(qe,Ke){Ke===void 0&&(Ke=!1);var Qe=Ke?$e(qe+"/conv0"):je(qe+"/conv0"),Je=je(qe+"/conv1"),st=je(qe+"/conv2"),Mt=je(qe+"/conv3");return{conv0:Qe,conv1:Je,conv2:st,conv3:Mt}}return{extractDenseBlock3Params:Ge,extractDenseBlock4Params:Ye}}function extractParamsFromWeigthMap$7(m){var y=[],v=loadParamsFactory$1(m,y).extractDenseBlock4Params,$e={dense0:v("dense0",!0),dense1:v("dense1"),dense2:v("dense2"),dense3:v("dense3")};return disposeUnusedWeightTensors(m,y),{params:$e,paramMappings:y}}var FaceFeatureExtractor=function(m){__extends(y,m);function y(){return m.call(this,"FaceFeatureExtractor")||this}return y.prototype.forwardInput=function(v){var $e=this.params;if(!$e)throw new Error("FaceFeatureExtractor - load model before inference");return Ze(function(){var je=v.toBatchTensor(112,!0),Ge=[122.782,117.001,104.298],Ye=normalize$1(je,Ge).div(On(255)),qe=denseBlock4(Ye,$e.dense0,!0);return qe=denseBlock4(qe,$e.dense1),qe=denseBlock4(qe,$e.dense2),qe=denseBlock4(qe,$e.dense3),qe=fl(qe,[7,7],[2,2],"valid"),qe})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap$7(v)},y.prototype.extractParams=function(v){return extractParams$7(v)},y}(NeuralNetwork);function fullyConnectedLayer(m,y){return Ze(function(){return rc(el(m,y.weights),y.bias)})}function extractParams$6(m,y,v){var $e=[],je=extractWeightsFactory(m),Ge=je.extractWeights,Ye=je.getRemainingWeights,qe=extractFCParamsFactory(Ge,$e),Ke=qe(y,v,"fc");if(Ye().length!==0)throw new Error("weights remaing after extract: "+Ye().length);return{paramMappings:$e,params:{fc:Ke}}}function extractParamsFromWeigthMap$6(m){var y=[],v=extractWeightEntryFactory(m,y);function $e(Ge){var Ye=v(Ge+"/weights",2),qe=v(Ge+"/bias",1);return{weights:Ye,bias:qe}}var je={fc:$e("fc")};return disposeUnusedWeightTensors(m,y),{params:je,paramMappings:y}}function seperateWeightMaps(m){var y={},v={};return Object.keys(m).forEach(function($e){var je=$e.startsWith("fc")?v:y;je[$e]=m[$e]}),{featureExtractorMap:y,classifierMap:v}}var FaceProcessor=function(m){__extends(y,m);function y(v,$e){var je=m.call(this,v)||this;return je._faceFeatureExtractor=$e,je}return Object.defineProperty(y.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),y.prototype.runNet=function(v){var $e=this,je=this.params;if(!je)throw new Error(this._name+" - load model before inference");return Ze(function(){var Ge=v instanceof NetInput?$e.faceFeatureExtractor.forwardInput(v):v;return fullyConnectedLayer(Ge.as2D(Ge.shape[0],-1),je.fc)})},y.prototype.dispose=function(v){v===void 0&&(v=!0),this.faceFeatureExtractor.dispose(v),m.prototype.dispose.call(this,v)},y.prototype.loadClassifierParams=function(v){var $e=this.extractClassifierParams(v),je=$e.params,Ge=$e.paramMappings;this._params=je,this._paramMappings=Ge},y.prototype.extractClassifierParams=function(v){return extractParams$6(v,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},y.prototype.extractParamsFromWeigthMap=function(v){var $e=seperateWeightMaps(v),je=$e.featureExtractorMap,Ge=$e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(je),extractParamsFromWeigthMap$6(Ge)},y.prototype.extractParams=function(v){var $e=this.getClassifierChannelsIn(),je=this.getClassifierChannelsOut(),Ge=je*$e+je,Ye=v.slice(0,v.length-Ge),qe=v.slice(v.length-Ge);return this.faceFeatureExtractor.extractWeights(Ye),this.extractClassifierParams(qe)},y}(NeuralNetwork),FACE_EXPRESSION_LABELS=["neutral","happy","sad","angry","fearful","disgusted","surprised"],FaceExpressions=function(){function m(y){var v=this;if(y.length!==7)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+y.length);FACE_EXPRESSION_LABELS.forEach(function($e,je){v[$e]=y[je]})}return m.prototype.asSortedArray=function(){var y=this;return FACE_EXPRESSION_LABELS.map(function(v){return{expression:v,probability:y[v]}}).sort(function(v,$e){return $e.probability-v.probability})},m}(),FaceExpressionNet=function(m){__extends(y,m);function y(v){return v===void 0&&(v=new FaceFeatureExtractor),m.call(this,"FaceExpressionNet",v)||this}return y.prototype.forwardInput=function(v){var $e=this;return Ze(function(){return go($e.runNet(v))})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.predictExpressions=function(v){return __awaiter(this,void 0,void 0,function(){var $e,je,Ge,Ye,qe=this;return __generator(this,function(Ke){switch(Ke.label){case 0:return[4,toNetInput(v)];case 1:return $e=Ke.sent(),[4,this.forwardInput($e)];case 2:return je=Ke.sent(),[4,Promise.all(Ur(je).map(function(Qe){return __awaiter(qe,void 0,void 0,function(){var Je;return __generator(this,function(st){switch(st.label){case 0:return[4,Qe.data()];case 1:return Je=st.sent(),Qe.dispose(),[2,Je]}})})}))];case 3:return Ge=Ke.sent(),je.dispose(),Ye=Ge.map(function(Qe){return new FaceExpressions(Qe)}),[2,$e.isBatchInput?Ye:Ye[0]]}})})},y.prototype.getDefaultModelName=function(){return"face_expression_model"},y.prototype.getClassifierChannelsIn=function(){return 256},y.prototype.getClassifierChannelsOut=function(){return 7},y}(FaceProcessor);function extendWithFaceExpressions(m,y){var v={expressions:y};return Object.assign({},m,v)}function isWithFaceLandmarks(m){return isWithFaceDetection(m)&&m.landmarks instanceof FaceLandmarks&&m.unshiftedLandmarks instanceof FaceLandmarks&&m.alignedRect instanceof FaceDetection}function extendWithFaceLandmarks(m,y){var v=m.detection.box,$e=y.shiftBy(v.x,v.y),je=$e.align(),Ge=m.detection.imageDims,Ye=new FaceDetection(m.detection.score,je.rescale(Ge.reverse()),Ge),qe={landmarks:$e,unshiftedLandmarks:y,alignedRect:Ye};return Object.assign({},m,qe)}function extractorsFactory$8(m,y){var v=extractConvParamsFactory(m,y),$e=extractSeparableConvParamsFactory(m,y);function je(Ye,qe,Ke){var Qe=$e(Ye,qe,Ke+"/separable_conv0"),Je=$e(qe,qe,Ke+"/separable_conv1"),st=v(Ye,qe,1,Ke+"/expansion_conv");return{separable_conv0:Qe,separable_conv1:Je,expansion_conv:st}}function Ge(Ye,qe){var Ke=$e(Ye,Ye,qe+"/separable_conv0"),Qe=$e(Ye,Ye,qe+"/separable_conv1"),Je=$e(Ye,Ye,qe+"/separable_conv2");return{separable_conv0:Ke,separable_conv1:Qe,separable_conv2:Je}}return{extractConvParams:v,extractSeparableConvParams:$e,extractReductionBlockParams:je,extractMainBlockParams:Ge}}function extractParams$5(m,y){var v=[],$e=extractWeightsFactory(m),je=$e.extractWeights,Ge=$e.getRemainingWeights,Ye=extractorsFactory$8(je,v),qe=Ye.extractConvParams,Ke=Ye.extractSeparableConvParams,Qe=Ye.extractReductionBlockParams,Je=Ye.extractMainBlockParams,st=qe(3,32,3,"entry_flow/conv_in"),Mt=Qe(32,64,"entry_flow/reduction_block_0"),nn=Qe(64,128,"entry_flow/reduction_block_1"),rn={conv_in:st,reduction_block_0:Mt,reduction_block_1:nn},on={};range(y,0,1).forEach(function(cn){on["main_block_"+cn]=Je(128,"middle_flow/main_block_"+cn)});var an=Qe(128,256,"exit_flow/reduction_block"),sn=Ke(256,512,"exit_flow/separable_conv"),ln={reduction_block:an,separable_conv:sn};if(Ge().length!==0)throw new Error("weights remaing after extract: "+Ge().length);return{paramMappings:v,params:{entry_flow:rn,middle_flow:on,exit_flow:ln}}}function loadParamsFactory(m,y){var v=extractWeightEntryFactory(m,y),$e=loadConvParamsFactory(v),je=loadSeparableConvParamsFactory(v);function Ge(qe){var Ke=je(qe+"/separable_conv0"),Qe=je(qe+"/separable_conv1"),Je=$e(qe+"/expansion_conv");return{separable_conv0:Ke,separable_conv1:Qe,expansion_conv:Je}}function Ye(qe){var Ke=je(qe+"/separable_conv0"),Qe=je(qe+"/separable_conv1"),Je=je(qe+"/separable_conv2");return{separable_conv0:Ke,separable_conv1:Qe,separable_conv2:Je}}return{extractConvParams:$e,extractSeparableConvParams:je,extractReductionBlockParams:Ge,extractMainBlockParams:Ye}}function extractParamsFromWeigthMap$5(m,y){var v=[],$e=loadParamsFactory(m,v),je=$e.extractConvParams,Ge=$e.extractSeparableConvParams,Ye=$e.extractReductionBlockParams,qe=$e.extractMainBlockParams,Ke=je("entry_flow/conv_in"),Qe=Ye("entry_flow/reduction_block_0"),Je=Ye("entry_flow/reduction_block_1"),st={conv_in:Ke,reduction_block_0:Qe,reduction_block_1:Je},Mt={};range(y,0,1).forEach(function(an){Mt["main_block_"+an]=qe("middle_flow/main_block_"+an)});var nn=Ye("exit_flow/reduction_block"),rn=Ge("exit_flow/separable_conv"),on={reduction_block:nn,separable_conv:rn};return disposeUnusedWeightTensors(m,v),{params:{entry_flow:st,middle_flow:Mt,exit_flow:on},paramMappings:v}}function conv$1(m,y,v){return rc(qc(m,y.filters,v,"same"),y.bias)}function reductionBlock(m,y,v){v===void 0&&(v=!0);var $e=v?Bl(m):m;return $e=depthwiseSeparableConv$1($e,y.separable_conv0,[1,1]),$e=depthwiseSeparableConv$1(Bl($e),y.separable_conv1,[1,1]),$e=hl($e,[3,3],[2,2],"same"),$e=rc($e,conv$1(m,y.expansion_conv,[2,2])),$e}function mainBlock(m,y){var v=depthwiseSeparableConv$1(Bl(m),y.separable_conv0,[1,1]);return v=depthwiseSeparableConv$1(Bl(v),y.separable_conv1,[1,1]),v=depthwiseSeparableConv$1(Bl(v),y.separable_conv2,[1,1]),v=rc(v,m),v}var TinyXception=function(m){__extends(y,m);function y(v){var $e=m.call(this,"TinyXception")||this;return $e._numMainBlocks=v,$e}return y.prototype.forwardInput=function(v){var $e=this,je=this.params;if(!je)throw new Error("TinyXception - load model before inference");return Ze(function(){var Ge=v.toBatchTensor(112,!0),Ye=[122.782,117.001,104.298],qe=normalize$1(Ge,Ye).div(On(256)),Ke=Bl(conv$1(qe,je.entry_flow.conv_in,[2,2]));return Ke=reductionBlock(Ke,je.entry_flow.reduction_block_0,!1),Ke=reductionBlock(Ke,je.entry_flow.reduction_block_1),range($e._numMainBlocks,0,1).forEach(function(Qe){Ke=mainBlock(Ke,je.middle_flow["main_block_"+Qe])}),Ke=reductionBlock(Ke,je.exit_flow.reduction_block),Ke=Bl(depthwiseSeparableConv$1(Ke,je.exit_flow.separable_conv,[1,1])),Ke})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.getDefaultModelName=function(){return"tiny_xception_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap$5(v,this._numMainBlocks)},y.prototype.extractParams=function(v){return extractParams$5(v,this._numMainBlocks)},y}(NeuralNetwork);function extractParams$4(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,je=v.getRemainingWeights,Ge=extractFCParamsFactory($e,y),Ye=Ge(512,1,"fc/age"),qe=Ge(512,2,"fc/gender");if(je().length!==0)throw new Error("weights remaing after extract: "+je().length);return{paramMappings:y,params:{fc:{age:Ye,gender:qe}}}}function extractParamsFromWeigthMap$4(m){var y=[],v=extractWeightEntryFactory(m,y);function $e(Ge){var Ye=v(Ge+"/weights",2),qe=v(Ge+"/bias",1);return{weights:Ye,bias:qe}}var je={fc:{age:$e("fc/age"),gender:$e("fc/gender")}};return disposeUnusedWeightTensors(m,y),{params:je,paramMappings:y}}var Gender;(function(m){m.FEMALE="female",m.MALE="male"})(Gender||(Gender={}));var AgeGenderNet=function(m){__extends(y,m);function y(v){v===void 0&&(v=new TinyXception(2));var $e=m.call(this,"AgeGenderNet")||this;return $e._faceFeatureExtractor=v,$e}return Object.defineProperty(y.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),y.prototype.runNet=function(v){var $e=this,je=this.params;if(!je)throw new Error(this._name+" - load model before inference");return Ze(function(){var Ge=v instanceof NetInput?$e.faceFeatureExtractor.forwardInput(v):v,Ye=fl(Ge,[7,7],[2,2],"valid").as2D(Ge.shape[0],-1),qe=fullyConnectedLayer(Ye,je.fc.age).as1D(),Ke=fullyConnectedLayer(Ye,je.fc.gender);return{age:qe,gender:Ke}})},y.prototype.forwardInput=function(v){var $e=this;return Ze(function(){var je=$e.runNet(v),Ge=je.age,Ye=je.gender;return{age:Ge,gender:go(Ye)}})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.predictAgeAndGender=function(v){return __awaiter(this,void 0,void 0,function(){var $e,je,Ge,Ye,qe,Ke,Qe=this;return __generator(this,function(Je){switch(Je.label){case 0:return[4,toNetInput(v)];case 1:return $e=Je.sent(),[4,this.forwardInput($e)];case 2:return je=Je.sent(),Ge=Ur(je.age),Ye=Ur(je.gender),qe=Ge.map(function(st,Mt){return{ageTensor:st,genderTensor:Ye[Mt]}}),[4,Promise.all(qe.map(function(st){var Mt=st.ageTensor,nn=st.genderTensor;return __awaiter(Qe,void 0,void 0,function(){var rn,on,an,sn,ln;return __generator(this,function(cn){switch(cn.label){case 0:return[4,Mt.data()];case 1:return rn=cn.sent()[0],[4,nn.data()];case 2:return on=cn.sent()[0],an=on>.5,sn=an?Gender.MALE:Gender.FEMALE,ln=an?on:1-on,Mt.dispose(),nn.dispose(),[2,{age:rn,gender:sn,genderProbability:ln}]}})})}))];case 3:return Ke=Je.sent(),je.age.dispose(),je.gender.dispose(),[2,$e.isBatchInput?Ke:Ke[0]]}})})},y.prototype.getDefaultModelName=function(){return"age_gender_model"},y.prototype.dispose=function(v){v===void 0&&(v=!0),this.faceFeatureExtractor.dispose(v),m.prototype.dispose.call(this,v)},y.prototype.loadClassifierParams=function(v){var $e=this.extractClassifierParams(v),je=$e.params,Ge=$e.paramMappings;this._params=je,this._paramMappings=Ge},y.prototype.extractClassifierParams=function(v){return extractParams$4(v)},y.prototype.extractParamsFromWeigthMap=function(v){var $e=seperateWeightMaps(v),je=$e.featureExtractorMap,Ge=$e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(je),extractParamsFromWeigthMap$4(Ge)},y.prototype.extractParams=function(v){var $e=1539,je=v.slice(0,v.length-$e),Ge=v.slice(v.length-$e);return this.faceFeatureExtractor.extractWeights(je),this.extractClassifierParams(Ge)},y}(NeuralNetwork),FaceLandmark68NetBase=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.postProcess=function(v,$e,je){var Ge=je.map(function(qe){var Ke=qe.width,Qe=qe.height,Je=$e/Math.max(Qe,Ke);return{width:Ke*Je,height:Qe*Je}}),Ye=Ge.length;return Ze(function(){var qe=function(Mt,nn){return Pr([Hn([68],Mt),Hn([68],nn)],1).as2D(1,136).as1D()},Ke=function(Mt,nn){var rn=Ge[Mt],on=rn.width,an=rn.height;return nn(on,an)?Math.abs(on-an)/2:0},Qe=function(Mt){return Ke(Mt,function(nn,rn){return nn<rn})},Je=function(Mt){return Ke(Mt,function(nn,rn){return rn<nn})},st=v.mul(Hn([Ye,136],$e)).sub(Pr(Array.from(Array(Ye),function(Mt,nn){return qe(Qe(nn),Je(nn))}))).div(Pr(Array.from(Array(Ye),function(Mt,nn){return qe(Ge[nn].width,Ge[nn].height)})));return st})},y.prototype.forwardInput=function(v){var $e=this;return Ze(function(){var je=$e.runNet(v);return $e.postProcess(je,v.inputSize,v.inputDimensions.map(function(Ge){var Ye=Ge[0],qe=Ge[1];return{height:Ye,width:qe}}))})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.detectLandmarks=function(v){return __awaiter(this,void 0,void 0,function(){var $e,je,Ge,Ye=this;return __generator(this,function(qe){switch(qe.label){case 0:return[4,toNetInput(v)];case 1:return $e=qe.sent(),je=Ze(function(){return Ur(Ye.forwardInput($e))}),[4,Promise.all(je.map(function(Ke,Qe){return __awaiter(Ye,void 0,void 0,function(){var Je,st,Mt,nn,rn;return __generator(this,function(on){switch(on.label){case 0:return Mt=(st=Array).from,[4,Ke.data()];case 1:return Je=Mt.apply(st,[on.sent()]),nn=Je.filter(function(an,sn){return isEven(sn)}),rn=Je.filter(function(an,sn){return!isEven(sn)}),[2,new FaceLandmarks68(Array(68).fill(0).map(function(an,sn){return new Point(nn[sn],rn[sn])}),{height:$e.getInputHeight(Qe),width:$e.getInputWidth(Qe)})]}})})}))];case 2:return Ge=qe.sent(),je.forEach(function(Ke){return Ke.dispose()}),[2,$e.isBatchInput?Ge:Ge[0]]}})})},y.prototype.getClassifierChannelsOut=function(){return 136},y}(FaceProcessor),FaceLandmark68Net=function(m){__extends(y,m);function y(v){return v===void 0&&(v=new FaceFeatureExtractor),m.call(this,"FaceLandmark68Net",v)||this}return y.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},y.prototype.getClassifierChannelsIn=function(){return 256},y}(FaceLandmark68NetBase);function extractParamsFromWeigthMapTiny(m){var y=[],v=loadParamsFactory$1(m,y).extractDenseBlock3Params,$e={dense0:v("dense0",!0),dense1:v("dense1"),dense2:v("dense2")};return disposeUnusedWeightTensors(m,y),{params:$e,paramMappings:y}}function extractParamsTiny(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,je=v.getRemainingWeights,Ge=extractorsFactory$9($e,y).extractDenseBlock3Params,Ye=Ge(3,32,"dense0",!0),qe=Ge(32,64,"dense1"),Ke=Ge(64,128,"dense2");if(je().length!==0)throw new Error("weights remaing after extract: "+je().length);return{paramMappings:y,params:{dense0:Ye,dense1:qe,dense2:Ke}}}var TinyFaceFeatureExtractor=function(m){__extends(y,m);function y(){return m.call(this,"TinyFaceFeatureExtractor")||this}return y.prototype.forwardInput=function(v){var $e=this.params;if(!$e)throw new Error("TinyFaceFeatureExtractor - load model before inference");return Ze(function(){var je=v.toBatchTensor(112,!0),Ge=[122.782,117.001,104.298],Ye=normalize$1(je,Ge).div(On(255)),qe=denseBlock3(Ye,$e.dense0,!0);return qe=denseBlock3(qe,$e.dense1),qe=denseBlock3(qe,$e.dense2),qe=fl(qe,[14,14],[2,2],"valid"),qe})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMapTiny(v)},y.prototype.extractParams=function(v){return extractParamsTiny(v)},y}(NeuralNetwork),FaceLandmark68TinyNet=function(m){__extends(y,m);function y(v){return v===void 0&&(v=new TinyFaceFeatureExtractor),m.call(this,"FaceLandmark68TinyNet",v)||this}return y.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},y.prototype.getClassifierChannelsIn=function(){return 128},y}(FaceLandmark68NetBase);(function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y})(FaceLandmark68Net);function scale(m,y){return rc(gc(m,y.weights),y.biases)}function convLayer(m,y,v,$e,je){je===void 0&&(je="same");var Ge=y.conv,Ye=Ge.filters,qe=Ge.bias,Ke=qc(m,Ye,v,je);return Ke=rc(Ke,qe),Ke=scale(Ke,y.scale),$e?Bl(Ke):Ke}function conv(m,y){return convLayer(m,y,[1,1],!0)}function convNoRelu(m,y){return convLayer(m,y,[1,1],!1)}function convDown(m,y){return convLayer(m,y,[2,2],!0,"valid")}function extractorsFactory$7(m,y){function v(qe,Ke,Qe){var Je=m(qe),st=Je.length/(Ke*Qe*Qe);if(isFloat(st))throw new Error("depth has to be an integer: "+st+", weights.length: "+Je.length+", numFilters: "+Ke+", filterSize: "+Qe);return Ze(function(){return Wl(Ln(Je,[Ke,st,Qe,Qe]),[2,3,1,0])})}function $e(qe,Ke,Qe,Je){var st=v(qe,Ke,Qe),Mt=Mn(m(Ke));return y.push({paramPath:Je+"/filters"},{paramPath:Je+"/bias"}),{filters:st,bias:Mt}}function je(qe,Ke){var Qe=Mn(m(qe)),Je=Mn(m(qe));return y.push({paramPath:Ke+"/weights"},{paramPath:Ke+"/biases"}),{weights:Qe,biases:Je}}function Ge(qe,Ke,Qe,Je){var st=$e(qe,Ke,Qe,Je+"/conv"),Mt=je(Ke,Je+"/scale");return{conv:st,scale:Mt}}function Ye(qe,Ke,Qe,Je,st){st===void 0&&(st=!1);var Mt=Ge((st?.5:1)*qe,Ke,Qe,Je+"/conv1"),nn=Ge(qe,Ke,Qe,Je+"/conv2");return{conv1:Mt,conv2:nn}}return{extractConvLayerParams:Ge,extractResidualLayerParams:Ye}}function extractParams$3(m){var y=extractWeightsFactory(m),v=y.extractWeights,$e=y.getRemainingWeights,je=[],Ge=extractorsFactory$7(v,je),Ye=Ge.extractConvLayerParams,qe=Ge.extractResidualLayerParams,Ke=Ye(4704,32,7,"conv32_down"),Qe=qe(9216,32,3,"conv32_1"),Je=qe(9216,32,3,"conv32_2"),st=qe(9216,32,3,"conv32_3"),Mt=qe(36864,64,3,"conv64_down",!0),nn=qe(36864,64,3,"conv64_1"),rn=qe(36864,64,3,"conv64_2"),on=qe(36864,64,3,"conv64_3"),an=qe(147456,128,3,"conv128_down",!0),sn=qe(147456,128,3,"conv128_1"),ln=qe(147456,128,3,"conv128_2"),cn=qe(589824,256,3,"conv256_down",!0),un=qe(589824,256,3,"conv256_1"),hn=qe(589824,256,3,"conv256_2"),fn=qe(589824,256,3,"conv256_down_out"),to=Ze(function(){return Wl(Bn(v(256*128),[128,256]),[1,0])});if(je.push({paramPath:"fc"}),$e().length!==0)throw new Error("weights remaing after extract: "+$e().length);var Mi={conv32_down:Ke,conv32_1:Qe,conv32_2:Je,conv32_3:st,conv64_down:Mt,conv64_1:nn,conv64_2:rn,conv64_3:on,conv128_down:an,conv128_1:sn,conv128_2:ln,conv256_down:cn,conv256_1:un,conv256_2:hn,conv256_down_out:fn,fc:to};return{params:Mi,paramMappings:je}}function extractorsFactory$6(m,y){var v=extractWeightEntryFactory(m,y);function $e(Ye){var qe=v(Ye+"/scale/weights",1),Ke=v(Ye+"/scale/biases",1);return{weights:qe,biases:Ke}}function je(Ye){var qe=v(Ye+"/conv/filters",4),Ke=v(Ye+"/conv/bias",1),Qe=$e(Ye);return{conv:{filters:qe,bias:Ke},scale:Qe}}function Ge(Ye){return{conv1:je(Ye+"/conv1"),conv2:je(Ye+"/conv2")}}return{extractConvLayerParams:je,extractResidualLayerParams:Ge}}function extractParamsFromWeigthMap$3(m){var y=[],v=extractorsFactory$6(m,y),$e=v.extractConvLayerParams,je=v.extractResidualLayerParams,Ge=$e("conv32_down"),Ye=je("conv32_1"),qe=je("conv32_2"),Ke=je("conv32_3"),Qe=je("conv64_down"),Je=je("conv64_1"),st=je("conv64_2"),Mt=je("conv64_3"),nn=je("conv128_down"),rn=je("conv128_1"),on=je("conv128_2"),an=je("conv256_down"),sn=je("conv256_1"),ln=je("conv256_2"),cn=je("conv256_down_out"),un=m.fc;if(y.push({originalPath:"fc",paramPath:"fc"}),!isTensor2D(un))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+un);var hn={conv32_down:Ge,conv32_1:Ye,conv32_2:qe,conv32_3:Ke,conv64_down:Qe,conv64_1:Je,conv64_2:st,conv64_3:Mt,conv128_down:nn,conv128_1:rn,conv128_2:on,conv256_down:an,conv256_1:sn,conv256_2:ln,conv256_down_out:cn,fc:un};return disposeUnusedWeightTensors(m,y),{params:hn,paramMappings:y}}function residual(m,y){var v=conv(m,y.conv1);return v=convNoRelu(v,y.conv2),v=rc(v,m),v=Bl(v),v}function residualDown(m,y){var v=convDown(m,y.conv1);v=convNoRelu(v,y.conv2);var $e=fl(m,2,2,"valid"),je=Gn($e.shape),Ge=$e.shape[3]!==v.shape[3],Ye=$e.shape[1]!==v.shape[1]||$e.shape[2]!==v.shape[2];if(Ye){var qe=__spreadArrays(v.shape);qe[1]=1;var Ke=Gn(qe);v=Yn([v,Ke],1);var Qe=__spreadArrays(v.shape);Qe[2]=1;var Je=Gn(Qe);v=Yn([v,Je],2)}return $e=Ge?Yn([$e,je],3):$e,v=rc($e,v),v=Bl(v),v}var FaceRecognitionNet=function(m){__extends(y,m);function y(){return m.call(this,"FaceRecognitionNet")||this}return y.prototype.forwardInput=function(v){var $e=this.params;if(!$e)throw new Error("FaceRecognitionNet - load model before inference");return Ze(function(){var je=v.toBatchTensor(150,!0).toFloat(),Ge=[122.782,117.001,104.298],Ye=normalize$1(je,Ge).div(On(256)),qe=convDown(Ye,$e.conv32_down);qe=hl(qe,3,2,"valid"),qe=residual(qe,$e.conv32_1),qe=residual(qe,$e.conv32_2),qe=residual(qe,$e.conv32_3),qe=residualDown(qe,$e.conv64_down),qe=residual(qe,$e.conv64_1),qe=residual(qe,$e.conv64_2),qe=residual(qe,$e.conv64_3),qe=residualDown(qe,$e.conv128_down),qe=residual(qe,$e.conv128_1),qe=residual(qe,$e.conv128_2),qe=residualDown(qe,$e.conv256_down),qe=residual(qe,$e.conv256_1),qe=residual(qe,$e.conv256_2),qe=residualDown(qe,$e.conv256_down_out);var Ke=qe.mean([1,2]),Qe=el(Ke,$e.fc);return Qe})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.computeFaceDescriptor=function(v){return __awaiter(this,void 0,void 0,function(){var $e,je,Ge,Ye=this;return __generator(this,function(qe){switch(qe.label){case 0:return[4,toNetInput(v)];case 1:return $e=qe.sent(),je=Ze(function(){return Ur(Ye.forwardInput($e))}),[4,Promise.all(je.map(function(Ke){return Ke.data()}))];case 2:return Ge=qe.sent(),je.forEach(function(Ke){return Ke.dispose()}),[2,$e.isBatchInput?Ge:Ge[0]]}})})},y.prototype.getDefaultModelName=function(){return"face_recognition_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap$3(v)},y.prototype.extractParams=function(v){return extractParams$3(v)},y}(NeuralNetwork);function extendWithFaceDescriptor(m,y){var v={descriptor:y};return Object.assign({},m,v)}function extendWithAge(m,y){var v={age:y};return Object.assign({},m,v)}function extendWithGender(m,y,v){var $e={gender:y,genderProbability:v};return Object.assign({},m,$e)}var MtcnnOptions=function(){function m(y){var v=y===void 0?{}:y,$e=v.minFaceSize,je=v.scaleFactor,Ge=v.maxNumScales,Ye=v.scoreThresholds,qe=v.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=$e||20,this._scaleFactor=je||.709,this._maxNumScales=Ge||10,this._scoreThresholds=Ye||[.6,.7,.7],this._scaleSteps=qe,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(Ke){return typeof Ke!="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(Ke){return typeof Ke!="number"})))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(m.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),m}();function extractorsFactory$5(m,y){function v(Ke,Qe){var Je=Ln(m(9*Ke),[3,3,Ke,1]),st=Mn(m(Ke)),Mt=Mn(m(Ke)),nn=Mn(m(Ke)),rn=Mn(m(Ke));return y.push({paramPath:Qe+"/filters"},{paramPath:Qe+"/batch_norm_scale"},{paramPath:Qe+"/batch_norm_offset"},{paramPath:Qe+"/batch_norm_mean"},{paramPath:Qe+"/batch_norm_variance"}),{filters:Je,batch_norm_scale:st,batch_norm_offset:Mt,batch_norm_mean:nn,batch_norm_variance:rn}}function $e(Ke,Qe,Je,st,Mt){var nn=Ln(m(Ke*Qe*Je*Je),[Je,Je,Ke,Qe]),rn=Mn(m(Qe));return y.push({paramPath:st+"/filters"},{paramPath:st+"/"+(Mt?"batch_norm_offset":"bias")}),{filters:nn,bias:rn}}function je(Ke,Qe,Je,st){var Mt=$e(Ke,Qe,Je,st,!0),nn=Mt.filters,rn=Mt.bias;return{filters:nn,batch_norm_offset:rn}}function Ge(Ke,Qe,Je){var st=v(Ke,Je+"/depthwise_conv"),Mt=je(Ke,Qe,1,Je+"/pointwise_conv");return{depthwise_conv:st,pointwise_conv:Mt}}function Ye(){var Ke=je(3,32,3,"mobilenetv1/conv_0"),Qe=Ge(32,64,"mobilenetv1/conv_1"),Je=Ge(64,128,"mobilenetv1/conv_2"),st=Ge(128,128,"mobilenetv1/conv_3"),Mt=Ge(128,256,"mobilenetv1/conv_4"),nn=Ge(256,256,"mobilenetv1/conv_5"),rn=Ge(256,512,"mobilenetv1/conv_6"),on=Ge(512,512,"mobilenetv1/conv_7"),an=Ge(512,512,"mobilenetv1/conv_8"),sn=Ge(512,512,"mobilenetv1/conv_9"),ln=Ge(512,512,"mobilenetv1/conv_10"),cn=Ge(512,512,"mobilenetv1/conv_11"),un=Ge(512,1024,"mobilenetv1/conv_12"),hn=Ge(1024,1024,"mobilenetv1/conv_13");return{conv_0:Ke,conv_1:Qe,conv_2:Je,conv_3:st,conv_4:Mt,conv_5:nn,conv_6:rn,conv_7:on,conv_8:an,conv_9:sn,conv_10:ln,conv_11:cn,conv_12:un,conv_13:hn}}function qe(){var Ke=je(1024,256,1,"prediction_layer/conv_0"),Qe=je(256,512,3,"prediction_layer/conv_1"),Je=je(512,128,1,"prediction_layer/conv_2"),st=je(128,256,3,"prediction_layer/conv_3"),Mt=je(256,128,1,"prediction_layer/conv_4"),nn=je(128,256,3,"prediction_layer/conv_5"),rn=je(256,64,1,"prediction_layer/conv_6"),on=je(64,128,3,"prediction_layer/conv_7"),an=$e(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),sn=$e(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),ln=$e(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),cn=$e(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),un=$e(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),hn=$e(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),fn=$e(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),to=$e(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),Mi=$e(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),Uo=$e(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),fo=$e(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),dd=$e(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),mo={box_encoding_predictor:an,class_predictor:sn},ho={box_encoding_predictor:ln,class_predictor:cn},Xr={box_encoding_predictor:un,class_predictor:hn},lo={box_encoding_predictor:fn,class_predictor:to},co={box_encoding_predictor:Mi,class_predictor:Uo},uo={box_encoding_predictor:fo,class_predictor:dd};return{conv_0:Ke,conv_1:Qe,conv_2:Je,conv_3:st,conv_4:Mt,conv_5:nn,conv_6:rn,conv_7:on,box_predictor_0:mo,box_predictor_1:ho,box_predictor_2:Xr,box_predictor_3:lo,box_predictor_4:co,box_predictor_5:uo}}return{extractMobilenetV1Params:Ye,extractPredictionLayerParams:qe}}function extractParams$2(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,je=v.getRemainingWeights,Ge=extractorsFactory$5($e,y),Ye=Ge.extractMobilenetV1Params,qe=Ge.extractPredictionLayerParams,Ke=Ye(),Qe=qe(),Je=Pn($e(5118*4),[1,5118,4]),st={extra_dim:Je};if(y.push({paramPath:"output_layer/extra_dim"}),je().length!==0)throw new Error("weights remaing after extract: "+je().length);return{params:{mobilenetv1:Ke,prediction_layer:Qe,output_layer:st},paramMappings:y}}function extractorsFactory$4(m,y){var v=extractWeightEntryFactory(m,y);function $e(Qe,Je,st){var Mt=v(Qe+"/Conv2d_"+Je+"_pointwise/weights",4,st+"/filters"),nn=v(Qe+"/Conv2d_"+Je+"_pointwise/convolution_bn_offset",1,st+"/batch_norm_offset");return{filters:Mt,batch_norm_offset:nn}}function je(Qe){var Je="mobilenetv1/conv_"+Qe,st="MobilenetV1/Conv2d_"+Qe+"_depthwise",Mt=Je+"/depthwise_conv",nn=Je+"/pointwise_conv",rn=v(st+"/depthwise_weights",4,Mt+"/filters"),on=v(st+"/BatchNorm/gamma",1,Mt+"/batch_norm_scale"),an=v(st+"/BatchNorm/beta",1,Mt+"/batch_norm_offset"),sn=v(st+"/BatchNorm/moving_mean",1,Mt+"/batch_norm_mean"),ln=v(st+"/BatchNorm/moving_variance",1,Mt+"/batch_norm_variance");return{depthwise_conv:{filters:rn,batch_norm_scale:on,batch_norm_offset:an,batch_norm_mean:sn,batch_norm_variance:ln},pointwise_conv:$e("MobilenetV1",Qe,nn)}}function Ge(){return{conv_0:$e("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:je(1),conv_2:je(2),conv_3:je(3),conv_4:je(4),conv_5:je(5),conv_6:je(6),conv_7:je(7),conv_8:je(8),conv_9:je(9),conv_10:je(10),conv_11:je(11),conv_12:je(12),conv_13:je(13)}}function Ye(Qe,Je){var st=v(Qe+"/weights",4,Je+"/filters"),Mt=v(Qe+"/biases",1,Je+"/bias");return{filters:st,bias:Mt}}function qe(Qe){var Je=Ye("Prediction/BoxPredictor_"+Qe+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+Qe+"/box_encoding_predictor"),st=Ye("Prediction/BoxPredictor_"+Qe+"/ClassPredictor","prediction_layer/box_predictor_"+Qe+"/class_predictor");return{box_encoding_predictor:Je,class_predictor:st}}function Ke(){return{conv_0:$e("Prediction",0,"prediction_layer/conv_0"),conv_1:$e("Prediction",1,"prediction_layer/conv_1"),conv_2:$e("Prediction",2,"prediction_layer/conv_2"),conv_3:$e("Prediction",3,"prediction_layer/conv_3"),conv_4:$e("Prediction",4,"prediction_layer/conv_4"),conv_5:$e("Prediction",5,"prediction_layer/conv_5"),conv_6:$e("Prediction",6,"prediction_layer/conv_6"),conv_7:$e("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:qe(0),box_predictor_1:qe(1),box_predictor_2:qe(2),box_predictor_3:qe(3),box_predictor_4:qe(4),box_predictor_5:qe(5)}}return{extractMobilenetV1Params:Ge,extractPredictionLayerParams:Ke}}function extractParamsFromWeigthMap$2(m){var y=[],v=extractorsFactory$4(m,y),$e=v.extractMobilenetV1Params,je=v.extractPredictionLayerParams,Ge=m["Output/extra_dim"];if(y.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!isTensor3D(Ge))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+Ge);var Ye={mobilenetv1:$e(),prediction_layer:je(),output_layer:{extra_dim:Ge}};return disposeUnusedWeightTensors(m,y),{params:Ye,paramMappings:y}}function pointwiseConvLayer(m,y,v){return Ze(function(){var $e=qc(m,y.filters,v,"same");return $e=rc($e,y.batch_norm_offset),hu($e,0,6)})}var epsilon=.0010000000474974513;function depthwiseConvLayer(m,y,v){return Ze(function(){var $e=Yc(m,y.filters,v,"same");return $e=ju($e,y.batch_norm_mean,y.batch_norm_variance,y.batch_norm_offset,y.batch_norm_scale,epsilon),hu($e,0,6)})}function getStridesForLayerIdx(m){return[2,4,6,12].some(function(y){return y===m})?[2,2]:[1,1]}function mobileNetV1(m,y){return Ze(function(){var v=null,$e=pointwiseConvLayer(m,y.conv_0,[2,2]),je=[y.conv_1,y.conv_2,y.conv_3,y.conv_4,y.conv_5,y.conv_6,y.conv_7,y.conv_8,y.conv_9,y.conv_10,y.conv_11,y.conv_12,y.conv_13];if(je.forEach(function(Ge,Ye){var qe=Ye+1,Ke=getStridesForLayerIdx(qe);$e=depthwiseConvLayer($e,Ge.depthwise_conv,Ke),$e=pointwiseConvLayer($e,Ge.pointwise_conv,[1,1]),qe===11&&(v=$e)}),v===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:$e,conv11:v}})}function nonMaxSuppression(m,y,v,$e,je){var Ge=m.shape[0],Ye=Math.min(v,Ge),qe=y.map(function(Je,st){return{score:Je,boxIndex:st}}).filter(function(Je){return Je.score>je}).sort(function(Je,st){return st.score-Je.score}),Ke=function(Je){return Je<=$e?1:0},Qe=[];return qe.forEach(function(Je){if(!(Qe.length>=Ye)){for(var st=Je.score,Mt=Qe.length-1;Mt>=0;--Mt){var nn=IOU(m,Je.boxIndex,Qe[Mt]);if(nn!==0&&(Je.score*=Ke(nn),Je.score<=je))break}st===Je.score&&Qe.push(Je.boxIndex)}}),Qe}function IOU(m,y,v){var $e=m.arraySync(),je=Math.min($e[y][0],$e[y][2]),Ge=Math.min($e[y][1],$e[y][3]),Ye=Math.max($e[y][0],$e[y][2]),qe=Math.max($e[y][1],$e[y][3]),Ke=Math.min($e[v][0],$e[v][2]),Qe=Math.min($e[v][1],$e[v][3]),Je=Math.max($e[v][0],$e[v][2]),st=Math.max($e[v][1],$e[v][3]),Mt=(Ye-je)*(qe-Ge),nn=(Je-Ke)*(st-Qe);if(Mt<=0||nn<=0)return 0;var rn=Math.max(je,Ke),on=Math.max(Ge,Qe),an=Math.min(Ye,Je),sn=Math.min(qe,st),ln=Math.max(an-rn,0)*Math.max(sn-on,0);return ln/(Mt+nn-ln)}function getCenterCoordinatesAndSizesLayer(m){var y=Ur(Wl(m,[1,0])),v=[Cc(y[2],y[0]),Cc(y[3],y[1])],$e=[rc(y[0],sc(v[0],On(2))),rc(y[1],sc(v[1],On(2)))];return{sizes:v,centers:$e}}function decodeBoxesLayer(m,y){var v=getCenterCoordinatesAndSizesLayer(m),$e=v.sizes,je=v.centers,Ge=Ur(Wl(y,[1,0])),Ye=sc(gc(vu(sc(Ge[2],On(5))),$e[0]),On(2)),qe=rc(gc(sc(Ge[0],On(10)),$e[0]),je[0]),Ke=sc(gc(vu(sc(Ge[3],On(5))),$e[1]),On(2)),Qe=rc(gc(sc(Ge[1],On(10)),$e[1]),je[1]);return Wl(Pr([Cc(qe,Ye),Cc(Qe,Ke),rc(qe,Ye),rc(Qe,Ke)]),[1,0])}function outputLayer(m,y,v){return Ze(function(){var $e=m.shape[0],je=decodeBoxesLayer(Or(Lr(v.extra_dim,[$e,1,1]),[-1,4]),Or(m,[-1,4]));je=Or(je,[$e,je.shape[0]/$e,4]);var Ge=Iu(ml(y,[0,0,1],[-1,-1,-1])),Ye=ml(Ge,[0,0,0],[-1,-1,1]);Ye=Or(Ye,[$e,Ye.shape[1]]);var qe=Ur(je),Ke=Ur(Ye);return{boxes:qe,scores:Ke}})}function boxPredictionLayer(m,y){return Ze(function(){var v=m.shape[0],$e=Or(convLayer$1(m,y.box_encoding_predictor),[v,-1,1,4]),je=Or(convLayer$1(m,y.class_predictor),[v,-1,3]);return{boxPredictionEncoding:$e,classPrediction:je}})}function predictionLayer(m,y,v){return Ze(function(){var $e=pointwiseConvLayer(m,v.conv_0,[1,1]),je=pointwiseConvLayer($e,v.conv_1,[2,2]),Ge=pointwiseConvLayer(je,v.conv_2,[1,1]),Ye=pointwiseConvLayer(Ge,v.conv_3,[2,2]),qe=pointwiseConvLayer(Ye,v.conv_4,[1,1]),Ke=pointwiseConvLayer(qe,v.conv_5,[2,2]),Qe=pointwiseConvLayer(Ke,v.conv_6,[1,1]),Je=pointwiseConvLayer(Qe,v.conv_7,[2,2]),st=boxPredictionLayer(y,v.box_predictor_0),Mt=boxPredictionLayer(m,v.box_predictor_1),nn=boxPredictionLayer(je,v.box_predictor_2),rn=boxPredictionLayer(Ye,v.box_predictor_3),on=boxPredictionLayer(Ke,v.box_predictor_4),an=boxPredictionLayer(Je,v.box_predictor_5),sn=Yn([st.boxPredictionEncoding,Mt.boxPredictionEncoding,nn.boxPredictionEncoding,rn.boxPredictionEncoding,on.boxPredictionEncoding,an.boxPredictionEncoding],1),ln=Yn([st.classPrediction,Mt.classPrediction,nn.classPrediction,rn.classPrediction,on.classPrediction,an.classPrediction],1);return{boxPredictions:sn,classPredictions:ln}})}var SsdMobilenetv1Options=function(){function m(y){var v=y===void 0?{}:y,$e=v.minConfidence,je=v.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=$e||.5,this._maxResults=je||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(m.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),m}(),SsdMobilenetv1=function(m){__extends(y,m);function y(){return m.call(this,"SsdMobilenetv1")||this}return y.prototype.forwardInput=function(v){var $e=this.params;if(!$e)throw new Error("SsdMobilenetv1 - load model before inference");return Ze(function(){var je=v.toBatchTensor(512,!1).toFloat(),Ge=Cc(gc(je,On(.007843137718737125)),On(1)),Ye=mobileNetV1(Ge,$e.mobilenetv1),qe=predictionLayer(Ye.out,Ye.conv11,$e.prediction_layer),Ke=qe.boxPredictions,Qe=qe.classPredictions;return outputLayer(Ke,Qe,$e.output_layer)})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.locateFaces=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var je,Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln,cn,un,hn,fn,to,Mi;return __generator(this,function(Uo){switch(Uo.label){case 0:return je=new SsdMobilenetv1Options($e),Ge=je.maxResults,Ye=je.minConfidence,[4,toNetInput(v)];case 1:for(qe=Uo.sent(),Ke=this.forwardInput(qe),Qe=Ke.boxes,Je=Ke.scores,st=Qe[0],Mt=Je[0],nn=1;nn<Qe.length;nn++)Qe[nn].dispose(),Je[nn].dispose();return an=(on=Array).from,[4,Mt.data()];case 2:return rn=an.apply(on,[Uo.sent()]),sn=.5,ln=nonMaxSuppression(st,rn,Ge,sn,Ye),cn=qe.getReshapedInputDimensions(0),un=qe.inputSize,hn=un/cn.width,fn=un/cn.height,to=st.arraySync(),Mi=ln.map(function(fo){var dd=[Math.max(0,to[fo][0]),Math.min(1,to[fo][2])].map(function(uo){return uo*fn}),mo=dd[0],ho=dd[1],Xr=[Math.max(0,to[fo][1]),Math.min(1,to[fo][3])].map(function(uo){return uo*hn}),lo=Xr[0],co=Xr[1];return new FaceDetection(rn[fo],new Rect(lo,mo,co-lo,ho-mo),{height:qe.getInputHeight(0),width:qe.getInputWidth(0)})}),st.dispose(),Mt.dispose(),[2,Mi]}})})},y.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap$2(v)},y.prototype.extractParams=function(v){return extractParams$2(v)},y}(NeuralNetwork);(function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y})(SsdMobilenetv1);var IOU_THRESHOLD$1=.4,BOX_ANCHORS$1=[new Point(.738768,.874946),new Point(2.42204,2.65704),new Point(4.30971,7.04493),new Point(10.246,4.59428),new Point(12.6868,11.8741)],BOX_ANCHORS_SEPARABLE=[new Point(1.603231,2.094468),new Point(6.041143,7.080126),new Point(2.882459,3.518061),new Point(4.266906,5.178857),new Point(9.041765,10.66308)],MEAN_RGB_SEPARABLE=[117.001,114.697,97.404],DEFAULT_MODEL_NAME="tiny_yolov2_model",DEFAULT_MODEL_NAME_SEPARABLE_CONV="tiny_yolov2_separable_conv_model",isNumber=function(m){return typeof m=="number"};function validateConfig(m){if(!m)throw new Error("invalid config: "+m);if(typeof m.withSeparableConvs!="boolean")throw new Error("config.withSeparableConvs has to be a boolean, have: "+m.withSeparableConvs);if(!isNumber(m.iouThreshold)||m.iouThreshold<0||m.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+m.iouThreshold);if(!Array.isArray(m.classes)||!m.classes.length||!m.classes.every(function(y){return typeof y=="string"}))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(m.classes));if(!Array.isArray(m.anchors)||!m.anchors.length||!m.anchors.map(function(y){return y||{}}).every(function(y){return isNumber(y.x)&&isNumber(y.y)}))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(m.anchors));if(m.meanRgb&&(!Array.isArray(m.meanRgb)||m.meanRgb.length!==3||!m.meanRgb.every(isNumber)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(m.meanRgb))}function leaky(m){return Ze(function(){var y=gc(m,On(.10000000149011612));return rc(Bl(Cc(m,y)),y)})}function convWithBatchNorm(m,y){return Ze(function(){var v=Ir(m,[[0,0],[1,1],[1,1],[0,0]]);return v=qc(v,y.conv.filters,[1,1],"valid"),v=Cc(v,y.bn.sub),v=gc(v,y.bn.truediv),v=rc(v,y.conv.bias),leaky(v)})}function depthwiseSeparableConv(m,y){return Ze(function(){var v=Ir(m,[[0,0],[1,1],[1,1],[0,0]]);return v=Jc(v,y.depthwise_filter,y.pointwise_filter,[1,1],"valid"),v=rc(v,y.bias),leaky(v)})}function extractorsFactory$3(m,y){var v=extractConvParamsFactory(m,y);function $e(Ye,qe){var Ke=Mn(m(Ye)),Qe=Mn(m(Ye));return y.push({paramPath:qe+"/sub"},{paramPath:qe+"/truediv"}),{sub:Ke,truediv:Qe}}function je(Ye,qe,Ke){var Qe=v(Ye,qe,3,Ke+"/conv"),Je=$e(qe,Ke+"/bn");return{conv:Qe,bn:Je}}var Ge=extractSeparableConvParamsFactory(m,y);return{extractConvParams:v,extractConvWithBatchNormParams:je,extractSeparableConvParams:Ge}}function extractParams$1(m,y,v,$e){var je=extractWeightsFactory(m),Ge=je.extractWeights,Ye=je.getRemainingWeights,qe=[],Ke=extractorsFactory$3(Ge,qe),Qe=Ke.extractConvParams,Je=Ke.extractConvWithBatchNormParams,st=Ke.extractSeparableConvParams,Mt;if(y.withSeparableConvs){var nn=$e[0],rn=$e[1],on=$e[2],an=$e[3],sn=$e[4],ln=$e[5],cn=$e[6],un=$e[7],hn=$e[8],fn=y.isFirstLayerConv2d?Qe(nn,rn,3,"conv0"):st(nn,rn,"conv0"),to=st(rn,on,"conv1"),Mi=st(on,an,"conv2"),Uo=st(an,sn,"conv3"),fo=st(sn,ln,"conv4"),dd=st(ln,cn,"conv5"),mo=un?st(cn,un,"conv6"):void 0,ho=hn?st(un,hn,"conv7"):void 0,Xr=Qe(hn||un||cn,5*v,1,"conv8");Mt={conv0:fn,conv1:to,conv2:Mi,conv3:Uo,conv4:fo,conv5:dd,conv6:mo,conv7:ho,conv8:Xr}}else{var nn=$e[0],rn=$e[1],on=$e[2],an=$e[3],sn=$e[4],ln=$e[5],cn=$e[6],un=$e[7],hn=$e[8],fn=Je(nn,rn,"conv0"),to=Je(rn,on,"conv1"),Mi=Je(on,an,"conv2"),Uo=Je(an,sn,"conv3"),fo=Je(sn,ln,"conv4"),dd=Je(ln,cn,"conv5"),mo=Je(cn,un,"conv6"),ho=Je(un,hn,"conv7"),Xr=Qe(hn,5*v,1,"conv8");Mt={conv0:fn,conv1:to,conv2:Mi,conv3:Uo,conv4:fo,conv5:dd,conv6:mo,conv7:ho,conv8:Xr}}if(Ye().length!==0)throw new Error("weights remaing after extract: "+Ye().length);return{params:Mt,paramMappings:qe}}function extractorsFactory$2(m,y){var v=extractWeightEntryFactory(m,y);function $e(qe){var Ke=v(qe+"/sub",1),Qe=v(qe+"/truediv",1);return{sub:Ke,truediv:Qe}}function je(qe){var Ke=v(qe+"/filters",4),Qe=v(qe+"/bias",1);return{filters:Ke,bias:Qe}}function Ge(qe){var Ke=je(qe+"/conv"),Qe=$e(qe+"/bn");return{conv:Ke,bn:Qe}}var Ye=loadSeparableConvParamsFactory(v);return{extractConvParams:je,extractConvWithBatchNormParams:Ge,extractSeparableConvParams:Ye}}function extractParamsFromWeigthMap$1(m,y){var v=[],$e=extractorsFactory$2(m,v),je=$e.extractConvParams,Ge=$e.extractConvWithBatchNormParams,Ye=$e.extractSeparableConvParams,qe;if(y.withSeparableConvs){var Ke=y.filterSizes&&y.filterSizes.length||9;qe={conv0:y.isFirstLayerConv2d?je("conv0"):Ye("conv0"),conv1:Ye("conv1"),conv2:Ye("conv2"),conv3:Ye("conv3"),conv4:Ye("conv4"),conv5:Ye("conv5"),conv6:Ke>7?Ye("conv6"):void 0,conv7:Ke>8?Ye("conv7"):void 0,conv8:je("conv8")}}else qe={conv0:Ge("conv0"),conv1:Ge("conv1"),conv2:Ge("conv2"),conv3:Ge("conv3"),conv4:Ge("conv4"),conv5:Ge("conv5"),conv6:Ge("conv6"),conv7:Ge("conv7"),conv8:je("conv8")};return disposeUnusedWeightTensors(m,v),{params:qe,paramMappings:v}}var TinyYolov2SizeType;(function(m){m[m.XS=224]="XS",m[m.SM=320]="SM",m[m.MD=416]="MD",m[m.LG=608]="LG"})(TinyYolov2SizeType||(TinyYolov2SizeType={}));var TinyYolov2Options=function(){function m(y){var v=y===void 0?{}:y,$e=v.inputSize,je=v.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=$e||416,this._scoreThreshold=je||.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(m.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),m}(),TinyYolov2Base=function(m){__extends(y,m);function y(v){var $e=m.call(this,"TinyYolov2")||this;return validateConfig(v),$e._config=v,$e}return Object.defineProperty(y.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),y.prototype.runTinyYolov2=function(v,$e){var je=convWithBatchNorm(v,$e.conv0);return je=hl(je,[2,2],[2,2],"same"),je=convWithBatchNorm(je,$e.conv1),je=hl(je,[2,2],[2,2],"same"),je=convWithBatchNorm(je,$e.conv2),je=hl(je,[2,2],[2,2],"same"),je=convWithBatchNorm(je,$e.conv3),je=hl(je,[2,2],[2,2],"same"),je=convWithBatchNorm(je,$e.conv4),je=hl(je,[2,2],[2,2],"same"),je=convWithBatchNorm(je,$e.conv5),je=hl(je,[2,2],[1,1],"same"),je=convWithBatchNorm(je,$e.conv6),je=convWithBatchNorm(je,$e.conv7),convLayer$1(je,$e.conv8,"valid",!1)},y.prototype.runMobilenet=function(v,$e){var je=this.config.isFirstLayerConv2d?leaky(convLayer$1(v,$e.conv0,"valid",!1)):depthwiseSeparableConv(v,$e.conv0);return je=hl(je,[2,2],[2,2],"same"),je=depthwiseSeparableConv(je,$e.conv1),je=hl(je,[2,2],[2,2],"same"),je=depthwiseSeparableConv(je,$e.conv2),je=hl(je,[2,2],[2,2],"same"),je=depthwiseSeparableConv(je,$e.conv3),je=hl(je,[2,2],[2,2],"same"),je=depthwiseSeparableConv(je,$e.conv4),je=hl(je,[2,2],[2,2],"same"),je=depthwiseSeparableConv(je,$e.conv5),je=hl(je,[2,2],[1,1],"same"),je=$e.conv6?depthwiseSeparableConv(je,$e.conv6):je,je=$e.conv7?depthwiseSeparableConv(je,$e.conv7):je,convLayer$1(je,$e.conv8,"valid",!1)},y.prototype.forwardInput=function(v,$e){var je=this,Ge=this.params;if(!Ge)throw new Error("TinyYolov2 - load model before inference");return Ze(function(){var Ye=v.toBatchTensor($e,!1).toFloat();return Ye=je.config.meanRgb?normalize$1(Ye,je.config.meanRgb):Ye,Ye=Ye.div(On(256)),je.config.withSeparableConvs?je.runMobilenet(Ye,Ge):je.runTinyYolov2(Ye,Ge)})},y.prototype.forward=function(v,$e){return __awaiter(this,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return je=this.forwardInput,[4,toNetInput(v)];case 1:return[4,je.apply(this,[Ge.sent(),$e])];case 2:return[2,Ge.sent()]}})})},y.prototype.detect=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var je,Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln=this;return __generator(this,function(cn){switch(cn.label){case 0:return je=new TinyYolov2Options($e),Ge=je.inputSize,Ye=je.scoreThreshold,[4,toNetInput(v)];case 1:return qe=cn.sent(),[4,this.forwardInput(qe,Ge)];case 2:return Ke=cn.sent(),Qe=Ze(function(){return Ur(Ke)[0].expandDims()}),Je={width:qe.getInputWidth(0),height:qe.getInputHeight(0)},[4,this.extractBoxes(Qe,qe.getReshapedInputDimensions(0),Ye)];case 3:return st=cn.sent(),Ke.dispose(),Qe.dispose(),Mt=st.map(function(un){return un.box}),nn=st.map(function(un){return un.score}),rn=st.map(function(un){return un.classScore}),on=st.map(function(un){return ln.config.classes[un.label]}),an=nonMaxSuppression$1(Mt.map(function(un){return un.rescale(Ge)}),nn,this.config.iouThreshold,!0),sn=an.map(function(un){return new ObjectDetection(nn[un],rn[un],on[un],Mt[un],Je)}),[2,sn]}})})},y.prototype.getDefaultModelName=function(){return""},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap$1(v,this.config)},y.prototype.extractParams=function(v){var $e=this.config.filterSizes||y.DEFAULT_FILTER_SIZES,je=$e?$e.length:void 0;if(je!==7&&je!==8&&je!==9)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+je+" filterSizes in config");return extractParams$1(v,this.config,this.boxEncodingSize,$e)},y.prototype.extractBoxes=function(v,$e,je){return __awaiter(this,void 0,void 0,function(){var Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln,cn,un,hn,fn,to,Mi,Uo,fo,dd,mo,ho,Xr,lo,co,uo,od=this;return __generator(this,function(rd){switch(rd.label){case 0:return Ge=$e.width,Ye=$e.height,qe=Math.max(Ge,Ye),Ke=qe/Ge,Qe=qe/Ye,Je=v.shape[1],st=this.config.anchors.length,Mt=Ze(function(){var ld=v.reshape([Je,Je,st,od.boxEncodingSize]),hd=ld.slice([0,0,0,0],[Je,Je,st,4]),pd=ld.slice([0,0,0,4],[Je,Je,st,1]),fd=od.withClassScores?go(ld.slice([0,0,0,5],[Je,Je,st,od.config.classes.length]),3):On(0);return[hd,pd,fd]}),nn=Mt[0],rn=Mt[1],on=Mt[2],an=[],[4,rn.array()];case 1:return sn=rd.sent(),[4,nn.array()];case 2:ln=rd.sent(),cn=0,rd.label=3;case 3:if(!(cn<Je))return[3,12];un=0,rd.label=4;case 4:if(!(un<Je))return[3,11];hn=0,rd.label=5;case 5:return hn<st?(fn=sigmoid(sn[cn][un][hn][0]),!je||fn>je?(to=(un+sigmoid(ln[cn][un][hn][0]))/Je*Ke,Mi=(cn+sigmoid(ln[cn][un][hn][1]))/Je*Qe,Uo=Math.exp(ln[cn][un][hn][2])*this.config.anchors[hn].x/Je*Ke,fo=Math.exp(ln[cn][un][hn][3])*this.config.anchors[hn].y/Je*Qe,dd=to-Uo/2,mo=Mi-fo/2,ho={row:cn,col:un,anchor:hn},this.withClassScores?[4,this.extractPredictedClass(on,ho)]:[3,7]):[3,9]):[3,10];case 6:return uo=rd.sent(),[3,8];case 7:uo={classScore:1,label:0},rd.label=8;case 8:Xr=uo,lo=Xr.classScore,co=Xr.label,an.push(__assign({box:new BoundingBox(dd,mo,dd+Uo,mo+fo),score:fn,classScore:fn*lo,label:co},ho)),rd.label=9;case 9:return hn++,[3,5];case 10:return un++,[3,4];case 11:return cn++,[3,3];case 12:return nn.dispose(),rn.dispose(),on.dispose(),[2,an]}})})},y.prototype.extractPredictedClass=function(v,$e){return __awaiter(this,void 0,void 0,function(){var je,Ge,Ye,qe;return __generator(this,function(Ke){switch(Ke.label){case 0:return je=$e.row,Ge=$e.col,Ye=$e.anchor,[4,v.array()];case 1:return qe=Ke.sent(),[2,Array(this.config.classes.length).fill(0).map(function(Qe,Je){return qe[je][Ge][Ye][Je]}).map(function(Qe,Je){return{classScore:Qe,label:Je}}).reduce(function(Qe,Je){return Qe.classScore>Je.classScore?Qe:Je})]}})})},y.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],y}(NeuralNetwork),TinyYolov2=function(m){__extends(y,m);function y(v){v===void 0&&(v=!0);var $e=this,je=Object.assign({},{withSeparableConvs:v,iouThreshold:IOU_THRESHOLD$1,classes:["face"]},v?{anchors:BOX_ANCHORS_SEPARABLE,meanRgb:MEAN_RGB_SEPARABLE}:{anchors:BOX_ANCHORS$1,withClassScores:!0});return $e=m.call(this,je)||this,$e}return Object.defineProperty(y.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),y.prototype.locateFaces=function(v,$e){return __awaiter(this,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.detect(v,$e)];case 1:return je=Ge.sent(),[2,je.map(function(Ye){return new FaceDetection(Ye.score,Ye.relativeBox,{width:Ye.imageWidth,height:Ye.imageHeight})})]}})})},y.prototype.getDefaultModelName=function(){return this.withSeparableConvs?DEFAULT_MODEL_NAME_SEPARABLE_CONV:DEFAULT_MODEL_NAME},y.prototype.extractParamsFromWeigthMap=function(v){return m.prototype.extractParamsFromWeigthMap.call(this,v)},y}(TinyYolov2Base),TinyFaceDetectorOptions=function(m){__extends(y,m);function y(){var v=m!==null&&m.apply(this,arguments)||this;return v._name="TinyFaceDetectorOptions",v}return y}(TinyYolov2Options),ComposableTask=function(){function m(){}return m.prototype.then=function(y){return __awaiter(this,void 0,void 0,function(){var v;return __generator(this,function($e){switch($e.label){case 0:return v=y,[4,this.run()];case 1:return[2,v.apply(void 0,[$e.sent()])]}})})},m.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(y){throw new Error("ComposableTask - run is not implemented")})})},m}();function extractAllFacesAndComputeResults(m,y,v,$e,je){return je===void 0&&(je=function(Ge){var Ye=Ge.alignedRect;return Ye}),__awaiter(this,void 0,void 0,function(){var Ge,Ye,qe,Ke,Qe;return __generator(this,function(Je){switch(Je.label){case 0:return Ge=m.map(function(st){return isWithFaceLandmarks(st)?je(st):st.detection}),qe=$e,qe?[3,5]:y instanceof wt?[4,extractFaceTensors(y,Ge)]:[3,2];case 1:return Ke=Je.sent(),[3,4];case 2:return[4,extractFaces(y,Ge)];case 3:Ke=Je.sent(),Je.label=4;case 4:qe=Ke,Je.label=5;case 5:return Ye=qe,[4,v(Ye)];case 6:return Qe=Je.sent(),Ye.forEach(function(st){return st instanceof wt&&st.dispose()}),[2,Qe]}})})}function extractSingleFaceAndComputeResult(m,y,v,$e,je){return __awaiter(this,void 0,void 0,function(){var Ge=this;return __generator(this,function(Ye){return[2,extractAllFacesAndComputeResults([m],y,function(qe){return __awaiter(Ge,void 0,void 0,function(){return __generator(this,function(Ke){return[2,v(qe[0])]})})},$e,je)]})})}function bgrToRgbTensor(m){return Ze(function(){return Pr(Ur(m,3).reverse(),3)})}var CELL_STRIDE=2,CELL_SIZE=12;function extractorsFactory$1(m,y){var v=extractConvParamsFactory(m,y),$e=extractFCParamsFactory(m,y);function je(Qe,Je){var st=Mn(m(Qe));return y.push({paramPath:Je}),st}function Ge(Qe,Je,st){st===void 0&&(st=!1);var Mt=v(Qe[0],Qe[1],3,Je+"/conv1"),nn=je(Qe[1],Je+"/prelu1_alpha"),rn=v(Qe[1],Qe[2],3,Je+"/conv2"),on=je(Qe[2],Je+"/prelu2_alpha"),an=v(Qe[2],Qe[3],st?2:3,Je+"/conv3"),sn=je(Qe[3],Je+"/prelu3_alpha");return{conv1:Mt,prelu1_alpha:nn,conv2:rn,prelu2_alpha:on,conv3:an,prelu3_alpha:sn}}function Ye(){var Qe=Ge([3,10,16,32],"pnet"),Je=v(32,2,1,"pnet/conv4_1"),st=v(32,4,1,"pnet/conv4_2");return __assign(__assign({},Qe),{conv4_1:Je,conv4_2:st})}function qe(){var Qe=Ge([3,28,48,64],"rnet",!0),Je=$e(576,128,"rnet/fc1"),st=je(128,"rnet/prelu4_alpha"),Mt=$e(128,2,"rnet/fc2_1"),nn=$e(128,4,"rnet/fc2_2");return __assign(__assign({},Qe),{fc1:Je,prelu4_alpha:st,fc2_1:Mt,fc2_2:nn})}function Ke(){var Qe=Ge([3,32,64,64],"onet"),Je=v(64,128,2,"onet/conv4"),st=je(128,"onet/prelu4_alpha"),Mt=$e(1152,256,"onet/fc1"),nn=je(256,"onet/prelu5_alpha"),rn=$e(256,2,"onet/fc2_1"),on=$e(256,4,"onet/fc2_2"),an=$e(256,10,"onet/fc2_3");return __assign(__assign({},Qe),{conv4:Je,prelu4_alpha:st,fc1:Mt,prelu5_alpha:nn,fc2_1:rn,fc2_2:on,fc2_3:an})}return{extractPNetParams:Ye,extractRNetParams:qe,extractONetParams:Ke}}function extractParams(m){var y=extractWeightsFactory(m),v=y.extractWeights,$e=y.getRemainingWeights,je=[],Ge=extractorsFactory$1(v,je),Ye=Ge.extractPNetParams,qe=Ge.extractRNetParams,Ke=Ge.extractONetParams,Qe=Ye(),Je=qe(),st=Ke();if($e().length!==0)throw new Error("weights remaing after extract: "+$e().length);return{params:{pnet:Qe,rnet:Je,onet:st},paramMappings:je}}function extractorsFactory(m,y){var v=extractWeightEntryFactory(m,y);function $e(Je){var st=v(Je+"/weights",4,Je+"/filters"),Mt=v(Je+"/bias",1);return{filters:st,bias:Mt}}function je(Je){var st=v(Je+"/weights",2),Mt=v(Je+"/bias",1);return{weights:st,bias:Mt}}function Ge(Je){return v(Je,1)}function Ye(Je){var st=$e(Je+"/conv1"),Mt=Ge(Je+"/prelu1_alpha"),nn=$e(Je+"/conv2"),rn=Ge(Je+"/prelu2_alpha"),on=$e(Je+"/conv3"),an=Ge(Je+"/prelu3_alpha");return{conv1:st,prelu1_alpha:Mt,conv2:nn,prelu2_alpha:rn,conv3:on,prelu3_alpha:an}}function qe(){var Je=Ye("pnet"),st=$e("pnet/conv4_1"),Mt=$e("pnet/conv4_2");return __assign(__assign({},Je),{conv4_1:st,conv4_2:Mt})}function Ke(){var Je=Ye("rnet"),st=je("rnet/fc1"),Mt=Ge("rnet/prelu4_alpha"),nn=je("rnet/fc2_1"),rn=je("rnet/fc2_2");return __assign(__assign({},Je),{fc1:st,prelu4_alpha:Mt,fc2_1:nn,fc2_2:rn})}function Qe(){var Je=Ye("onet"),st=$e("onet/conv4"),Mt=Ge("onet/prelu4_alpha"),nn=je("onet/fc1"),rn=Ge("onet/prelu5_alpha"),on=je("onet/fc2_1"),an=je("onet/fc2_2"),sn=je("onet/fc2_3");return __assign(__assign({},Je),{conv4:st,prelu4_alpha:Mt,fc1:nn,prelu5_alpha:rn,fc2_1:on,fc2_2:an,fc2_3:sn})}return{extractPNetParams:qe,extractRNetParams:Ke,extractONetParams:Qe}}function extractParamsFromWeigthMap(m){var y=[],v=extractorsFactory(m,y),$e=v.extractPNetParams,je=v.extractRNetParams,Ge=v.extractONetParams,Ye=$e(),qe=je(),Ke=Ge();return disposeUnusedWeightTensors(m,y),{params:{pnet:Ye,rnet:qe,onet:Ke},paramMappings:y}}function getSizesForScale(m,y){var v=y[0],$e=y[1];return{height:Math.floor(v*m),width:Math.floor($e*m)}}function pyramidDown(m,y,v){for(var $e=v[0],je=v[1],Ge=CELL_SIZE/m,Ye=[],qe=Math.min($e,je)*Ge,Ke=0;qe>=12;)Ye.push(Ge*Math.pow(y,Ke)),qe=qe*y,Ke+=1;return Ye}var MtcnnBox=function(m){__extends(y,m);function y(v,$e,je,Ge){return m.call(this,{left:v,top:$e,right:je,bottom:Ge},!0)||this}return y}(Box);function normalize(m){return Ze(function(){return gc(Cc(m,On(127.5)),On(.0078125))})}function prelu(m,y){return Ze(function(){return rc(Bl(m),gc(y,wu(Bl(wu(m)))))})}function sharedLayer(m,y,v){return v===void 0&&(v=!1),Ze(function(){var $e=convLayer$1(m,y.conv1,"valid");return $e=prelu($e,y.prelu1_alpha),$e=hl($e,v?[2,2]:[3,3],[2,2],"same"),$e=convLayer$1($e,y.conv2,"valid"),$e=prelu($e,y.prelu2_alpha),$e=v?$e:hl($e,[3,3],[2,2],"valid"),$e=convLayer$1($e,y.conv3,"valid"),$e=prelu($e,y.prelu3_alpha),$e})}function PNet(m,y){return Ze(function(){var v=sharedLayer(m,y,!0),$e=convLayer$1(v,y.conv4_1,"valid"),je=wr(Sl($e,3),3),Ge=go(Cc($e,je),3),Ye=convLayer$1(v,y.conv4_2,"valid");return{prob:Ge,regions:Ye}})}function rescaleAndNormalize(m,y){return Ze(function(){var v=getSizesForScale(y,m.shape.slice(1)),$e=v.height,je=v.width,Ge=Oh.resizeBilinear(m,[$e,je]),Ye=normalize(Ge);return Wl(Ye,[0,2,1,3])})}function extractBoundingBoxes(m,y,v,$e){for(var je=[],Ge=m.arraySync(),Ye=0;Ye<m.shape[0];Ye++)for(var qe=0;qe<m.shape[1];qe++)Ge[Ye][qe]>=$e&&je.push(new Point(qe,Ye));var Ke=je.map(function(Qe){var Je=new BoundingBox(Math.round((Qe.y*CELL_STRIDE+1)/v),Math.round((Qe.x*CELL_STRIDE+1)/v),Math.round((Qe.y*CELL_STRIDE+CELL_SIZE)/v),Math.round((Qe.x*CELL_STRIDE+CELL_SIZE)/v)),st=Ge[Qe.y][Qe.x],Mt=y.arraySync(),nn=new MtcnnBox(Mt[Qe.y][Qe.x][0],Mt[Qe.y][Qe.x][1],Mt[Qe.y][Qe.x][2],Mt[Qe.y][Qe.x][3]);return{cell:Je,score:st,region:nn}});return Ke}function stage1(m,y,v,$e,je){je.stage1=[];var Ge=y.map(function(Mt){return Ze(function(){var nn={scale:Mt},rn=rescaleAndNormalize(m,Mt),on=Date.now(),an=PNet(rn,$e),sn=an.prob,ln=an.regions;nn.pnet=Date.now()-on;var cn=Ur(Ur(sn,3)[1])[0],un=Ur(ln)[0];return{scoresTensor:cn,regionsTensor:un,scale:Mt,statsForScale:nn}})}),Ye=Ge.map(function(Mt){var nn=Mt.scoresTensor,rn=Mt.regionsTensor,on=Mt.scale,an=Mt.statsForScale,sn=extractBoundingBoxes(nn,rn,on,v);if(nn.dispose(),rn.dispose(),!sn.length)return je.stage1.push(an),[];var ln=Date.now(),cn=nonMaxSuppression$1(sn.map(function(un){return un.cell}),sn.map(function(un){return un.score}),.5);return an.nms=Date.now()-ln,an.numBoxes=cn.length,je.stage1.push(an),cn.map(function(un){return sn[un]})}),qe=Ye.reduce(function(Mt,nn){return Mt.concat(nn)},[]),Ke=[],Qe=[];if(qe.length>0){var Je=Date.now(),st=nonMaxSuppression$1(qe.map(function(Mt){return Mt.cell}),qe.map(function(Mt){return Mt.score}),.7);je.stage1_nms=Date.now()-Je,Qe=st.map(function(Mt){return qe[Mt].score}),Ke=st.map(function(Mt){return qe[Mt]}).map(function(Mt){var nn=Mt.cell,rn=Mt.region;return new BoundingBox(nn.left+rn.left*nn.width,nn.top+rn.top*nn.height,nn.right+rn.right*nn.width,nn.bottom+rn.bottom*nn.height).toSquare().round()})}return{boxes:Ke,scores:Qe}}function extractImagePatches(m,y,v){var $e=v.width,je=v.height;return __awaiter(this,void 0,void 0,function(){var Ge,Ye,qe,Ke=this;return __generator(this,function(Qe){switch(Qe.label){case 0:return Ge=getContext2dOrThrow(m),[4,Promise.all(y.map(function(Je){return __awaiter(Ke,void 0,void 0,function(){var st,Mt,nn,rn,on,an,sn,ln;return __generator(this,function(cn){return st=Je.padAtBorders(m.height,m.width),Mt=st.y,nn=st.ey,rn=st.x,on=st.ex,an=rn-1,sn=Mt-1,ln=Ge.getImageData(an,sn,on-an,nn-sn),[2,env.isNodejs()?createCanvasFromMedia(ln):createImageBitmap(ln)]})})}))];case 1:return Ye=Qe.sent(),qe=[],Ye.forEach(function(Je){var st=createCanvas({width:$e,height:je}),Mt=getContext2dOrThrow(st);Mt.drawImage(Je,0,0,$e,je);for(var nn=Mt.getImageData(0,0,$e,je).data,rn=[],on=0;on<nn.length;on+=4)rn.push(nn[on+2]),rn.push(nn[on+1]),rn.push(nn[on]);qe.push(rn)}),[2,qe.map(function(Je){var st=Ze(function(){var Mt=Wl(Ln(Je,[1,$e,je,3]),[0,2,1,3]).toFloat();return normalize(Mt)});return st})]}})})}function RNet(m,y){return Ze(function(){var v=sharedLayer(m,y),$e=Or(v,[v.shape[0],y.fc1.weights.shape[0]]),je=fullyConnectedLayer($e,y.fc1),Ge=prelu(je,y.prelu4_alpha),Ye=fullyConnectedLayer(Ge,y.fc2_1),qe=wr(Sl(Ye,1),1),Ke=go(Cc(Ye,qe),1),Qe=fullyConnectedLayer(Ge,y.fc2_2),Je=Ur(Ke,1)[1];return{scores:Je,regions:Qe}})}function stage2(m,y,v,$e,je){return __awaiter(this,void 0,void 0,function(){var Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln;return __generator(this,function(cn){switch(cn.label){case 0:return Ge=Date.now(),[4,extractImagePatches(m,y,{width:24,height:24})];case 1:return Ye=cn.sent(),je.stage2_extractImagePatches=Date.now()-Ge,Ge=Date.now(),qe=Ye.map(function(un){var hn=RNet(un,$e);return un.dispose(),hn}),je.stage2_rnet=Date.now()-Ge,Ke=qe.length>1?Yn(qe.map(function(un){return un.scores})):qe[0].scores,st=(Je=Array).from,[4,Ke.data()];case 2:return Qe=st.apply(Je,[cn.sent()]),Ke.dispose(),Mt=Qe.map(function(un,hn){return{score:un,idx:hn}}).filter(function(un){return un.score>v}).map(function(un){var hn=un.idx;return hn}),nn=Mt.map(function(un){return y[un]}),rn=Mt.map(function(un){return Qe[un]}),on=[],an=[],nn.length>0&&(Ge=Date.now(),sn=nonMaxSuppression$1(nn,rn,.7),je.stage2_nms=Date.now()-Ge,ln=sn.map(function(un){var hn=qe[Mt[un]].regions.arraySync();return new MtcnnBox(hn[0][0],hn[0][1],hn[0][2],hn[0][3])}),an=sn.map(function(un){return rn[un]}),on=sn.map(function(un,hn){return nn[un].calibrate(ln[hn])})),qe.forEach(function(un){un.regions.dispose(),un.scores.dispose()}),[2,{boxes:on,scores:an}]}})})}function ONet(m,y){return Ze(function(){var v=sharedLayer(m,y);v=hl(v,[2,2],[2,2],"same"),v=convLayer$1(v,y.conv4,"valid"),v=prelu(v,y.prelu4_alpha);var $e=Or(v,[v.shape[0],y.fc1.weights.shape[0]]),je=fullyConnectedLayer($e,y.fc1),Ge=prelu(je,y.prelu5_alpha),Ye=fullyConnectedLayer(Ge,y.fc2_1),qe=wr(Sl(Ye,1),1),Ke=go(Cc(Ye,qe),1),Qe=fullyConnectedLayer(Ge,y.fc2_2),Je=fullyConnectedLayer(Ge,y.fc2_3),st=Ur(Ke,1)[1];return{scores:st,regions:Qe,points:Je}})}function stage3(m,y,v,$e,je){return __awaiter(this,void 0,void 0,function(){var Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln,cn;return __generator(this,function(un){switch(un.label){case 0:return Ge=Date.now(),[4,extractImagePatches(m,y,{width:48,height:48})];case 1:return Ye=un.sent(),je.stage3_extractImagePatches=Date.now()-Ge,Ge=Date.now(),qe=Ye.map(function(hn){var fn=ONet(hn,$e);return hn.dispose(),fn}),je.stage3_onet=Date.now()-Ge,Ke=qe.length>1?Yn(qe.map(function(hn){return hn.scores})):qe[0].scores,st=(Je=Array).from,[4,Ke.data()];case 2:return Qe=st.apply(Je,[un.sent()]),Ke.dispose(),Mt=Qe.map(function(hn,fn){return{score:hn,idx:fn}}).filter(function(hn){return hn.score>v}).map(function(hn){var fn=hn.idx;return fn}),nn=Mt.map(function(hn){var fn=qe[hn].regions.arraySync();return new MtcnnBox(fn[0][0],fn[0][1],fn[0][2],fn[0][3])}),rn=Mt.map(function(hn,fn){return y[hn].calibrate(nn[fn])}),on=Mt.map(function(hn){return Qe[hn]}),an=[],sn=[],ln=[],rn.length>0&&(Ge=Date.now(),cn=nonMaxSuppression$1(rn,on,.7,!1),je.stage3_nms=Date.now()-Ge,an=cn.map(function(hn){return rn[hn]}),sn=cn.map(function(hn){return on[hn]}),ln=cn.map(function(hn,fn){return Array(5).fill(0).map(function(to,Mi){var Uo=qe[hn].points.arraySync();return new Point(Uo[0][Mi]*(an[fn].width+1)+an[fn].left,Uo[0][Mi+5]*(an[fn].height+1)+an[fn].top)})})),qe.forEach(function(hn){hn.regions.dispose(),hn.scores.dispose(),hn.points.dispose()}),[2,{boxes:an,scores:sn,points:ln}]}})})}var Mtcnn=function(m){__extends(y,m);function y(){return m.call(this,"Mtcnn")||this}return y.prototype.load=function(v){return __awaiter(this,void 0,void 0,function(){return __generator(this,function($e){return console.warn("mtcnn is deprecated and will be removed soon"),[2,m.prototype.load.call(this,v)]})})},y.prototype.loadFromDisk=function(v){return __awaiter(this,void 0,void 0,function(){return __generator(this,function($e){return console.warn("mtcnn is deprecated and will be removed soon"),[2,m.prototype.loadFromDisk.call(this,v)]})})},y.prototype.forwardInput=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var je,Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln,cn,un,hn,fn,to,Mi;return __generator(this,function(Uo){switch(Uo.label){case 0:if(je=this.params,!je)throw new Error("Mtcnn - load model before inference");if(Ge=v.canvases[0],!Ge)throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return Ye={},qe=Date.now(),Ke=Ze(function(){return bgrToRgbTensor(wr(id.fromPixels(Ge)).toFloat())}),Qe=function(fo){return Ke.dispose(),Ye.total=Date.now()-qe,fo},Je=Ke.shape.slice(1),st=Je[0],Mt=Je[1],nn=new MtcnnOptions($e),rn=nn.minFaceSize,on=nn.scaleFactor,an=nn.maxNumScales,sn=nn.scoreThresholds,ln=nn.scaleSteps,cn=(ln||pyramidDown(rn,on,[st,Mt])).filter(function(fo){var dd=getSizesForScale(fo,[st,Mt]);return Math.min(dd.width,dd.height)>CELL_SIZE}).slice(0,an),Ye.scales=cn,Ye.pyramid=cn.map(function(fo){return getSizesForScale(fo,[st,Mt])}),un=Date.now(),[4,stage1(Ke,cn,sn[0],je.pnet,Ye)];case 1:return hn=Uo.sent(),Ye.total_stage1=Date.now()-un,hn.boxes.length?(Ye.stage2_numInputBoxes=hn.boxes.length,un=Date.now(),[4,stage2(Ge,hn.boxes,sn[1],je.rnet,Ye)]):[2,Qe({results:[],stats:Ye})];case 2:return fn=Uo.sent(),Ye.total_stage2=Date.now()-un,fn.boxes.length?(Ye.stage3_numInputBoxes=fn.boxes.length,un=Date.now(),[4,stage3(Ge,fn.boxes,sn[2],je.onet,Ye)]):[2,Qe({results:[],stats:Ye})];case 3:return to=Uo.sent(),Ye.total_stage3=Date.now()-un,Mi=to.boxes.map(function(fo,dd){return extendWithFaceLandmarks(extendWithFaceDetection({},new FaceDetection(to.scores[dd],new Rect(fo.left/Mt,fo.top/st,fo.width/Mt,fo.height/st),{height:st,width:Mt})),new FaceLandmarks5(to.points[dd].map(function(mo){return mo.sub(new Point(fo.left,fo.top)).div(new Point(fo.width,fo.height))}),{width:fo.width,height:fo.height}))}),[2,Qe({results:Mi,stats:Ye})]}})})},y.prototype.forward=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return je=this.forwardInput,[4,toNetInput(v)];case 1:return[4,je.apply(this,[Ge.sent(),$e])];case 2:return[2,Ge.sent().results]}})})},y.prototype.forwardWithStats=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return je=this.forwardInput,[4,toNetInput(v)];case 1:return[2,je.apply(this,[Ge.sent(),$e])]}})})},y.prototype.getDefaultModelName=function(){return"mtcnn_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap(v)},y.prototype.extractParams=function(v){return extractParams(v)},y}(NeuralNetwork),IOU_THRESHOLD=.4,BOX_ANCHORS=[new Point(1.603231,2.094468),new Point(6.041143,7.080126),new Point(2.882459,3.518061),new Point(4.266906,5.178857),new Point(9.041765,10.66308)],MEAN_RGB=[117.001,114.697,97.404],TinyFaceDetector=function(m){__extends(y,m);function y(){var v=this,$e={withSeparableConvs:!0,iouThreshold:IOU_THRESHOLD,classes:["face"],anchors:BOX_ANCHORS,meanRgb:MEAN_RGB,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return v=m.call(this,$e)||this,v}return Object.defineProperty(y.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),y.prototype.locateFaces=function(v,$e){return __awaiter(this,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.detect(v,$e)];case 1:return je=Ge.sent(),[2,je.map(function(Ye){return new FaceDetection(Ye.score,Ye.relativeBox,{width:Ye.imageWidth,height:Ye.imageHeight})})]}})})},y.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},y.prototype.extractParamsFromWeigthMap=function(v){return m.prototype.extractParamsFromWeigthMap.call(this,v)},y}(TinyYolov2Base),nets={ssdMobilenetv1:new SsdMobilenetv1,tinyFaceDetector:new TinyFaceDetector,tinyYolov2:new TinyYolov2,mtcnn:new Mtcnn,faceLandmark68Net:new FaceLandmark68Net,faceLandmark68TinyNet:new FaceLandmark68TinyNet,faceRecognitionNet:new FaceRecognitionNet,faceExpressionNet:new FaceExpressionNet,ageGenderNet:new AgeGenderNet},PredictFaceExpressionsTaskBase=function(m){__extends(y,m);function y(v,$e,je){var Ge=m.call(this)||this;return Ge.parentTask=v,Ge.input=$e,Ge.extractedFaces=je,Ge}return y}(ComposableTask),PredictAllFaceExpressionsTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je=this;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.parentTask];case 1:return v=Ge.sent(),[4,extractAllFacesAndComputeResults(v,this.input,function(Ye){return __awaiter(je,void 0,void 0,function(){return __generator(this,function(qe){switch(qe.label){case 0:return[4,Promise.all(Ye.map(function(Ke){return nets.faceExpressionNet.predictExpressions(Ke)}))];case 1:return[2,qe.sent()]}})})},this.extractedFaces)];case 2:return $e=Ge.sent(),[2,v.map(function(Ye,qe){return extendWithFaceExpressions(Ye,$e[qe])})]}})})},y.prototype.withAgeAndGender=function(){return new PredictAllAgeAndGenderTask(this,this.input)},y}(PredictFaceExpressionsTaskBase),PredictSingleFaceExpressionsTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e;return __generator(this,function(je){switch(je.label){case 0:return[4,this.parentTask];case 1:return v=je.sent(),v?[4,extractSingleFaceAndComputeResult(v,this.input,function(Ge){return nets.faceExpressionNet.predictExpressions(Ge)},this.extractedFaces)]:[2];case 2:return $e=je.sent(),[2,extendWithFaceExpressions(v,$e)]}})})},y.prototype.withAgeAndGender=function(){return new PredictSingleAgeAndGenderTask(this,this.input)},y}(PredictFaceExpressionsTaskBase),PredictAllFaceExpressionsWithFaceAlignmentTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.withAgeAndGender=function(){return new PredictAllAgeAndGenderWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptors=function(){return new ComputeAllFaceDescriptorsTask(this,this.input)},y}(PredictAllFaceExpressionsTask),PredictSingleFaceExpressionsWithFaceAlignmentTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.withAgeAndGender=function(){return new PredictSingleAgeAndGenderWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptor=function(){return new ComputeSingleFaceDescriptorTask(this,this.input)},y}(PredictSingleFaceExpressionsTask),PredictAgeAndGenderTaskBase=function(m){__extends(y,m);function y(v,$e,je){var Ge=m.call(this)||this;return Ge.parentTask=v,Ge.input=$e,Ge.extractedFaces=je,Ge}return y}(ComposableTask),PredictAllAgeAndGenderTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je=this;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.parentTask];case 1:return v=Ge.sent(),[4,extractAllFacesAndComputeResults(v,this.input,function(Ye){return __awaiter(je,void 0,void 0,function(){return __generator(this,function(qe){switch(qe.label){case 0:return[4,Promise.all(Ye.map(function(Ke){return nets.ageGenderNet.predictAgeAndGender(Ke)}))];case 1:return[2,qe.sent()]}})})},this.extractedFaces)];case 2:return $e=Ge.sent(),[2,v.map(function(Ye,qe){var Ke=$e[qe],Qe=Ke.age,Je=Ke.gender,st=Ke.genderProbability;return extendWithAge(extendWithGender(Ye,Je,st),Qe)})]}})})},y.prototype.withFaceExpressions=function(){return new PredictAllFaceExpressionsTask(this,this.input)},y}(PredictAgeAndGenderTaskBase),PredictSingleAgeAndGenderTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye;return __generator(this,function(qe){switch(qe.label){case 0:return[4,this.parentTask];case 1:return v=qe.sent(),v?[4,extractSingleFaceAndComputeResult(v,this.input,function(Ke){return nets.ageGenderNet.predictAgeAndGender(Ke)},this.extractedFaces)]:[2];case 2:return $e=qe.sent(),je=$e.age,Ge=$e.gender,Ye=$e.genderProbability,[2,extendWithAge(extendWithGender(v,Ge,Ye),je)]}})})},y.prototype.withFaceExpressions=function(){return new PredictSingleFaceExpressionsTask(this,this.input)},y}(PredictAgeAndGenderTaskBase),PredictAllAgeAndGenderWithFaceAlignmentTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.withFaceExpressions=function(){return new PredictAllFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptors=function(){return new ComputeAllFaceDescriptorsTask(this,this.input)},y}(PredictAllAgeAndGenderTask),PredictSingleAgeAndGenderWithFaceAlignmentTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.withFaceExpressions=function(){return new PredictSingleFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptor=function(){return new ComputeSingleFaceDescriptorTask(this,this.input)},y}(PredictSingleAgeAndGenderTask),ComputeFaceDescriptorsTaskBase=function(m){__extends(y,m);function y(v,$e){var je=m.call(this)||this;return je.parentTask=v,je.input=$e,je}return y}(ComposableTask),ComputeAllFaceDescriptorsTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e;return __generator(this,function(je){switch(je.label){case 0:return[4,this.parentTask];case 1:return v=je.sent(),[4,extractAllFacesAndComputeResults(v,this.input,function(Ge){return Promise.all(Ge.map(function(Ye){return nets.faceRecognitionNet.computeFaceDescriptor(Ye)}))},null,function(Ge){return Ge.landmarks.align(null,{useDlibAlignment:!0})})];case 2:return $e=je.sent(),[2,$e.map(function(Ge,Ye){return extendWithFaceDescriptor(v[Ye],Ge)})]}})})},y.prototype.withFaceExpressions=function(){return new PredictAllFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withAgeAndGender=function(){return new PredictAllAgeAndGenderWithFaceAlignmentTask(this,this.input)},y}(ComputeFaceDescriptorsTaskBase),ComputeSingleFaceDescriptorTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e;return __generator(this,function(je){switch(je.label){case 0:return[4,this.parentTask];case 1:return v=je.sent(),v?[4,extractSingleFaceAndComputeResult(v,this.input,function(Ge){return nets.faceRecognitionNet.computeFaceDescriptor(Ge)},null,function(Ge){return Ge.landmarks.align(null,{useDlibAlignment:!0})})]:[2];case 2:return $e=je.sent(),[2,extendWithFaceDescriptor(v,$e)]}})})},y.prototype.withFaceExpressions=function(){return new PredictSingleFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withAgeAndGender=function(){return new PredictSingleAgeAndGenderWithFaceAlignmentTask(this,this.input)},y}(ComputeFaceDescriptorsTaskBase),DetectFaceLandmarksTaskBase=function(m){__extends(y,m);function y(v,$e,je){var Ge=m.call(this)||this;return Ge.parentTask=v,Ge.input=$e,Ge.useTinyLandmarkNet=je,Ge}return Object.defineProperty(y.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?nets.faceLandmark68TinyNet:nets.faceLandmark68Net},enumerable:!0,configurable:!0}),y}(ComposableTask),DetectAllFaceLandmarksTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye,qe=this;return __generator(this,function(Ke){switch(Ke.label){case 0:return[4,this.parentTask];case 1:return v=Ke.sent(),$e=v.map(function(Qe){return Qe.detection}),this.input instanceof wt?[4,extractFaceTensors(this.input,$e)]:[3,3];case 2:return Ge=Ke.sent(),[3,5];case 3:return[4,extractFaces(this.input,$e)];case 4:Ge=Ke.sent(),Ke.label=5;case 5:return je=Ge,[4,Promise.all(je.map(function(Qe){return qe.landmarkNet.detectLandmarks(Qe)}))];case 6:return Ye=Ke.sent(),je.forEach(function(Qe){return Qe instanceof wt&&Qe.dispose()}),[2,v.map(function(Qe,Je){return extendWithFaceLandmarks(Qe,Ye[Je])})]}})})},y.prototype.withFaceExpressions=function(){return new PredictAllFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withAgeAndGender=function(){return new PredictAllAgeAndGenderWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptors=function(){return new ComputeAllFaceDescriptorsTask(this,this.input)},y}(DetectFaceLandmarksTaskBase),DetectSingleFaceLandmarksTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye;return __generator(this,function(qe){switch(qe.label){case 0:return[4,this.parentTask];case 1:return v=qe.sent(),v?($e=v.detection,this.input instanceof wt?[4,extractFaceTensors(this.input,[$e])]:[3,3]):[2];case 2:return Ge=qe.sent(),[3,5];case 3:return[4,extractFaces(this.input,[$e])];case 4:Ge=qe.sent(),qe.label=5;case 5:return je=Ge,[4,this.landmarkNet.detectLandmarks(je[0])];case 6:return Ye=qe.sent(),je.forEach(function(Ke){return Ke instanceof wt&&Ke.dispose()}),[2,extendWithFaceLandmarks(v,Ye)]}})})},y.prototype.withFaceExpressions=function(){return new PredictSingleFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withAgeAndGender=function(){return new PredictSingleAgeAndGenderWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptor=function(){return new ComputeSingleFaceDescriptorTask(this,this.input)},y}(DetectFaceLandmarksTaskBase),DetectFacesTaskBase=function(m){__extends(y,m);function y(v,$e){$e===void 0&&($e=new SsdMobilenetv1Options);var je=m.call(this)||this;return je.input=v,je.options=$e,je}return y}(ComposableTask),DetectAllFacesTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge;return __generator(this,function(Ye){switch(Ye.label){case 0:return v=this,$e=v.input,je=v.options,je instanceof MtcnnOptions?[4,nets.mtcnn.forward($e,je)]:[3,2];case 1:return[2,Ye.sent().map(function(qe){return qe.detection})];case 2:if(Ge=je instanceof TinyFaceDetectorOptions?function(qe){return nets.tinyFaceDetector.locateFaces(qe,je)}:je instanceof SsdMobilenetv1Options?function(qe){return nets.ssdMobilenetv1.locateFaces(qe,je)}:je instanceof TinyYolov2Options?function(qe){return nets.tinyYolov2.locateFaces(qe,je)}:null,!Ge)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,Ge($e)]}})})},y.prototype.runAndExtendWithFaceDetections=function(){var v=this;return new Promise(function($e){return __awaiter(v,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.run()];case 1:return je=Ge.sent(),[2,$e(je.map(function(Ye){return extendWithFaceDetection({},Ye)}))]}})})})},y.prototype.withFaceLandmarks=function(v){return v===void 0&&(v=!1),new DetectAllFaceLandmarksTask(this.runAndExtendWithFaceDetections(),this.input,v)},y.prototype.withFaceExpressions=function(){return new PredictAllFaceExpressionsTask(this.runAndExtendWithFaceDetections(),this.input)},y.prototype.withAgeAndGender=function(){return new PredictAllAgeAndGenderTask(this.runAndExtendWithFaceDetections(),this.input)},y}(DetectFacesTaskBase);(function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e;return __generator(this,function(je){switch(je.label){case 0:return[4,new DetectAllFacesTask(this.input,this.options)];case 1:return v=je.sent(),$e=v[0],v.forEach(function(Ge){Ge.score>$e.score&&($e=Ge)}),[2,$e]}})})},y.prototype.runAndExtendWithFaceDetection=function(){var v=this;return new Promise(function($e){return __awaiter(v,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.run()];case 1:return je=Ge.sent(),[2,$e(je?extendWithFaceDetection({},je):void 0)]}})})})},y.prototype.withFaceLandmarks=function(v){return v===void 0&&(v=!1),new DetectSingleFaceLandmarksTask(this.runAndExtendWithFaceDetection(),this.input,v)},y.prototype.withFaceExpressions=function(){return new PredictSingleFaceExpressionsTask(this.runAndExtendWithFaceDetection(),this.input)},y.prototype.withAgeAndGender=function(){return new PredictSingleAgeAndGenderTask(this.runAndExtendWithFaceDetection(),this.input)},y})(DetectFacesTaskBase);function detectAllFaces(m,y){return y===void 0&&(y=new SsdMobilenetv1Options),new DetectAllFacesTask(m,y)}function euclideanDistance(m,y){if(m.length!==y.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var v=Array.from(m),$e=Array.from(y);return Math.sqrt(v.map(function(je,Ge){return je-$e[Ge]}).reduce(function(je,Ge){return je+Math.pow(Ge,2)},0))}(function(){function m(y,v){v===void 0&&(v=.6),this._distanceThreshold=v;var $e=Array.isArray(y)?y:[y];if(!$e.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var je=1,Ge=function(){return"person "+je++};this._labeledDescriptors=$e.map(function(Ye){if(Ye instanceof LabeledFaceDescriptors)return Ye;if(Ye instanceof Float32Array)return new LabeledFaceDescriptors(Ge(),[Ye]);if(Ye.descriptor&&Ye.descriptor instanceof Float32Array)return new LabeledFaceDescriptors(Ge(),[Ye.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")})}return Object.defineProperty(m.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),m.prototype.computeMeanDistance=function(y,v){return v.map(function($e){return euclideanDistance($e,y)}).reduce(function($e,je){return $e+je},0)/(v.length||1)},m.prototype.matchDescriptor=function(y){var v=this;return this.labeledDescriptors.map(function($e){var je=$e.descriptors,Ge=$e.label;return new FaceMatch(Ge,v.computeMeanDistance(y,je))}).reduce(function($e,je){return $e.distance<je.distance?$e:je})},m.prototype.findBestMatch=function(y){var v=this.matchDescriptor(y);return v.distance<this.distanceThreshold?v:new FaceMatch("unknown",v.distance)},m.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(y){return y.toJSON()})}},m.fromJSON=function(y){var v=y.labeledDescriptors.map(function($e){return LabeledFaceDescriptors.fromJSON($e)});return new m(v,y.distanceThreshold)},m})();let _modelLoaded=!1;async function loadModels(m="/models"){_modelLoaded||(await Promise.all([nets.tinyFaceDetector.loadFromUri(m),nets.faceLandmark68TinyNet.loadFromUri(m)]),_modelLoaded=!0)}function getBase64ImageSize(m){const y=m.indexOf("base64,");return y<0?-1:(m.substr(y+6).length*.75).toFixed(2)}function base64toFile(m,y,v){let $e=atob(m),je=$e.length,Ge=new Uint8Array(je);for(;je--;)Ge[je]=$e.charCodeAt(je);return new File([Ge],y,{type:v})}function createEyeMask(m,y){const v=[...m,...y],$e=v.map(st=>st.x),je=v.map(st=>st.y),Ge=Math.min(...$e),Ye=Math.max(...$e),qe=Math.min(...je),Ke=Math.max(...je),Qe=(Ye-Ge)*.4,Je=(Ke-qe)*.8+6;return{x:Ge-Qe,y:qe-Je,width:Ye-Ge+Qe*2,height:Ke-qe+Je*2}}function applyMosaic(m,y){const v=Math.max(0,Math.round(y.x)),$e=Math.max(0,Math.round(y.y)),je=Math.round(y.width),Ge=Math.round(y.height);m.fillStyle="#000000",m.fillRect(v,$e,je,Ge)}async function faceMaskImage(m,y,v="/models"){await loadModels(v);const $e=await new Promise((Qe,Je)=>{const st=new Image;st.crossOrigin="anonymous",st.onload=()=>Qe(st),st.onerror=Je,st.src=m}),je=await detectAllFaces($e,new TinyFaceDetectorOptions).withFaceLandmarks(!0);if(!je.length){console.warn("faceMaskImage: 未检测到人脸"),y&&y(null);return}const Ge=document.createElement("canvas");Ge.width=$e.naturalWidth,Ge.height=$e.naturalHeight;const Ye=Ge.getContext("2d");Ye.drawImage($e,0,0),je.forEach(({landmarks:Qe})=>{const Je=Qe.getLeftEye(),st=Qe.getRightEye(),Mt=createEyeMask(Je,st);applyMosaic(Ye,Mt)});const qe=Ge.toDataURL("image/jpeg",.9),Ke=getBase64ImageSize(qe);console.log("faceMaskImage 处理后大小(字节):",Ke),y&&y(base64toFile(qe.split(",")[1],"face-masked.jpg","image/jpeg"))}const fun=(m,y,v)=>y.then($e=>/^image\/\w+/.test(m.type)?new Promise((je,Ge)=>{let Ye=v.fileList.filter(qe=>qe.raw&&qe.raw==m)[0];if(!Ye){Ge();return}Ye.message="打码处理中...",faceMaskImage(URL.createObjectURL(m),qe=>{if(Ye.message="",!qe){je(m);return}setBaseProps(qe,Ye.raw),Ye.raw=qe,je(Ye.raw)})}):!0),uploadProcess={compress:fun$1,face:fun};function useOssUploader(m,y,v={fileType:[],requireMd5:!1,request:null,signatureUrl:"",addFileMd5Url:"",queryFileMd5Url:"",beginUploadFlow:[]}){let $e=1;const je=async function(Qe){debugger;let Je=Qe.url;if(Qe.objUrl)return Qe.objUrl;if(!Qe.loading)return Qe.loading=!0,Qe.loadError=!1,await axios({method:"GET",url:Je,responseType:"blob",onDownloadProgress:st=>{let Mt=st.total>0?st.loaded/st.total*100:0;Qe.loadingPercent=isNaN(Mt)?0:Mt}}).then(st=>{const{data:Mt,headers:nn}=st;Qe.objUrl=URL.createObjectURL(Mt);let rn=new Image;rn.src=Qe.objUrl,rn.onload=()=>{Qe.width=rn.width,Qe.height=rn.height,Qe.viewBox=[0,0,Qe.width,Qe.height],Qe.matrix=[[1,0],[0,1],[0,0]],Qe.loading=!1}}).catch(()=>{Qe.loading=!1,Qe.loadError=!0})},Ge=async function(Qe){return await v.request({method:"GET",url:`${v.signatureUrl}${Qe}`})},Ye=async function(Qe){return await v.request({method:"POST",url:`${v.addFileMd5Url}`,data:Qe})},qe=async function(Qe){return await v.request({method:"GET",url:`${v.queryFileMd5Url}`,params:Qe})};let Ke=vue.reactive({fileList:y||[],onHttpRequest:async Qe=>{const{action:Je,file:st,onProgress:Mt,onSuccess:nn,onError:rn}=Qe;let on=await Ge(st.name);if(on.code!==200)throw new Error("Get signature error");const an=on.data,{accessid:sn,policy:ln,signature:cn,dir:un,host:hn}=an;let fn=new FormData;return fn.append("key",un),fn.append("policy",ln),fn.append("OSSAccessKeyId",sn),fn.append("success_action_status","200"),fn.append("signature",cn),fn.append("file",st),await axios.create({onUploadProgress:Mi=>{Mi.percent=Mi.total>0?Mi.loaded/Mi.total*100:0,Mt(Mi)}}).post(hn,fn,{headers:{"Content-Type":"multipart/form-data"}}).then(Mi=>({code:200,fileName:hn+un}))},onBeforeUpload:Qe=>new Promise((Je,st)=>{let Mt=new Promise(nn=>{nn(!0)});Mt=Mt.then(nn=>new Promise(rn=>{Ke.md5({raw:Qe}).then(on=>{rn(on)})})),v.requireMd5&&(Mt=Mt.then(nn=>qe({mdaValue:nn}).then(rn=>{if(rn.rows.length){let on={name:rn.rows[0].filePath,url:rn.rows[0].filePath};throw on.uid=on.uid||$e++,on.status="success",Ke.fileList.push(on),Ke.fileList.map(an=>{je(an)}),new Error("文件已存在")}else return Qe.md5=nn,!0})));for(let nn of v.beginUploadFlow)typeof nn=="string"&&(Mt=uploadProcess[nn](Qe,Mt,Ke));Mt.then(nn=>{Je(nn)}).catch(nn=>{st(!1)})}),onChange:(Qe,Je)=>{if(console.log("onChange:"+Qe.status),Qe.status=="ready"){if(v.fileType&&v.fileType.length>0&&v.fileType.indexOf(Qe.name.split(".").pop().toLocaleLowerCase())==-1)throw Je.splice(Je.indexOf(Qe),1),ElMessage.error(`文件格式不正确, 请上传${v.fileType.join("/")}格式文件!`),new Error("文件格式不正确");Qe.uid=Qe.uid||$e++}else Qe.status=="success"&&(Qe.url=Qe.response.fileName,je(Qe),v.requireMd5&&Ye({filePath:Qe.url,mdaValue:Qe.raw.md5}))},init:function(Qe){Qe=Qe||"",Ke.fileList=(Array.isArray(Qe)?Qe:Qe.length?Qe.split(","):[]).map(Je=>(typeof Je=="string"&&(Je={name:Je,url:Je}),Je.uid=Je.uid||new Date().getTime()+$e++,Je.status="success",Je)),Ke.fileList.map(Je=>{je(Je)})},md5(Qe){return new Promise((Je,st)=>{const Mt=Qe.raw,rn=Math.ceil(Mt.size/10),on=new FileReader,an=new SparkMD5;let sn=0;const ln=()=>{const cn=Mt.slice(sn,sn+rn);on.readAsBinaryString(cn)};on.onload=cn=>{an.appendBinary(cn.target.result),sn<Mt.size?(sn+=rn,ln()):Je(an.end())},ln()})},previewDownload:Qe=>{let Je=document.createElement("a");Je.download=Qe.name,Je.href=Qe.url,Je.click(),window.URL.revokeObjectURL(Je.href)}});return Ke.init(m),[Ke,je]}const _hoisted_1$4={class:"w-full"},_hoisted_2$4={class:"flex justify-center"},_hoisted_3$3={key:0,class:"el-upload__tip font-bold"},_hoisted_4$3={style:{color:"#f56c6c"}},_hoisted_5$3={style:{color:"#f56c6c"}},_sfc_main$4={__name:"index",props:{modelValue:[String,Object,Array],multipleSelect:{type:Boolean,default:!0},drag:{type:Boolean,default:!1},limit:{type:Number,default:5},fileMaxSize:{type:Number,default:5},fileType:{type:Array,default:()=>["pdf","doc","docx","xls","xlsx","rar"]},isShowTip:{type:Boolean,default:!0},size:{default:()=>({width:"148px",height:"148px"})},view:{type:String,default:null},operations:{default:()=>({back:!1,close:!1,rotateLeft:!1,rotateRight:!1})},md5:{type:Object,default:()=>({requireMd5:!1,addFileMd5Url:"",queryFileMd5Url:""})},oss:{type:Object,default:()=>({signatureUrl:""})}},setup(m,{emit:y}){const v=m,$e=vue.useAttrs(),je=y;vue.ref(0),vue.ref([]);const Ge=vue.ref([]),Ye=vue.computed(()=>v.isShowTip&&(v.fileType||v.fileMaxSize)),qe=vue.inject("request"),[Ke]=useOssUploader("",Ge,{request:qe,fileType:v.fileType,signatureUrl:v.oss.signatureUrl,requireMd5:v.md5.requireMd5,addFileMd5Url:v.md5.addFileMd5Url,queryFileMd5Url:v.md5.queryFileMd5Url});function Qe(Mt,nn){let rn="";nn=nn||",";for(let on in Mt)Mt[on].url!==void 0&&Mt[on].url.indexOf("blob:")!==0&&(rn+=Mt[on].url+nn);return rn!=""?rn.substr(0,rn.length-1):""}const Je=()=>{(Ge.value.length==0||Ge.value.every(Mt=>Mt.status=="success"))&&je("update:modelValue",Array.isArray(v.modelValue)?Ge.value:Qe(Ge.value))};function st(Mt,nn,rn){nn.url=nn.response.fileName,Je()}return vue.watch(()=>v.modelValue,Mt=>{if(Mt)Ke.init(Mt);else return Ge.value=[]},{deep:!0,immediate:!0}),vue.watch(()=>Ge.value.length,()=>{console.log("fileupload filelist changed....."),Je()}),(Mt,nn)=>{const rn=vue.resolveComponent("sy-svg-icon"),on=vue.resolveComponent("el-button"),an=vue.resolveComponent("el-upload");return vue.openBlock(),vue.createElementBlock("div",_hoisted_1$4,[vue.createVNode(an,vue.mergeProps({class:"upload-file",drag:m.drag,multiple:"","http-request":vue.unref(Ke).onHttpRequest,"on-success":st,"on-change":vue.unref(Ke).onChange,"before-upload":vue.unref(Ke).onBeforeUpload,"file-list":vue.unref(Ke).fileList,"onUpdate:fileList":nn[0]||(nn[0]=sn=>vue.unref(Ke).fileList=sn),"on-preview":vue.unref(Ke).previewDownload},vue.unref($e)),{default:vue.withCtx(()=>[vue.renderSlot(Mt.$slots,"default",{},()=>[m.drag?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[vue.createElementVNode("div",_hoisted_2$4,[vue.createVNode(rn,{"icon-class":"upload","class-name":"",style:{width:"3rem",height:"3rem",color:"var(--el-color-primary)"}})]),nn[1]||(nn[1]=vue.createElementVNode("div",{class:"el-upload__text"},[vue.createTextVNode(" 将文件拖拽入这里或 "),vue.createElementVNode("em",null,"点击上传")],-1))],64)):(vue.openBlock(),vue.createBlock(on,{key:1,type:"primary",disabled:vue.unref($e).disabled},{default:vue.withCtx(()=>nn[2]||(nn[2]=[vue.createTextVNode("点击上传")])),_:1},8,["disabled"]))])]),tip:vue.withCtx(()=>[Ye.value?(vue.openBlock(),vue.createElementBlock("div",_hoisted_3$3,[nn[5]||(nn[5]=vue.createTextVNode(" 请上传 ")),m.fileMaxSize?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[nn[3]||(nn[3]=vue.createTextVNode(" 大小不超过 ")),vue.createElementVNode("b",_hoisted_4$3,vue.toDisplayString(m.fileMaxSize)+"MB",1)],64)):vue.createCommentVNode("",!0),m.fileType?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[nn[4]||(nn[4]=vue.createTextVNode(" 格式为 ")),vue.createElementVNode("b",_hoisted_5$3,vue.toDisplayString(m.fileType.join("/")),1)],64)):vue.createCommentVNode("",!0),nn[6]||(nn[6]=vue.createTextVNode(" 的文件 "))])):vue.createCommentVNode("",!0)]),_:3},16,["drag","http-request","on-change","before-upload","file-list","on-preview"])])}}},index$8=Object.freeze(Object.defineProperty({__proto__:null,default:_sfc_main$4},Symbol.toStringTag,{value:"Module"})),Mode={CONTAIN:{name:"contain",icon:"FullScreen"},ORIGINAL:{name:"original",icon:"ScaleToOriginal"}},_hoisted_1$3={class:"x-image-viewer__wrapper"},_hoisted_2$3={key:1,class:"x-image-viewer__btn x-image-viewer__desc"},_hoisted_3$2={class:"x-image-viewer__btn x-image-viewer__actions"},_hoisted_4$2={class:"x-image-viewer__actions__inner"},_hoisted_5$2=["src"],mousewheelEventName="mousewheel",_sfc_main$3={__name:"index",props:{urls:{type:Array,default:()=>[]},zIndex:{type:Number,default:9e3},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},hideOnClickModal:{type:Boolean,default:!1},animateClass:{type:String,default:"fadeInDown"}},emits:["close","change"],setup(m,{emit:y}){const v=m,$e=y;let je=null;const Ge=vue.ref(!0),Ye=vue.ref(!1),qe=vue.ref(v.initialIndex),Ke=vue.ref(null),Qe=vue.ref(Mode.CONTAIN),Je=vue.ref({scale:1,deg:0,offsetX:0,offsetY:0,rotateX:0,rotateY:0,enableTransition:!1}),st=vue.computed(()=>{const{urls:co}=v;return co.length<=1}),Mt=vue.computed(()=>qe.value===0),nn=vue.computed(()=>qe.value===0),rn=vue.computed(()=>v.urls[qe.value]),on=vue.computed(()=>{const{scale:co,deg:uo,offsetX:od,offsetY:rd,rotateX:ld,rotateY:hd,enableTransition:pd}=Je.value,fd={transform:`scale(${co}) rotate(${uo}deg) rotateX(${ld}deg) rotateY(${hd}deg)`,transition:pd?"transform .3s":"",marginLeft:`${od}px`,marginTop:`${rd}px`};return Qe.value.name===Mode.CONTAIN.name&&(fd.maxWidth="100%",fd.maxHeight="100%"),fd});function an(){$e("close")}function sn(){Ge.value=!1,Ye.value=!0}function ln(){Ge.value=!1}function cn(co){let uo=!1;return function(...od){uo||(uo=!0,window.requestAnimationFrame(()=>{co.apply(this,od),uo=!1}))}}const un=function(co,uo,od,rd=!1){co&&uo&&od&&co.addEventListener(uo,od,rd)},hn=function(co,uo,od,rd=!1){co&&uo&&od&&co.removeEventListener(uo,od,rd)};function fn(co){if(Ge.value||co.button!==0)return;const{offsetX:uo,offsetY:od}=Je.value,rd=co.pageX,ld=co.pageY;je=cn(hd=>{Je.value={...Je.value,offsetX:uo+hd.pageX-rd,offsetY:od+hd.pageY-ld}}),un(document,"mousemove",je),un(document,"mouseup",()=>{hn(document,"mousemove",je)}),co.preventDefault()}function to(){Je.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1,rotateX:0,rotateY:0}}function Mi(co,uo={}){if(Ge.value)return;const{zoomRate:od,rotateDeg:rd,rotateXDeg:ld,rotateYDeg:hd,enableTransition:pd}={zoomRate:.2,rotateDeg:90,rotateXDeg:180,rotateYDeg:180,enableTransition:!0,...uo};if(co==="zoomOut")Je.value.scale>.2&&(Je.value.scale=parseFloat((Je.value.scale-od).toFixed(3)));else if(co==="zoomIn")Je.value.scale=parseFloat((Je.value.scale+od).toFixed(3));else if(co==="clocelise")Je.value.deg+=rd;else if(co==="anticlocelise")Je.value.deg-=rd;else if(co==="fliphorizontal"){let fd=Je.value.deg!=0&&Math.abs(Je.value.deg)/rd%2!=0?"rotateX":"rotateY";Je.value[fd]=Je.value[fd]?0:hd}else if(co==="flipvertical"){let fd=Je.value.deg!=0&&Math.abs(Je.value.deg)/rd%2!=0?"rotateY":"rotateX";Je.value[fd]=Je.value[fd]?0:ld}Je.value.enableTransition=pd}function Uo(){if(Ge.value)return;const co=Object.keys(Mode),uo=Object.values(Mode),od=Qe.value.name,ld=(uo.findIndex(hd=>hd.name===od)+1)%co.length;Qe.value=Mode[co[ld]],to()}function fo(){if(Mt.value&&!v.infinite)return;const co=v.urls.length;qe.value=(qe.value-1+co)%co,Ye.value=!1}function dd(){if(nn.value&&!v.infinite)return;const co=v.urls.length;qe.value=(qe.value+1)%co,Ye.value=!1}let mo=null,ho=null;const Xr=()=>{mo=cn(uo=>{switch(uo.keyCode){case 27:an();break;case 32:Uo();break;case 37:this.prev();break;case 38:Mi("zoomIn");break;case 39:this.next();break;case 40:Mi("zoomOut");break}});let co=cn(uo=>{(uo.wheelDelta?uo.wheelDelta:-uo.detail)>0?Mi("zoomIn",{zoomRate:.09,enableTransition:!1}):Mi("zoomOut",{zoomRate:.09,enableTransition:!1})});un(document,"keydown",mo),un(document,mousewheelEventName,co)},lo=()=>{hn(document,"keydown",mo),hn(document,mousewheelEventName,ho),mo=null,ho=null};return vue.watch(rn,()=>{vue.nextTick(()=>{Ke.value.complete||(Ge.value=!0)})}),vue.watch(qe,co=>{to(),$e("change",co)}),vue.onMounted(()=>{vue.nextTick(()=>{const co=document.querySelector("body");co.append?co.append(document.getElementById("x-image-viewer")):co.appendChild(document.getElementById("x-image-viewer")),Xr()})}),vue.onUnmounted(()=>{document.querySelector("body").removeChild(document.getElementById("x-image-viewer")),lo()}),(co,uo)=>{const od=vue.resolveComponent("el-icon-close"),rd=vue.resolveComponent("el-icon"),ld=vue.resolveComponent("el-icon-zoom-out"),hd=vue.resolveComponent("el-icon-zoom-in"),pd=vue.resolveComponent("el-icon-refresh-left"),fd=vue.resolveComponent("el-icon-refresh-right"),vd=vue.resolveComponent("el-icon-switch"),gd=vue.resolveComponent("el-icon-sort");return vue.openBlock(),vue.createElementBlock("template",null,[vue.createElementVNode("div",{id:"x-image-viewer",class:"x-image-viewer",style:vue.normalizeStyle({zIndex:m.zIndex})},[vue.createElementVNode("div",_hoisted_1$3,[vue.createElementVNode("div",{class:"x-image-viewer__mask",onClick:uo[0]||(uo[0]=vue.withModifiers(yd=>m.hideOnClickModal&&an(),["self"]))}),vue.createElementVNode("span",{class:"x-image-viewer__btn x-image-viewer__close",onClick:an},[vue.createVNode(rd,null,{default:vue.withCtx(()=>[vue.createVNode(od)]),_:1})]),st.value?vue.createCommentVNode("",!0):(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[vue.createElementVNode("span",{class:vue.normalizeClass(["x-image-viewer__btn x-image-viewer__prev",{"is-disabled":!m.infinite&&Mt.value}]),onClick:fo},uo[7]||(uo[7]=[vue.createElementVNode("i",{class:"el-icon-arrow-left"},null,-1)]),2),vue.createElementVNode("span",{class:vue.normalizeClass(["x-image-viewer__btn x-image-viewer__next",{"is-disabled":!m.infinite&&nn.value}]),onClick:dd},uo[8]||(uo[8]=[vue.createElementVNode("i",{class:"el-icon-arrow-right"},null,-1)]),2)],64)),rn.value.desc?(vue.openBlock(),vue.createElementBlock("div",_hoisted_2$3,vue.toDisplayString(rn.value.desc),1)):vue.createCommentVNode("",!0),vue.createElementVNode("div",_hoisted_3$2,[vue.createElementVNode("div",_hoisted_4$2,[vue.createVNode(rd,{onClick:uo[1]||(uo[1]=yd=>Mi("zoomOut"))},{default:vue.withCtx(()=>[vue.createVNode(ld)]),_:1}),vue.createVNode(rd,{onClick:uo[2]||(uo[2]=yd=>Mi("zoomIn"))},{default:vue.withCtx(()=>[vue.createVNode(hd)]),_:1}),uo[9]||(uo[9]=vue.createElementVNode("i",{class:"x-image-viewer__actions__divider"},null,-1)),vue.createVNode(rd,{onClick:Uo},{default:vue.withCtx(()=>[(vue.openBlock(),vue.createBlock(vue.resolveDynamicComponent(Qe.value.icon)))]),_:1}),uo[10]||(uo[10]=vue.createElementVNode("i",{class:"x-image-viewer__actions__divider"},null,-1)),vue.createVNode(rd,{onClick:uo[3]||(uo[3]=yd=>Mi("anticlocelise"))},{default:vue.withCtx(()=>[vue.createVNode(pd)]),_:1}),vue.createVNode(rd,{onClick:uo[4]||(uo[4]=yd=>Mi("clocelise"))},{default:vue.withCtx(()=>[vue.createVNode(fd)]),_:1}),vue.createVNode(rd,{onClick:uo[5]||(uo[5]=yd=>Mi("fliphorizontal"))},{default:vue.withCtx(()=>[vue.createVNode(vd)]),_:1}),vue.createVNode(rd,{onClick:uo[6]||(uo[6]=yd=>Mi("flipvertical"))},{default:vue.withCtx(()=>[vue.createVNode(gd)]),_:1})])]),vue.createElementVNode("div",{class:vue.normalizeClass(["x-image-viewer__canvas opacity-hide",[Ye.value===!0?"opacity-show animated "+m.animateClass:""]])},[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(m.urls,(yd,Td)=>vue.withDirectives((vue.openBlock(),vue.createElementBlock("img",{ref_for:!0,ref_key:"img",ref:Ke,key:yd,src:rn.value.src,style:vue.normalizeStyle(on.value),class:"x-image-viewer__img",onLoad:sn,onError:ln,onMousedown:fn},null,44,_hoisted_5$2)),[[vue.vShow,Td===qe.value]])),128))],2)])],4)])}}},index$6=_export_sfc(_sfc_main$3,[["__scopeId","data-v-bf955e52"]]),index$7=Object.freeze(Object.defineProperty({__proto__:null,default:index$6},Symbol.toStringTag,{value:"Module"})),_hoisted_1$2={class:"component-upload-image"},_hoisted_2$2={style:{display:"flex",width:"100%"}},_hoisted_3$1={key:0,class:"relative rounded overflow-hidden flex justify-center items-center",style:{width:"120px",height:"96px","margin-top":"8px"}},_hoisted_4$1={class:"absolute"},_hoisted_5$1=["onClick"],_hoisted_6$1={class:"relative overflow-hidden flex flex-col justify-center items-center w-full h-full select-none outline-none"},_hoisted_7$1=["src"],_hoisted_8$1=["viewBox"],_hoisted_9$1=["transform"],_hoisted_10$1=["xlink:href","width","height"],_hoisted_11$1={class:"photo-operations"},_hoisted_12$1={class:"absolute top-0 right-0 w-full flex justify-end gap-1"},_hoisted_13$1={class:"opacity-[0.7] hover:opacity-[1] rounded-1/2"},_hoisted_14$1={class:"opacity-[0.7] hover:opacity-[1] rounded-1/2"},_hoisted_15$1={class:"absolute bottom-0 w-full flex justify-center gap-1"},_hoisted_16$1={class:"opacity-[0.7] hover:opacity-[1] rounded-1/2"},_hoisted_17$1={class:"opacity-[0.7] hover:opacity-[1] rounded-1/2"},_hoisted_18$1=["onClick"],_hoisted_19$1={key:0,class:"el-upload__tip"},_hoisted_20$1={style:{color:"#f56c6c"}},_hoisted_21$1={style:{color:"#f56c6c"}},_sfc_main$2={__name:"index",props:{modelValue:[String,Object,Array],multipleSelect:{type:Boolean,default:!0},limit:{type:Number,default:5},fileMaxSize:{type:Number,default:5},fileType:{type:Array,default:()=>["png","jpg","jpeg","raw","tiff","jfif"]},isShowTip:{type:Boolean,default:!0},onDrop:{default:m=>{}},onBackPool:{default:m=>{}},defaultBg:String,disabled:{default:!1},size:{default:()=>({width:"148px",height:"148px"})},view:{type:String,default:null},operations:{default:()=>({back:!1,rotateLeft:!1,rotateRight:!1})},md5:{type:Object,default:()=>({requireMd5:!1,addFileMd5Url:"",queryFileMd5Url:""})},beginUploadFlow:{type:Array,default:()=>[]},oss:{type:Object,default:()=>({signatureUrl:""})}},setup(m,{expose:y,emit:v}){const $e=m,je=vue.useAttrs(),Ge=v;vue.ref(0),vue.ref([]);const Ye=vue.ref([]),qe=vue.computed(()=>$e.isShowTip&&($e.fileType||$e.fileMaxSize)),Ke=vue.inject("request"),[Qe,Je]=useOssUploader("",Ye,{request:Ke,fileType:$e.fileType,signatureUrl:$e.oss.signatureUrl,requireMd5:$e.md5.requireMd5,addFileMd5Url:$e.md5.addFileMd5Url,queryFileMd5Url:$e.md5.queryFileMd5Url,beginUploadFlow:$e.beginUploadFlow}),st=vue.ref(!1),Mt=vue.ref([]),nn=()=>{st.value=!1};function rn(){ElMessage.error(`上传文件数量不能超过 ${$e.limit} 个!`)}function on(){ElMessage.error("上传图片失败")}function an(Xr,lo){let co="";lo=lo||",";for(let uo in Xr)Xr[uo].url!==void 0&&Xr[uo].url.indexOf("blob:")!==0&&(co+=Xr[uo].url+lo);return co!=""?co.substr(0,co.length-1):""}function sn(Xr){console.log("enter"),Xr.preventDefault()}function ln(Xr){console.log("over"),Xr.preventDefault(),setTimeout(()=>{Xr.target.classList.add("over")},0)}function cn(Xr){console.log("drop"),Xr.preventDefault(),$e.onDrop&&$e.onDrop(Xr)}function un(Xr){$e.onBackPool&&$e.onBackPool(Xr)}function hn(Xr){dd(Xr)}function fn(Xr){Mt.value=[],Mt.value.push({src:Xr.url,desc:""}),st.value=!0}function to(Xr,lo){let co=[];for(let uo=0;uo<Xr.length;uo++){co[uo]=[];for(let od=0;od<lo[0].length;od++){let rd=0;for(let ld=0;ld<Xr[0].length;ld++)rd+=Xr[uo][ld]*lo[ld][od];co[uo][od]=rd}}return co}function Mi(Xr,lo){let co=Xr.hd=Xr.hd||0,uo=Xr.vd=Xr.vd||0,od=Xr.deg=Xr.deg||0,rd=Xr.viewBox,ld=Xr.matrix;if(lo=="rotateleft"){od+=90;let hd=[[Math.cos(90*(Math.PI/180)),-Math.sin(90*(Math.PI/180))],[Math.sin(90*(Math.PI/180)),Math.cos(90*(Math.PI/180))],[0,0]];ld=to(ld,hd),Xr.viewBox=Uo(Xr.hd!=co,Xr.vd!=uo,90,rd)}else if(lo=="rotateright"){od-=90;let hd=[[Math.cos(-90*(Math.PI/180)),-Math.sin(-90*(Math.PI/180))],[Math.sin(-90*(Math.PI/180)),Math.cos(-90*(Math.PI/180))],[0,0]];ld=to(ld,hd),Xr.viewBox=Uo(Xr.hd!=co,Xr.vd!=uo,-90,rd)}else lo=="fliphorizontal"?(co=co?0:1,ld=to(ld,[[-1,0],[0,1],[0,0]])):lo=="flipvertical"&&(uo=uo?0:1,ld=to(ld,[[1,0],[0,-1],[0,0]]));Xr.matrix=ld,Xr.deg=od,Xr.hd=co,Xr.vd=uo}function Uo(Xr,lo,co,uo){let od=JSON.parse(JSON.stringify(uo));const[rd,ld,hd,pd]=uo;if(Xr==!0&&(od[0]=od[0]==0-hd?0:0-hd),lo==!0&&(od[1]=od[1]==0-pd?0:0-pd),co){let fd=co/90%4;for(let vd=0;vd<Math.abs(fd);vd++)if(od[2]=pd,od[3]=hd,co>0){let gd=od[1];od[1]=od[0]==0-hd?0:0-hd,od[0]=gd}else{let gd=od[1];od[1]=od[0],od[0]=gd==0-pd?0:0-pd}}return od}const fo=Xr=>{Ye.value.push(Xr)},dd=Xr=>{Ye.value.indexOf(Xr)!=-1&&Ye.value.splice(Ye.value.indexOf(Xr),1)},mo=()=>{(Ye.value.length==0||Ye.value.every(Xr=>Xr.status=="success"))&&Ge("update:modelValue",Array.isArray($e.modelValue)?Ye.value:an(Ye.value))};function ho(Xr,lo,co){lo.url=lo.response.fileName,mo()}return vue.watch(()=>$e.modelValue,Xr=>{if(Xr)Qe.init(Xr);else return Ye.value=[]},{deep:!0,immediate:!0}),vue.watch(()=>Ye.value.length,()=>{console.log("imageupload filelist changed....."),mo()}),y({pushFile:fo,removeFile:dd}),(Xr,lo)=>{const co=vue.resolveComponent("el-icon"),uo=vue.resolveComponent("el-upload"),od=vue.resolveComponent("sy-svg-icon"),rd=vue.resolveComponent("sy-image-view");return vue.openBlock(),vue.createElementBlock("div",_hoisted_1$2,[vue.createElementVNode("div",_hoisted_2$2,[vue.createVNode(uo,vue.mergeProps({multiple:m.multipleSelect,ref:"imageUpload","show-file-list":!1,"file-list":Ye.value,"onUpdate:fileList":lo[0]||(lo[0]=ld=>Ye.value=ld),"http-request":vue.unref(Qe).onHttpRequest,"list-type":"picture-card",limit:m.limit,"on-success":ho,"on-change":vue.unref(Qe).onChange,"before-upload":vue.unref(Qe).onBeforeUpload,"on-error":on,"on-exceed":rn,class:{hidden:Ye.value.length>=m.limit,disabled:m.disabled},style:"width:"+(Ye.value.length>=m.limit?"auto":m.size.width)+";height:"+(Ye.value.length>=m.limit?"auto":m.size.height)+";"},vue.unref(je),{onDragenter:sn,onDragover:ln,onDrop:cn,"auto-upload":!0,disabled:m.disabled}),{default:vue.withCtx(()=>[vue.createElementVNode("div",{style:vue.normalizeStyle([{"background-position":"center","background-repeat":"no-repeat",width:"100%",height:"100%",display:"flex","justify-content":"center","align-items":"center"},m.defaultBg&&m.defaultBg!=""?"background-image:url("+m.defaultBg+");":""])},[!m.defaultBg||m.defaultBg==""?(vue.openBlock(),vue.createBlock(co,{key:0,class:"avatar-uploader-icon"},{default:vue.withCtx(()=>[vue.createVNode(vue.unref(plus_default))]),_:1})):vue.createCommentVNode("",!0)],4)]),_:1},16,["multiple","file-list","http-request","limit","on-change","before-upload","class","style","disabled"]),Ye.value.length>0?(vue.openBlock(),vue.createElementBlock("div",{key:0,class:vue.normalizeClass(["flex flex-wrap gap-2",{disabled:m.disabled,"ml-2":Ye.value.length<m.limit}])},[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(Ye.value,ld=>(vue.openBlock(),vue.createElementBlock("div",{key:ld.uid,class:"el-upload--picture-card",style:vue.normalizeStyle("width:"+m.size.width+";height:"+m.size.height+";")},[ld.status=="ready"||ld.status=="uploading"||ld.loading?(vue.openBlock(),vue.createElementBlock("div",_hoisted_3$1,[vue.createVNode(od,{"class-name":"icon-down","icon-class":"down"}),vue.createElementVNode("div",_hoisted_4$1,[ld.status=="uploading"?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[vue.createTextVNode("上传进度"+vue.toDisplayString(parseInt(ld.percentage||0))+"%",1)],64)):vue.createCommentVNode("",!0),ld.loading?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[vue.createTextVNode("加载进度"+vue.toDisplayString(parseInt(ld.loadingPercent||0))+"%",1)],64)):vue.createCommentVNode("",!0),ld.message?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:2},[vue.createTextVNode(vue.toDisplayString(ld.message),1)],64)):vue.createCommentVNode("",!0)])])):vue.createCommentVNode("",!0),ld.status=="success"&&!ld.loading?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[ld.loadError?vue.createCommentVNode("",!0):(vue.openBlock(),vue.createElementBlock("div",{key:0,onClick:hd=>fn(ld),class:"w-full h-full relative rounded overflow-hidden file-item"},[vue.createElementVNode("div",_hoisted_6$1,[m.view=="img"?(vue.openBlock(),vue.createElementBlock("img",{key:0,style:{width:"100%"},src:ld.objUrl,fit:"contain"},null,8,_hoisted_7$1)):(vue.openBlock(),vue.createElementBlock("svg",{key:1,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",viewBox:ld.viewBox.join(" "),xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[vue.createElementVNode("g",{class:"origin-top-left preserve-3d",transform:"matrix("+ld.matrix.join(",")+")"},[vue.createElementVNode("image",{"xlink:href":ld.objUrl,x:"0",y:"0",width:ld.width,height:ld.height},null,8,_hoisted_10$1)],8,_hoisted_9$1)],8,_hoisted_8$1))]),vue.createElementVNode("div",_hoisted_11$1,[vue.createElementVNode("div",_hoisted_12$1,[vue.withDirectives(vue.createElementVNode("div",_hoisted_13$1,[vue.createVNode(od,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(hd=>un(ld),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.back]]),vue.withDirectives(vue.createElementVNode("div",_hoisted_14$1,[vue.createVNode(od,{"class-name":"icon-photo ","icon-class":"close",onClick:vue.withModifiers(hd=>hn(ld),["stop"])},null,8,["onClick"])],512),[[vue.vShow,!m.operations.back]])]),vue.createElementVNode("div",_hoisted_15$1,[vue.withDirectives(vue.createElementVNode("div",_hoisted_16$1,[vue.createVNode(od,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(hd=>Mi(ld,"rotateleft"),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.rotateLeft]]),vue.withDirectives(vue.createElementVNode("div",_hoisted_17$1,[vue.createVNode(od,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(hd=>Mi(ld,"rotateright"),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.rotateRight]])])])],8,_hoisted_5$1)),ld.loadError?(vue.openBlock(),vue.createElementBlock("div",{key:1,onClick:hd=>vue.unref(Je)(ld),class:"w-full h-full relative rounded overflow-hidden file-item"},lo[1]||(lo[1]=[vue.createElementVNode("div",{class:"relative overflow-hidden flex flex-col justify-center items-center w-full h-full select-none outline-none"}," 加载失败 ",-1)]),8,_hoisted_18$1)):vue.createCommentVNode("",!0)],64)):vue.createCommentVNode("",!0)],4))),128))],2)):vue.createCommentVNode("",!0)]),qe.value?(vue.openBlock(),vue.createElementBlock("div",_hoisted_19$1,[lo[4]||(lo[4]=vue.createTextVNode(" 请上传 ")),m.fileMaxSize?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[lo[2]||(lo[2]=vue.createTextVNode(" 大小不超过 ")),vue.createElementVNode("b",_hoisted_20$1,vue.toDisplayString(m.fileMaxSize)+"MB",1)],64)):vue.createCommentVNode("",!0),m.fileType?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[lo[3]||(lo[3]=vue.createTextVNode(" 格式为 ")),vue.createElementVNode("b",_hoisted_21$1,vue.toDisplayString(m.fileType.join("/")),1)],64)):vue.createCommentVNode("",!0),lo[5]||(lo[5]=vue.createTextVNode(" 的文件 "))])):vue.createCommentVNode("",!0),st.value?(vue.openBlock(),vue.createBlock(rd,{key:1,urls:Mt.value,onClose:nn},null,8,["urls"])):vue.createCommentVNode("",!0)])}}},index$4=_export_sfc(_sfc_main$2,[["__scopeId","data-v-8342b270"]]),index$5=Object.freeze(Object.defineProperty({__proto__:null,default:index$4},Symbol.toStringTag,{value:"Module"})),_sfc_main$1={name:"SvgIcon",props:{iconClass:{type:String,required:!0},className:{type:String},title:{type:String,default:""}},computed:{iconName(){return`#icon-${this.iconClass}`},svgClass(){return this.className?"svg-icon "+this.className:"svg-icon"}}},_hoisted_1$1=["xlink:href"],_hoisted_2$1={key:0};function _sfc_render(m,y,v,$e,je,Ge){return vue.openBlock(),vue.createElementBlock("svg",{class:vue.normalizeClass(Ge.svgClass),"aria-hidden":"true"},[vue.createElementVNode("use",{"xlink:href":Ge.iconName},null,8,_hoisted_1$1),v.title?(vue.openBlock(),vue.createElementBlock("title",_hoisted_2$1,vue.toDisplayString(v.title),1)):vue.createCommentVNode("",!0)],2)}const index$2=_export_sfc(_sfc_main$1,[["render",_sfc_render],["__scopeId","data-v-f0bfb888"]]),index$3=Object.freeze(Object.defineProperty({__proto__:null,default:index$2},Symbol.toStringTag,{value:"Module"})),_hoisted_1={class:"tooth-wrapper"},_hoisted_2=["id","fill"],_hoisted_3=["id","fill"],_hoisted_4=["id","fill"],_hoisted_5=["id","fill"],_hoisted_6=["id","fill"],_hoisted_7=["id","fill"],_hoisted_8=["id","fill"],_hoisted_9=["id","fill"],_hoisted_10=["id","fill"],_hoisted_11=["id","fill"],_hoisted_12=["id","fill"],_hoisted_13=["id","fill"],_hoisted_14=["id","fill"],_hoisted_15=["id","fill"],_hoisted_16=["id","fill"],_hoisted_17=["id","fill"],_hoisted_18=["id","fill"],_hoisted_19=["id","fill"],_hoisted_20=["id","fill"],_hoisted_21=["id","fill"],_hoisted_22=["id","fill"],_hoisted_23=["id","fill"],_hoisted_24=["id","fill"],_hoisted_25=["id","fill"],_hoisted_26=["id","fill"],_hoisted_27=["id","fill"],_hoisted_28=["id","fill"],_hoisted_29=["id","fill"],_hoisted_30=["id","fill"],_hoisted_31=["id","fill"],_hoisted_32=["id","fill"],_hoisted_33=["id","fill"],_hoisted_34=["id","fill"],_hoisted_35=["id","fill"],_hoisted_36=["id","fill"],_hoisted_37=["id","fill"],_hoisted_38=["id","fill"],_hoisted_39=["id","fill"],_hoisted_40=["id","fill"],_hoisted_41=["id","fill"],_hoisted_42=["id","fill"],_hoisted_43=["id","fill"],_hoisted_44=["id","fill"],_hoisted_45=["id","fill"],_hoisted_46=["id","fill"],_hoisted_47=["id","fill"],_hoisted_48=["id","fill"],_hoisted_49=["id","fill"],_hoisted_50=["id","fill"],_hoisted_51=["id","fill"],_hoisted_52=["id","fill"],_hoisted_53=["id","fill"],_hoisted_54=["id"],_hoisted_55=["offset","stop-color"],_hoisted_56={style:{"text-align":"right",margin:"0","margin-top":"5px",display:"flex"}},_sfc_main={__name:"index",props:vue.mergeModels({symptomItems:{type:Array,default:()=>[]}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(m){const y=vue.useModel(m,"modelValue"),v=vue.ref({}),$e=vue.ref(null);vue.ref(!1);const je=m,Ge={1:[11,12,13,14,15,16,17,18],2:[21,22,23,24,25,26,27,28],3:[31,32,33,34,35,36,37,38],4:[41,42,43,44,45,46,47,48],5:[51,52,53,54,55],6:[61,62,63,64,65],7:[71,72,73,74,75],8:[81,82,83,84,85]},Ye=vue.ref([]),qe=vue.ref(!1),Ke=vue.ref(0),Qe=un=>{un&&Ye.value.push(un)},Je=vue.computed(()=>Ye.value[Ke.value]),st=vue.ref([]),Mt=un=>{un.target.focus(),console.log("focus:"+un.target.id),Ke.value=Array.from($e.value.children).indexOf(un.target);const hn=Je.value.attributes.id.value;v.value.hasOwnProperty(hn)?st.value=JSON.parse(JSON.stringify(v.value[hn])):st.value=[],qe.value=!0},nn=un=>{un.target.classList.contains("tooth")&&console.log("blur:"+un.target.id)},rn=un=>{const hn={};return un&&un.split(".").forEach(fn=>{const[to,Mi]=fn.split("|");hn[to]=Mi?Mi.split(","):[]}),hn},on=()=>{const un=Object.keys(v.value).reduce((hn,fn)=>(hn.push(fn+"|"+v.value[fn].join(",")),hn),[]).join(".");y.value=un,console.log(un)},an=un=>v.value.hasOwnProperty(un)?v.value[un].length==0?["green"]:v.value[un].map(fn=>je.symptomItems.filter(Mi=>Mi.value==fn)[0].color||"green"):["white"],sn=un=>v.value.hasOwnProperty(un)?"url(#pos-"+un+")":"white",ln=()=>{const un=Je.value.attributes.id.value;v.value[un]=st.value,qe.value=!1},cn=()=>{delete v.value[Je.value.attributes.id.value],qe.value=!1};return vue.onMounted(()=>{v.value=rn(y.value)}),vue.watch(()=>y.value,un=>{v.value=rn(y.value)}),vue.watch(()=>v.value,un=>{on()},{deep:!0}),(un,hn)=>{const fn=vue.resolveComponent("el-checkbox"),to=vue.resolveComponent("el-checkbox-group"),Mi=vue.resolveComponent("el-button"),Uo=vue.resolveComponent("el-popover");return vue.openBlock(),vue.createElementBlock("div",_hoisted_1,[(vue.openBlock(),vue.createElementBlock("svg",{ref_key:"svgContainer",ref:$e,width:"100%",height:"220",viewBox:"0 0 702 301",fill:"none",xmlns:"http://www.w3.org/2000/svg",onFocusout:nn},[vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][0])}]),id:Ge[4][0],fill:sn(Ge[4][0]),d:"M328.584 212.314C333.583 210.518 342.343 201.534 337.392 179.975L319.537 179.975C316.998 188.509 315.252 206.924 328.584 212.314Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_2),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][1])}]),id:Ge[4][1],fill:sn(Ge[4][1]),d:"M298.011 213.017C303.177 211.181 312.229 202.003 307.113 179.975L288.663 179.975C286.039 188.694 284.235 207.51 298.011 213.017Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_3),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][2])}]),id:Ge[4][2],fill:sn(Ge[4][2]),d:"M264.101 220.047C271.163 216.79 283.462 205.517 276.161 186.491C272.771 182.06 269.533 180.301 268.338 179.975L258.234 179.975C253.888 182.147 246.37 190.4 251.063 206.038C252.584 210.382 257.321 219.266 264.101 220.047Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_4),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][3])}]),id:Ge[4][3],fill:sn(Ge[4][3]),d:"M227.041 213.017C232.874 211.181 243.094 202.003 237.317 179.975L216.487 179.975C213.525 188.694 211.488 207.51 227.041 213.017Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_5),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][4])}]),id:Ge[4][4],fill:sn(Ge[4][4]),d:"M190.294 212.745C198.375 208.785 209.066 196.576 198.872 179.703L181.648 179.703C175.318 186.633 172.157 205.364 190.294 212.745Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_6),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][5])}]),id:Ge[4][5],fill:sn(Ge[4][5]),d:"M160.385 179H127.669C123.255 186.823 123.728 194.832 124.516 197.859C126.881 212.177 154.866 210.78 161.961 205.542C170.633 193.668 163.801 181.91 160.385 179Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_7),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][6])}]),id:Ge[4][6],fill:sn(Ge[4][6]),d:"M111.187 179.272H82.0111C78.0742 187.146 78.496 195.207 79.199 198.254C81.3081 212.666 106.266 211.26 112.593 205.987C120.326 194.035 114.233 182.201 111.187 179.272Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_8),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][7])}]),id:Ge[4][7],fill:sn(Ge[4][7]),d:"M63.624 179.272H34.4483C30.5114 187.146 30.9332 195.207 31.6362 198.254C33.7453 212.666 58.7028 211.26 65.03 205.987C72.7633 194.035 66.6704 182.201 63.624 179.272Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_9),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][7])}]),id:Ge[3][7],fill:sn(Ge[3][7]),d:"M659.815 179H630.639C626.702 186.874 627.124 194.935 627.827 197.982C629.936 212.394 654.894 210.988 661.221 205.715C668.954 193.764 662.861 181.929 659.815 179Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_10),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][6])}]),id:Ge[3][6],fill:sn(Ge[3][6]),d:"M612.712 179H583.537C579.6 186.874 580.021 194.935 580.724 197.982C582.833 212.394 607.791 210.988 614.118 205.715C621.851 193.764 615.759 181.929 612.712 179Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_11),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][5])}]),id:Ge[3][5],fill:sn(Ge[3][5]),d:"M563.219 179H530.503C526.089 186.823 526.562 194.832 527.35 197.859C529.715 212.177 557.701 210.78 564.796 205.542C573.467 193.668 566.635 181.91 563.219 179Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_12),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][4])}]),id:Ge[3][4],fill:sn(Ge[3][4]),d:"M504.597 212.042C512.678 208.082 523.369 195.873 513.175 179L495.951 179C489.621 185.93 486.46 204.66 504.597 212.042Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_13),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][3])}]),id:Ge[3][3],fill:sn(Ge[3][3]),d:"M467.744 212.745C473.576 210.91 483.797 201.731 478.02 179.703L457.19 179.703C454.227 188.423 452.19 207.238 467.744 212.745Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_14),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][2])}]),id:Ge[3][2],fill:sn(Ge[3][2]),d:"M433.095 219.776C440.157 216.518 452.455 205.245 445.154 186.219C441.765 181.788 438.527 180.029 437.332 179.703L427.228 179.703C422.882 181.875 415.363 190.128 420.057 205.766C421.578 210.11 426.315 218.994 433.095 219.776Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_15),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][1])}]),id:Ge[3][1],fill:sn(Ge[3][1]),d:"M398.108 212.745C403.274 210.91 412.326 201.731 407.21 179.703L388.76 179.703C386.136 188.423 384.332 207.238 398.108 212.745Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_16),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][0])}]),id:Ge[3][0],fill:sn(Ge[3][0]),d:"M367.517 212.042C372.516 210.246 381.277 201.263 376.325 179.703L358.471 179.703C355.932 188.237 354.186 206.652 367.517 212.042Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_17),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][7])}]),id:Ge[2][7],fill:sn(Ge[2][7]),d:"M636.739 125.842C629.99 116.562 635.099 106.743 638.497 102.993H659.236C667.672 114.242 663.688 122.913 660.642 125.842C652.792 125.959 637.02 126.123 636.739 125.842Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_18),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][6])}]),id:Ge[2][6],fill:sn(Ge[2][6]),d:"M591.401 126.193C586.339 114.945 590.932 103.696 593.862 99.4783H616.007C625.568 107.915 623.037 120.803 620.577 126.193H591.401Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_19),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][5])}]),id:Ge[2][5],fill:sn(Ge[2][5]),d:"M539.613 126.193C529.211 114.382 536.45 101.587 541.37 96.6662H569.133C581.785 109.363 576.748 121.641 572.648 126.193H539.613Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_20),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][4])}]),id:Ge[2][4],fill:sn(Ge[2][4]),d:"M507.937 126.193C495.564 112.414 506.765 100.767 513.913 96.6662C529.942 109.321 524.341 121.624 519.537 126.193H507.937Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_21),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][3])}]),id:Ge[2][3],fill:sn(Ge[2][3]),d:"M471.38 116.702C467.443 101.517 476.769 94.6743 481.925 93.1511C488.393 95.1196 491.181 101.236 491.767 104.048C495.142 114.453 490.361 123.381 487.549 126.545H480.167C473.7 123.452 471.614 118.694 471.38 116.702Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_22),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][2])}]),id:Ge[2][2],fill:sn(Ge[2][2]),d:"M444.313 82.2542C436.697 85.7693 423.433 97.9317 431.307 118.46C434.963 123.241 438.454 125.139 439.743 125.49H450.64C455.327 123.147 463.435 114.242 458.374 97.3692C456.733 92.6824 451.625 83.0978 444.313 82.2542Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_23),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][1])}]),id:Ge[2][1],fill:sn(Ge[2][1]),d:"M407.404 90.6905C402.717 92.9167 394.609 102.993 399.671 125.49H417.598C420.059 116.351 421.465 96.5959 407.404 90.6905Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_24),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][0])}]),id:Ge[2][0],fill:sn(Ge[2][0]),d:"M372.253 83.6602C364.871 86.0036 351.935 97.7207 359.247 125.842H385.61C389.36 114.711 391.937 90.6905 372.253 83.6602Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_25),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][0])}]),id:Ge[1][0],fill:sn(Ge[1][0]),d:"M320.58 82.9572C312.613 85.5349 299.068 97.7911 308.629 126.193H332.883C336.516 114.828 339.14 90.2687 320.58 82.9572Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_26),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][1])}]),id:Ge[1][1],fill:sn(Ge[1][1]),d:"M278.047 126.193C270.173 106.227 279.688 94.2056 285.429 90.6905C300.895 100.533 297.498 118.46 293.865 126.193H278.047Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_27),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][2])}]),id:Ge[1][2],fill:sn(Ge[1][2]),d:"M235.163 117.406C228.695 97.4395 242.779 86.3552 250.629 83.3087C261.034 86.402 264.807 92.5652 265.393 95.2602V118.109C265.393 122.608 260.706 125.373 258.362 126.193H246.762C241.841 124.787 237.623 122.327 235.163 117.406Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_28),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][3])}]),id:Ge[1][3],fill:sn(Ge[1][3]),d:"M207.393 126.545C194.176 110.516 204.932 99.0096 211.963 95.2602C229.96 104.54 223.445 119.983 217.938 126.545H207.393Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_29),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][4])}]),id:Ge[1][4],fill:sn(Ge[1][4]),d:"M179.626 96.47C173.321 99.4891 163.444 109.73 174.372 126.54C174.372 126.83 182.778 126.661 186.981 126.54C191.652 118.69 196.088 102.629 179.626 96.47Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_30),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][5])}]),id:Ge[1][5],fill:sn(Ge[1][5]),d:"M121.276 126.193C110.874 114.382 118.113 101.587 123.033 96.6662H150.796C163.448 109.363 158.41 121.641 154.31 126.193H121.276Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_31),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][6])}]),id:Ge[1][6],fill:sn(Ge[1][6]),d:"M74.1694 126.193C69.1076 114.945 73.7007 103.696 76.6299 99.4783H98.7753C108.336 107.915 105.806 120.803 103.345 126.193H74.1694Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_32),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][7])}]),id:Ge[1][7],fill:sn(Ge[1][7]),d:"M34.4483 125.842C27.6993 116.562 32.8079 106.743 36.2059 102.993H56.9452C65.3815 114.242 61.3977 122.913 58.3512 125.842C50.5008 125.959 34.7295 126.123 34.4483 125.842Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_33),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[8][0])}]),id:Ge[8][0],fill:sn(Ge[8][0]),d:"M328.148 277.424C333.147 275.627 341.907 266.644 336.956 245.085L319.102 245.085C316.562 253.619 314.817 272.034 328.148 277.424Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_34),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[8][1])}]),id:Ge[8][1],fill:sn(Ge[8][1]),d:"M297.575 278.127C302.741 276.291 311.793 267.113 306.677 245.085L288.227 245.085C285.603 253.804 283.799 272.62 297.575 278.127Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_35),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[8][2])}]),id:Ge[8][2],fill:sn(Ge[8][2]),d:"M263.665 285.157C270.727 281.899 283.026 270.627 275.725 251.6C272.335 247.17 269.097 245.41 267.902 245.085L257.798 245.085C253.452 247.256 245.934 255.51 250.627 271.148C252.149 275.492 256.886 284.375 263.665 285.157Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_36),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[8][3])}]),id:Ge[8][3],fill:sn(Ge[8][3]),d:"M226.605 278.127C232.438 276.291 242.658 267.113 236.881 245.085L216.051 245.085C213.089 253.804 211.052 272.62 226.605 278.127Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_37),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[8][4])}]),id:Ge[8][4],fill:sn(Ge[8][4]),d:"M190.294 278.127C198.375 274.167 209.066 261.957 198.872 245.085L181.648 245.085C175.318 252.015 172.157 270.745 190.294 278.127Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_38),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[7][4])}]),id:Ge[7][4],fill:sn(Ge[7][4]),d:"M504.597 277.424C512.678 273.464 523.369 261.254 513.175 244.382L495.951 244.382C489.621 251.312 486.46 270.042 504.597 277.424Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_39),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[7][3])}]),id:Ge[7][3],fill:sn(Ge[7][3]),d:"M467.744 278.127C473.576 276.291 483.797 267.113 478.02 245.085L457.19 245.085C454.227 253.804 452.19 272.62 467.744 278.127Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_40),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[7][2])}]),id:Ge[7][2],fill:sn(Ge[7][2]),d:"M433.095 285.157C440.157 281.899 452.455 270.627 445.154 251.6C441.765 247.17 438.527 245.41 437.332 245.085L427.228 245.085C422.882 247.256 415.363 255.51 420.057 271.148C421.578 275.492 426.315 284.375 433.095 285.157Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_41),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[7][1])}]),id:Ge[7][1],fill:sn(Ge[7][1]),d:"M398.108 278.127C403.274 276.291 412.326 267.113 407.21 245.085L388.76 245.085C386.136 253.804 384.332 272.62 398.108 278.127Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_42),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[7][0])}]),id:Ge[7][0],fill:sn(Ge[7][0]),d:"M367.517 277.424C372.516 275.627 381.277 266.644 376.325 245.085L358.471 245.085C355.932 253.619 354.186 272.034 367.517 277.424Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_43),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[6][4])}]),id:Ge[6][4],fill:sn(Ge[6][4]),d:"M507.937 57.9997C495.564 44.2204 506.765 32.5736 513.913 28.4726C529.942 41.1271 524.341 53.4301 519.537 57.9997H507.937Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_44),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[6][3])}]),id:Ge[6][3],fill:sn(Ge[6][3]),d:"M471.38 48.5089C467.443 33.3235 476.769 26.4807 481.925 24.9575C488.393 26.9259 491.181 33.0423 491.767 35.8544C495.142 46.2592 490.361 55.1876 487.549 58.3512H480.167C473.7 55.2579 471.614 50.5008 471.38 48.5089Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_45),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[6][2])}]),id:Ge[6][2],fill:sn(Ge[6][2]),d:"M444.313 14.0605C436.697 17.5757 423.433 29.738 431.307 50.2664C434.963 55.047 438.454 56.9452 439.743 57.2967H450.64C455.327 54.9533 463.435 46.0483 458.374 29.1756C456.733 24.4888 451.625 14.9042 444.313 14.0605Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_46),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[6][1])}]),id:Ge[6][1],fill:sn(Ge[6][1]),d:"M407.404 22.4969C402.717 24.7231 394.609 34.7998 399.671 57.2967H417.598C420.059 48.1573 421.465 28.4023 407.404 22.4969Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_47),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[6][0])}]),id:Ge[6][0],fill:sn(Ge[6][0]),d:"M372.253 15.4666C364.871 17.81 351.935 29.5271 359.247 57.6482H385.61C389.36 46.517 391.937 22.4969 372.253 15.4666Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_48),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[5][0])}]),id:Ge[5][0],fill:sn(Ge[5][0]),d:"M320.58 14.7636C312.613 17.3413 299.068 29.5974 308.629 57.9997H332.883C336.516 46.6341 339.14 22.075 320.58 14.7636Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_49),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[5][1])}]),id:Ge[5][1],fill:sn(Ge[5][1]),d:"M278.047 57.9997C270.173 38.0338 279.688 26.012 285.429 22.4969C300.895 32.3392 297.498 50.2664 293.865 57.9997H278.047Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_50),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[5][2])}]),id:Ge[5][2],fill:sn(Ge[5][2]),d:"M235.163 49.2119C228.695 29.2459 242.779 18.1615 250.629 15.1151C261.034 18.2084 264.807 24.3716 265.393 27.0665V49.9149C265.393 54.4143 260.706 57.1795 258.362 57.9997H246.762C241.841 56.5937 237.623 54.1331 235.163 49.2119Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_51),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[5][3])}]),id:Ge[5][3],fill:sn(Ge[5][3]),d:"M207.393 58.3512C194.176 42.3222 204.932 30.816 211.963 27.0665C229.96 36.3465 223.445 51.7897 217.938 58.3512H207.393Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_52),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[5][4])}]),id:Ge[5][4],fill:sn(Ge[5][4]),d:"M179.626 28.2764C173.321 31.2955 163.444 41.5362 174.372 58.3465C174.372 58.6363 182.778 58.4673 186.981 58.3465C191.652 50.4969 196.088 34.4353 179.626 28.2764Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_53),hn[2]||(hn[2]=vue.createElementVNode("path",{class:"tooth",fill:"white",d:"M29.8787 152.908H665.063",stroke:"#CCE6FB","stroke-width":"2"},null,-1)),hn[3]||(hn[3]=vue.createElementVNode("path",{class:"tooth",fill:"white",d:"M347.295 78.739V225.672",stroke:"#CCE6FB","stroke-width":"2"},null,-1)),vue.createElementVNode("defs",null,[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(Object.keys(v.value),fo=>(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,[v.value[fo]?(vue.openBlock(),vue.createElementBlock("linearGradient",{key:0,id:"pos-"+fo,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(an(fo),(dd,mo)=>(vue.openBlock(),vue.createElementBlock("stop",{key:mo,offset:`${mo/(an(fo).length-1||1)*100}%`,"stop-color":dd},null,8,_hoisted_55))),128))],8,_hoisted_54)):vue.createCommentVNode("",!0)],64))),256))])],544)),vue.createVNode(Uo,{visible:qe.value,"virtual-ref":Je.value,"virtual-triggering":"",trigger:"click",title:"选择牙齿状况",width:"200"},{default:vue.withCtx(()=>[vue.createElementVNode("div",null,[vue.createVNode(to,{modelValue:st.value,"onUpdate:modelValue":hn[0]||(hn[0]=fo=>st.value=fo)},{default:vue.withCtx(()=>[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(m.symptomItems,fo=>(vue.openBlock(),vue.createBlock(fn,{label:fo.label,value:fo.value},null,8,["label","value"]))),256))]),_:1},8,["modelValue"])]),vue.createElementVNode("div",_hoisted_56,[vue.createVNode(Mi,{size:"small",text:"",onClick:cn},{default:vue.withCtx(()=>hn[4]||(hn[4]=[vue.createTextVNode("清除")])),_:1}),vue.createVNode(Mi,{size:"small",text:"",onClick:hn[1]||(hn[1]=fo=>qe.value=!1)},{default:vue.withCtx(()=>hn[5]||(hn[5]=[vue.createTextVNode("取消")])),_:1}),vue.createVNode(Mi,{size:"small",type:"primary",onClick:ln},{default:vue.withCtx(()=>hn[6]||(hn[6]=[vue.createTextVNode(" 确定 ")])),_:1})])]),_:1},8,["visible","virtual-ref"])])}}},index=_export_sfc(_sfc_main,[["__scopeId","data-v-76426ce9"]]),index$1=Object.freeze(Object.defineProperty({__proto__:null,default:index},Symbol.toStringTag,{value:"Module"}));return index$b});
|
|
4970
|
+
***************************************************************************** */var extendStatics=function(m,y){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,$e){v.__proto__=$e}||function(v,$e){for(var je in $e)$e.hasOwnProperty(je)&&(v[je]=$e[je])},extendStatics(m,y)};function __extends(m,y){extendStatics(m,y);function v(){this.constructor=m}m.prototype=y===null?Object.create(y):(v.prototype=y.prototype,new v)}var __assign=function(){return __assign=Object.assign||function(y){for(var v,$e=1,je=arguments.length;$e<je;$e++){v=arguments[$e];for(var Ge in v)Object.prototype.hasOwnProperty.call(v,Ge)&&(y[Ge]=v[Ge])}return y},__assign.apply(this,arguments)};function __awaiter(m,y,v,$e){function je(Ge){return Ge instanceof v?Ge:new v(function(Ye){Ye(Ge)})}return new(v||(v=Promise))(function(Ge,Ye){function qe(Je){try{Qe($e.next(Je))}catch(st){Ye(st)}}function Ke(Je){try{Qe($e.throw(Je))}catch(st){Ye(st)}}function Qe(Je){Je.done?Ge(Je.value):je(Je.value).then(qe,Ke)}Qe(($e=$e.apply(m,[])).next())})}function __generator(m,y){var v={label:0,sent:function(){if(Ge[0]&1)throw Ge[1];return Ge[1]},trys:[],ops:[]},$e,je,Ge,Ye;return Ye={next:qe(0),throw:qe(1),return:qe(2)},typeof Symbol=="function"&&(Ye[Symbol.iterator]=function(){return this}),Ye;function qe(Qe){return function(Je){return Ke([Qe,Je])}}function Ke(Qe){if($e)throw new TypeError("Generator is already executing.");for(;v;)try{if($e=1,je&&(Ge=Qe[0]&2?je.return:Qe[0]?je.throw||((Ge=je.return)&&Ge.call(je),0):je.next)&&!(Ge=Ge.call(je,Qe[1])).done)return Ge;switch(je=0,Ge&&(Qe=[Qe[0]&2,Ge.value]),Qe[0]){case 0:case 1:Ge=Qe;break;case 4:return v.label++,{value:Qe[1],done:!1};case 5:v.label++,je=Qe[1],Qe=[0];continue;case 7:Qe=v.ops.pop(),v.trys.pop();continue;default:if(Ge=v.trys,!(Ge=Ge.length>0&&Ge[Ge.length-1])&&(Qe[0]===6||Qe[0]===2)){v=0;continue}if(Qe[0]===3&&(!Ge||Qe[1]>Ge[0]&&Qe[1]<Ge[3])){v.label=Qe[1];break}if(Qe[0]===6&&v.label<Ge[1]){v.label=Ge[1],Ge=Qe;break}if(Ge&&v.label<Ge[2]){v.label=Ge[2],v.ops.push(Qe);break}Ge[2]&&v.ops.pop(),v.trys.pop();continue}Qe=y.call(m,v)}catch(Je){Qe=[6,Je],je=0}finally{$e=Ge=0}if(Qe[0]&5)throw Qe[1];return{value:Qe[0]?Qe[1]:void 0,done:!0}}}function __spreadArrays(){for(var m=0,y=0,v=arguments.length;y<v;y++)m+=arguments[y].length;for(var $e=Array(m),je=0,y=0;y<v;y++)for(var Ge=arguments[y],Ye=0,qe=Ge.length;Ye<qe;Ye++,je++)$e[je]=Ge[Ye];return $e}var Dimensions=function(){function m(y,v){if(!isValidNumber(y)||!isValidNumber(v))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:y,height:v}));this._width=y,this._height=v}return Object.defineProperty(m.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),m.prototype.reverse=function(){return new m(1/this.width,1/this.height)},m}();function isTensor(m,y){return m instanceof wt&&m.shape.length===y}function isTensor2D(m){return isTensor(m,2)}function isTensor3D(m){return isTensor(m,3)}function isTensor4D(m){return isTensor(m,4)}function isFloat(m){return m%1!==0}function isEven(m){return m%2===0}function round(m,y){y===void 0&&(y=2);var v=Math.pow(10,y);return Math.floor(m*v)/v}function isDimensions(m){return m&&m.width&&m.height}function computeReshapedDimensions(m,y){var v=m.width,$e=m.height,je=y/Math.max($e,v);return new Dimensions(Math.round(v*je),Math.round($e*je))}function getCenterPoint(m){return m.reduce(function(y,v){return y.add(v)},new Point(0,0)).div(new Point(m.length,m.length))}function range(m,y,v){return Array(m).fill(0).map(function($e,je){return y+je*v})}function isValidNumber(m){return!!m&&m!==1/0&&m!==-1/0&&!isNaN(m)||m===0}function isValidProbablitiy(m){return isValidNumber(m)&&0<=m&&m<=1}var Point=function(){function m(y,v){this._x=y,this._y=v}return Object.defineProperty(m.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),m.prototype.add=function(y){return new m(this.x+y.x,this.y+y.y)},m.prototype.sub=function(y){return new m(this.x-y.x,this.y-y.y)},m.prototype.mul=function(y){return new m(this.x*y.x,this.y*y.y)},m.prototype.div=function(y){return new m(this.x/y.x,this.y/y.y)},m.prototype.abs=function(){return new m(Math.abs(this.x),Math.abs(this.y))},m.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},m.prototype.floor=function(){return new m(Math.floor(this.x),Math.floor(this.y))},m}(),Box=function(){function m(y,v){v===void 0&&(v=!0);var $e=y||{},je=[$e.left,$e.top,$e.right,$e.bottom].every(isValidNumber),Ge=[$e.x,$e.y,$e.width,$e.height].every(isValidNumber);if(!Ge&&!je)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify($e));var Ye=Ge?[$e.x,$e.y,$e.width,$e.height]:[$e.left,$e.top,$e.right-$e.left,$e.bottom-$e.top],qe=Ye[0],Ke=Ye[1],Qe=Ye[2],Je=Ye[3];m.assertIsValidBox({x:qe,y:Ke,width:Qe,height:Je},"Box.constructor",v),this._x=qe,this._y=Ke,this._width=Qe,this._height=Je}return m.isRect=function(y){return!!y&&[y.x,y.y,y.width,y.height].every(isValidNumber)},m.assertIsValidBox=function(y,v,$e){if($e===void 0&&($e=!1),!m.isRect(y))throw new Error(v+" - invalid box: "+JSON.stringify(y)+", expected object with properties x, y, width, height");if(!$e&&(y.width<0||y.height<0))throw new Error(v+" - width ("+y.width+") and height ("+y.height+") must be positive numbers")},Object.defineProperty(m.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"topLeft",{get:function(){return new Point(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"topRight",{get:function(){return new Point(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"bottomLeft",{get:function(){return new Point(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"bottomRight",{get:function(){return new Point(this.right,this.bottom)},enumerable:!0,configurable:!0}),m.prototype.round=function(){var y=[this.x,this.y,this.width,this.height].map(function(Ye){return Math.round(Ye)}),v=y[0],$e=y[1],je=y[2],Ge=y[3];return new m({x:v,y:$e,width:je,height:Ge})},m.prototype.floor=function(){var y=[this.x,this.y,this.width,this.height].map(function(Ye){return Math.floor(Ye)}),v=y[0],$e=y[1],je=y[2],Ge=y[3];return new m({x:v,y:$e,width:je,height:Ge})},m.prototype.toSquare=function(){var y=this,v=y.x,$e=y.y,je=y.width,Ge=y.height,Ye=Math.abs(je-Ge);return je<Ge&&(v-=Ye/2,je+=Ye),Ge<je&&($e-=Ye/2,Ge+=Ye),new m({x:v,y:$e,width:je,height:Ge})},m.prototype.rescale=function(y){var v=isDimensions(y)?y.width:y,$e=isDimensions(y)?y.height:y;return new m({x:this.x*v,y:this.y*$e,width:this.width*v,height:this.height*$e})},m.prototype.pad=function(y,v){var $e=[this.x-y/2,this.y-v/2,this.width+y,this.height+v],je=$e[0],Ge=$e[1],Ye=$e[2],qe=$e[3];return new m({x:je,y:Ge,width:Ye,height:qe})},m.prototype.clipAtImageBorders=function(y,v){var $e=this,je=$e.x,Ge=$e.y,Ye=$e.right,qe=$e.bottom,Ke=Math.max(je,0),Qe=Math.max(Ge,0),Je=Ye-Ke,st=qe-Qe,Mt=Math.min(Je,y-Ke),nn=Math.min(st,v-Qe);return new m({x:Ke,y:Qe,width:Mt,height:nn}).floor()},m.prototype.shift=function(y,v){var $e=this,je=$e.width,Ge=$e.height,Ye=this.x+y,qe=this.y+v;return new m({x:Ye,y:qe,width:je,height:Ge})},m.prototype.padAtBorders=function(y,v){var $e=this.width+1,je=this.height+1,Ge=1,Ye=1,qe=$e,Ke=je,Qe=this.left,Je=this.top,st=this.right,Mt=this.bottom;return st>v&&(qe=-st+v+$e,st=v),Mt>y&&(Ke=-Mt+y+je,Mt=y),Qe<1&&(Ke=2-Qe,Qe=1),Je<1&&(Ke=2-Je,Je=1),{dy:Ye,edy:Ke,dx:Ge,edx:qe,y:Je,ey:Mt,x:Qe,ex:st,w:$e,h:je}},m.prototype.calibrate=function(y){return new m({left:this.left+y.left*this.width,top:this.top+y.top*this.height,right:this.right+y.right*this.width,bottom:this.bottom+y.bottom*this.height}).toSquare().round()},m}(),BoundingBox=function(m){__extends(y,m);function y(v,$e,je,Ge,Ye){return Ye===void 0&&(Ye=!1),m.call(this,{left:v,top:$e,right:je,bottom:Ge},Ye)||this}return y}(Box),ObjectDetection=function(){function m(y,v,$e,je,Ge){this._imageDims=new Dimensions(Ge.width,Ge.height),this._score=y,this._classScore=v,this._className=$e,this._box=new Box(je).rescale(this._imageDims)}return Object.defineProperty(m.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"relativeBox",{get:function(){return new Box(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),m.prototype.forSize=function(y,v){return new m(this.score,this.classScore,this.className,this.relativeBox,{width:y,height:v})},m}(),FaceDetection=function(m){__extends(y,m);function y(v,$e,je){return m.call(this,v,v,"",$e,je)||this}return y.prototype.forSize=function(v,$e){var je=m.prototype.forSize.call(this,v,$e),Ge=je.score,Ye=je.relativeBox,qe=je.imageDims;return new y(Ge,Ye,qe)},y}(ObjectDetection);function iou(m,y,v){v===void 0&&(v=!0);var $e=Math.max(0,Math.min(m.right,y.right)-Math.max(m.left,y.left)),je=Math.max(0,Math.min(m.bottom,y.bottom)-Math.max(m.top,y.top)),Ge=$e*je;return v?Ge/(m.area+y.area-Ge):Ge/Math.min(m.area,y.area)}function minBbox(m){var y=m.map(function(qe){return qe.x}),v=m.map(function(qe){return qe.y}),$e=y.reduce(function(qe,Ke){return Ke<qe?Ke:qe},1/0),je=v.reduce(function(qe,Ke){return Ke<qe?Ke:qe},1/0),Ge=y.reduce(function(qe,Ke){return qe<Ke?Ke:qe},0),Ye=v.reduce(function(qe,Ke){return qe<Ke?Ke:qe},0);return new BoundingBox($e,je,Ge,Ye)}function nonMaxSuppression$1(m,y,v,$e){$e===void 0&&($e=!0);for(var je=y.map(function(qe,Ke){return{score:qe,boxIndex:Ke}}).sort(function(qe,Ke){return qe.score-Ke.score}).map(function(qe){return qe.boxIndex}),Ge=[],Ye=function(){var qe=je.pop();Ge.push(qe);for(var Ke=je,Qe=[],Je=0;Je<Ke.length;Je++){var st=Ke[Je],Mt=m[qe],nn=m[st];Qe.push(iou(Mt,nn,$e))}je=je.filter(function(rn,on){return Qe[on]<=v})};je.length>0;)Ye();return Ge}function normalize$1(m,y){return Ze(function(){var v=y[0],$e=y[1],je=y[2],Ge=Hn(__spreadArrays(m.shape.slice(0,3),[1]),v),Ye=Hn(__spreadArrays(m.shape.slice(0,3),[1]),$e),qe=Hn(__spreadArrays(m.shape.slice(0,3),[1]),je),Ke=Yn([Ge,Ye,qe],3);return Cc(m,Ke)})}function padToSquare(m,y){return y===void 0&&(y=!1),Ze(function(){var v=m.shape.slice(1),$e=v[0],je=v[1];if($e===je)return m;var Ge=Math.abs($e-je),Ye=Math.round(Ge*(y?.5:1)),qe=$e>je?2:1,Ke=function(nn){var rn=m.shape.slice();return rn[qe]=nn,Hn(rn,0)},Qe=Ke(Ye),Je=Ge-Qe.shape[qe],st=y&&Je?Ke(Je):null,Mt=[st,m,Qe].filter(function(nn){return!!nn}).map(function(nn){return nn.toFloat()});return Yn(Mt,qe)})}function sigmoid(m){return 1/(1+Math.exp(-m))}var Rect=function(m){__extends(y,m);function y(v,$e,je,Ge,Ye){return Ye===void 0&&(Ye=!1),m.call(this,{x:v,y:$e,width:je,height:Ge},Ye)||this}return y}(Box),relX=.5,relY=.43,relScale=.45,FaceLandmarks=function(){function m(y,v,$e){$e===void 0&&($e=new Point(0,0));var je=v.width,Ge=v.height;this._imgDims=new Dimensions(je,Ge),this._shift=$e,this._positions=y.map(function(Ye){return Ye.mul(new Point(je,Ge)).add($e)})}return Object.defineProperty(m.prototype,"shift",{get:function(){return new Point(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"relativePositions",{get:function(){var y=this;return this._positions.map(function(v){return v.sub(y._shift).div(new Point(y.imageWidth,y.imageHeight))})},enumerable:!0,configurable:!0}),m.prototype.forSize=function(y,v){return new this.constructor(this.relativePositions,{width:y,height:v})},m.prototype.shiftBy=function(y,v){return new this.constructor(this.relativePositions,this._imgDims,new Point(y,v))},m.prototype.shiftByPoint=function(y){return this.shiftBy(y.x,y.y)},m.prototype.align=function(y,v){if(v===void 0&&(v={}),y){var $e=y instanceof FaceDetection?y.box.floor():new Box(y);return this.shiftBy($e.x,$e.y).align(null,v)}var je=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},v),Ge=je.useDlibAlignment,Ye=je.minBoxPadding;return Ge?this.alignDlib():this.alignMinBbox(Ye)},m.prototype.alignDlib=function(){var y=this.getRefPointsForAlignment(),v=y[0],$e=y[1],je=y[2],Ge=function(st){return je.sub(st).magnitude()},Ye=(Ge(v)+Ge($e))/2,qe=Math.floor(Ye/relScale),Ke=getCenterPoint(y),Qe=Math.floor(Math.max(0,Ke.x-relX*qe)),Je=Math.floor(Math.max(0,Ke.y-relY*qe));return new Rect(Qe,Je,Math.min(qe,this.imageWidth+Qe),Math.min(qe,this.imageHeight+Je))},m.prototype.alignMinBbox=function(y){var v=minBbox(this.positions);return v.pad(v.width*y,v.height*y)},m.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},m}(),FaceLandmarks5=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.getRefPointsForAlignment=function(){var v=this.positions;return[v[0],v[1],getCenterPoint([v[3],v[4]])]},y}(FaceLandmarks),FaceLandmarks68=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.getJawOutline=function(){return this.positions.slice(0,17)},y.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},y.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},y.prototype.getNose=function(){return this.positions.slice(27,36)},y.prototype.getLeftEye=function(){return this.positions.slice(36,42)},y.prototype.getRightEye=function(){return this.positions.slice(42,48)},y.prototype.getMouth=function(){return this.positions.slice(48,68)},y.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(getCenterPoint)},y}(FaceLandmarks),FaceMatch=function(){function m(y,v){this._label=y,this._distance=v}return Object.defineProperty(m.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),m.prototype.toString=function(y){return y===void 0&&(y=!0),""+this.label+(y?" ("+round(this.distance)+")":"")},m}(),LabeledBox=function(m){__extends(y,m);function y(v,$e){var je=m.call(this,v)||this;return je._label=$e,je}return y.assertIsValidLabeledBox=function(v,$e){if(Box.assertIsValidBox(v,$e),!isValidNumber(v.label))throw new Error($e+" - expected property label ("+v.label+") to be a number")},Object.defineProperty(y.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),y}(Box),LabeledFaceDescriptors=function(){function m(y,v){if(typeof y!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(v)||v.some(function($e){return!($e instanceof Float32Array)}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=y,this._descriptors=v}return Object.defineProperty(m.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),m.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map(function(y){return Array.from(y)})}},m.fromJSON=function(y){var v=y.descriptors.map(function($e){return new Float32Array($e)});return new m(y.label,v)},m}();(function(m){__extends(y,m);function y(v,$e,je,Ge){var Ye=m.call(this,v,$e)||this;return Ye._score=je,Ye._classScore=Ge,Ye}return y.assertIsValidPredictedBox=function(v,$e){if(LabeledBox.assertIsValidLabeledBox(v,$e),!isValidProbablitiy(v.score)||!isValidProbablitiy(v.classScore))throw new Error($e+" - expected properties score ("+v.score+") and ("+v.classScore+") to be a number between [0, 1]")},Object.defineProperty(y.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),y})(LabeledBox);function isWithFaceDetection(m){return m.detection instanceof FaceDetection}function extendWithFaceDetection(m,y){var v={detection:y};return Object.assign({},m,v)}function createBrowserEnv(){var m=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")},y=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:m,readFile:y}}function createFileSystem(m){var y="";if(!m)try{m=require("fs")}catch($e){y=$e.toString()}var v=m?function($e){return new Promise(function(je,Ge){m.readFile($e,function(Ye,qe){return Ye?Ge(Ye):je(qe)})})}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+y)};return{readFile:v}}function createNodejsEnv(){var m=global.Canvas||global.HTMLCanvasElement,y=global.Image||global.HTMLImageElement,v=function(){if(m)return new m;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},$e=function(){if(y)return new y;throw new Error("createImageElement - missing Image implementation for nodejs environment")},je=global.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},Ge=createFileSystem();return __assign({Canvas:m||function(){function Ye(){}return Ye}(),CanvasRenderingContext2D:global.CanvasRenderingContext2D||function(){function Ye(){}return Ye}(),Image:y||function(){function Ye(){}return Ye}(),ImageData:global.ImageData||function(){function Ye(){}return Ye}(),Video:global.HTMLVideoElement||function(){function Ye(){}return Ye}(),createCanvasElement:v,createImageElement:$e,fetch:je},Ge)}function isBrowser(){return typeof window=="object"&&typeof document<"u"&&typeof HTMLImageElement<"u"&&typeof HTMLCanvasElement<"u"&&typeof HTMLVideoElement<"u"&&typeof ImageData<"u"&&typeof CanvasRenderingContext2D<"u"}function isNodejs(){return typeof global=="object"&&typeof require=="function"&&typeof module<"u"&&typeof process<"u"&&!!process.version}var environment;function getEnv(){if(!environment)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return environment}function setEnv(m){environment=m}function initialize(){isBrowser()&&setEnv(createBrowserEnv()),isNodejs()&&setEnv(createNodejsEnv())}function monkeyPatch(m){if(environment||initialize(),!environment)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var y=m.Canvas,v=y===void 0?environment.Canvas:y,$e=m.Image,je=$e===void 0?environment.Image:$e;environment.Canvas=v,environment.Image=je,environment.createCanvasElement=m.createCanvasElement||function(){return new v},environment.createImageElement=m.createImageElement||function(){return new je},environment.ImageData=m.ImageData||environment.ImageData,environment.Video=m.Video||environment.Video,environment.fetch=m.fetch||environment.fetch,environment.readFile=m.readFile||environment.readFile}var env={getEnv,setEnv,initialize,createBrowserEnv,createFileSystem,createNodejsEnv,monkeyPatch,isBrowser,isNodejs};initialize();function resolveInput(m){return!env.isNodejs()&&typeof m=="string"?document.getElementById(m):m}function getContext2dOrThrow(m){var y=env.getEnv(),v=y.Canvas,$e=y.CanvasRenderingContext2D;if(m instanceof $e)return m;var je=resolveInput(m);if(!(je instanceof v))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var Ge=je.getContext("2d");if(!Ge)throw new Error("resolveContext2d - canvas 2d context is null");return Ge}var AnchorPosition;(function(m){m.TOP_LEFT="TOP_LEFT",m.TOP_RIGHT="TOP_RIGHT",m.BOTTOM_LEFT="BOTTOM_LEFT",m.BOTTOM_RIGHT="BOTTOM_RIGHT"})(AnchorPosition||(AnchorPosition={}));function isMediaLoaded(m){var y=env.getEnv(),v=y.Image,$e=y.Video;return m instanceof v&&m.complete||m instanceof $e&&m.readyState>=3}function awaitMediaLoaded(m){return new Promise(function(y,v){if(m instanceof env.getEnv().Canvas||isMediaLoaded(m))return y();function $e(Ge){Ge.currentTarget&&(Ge.currentTarget.removeEventListener("load",$e),Ge.currentTarget.removeEventListener("error",je),y(Ge))}function je(Ge){Ge.currentTarget&&(Ge.currentTarget.removeEventListener("load",$e),Ge.currentTarget.removeEventListener("error",je),v(Ge))}m.addEventListener("load",$e),m.addEventListener("error",je)})}function getMediaDimensions(m){var y=env.getEnv(),v=y.Image,$e=y.Video;return m instanceof v?new Dimensions(m.naturalWidth,m.naturalHeight):m instanceof $e?new Dimensions(m.videoWidth,m.videoHeight):new Dimensions(m.width,m.height)}function createCanvas(m){var y=m.width,v=m.height,$e=env.getEnv().createCanvasElement,je=$e();return je.width=y,je.height=v,je}function createCanvasFromMedia(m,y){var v=env.getEnv().ImageData;if(!(m instanceof v)&&!isMediaLoaded(m))throw new Error("createCanvasFromMedia - media has not finished loading yet");var $e=getMediaDimensions(m),je=$e.width,Ge=$e.height,Ye=createCanvas({width:je,height:Ge});return m instanceof v?getContext2dOrThrow(Ye).putImageData(m,0,0):getContext2dOrThrow(Ye).drawImage(m,0,0,je,Ge),Ye}function imageTensorToCanvas(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye,qe;return __generator(this,function(Ke){switch(Ke.label){case 0:return v=env.getEnv().createCanvasElement(),$e=m.shape.slice(isTensor4D(m)?1:0),je=$e[0],Ge=$e[1],Ye=$e[2],qe=Ze(function(){return m.as3D(je,Ge,Ye).toInt()}),[4,id.toPixels(qe,v)];case 1:return Ke.sent(),qe.dispose(),[2,v]}})})}function isMediaElement(m){var y=env.getEnv(),v=y.Image,$e=y.Canvas,je=y.Video;return m instanceof v||m instanceof $e||m instanceof je}function imageToSquare(m,y,v){v===void 0&&(v=!1);var $e=env.getEnv(),je=$e.Image,Ge=$e.Canvas;if(!(m instanceof je||m instanceof Ge))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var Ye=getMediaDimensions(m),qe=y/Math.max(Ye.height,Ye.width),Ke=qe*Ye.width,Qe=qe*Ye.height,Je=createCanvas({width:y,height:y}),st=m instanceof Ge?m:createCanvasFromMedia(m),Mt=Math.abs(Ke-Qe)/2,nn=v&&Ke<Qe?Mt:0,rn=v&&Qe<Ke?Mt:0;return getContext2dOrThrow(Je).drawImage(st,nn,rn,Ke,Qe),Je}var NetInput=function(){function m(y,v){var $e=this;if(v===void 0&&(v=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(y))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+y);this._treatAsBatchInput=v,this._batchSize=y.length,y.forEach(function(je,Ge){if(isTensor3D(je)){$e._imageTensors[Ge]=je,$e._inputDimensions[Ge]=je.shape;return}if(isTensor4D(je)){var Ye=je.shape[0];if(Ye!==1)throw new Error("NetInput - tf.Tensor4D with batchSize "+Ye+" passed, but not supported in input array");$e._imageTensors[Ge]=je,$e._inputDimensions[Ge]=je.shape.slice(1);return}var qe=je instanceof env.getEnv().Canvas?je:createCanvasFromMedia(je);$e._canvases[Ge]=qe,$e._inputDimensions[Ge]=[qe.height,qe.width,3]})}return Object.defineProperty(m.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"reshapedInputDimensions",{get:function(){var y=this;return range(this.batchSize,0,1).map(function(v,$e){return y.getReshapedInputDimensions($e)})},enumerable:!0,configurable:!0}),m.prototype.getInput=function(y){return this.canvases[y]||this.imageTensors[y]},m.prototype.getInputDimensions=function(y){return this._inputDimensions[y]},m.prototype.getInputHeight=function(y){return this._inputDimensions[y][0]},m.prototype.getInputWidth=function(y){return this._inputDimensions[y][1]},m.prototype.getReshapedInputDimensions=function(y){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");var v=this.getInputWidth(y),$e=this.getInputHeight(y);return computeReshapedDimensions({width:v,height:$e},this.inputSize)},m.prototype.toBatchTensor=function(y,v){var $e=this;return v===void 0&&(v=!0),this._inputSize=y,Ze(function(){var je=range($e.batchSize,0,1).map(function(Ye){var qe=$e.getInput(Ye);if(qe instanceof wt){var Ke=isTensor4D(qe)?qe:qe.expandDims();return Ke=padToSquare(Ke,v),(Ke.shape[1]!==y||Ke.shape[2]!==y)&&(Ke=Oh.resizeBilinear(Ke,[y,y])),Ke.as3D(y,y,3)}if(qe instanceof env.getEnv().Canvas)return id.fromPixels(imageToSquare(qe,y,v));throw new Error("toBatchTensor - at batchIdx "+Ye+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+qe)}),Ge=Pr(je.map(function(Ye){return Ye.toFloat()})).as4D($e.batchSize,y,y,3);return Ge})},m}();function toNetInput(m){return __awaiter(this,void 0,void 0,function(){var y,v,$e;return __generator(this,function(je){switch(je.label){case 0:if(m instanceof NetInput)return[2,m];if(y=Array.isArray(m)?m:[m],!y.length)throw new Error("toNetInput - empty array passed as input");return v=function(Ge){return Array.isArray(m)?" at input index "+Ge+":":""},$e=y.map(resolveInput),$e.forEach(function(Ge,Ye){if(!isMediaElement(Ge)&&!isTensor3D(Ge)&&!isTensor4D(Ge))throw typeof y[Ye]=="string"?new Error("toNetInput -"+v(Ye)+" string passed, but could not resolve HTMLElement for element id "+y[Ye]):new Error("toNetInput -"+v(Ye)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");if(isTensor4D(Ge)){var qe=Ge.shape[0];if(qe!==1)throw new Error("toNetInput -"+v(Ye)+" tf.Tensor4D with batchSize "+qe+" passed, but not supported in input array")}}),[4,Promise.all($e.map(function(Ge){return isMediaElement(Ge)&&awaitMediaLoaded(Ge)}))];case 1:return je.sent(),[2,new NetInput($e,Array.isArray(m))]}})})}function extractFaces(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye,qe,Ke;return __generator(this,function(Qe){switch(Qe.label){case 0:return v=env.getEnv().Canvas,$e=m,m instanceof v?[3,5]:[4,toNetInput(m)];case 1:if(je=Qe.sent(),je.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return Ge=je.getInput(0),Ge instanceof v?(Ye=Ge,[3,4]):[3,2];case 2:return[4,imageTensorToCanvas(Ge)];case 3:Ye=Qe.sent(),Qe.label=4;case 4:$e=Ye,Qe.label=5;case 5:return qe=getContext2dOrThrow($e),Ke=y.map(function(Je){return Je instanceof FaceDetection?Je.forSize($e.width,$e.height).box.floor():Je}).map(function(Je){return Je.clipAtImageBorders($e.width,$e.height)}),[2,Ke.map(function(Je){var st=Je.x,Mt=Je.y,nn=Je.width,rn=Je.height,on=createCanvas({width:nn,height:rn});return getContext2dOrThrow(on).putImageData(qe.getImageData(st,Mt,nn,rn),0,0),on})]}})})}function extractFaceTensors(m,y){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(v){if(!isTensor3D(m)&&!isTensor4D(m))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(isTensor4D(m)&&m.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,Ze(function(){var $e=m.shape.slice(isTensor4D(m)?1:0),je=$e[0],Ge=$e[1],Ye=$e[2],qe=y.map(function(Qe){return Qe instanceof FaceDetection?Qe.forSize(Ge,je).box:Qe}).map(function(Qe){return Qe.clipAtImageBorders(Ge,je)}),Ke=qe.map(function(Qe){var Je=Qe.x,st=Qe.y,Mt=Qe.width,nn=Qe.height;return xl(m.as3D(je,Ge,Ye),[st,Je,0],[nn,Mt,Ye])});return Ke})]})})}function fetchOrThrow(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e;return __generator(this,function(je){switch(je.label){case 0:return v=env.getEnv().fetch,[4,v(m,y)];case 1:if($e=je.sent(),!($e.status<400))throw new Error("failed to fetch: ("+$e.status+") "+$e.statusText+", from url: "+$e.url);return[2,$e]}})})}function fetchJson(m){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(y){switch(y.label){case 0:return[4,fetchOrThrow(m)];case 1:return[2,y.sent().json()]}})})}function getModelUris(m,y){var v=y+"-weights_manifest.json";if(!m)return{modelBaseUri:"",manifestUri:v};if(m==="/")return{modelBaseUri:"/",manifestUri:"/"+v};var $e=m.startsWith("http://")?"http://":m.startsWith("https://")?"https://":"";m=m.replace($e,"");var je=m.split("/").filter(function(qe){return qe}),Ge=m.endsWith(".json")?je[je.length-1]:v,Ye=$e+(m.endsWith(".json")?je.slice(0,je.length-1):je).join("/");return Ye=m.startsWith("/")?"/"+Ye:Ye,{modelBaseUri:Ye,manifestUri:Ye==="/"?"/"+Ge:Ye+"/"+Ge}}function loadWeightMap(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge;return __generator(this,function(Ye){switch(Ye.label){case 0:return v=getModelUris(m,y),$e=v.manifestUri,je=v.modelBaseUri,[4,fetchJson($e)];case 1:return Ge=Ye.sent(),[2,ed.loadWeights(Ge,je)]}})})}var NeuralNetwork=function(){function m(y){this._name=y,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(m.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),m.prototype.getParamFromPath=function(y){var v=this.traversePropertyPath(y),$e=v.obj,je=v.objProp;return $e[je]},m.prototype.reassignParamFromPath=function(y,v){var $e=this.traversePropertyPath(y),je=$e.obj,Ge=$e.objProp;je[Ge].dispose(),je[Ge]=v},m.prototype.getParamList=function(){var y=this;return this._paramMappings.map(function(v){var $e=v.paramPath;return{path:$e,tensor:y.getParamFromPath($e)}})},m.prototype.getTrainableParams=function(){return this.getParamList().filter(function(y){return y.tensor instanceof St})},m.prototype.getFrozenParams=function(){return this.getParamList().filter(function(y){return!(y.tensor instanceof St)})},m.prototype.variable=function(){var y=this;this.getFrozenParams().forEach(function(v){var $e=v.path,je=v.tensor;y.reassignParamFromPath($e,je.variable())})},m.prototype.freeze=function(){var y=this;this.getTrainableParams().forEach(function(v){var $e=v.path,je=v.tensor,Ge=Fn(je.dataSync());je.dispose(),y.reassignParamFromPath($e,Ge)})},m.prototype.dispose=function(y){y===void 0&&(y=!0),this.getParamList().forEach(function(v){if(y&&v.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+v.path);v.tensor.dispose()}),this._params=void 0},m.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(y){var v=y.tensor;return Array.from(v.dataSync())}).reduce(function(y,v){return y.concat(v)}))},m.prototype.load=function(y){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(v){switch(v.label){case 0:return y instanceof Float32Array?(this.extractWeights(y),[2]):[4,this.loadFromUri(y)];case 1:return v.sent(),[2]}})})},m.prototype.loadFromUri=function(y){return __awaiter(this,void 0,void 0,function(){var v;return __generator(this,function($e){switch($e.label){case 0:if(y&&typeof y!="string")throw new Error(this._name+".loadFromUri - expected model uri");return[4,loadWeightMap(y,this.getDefaultModelName())];case 1:return v=$e.sent(),this.loadFromWeightMap(v),[2]}})})},m.prototype.loadFromDisk=function(y){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye,qe,Ke,Qe,Je,st;return __generator(this,function(Mt){switch(Mt.label){case 0:if(y&&typeof y!="string")throw new Error(this._name+".loadFromDisk - expected model file path");return v=env.getEnv().readFile,$e=getModelUris(y,this.getDefaultModelName()),je=$e.manifestUri,Ge=$e.modelBaseUri,Ye=function(nn){return Promise.all(nn.map(function(rn){return v(rn).then(function(on){return on.buffer})}))},qe=ed.weightsLoaderFactory(Ye),Je=(Qe=JSON).parse,[4,v(je)];case 1:return Ke=Je.apply(Qe,[Mt.sent().toString()]),[4,qe(Ke,Ge)];case 2:return st=Mt.sent(),this.loadFromWeightMap(st),[2]}})})},m.prototype.loadFromWeightMap=function(y){var v=this.extractParamsFromWeigthMap(y),$e=v.paramMappings,je=v.params;this._paramMappings=$e,this._params=je},m.prototype.extractWeights=function(y){var v=this.extractParams(y),$e=v.paramMappings,je=v.params;this._paramMappings=$e,this._params=je},m.prototype.traversePropertyPath=function(y){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var v=y.split("/").reduce(function(Ge,Ye){if(!Ge.nextObj.hasOwnProperty(Ye))throw new Error("traversePropertyPath - object does not have property "+Ye+", for path "+y);return{obj:Ge.nextObj,objProp:Ye,nextObj:Ge.nextObj[Ye]}},{nextObj:this.params}),$e=v.obj,je=v.objProp;if(!$e||!je||!($e[je]instanceof wt))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+y);return{obj:$e,objProp:je}},m}();function depthwiseSeparableConv$1(m,y,v){return Ze(function(){var $e=Jc(m,y.depthwise_filter,y.pointwise_filter,v,"same");return $e=rc($e,y.bias),$e})}function denseBlock3(m,y,v){return v===void 0&&(v=!1),Ze(function(){var $e=Bl(v?rc(qc(m,y.conv0.filters,[2,2],"same"),y.conv0.bias):depthwiseSeparableConv$1(m,y.conv0,[2,2])),je=depthwiseSeparableConv$1($e,y.conv1,[1,1]),Ge=Bl(rc($e,je)),Ye=depthwiseSeparableConv$1(Ge,y.conv2,[1,1]);return Bl(rc($e,rc(je,Ye)))})}function denseBlock4(m,y,v,$e){return v===void 0&&(v=!1),$e===void 0&&($e=!0),Ze(function(){var je=Bl(v?rc(qc(m,y.conv0.filters,$e?[2,2]:[1,1],"same"),y.conv0.bias):depthwiseSeparableConv$1(m,y.conv0,$e?[2,2]:[1,1])),Ge=depthwiseSeparableConv$1(je,y.conv1,[1,1]),Ye=Bl(rc(je,Ge)),qe=depthwiseSeparableConv$1(Ye,y.conv2,[1,1]),Ke=Bl(rc(je,rc(Ge,qe))),Qe=depthwiseSeparableConv$1(Ke,y.conv3,[1,1]);return Bl(rc(je,rc(Ge,rc(qe,Qe))))})}function convLayer$1(m,y,v,$e){return v===void 0&&(v="same"),$e===void 0&&($e=!1),Ze(function(){var je=rc(qc(m,y.filters,[1,1],v),y.bias);return $e?Bl(je):je})}function disposeUnusedWeightTensors(m,y){Object.keys(m).forEach(function(v){y.some(function($e){return $e.originalPath===v})||m[v].dispose()})}function extractConvParamsFactory(m,y){return function(v,$e,je,Ge){var Ye=Ln(m(v*$e*je*je),[je,je,v,$e]),qe=Mn(m($e));return y.push({paramPath:Ge+"/filters"},{paramPath:Ge+"/bias"}),{filters:Ye,bias:qe}}}function extractFCParamsFactory(m,y){return function(v,$e,je){var Ge=Bn(m(v*$e),[v,$e]),Ye=Mn(m($e));return y.push({paramPath:je+"/weights"},{paramPath:je+"/bias"}),{weights:Ge,bias:Ye}}}var SeparableConvParams=function(){function m(y,v,$e){this.depthwise_filter=y,this.pointwise_filter=v,this.bias=$e}return m}();function extractSeparableConvParamsFactory(m,y){return function(v,$e,je){var Ge=Ln(m(9*v),[3,3,v,1]),Ye=Ln(m(v*$e),[1,1,v,$e]),qe=Mn(m($e));return y.push({paramPath:je+"/depthwise_filter"},{paramPath:je+"/pointwise_filter"},{paramPath:je+"/bias"}),new SeparableConvParams(Ge,Ye,qe)}}function loadSeparableConvParamsFactory(m){return function(y){var v=m(y+"/depthwise_filter",4),$e=m(y+"/pointwise_filter",4),je=m(y+"/bias",1);return new SeparableConvParams(v,$e,je)}}function extractWeightEntryFactory(m,y){return function(v,$e,je){var Ge=m[v];if(!isTensor(Ge,$e))throw new Error("expected weightMap["+v+"] to be a Tensor"+$e+"D, instead have "+Ge);return y.push({originalPath:v,paramPath:je||v}),Ge}}function extractWeightsFactory(m){var y=m;function v(je){var Ge=y.slice(0,je);return y=y.slice(je),Ge}function $e(){return y}return{extractWeights:v,getRemainingWeights:$e}}function extractorsFactory$9(m,y){var v=extractConvParamsFactory(m,y),$e=extractSeparableConvParamsFactory(m,y);function je(Ye,qe,Ke,Qe){Qe===void 0&&(Qe=!1);var Je=Qe?v(Ye,qe,3,Ke+"/conv0"):$e(Ye,qe,Ke+"/conv0"),st=$e(qe,qe,Ke+"/conv1"),Mt=$e(qe,qe,Ke+"/conv2");return{conv0:Je,conv1:st,conv2:Mt}}function Ge(Ye,qe,Ke,Qe){Qe===void 0&&(Qe=!1);var Je=je(Ye,qe,Ke,Qe),st=Je.conv0,Mt=Je.conv1,nn=Je.conv2,rn=$e(qe,qe,Ke+"/conv3");return{conv0:st,conv1:Mt,conv2:nn,conv3:rn}}return{extractDenseBlock3Params:je,extractDenseBlock4Params:Ge}}function extractParams$7(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,je=v.getRemainingWeights,Ge=extractorsFactory$9($e,y).extractDenseBlock4Params,Ye=Ge(3,32,"dense0",!0),qe=Ge(32,64,"dense1"),Ke=Ge(64,128,"dense2"),Qe=Ge(128,256,"dense3");if(je().length!==0)throw new Error("weights remaing after extract: "+je().length);return{paramMappings:y,params:{dense0:Ye,dense1:qe,dense2:Ke,dense3:Qe}}}function loadConvParamsFactory(m){return function(y){var v=m(y+"/filters",4),$e=m(y+"/bias",1);return{filters:v,bias:$e}}}function loadParamsFactory$1(m,y){var v=extractWeightEntryFactory(m,y),$e=loadConvParamsFactory(v),je=loadSeparableConvParamsFactory(v);function Ge(qe,Ke){Ke===void 0&&(Ke=!1);var Qe=Ke?$e(qe+"/conv0"):je(qe+"/conv0"),Je=je(qe+"/conv1"),st=je(qe+"/conv2");return{conv0:Qe,conv1:Je,conv2:st}}function Ye(qe,Ke){Ke===void 0&&(Ke=!1);var Qe=Ke?$e(qe+"/conv0"):je(qe+"/conv0"),Je=je(qe+"/conv1"),st=je(qe+"/conv2"),Mt=je(qe+"/conv3");return{conv0:Qe,conv1:Je,conv2:st,conv3:Mt}}return{extractDenseBlock3Params:Ge,extractDenseBlock4Params:Ye}}function extractParamsFromWeigthMap$7(m){var y=[],v=loadParamsFactory$1(m,y).extractDenseBlock4Params,$e={dense0:v("dense0",!0),dense1:v("dense1"),dense2:v("dense2"),dense3:v("dense3")};return disposeUnusedWeightTensors(m,y),{params:$e,paramMappings:y}}var FaceFeatureExtractor=function(m){__extends(y,m);function y(){return m.call(this,"FaceFeatureExtractor")||this}return y.prototype.forwardInput=function(v){var $e=this.params;if(!$e)throw new Error("FaceFeatureExtractor - load model before inference");return Ze(function(){var je=v.toBatchTensor(112,!0),Ge=[122.782,117.001,104.298],Ye=normalize$1(je,Ge).div(On(255)),qe=denseBlock4(Ye,$e.dense0,!0);return qe=denseBlock4(qe,$e.dense1),qe=denseBlock4(qe,$e.dense2),qe=denseBlock4(qe,$e.dense3),qe=fl(qe,[7,7],[2,2],"valid"),qe})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap$7(v)},y.prototype.extractParams=function(v){return extractParams$7(v)},y}(NeuralNetwork);function fullyConnectedLayer(m,y){return Ze(function(){return rc(el(m,y.weights),y.bias)})}function extractParams$6(m,y,v){var $e=[],je=extractWeightsFactory(m),Ge=je.extractWeights,Ye=je.getRemainingWeights,qe=extractFCParamsFactory(Ge,$e),Ke=qe(y,v,"fc");if(Ye().length!==0)throw new Error("weights remaing after extract: "+Ye().length);return{paramMappings:$e,params:{fc:Ke}}}function extractParamsFromWeigthMap$6(m){var y=[],v=extractWeightEntryFactory(m,y);function $e(Ge){var Ye=v(Ge+"/weights",2),qe=v(Ge+"/bias",1);return{weights:Ye,bias:qe}}var je={fc:$e("fc")};return disposeUnusedWeightTensors(m,y),{params:je,paramMappings:y}}function seperateWeightMaps(m){var y={},v={};return Object.keys(m).forEach(function($e){var je=$e.startsWith("fc")?v:y;je[$e]=m[$e]}),{featureExtractorMap:y,classifierMap:v}}var FaceProcessor=function(m){__extends(y,m);function y(v,$e){var je=m.call(this,v)||this;return je._faceFeatureExtractor=$e,je}return Object.defineProperty(y.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),y.prototype.runNet=function(v){var $e=this,je=this.params;if(!je)throw new Error(this._name+" - load model before inference");return Ze(function(){var Ge=v instanceof NetInput?$e.faceFeatureExtractor.forwardInput(v):v;return fullyConnectedLayer(Ge.as2D(Ge.shape[0],-1),je.fc)})},y.prototype.dispose=function(v){v===void 0&&(v=!0),this.faceFeatureExtractor.dispose(v),m.prototype.dispose.call(this,v)},y.prototype.loadClassifierParams=function(v){var $e=this.extractClassifierParams(v),je=$e.params,Ge=$e.paramMappings;this._params=je,this._paramMappings=Ge},y.prototype.extractClassifierParams=function(v){return extractParams$6(v,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},y.prototype.extractParamsFromWeigthMap=function(v){var $e=seperateWeightMaps(v),je=$e.featureExtractorMap,Ge=$e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(je),extractParamsFromWeigthMap$6(Ge)},y.prototype.extractParams=function(v){var $e=this.getClassifierChannelsIn(),je=this.getClassifierChannelsOut(),Ge=je*$e+je,Ye=v.slice(0,v.length-Ge),qe=v.slice(v.length-Ge);return this.faceFeatureExtractor.extractWeights(Ye),this.extractClassifierParams(qe)},y}(NeuralNetwork),FACE_EXPRESSION_LABELS=["neutral","happy","sad","angry","fearful","disgusted","surprised"],FaceExpressions=function(){function m(y){var v=this;if(y.length!==7)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+y.length);FACE_EXPRESSION_LABELS.forEach(function($e,je){v[$e]=y[je]})}return m.prototype.asSortedArray=function(){var y=this;return FACE_EXPRESSION_LABELS.map(function(v){return{expression:v,probability:y[v]}}).sort(function(v,$e){return $e.probability-v.probability})},m}(),FaceExpressionNet=function(m){__extends(y,m);function y(v){return v===void 0&&(v=new FaceFeatureExtractor),m.call(this,"FaceExpressionNet",v)||this}return y.prototype.forwardInput=function(v){var $e=this;return Ze(function(){return go($e.runNet(v))})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.predictExpressions=function(v){return __awaiter(this,void 0,void 0,function(){var $e,je,Ge,Ye,qe=this;return __generator(this,function(Ke){switch(Ke.label){case 0:return[4,toNetInput(v)];case 1:return $e=Ke.sent(),[4,this.forwardInput($e)];case 2:return je=Ke.sent(),[4,Promise.all(Ur(je).map(function(Qe){return __awaiter(qe,void 0,void 0,function(){var Je;return __generator(this,function(st){switch(st.label){case 0:return[4,Qe.data()];case 1:return Je=st.sent(),Qe.dispose(),[2,Je]}})})}))];case 3:return Ge=Ke.sent(),je.dispose(),Ye=Ge.map(function(Qe){return new FaceExpressions(Qe)}),[2,$e.isBatchInput?Ye:Ye[0]]}})})},y.prototype.getDefaultModelName=function(){return"face_expression_model"},y.prototype.getClassifierChannelsIn=function(){return 256},y.prototype.getClassifierChannelsOut=function(){return 7},y}(FaceProcessor);function extendWithFaceExpressions(m,y){var v={expressions:y};return Object.assign({},m,v)}function isWithFaceLandmarks(m){return isWithFaceDetection(m)&&m.landmarks instanceof FaceLandmarks&&m.unshiftedLandmarks instanceof FaceLandmarks&&m.alignedRect instanceof FaceDetection}function extendWithFaceLandmarks(m,y){var v=m.detection.box,$e=y.shiftBy(v.x,v.y),je=$e.align(),Ge=m.detection.imageDims,Ye=new FaceDetection(m.detection.score,je.rescale(Ge.reverse()),Ge),qe={landmarks:$e,unshiftedLandmarks:y,alignedRect:Ye};return Object.assign({},m,qe)}function extractorsFactory$8(m,y){var v=extractConvParamsFactory(m,y),$e=extractSeparableConvParamsFactory(m,y);function je(Ye,qe,Ke){var Qe=$e(Ye,qe,Ke+"/separable_conv0"),Je=$e(qe,qe,Ke+"/separable_conv1"),st=v(Ye,qe,1,Ke+"/expansion_conv");return{separable_conv0:Qe,separable_conv1:Je,expansion_conv:st}}function Ge(Ye,qe){var Ke=$e(Ye,Ye,qe+"/separable_conv0"),Qe=$e(Ye,Ye,qe+"/separable_conv1"),Je=$e(Ye,Ye,qe+"/separable_conv2");return{separable_conv0:Ke,separable_conv1:Qe,separable_conv2:Je}}return{extractConvParams:v,extractSeparableConvParams:$e,extractReductionBlockParams:je,extractMainBlockParams:Ge}}function extractParams$5(m,y){var v=[],$e=extractWeightsFactory(m),je=$e.extractWeights,Ge=$e.getRemainingWeights,Ye=extractorsFactory$8(je,v),qe=Ye.extractConvParams,Ke=Ye.extractSeparableConvParams,Qe=Ye.extractReductionBlockParams,Je=Ye.extractMainBlockParams,st=qe(3,32,3,"entry_flow/conv_in"),Mt=Qe(32,64,"entry_flow/reduction_block_0"),nn=Qe(64,128,"entry_flow/reduction_block_1"),rn={conv_in:st,reduction_block_0:Mt,reduction_block_1:nn},on={};range(y,0,1).forEach(function(cn){on["main_block_"+cn]=Je(128,"middle_flow/main_block_"+cn)});var an=Qe(128,256,"exit_flow/reduction_block"),sn=Ke(256,512,"exit_flow/separable_conv"),ln={reduction_block:an,separable_conv:sn};if(Ge().length!==0)throw new Error("weights remaing after extract: "+Ge().length);return{paramMappings:v,params:{entry_flow:rn,middle_flow:on,exit_flow:ln}}}function loadParamsFactory(m,y){var v=extractWeightEntryFactory(m,y),$e=loadConvParamsFactory(v),je=loadSeparableConvParamsFactory(v);function Ge(qe){var Ke=je(qe+"/separable_conv0"),Qe=je(qe+"/separable_conv1"),Je=$e(qe+"/expansion_conv");return{separable_conv0:Ke,separable_conv1:Qe,expansion_conv:Je}}function Ye(qe){var Ke=je(qe+"/separable_conv0"),Qe=je(qe+"/separable_conv1"),Je=je(qe+"/separable_conv2");return{separable_conv0:Ke,separable_conv1:Qe,separable_conv2:Je}}return{extractConvParams:$e,extractSeparableConvParams:je,extractReductionBlockParams:Ge,extractMainBlockParams:Ye}}function extractParamsFromWeigthMap$5(m,y){var v=[],$e=loadParamsFactory(m,v),je=$e.extractConvParams,Ge=$e.extractSeparableConvParams,Ye=$e.extractReductionBlockParams,qe=$e.extractMainBlockParams,Ke=je("entry_flow/conv_in"),Qe=Ye("entry_flow/reduction_block_0"),Je=Ye("entry_flow/reduction_block_1"),st={conv_in:Ke,reduction_block_0:Qe,reduction_block_1:Je},Mt={};range(y,0,1).forEach(function(an){Mt["main_block_"+an]=qe("middle_flow/main_block_"+an)});var nn=Ye("exit_flow/reduction_block"),rn=Ge("exit_flow/separable_conv"),on={reduction_block:nn,separable_conv:rn};return disposeUnusedWeightTensors(m,v),{params:{entry_flow:st,middle_flow:Mt,exit_flow:on},paramMappings:v}}function conv$1(m,y,v){return rc(qc(m,y.filters,v,"same"),y.bias)}function reductionBlock(m,y,v){v===void 0&&(v=!0);var $e=v?Bl(m):m;return $e=depthwiseSeparableConv$1($e,y.separable_conv0,[1,1]),$e=depthwiseSeparableConv$1(Bl($e),y.separable_conv1,[1,1]),$e=hl($e,[3,3],[2,2],"same"),$e=rc($e,conv$1(m,y.expansion_conv,[2,2])),$e}function mainBlock(m,y){var v=depthwiseSeparableConv$1(Bl(m),y.separable_conv0,[1,1]);return v=depthwiseSeparableConv$1(Bl(v),y.separable_conv1,[1,1]),v=depthwiseSeparableConv$1(Bl(v),y.separable_conv2,[1,1]),v=rc(v,m),v}var TinyXception=function(m){__extends(y,m);function y(v){var $e=m.call(this,"TinyXception")||this;return $e._numMainBlocks=v,$e}return y.prototype.forwardInput=function(v){var $e=this,je=this.params;if(!je)throw new Error("TinyXception - load model before inference");return Ze(function(){var Ge=v.toBatchTensor(112,!0),Ye=[122.782,117.001,104.298],qe=normalize$1(Ge,Ye).div(On(256)),Ke=Bl(conv$1(qe,je.entry_flow.conv_in,[2,2]));return Ke=reductionBlock(Ke,je.entry_flow.reduction_block_0,!1),Ke=reductionBlock(Ke,je.entry_flow.reduction_block_1),range($e._numMainBlocks,0,1).forEach(function(Qe){Ke=mainBlock(Ke,je.middle_flow["main_block_"+Qe])}),Ke=reductionBlock(Ke,je.exit_flow.reduction_block),Ke=Bl(depthwiseSeparableConv$1(Ke,je.exit_flow.separable_conv,[1,1])),Ke})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.getDefaultModelName=function(){return"tiny_xception_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap$5(v,this._numMainBlocks)},y.prototype.extractParams=function(v){return extractParams$5(v,this._numMainBlocks)},y}(NeuralNetwork);function extractParams$4(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,je=v.getRemainingWeights,Ge=extractFCParamsFactory($e,y),Ye=Ge(512,1,"fc/age"),qe=Ge(512,2,"fc/gender");if(je().length!==0)throw new Error("weights remaing after extract: "+je().length);return{paramMappings:y,params:{fc:{age:Ye,gender:qe}}}}function extractParamsFromWeigthMap$4(m){var y=[],v=extractWeightEntryFactory(m,y);function $e(Ge){var Ye=v(Ge+"/weights",2),qe=v(Ge+"/bias",1);return{weights:Ye,bias:qe}}var je={fc:{age:$e("fc/age"),gender:$e("fc/gender")}};return disposeUnusedWeightTensors(m,y),{params:je,paramMappings:y}}var Gender;(function(m){m.FEMALE="female",m.MALE="male"})(Gender||(Gender={}));var AgeGenderNet=function(m){__extends(y,m);function y(v){v===void 0&&(v=new TinyXception(2));var $e=m.call(this,"AgeGenderNet")||this;return $e._faceFeatureExtractor=v,$e}return Object.defineProperty(y.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),y.prototype.runNet=function(v){var $e=this,je=this.params;if(!je)throw new Error(this._name+" - load model before inference");return Ze(function(){var Ge=v instanceof NetInput?$e.faceFeatureExtractor.forwardInput(v):v,Ye=fl(Ge,[7,7],[2,2],"valid").as2D(Ge.shape[0],-1),qe=fullyConnectedLayer(Ye,je.fc.age).as1D(),Ke=fullyConnectedLayer(Ye,je.fc.gender);return{age:qe,gender:Ke}})},y.prototype.forwardInput=function(v){var $e=this;return Ze(function(){var je=$e.runNet(v),Ge=je.age,Ye=je.gender;return{age:Ge,gender:go(Ye)}})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.predictAgeAndGender=function(v){return __awaiter(this,void 0,void 0,function(){var $e,je,Ge,Ye,qe,Ke,Qe=this;return __generator(this,function(Je){switch(Je.label){case 0:return[4,toNetInput(v)];case 1:return $e=Je.sent(),[4,this.forwardInput($e)];case 2:return je=Je.sent(),Ge=Ur(je.age),Ye=Ur(je.gender),qe=Ge.map(function(st,Mt){return{ageTensor:st,genderTensor:Ye[Mt]}}),[4,Promise.all(qe.map(function(st){var Mt=st.ageTensor,nn=st.genderTensor;return __awaiter(Qe,void 0,void 0,function(){var rn,on,an,sn,ln;return __generator(this,function(cn){switch(cn.label){case 0:return[4,Mt.data()];case 1:return rn=cn.sent()[0],[4,nn.data()];case 2:return on=cn.sent()[0],an=on>.5,sn=an?Gender.MALE:Gender.FEMALE,ln=an?on:1-on,Mt.dispose(),nn.dispose(),[2,{age:rn,gender:sn,genderProbability:ln}]}})})}))];case 3:return Ke=Je.sent(),je.age.dispose(),je.gender.dispose(),[2,$e.isBatchInput?Ke:Ke[0]]}})})},y.prototype.getDefaultModelName=function(){return"age_gender_model"},y.prototype.dispose=function(v){v===void 0&&(v=!0),this.faceFeatureExtractor.dispose(v),m.prototype.dispose.call(this,v)},y.prototype.loadClassifierParams=function(v){var $e=this.extractClassifierParams(v),je=$e.params,Ge=$e.paramMappings;this._params=je,this._paramMappings=Ge},y.prototype.extractClassifierParams=function(v){return extractParams$4(v)},y.prototype.extractParamsFromWeigthMap=function(v){var $e=seperateWeightMaps(v),je=$e.featureExtractorMap,Ge=$e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(je),extractParamsFromWeigthMap$4(Ge)},y.prototype.extractParams=function(v){var $e=1539,je=v.slice(0,v.length-$e),Ge=v.slice(v.length-$e);return this.faceFeatureExtractor.extractWeights(je),this.extractClassifierParams(Ge)},y}(NeuralNetwork),FaceLandmark68NetBase=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.postProcess=function(v,$e,je){var Ge=je.map(function(qe){var Ke=qe.width,Qe=qe.height,Je=$e/Math.max(Qe,Ke);return{width:Ke*Je,height:Qe*Je}}),Ye=Ge.length;return Ze(function(){var qe=function(Mt,nn){return Pr([Hn([68],Mt),Hn([68],nn)],1).as2D(1,136).as1D()},Ke=function(Mt,nn){var rn=Ge[Mt],on=rn.width,an=rn.height;return nn(on,an)?Math.abs(on-an)/2:0},Qe=function(Mt){return Ke(Mt,function(nn,rn){return nn<rn})},Je=function(Mt){return Ke(Mt,function(nn,rn){return rn<nn})},st=v.mul(Hn([Ye,136],$e)).sub(Pr(Array.from(Array(Ye),function(Mt,nn){return qe(Qe(nn),Je(nn))}))).div(Pr(Array.from(Array(Ye),function(Mt,nn){return qe(Ge[nn].width,Ge[nn].height)})));return st})},y.prototype.forwardInput=function(v){var $e=this;return Ze(function(){var je=$e.runNet(v);return $e.postProcess(je,v.inputSize,v.inputDimensions.map(function(Ge){var Ye=Ge[0],qe=Ge[1];return{height:Ye,width:qe}}))})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.detectLandmarks=function(v){return __awaiter(this,void 0,void 0,function(){var $e,je,Ge,Ye=this;return __generator(this,function(qe){switch(qe.label){case 0:return[4,toNetInput(v)];case 1:return $e=qe.sent(),je=Ze(function(){return Ur(Ye.forwardInput($e))}),[4,Promise.all(je.map(function(Ke,Qe){return __awaiter(Ye,void 0,void 0,function(){var Je,st,Mt,nn,rn;return __generator(this,function(on){switch(on.label){case 0:return Mt=(st=Array).from,[4,Ke.data()];case 1:return Je=Mt.apply(st,[on.sent()]),nn=Je.filter(function(an,sn){return isEven(sn)}),rn=Je.filter(function(an,sn){return!isEven(sn)}),[2,new FaceLandmarks68(Array(68).fill(0).map(function(an,sn){return new Point(nn[sn],rn[sn])}),{height:$e.getInputHeight(Qe),width:$e.getInputWidth(Qe)})]}})})}))];case 2:return Ge=qe.sent(),je.forEach(function(Ke){return Ke.dispose()}),[2,$e.isBatchInput?Ge:Ge[0]]}})})},y.prototype.getClassifierChannelsOut=function(){return 136},y}(FaceProcessor),FaceLandmark68Net=function(m){__extends(y,m);function y(v){return v===void 0&&(v=new FaceFeatureExtractor),m.call(this,"FaceLandmark68Net",v)||this}return y.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},y.prototype.getClassifierChannelsIn=function(){return 256},y}(FaceLandmark68NetBase);function extractParamsFromWeigthMapTiny(m){var y=[],v=loadParamsFactory$1(m,y).extractDenseBlock3Params,$e={dense0:v("dense0",!0),dense1:v("dense1"),dense2:v("dense2")};return disposeUnusedWeightTensors(m,y),{params:$e,paramMappings:y}}function extractParamsTiny(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,je=v.getRemainingWeights,Ge=extractorsFactory$9($e,y).extractDenseBlock3Params,Ye=Ge(3,32,"dense0",!0),qe=Ge(32,64,"dense1"),Ke=Ge(64,128,"dense2");if(je().length!==0)throw new Error("weights remaing after extract: "+je().length);return{paramMappings:y,params:{dense0:Ye,dense1:qe,dense2:Ke}}}var TinyFaceFeatureExtractor=function(m){__extends(y,m);function y(){return m.call(this,"TinyFaceFeatureExtractor")||this}return y.prototype.forwardInput=function(v){var $e=this.params;if(!$e)throw new Error("TinyFaceFeatureExtractor - load model before inference");return Ze(function(){var je=v.toBatchTensor(112,!0),Ge=[122.782,117.001,104.298],Ye=normalize$1(je,Ge).div(On(255)),qe=denseBlock3(Ye,$e.dense0,!0);return qe=denseBlock3(qe,$e.dense1),qe=denseBlock3(qe,$e.dense2),qe=fl(qe,[14,14],[2,2],"valid"),qe})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMapTiny(v)},y.prototype.extractParams=function(v){return extractParamsTiny(v)},y}(NeuralNetwork),FaceLandmark68TinyNet=function(m){__extends(y,m);function y(v){return v===void 0&&(v=new TinyFaceFeatureExtractor),m.call(this,"FaceLandmark68TinyNet",v)||this}return y.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},y.prototype.getClassifierChannelsIn=function(){return 128},y}(FaceLandmark68NetBase);(function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y})(FaceLandmark68Net);function scale(m,y){return rc(gc(m,y.weights),y.biases)}function convLayer(m,y,v,$e,je){je===void 0&&(je="same");var Ge=y.conv,Ye=Ge.filters,qe=Ge.bias,Ke=qc(m,Ye,v,je);return Ke=rc(Ke,qe),Ke=scale(Ke,y.scale),$e?Bl(Ke):Ke}function conv(m,y){return convLayer(m,y,[1,1],!0)}function convNoRelu(m,y){return convLayer(m,y,[1,1],!1)}function convDown(m,y){return convLayer(m,y,[2,2],!0,"valid")}function extractorsFactory$7(m,y){function v(qe,Ke,Qe){var Je=m(qe),st=Je.length/(Ke*Qe*Qe);if(isFloat(st))throw new Error("depth has to be an integer: "+st+", weights.length: "+Je.length+", numFilters: "+Ke+", filterSize: "+Qe);return Ze(function(){return Wl(Ln(Je,[Ke,st,Qe,Qe]),[2,3,1,0])})}function $e(qe,Ke,Qe,Je){var st=v(qe,Ke,Qe),Mt=Mn(m(Ke));return y.push({paramPath:Je+"/filters"},{paramPath:Je+"/bias"}),{filters:st,bias:Mt}}function je(qe,Ke){var Qe=Mn(m(qe)),Je=Mn(m(qe));return y.push({paramPath:Ke+"/weights"},{paramPath:Ke+"/biases"}),{weights:Qe,biases:Je}}function Ge(qe,Ke,Qe,Je){var st=$e(qe,Ke,Qe,Je+"/conv"),Mt=je(Ke,Je+"/scale");return{conv:st,scale:Mt}}function Ye(qe,Ke,Qe,Je,st){st===void 0&&(st=!1);var Mt=Ge((st?.5:1)*qe,Ke,Qe,Je+"/conv1"),nn=Ge(qe,Ke,Qe,Je+"/conv2");return{conv1:Mt,conv2:nn}}return{extractConvLayerParams:Ge,extractResidualLayerParams:Ye}}function extractParams$3(m){var y=extractWeightsFactory(m),v=y.extractWeights,$e=y.getRemainingWeights,je=[],Ge=extractorsFactory$7(v,je),Ye=Ge.extractConvLayerParams,qe=Ge.extractResidualLayerParams,Ke=Ye(4704,32,7,"conv32_down"),Qe=qe(9216,32,3,"conv32_1"),Je=qe(9216,32,3,"conv32_2"),st=qe(9216,32,3,"conv32_3"),Mt=qe(36864,64,3,"conv64_down",!0),nn=qe(36864,64,3,"conv64_1"),rn=qe(36864,64,3,"conv64_2"),on=qe(36864,64,3,"conv64_3"),an=qe(147456,128,3,"conv128_down",!0),sn=qe(147456,128,3,"conv128_1"),ln=qe(147456,128,3,"conv128_2"),cn=qe(589824,256,3,"conv256_down",!0),un=qe(589824,256,3,"conv256_1"),hn=qe(589824,256,3,"conv256_2"),fn=qe(589824,256,3,"conv256_down_out"),to=Ze(function(){return Wl(Bn(v(256*128),[128,256]),[1,0])});if(je.push({paramPath:"fc"}),$e().length!==0)throw new Error("weights remaing after extract: "+$e().length);var Mi={conv32_down:Ke,conv32_1:Qe,conv32_2:Je,conv32_3:st,conv64_down:Mt,conv64_1:nn,conv64_2:rn,conv64_3:on,conv128_down:an,conv128_1:sn,conv128_2:ln,conv256_down:cn,conv256_1:un,conv256_2:hn,conv256_down_out:fn,fc:to};return{params:Mi,paramMappings:je}}function extractorsFactory$6(m,y){var v=extractWeightEntryFactory(m,y);function $e(Ye){var qe=v(Ye+"/scale/weights",1),Ke=v(Ye+"/scale/biases",1);return{weights:qe,biases:Ke}}function je(Ye){var qe=v(Ye+"/conv/filters",4),Ke=v(Ye+"/conv/bias",1),Qe=$e(Ye);return{conv:{filters:qe,bias:Ke},scale:Qe}}function Ge(Ye){return{conv1:je(Ye+"/conv1"),conv2:je(Ye+"/conv2")}}return{extractConvLayerParams:je,extractResidualLayerParams:Ge}}function extractParamsFromWeigthMap$3(m){var y=[],v=extractorsFactory$6(m,y),$e=v.extractConvLayerParams,je=v.extractResidualLayerParams,Ge=$e("conv32_down"),Ye=je("conv32_1"),qe=je("conv32_2"),Ke=je("conv32_3"),Qe=je("conv64_down"),Je=je("conv64_1"),st=je("conv64_2"),Mt=je("conv64_3"),nn=je("conv128_down"),rn=je("conv128_1"),on=je("conv128_2"),an=je("conv256_down"),sn=je("conv256_1"),ln=je("conv256_2"),cn=je("conv256_down_out"),un=m.fc;if(y.push({originalPath:"fc",paramPath:"fc"}),!isTensor2D(un))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+un);var hn={conv32_down:Ge,conv32_1:Ye,conv32_2:qe,conv32_3:Ke,conv64_down:Qe,conv64_1:Je,conv64_2:st,conv64_3:Mt,conv128_down:nn,conv128_1:rn,conv128_2:on,conv256_down:an,conv256_1:sn,conv256_2:ln,conv256_down_out:cn,fc:un};return disposeUnusedWeightTensors(m,y),{params:hn,paramMappings:y}}function residual(m,y){var v=conv(m,y.conv1);return v=convNoRelu(v,y.conv2),v=rc(v,m),v=Bl(v),v}function residualDown(m,y){var v=convDown(m,y.conv1);v=convNoRelu(v,y.conv2);var $e=fl(m,2,2,"valid"),je=Gn($e.shape),Ge=$e.shape[3]!==v.shape[3],Ye=$e.shape[1]!==v.shape[1]||$e.shape[2]!==v.shape[2];if(Ye){var qe=__spreadArrays(v.shape);qe[1]=1;var Ke=Gn(qe);v=Yn([v,Ke],1);var Qe=__spreadArrays(v.shape);Qe[2]=1;var Je=Gn(Qe);v=Yn([v,Je],2)}return $e=Ge?Yn([$e,je],3):$e,v=rc($e,v),v=Bl(v),v}var FaceRecognitionNet=function(m){__extends(y,m);function y(){return m.call(this,"FaceRecognitionNet")||this}return y.prototype.forwardInput=function(v){var $e=this.params;if(!$e)throw new Error("FaceRecognitionNet - load model before inference");return Ze(function(){var je=v.toBatchTensor(150,!0).toFloat(),Ge=[122.782,117.001,104.298],Ye=normalize$1(je,Ge).div(On(256)),qe=convDown(Ye,$e.conv32_down);qe=hl(qe,3,2,"valid"),qe=residual(qe,$e.conv32_1),qe=residual(qe,$e.conv32_2),qe=residual(qe,$e.conv32_3),qe=residualDown(qe,$e.conv64_down),qe=residual(qe,$e.conv64_1),qe=residual(qe,$e.conv64_2),qe=residual(qe,$e.conv64_3),qe=residualDown(qe,$e.conv128_down),qe=residual(qe,$e.conv128_1),qe=residual(qe,$e.conv128_2),qe=residualDown(qe,$e.conv256_down),qe=residual(qe,$e.conv256_1),qe=residual(qe,$e.conv256_2),qe=residualDown(qe,$e.conv256_down_out);var Ke=qe.mean([1,2]),Qe=el(Ke,$e.fc);return Qe})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.computeFaceDescriptor=function(v){return __awaiter(this,void 0,void 0,function(){var $e,je,Ge,Ye=this;return __generator(this,function(qe){switch(qe.label){case 0:return[4,toNetInput(v)];case 1:return $e=qe.sent(),je=Ze(function(){return Ur(Ye.forwardInput($e))}),[4,Promise.all(je.map(function(Ke){return Ke.data()}))];case 2:return Ge=qe.sent(),je.forEach(function(Ke){return Ke.dispose()}),[2,$e.isBatchInput?Ge:Ge[0]]}})})},y.prototype.getDefaultModelName=function(){return"face_recognition_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap$3(v)},y.prototype.extractParams=function(v){return extractParams$3(v)},y}(NeuralNetwork);function extendWithFaceDescriptor(m,y){var v={descriptor:y};return Object.assign({},m,v)}function extendWithAge(m,y){var v={age:y};return Object.assign({},m,v)}function extendWithGender(m,y,v){var $e={gender:y,genderProbability:v};return Object.assign({},m,$e)}var MtcnnOptions=function(){function m(y){var v=y===void 0?{}:y,$e=v.minFaceSize,je=v.scaleFactor,Ge=v.maxNumScales,Ye=v.scoreThresholds,qe=v.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=$e||20,this._scaleFactor=je||.709,this._maxNumScales=Ge||10,this._scoreThresholds=Ye||[.6,.7,.7],this._scaleSteps=qe,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(Ke){return typeof Ke!="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(Ke){return typeof Ke!="number"})))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(m.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),m}();function extractorsFactory$5(m,y){function v(Ke,Qe){var Je=Ln(m(9*Ke),[3,3,Ke,1]),st=Mn(m(Ke)),Mt=Mn(m(Ke)),nn=Mn(m(Ke)),rn=Mn(m(Ke));return y.push({paramPath:Qe+"/filters"},{paramPath:Qe+"/batch_norm_scale"},{paramPath:Qe+"/batch_norm_offset"},{paramPath:Qe+"/batch_norm_mean"},{paramPath:Qe+"/batch_norm_variance"}),{filters:Je,batch_norm_scale:st,batch_norm_offset:Mt,batch_norm_mean:nn,batch_norm_variance:rn}}function $e(Ke,Qe,Je,st,Mt){var nn=Ln(m(Ke*Qe*Je*Je),[Je,Je,Ke,Qe]),rn=Mn(m(Qe));return y.push({paramPath:st+"/filters"},{paramPath:st+"/"+(Mt?"batch_norm_offset":"bias")}),{filters:nn,bias:rn}}function je(Ke,Qe,Je,st){var Mt=$e(Ke,Qe,Je,st,!0),nn=Mt.filters,rn=Mt.bias;return{filters:nn,batch_norm_offset:rn}}function Ge(Ke,Qe,Je){var st=v(Ke,Je+"/depthwise_conv"),Mt=je(Ke,Qe,1,Je+"/pointwise_conv");return{depthwise_conv:st,pointwise_conv:Mt}}function Ye(){var Ke=je(3,32,3,"mobilenetv1/conv_0"),Qe=Ge(32,64,"mobilenetv1/conv_1"),Je=Ge(64,128,"mobilenetv1/conv_2"),st=Ge(128,128,"mobilenetv1/conv_3"),Mt=Ge(128,256,"mobilenetv1/conv_4"),nn=Ge(256,256,"mobilenetv1/conv_5"),rn=Ge(256,512,"mobilenetv1/conv_6"),on=Ge(512,512,"mobilenetv1/conv_7"),an=Ge(512,512,"mobilenetv1/conv_8"),sn=Ge(512,512,"mobilenetv1/conv_9"),ln=Ge(512,512,"mobilenetv1/conv_10"),cn=Ge(512,512,"mobilenetv1/conv_11"),un=Ge(512,1024,"mobilenetv1/conv_12"),hn=Ge(1024,1024,"mobilenetv1/conv_13");return{conv_0:Ke,conv_1:Qe,conv_2:Je,conv_3:st,conv_4:Mt,conv_5:nn,conv_6:rn,conv_7:on,conv_8:an,conv_9:sn,conv_10:ln,conv_11:cn,conv_12:un,conv_13:hn}}function qe(){var Ke=je(1024,256,1,"prediction_layer/conv_0"),Qe=je(256,512,3,"prediction_layer/conv_1"),Je=je(512,128,1,"prediction_layer/conv_2"),st=je(128,256,3,"prediction_layer/conv_3"),Mt=je(256,128,1,"prediction_layer/conv_4"),nn=je(128,256,3,"prediction_layer/conv_5"),rn=je(256,64,1,"prediction_layer/conv_6"),on=je(64,128,3,"prediction_layer/conv_7"),an=$e(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),sn=$e(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),ln=$e(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),cn=$e(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),un=$e(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),hn=$e(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),fn=$e(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),to=$e(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),Mi=$e(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),Uo=$e(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),fo=$e(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),dd=$e(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),mo={box_encoding_predictor:an,class_predictor:sn},ho={box_encoding_predictor:ln,class_predictor:cn},Xr={box_encoding_predictor:un,class_predictor:hn},lo={box_encoding_predictor:fn,class_predictor:to},co={box_encoding_predictor:Mi,class_predictor:Uo},uo={box_encoding_predictor:fo,class_predictor:dd};return{conv_0:Ke,conv_1:Qe,conv_2:Je,conv_3:st,conv_4:Mt,conv_5:nn,conv_6:rn,conv_7:on,box_predictor_0:mo,box_predictor_1:ho,box_predictor_2:Xr,box_predictor_3:lo,box_predictor_4:co,box_predictor_5:uo}}return{extractMobilenetV1Params:Ye,extractPredictionLayerParams:qe}}function extractParams$2(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,je=v.getRemainingWeights,Ge=extractorsFactory$5($e,y),Ye=Ge.extractMobilenetV1Params,qe=Ge.extractPredictionLayerParams,Ke=Ye(),Qe=qe(),Je=Pn($e(5118*4),[1,5118,4]),st={extra_dim:Je};if(y.push({paramPath:"output_layer/extra_dim"}),je().length!==0)throw new Error("weights remaing after extract: "+je().length);return{params:{mobilenetv1:Ke,prediction_layer:Qe,output_layer:st},paramMappings:y}}function extractorsFactory$4(m,y){var v=extractWeightEntryFactory(m,y);function $e(Qe,Je,st){var Mt=v(Qe+"/Conv2d_"+Je+"_pointwise/weights",4,st+"/filters"),nn=v(Qe+"/Conv2d_"+Je+"_pointwise/convolution_bn_offset",1,st+"/batch_norm_offset");return{filters:Mt,batch_norm_offset:nn}}function je(Qe){var Je="mobilenetv1/conv_"+Qe,st="MobilenetV1/Conv2d_"+Qe+"_depthwise",Mt=Je+"/depthwise_conv",nn=Je+"/pointwise_conv",rn=v(st+"/depthwise_weights",4,Mt+"/filters"),on=v(st+"/BatchNorm/gamma",1,Mt+"/batch_norm_scale"),an=v(st+"/BatchNorm/beta",1,Mt+"/batch_norm_offset"),sn=v(st+"/BatchNorm/moving_mean",1,Mt+"/batch_norm_mean"),ln=v(st+"/BatchNorm/moving_variance",1,Mt+"/batch_norm_variance");return{depthwise_conv:{filters:rn,batch_norm_scale:on,batch_norm_offset:an,batch_norm_mean:sn,batch_norm_variance:ln},pointwise_conv:$e("MobilenetV1",Qe,nn)}}function Ge(){return{conv_0:$e("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:je(1),conv_2:je(2),conv_3:je(3),conv_4:je(4),conv_5:je(5),conv_6:je(6),conv_7:je(7),conv_8:je(8),conv_9:je(9),conv_10:je(10),conv_11:je(11),conv_12:je(12),conv_13:je(13)}}function Ye(Qe,Je){var st=v(Qe+"/weights",4,Je+"/filters"),Mt=v(Qe+"/biases",1,Je+"/bias");return{filters:st,bias:Mt}}function qe(Qe){var Je=Ye("Prediction/BoxPredictor_"+Qe+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+Qe+"/box_encoding_predictor"),st=Ye("Prediction/BoxPredictor_"+Qe+"/ClassPredictor","prediction_layer/box_predictor_"+Qe+"/class_predictor");return{box_encoding_predictor:Je,class_predictor:st}}function Ke(){return{conv_0:$e("Prediction",0,"prediction_layer/conv_0"),conv_1:$e("Prediction",1,"prediction_layer/conv_1"),conv_2:$e("Prediction",2,"prediction_layer/conv_2"),conv_3:$e("Prediction",3,"prediction_layer/conv_3"),conv_4:$e("Prediction",4,"prediction_layer/conv_4"),conv_5:$e("Prediction",5,"prediction_layer/conv_5"),conv_6:$e("Prediction",6,"prediction_layer/conv_6"),conv_7:$e("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:qe(0),box_predictor_1:qe(1),box_predictor_2:qe(2),box_predictor_3:qe(3),box_predictor_4:qe(4),box_predictor_5:qe(5)}}return{extractMobilenetV1Params:Ge,extractPredictionLayerParams:Ke}}function extractParamsFromWeigthMap$2(m){var y=[],v=extractorsFactory$4(m,y),$e=v.extractMobilenetV1Params,je=v.extractPredictionLayerParams,Ge=m["Output/extra_dim"];if(y.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!isTensor3D(Ge))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+Ge);var Ye={mobilenetv1:$e(),prediction_layer:je(),output_layer:{extra_dim:Ge}};return disposeUnusedWeightTensors(m,y),{params:Ye,paramMappings:y}}function pointwiseConvLayer(m,y,v){return Ze(function(){var $e=qc(m,y.filters,v,"same");return $e=rc($e,y.batch_norm_offset),hu($e,0,6)})}var epsilon=.0010000000474974513;function depthwiseConvLayer(m,y,v){return Ze(function(){var $e=Yc(m,y.filters,v,"same");return $e=ju($e,y.batch_norm_mean,y.batch_norm_variance,y.batch_norm_offset,y.batch_norm_scale,epsilon),hu($e,0,6)})}function getStridesForLayerIdx(m){return[2,4,6,12].some(function(y){return y===m})?[2,2]:[1,1]}function mobileNetV1(m,y){return Ze(function(){var v=null,$e=pointwiseConvLayer(m,y.conv_0,[2,2]),je=[y.conv_1,y.conv_2,y.conv_3,y.conv_4,y.conv_5,y.conv_6,y.conv_7,y.conv_8,y.conv_9,y.conv_10,y.conv_11,y.conv_12,y.conv_13];if(je.forEach(function(Ge,Ye){var qe=Ye+1,Ke=getStridesForLayerIdx(qe);$e=depthwiseConvLayer($e,Ge.depthwise_conv,Ke),$e=pointwiseConvLayer($e,Ge.pointwise_conv,[1,1]),qe===11&&(v=$e)}),v===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:$e,conv11:v}})}function nonMaxSuppression(m,y,v,$e,je){var Ge=m.shape[0],Ye=Math.min(v,Ge),qe=y.map(function(Je,st){return{score:Je,boxIndex:st}}).filter(function(Je){return Je.score>je}).sort(function(Je,st){return st.score-Je.score}),Ke=function(Je){return Je<=$e?1:0},Qe=[];return qe.forEach(function(Je){if(!(Qe.length>=Ye)){for(var st=Je.score,Mt=Qe.length-1;Mt>=0;--Mt){var nn=IOU(m,Je.boxIndex,Qe[Mt]);if(nn!==0&&(Je.score*=Ke(nn),Je.score<=je))break}st===Je.score&&Qe.push(Je.boxIndex)}}),Qe}function IOU(m,y,v){var $e=m.arraySync(),je=Math.min($e[y][0],$e[y][2]),Ge=Math.min($e[y][1],$e[y][3]),Ye=Math.max($e[y][0],$e[y][2]),qe=Math.max($e[y][1],$e[y][3]),Ke=Math.min($e[v][0],$e[v][2]),Qe=Math.min($e[v][1],$e[v][3]),Je=Math.max($e[v][0],$e[v][2]),st=Math.max($e[v][1],$e[v][3]),Mt=(Ye-je)*(qe-Ge),nn=(Je-Ke)*(st-Qe);if(Mt<=0||nn<=0)return 0;var rn=Math.max(je,Ke),on=Math.max(Ge,Qe),an=Math.min(Ye,Je),sn=Math.min(qe,st),ln=Math.max(an-rn,0)*Math.max(sn-on,0);return ln/(Mt+nn-ln)}function getCenterCoordinatesAndSizesLayer(m){var y=Ur(Wl(m,[1,0])),v=[Cc(y[2],y[0]),Cc(y[3],y[1])],$e=[rc(y[0],sc(v[0],On(2))),rc(y[1],sc(v[1],On(2)))];return{sizes:v,centers:$e}}function decodeBoxesLayer(m,y){var v=getCenterCoordinatesAndSizesLayer(m),$e=v.sizes,je=v.centers,Ge=Ur(Wl(y,[1,0])),Ye=sc(gc(vu(sc(Ge[2],On(5))),$e[0]),On(2)),qe=rc(gc(sc(Ge[0],On(10)),$e[0]),je[0]),Ke=sc(gc(vu(sc(Ge[3],On(5))),$e[1]),On(2)),Qe=rc(gc(sc(Ge[1],On(10)),$e[1]),je[1]);return Wl(Pr([Cc(qe,Ye),Cc(Qe,Ke),rc(qe,Ye),rc(Qe,Ke)]),[1,0])}function outputLayer(m,y,v){return Ze(function(){var $e=m.shape[0],je=decodeBoxesLayer(Or(Lr(v.extra_dim,[$e,1,1]),[-1,4]),Or(m,[-1,4]));je=Or(je,[$e,je.shape[0]/$e,4]);var Ge=Iu(ml(y,[0,0,1],[-1,-1,-1])),Ye=ml(Ge,[0,0,0],[-1,-1,1]);Ye=Or(Ye,[$e,Ye.shape[1]]);var qe=Ur(je),Ke=Ur(Ye);return{boxes:qe,scores:Ke}})}function boxPredictionLayer(m,y){return Ze(function(){var v=m.shape[0],$e=Or(convLayer$1(m,y.box_encoding_predictor),[v,-1,1,4]),je=Or(convLayer$1(m,y.class_predictor),[v,-1,3]);return{boxPredictionEncoding:$e,classPrediction:je}})}function predictionLayer(m,y,v){return Ze(function(){var $e=pointwiseConvLayer(m,v.conv_0,[1,1]),je=pointwiseConvLayer($e,v.conv_1,[2,2]),Ge=pointwiseConvLayer(je,v.conv_2,[1,1]),Ye=pointwiseConvLayer(Ge,v.conv_3,[2,2]),qe=pointwiseConvLayer(Ye,v.conv_4,[1,1]),Ke=pointwiseConvLayer(qe,v.conv_5,[2,2]),Qe=pointwiseConvLayer(Ke,v.conv_6,[1,1]),Je=pointwiseConvLayer(Qe,v.conv_7,[2,2]),st=boxPredictionLayer(y,v.box_predictor_0),Mt=boxPredictionLayer(m,v.box_predictor_1),nn=boxPredictionLayer(je,v.box_predictor_2),rn=boxPredictionLayer(Ye,v.box_predictor_3),on=boxPredictionLayer(Ke,v.box_predictor_4),an=boxPredictionLayer(Je,v.box_predictor_5),sn=Yn([st.boxPredictionEncoding,Mt.boxPredictionEncoding,nn.boxPredictionEncoding,rn.boxPredictionEncoding,on.boxPredictionEncoding,an.boxPredictionEncoding],1),ln=Yn([st.classPrediction,Mt.classPrediction,nn.classPrediction,rn.classPrediction,on.classPrediction,an.classPrediction],1);return{boxPredictions:sn,classPredictions:ln}})}var SsdMobilenetv1Options=function(){function m(y){var v=y===void 0?{}:y,$e=v.minConfidence,je=v.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=$e||.5,this._maxResults=je||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(m.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),m}(),SsdMobilenetv1=function(m){__extends(y,m);function y(){return m.call(this,"SsdMobilenetv1")||this}return y.prototype.forwardInput=function(v){var $e=this.params;if(!$e)throw new Error("SsdMobilenetv1 - load model before inference");return Ze(function(){var je=v.toBatchTensor(512,!1).toFloat(),Ge=Cc(gc(je,On(.007843137718737125)),On(1)),Ye=mobileNetV1(Ge,$e.mobilenetv1),qe=predictionLayer(Ye.out,Ye.conv11,$e.prediction_layer),Ke=qe.boxPredictions,Qe=qe.classPredictions;return outputLayer(Ke,Qe,$e.output_layer)})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(je){switch(je.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[je.sent()])]}})})},y.prototype.locateFaces=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var je,Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln,cn,un,hn,fn,to,Mi;return __generator(this,function(Uo){switch(Uo.label){case 0:return je=new SsdMobilenetv1Options($e),Ge=je.maxResults,Ye=je.minConfidence,[4,toNetInput(v)];case 1:for(qe=Uo.sent(),Ke=this.forwardInput(qe),Qe=Ke.boxes,Je=Ke.scores,st=Qe[0],Mt=Je[0],nn=1;nn<Qe.length;nn++)Qe[nn].dispose(),Je[nn].dispose();return an=(on=Array).from,[4,Mt.data()];case 2:return rn=an.apply(on,[Uo.sent()]),sn=.5,ln=nonMaxSuppression(st,rn,Ge,sn,Ye),cn=qe.getReshapedInputDimensions(0),un=qe.inputSize,hn=un/cn.width,fn=un/cn.height,to=st.arraySync(),Mi=ln.map(function(fo){var dd=[Math.max(0,to[fo][0]),Math.min(1,to[fo][2])].map(function(uo){return uo*fn}),mo=dd[0],ho=dd[1],Xr=[Math.max(0,to[fo][1]),Math.min(1,to[fo][3])].map(function(uo){return uo*hn}),lo=Xr[0],co=Xr[1];return new FaceDetection(rn[fo],new Rect(lo,mo,co-lo,ho-mo),{height:qe.getInputHeight(0),width:qe.getInputWidth(0)})}),st.dispose(),Mt.dispose(),[2,Mi]}})})},y.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap$2(v)},y.prototype.extractParams=function(v){return extractParams$2(v)},y}(NeuralNetwork);(function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y})(SsdMobilenetv1);var IOU_THRESHOLD$1=.4,BOX_ANCHORS$1=[new Point(.738768,.874946),new Point(2.42204,2.65704),new Point(4.30971,7.04493),new Point(10.246,4.59428),new Point(12.6868,11.8741)],BOX_ANCHORS_SEPARABLE=[new Point(1.603231,2.094468),new Point(6.041143,7.080126),new Point(2.882459,3.518061),new Point(4.266906,5.178857),new Point(9.041765,10.66308)],MEAN_RGB_SEPARABLE=[117.001,114.697,97.404],DEFAULT_MODEL_NAME="tiny_yolov2_model",DEFAULT_MODEL_NAME_SEPARABLE_CONV="tiny_yolov2_separable_conv_model",isNumber=function(m){return typeof m=="number"};function validateConfig(m){if(!m)throw new Error("invalid config: "+m);if(typeof m.withSeparableConvs!="boolean")throw new Error("config.withSeparableConvs has to be a boolean, have: "+m.withSeparableConvs);if(!isNumber(m.iouThreshold)||m.iouThreshold<0||m.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+m.iouThreshold);if(!Array.isArray(m.classes)||!m.classes.length||!m.classes.every(function(y){return typeof y=="string"}))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(m.classes));if(!Array.isArray(m.anchors)||!m.anchors.length||!m.anchors.map(function(y){return y||{}}).every(function(y){return isNumber(y.x)&&isNumber(y.y)}))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(m.anchors));if(m.meanRgb&&(!Array.isArray(m.meanRgb)||m.meanRgb.length!==3||!m.meanRgb.every(isNumber)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(m.meanRgb))}function leaky(m){return Ze(function(){var y=gc(m,On(.10000000149011612));return rc(Bl(Cc(m,y)),y)})}function convWithBatchNorm(m,y){return Ze(function(){var v=Ir(m,[[0,0],[1,1],[1,1],[0,0]]);return v=qc(v,y.conv.filters,[1,1],"valid"),v=Cc(v,y.bn.sub),v=gc(v,y.bn.truediv),v=rc(v,y.conv.bias),leaky(v)})}function depthwiseSeparableConv(m,y){return Ze(function(){var v=Ir(m,[[0,0],[1,1],[1,1],[0,0]]);return v=Jc(v,y.depthwise_filter,y.pointwise_filter,[1,1],"valid"),v=rc(v,y.bias),leaky(v)})}function extractorsFactory$3(m,y){var v=extractConvParamsFactory(m,y);function $e(Ye,qe){var Ke=Mn(m(Ye)),Qe=Mn(m(Ye));return y.push({paramPath:qe+"/sub"},{paramPath:qe+"/truediv"}),{sub:Ke,truediv:Qe}}function je(Ye,qe,Ke){var Qe=v(Ye,qe,3,Ke+"/conv"),Je=$e(qe,Ke+"/bn");return{conv:Qe,bn:Je}}var Ge=extractSeparableConvParamsFactory(m,y);return{extractConvParams:v,extractConvWithBatchNormParams:je,extractSeparableConvParams:Ge}}function extractParams$1(m,y,v,$e){var je=extractWeightsFactory(m),Ge=je.extractWeights,Ye=je.getRemainingWeights,qe=[],Ke=extractorsFactory$3(Ge,qe),Qe=Ke.extractConvParams,Je=Ke.extractConvWithBatchNormParams,st=Ke.extractSeparableConvParams,Mt;if(y.withSeparableConvs){var nn=$e[0],rn=$e[1],on=$e[2],an=$e[3],sn=$e[4],ln=$e[5],cn=$e[6],un=$e[7],hn=$e[8],fn=y.isFirstLayerConv2d?Qe(nn,rn,3,"conv0"):st(nn,rn,"conv0"),to=st(rn,on,"conv1"),Mi=st(on,an,"conv2"),Uo=st(an,sn,"conv3"),fo=st(sn,ln,"conv4"),dd=st(ln,cn,"conv5"),mo=un?st(cn,un,"conv6"):void 0,ho=hn?st(un,hn,"conv7"):void 0,Xr=Qe(hn||un||cn,5*v,1,"conv8");Mt={conv0:fn,conv1:to,conv2:Mi,conv3:Uo,conv4:fo,conv5:dd,conv6:mo,conv7:ho,conv8:Xr}}else{var nn=$e[0],rn=$e[1],on=$e[2],an=$e[3],sn=$e[4],ln=$e[5],cn=$e[6],un=$e[7],hn=$e[8],fn=Je(nn,rn,"conv0"),to=Je(rn,on,"conv1"),Mi=Je(on,an,"conv2"),Uo=Je(an,sn,"conv3"),fo=Je(sn,ln,"conv4"),dd=Je(ln,cn,"conv5"),mo=Je(cn,un,"conv6"),ho=Je(un,hn,"conv7"),Xr=Qe(hn,5*v,1,"conv8");Mt={conv0:fn,conv1:to,conv2:Mi,conv3:Uo,conv4:fo,conv5:dd,conv6:mo,conv7:ho,conv8:Xr}}if(Ye().length!==0)throw new Error("weights remaing after extract: "+Ye().length);return{params:Mt,paramMappings:qe}}function extractorsFactory$2(m,y){var v=extractWeightEntryFactory(m,y);function $e(qe){var Ke=v(qe+"/sub",1),Qe=v(qe+"/truediv",1);return{sub:Ke,truediv:Qe}}function je(qe){var Ke=v(qe+"/filters",4),Qe=v(qe+"/bias",1);return{filters:Ke,bias:Qe}}function Ge(qe){var Ke=je(qe+"/conv"),Qe=$e(qe+"/bn");return{conv:Ke,bn:Qe}}var Ye=loadSeparableConvParamsFactory(v);return{extractConvParams:je,extractConvWithBatchNormParams:Ge,extractSeparableConvParams:Ye}}function extractParamsFromWeigthMap$1(m,y){var v=[],$e=extractorsFactory$2(m,v),je=$e.extractConvParams,Ge=$e.extractConvWithBatchNormParams,Ye=$e.extractSeparableConvParams,qe;if(y.withSeparableConvs){var Ke=y.filterSizes&&y.filterSizes.length||9;qe={conv0:y.isFirstLayerConv2d?je("conv0"):Ye("conv0"),conv1:Ye("conv1"),conv2:Ye("conv2"),conv3:Ye("conv3"),conv4:Ye("conv4"),conv5:Ye("conv5"),conv6:Ke>7?Ye("conv6"):void 0,conv7:Ke>8?Ye("conv7"):void 0,conv8:je("conv8")}}else qe={conv0:Ge("conv0"),conv1:Ge("conv1"),conv2:Ge("conv2"),conv3:Ge("conv3"),conv4:Ge("conv4"),conv5:Ge("conv5"),conv6:Ge("conv6"),conv7:Ge("conv7"),conv8:je("conv8")};return disposeUnusedWeightTensors(m,v),{params:qe,paramMappings:v}}var TinyYolov2SizeType;(function(m){m[m.XS=224]="XS",m[m.SM=320]="SM",m[m.MD=416]="MD",m[m.LG=608]="LG"})(TinyYolov2SizeType||(TinyYolov2SizeType={}));var TinyYolov2Options=function(){function m(y){var v=y===void 0?{}:y,$e=v.inputSize,je=v.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=$e||416,this._scoreThreshold=je||.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(m.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),m}(),TinyYolov2Base=function(m){__extends(y,m);function y(v){var $e=m.call(this,"TinyYolov2")||this;return validateConfig(v),$e._config=v,$e}return Object.defineProperty(y.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),y.prototype.runTinyYolov2=function(v,$e){var je=convWithBatchNorm(v,$e.conv0);return je=hl(je,[2,2],[2,2],"same"),je=convWithBatchNorm(je,$e.conv1),je=hl(je,[2,2],[2,2],"same"),je=convWithBatchNorm(je,$e.conv2),je=hl(je,[2,2],[2,2],"same"),je=convWithBatchNorm(je,$e.conv3),je=hl(je,[2,2],[2,2],"same"),je=convWithBatchNorm(je,$e.conv4),je=hl(je,[2,2],[2,2],"same"),je=convWithBatchNorm(je,$e.conv5),je=hl(je,[2,2],[1,1],"same"),je=convWithBatchNorm(je,$e.conv6),je=convWithBatchNorm(je,$e.conv7),convLayer$1(je,$e.conv8,"valid",!1)},y.prototype.runMobilenet=function(v,$e){var je=this.config.isFirstLayerConv2d?leaky(convLayer$1(v,$e.conv0,"valid",!1)):depthwiseSeparableConv(v,$e.conv0);return je=hl(je,[2,2],[2,2],"same"),je=depthwiseSeparableConv(je,$e.conv1),je=hl(je,[2,2],[2,2],"same"),je=depthwiseSeparableConv(je,$e.conv2),je=hl(je,[2,2],[2,2],"same"),je=depthwiseSeparableConv(je,$e.conv3),je=hl(je,[2,2],[2,2],"same"),je=depthwiseSeparableConv(je,$e.conv4),je=hl(je,[2,2],[2,2],"same"),je=depthwiseSeparableConv(je,$e.conv5),je=hl(je,[2,2],[1,1],"same"),je=$e.conv6?depthwiseSeparableConv(je,$e.conv6):je,je=$e.conv7?depthwiseSeparableConv(je,$e.conv7):je,convLayer$1(je,$e.conv8,"valid",!1)},y.prototype.forwardInput=function(v,$e){var je=this,Ge=this.params;if(!Ge)throw new Error("TinyYolov2 - load model before inference");return Ze(function(){var Ye=v.toBatchTensor($e,!1).toFloat();return Ye=je.config.meanRgb?normalize$1(Ye,je.config.meanRgb):Ye,Ye=Ye.div(On(256)),je.config.withSeparableConvs?je.runMobilenet(Ye,Ge):je.runTinyYolov2(Ye,Ge)})},y.prototype.forward=function(v,$e){return __awaiter(this,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return je=this.forwardInput,[4,toNetInput(v)];case 1:return[4,je.apply(this,[Ge.sent(),$e])];case 2:return[2,Ge.sent()]}})})},y.prototype.detect=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var je,Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln=this;return __generator(this,function(cn){switch(cn.label){case 0:return je=new TinyYolov2Options($e),Ge=je.inputSize,Ye=je.scoreThreshold,[4,toNetInput(v)];case 1:return qe=cn.sent(),[4,this.forwardInput(qe,Ge)];case 2:return Ke=cn.sent(),Qe=Ze(function(){return Ur(Ke)[0].expandDims()}),Je={width:qe.getInputWidth(0),height:qe.getInputHeight(0)},[4,this.extractBoxes(Qe,qe.getReshapedInputDimensions(0),Ye)];case 3:return st=cn.sent(),Ke.dispose(),Qe.dispose(),Mt=st.map(function(un){return un.box}),nn=st.map(function(un){return un.score}),rn=st.map(function(un){return un.classScore}),on=st.map(function(un){return ln.config.classes[un.label]}),an=nonMaxSuppression$1(Mt.map(function(un){return un.rescale(Ge)}),nn,this.config.iouThreshold,!0),sn=an.map(function(un){return new ObjectDetection(nn[un],rn[un],on[un],Mt[un],Je)}),[2,sn]}})})},y.prototype.getDefaultModelName=function(){return""},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap$1(v,this.config)},y.prototype.extractParams=function(v){var $e=this.config.filterSizes||y.DEFAULT_FILTER_SIZES,je=$e?$e.length:void 0;if(je!==7&&je!==8&&je!==9)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+je+" filterSizes in config");return extractParams$1(v,this.config,this.boxEncodingSize,$e)},y.prototype.extractBoxes=function(v,$e,je){return __awaiter(this,void 0,void 0,function(){var Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln,cn,un,hn,fn,to,Mi,Uo,fo,dd,mo,ho,Xr,lo,co,uo,od=this;return __generator(this,function(rd){switch(rd.label){case 0:return Ge=$e.width,Ye=$e.height,qe=Math.max(Ge,Ye),Ke=qe/Ge,Qe=qe/Ye,Je=v.shape[1],st=this.config.anchors.length,Mt=Ze(function(){var ld=v.reshape([Je,Je,st,od.boxEncodingSize]),hd=ld.slice([0,0,0,0],[Je,Je,st,4]),pd=ld.slice([0,0,0,4],[Je,Je,st,1]),fd=od.withClassScores?go(ld.slice([0,0,0,5],[Je,Je,st,od.config.classes.length]),3):On(0);return[hd,pd,fd]}),nn=Mt[0],rn=Mt[1],on=Mt[2],an=[],[4,rn.array()];case 1:return sn=rd.sent(),[4,nn.array()];case 2:ln=rd.sent(),cn=0,rd.label=3;case 3:if(!(cn<Je))return[3,12];un=0,rd.label=4;case 4:if(!(un<Je))return[3,11];hn=0,rd.label=5;case 5:return hn<st?(fn=sigmoid(sn[cn][un][hn][0]),!je||fn>je?(to=(un+sigmoid(ln[cn][un][hn][0]))/Je*Ke,Mi=(cn+sigmoid(ln[cn][un][hn][1]))/Je*Qe,Uo=Math.exp(ln[cn][un][hn][2])*this.config.anchors[hn].x/Je*Ke,fo=Math.exp(ln[cn][un][hn][3])*this.config.anchors[hn].y/Je*Qe,dd=to-Uo/2,mo=Mi-fo/2,ho={row:cn,col:un,anchor:hn},this.withClassScores?[4,this.extractPredictedClass(on,ho)]:[3,7]):[3,9]):[3,10];case 6:return uo=rd.sent(),[3,8];case 7:uo={classScore:1,label:0},rd.label=8;case 8:Xr=uo,lo=Xr.classScore,co=Xr.label,an.push(__assign({box:new BoundingBox(dd,mo,dd+Uo,mo+fo),score:fn,classScore:fn*lo,label:co},ho)),rd.label=9;case 9:return hn++,[3,5];case 10:return un++,[3,4];case 11:return cn++,[3,3];case 12:return nn.dispose(),rn.dispose(),on.dispose(),[2,an]}})})},y.prototype.extractPredictedClass=function(v,$e){return __awaiter(this,void 0,void 0,function(){var je,Ge,Ye,qe;return __generator(this,function(Ke){switch(Ke.label){case 0:return je=$e.row,Ge=$e.col,Ye=$e.anchor,[4,v.array()];case 1:return qe=Ke.sent(),[2,Array(this.config.classes.length).fill(0).map(function(Qe,Je){return qe[je][Ge][Ye][Je]}).map(function(Qe,Je){return{classScore:Qe,label:Je}}).reduce(function(Qe,Je){return Qe.classScore>Je.classScore?Qe:Je})]}})})},y.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],y}(NeuralNetwork),TinyYolov2=function(m){__extends(y,m);function y(v){v===void 0&&(v=!0);var $e=this,je=Object.assign({},{withSeparableConvs:v,iouThreshold:IOU_THRESHOLD$1,classes:["face"]},v?{anchors:BOX_ANCHORS_SEPARABLE,meanRgb:MEAN_RGB_SEPARABLE}:{anchors:BOX_ANCHORS$1,withClassScores:!0});return $e=m.call(this,je)||this,$e}return Object.defineProperty(y.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),y.prototype.locateFaces=function(v,$e){return __awaiter(this,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.detect(v,$e)];case 1:return je=Ge.sent(),[2,je.map(function(Ye){return new FaceDetection(Ye.score,Ye.relativeBox,{width:Ye.imageWidth,height:Ye.imageHeight})})]}})})},y.prototype.getDefaultModelName=function(){return this.withSeparableConvs?DEFAULT_MODEL_NAME_SEPARABLE_CONV:DEFAULT_MODEL_NAME},y.prototype.extractParamsFromWeigthMap=function(v){return m.prototype.extractParamsFromWeigthMap.call(this,v)},y}(TinyYolov2Base),TinyFaceDetectorOptions=function(m){__extends(y,m);function y(){var v=m!==null&&m.apply(this,arguments)||this;return v._name="TinyFaceDetectorOptions",v}return y}(TinyYolov2Options),ComposableTask=function(){function m(){}return m.prototype.then=function(y){return __awaiter(this,void 0,void 0,function(){var v;return __generator(this,function($e){switch($e.label){case 0:return v=y,[4,this.run()];case 1:return[2,v.apply(void 0,[$e.sent()])]}})})},m.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(y){throw new Error("ComposableTask - run is not implemented")})})},m}();function extractAllFacesAndComputeResults(m,y,v,$e,je){return je===void 0&&(je=function(Ge){var Ye=Ge.alignedRect;return Ye}),__awaiter(this,void 0,void 0,function(){var Ge,Ye,qe,Ke,Qe;return __generator(this,function(Je){switch(Je.label){case 0:return Ge=m.map(function(st){return isWithFaceLandmarks(st)?je(st):st.detection}),qe=$e,qe?[3,5]:y instanceof wt?[4,extractFaceTensors(y,Ge)]:[3,2];case 1:return Ke=Je.sent(),[3,4];case 2:return[4,extractFaces(y,Ge)];case 3:Ke=Je.sent(),Je.label=4;case 4:qe=Ke,Je.label=5;case 5:return Ye=qe,[4,v(Ye)];case 6:return Qe=Je.sent(),Ye.forEach(function(st){return st instanceof wt&&st.dispose()}),[2,Qe]}})})}function extractSingleFaceAndComputeResult(m,y,v,$e,je){return __awaiter(this,void 0,void 0,function(){var Ge=this;return __generator(this,function(Ye){return[2,extractAllFacesAndComputeResults([m],y,function(qe){return __awaiter(Ge,void 0,void 0,function(){return __generator(this,function(Ke){return[2,v(qe[0])]})})},$e,je)]})})}function bgrToRgbTensor(m){return Ze(function(){return Pr(Ur(m,3).reverse(),3)})}var CELL_STRIDE=2,CELL_SIZE=12;function extractorsFactory$1(m,y){var v=extractConvParamsFactory(m,y),$e=extractFCParamsFactory(m,y);function je(Qe,Je){var st=Mn(m(Qe));return y.push({paramPath:Je}),st}function Ge(Qe,Je,st){st===void 0&&(st=!1);var Mt=v(Qe[0],Qe[1],3,Je+"/conv1"),nn=je(Qe[1],Je+"/prelu1_alpha"),rn=v(Qe[1],Qe[2],3,Je+"/conv2"),on=je(Qe[2],Je+"/prelu2_alpha"),an=v(Qe[2],Qe[3],st?2:3,Je+"/conv3"),sn=je(Qe[3],Je+"/prelu3_alpha");return{conv1:Mt,prelu1_alpha:nn,conv2:rn,prelu2_alpha:on,conv3:an,prelu3_alpha:sn}}function Ye(){var Qe=Ge([3,10,16,32],"pnet"),Je=v(32,2,1,"pnet/conv4_1"),st=v(32,4,1,"pnet/conv4_2");return __assign(__assign({},Qe),{conv4_1:Je,conv4_2:st})}function qe(){var Qe=Ge([3,28,48,64],"rnet",!0),Je=$e(576,128,"rnet/fc1"),st=je(128,"rnet/prelu4_alpha"),Mt=$e(128,2,"rnet/fc2_1"),nn=$e(128,4,"rnet/fc2_2");return __assign(__assign({},Qe),{fc1:Je,prelu4_alpha:st,fc2_1:Mt,fc2_2:nn})}function Ke(){var Qe=Ge([3,32,64,64],"onet"),Je=v(64,128,2,"onet/conv4"),st=je(128,"onet/prelu4_alpha"),Mt=$e(1152,256,"onet/fc1"),nn=je(256,"onet/prelu5_alpha"),rn=$e(256,2,"onet/fc2_1"),on=$e(256,4,"onet/fc2_2"),an=$e(256,10,"onet/fc2_3");return __assign(__assign({},Qe),{conv4:Je,prelu4_alpha:st,fc1:Mt,prelu5_alpha:nn,fc2_1:rn,fc2_2:on,fc2_3:an})}return{extractPNetParams:Ye,extractRNetParams:qe,extractONetParams:Ke}}function extractParams(m){var y=extractWeightsFactory(m),v=y.extractWeights,$e=y.getRemainingWeights,je=[],Ge=extractorsFactory$1(v,je),Ye=Ge.extractPNetParams,qe=Ge.extractRNetParams,Ke=Ge.extractONetParams,Qe=Ye(),Je=qe(),st=Ke();if($e().length!==0)throw new Error("weights remaing after extract: "+$e().length);return{params:{pnet:Qe,rnet:Je,onet:st},paramMappings:je}}function extractorsFactory(m,y){var v=extractWeightEntryFactory(m,y);function $e(Je){var st=v(Je+"/weights",4,Je+"/filters"),Mt=v(Je+"/bias",1);return{filters:st,bias:Mt}}function je(Je){var st=v(Je+"/weights",2),Mt=v(Je+"/bias",1);return{weights:st,bias:Mt}}function Ge(Je){return v(Je,1)}function Ye(Je){var st=$e(Je+"/conv1"),Mt=Ge(Je+"/prelu1_alpha"),nn=$e(Je+"/conv2"),rn=Ge(Je+"/prelu2_alpha"),on=$e(Je+"/conv3"),an=Ge(Je+"/prelu3_alpha");return{conv1:st,prelu1_alpha:Mt,conv2:nn,prelu2_alpha:rn,conv3:on,prelu3_alpha:an}}function qe(){var Je=Ye("pnet"),st=$e("pnet/conv4_1"),Mt=$e("pnet/conv4_2");return __assign(__assign({},Je),{conv4_1:st,conv4_2:Mt})}function Ke(){var Je=Ye("rnet"),st=je("rnet/fc1"),Mt=Ge("rnet/prelu4_alpha"),nn=je("rnet/fc2_1"),rn=je("rnet/fc2_2");return __assign(__assign({},Je),{fc1:st,prelu4_alpha:Mt,fc2_1:nn,fc2_2:rn})}function Qe(){var Je=Ye("onet"),st=$e("onet/conv4"),Mt=Ge("onet/prelu4_alpha"),nn=je("onet/fc1"),rn=Ge("onet/prelu5_alpha"),on=je("onet/fc2_1"),an=je("onet/fc2_2"),sn=je("onet/fc2_3");return __assign(__assign({},Je),{conv4:st,prelu4_alpha:Mt,fc1:nn,prelu5_alpha:rn,fc2_1:on,fc2_2:an,fc2_3:sn})}return{extractPNetParams:qe,extractRNetParams:Ke,extractONetParams:Qe}}function extractParamsFromWeigthMap(m){var y=[],v=extractorsFactory(m,y),$e=v.extractPNetParams,je=v.extractRNetParams,Ge=v.extractONetParams,Ye=$e(),qe=je(),Ke=Ge();return disposeUnusedWeightTensors(m,y),{params:{pnet:Ye,rnet:qe,onet:Ke},paramMappings:y}}function getSizesForScale(m,y){var v=y[0],$e=y[1];return{height:Math.floor(v*m),width:Math.floor($e*m)}}function pyramidDown(m,y,v){for(var $e=v[0],je=v[1],Ge=CELL_SIZE/m,Ye=[],qe=Math.min($e,je)*Ge,Ke=0;qe>=12;)Ye.push(Ge*Math.pow(y,Ke)),qe=qe*y,Ke+=1;return Ye}var MtcnnBox=function(m){__extends(y,m);function y(v,$e,je,Ge){return m.call(this,{left:v,top:$e,right:je,bottom:Ge},!0)||this}return y}(Box);function normalize(m){return Ze(function(){return gc(Cc(m,On(127.5)),On(.0078125))})}function prelu(m,y){return Ze(function(){return rc(Bl(m),gc(y,wu(Bl(wu(m)))))})}function sharedLayer(m,y,v){return v===void 0&&(v=!1),Ze(function(){var $e=convLayer$1(m,y.conv1,"valid");return $e=prelu($e,y.prelu1_alpha),$e=hl($e,v?[2,2]:[3,3],[2,2],"same"),$e=convLayer$1($e,y.conv2,"valid"),$e=prelu($e,y.prelu2_alpha),$e=v?$e:hl($e,[3,3],[2,2],"valid"),$e=convLayer$1($e,y.conv3,"valid"),$e=prelu($e,y.prelu3_alpha),$e})}function PNet(m,y){return Ze(function(){var v=sharedLayer(m,y,!0),$e=convLayer$1(v,y.conv4_1,"valid"),je=wr(Sl($e,3),3),Ge=go(Cc($e,je),3),Ye=convLayer$1(v,y.conv4_2,"valid");return{prob:Ge,regions:Ye}})}function rescaleAndNormalize(m,y){return Ze(function(){var v=getSizesForScale(y,m.shape.slice(1)),$e=v.height,je=v.width,Ge=Oh.resizeBilinear(m,[$e,je]),Ye=normalize(Ge);return Wl(Ye,[0,2,1,3])})}function extractBoundingBoxes(m,y,v,$e){for(var je=[],Ge=m.arraySync(),Ye=0;Ye<m.shape[0];Ye++)for(var qe=0;qe<m.shape[1];qe++)Ge[Ye][qe]>=$e&&je.push(new Point(qe,Ye));var Ke=je.map(function(Qe){var Je=new BoundingBox(Math.round((Qe.y*CELL_STRIDE+1)/v),Math.round((Qe.x*CELL_STRIDE+1)/v),Math.round((Qe.y*CELL_STRIDE+CELL_SIZE)/v),Math.round((Qe.x*CELL_STRIDE+CELL_SIZE)/v)),st=Ge[Qe.y][Qe.x],Mt=y.arraySync(),nn=new MtcnnBox(Mt[Qe.y][Qe.x][0],Mt[Qe.y][Qe.x][1],Mt[Qe.y][Qe.x][2],Mt[Qe.y][Qe.x][3]);return{cell:Je,score:st,region:nn}});return Ke}function stage1(m,y,v,$e,je){je.stage1=[];var Ge=y.map(function(Mt){return Ze(function(){var nn={scale:Mt},rn=rescaleAndNormalize(m,Mt),on=Date.now(),an=PNet(rn,$e),sn=an.prob,ln=an.regions;nn.pnet=Date.now()-on;var cn=Ur(Ur(sn,3)[1])[0],un=Ur(ln)[0];return{scoresTensor:cn,regionsTensor:un,scale:Mt,statsForScale:nn}})}),Ye=Ge.map(function(Mt){var nn=Mt.scoresTensor,rn=Mt.regionsTensor,on=Mt.scale,an=Mt.statsForScale,sn=extractBoundingBoxes(nn,rn,on,v);if(nn.dispose(),rn.dispose(),!sn.length)return je.stage1.push(an),[];var ln=Date.now(),cn=nonMaxSuppression$1(sn.map(function(un){return un.cell}),sn.map(function(un){return un.score}),.5);return an.nms=Date.now()-ln,an.numBoxes=cn.length,je.stage1.push(an),cn.map(function(un){return sn[un]})}),qe=Ye.reduce(function(Mt,nn){return Mt.concat(nn)},[]),Ke=[],Qe=[];if(qe.length>0){var Je=Date.now(),st=nonMaxSuppression$1(qe.map(function(Mt){return Mt.cell}),qe.map(function(Mt){return Mt.score}),.7);je.stage1_nms=Date.now()-Je,Qe=st.map(function(Mt){return qe[Mt].score}),Ke=st.map(function(Mt){return qe[Mt]}).map(function(Mt){var nn=Mt.cell,rn=Mt.region;return new BoundingBox(nn.left+rn.left*nn.width,nn.top+rn.top*nn.height,nn.right+rn.right*nn.width,nn.bottom+rn.bottom*nn.height).toSquare().round()})}return{boxes:Ke,scores:Qe}}function extractImagePatches(m,y,v){var $e=v.width,je=v.height;return __awaiter(this,void 0,void 0,function(){var Ge,Ye,qe,Ke=this;return __generator(this,function(Qe){switch(Qe.label){case 0:return Ge=getContext2dOrThrow(m),[4,Promise.all(y.map(function(Je){return __awaiter(Ke,void 0,void 0,function(){var st,Mt,nn,rn,on,an,sn,ln;return __generator(this,function(cn){return st=Je.padAtBorders(m.height,m.width),Mt=st.y,nn=st.ey,rn=st.x,on=st.ex,an=rn-1,sn=Mt-1,ln=Ge.getImageData(an,sn,on-an,nn-sn),[2,env.isNodejs()?createCanvasFromMedia(ln):createImageBitmap(ln)]})})}))];case 1:return Ye=Qe.sent(),qe=[],Ye.forEach(function(Je){var st=createCanvas({width:$e,height:je}),Mt=getContext2dOrThrow(st);Mt.drawImage(Je,0,0,$e,je);for(var nn=Mt.getImageData(0,0,$e,je).data,rn=[],on=0;on<nn.length;on+=4)rn.push(nn[on+2]),rn.push(nn[on+1]),rn.push(nn[on]);qe.push(rn)}),[2,qe.map(function(Je){var st=Ze(function(){var Mt=Wl(Ln(Je,[1,$e,je,3]),[0,2,1,3]).toFloat();return normalize(Mt)});return st})]}})})}function RNet(m,y){return Ze(function(){var v=sharedLayer(m,y),$e=Or(v,[v.shape[0],y.fc1.weights.shape[0]]),je=fullyConnectedLayer($e,y.fc1),Ge=prelu(je,y.prelu4_alpha),Ye=fullyConnectedLayer(Ge,y.fc2_1),qe=wr(Sl(Ye,1),1),Ke=go(Cc(Ye,qe),1),Qe=fullyConnectedLayer(Ge,y.fc2_2),Je=Ur(Ke,1)[1];return{scores:Je,regions:Qe}})}function stage2(m,y,v,$e,je){return __awaiter(this,void 0,void 0,function(){var Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln;return __generator(this,function(cn){switch(cn.label){case 0:return Ge=Date.now(),[4,extractImagePatches(m,y,{width:24,height:24})];case 1:return Ye=cn.sent(),je.stage2_extractImagePatches=Date.now()-Ge,Ge=Date.now(),qe=Ye.map(function(un){var hn=RNet(un,$e);return un.dispose(),hn}),je.stage2_rnet=Date.now()-Ge,Ke=qe.length>1?Yn(qe.map(function(un){return un.scores})):qe[0].scores,st=(Je=Array).from,[4,Ke.data()];case 2:return Qe=st.apply(Je,[cn.sent()]),Ke.dispose(),Mt=Qe.map(function(un,hn){return{score:un,idx:hn}}).filter(function(un){return un.score>v}).map(function(un){var hn=un.idx;return hn}),nn=Mt.map(function(un){return y[un]}),rn=Mt.map(function(un){return Qe[un]}),on=[],an=[],nn.length>0&&(Ge=Date.now(),sn=nonMaxSuppression$1(nn,rn,.7),je.stage2_nms=Date.now()-Ge,ln=sn.map(function(un){var hn=qe[Mt[un]].regions.arraySync();return new MtcnnBox(hn[0][0],hn[0][1],hn[0][2],hn[0][3])}),an=sn.map(function(un){return rn[un]}),on=sn.map(function(un,hn){return nn[un].calibrate(ln[hn])})),qe.forEach(function(un){un.regions.dispose(),un.scores.dispose()}),[2,{boxes:on,scores:an}]}})})}function ONet(m,y){return Ze(function(){var v=sharedLayer(m,y);v=hl(v,[2,2],[2,2],"same"),v=convLayer$1(v,y.conv4,"valid"),v=prelu(v,y.prelu4_alpha);var $e=Or(v,[v.shape[0],y.fc1.weights.shape[0]]),je=fullyConnectedLayer($e,y.fc1),Ge=prelu(je,y.prelu5_alpha),Ye=fullyConnectedLayer(Ge,y.fc2_1),qe=wr(Sl(Ye,1),1),Ke=go(Cc(Ye,qe),1),Qe=fullyConnectedLayer(Ge,y.fc2_2),Je=fullyConnectedLayer(Ge,y.fc2_3),st=Ur(Ke,1)[1];return{scores:st,regions:Qe,points:Je}})}function stage3(m,y,v,$e,je){return __awaiter(this,void 0,void 0,function(){var Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln,cn;return __generator(this,function(un){switch(un.label){case 0:return Ge=Date.now(),[4,extractImagePatches(m,y,{width:48,height:48})];case 1:return Ye=un.sent(),je.stage3_extractImagePatches=Date.now()-Ge,Ge=Date.now(),qe=Ye.map(function(hn){var fn=ONet(hn,$e);return hn.dispose(),fn}),je.stage3_onet=Date.now()-Ge,Ke=qe.length>1?Yn(qe.map(function(hn){return hn.scores})):qe[0].scores,st=(Je=Array).from,[4,Ke.data()];case 2:return Qe=st.apply(Je,[un.sent()]),Ke.dispose(),Mt=Qe.map(function(hn,fn){return{score:hn,idx:fn}}).filter(function(hn){return hn.score>v}).map(function(hn){var fn=hn.idx;return fn}),nn=Mt.map(function(hn){var fn=qe[hn].regions.arraySync();return new MtcnnBox(fn[0][0],fn[0][1],fn[0][2],fn[0][3])}),rn=Mt.map(function(hn,fn){return y[hn].calibrate(nn[fn])}),on=Mt.map(function(hn){return Qe[hn]}),an=[],sn=[],ln=[],rn.length>0&&(Ge=Date.now(),cn=nonMaxSuppression$1(rn,on,.7,!1),je.stage3_nms=Date.now()-Ge,an=cn.map(function(hn){return rn[hn]}),sn=cn.map(function(hn){return on[hn]}),ln=cn.map(function(hn,fn){return Array(5).fill(0).map(function(to,Mi){var Uo=qe[hn].points.arraySync();return new Point(Uo[0][Mi]*(an[fn].width+1)+an[fn].left,Uo[0][Mi+5]*(an[fn].height+1)+an[fn].top)})})),qe.forEach(function(hn){hn.regions.dispose(),hn.scores.dispose(),hn.points.dispose()}),[2,{boxes:an,scores:sn,points:ln}]}})})}var Mtcnn=function(m){__extends(y,m);function y(){return m.call(this,"Mtcnn")||this}return y.prototype.load=function(v){return __awaiter(this,void 0,void 0,function(){return __generator(this,function($e){return console.warn("mtcnn is deprecated and will be removed soon"),[2,m.prototype.load.call(this,v)]})})},y.prototype.loadFromDisk=function(v){return __awaiter(this,void 0,void 0,function(){return __generator(this,function($e){return console.warn("mtcnn is deprecated and will be removed soon"),[2,m.prototype.loadFromDisk.call(this,v)]})})},y.prototype.forwardInput=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var je,Ge,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,sn,ln,cn,un,hn,fn,to,Mi;return __generator(this,function(Uo){switch(Uo.label){case 0:if(je=this.params,!je)throw new Error("Mtcnn - load model before inference");if(Ge=v.canvases[0],!Ge)throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return Ye={},qe=Date.now(),Ke=Ze(function(){return bgrToRgbTensor(wr(id.fromPixels(Ge)).toFloat())}),Qe=function(fo){return Ke.dispose(),Ye.total=Date.now()-qe,fo},Je=Ke.shape.slice(1),st=Je[0],Mt=Je[1],nn=new MtcnnOptions($e),rn=nn.minFaceSize,on=nn.scaleFactor,an=nn.maxNumScales,sn=nn.scoreThresholds,ln=nn.scaleSteps,cn=(ln||pyramidDown(rn,on,[st,Mt])).filter(function(fo){var dd=getSizesForScale(fo,[st,Mt]);return Math.min(dd.width,dd.height)>CELL_SIZE}).slice(0,an),Ye.scales=cn,Ye.pyramid=cn.map(function(fo){return getSizesForScale(fo,[st,Mt])}),un=Date.now(),[4,stage1(Ke,cn,sn[0],je.pnet,Ye)];case 1:return hn=Uo.sent(),Ye.total_stage1=Date.now()-un,hn.boxes.length?(Ye.stage2_numInputBoxes=hn.boxes.length,un=Date.now(),[4,stage2(Ge,hn.boxes,sn[1],je.rnet,Ye)]):[2,Qe({results:[],stats:Ye})];case 2:return fn=Uo.sent(),Ye.total_stage2=Date.now()-un,fn.boxes.length?(Ye.stage3_numInputBoxes=fn.boxes.length,un=Date.now(),[4,stage3(Ge,fn.boxes,sn[2],je.onet,Ye)]):[2,Qe({results:[],stats:Ye})];case 3:return to=Uo.sent(),Ye.total_stage3=Date.now()-un,Mi=to.boxes.map(function(fo,dd){return extendWithFaceLandmarks(extendWithFaceDetection({},new FaceDetection(to.scores[dd],new Rect(fo.left/Mt,fo.top/st,fo.width/Mt,fo.height/st),{height:st,width:Mt})),new FaceLandmarks5(to.points[dd].map(function(mo){return mo.sub(new Point(fo.left,fo.top)).div(new Point(fo.width,fo.height))}),{width:fo.width,height:fo.height}))}),[2,Qe({results:Mi,stats:Ye})]}})})},y.prototype.forward=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return je=this.forwardInput,[4,toNetInput(v)];case 1:return[4,je.apply(this,[Ge.sent(),$e])];case 2:return[2,Ge.sent().results]}})})},y.prototype.forwardWithStats=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return je=this.forwardInput,[4,toNetInput(v)];case 1:return[2,je.apply(this,[Ge.sent(),$e])]}})})},y.prototype.getDefaultModelName=function(){return"mtcnn_model"},y.prototype.extractParamsFromWeigthMap=function(v){return extractParamsFromWeigthMap(v)},y.prototype.extractParams=function(v){return extractParams(v)},y}(NeuralNetwork),IOU_THRESHOLD=.4,BOX_ANCHORS=[new Point(1.603231,2.094468),new Point(6.041143,7.080126),new Point(2.882459,3.518061),new Point(4.266906,5.178857),new Point(9.041765,10.66308)],MEAN_RGB=[117.001,114.697,97.404],TinyFaceDetector=function(m){__extends(y,m);function y(){var v=this,$e={withSeparableConvs:!0,iouThreshold:IOU_THRESHOLD,classes:["face"],anchors:BOX_ANCHORS,meanRgb:MEAN_RGB,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return v=m.call(this,$e)||this,v}return Object.defineProperty(y.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),y.prototype.locateFaces=function(v,$e){return __awaiter(this,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.detect(v,$e)];case 1:return je=Ge.sent(),[2,je.map(function(Ye){return new FaceDetection(Ye.score,Ye.relativeBox,{width:Ye.imageWidth,height:Ye.imageHeight})})]}})})},y.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},y.prototype.extractParamsFromWeigthMap=function(v){return m.prototype.extractParamsFromWeigthMap.call(this,v)},y}(TinyYolov2Base),nets={ssdMobilenetv1:new SsdMobilenetv1,tinyFaceDetector:new TinyFaceDetector,tinyYolov2:new TinyYolov2,mtcnn:new Mtcnn,faceLandmark68Net:new FaceLandmark68Net,faceLandmark68TinyNet:new FaceLandmark68TinyNet,faceRecognitionNet:new FaceRecognitionNet,faceExpressionNet:new FaceExpressionNet,ageGenderNet:new AgeGenderNet},PredictFaceExpressionsTaskBase=function(m){__extends(y,m);function y(v,$e,je){var Ge=m.call(this)||this;return Ge.parentTask=v,Ge.input=$e,Ge.extractedFaces=je,Ge}return y}(ComposableTask),PredictAllFaceExpressionsTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je=this;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.parentTask];case 1:return v=Ge.sent(),[4,extractAllFacesAndComputeResults(v,this.input,function(Ye){return __awaiter(je,void 0,void 0,function(){return __generator(this,function(qe){switch(qe.label){case 0:return[4,Promise.all(Ye.map(function(Ke){return nets.faceExpressionNet.predictExpressions(Ke)}))];case 1:return[2,qe.sent()]}})})},this.extractedFaces)];case 2:return $e=Ge.sent(),[2,v.map(function(Ye,qe){return extendWithFaceExpressions(Ye,$e[qe])})]}})})},y.prototype.withAgeAndGender=function(){return new PredictAllAgeAndGenderTask(this,this.input)},y}(PredictFaceExpressionsTaskBase),PredictSingleFaceExpressionsTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e;return __generator(this,function(je){switch(je.label){case 0:return[4,this.parentTask];case 1:return v=je.sent(),v?[4,extractSingleFaceAndComputeResult(v,this.input,function(Ge){return nets.faceExpressionNet.predictExpressions(Ge)},this.extractedFaces)]:[2];case 2:return $e=je.sent(),[2,extendWithFaceExpressions(v,$e)]}})})},y.prototype.withAgeAndGender=function(){return new PredictSingleAgeAndGenderTask(this,this.input)},y}(PredictFaceExpressionsTaskBase),PredictAllFaceExpressionsWithFaceAlignmentTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.withAgeAndGender=function(){return new PredictAllAgeAndGenderWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptors=function(){return new ComputeAllFaceDescriptorsTask(this,this.input)},y}(PredictAllFaceExpressionsTask),PredictSingleFaceExpressionsWithFaceAlignmentTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.withAgeAndGender=function(){return new PredictSingleAgeAndGenderWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptor=function(){return new ComputeSingleFaceDescriptorTask(this,this.input)},y}(PredictSingleFaceExpressionsTask),PredictAgeAndGenderTaskBase=function(m){__extends(y,m);function y(v,$e,je){var Ge=m.call(this)||this;return Ge.parentTask=v,Ge.input=$e,Ge.extractedFaces=je,Ge}return y}(ComposableTask),PredictAllAgeAndGenderTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je=this;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.parentTask];case 1:return v=Ge.sent(),[4,extractAllFacesAndComputeResults(v,this.input,function(Ye){return __awaiter(je,void 0,void 0,function(){return __generator(this,function(qe){switch(qe.label){case 0:return[4,Promise.all(Ye.map(function(Ke){return nets.ageGenderNet.predictAgeAndGender(Ke)}))];case 1:return[2,qe.sent()]}})})},this.extractedFaces)];case 2:return $e=Ge.sent(),[2,v.map(function(Ye,qe){var Ke=$e[qe],Qe=Ke.age,Je=Ke.gender,st=Ke.genderProbability;return extendWithAge(extendWithGender(Ye,Je,st),Qe)})]}})})},y.prototype.withFaceExpressions=function(){return new PredictAllFaceExpressionsTask(this,this.input)},y}(PredictAgeAndGenderTaskBase),PredictSingleAgeAndGenderTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye;return __generator(this,function(qe){switch(qe.label){case 0:return[4,this.parentTask];case 1:return v=qe.sent(),v?[4,extractSingleFaceAndComputeResult(v,this.input,function(Ke){return nets.ageGenderNet.predictAgeAndGender(Ke)},this.extractedFaces)]:[2];case 2:return $e=qe.sent(),je=$e.age,Ge=$e.gender,Ye=$e.genderProbability,[2,extendWithAge(extendWithGender(v,Ge,Ye),je)]}})})},y.prototype.withFaceExpressions=function(){return new PredictSingleFaceExpressionsTask(this,this.input)},y}(PredictAgeAndGenderTaskBase),PredictAllAgeAndGenderWithFaceAlignmentTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.withFaceExpressions=function(){return new PredictAllFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptors=function(){return new ComputeAllFaceDescriptorsTask(this,this.input)},y}(PredictAllAgeAndGenderTask),PredictSingleAgeAndGenderWithFaceAlignmentTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.withFaceExpressions=function(){return new PredictSingleFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptor=function(){return new ComputeSingleFaceDescriptorTask(this,this.input)},y}(PredictSingleAgeAndGenderTask),ComputeFaceDescriptorsTaskBase=function(m){__extends(y,m);function y(v,$e){var je=m.call(this)||this;return je.parentTask=v,je.input=$e,je}return y}(ComposableTask),ComputeAllFaceDescriptorsTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e;return __generator(this,function(je){switch(je.label){case 0:return[4,this.parentTask];case 1:return v=je.sent(),[4,extractAllFacesAndComputeResults(v,this.input,function(Ge){return Promise.all(Ge.map(function(Ye){return nets.faceRecognitionNet.computeFaceDescriptor(Ye)}))},null,function(Ge){return Ge.landmarks.align(null,{useDlibAlignment:!0})})];case 2:return $e=je.sent(),[2,$e.map(function(Ge,Ye){return extendWithFaceDescriptor(v[Ye],Ge)})]}})})},y.prototype.withFaceExpressions=function(){return new PredictAllFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withAgeAndGender=function(){return new PredictAllAgeAndGenderWithFaceAlignmentTask(this,this.input)},y}(ComputeFaceDescriptorsTaskBase),ComputeSingleFaceDescriptorTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e;return __generator(this,function(je){switch(je.label){case 0:return[4,this.parentTask];case 1:return v=je.sent(),v?[4,extractSingleFaceAndComputeResult(v,this.input,function(Ge){return nets.faceRecognitionNet.computeFaceDescriptor(Ge)},null,function(Ge){return Ge.landmarks.align(null,{useDlibAlignment:!0})})]:[2];case 2:return $e=je.sent(),[2,extendWithFaceDescriptor(v,$e)]}})})},y.prototype.withFaceExpressions=function(){return new PredictSingleFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withAgeAndGender=function(){return new PredictSingleAgeAndGenderWithFaceAlignmentTask(this,this.input)},y}(ComputeFaceDescriptorsTaskBase),DetectFaceLandmarksTaskBase=function(m){__extends(y,m);function y(v,$e,je){var Ge=m.call(this)||this;return Ge.parentTask=v,Ge.input=$e,Ge.useTinyLandmarkNet=je,Ge}return Object.defineProperty(y.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?nets.faceLandmark68TinyNet:nets.faceLandmark68Net},enumerable:!0,configurable:!0}),y}(ComposableTask),DetectAllFaceLandmarksTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye,qe=this;return __generator(this,function(Ke){switch(Ke.label){case 0:return[4,this.parentTask];case 1:return v=Ke.sent(),$e=v.map(function(Qe){return Qe.detection}),this.input instanceof wt?[4,extractFaceTensors(this.input,$e)]:[3,3];case 2:return Ge=Ke.sent(),[3,5];case 3:return[4,extractFaces(this.input,$e)];case 4:Ge=Ke.sent(),Ke.label=5;case 5:return je=Ge,[4,Promise.all(je.map(function(Qe){return qe.landmarkNet.detectLandmarks(Qe)}))];case 6:return Ye=Ke.sent(),je.forEach(function(Qe){return Qe instanceof wt&&Qe.dispose()}),[2,v.map(function(Qe,Je){return extendWithFaceLandmarks(Qe,Ye[Je])})]}})})},y.prototype.withFaceExpressions=function(){return new PredictAllFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withAgeAndGender=function(){return new PredictAllAgeAndGenderWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptors=function(){return new ComputeAllFaceDescriptorsTask(this,this.input)},y}(DetectFaceLandmarksTaskBase),DetectSingleFaceLandmarksTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge,Ye;return __generator(this,function(qe){switch(qe.label){case 0:return[4,this.parentTask];case 1:return v=qe.sent(),v?($e=v.detection,this.input instanceof wt?[4,extractFaceTensors(this.input,[$e])]:[3,3]):[2];case 2:return Ge=qe.sent(),[3,5];case 3:return[4,extractFaces(this.input,[$e])];case 4:Ge=qe.sent(),qe.label=5;case 5:return je=Ge,[4,this.landmarkNet.detectLandmarks(je[0])];case 6:return Ye=qe.sent(),je.forEach(function(Ke){return Ke instanceof wt&&Ke.dispose()}),[2,extendWithFaceLandmarks(v,Ye)]}})})},y.prototype.withFaceExpressions=function(){return new PredictSingleFaceExpressionsWithFaceAlignmentTask(this,this.input)},y.prototype.withAgeAndGender=function(){return new PredictSingleAgeAndGenderWithFaceAlignmentTask(this,this.input)},y.prototype.withFaceDescriptor=function(){return new ComputeSingleFaceDescriptorTask(this,this.input)},y}(DetectFaceLandmarksTaskBase),DetectFacesTaskBase=function(m){__extends(y,m);function y(v,$e){$e===void 0&&($e=new SsdMobilenetv1Options);var je=m.call(this)||this;return je.input=v,je.options=$e,je}return y}(ComposableTask),DetectAllFacesTask=function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e,je,Ge;return __generator(this,function(Ye){switch(Ye.label){case 0:return v=this,$e=v.input,je=v.options,je instanceof MtcnnOptions?[4,nets.mtcnn.forward($e,je)]:[3,2];case 1:return[2,Ye.sent().map(function(qe){return qe.detection})];case 2:if(Ge=je instanceof TinyFaceDetectorOptions?function(qe){return nets.tinyFaceDetector.locateFaces(qe,je)}:je instanceof SsdMobilenetv1Options?function(qe){return nets.ssdMobilenetv1.locateFaces(qe,je)}:je instanceof TinyYolov2Options?function(qe){return nets.tinyYolov2.locateFaces(qe,je)}:null,!Ge)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,Ge($e)]}})})},y.prototype.runAndExtendWithFaceDetections=function(){var v=this;return new Promise(function($e){return __awaiter(v,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.run()];case 1:return je=Ge.sent(),[2,$e(je.map(function(Ye){return extendWithFaceDetection({},Ye)}))]}})})})},y.prototype.withFaceLandmarks=function(v){return v===void 0&&(v=!1),new DetectAllFaceLandmarksTask(this.runAndExtendWithFaceDetections(),this.input,v)},y.prototype.withFaceExpressions=function(){return new PredictAllFaceExpressionsTask(this.runAndExtendWithFaceDetections(),this.input)},y.prototype.withAgeAndGender=function(){return new PredictAllAgeAndGenderTask(this.runAndExtendWithFaceDetections(),this.input)},y}(DetectFacesTaskBase);(function(m){__extends(y,m);function y(){return m!==null&&m.apply(this,arguments)||this}return y.prototype.run=function(){return __awaiter(this,void 0,void 0,function(){var v,$e;return __generator(this,function(je){switch(je.label){case 0:return[4,new DetectAllFacesTask(this.input,this.options)];case 1:return v=je.sent(),$e=v[0],v.forEach(function(Ge){Ge.score>$e.score&&($e=Ge)}),[2,$e]}})})},y.prototype.runAndExtendWithFaceDetection=function(){var v=this;return new Promise(function($e){return __awaiter(v,void 0,void 0,function(){var je;return __generator(this,function(Ge){switch(Ge.label){case 0:return[4,this.run()];case 1:return je=Ge.sent(),[2,$e(je?extendWithFaceDetection({},je):void 0)]}})})})},y.prototype.withFaceLandmarks=function(v){return v===void 0&&(v=!1),new DetectSingleFaceLandmarksTask(this.runAndExtendWithFaceDetection(),this.input,v)},y.prototype.withFaceExpressions=function(){return new PredictSingleFaceExpressionsTask(this.runAndExtendWithFaceDetection(),this.input)},y.prototype.withAgeAndGender=function(){return new PredictSingleAgeAndGenderTask(this.runAndExtendWithFaceDetection(),this.input)},y})(DetectFacesTaskBase);function detectAllFaces(m,y){return y===void 0&&(y=new SsdMobilenetv1Options),new DetectAllFacesTask(m,y)}function euclideanDistance(m,y){if(m.length!==y.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var v=Array.from(m),$e=Array.from(y);return Math.sqrt(v.map(function(je,Ge){return je-$e[Ge]}).reduce(function(je,Ge){return je+Math.pow(Ge,2)},0))}(function(){function m(y,v){v===void 0&&(v=.6),this._distanceThreshold=v;var $e=Array.isArray(y)?y:[y];if(!$e.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var je=1,Ge=function(){return"person "+je++};this._labeledDescriptors=$e.map(function(Ye){if(Ye instanceof LabeledFaceDescriptors)return Ye;if(Ye instanceof Float32Array)return new LabeledFaceDescriptors(Ge(),[Ye]);if(Ye.descriptor&&Ye.descriptor instanceof Float32Array)return new LabeledFaceDescriptors(Ge(),[Ye.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")})}return Object.defineProperty(m.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),m.prototype.computeMeanDistance=function(y,v){return v.map(function($e){return euclideanDistance($e,y)}).reduce(function($e,je){return $e+je},0)/(v.length||1)},m.prototype.matchDescriptor=function(y){var v=this;return this.labeledDescriptors.map(function($e){var je=$e.descriptors,Ge=$e.label;return new FaceMatch(Ge,v.computeMeanDistance(y,je))}).reduce(function($e,je){return $e.distance<je.distance?$e:je})},m.prototype.findBestMatch=function(y){var v=this.matchDescriptor(y);return v.distance<this.distanceThreshold?v:new FaceMatch("unknown",v.distance)},m.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(y){return y.toJSON()})}},m.fromJSON=function(y){var v=y.labeledDescriptors.map(function($e){return LabeledFaceDescriptors.fromJSON($e)});return new m(v,y.distanceThreshold)},m})();let _modelLoaded=!1;async function loadModels(m="/models"){_modelLoaded||(await Promise.all([nets.tinyFaceDetector.loadFromUri(m),nets.faceLandmark68TinyNet.loadFromUri(m)]),_modelLoaded=!0)}function getBase64ImageSize(m){const y=m.indexOf("base64,");return y<0?-1:(m.substr(y+6).length*.75).toFixed(2)}function base64toFile(m,y,v){let $e=atob(m),je=$e.length,Ge=new Uint8Array(je);for(;je--;)Ge[je]=$e.charCodeAt(je);return new File([Ge],y,{type:v})}function createEyeMask(m,y){const v=[...m,...y],$e=v.map(st=>st.x),je=v.map(st=>st.y),Ge=Math.min(...$e),Ye=Math.max(...$e),qe=Math.min(...je),Ke=Math.max(...je),Qe=(Ye-Ge)*.4,Je=(Ke-qe)*.8+6;return{x:Ge-Qe,y:qe-Je,width:Ye-Ge+Qe*2,height:Ke-qe+Je*2}}function applyMosaic(m,y){const v=Math.max(0,Math.round(y.x)),$e=Math.max(0,Math.round(y.y)),je=Math.round(y.width),Ge=Math.round(y.height);m.fillStyle="#000000",m.fillRect(v,$e,je,Ge)}async function faceMaskImage(m,y,v="/models"){await loadModels(v);const $e=await new Promise((Qe,Je)=>{const st=new Image;st.crossOrigin="anonymous",st.onload=()=>Qe(st),st.onerror=Je,st.src=m}),je=await detectAllFaces($e,new TinyFaceDetectorOptions).withFaceLandmarks(!0);if(!je.length){console.warn("faceMaskImage: 未检测到人脸"),y&&y(null);return}const Ge=document.createElement("canvas");Ge.width=$e.naturalWidth,Ge.height=$e.naturalHeight;const Ye=Ge.getContext("2d");Ye.drawImage($e,0,0),je.forEach(({landmarks:Qe})=>{const Je=Qe.getLeftEye(),st=Qe.getRightEye(),Mt=createEyeMask(Je,st);applyMosaic(Ye,Mt)});const qe=Ge.toDataURL("image/jpeg",.9),Ke=getBase64ImageSize(qe);console.log("faceMaskImage 处理后大小(字节):",Ke),y&&y(base64toFile(qe.split(",")[1],"face-masked.jpg","image/jpeg"))}const fun=(m,y,v)=>y.then($e=>/^image\/\w+/.test(m.type)?new Promise((je,Ge)=>{let Ye=v.fileList.filter(qe=>qe.raw&&qe.raw==m)[0];if(!Ye){Ge();return}Ye.message="打码处理中...",faceMaskImage(URL.createObjectURL(m),qe=>{if(Ye.message="",!qe){je(m);return}setBaseProps(qe,Ye.raw),Ye.raw=qe,je(Ye.raw)})}):!0),uploadProcess={compress:fun$1,face:fun};function useOssUploader(m,y,v={fileType:[],requireMd5:!1,request:null,signatureUrl:"",addFileMd5Url:"",queryFileMd5Url:"",beginUploadFlow:[]}){let $e=1;const je=async function(Qe){console.log("111111111111111111112222222222222222222223333333333");let Je=Qe.url;if(Qe.objUrl)return Qe.objUrl;if(!Qe.loading&&!Qe.loadError)return Qe.loading=!0,Qe.loadError=!1,await axios({method:"GET",url:Je,responseType:"blob",onDownloadProgress:st=>{let Mt=st.total>0?st.loaded/st.total*100:0;Qe.loadingPercent=isNaN(Mt)?0:Mt}}).then(st=>{const{data:Mt,headers:nn}=st;Qe.objUrl=URL.createObjectURL(Mt);let rn=new Image;rn.src=Qe.objUrl,rn.onload=()=>{Qe.width=rn.width,Qe.height=rn.height,Qe.viewBox=[0,0,Qe.width,Qe.height],Qe.matrix=[[1,0],[0,1],[0,0]],Qe.loading=!1}}).catch(()=>{Qe.loading=!1,Qe.loadError=!0})},Ge=async function(Qe){return await v.request({method:"GET",url:`${v.signatureUrl}${Qe}`})},Ye=async function(Qe){return await v.request({method:"POST",url:`${v.addFileMd5Url}`,data:Qe})},qe=async function(Qe){return await v.request({method:"GET",url:`${v.queryFileMd5Url}`,params:Qe})};let Ke=vue.reactive({fileList:y||[],onHttpRequest:async Qe=>{const{action:Je,file:st,onProgress:Mt,onSuccess:nn,onError:rn}=Qe;let on=await Ge(st.name);if(on.code!==200)throw new Error("Get signature error");const an=on.data,{accessid:sn,policy:ln,signature:cn,dir:un,host:hn}=an;let fn=new FormData;return fn.append("key",un),fn.append("policy",ln),fn.append("OSSAccessKeyId",sn),fn.append("success_action_status","200"),fn.append("signature",cn),fn.append("file",st),await axios.create({onUploadProgress:Mi=>{Mi.percent=Mi.total>0?Mi.loaded/Mi.total*100:0,Mt(Mi)}}).post(hn,fn,{headers:{"Content-Type":"multipart/form-data"}}).then(Mi=>({code:200,fileName:hn+un}))},onBeforeUpload:Qe=>new Promise((Je,st)=>{let Mt=new Promise(nn=>{nn(!0)});Mt=Mt.then(nn=>new Promise(rn=>{Ke.md5({raw:Qe}).then(on=>{rn(on)})})),v.requireMd5&&(Mt=Mt.then(nn=>qe({mdaValue:nn}).then(rn=>{if(rn.rows.length){let on={name:rn.rows[0].filePath,url:rn.rows[0].filePath};throw on.uid=on.uid||$e++,on.status="success",Ke.fileList.push(on),Ke.fileList.map(an=>{je(an)}),new Error("文件已存在")}else return Qe.md5=nn,!0})));for(let nn of v.beginUploadFlow)typeof nn=="string"&&(Mt=uploadProcess[nn](Qe,Mt,Ke));Mt.then(nn=>{Je(nn)}).catch(nn=>{st(!1)})}),onChange:(Qe,Je)=>{if(console.log("onChange:"+Qe.status),Qe.status=="ready"){if(v.fileType&&v.fileType.length>0&&v.fileType.indexOf(Qe.name.split(".").pop().toLocaleLowerCase())==-1)throw Je.splice(Je.indexOf(Qe),1),ElMessage.error(`文件格式不正确, 请上传${v.fileType.join("/")}格式文件!`),new Error("文件格式不正确");Qe.uid=Qe.uid||$e++}else Qe.status=="success"&&(Qe.url=Qe.response.fileName,je(Qe),v.requireMd5&&Ye({filePath:Qe.url,mdaValue:Qe.raw.md5}))},init:function(Qe){Qe=Qe||"",Ke.fileList=(Array.isArray(Qe)?Qe:Qe.length?Qe.split(","):[]).map(Je=>(typeof Je=="string"&&(Je={name:Je,url:Je}),Je.uid=Je.uid||new Date().getTime()+$e++,Je.status="success",Je)),Ke.fileList.map(Je=>{je(Je)})},md5(Qe){return new Promise((Je,st)=>{const Mt=Qe.raw,rn=Math.ceil(Mt.size/10),on=new FileReader,an=new SparkMD5;let sn=0;const ln=()=>{const cn=Mt.slice(sn,sn+rn);on.readAsBinaryString(cn)};on.onload=cn=>{an.appendBinary(cn.target.result),sn<Mt.size?(sn+=rn,ln()):Je(an.end())},ln()})},previewDownload:Qe=>{let Je=document.createElement("a");Je.download=Qe.name,Je.href=Qe.url,Je.click(),window.URL.revokeObjectURL(Je.href)}});return Ke.init(m),[Ke,je]}const _hoisted_1$4={class:"w-full"},_hoisted_2$4={class:"flex justify-center"},_hoisted_3$3={key:0,class:"el-upload__tip font-bold"},_hoisted_4$3={style:{color:"#f56c6c"}},_hoisted_5$3={style:{color:"#f56c6c"}},_sfc_main$4={__name:"index",props:{modelValue:[String,Object,Array],multipleSelect:{type:Boolean,default:!0},drag:{type:Boolean,default:!1},limit:{type:Number,default:5},fileMaxSize:{type:Number,default:5},fileType:{type:Array,default:()=>["pdf","doc","docx","xls","xlsx","rar"]},isShowTip:{type:Boolean,default:!0},size:{default:()=>({width:"148px",height:"148px"})},view:{type:String,default:null},operations:{default:()=>({back:!1,close:!1,rotateLeft:!1,rotateRight:!1})},md5:{type:Object,default:()=>({requireMd5:!1,addFileMd5Url:"",queryFileMd5Url:""})},oss:{type:Object,default:()=>({signatureUrl:""})}},setup(m,{emit:y}){const v=m,$e=vue.useAttrs(),je=y;vue.ref(0),vue.ref([]);const Ge=vue.ref([]),Ye=vue.computed(()=>v.isShowTip&&(v.fileType||v.fileMaxSize)),qe=vue.inject("request"),[Ke]=useOssUploader("",Ge,{request:qe,fileType:v.fileType,signatureUrl:v.oss.signatureUrl,requireMd5:v.md5.requireMd5,addFileMd5Url:v.md5.addFileMd5Url,queryFileMd5Url:v.md5.queryFileMd5Url});function Qe(Mt,nn){let rn="";nn=nn||",";for(let on in Mt)Mt[on].url!==void 0&&Mt[on].url.indexOf("blob:")!==0&&(rn+=Mt[on].url+nn);return rn!=""?rn.substr(0,rn.length-1):""}const Je=()=>{(Ge.value.length==0||Ge.value.every(Mt=>Mt.status=="success"))&&je("update:modelValue",Array.isArray(v.modelValue)?Ge.value:Qe(Ge.value))};function st(Mt,nn,rn){nn.url=nn.response.fileName,Je()}return vue.watch(()=>v.modelValue,Mt=>{if(Mt)Ke.init(Mt);else return Ge.value=[]},{deep:!0,immediate:!0}),vue.watch(()=>Ge.value.length,()=>{console.log("fileupload filelist changed....."),Je()}),(Mt,nn)=>{const rn=vue.resolveComponent("sy-svg-icon"),on=vue.resolveComponent("el-button"),an=vue.resolveComponent("el-upload");return vue.openBlock(),vue.createElementBlock("div",_hoisted_1$4,[vue.createVNode(an,vue.mergeProps({class:"upload-file",drag:m.drag,multiple:"","http-request":vue.unref(Ke).onHttpRequest,"on-success":st,"on-change":vue.unref(Ke).onChange,"before-upload":vue.unref(Ke).onBeforeUpload,"file-list":vue.unref(Ke).fileList,"onUpdate:fileList":nn[0]||(nn[0]=sn=>vue.unref(Ke).fileList=sn),"on-preview":vue.unref(Ke).previewDownload},vue.unref($e)),{default:vue.withCtx(()=>[vue.renderSlot(Mt.$slots,"default",{},()=>[m.drag?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[vue.createElementVNode("div",_hoisted_2$4,[vue.createVNode(rn,{"icon-class":"upload","class-name":"",style:{width:"3rem",height:"3rem",color:"var(--el-color-primary)"}})]),nn[1]||(nn[1]=vue.createElementVNode("div",{class:"el-upload__text"},[vue.createTextVNode(" 将文件拖拽入这里或 "),vue.createElementVNode("em",null,"点击上传")],-1))],64)):(vue.openBlock(),vue.createBlock(on,{key:1,type:"primary",disabled:vue.unref($e).disabled},{default:vue.withCtx(()=>nn[2]||(nn[2]=[vue.createTextVNode("点击上传")])),_:1},8,["disabled"]))])]),tip:vue.withCtx(()=>[Ye.value?(vue.openBlock(),vue.createElementBlock("div",_hoisted_3$3,[nn[5]||(nn[5]=vue.createTextVNode(" 请上传 ")),m.fileMaxSize?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[nn[3]||(nn[3]=vue.createTextVNode(" 大小不超过 ")),vue.createElementVNode("b",_hoisted_4$3,vue.toDisplayString(m.fileMaxSize)+"MB",1)],64)):vue.createCommentVNode("",!0),m.fileType?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[nn[4]||(nn[4]=vue.createTextVNode(" 格式为 ")),vue.createElementVNode("b",_hoisted_5$3,vue.toDisplayString(m.fileType.join("/")),1)],64)):vue.createCommentVNode("",!0),nn[6]||(nn[6]=vue.createTextVNode(" 的文件 "))])):vue.createCommentVNode("",!0)]),_:3},16,["drag","http-request","on-change","before-upload","file-list","on-preview"])])}}},index$8=Object.freeze(Object.defineProperty({__proto__:null,default:_sfc_main$4},Symbol.toStringTag,{value:"Module"})),Mode={CONTAIN:{name:"contain",icon:"FullScreen"},ORIGINAL:{name:"original",icon:"ScaleToOriginal"}},_hoisted_1$3={class:"x-image-viewer__wrapper"},_hoisted_2$3={key:1,class:"x-image-viewer__btn x-image-viewer__desc"},_hoisted_3$2={class:"x-image-viewer__btn x-image-viewer__actions"},_hoisted_4$2={class:"x-image-viewer__actions__inner"},_hoisted_5$2=["src"],mousewheelEventName="mousewheel",_sfc_main$3={__name:"index",props:{urls:{type:Array,default:()=>[]},zIndex:{type:Number,default:9e3},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},hideOnClickModal:{type:Boolean,default:!1},animateClass:{type:String,default:"fadeInDown"}},emits:["close","change"],setup(m,{emit:y}){const v=m,$e=y;let je=null;const Ge=vue.ref(!0),Ye=vue.ref(!1),qe=vue.ref(v.initialIndex),Ke=vue.ref(null),Qe=vue.ref(Mode.CONTAIN),Je=vue.ref({scale:1,deg:0,offsetX:0,offsetY:0,rotateX:0,rotateY:0,enableTransition:!1}),st=vue.computed(()=>{const{urls:co}=v;return co.length<=1}),Mt=vue.computed(()=>qe.value===0),nn=vue.computed(()=>qe.value===0),rn=vue.computed(()=>v.urls[qe.value]),on=vue.computed(()=>{const{scale:co,deg:uo,offsetX:od,offsetY:rd,rotateX:ld,rotateY:hd,enableTransition:pd}=Je.value,fd={transform:`scale(${co}) rotate(${uo}deg) rotateX(${ld}deg) rotateY(${hd}deg)`,transition:pd?"transform .3s":"",marginLeft:`${od}px`,marginTop:`${rd}px`};return Qe.value.name===Mode.CONTAIN.name&&(fd.maxWidth="100%",fd.maxHeight="100%"),fd});function an(){$e("close")}function sn(){Ge.value=!1,Ye.value=!0}function ln(){Ge.value=!1}function cn(co){let uo=!1;return function(...od){uo||(uo=!0,window.requestAnimationFrame(()=>{co.apply(this,od),uo=!1}))}}const un=function(co,uo,od,rd=!1){co&&uo&&od&&co.addEventListener(uo,od,rd)},hn=function(co,uo,od,rd=!1){co&&uo&&od&&co.removeEventListener(uo,od,rd)};function fn(co){if(Ge.value||co.button!==0)return;const{offsetX:uo,offsetY:od}=Je.value,rd=co.pageX,ld=co.pageY;je=cn(hd=>{Je.value={...Je.value,offsetX:uo+hd.pageX-rd,offsetY:od+hd.pageY-ld}}),un(document,"mousemove",je),un(document,"mouseup",()=>{hn(document,"mousemove",je)}),co.preventDefault()}function to(){Je.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1,rotateX:0,rotateY:0}}function Mi(co,uo={}){if(Ge.value)return;const{zoomRate:od,rotateDeg:rd,rotateXDeg:ld,rotateYDeg:hd,enableTransition:pd}={zoomRate:.2,rotateDeg:90,rotateXDeg:180,rotateYDeg:180,enableTransition:!0,...uo};if(co==="zoomOut")Je.value.scale>.2&&(Je.value.scale=parseFloat((Je.value.scale-od).toFixed(3)));else if(co==="zoomIn")Je.value.scale=parseFloat((Je.value.scale+od).toFixed(3));else if(co==="clocelise")Je.value.deg+=rd;else if(co==="anticlocelise")Je.value.deg-=rd;else if(co==="fliphorizontal"){let fd=Je.value.deg!=0&&Math.abs(Je.value.deg)/rd%2!=0?"rotateX":"rotateY";Je.value[fd]=Je.value[fd]?0:hd}else if(co==="flipvertical"){let fd=Je.value.deg!=0&&Math.abs(Je.value.deg)/rd%2!=0?"rotateY":"rotateX";Je.value[fd]=Je.value[fd]?0:ld}Je.value.enableTransition=pd}function Uo(){if(Ge.value)return;const co=Object.keys(Mode),uo=Object.values(Mode),od=Qe.value.name,ld=(uo.findIndex(hd=>hd.name===od)+1)%co.length;Qe.value=Mode[co[ld]],to()}function fo(){if(Mt.value&&!v.infinite)return;const co=v.urls.length;qe.value=(qe.value-1+co)%co,Ye.value=!1}function dd(){if(nn.value&&!v.infinite)return;const co=v.urls.length;qe.value=(qe.value+1)%co,Ye.value=!1}let mo=null,ho=null;const Xr=()=>{mo=cn(uo=>{switch(uo.keyCode){case 27:an();break;case 32:Uo();break;case 37:this.prev();break;case 38:Mi("zoomIn");break;case 39:this.next();break;case 40:Mi("zoomOut");break}});let co=cn(uo=>{(uo.wheelDelta?uo.wheelDelta:-uo.detail)>0?Mi("zoomIn",{zoomRate:.09,enableTransition:!1}):Mi("zoomOut",{zoomRate:.09,enableTransition:!1})});un(document,"keydown",mo),un(document,mousewheelEventName,co)},lo=()=>{hn(document,"keydown",mo),hn(document,mousewheelEventName,ho),mo=null,ho=null};return vue.watch(rn,()=>{vue.nextTick(()=>{Ke.value.complete||(Ge.value=!0)})}),vue.watch(qe,co=>{to(),$e("change",co)}),vue.onMounted(()=>{vue.nextTick(()=>{const co=document.querySelector("body");co.append?co.append(document.getElementById("x-image-viewer")):co.appendChild(document.getElementById("x-image-viewer")),Xr()})}),vue.onUnmounted(()=>{document.querySelector("body").removeChild(document.getElementById("x-image-viewer")),lo()}),(co,uo)=>{const od=vue.resolveComponent("el-icon-close"),rd=vue.resolveComponent("el-icon"),ld=vue.resolveComponent("el-icon-zoom-out"),hd=vue.resolveComponent("el-icon-zoom-in"),pd=vue.resolveComponent("el-icon-refresh-left"),fd=vue.resolveComponent("el-icon-refresh-right"),vd=vue.resolveComponent("el-icon-switch"),gd=vue.resolveComponent("el-icon-sort");return vue.openBlock(),vue.createElementBlock("template",null,[vue.createElementVNode("div",{id:"x-image-viewer",class:"x-image-viewer",style:vue.normalizeStyle({zIndex:m.zIndex})},[vue.createElementVNode("div",_hoisted_1$3,[vue.createElementVNode("div",{class:"x-image-viewer__mask",onClick:uo[0]||(uo[0]=vue.withModifiers(yd=>m.hideOnClickModal&&an(),["self"]))}),vue.createElementVNode("span",{class:"x-image-viewer__btn x-image-viewer__close",onClick:an},[vue.createVNode(rd,null,{default:vue.withCtx(()=>[vue.createVNode(od)]),_:1})]),st.value?vue.createCommentVNode("",!0):(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[vue.createElementVNode("span",{class:vue.normalizeClass(["x-image-viewer__btn x-image-viewer__prev",{"is-disabled":!m.infinite&&Mt.value}]),onClick:fo},uo[7]||(uo[7]=[vue.createElementVNode("i",{class:"el-icon-arrow-left"},null,-1)]),2),vue.createElementVNode("span",{class:vue.normalizeClass(["x-image-viewer__btn x-image-viewer__next",{"is-disabled":!m.infinite&&nn.value}]),onClick:dd},uo[8]||(uo[8]=[vue.createElementVNode("i",{class:"el-icon-arrow-right"},null,-1)]),2)],64)),rn.value.desc?(vue.openBlock(),vue.createElementBlock("div",_hoisted_2$3,vue.toDisplayString(rn.value.desc),1)):vue.createCommentVNode("",!0),vue.createElementVNode("div",_hoisted_3$2,[vue.createElementVNode("div",_hoisted_4$2,[vue.createVNode(rd,{onClick:uo[1]||(uo[1]=yd=>Mi("zoomOut"))},{default:vue.withCtx(()=>[vue.createVNode(ld)]),_:1}),vue.createVNode(rd,{onClick:uo[2]||(uo[2]=yd=>Mi("zoomIn"))},{default:vue.withCtx(()=>[vue.createVNode(hd)]),_:1}),uo[9]||(uo[9]=vue.createElementVNode("i",{class:"x-image-viewer__actions__divider"},null,-1)),vue.createVNode(rd,{onClick:Uo},{default:vue.withCtx(()=>[(vue.openBlock(),vue.createBlock(vue.resolveDynamicComponent(Qe.value.icon)))]),_:1}),uo[10]||(uo[10]=vue.createElementVNode("i",{class:"x-image-viewer__actions__divider"},null,-1)),vue.createVNode(rd,{onClick:uo[3]||(uo[3]=yd=>Mi("anticlocelise"))},{default:vue.withCtx(()=>[vue.createVNode(pd)]),_:1}),vue.createVNode(rd,{onClick:uo[4]||(uo[4]=yd=>Mi("clocelise"))},{default:vue.withCtx(()=>[vue.createVNode(fd)]),_:1}),vue.createVNode(rd,{onClick:uo[5]||(uo[5]=yd=>Mi("fliphorizontal"))},{default:vue.withCtx(()=>[vue.createVNode(vd)]),_:1}),vue.createVNode(rd,{onClick:uo[6]||(uo[6]=yd=>Mi("flipvertical"))},{default:vue.withCtx(()=>[vue.createVNode(gd)]),_:1})])]),vue.createElementVNode("div",{class:vue.normalizeClass(["x-image-viewer__canvas opacity-hide",[Ye.value===!0?"opacity-show animated "+m.animateClass:""]])},[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(m.urls,(yd,Td)=>vue.withDirectives((vue.openBlock(),vue.createElementBlock("img",{ref_for:!0,ref_key:"img",ref:Ke,key:yd,src:rn.value.src,style:vue.normalizeStyle(on.value),class:"x-image-viewer__img",onLoad:sn,onError:ln,onMousedown:fn},null,44,_hoisted_5$2)),[[vue.vShow,Td===qe.value]])),128))],2)])],4)])}}},index$6=_export_sfc(_sfc_main$3,[["__scopeId","data-v-bf955e52"]]),index$7=Object.freeze(Object.defineProperty({__proto__:null,default:index$6},Symbol.toStringTag,{value:"Module"})),_hoisted_1$2={class:"component-upload-image"},_hoisted_2$2={style:{display:"flex",width:"100%"}},_hoisted_3$1={key:0,class:"relative rounded overflow-hidden flex justify-center items-center",style:{width:"120px",height:"96px","margin-top":"8px"}},_hoisted_4$1={class:"absolute"},_hoisted_5$1=["onClick"],_hoisted_6$1={class:"relative overflow-hidden flex flex-col justify-center items-center w-full h-full select-none outline-none"},_hoisted_7$1=["src"],_hoisted_8$1=["viewBox"],_hoisted_9$1=["transform"],_hoisted_10$1=["xlink:href","width","height"],_hoisted_11$1={class:"photo-operations"},_hoisted_12$1={class:"absolute top-0 right-0 w-full flex justify-end gap-1"},_hoisted_13$1={class:"opacity-[0.7] hover:opacity-[1] rounded-1/2"},_hoisted_14$1={class:"opacity-[0.7] hover:opacity-[1] rounded-1/2"},_hoisted_15$1={class:"absolute bottom-0 w-full flex justify-center gap-1"},_hoisted_16$1={class:"opacity-[0.7] hover:opacity-[1] rounded-1/2"},_hoisted_17$1={class:"opacity-[0.7] hover:opacity-[1] rounded-1/2"},_hoisted_18$1=["onClick"],_hoisted_19$1={key:0,class:"el-upload__tip"},_hoisted_20$1={style:{color:"#f56c6c"}},_hoisted_21$1={style:{color:"#f56c6c"}},_sfc_main$2={__name:"index",props:{modelValue:[String,Object,Array],multipleSelect:{type:Boolean,default:!0},limit:{type:Number,default:5},fileMaxSize:{type:Number,default:5},fileType:{type:Array,default:()=>["png","jpg","jpeg","raw","tiff","jfif"]},isShowTip:{type:Boolean,default:!0},onDrop:{default:m=>{}},onBackPool:{default:m=>{}},defaultBg:String,disabled:{default:!1},size:{default:()=>({width:"148px",height:"148px"})},view:{type:String,default:null},operations:{default:()=>({back:!1,rotateLeft:!1,rotateRight:!1})},md5:{type:Object,default:()=>({requireMd5:!1,addFileMd5Url:"",queryFileMd5Url:""})},beginUploadFlow:{type:Array,default:()=>[]},oss:{type:Object,default:()=>({signatureUrl:""})}},setup(m,{expose:y,emit:v}){const $e=m,je=vue.useAttrs(),Ge=v;vue.ref(0),vue.ref([]);const Ye=vue.ref([]),qe=vue.computed(()=>$e.isShowTip&&($e.fileType||$e.fileMaxSize)),Ke=vue.inject("request"),[Qe,Je]=useOssUploader("",Ye,{request:Ke,fileType:$e.fileType,signatureUrl:$e.oss.signatureUrl,requireMd5:$e.md5.requireMd5,addFileMd5Url:$e.md5.addFileMd5Url,queryFileMd5Url:$e.md5.queryFileMd5Url,beginUploadFlow:$e.beginUploadFlow}),st=vue.ref(!1),Mt=vue.ref([]),nn=()=>{st.value=!1};function rn(){ElMessage.error(`上传文件数量不能超过 ${$e.limit} 个!`)}function on(){ElMessage.error("上传图片失败")}function an(Xr,lo){let co="";lo=lo||",";for(let uo in Xr)Xr[uo].url!==void 0&&Xr[uo].url.indexOf("blob:")!==0&&(co+=Xr[uo].url+lo);return co!=""?co.substr(0,co.length-1):""}function sn(Xr){console.log("enter"),Xr.preventDefault()}function ln(Xr){console.log("over"),Xr.preventDefault(),setTimeout(()=>{Xr.target.classList.add("over")},0)}function cn(Xr){console.log("drop"),Xr.preventDefault(),$e.onDrop&&$e.onDrop(Xr)}function un(Xr){$e.onBackPool&&$e.onBackPool(Xr)}function hn(Xr){dd(Xr)}function fn(Xr){Mt.value=[],Mt.value.push({src:Xr.url,desc:""}),st.value=!0}function to(Xr,lo){let co=[];for(let uo=0;uo<Xr.length;uo++){co[uo]=[];for(let od=0;od<lo[0].length;od++){let rd=0;for(let ld=0;ld<Xr[0].length;ld++)rd+=Xr[uo][ld]*lo[ld][od];co[uo][od]=rd}}return co}function Mi(Xr,lo){let co=Xr.hd=Xr.hd||0,uo=Xr.vd=Xr.vd||0,od=Xr.deg=Xr.deg||0,rd=Xr.viewBox,ld=Xr.matrix;if(lo=="rotateleft"){od+=90;let hd=[[Math.cos(90*(Math.PI/180)),-Math.sin(90*(Math.PI/180))],[Math.sin(90*(Math.PI/180)),Math.cos(90*(Math.PI/180))],[0,0]];ld=to(ld,hd),Xr.viewBox=Uo(Xr.hd!=co,Xr.vd!=uo,90,rd)}else if(lo=="rotateright"){od-=90;let hd=[[Math.cos(-90*(Math.PI/180)),-Math.sin(-90*(Math.PI/180))],[Math.sin(-90*(Math.PI/180)),Math.cos(-90*(Math.PI/180))],[0,0]];ld=to(ld,hd),Xr.viewBox=Uo(Xr.hd!=co,Xr.vd!=uo,-90,rd)}else lo=="fliphorizontal"?(co=co?0:1,ld=to(ld,[[-1,0],[0,1],[0,0]])):lo=="flipvertical"&&(uo=uo?0:1,ld=to(ld,[[1,0],[0,-1],[0,0]]));Xr.matrix=ld,Xr.deg=od,Xr.hd=co,Xr.vd=uo}function Uo(Xr,lo,co,uo){let od=JSON.parse(JSON.stringify(uo));const[rd,ld,hd,pd]=uo;if(Xr==!0&&(od[0]=od[0]==0-hd?0:0-hd),lo==!0&&(od[1]=od[1]==0-pd?0:0-pd),co){let fd=co/90%4;for(let vd=0;vd<Math.abs(fd);vd++)if(od[2]=pd,od[3]=hd,co>0){let gd=od[1];od[1]=od[0]==0-hd?0:0-hd,od[0]=gd}else{let gd=od[1];od[1]=od[0],od[0]=gd==0-pd?0:0-pd}}return od}const fo=Xr=>{Ye.value.push(Xr)},dd=Xr=>{Ye.value.indexOf(Xr)!=-1&&Ye.value.splice(Ye.value.indexOf(Xr),1)},mo=()=>{(Ye.value.length==0||Ye.value.every(Xr=>Xr.status=="success"))&&Ge("update:modelValue",Array.isArray($e.modelValue)?Ye.value:an(Ye.value))};function ho(Xr,lo,co){lo.url=lo.response.fileName,mo()}return vue.watch(()=>$e.modelValue,Xr=>{if(Xr)Qe.init(Xr);else return Ye.value=[]},{deep:!0,immediate:!0}),vue.watch(()=>Ye.value.length,()=>{console.log("imageupload filelist changed....."),mo()}),y({pushFile:fo,removeFile:dd}),(Xr,lo)=>{const co=vue.resolveComponent("el-icon"),uo=vue.resolveComponent("el-upload"),od=vue.resolveComponent("sy-svg-icon"),rd=vue.resolveComponent("sy-image-view");return vue.openBlock(),vue.createElementBlock("div",_hoisted_1$2,[vue.createElementVNode("div",_hoisted_2$2,[vue.createVNode(uo,vue.mergeProps({multiple:m.multipleSelect,ref:"imageUpload","show-file-list":!1,"file-list":Ye.value,"onUpdate:fileList":lo[0]||(lo[0]=ld=>Ye.value=ld),"http-request":vue.unref(Qe).onHttpRequest,"list-type":"picture-card",limit:m.limit,"on-success":ho,"on-change":vue.unref(Qe).onChange,"before-upload":vue.unref(Qe).onBeforeUpload,"on-error":on,"on-exceed":rn,class:{hidden:Ye.value.length>=m.limit,disabled:m.disabled},style:"width:"+(Ye.value.length>=m.limit?"auto":m.size.width)+";height:"+(Ye.value.length>=m.limit?"auto":m.size.height)+";"},vue.unref(je),{onDragenter:sn,onDragover:ln,onDrop:cn,"auto-upload":!0,disabled:m.disabled}),{default:vue.withCtx(()=>[vue.createElementVNode("div",{style:vue.normalizeStyle([{"background-position":"center","background-repeat":"no-repeat",width:"100%",height:"100%",display:"flex","justify-content":"center","align-items":"center"},m.defaultBg&&m.defaultBg!=""?"background-image:url("+m.defaultBg+");":""])},[!m.defaultBg||m.defaultBg==""?(vue.openBlock(),vue.createBlock(co,{key:0,class:"avatar-uploader-icon"},{default:vue.withCtx(()=>[vue.createVNode(vue.unref(plus_default))]),_:1})):vue.createCommentVNode("",!0)],4)]),_:1},16,["multiple","file-list","http-request","limit","on-change","before-upload","class","style","disabled"]),Ye.value.length>0?(vue.openBlock(),vue.createElementBlock("div",{key:0,class:vue.normalizeClass(["flex flex-wrap gap-2",{disabled:m.disabled,"ml-2":Ye.value.length<m.limit}])},[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(Ye.value,ld=>(vue.openBlock(),vue.createElementBlock("div",{key:ld.uid,class:"el-upload--picture-card",style:vue.normalizeStyle("width:"+m.size.width+";height:"+m.size.height+";")},[ld.status=="ready"||ld.status=="uploading"||ld.loading?(vue.openBlock(),vue.createElementBlock("div",_hoisted_3$1,[vue.createVNode(od,{"class-name":"icon-down","icon-class":"down"}),vue.createElementVNode("div",_hoisted_4$1,[ld.status=="uploading"?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[vue.createTextVNode("上传进度"+vue.toDisplayString(parseInt(ld.percentage||0))+"%",1)],64)):vue.createCommentVNode("",!0),ld.loading?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[vue.createTextVNode("加载进度"+vue.toDisplayString(parseInt(ld.loadingPercent||0))+"%",1)],64)):vue.createCommentVNode("",!0),ld.message?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:2},[vue.createTextVNode(vue.toDisplayString(ld.message),1)],64)):vue.createCommentVNode("",!0)])])):vue.createCommentVNode("",!0),ld.status=="success"&&!ld.loading?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[ld.loadError?vue.createCommentVNode("",!0):(vue.openBlock(),vue.createElementBlock("div",{key:0,onClick:hd=>fn(ld),class:"w-full h-full relative rounded overflow-hidden file-item"},[vue.createElementVNode("div",_hoisted_6$1,[m.view=="img"?(vue.openBlock(),vue.createElementBlock("img",{key:0,style:{width:"100%"},src:ld.objUrl,fit:"contain"},null,8,_hoisted_7$1)):(vue.openBlock(),vue.createElementBlock("svg",{key:1,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",viewBox:ld.viewBox.join(" "),xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[vue.createElementVNode("g",{class:"origin-top-left preserve-3d",transform:"matrix("+ld.matrix.join(",")+")"},[vue.createElementVNode("image",{"xlink:href":ld.objUrl,x:"0",y:"0",width:ld.width,height:ld.height},null,8,_hoisted_10$1)],8,_hoisted_9$1)],8,_hoisted_8$1))]),vue.createElementVNode("div",_hoisted_11$1,[vue.createElementVNode("div",_hoisted_12$1,[vue.withDirectives(vue.createElementVNode("div",_hoisted_13$1,[vue.createVNode(od,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(hd=>un(ld),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.back]]),vue.withDirectives(vue.createElementVNode("div",_hoisted_14$1,[vue.createVNode(od,{"class-name":"icon-photo ","icon-class":"close",onClick:vue.withModifiers(hd=>hn(ld),["stop"])},null,8,["onClick"])],512),[[vue.vShow,!m.operations.back]])]),vue.createElementVNode("div",_hoisted_15$1,[vue.withDirectives(vue.createElementVNode("div",_hoisted_16$1,[vue.createVNode(od,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(hd=>Mi(ld,"rotateleft"),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.rotateLeft]]),vue.withDirectives(vue.createElementVNode("div",_hoisted_17$1,[vue.createVNode(od,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(hd=>Mi(ld,"rotateright"),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.rotateRight]])])])],8,_hoisted_5$1)),ld.loadError?(vue.openBlock(),vue.createElementBlock("div",{key:1,onClick:hd=>vue.unref(Je)(ld),class:"w-full h-full relative rounded overflow-hidden file-item"},lo[1]||(lo[1]=[vue.createElementVNode("div",{class:"relative overflow-hidden flex flex-col justify-center items-center w-full h-full select-none outline-none"}," 加载失败 ",-1)]),8,_hoisted_18$1)):vue.createCommentVNode("",!0)],64)):vue.createCommentVNode("",!0)],4))),128))],2)):vue.createCommentVNode("",!0)]),qe.value?(vue.openBlock(),vue.createElementBlock("div",_hoisted_19$1,[lo[4]||(lo[4]=vue.createTextVNode(" 请上传 ")),m.fileMaxSize?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[lo[2]||(lo[2]=vue.createTextVNode(" 大小不超过 ")),vue.createElementVNode("b",_hoisted_20$1,vue.toDisplayString(m.fileMaxSize)+"MB",1)],64)):vue.createCommentVNode("",!0),m.fileType?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[lo[3]||(lo[3]=vue.createTextVNode(" 格式为 ")),vue.createElementVNode("b",_hoisted_21$1,vue.toDisplayString(m.fileType.join("/")),1)],64)):vue.createCommentVNode("",!0),lo[5]||(lo[5]=vue.createTextVNode(" 的文件 "))])):vue.createCommentVNode("",!0),st.value?(vue.openBlock(),vue.createBlock(rd,{key:1,urls:Mt.value,onClose:nn},null,8,["urls"])):vue.createCommentVNode("",!0)])}}},index$4=_export_sfc(_sfc_main$2,[["__scopeId","data-v-8342b270"]]),index$5=Object.freeze(Object.defineProperty({__proto__:null,default:index$4},Symbol.toStringTag,{value:"Module"})),_sfc_main$1={name:"SvgIcon",props:{iconClass:{type:String,required:!0},className:{type:String},title:{type:String,default:""}},computed:{iconName(){return`#icon-${this.iconClass}`},svgClass(){return this.className?"svg-icon "+this.className:"svg-icon"}}},_hoisted_1$1=["xlink:href"],_hoisted_2$1={key:0};function _sfc_render(m,y,v,$e,je,Ge){return vue.openBlock(),vue.createElementBlock("svg",{class:vue.normalizeClass(Ge.svgClass),"aria-hidden":"true"},[vue.createElementVNode("use",{"xlink:href":Ge.iconName},null,8,_hoisted_1$1),v.title?(vue.openBlock(),vue.createElementBlock("title",_hoisted_2$1,vue.toDisplayString(v.title),1)):vue.createCommentVNode("",!0)],2)}const index$2=_export_sfc(_sfc_main$1,[["render",_sfc_render],["__scopeId","data-v-f0bfb888"]]),index$3=Object.freeze(Object.defineProperty({__proto__:null,default:index$2},Symbol.toStringTag,{value:"Module"})),_hoisted_1={class:"tooth-wrapper"},_hoisted_2=["id","fill"],_hoisted_3=["id","fill"],_hoisted_4=["id","fill"],_hoisted_5=["id","fill"],_hoisted_6=["id","fill"],_hoisted_7=["id","fill"],_hoisted_8=["id","fill"],_hoisted_9=["id","fill"],_hoisted_10=["id","fill"],_hoisted_11=["id","fill"],_hoisted_12=["id","fill"],_hoisted_13=["id","fill"],_hoisted_14=["id","fill"],_hoisted_15=["id","fill"],_hoisted_16=["id","fill"],_hoisted_17=["id","fill"],_hoisted_18=["id","fill"],_hoisted_19=["id","fill"],_hoisted_20=["id","fill"],_hoisted_21=["id","fill"],_hoisted_22=["id","fill"],_hoisted_23=["id","fill"],_hoisted_24=["id","fill"],_hoisted_25=["id","fill"],_hoisted_26=["id","fill"],_hoisted_27=["id","fill"],_hoisted_28=["id","fill"],_hoisted_29=["id","fill"],_hoisted_30=["id","fill"],_hoisted_31=["id","fill"],_hoisted_32=["id","fill"],_hoisted_33=["id","fill"],_hoisted_34=["id","fill"],_hoisted_35=["id","fill"],_hoisted_36=["id","fill"],_hoisted_37=["id","fill"],_hoisted_38=["id","fill"],_hoisted_39=["id","fill"],_hoisted_40=["id","fill"],_hoisted_41=["id","fill"],_hoisted_42=["id","fill"],_hoisted_43=["id","fill"],_hoisted_44=["id","fill"],_hoisted_45=["id","fill"],_hoisted_46=["id","fill"],_hoisted_47=["id","fill"],_hoisted_48=["id","fill"],_hoisted_49=["id","fill"],_hoisted_50=["id","fill"],_hoisted_51=["id","fill"],_hoisted_52=["id","fill"],_hoisted_53=["id","fill"],_hoisted_54=["id"],_hoisted_55=["offset","stop-color"],_hoisted_56={style:{"text-align":"right",margin:"0","margin-top":"5px",display:"flex"}},_sfc_main={__name:"index",props:vue.mergeModels({symptomItems:{type:Array,default:()=>[]}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(m){const y=vue.useModel(m,"modelValue"),v=vue.ref({}),$e=vue.ref(null);vue.ref(!1);const je=m,Ge={1:[11,12,13,14,15,16,17,18],2:[21,22,23,24,25,26,27,28],3:[31,32,33,34,35,36,37,38],4:[41,42,43,44,45,46,47,48],5:[51,52,53,54,55],6:[61,62,63,64,65],7:[71,72,73,74,75],8:[81,82,83,84,85]},Ye=vue.ref([]),qe=vue.ref(!1),Ke=vue.ref(0),Qe=un=>{un&&Ye.value.push(un)},Je=vue.computed(()=>Ye.value[Ke.value]),st=vue.ref([]),Mt=un=>{un.target.focus(),console.log("focus:"+un.target.id),Ke.value=Array.from($e.value.children).indexOf(un.target);const hn=Je.value.attributes.id.value;v.value.hasOwnProperty(hn)?st.value=JSON.parse(JSON.stringify(v.value[hn])):st.value=[],qe.value=!0},nn=un=>{un.target.classList.contains("tooth")&&console.log("blur:"+un.target.id)},rn=un=>{const hn={};return un&&un.split(".").forEach(fn=>{const[to,Mi]=fn.split("|");hn[to]=Mi?Mi.split(","):[]}),hn},on=()=>{const un=Object.keys(v.value).reduce((hn,fn)=>(hn.push(fn+"|"+v.value[fn].join(",")),hn),[]).join(".");y.value=un,console.log(un)},an=un=>v.value.hasOwnProperty(un)?v.value[un].length==0?["green"]:v.value[un].map(fn=>je.symptomItems.filter(Mi=>Mi.value==fn)[0].color||"green"):["white"],sn=un=>v.value.hasOwnProperty(un)?"url(#pos-"+un+")":"white",ln=()=>{const un=Je.value.attributes.id.value;v.value[un]=st.value,qe.value=!1},cn=()=>{delete v.value[Je.value.attributes.id.value],qe.value=!1};return vue.onMounted(()=>{v.value=rn(y.value)}),vue.watch(()=>y.value,un=>{v.value=rn(y.value)}),vue.watch(()=>v.value,un=>{on()},{deep:!0}),(un,hn)=>{const fn=vue.resolveComponent("el-checkbox"),to=vue.resolveComponent("el-checkbox-group"),Mi=vue.resolveComponent("el-button"),Uo=vue.resolveComponent("el-popover");return vue.openBlock(),vue.createElementBlock("div",_hoisted_1,[(vue.openBlock(),vue.createElementBlock("svg",{ref_key:"svgContainer",ref:$e,width:"100%",height:"220",viewBox:"0 0 702 301",fill:"none",xmlns:"http://www.w3.org/2000/svg",onFocusout:nn},[vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][0])}]),id:Ge[4][0],fill:sn(Ge[4][0]),d:"M328.584 212.314C333.583 210.518 342.343 201.534 337.392 179.975L319.537 179.975C316.998 188.509 315.252 206.924 328.584 212.314Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_2),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][1])}]),id:Ge[4][1],fill:sn(Ge[4][1]),d:"M298.011 213.017C303.177 211.181 312.229 202.003 307.113 179.975L288.663 179.975C286.039 188.694 284.235 207.51 298.011 213.017Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_3),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][2])}]),id:Ge[4][2],fill:sn(Ge[4][2]),d:"M264.101 220.047C271.163 216.79 283.462 205.517 276.161 186.491C272.771 182.06 269.533 180.301 268.338 179.975L258.234 179.975C253.888 182.147 246.37 190.4 251.063 206.038C252.584 210.382 257.321 219.266 264.101 220.047Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_4),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][3])}]),id:Ge[4][3],fill:sn(Ge[4][3]),d:"M227.041 213.017C232.874 211.181 243.094 202.003 237.317 179.975L216.487 179.975C213.525 188.694 211.488 207.51 227.041 213.017Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_5),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][4])}]),id:Ge[4][4],fill:sn(Ge[4][4]),d:"M190.294 212.745C198.375 208.785 209.066 196.576 198.872 179.703L181.648 179.703C175.318 186.633 172.157 205.364 190.294 212.745Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_6),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][5])}]),id:Ge[4][5],fill:sn(Ge[4][5]),d:"M160.385 179H127.669C123.255 186.823 123.728 194.832 124.516 197.859C126.881 212.177 154.866 210.78 161.961 205.542C170.633 193.668 163.801 181.91 160.385 179Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_7),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][6])}]),id:Ge[4][6],fill:sn(Ge[4][6]),d:"M111.187 179.272H82.0111C78.0742 187.146 78.496 195.207 79.199 198.254C81.3081 212.666 106.266 211.26 112.593 205.987C120.326 194.035 114.233 182.201 111.187 179.272Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_8),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[4][7])}]),id:Ge[4][7],fill:sn(Ge[4][7]),d:"M63.624 179.272H34.4483C30.5114 187.146 30.9332 195.207 31.6362 198.254C33.7453 212.666 58.7028 211.26 65.03 205.987C72.7633 194.035 66.6704 182.201 63.624 179.272Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_9),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][7])}]),id:Ge[3][7],fill:sn(Ge[3][7]),d:"M659.815 179H630.639C626.702 186.874 627.124 194.935 627.827 197.982C629.936 212.394 654.894 210.988 661.221 205.715C668.954 193.764 662.861 181.929 659.815 179Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_10),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][6])}]),id:Ge[3][6],fill:sn(Ge[3][6]),d:"M612.712 179H583.537C579.6 186.874 580.021 194.935 580.724 197.982C582.833 212.394 607.791 210.988 614.118 205.715C621.851 193.764 615.759 181.929 612.712 179Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_11),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][5])}]),id:Ge[3][5],fill:sn(Ge[3][5]),d:"M563.219 179H530.503C526.089 186.823 526.562 194.832 527.35 197.859C529.715 212.177 557.701 210.78 564.796 205.542C573.467 193.668 566.635 181.91 563.219 179Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_12),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][4])}]),id:Ge[3][4],fill:sn(Ge[3][4]),d:"M504.597 212.042C512.678 208.082 523.369 195.873 513.175 179L495.951 179C489.621 185.93 486.46 204.66 504.597 212.042Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_13),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][3])}]),id:Ge[3][3],fill:sn(Ge[3][3]),d:"M467.744 212.745C473.576 210.91 483.797 201.731 478.02 179.703L457.19 179.703C454.227 188.423 452.19 207.238 467.744 212.745Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_14),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][2])}]),id:Ge[3][2],fill:sn(Ge[3][2]),d:"M433.095 219.776C440.157 216.518 452.455 205.245 445.154 186.219C441.765 181.788 438.527 180.029 437.332 179.703L427.228 179.703C422.882 181.875 415.363 190.128 420.057 205.766C421.578 210.11 426.315 218.994 433.095 219.776Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_15),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][1])}]),id:Ge[3][1],fill:sn(Ge[3][1]),d:"M398.108 212.745C403.274 210.91 412.326 201.731 407.21 179.703L388.76 179.703C386.136 188.423 384.332 207.238 398.108 212.745Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_16),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[3][0])}]),id:Ge[3][0],fill:sn(Ge[3][0]),d:"M367.517 212.042C372.516 210.246 381.277 201.263 376.325 179.703L358.471 179.703C355.932 188.237 354.186 206.652 367.517 212.042Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_17),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][7])}]),id:Ge[2][7],fill:sn(Ge[2][7]),d:"M636.739 125.842C629.99 116.562 635.099 106.743 638.497 102.993H659.236C667.672 114.242 663.688 122.913 660.642 125.842C652.792 125.959 637.02 126.123 636.739 125.842Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_18),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][6])}]),id:Ge[2][6],fill:sn(Ge[2][6]),d:"M591.401 126.193C586.339 114.945 590.932 103.696 593.862 99.4783H616.007C625.568 107.915 623.037 120.803 620.577 126.193H591.401Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_19),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][5])}]),id:Ge[2][5],fill:sn(Ge[2][5]),d:"M539.613 126.193C529.211 114.382 536.45 101.587 541.37 96.6662H569.133C581.785 109.363 576.748 121.641 572.648 126.193H539.613Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_20),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][4])}]),id:Ge[2][4],fill:sn(Ge[2][4]),d:"M507.937 126.193C495.564 112.414 506.765 100.767 513.913 96.6662C529.942 109.321 524.341 121.624 519.537 126.193H507.937Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_21),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][3])}]),id:Ge[2][3],fill:sn(Ge[2][3]),d:"M471.38 116.702C467.443 101.517 476.769 94.6743 481.925 93.1511C488.393 95.1196 491.181 101.236 491.767 104.048C495.142 114.453 490.361 123.381 487.549 126.545H480.167C473.7 123.452 471.614 118.694 471.38 116.702Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_22),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][2])}]),id:Ge[2][2],fill:sn(Ge[2][2]),d:"M444.313 82.2542C436.697 85.7693 423.433 97.9317 431.307 118.46C434.963 123.241 438.454 125.139 439.743 125.49H450.64C455.327 123.147 463.435 114.242 458.374 97.3692C456.733 92.6824 451.625 83.0978 444.313 82.2542Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_23),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][1])}]),id:Ge[2][1],fill:sn(Ge[2][1]),d:"M407.404 90.6905C402.717 92.9167 394.609 102.993 399.671 125.49H417.598C420.059 116.351 421.465 96.5959 407.404 90.6905Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_24),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[2][0])}]),id:Ge[2][0],fill:sn(Ge[2][0]),d:"M372.253 83.6602C364.871 86.0036 351.935 97.7207 359.247 125.842H385.61C389.36 114.711 391.937 90.6905 372.253 83.6602Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_25),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][0])}]),id:Ge[1][0],fill:sn(Ge[1][0]),d:"M320.58 82.9572C312.613 85.5349 299.068 97.7911 308.629 126.193H332.883C336.516 114.828 339.14 90.2687 320.58 82.9572Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_26),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][1])}]),id:Ge[1][1],fill:sn(Ge[1][1]),d:"M278.047 126.193C270.173 106.227 279.688 94.2056 285.429 90.6905C300.895 100.533 297.498 118.46 293.865 126.193H278.047Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_27),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][2])}]),id:Ge[1][2],fill:sn(Ge[1][2]),d:"M235.163 117.406C228.695 97.4395 242.779 86.3552 250.629 83.3087C261.034 86.402 264.807 92.5652 265.393 95.2602V118.109C265.393 122.608 260.706 125.373 258.362 126.193H246.762C241.841 124.787 237.623 122.327 235.163 117.406Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_28),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][3])}]),id:Ge[1][3],fill:sn(Ge[1][3]),d:"M207.393 126.545C194.176 110.516 204.932 99.0096 211.963 95.2602C229.96 104.54 223.445 119.983 217.938 126.545H207.393Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_29),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][4])}]),id:Ge[1][4],fill:sn(Ge[1][4]),d:"M179.626 96.47C173.321 99.4891 163.444 109.73 174.372 126.54C174.372 126.83 182.778 126.661 186.981 126.54C191.652 118.69 196.088 102.629 179.626 96.47Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_30),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][5])}]),id:Ge[1][5],fill:sn(Ge[1][5]),d:"M121.276 126.193C110.874 114.382 118.113 101.587 123.033 96.6662H150.796C163.448 109.363 158.41 121.641 154.31 126.193H121.276Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_31),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][6])}]),id:Ge[1][6],fill:sn(Ge[1][6]),d:"M74.1694 126.193C69.1076 114.945 73.7007 103.696 76.6299 99.4783H98.7753C108.336 107.915 105.806 120.803 103.345 126.193H74.1694Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_32),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[1][7])}]),id:Ge[1][7],fill:sn(Ge[1][7]),d:"M34.4483 125.842C27.6993 116.562 32.8079 106.743 36.2059 102.993H56.9452C65.3815 114.242 61.3977 122.913 58.3512 125.842C50.5008 125.959 34.7295 126.123 34.4483 125.842Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_33),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[8][0])}]),id:Ge[8][0],fill:sn(Ge[8][0]),d:"M328.148 277.424C333.147 275.627 341.907 266.644 336.956 245.085L319.102 245.085C316.562 253.619 314.817 272.034 328.148 277.424Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_34),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[8][1])}]),id:Ge[8][1],fill:sn(Ge[8][1]),d:"M297.575 278.127C302.741 276.291 311.793 267.113 306.677 245.085L288.227 245.085C285.603 253.804 283.799 272.62 297.575 278.127Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_35),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[8][2])}]),id:Ge[8][2],fill:sn(Ge[8][2]),d:"M263.665 285.157C270.727 281.899 283.026 270.627 275.725 251.6C272.335 247.17 269.097 245.41 267.902 245.085L257.798 245.085C253.452 247.256 245.934 255.51 250.627 271.148C252.149 275.492 256.886 284.375 263.665 285.157Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_36),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[8][3])}]),id:Ge[8][3],fill:sn(Ge[8][3]),d:"M226.605 278.127C232.438 276.291 242.658 267.113 236.881 245.085L216.051 245.085C213.089 253.804 211.052 272.62 226.605 278.127Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_37),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[8][4])}]),id:Ge[8][4],fill:sn(Ge[8][4]),d:"M190.294 278.127C198.375 274.167 209.066 261.957 198.872 245.085L181.648 245.085C175.318 252.015 172.157 270.745 190.294 278.127Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_38),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[7][4])}]),id:Ge[7][4],fill:sn(Ge[7][4]),d:"M504.597 277.424C512.678 273.464 523.369 261.254 513.175 244.382L495.951 244.382C489.621 251.312 486.46 270.042 504.597 277.424Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_39),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[7][3])}]),id:Ge[7][3],fill:sn(Ge[7][3]),d:"M467.744 278.127C473.576 276.291 483.797 267.113 478.02 245.085L457.19 245.085C454.227 253.804 452.19 272.62 467.744 278.127Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_40),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[7][2])}]),id:Ge[7][2],fill:sn(Ge[7][2]),d:"M433.095 285.157C440.157 281.899 452.455 270.627 445.154 251.6C441.765 247.17 438.527 245.41 437.332 245.085L427.228 245.085C422.882 247.256 415.363 255.51 420.057 271.148C421.578 275.492 426.315 284.375 433.095 285.157Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_41),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[7][1])}]),id:Ge[7][1],fill:sn(Ge[7][1]),d:"M398.108 278.127C403.274 276.291 412.326 267.113 407.21 245.085L388.76 245.085C386.136 253.804 384.332 272.62 398.108 278.127Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_42),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[7][0])}]),id:Ge[7][0],fill:sn(Ge[7][0]),d:"M367.517 277.424C372.516 275.627 381.277 266.644 376.325 245.085L358.471 245.085C355.932 253.619 354.186 272.034 367.517 277.424Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_43),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[6][4])}]),id:Ge[6][4],fill:sn(Ge[6][4]),d:"M507.937 57.9997C495.564 44.2204 506.765 32.5736 513.913 28.4726C529.942 41.1271 524.341 53.4301 519.537 57.9997H507.937Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_44),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[6][3])}]),id:Ge[6][3],fill:sn(Ge[6][3]),d:"M471.38 48.5089C467.443 33.3235 476.769 26.4807 481.925 24.9575C488.393 26.9259 491.181 33.0423 491.767 35.8544C495.142 46.2592 490.361 55.1876 487.549 58.3512H480.167C473.7 55.2579 471.614 50.5008 471.38 48.5089Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_45),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[6][2])}]),id:Ge[6][2],fill:sn(Ge[6][2]),d:"M444.313 14.0605C436.697 17.5757 423.433 29.738 431.307 50.2664C434.963 55.047 438.454 56.9452 439.743 57.2967H450.64C455.327 54.9533 463.435 46.0483 458.374 29.1756C456.733 24.4888 451.625 14.9042 444.313 14.0605Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_46),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[6][1])}]),id:Ge[6][1],fill:sn(Ge[6][1]),d:"M407.404 22.4969C402.717 24.7231 394.609 34.7998 399.671 57.2967H417.598C420.059 48.1573 421.465 28.4023 407.404 22.4969Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_47),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[6][0])}]),id:Ge[6][0],fill:sn(Ge[6][0]),d:"M372.253 15.4666C364.871 17.81 351.935 29.5271 359.247 57.6482H385.61C389.36 46.517 391.937 22.4969 372.253 15.4666Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_48),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[5][0])}]),id:Ge[5][0],fill:sn(Ge[5][0]),d:"M320.58 14.7636C312.613 17.3413 299.068 29.5974 308.629 57.9997H332.883C336.516 46.6341 339.14 22.075 320.58 14.7636Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_49),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[5][1])}]),id:Ge[5][1],fill:sn(Ge[5][1]),d:"M278.047 57.9997C270.173 38.0338 279.688 26.012 285.429 22.4969C300.895 32.3392 297.498 50.2664 293.865 57.9997H278.047Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_50),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[5][2])}]),id:Ge[5][2],fill:sn(Ge[5][2]),d:"M235.163 49.2119C228.695 29.2459 242.779 18.1615 250.629 15.1151C261.034 18.2084 264.807 24.3716 265.393 27.0665V49.9149C265.393 54.4143 260.706 57.1795 258.362 57.9997H246.762C241.841 56.5937 237.623 54.1331 235.163 49.2119Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_51),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[5][3])}]),id:Ge[5][3],fill:sn(Ge[5][3]),d:"M207.393 58.3512C194.176 42.3222 204.932 30.816 211.963 27.0665C229.96 36.3465 223.445 51.7897 217.938 58.3512H207.393Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_52),vue.createElementVNode("path",{tabindex:"0",ref:Qe,onClick:Mt,class:vue.normalizeClass(["tooth",{actived:v.value.hasOwnProperty(Ge[5][4])}]),id:Ge[5][4],fill:sn(Ge[5][4]),d:"M179.626 28.2764C173.321 31.2955 163.444 41.5362 174.372 58.3465C174.372 58.6363 182.778 58.4673 186.981 58.3465C191.652 50.4969 196.088 34.4353 179.626 28.2764Z",stroke:"#969696","stroke-width":"2"},null,10,_hoisted_53),hn[2]||(hn[2]=vue.createElementVNode("path",{class:"tooth",fill:"white",d:"M29.8787 152.908H665.063",stroke:"#CCE6FB","stroke-width":"2"},null,-1)),hn[3]||(hn[3]=vue.createElementVNode("path",{class:"tooth",fill:"white",d:"M347.295 78.739V225.672",stroke:"#CCE6FB","stroke-width":"2"},null,-1)),vue.createElementVNode("defs",null,[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(Object.keys(v.value),fo=>(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,[v.value[fo]?(vue.openBlock(),vue.createElementBlock("linearGradient",{key:0,id:"pos-"+fo,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(an(fo),(dd,mo)=>(vue.openBlock(),vue.createElementBlock("stop",{key:mo,offset:`${mo/(an(fo).length-1||1)*100}%`,"stop-color":dd},null,8,_hoisted_55))),128))],8,_hoisted_54)):vue.createCommentVNode("",!0)],64))),256))])],544)),vue.createVNode(Uo,{visible:qe.value,"virtual-ref":Je.value,"virtual-triggering":"",trigger:"click",title:"选择牙齿状况",width:"200"},{default:vue.withCtx(()=>[vue.createElementVNode("div",null,[vue.createVNode(to,{modelValue:st.value,"onUpdate:modelValue":hn[0]||(hn[0]=fo=>st.value=fo)},{default:vue.withCtx(()=>[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(m.symptomItems,fo=>(vue.openBlock(),vue.createBlock(fn,{label:fo.label,value:fo.value},null,8,["label","value"]))),256))]),_:1},8,["modelValue"])]),vue.createElementVNode("div",_hoisted_56,[vue.createVNode(Mi,{size:"small",text:"",onClick:cn},{default:vue.withCtx(()=>hn[4]||(hn[4]=[vue.createTextVNode("清除")])),_:1}),vue.createVNode(Mi,{size:"small",text:"",onClick:hn[1]||(hn[1]=fo=>qe.value=!1)},{default:vue.withCtx(()=>hn[5]||(hn[5]=[vue.createTextVNode("取消")])),_:1}),vue.createVNode(Mi,{size:"small",type:"primary",onClick:ln},{default:vue.withCtx(()=>hn[6]||(hn[6]=[vue.createTextVNode(" 确定 ")])),_:1})])]),_:1},8,["visible","virtual-ref"])])}}},index=_export_sfc(_sfc_main,[["__scopeId","data-v-76426ce9"]]),index$1=Object.freeze(Object.defineProperty({__proto__:null,default:index},Symbol.toStringTag,{value:"Module"}));return index$b});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { reactive as yf } from "vue";
|
|
2
2
|
import { g as bf } from "./_commonjsHelpers-C6fGbg64.js";
|
|
3
|
-
import { E as xf } from "./index-
|
|
3
|
+
import { E as xf } from "./index-DvIP0lLx.js";
|
|
4
4
|
function Ru(r, t) {
|
|
5
5
|
return function() {
|
|
6
6
|
return r.apply(t, arguments);
|
|
@@ -21164,11 +21164,11 @@ function Qx(r, t, e = {
|
|
|
21164
21164
|
}) {
|
|
21165
21165
|
let n = 1;
|
|
21166
21166
|
const o = async function(c) {
|
|
21167
|
-
|
|
21167
|
+
console.log("111111111111111111112222222222222222222223333333333");
|
|
21168
21168
|
let l = c.url;
|
|
21169
21169
|
if (c.objUrl)
|
|
21170
21170
|
return c.objUrl;
|
|
21171
|
-
if (!c.loading)
|
|
21171
|
+
if (!c.loading && !c.loadError)
|
|
21172
21172
|
return c.loading = !0, c.loadError = !1, await Te({
|
|
21173
21173
|
method: "GET",
|
|
21174
21174
|
url: l,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { inject, ref, defineComponent, getCurrentInstance, watch, provide, createVNode, Fragment, mergeProps, resolveComponent, computed, createTextVNode, h, onMounted, isVNode, withDirectives, resolveDirective } from "vue";
|
|
2
2
|
import draggable from "vuedraggable";
|
|
3
3
|
import { i as insertCustomCssToHead } from "./css-Ck5wARX-.js";
|
|
4
|
-
import { u as useTemplateUtils } from "./index-
|
|
5
|
-
import { E as ElMessage } from "./index-
|
|
4
|
+
import { u as useTemplateUtils } from "./index-IeR0F5G0.js";
|
|
5
|
+
import { E as ElMessage } from "./index-DvIP0lLx.js";
|
|
6
6
|
function isNull(n) {
|
|
7
7
|
return n == null;
|
|
8
8
|
}
|
|
@@ -2,7 +2,7 @@ import { mergeModels as _e, inject as oe, ref as U, useModel as te, watch as we,
|
|
|
2
2
|
import D from "vuedraggable";
|
|
3
3
|
import { _ as ae } from "./index-DYcISXeA.js";
|
|
4
4
|
import Me from "./index-DmjTLesN.js";
|
|
5
|
-
import { b as ze, a as He } from "./index-
|
|
5
|
+
import { b as ze, a as He } from "./index-IeR0F5G0.js";
|
|
6
6
|
import { e as qe, i as Ae } from "./css-Ck5wARX-.js";
|
|
7
7
|
import { _ as Ee } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
8
8
|
const Ne = { style: {} }, Te = { style: {} }, Ie = { style: {} }, We = { style: {} }, $e = { key: 0 }, Be = { class: "dialog-footer" }, Fe = { key: 1 }, Re = { class: "dialog-footer" }, Pe = { key: 2 }, je = { class: "dialog-footer" }, Oe = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref as _, resolveComponent as s, createElementBlock as p, openBlock as d, Fragment as y, createVNode as l, createCommentVNode as b, withCtx as t, renderList as N, unref as u, createBlock as $, mergeProps as E, createElementVNode as v, createTextVNode as i, toDisplayString as I } from "vue";
|
|
2
|
-
import { a as R, b as X, c as Y } from "./index-
|
|
2
|
+
import { a as R, b as X, c as Y } from "./index-IeR0F5G0.js";
|
|
3
3
|
import { _ as Z } from "./index-DYcISXeA.js";
|
|
4
4
|
import O from "vuedraggable";
|
|
5
5
|
import { _ as h } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|