sy-form-designer 1.0.45 → 1.0.46
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-kcIxGzRD.js → designer-BOZ1HBGM.js} +1 -1
- package/{index-FijTrnzc.js → index-BP-uCkyK.js} +1 -1
- package/{index-Bb5LLzeS.js → index-Bag_JJe4.js} +1 -1
- package/{index-tIoOCl2-.js → index-DOSmBh1u.js} +1 -1
- package/{index-BORbrSP5.js → index-DUOv0cU2.js} +3 -3
- package/index.js +1 -1
- package/index.umd.cjs +2 -2
- package/{ossHook-BIBivO-f.js → ossHook-DaQ1xzEh.js} +8 -6
- package/package.json +1 -1
- package/{render-BMkfEoty.js → render-CPfcptNe.js} +2 -2
- package/{settings-BUvNvGbc.js → settings-CADVb010.js} +1 -1
- package/{widgets-2-Iq9Sf8.js → widgets-Bh14Em91.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-CADVb010.js";
|
|
3
3
|
import { _ as te } from "./index-C1OyATSu.js";
|
|
4
4
|
const ne = { class: "form-designer" }, ae = { class: "toolbar-container" }, de = {
|
|
5
5
|
class: "right-toolbar",
|
|
@@ -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-DaQ1xzEh.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"
|
|
@@ -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-CPfcptNe.js"), "./libs/panels/settings.vue": () => import("./settings-CADVb010.js"), "./libs/panels/widgets.vue": () => import("./widgets-Bh14Em91.js") }), Er = /* @__PURE__ */ Object.assign({ "./libs/designer.vue": () => import("./designer-BOZ1HBGM.js") }), go = /* @__PURE__ */ Object.assign({ "./libs/extensions/file-upload/index.vue": () => import("./index-BP-uCkyK.js"), "./libs/extensions/image-view/index.vue": () => import("./index-DWYaW2hS.js"), "./libs/extensions/picture-upload/index.vue": () => import("./index-DUOv0cU2.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));
|
|
@@ -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-Bag_JJe4.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;
|
|
@@ -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-DaQ1xzEh.js";
|
|
3
|
+
import { p as ge } from "./index-Bag_JJe4.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-DOSmBh1u.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",
|
package/index.js
CHANGED
package/index.umd.cjs
CHANGED
|
@@ -4967,7 +4967,7 @@ Manifest JSON has weights with names: `+Ke.join(", ")+".");return Je=je.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 Ge in $e)$e.hasOwnProperty(Ge)&&(v[Ge]=$e[Ge])},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,Ge=arguments.length;$e<Ge;$e++){v=arguments[$e];for(var je in v)Object.prototype.hasOwnProperty.call(v,je)&&(y[je]=v[je])}return y},__assign.apply(this,arguments)};function __awaiter(m,y,v,$e){function Ge(je){return je instanceof v?je:new v(function(Ye){Ye(je)})}return new(v||(v=Promise))(function(je,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?je(Je.value):Ge(Je.value).then(qe,Ke)}Qe(($e=$e.apply(m,[])).next())})}function __generator(m,y){var v={label:0,sent:function(){if(je[0]&1)throw je[1];return je[1]},trys:[],ops:[]},$e,Ge,je,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,Ge&&(je=Qe[0]&2?Ge.return:Qe[0]?Ge.throw||((je=Ge.return)&&je.call(Ge),0):Ge.next)&&!(je=je.call(Ge,Qe[1])).done)return je;switch(Ge=0,je&&(Qe=[Qe[0]&2,je.value]),Qe[0]){case 0:case 1:je=Qe;break;case 4:return v.label++,{value:Qe[1],done:!1};case 5:v.label++,Ge=Qe[1],Qe=[0];continue;case 7:Qe=v.ops.pop(),v.trys.pop();continue;default:if(je=v.trys,!(je=je.length>0&&je[je.length-1])&&(Qe[0]===6||Qe[0]===2)){v=0;continue}if(Qe[0]===3&&(!je||Qe[1]>je[0]&&Qe[1]<je[3])){v.label=Qe[1];break}if(Qe[0]===6&&v.label<je[1]){v.label=je[1],je=Qe;break}if(je&&v.label<je[2]){v.label=je[2],v.ops.push(Qe);break}je[2]&&v.ops.pop(),v.trys.pop();continue}Qe=y.call(m,v)}catch(Je){Qe=[6,Je],Ge=0}finally{$e=je=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),Ge=0,y=0;y<v;y++)for(var je=arguments[y],Ye=0,qe=je.length;Ye<qe;Ye++,Ge++)$e[Ge]=je[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,Ge=y/Math.max($e,v);return new Dimensions(Math.round(v*Ge),Math.round($e*Ge))}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,Ge){return y+Ge*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||{},Ge=[$e.left,$e.top,$e.right,$e.bottom].every(isValidNumber),je=[$e.x,$e.y,$e.width,$e.height].every(isValidNumber);if(!je&&!Ge)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify($e));var Ye=je?[$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],Ge=y[2],je=y[3];return new m({x:v,y:$e,width:Ge,height:je})},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],Ge=y[2],je=y[3];return new m({x:v,y:$e,width:Ge,height:je})},m.prototype.toSquare=function(){var y=this,v=y.x,$e=y.y,Ge=y.width,je=y.height,Ye=Math.abs(Ge-je);return Ge<je&&(v-=Ye/2,Ge+=Ye),je<Ge&&($e-=Ye/2,je+=Ye),new m({x:v,y:$e,width:Ge,height:je})},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],Ge=$e[0],je=$e[1],Ye=$e[2],qe=$e[3];return new m({x:Ge,y:je,width:Ye,height:qe})},m.prototype.clipAtImageBorders=function(y,v){var $e=this,Ge=$e.x,je=$e.y,Ye=$e.right,qe=$e.bottom,Ke=Math.max(Ge,0),Qe=Math.max(je,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,Ge=$e.width,je=$e.height,Ye=this.x+y,qe=this.y+v;return new m({x:Ye,y:qe,width:Ge,height:je})},m.prototype.padAtBorders=function(y,v){var $e=this.width+1,Ge=this.height+1,je=1,Ye=1,qe=$e,Ke=Ge,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+Ge,Mt=y),Qe<1&&(Ke=2-Qe,Qe=1),Je<1&&(Ke=2-Je,Je=1),{dy:Ye,edy:Ke,dx:je,edx:qe,y:Je,ey:Mt,x:Qe,ex:st,w:$e,h:Ge}},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,Ge,je,Ye){return Ye===void 0&&(Ye=!1),m.call(this,{left:v,top:$e,right:Ge,bottom:je},Ye)||this}return y}(Box),ObjectDetection=function(){function m(y,v,$e,Ge,je){this._imageDims=new Dimensions(je.width,je.height),this._score=y,this._classScore=v,this._className=$e,this._box=new Box(Ge).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,Ge){return m.call(this,v,v,"",$e,Ge)||this}return y.prototype.forSize=function(v,$e){var Ge=m.prototype.forSize.call(this,v,$e),je=Ge.score,Ye=Ge.relativeBox,qe=Ge.imageDims;return new y(je,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)),Ge=Math.max(0,Math.min(m.bottom,y.bottom)-Math.max(m.top,y.top)),je=$e*Ge;return v?je/(m.area+y.area-je):je/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),Ge=v.reduce(function(qe,Ke){return Ke<qe?Ke:qe},1/0),je=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,Ge,je,Ye)}function nonMaxSuppression$1(m,y,v,$e){$e===void 0&&($e=!0);for(var Ge=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}),je=[],Ye=function(){var qe=Ge.pop();je.push(qe);for(var Ke=Ge,Qe=[],Je=0;Je<Ke.length;Je++){var st=Ke[Je],Mt=m[qe],nn=m[st];Qe.push(iou(Mt,nn,$e))}Ge=Ge.filter(function(rn,on){return Qe[on]<=v})};Ge.length>0;)Ye();return je}function normalize$1(m,y){return Ze(function(){var v=y[0],$e=y[1],Ge=y[2],je=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]),Ge),Ke=Yn([je,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],Ge=v[1];if($e===Ge)return m;var je=Math.abs($e-Ge),Ye=Math.round(je*(y?.5:1)),qe=$e>Ge?2:1,Ke=function(nn){var rn=m.shape.slice();return rn[qe]=nn,Hn(rn,0)},Qe=Ke(Ye),Je=je-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,Ge,je,Ye){return Ye===void 0&&(Ye=!1),m.call(this,{x:v,y:$e,width:Ge,height:je},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 Ge=v.width,je=v.height;this._imgDims=new Dimensions(Ge,je),this._shift=$e,this._positions=y.map(function(Ye){return Ye.mul(new Point(Ge,je)).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 Ge=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},v),je=Ge.useDlibAlignment,Ye=Ge.minBoxPadding;return je?this.alignDlib():this.alignMinBbox(Ye)},m.prototype.alignDlib=function(){var y=this.getRefPointsForAlignment(),v=y[0],$e=y[1],Ge=y[2],je=function(st){return Ge.sub(st).magnitude()},Ye=(je(v)+je($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 Ge=m.call(this,v)||this;return Ge._label=$e,Ge}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,Ge,je){var Ye=m.call(this,v,$e)||this;return Ye._score=Ge,Ye._classScore=je,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(Ge,je){m.readFile($e,function(Ye,qe){return Ye?je(Ye):Ge(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")},Ge=global.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},je=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:Ge},je)}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,Ge=$e===void 0?environment.Image:$e;environment.Canvas=v,environment.Image=Ge,environment.createCanvasElement=m.createCanvasElement||function(){return new v},environment.createImageElement=m.createImageElement||function(){return new Ge},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 Ge=resolveInput(m);if(!(Ge instanceof v))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var je=Ge.getContext("2d");if(!je)throw new Error("resolveContext2d - canvas 2d context is null");return je}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(je){je.currentTarget&&(je.currentTarget.removeEventListener("load",$e),je.currentTarget.removeEventListener("error",Ge),y(je))}function Ge(je){je.currentTarget&&(je.currentTarget.removeEventListener("load",$e),je.currentTarget.removeEventListener("error",Ge),v(je))}m.addEventListener("load",$e),m.addEventListener("error",Ge)})}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,Ge=$e();return Ge.width=y,Ge.height=v,Ge}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),Ge=$e.width,je=$e.height,Ye=createCanvas({width:Ge,height:je});return m instanceof v?getContext2dOrThrow(Ye).putImageData(m,0,0):getContext2dOrThrow(Ye).drawImage(m,0,0,Ge,je),Ye}function imageTensorToCanvas(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,Ge,je,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),Ge=$e[0],je=$e[1],Ye=$e[2],qe=Ze(function(){return m.as3D(Ge,je,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,Ge=y.Video;return m instanceof v||m instanceof $e||m instanceof Ge}function imageToSquare(m,y,v){v===void 0&&(v=!1);var $e=env.getEnv(),Ge=$e.Image,je=$e.Canvas;if(!(m instanceof Ge||m instanceof je))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 je?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(Ge,je){if(isTensor3D(Ge)){$e._imageTensors[je]=Ge,$e._inputDimensions[je]=Ge.shape;return}if(isTensor4D(Ge)){var Ye=Ge.shape[0];if(Ye!==1)throw new Error("NetInput - tf.Tensor4D with batchSize "+Ye+" passed, but not supported in input array");$e._imageTensors[je]=Ge,$e._inputDimensions[je]=Ge.shape.slice(1);return}var qe=Ge instanceof env.getEnv().Canvas?Ge:createCanvasFromMedia(Ge);$e._canvases[je]=qe,$e._inputDimensions[je]=[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 Ge=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)}),je=Pr(Ge.map(function(Ye){return Ye.toFloat()})).as4D($e.batchSize,y,y,3);return je})},m}();function toNetInput(m){return __awaiter(this,void 0,void 0,function(){var y,v,$e;return __generator(this,function(Ge){switch(Ge.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(je){return Array.isArray(m)?" at input index "+je+":":""},$e=y.map(resolveInput),$e.forEach(function(je,Ye){if(!isMediaElement(je)&&!isTensor3D(je)&&!isTensor4D(je))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(je)){var qe=je.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(je){return isMediaElement(je)&&awaitMediaLoaded(je)}))];case 1:return Ge.sent(),[2,new NetInput($e,Array.isArray(m))]}})})}function extractFaces(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,Ge,je,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(Ge=Qe.sent(),Ge.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return je=Ge.getInput(0),je instanceof v?(Ye=je,[3,4]):[3,2];case 2:return[4,imageTensorToCanvas(je)];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),Ge=$e[0],je=$e[1],Ye=$e[2],qe=y.map(function(Qe){return Qe instanceof FaceDetection?Qe.forSize(je,Ge).box:Qe}).map(function(Qe){return Qe.clipAtImageBorders(je,Ge)}),Ke=qe.map(function(Qe){var Je=Qe.x,st=Qe.y,Mt=Qe.width,nn=Qe.height;return xl(m.as3D(Ge,je,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(Ge){switch(Ge.label){case 0:return v=env.getEnv().fetch,[4,v(m,y)];case 1:if($e=Ge.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 Ge=m.split("/").filter(function(qe){return qe}),je=m.endsWith(".json")?Ge[Ge.length-1]:v,Ye=$e+(m.endsWith(".json")?Ge.slice(0,Ge.length-1):Ge).join("/");return Ye=m.startsWith("/")?"/"+Ye:Ye,{modelBaseUri:Ye,manifestUri:Ye==="/"?"/"+je:Ye+"/"+je}}function loadWeightMap(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,Ge,je;return __generator(this,function(Ye){switch(Ye.label){case 0:return v=getModelUris(m,y),$e=v.manifestUri,Ge=v.modelBaseUri,[4,fetchJson($e)];case 1:return je=Ye.sent(),[2,ed.loadWeights(je,Ge)]}})})}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,Ge=v.objProp;return $e[Ge]},m.prototype.reassignParamFromPath=function(y,v){var $e=this.traversePropertyPath(y),Ge=$e.obj,je=$e.objProp;Ge[je].dispose(),Ge[je]=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,Ge=v.tensor;y.reassignParamFromPath($e,Ge.variable())})},m.prototype.freeze=function(){var y=this;this.getTrainableParams().forEach(function(v){var $e=v.path,Ge=v.tensor,je=Fn(Ge.dataSync());Ge.dispose(),y.reassignParamFromPath($e,je)})},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,Ge,je,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()),Ge=$e.manifestUri,je=$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(Ge)];case 1:return Ke=Je.apply(Qe,[Mt.sent().toString()]),[4,qe(Ke,je)];case 2:return st=Mt.sent(),this.loadFromWeightMap(st),[2]}})})},m.prototype.loadFromWeightMap=function(y){var v=this.extractParamsFromWeigthMap(y),$e=v.paramMappings,Ge=v.params;this._paramMappings=$e,this._params=Ge},m.prototype.extractWeights=function(y){var v=this.extractParams(y),$e=v.paramMappings,Ge=v.params;this._paramMappings=$e,this._params=Ge},m.prototype.traversePropertyPath=function(y){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var v=y.split("/").reduce(function(je,Ye){if(!je.nextObj.hasOwnProperty(Ye))throw new Error("traversePropertyPath - object does not have property "+Ye+", for path "+y);return{obj:je.nextObj,objProp:Ye,nextObj:je.nextObj[Ye]}},{nextObj:this.params}),$e=v.obj,Ge=v.objProp;if(!$e||!Ge||!($e[Ge]instanceof wt))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+y);return{obj:$e,objProp:Ge}},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])),Ge=depthwiseSeparableConv$1($e,y.conv1,[1,1]),je=Bl(rc($e,Ge)),Ye=depthwiseSeparableConv$1(je,y.conv2,[1,1]);return Bl(rc($e,rc(Ge,Ye)))})}function denseBlock4(m,y,v,$e){return v===void 0&&(v=!1),$e===void 0&&($e=!0),Ze(function(){var Ge=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])),je=depthwiseSeparableConv$1(Ge,y.conv1,[1,1]),Ye=Bl(rc(Ge,je)),qe=depthwiseSeparableConv$1(Ye,y.conv2,[1,1]),Ke=Bl(rc(Ge,rc(je,qe))),Qe=depthwiseSeparableConv$1(Ke,y.conv3,[1,1]);return Bl(rc(Ge,rc(je,rc(qe,Qe))))})}function convLayer$1(m,y,v,$e){return v===void 0&&(v="same"),$e===void 0&&($e=!1),Ze(function(){var Ge=rc(qc(m,y.filters,[1,1],v),y.bias);return $e?Bl(Ge):Ge})}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,Ge,je){var Ye=Ln(m(v*$e*Ge*Ge),[Ge,Ge,v,$e]),qe=Mn(m($e));return y.push({paramPath:je+"/filters"},{paramPath:je+"/bias"}),{filters:Ye,bias:qe}}}function extractFCParamsFactory(m,y){return function(v,$e,Ge){var je=Bn(m(v*$e),[v,$e]),Ye=Mn(m($e));return y.push({paramPath:Ge+"/weights"},{paramPath:Ge+"/bias"}),{weights:je,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,Ge){var je=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:Ge+"/depthwise_filter"},{paramPath:Ge+"/pointwise_filter"},{paramPath:Ge+"/bias"}),new SeparableConvParams(je,Ye,qe)}}function loadSeparableConvParamsFactory(m){return function(y){var v=m(y+"/depthwise_filter",4),$e=m(y+"/pointwise_filter",4),Ge=m(y+"/bias",1);return new SeparableConvParams(v,$e,Ge)}}function extractWeightEntryFactory(m,y){return function(v,$e,Ge){var je=m[v];if(!isTensor(je,$e))throw new Error("expected weightMap["+v+"] to be a Tensor"+$e+"D, instead have "+je);return y.push({originalPath:v,paramPath:Ge||v}),je}}function extractWeightsFactory(m){var y=m;function v(Ge){var je=y.slice(0,Ge);return y=y.slice(Ge),je}function $e(){return y}return{extractWeights:v,getRemainingWeights:$e}}function extractorsFactory$9(m,y){var v=extractConvParamsFactory(m,y),$e=extractSeparableConvParamsFactory(m,y);function Ge(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 je(Ye,qe,Ke,Qe){Qe===void 0&&(Qe=!1);var Je=Ge(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:Ge,extractDenseBlock4Params:je}}function extractParams$7(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,Ge=v.getRemainingWeights,je=extractorsFactory$9($e,y).extractDenseBlock4Params,Ye=je(3,32,"dense0",!0),qe=je(32,64,"dense1"),Ke=je(64,128,"dense2"),Qe=je(128,256,"dense3");if(Ge().length!==0)throw new Error("weights remaing after extract: "+Ge().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),Ge=loadSeparableConvParamsFactory(v);function je(qe,Ke){Ke===void 0&&(Ke=!1);var Qe=Ke?$e(qe+"/conv0"):Ge(qe+"/conv0"),Je=Ge(qe+"/conv1"),st=Ge(qe+"/conv2");return{conv0:Qe,conv1:Je,conv2:st}}function Ye(qe,Ke){Ke===void 0&&(Ke=!1);var Qe=Ke?$e(qe+"/conv0"):Ge(qe+"/conv0"),Je=Ge(qe+"/conv1"),st=Ge(qe+"/conv2"),Mt=Ge(qe+"/conv3");return{conv0:Qe,conv1:Je,conv2:st,conv3:Mt}}return{extractDenseBlock3Params:je,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 Ge=v.toBatchTensor(112,!0),je=[122.782,117.001,104.298],Ye=normalize$1(Ge,je).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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.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=[],Ge=extractWeightsFactory(m),je=Ge.extractWeights,Ye=Ge.getRemainingWeights,qe=extractFCParamsFactory(je,$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(je){var Ye=v(je+"/weights",2),qe=v(je+"/bias",1);return{weights:Ye,bias:qe}}var Ge={fc:$e("fc")};return disposeUnusedWeightTensors(m,y),{params:Ge,paramMappings:y}}function seperateWeightMaps(m){var y={},v={};return Object.keys(m).forEach(function($e){var Ge=$e.startsWith("fc")?v:y;Ge[$e]=m[$e]}),{featureExtractorMap:y,classifierMap:v}}var FaceProcessor=function(m){__extends(y,m);function y(v,$e){var Ge=m.call(this,v)||this;return Ge._faceFeatureExtractor=$e,Ge}return Object.defineProperty(y.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),y.prototype.runNet=function(v){var $e=this,Ge=this.params;if(!Ge)throw new Error(this._name+" - load model before inference");return Ze(function(){var je=v instanceof NetInput?$e.faceFeatureExtractor.forwardInput(v):v;return fullyConnectedLayer(je.as2D(je.shape[0],-1),Ge.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),Ge=$e.params,je=$e.paramMappings;this._params=Ge,this._paramMappings=je},y.prototype.extractClassifierParams=function(v){return extractParams$6(v,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},y.prototype.extractParamsFromWeigthMap=function(v){var $e=seperateWeightMaps(v),Ge=$e.featureExtractorMap,je=$e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(Ge),extractParamsFromWeigthMap$6(je)},y.prototype.extractParams=function(v){var $e=this.getClassifierChannelsIn(),Ge=this.getClassifierChannelsOut(),je=Ge*$e+Ge,Ye=v.slice(0,v.length-je),qe=v.slice(v.length-je);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,Ge){v[$e]=y[Ge]})}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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.sent()])]}})})},y.prototype.predictExpressions=function(v){return __awaiter(this,void 0,void 0,function(){var $e,Ge,je,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 Ge=Ke.sent(),[4,Promise.all(Ur(Ge).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 je=Ke.sent(),Ge.dispose(),Ye=je.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),Ge=$e.align(),je=m.detection.imageDims,Ye=new FaceDetection(m.detection.score,Ge.rescale(je.reverse()),je),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 Ge(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 je(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:Ge,extractMainBlockParams:je}}function extractParams$5(m,y){var v=[],$e=extractWeightsFactory(m),Ge=$e.extractWeights,je=$e.getRemainingWeights,Ye=extractorsFactory$8(Ge,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(fn){on["main_block_"+fn]=Je(128,"middle_flow/main_block_"+fn)});var an=Qe(128,256,"exit_flow/reduction_block"),un=Ke(256,512,"exit_flow/separable_conv"),ln={reduction_block:an,separable_conv:un};if(je().length!==0)throw new Error("weights remaing after extract: "+je().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),Ge=loadSeparableConvParamsFactory(v);function je(qe){var Ke=Ge(qe+"/separable_conv0"),Qe=Ge(qe+"/separable_conv1"),Je=$e(qe+"/expansion_conv");return{separable_conv0:Ke,separable_conv1:Qe,expansion_conv:Je}}function Ye(qe){var Ke=Ge(qe+"/separable_conv0"),Qe=Ge(qe+"/separable_conv1"),Je=Ge(qe+"/separable_conv2");return{separable_conv0:Ke,separable_conv1:Qe,separable_conv2:Je}}return{extractConvParams:$e,extractSeparableConvParams:Ge,extractReductionBlockParams:je,extractMainBlockParams:Ye}}function extractParamsFromWeigthMap$5(m,y){var v=[],$e=loadParamsFactory(m,v),Ge=$e.extractConvParams,je=$e.extractSeparableConvParams,Ye=$e.extractReductionBlockParams,qe=$e.extractMainBlockParams,Ke=Ge("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=je("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,Ge=this.params;if(!Ge)throw new Error("TinyXception - load model before inference");return Ze(function(){var je=v.toBatchTensor(112,!0),Ye=[122.782,117.001,104.298],qe=normalize$1(je,Ye).div(On(256)),Ke=Bl(conv$1(qe,Ge.entry_flow.conv_in,[2,2]));return Ke=reductionBlock(Ke,Ge.entry_flow.reduction_block_0,!1),Ke=reductionBlock(Ke,Ge.entry_flow.reduction_block_1),range($e._numMainBlocks,0,1).forEach(function(Qe){Ke=mainBlock(Ke,Ge.middle_flow["main_block_"+Qe])}),Ke=reductionBlock(Ke,Ge.exit_flow.reduction_block),Ke=Bl(depthwiseSeparableConv$1(Ke,Ge.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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.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,Ge=v.getRemainingWeights,je=extractFCParamsFactory($e,y),Ye=je(512,1,"fc/age"),qe=je(512,2,"fc/gender");if(Ge().length!==0)throw new Error("weights remaing after extract: "+Ge().length);return{paramMappings:y,params:{fc:{age:Ye,gender:qe}}}}function extractParamsFromWeigthMap$4(m){var y=[],v=extractWeightEntryFactory(m,y);function $e(je){var Ye=v(je+"/weights",2),qe=v(je+"/bias",1);return{weights:Ye,bias:qe}}var Ge={fc:{age:$e("fc/age"),gender:$e("fc/gender")}};return disposeUnusedWeightTensors(m,y),{params:Ge,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,Ge=this.params;if(!Ge)throw new Error(this._name+" - load model before inference");return Ze(function(){var je=v instanceof NetInput?$e.faceFeatureExtractor.forwardInput(v):v,Ye=fl(je,[7,7],[2,2],"valid").as2D(je.shape[0],-1),qe=fullyConnectedLayer(Ye,Ge.fc.age).as1D(),Ke=fullyConnectedLayer(Ye,Ge.fc.gender);return{age:qe,gender:Ke}})},y.prototype.forwardInput=function(v){var $e=this;return Ze(function(){var Ge=$e.runNet(v),je=Ge.age,Ye=Ge.gender;return{age:je,gender:go(Ye)}})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.sent()])]}})})},y.prototype.predictAgeAndGender=function(v){return __awaiter(this,void 0,void 0,function(){var $e,Ge,je,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 Ge=Je.sent(),je=Ur(Ge.age),Ye=Ur(Ge.gender),qe=je.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,un,ln;return __generator(this,function(fn){switch(fn.label){case 0:return[4,Mt.data()];case 1:return rn=fn.sent()[0],[4,nn.data()];case 2:return on=fn.sent()[0],an=on>.5,un=an?Gender.MALE:Gender.FEMALE,ln=an?on:1-on,Mt.dispose(),nn.dispose(),[2,{age:rn,gender:un,genderProbability:ln}]}})})}))];case 3:return Ke=Je.sent(),Ge.age.dispose(),Ge.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),Ge=$e.params,je=$e.paramMappings;this._params=Ge,this._paramMappings=je},y.prototype.extractClassifierParams=function(v){return extractParams$4(v)},y.prototype.extractParamsFromWeigthMap=function(v){var $e=seperateWeightMaps(v),Ge=$e.featureExtractorMap,je=$e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(Ge),extractParamsFromWeigthMap$4(je)},y.prototype.extractParams=function(v){var $e=1539,Ge=v.slice(0,v.length-$e),je=v.slice(v.length-$e);return this.faceFeatureExtractor.extractWeights(Ge),this.extractClassifierParams(je)},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,Ge){var je=Ge.map(function(qe){var Ke=qe.width,Qe=qe.height,Je=$e/Math.max(Qe,Ke);return{width:Ke*Je,height:Qe*Je}}),Ye=je.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=je[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(je[nn].width,je[nn].height)})));return st})},y.prototype.forwardInput=function(v){var $e=this;return Ze(function(){var Ge=$e.runNet(v);return $e.postProcess(Ge,v.inputSize,v.inputDimensions.map(function(je){var Ye=je[0],qe=je[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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.sent()])]}})})},y.prototype.detectLandmarks=function(v){return __awaiter(this,void 0,void 0,function(){var $e,Ge,je,Ye=this;return __generator(this,function(qe){switch(qe.label){case 0:return[4,toNetInput(v)];case 1:return $e=qe.sent(),Ge=Ze(function(){return Ur(Ye.forwardInput($e))}),[4,Promise.all(Ge.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,un){return isEven(un)}),rn=Je.filter(function(an,un){return!isEven(un)}),[2,new FaceLandmarks68(Array(68).fill(0).map(function(an,un){return new Point(nn[un],rn[un])}),{height:$e.getInputHeight(Qe),width:$e.getInputWidth(Qe)})]}})})}))];case 2:return je=qe.sent(),Ge.forEach(function(Ke){return Ke.dispose()}),[2,$e.isBatchInput?je:je[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,Ge=v.getRemainingWeights,je=extractorsFactory$9($e,y).extractDenseBlock3Params,Ye=je(3,32,"dense0",!0),qe=je(32,64,"dense1"),Ke=je(64,128,"dense2");if(Ge().length!==0)throw new Error("weights remaing after extract: "+Ge().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 Ge=v.toBatchTensor(112,!0),je=[122.782,117.001,104.298],Ye=normalize$1(Ge,je).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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.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,Ge){Ge===void 0&&(Ge="same");var je=y.conv,Ye=je.filters,qe=je.bias,Ke=qc(m,Ye,v,Ge);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 Ge(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 je(qe,Ke,Qe,Je){var st=$e(qe,Ke,Qe,Je+"/conv"),Mt=Ge(Ke,Je+"/scale");return{conv:st,scale:Mt}}function Ye(qe,Ke,Qe,Je,st){st===void 0&&(st=!1);var Mt=je((st?.5:1)*qe,Ke,Qe,Je+"/conv1"),nn=je(qe,Ke,Qe,Je+"/conv2");return{conv1:Mt,conv2:nn}}return{extractConvLayerParams:je,extractResidualLayerParams:Ye}}function extractParams$3(m){var y=extractWeightsFactory(m),v=y.extractWeights,$e=y.getRemainingWeights,Ge=[],je=extractorsFactory$7(v,Ge),Ye=je.extractConvLayerParams,qe=je.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),un=qe(147456,128,3,"conv128_1"),ln=qe(147456,128,3,"conv128_2"),fn=qe(589824,256,3,"conv256_down",!0),cn=qe(589824,256,3,"conv256_1"),Xr=qe(589824,256,3,"conv256_2"),Mi=qe(589824,256,3,"conv256_down_out"),to=Ze(function(){return Wl(Bn(v(256*128),[128,256]),[1,0])});if(Ge.push({paramPath:"fc"}),$e().length!==0)throw new Error("weights remaing after extract: "+$e().length);var ld={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:un,conv128_2:ln,conv256_down:fn,conv256_1:cn,conv256_2:Xr,conv256_down_out:Mi,fc:to};return{params:ld,paramMappings:Ge}}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 Ge(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 je(Ye){return{conv1:Ge(Ye+"/conv1"),conv2:Ge(Ye+"/conv2")}}return{extractConvLayerParams:Ge,extractResidualLayerParams:je}}function extractParamsFromWeigthMap$3(m){var y=[],v=extractorsFactory$6(m,y),$e=v.extractConvLayerParams,Ge=v.extractResidualLayerParams,je=$e("conv32_down"),Ye=Ge("conv32_1"),qe=Ge("conv32_2"),Ke=Ge("conv32_3"),Qe=Ge("conv64_down"),Je=Ge("conv64_1"),st=Ge("conv64_2"),Mt=Ge("conv64_3"),nn=Ge("conv128_down"),rn=Ge("conv128_1"),on=Ge("conv128_2"),an=Ge("conv256_down"),un=Ge("conv256_1"),ln=Ge("conv256_2"),fn=Ge("conv256_down_out"),cn=m.fc;if(y.push({originalPath:"fc",paramPath:"fc"}),!isTensor2D(cn))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+cn);var Xr={conv32_down:je,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:un,conv256_2:ln,conv256_down_out:fn,fc:cn};return disposeUnusedWeightTensors(m,y),{params:Xr,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"),Ge=Gn($e.shape),je=$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=je?Yn([$e,Ge],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 Ge=v.toBatchTensor(150,!0).toFloat(),je=[122.782,117.001,104.298],Ye=normalize$1(Ge,je).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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.sent()])]}})})},y.prototype.computeFaceDescriptor=function(v){return __awaiter(this,void 0,void 0,function(){var $e,Ge,je,Ye=this;return __generator(this,function(qe){switch(qe.label){case 0:return[4,toNetInput(v)];case 1:return $e=qe.sent(),Ge=Ze(function(){return Ur(Ye.forwardInput($e))}),[4,Promise.all(Ge.map(function(Ke){return Ke.data()}))];case 2:return je=qe.sent(),Ge.forEach(function(Ke){return Ke.dispose()}),[2,$e.isBatchInput?je:je[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,Ge=v.scaleFactor,je=v.maxNumScales,Ye=v.scoreThresholds,qe=v.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=$e||20,this._scaleFactor=Ge||.709,this._maxNumScales=je||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 Ge(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 je(Ke,Qe,Je){var st=v(Ke,Je+"/depthwise_conv"),Mt=Ge(Ke,Qe,1,Je+"/pointwise_conv");return{depthwise_conv:st,pointwise_conv:Mt}}function Ye(){var Ke=Ge(3,32,3,"mobilenetv1/conv_0"),Qe=je(32,64,"mobilenetv1/conv_1"),Je=je(64,128,"mobilenetv1/conv_2"),st=je(128,128,"mobilenetv1/conv_3"),Mt=je(128,256,"mobilenetv1/conv_4"),nn=je(256,256,"mobilenetv1/conv_5"),rn=je(256,512,"mobilenetv1/conv_6"),on=je(512,512,"mobilenetv1/conv_7"),an=je(512,512,"mobilenetv1/conv_8"),un=je(512,512,"mobilenetv1/conv_9"),ln=je(512,512,"mobilenetv1/conv_10"),fn=je(512,512,"mobilenetv1/conv_11"),cn=je(512,1024,"mobilenetv1/conv_12"),Xr=je(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:un,conv_10:ln,conv_11:fn,conv_12:cn,conv_13:Xr}}function qe(){var Ke=Ge(1024,256,1,"prediction_layer/conv_0"),Qe=Ge(256,512,3,"prediction_layer/conv_1"),Je=Ge(512,128,1,"prediction_layer/conv_2"),st=Ge(128,256,3,"prediction_layer/conv_3"),Mt=Ge(256,128,1,"prediction_layer/conv_4"),nn=Ge(128,256,3,"prediction_layer/conv_5"),rn=Ge(256,64,1,"prediction_layer/conv_6"),on=Ge(64,128,3,"prediction_layer/conv_7"),an=$e(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),un=$e(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),ln=$e(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),fn=$e(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),cn=$e(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),Xr=$e(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),Mi=$e(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),to=$e(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),ld=$e(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),od=$e(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),Uo=$e(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),vd=$e(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),rd={box_encoding_predictor:an,class_predictor:un},mo={box_encoding_predictor:ln,class_predictor:fn},uo={box_encoding_predictor:cn,class_predictor:Xr},lo={box_encoding_predictor:Mi,class_predictor:to},fo={box_encoding_predictor:ld,class_predictor:od},ho={box_encoding_predictor:Uo,class_predictor:vd};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:rd,box_predictor_1:mo,box_predictor_2:uo,box_predictor_3:lo,box_predictor_4:fo,box_predictor_5:ho}}return{extractMobilenetV1Params:Ye,extractPredictionLayerParams:qe}}function extractParams$2(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,Ge=v.getRemainingWeights,je=extractorsFactory$5($e,y),Ye=je.extractMobilenetV1Params,qe=je.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"}),Ge().length!==0)throw new Error("weights remaing after extract: "+Ge().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 Ge(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"),un=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:un,batch_norm_variance:ln},pointwise_conv:$e("MobilenetV1",Qe,nn)}}function je(){return{conv_0:$e("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:Ge(1),conv_2:Ge(2),conv_3:Ge(3),conv_4:Ge(4),conv_5:Ge(5),conv_6:Ge(6),conv_7:Ge(7),conv_8:Ge(8),conv_9:Ge(9),conv_10:Ge(10),conv_11:Ge(11),conv_12:Ge(12),conv_13:Ge(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:je,extractPredictionLayerParams:Ke}}function extractParamsFromWeigthMap$2(m){var y=[],v=extractorsFactory$4(m,y),$e=v.extractMobilenetV1Params,Ge=v.extractPredictionLayerParams,je=m["Output/extra_dim"];if(y.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!isTensor3D(je))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+je);var Ye={mobilenetv1:$e(),prediction_layer:Ge(),output_layer:{extra_dim:je}};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]),Ge=[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(Ge.forEach(function(je,Ye){var qe=Ye+1,Ke=getStridesForLayerIdx(qe);$e=depthwiseConvLayer($e,je.depthwise_conv,Ke),$e=pointwiseConvLayer($e,je.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,Ge){var je=m.shape[0],Ye=Math.min(v,je),qe=y.map(function(Je,st){return{score:Je,boxIndex:st}}).filter(function(Je){return Je.score>Ge}).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<=Ge))break}st===Je.score&&Qe.push(Je.boxIndex)}}),Qe}function IOU(m,y,v){var $e=m.arraySync(),Ge=Math.min($e[y][0],$e[y][2]),je=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-Ge)*(qe-je),nn=(Je-Ke)*(st-Qe);if(Mt<=0||nn<=0)return 0;var rn=Math.max(Ge,Ke),on=Math.max(je,Qe),an=Math.min(Ye,Je),un=Math.min(qe,st),ln=Math.max(an-rn,0)*Math.max(un-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,Ge=v.centers,je=Ur(Wl(y,[1,0])),Ye=sc(gc(vu(sc(je[2],On(5))),$e[0]),On(2)),qe=rc(gc(sc(je[0],On(10)),$e[0]),Ge[0]),Ke=sc(gc(vu(sc(je[3],On(5))),$e[1]),On(2)),Qe=rc(gc(sc(je[1],On(10)),$e[1]),Ge[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],Ge=decodeBoxesLayer(Or(Lr(v.extra_dim,[$e,1,1]),[-1,4]),Or(m,[-1,4]));Ge=Or(Ge,[$e,Ge.shape[0]/$e,4]);var je=Iu(ml(y,[0,0,1],[-1,-1,-1])),Ye=ml(je,[0,0,0],[-1,-1,1]);Ye=Or(Ye,[$e,Ye.shape[1]]);var qe=Ur(Ge),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]),Ge=Or(convLayer$1(m,y.class_predictor),[v,-1,3]);return{boxPredictionEncoding:$e,classPrediction:Ge}})}function predictionLayer(m,y,v){return Ze(function(){var $e=pointwiseConvLayer(m,v.conv_0,[1,1]),Ge=pointwiseConvLayer($e,v.conv_1,[2,2]),je=pointwiseConvLayer(Ge,v.conv_2,[1,1]),Ye=pointwiseConvLayer(je,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(Ge,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),un=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:un,classPredictions:ln}})}var SsdMobilenetv1Options=function(){function m(y){var v=y===void 0?{}:y,$e=v.minConfidence,Ge=v.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=$e||.5,this._maxResults=Ge||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 Ge=v.toBatchTensor(512,!1).toFloat(),je=Cc(gc(Ge,On(.007843137718737125)),On(1)),Ye=mobileNetV1(je,$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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.sent()])]}})})},y.prototype.locateFaces=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var Ge,je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln,fn,cn,Xr,Mi,to,ld;return __generator(this,function(od){switch(od.label){case 0:return Ge=new SsdMobilenetv1Options($e),je=Ge.maxResults,Ye=Ge.minConfidence,[4,toNetInput(v)];case 1:for(qe=od.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,[od.sent()]),un=.5,ln=nonMaxSuppression(st,rn,je,un,Ye),fn=qe.getReshapedInputDimensions(0),cn=qe.inputSize,Xr=cn/fn.width,Mi=cn/fn.height,to=st.arraySync(),ld=ln.map(function(Uo){var vd=[Math.max(0,to[Uo][0]),Math.min(1,to[Uo][2])].map(function(ho){return ho*Mi}),rd=vd[0],mo=vd[1],uo=[Math.max(0,to[Uo][1]),Math.min(1,to[Uo][3])].map(function(ho){return ho*Xr}),lo=uo[0],fo=uo[1];return new FaceDetection(rn[Uo],new Rect(lo,rd,fo-lo,mo-rd),{height:qe.getInputHeight(0),width:qe.getInputWidth(0)})}),st.dispose(),Mt.dispose(),[2,ld]}})})},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 Ge(Ye,qe,Ke){var Qe=v(Ye,qe,3,Ke+"/conv"),Je=$e(qe,Ke+"/bn");return{conv:Qe,bn:Je}}var je=extractSeparableConvParamsFactory(m,y);return{extractConvParams:v,extractConvWithBatchNormParams:Ge,extractSeparableConvParams:je}}function extractParams$1(m,y,v,$e){var Ge=extractWeightsFactory(m),je=Ge.extractWeights,Ye=Ge.getRemainingWeights,qe=[],Ke=extractorsFactory$3(je,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],un=$e[4],ln=$e[5],fn=$e[6],cn=$e[7],Xr=$e[8],Mi=y.isFirstLayerConv2d?Qe(nn,rn,3,"conv0"):st(nn,rn,"conv0"),to=st(rn,on,"conv1"),ld=st(on,an,"conv2"),od=st(an,un,"conv3"),Uo=st(un,ln,"conv4"),vd=st(ln,fn,"conv5"),rd=cn?st(fn,cn,"conv6"):void 0,mo=Xr?st(cn,Xr,"conv7"):void 0,uo=Qe(Xr||cn||fn,5*v,1,"conv8");Mt={conv0:Mi,conv1:to,conv2:ld,conv3:od,conv4:Uo,conv5:vd,conv6:rd,conv7:mo,conv8:uo}}else{var nn=$e[0],rn=$e[1],on=$e[2],an=$e[3],un=$e[4],ln=$e[5],fn=$e[6],cn=$e[7],Xr=$e[8],Mi=Je(nn,rn,"conv0"),to=Je(rn,on,"conv1"),ld=Je(on,an,"conv2"),od=Je(an,un,"conv3"),Uo=Je(un,ln,"conv4"),vd=Je(ln,fn,"conv5"),rd=Je(fn,cn,"conv6"),mo=Je(cn,Xr,"conv7"),uo=Qe(Xr,5*v,1,"conv8");Mt={conv0:Mi,conv1:to,conv2:ld,conv3:od,conv4:Uo,conv5:vd,conv6:rd,conv7:mo,conv8:uo}}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 Ge(qe){var Ke=v(qe+"/filters",4),Qe=v(qe+"/bias",1);return{filters:Ke,bias:Qe}}function je(qe){var Ke=Ge(qe+"/conv"),Qe=$e(qe+"/bn");return{conv:Ke,bn:Qe}}var Ye=loadSeparableConvParamsFactory(v);return{extractConvParams:Ge,extractConvWithBatchNormParams:je,extractSeparableConvParams:Ye}}function extractParamsFromWeigthMap$1(m,y){var v=[],$e=extractorsFactory$2(m,v),Ge=$e.extractConvParams,je=$e.extractConvWithBatchNormParams,Ye=$e.extractSeparableConvParams,qe;if(y.withSeparableConvs){var Ke=y.filterSizes&&y.filterSizes.length||9;qe={conv0:y.isFirstLayerConv2d?Ge("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:Ge("conv8")}}else qe={conv0:je("conv0"),conv1:je("conv1"),conv2:je("conv2"),conv3:je("conv3"),conv4:je("conv4"),conv5:je("conv5"),conv6:je("conv6"),conv7:je("conv7"),conv8:Ge("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,Ge=v.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=$e||416,this._scoreThreshold=Ge||.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 Ge=convWithBatchNorm(v,$e.conv0);return Ge=hl(Ge,[2,2],[2,2],"same"),Ge=convWithBatchNorm(Ge,$e.conv1),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=convWithBatchNorm(Ge,$e.conv2),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=convWithBatchNorm(Ge,$e.conv3),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=convWithBatchNorm(Ge,$e.conv4),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=convWithBatchNorm(Ge,$e.conv5),Ge=hl(Ge,[2,2],[1,1],"same"),Ge=convWithBatchNorm(Ge,$e.conv6),Ge=convWithBatchNorm(Ge,$e.conv7),convLayer$1(Ge,$e.conv8,"valid",!1)},y.prototype.runMobilenet=function(v,$e){var Ge=this.config.isFirstLayerConv2d?leaky(convLayer$1(v,$e.conv0,"valid",!1)):depthwiseSeparableConv(v,$e.conv0);return Ge=hl(Ge,[2,2],[2,2],"same"),Ge=depthwiseSeparableConv(Ge,$e.conv1),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=depthwiseSeparableConv(Ge,$e.conv2),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=depthwiseSeparableConv(Ge,$e.conv3),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=depthwiseSeparableConv(Ge,$e.conv4),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=depthwiseSeparableConv(Ge,$e.conv5),Ge=hl(Ge,[2,2],[1,1],"same"),Ge=$e.conv6?depthwiseSeparableConv(Ge,$e.conv6):Ge,Ge=$e.conv7?depthwiseSeparableConv(Ge,$e.conv7):Ge,convLayer$1(Ge,$e.conv8,"valid",!1)},y.prototype.forwardInput=function(v,$e){var Ge=this,je=this.params;if(!je)throw new Error("TinyYolov2 - load model before inference");return Ze(function(){var Ye=v.toBatchTensor($e,!1).toFloat();return Ye=Ge.config.meanRgb?normalize$1(Ye,Ge.config.meanRgb):Ye,Ye=Ye.div(On(256)),Ge.config.withSeparableConvs?Ge.runMobilenet(Ye,je):Ge.runTinyYolov2(Ye,je)})},y.prototype.forward=function(v,$e){return __awaiter(this,void 0,void 0,function(){var Ge;return __generator(this,function(je){switch(je.label){case 0:return Ge=this.forwardInput,[4,toNetInput(v)];case 1:return[4,Ge.apply(this,[je.sent(),$e])];case 2:return[2,je.sent()]}})})},y.prototype.detect=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var Ge,je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln=this;return __generator(this,function(fn){switch(fn.label){case 0:return Ge=new TinyYolov2Options($e),je=Ge.inputSize,Ye=Ge.scoreThreshold,[4,toNetInput(v)];case 1:return qe=fn.sent(),[4,this.forwardInput(qe,je)];case 2:return Ke=fn.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=fn.sent(),Ke.dispose(),Qe.dispose(),Mt=st.map(function(cn){return cn.box}),nn=st.map(function(cn){return cn.score}),rn=st.map(function(cn){return cn.classScore}),on=st.map(function(cn){return ln.config.classes[cn.label]}),an=nonMaxSuppression$1(Mt.map(function(cn){return cn.rescale(je)}),nn,this.config.iouThreshold,!0),un=an.map(function(cn){return new ObjectDetection(nn[cn],rn[cn],on[cn],Mt[cn],Je)}),[2,un]}})})},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,Ge=$e?$e.length:void 0;if(Ge!==7&&Ge!==8&&Ge!==9)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+Ge+" filterSizes in config");return extractParams$1(v,this.config,this.boxEncodingSize,$e)},y.prototype.extractBoxes=function(v,$e,Ge){return __awaiter(this,void 0,void 0,function(){var je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln,fn,cn,Xr,Mi,to,ld,od,Uo,vd,rd,mo,uo,lo,fo,ho,hd=this;return __generator(this,function(dd){switch(dd.label){case 0:return je=$e.width,Ye=$e.height,qe=Math.max(je,Ye),Ke=qe/je,Qe=qe/Ye,Je=v.shape[1],st=this.config.anchors.length,Mt=Ze(function(){var pd=v.reshape([Je,Je,st,hd.boxEncodingSize]),gd=pd.slice([0,0,0,0],[Je,Je,st,4]),Sd=pd.slice([0,0,0,4],[Je,Je,st,1]),yd=hd.withClassScores?go(pd.slice([0,0,0,5],[Je,Je,st,hd.config.classes.length]),3):On(0);return[gd,Sd,yd]}),nn=Mt[0],rn=Mt[1],on=Mt[2],an=[],[4,rn.array()];case 1:return un=dd.sent(),[4,nn.array()];case 2:ln=dd.sent(),fn=0,dd.label=3;case 3:if(!(fn<Je))return[3,12];cn=0,dd.label=4;case 4:if(!(cn<Je))return[3,11];Xr=0,dd.label=5;case 5:return Xr<st?(Mi=sigmoid(un[fn][cn][Xr][0]),!Ge||Mi>Ge?(to=(cn+sigmoid(ln[fn][cn][Xr][0]))/Je*Ke,ld=(fn+sigmoid(ln[fn][cn][Xr][1]))/Je*Qe,od=Math.exp(ln[fn][cn][Xr][2])*this.config.anchors[Xr].x/Je*Ke,Uo=Math.exp(ln[fn][cn][Xr][3])*this.config.anchors[Xr].y/Je*Qe,vd=to-od/2,rd=ld-Uo/2,mo={row:fn,col:cn,anchor:Xr},this.withClassScores?[4,this.extractPredictedClass(on,mo)]:[3,7]):[3,9]):[3,10];case 6:return ho=dd.sent(),[3,8];case 7:ho={classScore:1,label:0},dd.label=8;case 8:uo=ho,lo=uo.classScore,fo=uo.label,an.push(__assign({box:new BoundingBox(vd,rd,vd+od,rd+Uo),score:Mi,classScore:Mi*lo,label:fo},mo)),dd.label=9;case 9:return Xr++,[3,5];case 10:return cn++,[3,4];case 11:return fn++,[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 Ge,je,Ye,qe;return __generator(this,function(Ke){switch(Ke.label){case 0:return Ge=$e.row,je=$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[Ge][je][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,Ge=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,Ge)||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 Ge;return __generator(this,function(je){switch(je.label){case 0:return[4,this.detect(v,$e)];case 1:return Ge=je.sent(),[2,Ge.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,Ge){return Ge===void 0&&(Ge=function(je){var Ye=je.alignedRect;return Ye}),__awaiter(this,void 0,void 0,function(){var je,Ye,qe,Ke,Qe;return __generator(this,function(Je){switch(Je.label){case 0:return je=m.map(function(st){return isWithFaceLandmarks(st)?Ge(st):st.detection}),qe=$e,qe?[3,5]:y instanceof wt?[4,extractFaceTensors(y,je)]:[3,2];case 1:return Ke=Je.sent(),[3,4];case 2:return[4,extractFaces(y,je)];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,Ge){return __awaiter(this,void 0,void 0,function(){var je=this;return __generator(this,function(Ye){return[2,extractAllFacesAndComputeResults([m],y,function(qe){return __awaiter(je,void 0,void 0,function(){return __generator(this,function(Ke){return[2,v(qe[0])]})})},$e,Ge)]})})}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 Ge(Qe,Je){var st=Mn(m(Qe));return y.push({paramPath:Je}),st}function je(Qe,Je,st){st===void 0&&(st=!1);var Mt=v(Qe[0],Qe[1],3,Je+"/conv1"),nn=Ge(Qe[1],Je+"/prelu1_alpha"),rn=v(Qe[1],Qe[2],3,Je+"/conv2"),on=Ge(Qe[2],Je+"/prelu2_alpha"),an=v(Qe[2],Qe[3],st?2:3,Je+"/conv3"),un=Ge(Qe[3],Je+"/prelu3_alpha");return{conv1:Mt,prelu1_alpha:nn,conv2:rn,prelu2_alpha:on,conv3:an,prelu3_alpha:un}}function Ye(){var Qe=je([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=je([3,28,48,64],"rnet",!0),Je=$e(576,128,"rnet/fc1"),st=Ge(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=je([3,32,64,64],"onet"),Je=v(64,128,2,"onet/conv4"),st=Ge(128,"onet/prelu4_alpha"),Mt=$e(1152,256,"onet/fc1"),nn=Ge(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,Ge=[],je=extractorsFactory$1(v,Ge),Ye=je.extractPNetParams,qe=je.extractRNetParams,Ke=je.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:Ge}}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 Ge(Je){var st=v(Je+"/weights",2),Mt=v(Je+"/bias",1);return{weights:st,bias:Mt}}function je(Je){return v(Je,1)}function Ye(Je){var st=$e(Je+"/conv1"),Mt=je(Je+"/prelu1_alpha"),nn=$e(Je+"/conv2"),rn=je(Je+"/prelu2_alpha"),on=$e(Je+"/conv3"),an=je(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=Ge("rnet/fc1"),Mt=je("rnet/prelu4_alpha"),nn=Ge("rnet/fc2_1"),rn=Ge("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=je("onet/prelu4_alpha"),nn=Ge("onet/fc1"),rn=je("onet/prelu5_alpha"),on=Ge("onet/fc2_1"),an=Ge("onet/fc2_2"),un=Ge("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:un})}return{extractPNetParams:qe,extractRNetParams:Ke,extractONetParams:Qe}}function extractParamsFromWeigthMap(m){var y=[],v=extractorsFactory(m,y),$e=v.extractPNetParams,Ge=v.extractRNetParams,je=v.extractONetParams,Ye=$e(),qe=Ge(),Ke=je();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],Ge=v[1],je=CELL_SIZE/m,Ye=[],qe=Math.min($e,Ge)*je,Ke=0;qe>=12;)Ye.push(je*Math.pow(y,Ke)),qe=qe*y,Ke+=1;return Ye}var MtcnnBox=function(m){__extends(y,m);function y(v,$e,Ge,je){return m.call(this,{left:v,top:$e,right:Ge,bottom:je},!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"),Ge=wr(Sl($e,3),3),je=go(Cc($e,Ge),3),Ye=convLayer$1(v,y.conv4_2,"valid");return{prob:je,regions:Ye}})}function rescaleAndNormalize(m,y){return Ze(function(){var v=getSizesForScale(y,m.shape.slice(1)),$e=v.height,Ge=v.width,je=Oh.resizeBilinear(m,[$e,Ge]),Ye=normalize(je);return Wl(Ye,[0,2,1,3])})}function extractBoundingBoxes(m,y,v,$e){for(var Ge=[],je=m.arraySync(),Ye=0;Ye<m.shape[0];Ye++)for(var qe=0;qe<m.shape[1];qe++)je[Ye][qe]>=$e&&Ge.push(new Point(qe,Ye));var Ke=Ge.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=je[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,Ge){Ge.stage1=[];var je=y.map(function(Mt){return Ze(function(){var nn={scale:Mt},rn=rescaleAndNormalize(m,Mt),on=Date.now(),an=PNet(rn,$e),un=an.prob,ln=an.regions;nn.pnet=Date.now()-on;var fn=Ur(Ur(un,3)[1])[0],cn=Ur(ln)[0];return{scoresTensor:fn,regionsTensor:cn,scale:Mt,statsForScale:nn}})}),Ye=je.map(function(Mt){var nn=Mt.scoresTensor,rn=Mt.regionsTensor,on=Mt.scale,an=Mt.statsForScale,un=extractBoundingBoxes(nn,rn,on,v);if(nn.dispose(),rn.dispose(),!un.length)return Ge.stage1.push(an),[];var ln=Date.now(),fn=nonMaxSuppression$1(un.map(function(cn){return cn.cell}),un.map(function(cn){return cn.score}),.5);return an.nms=Date.now()-ln,an.numBoxes=fn.length,Ge.stage1.push(an),fn.map(function(cn){return un[cn]})}),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);Ge.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,Ge=v.height;return __awaiter(this,void 0,void 0,function(){var je,Ye,qe,Ke=this;return __generator(this,function(Qe){switch(Qe.label){case 0:return je=getContext2dOrThrow(m),[4,Promise.all(y.map(function(Je){return __awaiter(Ke,void 0,void 0,function(){var st,Mt,nn,rn,on,an,un,ln;return __generator(this,function(fn){return st=Je.padAtBorders(m.height,m.width),Mt=st.y,nn=st.ey,rn=st.x,on=st.ex,an=rn-1,un=Mt-1,ln=je.getImageData(an,un,on-an,nn-un),[2,env.isNodejs()?createCanvasFromMedia(ln):createImageBitmap(ln)]})})}))];case 1:return Ye=Qe.sent(),qe=[],Ye.forEach(function(Je){var st=createCanvas({width:$e,height:Ge}),Mt=getContext2dOrThrow(st);Mt.drawImage(Je,0,0,$e,Ge);for(var nn=Mt.getImageData(0,0,$e,Ge).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,Ge,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]]),Ge=fullyConnectedLayer($e,y.fc1),je=prelu(Ge,y.prelu4_alpha),Ye=fullyConnectedLayer(je,y.fc2_1),qe=wr(Sl(Ye,1),1),Ke=go(Cc(Ye,qe),1),Qe=fullyConnectedLayer(je,y.fc2_2),Je=Ur(Ke,1)[1];return{scores:Je,regions:Qe}})}function stage2(m,y,v,$e,Ge){return __awaiter(this,void 0,void 0,function(){var je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln;return __generator(this,function(fn){switch(fn.label){case 0:return je=Date.now(),[4,extractImagePatches(m,y,{width:24,height:24})];case 1:return Ye=fn.sent(),Ge.stage2_extractImagePatches=Date.now()-je,je=Date.now(),qe=Ye.map(function(cn){var Xr=RNet(cn,$e);return cn.dispose(),Xr}),Ge.stage2_rnet=Date.now()-je,Ke=qe.length>1?Yn(qe.map(function(cn){return cn.scores})):qe[0].scores,st=(Je=Array).from,[4,Ke.data()];case 2:return Qe=st.apply(Je,[fn.sent()]),Ke.dispose(),Mt=Qe.map(function(cn,Xr){return{score:cn,idx:Xr}}).filter(function(cn){return cn.score>v}).map(function(cn){var Xr=cn.idx;return Xr}),nn=Mt.map(function(cn){return y[cn]}),rn=Mt.map(function(cn){return Qe[cn]}),on=[],an=[],nn.length>0&&(je=Date.now(),un=nonMaxSuppression$1(nn,rn,.7),Ge.stage2_nms=Date.now()-je,ln=un.map(function(cn){var Xr=qe[Mt[cn]].regions.arraySync();return new MtcnnBox(Xr[0][0],Xr[0][1],Xr[0][2],Xr[0][3])}),an=un.map(function(cn){return rn[cn]}),on=un.map(function(cn,Xr){return nn[cn].calibrate(ln[Xr])})),qe.forEach(function(cn){cn.regions.dispose(),cn.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]]),Ge=fullyConnectedLayer($e,y.fc1),je=prelu(Ge,y.prelu5_alpha),Ye=fullyConnectedLayer(je,y.fc2_1),qe=wr(Sl(Ye,1),1),Ke=go(Cc(Ye,qe),1),Qe=fullyConnectedLayer(je,y.fc2_2),Je=fullyConnectedLayer(je,y.fc2_3),st=Ur(Ke,1)[1];return{scores:st,regions:Qe,points:Je}})}function stage3(m,y,v,$e,Ge){return __awaiter(this,void 0,void 0,function(){var je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln,fn;return __generator(this,function(cn){switch(cn.label){case 0:return je=Date.now(),[4,extractImagePatches(m,y,{width:48,height:48})];case 1:return Ye=cn.sent(),Ge.stage3_extractImagePatches=Date.now()-je,je=Date.now(),qe=Ye.map(function(Xr){var Mi=ONet(Xr,$e);return Xr.dispose(),Mi}),Ge.stage3_onet=Date.now()-je,Ke=qe.length>1?Yn(qe.map(function(Xr){return Xr.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(Xr,Mi){return{score:Xr,idx:Mi}}).filter(function(Xr){return Xr.score>v}).map(function(Xr){var Mi=Xr.idx;return Mi}),nn=Mt.map(function(Xr){var Mi=qe[Xr].regions.arraySync();return new MtcnnBox(Mi[0][0],Mi[0][1],Mi[0][2],Mi[0][3])}),rn=Mt.map(function(Xr,Mi){return y[Xr].calibrate(nn[Mi])}),on=Mt.map(function(Xr){return Qe[Xr]}),an=[],un=[],ln=[],rn.length>0&&(je=Date.now(),fn=nonMaxSuppression$1(rn,on,.7,!1),Ge.stage3_nms=Date.now()-je,an=fn.map(function(Xr){return rn[Xr]}),un=fn.map(function(Xr){return on[Xr]}),ln=fn.map(function(Xr,Mi){return Array(5).fill(0).map(function(to,ld){var od=qe[Xr].points.arraySync();return new Point(od[0][ld]*(an[Mi].width+1)+an[Mi].left,od[0][ld+5]*(an[Mi].height+1)+an[Mi].top)})})),qe.forEach(function(Xr){Xr.regions.dispose(),Xr.scores.dispose(),Xr.points.dispose()}),[2,{boxes:an,scores:un,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 Ge,je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln,fn,cn,Xr,Mi,to,ld;return __generator(this,function(od){switch(od.label){case 0:if(Ge=this.params,!Ge)throw new Error("Mtcnn - load model before inference");if(je=v.canvases[0],!je)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(je)).toFloat())}),Qe=function(Uo){return Ke.dispose(),Ye.total=Date.now()-qe,Uo},Je=Ke.shape.slice(1),st=Je[0],Mt=Je[1],nn=new MtcnnOptions($e),rn=nn.minFaceSize,on=nn.scaleFactor,an=nn.maxNumScales,un=nn.scoreThresholds,ln=nn.scaleSteps,fn=(ln||pyramidDown(rn,on,[st,Mt])).filter(function(Uo){var vd=getSizesForScale(Uo,[st,Mt]);return Math.min(vd.width,vd.height)>CELL_SIZE}).slice(0,an),Ye.scales=fn,Ye.pyramid=fn.map(function(Uo){return getSizesForScale(Uo,[st,Mt])}),cn=Date.now(),[4,stage1(Ke,fn,un[0],Ge.pnet,Ye)];case 1:return Xr=od.sent(),Ye.total_stage1=Date.now()-cn,Xr.boxes.length?(Ye.stage2_numInputBoxes=Xr.boxes.length,cn=Date.now(),[4,stage2(je,Xr.boxes,un[1],Ge.rnet,Ye)]):[2,Qe({results:[],stats:Ye})];case 2:return Mi=od.sent(),Ye.total_stage2=Date.now()-cn,Mi.boxes.length?(Ye.stage3_numInputBoxes=Mi.boxes.length,cn=Date.now(),[4,stage3(je,Mi.boxes,un[2],Ge.onet,Ye)]):[2,Qe({results:[],stats:Ye})];case 3:return to=od.sent(),Ye.total_stage3=Date.now()-cn,ld=to.boxes.map(function(Uo,vd){return extendWithFaceLandmarks(extendWithFaceDetection({},new FaceDetection(to.scores[vd],new Rect(Uo.left/Mt,Uo.top/st,Uo.width/Mt,Uo.height/st),{height:st,width:Mt})),new FaceLandmarks5(to.points[vd].map(function(rd){return rd.sub(new Point(Uo.left,Uo.top)).div(new Point(Uo.width,Uo.height))}),{width:Uo.width,height:Uo.height}))}),[2,Qe({results:ld,stats:Ye})]}})})},y.prototype.forward=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var Ge;return __generator(this,function(je){switch(je.label){case 0:return Ge=this.forwardInput,[4,toNetInput(v)];case 1:return[4,Ge.apply(this,[je.sent(),$e])];case 2:return[2,je.sent().results]}})})},y.prototype.forwardWithStats=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var Ge;return __generator(this,function(je){switch(je.label){case 0:return Ge=this.forwardInput,[4,toNetInput(v)];case 1:return[2,Ge.apply(this,[je.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 Ge;return __generator(this,function(je){switch(je.label){case 0:return[4,this.detect(v,$e)];case 1:return Ge=je.sent(),[2,Ge.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,Ge){var je=m.call(this)||this;return je.parentTask=v,je.input=$e,je.extractedFaces=Ge,je}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,Ge=this;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(Ye){return __awaiter(Ge,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=je.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(Ge){switch(Ge.label){case 0:return[4,this.parentTask];case 1:return v=Ge.sent(),v?[4,extractSingleFaceAndComputeResult(v,this.input,function(je){return nets.faceExpressionNet.predictExpressions(je)},this.extractedFaces)]:[2];case 2:return $e=Ge.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,Ge){var je=m.call(this)||this;return je.parentTask=v,je.input=$e,je.extractedFaces=Ge,je}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,Ge=this;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(Ye){return __awaiter(Ge,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=je.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,Ge,je,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(),Ge=$e.age,je=$e.gender,Ye=$e.genderProbability,[2,extendWithAge(extendWithGender(v,je,Ye),Ge)]}})})},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 Ge=m.call(this)||this;return Ge.parentTask=v,Ge.input=$e,Ge}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(Ge){switch(Ge.label){case 0:return[4,this.parentTask];case 1:return v=Ge.sent(),[4,extractAllFacesAndComputeResults(v,this.input,function(je){return Promise.all(je.map(function(Ye){return nets.faceRecognitionNet.computeFaceDescriptor(Ye)}))},null,function(je){return je.landmarks.align(null,{useDlibAlignment:!0})})];case 2:return $e=Ge.sent(),[2,$e.map(function(je,Ye){return extendWithFaceDescriptor(v[Ye],je)})]}})})},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(Ge){switch(Ge.label){case 0:return[4,this.parentTask];case 1:return v=Ge.sent(),v?[4,extractSingleFaceAndComputeResult(v,this.input,function(je){return nets.faceRecognitionNet.computeFaceDescriptor(je)},null,function(je){return je.landmarks.align(null,{useDlibAlignment:!0})})]:[2];case 2:return $e=Ge.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,Ge){var je=m.call(this)||this;return je.parentTask=v,je.input=$e,je.useTinyLandmarkNet=Ge,je}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,Ge,je,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 je=Ke.sent(),[3,5];case 3:return[4,extractFaces(this.input,$e)];case 4:je=Ke.sent(),Ke.label=5;case 5:return Ge=je,[4,Promise.all(Ge.map(function(Qe){return qe.landmarkNet.detectLandmarks(Qe)}))];case 6:return Ye=Ke.sent(),Ge.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,Ge,je,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 je=qe.sent(),[3,5];case 3:return[4,extractFaces(this.input,[$e])];case 4:je=qe.sent(),qe.label=5;case 5:return Ge=je,[4,this.landmarkNet.detectLandmarks(Ge[0])];case 6:return Ye=qe.sent(),Ge.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 Ge=m.call(this)||this;return Ge.input=v,Ge.options=$e,Ge}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,Ge,je;return __generator(this,function(Ye){switch(Ye.label){case 0:return v=this,$e=v.input,Ge=v.options,Ge instanceof MtcnnOptions?[4,nets.mtcnn.forward($e,Ge)]:[3,2];case 1:return[2,Ye.sent().map(function(qe){return qe.detection})];case 2:if(je=Ge instanceof TinyFaceDetectorOptions?function(qe){return nets.tinyFaceDetector.locateFaces(qe,Ge)}:Ge instanceof SsdMobilenetv1Options?function(qe){return nets.ssdMobilenetv1.locateFaces(qe,Ge)}:Ge instanceof TinyYolov2Options?function(qe){return nets.tinyYolov2.locateFaces(qe,Ge)}:null,!je)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,je($e)]}})})},y.prototype.runAndExtendWithFaceDetections=function(){var v=this;return new Promise(function($e){return __awaiter(v,void 0,void 0,function(){var Ge;return __generator(this,function(je){switch(je.label){case 0:return[4,this.run()];case 1:return Ge=je.sent(),[2,$e(Ge.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(Ge){switch(Ge.label){case 0:return[4,new DetectAllFacesTask(this.input,this.options)];case 1:return v=Ge.sent(),$e=v[0],v.forEach(function(je){je.score>$e.score&&($e=je)}),[2,$e]}})})},y.prototype.runAndExtendWithFaceDetection=function(){var v=this;return new Promise(function($e){return __awaiter(v,void 0,void 0,function(){var Ge;return __generator(this,function(je){switch(je.label){case 0:return[4,this.run()];case 1:return Ge=je.sent(),[2,$e(Ge?extendWithFaceDetection({},Ge):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(Ge,je){return Ge-$e[je]}).reduce(function(Ge,je){return Ge+Math.pow(je,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 Ge=1,je=function(){return"person "+Ge++};this._labeledDescriptors=$e.map(function(Ye){if(Ye instanceof LabeledFaceDescriptors)return Ye;if(Ye instanceof Float32Array)return new LabeledFaceDescriptors(je(),[Ye]);if(Ye.descriptor&&Ye.descriptor instanceof Float32Array)return new LabeledFaceDescriptors(je(),[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,Ge){return $e+Ge},0)/(v.length||1)},m.prototype.matchDescriptor=function(y){var v=this;return this.labeledDescriptors.map(function($e){var Ge=$e.descriptors,je=$e.label;return new FaceMatch(je,v.computeMeanDistance(y,Ge))}).reduce(function($e,Ge){return $e.distance<Ge.distance?$e:Ge})},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$1(m){const y=m.indexOf("base64,");return y<0?-1:(m.substr(y+6).length*.75).toFixed(2)}function base64toFile$1(m,y,v){let $e=atob(m),Ge=$e.length,je=new Uint8Array(Ge);for(;Ge--;)je[Ge]=$e.charCodeAt(Ge);return new File([je],y,{type:v})}function createEyeMask(m,y){const v=[...m,...y],$e=v.map(st=>st.x),Ge=v.map(st=>st.y),je=Math.min(...$e),Ye=Math.max(...$e),qe=Math.min(...Ge),Ke=Math.max(...Ge),Qe=(Ye-je)*.4,Je=(Ke-qe)*.8+6;return{x:je-Qe,y:qe-Je,width:Ye-je+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)),Ge=Math.round(y.width),je=Math.round(y.height);m.fillStyle="#000000",m.fillRect(v,$e,Ge,je)}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}),Ge=await detectAllFaces($e,new TinyFaceDetectorOptions).withFaceLandmarks(!0);if(!Ge.length){console.warn("faceMaskImage: 未检测到人脸"),y&&y(null);return}const je=document.createElement("canvas");je.width=$e.naturalWidth,je.height=$e.naturalHeight;const Ye=je.getContext("2d");Ye.drawImage($e,0,0),Ge.forEach(({landmarks:Qe})=>{const Je=Qe.getLeftEye(),st=Qe.getRightEye(),Mt=createEyeMask(Je,st);applyMosaic(Ye,Mt)});const qe=je.toDataURL("image/jpeg",.9),Ke=getBase64ImageSize$1(qe);console.log("faceMaskImage 处理后大小(字节):",Ke),y&&y(base64toFile$1(qe.split(",")[1],"face-masked.jpg","image/jpeg"))}const fun$1=(m,y,v)=>y.then($e=>/^image\/\w+/.test(m.type)?new Promise((Ge,je)=>{let Ye=v.fileList.filter(qe=>qe.raw&&qe.raw==m)[0];if(!Ye){je();return}Ye.message="打码处理中...",faceMaskImage(URL.createObjectURL(m),qe=>{if(Ye.message="",!qe){Ge(m);return}setBaseProps(qe,Ye.raw),Ye.raw=qe,Ge(Ye.raw)})}):!0);var lodash$1={exports:{}};/**
|
|
4970
|
+
***************************************************************************** */var extendStatics=function(m,y){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,$e){v.__proto__=$e}||function(v,$e){for(var Ge in $e)$e.hasOwnProperty(Ge)&&(v[Ge]=$e[Ge])},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,Ge=arguments.length;$e<Ge;$e++){v=arguments[$e];for(var je in v)Object.prototype.hasOwnProperty.call(v,je)&&(y[je]=v[je])}return y},__assign.apply(this,arguments)};function __awaiter(m,y,v,$e){function Ge(je){return je instanceof v?je:new v(function(Ye){Ye(je)})}return new(v||(v=Promise))(function(je,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?je(Je.value):Ge(Je.value).then(qe,Ke)}Qe(($e=$e.apply(m,[])).next())})}function __generator(m,y){var v={label:0,sent:function(){if(je[0]&1)throw je[1];return je[1]},trys:[],ops:[]},$e,Ge,je,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,Ge&&(je=Qe[0]&2?Ge.return:Qe[0]?Ge.throw||((je=Ge.return)&&je.call(Ge),0):Ge.next)&&!(je=je.call(Ge,Qe[1])).done)return je;switch(Ge=0,je&&(Qe=[Qe[0]&2,je.value]),Qe[0]){case 0:case 1:je=Qe;break;case 4:return v.label++,{value:Qe[1],done:!1};case 5:v.label++,Ge=Qe[1],Qe=[0];continue;case 7:Qe=v.ops.pop(),v.trys.pop();continue;default:if(je=v.trys,!(je=je.length>0&&je[je.length-1])&&(Qe[0]===6||Qe[0]===2)){v=0;continue}if(Qe[0]===3&&(!je||Qe[1]>je[0]&&Qe[1]<je[3])){v.label=Qe[1];break}if(Qe[0]===6&&v.label<je[1]){v.label=je[1],je=Qe;break}if(je&&v.label<je[2]){v.label=je[2],v.ops.push(Qe);break}je[2]&&v.ops.pop(),v.trys.pop();continue}Qe=y.call(m,v)}catch(Je){Qe=[6,Je],Ge=0}finally{$e=je=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),Ge=0,y=0;y<v;y++)for(var je=arguments[y],Ye=0,qe=je.length;Ye<qe;Ye++,Ge++)$e[Ge]=je[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,Ge=y/Math.max($e,v);return new Dimensions(Math.round(v*Ge),Math.round($e*Ge))}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,Ge){return y+Ge*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||{},Ge=[$e.left,$e.top,$e.right,$e.bottom].every(isValidNumber),je=[$e.x,$e.y,$e.width,$e.height].every(isValidNumber);if(!je&&!Ge)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify($e));var Ye=je?[$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],Ge=y[2],je=y[3];return new m({x:v,y:$e,width:Ge,height:je})},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],Ge=y[2],je=y[3];return new m({x:v,y:$e,width:Ge,height:je})},m.prototype.toSquare=function(){var y=this,v=y.x,$e=y.y,Ge=y.width,je=y.height,Ye=Math.abs(Ge-je);return Ge<je&&(v-=Ye/2,Ge+=Ye),je<Ge&&($e-=Ye/2,je+=Ye),new m({x:v,y:$e,width:Ge,height:je})},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],Ge=$e[0],je=$e[1],Ye=$e[2],qe=$e[3];return new m({x:Ge,y:je,width:Ye,height:qe})},m.prototype.clipAtImageBorders=function(y,v){var $e=this,Ge=$e.x,je=$e.y,Ye=$e.right,qe=$e.bottom,Ke=Math.max(Ge,0),Qe=Math.max(je,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,Ge=$e.width,je=$e.height,Ye=this.x+y,qe=this.y+v;return new m({x:Ye,y:qe,width:Ge,height:je})},m.prototype.padAtBorders=function(y,v){var $e=this.width+1,Ge=this.height+1,je=1,Ye=1,qe=$e,Ke=Ge,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+Ge,Mt=y),Qe<1&&(Ke=2-Qe,Qe=1),Je<1&&(Ke=2-Je,Je=1),{dy:Ye,edy:Ke,dx:je,edx:qe,y:Je,ey:Mt,x:Qe,ex:st,w:$e,h:Ge}},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,Ge,je,Ye){return Ye===void 0&&(Ye=!1),m.call(this,{left:v,top:$e,right:Ge,bottom:je},Ye)||this}return y}(Box),ObjectDetection=function(){function m(y,v,$e,Ge,je){this._imageDims=new Dimensions(je.width,je.height),this._score=y,this._classScore=v,this._className=$e,this._box=new Box(Ge).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,Ge){return m.call(this,v,v,"",$e,Ge)||this}return y.prototype.forSize=function(v,$e){var Ge=m.prototype.forSize.call(this,v,$e),je=Ge.score,Ye=Ge.relativeBox,qe=Ge.imageDims;return new y(je,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)),Ge=Math.max(0,Math.min(m.bottom,y.bottom)-Math.max(m.top,y.top)),je=$e*Ge;return v?je/(m.area+y.area-je):je/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),Ge=v.reduce(function(qe,Ke){return Ke<qe?Ke:qe},1/0),je=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,Ge,je,Ye)}function nonMaxSuppression$1(m,y,v,$e){$e===void 0&&($e=!0);for(var Ge=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}),je=[],Ye=function(){var qe=Ge.pop();je.push(qe);for(var Ke=Ge,Qe=[],Je=0;Je<Ke.length;Je++){var st=Ke[Je],Mt=m[qe],nn=m[st];Qe.push(iou(Mt,nn,$e))}Ge=Ge.filter(function(rn,on){return Qe[on]<=v})};Ge.length>0;)Ye();return je}function normalize$1(m,y){return Ze(function(){var v=y[0],$e=y[1],Ge=y[2],je=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]),Ge),Ke=Yn([je,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],Ge=v[1];if($e===Ge)return m;var je=Math.abs($e-Ge),Ye=Math.round(je*(y?.5:1)),qe=$e>Ge?2:1,Ke=function(nn){var rn=m.shape.slice();return rn[qe]=nn,Hn(rn,0)},Qe=Ke(Ye),Je=je-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,Ge,je,Ye){return Ye===void 0&&(Ye=!1),m.call(this,{x:v,y:$e,width:Ge,height:je},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 Ge=v.width,je=v.height;this._imgDims=new Dimensions(Ge,je),this._shift=$e,this._positions=y.map(function(Ye){return Ye.mul(new Point(Ge,je)).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 Ge=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},v),je=Ge.useDlibAlignment,Ye=Ge.minBoxPadding;return je?this.alignDlib():this.alignMinBbox(Ye)},m.prototype.alignDlib=function(){var y=this.getRefPointsForAlignment(),v=y[0],$e=y[1],Ge=y[2],je=function(st){return Ge.sub(st).magnitude()},Ye=(je(v)+je($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 Ge=m.call(this,v)||this;return Ge._label=$e,Ge}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,Ge,je){var Ye=m.call(this,v,$e)||this;return Ye._score=Ge,Ye._classScore=je,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(Ge,je){m.readFile($e,function(Ye,qe){return Ye?je(Ye):Ge(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")},Ge=global.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},je=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:Ge},je)}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,Ge=$e===void 0?environment.Image:$e;environment.Canvas=v,environment.Image=Ge,environment.createCanvasElement=m.createCanvasElement||function(){return new v},environment.createImageElement=m.createImageElement||function(){return new Ge},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 Ge=resolveInput(m);if(!(Ge instanceof v))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var je=Ge.getContext("2d");if(!je)throw new Error("resolveContext2d - canvas 2d context is null");return je}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(je){je.currentTarget&&(je.currentTarget.removeEventListener("load",$e),je.currentTarget.removeEventListener("error",Ge),y(je))}function Ge(je){je.currentTarget&&(je.currentTarget.removeEventListener("load",$e),je.currentTarget.removeEventListener("error",Ge),v(je))}m.addEventListener("load",$e),m.addEventListener("error",Ge)})}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,Ge=$e();return Ge.width=y,Ge.height=v,Ge}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),Ge=$e.width,je=$e.height,Ye=createCanvas({width:Ge,height:je});return m instanceof v?getContext2dOrThrow(Ye).putImageData(m,0,0):getContext2dOrThrow(Ye).drawImage(m,0,0,Ge,je),Ye}function imageTensorToCanvas(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,Ge,je,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),Ge=$e[0],je=$e[1],Ye=$e[2],qe=Ze(function(){return m.as3D(Ge,je,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,Ge=y.Video;return m instanceof v||m instanceof $e||m instanceof Ge}function imageToSquare(m,y,v){v===void 0&&(v=!1);var $e=env.getEnv(),Ge=$e.Image,je=$e.Canvas;if(!(m instanceof Ge||m instanceof je))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 je?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(Ge,je){if(isTensor3D(Ge)){$e._imageTensors[je]=Ge,$e._inputDimensions[je]=Ge.shape;return}if(isTensor4D(Ge)){var Ye=Ge.shape[0];if(Ye!==1)throw new Error("NetInput - tf.Tensor4D with batchSize "+Ye+" passed, but not supported in input array");$e._imageTensors[je]=Ge,$e._inputDimensions[je]=Ge.shape.slice(1);return}var qe=Ge instanceof env.getEnv().Canvas?Ge:createCanvasFromMedia(Ge);$e._canvases[je]=qe,$e._inputDimensions[je]=[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 Ge=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)}),je=Pr(Ge.map(function(Ye){return Ye.toFloat()})).as4D($e.batchSize,y,y,3);return je})},m}();function toNetInput(m){return __awaiter(this,void 0,void 0,function(){var y,v,$e;return __generator(this,function(Ge){switch(Ge.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(je){return Array.isArray(m)?" at input index "+je+":":""},$e=y.map(resolveInput),$e.forEach(function(je,Ye){if(!isMediaElement(je)&&!isTensor3D(je)&&!isTensor4D(je))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(je)){var qe=je.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(je){return isMediaElement(je)&&awaitMediaLoaded(je)}))];case 1:return Ge.sent(),[2,new NetInput($e,Array.isArray(m))]}})})}function extractFaces(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,Ge,je,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(Ge=Qe.sent(),Ge.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return je=Ge.getInput(0),je instanceof v?(Ye=je,[3,4]):[3,2];case 2:return[4,imageTensorToCanvas(je)];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),Ge=$e[0],je=$e[1],Ye=$e[2],qe=y.map(function(Qe){return Qe instanceof FaceDetection?Qe.forSize(je,Ge).box:Qe}).map(function(Qe){return Qe.clipAtImageBorders(je,Ge)}),Ke=qe.map(function(Qe){var Je=Qe.x,st=Qe.y,Mt=Qe.width,nn=Qe.height;return xl(m.as3D(Ge,je,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(Ge){switch(Ge.label){case 0:return v=env.getEnv().fetch,[4,v(m,y)];case 1:if($e=Ge.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 Ge=m.split("/").filter(function(qe){return qe}),je=m.endsWith(".json")?Ge[Ge.length-1]:v,Ye=$e+(m.endsWith(".json")?Ge.slice(0,Ge.length-1):Ge).join("/");return Ye=m.startsWith("/")?"/"+Ye:Ye,{modelBaseUri:Ye,manifestUri:Ye==="/"?"/"+je:Ye+"/"+je}}function loadWeightMap(m,y){return __awaiter(this,void 0,void 0,function(){var v,$e,Ge,je;return __generator(this,function(Ye){switch(Ye.label){case 0:return v=getModelUris(m,y),$e=v.manifestUri,Ge=v.modelBaseUri,[4,fetchJson($e)];case 1:return je=Ye.sent(),[2,ed.loadWeights(je,Ge)]}})})}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,Ge=v.objProp;return $e[Ge]},m.prototype.reassignParamFromPath=function(y,v){var $e=this.traversePropertyPath(y),Ge=$e.obj,je=$e.objProp;Ge[je].dispose(),Ge[je]=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,Ge=v.tensor;y.reassignParamFromPath($e,Ge.variable())})},m.prototype.freeze=function(){var y=this;this.getTrainableParams().forEach(function(v){var $e=v.path,Ge=v.tensor,je=Fn(Ge.dataSync());Ge.dispose(),y.reassignParamFromPath($e,je)})},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,Ge,je,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()),Ge=$e.manifestUri,je=$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(Ge)];case 1:return Ke=Je.apply(Qe,[Mt.sent().toString()]),[4,qe(Ke,je)];case 2:return st=Mt.sent(),this.loadFromWeightMap(st),[2]}})})},m.prototype.loadFromWeightMap=function(y){var v=this.extractParamsFromWeigthMap(y),$e=v.paramMappings,Ge=v.params;this._paramMappings=$e,this._params=Ge},m.prototype.extractWeights=function(y){var v=this.extractParams(y),$e=v.paramMappings,Ge=v.params;this._paramMappings=$e,this._params=Ge},m.prototype.traversePropertyPath=function(y){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var v=y.split("/").reduce(function(je,Ye){if(!je.nextObj.hasOwnProperty(Ye))throw new Error("traversePropertyPath - object does not have property "+Ye+", for path "+y);return{obj:je.nextObj,objProp:Ye,nextObj:je.nextObj[Ye]}},{nextObj:this.params}),$e=v.obj,Ge=v.objProp;if(!$e||!Ge||!($e[Ge]instanceof wt))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+y);return{obj:$e,objProp:Ge}},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])),Ge=depthwiseSeparableConv$1($e,y.conv1,[1,1]),je=Bl(rc($e,Ge)),Ye=depthwiseSeparableConv$1(je,y.conv2,[1,1]);return Bl(rc($e,rc(Ge,Ye)))})}function denseBlock4(m,y,v,$e){return v===void 0&&(v=!1),$e===void 0&&($e=!0),Ze(function(){var Ge=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])),je=depthwiseSeparableConv$1(Ge,y.conv1,[1,1]),Ye=Bl(rc(Ge,je)),qe=depthwiseSeparableConv$1(Ye,y.conv2,[1,1]),Ke=Bl(rc(Ge,rc(je,qe))),Qe=depthwiseSeparableConv$1(Ke,y.conv3,[1,1]);return Bl(rc(Ge,rc(je,rc(qe,Qe))))})}function convLayer$1(m,y,v,$e){return v===void 0&&(v="same"),$e===void 0&&($e=!1),Ze(function(){var Ge=rc(qc(m,y.filters,[1,1],v),y.bias);return $e?Bl(Ge):Ge})}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,Ge,je){var Ye=Ln(m(v*$e*Ge*Ge),[Ge,Ge,v,$e]),qe=Mn(m($e));return y.push({paramPath:je+"/filters"},{paramPath:je+"/bias"}),{filters:Ye,bias:qe}}}function extractFCParamsFactory(m,y){return function(v,$e,Ge){var je=Bn(m(v*$e),[v,$e]),Ye=Mn(m($e));return y.push({paramPath:Ge+"/weights"},{paramPath:Ge+"/bias"}),{weights:je,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,Ge){var je=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:Ge+"/depthwise_filter"},{paramPath:Ge+"/pointwise_filter"},{paramPath:Ge+"/bias"}),new SeparableConvParams(je,Ye,qe)}}function loadSeparableConvParamsFactory(m){return function(y){var v=m(y+"/depthwise_filter",4),$e=m(y+"/pointwise_filter",4),Ge=m(y+"/bias",1);return new SeparableConvParams(v,$e,Ge)}}function extractWeightEntryFactory(m,y){return function(v,$e,Ge){var je=m[v];if(!isTensor(je,$e))throw new Error("expected weightMap["+v+"] to be a Tensor"+$e+"D, instead have "+je);return y.push({originalPath:v,paramPath:Ge||v}),je}}function extractWeightsFactory(m){var y=m;function v(Ge){var je=y.slice(0,Ge);return y=y.slice(Ge),je}function $e(){return y}return{extractWeights:v,getRemainingWeights:$e}}function extractorsFactory$9(m,y){var v=extractConvParamsFactory(m,y),$e=extractSeparableConvParamsFactory(m,y);function Ge(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 je(Ye,qe,Ke,Qe){Qe===void 0&&(Qe=!1);var Je=Ge(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:Ge,extractDenseBlock4Params:je}}function extractParams$7(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,Ge=v.getRemainingWeights,je=extractorsFactory$9($e,y).extractDenseBlock4Params,Ye=je(3,32,"dense0",!0),qe=je(32,64,"dense1"),Ke=je(64,128,"dense2"),Qe=je(128,256,"dense3");if(Ge().length!==0)throw new Error("weights remaing after extract: "+Ge().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),Ge=loadSeparableConvParamsFactory(v);function je(qe,Ke){Ke===void 0&&(Ke=!1);var Qe=Ke?$e(qe+"/conv0"):Ge(qe+"/conv0"),Je=Ge(qe+"/conv1"),st=Ge(qe+"/conv2");return{conv0:Qe,conv1:Je,conv2:st}}function Ye(qe,Ke){Ke===void 0&&(Ke=!1);var Qe=Ke?$e(qe+"/conv0"):Ge(qe+"/conv0"),Je=Ge(qe+"/conv1"),st=Ge(qe+"/conv2"),Mt=Ge(qe+"/conv3");return{conv0:Qe,conv1:Je,conv2:st,conv3:Mt}}return{extractDenseBlock3Params:je,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 Ge=v.toBatchTensor(112,!0),je=[122.782,117.001,104.298],Ye=normalize$1(Ge,je).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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.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=[],Ge=extractWeightsFactory(m),je=Ge.extractWeights,Ye=Ge.getRemainingWeights,qe=extractFCParamsFactory(je,$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(je){var Ye=v(je+"/weights",2),qe=v(je+"/bias",1);return{weights:Ye,bias:qe}}var Ge={fc:$e("fc")};return disposeUnusedWeightTensors(m,y),{params:Ge,paramMappings:y}}function seperateWeightMaps(m){var y={},v={};return Object.keys(m).forEach(function($e){var Ge=$e.startsWith("fc")?v:y;Ge[$e]=m[$e]}),{featureExtractorMap:y,classifierMap:v}}var FaceProcessor=function(m){__extends(y,m);function y(v,$e){var Ge=m.call(this,v)||this;return Ge._faceFeatureExtractor=$e,Ge}return Object.defineProperty(y.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),y.prototype.runNet=function(v){var $e=this,Ge=this.params;if(!Ge)throw new Error(this._name+" - load model before inference");return Ze(function(){var je=v instanceof NetInput?$e.faceFeatureExtractor.forwardInput(v):v;return fullyConnectedLayer(je.as2D(je.shape[0],-1),Ge.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),Ge=$e.params,je=$e.paramMappings;this._params=Ge,this._paramMappings=je},y.prototype.extractClassifierParams=function(v){return extractParams$6(v,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},y.prototype.extractParamsFromWeigthMap=function(v){var $e=seperateWeightMaps(v),Ge=$e.featureExtractorMap,je=$e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(Ge),extractParamsFromWeigthMap$6(je)},y.prototype.extractParams=function(v){var $e=this.getClassifierChannelsIn(),Ge=this.getClassifierChannelsOut(),je=Ge*$e+Ge,Ye=v.slice(0,v.length-je),qe=v.slice(v.length-je);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,Ge){v[$e]=y[Ge]})}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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.sent()])]}})})},y.prototype.predictExpressions=function(v){return __awaiter(this,void 0,void 0,function(){var $e,Ge,je,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 Ge=Ke.sent(),[4,Promise.all(Ur(Ge).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 je=Ke.sent(),Ge.dispose(),Ye=je.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),Ge=$e.align(),je=m.detection.imageDims,Ye=new FaceDetection(m.detection.score,Ge.rescale(je.reverse()),je),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 Ge(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 je(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:Ge,extractMainBlockParams:je}}function extractParams$5(m,y){var v=[],$e=extractWeightsFactory(m),Ge=$e.extractWeights,je=$e.getRemainingWeights,Ye=extractorsFactory$8(Ge,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(fn){on["main_block_"+fn]=Je(128,"middle_flow/main_block_"+fn)});var an=Qe(128,256,"exit_flow/reduction_block"),un=Ke(256,512,"exit_flow/separable_conv"),ln={reduction_block:an,separable_conv:un};if(je().length!==0)throw new Error("weights remaing after extract: "+je().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),Ge=loadSeparableConvParamsFactory(v);function je(qe){var Ke=Ge(qe+"/separable_conv0"),Qe=Ge(qe+"/separable_conv1"),Je=$e(qe+"/expansion_conv");return{separable_conv0:Ke,separable_conv1:Qe,expansion_conv:Je}}function Ye(qe){var Ke=Ge(qe+"/separable_conv0"),Qe=Ge(qe+"/separable_conv1"),Je=Ge(qe+"/separable_conv2");return{separable_conv0:Ke,separable_conv1:Qe,separable_conv2:Je}}return{extractConvParams:$e,extractSeparableConvParams:Ge,extractReductionBlockParams:je,extractMainBlockParams:Ye}}function extractParamsFromWeigthMap$5(m,y){var v=[],$e=loadParamsFactory(m,v),Ge=$e.extractConvParams,je=$e.extractSeparableConvParams,Ye=$e.extractReductionBlockParams,qe=$e.extractMainBlockParams,Ke=Ge("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=je("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,Ge=this.params;if(!Ge)throw new Error("TinyXception - load model before inference");return Ze(function(){var je=v.toBatchTensor(112,!0),Ye=[122.782,117.001,104.298],qe=normalize$1(je,Ye).div(On(256)),Ke=Bl(conv$1(qe,Ge.entry_flow.conv_in,[2,2]));return Ke=reductionBlock(Ke,Ge.entry_flow.reduction_block_0,!1),Ke=reductionBlock(Ke,Ge.entry_flow.reduction_block_1),range($e._numMainBlocks,0,1).forEach(function(Qe){Ke=mainBlock(Ke,Ge.middle_flow["main_block_"+Qe])}),Ke=reductionBlock(Ke,Ge.exit_flow.reduction_block),Ke=Bl(depthwiseSeparableConv$1(Ke,Ge.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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.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,Ge=v.getRemainingWeights,je=extractFCParamsFactory($e,y),Ye=je(512,1,"fc/age"),qe=je(512,2,"fc/gender");if(Ge().length!==0)throw new Error("weights remaing after extract: "+Ge().length);return{paramMappings:y,params:{fc:{age:Ye,gender:qe}}}}function extractParamsFromWeigthMap$4(m){var y=[],v=extractWeightEntryFactory(m,y);function $e(je){var Ye=v(je+"/weights",2),qe=v(je+"/bias",1);return{weights:Ye,bias:qe}}var Ge={fc:{age:$e("fc/age"),gender:$e("fc/gender")}};return disposeUnusedWeightTensors(m,y),{params:Ge,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,Ge=this.params;if(!Ge)throw new Error(this._name+" - load model before inference");return Ze(function(){var je=v instanceof NetInput?$e.faceFeatureExtractor.forwardInput(v):v,Ye=fl(je,[7,7],[2,2],"valid").as2D(je.shape[0],-1),qe=fullyConnectedLayer(Ye,Ge.fc.age).as1D(),Ke=fullyConnectedLayer(Ye,Ge.fc.gender);return{age:qe,gender:Ke}})},y.prototype.forwardInput=function(v){var $e=this;return Ze(function(){var Ge=$e.runNet(v),je=Ge.age,Ye=Ge.gender;return{age:je,gender:go(Ye)}})},y.prototype.forward=function(v){return __awaiter(this,void 0,void 0,function(){var $e;return __generator(this,function(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.sent()])]}})})},y.prototype.predictAgeAndGender=function(v){return __awaiter(this,void 0,void 0,function(){var $e,Ge,je,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 Ge=Je.sent(),je=Ur(Ge.age),Ye=Ur(Ge.gender),qe=je.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,un,ln;return __generator(this,function(fn){switch(fn.label){case 0:return[4,Mt.data()];case 1:return rn=fn.sent()[0],[4,nn.data()];case 2:return on=fn.sent()[0],an=on>.5,un=an?Gender.MALE:Gender.FEMALE,ln=an?on:1-on,Mt.dispose(),nn.dispose(),[2,{age:rn,gender:un,genderProbability:ln}]}})})}))];case 3:return Ke=Je.sent(),Ge.age.dispose(),Ge.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),Ge=$e.params,je=$e.paramMappings;this._params=Ge,this._paramMappings=je},y.prototype.extractClassifierParams=function(v){return extractParams$4(v)},y.prototype.extractParamsFromWeigthMap=function(v){var $e=seperateWeightMaps(v),Ge=$e.featureExtractorMap,je=$e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(Ge),extractParamsFromWeigthMap$4(je)},y.prototype.extractParams=function(v){var $e=1539,Ge=v.slice(0,v.length-$e),je=v.slice(v.length-$e);return this.faceFeatureExtractor.extractWeights(Ge),this.extractClassifierParams(je)},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,Ge){var je=Ge.map(function(qe){var Ke=qe.width,Qe=qe.height,Je=$e/Math.max(Qe,Ke);return{width:Ke*Je,height:Qe*Je}}),Ye=je.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=je[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(je[nn].width,je[nn].height)})));return st})},y.prototype.forwardInput=function(v){var $e=this;return Ze(function(){var Ge=$e.runNet(v);return $e.postProcess(Ge,v.inputSize,v.inputDimensions.map(function(je){var Ye=je[0],qe=je[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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.sent()])]}})})},y.prototype.detectLandmarks=function(v){return __awaiter(this,void 0,void 0,function(){var $e,Ge,je,Ye=this;return __generator(this,function(qe){switch(qe.label){case 0:return[4,toNetInput(v)];case 1:return $e=qe.sent(),Ge=Ze(function(){return Ur(Ye.forwardInput($e))}),[4,Promise.all(Ge.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,un){return isEven(un)}),rn=Je.filter(function(an,un){return!isEven(un)}),[2,new FaceLandmarks68(Array(68).fill(0).map(function(an,un){return new Point(nn[un],rn[un])}),{height:$e.getInputHeight(Qe),width:$e.getInputWidth(Qe)})]}})})}))];case 2:return je=qe.sent(),Ge.forEach(function(Ke){return Ke.dispose()}),[2,$e.isBatchInput?je:je[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,Ge=v.getRemainingWeights,je=extractorsFactory$9($e,y).extractDenseBlock3Params,Ye=je(3,32,"dense0",!0),qe=je(32,64,"dense1"),Ke=je(64,128,"dense2");if(Ge().length!==0)throw new Error("weights remaing after extract: "+Ge().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 Ge=v.toBatchTensor(112,!0),je=[122.782,117.001,104.298],Ye=normalize$1(Ge,je).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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.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,Ge){Ge===void 0&&(Ge="same");var je=y.conv,Ye=je.filters,qe=je.bias,Ke=qc(m,Ye,v,Ge);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 Ge(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 je(qe,Ke,Qe,Je){var st=$e(qe,Ke,Qe,Je+"/conv"),Mt=Ge(Ke,Je+"/scale");return{conv:st,scale:Mt}}function Ye(qe,Ke,Qe,Je,st){st===void 0&&(st=!1);var Mt=je((st?.5:1)*qe,Ke,Qe,Je+"/conv1"),nn=je(qe,Ke,Qe,Je+"/conv2");return{conv1:Mt,conv2:nn}}return{extractConvLayerParams:je,extractResidualLayerParams:Ye}}function extractParams$3(m){var y=extractWeightsFactory(m),v=y.extractWeights,$e=y.getRemainingWeights,Ge=[],je=extractorsFactory$7(v,Ge),Ye=je.extractConvLayerParams,qe=je.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),un=qe(147456,128,3,"conv128_1"),ln=qe(147456,128,3,"conv128_2"),fn=qe(589824,256,3,"conv256_down",!0),cn=qe(589824,256,3,"conv256_1"),Xr=qe(589824,256,3,"conv256_2"),Mi=qe(589824,256,3,"conv256_down_out"),to=Ze(function(){return Wl(Bn(v(256*128),[128,256]),[1,0])});if(Ge.push({paramPath:"fc"}),$e().length!==0)throw new Error("weights remaing after extract: "+$e().length);var ld={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:un,conv128_2:ln,conv256_down:fn,conv256_1:cn,conv256_2:Xr,conv256_down_out:Mi,fc:to};return{params:ld,paramMappings:Ge}}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 Ge(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 je(Ye){return{conv1:Ge(Ye+"/conv1"),conv2:Ge(Ye+"/conv2")}}return{extractConvLayerParams:Ge,extractResidualLayerParams:je}}function extractParamsFromWeigthMap$3(m){var y=[],v=extractorsFactory$6(m,y),$e=v.extractConvLayerParams,Ge=v.extractResidualLayerParams,je=$e("conv32_down"),Ye=Ge("conv32_1"),qe=Ge("conv32_2"),Ke=Ge("conv32_3"),Qe=Ge("conv64_down"),Je=Ge("conv64_1"),st=Ge("conv64_2"),Mt=Ge("conv64_3"),nn=Ge("conv128_down"),rn=Ge("conv128_1"),on=Ge("conv128_2"),an=Ge("conv256_down"),un=Ge("conv256_1"),ln=Ge("conv256_2"),fn=Ge("conv256_down_out"),cn=m.fc;if(y.push({originalPath:"fc",paramPath:"fc"}),!isTensor2D(cn))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+cn);var Xr={conv32_down:je,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:un,conv256_2:ln,conv256_down_out:fn,fc:cn};return disposeUnusedWeightTensors(m,y),{params:Xr,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"),Ge=Gn($e.shape),je=$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=je?Yn([$e,Ge],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 Ge=v.toBatchTensor(150,!0).toFloat(),je=[122.782,117.001,104.298],Ye=normalize$1(Ge,je).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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.sent()])]}})})},y.prototype.computeFaceDescriptor=function(v){return __awaiter(this,void 0,void 0,function(){var $e,Ge,je,Ye=this;return __generator(this,function(qe){switch(qe.label){case 0:return[4,toNetInput(v)];case 1:return $e=qe.sent(),Ge=Ze(function(){return Ur(Ye.forwardInput($e))}),[4,Promise.all(Ge.map(function(Ke){return Ke.data()}))];case 2:return je=qe.sent(),Ge.forEach(function(Ke){return Ke.dispose()}),[2,$e.isBatchInput?je:je[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,Ge=v.scaleFactor,je=v.maxNumScales,Ye=v.scoreThresholds,qe=v.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=$e||20,this._scaleFactor=Ge||.709,this._maxNumScales=je||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 Ge(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 je(Ke,Qe,Je){var st=v(Ke,Je+"/depthwise_conv"),Mt=Ge(Ke,Qe,1,Je+"/pointwise_conv");return{depthwise_conv:st,pointwise_conv:Mt}}function Ye(){var Ke=Ge(3,32,3,"mobilenetv1/conv_0"),Qe=je(32,64,"mobilenetv1/conv_1"),Je=je(64,128,"mobilenetv1/conv_2"),st=je(128,128,"mobilenetv1/conv_3"),Mt=je(128,256,"mobilenetv1/conv_4"),nn=je(256,256,"mobilenetv1/conv_5"),rn=je(256,512,"mobilenetv1/conv_6"),on=je(512,512,"mobilenetv1/conv_7"),an=je(512,512,"mobilenetv1/conv_8"),un=je(512,512,"mobilenetv1/conv_9"),ln=je(512,512,"mobilenetv1/conv_10"),fn=je(512,512,"mobilenetv1/conv_11"),cn=je(512,1024,"mobilenetv1/conv_12"),Xr=je(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:un,conv_10:ln,conv_11:fn,conv_12:cn,conv_13:Xr}}function qe(){var Ke=Ge(1024,256,1,"prediction_layer/conv_0"),Qe=Ge(256,512,3,"prediction_layer/conv_1"),Je=Ge(512,128,1,"prediction_layer/conv_2"),st=Ge(128,256,3,"prediction_layer/conv_3"),Mt=Ge(256,128,1,"prediction_layer/conv_4"),nn=Ge(128,256,3,"prediction_layer/conv_5"),rn=Ge(256,64,1,"prediction_layer/conv_6"),on=Ge(64,128,3,"prediction_layer/conv_7"),an=$e(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),un=$e(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),ln=$e(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),fn=$e(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),cn=$e(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),Xr=$e(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),Mi=$e(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),to=$e(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),ld=$e(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),od=$e(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),Uo=$e(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),vd=$e(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),rd={box_encoding_predictor:an,class_predictor:un},mo={box_encoding_predictor:ln,class_predictor:fn},uo={box_encoding_predictor:cn,class_predictor:Xr},lo={box_encoding_predictor:Mi,class_predictor:to},fo={box_encoding_predictor:ld,class_predictor:od},ho={box_encoding_predictor:Uo,class_predictor:vd};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:rd,box_predictor_1:mo,box_predictor_2:uo,box_predictor_3:lo,box_predictor_4:fo,box_predictor_5:ho}}return{extractMobilenetV1Params:Ye,extractPredictionLayerParams:qe}}function extractParams$2(m){var y=[],v=extractWeightsFactory(m),$e=v.extractWeights,Ge=v.getRemainingWeights,je=extractorsFactory$5($e,y),Ye=je.extractMobilenetV1Params,qe=je.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"}),Ge().length!==0)throw new Error("weights remaing after extract: "+Ge().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 Ge(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"),un=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:un,batch_norm_variance:ln},pointwise_conv:$e("MobilenetV1",Qe,nn)}}function je(){return{conv_0:$e("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:Ge(1),conv_2:Ge(2),conv_3:Ge(3),conv_4:Ge(4),conv_5:Ge(5),conv_6:Ge(6),conv_7:Ge(7),conv_8:Ge(8),conv_9:Ge(9),conv_10:Ge(10),conv_11:Ge(11),conv_12:Ge(12),conv_13:Ge(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:je,extractPredictionLayerParams:Ke}}function extractParamsFromWeigthMap$2(m){var y=[],v=extractorsFactory$4(m,y),$e=v.extractMobilenetV1Params,Ge=v.extractPredictionLayerParams,je=m["Output/extra_dim"];if(y.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!isTensor3D(je))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+je);var Ye={mobilenetv1:$e(),prediction_layer:Ge(),output_layer:{extra_dim:je}};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]),Ge=[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(Ge.forEach(function(je,Ye){var qe=Ye+1,Ke=getStridesForLayerIdx(qe);$e=depthwiseConvLayer($e,je.depthwise_conv,Ke),$e=pointwiseConvLayer($e,je.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,Ge){var je=m.shape[0],Ye=Math.min(v,je),qe=y.map(function(Je,st){return{score:Je,boxIndex:st}}).filter(function(Je){return Je.score>Ge}).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<=Ge))break}st===Je.score&&Qe.push(Je.boxIndex)}}),Qe}function IOU(m,y,v){var $e=m.arraySync(),Ge=Math.min($e[y][0],$e[y][2]),je=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-Ge)*(qe-je),nn=(Je-Ke)*(st-Qe);if(Mt<=0||nn<=0)return 0;var rn=Math.max(Ge,Ke),on=Math.max(je,Qe),an=Math.min(Ye,Je),un=Math.min(qe,st),ln=Math.max(an-rn,0)*Math.max(un-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,Ge=v.centers,je=Ur(Wl(y,[1,0])),Ye=sc(gc(vu(sc(je[2],On(5))),$e[0]),On(2)),qe=rc(gc(sc(je[0],On(10)),$e[0]),Ge[0]),Ke=sc(gc(vu(sc(je[3],On(5))),$e[1]),On(2)),Qe=rc(gc(sc(je[1],On(10)),$e[1]),Ge[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],Ge=decodeBoxesLayer(Or(Lr(v.extra_dim,[$e,1,1]),[-1,4]),Or(m,[-1,4]));Ge=Or(Ge,[$e,Ge.shape[0]/$e,4]);var je=Iu(ml(y,[0,0,1],[-1,-1,-1])),Ye=ml(je,[0,0,0],[-1,-1,1]);Ye=Or(Ye,[$e,Ye.shape[1]]);var qe=Ur(Ge),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]),Ge=Or(convLayer$1(m,y.class_predictor),[v,-1,3]);return{boxPredictionEncoding:$e,classPrediction:Ge}})}function predictionLayer(m,y,v){return Ze(function(){var $e=pointwiseConvLayer(m,v.conv_0,[1,1]),Ge=pointwiseConvLayer($e,v.conv_1,[2,2]),je=pointwiseConvLayer(Ge,v.conv_2,[1,1]),Ye=pointwiseConvLayer(je,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(Ge,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),un=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:un,classPredictions:ln}})}var SsdMobilenetv1Options=function(){function m(y){var v=y===void 0?{}:y,$e=v.minConfidence,Ge=v.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=$e||.5,this._maxResults=Ge||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 Ge=v.toBatchTensor(512,!1).toFloat(),je=Cc(gc(Ge,On(.007843137718737125)),On(1)),Ye=mobileNetV1(je,$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(Ge){switch(Ge.label){case 0:return $e=this.forwardInput,[4,toNetInput(v)];case 1:return[2,$e.apply(this,[Ge.sent()])]}})})},y.prototype.locateFaces=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var Ge,je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln,fn,cn,Xr,Mi,to,ld;return __generator(this,function(od){switch(od.label){case 0:return Ge=new SsdMobilenetv1Options($e),je=Ge.maxResults,Ye=Ge.minConfidence,[4,toNetInput(v)];case 1:for(qe=od.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,[od.sent()]),un=.5,ln=nonMaxSuppression(st,rn,je,un,Ye),fn=qe.getReshapedInputDimensions(0),cn=qe.inputSize,Xr=cn/fn.width,Mi=cn/fn.height,to=st.arraySync(),ld=ln.map(function(Uo){var vd=[Math.max(0,to[Uo][0]),Math.min(1,to[Uo][2])].map(function(ho){return ho*Mi}),rd=vd[0],mo=vd[1],uo=[Math.max(0,to[Uo][1]),Math.min(1,to[Uo][3])].map(function(ho){return ho*Xr}),lo=uo[0],fo=uo[1];return new FaceDetection(rn[Uo],new Rect(lo,rd,fo-lo,mo-rd),{height:qe.getInputHeight(0),width:qe.getInputWidth(0)})}),st.dispose(),Mt.dispose(),[2,ld]}})})},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 Ge(Ye,qe,Ke){var Qe=v(Ye,qe,3,Ke+"/conv"),Je=$e(qe,Ke+"/bn");return{conv:Qe,bn:Je}}var je=extractSeparableConvParamsFactory(m,y);return{extractConvParams:v,extractConvWithBatchNormParams:Ge,extractSeparableConvParams:je}}function extractParams$1(m,y,v,$e){var Ge=extractWeightsFactory(m),je=Ge.extractWeights,Ye=Ge.getRemainingWeights,qe=[],Ke=extractorsFactory$3(je,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],un=$e[4],ln=$e[5],fn=$e[6],cn=$e[7],Xr=$e[8],Mi=y.isFirstLayerConv2d?Qe(nn,rn,3,"conv0"):st(nn,rn,"conv0"),to=st(rn,on,"conv1"),ld=st(on,an,"conv2"),od=st(an,un,"conv3"),Uo=st(un,ln,"conv4"),vd=st(ln,fn,"conv5"),rd=cn?st(fn,cn,"conv6"):void 0,mo=Xr?st(cn,Xr,"conv7"):void 0,uo=Qe(Xr||cn||fn,5*v,1,"conv8");Mt={conv0:Mi,conv1:to,conv2:ld,conv3:od,conv4:Uo,conv5:vd,conv6:rd,conv7:mo,conv8:uo}}else{var nn=$e[0],rn=$e[1],on=$e[2],an=$e[3],un=$e[4],ln=$e[5],fn=$e[6],cn=$e[7],Xr=$e[8],Mi=Je(nn,rn,"conv0"),to=Je(rn,on,"conv1"),ld=Je(on,an,"conv2"),od=Je(an,un,"conv3"),Uo=Je(un,ln,"conv4"),vd=Je(ln,fn,"conv5"),rd=Je(fn,cn,"conv6"),mo=Je(cn,Xr,"conv7"),uo=Qe(Xr,5*v,1,"conv8");Mt={conv0:Mi,conv1:to,conv2:ld,conv3:od,conv4:Uo,conv5:vd,conv6:rd,conv7:mo,conv8:uo}}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 Ge(qe){var Ke=v(qe+"/filters",4),Qe=v(qe+"/bias",1);return{filters:Ke,bias:Qe}}function je(qe){var Ke=Ge(qe+"/conv"),Qe=$e(qe+"/bn");return{conv:Ke,bn:Qe}}var Ye=loadSeparableConvParamsFactory(v);return{extractConvParams:Ge,extractConvWithBatchNormParams:je,extractSeparableConvParams:Ye}}function extractParamsFromWeigthMap$1(m,y){var v=[],$e=extractorsFactory$2(m,v),Ge=$e.extractConvParams,je=$e.extractConvWithBatchNormParams,Ye=$e.extractSeparableConvParams,qe;if(y.withSeparableConvs){var Ke=y.filterSizes&&y.filterSizes.length||9;qe={conv0:y.isFirstLayerConv2d?Ge("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:Ge("conv8")}}else qe={conv0:je("conv0"),conv1:je("conv1"),conv2:je("conv2"),conv3:je("conv3"),conv4:je("conv4"),conv5:je("conv5"),conv6:je("conv6"),conv7:je("conv7"),conv8:Ge("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,Ge=v.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=$e||416,this._scoreThreshold=Ge||.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 Ge=convWithBatchNorm(v,$e.conv0);return Ge=hl(Ge,[2,2],[2,2],"same"),Ge=convWithBatchNorm(Ge,$e.conv1),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=convWithBatchNorm(Ge,$e.conv2),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=convWithBatchNorm(Ge,$e.conv3),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=convWithBatchNorm(Ge,$e.conv4),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=convWithBatchNorm(Ge,$e.conv5),Ge=hl(Ge,[2,2],[1,1],"same"),Ge=convWithBatchNorm(Ge,$e.conv6),Ge=convWithBatchNorm(Ge,$e.conv7),convLayer$1(Ge,$e.conv8,"valid",!1)},y.prototype.runMobilenet=function(v,$e){var Ge=this.config.isFirstLayerConv2d?leaky(convLayer$1(v,$e.conv0,"valid",!1)):depthwiseSeparableConv(v,$e.conv0);return Ge=hl(Ge,[2,2],[2,2],"same"),Ge=depthwiseSeparableConv(Ge,$e.conv1),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=depthwiseSeparableConv(Ge,$e.conv2),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=depthwiseSeparableConv(Ge,$e.conv3),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=depthwiseSeparableConv(Ge,$e.conv4),Ge=hl(Ge,[2,2],[2,2],"same"),Ge=depthwiseSeparableConv(Ge,$e.conv5),Ge=hl(Ge,[2,2],[1,1],"same"),Ge=$e.conv6?depthwiseSeparableConv(Ge,$e.conv6):Ge,Ge=$e.conv7?depthwiseSeparableConv(Ge,$e.conv7):Ge,convLayer$1(Ge,$e.conv8,"valid",!1)},y.prototype.forwardInput=function(v,$e){var Ge=this,je=this.params;if(!je)throw new Error("TinyYolov2 - load model before inference");return Ze(function(){var Ye=v.toBatchTensor($e,!1).toFloat();return Ye=Ge.config.meanRgb?normalize$1(Ye,Ge.config.meanRgb):Ye,Ye=Ye.div(On(256)),Ge.config.withSeparableConvs?Ge.runMobilenet(Ye,je):Ge.runTinyYolov2(Ye,je)})},y.prototype.forward=function(v,$e){return __awaiter(this,void 0,void 0,function(){var Ge;return __generator(this,function(je){switch(je.label){case 0:return Ge=this.forwardInput,[4,toNetInput(v)];case 1:return[4,Ge.apply(this,[je.sent(),$e])];case 2:return[2,je.sent()]}})})},y.prototype.detect=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var Ge,je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln=this;return __generator(this,function(fn){switch(fn.label){case 0:return Ge=new TinyYolov2Options($e),je=Ge.inputSize,Ye=Ge.scoreThreshold,[4,toNetInput(v)];case 1:return qe=fn.sent(),[4,this.forwardInput(qe,je)];case 2:return Ke=fn.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=fn.sent(),Ke.dispose(),Qe.dispose(),Mt=st.map(function(cn){return cn.box}),nn=st.map(function(cn){return cn.score}),rn=st.map(function(cn){return cn.classScore}),on=st.map(function(cn){return ln.config.classes[cn.label]}),an=nonMaxSuppression$1(Mt.map(function(cn){return cn.rescale(je)}),nn,this.config.iouThreshold,!0),un=an.map(function(cn){return new ObjectDetection(nn[cn],rn[cn],on[cn],Mt[cn],Je)}),[2,un]}})})},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,Ge=$e?$e.length:void 0;if(Ge!==7&&Ge!==8&&Ge!==9)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+Ge+" filterSizes in config");return extractParams$1(v,this.config,this.boxEncodingSize,$e)},y.prototype.extractBoxes=function(v,$e,Ge){return __awaiter(this,void 0,void 0,function(){var je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln,fn,cn,Xr,Mi,to,ld,od,Uo,vd,rd,mo,uo,lo,fo,ho,hd=this;return __generator(this,function(dd){switch(dd.label){case 0:return je=$e.width,Ye=$e.height,qe=Math.max(je,Ye),Ke=qe/je,Qe=qe/Ye,Je=v.shape[1],st=this.config.anchors.length,Mt=Ze(function(){var pd=v.reshape([Je,Je,st,hd.boxEncodingSize]),gd=pd.slice([0,0,0,0],[Je,Je,st,4]),Sd=pd.slice([0,0,0,4],[Je,Je,st,1]),yd=hd.withClassScores?go(pd.slice([0,0,0,5],[Je,Je,st,hd.config.classes.length]),3):On(0);return[gd,Sd,yd]}),nn=Mt[0],rn=Mt[1],on=Mt[2],an=[],[4,rn.array()];case 1:return un=dd.sent(),[4,nn.array()];case 2:ln=dd.sent(),fn=0,dd.label=3;case 3:if(!(fn<Je))return[3,12];cn=0,dd.label=4;case 4:if(!(cn<Je))return[3,11];Xr=0,dd.label=5;case 5:return Xr<st?(Mi=sigmoid(un[fn][cn][Xr][0]),!Ge||Mi>Ge?(to=(cn+sigmoid(ln[fn][cn][Xr][0]))/Je*Ke,ld=(fn+sigmoid(ln[fn][cn][Xr][1]))/Je*Qe,od=Math.exp(ln[fn][cn][Xr][2])*this.config.anchors[Xr].x/Je*Ke,Uo=Math.exp(ln[fn][cn][Xr][3])*this.config.anchors[Xr].y/Je*Qe,vd=to-od/2,rd=ld-Uo/2,mo={row:fn,col:cn,anchor:Xr},this.withClassScores?[4,this.extractPredictedClass(on,mo)]:[3,7]):[3,9]):[3,10];case 6:return ho=dd.sent(),[3,8];case 7:ho={classScore:1,label:0},dd.label=8;case 8:uo=ho,lo=uo.classScore,fo=uo.label,an.push(__assign({box:new BoundingBox(vd,rd,vd+od,rd+Uo),score:Mi,classScore:Mi*lo,label:fo},mo)),dd.label=9;case 9:return Xr++,[3,5];case 10:return cn++,[3,4];case 11:return fn++,[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 Ge,je,Ye,qe;return __generator(this,function(Ke){switch(Ke.label){case 0:return Ge=$e.row,je=$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[Ge][je][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,Ge=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,Ge)||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 Ge;return __generator(this,function(je){switch(je.label){case 0:return[4,this.detect(v,$e)];case 1:return Ge=je.sent(),[2,Ge.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,Ge){return Ge===void 0&&(Ge=function(je){var Ye=je.alignedRect;return Ye}),__awaiter(this,void 0,void 0,function(){var je,Ye,qe,Ke,Qe;return __generator(this,function(Je){switch(Je.label){case 0:return je=m.map(function(st){return isWithFaceLandmarks(st)?Ge(st):st.detection}),qe=$e,qe?[3,5]:y instanceof wt?[4,extractFaceTensors(y,je)]:[3,2];case 1:return Ke=Je.sent(),[3,4];case 2:return[4,extractFaces(y,je)];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,Ge){return __awaiter(this,void 0,void 0,function(){var je=this;return __generator(this,function(Ye){return[2,extractAllFacesAndComputeResults([m],y,function(qe){return __awaiter(je,void 0,void 0,function(){return __generator(this,function(Ke){return[2,v(qe[0])]})})},$e,Ge)]})})}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 Ge(Qe,Je){var st=Mn(m(Qe));return y.push({paramPath:Je}),st}function je(Qe,Je,st){st===void 0&&(st=!1);var Mt=v(Qe[0],Qe[1],3,Je+"/conv1"),nn=Ge(Qe[1],Je+"/prelu1_alpha"),rn=v(Qe[1],Qe[2],3,Je+"/conv2"),on=Ge(Qe[2],Je+"/prelu2_alpha"),an=v(Qe[2],Qe[3],st?2:3,Je+"/conv3"),un=Ge(Qe[3],Je+"/prelu3_alpha");return{conv1:Mt,prelu1_alpha:nn,conv2:rn,prelu2_alpha:on,conv3:an,prelu3_alpha:un}}function Ye(){var Qe=je([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=je([3,28,48,64],"rnet",!0),Je=$e(576,128,"rnet/fc1"),st=Ge(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=je([3,32,64,64],"onet"),Je=v(64,128,2,"onet/conv4"),st=Ge(128,"onet/prelu4_alpha"),Mt=$e(1152,256,"onet/fc1"),nn=Ge(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,Ge=[],je=extractorsFactory$1(v,Ge),Ye=je.extractPNetParams,qe=je.extractRNetParams,Ke=je.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:Ge}}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 Ge(Je){var st=v(Je+"/weights",2),Mt=v(Je+"/bias",1);return{weights:st,bias:Mt}}function je(Je){return v(Je,1)}function Ye(Je){var st=$e(Je+"/conv1"),Mt=je(Je+"/prelu1_alpha"),nn=$e(Je+"/conv2"),rn=je(Je+"/prelu2_alpha"),on=$e(Je+"/conv3"),an=je(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=Ge("rnet/fc1"),Mt=je("rnet/prelu4_alpha"),nn=Ge("rnet/fc2_1"),rn=Ge("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=je("onet/prelu4_alpha"),nn=Ge("onet/fc1"),rn=je("onet/prelu5_alpha"),on=Ge("onet/fc2_1"),an=Ge("onet/fc2_2"),un=Ge("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:un})}return{extractPNetParams:qe,extractRNetParams:Ke,extractONetParams:Qe}}function extractParamsFromWeigthMap(m){var y=[],v=extractorsFactory(m,y),$e=v.extractPNetParams,Ge=v.extractRNetParams,je=v.extractONetParams,Ye=$e(),qe=Ge(),Ke=je();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],Ge=v[1],je=CELL_SIZE/m,Ye=[],qe=Math.min($e,Ge)*je,Ke=0;qe>=12;)Ye.push(je*Math.pow(y,Ke)),qe=qe*y,Ke+=1;return Ye}var MtcnnBox=function(m){__extends(y,m);function y(v,$e,Ge,je){return m.call(this,{left:v,top:$e,right:Ge,bottom:je},!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"),Ge=wr(Sl($e,3),3),je=go(Cc($e,Ge),3),Ye=convLayer$1(v,y.conv4_2,"valid");return{prob:je,regions:Ye}})}function rescaleAndNormalize(m,y){return Ze(function(){var v=getSizesForScale(y,m.shape.slice(1)),$e=v.height,Ge=v.width,je=Oh.resizeBilinear(m,[$e,Ge]),Ye=normalize(je);return Wl(Ye,[0,2,1,3])})}function extractBoundingBoxes(m,y,v,$e){for(var Ge=[],je=m.arraySync(),Ye=0;Ye<m.shape[0];Ye++)for(var qe=0;qe<m.shape[1];qe++)je[Ye][qe]>=$e&&Ge.push(new Point(qe,Ye));var Ke=Ge.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=je[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,Ge){Ge.stage1=[];var je=y.map(function(Mt){return Ze(function(){var nn={scale:Mt},rn=rescaleAndNormalize(m,Mt),on=Date.now(),an=PNet(rn,$e),un=an.prob,ln=an.regions;nn.pnet=Date.now()-on;var fn=Ur(Ur(un,3)[1])[0],cn=Ur(ln)[0];return{scoresTensor:fn,regionsTensor:cn,scale:Mt,statsForScale:nn}})}),Ye=je.map(function(Mt){var nn=Mt.scoresTensor,rn=Mt.regionsTensor,on=Mt.scale,an=Mt.statsForScale,un=extractBoundingBoxes(nn,rn,on,v);if(nn.dispose(),rn.dispose(),!un.length)return Ge.stage1.push(an),[];var ln=Date.now(),fn=nonMaxSuppression$1(un.map(function(cn){return cn.cell}),un.map(function(cn){return cn.score}),.5);return an.nms=Date.now()-ln,an.numBoxes=fn.length,Ge.stage1.push(an),fn.map(function(cn){return un[cn]})}),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);Ge.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,Ge=v.height;return __awaiter(this,void 0,void 0,function(){var je,Ye,qe,Ke=this;return __generator(this,function(Qe){switch(Qe.label){case 0:return je=getContext2dOrThrow(m),[4,Promise.all(y.map(function(Je){return __awaiter(Ke,void 0,void 0,function(){var st,Mt,nn,rn,on,an,un,ln;return __generator(this,function(fn){return st=Je.padAtBorders(m.height,m.width),Mt=st.y,nn=st.ey,rn=st.x,on=st.ex,an=rn-1,un=Mt-1,ln=je.getImageData(an,un,on-an,nn-un),[2,env.isNodejs()?createCanvasFromMedia(ln):createImageBitmap(ln)]})})}))];case 1:return Ye=Qe.sent(),qe=[],Ye.forEach(function(Je){var st=createCanvas({width:$e,height:Ge}),Mt=getContext2dOrThrow(st);Mt.drawImage(Je,0,0,$e,Ge);for(var nn=Mt.getImageData(0,0,$e,Ge).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,Ge,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]]),Ge=fullyConnectedLayer($e,y.fc1),je=prelu(Ge,y.prelu4_alpha),Ye=fullyConnectedLayer(je,y.fc2_1),qe=wr(Sl(Ye,1),1),Ke=go(Cc(Ye,qe),1),Qe=fullyConnectedLayer(je,y.fc2_2),Je=Ur(Ke,1)[1];return{scores:Je,regions:Qe}})}function stage2(m,y,v,$e,Ge){return __awaiter(this,void 0,void 0,function(){var je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln;return __generator(this,function(fn){switch(fn.label){case 0:return je=Date.now(),[4,extractImagePatches(m,y,{width:24,height:24})];case 1:return Ye=fn.sent(),Ge.stage2_extractImagePatches=Date.now()-je,je=Date.now(),qe=Ye.map(function(cn){var Xr=RNet(cn,$e);return cn.dispose(),Xr}),Ge.stage2_rnet=Date.now()-je,Ke=qe.length>1?Yn(qe.map(function(cn){return cn.scores})):qe[0].scores,st=(Je=Array).from,[4,Ke.data()];case 2:return Qe=st.apply(Je,[fn.sent()]),Ke.dispose(),Mt=Qe.map(function(cn,Xr){return{score:cn,idx:Xr}}).filter(function(cn){return cn.score>v}).map(function(cn){var Xr=cn.idx;return Xr}),nn=Mt.map(function(cn){return y[cn]}),rn=Mt.map(function(cn){return Qe[cn]}),on=[],an=[],nn.length>0&&(je=Date.now(),un=nonMaxSuppression$1(nn,rn,.7),Ge.stage2_nms=Date.now()-je,ln=un.map(function(cn){var Xr=qe[Mt[cn]].regions.arraySync();return new MtcnnBox(Xr[0][0],Xr[0][1],Xr[0][2],Xr[0][3])}),an=un.map(function(cn){return rn[cn]}),on=un.map(function(cn,Xr){return nn[cn].calibrate(ln[Xr])})),qe.forEach(function(cn){cn.regions.dispose(),cn.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]]),Ge=fullyConnectedLayer($e,y.fc1),je=prelu(Ge,y.prelu5_alpha),Ye=fullyConnectedLayer(je,y.fc2_1),qe=wr(Sl(Ye,1),1),Ke=go(Cc(Ye,qe),1),Qe=fullyConnectedLayer(je,y.fc2_2),Je=fullyConnectedLayer(je,y.fc2_3),st=Ur(Ke,1)[1];return{scores:st,regions:Qe,points:Je}})}function stage3(m,y,v,$e,Ge){return __awaiter(this,void 0,void 0,function(){var je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln,fn;return __generator(this,function(cn){switch(cn.label){case 0:return je=Date.now(),[4,extractImagePatches(m,y,{width:48,height:48})];case 1:return Ye=cn.sent(),Ge.stage3_extractImagePatches=Date.now()-je,je=Date.now(),qe=Ye.map(function(Xr){var Mi=ONet(Xr,$e);return Xr.dispose(),Mi}),Ge.stage3_onet=Date.now()-je,Ke=qe.length>1?Yn(qe.map(function(Xr){return Xr.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(Xr,Mi){return{score:Xr,idx:Mi}}).filter(function(Xr){return Xr.score>v}).map(function(Xr){var Mi=Xr.idx;return Mi}),nn=Mt.map(function(Xr){var Mi=qe[Xr].regions.arraySync();return new MtcnnBox(Mi[0][0],Mi[0][1],Mi[0][2],Mi[0][3])}),rn=Mt.map(function(Xr,Mi){return y[Xr].calibrate(nn[Mi])}),on=Mt.map(function(Xr){return Qe[Xr]}),an=[],un=[],ln=[],rn.length>0&&(je=Date.now(),fn=nonMaxSuppression$1(rn,on,.7,!1),Ge.stage3_nms=Date.now()-je,an=fn.map(function(Xr){return rn[Xr]}),un=fn.map(function(Xr){return on[Xr]}),ln=fn.map(function(Xr,Mi){return Array(5).fill(0).map(function(to,ld){var od=qe[Xr].points.arraySync();return new Point(od[0][ld]*(an[Mi].width+1)+an[Mi].left,od[0][ld+5]*(an[Mi].height+1)+an[Mi].top)})})),qe.forEach(function(Xr){Xr.regions.dispose(),Xr.scores.dispose(),Xr.points.dispose()}),[2,{boxes:an,scores:un,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 Ge,je,Ye,qe,Ke,Qe,Je,st,Mt,nn,rn,on,an,un,ln,fn,cn,Xr,Mi,to,ld;return __generator(this,function(od){switch(od.label){case 0:if(Ge=this.params,!Ge)throw new Error("Mtcnn - load model before inference");if(je=v.canvases[0],!je)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(je)).toFloat())}),Qe=function(Uo){return Ke.dispose(),Ye.total=Date.now()-qe,Uo},Je=Ke.shape.slice(1),st=Je[0],Mt=Je[1],nn=new MtcnnOptions($e),rn=nn.minFaceSize,on=nn.scaleFactor,an=nn.maxNumScales,un=nn.scoreThresholds,ln=nn.scaleSteps,fn=(ln||pyramidDown(rn,on,[st,Mt])).filter(function(Uo){var vd=getSizesForScale(Uo,[st,Mt]);return Math.min(vd.width,vd.height)>CELL_SIZE}).slice(0,an),Ye.scales=fn,Ye.pyramid=fn.map(function(Uo){return getSizesForScale(Uo,[st,Mt])}),cn=Date.now(),[4,stage1(Ke,fn,un[0],Ge.pnet,Ye)];case 1:return Xr=od.sent(),Ye.total_stage1=Date.now()-cn,Xr.boxes.length?(Ye.stage2_numInputBoxes=Xr.boxes.length,cn=Date.now(),[4,stage2(je,Xr.boxes,un[1],Ge.rnet,Ye)]):[2,Qe({results:[],stats:Ye})];case 2:return Mi=od.sent(),Ye.total_stage2=Date.now()-cn,Mi.boxes.length?(Ye.stage3_numInputBoxes=Mi.boxes.length,cn=Date.now(),[4,stage3(je,Mi.boxes,un[2],Ge.onet,Ye)]):[2,Qe({results:[],stats:Ye})];case 3:return to=od.sent(),Ye.total_stage3=Date.now()-cn,ld=to.boxes.map(function(Uo,vd){return extendWithFaceLandmarks(extendWithFaceDetection({},new FaceDetection(to.scores[vd],new Rect(Uo.left/Mt,Uo.top/st,Uo.width/Mt,Uo.height/st),{height:st,width:Mt})),new FaceLandmarks5(to.points[vd].map(function(rd){return rd.sub(new Point(Uo.left,Uo.top)).div(new Point(Uo.width,Uo.height))}),{width:Uo.width,height:Uo.height}))}),[2,Qe({results:ld,stats:Ye})]}})})},y.prototype.forward=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var Ge;return __generator(this,function(je){switch(je.label){case 0:return Ge=this.forwardInput,[4,toNetInput(v)];case 1:return[4,Ge.apply(this,[je.sent(),$e])];case 2:return[2,je.sent().results]}})})},y.prototype.forwardWithStats=function(v,$e){return $e===void 0&&($e={}),__awaiter(this,void 0,void 0,function(){var Ge;return __generator(this,function(je){switch(je.label){case 0:return Ge=this.forwardInput,[4,toNetInput(v)];case 1:return[2,Ge.apply(this,[je.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 Ge;return __generator(this,function(je){switch(je.label){case 0:return[4,this.detect(v,$e)];case 1:return Ge=je.sent(),[2,Ge.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,Ge){var je=m.call(this)||this;return je.parentTask=v,je.input=$e,je.extractedFaces=Ge,je}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,Ge=this;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(Ye){return __awaiter(Ge,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=je.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(Ge){switch(Ge.label){case 0:return[4,this.parentTask];case 1:return v=Ge.sent(),v?[4,extractSingleFaceAndComputeResult(v,this.input,function(je){return nets.faceExpressionNet.predictExpressions(je)},this.extractedFaces)]:[2];case 2:return $e=Ge.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,Ge){var je=m.call(this)||this;return je.parentTask=v,je.input=$e,je.extractedFaces=Ge,je}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,Ge=this;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(Ye){return __awaiter(Ge,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=je.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,Ge,je,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(),Ge=$e.age,je=$e.gender,Ye=$e.genderProbability,[2,extendWithAge(extendWithGender(v,je,Ye),Ge)]}})})},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 Ge=m.call(this)||this;return Ge.parentTask=v,Ge.input=$e,Ge}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(Ge){switch(Ge.label){case 0:return[4,this.parentTask];case 1:return v=Ge.sent(),[4,extractAllFacesAndComputeResults(v,this.input,function(je){return Promise.all(je.map(function(Ye){return nets.faceRecognitionNet.computeFaceDescriptor(Ye)}))},null,function(je){return je.landmarks.align(null,{useDlibAlignment:!0})})];case 2:return $e=Ge.sent(),[2,$e.map(function(je,Ye){return extendWithFaceDescriptor(v[Ye],je)})]}})})},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(Ge){switch(Ge.label){case 0:return[4,this.parentTask];case 1:return v=Ge.sent(),v?[4,extractSingleFaceAndComputeResult(v,this.input,function(je){return nets.faceRecognitionNet.computeFaceDescriptor(je)},null,function(je){return je.landmarks.align(null,{useDlibAlignment:!0})})]:[2];case 2:return $e=Ge.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,Ge){var je=m.call(this)||this;return je.parentTask=v,je.input=$e,je.useTinyLandmarkNet=Ge,je}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,Ge,je,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 je=Ke.sent(),[3,5];case 3:return[4,extractFaces(this.input,$e)];case 4:je=Ke.sent(),Ke.label=5;case 5:return Ge=je,[4,Promise.all(Ge.map(function(Qe){return qe.landmarkNet.detectLandmarks(Qe)}))];case 6:return Ye=Ke.sent(),Ge.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,Ge,je,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 je=qe.sent(),[3,5];case 3:return[4,extractFaces(this.input,[$e])];case 4:je=qe.sent(),qe.label=5;case 5:return Ge=je,[4,this.landmarkNet.detectLandmarks(Ge[0])];case 6:return Ye=qe.sent(),Ge.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 Ge=m.call(this)||this;return Ge.input=v,Ge.options=$e,Ge}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,Ge,je;return __generator(this,function(Ye){switch(Ye.label){case 0:return v=this,$e=v.input,Ge=v.options,Ge instanceof MtcnnOptions?[4,nets.mtcnn.forward($e,Ge)]:[3,2];case 1:return[2,Ye.sent().map(function(qe){return qe.detection})];case 2:if(je=Ge instanceof TinyFaceDetectorOptions?function(qe){return nets.tinyFaceDetector.locateFaces(qe,Ge)}:Ge instanceof SsdMobilenetv1Options?function(qe){return nets.ssdMobilenetv1.locateFaces(qe,Ge)}:Ge instanceof TinyYolov2Options?function(qe){return nets.tinyYolov2.locateFaces(qe,Ge)}:null,!je)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,je($e)]}})})},y.prototype.runAndExtendWithFaceDetections=function(){var v=this;return new Promise(function($e){return __awaiter(v,void 0,void 0,function(){var Ge;return __generator(this,function(je){switch(je.label){case 0:return[4,this.run()];case 1:return Ge=je.sent(),[2,$e(Ge.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(Ge){switch(Ge.label){case 0:return[4,new DetectAllFacesTask(this.input,this.options)];case 1:return v=Ge.sent(),$e=v[0],v.forEach(function(je){je.score>$e.score&&($e=je)}),[2,$e]}})})},y.prototype.runAndExtendWithFaceDetection=function(){var v=this;return new Promise(function($e){return __awaiter(v,void 0,void 0,function(){var Ge;return __generator(this,function(je){switch(je.label){case 0:return[4,this.run()];case 1:return Ge=je.sent(),[2,$e(Ge?extendWithFaceDetection({},Ge):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(Ge,je){return Ge-$e[je]}).reduce(function(Ge,je){return Ge+Math.pow(je,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 Ge=1,je=function(){return"person "+Ge++};this._labeledDescriptors=$e.map(function(Ye){if(Ye instanceof LabeledFaceDescriptors)return Ye;if(Ye instanceof Float32Array)return new LabeledFaceDescriptors(je(),[Ye]);if(Ye.descriptor&&Ye.descriptor instanceof Float32Array)return new LabeledFaceDescriptors(je(),[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,Ge){return $e+Ge},0)/(v.length||1)},m.prototype.matchDescriptor=function(y){var v=this;return this.labeledDescriptors.map(function($e){var Ge=$e.descriptors,je=$e.label;return new FaceMatch(je,v.computeMeanDistance(y,Ge))}).reduce(function($e,Ge){return $e.distance<Ge.distance?$e:Ge})},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$1(m){const y=m.indexOf("base64,");return y<0?-1:(m.substr(y+6).length*.75).toFixed(2)}function base64toFile$1(m,y,v){let $e=atob(m),Ge=$e.length,je=new Uint8Array(Ge);for(;Ge--;)je[Ge]=$e.charCodeAt(Ge);return new File([je],y,{type:v})}function createEyeMask(m,y){const v=[...m,...y],$e=v.map(st=>st.x),Ge=v.map(st=>st.y),je=Math.min(...$e),Ye=Math.max(...$e),qe=Math.min(...Ge),Ke=Math.max(...Ge),Qe=(Ye-je)*.4,Je=(Ke-qe)*.8+6;return{x:je-Qe,y:qe-Je,width:Ye-je+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)),Ge=Math.round(y.width),je=Math.round(y.height);m.fillStyle="#000000",m.fillRect(v,$e,Ge,je)}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}),Ge=await detectAllFaces($e,new TinyFaceDetectorOptions).withFaceLandmarks(!0);if(!Ge.length){console.warn("faceMaskImage: 未检测到人脸"),y&&y(null);return}const je=document.createElement("canvas");je.width=$e.naturalWidth,je.height=$e.naturalHeight;const Ye=je.getContext("2d");Ye.drawImage($e,0,0),Ge.forEach(({landmarks:Qe})=>{const Je=Qe.getLeftEye(),st=Qe.getRightEye(),Mt=createEyeMask(Je,st);applyMosaic(Ye,Mt)});const qe=je.toDataURL("image/jpeg",.9),Ke=getBase64ImageSize$1(qe);console.log("faceMaskImage 处理后大小(字节):",Ke),y&&y(base64toFile$1(qe.split(",")[1],"face-masked.jpg","image/jpeg"))}const fun$1=(m,y,v)=>y.then($e=>($e instanceof File&&(m=$e),/^image\/\w+/.test(m.type)?new Promise((Ge,je)=>{let Ye=v.fileList.filter(qe=>qe.raw&&qe.raw==m)[0];if(!Ye){je();return}Ye.message="打码处理中...",faceMaskImage(URL.createObjectURL(m),qe=>{if(Ye.message="",!qe){Ge(m);return}setBaseProps(qe,Ye.raw),Ye.raw=qe;debugger;Ge(Ye.raw)})}):!0));var lodash$1={exports:{}};/**
|
|
4971
4971
|
* @license
|
|
4972
4972
|
* Lodash <https://lodash.com/>
|
|
4973
4973
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
@@ -4993,4 +4993,4 @@ __p += '`),Tp&&(Zd+=`' +
|
|
|
4993
4993
|
function print() { __p += __j.call(arguments, '') }
|
|
4994
4994
|
`:`;
|
|
4995
4995
|
`)+Zd+`return __p
|
|
4996
|
-
}`;var wp=eb(function(){return Mp(Ad,sp+"return "+Zd).apply(v,Md)});if(wp.source=Zd,my(wp))throw wp;return wp}function HE(sn){return Ip(sn).toLowerCase()}function zE(sn){return Ip(sn).toUpperCase()}function GE(sn,hn,co){if(sn=Ip(sn),sn&&(co||hn===v))return l0(sn);if(!sn||!(hn=ov(hn)))return sn;var fd=mv(sn),md=mv(hn),Ad=c0(fd,md),Md=d0(fd,md)+1;return Wv(fd,Ad,Md).join("")}function jE(sn,hn,co){if(sn=Ip(sn),sn&&(co||hn===v))return sn.slice(0,f0(sn)+1);if(!sn||!(hn=ov(hn)))return sn;var fd=mv(sn),md=d0(fd,mv(hn))+1;return Wv(fd,0,md).join("")}function KE(sn,hn,co){if(sn=Ip(sn),sn&&(co||hn===v))return sn.replace(mm,"");if(!sn||!(hn=ov(hn)))return sn;var fd=mv(sn),md=c0(fd,mv(hn));return Wv(fd,md).join("")}function YE(sn,hn){var co=Uo,fd=vd;if(Pp(hn)){var md="separator"in hn?hn.separator:md;co="length"in hn?yp(hn.length):co,fd="omission"in hn?ov(hn.omission):fd}sn=Ip(sn);var Ad=sn.length;if(eg(sn)){var Md=mv(sn);Ad=Md.length}if(co>=Ad)return sn;var Pd=co-tg(fd);if(Pd<1)return fd;var Vd=Md?Wv(Md,0,Pd).join(""):sn.slice(0,Pd);if(md===v)return Vd+fd;if(Md&&(Pd+=Vd.length-Pd),yy(md)){if(sn.slice(Pd).search(md)){var qd,Xd=Vd;for(md.global||(md=Om(md.source,Ip(My.exec(md))+"g")),md.lastIndex=0;qd=md.exec(Xd);)var Zd=qd.index;Vd=Vd.slice(0,Zd===v?Pd:Zd)}}else if(sn.indexOf(ov(md),Pd)!=Pd){var tp=Vd.lastIndexOf(md);tp>-1&&(Vd=Vd.slice(0,tp))}return Vd+fd}function qE(sn){return sn=Ip(sn),sn&&ab.test(sn)?sn.replace(Ty,Ew):sn}var XE=ug(function(sn,hn,co){return sn+(co?" ":"")+hn.toUpperCase()}),xy=t1("toUpperCase");function Q1(sn,hn,co){return sn=Ip(sn),hn=co?v:hn,hn===v?bw(sn)?kw(sn):cw(sn):sn.match(hn)||[]}var eb=xp(function(sn,hn){try{return rv(sn,v,hn)}catch(co){return my(co)?co:new gp(co)}}),JE=Rv(function(sn,hn){return cv(hn,function(co){co=Cv(co),kv(sn,co,vy(sn[co],sn))}),sn});function ZE(sn){var hn=sn==null?0:sn.length,co=cp();return sn=hn?Fp(sn,function(fd){if(typeof fd[1]!="function")throw new dv(Ye);return[co(fd[0]),fd[1]]}):[],xp(function(fd){for(var md=-1;++md<hn;){var Ad=sn[md];if(rv(Ad[0],this,fd))return rv(Ad[1],this,fd)}})}function QE(sn){return Ex(fv(sn,st))}function _y(sn){return function(){return sn}}function eS(sn,hn){return sn==null||sn!==sn?hn:sn}var tS=r1(),nS=r1(!0);function nv(sn){return sn}function Cy(sn){return L0(typeof sn=="function"?sn:fv(sn,st))}function rS(sn){return $0(fv(sn,st))}function iS(sn,hn){return D0(sn,fv(hn,st))}var oS=xp(function(sn,hn){return function(co){return wg(co,sn,hn)}}),aS=xp(function(sn,hn){return function(co){return wg(sn,co,hn)}});function Ey(sn,hn,co){var fd=Gp(hn),md=Xg(hn,fd);co==null&&!(Pp(hn)&&(md.length||!fd.length))&&(co=hn,hn=sn,sn=this,md=Xg(hn,Gp(hn)));var Ad=!(Pp(co)&&"chain"in co)||!!co.chain,Md=Mv(sn);return cv(md,function(Pd){var Vd=hn[Pd];sn[Pd]=Vd,Md&&(sn.prototype[Pd]=function(){var qd=this.__chain__;if(Ad||qd){var Xd=sn(this.__wrapped__),Zd=Xd.__actions__=Qp(this.__actions__);return Zd.push({func:Vd,args:arguments,thisArg:sn}),Xd.__chain__=qd,Xd}return Vd.apply(sn,$v([this.value()],arguments))})}),sn}function sS(){return jp._===this&&(jp._=Lw),this}function Sy(){}function uS(sn){return sn=yp(sn),xp(function(hn){return F0(hn,sn)})}var lS=ny(Fp),cS=ny(i0),dS=ny(km);function tb(sn){return ly(sn)?Tm(Cv(sn)):Wx(sn)}function hS(sn){return function(hn){return sn==null?v:Yv(sn,hn)}}var fS=o1(),pS=o1(!0);function Ay(){return[]}function ky(){return!1}function vS(){return{}}function gS(){return""}function mS(){return!0}function yS(sn,hn){if(sn=yp(sn),sn<1||sn>hd)return[];var co=gd,fd=Yp(sn,gd);hn=cp(hn),sn-=gd;for(var md=Mm(fd,hn);++co<sn;)hn(co);return md}function bS(sn){return mp(sn)?Fp(sn,Cv):av(sn)?[sn]:Qp(x1(Ip(sn)))}function wS(sn){var hn=++Mw;return Ip(sn)+hn}var xS=nm(function(sn,hn){return sn+hn},0),_S=ry("ceil"),CS=nm(function(sn,hn){return sn/hn},1),ES=ry("floor");function SS(sn){return sn&&sn.length?qg(sn,nv,Um):v}function AS(sn,hn){return sn&&sn.length?qg(sn,cp(hn,2),Um):v}function kS(sn){return s0(sn,nv)}function TS(sn,hn){return s0(sn,cp(hn,2))}function RS(sn){return sn&&sn.length?qg(sn,nv,jm):v}function NS(sn,hn){return sn&&sn.length?qg(sn,cp(hn,2),jm):v}var MS=nm(function(sn,hn){return sn*hn},1),IS=ry("round"),LS=nm(function(sn,hn){return sn-hn},0);function OS(sn){return sn&&sn.length?Nm(sn,nv):0}function $S(sn,hn){return sn&&sn.length?Nm(sn,cp(hn,2)):0}return _d.after=r2,_d.ary=I1,_d.assign=z2,_d.assignIn=j1,_d.assignInWith=vm,_d.assignWith=G2,_d.at=j2,_d.before=L1,_d.bind=vy,_d.bindAll=JE,_d.bindKey=O1,_d.castArray=v2,_d.chain=R1,_d.chunk=E_,_d.compact=S_,_d.concat=A_,_d.cond=ZE,_d.conforms=QE,_d.constant=_y,_d.countBy=OC,_d.create=K2,_d.curry=$1,_d.curryRight=D1,_d.debounce=F1,_d.defaults=Y2,_d.defaultsDeep=q2,_d.defer=i2,_d.delay=o2,_d.difference=k_,_d.differenceBy=T_,_d.differenceWith=R_,_d.drop=N_,_d.dropRight=M_,_d.dropRightWhile=I_,_d.dropWhile=L_,_d.fill=O_,_d.filter=DC,_d.flatMap=BC,_d.flatMapDeep=VC,_d.flatMapDepth=WC,_d.flatten=S1,_d.flattenDeep=$_,_d.flattenDepth=D_,_d.flip=a2,_d.flow=tS,_d.flowRight=nS,_d.fromPairs=F_,_d.functions=nE,_d.functionsIn=rE,_d.groupBy=UC,_d.initial=B_,_d.intersection=V_,_d.intersectionBy=W_,_d.intersectionWith=U_,_d.invert=oE,_d.invertBy=aE,_d.invokeMap=zC,_d.iteratee=Cy,_d.keyBy=GC,_d.keys=Gp,_d.keysIn=tv,_d.map=lm,_d.mapKeys=uE,_d.mapValues=lE,_d.matches=rS,_d.matchesProperty=iS,_d.memoize=dm,_d.merge=cE,_d.mergeWith=K1,_d.method=oS,_d.methodOf=aS,_d.mixin=Ey,_d.negate=hm,_d.nthArg=uS,_d.omit=dE,_d.omitBy=hE,_d.once=s2,_d.orderBy=jC,_d.over=lS,_d.overArgs=u2,_d.overEvery=cS,_d.overSome=dS,_d.partial=gy,_d.partialRight=P1,_d.partition=KC,_d.pick=fE,_d.pickBy=Y1,_d.property=tb,_d.propertyOf=hS,_d.pull=j_,_d.pullAll=k1,_d.pullAllBy=K_,_d.pullAllWith=Y_,_d.pullAt=q_,_d.range=fS,_d.rangeRight=pS,_d.rearg=l2,_d.reject=XC,_d.remove=X_,_d.rest=c2,_d.reverse=fy,_d.sampleSize=ZC,_d.set=vE,_d.setWith=gE,_d.shuffle=QC,_d.slice=J_,_d.sortBy=n2,_d.sortedUniq=iC,_d.sortedUniqBy=oC,_d.split=BE,_d.spread=d2,_d.tail=aC,_d.take=sC,_d.takeRight=uC,_d.takeRightWhile=lC,_d.takeWhile=cC,_d.tap=SC,_d.throttle=h2,_d.thru=um,_d.toArray=H1,_d.toPairs=q1,_d.toPairsIn=X1,_d.toPath=bS,_d.toPlainObject=G1,_d.transform=mE,_d.unary=f2,_d.union=dC,_d.unionBy=hC,_d.unionWith=fC,_d.uniq=pC,_d.uniqBy=vC,_d.uniqWith=gC,_d.unset=yE,_d.unzip=py,_d.unzipWith=T1,_d.update=bE,_d.updateWith=wE,_d.values=dg,_d.valuesIn=xE,_d.without=mC,_d.words=Q1,_d.wrap=p2,_d.xor=yC,_d.xorBy=bC,_d.xorWith=wC,_d.zip=xC,_d.zipObject=_C,_d.zipObjectDeep=CC,_d.zipWith=EC,_d.entries=q1,_d.entriesIn=X1,_d.extend=j1,_d.extendWith=vm,Ey(_d,_d),_d.add=xS,_d.attempt=eb,_d.camelCase=SE,_d.capitalize=J1,_d.ceil=_S,_d.clamp=_E,_d.clone=g2,_d.cloneDeep=y2,_d.cloneDeepWith=b2,_d.cloneWith=m2,_d.conformsTo=w2,_d.deburr=Z1,_d.defaultTo=eS,_d.divide=CS,_d.endsWith=AE,_d.eq=bv,_d.escape=kE,_d.escapeRegExp=TE,_d.every=$C,_d.find=FC,_d.findIndex=C1,_d.findKey=X2,_d.findLast=PC,_d.findLastIndex=E1,_d.findLastKey=J2,_d.floor=ES,_d.forEach=N1,_d.forEachRight=M1,_d.forIn=Z2,_d.forInRight=Q2,_d.forOwn=eE,_d.forOwnRight=tE,_d.get=by,_d.gt=x2,_d.gte=_2,_d.has=iE,_d.hasIn=wy,_d.head=A1,_d.identity=nv,_d.includes=HC,_d.indexOf=P_,_d.inRange=CE,_d.invoke=sE,_d.isArguments=Jv,_d.isArray=mp,_d.isArrayBuffer=C2,_d.isArrayLike=ev,_d.isArrayLikeObject=Vp,_d.isBoolean=E2,_d.isBuffer=Uv,_d.isDate=S2,_d.isElement=A2,_d.isEmpty=k2,_d.isEqual=T2,_d.isEqualWith=R2,_d.isError=my,_d.isFinite=N2,_d.isFunction=Mv,_d.isInteger=B1,_d.isLength=fm,_d.isMap=V1,_d.isMatch=M2,_d.isMatchWith=I2,_d.isNaN=L2,_d.isNative=O2,_d.isNil=D2,_d.isNull=$2,_d.isNumber=W1,_d.isObject=Pp,_d.isObjectLike=Bp,_d.isPlainObject=Ag,_d.isRegExp=yy,_d.isSafeInteger=F2,_d.isSet=U1,_d.isString=pm,_d.isSymbol=av,_d.isTypedArray=cg,_d.isUndefined=P2,_d.isWeakMap=B2,_d.isWeakSet=V2,_d.join=H_,_d.kebabCase=RE,_d.last=vv,_d.lastIndexOf=z_,_d.lowerCase=NE,_d.lowerFirst=ME,_d.lt=W2,_d.lte=U2,_d.max=SS,_d.maxBy=AS,_d.mean=kS,_d.meanBy=TS,_d.min=RS,_d.minBy=NS,_d.stubArray=Ay,_d.stubFalse=ky,_d.stubObject=vS,_d.stubString=gS,_d.stubTrue=mS,_d.multiply=MS,_d.nth=G_,_d.noConflict=sS,_d.noop=Sy,_d.now=cm,_d.pad=IE,_d.padEnd=LE,_d.padStart=OE,_d.parseInt=$E,_d.random=EE,_d.reduce=YC,_d.reduceRight=qC,_d.repeat=DE,_d.replace=FE,_d.result=pE,_d.round=IS,_d.runInContext=Bd,_d.sample=JC,_d.size=e2,_d.snakeCase=PE,_d.some=t2,_d.sortedIndex=Z_,_d.sortedIndexBy=Q_,_d.sortedIndexOf=eC,_d.sortedLastIndex=tC,_d.sortedLastIndexBy=nC,_d.sortedLastIndexOf=rC,_d.startCase=VE,_d.startsWith=WE,_d.subtract=LS,_d.sum=OS,_d.sumBy=$S,_d.template=UE,_d.times=yS,_d.toFinite=Iv,_d.toInteger=yp,_d.toLength=z1,_d.toLower=HE,_d.toNumber=gv,_d.toSafeInteger=H2,_d.toString=Ip,_d.toUpper=zE,_d.trim=GE,_d.trimEnd=jE,_d.trimStart=KE,_d.truncate=YE,_d.unescape=qE,_d.uniqueId=wS,_d.upperCase=XE,_d.upperFirst=xy,_d.each=N1,_d.eachRight=M1,_d.first=A1,Ey(_d,function(){var sn={};return xv(_d,function(hn,co){Lp.call(_d.prototype,co)||(sn[co]=hn)}),sn}(),{chain:!1}),_d.VERSION=$e,cv(["bind","bindKey","curry","curryRight","partial","partialRight"],function(sn){_d[sn].placeholder=_d}),cv(["drop","take"],function(sn,hn){Ep.prototype[sn]=function(co){co=co===v?1:Hp(yp(co),0);var fd=this.__filtered__&&!hn?new Ep(this):this.clone();return fd.__filtered__?fd.__takeCount__=Yp(co,fd.__takeCount__):fd.__views__.push({size:Yp(co,gd),type:sn+(fd.__dir__<0?"Right":"")}),fd},Ep.prototype[sn+"Right"]=function(co){return this.reverse()[sn](co).reverse()}}),cv(["filter","map","takeWhile"],function(sn,hn){var co=hn+1,fd=co==uo||co==fo;Ep.prototype[sn]=function(md){var Ad=this.clone();return Ad.__iteratees__.push({iteratee:cp(md,3),type:co}),Ad.__filtered__=Ad.__filtered__||fd,Ad}}),cv(["head","last"],function(sn,hn){var co="take"+(hn?"Right":"");Ep.prototype[sn]=function(){return this[co](1).value()[0]}}),cv(["initial","tail"],function(sn,hn){var co="drop"+(hn?"":"Right");Ep.prototype[sn]=function(){return this.__filtered__?new Ep(this):this[co](1)}}),Ep.prototype.compact=function(){return this.filter(nv)},Ep.prototype.find=function(sn){return this.filter(sn).head()},Ep.prototype.findLast=function(sn){return this.reverse().find(sn)},Ep.prototype.invokeMap=xp(function(sn,hn){return typeof sn=="function"?new Ep(this):this.map(function(co){return wg(co,sn,hn)})}),Ep.prototype.reject=function(sn){return this.filter(hm(cp(sn)))},Ep.prototype.slice=function(sn,hn){sn=yp(sn);var co=this;return co.__filtered__&&(sn>0||hn<0)?new Ep(co):(sn<0?co=co.takeRight(-sn):sn&&(co=co.drop(sn)),hn!==v&&(hn=yp(hn),co=hn<0?co.dropRight(-hn):co.take(hn-sn)),co)},Ep.prototype.takeRightWhile=function(sn){return this.reverse().takeWhile(sn).reverse()},Ep.prototype.toArray=function(){return this.take(gd)},xv(Ep.prototype,function(sn,hn){var co=/^(?:filter|find|map|reject)|While$/.test(hn),fd=/^(?:head|last)$/.test(hn),md=_d[fd?"take"+(hn=="last"?"Right":""):hn],Ad=fd||/^find/.test(hn);md&&(_d.prototype[hn]=function(){var Md=this.__wrapped__,Pd=fd?[1]:arguments,Vd=Md instanceof Ep,qd=Pd[0],Xd=Vd||mp(Md),Zd=function(Cp){var Tp=md.apply(_d,$v([Cp],Pd));return fd&&tp?Tp[0]:Tp};Xd&&co&&typeof qd=="function"&&qd.length!=1&&(Vd=Xd=!1);var tp=this.__chain__,sp=!!this.__actions__.length,dp=Ad&&!tp,wp=Vd&&!sp;if(!Ad&&Xd){Md=wp?Md:new Ep(this);var hp=sn.apply(Md,Pd);return hp.__actions__.push({func:um,args:[Zd],thisArg:v}),new hv(hp,tp)}return dp&&wp?sn.apply(this,Pd):(hp=this.thru(Zd),dp?fd?hp.value()[0]:hp.value():hp)})}),cv(["pop","push","shift","sort","splice","unshift"],function(sn){var hn=Og[sn],co=/^(?:push|sort|unshift)$/.test(sn)?"tap":"thru",fd=/^(?:pop|shift)$/.test(sn);_d.prototype[sn]=function(){var md=arguments;if(fd&&!this.__chain__){var Ad=this.value();return hn.apply(mp(Ad)?Ad:[],md)}return this[co](function(Md){return hn.apply(mp(Md)?Md:[],md)})}}),xv(Ep.prototype,function(sn,hn){var co=_d[hn];if(co){var fd=co.name+"";Lp.call(og,fd)||(og[fd]=[]),og[fd].push({name:hn,func:co})}}),og[tm(v,un).name]=[{name:"wrapper",func:v}],Ep.prototype.clone=qw,Ep.prototype.reverse=Xw,Ep.prototype.value=Jw,_d.prototype.at=AC,_d.prototype.chain=kC,_d.prototype.commit=TC,_d.prototype.next=RC,_d.prototype.plant=MC,_d.prototype.reverse=IC,_d.prototype.toJSON=_d.prototype.valueOf=_d.prototype.value=LC,_d.prototype.first=_d.prototype.head,fg&&(_d.prototype[fg]=NC),_d},ng=Tw();Hv?((Hv.exports=ng)._=ng,Cm._=ng):jp._=ng}).call(lodash)}(lodash$1,lodash$1.exports)),lodash$1.exports}var lodashExports=requireLodash();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),Ge=$e.length,je=new Uint8Array(Ge);for(;Ge--;)je[Ge]=$e.charCodeAt(Ge);return new File([je],y,{type:v})}async function waterImage(m,y={text:"",fontSize:40,font:"宋体",color:"rgba(255, 255, 255, 0.5)",opacity:.5,spacing:200,angle:20,autoSize:!1,rate:null},v){lodashExports.defaults(y,{text:"",fontSize:40,font:"宋体",color:"rgba(255, 255, 255, 0.5)",opacity:.5,spacing:200,angle:20,autoSize:!1,rate:null});const $e=await new Promise((Ke,Qe)=>{const Je=new Image;Je.crossOrigin="anonymous",Je.onload=()=>Ke(Je),Je.onerror=Qe,Je.src=m}),Ge=document.createElement("canvas");Ge.width=$e.naturalWidth,Ge.height=$e.naturalHeight;const je=Ge.getContext("2d");if(je.drawImage($e,0,0),y.text&&y.text.trim()){let{text:Ke,fontSize:Qe,font:Je,color:st,opacity:Mt,spacing:nn,angle:rn,autoSize:on,rate:an}=y;if(on){const fn=$e.naturalWidth;an=an||32/375,Qe=an*fn,Qe=Math.max(12,Math.min(Qe,100)),nn=Qe*6,nn=Math.max(100,Math.min(nn,1e3)),console.log(`自动适配: 图片宽度=${fn}px, 文字大小=${Qe.toFixed(2)}px, 间距=${nn.toFixed(2)}px`)}je.save(),je.font=`${Qe}px ${Je}`,je.fillStyle=st,je.globalAlpha=Mt,je.measureText(Ke).width;const un=Math.ceil(Ge.width/nn)+1,ln=Math.ceil(Ge.height/nn)+1;for(let fn=0;fn<un;fn++)for(let cn=0;cn<ln;cn++){const Xr=fn*nn,Mi=cn*nn;je.save(),je.translate(Xr,Mi),rn!==0&&je.rotate(rn*Math.PI/180),je.fillText(Ke,0,0),je.restore()}je.restore()}const Ye=Ge.toDataURL("image/jpeg",.9),qe=getBase64ImageSize(Ye);console.log("waterImage 处理后大小(字节):",qe),v&&v(base64toFile(Ye.split(",")[1],"water-masked.jpg","image/jpeg"))}const fun=(m,y,v,$e={text:""})=>y.then(Ge=>/^image\/\w+/.test(m.type)?new Promise((je,Ye)=>{let qe=v.fileList.filter(Ke=>Ke.raw&&Ke.raw==m)[0];if(!qe){Ye();return}qe.message="水印处理中...",waterImage(URL.createObjectURL(m),$e,Ke=>{qe.message="",setBaseProps(Ke,qe.raw),qe.raw=Ke,je(qe.raw)})}):!0),uploadProcess={compress:fun$2,face:fun$1,water:fun};function useOssUploader(m,y,v={fileType:[],requireMd5:!1,request:null,signatureUrl:"",addFileMd5Url:"",queryFileMd5Url:"",beginUploadFlow:[]}){let $e=1;const Ge=async function(Qe){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})},je=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 je(st.name);if(on.code!==200)throw new Error("Get signature error");const an=on.data,{accessid:un,policy:ln,signature:fn,dir:cn,host:Xr}=an;let Mi=new FormData;return Mi.append("key",cn),Mi.append("policy",ln),Mi.append("OSSAccessKeyId",un),Mi.append("success_action_status","200"),Mi.append("signature",fn),Mi.append("file",st),await axios.create({onUploadProgress:ld=>{ld.percent=ld.total>0?ld.loaded/ld.total*100:0,Mt(ld)}}).post(Xr,Mi,{headers:{"Content-Type":"multipart/form-data"}}).then(ld=>({code:200,fileName:Xr+cn}))},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=>{Ge(an)}),new Error("文件已存在")}else return Qe.md5=nn,!0})));for(let nn of v.beginUploadFlow)typeof nn=="string"?Mt=uploadProcess[nn](Qe,Mt,Ke):typeof nn=="object"&&nn instanceof Object&&(Mt=uploadProcess[nn.name](Qe,Mt,Ke,nn));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,Ge(Qe),v.requireMd5&&Ye({filePath:Qe.url,mdaValue:Qe.raw.md5}))},init:function(Qe){console.log("init oss upload....",Qe),Qe=Qe||"";const Je=Array.isArray(Qe)?Qe:Qe.length?Qe.split(","):[];Ke.fileList=Je.map(st=>{const Mt=typeof st=="string"?st:st.url,nn=Ke.fileList.find(on=>on.url===Mt);if(nn)return nn;let rn=typeof st=="string"?{name:st,url:st}:{...st};return rn.uid=rn.uid||new Date().getTime()+$e++,rn.status="success",rn}),Ke.fileList.map(st=>{Ge(st)})},md5(Qe){return new Promise((Je,st)=>{const Mt=Qe.raw,rn=Math.ceil(Mt.size/10),on=new FileReader,an=new SparkMD5;let un=0;const ln=()=>{const fn=Mt.slice(un,un+rn);on.readAsBinaryString(fn)};on.onload=fn=>{an.appendBinary(fn.target.result),un<Mt.size?(un+=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,Ge]}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(),Ge=y;vue.ref(0),vue.ref([]);const je=vue.ref([]),Ye=vue.computed(()=>v.isShowTip&&(v.fileType||v.fileMaxSize)),qe=vue.inject("request"),[Ke]=useOssUploader("",je,{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=()=>{(je.value.length==0||je.value.every(Mt=>Mt.status=="success"))&&Ge("update:modelValue",Array.isArray(v.modelValue)?je.value:Qe(je.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 je.value=[]},{deep:!0,immediate:!0}),vue.watch(()=>je.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]=un=>vue.unref(Ke).fileList=un),"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 Ge=null;const je=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:fo}=v;return fo.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:fo,deg:ho,offsetX:hd,offsetY:dd,rotateX:pd,rotateY:gd,enableTransition:Sd}=Je.value,yd={transform:`scale(${fo}) rotate(${ho}deg) rotateX(${pd}deg) rotateY(${gd}deg)`,transition:Sd?"transform .3s":"",marginLeft:`${hd}px`,marginTop:`${dd}px`};return Qe.value.name===Mode.CONTAIN.name&&(yd.maxWidth="100%",yd.maxHeight="100%"),yd});function an(){$e("close")}function un(){je.value=!1,Ye.value=!0}function ln(){je.value=!1}function fn(fo){let ho=!1;return function(...hd){ho||(ho=!0,window.requestAnimationFrame(()=>{fo.apply(this,hd),ho=!1}))}}const cn=function(fo,ho,hd,dd=!1){fo&&ho&&hd&&fo.addEventListener(ho,hd,dd)},Xr=function(fo,ho,hd,dd=!1){fo&&ho&&hd&&fo.removeEventListener(ho,hd,dd)};function Mi(fo){if(je.value||fo.button!==0)return;const{offsetX:ho,offsetY:hd}=Je.value,dd=fo.pageX,pd=fo.pageY;Ge=fn(gd=>{Je.value={...Je.value,offsetX:ho+gd.pageX-dd,offsetY:hd+gd.pageY-pd}}),cn(document,"mousemove",Ge),cn(document,"mouseup",()=>{Xr(document,"mousemove",Ge)}),fo.preventDefault()}function to(){Je.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1,rotateX:0,rotateY:0}}function ld(fo,ho={}){if(je.value)return;const{zoomRate:hd,rotateDeg:dd,rotateXDeg:pd,rotateYDeg:gd,enableTransition:Sd}={zoomRate:.2,rotateDeg:90,rotateXDeg:180,rotateYDeg:180,enableTransition:!0,...ho};if(fo==="zoomOut")Je.value.scale>.2&&(Je.value.scale=parseFloat((Je.value.scale-hd).toFixed(3)));else if(fo==="zoomIn")Je.value.scale=parseFloat((Je.value.scale+hd).toFixed(3));else if(fo==="clocelise")Je.value.deg+=dd;else if(fo==="anticlocelise")Je.value.deg-=dd;else if(fo==="fliphorizontal"){let yd=Je.value.deg!=0&&Math.abs(Je.value.deg)/dd%2!=0?"rotateX":"rotateY";Je.value[yd]=Je.value[yd]?0:gd}else if(fo==="flipvertical"){let yd=Je.value.deg!=0&&Math.abs(Je.value.deg)/dd%2!=0?"rotateY":"rotateX";Je.value[yd]=Je.value[yd]?0:pd}Je.value.enableTransition=Sd}function od(){if(je.value)return;const fo=Object.keys(Mode),ho=Object.values(Mode),hd=Qe.value.name,pd=(ho.findIndex(gd=>gd.name===hd)+1)%fo.length;Qe.value=Mode[fo[pd]],to()}function Uo(){if(Mt.value&&!v.infinite)return;const fo=v.urls.length;qe.value=(qe.value-1+fo)%fo,Ye.value=!1}function vd(){if(nn.value&&!v.infinite)return;const fo=v.urls.length;qe.value=(qe.value+1)%fo,Ye.value=!1}let rd=null,mo=null;const uo=()=>{rd=fn(ho=>{switch(ho.keyCode){case 27:an();break;case 32:od();break;case 37:this.prev();break;case 38:ld("zoomIn");break;case 39:this.next();break;case 40:ld("zoomOut");break}});let fo=fn(ho=>{(ho.wheelDelta?ho.wheelDelta:-ho.detail)>0?ld("zoomIn",{zoomRate:.09,enableTransition:!1}):ld("zoomOut",{zoomRate:.09,enableTransition:!1})});cn(document,"keydown",rd),cn(document,mousewheelEventName,fo)},lo=()=>{Xr(document,"keydown",rd),Xr(document,mousewheelEventName,mo),rd=null,mo=null};return vue.watch(rn,()=>{vue.nextTick(()=>{Ke.value.complete||(je.value=!0)})}),vue.watch(qe,fo=>{to(),$e("change",fo)}),vue.onMounted(()=>{vue.nextTick(()=>{const fo=document.querySelector("body");fo.append?fo.append(document.getElementById("x-image-viewer")):fo.appendChild(document.getElementById("x-image-viewer")),uo()})}),vue.onUnmounted(()=>{document.querySelector("body").removeChild(document.getElementById("x-image-viewer")),lo()}),(fo,ho)=>{const hd=vue.resolveComponent("el-icon-close"),dd=vue.resolveComponent("el-icon"),pd=vue.resolveComponent("el-icon-zoom-out"),gd=vue.resolveComponent("el-icon-zoom-in"),Sd=vue.resolveComponent("el-icon-refresh-left"),yd=vue.resolveComponent("el-icon-refresh-right"),Td=vue.resolveComponent("el-icon-switch"),Nd=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:ho[0]||(ho[0]=vue.withModifiers($d=>m.hideOnClickModal&&an(),["self"]))}),vue.createElementVNode("span",{class:"x-image-viewer__btn x-image-viewer__close",onClick:an},[vue.createVNode(dd,null,{default:vue.withCtx(()=>[vue.createVNode(hd)]),_: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:Uo},ho[7]||(ho[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:vd},ho[8]||(ho[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(dd,{onClick:ho[1]||(ho[1]=$d=>ld("zoomOut"))},{default:vue.withCtx(()=>[vue.createVNode(pd)]),_:1}),vue.createVNode(dd,{onClick:ho[2]||(ho[2]=$d=>ld("zoomIn"))},{default:vue.withCtx(()=>[vue.createVNode(gd)]),_:1}),ho[9]||(ho[9]=vue.createElementVNode("i",{class:"x-image-viewer__actions__divider"},null,-1)),vue.createVNode(dd,{onClick:od},{default:vue.withCtx(()=>[(vue.openBlock(),vue.createBlock(vue.resolveDynamicComponent(Qe.value.icon)))]),_:1}),ho[10]||(ho[10]=vue.createElementVNode("i",{class:"x-image-viewer__actions__divider"},null,-1)),vue.createVNode(dd,{onClick:ho[3]||(ho[3]=$d=>ld("anticlocelise"))},{default:vue.withCtx(()=>[vue.createVNode(Sd)]),_:1}),vue.createVNode(dd,{onClick:ho[4]||(ho[4]=$d=>ld("clocelise"))},{default:vue.withCtx(()=>[vue.createVNode(yd)]),_:1}),vue.createVNode(dd,{onClick:ho[5]||(ho[5]=$d=>ld("fliphorizontal"))},{default:vue.withCtx(()=>[vue.createVNode(Td)]),_:1}),vue.createVNode(dd,{onClick:ho[6]||(ho[6]=$d=>ld("flipvertical"))},{default:vue.withCtx(()=>[vue.createVNode(Nd)]),_: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,($d,Wd)=>vue.withDirectives((vue.openBlock(),vue.createElementBlock("img",{ref_for:!0,ref_key:"img",ref:Ke,key:$d,src:rn.value.src,style:vue.normalizeStyle(on.value),class:"x-image-viewer__img",onLoad:un,onError:ln,onMousedown:Mi},null,44,_hoisted_5$2)),[[vue.vShow,Wd===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,Ge=vue.useAttrs(),je=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(uo,lo){let fo="";lo=lo||",";for(let ho in uo)uo[ho].url!==void 0&&uo[ho].url.indexOf("blob:")!==0&&(fo+=uo[ho].url+lo);return fo!=""?fo.substr(0,fo.length-1):""}function un(uo){console.log("enter"),uo.preventDefault()}function ln(uo){console.log("over"),uo.preventDefault(),setTimeout(()=>{uo.target.classList.add("over")},0)}function fn(uo){console.log("drop"),uo.preventDefault(),$e.onDrop&&$e.onDrop(uo)}function cn(uo){$e.onBackPool&&$e.onBackPool(uo)}function Xr(uo){vd(uo)}function Mi(uo){Mt.value=[],Mt.value.push({src:uo.url,desc:""}),st.value=!0}function to(uo,lo){let fo=[];for(let ho=0;ho<uo.length;ho++){fo[ho]=[];for(let hd=0;hd<lo[0].length;hd++){let dd=0;for(let pd=0;pd<uo[0].length;pd++)dd+=uo[ho][pd]*lo[pd][hd];fo[ho][hd]=dd}}return fo}function ld(uo,lo){let fo=uo.hd=uo.hd||0,ho=uo.vd=uo.vd||0,hd=uo.deg=uo.deg||0,dd=uo.viewBox,pd=uo.matrix;if(lo=="rotateleft"){hd+=90;let gd=[[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]];pd=to(pd,gd),uo.viewBox=od(uo.hd!=fo,uo.vd!=ho,90,dd)}else if(lo=="rotateright"){hd-=90;let gd=[[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]];pd=to(pd,gd),uo.viewBox=od(uo.hd!=fo,uo.vd!=ho,-90,dd)}else lo=="fliphorizontal"?(fo=fo?0:1,pd=to(pd,[[-1,0],[0,1],[0,0]])):lo=="flipvertical"&&(ho=ho?0:1,pd=to(pd,[[1,0],[0,-1],[0,0]]));uo.matrix=pd,uo.deg=hd,uo.hd=fo,uo.vd=ho}function od(uo,lo,fo,ho){let hd=JSON.parse(JSON.stringify(ho));const[dd,pd,gd,Sd]=ho;if(uo==!0&&(hd[0]=hd[0]==0-gd?0:0-gd),lo==!0&&(hd[1]=hd[1]==0-Sd?0:0-Sd),fo){let yd=fo/90%4;for(let Td=0;Td<Math.abs(yd);Td++)if(hd[2]=Sd,hd[3]=gd,fo>0){let Nd=hd[1];hd[1]=hd[0]==0-gd?0:0-gd,hd[0]=Nd}else{let Nd=hd[1];hd[1]=hd[0],hd[0]=Nd==0-Sd?0:0-Sd}}return hd}const Uo=uo=>{Ye.value.push(uo)},vd=uo=>{Ye.value.indexOf(uo)!=-1&&Ye.value.splice(Ye.value.indexOf(uo),1)},rd=()=>{(Ye.value.length==0||Ye.value.every(uo=>uo.status=="success"))&&je("update:modelValue",Array.isArray($e.modelValue)?Ye.value:an(Ye.value))};function mo(uo,lo,fo){lo.url=lo.response.fileName,rd()}return vue.watch(()=>$e.modelValue,uo=>{if(uo)Qe.init(uo);else return Ye.value=[]},{deep:!0,immediate:!0}),vue.watch(()=>Ye.value.length,()=>{console.log("imageupload filelist changed....."),rd()}),y({pushFile:Uo,removeFile:vd}),(uo,lo)=>{const fo=vue.resolveComponent("el-icon"),ho=vue.resolveComponent("el-upload"),hd=vue.resolveComponent("sy-svg-icon"),dd=vue.resolveComponent("sy-image-view");return vue.openBlock(),vue.createElementBlock("div",_hoisted_1$2,[vue.createElementVNode("div",_hoisted_2$2,[vue.createVNode(ho,vue.mergeProps({multiple:m.multipleSelect,ref:"imageUpload","show-file-list":!1,"file-list":Ye.value,"onUpdate:fileList":lo[0]||(lo[0]=pd=>Ye.value=pd),"http-request":vue.unref(Qe).onHttpRequest,"list-type":"picture-card",limit:m.limit,"on-success":mo,"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(Ge),{onDragenter:un,onDragover:ln,onDrop:fn,"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(fo,{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,pd=>(vue.openBlock(),vue.createElementBlock("div",{key:pd.uid,class:"el-upload--picture-card",style:vue.normalizeStyle("width:"+m.size.width+";height:"+m.size.height+";")},[pd.status=="ready"||pd.status=="uploading"||pd.loading?(vue.openBlock(),vue.createElementBlock("div",_hoisted_3$1,[vue.createVNode(hd,{"class-name":"icon-down","icon-class":"down"}),vue.createElementVNode("div",_hoisted_4$1,[pd.status=="uploading"?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[vue.createTextVNode("上传进度"+vue.toDisplayString(parseInt(pd.percentage||0))+"%",1)],64)):vue.createCommentVNode("",!0),pd.loading?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[vue.createTextVNode("加载进度"+vue.toDisplayString(parseInt(pd.loadingPercent||0))+"%",1)],64)):vue.createCommentVNode("",!0),pd.message?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:2},[vue.createTextVNode(vue.toDisplayString(pd.message),1)],64)):vue.createCommentVNode("",!0)])])):vue.createCommentVNode("",!0),pd.status=="success"&&!pd.loading?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[pd.loadError?vue.createCommentVNode("",!0):(vue.openBlock(),vue.createElementBlock("div",{key:0,onClick:gd=>Mi(pd),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:pd.objUrl,fit:"contain"},null,8,_hoisted_7$1)):(vue.openBlock(),vue.createElementBlock("svg",{key:1,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",viewBox:pd.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("+pd.matrix.join(",")+")"},[vue.createElementVNode("image",{"xlink:href":pd.objUrl,x:"0",y:"0",width:pd.width,height:pd.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(hd,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(gd=>cn(pd),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.back]]),vue.withDirectives(vue.createElementVNode("div",_hoisted_14$1,[vue.createVNode(hd,{"class-name":"icon-photo ","icon-class":"close",onClick:vue.withModifiers(gd=>Xr(pd),["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(hd,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(gd=>ld(pd,"rotateleft"),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.rotateLeft]]),vue.withDirectives(vue.createElementVNode("div",_hoisted_17$1,[vue.createVNode(hd,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(gd=>ld(pd,"rotateright"),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.rotateRight]])])])],8,_hoisted_5$1)),pd.loadError?(vue.openBlock(),vue.createElementBlock("div",{key:1,onClick:gd=>vue.unref(Je)(pd),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(dd,{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,Ge,je){return vue.openBlock(),vue.createElementBlock("svg",{class:vue.normalizeClass(je.svgClass),"aria-hidden":"true"},[vue.createElementVNode("use",{"xlink:href":je.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 Ge=m,je={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=cn=>{cn&&Ye.value.push(cn)},Je=vue.computed(()=>Ye.value[Ke.value]),st=vue.ref([]),Mt=cn=>{cn.target.focus(),console.log("focus:"+cn.target.id),Ke.value=Array.from($e.value.children).indexOf(cn.target);const Xr=Je.value.attributes.id.value;v.value.hasOwnProperty(Xr)?st.value=JSON.parse(JSON.stringify(v.value[Xr])):st.value=[],qe.value=!0},nn=cn=>{cn.target.classList.contains("tooth")&&console.log("blur:"+cn.target.id)},rn=cn=>{const Xr={};return cn&&cn.split(".").forEach(Mi=>{const[to,ld]=Mi.split("|");Xr[to]=ld?ld.split(","):[]}),Xr},on=()=>{const cn=Object.keys(v.value).reduce((Xr,Mi)=>(Xr.push(Mi+"|"+v.value[Mi].join(",")),Xr),[]).join(".");y.value=cn,console.log(cn)},an=cn=>v.value.hasOwnProperty(cn)?v.value[cn].length==0?["green"]:v.value[cn].map(Mi=>Ge.symptomItems.filter(ld=>ld.value==Mi)[0].color||"green"):["white"],un=cn=>v.value.hasOwnProperty(cn)?"url(#pos-"+cn+")":"white",ln=()=>{const cn=Je.value.attributes.id.value;v.value[cn]=st.value,qe.value=!1},fn=()=>{delete v.value[Je.value.attributes.id.value],qe.value=!1};return vue.onMounted(()=>{v.value=rn(y.value)}),vue.watch(()=>y.value,cn=>{v.value=rn(y.value)}),vue.watch(()=>v.value,cn=>{on()},{deep:!0}),(cn,Xr)=>{const Mi=vue.resolveComponent("el-checkbox"),to=vue.resolveComponent("el-checkbox-group"),ld=vue.resolveComponent("el-button"),od=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(je[4][0])}]),id:je[4][0],fill:un(je[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(je[4][1])}]),id:je[4][1],fill:un(je[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(je[4][2])}]),id:je[4][2],fill:un(je[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(je[4][3])}]),id:je[4][3],fill:un(je[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(je[4][4])}]),id:je[4][4],fill:un(je[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(je[4][5])}]),id:je[4][5],fill:un(je[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(je[4][6])}]),id:je[4][6],fill:un(je[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(je[4][7])}]),id:je[4][7],fill:un(je[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(je[3][7])}]),id:je[3][7],fill:un(je[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(je[3][6])}]),id:je[3][6],fill:un(je[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(je[3][5])}]),id:je[3][5],fill:un(je[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(je[3][4])}]),id:je[3][4],fill:un(je[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(je[3][3])}]),id:je[3][3],fill:un(je[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(je[3][2])}]),id:je[3][2],fill:un(je[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(je[3][1])}]),id:je[3][1],fill:un(je[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(je[3][0])}]),id:je[3][0],fill:un(je[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(je[2][7])}]),id:je[2][7],fill:un(je[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(je[2][6])}]),id:je[2][6],fill:un(je[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(je[2][5])}]),id:je[2][5],fill:un(je[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(je[2][4])}]),id:je[2][4],fill:un(je[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(je[2][3])}]),id:je[2][3],fill:un(je[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(je[2][2])}]),id:je[2][2],fill:un(je[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(je[2][1])}]),id:je[2][1],fill:un(je[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(je[2][0])}]),id:je[2][0],fill:un(je[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(je[1][0])}]),id:je[1][0],fill:un(je[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(je[1][1])}]),id:je[1][1],fill:un(je[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(je[1][2])}]),id:je[1][2],fill:un(je[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(je[1][3])}]),id:je[1][3],fill:un(je[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(je[1][4])}]),id:je[1][4],fill:un(je[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(je[1][5])}]),id:je[1][5],fill:un(je[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(je[1][6])}]),id:je[1][6],fill:un(je[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(je[1][7])}]),id:je[1][7],fill:un(je[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(je[8][0])}]),id:je[8][0],fill:un(je[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(je[8][1])}]),id:je[8][1],fill:un(je[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(je[8][2])}]),id:je[8][2],fill:un(je[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(je[8][3])}]),id:je[8][3],fill:un(je[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(je[8][4])}]),id:je[8][4],fill:un(je[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(je[7][4])}]),id:je[7][4],fill:un(je[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(je[7][3])}]),id:je[7][3],fill:un(je[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(je[7][2])}]),id:je[7][2],fill:un(je[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(je[7][1])}]),id:je[7][1],fill:un(je[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(je[7][0])}]),id:je[7][0],fill:un(je[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(je[6][4])}]),id:je[6][4],fill:un(je[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(je[6][3])}]),id:je[6][3],fill:un(je[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(je[6][2])}]),id:je[6][2],fill:un(je[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(je[6][1])}]),id:je[6][1],fill:un(je[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(je[6][0])}]),id:je[6][0],fill:un(je[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(je[5][0])}]),id:je[5][0],fill:un(je[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(je[5][1])}]),id:je[5][1],fill:un(je[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(je[5][2])}]),id:je[5][2],fill:un(je[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(je[5][3])}]),id:je[5][3],fill:un(je[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(je[5][4])}]),id:je[5][4],fill:un(je[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),Xr[2]||(Xr[2]=vue.createElementVNode("path",{class:"tooth",fill:"white",d:"M29.8787 152.908H665.063",stroke:"#CCE6FB","stroke-width":"2"},null,-1)),Xr[3]||(Xr[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),Uo=>(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,[v.value[Uo]?(vue.openBlock(),vue.createElementBlock("linearGradient",{key:0,id:"pos-"+Uo,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(an(Uo),(vd,rd)=>(vue.openBlock(),vue.createElementBlock("stop",{key:rd,offset:`${rd/(an(Uo).length-1||1)*100}%`,"stop-color":vd},null,8,_hoisted_55))),128))],8,_hoisted_54)):vue.createCommentVNode("",!0)],64))),256))])],544)),vue.createVNode(od,{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":Xr[0]||(Xr[0]=Uo=>st.value=Uo)},{default:vue.withCtx(()=>[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(m.symptomItems,Uo=>(vue.openBlock(),vue.createBlock(Mi,{label:Uo.label,value:Uo.value},null,8,["label","value"]))),256))]),_:1},8,["modelValue"])]),vue.createElementVNode("div",_hoisted_56,[vue.createVNode(ld,{size:"small",text:"",onClick:fn},{default:vue.withCtx(()=>Xr[4]||(Xr[4]=[vue.createTextVNode("清除")])),_:1}),vue.createVNode(ld,{size:"small",text:"",onClick:Xr[1]||(Xr[1]=Uo=>qe.value=!1)},{default:vue.withCtx(()=>Xr[5]||(Xr[5]=[vue.createTextVNode("取消")])),_:1}),vue.createVNode(ld,{size:"small",type:"primary",onClick:ln},{default:vue.withCtx(()=>Xr[6]||(Xr[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});
|
|
4996
|
+
}`;var wp=eb(function(){return Mp(Ad,sp+"return "+Zd).apply(v,Md)});if(wp.source=Zd,my(wp))throw wp;return wp}function HE(sn){return Ip(sn).toLowerCase()}function zE(sn){return Ip(sn).toUpperCase()}function GE(sn,hn,co){if(sn=Ip(sn),sn&&(co||hn===v))return l0(sn);if(!sn||!(hn=ov(hn)))return sn;var fd=mv(sn),md=mv(hn),Ad=c0(fd,md),Md=d0(fd,md)+1;return Wv(fd,Ad,Md).join("")}function jE(sn,hn,co){if(sn=Ip(sn),sn&&(co||hn===v))return sn.slice(0,f0(sn)+1);if(!sn||!(hn=ov(hn)))return sn;var fd=mv(sn),md=d0(fd,mv(hn))+1;return Wv(fd,0,md).join("")}function KE(sn,hn,co){if(sn=Ip(sn),sn&&(co||hn===v))return sn.replace(mm,"");if(!sn||!(hn=ov(hn)))return sn;var fd=mv(sn),md=c0(fd,mv(hn));return Wv(fd,md).join("")}function YE(sn,hn){var co=Uo,fd=vd;if(Pp(hn)){var md="separator"in hn?hn.separator:md;co="length"in hn?yp(hn.length):co,fd="omission"in hn?ov(hn.omission):fd}sn=Ip(sn);var Ad=sn.length;if(eg(sn)){var Md=mv(sn);Ad=Md.length}if(co>=Ad)return sn;var Pd=co-tg(fd);if(Pd<1)return fd;var Vd=Md?Wv(Md,0,Pd).join(""):sn.slice(0,Pd);if(md===v)return Vd+fd;if(Md&&(Pd+=Vd.length-Pd),yy(md)){if(sn.slice(Pd).search(md)){var qd,Xd=Vd;for(md.global||(md=Om(md.source,Ip(My.exec(md))+"g")),md.lastIndex=0;qd=md.exec(Xd);)var Zd=qd.index;Vd=Vd.slice(0,Zd===v?Pd:Zd)}}else if(sn.indexOf(ov(md),Pd)!=Pd){var tp=Vd.lastIndexOf(md);tp>-1&&(Vd=Vd.slice(0,tp))}return Vd+fd}function qE(sn){return sn=Ip(sn),sn&&ab.test(sn)?sn.replace(Ty,Ew):sn}var XE=ug(function(sn,hn,co){return sn+(co?" ":"")+hn.toUpperCase()}),xy=t1("toUpperCase");function Q1(sn,hn,co){return sn=Ip(sn),hn=co?v:hn,hn===v?bw(sn)?kw(sn):cw(sn):sn.match(hn)||[]}var eb=xp(function(sn,hn){try{return rv(sn,v,hn)}catch(co){return my(co)?co:new gp(co)}}),JE=Rv(function(sn,hn){return cv(hn,function(co){co=Cv(co),kv(sn,co,vy(sn[co],sn))}),sn});function ZE(sn){var hn=sn==null?0:sn.length,co=cp();return sn=hn?Fp(sn,function(fd){if(typeof fd[1]!="function")throw new dv(Ye);return[co(fd[0]),fd[1]]}):[],xp(function(fd){for(var md=-1;++md<hn;){var Ad=sn[md];if(rv(Ad[0],this,fd))return rv(Ad[1],this,fd)}})}function QE(sn){return Ex(fv(sn,st))}function _y(sn){return function(){return sn}}function eS(sn,hn){return sn==null||sn!==sn?hn:sn}var tS=r1(),nS=r1(!0);function nv(sn){return sn}function Cy(sn){return L0(typeof sn=="function"?sn:fv(sn,st))}function rS(sn){return $0(fv(sn,st))}function iS(sn,hn){return D0(sn,fv(hn,st))}var oS=xp(function(sn,hn){return function(co){return wg(co,sn,hn)}}),aS=xp(function(sn,hn){return function(co){return wg(sn,co,hn)}});function Ey(sn,hn,co){var fd=Gp(hn),md=Xg(hn,fd);co==null&&!(Pp(hn)&&(md.length||!fd.length))&&(co=hn,hn=sn,sn=this,md=Xg(hn,Gp(hn)));var Ad=!(Pp(co)&&"chain"in co)||!!co.chain,Md=Mv(sn);return cv(md,function(Pd){var Vd=hn[Pd];sn[Pd]=Vd,Md&&(sn.prototype[Pd]=function(){var qd=this.__chain__;if(Ad||qd){var Xd=sn(this.__wrapped__),Zd=Xd.__actions__=Qp(this.__actions__);return Zd.push({func:Vd,args:arguments,thisArg:sn}),Xd.__chain__=qd,Xd}return Vd.apply(sn,$v([this.value()],arguments))})}),sn}function sS(){return jp._===this&&(jp._=Lw),this}function Sy(){}function uS(sn){return sn=yp(sn),xp(function(hn){return F0(hn,sn)})}var lS=ny(Fp),cS=ny(i0),dS=ny(km);function tb(sn){return ly(sn)?Tm(Cv(sn)):Wx(sn)}function hS(sn){return function(hn){return sn==null?v:Yv(sn,hn)}}var fS=o1(),pS=o1(!0);function Ay(){return[]}function ky(){return!1}function vS(){return{}}function gS(){return""}function mS(){return!0}function yS(sn,hn){if(sn=yp(sn),sn<1||sn>hd)return[];var co=gd,fd=Yp(sn,gd);hn=cp(hn),sn-=gd;for(var md=Mm(fd,hn);++co<sn;)hn(co);return md}function bS(sn){return mp(sn)?Fp(sn,Cv):av(sn)?[sn]:Qp(x1(Ip(sn)))}function wS(sn){var hn=++Mw;return Ip(sn)+hn}var xS=nm(function(sn,hn){return sn+hn},0),_S=ry("ceil"),CS=nm(function(sn,hn){return sn/hn},1),ES=ry("floor");function SS(sn){return sn&&sn.length?qg(sn,nv,Um):v}function AS(sn,hn){return sn&&sn.length?qg(sn,cp(hn,2),Um):v}function kS(sn){return s0(sn,nv)}function TS(sn,hn){return s0(sn,cp(hn,2))}function RS(sn){return sn&&sn.length?qg(sn,nv,jm):v}function NS(sn,hn){return sn&&sn.length?qg(sn,cp(hn,2),jm):v}var MS=nm(function(sn,hn){return sn*hn},1),IS=ry("round"),LS=nm(function(sn,hn){return sn-hn},0);function OS(sn){return sn&&sn.length?Nm(sn,nv):0}function $S(sn,hn){return sn&&sn.length?Nm(sn,cp(hn,2)):0}return _d.after=r2,_d.ary=I1,_d.assign=z2,_d.assignIn=j1,_d.assignInWith=vm,_d.assignWith=G2,_d.at=j2,_d.before=L1,_d.bind=vy,_d.bindAll=JE,_d.bindKey=O1,_d.castArray=v2,_d.chain=R1,_d.chunk=E_,_d.compact=S_,_d.concat=A_,_d.cond=ZE,_d.conforms=QE,_d.constant=_y,_d.countBy=OC,_d.create=K2,_d.curry=$1,_d.curryRight=D1,_d.debounce=F1,_d.defaults=Y2,_d.defaultsDeep=q2,_d.defer=i2,_d.delay=o2,_d.difference=k_,_d.differenceBy=T_,_d.differenceWith=R_,_d.drop=N_,_d.dropRight=M_,_d.dropRightWhile=I_,_d.dropWhile=L_,_d.fill=O_,_d.filter=DC,_d.flatMap=BC,_d.flatMapDeep=VC,_d.flatMapDepth=WC,_d.flatten=S1,_d.flattenDeep=$_,_d.flattenDepth=D_,_d.flip=a2,_d.flow=tS,_d.flowRight=nS,_d.fromPairs=F_,_d.functions=nE,_d.functionsIn=rE,_d.groupBy=UC,_d.initial=B_,_d.intersection=V_,_d.intersectionBy=W_,_d.intersectionWith=U_,_d.invert=oE,_d.invertBy=aE,_d.invokeMap=zC,_d.iteratee=Cy,_d.keyBy=GC,_d.keys=Gp,_d.keysIn=tv,_d.map=lm,_d.mapKeys=uE,_d.mapValues=lE,_d.matches=rS,_d.matchesProperty=iS,_d.memoize=dm,_d.merge=cE,_d.mergeWith=K1,_d.method=oS,_d.methodOf=aS,_d.mixin=Ey,_d.negate=hm,_d.nthArg=uS,_d.omit=dE,_d.omitBy=hE,_d.once=s2,_d.orderBy=jC,_d.over=lS,_d.overArgs=u2,_d.overEvery=cS,_d.overSome=dS,_d.partial=gy,_d.partialRight=P1,_d.partition=KC,_d.pick=fE,_d.pickBy=Y1,_d.property=tb,_d.propertyOf=hS,_d.pull=j_,_d.pullAll=k1,_d.pullAllBy=K_,_d.pullAllWith=Y_,_d.pullAt=q_,_d.range=fS,_d.rangeRight=pS,_d.rearg=l2,_d.reject=XC,_d.remove=X_,_d.rest=c2,_d.reverse=fy,_d.sampleSize=ZC,_d.set=vE,_d.setWith=gE,_d.shuffle=QC,_d.slice=J_,_d.sortBy=n2,_d.sortedUniq=iC,_d.sortedUniqBy=oC,_d.split=BE,_d.spread=d2,_d.tail=aC,_d.take=sC,_d.takeRight=uC,_d.takeRightWhile=lC,_d.takeWhile=cC,_d.tap=SC,_d.throttle=h2,_d.thru=um,_d.toArray=H1,_d.toPairs=q1,_d.toPairsIn=X1,_d.toPath=bS,_d.toPlainObject=G1,_d.transform=mE,_d.unary=f2,_d.union=dC,_d.unionBy=hC,_d.unionWith=fC,_d.uniq=pC,_d.uniqBy=vC,_d.uniqWith=gC,_d.unset=yE,_d.unzip=py,_d.unzipWith=T1,_d.update=bE,_d.updateWith=wE,_d.values=dg,_d.valuesIn=xE,_d.without=mC,_d.words=Q1,_d.wrap=p2,_d.xor=yC,_d.xorBy=bC,_d.xorWith=wC,_d.zip=xC,_d.zipObject=_C,_d.zipObjectDeep=CC,_d.zipWith=EC,_d.entries=q1,_d.entriesIn=X1,_d.extend=j1,_d.extendWith=vm,Ey(_d,_d),_d.add=xS,_d.attempt=eb,_d.camelCase=SE,_d.capitalize=J1,_d.ceil=_S,_d.clamp=_E,_d.clone=g2,_d.cloneDeep=y2,_d.cloneDeepWith=b2,_d.cloneWith=m2,_d.conformsTo=w2,_d.deburr=Z1,_d.defaultTo=eS,_d.divide=CS,_d.endsWith=AE,_d.eq=bv,_d.escape=kE,_d.escapeRegExp=TE,_d.every=$C,_d.find=FC,_d.findIndex=C1,_d.findKey=X2,_d.findLast=PC,_d.findLastIndex=E1,_d.findLastKey=J2,_d.floor=ES,_d.forEach=N1,_d.forEachRight=M1,_d.forIn=Z2,_d.forInRight=Q2,_d.forOwn=eE,_d.forOwnRight=tE,_d.get=by,_d.gt=x2,_d.gte=_2,_d.has=iE,_d.hasIn=wy,_d.head=A1,_d.identity=nv,_d.includes=HC,_d.indexOf=P_,_d.inRange=CE,_d.invoke=sE,_d.isArguments=Jv,_d.isArray=mp,_d.isArrayBuffer=C2,_d.isArrayLike=ev,_d.isArrayLikeObject=Vp,_d.isBoolean=E2,_d.isBuffer=Uv,_d.isDate=S2,_d.isElement=A2,_d.isEmpty=k2,_d.isEqual=T2,_d.isEqualWith=R2,_d.isError=my,_d.isFinite=N2,_d.isFunction=Mv,_d.isInteger=B1,_d.isLength=fm,_d.isMap=V1,_d.isMatch=M2,_d.isMatchWith=I2,_d.isNaN=L2,_d.isNative=O2,_d.isNil=D2,_d.isNull=$2,_d.isNumber=W1,_d.isObject=Pp,_d.isObjectLike=Bp,_d.isPlainObject=Ag,_d.isRegExp=yy,_d.isSafeInteger=F2,_d.isSet=U1,_d.isString=pm,_d.isSymbol=av,_d.isTypedArray=cg,_d.isUndefined=P2,_d.isWeakMap=B2,_d.isWeakSet=V2,_d.join=H_,_d.kebabCase=RE,_d.last=vv,_d.lastIndexOf=z_,_d.lowerCase=NE,_d.lowerFirst=ME,_d.lt=W2,_d.lte=U2,_d.max=SS,_d.maxBy=AS,_d.mean=kS,_d.meanBy=TS,_d.min=RS,_d.minBy=NS,_d.stubArray=Ay,_d.stubFalse=ky,_d.stubObject=vS,_d.stubString=gS,_d.stubTrue=mS,_d.multiply=MS,_d.nth=G_,_d.noConflict=sS,_d.noop=Sy,_d.now=cm,_d.pad=IE,_d.padEnd=LE,_d.padStart=OE,_d.parseInt=$E,_d.random=EE,_d.reduce=YC,_d.reduceRight=qC,_d.repeat=DE,_d.replace=FE,_d.result=pE,_d.round=IS,_d.runInContext=Bd,_d.sample=JC,_d.size=e2,_d.snakeCase=PE,_d.some=t2,_d.sortedIndex=Z_,_d.sortedIndexBy=Q_,_d.sortedIndexOf=eC,_d.sortedLastIndex=tC,_d.sortedLastIndexBy=nC,_d.sortedLastIndexOf=rC,_d.startCase=VE,_d.startsWith=WE,_d.subtract=LS,_d.sum=OS,_d.sumBy=$S,_d.template=UE,_d.times=yS,_d.toFinite=Iv,_d.toInteger=yp,_d.toLength=z1,_d.toLower=HE,_d.toNumber=gv,_d.toSafeInteger=H2,_d.toString=Ip,_d.toUpper=zE,_d.trim=GE,_d.trimEnd=jE,_d.trimStart=KE,_d.truncate=YE,_d.unescape=qE,_d.uniqueId=wS,_d.upperCase=XE,_d.upperFirst=xy,_d.each=N1,_d.eachRight=M1,_d.first=A1,Ey(_d,function(){var sn={};return xv(_d,function(hn,co){Lp.call(_d.prototype,co)||(sn[co]=hn)}),sn}(),{chain:!1}),_d.VERSION=$e,cv(["bind","bindKey","curry","curryRight","partial","partialRight"],function(sn){_d[sn].placeholder=_d}),cv(["drop","take"],function(sn,hn){Ep.prototype[sn]=function(co){co=co===v?1:Hp(yp(co),0);var fd=this.__filtered__&&!hn?new Ep(this):this.clone();return fd.__filtered__?fd.__takeCount__=Yp(co,fd.__takeCount__):fd.__views__.push({size:Yp(co,gd),type:sn+(fd.__dir__<0?"Right":"")}),fd},Ep.prototype[sn+"Right"]=function(co){return this.reverse()[sn](co).reverse()}}),cv(["filter","map","takeWhile"],function(sn,hn){var co=hn+1,fd=co==uo||co==fo;Ep.prototype[sn]=function(md){var Ad=this.clone();return Ad.__iteratees__.push({iteratee:cp(md,3),type:co}),Ad.__filtered__=Ad.__filtered__||fd,Ad}}),cv(["head","last"],function(sn,hn){var co="take"+(hn?"Right":"");Ep.prototype[sn]=function(){return this[co](1).value()[0]}}),cv(["initial","tail"],function(sn,hn){var co="drop"+(hn?"":"Right");Ep.prototype[sn]=function(){return this.__filtered__?new Ep(this):this[co](1)}}),Ep.prototype.compact=function(){return this.filter(nv)},Ep.prototype.find=function(sn){return this.filter(sn).head()},Ep.prototype.findLast=function(sn){return this.reverse().find(sn)},Ep.prototype.invokeMap=xp(function(sn,hn){return typeof sn=="function"?new Ep(this):this.map(function(co){return wg(co,sn,hn)})}),Ep.prototype.reject=function(sn){return this.filter(hm(cp(sn)))},Ep.prototype.slice=function(sn,hn){sn=yp(sn);var co=this;return co.__filtered__&&(sn>0||hn<0)?new Ep(co):(sn<0?co=co.takeRight(-sn):sn&&(co=co.drop(sn)),hn!==v&&(hn=yp(hn),co=hn<0?co.dropRight(-hn):co.take(hn-sn)),co)},Ep.prototype.takeRightWhile=function(sn){return this.reverse().takeWhile(sn).reverse()},Ep.prototype.toArray=function(){return this.take(gd)},xv(Ep.prototype,function(sn,hn){var co=/^(?:filter|find|map|reject)|While$/.test(hn),fd=/^(?:head|last)$/.test(hn),md=_d[fd?"take"+(hn=="last"?"Right":""):hn],Ad=fd||/^find/.test(hn);md&&(_d.prototype[hn]=function(){var Md=this.__wrapped__,Pd=fd?[1]:arguments,Vd=Md instanceof Ep,qd=Pd[0],Xd=Vd||mp(Md),Zd=function(Cp){var Tp=md.apply(_d,$v([Cp],Pd));return fd&&tp?Tp[0]:Tp};Xd&&co&&typeof qd=="function"&&qd.length!=1&&(Vd=Xd=!1);var tp=this.__chain__,sp=!!this.__actions__.length,dp=Ad&&!tp,wp=Vd&&!sp;if(!Ad&&Xd){Md=wp?Md:new Ep(this);var hp=sn.apply(Md,Pd);return hp.__actions__.push({func:um,args:[Zd],thisArg:v}),new hv(hp,tp)}return dp&&wp?sn.apply(this,Pd):(hp=this.thru(Zd),dp?fd?hp.value()[0]:hp.value():hp)})}),cv(["pop","push","shift","sort","splice","unshift"],function(sn){var hn=Og[sn],co=/^(?:push|sort|unshift)$/.test(sn)?"tap":"thru",fd=/^(?:pop|shift)$/.test(sn);_d.prototype[sn]=function(){var md=arguments;if(fd&&!this.__chain__){var Ad=this.value();return hn.apply(mp(Ad)?Ad:[],md)}return this[co](function(Md){return hn.apply(mp(Md)?Md:[],md)})}}),xv(Ep.prototype,function(sn,hn){var co=_d[hn];if(co){var fd=co.name+"";Lp.call(og,fd)||(og[fd]=[]),og[fd].push({name:hn,func:co})}}),og[tm(v,un).name]=[{name:"wrapper",func:v}],Ep.prototype.clone=qw,Ep.prototype.reverse=Xw,Ep.prototype.value=Jw,_d.prototype.at=AC,_d.prototype.chain=kC,_d.prototype.commit=TC,_d.prototype.next=RC,_d.prototype.plant=MC,_d.prototype.reverse=IC,_d.prototype.toJSON=_d.prototype.valueOf=_d.prototype.value=LC,_d.prototype.first=_d.prototype.head,fg&&(_d.prototype[fg]=NC),_d},ng=Tw();Hv?((Hv.exports=ng)._=ng,Cm._=ng):jp._=ng}).call(lodash)}(lodash$1,lodash$1.exports)),lodash$1.exports}var lodashExports=requireLodash();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),Ge=$e.length,je=new Uint8Array(Ge);for(;Ge--;)je[Ge]=$e.charCodeAt(Ge);return new File([je],y,{type:v})}async function waterImage(m,y={text:"",fontSize:40,font:"宋体",color:"rgba(255, 255, 255, 0.5)",opacity:.5,spacing:200,angle:20,autoSize:!1,rate:null},v){lodashExports.defaults(y,{text:"",fontSize:40,font:"宋体",color:"rgba(255, 255, 255, 0.5)",opacity:.5,spacing:200,angle:20,autoSize:!1,rate:null});const $e=await new Promise((Ke,Qe)=>{const Je=new Image;Je.crossOrigin="anonymous",Je.onload=()=>Ke(Je),Je.onerror=Qe,Je.src=m}),Ge=document.createElement("canvas");Ge.width=$e.naturalWidth,Ge.height=$e.naturalHeight;const je=Ge.getContext("2d");if(je.drawImage($e,0,0),y.text&&y.text.trim()){let{text:Ke,fontSize:Qe,font:Je,color:st,opacity:Mt,spacing:nn,angle:rn,autoSize:on,rate:an}=y;if(on){const fn=$e.naturalWidth;an=an||32/375,Qe=an*fn,Qe=Math.max(12,Math.min(Qe,100)),nn=Qe*6,nn=Math.max(100,Math.min(nn,1e3)),console.log(`自动适配: 图片宽度=${fn}px, 文字大小=${Qe.toFixed(2)}px, 间距=${nn.toFixed(2)}px`)}je.save(),je.font=`${Qe}px ${Je}`,je.fillStyle=st,je.globalAlpha=Mt,je.measureText(Ke).width;const un=Math.ceil(Ge.width/nn)+1,ln=Math.ceil(Ge.height/nn)+1;for(let fn=0;fn<un;fn++)for(let cn=0;cn<ln;cn++){const Xr=fn*nn,Mi=cn*nn;je.save(),je.translate(Xr,Mi),rn!==0&&je.rotate(rn*Math.PI/180),je.fillText(Ke,0,0),je.restore()}je.restore()}const Ye=Ge.toDataURL("image/jpeg",.9),qe=getBase64ImageSize(Ye);console.log("waterImage 处理后大小(字节):",qe),v&&v(base64toFile(Ye.split(",")[1],"water-masked.jpg","image/jpeg"))}const fun=(m,y,v,$e={text:""})=>y.then(Ge=>(Ge instanceof File&&(m=Ge),/^image\/\w+/.test(m.type)?new Promise((je,Ye)=>{let qe=v.fileList.filter(Ke=>Ke.raw&&Ke.raw==m)[0];if(!qe){Ye();return}qe.message="水印处理中...",waterImage(URL.createObjectURL(m),$e,Ke=>{qe.message="",setBaseProps(Ke,qe.raw),qe.raw=Ke,je(qe.raw)})}):!0)),uploadProcess={compress:fun$2,face:fun$1,water:fun};function useOssUploader(m,y,v={fileType:[],requireMd5:!1,request:null,signatureUrl:"",addFileMd5Url:"",queryFileMd5Url:"",beginUploadFlow:[]}){let $e=1;const Ge=async function(Qe){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})},je=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 je(st.name);if(on.code!==200)throw new Error("Get signature error");const an=on.data,{accessid:un,policy:ln,signature:fn,dir:cn,host:Xr}=an;let Mi=new FormData;return Mi.append("key",cn),Mi.append("policy",ln),Mi.append("OSSAccessKeyId",un),Mi.append("success_action_status","200"),Mi.append("signature",fn),Mi.append("file",st),await axios.create({onUploadProgress:ld=>{ld.percent=ld.total>0?ld.loaded/ld.total*100:0,Mt(ld)}}).post(Xr,Mi,{headers:{"Content-Type":"multipart/form-data"}}).then(ld=>({code:200,fileName:Xr+cn}))},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=>{Ge(an)}),new Error("文件已存在")}else return Qe.md5=nn,!0})));for(let nn of v.beginUploadFlow)typeof nn=="string"?Mt=uploadProcess[nn](Qe,Mt,Ke):typeof nn=="object"&&nn instanceof Object&&(Mt=uploadProcess[nn.name](Qe,Mt,Ke,nn));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,Ge(Qe),v.requireMd5&&Ye({filePath:Qe.url,mdaValue:Qe.raw.md5}))},init:function(Qe){console.log("init oss upload....",Qe),Qe=Qe||"";const Je=Array.isArray(Qe)?Qe:Qe.length?Qe.split(","):[];Ke.fileList=Je.map(st=>{const Mt=typeof st=="string"?st:st.url,nn=Ke.fileList.find(on=>on.url===Mt);if(nn)return nn;let rn=typeof st=="string"?{name:st,url:st}:{...st};return rn.uid=rn.uid||new Date().getTime()+$e++,rn.status="success",rn}),Ke.fileList.map(st=>{Ge(st)})},md5(Qe){return new Promise((Je,st)=>{const Mt=Qe.raw,rn=Math.ceil(Mt.size/10),on=new FileReader,an=new SparkMD5;let un=0;const ln=()=>{const fn=Mt.slice(un,un+rn);on.readAsBinaryString(fn)};on.onload=fn=>{an.appendBinary(fn.target.result),un<Mt.size?(un+=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,Ge]}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(),Ge=y;vue.ref(0),vue.ref([]);const je=vue.ref([]),Ye=vue.computed(()=>v.isShowTip&&(v.fileType||v.fileMaxSize)),qe=vue.inject("request"),[Ke]=useOssUploader("",je,{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=()=>{(je.value.length==0||je.value.every(Mt=>Mt.status=="success"))&&Ge("update:modelValue",Array.isArray(v.modelValue)?je.value:Qe(je.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 je.value=[]},{deep:!0,immediate:!0}),vue.watch(()=>je.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]=un=>vue.unref(Ke).fileList=un),"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 Ge=null;const je=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:fo}=v;return fo.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:fo,deg:ho,offsetX:hd,offsetY:dd,rotateX:pd,rotateY:gd,enableTransition:Sd}=Je.value,yd={transform:`scale(${fo}) rotate(${ho}deg) rotateX(${pd}deg) rotateY(${gd}deg)`,transition:Sd?"transform .3s":"",marginLeft:`${hd}px`,marginTop:`${dd}px`};return Qe.value.name===Mode.CONTAIN.name&&(yd.maxWidth="100%",yd.maxHeight="100%"),yd});function an(){$e("close")}function un(){je.value=!1,Ye.value=!0}function ln(){je.value=!1}function fn(fo){let ho=!1;return function(...hd){ho||(ho=!0,window.requestAnimationFrame(()=>{fo.apply(this,hd),ho=!1}))}}const cn=function(fo,ho,hd,dd=!1){fo&&ho&&hd&&fo.addEventListener(ho,hd,dd)},Xr=function(fo,ho,hd,dd=!1){fo&&ho&&hd&&fo.removeEventListener(ho,hd,dd)};function Mi(fo){if(je.value||fo.button!==0)return;const{offsetX:ho,offsetY:hd}=Je.value,dd=fo.pageX,pd=fo.pageY;Ge=fn(gd=>{Je.value={...Je.value,offsetX:ho+gd.pageX-dd,offsetY:hd+gd.pageY-pd}}),cn(document,"mousemove",Ge),cn(document,"mouseup",()=>{Xr(document,"mousemove",Ge)}),fo.preventDefault()}function to(){Je.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1,rotateX:0,rotateY:0}}function ld(fo,ho={}){if(je.value)return;const{zoomRate:hd,rotateDeg:dd,rotateXDeg:pd,rotateYDeg:gd,enableTransition:Sd}={zoomRate:.2,rotateDeg:90,rotateXDeg:180,rotateYDeg:180,enableTransition:!0,...ho};if(fo==="zoomOut")Je.value.scale>.2&&(Je.value.scale=parseFloat((Je.value.scale-hd).toFixed(3)));else if(fo==="zoomIn")Je.value.scale=parseFloat((Je.value.scale+hd).toFixed(3));else if(fo==="clocelise")Je.value.deg+=dd;else if(fo==="anticlocelise")Je.value.deg-=dd;else if(fo==="fliphorizontal"){let yd=Je.value.deg!=0&&Math.abs(Je.value.deg)/dd%2!=0?"rotateX":"rotateY";Je.value[yd]=Je.value[yd]?0:gd}else if(fo==="flipvertical"){let yd=Je.value.deg!=0&&Math.abs(Je.value.deg)/dd%2!=0?"rotateY":"rotateX";Je.value[yd]=Je.value[yd]?0:pd}Je.value.enableTransition=Sd}function od(){if(je.value)return;const fo=Object.keys(Mode),ho=Object.values(Mode),hd=Qe.value.name,pd=(ho.findIndex(gd=>gd.name===hd)+1)%fo.length;Qe.value=Mode[fo[pd]],to()}function Uo(){if(Mt.value&&!v.infinite)return;const fo=v.urls.length;qe.value=(qe.value-1+fo)%fo,Ye.value=!1}function vd(){if(nn.value&&!v.infinite)return;const fo=v.urls.length;qe.value=(qe.value+1)%fo,Ye.value=!1}let rd=null,mo=null;const uo=()=>{rd=fn(ho=>{switch(ho.keyCode){case 27:an();break;case 32:od();break;case 37:this.prev();break;case 38:ld("zoomIn");break;case 39:this.next();break;case 40:ld("zoomOut");break}});let fo=fn(ho=>{(ho.wheelDelta?ho.wheelDelta:-ho.detail)>0?ld("zoomIn",{zoomRate:.09,enableTransition:!1}):ld("zoomOut",{zoomRate:.09,enableTransition:!1})});cn(document,"keydown",rd),cn(document,mousewheelEventName,fo)},lo=()=>{Xr(document,"keydown",rd),Xr(document,mousewheelEventName,mo),rd=null,mo=null};return vue.watch(rn,()=>{vue.nextTick(()=>{Ke.value.complete||(je.value=!0)})}),vue.watch(qe,fo=>{to(),$e("change",fo)}),vue.onMounted(()=>{vue.nextTick(()=>{const fo=document.querySelector("body");fo.append?fo.append(document.getElementById("x-image-viewer")):fo.appendChild(document.getElementById("x-image-viewer")),uo()})}),vue.onUnmounted(()=>{document.querySelector("body").removeChild(document.getElementById("x-image-viewer")),lo()}),(fo,ho)=>{const hd=vue.resolveComponent("el-icon-close"),dd=vue.resolveComponent("el-icon"),pd=vue.resolveComponent("el-icon-zoom-out"),gd=vue.resolveComponent("el-icon-zoom-in"),Sd=vue.resolveComponent("el-icon-refresh-left"),yd=vue.resolveComponent("el-icon-refresh-right"),Td=vue.resolveComponent("el-icon-switch"),Nd=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:ho[0]||(ho[0]=vue.withModifiers($d=>m.hideOnClickModal&&an(),["self"]))}),vue.createElementVNode("span",{class:"x-image-viewer__btn x-image-viewer__close",onClick:an},[vue.createVNode(dd,null,{default:vue.withCtx(()=>[vue.createVNode(hd)]),_: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:Uo},ho[7]||(ho[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:vd},ho[8]||(ho[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(dd,{onClick:ho[1]||(ho[1]=$d=>ld("zoomOut"))},{default:vue.withCtx(()=>[vue.createVNode(pd)]),_:1}),vue.createVNode(dd,{onClick:ho[2]||(ho[2]=$d=>ld("zoomIn"))},{default:vue.withCtx(()=>[vue.createVNode(gd)]),_:1}),ho[9]||(ho[9]=vue.createElementVNode("i",{class:"x-image-viewer__actions__divider"},null,-1)),vue.createVNode(dd,{onClick:od},{default:vue.withCtx(()=>[(vue.openBlock(),vue.createBlock(vue.resolveDynamicComponent(Qe.value.icon)))]),_:1}),ho[10]||(ho[10]=vue.createElementVNode("i",{class:"x-image-viewer__actions__divider"},null,-1)),vue.createVNode(dd,{onClick:ho[3]||(ho[3]=$d=>ld("anticlocelise"))},{default:vue.withCtx(()=>[vue.createVNode(Sd)]),_:1}),vue.createVNode(dd,{onClick:ho[4]||(ho[4]=$d=>ld("clocelise"))},{default:vue.withCtx(()=>[vue.createVNode(yd)]),_:1}),vue.createVNode(dd,{onClick:ho[5]||(ho[5]=$d=>ld("fliphorizontal"))},{default:vue.withCtx(()=>[vue.createVNode(Td)]),_:1}),vue.createVNode(dd,{onClick:ho[6]||(ho[6]=$d=>ld("flipvertical"))},{default:vue.withCtx(()=>[vue.createVNode(Nd)]),_: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,($d,Wd)=>vue.withDirectives((vue.openBlock(),vue.createElementBlock("img",{ref_for:!0,ref_key:"img",ref:Ke,key:$d,src:rn.value.src,style:vue.normalizeStyle(on.value),class:"x-image-viewer__img",onLoad:un,onError:ln,onMousedown:Mi},null,44,_hoisted_5$2)),[[vue.vShow,Wd===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,Ge=vue.useAttrs(),je=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(uo,lo){let fo="";lo=lo||",";for(let ho in uo)uo[ho].url!==void 0&&uo[ho].url.indexOf("blob:")!==0&&(fo+=uo[ho].url+lo);return fo!=""?fo.substr(0,fo.length-1):""}function un(uo){console.log("enter"),uo.preventDefault()}function ln(uo){console.log("over"),uo.preventDefault(),setTimeout(()=>{uo.target.classList.add("over")},0)}function fn(uo){console.log("drop"),uo.preventDefault(),$e.onDrop&&$e.onDrop(uo)}function cn(uo){$e.onBackPool&&$e.onBackPool(uo)}function Xr(uo){vd(uo)}function Mi(uo){Mt.value=[],Mt.value.push({src:uo.url,desc:""}),st.value=!0}function to(uo,lo){let fo=[];for(let ho=0;ho<uo.length;ho++){fo[ho]=[];for(let hd=0;hd<lo[0].length;hd++){let dd=0;for(let pd=0;pd<uo[0].length;pd++)dd+=uo[ho][pd]*lo[pd][hd];fo[ho][hd]=dd}}return fo}function ld(uo,lo){let fo=uo.hd=uo.hd||0,ho=uo.vd=uo.vd||0,hd=uo.deg=uo.deg||0,dd=uo.viewBox,pd=uo.matrix;if(lo=="rotateleft"){hd+=90;let gd=[[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]];pd=to(pd,gd),uo.viewBox=od(uo.hd!=fo,uo.vd!=ho,90,dd)}else if(lo=="rotateright"){hd-=90;let gd=[[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]];pd=to(pd,gd),uo.viewBox=od(uo.hd!=fo,uo.vd!=ho,-90,dd)}else lo=="fliphorizontal"?(fo=fo?0:1,pd=to(pd,[[-1,0],[0,1],[0,0]])):lo=="flipvertical"&&(ho=ho?0:1,pd=to(pd,[[1,0],[0,-1],[0,0]]));uo.matrix=pd,uo.deg=hd,uo.hd=fo,uo.vd=ho}function od(uo,lo,fo,ho){let hd=JSON.parse(JSON.stringify(ho));const[dd,pd,gd,Sd]=ho;if(uo==!0&&(hd[0]=hd[0]==0-gd?0:0-gd),lo==!0&&(hd[1]=hd[1]==0-Sd?0:0-Sd),fo){let yd=fo/90%4;for(let Td=0;Td<Math.abs(yd);Td++)if(hd[2]=Sd,hd[3]=gd,fo>0){let Nd=hd[1];hd[1]=hd[0]==0-gd?0:0-gd,hd[0]=Nd}else{let Nd=hd[1];hd[1]=hd[0],hd[0]=Nd==0-Sd?0:0-Sd}}return hd}const Uo=uo=>{Ye.value.push(uo)},vd=uo=>{Ye.value.indexOf(uo)!=-1&&Ye.value.splice(Ye.value.indexOf(uo),1)},rd=()=>{(Ye.value.length==0||Ye.value.every(uo=>uo.status=="success"))&&je("update:modelValue",Array.isArray($e.modelValue)?Ye.value:an(Ye.value))};function mo(uo,lo,fo){lo.url=lo.response.fileName,rd()}return vue.watch(()=>$e.modelValue,uo=>{if(uo)Qe.init(uo);else return Ye.value=[]},{deep:!0,immediate:!0}),vue.watch(()=>Ye.value.length,()=>{console.log("imageupload filelist changed....."),rd()}),y({pushFile:Uo,removeFile:vd}),(uo,lo)=>{const fo=vue.resolveComponent("el-icon"),ho=vue.resolveComponent("el-upload"),hd=vue.resolveComponent("sy-svg-icon"),dd=vue.resolveComponent("sy-image-view");return vue.openBlock(),vue.createElementBlock("div",_hoisted_1$2,[vue.createElementVNode("div",_hoisted_2$2,[vue.createVNode(ho,vue.mergeProps({multiple:m.multipleSelect,ref:"imageUpload","show-file-list":!1,"file-list":Ye.value,"onUpdate:fileList":lo[0]||(lo[0]=pd=>Ye.value=pd),"http-request":vue.unref(Qe).onHttpRequest,"list-type":"picture-card",limit:m.limit,"on-success":mo,"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(Ge),{onDragenter:un,onDragover:ln,onDrop:fn,"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(fo,{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,pd=>(vue.openBlock(),vue.createElementBlock("div",{key:pd.uid,class:"el-upload--picture-card",style:vue.normalizeStyle("width:"+m.size.width+";height:"+m.size.height+";")},[pd.status=="ready"||pd.status=="uploading"||pd.loading?(vue.openBlock(),vue.createElementBlock("div",_hoisted_3$1,[vue.createVNode(hd,{"class-name":"icon-down","icon-class":"down"}),vue.createElementVNode("div",_hoisted_4$1,[pd.status=="uploading"?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:0},[vue.createTextVNode("上传进度"+vue.toDisplayString(parseInt(pd.percentage||0))+"%",1)],64)):vue.createCommentVNode("",!0),pd.loading?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[vue.createTextVNode("加载进度"+vue.toDisplayString(parseInt(pd.loadingPercent||0))+"%",1)],64)):vue.createCommentVNode("",!0),pd.message?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:2},[vue.createTextVNode(vue.toDisplayString(pd.message),1)],64)):vue.createCommentVNode("",!0)])])):vue.createCommentVNode("",!0),pd.status=="success"&&!pd.loading?(vue.openBlock(),vue.createElementBlock(vue.Fragment,{key:1},[pd.loadError?vue.createCommentVNode("",!0):(vue.openBlock(),vue.createElementBlock("div",{key:0,onClick:gd=>Mi(pd),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:pd.objUrl,fit:"contain"},null,8,_hoisted_7$1)):(vue.openBlock(),vue.createElementBlock("svg",{key:1,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",viewBox:pd.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("+pd.matrix.join(",")+")"},[vue.createElementVNode("image",{"xlink:href":pd.objUrl,x:"0",y:"0",width:pd.width,height:pd.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(hd,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(gd=>cn(pd),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.back]]),vue.withDirectives(vue.createElementVNode("div",_hoisted_14$1,[vue.createVNode(hd,{"class-name":"icon-photo ","icon-class":"close",onClick:vue.withModifiers(gd=>Xr(pd),["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(hd,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(gd=>ld(pd,"rotateleft"),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.rotateLeft]]),vue.withDirectives(vue.createElementVNode("div",_hoisted_17$1,[vue.createVNode(hd,{"class-name":"icon-photo","icon-class":"right-arrow",onClick:vue.withModifiers(gd=>ld(pd,"rotateright"),["stop"])},null,8,["onClick"])],512),[[vue.vShow,m.operations.rotateRight]])])])],8,_hoisted_5$1)),pd.loadError?(vue.openBlock(),vue.createElementBlock("div",{key:1,onClick:gd=>vue.unref(Je)(pd),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(dd,{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,Ge,je){return vue.openBlock(),vue.createElementBlock("svg",{class:vue.normalizeClass(je.svgClass),"aria-hidden":"true"},[vue.createElementVNode("use",{"xlink:href":je.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 Ge=m,je={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=cn=>{cn&&Ye.value.push(cn)},Je=vue.computed(()=>Ye.value[Ke.value]),st=vue.ref([]),Mt=cn=>{cn.target.focus(),console.log("focus:"+cn.target.id),Ke.value=Array.from($e.value.children).indexOf(cn.target);const Xr=Je.value.attributes.id.value;v.value.hasOwnProperty(Xr)?st.value=JSON.parse(JSON.stringify(v.value[Xr])):st.value=[],qe.value=!0},nn=cn=>{cn.target.classList.contains("tooth")&&console.log("blur:"+cn.target.id)},rn=cn=>{const Xr={};return cn&&cn.split(".").forEach(Mi=>{const[to,ld]=Mi.split("|");Xr[to]=ld?ld.split(","):[]}),Xr},on=()=>{const cn=Object.keys(v.value).reduce((Xr,Mi)=>(Xr.push(Mi+"|"+v.value[Mi].join(",")),Xr),[]).join(".");y.value=cn,console.log(cn)},an=cn=>v.value.hasOwnProperty(cn)?v.value[cn].length==0?["green"]:v.value[cn].map(Mi=>Ge.symptomItems.filter(ld=>ld.value==Mi)[0].color||"green"):["white"],un=cn=>v.value.hasOwnProperty(cn)?"url(#pos-"+cn+")":"white",ln=()=>{const cn=Je.value.attributes.id.value;v.value[cn]=st.value,qe.value=!1},fn=()=>{delete v.value[Je.value.attributes.id.value],qe.value=!1};return vue.onMounted(()=>{v.value=rn(y.value)}),vue.watch(()=>y.value,cn=>{v.value=rn(y.value)}),vue.watch(()=>v.value,cn=>{on()},{deep:!0}),(cn,Xr)=>{const Mi=vue.resolveComponent("el-checkbox"),to=vue.resolveComponent("el-checkbox-group"),ld=vue.resolveComponent("el-button"),od=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(je[4][0])}]),id:je[4][0],fill:un(je[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(je[4][1])}]),id:je[4][1],fill:un(je[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(je[4][2])}]),id:je[4][2],fill:un(je[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(je[4][3])}]),id:je[4][3],fill:un(je[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(je[4][4])}]),id:je[4][4],fill:un(je[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(je[4][5])}]),id:je[4][5],fill:un(je[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(je[4][6])}]),id:je[4][6],fill:un(je[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(je[4][7])}]),id:je[4][7],fill:un(je[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(je[3][7])}]),id:je[3][7],fill:un(je[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(je[3][6])}]),id:je[3][6],fill:un(je[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(je[3][5])}]),id:je[3][5],fill:un(je[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(je[3][4])}]),id:je[3][4],fill:un(je[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(je[3][3])}]),id:je[3][3],fill:un(je[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(je[3][2])}]),id:je[3][2],fill:un(je[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(je[3][1])}]),id:je[3][1],fill:un(je[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(je[3][0])}]),id:je[3][0],fill:un(je[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(je[2][7])}]),id:je[2][7],fill:un(je[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(je[2][6])}]),id:je[2][6],fill:un(je[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(je[2][5])}]),id:je[2][5],fill:un(je[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(je[2][4])}]),id:je[2][4],fill:un(je[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(je[2][3])}]),id:je[2][3],fill:un(je[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(je[2][2])}]),id:je[2][2],fill:un(je[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(je[2][1])}]),id:je[2][1],fill:un(je[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(je[2][0])}]),id:je[2][0],fill:un(je[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(je[1][0])}]),id:je[1][0],fill:un(je[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(je[1][1])}]),id:je[1][1],fill:un(je[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(je[1][2])}]),id:je[1][2],fill:un(je[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(je[1][3])}]),id:je[1][3],fill:un(je[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(je[1][4])}]),id:je[1][4],fill:un(je[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(je[1][5])}]),id:je[1][5],fill:un(je[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(je[1][6])}]),id:je[1][6],fill:un(je[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(je[1][7])}]),id:je[1][7],fill:un(je[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(je[8][0])}]),id:je[8][0],fill:un(je[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(je[8][1])}]),id:je[8][1],fill:un(je[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(je[8][2])}]),id:je[8][2],fill:un(je[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(je[8][3])}]),id:je[8][3],fill:un(je[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(je[8][4])}]),id:je[8][4],fill:un(je[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(je[7][4])}]),id:je[7][4],fill:un(je[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(je[7][3])}]),id:je[7][3],fill:un(je[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(je[7][2])}]),id:je[7][2],fill:un(je[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(je[7][1])}]),id:je[7][1],fill:un(je[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(je[7][0])}]),id:je[7][0],fill:un(je[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(je[6][4])}]),id:je[6][4],fill:un(je[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(je[6][3])}]),id:je[6][3],fill:un(je[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(je[6][2])}]),id:je[6][2],fill:un(je[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(je[6][1])}]),id:je[6][1],fill:un(je[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(je[6][0])}]),id:je[6][0],fill:un(je[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(je[5][0])}]),id:je[5][0],fill:un(je[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(je[5][1])}]),id:je[5][1],fill:un(je[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(je[5][2])}]),id:je[5][2],fill:un(je[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(je[5][3])}]),id:je[5][3],fill:un(je[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(je[5][4])}]),id:je[5][4],fill:un(je[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),Xr[2]||(Xr[2]=vue.createElementVNode("path",{class:"tooth",fill:"white",d:"M29.8787 152.908H665.063",stroke:"#CCE6FB","stroke-width":"2"},null,-1)),Xr[3]||(Xr[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),Uo=>(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,[v.value[Uo]?(vue.openBlock(),vue.createElementBlock("linearGradient",{key:0,id:"pos-"+Uo,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(an(Uo),(vd,rd)=>(vue.openBlock(),vue.createElementBlock("stop",{key:rd,offset:`${rd/(an(Uo).length-1||1)*100}%`,"stop-color":vd},null,8,_hoisted_55))),128))],8,_hoisted_54)):vue.createCommentVNode("",!0)],64))),256))])],544)),vue.createVNode(od,{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":Xr[0]||(Xr[0]=Uo=>st.value=Uo)},{default:vue.withCtx(()=>[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(m.symptomItems,Uo=>(vue.openBlock(),vue.createBlock(Mi,{label:Uo.label,value:Uo.value},null,8,["label","value"]))),256))]),_:1},8,["modelValue"])]),vue.createElementVNode("div",_hoisted_56,[vue.createVNode(ld,{size:"small",text:"",onClick:fn},{default:vue.withCtx(()=>Xr[4]||(Xr[4]=[vue.createTextVNode("清除")])),_:1}),vue.createVNode(ld,{size:"small",text:"",onClick:Xr[1]||(Xr[1]=Uo=>qe.value=!1)},{default:vue.withCtx(()=>Xr[5]||(Xr[5]=[vue.createTextVNode("取消")])),_:1}),vue.createVNode(ld,{size:"small",type:"primary",onClick:ln},{default:vue.withCtx(()=>Xr[6]||(Xr[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 nC } from "vue";
|
|
2
2
|
import { g as rC, c as ts } from "./_commonjsHelpers-DaMA6jEr.js";
|
|
3
|
-
import { E as oC } from "./index-
|
|
3
|
+
import { E as oC } from "./index-DOSmBh1u.js";
|
|
4
4
|
function Ov(r, t) {
|
|
5
5
|
return function() {
|
|
6
6
|
return r.apply(t, arguments);
|
|
@@ -21136,7 +21136,7 @@ async function hN(r, t, e = "/models") {
|
|
|
21136
21136
|
const s = i.toDataURL("image/jpeg", 0.9), c = uN(s);
|
|
21137
21137
|
console.log("faceMaskImage 处理后大小(字节):", c), t && t(cN(s.split(",")[1], "face-masked.jpg", "image/jpeg"));
|
|
21138
21138
|
}
|
|
21139
|
-
const pN = (r, t, e) => t.then((n) => /^image\/\w+/.test(r.type) ? new Promise((o, i) => {
|
|
21139
|
+
const pN = (r, t, e) => t.then((n) => (n instanceof File && (r = n), /^image\/\w+/.test(r.type) ? new Promise((o, i) => {
|
|
21140
21140
|
let a = e.fileList.filter((s) => s.raw && s.raw == r)[0];
|
|
21141
21141
|
if (!a) {
|
|
21142
21142
|
i();
|
|
@@ -21147,9 +21147,11 @@ const pN = (r, t, e) => t.then((n) => /^image\/\w+/.test(r.type) ? new Promise((
|
|
|
21147
21147
|
o(r);
|
|
21148
21148
|
return;
|
|
21149
21149
|
}
|
|
21150
|
-
Bl(s, a.raw), a.raw = s
|
|
21150
|
+
Bl(s, a.raw), a.raw = s;
|
|
21151
|
+
debugger;
|
|
21152
|
+
o(a.raw);
|
|
21151
21153
|
});
|
|
21152
|
-
}) : !0);
|
|
21154
|
+
}) : !0));
|
|
21153
21155
|
var Gi = { exports: {} };
|
|
21154
21156
|
/**
|
|
21155
21157
|
* @license
|
|
@@ -24892,7 +24894,7 @@ async function xN(r, t = {
|
|
|
24892
24894
|
const a = o.toDataURL("image/jpeg", 0.9), s = mN(a);
|
|
24893
24895
|
console.log("waterImage 处理后大小(字节):", s), e && e(yN(a.split(",")[1], "water-masked.jpg", "image/jpeg"));
|
|
24894
24896
|
}
|
|
24895
|
-
const bN = (r, t, e, n = { text: "" }) => t.then((o) => /^image\/\w+/.test(r.type) ? new Promise((i, a) => {
|
|
24897
|
+
const bN = (r, t, e, n = { text: "" }) => t.then((o) => (o instanceof File && (r = o), /^image\/\w+/.test(r.type) ? new Promise((i, a) => {
|
|
24896
24898
|
let s = e.fileList.filter((c) => c.raw && c.raw == r)[0];
|
|
24897
24899
|
if (!s) {
|
|
24898
24900
|
a();
|
|
@@ -24901,7 +24903,7 @@ const bN = (r, t, e, n = { text: "" }) => t.then((o) => /^image\/\w+/.test(r.typ
|
|
|
24901
24903
|
s.message = "水印处理中...", xN(URL.createObjectURL(r), n, (c) => {
|
|
24902
24904
|
s.message = "", Bl(c, s.raw), s.raw = c, i(s.raw);
|
|
24903
24905
|
});
|
|
24904
|
-
}) : !0), Pv = {
|
|
24906
|
+
}) : !0)), Pv = {
|
|
24905
24907
|
compress: WE,
|
|
24906
24908
|
face: pN,
|
|
24907
24909
|
water: bN
|
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-Bag_JJe4.js";
|
|
5
|
+
import { E as ElMessage } from "./index-DOSmBh1u.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-C1OyATSu.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-Bag_JJe4.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-Bag_JJe4.js";
|
|
3
3
|
import { _ as Z } from "./index-C1OyATSu.js";
|
|
4
4
|
import O from "vuedraggable";
|
|
5
5
|
import { _ as h } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|